@fluixi/dom 1.0.0-alpha.83 → 1.0.0-alpha.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/dom-client.cjs +1427 -1
- package/dist/cdn/dom-client.d.ts +2 -2
- package/dist/cdn/dom-client.global.js +2 -1
- package/dist/cdn/dom-client.js +3 -3
- package/dist/cdn/dom-client.mjs +1430 -1
- package/dist/cdn/dom.cjs +3127 -1
- package/dist/cdn/dom.d.ts +2 -2
- package/dist/cdn/dom.global.js +2 -1
- package/dist/cdn/dom.js +4 -4
- package/dist/cdn/dom.mjs +3133 -1
- package/dist/index.cjs +3155 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +3149 -1
- package/dist/lib/component/index.cjs +128 -1
- package/dist/lib/component/index.mjs +105 -1
- package/dist/lib/component/modifiers.cjs +126 -1
- package/dist/lib/component/modifiers.d.ts +12 -0
- package/dist/lib/component/modifiers.d.ts.map +1 -1
- package/dist/lib/component/modifiers.js +12 -84
- package/dist/lib/component/modifiers.mjs +105 -1
- package/dist/lib/dom/delegate.cjs +60 -1
- package/dist/lib/dom/delegate.js +1 -1
- package/dist/lib/dom/delegate.mjs +39 -1
- package/dist/lib/dom/dynamic-element.cjs +949 -1
- package/dist/lib/dom/dynamic-element.d.ts +3 -3
- package/dist/lib/dom/dynamic-element.js +2 -2
- package/dist/lib/dom/dynamic-element.mjs +928 -1
- package/dist/lib/dom/hydration-state.cjs +93 -1
- package/dist/lib/dom/hydration-state.d.ts +1 -1
- package/dist/lib/dom/hydration-state.js +1 -1
- package/dist/lib/dom/hydration-state.mjs +72 -1
- package/dist/lib/dom/hydration.cjs +685 -1
- package/dist/lib/dom/hydration.js +8 -8
- package/dist/lib/dom/hydration.mjs +664 -1
- package/dist/lib/dom/index.cjs +2040 -1
- package/dist/lib/dom/index.js +1 -1
- package/dist/lib/dom/index.mjs +2020 -1
- package/dist/lib/dom/integration.cjs +71 -1
- package/dist/lib/dom/integration.js +3 -3
- package/dist/lib/dom/integration.mjs +51 -1
- package/dist/lib/dom/island.cjs +790 -1
- package/dist/lib/dom/island.d.ts +1 -1
- package/dist/lib/dom/island.js +11 -11
- package/dist/lib/dom/island.mjs +769 -1
- package/dist/lib/dom/runtime.cjs +1432 -1
- package/dist/lib/dom/runtime.d.ts +60 -17
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +122 -79
- package/dist/lib/dom/runtime.mjs +1414 -1
- package/dist/lib/dom/server/fx-data.cjs +53 -1
- package/dist/lib/dom/server/fx-data.d.ts +5 -5
- package/dist/lib/dom/server/fx-data.js +6 -6
- package/dist/lib/dom/server/fx-data.mjs +32 -1
- package/dist/lib/dom/server/host.cjs +66 -1
- package/dist/lib/dom/server/host.d.ts +6 -0
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.js +7 -1
- package/dist/lib/dom/server/host.mjs +45 -1
- package/dist/lib/dom/server/index.cjs +759 -1
- package/dist/lib/dom/server/index.d.ts +1 -1
- package/dist/lib/dom/server/index.js +1 -1
- package/dist/lib/dom/server/index.mjs +743 -1
- package/dist/lib/dom/server/nodes.cjs +302 -1
- package/dist/lib/dom/server/nodes.d.ts +2 -2
- package/dist/lib/dom/server/nodes.d.ts.map +1 -1
- package/dist/lib/dom/server/nodes.js +4 -4
- package/dist/lib/dom/server/nodes.mjs +279 -1
- package/dist/lib/dom/server/parse-template.cjs +395 -1
- package/dist/lib/dom/server/parse-template.d.ts +1 -1
- package/dist/lib/dom/server/parse-template.js +4 -4
- package/dist/lib/dom/server/parse-template.mjs +372 -1
- package/dist/lib/dom/server/render.cjs +691 -1
- package/dist/lib/dom/server/render.d.ts +9 -1
- package/dist/lib/dom/server/render.d.ts.map +1 -1
- package/dist/lib/dom/server/render.js +23 -15
- package/dist/lib/dom/server/render.mjs +677 -1
- package/dist/lib/dom/server/request-context.cjs +110 -1
- package/dist/lib/dom/server/request-context.d.ts +29 -9
- package/dist/lib/dom/server/request-context.d.ts.map +1 -1
- package/dist/lib/dom/server/request-context.js +28 -8
- package/dist/lib/dom/server/request-context.mjs +89 -1
- package/dist/lib/dom/server/serialize.cjs +187 -1
- package/dist/lib/dom/server/serialize.js +3 -3
- package/dist/lib/dom/server/serialize.mjs +164 -1
- package/dist/lib/dom/server-renderer.cjs +760 -1
- package/dist/lib/dom/server-renderer.js +1 -1
- package/dist/lib/dom/server-renderer.mjs +745 -1
- package/dist/lib/dom/types.cjs +18 -1
- package/dist/lib/dom/utils.cjs +381 -1
- package/dist/lib/dom/utils.d.ts +1 -88
- package/dist/lib/dom/utils.d.ts.map +1 -1
- package/dist/lib/dom/utils.js +2 -99
- package/dist/lib/dom/utils.mjs +361 -1
- package/dist/lib/dom/versions.cjs +60 -1
- package/dist/lib/dom/versions.d.ts +3 -3
- package/dist/lib/dom/versions.d.ts.map +1 -1
- package/dist/lib/dom/versions.js +17 -5
- package/dist/lib/dom/versions.mjs +37 -1
- package/dist/lib/element/attributes.cjs +19 -1
- package/dist/lib/element/attributes.d.ts +7 -7
- package/dist/lib/element/attributes.js +1 -1
- package/dist/lib/element/attributes.mjs +1 -0
- package/dist/lib/element/index.cjs +19 -1
- package/dist/lib/element/index.mjs +1 -0
- package/dist/lib/element/types.cjs +18 -1
- package/dist/lib/element/types.d.ts +4 -5
- package/dist/lib/element/types.d.ts.map +1 -1
- package/dist/lib/element/types.js +0 -1
- package/dist/lib/flow/class-map.cjs +38 -1
- package/dist/lib/flow/class-map.d.ts +3 -3
- package/dist/lib/flow/class-map.js +2 -2
- package/dist/lib/flow/class-map.mjs +17 -1
- package/dist/lib/flow/client-only.cjs +57 -1
- package/dist/lib/flow/client-only.d.ts +4 -4
- package/dist/lib/flow/client-only.js +3 -3
- package/dist/lib/flow/client-only.mjs +36 -1
- package/dist/lib/flow/dynamic.cjs +53 -1
- package/dist/lib/flow/dynamic.d.ts +2 -2
- package/dist/lib/flow/dynamic.js +3 -3
- package/dist/lib/flow/dynamic.mjs +32 -1
- package/dist/lib/flow/error-boundary.cjs +43 -1
- package/dist/lib/flow/error-boundary.d.ts +2 -2
- package/dist/lib/flow/error-boundary.js +3 -3
- package/dist/lib/flow/error-boundary.mjs +22 -1
- package/dist/lib/flow/for.cjs +66 -1
- package/dist/lib/flow/for.d.ts +9 -9
- package/dist/lib/flow/for.d.ts.map +1 -1
- package/dist/lib/flow/for.js +2 -2
- package/dist/lib/flow/for.mjs +45 -1
- package/dist/lib/flow/index-flow.cjs +67 -1
- package/dist/lib/flow/index-flow.d.ts +5 -5
- package/dist/lib/flow/index-flow.js +4 -4
- package/dist/lib/flow/index-flow.mjs +46 -1
- package/dist/lib/flow/index.cjs +805 -1
- package/dist/lib/flow/index.mjs +792 -1
- package/dist/lib/flow/portal.cjs +538 -1
- package/dist/lib/flow/portal.mjs +519 -1
- package/dist/lib/flow/show.cjs +81 -1
- package/dist/lib/flow/show.d.ts +1 -1
- package/dist/lib/flow/show.d.ts.map +1 -1
- package/dist/lib/flow/show.js +4 -115
- package/dist/lib/flow/show.mjs +67 -1
- package/dist/lib/flow/style-map.cjs +43 -1
- package/dist/lib/flow/style-map.d.ts +3 -3
- package/dist/lib/flow/style-map.js +3 -3
- package/dist/lib/flow/style-map.mjs +22 -1
- package/dist/lib/flow/switch.cjs +91 -1
- package/dist/lib/flow/switch.d.ts +3 -3
- package/dist/lib/flow/switch.d.ts.map +1 -1
- package/dist/lib/flow/switch.js +6 -6
- package/dist/lib/flow/switch.mjs +70 -1
- package/dist/lib/flow/utils.cjs +44 -1
- package/dist/lib/flow/utils.d.ts +1 -1
- package/dist/lib/flow/utils.js +1 -1
- package/dist/lib/flow/utils.mjs +23 -1
- package/dist/lib/html.cjs +32 -1
- package/dist/lib/html.d.ts +6 -6
- package/dist/lib/html.js +5 -5
- package/dist/lib/html.mjs +11 -1
- package/dist/lib/index.cjs +3104 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -3
- package/dist/lib/index.mjs +3097 -1
- package/dist/lib/shared/types.cjs +18 -1
- package/dist/lib/shared/types.d.ts +8 -8
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +26 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +2 -2
- package/dist/version.generated.mjs +5 -1
- package/package.json +7 -6
- package/dist/lib/jsx/control-flow/flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/flow.js +0 -627
- package/dist/lib/jsx/control-flow/flow.mjs +0 -0
- package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/for-flow.js +0 -1
- package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
package/dist/lib/flow/index.cjs
CHANGED
|
@@ -1 +1,805 @@
|
|
|
1
|
-
"use strict";var H=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var he=Object.prototype.hasOwnProperty;var me=(e,n)=>{for(var o in n)H(e,o,{get:n[o],enumerable:!0})},xe=(e,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of pe(n))!he.call(e,a)&&a!==o&&H(e,a,{get:()=>n[a],enumerable:!(t=ye(n,a))||t.enumerable});return e};var ge=e=>xe(H({},"__esModule",{value:!0}),e);var ve={};me(ve,{ClientOnly:()=>K,Dynamic:()=>ee,ErrorBoundary:()=>fe,For:()=>X,Index:()=>Y,Match:()=>Z,NoSsr:()=>se,Portal:()=>ie,Show:()=>z,Switch:()=>Q,classMap:()=>ce,indexArray:()=>P.indexArray,keyArray:()=>P.keyArray,mapArray:()=>P.mapArray,styleMap:()=>ue});module.exports=ge(ve);var y=require("@fluixi/reactive/signal");function V(e){return typeof e=="function"?e:(()=>e)}function w(e){return()=>{let n=e();return typeof n=="function"?n():n}}function B(e){return e!=null&&e!==!1}function q(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function z(e){let n=w(()=>e.when),o=(0,y.createMemo)(n,void 0,{name:"Show.when"}),t=(0,y.createMemo)(o,void 0,{name:"Show.cond"}),a=(0,y.getOwner)(),s=null,f=null,i=r=>{r!==f&&(s&&(0,y.disposeScope)(s),s=(0,y.createChildOwner)(a),f=r)};return(0,y.createMemo)(()=>{let r=t();return i(r?"when":"fallback"),(0,y.runWithOwner)(s,()=>{if(r){let c=e.children;return typeof c=="function"&&!q(c)?typeof o=="function"?(0,y.untrack)(()=>(0,y.untrack)(o)?c(o()):e.fallback):c(o):c}return e.fallback});return e.fallback??null},void 0,{name:"Show.result"})}var C=require("@fluixi/reactive/signal");var g={active:!1,cursor:null,parents:[]},be=null;function G(){return be}function D(e,n){return g.active&&n.parentNode===e}function $(e){let n=g.parents.lastIndexOf(e);n!==-1&&(g.parents.length=n),g.cursor=e.nextSibling}function v(e){if(!g.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&$(n)}function X(e){let n=w(()=>e.each),o=()=>e.fallback??null,t=(a,s)=>{let f=e.children,i=Array.isArray(f)?f.map(r=>typeof r=="function"?r(a,s):r):typeof f=="function"?f(a,s):f;return v(i),i};return e.by?(0,C.keyArray)(n,e.by,(a,s)=>t(a,s),{fallback:o}):(0,C.mapArray)(n,(a,s)=>t(a,s),{fallback:o})}var J=require("@fluixi/reactive/signal");function Y(e){let n=w(()=>e.each);return(0,J.indexArray)(n,(o,t)=>{let a=e.children(o,t);return v(a),a},{fallback:()=>e.fallback??null})}var P=require("@fluixi/reactive/signal");var m=require("@fluixi/reactive/signal");var U=Symbol("match");function Z(e){return{[U]:!0,when:w(()=>e.when),get children(){return e.children}}}function Q(e){let n=Array.isArray(e.children)?e.children:[e.children],o=(0,m.getOwner)(),t=null,a=-1,s=f=>{f!==a&&(t&&(0,m.disposeScope)(t),t=(0,m.createChildOwner)(o),a=f)};return(0,m.createMemo)(()=>{for(let f=0;f<n.length;f+=1){let r=n[f],c=0;for(;typeof r=="function"&&!r[U]&&c++<10;)r=r();if(!r||typeof r!="object"||r[U]!==!0)continue;let l=r.when();if(B(l))return s(f),(0,m.runWithOwner)(t,()=>typeof r.children=="function"?r.children(l):r.children)}return s(-2),(0,m.runWithOwner)(t,()=>e.fallback??null)},void 0,{name:"Switch"})}var b=require("@fluixi/reactive/signal");function ee(e){let n=V(e.component),{component:o,...t}=e,a=(0,b.getOwner)(),s=null,f;return(0,b.createMemo)(()=>{let i=n();return i!==f&&(s&&(0,b.disposeScope)(s),s=(0,b.createChildOwner)(a),f=i),i==null?null:typeof i=="string"?{tag:i,props:t}:(0,b.runWithOwner)(s,()=>i(t))},void 0,{name:"Dynamic"})}var L=require("@fluixi/reactive/signal");var x=require("@fluixi/reactive/signal");function E(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var h=require("@fluixi/reactive/signal");var ne=Symbol.for("fluixi.server-node"),Te=Symbol.for("fluixi.dom.server-host"),Ne=globalThis,W=Ne[Te]??={server:typeof document>"u",nodes:null};function k(){return W.server}function te(){if(!W.nodes)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return W.nodes}function M(e){return e!=null&&e[ne]===!0?!0:typeof Node<"u"&&e instanceof Node}function oe(e){return e!=null&&e[ne]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}var we="__fx_at";function A(e,n=!1){if(k())return te().createText(e);if(g.active&&!n){let o=G()?.hydrateText(e);if(o)return o}return document.createTextNode(e)}var N=0,Ae=200;function Ee(e,n,o,t,a){let s=t,f=new Map;return(0,h.createRenderEffect)(()=>{(0,h.reportReactiveBinding)(o??n,"content",void 0,e);let i;if(E(e)&&!(0,x.isSignal)(e)){if(!f.has(e)){N++;try{let r=e();f.set(e,r)}finally{N--}}for(i=f.get(e);typeof i=="function"&&(0,x.isSignal)(i);)i=i()}else for(i=e();typeof i=="function"&&(0,x.isSignal)(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(E(i)){if(!f.has(i)){let c=i;N++;try{let l=c();f.set(c,l)}finally{N--}}i=f.get(i)}else if((0,x.isSignal)(i))i=i();else if(i=i(),typeof i!="function"||!(0,x.isSignal)(i)&&!E(i))break}N++;try{s=O(n,i,o,s,f),a(s)}finally{N--}})}function I(e,n,o,t){if(N>Ae)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;o!==void 0&&!o&&(o=A("",!0),e.appendChild(o));let a=t??null,s=r=>Array.isArray(r)&&r.some(c=>typeof c=="function"),f=r=>typeof r=="function"?r:()=>r;if(typeof n!="function"&&!s(n)){N++;try{a=O(e,n,o,a)}finally{N--}return()=>a}let i=Ee(f(n),e,o,a,r=>{a=r});return()=>(i?.(),a)}function O(e,n,o,t,a){if(n==null||typeof n=="boolean")return S(e,t,o);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return S(e,t,o);if(R(n)){let f=A("",!0);return Array.isArray(t)?t.length>0?(e.replaceChild(f,t[0]),S(e,t.slice(1),o)):p(e,f,o):t?e.replaceChild(f,t):p(e,f,o),n.then(i=>{f.parentNode===e&&O(e,i,f.nextSibling,f)}).catch(i=>{console.error("Error resolving promise in insertExpression:",i)}),f}let s=typeof n;if(s==="string"||s==="number"){if(s==="number"&&(n=String(n)),Array.isArray(t)){if(t.length===0){let i=A(n);return p(e,i,o),i}if(t.length===1&&t[0].nodeType===3)return t[0].data=n,t;t=S(e,t,o)}if(t&&oe(t))return t.data=n,t;let f=A(n);return t&&t.parentNode===e?e.replaceChild(f,t):D(e,f)||p(e,f,o),f}if(M(n))return D(e,n)?($(n),n):Array.isArray(t)?(t.length===0?p(e,n,o):t[0].parentNode===e?(e.replaceChild(n,t[0]),S(e,t.slice(1),o)):p(e,n,o),n):(t?t!==n&&(t.parentNode===e?e.replaceChild(n,t):p(e,n,o)):p(e,n,o),n);if(Array.isArray(n)){let f=[],i=Array.isArray(t)?t:t?[t]:[],r=[];T(n,f,e,o,!0,a,r);let c=Se(e,i,f,o);for(let l of r){let u=I(e,l.sig,l.marker);(0,h.onCleanup)(()=>{S(e,u()),l.marker.parentNode===e&&e.removeChild(l.marker)})}return c}if(s==="object"&&n!==null&&typeof n=="object"){let f=n;if("type"in f&&"props"in f){let i=f;if(typeof i.type=="function"){let r=i.type(i.props||{});return O(e,r,o,t)}}}return S(e,t,o)}function T(e,n,o,t,a=!0,s,f){for(let i=0;i<e.length;i++){let r=e[i];if(!(r==null||typeof r=="boolean")){for(;typeof r=="function"&&!R(r)&&!(0,x.isSignal)(r)&&!E(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let c;for(E(r)&&!(0,x.isSignal)(r)?(s||(s=new Map),s.has(r)||s.set(r,r()),c=s.get(r)):c=r();typeof c=="function"&&!R(c)&&!(0,x.isSignal)(c)&&!E(c);)s||(s=new Map),s.has(c)||s.set(c,c()),c=s.get(c);if(c==null||typeof c=="boolean")continue;if(typeof c=="function"){if((0,x.isSignal)(c)){if(f){let u=A("",!0);n.push(u),f.push({marker:u,sig:c});continue}let l=c();for(;typeof l=="function"&&(0,x.isSignal)(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?T(l,n,o,t,a,s):T([l],n,o,t,a,s);continue}continue}Array.isArray(c)?T(c,n,o,t,a,s,f):T([c],n,o,t,a,s,f);continue}if(R(r)){let c=A("",!0);n.push(c),r.then(l=>{if(c.parentNode){let u=[];if(T([l],u,c.parentNode,void 0,!1,s),u.length>0){c.parentNode.replaceChild(u[0],c);for(let d=1;d<u.length;d++)c.parentNode?.insertBefore(u[d],u[d-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(r)){T(r,n,o,t,a,s,f);continue}if(M(r)){n.push(r);continue}if(typeof r=="object"&&r!==null&&"type"in r&&"props"in r){let c=r;if(typeof c.type=="function"){let l=c.type(c.props||{});Array.isArray(l)?T(l,n,o,t,!1,s):T([l],n,o,t,!1,s);continue}}if(typeof r=="string"||typeof r=="number"){let c=String(r);if(c.trim()===""&&c!==" ")continue;n.push(A(c));continue}n.push(A(String(r)))}}}}function Se(e,n,o,t){for(let u=0;u<o.length;u++){let d=o[u].parentNode;d!==null&&d!==e&&d.nodeType!==11&&(o=o.slice(),o[u]=o[u].cloneNode(!0))}let a=o.length,s=n.length,f=a,i=0,r=0,c=s>0?n[s-1].nextSibling??void 0:t,l=null;for(;i<s||r<f;){if(n[i]===o[r]){i++,r++;continue}for(;s>i&&f>r&&n[s-1]===o[f-1];)s--,f--;if(s===i){let u=f<a?r?o[r-1].nextSibling??void 0:o[f-r]:c;for(;r<f;)p(e,o[r++],u)}else if(f===r)for(;i<s;)(!l||!l.has(n[i]))&&n[i].parentNode===e&&e.removeChild(n[i]),i++;else if(n[i]===o[f-1]&&o[r]===n[s-1]){let u=n[--s].nextSibling;p(e,o[r++],n[i++].nextSibling),p(e,o[--f],u),n[s]=n[i-1]}else{if(!l){l=new Map;let d=r;for(;d<f;)l.set(o[d],d++)}let u=l.get(n[i]);if(u!=null)if(r<u&&u<f){let d=i,F=1;for(;++d<s&&d<f&&!(!l.has(n[d])||l.get(n[d])!==u+F);)F++;if(F>u-r){let de=n[i];for(;r<u;)p(e,o[r++],de)}else n[i].parentNode===e?e.replaceChild(o[r++],n[i++]):(p(e,o[r++],c),i++)}else i++;else n[i].parentNode===e&&e.removeChild(n[i]),i++}}return o}function S(e,n,o){if(n)if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].parentNode===e&&e.removeChild(n[t]);else n.parentNode===e&&e.removeChild(n);return null}function p(e,n,o){g.active&&n.parentNode===e||(o&&o.parentNode===e?e.insertBefore(n,o):e.appendChild(n))}function re(e,n){if(!e)return;let o=e[we]?.name;if((0,h.reportReactiveDirective)(n,"ref",o||typeof e=="function"&&e.name||"ref",e),M(e)){let t=n,a=e;if(!t)return;typeof t=="function"?t(a):typeof t=="object"&&"current"in t&&(t.current=a);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}function R(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function ie(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,o,t;return(0,L.createRoot)(a=>{o=a,t=document.createElement("div"),t.style.display="contents",n().appendChild(t),I(t,e.children)&&re(e.ref,t)}),(0,L.onCleanup)(()=>{o(),t.remove()}),null}var j=require("@fluixi/reactive/signal");function K(e){if(k())return e.fallback??null;let n=g.active,[o,t]=(0,j.createSignal)(!n);return n&&queueMicrotask(()=>t(!0)),(0,j.createMemo)(()=>o()?e.children:e.fallback??null,void 0,{name:"client-only"})}var se=K;var _=require("@fluixi/reactive/signal");function fe(e){let[n,o]=(0,_.createSignal)(null),t=()=>o(null);return(0,_.createMemo)(()=>{let a=n();if(a!==null)return typeof e.fallback=="function"?e.fallback(a,t):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(s){return o(s),typeof e.fallback=="function"?e.fallback(s,t):e.fallback}},void 0,{name:"ErrorBoundary"})}var ae=require("@fluixi/reactive/signal");function ce(e){return(0,ae.createMemo)(()=>{let n=typeof e=="function"?e():e,o=[];for(let[t,a]of Object.entries(n)){if(!t)continue;(typeof a=="function"?a():a)&&o.push(t)}return o.join(" ")},void 0,{name:"ClassMap"})}var le=require("@fluixi/reactive/signal");function Pe(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function ue(e){return(0,le.createMemo)(()=>{let n=typeof e=="function"?e():e,o=[];for(let[t,a]of Object.entries(n)){if(!t)continue;let s=typeof a=="function"?a():a;s!=null&&o.push(`${Pe(t)}: ${s}`)}return o.join("; ")},void 0,{name:"StyleMap"})}
|
|
1
|
+
/*! @fluixi/dom v1.0.0-alpha.85 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/lib/flow/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
ClientOnly: () => ClientOnly,
|
|
25
|
+
Dynamic: () => Dynamic,
|
|
26
|
+
ErrorBoundary: () => ErrorBoundary,
|
|
27
|
+
For: () => For,
|
|
28
|
+
Index: () => Index,
|
|
29
|
+
Match: () => Match,
|
|
30
|
+
NoSsr: () => NoSsr,
|
|
31
|
+
Portal: () => Portal,
|
|
32
|
+
Show: () => Show,
|
|
33
|
+
Switch: () => Switch,
|
|
34
|
+
classMap: () => classMap,
|
|
35
|
+
indexArray: () => import_signal13.indexArray,
|
|
36
|
+
keyArray: () => import_signal13.keyArray,
|
|
37
|
+
mapArray: () => import_signal13.mapArray,
|
|
38
|
+
styleMap: () => styleMap
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(index_exports);
|
|
41
|
+
|
|
42
|
+
// src/lib/flow/show.ts
|
|
43
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
44
|
+
|
|
45
|
+
// src/lib/flow/utils.ts
|
|
46
|
+
function normalizeAccessor(value) {
|
|
47
|
+
return typeof value === "function" ? value : (() => value);
|
|
48
|
+
}
|
|
49
|
+
function resolveReactiveProp(read) {
|
|
50
|
+
return () => {
|
|
51
|
+
const value = read();
|
|
52
|
+
return typeof value === "function" ? value() : value;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function isTruthy(value) {
|
|
56
|
+
return value !== null && value !== void 0 && value !== false;
|
|
57
|
+
}
|
|
58
|
+
function isLitResult(value) {
|
|
59
|
+
if (!value || typeof value !== "object") return false;
|
|
60
|
+
return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/lib/flow/show.ts
|
|
64
|
+
function Show(props) {
|
|
65
|
+
const when = resolveReactiveProp(() => props.when);
|
|
66
|
+
const value = (0, import_signal.createMemo)(when, void 0, { name: "Show.when" });
|
|
67
|
+
const cond = (0, import_signal.createMemo)(value, void 0, { name: "Show.cond" });
|
|
68
|
+
const parentOwner = (0, import_signal.getOwner)();
|
|
69
|
+
let branchScope = null;
|
|
70
|
+
let shown = null;
|
|
71
|
+
const enterBranch = (next) => {
|
|
72
|
+
if (next === shown) return;
|
|
73
|
+
if (branchScope) (0, import_signal.disposeScope)(branchScope);
|
|
74
|
+
branchScope = (0, import_signal.createChildOwner)(parentOwner);
|
|
75
|
+
shown = next;
|
|
76
|
+
};
|
|
77
|
+
return (0, import_signal.createMemo)(
|
|
78
|
+
() => {
|
|
79
|
+
const evaluate = cond();
|
|
80
|
+
enterBranch(evaluate ? "when" : "fallback");
|
|
81
|
+
return (0, import_signal.runWithOwner)(branchScope, () => {
|
|
82
|
+
if (evaluate) {
|
|
83
|
+
let children = props.children;
|
|
84
|
+
if (typeof children === "function" && !isLitResult(children)) {
|
|
85
|
+
if (typeof value === "function") {
|
|
86
|
+
return (0, import_signal.untrack)(() => {
|
|
87
|
+
if (!(0, import_signal.untrack)(value)) return props.fallback;
|
|
88
|
+
return children(value());
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return children(value);
|
|
92
|
+
}
|
|
93
|
+
return children;
|
|
94
|
+
}
|
|
95
|
+
return props.fallback;
|
|
96
|
+
});
|
|
97
|
+
return props.fallback ?? null;
|
|
98
|
+
},
|
|
99
|
+
void 0,
|
|
100
|
+
// Not `Show`: the compiler already marks the memo it wraps the component in with that,
|
|
101
|
+
// and two cards of the same name in one graph is worse than a longer one.
|
|
102
|
+
{ name: "Show.result" }
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/lib/flow/for.ts
|
|
107
|
+
var import_signal2 = require("@fluixi/reactive/signal");
|
|
108
|
+
|
|
109
|
+
// src/lib/dom/hydration-state.ts
|
|
110
|
+
var hydration = {
|
|
111
|
+
active: false,
|
|
112
|
+
cursor: null,
|
|
113
|
+
parents: []
|
|
114
|
+
};
|
|
115
|
+
var _walker = null;
|
|
116
|
+
function getHydrationWalker() {
|
|
117
|
+
return _walker;
|
|
118
|
+
}
|
|
119
|
+
function isAdopted(parent, node) {
|
|
120
|
+
return hydration.active && node.parentNode === parent;
|
|
121
|
+
}
|
|
122
|
+
function ascendPast(node) {
|
|
123
|
+
const idx = hydration.parents.lastIndexOf(node);
|
|
124
|
+
if (idx !== -1) hydration.parents.length = idx;
|
|
125
|
+
hydration.cursor = node.nextSibling;
|
|
126
|
+
}
|
|
127
|
+
function hydrateAdvancePast(rendered) {
|
|
128
|
+
if (!hydration.active || rendered == null) return;
|
|
129
|
+
const last = Array.isArray(rendered) ? rendered[rendered.length - 1] : rendered;
|
|
130
|
+
if (last && typeof last.nodeType === "number") {
|
|
131
|
+
ascendPast(last);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/lib/flow/for.ts
|
|
136
|
+
function For(props) {
|
|
137
|
+
const each = resolveReactiveProp(() => props.each);
|
|
138
|
+
const fallback = () => props.fallback ?? null;
|
|
139
|
+
const render = (item, index) => {
|
|
140
|
+
const children = props.children;
|
|
141
|
+
const rendered = Array.isArray(children) ? children.map((c) => typeof c === "function" ? c(item, index) : c) : typeof children === "function" ? children(item, index) : children;
|
|
142
|
+
hydrateAdvancePast(rendered);
|
|
143
|
+
return rendered;
|
|
144
|
+
};
|
|
145
|
+
return props.by ? (0, import_signal2.keyArray)(each, props.by, (item, index) => render(item, index), { fallback }) : (0, import_signal2.mapArray)(each, (item, index) => render(item, index), { fallback });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// src/lib/flow/index-flow.ts
|
|
149
|
+
var import_signal3 = require("@fluixi/reactive/signal");
|
|
150
|
+
function Index(props) {
|
|
151
|
+
const each = resolveReactiveProp(() => props.each);
|
|
152
|
+
return (0, import_signal3.indexArray)(
|
|
153
|
+
each,
|
|
154
|
+
(item, index) => {
|
|
155
|
+
const rendered = props.children(item, index);
|
|
156
|
+
hydrateAdvancePast(rendered);
|
|
157
|
+
return rendered;
|
|
158
|
+
},
|
|
159
|
+
{ fallback: () => props.fallback ?? null }
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/lib/flow/index.ts
|
|
164
|
+
var import_signal13 = require("@fluixi/reactive/signal");
|
|
165
|
+
|
|
166
|
+
// src/lib/flow/switch.ts
|
|
167
|
+
var import_signal4 = require("@fluixi/reactive/signal");
|
|
168
|
+
var MATCH_MARKER = /* @__PURE__ */ Symbol("match");
|
|
169
|
+
function Match(props) {
|
|
170
|
+
return {
|
|
171
|
+
[MATCH_MARKER]: true,
|
|
172
|
+
// Lazy read through the prop getter. Switch calls `branch.when()` inside its memo,
|
|
173
|
+
// so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
|
|
174
|
+
when: resolveReactiveProp(() => props.when),
|
|
175
|
+
// Lazy, like `when`. Read eagerly, every branch's children were built the
|
|
176
|
+
// moment the Match node was, before Switch had chosen one, so they were
|
|
177
|
+
// created outside the branch's scope (and non-matching branches were built
|
|
178
|
+
// for nothing). Switch reads this inside the selected branch's scope.
|
|
179
|
+
get children() {
|
|
180
|
+
return props.children;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function Switch(props) {
|
|
185
|
+
const branches = Array.isArray(props.children) ? props.children : [props.children];
|
|
186
|
+
const parentOwner = (0, import_signal4.getOwner)();
|
|
187
|
+
let branchScope = null;
|
|
188
|
+
let shown = -1;
|
|
189
|
+
const enterBranch = (index) => {
|
|
190
|
+
if (index === shown) return;
|
|
191
|
+
if (branchScope) (0, import_signal4.disposeScope)(branchScope);
|
|
192
|
+
branchScope = (0, import_signal4.createChildOwner)(parentOwner);
|
|
193
|
+
shown = index;
|
|
194
|
+
};
|
|
195
|
+
return (0, import_signal4.createMemo)(() => {
|
|
196
|
+
for (let i = 0; i < branches.length; i += 1) {
|
|
197
|
+
const raw = branches[i];
|
|
198
|
+
let branch = raw;
|
|
199
|
+
let guard = 0;
|
|
200
|
+
while (typeof branch === "function" && !branch[MATCH_MARKER] && guard++ < 10) {
|
|
201
|
+
branch = branch();
|
|
202
|
+
}
|
|
203
|
+
if (!branch || typeof branch !== "object" || branch[MATCH_MARKER] !== true) {
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const value = branch.when();
|
|
207
|
+
if (isTruthy(value)) {
|
|
208
|
+
enterBranch(i);
|
|
209
|
+
return (0, import_signal4.runWithOwner)(
|
|
210
|
+
branchScope,
|
|
211
|
+
() => typeof branch.children === "function" ? branch.children(value) : branch.children
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
enterBranch(-2);
|
|
216
|
+
return (0, import_signal4.runWithOwner)(branchScope, () => props.fallback ?? null);
|
|
217
|
+
}, void 0, { name: "Switch" });
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// src/lib/flow/dynamic.ts
|
|
221
|
+
var import_signal5 = require("@fluixi/reactive/signal");
|
|
222
|
+
function Dynamic(props) {
|
|
223
|
+
const getComponent = normalizeAccessor(props.component);
|
|
224
|
+
const { component: _c, ...rest } = props;
|
|
225
|
+
const parentOwner = (0, import_signal5.getOwner)();
|
|
226
|
+
let scope = null;
|
|
227
|
+
let current;
|
|
228
|
+
return (0, import_signal5.createMemo)(() => {
|
|
229
|
+
const C = getComponent();
|
|
230
|
+
if (C !== current) {
|
|
231
|
+
if (scope) (0, import_signal5.disposeScope)(scope);
|
|
232
|
+
scope = (0, import_signal5.createChildOwner)(parentOwner);
|
|
233
|
+
current = C;
|
|
234
|
+
}
|
|
235
|
+
if (C == null) return null;
|
|
236
|
+
if (typeof C === "string") {
|
|
237
|
+
return { tag: C, props: rest };
|
|
238
|
+
}
|
|
239
|
+
return (0, import_signal5.runWithOwner)(scope, () => C(rest));
|
|
240
|
+
}, void 0, { name: "Dynamic" });
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// src/lib/flow/portal.ts
|
|
244
|
+
var import_signal8 = require("@fluixi/reactive/signal");
|
|
245
|
+
|
|
246
|
+
// src/lib/dom/runtime.ts
|
|
247
|
+
var import_signal6 = require("@fluixi/reactive/signal");
|
|
248
|
+
|
|
249
|
+
// src/lib/component/modifiers.ts
|
|
250
|
+
function isComponent(value) {
|
|
251
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// src/lib/dom/runtime.ts
|
|
255
|
+
var import_signal7 = require("@fluixi/reactive/signal");
|
|
256
|
+
|
|
257
|
+
// src/lib/dom/server/host.ts
|
|
258
|
+
var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
|
|
259
|
+
var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
|
|
260
|
+
var realm = globalThis;
|
|
261
|
+
var state = realm[STATE] ??= {
|
|
262
|
+
server: typeof document === "undefined",
|
|
263
|
+
nodes: null
|
|
264
|
+
};
|
|
265
|
+
function isServer() {
|
|
266
|
+
return state.server;
|
|
267
|
+
}
|
|
268
|
+
function getServerNodes() {
|
|
269
|
+
if (!state.nodes) {
|
|
270
|
+
throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
|
|
271
|
+
}
|
|
272
|
+
return state.nodes;
|
|
273
|
+
}
|
|
274
|
+
function isDomNode(x) {
|
|
275
|
+
if (x != null && x[SERVER_NODE] === true) return true;
|
|
276
|
+
return typeof Node !== "undefined" && x instanceof Node;
|
|
277
|
+
}
|
|
278
|
+
function isDomText(x) {
|
|
279
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
|
|
280
|
+
return typeof Text !== "undefined" && x instanceof Text;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// src/lib/dom/runtime.ts
|
|
284
|
+
var HOLE_TAG = "__fx_at";
|
|
285
|
+
function createTextNode(value, anchor = false) {
|
|
286
|
+
if (isServer()) return getServerNodes().createText(value);
|
|
287
|
+
if (hydration.active && !anchor) {
|
|
288
|
+
const node = getHydrationWalker()?.hydrateText(value);
|
|
289
|
+
if (node) return node;
|
|
290
|
+
}
|
|
291
|
+
return document.createTextNode(value);
|
|
292
|
+
}
|
|
293
|
+
var _insertDepth = 0;
|
|
294
|
+
var MAX_INSERT_DEPTH = 200;
|
|
295
|
+
function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
|
|
296
|
+
let current = initialCurrent;
|
|
297
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
298
|
+
return (0, import_signal7.createRenderEffect)(() => {
|
|
299
|
+
(0, import_signal7.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
|
|
300
|
+
let value;
|
|
301
|
+
if (isComponent(getAccessor) && !(0, import_signal6.isSignal)(getAccessor)) {
|
|
302
|
+
if (!componentCache.has(getAccessor)) {
|
|
303
|
+
_insertDepth++;
|
|
304
|
+
try {
|
|
305
|
+
const inst = getAccessor();
|
|
306
|
+
componentCache.set(getAccessor, inst);
|
|
307
|
+
} finally {
|
|
308
|
+
_insertDepth--;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
value = componentCache.get(getAccessor);
|
|
312
|
+
while (typeof value === "function" && (0, import_signal6.isSignal)(value)) value = value();
|
|
313
|
+
} else {
|
|
314
|
+
value = getAccessor();
|
|
315
|
+
while (typeof value === "function" && (0, import_signal6.isSignal)(value)) {
|
|
316
|
+
value = value();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
{
|
|
320
|
+
let chainDepth = 0;
|
|
321
|
+
while (typeof value === "function" && chainDepth++ < 50) {
|
|
322
|
+
if (isComponent(value)) {
|
|
323
|
+
if (!componentCache.has(value)) {
|
|
324
|
+
const thunk = value;
|
|
325
|
+
_insertDepth++;
|
|
326
|
+
try {
|
|
327
|
+
const inst = thunk();
|
|
328
|
+
componentCache.set(thunk, inst);
|
|
329
|
+
} finally {
|
|
330
|
+
_insertDepth--;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
value = componentCache.get(value);
|
|
334
|
+
} else if ((0, import_signal6.isSignal)(value)) {
|
|
335
|
+
value = value();
|
|
336
|
+
} else {
|
|
337
|
+
value = value();
|
|
338
|
+
if (typeof value !== "function" || !(0, import_signal6.isSignal)(value) && !isComponent(value)) break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
_insertDepth++;
|
|
343
|
+
try {
|
|
344
|
+
current = insertExpression(parent, value, marker, current, componentCache);
|
|
345
|
+
setCurrent(current);
|
|
346
|
+
} finally {
|
|
347
|
+
_insertDepth--;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function insert(parent, accessor, marker, init) {
|
|
352
|
+
if (_insertDepth > MAX_INSERT_DEPTH) {
|
|
353
|
+
console.error("[insert] Exceeded max call depth, possible infinite loop.");
|
|
354
|
+
return () => null;
|
|
355
|
+
}
|
|
356
|
+
if (marker !== void 0 && !marker) {
|
|
357
|
+
marker = createTextNode("", true);
|
|
358
|
+
parent.appendChild(marker);
|
|
359
|
+
}
|
|
360
|
+
let current = init ?? null;
|
|
361
|
+
const isReactiveArray = (element) => {
|
|
362
|
+
return Array.isArray(element) && element.some((v) => typeof v === "function");
|
|
363
|
+
};
|
|
364
|
+
const normalizeAccessor3 = (accessor2) => {
|
|
365
|
+
if (typeof accessor2 === "function") return accessor2;
|
|
366
|
+
return () => accessor2;
|
|
367
|
+
};
|
|
368
|
+
if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
|
|
369
|
+
_insertDepth++;
|
|
370
|
+
try {
|
|
371
|
+
current = insertExpression(parent, accessor, marker, current);
|
|
372
|
+
} finally {
|
|
373
|
+
_insertDepth--;
|
|
374
|
+
}
|
|
375
|
+
return () => current;
|
|
376
|
+
}
|
|
377
|
+
const dispose = _createInsertEffect(
|
|
378
|
+
normalizeAccessor3(accessor),
|
|
379
|
+
parent,
|
|
380
|
+
marker,
|
|
381
|
+
current,
|
|
382
|
+
(v) => {
|
|
383
|
+
current = v;
|
|
384
|
+
}
|
|
385
|
+
);
|
|
386
|
+
return () => {
|
|
387
|
+
dispose?.();
|
|
388
|
+
return current;
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function insertExpression(parent, value, marker, current, componentCache) {
|
|
392
|
+
if (value == null || typeof value === "boolean") {
|
|
393
|
+
return cleanChildren(parent, current, marker);
|
|
394
|
+
}
|
|
395
|
+
if (typeof value === "function") {
|
|
396
|
+
while (typeof value === "function") {
|
|
397
|
+
value = value();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (value == null || typeof value === "boolean") {
|
|
401
|
+
return cleanChildren(parent, current, marker);
|
|
402
|
+
}
|
|
403
|
+
if (isPromise(value)) {
|
|
404
|
+
const placeholder = createTextNode("", true);
|
|
405
|
+
if (Array.isArray(current)) {
|
|
406
|
+
if (current.length > 0) {
|
|
407
|
+
parent.replaceChild(placeholder, current[0]);
|
|
408
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
409
|
+
} else {
|
|
410
|
+
insertBefore(parent, placeholder, marker);
|
|
411
|
+
}
|
|
412
|
+
} else if (current) {
|
|
413
|
+
parent.replaceChild(placeholder, current);
|
|
414
|
+
} else {
|
|
415
|
+
insertBefore(parent, placeholder, marker);
|
|
416
|
+
}
|
|
417
|
+
value.then((resolved) => {
|
|
418
|
+
if (placeholder.parentNode === parent) {
|
|
419
|
+
insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
|
|
420
|
+
}
|
|
421
|
+
}).catch((err) => {
|
|
422
|
+
console.error("Error resolving promise in insertExpression:", err);
|
|
423
|
+
});
|
|
424
|
+
return placeholder;
|
|
425
|
+
}
|
|
426
|
+
const t = typeof value;
|
|
427
|
+
if (t === "string" || t === "number") {
|
|
428
|
+
if (t === "number") value = String(value);
|
|
429
|
+
if (Array.isArray(current)) {
|
|
430
|
+
if (current.length === 0) {
|
|
431
|
+
const node2 = createTextNode(value);
|
|
432
|
+
insertBefore(parent, node2, marker);
|
|
433
|
+
return node2;
|
|
434
|
+
}
|
|
435
|
+
if (current.length === 1 && current[0].nodeType === 3) {
|
|
436
|
+
current[0].data = value;
|
|
437
|
+
return current;
|
|
438
|
+
}
|
|
439
|
+
current = cleanChildren(parent, current, marker);
|
|
440
|
+
}
|
|
441
|
+
if (current && isDomText(current)) {
|
|
442
|
+
current.data = value;
|
|
443
|
+
return current;
|
|
444
|
+
}
|
|
445
|
+
const node = createTextNode(value);
|
|
446
|
+
if (current && current.parentNode === parent) {
|
|
447
|
+
parent.replaceChild(node, current);
|
|
448
|
+
} else if (!isAdopted(parent, node)) {
|
|
449
|
+
insertBefore(parent, node, marker);
|
|
450
|
+
}
|
|
451
|
+
return node;
|
|
452
|
+
}
|
|
453
|
+
if (isDomNode(value)) {
|
|
454
|
+
if (isAdopted(parent, value)) {
|
|
455
|
+
ascendPast(value);
|
|
456
|
+
return value;
|
|
457
|
+
}
|
|
458
|
+
if (Array.isArray(current)) {
|
|
459
|
+
if (current.length === 0) {
|
|
460
|
+
insertBefore(parent, value, marker);
|
|
461
|
+
} else if (current[0].parentNode === parent) {
|
|
462
|
+
parent.replaceChild(value, current[0]);
|
|
463
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
464
|
+
} else {
|
|
465
|
+
insertBefore(parent, value, marker);
|
|
466
|
+
}
|
|
467
|
+
return value;
|
|
468
|
+
}
|
|
469
|
+
if (!current) {
|
|
470
|
+
insertBefore(parent, value, marker);
|
|
471
|
+
} else if (current !== value) {
|
|
472
|
+
if (current.parentNode === parent) {
|
|
473
|
+
parent.replaceChild(value, current);
|
|
474
|
+
} else {
|
|
475
|
+
insertBefore(parent, value, marker);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return value;
|
|
479
|
+
}
|
|
480
|
+
if (Array.isArray(value)) {
|
|
481
|
+
const array = [];
|
|
482
|
+
const currentArray = Array.isArray(current) ? current : current ? [current] : [];
|
|
483
|
+
const reactiveSlots = [];
|
|
484
|
+
flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
|
|
485
|
+
const reconciled = reconcileArrays(parent, currentArray, array, marker);
|
|
486
|
+
for (const slot of reactiveSlots) {
|
|
487
|
+
const disposeSlot = insert(parent, slot.sig, slot.marker);
|
|
488
|
+
(0, import_signal7.onCleanup)(() => {
|
|
489
|
+
cleanChildren(parent, disposeSlot());
|
|
490
|
+
if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
return reconciled;
|
|
494
|
+
}
|
|
495
|
+
if (t === "object" && value !== null && typeof value === "object") {
|
|
496
|
+
const objValue = value;
|
|
497
|
+
if ("type" in objValue && "props" in objValue) {
|
|
498
|
+
const jsxValue = objValue;
|
|
499
|
+
if (typeof jsxValue.type === "function") {
|
|
500
|
+
const result = jsxValue.type(jsxValue.props || {});
|
|
501
|
+
return insertExpression(parent, result, marker, current);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return cleanChildren(parent, current, marker);
|
|
506
|
+
}
|
|
507
|
+
function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
|
|
508
|
+
for (let i = 0; i < arr.length; i++) {
|
|
509
|
+
let item = arr[i];
|
|
510
|
+
if (item == null || typeof item === "boolean") continue;
|
|
511
|
+
while (typeof item === "function" && !isPromise(item) && !(0, import_signal6.isSignal)(item) && !isComponent(item)) {
|
|
512
|
+
item = item();
|
|
513
|
+
if (item == null || typeof item === "boolean") break;
|
|
514
|
+
}
|
|
515
|
+
if (item == null || typeof item === "boolean") continue;
|
|
516
|
+
if (typeof item === "function") {
|
|
517
|
+
let resolved;
|
|
518
|
+
if (isComponent(item) && !(0, import_signal6.isSignal)(item)) {
|
|
519
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
520
|
+
if (!componentCache.has(item)) componentCache.set(item, item());
|
|
521
|
+
resolved = componentCache.get(item);
|
|
522
|
+
} else {
|
|
523
|
+
resolved = item();
|
|
524
|
+
}
|
|
525
|
+
while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal6.isSignal)(resolved) && !isComponent(resolved)) {
|
|
526
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
527
|
+
if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
|
|
528
|
+
resolved = componentCache.get(resolved);
|
|
529
|
+
}
|
|
530
|
+
if (resolved == null || typeof resolved === "boolean") continue;
|
|
531
|
+
if (typeof resolved === "function") {
|
|
532
|
+
if ((0, import_signal6.isSignal)(resolved)) {
|
|
533
|
+
if (reactiveSlots) {
|
|
534
|
+
const slot = createTextNode("", true);
|
|
535
|
+
result.push(slot);
|
|
536
|
+
reactiveSlots.push({ marker: slot, sig: resolved });
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
let val = resolved();
|
|
540
|
+
while (typeof val === "function" && (0, import_signal6.isSignal)(val)) val = val();
|
|
541
|
+
if (val == null || typeof val === "boolean") continue;
|
|
542
|
+
if (Array.isArray(val)) {
|
|
543
|
+
flattenArray(val, result, parent, marker, track, componentCache);
|
|
544
|
+
} else flattenArray([val], result, parent, marker, track, componentCache);
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
|
|
550
|
+
else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
if (isPromise(item)) {
|
|
554
|
+
const placeholder = createTextNode("", true);
|
|
555
|
+
result.push(placeholder);
|
|
556
|
+
item.then((resolved) => {
|
|
557
|
+
if (placeholder.parentNode) {
|
|
558
|
+
const tempNodes = [];
|
|
559
|
+
flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
|
|
560
|
+
if (tempNodes.length > 0) {
|
|
561
|
+
placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
|
|
562
|
+
for (let j = 1; j < tempNodes.length; j++) {
|
|
563
|
+
placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}).catch((err) => console.error("Error resolving promise in array:", err));
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
if (Array.isArray(item)) {
|
|
571
|
+
flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
if (isDomNode(item)) {
|
|
575
|
+
result.push(item);
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
|
|
579
|
+
const jsxItem = item;
|
|
580
|
+
if (typeof jsxItem.type === "function") {
|
|
581
|
+
const resolved = jsxItem.type(jsxItem.props || {});
|
|
582
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
|
|
583
|
+
else flattenArray([resolved], result, parent, marker, false, componentCache);
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
588
|
+
const str = String(item);
|
|
589
|
+
if (str.trim() === "" && str !== " ") continue;
|
|
590
|
+
result.push(createTextNode(str));
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
result.push(createTextNode(String(item)));
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function reconcileArrays(parent, a, b, marker) {
|
|
597
|
+
for (let i = 0; i < b.length; i++) {
|
|
598
|
+
const owner = b[i].parentNode;
|
|
599
|
+
if (owner !== null && owner !== parent && owner.nodeType !== 11) {
|
|
600
|
+
b = b.slice();
|
|
601
|
+
b[i] = b[i].cloneNode(true);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
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;
|
|
605
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
606
|
+
if (a[aStart] === b[bStart]) {
|
|
607
|
+
aStart++;
|
|
608
|
+
bStart++;
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
|
|
612
|
+
aEnd--;
|
|
613
|
+
bEnd--;
|
|
614
|
+
}
|
|
615
|
+
if (aEnd === aStart) {
|
|
616
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
|
|
617
|
+
while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
|
|
618
|
+
} else if (bEnd === bStart) {
|
|
619
|
+
while (aStart < aEnd) {
|
|
620
|
+
if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
|
|
621
|
+
parent.removeChild(a[aStart]);
|
|
622
|
+
aStart++;
|
|
623
|
+
}
|
|
624
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
625
|
+
const node = a[--aEnd].nextSibling;
|
|
626
|
+
insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
|
|
627
|
+
insertBefore(parent, b[--bEnd], node);
|
|
628
|
+
a[aEnd] = a[aStart - 1];
|
|
629
|
+
} else {
|
|
630
|
+
if (!map) {
|
|
631
|
+
map = /* @__PURE__ */ new Map();
|
|
632
|
+
let i = bStart;
|
|
633
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
634
|
+
}
|
|
635
|
+
const index = map.get(a[aStart]);
|
|
636
|
+
if (index != null) {
|
|
637
|
+
if (bStart < index && index < bEnd) {
|
|
638
|
+
let i = aStart, sequence = 1;
|
|
639
|
+
while (++i < aEnd && i < bEnd) {
|
|
640
|
+
if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
|
|
641
|
+
sequence++;
|
|
642
|
+
}
|
|
643
|
+
if (sequence > index - bStart) {
|
|
644
|
+
const node = a[aStart];
|
|
645
|
+
while (bStart < index) insertBefore(parent, b[bStart++], node);
|
|
646
|
+
} else {
|
|
647
|
+
if (a[aStart].parentNode === parent) {
|
|
648
|
+
parent.replaceChild(b[bStart++], a[aStart++]);
|
|
649
|
+
} else {
|
|
650
|
+
insertBefore(parent, b[bStart++], after);
|
|
651
|
+
aStart++;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
} else {
|
|
655
|
+
aStart++;
|
|
656
|
+
}
|
|
657
|
+
} else {
|
|
658
|
+
if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
|
|
659
|
+
aStart++;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return b;
|
|
664
|
+
}
|
|
665
|
+
function cleanChildren(parent, current, marker) {
|
|
666
|
+
if (current) {
|
|
667
|
+
if (Array.isArray(current)) {
|
|
668
|
+
for (let i = 0; i < current.length; i++) {
|
|
669
|
+
if (current[i].parentNode === parent) parent.removeChild(current[i]);
|
|
670
|
+
}
|
|
671
|
+
} else if (current.parentNode === parent) {
|
|
672
|
+
parent.removeChild(current);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return null;
|
|
676
|
+
}
|
|
677
|
+
function insertBefore(parent, node, marker) {
|
|
678
|
+
if (hydration.active && node.parentNode === parent) return;
|
|
679
|
+
if (marker) {
|
|
680
|
+
if (marker.parentNode === parent) {
|
|
681
|
+
parent.insertBefore(node, marker);
|
|
682
|
+
} else {
|
|
683
|
+
parent.appendChild(node);
|
|
684
|
+
}
|
|
685
|
+
} else {
|
|
686
|
+
parent.appendChild(node);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
function handleRef(ref, element) {
|
|
690
|
+
if (!ref) return;
|
|
691
|
+
const held = ref[HOLE_TAG]?.name;
|
|
692
|
+
(0, import_signal7.reportReactiveDirective)(
|
|
693
|
+
element,
|
|
694
|
+
"ref",
|
|
695
|
+
held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
|
|
696
|
+
ref
|
|
697
|
+
);
|
|
698
|
+
if (isDomNode(ref)) {
|
|
699
|
+
const actualRef = element;
|
|
700
|
+
const actualElement = ref;
|
|
701
|
+
if (!actualRef) return;
|
|
702
|
+
if (typeof actualRef === "function") actualRef(actualElement);
|
|
703
|
+
else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
if (typeof ref === "function") ref(element);
|
|
707
|
+
else if (typeof ref === "object" && "current" in ref) ref.current = element;
|
|
708
|
+
}
|
|
709
|
+
function isPromise(v) {
|
|
710
|
+
return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
// src/lib/flow/portal.ts
|
|
714
|
+
function Portal(props) {
|
|
715
|
+
const getMount = () => {
|
|
716
|
+
if (!props.mount) return document.body;
|
|
717
|
+
return typeof props.mount === "function" ? props.mount() : props.mount;
|
|
718
|
+
};
|
|
719
|
+
let dispose;
|
|
720
|
+
let container;
|
|
721
|
+
(0, import_signal8.createRoot)((d) => {
|
|
722
|
+
dispose = d;
|
|
723
|
+
container = document.createElement("div");
|
|
724
|
+
container.style.display = "contents";
|
|
725
|
+
const target = getMount();
|
|
726
|
+
target.appendChild(container);
|
|
727
|
+
const inserted = insert(container, props.children);
|
|
728
|
+
if (inserted) {
|
|
729
|
+
handleRef(props.ref, container);
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
(0, import_signal8.onCleanup)(() => {
|
|
733
|
+
dispose();
|
|
734
|
+
container.remove();
|
|
735
|
+
});
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// src/lib/flow/client-only.ts
|
|
740
|
+
var import_signal9 = require("@fluixi/reactive/signal");
|
|
741
|
+
function ClientOnly(props) {
|
|
742
|
+
if (isServer()) return props.fallback ?? null;
|
|
743
|
+
const hydrating = hydration.active;
|
|
744
|
+
const [ready, setReady] = (0, import_signal9.createSignal)(!hydrating);
|
|
745
|
+
if (hydrating) queueMicrotask(() => setReady(true));
|
|
746
|
+
return (0, import_signal9.createMemo)(() => ready() ? props.children : props.fallback ?? null, void 0, {
|
|
747
|
+
name: "client-only"
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
var NoSsr = ClientOnly;
|
|
751
|
+
|
|
752
|
+
// src/lib/flow/error-boundary.ts
|
|
753
|
+
var import_signal10 = require("@fluixi/reactive/signal");
|
|
754
|
+
function ErrorBoundary(props) {
|
|
755
|
+
const [error, setError] = (0, import_signal10.createSignal)(null);
|
|
756
|
+
const reset = () => setError(null);
|
|
757
|
+
return (0, import_signal10.createMemo)(() => {
|
|
758
|
+
const err = error();
|
|
759
|
+
if (err !== null) {
|
|
760
|
+
return typeof props.fallback === "function" ? props.fallback(err, reset) : props.fallback;
|
|
761
|
+
}
|
|
762
|
+
try {
|
|
763
|
+
const content = typeof props.children === "function" ? props.children() : props.children;
|
|
764
|
+
return content;
|
|
765
|
+
} catch (e) {
|
|
766
|
+
setError(e);
|
|
767
|
+
return typeof props.fallback === "function" ? props.fallback(e, reset) : props.fallback;
|
|
768
|
+
}
|
|
769
|
+
}, void 0, { name: "ErrorBoundary" });
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// src/lib/flow/class-map.ts
|
|
773
|
+
var import_signal11 = require("@fluixi/reactive/signal");
|
|
774
|
+
function classMap(input) {
|
|
775
|
+
return (0, import_signal11.createMemo)(() => {
|
|
776
|
+
const map = typeof input === "function" ? input() : input;
|
|
777
|
+
const classes = [];
|
|
778
|
+
for (const [cls, cond] of Object.entries(map)) {
|
|
779
|
+
if (!cls) continue;
|
|
780
|
+
const active = typeof cond === "function" ? cond() : cond;
|
|
781
|
+
if (active) classes.push(cls);
|
|
782
|
+
}
|
|
783
|
+
return classes.join(" ");
|
|
784
|
+
}, void 0, { name: "ClassMap" });
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// src/lib/flow/style-map.ts
|
|
788
|
+
var import_signal12 = require("@fluixi/reactive/signal");
|
|
789
|
+
function toKebab(prop) {
|
|
790
|
+
return prop.startsWith("--") ? prop : prop.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
791
|
+
}
|
|
792
|
+
function styleMap(input) {
|
|
793
|
+
return (0, import_signal12.createMemo)(() => {
|
|
794
|
+
const map = typeof input === "function" ? input() : input;
|
|
795
|
+
const parts = [];
|
|
796
|
+
for (const [prop, val] of Object.entries(map)) {
|
|
797
|
+
if (!prop) continue;
|
|
798
|
+
const resolved = typeof val === "function" ? val() : val;
|
|
799
|
+
if (resolved != null) {
|
|
800
|
+
parts.push(`${toKebab(prop)}: ${resolved}`);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
return parts.join("; ");
|
|
804
|
+
}, void 0, { name: "StyleMap" });
|
|
805
|
+
}
|