@fluixi/dom 1.0.0-alpha.83 → 1.0.0-alpha.85
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 +2 -2
- 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.js +3 -3
- 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 +11 -11
- package/dist/lib/dom/island.mjs +769 -1
- package/dist/lib/dom/runtime.cjs +1432 -1
- package/dist/lib/dom/runtime.d.ts +60 -17
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +122 -79
- 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 +6 -0
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.js +7 -1
- 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 +23 -15
- 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 +2 -2
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +4 -115
- 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 +3 -3
- 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 +6 -6
- 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/lib/dom/index.cjs
CHANGED
|
@@ -1 +1,2040 @@
|
|
|
1
|
-
"use strict";var oe=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ue=Object.prototype.hasOwnProperty;var Ye=(e,t)=>{for(var n in t)oe(e,n,{get:t[n],enumerable:!0})},Ze=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ze(t))!Ue.call(e,r)&&r!==n&&oe(e,r,{get:()=>t[r],enumerable:!(o=Xe(t,r))||o.enumerable});return e};var Qe=e=>Ze(oe({},"__esModule",{value:!0}),e);var An={};Ye(An,{Island:()=>Be,JSX_PROPERTIES:()=>H,SVG_ELEMENTS:()=>it,SVG_NAMESPACE:()=>I,VOID_ELEMENTS:()=>rt,addClass:()=>ft,addDelegatedEventListener:()=>Ie,addNativeEventListener:()=>ce,appendChildren:()=>xt,applyElementProp:()=>D,applyProps:()=>Qt,applyUse:()=>de,bindPair:()=>fn,captureHydrationCursor:()=>Le,cleanChildren:()=>w,cloneTemplate:()=>He,closest:()=>at,createComponent:()=>dn,createElement:()=>mt,createNativeElement:()=>le,createPortal:()=>nn,createTemplate:()=>De,delegate:()=>Tt,delegateEvents:()=>ue,escapeHTML:()=>sn,fnName:()=>Jt,generateID:()=>Dt,getAttribute:()=>dt,getGlobal:()=>Mt,getLitEventName:()=>nt,getOffset:()=>Et,getStableElementId:()=>It,getStyle:()=>yt,handleRef:()=>ye,hasClass:()=>ct,holeContent:()=>Gt,holeEnd:()=>Bt,holeScope:()=>Wt,hydrate:()=>te,hydrateAdvancePast:()=>Me,hydrateIslands:()=>Ge,initializeIntegration:()=>cn,insert:()=>C,insertExpression:()=>M,intergartionInitialized:()=>pn,isAccessor:()=>an,isCustomElement:()=>he,isDOMNode:()=>Lt,isDelegatedEvent:()=>qt,isDomElement:()=>F,isDomNode:()=>v,isDomText:()=>V,isEventHandler:()=>tt,isFunction:()=>Ft,isIntegrationInitialized:()=>yn,isJSXTemplate:()=>Rt,isLitTemplateResult:()=>Ee,isNativeElement:()=>on,isPromise:()=>P,isReactElement:()=>At,isSVGElement:()=>rn,isServer:()=>E,isTemplateFactory:()=>Ct,isVisible:()=>ht,iterateFn:()=>Xt,makeArrayFlat:()=>je,mergeProps:()=>en,observeIntersection:()=>wt,observeResize:()=>St,query:()=>re,queryAll:()=>st,registerCreateComponent:()=>ln,registerGlobal:()=>Pt,removeAttribute:()=>pt,removeChildren:()=>gt,removeClass:()=>ut,removeDelegatedEventListener:()=>fe,render:()=>me,resetIntegration:()=>mn,runHydrationAt:()=>L,runWithoutHydration:()=>Pe,scrollIntoView:()=>bt,setAttribute:()=>x,setClassList:()=>O,setClassName:()=>k,setDynamicAttribute:()=>J,setDynamicBoolAttribute:()=>pe,setDynamicProperty:()=>X,setProperty:()=>_,setServerMode:()=>Ae,setStyle:()=>$,setStyles:()=>be,shouldSetAsProperty:()=>ot,splitProps:()=>tn,spread:()=>Zt,templateNode:()=>Vt,toAttributeName:()=>et,toggleClass:()=>lt,waitForElement:()=>Nt});module.exports=Qe(An);function et(e){return e.startsWith("aria-")||e.startsWith("data-")?e:/[A-Z]/.test(e)?e.replace(/([A-Z])/g,"-$1").toLowerCase():e}function tt(e){return e.startsWith("@")||e.startsWith("on")&&e.length>2}function nt(e){return e.startsWith("@")?e.slice(1):e.startsWith("on")?e.slice(2).toLowerCase():e}function ot(e,t){let n=new Set(["checked","value","selected","disabled","readonly","required","multiple","open","contenteditable","draggable","spellcheck"]),o={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)||o[e]&&o[e].has(t)}var rt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),it=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"]),I="http://www.w3.org/2000/svg";function he(e){return e.localName.includes("-")}function D(e,t,n,o=!1){if(n==null){e.removeAttribute(t);return}if(he(e)){e[t]=n;return}x(e,t,n,o)}var H=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function re(e,t=document){return t.querySelector(e)}function st(e,t=document){return Array.from(t.querySelectorAll(e))}function at(e,t){return e.closest(t)}function ft(e,...t){e.classList.add(...t)}function ut(e,...t){e.classList.remove(...t)}function lt(e,...t){t.forEach(n=>e.classList.toggle(n))}function ct(e,t){return e.classList.contains(t)}function x(e,t,n,o=!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 dt(e,t){return e.getAttribute(t)}function pt(e,t){e.removeAttribute(t)}function be(e,t){Object.assign(e.style,t)}function yt(e,t){return window.getComputedStyle(e).getPropertyValue(t)}function mt(e,t={},...n){let o=document.createElement(e);return Object.entries(t).forEach(([r,s])=>{if(r==="class"||r==="className")o.className=s;else if(r==="style"&&typeof s=="object")be(o,s);else if(r.startsWith("on")&&typeof s=="function"){let a=r.slice(2).toLowerCase();o.addEventListener(a,s)}else x(o,r,s)}),n.forEach(r=>{typeof r=="string"?o.appendChild(document.createTextNode(r)):o.appendChild(r)}),o}function gt(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function xt(e,...t){t.forEach(n=>{typeof n=="string"?e.appendChild(document.createTextNode(n)):e.appendChild(n)})}function ht(e){let t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=window.innerHeight&&t.right<=window.innerWidth}function bt(e,t={behavior:"smooth",block:"nearest"}){e.scrollIntoView(t)}function Et(e){let t=e.getBoundingClientRect();return{top:t.top+window.pageYOffset,left:t.left+window.pageXOffset}}function Tt(e,t,n,o){let r=s=>{let a=s.target.closest(n);a&&e.contains(a)&&o(s,a)};return e.addEventListener(t,r),()=>{e.removeEventListener(t,r)}}function Nt(e,t=5e3){return new Promise((n,o)=>{let r=re(e);if(r){n(r);return}let s=new MutationObserver(()=>{let i=re(e);i&&(s.disconnect(),clearTimeout(a),n(i))});s.observe(document.body,{childList:!0,subtree:!0});let a=setTimeout(()=>{s.disconnect(),o(new Error(`Element ${e} not found within ${t}ms`))},t)})}function wt(e,t,n={}){let o=new IntersectionObserver(r=>{r.forEach(s=>{t(s.isIntersecting)})},n);return o.observe(e),()=>{o.disconnect()}}function St(e,t){let n=new ResizeObserver(o=>{o.forEach(t)});return n.observe(e),()=>{n.disconnect()}}var vt=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function At(e){return typeof e=="object"&&e!==null&&e.$$typeof===vt}function Ee(e){return e&&typeof e=="object"&&e.strings&&Array.isArray(e.strings)&&e.values&&Array.isArray(e.values)}function Ct(e){if(typeof e!="function")return!1;try{let t=e();return Ee(t)}catch{return!1}}function Rt(e){return typeof e=="object"&&e!==null&&(e.$$typeof==="template"||typeof e.type=="function")}function Lt(e){return e instanceof Node}function Pt(e,t,n="Fluixi"){typeof globalThis<"u"&&(typeof globalThis[n]>"u"&&(globalThis[n]={}),typeof globalThis[n][e]>"u"&&(globalThis[n][e]=t))}function Mt(e,t,n="Fluixi"){return typeof globalThis<"u"&&typeof globalThis[n]<"u"&&typeof globalThis[n][e]<"u"?globalThis[n][e]:t}var m=require("@fluixi/reactive/signal");var Te="1.0.0-alpha.83";var Ne=require("@fluixi/reactive/version"),h={dom:Te,reactive:Ne.VERSION};function we(e){h.core&&e.setAttribute("fluixi",h.core),e.setAttribute("fx-dom",h.dom),e.setAttribute("fx-reactive",h.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=h)}function Se(){let e=[h.core,h.dom,h.reactive].filter(t=>t!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${h.core??"(absent)"}, dom ${h.dom}, reactive ${h.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 ve(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-component"),{value:!0,enumerable:!0}),e}function b(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var l=require("@fluixi/reactive/signal");var ie=Symbol.for("fluixi.server-node"),_t=Symbol.for("fluixi.dom.server-host"),kt=globalThis,j=kt[_t]??={server:typeof document>"u",nodes:null};function E(){return j.server}function Ae(e){j.server=e}function q(){if(!j.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return j.nodes}function v(e){return e!=null&&e[ie]===!0?!0:typeof Node<"u"&&e instanceof Node}function F(e){return e!=null&&e[ie]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function V(e){return e!=null&&e[ie]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var c={active:!1,cursor:null,parents:[]},Ce=null;function Re(e){Ce=e}function W(){return Ce}function se(e,t){return c.active&&t.parentNode===e}function ae(e){let t=c.parents.lastIndexOf(e);t!==-1&&(c.parents.length=t),c.cursor=e.nextSibling}function Le(){return c.active?c.cursor:null}function L(e,t){if(!e||e.parentNode==null)return t();let n=c.active,o=c.cursor,r=c.parents;c.active=!0,c.cursor=e,c.parents=[];try{return t()}finally{c.active=n,c.cursor=o,c.parents=r}}function Pe(e){if(!c.active)return e();let t=c.cursor,n=c.parents;c.active=!1,c.parents=[];try{return e()}finally{c.active=!0,c.cursor=t,c.parents=n}}function Me(e){if(!c.active||e==null)return;let t=Array.isArray(e)?e[e.length-1]:e;t&&typeof t.nodeType=="number"&&ae(t)}function Ot(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 o=0,r=e;for(;r=r.previousElementSibling;)r.tagName===e.tagName&&o++;n+=`:nth-of-type(${o+1})`,t.unshift(n),e=e.parentElement}return t.join(">")}function $t(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 It(e){return $t(Ot(e))}var Dt=()=>"xxyxxxxxxy-4xx8".replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),Ht={};var K="__fx_at",$e="__fx_loc";function _e(e,t){return t&&(e[$e]=t),e}var ke=new Map,B=new Set,z=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function ue(e){if(!E())for(let t of e)B.has(t)||z.has(t)||(B.add(t),document.addEventListener(t,jt))}function jt(e){let t=`$$${e.type}`,n=e.composedPath&&e.composedPath()[0]||e.target;for(;n;){let o=n[t];if(o&&!n.disabled&&(o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Element?n.host:n.parentNode}}function Ie(e,t,n){if(e[`$$${t}`]=n,z.has(t)){let o=`__fx_${t}`;if(!e[o]){let r=s=>{e[`$$${t}`]?.(s)};e.addEventListener(t,r),e[o]=r}return}B.has(t)||ue([t])}function fe(e,t){delete e[`$$${t}`];let n=`__fx_${t}`,o=e[n];o&&(e.removeEventListener(t,o),delete e[n])}function qt(e){return!z.has(e)}function Ft(e){return typeof e=="function"}function S(e,t=!1){if(E())return q().createText(e);if(c.active&&!t){let n=W()?.hydrateText(e);if(n)return n}return document.createTextNode(e)}function le(e,t=!1,n){if(E())return q().createElement(e,t);if(c.active){let o=W()?.hydrateElement(e);if(o)return n?_e(o,n):o}return _e(t?document.createElementNS(I,e):document.createElement(e),n)}function De(e,t=!1){let n=ke.get(e);if(n)return n;let o=document.createElement("template");return t?o.innerHTML=`<svg>${e}</svg>`:o.innerHTML=e,ke.set(e,o),o}function Vt(e,t,n=!1,o=!1,r){if(E()){let s=q();return n?s.parseTemplate(e,o):s.createRaw(e)}if(c.active){let s=W()?.hydrateStatic(t);if(s)return Oe(s,r)}return Oe(He(De(e,o),o).firstChild,r)}function Oe(e,t){let n=e;if(!t||typeof n?.querySelectorAll!="function")return e;let o=[n,...n.querySelectorAll("*")];for(let r=0;r<o.length&&r*2+1<t.pos.length;r++){let s=t.pos[r*2];s&&(o[r][$e]={file:t.file,line:s,column:t.pos[r*2+1]})}return e}function Wt(e,t){if(!c.active)return t();let n=L(e.nextSibling,t);if(typeof n=="function"){let o=n;return Kt(o,(...s)=>c.active?L(e.nextSibling,()=>o(...s)):o(...s))}return n}function Kt(e,t){let n=e[K];return n!==void 0&&(t[K]=n),t}function Bt(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 Gt(e,t){let n=[];for(let o=e.nextSibling;o&&o!==t;o=o.nextSibling)n.push(o);return n}function He(e,t=!1){let n=e.content.cloneNode(!0);return t?n.firstChild:n}function je(e){return Array.isArray(e)?e.length===2&&e[1]===" "?Array.isArray(e[0])?je(e[0]):(typeof e[0]=="function",e[0]):e.length===1&&typeof e[0]=="function"?e[0]:e:e}function Jt(e){return typeof e!="function"?null:e._name||e.name||"anonymous"}function Xt(e){if((0,m.isSignal)(e)||b(e)||typeof e!="function")return e;let t=e();for(;typeof t=="function"&&!(0,m.isSignal)(t)&&!b(t);)t=t();return t}var N=0,zt=200;function Ut(e,t,n,o,r){let s=o,a=new Map;return(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(n??t,"content",void 0,e);let i;if(b(e)&&!(0,m.isSignal)(e)){if(!a.has(e)){N++;try{let f=e();a.set(e,f)}finally{N--}}for(i=a.get(e);typeof i=="function"&&(0,m.isSignal)(i);)i=i()}else for(i=e();typeof i=="function"&&(0,m.isSignal)(i);)i=i();{let f=0;for(;typeof i=="function"&&f++<50;)if(b(i)){if(!a.has(i)){let u=i;N++;try{let d=u();a.set(u,d)}finally{N--}}i=a.get(i)}else if((0,m.isSignal)(i))i=i();else if(i=i(),typeof i!="function"||!(0,m.isSignal)(i)&&!b(i))break}N++;try{s=M(t,i,n,s,a),r(s)}finally{N--}})}function C(e,t,n,o){if(N>zt)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;n!==void 0&&!n&&(n=S("",!0),e.appendChild(n));let r=o??null,s=f=>Array.isArray(f)&&f.some(u=>typeof u=="function"),a=f=>typeof f=="function"?f:()=>f;if(typeof t!="function"&&!s(t)){N++;try{r=M(e,t,n,r)}finally{N--}return()=>r}let i=Ut(a(t),e,n,r,f=>{r=f});return()=>(i?.(),r)}function M(e,t,n,o,r){if(t==null||typeof t=="boolean")return w(e,o,n);if(typeof t=="function")for(;typeof t=="function";)t=t();if(t==null||typeof t=="boolean")return w(e,o,n);if(P(t)){let a=S("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(a,o[0]),w(e,o.slice(1),n)):g(e,a,n):o?e.replaceChild(a,o):g(e,a,n),t.then(i=>{a.parentNode===e&&M(e,i,a.nextSibling,a)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),a}let s=typeof t;if(s==="string"||s==="number"){if(s==="number"&&(t=String(t)),Array.isArray(o)){if(o.length===0){let i=S(t);return g(e,i,n),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=t,o;o=w(e,o,n)}if(o&&V(o))return o.data=t,o;let a=S(t);return o&&o.parentNode===e?e.replaceChild(a,o):se(e,a)||g(e,a,n),a}if(v(t))return se(e,t)?(ae(t),t):Array.isArray(o)?(o.length===0?g(e,t,n):o[0].parentNode===e?(e.replaceChild(t,o[0]),w(e,o.slice(1),n)):g(e,t,n),t):(o?o!==t&&(o.parentNode===e?e.replaceChild(t,o):g(e,t,n)):g(e,t,n),t);if(Array.isArray(t)){let a=[],i=Array.isArray(o)?o:o?[o]:[],f=[];T(t,a,e,n,!0,r,f);let u=Yt(e,i,a,n);for(let d of f){let p=C(e,d.sig,d.marker);(0,l.onCleanup)(()=>{w(e,p()),d.marker.parentNode===e&&e.removeChild(d.marker)})}return u}if(s==="object"&&t!==null&&typeof t=="object"){let a=t;if("type"in a&&"props"in a){let i=a;if(typeof i.type=="function"){let f=i.type(i.props||{});return M(e,f,n,o)}}}return w(e,o,n)}function T(e,t,n,o,r=!0,s,a){for(let i=0;i<e.length;i++){let f=e[i];if(!(f==null||typeof f=="boolean")){for(;typeof f=="function"&&!P(f)&&!(0,m.isSignal)(f)&&!b(f)&&(f=f(),!(f==null||typeof f=="boolean")););if(!(f==null||typeof f=="boolean")){if(typeof f=="function"){let u;for(b(f)&&!(0,m.isSignal)(f)?(s||(s=new Map),s.has(f)||s.set(f,f()),u=s.get(f)):u=f();typeof u=="function"&&!P(u)&&!(0,m.isSignal)(u)&&!b(u);)s||(s=new Map),s.has(u)||s.set(u,u()),u=s.get(u);if(u==null||typeof u=="boolean")continue;if(typeof u=="function"){if((0,m.isSignal)(u)){if(a){let p=S("",!0);t.push(p),a.push({marker:p,sig:u});continue}let d=u();for(;typeof d=="function"&&(0,m.isSignal)(d);)d=d();if(d==null||typeof d=="boolean")continue;Array.isArray(d)?T(d,t,n,o,r,s):T([d],t,n,o,r,s);continue}continue}Array.isArray(u)?T(u,t,n,o,r,s,a):T([u],t,n,o,r,s,a);continue}if(P(f)){let u=S("",!0);t.push(u),f.then(d=>{if(u.parentNode){let p=[];if(T([d],p,u.parentNode,void 0,!1,s),p.length>0){u.parentNode.replaceChild(p[0],u);for(let y=1;y<p.length;y++)u.parentNode?.insertBefore(p[y],p[y-1].nextSibling)}}}).catch(d=>console.error("Error resolving promise in array:",d));continue}if(Array.isArray(f)){T(f,t,n,o,r,s,a);continue}if(v(f)){t.push(f);continue}if(typeof f=="object"&&f!==null&&"type"in f&&"props"in f){let u=f;if(typeof u.type=="function"){let d=u.type(u.props||{});Array.isArray(d)?T(d,t,n,o,!1,s):T([d],t,n,o,!1,s);continue}}if(typeof f=="string"||typeof f=="number"){let u=String(f);if(u.trim()===""&&u!==" ")continue;t.push(S(u));continue}t.push(S(String(f)))}}}}function Yt(e,t,n,o){for(let p=0;p<n.length;p++){let y=n[p].parentNode;y!==null&&y!==e&&y.nodeType!==11&&(n=n.slice(),n[p]=n[p].cloneNode(!0))}let r=n.length,s=t.length,a=r,i=0,f=0,u=s>0?t[s-1].nextSibling??void 0:o,d=null;for(;i<s||f<a;){if(t[i]===n[f]){i++,f++;continue}for(;s>i&&a>f&&t[s-1]===n[a-1];)s--,a--;if(s===i){let p=a<r?f?n[f-1].nextSibling??void 0:n[a-f]:u;for(;f<a;)g(e,n[f++],p)}else if(a===f)for(;i<s;)(!d||!d.has(t[i]))&&t[i].parentNode===e&&e.removeChild(t[i]),i++;else if(t[i]===n[a-1]&&n[f]===t[s-1]){let p=t[--s].nextSibling;g(e,n[f++],t[i++].nextSibling),g(e,n[--a],p),t[s]=t[i-1]}else{if(!d){d=new Map;let y=f;for(;y<a;)d.set(n[y],y++)}let p=d.get(t[i]);if(p!=null)if(f<p&&p<a){let y=i,ne=1;for(;++y<s&&y<a&&!(!d.has(t[y])||d.get(t[y])!==p+ne);)ne++;if(ne>p-f){let Je=t[i];for(;f<p;)g(e,n[f++],Je)}else t[i].parentNode===e?e.replaceChild(n[f++],t[i++]):(g(e,n[f++],u),i++)}else i++;else t[i].parentNode===e&&e.removeChild(t[i]),i++}}return n}function w(e,t,n){if(t)if(Array.isArray(t))for(let o=0;o<t.length;o++)t[o].parentNode===e&&e.removeChild(t[o]);else t.parentNode===e&&e.removeChild(t);return null}function g(e,t,n){c.active&&t.parentNode===e||(n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t))}function _(e,t,n){n==null?delete e[t]:e[t]=n}function ce(e,t,n){let o=n,r;return Array.isArray(n)&&(o=n[0],r=n[1]),typeof o!="function"?()=>{}:(e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r))}function qe(e,t){if(!t||typeof t!="function")return;let n=t[K]?.name;if(!n)return;let o=n.indexOf(":");o!==-1&&(0,l.reportReactiveDirective)(e,n.slice(0,o),n.slice(o+1),t)}function G(e,t,n){let o=typeof n=="function"?(0,l.untrack)(()=>n()):n;if(!(!o||typeof o!="object"))for(let r of Object.keys(o))(0,l.reportReactiveDirective)(e,t,r)}function de(e,t){let n=(o,r)=>{typeof o=="function"&&((0,l.reportReactiveDirective)(e,"use",o.name||"use",r),o(e,r??(()=>{})))};if(typeof t=="function"){n(t);return}if(Array.isArray(t)){if(typeof t[0]=="function"){n(t[0],t[1]);return}for(let o of t)Array.isArray(o)?n(o[0],o[1]):n(o)}}function J(e,t,n,o=!1){return qe(e,n),typeof n!="function"?(x(e,t,n,o),()=>{}):(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute",t,n);let r=typeof n=="function"?n():n;x(e,t,r,o)})}function X(e,t,n){return typeof n!="function"?(_(e,t,n),()=>{}):(qe(e,n),(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"property",t,n);let o=typeof n=="function"?n():n;_(e,t,o)}))}function pe(e,t,n){return typeof n!="function"?(x(e,t,!!n),()=>{}):(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute",t,n);let o=n();x(e,t,!!o)})}function k(e,t){if(t==null){e.removeAttribute("class");return}if(typeof t=="function"){(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute","class",t),k(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(o=>{let r=t[o];return typeof r=="function"?r():!!r}).join(" ");e.setAttribute("class",n);return}e.setAttribute("class",String(t))}function O(e,t,n){if(!(!t||typeof t!="object"))for(let o in t){let r=t[o],s=o.split(/\s+/).filter(Boolean);if(typeof r=="function"&&n)n.push((0,l.createRenderEffect)(()=>{let a=!!r();for(let i of s)e.classList.toggle(i,a)}));else{let a=!!(typeof r=="function"?r():r);for(let i of s)e.classList.toggle(i,a)}}}function $(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 o in n){let r=n[o];r==null?e.style[o]="":e.style[o]=r}}function Zt(e){let{element:t,props:n,prevProps:o=Ht,isSVG:r=!1,skipChildren:s=!1}=e;if(!t||!F(t))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!n)return console.warn("[spread] Warning: props is undefined!"),()=>{};let a=r||t.namespaceURI===I,i=[];for(let f in n){if(s&&f==="children")continue;let u=n[f],d=o[f];if(u===d)continue;if(f==="ref"){ye(u,t);continue}if(f==="use"){de(t,u);continue}if(f.startsWith("on:")){i.push(ce(t,f.slice(3),u));continue}if(f.startsWith("prop:")){(0,l.reportReactiveDirective)(t,"prop",f.slice(5),u),i.push(X(t,f.slice(5),u));continue}if(f.startsWith("attr:")){(0,l.reportReactiveDirective)(t,"attr",f.slice(5),u),i.push(J(t,f.slice(5),u,a));continue}if(f.startsWith("bool:")){(0,l.reportReactiveDirective)(t,"bool",f.slice(5),u),i.push(pe(t,f.slice(5),u));continue}if(f==="class"||f==="className"){typeof u=="function"?i.push((0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(t,"attribute","class",u),k(t,u())})):k(t,u);continue}if(f==="classList"){G(t,"class",u),typeof u=="function"?i.push((0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(t,"attribute","class",u),O(t,u())})):O(t,u,i);continue}if(f==="style"){G(t,"style",u),typeof u=="function"?i.push((0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(t,"attribute","style",u),$(t,u())})):$(t,u);continue}if(f.startsWith("on")){let y=f.slice(2).toLowerCase();d&&fe(t,y),u&&Ie(t,y,u);continue}let p=H.has(f)||!a&&f in t;typeof u=="function"?i.push(p?X(t,f,u):J(t,f,u,a)):i.push((0,l.createRenderEffect)(()=>p?_(t,f,n[f]):x(t,f,n[f],a)))}for(let f in o)if(!(f in n))if(f.startsWith("on")){let u=f.slice(2).toLowerCase();fe(t,u)}else H.has(f)?_(t,f,null):t.removeAttribute(f);return()=>{i.forEach(f=>f())}}function Qt(e,t,n=!1){for(let o in t){let r=t[o];if(o==="ref"){ye(r,e);continue}if(o!=="children"){if(o==="use"){de(e,r);continue}if(o.startsWith("on:")){ce(e,o.slice(3),r);continue}if(o.startsWith("prop:")){(0,l.reportReactiveDirective)(e,"prop",o.slice(5),r),X(e,o.slice(5),r);continue}if(o.startsWith("attr:")){(0,l.reportReactiveDirective)(e,"attr",o.slice(5),r),J(e,o.slice(5),r,n);continue}if(o.startsWith("bool:")){(0,l.reportReactiveDirective)(e,"bool",o.slice(5),r),pe(e,o.slice(5),r);continue}if(o.startsWith("on")&&o.length>2){let s=o.slice(2).toLowerCase();if(typeof r=="function")if(z.has(s)){e[`$$${s}`]=r;let a=`__fx_${s}`;if(!e[a]){let i=f=>{e[`$$${s}`]?.(f)};e.addEventListener(s,i),e[a]=i}}else e[`$$${s}`]=r,B.has(s)||ue([s]);continue}if(o==="class"||o==="className"){k(e,r);continue}if(o==="classList"){G(e,"class",r),typeof r=="function"?(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute","class",r),O(e,r())}):O(e,r);continue}if(o==="style"){G(e,"style",r),typeof r=="function"?(0,l.createRenderEffect)(()=>{(0,l.reportReactiveBinding)(e,"attribute","style",r),$(e,r())}):$(e,r);continue}if(o==="innerHTML"){if(typeof r=="function"){let s=(0,l.createEffect)(()=>{let a=r();for(;typeof a=="function";)a=a();e.innerHTML=a});(0,l.onCleanup)(()=>s())}else e.innerHTML=r;continue}if(o==="value"&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA")){if(typeof r=="function"){let s=(0,l.createEffect)(()=>{let a=r();for(;typeof a=="function"&&a.length===0;)a=a();document.activeElement!==e&&(e.value=a??"")});(0,l.onCleanup)(()=>{s()})}else(0,l.createRenderEffect)(()=>{document.activeElement!==e&&(e.value=t[o]??"")});continue}if(o==="checked"&&e.tagName==="INPUT"){if(typeof r=="function"){let s=(0,l.createEffect)(()=>{let a=r();for(;typeof a=="function"&&a.length===0;)a=a();document.activeElement!==e&&(e.checked=a??"")});(0,l.onCleanup)(()=>{s()})}else(0,l.createRenderEffect)(()=>{document.activeElement!==e&&(e.checked=t[o]??"")});continue}if(o==="value"&&e.tagName==="SELECT"){if(typeof r=="function"){let s=!0,a=(0,l.createEffect)(()=>{let i=r();for(;typeof i=="function"&&i.length===0;)i=i();s?(s=!1,queueMicrotask(()=>{e.value=i??""})):e.value=i??""});(0,l.onCleanup)(()=>{a()})}else{let s=!0;(0,l.createRenderEffect)(()=>{let a=t[o];s?(s=!1,queueMicrotask(()=>{e.value=a??""})):e.value=a??""})}continue}if(typeof r=="function"){let s=(0,l.createEffect)(()=>{let a=r();for(;typeof a=="function"&&a.length===0;)a=a();D(e,o,a,n)});(0,l.onCleanup)(()=>{s()})}else(0,l.createRenderEffect)(()=>D(e,o,t[o],n))}}}function en(...e){let t=o=>{for(let r=e.length-1;r>=0;r--){let s=e[r];if(s&&o in s&&s[o]!==void 0)return s[o]}},n=o=>{for(let r of e)if(r&&o in r)return!0;return!1};return new Proxy({},{get:(o,r)=>t(r),has:(o,r)=>n(r),ownKeys:()=>{let o=new Set;for(let r of e)if(r)for(let s of Reflect.ownKeys(r))o.add(s);return[...o]},getOwnPropertyDescriptor:(o,r)=>n(r)?{enumerable:!0,configurable:!0,get:()=>t(r)}:void 0})}function tn(e,...t){let n=new Set;for(let a of t)for(let i of a)n.add(i);let o=a=>({enumerable:!0,configurable:!0,get:()=>e[a]}),r=t.map(a=>{let i=new Set(a);return new Proxy({},{get:(f,u)=>i.has(u)?e[u]:void 0,has:(f,u)=>i.has(u)&&u in e,ownKeys:()=>Array.from(i).filter(f=>f in e),getOwnPropertyDescriptor:(f,u)=>i.has(u)&&u in e?o(u):void 0})}),s=new Proxy({},{get:(a,i)=>n.has(i)?void 0:e[i],has:(a,i)=>!n.has(i)&&i in e,ownKeys:()=>Reflect.ownKeys(e).filter(a=>!n.has(a)),getOwnPropertyDescriptor:(a,i)=>!n.has(i)&&i in e?o(i):void 0});return[...r,s]}function ye(e,t){if(!e)return;let n=e[K]?.name;if((0,l.reportReactiveDirective)(t,"ref",n||typeof e=="function"&&e.name||"ref",e),v(e)){let o=t,r=e;if(!o)return;typeof o=="function"?o(r):typeof o=="object"&&"current"in o&&(o.current=r);return}typeof e=="function"?e(t):typeof e=="object"&&"current"in e&&(e.current=t)}function nn(e,t,n){let o=t||document.body,r=(0,l.readChildren)(()=>e),s=[];return(0,l.batch)(()=>{let a=(0,l.createRenderEffect)(()=>{let i=r();Array.isArray(i)?(i.forEach(f=>o.appendChild(f)),s.push(()=>{i.forEach(f=>{f.parentNode===o&&o.removeChild(f)})})):v(i)&&(o.appendChild(i),s.push(()=>{i.parentNode===o&&o.removeChild(i)}))});s.push(a),(0,l.onCleanup)(()=>{s.forEach(i=>i())})}),null}function on(e){return typeof e=="string"&&e.toLowerCase()===e}function rn(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 sn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function P(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function an(e){return typeof e=="function"&&e.length===0&&(0,m.isSignal)(e)}function me(e,t,n){if(!t)throw new Error("Container element is required");let o,r,s=[];return(0,l.createRoot)(a=>{(0,l.batch)(()=>{c.active||(t.textContent=""),we(t),Se(),C(t,e)}),r=a}),()=>{r?.(),o?.(),s.forEach(a=>a()),t.textContent=""}}function fn(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(…)`.")}var R=require("@fluixi/reactive");var un="__fx_dom_create_component__",A=globalThis[un]??={fn:null};function ln(e){A.fn=e}function cn(e={}){let t=e.signalSystem?.createComponent;t&&(A.fn=t)}function dn(e,t){if(A.fn)return A.fn(e,t);t&&(0,R.reportReactiveProps)(t);let n=typeof e=="function"?(0,R.untrack)(()=>e(t)):e,o=n!=null&&(typeof n=="function"||typeof n=="object");if(o)try{n.$name=e?.name}catch{}return o&&!(0,R.isSignal)(n)?ve(n):n}var pn=()=>A.fn!==null,yn=()=>A.fn!==null;function mn(){A.fn=null}var U,gn={getStore:()=>U,run(e,t){let n=U;U=e;try{return t()}finally{U=n}}},xn=gn;function Fe(){return xn.getStore()}var Y=require("@fluixi/reactive/signal");var hn="__FX_DATA__";var ge;function Ve(){let e=globalThis.__FX_DATA__;if(e)return e;if(ge!==void 0)return ge;let t=null;if(typeof document<"u"){let n=document.getElementById(hn)?.textContent;if(n)try{t=JSON.parse(n)}catch{t=null}}return ge=t}function Z(){for(;;){for(;c.cursor&&c.cursor.nodeType===3&&c.cursor.data==="";)c.cursor=c.cursor.nextSibling;if(c.cursor!=null||!c.parents.length)return;c.cursor=c.parents.pop().nextSibling}}var bn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Q=typeof process<"u"&&process.env&&!1;function ee(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 En(e){Z();let t=c.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(bn.has(e.toLowerCase())?c.cursor=t.nextSibling:(c.parents.push(t),c.cursor=t.firstChild),t):(Q&&t&&ee(`<${e}>`,t),null)}function Tn(e){Z();let t=c.cursor;return t&&t.nodeType===1&&t.tagName.toLowerCase()===e.toLowerCase()?(c.cursor=t.nextSibling,t):(Q&&t&&ee(`<${e}> (static)`,t),null)}function Nn(e){if(e===""){let n=c.cursor;return n&&n.nodeType===3&&n.data!==""?(c.cursor=n.nextSibling,n.data="",n):null}Z();let t=c.cursor;return t&&t.nodeType===3?(c.cursor=t.nextSibling,t.nodeValue!==e&&(t.nodeValue=e),t):(Q&&t&&ee(`text ${JSON.stringify(e.slice(0,24))}`,t),null)}function wn(e){Z();let t=c.cursor;return t&&t.nodeType===8&&t.data===e?(c.cursor=t.nextSibling,t):(Q&&t&&ee(`marker <!--${e.slice(0,24)}-->`,t),null)}var We=!1;function Sn(){We||(We=!0,Re({hydrateElement:En,hydrateText:Nn,hydrateMarker:wn,hydrateStatic:Tn}))}function te(e,t,n){Sn(),c.active=!0,c.cursor=t.firstChild,c.parents=[];let o=Ve(),r=n?.resourceNamespace,s=0;(0,Y.setResourceIdSource)(()=>r?`${r}:r${s++}`:`r${s++}`),(0,Y.setServerDataGetter)(o?a=>a in o?{value:o[a]}:void 0:null);try{return me(e,t)}finally{c.active=!1,c.cursor=null,c.parents=[]}}var xe="fluixi-island";function Be(e){let{component:t,props:n={},name:o}=e,r=le(xe),s=o??t.name??"Island";x(r,"name",s),x(r,"props",JSON.stringify(n??{}));let a=E()?Fe():void 0;if(a){let i=a.nextIslandNamespace(s);C(r,()=>a.withResourceScope(i,()=>t(n)))}else C(r,()=>t(n));return r}var Ke=!1;function vn(){if(Ke||typeof document>"u")return;Ke=!0;let e=document.createElement("style");e.textContent=`${xe}{display:contents}`,document.head.appendChild(e)}function Ge(e){if(typeof document>"u")return;vn();let t=document.querySelectorAll(xe),n=new Map;t.forEach(o=>{let r=o.getAttribute("name")??"",s=n.get(r)??0;n.set(r,s+1);let a=e[r];if(!a){typeof process>"u"&&console.warn(`[fluixi] island "${r}" has no component in the registry — left static.`);return}let i={};try{i=JSON.parse(o.getAttribute("props")||"{}")}catch{}te(()=>a(i),o,{resourceNamespace:`${r}#${s}`})})}
|
|
1
|
+
/*! @fluixi/dom v1.0.0-alpha.85 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/lib/dom/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
Island: () => Island,
|
|
25
|
+
JSX_PROPERTIES: () => JSX_PROPERTIES,
|
|
26
|
+
SVG_ELEMENTS: () => SVG_ELEMENTS,
|
|
27
|
+
SVG_NAMESPACE: () => SVG_NAMESPACE,
|
|
28
|
+
VOID_ELEMENTS: () => VOID_ELEMENTS,
|
|
29
|
+
addClass: () => addClass,
|
|
30
|
+
addDelegatedEventListener: () => addDelegatedEventListener,
|
|
31
|
+
addNativeEventListener: () => addNativeEventListener,
|
|
32
|
+
appendChildren: () => appendChildren,
|
|
33
|
+
applyElementProp: () => applyElementProp,
|
|
34
|
+
applyProps: () => applyProps,
|
|
35
|
+
applyUse: () => applyUse,
|
|
36
|
+
bindPair: () => bindPair,
|
|
37
|
+
captureHydrationCursor: () => captureHydrationCursor,
|
|
38
|
+
cleanChildren: () => cleanChildren,
|
|
39
|
+
cloneTemplate: () => cloneTemplate,
|
|
40
|
+
closest: () => closest,
|
|
41
|
+
createComponent: () => createComponent,
|
|
42
|
+
createElement: () => createElement,
|
|
43
|
+
createNativeElement: () => createNativeElement,
|
|
44
|
+
createPortal: () => createPortal,
|
|
45
|
+
createTemplate: () => createTemplate,
|
|
46
|
+
delegate: () => delegate,
|
|
47
|
+
delegateEvents: () => delegateEvents,
|
|
48
|
+
escapeHTML: () => escapeHTML,
|
|
49
|
+
fnName: () => fnName,
|
|
50
|
+
generateID: () => generateID,
|
|
51
|
+
getAttribute: () => getAttribute,
|
|
52
|
+
getGlobal: () => getGlobal,
|
|
53
|
+
getLitEventName: () => getLitEventName,
|
|
54
|
+
getOffset: () => getOffset,
|
|
55
|
+
getStableElementId: () => getStableElementId,
|
|
56
|
+
getStyle: () => getStyle,
|
|
57
|
+
handleRef: () => handleRef,
|
|
58
|
+
hasClass: () => hasClass,
|
|
59
|
+
holeContent: () => holeContent,
|
|
60
|
+
holeEnd: () => holeEnd,
|
|
61
|
+
holeScope: () => holeScope,
|
|
62
|
+
hydrate: () => hydrate,
|
|
63
|
+
hydrateAdvancePast: () => hydrateAdvancePast,
|
|
64
|
+
hydrateIslands: () => hydrateIslands,
|
|
65
|
+
initializeIntegration: () => initializeIntegration,
|
|
66
|
+
insert: () => insert,
|
|
67
|
+
insertExpression: () => insertExpression,
|
|
68
|
+
intergartionInitialized: () => intergartionInitialized,
|
|
69
|
+
isAccessor: () => isAccessor,
|
|
70
|
+
isCustomElement: () => isCustomElement,
|
|
71
|
+
isDOMNode: () => isDOMNode,
|
|
72
|
+
isDelegatedEvent: () => isDelegatedEvent,
|
|
73
|
+
isDomElement: () => isDomElement,
|
|
74
|
+
isDomNode: () => isDomNode,
|
|
75
|
+
isDomText: () => isDomText,
|
|
76
|
+
isEventHandler: () => isEventHandler,
|
|
77
|
+
isFunction: () => isFunction,
|
|
78
|
+
isIntegrationInitialized: () => isIntegrationInitialized,
|
|
79
|
+
isJSXTemplate: () => isJSXTemplate,
|
|
80
|
+
isLitTemplateResult: () => isLitTemplateResult,
|
|
81
|
+
isNativeElement: () => isNativeElement,
|
|
82
|
+
isPromise: () => isPromise,
|
|
83
|
+
isReactElement: () => isReactElement,
|
|
84
|
+
isSVGElement: () => isSVGElement,
|
|
85
|
+
isServer: () => isServer,
|
|
86
|
+
isTemplateFactory: () => isTemplateFactory,
|
|
87
|
+
isVisible: () => isVisible,
|
|
88
|
+
iterateFn: () => iterateFn,
|
|
89
|
+
makeArrayFlat: () => makeArrayFlat,
|
|
90
|
+
mergeProps: () => mergeProps,
|
|
91
|
+
observeIntersection: () => observeIntersection,
|
|
92
|
+
observeResize: () => observeResize,
|
|
93
|
+
query: () => query,
|
|
94
|
+
queryAll: () => queryAll,
|
|
95
|
+
registerCreateComponent: () => registerCreateComponent,
|
|
96
|
+
registerGlobal: () => registerGlobal,
|
|
97
|
+
removeAttribute: () => removeAttribute,
|
|
98
|
+
removeChildren: () => removeChildren,
|
|
99
|
+
removeClass: () => removeClass,
|
|
100
|
+
removeDelegatedEventListener: () => removeDelegatedEventListener,
|
|
101
|
+
render: () => render,
|
|
102
|
+
resetIntegration: () => resetIntegration,
|
|
103
|
+
runHydrationAt: () => runHydrationAt,
|
|
104
|
+
runWithoutHydration: () => runWithoutHydration,
|
|
105
|
+
scrollIntoView: () => scrollIntoView,
|
|
106
|
+
setAttribute: () => setAttribute,
|
|
107
|
+
setClassList: () => setClassList,
|
|
108
|
+
setClassName: () => setClassName,
|
|
109
|
+
setDynamicAttribute: () => setDynamicAttribute,
|
|
110
|
+
setDynamicBoolAttribute: () => setDynamicBoolAttribute,
|
|
111
|
+
setDynamicProperty: () => setDynamicProperty,
|
|
112
|
+
setProperty: () => setProperty,
|
|
113
|
+
setServerMode: () => setServerMode,
|
|
114
|
+
setStyle: () => setStyle,
|
|
115
|
+
setStyles: () => setStyles,
|
|
116
|
+
shouldSetAsProperty: () => shouldSetAsProperty,
|
|
117
|
+
splitProps: () => splitProps,
|
|
118
|
+
spread: () => spread,
|
|
119
|
+
templateNode: () => templateNode,
|
|
120
|
+
toAttributeName: () => toAttributeName,
|
|
121
|
+
toggleClass: () => toggleClass,
|
|
122
|
+
waitForElement: () => waitForElement
|
|
123
|
+
});
|
|
124
|
+
module.exports = __toCommonJS(index_exports);
|
|
125
|
+
|
|
126
|
+
// src/lib/dom/utils.ts
|
|
127
|
+
function toAttributeName(key) {
|
|
128
|
+
if (key.startsWith("aria-") || key.startsWith("data-")) {
|
|
129
|
+
return key;
|
|
130
|
+
}
|
|
131
|
+
if (/[A-Z]/.test(key)) {
|
|
132
|
+
return key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
133
|
+
}
|
|
134
|
+
return key;
|
|
135
|
+
}
|
|
136
|
+
function isEventHandler(key) {
|
|
137
|
+
return key.startsWith("@") || key.startsWith("on") && key.length > 2;
|
|
138
|
+
}
|
|
139
|
+
function getLitEventName(key) {
|
|
140
|
+
if (key.startsWith("@")) {
|
|
141
|
+
return key.slice(1);
|
|
142
|
+
}
|
|
143
|
+
if (key.startsWith("on")) {
|
|
144
|
+
const eventName = key.slice(2);
|
|
145
|
+
return eventName.toLowerCase();
|
|
146
|
+
}
|
|
147
|
+
return key;
|
|
148
|
+
}
|
|
149
|
+
function shouldSetAsProperty(element, key) {
|
|
150
|
+
const propertyAttributes = /* @__PURE__ */ new Set([
|
|
151
|
+
"checked",
|
|
152
|
+
"value",
|
|
153
|
+
"selected",
|
|
154
|
+
"disabled",
|
|
155
|
+
"readonly",
|
|
156
|
+
"required",
|
|
157
|
+
"multiple",
|
|
158
|
+
"open",
|
|
159
|
+
"contenteditable",
|
|
160
|
+
"draggable",
|
|
161
|
+
"spellcheck"
|
|
162
|
+
]);
|
|
163
|
+
const elementSpecificProps = {
|
|
164
|
+
input: /* @__PURE__ */ new Set(["value", "checked", "indeterminate"]),
|
|
165
|
+
textarea: /* @__PURE__ */ new Set(["value"]),
|
|
166
|
+
select: /* @__PURE__ */ new Set(["value"]),
|
|
167
|
+
option: /* @__PURE__ */ new Set(["selected", "value"]),
|
|
168
|
+
audio: /* @__PURE__ */ new Set(["volume", "currentTime", "paused"]),
|
|
169
|
+
video: /* @__PURE__ */ new Set(["volume", "currentTime", "paused"]),
|
|
170
|
+
img: /* @__PURE__ */ new Set(["src", "srcset"]),
|
|
171
|
+
iframe: /* @__PURE__ */ new Set(["src"]),
|
|
172
|
+
a: /* @__PURE__ */ new Set(["href"])
|
|
173
|
+
};
|
|
174
|
+
return propertyAttributes.has(key) || elementSpecificProps[element] && elementSpecificProps[element].has(key);
|
|
175
|
+
}
|
|
176
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
177
|
+
"area",
|
|
178
|
+
"base",
|
|
179
|
+
"br",
|
|
180
|
+
"col",
|
|
181
|
+
"embed",
|
|
182
|
+
"hr",
|
|
183
|
+
"img",
|
|
184
|
+
"input",
|
|
185
|
+
"link",
|
|
186
|
+
"meta",
|
|
187
|
+
"param",
|
|
188
|
+
"source",
|
|
189
|
+
"track",
|
|
190
|
+
"wbr"
|
|
191
|
+
]);
|
|
192
|
+
var SVG_ELEMENTS = /* @__PURE__ */ new Set([
|
|
193
|
+
"svg",
|
|
194
|
+
"g",
|
|
195
|
+
"path",
|
|
196
|
+
"circle",
|
|
197
|
+
"rect",
|
|
198
|
+
"line",
|
|
199
|
+
"polyline",
|
|
200
|
+
"polygon",
|
|
201
|
+
"ellipse",
|
|
202
|
+
"text",
|
|
203
|
+
"tspan",
|
|
204
|
+
"use",
|
|
205
|
+
"defs",
|
|
206
|
+
"symbol",
|
|
207
|
+
"mask",
|
|
208
|
+
"clipPath",
|
|
209
|
+
"pattern",
|
|
210
|
+
"linearGradient",
|
|
211
|
+
"radialGradient",
|
|
212
|
+
"stop",
|
|
213
|
+
"filter",
|
|
214
|
+
"feGaussianBlur",
|
|
215
|
+
"feOffset",
|
|
216
|
+
"feMerge",
|
|
217
|
+
"feMergeNode",
|
|
218
|
+
"foreignObject"
|
|
219
|
+
]);
|
|
220
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
221
|
+
function isCustomElement(element) {
|
|
222
|
+
return element.localName.includes("-");
|
|
223
|
+
}
|
|
224
|
+
function applyElementProp(element, name, value, isSVG = false) {
|
|
225
|
+
if (value == null) {
|
|
226
|
+
element.removeAttribute(name);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (isCustomElement(element)) {
|
|
230
|
+
element[name] = value;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
setAttribute(element, name, value, isSVG);
|
|
234
|
+
}
|
|
235
|
+
var JSX_PROPERTIES = /* @__PURE__ */ new Set([
|
|
236
|
+
"className",
|
|
237
|
+
"value",
|
|
238
|
+
"checked",
|
|
239
|
+
"selected",
|
|
240
|
+
"innerHTML",
|
|
241
|
+
"innerText",
|
|
242
|
+
"textContent",
|
|
243
|
+
"indeterminate",
|
|
244
|
+
"htmlFor"
|
|
245
|
+
]);
|
|
246
|
+
function query(selector, root = document) {
|
|
247
|
+
return root.querySelector(selector);
|
|
248
|
+
}
|
|
249
|
+
function queryAll(selector, root = document) {
|
|
250
|
+
return Array.from(root.querySelectorAll(selector));
|
|
251
|
+
}
|
|
252
|
+
function closest(element, selector) {
|
|
253
|
+
return element.closest(selector);
|
|
254
|
+
}
|
|
255
|
+
function addClass(element, ...classes) {
|
|
256
|
+
element.classList.add(...classes);
|
|
257
|
+
}
|
|
258
|
+
function removeClass(element, ...classes) {
|
|
259
|
+
element.classList.remove(...classes);
|
|
260
|
+
}
|
|
261
|
+
function toggleClass(element, ...classes) {
|
|
262
|
+
classes.forEach((cls) => element.classList.toggle(cls));
|
|
263
|
+
}
|
|
264
|
+
function hasClass(element, className) {
|
|
265
|
+
return element.classList.contains(className);
|
|
266
|
+
}
|
|
267
|
+
function setAttribute(element, name, value, isSVG = false) {
|
|
268
|
+
if (value == null || value === false) {
|
|
269
|
+
element.removeAttribute(name);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (value === true) {
|
|
273
|
+
element.setAttribute(name, "");
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (typeof value === "object") {
|
|
277
|
+
element.setAttribute(name, JSON.stringify(value));
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
element.setAttribute(name, String(value));
|
|
281
|
+
}
|
|
282
|
+
function getAttribute(element, name) {
|
|
283
|
+
return element.getAttribute(name);
|
|
284
|
+
}
|
|
285
|
+
function removeAttribute(element, name) {
|
|
286
|
+
element.removeAttribute(name);
|
|
287
|
+
}
|
|
288
|
+
function setStyles(element, styles) {
|
|
289
|
+
Object.assign(element.style, styles);
|
|
290
|
+
}
|
|
291
|
+
function getStyle(element, property) {
|
|
292
|
+
return window.getComputedStyle(element).getPropertyValue(property);
|
|
293
|
+
}
|
|
294
|
+
function createElement(tagName, attributes = {}, ...children) {
|
|
295
|
+
const element = document.createElement(tagName);
|
|
296
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
297
|
+
if (key === "class" || key === "className") {
|
|
298
|
+
element.className = value;
|
|
299
|
+
} else if (key === "style" && typeof value === "object") {
|
|
300
|
+
setStyles(element, value);
|
|
301
|
+
} else if (key.startsWith("on") && typeof value === "function") {
|
|
302
|
+
const event = key.slice(2).toLowerCase();
|
|
303
|
+
element.addEventListener(event, value);
|
|
304
|
+
} else {
|
|
305
|
+
setAttribute(element, key, value);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
children.forEach((child) => {
|
|
309
|
+
if (typeof child === "string") {
|
|
310
|
+
element.appendChild(document.createTextNode(child));
|
|
311
|
+
} else {
|
|
312
|
+
element.appendChild(child);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
return element;
|
|
316
|
+
}
|
|
317
|
+
function removeChildren(element) {
|
|
318
|
+
while (element.firstChild) {
|
|
319
|
+
element.removeChild(element.firstChild);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function appendChildren(parent, ...children) {
|
|
323
|
+
children.forEach((child) => {
|
|
324
|
+
if (typeof child === "string") {
|
|
325
|
+
parent.appendChild(document.createTextNode(child));
|
|
326
|
+
} else {
|
|
327
|
+
parent.appendChild(child);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
function isVisible(element) {
|
|
332
|
+
const rect = element.getBoundingClientRect();
|
|
333
|
+
return rect.top >= 0 && rect.left >= 0 && rect.bottom <= window.innerHeight && rect.right <= window.innerWidth;
|
|
334
|
+
}
|
|
335
|
+
function scrollIntoView(element, options = { behavior: "smooth", block: "nearest" }) {
|
|
336
|
+
element.scrollIntoView(options);
|
|
337
|
+
}
|
|
338
|
+
function getOffset(element) {
|
|
339
|
+
const rect = element.getBoundingClientRect();
|
|
340
|
+
return {
|
|
341
|
+
top: rect.top + window.pageYOffset,
|
|
342
|
+
left: rect.left + window.pageXOffset
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function delegate(parent, eventName, selector, handler) {
|
|
346
|
+
const listener = (event) => {
|
|
347
|
+
const target = event.target.closest(selector);
|
|
348
|
+
if (target && parent.contains(target)) {
|
|
349
|
+
handler(event, target);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
parent.addEventListener(eventName, listener);
|
|
353
|
+
return () => {
|
|
354
|
+
parent.removeEventListener(eventName, listener);
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function waitForElement(selector, timeout = 5e3) {
|
|
358
|
+
return new Promise((resolve, reject) => {
|
|
359
|
+
const element = query(selector);
|
|
360
|
+
if (element) {
|
|
361
|
+
resolve(element);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const observer = new MutationObserver(() => {
|
|
365
|
+
const element2 = query(selector);
|
|
366
|
+
if (element2) {
|
|
367
|
+
observer.disconnect();
|
|
368
|
+
clearTimeout(timeoutId);
|
|
369
|
+
resolve(element2);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
observer.observe(document.body, {
|
|
373
|
+
childList: true,
|
|
374
|
+
subtree: true
|
|
375
|
+
});
|
|
376
|
+
const timeoutId = setTimeout(() => {
|
|
377
|
+
observer.disconnect();
|
|
378
|
+
reject(new Error(`Element ${selector} not found within ${timeout}ms`));
|
|
379
|
+
}, timeout);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function observeIntersection(element, callback, options = {}) {
|
|
383
|
+
const observer = new IntersectionObserver((entries) => {
|
|
384
|
+
entries.forEach((entry) => {
|
|
385
|
+
callback(entry.isIntersecting);
|
|
386
|
+
});
|
|
387
|
+
}, options);
|
|
388
|
+
observer.observe(element);
|
|
389
|
+
return () => {
|
|
390
|
+
observer.disconnect();
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function observeResize(element, callback) {
|
|
394
|
+
const observer = new ResizeObserver((entries) => {
|
|
395
|
+
entries.forEach(callback);
|
|
396
|
+
});
|
|
397
|
+
observer.observe(element);
|
|
398
|
+
return () => {
|
|
399
|
+
observer.disconnect();
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
|
|
403
|
+
function isReactElement(value) {
|
|
404
|
+
return typeof value === "object" && value !== null && value.$$typeof === REACT_ELEMENT_TYPE;
|
|
405
|
+
}
|
|
406
|
+
function isLitTemplateResult(value) {
|
|
407
|
+
return value && typeof value === "object" && value.strings && Array.isArray(value.strings) && value.values && Array.isArray(value.values);
|
|
408
|
+
}
|
|
409
|
+
function isTemplateFactory(value) {
|
|
410
|
+
if (typeof value !== "function") return false;
|
|
411
|
+
try {
|
|
412
|
+
const result = value();
|
|
413
|
+
return isLitTemplateResult(result);
|
|
414
|
+
} catch {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function isJSXTemplate(value) {
|
|
419
|
+
return typeof value === "object" && value !== null && (value.$$typeof === "template" || typeof value.type === "function");
|
|
420
|
+
}
|
|
421
|
+
function isDOMNode(value) {
|
|
422
|
+
return value instanceof Node;
|
|
423
|
+
}
|
|
424
|
+
function registerGlobal(key, value, _Key = "Fluixi") {
|
|
425
|
+
if (typeof globalThis !== "undefined") {
|
|
426
|
+
if (typeof globalThis[_Key] === "undefined") {
|
|
427
|
+
globalThis[_Key] = {};
|
|
428
|
+
}
|
|
429
|
+
if (typeof globalThis[_Key][key] === "undefined") {
|
|
430
|
+
globalThis[_Key][key] = value;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function getGlobal(key, value, _Key = "Fluixi") {
|
|
435
|
+
if (typeof globalThis !== "undefined") {
|
|
436
|
+
if (typeof globalThis[_Key] !== "undefined") {
|
|
437
|
+
if (typeof globalThis[_Key][key] !== "undefined") {
|
|
438
|
+
return globalThis[_Key][key];
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return value;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// src/lib/dom/runtime.ts
|
|
446
|
+
var import_signal2 = require("@fluixi/reactive/signal");
|
|
447
|
+
|
|
448
|
+
// src/version.generated.ts
|
|
449
|
+
var VERSION = "1.0.0-alpha.85";
|
|
450
|
+
|
|
451
|
+
// src/lib/dom/versions.ts
|
|
452
|
+
var import_version = require("@fluixi/reactive/version");
|
|
453
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
454
|
+
var versions = { dom: VERSION, reactive: import_version.VERSION };
|
|
455
|
+
function stampVersions(container) {
|
|
456
|
+
if (versions.core) container.setAttribute("fluixi", versions.core);
|
|
457
|
+
container.setAttribute("fx-dom", versions.dom);
|
|
458
|
+
container.setAttribute("fx-reactive", versions.reactive);
|
|
459
|
+
if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
|
|
460
|
+
}
|
|
461
|
+
function warnOnVersionSkew() {
|
|
462
|
+
const builds = (0, import_signal.joinedVersions)();
|
|
463
|
+
if (builds.length > 1) {
|
|
464
|
+
console.warn(
|
|
465
|
+
`[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.`
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
const present = [versions.core, versions.dom, versions.reactive].filter(
|
|
469
|
+
(v) => v !== void 0
|
|
470
|
+
);
|
|
471
|
+
if (new Set(present).size <= 1) return;
|
|
472
|
+
console.warn(
|
|
473
|
+
`[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\`.`
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// src/lib/component/modifiers.ts
|
|
478
|
+
function asComponent(value) {
|
|
479
|
+
if (typeof value !== "function") return value;
|
|
480
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-component"), { value: true, enumerable: true });
|
|
481
|
+
return value;
|
|
482
|
+
}
|
|
483
|
+
function isComponent(value) {
|
|
484
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// src/lib/dom/runtime.ts
|
|
488
|
+
var import_signal3 = require("@fluixi/reactive/signal");
|
|
489
|
+
|
|
490
|
+
// src/lib/dom/server/host.ts
|
|
491
|
+
var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
|
|
492
|
+
var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
|
|
493
|
+
var realm = globalThis;
|
|
494
|
+
var state = realm[STATE] ??= {
|
|
495
|
+
server: typeof document === "undefined",
|
|
496
|
+
nodes: null
|
|
497
|
+
};
|
|
498
|
+
function isServer() {
|
|
499
|
+
return state.server;
|
|
500
|
+
}
|
|
501
|
+
function setServerMode(on) {
|
|
502
|
+
state.server = on;
|
|
503
|
+
}
|
|
504
|
+
function getServerNodes() {
|
|
505
|
+
if (!state.nodes) {
|
|
506
|
+
throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
|
|
507
|
+
}
|
|
508
|
+
return state.nodes;
|
|
509
|
+
}
|
|
510
|
+
function isDomNode(x) {
|
|
511
|
+
if (x != null && x[SERVER_NODE] === true) return true;
|
|
512
|
+
return typeof Node !== "undefined" && x instanceof Node;
|
|
513
|
+
}
|
|
514
|
+
function isDomElement(x) {
|
|
515
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 1;
|
|
516
|
+
return typeof Element !== "undefined" && x instanceof Element;
|
|
517
|
+
}
|
|
518
|
+
function isDomText(x) {
|
|
519
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
|
|
520
|
+
return typeof Text !== "undefined" && x instanceof Text;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// src/lib/dom/hydration-state.ts
|
|
524
|
+
var hydration = {
|
|
525
|
+
active: false,
|
|
526
|
+
cursor: null,
|
|
527
|
+
parents: []
|
|
528
|
+
};
|
|
529
|
+
var _walker = null;
|
|
530
|
+
function registerHydrationWalker(walker) {
|
|
531
|
+
_walker = walker;
|
|
532
|
+
}
|
|
533
|
+
function getHydrationWalker() {
|
|
534
|
+
return _walker;
|
|
535
|
+
}
|
|
536
|
+
function isAdopted(parent, node) {
|
|
537
|
+
return hydration.active && node.parentNode === parent;
|
|
538
|
+
}
|
|
539
|
+
function ascendPast(node) {
|
|
540
|
+
const idx = hydration.parents.lastIndexOf(node);
|
|
541
|
+
if (idx !== -1) hydration.parents.length = idx;
|
|
542
|
+
hydration.cursor = node.nextSibling;
|
|
543
|
+
}
|
|
544
|
+
function captureHydrationCursor() {
|
|
545
|
+
return hydration.active ? hydration.cursor : null;
|
|
546
|
+
}
|
|
547
|
+
function runHydrationAt(cursor, fn) {
|
|
548
|
+
if (!cursor || cursor.parentNode == null) return fn();
|
|
549
|
+
const prevActive = hydration.active;
|
|
550
|
+
const prevCursor = hydration.cursor;
|
|
551
|
+
const prevParents = hydration.parents;
|
|
552
|
+
hydration.active = true;
|
|
553
|
+
hydration.cursor = cursor;
|
|
554
|
+
hydration.parents = [];
|
|
555
|
+
try {
|
|
556
|
+
return fn();
|
|
557
|
+
} finally {
|
|
558
|
+
hydration.active = prevActive;
|
|
559
|
+
hydration.cursor = prevCursor;
|
|
560
|
+
hydration.parents = prevParents;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function runWithoutHydration(fn) {
|
|
564
|
+
if (!hydration.active) return fn();
|
|
565
|
+
const prevCursor = hydration.cursor;
|
|
566
|
+
const prevParents = hydration.parents;
|
|
567
|
+
hydration.active = false;
|
|
568
|
+
hydration.parents = [];
|
|
569
|
+
try {
|
|
570
|
+
return fn();
|
|
571
|
+
} finally {
|
|
572
|
+
hydration.active = true;
|
|
573
|
+
hydration.cursor = prevCursor;
|
|
574
|
+
hydration.parents = prevParents;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
function hydrateAdvancePast(rendered) {
|
|
578
|
+
if (!hydration.active || rendered == null) return;
|
|
579
|
+
const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
|
|
580
|
+
if (last && typeof last.nodeType === "number") {
|
|
581
|
+
ascendPast(last);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// src/lib/dom/runtime.ts
|
|
586
|
+
function getElementFingerprint(el) {
|
|
587
|
+
const parts = [];
|
|
588
|
+
while (el && el.nodeType === 1) {
|
|
589
|
+
let part = el.tagName.toLowerCase();
|
|
590
|
+
if (el.id) {
|
|
591
|
+
part += `#${el.id}`;
|
|
592
|
+
parts.unshift(part);
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
if (el.getAttribute("data-id")) {
|
|
596
|
+
part += `[data-id="${el.getAttribute("data-id")}"]`;
|
|
597
|
+
}
|
|
598
|
+
let index = 0;
|
|
599
|
+
let sibling = el;
|
|
600
|
+
while (sibling = sibling.previousElementSibling) {
|
|
601
|
+
if (sibling.tagName === el.tagName) index++;
|
|
602
|
+
}
|
|
603
|
+
part += `:nth-of-type(${index + 1})`;
|
|
604
|
+
parts.unshift(part);
|
|
605
|
+
el = el.parentElement;
|
|
606
|
+
}
|
|
607
|
+
return parts.join(">");
|
|
608
|
+
}
|
|
609
|
+
function hashString(str) {
|
|
610
|
+
let hash = 0;
|
|
611
|
+
for (let i = 0; i < str.length; i++) {
|
|
612
|
+
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
613
|
+
hash |= 0;
|
|
614
|
+
}
|
|
615
|
+
return `el_${Math.abs(hash)}`;
|
|
616
|
+
}
|
|
617
|
+
function getStableElementId(el) {
|
|
618
|
+
return hashString(getElementFingerprint(el));
|
|
619
|
+
}
|
|
620
|
+
var generateID = () => {
|
|
621
|
+
return "xxyxxxxxxy-4xx8".replace(/[xy]/g, function(c) {
|
|
622
|
+
let r = Math.random() * 16 | 0;
|
|
623
|
+
let v = c === "x" ? r : r & 3 | 8;
|
|
624
|
+
return v.toString(16);
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
var EMPTY_OBJ = {};
|
|
628
|
+
var HOLE_TAG = "__fx_at";
|
|
629
|
+
var LOC_TAG = "__fx_loc";
|
|
630
|
+
function located(element, at) {
|
|
631
|
+
if (at) element[LOC_TAG] = at;
|
|
632
|
+
return element;
|
|
633
|
+
}
|
|
634
|
+
var templateCache = /* @__PURE__ */ new Map();
|
|
635
|
+
var delegatedSet = /* @__PURE__ */ new Set();
|
|
636
|
+
var NON_DELEGATED = /* @__PURE__ */ new Set(["scroll", "focus", "blur", "load", "error", "resize", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "gotpointercapture", "lostpointercapture"]);
|
|
637
|
+
function delegateEvents(eventNames) {
|
|
638
|
+
if (isServer()) return;
|
|
639
|
+
for (const name of eventNames) {
|
|
640
|
+
if (delegatedSet.has(name) || NON_DELEGATED.has(name)) continue;
|
|
641
|
+
delegatedSet.add(name);
|
|
642
|
+
document.addEventListener(name, delegatedEventHandler);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function delegatedEventHandler(e) {
|
|
646
|
+
const key = `$$${e.type}`;
|
|
647
|
+
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
648
|
+
while (node) {
|
|
649
|
+
const handler = node[key];
|
|
650
|
+
if (handler && !node.disabled) {
|
|
651
|
+
handler(e);
|
|
652
|
+
if (e.cancelBubble) return;
|
|
653
|
+
}
|
|
654
|
+
node = node.host && node.host !== node && node.host instanceof Element ? node.host : node.parentNode;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
function addDelegatedEventListener(element, name, handler) {
|
|
658
|
+
element[`$$${name}`] = handler;
|
|
659
|
+
if (NON_DELEGATED.has(name)) {
|
|
660
|
+
const key = `__fx_${name}`;
|
|
661
|
+
if (!element[key]) {
|
|
662
|
+
const forwarder = (e) => {
|
|
663
|
+
element[`$$${name}`]?.(e);
|
|
664
|
+
};
|
|
665
|
+
element.addEventListener(name, forwarder);
|
|
666
|
+
element[key] = forwarder;
|
|
667
|
+
}
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
if (!delegatedSet.has(name)) {
|
|
671
|
+
delegateEvents([name]);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function removeDelegatedEventListener(element, name) {
|
|
675
|
+
delete element[`$$${name}`];
|
|
676
|
+
const key = `__fx_${name}`;
|
|
677
|
+
const forwarder = element[key];
|
|
678
|
+
if (forwarder) {
|
|
679
|
+
element.removeEventListener(name, forwarder);
|
|
680
|
+
delete element[key];
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
function isDelegatedEvent(name) {
|
|
684
|
+
return !NON_DELEGATED.has(name);
|
|
685
|
+
}
|
|
686
|
+
function isFunction(value) {
|
|
687
|
+
return typeof value === "function";
|
|
688
|
+
}
|
|
689
|
+
function createTextNode(value, anchor = false) {
|
|
690
|
+
if (isServer()) return getServerNodes().createText(value);
|
|
691
|
+
if (hydration.active && !anchor) {
|
|
692
|
+
const node = getHydrationWalker()?.hydrateText(value);
|
|
693
|
+
if (node) return node;
|
|
694
|
+
}
|
|
695
|
+
return document.createTextNode(value);
|
|
696
|
+
}
|
|
697
|
+
function createNativeElement(tag, isSVG = false, at) {
|
|
698
|
+
if (isServer()) return getServerNodes().createElement(tag, isSVG);
|
|
699
|
+
if (hydration.active) {
|
|
700
|
+
const node = getHydrationWalker()?.hydrateElement(tag);
|
|
701
|
+
if (node) return at ? located(node, at) : node;
|
|
702
|
+
}
|
|
703
|
+
return located(
|
|
704
|
+
isSVG ? document.createElementNS(SVG_NAMESPACE, tag) : document.createElement(tag),
|
|
705
|
+
at
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
function createTemplate(html, isSVG = false) {
|
|
709
|
+
const cached = templateCache.get(html);
|
|
710
|
+
if (cached) return cached;
|
|
711
|
+
const template = document.createElement("template");
|
|
712
|
+
if (isSVG) {
|
|
713
|
+
template.innerHTML = `<svg>${html}</svg>`;
|
|
714
|
+
} else {
|
|
715
|
+
template.innerHTML = html;
|
|
716
|
+
}
|
|
717
|
+
templateCache.set(html, template);
|
|
718
|
+
return template;
|
|
719
|
+
}
|
|
720
|
+
function templateNode(html, tag, holes = false, isSVG = false, at) {
|
|
721
|
+
if (isServer()) {
|
|
722
|
+
const nodes = getServerNodes();
|
|
723
|
+
return holes ? nodes.parseTemplate(html, isSVG) : nodes.createRaw(html);
|
|
724
|
+
}
|
|
725
|
+
if (hydration.active) {
|
|
726
|
+
const node = getHydrationWalker()?.hydrateStatic(tag);
|
|
727
|
+
if (node) return stampPositions(node, at);
|
|
728
|
+
}
|
|
729
|
+
return stampPositions(cloneTemplate(createTemplate(html, isSVG), isSVG).firstChild, at);
|
|
730
|
+
}
|
|
731
|
+
function stampPositions(node, at) {
|
|
732
|
+
const root = node;
|
|
733
|
+
if (!at || typeof root?.querySelectorAll !== "function") return node;
|
|
734
|
+
const all = [root, ...root.querySelectorAll("*")];
|
|
735
|
+
for (let i = 0; i < all.length && i * 2 + 1 < at.pos.length; i++) {
|
|
736
|
+
const line = at.pos[i * 2];
|
|
737
|
+
if (line) all[i][LOC_TAG] = { file: at.file, line, column: at.pos[i * 2 + 1] };
|
|
738
|
+
}
|
|
739
|
+
return node;
|
|
740
|
+
}
|
|
741
|
+
function holeScope(start, produce) {
|
|
742
|
+
if (!hydration.active) return produce();
|
|
743
|
+
const value = runHydrationAt(start.nextSibling, produce);
|
|
744
|
+
if (typeof value === "function") {
|
|
745
|
+
const accessor = value;
|
|
746
|
+
const wrapped = (...args) => hydration.active ? runHydrationAt(start.nextSibling, () => accessor(...args)) : accessor(...args);
|
|
747
|
+
return carryHoleTag(accessor, wrapped);
|
|
748
|
+
}
|
|
749
|
+
return value;
|
|
750
|
+
}
|
|
751
|
+
function carryHoleTag(from, to) {
|
|
752
|
+
const tag = from[HOLE_TAG];
|
|
753
|
+
if (tag !== void 0) to[HOLE_TAG] = tag;
|
|
754
|
+
return to;
|
|
755
|
+
}
|
|
756
|
+
function holeEnd(start) {
|
|
757
|
+
for (let n = start.nextSibling; n; n = n.nextSibling) {
|
|
758
|
+
if (n.nodeType === 8 && n.data === "fx/") return n;
|
|
759
|
+
}
|
|
760
|
+
throw new Error("[fluixi] template hole is missing its closing marker");
|
|
761
|
+
}
|
|
762
|
+
function holeContent(start, end) {
|
|
763
|
+
const nodes = [];
|
|
764
|
+
for (let n = start.nextSibling; n && n !== end; n = n.nextSibling) nodes.push(n);
|
|
765
|
+
return nodes;
|
|
766
|
+
}
|
|
767
|
+
function cloneTemplate(template, isSVG = false) {
|
|
768
|
+
const clone = template.content.cloneNode(true);
|
|
769
|
+
if (isSVG) return clone.firstChild;
|
|
770
|
+
return clone;
|
|
771
|
+
}
|
|
772
|
+
function makeArrayFlat(values) {
|
|
773
|
+
if (!Array.isArray(values)) return values;
|
|
774
|
+
if (values.length === 2 && values[1] === " ") {
|
|
775
|
+
if (Array.isArray(values[0])) return makeArrayFlat(values[0]);
|
|
776
|
+
if (typeof values[0] === "function") return values[0];
|
|
777
|
+
return values[0];
|
|
778
|
+
}
|
|
779
|
+
if (values.length === 1 && typeof values[0] === "function") return values[0];
|
|
780
|
+
return values;
|
|
781
|
+
}
|
|
782
|
+
function fnName(fn) {
|
|
783
|
+
if (typeof fn !== "function") return null;
|
|
784
|
+
return fn._name || fn.name || "anonymous";
|
|
785
|
+
}
|
|
786
|
+
function iterateFn(item) {
|
|
787
|
+
if ((0, import_signal2.isSignal)(item)) return item;
|
|
788
|
+
if (isComponent(item)) return item;
|
|
789
|
+
if (typeof item !== "function") return item;
|
|
790
|
+
let content = item();
|
|
791
|
+
while (typeof content === "function" && !(0, import_signal2.isSignal)(content) && !isComponent(content)) {
|
|
792
|
+
content = content();
|
|
793
|
+
}
|
|
794
|
+
return content;
|
|
795
|
+
}
|
|
796
|
+
var _insertDepth = 0;
|
|
797
|
+
var MAX_INSERT_DEPTH = 200;
|
|
798
|
+
function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
|
|
799
|
+
let current = initialCurrent;
|
|
800
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
801
|
+
return (0, import_signal3.createRenderEffect)(() => {
|
|
802
|
+
(0, import_signal3.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
|
|
803
|
+
let value;
|
|
804
|
+
if (isComponent(getAccessor) && !(0, import_signal2.isSignal)(getAccessor)) {
|
|
805
|
+
if (!componentCache.has(getAccessor)) {
|
|
806
|
+
_insertDepth++;
|
|
807
|
+
try {
|
|
808
|
+
const inst = getAccessor();
|
|
809
|
+
componentCache.set(getAccessor, inst);
|
|
810
|
+
} finally {
|
|
811
|
+
_insertDepth--;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
value = componentCache.get(getAccessor);
|
|
815
|
+
while (typeof value === "function" && (0, import_signal2.isSignal)(value)) value = value();
|
|
816
|
+
} else {
|
|
817
|
+
value = getAccessor();
|
|
818
|
+
while (typeof value === "function" && (0, import_signal2.isSignal)(value)) {
|
|
819
|
+
value = value();
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
{
|
|
823
|
+
let chainDepth = 0;
|
|
824
|
+
while (typeof value === "function" && chainDepth++ < 50) {
|
|
825
|
+
if (isComponent(value)) {
|
|
826
|
+
if (!componentCache.has(value)) {
|
|
827
|
+
const thunk = value;
|
|
828
|
+
_insertDepth++;
|
|
829
|
+
try {
|
|
830
|
+
const inst = thunk();
|
|
831
|
+
componentCache.set(thunk, inst);
|
|
832
|
+
} finally {
|
|
833
|
+
_insertDepth--;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
value = componentCache.get(value);
|
|
837
|
+
} else if ((0, import_signal2.isSignal)(value)) {
|
|
838
|
+
value = value();
|
|
839
|
+
} else {
|
|
840
|
+
value = value();
|
|
841
|
+
if (typeof value !== "function" || !(0, import_signal2.isSignal)(value) && !isComponent(value)) break;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
_insertDepth++;
|
|
846
|
+
try {
|
|
847
|
+
current = insertExpression(parent, value, marker, current, componentCache);
|
|
848
|
+
setCurrent(current);
|
|
849
|
+
} finally {
|
|
850
|
+
_insertDepth--;
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
function insert(parent, accessor, marker, init) {
|
|
855
|
+
if (_insertDepth > MAX_INSERT_DEPTH) {
|
|
856
|
+
console.error("[insert] Exceeded max call depth, possible infinite loop.");
|
|
857
|
+
return () => null;
|
|
858
|
+
}
|
|
859
|
+
if (marker !== void 0 && !marker) {
|
|
860
|
+
marker = createTextNode("", true);
|
|
861
|
+
parent.appendChild(marker);
|
|
862
|
+
}
|
|
863
|
+
let current = init ?? null;
|
|
864
|
+
const isReactiveArray = (element) => {
|
|
865
|
+
return Array.isArray(element) && element.some((v) => typeof v === "function");
|
|
866
|
+
};
|
|
867
|
+
const normalizeAccessor = (accessor2) => {
|
|
868
|
+
if (typeof accessor2 === "function") return accessor2;
|
|
869
|
+
return () => accessor2;
|
|
870
|
+
};
|
|
871
|
+
if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
|
|
872
|
+
_insertDepth++;
|
|
873
|
+
try {
|
|
874
|
+
current = insertExpression(parent, accessor, marker, current);
|
|
875
|
+
} finally {
|
|
876
|
+
_insertDepth--;
|
|
877
|
+
}
|
|
878
|
+
return () => current;
|
|
879
|
+
}
|
|
880
|
+
const dispose = _createInsertEffect(
|
|
881
|
+
normalizeAccessor(accessor),
|
|
882
|
+
parent,
|
|
883
|
+
marker,
|
|
884
|
+
current,
|
|
885
|
+
(v) => {
|
|
886
|
+
current = v;
|
|
887
|
+
}
|
|
888
|
+
);
|
|
889
|
+
return () => {
|
|
890
|
+
dispose?.();
|
|
891
|
+
return current;
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
function insertExpression(parent, value, marker, current, componentCache) {
|
|
895
|
+
if (value == null || typeof value === "boolean") {
|
|
896
|
+
return cleanChildren(parent, current, marker);
|
|
897
|
+
}
|
|
898
|
+
if (typeof value === "function") {
|
|
899
|
+
while (typeof value === "function") {
|
|
900
|
+
value = value();
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
if (value == null || typeof value === "boolean") {
|
|
904
|
+
return cleanChildren(parent, current, marker);
|
|
905
|
+
}
|
|
906
|
+
if (isPromise(value)) {
|
|
907
|
+
const placeholder = createTextNode("", true);
|
|
908
|
+
if (Array.isArray(current)) {
|
|
909
|
+
if (current.length > 0) {
|
|
910
|
+
parent.replaceChild(placeholder, current[0]);
|
|
911
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
912
|
+
} else {
|
|
913
|
+
insertBefore(parent, placeholder, marker);
|
|
914
|
+
}
|
|
915
|
+
} else if (current) {
|
|
916
|
+
parent.replaceChild(placeholder, current);
|
|
917
|
+
} else {
|
|
918
|
+
insertBefore(parent, placeholder, marker);
|
|
919
|
+
}
|
|
920
|
+
value.then((resolved) => {
|
|
921
|
+
if (placeholder.parentNode === parent) {
|
|
922
|
+
insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
|
|
923
|
+
}
|
|
924
|
+
}).catch((err) => {
|
|
925
|
+
console.error("Error resolving promise in insertExpression:", err);
|
|
926
|
+
});
|
|
927
|
+
return placeholder;
|
|
928
|
+
}
|
|
929
|
+
const t = typeof value;
|
|
930
|
+
if (t === "string" || t === "number") {
|
|
931
|
+
if (t === "number") value = String(value);
|
|
932
|
+
if (Array.isArray(current)) {
|
|
933
|
+
if (current.length === 0) {
|
|
934
|
+
const node2 = createTextNode(value);
|
|
935
|
+
insertBefore(parent, node2, marker);
|
|
936
|
+
return node2;
|
|
937
|
+
}
|
|
938
|
+
if (current.length === 1 && current[0].nodeType === 3) {
|
|
939
|
+
current[0].data = value;
|
|
940
|
+
return current;
|
|
941
|
+
}
|
|
942
|
+
current = cleanChildren(parent, current, marker);
|
|
943
|
+
}
|
|
944
|
+
if (current && isDomText(current)) {
|
|
945
|
+
current.data = value;
|
|
946
|
+
return current;
|
|
947
|
+
}
|
|
948
|
+
const node = createTextNode(value);
|
|
949
|
+
if (current && current.parentNode === parent) {
|
|
950
|
+
parent.replaceChild(node, current);
|
|
951
|
+
} else if (!isAdopted(parent, node)) {
|
|
952
|
+
insertBefore(parent, node, marker);
|
|
953
|
+
}
|
|
954
|
+
return node;
|
|
955
|
+
}
|
|
956
|
+
if (isDomNode(value)) {
|
|
957
|
+
if (isAdopted(parent, value)) {
|
|
958
|
+
ascendPast(value);
|
|
959
|
+
return value;
|
|
960
|
+
}
|
|
961
|
+
if (Array.isArray(current)) {
|
|
962
|
+
if (current.length === 0) {
|
|
963
|
+
insertBefore(parent, value, marker);
|
|
964
|
+
} else if (current[0].parentNode === parent) {
|
|
965
|
+
parent.replaceChild(value, current[0]);
|
|
966
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
967
|
+
} else {
|
|
968
|
+
insertBefore(parent, value, marker);
|
|
969
|
+
}
|
|
970
|
+
return value;
|
|
971
|
+
}
|
|
972
|
+
if (!current) {
|
|
973
|
+
insertBefore(parent, value, marker);
|
|
974
|
+
} else if (current !== value) {
|
|
975
|
+
if (current.parentNode === parent) {
|
|
976
|
+
parent.replaceChild(value, current);
|
|
977
|
+
} else {
|
|
978
|
+
insertBefore(parent, value, marker);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
return value;
|
|
982
|
+
}
|
|
983
|
+
if (Array.isArray(value)) {
|
|
984
|
+
const array = [];
|
|
985
|
+
const currentArray = Array.isArray(current) ? current : current ? [current] : [];
|
|
986
|
+
const reactiveSlots = [];
|
|
987
|
+
flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
|
|
988
|
+
const reconciled = reconcileArrays(parent, currentArray, array, marker);
|
|
989
|
+
for (const slot of reactiveSlots) {
|
|
990
|
+
const disposeSlot = insert(parent, slot.sig, slot.marker);
|
|
991
|
+
(0, import_signal3.onCleanup)(() => {
|
|
992
|
+
cleanChildren(parent, disposeSlot());
|
|
993
|
+
if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
return reconciled;
|
|
997
|
+
}
|
|
998
|
+
if (t === "object" && value !== null && typeof value === "object") {
|
|
999
|
+
const objValue = value;
|
|
1000
|
+
if ("type" in objValue && "props" in objValue) {
|
|
1001
|
+
const jsxValue = objValue;
|
|
1002
|
+
if (typeof jsxValue.type === "function") {
|
|
1003
|
+
const result = jsxValue.type(jsxValue.props || {});
|
|
1004
|
+
return insertExpression(parent, result, marker, current);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
return cleanChildren(parent, current, marker);
|
|
1009
|
+
}
|
|
1010
|
+
function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
|
|
1011
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1012
|
+
let item = arr[i];
|
|
1013
|
+
if (item == null || typeof item === "boolean") continue;
|
|
1014
|
+
while (typeof item === "function" && !isPromise(item) && !(0, import_signal2.isSignal)(item) && !isComponent(item)) {
|
|
1015
|
+
item = item();
|
|
1016
|
+
if (item == null || typeof item === "boolean") break;
|
|
1017
|
+
}
|
|
1018
|
+
if (item == null || typeof item === "boolean") continue;
|
|
1019
|
+
if (typeof item === "function") {
|
|
1020
|
+
let resolved;
|
|
1021
|
+
if (isComponent(item) && !(0, import_signal2.isSignal)(item)) {
|
|
1022
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
1023
|
+
if (!componentCache.has(item)) componentCache.set(item, item());
|
|
1024
|
+
resolved = componentCache.get(item);
|
|
1025
|
+
} else {
|
|
1026
|
+
resolved = item();
|
|
1027
|
+
}
|
|
1028
|
+
while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal2.isSignal)(resolved) && !isComponent(resolved)) {
|
|
1029
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
1030
|
+
if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
|
|
1031
|
+
resolved = componentCache.get(resolved);
|
|
1032
|
+
}
|
|
1033
|
+
if (resolved == null || typeof resolved === "boolean") continue;
|
|
1034
|
+
if (typeof resolved === "function") {
|
|
1035
|
+
if ((0, import_signal2.isSignal)(resolved)) {
|
|
1036
|
+
if (reactiveSlots) {
|
|
1037
|
+
const slot = createTextNode("", true);
|
|
1038
|
+
result.push(slot);
|
|
1039
|
+
reactiveSlots.push({ marker: slot, sig: resolved });
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
let val = resolved();
|
|
1043
|
+
while (typeof val === "function" && (0, import_signal2.isSignal)(val)) val = val();
|
|
1044
|
+
if (val == null || typeof val === "boolean") continue;
|
|
1045
|
+
if (Array.isArray(val)) {
|
|
1046
|
+
flattenArray(val, result, parent, marker, track, componentCache);
|
|
1047
|
+
} else flattenArray([val], result, parent, marker, track, componentCache);
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
continue;
|
|
1051
|
+
}
|
|
1052
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
|
|
1053
|
+
else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
if (isPromise(item)) {
|
|
1057
|
+
const placeholder = createTextNode("", true);
|
|
1058
|
+
result.push(placeholder);
|
|
1059
|
+
item.then((resolved) => {
|
|
1060
|
+
if (placeholder.parentNode) {
|
|
1061
|
+
const tempNodes = [];
|
|
1062
|
+
flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
|
|
1063
|
+
if (tempNodes.length > 0) {
|
|
1064
|
+
placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
|
|
1065
|
+
for (let j = 1; j < tempNodes.length; j++) {
|
|
1066
|
+
placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}).catch((err) => console.error("Error resolving promise in array:", err));
|
|
1071
|
+
continue;
|
|
1072
|
+
}
|
|
1073
|
+
if (Array.isArray(item)) {
|
|
1074
|
+
flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
1077
|
+
if (isDomNode(item)) {
|
|
1078
|
+
result.push(item);
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
|
|
1082
|
+
const jsxItem = item;
|
|
1083
|
+
if (typeof jsxItem.type === "function") {
|
|
1084
|
+
const resolved = jsxItem.type(jsxItem.props || {});
|
|
1085
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
|
|
1086
|
+
else flattenArray([resolved], result, parent, marker, false, componentCache);
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
1091
|
+
const str = String(item);
|
|
1092
|
+
if (str.trim() === "" && str !== " ") continue;
|
|
1093
|
+
result.push(createTextNode(str));
|
|
1094
|
+
continue;
|
|
1095
|
+
}
|
|
1096
|
+
result.push(createTextNode(String(item)));
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function reconcileArrays(parent, a, b, marker) {
|
|
1100
|
+
for (let i = 0; i < b.length; i++) {
|
|
1101
|
+
const owner = b[i].parentNode;
|
|
1102
|
+
if (owner !== null && owner !== parent && owner.nodeType !== 11) {
|
|
1103
|
+
b = b.slice();
|
|
1104
|
+
b[i] = b[i].cloneNode(true);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
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;
|
|
1108
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
1109
|
+
if (a[aStart] === b[bStart]) {
|
|
1110
|
+
aStart++;
|
|
1111
|
+
bStart++;
|
|
1112
|
+
continue;
|
|
1113
|
+
}
|
|
1114
|
+
while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
|
|
1115
|
+
aEnd--;
|
|
1116
|
+
bEnd--;
|
|
1117
|
+
}
|
|
1118
|
+
if (aEnd === aStart) {
|
|
1119
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
|
|
1120
|
+
while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
|
|
1121
|
+
} else if (bEnd === bStart) {
|
|
1122
|
+
while (aStart < aEnd) {
|
|
1123
|
+
if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
|
|
1124
|
+
parent.removeChild(a[aStart]);
|
|
1125
|
+
aStart++;
|
|
1126
|
+
}
|
|
1127
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
1128
|
+
const node = a[--aEnd].nextSibling;
|
|
1129
|
+
insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
|
|
1130
|
+
insertBefore(parent, b[--bEnd], node);
|
|
1131
|
+
a[aEnd] = a[aStart - 1];
|
|
1132
|
+
} else {
|
|
1133
|
+
if (!map) {
|
|
1134
|
+
map = /* @__PURE__ */ new Map();
|
|
1135
|
+
let i = bStart;
|
|
1136
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
1137
|
+
}
|
|
1138
|
+
const index = map.get(a[aStart]);
|
|
1139
|
+
if (index != null) {
|
|
1140
|
+
if (bStart < index && index < bEnd) {
|
|
1141
|
+
let i = aStart, sequence = 1;
|
|
1142
|
+
while (++i < aEnd && i < bEnd) {
|
|
1143
|
+
if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
|
|
1144
|
+
sequence++;
|
|
1145
|
+
}
|
|
1146
|
+
if (sequence > index - bStart) {
|
|
1147
|
+
const node = a[aStart];
|
|
1148
|
+
while (bStart < index) insertBefore(parent, b[bStart++], node);
|
|
1149
|
+
} else {
|
|
1150
|
+
if (a[aStart].parentNode === parent) {
|
|
1151
|
+
parent.replaceChild(b[bStart++], a[aStart++]);
|
|
1152
|
+
} else {
|
|
1153
|
+
insertBefore(parent, b[bStart++], after);
|
|
1154
|
+
aStart++;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
} else {
|
|
1158
|
+
aStart++;
|
|
1159
|
+
}
|
|
1160
|
+
} else {
|
|
1161
|
+
if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
|
|
1162
|
+
aStart++;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
return b;
|
|
1167
|
+
}
|
|
1168
|
+
function cleanChildren(parent, current, marker) {
|
|
1169
|
+
if (current) {
|
|
1170
|
+
if (Array.isArray(current)) {
|
|
1171
|
+
for (let i = 0; i < current.length; i++) {
|
|
1172
|
+
if (current[i].parentNode === parent) parent.removeChild(current[i]);
|
|
1173
|
+
}
|
|
1174
|
+
} else if (current.parentNode === parent) {
|
|
1175
|
+
parent.removeChild(current);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
1180
|
+
function insertBefore(parent, node, marker) {
|
|
1181
|
+
if (hydration.active && node.parentNode === parent) return;
|
|
1182
|
+
if (marker) {
|
|
1183
|
+
if (marker.parentNode === parent) {
|
|
1184
|
+
parent.insertBefore(node, marker);
|
|
1185
|
+
} else {
|
|
1186
|
+
parent.appendChild(node);
|
|
1187
|
+
}
|
|
1188
|
+
} else {
|
|
1189
|
+
parent.appendChild(node);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
function setProperty(element, name, value) {
|
|
1193
|
+
if (value == null) delete element[name];
|
|
1194
|
+
else element[name] = value;
|
|
1195
|
+
}
|
|
1196
|
+
function addNativeEventListener(element, name, value) {
|
|
1197
|
+
let handler = value;
|
|
1198
|
+
let options;
|
|
1199
|
+
if (Array.isArray(value)) {
|
|
1200
|
+
handler = value[0];
|
|
1201
|
+
options = value[1];
|
|
1202
|
+
}
|
|
1203
|
+
if (typeof handler !== "function") return () => {
|
|
1204
|
+
};
|
|
1205
|
+
element.addEventListener(name, handler, options);
|
|
1206
|
+
return () => element.removeEventListener(name, handler, options);
|
|
1207
|
+
}
|
|
1208
|
+
function reportMarked(element, accessor) {
|
|
1209
|
+
if (!accessor || typeof accessor !== "function") return;
|
|
1210
|
+
const written = accessor[HOLE_TAG]?.name;
|
|
1211
|
+
if (!written) return;
|
|
1212
|
+
const colon = written.indexOf(":");
|
|
1213
|
+
if (colon === -1) return;
|
|
1214
|
+
(0, import_signal3.reportReactiveDirective)(element, written.slice(0, colon), written.slice(colon + 1), accessor);
|
|
1215
|
+
}
|
|
1216
|
+
function reportKeys(element, kind, value) {
|
|
1217
|
+
const from = typeof value === "function" ? (0, import_signal3.untrack)(() => value()) : value;
|
|
1218
|
+
if (!from || typeof from !== "object") return;
|
|
1219
|
+
for (const key of Object.keys(from)) (0, import_signal3.reportReactiveDirective)(element, kind, key);
|
|
1220
|
+
}
|
|
1221
|
+
function applyUse(element, value) {
|
|
1222
|
+
const call = (dir, accessor) => {
|
|
1223
|
+
if (typeof dir !== "function") return;
|
|
1224
|
+
(0, import_signal3.reportReactiveDirective)(element, "use", dir.name || "use", accessor);
|
|
1225
|
+
dir(element, accessor ?? (() => void 0));
|
|
1226
|
+
};
|
|
1227
|
+
if (typeof value === "function") {
|
|
1228
|
+
call(value);
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (!Array.isArray(value)) return;
|
|
1232
|
+
if (typeof value[0] === "function") {
|
|
1233
|
+
call(value[0], value[1]);
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
for (const pair of value) {
|
|
1237
|
+
if (Array.isArray(pair)) call(pair[0], pair[1]);
|
|
1238
|
+
else call(pair);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
function setDynamicAttribute(element, name, accessor, isSVG = false) {
|
|
1242
|
+
reportMarked(element, accessor);
|
|
1243
|
+
if (typeof accessor !== "function") {
|
|
1244
|
+
setAttribute(element, name, accessor, isSVG);
|
|
1245
|
+
return () => {
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
return (0, import_signal3.createRenderEffect)(() => {
|
|
1249
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", name, accessor);
|
|
1250
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
1251
|
+
setAttribute(element, name, value, isSVG);
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
function setDynamicProperty(element, name, accessor) {
|
|
1255
|
+
if (typeof accessor !== "function") {
|
|
1256
|
+
setProperty(element, name, accessor);
|
|
1257
|
+
return () => {
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
reportMarked(element, accessor);
|
|
1261
|
+
return (0, import_signal3.createRenderEffect)(() => {
|
|
1262
|
+
(0, import_signal3.reportReactiveBinding)(element, "property", name, accessor);
|
|
1263
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
1264
|
+
setProperty(element, name, value);
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
function setDynamicBoolAttribute(element, name, accessor) {
|
|
1268
|
+
if (typeof accessor !== "function") {
|
|
1269
|
+
setAttribute(element, name, !!accessor);
|
|
1270
|
+
return () => {
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
return (0, import_signal3.createRenderEffect)(() => {
|
|
1274
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", name, accessor);
|
|
1275
|
+
const value = accessor();
|
|
1276
|
+
setAttribute(element, name, !!value);
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
function setClassName(element, value) {
|
|
1280
|
+
if (value == null) {
|
|
1281
|
+
element.removeAttribute("class");
|
|
1282
|
+
return;
|
|
1283
|
+
}
|
|
1284
|
+
if (typeof value === "function") {
|
|
1285
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1286
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
|
|
1287
|
+
setClassName(element, value());
|
|
1288
|
+
});
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
if (typeof value === "string") {
|
|
1292
|
+
element.setAttribute("class", value);
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
if (Array.isArray(value)) {
|
|
1296
|
+
element.setAttribute("class", value.filter(Boolean).join(" "));
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
if (typeof value === "object") {
|
|
1300
|
+
const classes = Object.keys(value).filter((key) => {
|
|
1301
|
+
const v = value[key];
|
|
1302
|
+
return typeof v === "function" ? v() : Boolean(v);
|
|
1303
|
+
}).join(" ");
|
|
1304
|
+
element.setAttribute("class", classes);
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
element.setAttribute("class", String(value));
|
|
1308
|
+
}
|
|
1309
|
+
function setClassList(element, value, disposers) {
|
|
1310
|
+
if (!value || typeof value !== "object") return;
|
|
1311
|
+
for (const name in value) {
|
|
1312
|
+
const cond = value[name];
|
|
1313
|
+
const names = name.split(/\s+/).filter(Boolean);
|
|
1314
|
+
if (typeof cond === "function" && disposers) {
|
|
1315
|
+
disposers.push(
|
|
1316
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1317
|
+
const on = !!cond();
|
|
1318
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
1319
|
+
})
|
|
1320
|
+
);
|
|
1321
|
+
} else {
|
|
1322
|
+
const on = !!(typeof cond === "function" ? cond() : cond);
|
|
1323
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function setStyle(element, _value) {
|
|
1328
|
+
let value = _value;
|
|
1329
|
+
while (typeof value === "function") value = value();
|
|
1330
|
+
if (value == null) {
|
|
1331
|
+
element.removeAttribute("style");
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
if (typeof value === "string") {
|
|
1335
|
+
element.style.cssText = value;
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
if (typeof value === "object") {
|
|
1339
|
+
for (const key in value) {
|
|
1340
|
+
const styleValue = value[key];
|
|
1341
|
+
if (styleValue == null) element.style[key] = "";
|
|
1342
|
+
else element.style[key] = styleValue;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
function spread(options) {
|
|
1347
|
+
const {
|
|
1348
|
+
element,
|
|
1349
|
+
props,
|
|
1350
|
+
prevProps = EMPTY_OBJ,
|
|
1351
|
+
isSVG = false,
|
|
1352
|
+
skipChildren = false
|
|
1353
|
+
} = options;
|
|
1354
|
+
if (!element || !isDomElement(element)) {
|
|
1355
|
+
console.error("[spread] Error: element is not a DOM Element!");
|
|
1356
|
+
return () => {
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
if (!props) {
|
|
1360
|
+
console.warn("[spread] Warning: props is undefined!");
|
|
1361
|
+
return () => {
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
const elementIsSVG = isSVG || element.namespaceURI === SVG_NAMESPACE;
|
|
1365
|
+
const disposers = [];
|
|
1366
|
+
for (const key in props) {
|
|
1367
|
+
if (skipChildren && key === "children") continue;
|
|
1368
|
+
const value = props[key];
|
|
1369
|
+
const prev = prevProps[key];
|
|
1370
|
+
if (value === prev) continue;
|
|
1371
|
+
if (key === "ref") {
|
|
1372
|
+
handleRef(value, element);
|
|
1373
|
+
continue;
|
|
1374
|
+
}
|
|
1375
|
+
if (key === "use") {
|
|
1376
|
+
applyUse(element, value);
|
|
1377
|
+
continue;
|
|
1378
|
+
}
|
|
1379
|
+
if (key.startsWith("on:")) {
|
|
1380
|
+
disposers.push(addNativeEventListener(element, key.slice(3), value));
|
|
1381
|
+
continue;
|
|
1382
|
+
}
|
|
1383
|
+
if (key.startsWith("prop:")) {
|
|
1384
|
+
(0, import_signal3.reportReactiveDirective)(element, "prop", key.slice(5), value);
|
|
1385
|
+
disposers.push(setDynamicProperty(element, key.slice(5), value));
|
|
1386
|
+
continue;
|
|
1387
|
+
}
|
|
1388
|
+
if (key.startsWith("attr:")) {
|
|
1389
|
+
(0, import_signal3.reportReactiveDirective)(element, "attr", key.slice(5), value);
|
|
1390
|
+
disposers.push(setDynamicAttribute(element, key.slice(5), value, elementIsSVG));
|
|
1391
|
+
continue;
|
|
1392
|
+
}
|
|
1393
|
+
if (key.startsWith("bool:")) {
|
|
1394
|
+
(0, import_signal3.reportReactiveDirective)(element, "bool", key.slice(5), value);
|
|
1395
|
+
disposers.push(setDynamicBoolAttribute(element, key.slice(5), value));
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
if (key === "class" || key === "className") {
|
|
1399
|
+
if (typeof value === "function") {
|
|
1400
|
+
disposers.push(
|
|
1401
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1402
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
|
|
1403
|
+
setClassName(element, value());
|
|
1404
|
+
})
|
|
1405
|
+
);
|
|
1406
|
+
} else {
|
|
1407
|
+
setClassName(element, value);
|
|
1408
|
+
}
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1411
|
+
if (key === "classList") {
|
|
1412
|
+
reportKeys(element, "class", value);
|
|
1413
|
+
if (typeof value === "function") {
|
|
1414
|
+
disposers.push(
|
|
1415
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1416
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
|
|
1417
|
+
setClassList(element, value());
|
|
1418
|
+
})
|
|
1419
|
+
);
|
|
1420
|
+
} else {
|
|
1421
|
+
setClassList(element, value, disposers);
|
|
1422
|
+
}
|
|
1423
|
+
continue;
|
|
1424
|
+
}
|
|
1425
|
+
if (key === "style") {
|
|
1426
|
+
reportKeys(element, "style", value);
|
|
1427
|
+
if (typeof value === "function") {
|
|
1428
|
+
disposers.push(
|
|
1429
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1430
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "style", value);
|
|
1431
|
+
setStyle(element, value());
|
|
1432
|
+
})
|
|
1433
|
+
);
|
|
1434
|
+
} else {
|
|
1435
|
+
setStyle(element, value);
|
|
1436
|
+
}
|
|
1437
|
+
continue;
|
|
1438
|
+
}
|
|
1439
|
+
if (key.startsWith("on")) {
|
|
1440
|
+
const eventName = key.slice(2).toLowerCase();
|
|
1441
|
+
if (prev) removeDelegatedEventListener(element, eventName);
|
|
1442
|
+
if (value) addDelegatedEventListener(element, eventName, value);
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1445
|
+
const asProperty = JSX_PROPERTIES.has(key) || !elementIsSVG && key in element;
|
|
1446
|
+
if (typeof value === "function") {
|
|
1447
|
+
disposers.push(
|
|
1448
|
+
asProperty ? setDynamicProperty(element, key, value) : setDynamicAttribute(element, key, value, elementIsSVG)
|
|
1449
|
+
);
|
|
1450
|
+
} else {
|
|
1451
|
+
disposers.push(
|
|
1452
|
+
(0, import_signal3.createRenderEffect)(
|
|
1453
|
+
() => asProperty ? setProperty(element, key, props[key]) : setAttribute(element, key, props[key], elementIsSVG)
|
|
1454
|
+
)
|
|
1455
|
+
);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
for (const key in prevProps) {
|
|
1459
|
+
if (!(key in props)) {
|
|
1460
|
+
if (key.startsWith("on")) {
|
|
1461
|
+
const eventName = key.slice(2).toLowerCase();
|
|
1462
|
+
removeDelegatedEventListener(element, eventName);
|
|
1463
|
+
} else if (JSX_PROPERTIES.has(key)) {
|
|
1464
|
+
setProperty(element, key, null);
|
|
1465
|
+
} else {
|
|
1466
|
+
element.removeAttribute(key);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
return () => {
|
|
1471
|
+
disposers.forEach((d) => d());
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
function applyProps(element, props, isSVG = false) {
|
|
1475
|
+
for (const key in props) {
|
|
1476
|
+
const val = props[key];
|
|
1477
|
+
if (key === "ref") {
|
|
1478
|
+
handleRef(val, element);
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
if (key === "children") continue;
|
|
1482
|
+
if (key === "use") {
|
|
1483
|
+
applyUse(element, val);
|
|
1484
|
+
continue;
|
|
1485
|
+
}
|
|
1486
|
+
if (key.startsWith("on:")) {
|
|
1487
|
+
addNativeEventListener(element, key.slice(3), val);
|
|
1488
|
+
continue;
|
|
1489
|
+
}
|
|
1490
|
+
if (key.startsWith("prop:")) {
|
|
1491
|
+
(0, import_signal3.reportReactiveDirective)(element, "prop", key.slice(5), val);
|
|
1492
|
+
setDynamicProperty(element, key.slice(5), val);
|
|
1493
|
+
continue;
|
|
1494
|
+
}
|
|
1495
|
+
if (key.startsWith("attr:")) {
|
|
1496
|
+
(0, import_signal3.reportReactiveDirective)(element, "attr", key.slice(5), val);
|
|
1497
|
+
setDynamicAttribute(element, key.slice(5), val, isSVG);
|
|
1498
|
+
continue;
|
|
1499
|
+
}
|
|
1500
|
+
if (key.startsWith("bool:")) {
|
|
1501
|
+
(0, import_signal3.reportReactiveDirective)(element, "bool", key.slice(5), val);
|
|
1502
|
+
setDynamicBoolAttribute(element, key.slice(5), val);
|
|
1503
|
+
continue;
|
|
1504
|
+
}
|
|
1505
|
+
if (key.startsWith("on") && key.length > 2) {
|
|
1506
|
+
const name = key.slice(2).toLowerCase();
|
|
1507
|
+
if (typeof val === "function") {
|
|
1508
|
+
if (NON_DELEGATED.has(name)) {
|
|
1509
|
+
element[`$$${name}`] = val;
|
|
1510
|
+
const listenerKey = `__fx_${name}`;
|
|
1511
|
+
if (!element[listenerKey]) {
|
|
1512
|
+
const forwarder = (e) => {
|
|
1513
|
+
element[`$$${name}`]?.(e);
|
|
1514
|
+
};
|
|
1515
|
+
element.addEventListener(name, forwarder);
|
|
1516
|
+
element[listenerKey] = forwarder;
|
|
1517
|
+
}
|
|
1518
|
+
} else {
|
|
1519
|
+
element[`$$${name}`] = val;
|
|
1520
|
+
if (!delegatedSet.has(name)) delegateEvents([name]);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
continue;
|
|
1524
|
+
}
|
|
1525
|
+
if (key === "class" || key === "className") {
|
|
1526
|
+
setClassName(element, val);
|
|
1527
|
+
continue;
|
|
1528
|
+
}
|
|
1529
|
+
if (key === "classList") {
|
|
1530
|
+
reportKeys(element, "class", val);
|
|
1531
|
+
if (typeof val === "function")
|
|
1532
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1533
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "class", val);
|
|
1534
|
+
setClassList(element, val());
|
|
1535
|
+
});
|
|
1536
|
+
else setClassList(element, val);
|
|
1537
|
+
continue;
|
|
1538
|
+
}
|
|
1539
|
+
if (key === "style") {
|
|
1540
|
+
reportKeys(element, "style", val);
|
|
1541
|
+
if (typeof val === "function")
|
|
1542
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1543
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "style", val);
|
|
1544
|
+
setStyle(element, val());
|
|
1545
|
+
});
|
|
1546
|
+
else setStyle(element, val);
|
|
1547
|
+
continue;
|
|
1548
|
+
}
|
|
1549
|
+
if (key === "innerHTML") {
|
|
1550
|
+
if (typeof val === "function") {
|
|
1551
|
+
const dispose = (0, import_signal3.createEffect)(() => {
|
|
1552
|
+
let v = val();
|
|
1553
|
+
while (typeof v === "function") v = v();
|
|
1554
|
+
element.innerHTML = v;
|
|
1555
|
+
});
|
|
1556
|
+
(0, import_signal3.onCleanup)(() => dispose());
|
|
1557
|
+
} else {
|
|
1558
|
+
element.innerHTML = val;
|
|
1559
|
+
}
|
|
1560
|
+
continue;
|
|
1561
|
+
}
|
|
1562
|
+
if (key === "value" && (element.tagName === "INPUT" || element.tagName === "TEXTAREA")) {
|
|
1563
|
+
if (typeof val === "function") {
|
|
1564
|
+
const dispose = (0, import_signal3.createEffect)(() => {
|
|
1565
|
+
let v = val();
|
|
1566
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1567
|
+
if (document.activeElement !== element) {
|
|
1568
|
+
element.value = v ?? "";
|
|
1569
|
+
}
|
|
1570
|
+
});
|
|
1571
|
+
(0, import_signal3.onCleanup)(() => {
|
|
1572
|
+
dispose();
|
|
1573
|
+
});
|
|
1574
|
+
} else {
|
|
1575
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1576
|
+
if (document.activeElement !== element) {
|
|
1577
|
+
element.value = props[key] ?? "";
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
continue;
|
|
1582
|
+
}
|
|
1583
|
+
if (key === "checked" && element.tagName === "INPUT") {
|
|
1584
|
+
if (typeof val === "function") {
|
|
1585
|
+
const dispose = (0, import_signal3.createEffect)(() => {
|
|
1586
|
+
let v = val();
|
|
1587
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1588
|
+
if (document.activeElement !== element) {
|
|
1589
|
+
element.checked = v ?? "";
|
|
1590
|
+
}
|
|
1591
|
+
});
|
|
1592
|
+
(0, import_signal3.onCleanup)(() => {
|
|
1593
|
+
dispose();
|
|
1594
|
+
});
|
|
1595
|
+
} else {
|
|
1596
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1597
|
+
if (document.activeElement !== element) {
|
|
1598
|
+
element.checked = props[key] ?? "";
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
if (key === "value" && element.tagName === "SELECT") {
|
|
1605
|
+
if (typeof val === "function") {
|
|
1606
|
+
let firstRun = true;
|
|
1607
|
+
const dispose = (0, import_signal3.createEffect)(() => {
|
|
1608
|
+
let v = val();
|
|
1609
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1610
|
+
if (firstRun) {
|
|
1611
|
+
firstRun = false;
|
|
1612
|
+
queueMicrotask(() => {
|
|
1613
|
+
element.value = v ?? "";
|
|
1614
|
+
});
|
|
1615
|
+
} else {
|
|
1616
|
+
element.value = v ?? "";
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
(0, import_signal3.onCleanup)(() => {
|
|
1620
|
+
dispose();
|
|
1621
|
+
});
|
|
1622
|
+
} else {
|
|
1623
|
+
let firstRun = true;
|
|
1624
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
1625
|
+
const v = props[key];
|
|
1626
|
+
if (firstRun) {
|
|
1627
|
+
firstRun = false;
|
|
1628
|
+
queueMicrotask(() => {
|
|
1629
|
+
element.value = v ?? "";
|
|
1630
|
+
});
|
|
1631
|
+
} else {
|
|
1632
|
+
element.value = v ?? "";
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
continue;
|
|
1637
|
+
}
|
|
1638
|
+
if (typeof val === "function") {
|
|
1639
|
+
const dispose = (0, import_signal3.createEffect)(() => {
|
|
1640
|
+
let v = val();
|
|
1641
|
+
while (typeof v === "function" && v.length === 0) v = v();
|
|
1642
|
+
applyElementProp(element, key, v, isSVG);
|
|
1643
|
+
});
|
|
1644
|
+
(0, import_signal3.onCleanup)(() => {
|
|
1645
|
+
dispose();
|
|
1646
|
+
});
|
|
1647
|
+
} else {
|
|
1648
|
+
(0, import_signal3.createRenderEffect)(() => applyElementProp(element, key, props[key], isSVG));
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
function mergeProps(...sources) {
|
|
1653
|
+
const resolve = (key) => {
|
|
1654
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1655
|
+
const s = sources[i];
|
|
1656
|
+
if (s && key in s && s[key] !== void 0) return s[key];
|
|
1657
|
+
}
|
|
1658
|
+
return void 0;
|
|
1659
|
+
};
|
|
1660
|
+
const hasKey = (key) => {
|
|
1661
|
+
for (const s of sources) if (s && key in s) return true;
|
|
1662
|
+
return false;
|
|
1663
|
+
};
|
|
1664
|
+
return new Proxy({}, {
|
|
1665
|
+
get: (_, key) => resolve(key),
|
|
1666
|
+
has: (_, key) => hasKey(key),
|
|
1667
|
+
ownKeys: () => {
|
|
1668
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1669
|
+
for (const s of sources) if (s) for (const k of Reflect.ownKeys(s)) keys.add(k);
|
|
1670
|
+
return [...keys];
|
|
1671
|
+
},
|
|
1672
|
+
getOwnPropertyDescriptor: (_, key) => hasKey(key) ? { enumerable: true, configurable: true, get: () => resolve(key) } : void 0
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
function splitProps(props, ...keys) {
|
|
1676
|
+
const taken = /* @__PURE__ */ new Set();
|
|
1677
|
+
for (const group of keys) for (const k of group) taken.add(k);
|
|
1678
|
+
const descriptor = (p) => ({
|
|
1679
|
+
enumerable: true,
|
|
1680
|
+
configurable: true,
|
|
1681
|
+
get: () => props[p]
|
|
1682
|
+
});
|
|
1683
|
+
const groups = keys.map((group) => {
|
|
1684
|
+
const keySet = new Set(group);
|
|
1685
|
+
return new Proxy({}, {
|
|
1686
|
+
get: (_, p) => keySet.has(p) ? props[p] : void 0,
|
|
1687
|
+
has: (_, p) => keySet.has(p) && p in props,
|
|
1688
|
+
ownKeys: () => Array.from(keySet).filter((k) => k in props),
|
|
1689
|
+
getOwnPropertyDescriptor: (_, p) => keySet.has(p) && p in props ? descriptor(p) : void 0
|
|
1690
|
+
});
|
|
1691
|
+
});
|
|
1692
|
+
const rest = new Proxy({}, {
|
|
1693
|
+
get: (_, p) => taken.has(p) ? void 0 : props[p],
|
|
1694
|
+
has: (_, p) => !taken.has(p) && p in props,
|
|
1695
|
+
ownKeys: () => Reflect.ownKeys(props).filter((k) => !taken.has(k)),
|
|
1696
|
+
getOwnPropertyDescriptor: (_, p) => !taken.has(p) && p in props ? descriptor(p) : void 0
|
|
1697
|
+
});
|
|
1698
|
+
return [...groups, rest];
|
|
1699
|
+
}
|
|
1700
|
+
function handleRef(ref, element) {
|
|
1701
|
+
if (!ref) return;
|
|
1702
|
+
const held = ref[HOLE_TAG]?.name;
|
|
1703
|
+
(0, import_signal3.reportReactiveDirective)(
|
|
1704
|
+
element,
|
|
1705
|
+
"ref",
|
|
1706
|
+
held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
|
|
1707
|
+
ref
|
|
1708
|
+
);
|
|
1709
|
+
if (isDomNode(ref)) {
|
|
1710
|
+
const actualRef = element;
|
|
1711
|
+
const actualElement = ref;
|
|
1712
|
+
if (!actualRef) return;
|
|
1713
|
+
if (typeof actualRef === "function") actualRef(actualElement);
|
|
1714
|
+
else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
if (typeof ref === "function") ref(element);
|
|
1718
|
+
else if (typeof ref === "object" && "current" in ref) ref.current = element;
|
|
1719
|
+
}
|
|
1720
|
+
function createPortal(children, element, props) {
|
|
1721
|
+
const container = element || document.body;
|
|
1722
|
+
const resolved = (0, import_signal3.readChildren)(() => children);
|
|
1723
|
+
const cleanups = [];
|
|
1724
|
+
(0, import_signal3.batch)(() => {
|
|
1725
|
+
const dispose = (0, import_signal3.createRenderEffect)(() => {
|
|
1726
|
+
const nodes = resolved();
|
|
1727
|
+
if (Array.isArray(nodes)) {
|
|
1728
|
+
nodes.forEach((node) => container.appendChild(node));
|
|
1729
|
+
cleanups.push(() => {
|
|
1730
|
+
nodes.forEach((node) => {
|
|
1731
|
+
if (node.parentNode === container) {
|
|
1732
|
+
container.removeChild(node);
|
|
1733
|
+
}
|
|
1734
|
+
});
|
|
1735
|
+
});
|
|
1736
|
+
} else if (isDomNode(nodes)) {
|
|
1737
|
+
container.appendChild(nodes);
|
|
1738
|
+
cleanups.push(() => {
|
|
1739
|
+
if (nodes.parentNode === container) {
|
|
1740
|
+
container.removeChild(nodes);
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
cleanups.push(dispose);
|
|
1746
|
+
(0, import_signal3.onCleanup)(() => {
|
|
1747
|
+
cleanups.forEach((fn) => fn());
|
|
1748
|
+
});
|
|
1749
|
+
});
|
|
1750
|
+
return null;
|
|
1751
|
+
}
|
|
1752
|
+
function isNativeElement(tag) {
|
|
1753
|
+
return typeof tag === "string" && tag.toLowerCase() === tag;
|
|
1754
|
+
}
|
|
1755
|
+
function isSVGElement(tag) {
|
|
1756
|
+
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";
|
|
1757
|
+
}
|
|
1758
|
+
function escapeHTML(str) {
|
|
1759
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1760
|
+
}
|
|
1761
|
+
function isPromise(v) {
|
|
1762
|
+
return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
|
|
1763
|
+
}
|
|
1764
|
+
function isAccessor(value) {
|
|
1765
|
+
return typeof value === "function" && value.length === 0 && (0, import_signal2.isSignal)(value);
|
|
1766
|
+
}
|
|
1767
|
+
function render(element, container, context) {
|
|
1768
|
+
if (!container) {
|
|
1769
|
+
throw new Error("Container element is required");
|
|
1770
|
+
}
|
|
1771
|
+
let rendererDispose;
|
|
1772
|
+
let disposeRoot;
|
|
1773
|
+
const disposers = [];
|
|
1774
|
+
(0, import_signal3.createRoot)((dispose) => {
|
|
1775
|
+
(0, import_signal3.batch)(() => {
|
|
1776
|
+
if (!hydration.active) {
|
|
1777
|
+
container.textContent = "";
|
|
1778
|
+
}
|
|
1779
|
+
stampVersions(container);
|
|
1780
|
+
warnOnVersionSkew();
|
|
1781
|
+
insert(container, element);
|
|
1782
|
+
return;
|
|
1783
|
+
});
|
|
1784
|
+
disposeRoot = dispose;
|
|
1785
|
+
});
|
|
1786
|
+
return () => {
|
|
1787
|
+
disposeRoot?.();
|
|
1788
|
+
rendererDispose?.();
|
|
1789
|
+
disposers.forEach((d) => d());
|
|
1790
|
+
container.textContent = "";
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
function bindPair(source) {
|
|
1794
|
+
if (Array.isArray(source)) return source;
|
|
1795
|
+
if (typeof source === "function" && typeof source.set === "function") {
|
|
1796
|
+
return [source, source.set];
|
|
1797
|
+
}
|
|
1798
|
+
throw new TypeError(
|
|
1799
|
+
"[fluixi] bind: needs a signal, either `signal(...)` or the `[get, set]` pair from `createSignal(...)`."
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
// src/lib/dom/integration.ts
|
|
1804
|
+
var import_reactive = require("@fluixi/reactive");
|
|
1805
|
+
var _slotKey = "__fx_dom_create_component__";
|
|
1806
|
+
var _slot = globalThis[_slotKey] ??= { fn: null };
|
|
1807
|
+
function registerCreateComponent(createComponent2) {
|
|
1808
|
+
_slot.fn = createComponent2;
|
|
1809
|
+
}
|
|
1810
|
+
function initializeIntegration(options = {}) {
|
|
1811
|
+
const cc = options.signalSystem?.createComponent;
|
|
1812
|
+
if (cc) _slot.fn = cc;
|
|
1813
|
+
}
|
|
1814
|
+
function createComponent(Comp, props) {
|
|
1815
|
+
if (_slot.fn) return _slot.fn(Comp, props);
|
|
1816
|
+
if (props) (0, import_reactive.reportReactiveProps)(props);
|
|
1817
|
+
const component = typeof Comp === "function" ? (0, import_reactive.untrack)(() => Comp(props)) : Comp;
|
|
1818
|
+
const nameable = component != null && (typeof component === "function" || typeof component === "object");
|
|
1819
|
+
if (nameable) {
|
|
1820
|
+
try {
|
|
1821
|
+
component["$name"] = Comp?.name;
|
|
1822
|
+
} catch {
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
if (nameable && !(0, import_reactive.isSignal)(component)) {
|
|
1826
|
+
return asComponent(component);
|
|
1827
|
+
}
|
|
1828
|
+
return component;
|
|
1829
|
+
}
|
|
1830
|
+
var intergartionInitialized = () => _slot.fn !== null;
|
|
1831
|
+
var isIntegrationInitialized = () => _slot.fn !== null;
|
|
1832
|
+
function resetIntegration() {
|
|
1833
|
+
_slot.fn = null;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
// src/lib/dom/server/request-context.ts
|
|
1837
|
+
var _current;
|
|
1838
|
+
var syncStore = {
|
|
1839
|
+
getStore: () => _current,
|
|
1840
|
+
run(ctx, fn) {
|
|
1841
|
+
const prev = _current;
|
|
1842
|
+
_current = ctx;
|
|
1843
|
+
try {
|
|
1844
|
+
return fn();
|
|
1845
|
+
} finally {
|
|
1846
|
+
_current = prev;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
};
|
|
1850
|
+
var _store = syncStore;
|
|
1851
|
+
function getRequestContext() {
|
|
1852
|
+
return _store.getStore();
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
// src/lib/dom/hydration.ts
|
|
1856
|
+
var import_signal4 = require("@fluixi/reactive/signal");
|
|
1857
|
+
|
|
1858
|
+
// src/lib/dom/server/fx-data.ts
|
|
1859
|
+
var FX_DATA_ID = "__FX_DATA__";
|
|
1860
|
+
var _scriptCache;
|
|
1861
|
+
function getServerData() {
|
|
1862
|
+
const g = globalThis.__FX_DATA__;
|
|
1863
|
+
if (g) return g;
|
|
1864
|
+
if (_scriptCache !== void 0) return _scriptCache;
|
|
1865
|
+
let parsed = null;
|
|
1866
|
+
if (typeof document !== "undefined") {
|
|
1867
|
+
const text = document.getElementById(FX_DATA_ID)?.textContent;
|
|
1868
|
+
if (text) {
|
|
1869
|
+
try {
|
|
1870
|
+
parsed = JSON.parse(text);
|
|
1871
|
+
} catch {
|
|
1872
|
+
parsed = null;
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
return _scriptCache = parsed;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
// src/lib/dom/hydration.ts
|
|
1880
|
+
function recoverCursor() {
|
|
1881
|
+
for (; ; ) {
|
|
1882
|
+
while (hydration.cursor && hydration.cursor.nodeType === 3 && hydration.cursor.data === "") {
|
|
1883
|
+
hydration.cursor = hydration.cursor.nextSibling;
|
|
1884
|
+
}
|
|
1885
|
+
if (hydration.cursor != null || !hydration.parents.length) return;
|
|
1886
|
+
hydration.cursor = hydration.parents.pop().nextSibling;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
var VOID_ELEMENTS2 = /* @__PURE__ */ new Set([
|
|
1890
|
+
"area",
|
|
1891
|
+
"base",
|
|
1892
|
+
"br",
|
|
1893
|
+
"col",
|
|
1894
|
+
"embed",
|
|
1895
|
+
"hr",
|
|
1896
|
+
"img",
|
|
1897
|
+
"input",
|
|
1898
|
+
"link",
|
|
1899
|
+
"meta",
|
|
1900
|
+
"param",
|
|
1901
|
+
"source",
|
|
1902
|
+
"track",
|
|
1903
|
+
"wbr"
|
|
1904
|
+
]);
|
|
1905
|
+
var DEV = typeof process !== "undefined" && process.env && false;
|
|
1906
|
+
function warnMismatch(expected, found) {
|
|
1907
|
+
const f = found.nodeType === 1 ? `<${found.tagName.toLowerCase()}>` : found.nodeType === 3 ? `text ${JSON.stringify((found.nodeValue ?? "").slice(0, 24))}` : found.nodeType === 8 ? "comment" : "node";
|
|
1908
|
+
console.warn(
|
|
1909
|
+
`[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).`
|
|
1910
|
+
);
|
|
1911
|
+
}
|
|
1912
|
+
function hydrateElement(tag) {
|
|
1913
|
+
recoverCursor();
|
|
1914
|
+
const c = hydration.cursor;
|
|
1915
|
+
if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
|
|
1916
|
+
if (VOID_ELEMENTS2.has(tag.toLowerCase())) {
|
|
1917
|
+
hydration.cursor = c.nextSibling;
|
|
1918
|
+
} else {
|
|
1919
|
+
hydration.parents.push(c);
|
|
1920
|
+
hydration.cursor = c.firstChild;
|
|
1921
|
+
}
|
|
1922
|
+
return c;
|
|
1923
|
+
}
|
|
1924
|
+
if (DEV && c) warnMismatch(`<${tag}>`, c);
|
|
1925
|
+
return null;
|
|
1926
|
+
}
|
|
1927
|
+
function hydrateStatic(tag) {
|
|
1928
|
+
recoverCursor();
|
|
1929
|
+
const c = hydration.cursor;
|
|
1930
|
+
if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
|
|
1931
|
+
hydration.cursor = c.nextSibling;
|
|
1932
|
+
return c;
|
|
1933
|
+
}
|
|
1934
|
+
if (DEV && c) warnMismatch(`<${tag}> (static)`, c);
|
|
1935
|
+
return null;
|
|
1936
|
+
}
|
|
1937
|
+
function hydrateText(value) {
|
|
1938
|
+
if (value === "") {
|
|
1939
|
+
const c2 = hydration.cursor;
|
|
1940
|
+
if (c2 && c2.nodeType === 3 && c2.data !== "") {
|
|
1941
|
+
hydration.cursor = c2.nextSibling;
|
|
1942
|
+
c2.data = "";
|
|
1943
|
+
return c2;
|
|
1944
|
+
}
|
|
1945
|
+
return null;
|
|
1946
|
+
}
|
|
1947
|
+
recoverCursor();
|
|
1948
|
+
const c = hydration.cursor;
|
|
1949
|
+
if (c && c.nodeType === 3) {
|
|
1950
|
+
hydration.cursor = c.nextSibling;
|
|
1951
|
+
if (c.nodeValue !== value) c.nodeValue = value;
|
|
1952
|
+
return c;
|
|
1953
|
+
}
|
|
1954
|
+
if (DEV && c) warnMismatch(`text ${JSON.stringify(value.slice(0, 24))}`, c);
|
|
1955
|
+
return null;
|
|
1956
|
+
}
|
|
1957
|
+
function hydrateMarker(value) {
|
|
1958
|
+
recoverCursor();
|
|
1959
|
+
const c = hydration.cursor;
|
|
1960
|
+
if (c && c.nodeType === 8 && c.data === value) {
|
|
1961
|
+
hydration.cursor = c.nextSibling;
|
|
1962
|
+
return c;
|
|
1963
|
+
}
|
|
1964
|
+
if (DEV && c) warnMismatch(`marker <!--${value.slice(0, 24)}-->`, c);
|
|
1965
|
+
return null;
|
|
1966
|
+
}
|
|
1967
|
+
var _walkerRegistered = false;
|
|
1968
|
+
function ensureWalker() {
|
|
1969
|
+
if (_walkerRegistered) return;
|
|
1970
|
+
_walkerRegistered = true;
|
|
1971
|
+
registerHydrationWalker({ hydrateElement, hydrateText, hydrateMarker, hydrateStatic });
|
|
1972
|
+
}
|
|
1973
|
+
function hydrate(element, container, options) {
|
|
1974
|
+
ensureWalker();
|
|
1975
|
+
hydration.active = true;
|
|
1976
|
+
hydration.cursor = container.firstChild;
|
|
1977
|
+
hydration.parents = [];
|
|
1978
|
+
const data = getServerData();
|
|
1979
|
+
const ns = options?.resourceNamespace;
|
|
1980
|
+
let rid = 0;
|
|
1981
|
+
(0, import_signal4.setResourceIdSource)(() => ns ? `${ns}:r${rid++}` : `r${rid++}`);
|
|
1982
|
+
(0, import_signal4.setServerDataGetter)(data ? (id) => id in data ? { value: data[id] } : void 0 : null);
|
|
1983
|
+
try {
|
|
1984
|
+
return render(element, container);
|
|
1985
|
+
} finally {
|
|
1986
|
+
hydration.active = false;
|
|
1987
|
+
hydration.cursor = null;
|
|
1988
|
+
hydration.parents = [];
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
// src/lib/dom/island.ts
|
|
1993
|
+
var TAG = "fluixi-island";
|
|
1994
|
+
function Island(props) {
|
|
1995
|
+
const { component, props: cprops = {}, name } = props;
|
|
1996
|
+
const el = createNativeElement(TAG);
|
|
1997
|
+
const islandName = name ?? component.name ?? "Island";
|
|
1998
|
+
setAttribute(el, "name", islandName);
|
|
1999
|
+
setAttribute(el, "props", JSON.stringify(cprops ?? {}));
|
|
2000
|
+
const ctx = isServer() ? getRequestContext() : void 0;
|
|
2001
|
+
if (ctx) {
|
|
2002
|
+
const ns = ctx.nextIslandNamespace(islandName);
|
|
2003
|
+
insert(el, () => ctx.withResourceScope(ns, () => component(cprops)));
|
|
2004
|
+
} else {
|
|
2005
|
+
insert(el, () => component(cprops));
|
|
2006
|
+
}
|
|
2007
|
+
return el;
|
|
2008
|
+
}
|
|
2009
|
+
var _styleInjected = false;
|
|
2010
|
+
function ensureDisplayContents() {
|
|
2011
|
+
if (_styleInjected || typeof document === "undefined") return;
|
|
2012
|
+
_styleInjected = true;
|
|
2013
|
+
const style = document.createElement("style");
|
|
2014
|
+
style.textContent = `${TAG}{display:contents}`;
|
|
2015
|
+
document.head.appendChild(style);
|
|
2016
|
+
}
|
|
2017
|
+
function hydrateIslands(registry) {
|
|
2018
|
+
if (typeof document === "undefined") return;
|
|
2019
|
+
ensureDisplayContents();
|
|
2020
|
+
const els = document.querySelectorAll(TAG);
|
|
2021
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2022
|
+
els.forEach((el) => {
|
|
2023
|
+
const name = el.getAttribute("name") ?? "";
|
|
2024
|
+
const occ = counts.get(name) ?? 0;
|
|
2025
|
+
counts.set(name, occ + 1);
|
|
2026
|
+
const Comp = registry[name];
|
|
2027
|
+
if (!Comp) {
|
|
2028
|
+
if (typeof process === "undefined" || false) {
|
|
2029
|
+
console.warn(`[fluixi] island "${name}" has no component in the registry, left static.`);
|
|
2030
|
+
}
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
2033
|
+
let props = {};
|
|
2034
|
+
try {
|
|
2035
|
+
props = JSON.parse(el.getAttribute("props") || "{}");
|
|
2036
|
+
} catch {
|
|
2037
|
+
}
|
|
2038
|
+
hydrate(() => Comp(props), el, { resourceNamespace: `${name}#${occ}` });
|
|
2039
|
+
});
|
|
2040
|
+
}
|