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.
- package/app/client/src/App.tsx +9 -11
- package/app/client/src/components/AppLayout.tsx +291 -290
- package/app/client/src/components/BackButton.tsx +17 -16
- package/app/client/src/components/ColorWheel.tsx +1 -0
- package/app/client/src/components/DemoPage.tsx +136 -135
- package/app/client/src/components/ErrorBoundary.tsx +2 -1
- package/app/client/src/components/LiveErrorBoundary.tsx +2 -1
- package/app/client/src/components/ThemePicker.tsx +1 -0
- package/app/client/src/framework/ClientOnly.tsx +14 -0
- package/app/client/src/framework/LivePage.tsx +55 -0
- package/app/client/src/framework/RscHomePage.tsx +125 -0
- package/app/client/src/framework/RscLink.tsx +31 -0
- package/app/client/src/framework/RscNav.tsx +42 -0
- package/app/client/src/framework/RscRoot.tsx +54 -0
- package/app/client/src/framework/csrf.ts +22 -0
- package/app/client/src/framework/entry.browser.tsx +51 -0
- package/app/client/src/framework/entry.rsc.tsx +41 -0
- package/app/client/src/framework/entry.ssr.tsx +12 -0
- package/app/client/src/framework/navigation.ts +29 -0
- package/app/client/src/framework/params.tsx +22 -0
- package/app/client/src/framework/routes.ts +143 -0
- package/app/client/src/framework/vite-rsc.d.ts +21 -0
- package/app/client/src/hooks/useThemeClock.ts +16 -1
- package/app/client/src/live/AuthDemo.tsx +271 -270
- package/app/client/src/live/CounterDemo.tsx +152 -151
- package/app/client/src/live/FormDemo.tsx +141 -140
- package/app/client/src/live/PingPongDemo.tsx +181 -180
- package/app/client/src/live/RoomChatDemo.tsx +398 -397
- package/app/client/src/live/SharedCounterDemo.tsx +2 -1
- package/app/client/src/pages/ApiTestPage.tsx +1 -0
- package/app/client/src/pages/auth.tsx +13 -0
- package/app/client/src/pages/blog/[slug].tsx +23 -0
- package/app/client/src/pages/counter.tsx +15 -0
- package/app/client/src/pages/form.tsx +13 -0
- package/app/client/src/pages/index.tsx +9 -0
- package/app/client/src/pages/ping-pong.tsx +13 -0
- package/app/client/src/pages/room-chat.tsx +13 -0
- package/app/client/src/pages/shared-counter.tsx +13 -0
- package/app/client/src/pages/sobre.tsx +19 -0
- package/app/server/index.ts +5 -1
- package/app/server/live/rooms/index.ts +14 -0
- package/config/system/plugins.config.ts +12 -2
- package/core/cli/commands/dev.ts +9 -1
- package/core/plugins/built-in/rsc/index.ts +156 -0
- package/core/plugins/built-in/ssr/bun-asset-loader.ts +46 -0
- package/core/plugins/built-in/ssr/index.ts +143 -0
- package/core/plugins/built-in/ssr/registry.ts +38 -0
- package/core/plugins/built-in/vite/index.ts +7 -0
- package/core/server/live/websocket-plugin.ts +29 -10
- package/core/utils/version.ts +6 -6
- package/create-fluxstack.ts +64 -5
- package/package.json +112 -108
- package/playwright.config.ts +6 -2
- package/vite.config.ts +22 -0
- package/app/client/.live-stubs/LiveUpload.js +0 -15
|
@@ -1,135 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{ to: '/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{ to: '/
|
|
11
|
-
{ to: '/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
1
|
+
'use client'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
import { Link, useLocation } from 'react-router'
|
|
4
|
+
import { FaArrowLeft, FaBolt } from 'react-icons/fa'
|
|
5
|
+
|
|
6
|
+
const demoNav = [
|
|
7
|
+
{ to: '/counter', label: 'Counter' },
|
|
8
|
+
{ to: '/form', label: 'Form' },
|
|
9
|
+
|
|
10
|
+
{ to: '/room-chat', label: 'Room Chat' },
|
|
11
|
+
{ to: '/auth', label: 'Auth' },
|
|
12
|
+
{ to: '/ping-pong', label: 'Ping Pong' },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const demoMeta: Record<string, { title: string; description: string; note?: ReactNode }> = {
|
|
16
|
+
'/counter': {
|
|
17
|
+
title: 'Counters',
|
|
18
|
+
description: 'Compare estado local, estado isolado por sala e estado compartilhado em tempo real.',
|
|
19
|
+
},
|
|
20
|
+
'/form': {
|
|
21
|
+
title: 'Live Form',
|
|
22
|
+
description: 'Formulario com campos sincronizados pelo servidor, debounce e estado compartilhado pelo proxy Live.',
|
|
23
|
+
note: <>Este formulario usa <code className="text-theme">Live.use()</code> - cada campo sincroniza automaticamente com o servidor.</>,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
'/shared-counter': {
|
|
27
|
+
title: 'Shared Counter',
|
|
28
|
+
description: 'Uma sala global sincroniza usuarios, eventos e estado entre abas abertas ao mesmo tempo.',
|
|
29
|
+
note: <>Contador compartilhado usando <code className="text-theme">LiveRoom</code> - abra em varias abas.</>,
|
|
30
|
+
},
|
|
31
|
+
'/room-chat': {
|
|
32
|
+
title: 'Room Chat',
|
|
33
|
+
description: 'Chat multi-sala com salas publicas, salas protegidas por senha e mensagens em tempo real.',
|
|
34
|
+
note: <>Chat com multiplas salas usando o sistema <code className="text-theme">$room</code>.</>,
|
|
35
|
+
},
|
|
36
|
+
'/auth': {
|
|
37
|
+
title: 'Live Auth',
|
|
38
|
+
description: 'Fluxo de autenticacao para Live Components com roles, permissoes e painel protegido.',
|
|
39
|
+
note: <>Sistema de autenticacao declarativo para Live Components com <code className="text-theme">$auth</code>.</>,
|
|
40
|
+
},
|
|
41
|
+
'/ping-pong': {
|
|
42
|
+
title: 'Ping Pong Binary',
|
|
43
|
+
description: 'Mede round-trip time de mensagens binarias no WebSocket usando codec msgpack.',
|
|
44
|
+
note: <>Latency demo com <code className="text-theme-secondary">msgpack</code> binary codec - mensagens binarias no WebSocket.</>,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface DemoPageProps {
|
|
49
|
+
children: ReactNode
|
|
50
|
+
title?: string
|
|
51
|
+
description?: string
|
|
52
|
+
eyebrow?: string
|
|
53
|
+
note?: ReactNode
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function DemoPage({
|
|
57
|
+
children,
|
|
58
|
+
title,
|
|
59
|
+
description,
|
|
60
|
+
eyebrow = 'Live Demo',
|
|
61
|
+
note,
|
|
62
|
+
}: DemoPageProps) {
|
|
63
|
+
const location = useLocation()
|
|
64
|
+
const meta = demoMeta[location.pathname]
|
|
65
|
+
const pageTitle = title ?? meta?.title ?? 'Live Component Demo'
|
|
66
|
+
const pageDescription = description ?? meta?.description ?? 'Explore uma capacidade do runtime Live em uma interface conectada ao servidor.'
|
|
67
|
+
const pageNote = meta?.note ?? note
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div className="relative min-h-[calc(100vh-128px)] overflow-hidden px-4 py-8 sm:px-6 lg:px-8">
|
|
71
|
+
<div className="absolute inset-0 app-grid-bg opacity-45" />
|
|
72
|
+
|
|
73
|
+
<div className="relative z-10 mx-auto flex w-full max-w-7xl flex-col gap-6">
|
|
74
|
+
<div className="flex flex-col gap-4">
|
|
75
|
+
<Link
|
|
76
|
+
to="/"
|
|
77
|
+
className="inline-flex w-fit items-center gap-2 rounded-lg border border-white/10 bg-white/[0.03] px-3 py-2 text-sm text-gray-300 transition hover:border-white/20 hover:bg-white/[0.06] hover:text-white"
|
|
78
|
+
>
|
|
79
|
+
<FaArrowLeft className="h-3 w-3" />
|
|
80
|
+
Home
|
|
81
|
+
</Link>
|
|
82
|
+
|
|
83
|
+
<section className="rounded-lg border border-white/10 bg-[#07070b]/75 p-5 shadow-2xl shadow-black/20 backdrop-blur sm:p-6">
|
|
84
|
+
<div className="flex flex-col gap-5 lg:flex-row lg:items-end lg:justify-between">
|
|
85
|
+
<div className="max-w-3xl">
|
|
86
|
+
<div className="mb-4 inline-flex items-center gap-2 rounded-full border border-theme-active bg-theme-muted px-3 py-1 text-xs font-medium text-theme">
|
|
87
|
+
<FaBolt className="h-3 w-3" />
|
|
88
|
+
{eyebrow}
|
|
89
|
+
</div>
|
|
90
|
+
<h1 className="text-3xl font-semibold tracking-tight text-white sm:text-4xl">
|
|
91
|
+
{pageTitle}
|
|
92
|
+
</h1>
|
|
93
|
+
<p className="mt-3 max-w-2xl text-sm leading-7 text-gray-400 sm:text-base">
|
|
94
|
+
{pageDescription}
|
|
95
|
+
</p>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div className="flex flex-wrap gap-2 lg:justify-end">
|
|
99
|
+
{demoNav.map(item => {
|
|
100
|
+
const active = location.pathname === item.to
|
|
101
|
+
return (
|
|
102
|
+
<Link
|
|
103
|
+
key={item.to}
|
|
104
|
+
to={item.to}
|
|
105
|
+
className={`rounded-lg border px-3 py-2 text-xs font-medium transition ${
|
|
106
|
+
active
|
|
107
|
+
? 'border-white bg-white text-black'
|
|
108
|
+
: 'border-white/10 bg-white/[0.025] text-gray-400 hover:border-white/20 hover:bg-white/[0.06] hover:text-white'
|
|
109
|
+
}`}
|
|
110
|
+
>
|
|
111
|
+
{item.label}
|
|
112
|
+
</Link>
|
|
113
|
+
)
|
|
114
|
+
})}
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
</section>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<section className="rounded-lg border border-white/10 bg-black/20 p-3 shadow-2xl shadow-black/20 backdrop-blur sm:p-5">
|
|
121
|
+
<div className="mx-auto flex w-full max-w-6xl flex-col items-center">
|
|
122
|
+
{children}
|
|
123
|
+
</div>
|
|
124
|
+
</section>
|
|
125
|
+
|
|
126
|
+
{pageNote && (
|
|
127
|
+
<aside className="mx-auto w-full max-w-3xl rounded-lg border border-theme bg-theme-accent px-4 py-3 text-center">
|
|
128
|
+
<p className="text-xs leading-6 text-gray-400 sm:text-sm">
|
|
129
|
+
{pageNote}
|
|
130
|
+
</p>
|
|
131
|
+
</aside>
|
|
132
|
+
)}
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
// ClientOnly — adia a renderização dos filhos até DEPOIS da hidratação.
|
|
3
|
+
// Os Live Components (@fluxstack/live-react) usam Live.use(), que não suporta
|
|
4
|
+
// render no SSR (server.edge). Então no server/SSR mostramos um placeholder e
|
|
5
|
+
// só montamos o Live no client após o mount. Isso evita o erro de SSR e mantém
|
|
6
|
+
// o resto da página (server components) renderizando normalmente.
|
|
7
|
+
import { useEffect, useState } from 'react'
|
|
8
|
+
import type { ReactNode } from 'react'
|
|
9
|
+
|
|
10
|
+
export function ClientOnly({ children, fallback = null }: { children: ReactNode; fallback?: ReactNode }) {
|
|
11
|
+
const [mounted, setMounted] = useState(false)
|
|
12
|
+
useEffect(() => setMounted(true), [])
|
|
13
|
+
return <>{mounted ? children : fallback}</>
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
// LivePage — wrapper de página que usa Live Components.
|
|
3
|
+
//
|
|
4
|
+
// Esconde a cerimônia: cabeçalho (server-friendly) + LiveComponentsProvider +
|
|
5
|
+
// ClientOnly. O dev só escreve <LivePage><MeuDemoLive/></LivePage> e os Live
|
|
6
|
+
// Components funcionam (placeholder no SSR, conectam no client). O Provider
|
|
7
|
+
// compartilha a conexão única via connectionPool (keep-alive no entry.browser).
|
|
8
|
+
import type { ReactNode } from 'react'
|
|
9
|
+
import { LiveComponentsProvider } from '@/core/client'
|
|
10
|
+
import { ClientOnly } from './ClientOnly'
|
|
11
|
+
import { ParamsProvider } from './params'
|
|
12
|
+
import type { RouteParams } from './routes'
|
|
13
|
+
|
|
14
|
+
function Loading() {
|
|
15
|
+
return (
|
|
16
|
+
<div className="flex w-full items-center justify-center rounded-lg border border-white/10 bg-white/[0.02] p-12 text-sm text-gray-500">
|
|
17
|
+
<span className="mr-2 inline-block h-3 w-3 animate-pulse rounded-full bg-theme" />
|
|
18
|
+
Conectando ao Live…
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function LivePage({
|
|
24
|
+
title,
|
|
25
|
+
description,
|
|
26
|
+
params = {},
|
|
27
|
+
children,
|
|
28
|
+
}: {
|
|
29
|
+
title?: string
|
|
30
|
+
description?: string
|
|
31
|
+
/** params da rota — repasse o `params` que a página recebeu, p/ useParams() funcionar */
|
|
32
|
+
params?: RouteParams
|
|
33
|
+
children: ReactNode
|
|
34
|
+
}) {
|
|
35
|
+
return (
|
|
36
|
+
<div className="relative min-h-[calc(100vh-57px)] px-4 py-10">
|
|
37
|
+
<div className="absolute inset-0 app-grid-bg opacity-70" />
|
|
38
|
+
<div className="relative z-10 mx-auto flex max-w-7xl flex-col gap-6">
|
|
39
|
+
{title && (
|
|
40
|
+
<div>
|
|
41
|
+
<h1 className="text-3xl font-semibold text-white">{title}</h1>
|
|
42
|
+
{description && <p className="mt-1 text-sm text-gray-500">{description}</p>}
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
<ClientOnly fallback={<Loading />}>
|
|
46
|
+
<ParamsProvider params={params}>
|
|
47
|
+
<LiveComponentsProvider autoConnect reconnectInterval={1000} heartbeatInterval={30000}>
|
|
48
|
+
{children}
|
|
49
|
+
</LiveComponentsProvider>
|
|
50
|
+
</ParamsProvider>
|
|
51
|
+
</ClientOnly>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// HomePage como SERVER COMPONENT (RSC) — a página bonita original, portada.
|
|
2
|
+
// Sem estado/interatividade → roda 100% no server, 0 JS no client.
|
|
3
|
+
// Diferenças vs HomePage.tsx original:
|
|
4
|
+
// - <Link> (react-router) → <a> (navegação RSC usa anchor + fetch do payload)
|
|
5
|
+
// - apiStatus vem como prop do server (sem fetch client no shell)
|
|
6
|
+
import FluxStack from '@client/src/assets/fluxstack.svg'
|
|
7
|
+
import {
|
|
8
|
+
FaArrowRight,
|
|
9
|
+
FaBolt,
|
|
10
|
+
FaCodeBranch,
|
|
11
|
+
FaLayerGroup,
|
|
12
|
+
FaServer,
|
|
13
|
+
FaShieldAlt,
|
|
14
|
+
FaTerminal,
|
|
15
|
+
} from 'react-icons/fa'
|
|
16
|
+
|
|
17
|
+
export function RscHomePage() {
|
|
18
|
+
const features = [
|
|
19
|
+
{ icon: FaBolt, title: 'Runtime rapido', copy: 'Bun no centro do fluxo de dev e build, com feedback curto para projetos full stack.' },
|
|
20
|
+
{ icon: FaShieldAlt, title: 'Type-safe', copy: 'Contratos compartilhados entre Elysia, Eden Treaty e React sem duplicar modelos.' },
|
|
21
|
+
{ icon: FaLayerGroup, title: 'Live Components', copy: 'Estado no servidor com UI reativa, salas em tempo real e componentes declarativos.' },
|
|
22
|
+
]
|
|
23
|
+
const stackItems = ['Bun', 'Elysia', 'React', 'TypeScript']
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="relative min-h-[calc(100vh-72px)] overflow-hidden px-4 py-10 sm:px-6 lg:px-8">
|
|
27
|
+
<div className="absolute inset-0 app-grid-bg opacity-70" />
|
|
28
|
+
<div className="absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-white/25 to-transparent" />
|
|
29
|
+
|
|
30
|
+
<div className="relative z-10 mx-auto flex w-full max-w-7xl flex-col gap-10 lg:min-h-[calc(100vh-144px)] lg:justify-center">
|
|
31
|
+
<section className="grid items-center gap-8 lg:grid-cols-[1.04fr_0.96fr]">
|
|
32
|
+
<div className="max-w-3xl">
|
|
33
|
+
<div className="mb-6 inline-flex items-center gap-2 rounded-full border border-white/10 bg-white/[0.04] px-3 py-1.5 text-xs text-gray-300 shadow-[inset_0_1px_0_rgba(255,255,255,0.08)]">
|
|
34
|
+
<span className="h-1.5 w-1.5 rounded-full bg-emerald-300" />
|
|
35
|
+
<span className="rounded-full border border-emerald-400/25 bg-emerald-400/10 text-emerald-200 px-2 py-0.5">Server Rendered (RSC)</span>
|
|
36
|
+
<span className="hidden sm:inline">Full-stack starter for production apps</span>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div className="mb-5 flex items-center gap-4">
|
|
40
|
+
<div className="relative flex h-16 w-16 items-center justify-center rounded-lg border border-white/10 bg-white/[0.04] shadow-2xl shadow-black/30">
|
|
41
|
+
<img src={FluxStack} alt="FluxStack" className="h-11 w-11 glow-theme" />
|
|
42
|
+
</div>
|
|
43
|
+
<div className="hidden h-px flex-1 bg-gradient-to-r from-white/20 to-transparent sm:block" />
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<h1 className="max-w-4xl text-left text-5xl font-semibold tracking-tight text-white sm:text-6xl lg:text-7xl">
|
|
47
|
+
FluxStack
|
|
48
|
+
<span className="block bg-theme-gradient bg-clip-text text-transparent">TypeScript full stack.</span>
|
|
49
|
+
</h1>
|
|
50
|
+
|
|
51
|
+
<p className="mt-5 max-w-2xl text-left text-base leading-8 text-gray-400 sm:text-lg">
|
|
52
|
+
Um framework direto ao ponto para construir APIs Elysia, interfaces React,
|
|
53
|
+
componentes em tempo real e contratos type-safe em uma unica base.
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<div className="mt-8 flex flex-col gap-3 sm:flex-row">
|
|
57
|
+
<a href="/counter" className="inline-flex h-11 items-center justify-center gap-2 rounded-lg bg-white px-5 text-sm font-semibold text-black transition hover:bg-gray-200">
|
|
58
|
+
Ver demos
|
|
59
|
+
<FaArrowRight className="h-3.5 w-3.5" />
|
|
60
|
+
</a>
|
|
61
|
+
<a href="/swagger" target="_blank" rel="noopener noreferrer" className="inline-flex h-11 items-center justify-center gap-2 rounded-lg border border-white/10 bg-white/[0.03] px-5 text-sm font-semibold text-white transition hover:border-white/20 hover:bg-white/[0.06]">
|
|
62
|
+
<FaServer className="h-3.5 w-3.5 text-theme" />
|
|
63
|
+
API docs
|
|
64
|
+
</a>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div className="mt-8 flex flex-wrap gap-2">
|
|
68
|
+
{stackItems.map((item) => (
|
|
69
|
+
<span key={item} className="rounded-full border border-white/10 bg-black/20 px-3 py-1 text-xs font-medium text-gray-300">{item}</span>
|
|
70
|
+
))}
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div className="relative">
|
|
75
|
+
<div className="rounded-lg border border-white/10 bg-[#050508]/80 shadow-2xl shadow-black/40 backdrop-blur">
|
|
76
|
+
<div className="flex items-center justify-between border-b border-white/10 px-4 py-3">
|
|
77
|
+
<div className="flex items-center gap-2">
|
|
78
|
+
<span className="h-2.5 w-2.5 rounded-full bg-red-400/80" />
|
|
79
|
+
<span className="h-2.5 w-2.5 rounded-full bg-amber-300/80" />
|
|
80
|
+
<span className="h-2.5 w-2.5 rounded-full bg-emerald-300/80" />
|
|
81
|
+
</div>
|
|
82
|
+
<span className="font-mono text-xs text-gray-500">fluxstack.config.ts</span>
|
|
83
|
+
</div>
|
|
84
|
+
<div className="space-y-5 p-5 sm:p-6">
|
|
85
|
+
<div className="rounded-lg border border-white/10 bg-white/[0.03] p-4">
|
|
86
|
+
<div className="mb-3 flex items-center gap-2 text-sm font-semibold text-white">
|
|
87
|
+
<FaTerminal className="text-theme" />
|
|
88
|
+
Ship from one command
|
|
89
|
+
</div>
|
|
90
|
+
<pre className="overflow-x-auto rounded-md bg-black/50 p-4 text-left text-xs leading-6 text-gray-300">
|
|
91
|
+
<code>{`bunx create-fluxstack my-app\ncd my-app\nbun dev`}</code>
|
|
92
|
+
</pre>
|
|
93
|
+
</div>
|
|
94
|
+
<div className="grid gap-3 sm:grid-cols-2">
|
|
95
|
+
<div className="rounded-lg border border-white/10 bg-white/[0.03] p-4">
|
|
96
|
+
<FaCodeBranch className="mb-4 text-theme-secondary" />
|
|
97
|
+
<p className="text-sm font-semibold text-white">Typed routes</p>
|
|
98
|
+
<p className="mt-1 text-xs leading-5 text-gray-500">Client e server compartilham o contrato.</p>
|
|
99
|
+
</div>
|
|
100
|
+
<div className="rounded-lg border border-white/10 bg-white/[0.03] p-4">
|
|
101
|
+
<FaLayerGroup className="mb-4 text-theme" />
|
|
102
|
+
<p className="text-sm font-semibold text-white">Live UI</p>
|
|
103
|
+
<p className="mt-1 text-xs leading-5 text-gray-500">WebSocket, rooms e estado remoto.</p>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</section>
|
|
110
|
+
|
|
111
|
+
<section className="grid gap-3 sm:grid-cols-3">
|
|
112
|
+
{features.map(({ icon: Icon, title, copy }) => (
|
|
113
|
+
<article key={title} className="group rounded-lg border border-white/10 bg-white/[0.025] p-5 text-left transition hover:border-white/20 hover:bg-white/[0.045]">
|
|
114
|
+
<div className="mb-5 flex h-9 w-9 items-center justify-center rounded-lg border border-white/10 bg-black/30 text-theme transition group-hover:border-theme-active">
|
|
115
|
+
<Icon className="h-4 w-4" />
|
|
116
|
+
</div>
|
|
117
|
+
<h2 className="text-sm font-semibold text-white">{title}</h2>
|
|
118
|
+
<p className="mt-2 text-sm leading-6 text-gray-500">{copy}</p>
|
|
119
|
+
</article>
|
|
120
|
+
))}
|
|
121
|
+
</section>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
// Link client-side para navegação RSC sem reload. Intercepta o clique e usa
|
|
3
|
+
// o navigate do RootClient (fetch do .rsc + transition). Cai pra <a> normal
|
|
4
|
+
// em ctrl/cmd-click, target _blank, ou links externos.
|
|
5
|
+
import type { ReactNode, MouseEvent } from 'react'
|
|
6
|
+
import { navigate } from './navigation'
|
|
7
|
+
|
|
8
|
+
export function RscLink({
|
|
9
|
+
href,
|
|
10
|
+
className,
|
|
11
|
+
children,
|
|
12
|
+
external,
|
|
13
|
+
}: {
|
|
14
|
+
href: string
|
|
15
|
+
className?: string
|
|
16
|
+
children: ReactNode
|
|
17
|
+
external?: boolean
|
|
18
|
+
}) {
|
|
19
|
+
function onClick(e: MouseEvent<HTMLAnchorElement>) {
|
|
20
|
+
if (external) return // deixa o browser tratar (ex: /swagger, target _blank)
|
|
21
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) return
|
|
22
|
+
e.preventDefault()
|
|
23
|
+
navigate(href)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<a href={href} className={className} onClick={onClick} {...(external ? { target: '_blank', rel: 'noopener noreferrer' } : {})}>
|
|
28
|
+
{children}
|
|
29
|
+
</a>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Navbar SERVER COMPONENT — gerada automaticamente a partir das rotas descobertas
|
|
2
|
+
// (file-based). Adicionar uma página em pages/ a faz aparecer aqui sozinha
|
|
3
|
+
// (a menos que a página exporte `nav = false`). Links via RscLink (SPA sem reload).
|
|
4
|
+
import FluxStackLogo from '@client/src/assets/fluxstack.svg'
|
|
5
|
+
import { RscLink } from './RscLink'
|
|
6
|
+
import { routes } from './routes'
|
|
7
|
+
|
|
8
|
+
export function RscNav({ active }: { active: string }) {
|
|
9
|
+
const navItems = routes.filter((r) => r.inNav)
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<header className="sticky top-0 z-50 border-b border-white/10 bg-black/60 backdrop-blur">
|
|
13
|
+
<div className="mx-auto flex max-w-7xl items-center gap-6 px-4 py-3">
|
|
14
|
+
<RscLink href="/" className="flex items-center gap-2">
|
|
15
|
+
<img src={FluxStackLogo} alt="FluxStack" className="h-6 w-6" />
|
|
16
|
+
<span className="font-semibold text-white">FluxStack</span>
|
|
17
|
+
</RscLink>
|
|
18
|
+
<nav className="flex flex-wrap items-center gap-1">
|
|
19
|
+
{navItems.map((item) => {
|
|
20
|
+
const isActive = item.path === active
|
|
21
|
+
return (
|
|
22
|
+
<RscLink
|
|
23
|
+
key={item.path}
|
|
24
|
+
href={item.path}
|
|
25
|
+
className={`rounded-lg px-3 py-1.5 text-sm transition ${
|
|
26
|
+
isActive
|
|
27
|
+
? 'bg-white/10 text-white'
|
|
28
|
+
: 'text-gray-400 hover:bg-white/[0.05] hover:text-white'
|
|
29
|
+
}`}
|
|
30
|
+
>
|
|
31
|
+
{item.navLabel}
|
|
32
|
+
</RscLink>
|
|
33
|
+
)
|
|
34
|
+
})}
|
|
35
|
+
</nav>
|
|
36
|
+
<RscLink href="/swagger" external className="ml-auto text-sm text-gray-400 hover:text-white">
|
|
37
|
+
API docs
|
|
38
|
+
</RscLink>
|
|
39
|
+
</div>
|
|
40
|
+
</header>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// SERVER COMPONENTS do site FluxStack via RSC — agora com roteamento FILE-BASED.
|
|
2
|
+
//
|
|
3
|
+
// O dev NÃO edita este arquivo para adicionar páginas: basta criar um arquivo em
|
|
4
|
+
// app/client/src/pages/ (ver framework/routes.ts). Aqui só montamos a casca
|
|
5
|
+
// (navbar + a página que casa com o pathname) a partir do mapa descoberto.
|
|
6
|
+
import '../index.css' // Tailwind + temas
|
|
7
|
+
import { RscNav } from './RscNav'
|
|
8
|
+
import { routes, matchRoute } from './routes'
|
|
9
|
+
|
|
10
|
+
function NotFound({ pathname }: { pathname: string }) {
|
|
11
|
+
return (
|
|
12
|
+
<div className="flex min-h-[calc(100vh-57px)] flex-col items-center justify-center gap-4 text-center">
|
|
13
|
+
<h1 className="text-6xl font-black text-white">404</h1>
|
|
14
|
+
<p className="text-gray-400">A rota <code className="text-theme">{pathname}</code> não existe.</p>
|
|
15
|
+
<a href="/" className="rounded-lg bg-white px-5 py-2 text-sm font-semibold text-black">Voltar ao início</a>
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Conteúdo da rota (nav + página). É o que as navegações client buscam (.rsc). */
|
|
21
|
+
export function RscPage({ pathname = '/' }: { pathname?: string }) {
|
|
22
|
+
const match = matchRoute(pathname)
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<RscNav active={pathname} />
|
|
26
|
+
{match
|
|
27
|
+
? <match.route.Component params={match.params} />
|
|
28
|
+
: <NotFound pathname={pathname} />}
|
|
29
|
+
</>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Documento completo. Controle client (navegação + keep-alive WS) vive no
|
|
34
|
+
* entry.browser; o body renderiza o RscPage direto.
|
|
35
|
+
* csrfToken: injetado pelo server p/ o client não precisar fazer fetch('/api/__csrf'). */
|
|
36
|
+
export function RscDocument({ pathname = '/', csrfToken }: { pathname?: string; csrfToken?: string }) {
|
|
37
|
+
return (
|
|
38
|
+
<html lang="pt-BR">
|
|
39
|
+
<head>
|
|
40
|
+
<meta charSet="utf-8" />
|
|
41
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
42
|
+
{csrfToken && <meta name="csrf-token" content={csrfToken} />}
|
|
43
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
44
|
+
<title>FluxStack</title>
|
|
45
|
+
</head>
|
|
46
|
+
<body>
|
|
47
|
+
<RscPage pathname={pathname} />
|
|
48
|
+
</body>
|
|
49
|
+
</html>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// re-export para conveniência
|
|
54
|
+
export { routes }
|