8000 refactor(nitro,nuxt): move to `nitropack/runtime` namespace · nuxt/nuxt@897a225 · GitHub
[go: up one dir, main page]

Skip to content

Commit 897a225

Browse files
committed
refactor(nitro,nuxt): move to nitropack/runtime namespace
1 parent 5ce351d commit 897a225

File tree

11 files changed

+59
-10
lines changed

11 files changed

+59
-10
lines changed

packages/nitro-server/src/augments.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,33 @@ declare module 'nitropack' {
3333
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
3434
}
3535
}
36+
declare module 'nitropack/types' {
37+
interface NitroRuntimeConfigApp {
38+
buildAssetsDir: string
39+
cdnURL: string
40+
}
41+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
42+
interface NitroRuntimeConfig extends RuntimeConfig {}
43+
interface NitroRouteConfig {
44+
ssr?: boolean
45+
noScripts?: boolean
46+
/** @deprecated Use `noScripts` instead */
47+
experimentalNoScripts?: boolean
48+
}
49+
interface NitroRouteRules {
50+
ssr?: boolean
51+
noScripts?: boolean
52+
/** @deprecated Use `noScripts` instead */
53+
experimentalNoScripts?: boolean
54+
appMiddleware?: Record<string, boolean>
55+
appLayout?: string | false
56+
}
57+
interface NitroRuntimeHooks {
58+
'dev:ssr-logs': (ctx: { logs: LogObject[], path: string }) => void | Promise<void>
59+
'render:html': (htmlContext: NuxtRenderHTMLContext, context: { event: H3Event }) => void | Promise<void>
60+
'render:island': (islandResponse: NuxtIslandResponse, context: { event: H3Event, islandContext: NuxtIslandContext }) => void | Promise<void>
61+
}
62+
}
3663
declare module '@nuxt/schema' {
3764
interface NuxtHooks {
3865
/**
@@ -202,7 +229,7 @@ declare module 'nuxt/schema' {
202229
* Each handler accepts the following options:
203230
* - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
204231
*
205-
* @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
232+
* @see [`server/` directory documentation](https://nuxt.com/docs/3.x/directory-structure/server)
206233
*
207234
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
208235
*

packages/nitro-server/src/runtime/handlers/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { joinURL, withQuery, withoutBase } from 'ufo'
2-
import type { NitroErrorHandler } from 'nitropack'
2+
import type { NitroErrorHandler } from 'nitropack/types'
33
import { appendResponseHeader, getRequestHeaders, send, setResponseHeader, setResponseHeaders, setResponseStatus } from 'h3'
44
import type { NuxtPayload } from 'nuxt/app'
55
import { useRuntimeConfig } from 'nitropack/runtime/config'

packages/nitro-server/src/runtime/handlers/island.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { RenderResponse } from 'nitropack'
1+
import type { RenderResponse } from 'nitropack/types'
22
import type { Link, SerializableHead } from '@unhead/vue/types'
33
import { destr } from 'destr'
44
import type { H3Event } from 'h3'

packages/nuxt/src/app/composables/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FetchError, FetchOptions, ResponseType as _ResponseType } from 'ofetch'
2-
import type { $Fetch, H3Event$Fetch, NitroFetchRequest, TypedInternalResponse, AvailableRouterMethod as _AvailableRouterMethod } from 'nitropack'
2+
import type { $Fetch, H3Event$Fetch, NitroFetchRequest, TypedInternalResponse, AvailableRouterMethod as _AvailableRouterMethod } from 'nitropack/types'
33
import type { MaybeRef, MaybeRefOrGetter, Ref } from 'vue'
44
import { computed, reactive, toValue, watch } from 'vue'
55
import { hash } from 'ohash'

packages/nuxt/src/app/composables/manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { H3Event } from 'h3'
2-
import type { NitroRouteRules } from 'nitropack'
2+
import type { NitroRouteRules } from 'nitropack/types'
33
import { useNuxtApp, useRuntimeConfig } from '../nuxt'
44
// @ts-expect-error virtual file
55
import { appManifest as isAppManifestEnabled } from '#build/nuxt.config.mjs'

packages/nuxt/src/app/composables/ssr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { H3Event } from 'h3'
22
import { setResponseStatus as _setResponseStatus, appendHeader, getRequestHeader, getRequestHeaders, getResponseHeader, removeResponseHeader, setResponseHeader } from 'h3'
33
import { computed, getCurrentInstance, ref } from 'vue'
4-
import type { H3Event$Fetch } from 'nitropack'
4+
import type { H3Event$Fetch } from 'nitropack/types'
55

66
import type { NuxtApp } from '../nuxt'
77
import { useNuxtApp } from '../nuxt'

packages/nuxt/src/app/nuxt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getContext } from 'unctx'
77
import type { UseContext } from 'unctx'
88
import type { SSRContext, createRenderer } from 'vue-bundle-renderer/runtime'
99
import type { EventHandlerRequest, H3Event } from 'h3'
10-
import type { RenderResponse } from 'nitropack'
10+
import type { RenderResponse } from 'nitropack/types'
1111
import type { LogObject } from 'consola'
1212
import type { VueHeadClient } from '@unhead/vue/types'
1313

packages/nuxt/src/pages/module.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ export default defineNuxtModule({
197197
' interface NitroRouteConfig {',
198198
' appMiddleware?: string | string[] | Record<string, boolean>',
199199
' }',
200+
' interface NitroRouteRules {',
201+
' appMiddleware?: string | string[] | Record<string, boolean>',
202+
' }',
203+
'}',
204+
'declare module \'nitropack/types\' {',
205+
' interface NitroRouteConfig {',
206+
' appMiddleware?: string | string[] | Record<string, boolean>',
207+
' }',
208+
' interface NitroRouteRules {',
209+
' appMiddleware?: string | string[] | Record<string, boolean>',
210+
' }',
200211
'}',
201212
'export {}',
202213
].join('\n'),
@@ -604,6 +615,17 @@ export default defineNuxtModule({
604615
' interface NitroRouteConfig {',
605616
' appMiddleware?: MiddlewareKey | MiddlewareKey[] | Record<MiddlewareKey, boolean>',
606617
' }',
618+
' interface NitroRouteRules {',
619+
' appMiddleware?: MiddlewareKey | MiddlewareKey[] | Record<MiddlewareKey, boolean>',
620+
' }',
621+
'}',
622+
'declare module \'nitropack/types\' {',
623+
' interface NitroRouteConfig {',
624+
' appMiddleware?: MiddlewareKey | MiddlewareKey[] | Record<MiddlewareKey, boolean>',
625+
' }',
626+
' interface NitroRouteRules {',
627+
' appMiddleware?: MiddlewareKey | MiddlewareKey[] | Record<MiddlewareKey, boolean>',
628+
' }',
607629
'}',
608630
].join('\n')
609631
},

packages/nuxt/src/pages/route-rules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NuxtPage } from '@nuxt/sch AABF ema'
2-
import type { NitroRouteConfig } from 'nitropack'
2+
import type { NitroRouteConfig } from 'nitropack/types'
33

44
import { pathToNitroGlob } from './utils.ts'
55

packages/nuxt/src/pages/runtime/composables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { KeepAliveProps, TransitionProps, UnwrapRef } from 'vue'
22
import { getCurrentInstance } from 'vue'
33
import type { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteRecordRaw, RouteRecordRedirectOption } from 'vue-router'
44
import { useRoute } from 'vue-router'
5-
import type { NitroRouteConfig } from 'nitropack'
5+
import type { NitroRouteConfig } from 'nitropack/types'
66
import type { NuxtError } from 'nuxt/app'
77
import { useNuxtApp } from '#app/nuxt'
88
import type { SerializableValue } from './utils'

0 commit comments

Comments
 (0)
0