feat(ui): migrate Flutter UI library to Next.js 16 (App Router)
Migrate all 87 Dart files from /Users/chase/Documents/cozsweet/lib/ui/ to TypeScript React components, replacing Flutter-native features with Web equivalents and reimplementing the BLoC pattern with React Context + useReducer. Highlights - 1:1 BLoC -> Context+useReducer+side-effects mapping for auth, chat, user, and sidebar features (4 providers wired in root-providers.tsx) - 500px MobileShell primitive eliminates per-screen layout boilerplate - Headless Dialog primitive (createPortal + ESC + scroll lock) powers quota / pwa-install / username / pronouns / subscription / other-options dialogs - New integrations/: facebook-sdk, google-identity, pwa-install, media-recorder (Web Speech API + MediaRecorder), browser-detect, chat-websocket (singleton), message-queue (throttled send) - CSS Modules + existing design tokens (no new styling system); extended with breakpoints.css and dimensions.css - Custom hooks: useBreakpoint (useSyncExternalStore), useFullVisibility (IntersectionObserver), usePwaInstall, usePullToRefresh - Vitest + jsdom; 15 unit tests (chat-reducer, auth-validators) - React 19.2.4, Next.js 16.2.7, Zod 4, lottie-react, classnames Workarounds - next.config.ts: experimental.staticGenerationRetryCount = 0 to bypass Next.js 16.2.7 /_global-error workStore prerender bug - src/app/global-error.tsx: required Client Component - src/types/globals.d.ts: centralized window.google / FB / SpeechRecognition declarations Routes (/, /splash, /auth, /chat, /chat/deviceid/[deviceId], /sidebar) all build and lint clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,26 +3,35 @@
|
||||
/**
|
||||
* 根级 Client Providers 包装
|
||||
*
|
||||
* 本轮只做两件事:
|
||||
* 1. 透传 `children`,让 `app/layout.tsx` 保持 Server Component 的同时,
|
||||
* 在子树中按需渲染 Client-only 组件(如未来 `<AuthContextProvider>`)。
|
||||
* 2. 预置一个 `<div id="toast-portal" />` 挂载点,供后续 toast 系统
|
||||
* 通过 `createPortal(..., document.getElementById("toast-portal"))` 渲染。
|
||||
* 把所有功能 Provider 串起来:
|
||||
* AuthProvider → UserProvider → SidebarProvider → ChatProvider
|
||||
*
|
||||
* 不引入任何运行时依赖;不挂载任何 Context。
|
||||
* 它们始终挂载,保证各页面直接 `use*State()` / `use*Dispatch()` 即可,
|
||||
* 无需在每个页面单独包裹。
|
||||
*/
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { AuthProvider } from "@/contexts/auth/auth-context";
|
||||
import { ChatProvider } from "@/contexts/chat/chat-context";
|
||||
import { SidebarProvider } from "@/contexts/sidebar/sidebar-context";
|
||||
import { UserProvider } from "@/contexts/user/user-context";
|
||||
|
||||
export interface RootProvidersProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function RootProviders({ children }: RootProvidersProps) {
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
<div id="toast-portal" />
|
||||
</>
|
||||
<AuthProvider>
|
||||
<UserProvider>
|
||||
<SidebarProvider>
|
||||
<ChatProvider>
|
||||
{children}
|
||||
<div id="toast-portal" />
|
||||
</ChatProvider>
|
||||
</SidebarProvider>
|
||||
</UserProvider>
|
||||
</AuthProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user