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