flexium 0.13.1 → 0.14.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.
- package/dist/{chunk-NY6NOGFU.mjs → chunk-J3542Z77.mjs} +2 -2
- package/dist/chunk-J3542Z77.mjs.map +1 -0
- package/dist/{chunk-DUGPBZZ3.js → chunk-LHOIM4QY.js} +2 -2
- package/dist/chunk-LHOIM4QY.js.map +1 -0
- package/dist/core.d.cts +6 -1
- package/dist/core.d.ts +6 -1
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/dom.d.cts +1 -10
- package/dist/dom.d.ts +1 -10
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/dom.mjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-dev-runtime.mjs +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/router.js +1 -1
- package/dist/router.js.map +1 -1
- package/dist/router.mjs +1 -1
- package/dist/router.mjs.map +1 -1
- package/package.json +2 -17
- package/dist/canvas.d.cts +0 -84
- package/dist/canvas.d.ts +0 -84
- package/dist/canvas.js +0 -2
- package/dist/canvas.js.map +0 -1
- package/dist/canvas.mjs +0 -2
- package/dist/canvas.mjs.map +0 -1
- package/dist/chunk-DUGPBZZ3.js.map +0 -1
- package/dist/chunk-NY6NOGFU.mjs.map +0 -1
- package/dist/interactive.d.cts +0 -84
- package/dist/interactive.d.ts +0 -84
- package/dist/interactive.js +0 -2
- package/dist/interactive.js.map +0 -1
- package/dist/interactive.mjs +0 -2
- package/dist/interactive.mjs.map +0 -1
package/dist/metafile-esm.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/index.ts":{"bytes":67,"imports":[],"format":"esm"},"src/core/lifecycle.ts":{"bytes":2686,"imports":[],"format":"esm"},"src/core/reactive.ts":{"bytes":2080,"imports":[{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"./lifecycle"}],"format":"esm"},"src/core/hook.ts":{"bytes":986,"imports":[],"format":"esm"},"src/core/devtools.ts":{"bytes":1841,"imports":[],"format":"esm"},"src/core/context.ts":{"bytes":1918,"imports":[],"format":"esm"},"src/core/use.ts":{"bytes":8125,"imports":[{"path":"src/core/reactive.ts","kind":"import-statement","original":"./reactive"},{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"./lifecycle"},{"path":"src/core/hook.ts","kind":"import-statement","original":"./hook"},{"path":"src/core/devtools.ts","kind":"import-statement","original":"./devtools"},{"path":"src/core/context.ts","kind":"import-statement","original":"./context"},{"path":"src/core/context.ts","kind":"import-statement","original":"./context"}],"format":"esm"},"src/core/ref.ts":{"bytes":812,"imports":[{"path":"src/core/hook.ts","kind":"import-statement","original":"./hook"}],"format":"esm"},"src/core/index.ts":{"bytes":315,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"./use"},{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"./lifecycle"},{"path":"src/core/ref.ts","kind":"import-statement","original":"./ref"},{"path":"src/core/context.ts","kind":"import-statement","original":"./context"}],"format":"esm"},"src/dom/f.ts":{"bytes":285,"imports":[],"format":"esm"},"src/dom/render.ts":{"bytes":15127,"imports":[{"path":"src/core/context.ts","kind":"import-statement","original":"../core/context"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../core/hook"},{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"../core/lifecycle"}],"format":"esm"},"src/dom/hydrate.ts":{"bytes":9324,"imports":[{"path":"src/core/hook.ts","kind":"import-statement","original":"../core/hook"},{"path":"src/core/context.ts","kind":"import-statement","original":"../core/context"},{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"../core/lifecycle"},{"path":"src/dom/render.ts","kind":"dynamic-import","original":"./render"}],"format":"esm"},"src/dom/components/Portal.tsx":{"bytes":1937,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../../core/hook"},{"path":"src/dom/render.ts","kind":"import-statement","original":"../render"}],"format":"esm"},"src/dom/components/suspenseContext.ts":{"bytes":412,"imports":[{"path":"src/core/context.ts","kind":"import-statement","original":"../../core/context"},{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"}],"format":"esm"},"src/dom/components/Suspense.tsx":{"bytes":1770,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../../core/hook"},{"path":"src/dom/components/suspenseContext.ts","kind":"import-statement","original":"./suspenseContext"}],"format":"esm"},"src/dom/components/ErrorBoundary.tsx":{"bytes":2854,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../../core/hook"}],"format":"esm"},"src/dom/components/lazy.ts":{"bytes":1767,"imports":[{"path":"src/dom/components/suspenseContext.ts","kind":"import-statement","original":"./suspenseContext"}],"format":"esm"},"src/dom/components/index.ts":{"bytes":598,"imports":[{"path":"src/dom/components/Portal.tsx","kind":"import-statement","original":"./Portal"},{"path":"src/dom/components/Suspense.tsx","kind":"import-statement","original":"./Suspense"},{"path":"src/dom/components/ErrorBoundary.tsx","kind":"import-statement","original":"./ErrorBoundary"},{"path":"src/dom/components/lazy.ts","kind":"import-statement","original":"./lazy"},{"path":"src/dom/components/suspenseContext.ts","kind":"import-statement","original":"./suspenseContext"},{"path":"src/dom/components/ErrorBoundary.tsx","kind":"import-statement","original":"./ErrorBoundary"}],"format":"esm"},"src/dom/index.ts":{"bytes":457,"imports":[{"path":"src/dom/f.ts","kind":"import-statement","original":"./f"},{"path":"src/dom/render.ts","kind":"import-statement","original":"./render"},{"path":"src/dom/hydrate.ts","kind":"import-statement","original":"./hydrate"},{"path":"src/dom/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"},"src/server/escape.ts":{"bytes":364,"imports":[],"format":"esm"},"src/server/serverState.ts":{"bytes":896,"imports":[],"format":"esm"},"src/server/renderToString.ts":{"bytes":6572,"imports":[{"path":"src/server/escape.ts","kind":"import-statement","original":"./escape"},{"path":"src/server/serverState.ts","kind":"import-statement","original":"./serverState"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../core/hook"},{"path":"src/core/context.ts","kind":"import-statement","original":"../core/context"}],"format":"esm"},"src/server/index.ts":{"bytes":243,"imports":[{"path":"src/server/renderToString.ts","kind":"import-statement","original":"./renderToString"},{"path":"src/server/serverState.ts","kind":"import-statement","original":"./serverState"}],"format":"esm"},"src/router/types.ts":{"bytes":807,"imports":[],"format":"esm"},"src/router/utils.ts":{"bytes":3745,"imports":[{"path":"./types","kind":"import-statement","external":true}],"format":"esm"},"src/router/router.ts":{"bytes":3207,"imports":[{"path":"src/core/reactive.ts","kind":"import-statement","original":"../core/reactive"},{"path":"src/core/context.ts","kind":"import-statement","original":"../core/context"},{"path":"src/core/use.ts","kind":"import-statement","original":"../core/use"},{"path":"src/router/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/jsx-runtime.ts":{"bytes":735,"imports":[],"format":"esm"},"src/router/dom/Route.tsx":{"bytes":106,"imports":[],"format":"esm"},"src/router/dom/Routes.tsx":{"bytes":2584,"imports":[{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"../../jsx-runtime"},{"path":"src/router/router.ts","kind":"import-statement","original":"../router"},{"path":"src/router/utils.ts","kind":"import-statement","original":"../utils"},{"path":"src/router/dom/Route.tsx","kind":"import-statement","original":"./Route"}],"format":"esm"},"src/router/dom/Outlet.tsx":{"bytes":744,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"../../jsx-runtime"},{"path":"src/router/router.ts","kind":"import-statement","original":"../router"}],"format":"esm"},"src/router/dom/Link.tsx":{"bytes":447,"imports":[{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"../../jsx-runtime"},{"path":"src/router/router.ts","kind":"import-statement","original":"../router"}],"format":"esm"},"src/router/index.ts":{"bytes":309,"imports":[{"path":"src/router/types.ts","kind":"import-statement","original":"./types"},{"path":"src/router/router.ts","kind":"import-statement","original":"./router"},{"path":"src/router/dom/Routes.tsx","kind":"import-statement","original":"./dom/Routes"},{"path":"src/router/dom/Route.tsx","kind":"import-statement","original":"./dom/Route"},{"path":"src/router/dom/Outlet.tsx","kind":"import-statement","original":"./dom/Outlet"},{"path":"src/router/dom/Link.tsx","kind":"import-statement","original":"./dom/Link"}],"format":"esm"},"src/canvas/Canvas.tsx":{"bytes":5526,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../core/use"},{"path":"src/core/reactive.ts","kind":"import-statement","original":"../core/reactive"},{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"flexium/jsx-runtime"}],"format":"esm"},"src/canvas/dom/DrawRect.tsx":{"bytes":293,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/canvas/Canvas.tsx","kind":"import-statement","original":"../Canvas"}],"format":"esm"},"src/canvas/dom/DrawCircle.tsx":{"bytes":303,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/canvas/Canvas.tsx","kind":"import-statement","original":"../Canvas"}],"format":"esm"},"src/canvas/dom/DrawArc.tsx":{"bytes":288,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/canvas/Canvas.tsx","kind":"import-statement","original":"../Canvas"}],"format":"esm"},"src/canvas/dom/DrawLine.tsx":{"bytes":293,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/canvas/Canvas.tsx","kind":"import-statement","original":"../Canvas"}],"format":"esm"},"src/canvas/dom/DrawText.tsx":{"bytes":293,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/canvas/Canvas.tsx","kind":"import-statement","original":"../Canvas"}],"format":"esm"},"src/canvas/dom/DrawPath.tsx":{"bytes":293,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/canvas/Canvas.tsx","kind":"import-statement","original":"../Canvas"}],"format":"esm"},"src/canvas/index.ts":{"bytes":427,"imports":[{"path":"src/canvas/Canvas.tsx","kind":"import-statement","original":"./Canvas"},{"path":"src/canvas/dom/DrawRect.tsx","kind":"import-statement","original":"./dom/DrawRect"},{"path":"src/canvas/dom/DrawCircle.tsx","kind":"import-statement","original":"./dom/DrawCircle"},{"path":"src/canvas/dom/DrawArc.tsx","kind":"import-statement","original":"./dom/DrawArc"},{"path":"src/canvas/dom/DrawLine.tsx","kind":"import-statement","original":"./dom/DrawLine"},{"path":"src/canvas/dom/DrawText.tsx","kind":"import-statement","original":"./dom/DrawText"},{"path":"src/canvas/dom/DrawPath.tsx","kind":"import-statement","original":"./dom/DrawPath"}],"format":"esm"},"src/interactive/loop.ts":{"bytes":1687,"imports":[],"format":"esm"},"src/interactive/types.ts":{"bytes":1937,"imports":[],"format":"esm"},"src/interactive/keyboard.ts":{"bytes":2398,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../core/use"},{"path":"src/interactive/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/interactive/mouse.ts":{"bytes":3174,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../core/use"},{"path":"src/interactive/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/interactive/index.ts":{"bytes":215,"imports":[{"path":"src/interactive/loop.ts","kind":"import-statement","original":"./loop"},{"path":"src/interactive/keyboard.ts","kind":"import-statement","original":"./keyboard"},{"path":"src/interactive/mouse.ts","kind":"import-statement","original":"./mouse"}],"format":"esm"},"src/jsx-dev-runtime.ts":{"bytes":211,"imports":[{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"./jsx-runtime"}],"format":"esm"}},"outputs":{"dist/jsx-dev-runtime.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":510},"dist/jsx-dev-runtime.mjs":{"imports":[{"path":"dist/chunk-NY6NOGFU.mjs","kind":"import-statement"}],"exports":["Fragment","jsxDEV"],"entryPoint":"src/jsx-dev-runtime.ts","inputs":{"src/jsx-dev-runtime.ts":{"bytesInOutput":40}},"bytes":123},"dist/render-4HB53K66.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/render-4HB53K66.mjs":{"imports":[{"path":"dist/chunk-TP5HUAIN.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["reconcile","render"],"entryPoint":"src/dom/render.ts","inputs":{},"bytes":132},"dist/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":204},"dist/index.mjs":{"imports":[],"exports":["VERSION"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":15}},"bytes":37},"dist/core.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1066},"dist/core.mjs":{"imports":[{"path":"dist/chunk-3AKECLKA.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["Context","sync","use","useRef"],"entryPoint":"src/core/index.ts","inputs":{"src/core/index.ts":{"bytesInOutput":0},"src/core/ref.ts":{"bytesInOutput":42}},"bytes":225},"dist/dom.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":27792},"dist/dom.mjs":{"imports":[{"path":"dist/chunk-TP5HUAIN.mjs","kind":"import-statement"},{"path":"dist/chunk-3AKECLKA.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"},{"path":"dist/render-4HB53K66.mjs","kind":"dynamic-import"}],"exports":["ErrorBoundary","Portal","Suspense","f","hydrate","lazy","reconcile","render","suspenseContext"],"entryPoint":"src/dom/index.ts","inputs":{"src/dom/f.ts":{"bytesInOutput":70},"src/dom/index.ts":{"bytesInOutput":0},"src/dom/hydrate.ts":{"bytesInOutput":2734},"src/dom/components/Portal.tsx":{"bytesInOutput":500},"src/dom/components/index.ts":{"bytesInOutput":0},"src/dom/components/suspenseContext.ts":{"bytesInOutput":84},"src/dom/components/Suspense.tsx":{"bytesInOutput":293},"src/dom/components/ErrorBoundary.tsx":{"bytesInOutput":500},"src/dom/components/lazy.ts":{"bytesInOutput":249}},"bytes":4761},"dist/chunk-TP5HUAIN.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23945},"dist/chunk-TP5HUAIN.mjs":{"imports":[{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["a","b"],"inputs":{"src/dom/render.ts":{"bytesInOutput":4853}},"bytes":4965},"dist/server.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12945},"dist/server.mjs":{"imports":[{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["getIsServer","renderToStaticMarkup","renderToString"],"entryPoint":"src/server/index.ts","inputs":{"src/server/escape.ts":{"bytesInOutput":157},"src/server/serverState.ts":{"bytesInOutput":186},"src/server/renderToString.ts":{"bytesInOutput":2125},"src/server/index.ts":{"bytesInOutput":0}},"bytes":2595},"dist/router.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17327},"dist/router.mjs":{"imports":[{"path":"dist/chunk-3AKECLKA.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"},{"path":"dist/chunk-NY6NOGFU.mjs","kind":"import-statement"}],"exports":["Link","Outlet","Route","Routes","useLocation","useNavigate","useParams","useQuery","useRouter"],"entryPoint":"src/router/index.ts","inputs":{"src/router/index.ts":{"bytesInOutput":0},"src/router/utils.ts":{"bytesInOutput":1073},"src/router/router.ts":{"bytesInOutput":859},"src/router/dom/Route.tsx":{"bytesInOutput":26},"src/router/dom/Routes.tsx":{"bytesInOutput":638},"src/router/dom/Outlet.tsx":{"bytesInOutput":244},"src/router/dom/Link.tsx":{"bytesInOutput":133}},"bytes":3259},"dist/canvas.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12688},"dist/canvas.mjs":{"imports":[{"path":"dist/chunk-3AKECLKA.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"},{"path":"dist/chunk-NY6NOGFU.mjs","kind":"import-statement"}],"exports":["Canvas","DrawArc","DrawCircle","DrawLine","DrawPath","DrawRect","DrawText"],"entryPoint":"src/canvas/index.ts","inputs":{"src/canvas/Canvas.tsx":{"bytesInOutput":1875},"src/canvas/index.ts":{"bytesInOutput":0},"src/canvas/dom/DrawRect.tsx":{"bytesInOutput":60},"src/canvas/dom/DrawCircle.tsx":{"bytesInOutput":62},"src/canvas/dom/DrawArc.tsx":{"bytesInOutput":59},"src/canvas/dom/DrawLine.tsx":{"bytesInOutput":60},"src/canvas/dom/DrawText.tsx":{"bytesInOutput":60},"src/canvas/dom/DrawPath.tsx":{"bytesInOutput":60}},"bytes":2489},"dist/interactive.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":15153},"dist/interactive.mjs":{"imports":[{"path":"dist/chunk-3AKECLKA.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["Keys","MouseButton","useKeyboard","useLoop","useMouse"],"entryPoint":"src/interactive/index.ts","inputs":{"src/interactive/loop.ts":{"bytesInOutput":459},"src/interactive/index.ts":{"bytesInOutput":0},"src/interactive/types.ts":{"bytesInOutput":701},"src/interactive/keyboard.ts":{"bytesInOutput":689},"src/interactive/mouse.ts":{"bytesInOutput":1150}},"bytes":3178},"dist/chunk-3AKECLKA.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18028},"dist/chunk-3AKECLKA.mjs":{"imports":[{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["a","b","c"],"inputs":{"src/core/reactive.ts":{"bytesInOutput":590},"src/core/devtools.ts":{"bytesInOutput":372},"src/core/use.ts":{"bytesInOutput":2043}},"bytes":3145},"dist/chunk-NRPWBHKP.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4599},"dist/chunk-NRPWBHKP.mjs":{"imports":[],"exports":["a","b","c","d","e"],"inputs":{"src/core/lifecycle.ts":{"bytesInOutput":813}},"bytes":857},"dist/chunk-MI76R42D.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4337},"dist/chunk-MI76R42D.mjs":{"imports":[],"exports":["a","b","c","d","e","f"],"inputs":{"src/core/hook.ts":{"bytesInOutput":227},"src/core/context.ts":{"bytesInOutput":307}},"bytes":585},"dist/jsx-runtime.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/jsx-runtime.mjs":{"imports":[{"path":"dist/chunk-NY6NOGFU.mjs","kind":"import-statement"}],"exports":["Fragment","jsx","jsxs"],"entryPoint":"src/jsx-runtime.ts","inputs":{},"bytes":82},"dist/chunk-NY6NOGFU.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1291},"dist/chunk-NY6NOGFU.mjs":{"imports":[],"exports":["a","b","c"],"inputs":{"src/jsx-runtime.ts":{"bytesInOutput":183}},"bytes":213}}}
|
|
1
|
+
{"inputs":{"src/index.ts":{"bytes":67,"imports":[],"format":"esm"},"src/core/lifecycle.ts":{"bytes":2686,"imports":[],"format":"esm"},"src/core/reactive.ts":{"bytes":2080,"imports":[{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"./lifecycle"}],"format":"esm"},"src/core/hook.ts":{"bytes":986,"imports":[],"format":"esm"},"src/core/devtools.ts":{"bytes":1841,"imports":[],"format":"esm"},"src/core/context.ts":{"bytes":1918,"imports":[],"format":"esm"},"src/core/use.ts":{"bytes":8125,"imports":[{"path":"src/core/reactive.ts","kind":"import-statement","original":"./reactive"},{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"./lifecycle"},{"path":"src/core/hook.ts","kind":"import-statement","original":"./hook"},{"path":"src/core/devtools.ts","kind":"import-statement","original":"./devtools"},{"path":"src/core/context.ts","kind":"import-statement","original":"./context"},{"path":"src/core/context.ts","kind":"import-statement","original":"./context"}],"format":"esm"},"src/core/ref.ts":{"bytes":812,"imports":[{"path":"src/core/hook.ts","kind":"import-statement","original":"./hook"}],"format":"esm"},"src/core/index.ts":{"bytes":441,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"./use"},{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"./lifecycle"},{"path":"src/core/ref.ts","kind":"import-statement","original":"./ref"},{"path":"src/core/context.ts","kind":"import-statement","original":"./context"},{"path":"src/core/reactive.ts","kind":"import-statement","original":"./reactive"}],"format":"esm"},"src/dom/f.ts":{"bytes":285,"imports":[],"format":"esm"},"src/dom/render.ts":{"bytes":15127,"imports":[{"path":"src/core/context.ts","kind":"import-statement","original":"../core/context"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../core/hook"},{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"../core/lifecycle"}],"format":"esm"},"src/dom/hydrate.ts":{"bytes":9324,"imports":[{"path":"src/core/hook.ts","kind":"import-statement","original":"../core/hook"},{"path":"src/core/context.ts","kind":"import-statement","original":"../core/context"},{"path":"src/core/lifecycle.ts","kind":"import-statement","original":"../core/lifecycle"},{"path":"src/dom/render.ts","kind":"dynamic-import","original":"./render"}],"format":"esm"},"src/dom/components/Portal.tsx":{"bytes":1937,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../../core/hook"},{"path":"src/dom/render.ts","kind":"import-statement","original":"../render"}],"format":"esm"},"src/dom/components/suspenseContext.ts":{"bytes":412,"imports":[{"path":"src/core/context.ts","kind":"import-statement","original":"../../core/context"},{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"}],"format":"esm"},"src/dom/components/Suspense.tsx":{"bytes":1770,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../../core/hook"},{"path":"src/dom/components/suspenseContext.ts","kind":"import-statement","original":"./suspenseContext"}],"format":"esm"},"src/dom/components/ErrorBoundary.tsx":{"bytes":2854,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../../core/hook"}],"format":"esm"},"src/dom/components/lazy.ts":{"bytes":1767,"imports":[{"path":"src/dom/components/suspenseContext.ts","kind":"import-statement","original":"./suspenseContext"}],"format":"esm"},"src/dom/components/index.ts":{"bytes":598,"imports":[{"path":"src/dom/components/Portal.tsx","kind":"import-statement","original":"./Portal"},{"path":"src/dom/components/Suspense.tsx","kind":"import-statement","original":"./Suspense"},{"path":"src/dom/components/ErrorBoundary.tsx","kind":"import-statement","original":"./ErrorBoundary"},{"path":"src/dom/components/lazy.ts","kind":"import-statement","original":"./lazy"},{"path":"src/dom/components/suspenseContext.ts","kind":"import-statement","original":"./suspenseContext"},{"path":"src/dom/components/ErrorBoundary.tsx","kind":"import-statement","original":"./ErrorBoundary"}],"format":"esm"},"src/dom/index.ts":{"bytes":373,"imports":[{"path":"src/dom/f.ts","kind":"import-statement","original":"./f"},{"path":"src/dom/render.ts","kind":"import-statement","original":"./render"},{"path":"src/dom/hydrate.ts","kind":"import-statement","original":"./hydrate"},{"path":"src/dom/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"},"src/server/escape.ts":{"bytes":364,"imports":[],"format":"esm"},"src/server/serverState.ts":{"bytes":896,"imports":[],"format":"esm"},"src/server/renderToString.ts":{"bytes":6572,"imports":[{"path":"src/server/escape.ts","kind":"import-statement","original":"./escape"},{"path":"src/server/serverState.ts","kind":"import-statement","original":"./serverState"},{"path":"src/core/hook.ts","kind":"import-statement","original":"../core/hook"},{"path":"src/core/context.ts","kind":"import-statement","original":"../core/context"}],"format":"esm"},"src/server/index.ts":{"bytes":243,"imports":[{"path":"src/server/renderToString.ts","kind":"import-statement","original":"./renderToString"},{"path":"src/server/serverState.ts","kind":"import-statement","original":"./serverState"}],"format":"esm"},"src/router/types.ts":{"bytes":807,"imports":[],"format":"esm"},"src/router/utils.ts":{"bytes":3745,"imports":[{"path":"./types","kind":"import-statement","external":true}],"format":"esm"},"src/router/router.ts":{"bytes":3207,"imports":[{"path":"src/core/reactive.ts","kind":"import-statement","original":"../core/reactive"},{"path":"src/core/context.ts","kind":"import-statement","original":"../core/context"},{"path":"src/core/use.ts","kind":"import-statement","original":"../core/use"},{"path":"src/router/utils.ts","kind":"import-statement","original":"./utils"}],"format":"esm"},"src/jsx-runtime.ts":{"bytes":741,"imports":[],"format":"esm"},"src/router/dom/Route.tsx":{"bytes":106,"imports":[],"format":"esm"},"src/router/dom/Routes.tsx":{"bytes":2590,"imports":[{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"../../jsx-runtime"},{"path":"src/router/router.ts","kind":"import-statement","original":"../router"},{"path":"src/router/utils.ts","kind":"import-statement","original":"../utils"},{"path":"src/router/dom/Route.tsx","kind":"import-statement","original":"./Route"}],"format":"esm"},"src/router/dom/Outlet.tsx":{"bytes":744,"imports":[{"path":"src/core/use.ts","kind":"import-statement","original":"../../core/use"},{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"../../jsx-runtime"},{"path":"src/router/router.ts","kind":"import-statement","original":"../router"}],"format":"esm"},"src/router/dom/Link.tsx":{"bytes":447,"imports":[{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"../../jsx-runtime"},{"path":"src/router/router.ts","kind":"import-statement","original":"../router"}],"format":"esm"},"src/router/index.ts":{"bytes":309,"imports":[{"path":"src/router/types.ts","kind":"import-statement","original":"./types"},{"path":"src/router/router.ts","kind":"import-statement","original":"./router"},{"path":"src/router/dom/Routes.tsx","kind":"import-statement","original":"./dom/Routes"},{"path":"src/router/dom/Route.tsx","kind":"import-statement","original":"./dom/Route"},{"path":"src/router/dom/Outlet.tsx","kind":"import-statement","original":"./dom/Outlet"},{"path":"src/router/dom/Link.tsx","kind":"import-statement","original":"./dom/Link"}],"format":"esm"},"src/jsx-dev-runtime.ts":{"bytes":211,"imports":[{"path":"src/jsx-runtime.ts","kind":"import-statement","original":"./jsx-runtime"}],"format":"esm"}},"outputs":{"dist/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":204},"dist/index.mjs":{"imports":[],"exports":["VERSION"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":15}},"bytes":37},"dist/core.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1066},"dist/core.mjs":{"imports":[{"path":"dist/chunk-3AKECLKA.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["Context","getContextValue","isReactive","popContext","pushContext","sync","use","useRef"],"entryPoint":"src/core/index.ts","inputs":{"src/core/index.ts":{"bytesInOutput":0},"src/core/ref.ts":{"bytesInOutput":42}},"bytes":323},"dist/dom.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":27792},"dist/dom.mjs":{"imports":[{"path":"dist/chunk-3AKECLKA.mjs","kind":"import-statement"},{"path":"dist/chunk-TP5HUAIN.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"},{"path":"dist/render-4HB53K66.mjs","kind":"dynamic-import"}],"exports":["ErrorBoundary","Portal","Suspense","f","hydrate","lazy","render"],"entryPoint":"src/dom/index.ts","inputs":{"src/dom/f.ts":{"bytesInOutput":70},"src/dom/index.ts":{"bytesInOutput":0},"src/dom/hydrate.ts":{"bytesInOutput":2734},"src/dom/components/Portal.tsx":{"bytesInOutput":500},"src/dom/components/index.ts":{"bytesInOutput":0},"src/dom/components/suspenseContext.ts":{"bytesInOutput":84},"src/dom/components/Suspense.tsx":{"bytesInOutput":293},"src/dom/components/ErrorBoundary.tsx":{"bytesInOutput":500},"src/dom/components/lazy.ts":{"bytesInOutput":249}},"bytes":4718},"dist/server.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12945},"dist/server.mjs":{"imports":[{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["getIsServer","renderToStaticMarkup","renderToString"],"entryPoint":"src/server/index.ts","inputs":{"src/server/escape.ts":{"bytesInOutput":157},"src/server/serverState.ts":{"bytesInOutput":186},"src/server/renderToString.ts":{"bytesInOutput":2125},"src/server/index.ts":{"bytesInOutput":0}},"bytes":2595},"dist/router.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":17333},"dist/router.mjs":{"imports":[{"path":"dist/chunk-3AKECLKA.mjs","kind":"import-statement"},{"path":"dist/chunk-J3542Z77.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["Link","Outlet","Route","Routes","useLocation","useNavigate","useParams","useQuery","useRouter"],"entryPoint":"src/router/index.ts","inputs":{"src/router/index.ts":{"bytesInOutput":0},"src/router/utils.ts":{"bytesInOutput":1073},"src/router/router.ts":{"bytesInOutput":859},"src/router/dom/Route.tsx":{"bytesInOutput":26},"src/router/dom/Routes.tsx":{"bytesInOutput":638},"src/router/dom/Outlet.tsx":{"bytesInOutput":244},"src/router/dom/Link.tsx":{"bytesInOutput":133}},"bytes":3259},"dist/chunk-3AKECLKA.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18028},"dist/chunk-3AKECLKA.mjs":{"imports":[{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["a","b","c"],"inputs":{"src/core/reactive.ts":{"bytesInOutput":590},"src/core/devtools.ts":{"bytesInOutput":372},"src/core/use.ts":{"bytesInOutput":2043}},"bytes":3145},"dist/jsx-runtime.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/jsx-runtime.mjs":{"imports":[{"path":"dist/chunk-J3542Z77.mjs","kind":"import-statement"}],"exports":["Fragment","jsx","jsxs"],"entryPoint":"src/jsx-runtime.ts","inputs":{},"bytes":82},"dist/jsx-dev-runtime.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":510},"dist/jsx-dev-runtime.mjs":{"imports":[{"path":"dist/chunk-J3542Z77.mjs","kind":"import-statement"}],"exports":["Fragment","jsxDEV"],"entryPoint":"src/jsx-dev-runtime.ts","inputs":{"src/jsx-dev-runtime.ts":{"bytesInOutput":40}},"bytes":123},"dist/chunk-J3542Z77.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1297},"dist/chunk-J3542Z77.mjs":{"imports":[],"exports":["a","b","c"],"inputs":{"src/jsx-runtime.ts":{"bytesInOutput":183}},"bytes":213},"dist/render-4HB53K66.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/render-4HB53K66.mjs":{"imports":[{"path":"dist/chunk-TP5HUAIN.mjs","kind":"import-statement"},{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["reconcile","render"],"entryPoint":"src/dom/render.ts","inputs":{},"bytes":132},"dist/chunk-TP5HUAIN.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23945},"dist/chunk-TP5HUAIN.mjs":{"imports":[{"path":"dist/chunk-NRPWBHKP.mjs","kind":"import-statement"},{"path":"dist/chunk-MI76R42D.mjs","kind":"import-statement"}],"exports":["a","b"],"inputs":{"src/dom/render.ts":{"bytesInOutput":4853}},"bytes":4965},"dist/chunk-NRPWBHKP.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4599},"dist/chunk-NRPWBHKP.mjs":{"imports":[],"exports":["a","b","c","d","e"],"inputs":{"src/core/lifecycle.ts":{"bytesInOutput":813}},"bytes":857},"dist/chunk-MI76R42D.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4337},"dist/chunk-MI76R42D.mjs":{"imports":[],"exports":["a","b","c","d","e","f"],"inputs":{"src/core/hook.ts":{"bytesInOutput":227},"src/core/context.ts":{"bytesInOutput":307}},"bytes":585}}}
|
package/dist/router.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkACYN2UKT_js=require('./chunk-ACYN2UKT.js')
|
|
1
|
+
'use strict';var chunkACYN2UKT_js=require('./chunk-ACYN2UKT.js'),chunkLHOIM4QY_js=require('./chunk-LHOIM4QY.js');require('./chunk-3CKIHQIE.js');var chunkE6Z7AI4J_js=require('./chunk-E6Z7AI4J.js');function k(t){if(!t)return {};if(typeof URLSearchParams<"u"){let e=new URLSearchParams(t),r={};return e.forEach((n,o)=>r[o]=n),r}return t.substring(1).split("&").reduce((e,r)=>{let[n,o]=r.split("=");return n&&(e[decodeURIComponent(n)]=decodeURIComponent(o||"")),e},{})}function D(t){return !!(t.length>2048||t.includes("__proto__")||t.includes("constructor")||/^\s*javascript:/i.test(t))}function R(t){let e=[];return t.forEach(r=>{if(!r)return;let{path:n,component:o,children:i,beforeEnter:f}=r.props||{},u={path:n||"/",component:o,beforeEnter:f};if(i){let c=Array.isArray(i)?i:[i];u.children=R(c);}!u.children&&r.children&&r.children.length>0&&(u.children=R(r.children)),e.push(u);}),e}function E(t,e){for(let r of t){let n=r.path,o=T(n,e);if(o)return [{route:r,params:o.params,pathname:o.path}]}return null}function T(t,e){let r=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(r.length!==n.length)return null;let o={};for(let i=0;i<r.length;i++){let f=r[i],u=n[i];if(f.startsWith(":")){let c=f.slice(1);o[c]=u;}else if(f!==u)return null}return {params:o,path:e}}var L=new chunkE6Z7AI4J_js.c(null),p=new chunkE6Z7AI4J_js.c(0),U=()=>({pathname:"/",search:"",hash:"",query:{}}),w=()=>typeof window>"u"?U():{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,query:k(window.location.search)},l=null,y=null,N=false;function d(){if(l&&y)return [l,y];l=chunkACYN2UKT_js.a(w());let t=e=>{l&&(l.pathname=e.pathname,l.search=e.search,l.hash=e.hash,l.query=e.query);};return y=e=>{if(typeof window>"u")return;if(D(e)){console.error("[Flexium Router] Blocked navigation to unsafe path:",e);return}window.history.pushState({},"",e);let r=w();t(r);},typeof window<"u"&&!N&&(window.addEventListener("popstate",()=>{t(w());}),N=true),[l,y]}function m(){let[t]=chunkACYN2UKT_js.c(L);if(!t)throw new Error("useRouter() must be called within a <Routes> component");return t}function j(){let[,t]=d();return t}function q(){return m().params}function _(){let[t]=d();return t.query}function x(t){return null}function F(t){return t&&typeof t=="object"&&("type"in t||Array.isArray(t))}function Q(t){let[e,r]=d(),n=Array.isArray(t.children)?t.children:[t.children],o=n.filter(s=>F(s)&&s.type===x),i=n.filter(s=>!F(s)||s.type!==x),f=R(o),u=e.pathname,c=E(f,u)||[],A=c.length>0?c[c.length-1].params:{},S={location:e,navigate:r,matches:c,params:A},C=null;if(c.length>0){let s=c[0],P=s.route.component,g=u;s.route.beforeEnter?s.route.beforeEnter(s.params)!==false&&(C=chunkLHOIM4QY_js.a(p.Provider,{value:1,key:g,children:chunkLHOIM4QY_js.a(P,{params:s.params,key:g})})):C=chunkLHOIM4QY_js.a(p.Provider,{value:1,key:g,children:chunkLHOIM4QY_js.a(P,{params:s.params,key:g})});}return chunkLHOIM4QY_js.a(L.Provider,{value:S,children:[...i,C]})}function B(){let t=m(),[e]=chunkACYN2UKT_js.c(p),r=e??0,[n]=chunkACYN2UKT_js.c(()=>t.matches);if(r>=n.length)return null;let o=n[r],i=o.route.component;return o.route.beforeEnter&&o.route.beforeEnter(o.params)===false?null:chunkLHOIM4QY_js.a(p.Provider,{value:r+1,children:chunkLHOIM4QY_js.a(i,{params:o.params})})}function M(t){let e=m();return chunkLHOIM4QY_js.a("a",{href:t.to,class:t.class,onclick:r=>{r.preventDefault(),e.navigate(t.to);},children:t.children})}exports.Link=M;exports.Outlet=B;exports.Route=x;exports.Routes=Q;exports.useLocation=d;exports.useNavigate=j;exports.useParams=q;exports.useQuery=_;exports.useRouter=m;//# sourceMappingURL=router.js.map
|
|
2
2
|
//# sourceMappingURL=router.js.map
|
package/dist/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/utils.ts","../src/router/router.ts","../src/router/dom/Route.tsx","../src/router/dom/Routes.tsx","../src/router/dom/Outlet.tsx","../src/router/dom/Link.tsx"],"names":["parseQuery","search","params","result","value","key","accumulator","part","isUnsafePath","path","createRoutesFromChildren","children","routes","child","component","subChildren","beforeEnter","route","nestedChildren","matchRoutes","locationPathname","routePath","matchResult","matchPath","locationPath","routeSegments","locationSegments","routeSegment","locationSegment","RouterCtx","Context","RouteDepthCtx","getDefaultLocation","getCurrentLocation","globalLocation","globalNavigate","popstateListenerAttached","useLocation","reactive","updateLocation","newLocation","useRouter","routerContext","use","useNavigate","navigate","useParams","useQuery","location","Route","_props","isFNode","node","Routes","props","currentLocation","childrenList","routeNodes","otherChildren","routeDefinitions","currentPath","matches","matchedContent","rootMatch","Component","routeKey","jsx","Outlet","depthValue","depth","match","Link","event"],"mappings":"oMAGA,SAASA,CAAAA,CAAWC,EAAwC,CAC1D,GAAI,CAACA,CAAAA,CAAQ,OAAO,EAAC,CACrB,GAAI,OAAO,eAAA,CAAoB,GAAA,CAAa,CAC1C,IAAMC,CAAAA,CAAS,IAAI,eAAA,CAAgBD,CAAM,CAAA,CACnCE,CAAAA,CAAiC,EAAC,CACxC,OAAAD,C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AAA,CAAOA,EAAM,KAAA,CACb,OAAA,CAAUkB,CAAAA,EAAiB,CACvBA,CAAAA,CAAM,cAAA,GACN9B,CAAAA,CAAc,QAAA,CAASY,EAAM,EAAE,EACnC,EACA,QAAA,CAAUA,CAAAA,CAAM,QACpB,CAAC,CACL","file":"router.js","sourcesContent":["import { RouteDefinition, RouteMatch } from './types'\n\n// Simple query parser (native URLSearchParams fallback) - internal use only\nfunction parseQuery(search: string): Record<string, string> {\n if (!search) return {}\n if (typeof URLSearchParams !== 'undefined') {\n const params = new URLSearchParams(search)\n const result: Record<string, string> = {}\n params.forEach((value, key) => result[key] = value)\n return result\n }\n return search\n .substring(1)\n .split('&')\n .reduce((accumulator, part) => {\n const [key, value] = part.split('=')\n if (key) accumulator[decodeURIComponent(key)] = decodeURIComponent(value || '')\n return accumulator\n }, {} as Record<string, string>)\n}\n\nfunction isUnsafePath(path: string): boolean {\n // Prevent prototype pollution or massive strings\n if (path.length > 2048) return true\n if (path.includes('__proto__') || path.includes('constructor')) return true\n // Basic XSS check for javascript: protocol\n if (/^\\s*javascript:/i.test(path)) return true\n return false\n}\n\n// Convert children FNodes to RouteDefinitions - internal use only\nfunction createRoutesFromChildren(children: any[]): RouteDefinition[] {\n const routes: RouteDefinition[] = []\n\n children.forEach(child => {\n if (!child) return\n\n // Assuming child is an FNode-like object (config)\n // In Flexium, Route component returns null, but 'createNode' isn't called here.\n // We are traversing the props passed to Router.\n\n const { path, component, children: subChildren, beforeEnter } = child.props || {}\n\n const route: RouteDefinition = {\n path: path || '/',\n component: component,\n beforeEnter\n }\n\n if (subChildren) {\n // If subChildren is array\n const nestedChildren = Array.isArray(subChildren) ? subChildren : [subChildren]\n // We expect the children of a Route to be other Routes\n // However, the 'children' prop in JSX might be the Route components themselves.\n route.children = createRoutesFromChildren(nestedChildren)\n }\n\n // Also check child.children if props.children is empty (direct FNode structure)\n if (!route.children && child.children && child.children.length > 0) {\n route.children = createRoutesFromChildren(child.children)\n }\n\n routes.push(route)\n })\n return routes\n}\n\n// Simple Matcher - internal use only\nfunction matchRoutes(routes: RouteDefinition[], locationPathname: string): RouteMatch[] | null {\n // We want to find the best matching branch\n\n for (const route of routes) {\n // 1. Match current segment\n // Simple exact match or parameter match logic needed?\n // Let's implement simple param matching: /user/:id\n\n const routePath = route.path\n\n const matchResult = matchPath(routePath, locationPathname)\n if (matchResult) {\n return [{ route, params: matchResult.params, pathname: matchResult.path }]\n }\n }\n return null\n}\n\nfunction matchPath(routePath: string, locationPath: string) {\n // 1. Split into segments\n const routeSegments = routePath.split('/').filter(Boolean)\n const locationSegments = locationPath.split('/').filter(Boolean)\n\n if (routeSegments.length !== locationSegments.length) return null\n\n const params: Record<string, string> = {}\n\n for (let i = 0; i < routeSegments.length; i++) {\n const routeSegment = routeSegments[i]\n const locationSegment = locationSegments[i]\n\n if (routeSegment.startsWith(':')) {\n const key = routeSegment.slice(1)\n params[key] = locationSegment\n } else if (routeSegment !== locationSegment) {\n return null\n }\n }\n\n return { params, path: locationPath }\n}\n\n// Export only what's needed by other router files\nexport { parseQuery, isUnsafePath, createRoutesFromChildren, matchRoutes }\n","import { reactive } from '../core/reactive'\nimport { Context } from '../core/context'\nimport { use } from '../core/use'\nimport type { Location, RouterContext } from './types'\nimport { parseQuery, isUnsafePath } from './utils'\n\n// Contexts\nexport const RouterCtx = new Context<RouterContext>(null as any)\nexport const RouteDepthCtx = new Context<number>(0)\n\n// Helper functions\nconst getDefaultLocation = (): Location => ({\n pathname: '/',\n search: '',\n hash: '',\n query: {},\n})\n\nconst getCurrentLocation = (): Location => {\n if (typeof window === 'undefined') {\n return getDefaultLocation()\n }\n return {\n pathname: window.location.pathname,\n search: window.location.search,\n hash: window.location.hash,\n query: parseQuery(window.location.search),\n }\n}\n\n// Global singleton location state\nlet globalLocation: Location | null = null\nlet globalNavigate: ((path: string) => void) | null = null\nlet popstateListenerAttached = false\n\n// Create location state and navigation (singleton pattern)\nexport function useLocation(): [Location, (path: string) => void] {\n // Return existing singleton if already created\n if (globalLocation && globalNavigate) {\n return [globalLocation, globalNavigate]\n }\n\n // Create a reactive location object (only once)\n globalLocation = reactive<Location>(getCurrentLocation())\n\n const updateLocation = (newLocation: Location) => {\n if (!globalLocation) return\n globalLocation.pathname = newLocation.pathname\n globalLocation.search = newLocation.search\n globalLocation.hash = newLocation.hash\n globalLocation.query = newLocation.query\n }\n\n globalNavigate = (path: string) => {\n if (typeof window === 'undefined') return\n if (isUnsafePath(path)) {\n console.error('[Flexium Router] Blocked navigation to unsafe path:', path)\n return\n }\n window.history.pushState({}, '', path)\n const newLocation = getCurrentLocation()\n updateLocation(newLocation)\n }\n\n // Listen to popstate (only once)\n if (typeof window !== 'undefined' && !popstateListenerAttached) {\n window.addEventListener('popstate', () => {\n updateLocation(getCurrentLocation())\n })\n popstateListenerAttached = true\n }\n\n return [globalLocation, globalNavigate]\n}\n\n// Router hook - returns full router context\nexport function useRouter(): RouterContext {\n const [routerContext] = use(RouterCtx)\n if (!routerContext) {\n throw new Error('useRouter() must be called within a <Routes> component')\n }\n return routerContext\n}\n\n// Navigate hook - returns navigate function\nexport function useNavigate(): (path: string) => void {\n const [, navigate] = useLocation()\n return navigate\n}\n\n// Params hook - returns route params\nexport function useParams<T extends Record<string, string> = Record<string, string>>(): T {\n const router = useRouter()\n return router.params as T\n}\n\n// Query hook - returns query params\nexport function useQuery<T extends Record<string, string> = Record<string, string>>(): T {\n const [location] = useLocation()\n return location.query as T\n}\n","import type { RouteProps } from '../types'\n\nexport function Route(_props: RouteProps) {\n return null\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { FNode, FNodeChild } from '../../dom'\nimport { RouterCtx, RouteDepthCtx, useLocation } from '../router'\nimport { createRoutesFromChildren, matchRoutes } from '../utils'\nimport { Route } from './Route'\n\nfunction isFNode(node: any): node is FNode {\n return node && typeof node === 'object' && ('type' in node || Array.isArray(node))\n}\n\nexport function Routes(props: { children: FNodeChild }) {\n const [currentLocation, navigate] = useLocation()\n\n // Parse children to find <Route> definitions and other content\n let childrenList: any[] = Array.isArray(props.children) ? props.children : [props.children]\n\n // Separate routes from other children (like Nav components)\n const routeNodes = childrenList.filter(child => isFNode(child) && child.type === Route)\n const otherChildren = childrenList.filter(child => !isFNode(child) || child.type !== Route)\n\n // Create route definitions\n const routeDefinitions = createRoutesFromChildren(routeNodes)\n\n // DIRECT access to currentLocation.pathname\n // This should trigger reactive tracking in the component's effect context\n const currentPath = currentLocation.pathname\n const matches = matchRoutes(routeDefinitions, currentPath) || []\n const params = matches.length > 0 ? matches[matches.length - 1].params : {}\n\n const routerContext = {\n location: currentLocation,\n navigate,\n matches: matches,\n params: params\n }\n\n // Render matched component\n let matchedContent: FNodeChild = null\n\n if (matches.length > 0) {\n const rootMatch = matches[0]\n const Component = rootMatch.route.component\n\n // Use pathname as key to force re-mount on route change\n const routeKey = currentPath\n\n // Guard Check\n if (rootMatch.route.beforeEnter) {\n const result = rootMatch.route.beforeEnter(rootMatch.params)\n if (result !== false) {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n } else {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n }\n\n return f(RouterCtx.Provider, {\n value: routerContext,\n children: [...otherChildren, matchedContent]\n })\n}\n","import { use } from '../../core/use'\nimport { jsx as f } from '../../jsx-runtime'\nimport { RouteDepthCtx, useRouter } from '../router'\n\nexport function Outlet() {\n const routerContext = useRouter()\n const [depthValue] = use(RouteDepthCtx)\n const depth = depthValue ?? 0\n\n const [matches] = use(() => routerContext.matches)\n\n if (depth >= matches.length) return null\n\n const match = matches[depth]\n const Component = match.route.component\n\n // Guard\n if (match.route.beforeEnter) {\n if (match.route.beforeEnter(match.params) === false) return null\n }\n\n // Render next level\n return f(RouteDepthCtx.Provider, {\n value: depth + 1,\n children: f(Component, { params: match.params })\n })\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { LinkProps } from '../types'\nimport { useRouter } from '../router'\n\nexport function Link(props: LinkProps) {\n const routerContext = useRouter()\n return f('a', {\n href: props.to,\n class: props.class,\n onclick: (event: Event) => {\n event.preventDefault()\n routerContext.navigate(props.to)\n },\n children: props.children\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/router/utils.ts","../src/router/router.ts","../src/router/dom/Route.tsx","../src/router/dom/Routes.tsx","../src/router/dom/Outlet.tsx","../src/router/dom/Link.tsx"],"names":["parseQuery","search","params","result","value","key","accumulator","part","isUnsafePath","path","createRoutesFromChildren","children","routes","child","component","subChildren","beforeEnter","route","nestedChildren","matchRoutes","locationPathname","routePath","matchResult","matchPath","locationPath","routeSegments","locationSegments","routeSegment","locationSegment","RouterCtx","Context","RouteDepthCtx","getDefaultLocation","getCurrentLocation","globalLocation","globalNavigate","popstateListenerAttached","useLocation","reactive","updateLocation","newLocation","useRouter","routerContext","use","useNavigate","navigate","useParams","useQuery","location","Route","_props","isFNode","node","Routes","props","currentLocation","childrenList","routeNodes","otherChildren","routeDefinitions","currentPath","matches","matchedContent","rootMatch","Component","routeKey","jsx","Outlet","depthValue","depth","match","Link","event"],"mappings":"oMAGA,SAASA,CAAAA,CAAWC,EAAwC,CAC1D,GAAI,CAACA,CAAAA,CAAQ,OAAO,EAAC,CACrB,GAAI,OAAO,eAAA,CAAoB,GAAA,CAAa,CAC1C,IAAMC,CAAAA,CAAS,IAAI,eAAA,CAAgBD,CAAM,CAAA,CACnCE,CAAAA,CAAiC,EAAC,CACxC,OAAAD,CAAAA,CAAO,OAAA,CAAQ,CAACE,CAAAA,CAAOC,CAAAA,GAAQF,EAAOE,CAAG,CAAA,CAAID,CAAK,CAAA,CAC3CD,CACT,CACA,OAAOF,CAAAA,CACJ,UAAU,CAAC,CAAA,CACX,MAAM,GAAG,CAAA,CACT,MAAA,CAAO,CAACK,CAAAA,CAAaC,CAAAA,GAAS,CAC7B,GAAM,CAACF,EAAKD,CAAK,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AAErC,CAAAA,CAAU,QAAA,CAAU,CACzB,KAAA,CAAOa,CAAAA,CACP,SAAU,CAAC,GAAGgB,EAAeI,CAAc,CAC/C,CAAC,CACL,CCjEO,SAASK,CAAAA,EAAS,CACrB,IAAMzB,EAAgBD,CAAAA,EAAU,CAC1B,CAAC2B,CAAU,CAAA,CAAIzB,mBAAIZ,CAAa,CAAA,CAChCsC,EAAQD,CAAAA,EAAc,CAAA,CAEtB,CAACP,CAAO,CAAA,CAAIlB,mBAAI,IAAMD,CAAAA,CAAc,OAAO,CAAA,CAEjD,GAAI2B,CAAAA,EAASR,CAAAA,CAAQ,MAAA,CAAQ,OAAO,KAEpC,IAAMS,CAAAA,CAAQT,EAAQQ,CAAK,CAAA,CACrBL,EAAYM,CAAAA,CAAM,KAAA,CAAM,SAAA,CAG9B,OAAIA,CAAAA,CAAM,KAAA,CAAM,aACRA,CAAAA,CAAM,KAAA,CAAM,YAAYA,CAAAA,CAAM,MAAM,IAAM,KAAA,CAAc,IAAA,CAIzDJ,kBAAAA,CAAEnC,CAAAA,CAAc,QAAA,CAAU,CAC7B,MAAOsC,CAAAA,CAAQ,CAAA,CACf,SAAUH,kBAAAA,CAAEF,CAAAA,CAAW,CAAE,MAAA,CAAQM,CAAAA,CAAM,MAAO,CAAC,CACnD,CAAC,CACL,CCtBO,SAASC,CAAAA,CAAKjB,CAAAA,CAAkB,CACnC,IAAMZ,CAAAA,CAAgBD,CAAAA,EAAU,CAChC,OAAOyB,kBAAAA,CAAE,IAAK,CACV,IAAA,CAAMZ,EAAM,EAAA,CACZ,KAAA,CAAOA,EAAM,KAAA,CACb,OAAA,CAAUkB,CAAAA,EAAiB,CACvBA,CAAAA,CAAM,cAAA,GACN9B,CAAAA,CAAc,QAAA,CAASY,EAAM,EAAE,EACnC,EACA,QAAA,CAAUA,CAAAA,CAAM,QACpB,CAAC,CACL","file":"router.js","sourcesContent":["import { RouteDefinition, RouteMatch } from './types'\n\n// Simple query parser (native URLSearchParams fallback) - internal use only\nfunction parseQuery(search: string): Record<string, string> {\n if (!search) return {}\n if (typeof URLSearchParams !== 'undefined') {\n const params = new URLSearchParams(search)\n const result: Record<string, string> = {}\n params.forEach((value, key) => result[key] = value)\n return result\n }\n return search\n .substring(1)\n .split('&')\n .reduce((accumulator, part) => {\n const [key, value] = part.split('=')\n if (key) accumulator[decodeURIComponent(key)] = decodeURIComponent(value || '')\n return accumulator\n }, {} as Record<string, string>)\n}\n\nfunction isUnsafePath(path: string): boolean {\n // Prevent prototype pollution or massive strings\n if (path.length > 2048) return true\n if (path.includes('__proto__') || path.includes('constructor')) return true\n // Basic XSS check for javascript: protocol\n if (/^\\s*javascript:/i.test(path)) return true\n return false\n}\n\n// Convert children FNodes to RouteDefinitions - internal use only\nfunction createRoutesFromChildren(children: any[]): RouteDefinition[] {\n const routes: RouteDefinition[] = []\n\n children.forEach(child => {\n if (!child) return\n\n // Assuming child is an FNode-like object (config)\n // In Flexium, Route component returns null, but 'createNode' isn't called here.\n // We are traversing the props passed to Router.\n\n const { path, component, children: subChildren, beforeEnter } = child.props || {}\n\n const route: RouteDefinition = {\n path: path || '/',\n component: component,\n beforeEnter\n }\n\n if (subChildren) {\n // If subChildren is array\n const nestedChildren = Array.isArray(subChildren) ? subChildren : [subChildren]\n // We expect the children of a Route to be other Routes\n // However, the 'children' prop in JSX might be the Route components themselves.\n route.children = createRoutesFromChildren(nestedChildren)\n }\n\n // Also check child.children if props.children is empty (direct FNode structure)\n if (!route.children && child.children && child.children.length > 0) {\n route.children = createRoutesFromChildren(child.children)\n }\n\n routes.push(route)\n })\n return routes\n}\n\n// Simple Matcher - internal use only\nfunction matchRoutes(routes: RouteDefinition[], locationPathname: string): RouteMatch[] | null {\n // We want to find the best matching branch\n\n for (const route of routes) {\n // 1. Match current segment\n // Simple exact match or parameter match logic needed?\n // Let's implement simple param matching: /user/:id\n\n const routePath = route.path\n\n const matchResult = matchPath(routePath, locationPathname)\n if (matchResult) {\n return [{ route, params: matchResult.params, pathname: matchResult.path }]\n }\n }\n return null\n}\n\nfunction matchPath(routePath: string, locationPath: string) {\n // 1. Split into segments\n const routeSegments = routePath.split('/').filter(Boolean)\n const locationSegments = locationPath.split('/').filter(Boolean)\n\n if (routeSegments.length !== locationSegments.length) return null\n\n const params: Record<string, string> = {}\n\n for (let i = 0; i < routeSegments.length; i++) {\n const routeSegment = routeSegments[i]\n const locationSegment = locationSegments[i]\n\n if (routeSegment.startsWith(':')) {\n const key = routeSegment.slice(1)\n params[key] = locationSegment\n } else if (routeSegment !== locationSegment) {\n return null\n }\n }\n\n return { params, path: locationPath }\n}\n\n// Export only what's needed by other router files\nexport { parseQuery, isUnsafePath, createRoutesFromChildren, matchRoutes }\n","import { reactive } from '../core/reactive'\nimport { Context } from '../core/context'\nimport { use } from '../core/use'\nimport type { Location, RouterContext } from './types'\nimport { parseQuery, isUnsafePath } from './utils'\n\n// Contexts\nexport const RouterCtx = new Context<RouterContext>(null as any)\nexport const RouteDepthCtx = new Context<number>(0)\n\n// Helper functions\nconst getDefaultLocation = (): Location => ({\n pathname: '/',\n search: '',\n hash: '',\n query: {},\n})\n\nconst getCurrentLocation = (): Location => {\n if (typeof window === 'undefined') {\n return getDefaultLocation()\n }\n return {\n pathname: window.location.pathname,\n search: window.location.search,\n hash: window.location.hash,\n query: parseQuery(window.location.search),\n }\n}\n\n// Global singleton location state\nlet globalLocation: Location | null = null\nlet globalNavigate: ((path: string) => void) | null = null\nlet popstateListenerAttached = false\n\n// Create location state and navigation (singleton pattern)\nexport function useLocation(): [Location, (path: string) => void] {\n // Return existing singleton if already created\n if (globalLocation && globalNavigate) {\n return [globalLocation, globalNavigate]\n }\n\n // Create a reactive location object (only once)\n globalLocation = reactive<Location>(getCurrentLocation())\n\n const updateLocation = (newLocation: Location) => {\n if (!globalLocation) return\n globalLocation.pathname = newLocation.pathname\n globalLocation.search = newLocation.search\n globalLocation.hash = newLocation.hash\n globalLocation.query = newLocation.query\n }\n\n globalNavigate = (path: string) => {\n if (typeof window === 'undefined') return\n if (isUnsafePath(path)) {\n console.error('[Flexium Router] Blocked navigation to unsafe path:', path)\n return\n }\n window.history.pushState({}, '', path)\n const newLocation = getCurrentLocation()\n updateLocation(newLocation)\n }\n\n // Listen to popstate (only once)\n if (typeof window !== 'undefined' && !popstateListenerAttached) {\n window.addEventListener('popstate', () => {\n updateLocation(getCurrentLocation())\n })\n popstateListenerAttached = true\n }\n\n return [globalLocation, globalNavigate]\n}\n\n// Router hook - returns full router context\nexport function useRouter(): RouterContext {\n const [routerContext] = use(RouterCtx)\n if (!routerContext) {\n throw new Error('useRouter() must be called within a <Routes> component')\n }\n return routerContext\n}\n\n// Navigate hook - returns navigate function\nexport function useNavigate(): (path: string) => void {\n const [, navigate] = useLocation()\n return navigate\n}\n\n// Params hook - returns route params\nexport function useParams<T extends Record<string, string> = Record<string, string>>(): T {\n const router = useRouter()\n return router.params as T\n}\n\n// Query hook - returns query params\nexport function useQuery<T extends Record<string, string> = Record<string, string>>(): T {\n const [location] = useLocation()\n return location.query as T\n}\n","import type { RouteProps } from '../types'\n\nexport function Route(_props: RouteProps) {\n return null\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { FNode, FNodeChild } from '../../dom/types'\nimport { RouterCtx, RouteDepthCtx, useLocation } from '../router'\nimport { createRoutesFromChildren, matchRoutes } from '../utils'\nimport { Route } from './Route'\n\nfunction isFNode(node: any): node is FNode {\n return node && typeof node === 'object' && ('type' in node || Array.isArray(node))\n}\n\nexport function Routes(props: { children: FNodeChild }) {\n const [currentLocation, navigate] = useLocation()\n\n // Parse children to find <Route> definitions and other content\n let childrenList: any[] = Array.isArray(props.children) ? props.children : [props.children]\n\n // Separate routes from other children (like Nav components)\n const routeNodes = childrenList.filter(child => isFNode(child) && child.type === Route)\n const otherChildren = childrenList.filter(child => !isFNode(child) || child.type !== Route)\n\n // Create route definitions\n const routeDefinitions = createRoutesFromChildren(routeNodes)\n\n // DIRECT access to currentLocation.pathname\n // This should trigger reactive tracking in the component's effect context\n const currentPath = currentLocation.pathname\n const matches = matchRoutes(routeDefinitions, currentPath) || []\n const params = matches.length > 0 ? matches[matches.length - 1].params : {}\n\n const routerContext = {\n location: currentLocation,\n navigate,\n matches: matches,\n params: params\n }\n\n // Render matched component\n let matchedContent: FNodeChild = null\n\n if (matches.length > 0) {\n const rootMatch = matches[0]\n const Component = rootMatch.route.component\n\n // Use pathname as key to force re-mount on route change\n const routeKey = currentPath\n\n // Guard Check\n if (rootMatch.route.beforeEnter) {\n const result = rootMatch.route.beforeEnter(rootMatch.params)\n if (result !== false) {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n } else {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n }\n\n return f(RouterCtx.Provider, {\n value: routerContext,\n children: [...otherChildren, matchedContent]\n })\n}\n","import { use } from '../../core/use'\nimport { jsx as f } from '../../jsx-runtime'\nimport { RouteDepthCtx, useRouter } from '../router'\n\nexport function Outlet() {\n const routerContext = useRouter()\n const [depthValue] = use(RouteDepthCtx)\n const depth = depthValue ?? 0\n\n const [matches] = use(() => routerContext.matches)\n\n if (depth >= matches.length) return null\n\n const match = matches[depth]\n const Component = match.route.component\n\n // Guard\n if (match.route.beforeEnter) {\n if (match.route.beforeEnter(match.params) === false) return null\n }\n\n // Render next level\n return f(RouteDepthCtx.Provider, {\n value: depth + 1,\n children: f(Component, { params: match.params })\n })\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { LinkProps } from '../types'\nimport { useRouter } from '../router'\n\nexport function Link(props: LinkProps) {\n const routerContext = useRouter()\n return f('a', {\n href: props.to,\n class: props.class,\n onclick: (event: Event) => {\n event.preventDefault()\n routerContext.navigate(props.to)\n },\n children: props.children\n })\n}\n"]}
|
package/dist/router.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,c as c$1}from'./chunk-3AKECLKA.mjs';import'./chunk-
|
|
1
|
+
import {a,c as c$1}from'./chunk-3AKECLKA.mjs';import {a as a$1}from'./chunk-J3542Z77.mjs';import'./chunk-NRPWBHKP.mjs';import {c}from'./chunk-MI76R42D.mjs';function k(t){if(!t)return {};if(typeof URLSearchParams<"u"){let e=new URLSearchParams(t),r={};return e.forEach((n,o)=>r[o]=n),r}return t.substring(1).split("&").reduce((e,r)=>{let[n,o]=r.split("=");return n&&(e[decodeURIComponent(n)]=decodeURIComponent(o||"")),e},{})}function D(t){return !!(t.length>2048||t.includes("__proto__")||t.includes("constructor")||/^\s*javascript:/i.test(t))}function R(t){let e=[];return t.forEach(r=>{if(!r)return;let{path:n,component:o,children:i,beforeEnter:f}=r.props||{},u={path:n||"/",component:o,beforeEnter:f};if(i){let c=Array.isArray(i)?i:[i];u.children=R(c);}!u.children&&r.children&&r.children.length>0&&(u.children=R(r.children)),e.push(u);}),e}function E(t,e){for(let r of t){let n=r.path,o=T(n,e);if(o)return [{route:r,params:o.params,pathname:o.path}]}return null}function T(t,e){let r=t.split("/").filter(Boolean),n=e.split("/").filter(Boolean);if(r.length!==n.length)return null;let o={};for(let i=0;i<r.length;i++){let f=r[i],u=n[i];if(f.startsWith(":")){let c=f.slice(1);o[c]=u;}else if(f!==u)return null}return {params:o,path:e}}var L=new c(null),p=new c(0),U=()=>({pathname:"/",search:"",hash:"",query:{}}),w=()=>typeof window>"u"?U():{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash,query:k(window.location.search)},l=null,y=null,N=false;function d(){if(l&&y)return [l,y];l=a(w());let t=e=>{l&&(l.pathname=e.pathname,l.search=e.search,l.hash=e.hash,l.query=e.query);};return y=e=>{if(typeof window>"u")return;if(D(e)){console.error("[Flexium Router] Blocked navigation to unsafe path:",e);return}window.history.pushState({},"",e);let r=w();t(r);},typeof window<"u"&&!N&&(window.addEventListener("popstate",()=>{t(w());}),N=true),[l,y]}function m(){let[t]=c$1(L);if(!t)throw new Error("useRouter() must be called within a <Routes> component");return t}function j(){let[,t]=d();return t}function q(){return m().params}function _(){let[t]=d();return t.query}function x(t){return null}function F(t){return t&&typeof t=="object"&&("type"in t||Array.isArray(t))}function Q(t){let[e,r]=d(),n=Array.isArray(t.children)?t.children:[t.children],o=n.filter(s=>F(s)&&s.type===x),i=n.filter(s=>!F(s)||s.type!==x),f=R(o),u=e.pathname,c=E(f,u)||[],A=c.length>0?c[c.length-1].params:{},S={location:e,navigate:r,matches:c,params:A},C=null;if(c.length>0){let s=c[0],P=s.route.component,g=u;s.route.beforeEnter?s.route.beforeEnter(s.params)!==false&&(C=a$1(p.Provider,{value:1,key:g,children:a$1(P,{params:s.params,key:g})})):C=a$1(p.Provider,{value:1,key:g,children:a$1(P,{params:s.params,key:g})});}return a$1(L.Provider,{value:S,children:[...i,C]})}function B(){let t=m(),[e]=c$1(p),r=e??0,[n]=c$1(()=>t.matches);if(r>=n.length)return null;let o=n[r],i=o.route.component;return o.route.beforeEnter&&o.route.beforeEnter(o.params)===false?null:a$1(p.Provider,{value:r+1,children:a$1(i,{params:o.params})})}function M(t){let e=m();return a$1("a",{href:t.to,class:t.class,onclick:r=>{r.preventDefault(),e.navigate(t.to);},children:t.children})}export{M as Link,B as Outlet,x as Route,Q as Routes,d as useLocation,j as useNavigate,q as useParams,_ as useQuery,m as useRouter};//# sourceMappingURL=router.mjs.map
|
|
2
2
|
//# sourceMappingURL=router.mjs.map
|
package/dist/router.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/utils.ts","../src/router/router.ts","../src/router/dom/Route.tsx","../src/router/dom/Routes.tsx","../src/router/dom/Outlet.tsx","../src/router/dom/Link.tsx"],"names":["parseQuery","search","params","result","value","key","accumulator","part","isUnsafePath","path","createRoutesFromChildren","children","routes","child","component","subChildren","beforeEnter","route","nestedChildren","matchRoutes","locationPathname","routePath","matchResult","matchPath","locationPath","routeSegments","locationSegments","routeSegment","locationSegment","RouterCtx","Context","RouteDepthCtx","getDefaultLocation","getCurrentLocation","globalLocation","globalNavigate","popstateListenerAttached","useLocation","reactive","updateLocation","newLocation","useRouter","routerContext","use","useNavigate","navigate","useParams","useQuery","location","Route","_props","isFNode","node","Routes","props","currentLocation","childrenList","routeNodes","otherChildren","routeDefinitions","currentPath","matches","matchedContent","rootMatch","Component","routeKey","jsx","Outlet","depthValue","depth","match","Link","event"],"mappings":"4JAGA,SAASA,CAAAA,CAAWC,EAAwC,CAC1D,GAAI,CAACA,CAAAA,CAAQ,OAAO,EAAC,CACrB,GAAI,OAAO,eAAA,CAAoB,GAAA,CAAa,CAC1C,IAAMC,CAAAA,CAAS,IAAI,eAAA,CAAgBD,CAAM,CAAA,CACnCE,CAAAA,CAAiC,EAAC,CACxC,OAAAD,CAAAA,CAAO,OAAA,CAAQ,CAACE,CAAAA,CAAOC,CAAAA,GAAQF,EAAOE,CAAG,CAAA,CAAID,CAAK,CAAA,CAC3CD,CACT,CACA,OAAOF,CAAAA,CACJ,UAAU,CAAC,CAAA,CACX,MAAM,GAAG,CAAA,CACT,MAAA,CAAO,CAACK,CAAAA,CAAaC,CAAAA,GAAS,CAC7B,GAAM,CAACF,EAAKD,CAAK,CAAA,CAAIG,EAAK,KAAA,CAAM,GAAG,EACnC,OAAIF,CAAAA,GAAKC,EAAY,kBAAA,CAAmBD,CAAG,CAAC,CAAA,CAAI,kBAAA,CAAmBD,GAAS,EAAE,CAAA,CAAA,CACvEE,CACT,CAAA,CAAG,EAA4B,CACnC,CAEA,SAASE,EAAaC,CAAAA,CAAuB,CAK3C,OAHI,CAAA,EAAAA,CAAAA,CAAK,MAAA,CAAS,IAAA,EACdA,CAAAA,CAAK,QAAA,CAAS,WAAW,CAAA,EAAKA,CAAAA,CAAK,SAAS,aAAa,CAAA,EAEzD,mBAAmB,IAAA,CAAKA,CAAI,CAAA,CAElC,CAGA,SAASC,CAAAA,CAAyBC,EAAoC,CACpE,IAAMC,EAA4B,EAAC,CAEnC,OAAAD,CAAAA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G9B,OAAIA,CAAAA,CAAM,KAAA,CAAM,aACRA,CAAAA,CAAM,KAAA,CAAM,YAAYA,CAAAA,CAAM,MAAM,IAAM,KAAA,CAAc,IAAA,CAIzDJ,GAAAA,CAAEnC,CAAAA,CAAc,QAAA,CAAU,CAC7B,MAAOsC,CAAAA,CAAQ,CAAA,CACf,SAAUH,GAAAA,CAAEF,CAAAA,CAAW,CAAE,MAAA,CAAQM,CAAAA,CAAM,MAAO,CAAC,CACnD,CAAC,CACL,CCtBO,SAASC,CAAAA,CAAKjB,CAAAA,CAAkB,CACnC,IAAMZ,CAAAA,CAAgBD,CAAAA,EAAU,CAChC,OAAOyB,GAAAA,CAAE,IAAK,CACV,IAAA,CAAMZ,EAAM,EAAA,CACZ,KAAA,CAAOA,EAAM,KAAA,CACb,OAAA,CAAUkB,CAAAA,EAAiB,CACvBA,CAAAA,CAAM,cAAA,GACN9B,CAAAA,CAAc,QAAA,CAASY,EAAM,EAAE,EACnC,EACA,QAAA,CAAUA,CAAAA,CAAM,QACpB,CAAC,CACL","file":"router.mjs","sourcesContent":["import { RouteDefinition, RouteMatch } from './types'\n\n// Simple query parser (native URLSearchParams fallback) - internal use only\nfunction parseQuery(search: string): Record<string, string> {\n if (!search) return {}\n if (typeof URLSearchParams !== 'undefined') {\n const params = new URLSearchParams(search)\n const result: Record<string, string> = {}\n params.forEach((value, key) => result[key] = value)\n return result\n }\n return search\n .substring(1)\n .split('&')\n .reduce((accumulator, part) => {\n const [key, value] = part.split('=')\n if (key) accumulator[decodeURIComponent(key)] = decodeURIComponent(value || '')\n return accumulator\n }, {} as Record<string, string>)\n}\n\nfunction isUnsafePath(path: string): boolean {\n // Prevent prototype pollution or massive strings\n if (path.length > 2048) return true\n if (path.includes('__proto__') || path.includes('constructor')) return true\n // Basic XSS check for javascript: protocol\n if (/^\\s*javascript:/i.test(path)) return true\n return false\n}\n\n// Convert children FNodes to RouteDefinitions - internal use only\nfunction createRoutesFromChildren(children: any[]): RouteDefinition[] {\n const routes: RouteDefinition[] = []\n\n children.forEach(child => {\n if (!child) return\n\n // Assuming child is an FNode-like object (config)\n // In Flexium, Route component returns null, but 'createNode' isn't called here.\n // We are traversing the props passed to Router.\n\n const { path, component, children: subChildren, beforeEnter } = child.props || {}\n\n const route: RouteDefinition = {\n path: path || '/',\n component: component,\n beforeEnter\n }\n\n if (subChildren) {\n // If subChildren is array\n const nestedChildren = Array.isArray(subChildren) ? subChildren : [subChildren]\n // We expect the children of a Route to be other Routes\n // However, the 'children' prop in JSX might be the Route components themselves.\n route.children = createRoutesFromChildren(nestedChildren)\n }\n\n // Also check child.children if props.children is empty (direct FNode structure)\n if (!route.children && child.children && child.children.length > 0) {\n route.children = createRoutesFromChildren(child.children)\n }\n\n routes.push(route)\n })\n return routes\n}\n\n// Simple Matcher - internal use only\nfunction matchRoutes(routes: RouteDefinition[], locationPathname: string): RouteMatch[] | null {\n // We want to find the best matching branch\n\n for (const route of routes) {\n // 1. Match current segment\n // Simple exact match or parameter match logic needed?\n // Let's implement simple param matching: /user/:id\n\n const routePath = route.path\n\n const matchResult = matchPath(routePath, locationPathname)\n if (matchResult) {\n return [{ route, params: matchResult.params, pathname: matchResult.path }]\n }\n }\n return null\n}\n\nfunction matchPath(routePath: string, locationPath: string) {\n // 1. Split into segments\n const routeSegments = routePath.split('/').filter(Boolean)\n const locationSegments = locationPath.split('/').filter(Boolean)\n\n if (routeSegments.length !== locationSegments.length) return null\n\n const params: Record<string, string> = {}\n\n for (let i = 0; i < routeSegments.length; i++) {\n const routeSegment = routeSegments[i]\n const locationSegment = locationSegments[i]\n\n if (routeSegment.startsWith(':')) {\n const key = routeSegment.slice(1)\n params[key] = locationSegment\n } else if (routeSegment !== locationSegment) {\n return null\n }\n }\n\n return { params, path: locationPath }\n}\n\n// Export only what's needed by other router files\nexport { parseQuery, isUnsafePath, createRoutesFromChildren, matchRoutes }\n","import { reactive } from '../core/reactive'\nimport { Context } from '../core/context'\nimport { use } from '../core/use'\nimport type { Location, RouterContext } from './types'\nimport { parseQuery, isUnsafePath } from './utils'\n\n// Contexts\nexport const RouterCtx = new Context<RouterContext>(null as any)\nexport const RouteDepthCtx = new Context<number>(0)\n\n// Helper functions\nconst getDefaultLocation = (): Location => ({\n pathname: '/',\n search: '',\n hash: '',\n query: {},\n})\n\nconst getCurrentLocation = (): Location => {\n if (typeof window === 'undefined') {\n return getDefaultLocation()\n }\n return {\n pathname: window.location.pathname,\n search: window.location.search,\n hash: window.location.hash,\n query: parseQuery(window.location.search),\n }\n}\n\n// Global singleton location state\nlet globalLocation: Location | null = null\nlet globalNavigate: ((path: string) => void) | null = null\nlet popstateListenerAttached = false\n\n// Create location state and navigation (singleton pattern)\nexport function useLocation(): [Location, (path: string) => void] {\n // Return existing singleton if already created\n if (globalLocation && globalNavigate) {\n return [globalLocation, globalNavigate]\n }\n\n // Create a reactive location object (only once)\n globalLocation = reactive<Location>(getCurrentLocation())\n\n const updateLocation = (newLocation: Location) => {\n if (!globalLocation) return\n globalLocation.pathname = newLocation.pathname\n globalLocation.search = newLocation.search\n globalLocation.hash = newLocation.hash\n globalLocation.query = newLocation.query\n }\n\n globalNavigate = (path: string) => {\n if (typeof window === 'undefined') return\n if (isUnsafePath(path)) {\n console.error('[Flexium Router] Blocked navigation to unsafe path:', path)\n return\n }\n window.history.pushState({}, '', path)\n const newLocation = getCurrentLocation()\n updateLocation(newLocation)\n }\n\n // Listen to popstate (only once)\n if (typeof window !== 'undefined' && !popstateListenerAttached) {\n window.addEventListener('popstate', () => {\n updateLocation(getCurrentLocation())\n })\n popstateListenerAttached = true\n }\n\n return [globalLocation, globalNavigate]\n}\n\n// Router hook - returns full router context\nexport function useRouter(): RouterContext {\n const [routerContext] = use(RouterCtx)\n if (!routerContext) {\n throw new Error('useRouter() must be called within a <Routes> component')\n }\n return routerContext\n}\n\n// Navigate hook - returns navigate function\nexport function useNavigate(): (path: string) => void {\n const [, navigate] = useLocation()\n return navigate\n}\n\n// Params hook - returns route params\nexport function useParams<T extends Record<string, string> = Record<string, string>>(): T {\n const router = useRouter()\n return router.params as T\n}\n\n// Query hook - returns query params\nexport function useQuery<T extends Record<string, string> = Record<string, string>>(): T {\n const [location] = useLocation()\n return location.query as T\n}\n","import type { RouteProps } from '../types'\n\nexport function Route(_props: RouteProps) {\n return null\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { FNode, FNodeChild } from '../../dom'\nimport { RouterCtx, RouteDepthCtx, useLocation } from '../router'\nimport { createRoutesFromChildren, matchRoutes } from '../utils'\nimport { Route } from './Route'\n\nfunction isFNode(node: any): node is FNode {\n return node && typeof node === 'object' && ('type' in node || Array.isArray(node))\n}\n\nexport function Routes(props: { children: FNodeChild }) {\n const [currentLocation, navigate] = useLocation()\n\n // Parse children to find <Route> definitions and other content\n let childrenList: any[] = Array.isArray(props.children) ? props.children : [props.children]\n\n // Separate routes from other children (like Nav components)\n const routeNodes = childrenList.filter(child => isFNode(child) && child.type === Route)\n const otherChildren = childrenList.filter(child => !isFNode(child) || child.type !== Route)\n\n // Create route definitions\n const routeDefinitions = createRoutesFromChildren(routeNodes)\n\n // DIRECT access to currentLocation.pathname\n // This should trigger reactive tracking in the component's effect context\n const currentPath = currentLocation.pathname\n const matches = matchRoutes(routeDefinitions, currentPath) || []\n const params = matches.length > 0 ? matches[matches.length - 1].params : {}\n\n const routerContext = {\n location: currentLocation,\n navigate,\n matches: matches,\n params: params\n }\n\n // Render matched component\n let matchedContent: FNodeChild = null\n\n if (matches.length > 0) {\n const rootMatch = matches[0]\n const Component = rootMatch.route.component\n\n // Use pathname as key to force re-mount on route change\n const routeKey = currentPath\n\n // Guard Check\n if (rootMatch.route.beforeEnter) {\n const result = rootMatch.route.beforeEnter(rootMatch.params)\n if (result !== false) {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n } else {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n }\n\n return f(RouterCtx.Provider, {\n value: routerContext,\n children: [...otherChildren, matchedContent]\n })\n}\n","import { use } from '../../core/use'\nimport { jsx as f } from '../../jsx-runtime'\nimport { RouteDepthCtx, useRouter } from '../router'\n\nexport function Outlet() {\n const routerContext = useRouter()\n const [depthValue] = use(RouteDepthCtx)\n const depth = depthValue ?? 0\n\n const [matches] = use(() => routerContext.matches)\n\n if (depth >= matches.length) return null\n\n const match = matches[depth]\n const Component = match.route.component\n\n // Guard\n if (match.route.beforeEnter) {\n if (match.route.beforeEnter(match.params) === false) return null\n }\n\n // Render next level\n return f(RouteDepthCtx.Provider, {\n value: depth + 1,\n children: f(Component, { params: match.params })\n })\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { LinkProps } from '../types'\nimport { useRouter } from '../router'\n\nexport function Link(props: LinkProps) {\n const routerContext = useRouter()\n return f('a', {\n href: props.to,\n class: props.class,\n onclick: (event: Event) => {\n event.preventDefault()\n routerContext.navigate(props.to)\n },\n children: props.children\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/router/utils.ts","../src/router/router.ts","../src/router/dom/Route.tsx","../src/router/dom/Routes.tsx","../src/router/dom/Outlet.tsx","../src/router/dom/Link.tsx"],"names":["parseQuery","search","params","result","value","key","accumulator","part","isUnsafePath","path","createRoutesFromChildren","children","routes","child","component","subChildren","beforeEnter","route","nestedChildren","matchRoutes","locationPathname","routePath","matchResult","matchPath","locationPath","routeSegments","locationSegments","routeSegment","locationSegment","RouterCtx","Context","RouteDepthCtx","getDefaultLocation","getCurrentLocation","globalLocation","globalNavigate","popstateListenerAttached","useLocation","reactive","updateLocation","newLocation","useRouter","routerContext","use","useNavigate","navigate","useParams","useQuery","location","Route","_props","isFNode","node","Routes","props","currentLocation","childrenList","routeNodes","otherChildren","routeDefinitions","currentPath","matches","matchedContent","rootMatch","Component","routeKey","jsx","Outlet","depthValue","depth","match","Link","event"],"mappings":"4JAGA,SAASA,CAAA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AM,MAAO,CAAC,CACnD,CAAC,CACL,CCtBO,SAASC,CAAAA,CAAKjB,CAAAA,CAAkB,CACnC,IAAMZ,CAAAA,CAAgBD,CAAAA,EAAU,CAChC,OAAOyB,GAAAA,CAAE,IAAK,CACV,IAAA,CAAMZ,EAAM,EAAA,CACZ,KAAA,CAAOA,EAAM,KAAA,CACb,OAAA,CAAUkB,CAAAA,EAAiB,CACvBA,CAAAA,CAAM,cAAA,GACN9B,CAAAA,CAAc,QAAA,CAASY,EAAM,EAAE,EACnC,EACA,QAAA,CAAUA,CAAAA,CAAM,QACpB,CAAC,CACL","file":"router.mjs","sourcesContent":["import { RouteDefinition, RouteMatch } from './types'\n\n// Simple query parser (native URLSearchParams fallback) - internal use only\nfunction parseQuery(search: string): Record<string, string> {\n if (!search) return {}\n if (typeof URLSearchParams !== 'undefined') {\n const params = new URLSearchParams(search)\n const result: Record<string, string> = {}\n params.forEach((value, key) => result[key] = value)\n return result\n }\n return search\n .substring(1)\n .split('&')\n .reduce((accumulator, part) => {\n const [key, value] = part.split('=')\n if (key) accumulator[decodeURIComponent(key)] = decodeURIComponent(value || '')\n return accumulator\n }, {} as Record<string, string>)\n}\n\nfunction isUnsafePath(path: string): boolean {\n // Prevent prototype pollution or massive strings\n if (path.length > 2048) return true\n if (path.includes('__proto__') || path.includes('constructor')) return true\n // Basic XSS check for javascript: protocol\n if (/^\\s*javascript:/i.test(path)) return true\n return false\n}\n\n// Convert children FNodes to RouteDefinitions - internal use only\nfunction createRoutesFromChildren(children: any[]): RouteDefinition[] {\n const routes: RouteDefinition[] = []\n\n children.forEach(child => {\n if (!child) return\n\n // Assuming child is an FNode-like object (config)\n // In Flexium, Route component returns null, but 'createNode' isn't called here.\n // We are traversing the props passed to Router.\n\n const { path, component, children: subChildren, beforeEnter } = child.props || {}\n\n const route: RouteDefinition = {\n path: path || '/',\n component: component,\n beforeEnter\n }\n\n if (subChildren) {\n // If subChildren is array\n const nestedChildren = Array.isArray(subChildren) ? subChildren : [subChildren]\n // We expect the children of a Route to be other Routes\n // However, the 'children' prop in JSX might be the Route components themselves.\n route.children = createRoutesFromChildren(nestedChildren)\n }\n\n // Also check child.children if props.children is empty (direct FNode structure)\n if (!route.children && child.children && child.children.length > 0) {\n route.children = createRoutesFromChildren(child.children)\n }\n\n routes.push(route)\n })\n return routes\n}\n\n// Simple Matcher - internal use only\nfunction matchRoutes(routes: RouteDefinition[], locationPathname: string): RouteMatch[] | null {\n // We want to find the best matching branch\n\n for (const route of routes) {\n // 1. Match current segment\n // Simple exact match or parameter match logic needed?\n // Let's implement simple param matching: /user/:id\n\n const routePath = route.path\n\n const matchResult = matchPath(routePath, locationPathname)\n if (matchResult) {\n return [{ route, params: matchResult.params, pathname: matchResult.path }]\n }\n }\n return null\n}\n\nfunction matchPath(routePath: string, locationPath: string) {\n // 1. Split into segments\n const routeSegments = routePath.split('/').filter(Boolean)\n const locationSegments = locationPath.split('/').filter(Boolean)\n\n if (routeSegments.length !== locationSegments.length) return null\n\n const params: Record<string, string> = {}\n\n for (let i = 0; i < routeSegments.length; i++) {\n const routeSegment = routeSegments[i]\n const locationSegment = locationSegments[i]\n\n if (routeSegment.startsWith(':')) {\n const key = routeSegment.slice(1)\n params[key] = locationSegment\n } else if (routeSegment !== locationSegment) {\n return null\n }\n }\n\n return { params, path: locationPath }\n}\n\n// Export only what's needed by other router files\nexport { parseQuery, isUnsafePath, createRoutesFromChildren, matchRoutes }\n","import { reactive } from '../core/reactive'\nimport { Context } from '../core/context'\nimport { use } from '../core/use'\nimport type { Location, RouterContext } from './types'\nimport { parseQuery, isUnsafePath } from './utils'\n\n// Contexts\nexport const RouterCtx = new Context<RouterContext>(null as any)\nexport const RouteDepthCtx = new Context<number>(0)\n\n// Helper functions\nconst getDefaultLocation = (): Location => ({\n pathname: '/',\n search: '',\n hash: '',\n query: {},\n})\n\nconst getCurrentLocation = (): Location => {\n if (typeof window === 'undefined') {\n return getDefaultLocation()\n }\n return {\n pathname: window.location.pathname,\n search: window.location.search,\n hash: window.location.hash,\n query: parseQuery(window.location.search),\n }\n}\n\n// Global singleton location state\nlet globalLocation: Location | null = null\nlet globalNavigate: ((path: string) => void) | null = null\nlet popstateListenerAttached = false\n\n// Create location state and navigation (singleton pattern)\nexport function useLocation(): [Location, (path: string) => void] {\n // Return existing singleton if already created\n if (globalLocation && globalNavigate) {\n return [globalLocation, globalNavigate]\n }\n\n // Create a reactive location object (only once)\n globalLocation = reactive<Location>(getCurrentLocation())\n\n const updateLocation = (newLocation: Location) => {\n if (!globalLocation) return\n globalLocation.pathname = newLocation.pathname\n globalLocation.search = newLocation.search\n globalLocation.hash = newLocation.hash\n globalLocation.query = newLocation.query\n }\n\n globalNavigate = (path: string) => {\n if (typeof window === 'undefined') return\n if (isUnsafePath(path)) {\n console.error('[Flexium Router] Blocked navigation to unsafe path:', path)\n return\n }\n window.history.pushState({}, '', path)\n const newLocation = getCurrentLocation()\n updateLocation(newLocation)\n }\n\n // Listen to popstate (only once)\n if (typeof window !== 'undefined' && !popstateListenerAttached) {\n window.addEventListener('popstate', () => {\n updateLocation(getCurrentLocation())\n })\n popstateListenerAttached = true\n }\n\n return [globalLocation, globalNavigate]\n}\n\n// Router hook - returns full router context\nexport function useRouter(): RouterContext {\n const [routerContext] = use(RouterCtx)\n if (!routerContext) {\n throw new Error('useRouter() must be called within a <Routes> component')\n }\n return routerContext\n}\n\n// Navigate hook - returns navigate function\nexport function useNavigate(): (path: string) => void {\n const [, navigate] = useLocation()\n return navigate\n}\n\n// Params hook - returns route params\nexport function useParams<T extends Record<string, string> = Record<string, string>>(): T {\n const router = useRouter()\n return router.params as T\n}\n\n// Query hook - returns query params\nexport function useQuery<T extends Record<string, string> = Record<string, string>>(): T {\n const [location] = useLocation()\n return location.query as T\n}\n","import type { RouteProps } from '../types'\n\nexport function Route(_props: RouteProps) {\n return null\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { FNode, FNodeChild } from '../../dom/types'\nimport { RouterCtx, RouteDepthCtx, useLocation } from '../router'\nimport { createRoutesFromChildren, matchRoutes } from '../utils'\nimport { Route } from './Route'\n\nfunction isFNode(node: any): node is FNode {\n return node && typeof node === 'object' && ('type' in node || Array.isArray(node))\n}\n\nexport function Routes(props: { children: FNodeChild }) {\n const [currentLocation, navigate] = useLocation()\n\n // Parse children to find <Route> definitions and other content\n let childrenList: any[] = Array.isArray(props.children) ? props.children : [props.children]\n\n // Separate routes from other children (like Nav components)\n const routeNodes = childrenList.filter(child => isFNode(child) && child.type === Route)\n const otherChildren = childrenList.filter(child => !isFNode(child) || child.type !== Route)\n\n // Create route definitions\n const routeDefinitions = createRoutesFromChildren(routeNodes)\n\n // DIRECT access to currentLocation.pathname\n // This should trigger reactive tracking in the component's effect context\n const currentPath = currentLocation.pathname\n const matches = matchRoutes(routeDefinitions, currentPath) || []\n const params = matches.length > 0 ? matches[matches.length - 1].params : {}\n\n const routerContext = {\n location: currentLocation,\n navigate,\n matches: matches,\n params: params\n }\n\n // Render matched component\n let matchedContent: FNodeChild = null\n\n if (matches.length > 0) {\n const rootMatch = matches[0]\n const Component = rootMatch.route.component\n\n // Use pathname as key to force re-mount on route change\n const routeKey = currentPath\n\n // Guard Check\n if (rootMatch.route.beforeEnter) {\n const result = rootMatch.route.beforeEnter(rootMatch.params)\n if (result !== false) {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n } else {\n matchedContent = f(RouteDepthCtx.Provider, {\n value: 1,\n key: routeKey,\n children: f(Component, { params: rootMatch.params, key: routeKey })\n })\n }\n }\n\n return f(RouterCtx.Provider, {\n value: routerContext,\n children: [...otherChildren, matchedContent]\n })\n}\n","import { use } from '../../core/use'\nimport { jsx as f } from '../../jsx-runtime'\nimport { RouteDepthCtx, useRouter } from '../router'\n\nexport function Outlet() {\n const routerContext = useRouter()\n const [depthValue] = use(RouteDepthCtx)\n const depth = depthValue ?? 0\n\n const [matches] = use(() => routerContext.matches)\n\n if (depth >= matches.length) return null\n\n const match = matches[depth]\n const Component = match.route.component\n\n // Guard\n if (match.route.beforeEnter) {\n if (match.route.beforeEnter(match.params) === false) return null\n }\n\n // Render next level\n return f(RouteDepthCtx.Provider, {\n value: depth + 1,\n children: f(Component, { params: match.params })\n })\n}\n","import { jsx as f } from '../../jsx-runtime'\nimport type { LinkProps } from '../types'\nimport { useRouter } from '../router'\n\nexport function Link(props: LinkProps) {\n const routerContext = useRouter()\n return f('a', {\n href: props.to,\n class: props.class,\n onclick: (event: Event) => {\n event.preventDefault()\n routerContext.navigate(props.to)\n },\n children: props.children\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flexium",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A lightweight, signals-based UI framework with cross-platform renderers",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -44,16 +44,6 @@
|
|
|
44
44
|
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
45
45
|
"import": "./dist/jsx-dev-runtime.mjs",
|
|
46
46
|
"require": "./dist/jsx-dev-runtime.js"
|
|
47
|
-
},
|
|
48
|
-
"./canvas": {
|
|
49
|
-
"types": "./dist/canvas.d.ts",
|
|
50
|
-
"import": "./dist/canvas.mjs",
|
|
51
|
-
"require": "./dist/canvas.js"
|
|
52
|
-
},
|
|
53
|
-
"./interactive": {
|
|
54
|
-
"types": "./dist/interactive.d.ts",
|
|
55
|
-
"import": "./dist/interactive.mjs",
|
|
56
|
-
"require": "./dist/interactive.js"
|
|
57
47
|
}
|
|
58
48
|
},
|
|
59
49
|
"files": [
|
|
@@ -91,11 +81,7 @@
|
|
|
91
81
|
"ui",
|
|
92
82
|
"framework",
|
|
93
83
|
"dom",
|
|
94
|
-
"canvas",
|
|
95
|
-
"game",
|
|
96
|
-
"game-loop",
|
|
97
84
|
"renderer",
|
|
98
|
-
"flexbox",
|
|
99
85
|
"lightweight",
|
|
100
86
|
"fine-grained",
|
|
101
87
|
"typescript",
|
|
@@ -106,8 +92,7 @@
|
|
|
106
92
|
"no-virtual-dom",
|
|
107
93
|
"signal-based",
|
|
108
94
|
"computed",
|
|
109
|
-
"effect"
|
|
110
|
-
"cross-platform"
|
|
95
|
+
"effect"
|
|
111
96
|
],
|
|
112
97
|
"author": "Flexium Contributors",
|
|
113
98
|
"license": "MIT",
|
package/dist/canvas.d.cts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { JSX } from './jsx-runtime.cjs';
|
|
2
|
-
import './types-DH8L3A5z.cjs';
|
|
3
|
-
|
|
4
|
-
interface CanvasProps {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
children?: any;
|
|
8
|
-
style?: any;
|
|
9
|
-
ref?: (el: HTMLCanvasElement) => void;
|
|
10
|
-
}
|
|
11
|
-
interface DrawRectProps {
|
|
12
|
-
x: number | (() => number);
|
|
13
|
-
y: number | (() => number);
|
|
14
|
-
width: number | (() => number);
|
|
15
|
-
height: number | (() => number);
|
|
16
|
-
fill?: string | (() => string);
|
|
17
|
-
stroke?: string | (() => string);
|
|
18
|
-
strokeWidth?: number | (() => number);
|
|
19
|
-
opacity?: number | (() => number);
|
|
20
|
-
}
|
|
21
|
-
interface DrawCircleProps {
|
|
22
|
-
x: number | (() => number);
|
|
23
|
-
y: number | (() => number);
|
|
24
|
-
radius: number | (() => number);
|
|
25
|
-
fill?: string | (() => string);
|
|
26
|
-
stroke?: string | (() => string);
|
|
27
|
-
strokeWidth?: number | (() => number);
|
|
28
|
-
opacity?: number | (() => number);
|
|
29
|
-
}
|
|
30
|
-
interface DrawArcProps {
|
|
31
|
-
x: number | (() => number);
|
|
32
|
-
y: number | (() => number);
|
|
33
|
-
radius: number | (() => number);
|
|
34
|
-
startAngle: number | (() => number);
|
|
35
|
-
endAngle: number | (() => number);
|
|
36
|
-
counterclockwise?: boolean;
|
|
37
|
-
fill?: string | (() => string);
|
|
38
|
-
stroke?: string | (() => string);
|
|
39
|
-
strokeWidth?: number | (() => number);
|
|
40
|
-
opacity?: number | (() => number);
|
|
41
|
-
}
|
|
42
|
-
interface DrawLineProps {
|
|
43
|
-
x1: number | (() => number);
|
|
44
|
-
y1: number | (() => number);
|
|
45
|
-
x2: number | (() => number);
|
|
46
|
-
y2: number | (() => number);
|
|
47
|
-
stroke?: string | (() => string);
|
|
48
|
-
strokeWidth?: number | (() => number);
|
|
49
|
-
opacity?: number | (() => number);
|
|
50
|
-
}
|
|
51
|
-
interface DrawTextProps {
|
|
52
|
-
text: string | (() => string);
|
|
53
|
-
x: number | (() => number);
|
|
54
|
-
y: number | (() => number);
|
|
55
|
-
fill?: string | (() => string);
|
|
56
|
-
fontSize?: number | (() => number);
|
|
57
|
-
fontFamily?: string | (() => string);
|
|
58
|
-
fontWeight?: string | (() => string);
|
|
59
|
-
textAlign?: 'left' | 'center' | 'right';
|
|
60
|
-
opacity?: number | (() => number);
|
|
61
|
-
}
|
|
62
|
-
interface DrawPathProps {
|
|
63
|
-
d: string | (() => string);
|
|
64
|
-
fill?: string | (() => string);
|
|
65
|
-
stroke?: string | (() => string);
|
|
66
|
-
strokeWidth?: number | (() => number);
|
|
67
|
-
opacity?: number | (() => number);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
declare function Canvas(props: CanvasProps): JSX.Element;
|
|
71
|
-
|
|
72
|
-
declare function DrawRect(props: DrawRectProps): null;
|
|
73
|
-
|
|
74
|
-
declare function DrawCircle(props: DrawCircleProps): null;
|
|
75
|
-
|
|
76
|
-
declare function DrawArc(props: DrawArcProps): null;
|
|
77
|
-
|
|
78
|
-
declare function DrawLine(props: DrawLineProps): null;
|
|
79
|
-
|
|
80
|
-
declare function DrawText(props: DrawTextProps): null;
|
|
81
|
-
|
|
82
|
-
declare function DrawPath(props: DrawPathProps): null;
|
|
83
|
-
|
|
84
|
-
export { Canvas, type CanvasProps, DrawArc, type DrawArcProps, DrawCircle, type DrawCircleProps, DrawLine, type DrawLineProps, DrawPath, type DrawPathProps, DrawRect, type DrawRectProps, DrawText, type DrawTextProps };
|
package/dist/canvas.d.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { JSX } from './jsx-runtime.js';
|
|
2
|
-
import './types-DH8L3A5z.js';
|
|
3
|
-
|
|
4
|
-
interface CanvasProps {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
children?: any;
|
|
8
|
-
style?: any;
|
|
9
|
-
ref?: (el: HTMLCanvasElement) => void;
|
|
10
|
-
}
|
|
11
|
-
interface DrawRectProps {
|
|
12
|
-
x: number | (() => number);
|
|
13
|
-
y: number | (() => number);
|
|
14
|
-
width: number | (() => number);
|
|
15
|
-
height: number | (() => number);
|
|
16
|
-
fill?: string | (() => string);
|
|
17
|
-
stroke?: string | (() => string);
|
|
18
|
-
strokeWidth?: number | (() => number);
|
|
19
|
-
opacity?: number | (() => number);
|
|
20
|
-
}
|
|
21
|
-
interface DrawCircleProps {
|
|
22
|
-
x: number | (() => number);
|
|
23
|
-
y: number | (() => number);
|
|
24
|
-
radius: number | (() => number);
|
|
25
|
-
fill?: string | (() => string);
|
|
26
|
-
stroke?: string | (() => string);
|
|
27
|
-
strokeWidth?: number | (() => number);
|
|
28
|
-
opacity?: number | (() => number);
|
|
29
|
-
}
|
|
30
|
-
interface DrawArcProps {
|
|
31
|
-
x: number | (() => number);
|
|
32
|
-
y: number | (() => number);
|
|
33
|
-
radius: number | (() => number);
|
|
34
|
-
startAngle: number | (() => number);
|
|
35
|
-
endAngle: number | (() => number);
|
|
36
|
-
counterclockwise?: boolean;
|
|
37
|
-
fill?: string | (() => string);
|
|
38
|
-
stroke?: string | (() => string);
|
|
39
|
-
strokeWidth?: number | (() => number);
|
|
40
|
-
opacity?: number | (() => number);
|
|
41
|
-
}
|
|
42
|
-
interface DrawLineProps {
|
|
43
|
-
x1: number | (() => number);
|
|
44
|
-
y1: number | (() => number);
|
|
45
|
-
x2: number | (() => number);
|
|
46
|
-
y2: number | (() => number);
|
|
47
|
-
stroke?: string | (() => string);
|
|
48
|
-
strokeWidth?: number | (() => number);
|
|
49
|
-
opacity?: number | (() => number);
|
|
50
|
-
}
|
|
51
|
-
interface DrawTextProps {
|
|
52
|
-
text: string | (() => string);
|
|
53
|
-
x: number | (() => number);
|
|
54
|
-
y: number | (() => number);
|
|
55
|
-
fill?: string | (() => string);
|
|
56
|
-
fontSize?: number | (() => number);
|
|
57
|
-
fontFamily?: string | (() => string);
|
|
58
|
-
fontWeight?: string | (() => string);
|
|
59
|
-
textAlign?: 'left' | 'center' | 'right';
|
|
60
|
-
opacity?: number | (() => number);
|
|
61
|
-
}
|
|
62
|
-
interface DrawPathProps {
|
|
63
|
-
d: string | (() => string);
|
|
64
|
-
fill?: string | (() => string);
|
|
65
|
-
stroke?: string | (() => string);
|
|
66
|
-
strokeWidth?: number | (() => number);
|
|
67
|
-
opacity?: number | (() => number);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
declare function Canvas(props: CanvasProps): JSX.Element;
|
|
71
|
-
|
|
72
|
-
declare function DrawRect(props: DrawRectProps): null;
|
|
73
|
-
|
|
74
|
-
declare function DrawCircle(props: DrawCircleProps): null;
|
|
75
|
-
|
|
76
|
-
declare function DrawArc(props: DrawArcProps): null;
|
|
77
|
-
|
|
78
|
-
declare function DrawLine(props: DrawLineProps): null;
|
|
79
|
-
|
|
80
|
-
declare function DrawText(props: DrawTextProps): null;
|
|
81
|
-
|
|
82
|
-
declare function DrawPath(props: DrawPathProps): null;
|
|
83
|
-
|
|
84
|
-
export { Canvas, type CanvasProps, DrawArc, type DrawArcProps, DrawCircle, type DrawCircleProps, DrawLine, type DrawLineProps, DrawPath, type DrawPathProps, DrawRect, type DrawRectProps, DrawText, type DrawTextProps };
|
package/dist/canvas.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use strict';var chunkACYN2UKT_js=require('./chunk-ACYN2UKT.js');require('./chunk-3CKIHQIE.js'),require('./chunk-E6Z7AI4J.js');var chunkDUGPBZZ3_js=require('./chunk-DUGPBZZ3.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 chunkACYN2UKT_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 chunkACYN2UKT_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 chunkACYN2UKT_js.c(()=>{l({type:"rect",props:t});}),null}function v(t){return chunkACYN2UKT_js.c(()=>{l({type:"circle",props:t});}),null}function A(t){return chunkACYN2UKT_js.c(()=>{l({type:"arc",props:t});}),null}function W(t){return chunkACYN2UKT_js.c(()=>{l({type:"line",props:t});}),null}function b(t){return chunkACYN2UKT_js.c(()=>{l({type:"text",props:t});}),null}function R(t){return chunkACYN2UKT_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
|
-
//# sourceMappingURL=canvas.js.map
|