mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
34b1b56788
Phase 1 of the refactor plan in docs/ARCHITECTURE.md.
Install
- yarn add @tanstack/react-query@5 @tanstack/react-query-devtools@5
- Both pinned to ^5 (matches React 19 peer requirement).
Wiring
- src/index.tsx: mounts QueryClientProvider above ErrorBoundary +
Suspense. Default config: staleTime=30s, retry=1,
refetchOnWindowFocus=false (chat client, not a data dashboard).
Adapter
- src/api/nitro-query/createNitroQuery.ts: replaces the previous
prototype that just threw. Exposes:
* useNitroQuery({ key, request, parser, select, timeoutMs })
— wraps TanStack's useQuery; queryFn awaits the parser response.
* awaitNitroResponse(...) — lower-level helper for imperative use
via queryClient.fetchQuery.
The Promise:
1. registers the parser via GetCommunication().registerMessageEvent
2. dispatches the composer via SendMessageComposer
3. resolves with select(event) on the first matching parser
4. rejects after timeoutMs (default 15s)
5. always cleans up the listener + timeout (cancel-safe).
Pilot
- src/components/catalog/views/targeted-offer/OfferView.tsx:
the previous useMessageEventState + manual useEffect-send pattern
becomes a single useNitroQuery call. staleTime:Infinity because the
targeted offer doesn't change during a session. Subsequent OfferView
remounts (e.g. opening/closing the dialog) now reuse the cached
payload — the GetTargetedOfferComposer is no longer re-sent each
time.
Verification
- yarn eslint on the four touched files: 1 pre-existing
no-redundant-type-constituents error (IMessageEvent resolves as `any`
in the local sandbox without the renderer SDK installed; matches the
12 other pre-existing instances of the same false positive).
- yarn tsc on the four touched files: clean (modulo the
project-wide TS2307 about @nitrots/nitro-renderer).
- The original prototype's "throw" guard is gone — useNitroQuery is now
callable.
Migration path (per docs/ARCHITECTURE.md)
- Next adoption targets (read-only fetches first): useCatalog's page
data, useInventoryFurni's bot listing, Navigator search results,
Marketplace listings.
- Push messages (server-pushed events the client doesn't request)
keep using useNitroEventState / useMessageEventState — they're
subscriptions, not requests.
https://claude.ai/code/session_01GrR87LAqnAEyKG2ZbmQt5Q
58 lines
2.0 KiB
JSON
58 lines
2.0 KiB
JSON
{
|
|
"name": "nitro-react",
|
|
"version": "2.2",
|
|
"homepage": ".",
|
|
"private": true,
|
|
"scripts": {
|
|
"prebuild": "node scripts/write-asset-loader.mjs",
|
|
"start": "vite --host",
|
|
"build": "vite build && node scripts/minify-dist.mjs",
|
|
"build:prod": "npx browserslist@latest --update-db && yarn build",
|
|
"eslint": "eslint ./src",
|
|
"typecheck": "tsgo --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"@babel/runtime": "^7.29.2",
|
|
"@emoji-mart/data": "^1.2.1",
|
|
"@emoji-mart/react": "^1.1.1",
|
|
"@radix-ui/react-popover": "^1.1.15",
|
|
"@radix-ui/react-slider": "^1.3.6",
|
|
"@tanstack/react-query": "5",
|
|
"@tanstack/react-query-devtools": "5",
|
|
"@tanstack/react-virtual": "^3.13.24",
|
|
"dompurify": "^3.4.2",
|
|
"emoji-mart": "^5.6.0",
|
|
"emoji-toolkit": "10.0.0",
|
|
"framer-motion": "^12.38.0",
|
|
"react": "^19.2.5",
|
|
"react-dom": "^19.2.5",
|
|
"react-error-boundary": "^6.1.1",
|
|
"react-icons": "^5.6.0",
|
|
"react-player": "^2.16.0",
|
|
"use-between": "^1.4.0"
|
|
},
|
|
"devDependencies": {
|
|
"@tailwindcss/forms": "^0.5.11",
|
|
"@tailwindcss/postcss": "^4.2.4",
|
|
"@types/node": "^25.6.0",
|
|
"@types/react": "^19.2.14",
|
|
"@types/react-dom": "^19.2.3",
|
|
"@typescript-eslint/eslint-plugin": "^8.59.1",
|
|
"@typescript-eslint/parser": "^8.59.1",
|
|
"@typescript/native-preview": "^7.0.0-dev.20260509.2",
|
|
"@vitejs/plugin-react": "^6.0.1",
|
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
"eslint": "^10.2.1",
|
|
"eslint-plugin-react": "^7.37.5",
|
|
"eslint-plugin-react-compiler": "19.1.0-rc.2",
|
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
"postcss": "^8.5.12",
|
|
"postcss-nested": "^7.0.2",
|
|
"sass": "^1.99.0",
|
|
"tailwindcss": "^4.2.4",
|
|
"typescript": "^6.0.3",
|
|
"typescript-eslint": "^8.59.1",
|
|
"vite": "^8.0.10"
|
|
}
|
|
}
|