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