flexium 0.10.7 → 0.12.6

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 (192) hide show
  1. package/README.md +10 -10
  2. package/dist/canvas.d.cts +83 -23
  3. package/dist/canvas.d.ts +83 -23
  4. package/dist/canvas.js +1 -1
  5. package/dist/canvas.js.map +1 -1
  6. package/dist/canvas.mjs +1 -1
  7. package/dist/canvas.mjs.map +1 -1
  8. package/dist/chunk-44RZHCII.mjs +2 -0
  9. package/dist/chunk-44RZHCII.mjs.map +1 -0
  10. package/dist/chunk-7BXR4ZFD.js +2 -0
  11. package/dist/chunk-7BXR4ZFD.js.map +1 -0
  12. package/dist/chunk-7DXFHPWZ.mjs +2 -0
  13. package/dist/chunk-7DXFHPWZ.mjs.map +1 -0
  14. package/dist/chunk-ALTO2MGI.js +2 -0
  15. package/dist/chunk-ALTO2MGI.js.map +1 -0
  16. package/dist/chunk-C452JE6C.js +2 -0
  17. package/dist/chunk-C452JE6C.js.map +1 -0
  18. package/dist/chunk-CPJRQL2C.mjs +2 -0
  19. package/dist/chunk-CPJRQL2C.mjs.map +1 -0
  20. package/dist/chunk-EJ7Z5OMU.mjs +2 -0
  21. package/dist/chunk-EJ7Z5OMU.mjs.map +1 -0
  22. package/dist/chunk-ENWGYQNU.js +2 -0
  23. package/dist/chunk-ENWGYQNU.js.map +1 -0
  24. package/dist/chunk-EXLNKYSH.js +2 -0
  25. package/dist/chunk-EXLNKYSH.js.map +1 -0
  26. package/dist/chunk-LUREDEUB.mjs +2 -0
  27. package/dist/chunk-LUREDEUB.mjs.map +1 -0
  28. package/dist/chunk-LUW7DIEW.js +2 -0
  29. package/dist/chunk-LUW7DIEW.js.map +1 -0
  30. package/dist/chunk-ZCO4NIGC.mjs +2 -0
  31. package/dist/chunk-ZCO4NIGC.mjs.map +1 -0
  32. package/dist/core.d.cts +41 -2
  33. package/dist/core.d.ts +41 -2
  34. package/dist/core.js +1 -1
  35. package/dist/core.mjs +1 -1
  36. package/dist/dom.d.cts +10 -33
  37. package/dist/dom.d.ts +10 -33
  38. package/dist/dom.js +1 -1
  39. package/dist/dom.js.map +1 -1
  40. package/dist/dom.mjs +1 -1
  41. package/dist/dom.mjs.map +1 -1
  42. package/dist/index.d.cts +1 -24
  43. package/dist/index.d.ts +1 -24
  44. package/dist/index.js +1 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/index.mjs +1 -1
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/interactive.d.cts +65 -148
  49. package/dist/interactive.d.ts +65 -148
  50. package/dist/interactive.js +1 -1
  51. package/dist/interactive.js.map +1 -1
  52. package/dist/interactive.mjs +1 -1
  53. package/dist/interactive.mjs.map +1 -1
  54. package/dist/jsx-dev-runtime.d.cts +6 -2
  55. package/dist/jsx-dev-runtime.d.ts +6 -2
  56. package/dist/jsx-dev-runtime.js +1 -1
  57. package/dist/jsx-dev-runtime.js.map +1 -1
  58. package/dist/jsx-dev-runtime.mjs +1 -1
  59. package/dist/jsx-dev-runtime.mjs.map +1 -1
  60. package/dist/jsx-runtime.d.cts +6 -68
  61. package/dist/jsx-runtime.d.ts +6 -68
  62. package/dist/jsx-runtime.js +1 -1
  63. package/dist/jsx-runtime.mjs +1 -1
  64. package/dist/metafile-cjs.json +1 -1
  65. package/dist/metafile-esm.json +1 -1
  66. package/dist/router.d.cts +48 -15
  67. package/dist/router.d.ts +48 -15
  68. package/dist/router.js +1 -1
  69. package/dist/router.js.map +1 -1
  70. package/dist/router.mjs +1 -1
  71. package/dist/router.mjs.map +1 -1
  72. package/package.json +13 -53
  73. package/dist/DrawText-CVAKQ5wZ.d.cts +0 -309
  74. package/dist/DrawText-Dlh1L1Ar.d.ts +0 -309
  75. package/dist/Motion-BrOAJzgH.d.cts +0 -87
  76. package/dist/Motion-BrOAJzgH.d.ts +0 -87
  77. package/dist/advanced.d.cts +0 -32
  78. package/dist/advanced.d.ts +0 -32
  79. package/dist/advanced.js +0 -2
  80. package/dist/advanced.js.map +0 -1
  81. package/dist/advanced.mjs +0 -2
  82. package/dist/advanced.mjs.map +0 -1
  83. package/dist/chunk-5ICRQIS2.js +0 -3
  84. package/dist/chunk-5ICRQIS2.js.map +0 -1
  85. package/dist/chunk-5K55ASOD.mjs +0 -3
  86. package/dist/chunk-5K55ASOD.mjs.map +0 -1
  87. package/dist/chunk-AZEHBSBG.js +0 -3
  88. package/dist/chunk-AZEHBSBG.js.map +0 -1
  89. package/dist/chunk-BBNYMXE7.mjs +0 -2
  90. package/dist/chunk-BBNYMXE7.mjs.map +0 -1
  91. package/dist/chunk-BYHIHYRR.mjs +0 -2
  92. package/dist/chunk-BYHIHYRR.mjs.map +0 -1
  93. package/dist/chunk-DZ7L3SHV.js +0 -2
  94. package/dist/chunk-DZ7L3SHV.js.map +0 -1
  95. package/dist/chunk-ECYYIQEX.mjs +0 -3
  96. package/dist/chunk-ECYYIQEX.mjs.map +0 -1
  97. package/dist/chunk-FDMJHFN7.mjs +0 -2
  98. package/dist/chunk-FDMJHFN7.mjs.map +0 -1
  99. package/dist/chunk-GKJQEOP7.mjs +0 -2
  100. package/dist/chunk-GKJQEOP7.mjs.map +0 -1
  101. package/dist/chunk-GYDP6MFV.js +0 -3
  102. package/dist/chunk-GYDP6MFV.js.map +0 -1
  103. package/dist/chunk-HB5VPQTB.mjs +0 -2
  104. package/dist/chunk-HB5VPQTB.mjs.map +0 -1
  105. package/dist/chunk-KNF5ERPK.mjs +0 -2
  106. package/dist/chunk-KNF5ERPK.mjs.map +0 -1
  107. package/dist/chunk-OPAAGNBO.mjs +0 -2
  108. package/dist/chunk-OPAAGNBO.mjs.map +0 -1
  109. package/dist/chunk-OPAQ4R4M.mjs +0 -2
  110. package/dist/chunk-OPAQ4R4M.mjs.map +0 -1
  111. package/dist/chunk-Q7IWDVJ4.js +0 -2
  112. package/dist/chunk-Q7IWDVJ4.js.map +0 -1
  113. package/dist/chunk-QPCIDSMM.js +0 -2
  114. package/dist/chunk-QPCIDSMM.js.map +0 -1
  115. package/dist/chunk-QZIX4FXS.mjs +0 -2
  116. package/dist/chunk-QZIX4FXS.mjs.map +0 -1
  117. package/dist/chunk-RMN5IPS5.js +0 -2
  118. package/dist/chunk-RMN5IPS5.js.map +0 -1
  119. package/dist/chunk-U6C6VDVZ.js +0 -2
  120. package/dist/chunk-U6C6VDVZ.js.map +0 -1
  121. package/dist/chunk-WQFQO5LK.js +0 -2
  122. package/dist/chunk-WQFQO5LK.js.map +0 -1
  123. package/dist/chunk-WVEJT7HD.mjs +0 -2
  124. package/dist/chunk-WVEJT7HD.mjs.map +0 -1
  125. package/dist/chunk-WWEWRI6S.js +0 -2
  126. package/dist/chunk-WWEWRI6S.js.map +0 -1
  127. package/dist/chunk-XJHWMHKF.js +0 -2
  128. package/dist/chunk-XJHWMHKF.js.map +0 -1
  129. package/dist/chunk-Y6KKAHLS.mjs +0 -3
  130. package/dist/chunk-Y6KKAHLS.mjs.map +0 -1
  131. package/dist/chunk-YDZ37ZZ4.js +0 -2
  132. package/dist/chunk-YDZ37ZZ4.js.map +0 -1
  133. package/dist/chunk-YPVRQKMW.js +0 -2
  134. package/dist/chunk-YPVRQKMW.js.map +0 -1
  135. package/dist/components-BMbqsbMY.d.cts +0 -126
  136. package/dist/components-C83mBQXW.d.ts +0 -126
  137. package/dist/core-CxHP8991.d.cts +0 -32
  138. package/dist/core-D0ggvjX3.d.ts +0 -32
  139. package/dist/effect-554ONNZR.js +0 -2
  140. package/dist/effect-554ONNZR.js.map +0 -1
  141. package/dist/effect-T2GVIS3T.mjs +0 -2
  142. package/dist/effect-T2GVIS3T.mjs.map +0 -1
  143. package/dist/owner-QS9tPwPr.d.cts +0 -27
  144. package/dist/owner-QS9tPwPr.d.ts +0 -27
  145. package/dist/portal-BK_0Z0hE.d.cts +0 -206
  146. package/dist/portal-CbguxtuQ.d.ts +0 -206
  147. package/dist/primitives/layout.d.cts +0 -295
  148. package/dist/primitives/layout.d.ts +0 -295
  149. package/dist/primitives/layout.js +0 -2
  150. package/dist/primitives/layout.js.map +0 -1
  151. package/dist/primitives/layout.mjs +0 -2
  152. package/dist/primitives/layout.mjs.map +0 -1
  153. package/dist/primitives/motion.d.cts +0 -230
  154. package/dist/primitives/motion.d.ts +0 -230
  155. package/dist/primitives/motion.js +0 -2
  156. package/dist/primitives/motion.js.map +0 -1
  157. package/dist/primitives/motion.mjs +0 -2
  158. package/dist/primitives/motion.mjs.map +0 -1
  159. package/dist/primitives/ui.d.cts +0 -81
  160. package/dist/primitives/ui.d.ts +0 -81
  161. package/dist/primitives/ui.js +0 -2
  162. package/dist/primitives/ui.js.map +0 -1
  163. package/dist/primitives/ui.mjs +0 -2
  164. package/dist/primitives/ui.mjs.map +0 -1
  165. package/dist/primitives.d.cts +0 -93
  166. package/dist/primitives.d.ts +0 -93
  167. package/dist/primitives.js +0 -2
  168. package/dist/primitives.js.map +0 -1
  169. package/dist/primitives.mjs +0 -2
  170. package/dist/primitives.mjs.map +0 -1
  171. package/dist/renderer-DSLb-FGg.d.cts +0 -135
  172. package/dist/renderer-DSLb-FGg.d.ts +0 -135
  173. package/dist/server.d.cts +0 -3
  174. package/dist/server.d.ts +0 -3
  175. package/dist/server.js +0 -2
  176. package/dist/server.js.map +0 -1
  177. package/dist/server.mjs +0 -2
  178. package/dist/server.mjs.map +0 -1
  179. package/dist/state-DitsMyev.d.cts +0 -96
  180. package/dist/state-DitsMyev.d.ts +0 -96
  181. package/dist/state-RYKSC35A.mjs +0 -2
  182. package/dist/state-RYKSC35A.mjs.map +0 -1
  183. package/dist/state-XUXPMCFJ.js +0 -2
  184. package/dist/state-XUXPMCFJ.js.map +0 -1
  185. package/dist/sync-Z4QqUDjF.d.cts +0 -25
  186. package/dist/sync-Z4QqUDjF.d.ts +0 -25
  187. package/dist/test-exports.d.cts +0 -68
  188. package/dist/test-exports.d.ts +0 -68
  189. package/dist/test-exports.js +0 -2
  190. package/dist/test-exports.js.map +0 -1
  191. package/dist/test-exports.mjs +0 -2
  192. package/dist/test-exports.mjs.map +0 -1
@@ -0,0 +1,2 @@
1
+ function i(e,r,t){let{children:n,...o}=r||{};return {type:e,props:o,children:Array.isArray(n)?n:n?[n]:[],key:t}}function a(e,r,t){return i(e,r,t)}function d(e){return e.children}export{i as a,a as b,d as c};//# sourceMappingURL=chunk-ZCO4NIGC.mjs.map
2
+ //# sourceMappingURL=chunk-ZCO4NIGC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx-runtime.ts"],"names":["jsx","type","props","key","children","otherProps","jsxs","Fragment"],"mappings":"AAEO,SAASA,CAAAA,CAAIC,CAAAA,CAAWC,CAAAA,CAAYC,CAAAA,CAAkB,CACzD,GAAM,CAAE,QAAA,CAAAC,CAAAA,CAAU,GAAGC,CAAW,CAAA,CAAIH,CAAAA,EAAS,EAAC,CAC9C,OAAO,CACH,IAAA,CAAAD,CAAAA,CACA,KAAA,CAAOI,CAAAA,CACP,QAAA,CAAU,KAAA,CAAM,OAAA,CAAQD,CAAQ,CAAA,CAAIA,CAAAA,CAAYA,CAAAA,CAAW,CAACA,CAAQ,CAAA,CAAI,EAAC,CACzE,GAAA,CAAAD,CACJ,CACJ,CAEO,SAASG,CAAAA,CAAKL,CAAAA,CAAWC,CAAAA,CAAYC,CAAAA,CAAkB,CAC1D,OAAOH,CAAAA,CAAIC,CAAAA,CAAMC,CAAAA,CAAOC,CAAG,CAC/B,CAEO,SAASI,CAAAA,CAASL,CAAAA,CAAwB,CAC7C,OAAOA,CAAAA,CAAM,QACjB","file":"chunk-ZCO4NIGC.mjs","sourcesContent":["import type { FNode, FNodeChild } from './dom'\n\nexport function jsx(type: any, props: any, key?: any): FNode {\n const { children, ...otherProps } = props || {}\n return {\n type,\n props: otherProps,\n children: Array.isArray(children) ? children : (children ? [children] : []),\n key\n }\n}\n\nexport function jsxs(type: any, props: any, key?: any): FNode {\n return jsx(type, props, key)\n}\n\nexport function Fragment(props: any): FNodeChild {\n return props.children\n}\n\nexport namespace JSX {\n export interface IntrinsicElements {\n [elemName: string]: any\n }\n export type Element = FNode | FNodeChild\n export interface ElementChildrenAttribute {\n children: {}\n }\n}\n"]}
package/dist/core.d.cts CHANGED
@@ -1,2 +1,41 @@
1
- export { A as AsyncStatus, R as RefObject, c as StateAction, d as StateKey, f as StateOptions, S as StateValue, e as equals, b as isStateValue, a as isTruthy, r as ref, s as state } from './state-DitsMyev.cjs';
2
- export { e as effect } from './core-CxHP8991.cjs';
1
+ type StateSetter<T> = (newValue: T | ((prev: T) => T)) => void;
2
+ type ResourceControl = {
3
+ refetch: () => Promise<void>;
4
+ readonly loading: boolean;
5
+ readonly error: unknown;
6
+ readonly status: 'idle' | 'loading' | 'success' | 'error';
7
+ };
8
+ type StateAction<T> = StateSetter<T> | ResourceControl;
9
+ interface StateOptions {
10
+ key?: unknown[];
11
+ }
12
+ declare function state<T>(fn: () => Promise<T>, options?: StateOptions): [T | undefined, ResourceControl];
13
+ declare function state<T>(fn: () => T, options?: StateOptions): [T, ResourceControl];
14
+ declare function state<T>(initialValue: T extends Function ? never : T, options?: StateOptions): [T, StateSetter<T>];
15
+
16
+ declare function effect(fn: () => (void | (() => void)), deps?: any[]): void;
17
+ declare function memo<T>(factory: () => T, deps?: any[]): T;
18
+ /**
19
+ * Unified sync API
20
+ * - sync(): Force refresh (flush pending effects)
21
+ * - sync(fn): Batch updates (run fn then flush)
22
+ */
23
+ declare function sync(fn?: () => void): void;
24
+ declare function batch(fn: () => void): void;
25
+
26
+ interface Context<T> {
27
+ Provider: (props: {
28
+ value: T;
29
+ children: any;
30
+ }) => any;
31
+ id: symbol;
32
+ defaultValue: T;
33
+ }
34
+ declare function createContext<T>(defaultValue: T): Context<T>;
35
+ declare function context<T>(ctx: Context<T>): T;
36
+ declare function pushContext(id: symbol, value: any): any;
37
+ declare function popContext(id: symbol, prevValue: any): void;
38
+ declare function snapshotContext(): Map<symbol, any>;
39
+ declare function runWithContext<R>(snapshot: Map<symbol, any>, fn: () => R): R;
40
+
41
+ export { type Context, type ResourceControl, type StateAction, type StateSetter, batch, context, createContext, effect, memo, popContext, pushContext, runWithContext, snapshotContext, state, sync };
package/dist/core.d.ts CHANGED
@@ -1,2 +1,41 @@
1
- export { A as AsyncStatus, R as RefObject, c as StateAction, d as StateKey, f as StateOptions, S as StateValue, e as equals, b as isStateValue, a as isTruthy, r as ref, s as state } from './state-DitsMyev.js';
2
- export { e as effect } from './core-D0ggvjX3.js';
1
+ type StateSetter<T> = (newValue: T | ((prev: T) => T)) => void;
2
+ type ResourceControl = {
3
+ refetch: () => Promise<void>;
4
+ readonly loading: boolean;
5
+ readonly error: unknown;
6
+ readonly status: 'idle' | 'loading' | 'success' | 'error';
7
+ };
8
+ type StateAction<T> = StateSetter<T> | ResourceControl;
9
+ interface StateOptions {
10
+ key?: unknown[];
11
+ }
12
+ declare function state<T>(fn: () => Promise<T>, options?: StateOptions): [T | undefined, ResourceControl];
13
+ declare function state<T>(fn: () => T, options?: StateOptions): [T, ResourceControl];
14
+ declare function state<T>(initialValue: T extends Function ? never : T, options?: StateOptions): [T, StateSetter<T>];
15
+
16
+ declare function effect(fn: () => (void | (() => void)), deps?: any[]): void;
17
+ declare function memo<T>(factory: () => T, deps?: any[]): T;
18
+ /**
19
+ * Unified sync API
20
+ * - sync(): Force refresh (flush pending effects)
21
+ * - sync(fn): Batch updates (run fn then flush)
22
+ */
23
+ declare function sync(fn?: () => void): void;
24
+ declare function batch(fn: () => void): void;
25
+
26
+ interface Context<T> {
27
+ Provider: (props: {
28
+ value: T;
29
+ children: any;
30
+ }) => any;
31
+ id: symbol;
32
+ defaultValue: T;
33
+ }
34
+ declare function createContext<T>(defaultValue: T): Context<T>;
35
+ declare function context<T>(ctx: Context<T>): T;
36
+ declare function pushContext(id: symbol, value: any): any;
37
+ declare function popContext(id: symbol, prevValue: any): void;
38
+ declare function snapshotContext(): Map<symbol, any>;
39
+ declare function runWithContext<R>(snapshot: Map<symbol, any>, fn: () => R): R;
40
+
41
+ export { type Context, type ResourceControl, type StateAction, type StateSetter, batch, context, createContext, effect, memo, popContext, pushContext, runWithContext, snapshotContext, state, sync };
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkXJHWMHKF_js=require('./chunk-XJHWMHKF.js');require('./chunk-YPVRQKMW.js');var chunkWWEWRI6S_js=require('./chunk-WWEWRI6S.js');require('./chunk-GYDP6MFV.js');Object.defineProperty(exports,"equals",{enumerable:true,get:function(){return chunkXJHWMHKF_js.i}});Object.defineProperty(exports,"isStateValue",{enumerable:true,get:function(){return chunkXJHWMHKF_js.f}});Object.defineProperty(exports,"isTruthy",{enumerable:true,get:function(){return chunkXJHWMHKF_js.j}});Object.defineProperty(exports,"ref",{enumerable:true,get:function(){return chunkXJHWMHKF_js.l}});Object.defineProperty(exports,"state",{enumerable:true,get:function(){return chunkXJHWMHKF_js.k}});Object.defineProperty(exports,"effect",{enumerable:true,get:function(){return chunkWWEWRI6S_js.c}});//# sourceMappingURL=core.js.map
1
+ 'use strict';var chunkLUW7DIEW_js=require('./chunk-LUW7DIEW.js'),chunkC452JE6C_js=require('./chunk-C452JE6C.js'),chunkALTO2MGI_js=require('./chunk-ALTO2MGI.js');require('./chunk-7BXR4ZFD.js'),require('./chunk-ENWGYQNU.js');Object.defineProperty(exports,"context",{enumerable:true,get:function(){return chunkLUW7DIEW_js.b}});Object.defineProperty(exports,"createContext",{enumerable:true,get:function(){return chunkLUW7DIEW_js.a}});Object.defineProperty(exports,"popContext",{enumerable:true,get:function(){return chunkLUW7DIEW_js.d}});Object.defineProperty(exports,"pushContext",{enumerable:true,get:function(){return chunkLUW7DIEW_js.c}});Object.defineProperty(exports,"runWithContext",{enumerable:true,get:function(){return chunkLUW7DIEW_js.f}});Object.defineProperty(exports,"snapshotContext",{enumerable:true,get:function(){return chunkLUW7DIEW_js.e}});Object.defineProperty(exports,"batch",{enumerable:true,get:function(){return chunkC452JE6C_js.d}});Object.defineProperty(exports,"effect",{enumerable:true,get:function(){return chunkC452JE6C_js.a}});Object.defineProperty(exports,"memo",{enumerable:true,get:function(){return chunkC452JE6C_js.b}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkC452JE6C_js.c}});Object.defineProperty(exports,"state",{enumerable:true,get:function(){return chunkALTO2MGI_js.a}});//# sourceMappingURL=core.js.map
2
2
  //# sourceMappingURL=core.js.map
package/dist/core.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export{i as equals,f as isStateValue,j as isTruthy,l as ref,k as state}from'./chunk-BBNYMXE7.mjs';import'./chunk-FDMJHFN7.mjs';export{c as effect}from'./chunk-HB5VPQTB.mjs';import'./chunk-ECYYIQEX.mjs';//# sourceMappingURL=core.mjs.map
1
+ export{b as context,a as createContext,d as popContext,c as pushContext,f as runWithContext,e as snapshotContext}from'./chunk-LUREDEUB.mjs';export{d as batch,a as effect,b as memo,c as sync}from'./chunk-EJ7Z5OMU.mjs';export{a as state}from'./chunk-7DXFHPWZ.mjs';import'./chunk-CPJRQL2C.mjs';import'./chunk-44RZHCII.mjs';//# sourceMappingURL=core.mjs.map
2
2
  //# sourceMappingURL=core.mjs.map
package/dist/dom.d.cts CHANGED
@@ -1,35 +1,12 @@
1
- export { D as DOMRenderer, F as Fragment, P as Portal, a as createReactiveRoot, c as createRoot, d as domRenderer, f, m as mountReactive, r as render } from './portal-BK_0Z0hE.cjs';
2
- export { C as CommonProps, R as Renderer } from './renderer-DSLb-FGg.cjs';
3
- import './state-DitsMyev.cjs';
4
-
5
- /**
6
- * Hydration options
7
- */
8
- interface HydrateOptions {
9
- /** Called when hydration encounters a mismatch */
10
- onMismatch?: (message: string, domNode: Node | null, vnode: any) => void;
11
- /** Whether to recover from mismatches by re-rendering */
12
- recoverMismatch?: boolean;
13
- }
14
- /**
15
- * Hydrate server-rendered HTML with client-side interactivity
16
- *
17
- * This function walks the existing DOM tree and attaches event handlers,
18
- * sets up signal bindings, and validates that the DOM matches the expected vnode structure.
19
- *
20
- * @param vnode - Virtual node to hydrate against
21
- * @param container - Container element with server-rendered HTML
22
- * @param options - Hydration options
23
- *
24
- * @example
25
- * ```tsx
26
- * // Server rendered HTML in #app
27
- * hydrate(<App />, document.getElementById('app'));
28
- * ```
29
- */
30
- declare function hydrate(vnode: any, container: Element, options?: HydrateOptions): void;
31
- declare global {
32
- const __DEV__: boolean | undefined;
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[];
6
+ key?: any;
33
7
  }
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[];
34
11
 
35
- export { hydrate };
12
+ export { type FNode, type FNodeChild, f, reconcile, render };
package/dist/dom.d.ts CHANGED
@@ -1,35 +1,12 @@
1
- export { D as DOMRenderer, F as Fragment, P as Portal, a as createReactiveRoot, c as createRoot, d as domRenderer, f, m as mountReactive, r as render } from './portal-CbguxtuQ.js';
2
- export { C as CommonProps, R as Renderer } from './renderer-DSLb-FGg.js';
3
- import './state-DitsMyev.js';
4
-
5
- /**
6
- * Hydration options
7
- */
8
- interface HydrateOptions {
9
- /** Called when hydration encounters a mismatch */
10
- onMismatch?: (message: string, domNode: Node | null, vnode: any) => void;
11
- /** Whether to recover from mismatches by re-rendering */
12
- recoverMismatch?: boolean;
13
- }
14
- /**
15
- * Hydrate server-rendered HTML with client-side interactivity
16
- *
17
- * This function walks the existing DOM tree and attaches event handlers,
18
- * sets up signal bindings, and validates that the DOM matches the expected vnode structure.
19
- *
20
- * @param vnode - Virtual node to hydrate against
21
- * @param container - Container element with server-rendered HTML
22
- * @param options - Hydration options
23
- *
24
- * @example
25
- * ```tsx
26
- * // Server rendered HTML in #app
27
- * hydrate(<App />, document.getElementById('app'));
28
- * ```
29
- */
30
- declare function hydrate(vnode: any, container: Element, options?: HydrateOptions): void;
31
- declare global {
32
- const __DEV__: boolean | undefined;
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[];
6
+ key?: any;
33
7
  }
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[];
34
11
 
35
- export { hydrate };
12
+ export { type FNode, type FNodeChild, f, reconcile, render };
package/dist/dom.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk5ICRQIS2_js=require('./chunk-5ICRQIS2.js');require('./chunk-DZ7L3SHV.js');var chunkXJHWMHKF_js=require('./chunk-XJHWMHKF.js');require('./chunk-YPVRQKMW.js');var chunkQ7IWDVJ4_js=require('./chunk-Q7IWDVJ4.js');require('./chunk-WQFQO5LK.js');var chunkWWEWRI6S_js=require('./chunk-WWEWRI6S.js');require('./chunk-GYDP6MFV.js');var C={viewBox:"viewBox",preserveAspectRatio:"preserveAspectRatio",strokeWidth:"stroke-width",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",stopColor:"stop-color",stopOpacity:"stop-opacity",clipPath:"clip-path",markerEnd:"marker-end",markerStart:"marker-start",markerMid:"marker-mid"};function M(t,e,s={}){let{onMismatch:n,recoverMismatch:i=false}=s,r=(a,o,p)=>{n?n(a,o,p):typeof __DEV__<"u"&&__DEV__&&console.warn(`[Flexium Hydration] ${a}`);};c(t,e.firstChild,{handleMismatch:r,recoverMismatch:i});}function c(t,e,s){if(t==null||t===false)return e;if(!e)return s.handleMismatch("No DOM node found for vnode",e,t),null;if(typeof t=="string"||typeof t=="number")if(e.nodeType===Node.TEXT_NODE){let n=String(t);return e.textContent!==n&&(s.handleMismatch(`Text mismatch: "${e.textContent}" vs "${n}"`,e,t),e.textContent=n),e.nextSibling}else return s.handleMismatch(`Expected text node, got ${e.nodeType}`,e,t),e.nextSibling;if(chunkXJHWMHKF_js.g(t)&&e.nodeType===Node.TEXT_NODE)return chunkWWEWRI6S_js.c(()=>{e.textContent=String(t());}),e.nextSibling;if(typeof t=="function")return chunkWWEWRI6S_js.c(()=>{let n=t();e.nodeType===Node.TEXT_NODE&&(e.textContent=String(n));}),e.nextSibling;if(typeof t.type=="function"){let n=t.type({...t.props,children:t.children});return c(n,e,s)}if(t.type==="fragment"||t.type===null){let n=e,i=t.children||[];for(let r of i)n=c(r,n,s);return n}if(typeof t.type=="string"){if(e.nodeType!==Node.ELEMENT_NODE)return s.handleMismatch(`Expected element node, got ${e.nodeType}`,e,t),e.nextSibling;let n=e,i=n.tagName.toLowerCase();if(i!==t.type.toLowerCase())return s.handleMismatch(`Tag mismatch: "${i}" vs "${t.type}"`,e,t),e.nextSibling;t.props&&b(n,t.props,s);let r=n.firstChild;if(t.children){let a=Array.isArray(t.children)?t.children.flat():[t.children];for(let o of a)o==null||o===false||(r=c(o,r,s));}return n.nextSibling}return e?.nextSibling||null}function b(t,e,s){for(let n in e){let i=e[n];if(n==="children"||n==="key"||n==="ref"){n==="ref"&&typeof i=="function"&&i(t);continue}if(n.startsWith("on")){let r=n.slice(2).toLowerCase();t.addEventListener(r,i);continue}if(chunkXJHWMHKF_js.g(i)){let r=n==="className"?"class":n;chunkWWEWRI6S_js.c(()=>{let a=i();if(r==="class")t.setAttribute("class",String(a));else if(r==="style"&&typeof a=="object")Object.assign(t.style,a);else {let o=C[r]||r;r in t&&!(t instanceof SVGElement)?t[r]=a:t.setAttribute(o,String(a));}});continue}if(typeof __DEV__<"u"&&__DEV__&&(n==="className"||n==="class")){let r=t.getAttribute("class")||"";r!==i&&s.handleMismatch(`Class mismatch on <${t.tagName.toLowerCase()}>: "${r}" vs "${i}"`,t,e);}}}Object.defineProperty(exports,"DOMRenderer",{enumerable:true,get:function(){return chunk5ICRQIS2_js.a}});Object.defineProperty(exports,"Portal",{enumerable:true,get:function(){return chunk5ICRQIS2_js.i}});Object.defineProperty(exports,"createReactiveRoot",{enumerable:true,get:function(){return chunk5ICRQIS2_js.f}});Object.defineProperty(exports,"createRoot",{enumerable:true,get:function(){return chunk5ICRQIS2_js.h}});Object.defineProperty(exports,"domRenderer",{enumerable:true,get:function(){return chunk5ICRQIS2_js.b}});Object.defineProperty(exports,"mountReactive",{enumerable:true,get:function(){return chunk5ICRQIS2_js.e}});Object.defineProperty(exports,"render",{enumerable:true,get:function(){return chunk5ICRQIS2_js.g}});Object.defineProperty(exports,"Fragment",{enumerable:true,get:function(){return chunkQ7IWDVJ4_js.b}});Object.defineProperty(exports,"f",{enumerable:true,get:function(){return chunkQ7IWDVJ4_js.a}});exports.hydrate=M;//# sourceMappingURL=dom.js.map
1
+ 'use strict';var chunkLUW7DIEW_js=require('./chunk-LUW7DIEW.js'),chunkENWGYQNU_js=require('./chunk-ENWGYQNU.js');var m=new WeakMap,g=null;function A(e){e.children.forEach(n=>{A(n);}),e.nodes.forEach(n=>{n.parentNode&&n.parentNode.removeChild(n);}),e.children.clear(),e.parentInstance&&e.parentInstance.children.delete(e);}function x(e,n,a){let f=a||n,s=c=>{let u={...c.props};return c.children&&c.children.length>0&&(u.children=c.children.length===1?c.children[0]:c.children),u},o=e.key!==void 0;m.has(f)||m.set(f,new Map);let t=m.get(f),i;if(o)i=e.key;else {let c=0,u=e.type.name||"anonymous";t.forEach((_,h)=>{typeof h=="string"&&h.startsWith(`__auto_${u}_`)&&c++;}),i=`__auto_${u}_${c}`;}if(t.has(i)){let c=t.get(i);c.vnode=e;let u=s(e),_=l=>{let N={};for(let v in l)v!=="children"&&typeof l[v]!="function"&&(N[v]=l[v]);return N},h=_(c.props),T=_(u);JSON.stringify(h)!==JSON.stringify(T);return c.props=u,c.children.clear(),c.renderFn&&c.renderFn(),c.nodes}let r={hooks:[],hookIndex:0,nodes:[],parent:n,vnode:e,props:s(e),key:i,children:new Set,parentInstance:g||void 0};g&&g.children.add(r),t.set(i,r);let d=true,E=()=>{let c=r.vnode,u=r.props;c.type._contextId!==void 0&&chunkLUW7DIEW_js.c(c.type._contextId,u.value);let h=g;g=r;let T=chunkENWGYQNU_js.g(r,()=>c.type(u));if(d){let y=C(T,n);r.nodes=y?Array.isArray(y)?y:[y]:[],d=false;}else {if(r.nodes.length===0){let p=C(T,n);r.nodes=p?Array.isArray(p)?p:[p]:[],g=h;return}let y=r.nodes[0],l=y.parentNode;if(!l){g=h;return}let N=document.createComment("flexium-marker");l.insertBefore(N,y),r.children.forEach(p=>{A(p);}),r.children.clear(),r.nodes.forEach(p=>{p.parentNode&&p.parentNode.removeChild(p);});let v=document.createElement("div"),M=C(T,v,l),L=M?Array.isArray(M)?M:[M]:[];L.forEach(p=>{l.insertBefore(p,N);}),l.removeChild(N),r.nodes=L;}g=h;};return r.renderFn=E,chunkENWGYQNU_js.b(E),r.nodes}function C(e,n,a){let f=a||n;if(e==null||typeof e=="boolean"){let s=document.createTextNode("");return n.appendChild(s),s}if(typeof e=="string"||typeof e=="number"){let s=document.createTextNode(String(e));return n.appendChild(s),s}if(Array.isArray(e)){let s=new Set;m.has(f)&&m.get(f).forEach((r,d)=>s.add(d));let o=[];e.forEach(i=>{let r=C(i,n,a);r&&(Array.isArray(r)?o.push(...r):o.push(r));});let t=new Set;if(m.has(f)&&m.get(f).forEach((r,d)=>t.add(d)),m.has(f)){let i=m.get(f),r=[];s.forEach(d=>{if(!t.has(d)){let E=i.get(d);E&&(A(E),r.push(d));}}),r.forEach(d=>i.delete(d));}return o}if(typeof e=="object"){if(typeof e.type=="string"){let s=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([o,t])=>{if(o.startsWith("on")&&typeof t=="function"){let i=o.slice(2).toLowerCase();s.addEventListener(i,t),s.__eventHandlers||(s.__eventHandlers={}),s.__eventHandlers[i]=t;}else F(s,o,t);}),e.children&&e.children.length>0&&e.children.forEach(o=>{C(o,s);}),n.appendChild(s),s}if(typeof e.type=="function")return e.type._contextId!==void 0,x(e,n,a)}return null}function V(e,n){n.innerHTML="",C(e,n);}function W(e,n,...a){return {type:e,props:n||{},children:a,key:n?.key}}function F(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 R(e,n){return e.nodeType!==n.nodeType?false:e.nodeType===Node.ELEMENT_NODE&&n.nodeType===Node.ELEMENT_NODE?e.tagName===n.tagName:true}function S(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&&e.setAttribute(t.name,t.value);});let s=e.__eventHandlers||{},o=n.__eventHandlers||{};Object.keys(s).forEach(t=>{o[t]||e.removeEventListener(t,s[t]);}),Object.keys(o).forEach(t=>{s[t]!==o[t]&&(s[t]&&e.removeEventListener(t,s[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 D(e,n){let a=Array.from(e.childNodes),f=Array.from(n.childNodes),s=Math.max(a.length,f.length);for(let o=0;o<s;o++){let t=a[o],i=f[o];!t&&i?e.appendChild(i):t&&!i?e.removeChild(t):t&&i&&O(t,i,e);}}function O(e,n,a){R(e,n)?e.nodeType===Node.TEXT_NODE?e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue):e.nodeType===Node.ELEMENT_NODE&&(S(e,n),D(e,n)):a.replaceChild(n,e);}function B(e,n,a,f){let s=Math.max(e.length,n.length),o=[];for(let t=0;t<s;t++){let i=e[t],r=n[t];!i&&r?(a.insertBefore(r,f),o.push(r)):i&&!r?i.parentNode&&a.removeChild(i):i&&r&&(O(i,r,a),o.push(i));}return o}exports.f=W;exports.reconcile=B;exports.render=V;//# sourceMappingURL=dom.js.map
2
2
  //# sourceMappingURL=dom.js.map
package/dist/dom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/renderers/dom/hydrate.ts"],"names":["SVG_ATTR_MAP","hydrate","vnode","container","options","onMismatch","recoverMismatch","handleMismatch","message","domNode","vn","hydrateNode","ctx","text","isSignal","effect","value","result","currentNode","children","child","el","tagName","hydrateProps","childDom","props","key","eventName","propName","val","attrName","domClass"],"mappings":"yVAOA,IAAMA,CAAAA,CAAuC,CAC3C,OAAA,CAAS,SAAA,CACT,mBAAA,CAAqB,qBAAA,CACrB,WAAA,CAAa,cAAA,CACb,aAAA,CAAe,gBAAA,CACf,cAAA,CAAgB,iBAAA,CAChB,eAAA,CAAiB,kBAAA,CACjB,gBAAA,CAAkB,mBAAA,CAClB,WAAA,CAAa,cAAA,CACb,aAAA,CAAe,gBAAA,CACf,SAAA,CAAW,YAAA,CACX,WAAA,CAAa,cAAA,CACb,QAAA,CAAU,WAAA,CACV,SAAA,CAAW,YAAA,CACX,WAAA,CAAa,cAAA,CACb,SAAA,CAAW,YACb,CAAA,CA6BO,SAASC,CAAAA,CAEdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0B,EAAC,CAC3B,CACA,GAAM,CAAE,UAAA,CAAAC,CAAAA,CAAY,eAAA,CAAAC,CAAAA,CAAkB,KAAM,CAAA,CAAIF,CAAAA,CAG1CG,CAAAA,CAAiB,CAACC,CAAAA,CAAiBC,CAAAA,CAAsBC,CAAAA,GAAY,CACrEL,CAAAA,CACFA,CAAAA,CAAWG,CAAAA,CAASC,CAAAA,CAASC,CAAE,CAAA,CACtB,OAAO,OAAA,CAAY,GAAA,EAAc,OAAA,EAC1C,OAAA,CA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BS,CAAAA,CAAG,OAAA,CAAQ,WAAA,EAAa,CAAA,IAAA,EAAOU,CAAQ,CAAA,MAAA,EAASf,CAAK,CAAA,CAAA,CAAA,CAC3EK,CAAAA,CACAI,CACF,EAEJ,CAEJ,CACF","file":"dom.js","sourcesContent":["import { isSignal } from '../../core/state'\nimport { effect } from '../../core/effect'\n\n/**\n * SVG Attribute Case Mapping\n * React-like camelCase to SVG case-sensitive attributes\n */\nconst SVG_ATTR_MAP: Record<string, string> = {\n viewBox: 'viewBox',\n preserveAspectRatio: 'preserveAspectRatio',\n strokeWidth: 'stroke-width',\n strokeLinecap: 'stroke-linecap',\n strokeLinejoin: 'stroke-linejoin',\n strokeDasharray: 'stroke-dasharray',\n strokeDashoffset: 'stroke-dashoffset',\n fillOpacity: 'fill-opacity',\n strokeOpacity: 'stroke-opacity',\n stopColor: 'stop-color',\n stopOpacity: 'stop-opacity',\n clipPath: 'clip-path',\n markerEnd: 'marker-end',\n markerStart: 'marker-start',\n markerMid: 'marker-mid',\n}\n\n/**\n * Hydration options\n */\nexport interface HydrateOptions {\n /** Called when hydration encounters a mismatch */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onMismatch?: (message: string, domNode: Node | null, vnode: any) => void\n /** Whether to recover from mismatches by re-rendering */\n recoverMismatch?: boolean\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n *\n * This function walks the existing DOM tree and attaches event handlers,\n * sets up signal bindings, and validates that the DOM matches the expected vnode structure.\n *\n * @param vnode - Virtual node to hydrate against\n * @param container - Container element with server-rendered HTML\n * @param options - Hydration options\n *\n * @example\n * ```tsx\n * // Server rendered HTML in #app\n * hydrate(<App />, document.getElementById('app'));\n * ```\n */\nexport function hydrate(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vnode: any,\n container: Element,\n options: HydrateOptions = {}\n) {\n const { onMismatch, recoverMismatch = false } = options\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handleMismatch = (message: string, domNode: Node | null, vn: any) => {\n if (onMismatch) {\n onMismatch(message, domNode, vn)\n } else if (typeof __DEV__ !== 'undefined' ? __DEV__ : false) {\n console.warn(`[Flexium Hydration] ${message}`)\n }\n }\n\n hydrateNode(vnode, container.firstChild as Node, {\n handleMismatch,\n recoverMismatch,\n })\n}\n\ninterface HydrateContext {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleMismatch: (message: string, domNode: Node | null, vnode: any) => void\n recoverMismatch: boolean\n}\n\nfunction hydrateNode(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vnode: any,\n domNode: Node | null,\n ctx: HydrateContext\n): Node | null {\n if (vnode === null || vnode === undefined || vnode === false) {\n return domNode\n }\n\n if (!domNode) {\n ctx.handleMismatch('No DOM node found for vnode', domNode, vnode)\n return null\n }\n\n // Handle text/number primitives\n if (typeof vnode === 'string' || typeof vnode === 'number') {\n if (domNode.nodeType === Node.TEXT_NODE) {\n const text = String(vnode)\n if (domNode.textContent !== text) {\n ctx.handleMismatch(\n `Text mismatch: \"${domNode.textContent}\" vs \"${text}\"`,\n domNode,\n vnode\n )\n domNode.textContent = text\n }\n return domNode.nextSibling\n } else {\n ctx.handleMismatch(\n `Expected text node, got ${domNode.nodeType}`,\n domNode,\n vnode\n )\n return domNode.nextSibling\n }\n }\n\n // Handle signals - create reactive binding\n if (isSignal(vnode)) {\n if (domNode.nodeType === Node.TEXT_NODE) {\n effect(() => {\n domNode.textContent = String((vnode as any)())\n })\n return domNode.nextSibling\n }\n }\n\n // Handle computed values\n if (typeof vnode === 'function') {\n // Create reactive binding for computed/derived values\n effect(() => {\n const value = vnode()\n if (domNode.nodeType === Node.TEXT_NODE) {\n domNode.textContent = String(value)\n }\n })\n return domNode.nextSibling\n }\n\n // Handle function components\n if (typeof vnode.type === 'function') {\n const result = vnode.type({ ...vnode.props, children: vnode.children })\n return hydrateNode(result, domNode, ctx)\n }\n\n // Handle fragments\n if (vnode.type === 'fragment' || vnode.type === null) {\n let currentNode: Node | null = domNode\n const children = vnode.children || []\n for (const child of children) {\n currentNode = hydrateNode(child, currentNode, ctx)\n }\n return currentNode\n }\n\n // Handle element vnodes\n if (typeof vnode.type === 'string') {\n if (domNode.nodeType !== Node.ELEMENT_NODE) {\n ctx.handleMismatch(\n `Expected element node, got ${domNode.nodeType}`,\n domNode,\n vnode\n )\n return domNode.nextSibling\n }\n\n const el = domNode as Element\n const tagName = el.tagName.toLowerCase()\n\n if (tagName !== vnode.type.toLowerCase()) {\n ctx.handleMismatch(\n `Tag mismatch: \"${tagName}\" vs \"${vnode.type}\"`,\n domNode,\n vnode\n )\n return domNode.nextSibling\n }\n\n // Hydrate props\n if (vnode.props) {\n hydrateProps(el, vnode.props, ctx)\n }\n\n // Hydrate children\n let childDom = el.firstChild\n if (vnode.children) {\n const children = Array.isArray(vnode.children)\n ? vnode.children.flat()\n : [vnode.children]\n for (const child of children) {\n if (child === null || child === undefined || child === false) continue\n childDom = hydrateNode(child, childDom, ctx) as ChildNode | null\n }\n }\n\n return el.nextSibling\n }\n\n return domNode?.nextSibling || null\n}\n\n/**\n * Hydrate element props - attach events, set up reactive bindings\n */\nfunction hydrateProps(\n el: Element,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>,\n ctx: HydrateContext\n): void {\n for (const key in props) {\n const value = props[key]\n\n if (key === 'children' || key === 'key' || key === 'ref') {\n // Handle ref callback\n if (key === 'ref' && typeof value === 'function') {\n value(el)\n }\n continue\n }\n\n // Event handlers\n if (key.startsWith('on')) {\n const eventName = key.slice(2).toLowerCase()\n el.addEventListener(eventName, value)\n continue\n }\n\n // Reactive props (signals)\n if (isSignal(value)) {\n const propName = key === 'className' ? 'class' : key\n effect(() => {\n const val = (value as any)()\n if (propName === 'class') {\n el.setAttribute('class', String(val))\n } else if (propName === 'style' && typeof val === 'object') {\n Object.assign((el as HTMLElement).style, val)\n } else {\n // Handle SVG attributes\n const attrName = SVG_ATTR_MAP[propName] || propName\n\n if (propName in el && !(el instanceof SVGElement)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ; (el as any)[propName] = val\n } else {\n el.setAttribute(attrName, String(val))\n }\n }\n })\n continue\n }\n\n // Validate static props match (in development)\n if (typeof __DEV__ !== 'undefined' ? __DEV__ : false) {\n if (key === 'className' || key === 'class') {\n const domClass = el.getAttribute('class') || ''\n if (domClass !== value) {\n ctx.handleMismatch(\n `Class mismatch on <${el.tagName.toLowerCase()}>: \"${domClass}\" vs \"${value}\"`,\n el,\n props\n )\n }\n }\n }\n }\n}\n\n// Declare global __DEV__ for development mode detection\ndeclare global {\n const __DEV__: boolean | undefined\n}\n"]}
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","filterProps","filtered","oldFiltered","newFiltered","isFirstRender","renderFn","currentVnode","currentProps","pushContext","previousRenderingInstance","result","runWithComponent","newNodes","renderNode","firstNode","nodeParent","marker","tempContainer","newNodesArray","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","reconcile","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,CAAA,CAGDD,CAAAA,CAAS,KAAA,CAAM,OAAA,CAAQE,CAAAA,EAAQ,CACvBA,CAAAA,CAAK,UAAA,EACLA,CAAAA,CAAK,UAAA,CAAW,YAAYA,CAA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AAAA,CAASL,CAAC,CAAA,CACpBZ,CAAAA,CAAU1B,CAAAA,CAASsC,CAAC,CAAA,CAEtB,CAACb,CAAAA,EAAWC,CAAAA,EAEZlD,EAAO,YAAA,CAAakD,CAAAA,CAASkB,CAAY,CAAA,CACzCC,EAAY,IAAA,CAAKnB,CAAO,CAAA,EACjBD,CAAAA,EAAW,CAACC,CAAAA,CAEfD,CAAAA,CAAQ,UAAA,EACRjD,CAAAA,CAAO,YAAYiD,CAAO,CAAA,CAEvBA,CAAAA,EAAWC,CAAAA,GAElBe,EAAUhB,CAAAA,CAASC,CAAAA,CAASlD,CAAiB,CAAA,CAC7CqE,EAAY,IAAA,CAAKpB,CAAO,CAAA,EAEhC,CAEA,OAAOoB,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 vnode: 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 vnode\n instance.vnode = fnode\n\n // Update props (non-reactive) - we'll trigger re-render manually\n const newProps = mergeProps(fnode)\n\n // Check if meaningful props changed\n // Exclude: children (always new objects), functions (event handlers change every render)\n const filterProps = (props: any) => {\n const filtered: any = {}\n for (const key in props) {\n if (key !== 'children' && typeof props[key] !== 'function') {\n filtered[key] = props[key]\n }\n }\n return filtered\n }\n\n const oldFiltered = filterProps(instance.props)\n const newFiltered = filterProps(newProps)\n const propsChanged = JSON.stringify(oldFiltered) !== JSON.stringify(newFiltered)\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 vnode: 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 currentVnode = instance.vnode\n const currentProps = instance.props\n\n // Check if this is a Context Provider\n const isProvider = (currentVnode.type as any)._contextId !== undefined\n if (isProvider) {\n // Set context value before rendering\n pushContext((currentVnode.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, () => currentVnode.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 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\n const marker = document.createComment('flexium-marker')\n nodeParent.insertBefore(marker, firstNode)\n\n // Remove all child instances recursively before re-rendering\n instance.children.forEach(child => {\n removeComponentInstance(child)\n })\n instance.children.clear()\n\n // Remove old nodes\n instance.nodes.forEach(node => {\n if (node.parentNode) {\n node.parentNode.removeChild(node)\n }\n })\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 // Move nodes from temp container to actual parent before marker\n newNodesArray.forEach(node => {\n nodeParent.insertBefore(node, marker)\n })\n\n // Remove marker\n nodeParent.removeChild(marker)\n\n instance.nodes = newNodesArray\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 (VNode)\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.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 {\n // Regular attribute\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 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 oldEl.setAttribute(attr.name, attr.value)\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 // 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"]}
package/dist/dom.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export{a as DOMRenderer,i as Portal,f as createReactiveRoot,h as createRoot,b as domRenderer,e as mountReactive,g as render}from'./chunk-Y6KKAHLS.mjs';import'./chunk-OPAAGNBO.mjs';import {g}from'./chunk-BBNYMXE7.mjs';import'./chunk-FDMJHFN7.mjs';export{b as Fragment,a as f}from'./chunk-WVEJT7HD.mjs';import'./chunk-KNF5ERPK.mjs';import {c as c$1}from'./chunk-HB5VPQTB.mjs';import'./chunk-ECYYIQEX.mjs';var C={viewBox:"viewBox",preserveAspectRatio:"preserveAspectRatio",strokeWidth:"stroke-width",strokeLinecap:"stroke-linecap",strokeLinejoin:"stroke-linejoin",strokeDasharray:"stroke-dasharray",strokeDashoffset:"stroke-dashoffset",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",stopColor:"stop-color",stopOpacity:"stop-opacity",clipPath:"clip-path",markerEnd:"marker-end",markerStart:"marker-start",markerMid:"marker-mid"};function M(t,e,s={}){let{onMismatch:n,recoverMismatch:i=false}=s,r=(a,o,p)=>{n?n(a,o,p):typeof __DEV__<"u"&&__DEV__&&console.warn(`[Flexium Hydration] ${a}`);};c(t,e.firstChild,{handleMismatch:r,recoverMismatch:i});}function c(t,e,s){if(t==null||t===false)return e;if(!e)return s.handleMismatch("No DOM node found for vnode",e,t),null;if(typeof t=="string"||typeof t=="number")if(e.nodeType===Node.TEXT_NODE){let n=String(t);return e.textContent!==n&&(s.handleMismatch(`Text mismatch: "${e.textContent}" vs "${n}"`,e,t),e.textContent=n),e.nextSibling}else return s.handleMismatch(`Expected text node, got ${e.nodeType}`,e,t),e.nextSibling;if(g(t)&&e.nodeType===Node.TEXT_NODE)return c$1(()=>{e.textContent=String(t());}),e.nextSibling;if(typeof t=="function")return c$1(()=>{let n=t();e.nodeType===Node.TEXT_NODE&&(e.textContent=String(n));}),e.nextSibling;if(typeof t.type=="function"){let n=t.type({...t.props,children:t.children});return c(n,e,s)}if(t.type==="fragment"||t.type===null){let n=e,i=t.children||[];for(let r of i)n=c(r,n,s);return n}if(typeof t.type=="string"){if(e.nodeType!==Node.ELEMENT_NODE)return s.handleMismatch(`Expected element node, got ${e.nodeType}`,e,t),e.nextSibling;let n=e,i=n.tagName.toLowerCase();if(i!==t.type.toLowerCase())return s.handleMismatch(`Tag mismatch: "${i}" vs "${t.type}"`,e,t),e.nextSibling;t.props&&b(n,t.props,s);let r=n.firstChild;if(t.children){let a=Array.isArray(t.children)?t.children.flat():[t.children];for(let o of a)o==null||o===false||(r=c(o,r,s));}return n.nextSibling}return e?.nextSibling||null}function b(t,e,s){for(let n in e){let i=e[n];if(n==="children"||n==="key"||n==="ref"){n==="ref"&&typeof i=="function"&&i(t);continue}if(n.startsWith("on")){let r=n.slice(2).toLowerCase();t.addEventListener(r,i);continue}if(g(i)){let r=n==="className"?"class":n;c$1(()=>{let a=i();if(r==="class")t.setAttribute("class",String(a));else if(r==="style"&&typeof a=="object")Object.assign(t.style,a);else {let o=C[r]||r;r in t&&!(t instanceof SVGElement)?t[r]=a:t.setAttribute(o,String(a));}});continue}if(typeof __DEV__<"u"&&__DEV__&&(n==="className"||n==="class")){let r=t.getAttribute("class")||"";r!==i&&s.handleMismatch(`Class mismatch on <${t.tagName.toLowerCase()}>: "${r}" vs "${i}"`,t,e);}}}export{M as hydrate};//# sourceMappingURL=dom.mjs.map
1
+ import {c}from'./chunk-LUREDEUB.mjs';import {b,g as g$1}from'./chunk-44RZHCII.mjs';var m=new WeakMap,g=null;function A(e){e.children.forEach(n=>{A(n);}),e.nodes.forEach(n=>{n.parentNode&&n.parentNode.removeChild(n);}),e.children.clear(),e.parentInstance&&e.parentInstance.children.delete(e);}function x(e,n,a){let f=a||n,s=c=>{let u={...c.props};return c.children&&c.children.length>0&&(u.children=c.children.length===1?c.children[0]:c.children),u},o=e.key!==void 0;m.has(f)||m.set(f,new Map);let t=m.get(f),i;if(o)i=e.key;else {let c=0,u=e.type.name||"anonymous";t.forEach((_,h)=>{typeof h=="string"&&h.startsWith(`__auto_${u}_`)&&c++;}),i=`__auto_${u}_${c}`;}if(t.has(i)){let c=t.get(i);c.vnode=e;let u=s(e),_=l=>{let N={};for(let v in l)v!=="children"&&typeof l[v]!="function"&&(N[v]=l[v]);return N},h=_(c.props),T=_(u);JSON.stringify(h)!==JSON.stringify(T);return c.props=u,c.children.clear(),c.renderFn&&c.renderFn(),c.nodes}let r={hooks:[],hookIndex:0,nodes:[],parent:n,vnode:e,props:s(e),key:i,children:new Set,parentInstance:g||void 0};g&&g.children.add(r),t.set(i,r);let d=true,E=()=>{let c$1=r.vnode,u=r.props;c$1.type._contextId!==void 0&&c(c$1.type._contextId,u.value);let h=g;g=r;let T=g$1(r,()=>c$1.type(u));if(d){let y=C(T,n);r.nodes=y?Array.isArray(y)?y:[y]:[],d=false;}else {if(r.nodes.length===0){let p=C(T,n);r.nodes=p?Array.isArray(p)?p:[p]:[],g=h;return}let y=r.nodes[0],l=y.parentNode;if(!l){g=h;return}let N=document.createComment("flexium-marker");l.insertBefore(N,y),r.children.forEach(p=>{A(p);}),r.children.clear(),r.nodes.forEach(p=>{p.parentNode&&p.parentNode.removeChild(p);});let v=document.createElement("div"),M=C(T,v,l),L=M?Array.isArray(M)?M:[M]:[];L.forEach(p=>{l.insertBefore(p,N);}),l.removeChild(N),r.nodes=L;}g=h;};return r.renderFn=E,b(E),r.nodes}function C(e,n,a){let f=a||n;if(e==null||typeof e=="boolean"){let s=document.createTextNode("");return n.appendChild(s),s}if(typeof e=="string"||typeof e=="number"){let s=document.createTextNode(String(e));return n.appendChild(s),s}if(Array.isArray(e)){let s=new Set;m.has(f)&&m.get(f).forEach((r,d)=>s.add(d));let o=[];e.forEach(i=>{let r=C(i,n,a);r&&(Array.isArray(r)?o.push(...r):o.push(r));});let t=new Set;if(m.has(f)&&m.get(f).forEach((r,d)=>t.add(d)),m.has(f)){let i=m.get(f),r=[];s.forEach(d=>{if(!t.has(d)){let E=i.get(d);E&&(A(E),r.push(d));}}),r.forEach(d=>i.delete(d));}return o}if(typeof e=="object"){if(typeof e.type=="string"){let s=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([o,t])=>{if(o.startsWith("on")&&typeof t=="function"){let i=o.slice(2).toLowerCase();s.addEventListener(i,t),s.__eventHandlers||(s.__eventHandlers={}),s.__eventHandlers[i]=t;}else F(s,o,t);}),e.children&&e.children.length>0&&e.children.forEach(o=>{C(o,s);}),n.appendChild(s),s}if(typeof e.type=="function")return e.type._contextId!==void 0,x(e,n,a)}return null}function V(e,n){n.innerHTML="",C(e,n);}function W(e,n,...a){return {type:e,props:n||{},children:a,key:n?.key}}function F(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 R(e,n){return e.nodeType!==n.nodeType?false:e.nodeType===Node.ELEMENT_NODE&&n.nodeType===Node.ELEMENT_NODE?e.tagName===n.tagName:true}function S(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&&e.setAttribute(t.name,t.value);});let s=e.__eventHandlers||{},o=n.__eventHandlers||{};Object.keys(s).forEach(t=>{o[t]||e.removeEventListener(t,s[t]);}),Object.keys(o).forEach(t=>{s[t]!==o[t]&&(s[t]&&e.removeEventListener(t,s[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 D(e,n){let a=Array.from(e.childNodes),f=Array.from(n.childNodes),s=Math.max(a.length,f.length);for(let o=0;o<s;o++){let t=a[o],i=f[o];!t&&i?e.appendChild(i):t&&!i?e.removeChild(t):t&&i&&O(t,i,e);}}function O(e,n,a){R(e,n)?e.nodeType===Node.TEXT_NODE?e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue):e.nodeType===Node.ELEMENT_NODE&&(S(e,n),D(e,n)):a.replaceChild(n,e);}function B(e,n,a,f){let s=Math.max(e.length,n.length),o=[];for(let t=0;t<s;t++){let i=e[t],r=n[t];!i&&r?(a.insertBefore(r,f),o.push(r)):i&&!r?i.parentNode&&a.removeChild(i):i&&r&&(O(i,r,a),o.push(i));}return o}export{W as f,B as reconcile,V as render};//# sourceMappingURL=dom.mjs.map
2
2
  //# sourceMappingURL=dom.mjs.map
package/dist/dom.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/renderers/dom/hydrate.ts"],"names":["SVG_ATTR_MAP","hydrate","vnode","container","options","onMismatch","recoverMismatch","handleMismatch","message","domNode","vn","hydrateNode","ctx","text","isSignal","effect","value","result","currentNode","children","child","el","tagName","hydrateProps","child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AA,GAAa,OAAA,CACfP,CAAAA,CAAG,YAAA,CAAa,OAAA,CAAS,MAAA,CAAOQ,CAAG,CAAC,CAAA,CAAA,KAAA,GAC3BD,CAAAA,GAAa,OAAA,EAAW,OAAOC,CAAAA,EAAQ,QAAA,CAChD,MAAA,CAAO,MAAA,CAAQR,EAAmB,KAAA,CAAOQ,CAAG,CAAA,CAAA,KACvC,CAEL,IAAMC,CAAAA,CAAW9B,CAAAA,CAAa4B,CAAQ,CAAA,EAAKA,CAAAA,CAEvCA,CAAAA,IAAYP,CAAAA,EAAM,EAAEA,CAAAA,YAAc,UAAA,CAAA,CAEjCA,CAAAA,CAAWO,CAAQ,CAAA,CAAIC,CAAAA,CAE1BR,CAAAA,CAAG,YAAA,CAAaS,CAAAA,CAAU,MAAA,CAAOD,CAAG,CAAC,EAEzC,CACF,CAAC,CAAA,CACD,QACF,CAGA,GAAI,OAAO,OAAA,CAAY,GAAA,EAAc,OAAA,GAC/BH,CAAAA,GAAQ,WAAA,EAAeA,CAAAA,GAAQ,OAAA,CAAA,CAAS,CAC1C,IAAMK,CAAAA,CAAWV,CAAAA,CAAG,YAAA,CAAa,OAAO,CAAA,EAAK,EAAA,CACzCU,CAAAA,GAAaf,CAAAA,EACfJ,CAAAA,CAAI,cAAA,CACF,CAAA,mBAAA,EAAsBS,CAAAA,CAAG,OAAA,CAAQ,WAAA,EAAa,CAAA,IAAA,EAAOU,CAAQ,CAAA,MAAA,EAASf,CAAK,CAAA,CAAA,CAAA,CAC3EK,CAAAA,CACAI,CACF,EAEJ,CAEJ,CACF","file":"dom.mjs","sourcesContent":["import { isSignal } from '../../core/state'\nimport { effect } from '../../core/effect'\n\n/**\n * SVG Attribute Case Mapping\n * React-like camelCase to SVG case-sensitive attributes\n */\nconst SVG_ATTR_MAP: Record<string, string> = {\n viewBox: 'viewBox',\n preserveAspectRatio: 'preserveAspectRatio',\n strokeWidth: 'stroke-width',\n strokeLinecap: 'stroke-linecap',\n strokeLinejoin: 'stroke-linejoin',\n strokeDasharray: 'stroke-dasharray',\n strokeDashoffset: 'stroke-dashoffset',\n fillOpacity: 'fill-opacity',\n strokeOpacity: 'stroke-opacity',\n stopColor: 'stop-color',\n stopOpacity: 'stop-opacity',\n clipPath: 'clip-path',\n markerEnd: 'marker-end',\n markerStart: 'marker-start',\n markerMid: 'marker-mid',\n}\n\n/**\n * Hydration options\n */\nexport interface HydrateOptions {\n /** Called when hydration encounters a mismatch */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onMismatch?: (message: string, domNode: Node | null, vnode: any) => void\n /** Whether to recover from mismatches by re-rendering */\n recoverMismatch?: boolean\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n *\n * This function walks the existing DOM tree and attaches event handlers,\n * sets up signal bindings, and validates that the DOM matches the expected vnode structure.\n *\n * @param vnode - Virtual node to hydrate against\n * @param container - Container element with server-rendered HTML\n * @param options - Hydration options\n *\n * @example\n * ```tsx\n * // Server rendered HTML in #app\n * hydrate(<App />, document.getElementById('app'));\n * ```\n */\nexport function hydrate(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vnode: any,\n container: Element,\n options: HydrateOptions = {}\n) {\n const { onMismatch, recoverMismatch = false } = options\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handleMismatch = (message: string, domNode: Node | null, vn: any) => {\n if (onMismatch) {\n onMismatch(message, domNode, vn)\n } else if (typeof __DEV__ !== 'undefined' ? __DEV__ : false) {\n console.warn(`[Flexium Hydration] ${message}`)\n }\n }\n\n hydrateNode(vnode, container.firstChild as Node, {\n handleMismatch,\n recoverMismatch,\n })\n}\n\ninterface HydrateContext {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleMismatch: (message: string, domNode: Node | null, vnode: any) => void\n recoverMismatch: boolean\n}\n\nfunction hydrateNode(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n vnode: any,\n domNode: Node | null,\n ctx: HydrateContext\n): Node | null {\n if (vnode === null || vnode === undefined || vnode === false) {\n return domNode\n }\n\n if (!domNode) {\n ctx.handleMismatch('No DOM node found for vnode', domNode, vnode)\n return null\n }\n\n // Handle text/number primitives\n if (typeof vnode === 'string' || typeof vnode === 'number') {\n if (domNode.nodeType === Node.TEXT_NODE) {\n const text = String(vnode)\n if (domNode.textContent !== text) {\n ctx.handleMismatch(\n `Text mismatch: \"${domNode.textContent}\" vs \"${text}\"`,\n domNode,\n vnode\n )\n domNode.textContent = text\n }\n return domNode.nextSibling\n } else {\n ctx.handleMismatch(\n `Expected text node, got ${domNode.nodeType}`,\n domNode,\n vnode\n )\n return domNode.nextSibling\n }\n }\n\n // Handle signals - create reactive binding\n if (isSignal(vnode)) {\n if (domNode.nodeType === Node.TEXT_NODE) {\n effect(() => {\n domNode.textContent = String((vnode as any)())\n })\n return domNode.nextSibling\n }\n }\n\n // Handle computed values\n if (typeof vnode === 'function') {\n // Create reactive binding for computed/derived values\n effect(() => {\n const value = vnode()\n if (domNode.nodeType === Node.TEXT_NODE) {\n domNode.textContent = String(value)\n }\n })\n return domNode.nextSibling\n }\n\n // Handle function components\n if (typeof vnode.type === 'function') {\n const result = vnode.type({ ...vnode.props, children: vnode.children })\n return hydrateNode(result, domNode, ctx)\n }\n\n // Handle fragments\n if (vnode.type === 'fragment' || vnode.type === null) {\n let currentNode: Node | null = domNode\n const children = vnode.children || []\n for (const child of children) {\n currentNode = hydrateNode(child, currentNode, ctx)\n }\n return currentNode\n }\n\n // Handle element vnodes\n if (typeof vnode.type === 'string') {\n if (domNode.nodeType !== Node.ELEMENT_NODE) {\n ctx.handleMismatch(\n `Expected element node, got ${domNode.nodeType}`,\n domNode,\n vnode\n )\n return domNode.nextSibling\n }\n\n const el = domNode as Element\n const tagName = el.tagName.toLowerCase()\n\n if (tagName !== vnode.type.toLowerCase()) {\n ctx.handleMismatch(\n `Tag mismatch: \"${tagName}\" vs \"${vnode.type}\"`,\n domNode,\n vnode\n )\n return domNode.nextSibling\n }\n\n // Hydrate props\n if (vnode.props) {\n hydrateProps(el, vnode.props, ctx)\n }\n\n // Hydrate children\n let childDom = el.firstChild\n if (vnode.children) {\n const children = Array.isArray(vnode.children)\n ? vnode.children.flat()\n : [vnode.children]\n for (const child of children) {\n if (child === null || child === undefined || child === false) continue\n childDom = hydrateNode(child, childDom, ctx) as ChildNode | null\n }\n }\n\n return el.nextSibling\n }\n\n return domNode?.nextSibling || null\n}\n\n/**\n * Hydrate element props - attach events, set up reactive bindings\n */\nfunction hydrateProps(\n el: Element,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n props: Record<string, any>,\n ctx: HydrateContext\n): void {\n for (const key in props) {\n const value = props[key]\n\n if (key === 'children' || key === 'key' || key === 'ref') {\n // Handle ref callback\n if (key === 'ref' && typeof value === 'function') {\n value(el)\n }\n continue\n }\n\n // Event handlers\n if (key.startsWith('on')) {\n const eventName = key.slice(2).toLowerCase()\n el.addEventListener(eventName, value)\n continue\n }\n\n // Reactive props (signals)\n if (isSignal(value)) {\n const propName = key === 'className' ? 'class' : key\n effect(() => {\n const val = (value as any)()\n if (propName === 'class') {\n el.setAttribute('class', String(val))\n } else if (propName === 'style' && typeof val === 'object') {\n Object.assign((el as HTMLElement).style, val)\n } else {\n // Handle SVG attributes\n const attrName = SVG_ATTR_MAP[propName] || propName\n\n if (propName in el && !(el instanceof SVGElement)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ; (el as any)[propName] = val\n } else {\n el.setAttribute(attrName, String(val))\n }\n }\n })\n continue\n }\n\n // Validate static props match (in development)\n if (typeof __DEV__ !== 'undefined' ? __DEV__ : false) {\n if (key === 'className' || key === 'class') {\n const domClass = el.getAttribute('class') || ''\n if (domClass !== value) {\n ctx.handleMismatch(\n `Class mismatch on <${el.tagName.toLowerCase()}>: \"${domClass}\" vs \"${value}\"`,\n el,\n props\n )\n }\n }\n }\n }\n}\n\n// Declare global __DEV__ for development mode detection\ndeclare global {\n const __DEV__: boolean | undefined\n}\n"]}
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","filterProps","filtered","oldFiltered","newFiltered","isFirstRender","renderFn","currentVnode","currentProps","pushContext","previousRenderingInstance","result","runWithComponent","newNodes","renderNode","firstNode","nodeParent","marker","tempContainer","newNodesArray","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","reconcile","oldNodes","beforeMarker","resultNodes"],"mappings":"mFA4BA,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,CAAA,CAGDD,CAAAA,CAAS,KAAA,CAAM,OAAA,CAAQE,CAAAA,EAAQ,CACvBA,CAAAA,CAAK,UAAA,EACLA,CAAAA,CAAK,UAAA,CAAW,YAAYA,CAAI,EAExC,CAAC,CAAA,CAGDF,EAAS,QAAA,CAAS,KAAA,EAAM,CAGpBA,CAAAA,CAAS,cAAA,EACTA,CAAAA,CAAS,cAAA,CAAe,QAAA,CAAS,OAAOA,CAAQ,EAExD,CAGA,SAASG,EAAgBC,CAAAA,CAAYC,CAAAA,CAAqBC,CAAAA,CAAsC,CAC5F,IAAMC,CAAAA,CAA0BD,CAAAA,EAAkBD,CAAAA,CAE5CG,CAAAA,CAAcN,CAAAA,EAAc,CAC9B,IAAMO,CAAAA,CAAQ,CAAE,GAAGP,CAAAA,CAAK,KAAM,CAAA,CAC9B,OAAIA,CAAAA,CAAK,QAAA,EAAYA,CAAA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B,CAAO,CAAA,EAEhC,CAEA,OAAOoB,CACX","file":"dom.mjs","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 vnode: 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 vnode\n instance.vnode = fnode\n\n // Update props (non-reactive) - we'll trigger re-render manually\n const newProps = mergeProps(fnode)\n\n // Check if meaningful props changed\n // Exclude: children (always new objects), functions (event handlers change every render)\n const filterProps = (props: any) => {\n const filtered: any = {}\n for (const key in props) {\n if (key !== 'children' && typeof props[key] !== 'function') {\n filtered[key] = props[key]\n }\n }\n return filtered\n }\n\n const oldFiltered = filterProps(instance.props)\n const newFiltered = filterProps(newProps)\n const propsChanged = JSON.stringify(oldFiltered) !== JSON.stringify(newFiltered)\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 vnode: 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 currentVnode = instance.vnode\n const currentProps = instance.props\n\n // Check if this is a Context Provider\n const isProvider = (currentVnode.type as any)._contextId !== undefined\n if (isProvider) {\n // Set context value before rendering\n pushContext((currentVnode.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, () => currentVnode.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 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\n const marker = document.createComment('flexium-marker')\n nodeParent.insertBefore(marker, firstNode)\n\n // Remove all child instances recursively before re-rendering\n instance.children.forEach(child => {\n removeComponentInstance(child)\n })\n instance.children.clear()\n\n // Remove old nodes\n instance.nodes.forEach(node => {\n if (node.parentNode) {\n node.parentNode.removeChild(node)\n }\n })\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 // Move nodes from temp container to actual parent before marker\n newNodesArray.forEach(node => {\n nodeParent.insertBefore(node, marker)\n })\n\n // Remove marker\n nodeParent.removeChild(marker)\n\n instance.nodes = newNodesArray\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 (VNode)\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.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 {\n // Regular attribute\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 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 oldEl.setAttribute(attr.name, attr.value)\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 // 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"]}
package/dist/index.d.cts CHANGED
@@ -1,26 +1,3 @@
1
- /**
2
- * Flexium - Next-generation UI/UX library
3
- *
4
- * Please use explicit imports from submodules:
5
- *
6
- * @example
7
- * ```tsx
8
- * // Core reactivity
9
- * import { state, effect } from 'flexium/core'
10
- *
11
- * // DOM rendering
12
- * import { render, createRoot, Portal } from 'flexium/dom'
13
- *
14
- * // Canvas rendering
15
- * import { Canvas, Rect, Circle } from 'flexium/canvas'
16
- *
17
- * // Cross-platform primitives
18
- * import { Row, Column, Text } from 'flexium/primitives'
19
- *
20
- * // Router
21
- * import { Router, Route, Link } from 'flexium/router'
22
- * ```
23
- */
24
- declare const VERSION = "0.10.7";
1
+ declare const VERSION = "0.12.6";
25
2
 
26
3
  export { VERSION };
package/dist/index.d.ts CHANGED
@@ -1,26 +1,3 @@
1
- /**
2
- * Flexium - Next-generation UI/UX library
3
- *
4
- * Please use explicit imports from submodules:
5
- *
6
- * @example
7
- * ```tsx
8
- * // Core reactivity
9
- * import { state, effect } from 'flexium/core'
10
- *
11
- * // DOM rendering
12
- * import { render, createRoot, Portal } from 'flexium/dom'
13
- *
14
- * // Canvas rendering
15
- * import { Canvas, Rect, Circle } from 'flexium/canvas'
16
- *
17
- * // Cross-platform primitives
18
- * import { Row, Column, Text } from 'flexium/primitives'
19
- *
20
- * // Router
21
- * import { Router, Route, Link } from 'flexium/router'
22
- * ```
23
- */
24
- declare const VERSION = "0.10.7";
1
+ declare const VERSION = "0.12.6";
25
2
 
26
3
  export { VERSION };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var o="0.10.7";exports.VERSION=o;//# sourceMappingURL=index.js.map
1
+ 'use strict';var o="0.12.6";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":"aAwBO,IAAMA,CAAAA,CAAU","file":"index.js","sourcesContent":["/**\n * Flexium - Next-generation UI/UX library\n *\n * Please use explicit imports from submodules:\n *\n * @example\n * ```tsx\n * // Core reactivity\n * import { state, effect } from 'flexium/core'\n *\n * // DOM rendering\n * import { render, createRoot, Portal } from 'flexium/dom'\n *\n * // Canvas rendering\n * import { Canvas, Rect, Circle } from 'flexium/canvas'\n *\n * // Cross-platform primitives\n * import { Row, Column, Text } from 'flexium/primitives'\n *\n * // Router\n * import { Router, Route, Link } from 'flexium/router'\n * ```\n */\n\nexport const VERSION = '0.10.7'\n\n// Intentionally empty - use explicit submodule imports\n// flexium/core, flexium/dom, flexium/canvas, flexium/primitives, flexium/router\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"aAAO,IAAMA,CAAAA,CAAU","file":"index.js","sourcesContent":["export const VERSION = '0.12.6' // Bump version to signify rebuild\n"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var o="0.10.7";export{o as VERSION};//# sourceMappingURL=index.mjs.map
1
+ var o="0.12.6";export{o as VERSION};//# sourceMappingURL=index.mjs.map
2
2
  //# sourceMappingURL=index.mjs.map