flexium 0.12.13 → 0.12.17

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 (101) hide show
  1. package/README.md +149 -92
  2. package/dist/canvas.d.cts +14 -13
  3. package/dist/canvas.d.ts +14 -13
  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-3DKZ2J4D.mjs +2 -0
  9. package/dist/chunk-3DKZ2J4D.mjs.map +1 -0
  10. package/dist/chunk-5PNH2ARD.mjs +2 -0
  11. package/dist/chunk-5PNH2ARD.mjs.map +1 -0
  12. package/dist/{chunk-7BXR4ZFD.js → chunk-6VIRXD2Y.js} +2 -2
  13. package/dist/chunk-6VIRXD2Y.js.map +1 -0
  14. package/dist/chunk-6Z33DLMI.js +2 -0
  15. package/dist/chunk-6Z33DLMI.js.map +1 -0
  16. package/dist/chunk-E75BJDOQ.mjs +2 -0
  17. package/dist/chunk-E75BJDOQ.mjs.map +1 -0
  18. package/dist/chunk-IWFEXW4F.mjs +2 -0
  19. package/dist/chunk-IWFEXW4F.mjs.map +1 -0
  20. package/dist/chunk-JY6CE6RN.mjs +2 -0
  21. package/dist/chunk-JY6CE6RN.mjs.map +1 -0
  22. package/dist/chunk-LTT43APF.js +2 -0
  23. package/dist/chunk-LTT43APF.js.map +1 -0
  24. package/dist/chunk-PSKDIB7J.js +2 -0
  25. package/dist/chunk-PSKDIB7J.js.map +1 -0
  26. package/dist/chunk-UWFVCKRU.js +2 -0
  27. package/dist/chunk-UWFVCKRU.js.map +1 -0
  28. package/dist/chunk-WGKD63GN.mjs +2 -0
  29. package/dist/chunk-WGKD63GN.mjs.map +1 -0
  30. package/dist/chunk-YWTD32NA.js +2 -0
  31. package/dist/chunk-YWTD32NA.js.map +1 -0
  32. package/dist/core.d.cts +91 -15
  33. package/dist/core.d.ts +91 -15
  34. package/dist/core.js +1 -1
  35. package/dist/core.js.map +1 -1
  36. package/dist/core.mjs +1 -1
  37. package/dist/core.mjs.map +1 -1
  38. package/dist/dom.d.cts +154 -9
  39. package/dist/dom.d.ts +154 -9
  40. package/dist/dom.js +1 -1
  41. package/dist/dom.js.map +1 -1
  42. package/dist/dom.mjs +1 -1
  43. package/dist/dom.mjs.map +1 -1
  44. package/dist/index.d.cts +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js +1 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +1 -1
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/interactive.d.cts +17 -16
  51. package/dist/interactive.d.ts +17 -16
  52. package/dist/interactive.js +1 -1
  53. package/dist/interactive.js.map +1 -1
  54. package/dist/interactive.mjs +1 -1
  55. package/dist/interactive.mjs.map +1 -1
  56. package/dist/jsx-dev-runtime.d.cts +1 -1
  57. package/dist/jsx-dev-runtime.d.ts +1 -1
  58. package/dist/jsx-runtime.d.cts +1 -1
  59. package/dist/jsx-runtime.d.ts +1 -1
  60. package/dist/metafile-cjs.json +1 -1
  61. package/dist/metafile-esm.json +1 -1
  62. package/dist/render-QZAFAGIM.js +2 -0
  63. package/dist/render-QZAFAGIM.js.map +1 -0
  64. package/dist/render-UIWHIMS2.mjs +2 -0
  65. package/dist/render-UIWHIMS2.mjs.map +1 -0
  66. package/dist/router.d.cts +1 -1
  67. package/dist/router.d.ts +1 -1
  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/dist/server.d.cts +17 -0
  73. package/dist/server.d.ts +17 -0
  74. package/dist/server.js +2 -0
  75. package/dist/server.js.map +1 -0
  76. package/dist/server.mjs +2 -0
  77. package/dist/server.mjs.map +1 -0
  78. package/dist/types-CxlS2F2j.d.cts +19 -0
  79. package/dist/types-CxlS2F2j.d.ts +19 -0
  80. package/dist/types-y2GGaXXk.d.cts +9 -0
  81. package/dist/types-y2GGaXXk.d.ts +9 -0
  82. package/package.json +6 -1
  83. package/dist/chunk-44RZHCII.mjs +0 -2
  84. package/dist/chunk-44RZHCII.mjs.map +0 -1
  85. package/dist/chunk-7BXR4ZFD.js.map +0 -1
  86. package/dist/chunk-APAMPY43.js +0 -2
  87. package/dist/chunk-APAMPY43.js.map +0 -1
  88. package/dist/chunk-CPJRQL2C.mjs +0 -2
  89. package/dist/chunk-CPJRQL2C.mjs.map +0 -1
  90. package/dist/chunk-ECB5HZOQ.mjs +0 -2
  91. package/dist/chunk-ECB5HZOQ.mjs.map +0 -1
  92. package/dist/chunk-ENWGYQNU.js +0 -2
  93. package/dist/chunk-ENWGYQNU.js.map +0 -1
  94. package/dist/chunk-IA4FEBFE.js +0 -2
  95. package/dist/chunk-IA4FEBFE.js.map +0 -1
  96. package/dist/chunk-LUREDEUB.mjs +0 -2
  97. package/dist/chunk-LUREDEUB.mjs.map +0 -1
  98. package/dist/chunk-LUW7DIEW.js +0 -2
  99. package/dist/chunk-LUW7DIEW.js.map +0 -1
  100. package/dist/chunk-S6WF3XNF.mjs +0 -2
  101. package/dist/chunk-S6WF3XNF.mjs.map +0 -1
package/dist/core.d.cts CHANGED
@@ -1,3 +1,5 @@
1
+ import { F as FNodeChild } from './types-y2GGaXXk.cjs';
2
+
1
3
  type StateSetter<T> = (newValue: T | ((prev: T) => T)) => void;
2
4
  type ResourceControl = {
3
5
  refetch: () => Promise<void>;
@@ -5,15 +7,33 @@ type ResourceControl = {
5
7
  readonly error: unknown;
6
8
  readonly status: 'idle' | 'loading' | 'success' | 'error';
7
9
  };
8
- type StateAction<T> = StateSetter<T> | ResourceControl;
9
10
  interface StateOptions {
10
11
  key?: unknown[];
11
12
  deps?: any[];
13
+ /** Debug name for DevTools */
14
+ name?: string;
12
15
  }
16
+ interface Context<T> {
17
+ Provider: (props: {
18
+ value: T;
19
+ children: any;
20
+ }) => any;
21
+ id: symbol;
22
+ defaultValue: T;
23
+ }
24
+
25
+ type StateAction<T> = StateSetter<T> | ResourceControl;
13
26
  declare function state<T>(fn: () => Promise<T>, options?: StateOptions): [T | undefined, ResourceControl];
14
27
  declare function state<T>(fn: () => T, options?: StateOptions): [T, ResourceControl];
15
28
  declare function state<T>(initialValue: T extends Function ? never : T, options?: StateOptions): [T, StateSetter<T>];
16
29
 
30
+ interface RefObject<T> {
31
+ current: T | null;
32
+ }
33
+ type RefCallback<T> = (instance: T | null) => void;
34
+ type Ref<T> = RefObject<T> | RefCallback<T> | null;
35
+ type ForwardedRef<T> = RefCallback<T> | RefObject<T> | null;
36
+
17
37
  declare function effect(fn: () => (void | (() => void)), deps?: any[]): void;
18
38
  /**
19
39
  * Unified sync API
@@ -21,21 +41,77 @@ declare function effect(fn: () => (void | (() => void)), deps?: any[]): void;
21
41
  * - sync(fn): Batch updates (run fn then flush)
22
42
  */
23
43
  declare function sync(fn?: () => void): void;
24
- declare function batch(fn: () => void): void;
25
44
 
26
- interface Context<T> {
27
- Provider: (props: {
28
- value: T;
29
- children: any;
30
- }) => any;
31
- id: symbol;
32
- defaultValue: T;
33
- }
34
45
  declare function createContext<T>(defaultValue: T): Context<T>;
35
46
  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
47
 
41
- export { type Context, type ResourceControl, type StateAction, type StateSetter, batch, context, createContext, effect, popContext, pushContext, runWithContext, snapshotContext, state, sync };
48
+ declare const FORWARD_REF_SYMBOL: unique symbol;
49
+ interface ForwardRefRenderFunction<P, T> {
50
+ (props: P, ref: ForwardedRef<T>): FNodeChild;
51
+ }
52
+ interface ForwardRefComponent<P, T> {
53
+ (props: P & {
54
+ ref?: Ref<T>;
55
+ }): FNodeChild;
56
+ $$typeof: typeof FORWARD_REF_SYMBOL;
57
+ render: ForwardRefRenderFunction<P, T>;
58
+ }
59
+ /**
60
+ * Forwards a ref through a component to a child element
61
+ *
62
+ * @example
63
+ * ```tsx
64
+ * const FancyInput = forwardRef<{ placeholder?: string }, HTMLInputElement>(
65
+ * (props, ref) => {
66
+ * return (
67
+ * <input
68
+ * ref={ref}
69
+ * class="fancy-input"
70
+ * placeholder={props.placeholder}
71
+ * />
72
+ * )
73
+ * }
74
+ * )
75
+ *
76
+ * function Parent() {
77
+ * const inputRef = ref<HTMLInputElement>()
78
+ *
79
+ * return (
80
+ * <div>
81
+ * <FancyInput ref={inputRef} placeholder="Type here..." />
82
+ * <button onClick={() => inputRef.current?.select()}>
83
+ * Select All
84
+ * </button>
85
+ * </div>
86
+ * )
87
+ * }
88
+ * ```
89
+ */
90
+ declare function forwardRef<P = {}, T = HTMLElement>(render: ForwardRefRenderFunction<P, T>): ForwardRefComponent<P, T>;
91
+
92
+ /**
93
+ * Creates a mutable ref object that persists across renders
94
+ *
95
+ * @example
96
+ * ```tsx
97
+ * function InputWithFocus() {
98
+ * const inputRef = ref<HTMLInputElement>()
99
+ *
100
+ * const focusInput = () => {
101
+ * inputRef.current?.focus()
102
+ * }
103
+ *
104
+ * return (
105
+ * <div>
106
+ * <input ref={inputRef} type="text" />
107
+ * <button onClick={focusInput}>Focus Input</button>
108
+ * </div>
109
+ * )
110
+ * }
111
+ * ```
112
+ */
113
+ declare function ref<T>(initialValue: T): RefObject<T>;
114
+ declare function ref<T>(initialValue: T | null): RefObject<T | null>;
115
+ declare function ref<T = undefined>(): RefObject<T | undefined>;
116
+
117
+ export { type Context, type ForwardedRef, type Ref, type RefCallback, type RefObject, type ResourceControl, type StateAction, type StateOptions, type StateSetter, context, createContext, effect, forwardRef, ref, state, sync };
package/dist/core.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { F as FNodeChild } from './types-y2GGaXXk.js';
2
+
1
3
  type StateSetter<T> = (newValue: T | ((prev: T) => T)) => void;
2
4
  type ResourceControl = {
3
5
  refetch: () => Promise<void>;
@@ -5,15 +7,33 @@ type ResourceControl = {
5
7
  readonly error: unknown;
6
8
  readonly status: 'idle' | 'loading' | 'success' | 'error';
7
9
  };
8
- type StateAction<T> = StateSetter<T> | ResourceControl;
9
10
  interface StateOptions {
10
11
  key?: unknown[];
11
12
  deps?: any[];
13
+ /** Debug name for DevTools */
14
+ name?: string;
12
15
  }
16
+ interface Context<T> {
17
+ Provider: (props: {
18
+ value: T;
19
+ children: any;
20
+ }) => any;
21
+ id: symbol;
22
+ defaultValue: T;
23
+ }
24
+
25
+ type StateAction<T> = StateSetter<T> | ResourceControl;
13
26
  declare function state<T>(fn: () => Promise<T>, options?: StateOptions): [T | undefined, ResourceControl];
14
27
  declare function state<T>(fn: () => T, options?: StateOptions): [T, ResourceControl];
15
28
  declare function state<T>(initialValue: T extends Function ? never : T, options?: StateOptions): [T, StateSetter<T>];
16
29
 
30
+ interface RefObject<T> {
31
+ current: T | null;
32
+ }
33
+ type RefCallback<T> = (instance: T | null) => void;
34
+ type Ref<T> = RefObject<T> | RefCallback<T> | null;
35
+ type ForwardedRef<T> = RefCallback<T> | RefObject<T> | null;
36
+
17
37
  declare function effect(fn: () => (void | (() => void)), deps?: any[]): void;
18
38
  /**
19
39
  * Unified sync API
@@ -21,21 +41,77 @@ declare function effect(fn: () => (void | (() => void)), deps?: any[]): void;
21
41
  * - sync(fn): Batch updates (run fn then flush)
22
42
  */
23
43
  declare function sync(fn?: () => void): void;
24
- declare function batch(fn: () => void): void;
25
44
 
26
- interface Context<T> {
27
- Provider: (props: {
28
- value: T;
29
- children: any;
30
- }) => any;
31
- id: symbol;
32
- defaultValue: T;
33
- }
34
45
  declare function createContext<T>(defaultValue: T): Context<T>;
35
46
  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
47
 
41
- export { type Context, type ResourceControl, type StateAction, type StateSetter, batch, context, createContext, effect, popContext, pushContext, runWithContext, snapshotContext, state, sync };
48
+ declare const FORWARD_REF_SYMBOL: unique symbol;
49
+ interface ForwardRefRenderFunction<P, T> {
50
+ (props: P, ref: ForwardedRef<T>): FNodeChild;
51
+ }
52
+ interface ForwardRefComponent<P, T> {
53
+ (props: P & {
54
+ ref?: Ref<T>;
55
+ }): FNodeChild;
56
+ $$typeof: typeof FORWARD_REF_SYMBOL;
57
+ render: ForwardRefRenderFunction<P, T>;
58
+ }
59
+ /**
60
+ * Forwards a ref through a component to a child element
61
+ *
62
+ * @example
63
+ * ```tsx
64
+ * const FancyInput = forwardRef<{ placeholder?: string }, HTMLInputElement>(
65
+ * (props, ref) => {
66
+ * return (
67
+ * <input
68
+ * ref={ref}
69
+ * class="fancy-input"
70
+ * placeholder={props.placeholder}
71
+ * />
72
+ * )
73
+ * }
74
+ * )
75
+ *
76
+ * function Parent() {
77
+ * const inputRef = ref<HTMLInputElement>()
78
+ *
79
+ * return (
80
+ * <div>
81
+ * <FancyInput ref={inputRef} placeholder="Type here..." />
82
+ * <button onClick={() => inputRef.current?.select()}>
83
+ * Select All
84
+ * </button>
85
+ * </div>
86
+ * )
87
+ * }
88
+ * ```
89
+ */
90
+ declare function forwardRef<P = {}, T = HTMLElement>(render: ForwardRefRenderFunction<P, T>): ForwardRefComponent<P, T>;
91
+
92
+ /**
93
+ * Creates a mutable ref object that persists across renders
94
+ *
95
+ * @example
96
+ * ```tsx
97
+ * function InputWithFocus() {
98
+ * const inputRef = ref<HTMLInputElement>()
99
+ *
100
+ * const focusInput = () => {
101
+ * inputRef.current?.focus()
102
+ * }
103
+ *
104
+ * return (
105
+ * <div>
106
+ * <input ref={inputRef} type="text" />
107
+ * <button onClick={focusInput}>Focus Input</button>
108
+ * </div>
109
+ * )
110
+ * }
111
+ * ```
112
+ */
113
+ declare function ref<T>(initialValue: T): RefObject<T>;
114
+ declare function ref<T>(initialValue: T | null): RefObject<T | null>;
115
+ declare function ref<T = undefined>(): RefObject<T | undefined>;
116
+
117
+ export { type Context, type ForwardedRef, type Ref, type RefCallback, type RefObject, type ResourceControl, type StateAction, type StateOptions, type StateSetter, context, createContext, effect, forwardRef, ref, state, sync };
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkLUW7DIEW_js=require('./chunk-LUW7DIEW.js'),chunkIA4FEBFE_js=require('./chunk-IA4FEBFE.js'),chunkAPAMPY43_js=require('./chunk-APAMPY43.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 chunkIA4FEBFE_js.c}});Object.defineProperty(exports,"effect",{enumerable:true,get:function(){return chunkIA4FEBFE_js.a}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkIA4FEBFE_js.b}});Object.defineProperty(exports,"state",{enumerable:true,get:function(){return chunkAPAMPY43_js.a}});//# sourceMappingURL=core.js.map
1
+ 'use strict';var chunkPSKDIB7J_js=require('./chunk-PSKDIB7J.js'),chunkLTT43APF_js=require('./chunk-LTT43APF.js');require('./chunk-6VIRXD2Y.js');var chunkYWTD32NA_js=require('./chunk-YWTD32NA.js'),chunkUWFVCKRU_js=require('./chunk-UWFVCKRU.js');function t(e){return chunkUWFVCKRU_js.b(()=>({current:e}))}var f=Symbol("flexium.forwardRef");function n(e){let r=p=>{let{ref:R,...d}=p;return e(d,R??null)};return r.$$typeof=f,r.render=e,r}Object.defineProperty(exports,"context",{enumerable:true,get:function(){return chunkPSKDIB7J_js.b}});Object.defineProperty(exports,"createContext",{enumerable:true,get:function(){return chunkPSKDIB7J_js.a}});Object.defineProperty(exports,"state",{enumerable:true,get:function(){return chunkLTT43APF_js.a}});Object.defineProperty(exports,"effect",{enumerable:true,get:function(){return chunkYWTD32NA_js.e}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkYWTD32NA_js.f}});exports.forwardRef=n;exports.ref=t;//# sourceMappingURL=core.js.map
2
2
  //# sourceMappingURL=core.js.map
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"core.js"}
1
+ {"version":3,"sources":["../src/ref/ref.ts","../src/ref/forwardRef.ts"],"names":["ref","initialValue","hook","FORWARD_REF_SYMBOL","forwardRef","render","ForwardRefComponent","props","otherProps"],"mappings":"oPA2BO,SAASA,CAAAA,CAAOC,EAA4C,CACjE,OAAOC,mBAAK,KAAO,CACjB,QAASD,CACX,CAAA,CAAE,CACJ,CC3BO,IAAME,EAAqB,MAAA,CAAO,oBAAoB,EA2CtD,SAASC,CAAAA,CACdC,CAAAA,CAC2B,CAC3B,IAAMC,CAAAA,CAAuBC,GAA4C,CACvE,GAAM,CAAE,GAAA,CAAAP,CAAAA,CAAK,GAAGQ,CAAW,CAAA,CAAID,CAAAA,CAC/B,OAAOF,CAAAA,CAAOG,CAAAA,CAAiBR,GAAO,IAAI,CAC5C,EAGA,OAAAM,CAAAA,CAAoB,SAAWH,CAAAA,CAC/BG,CAAAA,CAAoB,MAAA,CAASD,CAAAA,CAEtBC,CACT","file":"core.js","sourcesContent":["import { hook } from '../core/hook'\nimport type { RefObject } from './types'\n\n/**\n * Creates a mutable ref object that persists across renders\n *\n * @example\n * ```tsx\n * function InputWithFocus() {\n * const inputRef = ref<HTMLInputElement>()\n *\n * const focusInput = () => {\n * inputRef.current?.focus()\n * }\n *\n * return (\n * <div>\n * <input ref={inputRef} type=\"text\" />\n * <button onClick={focusInput}>Focus Input</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function ref<T>(initialValue: T): RefObject<T>\nexport function ref<T>(initialValue: T | null): RefObject<T | null>\nexport function ref<T = undefined>(): RefObject<T | undefined>\nexport function ref<T>(initialValue?: T): RefObject<T | undefined> {\n return hook(() => ({\n current: initialValue\n }))\n}\n","import type { FNodeChild } from '../dom/types'\nimport type { ForwardedRef, Ref } from './types'\n\n// Symbol to identify forwarded components\nexport const FORWARD_REF_SYMBOL = Symbol('flexium.forwardRef')\n\nexport interface ForwardRefRenderFunction<P, T> {\n (props: P, ref: ForwardedRef<T>): FNodeChild\n}\n\nexport interface ForwardRefComponent<P, T> {\n (props: P & { ref?: Ref<T> }): FNodeChild\n $$typeof: typeof FORWARD_REF_SYMBOL\n render: ForwardRefRenderFunction<P, T>\n}\n\n/**\n * Forwards a ref through a component to a child element\n *\n * @example\n * ```tsx\n * const FancyInput = forwardRef<{ placeholder?: string }, HTMLInputElement>(\n * (props, ref) => {\n * return (\n * <input\n * ref={ref}\n * class=\"fancy-input\"\n * placeholder={props.placeholder}\n * />\n * )\n * }\n * )\n *\n * function Parent() {\n * const inputRef = ref<HTMLInputElement>()\n *\n * return (\n * <div>\n * <FancyInput ref={inputRef} placeholder=\"Type here...\" />\n * <button onClick={() => inputRef.current?.select()}>\n * Select All\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function forwardRef<P = {}, T = HTMLElement>(\n render: ForwardRefRenderFunction<P, T>\n): ForwardRefComponent<P, T> {\n const ForwardRefComponent = (props: P & { ref?: Ref<T> }): FNodeChild => {\n const { ref, ...otherProps } = props as P & { ref?: Ref<T> }\n return render(otherProps as P, ref ?? null)\n }\n\n // Mark as forwarded component\n ForwardRefComponent.$$typeof = FORWARD_REF_SYMBOL\n ForwardRefComponent.render = render\n\n return ForwardRefComponent\n}\n"]}
package/dist/core.mjs CHANGED
@@ -1,2 +1,2 @@
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{c as batch,a as effect,b as sync}from'./chunk-S6WF3XNF.mjs';export{a as state}from'./chunk-ECB5HZOQ.mjs';import'./chunk-CPJRQL2C.mjs';import'./chunk-44RZHCII.mjs';//# sourceMappingURL=core.mjs.map
1
+ export{b as context,a as createContext}from'./chunk-3DKZ2J4D.mjs';export{a as state}from'./chunk-WGKD63GN.mjs';import'./chunk-JY6CE6RN.mjs';export{e as effect,f as sync}from'./chunk-IWFEXW4F.mjs';import {b}from'./chunk-5PNH2ARD.mjs';function t(e){return b(()=>({current:e}))}var f=Symbol("flexium.forwardRef");function n(e){let r=p=>{let{ref:R,...d}=p;return e(d,R??null)};return r.$$typeof=f,r.render=e,r}export{n as forwardRef,t as ref};//# sourceMappingURL=core.mjs.map
2
2
  //# sourceMappingURL=core.mjs.map
package/dist/core.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"core.mjs"}
1
+ {"version":3,"sources":["../src/ref/ref.ts","../src/ref/forwardRef.ts"],"names":["ref","initialValue","hook","FORWARD_REF_SYMBOL","forwardRef","render","ForwardRefComponent","props","otherProps"],"mappings":"yOA2BO,SAASA,CAAAA,CAAOC,EAA4C,CACjE,OAAOC,EAAK,KAAO,CACjB,QAASD,CACX,CAAA,CAAE,CACJ,CC3BO,IAAME,EAAqB,MAAA,CAAO,oBAAoB,EA2CtD,SAASC,CAAAA,CACdC,CAAAA,CAC2B,CAC3B,IAAMC,CAAAA,CAAuBC,GAA4C,CACvE,GAAM,CAAE,GAAA,CAAAP,CAAAA,CAAK,GAAGQ,CAAW,CAAA,CAAID,CAAAA,CAC/B,OAAOF,CAAAA,CAAOG,CAAAA,CAAiBR,GAAO,IAAI,CAC5C,EAGA,OAAAM,CAAAA,CAAoB,SAAWH,CAAAA,CAC/BG,CAAAA,CAAoB,MAAA,CAASD,CAAAA,CAEtBC,CACT","file":"core.mjs","sourcesContent":["import { hook } from '../core/hook'\nimport type { RefObject } from './types'\n\n/**\n * Creates a mutable ref object that persists across renders\n *\n * @example\n * ```tsx\n * function InputWithFocus() {\n * const inputRef = ref<HTMLInputElement>()\n *\n * const focusInput = () => {\n * inputRef.current?.focus()\n * }\n *\n * return (\n * <div>\n * <input ref={inputRef} type=\"text\" />\n * <button onClick={focusInput}>Focus Input</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function ref<T>(initialValue: T): RefObject<T>\nexport function ref<T>(initialValue: T | null): RefObject<T | null>\nexport function ref<T = undefined>(): RefObject<T | undefined>\nexport function ref<T>(initialValue?: T): RefObject<T | undefined> {\n return hook(() => ({\n current: initialValue\n }))\n}\n","import type { FNodeChild } from '../dom/types'\nimport type { ForwardedRef, Ref } from './types'\n\n// Symbol to identify forwarded components\nexport const FORWARD_REF_SYMBOL = Symbol('flexium.forwardRef')\n\nexport interface ForwardRefRenderFunction<P, T> {\n (props: P, ref: ForwardedRef<T>): FNodeChild\n}\n\nexport interface ForwardRefComponent<P, T> {\n (props: P & { ref?: Ref<T> }): FNodeChild\n $$typeof: typeof FORWARD_REF_SYMBOL\n render: ForwardRefRenderFunction<P, T>\n}\n\n/**\n * Forwards a ref through a component to a child element\n *\n * @example\n * ```tsx\n * const FancyInput = forwardRef<{ placeholder?: string }, HTMLInputElement>(\n * (props, ref) => {\n * return (\n * <input\n * ref={ref}\n * class=\"fancy-input\"\n * placeholder={props.placeholder}\n * />\n * )\n * }\n * )\n *\n * function Parent() {\n * const inputRef = ref<HTMLInputElement>()\n *\n * return (\n * <div>\n * <FancyInput ref={inputRef} placeholder=\"Type here...\" />\n * <button onClick={() => inputRef.current?.select()}>\n * Select All\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function forwardRef<P = {}, T = HTMLElement>(\n render: ForwardRefRenderFunction<P, T>\n): ForwardRefComponent<P, T> {\n const ForwardRefComponent = (props: P & { ref?: Ref<T> }): FNodeChild => {\n const { ref, ...otherProps } = props as P & { ref?: Ref<T> }\n return render(otherProps as P, ref ?? null)\n }\n\n // Mark as forwarded component\n ForwardRefComponent.$$typeof = FORWARD_REF_SYMBOL\n ForwardRefComponent.render = render\n\n return ForwardRefComponent\n}\n"]}
package/dist/dom.d.cts CHANGED
@@ -1,12 +1,157 @@
1
- type FNodeChild = FNode | string | number | boolean | null | undefined | FNodeChild[] | (() => FNode);
2
- interface FNode {
3
- type: string | Function;
4
- props: Record<string, any>;
5
- children: FNodeChild[];
1
+ import { a as FNode, F as FNodeChild } from './types-y2GGaXXk.cjs';
2
+ import { S as SerializedState } from './types-CxlS2F2j.cjs';
3
+
4
+ /**
5
+ * f() - Create FNodes without JSX
6
+ */
7
+ declare function f(type: string | Function, props?: any, ...children: any[]): FNode;
8
+
9
+ declare function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[];
10
+ declare function render(app: any, container: HTMLElement): void;
11
+
12
+ interface HydrateOptions {
13
+ /**
14
+ * Serialized state from server
15
+ * Typically embedded in HTML as JSON script tag
16
+ */
17
+ state?: SerializedState;
18
+ /**
19
+ * Called when hydration completes successfully
20
+ */
21
+ onHydrated?: () => void;
22
+ /**
23
+ * Called when hydration fails (falls back to full render)
24
+ */
25
+ onMismatch?: (error: Error) => void;
26
+ }
27
+ /**
28
+ * Hydrate server-rendered HTML with client-side interactivity
29
+ */
30
+ declare function hydrate(app: FNodeChild | (() => FNodeChild), container: HTMLElement, options?: HydrateOptions): void;
31
+
32
+ interface PortalProps {
33
+ /** Target element or CSS selector to render children into */
34
+ target: HTMLElement | string;
35
+ /** Children to render in the portal */
36
+ children: FNodeChild;
37
+ /** Optional key for reconciliation */
6
38
  key?: any;
7
39
  }
8
- declare function render(app: any, container: HTMLElement): void;
9
- declare function f(type: string | Function, props?: any, ...children: any[]): any;
10
- declare function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[];
40
+ interface SuspenseProps {
41
+ /** Fallback UI to display while loading */
42
+ fallback: FNodeChild;
43
+ /** Children to render when loaded */
44
+ children: FNodeChild;
45
+ }
46
+ interface LazyComponent<P = any> {
47
+ (props: P): FNodeChild;
48
+ _lazy: true;
49
+ _loader: () => Promise<{
50
+ default: (props: P) => FNodeChild;
51
+ }>;
52
+ _resolved?: (props: P) => FNodeChild;
53
+ _promise?: Promise<any>;
54
+ _error?: Error;
55
+ }
56
+ interface SuspenseContextValue {
57
+ /** Register a pending promise with the suspense boundary */
58
+ register: (promise: Promise<any>) => void;
59
+ /** Whether there's an active suspense boundary */
60
+ hasBoundary: boolean;
61
+ }
62
+ interface ErrorInfo {
63
+ /** Component stack trace */
64
+ componentStack: string;
65
+ /** Error occurred during which phase */
66
+ phase: 'render' | 'effect' | 'event';
67
+ }
68
+ interface ErrorBoundaryProps {
69
+ /** Fallback UI to display when error occurs */
70
+ fallback: FNodeChild | ((error: Error, info: ErrorInfo) => FNodeChild);
71
+ /** Callback when error is caught */
72
+ onError?: (error: Error, info: ErrorInfo) => void;
73
+ /** Children to render */
74
+ children: FNodeChild;
75
+ /** Key to reset boundary (changing key resets error state) */
76
+ resetKey?: unknown;
77
+ }
78
+
79
+ /**
80
+ * Portal component that renders children into a different DOM node
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * function Modal({ isOpen, onClose, children }) {
85
+ * if (!isOpen) return null
86
+ *
87
+ * return (
88
+ * <Portal target={document.body}>
89
+ * <div class="modal-backdrop" onClick={onClose}>
90
+ * <div class="modal-content" onClick={e => e.stopPropagation()}>
91
+ * {children}
92
+ * </div>
93
+ * </div>
94
+ * </Portal>
95
+ * )
96
+ * }
97
+ * ```
98
+ */
99
+ declare function Portal(props: PortalProps): null;
100
+
101
+ /**
102
+ * Suspense component that shows fallback while children are loading
103
+ *
104
+ * @example
105
+ * ```tsx
106
+ * const Dashboard = lazy(() => import('./Dashboard'))
107
+ *
108
+ * function App() {
109
+ * return (
110
+ * <Suspense fallback={<div>Loading...</div>}>
111
+ * <Dashboard />
112
+ * </Suspense>
113
+ * )
114
+ * }
115
+ * ```
116
+ */
117
+ declare function Suspense(props: SuspenseProps): FNodeChild;
118
+
119
+ /**
120
+ * ErrorBoundary component that catches errors in its children and displays fallback UI
121
+ *
122
+ * @example
123
+ * ```tsx
124
+ * <ErrorBoundary
125
+ * fallback={(error, info) => <div>Error: {error.message}</div>}
126
+ * onError={(error, info) => console.error(error)}
127
+ * >
128
+ * <App />
129
+ * </ErrorBoundary>
130
+ * ```
131
+ */
132
+ declare function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild;
133
+
134
+ /**
135
+ * Creates a lazy-loaded component for code splitting
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * const Dashboard = lazy(() => import('./Dashboard'))
140
+ * const Settings = lazy(() => import('./Settings'))
141
+ *
142
+ * function App() {
143
+ * return (
144
+ * <Suspense fallback={<div>Loading...</div>}>
145
+ * <Dashboard />
146
+ * </Suspense>
147
+ * )
148
+ * }
149
+ * ```
150
+ */
151
+ declare function lazy<P = {}>(loader: () => Promise<{
152
+ default: (props: P) => FNodeChild;
153
+ }>): LazyComponent<P>;
154
+
155
+ declare function suspenseContext(): SuspenseContextValue;
11
156
 
12
- export { type FNode, type FNodeChild, f, reconcile, render };
157
+ export { ErrorBoundary, type ErrorBoundaryProps, type ErrorInfo, FNode, FNodeChild, type HydrateOptions, type LazyComponent, Portal, type PortalProps, Suspense, type SuspenseContextValue, type SuspenseProps, f, hydrate, lazy, reconcile, render, suspenseContext };
package/dist/dom.d.ts CHANGED
@@ -1,12 +1,157 @@
1
- type FNodeChild = FNode | string | number | boolean | null | undefined | FNodeChild[] | (() => FNode);
2
- interface FNode {
3
- type: string | Function;
4
- props: Record<string, any>;
5
- children: FNodeChild[];
1
+ import { a as FNode, F as FNodeChild } from './types-y2GGaXXk.js';
2
+ import { S as SerializedState } from './types-CxlS2F2j.js';
3
+
4
+ /**
5
+ * f() - Create FNodes without JSX
6
+ */
7
+ declare function f(type: string | Function, props?: any, ...children: any[]): FNode;
8
+
9
+ declare function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[];
10
+ declare function render(app: any, container: HTMLElement): void;
11
+
12
+ interface HydrateOptions {
13
+ /**
14
+ * Serialized state from server
15
+ * Typically embedded in HTML as JSON script tag
16
+ */
17
+ state?: SerializedState;
18
+ /**
19
+ * Called when hydration completes successfully
20
+ */
21
+ onHydrated?: () => void;
22
+ /**
23
+ * Called when hydration fails (falls back to full render)
24
+ */
25
+ onMismatch?: (error: Error) => void;
26
+ }
27
+ /**
28
+ * Hydrate server-rendered HTML with client-side interactivity
29
+ */
30
+ declare function hydrate(app: FNodeChild | (() => FNodeChild), container: HTMLElement, options?: HydrateOptions): void;
31
+
32
+ interface PortalProps {
33
+ /** Target element or CSS selector to render children into */
34
+ target: HTMLElement | string;
35
+ /** Children to render in the portal */
36
+ children: FNodeChild;
37
+ /** Optional key for reconciliation */
6
38
  key?: any;
7
39
  }
8
- declare function render(app: any, container: HTMLElement): void;
9
- declare function f(type: string | Function, props?: any, ...children: any[]): any;
10
- declare function reconcile(oldNodes: Node[], newNodes: Node[], parent: Node, beforeMarker: Node): Node[];
40
+ interface SuspenseProps {
41
+ /** Fallback UI to display while loading */
42
+ fallback: FNodeChild;
43
+ /** Children to render when loaded */
44
+ children: FNodeChild;
45
+ }
46
+ interface LazyComponent<P = any> {
47
+ (props: P): FNodeChild;
48
+ _lazy: true;
49
+ _loader: () => Promise<{
50
+ default: (props: P) => FNodeChild;
51
+ }>;
52
+ _resolved?: (props: P) => FNodeChild;
53
+ _promise?: Promise<any>;
54
+ _error?: Error;
55
+ }
56
+ interface SuspenseContextValue {
57
+ /** Register a pending promise with the suspense boundary */
58
+ register: (promise: Promise<any>) => void;
59
+ /** Whether there's an active suspense boundary */
60
+ hasBoundary: boolean;
61
+ }
62
+ interface ErrorInfo {
63
+ /** Component stack trace */
64
+ componentStack: string;
65
+ /** Error occurred during which phase */
66
+ phase: 'render' | 'effect' | 'event';
67
+ }
68
+ interface ErrorBoundaryProps {
69
+ /** Fallback UI to display when error occurs */
70
+ fallback: FNodeChild | ((error: Error, info: ErrorInfo) => FNodeChild);
71
+ /** Callback when error is caught */
72
+ onError?: (error: Error, info: ErrorInfo) => void;
73
+ /** Children to render */
74
+ children: FNodeChild;
75
+ /** Key to reset boundary (changing key resets error state) */
76
+ resetKey?: unknown;
77
+ }
78
+
79
+ /**
80
+ * Portal component that renders children into a different DOM node
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * function Modal({ isOpen, onClose, children }) {
85
+ * if (!isOpen) return null
86
+ *
87
+ * return (
88
+ * <Portal target={document.body}>
89
+ * <div class="modal-backdrop" onClick={onClose}>
90
+ * <div class="modal-content" onClick={e => e.stopPropagation()}>
91
+ * {children}
92
+ * </div>
93
+ * </div>
94
+ * </Portal>
95
+ * )
96
+ * }
97
+ * ```
98
+ */
99
+ declare function Portal(props: PortalProps): null;
100
+
101
+ /**
102
+ * Suspense component that shows fallback while children are loading
103
+ *
104
+ * @example
105
+ * ```tsx
106
+ * const Dashboard = lazy(() => import('./Dashboard'))
107
+ *
108
+ * function App() {
109
+ * return (
110
+ * <Suspense fallback={<div>Loading...</div>}>
111
+ * <Dashboard />
112
+ * </Suspense>
113
+ * )
114
+ * }
115
+ * ```
116
+ */
117
+ declare function Suspense(props: SuspenseProps): FNodeChild;
118
+
119
+ /**
120
+ * ErrorBoundary component that catches errors in its children and displays fallback UI
121
+ *
122
+ * @example
123
+ * ```tsx
124
+ * <ErrorBoundary
125
+ * fallback={(error, info) => <div>Error: {error.message}</div>}
126
+ * onError={(error, info) => console.error(error)}
127
+ * >
128
+ * <App />
129
+ * </ErrorBoundary>
130
+ * ```
131
+ */
132
+ declare function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild;
133
+
134
+ /**
135
+ * Creates a lazy-loaded component for code splitting
136
+ *
137
+ * @example
138
+ * ```tsx
139
+ * const Dashboard = lazy(() => import('./Dashboard'))
140
+ * const Settings = lazy(() => import('./Settings'))
141
+ *
142
+ * function App() {
143
+ * return (
144
+ * <Suspense fallback={<div>Loading...</div>}>
145
+ * <Dashboard />
146
+ * </Suspense>
147
+ * )
148
+ * }
149
+ * ```
150
+ */
151
+ declare function lazy<P = {}>(loader: () => Promise<{
152
+ default: (props: P) => FNodeChild;
153
+ }>): LazyComponent<P>;
154
+
155
+ declare function suspenseContext(): SuspenseContextValue;
11
156
 
12
- export { type FNode, type FNodeChild, f, reconcile, render };
157
+ export { ErrorBoundary, type ErrorBoundaryProps, type ErrorInfo, FNode, FNodeChild, type HydrateOptions, type LazyComponent, Portal, type PortalProps, Suspense, type SuspenseContextValue, type SuspenseProps, f, hydrate, lazy, reconcile, render, suspenseContext };