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