create-fluxstack 1.21.1 → 1.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/app/client/src/App.tsx +9 -11
  2. package/app/client/src/components/AppLayout.tsx +291 -290
  3. package/app/client/src/components/BackButton.tsx +17 -16
  4. package/app/client/src/components/ColorWheel.tsx +1 -0
  5. package/app/client/src/components/DemoPage.tsx +136 -135
  6. package/app/client/src/components/ErrorBoundary.tsx +2 -1
  7. package/app/client/src/components/LiveErrorBoundary.tsx +2 -1
  8. package/app/client/src/components/ThemePicker.tsx +1 -0
  9. package/app/client/src/framework/ClientOnly.tsx +14 -0
  10. package/app/client/src/framework/LivePage.tsx +55 -0
  11. package/app/client/src/framework/RscHomePage.tsx +125 -0
  12. package/app/client/src/framework/RscLink.tsx +31 -0
  13. package/app/client/src/framework/RscNav.tsx +42 -0
  14. package/app/client/src/framework/RscRoot.tsx +54 -0
  15. package/app/client/src/framework/csrf.ts +22 -0
  16. package/app/client/src/framework/entry.browser.tsx +51 -0
  17. package/app/client/src/framework/entry.rsc.tsx +41 -0
  18. package/app/client/src/framework/entry.ssr.tsx +12 -0
  19. package/app/client/src/framework/navigation.ts +29 -0
  20. package/app/client/src/framework/params.tsx +22 -0
  21. package/app/client/src/framework/routes.ts +143 -0
  22. package/app/client/src/framework/vite-rsc.d.ts +21 -0
  23. package/app/client/src/hooks/useThemeClock.ts +16 -1
  24. package/app/client/src/live/AuthDemo.tsx +271 -270
  25. package/app/client/src/live/CounterDemo.tsx +152 -151
  26. package/app/client/src/live/FormDemo.tsx +141 -140
  27. package/app/client/src/live/PingPongDemo.tsx +181 -180
  28. package/app/client/src/live/RoomChatDemo.tsx +398 -397
  29. package/app/client/src/live/SharedCounterDemo.tsx +2 -1
  30. package/app/client/src/pages/ApiTestPage.tsx +1 -0
  31. package/app/client/src/pages/auth.tsx +13 -0
  32. package/app/client/src/pages/blog/[slug].tsx +23 -0
  33. package/app/client/src/pages/counter.tsx +15 -0
  34. package/app/client/src/pages/form.tsx +13 -0
  35. package/app/client/src/pages/index.tsx +9 -0
  36. package/app/client/src/pages/ping-pong.tsx +13 -0
  37. package/app/client/src/pages/room-chat.tsx +13 -0
  38. package/app/client/src/pages/shared-counter.tsx +13 -0
  39. package/app/client/src/pages/sobre.tsx +19 -0
  40. package/app/server/index.ts +5 -1
  41. package/app/server/live/rooms/index.ts +14 -0
  42. package/config/system/plugins.config.ts +12 -2
  43. package/core/cli/commands/dev.ts +9 -1
  44. package/core/plugins/built-in/rsc/index.ts +156 -0
  45. package/core/plugins/built-in/ssr/bun-asset-loader.ts +46 -0
  46. package/core/plugins/built-in/ssr/index.ts +143 -0
  47. package/core/plugins/built-in/ssr/registry.ts +38 -0
  48. package/core/plugins/built-in/vite/index.ts +7 -0
  49. package/core/server/live/websocket-plugin.ts +29 -10
  50. package/core/utils/version.ts +6 -6
  51. package/create-fluxstack.ts +64 -5
  52. package/package.json +112 -108
  53. package/playwright.config.ts +6 -2
  54. package/vite.config.ts +22 -0
  55. package/app/client/.live-stubs/LiveUpload.js +0 -15
@@ -1,5 +1,5 @@
1
1
  import { useState, useEffect, useRef } from 'react'
2
- import { Routes, Route } from 'react-router'
2
+ import { Routes, Route, useLocation } from 'react-router'
3
3
  import { api } from './lib/eden-api'
4
4
  import { LiveComponentsProvider, useLiveComponents } from '@/core/client'
5
5
  import { executeHook } from './lib/plugin-hooks'
@@ -16,12 +16,15 @@ import { HomePage } from './pages/HomePage'
16
16
  import { ApiTestPage } from './pages/ApiTestPage'
17
17
 
18
18
  function NotFoundPage() {
19
+ // SSR-safe: useLocation funciona no server (StaticRouter) e no client,
20
+ // diferente de window.location que quebra durante renderToString.
21
+ const { pathname } = useLocation()
19
22
  return (
20
23
  <div className="flex flex-col items-center justify-center min-h-[60vh] text-center px-4">
21
24
  <h1 className="text-6xl font-black text-white mb-4">404</h1>
22
25
  <p className="text-xl text-gray-400 mb-6">Pagina nao encontrada</p>
23
26
  <p className="text-sm text-gray-500 mb-8">
24
- O caminho <code className="text-theme">{window.location.pathname}</code> nao existe.
27
+ O caminho <code className="text-theme">{pathname}</code> nao existe.
25
28
  </p>
26
29
  <a
27
30
  href="/"
@@ -197,19 +200,14 @@ function AppContent() {
197
200
  }
198
201
 
199
202
  function App() {
200
- // In dev, connect WebSocket directly to backend (port 3000) to avoid
201
- // Vite proxy overhead and HMR WebSocket contention on port 5173.
202
- // In production, both are served from the same origin so auto-detect works.
203
- const wsUrl = import.meta.env.DEV
204
- ? 'ws://localhost:3000/api/live/ws'
205
- : undefined
206
-
203
+ // Sem `url`: o WebSocket usa auto-detect (mesma origem da página). Acesse o
204
+ // app pela porta do Elysia (3000) ele serve frontend (proxy Vite) + API +
205
+ // WS na mesma origem, então o WS resolve para ws(s)://<host>/api/live/ws.
206
+ // (Acessar o Vite cru na 5173 não tem WS Live — entre sempre pela 3000.)
207
207
  return (
208
208
  <LiveComponentsProvider
209
- //url={wsUrl}
210
209
  autoConnect={true}
211
210
  reconnectInterval={1000}
212
- maxReconnectAttempts={5}
213
211
  heartbeatInterval={30000}
214
212
  debug={false}
215
213
  >