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.
- package/README.md +10 -10
- package/dist/canvas.d.cts +83 -23
- package/dist/canvas.d.ts +83 -23
- package/dist/canvas.js +1 -1
- package/dist/canvas.js.map +1 -1
- package/dist/canvas.mjs +1 -1
- package/dist/canvas.mjs.map +1 -1
- package/dist/chunk-44RZHCII.mjs +2 -0
- package/dist/chunk-44RZHCII.mjs.map +1 -0
- package/dist/chunk-7BXR4ZFD.js +2 -0
- package/dist/chunk-7BXR4ZFD.js.map +1 -0
- package/dist/chunk-7DXFHPWZ.mjs +2 -0
- package/dist/chunk-7DXFHPWZ.mjs.map +1 -0
- package/dist/chunk-ALTO2MGI.js +2 -0
- package/dist/chunk-ALTO2MGI.js.map +1 -0
- package/dist/chunk-C452JE6C.js +2 -0
- package/dist/chunk-C452JE6C.js.map +1 -0
- package/dist/chunk-CPJRQL2C.mjs +2 -0
- package/dist/chunk-CPJRQL2C.mjs.map +1 -0
- package/dist/chunk-EJ7Z5OMU.mjs +2 -0
- package/dist/chunk-EJ7Z5OMU.mjs.map +1 -0
- package/dist/chunk-ENWGYQNU.js +2 -0
- package/dist/chunk-ENWGYQNU.js.map +1 -0
- package/dist/chunk-EXLNKYSH.js +2 -0
- package/dist/chunk-EXLNKYSH.js.map +1 -0
- package/dist/chunk-LUREDEUB.mjs +2 -0
- package/dist/chunk-LUREDEUB.mjs.map +1 -0
- package/dist/chunk-LUW7DIEW.js +2 -0
- package/dist/chunk-LUW7DIEW.js.map +1 -0
- package/dist/chunk-ZCO4NIGC.mjs +2 -0
- package/dist/chunk-ZCO4NIGC.mjs.map +1 -0
- package/dist/core.d.cts +41 -2
- package/dist/core.d.ts +41 -2
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/dom.d.cts +10 -33
- package/dist/dom.d.ts +10 -33
- package/dist/dom.js +1 -1
- package/dist/dom.js.map +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/dom.mjs.map +1 -1
- package/dist/index.d.cts +1 -24
- package/dist/index.d.ts +1 -24
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interactive.d.cts +65 -148
- package/dist/interactive.d.ts +65 -148
- package/dist/interactive.js +1 -1
- package/dist/interactive.js.map +1 -1
- package/dist/interactive.mjs +1 -1
- package/dist/interactive.mjs.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +6 -2
- package/dist/jsx-dev-runtime.d.ts +6 -2
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-dev-runtime.mjs +1 -1
- package/dist/jsx-dev-runtime.mjs.map +1 -1
- package/dist/jsx-runtime.d.cts +6 -68
- package/dist/jsx-runtime.d.ts +6 -68
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/router.d.cts +48 -15
- package/dist/router.d.ts +48 -15
- package/dist/router.js +1 -1
- package/dist/router.js.map +1 -1
- package/dist/router.mjs +1 -1
- package/dist/router.mjs.map +1 -1
- package/package.json +13 -53
- package/dist/DrawText-CVAKQ5wZ.d.cts +0 -309
- package/dist/DrawText-Dlh1L1Ar.d.ts +0 -309
- package/dist/Motion-BrOAJzgH.d.cts +0 -87
- package/dist/Motion-BrOAJzgH.d.ts +0 -87
- package/dist/advanced.d.cts +0 -32
- package/dist/advanced.d.ts +0 -32
- package/dist/advanced.js +0 -2
- package/dist/advanced.js.map +0 -1
- package/dist/advanced.mjs +0 -2
- package/dist/advanced.mjs.map +0 -1
- package/dist/chunk-5ICRQIS2.js +0 -3
- package/dist/chunk-5ICRQIS2.js.map +0 -1
- package/dist/chunk-5K55ASOD.mjs +0 -3
- package/dist/chunk-5K55ASOD.mjs.map +0 -1
- package/dist/chunk-AZEHBSBG.js +0 -3
- package/dist/chunk-AZEHBSBG.js.map +0 -1
- package/dist/chunk-BBNYMXE7.mjs +0 -2
- package/dist/chunk-BBNYMXE7.mjs.map +0 -1
- package/dist/chunk-BYHIHYRR.mjs +0 -2
- package/dist/chunk-BYHIHYRR.mjs.map +0 -1
- package/dist/chunk-DZ7L3SHV.js +0 -2
- package/dist/chunk-DZ7L3SHV.js.map +0 -1
- package/dist/chunk-ECYYIQEX.mjs +0 -3
- package/dist/chunk-ECYYIQEX.mjs.map +0 -1
- package/dist/chunk-FDMJHFN7.mjs +0 -2
- package/dist/chunk-FDMJHFN7.mjs.map +0 -1
- package/dist/chunk-GKJQEOP7.mjs +0 -2
- package/dist/chunk-GKJQEOP7.mjs.map +0 -1
- package/dist/chunk-GYDP6MFV.js +0 -3
- package/dist/chunk-GYDP6MFV.js.map +0 -1
- package/dist/chunk-HB5VPQTB.mjs +0 -2
- package/dist/chunk-HB5VPQTB.mjs.map +0 -1
- package/dist/chunk-KNF5ERPK.mjs +0 -2
- package/dist/chunk-KNF5ERPK.mjs.map +0 -1
- package/dist/chunk-OPAAGNBO.mjs +0 -2
- package/dist/chunk-OPAAGNBO.mjs.map +0 -1
- package/dist/chunk-OPAQ4R4M.mjs +0 -2
- package/dist/chunk-OPAQ4R4M.mjs.map +0 -1
- package/dist/chunk-Q7IWDVJ4.js +0 -2
- package/dist/chunk-Q7IWDVJ4.js.map +0 -1
- package/dist/chunk-QPCIDSMM.js +0 -2
- package/dist/chunk-QPCIDSMM.js.map +0 -1
- package/dist/chunk-QZIX4FXS.mjs +0 -2
- package/dist/chunk-QZIX4FXS.mjs.map +0 -1
- package/dist/chunk-RMN5IPS5.js +0 -2
- package/dist/chunk-RMN5IPS5.js.map +0 -1
- package/dist/chunk-U6C6VDVZ.js +0 -2
- package/dist/chunk-U6C6VDVZ.js.map +0 -1
- package/dist/chunk-WQFQO5LK.js +0 -2
- package/dist/chunk-WQFQO5LK.js.map +0 -1
- package/dist/chunk-WVEJT7HD.mjs +0 -2
- package/dist/chunk-WVEJT7HD.mjs.map +0 -1
- package/dist/chunk-WWEWRI6S.js +0 -2
- package/dist/chunk-WWEWRI6S.js.map +0 -1
- package/dist/chunk-XJHWMHKF.js +0 -2
- package/dist/chunk-XJHWMHKF.js.map +0 -1
- package/dist/chunk-Y6KKAHLS.mjs +0 -3
- package/dist/chunk-Y6KKAHLS.mjs.map +0 -1
- package/dist/chunk-YDZ37ZZ4.js +0 -2
- package/dist/chunk-YDZ37ZZ4.js.map +0 -1
- package/dist/chunk-YPVRQKMW.js +0 -2
- package/dist/chunk-YPVRQKMW.js.map +0 -1
- package/dist/components-BMbqsbMY.d.cts +0 -126
- package/dist/components-C83mBQXW.d.ts +0 -126
- package/dist/core-CxHP8991.d.cts +0 -32
- package/dist/core-D0ggvjX3.d.ts +0 -32
- package/dist/effect-554ONNZR.js +0 -2
- package/dist/effect-554ONNZR.js.map +0 -1
- package/dist/effect-T2GVIS3T.mjs +0 -2
- package/dist/effect-T2GVIS3T.mjs.map +0 -1
- package/dist/owner-QS9tPwPr.d.cts +0 -27
- package/dist/owner-QS9tPwPr.d.ts +0 -27
- package/dist/portal-BK_0Z0hE.d.cts +0 -206
- package/dist/portal-CbguxtuQ.d.ts +0 -206
- package/dist/primitives/layout.d.cts +0 -295
- package/dist/primitives/layout.d.ts +0 -295
- package/dist/primitives/layout.js +0 -2
- package/dist/primitives/layout.js.map +0 -1
- package/dist/primitives/layout.mjs +0 -2
- package/dist/primitives/layout.mjs.map +0 -1
- package/dist/primitives/motion.d.cts +0 -230
- package/dist/primitives/motion.d.ts +0 -230
- package/dist/primitives/motion.js +0 -2
- package/dist/primitives/motion.js.map +0 -1
- package/dist/primitives/motion.mjs +0 -2
- package/dist/primitives/motion.mjs.map +0 -1
- package/dist/primitives/ui.d.cts +0 -81
- package/dist/primitives/ui.d.ts +0 -81
- package/dist/primitives/ui.js +0 -2
- package/dist/primitives/ui.js.map +0 -1
- package/dist/primitives/ui.mjs +0 -2
- package/dist/primitives/ui.mjs.map +0 -1
- package/dist/primitives.d.cts +0 -93
- package/dist/primitives.d.ts +0 -93
- package/dist/primitives.js +0 -2
- package/dist/primitives.js.map +0 -1
- package/dist/primitives.mjs +0 -2
- package/dist/primitives.mjs.map +0 -1
- package/dist/renderer-DSLb-FGg.d.cts +0 -135
- package/dist/renderer-DSLb-FGg.d.ts +0 -135
- package/dist/server.d.cts +0 -3
- package/dist/server.d.ts +0 -3
- package/dist/server.js +0 -2
- package/dist/server.js.map +0 -1
- package/dist/server.mjs +0 -2
- package/dist/server.mjs.map +0 -1
- package/dist/state-DitsMyev.d.cts +0 -96
- package/dist/state-DitsMyev.d.ts +0 -96
- package/dist/state-RYKSC35A.mjs +0 -2
- package/dist/state-RYKSC35A.mjs.map +0 -1
- package/dist/state-XUXPMCFJ.js +0 -2
- package/dist/state-XUXPMCFJ.js.map +0 -1
- package/dist/sync-Z4QqUDjF.d.cts +0 -25
- package/dist/sync-Z4QqUDjF.d.ts +0 -25
- package/dist/test-exports.d.cts +0 -68
- package/dist/test-exports.d.ts +0 -68
- package/dist/test-exports.js +0 -2
- package/dist/test-exports.js.map +0 -1
- package/dist/test-exports.mjs +0 -2
- package/dist/test-exports.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -193,19 +193,19 @@ function App() {
|
|
|
193
193
|
## Routing
|
|
194
194
|
|
|
195
195
|
```tsx
|
|
196
|
-
import {
|
|
196
|
+
import { Routes, Route, Link } from 'flexium/router';
|
|
197
197
|
|
|
198
198
|
function App() {
|
|
199
199
|
return (
|
|
200
|
-
<
|
|
200
|
+
<Routes>
|
|
201
201
|
<nav>
|
|
202
|
-
<Link
|
|
203
|
-
<Link
|
|
202
|
+
<Link to="/">Home</Link>
|
|
203
|
+
<Link to="/about">About</Link>
|
|
204
204
|
</nav>
|
|
205
205
|
<Route path="/" component={Home} />
|
|
206
206
|
<Route path="/about" component={About} />
|
|
207
207
|
<Route path="/users/:id" component={UserProfile} />
|
|
208
|
-
</
|
|
208
|
+
</Routes>
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -214,13 +214,13 @@ function UserProfile({ params }) {
|
|
|
214
214
|
return <h1>User: {params.id}</h1>;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
// Or use the hook
|
|
218
|
-
import {
|
|
217
|
+
// Or use the router hook
|
|
218
|
+
import { router } from 'flexium/router';
|
|
219
219
|
|
|
220
220
|
function UserProfileHook() {
|
|
221
|
-
const
|
|
222
|
-
//
|
|
223
|
-
return <h1>User: {
|
|
221
|
+
const r = router();
|
|
222
|
+
// Access params directly from router context
|
|
223
|
+
return <h1>User: {r.params.id}</h1>;
|
|
224
224
|
}
|
|
225
225
|
```
|
|
226
226
|
|
package/dist/canvas.d.cts
CHANGED
|
@@ -1,23 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { JSX } from './jsx-runtime.cjs';
|
|
2
|
+
import './dom.cjs';
|
|
3
|
+
|
|
4
|
+
interface CanvasProps {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
children?: any;
|
|
8
|
+
style?: any;
|
|
9
|
+
ref?: (el: HTMLCanvasElement) => void;
|
|
10
|
+
}
|
|
11
|
+
declare function Canvas(props: CanvasProps): JSX.Element;
|
|
12
|
+
|
|
13
|
+
interface DrawRectProps {
|
|
14
|
+
x: number | (() => number);
|
|
15
|
+
y: number | (() => number);
|
|
16
|
+
width: number | (() => number);
|
|
17
|
+
height: number | (() => number);
|
|
18
|
+
fill?: string | (() => string);
|
|
19
|
+
stroke?: string | (() => string);
|
|
20
|
+
strokeWidth?: number | (() => number);
|
|
21
|
+
opacity?: number | (() => number);
|
|
22
|
+
}
|
|
23
|
+
declare function DrawRect(props: DrawRectProps): null;
|
|
24
|
+
|
|
25
|
+
interface DrawCircleProps {
|
|
26
|
+
x: number | (() => number);
|
|
27
|
+
y: number | (() => number);
|
|
28
|
+
radius: number | (() => number);
|
|
29
|
+
fill?: string | (() => string);
|
|
30
|
+
stroke?: string | (() => string);
|
|
31
|
+
strokeWidth?: number | (() => number);
|
|
32
|
+
opacity?: number | (() => number);
|
|
33
|
+
}
|
|
34
|
+
declare function DrawCircle(props: DrawCircleProps): null;
|
|
35
|
+
|
|
36
|
+
interface DrawArcProps {
|
|
37
|
+
x: number | (() => number);
|
|
38
|
+
y: number | (() => number);
|
|
39
|
+
radius: number | (() => number);
|
|
40
|
+
startAngle: number | (() => number);
|
|
41
|
+
endAngle: number | (() => number);
|
|
42
|
+
counterclockwise?: boolean;
|
|
43
|
+
fill?: string | (() => string);
|
|
44
|
+
stroke?: string | (() => string);
|
|
45
|
+
strokeWidth?: number | (() => number);
|
|
46
|
+
opacity?: number | (() => number);
|
|
47
|
+
}
|
|
48
|
+
declare function DrawArc(props: DrawArcProps): null;
|
|
49
|
+
|
|
50
|
+
interface DrawLineProps {
|
|
51
|
+
x1: number | (() => number);
|
|
52
|
+
y1: number | (() => number);
|
|
53
|
+
x2: number | (() => number);
|
|
54
|
+
y2: number | (() => number);
|
|
55
|
+
stroke?: string | (() => string);
|
|
56
|
+
strokeWidth?: number | (() => number);
|
|
57
|
+
opacity?: number | (() => number);
|
|
58
|
+
}
|
|
59
|
+
declare function DrawLine(props: DrawLineProps): null;
|
|
60
|
+
|
|
61
|
+
interface DrawTextProps {
|
|
62
|
+
text: string | (() => string);
|
|
63
|
+
x: number | (() => number);
|
|
64
|
+
y: number | (() => number);
|
|
65
|
+
fill?: string | (() => string);
|
|
66
|
+
fontSize?: number | (() => number);
|
|
67
|
+
fontFamily?: string | (() => string);
|
|
68
|
+
fontWeight?: string | (() => string);
|
|
69
|
+
textAlign?: 'left' | 'center' | 'right';
|
|
70
|
+
opacity?: number | (() => number);
|
|
71
|
+
}
|
|
72
|
+
declare function DrawText(props: DrawTextProps): null;
|
|
73
|
+
|
|
74
|
+
interface DrawPathProps {
|
|
75
|
+
d: string | (() => string);
|
|
76
|
+
fill?: string | (() => string);
|
|
77
|
+
stroke?: string | (() => string);
|
|
78
|
+
strokeWidth?: number | (() => number);
|
|
79
|
+
opacity?: number | (() => number);
|
|
80
|
+
}
|
|
81
|
+
declare function DrawPath(props: DrawPathProps): null;
|
|
82
|
+
|
|
83
|
+
export { Canvas, type CanvasProps, DrawArc, type DrawArcProps, DrawCircle, type DrawCircleProps, DrawLine, type DrawLineProps, DrawPath, type DrawPathProps, DrawRect, type DrawRectProps, DrawText, type DrawTextProps };
|
package/dist/canvas.d.ts
CHANGED
|
@@ -1,23 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { JSX } from './jsx-runtime.js';
|
|
2
|
+
import './dom.js';
|
|
3
|
+
|
|
4
|
+
interface CanvasProps {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
children?: any;
|
|
8
|
+
style?: any;
|
|
9
|
+
ref?: (el: HTMLCanvasElement) => void;
|
|
10
|
+
}
|
|
11
|
+
declare function Canvas(props: CanvasProps): JSX.Element;
|
|
12
|
+
|
|
13
|
+
interface DrawRectProps {
|
|
14
|
+
x: number | (() => number);
|
|
15
|
+
y: number | (() => number);
|
|
16
|
+
width: number | (() => number);
|
|
17
|
+
height: number | (() => number);
|
|
18
|
+
fill?: string | (() => string);
|
|
19
|
+
stroke?: string | (() => string);
|
|
20
|
+
strokeWidth?: number | (() => number);
|
|
21
|
+
opacity?: number | (() => number);
|
|
22
|
+
}
|
|
23
|
+
declare function DrawRect(props: DrawRectProps): null;
|
|
24
|
+
|
|
25
|
+
interface DrawCircleProps {
|
|
26
|
+
x: number | (() => number);
|
|
27
|
+
y: number | (() => number);
|
|
28
|
+
radius: number | (() => number);
|
|
29
|
+
fill?: string | (() => string);
|
|
30
|
+
stroke?: string | (() => string);
|
|
31
|
+
strokeWidth?: number | (() => number);
|
|
32
|
+
opacity?: number | (() => number);
|
|
33
|
+
}
|
|
34
|
+
declare function DrawCircle(props: DrawCircleProps): null;
|
|
35
|
+
|
|
36
|
+
interface DrawArcProps {
|
|
37
|
+
x: number | (() => number);
|
|
38
|
+
y: number | (() => number);
|
|
39
|
+
radius: number | (() => number);
|
|
40
|
+
startAngle: number | (() => number);
|
|
41
|
+
endAngle: number | (() => number);
|
|
42
|
+
counterclockwise?: boolean;
|
|
43
|
+
fill?: string | (() => string);
|
|
44
|
+
stroke?: string | (() => string);
|
|
45
|
+
strokeWidth?: number | (() => number);
|
|
46
|
+
opacity?: number | (() => number);
|
|
47
|
+
}
|
|
48
|
+
declare function DrawArc(props: DrawArcProps): null;
|
|
49
|
+
|
|
50
|
+
interface DrawLineProps {
|
|
51
|
+
x1: number | (() => number);
|
|
52
|
+
y1: number | (() => number);
|
|
53
|
+
x2: number | (() => number);
|
|
54
|
+
y2: number | (() => number);
|
|
55
|
+
stroke?: string | (() => string);
|
|
56
|
+
strokeWidth?: number | (() => number);
|
|
57
|
+
opacity?: number | (() => number);
|
|
58
|
+
}
|
|
59
|
+
declare function DrawLine(props: DrawLineProps): null;
|
|
60
|
+
|
|
61
|
+
interface DrawTextProps {
|
|
62
|
+
text: string | (() => string);
|
|
63
|
+
x: number | (() => number);
|
|
64
|
+
y: number | (() => number);
|
|
65
|
+
fill?: string | (() => string);
|
|
66
|
+
fontSize?: number | (() => number);
|
|
67
|
+
fontFamily?: string | (() => string);
|
|
68
|
+
fontWeight?: string | (() => string);
|
|
69
|
+
textAlign?: 'left' | 'center' | 'right';
|
|
70
|
+
opacity?: number | (() => number);
|
|
71
|
+
}
|
|
72
|
+
declare function DrawText(props: DrawTextProps): null;
|
|
73
|
+
|
|
74
|
+
interface DrawPathProps {
|
|
75
|
+
d: string | (() => string);
|
|
76
|
+
fill?: string | (() => string);
|
|
77
|
+
stroke?: string | (() => string);
|
|
78
|
+
strokeWidth?: number | (() => number);
|
|
79
|
+
opacity?: number | (() => number);
|
|
80
|
+
}
|
|
81
|
+
declare function DrawPath(props: DrawPathProps): null;
|
|
82
|
+
|
|
83
|
+
export { Canvas, type CanvasProps, DrawArc, type DrawArcProps, DrawCircle, type DrawCircleProps, DrawLine, type DrawLineProps, DrawPath, type DrawPathProps, DrawRect, type DrawRectProps, DrawText, type DrawTextProps };
|
package/dist/canvas.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkC452JE6C_js=require('./chunk-C452JE6C.js'),chunk7BXR4ZFD_js=require('./chunk-7BXR4ZFD.js');require('./chunk-ENWGYQNU.js');var chunkEXLNKYSH_js=require('./chunk-EXLNKYSH.js');var h=[];function u(e){h.push(e);}function D(e){let{width:p,height:b,children:r,style:m,ref:a}=e,i,o=null,s=()=>{!i||!o||(o.clearRect(0,0,p,b),h.length=0,Array.isArray(r)?r.forEach(n=>{typeof n=="function"&&n();}):typeof r=="function"&&r(),h.forEach(n=>{P(o,n);}),null);};return chunkC452JE6C_js.a(()=>{i&&s();}),chunkEXLNKYSH_js.a("canvas",{ref:n=>{i=n,o=n.getContext("2d"),a&&a(n),s();},width:p,height:b,style:m})}function t(e){return chunk7BXR4ZFD_js.b(e)?e.valueOf?.()??e:e}function P(e,p){let{type:b,props:r}=p,m=t(r.opacity);switch(m!==void 0&&(e.globalAlpha=m),b){case "rect":{let a=t(r.x),i=t(r.y),o=t(r.width),s=t(r.height),n=t(r.fill),f=t(r.stroke),c=t(r.strokeWidth);n&&(e.fillStyle=n,e.fillRect(a,i,o,s)),f&&(e.strokeStyle=f,c&&(e.lineWidth=c),e.strokeRect(a,i,o,s));break}case "circle":{let a=t(r.x),i=t(r.y),o=t(r.radius),s=t(r.fill),n=t(r.stroke),f=t(r.strokeWidth);e.beginPath(),e.arc(a,i,o,0,Math.PI*2),s&&(e.fillStyle=s,e.fill()),n&&(e.strokeStyle=n,f&&(e.lineWidth=f),e.stroke());break}case "arc":{let a=t(r.x),i=t(r.y),o=t(r.radius),s=t(r.startAngle),n=t(r.endAngle),f=t(r.counterclockwise)||false,c=t(r.fill),y=t(r.stroke),g=t(r.strokeWidth);e.beginPath(),e.arc(a,i,o,s,n,f),c&&(e.fillStyle=c,e.fill()),y&&(e.strokeStyle=y,g&&(e.lineWidth=g),e.stroke());break}case "line":{let a=t(r.x1),i=t(r.y1),o=t(r.x2),s=t(r.y2),n=t(r.stroke)||"black",f=t(r.strokeWidth)||1;e.beginPath(),e.moveTo(a,i),e.lineTo(o,s),e.strokeStyle=n,e.lineWidth=f,e.stroke();break}case "text":{let a=t(r.x),i=t(r.y),o=t(r.text),s=t(r.fill)||"black",n=t(r.fontSize)||16,f=t(r.fontFamily)||"sans-serif",c=t(r.fontWeight)||"normal",y=t(r.textAlign)||"left";e.font=`${c} ${n}px ${f}`,e.textAlign=y,e.fillStyle=s,e.fillText(o,a,i);break}case "path":{let a=t(r.d),i=t(r.fill),o=t(r.stroke),s=t(r.strokeWidth),n=new Path2D(a);i&&(e.fillStyle=i,e.fill(n)),o&&(e.strokeStyle=o,s&&(e.lineWidth=s),e.stroke(n));break}}m!==void 0&&(e.globalAlpha=1);}function x(e){return chunkC452JE6C_js.a(()=>{u({type:"rect",props:e});}),null}function C(e){return chunkC452JE6C_js.a(()=>{u({type:"circle",props:e});}),null}function W(e){return chunkC452JE6C_js.a(()=>{u({type:"arc",props:e});}),null}function v(e){return chunkC452JE6C_js.a(()=>{u({type:"line",props:e});}),null}function A(e){return chunkC452JE6C_js.a(()=>{u({type:"text",props:e});}),null}function S(e){return chunkC452JE6C_js.a(()=>{u({type:"path",props:e});}),null}exports.Canvas=D;exports.DrawArc=W;exports.DrawCircle=C;exports.DrawLine=v;exports.DrawPath=S;exports.DrawRect=x;exports.DrawText=A;//# sourceMappingURL=canvas.js.map
|
|
2
2
|
//# sourceMappingURL=canvas.js.map
|
package/dist/canvas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"canvas.js"}
|
|
1
|
+
{"version":3,"sources":["../src/canvas/Canvas.tsx","../src/canvas/dom/DrawRect.tsx","../src/canvas/dom/DrawCircle.tsx","../src/canvas/dom/DrawArc.tsx","../src/canvas/dom/DrawLine.tsx","../src/canvas/dom/DrawText.tsx","../src/canvas/dom/DrawPath.tsx"],"names":["drawQueue","queueDraw","node","Canvas","props","width","height","children","style","ref","canvas","ctx","render","child","drawNode","effect","jsx","el","getValue","val","isReactive","type","opacity","x","y","w","h","fill","stroke","strokeWidth","radius","startAngle","endAngle","counterclockwise","x1","y1","x2","y2","text","fontSize","fontFamily","fontWeight","textAlign","d","path","DrawRect","DrawCircle","DrawArc","DrawLine","DrawText","DrawPath"],"mappings":"oMAiBA,IACMA,CAAAA,CAA8B,GAM7B,SAASC,CAAAA,CAAUC,CAAAA,CAAsB,CAC9CF,CAAAA,CAAU,KAAKE,CAAI,EACrB,CAEO,SAASC,CAAAA,CAAOC,EAAoB,CACzC,GAAM,CAAE,KAAA,CAAAC,EAAO,MAAA,CAAAC,CAAAA,CAAQ,SAAAC,CAAAA,CAAU,KAAA,CAAAC,EAAO,GAAA,CAAAC,CAAI,CAAA,CAAIL,CAAAA,CAE5CM,EACAC,CAAAA,CAAuC,IAAA,CAErCC,EAAS,IAAM,CACf,CAACF,CAAAA,EAAU,CAACC,CAAAA,GAGhBA,CAAA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G,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCPO,SAAS6C,EAAS7C,CAAAA,CAAsB,CAC7C,OAAAW,kBAAAA,CAAO,IAAM,CACXd,CAAAA,CAAU,CACR,IAAA,CAAM,MAAA,CACN,MAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCbO,SAAS8C,CAAAA,CAAS9C,CAAAA,CAAsB,CAC7C,OAAAW,kBAAAA,CAAO,IAAM,CACXd,CAAAA,CAAU,CACR,IAAA,CAAM,OACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,EAEM,IACT","file":"canvas.js","sourcesContent":["import { effect } from '../core/lifecycle'\nimport { isReactive } from '../core/reactive'\n\nexport interface CanvasProps {\n width: number\n height: number\n children?: any\n style?: any\n ref?: (el: HTMLCanvasElement) => void\n}\n\ninterface CanvasDrawNode {\n type: 'rect' | 'circle' | 'arc' | 'line' | 'text' | 'path'\n props: any\n}\n\n// Canvas context for children to access\nlet currentCanvasContext: CanvasRenderingContext2D | null = null\nconst drawQueue: CanvasDrawNode[] = []\n\nexport function getCanvasContext() {\n return currentCanvasContext\n}\n\nexport function queueDraw(node: CanvasDrawNode) {\n drawQueue.push(node)\n}\n\nexport function Canvas(props: CanvasProps) {\n const { width, height, children, style, ref } = props\n\n let canvas: HTMLCanvasElement | undefined\n let ctx: CanvasRenderingContext2D | null = null\n\n const render = () => {\n if (!canvas || !ctx) return\n\n // Clear canvas\n ctx.clearRect(0, 0, width, height)\n\n // Clear draw queue\n drawQueue.length = 0\n\n // Set current context for children\n currentCanvasContext = ctx\n\n // Render children (they will queue draw commands)\n if (Array.isArray(children)) {\n children.forEach(child => {\n if (typeof child === 'function') {\n child()\n }\n })\n } else if (typeof children === 'function') {\n children()\n }\n\n // Execute draw queue\n drawQueue.forEach(node => {\n drawNode(ctx!, node)\n })\n\n // Clear context\n currentCanvasContext = null\n }\n\n effect(() => {\n if (canvas) {\n render()\n }\n })\n\n return (\n <canvas\n ref={(el: HTMLCanvasElement) => {\n canvas = el\n ctx = el.getContext('2d')\n if (ref) ref(el)\n render()\n }}\n width={width}\n height={height}\n style={style}\n />\n )\n}\n\nfunction getValue(val: any): any {\n if (isReactive(val)) {\n return val.valueOf?.() ?? val\n }\n return val\n}\n\nfunction drawNode(ctx: CanvasRenderingContext2D, node: CanvasDrawNode) {\n const { type, props } = node\n\n // Apply opacity\n const opacity = getValue(props.opacity)\n if (opacity !== undefined) {\n ctx.globalAlpha = opacity\n }\n\n switch (type) {\n case 'rect': {\n const x = getValue(props.x)\n const y = getValue(props.y)\n const w = getValue(props.width)\n const h = getValue(props.height)\n const fill = getValue(props.fill)\n const stroke = getValue(props.stroke)\n const strokeWidth = getValue(props.strokeWidth)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fillRect(x, y, w, h)\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n if (strokeWidth) ctx.lineWidth = strokeWidth\n ctx.strokeRect(x, y, w, h)\n }\n break\n }\n\n case 'circle': {\n const x = getValue(props.x)\n const y = getValue(props.y)\n const radius = getValue(props.radius)\n const fill = getValue(props.fill)\n const stroke = getValue(props.stroke)\n const strokeWidth = getValue(props.strokeWidth)\n\n ctx.beginPath()\n ctx.arc(x, y, radius, 0, Math.PI * 2)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill()\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n if (strokeWidth) ctx.lineWidth = strokeWidth\n ctx.stroke()\n }\n break\n }\n\n case 'arc': {\n const x = getValue(props.x)\n const y = getValue(props.y)\n const radius = getValue(props.radius)\n const startAngle = getValue(props.startAngle)\n const endAngle = getValue(props.endAngle)\n const counterclockwise = getValue(props.counterclockwise) || false\n const fill = getValue(props.fill)\n const stroke = getValue(props.stroke)\n const strokeWidth = getValue(props.strokeWidth)\n\n ctx.beginPath()\n ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill()\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n if (strokeWidth) ctx.lineWidth = strokeWidth\n ctx.stroke()\n }\n break\n }\n\n case 'line': {\n const x1 = getValue(props.x1)\n const y1 = getValue(props.y1)\n const x2 = getValue(props.x2)\n const y2 = getValue(props.y2)\n const stroke = getValue(props.stroke) || 'black'\n const strokeWidth = getValue(props.strokeWidth) || 1\n\n ctx.beginPath()\n ctx.moveTo(x1, y1)\n ctx.lineTo(x2, y2)\n ctx.strokeStyle = stroke\n ctx.lineWidth = strokeWidth\n ctx.stroke()\n break\n }\n\n case 'text': {\n const x = getValue(props.x)\n const y = getValue(props.y)\n const text = getValue(props.text)\n const fill = getValue(props.fill) || 'black'\n const fontSize = getValue(props.fontSize) || 16\n const fontFamily = getValue(props.fontFamily) || 'sans-serif'\n const fontWeight = getValue(props.fontWeight) || 'normal'\n const textAlign = getValue(props.textAlign) || 'left'\n\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`\n ctx.textAlign = textAlign as CanvasTextAlign\n ctx.fillStyle = fill\n ctx.fillText(text, x, y)\n break\n }\n\n case 'path': {\n const d = getValue(props.d)\n const fill = getValue(props.fill)\n const stroke = getValue(props.stroke)\n const strokeWidth = getValue(props.strokeWidth)\n\n // Parse SVG path data\n const path = new Path2D(d)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill(path)\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n if (strokeWidth) ctx.lineWidth = strokeWidth\n ctx.stroke(path)\n }\n break\n }\n }\n\n // Reset opacity\n if (opacity !== undefined) {\n ctx.globalAlpha = 1\n }\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawRectProps {\n x: number | (() => number)\n y: number | (() => number)\n width: number | (() => number)\n height: number | (() => number)\n fill?: string | (() => string)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawRect(props: DrawRectProps) {\n effect(() => {\n queueDraw({\n type: 'rect',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawCircleProps {\n x: number | (() => number)\n y: number | (() => number)\n radius: number | (() => number)\n fill?: string | (() => string)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawCircle(props: DrawCircleProps) {\n effect(() => {\n queueDraw({\n type: 'circle',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawArcProps {\n x: number | (() => number)\n y: number | (() => number)\n radius: number | (() => number)\n startAngle: number | (() => number)\n endAngle: number | (() => number)\n counterclockwise?: boolean\n fill?: string | (() => string)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawArc(props: DrawArcProps) {\n effect(() => {\n queueDraw({\n type: 'arc',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawLineProps {\n x1: number | (() => number)\n y1: number | (() => number)\n x2: number | (() => number)\n y2: number | (() => number)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawLine(props: DrawLineProps) {\n effect(() => {\n queueDraw({\n type: 'line',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawTextProps {\n text: string | (() => string)\n x: number | (() => number)\n y: number | (() => number)\n fill?: string | (() => string)\n fontSize?: number | (() => number)\n fontFamily?: string | (() => string)\n fontWeight?: string | (() => string)\n textAlign?: 'left' | 'center' | 'right'\n opacity?: number | (() => number)\n}\n\nexport function DrawText(props: DrawTextProps) {\n effect(() => {\n queueDraw({\n type: 'text',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawPathProps {\n d: string | (() => string)\n fill?: string | (() => string)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawPath(props: DrawPathProps) {\n effect(() => {\n queueDraw({\n type: 'path',\n props\n })\n })\n\n return null\n}\n"]}
|
package/dist/canvas.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import {a as a$1}from'./chunk-EJ7Z5OMU.mjs';import {b}from'./chunk-CPJRQL2C.mjs';import'./chunk-44RZHCII.mjs';import {a}from'./chunk-ZCO4NIGC.mjs';var h=[];function u(e){h.push(e);}function D(e){let{width:p,height:b,children:r,style:m,ref:a$2}=e,i,o=null,s=()=>{!i||!o||(o.clearRect(0,0,p,b),h.length=0,Array.isArray(r)?r.forEach(n=>{typeof n=="function"&&n();}):typeof r=="function"&&r(),h.forEach(n=>{P(o,n);}),null);};return a$1(()=>{i&&s();}),a("canvas",{ref:n=>{i=n,o=n.getContext("2d"),a$2&&a$2(n),s();},width:p,height:b,style:m})}function t(e){return b(e)?e.valueOf?.()??e:e}function P(e,p){let{type:b,props:r}=p,m=t(r.opacity);switch(m!==void 0&&(e.globalAlpha=m),b){case "rect":{let a=t(r.x),i=t(r.y),o=t(r.width),s=t(r.height),n=t(r.fill),f=t(r.stroke),c=t(r.strokeWidth);n&&(e.fillStyle=n,e.fillRect(a,i,o,s)),f&&(e.strokeStyle=f,c&&(e.lineWidth=c),e.strokeRect(a,i,o,s));break}case "circle":{let a=t(r.x),i=t(r.y),o=t(r.radius),s=t(r.fill),n=t(r.stroke),f=t(r.strokeWidth);e.beginPath(),e.arc(a,i,o,0,Math.PI*2),s&&(e.fillStyle=s,e.fill()),n&&(e.strokeStyle=n,f&&(e.lineWidth=f),e.stroke());break}case "arc":{let a=t(r.x),i=t(r.y),o=t(r.radius),s=t(r.startAngle),n=t(r.endAngle),f=t(r.counterclockwise)||false,c=t(r.fill),y=t(r.stroke),g=t(r.strokeWidth);e.beginPath(),e.arc(a,i,o,s,n,f),c&&(e.fillStyle=c,e.fill()),y&&(e.strokeStyle=y,g&&(e.lineWidth=g),e.stroke());break}case "line":{let a=t(r.x1),i=t(r.y1),o=t(r.x2),s=t(r.y2),n=t(r.stroke)||"black",f=t(r.strokeWidth)||1;e.beginPath(),e.moveTo(a,i),e.lineTo(o,s),e.strokeStyle=n,e.lineWidth=f,e.stroke();break}case "text":{let a=t(r.x),i=t(r.y),o=t(r.text),s=t(r.fill)||"black",n=t(r.fontSize)||16,f=t(r.fontFamily)||"sans-serif",c=t(r.fontWeight)||"normal",y=t(r.textAlign)||"left";e.font=`${c} ${n}px ${f}`,e.textAlign=y,e.fillStyle=s,e.fillText(o,a,i);break}case "path":{let a=t(r.d),i=t(r.fill),o=t(r.stroke),s=t(r.strokeWidth),n=new Path2D(a);i&&(e.fillStyle=i,e.fill(n)),o&&(e.strokeStyle=o,s&&(e.lineWidth=s),e.stroke(n));break}}m!==void 0&&(e.globalAlpha=1);}function x(e){return a$1(()=>{u({type:"rect",props:e});}),null}function C(e){return a$1(()=>{u({type:"circle",props:e});}),null}function W(e){return a$1(()=>{u({type:"arc",props:e});}),null}function v(e){return a$1(()=>{u({type:"line",props:e});}),null}function A(e){return a$1(()=>{u({type:"text",props:e});}),null}function S(e){return a$1(()=>{u({type:"path",props:e});}),null}export{D as Canvas,W as DrawArc,C as DrawCircle,v as DrawLine,S as DrawPath,x as DrawRect,A as DrawText};//# sourceMappingURL=canvas.mjs.map
|
|
2
2
|
//# sourceMappingURL=canvas.mjs.map
|
package/dist/canvas.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"canvas.mjs"}
|
|
1
|
+
{"version":3,"sources":["../src/canvas/Canvas.tsx","../src/canvas/dom/DrawRect.tsx","../src/canvas/dom/DrawCircle.tsx","../src/canvas/dom/DrawArc.tsx","../src/canvas/dom/DrawLine.tsx","../src/canvas/dom/DrawText.tsx","../src/canvas/dom/DrawPath.tsx"],"names":["drawQueue","queueDraw","node","Canvas","props","width","height","children","style","ref","canvas","ctx","render","child","drawNode","effect","jsx","el","getValue","val","isReactive","type","opacity","x","y","w","h","fill","stroke","strokeWidth","radius","startAngle","endAngle","counterclockwise","x1","y1","x2","y2","text","fontSize","fontFamily","fontWeight","textAlign","d","path","DrawRect","DrawCircle","DrawArc","DrawLine","DrawText","DrawPath"],"mappings":"mJAiBA,IACMA,CAAAA,CAA8B,GAM7B,SAASC,CAAAA,CAAUC,CAAAA,CAAsB,CAC9CF,CAAAA,CAAU,KAAKE,CAAI,EACrB,CAEO,SAASC,CAAAA,CAAOC,EAAoB,CACzC,GAAM,CAAE,KAAA,CAAAC,EAAO,MAAA,CAAAC,CAAAA,CAAQ,SAAAC,CAAAA,CAAU,KAAA,CAAAC,EAAO,GAAA,CAAAC,GAAI,CAAA,CAAIL,CAAAA,CAE5CM,EACAC,CAAAA,CAAuC,IAAA,CAErCC,EAAS,IAAM,CACf,CAACF,CAAAA,EAAU,CAACC,CAAAA,GAGhBA,CAAAA,CAAI,UAAU,CAAA,CAAG,CAAA,CAAGN,CAAAA,CAAOC,CAAM,EAGjCN,CAAAA,CAAU,MAAA,CAAS,CAAA,CAMf,KAAA,CAAM,OAAA,CAAQO,CAAQ,CAAA,CACxBA,CAAAA,CAAS,QAAQM,CAAAA,EAAS,CACpB,OAAOA,CAAAA,EAAU,YACnBA,CAAAA,GAEJ,CAAC,CAAA,CACQ,OAAON,GAAa,UAAA,EAC7BA,CAAAA,EAAS,CAIXP,CAAAA,CAAU,QAAQE,CAAAA,EAAQ,CACxBY,EAASH,CAAAA,CAAMT,CAAI,EACrB,CAAC,CAAA,CAGsB,IAAA,EACzB,EAEA,OAAAa,GAAAA,CAAO,IAAM,CACPL,GACFE,CAAAA,GAEJ,CAAC,CAAA,CAGCI,EAAC,QAAA,CAAA,CACC,GAAA,CAAMC,GAA0B,CAC9BP,CAAAA,CAASO,EACTN,CAAAA,CAAMM,CAAAA,CAAG,UAAA,CAA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AAA,CAAI,YAAc,CAAA,EAEtB,CChOO,SAASkC,CAAAA,CAASzC,EAAsB,CAC7C,OAAAW,IAAO,IAAM,CACXd,EAAU,CACR,IAAA,CAAM,MAAA,CACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCVO,SAAS0C,CAAAA,CAAW1C,CAAAA,CAAwB,CACjD,OAAAW,GAAAA,CAAO,IAAM,CACXd,CAAAA,CAAU,CACR,KAAM,QAAA,CACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCNO,SAAS2C,CAAAA,CAAQ3C,CAAAA,CAAqB,CAC3C,OAAAW,IAAO,IAAM,CACXd,EAAU,CACR,IAAA,CAAM,MACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCZO,SAAS4C,CAAAA,CAAS5C,EAAsB,CAC7C,OAAAW,GAAAA,CAAO,IAAM,CACXd,CAAAA,CAAU,CACR,KAAM,MAAA,CACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCPO,SAAS6C,EAAS7C,CAAAA,CAAsB,CAC7C,OAAAW,GAAAA,CAAO,IAAM,CACXd,CAAAA,CAAU,CACR,IAAA,CAAM,MAAA,CACN,MAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCbO,SAAS8C,CAAAA,CAAS9C,CAAAA,CAAsB,CAC7C,OAAAW,GAAAA,CAAO,IAAM,CACXd,CAAAA,CAAU,CACR,IAAA,CAAM,OACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,EAEM,IACT","file":"canvas.mjs","sourcesContent":["import { effect } from '../core/lifecycle'\nimport { isReactive } from '../core/reactive'\n\nexport interface CanvasProps {\n width: number\n height: number\n children?: any\n style?: any\n ref?: (el: HTMLCanvasElement) => void\n}\n\ninterface CanvasDrawNode {\n type: 'rect' | 'circle' | 'arc' | 'line' | 'text' | 'path'\n props: any\n}\n\n// Canvas context for children to access\nlet currentCanvasContext: CanvasRenderingContext2D | null = null\nconst drawQueue: CanvasDrawNode[] = []\n\nexport function getCanvasContext() {\n return currentCanvasContext\n}\n\nexport function queueDraw(node: CanvasDrawNode) {\n drawQueue.push(node)\n}\n\nexport function Canvas(props: CanvasProps) {\n const { width, height, children, style, ref } = props\n\n let canvas: HTMLCanvasElement | undefined\n let ctx: CanvasRenderingContext2D | null = null\n\n const render = () => {\n if (!canvas || !ctx) return\n\n // Clear canvas\n ctx.clearRect(0, 0, width, height)\n\n // Clear draw queue\n drawQueue.length = 0\n\n // Set current context for children\n currentCanvasContext = ctx\n\n // Render children (they will queue draw commands)\n if (Array.isArray(children)) {\n children.forEach(child => {\n if (typeof child === 'function') {\n child()\n }\n })\n } else if (typeof children === 'function') {\n children()\n }\n\n // Execute draw queue\n drawQueue.forEach(node => {\n drawNode(ctx!, node)\n })\n\n // Clear context\n currentCanvasContext = null\n }\n\n effect(() => {\n if (canvas) {\n render()\n }\n })\n\n return (\n <canvas\n ref={(el: HTMLCanvasElement) => {\n canvas = el\n ctx = el.getContext('2d')\n if (ref) ref(el)\n render()\n }}\n width={width}\n height={height}\n style={style}\n />\n )\n}\n\nfunction getValue(val: any): any {\n if (isReactive(val)) {\n return val.valueOf?.() ?? val\n }\n return val\n}\n\nfunction drawNode(ctx: CanvasRenderingContext2D, node: CanvasDrawNode) {\n const { type, props } = node\n\n // Apply opacity\n const opacity = getValue(props.opacity)\n if (opacity !== undefined) {\n ctx.globalAlpha = opacity\n }\n\n switch (type) {\n case 'rect': {\n const x = getValue(props.x)\n const y = getValue(props.y)\n const w = getValue(props.width)\n const h = getValue(props.height)\n const fill = getValue(props.fill)\n const stroke = getValue(props.stroke)\n const strokeWidth = getValue(props.strokeWidth)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fillRect(x, y, w, h)\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n if (strokeWidth) ctx.lineWidth = strokeWidth\n ctx.strokeRect(x, y, w, h)\n }\n break\n }\n\n case 'circle': {\n const x = getValue(props.x)\n const y = getValue(props.y)\n const radius = getValue(props.radius)\n const fill = getValue(props.fill)\n const stroke = getValue(props.stroke)\n const strokeWidth = getValue(props.strokeWidth)\n\n ctx.beginPath()\n ctx.arc(x, y, radius, 0, Math.PI * 2)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill()\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n if (strokeWidth) ctx.lineWidth = strokeWidth\n ctx.stroke()\n }\n break\n }\n\n case 'arc': {\n const x = getValue(props.x)\n const y = getValue(props.y)\n const radius = getValue(props.radius)\n const startAngle = getValue(props.startAngle)\n const endAngle = getValue(props.endAngle)\n const counterclockwise = getValue(props.counterclockwise) || false\n const fill = getValue(props.fill)\n const stroke = getValue(props.stroke)\n const strokeWidth = getValue(props.strokeWidth)\n\n ctx.beginPath()\n ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill()\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n if (strokeWidth) ctx.lineWidth = strokeWidth\n ctx.stroke()\n }\n break\n }\n\n case 'line': {\n const x1 = getValue(props.x1)\n const y1 = getValue(props.y1)\n const x2 = getValue(props.x2)\n const y2 = getValue(props.y2)\n const stroke = getValue(props.stroke) || 'black'\n const strokeWidth = getValue(props.strokeWidth) || 1\n\n ctx.beginPath()\n ctx.moveTo(x1, y1)\n ctx.lineTo(x2, y2)\n ctx.strokeStyle = stroke\n ctx.lineWidth = strokeWidth\n ctx.stroke()\n break\n }\n\n case 'text': {\n const x = getValue(props.x)\n const y = getValue(props.y)\n const text = getValue(props.text)\n const fill = getValue(props.fill) || 'black'\n const fontSize = getValue(props.fontSize) || 16\n const fontFamily = getValue(props.fontFamily) || 'sans-serif'\n const fontWeight = getValue(props.fontWeight) || 'normal'\n const textAlign = getValue(props.textAlign) || 'left'\n\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`\n ctx.textAlign = textAlign as CanvasTextAlign\n ctx.fillStyle = fill\n ctx.fillText(text, x, y)\n break\n }\n\n case 'path': {\n const d = getValue(props.d)\n const fill = getValue(props.fill)\n const stroke = getValue(props.stroke)\n const strokeWidth = getValue(props.strokeWidth)\n\n // Parse SVG path data\n const path = new Path2D(d)\n\n if (fill) {\n ctx.fillStyle = fill\n ctx.fill(path)\n }\n\n if (stroke) {\n ctx.strokeStyle = stroke\n if (strokeWidth) ctx.lineWidth = strokeWidth\n ctx.stroke(path)\n }\n break\n }\n }\n\n // Reset opacity\n if (opacity !== undefined) {\n ctx.globalAlpha = 1\n }\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawRectProps {\n x: number | (() => number)\n y: number | (() => number)\n width: number | (() => number)\n height: number | (() => number)\n fill?: string | (() => string)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawRect(props: DrawRectProps) {\n effect(() => {\n queueDraw({\n type: 'rect',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawCircleProps {\n x: number | (() => number)\n y: number | (() => number)\n radius: number | (() => number)\n fill?: string | (() => string)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawCircle(props: DrawCircleProps) {\n effect(() => {\n queueDraw({\n type: 'circle',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawArcProps {\n x: number | (() => number)\n y: number | (() => number)\n radius: number | (() => number)\n startAngle: number | (() => number)\n endAngle: number | (() => number)\n counterclockwise?: boolean\n fill?: string | (() => string)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawArc(props: DrawArcProps) {\n effect(() => {\n queueDraw({\n type: 'arc',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawLineProps {\n x1: number | (() => number)\n y1: number | (() => number)\n x2: number | (() => number)\n y2: number | (() => number)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawLine(props: DrawLineProps) {\n effect(() => {\n queueDraw({\n type: 'line',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawTextProps {\n text: string | (() => string)\n x: number | (() => number)\n y: number | (() => number)\n fill?: string | (() => string)\n fontSize?: number | (() => number)\n fontFamily?: string | (() => string)\n fontWeight?: string | (() => string)\n textAlign?: 'left' | 'center' | 'right'\n opacity?: number | (() => number)\n}\n\nexport function DrawText(props: DrawTextProps) {\n effect(() => {\n queueDraw({\n type: 'text',\n props\n })\n })\n\n return null\n}\n","import { effect } from '../../core/lifecycle'\nimport { queueDraw } from '../Canvas'\n\nexport interface DrawPathProps {\n d: string | (() => string)\n fill?: string | (() => string)\n stroke?: string | (() => string)\n strokeWidth?: number | (() => number)\n opacity?: number | (() => number)\n}\n\nexport function DrawPath(props: DrawPathProps) {\n effect(() => {\n queueDraw({\n type: 'path',\n props\n })\n })\n\n return null\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var o,r=class{constructor(t,n){this.fn=t;this.scheduler=n;this.deps=[];this.active=true;}run(){if(!this.active)return this.fn();let t=o;try{return this.cleanup(),o=this,this.fn()}finally{o=t;}}stop(){this.active&&(this.cleanup(),this.active=false);}cleanup(){let{deps:t}=this;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(this);t.length=0;}}};function p(e,t={}){let n=new r(e,t.scheduler);n.run();let c=n.run.bind(n);return c.effect=n,c}function d(e){o&&(e.add(o),o.deps.push(e));}var i=new Set,s=false,a=false;function l(e){i.has(e)||(i.add(e),!s&&!a&&(s=true,Promise.resolve().then(h)));}function h(){s=false;let e=[...i];i.clear();for(let t of e)t.active&&t.run();}function v(e){a=e;}function x(e){let t=[...e];for(let n of t)n!==o&&(n.scheduler?n.scheduler():l(n));}var f=null;function g(e,t){let n=f;f=e,e.hookIndex=0;try{return t()}finally{f=n;}}function k(e){if(!f)return e();let t=f,{hooks:n,hookIndex:c}=t;if(c<n.length)return t.hookIndex++,n[c];let u=e();return n.push(u),t.hookIndex++,u}export{o as a,p as b,d as c,h as d,v as e,x as f,g,k as h};//# sourceMappingURL=chunk-44RZHCII.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-44RZHCII.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/effect.ts","../src/core/hook.ts"],"names":["activeEffect","ReactiveEffectLike","fn","scheduler","parent","deps","i","unsafeEffect","options","_effect","runner","trackEffect","dep","queue","isFlushPending","isBatching","queueJob","effect","flush","effects","setBatching","value","triggerEffects","currentComponent","runWithComponent","component","prev","hook","factory","instance","hooks","hookIndex"],"mappings":"AAAO,IAAIA,CAAAA,CAEEC,CAAAA,CAAN,KAAyB,CAI5B,YACWC,CAAAA,CACAC,CAAAA,CACT,CAFS,IAAA,CAAA,EAAA,CAAAD,CAAAA,CACA,IAAA,CAAA,SAAA,CAAAC,CAAAA,CALX,IAAA,CAAA,IAAA,CAAmB,EAAC,CACpB,IAAA,CAAA,MAAA,CAAS,KAKL,CAEJ,GAAA,EAAM,CACF,GAAI,CAAC,KAAK,MAAA,CACN,OAAO,IAAA,CAAK,EAAA,EAAG,CAGnB,IAAIC,CAAAA,CAAqCJ,CAAAA,CACzC,GAAI,CACA,OAAA,IAAA,CAAK,OAAA,EAAQ,CACbA,CAAAA,CAAe,IAAA,CACR,IAAA,CAAK,EAAA,EAChB,CAAA,OAAE,CACEA,CAAAA,CAAeI,EACnB,CACJ,CAEA,IAAA,EAAO,CACC,KAAK,MAAA,GACL,IAAA,CAAK,OAAA,EAAQ,CACb,IAAA,CAAK,MAAA,CAAS,KAAA,EAEtB,CA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,EACzBA,CAAAA,CAAM,KAAA,EAAM,CACZ,IAAA,IAAWI,CAAAA,IAAUE,CAAAA,CACbF,CAAAA,CAAO,MAAA,EACPA,EAAO,GAAA,GAGnB,CAEO,SAASG,CAAAA,CAAYC,CAAAA,CAAgB,CACxCN,CAAAA,CAAaM,EACjB,CAEO,SAASC,CAAAA,CAAeV,CAAAA,CAA0B,CACrD,IAAMO,CAAAA,CAAU,CAAC,GAAGP,CAAG,CAAA,CACvB,IAAA,IAAWK,CAAAA,IAAUE,EACbF,CAAAA,GAAWjB,CAAAA,GACPiB,CAAAA,CAAO,SAAA,CACPA,EAAO,SAAA,EAAU,CAEjBD,CAAAA,CAASC,CAAM,CAAA,EAI/B,CChGA,IAAIM,CAAAA,CAA6C,KAM1C,SAASC,CAAAA,CAAoBC,CAAAA,CAA8BvB,CAAAA,CAAgB,CAC9E,IAAMwB,CAAAA,CAAOH,CAAAA,CACbA,EAAmBE,CAAAA,CACnBA,CAAAA,CAAU,SAAA,CAAY,CAAA,CACtB,GAAI,CACA,OAAOvB,CAAAA,EACX,CAAA,OAAE,CACEqB,CAAAA,CAAmBG,EACvB,CACJ,CAEO,SAASC,CAAAA,CAAQC,CAAAA,CAAqB,CACzC,GAAI,CAACL,CAAAA,CAED,OAAOK,CAAAA,EAAQ,CAGnB,IAAMC,CAAAA,CAAWN,EACX,CAAE,KAAA,CAAAO,CAAAA,CAAO,SAAA,CAAAC,CAAU,CAAA,CAAIF,CAAAA,CAE7B,GAAIE,EAAYD,CAAAA,CAAM,MAAA,CAElB,OAAAD,CAAAA,CAAS,SAAA,EAAA,CACFC,CAAAA,CAAMC,CAAS,CAAA,CAI1B,IAAMV,CAAAA,CAAQO,CAAAA,EAAQ,CACtB,OAAAE,EAAM,IAAA,CAAKT,CAAK,CAAA,CAChBQ,CAAAA,CAAS,YAEFR,CACX","file":"chunk-44RZHCII.mjs","sourcesContent":["export let activeEffect: ReactiveEffect | undefined\n\nexport class ReactiveEffectLike {\n deps: Set<any>[] = []\n active = true\n\n constructor(\n public fn: () => void,\n public scheduler?: () => void\n ) { }\n\n run() {\n if (!this.active) {\n return this.fn()\n }\n\n let parent: ReactiveEffect | undefined = activeEffect\n try {\n this.cleanup()\n activeEffect = this\n return this.fn()\n } finally {\n activeEffect = parent\n }\n }\n\n stop() {\n if (this.active) {\n this.cleanup()\n this.active = false\n }\n }\n\n cleanup() {\n const { deps } = this\n if (deps.length) {\n for (let i = 0; i < deps.length; i++) {\n deps[i].delete(this)\n }\n deps.length = 0\n }\n }\n}\n\nexport type ReactiveEffect = ReactiveEffectLike\n\nexport function unsafeEffect(fn: () => void, options: { scheduler?: () => void } = {}) {\n const _effect = new ReactiveEffectLike(fn, options.scheduler)\n _effect.run()\n\n const runner: any = _effect.run.bind(_effect)\n runner.effect = _effect\n return runner\n}\n\nexport function trackEffect(dep: Set<ReactiveEffect>) {\n if (activeEffect) {\n dep.add(activeEffect)\n activeEffect.deps.push(dep)\n }\n}\n\nconst queue = new Set<ReactiveEffect>()\nlet isFlushPending = false\nlet isBatching = false\n\nexport function queueJob(effect: ReactiveEffect) {\n if (!queue.has(effect)) {\n queue.add(effect)\n if (!isFlushPending && !isBatching) {\n isFlushPending = true\n Promise.resolve().then(flush)\n }\n }\n}\n\nexport function flush() {\n isFlushPending = false\n const effects = [...queue]\n queue.clear()\n for (const effect of effects) {\n if (effect.active) {\n effect.run()\n }\n }\n}\n\nexport function setBatching(value: boolean) {\n isBatching = value\n}\n\nexport function triggerEffects(dep: Set<ReactiveEffect>) {\n const effects = [...dep]\n for (const effect of effects) {\n if (effect !== activeEffect) {\n if (effect.scheduler) {\n effect.scheduler()\n } else {\n queueJob(effect)\n }\n }\n }\n}\n","\nexport interface ComponentInstance {\n hooks: any[]\n hookIndex: number\n}\n\nlet currentComponent: ComponentInstance | null = null\n\nexport function getComponent(): ComponentInstance | null {\n return currentComponent\n}\n\nexport function runWithComponent<T>(component: ComponentInstance, fn: () => T): T {\n const prev = currentComponent\n currentComponent = component\n component.hookIndex = 0\n try {\n return fn()\n } finally {\n currentComponent = prev\n }\n}\n\nexport function hook<T>(factory: () => T): T {\n if (!currentComponent) {\n // Outside component: just run factory\n return factory()\n }\n\n const instance = currentComponent\n const { hooks, hookIndex } = instance\n\n if (hookIndex < hooks.length) {\n // Return existing hook\n instance.hookIndex++\n return hooks[hookIndex] as T\n }\n\n // Create new hook\n const value = factory()\n hooks.push(value)\n instance.hookIndex++\n\n return value\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkENWGYQNU_js=require('./chunk-ENWGYQNU.js');var p=Symbol("flexium.reactive"),s=new WeakMap,l=new WeakMap;function M(e){if(e&&e[p])return e;let o=l.get(e);if(o)return o;let t=new Proxy(e,{get(n,r,i){if(r===p)return true;let c=Reflect.get(n,r,i);return b(n,r),c!==null&&typeof c=="object"?M(c):c},set(n,r,i,c){let x=n[r],a=Reflect.set(n,r,i,c);return a&&d(i,x)&&w(n,r),a}});return l.set(e,t),t}function b(e,o){if(!chunkENWGYQNU_js.a)return;let t=s.get(e);t||s.set(e,t=new Map);let n=t.get(o);n||t.set(o,n=new Set),chunkENWGYQNU_js.c(n);}function w(e,o){let t=s.get(e);if(!t)return;let n=t.get(o);n&&chunkENWGYQNU_js.f(n);}function d(e,o){return !Object.is(e,o)}function T(e){return !!(e&&e[p])}exports.a=M;exports.b=T;//# sourceMappingURL=chunk-7BXR4ZFD.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-7BXR4ZFD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/reactive.ts"],"names":["REACTIVE_SIGNAL","targetMap","reactiveMap","reactive","target","existingProxy","proxy","key","receiver","res","track","value","oldValue","result","hasChanged","trigger","activeEffect","depsMap","dep","trackEffect","triggerEffects","isReactive"],"mappings":"iEAEO,IAAMA,CAAAA,CAAkB,OAAO,kBAAkB,CAAA,CAIlDC,EAAY,IAAI,OAAA,CAGhBC,EAAc,IAAI,OAA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,CAAAA,CAAU,IAAI,GAAM,CAAA,CAG/C,IAAIC,CAAAA,CAAMD,CAAAA,CAAQ,GAAA,CAAIV,CAAG,CAAA,CACpBW,CAAAA,EACDD,EAAQ,GAAA,CAAIV,CAAAA,CAAMW,EAAM,IAAI,GAAM,CAAA,CAGtCC,kBAAAA,CAAYD,CAAG,EACnB,CAEO,SAASH,CAAAA,CAAQX,EAAgBG,CAAAA,CAAc,CAClD,IAAMU,CAAAA,CAAUhB,CAAAA,CAAU,GAAA,CAAIG,CAAM,CAAA,CACpC,GAAI,CAACa,CAAAA,CAAS,OAEd,IAAMC,CAAAA,CAAMD,CAAAA,CAAQ,IAAIV,CAAG,CAAA,CACvBW,CAAAA,EACAE,kBAAAA,CAAeF,CAAG,EAE1B,CAEA,SAASJ,CAAAA,CAAWH,EAAYC,CAAAA,CAAwB,CACpD,OAAO,CAAC,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAOC,CAAQ,CACrC,CAEO,SAASS,CAAAA,CAAWV,EAAyB,CAChD,OAAO,CAAC,EAAEA,CAAAA,EAAUA,CAAAA,CAAcX,CAAe,CAAA,CACrD","file":"chunk-7BXR4ZFD.js","sourcesContent":["import { activeEffect, trackEffect, triggerEffects } from './effect'\n\nexport const REACTIVE_SIGNAL = Symbol('flexium.reactive')\n\ntype Dep = Set<any>\ntype KeyToDepMap = Map<any, Dep>\nconst targetMap = new WeakMap<any, KeyToDepMap>()\n\n// WeakMap to store existing proxies to avoid duplicates\nconst reactiveMap = new WeakMap<object, any>()\n\nexport function reactive<T extends object>(target: T): T {\n if (target && (target as any)[REACTIVE_SIGNAL]) {\n return target\n }\n\n const existingProxy = reactiveMap.get(target)\n if (existingProxy) {\n return existingProxy\n }\n\n const proxy = new Proxy(target, {\n get(target, key, receiver) {\n if (key === REACTIVE_SIGNAL) return true\n\n const res = Reflect.get(target, key, receiver)\n\n track(target, key)\n\n if (res !== null && typeof res === 'object') {\n return reactive(res)\n }\n\n return res\n },\n set(target, key, value, receiver) {\n const oldValue = (target as any)[key]\n const result = Reflect.set(target, key, value, receiver)\n\n if (result && hasChanged(value, oldValue)) {\n trigger(target, key)\n }\n\n return result\n }\n })\n\n reactiveMap.set(target, proxy)\n return proxy\n}\n\nexport function track(target: object, key: unknown) {\n if (!activeEffect) return\n\n let depsMap = targetMap.get(target)\n if (!depsMap) {\n targetMap.set(target, (depsMap = new Map()))\n }\n\n let dep = depsMap.get(key)\n if (!dep) {\n depsMap.set(key, (dep = new Set()))\n }\n\n trackEffect(dep)\n}\n\nexport function trigger(target: object, key: unknown) {\n const depsMap = targetMap.get(target)\n if (!depsMap) return\n\n const dep = depsMap.get(key)\n if (dep) {\n triggerEffects(dep)\n }\n}\n\nfunction hasChanged(value: any, oldValue: any): boolean {\n return !Object.is(value, oldValue)\n}\n\nexport function isReactive(value: unknown): boolean {\n return !!(value && (value as any)[REACTIVE_SIGNAL])\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a}from'./chunk-CPJRQL2C.mjs';import {h,b}from'./chunk-44RZHCII.mjs';var f=new Map;function S(s){return JSON.stringify(s)}function x(s,l){if(l?.key&&!Array.isArray(l.key))throw new Error("State key must be an array");let r=h(()=>a({container:void 0,serializedKey:void 0})),d=l?.key,n=d?S(d):void 0,v=n!==r.serializedKey;if(!r.container||v)if(r.serializedKey=n,n&&f.has(n))r.container=f.get(n);else {let o;if(typeof s=="function"){let a$1=s,e=a({type:"resource",value:void 0,loading:true,error:null,status:"idle",run:()=>{}}),p=()=>{try{let i=a$1();i instanceof Promise?(e.loading=!0,e.status="loading",e.error=null,i.then(c=>{e.value=c,e.status="success",e.loading=!1;}).catch(c=>{e.error=c,e.status="error",e.loading=!1;})):(e.value=i,e.status="success",e.loading=!1,e.error=null);}catch(i){e.error=i,e.status="error",e.loading=false;}};e.run=p,b(p),o=e;}else o=a({type:"signal",value:s});n&&f.set(n,o),r.container=o;}let t=r.container,y=t.value;return t.type==="signal"?[y,a=>{typeof a=="function"?t.value=a(t.value):t.value=a;}]:[y,{refetch:async()=>{t.run();},get loading(){return t.loading},get error(){return t.error},get status(){return t.status}}]}export{x as a};//# sourceMappingURL=chunk-7DXFHPWZ.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-7DXFHPWZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/state.ts"],"names":["globalRegistry","serializeKey","key","state","input","options","stateRef","hook","reactive","currentKey","serializedKey","keyChanged","newContainer","fn","run","result","data","err","unsafeEffect","container","currentValue","newValue"],"mappings":"4EAqBA,IAAMA,CAAAA,CAAiB,IAAI,GAAA,CAE3B,SAASC,CAAAA,CAAaC,CAAAA,CAAwB,CAC5C,OAAO,IAAA,CAAK,SAAA,CAAUA,CAAG,CAC3B,CAMO,SAASC,CAAAA,CAASC,CAAAA,CAA2CC,CAAAA,CAA6B,CAE/F,GAAIA,CAAAA,EAAS,GAAA,EAAO,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAAA,CAAQ,GAAG,CAAA,CAC5C,MAAM,IAAI,MAAM,4BAA4B,CAAA,CAI9C,IAAMC,CAAAA,CAAWC,CAAAA,CAAK,IACbC,CAAAA,CAAS,CACd,SAAA,CAAW,MAAA,CACX,aAAA,CAAe,MACjB,CAAC,CACF,CAAA,CAGKC,CAAAA,CAAaJ,GAAS,GAAA,CACtBK,CAAAA,CAAgBD,CAAAA,CAAaR,CAAAA,CAAaQ,CAAU,CAAA,CAAI,MAAA,CAGxDE,CAAAA,CAAaD,IAAkBJ,CAAAA,CAAS,aAAA,CAG9C,GAAI,CAACA,CAAAA,CAAS,SAAA,EAAaK,CAAAA,CAIzB,GAHAL,EAAS,aAAA,CAAgBI,CAAAA,CAGrBA,CAAAA,EAAiBV,CAAAA,CAAe,GAAA,CAAIU,CAAa,CAAA,CACnDJ,CAAAA,CAAS,SAAA,CAAYN,CAAAA,CAAe,GAAA,CAAIU,CAAa,CAAA,CAAA,KAChD,CACL,IAAIE,CAAAA,CAGJ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AGES,CAAAA,CAAeJ,EAAS,CACtB,IAAA,CAAM,QAAA,CACN,KAAA,CAAOJ,CACT,CAAC,CAAA,CAICM,CAAAA,EACFV,EAAe,GAAA,CAAIU,CAAAA,CAAeE,CAAY,CAAA,CAGhDN,CAAAA,CAAS,SAAA,CAAYM,EACvB,CAGF,IAAMO,CAAAA,CAAYb,CAAAA,CAAS,SAAA,CAIrBc,CAAAA,CAAeD,CAAAA,CAAU,KAAA,CAE/B,OAAIA,EAAU,IAAA,GAAS,QAAA,CAQd,CAACC,CAAAA,CAPQC,CAAAA,EAAmC,CAC7C,OAAOA,CAAAA,EAAa,UAAA,CACtBF,CAAAA,CAAU,KAAA,CAASE,CAAAA,CAAsBF,CAAAA,CAAU,KAAK,CAAA,CAExDA,CAAAA,CAAU,MAAQE,EAEtB,CAC4B,CAAA,CASrB,CAACD,CAAAA,CANQ,CACd,OAAA,CAAS,SAAY,CAAED,CAAAA,CAAU,GAAA,GAAM,CAAA,CACvC,IAAI,OAAA,EAAU,CAAE,OAAOA,CAAAA,CAAU,OAAQ,CAAA,CACzC,IAAI,KAAA,EAAQ,CAAE,OAAOA,CAAAA,CAAU,KAAM,CAAA,CACrC,IAAI,MAAA,EAAS,CAAE,OAAOA,CAAAA,CAAU,MAAO,CACzC,CAC6B,CAEjC","file":"chunk-7DXFHPWZ.mjs","sourcesContent":["\nimport { reactive } from './reactive'\nimport { unsafeEffect } from './effect'\nimport { hook } from './hook'\n\nexport type StateSetter<T> = (newValue: T | ((prev: T) => T)) => void\n\nexport type ResourceControl = {\n refetch: () => Promise<void>\n readonly loading: boolean\n readonly error: unknown\n readonly status: 'idle' | 'loading' | 'success' | 'error'\n}\n\nexport type StateAction<T> = StateSetter<T> | ResourceControl\n\nexport interface StateOptions {\n key?: unknown[]\n}\n\n// Global State Registry\nconst globalRegistry = new Map<string, any>()\n\nfunction serializeKey(key: unknown[]): string {\n return JSON.stringify(key)\n}\n\n// Overloads\nexport function state<T>(fn: () => Promise<T>, options?: StateOptions): [T | undefined, ResourceControl]\nexport function state<T>(fn: () => T, options?: StateOptions): [T, ResourceControl]\nexport function state<T>(initialValue: T extends Function ? never : T, options?: StateOptions): [T, StateSetter<T>]\nexport function state<T>(input: T | (() => T) | (() => Promise<T>), options?: StateOptions): any {\n // 0. Validate key if provided\n if (options?.key && !Array.isArray(options.key)) {\n throw new Error('State key must be an array')\n }\n\n // Hook Wrapper: Store container reference and track key\n const stateRef = hook(() => {\n return reactive({\n container: undefined as any,\n serializedKey: undefined as any\n })\n })\n\n // Compute serialized key\n const currentKey = options?.key\n const serializedKey = currentKey ? serializeKey(currentKey) : undefined\n\n // Check if key has changed by comparing serialized strings\n const keyChanged = serializedKey !== stateRef.serializedKey\n\n // If key changed or first time, get/create container\n if (!stateRef.container || keyChanged) {\n stateRef.serializedKey = serializedKey\n\n // Check Registry FIRST\n if (serializedKey && globalRegistry.has(serializedKey)) {\n stateRef.container = globalRegistry.get(serializedKey)\n } else {\n let newContainer: any\n\n // 1. Function (Computed or Resource)\n if (typeof input === 'function') {\n const fn = input as Function\n\n const state = reactive({\n type: 'resource',\n value: undefined as T | undefined,\n loading: true,\n error: null as any,\n status: 'idle' as 'idle' | 'loading' | 'success' | 'error',\n run: () => { }\n })\n\n const run = () => {\n try {\n const result = fn()\n\n if (result instanceof Promise) {\n state.loading = true\n state.status = 'loading'\n state.error = null\n\n result\n .then(data => {\n state.value = data\n state.status = 'success'\n state.loading = false\n })\n .catch(err => {\n state.error = err\n state.status = 'error'\n state.loading = false\n })\n } else {\n state.value = result\n state.status = 'success'\n state.loading = false\n state.error = null\n }\n } catch (err) {\n state.error = err\n state.status = 'error'\n state.loading = false\n }\n }\n\n state.run = run\n\n // Make it reactive!\n unsafeEffect(run)\n\n newContainer = state\n\n } else {\n // 2. Value (Signal)\n // We return the reactive proxy itself as the container\n newContainer = reactive({\n type: 'signal',\n value: input\n })\n }\n\n // Register in global registry if needed\n if (serializedKey) {\n globalRegistry.set(serializedKey, newContainer)\n }\n\n stateRef.container = newContainer\n }\n }\n\n const container = stateRef.container\n\n // --- RETURN LOGIC ---\n // Access container.value to track dependency in the component's effect\n const currentValue = container.value\n\n if (container.type === 'signal') {\n const setter = (newValue: T | ((prev: T) => T)) => {\n if (typeof newValue === 'function') {\n container.value = (newValue as Function)(container.value)\n } else {\n container.value = newValue\n }\n }\n return [currentValue, setter]\n } else {\n // Resource / Computed\n const control = {\n refetch: async () => { container.run() },\n get loading() { return container.loading },\n get error() { return container.error },\n get status() { return container.status }\n }\n return [currentValue, control]\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk7BXR4ZFD_js=require('./chunk-7BXR4ZFD.js'),chunkENWGYQNU_js=require('./chunk-ENWGYQNU.js');var f=new Map;function S(s){return JSON.stringify(s)}function x(s,l){if(l?.key&&!Array.isArray(l.key))throw new Error("State key must be an array");let r=chunkENWGYQNU_js.h(()=>chunk7BXR4ZFD_js.a({container:void 0,serializedKey:void 0})),d=l?.key,n=d?S(d):void 0,v=n!==r.serializedKey;if(!r.container||v)if(r.serializedKey=n,n&&f.has(n))r.container=f.get(n);else {let o;if(typeof s=="function"){let a=s,e=chunk7BXR4ZFD_js.a({type:"resource",value:void 0,loading:true,error:null,status:"idle",run:()=>{}}),p=()=>{try{let i=a();i instanceof Promise?(e.loading=!0,e.status="loading",e.error=null,i.then(c=>{e.value=c,e.status="success",e.loading=!1;}).catch(c=>{e.error=c,e.status="error",e.loading=!1;})):(e.value=i,e.status="success",e.loading=!1,e.error=null);}catch(i){e.error=i,e.status="error",e.loading=false;}};e.run=p,chunkENWGYQNU_js.b(p),o=e;}else o=chunk7BXR4ZFD_js.a({type:"signal",value:s});n&&f.set(n,o),r.container=o;}let t=r.container,y=t.value;return t.type==="signal"?[y,a=>{typeof a=="function"?t.value=a(t.value):t.value=a;}]:[y,{refetch:async()=>{t.run();},get loading(){return t.loading},get error(){return t.error},get status(){return t.status}}]}exports.a=x;//# sourceMappingURL=chunk-ALTO2MGI.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-ALTO2MGI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/state.ts"],"names":["globalRegistry","serializeKey","key","state","input","options","stateRef","hook","reactive","currentKey","serializedKey","keyChanged","newContainer","fn","run","result","data","err","unsafeEffect","container","currentValue","newValue"],"mappings":"iHAqBA,IAAMA,CAAAA,CAAiB,IAAI,GAAA,CAE3B,SAASC,CAAAA,CAAaC,CAAAA,CAAwB,CAC5C,OAAO,IAAA,CAAK,SAAA,CAAUA,CAAG,CAC3B,CAMO,SAASC,CAAAA,CAASC,CAAAA,CAA2CC,CAAAA,CAA6B,CAE/F,GAAIA,CAAAA,EAAS,GAAA,EAAO,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAAA,CAAQ,GAAG,CAAA,CAC5C,MAAM,IAAI,MAAM,4BAA4B,CAAA,CAI9C,IAAMC,CAAAA,CAAWC,kBAAAA,CAAK,IACbC,kBAAAA,CAAS,CACd,SAAA,CAAW,MAAA,CACX,aAAA,CAAe,MACjB,CAAC,CACF,CAAA,CAGKC,CAAAA,CAAaJ,GAAS,GAAA,CACtBK,CAAAA,CAAgBD,CAAAA,CAAaR,CAAAA,CAAaQ,CAAU,CAAA,CAAI,MAAA,CAGxDE,CAAAA,CAAaD,IAAkBJ,CAAAA,CAAS,aAAA,CAG9C,GAAI,CAACA,CAAAA,CAAS,SAAA,EAAaK,CAAAA,CAIzB,GAHAL,EAAS,aAAA,CAAgBI,CAAAA,CAGrBA,CAAAA,EAAiBV,CAAAA,CAAe,GAAA,CAAIU,CAAa,CAAA,CACnDJ,CAAAA,CAAS,SAAA,CAAYN,CAAAA,CAAe,GAAA,CAAIU,CAAa,CAAA,CAAA,KAChD,CACL,IAAIE,CAAAA,CAGJ,GAAI,OAAOR,CAAAA,EAAU,UAAA,CAAY,CAC/B,IAAMS,CAAAA,CAAKT,CAAAA,CAELD,CAAAA,CAAQK,kBAAAA,CAAS,CAC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,GAAA,CAAIU,CAAAA,CAAeE,CAAY,CAAA,CAGhDN,CAAAA,CAAS,SAAA,CAAYM,EACvB,CAGF,IAAMO,CAAAA,CAAYb,CAAAA,CAAS,SAAA,CAIrBc,CAAAA,CAAeD,CAAAA,CAAU,KAAA,CAE/B,OAAIA,EAAU,IAAA,GAAS,QAAA,CAQd,CAACC,CAAAA,CAPQC,CAAAA,EAAmC,CAC7C,OAAOA,CAAAA,EAAa,UAAA,CACtBF,CAAAA,CAAU,KAAA,CAASE,CAAAA,CAAsBF,CAAAA,CAAU,KAAK,CAAA,CAExDA,CAAAA,CAAU,MAAQE,EAEtB,CAC4B,CAAA,CASrB,CAACD,CAAAA,CANQ,CACd,OAAA,CAAS,SAAY,CAAED,CAAAA,CAAU,GAAA,GAAM,CAAA,CACvC,IAAI,OAAA,EAAU,CAAE,OAAOA,CAAAA,CAAU,OAAQ,CAAA,CACzC,IAAI,KAAA,EAAQ,CAAE,OAAOA,CAAAA,CAAU,KAAM,CAAA,CACrC,IAAI,MAAA,EAAS,CAAE,OAAOA,CAAAA,CAAU,MAAO,CACzC,CAC6B,CAEjC","file":"chunk-ALTO2MGI.js","sourcesContent":["\nimport { reactive } from './reactive'\nimport { unsafeEffect } from './effect'\nimport { hook } from './hook'\n\nexport type StateSetter<T> = (newValue: T | ((prev: T) => T)) => void\n\nexport type ResourceControl = {\n refetch: () => Promise<void>\n readonly loading: boolean\n readonly error: unknown\n readonly status: 'idle' | 'loading' | 'success' | 'error'\n}\n\nexport type StateAction<T> = StateSetter<T> | ResourceControl\n\nexport interface StateOptions {\n key?: unknown[]\n}\n\n// Global State Registry\nconst globalRegistry = new Map<string, any>()\n\nfunction serializeKey(key: unknown[]): string {\n return JSON.stringify(key)\n}\n\n// Overloads\nexport function state<T>(fn: () => Promise<T>, options?: StateOptions): [T | undefined, ResourceControl]\nexport function state<T>(fn: () => T, options?: StateOptions): [T, ResourceControl]\nexport function state<T>(initialValue: T extends Function ? never : T, options?: StateOptions): [T, StateSetter<T>]\nexport function state<T>(input: T | (() => T) | (() => Promise<T>), options?: StateOptions): any {\n // 0. Validate key if provided\n if (options?.key && !Array.isArray(options.key)) {\n throw new Error('State key must be an array')\n }\n\n // Hook Wrapper: Store container reference and track key\n const stateRef = hook(() => {\n return reactive({\n container: undefined as any,\n serializedKey: undefined as any\n })\n })\n\n // Compute serialized key\n const currentKey = options?.key\n const serializedKey = currentKey ? serializeKey(currentKey) : undefined\n\n // Check if key has changed by comparing serialized strings\n const keyChanged = serializedKey !== stateRef.serializedKey\n\n // If key changed or first time, get/create container\n if (!stateRef.container || keyChanged) {\n stateRef.serializedKey = serializedKey\n\n // Check Registry FIRST\n if (serializedKey && globalRegistry.has(serializedKey)) {\n stateRef.container = globalRegistry.get(serializedKey)\n } else {\n let newContainer: any\n\n // 1. Function (Computed or Resource)\n if (typeof input === 'function') {\n const fn = input as Function\n\n const state = reactive({\n type: 'resource',\n value: undefined as T | undefined,\n loading: true,\n error: null as any,\n status: 'idle' as 'idle' | 'loading' | 'success' | 'error',\n run: () => { }\n })\n\n const run = () => {\n try {\n const result = fn()\n\n if (result instanceof Promise) {\n state.loading = true\n state.status = 'loading'\n state.error = null\n\n result\n .then(data => {\n state.value = data\n state.status = 'success'\n state.loading = false\n })\n .catch(err => {\n state.error = err\n state.status = 'error'\n state.loading = false\n })\n } else {\n state.value = result\n state.status = 'success'\n state.loading = false\n state.error = null\n }\n } catch (err) {\n state.error = err\n state.status = 'error'\n state.loading = false\n }\n }\n\n state.run = run\n\n // Make it reactive!\n unsafeEffect(run)\n\n newContainer = state\n\n } else {\n // 2. Value (Signal)\n // We return the reactive proxy itself as the container\n newContainer = reactive({\n type: 'signal',\n value: input\n })\n }\n\n // Register in global registry if needed\n if (serializedKey) {\n globalRegistry.set(serializedKey, newContainer)\n }\n\n stateRef.container = newContainer\n }\n }\n\n const container = stateRef.container\n\n // --- RETURN LOGIC ---\n // Access container.value to track dependency in the component's effect\n const currentValue = container.value\n\n if (container.type === 'signal') {\n const setter = (newValue: T | ((prev: T) => T)) => {\n if (typeof newValue === 'function') {\n container.value = (newValue as Function)(container.value)\n } else {\n container.value = newValue\n }\n }\n return [currentValue, setter]\n } else {\n // Resource / Computed\n const control = {\n refetch: async () => { container.run() },\n get loading() { return container.loading },\n get error() { return container.error },\n get status() { return container.status }\n }\n return [currentValue, control]\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkENWGYQNU_js=require('./chunk-ENWGYQNU.js');function p(n,a){let e=chunkENWGYQNU_js.h(()=>({cleanup:void 0,deps:void 0,effect:void 0,hasRun:false})),f=true;if(e.hasRun&&a&&e.deps&&(f=a.some((u,t)=>u!==e.deps[t])),f){e.cleanup&&(e.cleanup(),e.cleanup=void 0);let u=n();typeof u=="function"&&(e.cleanup=u),e.deps=a,e.hasRun=true;}}function h(n,a){let e=chunkENWGYQNU_js.h(()=>({value:void 0,deps:void 0,hasRun:false})),f=true;return e.hasRun&&a&&e.deps&&(f=a.some((u,t)=>u!==e.deps[t])),f&&(e.value=n(),e.deps=a,e.hasRun=true),e.value}function o(n){if(n){chunkENWGYQNU_js.e(true);try{n();}finally{chunkENWGYQNU_js.e(false),chunkENWGYQNU_js.d();}}else chunkENWGYQNU_js.d();}function v(n){o(n);}exports.a=p;exports.b=h;exports.c=o;exports.d=v;//# sourceMappingURL=chunk-C452JE6C.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-C452JE6C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/lifecycle.ts"],"names":["effect","fn","deps","state","hook","hasChanged","d","i","cleanup","memo","factory","sync","setBatching","flush","batch"],"mappings":"iEAGO,SAASA,CAAAA,CAAOC,CAAAA,CAAiCC,CAAAA,CAAc,CAElE,IAAMC,CAAAA,CAAQC,kBAAAA,CAAK,KAER,CACH,QAAS,MAAA,CACT,IAAA,CAAM,MAAA,CACN,MAAA,CAAQ,OACR,MAAA,CAAQ,KACZ,CAAA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AA,GACJ,CAAA,OAAE,CACEW,mBAAY,KAAK,CAAA,CACjBC,kBAAAA,GACJ,CACJ,CAAA,KACIA,kBAAAA,GAER,CAEO,SAASC,CAAAA,CAAMb,CAAAA,CAAgB,CAClCU,CAAAA,CAAKV,CAAE,EACX","file":"chunk-C452JE6C.js","sourcesContent":["import { hook } from './hook'\nimport { ReactiveEffect, flush, setBatching } from './effect'\n\nexport function effect(fn: () => (void | (() => void)), deps?: any[]) {\n // Use hook to store state across renders\n const state = hook(() => {\n // Initial State of the Hook (Runs once)\n return {\n cleanup: undefined as undefined | (() => void),\n deps: undefined as undefined | any[],\n effect: undefined as undefined | ReactiveEffect,\n hasRun: false\n }\n })\n\n // This runs on every render (update)\n\n // 1. Check dependencies\n let hasChanged = true\n if (state.hasRun && deps && state.deps) {\n hasChanged = deps.some((d, i) => d !== state.deps![i])\n }\n\n // 2. If changed, run effect\n if (hasChanged) {\n // Cleanup previous run\n if (state.cleanup) {\n state.cleanup()\n state.cleanup = undefined\n }\n\n // Run effect\n const cleanup = fn()\n if (typeof cleanup === 'function') {\n state.cleanup = cleanup\n }\n\n state.deps = deps\n state.hasRun = true\n }\n\n // Cleanup on component unmount logic is handled by the renderer via ComponentInstance context\n}\n\nexport function memo<T>(factory: () => T, deps?: any[]): T {\n const state = hook(() => ({\n value: undefined as undefined | T,\n deps: undefined as undefined | any[],\n hasRun: false\n }))\n\n let hasChanged = true\n if (state.hasRun && deps && state.deps) {\n hasChanged = deps.some((d, i) => d !== state.deps![i])\n }\n\n if (hasChanged) {\n state.value = factory()\n state.deps = deps\n state.hasRun = true\n }\n\n return state.value as T\n}\n\n/**\n * Unified sync API\n * - sync(): Force refresh (flush pending effects)\n * - sync(fn): Batch updates (run fn then flush)\n */\nexport function sync(fn?: () => void) {\n if (fn) {\n setBatching(true)\n try {\n fn()\n } finally {\n setBatching(false)\n flush()\n }\n } else {\n flush()\n }\n}\n\nexport function batch(fn: () => void) {\n sync(fn)\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a,c,f}from'./chunk-44RZHCII.mjs';var p=Symbol("flexium.reactive"),s=new WeakMap,l=new WeakMap;function M(e){if(e&&e[p])return e;let o=l.get(e);if(o)return o;let t=new Proxy(e,{get(n,r,i){if(r===p)return true;let c=Reflect.get(n,r,i);return b(n,r),c!==null&&typeof c=="object"?M(c):c},set(n,r,i,c){let x=n[r],a=Reflect.set(n,r,i,c);return a&&d(i,x)&&w(n,r),a}});return l.set(e,t),t}function b(e,o){if(!a)return;let t=s.get(e);t||s.set(e,t=new Map);let n=t.get(o);n||t.set(o,n=new Set),c(n);}function w(e,o){let t=s.get(e);if(!t)return;let n=t.get(o);n&&f(n);}function d(e,o){return !Object.is(e,o)}function T(e){return !!(e&&e[p])}export{M as a,T as b};//# sourceMappingURL=chunk-CPJRQL2C.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-CPJRQL2C.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/reactive.ts"],"names":["REACTIVE_SIGNAL","targetMap","reactiveMap","reactive","target","existingProxy","proxy","key","receiver","res","track","value","oldValue","result","hasChanged","trigger","activeEffect","depsMap","dep","trackEffect","triggerEffects","isReactive"],"mappings":"yCAEO,IAAMA,CAAAA,CAAkB,OAAO,kBAAkB,CAAA,CAIlDC,EAAY,IAAI,OAAA,CAGhBC,EAAc,IAAI,OAAA,CAEjB,SAASC,CAAAA,CAA2BC,CAAAA,CAAc,CACrD,GAAIA,CAAAA,EAAWA,EAAeJ,CAAe,CAAA,CACzC,OAAOI,CAAAA,CAGX,IAAMC,CAAAA,CAAgBH,EAAY,GAAA,CAAIE,CAAM,EAC5C,GAAIC,CAAAA,CACA,OAAOA,CAAAA,CAGX,IAAMC,CAAAA,CAAQ,IAAI,KAAA,CAAMF,CAAAA,CAAQ,CAC5B,GAAA,CAAIA,CAAAA,CAAQG,EAAKC,CAAAA,CAAU,CACvB,GAAID,CAAAA,GAAQP,CAAA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AAS,OAEd,IAAMC,CAAAA,CAAMD,CAAAA,CAAQ,IAAIV,CAAG,CAAA,CACvBW,CAAAA,EACAE,CAAAA,CAAeF,CAAG,EAE1B,CAEA,SAASJ,CAAAA,CAAWH,EAAYC,CAAAA,CAAwB,CACpD,OAAO,CAAC,MAAA,CAAO,EAAA,CAAGD,CAAAA,CAAOC,CAAQ,CACrC,CAEO,SAASS,CAAAA,CAAWV,EAAyB,CAChD,OAAO,CAAC,EAAEA,CAAAA,EAAUA,CAAAA,CAAcX,CAAe,CAAA,CACrD","file":"chunk-CPJRQL2C.mjs","sourcesContent":["import { activeEffect, trackEffect, triggerEffects } from './effect'\n\nexport const REACTIVE_SIGNAL = Symbol('flexium.reactive')\n\ntype Dep = Set<any>\ntype KeyToDepMap = Map<any, Dep>\nconst targetMap = new WeakMap<any, KeyToDepMap>()\n\n// WeakMap to store existing proxies to avoid duplicates\nconst reactiveMap = new WeakMap<object, any>()\n\nexport function reactive<T extends object>(target: T): T {\n if (target && (target as any)[REACTIVE_SIGNAL]) {\n return target\n }\n\n const existingProxy = reactiveMap.get(target)\n if (existingProxy) {\n return existingProxy\n }\n\n const proxy = new Proxy(target, {\n get(target, key, receiver) {\n if (key === REACTIVE_SIGNAL) return true\n\n const res = Reflect.get(target, key, receiver)\n\n track(target, key)\n\n if (res !== null && typeof res === 'object') {\n return reactive(res)\n }\n\n return res\n },\n set(target, key, value, receiver) {\n const oldValue = (target as any)[key]\n const result = Reflect.set(target, key, value, receiver)\n\n if (result && hasChanged(value, oldValue)) {\n trigger(target, key)\n }\n\n return result\n }\n })\n\n reactiveMap.set(target, proxy)\n return proxy\n}\n\nexport function track(target: object, key: unknown) {\n if (!activeEffect) return\n\n let depsMap = targetMap.get(target)\n if (!depsMap) {\n targetMap.set(target, (depsMap = new Map()))\n }\n\n let dep = depsMap.get(key)\n if (!dep) {\n depsMap.set(key, (dep = new Set()))\n }\n\n trackEffect(dep)\n}\n\nexport function trigger(target: object, key: unknown) {\n const depsMap = targetMap.get(target)\n if (!depsMap) return\n\n const dep = depsMap.get(key)\n if (dep) {\n triggerEffects(dep)\n }\n}\n\nfunction hasChanged(value: any, oldValue: any): boolean {\n return !Object.is(value, oldValue)\n}\n\nexport function isReactive(value: unknown): boolean {\n return !!(value && (value as any)[REACTIVE_SIGNAL])\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {h as h$1,e,d}from'./chunk-44RZHCII.mjs';function p(n,a){let e=h$1(()=>({cleanup:void 0,deps:void 0,effect:void 0,hasRun:false})),f=true;if(e.hasRun&&a&&e.deps&&(f=a.some((u,t)=>u!==e.deps[t])),f){e.cleanup&&(e.cleanup(),e.cleanup=void 0);let u=n();typeof u=="function"&&(e.cleanup=u),e.deps=a,e.hasRun=true;}}function h(n,a){let e=h$1(()=>({value:void 0,deps:void 0,hasRun:false})),f=true;return e.hasRun&&a&&e.deps&&(f=a.some((u,t)=>u!==e.deps[t])),f&&(e.value=n(),e.deps=a,e.hasRun=true),e.value}function o(n){if(n){e(true);try{n();}finally{e(false),d();}}else d();}function v(n){o(n);}export{p as a,h as b,o as c,v as d};//# sourceMappingURL=chunk-EJ7Z5OMU.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-EJ7Z5OMU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/lifecycle.ts"],"names":["effect","fn","deps","state","hook","hasChanged","d","i","cleanup","memo","factory","sync","setBatching","flush","batch"],"mappings":"gDAGO,SAASA,CAAAA,CAAOC,CAAAA,CAAiCC,CAAAA,CAAc,CAElE,IAAMC,CAAAA,CAAQC,GAAAA,CAAK,KAER,CACH,QAAS,MAAA,CACT,IAAA,CAAM,MAAA,CACN,MAAA,CAAQ,OACR,MAAA,CAAQ,KACZ,CAAA,CACH,CAAA,CAKGC,CAAAA,CAAa,IAAA,CAMjB,GALIF,CAAAA,CAAM,QAAUD,CAAAA,EAAQC,CAAAA,CAAM,IAAA,GAC9BE,CAAAA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CAAAA,CAAgB,CAClCU,CAAAA,CAAKV,CAAE,EACX","file":"chunk-EJ7Z5OMU.mjs","sourcesContent":["import { hook } from './hook'\nimport { ReactiveEffect, flush, setBatching } from './effect'\n\nexport function effect(fn: () => (void | (() => void)), deps?: any[]) {\n // Use hook to store state across renders\n const state = hook(() => {\n // Initial State of the Hook (Runs once)\n return {\n cleanup: undefined as undefined | (() => void),\n deps: undefined as undefined | any[],\n effect: undefined as undefined | ReactiveEffect,\n hasRun: false\n }\n })\n\n // This runs on every render (update)\n\n // 1. Check dependencies\n let hasChanged = true\n if (state.hasRun && deps && state.deps) {\n hasChanged = deps.some((d, i) => d !== state.deps![i])\n }\n\n // 2. If changed, run effect\n if (hasChanged) {\n // Cleanup previous run\n if (state.cleanup) {\n state.cleanup()\n state.cleanup = undefined\n }\n\n // Run effect\n const cleanup = fn()\n if (typeof cleanup === 'function') {\n state.cleanup = cleanup\n }\n\n state.deps = deps\n state.hasRun = true\n }\n\n // Cleanup on component unmount logic is handled by the renderer via ComponentInstance context\n}\n\nexport function memo<T>(factory: () => T, deps?: any[]): T {\n const state = hook(() => ({\n value: undefined as undefined | T,\n deps: undefined as undefined | any[],\n hasRun: false\n }))\n\n let hasChanged = true\n if (state.hasRun && deps && state.deps) {\n hasChanged = deps.some((d, i) => d !== state.deps![i])\n }\n\n if (hasChanged) {\n state.value = factory()\n state.deps = deps\n state.hasRun = true\n }\n\n return state.value as T\n}\n\n/**\n * Unified sync API\n * - sync(): Force refresh (flush pending effects)\n * - sync(fn): Batch updates (run fn then flush)\n */\nexport function sync(fn?: () => void) {\n if (fn) {\n setBatching(true)\n try {\n fn()\n } finally {\n setBatching(false)\n flush()\n }\n } else {\n flush()\n }\n}\n\nexport function batch(fn: () => void) {\n sync(fn)\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';exports.a=void 0;var r=class{constructor(t,n){this.fn=t;this.scheduler=n;this.deps=[];this.active=true;}run(){if(!this.active)return this.fn();let t=exports.a;try{return this.cleanup(),exports.a=this,this.fn()}finally{exports.a=t;}}stop(){this.active&&(this.cleanup(),this.active=false);}cleanup(){let{deps:t}=this;if(t.length){for(let n=0;n<t.length;n++)t[n].delete(this);t.length=0;}}};function p(e,t={}){let n=new r(e,t.scheduler);n.run();let c=n.run.bind(n);return c.effect=n,c}function d(e){exports.a&&(e.add(exports.a),exports.a.deps.push(e));}var i=new Set,s=false,a=false;function l(e){i.has(e)||(i.add(e),!s&&!a&&(s=true,Promise.resolve().then(h)));}function h(){s=false;let e=[...i];i.clear();for(let t of e)t.active&&t.run();}function v(e){a=e;}function x(e){let t=[...e];for(let n of t)n!==exports.a&&(n.scheduler?n.scheduler():l(n));}var f=null;function g(e,t){let n=f;f=e,e.hookIndex=0;try{return t()}finally{f=n;}}function k(e){if(!f)return e();let t=f,{hooks:n,hookIndex:c}=t;if(c<n.length)return t.hookIndex++,n[c];let u=e();return n.push(u),t.hookIndex++,u}exports.b=p;exports.c=d;exports.d=h;exports.e=v;exports.f=x;exports.g=g;exports.h=k;//# sourceMappingURL=chunk-ENWGYQNU.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-ENWGYQNU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/effect.ts","../src/core/hook.ts"],"names":["activeEffect","ReactiveEffectLike","fn","scheduler","parent","deps","i","unsafeEffect","options","_effect","runner","trackEffect","dep","queue","isFlushPending","isBatching","queueJob","effect","flush","effects","setBatching","value","triggerEffects","currentComponent","runWithComponent","component","prev","hook","factory","instance","hooks","hookIndex"],"mappings":"aAAWA,gBAAAA,KAEEC,CAAAA,CAAN,KAAyB,CAI5B,YACWC,CAAAA,CACAC,CAAAA,CACT,CAFS,IAAA,CAAA,EAAA,CAAAD,CAAAA,CACA,IAAA,CAAA,SAAA,CAAAC,CAAAA,CALX,IAAA,CAAA,IAAA,CAAmB,EAAC,CACpB,IAAA,CAAA,MAAA,CAAS,KAKL,CAEJ,GAAA,EAAM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A,CAAAC,CAAU,CAAA,CAAIF,CAAAA,CAE7B,GAAIE,EAAYD,CAAAA,CAAM,MAAA,CAElB,OAAAD,CAAAA,CAAS,SAAA,EAAA,CACFC,CAAAA,CAAMC,CAAS,CAAA,CAI1B,IAAMV,CAAAA,CAAQO,CAAAA,EAAQ,CACtB,OAAAE,EAAM,IAAA,CAAKT,CAAK,CAAA,CAChBQ,CAAAA,CAAS,YAEFR,CACX","file":"chunk-ENWGYQNU.js","sourcesContent":["export let activeEffect: ReactiveEffect | undefined\n\nexport class ReactiveEffectLike {\n deps: Set<any>[] = []\n active = true\n\n constructor(\n public fn: () => void,\n public scheduler?: () => void\n ) { }\n\n run() {\n if (!this.active) {\n return this.fn()\n }\n\n let parent: ReactiveEffect | undefined = activeEffect\n try {\n this.cleanup()\n activeEffect = this\n return this.fn()\n } finally {\n activeEffect = parent\n }\n }\n\n stop() {\n if (this.active) {\n this.cleanup()\n this.active = false\n }\n }\n\n cleanup() {\n const { deps } = this\n if (deps.length) {\n for (let i = 0; i < deps.length; i++) {\n deps[i].delete(this)\n }\n deps.length = 0\n }\n }\n}\n\nexport type ReactiveEffect = ReactiveEffectLike\n\nexport function unsafeEffect(fn: () => void, options: { scheduler?: () => void } = {}) {\n const _effect = new ReactiveEffectLike(fn, options.scheduler)\n _effect.run()\n\n const runner: any = _effect.run.bind(_effect)\n runner.effect = _effect\n return runner\n}\n\nexport function trackEffect(dep: Set<ReactiveEffect>) {\n if (activeEffect) {\n dep.add(activeEffect)\n activeEffect.deps.push(dep)\n }\n}\n\nconst queue = new Set<ReactiveEffect>()\nlet isFlushPending = false\nlet isBatching = false\n\nexport function queueJob(effect: ReactiveEffect) {\n if (!queue.has(effect)) {\n queue.add(effect)\n if (!isFlushPending && !isBatching) {\n isFlushPending = true\n Promise.resolve().then(flush)\n }\n }\n}\n\nexport function flush() {\n isFlushPending = false\n const effects = [...queue]\n queue.clear()\n for (const effect of effects) {\n if (effect.active) {\n effect.run()\n }\n }\n}\n\nexport function setBatching(value: boolean) {\n isBatching = value\n}\n\nexport function triggerEffects(dep: Set<ReactiveEffect>) {\n const effects = [...dep]\n for (const effect of effects) {\n if (effect !== activeEffect) {\n if (effect.scheduler) {\n effect.scheduler()\n } else {\n queueJob(effect)\n }\n }\n }\n}\n","\nexport interface ComponentInstance {\n hooks: any[]\n hookIndex: number\n}\n\nlet currentComponent: ComponentInstance | null = null\n\nexport function getComponent(): ComponentInstance | null {\n return currentComponent\n}\n\nexport function runWithComponent<T>(component: ComponentInstance, fn: () => T): T {\n const prev = currentComponent\n currentComponent = component\n component.hookIndex = 0\n try {\n return fn()\n } finally {\n currentComponent = prev\n }\n}\n\nexport function hook<T>(factory: () => T): T {\n if (!currentComponent) {\n // Outside component: just run factory\n return factory()\n }\n\n const instance = currentComponent\n const { hooks, hookIndex } = instance\n\n if (hookIndex < hooks.length) {\n // Return existing hook\n instance.hookIndex++\n return hooks[hookIndex] as T\n }\n\n // Create new hook\n const value = factory()\n hooks.push(value)\n instance.hookIndex++\n\n return value\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';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}exports.a=i;exports.b=a;exports.c=d;//# sourceMappingURL=chunk-EXLNKYSH.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-EXLNKYSH.js.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-EXLNKYSH.js","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"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=new Map;function c(t){let n=Symbol("context"),o=r=>r.children;return o._contextId=n,{Provider:o,id:n,defaultValue:t}}function s(t){return e.has(t.id)?e.get(t.id):t.defaultValue}function l(t,n){let o=e.get(t);return e.set(t,n),o}function p(t,n){n===void 0?e.delete(t):e.set(t,n);}function u(){return new Map(e)}function i(t,n){let o=new Map(e);e.clear(),t.forEach((r,a)=>e.set(a,r));try{return n()}finally{e.clear(),o.forEach((r,a)=>e.set(a,r));}}export{c as a,s as b,l as c,p as d,u as e,i as f};//# sourceMappingURL=chunk-LUREDEUB.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-LUREDEUB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/context.ts"],"names":["contextMap","createContext","defaultValue","id","Provider","props","context","ctx","pushContext","value","prev","popContext","prevValue","snapshotContext","runWithContext","snapshot","fn","prevContext","key"],"mappings":"AAMA,IAAMA,CAAAA,CAAa,IAAI,GAAA,CAEhB,SAASC,CAAAA,CAAiBC,CAAAA,CAA6B,CAC1D,IAAMC,CAAAA,CAAK,MAAA,CAAO,SAAS,CAAA,CACrBC,EAAYC,CAAAA,EAAuCA,CAAAA,CAAM,QAAA,CAC/D,OAACD,CAAAA,CAAiB,UAAA,CAAaD,CAAAA,CACxB,CAAE,SAAAC,CAAAA,CAAU,EAAA,CAAAD,CAAAA,CAAI,YAAA,CAAAD,CAAa,CACxC,CAEO,SAASI,EAAWC,CAAAA,CAAoB,CAC3C,OAAOP,CAAAA,CAAW,GAAA,CAAIO,CAAAA,CAAI,EAAE,CAAA,CAAIP,EAAW,GAAA,CAAIO,CAAAA,CAAI,EAAE,CAAA,CAAIA,CAAAA,CAAI,YACjE,CAGO,SAASC,EAAYL,CAAAA,CAAYM,CAAAA,CAAY,CAChD,IAAMC,CAAAA,CAAOV,CAAAA,CAAW,GAAA,CAAIG,CAAE,EAC9B,OAAAH,CAAAA,CAAW,GAAA,CAAIG,CAAAA,CAAIM,CAAK,CAAA,CACjBC,CACX,CAGO,SAASC,CAAAA,CAAWR,CAAAA,CAAYS,CAAAA,CAAgB,CAC/CA,CAAAA,GAAc,MAAA,CACdZ,CAAAA,CAAW,MAAA,CAAOG,CAAE,CAAA,CAEpBH,CAAAA,CAAW,GAAA,CAAIG,CAAAA,CAAIS,CAAS,EAEpC,CAEO,SAASC,CAAAA,EAAoC,CAChD,OAAO,IAAI,GAAA,CAAIb,CAAU,CAC7B,CAEO,SAASc,CAAAA,CAAkBC,CAAAA,CAA4BC,CAAAA,CAAgB,CAE1E,IAAMC,CAAAA,CAAc,IAAI,GAAA,CAAIjB,CAAU,CAAA,CAGtCA,CAAAA,CAAW,KAAA,EAAM,CACjBe,CAAAA,CAAS,OAAA,CAAQ,CAACN,CAAAA,CAAOS,IAAQlB,CAAAA,CAAW,GAAA,CAAIkB,CAAAA,CAAKT,CAAK,CAAC,CAAA,CAE3D,GAAI,CACA,OAAOO,CAAAA,EACX,CAAA,OAAE,CAEEhB,CAAAA,CAAW,KAAA,EAAM,CACjBiB,CAAAA,CAAY,QAAQ,CAACR,CAAAA,CAAOS,CAAAA,GAAQlB,CAAAA,CAAW,GAAA,CAAIkB,CAAAA,CAAKT,CAAK,CAAC,EAClE,CACJ","file":"chunk-LUREDEUB.mjs","sourcesContent":["export interface Context<T> {\n Provider: (props: { value: T; children: any }) => any\n id: symbol\n defaultValue: T\n}\n\nconst contextMap = new Map<symbol, any>()\n\nexport function createContext<T>(defaultValue: T): Context<T> {\n const id = Symbol('context')\n const Provider = (props: { value: T; children: any }) => props.children;\n (Provider as any)._contextId = id\n return { Provider, id, defaultValue }\n}\n\nexport function context<T>(ctx: Context<T>): T {\n return contextMap.has(ctx.id) ? contextMap.get(ctx.id) : ctx.defaultValue\n}\n\n// Internal helpers for renderer\nexport function pushContext(id: symbol, value: any) {\n const prev = contextMap.get(id)\n contextMap.set(id, value)\n return prev\n}\n\n\nexport function popContext(id: symbol, prevValue: any) {\n if (prevValue === undefined) {\n contextMap.delete(id)\n } else {\n contextMap.set(id, prevValue)\n }\n}\n\nexport function snapshotContext(): Map<symbol, any> {\n return new Map(contextMap)\n}\n\nexport function runWithContext<R>(snapshot: Map<symbol, any>, fn: () => R): R {\n // 1. Save current context\n const prevContext = new Map(contextMap)\n\n // 2. Apply snapshot\n contextMap.clear()\n snapshot.forEach((value, key) => contextMap.set(key, value))\n\n try {\n return fn()\n } finally {\n // 3. Restore previous context\n contextMap.clear()\n prevContext.forEach((value, key) => contextMap.set(key, value))\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var e=new Map;function c(t){let n=Symbol("context"),o=r=>r.children;return o._contextId=n,{Provider:o,id:n,defaultValue:t}}function s(t){return e.has(t.id)?e.get(t.id):t.defaultValue}function l(t,n){let o=e.get(t);return e.set(t,n),o}function p(t,n){n===void 0?e.delete(t):e.set(t,n);}function u(){return new Map(e)}function i(t,n){let o=new Map(e);e.clear(),t.forEach((r,a)=>e.set(a,r));try{return n()}finally{e.clear(),o.forEach((r,a)=>e.set(a,r));}}exports.a=c;exports.b=s;exports.c=l;exports.d=p;exports.e=u;exports.f=i;//# sourceMappingURL=chunk-LUW7DIEW.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-LUW7DIEW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/context.ts"],"names":["contextMap","createContext","defaultValue","id","Provider","props","context","ctx","pushContext","value","prev","popContext","prevValue","snapshotContext","runWithContext","snapshot","fn","prevContext","key"],"mappings":"aAMA,IAAMA,CAAAA,CAAa,IAAI,GAAA,CAEhB,SAASC,CAAAA,CAAiBC,CAAAA,CAA6B,CAC1D,IAAMC,CAAAA,CAAK,MAAA,CAAO,SAAS,CAAA,CACrBC,EAAYC,CAAAA,EAAuCA,CAAAA,CAAM,QAAA,CAC/D,OAACD,CAAAA,CAAiB,UAAA,CAAaD,CAAAA,CACxB,CAAE,SAAAC,CAAAA,CAAU,EAAA,CAAAD,CAAAA,CAAI,YAAA,CAAAD,CAAa,CACxC,CAEO,SAASI,EAAWC,CAAAA,CAAoB,CAC3C,OAAOP,CAAAA,CAAW,GAAA,CAAIO,CAAAA,CAAI,EAAE,CAAA,CAAIP,EAAW,GAAA,CAAIO,CAAAA,CAAI,EAAE,CAAA,CAAIA,CAAAA,CAAI,YACjE,CAGO,SAASC,EAAYL,CAAAA,CAAYM,CAAAA,CAAY,CAChD,IAAMC,CAAAA,CAAOV,CAAAA,CAAW,GAAA,CAAIG,CAAE,EAC9B,OAAAH,CAAAA,CAAW,GAAA,CAAIG,CAAAA,CAAIM,CAAK,CAAA,CACjBC,CACX,CAGO,SAASC,CAAAA,CAAWR,CAAAA,CAAYS,CAAAA,CAAgB,CAC/CA,CAAAA,GAAc,MAAA,CACdZ,CAAAA,CAAW,MAAA,CAAOG,CAAE,CAAA,CAEpBH,CAAAA,CAAW,GAAA,CAAIG,CAAAA,CAAIS,CAAS,EAEpC,CAEO,SAASC,CAAAA,EAAoC,CAChD,OAAO,IAAI,GAAA,CAAIb,CAAU,CAC7B,CAEO,SAASc,CAAAA,CAAkBC,CAAAA,CAA4BC,CAAAA,CAAgB,CAE1E,IAAMC,CAAAA,CAAc,IAAI,GAAA,CAAIjB,CAAU,CAAA,CAGtCA,CAAAA,CAAW,KAAA,EAAM,CACjBe,CAAAA,CAAS,OAAA,CAAQ,CAACN,CAAAA,CAAOS,IAAQlB,CAAAA,CAAW,GAAA,CAAIkB,CAAAA,CAAKT,CAAK,CAAC,CAAA,CAE3D,GAAI,CACA,OAAOO,CAAAA,EACX,CAAA,OAAE,CAEEhB,CAAAA,CAAW,KAAA,EAAM,CACjBiB,CAAAA,CAAY,QAAQ,CAACR,CAAAA,CAAOS,CAAAA,GAAQlB,CAAAA,CAAW,GAAA,CAAIkB,CAAAA,CAAKT,CAAK,CAAC,EAClE,CACJ","file":"chunk-LUW7DIEW.js","sourcesContent":["export interface Context<T> {\n Provider: (props: { value: T; children: any }) => any\n id: symbol\n defaultValue: T\n}\n\nconst contextMap = new Map<symbol, any>()\n\nexport function createContext<T>(defaultValue: T): Context<T> {\n const id = Symbol('context')\n const Provider = (props: { value: T; children: any }) => props.children;\n (Provider as any)._contextId = id\n return { Provider, id, defaultValue }\n}\n\nexport function context<T>(ctx: Context<T>): T {\n return contextMap.has(ctx.id) ? contextMap.get(ctx.id) : ctx.defaultValue\n}\n\n// Internal helpers for renderer\nexport function pushContext(id: symbol, value: any) {\n const prev = contextMap.get(id)\n contextMap.set(id, value)\n return prev\n}\n\n\nexport function popContext(id: symbol, prevValue: any) {\n if (prevValue === undefined) {\n contextMap.delete(id)\n } else {\n contextMap.set(id, prevValue)\n }\n}\n\nexport function snapshotContext(): Map<symbol, any> {\n return new Map(contextMap)\n}\n\nexport function runWithContext<R>(snapshot: Map<symbol, any>, fn: () => R): R {\n // 1. Save current context\n const prevContext = new Map(contextMap)\n\n // 2. Apply snapshot\n contextMap.clear()\n snapshot.forEach((value, key) => contextMap.set(key, value))\n\n try {\n return fn()\n } finally {\n // 3. Restore previous context\n contextMap.clear()\n prevContext.forEach((value, key) => contextMap.set(key, value))\n }\n}\n"]}
|