flexium 0.12.13 → 0.12.16

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 (100) hide show
  1. package/dist/canvas.d.cts +14 -13
  2. package/dist/canvas.d.ts +14 -13
  3. package/dist/canvas.js +1 -1
  4. package/dist/canvas.js.map +1 -1
  5. package/dist/canvas.mjs +1 -1
  6. package/dist/canvas.mjs.map +1 -1
  7. package/dist/chunk-3DKZ2J4D.mjs +2 -0
  8. package/dist/chunk-3DKZ2J4D.mjs.map +1 -0
  9. package/dist/chunk-5PNH2ARD.mjs +2 -0
  10. package/dist/chunk-5PNH2ARD.mjs.map +1 -0
  11. package/dist/{chunk-7BXR4ZFD.js → chunk-6VIRXD2Y.js} +2 -2
  12. package/dist/chunk-6VIRXD2Y.js.map +1 -0
  13. package/dist/chunk-6Z33DLMI.js +2 -0
  14. package/dist/chunk-6Z33DLMI.js.map +1 -0
  15. package/dist/chunk-E75BJDOQ.mjs +2 -0
  16. package/dist/chunk-E75BJDOQ.mjs.map +1 -0
  17. package/dist/chunk-IWFEXW4F.mjs +2 -0
  18. package/dist/chunk-IWFEXW4F.mjs.map +1 -0
  19. package/dist/chunk-JY6CE6RN.mjs +2 -0
  20. package/dist/chunk-JY6CE6RN.mjs.map +1 -0
  21. package/dist/chunk-LTT43APF.js +2 -0
  22. package/dist/chunk-LTT43APF.js.map +1 -0
  23. package/dist/chunk-PSKDIB7J.js +2 -0
  24. package/dist/chunk-PSKDIB7J.js.map +1 -0
  25. package/dist/chunk-UWFVCKRU.js +2 -0
  26. package/dist/chunk-UWFVCKRU.js.map +1 -0
  27. package/dist/chunk-WGKD63GN.mjs +2 -0
  28. package/dist/chunk-WGKD63GN.mjs.map +1 -0
  29. package/dist/chunk-YWTD32NA.js +2 -0
  30. package/dist/chunk-YWTD32NA.js.map +1 -0
  31. package/dist/core.d.cts +91 -15
  32. package/dist/core.d.ts +91 -15
  33. package/dist/core.js +1 -1
  34. package/dist/core.js.map +1 -1
  35. package/dist/core.mjs +1 -1
  36. package/dist/core.mjs.map +1 -1
  37. package/dist/dom.d.cts +154 -9
  38. package/dist/dom.d.ts +154 -9
  39. package/dist/dom.js +1 -1
  40. package/dist/dom.js.map +1 -1
  41. package/dist/dom.mjs +1 -1
  42. package/dist/dom.mjs.map +1 -1
  43. package/dist/index.d.cts +1 -1
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +1 -1
  48. package/dist/index.mjs.map +1 -1
  49. package/dist/interactive.d.cts +17 -16
  50. package/dist/interactive.d.ts +17 -16
  51. package/dist/interactive.js +1 -1
  52. package/dist/interactive.js.map +1 -1
  53. package/dist/interactive.mjs +1 -1
  54. package/dist/interactive.mjs.map +1 -1
  55. package/dist/jsx-dev-runtime.d.cts +1 -1
  56. package/dist/jsx-dev-runtime.d.ts +1 -1
  57. package/dist/jsx-runtime.d.cts +1 -1
  58. package/dist/jsx-runtime.d.ts +1 -1
  59. package/dist/metafile-cjs.json +1 -1
  60. package/dist/metafile-esm.json +1 -1
  61. package/dist/render-QZAFAGIM.js +2 -0
  62. package/dist/render-QZAFAGIM.js.map +1 -0
  63. package/dist/render-UIWHIMS2.mjs +2 -0
  64. package/dist/render-UIWHIMS2.mjs.map +1 -0
  65. package/dist/router.d.cts +1 -1
  66. package/dist/router.d.ts +1 -1
  67. package/dist/router.js +1 -1
  68. package/dist/router.js.map +1 -1
  69. package/dist/router.mjs +1 -1
  70. package/dist/router.mjs.map +1 -1
  71. package/dist/server.d.cts +17 -0
  72. package/dist/server.d.ts +17 -0
  73. package/dist/server.js +2 -0
  74. package/dist/server.js.map +1 -0
  75. package/dist/server.mjs +2 -0
  76. package/dist/server.mjs.map +1 -0
  77. package/dist/types-CxlS2F2j.d.cts +19 -0
  78. package/dist/types-CxlS2F2j.d.ts +19 -0
  79. package/dist/types-y2GGaXXk.d.cts +9 -0
  80. package/dist/types-y2GGaXXk.d.ts +9 -0
  81. package/package.json +6 -1
  82. package/dist/chunk-44RZHCII.mjs +0 -2
  83. package/dist/chunk-44RZHCII.mjs.map +0 -1
  84. package/dist/chunk-7BXR4ZFD.js.map +0 -1
  85. package/dist/chunk-APAMPY43.js +0 -2
  86. package/dist/chunk-APAMPY43.js.map +0 -1
  87. package/dist/chunk-CPJRQL2C.mjs +0 -2
  88. package/dist/chunk-CPJRQL2C.mjs.map +0 -1
  89. package/dist/chunk-ECB5HZOQ.mjs +0 -2
  90. package/dist/chunk-ECB5HZOQ.mjs.map +0 -1
  91. package/dist/chunk-ENWGYQNU.js +0 -2
  92. package/dist/chunk-ENWGYQNU.js.map +0 -1
  93. package/dist/chunk-IA4FEBFE.js +0 -2
  94. package/dist/chunk-IA4FEBFE.js.map +0 -1
  95. package/dist/chunk-LUREDEUB.mjs +0 -2
  96. package/dist/chunk-LUREDEUB.mjs.map +0 -1
  97. package/dist/chunk-LUW7DIEW.js +0 -2
  98. package/dist/chunk-LUW7DIEW.js.map +0 -1
  99. package/dist/chunk-S6WF3XNF.mjs +0 -2
  100. package/dist/chunk-S6WF3XNF.mjs.map +0 -1
package/dist/dom.d.cts CHANGED
@@ -1,12 +1,157 @@
1
- type FNodeChild = FNode | string | number | boolean | null | undefined | FNodeChild[] | (() => FNode);
2
- interface FNode {
3
- type: string | Function;
4
- props: Record<string, any>;
5
- children: FNodeChild[];
1
+ import { a as FNode, F as FNodeChild } from './types-y2GGaXXk.cjs';
2
+ import { S as SerializedState } from './types-CxlS2F2j.cjs';
3
+
4
+ /**
5
+ * f() - Create FNodes without JSX
6
+ */
7
+ declare function f(type: string | Function, props?: any, ...children: any[]): FNode;
8
+
9
+ declare function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[];
10
+ declare function render(app: any, container: HTMLElement): void;
11
+
12
+ interface HydrateOptions {
13
+ /**
14
+ * Serialized state from server
15
+ * Typically embedded in HTML as JSON script tag
16
+ */
17
+ state?: SerializedState;
18
+ /**
19
+ * Called when hydration completes successfully
20
+ */
21
+ onHydrated?: () => void;
22
+ /**
23
+ * Called when hydration fails (falls back to full render)
24
+ */
25
+ onMismatch?: (error: Error) => void;
26
+ }
27
+ /**
28
+ * Hydrate server-rendered HTML with client-side interactivity
29
+ */
30
+ declare function hydrate(app: FNodeChild | (() => FNodeChild), container: HTMLElement, options?: HydrateOptions): void;
31
+
32
+ interface PortalProps {
33
+ /** Target element or CSS selector to render children into */
34
+ target: HTMLElement | string;
35
+ /** Children to render in the portal */
36
+ children: FNodeChild;
37
+ /** Optional key for reconciliation */
6
38
  key?: any;
7
39
  }
8
- declare function render(app: any, container: HTMLElement): void;
9
- declare function f(type: string | Function, props?: any, ...children: any[]): any;
10
- declare function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[];
40
+ interface SuspenseProps {
41
+ /** Fallback UI to display while loading */
42
+ fallback: FNodeChild;
43
+ /** Children to render when loaded */
44
+ children: FNodeChild;
45
+ }
46
+ interface LazyComponent<P = any> {
47
+ (props: P): FNodeChild;
48
+ _lazy: true;
49
+ _loader: () => Promise<{
50
+ default: (props: P) => FNodeChild;
51
+ }>;
52
+ _resolved?: (props: P) => FNodeChild;
53
+ _promise?: Promise<any>;
54
+ _error?: Error;
55
+ }
56
+ interface SuspenseContextValue {
57
+ /** Register a pending promise with the suspense boundary */
58
+ register: (promise: Promise<any>) => void;
59
+ /** Whether there's an active suspense boundary */
60
+ hasBoundary: boolean;
61
+ }
62
+ interface ErrorInfo {
63
+ /** Component stack trace */
64
+ componentStack: string;
65
+ /** Error occurred during which phase */
66
+ phase: 'render' | 'effect' | 'event';
67
+ }
68
+ interface ErrorBoundaryProps {
69
+ /** Fallback UI to display when error occurs */
70
+ fallback: FNodeChild | ((error: Error, info: ErrorInfo) => FNodeChild);
71
+ /** Callback when error is caught */
72
+ onError?: (error: Error, info: ErrorInfo) => void;
73
+ /** Children to render */
74
+ children: FNodeChild;
75
+ /** Key to reset boundary (changing key resets error state) */
76
+ resetKey?: unknown;
77
+ }
78
+
79
+ /**
80
+ * Portal component that renders children into a different DOM node
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * function Modal({ isOpen, onClose, children }) {
85
+ * if (!isOpen) return null
86
+ *
87
+ * return (
88
+ * <Portal target={document.body}>
89
+ * <div class="modal-backdrop" onClick={onClose}>
90
+ * <div class="modal-content" onClick={e => e.stopPropagation()}>
91
+ * {children}
92
+ * </div>
93
+ * </div>
94
+ * </Portal>
95
+ * )
96
+ * }
97
+ * ```
98
+ */
99
+ declare function Portal(props: PortalProps): null;
100
+
101
+ /**
102
+ * Suspense component that shows fallback while children are loading
103
+ *
104
+ * @example
105
+ * ```tsx
106
+ * const Dashboard = lazy(() => import('./Dashboard'))
107
+ *
108
+ * function App() {
109
+ * return (
110
+ * <Suspense fallback={<div>Loading...</div>}>
111
+ * <Dashboard />
112
+ * </Suspense>
113
+ * )
114
+ * }
115
+ * ```
116
+ */
117
+ declare function Suspense(props: SuspenseProps): FNodeChild;
118
+
119
+ /**
120
+ * ErrorBoundary component that catches errors in its children and displays fallback UI
121
+ *
122
+ * @example
123
+ * ```tsx
124
+ * <ErrorBoundary
125
+ * fallback={(error, info) => <div>Error: {error.message}</div>}
126
+ * onError={(error, info) => console.error(error)}
127
+ * >
128
+ * <App />
129
+ * </ErrorBoundary>
130
+ * ```
131
+ */
132
+ declare function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild;
133
+
134
+ /**
135
+ * Creates a lazy-loaded component for code splitting
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * const Dashboard = lazy(() => import('./Dashboard'))
140
+ * const Settings = lazy(() => import('./Settings'))
141
+ *
142
+ * function App() {
143
+ * return (
144
+ * <Suspense fallback={<div>Loading...</div>}>
145
+ * <Dashboard />
146
+ * </Suspense>
147
+ * )
148
+ * }
149
+ * ```
150
+ */
151
+ declare function lazy<P = {}>(loader: () => Promise<{
152
+ default: (props: P) => FNodeChild;
153
+ }>): LazyComponent<P>;
154
+
155
+ declare function suspenseContext(): SuspenseContextValue;
11
156
 
12
- export { type FNode, type FNodeChild, f, reconcile, render };
157
+ export { ErrorBoundary, type ErrorBoundaryProps, type ErrorInfo, FNode, FNodeChild, type HydrateOptions, type LazyComponent, Portal, type PortalProps, Suspense, type SuspenseContextValue, type SuspenseProps, f, hydrate, lazy, reconcile, render, suspenseContext };
package/dist/dom.d.ts CHANGED
@@ -1,12 +1,157 @@
1
- type FNodeChild = FNode | string | number | boolean | null | undefined | FNodeChild[] | (() => FNode);
2
- interface FNode {
3
- type: string | Function;
4
- props: Record<string, any>;
5
- children: FNodeChild[];
1
+ import { a as FNode, F as FNodeChild } from './types-y2GGaXXk.js';
2
+ import { S as SerializedState } from './types-CxlS2F2j.js';
3
+
4
+ /**
5
+ * f() - Create FNodes without JSX
6
+ */
7
+ declare function f(type: string | Function, props?: any, ...children: any[]): FNode;
8
+
9
+ declare function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[];
10
+ declare function render(app: any, container: HTMLElement): void;
11
+
12
+ interface HydrateOptions {
13
+ /**
14
+ * Serialized state from server
15
+ * Typically embedded in HTML as JSON script tag
16
+ */
17
+ state?: SerializedState;
18
+ /**
19
+ * Called when hydration completes successfully
20
+ */
21
+ onHydrated?: () => void;
22
+ /**
23
+ * Called when hydration fails (falls back to full render)
24
+ */
25
+ onMismatch?: (error: Error) => void;
26
+ }
27
+ /**
28
+ * Hydrate server-rendered HTML with client-side interactivity
29
+ */
30
+ declare function hydrate(app: FNodeChild | (() => FNodeChild), container: HTMLElement, options?: HydrateOptions): void;
31
+
32
+ interface PortalProps {
33
+ /** Target element or CSS selector to render children into */
34
+ target: HTMLElement | string;
35
+ /** Children to render in the portal */
36
+ children: FNodeChild;
37
+ /** Optional key for reconciliation */
6
38
  key?: any;
7
39
  }
8
- declare function render(app: any, container: HTMLElement): void;
9
- declare function f(type: string | Function, props?: any, ...children: any[]): any;
10
- declare function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[];
40
+ interface SuspenseProps {
41
+ /** Fallback UI to display while loading */
42
+ fallback: FNodeChild;
43
+ /** Children to render when loaded */
44
+ children: FNodeChild;
45
+ }
46
+ interface LazyComponent<P = any> {
47
+ (props: P): FNodeChild;
48
+ _lazy: true;
49
+ _loader: () => Promise<{
50
+ default: (props: P) => FNodeChild;
51
+ }>;
52
+ _resolved?: (props: P) => FNodeChild;
53
+ _promise?: Promise<any>;
54
+ _error?: Error;
55
+ }
56
+ interface SuspenseContextValue {
57
+ /** Register a pending promise with the suspense boundary */
58
+ register: (promise: Promise<any>) => void;
59
+ /** Whether there's an active suspense boundary */
60
+ hasBoundary: boolean;
61
+ }
62
+ interface ErrorInfo {
63
+ /** Component stack trace */
64
+ componentStack: string;
65
+ /** Error occurred during which phase */
66
+ phase: 'render' | 'effect' | 'event';
67
+ }
68
+ interface ErrorBoundaryProps {
69
+ /** Fallback UI to display when error occurs */
70
+ fallback: FNodeChild | ((error: Error, info: ErrorInfo) => FNodeChild);
71
+ /** Callback when error is caught */
72
+ onError?: (error: Error, info: ErrorInfo) => void;
73
+ /** Children to render */
74
+ children: FNodeChild;
75
+ /** Key to reset boundary (changing key resets error state) */
76
+ resetKey?: unknown;
77
+ }
78
+
79
+ /**
80
+ * Portal component that renders children into a different DOM node
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * function Modal({ isOpen, onClose, children }) {
85
+ * if (!isOpen) return null
86
+ *
87
+ * return (
88
+ * <Portal target={document.body}>
89
+ * <div class="modal-backdrop" onClick={onClose}>
90
+ * <div class="modal-content" onClick={e => e.stopPropagation()}>
91
+ * {children}
92
+ * </div>
93
+ * </div>
94
+ * </Portal>
95
+ * )
96
+ * }
97
+ * ```
98
+ */
99
+ declare function Portal(props: PortalProps): null;
100
+
101
+ /**
102
+ * Suspense component that shows fallback while children are loading
103
+ *
104
+ * @example
105
+ * ```tsx
106
+ * const Dashboard = lazy(() => import('./Dashboard'))
107
+ *
108
+ * function App() {
109
+ * return (
110
+ * <Suspense fallback={<div>Loading...</div>}>
111
+ * <Dashboard />
112
+ * </Suspense>
113
+ * )
114
+ * }
115
+ * ```
116
+ */
117
+ declare function Suspense(props: SuspenseProps): FNodeChild;
118
+
119
+ /**
120
+ * ErrorBoundary component that catches errors in its children and displays fallback UI
121
+ *
122
+ * @example
123
+ * ```tsx
124
+ * <ErrorBoundary
125
+ * fallback={(error, info) => <div>Error: {error.message}</div>}
126
+ * onError={(error, info) => console.error(error)}
127
+ * >
128
+ * <App />
129
+ * </ErrorBoundary>
130
+ * ```
131
+ */
132
+ declare function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild;
133
+
134
+ /**
135
+ * Creates a lazy-loaded component for code splitting
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * const Dashboard = lazy(() => import('./Dashboard'))
140
+ * const Settings = lazy(() => import('./Settings'))
141
+ *
142
+ * function App() {
143
+ * return (
144
+ * <Suspense fallback={<div>Loading...</div>}>
145
+ * <Dashboard />
146
+ * </Suspense>
147
+ * )
148
+ * }
149
+ * ```
150
+ */
151
+ declare function lazy<P = {}>(loader: () => Promise<{
152
+ default: (props: P) => FNodeChild;
153
+ }>): LazyComponent<P>;
154
+
155
+ declare function suspenseContext(): SuspenseContextValue;
11
156
 
12
- export { type FNode, type FNodeChild, f, reconcile, render };
157
+ export { ErrorBoundary, type ErrorBoundaryProps, type ErrorInfo, FNode, FNodeChild, type HydrateOptions, type LazyComponent, Portal, type PortalProps, Suspense, type SuspenseContextValue, type SuspenseProps, f, hydrate, lazy, reconcile, render, suspenseContext };
package/dist/dom.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkLUW7DIEW_js=require('./chunk-LUW7DIEW.js'),chunkENWGYQNU_js=require('./chunk-ENWGYQNU.js');var m=new WeakMap,l=null;function H(e){e.children.forEach(n=>{H(n);}),e.nodes.forEach(n=>{n.parentNode&&n.parentNode.removeChild(n);}),e.children.clear(),e.parentInstance&&e.parentInstance.children.delete(e);}function E(e,n,a){let c=a||n,r=f=>{let u={...f.props};return f.children&&f.children.length>0&&(u.children=f.children.length===1?f.children[0]:f.children),u},o=e.key!==void 0;m.has(c)||m.set(c,new Map);let t=m.get(c),i;if(o)i=e.key;else {let f=0,u=e.type.name||"anonymous";t.forEach((b,h)=>{typeof h=="string"&&h.startsWith(`__auto_${u}_`)&&f++;}),i=`__auto_${u}_${f}`;}if(t.has(i)){let f=t.get(i);f.fnode=e;let u=r(e);return f.props=u,f.children.clear(),f.renderFn&&f.renderFn(),f.nodes}let s={hooks:[],hookIndex:0,nodes:[],parent:n,fnode:e,props:r(e),key:i,children:new Set,parentInstance:l||void 0};l&&l.children.add(s),t.set(i,s);let d=true,g=()=>{let f=s.fnode,u=s.props;f.type._contextId!==void 0&&chunkLUW7DIEW_js.c(f.type._contextId,u.value);let h=l;l=s;let M=chunkENWGYQNU_js.g(s,()=>f.type(u));if(d){let _=y(M,n);s.nodes=_?Array.isArray(_)?_:[_]:[],s.nodes.forEach(p=>{p.__ownerInstance||(p.__ownerInstance=s);}),d=false;}else {if(s.nodes.length===0){let N=y(M,n);s.nodes=N?Array.isArray(N)?N:[N]:[],l=h;return}let p=s.nodes[0].parentNode;if(!p){l=h;return}let v=document.createComment("flexium-marker"),T=s.nodes[s.nodes.length-1];T.nextSibling?p.insertBefore(v,T.nextSibling):p.appendChild(v),s.children.clear();let O=document.createElement("div"),C=y(M,O,p),F=C?Array.isArray(C)?C:[C]:[],R=P(s.nodes,F,p,v);p.removeChild(v),s.nodes=R;}l=h;};return s.renderFn=g,chunkENWGYQNU_js.b(g),s.nodes}function y(e,n,a){let c=a||n;if(e==null||typeof e=="boolean"){let r=document.createTextNode("");return n.appendChild(r),r}if(typeof e=="string"||typeof e=="number"){let r=document.createTextNode(String(e));return n.appendChild(r),r}if(Array.isArray(e)){let r=new Set;m.has(c)&&m.get(c).forEach((s,d)=>r.add(d));let o=[];e.forEach(i=>{let s=y(i,n,a);s&&(Array.isArray(s)?o.push(...s):o.push(s));});let t=new Set;if(m.has(c)&&m.get(c).forEach((s,d)=>t.add(d)),m.has(c)){let i=m.get(c),s=[];r.forEach(d=>{if(!t.has(d)){let g=i.get(d);g&&(H(g),s.push(d));}}),s.forEach(d=>i.delete(d));}return o}if(typeof e=="object"){if(typeof e.type=="string"){let r=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([o,t])=>{if(o==="ref"&&typeof t=="function")t(r);else if(o.startsWith("on")&&typeof t=="function"){let i=o.slice(2).toLowerCase();r.addEventListener(i,t),r.__eventHandlers||(r.__eventHandlers={}),r.__eventHandlers[i]=t;}else o!=="ref"&&S(r,o,t);}),e.children&&e.children.length>0&&e.children.forEach(o=>{y(o,r);}),n.appendChild(r),r}if(typeof e.type=="function")return e.type._contextId!==void 0,E(e,n,a)}return null}function $(e,n){n.innerHTML="",typeof e=="function"&&(e={type:e,props:{},children:[],key:void 0}),y(e,n);}function B(e,n,...a){return {type:e,props:n||{},children:a,key:n?.key}}function S(e,n,a){a==null?e.removeAttribute(n):n==="style"&&typeof a=="object"?Object.assign(e.style,a):n==="class"?e.className=String(a):n in e&&typeof e[n]!="function"?e[n]=a:e.setAttribute(n,String(a));}function D(e,n){return e.nodeType!==n.nodeType?false:e.nodeType===Node.ELEMENT_NODE&&n.nodeType===Node.ELEMENT_NODE?e.tagName===n.tagName:true}function k(e,n){Array.from(e.attributes).forEach(t=>{n.hasAttribute(t.name)||e.removeAttribute(t.name);}),Array.from(n.attributes).forEach(t=>{e.getAttribute(t.name)!==t.value&&(t.name==="value"&&"value"in e?e.value=t.value:t.name==="checked"&&"checked"in e?e.checked=t.value==="true"||t.value==="":e.setAttribute(t.name,t.value));});let r=e.__eventHandlers||{},o=n.__eventHandlers||{};Object.keys(r).forEach(t=>{o[t]||e.removeEventListener(t,r[t]);}),Object.keys(o).forEach(t=>{r[t]!==o[t]&&(r[t]&&e.removeEventListener(t,r[t]),e.addEventListener(t,o[t]));}),Object.keys(o).length>0?e.__eventHandlers=o:delete e.__eventHandlers,e instanceof HTMLInputElement&&n instanceof HTMLInputElement&&(e.value!==n.value&&(e.value=n.value),e.checked!==n.checked&&(e.checked=n.checked)),e instanceof HTMLTextAreaElement&&n instanceof HTMLTextAreaElement&&e.value!==n.value&&(e.value=n.value),e instanceof HTMLSelectElement&&n instanceof HTMLSelectElement&&e.value!==n.value&&(e.value=n.value);}function j(e,n){let a=Array.from(e.childNodes),c=Array.from(n.childNodes),r=Math.max(a.length,c.length);for(let o=0;o<r;o++){let t=a[o],i=c[o];!t&&i?e.appendChild(i):t&&!i?e.removeChild(t):t&&i&&x(t,i,e);}}function x(e,n,a){if(D(e,n)){let c=n.__ownerInstance;if(c){let r=c.nodes.indexOf(n);r!==-1&&(c.nodes[r]=e),e.__ownerInstance=c,delete n.__ownerInstance;}e.nodeType===Node.TEXT_NODE?e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue):e.nodeType===Node.ELEMENT_NODE&&(k(e,n),j(e,n));}else a.replaceChild(n,e);}function P(e,n,a,c){let r=Math.max(e.length,n.length),o=[];for(let t=0;t<r;t++){let i=e[t],s=n[t];!i&&s?(a.insertBefore(s,c),o.push(s)):i&&!s?i.parentNode&&a.removeChild(i):i&&s&&(x(i,s,a),o.push(i));}return o}exports.f=B;exports.reconcile=P;exports.render=$;//# sourceMappingURL=dom.js.map
1
+ 'use strict';var chunk6Z33DLMI_js=require('./chunk-6Z33DLMI.js'),chunkPSKDIB7J_js=require('./chunk-PSKDIB7J.js'),chunkLTT43APF_js=require('./chunk-LTT43APF.js');require('./chunk-6VIRXD2Y.js');var chunkYWTD32NA_js=require('./chunk-YWTD32NA.js'),chunkUWFVCKRU_js=require('./chunk-UWFVCKRU.js');function j(e,t,...r){return {type:e,props:t||{},children:r,key:t?.key}}var l=null,F=new WeakMap,m=null;function K(e,t,r={}){let{state:s,onHydrated:o,onMismatch:n}=r;l=t.firstChild;try{let i;typeof e=="function"&&!z(e)?i={type:e,props:{},children:[],key:void 0}:i=e,E(i,t),o?.();}catch(i){console.warn("[Flexium] Hydration mismatch, falling back to full render:",i),n?.(i),t.innerHTML="",import('./render-QZAFAGIM.js').then(({render:a})=>{a(e,t);});}finally{l=null;}}function z(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function E(e,t){if(e==null||typeof e=="boolean")return v(),null;if(typeof e=="string"||typeof e=="number")return X(String(e));if(Array.isArray(e)){let r=[];for(let s of e){let o=E(s,t);o&&(Array.isArray(o)?r.push(...o):r.push(o));}return r}if(typeof e=="function")return b({type:e,props:{},children:[],key:void 0},t);if(typeof e=="object"&&z(e)){if(typeof e.type=="string")return q(e);if(typeof e.type=="function")return b(e,t)}return null}function v(){for(;l&&l.nodeType===Node.TEXT_NODE&&(!l.textContent||l.textContent.trim()==="");)l=l.nextSibling;}function X(e){v();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 q(e,t){v();let r=l,s=e.type;if(!r||r.nodeType!==Node.ELEMENT_NODE)throw new Error(`Hydration mismatch: expected element <${s}>, got ${r?.nodeName||"nothing"}`);if(r.tagName.toLowerCase()!==s.toLowerCase())throw new Error(`Hydration mismatch: expected <${s}>, got <${r.tagName.toLowerCase()}>`);if(e.props){for(let[o,n]of Object.entries(e.props))if(o==="ref")typeof n=="function"?n(r):n&&typeof n=="object"&&"current"in n&&(n.current=r);else if(o.startsWith("on")&&typeof n=="function"){let i=o.slice(2).toLowerCase();r.addEventListener(i,n),r.__eventHandlers||(r.__eventHandlers={}),r.__eventHandlers[i]=n;}}if(l=r.nextSibling,e.children&&e.children.length>0){let o=l;l=r.firstChild;for(let n of e.children)E(n,r);l=o;}return r}function b(e,t){let r=e.type,s={...e.props};e.children&&e.children.length>0&&(s.children=e.children.length===1?e.children[0]:e.children);let o=r._contextId,n=o!==void 0,i;n&&(i=chunkPSKDIB7J_js.c(o,s.value)),F.has(t)||F.set(t,new Map);let a=F.get(t),x=e.key!==void 0,d;if(x)d=e.key;else {let y=0,u=r.name||"anonymous";a.forEach((g,h)=>{typeof h=="string"&&h.startsWith(`__auto_${u}_`)&&y++;}),d=`__auto_${u}_${y}`;}let p={hooks:[],hookIndex:0,nodes:[],parent:t,fnode:e,props:s,key:d,children:new Set,parentInstance:m||void 0};m&&m.children.add(p),a.set(d,p);let c=m;m=p;try{let y=chunkUWFVCKRU_js.a(p,()=>r(s)),u=E(y,t);p.nodes=u?Array.isArray(u)?u:[u]:[];let g=!0,h=()=>{if(g){g=!1;return}let R=p.props,Z=chunkUWFVCKRU_js.a(p,()=>r(R));};return p.renderFn=h,chunkYWTD32NA_js.b(h),p.nodes}finally{m=c,n&&chunkPSKDIB7J_js.d(o,i);}}function O(e){let{target:t,children:r}=e,s=chunkUWFVCKRU_js.b(()=>({container:null,mounted:false}));return chunkYWTD32NA_js.e(()=>{let o=null;if(typeof t=="string"?o=document.querySelector(t):t instanceof HTMLElement&&(o=t),!o){console.warn("[Flexium Portal] Target container not found:",t);return}let n=document.createElement("div");return n.setAttribute("data-flexium-portal","true"),o.appendChild(n),s.container=n,s.mounted=true,chunk6Z33DLMI_js.b(r,n),()=>{n.parentNode&&n.parentNode.removeChild(n),s.container=null,s.mounted=false;}},[t,r]),null}var G={register:()=>{},hasBoundary:false},H=chunkPSKDIB7J_js.a(G);function N(){return chunkPSKDIB7J_js.b(H)}function V(e){let{fallback:t,children:r}=e,s=chunkUWFVCKRU_js.b(()=>new Set),[o,n]=chunkLTT43APF_js.a(0),[i,a]=chunkLTT43APF_js.a(false),d={register:c=>{s.has(c)||(s.add(c),n(y=>y+1),a(true),c.finally(()=>{s.delete(c),n(y=>{let u=y-1;return u===0&&a(false),u});}));},hasBoundary:true},p=i?t:r;return {type:H.Provider,props:{value:d},children:[p],key:void 0}}function D(e){let{fallback:t,onError:r,children:s,resetKey:o}=e,[n,i]=chunkLTT43APF_js.a({error:null,info:null}),a=chunkUWFVCKRU_js.b(()=>({current:o}));o!==a.current&&(a.current=o,n.error!==null&&i({error:null,info:null}));if(n.error)return typeof t=="function"?t(n.error,n.info):t;try{return s}finally{}}function A(e){let t=null,r=null,s=null,o=n=>{if(t)return t(n);if(s)throw s;let i=N();return r||(r=e().then(a=>{t=a.default;}).catch(a=>{s=a instanceof Error?a:new Error(String(a));})),i.hasBoundary&&i.register(r),null};return o._lazy=true,o._loader=e,o}Object.defineProperty(exports,"reconcile",{enumerable:true,get:function(){return chunk6Z33DLMI_js.a}});Object.defineProperty(exports,"render",{enumerable:true,get:function(){return chunk6Z33DLMI_js.b}});exports.ErrorBoundary=D;exports.Portal=O;exports.Suspense=V;exports.f=j;exports.hydrate=K;exports.lazy=A;exports.suspenseContext=N;//# sourceMappingURL=dom.js.map
2
2
  //# sourceMappingURL=dom.js.map
package/dist/dom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dom/index.ts"],"names":["instanceRegistry","currentRenderingInstance","removeComponentInstance","instance","child","node","renderComponent","fnode","parent","registryParent","effectiveRegistryParent","mergeProps","props","hasExplicitKey","parentRegistry","key","instanceCount","componentName","_","k","newProps","isFirstRender","renderFn","currentFnode","currentProps","pushContext","previousRenderingInstance","result","runWithComponent","newNodes","renderNode","nodeParent","marker","lastNode","tempContainer","newNodesArray","reconciledNodes","reconcile","unsafeEffect","oldKeysSet","nodes","newKeysSet","keysToRemove","dom","value","eventName","setAttribute","render","app","container","f","type","children","el","canReuse","oldNode","newNode","updateAttributes","oldEl","newEl","attr","oldHandlers","newHandlers","event","reconcileChildren","oldChildren","newChildren","maxLen","i","oldChild","newChild","patchNode","ownerInstance","idx","oldNodes","beforeMarker","resultNodes"],"mappings":"iHA4BA,IAAMA,CAAAA,CAAmB,IAAI,OAAA,CAGzBC,CAAAA,CAAwD,KAG5D,SAASC,CAAAA,CAAwBC,CAAAA,CAAsC,CAEnEA,EAAS,QAAA,CAAS,OAAA,CAAQC,CAAAA,EAAS,CAC/BF,EAAwBE,CAAK,EACjC,CAAC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AAkB,CAAA,EAEhE,CAAA,KAEIhD,CAAAA,CAAO,YAAA,CAAagD,CAAAA,CAASD,CAAO,EAE5C,CAGO,SAASlB,CAAAA,CAAUqC,CAAAA,CAAkB7C,EAAkBrB,CAAAA,CAAcmE,CAAAA,CAA4B,CACpG,IAAMR,EAAS,IAAA,CAAK,GAAA,CAAIO,CAAAA,CAAS,MAAA,CAAQ7C,EAAS,MAAM,CAAA,CAClD+C,CAAAA,CAAsB,GAE5B,IAAA,IAASR,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAID,EAAQC,CAAAA,EAAAA,CAAK,CAC7B,IAAMb,CAAAA,CAAUmB,EAASN,CAAC,CAAA,CACpBZ,CAAAA,CAAU3B,CAAAA,CAASuC,CAAC,CAAA,CAEtB,CAACb,CAAAA,EAAWC,CAAAA,EAEZhD,EAAO,YAAA,CAAagD,CAAAA,CAASmB,CAAY,CAAA,CACzCC,EAAY,IAAA,CAAKpB,CAAO,CAAA,EACjBD,CAAAA,EAAW,CAACC,CAAAA,CAEfD,CAAAA,CAAQ,UAAA,EACR/C,CAAAA,CAAO,YAAY+C,CAAO,CAAA,CAEvBA,CAAAA,EAAWC,CAAAA,GAElBe,EAAUhB,CAAAA,CAASC,CAAAA,CAAShD,CAAiB,CAAA,CAC7CoE,EAAY,IAAA,CAAKrB,CAAO,CAAA,EAEhC,CAEA,OAAOqB,CACX","file":"dom.js","sourcesContent":["\nimport { pushContext } from '../core/context'\nimport { runWithComponent, type ComponentInstance } from '../core/hook'\nimport { unsafeEffect } from '../core/effect'\n\n// Types\nexport type FNodeChild = FNode | string | number | boolean | null | undefined | FNodeChild[] | (() => FNode)\n\nexport interface FNode {\n type: string | Function\n props: Record<string, any>\n children: FNodeChild[]\n key?: any\n}\n\n// Extended ComponentInstance for DOM tracking\ninterface DOMComponentInstance extends ComponentInstance {\n nodes: Node[]\n parent: HTMLElement\n fnode: any\n props: any\n key?: any\n renderFn?: () => void // Store render function for manual updates\n children: Set<DOMComponentInstance> // Track child component instances\n parentInstance?: DOMComponentInstance // Track parent component instance\n}\n\n// Registry to store component instances by parent and key\nconst instanceRegistry = new WeakMap<HTMLElement, Map<any, DOMComponentInstance>>()\n\n// Current rendering component instance (for tracking parent-child relationships)\nlet currentRenderingInstance: DOMComponentInstance | null = null\n\n// Recursively remove component instance and all its children\nfunction removeComponentInstance(instance: DOMComponentInstance): void {\n // First, recursively remove all child instances\n instance.children.forEach(child => {\n removeComponentInstance(child)\n })\n\n // Remove DOM nodes created by this instance\n instance.nodes.forEach(node => {\n if (node.parentNode) {\n node.parentNode.removeChild(node)\n }\n })\n\n // Clear the children set\n instance.children.clear()\n\n // Remove from parent's children set\n if (instance.parentInstance) {\n instance.parentInstance.children.delete(instance)\n }\n}\n\n// Render a function component with reactive re-rendering\nfunction renderComponent(fnode: any, parent: HTMLElement, registryParent?: HTMLElement): Node[] {\n const effectiveRegistryParent = registryParent || parent\n // Merge props with children\n const mergeProps = (node: any) => {\n const props = { ...node.props }\n if (node.children && node.children.length > 0) {\n props.children = node.children.length === 1\n ? node.children[0]\n : node.children\n }\n return props\n }\n\n // Generate key for this component\n // Use explicit key if provided, otherwise generate auto-key based on render order\n const hasExplicitKey = fnode.key !== undefined\n\n // Get or create registry for this parent\n // Always use the effectiveRegistryParent for registry, not a temp container\n if (!instanceRegistry.has(effectiveRegistryParent)) {\n instanceRegistry.set(effectiveRegistryParent, new Map())\n }\n const parentRegistry = instanceRegistry.get(effectiveRegistryParent)!\n\n // Generate key: explicit key, or auto-increment based on component type\n let key: any\n if (hasExplicitKey) {\n key = fnode.key\n } else {\n // Auto-generate unique key: componentType + instance number\n // Count how many instances of this type already exist\n let instanceCount = 0\n const componentName = fnode.type.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 // Try to reuse existing instance with same key\n if (parentRegistry.has(key)) {\n const instance = parentRegistry.get(key)!\n\n // Update fnode\n instance.fnode = fnode\n\n // Update props (non-reactive) - we'll trigger re-render manually\n const newProps = mergeProps(fnode)\n\n // Always update props (including children)\n instance.props = newProps\n\n // Always clear old children before re-rendering (they will be re-added during render)\n // This must be done BEFORE renderFn is called\n instance.children.clear()\n\n // Manually trigger re-render by calling renderFn\n if (instance.renderFn) {\n instance.renderFn()\n }\n\n return instance.nodes\n }\n\n // Create component instance with regular props (not reactive)\n const instance: DOMComponentInstance = {\n hooks: [],\n hookIndex: 0,\n nodes: [],\n parent,\n fnode: fnode,\n props: mergeProps(fnode), // Regular props, we handle updates manually\n key,\n children: new Set(),\n parentInstance: currentRenderingInstance || undefined\n }\n\n // Register this instance as a child of the current rendering instance\n if (currentRenderingInstance) {\n currentRenderingInstance.children.add(instance)\n }\n\n // Store instance in registry\n parentRegistry.set(key, instance)\n\n // Track if this is the first render\n let isFirstRender = true\n\n // Function to render the component\n const renderFn = () => {\n const currentFnode = instance.fnode\n const currentProps = instance.props\n\n // Check if this is a Context Provider\n const isProvider = (currentFnode.type as any)._contextId !== undefined\n if (isProvider) {\n // Set context value before rendering\n pushContext((currentFnode.type as any)._contextId, currentProps.value)\n }\n\n // Set this instance as the current rendering instance\n const previousRenderingInstance = currentRenderingInstance\n currentRenderingInstance = instance\n\n // Render component with hook context\n const result = runWithComponent(instance, () => currentFnode.type(currentProps))\n\n // DON'T restore currentRenderingInstance yet - we need it for renderNode calls below\n // It will be restored at the end of this function\n\n if (isFirstRender) {\n // First render: create new DOM nodes\n const newNodes = renderNode(result, parent)\n instance.nodes = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n // Mark nodes as owned by this instance (for reconciliation)\n // Only set ownership if not already owned (child components set ownership first)\n instance.nodes.forEach(node => {\n if (!(node as any).__ownerInstance) {\n (node as any).__ownerInstance = instance\n }\n })\n isFirstRender = false\n } else {\n // Re-render: reconcile with existing DOM\n // Don't early return if nodes is empty - component might render other components\n if (instance.nodes.length === 0) {\n // Component has no DOM nodes yet, might be rendering other components\n // Just re-render without reconciliation\n const newNodes = renderNode(result, parent)\n instance.nodes = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n // Restore previous rendering instance before returning\n currentRenderingInstance = previousRenderingInstance\n return\n }\n\n const firstNode = instance.nodes[0]\n const nodeParent = firstNode.parentNode as HTMLElement\n\n if (!nodeParent) {\n // Restore previous rendering instance before returning\n currentRenderingInstance = previousRenderingInstance\n return\n }\n\n // Create marker to know where to insert new nodes\n const marker = document.createComment('flexium-marker')\n const lastNode = instance.nodes[instance.nodes.length - 1]\n if (lastNode.nextSibling) {\n nodeParent.insertBefore(marker, lastNode.nextSibling)\n } else {\n nodeParent.appendChild(marker)\n }\n\n // Clear children references - actual cleanup happens via key-based registry\n // Don't call removeComponentInstance here as it removes DOM nodes that reconcile needs\n instance.children.clear()\n\n // Create temporary container for collecting new nodes\n const tempContainer = document.createElement('div')\n\n // Render into temp container, but use actual parent for registry\n const newNodes = renderNode(result, tempContainer, nodeParent)\n const newNodesArray = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n\n // Use reconcile to patch existing nodes instead of replacing\n const reconciledNodes = reconcile(instance.nodes, newNodesArray, nodeParent, marker)\n\n // Remove marker\n nodeParent.removeChild(marker)\n\n instance.nodes = reconciledNodes\n }\n\n // Restore previous rendering instance after all renderNode calls are done\n currentRenderingInstance = previousRenderingInstance\n }\n\n // Store renderFn for manual updates\n instance.renderFn = renderFn\n\n // Wrap in effect for reactive re-rendering\n unsafeEffect(renderFn)\n\n return instance.nodes\n}\n\nfunction renderNode(fnode: any, parent: HTMLElement, registryParent?: HTMLElement): Node | Node[] | null {\n // Use registryParent for instance lookups if provided, otherwise use parent\n const effectiveRegistryParent = registryParent || parent\n // 1. null/undefined/boolean -> empty text\n if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n const node = document.createTextNode('');\n parent.appendChild(node);\n return node;\n }\n\n // 2. Primitive (string/number) -> Text\n if (typeof fnode === 'string' || typeof fnode === 'number') {\n const node = document.createTextNode(String(fnode));\n parent.appendChild(node);\n return node;\n }\n\n // 3. Array -> render each item with key-based reconciliation\n if (Array.isArray(fnode)) {\n // Store old registry keys before rendering\n const oldKeysSet = new Set<any>()\n if (instanceRegistry.has(effectiveRegistryParent)) {\n const parentRegistry = instanceRegistry.get(effectiveRegistryParent)!\n parentRegistry.forEach((_, key) => oldKeysSet.add(key))\n }\n\n // Render all children\n const nodes: Node[] = [];\n fnode.forEach((child) => {\n const result = renderNode(child, parent, registryParent);\n if (result) {\n if (Array.isArray(result)) {\n nodes.push(...result);\n } else {\n nodes.push(result);\n }\n }\n });\n\n // After rendering, check which keys are still in the registry (= were reused or created)\n const newKeysSet = new Set<any>()\n if (instanceRegistry.has(effectiveRegistryParent)) {\n const parentRegistry = instanceRegistry.get(effectiveRegistryParent)!\n parentRegistry.forEach((_, key) => newKeysSet.add(key))\n }\n\n // Remove instances that existed before but don't exist now\n if (instanceRegistry.has(effectiveRegistryParent)) {\n const parentRegistry = instanceRegistry.get(effectiveRegistryParent)!\n const keysToRemove: any[] = []\n\n oldKeysSet.forEach(key => {\n if (!newKeysSet.has(key)) {\n const instance = parentRegistry.get(key)\n if (instance) {\n // Recursively remove component instance and all its children\n removeComponentInstance(instance)\n keysToRemove.push(key)\n }\n }\n })\n\n // Clean up registry\n keysToRemove.forEach(key => parentRegistry.delete(key))\n }\n\n return nodes;\n }\n\n // 4. Object (FNode)\n if (typeof fnode === 'object') {\n // 4a. HTML Element (intrinsic)\n if (typeof fnode.type === 'string') {\n const dom = document.createElement(fnode.type);\n\n // Set props/attributes\n if (fnode.props) {\n Object.entries(fnode.props).forEach(([key, value]) => {\n if (key === 'ref' && typeof value === 'function') {\n // ref callback - call with the DOM element\n value(dom);\n } else if (key.startsWith('on') && typeof value === 'function') {\n // Event handler: onClick -> click\n const eventName = key.slice(2).toLowerCase();\n dom.addEventListener(eventName, value as EventListener);\n\n // Store handlers for cleanup/reconciliation\n if (!(dom as any).__eventHandlers) {\n (dom as any).__eventHandlers = {};\n }\n (dom as any).__eventHandlers[eventName] = value;\n } else if (key !== 'ref') {\n // Regular attribute (skip ref if not a function)\n setAttribute(dom, key, value);\n }\n });\n }\n\n // Render children\n if (fnode.children && fnode.children.length > 0) {\n fnode.children.forEach((child: any) => {\n renderNode(child, dom);\n });\n }\n\n parent.appendChild(dom);\n return dom;\n }\n\n // 4b. Function Component\n if (typeof fnode.type === 'function') {\n // Check if this is a Context Provider\n const isProvider = (fnode.type as any)._contextId !== undefined;\n\n if (isProvider) {\n // Context Provider: treat like regular component for reactivity\n // This ensures providers re-render when their children change\n return renderComponent(fnode, parent, registryParent);\n } else {\n // Regular component: use reactive rendering\n return renderComponent(fnode, parent, registryParent);\n }\n }\n }\n\n // Fallback: unknown type\n return null;\n}\n\nexport function render(app: any, container: HTMLElement) {\n container.innerHTML = ''\n\n // Handle raw function components by wrapping them in an FNode\n if (typeof app === 'function') {\n app = { type: app, props: {}, children: [], key: undefined }\n }\n\n renderNode(app, container);\n}\n\n// f() - Create FNodes without JSX\nexport function f(\n type: string | Function,\n props?: any,\n ...children: any[]\n): any {\n return {\n type,\n props: props || {},\n children,\n key: props?.key\n }\n}\n\nfunction setAttribute(el: Element, key: string, value: any) {\n if (value === null || value === undefined) {\n el.removeAttribute(key)\n } else if (key === 'style' && typeof value === 'object') {\n // Handle style object\n Object.assign((el as HTMLElement).style, value)\n } else if (key === 'class') {\n // Handle class specially (className property)\n el.className = String(value)\n } else if (key in el && typeof (el as any)[key] !== 'function') {\n // Property-first approach: use DOM property if available\n // This automatically handles: disabled, checked, value, readonly, etc.\n (el as any)[key] = value\n } else {\n // Fallback to setAttribute for custom/data attributes\n el.setAttribute(key, String(value))\n }\n}\n\n// Reconciliation helpers\nfunction canReuse(oldNode: Node, newNode: Node): boolean {\n if (oldNode.nodeType !== newNode.nodeType) return false\n if (oldNode.nodeType === Node.ELEMENT_NODE && newNode.nodeType === Node.ELEMENT_NODE) {\n return (oldNode as Element).tagName === (newNode as Element).tagName\n }\n return true\n}\n\nfunction updateAttributes(oldEl: Element, newEl: Element): void {\n // Remove old attributes\n const oldAttrs = Array.from(oldEl.attributes)\n oldAttrs.forEach(attr => {\n if (!newEl.hasAttribute(attr.name)) {\n oldEl.removeAttribute(attr.name)\n }\n })\n\n // Set/update new attributes\n const newAttrs = Array.from(newEl.attributes)\n newAttrs.forEach(attr => {\n if (oldEl.getAttribute(attr.name) !== attr.value) {\n // Use DOM property for value/checked to preserve focus\n if (attr.name === 'value' && 'value' in oldEl) {\n (oldEl as HTMLInputElement).value = attr.value\n } else if (attr.name === 'checked' && 'checked' in oldEl) {\n (oldEl as HTMLInputElement).checked = attr.value === 'true' || attr.value === ''\n } else {\n oldEl.setAttribute(attr.name, attr.value)\n }\n }\n })\n\n // Update event handlers\n const oldHandlers = (oldEl as any).__eventHandlers || {}\n const newHandlers = (newEl as any).__eventHandlers || {}\n\n // Remove old handlers\n Object.keys(oldHandlers).forEach(event => {\n if (!newHandlers[event]) {\n oldEl.removeEventListener(event, oldHandlers[event])\n }\n })\n\n // Add/update new handlers\n Object.keys(newHandlers).forEach(event => {\n if (oldHandlers[event] !== newHandlers[event]) {\n if (oldHandlers[event]) {\n oldEl.removeEventListener(event, oldHandlers[event])\n }\n oldEl.addEventListener(event, newHandlers[event])\n }\n })\n\n // Update stored handlers\n if (Object.keys(newHandlers).length > 0) {\n (oldEl as any).__eventHandlers = newHandlers\n } else {\n delete (oldEl as any).__eventHandlers\n }\n\n // Special handling for form input values\n if (oldEl instanceof HTMLInputElement && newEl instanceof HTMLInputElement) {\n if (oldEl.value !== newEl.value) {\n oldEl.value = newEl.value\n }\n if (oldEl.checked !== newEl.checked) {\n oldEl.checked = newEl.checked\n }\n }\n if (oldEl instanceof HTMLTextAreaElement && newEl instanceof HTMLTextAreaElement) {\n if (oldEl.value !== newEl.value) {\n oldEl.value = newEl.value\n }\n }\n if (oldEl instanceof HTMLSelectElement && newEl instanceof HTMLSelectElement) {\n if (oldEl.value !== newEl.value) {\n oldEl.value = newEl.value\n }\n }\n}\n\nfunction reconcileChildren(oldEl: Element, newEl: Element): void {\n const oldChildren = Array.from(oldEl.childNodes)\n const newChildren = Array.from(newEl.childNodes)\n const maxLen = Math.max(oldChildren.length, newChildren.length)\n\n for (let i = 0; i < maxLen; i++) {\n const oldChild = oldChildren[i]\n const newChild = newChildren[i]\n\n if (!oldChild && newChild) {\n // Add new child\n oldEl.appendChild(newChild)\n } else if (oldChild && !newChild) {\n // Remove old child\n oldEl.removeChild(oldChild)\n } else if (oldChild && newChild) {\n // Patch child\n patchNode(oldChild, newChild, oldEl)\n }\n }\n}\n\nfunction patchNode(oldNode: Node, newNode: Node, parent: Element): void {\n if (canReuse(oldNode, newNode)) {\n // Transfer component instance ownership from newNode to oldNode\n // This ensures component instances reference actual DOM nodes after reconciliation\n const ownerInstance = (newNode as any).__ownerInstance as DOMComponentInstance | undefined\n if (ownerInstance) {\n const idx = ownerInstance.nodes.indexOf(newNode)\n if (idx !== -1) {\n ownerInstance.nodes[idx] = oldNode\n }\n ;(oldNode as any).__ownerInstance = ownerInstance\n delete (newNode as any).__ownerInstance\n }\n // Reuse node\n if (oldNode.nodeType === Node.TEXT_NODE) {\n // Update text content\n if (oldNode.nodeValue !== newNode.nodeValue) {\n oldNode.nodeValue = newNode.nodeValue\n }\n } else if (oldNode.nodeType === Node.ELEMENT_NODE) {\n // Update element\n updateAttributes(oldNode as Element, newNode as Element)\n reconcileChildren(oldNode as Element, newNode as Element)\n }\n } else {\n // Different type, replace\n parent.replaceChild(newNode, oldNode)\n }\n}\n\n// Exported for future use (Phase 2: Reactive rendering)\nexport function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[] {\n const maxLen = Math.max(oldNodes.length, newNodes.length)\n const resultNodes: Node[] = []\n\n for (let i = 0; i < maxLen; i++) {\n const oldNode = oldNodes[i]\n const newNode = newNodes[i]\n\n if (!oldNode && newNode) {\n // Add new node\n parent.insertBefore(newNode, beforeMarker)\n resultNodes.push(newNode)\n } else if (oldNode && !newNode) {\n // Remove old node\n if (oldNode.parentNode) {\n parent.removeChild(oldNode)\n }\n } else if (oldNode && newNode) {\n // Patch node\n patchNode(oldNode, newNode, parent as Element)\n resultNodes.push(oldNode)\n }\n }\n\n return resultNodes\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","currentResult","unsafeEffect","popContext","Portal","target","portalState","hook","effect","portalWrapper","defaultValue","SuspenseCtx","createContext","suspenseContext","context","Suspense","fallback","pendingSet","pendingCount","setPendingCount","showFallback","setShowFallback","contextValue","promise","c","newCount","content","ErrorBoundary","onError","resetKey","errorState","setErrorState","prevResetKeyRef","lazy","loader","resolved","LazyWrapper","suspense","module","err"],"mappings":"oSAKO,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,CAC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BC,CAAAA,CAAc,CAAE,MAAO,IAAA,CAAM,IAAA,CAAM,IAAK,CAAC,CAAA,CAAA,CAqB7C,GAAID,CAAAA,CAAW,MACb,OAAI,OAAOd,CAAAA,EAAa,UAAA,CACfA,CAAAA,CAASc,CAAAA,CAAW,MAAOA,CAAAA,CAAW,IAAK,EAE7Cd,CAAAA,CAMT,GAAI,CAEF,OAAO/D,CACT,CAAA,OAAE,CAEF,CACF,CCtFO,SAASgF,EACdC,CAAAA,CACkB,CAElB,IAAIC,CAAAA,CAA8C,IAAA,CAC9CZ,CAAAA,CAA+B,KAC/BxD,CAAAA,CAAsB,IAAA,CAGpBqE,EAAepF,CAAAA,EAAyB,CAE5C,GAAImF,CAAAA,CACF,OAAOA,CAAAA,CAASnF,CAAK,CAAA,CAIvB,GAAIe,EACF,MAAMA,CAAAA,CAIR,IAAMsE,CAAAA,CAAWxB,CAAAA,GAGjB,OAAKU,CAAAA,GACHA,CAAAA,CAAUW,CAAAA,EAAO,CACd,IAAA,CAAKI,GAAU,CACdH,CAAAA,CAAWG,EAAO,QACpB,CAAC,EACA,KAAA,CAAMC,CAAAA,EAAO,CACZxE,CAAAA,CAAQwE,CAAAA,YAAe,KAAA,CAAQA,EAAM,IAAI,KAAA,CAAM,OAAOA,CAAG,CAAC,EAC5D,CAAC,CAAA,CAAA,CAIDF,CAAAA,CAAS,WAAA,EACXA,CAAAA,CAAS,QAAA,CAASd,CAAO,CAAA,CAIpB,IACT,EAGC,OAACa,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, parent)\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, parent: HTMLElement): 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 const currentResult = 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 { effect } from '../../core/lifecycle'\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 effect(() => {\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 return () => {\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 { createContext, context } from '../../core/context'\nimport type { SuspenseContextValue } from './types'\n\nconst defaultValue: SuspenseContextValue = {\n register: () => {},\n hasBoundary: false\n}\n\nexport const SuspenseCtx = createContext<SuspenseContextValue>(defaultValue)\n\nexport function suspenseContext(): SuspenseContextValue {\n return context(SuspenseCtx)\n}\n","import { state } from '../../core/state'\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 [pendingCount, setPendingCount] = state(0)\n const [showFallback, setShowFallback] = state(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 { state } from '../../core/state'\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] = state<{\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 {c}from'./chunk-LUREDEUB.mjs';import {b,g}from'./chunk-44RZHCII.mjs';var m=new WeakMap,l=null;function H(e){e.children.forEach(n=>{H(n);}),e.nodes.forEach(n=>{n.parentNode&&n.parentNode.removeChild(n);}),e.children.clear(),e.parentInstance&&e.parentInstance.children.delete(e);}function E(e,n,a){let c$1=a||n,r=f=>{let u={...f.props};return f.children&&f.children.length>0&&(u.children=f.children.length===1?f.children[0]:f.children),u},o=e.key!==void 0;m.has(c$1)||m.set(c$1,new Map);let t=m.get(c$1),i;if(o)i=e.key;else {let f=0,u=e.type.name||"anonymous";t.forEach((b,h)=>{typeof h=="string"&&h.startsWith(`__auto_${u}_`)&&f++;}),i=`__auto_${u}_${f}`;}if(t.has(i)){let f=t.get(i);f.fnode=e;let u=r(e);return f.props=u,f.children.clear(),f.renderFn&&f.renderFn(),f.nodes}let s={hooks:[],hookIndex:0,nodes:[],parent:n,fnode:e,props:r(e),key:i,children:new Set,parentInstance:l||void 0};l&&l.children.add(s),t.set(i,s);let d=true,g$1=()=>{let f=s.fnode,u=s.props;f.type._contextId!==void 0&&c(f.type._contextId,u.value);let h=l;l=s;let M=g(s,()=>f.type(u));if(d){let _=y(M,n);s.nodes=_?Array.isArray(_)?_:[_]:[],s.nodes.forEach(p=>{p.__ownerInstance||(p.__ownerInstance=s);}),d=false;}else {if(s.nodes.length===0){let N=y(M,n);s.nodes=N?Array.isArray(N)?N:[N]:[],l=h;return}let p=s.nodes[0].parentNode;if(!p){l=h;return}let v=document.createComment("flexium-marker"),T=s.nodes[s.nodes.length-1];T.nextSibling?p.insertBefore(v,T.nextSibling):p.appendChild(v),s.children.clear();let O=document.createElement("div"),C=y(M,O,p),F=C?Array.isArray(C)?C:[C]:[],R=P(s.nodes,F,p,v);p.removeChild(v),s.nodes=R;}l=h;};return s.renderFn=g$1,b(g$1),s.nodes}function y(e,n,a){let c=a||n;if(e==null||typeof e=="boolean"){let r=document.createTextNode("");return n.appendChild(r),r}if(typeof e=="string"||typeof e=="number"){let r=document.createTextNode(String(e));return n.appendChild(r),r}if(Array.isArray(e)){let r=new Set;m.has(c)&&m.get(c).forEach((s,d)=>r.add(d));let o=[];e.forEach(i=>{let s=y(i,n,a);s&&(Array.isArray(s)?o.push(...s):o.push(s));});let t=new Set;if(m.has(c)&&m.get(c).forEach((s,d)=>t.add(d)),m.has(c)){let i=m.get(c),s=[];r.forEach(d=>{if(!t.has(d)){let g=i.get(d);g&&(H(g),s.push(d));}}),s.forEach(d=>i.delete(d));}return o}if(typeof e=="object"){if(typeof e.type=="string"){let r=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([o,t])=>{if(o==="ref"&&typeof t=="function")t(r);else if(o.startsWith("on")&&typeof t=="function"){let i=o.slice(2).toLowerCase();r.addEventListener(i,t),r.__eventHandlers||(r.__eventHandlers={}),r.__eventHandlers[i]=t;}else o!=="ref"&&S(r,o,t);}),e.children&&e.children.length>0&&e.children.forEach(o=>{y(o,r);}),n.appendChild(r),r}if(typeof e.type=="function")return e.type._contextId!==void 0,E(e,n,a)}return null}function $(e,n){n.innerHTML="",typeof e=="function"&&(e={type:e,props:{},children:[],key:void 0}),y(e,n);}function B(e,n,...a){return {type:e,props:n||{},children:a,key:n?.key}}function S(e,n,a){a==null?e.removeAttribute(n):n==="style"&&typeof a=="object"?Object.assign(e.style,a):n==="class"?e.className=String(a):n in e&&typeof e[n]!="function"?e[n]=a:e.setAttribute(n,String(a));}function D(e,n){return e.nodeType!==n.nodeType?false:e.nodeType===Node.ELEMENT_NODE&&n.nodeType===Node.ELEMENT_NODE?e.tagName===n.tagName:true}function k(e,n){Array.from(e.attributes).forEach(t=>{n.hasAttribute(t.name)||e.removeAttribute(t.name);}),Array.from(n.attributes).forEach(t=>{e.getAttribute(t.name)!==t.value&&(t.name==="value"&&"value"in e?e.value=t.value:t.name==="checked"&&"checked"in e?e.checked=t.value==="true"||t.value==="":e.setAttribute(t.name,t.value));});let r=e.__eventHandlers||{},o=n.__eventHandlers||{};Object.keys(r).forEach(t=>{o[t]||e.removeEventListener(t,r[t]);}),Object.keys(o).forEach(t=>{r[t]!==o[t]&&(r[t]&&e.removeEventListener(t,r[t]),e.addEventListener(t,o[t]));}),Object.keys(o).length>0?e.__eventHandlers=o:delete e.__eventHandlers,e instanceof HTMLInputElement&&n instanceof HTMLInputElement&&(e.value!==n.value&&(e.value=n.value),e.checked!==n.checked&&(e.checked=n.checked)),e instanceof HTMLTextAreaElement&&n instanceof HTMLTextAreaElement&&e.value!==n.value&&(e.value=n.value),e instanceof HTMLSelectElement&&n instanceof HTMLSelectElement&&e.value!==n.value&&(e.value=n.value);}function j(e,n){let a=Array.from(e.childNodes),c=Array.from(n.childNodes),r=Math.max(a.length,c.length);for(let o=0;o<r;o++){let t=a[o],i=c[o];!t&&i?e.appendChild(i):t&&!i?e.removeChild(t):t&&i&&x(t,i,e);}}function x(e,n,a){if(D(e,n)){let c=n.__ownerInstance;if(c){let r=c.nodes.indexOf(n);r!==-1&&(c.nodes[r]=e),e.__ownerInstance=c,delete n.__ownerInstance;}e.nodeType===Node.TEXT_NODE?e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue):e.nodeType===Node.ELEMENT_NODE&&(k(e,n),j(e,n));}else a.replaceChild(n,e);}function P(e,n,a,c){let r=Math.max(e.length,n.length),o=[];for(let t=0;t<r;t++){let i=e[t],s=n[t];!i&&s?(a.insertBefore(s,c),o.push(s)):i&&!s?i.parentNode&&a.removeChild(i):i&&s&&(x(i,s,a),o.push(i));}return o}export{B as f,P as reconcile,$ as render};//# sourceMappingURL=dom.mjs.map
1
+ import {b as b$3}from'./chunk-E75BJDOQ.mjs';export{a as reconcile,b as render}from'./chunk-E75BJDOQ.mjs';import {a,c,d,b as b$4}from'./chunk-3DKZ2J4D.mjs';import {a as a$2}from'./chunk-WGKD63GN.mjs';import'./chunk-JY6CE6RN.mjs';import {b as b$1,e}from'./chunk-IWFEXW4F.mjs';import {a as a$1,b as b$2}from'./chunk-5PNH2ARD.mjs';function j(e,t,...r){return {type:e,props:t||{},children:r,key:t?.key}}var l=null,F=new WeakMap,m=null;function K(e,t,r={}){let{state:s,onHydrated:o,onMismatch:n}=r;l=t.firstChild;try{let i;typeof e=="function"&&!z(e)?i={type:e,props:{},children:[],key:void 0}:i=e,E(i,t),o?.();}catch(i){console.warn("[Flexium] Hydration mismatch, falling back to full render:",i),n?.(i),t.innerHTML="",import('./render-UIWHIMS2.mjs').then(({render:a})=>{a(e,t);});}finally{l=null;}}function z(e){return e&&typeof e=="object"&&"type"in e&&"props"in e}function E(e,t){if(e==null||typeof e=="boolean")return v(),null;if(typeof e=="string"||typeof e=="number")return X(String(e));if(Array.isArray(e)){let r=[];for(let s of e){let o=E(s,t);o&&(Array.isArray(o)?r.push(...o):r.push(o));}return r}if(typeof e=="function")return b({type:e,props:{},children:[],key:void 0},t);if(typeof e=="object"&&z(e)){if(typeof e.type=="string")return q(e);if(typeof e.type=="function")return b(e,t)}return null}function v(){for(;l&&l.nodeType===Node.TEXT_NODE&&(!l.textContent||l.textContent.trim()==="");)l=l.nextSibling;}function X(e){v();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 q(e,t){v();let r=l,s=e.type;if(!r||r.nodeType!==Node.ELEMENT_NODE)throw new Error(`Hydration mismatch: expected element <${s}>, got ${r?.nodeName||"nothing"}`);if(r.tagName.toLowerCase()!==s.toLowerCase())throw new Error(`Hydration mismatch: expected <${s}>, got <${r.tagName.toLowerCase()}>`);if(e.props){for(let[o,n]of Object.entries(e.props))if(o==="ref")typeof n=="function"?n(r):n&&typeof n=="object"&&"current"in n&&(n.current=r);else if(o.startsWith("on")&&typeof n=="function"){let i=o.slice(2).toLowerCase();r.addEventListener(i,n),r.__eventHandlers||(r.__eventHandlers={}),r.__eventHandlers[i]=n;}}if(l=r.nextSibling,e.children&&e.children.length>0){let o=l;l=r.firstChild;for(let n of e.children)E(n,r);l=o;}return r}function b(e,t){let r=e.type,s={...e.props};e.children&&e.children.length>0&&(s.children=e.children.length===1?e.children[0]:e.children);let o=r._contextId,n=o!==void 0,i;n&&(i=c(o,s.value)),F.has(t)||F.set(t,new Map);let a=F.get(t),x=e.key!==void 0,d$1;if(x)d$1=e.key;else {let y=0,u=r.name||"anonymous";a.forEach((g,h)=>{typeof h=="string"&&h.startsWith(`__auto_${u}_`)&&y++;}),d$1=`__auto_${u}_${y}`;}let p={hooks:[],hookIndex:0,nodes:[],parent:t,fnode:e,props:s,key:d$1,children:new Set,parentInstance:m||void 0};m&&m.children.add(p),a.set(d$1,p);let c$1=m;m=p;try{let y=a$1(p,()=>r(s)),u=E(y,t);p.nodes=u?Array.isArray(u)?u:[u]:[];let g=!0,h=()=>{if(g){g=!1;return}let R=p.props,Z=a$1(p,()=>r(R));};return p.renderFn=h,b$1(h),p.nodes}finally{m=c$1,n&&d(o,i);}}function O(e$1){let{target:t,children:r}=e$1,s=b$2(()=>({container:null,mounted:false}));return e(()=>{let o=null;if(typeof t=="string"?o=document.querySelector(t):t instanceof HTMLElement&&(o=t),!o){console.warn("[Flexium Portal] Target container not found:",t);return}let n=document.createElement("div");return n.setAttribute("data-flexium-portal","true"),o.appendChild(n),s.container=n,s.mounted=true,b$3(r,n),()=>{n.parentNode&&n.parentNode.removeChild(n),s.container=null,s.mounted=false;}},[t,r]),null}var G={register:()=>{},hasBoundary:false},H=a(G);function N(){return b$4(H)}function V(e){let{fallback:t,children:r}=e,s=b$2(()=>new Set),[o,n]=a$2(0),[i,a]=a$2(false),d={register:c=>{s.has(c)||(s.add(c),n(y=>y+1),a(true),c.finally(()=>{s.delete(c),n(y=>{let u=y-1;return u===0&&a(false),u});}));},hasBoundary:true},p=i?t:r;return {type:H.Provider,props:{value:d},children:[p],key:void 0}}function D(e){let{fallback:t,onError:r,children:s,resetKey:o}=e,[n,i]=a$2({error:null,info:null}),a=b$2(()=>({current:o}));o!==a.current&&(a.current=o,n.error!==null&&i({error:null,info:null}));if(n.error)return typeof t=="function"?t(n.error,n.info):t;try{return s}finally{}}function A(e){let t=null,r=null,s=null,o=n=>{if(t)return t(n);if(s)throw s;let i=N();return r||(r=e().then(a=>{t=a.default;}).catch(a=>{s=a instanceof Error?a:new Error(String(a));})),i.hasBoundary&&i.register(r),null};return o._lazy=true,o._loader=e,o}export{D as ErrorBoundary,O as Portal,V as Suspense,j as f,K as hydrate,A as lazy,N as suspenseContext};//# sourceMappingURL=dom.mjs.map
2
2
  //# sourceMappingURL=dom.mjs.map