@fluixi/dom 1.0.0-alpha.66 → 1.0.0-alpha.68
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.cjs +1 -1
- package/dist/cdn/dom.global.js +1 -1
- package/dist/cdn/dom.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/element/attributes.d.ts +6 -6
- package/dist/lib/element/attributes.d.ts.map +1 -1
- package/dist/lib/flow/client-only.cjs +1 -0
- package/dist/lib/flow/client-only.d.ts +44 -0
- package/dist/lib/flow/client-only.d.ts.map +1 -0
- package/dist/lib/flow/client-only.js +46 -0
- package/dist/lib/flow/client-only.mjs +1 -0
- package/dist/lib/flow/dynamic.cjs +1 -1
- package/dist/lib/flow/dynamic.d.ts.map +1 -1
- package/dist/lib/flow/dynamic.js +15 -2
- package/dist/lib/flow/dynamic.mjs +1 -1
- package/dist/lib/flow/index.cjs +1 -1
- package/dist/lib/flow/index.d.ts +2 -0
- package/dist/lib/flow/index.d.ts.map +1 -1
- package/dist/lib/flow/index.js +1 -0
- package/dist/lib/flow/index.mjs +1 -1
- package/dist/lib/flow/show.cjs +1 -1
- package/dist/lib/flow/show.d.ts.map +1 -1
- package/dist/lib/flow/show.js +37 -15
- package/dist/lib/flow/show.mjs +1 -1
- package/dist/lib/flow/switch.cjs +1 -1
- package/dist/lib/flow/switch.d.ts.map +1 -1
- package/dist/lib/flow/switch.js +31 -7
- package/dist/lib/flow/switch.mjs +1 -1
- package/dist/lib/index.cjs +1 -1
- package/dist/lib/index.mjs +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createMemo, createSignal } from '@fluixi/reactive/signal';
|
|
2
|
+
import { isServer } from '../dom/server/host.js';
|
|
3
|
+
import { hydration } from '../dom/hydration-state.js';
|
|
4
|
+
/**
|
|
5
|
+
* Renders `children` only in the browser.
|
|
6
|
+
*
|
|
7
|
+
* For subtrees that cannot render on the server — they read `window`,
|
|
8
|
+
* `localStorage`, a canvas, or produce time/locale-dependent output that would
|
|
9
|
+
* differ between the two passes and corrupt hydration.
|
|
10
|
+
*
|
|
11
|
+
* The swap is deferred to a microtask rather than done immediately, because
|
|
12
|
+
* rendering `children` mid-hydration would desync the hydration cursor from the
|
|
13
|
+
* server markup — the exact bug this component exists to prevent. `hydrate()`
|
|
14
|
+
* runs synchronously and clears its flag in a `finally`, so a microtask is the
|
|
15
|
+
* first moment the pass is guaranteed to be over.
|
|
16
|
+
*
|
|
17
|
+
* Outside hydration (a plain client render) there is nothing to match, so
|
|
18
|
+
* `children` render straight away and `fallback` is never shown.
|
|
19
|
+
*
|
|
20
|
+
* @example JSX
|
|
21
|
+
* <ClientOnly fallback={<Skeleton />}>
|
|
22
|
+
* <Chart data={points()} />
|
|
23
|
+
* </ClientOnly>
|
|
24
|
+
*
|
|
25
|
+
* @example html``
|
|
26
|
+
* ClientOnly({ fallback: html`<div class="skeleton"></div>`, children: () => html`<x-chart></x-chart>` })
|
|
27
|
+
*/
|
|
28
|
+
export function ClientOnly(props) {
|
|
29
|
+
if (isServer)
|
|
30
|
+
return props.fallback ?? null;
|
|
31
|
+
// Captured now, not read inside the memo: `hydration.active` is a global that
|
|
32
|
+
// flips when the pass ends, and this subtree's behaviour is decided by whether
|
|
33
|
+
// it was created during hydration.
|
|
34
|
+
const hydrating = hydration.active;
|
|
35
|
+
const [ready, setReady] = createSignal(!hydrating);
|
|
36
|
+
if (hydrating)
|
|
37
|
+
queueMicrotask(() => setReady(true));
|
|
38
|
+
return createMemo(() => (ready() ? props.children : (props.fallback ?? null)), undefined, {
|
|
39
|
+
name: 'client-only',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `NoSsr` is {@link ClientOnly} — the same component under the name used by
|
|
44
|
+
* other libraries, so the concept is findable either way.
|
|
45
|
+
*/
|
|
46
|
+
export const NoSsr = ClientOnly;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createMemo as a,createSignal as l}from"@fluixi/reactive/signal";var r=typeof document>"u";var n={active:!1,cursor:null,parents:[]};function u(e){if(r)return e.fallback??null;let t=n.active,[o,i]=l(!t);return t&&queueMicrotask(()=>i(!0)),a(()=>o()?e.children:e.fallback??null,void 0,{name:"client-only"})}var y=u;export{u as ClientOnly,y as NoSsr};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var T=(n,e)=>{for(var s in e)p(n,s,{get:e[s],enumerable:!0})},d=(n,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of y(e))!l.call(n,t)&&t!==s&&p(n,t,{get:()=>e[t],enumerable:!(c=u(e,t))||c.enumerable});return n};var m=n=>d(p({},"__esModule",{value:!0}),n);var g={};T(g,{Dynamic:()=>A});module.exports=m(g);var r=require("@fluixi/reactive/signal");function f(n){return typeof n=="function"?n:(()=>n)}function A(n){let e=f(n.component),{component:s,...c}=n,t=(0,r.getOwner)(),i=null,a;return(0,r.createMemo)(()=>{let o=e();return o!==a&&(i&&(0,r.disposeScope)(i),i=(0,r.createChildOwner)(t),a=o),o==null?null:typeof o=="string"?{tag:o,props:c}:(0,r.runWithOwner)(i,()=>o(c))})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/dynamic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"dynamic.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/dynamic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkF,MAAM,yBAAyB,CAAC;AAGnI,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC/E;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACvH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GACrB,QAAQ,CAAC,GAAG,CAAC,CA4Bf"}
|
package/dist/lib/flow/dynamic.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMemo } from '@fluixi/reactive/signal';
|
|
1
|
+
import { createMemo, createChildOwner, disposeScope, getOwner, runWithOwner } from '@fluixi/reactive/signal';
|
|
2
2
|
import { normalizeAccessor } from './utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* Renders a component dynamically — mirrors SolidJS `<Dynamic>`.
|
|
@@ -17,14 +17,27 @@ export function Dynamic(props) {
|
|
|
17
17
|
const getComponent = normalizeAccessor(props.component);
|
|
18
18
|
// Spread all props except `component` to the resolved component.
|
|
19
19
|
const { component: _c, ...rest } = props;
|
|
20
|
+
// The rendered component owns its scope, disposed when `component` changes, so
|
|
21
|
+
// what the outgoing one registered with `onCleanup` goes with it. Keyed on the
|
|
22
|
+
// component itself, not on every re-run: the memo also re-runs when a prop it
|
|
23
|
+
// reads changes, and disposing then would remount on every update.
|
|
24
|
+
const parentOwner = getOwner();
|
|
25
|
+
let scope = null;
|
|
26
|
+
let current;
|
|
20
27
|
return createMemo(() => {
|
|
21
28
|
const C = getComponent();
|
|
29
|
+
if (C !== current) {
|
|
30
|
+
if (scope)
|
|
31
|
+
disposeScope(scope);
|
|
32
|
+
scope = createChildOwner(parentOwner);
|
|
33
|
+
current = C;
|
|
34
|
+
}
|
|
22
35
|
if (C == null)
|
|
23
36
|
return null;
|
|
24
37
|
if (typeof C === 'string') {
|
|
25
38
|
// Intrinsic element — return a descriptor that the runtime can handle.
|
|
26
39
|
return { tag: C, props: rest };
|
|
27
40
|
}
|
|
28
|
-
return C(rest);
|
|
41
|
+
return runWithOwner(scope, () => C(rest));
|
|
29
42
|
});
|
|
30
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as
|
|
1
|
+
import{createMemo as p,createChildOwner as a,disposeScope as f,getOwner as u,runWithOwner as y}from"@fluixi/reactive/signal";function s(n){return typeof n=="function"?n:(()=>n)}function g(n){let c=s(n.component),{component:l,...t}=n,i=u(),r=null,o;return p(()=>{let e=c();return e!==o&&(r&&f(r),r=a(i),o=e),e==null?null:typeof e=="string"?{tag:e,props:t}:y(r,()=>e(t))})}export{g as Dynamic};
|
package/dist/lib/flow/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var de=(e,n)=>{for(var t in n)j(e,t,{get:n[t],enumerable:!0})},pe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of ue(n))!ye.call(e,a)&&a!==t&&j(e,a,{get:()=>n[a],enumerable:!(o=le(n,a))||o.enumerable});return e};var he=e=>pe(j({},"__esModule",{value:!0}),e);var Ne={};de(Ne,{Dynamic:()=>J,ErrorBoundary:()=>re,For:()=>K,Index:()=>B,Match:()=>z,Portal:()=>oe,Show:()=>I,Switch:()=>G,classMap:()=>se,indexArray:()=>w.indexArray,keyArray:()=>w.keyArray,mapArray:()=>w.mapArray,styleMap:()=>ae});module.exports=he(Ne);var N=require("@fluixi/reactive/signal");function H(e){return typeof e=="function"?e:(()=>e)}function x(e){return()=>{let n=e();return typeof n=="function"?n():n}}function U(e){return e!=null&&e!==!1}function O(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function I(e){let n=x(()=>e.when),t=(0,N.createMemo)(n,void 0),o=(0,N.createMemo)(t,void 0);return(0,N.createMemo)(()=>{if(o()){let s=e.children;return typeof s=="function"&&!O(s)?typeof t=="function"?(0,N.untrack)(()=>(0,N.untrack)(t)?s(t()):e.fallback):s(t):s}return e.fallback},void 0,{name:"show"})}var S=require("@fluixi/reactive/signal");var g={active:!1,cursor:null,parents:[]},me=null;function W(){return me}function F(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 P(e){if(!g.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&_(n)}function K(e){let n=x(()=>e.each),t=()=>e.fallback??null,o=(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 P(i),i};return e.by?(0,S.keyArray)(n,e.by,(a,s)=>o(a,s),{fallback:t}):(0,S.mapArray)(n,(a,s)=>o(a,s),{fallback:t})}var V=require("@fluixi/reactive/signal");function B(e){let n=x(()=>e.each);return(0,V.indexArray)(n,(t,o)=>{let a=e.children(t,o);return P(a),a},{fallback:()=>e.fallback??null})}var w=require("@fluixi/reactive/signal");var q=require("@fluixi/reactive/signal");var $=Symbol("match");function z(e){return{[$]:!0,when:x(()=>e.when),children:e.children}}function G(e){let n=Array.isArray(e.children)?e.children:[e.children];return(0,q.createMemo)(()=>{for(let t of n){let o=t,a=0;for(;typeof o=="function"&&!o[$]&&a++<10;)o=o();if(!o||typeof o!="object"||o[$]!==!0)continue;let s=o.when();if(U(s))return typeof o.children=="function"?o.children(s):o.children}return e.fallback??null})}var X=require("@fluixi/reactive/signal");function J(e){let n=H(e.component),{component:t,...o}=e;return(0,X.createMemo)(()=>{let a=n();return a==null?null:typeof a=="string"?{tag:a,props:o}:a(o)})}var R=require("@fluixi/reactive/signal");var p=require("@fluixi/reactive/signal");function A(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var b=require("@fluixi/reactive/signal");var Z=typeof document>"u";var Q=Symbol.for("fluixi.server-node"),Y=null;function ee(){if(!Y)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return Y}function v(e){return e!=null&&e[Q]===!0?!0:typeof Node<"u"&&e instanceof Node}function ne(e){return e!=null&&e[Q]===!0?e.nodeType===3:typeof Text<"u"&&e instanceof Text}function T(e,n=!1){if(Z)return ee().createText(e);if(g.active&&!n){let t=W()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var m=0,xe=200;function ge(e,n,t,o,a){let s=o,f=new Map;return(0,b.createRenderEffect)(()=>{let i;if(A(e)&&!(0,p.isSignal)(e)){if(!f.has(e)){m++;try{let r=e();f.set(e,r)}finally{m--}}for(i=f.get(e);typeof i=="function"&&(0,p.isSignal)(i);)i=i()}else for(i=e();typeof i=="function"&&(0,p.isSignal)(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(A(i)){if(!f.has(i)){let c=i;m++;try{let l=c();f.set(c,l)}finally{m--}}i=f.get(i)}else if((0,p.isSignal)(i))i=i();else if(i=i(),typeof i!="function"||!(0,p.isSignal)(i)&&!A(i))break}m++;try{s=C(n,i,t,s,f),a(s)}finally{m--}})}function D(e,n,t,o){if(m>xe)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=T("",!0),e.appendChild(t));let a=o??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)){m++;try{a=C(e,n,t,null)}finally{m--}return()=>a}let i=ge(f(n),e,t,a,r=>{a=r});return()=>(i?.(),a)}function C(e,n,t,o,a){if(n==null||typeof n=="boolean")return E(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return E(e,o,t);if(M(n)){let f=T("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),E(e,o.slice(1),t)):d(e,f,t):o?e.replaceChild(f,o):d(e,f,t),n.then(i=>{f.parentNode===e&&C(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(o)){if(o.length===0){let i=T(n);return d(e,i,t),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=E(e,o,t)}if(o&&ne(o))return o.data=n,o;let f=T(n);return o&&o.parentNode===e?e.replaceChild(f,o):F(e,f)||d(e,f,t),f}if(v(n))return F(e,n)?(_(n),n):Array.isArray(o)?(o.length===0?d(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),E(e,o.slice(1),t)):d(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):d(e,n,t)):d(e,n,t),n);if(Array.isArray(n)){let f=[],i=Array.isArray(o)?o:o?[o]:[],r=[];h(n,f,e,t,!0,a,r);let c=Te(e,i,f,t);for(let l of r){let u=D(e,l.sig,l.marker);(0,b.onCleanup)(()=>{E(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 C(e,r,t,o)}}}return E(e,o,t)}function h(e,n,t,o,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"&&!M(r)&&!(0,p.isSignal)(r)&&!A(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let c;for(A(r)&&!(0,p.isSignal)(r)?(s||(s=new Map),s.has(r)||s.set(r,r()),c=s.get(r)):c=r();typeof c=="function"&&!M(c)&&!(0,p.isSignal)(c)&&!A(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,p.isSignal)(c)){if(f){let u=T("",!0);n.push(u),f.push({marker:u,sig:c});continue}let l=c();for(;typeof l=="function"&&(0,p.isSignal)(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?h(l,n,t,o,a,s):h([l],n,t,o,a,s);continue}continue}Array.isArray(c)?h(c,n,t,o,a,s,f):h([c],n,t,o,a,s,f);continue}if(M(r)){let c=T("",!0);n.push(c),r.then(l=>{if(c.parentNode){let u=[];if(h([l],u,c.parentNode,void 0,!1,s),u.length>0){c.parentNode.replaceChild(u[0],c);for(let y=1;y<u.length;y++)c.parentNode?.insertBefore(u[y],u[y-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(r)){h(r,n,t,o,a,s,f);continue}if(v(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)?h(l,n,t,o,!1,s):h([l],n,t,o,!1,s);continue}}if(typeof r=="string"||typeof r=="number"){let c=String(r);if(c.trim()===""&&c!==" ")continue;n.push(T(c));continue}n.push(T(String(r)))}}}}function Te(e,n,t,o){for(let u=0;u<t.length;u++)t[u].parentNode!==null&&t[u].parentNode!==e&&(t=t.slice(),t[u]=t[u].cloneNode(!0));let a=t.length,s=n.length,f=a,i=0,r=0,c=s>0?n[s-1].nextSibling??void 0:o,l=null;for(;i<s||r<f;){if(n[i]===t[r]){i++,r++;continue}for(;s>i&&f>r&&n[s-1]===t[f-1];)s--,f--;if(s===i){let u=f<a?r?t[r-1].nextSibling??void 0:t[f-r]:c;for(;r<f;)d(e,t[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]===t[f-1]&&t[r]===n[s-1]){let u=n[--s].nextSibling;d(e,t[r++],n[i++].nextSibling),d(e,t[--f],u),n[s]=n[i-1]}else{if(!l){l=new Map;let y=r;for(;y<f;)l.set(t[y],y++)}let u=l.get(n[i]);if(u!=null)if(r<u&&u<f){let y=i,L=1;for(;++y<s&&y<f&&!(!l.has(n[y])||l.get(n[y])!==u+L);)L++;if(L>u-r){let ce=n[i];for(;r<u;)d(e,t[r++],ce)}else n[i].parentNode===e?e.replaceChild(t[r++],n[i++]):(d(e,t[r++],c),i++)}else i++;else n[i].parentNode===e&&e.removeChild(n[i]),i++}}return t}function E(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function d(e,n,t){g.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function te(e,n){if(e){if(v(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}}function M(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function oe(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return(0,R.createRoot)(a=>{t=a,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),D(o,e.children)&&te(e.ref,o)}),(0,R.onCleanup)(()=>{t(),o.remove()}),null}var k=require("@fluixi/reactive/signal");function re(e){let[n,t]=(0,k.createSignal)(null),o=()=>t(null);return(0,k.createMemo)(()=>{let a=n();if(a!==null)return typeof e.fallback=="function"?e.fallback(a,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(s){return t(s),typeof e.fallback=="function"?e.fallback(s,o):e.fallback}})}var ie=require("@fluixi/reactive/signal");function se(e){return(0,ie.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;(typeof a=="function"?a():a)&&t.push(o)}return t.join(" ")})}var fe=require("@fluixi/reactive/signal");function be(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function ae(e){return(0,fe.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;let s=typeof a=="function"?a():a;s!=null&&t.push(`${be(o)}: ${s}`)}return t.join("; ")})}
|
|
1
|
+
"use strict";var $=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var he=Object.prototype.hasOwnProperty;var me=(e,n)=>{for(var t in n)$(e,t,{get:n[t],enumerable:!0})},xe=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of pe(n))!he.call(e,a)&&a!==t&&$(e,a,{get:()=>n[a],enumerable:!(o=de(n,a))||o.enumerable});return e};var ge=e=>xe($({},"__esModule",{value:!0}),e);var we={};me(we,{ClientOnly:()=>I,Dynamic:()=>Q,ErrorBoundary:()=>fe,For:()=>G,Index:()=>J,Match:()=>Y,NoSsr:()=>se,Portal:()=>ie,Show:()=>q,Switch:()=>Z,classMap:()=>ce,indexArray:()=>P.indexArray,keyArray:()=>P.keyArray,mapArray:()=>P.mapArray,styleMap:()=>ue});module.exports=ge(we);var y=require("@fluixi/reactive/signal");function K(e){return typeof e=="function"?e:(()=>e)}function N(e){return()=>{let n=e();return typeof n=="function"?n():n}}function V(e){return e!=null&&e!==!1}function B(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function q(e){let n=N(()=>e.when),t=(0,y.createMemo)(n,void 0),o=(0,y.createMemo)(t,void 0),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=o();return i(r?"when":"fallback"),(0,y.runWithOwner)(s,()=>{if(r){let c=e.children;return typeof c=="function"&&!B(c)?typeof t=="function"?(0,y.untrack)(()=>(0,y.untrack)(t)?c(t()):e.fallback):c(t):c}return e.fallback});return e.fallback??null},void 0,{name:"show"})}var v=require("@fluixi/reactive/signal");var x={active:!1,cursor:null,parents:[]},be=null;function z(){return be}function D(e,n){return x.active&&n.parentNode===e}function H(e){let n=x.parents.lastIndexOf(e);n!==-1&&(x.parents.length=n),x.cursor=e.nextSibling}function C(e){if(!x.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&H(n)}function G(e){let n=N(()=>e.each),t=()=>e.fallback??null,o=(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 C(i),i};return e.by?(0,v.keyArray)(n,e.by,(a,s)=>o(a,s),{fallback:t}):(0,v.mapArray)(n,(a,s)=>o(a,s),{fallback:t})}var X=require("@fluixi/reactive/signal");function J(e){let n=N(()=>e.each);return(0,X.indexArray)(n,(t,o)=>{let a=e.children(t,o);return C(a),a},{fallback:()=>e.fallback??null})}var P=require("@fluixi/reactive/signal");var h=require("@fluixi/reactive/signal");var U=Symbol("match");function Y(e){return{[U]:!0,when:N(()=>e.when),get children(){return e.children}}}function Z(e){let n=Array.isArray(e.children)?e.children:[e.children],t=(0,h.getOwner)(),o=null,a=-1,s=f=>{f!==a&&(o&&(0,h.disposeScope)(o),o=(0,h.createChildOwner)(t),a=f)};return(0,h.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(V(l))return s(f),(0,h.runWithOwner)(o,()=>typeof r.children=="function"?r.children(l):r.children)}return s(-2),(0,h.runWithOwner)(o,()=>e.fallback??null)})}var g=require("@fluixi/reactive/signal");function Q(e){let n=K(e.component),{component:t,...o}=e,a=(0,g.getOwner)(),s=null,f;return(0,g.createMemo)(()=>{let i=n();return i!==f&&(s&&(0,g.disposeScope)(s),s=(0,g.createChildOwner)(a),f=i),i==null?null:typeof i=="string"?{tag:i,props:o}:(0,g.runWithOwner)(s,()=>i(o))})}var L=require("@fluixi/reactive/signal");var m=require("@fluixi/reactive/signal");function w(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}var E=require("@fluixi/reactive/signal");var M=typeof document>"u";var ne=Symbol.for("fluixi.server-node"),ee=null;function te(){if(!ee)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return ee}function k(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}function A(e,n=!1){if(M)return te().createText(e);if(x.active&&!n){let t=z()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var T=0,Te=200;function Ne(e,n,t,o,a){let s=o,f=new Map;return(0,E.createRenderEffect)(()=>{let i;if(w(e)&&!(0,m.isSignal)(e)){if(!f.has(e)){T++;try{let r=e();f.set(e,r)}finally{T--}}for(i=f.get(e);typeof i=="function"&&(0,m.isSignal)(i);)i=i()}else for(i=e();typeof i=="function"&&(0,m.isSignal)(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(w(i)){if(!f.has(i)){let c=i;T++;try{let l=c();f.set(c,l)}finally{T--}}i=f.get(i)}else if((0,m.isSignal)(i))i=i();else if(i=i(),typeof i!="function"||!(0,m.isSignal)(i)&&!w(i))break}T++;try{s=O(n,i,t,s,f),a(s)}finally{T--}})}function W(e,n,t,o){if(T>Te)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=A("",!0),e.appendChild(t));let a=o??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)){T++;try{a=O(e,n,t,null)}finally{T--}return()=>a}let i=Ne(f(n),e,t,a,r=>{a=r});return()=>(i?.(),a)}function O(e,n,t,o,a){if(n==null||typeof n=="boolean")return S(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return S(e,o,t);if(R(n)){let f=A("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),S(e,o.slice(1),t)):p(e,f,t):o?e.replaceChild(f,o):p(e,f,t),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(o)){if(o.length===0){let i=A(n);return p(e,i,t),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=S(e,o,t)}if(o&&oe(o))return o.data=n,o;let f=A(n);return o&&o.parentNode===e?e.replaceChild(f,o):D(e,f)||p(e,f,t),f}if(k(n))return D(e,n)?(H(n),n):Array.isArray(o)?(o.length===0?p(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),S(e,o.slice(1),t)):p(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):p(e,n,t)):p(e,n,t),n);if(Array.isArray(n)){let f=[],i=Array.isArray(o)?o:o?[o]:[],r=[];b(n,f,e,t,!0,a,r);let c=Ae(e,i,f,t);for(let l of r){let u=W(e,l.sig,l.marker);(0,E.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,t,o)}}}return S(e,o,t)}function b(e,n,t,o,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,m.isSignal)(r)&&!w(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let c;for(w(r)&&!(0,m.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,m.isSignal)(c)&&!w(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,m.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,m.isSignal)(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?b(l,n,t,o,a,s):b([l],n,t,o,a,s);continue}continue}Array.isArray(c)?b(c,n,t,o,a,s,f):b([c],n,t,o,a,s,f);continue}if(R(r)){let c=A("",!0);n.push(c),r.then(l=>{if(c.parentNode){let u=[];if(b([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)){b(r,n,t,o,a,s,f);continue}if(k(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)?b(l,n,t,o,!1,s):b([l],n,t,o,!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 Ae(e,n,t,o){for(let u=0;u<t.length;u++)t[u].parentNode!==null&&t[u].parentNode!==e&&(t=t.slice(),t[u]=t[u].cloneNode(!0));let a=t.length,s=n.length,f=a,i=0,r=0,c=s>0?n[s-1].nextSibling??void 0:o,l=null;for(;i<s||r<f;){if(n[i]===t[r]){i++,r++;continue}for(;s>i&&f>r&&n[s-1]===t[f-1];)s--,f--;if(s===i){let u=f<a?r?t[r-1].nextSibling??void 0:t[f-r]:c;for(;r<f;)p(e,t[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]===t[f-1]&&t[r]===n[s-1]){let u=n[--s].nextSibling;p(e,t[r++],n[i++].nextSibling),p(e,t[--f],u),n[s]=n[i-1]}else{if(!l){l=new Map;let d=r;for(;d<f;)l.set(t[d],d++)}let u=l.get(n[i]);if(u!=null)if(r<u&&u<f){let d=i,_=1;for(;++d<s&&d<f&&!(!l.has(n[d])||l.get(n[d])!==u+_);)_++;if(_>u-r){let ye=n[i];for(;r<u;)p(e,t[r++],ye)}else n[i].parentNode===e?e.replaceChild(t[r++],n[i++]):(p(e,t[r++],c),i++)}else i++;else n[i].parentNode===e&&e.removeChild(n[i]),i++}}return t}function S(e,n,t){if(n)if(Array.isArray(n))for(let o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function p(e,n,t){x.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function re(e,n){if(e){if(k(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);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,t,o;return(0,L.createRoot)(a=>{t=a,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),W(o,e.children)&&re(e.ref,o)}),(0,L.onCleanup)(()=>{t(),o.remove()}),null}var j=require("@fluixi/reactive/signal");function I(e){if(M)return e.fallback??null;let n=x.active,[t,o]=(0,j.createSignal)(!n);return n&&queueMicrotask(()=>o(!0)),(0,j.createMemo)(()=>t()?e.children:e.fallback??null,void 0,{name:"client-only"})}var se=I;var F=require("@fluixi/reactive/signal");function fe(e){let[n,t]=(0,F.createSignal)(null),o=()=>t(null);return(0,F.createMemo)(()=>{let a=n();if(a!==null)return typeof e.fallback=="function"?e.fallback(a,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(s){return t(s),typeof e.fallback=="function"?e.fallback(s,o):e.fallback}})}var ae=require("@fluixi/reactive/signal");function ce(e){return(0,ae.createMemo)(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;(typeof a=="function"?a():a)&&t.push(o)}return t.join(" ")})}var le=require("@fluixi/reactive/signal");function Ee(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,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;let s=typeof a=="function"?a():a;s!=null&&t.push(`${Ee(o)}: ${s}`)}return t.join("; ")})}
|
package/dist/lib/flow/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export { Dynamic } from './dynamic.js';
|
|
|
11
11
|
export type { DynamicProps } from './dynamic.js';
|
|
12
12
|
export { Portal } from './portal.js';
|
|
13
13
|
export type { PortalProps } from './portal.js';
|
|
14
|
+
export { ClientOnly, NoSsr } from './client-only.js';
|
|
15
|
+
export type { ClientOnlyProps, NoSsrProps } from './client-only.js';
|
|
14
16
|
export { ErrorBoundary } from './error-boundary.js';
|
|
15
17
|
export type { ErrorBoundaryProps } from './error-boundary.js';
|
|
16
18
|
export { classMap } from './class-map.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/lib/flow/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { mapArray, keyArray, indexArray } from '@fluixi/reactive/signal';
|
|
|
6
6
|
export { Switch, Match } from './switch.js';
|
|
7
7
|
export { Dynamic } from './dynamic.js';
|
|
8
8
|
export { Portal } from './portal.js';
|
|
9
|
+
export { ClientOnly, NoSsr } from './client-only.js';
|
|
9
10
|
export { ErrorBoundary } from './error-boundary.js';
|
|
10
11
|
export { classMap } from './class-map.js';
|
|
11
12
|
export { styleMap } from './style-map.js';
|
package/dist/lib/flow/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as v,untrack as _}from"@fluixi/reactive/signal";function L(e){return typeof e=="function"?e:(()=>e)}function x(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 V(e){let n=x(()=>e.when),t=v(n,void 0),o=v(t,void 0);return v(()=>{if(o()){let s=e.children;return typeof s=="function"&&!F(s)?typeof t=="function"?_(()=>_(t)?s(t()):e.fallback):s(t):s}return e.fallback},void 0,{name:"show"})}import{mapArray as q,keyArray as z}from"@fluixi/reactive/signal";var g={active:!1,cursor:null,parents:[]},B=null;function $(){return B}function M(e,n){return g.active&&n.parentNode===e}function C(e){let n=g.parents.lastIndexOf(e);n!==-1&&(g.parents.length=n),g.cursor=e.nextSibling}function A(e){if(!g.active||e==null)return;let n=Array.isArray(e)?e[e.length-1]:e;n&&typeof n.nodeType=="number"&&C(n)}function G(e){let n=x(()=>e.each),t=()=>e.fallback??null,o=(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 A(i),i};return e.by?z(n,e.by,(a,s)=>o(a,s),{fallback:t}):q(n,(a,s)=>o(a,s),{fallback:t})}import{indexArray as X}from"@fluixi/reactive/signal";function J(e){let n=x(()=>e.each);return X(n,(t,o)=>{let a=e.children(t,o);return A(a),a},{fallback:()=>e.fallback??null})}import{mapArray as wn,keyArray as Pn,indexArray as Sn}from"@fluixi/reactive/signal";import{createMemo as Y}from"@fluixi/reactive/signal";var R=Symbol("match");function Z(e){return{[R]:!0,when:x(()=>e.when),children:e.children}}function Q(e){let n=Array.isArray(e.children)?e.children:[e.children];return Y(()=>{for(let t of n){let o=t,a=0;for(;typeof o=="function"&&!o[R]&&a++<10;)o=o();if(!o||typeof o!="object"||o[R]!==!0)continue;let s=o.when();if(j(s))return typeof o.children=="function"?o.children(s):o.children}return e.fallback??null})}import{createMemo as ee}from"@fluixi/reactive/signal";function ne(e){let n=L(e.component),{component:t,...o}=e;return ee(()=>{let a=n();return a==null?null:typeof a=="string"?{tag:a,props:o}:a(o)})}import{createRoot as fe,onCleanup as ae}from"@fluixi/reactive/signal";import{isSignal as p}from"@fluixi/reactive/signal";function b(e){return typeof e=="function"&&e[Symbol.for("fluixi-component")]===!0}import{batch as Je,createEffect as Ye,createRenderEffect as te,createRoot as Ze,onCleanup as oe,readChildren as Qe}from"@fluixi/reactive/signal";var H=typeof document>"u";var U=Symbol.for("fluixi.server-node"),D=null;function O(){if(!D)throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");return D}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 T(e,n=!1){if(H)return O().createText(e);if(g.active&&!n){let t=$()?.hydrateText(e);if(t)return t}return document.createTextNode(e)}var m=0,re=200;function ie(e,n,t,o,a){let s=o,f=new Map;return te(()=>{let i;if(b(e)&&!p(e)){if(!f.has(e)){m++;try{let r=e();f.set(e,r)}finally{m--}}for(i=f.get(e);typeof i=="function"&&p(i);)i=i()}else for(i=e();typeof i=="function"&&p(i);)i=i();{let r=0;for(;typeof i=="function"&&r++<50;)if(b(i)){if(!f.has(i)){let c=i;m++;try{let l=c();f.set(c,l)}finally{m--}}i=f.get(i)}else if(p(i))i=i();else if(i=i(),typeof i!="function"||!p(i)&&!b(i))break}m++;try{s=P(n,i,t,s,f),a(s)}finally{m--}})}function k(e,n,t,o){if(m>re)return console.error("[insert] Exceeded max call depth — possible infinite loop."),()=>null;t!==void 0&&!t&&(t=T("",!0),e.appendChild(t));let a=o??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)){m++;try{a=P(e,n,t,null)}finally{m--}return()=>a}let i=ie(f(n),e,t,a,r=>{a=r});return()=>(i?.(),a)}function P(e,n,t,o,a){if(n==null||typeof n=="boolean")return N(e,o,t);if(typeof n=="function")for(;typeof n=="function";)n=n();if(n==null||typeof n=="boolean")return N(e,o,t);if(w(n)){let f=T("",!0);return Array.isArray(o)?o.length>0?(e.replaceChild(f,o[0]),N(e,o.slice(1),t)):d(e,f,t):o?e.replaceChild(f,o):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(o)){if(o.length===0){let i=T(n);return d(e,i,t),i}if(o.length===1&&o[0].nodeType===3)return o[0].data=n,o;o=N(e,o,t)}if(o&&I(o))return o.data=n,o;let f=T(n);return o&&o.parentNode===e?e.replaceChild(f,o):M(e,f)||d(e,f,t),f}if(E(n))return M(e,n)?(C(n),n):Array.isArray(o)?(o.length===0?d(e,n,t):o[0].parentNode===e?(e.replaceChild(n,o[0]),N(e,o.slice(1),t)):d(e,n,t),n):(o?o!==n&&(o.parentNode===e?e.replaceChild(n,o):d(e,n,t)):d(e,n,t),n);if(Array.isArray(n)){let f=[],i=Array.isArray(o)?o:o?[o]:[],r=[];h(n,f,e,t,!0,a,r);let c=se(e,i,f,t);for(let l of r){let u=k(e,l.sig,l.marker);oe(()=>{N(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 P(e,r,t,o)}}}return N(e,o,t)}function h(e,n,t,o,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"&&!w(r)&&!p(r)&&!b(r)&&(r=r(),!(r==null||typeof r=="boolean")););if(!(r==null||typeof r=="boolean")){if(typeof r=="function"){let c;for(b(r)&&!p(r)?(s||(s=new Map),s.has(r)||s.set(r,r()),c=s.get(r)):c=r();typeof c=="function"&&!w(c)&&!p(c)&&!b(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(p(c)){if(f){let u=T("",!0);n.push(u),f.push({marker:u,sig:c});continue}let l=c();for(;typeof l=="function"&&p(l);)l=l();if(l==null||typeof l=="boolean")continue;Array.isArray(l)?h(l,n,t,o,a,s):h([l],n,t,o,a,s);continue}continue}Array.isArray(c)?h(c,n,t,o,a,s,f):h([c],n,t,o,a,s,f);continue}if(w(r)){let c=T("",!0);n.push(c),r.then(l=>{if(c.parentNode){let u=[];if(h([l],u,c.parentNode,void 0,!1,s),u.length>0){c.parentNode.replaceChild(u[0],c);for(let y=1;y<u.length;y++)c.parentNode?.insertBefore(u[y],u[y-1].nextSibling)}}}).catch(l=>console.error("Error resolving promise in array:",l));continue}if(Array.isArray(r)){h(r,n,t,o,a,s,f);continue}if(E(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)?h(l,n,t,o,!1,s):h([l],n,t,o,!1,s);continue}}if(typeof r=="string"||typeof r=="number"){let c=String(r);if(c.trim()===""&&c!==" ")continue;n.push(T(c));continue}n.push(T(String(r)))}}}}function se(e,n,t,o){for(let u=0;u<t.length;u++)t[u].parentNode!==null&&t[u].parentNode!==e&&(t=t.slice(),t[u]=t[u].cloneNode(!0));let a=t.length,s=n.length,f=a,i=0,r=0,c=s>0?n[s-1].nextSibling??void 0:o,l=null;for(;i<s||r<f;){if(n[i]===t[r]){i++,r++;continue}for(;s>i&&f>r&&n[s-1]===t[f-1];)s--,f--;if(s===i){let u=f<a?r?t[r-1].nextSibling??void 0:t[f-r]:c;for(;r<f;)d(e,t[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]===t[f-1]&&t[r]===n[s-1]){let u=n[--s].nextSibling;d(e,t[r++],n[i++].nextSibling),d(e,t[--f],u),n[s]=n[i-1]}else{if(!l){l=new Map;let y=r;for(;y<f;)l.set(t[y],y++)}let u=l.get(n[i]);if(u!=null)if(r<u&&u<f){let y=i,S=1;for(;++y<s&&y<f&&!(!l.has(n[y])||l.get(n[y])!==u+S);)S++;if(S>u-r){let K=n[i];for(;r<u;)d(e,t[r++],K)}else n[i].parentNode===e?e.replaceChild(t[r++],n[i++]):(d(e,t[r++],c),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 o=0;o<n.length;o++)n[o].parentNode===e&&e.removeChild(n[o]);else n.parentNode===e&&e.removeChild(n);return null}function d(e,n,t){g.active&&n.parentNode===e||(t&&t.parentNode===e?e.insertBefore(n,t):e.appendChild(n))}function W(e,n){if(e){if(E(e)){let t=n,o=e;if(!t)return;typeof t=="function"?t(o):typeof t=="object"&&"current"in t&&(t.current=o);return}typeof e=="function"?e(n):typeof e=="object"&&"current"in e&&(e.current=n)}}function w(e){return e!=null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"||e instanceof Promise}function ce(e){let n=()=>e.mount?typeof e.mount=="function"?e.mount():e.mount:document.body,t,o;return fe(a=>{t=a,o=document.createElement("div"),o.style.display="contents",n().appendChild(o),k(o,e.children)&&W(e.ref,o)}),ae(()=>{t(),o.remove()}),null}import{createMemo as le,createSignal as ue}from"@fluixi/reactive/signal";function ye(e){let[n,t]=ue(null),o=()=>t(null);return le(()=>{let a=n();if(a!==null)return typeof e.fallback=="function"?e.fallback(a,o):e.fallback;try{return typeof e.children=="function"?e.children():e.children}catch(s){return t(s),typeof e.fallback=="function"?e.fallback(s,o):e.fallback}})}import{createMemo as de}from"@fluixi/reactive/signal";function pe(e){return de(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;(typeof a=="function"?a():a)&&t.push(o)}return t.join(" ")})}import{createMemo as he}from"@fluixi/reactive/signal";function me(e){return e.startsWith("--")?e:e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`)}function xe(e){return he(()=>{let n=typeof e=="function"?e():e,t=[];for(let[o,a]of Object.entries(n)){if(!o)continue;let s=typeof a=="function"?a():a;s!=null&&t.push(`${me(o)}: ${s}`)}return t.join("; ")})}export{ne as Dynamic,ye as ErrorBoundary,G as For,J as Index,Z as Match,ce as Portal,V as Show,Q as Switch,pe as classMap,Sn as indexArray,Pn as keyArray,wn as mapArray,xe as styleMap};
|
|
1
|
+
import{createChildOwner as q,createMemo as v,disposeScope as z,getOwner as G,runWithOwner as X,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=v(n,void 0),r=v(t,void 0),c=G(),s=null,f=null,i=o=>{o!==f&&(s&&z(s),s=q(c),f=o)};return v(()=>{let o=r();return i(o?"when":"fallback"),X(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 Vn,keyArray as Bn,indexArray as qn}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 dn,createEffect as pn,createRenderEffect as he,createRoot as hn,onCleanup as me,readChildren as mn}from"@fluixi/reactive/signal";var E=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 w(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(E)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,null)}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(w(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(w(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++)t[u].parentNode!==null&&t[u].parentNode!==e&&(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,C=1;for(;++y<s&&y<f&&!(!l.has(n[y])||l.get(n[y])!==u+C);)C++;if(C>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(w(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 Ee,createSignal as we}from"@fluixi/reactive/signal";function V(e){if(E)return e.fallback??null;let n=p.active,[t,r]=we(!n);return n&&queueMicrotask(()=>r(!0)),Ee(()=>t()?e.children:e.fallback??null,void 0,{name:"client-only"})}var Se=V;import{createMemo as Pe,createSignal as Ce}from"@fluixi/reactive/signal";function ve(e){let[n,t]=Ce(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,ve 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,qn as indexArray,Bn as keyArray,Vn as mapArray,Le as styleMap};
|
package/dist/lib/flow/show.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var w=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},m=(e,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of h(n))!p.call(e,o)&&o!==t&&l(e,o,{get:()=>n[o],enumerable:!(a=y(n,o))||a.enumerable});return e};var A=e=>m(l({},"__esModule",{value:!0}),e);var k={};w(k,{Show:()=>b});module.exports=A(k);var r=require("@fluixi/reactive/signal");function u(e){return()=>{let n=e();return typeof n=="function"?n():n}}function T(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function b(e){let n=u(()=>e.when),t=(0,r.createMemo)(n,void 0),a=(0,r.createMemo)(t,void 0),o=(0,r.getOwner)(),c=null,f=null,d=i=>{i!==f&&(c&&(0,r.disposeScope)(c),c=(0,r.createChildOwner)(o),f=i)};return(0,r.createMemo)(()=>{let i=a();return d(i?"when":"fallback"),(0,r.runWithOwner)(c,()=>{if(i){let s=e.children;return typeof s=="function"&&!T(s)?typeof t=="function"?(0,r.untrack)(()=>(0,r.untrack)(t)?s(t()):e.fallback):s(t):s}return e.fallback});return e.fallback??null},void 0,{name:"show"})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/show.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/show.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,SAAS,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAGtG,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG;IACnC,yDAAyD;IACzD,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC;IACjD,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf;;;;;;OAMG;IACH,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;;;;;;;;;;;GAYG;AAcH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAgGhD"}
|
package/dist/lib/flow/show.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMemo, untrack } from '@fluixi/reactive/signal';
|
|
1
|
+
import { createChildOwner, createMemo, disposeScope, getOwner, runWithOwner, untrack, } from '@fluixi/reactive/signal';
|
|
2
2
|
import { resolveReactiveProp, isLitResult } from './utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* Conditionally renders content based on a reactive condition.
|
|
@@ -33,6 +33,25 @@ export function Show(props) {
|
|
|
33
33
|
// const {when} = props
|
|
34
34
|
const value = createMemo(when, undefined);
|
|
35
35
|
const cond = createMemo(value, undefined);
|
|
36
|
+
// Each branch renders in its own scope so that leaving it tears down whatever
|
|
37
|
+
// it registered — an event listener, an observer, a timer. Without this the
|
|
38
|
+
// branch's `onCleanup`s land on the enclosing owner and only run when the
|
|
39
|
+
// whole tree dies, so a closed <Show> kept listening and reacting.
|
|
40
|
+
//
|
|
41
|
+
// Keyed on which branch is showing, NOT on every re-run: the memo also re-runs
|
|
42
|
+
// when the value changes within the same branch, and disposing then would
|
|
43
|
+
// throw away DOM the runtime deliberately reuses.
|
|
44
|
+
const parentOwner = getOwner();
|
|
45
|
+
let branchScope = null;
|
|
46
|
+
let shown = null;
|
|
47
|
+
const enterBranch = (next) => {
|
|
48
|
+
if (next === shown)
|
|
49
|
+
return;
|
|
50
|
+
if (branchScope)
|
|
51
|
+
disposeScope(branchScope);
|
|
52
|
+
branchScope = createChildOwner(parentOwner);
|
|
53
|
+
shown = next;
|
|
54
|
+
};
|
|
36
55
|
return createMemo(() => {
|
|
37
56
|
// if (isResource(when)) {
|
|
38
57
|
// if (when.loading) {
|
|
@@ -41,22 +60,25 @@ export function Show(props) {
|
|
|
41
60
|
// }
|
|
42
61
|
// const value = when();
|
|
43
62
|
const evaluate = cond();
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
enterBranch(evaluate ? 'when' : 'fallback');
|
|
64
|
+
return runWithOwner(branchScope, () => {
|
|
65
|
+
if (evaluate) {
|
|
66
|
+
let children = props.children;
|
|
67
|
+
if (typeof children === 'function' && !isLitResult(children)) {
|
|
68
|
+
if (typeof value === 'function') {
|
|
69
|
+
// value = (value as any)() as any;
|
|
70
|
+
return untrack(() => {
|
|
71
|
+
if (!untrack(value))
|
|
72
|
+
return props.fallback;
|
|
73
|
+
return children(value());
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return children(value);
|
|
54
77
|
}
|
|
55
|
-
return children
|
|
78
|
+
return children;
|
|
56
79
|
}
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
return props.fallback;
|
|
80
|
+
return props.fallback;
|
|
81
|
+
});
|
|
60
82
|
// if (isTruthy(value)) {
|
|
61
83
|
// let children = props.children;
|
|
62
84
|
// // handle children on jsx
|
package/dist/lib/flow/show.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as
|
|
1
|
+
import{createChildOwner as y,createMemo as s,disposeScope as h,getOwner as p,runWithOwner as w,untrack as f}from"@fluixi/reactive/signal";function c(e){return()=>{let n=e();return typeof n=="function"?n():n}}function l(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function O(e){let n=c(()=>e.when),r=s(n,void 0),u=s(r,void 0),T=p(),i=null,a=null,d=t=>{t!==a&&(i&&h(i),i=y(T),a=t)};return s(()=>{let t=u();return d(t?"when":"fallback"),w(i,()=>{if(t){let o=e.children;return typeof o=="function"&&!l(o)?typeof r=="function"?f(()=>f(r)?o(r()):e.fallback):o(r):o}return e.fallback});return e.fallback??null},void 0,{name:"show"})}export{O as Show};
|
package/dist/lib/flow/switch.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var w=(e,n)=>{for(var l in n)s(e,l,{get:n[l],enumerable:!0})},b=(e,n,l,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of p(n))!A.call(e,o)&&o!==l&&s(e,o,{get:()=>n[o],enumerable:!(c=y(n,o))||c.enumerable});return e};var M=e=>b(s({},"__esModule",{value:!0}),e);var x={};w(x,{Match:()=>m,Switch:()=>N});module.exports=M(x);var t=require("@fluixi/reactive/signal");function h(e){return()=>{let n=e();return typeof n=="function"?n():n}}function d(e){return e!=null&&e!==!1}var a=Symbol("match");function m(e){return{[a]:!0,when:h(()=>e.when),get children(){return e.children}}}function N(e){let n=Array.isArray(e.children)?e.children:[e.children],l=(0,t.getOwner)(),c=null,o=-1,f=i=>{i!==o&&(c&&(0,t.disposeScope)(c),c=(0,t.createChildOwner)(l),o=i)};return(0,t.createMemo)(()=>{for(let i=0;i<n.length;i+=1){let r=n[i],T=0;for(;typeof r=="function"&&!r[a]&&T++<10;)r=r();if(!r||typeof r!="object"||r[a]!==!0)continue;let u=r.when();if(d(u))return f(i),(0,t.runWithOwner)(c,()=>typeof r.children=="function"?r.children(u):r.children)}return f(-2),(0,t.runWithOwner)(c,()=>e.fallback??null)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/lib/flow/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkF,MAAM,yBAAyB,CAAC;AAInI,QAAA,MAAM,YAAY,eAAkB,CAAC;AAErC,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,4CAA4C;IAC5C,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC;IACjD;;;OAGG;IACH,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;CAChD;AAED,qEAAqE;AACrE,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,GAAG;IAChC,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC;IAC7C,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;CAChD;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAc3D;AAED,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf;;;;;OAKG;IACH,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CA6CxD"}
|
package/dist/lib/flow/switch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMemo } from '@fluixi/reactive/signal';
|
|
1
|
+
import { createMemo, createChildOwner, disposeScope, getOwner, runWithOwner } from '@fluixi/reactive/signal';
|
|
2
2
|
import { resolveReactiveProp, isTruthy } from './utils.js';
|
|
3
3
|
// Internal marker used by Switch to identify Match nodes.
|
|
4
4
|
const MATCH_MARKER = Symbol('match');
|
|
@@ -18,7 +18,13 @@ export function Match(props) {
|
|
|
18
18
|
// Lazy read through the prop getter — Switch calls `branch.when()` inside its memo,
|
|
19
19
|
// so `when={cond()}` reacts; `when={cond}` unwraps via resolveReactiveProp.
|
|
20
20
|
when: resolveReactiveProp(() => props.when),
|
|
21
|
-
children
|
|
21
|
+
// Lazy, like `when`. Read eagerly, every branch's children were built the
|
|
22
|
+
// moment the Match node was — before Switch had chosen one — so they were
|
|
23
|
+
// created outside the branch's scope (and non-matching branches were built
|
|
24
|
+
// for nothing). Switch reads this inside the selected branch's scope.
|
|
25
|
+
get children() {
|
|
26
|
+
return props.children;
|
|
27
|
+
},
|
|
22
28
|
};
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
@@ -44,8 +50,25 @@ export function Match(props) {
|
|
|
44
50
|
*/
|
|
45
51
|
export function Switch(props) {
|
|
46
52
|
const branches = Array.isArray(props.children) ? props.children : [props.children];
|
|
53
|
+
// Each branch renders in its own scope, disposed when a different branch takes
|
|
54
|
+
// over, so whatever it registered with `onCleanup` — a listener, an observer, a
|
|
55
|
+
// timer — goes with it. Keyed on which branch is showing, not on every re-run:
|
|
56
|
+
// the memo also re-runs when a `when` value changes within the same branch, and
|
|
57
|
+
// disposing then would throw away DOM the runtime deliberately reuses.
|
|
58
|
+
const parentOwner = getOwner();
|
|
59
|
+
let branchScope = null;
|
|
60
|
+
let shown = -1;
|
|
61
|
+
const enterBranch = (index) => {
|
|
62
|
+
if (index === shown)
|
|
63
|
+
return;
|
|
64
|
+
if (branchScope)
|
|
65
|
+
disposeScope(branchScope);
|
|
66
|
+
branchScope = createChildOwner(parentOwner);
|
|
67
|
+
shown = index;
|
|
68
|
+
};
|
|
47
69
|
return createMemo(() => {
|
|
48
|
-
for (
|
|
70
|
+
for (let i = 0; i < branches.length; i += 1) {
|
|
71
|
+
const raw = branches[i];
|
|
49
72
|
// The JSX compiler wraps <Match> in createMemo(createComponent(...)); unwrap
|
|
50
73
|
// those (and skip whitespace/other children) to reach the MatchNode. Direct
|
|
51
74
|
// Match({...}) results (lit syntax) pass through unchanged.
|
|
@@ -59,11 +82,12 @@ export function Switch(props) {
|
|
|
59
82
|
}
|
|
60
83
|
const value = branch.when();
|
|
61
84
|
if (isTruthy(value)) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
: branch.children;
|
|
85
|
+
enterBranch(i);
|
|
86
|
+
return runWithOwner(branchScope, () => typeof branch.children === 'function' ? branch.children(value) : branch.children);
|
|
65
87
|
}
|
|
66
88
|
}
|
|
67
|
-
|
|
89
|
+
// The fallback is a branch too, so it gets a scope of its own.
|
|
90
|
+
enterBranch(-2);
|
|
91
|
+
return runWithOwner(branchScope, () => props.fallback ?? null);
|
|
68
92
|
});
|
|
69
93
|
}
|
package/dist/lib/flow/switch.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createMemo as
|
|
1
|
+
import{createMemo as T,createChildOwner as y,disposeScope as p,getOwner as A,runWithOwner as u}from"@fluixi/reactive/signal";function a(e){return()=>{let t=e();return typeof t=="function"?t():t}}function f(e){return e!=null&&e!==!1}var o=Symbol("match");function x(e){return{[o]:!0,when:a(()=>e.when),get children(){return e.children}}}function R(e){let t=Array.isArray(e.children)?e.children:[e.children],h=A(),c=null,i=-1,l=r=>{r!==i&&(c&&p(c),c=y(h),i=r)};return T(()=>{for(let r=0;r<t.length;r+=1){let n=t[r],d=0;for(;typeof n=="function"&&!n[o]&&d++<10;)n=n();if(!n||typeof n!="object"||n[o]!==!0)continue;let s=n.when();if(f(s))return l(r),u(c,()=>typeof n.children=="function"?n.children(s):n.children)}return l(-2),u(c,()=>e.fallback??null)})}export{x as Match,R as Switch};
|