flexium 0.12.19 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +26 -25
  2. package/dist/advanced.d.cts +5 -0
  3. package/dist/advanced.d.ts +5 -0
  4. package/dist/advanced.js +2 -0
  5. package/dist/advanced.js.map +1 -0
  6. package/dist/advanced.mjs +2 -0
  7. package/dist/advanced.mjs.map +1 -0
  8. package/dist/canvas.d.cts +1 -1
  9. package/dist/canvas.d.ts +1 -1
  10. package/dist/canvas.js +1 -1
  11. package/dist/canvas.js.map +1 -1
  12. package/dist/canvas.mjs +1 -1
  13. package/dist/canvas.mjs.map +1 -1
  14. package/dist/chunk-3CKIHQIE.js +2 -0
  15. package/dist/chunk-3CKIHQIE.js.map +1 -0
  16. package/dist/{chunk-PSKDIB7J.js → chunk-CGB4YXKS.js} +2 -2
  17. package/dist/chunk-CGB4YXKS.js.map +1 -0
  18. package/dist/chunk-INJXOHFD.mjs +2 -0
  19. package/dist/chunk-INJXOHFD.mjs.map +1 -0
  20. package/dist/{chunk-E75BJDOQ.mjs → chunk-JUP6RTZA.mjs} +2 -2
  21. package/dist/{chunk-E75BJDOQ.mjs.map → chunk-JUP6RTZA.mjs.map} +1 -1
  22. package/dist/{chunk-3DKZ2J4D.mjs → chunk-NDPEE2TQ.mjs} +2 -2
  23. package/dist/chunk-NDPEE2TQ.mjs.map +1 -0
  24. package/dist/chunk-NRPWBHKP.mjs +2 -0
  25. package/dist/chunk-NRPWBHKP.mjs.map +1 -0
  26. package/dist/chunk-W2L7BLE7.js +2 -0
  27. package/dist/chunk-W2L7BLE7.js.map +1 -0
  28. package/dist/{chunk-6Z33DLMI.js → chunk-X6HXRSMG.js} +2 -2
  29. package/dist/{chunk-6Z33DLMI.js.map → chunk-X6HXRSMG.js.map} +1 -1
  30. package/dist/core.d.cts +18 -74
  31. package/dist/core.d.ts +18 -74
  32. package/dist/core.js +1 -1
  33. package/dist/core.js.map +1 -1
  34. package/dist/core.mjs +1 -1
  35. package/dist/core.mjs.map +1 -1
  36. package/dist/dom.d.cts +1 -1
  37. package/dist/dom.d.ts +1 -1
  38. package/dist/dom.js +1 -1
  39. package/dist/dom.js.map +1 -1
  40. package/dist/dom.mjs +1 -1
  41. package/dist/dom.mjs.map +1 -1
  42. package/dist/index.d.cts +1 -1
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.js +1 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/index.mjs +1 -1
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/interactive.d.cts +2 -2
  49. package/dist/interactive.d.ts +2 -2
  50. package/dist/interactive.js +1 -1
  51. package/dist/interactive.js.map +1 -1
  52. package/dist/interactive.mjs +1 -1
  53. package/dist/interactive.mjs.map +1 -1
  54. package/dist/jsx-dev-runtime.d.cts +1 -1
  55. package/dist/jsx-dev-runtime.d.ts +1 -1
  56. package/dist/jsx-runtime.d.cts +1 -1
  57. package/dist/jsx-runtime.d.ts +1 -1
  58. package/dist/metafile-cjs.json +1 -1
  59. package/dist/metafile-esm.json +1 -1
  60. package/dist/render-L57MA662.mjs +2 -0
  61. package/dist/{render-UIWHIMS2.mjs.map → render-L57MA662.mjs.map} +1 -1
  62. package/dist/render-VERKNIPR.js +2 -0
  63. package/dist/{render-QZAFAGIM.js.map → render-VERKNIPR.js.map} +1 -1
  64. package/dist/router.d.cts +7 -3
  65. package/dist/router.d.ts +7 -3
  66. package/dist/router.js +1 -1
  67. package/dist/router.js.map +1 -1
  68. package/dist/router.mjs +1 -1
  69. package/dist/router.mjs.map +1 -1
  70. package/dist/server.d.cts +1 -1
  71. package/dist/server.d.ts +1 -1
  72. package/dist/server.js +1 -1
  73. package/dist/server.mjs +1 -1
  74. package/dist/types--emg3Tgw.d.cts +10 -0
  75. package/dist/types--emg3Tgw.d.ts +10 -0
  76. package/dist/{types-y2GGaXXk.d.cts → types-DH8L3A5z.d.cts} +1 -1
  77. package/dist/{types-y2GGaXXk.d.ts → types-DH8L3A5z.d.ts} +1 -1
  78. package/package.json +6 -1
  79. package/dist/chunk-3DKZ2J4D.mjs.map +0 -1
  80. package/dist/chunk-6VIRXD2Y.js +0 -2
  81. package/dist/chunk-6VIRXD2Y.js.map +0 -1
  82. package/dist/chunk-IWFEXW4F.mjs +0 -2
  83. package/dist/chunk-IWFEXW4F.mjs.map +0 -1
  84. package/dist/chunk-JY6CE6RN.mjs +0 -2
  85. package/dist/chunk-JY6CE6RN.mjs.map +0 -1
  86. package/dist/chunk-LTT43APF.js +0 -2
  87. package/dist/chunk-LTT43APF.js.map +0 -1
  88. package/dist/chunk-PSKDIB7J.js.map +0 -1
  89. package/dist/chunk-WGKD63GN.mjs +0 -2
  90. package/dist/chunk-WGKD63GN.mjs.map +0 -1
  91. package/dist/chunk-YWTD32NA.js +0 -2
  92. package/dist/chunk-YWTD32NA.js.map +0 -1
  93. package/dist/render-QZAFAGIM.js +0 -2
  94. package/dist/render-UIWHIMS2.mjs +0 -2
package/README.md CHANGED
@@ -6,11 +6,11 @@
6
6
 
7
7
  **Simpler, Faster, Unified.**
8
8
 
9
- Flexium is a next-generation UI framework that unifies state management, async data fetching, and global state into a single, powerful API: `state()`.
9
+ Flexium is a next-generation UI framework that unifies state management, async data fetching, and global state into a single, powerful API: `use()`.
10
10
 
11
11
  ## Key Features
12
12
 
13
- - **Unified State API** - No more `useState`, `useRecoil`, `useQuery` separation. Just `state()`.
13
+ - **Unified State API** - No more `useRecoil`, `useQuery` separation. Just `use()`.
14
14
  - **No Virtual DOM** - Direct DOM updates via Proxy-based fine-grained reactivity.
15
15
  - **Tiny Bundle** - Minimal footprint with tree-shaking support.
16
16
  - **Cross-Platform** - DOM, Canvas, Server (SSR) renderers included.
@@ -32,18 +32,18 @@ npm install
32
32
  npm run dev
33
33
  ```
34
34
 
35
- ## The Only API You Need: `state()`
35
+ ## The Only API You Need: `use()`
36
36
 
37
37
  Flexium unifies all state concepts into one function.
38
38
 
39
39
  ### Local State
40
40
 
41
41
  ```tsx
42
- import { state } from 'flexium/core'
42
+ import { use } from 'flexium/core'
43
43
  import { render } from 'flexium/dom'
44
44
 
45
45
  function Counter() {
46
- const [count, setCount] = state(0)
46
+ const [count, setCount] = use(0)
47
47
 
48
48
  return (
49
49
  <button onclick={() => setCount(c => c + 1)}>
@@ -61,11 +61,11 @@ Just add a `key` to share state across components. Keys can be strings or arrays
61
61
 
62
62
  ```tsx
63
63
  // Define global state with array key
64
- const [theme, setTheme] = state('light', { key: ['app', 'theme'] })
64
+ const [theme, setTheme] = use('light', { key: ['app', 'theme'] })
65
65
 
66
66
  function ThemeToggle() {
67
67
  // Access same state anywhere with the same key
68
- const [theme, setTheme] = state('light', { key: ['app', 'theme'] })
68
+ const [theme, setTheme] = use('light', { key: ['app', 'theme'] })
69
69
 
70
70
  return (
71
71
  <button onclick={() => setTheme(t => t === 'light' ? 'dark' : 'light')}>
@@ -81,7 +81,7 @@ Pass an async function to handle data fetching automatically.
81
81
 
82
82
  ```tsx
83
83
  function UserProfile({ id }) {
84
- const [user, control] = state(async () => {
84
+ const [user, control] = use(async () => {
85
85
  const res = await fetch(`/api/users/${id}`)
86
86
  return res.json()
87
87
  })
@@ -101,21 +101,21 @@ function UserProfile({ id }) {
101
101
  ### Computed/Derived State
102
102
 
103
103
  ```tsx
104
- const [count, setCount] = state(1)
105
- const [doubled] = state(() => count * 2, { deps: [count] })
104
+ const [count, setCount] = use(1)
105
+ const [doubled] = use(() => count * 2, [count])
106
106
  ```
107
107
 
108
108
  ## Package Structure
109
109
 
110
110
  ```
111
111
  flexium
112
- ├── /core # Core reactivity: state(), effect(), sync(), context()
112
+ ├── /core # Core reactivity: use(), sync(), createContext()
113
113
  ├── /dom # DOM renderer: render(), hydrate(), Portal, Suspense
114
- ├── /ref # Ref system: ref(), forwardRef()
115
- ├── /router # SPA routing: Routes, Route, Link, Outlet
114
+ ├── /ref # Ref system: useRef(), forwardRef()
115
+ ├── /router # SPA routing: Routes, Route, Link, Outlet, useRouter(), useLocation()
116
116
  ├── /server # SSR: renderToString(), renderToStaticMarkup()
117
117
  ├── /canvas # Canvas 2D: Canvas, DrawRect, DrawCircle, DrawText
118
- └── /interactive # Game loop: loop(), keyboard(), mouse()
118
+ └── /interactive # Game loop: useLoop(), keyboard(), mouse()
119
119
  ```
120
120
 
121
121
  ## Control Flow
@@ -136,7 +136,7 @@ Use native JavaScript for control flow - no special components needed:
136
136
  ## Routing
137
137
 
138
138
  ```tsx
139
- import { Routes, Route, Link, router } from 'flexium/router'
139
+ import { Routes, Route, Link, useRouter } from 'flexium/router'
140
140
 
141
141
  function App() {
142
142
  return (
@@ -158,7 +158,7 @@ function UserProfile({ params }) {
158
158
 
159
159
  // Or use the router hook
160
160
  function UserProfileHook() {
161
- const r = router()
161
+ const r = useRouter()
162
162
  return <h1>User: {r.params.id}</h1>
163
163
  }
164
164
  ```
@@ -167,9 +167,10 @@ function UserProfileHook() {
167
167
 
168
168
  ```tsx
169
169
  import { Canvas, DrawRect, DrawCircle, DrawText } from 'flexium/canvas'
170
+ import { use } from 'flexium/core'
170
171
 
171
172
  function App() {
172
- const [x, setX] = state(100)
173
+ const [x, setX] = use(100)
173
174
 
174
175
  return (
175
176
  <Canvas width={400} height={300}>
@@ -184,15 +185,15 @@ function App() {
184
185
  ## Game Development
185
186
 
186
187
  ```tsx
187
- import { state, effect } from 'flexium/core'
188
+ import { use } from 'flexium/core'
188
189
  import { Canvas, DrawRect } from 'flexium/canvas'
189
- import { loop, keyboard, Keys } from 'flexium/interactive'
190
+ import { useLoop, keyboard, Keys } from 'flexium/interactive'
190
191
 
191
192
  function Game() {
192
- const [x, setX] = state(100)
193
+ const [x, setX] = use(100)
193
194
  const kb = keyboard()
194
195
 
195
- const gameLoop = loop({
196
+ const gameLoop = useLoop({
196
197
  fixedFps: 60,
197
198
  onUpdate: (delta) => {
198
199
  if (kb.isPressed(Keys.ArrowRight)) setX(x => x + 200 * delta)
@@ -200,9 +201,9 @@ function Game() {
200
201
  }
201
202
  })
202
203
 
203
- effect(() => {
204
+ use(({ onCleanup }) => {
204
205
  gameLoop.start()
205
- return () => gameLoop.stop()
206
+ onCleanup(() => gameLoop.stop())
206
207
  }, [])
207
208
 
208
209
  return (
@@ -263,7 +264,7 @@ import { ErrorBoundary } from 'flexium/dom'
263
264
  ## Context API
264
265
 
265
266
  ```tsx
266
- import { createContext, context } from 'flexium/core'
267
+ import { use, createContext } from 'flexium/core'
267
268
 
268
269
  const ThemeCtx = createContext('light')
269
270
 
@@ -276,7 +277,7 @@ function App() {
276
277
  }
277
278
 
278
279
  function Child() {
279
- const theme = context(ThemeCtx)
280
+ const [theme] = use(ThemeCtx)
280
281
  return <div>Theme: {theme}</div>
281
282
  }
282
283
  ```
@@ -0,0 +1,5 @@
1
+ import { C as Context } from './types--emg3Tgw.cjs';
2
+
3
+ declare function createContext<T>(defaultValue: T): Context<T>;
4
+
5
+ export { Context, createContext };
@@ -0,0 +1,5 @@
1
+ import { C as Context } from './types--emg3Tgw.js';
2
+
3
+ declare function createContext<T>(defaultValue: T): Context<T>;
4
+
5
+ export { Context, createContext };
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkCGB4YXKS_js=require('./chunk-CGB4YXKS.js');Object.defineProperty(exports,"createContext",{enumerable:true,get:function(){return chunkCGB4YXKS_js.a}});//# sourceMappingURL=advanced.js.map
2
+ //# sourceMappingURL=advanced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"advanced.js"}
@@ -0,0 +1,2 @@
1
+ export{a as createContext}from'./chunk-NDPEE2TQ.mjs';//# sourceMappingURL=advanced.mjs.map
2
+ //# sourceMappingURL=advanced.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"advanced.mjs"}
package/dist/canvas.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { JSX } from './jsx-runtime.cjs';
2
- import './types-y2GGaXXk.cjs';
2
+ import './types-DH8L3A5z.cjs';
3
3
 
4
4
  interface CanvasProps {
5
5
  width: number;
package/dist/canvas.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { JSX } from './jsx-runtime.js';
2
- import './types-y2GGaXXk.js';
2
+ import './types-DH8L3A5z.js';
3
3
 
4
4
  interface CanvasProps {
5
5
  width: number;
package/dist/canvas.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk6VIRXD2Y_js=require('./chunk-6VIRXD2Y.js'),chunkYWTD32NA_js=require('./chunk-YWTD32NA.js');require('./chunk-UWFVCKRU.js');var chunkDUGPBZZ3_js=require('./chunk-DUGPBZZ3.js');var D=[];function l(t){D.push(t);}function C(t){let{width:u,height:w,children:e,style:y,ref:a}=t,s,n=null,i=()=>{!s||!n||(n.clearRect(0,0,u,w),D.length=0,Array.isArray(e)?e.forEach(o=>{typeof o=="function"&&o();}):typeof e=="function"&&e(),D.forEach(o=>{g(n,o);}),null);};return chunkYWTD32NA_js.e(()=>{s&&i();}),chunkDUGPBZZ3_js.a("canvas",{ref:o=>{s=o,n=o.getContext("2d"),a&&a(o),i();},width:u,height:w,style:y})}function r(t){return chunk6VIRXD2Y_js.b(t)?t.valueOf?.()??t:t}function g(t,u){let{type:w,props:e}=u,y=r(e.opacity);switch(y!==void 0&&(t.globalAlpha=y),w){case "rect":{let a=r(e.x),s=r(e.y),n=r(e.width),i=r(e.height),o=r(e.fill),f=r(e.stroke),c=r(e.strokeWidth);o&&(t.fillStyle=o,t.fillRect(a,s,n,i)),f&&(t.strokeStyle=f,c&&(t.lineWidth=c),t.strokeRect(a,s,n,i));break}case "circle":{let a=r(e.x),s=r(e.y),n=r(e.radius),i=r(e.fill),o=r(e.stroke),f=r(e.strokeWidth);t.beginPath(),t.arc(a,s,n,0,Math.PI*2),i&&(t.fillStyle=i,t.fill()),o&&(t.strokeStyle=o,f&&(t.lineWidth=f),t.stroke());break}case "arc":{let a=r(e.x),s=r(e.y),n=r(e.radius),i=r(e.startAngle),o=r(e.endAngle),f=r(e.counterclockwise)||false,c=r(e.fill),m=r(e.stroke),h=r(e.strokeWidth);t.beginPath(),t.arc(a,s,n,i,o,f),c&&(t.fillStyle=c,t.fill()),m&&(t.strokeStyle=m,h&&(t.lineWidth=h),t.stroke());break}case "line":{let a=r(e.x1),s=r(e.y1),n=r(e.x2),i=r(e.y2),o=r(e.stroke)||"black",f=r(e.strokeWidth)||1;t.beginPath(),t.moveTo(a,s),t.lineTo(n,i),t.strokeStyle=o,t.lineWidth=f,t.stroke();break}case "text":{let a=r(e.x),s=r(e.y),n=r(e.text),i=r(e.fill)||"black",o=r(e.fontSize)||16,f=r(e.fontFamily)||"sans-serif",c=r(e.fontWeight)||"normal",m=r(e.textAlign)||"left";t.font=`${c} ${o}px ${f}`,t.textAlign=m,t.fillStyle=i,t.fillText(n,a,s);break}case "path":{let a=r(e.d),s=r(e.fill),n=r(e.stroke),i=r(e.strokeWidth),o=new Path2D(a);s&&(t.fillStyle=s,t.fill(o)),n&&(t.strokeStyle=n,i&&(t.lineWidth=i),t.stroke(o));break}}y!==void 0&&(t.globalAlpha=1);}function x(t){return chunkYWTD32NA_js.e(()=>{l({type:"rect",props:t});}),null}function v(t){return chunkYWTD32NA_js.e(()=>{l({type:"circle",props:t});}),null}function A(t){return chunkYWTD32NA_js.e(()=>{l({type:"arc",props:t});}),null}function W(t){return chunkYWTD32NA_js.e(()=>{l({type:"line",props:t});}),null}function b(t){return chunkYWTD32NA_js.e(()=>{l({type:"text",props:t});}),null}function R(t){return chunkYWTD32NA_js.e(()=>{l({type:"path",props:t});}),null}exports.Canvas=C;exports.DrawArc=A;exports.DrawCircle=v;exports.DrawLine=W;exports.DrawPath=R;exports.DrawRect=x;exports.DrawText=b;//# sourceMappingURL=canvas.js.map
1
+ 'use strict';var chunkDUGPBZZ3_js=require('./chunk-DUGPBZZ3.js'),chunkW2L7BLE7_js=require('./chunk-W2L7BLE7.js');require('./chunk-3CKIHQIE.js'),require('./chunk-UWFVCKRU.js'),require('./chunk-CGB4YXKS.js');var D=[];function l(t){D.push(t);}function C(t){let{width:y,height:w,children:e,style:u,ref:a}=t,s,n=null,i=()=>{!s||!n||(n.clearRect(0,0,y,w),D.length=0,Array.isArray(e)?e.forEach(o=>{typeof o=="function"&&o();}):typeof e=="function"&&e(),D.forEach(o=>{g(n,o);}),null);};return chunkW2L7BLE7_js.c(()=>{s&&i();}),chunkDUGPBZZ3_js.a("canvas",{ref:o=>{s=o,n=o.getContext("2d"),a&&a(o),i();},width:y,height:w,style:u})}function r(t){return chunkW2L7BLE7_js.b(t)?t.valueOf?.()??t:t}function g(t,y){let{type:w,props:e}=y,u=r(e.opacity);switch(u!==void 0&&(t.globalAlpha=u),w){case "rect":{let a=r(e.x),s=r(e.y),n=r(e.width),i=r(e.height),o=r(e.fill),f=r(e.stroke),c=r(e.strokeWidth);o&&(t.fillStyle=o,t.fillRect(a,s,n,i)),f&&(t.strokeStyle=f,c&&(t.lineWidth=c),t.strokeRect(a,s,n,i));break}case "circle":{let a=r(e.x),s=r(e.y),n=r(e.radius),i=r(e.fill),o=r(e.stroke),f=r(e.strokeWidth);t.beginPath(),t.arc(a,s,n,0,Math.PI*2),i&&(t.fillStyle=i,t.fill()),o&&(t.strokeStyle=o,f&&(t.lineWidth=f),t.stroke());break}case "arc":{let a=r(e.x),s=r(e.y),n=r(e.radius),i=r(e.startAngle),o=r(e.endAngle),f=r(e.counterclockwise)||false,c=r(e.fill),m=r(e.stroke),h=r(e.strokeWidth);t.beginPath(),t.arc(a,s,n,i,o,f),c&&(t.fillStyle=c,t.fill()),m&&(t.strokeStyle=m,h&&(t.lineWidth=h),t.stroke());break}case "line":{let a=r(e.x1),s=r(e.y1),n=r(e.x2),i=r(e.y2),o=r(e.stroke)||"black",f=r(e.strokeWidth)||1;t.beginPath(),t.moveTo(a,s),t.lineTo(n,i),t.strokeStyle=o,t.lineWidth=f,t.stroke();break}case "text":{let a=r(e.x),s=r(e.y),n=r(e.text),i=r(e.fill)||"black",o=r(e.fontSize)||16,f=r(e.fontFamily)||"sans-serif",c=r(e.fontWeight)||"normal",m=r(e.textAlign)||"left";t.font=`${c} ${o}px ${f}`,t.textAlign=m,t.fillStyle=i,t.fillText(n,a,s);break}case "path":{let a=r(e.d),s=r(e.fill),n=r(e.stroke),i=r(e.strokeWidth),o=new Path2D(a);s&&(t.fillStyle=s,t.fill(o)),n&&(t.strokeStyle=n,i&&(t.lineWidth=i),t.stroke(o));break}}u!==void 0&&(t.globalAlpha=1);}function x(t){return chunkW2L7BLE7_js.c(()=>{l({type:"rect",props:t});}),null}function v(t){return chunkW2L7BLE7_js.c(()=>{l({type:"circle",props:t});}),null}function A(t){return chunkW2L7BLE7_js.c(()=>{l({type:"arc",props:t});}),null}function W(t){return chunkW2L7BLE7_js.c(()=>{l({type:"line",props:t});}),null}function b(t){return chunkW2L7BLE7_js.c(()=>{l({type:"text",props:t});}),null}function R(t){return chunkW2L7BLE7_js.c(()=>{l({type:"path",props:t});}),null}exports.Canvas=C;exports.DrawArc=A;exports.DrawCircle=v;exports.DrawLine=W;exports.DrawPath=R;exports.DrawRect=x;exports.DrawText=b;//# sourceMappingURL=canvas.js.map
2
2
  //# sourceMappingURL=canvas.js.map
@@ -1 +1 @@
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":"oMAOA,IACMA,CAAAA,CAA8B,GAM7B,SAASC,CAAAA,CAAUC,CAAAA,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AA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS2C,CAAAA,CAAQ3C,CAAAA,CAAqB,CAC3C,OAAAW,mBAAO,IAAM,CACXd,EAAU,CACR,IAAA,CAAM,MACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS4C,CAAAA,CAAS5C,EAAsB,CAC7C,OAAAW,kBAAAA,CAAO,IAAM,CACXd,CAAAA,CAAU,CACR,KAAM,MAAA,CACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,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,CCTO,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'\nimport type { CanvasProps, CanvasDrawNode } from './types'\n\nexport type { CanvasProps }\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'\nimport type { DrawRectProps } from '../types'\n\nexport type { DrawRectProps }\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'\nimport type { DrawCircleProps } from '../types'\n\nexport type { DrawCircleProps }\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'\nimport type { DrawArcProps } from '../types'\n\nexport type { DrawArcProps }\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'\nimport type { DrawLineProps } from '../types'\n\nexport type { DrawLineProps }\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'\nimport type { DrawTextProps } from '../types'\n\nexport type { DrawTextProps }\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'\nimport type { DrawPathProps } from '../types'\n\nexport type { DrawPathProps }\n\nexport function DrawPath(props: DrawPathProps) {\n effect(() => {\n queueDraw({\n type: 'path',\n props\n })\n })\n\n return null\n}\n"]}
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","use","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":"8MAOA,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,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,kBAAAA,CAAI,IAAM,CACJL,GACFE,CAAAA,GAEJ,CAAC,CAAA,CAGCI,mBAAC,QAAA,CAAA,CACC,GAAA,CAAMC,GAA0B,CAC9BP,CAAAA,CAASO,EACTN,CAAAA,CAAMM,CAAAA,CAAG,UAAA,CAAW,IAAI,EACpBR,CAAAA,EAAKA,CAAAA,CAAIQ,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CAAAA,CAASzC,EAAsB,CAC7C,OAAAW,mBAAI,IAAM,CACRd,EAAU,CACR,IAAA,CAAM,MAAA,CACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS0C,CAAAA,CAAW1C,CAAAA,CAAwB,CACjD,OAAAW,kBAAAA,CAAI,IAAM,CACRd,CAAAA,CAAU,CACR,KAAM,QAAA,CACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS2C,CAAAA,CAAQ3C,CAAAA,CAAqB,CAC3C,OAAAW,mBAAI,IAAM,CACRd,EAAU,CACR,IAAA,CAAM,MACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS4C,CAAAA,CAAS5C,EAAsB,CAC7C,OAAAW,kBAAAA,CAAI,IAAM,CACRd,CAAAA,CAAU,CACR,KAAM,MAAA,CACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS6C,EAAS7C,CAAAA,CAAsB,CAC7C,OAAAW,kBAAAA,CAAI,IAAM,CACRd,CAAAA,CAAU,CACR,IAAA,CAAM,MAAA,CACN,MAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS8C,CAAAA,CAAS9C,CAAAA,CAAsB,CAC7C,OAAAW,kBAAAA,CAAI,IAAM,CACRd,CAAAA,CAAU,CACR,IAAA,CAAM,OACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,EAEM,IACT","file":"canvas.js","sourcesContent":["import { use } from '../core/use'\nimport { isReactive } from '../core/reactive'\nimport type { CanvasProps, CanvasDrawNode } from './types'\n\nexport type { CanvasProps }\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 use(() => {\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 { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawRectProps } from '../types'\n\nexport type { DrawRectProps }\n\nexport function DrawRect(props: DrawRectProps) {\n use(() => {\n queueDraw({\n type: 'rect',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawCircleProps } from '../types'\n\nexport type { DrawCircleProps }\n\nexport function DrawCircle(props: DrawCircleProps) {\n use(() => {\n queueDraw({\n type: 'circle',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawArcProps } from '../types'\n\nexport type { DrawArcProps }\n\nexport function DrawArc(props: DrawArcProps) {\n use(() => {\n queueDraw({\n type: 'arc',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawLineProps } from '../types'\n\nexport type { DrawLineProps }\n\nexport function DrawLine(props: DrawLineProps) {\n use(() => {\n queueDraw({\n type: 'line',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawTextProps } from '../types'\n\nexport type { DrawTextProps }\n\nexport function DrawText(props: DrawTextProps) {\n use(() => {\n queueDraw({\n type: 'text',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawPathProps } from '../types'\n\nexport type { DrawPathProps }\n\nexport function DrawPath(props: DrawPathProps) {\n use(() => {\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
- import {b as b$1}from'./chunk-JY6CE6RN.mjs';import {e}from'./chunk-IWFEXW4F.mjs';import'./chunk-5PNH2ARD.mjs';import {a}from'./chunk-NY6NOGFU.mjs';var D=[];function l(t){D.push(t);}function C(t){let{width:u,height:w,children:e$1,style:y,ref:a$1}=t,s,n=null,i=()=>{!s||!n||(n.clearRect(0,0,u,w),D.length=0,Array.isArray(e$1)?e$1.forEach(o=>{typeof o=="function"&&o();}):typeof e$1=="function"&&e$1(),D.forEach(o=>{g(n,o);}),null);};return e(()=>{s&&i();}),a("canvas",{ref:o=>{s=o,n=o.getContext("2d"),a$1&&a$1(o),i();},width:u,height:w,style:y})}function r(t){return b$1(t)?t.valueOf?.()??t:t}function g(t,u){let{type:w,props:e}=u,y=r(e.opacity);switch(y!==void 0&&(t.globalAlpha=y),w){case "rect":{let a=r(e.x),s=r(e.y),n=r(e.width),i=r(e.height),o=r(e.fill),f=r(e.stroke),c=r(e.strokeWidth);o&&(t.fillStyle=o,t.fillRect(a,s,n,i)),f&&(t.strokeStyle=f,c&&(t.lineWidth=c),t.strokeRect(a,s,n,i));break}case "circle":{let a=r(e.x),s=r(e.y),n=r(e.radius),i=r(e.fill),o=r(e.stroke),f=r(e.strokeWidth);t.beginPath(),t.arc(a,s,n,0,Math.PI*2),i&&(t.fillStyle=i,t.fill()),o&&(t.strokeStyle=o,f&&(t.lineWidth=f),t.stroke());break}case "arc":{let a=r(e.x),s=r(e.y),n=r(e.radius),i=r(e.startAngle),o=r(e.endAngle),f=r(e.counterclockwise)||false,c=r(e.fill),m=r(e.stroke),h=r(e.strokeWidth);t.beginPath(),t.arc(a,s,n,i,o,f),c&&(t.fillStyle=c,t.fill()),m&&(t.strokeStyle=m,h&&(t.lineWidth=h),t.stroke());break}case "line":{let a=r(e.x1),s=r(e.y1),n=r(e.x2),i=r(e.y2),o=r(e.stroke)||"black",f=r(e.strokeWidth)||1;t.beginPath(),t.moveTo(a,s),t.lineTo(n,i),t.strokeStyle=o,t.lineWidth=f,t.stroke();break}case "text":{let a=r(e.x),s=r(e.y),n=r(e.text),i=r(e.fill)||"black",o=r(e.fontSize)||16,f=r(e.fontFamily)||"sans-serif",c=r(e.fontWeight)||"normal",m=r(e.textAlign)||"left";t.font=`${c} ${o}px ${f}`,t.textAlign=m,t.fillStyle=i,t.fillText(n,a,s);break}case "path":{let a=r(e.d),s=r(e.fill),n=r(e.stroke),i=r(e.strokeWidth),o=new Path2D(a);s&&(t.fillStyle=s,t.fill(o)),n&&(t.strokeStyle=n,i&&(t.lineWidth=i),t.stroke(o));break}}y!==void 0&&(t.globalAlpha=1);}function x(t){return e(()=>{l({type:"rect",props:t});}),null}function v(t){return e(()=>{l({type:"circle",props:t});}),null}function A(t){return e(()=>{l({type:"arc",props:t});}),null}function W(t){return e(()=>{l({type:"line",props:t});}),null}function b(t){return e(()=>{l({type:"text",props:t});}),null}function R(t){return e(()=>{l({type:"path",props:t});}),null}export{C as Canvas,A as DrawArc,v as DrawCircle,W as DrawLine,R as DrawPath,x as DrawRect,b as DrawText};//# sourceMappingURL=canvas.mjs.map
1
+ import {a}from'./chunk-NY6NOGFU.mjs';import {c,b as b$1}from'./chunk-INJXOHFD.mjs';import'./chunk-NRPWBHKP.mjs';import'./chunk-5PNH2ARD.mjs';import'./chunk-NDPEE2TQ.mjs';var D=[];function l(t){D.push(t);}function C(t){let{width:y,height:w,children:e,style:u,ref:a$1}=t,s,n=null,i=()=>{!s||!n||(n.clearRect(0,0,y,w),D.length=0,Array.isArray(e)?e.forEach(o=>{typeof o=="function"&&o();}):typeof e=="function"&&e(),D.forEach(o=>{g(n,o);}),null);};return c(()=>{s&&i();}),a("canvas",{ref:o=>{s=o,n=o.getContext("2d"),a$1&&a$1(o),i();},width:y,height:w,style:u})}function r(t){return b$1(t)?t.valueOf?.()??t:t}function g(t,y){let{type:w,props:e}=y,u=r(e.opacity);switch(u!==void 0&&(t.globalAlpha=u),w){case "rect":{let a=r(e.x),s=r(e.y),n=r(e.width),i=r(e.height),o=r(e.fill),f=r(e.stroke),c=r(e.strokeWidth);o&&(t.fillStyle=o,t.fillRect(a,s,n,i)),f&&(t.strokeStyle=f,c&&(t.lineWidth=c),t.strokeRect(a,s,n,i));break}case "circle":{let a=r(e.x),s=r(e.y),n=r(e.radius),i=r(e.fill),o=r(e.stroke),f=r(e.strokeWidth);t.beginPath(),t.arc(a,s,n,0,Math.PI*2),i&&(t.fillStyle=i,t.fill()),o&&(t.strokeStyle=o,f&&(t.lineWidth=f),t.stroke());break}case "arc":{let a=r(e.x),s=r(e.y),n=r(e.radius),i=r(e.startAngle),o=r(e.endAngle),f=r(e.counterclockwise)||false,c=r(e.fill),m=r(e.stroke),h=r(e.strokeWidth);t.beginPath(),t.arc(a,s,n,i,o,f),c&&(t.fillStyle=c,t.fill()),m&&(t.strokeStyle=m,h&&(t.lineWidth=h),t.stroke());break}case "line":{let a=r(e.x1),s=r(e.y1),n=r(e.x2),i=r(e.y2),o=r(e.stroke)||"black",f=r(e.strokeWidth)||1;t.beginPath(),t.moveTo(a,s),t.lineTo(n,i),t.strokeStyle=o,t.lineWidth=f,t.stroke();break}case "text":{let a=r(e.x),s=r(e.y),n=r(e.text),i=r(e.fill)||"black",o=r(e.fontSize)||16,f=r(e.fontFamily)||"sans-serif",c=r(e.fontWeight)||"normal",m=r(e.textAlign)||"left";t.font=`${c} ${o}px ${f}`,t.textAlign=m,t.fillStyle=i,t.fillText(n,a,s);break}case "path":{let a=r(e.d),s=r(e.fill),n=r(e.stroke),i=r(e.strokeWidth),o=new Path2D(a);s&&(t.fillStyle=s,t.fill(o)),n&&(t.strokeStyle=n,i&&(t.lineWidth=i),t.stroke(o));break}}u!==void 0&&(t.globalAlpha=1);}function x(t){return c(()=>{l({type:"rect",props:t});}),null}function v(t){return c(()=>{l({type:"circle",props:t});}),null}function A(t){return c(()=>{l({type:"arc",props:t});}),null}function W(t){return c(()=>{l({type:"line",props:t});}),null}function b(t){return c(()=>{l({type:"text",props:t});}),null}function R(t){return c(()=>{l({type:"path",props:t});}),null}export{C as Canvas,A as DrawArc,v as DrawCircle,W as DrawLine,R as DrawPath,x as DrawRect,b as DrawText};//# sourceMappingURL=canvas.mjs.map
2
2
  //# sourceMappingURL=canvas.mjs.map
@@ -1 +1 @@
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":"mJAOA,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,GAAAA,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,GAAQ,CAAA,CACxBA,GAAAA,CAAS,QAAQM,CAAAA,EAAS,CACpB,OAAOA,CAAAA,EAAU,YACnBA,CAAAA,GAEJ,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,CAAsB,CAC7C,OAAAW,CAAAA,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'\nimport type { CanvasProps, CanvasDrawNode } from './types'\n\nexport type { CanvasProps }\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'\nimport type { DrawRectProps } from '../types'\n\nexport type { DrawRectProps }\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'\nimport type { DrawCircleProps } from '../types'\n\nexport type { DrawCircleProps }\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'\nimport type { DrawArcProps } from '../types'\n\nexport type { DrawArcProps }\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'\nimport type { DrawLineProps } from '../types'\n\nexport type { DrawLineProps }\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'\nimport type { DrawTextProps } from '../types'\n\nexport type { DrawTextProps }\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'\nimport type { DrawPathProps } from '../types'\n\nexport type { DrawPathProps }\n\nexport function DrawPath(props: DrawPathProps) {\n effect(() => {\n queueDraw({\n type: 'path',\n props\n })\n })\n\n return null\n}\n"]}
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","use","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":"0KAOA,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,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N,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS6C,EAAS7C,CAAAA,CAAsB,CAC7C,OAAAW,CAAAA,CAAI,IAAM,CACRd,CAAAA,CAAU,CACR,IAAA,CAAM,MAAA,CACN,MAAAG,CACF,CAAC,EACH,CAAC,CAAA,CAEM,IACT,CCTO,SAAS8C,CAAAA,CAAS9C,CAAAA,CAAsB,CAC7C,OAAAW,CAAAA,CAAI,IAAM,CACRd,CAAAA,CAAU,CACR,IAAA,CAAM,OACN,KAAA,CAAAG,CACF,CAAC,EACH,CAAC,EAEM,IACT","file":"canvas.mjs","sourcesContent":["import { use } from '../core/use'\nimport { isReactive } from '../core/reactive'\nimport type { CanvasProps, CanvasDrawNode } from './types'\n\nexport type { CanvasProps }\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 use(() => {\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 { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawRectProps } from '../types'\n\nexport type { DrawRectProps }\n\nexport function DrawRect(props: DrawRectProps) {\n use(() => {\n queueDraw({\n type: 'rect',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawCircleProps } from '../types'\n\nexport type { DrawCircleProps }\n\nexport function DrawCircle(props: DrawCircleProps) {\n use(() => {\n queueDraw({\n type: 'circle',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawArcProps } from '../types'\n\nexport type { DrawArcProps }\n\nexport function DrawArc(props: DrawArcProps) {\n use(() => {\n queueDraw({\n type: 'arc',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawLineProps } from '../types'\n\nexport type { DrawLineProps }\n\nexport function DrawLine(props: DrawLineProps) {\n use(() => {\n queueDraw({\n type: 'line',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawTextProps } from '../types'\n\nexport type { DrawTextProps }\n\nexport function DrawText(props: DrawTextProps) {\n use(() => {\n queueDraw({\n type: 'text',\n props\n })\n })\n\n return null\n}\n","import { use } from '../../core/use'\nimport { queueDraw } from '../Canvas'\nimport type { DrawPathProps } from '../types'\n\nexport type { DrawPathProps }\n\nexport function DrawPath(props: DrawPathProps) {\n use(() => {\n queueDraw({\n type: 'path',\n props\n })\n })\n\n return null\n}\n"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';exports.a=void 0;var n=class{constructor(t,f){this.fn=t;this.scheduler=f;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 f=0;f<t.length;f++)t[f].delete(this);t.length=0;}}};function h(e,t={}){let f=new n(e,t.scheduler);f.run();let o=f.run.bind(f);return o.effect=f,o}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(r)));}function r(){s=false;let e=[...i];i.clear();for(let t of e)t.active&&t.run();}function u(e){a=e;}function p(e){let t=[...e];for(let f of t)f!==exports.a&&(f.scheduler?f.scheduler():l(f));}function v(e){if(e){u(true);try{e();}finally{u(false),r();}}else r();}exports.b=h;exports.c=d;exports.d=p;exports.e=v;//# sourceMappingURL=chunk-3CKIHQIE.js.map
2
+ //# sourceMappingURL=chunk-3CKIHQIE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/lifecycle.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","sync"],"mappings":"aACWA,gBAAAA,KAEEC,CAAAA,CAAN,KAAyB,CAI5B,WAAA,CACWC,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,IAAA,CAAK,MAAA,CACN,OAAO,IAAA,CAAK,EAAA,EAAG,CAGnB,IAAIC,EAAqCJ,SAAAA,CACzC,GAAI,CACA,OAAA,IAAA,CAAK,OAAA,EAAQ,CACbA,SAAAA,CAAe,IAAA,CACR,IAAA,CAAK,EAAA,EAChB,CAAA,OAAE,CACEA,SAAAA,CAAeI,EACnB,CACJ,CAEA,IAAA,EAAO,CACC,IAAA,CAAK,MAAA,GACL,IAAA,CAAK,OAAA,EAAQ,CACb,IAAA,CAAK,MAAA,CAAS,KAAA,EAEtB,CAEA,OAAA,EAAU,CACN,GAAM,CAAE,IAAA,CAAAC,CAAK,CAAA,CAAI,IAAA,CACjB,GAAIA,CAAAA,CAAK,MAAA,CAAQ,CACb,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAID,CAAAA,CAAK,MAAA,CAAQC,CAAAA,EAAAA,CAC7BD,CAAAA,CAAKC,CAAC,CAAA,CAAE,MAAA,CAAO,IAAI,CAAA,CAEvBD,CAAAA,CAAK,MAAA,CAAS,EAClB,CACJ,CACJ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AAC,GAAGP,CAAG,CAAA,CACvB,IAAA,IAAWK,CAAAA,IAAUE,CAAAA,CACbF,CAAAA,GAAWjB,SAAAA,GACPiB,CAAAA,CAAO,SAAA,CACPA,CAAAA,CAAO,SAAA,EAAU,CAEjBD,CAAAA,CAASC,CAAM,CAAA,EAI/B,CAOO,SAASM,CAAAA,CAAKrB,CAAAA,CAAiB,CAClC,GAAIA,CAAAA,CAAI,CACJkB,CAAAA,CAAY,IAAI,CAAA,CAChB,GAAI,CACAlB,CAAAA,GACJ,CAAA,OAAE,CACEkB,CAAAA,CAAY,KAAK,CAAA,CACjBF,CAAAA,GACJ,CACJ,CAAA,KACIA,CAAAA,GAER","file":"chunk-3CKIHQIE.js","sourcesContent":["// Reactive effect system\nexport 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\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"]}
@@ -1,2 +1,2 @@
1
- 'use strict';var n=new Map;function a(t){let e=Symbol("context"),o=r=>r.children;return o._contextId=e,{Provider:o,id:e,defaultValue:t}}function p(t){return n.has(t.id)?n.get(t.id):t.defaultValue}function s(t,e){let o=n.get(t);return n.set(t,e),o}function c(t,e){e===void 0?n.delete(t):n.set(t,e);}exports.a=a;exports.b=p;exports.c=s;exports.d=c;//# sourceMappingURL=chunk-PSKDIB7J.js.map
2
- //# sourceMappingURL=chunk-PSKDIB7J.js.map
1
+ 'use strict';var n=new Map;function a(t){let e=Symbol("context"),o=r=>r.children;return o._contextId=e,{Provider:o,id:e,defaultValue:t}}function p(t){return n.has(t.id)?n.get(t.id):t.defaultValue}function s(t,e){let o=n.get(t);return n.set(t,e),o}function c(t,e){e===void 0?n.delete(t):n.set(t,e);}exports.a=a;exports.b=p;exports.c=s;exports.d=c;//# sourceMappingURL=chunk-CGB4YXKS.js.map
2
+ //# sourceMappingURL=chunk-CGB4YXKS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/context.ts"],"names":["contextMap","createContext","defaultValue","id","Provider","props","useContext","ctx","pushContext","value","prev","popContext","prevValue"],"mappings":"aAIA,IAAMA,EAAa,IAAI,GAAA,CAEhB,SAASC,CAAAA,CAAiBC,EAA6B,CAC1D,IAAMC,CAAAA,CAAK,MAAA,CAAO,SAAS,CAAA,CACrBC,CAAAA,CAAYC,GAAuCA,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,CAAAA,CAAcC,EAAoB,CAC9C,OAAOP,EAAW,GAAA,CAAIO,CAAAA,CAAI,EAAE,CAAA,CAAIP,CAAAA,CAAW,GAAA,CAAIO,CAAAA,CAAI,EAAE,CAAA,CAAIA,CAAAA,CAAI,YACjE,CAGO,SAASC,CAAAA,CAAYL,CAAAA,CAAYM,CAAAA,CAAY,CAChD,IAAMC,CAAAA,CAAOV,CAAAA,CAAW,IAAIG,CAAE,CAAA,CAC9B,OAAAH,CAAAA,CAAW,GAAA,CAAIG,CAAAA,CAAIM,CAAK,EACjBC,CACX,CAGO,SAASC,CAAAA,CAAWR,CAAAA,CAAYS,EAAgB,CAC/CA,CAAAA,GAAc,MAAA,CACdZ,CAAAA,CAAW,OAAOG,CAAE,CAAA,CAEpBH,EAAW,GAAA,CAAIG,CAAAA,CAAIS,CAAS,EAEpC","file":"chunk-CGB4YXKS.js","sourcesContent":["import type { Context } from './types'\n\nexport type { Context }\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 useContext<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
+ import {a,c,d,b as b$3}from'./chunk-NRPWBHKP.mjs';import {b as b$2}from'./chunk-5PNH2ARD.mjs';import {b as b$1}from'./chunk-NDPEE2TQ.mjs';var C=Symbol("flexium.reactive"),b=new WeakMap,R=new WeakMap;function x(e){if(e&&e[C])return e;let r=R.get(e);if(r)return r;let s=new Proxy(e,{get(n,i,a){if(i===C)return true;let f=Reflect.get(n,i,a);return j(n,i),f!==null&&typeof f=="object"?x(f):f},set(n,i,a,f){let l=n[i],m=Reflect.set(n,i,a,f);return m&&A(a,l)&&I(n,i),m}});return R.set(e,s),s}function j(e,r){if(!a)return;let s=b.get(e);s||b.set(e,s=new Map);let n=s.get(r);n||s.set(r,n=new Set),c(n);}function I(e,r){let s=b.get(e);if(!s)return;let n=s.get(r);n&&d(n);}function A(e,r){return !Object.is(e,r)}function L(e){return !!(e&&e[C])}var K=0,M=new Map;function E(){if(typeof window<"u")return window.__FLEXIUM_DEVTOOLS__}function _(e,r){let s=E();if(!s)return -1;let n=++K;M.set(e,n);let i={id:n,name:r||`signal_${n}`,value:e.value,type:e.type||"signal",subscribers:0,createdAt:Date.now()};return s.onSignalCreate(i),n}function O(e,r){let s=E();if(!s)return;let n=M.get(e);n!==void 0&&s.onSignalUpdate(n,r);}function V(e){return e&&typeof e=="object"&&"id"in e&&"defaultValue"in e&&"Provider"in e}var P=new Map;function z(e){return JSON.stringify(e)}function q(e,r,s){if(V(e))return [b$1(e),void 0];let n,i;if(Array.isArray(r)?(n=r,i=s):r&&typeof r=="object"&&(i=r),i?.key&&!Array.isArray(i.key))throw new Error("State key must be an array");let a=b$2(()=>x({container:void 0,serializedKey:void 0})),f=i?.key,l=f?z(f):void 0,m=l!==a.serializedKey;if(typeof e=="function"&&n!==void 0){let c=e,o=b$2(()=>({value:void 0,prevDeps:void 0,cleanup:void 0,hasRun:false,params:void 0})),t=true;if(o.hasRun&&o.prevDeps&&(t=n.length!==o.prevDeps.length||n.some((p,d)=>p!==o.prevDeps[d])),t){o.cleanup&&(o.cleanup(),o.cleanup=void 0);let p={onCleanup:y=>{o.cleanup=y;},params:o.params},d=c(p);if(d instanceof Promise)throw new Error("deps with async functions is not supported. Use use(asyncFn) without deps for async resources.");o.value=d,o.prevDeps=[...n],o.hasRun=true;}let v={refetch:async()=>{},get loading(){return false},get error(){return null},get status(){return "success"}};return [o.value,v]}if(!a.container||m)if(a.serializedKey=l,l&&P.has(l))a.container=P.get(l);else {let c;if(typeof e=="function"){let o=e,t=x({type:"resource",value:void 0,loading:true,error:null,status:"idle",cleanup:void 0,params:void 0,run:()=>{}}),v=p=>{t.cleanup&&(t.cleanup(),t.cleanup=void 0),t.params=p;try{let d={onCleanup:g=>{t.cleanup=g;},params:t.params},y=o(d);y instanceof Promise?(t.loading=!0,t.status="loading",t.error=null,y.then(g=>{t.value=g,t.status="success",t.loading=!1;}).catch(g=>{t.error=g,t.status="error",t.loading=!1;})):(t.value=y,t.status="success",t.loading=!1,t.error=null);}catch(d){t.error=d,t.status="error",t.loading=false;}};t.run=v,b$3(()=>v()),c=t;}else c=x({type:"signal",value:e}),_(c,i?.name);l&&P.set(l,c),a.container=c;}let u=a.container,w=u.value;return u.type==="signal"?[w,o=>{typeof o=="function"?u.value=o(u.value):u.value=o,O(u,u.value);}]:[w,{refetch:async o=>{u.run(o);},get loading(){return u.loading},get error(){return u.error},get status(){return u.status}}]}export{x as a,L as b,q as c};//# sourceMappingURL=chunk-INJXOHFD.mjs.map
2
+ //# sourceMappingURL=chunk-INJXOHFD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/reactive.ts","../src/core/devtools.ts","../src/core/use.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","signalIdCounter","signalRegistry","getDevToolsHook","registerSignal","container","name","hook","id","info","updateSignal","isContext","globalRegistry","serializeKey","use","input","depsOrOptions","thirdArg","useContext","deps","options","stateRef","currentKey","serializedKey","keyChanged","fn","memoState","d","i","ctx","control","newContainer","state","run","params","data","err","unsafeEffect","currentValue","newValue"],"mappings":"0IAEO,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,EAAgBH,CAAAA,CAAY,GAAA,CAAIE,CAAM,CAAA,CAC5C,GAAIC,EACA,OAAOA,CAAAA,CAGX,IAAMC,CAAAA,CAAQ,IAAI,MAAMF,CAAAA,CAAQ,CAC5B,IAAIA,CAAAA,CAAQG,CAAAA,CAAKC,EAAU,CACvB,GAAID,CAAAA,GAAQP,CAAAA,CAAiB,OAAO,KAAA,CAEpC,IAAMS,CAAAA,CAAM,OAAA,CAAQ,IAAIL,CAAAA,CAAQG,CAAAA,CAAKC,CAAQ,CAAA,CAI7C,OAFAE,EAAMN,CAAAA,CAAQG,CAAG,EAEbE,CAAAA,GAAQ,IAAA,EAAQ,OAAOA,CAAAA,EAAQ,QAAA,CACxBN,EAASM,CAAG,CAAA,CAGhBA,CACX,CAAA,CACA,GAAA,CAAIL,CAAAA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C,EACjB,CAAA,KAEED,EAAejD,CAAAA,CAAS,CACtB,KAAM,QAAA,CACN,KAAA,CAAOiC,CACT,CAAC,CAAA,CAGDX,EAAe2B,CAAAA,CAAcX,CAAAA,EAAS,IAAI,CAAA,CAIxCG,CAAAA,EACFX,CAAAA,CAAe,GAAA,CAAIW,CAAAA,CAAeQ,CAAY,EAGhDV,CAAAA,CAAS,SAAA,CAAYU,EACvB,CAGF,IAAM1B,EAAYgB,CAAAA,CAAS,SAAA,CAGrBiB,EAAejC,CAAAA,CAAU,KAAA,CAE/B,OAAIA,CAAAA,CAAU,IAAA,GAAS,SASd,CAACiC,CAAAA,CARmBC,GAAa,CAClC,OAAOA,CAAAA,EAAa,UAAA,CACtBlC,CAAAA,CAAU,KAAA,CAASkC,EAAsBlC,CAAAA,CAAU,KAAK,EAExDA,CAAAA,CAAU,KAAA,CAAQkC,EAEpB7B,CAAAA,CAAaL,CAAAA,CAAWA,EAAU,KAAK,EACzC,CAC4B,CAAA,CASrB,CAACiC,EAN4B,CAClC,OAAA,CAAS,MAAOJ,CAAAA,EAAe,CAAE7B,CAAAA,CAAU,GAAA,CAAI6B,CAAM,EAAE,EACvD,IAAI,OAAA,EAAU,CAAE,OAAO7B,CAAAA,CAAU,OAAQ,CAAA,CACzC,IAAI,OAAQ,CAAE,OAAOA,EAAU,KAAM,CAAA,CACrC,IAAI,MAAA,EAAS,CAAE,OAAOA,CAAAA,CAAU,MAAO,CACzC,CAC6B,CAEjC","file":"chunk-INJXOHFD.mjs","sourcesContent":["import { activeEffect, trackEffect, triggerEffects } from './lifecycle'\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","// DevTools integration for Flexium\n// This module provides hooks for browser DevTools extension\n\ninterface SignalInfo {\n id: number\n name: string\n value: unknown\n type: string\n subscribers: number\n createdAt: number\n}\n\ninterface DevToolsHook {\n signals: Map<number, SignalInfo>\n onSignalCreate: (info: SignalInfo) => void\n onSignalUpdate: (id: number, value: unknown) => void\n onRender: (event: { timestamp: number; componentName: string; trigger: string; duration: number }) => void\n}\n\ndeclare global {\n interface Window {\n __FLEXIUM_DEVTOOLS__?: DevToolsHook\n }\n}\n\nlet signalIdCounter = 0\nconst signalRegistry = new Map<object, number>()\n\nfunction getDevToolsHook(): DevToolsHook | undefined {\n if (typeof window !== 'undefined') {\n return window.__FLEXIUM_DEVTOOLS__\n }\n return undefined\n}\n\nexport function registerSignal(container: object, name?: string): number {\n const hook = getDevToolsHook()\n if (!hook) return -1\n\n const id = ++signalIdCounter\n signalRegistry.set(container, id)\n\n const info: SignalInfo = {\n id,\n name: name || `signal_${id}`,\n value: (container as any).value,\n type: (container as any).type || 'signal',\n subscribers: 0,\n createdAt: Date.now(),\n }\n\n hook.onSignalCreate(info)\n return id\n}\n\nexport function updateSignal(container: object, value: unknown): void {\n const hook = getDevToolsHook()\n if (!hook) return\n\n const id = signalRegistry.get(container)\n if (id !== undefined) {\n hook.onSignalUpdate(id, value)\n }\n}\n\nexport function reportRender(componentName: string, trigger: string, duration: number): void {\n const hook = getDevToolsHook()\n if (!hook) return\n\n hook.onRender({\n timestamp: Date.now(),\n componentName,\n trigger,\n duration,\n })\n}\n\nexport function isDevToolsEnabled(): boolean {\n return getDevToolsHook() !== undefined\n}\n","import { reactive } from './reactive'\nimport { unsafeEffect } from './lifecycle'\nimport { hook } from './hook'\nimport { registerSignal, updateSignal } from './devtools'\nimport type { Context } from './types'\n\n// Re-export context utilities\nexport { createContext, pushContext, popContext, snapshotContext, runWithContext } from './context'\nimport { useContext as _useContext } from './context'\nexport type { Context }\n\nfunction isContext(value: any): value is Context<any> {\n return value && typeof value === 'object' && 'id' in value && 'defaultValue' in value && 'Provider' in value\n}\n\n// Types\nexport type Setter<T> = (newValue: T | ((prev: T) => T)) => void\n\nexport type ResourceControl<P = void> = {\n refetch: (params?: P) => Promise<void>\n readonly loading: boolean\n readonly error: unknown\n readonly status: 'idle' | 'loading' | 'success' | 'error'\n}\n\nexport interface UseContext<P = void> {\n onCleanup: (fn: () => void) => void\n params?: P\n}\n\nexport interface UseOptions {\n key?: unknown[]\n name?: string\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 use<T>(ctx: Context<T>): [T, undefined]\n\nexport function use<T, P = void>(\n fn: (ctx: UseContext<P>) => Promise<T>,\n depsOrOptions?: any[] | UseOptions,\n options?: UseOptions\n): [T | undefined, ResourceControl<P>]\n\nexport function use<T>(\n fn: (ctx: UseContext) => T,\n depsOrOptions?: any[] | UseOptions,\n options?: UseOptions\n): [T, ResourceControl]\n\nexport function use<T>(\n initialValue: T extends Function ? never : T,\n options?: UseOptions\n): [T, Setter<T>]\n\nexport function use<T, P = void>(\n input: T | Context<T> | ((ctx: UseContext<P>) => T) | ((ctx: UseContext<P>) => Promise<T>),\n depsOrOptions?: any[] | UseOptions,\n thirdArg?: UseOptions\n): any {\n // Context mode: use(SomeContext) returns [value, undefined] tuple for UX consistency\n if (isContext(input)) {\n const value = _useContext(input)\n return [value, undefined]\n }\n\n // Normalize arguments:\n // - use(value, { key }) → options only\n // - use(fn, [deps]) → deps only\n // - use(fn, [deps], { key }) → deps + options\n let deps: any[] | undefined\n let options: UseOptions | undefined\n\n if (Array.isArray(depsOrOptions)) {\n deps = depsOrOptions\n options = thirdArg // third arg is options when second is deps array\n } else if (depsOrOptions && typeof depsOrOptions === 'object') {\n options = depsOrOptions as UseOptions\n }\n\n // 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\n const keyChanged = serializedKey !== stateRef.serializedKey\n\n // DEPS MODE: Function with explicit deps array\n if (typeof input === 'function' && deps !== undefined) {\n const fn = input as (ctx: UseContext<P>) => T | Promise<T>\n\n const memoState = hook(() => ({\n value: undefined as T | undefined,\n prevDeps: undefined as any[] | undefined,\n cleanup: undefined as (() => void) | undefined,\n hasRun: false,\n params: undefined as P | undefined\n }))\n\n let hasChanged = true\n if (memoState.hasRun && memoState.prevDeps) {\n hasChanged = deps.length !== memoState.prevDeps.length ||\n deps.some((d, i) => d !== memoState.prevDeps![i])\n }\n\n if (hasChanged) {\n // Run previous cleanup\n if (memoState.cleanup) {\n memoState.cleanup()\n memoState.cleanup = undefined\n }\n\n // Create context with onCleanup\n const ctx: UseContext<P> = {\n onCleanup: (fn) => {\n memoState.cleanup = fn\n },\n params: memoState.params\n }\n\n const result = fn(ctx)\n\n if (result instanceof Promise) {\n throw new Error('deps with async functions is not supported. Use use(asyncFn) without deps for async resources.')\n }\n\n memoState.value = result\n memoState.prevDeps = [...deps]\n memoState.hasRun = true\n }\n\n const control: ResourceControl<P> = {\n refetch: async () => {},\n get loading() { return false },\n get error() { return null },\n get status() { return 'success' as const }\n }\n\n return [memoState.value, control]\n }\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 // Function (Computed or Resource)\n if (typeof input === 'function') {\n const fn = input as (ctx: UseContext<P>) => T | Promise<T>\n\n // State for async/computed\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 cleanup: undefined as (() => void) | undefined,\n params: undefined as P | undefined,\n run: () => {}\n })\n\n const run = (params?: P) => {\n // Run previous cleanup\n if (state.cleanup) {\n state.cleanup()\n state.cleanup = undefined\n }\n\n // Store params for context\n state.params = params\n\n try {\n // Create context\n const ctx: UseContext<P> = {\n onCleanup: (fn) => {\n state.cleanup = fn\n },\n params: state.params\n }\n\n const result = fn(ctx)\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 } else {\n // Value (Signal)\n newContainer = reactive({\n type: 'signal',\n value: input\n })\n\n // Register with DevTools\n registerSignal(newContainer, options?.name)\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 // Access container.value to track dependency\n const currentValue = container.value\n\n if (container.type === 'signal') {\n const setter: Setter<T> = (newValue) => {\n if (typeof newValue === 'function') {\n container.value = (newValue as Function)(container.value)\n } else {\n container.value = newValue\n }\n updateSignal(container, container.value)\n }\n return [currentValue, setter]\n } else {\n // Resource / Computed\n const control: ResourceControl<P> = {\n refetch: async (params?: P) => { container.run(params) },\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"]}
@@ -1,2 +1,2 @@
1
- import {c}from'./chunk-3DKZ2J4D.mjs';import {b}from'./chunk-IWFEXW4F.mjs';import {a}from'./chunk-5PNH2ARD.mjs';var p=new WeakMap,h=null;function E(e){e.children.forEach(n=>{E(n);}),e.nodes.forEach(n=>{n.parentNode&&n.parentNode.removeChild(n);}),e.children.clear(),e.parentInstance&&e.parentInstance.children.delete(e);}function S(e,n,o){let c$1=o||n,r=f=>{let u={...f.props};return f.children&&f.children.length>0&&(u.children=f.children.length===1?f.children[0]:f.children),u},a$1=e.key!==void 0;p.has(c$1)||p.set(c$1,new Map);let t=p.get(c$1),i;if(a$1)i=e.key;else {let f=0,u=e.type.name||"anonymous";t.forEach((b,l)=>{typeof l=="string"&&l.startsWith(`__auto_${u}_`)&&f++;}),i=`__auto_${u}_${f}`;}if(t.has(i)){let f=t.get(i);f.fnode=e;let u=r(e);return f.props=u,f.children.clear(),f.renderFn&&f.renderFn(),f.nodes}let s={hooks:[],hookIndex:0,nodes:[],parent:n,fnode:e,props:r(e),key:i,children:new Set,parentInstance:h||void 0};h&&h.children.add(s),t.set(i,s);let d=true,_=()=>{let f=s.fnode,u=s.props;f.type._contextId!==void 0&&c(f.type._contextId,u.value);let l=h;h=s;let v=a(s,()=>f.type(u));if(d){let g=y(v,n);s.nodes=g?Array.isArray(g)?g:[g]:[],s.nodes.forEach(m=>{m.__ownerInstance||(m.__ownerInstance=s);}),d=false;}else {if(s.nodes.length===0){let C=y(v,n);s.nodes=C?Array.isArray(C)?C:[C]:[],h=l;return}let m=s.nodes[0].parentNode;if(!m){h=l;return}let M=document.createComment("flexium-marker"),I=s.nodes[s.nodes.length-1];I.nextSibling?m.insertBefore(M,I.nextSibling):m.appendChild(M),s.children.clear();let x=document.createElement("div"),T=y(v,x,m),O=T?Array.isArray(T)?T:[T]:[],R=P(s.nodes,O,m,M);m.removeChild(M),s.nodes=R;}h=l;};return s.renderFn=_,b(_),s.nodes}function y(e,n,o){let c=o||n;if(e==null||typeof e=="boolean"){let r=document.createTextNode("");return n.appendChild(r),r}if(typeof e=="string"||typeof e=="number"){let r=document.createTextNode(String(e));return n.appendChild(r),r}if(Array.isArray(e)){let r=new Set;p.has(c)&&p.get(c).forEach((s,d)=>r.add(d));let a=[];e.forEach(i=>{let s=y(i,n,o);s&&(Array.isArray(s)?a.push(...s):a.push(s));});let t=new Set;if(p.has(c)&&p.get(c).forEach((s,d)=>t.add(d)),p.has(c)){let i=p.get(c),s=[];r.forEach(d=>{if(!t.has(d)){let _=i.get(d);_&&(E(_),s.push(d));}}),s.forEach(d=>i.delete(d));}return a}if(typeof e=="object"){if(typeof e.type=="string"){let r=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([a,t])=>{if(a==="ref")typeof t=="function"?t(r):t&&typeof t=="object"&&"current"in t&&(t.current=r);else if(a.startsWith("on")&&typeof t=="function"){let i=a.slice(2).toLowerCase();r.addEventListener(i,t),r.__eventHandlers||(r.__eventHandlers={}),r.__eventHandlers[i]=t;}else a!=="ref"&&D(r,a,t);}),e.children&&e.children.length>0&&e.children.forEach(a=>{y(a,r);}),n.appendChild(r),r}if(typeof e.type=="function")return S(e,n,o)}return null}function D(e,n,o){o==null?e.removeAttribute(n):n==="style"&&typeof o=="object"?Object.assign(e.style,o):n==="class"?e.className=String(o):n in e&&typeof e[n]!="function"?e[n]=o:e.setAttribute(n,String(o));}function j(e,n){return e.nodeType!==n.nodeType?false:e.nodeType===Node.ELEMENT_NODE&&n.nodeType===Node.ELEMENT_NODE?e.tagName===n.tagName:true}function k(e,n){Array.from(e.attributes).forEach(t=>{n.hasAttribute(t.name)||e.removeAttribute(t.name);}),Array.from(n.attributes).forEach(t=>{e.getAttribute(t.name)!==t.value&&(t.name==="value"&&"value"in e?e.value=t.value:t.name==="checked"&&"checked"in e?e.checked=t.value==="true"||t.value==="":e.setAttribute(t.name,t.value));});let r=e.__eventHandlers||{},a=n.__eventHandlers||{};Object.keys(r).forEach(t=>{a[t]||e.removeEventListener(t,r[t]);}),Object.keys(a).forEach(t=>{r[t]!==a[t]&&(r[t]&&e.removeEventListener(t,r[t]),e.addEventListener(t,a[t]));}),Object.keys(a).length>0?e.__eventHandlers=a:delete e.__eventHandlers,e instanceof HTMLInputElement&&n instanceof HTMLInputElement&&(e.value!==n.value&&(e.value=n.value),e.checked!==n.checked&&(e.checked=n.checked)),e instanceof HTMLTextAreaElement&&n instanceof HTMLTextAreaElement&&e.value!==n.value&&(e.value=n.value),e instanceof HTMLSelectElement&&n instanceof HTMLSelectElement&&e.value!==n.value&&(e.value=n.value);}function F(e,n){let o=Array.from(e.childNodes),c=Array.from(n.childNodes),r=Math.max(o.length,c.length);for(let a=0;a<r;a++){let t=o[a],i=c[a];!t&&i?e.appendChild(i):t&&!i?e.removeChild(t):t&&i&&H(t,i,e);}}function H(e,n,o){if(j(e,n)){let c=n.__ownerInstance;if(c){let r=c.nodes.indexOf(n);r!==-1&&(c.nodes[r]=e),e.__ownerInstance=c,delete n.__ownerInstance;}e.nodeType===Node.TEXT_NODE?e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue):e.nodeType===Node.ELEMENT_NODE&&(k(e,n),F(e,n));}else o.replaceChild(n,e);}function P(e,n,o,c){let r=Math.max(e.length,n.length),a=[];for(let t=0;t<r;t++){let i=e[t],s=n[t];!i&&s?(o.insertBefore(s,c),a.push(s)):i&&!s?i.parentNode&&o.removeChild(i):i&&s&&(H(i,s,o),a.push(i));}return a}function $(e,n){n.innerHTML="",typeof e=="function"&&(e={type:e,props:{},children:[],key:void 0}),y(e,n);}export{P as a,$ as b};//# sourceMappingURL=chunk-E75BJDOQ.mjs.map
2
- //# sourceMappingURL=chunk-E75BJDOQ.mjs.map
1
+ import {b}from'./chunk-NRPWBHKP.mjs';import {a}from'./chunk-5PNH2ARD.mjs';import {c}from'./chunk-NDPEE2TQ.mjs';var p=new WeakMap,h=null;function E(e){e.children.forEach(n=>{E(n);}),e.nodes.forEach(n=>{n.parentNode&&n.parentNode.removeChild(n);}),e.children.clear(),e.parentInstance&&e.parentInstance.children.delete(e);}function S(e,n,o){let c$1=o||n,r=f=>{let u={...f.props};return f.children&&f.children.length>0&&(u.children=f.children.length===1?f.children[0]:f.children),u},a$1=e.key!==void 0;p.has(c$1)||p.set(c$1,new Map);let t=p.get(c$1),i;if(a$1)i=e.key;else {let f=0,u=e.type.name||"anonymous";t.forEach((b,l)=>{typeof l=="string"&&l.startsWith(`__auto_${u}_`)&&f++;}),i=`__auto_${u}_${f}`;}if(t.has(i)){let f=t.get(i);f.fnode=e;let u=r(e);return f.props=u,f.children.clear(),f.renderFn&&f.renderFn(),f.nodes}let s={hooks:[],hookIndex:0,nodes:[],parent:n,fnode:e,props:r(e),key:i,children:new Set,parentInstance:h||void 0};h&&h.children.add(s),t.set(i,s);let d=true,_=()=>{let f=s.fnode,u=s.props;f.type._contextId!==void 0&&c(f.type._contextId,u.value);let l=h;h=s;let v=a(s,()=>f.type(u));if(d){let g=y(v,n);s.nodes=g?Array.isArray(g)?g:[g]:[],s.nodes.forEach(m=>{m.__ownerInstance||(m.__ownerInstance=s);}),d=false;}else {if(s.nodes.length===0){let C=y(v,n);s.nodes=C?Array.isArray(C)?C:[C]:[],h=l;return}let m=s.nodes[0].parentNode;if(!m){h=l;return}let M=document.createComment("flexium-marker"),I=s.nodes[s.nodes.length-1];I.nextSibling?m.insertBefore(M,I.nextSibling):m.appendChild(M),s.children.clear();let x=document.createElement("div"),T=y(v,x,m),O=T?Array.isArray(T)?T:[T]:[],R=P(s.nodes,O,m,M);m.removeChild(M),s.nodes=R;}h=l;};return s.renderFn=_,b(_),s.nodes}function y(e,n,o){let c=o||n;if(e==null||typeof e=="boolean"){let r=document.createTextNode("");return n.appendChild(r),r}if(typeof e=="string"||typeof e=="number"){let r=document.createTextNode(String(e));return n.appendChild(r),r}if(Array.isArray(e)){let r=new Set;p.has(c)&&p.get(c).forEach((s,d)=>r.add(d));let a=[];e.forEach(i=>{let s=y(i,n,o);s&&(Array.isArray(s)?a.push(...s):a.push(s));});let t=new Set;if(p.has(c)&&p.get(c).forEach((s,d)=>t.add(d)),p.has(c)){let i=p.get(c),s=[];r.forEach(d=>{if(!t.has(d)){let _=i.get(d);_&&(E(_),s.push(d));}}),s.forEach(d=>i.delete(d));}return a}if(typeof e=="object"){if(typeof e.type=="string"){let r=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([a,t])=>{if(a==="ref")typeof t=="function"?t(r):t&&typeof t=="object"&&"current"in t&&(t.current=r);else if(a.startsWith("on")&&typeof t=="function"){let i=a.slice(2).toLowerCase();r.addEventListener(i,t),r.__eventHandlers||(r.__eventHandlers={}),r.__eventHandlers[i]=t;}else a!=="ref"&&D(r,a,t);}),e.children&&e.children.length>0&&e.children.forEach(a=>{y(a,r);}),n.appendChild(r),r}if(typeof e.type=="function")return S(e,n,o)}return null}function D(e,n,o){o==null?e.removeAttribute(n):n==="style"&&typeof o=="object"?Object.assign(e.style,o):n==="class"?e.className=String(o):n in e&&typeof e[n]!="function"?e[n]=o:e.setAttribute(n,String(o));}function j(e,n){return e.nodeType!==n.nodeType?false:e.nodeType===Node.ELEMENT_NODE&&n.nodeType===Node.ELEMENT_NODE?e.tagName===n.tagName:true}function k(e,n){Array.from(e.attributes).forEach(t=>{n.hasAttribute(t.name)||e.removeAttribute(t.name);}),Array.from(n.attributes).forEach(t=>{e.getAttribute(t.name)!==t.value&&(t.name==="value"&&"value"in e?e.value=t.value:t.name==="checked"&&"checked"in e?e.checked=t.value==="true"||t.value==="":e.setAttribute(t.name,t.value));});let r=e.__eventHandlers||{},a=n.__eventHandlers||{};Object.keys(r).forEach(t=>{a[t]||e.removeEventListener(t,r[t]);}),Object.keys(a).forEach(t=>{r[t]!==a[t]&&(r[t]&&e.removeEventListener(t,r[t]),e.addEventListener(t,a[t]));}),Object.keys(a).length>0?e.__eventHandlers=a:delete e.__eventHandlers,e instanceof HTMLInputElement&&n instanceof HTMLInputElement&&(e.value!==n.value&&(e.value=n.value),e.checked!==n.checked&&(e.checked=n.checked)),e instanceof HTMLTextAreaElement&&n instanceof HTMLTextAreaElement&&e.value!==n.value&&(e.value=n.value),e instanceof HTMLSelectElement&&n instanceof HTMLSelectElement&&e.value!==n.value&&(e.value=n.value);}function F(e,n){let o=Array.from(e.childNodes),c=Array.from(n.childNodes),r=Math.max(o.length,c.length);for(let a=0;a<r;a++){let t=o[a],i=c[a];!t&&i?e.appendChild(i):t&&!i?e.removeChild(t):t&&i&&H(t,i,e);}}function H(e,n,o){if(j(e,n)){let c=n.__ownerInstance;if(c){let r=c.nodes.indexOf(n);r!==-1&&(c.nodes[r]=e),e.__ownerInstance=c,delete n.__ownerInstance;}e.nodeType===Node.TEXT_NODE?e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue):e.nodeType===Node.ELEMENT_NODE&&(k(e,n),F(e,n));}else o.replaceChild(n,e);}function P(e,n,o,c){let r=Math.max(e.length,n.length),a=[];for(let t=0;t<r;t++){let i=e[t],s=n[t];!i&&s?(o.insertBefore(s,c),a.push(s)):i&&!s?i.parentNode&&o.removeChild(i):i&&s&&(H(i,s,o),a.push(i));}return a}function $(e,n){n.innerHTML="",typeof e=="function"&&(e={type:e,props:{},children:[],key:void 0}),y(e,n);}export{P as a,$ as b};//# sourceMappingURL=chunk-JUP6RTZA.mjs.map
2
+ //# sourceMappingURL=chunk-JUP6RTZA.mjs.map