@fluixi/dom 1.0.0-alpha.83 → 1.0.0-alpha.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/dom-client.cjs +1427 -1
- package/dist/cdn/dom-client.d.ts +2 -2
- package/dist/cdn/dom-client.global.js +2 -1
- package/dist/cdn/dom-client.js +3 -3
- package/dist/cdn/dom-client.mjs +1430 -1
- package/dist/cdn/dom.cjs +3127 -1
- package/dist/cdn/dom.d.ts +2 -2
- package/dist/cdn/dom.global.js +2 -1
- package/dist/cdn/dom.js +4 -4
- package/dist/cdn/dom.mjs +3133 -1
- package/dist/index.cjs +3155 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +3149 -1
- package/dist/lib/component/index.cjs +128 -1
- package/dist/lib/component/index.mjs +105 -1
- package/dist/lib/component/modifiers.cjs +126 -1
- package/dist/lib/component/modifiers.d.ts +12 -0
- package/dist/lib/component/modifiers.d.ts.map +1 -1
- package/dist/lib/component/modifiers.js +12 -84
- package/dist/lib/component/modifiers.mjs +105 -1
- package/dist/lib/dom/delegate.cjs +60 -1
- package/dist/lib/dom/delegate.js +1 -1
- package/dist/lib/dom/delegate.mjs +39 -1
- package/dist/lib/dom/dynamic-element.cjs +949 -1
- package/dist/lib/dom/dynamic-element.d.ts +3 -3
- package/dist/lib/dom/dynamic-element.js +2 -2
- package/dist/lib/dom/dynamic-element.mjs +928 -1
- package/dist/lib/dom/hydration-state.cjs +93 -1
- package/dist/lib/dom/hydration-state.d.ts +1 -1
- package/dist/lib/dom/hydration-state.js +1 -1
- package/dist/lib/dom/hydration-state.mjs +72 -1
- package/dist/lib/dom/hydration.cjs +685 -1
- package/dist/lib/dom/hydration.js +8 -8
- package/dist/lib/dom/hydration.mjs +664 -1
- package/dist/lib/dom/index.cjs +2040 -1
- package/dist/lib/dom/index.js +1 -1
- package/dist/lib/dom/index.mjs +2020 -1
- package/dist/lib/dom/integration.cjs +71 -1
- package/dist/lib/dom/integration.js +3 -3
- package/dist/lib/dom/integration.mjs +51 -1
- package/dist/lib/dom/island.cjs +790 -1
- package/dist/lib/dom/island.d.ts +1 -1
- package/dist/lib/dom/island.js +11 -11
- package/dist/lib/dom/island.mjs +769 -1
- package/dist/lib/dom/runtime.cjs +1432 -1
- package/dist/lib/dom/runtime.d.ts +60 -17
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +122 -79
- package/dist/lib/dom/runtime.mjs +1414 -1
- package/dist/lib/dom/server/fx-data.cjs +53 -1
- package/dist/lib/dom/server/fx-data.d.ts +5 -5
- package/dist/lib/dom/server/fx-data.js +6 -6
- package/dist/lib/dom/server/fx-data.mjs +32 -1
- package/dist/lib/dom/server/host.cjs +66 -1
- package/dist/lib/dom/server/host.d.ts +6 -0
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.js +7 -1
- package/dist/lib/dom/server/host.mjs +45 -1
- package/dist/lib/dom/server/index.cjs +759 -1
- package/dist/lib/dom/server/index.d.ts +1 -1
- package/dist/lib/dom/server/index.js +1 -1
- package/dist/lib/dom/server/index.mjs +743 -1
- package/dist/lib/dom/server/nodes.cjs +302 -1
- package/dist/lib/dom/server/nodes.d.ts +2 -2
- package/dist/lib/dom/server/nodes.d.ts.map +1 -1
- package/dist/lib/dom/server/nodes.js +4 -4
- package/dist/lib/dom/server/nodes.mjs +279 -1
- package/dist/lib/dom/server/parse-template.cjs +395 -1
- package/dist/lib/dom/server/parse-template.d.ts +1 -1
- package/dist/lib/dom/server/parse-template.js +4 -4
- package/dist/lib/dom/server/parse-template.mjs +372 -1
- package/dist/lib/dom/server/render.cjs +691 -1
- package/dist/lib/dom/server/render.d.ts +9 -1
- package/dist/lib/dom/server/render.d.ts.map +1 -1
- package/dist/lib/dom/server/render.js +23 -15
- package/dist/lib/dom/server/render.mjs +677 -1
- package/dist/lib/dom/server/request-context.cjs +110 -1
- package/dist/lib/dom/server/request-context.d.ts +29 -9
- package/dist/lib/dom/server/request-context.d.ts.map +1 -1
- package/dist/lib/dom/server/request-context.js +28 -8
- package/dist/lib/dom/server/request-context.mjs +89 -1
- package/dist/lib/dom/server/serialize.cjs +187 -1
- package/dist/lib/dom/server/serialize.js +3 -3
- package/dist/lib/dom/server/serialize.mjs +164 -1
- package/dist/lib/dom/server-renderer.cjs +760 -1
- package/dist/lib/dom/server-renderer.js +1 -1
- package/dist/lib/dom/server-renderer.mjs +745 -1
- package/dist/lib/dom/types.cjs +18 -1
- package/dist/lib/dom/utils.cjs +381 -1
- package/dist/lib/dom/utils.d.ts +1 -88
- package/dist/lib/dom/utils.d.ts.map +1 -1
- package/dist/lib/dom/utils.js +2 -99
- package/dist/lib/dom/utils.mjs +361 -1
- package/dist/lib/dom/versions.cjs +60 -1
- package/dist/lib/dom/versions.d.ts +3 -3
- package/dist/lib/dom/versions.d.ts.map +1 -1
- package/dist/lib/dom/versions.js +17 -5
- package/dist/lib/dom/versions.mjs +37 -1
- package/dist/lib/element/attributes.cjs +19 -1
- package/dist/lib/element/attributes.d.ts +7 -7
- package/dist/lib/element/attributes.js +1 -1
- package/dist/lib/element/attributes.mjs +1 -0
- package/dist/lib/element/index.cjs +19 -1
- package/dist/lib/element/index.mjs +1 -0
- package/dist/lib/element/types.cjs +18 -1
- package/dist/lib/element/types.d.ts +4 -5
- package/dist/lib/element/types.d.ts.map +1 -1
- package/dist/lib/element/types.js +0 -1
- package/dist/lib/flow/class-map.cjs +38 -1
- package/dist/lib/flow/class-map.d.ts +3 -3
- package/dist/lib/flow/class-map.js +2 -2
- package/dist/lib/flow/class-map.mjs +17 -1
- package/dist/lib/flow/client-only.cjs +57 -1
- package/dist/lib/flow/client-only.d.ts +4 -4
- package/dist/lib/flow/client-only.js +3 -3
- package/dist/lib/flow/client-only.mjs +36 -1
- package/dist/lib/flow/dynamic.cjs +53 -1
- package/dist/lib/flow/dynamic.d.ts +2 -2
- package/dist/lib/flow/dynamic.js +3 -3
- package/dist/lib/flow/dynamic.mjs +32 -1
- package/dist/lib/flow/error-boundary.cjs +43 -1
- package/dist/lib/flow/error-boundary.d.ts +2 -2
- package/dist/lib/flow/error-boundary.js +3 -3
- package/dist/lib/flow/error-boundary.mjs +22 -1
- package/dist/lib/flow/for.cjs +66 -1
- package/dist/lib/flow/for.d.ts +9 -9
- package/dist/lib/flow/for.d.ts.map +1 -1
- package/dist/lib/flow/for.js +2 -2
- package/dist/lib/flow/for.mjs +45 -1
- package/dist/lib/flow/index-flow.cjs +67 -1
- package/dist/lib/flow/index-flow.d.ts +5 -5
- package/dist/lib/flow/index-flow.js +4 -4
- package/dist/lib/flow/index-flow.mjs +46 -1
- package/dist/lib/flow/index.cjs +805 -1
- package/dist/lib/flow/index.mjs +792 -1
- package/dist/lib/flow/portal.cjs +538 -1
- package/dist/lib/flow/portal.mjs +519 -1
- package/dist/lib/flow/show.cjs +81 -1
- package/dist/lib/flow/show.d.ts +1 -1
- package/dist/lib/flow/show.d.ts.map +1 -1
- package/dist/lib/flow/show.js +4 -115
- package/dist/lib/flow/show.mjs +67 -1
- package/dist/lib/flow/style-map.cjs +43 -1
- package/dist/lib/flow/style-map.d.ts +3 -3
- package/dist/lib/flow/style-map.js +3 -3
- package/dist/lib/flow/style-map.mjs +22 -1
- package/dist/lib/flow/switch.cjs +91 -1
- package/dist/lib/flow/switch.d.ts +3 -3
- package/dist/lib/flow/switch.d.ts.map +1 -1
- package/dist/lib/flow/switch.js +6 -6
- package/dist/lib/flow/switch.mjs +70 -1
- package/dist/lib/flow/utils.cjs +44 -1
- package/dist/lib/flow/utils.d.ts +1 -1
- package/dist/lib/flow/utils.js +1 -1
- package/dist/lib/flow/utils.mjs +23 -1
- package/dist/lib/html.cjs +32 -1
- package/dist/lib/html.d.ts +6 -6
- package/dist/lib/html.js +5 -5
- package/dist/lib/html.mjs +11 -1
- package/dist/lib/index.cjs +3104 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -3
- package/dist/lib/index.mjs +3097 -1
- package/dist/lib/shared/types.cjs +18 -1
- package/dist/lib/shared/types.d.ts +8 -8
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +26 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +2 -2
- package/dist/version.generated.mjs +5 -1
- package/package.json +7 -6
- package/dist/lib/jsx/control-flow/flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/flow.js +0 -627
- package/dist/lib/jsx/control-flow/flow.mjs +0 -0
- package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/for-flow.js +0 -1
- package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
package/dist/cdn/dom-client.cjs
CHANGED
|
@@ -1 +1,1427 @@
|
|
|
1
|
-
"use strict";var z=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Ze=Object.prototype.hasOwnProperty;var Qe=(e,n)=>{for(var t in n)z(e,t,{get:n[t],enumerable:!0})},en=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Ye(n))!Ze.call(e,i)&&i!==t&&z(e,i,{get:()=>n[i],enumerable:!(o=Je(n,i))||o.enumerable});return e};var nn=e=>en(z({},"__esModule",{value:!0}),e);var Sn={};Qe(Sn,{Dynamic:()=>de,ErrorBoundary:()=>ye,For:()=>ae,Index:()=>ce,Match:()=>fe,Portal:()=>pe,Show:()=>se,Switch:()=>ue,batch:()=>p.batch,classMap:()=>me,createComponent:()=>He,createComputed:()=>p.createComputed,createContext:()=>p.createContext,createEffect:()=>p.createEffect,createElement:()=>xe,createMemo:()=>p.createMemo,createRenderEffect:()=>p.createRenderEffect,createResource:()=>p.createResource,createRoot:()=>p.createRoot,createSignal:()=>p.createSignal,delegateEvents:()=>te,effect:()=>p.effect,hydrate:()=>ie,indexArray:()=>A.indexArray,insert:()=>k,keyArray:()=>A.keyArray,mapArray:()=>A.mapArray,memo:()=>p.memo,onCleanup:()=>p.onCleanup,render:()=>I,setAttribute:()=>w,setClassName:()=>O,setProperty:()=>M,setStyle:()=>$,signal:()=>p.signal,spread:()=>$e,store:()=>p.store,styleMap:()=>he,untrack:()=>p.untrack,useContext:()=>p.useContext});module.exports=nn(Sn);var ge="http://www.w3.org/2000/svg";var X=new Set(["className","value","checked","selected","innerHTML","innerText","textContent","indeterminate","htmlFor"]);function w(e,n,t,o=!1){if(t==null||t===!1){e.removeAttribute(n);return}if(t===!0){e.setAttribute(n,"");return}if(typeof t=="object"){e.setAttribute(n,JSON.stringify(t));return}e.setAttribute(n,String(t))}function tn(e,n){Object.assign(e.style,n)}function xe(e,n={},...t){let o=document.createElement(e);return Object.entries(n).forEach(([i,a])=>{if(i==="class"||i==="className")o.className=a;else if(i==="style"&&typeof a=="object")tn(o,a);else if(i.startsWith("on")&&typeof a=="function"){let c=i.slice(2).toLowerCase();o.addEventListener(c,a)}else w(o,i,a)}),t.forEach(i=>{typeof i=="string"?o.appendChild(document.createTextNode(i)):o.appendChild(i)}),o}var vn=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;var b=require("@fluixi/reactive/signal");var be="1.0.0-alpha.83";var Te=require("@fluixi/reactive/version"),x={dom:be,reactive:Te.VERSION};function Ee(e){x.core&&e.setAttribute("fluixi",x.core),e.setAttribute("fx-dom",x.dom),e.setAttribute("fx-reactive",x.reactive),typeof globalThis<"u"&&(globalThis.Fluixi=x)}function we(){let e=[x.core,x.dom,x.reactive].filter(n=>n!==void 0);new Set(e).size<=1||console.warn(`[fluixi] package versions disagree — core ${x.core??"(absent)"}, dom ${x.dom}, reactive ${x.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 Ne(e){return typeof e!="function"||Object.defineProperty(e,Symbol.for("fluixi-component"),{value:!0,enumerable:!0}),e}function P(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var u=require("@fluixi/reactive/signal");var Y=Symbol.for("fluixi.server-node"),on=Symbol.for("fluixi.dom.server-host"),rn=globalThis,J=rn[on]??={server:typeof document>"u",nodes:null};function Z(){return J.server}function Se(){if(!J.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return J.nodes}function _(e){return e!=null&&e[Y]===!0?!0:typeof Node<"u"&&e instanceof Node}function Ae(e){return e!=null&&e[Y]===!0?e.nodeType===1:typeof Element<"u"&&e instanceof Element}function ve(e){return e!=null&&e[Y]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var d={active:!1,cursor:null,parents:[]},Ce=null;function Pe(e){Ce=e}function Re(){return Ce}function Q(e,n){return d.active&&n.parentNode===e}function ee(e){let n=d.parents.lastIndexOf(e);n!==-1&&(d.parents.length=n),d.cursor=e.nextSibling}function D(e){if(!d.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&ee(n)}var sn={};var De="__fx_at";var ne=new Set,Fe=new Set(["scroll","focus","blur","load","error","resize","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture"]);function te(e){if(!Z())for(let n of e)ne.has(n)||Fe.has(n)||(ne.add(n),document.addEventListener(n,an))}function an(e){let n=`$$${e.type}`,t=e.composedPath&&e.composedPath()[0]||e.target;for(;t;){let o=t[n];if(o&&!t.disabled&&(o(e),e.cancelBubble))return;t=t.host&&t.host!==t&&t.host instanceof Element?t.host:t.parentNode}}function cn(e,n,t){if(e[`$$${n}`]=t,Fe.has(n)){let o=`__fx_${n}`;if(!e[o]){let i=a=>{e[`$$${n}`]?.(a)};e.addEventListener(n,i),e[o]=i}return}ne.has(n)||te([n])}function Me(e,n){delete e[`$$${n}`];let t=`__fx_${n}`,o=e[t];o&&(e.removeEventListener(n,o),delete e[t])}function v(e,n=!1){if(Z())return Se().createText(e);if(d.active&&!n){let t=Re()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var S=0,ln=200;function fn(e,n,t,o,i){let a=o,c=new Map;return(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(t??n,"content",void 0,e);let s;if(P(e)&&!(0,b.isSignal)(e)){if(!c.has(e)){S++;try{let r=e();c.set(e,r)}finally{S--}}for(s=c.get(e);typeof s=="function"&&(0,b.isSignal)(s);)s=s()}else for(s=e();typeof s=="function"&&(0,b.isSignal)(s);)s=s();{let r=0;for(;typeof s=="function"&&r++<50;)if(P(s)){if(!c.has(s)){let l=s;S++;try{let f=l();c.set(l,f)}finally{S--}}s=c.get(s)}else if((0,b.isSignal)(s))s=s();else if(s=s(),typeof s!="function"||!(0,b.isSignal)(s)&&!P(s))break}S++;try{a=j(n,s,t,a,c),i(a)}finally{S--}})}function k(e,n,t,o){if(S>ln)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=v("",!0),e.appendChild(t));let i=o??null,a=r=>Array.isArray(r)&&r.some(l=>typeof l=="function"),c=r=>typeof r=="function"?r:()=>r;if(typeof n!="function"&&!a(n)){S++;try{i=j(e,n,t,i)}finally{S--}return()=>i}let s=fn(c(n),e,t,i,r=>{i=r});return()=>(s?.(),i)}function j(e,n,t,o,i){if(n==null||typeof n=="boolean")return R(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return R(e,o,t);if(F(n)){let c=v("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(c,o[0]),R(e,o.slice(1),t)):g(e,c,t):o?e.replaceChild(c,o):g(e,c,t),n.then(s=>{c.parentNode===e&&j(e,s,c.nextSibling,c)}).catch(s=>{console.error("Error resolving promise in insertExpression:",s)}),c}let a=typeof n;if(a==="string"||a==="number"){if(a==="number"&&(n=String(n)),Array.isArray(o)){if(o.length===0){let s=v(n);return g(e,s,t),s}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=R(e,o,t)}if(o&&ve(o))return o.data=n,o;let c=v(n);return o&&o.parentNode===e?e.replaceChild(c,o):Q(e,c)||g(e,c,t),c}if(_(n))return Q(e,n)?(ee(n),n):Array.isArray(o)?(o.length===0?g(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),R(e,o.slice(1),t)):g(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):g(e,n,t)):g(e,n,t),n);if(Array.isArray(n)){let c=[],s=Array.isArray(o)?o:o?[o]:[],r=[];N(n,c,e,t,!0,i,r);let l=un(e,s,c,t);for(let f of r){let y=k(e,f.sig,f.marker);(0,u.onCleanup)(()=>{R(e,y()),f.marker.parentNode===e&&e.removeChild(f.marker)})}return l}if(a==="object"&&n!==null&&typeof n=="object"){let c=n;if("type"in c&&"props"in c){let s=c;if(typeof s.type=="function"){let r=s.type(s.props||{});return j(e,r,t,o)}}}return R(e,o,t)}function N(e,n,t,o,i=!0,a,c){for(let s=0;s<e.length;s++){let r=e[s];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!F(r)&&!(0,b.isSignal)(r)&&!P(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let l;for(P(r)&&!(0,b.isSignal)(r)?(a||(a=new Map),a.has(r)||a.set(r,r()),l=a.get(r)):l=r();typeof l=="function"&&!F(l)&&!(0,b.isSignal)(l)&&!P(l);)a||(a=new Map),a.has(l)||a.set(l,l()),l=a.get(l);if(l==null||typeof l=="boolean")continue;if(typeof l=="function"){if((0,b.isSignal)(l)){if(c){let y=v("",!0);n.push(y),c.push({marker:y,sig:l});continue}let f=l();for(;typeof f=="function"&&(0,b.isSignal)(f);)f=f();if(f==null||typeof f=="boolean")continue;Array.isArray(f)?N(f,n,t,o,i,a):N([f],n,t,o,i,a);continue}continue}Array.isArray(l)?N(l,n,t,o,i,a,c):N([l],n,t,o,i,a,c);continue}if(F(r)){let l=v("",!0);n.push(l),r.then(f=>{if(l.parentNode){let y=[];if(N([f],y,l.parentNode,void 0,!1,a),y.length>0){l.parentNode.replaceChild(y[0],l);for(let m=1;m<y.length;m++)l.parentNode?.insertBefore(y[m],y[m-1].nextSibling)}}}).catch(f=>console.error("Error resolving promise in array:",f));continue}if(Array.isArray(r)){N(r,n,t,o,i,a,c);continue}if(_(r)){n.push(r);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let l=r;if(typeof l.type=="function"){let f=l.type(l.props||{});Array.isArray(f)?N(f,n,t,o,!1,a):N([f],n,t,o,!1,a);continue}}if(typeof r=="string"||typeof r=="number"){let l=String(r);if(l.trim()===""&&l!==" ")continue;n.push(v(l));continue}n.push(v(String(r)))}}}}function un(e,n,t,o){for(let y=0;y<t.length;y++){let m=t[y].parentNode;m!==null&&m!==e&&m.nodeType!==11&&(t=t.slice(),t[y]=t[y].cloneNode(!0))}let i=t.length,a=n.length,c=i,s=0,r=0,l=a>0?n[a-1].nextSibling??void 0:o,f=null;for(;s<a||r<c;){if(n[s]===t[r]){s++,r++;continue}for(;a>s&&c>r&&n[a-1]===t[c-1];)a--,c--;if(a===s){let y=c<i?r?t[r-1].nextSibling??void 0:t[c-r]:l;for(;r<c;)g(e,t[r++],y)}else if(c===r)for(;s<a;)(!f||!f.has(n[s]))&&n[s].parentNode===e&&e.removeChild(n[s]),s++;else if(n[s]===t[c-1]&&t[r]===n[a-1]){let y=n[--a].nextSibling;g(e,t[r++],n[s++].nextSibling),g(e,t[--c],y),n[a]=n[s-1]}else{if(!f){f=new Map;let m=r;for(;m<c;)f.set(t[m],m++)}let y=f.get(n[s]);if(y!=null)if(r<y&&y<c){let m=s,G=1;for(;++m<a&&m<c&&!(!f.has(n[m])||f.get(n[m])!==y+G);)G++;if(G>y-r){let Xe=n[s];for(;r<y;)g(e,t[r++],Xe)}else n[s].parentNode===e?e.replaceChild(t[r++],n[s++]):(g(e,t[r++],l),s++)}else s++;else n[s].parentNode===e&&e.removeChild(n[s]),s++}}return t}function R(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function g(e,n,t){d.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function M(e,n,t){t==null?delete e[n]:e[n]=t}function dn(e,n,t){let o=t,i;return Array.isArray(t)&&(o=t[0],i=t[1]),typeof o!="function"?()=>{}:(e.addEventListener(n,o,i),()=>e.removeEventListener(n,o,i))}function je(e,n){if(!n||typeof n!="function")return;let t=n[De]?.name;if(!t)return;let o=t.indexOf(":");o!==-1&&(0,u.reportReactiveDirective)(e,t.slice(0,o),t.slice(o+1),n)}function ke(e,n,t){let o=typeof t=="function"?(0,u.untrack)(()=>t()):t;if(!(!o||typeof o!="object"))for(let i of Object.keys(o))(0,u.reportReactiveDirective)(e,n,i)}function pn(e,n){let t=(o,i)=>{typeof o=="function"&&((0,u.reportReactiveDirective)(e,"use",o.name||"use",i),o(e,i??(()=>{})))};if(typeof n=="function"){t(n);return}if(Array.isArray(n)){if(typeof n[0]=="function"){t(n[0],n[1]);return}for(let o of n)Array.isArray(o)?t(o[0],o[1]):t(o)}}function Le(e,n,t,o=!1){return je(e,t),typeof t!="function"?(w(e,n,t,o),()=>{}):(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"attribute",n,t);let i=typeof t=="function"?t():t;w(e,n,i,o)})}function Oe(e,n,t){return typeof t!="function"?(M(e,n,t),()=>{}):(je(e,t),(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"property",n,t);let o=typeof t=="function"?t():t;M(e,n,o)}))}function yn(e,n,t){return typeof t!="function"?(w(e,n,!!t),()=>{}):(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"attribute",n,t);let o=t();w(e,n,!!o)})}function O(e,n){if(n==null){e.removeAttribute("class");return}if(typeof n=="function"){(0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(e,"attribute","class",n),O(e,n())});return}if(typeof n=="string"){e.setAttribute("class",n);return}if(Array.isArray(n)){e.setAttribute("class",n.filter(Boolean).join(" "));return}if(typeof n=="object"){let t=Object.keys(n).filter(o=>{let i=n[o];return typeof i=="function"?i():!!i}).join(" ");e.setAttribute("class",t);return}e.setAttribute("class",String(n))}function _e(e,n,t){if(!(!n||typeof n!="object"))for(let o in n){let i=n[o],a=o.split(/\s+/).filter(Boolean);if(typeof i=="function"&&t)t.push((0,u.createRenderEffect)(()=>{let c=!!i();for(let s of a)e.classList.toggle(s,c)}));else{let c=!!(typeof i=="function"?i():i);for(let s of a)e.classList.toggle(s,c)}}}function $(e,n){let t=n;for(;typeof t=="function";)t=t();if(t==null){e.removeAttribute("style");return}if(typeof t=="string"){e.style.cssText=t;return}if(typeof t=="object")for(let o in t){let i=t[o];i==null?e.style[o]="":e.style[o]=i}}function $e(e){let{element:n,props:t,prevProps:o=sn,isSVG:i=!1,skipChildren:a=!1}=e;if(!n||!Ae(n))return console.error("[spread] Error: element is not a DOM Element!"),()=>{};if(!t)return console.warn("[spread] Warning: props is undefined!"),()=>{};let c=i||n.namespaceURI===ge,s=[];for(let r in t){if(a&&r==="children")continue;let l=t[r],f=o[r];if(l===f)continue;if(r==="ref"){oe(l,n);continue}if(r==="use"){pn(n,l);continue}if(r.startsWith("on:")){s.push(dn(n,r.slice(3),l));continue}if(r.startsWith("prop:")){(0,u.reportReactiveDirective)(n,"prop",r.slice(5),l),s.push(Oe(n,r.slice(5),l));continue}if(r.startsWith("attr:")){(0,u.reportReactiveDirective)(n,"attr",r.slice(5),l),s.push(Le(n,r.slice(5),l,c));continue}if(r.startsWith("bool:")){(0,u.reportReactiveDirective)(n,"bool",r.slice(5),l),s.push(yn(n,r.slice(5),l));continue}if(r==="class"||r==="className"){typeof l=="function"?s.push((0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(n,"attribute","class",l),O(n,l())})):O(n,l);continue}if(r==="classList"){ke(n,"class",l),typeof l=="function"?s.push((0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(n,"attribute","class",l),_e(n,l())})):_e(n,l,s);continue}if(r==="style"){ke(n,"style",l),typeof l=="function"?s.push((0,u.createRenderEffect)(()=>{(0,u.reportReactiveBinding)(n,"attribute","style",l),$(n,l())})):$(n,l);continue}if(r.startsWith("on")){let m=r.slice(2).toLowerCase();f&&Me(n,m),l&&cn(n,m,l);continue}let y=X.has(r)||!c&&r in n;typeof l=="function"?s.push(y?Oe(n,r,l):Le(n,r,l,c)):s.push((0,u.createRenderEffect)(()=>y?M(n,r,t[r]):w(n,r,t[r],c)))}for(let r in o)if(!(r in t))if(r.startsWith("on")){let l=r.slice(2).toLowerCase();Me(n,l)}else X.has(r)?M(n,r,null):n.removeAttribute(r);return()=>{s.forEach(r=>r())}}function oe(e,n){if(!e)return;let t=e[De]?.name;if((0,u.reportReactiveDirective)(n,"ref",t||typeof e=="function"&&e.name||"ref",e),_(e)){let o=n,i=e;if(!o)return;typeof o=="function"?o(i):typeof o=="object"&&"current"in o&&(o.current=i);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}function F(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function I(e,n,t){if(!n)throw new Error("Container element is required");let o,i,a=[];return(0,u.createRoot)(c=>{(0,u.batch)(()=>{d.active||(n.textContent=""),Ee(n),we(),k(n,e)}),i=c}),()=>{i?.(),o?.(),a.forEach(c=>c()),n.textContent=""}}var L=require("@fluixi/reactive");var mn="__fx_dom_create_component__",Ie=globalThis[mn]??={fn:null};function He(e,n){if(Ie.fn)return Ie.fn(e,n);n&&(0,L.reportReactiveProps)(n);let t=typeof e=="function"?(0,L.untrack)(()=>e(n)):e,o=t!=null&&(typeof t=="function"||typeof t=="object");if(o)try{t.$name=e?.name}catch{}return o&&!(0,L.isSignal)(t)?Ne(t):t}var H=require("@fluixi/reactive/signal");var hn="__FX_DATA__";var re;function Ve(){let e=globalThis.__FX_DATA__;if(e)return e;if(re!==void 0)return re;let n=null;if(typeof document<"u"){let t=document.getElementById(hn)?.textContent;if(t)try{n=JSON.parse(t)}catch{n=null}}return re=n}function V(){for(;;){for(;d.cursor&&d.cursor.nodeType===3&&d.cursor.data==="";)d.cursor=d.cursor.nextSibling;if(d.cursor!=null||!d.parents.length)return;d.cursor=d.parents.pop().nextSibling}}var gn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),U=typeof process<"u"&&process.env&&!1;function W(e,n){let t=n.nodeType===1?`<${n.tagName.toLowerCase()}>`:n.nodeType===3?`text ${JSON.stringify((n.nodeValue??"").slice(0,24))}`:n.nodeType===8?"comment":"node";console.warn(`[fluixi] hydration mismatch: expected ${e} but the server DOM has ${t}. 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 xn(e){V();let n=d.cursor;return n&&n.nodeType===1&&n.tagName.toLowerCase()===e.toLowerCase()?(gn.has(e.toLowerCase())?d.cursor=n.nextSibling:(d.parents.push(n),d.cursor=n.firstChild),n):(U&&n&&W(`<${e}>`,n),null)}function bn(e){V();let n=d.cursor;return n&&n.nodeType===1&&n.tagName.toLowerCase()===e.toLowerCase()?(d.cursor=n.nextSibling,n):(U&&n&&W(`<${e}> (static)`,n),null)}function Tn(e){if(e===""){let t=d.cursor;return t&&t.nodeType===3&&t.data!==""?(d.cursor=t.nextSibling,t.data="",t):null}V();let n=d.cursor;return n&&n.nodeType===3?(d.cursor=n.nextSibling,n.nodeValue!==e&&(n.nodeValue=e),n):(U&&n&&W(`text ${JSON.stringify(e.slice(0,24))}`,n),null)}function En(e){V();let n=d.cursor;return n&&n.nodeType===8&&n.data===e?(d.cursor=n.nextSibling,n):(U&&n&&W(`marker <!--${e.slice(0,24)}-->`,n),null)}var Ue=!1;function wn(){Ue||(Ue=!0,Pe({hydrateElement:xn,hydrateText:Tn,hydrateMarker:En,hydrateStatic:bn}))}function ie(e,n,t){wn(),d.active=!0,d.cursor=n.firstChild,d.parents=[];let o=Ve(),i=t?.resourceNamespace,a=0;(0,H.setResourceIdSource)(()=>i?`${i}:r${a++}`:`r${a++}`),(0,H.setServerDataGetter)(o?c=>c in o?{value:o[c]}:void 0:null);try{return I(e,n)}finally{d.active=!1,d.cursor=null,d.parents=[]}}var h=require("@fluixi/reactive/signal");function We(e){return typeof e=="function"?e:(()=>e)}function C(e){return()=>{let n=e();return typeof n=="function"?n():n}}function Ke(e){return e!=null&&e!==!1}function Be(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function se(e){let n=C(()=>e.when),t=(0,h.createMemo)(n,void 0,{name:"Show.when"}),o=(0,h.createMemo)(t,void 0,{name:"Show.cond"}),i=(0,h.getOwner)(),a=null,c=null,s=r=>{r!==c&&(a&&(0,h.disposeScope)(a),a=(0,h.createChildOwner)(i),c=r)};return(0,h.createMemo)(()=>{let r=o();return s(r?"when":"fallback"),(0,h.runWithOwner)(a,()=>{if(r){let l=e.children;return typeof l=="function"&&!Be(l)?typeof t=="function"?(0,h.untrack)(()=>(0,h.untrack)(t)?l(t()):e.fallback):l(t):l}return e.fallback});return e.fallback??null},void 0,{name:"Show.result"})}var K=require("@fluixi/reactive/signal");function ae(e){let n=C(()=>e.each),t=()=>e.fallback??null,o=(i,a)=>{let c=e.children,s=Array.isArray(c)?c.map(r=>typeof r=="function"?r(i,a):r):typeof c=="function"?c(i,a):c;return D(s),s};return e.by?(0,K.keyArray)(n,e.by,(i,a)=>o(i,a),{fallback:t}):(0,K.mapArray)(n,(i,a)=>o(i,a),{fallback:t})}var qe=require("@fluixi/reactive/signal");function ce(e){let n=C(()=>e.each);return(0,qe.indexArray)(n,(t,o)=>{let i=e.children(t,o);return D(i),i},{fallback:()=>e.fallback??null})}var A=require("@fluixi/reactive/signal");var T=require("@fluixi/reactive/signal");var le=Symbol("match");function fe(e){return{[le]:!0,when:C(()=>e.when),get children(){return e.children}}}function ue(e){let n=Array.isArray(e.children)?e.children:[e.children],t=(0,T.getOwner)(),o=null,i=-1,a=c=>{c!==i&&(o&&(0,T.disposeScope)(o),o=(0,T.createChildOwner)(t),i=c)};return(0,T.createMemo)(()=>{for(let c=0;c<n.length;c+=1){let r=n[c],l=0;for(;typeof r=="function"&&!r[le]&&l++<10;)r=r();if(!r||typeof r!="object"||r[le]!==!0)continue;let f=r.when();if(Ke(f))return a(c),(0,T.runWithOwner)(o,()=>typeof r.children=="function"?r.children(f):r.children)}return a(-2),(0,T.runWithOwner)(o,()=>e.fallback??null)},void 0,{name:"Switch"})}var E=require("@fluixi/reactive/signal");function de(e){let n=We(e.component),{component:t,...o}=e,i=(0,E.getOwner)(),a=null,c;return(0,E.createMemo)(()=>{let s=n();return s!==c&&(a&&(0,E.disposeScope)(a),a=(0,E.createChildOwner)(i),c=s),s==null?null:typeof s=="string"?{tag:s,props:o}:(0,E.runWithOwner)(a,()=>s(o))},void 0,{name:"Dynamic"})}var B=require("@fluixi/reactive/signal");function pe(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return(0,B.createRoot)(i=>{t=i,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),k(o,e.children)&&oe(e.ref,o)}),(0,B.onCleanup)(()=>{t(),o.remove()}),null}var q=require("@fluixi/reactive/signal");function ye(e){let[n,t]=(0,q.createSignal)(null),o=()=>t(null);return(0,q.createMemo)(()=>{let i=n();if(i!==null)return typeof e.fallback=="function"?e.fallback(i,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(a){return t(a),typeof e.fallback=="function"?e.fallback(a,o):e.fallback}},void 0,{name:"ErrorBoundary"})}var Ge=require("@fluixi/reactive/signal");function me(e){return(0,Ge.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,i]of Object.entries(n)){if(!o)continue;(typeof i=="function"?i():i)&&t.push(o)}return t.join(" ")},void 0,{name:"ClassMap"})}var ze=require("@fluixi/reactive/signal");function Nn(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function he(e){return(0,ze.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,i]of Object.entries(n)){if(!o)continue;let a=typeof i=="function"?i():i;a!=null&&t.push(`${Nn(o)}: ${a}`)}return t.join("; ")},void 0,{name:"StyleMap"})}var p=require("@fluixi/reactive");
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/cdn/dom-client.ts
|
|
21
|
+
var dom_client_exports = {};
|
|
22
|
+
__export(dom_client_exports, {
|
|
23
|
+
Dynamic: () => Dynamic,
|
|
24
|
+
ErrorBoundary: () => ErrorBoundary,
|
|
25
|
+
For: () => For,
|
|
26
|
+
Index: () => Index,
|
|
27
|
+
Match: () => Match,
|
|
28
|
+
Portal: () => Portal,
|
|
29
|
+
Show: () => Show,
|
|
30
|
+
Switch: () => Switch,
|
|
31
|
+
batch: () => import_reactive2.batch,
|
|
32
|
+
classMap: () => classMap,
|
|
33
|
+
createComponent: () => createComponent,
|
|
34
|
+
createComputed: () => import_reactive2.createComputed,
|
|
35
|
+
createContext: () => import_reactive2.createContext,
|
|
36
|
+
createEffect: () => import_reactive2.createEffect,
|
|
37
|
+
createElement: () => createElement,
|
|
38
|
+
createMemo: () => import_reactive2.createMemo,
|
|
39
|
+
createRenderEffect: () => import_reactive2.createRenderEffect,
|
|
40
|
+
createResource: () => import_reactive2.createResource,
|
|
41
|
+
createRoot: () => import_reactive2.createRoot,
|
|
42
|
+
createSignal: () => import_reactive2.createSignal,
|
|
43
|
+
delegateEvents: () => delegateEvents,
|
|
44
|
+
effect: () => import_reactive2.effect,
|
|
45
|
+
hydrate: () => hydrate,
|
|
46
|
+
indexArray: () => import_signal14.indexArray,
|
|
47
|
+
insert: () => insert,
|
|
48
|
+
keyArray: () => import_signal14.keyArray,
|
|
49
|
+
mapArray: () => import_signal14.mapArray,
|
|
50
|
+
memo: () => import_reactive2.memo,
|
|
51
|
+
onCleanup: () => import_reactive2.onCleanup,
|
|
52
|
+
render: () => render,
|
|
53
|
+
setAttribute: () => setAttribute,
|
|
54
|
+
setClassName: () => setClassName,
|
|
55
|
+
setProperty: () => setProperty,
|
|
56
|
+
setStyle: () => setStyle,
|
|
57
|
+
signal: () => import_reactive2.signal,
|
|
58
|
+
spread: () => spread,
|
|
59
|
+
store: () => import_reactive2.store,
|
|
60
|
+
styleMap: () => styleMap,
|
|
61
|
+
untrack: () => import_reactive2.untrack,
|
|
62
|
+
useContext: () => import_reactive2.useContext
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(dom_client_exports);
|
|
65
|
+
|
|
66
|
+
// src/lib/dom/utils.ts
|
|
67
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
68
|
+
var JSX_PROPERTIES = /* @__PURE__ */ new Set([
|
|
69
|
+
"className",
|
|
70
|
+
"value",
|
|
71
|
+
"checked",
|
|
72
|
+
"selected",
|
|
73
|
+
"innerHTML",
|
|
74
|
+
"innerText",
|
|
75
|
+
"textContent",
|
|
76
|
+
"indeterminate",
|
|
77
|
+
"htmlFor"
|
|
78
|
+
]);
|
|
79
|
+
function setAttribute(element, name, value, isSVG = false) {
|
|
80
|
+
if (value == null || value === false) {
|
|
81
|
+
element.removeAttribute(name);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (value === true) {
|
|
85
|
+
element.setAttribute(name, "");
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (typeof value === "object") {
|
|
89
|
+
element.setAttribute(name, JSON.stringify(value));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
element.setAttribute(name, String(value));
|
|
93
|
+
}
|
|
94
|
+
function setStyles(element, styles) {
|
|
95
|
+
Object.assign(element.style, styles);
|
|
96
|
+
}
|
|
97
|
+
function createElement(tagName, attributes = {}, ...children) {
|
|
98
|
+
const element = document.createElement(tagName);
|
|
99
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
100
|
+
if (key === "class" || key === "className") {
|
|
101
|
+
element.className = value;
|
|
102
|
+
} else if (key === "style" && typeof value === "object") {
|
|
103
|
+
setStyles(element, value);
|
|
104
|
+
} else if (key.startsWith("on") && typeof value === "function") {
|
|
105
|
+
const event = key.slice(2).toLowerCase();
|
|
106
|
+
element.addEventListener(event, value);
|
|
107
|
+
} else {
|
|
108
|
+
setAttribute(element, key, value);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
children.forEach((child) => {
|
|
112
|
+
if (typeof child === "string") {
|
|
113
|
+
element.appendChild(document.createTextNode(child));
|
|
114
|
+
} else {
|
|
115
|
+
element.appendChild(child);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return element;
|
|
119
|
+
}
|
|
120
|
+
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
|
|
121
|
+
|
|
122
|
+
// src/lib/dom/runtime.ts
|
|
123
|
+
var import_signal2 = require("@fluixi/reactive/signal");
|
|
124
|
+
|
|
125
|
+
// src/version.generated.ts
|
|
126
|
+
var VERSION = "1.0.0-alpha.84";
|
|
127
|
+
|
|
128
|
+
// src/lib/dom/versions.ts
|
|
129
|
+
var import_version = require("@fluixi/reactive/version");
|
|
130
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
131
|
+
var versions = { dom: VERSION, reactive: import_version.VERSION };
|
|
132
|
+
function stampVersions(container) {
|
|
133
|
+
if (versions.core) container.setAttribute("fluixi", versions.core);
|
|
134
|
+
container.setAttribute("fx-dom", versions.dom);
|
|
135
|
+
container.setAttribute("fx-reactive", versions.reactive);
|
|
136
|
+
if (typeof globalThis !== "undefined") globalThis.Fluixi = versions;
|
|
137
|
+
}
|
|
138
|
+
function warnOnVersionSkew() {
|
|
139
|
+
const builds = (0, import_signal.joinedVersions)();
|
|
140
|
+
if (builds.length > 1) {
|
|
141
|
+
console.warn(
|
|
142
|
+
`[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.`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
const present = [versions.core, versions.dom, versions.reactive].filter(
|
|
146
|
+
(v) => v !== void 0
|
|
147
|
+
);
|
|
148
|
+
if (new Set(present).size <= 1) return;
|
|
149
|
+
console.warn(
|
|
150
|
+
`[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\`.`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/lib/component/modifiers.ts
|
|
155
|
+
function asComponent(value) {
|
|
156
|
+
if (typeof value !== "function") return value;
|
|
157
|
+
Object.defineProperty(value, /* @__PURE__ */ Symbol.for("fluixi-component"), { value: true, enumerable: true });
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
function isComponent(value) {
|
|
161
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/lib/dom/runtime.ts
|
|
165
|
+
var import_signal3 = require("@fluixi/reactive/signal");
|
|
166
|
+
|
|
167
|
+
// src/lib/dom/server/host.ts
|
|
168
|
+
var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
|
|
169
|
+
var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
|
|
170
|
+
var realm = globalThis;
|
|
171
|
+
var state = realm[STATE] ??= {
|
|
172
|
+
server: typeof document === "undefined",
|
|
173
|
+
nodes: null
|
|
174
|
+
};
|
|
175
|
+
function isServer() {
|
|
176
|
+
return state.server;
|
|
177
|
+
}
|
|
178
|
+
function getServerNodes() {
|
|
179
|
+
if (!state.nodes) {
|
|
180
|
+
throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
|
|
181
|
+
}
|
|
182
|
+
return state.nodes;
|
|
183
|
+
}
|
|
184
|
+
function isDomNode(x) {
|
|
185
|
+
if (x != null && x[SERVER_NODE] === true) return true;
|
|
186
|
+
return typeof Node !== "undefined" && x instanceof Node;
|
|
187
|
+
}
|
|
188
|
+
function isDomElement(x) {
|
|
189
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 1;
|
|
190
|
+
return typeof Element !== "undefined" && x instanceof Element;
|
|
191
|
+
}
|
|
192
|
+
function isDomText(x) {
|
|
193
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
|
|
194
|
+
return typeof Text !== "undefined" && x instanceof Text;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/lib/dom/hydration-state.ts
|
|
198
|
+
var hydration = {
|
|
199
|
+
active: false,
|
|
200
|
+
cursor: null,
|
|
201
|
+
parents: []
|
|
202
|
+
};
|
|
203
|
+
var _walker = null;
|
|
204
|
+
function registerHydrationWalker(walker) {
|
|
205
|
+
_walker = walker;
|
|
206
|
+
}
|
|
207
|
+
function getHydrationWalker() {
|
|
208
|
+
return _walker;
|
|
209
|
+
}
|
|
210
|
+
function isAdopted(parent, node) {
|
|
211
|
+
return hydration.active && node.parentNode === parent;
|
|
212
|
+
}
|
|
213
|
+
function ascendPast(node) {
|
|
214
|
+
const idx = hydration.parents.lastIndexOf(node);
|
|
215
|
+
if (idx !== -1) hydration.parents.length = idx;
|
|
216
|
+
hydration.cursor = node.nextSibling;
|
|
217
|
+
}
|
|
218
|
+
function hydrateAdvancePast(rendered) {
|
|
219
|
+
if (!hydration.active || rendered == null) return;
|
|
220
|
+
const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
|
|
221
|
+
if (last && typeof last.nodeType === "number") {
|
|
222
|
+
ascendPast(last);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/lib/dom/runtime.ts
|
|
227
|
+
var EMPTY_OBJ = {};
|
|
228
|
+
var HOLE_TAG = "__fx_at";
|
|
229
|
+
var delegatedSet = /* @__PURE__ */ new Set();
|
|
230
|
+
var NON_DELEGATED = /* @__PURE__ */ new Set(["scroll", "focus", "blur", "load", "error", "resize", "mouseenter", "mouseleave", "pointerenter", "pointerleave", "gotpointercapture", "lostpointercapture"]);
|
|
231
|
+
function delegateEvents(eventNames) {
|
|
232
|
+
if (isServer()) return;
|
|
233
|
+
for (const name of eventNames) {
|
|
234
|
+
if (delegatedSet.has(name) || NON_DELEGATED.has(name)) continue;
|
|
235
|
+
delegatedSet.add(name);
|
|
236
|
+
document.addEventListener(name, delegatedEventHandler);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function delegatedEventHandler(e) {
|
|
240
|
+
const key = `$$${e.type}`;
|
|
241
|
+
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
242
|
+
while (node) {
|
|
243
|
+
const handler = node[key];
|
|
244
|
+
if (handler && !node.disabled) {
|
|
245
|
+
handler(e);
|
|
246
|
+
if (e.cancelBubble) return;
|
|
247
|
+
}
|
|
248
|
+
node = node.host && node.host !== node && node.host instanceof Element ? node.host : node.parentNode;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function addDelegatedEventListener(element, name, handler) {
|
|
252
|
+
element[`$$${name}`] = handler;
|
|
253
|
+
if (NON_DELEGATED.has(name)) {
|
|
254
|
+
const key = `__fx_${name}`;
|
|
255
|
+
if (!element[key]) {
|
|
256
|
+
const forwarder = (e) => {
|
|
257
|
+
element[`$$${name}`]?.(e);
|
|
258
|
+
};
|
|
259
|
+
element.addEventListener(name, forwarder);
|
|
260
|
+
element[key] = forwarder;
|
|
261
|
+
}
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (!delegatedSet.has(name)) {
|
|
265
|
+
delegateEvents([name]);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function removeDelegatedEventListener(element, name) {
|
|
269
|
+
delete element[`$$${name}`];
|
|
270
|
+
const key = `__fx_${name}`;
|
|
271
|
+
const forwarder = element[key];
|
|
272
|
+
if (forwarder) {
|
|
273
|
+
element.removeEventListener(name, forwarder);
|
|
274
|
+
delete element[key];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function createTextNode(value, anchor = false) {
|
|
278
|
+
if (isServer()) return getServerNodes().createText(value);
|
|
279
|
+
if (hydration.active && !anchor) {
|
|
280
|
+
const node = getHydrationWalker()?.hydrateText(value);
|
|
281
|
+
if (node) return node;
|
|
282
|
+
}
|
|
283
|
+
return document.createTextNode(value);
|
|
284
|
+
}
|
|
285
|
+
var _insertDepth = 0;
|
|
286
|
+
var MAX_INSERT_DEPTH = 200;
|
|
287
|
+
function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
|
|
288
|
+
let current = initialCurrent;
|
|
289
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
290
|
+
return (0, import_signal3.createRenderEffect)(() => {
|
|
291
|
+
(0, import_signal3.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
|
|
292
|
+
let value;
|
|
293
|
+
if (isComponent(getAccessor) && !(0, import_signal2.isSignal)(getAccessor)) {
|
|
294
|
+
if (!componentCache.has(getAccessor)) {
|
|
295
|
+
_insertDepth++;
|
|
296
|
+
try {
|
|
297
|
+
const inst = getAccessor();
|
|
298
|
+
componentCache.set(getAccessor, inst);
|
|
299
|
+
} finally {
|
|
300
|
+
_insertDepth--;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
value = componentCache.get(getAccessor);
|
|
304
|
+
while (typeof value === "function" && (0, import_signal2.isSignal)(value)) value = value();
|
|
305
|
+
} else {
|
|
306
|
+
value = getAccessor();
|
|
307
|
+
while (typeof value === "function" && (0, import_signal2.isSignal)(value)) {
|
|
308
|
+
value = value();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
{
|
|
312
|
+
let chainDepth = 0;
|
|
313
|
+
while (typeof value === "function" && chainDepth++ < 50) {
|
|
314
|
+
if (isComponent(value)) {
|
|
315
|
+
if (!componentCache.has(value)) {
|
|
316
|
+
const thunk = value;
|
|
317
|
+
_insertDepth++;
|
|
318
|
+
try {
|
|
319
|
+
const inst = thunk();
|
|
320
|
+
componentCache.set(thunk, inst);
|
|
321
|
+
} finally {
|
|
322
|
+
_insertDepth--;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
value = componentCache.get(value);
|
|
326
|
+
} else if ((0, import_signal2.isSignal)(value)) {
|
|
327
|
+
value = value();
|
|
328
|
+
} else {
|
|
329
|
+
value = value();
|
|
330
|
+
if (typeof value !== "function" || !(0, import_signal2.isSignal)(value) && !isComponent(value)) break;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
_insertDepth++;
|
|
335
|
+
try {
|
|
336
|
+
current = insertExpression(parent, value, marker, current, componentCache);
|
|
337
|
+
setCurrent(current);
|
|
338
|
+
} finally {
|
|
339
|
+
_insertDepth--;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
function insert(parent, accessor, marker, init) {
|
|
344
|
+
if (_insertDepth > MAX_INSERT_DEPTH) {
|
|
345
|
+
console.error("[insert] Exceeded max call depth, possible infinite loop.");
|
|
346
|
+
return () => null;
|
|
347
|
+
}
|
|
348
|
+
if (marker !== void 0 && !marker) {
|
|
349
|
+
marker = createTextNode("", true);
|
|
350
|
+
parent.appendChild(marker);
|
|
351
|
+
}
|
|
352
|
+
let current = init ?? null;
|
|
353
|
+
const isReactiveArray = (element) => {
|
|
354
|
+
return Array.isArray(element) && element.some((v) => typeof v === "function");
|
|
355
|
+
};
|
|
356
|
+
const normalizeAccessor3 = (accessor2) => {
|
|
357
|
+
if (typeof accessor2 === "function") return accessor2;
|
|
358
|
+
return () => accessor2;
|
|
359
|
+
};
|
|
360
|
+
if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
|
|
361
|
+
_insertDepth++;
|
|
362
|
+
try {
|
|
363
|
+
current = insertExpression(parent, accessor, marker, current);
|
|
364
|
+
} finally {
|
|
365
|
+
_insertDepth--;
|
|
366
|
+
}
|
|
367
|
+
return () => current;
|
|
368
|
+
}
|
|
369
|
+
const dispose = _createInsertEffect(
|
|
370
|
+
normalizeAccessor3(accessor),
|
|
371
|
+
parent,
|
|
372
|
+
marker,
|
|
373
|
+
current,
|
|
374
|
+
(v) => {
|
|
375
|
+
current = v;
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
return () => {
|
|
379
|
+
dispose?.();
|
|
380
|
+
return current;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function insertExpression(parent, value, marker, current, componentCache) {
|
|
384
|
+
if (value == null || typeof value === "boolean") {
|
|
385
|
+
return cleanChildren(parent, current, marker);
|
|
386
|
+
}
|
|
387
|
+
if (typeof value === "function") {
|
|
388
|
+
while (typeof value === "function") {
|
|
389
|
+
value = value();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (value == null || typeof value === "boolean") {
|
|
393
|
+
return cleanChildren(parent, current, marker);
|
|
394
|
+
}
|
|
395
|
+
if (isPromise(value)) {
|
|
396
|
+
const placeholder = createTextNode("", true);
|
|
397
|
+
if (Array.isArray(current)) {
|
|
398
|
+
if (current.length > 0) {
|
|
399
|
+
parent.replaceChild(placeholder, current[0]);
|
|
400
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
401
|
+
} else {
|
|
402
|
+
insertBefore(parent, placeholder, marker);
|
|
403
|
+
}
|
|
404
|
+
} else if (current) {
|
|
405
|
+
parent.replaceChild(placeholder, current);
|
|
406
|
+
} else {
|
|
407
|
+
insertBefore(parent, placeholder, marker);
|
|
408
|
+
}
|
|
409
|
+
value.then((resolved) => {
|
|
410
|
+
if (placeholder.parentNode === parent) {
|
|
411
|
+
insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
|
|
412
|
+
}
|
|
413
|
+
}).catch((err) => {
|
|
414
|
+
console.error("Error resolving promise in insertExpression:", err);
|
|
415
|
+
});
|
|
416
|
+
return placeholder;
|
|
417
|
+
}
|
|
418
|
+
const t = typeof value;
|
|
419
|
+
if (t === "string" || t === "number") {
|
|
420
|
+
if (t === "number") value = String(value);
|
|
421
|
+
if (Array.isArray(current)) {
|
|
422
|
+
if (current.length === 0) {
|
|
423
|
+
const node2 = createTextNode(value);
|
|
424
|
+
insertBefore(parent, node2, marker);
|
|
425
|
+
return node2;
|
|
426
|
+
}
|
|
427
|
+
if (current.length === 1 && current[0].nodeType === 3) {
|
|
428
|
+
current[0].data = value;
|
|
429
|
+
return current;
|
|
430
|
+
}
|
|
431
|
+
current = cleanChildren(parent, current, marker);
|
|
432
|
+
}
|
|
433
|
+
if (current && isDomText(current)) {
|
|
434
|
+
current.data = value;
|
|
435
|
+
return current;
|
|
436
|
+
}
|
|
437
|
+
const node = createTextNode(value);
|
|
438
|
+
if (current && current.parentNode === parent) {
|
|
439
|
+
parent.replaceChild(node, current);
|
|
440
|
+
} else if (!isAdopted(parent, node)) {
|
|
441
|
+
insertBefore(parent, node, marker);
|
|
442
|
+
}
|
|
443
|
+
return node;
|
|
444
|
+
}
|
|
445
|
+
if (isDomNode(value)) {
|
|
446
|
+
if (isAdopted(parent, value)) {
|
|
447
|
+
ascendPast(value);
|
|
448
|
+
return value;
|
|
449
|
+
}
|
|
450
|
+
if (Array.isArray(current)) {
|
|
451
|
+
if (current.length === 0) {
|
|
452
|
+
insertBefore(parent, value, marker);
|
|
453
|
+
} else if (current[0].parentNode === parent) {
|
|
454
|
+
parent.replaceChild(value, current[0]);
|
|
455
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
456
|
+
} else {
|
|
457
|
+
insertBefore(parent, value, marker);
|
|
458
|
+
}
|
|
459
|
+
return value;
|
|
460
|
+
}
|
|
461
|
+
if (!current) {
|
|
462
|
+
insertBefore(parent, value, marker);
|
|
463
|
+
} else if (current !== value) {
|
|
464
|
+
if (current.parentNode === parent) {
|
|
465
|
+
parent.replaceChild(value, current);
|
|
466
|
+
} else {
|
|
467
|
+
insertBefore(parent, value, marker);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return value;
|
|
471
|
+
}
|
|
472
|
+
if (Array.isArray(value)) {
|
|
473
|
+
const array = [];
|
|
474
|
+
const currentArray = Array.isArray(current) ? current : current ? [current] : [];
|
|
475
|
+
const reactiveSlots = [];
|
|
476
|
+
flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
|
|
477
|
+
const reconciled = reconcileArrays(parent, currentArray, array, marker);
|
|
478
|
+
for (const slot of reactiveSlots) {
|
|
479
|
+
const disposeSlot = insert(parent, slot.sig, slot.marker);
|
|
480
|
+
(0, import_signal3.onCleanup)(() => {
|
|
481
|
+
cleanChildren(parent, disposeSlot());
|
|
482
|
+
if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
return reconciled;
|
|
486
|
+
}
|
|
487
|
+
if (t === "object" && value !== null && typeof value === "object") {
|
|
488
|
+
const objValue = value;
|
|
489
|
+
if ("type" in objValue && "props" in objValue) {
|
|
490
|
+
const jsxValue = objValue;
|
|
491
|
+
if (typeof jsxValue.type === "function") {
|
|
492
|
+
const result = jsxValue.type(jsxValue.props || {});
|
|
493
|
+
return insertExpression(parent, result, marker, current);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return cleanChildren(parent, current, marker);
|
|
498
|
+
}
|
|
499
|
+
function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
|
|
500
|
+
for (let i = 0; i < arr.length; i++) {
|
|
501
|
+
let item = arr[i];
|
|
502
|
+
if (item == null || typeof item === "boolean") continue;
|
|
503
|
+
while (typeof item === "function" && !isPromise(item) && !(0, import_signal2.isSignal)(item) && !isComponent(item)) {
|
|
504
|
+
item = item();
|
|
505
|
+
if (item == null || typeof item === "boolean") break;
|
|
506
|
+
}
|
|
507
|
+
if (item == null || typeof item === "boolean") continue;
|
|
508
|
+
if (typeof item === "function") {
|
|
509
|
+
let resolved;
|
|
510
|
+
if (isComponent(item) && !(0, import_signal2.isSignal)(item)) {
|
|
511
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
512
|
+
if (!componentCache.has(item)) componentCache.set(item, item());
|
|
513
|
+
resolved = componentCache.get(item);
|
|
514
|
+
} else {
|
|
515
|
+
resolved = item();
|
|
516
|
+
}
|
|
517
|
+
while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal2.isSignal)(resolved) && !isComponent(resolved)) {
|
|
518
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
519
|
+
if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
|
|
520
|
+
resolved = componentCache.get(resolved);
|
|
521
|
+
}
|
|
522
|
+
if (resolved == null || typeof resolved === "boolean") continue;
|
|
523
|
+
if (typeof resolved === "function") {
|
|
524
|
+
if ((0, import_signal2.isSignal)(resolved)) {
|
|
525
|
+
if (reactiveSlots) {
|
|
526
|
+
const slot = createTextNode("", true);
|
|
527
|
+
result.push(slot);
|
|
528
|
+
reactiveSlots.push({ marker: slot, sig: resolved });
|
|
529
|
+
continue;
|
|
530
|
+
}
|
|
531
|
+
let val = resolved();
|
|
532
|
+
while (typeof val === "function" && (0, import_signal2.isSignal)(val)) val = val();
|
|
533
|
+
if (val == null || typeof val === "boolean") continue;
|
|
534
|
+
if (Array.isArray(val)) {
|
|
535
|
+
flattenArray(val, result, parent, marker, track, componentCache);
|
|
536
|
+
} else flattenArray([val], result, parent, marker, track, componentCache);
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
|
|
542
|
+
else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
if (isPromise(item)) {
|
|
546
|
+
const placeholder = createTextNode("", true);
|
|
547
|
+
result.push(placeholder);
|
|
548
|
+
item.then((resolved) => {
|
|
549
|
+
if (placeholder.parentNode) {
|
|
550
|
+
const tempNodes = [];
|
|
551
|
+
flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
|
|
552
|
+
if (tempNodes.length > 0) {
|
|
553
|
+
placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
|
|
554
|
+
for (let j = 1; j < tempNodes.length; j++) {
|
|
555
|
+
placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}).catch((err) => console.error("Error resolving promise in array:", err));
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
if (Array.isArray(item)) {
|
|
563
|
+
flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
if (isDomNode(item)) {
|
|
567
|
+
result.push(item);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
|
|
571
|
+
const jsxItem = item;
|
|
572
|
+
if (typeof jsxItem.type === "function") {
|
|
573
|
+
const resolved = jsxItem.type(jsxItem.props || {});
|
|
574
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
|
|
575
|
+
else flattenArray([resolved], result, parent, marker, false, componentCache);
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
580
|
+
const str = String(item);
|
|
581
|
+
if (str.trim() === "" && str !== " ") continue;
|
|
582
|
+
result.push(createTextNode(str));
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
result.push(createTextNode(String(item)));
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
function reconcileArrays(parent, a, b, marker) {
|
|
589
|
+
for (let i = 0; i < b.length; i++) {
|
|
590
|
+
const owner = b[i].parentNode;
|
|
591
|
+
if (owner !== null && owner !== parent && owner.nodeType !== 11) {
|
|
592
|
+
b = b.slice();
|
|
593
|
+
b[i] = b[i].cloneNode(true);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
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;
|
|
597
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
598
|
+
if (a[aStart] === b[bStart]) {
|
|
599
|
+
aStart++;
|
|
600
|
+
bStart++;
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
|
|
604
|
+
aEnd--;
|
|
605
|
+
bEnd--;
|
|
606
|
+
}
|
|
607
|
+
if (aEnd === aStart) {
|
|
608
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
|
|
609
|
+
while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
|
|
610
|
+
} else if (bEnd === bStart) {
|
|
611
|
+
while (aStart < aEnd) {
|
|
612
|
+
if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
|
|
613
|
+
parent.removeChild(a[aStart]);
|
|
614
|
+
aStart++;
|
|
615
|
+
}
|
|
616
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
617
|
+
const node = a[--aEnd].nextSibling;
|
|
618
|
+
insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
|
|
619
|
+
insertBefore(parent, b[--bEnd], node);
|
|
620
|
+
a[aEnd] = a[aStart - 1];
|
|
621
|
+
} else {
|
|
622
|
+
if (!map) {
|
|
623
|
+
map = /* @__PURE__ */ new Map();
|
|
624
|
+
let i = bStart;
|
|
625
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
626
|
+
}
|
|
627
|
+
const index = map.get(a[aStart]);
|
|
628
|
+
if (index != null) {
|
|
629
|
+
if (bStart < index && index < bEnd) {
|
|
630
|
+
let i = aStart, sequence = 1;
|
|
631
|
+
while (++i < aEnd && i < bEnd) {
|
|
632
|
+
if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
|
|
633
|
+
sequence++;
|
|
634
|
+
}
|
|
635
|
+
if (sequence > index - bStart) {
|
|
636
|
+
const node = a[aStart];
|
|
637
|
+
while (bStart < index) insertBefore(parent, b[bStart++], node);
|
|
638
|
+
} else {
|
|
639
|
+
if (a[aStart].parentNode === parent) {
|
|
640
|
+
parent.replaceChild(b[bStart++], a[aStart++]);
|
|
641
|
+
} else {
|
|
642
|
+
insertBefore(parent, b[bStart++], after);
|
|
643
|
+
aStart++;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
} else {
|
|
647
|
+
aStart++;
|
|
648
|
+
}
|
|
649
|
+
} else {
|
|
650
|
+
if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
|
|
651
|
+
aStart++;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return b;
|
|
656
|
+
}
|
|
657
|
+
function cleanChildren(parent, current, marker) {
|
|
658
|
+
if (current) {
|
|
659
|
+
if (Array.isArray(current)) {
|
|
660
|
+
for (let i = 0; i < current.length; i++) {
|
|
661
|
+
if (current[i].parentNode === parent) parent.removeChild(current[i]);
|
|
662
|
+
}
|
|
663
|
+
} else if (current.parentNode === parent) {
|
|
664
|
+
parent.removeChild(current);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return null;
|
|
668
|
+
}
|
|
669
|
+
function insertBefore(parent, node, marker) {
|
|
670
|
+
if (hydration.active && node.parentNode === parent) return;
|
|
671
|
+
if (marker) {
|
|
672
|
+
if (marker.parentNode === parent) {
|
|
673
|
+
parent.insertBefore(node, marker);
|
|
674
|
+
} else {
|
|
675
|
+
parent.appendChild(node);
|
|
676
|
+
}
|
|
677
|
+
} else {
|
|
678
|
+
parent.appendChild(node);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function setProperty(element, name, value) {
|
|
682
|
+
if (value == null) delete element[name];
|
|
683
|
+
else element[name] = value;
|
|
684
|
+
}
|
|
685
|
+
function addNativeEventListener(element, name, value) {
|
|
686
|
+
let handler = value;
|
|
687
|
+
let options;
|
|
688
|
+
if (Array.isArray(value)) {
|
|
689
|
+
handler = value[0];
|
|
690
|
+
options = value[1];
|
|
691
|
+
}
|
|
692
|
+
if (typeof handler !== "function") return () => {
|
|
693
|
+
};
|
|
694
|
+
element.addEventListener(name, handler, options);
|
|
695
|
+
return () => element.removeEventListener(name, handler, options);
|
|
696
|
+
}
|
|
697
|
+
function reportMarked(element, accessor) {
|
|
698
|
+
if (!accessor || typeof accessor !== "function") return;
|
|
699
|
+
const written = accessor[HOLE_TAG]?.name;
|
|
700
|
+
if (!written) return;
|
|
701
|
+
const colon = written.indexOf(":");
|
|
702
|
+
if (colon === -1) return;
|
|
703
|
+
(0, import_signal3.reportReactiveDirective)(element, written.slice(0, colon), written.slice(colon + 1), accessor);
|
|
704
|
+
}
|
|
705
|
+
function reportKeys(element, kind, value) {
|
|
706
|
+
const from = typeof value === "function" ? (0, import_signal3.untrack)(() => value()) : value;
|
|
707
|
+
if (!from || typeof from !== "object") return;
|
|
708
|
+
for (const key of Object.keys(from)) (0, import_signal3.reportReactiveDirective)(element, kind, key);
|
|
709
|
+
}
|
|
710
|
+
function applyUse(element, value) {
|
|
711
|
+
const call = (dir, accessor) => {
|
|
712
|
+
if (typeof dir !== "function") return;
|
|
713
|
+
(0, import_signal3.reportReactiveDirective)(element, "use", dir.name || "use", accessor);
|
|
714
|
+
dir(element, accessor ?? (() => void 0));
|
|
715
|
+
};
|
|
716
|
+
if (typeof value === "function") {
|
|
717
|
+
call(value);
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (!Array.isArray(value)) return;
|
|
721
|
+
if (typeof value[0] === "function") {
|
|
722
|
+
call(value[0], value[1]);
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
for (const pair of value) {
|
|
726
|
+
if (Array.isArray(pair)) call(pair[0], pair[1]);
|
|
727
|
+
else call(pair);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function setDynamicAttribute(element, name, accessor, isSVG = false) {
|
|
731
|
+
reportMarked(element, accessor);
|
|
732
|
+
if (typeof accessor !== "function") {
|
|
733
|
+
setAttribute(element, name, accessor, isSVG);
|
|
734
|
+
return () => {
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
return (0, import_signal3.createRenderEffect)(() => {
|
|
738
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", name, accessor);
|
|
739
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
740
|
+
setAttribute(element, name, value, isSVG);
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
function setDynamicProperty(element, name, accessor) {
|
|
744
|
+
if (typeof accessor !== "function") {
|
|
745
|
+
setProperty(element, name, accessor);
|
|
746
|
+
return () => {
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
reportMarked(element, accessor);
|
|
750
|
+
return (0, import_signal3.createRenderEffect)(() => {
|
|
751
|
+
(0, import_signal3.reportReactiveBinding)(element, "property", name, accessor);
|
|
752
|
+
const value = typeof accessor === "function" ? accessor() : accessor;
|
|
753
|
+
setProperty(element, name, value);
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
function setDynamicBoolAttribute(element, name, accessor) {
|
|
757
|
+
if (typeof accessor !== "function") {
|
|
758
|
+
setAttribute(element, name, !!accessor);
|
|
759
|
+
return () => {
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
return (0, import_signal3.createRenderEffect)(() => {
|
|
763
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", name, accessor);
|
|
764
|
+
const value = accessor();
|
|
765
|
+
setAttribute(element, name, !!value);
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
function setClassName(element, value) {
|
|
769
|
+
if (value == null) {
|
|
770
|
+
element.removeAttribute("class");
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
if (typeof value === "function") {
|
|
774
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
775
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
|
|
776
|
+
setClassName(element, value());
|
|
777
|
+
});
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
if (typeof value === "string") {
|
|
781
|
+
element.setAttribute("class", value);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
if (Array.isArray(value)) {
|
|
785
|
+
element.setAttribute("class", value.filter(Boolean).join(" "));
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
if (typeof value === "object") {
|
|
789
|
+
const classes = Object.keys(value).filter((key) => {
|
|
790
|
+
const v = value[key];
|
|
791
|
+
return typeof v === "function" ? v() : Boolean(v);
|
|
792
|
+
}).join(" ");
|
|
793
|
+
element.setAttribute("class", classes);
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
element.setAttribute("class", String(value));
|
|
797
|
+
}
|
|
798
|
+
function setClassList(element, value, disposers) {
|
|
799
|
+
if (!value || typeof value !== "object") return;
|
|
800
|
+
for (const name in value) {
|
|
801
|
+
const cond = value[name];
|
|
802
|
+
const names = name.split(/\s+/).filter(Boolean);
|
|
803
|
+
if (typeof cond === "function" && disposers) {
|
|
804
|
+
disposers.push(
|
|
805
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
806
|
+
const on = !!cond();
|
|
807
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
808
|
+
})
|
|
809
|
+
);
|
|
810
|
+
} else {
|
|
811
|
+
const on = !!(typeof cond === "function" ? cond() : cond);
|
|
812
|
+
for (const n of names) element.classList.toggle(n, on);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
function setStyle(element, _value) {
|
|
817
|
+
let value = _value;
|
|
818
|
+
while (typeof value === "function") value = value();
|
|
819
|
+
if (value == null) {
|
|
820
|
+
element.removeAttribute("style");
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
if (typeof value === "string") {
|
|
824
|
+
element.style.cssText = value;
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (typeof value === "object") {
|
|
828
|
+
for (const key in value) {
|
|
829
|
+
const styleValue = value[key];
|
|
830
|
+
if (styleValue == null) element.style[key] = "";
|
|
831
|
+
else element.style[key] = styleValue;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
function spread(options) {
|
|
836
|
+
const {
|
|
837
|
+
element,
|
|
838
|
+
props,
|
|
839
|
+
prevProps = EMPTY_OBJ,
|
|
840
|
+
isSVG = false,
|
|
841
|
+
skipChildren = false
|
|
842
|
+
} = options;
|
|
843
|
+
if (!element || !isDomElement(element)) {
|
|
844
|
+
console.error("[spread] Error: element is not a DOM Element!");
|
|
845
|
+
return () => {
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
if (!props) {
|
|
849
|
+
console.warn("[spread] Warning: props is undefined!");
|
|
850
|
+
return () => {
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
const elementIsSVG = isSVG || element.namespaceURI === SVG_NAMESPACE;
|
|
854
|
+
const disposers = [];
|
|
855
|
+
for (const key in props) {
|
|
856
|
+
if (skipChildren && key === "children") continue;
|
|
857
|
+
const value = props[key];
|
|
858
|
+
const prev = prevProps[key];
|
|
859
|
+
if (value === prev) continue;
|
|
860
|
+
if (key === "ref") {
|
|
861
|
+
handleRef(value, element);
|
|
862
|
+
continue;
|
|
863
|
+
}
|
|
864
|
+
if (key === "use") {
|
|
865
|
+
applyUse(element, value);
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
if (key.startsWith("on:")) {
|
|
869
|
+
disposers.push(addNativeEventListener(element, key.slice(3), value));
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
if (key.startsWith("prop:")) {
|
|
873
|
+
(0, import_signal3.reportReactiveDirective)(element, "prop", key.slice(5), value);
|
|
874
|
+
disposers.push(setDynamicProperty(element, key.slice(5), value));
|
|
875
|
+
continue;
|
|
876
|
+
}
|
|
877
|
+
if (key.startsWith("attr:")) {
|
|
878
|
+
(0, import_signal3.reportReactiveDirective)(element, "attr", key.slice(5), value);
|
|
879
|
+
disposers.push(setDynamicAttribute(element, key.slice(5), value, elementIsSVG));
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
if (key.startsWith("bool:")) {
|
|
883
|
+
(0, import_signal3.reportReactiveDirective)(element, "bool", key.slice(5), value);
|
|
884
|
+
disposers.push(setDynamicBoolAttribute(element, key.slice(5), value));
|
|
885
|
+
continue;
|
|
886
|
+
}
|
|
887
|
+
if (key === "class" || key === "className") {
|
|
888
|
+
if (typeof value === "function") {
|
|
889
|
+
disposers.push(
|
|
890
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
891
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
|
|
892
|
+
setClassName(element, value());
|
|
893
|
+
})
|
|
894
|
+
);
|
|
895
|
+
} else {
|
|
896
|
+
setClassName(element, value);
|
|
897
|
+
}
|
|
898
|
+
continue;
|
|
899
|
+
}
|
|
900
|
+
if (key === "classList") {
|
|
901
|
+
reportKeys(element, "class", value);
|
|
902
|
+
if (typeof value === "function") {
|
|
903
|
+
disposers.push(
|
|
904
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
905
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "class", value);
|
|
906
|
+
setClassList(element, value());
|
|
907
|
+
})
|
|
908
|
+
);
|
|
909
|
+
} else {
|
|
910
|
+
setClassList(element, value, disposers);
|
|
911
|
+
}
|
|
912
|
+
continue;
|
|
913
|
+
}
|
|
914
|
+
if (key === "style") {
|
|
915
|
+
reportKeys(element, "style", value);
|
|
916
|
+
if (typeof value === "function") {
|
|
917
|
+
disposers.push(
|
|
918
|
+
(0, import_signal3.createRenderEffect)(() => {
|
|
919
|
+
(0, import_signal3.reportReactiveBinding)(element, "attribute", "style", value);
|
|
920
|
+
setStyle(element, value());
|
|
921
|
+
})
|
|
922
|
+
);
|
|
923
|
+
} else {
|
|
924
|
+
setStyle(element, value);
|
|
925
|
+
}
|
|
926
|
+
continue;
|
|
927
|
+
}
|
|
928
|
+
if (key.startsWith("on")) {
|
|
929
|
+
const eventName = key.slice(2).toLowerCase();
|
|
930
|
+
if (prev) removeDelegatedEventListener(element, eventName);
|
|
931
|
+
if (value) addDelegatedEventListener(element, eventName, value);
|
|
932
|
+
continue;
|
|
933
|
+
}
|
|
934
|
+
const asProperty = JSX_PROPERTIES.has(key) || !elementIsSVG && key in element;
|
|
935
|
+
if (typeof value === "function") {
|
|
936
|
+
disposers.push(
|
|
937
|
+
asProperty ? setDynamicProperty(element, key, value) : setDynamicAttribute(element, key, value, elementIsSVG)
|
|
938
|
+
);
|
|
939
|
+
} else {
|
|
940
|
+
disposers.push(
|
|
941
|
+
(0, import_signal3.createRenderEffect)(
|
|
942
|
+
() => asProperty ? setProperty(element, key, props[key]) : setAttribute(element, key, props[key], elementIsSVG)
|
|
943
|
+
)
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
for (const key in prevProps) {
|
|
948
|
+
if (!(key in props)) {
|
|
949
|
+
if (key.startsWith("on")) {
|
|
950
|
+
const eventName = key.slice(2).toLowerCase();
|
|
951
|
+
removeDelegatedEventListener(element, eventName);
|
|
952
|
+
} else if (JSX_PROPERTIES.has(key)) {
|
|
953
|
+
setProperty(element, key, null);
|
|
954
|
+
} else {
|
|
955
|
+
element.removeAttribute(key);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return () => {
|
|
960
|
+
disposers.forEach((d) => d());
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
function handleRef(ref, element) {
|
|
964
|
+
if (!ref) return;
|
|
965
|
+
const held = ref[HOLE_TAG]?.name;
|
|
966
|
+
(0, import_signal3.reportReactiveDirective)(
|
|
967
|
+
element,
|
|
968
|
+
"ref",
|
|
969
|
+
held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
|
|
970
|
+
ref
|
|
971
|
+
);
|
|
972
|
+
if (isDomNode(ref)) {
|
|
973
|
+
const actualRef = element;
|
|
974
|
+
const actualElement = ref;
|
|
975
|
+
if (!actualRef) return;
|
|
976
|
+
if (typeof actualRef === "function") actualRef(actualElement);
|
|
977
|
+
else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
if (typeof ref === "function") ref(element);
|
|
981
|
+
else if (typeof ref === "object" && "current" in ref) ref.current = element;
|
|
982
|
+
}
|
|
983
|
+
function isPromise(v) {
|
|
984
|
+
return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
|
|
985
|
+
}
|
|
986
|
+
function render(element, container, context) {
|
|
987
|
+
if (!container) {
|
|
988
|
+
throw new Error("Container element is required");
|
|
989
|
+
}
|
|
990
|
+
let rendererDispose;
|
|
991
|
+
let disposeRoot;
|
|
992
|
+
const disposers = [];
|
|
993
|
+
(0, import_signal3.createRoot)((dispose) => {
|
|
994
|
+
(0, import_signal3.batch)(() => {
|
|
995
|
+
if (!hydration.active) {
|
|
996
|
+
container.textContent = "";
|
|
997
|
+
}
|
|
998
|
+
stampVersions(container);
|
|
999
|
+
warnOnVersionSkew();
|
|
1000
|
+
insert(container, element);
|
|
1001
|
+
return;
|
|
1002
|
+
});
|
|
1003
|
+
disposeRoot = dispose;
|
|
1004
|
+
});
|
|
1005
|
+
return () => {
|
|
1006
|
+
disposeRoot?.();
|
|
1007
|
+
rendererDispose?.();
|
|
1008
|
+
disposers.forEach((d) => d());
|
|
1009
|
+
container.textContent = "";
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
// src/lib/dom/integration.ts
|
|
1014
|
+
var import_reactive = require("@fluixi/reactive");
|
|
1015
|
+
var _slotKey = "__fx_dom_create_component__";
|
|
1016
|
+
var _slot = globalThis[_slotKey] ??= { fn: null };
|
|
1017
|
+
function createComponent(Comp, props) {
|
|
1018
|
+
if (_slot.fn) return _slot.fn(Comp, props);
|
|
1019
|
+
if (props) (0, import_reactive.reportReactiveProps)(props);
|
|
1020
|
+
const component = typeof Comp === "function" ? (0, import_reactive.untrack)(() => Comp(props)) : Comp;
|
|
1021
|
+
const nameable = component != null && (typeof component === "function" || typeof component === "object");
|
|
1022
|
+
if (nameable) {
|
|
1023
|
+
try {
|
|
1024
|
+
component["$name"] = Comp?.name;
|
|
1025
|
+
} catch {
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
if (nameable && !(0, import_reactive.isSignal)(component)) {
|
|
1029
|
+
return asComponent(component);
|
|
1030
|
+
}
|
|
1031
|
+
return component;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// src/lib/dom/hydration.ts
|
|
1035
|
+
var import_signal4 = require("@fluixi/reactive/signal");
|
|
1036
|
+
|
|
1037
|
+
// src/lib/dom/server/fx-data.ts
|
|
1038
|
+
var FX_DATA_ID = "__FX_DATA__";
|
|
1039
|
+
var _scriptCache;
|
|
1040
|
+
function getServerData() {
|
|
1041
|
+
const g = globalThis.__FX_DATA__;
|
|
1042
|
+
if (g) return g;
|
|
1043
|
+
if (_scriptCache !== void 0) return _scriptCache;
|
|
1044
|
+
let parsed = null;
|
|
1045
|
+
if (typeof document !== "undefined") {
|
|
1046
|
+
const text = document.getElementById(FX_DATA_ID)?.textContent;
|
|
1047
|
+
if (text) {
|
|
1048
|
+
try {
|
|
1049
|
+
parsed = JSON.parse(text);
|
|
1050
|
+
} catch {
|
|
1051
|
+
parsed = null;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
return _scriptCache = parsed;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
// src/lib/dom/hydration.ts
|
|
1059
|
+
function recoverCursor() {
|
|
1060
|
+
for (; ; ) {
|
|
1061
|
+
while (hydration.cursor && hydration.cursor.nodeType === 3 && hydration.cursor.data === "") {
|
|
1062
|
+
hydration.cursor = hydration.cursor.nextSibling;
|
|
1063
|
+
}
|
|
1064
|
+
if (hydration.cursor != null || !hydration.parents.length) return;
|
|
1065
|
+
hydration.cursor = hydration.parents.pop().nextSibling;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1069
|
+
"area",
|
|
1070
|
+
"base",
|
|
1071
|
+
"br",
|
|
1072
|
+
"col",
|
|
1073
|
+
"embed",
|
|
1074
|
+
"hr",
|
|
1075
|
+
"img",
|
|
1076
|
+
"input",
|
|
1077
|
+
"link",
|
|
1078
|
+
"meta",
|
|
1079
|
+
"param",
|
|
1080
|
+
"source",
|
|
1081
|
+
"track",
|
|
1082
|
+
"wbr"
|
|
1083
|
+
]);
|
|
1084
|
+
var DEV = typeof process !== "undefined" && process.env && false;
|
|
1085
|
+
function warnMismatch(expected, found) {
|
|
1086
|
+
const f = found.nodeType === 1 ? `<${found.tagName.toLowerCase()}>` : found.nodeType === 3 ? `text ${JSON.stringify((found.nodeValue ?? "").slice(0, 24))}` : found.nodeType === 8 ? "comment" : "node";
|
|
1087
|
+
console.warn(
|
|
1088
|
+
`[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).`
|
|
1089
|
+
);
|
|
1090
|
+
}
|
|
1091
|
+
function hydrateElement(tag) {
|
|
1092
|
+
recoverCursor();
|
|
1093
|
+
const c = hydration.cursor;
|
|
1094
|
+
if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
|
|
1095
|
+
if (VOID_ELEMENTS.has(tag.toLowerCase())) {
|
|
1096
|
+
hydration.cursor = c.nextSibling;
|
|
1097
|
+
} else {
|
|
1098
|
+
hydration.parents.push(c);
|
|
1099
|
+
hydration.cursor = c.firstChild;
|
|
1100
|
+
}
|
|
1101
|
+
return c;
|
|
1102
|
+
}
|
|
1103
|
+
if (DEV && c) warnMismatch(`<${tag}>`, c);
|
|
1104
|
+
return null;
|
|
1105
|
+
}
|
|
1106
|
+
function hydrateStatic(tag) {
|
|
1107
|
+
recoverCursor();
|
|
1108
|
+
const c = hydration.cursor;
|
|
1109
|
+
if (c && c.nodeType === 1 && c.tagName.toLowerCase() === tag.toLowerCase()) {
|
|
1110
|
+
hydration.cursor = c.nextSibling;
|
|
1111
|
+
return c;
|
|
1112
|
+
}
|
|
1113
|
+
if (DEV && c) warnMismatch(`<${tag}> (static)`, c);
|
|
1114
|
+
return null;
|
|
1115
|
+
}
|
|
1116
|
+
function hydrateText(value) {
|
|
1117
|
+
if (value === "") {
|
|
1118
|
+
const c2 = hydration.cursor;
|
|
1119
|
+
if (c2 && c2.nodeType === 3 && c2.data !== "") {
|
|
1120
|
+
hydration.cursor = c2.nextSibling;
|
|
1121
|
+
c2.data = "";
|
|
1122
|
+
return c2;
|
|
1123
|
+
}
|
|
1124
|
+
return null;
|
|
1125
|
+
}
|
|
1126
|
+
recoverCursor();
|
|
1127
|
+
const c = hydration.cursor;
|
|
1128
|
+
if (c && c.nodeType === 3) {
|
|
1129
|
+
hydration.cursor = c.nextSibling;
|
|
1130
|
+
if (c.nodeValue !== value) c.nodeValue = value;
|
|
1131
|
+
return c;
|
|
1132
|
+
}
|
|
1133
|
+
if (DEV && c) warnMismatch(`text ${JSON.stringify(value.slice(0, 24))}`, c);
|
|
1134
|
+
return null;
|
|
1135
|
+
}
|
|
1136
|
+
function hydrateMarker(value) {
|
|
1137
|
+
recoverCursor();
|
|
1138
|
+
const c = hydration.cursor;
|
|
1139
|
+
if (c && c.nodeType === 8 && c.data === value) {
|
|
1140
|
+
hydration.cursor = c.nextSibling;
|
|
1141
|
+
return c;
|
|
1142
|
+
}
|
|
1143
|
+
if (DEV && c) warnMismatch(`marker <!--${value.slice(0, 24)}-->`, c);
|
|
1144
|
+
return null;
|
|
1145
|
+
}
|
|
1146
|
+
var _walkerRegistered = false;
|
|
1147
|
+
function ensureWalker() {
|
|
1148
|
+
if (_walkerRegistered) return;
|
|
1149
|
+
_walkerRegistered = true;
|
|
1150
|
+
registerHydrationWalker({ hydrateElement, hydrateText, hydrateMarker, hydrateStatic });
|
|
1151
|
+
}
|
|
1152
|
+
function hydrate(element, container, options) {
|
|
1153
|
+
ensureWalker();
|
|
1154
|
+
hydration.active = true;
|
|
1155
|
+
hydration.cursor = container.firstChild;
|
|
1156
|
+
hydration.parents = [];
|
|
1157
|
+
const data = getServerData();
|
|
1158
|
+
const ns = options?.resourceNamespace;
|
|
1159
|
+
let rid = 0;
|
|
1160
|
+
(0, import_signal4.setResourceIdSource)(() => ns ? `${ns}:r${rid++}` : `r${rid++}`);
|
|
1161
|
+
(0, import_signal4.setServerDataGetter)(data ? (id) => id in data ? { value: data[id] } : void 0 : null);
|
|
1162
|
+
try {
|
|
1163
|
+
return render(element, container);
|
|
1164
|
+
} finally {
|
|
1165
|
+
hydration.active = false;
|
|
1166
|
+
hydration.cursor = null;
|
|
1167
|
+
hydration.parents = [];
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// src/lib/flow/show.ts
|
|
1172
|
+
var import_signal5 = require("@fluixi/reactive/signal");
|
|
1173
|
+
|
|
1174
|
+
// src/lib/flow/utils.ts
|
|
1175
|
+
function normalizeAccessor(value) {
|
|
1176
|
+
return typeof value === "function" ? value : (() => value);
|
|
1177
|
+
}
|
|
1178
|
+
function resolveReactiveProp(read) {
|
|
1179
|
+
return () => {
|
|
1180
|
+
const value = read();
|
|
1181
|
+
return typeof value === "function" ? value() : value;
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
function isTruthy(value) {
|
|
1185
|
+
return value !== null && value !== void 0 && value !== false;
|
|
1186
|
+
}
|
|
1187
|
+
function isLitResult(value) {
|
|
1188
|
+
if (!value || typeof value !== "object") return false;
|
|
1189
|
+
return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// src/lib/flow/show.ts
|
|
1193
|
+
function Show(props) {
|
|
1194
|
+
const when = resolveReactiveProp(() => props.when);
|
|
1195
|
+
const value = (0, import_signal5.createMemo)(when, void 0, { name: "Show.when" });
|
|
1196
|
+
const cond = (0, import_signal5.createMemo)(value, void 0, { name: "Show.cond" });
|
|
1197
|
+
const parentOwner = (0, import_signal5.getOwner)();
|
|
1198
|
+
let branchScope = null;
|
|
1199
|
+
let shown = null;
|
|
1200
|
+
const enterBranch = (next) => {
|
|
1201
|
+
if (next === shown) return;
|
|
1202
|
+
if (branchScope) (0, import_signal5.disposeScope)(branchScope);
|
|
1203
|
+
branchScope = (0, import_signal5.createChildOwner)(parentOwner);
|
|
1204
|
+
shown = next;
|
|
1205
|
+
};
|
|
1206
|
+
return (0, import_signal5.createMemo)(
|
|
1207
|
+
() => {
|
|
1208
|
+
const evaluate = cond();
|
|
1209
|
+
enterBranch(evaluate ? "when" : "fallback");
|
|
1210
|
+
return (0, import_signal5.runWithOwner)(branchScope, () => {
|
|
1211
|
+
if (evaluate) {
|
|
1212
|
+
let children = props.children;
|
|
1213
|
+
if (typeof children === "function" && !isLitResult(children)) {
|
|
1214
|
+
if (typeof value === "function") {
|
|
1215
|
+
return (0, import_signal5.untrack)(() => {
|
|
1216
|
+
if (!(0, import_signal5.untrack)(value)) return props.fallback;
|
|
1217
|
+
return children(value());
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
return children(value);
|
|
1221
|
+
}
|
|
1222
|
+
return children;
|
|
1223
|
+
}
|
|
1224
|
+
return props.fallback;
|
|
1225
|
+
});
|
|
1226
|
+
return props.fallback ?? null;
|
|
1227
|
+
},
|
|
1228
|
+
void 0,
|
|
1229
|
+
// Not `Show`: the compiler already marks the memo it wraps the component in with that,
|
|
1230
|
+
// and two cards of the same name in one graph is worse than a longer one.
|
|
1231
|
+
{ name: "Show.result" }
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// src/lib/flow/for.ts
|
|
1236
|
+
var import_signal6 = require("@fluixi/reactive/signal");
|
|
1237
|
+
function For(props) {
|
|
1238
|
+
const each = resolveReactiveProp(() => props.each);
|
|
1239
|
+
const fallback = () => props.fallback ?? null;
|
|
1240
|
+
const render2 = (item, index) => {
|
|
1241
|
+
const children = props.children;
|
|
1242
|
+
const rendered = Array.isArray(children) ? children.map((c) => typeof c === "function" ? c(item, index) : c) : typeof children === "function" ? children(item, index) : children;
|
|
1243
|
+
hydrateAdvancePast(rendered);
|
|
1244
|
+
return rendered;
|
|
1245
|
+
};
|
|
1246
|
+
return props.by ? (0, import_signal6.keyArray)(each, props.by, (item, index) => render2(item, index), { fallback }) : (0, import_signal6.mapArray)(each, (item, index) => render2(item, index), { fallback });
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
// src/lib/flow/index-flow.ts
|
|
1250
|
+
var import_signal7 = require("@fluixi/reactive/signal");
|
|
1251
|
+
function Index(props) {
|
|
1252
|
+
const each = resolveReactiveProp(() => props.each);
|
|
1253
|
+
return (0, import_signal7.indexArray)(
|
|
1254
|
+
each,
|
|
1255
|
+
(item, index) => {
|
|
1256
|
+
const rendered = props.children(item, index);
|
|
1257
|
+
hydrateAdvancePast(rendered);
|
|
1258
|
+
return rendered;
|
|
1259
|
+
},
|
|
1260
|
+
{ fallback: () => props.fallback ?? null }
|
|
1261
|
+
);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// src/lib/flow/index.ts
|
|
1265
|
+
var import_signal14 = require("@fluixi/reactive/signal");
|
|
1266
|
+
|
|
1267
|
+
// src/lib/flow/switch.ts
|
|
1268
|
+
var import_signal8 = require("@fluixi/reactive/signal");
|
|
1269
|
+
var MATCH_MARKER = /* @__PURE__ */ Symbol("match");
|
|
1270
|
+
function Match(props) {
|
|
1271
|
+
return {
|
|
1272
|
+
[MATCH_MARKER]: true,
|
|
1273
|
+
// Lazy read through the prop getter. Switch calls `branch.when()` inside its memo,
|
|
1274
|
+
// so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
|
|
1275
|
+
when: resolveReactiveProp(() => props.when),
|
|
1276
|
+
// Lazy, like `when`. Read eagerly, every branch's children were built the
|
|
1277
|
+
// moment the Match node was, before Switch had chosen one, so they were
|
|
1278
|
+
// created outside the branch's scope (and non-matching branches were built
|
|
1279
|
+
// for nothing). Switch reads this inside the selected branch's scope.
|
|
1280
|
+
get children() {
|
|
1281
|
+
return props.children;
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
function Switch(props) {
|
|
1286
|
+
const branches = Array.isArray(props.children) ? props.children : [props.children];
|
|
1287
|
+
const parentOwner = (0, import_signal8.getOwner)();
|
|
1288
|
+
let branchScope = null;
|
|
1289
|
+
let shown = -1;
|
|
1290
|
+
const enterBranch = (index) => {
|
|
1291
|
+
if (index === shown) return;
|
|
1292
|
+
if (branchScope) (0, import_signal8.disposeScope)(branchScope);
|
|
1293
|
+
branchScope = (0, import_signal8.createChildOwner)(parentOwner);
|
|
1294
|
+
shown = index;
|
|
1295
|
+
};
|
|
1296
|
+
return (0, import_signal8.createMemo)(() => {
|
|
1297
|
+
for (let i = 0; i < branches.length; i += 1) {
|
|
1298
|
+
const raw = branches[i];
|
|
1299
|
+
let branch = raw;
|
|
1300
|
+
let guard = 0;
|
|
1301
|
+
while (typeof branch === "function" && !branch[MATCH_MARKER] && guard++ < 10) {
|
|
1302
|
+
branch = branch();
|
|
1303
|
+
}
|
|
1304
|
+
if (!branch || typeof branch !== "object" || branch[MATCH_MARKER] !== true) {
|
|
1305
|
+
continue;
|
|
1306
|
+
}
|
|
1307
|
+
const value = branch.when();
|
|
1308
|
+
if (isTruthy(value)) {
|
|
1309
|
+
enterBranch(i);
|
|
1310
|
+
return (0, import_signal8.runWithOwner)(
|
|
1311
|
+
branchScope,
|
|
1312
|
+
() => typeof branch.children === "function" ? branch.children(value) : branch.children
|
|
1313
|
+
);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
enterBranch(-2);
|
|
1317
|
+
return (0, import_signal8.runWithOwner)(branchScope, () => props.fallback ?? null);
|
|
1318
|
+
}, void 0, { name: "Switch" });
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// src/lib/flow/dynamic.ts
|
|
1322
|
+
var import_signal9 = require("@fluixi/reactive/signal");
|
|
1323
|
+
function Dynamic(props) {
|
|
1324
|
+
const getComponent = normalizeAccessor(props.component);
|
|
1325
|
+
const { component: _c, ...rest } = props;
|
|
1326
|
+
const parentOwner = (0, import_signal9.getOwner)();
|
|
1327
|
+
let scope = null;
|
|
1328
|
+
let current;
|
|
1329
|
+
return (0, import_signal9.createMemo)(() => {
|
|
1330
|
+
const C = getComponent();
|
|
1331
|
+
if (C !== current) {
|
|
1332
|
+
if (scope) (0, import_signal9.disposeScope)(scope);
|
|
1333
|
+
scope = (0, import_signal9.createChildOwner)(parentOwner);
|
|
1334
|
+
current = C;
|
|
1335
|
+
}
|
|
1336
|
+
if (C == null) return null;
|
|
1337
|
+
if (typeof C === "string") {
|
|
1338
|
+
return { tag: C, props: rest };
|
|
1339
|
+
}
|
|
1340
|
+
return (0, import_signal9.runWithOwner)(scope, () => C(rest));
|
|
1341
|
+
}, void 0, { name: "Dynamic" });
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
// src/lib/flow/portal.ts
|
|
1345
|
+
var import_signal10 = require("@fluixi/reactive/signal");
|
|
1346
|
+
function Portal(props) {
|
|
1347
|
+
const getMount = () => {
|
|
1348
|
+
if (!props.mount) return document.body;
|
|
1349
|
+
return typeof props.mount === "function" ? props.mount() : props.mount;
|
|
1350
|
+
};
|
|
1351
|
+
let dispose;
|
|
1352
|
+
let container;
|
|
1353
|
+
(0, import_signal10.createRoot)((d) => {
|
|
1354
|
+
dispose = d;
|
|
1355
|
+
container = document.createElement("div");
|
|
1356
|
+
container.style.display = "contents";
|
|
1357
|
+
const target = getMount();
|
|
1358
|
+
target.appendChild(container);
|
|
1359
|
+
const inserted = insert(container, props.children);
|
|
1360
|
+
if (inserted) {
|
|
1361
|
+
handleRef(props.ref, container);
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
(0, import_signal10.onCleanup)(() => {
|
|
1365
|
+
dispose();
|
|
1366
|
+
container.remove();
|
|
1367
|
+
});
|
|
1368
|
+
return null;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
// src/lib/flow/error-boundary.ts
|
|
1372
|
+
var import_signal11 = require("@fluixi/reactive/signal");
|
|
1373
|
+
function ErrorBoundary(props) {
|
|
1374
|
+
const [error, setError] = (0, import_signal11.createSignal)(null);
|
|
1375
|
+
const reset = () => setError(null);
|
|
1376
|
+
return (0, import_signal11.createMemo)(() => {
|
|
1377
|
+
const err = error();
|
|
1378
|
+
if (err !== null) {
|
|
1379
|
+
return typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
|
|
1380
|
+
}
|
|
1381
|
+
try {
|
|
1382
|
+
const content = typeof props.children === "function" ? props.children() : props.children;
|
|
1383
|
+
return content;
|
|
1384
|
+
} catch (e) {
|
|
1385
|
+
setError(e);
|
|
1386
|
+
return typeof props.fallback === "function" ? props.fallback(e, reset) : props.fallback;
|
|
1387
|
+
}
|
|
1388
|
+
}, void 0, { name: "ErrorBoundary" });
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
// src/lib/flow/class-map.ts
|
|
1392
|
+
var import_signal12 = require("@fluixi/reactive/signal");
|
|
1393
|
+
function classMap(input) {
|
|
1394
|
+
return (0, import_signal12.createMemo)(() => {
|
|
1395
|
+
const map = typeof input === "function" ? input() : input;
|
|
1396
|
+
const classes = [];
|
|
1397
|
+
for (const [cls, cond] of Object.entries(map)) {
|
|
1398
|
+
if (!cls) continue;
|
|
1399
|
+
const active = typeof cond === "function" ? cond() : cond;
|
|
1400
|
+
if (active) classes.push(cls);
|
|
1401
|
+
}
|
|
1402
|
+
return classes.join(" ");
|
|
1403
|
+
}, void 0, { name: "ClassMap" });
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// src/lib/flow/style-map.ts
|
|
1407
|
+
var import_signal13 = require("@fluixi/reactive/signal");
|
|
1408
|
+
function toKebab(prop) {
|
|
1409
|
+
return prop.startsWith("--") ? prop : prop.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
1410
|
+
}
|
|
1411
|
+
function styleMap(input) {
|
|
1412
|
+
return (0, import_signal13.createMemo)(() => {
|
|
1413
|
+
const map = typeof input === "function" ? input() : input;
|
|
1414
|
+
const parts = [];
|
|
1415
|
+
for (const [prop, val] of Object.entries(map)) {
|
|
1416
|
+
if (!prop) continue;
|
|
1417
|
+
const resolved = typeof val === "function" ? val() : val;
|
|
1418
|
+
if (resolved != null) {
|
|
1419
|
+
parts.push(`${toKebab(prop)}: ${resolved}`);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
return parts.join("; ");
|
|
1423
|
+
}, void 0, { name: "StyleMap" });
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
// src/cdn/dom-client.ts
|
|
1427
|
+
var import_reactive2 = require("@fluixi/reactive");
|