From f50d864a66b29a7b385718f71f23b8b523c9ac72 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Fri, 15 May 2026 21:10:11 +0200 Subject: [PATCH 1/2] fix: correct router registration --- src/devtools-handlers.ts | 16 ++++++++++++++-- src/devtools.ts | 9 +++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/devtools-handlers.ts b/src/devtools-handlers.ts index 27b9665..bd10381 100644 --- a/src/devtools-handlers.ts +++ b/src/devtools-handlers.ts @@ -20,6 +20,7 @@ import { postHandler as htmlValidatePost, deleteHandler as htmlValidateDelete, } from './runtime/html-validate/api-handlers' +import { addDevServerHandler } from '@nuxt/kit' export { getHydrationMismatches, @@ -30,8 +31,10 @@ export { clearHtmlValidateReport, } -export function createHintsRouter() { - const router = createRouter() +function createHintsRouter() { + const router = createRouter({ + preemptive: true + }) router.get('/hydration', hydrationGet) router.post('/hydration', hydrationPost) @@ -47,3 +50,12 @@ export function createHintsRouter() { return router } + +export function registerDevServerHandlers() { + const router = createHintsRouter() + + addDevServerHandler({ + route: '/__nuxt_hints', + handler: router.handler, + }) +} \ No newline at end of file diff --git a/src/devtools.ts b/src/devtools.ts index d1c35b2..31171cf 100644 --- a/src/devtools.ts +++ b/src/devtools.ts @@ -7,13 +7,13 @@ import { joinURL } from 'ufo' import type { HintsClientFunctions, HintsServerFunctions } from './runtime/core/rpc-types' import { RPC_NAMESPACE } from './runtime/core/rpc-types' import { - createHintsRouter, - getHydrationMismatches, + getHydrationMismatches, clearHydrationMismatches, getLazyLoadHints, clearLazyLoadHint, getHtmlValidateReports, clearHtmlValidateReport, + registerDevServerHandlers, } from './devtools-handlers' const DEVTOOLS_UI_ROUTE = '/__nuxt-hints' @@ -54,10 +54,7 @@ export function setupDevToolsUI(nuxt: Nuxt, resolver: Resolver) { }, }, nuxt) - addDevServerHandler({ - route: '/__nuxt_hints', - handler: createHintsRouter().handler, - }) + registerDevServerHandlers() onDevToolsInitialized(() => { const rpc = extendServerRpc(RPC_NAMESPACE, { From fe6ec472d30fd5b30d8a6d2e41423b2e54fdbf78 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Sat, 16 May 2026 14:08:32 +0200 Subject: [PATCH 2/2] chore: lint --- src/devtools-handlers.ts | 4 ++-- src/devtools.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/devtools-handlers.ts b/src/devtools-handlers.ts index bd10381..3421fb6 100644 --- a/src/devtools-handlers.ts +++ b/src/devtools-handlers.ts @@ -33,7 +33,7 @@ export { function createHintsRouter() { const router = createRouter({ - preemptive: true + preemptive: true, }) router.get('/hydration', hydrationGet) @@ -58,4 +58,4 @@ export function registerDevServerHandlers() { route: '/__nuxt_hints', handler: router.handler, }) -} \ No newline at end of file +} diff --git a/src/devtools.ts b/src/devtools.ts index 31171cf..d29c4f9 100644 --- a/src/devtools.ts +++ b/src/devtools.ts @@ -7,7 +7,7 @@ import { joinURL } from 'ufo' import type { HintsClientFunctions, HintsServerFunctions } from './runtime/core/rpc-types' import { RPC_NAMESPACE } from './runtime/core/rpc-types' import { - getHydrationMismatches, + getHydrationMismatches, clearHydrationMismatches, getLazyLoadHints, clearLazyLoadHint,