flexium 0.14.4 → 0.15.0

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.
Files changed (53) hide show
  1. package/dist/chunk-44IBO7Q7.js +2 -0
  2. package/dist/chunk-44IBO7Q7.js.map +1 -0
  3. package/dist/chunk-4DTHOZSY.mjs +2 -0
  4. package/dist/chunk-4DTHOZSY.mjs.map +1 -0
  5. package/dist/chunk-64L26RKO.mjs +2 -0
  6. package/dist/chunk-64L26RKO.mjs.map +1 -0
  7. package/dist/chunk-6AVHHBFG.js +2 -0
  8. package/dist/chunk-6AVHHBFG.js.map +1 -0
  9. package/dist/{chunk-PUXZJ7OV.js → chunk-BGXOI2CB.js} +2 -2
  10. package/dist/{chunk-PUXZJ7OV.js.map → chunk-BGXOI2CB.js.map} +1 -1
  11. package/dist/chunk-LEL6ICHK.mjs +2 -0
  12. package/dist/{chunk-TP5HUAIN.mjs.map → chunk-LEL6ICHK.mjs.map} +1 -1
  13. package/dist/core.d.cts +57 -2
  14. package/dist/core.d.ts +57 -2
  15. package/dist/core.js +1 -1
  16. package/dist/core.mjs +1 -1
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/dom.d.cts +5 -0
  19. package/dist/dom.d.ts +5 -0
  20. package/dist/dom.js +1 -1
  21. package/dist/dom.js.map +1 -1
  22. package/dist/dom.mjs +1 -1
  23. package/dist/dom.mjs.map +1 -1
  24. package/dist/index.d.cts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +1 -1
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/metafile-cjs.json +1 -1
  31. package/dist/metafile-esm.json +1 -1
  32. package/dist/render-5F2KRAJI.js +2 -0
  33. package/dist/{render-MJ2LCNSG.js.map → render-5F2KRAJI.js.map} +1 -1
  34. package/dist/render-ZDUF6JTQ.mjs +2 -0
  35. package/dist/{render-4HB53K66.mjs.map → render-ZDUF6JTQ.mjs.map} +1 -1
  36. package/dist/router.js +1 -1
  37. package/dist/router.mjs +1 -1
  38. package/dist/router.mjs.map +1 -1
  39. package/dist/server.js +1 -1
  40. package/dist/server.mjs +1 -1
  41. package/dist/server.mjs.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-3AKECLKA.mjs +0 -2
  44. package/dist/chunk-3AKECLKA.mjs.map +0 -1
  45. package/dist/chunk-ACYN2UKT.js +0 -2
  46. package/dist/chunk-ACYN2UKT.js.map +0 -1
  47. package/dist/chunk-E6Z7AI4J.js +0 -2
  48. package/dist/chunk-E6Z7AI4J.js.map +0 -1
  49. package/dist/chunk-MI76R42D.mjs +0 -2
  50. package/dist/chunk-MI76R42D.mjs.map +0 -1
  51. package/dist/chunk-TP5HUAIN.mjs +0 -2
  52. package/dist/render-4HB53K66.mjs +0 -2
  53. package/dist/render-MJ2LCNSG.js +0 -2
package/dist/core.d.ts CHANGED
@@ -1,3 +1,48 @@
1
+ /**
2
+ * Useable - Base class for reactive data sources that work with use()
3
+ *
4
+ * Extend this class to create custom data sources (Context, Stream, Shared, etc.)
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * class MySource<T> extends Useable<T> {
9
+ * getInitial() { return this.initialValue }
10
+ * subscribe(params, callback) {
11
+ * // setup subscription
12
+ * return () => { // cleanup }
13
+ * }
14
+ * }
15
+ *
16
+ * const source = new MySource(...)
17
+ * const [value] = use(source)
18
+ * ```
19
+ */
20
+ declare abstract class Useable<T, P = void> {
21
+ /**
22
+ * Unique identifier for this Useable type
23
+ * Used internally by use() for type checking
24
+ */
25
+ readonly _useableTag: true;
26
+ /**
27
+ * Get the initial/current value synchronously
28
+ * Called when use() first accesses this source
29
+ */
30
+ abstract getInitial(params?: P): T;
31
+ /**
32
+ * Subscribe to value changes
33
+ * Called by use() to receive updates
34
+ *
35
+ * @param params - Optional parameters for the subscription
36
+ * @param callback - Function called when value changes
37
+ * @returns Cleanup function to unsubscribe
38
+ */
39
+ abstract subscribe(params: P | undefined, callback: (value: T) => void): () => void;
40
+ }
41
+ /**
42
+ * Type guard to check if a value is a Useable instance
43
+ */
44
+ declare function isUseable(value: unknown): value is Useable<any, any>;
45
+
1
46
  /**
2
47
  * Context for passing data through the component tree
3
48
  *
@@ -19,7 +64,7 @@
19
64
  * }
20
65
  * ```
21
66
  */
22
- declare class Context<T> {
67
+ declare class Context<T> extends Useable<T> {
23
68
  readonly id: symbol;
24
69
  readonly defaultValue: T;
25
70
  readonly Provider: (props: {
@@ -27,6 +72,15 @@ declare class Context<T> {
27
72
  children: any;
28
73
  }) => any;
29
74
  constructor(defaultValue: T);
75
+ /**
76
+ * Get current context value or default
77
+ */
78
+ getInitial(): T;
79
+ /**
80
+ * Context doesn't have traditional subscriptions
81
+ * Reactivity is handled by component re-rendering
82
+ */
83
+ subscribe(_params: undefined, _callback: (value: T) => void): () => void;
30
84
  }
31
85
  declare function getContextValue<T>(ctx: Context<T>): T;
32
86
  declare function pushContext(id: symbol, value: any): any;
@@ -48,6 +102,7 @@ interface UseOptions {
48
102
  name?: string;
49
103
  }
50
104
  declare function use<T>(ctx: Context<T>): [T, undefined];
105
+ declare function use<T, P = void>(source: Useable<T, P>, params?: P): [T, undefined];
51
106
  declare function use<T, P = void>(fn: (ctx: UseContext<P>) => Promise<T>, depsOrOptions?: any[] | UseOptions, options?: UseOptions): [T | undefined, ResourceControl<P>];
52
107
  declare function use<T>(fn: (ctx: UseContext) => T, depsOrOptions?: any[] | UseOptions, options?: UseOptions): [T, ResourceControl];
53
108
  declare function use<T>(initialValue: T extends Function ? never : T, options?: UseOptions): [T, Setter<T>];
@@ -93,4 +148,4 @@ declare function useRef<T = undefined>(): RefObject<T | undefined>;
93
148
 
94
149
  declare function isReactive(value: unknown): boolean;
95
150
 
96
- export { Context, type ForwardedRef, type Ref, type RefCallback, type RefObject, type ResourceControl, type Setter, type UseContext, type UseOptions, getContextValue, isReactive, popContext, pushContext, sync, use, useRef };
151
+ export { Context, type ForwardedRef, type Ref, type RefCallback, type RefObject, type ResourceControl, type Setter, type UseContext, type UseOptions, Useable, getContextValue, isReactive, isUseable, popContext, pushContext, sync, use, useRef };
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkACYN2UKT_js=require('./chunk-ACYN2UKT.js'),chunk3CKIHQIE_js=require('./chunk-3CKIHQIE.js'),chunkE6Z7AI4J_js=require('./chunk-E6Z7AI4J.js');function s(t){return chunkE6Z7AI4J_js.b(()=>({current:t}))}Object.defineProperty(exports,"isReactive",{enumerable:true,get:function(){return chunkACYN2UKT_js.b}});Object.defineProperty(exports,"use",{enumerable:true,get:function(){return chunkACYN2UKT_js.c}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunk3CKIHQIE_js.e}});Object.defineProperty(exports,"Context",{enumerable:true,get:function(){return chunkE6Z7AI4J_js.c}});Object.defineProperty(exports,"getContextValue",{enumerable:true,get:function(){return chunkE6Z7AI4J_js.d}});Object.defineProperty(exports,"popContext",{enumerable:true,get:function(){return chunkE6Z7AI4J_js.f}});Object.defineProperty(exports,"pushContext",{enumerable:true,get:function(){return chunkE6Z7AI4J_js.e}});exports.useRef=s;//# sourceMappingURL=core.js.map
1
+ 'use strict';var chunk6AVHHBFG_js=require('./chunk-6AVHHBFG.js'),chunk3CKIHQIE_js=require('./chunk-3CKIHQIE.js'),chunk44IBO7Q7_js=require('./chunk-44IBO7Q7.js');function R(t){return chunk44IBO7Q7_js.b(()=>({current:t}))}Object.defineProperty(exports,"isReactive",{enumerable:true,get:function(){return chunk6AVHHBFG_js.b}});Object.defineProperty(exports,"use",{enumerable:true,get:function(){return chunk6AVHHBFG_js.c}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunk3CKIHQIE_js.e}});Object.defineProperty(exports,"Context",{enumerable:true,get:function(){return chunk44IBO7Q7_js.e}});Object.defineProperty(exports,"Useable",{enumerable:true,get:function(){return chunk44IBO7Q7_js.c}});Object.defineProperty(exports,"getContextValue",{enumerable:true,get:function(){return chunk44IBO7Q7_js.f}});Object.defineProperty(exports,"isUseable",{enumerable:true,get:function(){return chunk44IBO7Q7_js.d}});Object.defineProperty(exports,"popContext",{enumerable:true,get:function(){return chunk44IBO7Q7_js.h}});Object.defineProperty(exports,"pushContext",{enumerable:true,get:function(){return chunk44IBO7Q7_js.g}});exports.useRef=R;//# sourceMappingURL=core.js.map
2
2
  //# sourceMappingURL=core.js.map
package/dist/core.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export{b as isReactive,c as use}from'./chunk-3AKECLKA.mjs';export{e as sync}from'./chunk-NRPWBHKP.mjs';import {b}from'./chunk-MI76R42D.mjs';export{c as Context,d as getContextValue,f as popContext,e as pushContext}from'./chunk-MI76R42D.mjs';function s(t){return b(()=>({current:t}))}export{s as useRef};//# sourceMappingURL=core.mjs.map
1
+ export{b as isReactive,c as use}from'./chunk-4DTHOZSY.mjs';export{e as sync}from'./chunk-NRPWBHKP.mjs';import {b}from'./chunk-64L26RKO.mjs';export{e as Context,c as Useable,f as getContextValue,d as isUseable,h as popContext,g as pushContext}from'./chunk-64L26RKO.mjs';function R(t){return b(()=>({current:t}))}export{R as useRef};//# sourceMappingURL=core.mjs.map
2
2
  //# sourceMappingURL=core.mjs.map
package/dist/core.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/ref.ts"],"names":["useRef","initialValue","hook"],"mappings":"iPA2BO,SAASA,CAAAA,CAAUC,CAAAA,CAA4C,CACpE,OAAOC,CAAAA,CAAK,KAAO,CACjB,OAAA,CAASD,CACX,CAAA,CAAE,CACJ","file":"core.mjs","sourcesContent":["import { hook } from './hook'\nimport type { RefObject } from './types'\n\n/**\n * Creates a mutable ref object that persists across renders\n *\n * @example\n * ```tsx\n * function InputWithFocus() {\n * const inputRef = useRef<HTMLInputElement>()\n *\n * const focusInput = () => {\n * inputRef.current?.focus()\n * }\n *\n * return (\n * <div>\n * <input ref={inputRef} type=\"text\" />\n * <button onClick={focusInput}>Focus Input</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRef<T>(initialValue: T): RefObject<T>\nexport function useRef<T>(initialValue: T | null): RefObject<T | null>\nexport function useRef<T = undefined>(): RefObject<T | undefined>\nexport function useRef<T>(initialValue?: T): RefObject<T | undefined> {\n return hook(() => ({\n current: initialValue\n }))\n}\n"]}
1
+ {"version":3,"sources":["../src/core/ref.ts"],"names":["useRef","initialValue","hook"],"mappings":"6QA2BO,SAASA,CAAAA,CAAUC,CAAAA,CAA4C,CACpE,OAAOC,CAAAA,CAAK,KAAO,CACjB,OAAA,CAASD,CACX,CAAA,CAAE,CACJ","file":"core.mjs","sourcesContent":["import { hook } from './hook'\nimport type { RefObject } from './types'\n\n/**\n * Creates a mutable ref object that persists across renders\n *\n * @example\n * ```tsx\n * function InputWithFocus() {\n * const inputRef = useRef<HTMLInputElement>()\n *\n * const focusInput = () => {\n * inputRef.current?.focus()\n * }\n *\n * return (\n * <div>\n * <input ref={inputRef} type=\"text\" />\n * <button onClick={focusInput}>Focus Input</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRef<T>(initialValue: T): RefObject<T>\nexport function useRef<T>(initialValue: T | null): RefObject<T | null>\nexport function useRef<T = undefined>(): RefObject<T | undefined>\nexport function useRef<T>(initialValue?: T): RefObject<T | undefined> {\n return hook(() => ({\n current: initialValue\n }))\n}\n"]}
package/dist/dom.d.cts CHANGED
@@ -72,6 +72,11 @@ interface ErrorBoundaryProps {
72
72
  /**
73
73
  * Portal component that renders children into a different DOM node
74
74
  *
75
+ * @deprecated Use Portal from 'flexium-ui' instead:
76
+ * ```tsx
77
+ * import { Portal } from 'flexium-ui'
78
+ * ```
79
+ *
75
80
  * @example
76
81
  * ```tsx
77
82
  * function Modal({ isOpen, onClose, children }) {
package/dist/dom.d.ts CHANGED
@@ -72,6 +72,11 @@ interface ErrorBoundaryProps {
72
72
  /**
73
73
  * Portal component that renders children into a different DOM node
74
74
  *
75
+ * @deprecated Use Portal from 'flexium-ui' instead:
76
+ * ```tsx
77
+ * import { Portal } from 'flexium-ui'
78
+ * ```
79
+ *
75
80
  * @example
76
81
  * ```tsx
77
82
  * function Modal({ isOpen, onClose, children }) {
package/dist/dom.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkPUXZJ7OV_js=require('./chunk-PUXZJ7OV.js'),chunkACYN2UKT_js=require('./chunk-ACYN2UKT.js'),chunk3CKIHQIE_js=require('./chunk-3CKIHQIE.js'),chunkE6Z7AI4J_js=require('./chunk-E6Z7AI4J.js');function A(e,t,...o){return {type:e,props:t||{},children:o,key:t?.key}}var l=null,P=new WeakMap,h=null;function W(e,t,o={}){let{state:n,onHydrated:r,onMismatch:i}=o;l=t.firstChild;try{let s;typeof e=="function"&&!T(e)?s={type:e,props:{},children:[],key:void 0}:s=e,E(s,t),r?.();}catch(s){console.warn("[Flexium] Hydration mismatch, falling back to full render:",s),i?.(s),t.innerHTML="",import('./render-MJ2LCNSG.js').then(({render:p})=>{p(e,t);});}finally{l=null;}}function T(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function E(e,t){if(e==null||typeof e=="boolean")return F(),null;if(typeof e=="string"||typeof e=="number")return j(String(e));if(Array.isArray(e)){let o=[];for(let n of e){let r=E(n,t);r&&(Array.isArray(r)?o.push(...r):o.push(r));}return o}if(typeof e=="function")return M({type:e,props:{},children:[],key:void 0},t);if(typeof e=="object"&&T(e)){if(typeof e.type=="string")return R(e);if(typeof e.type=="function")return M(e,t)}return null}function F(){for(;l&&l.nodeType===Node.TEXT_NODE&&(!l.textContent||l.textContent.trim()==="");)l=l.nextSibling;}function j(e){F();let t=l;if(!t)return null;if(t.nodeType!==Node.TEXT_NODE){if(e.trim()==="")return null;throw new Error(`Hydration mismatch: expected text node "${e}", got ${t.nodeName}`)}return l=t.nextSibling,t}function R(e){F();let t=l,o=e.type;if(!t||t.nodeType!==Node.ELEMENT_NODE)throw new Error(`Hydration mismatch: expected element <${o}>, got ${t?.nodeName||"nothing"}`);if(t.tagName.toLowerCase()!==o.toLowerCase())throw new Error(`Hydration mismatch: expected <${o}>, got <${t.tagName.toLowerCase()}>`);if(e.props){for(let[n,r]of Object.entries(e.props))if(n==="ref")typeof r=="function"?r(t):r&&typeof r=="object"&&"current"in r&&(r.current=t);else if(n.startsWith("on")&&typeof r=="function"){let i=n.slice(2).toLowerCase();t.addEventListener(i,r),t.__eventHandlers||(t.__eventHandlers={}),t.__eventHandlers[i]=r;}}if(l=t.nextSibling,e.children&&e.children.length>0){let n=l;l=t.firstChild;for(let r of e.children)E(r,t);l=n;}return t}function M(e,t){let o=e.type,n={...e.props};e.children&&e.children.length>0&&(n.children=e.children.length===1?e.children[0]:e.children);let r=o._contextId,i=r!==void 0,s;i&&(s=chunkE6Z7AI4J_js.e(r,n.value)),P.has(t)||P.set(t,new Map);let p=P.get(t),C=e.key!==void 0,u;if(C)u=e.key;else {let y=0,f=o.name||"anonymous";p.forEach((N,x)=>{typeof x=="string"&&x.startsWith(`__auto_${f}_`)&&y++;}),u=`__auto_${f}_${y}`;}let a={hooks:[],hookIndex:0,nodes:[],parent:t,fnode:e,props:n,key:u,children:new Set,parentInstance:h||void 0};h&&h.children.add(a),p.set(u,a);let c=h;h=a;try{let y=chunkE6Z7AI4J_js.a(a,()=>o(n)),f=E(y,t);a.nodes=f?Array.isArray(f)?f:[f]:[];let N=!0,x=()=>{if(N){N=!1;return}let D=a.props;chunkE6Z7AI4J_js.a(a,()=>o(D));};return a.renderFn=x,chunk3CKIHQIE_js.b(x),a.nodes}finally{h=c,i&&chunkE6Z7AI4J_js.f(r,s);}}function _(e){let{target:t,children:o}=e,n=chunkE6Z7AI4J_js.b(()=>({container:null,mounted:false}));return chunkACYN2UKT_js.c(({onCleanup:r})=>{let i=null;if(typeof t=="string"?i=document.querySelector(t):t instanceof HTMLElement&&(i=t),!i){console.warn("[Flexium Portal] Target container not found:",t);return}let s=document.createElement("div");s.setAttribute("data-flexium-portal","true"),i.appendChild(s),n.container=s,n.mounted=true,chunkPUXZJ7OV_js.b(o,s),r(()=>{s.parentNode&&s.parentNode.removeChild(s),n.container=null,n.mounted=false;});},[t,o]),null}var K={register:()=>{},hasBoundary:false},v=new chunkE6Z7AI4J_js.c(K);function b(){let[e]=chunkACYN2UKT_js.c(v);return e}function z(e){let{fallback:t,children:o}=e,n=chunkE6Z7AI4J_js.b(()=>new Set),[,r]=chunkACYN2UKT_js.c(0),[i,s]=chunkACYN2UKT_js.c(false),C={register:a=>{n.has(a)||(n.add(a),r(c=>c+1),s(true),a.finally(()=>{n.delete(a),r(c=>{let y=c-1;return y===0&&s(false),y});}));},hasBoundary:true},u=i?t:o;return {type:v.Provider,props:{value:C},children:[u],key:void 0}}function V(e){let{fallback:t,onError:o,children:n,resetKey:r}=e,[i,s]=chunkACYN2UKT_js.c({error:null,info:null}),p=chunkE6Z7AI4J_js.b(()=>({current:r}));r!==p.current&&(p.current=r,i.error!==null&&s({error:null,info:null}));if(i.error)return typeof t=="function"?t(i.error,i.info):t;try{return n}finally{}}function $(e){let t=null,o=null,n=null,r=i=>{if(t)return t(i);if(n)throw n;let s=b();return o||(o=e().then(p=>{t=p.default;}).catch(p=>{n=p instanceof Error?p:new Error(String(p));})),s.hasBoundary&&s.register(o),null};return r._lazy=true,r._loader=e,r}Object.defineProperty(exports,"render",{enumerable:true,get:function(){return chunkPUXZJ7OV_js.b}});exports.ErrorBoundary=V;exports.Portal=_;exports.Suspense=z;exports.f=A;exports.hydrate=W;exports.lazy=$;//# sourceMappingURL=dom.js.map
1
+ 'use strict';var chunkBGXOI2CB_js=require('./chunk-BGXOI2CB.js'),chunk6AVHHBFG_js=require('./chunk-6AVHHBFG.js'),chunk3CKIHQIE_js=require('./chunk-3CKIHQIE.js'),chunk44IBO7Q7_js=require('./chunk-44IBO7Q7.js');function A(e,t,...o){return {type:e,props:t||{},children:o,key:t?.key}}var l=null,P=new WeakMap,h=null;function W(e,t,o={}){let{state:n,onHydrated:r,onMismatch:i}=o;l=t.firstChild;try{let s;typeof e=="function"&&!T(e)?s={type:e,props:{},children:[],key:void 0}:s=e,E(s,t),r?.();}catch(s){console.warn("[Flexium] Hydration mismatch, falling back to full render:",s),i?.(s),t.innerHTML="",import('./render-5F2KRAJI.js').then(({render:p})=>{p(e,t);});}finally{l=null;}}function T(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function E(e,t){if(e==null||typeof e=="boolean")return F(),null;if(typeof e=="string"||typeof e=="number")return j(String(e));if(Array.isArray(e)){let o=[];for(let n of e){let r=E(n,t);r&&(Array.isArray(r)?o.push(...r):o.push(r));}return o}if(typeof e=="function")return M({type:e,props:{},children:[],key:void 0},t);if(typeof e=="object"&&T(e)){if(typeof e.type=="string")return R(e);if(typeof e.type=="function")return M(e,t)}return null}function F(){for(;l&&l.nodeType===Node.TEXT_NODE&&(!l.textContent||l.textContent.trim()==="");)l=l.nextSibling;}function j(e){F();let t=l;if(!t)return null;if(t.nodeType!==Node.TEXT_NODE){if(e.trim()==="")return null;throw new Error(`Hydration mismatch: expected text node "${e}", got ${t.nodeName}`)}return l=t.nextSibling,t}function R(e){F();let t=l,o=e.type;if(!t||t.nodeType!==Node.ELEMENT_NODE)throw new Error(`Hydration mismatch: expected element <${o}>, got ${t?.nodeName||"nothing"}`);if(t.tagName.toLowerCase()!==o.toLowerCase())throw new Error(`Hydration mismatch: expected <${o}>, got <${t.tagName.toLowerCase()}>`);if(e.props){for(let[n,r]of Object.entries(e.props))if(n==="ref")typeof r=="function"?r(t):r&&typeof r=="object"&&"current"in r&&(r.current=t);else if(n.startsWith("on")&&typeof r=="function"){let i=n.slice(2).toLowerCase();t.addEventListener(i,r),t.__eventHandlers||(t.__eventHandlers={}),t.__eventHandlers[i]=r;}}if(l=t.nextSibling,e.children&&e.children.length>0){let n=l;l=t.firstChild;for(let r of e.children)E(r,t);l=n;}return t}function M(e,t){let o=e.type,n={...e.props};e.children&&e.children.length>0&&(n.children=e.children.length===1?e.children[0]:e.children);let r=o._contextId,i=r!==void 0,s;i&&(s=chunk44IBO7Q7_js.g(r,n.value)),P.has(t)||P.set(t,new Map);let p=P.get(t),C=e.key!==void 0,u;if(C)u=e.key;else {let y=0,f=o.name||"anonymous";p.forEach((N,x)=>{typeof x=="string"&&x.startsWith(`__auto_${f}_`)&&y++;}),u=`__auto_${f}_${y}`;}let a={hooks:[],hookIndex:0,nodes:[],parent:t,fnode:e,props:n,key:u,children:new Set,parentInstance:h||void 0};h&&h.children.add(a),p.set(u,a);let c=h;h=a;try{let y=chunk44IBO7Q7_js.a(a,()=>o(n)),f=E(y,t);a.nodes=f?Array.isArray(f)?f:[f]:[];let N=!0,x=()=>{if(N){N=!1;return}let D=a.props;chunk44IBO7Q7_js.a(a,()=>o(D));};return a.renderFn=x,chunk3CKIHQIE_js.b(x),a.nodes}finally{h=c,i&&chunk44IBO7Q7_js.h(r,s);}}function _(e){let{target:t,children:o}=e,n=chunk44IBO7Q7_js.b(()=>({container:null,mounted:false}));return chunk6AVHHBFG_js.c(({onCleanup:r})=>{let i=null;if(typeof t=="string"?i=document.querySelector(t):t instanceof HTMLElement&&(i=t),!i){console.warn("[Flexium Portal] Target container not found:",t);return}let s=document.createElement("div");s.setAttribute("data-flexium-portal","true"),i.appendChild(s),n.container=s,n.mounted=true,chunkBGXOI2CB_js.b(o,s),r(()=>{s.parentNode&&s.parentNode.removeChild(s),n.container=null,n.mounted=false;});},[t,o]),null}var K={register:()=>{},hasBoundary:false},v=new chunk44IBO7Q7_js.e(K);function b(){let[e]=chunk6AVHHBFG_js.c(v);return e}function z(e){let{fallback:t,children:o}=e,n=chunk44IBO7Q7_js.b(()=>new Set),[,r]=chunk6AVHHBFG_js.c(0),[i,s]=chunk6AVHHBFG_js.c(false),C={register:a=>{n.has(a)||(n.add(a),r(c=>c+1),s(true),a.finally(()=>{n.delete(a),r(c=>{let y=c-1;return y===0&&s(false),y});}));},hasBoundary:true},u=i?t:o;return {type:v.Provider,props:{value:C},children:[u],key:void 0}}function V(e){let{fallback:t,onError:o,children:n,resetKey:r}=e,[i,s]=chunk6AVHHBFG_js.c({error:null,info:null}),p=chunk44IBO7Q7_js.b(()=>({current:r}));r!==p.current&&(p.current=r,i.error!==null&&s({error:null,info:null}));if(i.error)return typeof t=="function"?t(i.error,i.info):t;try{return n}finally{}}function $(e){let t=null,o=null,n=null,r=i=>{if(t)return t(i);if(n)throw n;let s=b();return o||(o=e().then(p=>{t=p.default;}).catch(p=>{n=p instanceof Error?p:new Error(String(p));})),s.hasBoundary&&s.register(o),null};return r._lazy=true,r._loader=e,r}Object.defineProperty(exports,"render",{enumerable:true,get:function(){return chunkBGXOI2CB_js.b}});exports.ErrorBoundary=V;exports.Portal=_;exports.Suspense=z;exports.f=A;exports.hydrate=W;exports.lazy=$;//# sourceMappingURL=dom.js.map
2
2
  //# sourceMappingURL=dom.js.map
package/dist/dom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dom/f.ts","../src/dom/hydrate.ts","../src/dom/components/Portal.tsx","../src/dom/components/suspenseContext.ts","../src/dom/components/Suspense.tsx","../src/dom/components/ErrorBoundary.tsx","../src/dom/components/lazy.ts"],"names":["f","type","props","children","hydrationCursor","hydratedInstanceRegistry","currentHydratingInstance","hydrate","app","container","options","state","onHydrated","onMismatch","fnode","isFNode","hydrateNode","error","render","value","parent","skipEmptyTextNodes","hydrateTextNode","nodes","child","result","hydrateComponent","hydrateElement","text","current","tag","key","eventName","savedCursor","Component","contextId","isProvider","prevContextValue","pushContext","parentRegistry","hasExplicitKey","instanceCount","componentName","_","k","instance","previousHydratingInstance","runWithComponent","isFirstRender","renderFn","currentProps","unsafeEffect","popContext","Portal","target","portalState","hook","use","onCleanup","portalWrapper","defaultValue","SuspenseCtx","Context","suspenseContext","Suspense","fallback","pendingSet","setPendingCount","showFallback","setShowFallback","contextValue","promise","newCount","content","ErrorBoundary","onError","resetKey","errorState","setErrorState","prevResetKeyRef","lazy","loader","resolved","LazyWrapper","suspense","module","err"],"mappings":"iNAKO,SAASA,CAAAA,CACZC,CAAAA,CACAC,CAAAA,CAA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,CAAA,CAAA,CAIDF,CAAAA,CAAS,WAAA,EACXA,CAAAA,CAAS,QAAA,CAASb,CAAO,CAAA,CAIpB,IACT,EAGC,OAACY,CAAAA,CAAiC,MAAQ,IAAA,CACzCA,CAAAA,CAAiC,OAAA,CAAUF,CAAAA,CAEtCE,CACT","file":"dom.js","sourcesContent":["import type { FNode } from './types'\n\n/**\n * f() - Create FNodes without JSX\n */\nexport function f(\n type: string | Function,\n props?: any,\n ...children: any[]\n): FNode {\n return {\n type,\n props: props || {},\n children,\n key: props?.key\n }\n}\n","import type { FNode, FNodeChild } from './types'\nimport type { SerializedState } from '../server/types'\nimport { runWithComponent, type ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\nimport { unsafeEffect } from '../core/lifecycle'\n\n// Hydration state\nlet isHydrating = false\nlet hydrationCursor: Node | null = null\nlet hydrationState: SerializedState | null = null\n\nexport interface HydrateOptions {\n /**\n * Serialized state from server\n * Typically embedded in HTML as JSON script tag\n */\n state?: SerializedState\n\n /**\n * Called when hydration completes successfully\n */\n onHydrated?: () => void\n\n /**\n * Called when hydration fails (falls back to full render)\n */\n onMismatch?: (error: Error) => void\n}\n\n// Extended ComponentInstance for DOM tracking (same as render.ts)\ninterface DOMComponentInstance extends ComponentInstance {\n nodes: Node[]\n parent: HTMLElement\n fnode: any\n props: any\n key?: any\n renderFn?: () => void\n children: Set<DOMComponentInstance>\n parentInstance?: DOMComponentInstance\n}\n\n// Registry for hydrated components\nconst hydratedInstanceRegistry = new WeakMap<HTMLElement, Map<any, DOMComponentInstance>>()\nlet currentHydratingInstance: DOMComponentInstance | null = null\n\nexport function getIsHydrating(): boolean {\n return isHydrating\n}\n\nexport function getHydrationState(): SerializedState | null {\n return hydrationState\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n */\nexport function hydrate(\n app: FNodeChild | (() => FNodeChild),\n container: HTMLElement,\n options: HydrateOptions = {}\n): void {\n const { state, onHydrated, onMismatch } = options\n\n // Store state for rehydration\n hydrationState = state || null\n\n // Initialize hydration mode\n isHydrating = true\n hydrationCursor = container.firstChild\n\n try {\n // Normalize input\n let fnode: FNodeChild\n if (typeof app === 'function' && !isFNode(app)) {\n fnode = { type: app, props: {}, children: [], key: undefined }\n } else {\n fnode = app\n }\n\n // Hydrate the tree\n hydrateNode(fnode, container)\n\n onHydrated?.()\n } catch (error) {\n // Hydration mismatch - fall back to full render\n console.warn('[Flexium] Hydration mismatch, falling back to full render:', error)\n onMismatch?.(error as Error)\n\n // Clear and re-render\n container.innerHTML = ''\n // Import dynamically to avoid circular deps\n import('./render').then(({ render }) => {\n render(app, container)\n })\n } finally {\n isHydrating = false\n hydrationCursor = null\n hydrationState = null\n }\n}\n\nfunction isFNode(value: any): value is FNode {\n return value && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction hydrateNode(fnode: FNodeChild, parent: HTMLElement): Node | Node[] | null {\n // Null/undefined/boolean -> skip empty text nodes\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n // Server might have rendered an empty text node\n skipEmptyTextNodes()\n return null\n }\n\n // String/number -> expect text node\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n return hydrateTextNode(String(fnode))\n }\n\n // Array -> hydrate each child\n if (Array.isArray(fnode)) {\n const nodes: Node[] = []\n for (const child of fnode) {\n const result = hydrateNode(child, parent)\n if (result) {\n if (Array.isArray(result)) {\n nodes.push(...result)\n } else {\n nodes.push(result)\n }\n }\n }\n return nodes\n }\n\n // Function (standalone) -> wrap in FNode and hydrate\n if (typeof fnode === 'function') {\n const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n return hydrateComponent(wrappedFnode, parent)\n }\n\n // Object (FNode)\n if (typeof fnode === 'object' && isFNode(fnode)) {\n if (typeof fnode.type === 'string') {\n return hydrateElement(fnode)\n }\n\n if (typeof fnode.type === 'function') {\n return hydrateComponent(fnode, parent)\n }\n }\n\n return null\n}\n\nfunction skipEmptyTextNodes(): void {\n while (\n hydrationCursor &&\n hydrationCursor.nodeType === Node.TEXT_NODE &&\n (!hydrationCursor.textContent || hydrationCursor.textContent.trim() === '')\n ) {\n hydrationCursor = hydrationCursor.nextSibling\n }\n}\n\nfunction hydrateTextNode(text: string): Node | null {\n skipEmptyTextNodes()\n\n const current = hydrationCursor\n\n if (!current) {\n // No node to hydrate - this is okay for conditional rendering\n return null\n }\n\n if (current.nodeType !== Node.TEXT_NODE) {\n // Try to find a text node nearby (whitespace handling)\n if (text.trim() === '') {\n return null\n }\n throw new Error(`Hydration mismatch: expected text node \"${text}\", got ${current.nodeName}`)\n }\n\n // Update cursor\n hydrationCursor = current.nextSibling\n\n return current\n}\n\nfunction hydrateElement(fnode: FNode): Node {\n skipEmptyTextNodes()\n\n const current = hydrationCursor as Element\n const tag = fnode.type as string\n\n // Validate element type\n if (!current || current.nodeType !== Node.ELEMENT_NODE) {\n throw new Error(`Hydration mismatch: expected element <${tag}>, got ${current?.nodeName || 'nothing'}`)\n }\n\n if (current.tagName.toLowerCase() !== tag.toLowerCase()) {\n throw new Error(`Hydration mismatch: expected <${tag}>, got <${current.tagName.toLowerCase()}>`)\n }\n\n // Attach event handlers and refs (don't modify DOM structure)\n if (fnode.props) {\n for (const [key, value] of Object.entries(fnode.props)) {\n if (key === 'ref') {\n if (typeof value === 'function') {\n value(current)\n } else if (value && typeof value === 'object' && 'current' in value) {\n value.current = current\n }\n } else if (key.startsWith('on') && typeof value === 'function') {\n const eventName = key.slice(2).toLowerCase()\n current.addEventListener(eventName, value as EventListener)\n\n // Store for reconciliation\n if (!(current as any).__eventHandlers) {\n (current as any).__eventHandlers = {}\n }\n (current as any).__eventHandlers[eventName] = value\n }\n }\n }\n\n // Move cursor past this element\n hydrationCursor = current.nextSibling\n\n // Hydrate children\n if (fnode.children && fnode.children.length > 0) {\n const savedCursor = hydrationCursor\n\n hydrationCursor = current.firstChild\n\n for (const child of fnode.children) {\n hydrateNode(child, current as HTMLElement)\n }\n\n hydrationCursor = savedCursor\n }\n\n return current\n}\n\nfunction hydrateComponent(fnode: FNode, parent: HTMLElement): Node | Node[] | null {\n const Component = fnode.type as Function\n\n // Merge props\n const props = { ...fnode.props }\n if (fnode.children && fnode.children.length > 0) {\n props.children = fnode.children.length === 1\n ? fnode.children[0]\n : fnode.children\n }\n\n // Handle context providers\n const contextId = (Component as any)._contextId\n const isProvider = contextId !== undefined\n let prevContextValue: any\n\n if (isProvider) {\n prevContextValue = pushContext(contextId, props.value)\n }\n\n // Generate key (same logic as render.ts)\n if (!hydratedInstanceRegistry.has(parent)) {\n hydratedInstanceRegistry.set(parent, new Map())\n }\n const parentRegistry = hydratedInstanceRegistry.get(parent)!\n\n const hasExplicitKey = fnode.key !== undefined\n let key: any\n if (hasExplicitKey) {\n key = fnode.key\n } else {\n let instanceCount = 0\n const componentName = (Component as any).name || 'anonymous'\n parentRegistry.forEach((_, k) => {\n if (typeof k === 'string' && k.startsWith(`__auto_${componentName}_`)) {\n instanceCount++\n }\n })\n key = `__auto_${componentName}_${instanceCount}`\n }\n\n // Create component instance\n const instance: DOMComponentInstance = {\n hooks: [],\n hookIndex: 0,\n nodes: [],\n parent,\n fnode,\n props,\n key,\n children: new Set(),\n parentInstance: currentHydratingInstance || undefined\n }\n\n if (currentHydratingInstance) {\n currentHydratingInstance.children.add(instance)\n }\n\n parentRegistry.set(key, instance)\n\n const previousHydratingInstance = currentHydratingInstance\n currentHydratingInstance = instance\n\n try {\n // First render during hydration - just match DOM\n const result = runWithComponent(instance, () => Component(props))\n const nodes = hydrateNode(result, parent)\n instance.nodes = nodes ? (Array.isArray(nodes) ? nodes : [nodes]) : []\n\n // Set up reactive re-rendering for future updates\n let isFirstRender = true\n const renderFn = () => {\n if (isFirstRender) {\n isFirstRender = false\n return // Skip first render, already done during hydration\n }\n\n // Re-render logic (same as render.ts but simplified)\n const currentProps = instance.props\n runWithComponent(instance, () => Component(currentProps))\n\n // For subsequent renders, use full render path\n // This will be handled by the normal reconciliation\n }\n\n instance.renderFn = renderFn\n unsafeEffect(renderFn)\n\n return instance.nodes\n } finally {\n currentHydratingInstance = previousHydratingInstance\n\n if (isProvider) {\n popContext(contextId, prevContextValue)\n }\n }\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { render } from '../render'\nimport type { PortalProps } from './types'\n\n/**\n * Portal component that renders children into a different DOM node\n *\n * @example\n * ```tsx\n * function Modal({ isOpen, onClose, children }) {\n * if (!isOpen) return null\n *\n * return (\n * <Portal target={document.body}>\n * <div class=\"modal-backdrop\" onClick={onClose}>\n * <div class=\"modal-content\" onClick={e => e.stopPropagation()}>\n * {children}\n * </div>\n * </div>\n * </Portal>\n * )\n * }\n * ```\n */\nexport function Portal(props: PortalProps): null {\n const { target, children } = props\n\n // Store rendered container for cleanup\n const portalState = hook(() => ({\n container: null as HTMLElement | null,\n mounted: false\n }))\n\n use(({ onCleanup }) => {\n // Resolve target container\n let container: HTMLElement | null = null\n\n if (typeof target === 'string') {\n container = document.querySelector(target)\n } else if (target instanceof HTMLElement) {\n container = target\n }\n\n if (!container) {\n console.warn('[Flexium Portal] Target container not found:', target)\n return\n }\n\n // Create a wrapper div to contain portal content\n const portalWrapper = document.createElement('div')\n portalWrapper.setAttribute('data-flexium-portal', 'true')\n container.appendChild(portalWrapper)\n\n portalState.container = portalWrapper\n portalState.mounted = true\n\n // Render children into the portal wrapper\n render(children, portalWrapper)\n\n // Cleanup function\n onCleanup(() => {\n if (portalWrapper.parentNode) {\n portalWrapper.parentNode.removeChild(portalWrapper)\n }\n portalState.container = null\n portalState.mounted = false\n })\n }, [target, children])\n\n // Portal renders nothing in its original location\n return null\n}\n","import { Context } from '../../core/context'\nimport { use } from '../../core/use'\nimport type { SuspenseContextValue } from './types'\n\nconst defaultValue: SuspenseContextValue = {\n register: () => {},\n hasBoundary: false\n}\n\nexport const SuspenseCtx = new Context<SuspenseContextValue>(defaultValue)\n\nexport function suspenseContext(): SuspenseContextValue {\n const [value] = use(SuspenseCtx)\n return value\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { SuspenseCtx } from './suspenseContext'\nimport type { SuspenseProps, SuspenseContextValue } from './types'\nimport type { FNodeChild } from '../types'\n\n/**\n * Suspense component that shows fallback while children are loading\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function Suspense(props: SuspenseProps): FNodeChild {\n const { fallback, children } = props\n\n // Track pending promises using hook for mutable Set\n const pendingSet = hook(() => new Set<Promise<any>>())\n const [, setPendingCount] = use(0)\n const [showFallback, setShowFallback] = use(false)\n\n // Register function for lazy components\n const register = (promise: Promise<any>) => {\n if (!pendingSet.has(promise)) {\n // Add to pending set\n pendingSet.add(promise)\n setPendingCount(c => c + 1)\n setShowFallback(true)\n\n // Wait for resolution\n promise.finally(() => {\n pendingSet.delete(promise)\n setPendingCount(c => {\n const newCount = c - 1\n if (newCount === 0) {\n setShowFallback(false)\n }\n return newCount\n })\n })\n }\n }\n\n const contextValue: SuspenseContextValue = {\n register,\n hasBoundary: true\n }\n\n // Render fallback or children based on pending state\n const content = showFallback ? fallback : children\n\n // Wrap content with Suspense context provider\n return {\n type: SuspenseCtx.Provider,\n props: { value: contextValue },\n children: [content],\n key: undefined\n } as any\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport type { FNodeChild } from '../types'\nimport type { ErrorInfo, ErrorBoundaryProps } from './types'\n\n// Component name stack for error messages\nlet componentNameStack: string[] = []\n\nexport function pushComponentName(name: string): void {\n componentNameStack.push(name)\n}\n\nexport function popComponentName(): void {\n componentNameStack.pop()\n}\n\nexport function getComponentStack(): string {\n return componentNameStack\n .map(name => ` at ${name}`)\n .reverse()\n .join('\\n')\n}\n\n// Stack of error boundaries for nested error propagation\ninterface ErrorBoundaryInstance {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => void\n}\n\nlet errorBoundaryStack: ErrorBoundaryInstance[] = []\n\nexport function pushErrorBoundary(instance: ErrorBoundaryInstance): void {\n errorBoundaryStack.push(instance)\n}\n\nexport function popErrorBoundary(): void {\n errorBoundaryStack.pop()\n}\n\nexport function getNearestErrorBoundary(): ErrorBoundaryInstance | null {\n return errorBoundaryStack[errorBoundaryStack.length - 1] || null\n}\n\n/**\n * ErrorBoundary component that catches errors in its children and displays fallback UI\n *\n * @example\n * ```tsx\n * <ErrorBoundary\n * fallback={(error, info) => <div>Error: {error.message}</div>}\n * onError={(error, info) => console.error(error)}\n * >\n * <App />\n * </ErrorBoundary>\n * ```\n */\nexport function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild {\n const { fallback, onError, children, resetKey } = props\n\n // Error state\n const [errorState, setErrorState] = use<{\n error: Error | null\n info: ErrorInfo | null\n }>({ error: null, info: null })\n\n // Track reset key changes to clear error\n const prevResetKeyRef = hook(() => ({ current: resetKey }))\n\n if (resetKey !== prevResetKeyRef.current) {\n prevResetKeyRef.current = resetKey\n if (errorState.error !== null) {\n setErrorState({ error: null, info: null })\n }\n }\n\n // Error boundary instance\n const boundaryInstance: ErrorBoundaryInstance = {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => {\n const info: ErrorInfo = {\n componentStack: getComponentStack(),\n phase\n }\n\n // Call error callback\n onError?.(error, info)\n\n // Update error state (triggers re-render with fallback)\n setErrorState({ error, info })\n }\n }\n\n // If we have an error, render fallback\n if (errorState.error) {\n if (typeof fallback === 'function') {\n return fallback(errorState.error, errorState.info!)\n }\n return fallback\n }\n\n // Push boundary onto stack for children to use\n pushErrorBoundary(boundaryInstance)\n\n try {\n // Return children - they will be rendered with this boundary active\n return children\n } finally {\n popErrorBoundary()\n }\n}\n","import { suspenseContext } from './suspenseContext'\nimport type { FNodeChild } from '../types'\nimport type { LazyComponent } from './types'\n\n/**\n * Creates a lazy-loaded component for code splitting\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n * const Settings = lazy(() => import('./Settings'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function lazy<P = {}>(\n loader: () => Promise<{ default: (props: P) => FNodeChild }>\n): LazyComponent<P> {\n // Shared state across all instances\n let resolved: ((props: P) => FNodeChild) | null = null\n let promise: Promise<any> | null = null\n let error: Error | null = null\n\n // The wrapper component\n const LazyWrapper = (props: P): FNodeChild => {\n // If already resolved, render immediately\n if (resolved) {\n return resolved(props)\n }\n\n // If error occurred, throw it (will be caught by ErrorBoundary)\n if (error) {\n throw error\n }\n\n // Get suspense context\n const suspense = suspenseContext()\n\n // Start loading if not already\n if (!promise) {\n promise = loader()\n .then(module => {\n resolved = module.default\n })\n .catch(err => {\n error = err instanceof Error ? err : new Error(String(err))\n })\n }\n\n // Register with suspense boundary if available\n if (suspense.hasBoundary) {\n suspense.register(promise)\n }\n\n // Return null - Suspense will show fallback\n return null\n }\n\n // Mark as lazy component\n ;(LazyWrapper as LazyComponent<P>)._lazy = true\n ;(LazyWrapper as LazyComponent<P>)._loader = loader\n\n return LazyWrapper as LazyComponent<P>\n}\n"]}
1
+ {"version":3,"sources":["../src/dom/f.ts","../src/dom/hydrate.ts","../src/dom/components/Portal.tsx","../src/dom/components/suspenseContext.ts","../src/dom/components/Suspense.tsx","../src/dom/components/ErrorBoundary.tsx","../src/dom/components/lazy.ts"],"names":["f","type","props","children","hydrationCursor","hydratedInstanceRegistry","currentHydratingInstance","hydrate","app","container","options","state","onHydrated","onMismatch","fnode","isFNode","hydrateNode","error","render","value","parent","skipEmptyTextNodes","hydrateTextNode","nodes","child","result","hydrateComponent","hydrateElement","text","current","tag","key","eventName","savedCursor","Component","contextId","isProvider","prevContextValue","pushContext","parentRegistry","hasExplicitKey","instanceCount","componentName","_","k","instance","previousHydratingInstance","runWithComponent","isFirstRender","renderFn","currentProps","unsafeEffect","popContext","Portal","target","portalState","hook","use","onCleanup","portalWrapper","defaultValue","SuspenseCtx","Context","suspenseContext","Suspense","fallback","pendingSet","setPendingCount","showFallback","setShowFallback","contextValue","promise","newCount","content","ErrorBoundary","onError","resetKey","errorState","setErrorState","prevResetKeyRef","lazy","loader","resolved","LazyWrapper","suspense","module","err"],"mappings":"iNAKO,SAASA,CAAAA,CACZC,CAAAA,CACAC,CAAAA,CAAAA,GACGC,CAAAA,CACE,CACL,OAAO,CACH,IAAA,CAAAF,CAAAA,CACA,KAAA,CAAOC,CAAAA,EAAS,GAChB,QAAA,CAAAC,CAAAA,CACA,GAAA,CAAKD,CAAAA,EAAO,GAChB,CACJ,CCTA,IACIE,CAAAA,CAA+B,IAAA,CAkC7BC,EAA2B,IAAI,OAAA,CACjCC,CAAAA,CAAwD,KAarD,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0B,EAAC,CACrB,CACN,GAAM,CAAE,MAAAC,CAAAA,CAAO,UAAA,CAAAC,CAAAA,CAAY,UAAA,CAAAC,CAAW,CAAA,CAAIH,CAAAA,CAO1CN,CAAAA,CAAkBK,CAAAA,CAAU,WAE5B,GAAI,CAEF,IAAIK,CAAAA,CACA,OAAON,CAAAA,EAAQ,UAAA,EAAc,CAACO,CAAAA,CAAQP,CAAG,CAAA,CAC3CM,CAAAA,CAAQ,CAAE,IAAA,CAAMN,EAAK,KAAA,CAAO,EAAC,CAAG,QAAA,CAAU,EAAC,CAAG,GAAA,CAAK,KAAA,CAAU,CAAA,CAE7DM,CAAAA,CAAQN,CAAAA,CAIVQ,CAAAA,CAAYF,CAAAA,CAAOL,CAAS,EAE5BG,CAAAA,KACF,CAAA,MAASK,CAAAA,CAAO,CAEd,OAAA,CAAQ,IAAA,CAAK,4DAAA,CAA8DA,CAAK,CAAA,CAChFJ,CAAAA,GAAaI,CAAc,CAAA,CAG3BR,CAAAA,CAAU,UAAY,EAAA,CAEtB,OAAO,sBAAU,CAAA,CAAE,IAAA,CAAK,CAAC,CAAE,MAAA,CAAAS,CAAO,CAAA,G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CAAAA,EAAO,CACd,IAAA,CAAKI,GAAU,CACdH,CAAAA,CAAWG,EAAO,QACpB,CAAC,EACA,KAAA,CAAMC,CAAAA,EAAO,CACZrE,CAAAA,CAAQqE,CAAAA,YAAe,KAAA,CAAQA,EAAM,IAAI,KAAA,CAAM,OAAOA,CAAG,CAAC,EAC5D,CAAC,CAAA,CAAA,CAIDF,CAAAA,CAAS,WAAA,EACXA,CAAAA,CAAS,QAAA,CAASb,CAAO,CAAA,CAIpB,IACT,EAGC,OAACY,CAAAA,CAAiC,MAAQ,IAAA,CACzCA,CAAAA,CAAiC,OAAA,CAAUF,CAAAA,CAEtCE,CACT","file":"dom.js","sourcesContent":["import type { FNode } from './types'\n\n/**\n * f() - Create FNodes without JSX\n */\nexport function f(\n type: string | Function,\n props?: any,\n ...children: any[]\n): FNode {\n return {\n type,\n props: props || {},\n children,\n key: props?.key\n }\n}\n","import type { FNode, FNodeChild } from './types'\nimport type { SerializedState } from '../server/types'\nimport { runWithComponent, type ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\nimport { unsafeEffect } from '../core/lifecycle'\n\n// Hydration state\nlet isHydrating = false\nlet hydrationCursor: Node | null = null\nlet hydrationState: SerializedState | null = null\n\nexport interface HydrateOptions {\n /**\n * Serialized state from server\n * Typically embedded in HTML as JSON script tag\n */\n state?: SerializedState\n\n /**\n * Called when hydration completes successfully\n */\n onHydrated?: () => void\n\n /**\n * Called when hydration fails (falls back to full render)\n */\n onMismatch?: (error: Error) => void\n}\n\n// Extended ComponentInstance for DOM tracking (same as render.ts)\ninterface DOMComponentInstance extends ComponentInstance {\n nodes: Node[]\n parent: HTMLElement\n fnode: any\n props: any\n key?: any\n renderFn?: () => void\n children: Set<DOMComponentInstance>\n parentInstance?: DOMComponentInstance\n}\n\n// Registry for hydrated components\nconst hydratedInstanceRegistry = new WeakMap<HTMLElement, Map<any, DOMComponentInstance>>()\nlet currentHydratingInstance: DOMComponentInstance | null = null\n\nexport function getIsHydrating(): boolean {\n return isHydrating\n}\n\nexport function getHydrationState(): SerializedState | null {\n return hydrationState\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n */\nexport function hydrate(\n app: FNodeChild | (() => FNodeChild),\n container: HTMLElement,\n options: HydrateOptions = {}\n): void {\n const { state, onHydrated, onMismatch } = options\n\n // Store state for rehydration\n hydrationState = state || null\n\n // Initialize hydration mode\n isHydrating = true\n hydrationCursor = container.firstChild\n\n try {\n // Normalize input\n let fnode: FNodeChild\n if (typeof app === 'function' && !isFNode(app)) {\n fnode = { type: app, props: {}, children: [], key: undefined }\n } else {\n fnode = app\n }\n\n // Hydrate the tree\n hydrateNode(fnode, container)\n\n onHydrated?.()\n } catch (error) {\n // Hydration mismatch - fall back to full render\n console.warn('[Flexium] Hydration mismatch, falling back to full render:', error)\n onMismatch?.(error as Error)\n\n // Clear and re-render\n container.innerHTML = ''\n // Import dynamically to avoid circular deps\n import('./render').then(({ render }) => {\n render(app, container)\n })\n } finally {\n isHydrating = false\n hydrationCursor = null\n hydrationState = null\n }\n}\n\nfunction isFNode(value: any): value is FNode {\n return value && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction hydrateNode(fnode: FNodeChild, parent: HTMLElement): Node | Node[] | null {\n // Null/undefined/boolean -> skip empty text nodes\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n // Server might have rendered an empty text node\n skipEmptyTextNodes()\n return null\n }\n\n // String/number -> expect text node\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n return hydrateTextNode(String(fnode))\n }\n\n // Array -> hydrate each child\n if (Array.isArray(fnode)) {\n const nodes: Node[] = []\n for (const child of fnode) {\n const result = hydrateNode(child, parent)\n if (result) {\n if (Array.isArray(result)) {\n nodes.push(...result)\n } else {\n nodes.push(result)\n }\n }\n }\n return nodes\n }\n\n // Function (standalone) -> wrap in FNode and hydrate\n if (typeof fnode === 'function') {\n const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n return hydrateComponent(wrappedFnode, parent)\n }\n\n // Object (FNode)\n if (typeof fnode === 'object' && isFNode(fnode)) {\n if (typeof fnode.type === 'string') {\n return hydrateElement(fnode)\n }\n\n if (typeof fnode.type === 'function') {\n return hydrateComponent(fnode, parent)\n }\n }\n\n return null\n}\n\nfunction skipEmptyTextNodes(): void {\n while (\n hydrationCursor &&\n hydrationCursor.nodeType === Node.TEXT_NODE &&\n (!hydrationCursor.textContent || hydrationCursor.textContent.trim() === '')\n ) {\n hydrationCursor = hydrationCursor.nextSibling\n }\n}\n\nfunction hydrateTextNode(text: string): Node | null {\n skipEmptyTextNodes()\n\n const current = hydrationCursor\n\n if (!current) {\n // No node to hydrate - this is okay for conditional rendering\n return null\n }\n\n if (current.nodeType !== Node.TEXT_NODE) {\n // Try to find a text node nearby (whitespace handling)\n if (text.trim() === '') {\n return null\n }\n throw new Error(`Hydration mismatch: expected text node \"${text}\", got ${current.nodeName}`)\n }\n\n // Update cursor\n hydrationCursor = current.nextSibling\n\n return current\n}\n\nfunction hydrateElement(fnode: FNode): Node {\n skipEmptyTextNodes()\n\n const current = hydrationCursor as Element\n const tag = fnode.type as string\n\n // Validate element type\n if (!current || current.nodeType !== Node.ELEMENT_NODE) {\n throw new Error(`Hydration mismatch: expected element <${tag}>, got ${current?.nodeName || 'nothing'}`)\n }\n\n if (current.tagName.toLowerCase() !== tag.toLowerCase()) {\n throw new Error(`Hydration mismatch: expected <${tag}>, got <${current.tagName.toLowerCase()}>`)\n }\n\n // Attach event handlers and refs (don't modify DOM structure)\n if (fnode.props) {\n for (const [key, value] of Object.entries(fnode.props)) {\n if (key === 'ref') {\n if (typeof value === 'function') {\n value(current)\n } else if (value && typeof value === 'object' && 'current' in value) {\n value.current = current\n }\n } else if (key.startsWith('on') && typeof value === 'function') {\n const eventName = key.slice(2).toLowerCase()\n current.addEventListener(eventName, value as EventListener)\n\n // Store for reconciliation\n if (!(current as any).__eventHandlers) {\n (current as any).__eventHandlers = {}\n }\n (current as any).__eventHandlers[eventName] = value\n }\n }\n }\n\n // Move cursor past this element\n hydrationCursor = current.nextSibling\n\n // Hydrate children\n if (fnode.children && fnode.children.length > 0) {\n const savedCursor = hydrationCursor\n\n hydrationCursor = current.firstChild\n\n for (const child of fnode.children) {\n hydrateNode(child, current as HTMLElement)\n }\n\n hydrationCursor = savedCursor\n }\n\n return current\n}\n\nfunction hydrateComponent(fnode: FNode, parent: HTMLElement): Node | Node[] | null {\n const Component = fnode.type as Function\n\n // Merge props\n const props = { ...fnode.props }\n if (fnode.children && fnode.children.length > 0) {\n props.children = fnode.children.length === 1\n ? fnode.children[0]\n : fnode.children\n }\n\n // Handle context providers\n const contextId = (Component as any)._contextId\n const isProvider = contextId !== undefined\n let prevContextValue: any\n\n if (isProvider) {\n prevContextValue = pushContext(contextId, props.value)\n }\n\n // Generate key (same logic as render.ts)\n if (!hydratedInstanceRegistry.has(parent)) {\n hydratedInstanceRegistry.set(parent, new Map())\n }\n const parentRegistry = hydratedInstanceRegistry.get(parent)!\n\n const hasExplicitKey = fnode.key !== undefined\n let key: any\n if (hasExplicitKey) {\n key = fnode.key\n } else {\n let instanceCount = 0\n const componentName = (Component as any).name || 'anonymous'\n parentRegistry.forEach((_, k) => {\n if (typeof k === 'string' && k.startsWith(`__auto_${componentName}_`)) {\n instanceCount++\n }\n })\n key = `__auto_${componentName}_${instanceCount}`\n }\n\n // Create component instance\n const instance: DOMComponentInstance = {\n hooks: [],\n hookIndex: 0,\n nodes: [],\n parent,\n fnode,\n props,\n key,\n children: new Set(),\n parentInstance: currentHydratingInstance || undefined\n }\n\n if (currentHydratingInstance) {\n currentHydratingInstance.children.add(instance)\n }\n\n parentRegistry.set(key, instance)\n\n const previousHydratingInstance = currentHydratingInstance\n currentHydratingInstance = instance\n\n try {\n // First render during hydration - just match DOM\n const result = runWithComponent(instance, () => Component(props))\n const nodes = hydrateNode(result, parent)\n instance.nodes = nodes ? (Array.isArray(nodes) ? nodes : [nodes]) : []\n\n // Set up reactive re-rendering for future updates\n let isFirstRender = true\n const renderFn = () => {\n if (isFirstRender) {\n isFirstRender = false\n return // Skip first render, already done during hydration\n }\n\n // Re-render logic (same as render.ts but simplified)\n const currentProps = instance.props\n runWithComponent(instance, () => Component(currentProps))\n\n // For subsequent renders, use full render path\n // This will be handled by the normal reconciliation\n }\n\n instance.renderFn = renderFn\n unsafeEffect(renderFn)\n\n return instance.nodes\n } finally {\n currentHydratingInstance = previousHydratingInstance\n\n if (isProvider) {\n popContext(contextId, prevContextValue)\n }\n }\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { render } from '../render'\nimport type { PortalProps } from './types'\n\n/**\n * Portal component that renders children into a different DOM node\n *\n * @deprecated Use Portal from 'flexium-ui' instead:\n * ```tsx\n * import { Portal } from 'flexium-ui'\n * ```\n *\n * @example\n * ```tsx\n * function Modal({ isOpen, onClose, children }) {\n * if (!isOpen) return null\n *\n * return (\n * <Portal target={document.body}>\n * <div class=\"modal-backdrop\" onClick={onClose}>\n * <div class=\"modal-content\" onClick={e => e.stopPropagation()}>\n * {children}\n * </div>\n * </div>\n * </Portal>\n * )\n * }\n * ```\n */\nexport function Portal(props: PortalProps): null {\n const { target, children } = props\n\n // Store rendered container for cleanup\n const portalState = hook(() => ({\n container: null as HTMLElement | null,\n mounted: false\n }))\n\n use(({ onCleanup }) => {\n // Resolve target container\n let container: HTMLElement | null = null\n\n if (typeof target === 'string') {\n container = document.querySelector(target)\n } else if (target instanceof HTMLElement) {\n container = target\n }\n\n if (!container) {\n console.warn('[Flexium Portal] Target container not found:', target)\n return\n }\n\n // Create a wrapper div to contain portal content\n const portalWrapper = document.createElement('div')\n portalWrapper.setAttribute('data-flexium-portal', 'true')\n container.appendChild(portalWrapper)\n\n portalState.container = portalWrapper\n portalState.mounted = true\n\n // Render children into the portal wrapper\n render(children, portalWrapper)\n\n // Cleanup function\n onCleanup(() => {\n if (portalWrapper.parentNode) {\n portalWrapper.parentNode.removeChild(portalWrapper)\n }\n portalState.container = null\n portalState.mounted = false\n })\n }, [target, children])\n\n // Portal renders nothing in its original location\n return null\n}\n","import { Context } from '../../core/context'\nimport { use } from '../../core/use'\nimport type { SuspenseContextValue } from './types'\n\nconst defaultValue: SuspenseContextValue = {\n register: () => {},\n hasBoundary: false\n}\n\nexport const SuspenseCtx = new Context<SuspenseContextValue>(defaultValue)\n\nexport function suspenseContext(): SuspenseContextValue {\n const [value] = use(SuspenseCtx)\n return value\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { SuspenseCtx } from './suspenseContext'\nimport type { SuspenseProps, SuspenseContextValue } from './types'\nimport type { FNodeChild } from '../types'\n\n/**\n * Suspense component that shows fallback while children are loading\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function Suspense(props: SuspenseProps): FNodeChild {\n const { fallback, children } = props\n\n // Track pending promises using hook for mutable Set\n const pendingSet = hook(() => new Set<Promise<any>>())\n const [, setPendingCount] = use(0)\n const [showFallback, setShowFallback] = use(false)\n\n // Register function for lazy components\n const register = (promise: Promise<any>) => {\n if (!pendingSet.has(promise)) {\n // Add to pending set\n pendingSet.add(promise)\n setPendingCount(c => c + 1)\n setShowFallback(true)\n\n // Wait for resolution\n promise.finally(() => {\n pendingSet.delete(promise)\n setPendingCount(c => {\n const newCount = c - 1\n if (newCount === 0) {\n setShowFallback(false)\n }\n return newCount\n })\n })\n }\n }\n\n const contextValue: SuspenseContextValue = {\n register,\n hasBoundary: true\n }\n\n // Render fallback or children based on pending state\n const content = showFallback ? fallback : children\n\n // Wrap content with Suspense context provider\n return {\n type: SuspenseCtx.Provider,\n props: { value: contextValue },\n children: [content],\n key: undefined\n } as any\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport type { FNodeChild } from '../types'\nimport type { ErrorInfo, ErrorBoundaryProps } from './types'\n\n// Component name stack for error messages\nlet componentNameStack: string[] = []\n\nexport function pushComponentName(name: string): void {\n componentNameStack.push(name)\n}\n\nexport function popComponentName(): void {\n componentNameStack.pop()\n}\n\nexport function getComponentStack(): string {\n return componentNameStack\n .map(name => ` at ${name}`)\n .reverse()\n .join('\\n')\n}\n\n// Stack of error boundaries for nested error propagation\ninterface ErrorBoundaryInstance {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => void\n}\n\nlet errorBoundaryStack: ErrorBoundaryInstance[] = []\n\nexport function pushErrorBoundary(instance: ErrorBoundaryInstance): void {\n errorBoundaryStack.push(instance)\n}\n\nexport function popErrorBoundary(): void {\n errorBoundaryStack.pop()\n}\n\nexport function getNearestErrorBoundary(): ErrorBoundaryInstance | null {\n return errorBoundaryStack[errorBoundaryStack.length - 1] || null\n}\n\n/**\n * ErrorBoundary component that catches errors in its children and displays fallback UI\n *\n * @example\n * ```tsx\n * <ErrorBoundary\n * fallback={(error, info) => <div>Error: {error.message}</div>}\n * onError={(error, info) => console.error(error)}\n * >\n * <App />\n * </ErrorBoundary>\n * ```\n */\nexport function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild {\n const { fallback, onError, children, resetKey } = props\n\n // Error state\n const [errorState, setErrorState] = use<{\n error: Error | null\n info: ErrorInfo | null\n }>({ error: null, info: null })\n\n // Track reset key changes to clear error\n const prevResetKeyRef = hook(() => ({ current: resetKey }))\n\n if (resetKey !== prevResetKeyRef.current) {\n prevResetKeyRef.current = resetKey\n if (errorState.error !== null) {\n setErrorState({ error: null, info: null })\n }\n }\n\n // Error boundary instance\n const boundaryInstance: ErrorBoundaryInstance = {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => {\n const info: ErrorInfo = {\n componentStack: getComponentStack(),\n phase\n }\n\n // Call error callback\n onError?.(error, info)\n\n // Update error state (triggers re-render with fallback)\n setErrorState({ error, info })\n }\n }\n\n // If we have an error, render fallback\n if (errorState.error) {\n if (typeof fallback === 'function') {\n return fallback(errorState.error, errorState.info!)\n }\n return fallback\n }\n\n // Push boundary onto stack for children to use\n pushErrorBoundary(boundaryInstance)\n\n try {\n // Return children - they will be rendered with this boundary active\n return children\n } finally {\n popErrorBoundary()\n }\n}\n","import { suspenseContext } from './suspenseContext'\nimport type { FNodeChild } from '../types'\nimport type { LazyComponent } from './types'\n\n/**\n * Creates a lazy-loaded component for code splitting\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n * const Settings = lazy(() => import('./Settings'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function lazy<P = {}>(\n loader: () => Promise<{ default: (props: P) => FNodeChild }>\n): LazyComponent<P> {\n // Shared state across all instances\n let resolved: ((props: P) => FNodeChild) | null = null\n let promise: Promise<any> | null = null\n let error: Error | null = null\n\n // The wrapper component\n const LazyWrapper = (props: P): FNodeChild => {\n // If already resolved, render immediately\n if (resolved) {\n return resolved(props)\n }\n\n // If error occurred, throw it (will be caught by ErrorBoundary)\n if (error) {\n throw error\n }\n\n // Get suspense context\n const suspense = suspenseContext()\n\n // Start loading if not already\n if (!promise) {\n promise = loader()\n .then(module => {\n resolved = module.default\n })\n .catch(err => {\n error = err instanceof Error ? err : new Error(String(err))\n })\n }\n\n // Register with suspense boundary if available\n if (suspense.hasBoundary) {\n suspense.register(promise)\n }\n\n // Return null - Suspense will show fallback\n return null\n }\n\n // Mark as lazy component\n ;(LazyWrapper as LazyComponent<P>)._lazy = true\n ;(LazyWrapper as LazyComponent<P>)._loader = loader\n\n return LazyWrapper as LazyComponent<P>\n}\n"]}
package/dist/dom.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {b as b$3}from'./chunk-TP5HUAIN.mjs';export{b as render}from'./chunk-TP5HUAIN.mjs';import {c as c$1}from'./chunk-3AKECLKA.mjs';import {b as b$1}from'./chunk-NRPWBHKP.mjs';import {c,e,a,f,b as b$2}from'./chunk-MI76R42D.mjs';function A(e,t,...o){return {type:e,props:t||{},children:o,key:t?.key}}var l=null,P=new WeakMap,h=null;function W(e,t,o={}){let{state:n,onHydrated:r,onMismatch:i}=o;l=t.firstChild;try{let s;typeof e=="function"&&!T(e)?s={type:e,props:{},children:[],key:void 0}:s=e,E(s,t),r?.();}catch(s){console.warn("[Flexium] Hydration mismatch, falling back to full render:",s),i?.(s),t.innerHTML="",import('./render-4HB53K66.mjs').then(({render:p})=>{p(e,t);});}finally{l=null;}}function T(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function E(e,t){if(e==null||typeof e=="boolean")return F(),null;if(typeof e=="string"||typeof e=="number")return j(String(e));if(Array.isArray(e)){let o=[];for(let n of e){let r=E(n,t);r&&(Array.isArray(r)?o.push(...r):o.push(r));}return o}if(typeof e=="function")return M({type:e,props:{},children:[],key:void 0},t);if(typeof e=="object"&&T(e)){if(typeof e.type=="string")return R(e);if(typeof e.type=="function")return M(e,t)}return null}function F(){for(;l&&l.nodeType===Node.TEXT_NODE&&(!l.textContent||l.textContent.trim()==="");)l=l.nextSibling;}function j(e){F();let t=l;if(!t)return null;if(t.nodeType!==Node.TEXT_NODE){if(e.trim()==="")return null;throw new Error(`Hydration mismatch: expected text node "${e}", got ${t.nodeName}`)}return l=t.nextSibling,t}function R(e){F();let t=l,o=e.type;if(!t||t.nodeType!==Node.ELEMENT_NODE)throw new Error(`Hydration mismatch: expected element <${o}>, got ${t?.nodeName||"nothing"}`);if(t.tagName.toLowerCase()!==o.toLowerCase())throw new Error(`Hydration mismatch: expected <${o}>, got <${t.tagName.toLowerCase()}>`);if(e.props){for(let[n,r]of Object.entries(e.props))if(n==="ref")typeof r=="function"?r(t):r&&typeof r=="object"&&"current"in r&&(r.current=t);else if(n.startsWith("on")&&typeof r=="function"){let i=n.slice(2).toLowerCase();t.addEventListener(i,r),t.__eventHandlers||(t.__eventHandlers={}),t.__eventHandlers[i]=r;}}if(l=t.nextSibling,e.children&&e.children.length>0){let n=l;l=t.firstChild;for(let r of e.children)E(r,t);l=n;}return t}function M(e$1,t){let o=e$1.type,n={...e$1.props};e$1.children&&e$1.children.length>0&&(n.children=e$1.children.length===1?e$1.children[0]:e$1.children);let r=o._contextId,i=r!==void 0,s;i&&(s=e(r,n.value)),P.has(t)||P.set(t,new Map);let p=P.get(t),C=e$1.key!==void 0,u;if(C)u=e$1.key;else {let y=0,f=o.name||"anonymous";p.forEach((N,x)=>{typeof x=="string"&&x.startsWith(`__auto_${f}_`)&&y++;}),u=`__auto_${f}_${y}`;}let a$1={hooks:[],hookIndex:0,nodes:[],parent:t,fnode:e$1,props:n,key:u,children:new Set,parentInstance:h||void 0};h&&h.children.add(a$1),p.set(u,a$1);let c=h;h=a$1;try{let y=a(a$1,()=>o(n)),f=E(y,t);a$1.nodes=f?Array.isArray(f)?f:[f]:[];let N=!0,x=()=>{if(N){N=!1;return}let D=a$1.props;a(a$1,()=>o(D));};return a$1.renderFn=x,b$1(x),a$1.nodes}finally{h=c,i&&f(r,s);}}function _(e){let{target:t,children:o}=e,n=b$2(()=>({container:null,mounted:false}));return c$1(({onCleanup:r})=>{let i=null;if(typeof t=="string"?i=document.querySelector(t):t instanceof HTMLElement&&(i=t),!i){console.warn("[Flexium Portal] Target container not found:",t);return}let s=document.createElement("div");s.setAttribute("data-flexium-portal","true"),i.appendChild(s),n.container=s,n.mounted=true,b$3(o,s),r(()=>{s.parentNode&&s.parentNode.removeChild(s),n.container=null,n.mounted=false;});},[t,o]),null}var K={register:()=>{},hasBoundary:false},v=new c(K);function b(){let[e]=c$1(v);return e}function z(e){let{fallback:t,children:o}=e,n=b$2(()=>new Set),[,r]=c$1(0),[i,s]=c$1(false),C={register:a=>{n.has(a)||(n.add(a),r(c=>c+1),s(true),a.finally(()=>{n.delete(a),r(c=>{let y=c-1;return y===0&&s(false),y});}));},hasBoundary:true},u=i?t:o;return {type:v.Provider,props:{value:C},children:[u],key:void 0}}function V(e){let{fallback:t,onError:o,children:n,resetKey:r}=e,[i,s]=c$1({error:null,info:null}),p=b$2(()=>({current:r}));r!==p.current&&(p.current=r,i.error!==null&&s({error:null,info:null}));if(i.error)return typeof t=="function"?t(i.error,i.info):t;try{return n}finally{}}function $(e){let t=null,o=null,n=null,r=i=>{if(t)return t(i);if(n)throw n;let s=b();return o||(o=e().then(p=>{t=p.default;}).catch(p=>{n=p instanceof Error?p:new Error(String(p));})),s.hasBoundary&&s.register(o),null};return r._lazy=true,r._loader=e,r}export{V as ErrorBoundary,_ as Portal,z as Suspense,A as f,W as hydrate,$ as lazy};//# sourceMappingURL=dom.mjs.map
1
+ import {b as b$3}from'./chunk-LEL6ICHK.mjs';export{b as render}from'./chunk-LEL6ICHK.mjs';import {c}from'./chunk-4DTHOZSY.mjs';import {b as b$1}from'./chunk-NRPWBHKP.mjs';import {e,g,a,h as h$1,b as b$2}from'./chunk-64L26RKO.mjs';function A(e,t,...o){return {type:e,props:t||{},children:o,key:t?.key}}var l=null,P=new WeakMap,h=null;function W(e,t,o={}){let{state:n,onHydrated:r,onMismatch:i}=o;l=t.firstChild;try{let s;typeof e=="function"&&!T(e)?s={type:e,props:{},children:[],key:void 0}:s=e,E(s,t),r?.();}catch(s){console.warn("[Flexium] Hydration mismatch, falling back to full render:",s),i?.(s),t.innerHTML="",import('./render-ZDUF6JTQ.mjs').then(({render:p})=>{p(e,t);});}finally{l=null;}}function T(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function E(e,t){if(e==null||typeof e=="boolean")return F(),null;if(typeof e=="string"||typeof e=="number")return j(String(e));if(Array.isArray(e)){let o=[];for(let n of e){let r=E(n,t);r&&(Array.isArray(r)?o.push(...r):o.push(r));}return o}if(typeof e=="function")return M({type:e,props:{},children:[],key:void 0},t);if(typeof e=="object"&&T(e)){if(typeof e.type=="string")return R(e);if(typeof e.type=="function")return M(e,t)}return null}function F(){for(;l&&l.nodeType===Node.TEXT_NODE&&(!l.textContent||l.textContent.trim()==="");)l=l.nextSibling;}function j(e){F();let t=l;if(!t)return null;if(t.nodeType!==Node.TEXT_NODE){if(e.trim()==="")return null;throw new Error(`Hydration mismatch: expected text node "${e}", got ${t.nodeName}`)}return l=t.nextSibling,t}function R(e){F();let t=l,o=e.type;if(!t||t.nodeType!==Node.ELEMENT_NODE)throw new Error(`Hydration mismatch: expected element <${o}>, got ${t?.nodeName||"nothing"}`);if(t.tagName.toLowerCase()!==o.toLowerCase())throw new Error(`Hydration mismatch: expected <${o}>, got <${t.tagName.toLowerCase()}>`);if(e.props){for(let[n,r]of Object.entries(e.props))if(n==="ref")typeof r=="function"?r(t):r&&typeof r=="object"&&"current"in r&&(r.current=t);else if(n.startsWith("on")&&typeof r=="function"){let i=n.slice(2).toLowerCase();t.addEventListener(i,r),t.__eventHandlers||(t.__eventHandlers={}),t.__eventHandlers[i]=r;}}if(l=t.nextSibling,e.children&&e.children.length>0){let n=l;l=t.firstChild;for(let r of e.children)E(r,t);l=n;}return t}function M(e,t){let o=e.type,n={...e.props};e.children&&e.children.length>0&&(n.children=e.children.length===1?e.children[0]:e.children);let r=o._contextId,i=r!==void 0,s;i&&(s=g(r,n.value)),P.has(t)||P.set(t,new Map);let p=P.get(t),C=e.key!==void 0,u;if(C)u=e.key;else {let y=0,f=o.name||"anonymous";p.forEach((N,x)=>{typeof x=="string"&&x.startsWith(`__auto_${f}_`)&&y++;}),u=`__auto_${f}_${y}`;}let a$1={hooks:[],hookIndex:0,nodes:[],parent:t,fnode:e,props:n,key:u,children:new Set,parentInstance:h||void 0};h&&h.children.add(a$1),p.set(u,a$1);let c=h;h=a$1;try{let y=a(a$1,()=>o(n)),f=E(y,t);a$1.nodes=f?Array.isArray(f)?f:[f]:[];let N=!0,x=()=>{if(N){N=!1;return}let D=a$1.props;a(a$1,()=>o(D));};return a$1.renderFn=x,b$1(x),a$1.nodes}finally{h=c,i&&h$1(r,s);}}function _(e){let{target:t,children:o}=e,n=b$2(()=>({container:null,mounted:false}));return c(({onCleanup:r})=>{let i=null;if(typeof t=="string"?i=document.querySelector(t):t instanceof HTMLElement&&(i=t),!i){console.warn("[Flexium Portal] Target container not found:",t);return}let s=document.createElement("div");s.setAttribute("data-flexium-portal","true"),i.appendChild(s),n.container=s,n.mounted=true,b$3(o,s),r(()=>{s.parentNode&&s.parentNode.removeChild(s),n.container=null,n.mounted=false;});},[t,o]),null}var K={register:()=>{},hasBoundary:false},v=new e(K);function b(){let[e]=c(v);return e}function z(e){let{fallback:t,children:o}=e,n=b$2(()=>new Set),[,r]=c(0),[i,s]=c(false),C={register:a=>{n.has(a)||(n.add(a),r(c=>c+1),s(true),a.finally(()=>{n.delete(a),r(c=>{let y=c-1;return y===0&&s(false),y});}));},hasBoundary:true},u=i?t:o;return {type:v.Provider,props:{value:C},children:[u],key:void 0}}function V(e){let{fallback:t,onError:o,children:n,resetKey:r}=e,[i,s]=c({error:null,info:null}),p=b$2(()=>({current:r}));r!==p.current&&(p.current=r,i.error!==null&&s({error:null,info:null}));if(i.error)return typeof t=="function"?t(i.error,i.info):t;try{return n}finally{}}function $(e){let t=null,o=null,n=null,r=i=>{if(t)return t(i);if(n)throw n;let s=b();return o||(o=e().then(p=>{t=p.default;}).catch(p=>{n=p instanceof Error?p:new Error(String(p));})),s.hasBoundary&&s.register(o),null};return r._lazy=true,r._loader=e,r}export{V as ErrorBoundary,_ as Portal,z as Suspense,A as f,W as hydrate,$ as lazy};//# sourceMappingURL=dom.mjs.map
2
2
  //# sourceMappingURL=dom.mjs.map
package/dist/dom.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dom/f.ts","../src/dom/hydrate.ts","../src/dom/components/Portal.tsx","../src/dom/components/suspenseContext.ts","../src/dom/components/Suspense.tsx","../src/dom/components/ErrorBoundary.tsx","../src/dom/components/lazy.ts"],"names":["f","type","props","children","hydrationCursor","hydratedInstanceRegistry","currentHydratingInstance","hydrate","app","container","options","state","onHydrated","onMismatch","fnode","isFNode","hydrateNode","error","render","value","parent","skipEmptyTextNodes","hydrateTextNode","nodes","child","result","hydrateComponent","hydrateElement","text","current","tag","key","eventName","savedCursor","Component","contextId","isProvider","prevContextValue","pushContext","parentRegistry","hasExplicitKey","instanceCount","componentName","_","k","instance","previousHydratingInstance","runWithComponent","isFirstRender","renderFn","currentProps","unsafeEffect","popContext","Portal","target","portalState","hook","use","onCleanup","portalWrapper","defaultValue","SuspenseCtx","Context","suspenseContext","Suspense","fallback","pendingSet","setPendingCount","showFallback","setShowFallback","contextValue","promise","newCount","content","ErrorBoundary","onError","resetKey","errorState","setErrorState","prevResetKeyRef","lazy","loader","resolved","LazyWrapper","suspense","module","err"],"mappings":"sOAKO,SAASA,CAAAA,CACZC,CAAAA,CACAC,CAAAA,CAAAA,GACGC,CAAAA,CACE,CACL,OAAO,CACH,IAAA,CAAAF,CAAAA,CACA,KAAA,CAAOC,CAAAA,EAAS,GAChB,QAAA,CAAAC,CAAAA,CACA,GAAA,CAAKD,CAAAA,EAAO,GAChB,CACJ,CCTA,IACIE,CAAAA,CAA+B,IAAA,CAkC7BC,EAA2B,IAAI,OAAA,CACjCC,CAAAA,CAAwD,KAarD,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0B,EAAC,CACrB,CACN,GAAM,CAAE,MAAAC,CAAAA,CAAO,UAAA,CAAAC,CAAAA,CAAY,UAAA,CAAAC,CAAW,CAAA,CAAIH,CAAAA,CAO1CN,CAAAA,CAAkBK,CAAAA,CAAU,WAE5B,GAAI,CAEF,IAAIK,CAAAA,CACA,OAAON,CAAAA,EAAQ,UAAA,EAAc,CAACO,CAAAA,CAAQP,CAAG,CAAA,CAC3CM,CAAAA,CAAQ,CAAE,IAAA,CAAMN,EAAK,KAAA,CAAO,EAAC,CAAG,QAAA,CAAU,EAAC,CAAG,GAAA,CAAK,KAAA,CAAU,CAAA,CAE7DM,CAAAA,CAAQN,CAAAA,CAIVQ,CAAAA,CAAYF,CAAAA,CAAOL,CAAS,EAE5BG,CAAAA,KACF,CAAA,MAASK,CAAAA,CAAO,CAEd,OAAA,CAAQ,IAAA,CAAK,4DAA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AA,CACF,OAAOA,CAAAA,CAAShF,CAAK,CAAA,CAIvB,GAAIe,EACF,MAAMA,CAAAA,CAIR,IAAMmE,CAAAA,CAAWrB,CAAAA,GAGjB,OAAKQ,CAAAA,GACHA,CAAAA,CAAUU,CAAAA,EAAO,CACd,IAAA,CAAKI,GAAU,CACdH,CAAAA,CAAWG,EAAO,QACpB,CAAC,EACA,KAAA,CAAMC,CAAAA,EAAO,CACZrE,CAAAA,CAAQqE,CAAAA,YAAe,KAAA,CAAQA,EAAM,IAAI,KAAA,CAAM,OAAOA,CAAG,CAAC,EAC5D,CAAC,CAAA,CAAA,CAIDF,CAAAA,CAAS,WAAA,EACXA,CAAAA,CAAS,QAAA,CAASb,CAAO,CAAA,CAIpB,IACT,EAGC,OAACY,CAAAA,CAAiC,MAAQ,IAAA,CACzCA,CAAAA,CAAiC,OAAA,CAAUF,CAAAA,CAEtCE,CACT","file":"dom.mjs","sourcesContent":["import type { FNode } from './types'\n\n/**\n * f() - Create FNodes without JSX\n */\nexport function f(\n type: string | Function,\n props?: any,\n ...children: any[]\n): FNode {\n return {\n type,\n props: props || {},\n children,\n key: props?.key\n }\n}\n","import type { FNode, FNodeChild } from './types'\nimport type { SerializedState } from '../server/types'\nimport { runWithComponent, type ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\nimport { unsafeEffect } from '../core/lifecycle'\n\n// Hydration state\nlet isHydrating = false\nlet hydrationCursor: Node | null = null\nlet hydrationState: SerializedState | null = null\n\nexport interface HydrateOptions {\n /**\n * Serialized state from server\n * Typically embedded in HTML as JSON script tag\n */\n state?: SerializedState\n\n /**\n * Called when hydration completes successfully\n */\n onHydrated?: () => void\n\n /**\n * Called when hydration fails (falls back to full render)\n */\n onMismatch?: (error: Error) => void\n}\n\n// Extended ComponentInstance for DOM tracking (same as render.ts)\ninterface DOMComponentInstance extends ComponentInstance {\n nodes: Node[]\n parent: HTMLElement\n fnode: any\n props: any\n key?: any\n renderFn?: () => void\n children: Set<DOMComponentInstance>\n parentInstance?: DOMComponentInstance\n}\n\n// Registry for hydrated components\nconst hydratedInstanceRegistry = new WeakMap<HTMLElement, Map<any, DOMComponentInstance>>()\nlet currentHydratingInstance: DOMComponentInstance | null = null\n\nexport function getIsHydrating(): boolean {\n return isHydrating\n}\n\nexport function getHydrationState(): SerializedState | null {\n return hydrationState\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n */\nexport function hydrate(\n app: FNodeChild | (() => FNodeChild),\n container: HTMLElement,\n options: HydrateOptions = {}\n): void {\n const { state, onHydrated, onMismatch } = options\n\n // Store state for rehydration\n hydrationState = state || null\n\n // Initialize hydration mode\n isHydrating = true\n hydrationCursor = container.firstChild\n\n try {\n // Normalize input\n let fnode: FNodeChild\n if (typeof app === 'function' && !isFNode(app)) {\n fnode = { type: app, props: {}, children: [], key: undefined }\n } else {\n fnode = app\n }\n\n // Hydrate the tree\n hydrateNode(fnode, container)\n\n onHydrated?.()\n } catch (error) {\n // Hydration mismatch - fall back to full render\n console.warn('[Flexium] Hydration mismatch, falling back to full render:', error)\n onMismatch?.(error as Error)\n\n // Clear and re-render\n container.innerHTML = ''\n // Import dynamically to avoid circular deps\n import('./render').then(({ render }) => {\n render(app, container)\n })\n } finally {\n isHydrating = false\n hydrationCursor = null\n hydrationState = null\n }\n}\n\nfunction isFNode(value: any): value is FNode {\n return value && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction hydrateNode(fnode: FNodeChild, parent: HTMLElement): Node | Node[] | null {\n // Null/undefined/boolean -> skip empty text nodes\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n // Server might have rendered an empty text node\n skipEmptyTextNodes()\n return null\n }\n\n // String/number -> expect text node\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n return hydrateTextNode(String(fnode))\n }\n\n // Array -> hydrate each child\n if (Array.isArray(fnode)) {\n const nodes: Node[] = []\n for (const child of fnode) {\n const result = hydrateNode(child, parent)\n if (result) {\n if (Array.isArray(result)) {\n nodes.push(...result)\n } else {\n nodes.push(result)\n }\n }\n }\n return nodes\n }\n\n // Function (standalone) -> wrap in FNode and hydrate\n if (typeof fnode === 'function') {\n const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n return hydrateComponent(wrappedFnode, parent)\n }\n\n // Object (FNode)\n if (typeof fnode === 'object' && isFNode(fnode)) {\n if (typeof fnode.type === 'string') {\n return hydrateElement(fnode)\n }\n\n if (typeof fnode.type === 'function') {\n return hydrateComponent(fnode, parent)\n }\n }\n\n return null\n}\n\nfunction skipEmptyTextNodes(): void {\n while (\n hydrationCursor &&\n hydrationCursor.nodeType === Node.TEXT_NODE &&\n (!hydrationCursor.textContent || hydrationCursor.textContent.trim() === '')\n ) {\n hydrationCursor = hydrationCursor.nextSibling\n }\n}\n\nfunction hydrateTextNode(text: string): Node | null {\n skipEmptyTextNodes()\n\n const current = hydrationCursor\n\n if (!current) {\n // No node to hydrate - this is okay for conditional rendering\n return null\n }\n\n if (current.nodeType !== Node.TEXT_NODE) {\n // Try to find a text node nearby (whitespace handling)\n if (text.trim() === '') {\n return null\n }\n throw new Error(`Hydration mismatch: expected text node \"${text}\", got ${current.nodeName}`)\n }\n\n // Update cursor\n hydrationCursor = current.nextSibling\n\n return current\n}\n\nfunction hydrateElement(fnode: FNode): Node {\n skipEmptyTextNodes()\n\n const current = hydrationCursor as Element\n const tag = fnode.type as string\n\n // Validate element type\n if (!current || current.nodeType !== Node.ELEMENT_NODE) {\n throw new Error(`Hydration mismatch: expected element <${tag}>, got ${current?.nodeName || 'nothing'}`)\n }\n\n if (current.tagName.toLowerCase() !== tag.toLowerCase()) {\n throw new Error(`Hydration mismatch: expected <${tag}>, got <${current.tagName.toLowerCase()}>`)\n }\n\n // Attach event handlers and refs (don't modify DOM structure)\n if (fnode.props) {\n for (const [key, value] of Object.entries(fnode.props)) {\n if (key === 'ref') {\n if (typeof value === 'function') {\n value(current)\n } else if (value && typeof value === 'object' && 'current' in value) {\n value.current = current\n }\n } else if (key.startsWith('on') && typeof value === 'function') {\n const eventName = key.slice(2).toLowerCase()\n current.addEventListener(eventName, value as EventListener)\n\n // Store for reconciliation\n if (!(current as any).__eventHandlers) {\n (current as any).__eventHandlers = {}\n }\n (current as any).__eventHandlers[eventName] = value\n }\n }\n }\n\n // Move cursor past this element\n hydrationCursor = current.nextSibling\n\n // Hydrate children\n if (fnode.children && fnode.children.length > 0) {\n const savedCursor = hydrationCursor\n\n hydrationCursor = current.firstChild\n\n for (const child of fnode.children) {\n hydrateNode(child, current as HTMLElement)\n }\n\n hydrationCursor = savedCursor\n }\n\n return current\n}\n\nfunction hydrateComponent(fnode: FNode, parent: HTMLElement): Node | Node[] | null {\n const Component = fnode.type as Function\n\n // Merge props\n const props = { ...fnode.props }\n if (fnode.children && fnode.children.length > 0) {\n props.children = fnode.children.length === 1\n ? fnode.children[0]\n : fnode.children\n }\n\n // Handle context providers\n const contextId = (Component as any)._contextId\n const isProvider = contextId !== undefined\n let prevContextValue: any\n\n if (isProvider) {\n prevContextValue = pushContext(contextId, props.value)\n }\n\n // Generate key (same logic as render.ts)\n if (!hydratedInstanceRegistry.has(parent)) {\n hydratedInstanceRegistry.set(parent, new Map())\n }\n const parentRegistry = hydratedInstanceRegistry.get(parent)!\n\n const hasExplicitKey = fnode.key !== undefined\n let key: any\n if (hasExplicitKey) {\n key = fnode.key\n } else {\n let instanceCount = 0\n const componentName = (Component as any).name || 'anonymous'\n parentRegistry.forEach((_, k) => {\n if (typeof k === 'string' && k.startsWith(`__auto_${componentName}_`)) {\n instanceCount++\n }\n })\n key = `__auto_${componentName}_${instanceCount}`\n }\n\n // Create component instance\n const instance: DOMComponentInstance = {\n hooks: [],\n hookIndex: 0,\n nodes: [],\n parent,\n fnode,\n props,\n key,\n children: new Set(),\n parentInstance: currentHydratingInstance || undefined\n }\n\n if (currentHydratingInstance) {\n currentHydratingInstance.children.add(instance)\n }\n\n parentRegistry.set(key, instance)\n\n const previousHydratingInstance = currentHydratingInstance\n currentHydratingInstance = instance\n\n try {\n // First render during hydration - just match DOM\n const result = runWithComponent(instance, () => Component(props))\n const nodes = hydrateNode(result, parent)\n instance.nodes = nodes ? (Array.isArray(nodes) ? nodes : [nodes]) : []\n\n // Set up reactive re-rendering for future updates\n let isFirstRender = true\n const renderFn = () => {\n if (isFirstRender) {\n isFirstRender = false\n return // Skip first render, already done during hydration\n }\n\n // Re-render logic (same as render.ts but simplified)\n const currentProps = instance.props\n runWithComponent(instance, () => Component(currentProps))\n\n // For subsequent renders, use full render path\n // This will be handled by the normal reconciliation\n }\n\n instance.renderFn = renderFn\n unsafeEffect(renderFn)\n\n return instance.nodes\n } finally {\n currentHydratingInstance = previousHydratingInstance\n\n if (isProvider) {\n popContext(contextId, prevContextValue)\n }\n }\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { render } from '../render'\nimport type { PortalProps } from './types'\n\n/**\n * Portal component that renders children into a different DOM node\n *\n * @example\n * ```tsx\n * function Modal({ isOpen, onClose, children }) {\n * if (!isOpen) return null\n *\n * return (\n * <Portal target={document.body}>\n * <div class=\"modal-backdrop\" onClick={onClose}>\n * <div class=\"modal-content\" onClick={e => e.stopPropagation()}>\n * {children}\n * </div>\n * </div>\n * </Portal>\n * )\n * }\n * ```\n */\nexport function Portal(props: PortalProps): null {\n const { target, children } = props\n\n // Store rendered container for cleanup\n const portalState = hook(() => ({\n container: null as HTMLElement | null,\n mounted: false\n }))\n\n use(({ onCleanup }) => {\n // Resolve target container\n let container: HTMLElement | null = null\n\n if (typeof target === 'string') {\n container = document.querySelector(target)\n } else if (target instanceof HTMLElement) {\n container = target\n }\n\n if (!container) {\n console.warn('[Flexium Portal] Target container not found:', target)\n return\n }\n\n // Create a wrapper div to contain portal content\n const portalWrapper = document.createElement('div')\n portalWrapper.setAttribute('data-flexium-portal', 'true')\n container.appendChild(portalWrapper)\n\n portalState.container = portalWrapper\n portalState.mounted = true\n\n // Render children into the portal wrapper\n render(children, portalWrapper)\n\n // Cleanup function\n onCleanup(() => {\n if (portalWrapper.parentNode) {\n portalWrapper.parentNode.removeChild(portalWrapper)\n }\n portalState.container = null\n portalState.mounted = false\n })\n }, [target, children])\n\n // Portal renders nothing in its original location\n return null\n}\n","import { Context } from '../../core/context'\nimport { use } from '../../core/use'\nimport type { SuspenseContextValue } from './types'\n\nconst defaultValue: SuspenseContextValue = {\n register: () => {},\n hasBoundary: false\n}\n\nexport const SuspenseCtx = new Context<SuspenseContextValue>(defaultValue)\n\nexport function suspenseContext(): SuspenseContextValue {\n const [value] = use(SuspenseCtx)\n return value\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { SuspenseCtx } from './suspenseContext'\nimport type { SuspenseProps, SuspenseContextValue } from './types'\nimport type { FNodeChild } from '../types'\n\n/**\n * Suspense component that shows fallback while children are loading\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function Suspense(props: SuspenseProps): FNodeChild {\n const { fallback, children } = props\n\n // Track pending promises using hook for mutable Set\n const pendingSet = hook(() => new Set<Promise<any>>())\n const [, setPendingCount] = use(0)\n const [showFallback, setShowFallback] = use(false)\n\n // Register function for lazy components\n const register = (promise: Promise<any>) => {\n if (!pendingSet.has(promise)) {\n // Add to pending set\n pendingSet.add(promise)\n setPendingCount(c => c + 1)\n setShowFallback(true)\n\n // Wait for resolution\n promise.finally(() => {\n pendingSet.delete(promise)\n setPendingCount(c => {\n const newCount = c - 1\n if (newCount === 0) {\n setShowFallback(false)\n }\n return newCount\n })\n })\n }\n }\n\n const contextValue: SuspenseContextValue = {\n register,\n hasBoundary: true\n }\n\n // Render fallback or children based on pending state\n const content = showFallback ? fallback : children\n\n // Wrap content with Suspense context provider\n return {\n type: SuspenseCtx.Provider,\n props: { value: contextValue },\n children: [content],\n key: undefined\n } as any\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport type { FNodeChild } from '../types'\nimport type { ErrorInfo, ErrorBoundaryProps } from './types'\n\n// Component name stack for error messages\nlet componentNameStack: string[] = []\n\nexport function pushComponentName(name: string): void {\n componentNameStack.push(name)\n}\n\nexport function popComponentName(): void {\n componentNameStack.pop()\n}\n\nexport function getComponentStack(): string {\n return componentNameStack\n .map(name => ` at ${name}`)\n .reverse()\n .join('\\n')\n}\n\n// Stack of error boundaries for nested error propagation\ninterface ErrorBoundaryInstance {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => void\n}\n\nlet errorBoundaryStack: ErrorBoundaryInstance[] = []\n\nexport function pushErrorBoundary(instance: ErrorBoundaryInstance): void {\n errorBoundaryStack.push(instance)\n}\n\nexport function popErrorBoundary(): void {\n errorBoundaryStack.pop()\n}\n\nexport function getNearestErrorBoundary(): ErrorBoundaryInstance | null {\n return errorBoundaryStack[errorBoundaryStack.length - 1] || null\n}\n\n/**\n * ErrorBoundary component that catches errors in its children and displays fallback UI\n *\n * @example\n * ```tsx\n * <ErrorBoundary\n * fallback={(error, info) => <div>Error: {error.message}</div>}\n * onError={(error, info) => console.error(error)}\n * >\n * <App />\n * </ErrorBoundary>\n * ```\n */\nexport function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild {\n const { fallback, onError, children, resetKey } = props\n\n // Error state\n const [errorState, setErrorState] = use<{\n error: Error | null\n info: ErrorInfo | null\n }>({ error: null, info: null })\n\n // Track reset key changes to clear error\n const prevResetKeyRef = hook(() => ({ current: resetKey }))\n\n if (resetKey !== prevResetKeyRef.current) {\n prevResetKeyRef.current = resetKey\n if (errorState.error !== null) {\n setErrorState({ error: null, info: null })\n }\n }\n\n // Error boundary instance\n const boundaryInstance: ErrorBoundaryInstance = {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => {\n const info: ErrorInfo = {\n componentStack: getComponentStack(),\n phase\n }\n\n // Call error callback\n onError?.(error, info)\n\n // Update error state (triggers re-render with fallback)\n setErrorState({ error, info })\n }\n }\n\n // If we have an error, render fallback\n if (errorState.error) {\n if (typeof fallback === 'function') {\n return fallback(errorState.error, errorState.info!)\n }\n return fallback\n }\n\n // Push boundary onto stack for children to use\n pushErrorBoundary(boundaryInstance)\n\n try {\n // Return children - they will be rendered with this boundary active\n return children\n } finally {\n popErrorBoundary()\n }\n}\n","import { suspenseContext } from './suspenseContext'\nimport type { FNodeChild } from '../types'\nimport type { LazyComponent } from './types'\n\n/**\n * Creates a lazy-loaded component for code splitting\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n * const Settings = lazy(() => import('./Settings'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function lazy<P = {}>(\n loader: () => Promise<{ default: (props: P) => FNodeChild }>\n): LazyComponent<P> {\n // Shared state across all instances\n let resolved: ((props: P) => FNodeChild) | null = null\n let promise: Promise<any> | null = null\n let error: Error | null = null\n\n // The wrapper component\n const LazyWrapper = (props: P): FNodeChild => {\n // If already resolved, render immediately\n if (resolved) {\n return resolved(props)\n }\n\n // If error occurred, throw it (will be caught by ErrorBoundary)\n if (error) {\n throw error\n }\n\n // Get suspense context\n const suspense = suspenseContext()\n\n // Start loading if not already\n if (!promise) {\n promise = loader()\n .then(module => {\n resolved = module.default\n })\n .catch(err => {\n error = err instanceof Error ? err : new Error(String(err))\n })\n }\n\n // Register with suspense boundary if available\n if (suspense.hasBoundary) {\n suspense.register(promise)\n }\n\n // Return null - Suspense will show fallback\n return null\n }\n\n // Mark as lazy component\n ;(LazyWrapper as LazyComponent<P>)._lazy = true\n ;(LazyWrapper as LazyComponent<P>)._loader = loader\n\n return LazyWrapper as LazyComponent<P>\n}\n"]}
1
+ {"version":3,"sources":["../src/dom/f.ts","../src/dom/hydrate.ts","../src/dom/components/Portal.tsx","../src/dom/components/suspenseContext.ts","../src/dom/components/Suspense.tsx","../src/dom/components/ErrorBoundary.tsx","../src/dom/components/lazy.ts"],"names":["f","type","props","children","hydrationCursor","hydratedInstanceRegistry","currentHydratingInstance","hydrate","app","container","options","state","onHydrated","onMismatch","fnode","isFNode","hydrateNode","error","render","value","parent","skipEmptyTextNodes","hydrateTextNode","nodes","child","result","hydrateComponent","hydrateElement","text","current","tag","key","eventName","savedCursor","Component","contextId","isProvider","prevContextValue","pushContext","parentRegistry","hasExplicitKey","instanceCount","componentName","_","k","instance","previousHydratingInstance","runWithComponent","isFirstRender","renderFn","currentProps","unsafeEffect","popContext","Portal","target","portalState","hook","use","onCleanup","portalWrapper","defaultValue","SuspenseCtx","Context","suspenseContext","Suspense","fallback","pendingSet","setPendingCount","showFallback","setShowFallback","contextValue","promise","newCount","content","ErrorBoundary","onError","resetKey","errorState","setErrorState","prevResetKeyRef","lazy","loader","resolved","LazyWrapper","suspense","module","err"],"mappings":"sOAKO,SAASA,CAAAA,CACZC,CAAAA,CACAC,CAAAA,CAAAA,GACGC,CAAAA,CACE,CACL,OAAO,CACH,IAAA,CAAAF,CAAAA,CACA,KAAA,CAAOC,CAAAA,EAAS,GAChB,QAAA,CAAAC,CAAAA,CACA,GAAA,CAAKD,CAAAA,EAAO,GAChB,CACJ,CCTA,IACIE,CAAAA,CAA+B,IAAA,CAkC7BC,EAA2B,IAAI,OAAA,CACjCC,CAAAA,CAAwD,KAarD,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0B,EAAC,CACrB,CACN,GAAM,CAAE,MAAAC,CAAAA,CAAO,UAAA,CAAAC,CAAAA,CAAY,UAAA,CAAAC,CAAW,CAAA,CAAIH,CAAAA,CAO1CN,CAAAA,CAAkBK,CAAAA,CAAU,WAE5B,GAAI,CAEF,IAAIK,CAAAA,CACA,OAAON,CAAAA,EAAQ,UAAA,EAAc,CAACO,CAAAA,CAAQP,CAAG,CAAA,CAC3CM,CAAAA,CAAQ,CAAE,IAAA,CAAMN,EAAK,KAAA,CAAO,EAAC,CAAG,QAAA,CAAU,E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,CAAA,OAAE,CAEF,CACF,CCtFO,SAAS6E,EACdC,CAAAA,CACkB,CAElB,IAAIC,CAAAA,CAA8C,IAAA,CAC9CX,CAAAA,CAA+B,KAC/BtD,CAAAA,CAAsB,IAAA,CAGpBkE,EAAejF,CAAAA,EAAyB,CAE5C,GAAIgF,CAAAA,CACF,OAAOA,CAAAA,CAAShF,CAAK,CAAA,CAIvB,GAAIe,EACF,MAAMA,CAAAA,CAIR,IAAMmE,CAAAA,CAAWrB,CAAAA,GAGjB,OAAKQ,CAAAA,GACHA,CAAAA,CAAUU,CAAAA,EAAO,CACd,IAAA,CAAKI,GAAU,CACdH,CAAAA,CAAWG,EAAO,QACpB,CAAC,EACA,KAAA,CAAMC,CAAAA,EAAO,CACZrE,CAAAA,CAAQqE,CAAAA,YAAe,KAAA,CAAQA,EAAM,IAAI,KAAA,CAAM,OAAOA,CAAG,CAAC,EAC5D,CAAC,CAAA,CAAA,CAIDF,CAAAA,CAAS,WAAA,EACXA,CAAAA,CAAS,QAAA,CAASb,CAAO,CAAA,CAIpB,IACT,EAGC,OAACY,CAAAA,CAAiC,MAAQ,IAAA,CACzCA,CAAAA,CAAiC,OAAA,CAAUF,CAAAA,CAEtCE,CACT","file":"dom.mjs","sourcesContent":["import type { FNode } from './types'\n\n/**\n * f() - Create FNodes without JSX\n */\nexport function f(\n type: string | Function,\n props?: any,\n ...children: any[]\n): FNode {\n return {\n type,\n props: props || {},\n children,\n key: props?.key\n }\n}\n","import type { FNode, FNodeChild } from './types'\nimport type { SerializedState } from '../server/types'\nimport { runWithComponent, type ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\nimport { unsafeEffect } from '../core/lifecycle'\n\n// Hydration state\nlet isHydrating = false\nlet hydrationCursor: Node | null = null\nlet hydrationState: SerializedState | null = null\n\nexport interface HydrateOptions {\n /**\n * Serialized state from server\n * Typically embedded in HTML as JSON script tag\n */\n state?: SerializedState\n\n /**\n * Called when hydration completes successfully\n */\n onHydrated?: () => void\n\n /**\n * Called when hydration fails (falls back to full render)\n */\n onMismatch?: (error: Error) => void\n}\n\n// Extended ComponentInstance for DOM tracking (same as render.ts)\ninterface DOMComponentInstance extends ComponentInstance {\n nodes: Node[]\n parent: HTMLElement\n fnode: any\n props: any\n key?: any\n renderFn?: () => void\n children: Set<DOMComponentInstance>\n parentInstance?: DOMComponentInstance\n}\n\n// Registry for hydrated components\nconst hydratedInstanceRegistry = new WeakMap<HTMLElement, Map<any, DOMComponentInstance>>()\nlet currentHydratingInstance: DOMComponentInstance | null = null\n\nexport function getIsHydrating(): boolean {\n return isHydrating\n}\n\nexport function getHydrationState(): SerializedState | null {\n return hydrationState\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n */\nexport function hydrate(\n app: FNodeChild | (() => FNodeChild),\n container: HTMLElement,\n options: HydrateOptions = {}\n): void {\n const { state, onHydrated, onMismatch } = options\n\n // Store state for rehydration\n hydrationState = state || null\n\n // Initialize hydration mode\n isHydrating = true\n hydrationCursor = container.firstChild\n\n try {\n // Normalize input\n let fnode: FNodeChild\n if (typeof app === 'function' && !isFNode(app)) {\n fnode = { type: app, props: {}, children: [], key: undefined }\n } else {\n fnode = app\n }\n\n // Hydrate the tree\n hydrateNode(fnode, container)\n\n onHydrated?.()\n } catch (error) {\n // Hydration mismatch - fall back to full render\n console.warn('[Flexium] Hydration mismatch, falling back to full render:', error)\n onMismatch?.(error as Error)\n\n // Clear and re-render\n container.innerHTML = ''\n // Import dynamically to avoid circular deps\n import('./render').then(({ render }) => {\n render(app, container)\n })\n } finally {\n isHydrating = false\n hydrationCursor = null\n hydrationState = null\n }\n}\n\nfunction isFNode(value: any): value is FNode {\n return value && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction hydrateNode(fnode: FNodeChild, parent: HTMLElement): Node | Node[] | null {\n // Null/undefined/boolean -> skip empty text nodes\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n // Server might have rendered an empty text node\n skipEmptyTextNodes()\n return null\n }\n\n // String/number -> expect text node\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n return hydrateTextNode(String(fnode))\n }\n\n // Array -> hydrate each child\n if (Array.isArray(fnode)) {\n const nodes: Node[] = []\n for (const child of fnode) {\n const result = hydrateNode(child, parent)\n if (result) {\n if (Array.isArray(result)) {\n nodes.push(...result)\n } else {\n nodes.push(result)\n }\n }\n }\n return nodes\n }\n\n // Function (standalone) -> wrap in FNode and hydrate\n if (typeof fnode === 'function') {\n const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n return hydrateComponent(wrappedFnode, parent)\n }\n\n // Object (FNode)\n if (typeof fnode === 'object' && isFNode(fnode)) {\n if (typeof fnode.type === 'string') {\n return hydrateElement(fnode)\n }\n\n if (typeof fnode.type === 'function') {\n return hydrateComponent(fnode, parent)\n }\n }\n\n return null\n}\n\nfunction skipEmptyTextNodes(): void {\n while (\n hydrationCursor &&\n hydrationCursor.nodeType === Node.TEXT_NODE &&\n (!hydrationCursor.textContent || hydrationCursor.textContent.trim() === '')\n ) {\n hydrationCursor = hydrationCursor.nextSibling\n }\n}\n\nfunction hydrateTextNode(text: string): Node | null {\n skipEmptyTextNodes()\n\n const current = hydrationCursor\n\n if (!current) {\n // No node to hydrate - this is okay for conditional rendering\n return null\n }\n\n if (current.nodeType !== Node.TEXT_NODE) {\n // Try to find a text node nearby (whitespace handling)\n if (text.trim() === '') {\n return null\n }\n throw new Error(`Hydration mismatch: expected text node \"${text}\", got ${current.nodeName}`)\n }\n\n // Update cursor\n hydrationCursor = current.nextSibling\n\n return current\n}\n\nfunction hydrateElement(fnode: FNode): Node {\n skipEmptyTextNodes()\n\n const current = hydrationCursor as Element\n const tag = fnode.type as string\n\n // Validate element type\n if (!current || current.nodeType !== Node.ELEMENT_NODE) {\n throw new Error(`Hydration mismatch: expected element <${tag}>, got ${current?.nodeName || 'nothing'}`)\n }\n\n if (current.tagName.toLowerCase() !== tag.toLowerCase()) {\n throw new Error(`Hydration mismatch: expected <${tag}>, got <${current.tagName.toLowerCase()}>`)\n }\n\n // Attach event handlers and refs (don't modify DOM structure)\n if (fnode.props) {\n for (const [key, value] of Object.entries(fnode.props)) {\n if (key === 'ref') {\n if (typeof value === 'function') {\n value(current)\n } else if (value && typeof value === 'object' && 'current' in value) {\n value.current = current\n }\n } else if (key.startsWith('on') && typeof value === 'function') {\n const eventName = key.slice(2).toLowerCase()\n current.addEventListener(eventName, value as EventListener)\n\n // Store for reconciliation\n if (!(current as any).__eventHandlers) {\n (current as any).__eventHandlers = {}\n }\n (current as any).__eventHandlers[eventName] = value\n }\n }\n }\n\n // Move cursor past this element\n hydrationCursor = current.nextSibling\n\n // Hydrate children\n if (fnode.children && fnode.children.length > 0) {\n const savedCursor = hydrationCursor\n\n hydrationCursor = current.firstChild\n\n for (const child of fnode.children) {\n hydrateNode(child, current as HTMLElement)\n }\n\n hydrationCursor = savedCursor\n }\n\n return current\n}\n\nfunction hydrateComponent(fnode: FNode, parent: HTMLElement): Node | Node[] | null {\n const Component = fnode.type as Function\n\n // Merge props\n const props = { ...fnode.props }\n if (fnode.children && fnode.children.length > 0) {\n props.children = fnode.children.length === 1\n ? fnode.children[0]\n : fnode.children\n }\n\n // Handle context providers\n const contextId = (Component as any)._contextId\n const isProvider = contextId !== undefined\n let prevContextValue: any\n\n if (isProvider) {\n prevContextValue = pushContext(contextId, props.value)\n }\n\n // Generate key (same logic as render.ts)\n if (!hydratedInstanceRegistry.has(parent)) {\n hydratedInstanceRegistry.set(parent, new Map())\n }\n const parentRegistry = hydratedInstanceRegistry.get(parent)!\n\n const hasExplicitKey = fnode.key !== undefined\n let key: any\n if (hasExplicitKey) {\n key = fnode.key\n } else {\n let instanceCount = 0\n const componentName = (Component as any).name || 'anonymous'\n parentRegistry.forEach((_, k) => {\n if (typeof k === 'string' && k.startsWith(`__auto_${componentName}_`)) {\n instanceCount++\n }\n })\n key = `__auto_${componentName}_${instanceCount}`\n }\n\n // Create component instance\n const instance: DOMComponentInstance = {\n hooks: [],\n hookIndex: 0,\n nodes: [],\n parent,\n fnode,\n props,\n key,\n children: new Set(),\n parentInstance: currentHydratingInstance || undefined\n }\n\n if (currentHydratingInstance) {\n currentHydratingInstance.children.add(instance)\n }\n\n parentRegistry.set(key, instance)\n\n const previousHydratingInstance = currentHydratingInstance\n currentHydratingInstance = instance\n\n try {\n // First render during hydration - just match DOM\n const result = runWithComponent(instance, () => Component(props))\n const nodes = hydrateNode(result, parent)\n instance.nodes = nodes ? (Array.isArray(nodes) ? nodes : [nodes]) : []\n\n // Set up reactive re-rendering for future updates\n let isFirstRender = true\n const renderFn = () => {\n if (isFirstRender) {\n isFirstRender = false\n return // Skip first render, already done during hydration\n }\n\n // Re-render logic (same as render.ts but simplified)\n const currentProps = instance.props\n runWithComponent(instance, () => Component(currentProps))\n\n // For subsequent renders, use full render path\n // This will be handled by the normal reconciliation\n }\n\n instance.renderFn = renderFn\n unsafeEffect(renderFn)\n\n return instance.nodes\n } finally {\n currentHydratingInstance = previousHydratingInstance\n\n if (isProvider) {\n popContext(contextId, prevContextValue)\n }\n }\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { render } from '../render'\nimport type { PortalProps } from './types'\n\n/**\n * Portal component that renders children into a different DOM node\n *\n * @deprecated Use Portal from 'flexium-ui' instead:\n * ```tsx\n * import { Portal } from 'flexium-ui'\n * ```\n *\n * @example\n * ```tsx\n * function Modal({ isOpen, onClose, children }) {\n * if (!isOpen) return null\n *\n * return (\n * <Portal target={document.body}>\n * <div class=\"modal-backdrop\" onClick={onClose}>\n * <div class=\"modal-content\" onClick={e => e.stopPropagation()}>\n * {children}\n * </div>\n * </div>\n * </Portal>\n * )\n * }\n * ```\n */\nexport function Portal(props: PortalProps): null {\n const { target, children } = props\n\n // Store rendered container for cleanup\n const portalState = hook(() => ({\n container: null as HTMLElement | null,\n mounted: false\n }))\n\n use(({ onCleanup }) => {\n // Resolve target container\n let container: HTMLElement | null = null\n\n if (typeof target === 'string') {\n container = document.querySelector(target)\n } else if (target instanceof HTMLElement) {\n container = target\n }\n\n if (!container) {\n console.warn('[Flexium Portal] Target container not found:', target)\n return\n }\n\n // Create a wrapper div to contain portal content\n const portalWrapper = document.createElement('div')\n portalWrapper.setAttribute('data-flexium-portal', 'true')\n container.appendChild(portalWrapper)\n\n portalState.container = portalWrapper\n portalState.mounted = true\n\n // Render children into the portal wrapper\n render(children, portalWrapper)\n\n // Cleanup function\n onCleanup(() => {\n if (portalWrapper.parentNode) {\n portalWrapper.parentNode.removeChild(portalWrapper)\n }\n portalState.container = null\n portalState.mounted = false\n })\n }, [target, children])\n\n // Portal renders nothing in its original location\n return null\n}\n","import { Context } from '../../core/context'\nimport { use } from '../../core/use'\nimport type { SuspenseContextValue } from './types'\n\nconst defaultValue: SuspenseContextValue = {\n register: () => {},\n hasBoundary: false\n}\n\nexport const SuspenseCtx = new Context<SuspenseContextValue>(defaultValue)\n\nexport function suspenseContext(): SuspenseContextValue {\n const [value] = use(SuspenseCtx)\n return value\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { SuspenseCtx } from './suspenseContext'\nimport type { SuspenseProps, SuspenseContextValue } from './types'\nimport type { FNodeChild } from '../types'\n\n/**\n * Suspense component that shows fallback while children are loading\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function Suspense(props: SuspenseProps): FNodeChild {\n const { fallback, children } = props\n\n // Track pending promises using hook for mutable Set\n const pendingSet = hook(() => new Set<Promise<any>>())\n const [, setPendingCount] = use(0)\n const [showFallback, setShowFallback] = use(false)\n\n // Register function for lazy components\n const register = (promise: Promise<any>) => {\n if (!pendingSet.has(promise)) {\n // Add to pending set\n pendingSet.add(promise)\n setPendingCount(c => c + 1)\n setShowFallback(true)\n\n // Wait for resolution\n promise.finally(() => {\n pendingSet.delete(promise)\n setPendingCount(c => {\n const newCount = c - 1\n if (newCount === 0) {\n setShowFallback(false)\n }\n return newCount\n })\n })\n }\n }\n\n const contextValue: SuspenseContextValue = {\n register,\n hasBoundary: true\n }\n\n // Render fallback or children based on pending state\n const content = showFallback ? fallback : children\n\n // Wrap content with Suspense context provider\n return {\n type: SuspenseCtx.Provider,\n props: { value: contextValue },\n children: [content],\n key: undefined\n } as any\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport type { FNodeChild } from '../types'\nimport type { ErrorInfo, ErrorBoundaryProps } from './types'\n\n// Component name stack for error messages\nlet componentNameStack: string[] = []\n\nexport function pushComponentName(name: string): void {\n componentNameStack.push(name)\n}\n\nexport function popComponentName(): void {\n componentNameStack.pop()\n}\n\nexport function getComponentStack(): string {\n return componentNameStack\n .map(name => ` at ${name}`)\n .reverse()\n .join('\\n')\n}\n\n// Stack of error boundaries for nested error propagation\ninterface ErrorBoundaryInstance {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => void\n}\n\nlet errorBoundaryStack: ErrorBoundaryInstance[] = []\n\nexport function pushErrorBoundary(instance: ErrorBoundaryInstance): void {\n errorBoundaryStack.push(instance)\n}\n\nexport function popErrorBoundary(): void {\n errorBoundaryStack.pop()\n}\n\nexport function getNearestErrorBoundary(): ErrorBoundaryInstance | null {\n return errorBoundaryStack[errorBoundaryStack.length - 1] || null\n}\n\n/**\n * ErrorBoundary component that catches errors in its children and displays fallback UI\n *\n * @example\n * ```tsx\n * <ErrorBoundary\n * fallback={(error, info) => <div>Error: {error.message}</div>}\n * onError={(error, info) => console.error(error)}\n * >\n * <App />\n * </ErrorBoundary>\n * ```\n */\nexport function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild {\n const { fallback, onError, children, resetKey } = props\n\n // Error state\n const [errorState, setErrorState] = use<{\n error: Error | null\n info: ErrorInfo | null\n }>({ error: null, info: null })\n\n // Track reset key changes to clear error\n const prevResetKeyRef = hook(() => ({ current: resetKey }))\n\n if (resetKey !== prevResetKeyRef.current) {\n prevResetKeyRef.current = resetKey\n if (errorState.error !== null) {\n setErrorState({ error: null, info: null })\n }\n }\n\n // Error boundary instance\n const boundaryInstance: ErrorBoundaryInstance = {\n handleError: (error: Error, phase: 'render' | 'effect' | 'event') => {\n const info: ErrorInfo = {\n componentStack: getComponentStack(),\n phase\n }\n\n // Call error callback\n onError?.(error, info)\n\n // Update error state (triggers re-render with fallback)\n setErrorState({ error, info })\n }\n }\n\n // If we have an error, render fallback\n if (errorState.error) {\n if (typeof fallback === 'function') {\n return fallback(errorState.error, errorState.info!)\n }\n return fallback\n }\n\n // Push boundary onto stack for children to use\n pushErrorBoundary(boundaryInstance)\n\n try {\n // Return children - they will be rendered with this boundary active\n return children\n } finally {\n popErrorBoundary()\n }\n}\n","import { suspenseContext } from './suspenseContext'\nimport type { FNodeChild } from '../types'\nimport type { LazyComponent } from './types'\n\n/**\n * Creates a lazy-loaded component for code splitting\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n * const Settings = lazy(() => import('./Settings'))\n *\n * function App() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <Dashboard />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function lazy<P = {}>(\n loader: () => Promise<{ default: (props: P) => FNodeChild }>\n): LazyComponent<P> {\n // Shared state across all instances\n let resolved: ((props: P) => FNodeChild) | null = null\n let promise: Promise<any> | null = null\n let error: Error | null = null\n\n // The wrapper component\n const LazyWrapper = (props: P): FNodeChild => {\n // If already resolved, render immediately\n if (resolved) {\n return resolved(props)\n }\n\n // If error occurred, throw it (will be caught by ErrorBoundary)\n if (error) {\n throw error\n }\n\n // Get suspense context\n const suspense = suspenseContext()\n\n // Start loading if not already\n if (!promise) {\n promise = loader()\n .then(module => {\n resolved = module.default\n })\n .catch(err => {\n error = err instanceof Error ? err : new Error(String(err))\n })\n }\n\n // Register with suspense boundary if available\n if (suspense.hasBoundary) {\n suspense.register(promise)\n }\n\n // Return null - Suspense will show fallback\n return null\n }\n\n // Mark as lazy component\n ;(LazyWrapper as LazyComponent<P>)._lazy = true\n ;(LazyWrapper as LazyComponent<P>)._loader = loader\n\n return LazyWrapper as LazyComponent<P>\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- declare const VERSION = "0.14.4";
1
+ declare const VERSION = "0.15.0";
2
2
 
3
3
  export { VERSION };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const VERSION = "0.14.4";
1
+ declare const VERSION = "0.15.0";
2
2
 
3
3
  export { VERSION };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var o="0.14.4";exports.VERSION=o;//# sourceMappingURL=index.js.map
1
+ 'use strict';var o="0.15.0";exports.VERSION=o;//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"aAAO,IAAMA,CAAAA,CAAU","file":"index.js","sourcesContent":["export const VERSION = '0.14.4' // Bump version to signify rebuild\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"aAAO,IAAMA,CAAAA,CAAU","file":"index.js","sourcesContent":["export const VERSION = '0.15.0' // Bump version to signify rebuild\n"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var o="0.14.4";export{o as VERSION};//# sourceMappingURL=index.mjs.map
1
+ var o="0.15.0";export{o as VERSION};//# sourceMappingURL=index.mjs.map
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"AAAO,IAAMA,CAAAA,CAAU","file":"index.mjs","sourcesContent":["export const VERSION = '0.14.4' // Bump version to signify rebuild\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"AAAO,IAAMA,CAAAA,CAAU","file":"index.mjs","sourcesContent":["export const VERSION = '0.15.0' // Bump version to signify rebuild\n"]}