import type { App, EffectScope, Ref, VNode, onErrorCaptured } from 'vue'; import type { RouteLocationNormalizedLoaded } from 'vue-router'; import type { Hookable } from 'hookable'; import type { SSRContext, createRenderer } from 'vue-bundle-renderer/runtime'; import type { EventHandlerRequest, H3Event } from 'h3'; import type { RenderResponse } from 'nitropack'; import type { LogObject } from 'consola'; import type { VueHeadClient } from '@unhead/vue/types'; import type { NuxtAppLiterals } from 'nuxt/app'; import type { DefaultAsyncDataErrorValue, DefaultErrorValue } from 'nuxt/app/defaults'; import type { NuxtIslandContext } from '../app/types.js'; import type { RouteMiddleware } from '../app/composables/router.js'; import type { NuxtError } from '../app/composables/error.js'; import type { AsyncDataExecuteOptions, AsyncDataRequestStatus } from '../app/composables/asyncData.js'; import type { NuxtAppManifestMeta } from '../app/composables/manifest.js'; import type { LoadingIndicator } from '../app/composables/loading-indicator.js'; import type { RouteAnnouncer } from '../app/composables/route-announcer.js'; import type { AppConfig, AppConfigInput, RuntimeConfig } from 'nuxt/schema'; export declare function getNuxtAppCtx(id?: any): import("unctx/index").UseContext; type HookResult = Promise | void; type AppRenderedContext = { ssrContext: NuxtApp['ssrContext']; renderResult: null | Awaited['renderToString']>>; }; export interface RuntimeNuxtHooks { 'app:created': (app: App) => HookResult; 'app:beforeMount': (app: App) => HookResult; 'app:mounted': (app: App) => HookResult; 'app:rendered': (ctx: AppRenderedContext) => HookResult; 'app:redirected': () => HookResult; 'app:suspense:resolve': (Component?: VNode) => HookResult; 'app:error': (err: any) => HookResult; 'app:error:cleared': (options: { redirect?: string; }) => HookResult; 'app:chunkError': (options: { error: any; }) => HookResult; 'app:data:refresh': (keys?: string[]) => HookResult; 'app:manifest:update': (meta?: NuxtAppManifestMeta) => HookResult; 'dev:ssr-logs': (logs: LogObject[]) => HookResult; 'link:prefetch': (link: string) => HookResult; 'page:start': (Component?: VNode) => HookResult; 'page:finish': (Component?: VNode) => HookResult; 'page:transition:finish': (Component?: VNode) => HookResult; 'page:view-transition:start': (transition: ViewTransition) => HookResult; 'page:loading:start': () => HookResult; 'page:loading:end': () => HookResult; 'vue:setup': () => void; 'vue:error': (...args: Parameters[0]>) => HookResult; } export interface NuxtSSRContext extends SSRContext { url: string; event: H3Event; runtimeConfig: RuntimeConfig; noSSR: boolean; /** whether we are rendering an SSR error */ error?: boolean; nuxt: _NuxtApp; payload: Partial; head: VueHeadClient; /** This is used solely to render runtime config with SPA renderer. */ config?: Pick; teleports?: Record; islandContext?: NuxtIslandContext; /** @internal */ _renderResponse?: Partial; /** @internal */ _payloadReducers: Record any>; /** @internal */ _sharedPrerenderCache?: { get(key: string): Promise | undefined; set(key: string, value: Promise): Promise; }; /** @internal */ _preloadManifest?: boolean; } export interface NuxtPayload { path?: string; serverRendered?: boolean; prerenderedAt?: number; data: Record; state: Record; once: Set; config?: Pick; error?: NuxtError | DefaultErrorValue; _errors: Record; [key: string]: unknown; } interface _NuxtApp { vueApp: App; globalName: string; versions: Record; hooks: Hookable; hook: _NuxtApp['hooks']['hook']; callHook: _NuxtApp['hooks']['callHook']; runWithContext: any>(fn: T) => ReturnType | Promise>>; [key: string]: unknown; /** @internal */ _cookies?: Record; /** * The id of the Nuxt application. * @internal */ _id: string; /** @internal */ _scope: EffectScope; /** @internal */ _asyncDataPromises: Record | undefined>; /** @internal */ _asyncData: Record; pending: Ref; error: Ref; status: Ref; execute: (opts?: AsyncDataExecuteOptions) => Promise; /** @internal */ _default: () => unknown; /** @internal */ _deps: number; /** @internal */ _off: () => void; /** @internal */ _init: boolean; /** @internal */ _execute: (opts?: AsyncDataExecuteOptions) => Promise; /** @internal */ _hash?: Record; } | undefined>; /** @internal */ _loadingIndicator?: LoadingIndicator; /** @internal */ _loadingIndicatorDeps?: number; /** @internal */ _middleware: { global: RouteMiddleware[]; named: Record; }; /** @internal */ _once: { [key: string]: Promise; }; /** @internal */ _observer?: { observe: (element: Element, callback: () => void) => () => void; }; /** @internal */ _appConfig: AppConfig; /** @internal */ _route: RouteLocationNormalizedLoaded; /** @internal */ _islandPromises?: Record>; /** @internal */ _payloadRevivers: Record any>; /** @internal */ _routeAnnouncer?: RouteAnnouncer; /** @internal */ _routeAnnouncerDeps?: number; $config: RuntimeConfig; isHydrating?: boolean; deferHydration: () => () => void | Promise; ssrContext?: NuxtSSRContext; payload: NuxtPayload; static: { data: Record; }; provide: (name: string, value: any) => void; } export interface NuxtApp extends _NuxtApp { } export declare const NuxtPluginIndicator = "__nuxt_plugin"; export interface PluginMeta { name?: string; enforce?: 'pre' | 'default' | 'post'; /** * Await for other named plugins to finish before running this plugin. */ dependsOn?: NuxtAppLiterals['pluginName'][]; /** * This allows more granular control over plugin order and should only be used by advanced users. * It overrides the value of `enforce` and is used to sort plugins. */ order?: number; } export interface PluginEnvContext { /** * This enable the plugin for islands components. * Require `experimental.componentsIslands`. * @default true */ islands?: boolean; } export interface ResolvedPluginMeta { name?: string; parallel?: boolean; } export interface Plugin = Record> { (nuxt: _NuxtApp): Promise | Promise<{ provide?: Injections; }> | void | { provide?: Injections; }; [NuxtPluginIndicator]?: true; meta?: ResolvedPluginMeta; } export interface ObjectPlugin = Record> extends PluginMeta { hooks?: Partial; setup?: Plugin; env?: PluginEnvContext; /** * Execute plugin in parallel with other parallel plugins. * @default false */ parallel?: boolean; /** * @internal */ _name?: string; } /** @deprecated Use `ObjectPlugin` */ export type ObjectPluginInput = Record> = ObjectPlugin; export interface CreateOptions { vueApp: NuxtApp['vueApp']; ssrContext?: NuxtApp['ssrContext']; globalName?: NuxtApp['globalName']; /** * The id of the Nuxt application, overrides the default id specified in the Nuxt config (default: `nuxt-app`). */ id?: NuxtApp['_id']; } /** @since 3.0.0 */ export declare function createNuxtApp(options: CreateOptions): NuxtApp; /** @since 3.12.0 */ export declare function registerPluginHooks(nuxtApp: NuxtApp, plugin: Plugin & ObjectPlugin): void; /** @since 3.0.0 */ export declare function applyPlugin(nuxtApp: NuxtApp, plugin: Plugin & ObjectPlugin): Promise; /** @since 3.0.0 */ export declare function applyPlugins(nuxtApp: NuxtApp, plugins: Array>): Promise; /** @since 3.0.0 */ export declare function defineNuxtPlugin>(plugin: Plugin | ObjectPlugin): Plugin & ObjectPlugin; export declare const definePayloadPlugin: typeof defineNuxtPlugin; /** @since 3.0.0 */ export declare function isNuxtPlugin(plugin: unknown): plugin is Function & Record<"__nuxt_plugin", unknown>; /** * Ensures that the setup function passed in has access to the Nuxt instance via `useNuxtApp`. * @param nuxt A Nuxt instance * @param setup The function to call * @since 3.0.0 */ export declare function callWithNuxt any>(nuxt: NuxtApp | _NuxtApp, setup: T, args?: Parameters): ReturnType | Promise>; /** * Returns the current Nuxt instance. * * Returns `null` if Nuxt instance is unavailable. * @since 3.10.0 */ export declare function tryUseNuxtApp(): NuxtApp | null; /** * Returns the current Nuxt instance. * * Throws an error if Nuxt instance is unavailable. * @since 3.0.0 */ export declare function useNuxtApp(): NuxtApp; /** @since 3.0.0 */ export declare function useRuntimeConfig(_event?: H3Event): RuntimeConfig; /** @since 3.0.0 */ export declare function defineAppConfig(config: C): C; export {};