Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022-PRESENT Nuxt Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,110 @@
'use strict';
const kit = require('@nuxt/kit');
const execa = require('execa');
function addCustomTab(tab, nuxt = kit.useNuxt()) {
nuxt.hook("devtools:customTabs", async (tabs) => {
if (typeof tab === "function")
tab = await tab();
tabs.push(tab);
});
}
function refreshCustomTabs(nuxt = kit.useNuxt()) {
return nuxt.callHook("devtools:customTabs:refresh");
}
function startSubprocess(execaOptions, tabOptions, nuxt = kit.useNuxt()) {
const id = tabOptions.id;
let restarting = false;
function start() {
const process2 = execa.execa(
execaOptions.command,
execaOptions.args,
{
reject: false,
...execaOptions,
env: {
COLORS: "true",
FORCE_COLOR: "true",
...execaOptions.env,
// Force disable Nuxi CLI override
__CLI_ARGV__: void 0
}
}
);
nuxt.callHook("devtools:terminal:write", { id, data: `> ${[execaOptions.command, ...execaOptions.args || []].join(" ")}
` });
process2.stdout.on("data", (data) => {
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
});
process2.stderr.on("data", (data) => {
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
});
process2.on("exit", (code) => {
if (!restarting) {
nuxt.callHook("devtools:terminal:write", { id, data: `
> process terminalated with ${code}
` });
nuxt.callHook("devtools:terminal:exit", { id, code: code || 0 });
}
});
return process2;
}
register();
nuxt.hook("close", () => {
terminate();
});
let process = start();
function restart() {
restarting = true;
process?.kill();
clear();
process = start();
restarting = false;
}
function clear() {
tabOptions.buffer = "";
register();
}
function terminate() {
restarting = false;
try {
process?.kill();
} catch {
}
nuxt.callHook("devtools:terminal:remove", { id });
}
function register() {
nuxt.callHook("devtools:terminal:register", {
onActionRestart: tabOptions.restartable === false ? void 0 : restart,
onActionTerminate: tabOptions.terminatable === false ? void 0 : terminate,
isTerminated: false,
...tabOptions
});
}
return {
getProcess: () => process,
terminate,
restart,
clear
};
}
function extendServerRpc(namespace, functions, nuxt = kit.useNuxt()) {
const ctx = _getContext(nuxt);
if (!ctx)
throw new Error("[Nuxt DevTools] Failed to get devtools context.");
return ctx.extendServerRpc(namespace, functions);
}
function onDevToolsInitialized(fn, nuxt = kit.useNuxt()) {
nuxt.hook("devtools:initialized", fn);
}
function _getContext(nuxt = kit.useNuxt()) {
return nuxt?.devtools;
}
exports.addCustomTab = addCustomTab;
exports.extendServerRpc = extendServerRpc;
exports.onDevToolsInitialized = onDevToolsInitialized;
exports.refreshCustomTabs = refreshCustomTabs;
exports.startSubprocess = startSubprocess;

View file

@ -0,0 +1,35 @@
import * as _nuxt_schema from '@nuxt/schema';
import { BirpcGroup } from 'birpc';
import { ExecaChildProcess } from 'execa';
import { M as ModuleCustomTab, S as SubprocessOptions, T as TerminalState, N as NuxtDevtoolsInfo } from './shared/devtools-kit.r2McQC71.cjs';
import 'vue';
import 'nuxt/schema';
import 'unimport';
import 'vue-router';
import 'nitropack';
import 'unstorage';
import 'vite';
/**
* Hooks to extend a custom tab in devtools.
*
* Provide a function to pass a factory that can be updated dynamically.
*/
declare function addCustomTab(tab: ModuleCustomTab | (() => ModuleCustomTab | Promise<ModuleCustomTab>), nuxt?: _nuxt_schema.Nuxt): void;
/**
* Retrigger update for custom tabs, `devtools:customTabs` will be called again.
*/
declare function refreshCustomTabs(nuxt?: _nuxt_schema.Nuxt): Promise<any>;
/**
* Create a subprocess that handled by the DevTools.
*/
declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): {
getProcess: () => ExecaChildProcess<string>;
terminate: () => void;
restart: () => void;
clear: () => void;
};
declare function extendServerRpc<ClientFunctions = Record<string, never>, ServerFunctions = Record<string, never>>(namespace: string, functions: ServerFunctions, nuxt?: _nuxt_schema.Nuxt): BirpcGroup<ClientFunctions, ServerFunctions>;
declare function onDevToolsInitialized(fn: (info: NuxtDevtoolsInfo) => void, nuxt?: _nuxt_schema.Nuxt): void;
export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };

View file

@ -0,0 +1,35 @@
import * as _nuxt_schema from '@nuxt/schema';
import { BirpcGroup } from 'birpc';
import { ExecaChildProcess } from 'execa';
import { M as ModuleCustomTab, S as SubprocessOptions, T as TerminalState, N as NuxtDevtoolsInfo } from './shared/devtools-kit.r2McQC71.mjs';
import 'vue';
import 'nuxt/schema';
import 'unimport';
import 'vue-router';
import 'nitropack';
import 'unstorage';
import 'vite';
/**
* Hooks to extend a custom tab in devtools.
*
* Provide a function to pass a factory that can be updated dynamically.
*/
declare function addCustomTab(tab: ModuleCustomTab | (() => ModuleCustomTab | Promise<ModuleCustomTab>), nuxt?: _nuxt_schema.Nuxt): void;
/**
* Retrigger update for custom tabs, `devtools:customTabs` will be called again.
*/
declare function refreshCustomTabs(nuxt?: _nuxt_schema.Nuxt): Promise<any>;
/**
* Create a subprocess that handled by the DevTools.
*/
declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): {
getProcess: () => ExecaChildProcess<string>;
terminate: () => void;
restart: () => void;
clear: () => void;
};
declare function extendServerRpc<ClientFunctions = Record<string, never>, ServerFunctions = Record<string, never>>(namespace: string, functions: ServerFunctions, nuxt?: _nuxt_schema.Nuxt): BirpcGroup<ClientFunctions, ServerFunctions>;
declare function onDevToolsInitialized(fn: (info: NuxtDevtoolsInfo) => void, nuxt?: _nuxt_schema.Nuxt): void;
export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };

View file

@ -0,0 +1,35 @@
import * as _nuxt_schema from '@nuxt/schema';
import { BirpcGroup } from 'birpc';
import { ExecaChildProcess } from 'execa';
import { M as ModuleCustomTab, S as SubprocessOptions, T as TerminalState, N as NuxtDevtoolsInfo } from './shared/devtools-kit.r2McQC71.js';
import 'vue';
import 'nuxt/schema';
import 'unimport';
import 'vue-router';
import 'nitropack';
import 'unstorage';
import 'vite';
/**
* Hooks to extend a custom tab in devtools.
*
* Provide a function to pass a factory that can be updated dynamically.
*/
declare function addCustomTab(tab: ModuleCustomTab | (() => ModuleCustomTab | Promise<ModuleCustomTab>), nuxt?: _nuxt_schema.Nuxt): void;
/**
* Retrigger update for custom tabs, `devtools:customTabs` will be called again.
*/
declare function refreshCustomTabs(nuxt?: _nuxt_schema.Nuxt): Promise<any>;
/**
* Create a subprocess that handled by the DevTools.
*/
declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): {
getProcess: () => ExecaChildProcess<string>;
terminate: () => void;
restart: () => void;
clear: () => void;
};
declare function extendServerRpc<ClientFunctions = Record<string, never>, ServerFunctions = Record<string, never>>(namespace: string, functions: ServerFunctions, nuxt?: _nuxt_schema.Nuxt): BirpcGroup<ClientFunctions, ServerFunctions>;
declare function onDevToolsInitialized(fn: (info: NuxtDevtoolsInfo) => void, nuxt?: _nuxt_schema.Nuxt): void;
export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };

View file

@ -0,0 +1,104 @@
import { useNuxt } from '@nuxt/kit';
import { execa } from 'execa';
function addCustomTab(tab, nuxt = useNuxt()) {
nuxt.hook("devtools:customTabs", async (tabs) => {
if (typeof tab === "function")
tab = await tab();
tabs.push(tab);
});
}
function refreshCustomTabs(nuxt = useNuxt()) {
return nuxt.callHook("devtools:customTabs:refresh");
}
function startSubprocess(execaOptions, tabOptions, nuxt = useNuxt()) {
const id = tabOptions.id;
let restarting = false;
function start() {
const process2 = execa(
execaOptions.command,
execaOptions.args,
{
reject: false,
...execaOptions,
env: {
COLORS: "true",
FORCE_COLOR: "true",
...execaOptions.env,
// Force disable Nuxi CLI override
__CLI_ARGV__: void 0
}
}
);
nuxt.callHook("devtools:terminal:write", { id, data: `> ${[execaOptions.command, ...execaOptions.args || []].join(" ")}
` });
process2.stdout.on("data", (data) => {
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
});
process2.stderr.on("data", (data) => {
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
});
process2.on("exit", (code) => {
if (!restarting) {
nuxt.callHook("devtools:terminal:write", { id, data: `
> process terminalated with ${code}
` });
nuxt.callHook("devtools:terminal:exit", { id, code: code || 0 });
}
});
return process2;
}
register();
nuxt.hook("close", () => {
terminate();
});
let process = start();
function restart() {
restarting = true;
process?.kill();
clear();
process = start();
restarting = false;
}
function clear() {
tabOptions.buffer = "";
register();
}
function terminate() {
restarting = false;
try {
process?.kill();
} catch {
}
nuxt.callHook("devtools:terminal:remove", { id });
}
function register() {
nuxt.callHook("devtools:terminal:register", {
onActionRestart: tabOptions.restartable === false ? void 0 : restart,
onActionTerminate: tabOptions.terminatable === false ? void 0 : terminate,
isTerminated: false,
...tabOptions
});
}
return {
getProcess: () => process,
terminate,
restart,
clear
};
}
function extendServerRpc(namespace, functions, nuxt = useNuxt()) {
const ctx = _getContext(nuxt);
if (!ctx)
throw new Error("[Nuxt DevTools] Failed to get devtools context.");
return ctx.extendServerRpc(namespace, functions);
}
function onDevToolsInitialized(fn, nuxt = useNuxt()) {
nuxt.hook("devtools:initialized", fn);
}
function _getContext(nuxt = useNuxt()) {
return nuxt?.devtools;
}
export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };

View file

@ -0,0 +1,4 @@
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools-kit/types';
import type { Ref } from 'vue';
export declare function onDevtoolsHostClientConnected(fn: (client: NuxtDevtoolsHostClient) => void): (() => void) | undefined;
export declare function useDevtoolsHostClient(): Ref<NuxtDevtoolsHostClient | undefined>;

View file

@ -0,0 +1,34 @@
import { shallowRef } from "vue";
let clientRef;
const fns = [];
export function onDevtoolsHostClientConnected(fn) {
fns.push(fn);
if (typeof window === "undefined")
return;
if (window.__NUXT_DEVTOOLS_HOST__) {
fns.forEach((fn2) => fn2(window.__NUXT_DEVTOOLS_HOST__));
}
Object.defineProperty(window, "__NUXT_DEVTOOLS_HOST__", {
set(value) {
if (value)
fns.forEach((fn2) => fn2(value));
},
get() {
return clientRef.value;
},
configurable: true
});
return () => {
fns.splice(fns.indexOf(fn), 1);
};
}
export function useDevtoolsHostClient() {
if (!clientRef) {
clientRef = shallowRef();
onDevtoolsHostClientConnected(setup);
}
function setup(client) {
clientRef.value = client;
}
return clientRef;
}

View file

@ -0,0 +1,4 @@
import type { Ref } from 'vue';
import type { NuxtDevtoolsIframeClient } from '../types';
export declare function onDevtoolsClientConnected(fn: (client: NuxtDevtoolsIframeClient) => void): (() => void) | undefined;
export declare function useDevtoolsClient(): Ref<NuxtDevtoolsIframeClient | undefined, NuxtDevtoolsIframeClient | undefined>;

View file

@ -0,0 +1,44 @@
import { shallowRef, triggerRef } from "vue";
let clientRef;
const hasSetup = false;
const fns = [];
export function onDevtoolsClientConnected(fn) {
fns.push(fn);
if (hasSetup)
return;
if (typeof window === "undefined")
return;
if (window.__NUXT_DEVTOOLS__) {
fns.forEach((fn2) => fn2(window.__NUXT_DEVTOOLS__));
}
Object.defineProperty(window, "__NUXT_DEVTOOLS__", {
set(value) {
if (value)
fns.forEach((fn2) => fn2(value));
},
get() {
return clientRef.value;
},
configurable: true
});
return () => {
fns.splice(fns.indexOf(fn), 1);
};
}
export function useDevtoolsClient() {
if (!clientRef) {
clientRef = shallowRef();
onDevtoolsClientConnected(setup);
}
function onUpdateReactivity() {
if (clientRef) {
triggerRef(clientRef);
}
}
function setup(client) {
clientRef.value = client;
if (client.host)
client.host.hooks.hook("host:update:reactivity", onUpdateReactivity);
}
return clientRef;
}

View file

@ -0,0 +1,797 @@
import { VNode, MaybeRefOrGetter } from 'vue';
import { BirpcGroup } from 'birpc';
import { Component, NuxtOptions, NuxtPage, NuxtLayout, NuxtApp, NuxtDebugModuleMutationRecord, Nuxt } from 'nuxt/schema';
import { Import, UnimportMeta } from 'unimport';
import { RouteRecordNormalized } from 'vue-router';
import { Nitro, StorageMounts } from 'nitropack';
import { StorageValue } from 'unstorage';
import { ResolvedConfig } from 'vite';
import { NuxtAnalyzeMeta } from '@nuxt/schema';
import { Options } from 'execa';
type TabCategory = 'pinned' | 'app' | 'vue-devtools' | 'analyze' | 'server' | 'modules' | 'documentation' | 'advanced';
interface ModuleCustomTab {
/**
* The name of the tab, must be unique
*/
name: string;
/**
* Icon of the tab, support any Iconify icons, or a url to an image
*/
icon?: string;
/**
* Title of the tab
*/
title: string;
/**
* Main view of the tab
*/
view: ModuleView;
/**
* Category of the tab
* @default 'app'
*/
category?: TabCategory;
/**
* Insert static vnode to the tab entry
*
* Advanced options. You don't usually need this.
*/
extraTabVNode?: VNode;
/**
* Require local authentication to access the tab
* It's highly recommended to enable this if the tab have sensitive information or have access to the OS
*
* @default false
*/
requireAuth?: boolean;
}
interface ModuleLaunchView {
/**
* A view for module to lazy launch some actions
*/
type: 'launch';
title?: string;
icon?: string;
description: string;
/**
* Action buttons
*/
actions: ModuleLaunchAction[];
}
interface ModuleIframeView {
/**
* Iframe view
*/
type: 'iframe';
/**
* Url of the iframe
*/
src: string;
/**
* Persist the iframe instance even if the tab is not active
*
* @default true
*/
persistent?: boolean;
/**
* Additional permissions to allow in the iframe
* These will be merged with the default permissions (clipboard-write, clipboard-read)
*
* @example ['camera', 'microphone', 'geolocation']
*/
permissions?: string[];
}
interface ModuleVNodeView {
/**
* Vue's VNode view
*/
type: 'vnode';
/**
* Send vnode to the client, they must be static and serializable
*
* Call `nuxt.hook('devtools:customTabs:refresh')` to trigger manual refresh
*/
vnode: VNode;
}
interface ModuleLaunchAction {
/**
* Label of the action button
*/
label: string;
/**
* Additional HTML attributes to the action button
*/
attrs?: Record<string, string>;
/**
* Indicate if the action is pending, will show a loading indicator and disable the button
*/
pending?: boolean;
/**
* Function to handle the action, this is executed on the server side.
* Will automatically refresh the tabs after the action is resolved.
*/
handle?: () => void | Promise<void>;
/**
* Treat the action as a link, will open the link in a new tab
*/
src?: string;
}
type ModuleView = ModuleIframeView | ModuleLaunchView | ModuleVNodeView;
interface ModuleIframeTabLazyOptions {
description?: string;
onLoad?: () => Promise<void>;
}
interface ModuleBuiltinTab {
name: string;
icon?: string;
title?: string;
path?: string;
category?: TabCategory;
show?: () => MaybeRefOrGetter<any>;
badge?: () => MaybeRefOrGetter<number | string | undefined>;
onClick?: () => void;
}
type ModuleTabInfo = ModuleCustomTab | ModuleBuiltinTab;
type CategorizedTabs = [TabCategory, (ModuleCustomTab | ModuleBuiltinTab)[]][];
interface HookInfo {
name: string;
start: number;
end?: number;
duration?: number;
listeners: number;
executions: number[];
}
interface ImageMeta {
width: number;
height: number;
orientation?: number;
type?: string;
mimeType?: string;
}
interface PackageUpdateInfo {
name: string;
current: string;
latest: string;
needsUpdate: boolean;
}
type PackageManagerName = 'npm' | 'yarn' | 'pnpm' | 'bun';
type NpmCommandType = 'install' | 'uninstall' | 'update';
interface NpmCommandOptions {
dev?: boolean;
global?: boolean;
}
interface AutoImportsWithMetadata {
imports: Import[];
metadata?: UnimportMeta;
dirs: string[];
}
interface RouteInfo extends Pick<RouteRecordNormalized, 'name' | 'path' | 'meta' | 'props' | 'children'> {
file?: string;
}
interface ServerRouteInfo {
route: string;
filepath: string;
method?: string;
type: 'api' | 'route' | 'runtime' | 'collection';
routes?: ServerRouteInfo[];
}
type ServerRouteInputType = 'string' | 'number' | 'boolean' | 'file' | 'date' | 'time' | 'datetime-local';
interface ServerRouteInput {
active: boolean;
key: string;
value: any;
type?: ServerRouteInputType;
}
interface Payload {
url: string;
time: number;
data?: Record<string, any>;
state?: Record<string, any>;
functions?: Record<string, any>;
}
interface ServerTaskInfo {
name: string;
handler: string;
description: string;
type: 'collection' | 'task';
tasks?: ServerTaskInfo[];
}
interface ScannedNitroTasks {
tasks: {
[name: string]: {
handler: string;
description: string;
};
};
scheduledTasks: {
[cron: string]: string[];
};
}
interface PluginInfoWithMetic {
src: string;
mode?: 'client' | 'server' | 'all';
ssr?: boolean;
metric?: PluginMetric;
}
interface PluginMetric {
src: string;
start: number;
end: number;
duration: number;
}
interface LoadingTimeMetric {
ssrStart?: number;
appInit?: number;
appLoad?: number;
pageStart?: number;
pageEnd?: number;
pluginInit?: number;
hmrStart?: number;
hmrEnd?: number;
}
interface BasicModuleInfo {
entryPath?: string;
meta?: {
name?: string;
};
}
interface InstalledModuleInfo {
name?: string;
isPackageModule: boolean;
isUninstallable: boolean;
info?: ModuleStaticInfo;
entryPath?: string;
timings?: Record<string, number | undefined>;
meta?: {
name?: string;
};
}
interface ModuleStaticInfo {
name: string;
description: string;
repo: string;
npm: string;
icon?: string;
github: string;
website: string;
learn_more: string;
category: string;
type: ModuleType;
stats: ModuleStats;
maintainers: MaintainerInfo[];
contributors: GitHubContributor[];
compatibility: ModuleCompatibility;
}
interface ModuleCompatibility {
nuxt: string;
requires: {
bridge?: boolean | 'optional';
};
}
interface ModuleStats {
downloads: number;
stars: number;
publishedAt: number;
createdAt: number;
}
type CompatibilityStatus = 'working' | 'wip' | 'unknown' | 'not-working';
type ModuleType = 'community' | 'official' | '3rd-party';
interface MaintainerInfo {
name: string;
github: string;
twitter?: string;
}
interface GitHubContributor {
login: string;
name?: string;
avatar_url?: string;
}
interface VueInspectorClient {
enabled: boolean;
position: {
x: number;
y: number;
};
linkParams: {
file: string;
line: number;
column: number;
};
enable: () => void;
disable: () => void;
toggleEnabled: () => void;
openInEditor: (url: URL) => void;
onUpdated: () => void;
}
type VueInspectorData = VueInspectorClient['linkParams'] & Partial<VueInspectorClient['position']>;
type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'json' | 'other';
interface AssetInfo {
path: string;
type: AssetType;
publicPath: string;
filePath: string;
size: number;
mtime: number;
layer?: string;
}
interface AssetEntry {
path: string;
content: string;
encoding?: BufferEncoding;
override?: boolean;
}
interface CodeSnippet {
code: string;
lang: string;
name: string;
docs?: string;
}
interface ComponentRelationship {
id: string;
deps: string[];
}
interface ComponentWithRelationships {
component: Component;
dependencies?: string[];
dependents?: string[];
}
interface CodeServerOptions {
codeBinary: string;
launchArg: string;
licenseTermsArg: string;
connectionTokenArg: string;
}
type CodeServerType = 'ms-code-cli' | 'ms-code-server' | 'coder-code-server';
interface ModuleOptions {
/**
* Enable DevTools
*
* @default true
*/
enabled?: boolean;
/**
* Custom tabs
*
* This is in static format, for dynamic injection, call `nuxt.hook('devtools:customTabs')` instead
*/
customTabs?: ModuleCustomTab[];
/**
* VS Code Server integration options.
*/
vscode?: VSCodeIntegrationOptions;
/**
* Enable Vue Component Inspector
*
* @default true
*/
componentInspector?: boolean;
/**
* Enable Vue DevTools integration
*/
vueDevTools?: boolean;
/**
* Enable vite-plugin-inspect
*
* @default true
*/
viteInspect?: boolean;
/**
* Enable Vite DevTools integration
*
* @experimental
* @default false
*/
viteDevTools?: boolean;
/**
* Disable dev time authorization check.
*
* **NOT RECOMMENDED**, only use this if you know what you are doing.
*
* @see https://github.com/nuxt/devtools/pull/257
* @default false
*/
disableAuthorization?: boolean;
/**
* Props for the iframe element, useful for environment with stricter CSP
*/
iframeProps?: Record<string, string | boolean>;
/**
* Experimental features
*/
experimental?: {
/**
* Timeline tab
* @deprecated Use `timeline.enable` instead
*/
timeline?: boolean;
};
/**
* Options for the timeline tab
*/
timeline?: {
/**
* Enable timeline tab
*
* @default false
*/
enabled?: boolean;
/**
* Track on function calls
*/
functions?: {
include?: (string | RegExp | ((item: Import) => boolean))[];
/**
* Include from specific modules
*
* @default ['#app', '@unhead/vue']
*/
includeFrom?: string[];
exclude?: (string | RegExp | ((item: Import) => boolean))[];
};
};
/**
* Options for assets tab
*/
assets?: {
/**
* Allowed file extensions for assets tab to upload.
* To security concern.
*
* Set to '*' to disbale this limitation entirely
*
* @default Common media and txt files
*/
uploadExtensions?: '*' | string[];
};
/**
* Enable anonymous telemetry, helping us improve Nuxt DevTools.
*
* By default it will respect global Nuxt telemetry settings.
*/
telemetry?: boolean;
}
interface ModuleGlobalOptions {
/**
* List of projects to enable devtools for. Only works when devtools is installed globally.
*/
projects?: string[];
}
interface VSCodeIntegrationOptions {
/**
* Enable VS Code Server integration
*/
enabled?: boolean;
/**
* Start VS Code Server on boot
*
* @default false
*/
startOnBoot?: boolean;
/**
* Port to start VS Code Server
*
* @default 3080
*/
port?: number;
/**
* Reuse existing server if available (same port)
*/
reuseExistingServer?: boolean;
/**
* Determine whether to use code-server or vs code tunnel
*
* @default 'local-serve'
*/
mode?: 'local-serve' | 'tunnel';
/**
* Options for VS Code tunnel
*/
tunnel?: VSCodeTunnelOptions;
/**
* Determines which binary and arguments to use for VS Code.
*
* By default, uses the MS Code Server (ms-code-server).
* Can alternatively use the open source Coder code-server (coder-code-server),
* or the MS VS Code CLI (ms-code-cli)
* @default 'ms-code-server'
*/
codeServer?: CodeServerType;
/**
* Host address to listen on. Unspecified by default.
*/
host?: string;
}
interface VSCodeTunnelOptions {
/**
* the machine name for port forwarding service
*
* default: device hostname
*/
name?: string;
}
interface NuxtDevToolsOptions {
behavior: {
telemetry: boolean | null;
openInEditor: string | undefined;
};
ui: {
componentsGraphShowGlobalComponents: boolean;
componentsGraphShowLayouts: boolean;
componentsGraphShowNodeModules: boolean;
componentsGraphShowPages: boolean;
componentsGraphShowWorkspace: boolean;
componentsView: 'list' | 'graph';
hiddenTabCategories: string[];
hiddenTabs: string[];
interactionCloseOnOutsideClick: boolean;
minimizePanelInactive: number;
pinnedTabs: string[];
scale: number;
showExperimentalFeatures: boolean;
showHelpButtons: boolean;
showPanel: boolean | null;
sidebarExpanded: boolean;
sidebarScrollable: boolean;
};
serverRoutes: {
selectedRoute: ServerRouteInfo | null;
view: 'tree' | 'list';
inputDefaults: Record<string, ServerRouteInput[]>;
sendFrom: 'app' | 'devtools';
};
serverTasks: {
enabled: boolean;
selectedTask: ServerTaskInfo | null;
view: 'tree' | 'list';
inputDefaults: Record<string, ServerRouteInput[]>;
};
assets: {
view: 'grid' | 'list';
};
}
interface AnalyzeBuildMeta extends NuxtAnalyzeMeta {
features: {
bundleClient: boolean;
bundleNitro: boolean;
viteInspect: boolean;
};
size: {
clientBundle?: number;
nitroBundle?: number;
};
}
interface AnalyzeBuildsInfo {
isBuilding: boolean;
builds: AnalyzeBuildMeta[];
}
interface TerminalBase {
id: string;
name: string;
description?: string;
icon?: string;
}
type TerminalAction = 'restart' | 'terminate' | 'clear' | 'remove';
interface SubprocessOptions extends Options {
command: string;
args?: string[];
}
interface TerminalInfo extends TerminalBase {
/**
* Whether the terminal can be restarted
*/
restartable?: boolean;
/**
* Whether the terminal can be terminated
*/
terminatable?: boolean;
/**
* Whether the terminal is terminated
*/
isTerminated?: boolean;
/**
* Content buffer
*/
buffer?: string;
}
interface TerminalState extends TerminalInfo {
/**
* User action to restart the terminal, when not provided, this action will be disabled
*/
onActionRestart?: () => Promise<void> | void;
/**
* User action to terminate the terminal, when not provided, this action will be disabled
*/
onActionTerminate?: () => Promise<void> | void;
}
interface WizardFunctions {
enablePages: (nuxt: any) => Promise<void>;
}
type WizardActions = keyof WizardFunctions;
type GetWizardArgs<T extends WizardActions> = WizardFunctions[T] extends (nuxt: any, ...args: infer A) => any ? A : never;
interface ServerFunctions {
getServerConfig: () => NuxtOptions;
getServerDebugContext: () => Promise<ServerDebugContext | undefined>;
getServerData: (token: string) => Promise<NuxtServerData>;
getServerRuntimeConfig: () => Record<string, any>;
getModuleOptions: () => ModuleOptions;
getComponents: () => Component[];
getComponentsRelationships: () => Promise<ComponentRelationship[]>;
getAutoImports: () => AutoImportsWithMetadata;
getServerPages: () => NuxtPage[];
getCustomTabs: () => ModuleCustomTab[];
getServerHooks: () => HookInfo[];
getServerLayouts: () => NuxtLayout[];
getStaticAssets: () => Promise<AssetInfo[]>;
getServerRoutes: () => ServerRouteInfo[];
getServerTasks: () => ScannedNitroTasks | null;
getServerApp: () => NuxtApp | undefined;
getOptions: <T extends keyof NuxtDevToolsOptions>(tab: T) => Promise<NuxtDevToolsOptions[T]>;
updateOptions: <T extends keyof NuxtDevToolsOptions>(tab: T, settings: Partial<NuxtDevToolsOptions[T]>) => Promise<void>;
clearOptions: () => Promise<void>;
checkForUpdateFor: (name: string) => Promise<PackageUpdateInfo | undefined>;
getNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<string[] | undefined>;
runNpmCommand: (token: string, command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{
processId: string;
} | undefined>;
getTerminals: () => TerminalInfo[];
getTerminalDetail: (token: string, id: string) => Promise<TerminalInfo | undefined>;
runTerminalAction: (token: string, id: string, action: TerminalAction) => Promise<boolean>;
getStorageMounts: () => Promise<StorageMounts>;
getStorageKeys: (base?: string) => Promise<string[]>;
getStorageItem: (token: string, key: string) => Promise<StorageValue>;
setStorageItem: (token: string, key: string, value: StorageValue) => Promise<void>;
removeStorageItem: (token: string, key: string) => Promise<void>;
getAnalyzeBuildInfo: () => Promise<AnalyzeBuildsInfo>;
generateAnalyzeBuildName: () => Promise<string>;
startAnalyzeBuild: (token: string, name: string) => Promise<string>;
clearAnalyzeBuilds: (token: string, names?: string[]) => Promise<void>;
getImageMeta: (token: string, filepath: string) => Promise<ImageMeta | undefined>;
getTextAssetContent: (token: string, filepath: string, limit?: number) => Promise<string | undefined>;
writeStaticAssets: (token: string, file: AssetEntry[], folder: string) => Promise<string[]>;
deleteStaticAsset: (token: string, filepath: string) => Promise<void>;
renameStaticAsset: (token: string, oldPath: string, newPath: string) => Promise<void>;
telemetryEvent: (payload: object, immediate?: boolean) => void;
customTabAction: (name: string, action: number) => Promise<boolean>;
runWizard: <T extends WizardActions>(token: string, name: T, ...args: GetWizardArgs<T>) => Promise<void>;
openInEditor: (filepath: string) => Promise<boolean>;
restartNuxt: (token: string, hard?: boolean) => Promise<void>;
installNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>;
uninstallNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>;
enableTimeline: (dry: boolean) => Promise<[string, string]>;
requestForAuth: (info?: string, origin?: string) => Promise<void>;
verifyAuthToken: (token: string) => Promise<boolean>;
}
interface ClientFunctions {
refresh: (event: ClientUpdateEvent) => void;
callHook: (hook: string, ...args: any[]) => Promise<void>;
navigateTo: (path: string) => void;
onTerminalData: (_: {
id: string;
data: string;
}) => void;
onTerminalExit: (_: {
id: string;
code?: number;
}) => void;
}
interface NuxtServerData {
nuxt: NuxtOptions;
nitro?: Nitro['options'];
vite: {
server?: ResolvedConfig;
client?: ResolvedConfig;
};
}
type ClientUpdateEvent = keyof ServerFunctions;
/**
* @internal
*/
interface NuxtDevtoolsServerContext {
nuxt: Nuxt;
options: ModuleOptions;
rpc: BirpcGroup<ClientFunctions, ServerFunctions>;
/**
* Hook to open file in editor
*/
openInEditorHooks: ((filepath: string) => boolean | void | Promise<boolean | void>)[];
/**
* Invalidate client cache for a function and ask for re-fetching
*/
refresh: (event: keyof ServerFunctions) => void;
/**
* Ensure dev auth token is valid, throw if not
*/
ensureDevAuthToken: (token: string) => Promise<void>;
extendServerRpc: <ClientFunctions = Record<string, never>, ServerFunctions = Record<string, never>>(name: string, functions: ServerFunctions) => BirpcGroup<ClientFunctions, ServerFunctions>;
}
interface NuxtDevtoolsInfo {
version: string;
packagePath: string;
isGlobalInstall: boolean;
}
interface InstallModuleReturn {
configOriginal: string;
configGenerated: string;
commands: string[];
processId: string;
}
type ServerDebugModuleMutationRecord = (Omit<NuxtDebugModuleMutationRecord, 'module'> & {
name: string;
});
interface ServerDebugContext {
moduleMutationRecords: ServerDebugModuleMutationRecord[];
}
declare module '@nuxt/schema' {
interface NuxtHooks {
/**
* Called before devtools starts. Useful to detect if devtools is enabled.
*/
'devtools:before': () => void;
/**
* Called after devtools is initialized.
*/
'devtools:initialized': (info: NuxtDevtoolsInfo) => void;
/**
* Hooks to extend devtools tabs.
*/
'devtools:customTabs': (tabs: ModuleCustomTab[]) => void;
/**
* Retrigger update for custom tabs, `devtools:customTabs` will be called again.
*/
'devtools:customTabs:refresh': () => void;
/**
* Register a terminal.
*/
'devtools:terminal:register': (terminal: TerminalState) => void;
/**
* Write to a terminal.
*
* Returns true if terminal is found.
*/
'devtools:terminal:write': (_: {
id: string;
data: string;
}) => void;
/**
* Remove a terminal from devtools.
*
* Returns true if terminal is found and deleted.
*/
'devtools:terminal:remove': (_: {
id: string;
}) => void;
/**
* Mark a terminal as terminated.
*/
'devtools:terminal:exit': (_: {
id: string;
code?: number;
}) => void;
}
}
declare module '@nuxt/schema' {
/**
* Runtime Hooks
*/
interface RuntimeNuxtHooks {
/**
* On terminal data.
*/
'devtools:terminal:data': (payload: {
id: string;
data: string;
}) => void;
}
}
export type { CodeServerType as $, AnalyzeBuildMeta as A, BasicModuleInfo as B, ClientFunctions as C, ModuleCompatibility as D, ModuleStats as E, CompatibilityStatus as F, ModuleType as G, HookInfo as H, ImageMeta as I, MaintainerInfo as J, GitHubContributor as K, LoadingTimeMetric as L, ModuleCustomTab as M, NuxtDevtoolsInfo as N, VueInspectorData as O, PluginMetric as P, AssetType as Q, RouteInfo as R, SubprocessOptions as S, TerminalState as T, AssetInfo as U, VueInspectorClient as V, AssetEntry as W, CodeSnippet as X, ComponentRelationship as Y, ComponentWithRelationships as Z, CodeServerOptions as _, ServerFunctions as a, ModuleOptions as a0, ModuleGlobalOptions as a1, VSCodeIntegrationOptions as a2, VSCodeTunnelOptions as a3, NuxtDevToolsOptions as a4, NuxtServerData as a5, ClientUpdateEvent as a6, NuxtDevtoolsServerContext as a7, InstallModuleReturn as a8, ServerDebugModuleMutationRecord as a9, ServerDebugContext as aa, TerminalBase as ab, TerminalAction as ac, TerminalInfo as ad, WizardFunctions as ae, WizardActions as af, GetWizardArgs as ag, AnalyzeBuildsInfo as b, TabCategory as c, ModuleLaunchView as d, ModuleIframeView as e, ModuleVNodeView as f, ModuleLaunchAction as g, ModuleView as h, ModuleIframeTabLazyOptions as i, ModuleBuiltinTab as j, ModuleTabInfo as k, CategorizedTabs as l, PackageUpdateInfo as m, PackageManagerName as n, NpmCommandType as o, NpmCommandOptions as p, AutoImportsWithMetadata as q, ServerRouteInfo as r, ServerRouteInputType as s, ServerRouteInput as t, Payload as u, ServerTaskInfo as v, ScannedNitroTasks as w, PluginInfoWithMetic as x, InstalledModuleInfo as y, ModuleStaticInfo as z };

View file

@ -0,0 +1,797 @@
import { VNode, MaybeRefOrGetter } from 'vue';
import { BirpcGroup } from 'birpc';
import { Component, NuxtOptions, NuxtPage, NuxtLayout, NuxtApp, NuxtDebugModuleMutationRecord, Nuxt } from 'nuxt/schema';
import { Import, UnimportMeta } from 'unimport';
import { RouteRecordNormalized } from 'vue-router';
import { Nitro, StorageMounts } from 'nitropack';
import { StorageValue } from 'unstorage';
import { ResolvedConfig } from 'vite';
import { NuxtAnalyzeMeta } from '@nuxt/schema';
import { Options } from 'execa';
type TabCategory = 'pinned' | 'app' | 'vue-devtools' | 'analyze' | 'server' | 'modules' | 'documentation' | 'advanced';
interface ModuleCustomTab {
/**
* The name of the tab, must be unique
*/
name: string;
/**
* Icon of the tab, support any Iconify icons, or a url to an image
*/
icon?: string;
/**
* Title of the tab
*/
title: string;
/**
* Main view of the tab
*/
view: ModuleView;
/**
* Category of the tab
* @default 'app'
*/
category?: TabCategory;
/**
* Insert static vnode to the tab entry
*
* Advanced options. You don't usually need this.
*/
extraTabVNode?: VNode;
/**
* Require local authentication to access the tab
* It's highly recommended to enable this if the tab have sensitive information or have access to the OS
*
* @default false
*/
requireAuth?: boolean;
}
interface ModuleLaunchView {
/**
* A view for module to lazy launch some actions
*/
type: 'launch';
title?: string;
icon?: string;
description: string;
/**
* Action buttons
*/
actions: ModuleLaunchAction[];
}
interface ModuleIframeView {
/**
* Iframe view
*/
type: 'iframe';
/**
* Url of the iframe
*/
src: string;
/**
* Persist the iframe instance even if the tab is not active
*
* @default true
*/
persistent?: boolean;
/**
* Additional permissions to allow in the iframe
* These will be merged with the default permissions (clipboard-write, clipboard-read)
*
* @example ['camera', 'microphone', 'geolocation']
*/
permissions?: string[];
}
interface ModuleVNodeView {
/**
* Vue's VNode view
*/
type: 'vnode';
/**
* Send vnode to the client, they must be static and serializable
*
* Call `nuxt.hook('devtools:customTabs:refresh')` to trigger manual refresh
*/
vnode: VNode;
}
interface ModuleLaunchAction {
/**
* Label of the action button
*/
label: string;
/**
* Additional HTML attributes to the action button
*/
attrs?: Record<string, string>;
/**
* Indicate if the action is pending, will show a loading indicator and disable the button
*/
pending?: boolean;
/**
* Function to handle the action, this is executed on the server side.
* Will automatically refresh the tabs after the action is resolved.
*/
handle?: () => void | Promise<void>;
/**
* Treat the action as a link, will open the link in a new tab
*/
src?: string;
}
type ModuleView = ModuleIframeView | ModuleLaunchView | ModuleVNodeView;
interface ModuleIframeTabLazyOptions {
description?: string;
onLoad?: () => Promise<void>;
}
interface ModuleBuiltinTab {
name: string;
icon?: string;
title?: string;
path?: string;
category?: TabCategory;
show?: () => MaybeRefOrGetter<any>;
badge?: () => MaybeRefOrGetter<number | string | undefined>;
onClick?: () => void;
}
type ModuleTabInfo = ModuleCustomTab | ModuleBuiltinTab;
type CategorizedTabs = [TabCategory, (ModuleCustomTab | ModuleBuiltinTab)[]][];
interface HookInfo {
name: string;
start: number;
end?: number;
duration?: number;
listeners: number;
executions: number[];
}
interface ImageMeta {
width: number;
height: number;
orientation?: number;
type?: string;
mimeType?: string;
}
interface PackageUpdateInfo {
name: string;
current: string;
latest: string;
needsUpdate: boolean;
}
type PackageManagerName = 'npm' | 'yarn' | 'pnpm' | 'bun';
type NpmCommandType = 'install' | 'uninstall' | 'update';
interface NpmCommandOptions {
dev?: boolean;
global?: boolean;
}
interface AutoImportsWithMetadata {
imports: Import[];
metadata?: UnimportMeta;
dirs: string[];
}
interface RouteInfo extends Pick<RouteRecordNormalized, 'name' | 'path' | 'meta' | 'props' | 'children'> {
file?: string;
}
interface ServerRouteInfo {
route: string;
filepath: string;
method?: string;
type: 'api' | 'route' | 'runtime' | 'collection';
routes?: ServerRouteInfo[];
}
type ServerRouteInputType = 'string' | 'number' | 'boolean' | 'file' | 'date' | 'time' | 'datetime-local';
interface ServerRouteInput {
active: boolean;
key: string;
value: any;
type?: ServerRouteInputType;
}
interface Payload {
url: string;
time: number;
data?: Record<string, any>;
state?: Record<string, any>;
functions?: Record<string, any>;
}
interface ServerTaskInfo {
name: string;
handler: string;
description: string;
type: 'collection' | 'task';
tasks?: ServerTaskInfo[];
}
interface ScannedNitroTasks {
tasks: {
[name: string]: {
handler: string;
description: string;
};
};
scheduledTasks: {
[cron: string]: string[];
};
}
interface PluginInfoWithMetic {
src: string;
mode?: 'client' | 'server' | 'all';
ssr?: boolean;
metric?: PluginMetric;
}
interface PluginMetric {
src: string;
start: number;
end: number;
duration: number;
}
interface LoadingTimeMetric {
ssrStart?: number;
appInit?: number;
appLoad?: number;
pageStart?: number;
pageEnd?: number;
pluginInit?: number;
hmrStart?: number;
hmrEnd?: number;
}
interface BasicModuleInfo {
entryPath?: string;
meta?: {
name?: string;
};
}
interface InstalledModuleInfo {
name?: string;
isPackageModule: boolean;
isUninstallable: boolean;
info?: ModuleStaticInfo;
entryPath?: string;
timings?: Record<string, number | undefined>;
meta?: {
name?: string;
};
}
interface ModuleStaticInfo {
name: string;
description: string;
repo: string;
npm: string;
icon?: string;
github: string;
website: string;
learn_more: string;
category: string;
type: ModuleType;
stats: ModuleStats;
maintainers: MaintainerInfo[];
contributors: GitHubContributor[];
compatibility: ModuleCompatibility;
}
interface ModuleCompatibility {
nuxt: string;
requires: {
bridge?: boolean | 'optional';
};
}
interface ModuleStats {
downloads: number;
stars: number;
publishedAt: number;
createdAt: number;
}
type CompatibilityStatus = 'working' | 'wip' | 'unknown' | 'not-working';
type ModuleType = 'community' | 'official' | '3rd-party';
interface MaintainerInfo {
name: string;
github: string;
twitter?: string;
}
interface GitHubContributor {
login: string;
name?: string;
avatar_url?: string;
}
interface VueInspectorClient {
enabled: boolean;
position: {
x: number;
y: number;
};
linkParams: {
file: string;
line: number;
column: number;
};
enable: () => void;
disable: () => void;
toggleEnabled: () => void;
openInEditor: (url: URL) => void;
onUpdated: () => void;
}
type VueInspectorData = VueInspectorClient['linkParams'] & Partial<VueInspectorClient['position']>;
type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'json' | 'other';
interface AssetInfo {
path: string;
type: AssetType;
publicPath: string;
filePath: string;
size: number;
mtime: number;
layer?: string;
}
interface AssetEntry {
path: string;
content: string;
encoding?: BufferEncoding;
override?: boolean;
}
interface CodeSnippet {
code: string;
lang: string;
name: string;
docs?: string;
}
interface ComponentRelationship {
id: string;
deps: string[];
}
interface ComponentWithRelationships {
component: Component;
dependencies?: string[];
dependents?: string[];
}
interface CodeServerOptions {
codeBinary: string;
launchArg: string;
licenseTermsArg: string;
connectionTokenArg: string;
}
type CodeServerType = 'ms-code-cli' | 'ms-code-server' | 'coder-code-server';
interface ModuleOptions {
/**
* Enable DevTools
*
* @default true
*/
enabled?: boolean;
/**
* Custom tabs
*
* This is in static format, for dynamic injection, call `nuxt.hook('devtools:customTabs')` instead
*/
customTabs?: ModuleCustomTab[];
/**
* VS Code Server integration options.
*/
vscode?: VSCodeIntegrationOptions;
/**
* Enable Vue Component Inspector
*
* @default true
*/
componentInspector?: boolean;
/**
* Enable Vue DevTools integration
*/
vueDevTools?: boolean;
/**
* Enable vite-plugin-inspect
*
* @default true
*/
viteInspect?: boolean;
/**
* Enable Vite DevTools integration
*
* @experimental
* @default false
*/
viteDevTools?: boolean;
/**
* Disable dev time authorization check.
*
* **NOT RECOMMENDED**, only use this if you know what you are doing.
*
* @see https://github.com/nuxt/devtools/pull/257
* @default false
*/
disableAuthorization?: boolean;
/**
* Props for the iframe element, useful for environment with stricter CSP
*/
iframeProps?: Record<string, string | boolean>;
/**
* Experimental features
*/
experimental?: {
/**
* Timeline tab
* @deprecated Use `timeline.enable` instead
*/
timeline?: boolean;
};
/**
* Options for the timeline tab
*/
timeline?: {
/**
* Enable timeline tab
*
* @default false
*/
enabled?: boolean;
/**
* Track on function calls
*/
functions?: {
include?: (string | RegExp | ((item: Import) => boolean))[];
/**
* Include from specific modules
*
* @default ['#app', '@unhead/vue']
*/
includeFrom?: string[];
exclude?: (string | RegExp | ((item: Import) => boolean))[];
};
};
/**
* Options for assets tab
*/
assets?: {
/**
* Allowed file extensions for assets tab to upload.
* To security concern.
*
* Set to '*' to disbale this limitation entirely
*
* @default Common media and txt files
*/
uploadExtensions?: '*' | string[];
};
/**
* Enable anonymous telemetry, helping us improve Nuxt DevTools.
*
* By default it will respect global Nuxt telemetry settings.
*/
telemetry?: boolean;
}
interface ModuleGlobalOptions {
/**
* List of projects to enable devtools for. Only works when devtools is installed globally.
*/
projects?: string[];
}
interface VSCodeIntegrationOptions {
/**
* Enable VS Code Server integration
*/
enabled?: boolean;
/**
* Start VS Code Server on boot
*
* @default false
*/
startOnBoot?: boolean;
/**
* Port to start VS Code Server
*
* @default 3080
*/
port?: number;
/**
* Reuse existing server if available (same port)
*/
reuseExistingServer?: boolean;
/**
* Determine whether to use code-server or vs code tunnel
*
* @default 'local-serve'
*/
mode?: 'local-serve' | 'tunnel';
/**
* Options for VS Code tunnel
*/
tunnel?: VSCodeTunnelOptions;
/**
* Determines which binary and arguments to use for VS Code.
*
* By default, uses the MS Code Server (ms-code-server).
* Can alternatively use the open source Coder code-server (coder-code-server),
* or the MS VS Code CLI (ms-code-cli)
* @default 'ms-code-server'
*/
codeServer?: CodeServerType;
/**
* Host address to listen on. Unspecified by default.
*/
host?: string;
}
interface VSCodeTunnelOptions {
/**
* the machine name for port forwarding service
*
* default: device hostname
*/
name?: string;
}
interface NuxtDevToolsOptions {
behavior: {
telemetry: boolean | null;
openInEditor: string | undefined;
};
ui: {
componentsGraphShowGlobalComponents: boolean;
componentsGraphShowLayouts: boolean;
componentsGraphShowNodeModules: boolean;
componentsGraphShowPages: boolean;
componentsGraphShowWorkspace: boolean;
componentsView: 'list' | 'graph';
hiddenTabCategories: string[];
hiddenTabs: string[];
interactionCloseOnOutsideClick: boolean;
minimizePanelInactive: number;
pinnedTabs: string[];
scale: number;
showExperimentalFeatures: boolean;
showHelpButtons: boolean;
showPanel: boolean | null;
sidebarExpanded: boolean;
sidebarScrollable: boolean;
};
serverRoutes: {
selectedRoute: ServerRouteInfo | null;
view: 'tree' | 'list';
inputDefaults: Record<string, ServerRouteInput[]>;
sendFrom: 'app' | 'devtools';
};
serverTasks: {
enabled: boolean;
selectedTask: ServerTaskInfo | null;
view: 'tree' | 'list';
inputDefaults: Record<string, ServerRouteInput[]>;
};
assets: {
view: 'grid' | 'list';
};
}
interface AnalyzeBuildMeta extends NuxtAnalyzeMeta {
features: {
bundleClient: boolean;
bundleNitro: boolean;
viteInspect: boolean;
};
size: {
clientBundle?: number;
nitroBundle?: number;
};
}
interface AnalyzeBuildsInfo {
isBuilding: boolean;
builds: AnalyzeBuildMeta[];
}
interface TerminalBase {
id: string;
name: string;
description?: string;
icon?: string;
}
type TerminalAction = 'restart' | 'terminate' | 'clear' | 'remove';
interface SubprocessOptions extends Options {
command: string;
args?: string[];
}
interface TerminalInfo extends TerminalBase {
/**
* Whether the terminal can be restarted
*/
restartable?: boolean;
/**
* Whether the terminal can be terminated
*/
terminatable?: boolean;
/**
* Whether the terminal is terminated
*/
isTerminated?: boolean;
/**
* Content buffer
*/
buffer?: string;
}
interface TerminalState extends TerminalInfo {
/**
* User action to restart the terminal, when not provided, this action will be disabled
*/
onActionRestart?: () => Promise<void> | void;
/**
* User action to terminate the terminal, when not provided, this action will be disabled
*/
onActionTerminate?: () => Promise<void> | void;
}
interface WizardFunctions {
enablePages: (nuxt: any) => Promise<void>;
}
type WizardActions = keyof WizardFunctions;
type GetWizardArgs<T extends WizardActions> = WizardFunctions[T] extends (nuxt: any, ...args: infer A) => any ? A : never;
interface ServerFunctions {
getServerConfig: () => NuxtOptions;
getServerDebugContext: () => Promise<ServerDebugContext | undefined>;
getServerData: (token: string) => Promise<NuxtServerData>;
getServerRuntimeConfig: () => Record<string, any>;
getModuleOptions: () => ModuleOptions;
getComponents: () => Component[];
getComponentsRelationships: () => Promise<ComponentRelationship[]>;
getAutoImports: () => AutoImportsWithMetadata;
getServerPages: () => NuxtPage[];
getCustomTabs: () => ModuleCustomTab[];
getServerHooks: () => HookInfo[];
getServerLayouts: () => NuxtLayout[];
getStaticAssets: () => Promise<AssetInfo[]>;
getServerRoutes: () => ServerRouteInfo[];
getServerTasks: () => ScannedNitroTasks | null;
getServerApp: () => NuxtApp | undefined;
getOptions: <T extends keyof NuxtDevToolsOptions>(tab: T) => Promise<NuxtDevToolsOptions[T]>;
updateOptions: <T extends keyof NuxtDevToolsOptions>(tab: T, settings: Partial<NuxtDevToolsOptions[T]>) => Promise<void>;
clearOptions: () => Promise<void>;
checkForUpdateFor: (name: string) => Promise<PackageUpdateInfo | undefined>;
getNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<string[] | undefined>;
runNpmCommand: (token: string, command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{
processId: string;
} | undefined>;
getTerminals: () => TerminalInfo[];
getTerminalDetail: (token: string, id: string) => Promise<TerminalInfo | undefined>;
runTerminalAction: (token: string, id: string, action: TerminalAction) => Promise<boolean>;
getStorageMounts: () => Promise<StorageMounts>;
getStorageKeys: (base?: string) => Promise<string[]>;
getStorageItem: (token: string, key: string) => Promise<StorageValue>;
setStorageItem: (token: string, key: string, value: StorageValue) => Promise<void>;
removeStorageItem: (token: string, key: string) => Promise<void>;
getAnalyzeBuildInfo: () => Promise<AnalyzeBuildsInfo>;
generateAnalyzeBuildName: () => Promise<string>;
startAnalyzeBuild: (token: string, name: string) => Promise<string>;
clearAnalyzeBuilds: (token: string, names?: string[]) => Promise<void>;
getImageMeta: (token: string, filepath: string) => Promise<ImageMeta | undefined>;
getTextAssetContent: (token: string, filepath: string, limit?: number) => Promise<string | undefined>;
writeStaticAssets: (token: string, file: AssetEntry[], folder: string) => Promise<string[]>;
deleteStaticAsset: (token: string, filepath: string) => Promise<void>;
renameStaticAsset: (token: string, oldPath: string, newPath: string) => Promise<void>;
telemetryEvent: (payload: object, immediate?: boolean) => void;
customTabAction: (name: string, action: number) => Promise<boolean>;
runWizard: <T extends WizardActions>(token: string, name: T, ...args: GetWizardArgs<T>) => Promise<void>;
openInEditor: (filepath: string) => Promise<boolean>;
restartNuxt: (token: string, hard?: boolean) => Promise<void>;
installNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>;
uninstallNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>;
enableTimeline: (dry: boolean) => Promise<[string, string]>;
requestForAuth: (info?: string, origin?: string) => Promise<void>;
verifyAuthToken: (token: string) => Promise<boolean>;
}
interface ClientFunctions {
refresh: (event: ClientUpdateEvent) => void;
callHook: (hook: string, ...args: any[]) => Promise<void>;
navigateTo: (path: string) => void;
onTerminalData: (_: {
id: string;
data: string;
}) => void;
onTerminalExit: (_: {
id: string;
code?: number;
}) => void;
}
interface NuxtServerData {
nuxt: NuxtOptions;
nitro?: Nitro['options'];
vite: {
server?: ResolvedConfig;
client?: ResolvedConfig;
};
}
type ClientUpdateEvent = keyof ServerFunctions;
/**
* @internal
*/
interface NuxtDevtoolsServerContext {
nuxt: Nuxt;
options: ModuleOptions;
rpc: BirpcGroup<ClientFunctions, ServerFunctions>;
/**
* Hook to open file in editor
*/
openInEditorHooks: ((filepath: string) => boolean | void | Promise<boolean | void>)[];
/**
* Invalidate client cache for a function and ask for re-fetching
*/
refresh: (event: keyof ServerFunctions) => void;
/**
* Ensure dev auth token is valid, throw if not
*/
ensureDevAuthToken: (token: string) => Promise<void>;
extendServerRpc: <ClientFunctions = Record<string, never>, ServerFunctions = Record<string, never>>(name: string, functions: ServerFunctions) => BirpcGroup<ClientFunctions, ServerFunctions>;
}
interface NuxtDevtoolsInfo {
version: string;
packagePath: string;
isGlobalInstall: boolean;
}
interface InstallModuleReturn {
configOriginal: string;
configGenerated: string;
commands: string[];
processId: string;
}
type ServerDebugModuleMutationRecord = (Omit<NuxtDebugModuleMutationRecord, 'module'> & {
name: string;
});
interface ServerDebugContext {
moduleMutationRecords: ServerDebugModuleMutationRecord[];
}
declare module '@nuxt/schema' {
interface NuxtHooks {
/**
* Called before devtools starts. Useful to detect if devtools is enabled.
*/
'devtools:before': () => void;
/**
* Called after devtools is initialized.
*/
'devtools:initialized': (info: NuxtDevtoolsInfo) => void;
/**
* Hooks to extend devtools tabs.
*/
'devtools:customTabs': (tabs: ModuleCustomTab[]) => void;
/**
* Retrigger update for custom tabs, `devtools:customTabs` will be called again.
*/
'devtools:customTabs:refresh': () => void;
/**
* Register a terminal.
*/
'devtools:terminal:register': (terminal: TerminalState) => void;
/**
* Write to a terminal.
*
* Returns true if terminal is found.
*/
'devtools:terminal:write': (_: {
id: string;
data: string;
}) => void;
/**
* Remove a terminal from devtools.
*
* Returns true if terminal is found and deleted.
*/
'devtools:terminal:remove': (_: {
id: string;
}) => void;
/**
* Mark a terminal as terminated.
*/
'devtools:terminal:exit': (_: {
id: string;
code?: number;
}) => void;
}
}
declare module '@nuxt/schema' {
/**
* Runtime Hooks
*/
interface RuntimeNuxtHooks {
/**
* On terminal data.
*/
'devtools:terminal:data': (payload: {
id: string;
data: string;
}) => void;
}
}
export type { CodeServerType as $, AnalyzeBuildMeta as A, BasicModuleInfo as B, ClientFunctions as C, ModuleCompatibility as D, ModuleStats as E, CompatibilityStatus as F, ModuleType as G, HookInfo as H, ImageMeta as I, MaintainerInfo as J, GitHubContributor as K, LoadingTimeMetric as L, ModuleCustomTab as M, NuxtDevtoolsInfo as N, VueInspectorData as O, PluginMetric as P, AssetType as Q, RouteInfo as R, SubprocessOptions as S, TerminalState as T, AssetInfo as U, VueInspectorClient as V, AssetEntry as W, CodeSnippet as X, ComponentRelationship as Y, ComponentWithRelationships as Z, CodeServerOptions as _, ServerFunctions as a, ModuleOptions as a0, ModuleGlobalOptions as a1, VSCodeIntegrationOptions as a2, VSCodeTunnelOptions as a3, NuxtDevToolsOptions as a4, NuxtServerData as a5, ClientUpdateEvent as a6, NuxtDevtoolsServerContext as a7, InstallModuleReturn as a8, ServerDebugModuleMutationRecord as a9, ServerDebugContext as aa, TerminalBase as ab, TerminalAction as ac, TerminalInfo as ad, WizardFunctions as ae, WizardActions as af, GetWizardArgs as ag, AnalyzeBuildsInfo as b, TabCategory as c, ModuleLaunchView as d, ModuleIframeView as e, ModuleVNodeView as f, ModuleLaunchAction as g, ModuleView as h, ModuleIframeTabLazyOptions as i, ModuleBuiltinTab as j, ModuleTabInfo as k, CategorizedTabs as l, PackageUpdateInfo as m, PackageManagerName as n, NpmCommandType as o, NpmCommandOptions as p, AutoImportsWithMetadata as q, ServerRouteInfo as r, ServerRouteInputType as s, ServerRouteInput as t, Payload as u, ServerTaskInfo as v, ScannedNitroTasks as w, PluginInfoWithMetic as x, InstalledModuleInfo as y, ModuleStaticInfo as z };

View file

@ -0,0 +1,797 @@
import { VNode, MaybeRefOrGetter } from 'vue';
import { BirpcGroup } from 'birpc';
import { Component, NuxtOptions, NuxtPage, NuxtLayout, NuxtApp, NuxtDebugModuleMutationRecord, Nuxt } from 'nuxt/schema';
import { Import, UnimportMeta } from 'unimport';
import { RouteRecordNormalized } from 'vue-router';
import { Nitro, StorageMounts } from 'nitropack';
import { StorageValue } from 'unstorage';
import { ResolvedConfig } from 'vite';
import { NuxtAnalyzeMeta } from '@nuxt/schema';
import { Options } from 'execa';
type TabCategory = 'pinned' | 'app' | 'vue-devtools' | 'analyze' | 'server' | 'modules' | 'documentation' | 'advanced';
interface ModuleCustomTab {
/**
* The name of the tab, must be unique
*/
name: string;
/**
* Icon of the tab, support any Iconify icons, or a url to an image
*/
icon?: string;
/**
* Title of the tab
*/
title: string;
/**
* Main view of the tab
*/
view: ModuleView;
/**
* Category of the tab
* @default 'app'
*/
category?: TabCategory;
/**
* Insert static vnode to the tab entry
*
* Advanced options. You don't usually need this.
*/
extraTabVNode?: VNode;
/**
* Require local authentication to access the tab
* It's highly recommended to enable this if the tab have sensitive information or have access to the OS
*
* @default false
*/
requireAuth?: boolean;
}
interface ModuleLaunchView {
/**
* A view for module to lazy launch some actions
*/
type: 'launch';
title?: string;
icon?: string;
description: string;
/**
* Action buttons
*/
actions: ModuleLaunchAction[];
}
interface ModuleIframeView {
/**
* Iframe view
*/
type: 'iframe';
/**
* Url of the iframe
*/
src: string;
/**
* Persist the iframe instance even if the tab is not active
*
* @default true
*/
persistent?: boolean;
/**
* Additional permissions to allow in the iframe
* These will be merged with the default permissions (clipboard-write, clipboard-read)
*
* @example ['camera', 'microphone', 'geolocation']
*/
permissions?: string[];
}
interface ModuleVNodeView {
/**
* Vue's VNode view
*/
type: 'vnode';
/**
* Send vnode to the client, they must be static and serializable
*
* Call `nuxt.hook('devtools:customTabs:refresh')` to trigger manual refresh
*/
vnode: VNode;
}
interface ModuleLaunchAction {
/**
* Label of the action button
*/
label: string;
/**
* Additional HTML attributes to the action button
*/
attrs?: Record<string, string>;
/**
* Indicate if the action is pending, will show a loading indicator and disable the button
*/
pending?: boolean;
/**
* Function to handle the action, this is executed on the server side.
* Will automatically refresh the tabs after the action is resolved.
*/
handle?: () => void | Promise<void>;
/**
* Treat the action as a link, will open the link in a new tab
*/
src?: string;
}
type ModuleView = ModuleIframeView | ModuleLaunchView | ModuleVNodeView;
interface ModuleIframeTabLazyOptions {
description?: string;
onLoad?: () => Promise<void>;
}
interface ModuleBuiltinTab {
name: string;
icon?: string;
title?: string;
path?: string;
category?: TabCategory;
show?: () => MaybeRefOrGetter<any>;
badge?: () => MaybeRefOrGetter<number | string | undefined>;
onClick?: () => void;
}
type ModuleTabInfo = ModuleCustomTab | ModuleBuiltinTab;
type CategorizedTabs = [TabCategory, (ModuleCustomTab | ModuleBuiltinTab)[]][];
interface HookInfo {
name: string;
start: number;
end?: number;
duration?: number;
listeners: number;
executions: number[];
}
interface ImageMeta {
width: number;
height: number;
orientation?: number;
type?: string;
mimeType?: string;
}
interface PackageUpdateInfo {
name: string;
current: string;
latest: string;
needsUpdate: boolean;
}
type PackageManagerName = 'npm' | 'yarn' | 'pnpm' | 'bun';
type NpmCommandType = 'install' | 'uninstall' | 'update';
interface NpmCommandOptions {
dev?: boolean;
global?: boolean;
}
interface AutoImportsWithMetadata {
imports: Import[];
metadata?: UnimportMeta;
dirs: string[];
}
interface RouteInfo extends Pick<RouteRecordNormalized, 'name' | 'path' | 'meta' | 'props' | 'children'> {
file?: string;
}
interface ServerRouteInfo {
route: string;
filepath: string;
method?: string;
type: 'api' | 'route' | 'runtime' | 'collection';
routes?: ServerRouteInfo[];
}
type ServerRouteInputType = 'string' | 'number' | 'boolean' | 'file' | 'date' | 'time' | 'datetime-local';
interface ServerRouteInput {
active: boolean;
key: string;
value: any;
type?: ServerRouteInputType;
}
interface Payload {
url: string;
time: number;
data?: Record<string, any>;
state?: Record<string, any>;
functions?: Record<string, any>;
}
interface ServerTaskInfo {
name: string;
handler: string;
description: string;
type: 'collection' | 'task';
tasks?: ServerTaskInfo[];
}
interface ScannedNitroTasks {
tasks: {
[name: string]: {
handler: string;
description: string;
};
};
scheduledTasks: {
[cron: string]: string[];
};
}
interface PluginInfoWithMetic {
src: string;
mode?: 'client' | 'server' | 'all';
ssr?: boolean;
metric?: PluginMetric;
}
interface PluginMetric {
src: string;
start: number;
end: number;
duration: number;
}
interface LoadingTimeMetric {
ssrStart?: number;
appInit?: number;
appLoad?: number;
pageStart?: number;
pageEnd?: number;
pluginInit?: number;
hmrStart?: number;
hmrEnd?: number;
}
interface BasicModuleInfo {
entryPath?: string;
meta?: {
name?: string;
};
}
interface InstalledModuleInfo {
name?: string;
isPackageModule: boolean;
isUninstallable: boolean;
info?: ModuleStaticInfo;
entryPath?: string;
timings?: Record<string, number | undefined>;
meta?: {
name?: string;
};
}
interface ModuleStaticInfo {
name: string;
description: string;
repo: string;
npm: string;
icon?: string;
github: string;
website: string;
learn_more: string;
category: string;
type: ModuleType;
stats: ModuleStats;
maintainers: MaintainerInfo[];
contributors: GitHubContributor[];
compatibility: ModuleCompatibility;
}
interface ModuleCompatibility {
nuxt: string;
requires: {
bridge?: boolean | 'optional';
};
}
interface ModuleStats {
downloads: number;
stars: number;
publishedAt: number;
createdAt: number;
}
type CompatibilityStatus = 'working' | 'wip' | 'unknown' | 'not-working';
type ModuleType = 'community' | 'official' | '3rd-party';
interface MaintainerInfo {
name: string;
github: string;
twitter?: string;
}
interface GitHubContributor {
login: string;
name?: string;
avatar_url?: string;
}
interface VueInspectorClient {
enabled: boolean;
position: {
x: number;
y: number;
};
linkParams: {
file: string;
line: number;
column: number;
};
enable: () => void;
disable: () => void;
toggleEnabled: () => void;
openInEditor: (url: URL) => void;
onUpdated: () => void;
}
type VueInspectorData = VueInspectorClient['linkParams'] & Partial<VueInspectorClient['position']>;
type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'json' | 'other';
interface AssetInfo {
path: string;
type: AssetType;
publicPath: string;
filePath: string;
size: number;
mtime: number;
layer?: string;
}
interface AssetEntry {
path: string;
content: string;
encoding?: BufferEncoding;
override?: boolean;
}
interface CodeSnippet {
code: string;
lang: string;
name: string;
docs?: string;
}
interface ComponentRelationship {
id: string;
deps: string[];
}
interface ComponentWithRelationships {
component: Component;
dependencies?: string[];
dependents?: string[];
}
interface CodeServerOptions {
codeBinary: string;
launchArg: string;
licenseTermsArg: string;
connectionTokenArg: string;
}
type CodeServerType = 'ms-code-cli' | 'ms-code-server' | 'coder-code-server';
interface ModuleOptions {
/**
* Enable DevTools
*
* @default true
*/
enabled?: boolean;
/**
* Custom tabs
*
* This is in static format, for dynamic injection, call `nuxt.hook('devtools:customTabs')` instead
*/
customTabs?: ModuleCustomTab[];
/**
* VS Code Server integration options.
*/
vscode?: VSCodeIntegrationOptions;
/**
* Enable Vue Component Inspector
*
* @default true
*/
componentInspector?: boolean;
/**
* Enable Vue DevTools integration
*/
vueDevTools?: boolean;
/**
* Enable vite-plugin-inspect
*
* @default true
*/
viteInspect?: boolean;
/**
* Enable Vite DevTools integration
*
* @experimental
* @default false
*/
viteDevTools?: boolean;
/**
* Disable dev time authorization check.
*
* **NOT RECOMMENDED**, only use this if you know what you are doing.
*
* @see https://github.com/nuxt/devtools/pull/257
* @default false
*/
disableAuthorization?: boolean;
/**
* Props for the iframe element, useful for environment with stricter CSP
*/
iframeProps?: Record<string, string | boolean>;
/**
* Experimental features
*/
experimental?: {
/**
* Timeline tab
* @deprecated Use `timeline.enable` instead
*/
timeline?: boolean;
};
/**
* Options for the timeline tab
*/
timeline?: {
/**
* Enable timeline tab
*
* @default false
*/
enabled?: boolean;
/**
* Track on function calls
*/
functions?: {
include?: (string | RegExp | ((item: Import) => boolean))[];
/**
* Include from specific modules
*
* @default ['#app', '@unhead/vue']
*/
includeFrom?: string[];
exclude?: (string | RegExp | ((item: Import) => boolean))[];
};
};
/**
* Options for assets tab
*/
assets?: {
/**
* Allowed file extensions for assets tab to upload.
* To security concern.
*
* Set to '*' to disbale this limitation entirely
*
* @default Common media and txt files
*/
uploadExtensions?: '*' | string[];
};
/**
* Enable anonymous telemetry, helping us improve Nuxt DevTools.
*
* By default it will respect global Nuxt telemetry settings.
*/
telemetry?: boolean;
}
interface ModuleGlobalOptions {
/**
* List of projects to enable devtools for. Only works when devtools is installed globally.
*/
projects?: string[];
}
interface VSCodeIntegrationOptions {
/**
* Enable VS Code Server integration
*/
enabled?: boolean;
/**
* Start VS Code Server on boot
*
* @default false
*/
startOnBoot?: boolean;
/**
* Port to start VS Code Server
*
* @default 3080
*/
port?: number;
/**
* Reuse existing server if available (same port)
*/
reuseExistingServer?: boolean;
/**
* Determine whether to use code-server or vs code tunnel
*
* @default 'local-serve'
*/
mode?: 'local-serve' | 'tunnel';
/**
* Options for VS Code tunnel
*/
tunnel?: VSCodeTunnelOptions;
/**
* Determines which binary and arguments to use for VS Code.
*
* By default, uses the MS Code Server (ms-code-server).
* Can alternatively use the open source Coder code-server (coder-code-server),
* or the MS VS Code CLI (ms-code-cli)
* @default 'ms-code-server'
*/
codeServer?: CodeServerType;
/**
* Host address to listen on. Unspecified by default.
*/
host?: string;
}
interface VSCodeTunnelOptions {
/**
* the machine name for port forwarding service
*
* default: device hostname
*/
name?: string;
}
interface NuxtDevToolsOptions {
behavior: {
telemetry: boolean | null;
openInEditor: string | undefined;
};
ui: {
componentsGraphShowGlobalComponents: boolean;
componentsGraphShowLayouts: boolean;
componentsGraphShowNodeModules: boolean;
componentsGraphShowPages: boolean;
componentsGraphShowWorkspace: boolean;
componentsView: 'list' | 'graph';
hiddenTabCategories: string[];
hiddenTabs: string[];
interactionCloseOnOutsideClick: boolean;
minimizePanelInactive: number;
pinnedTabs: string[];
scale: number;
showExperimentalFeatures: boolean;
showHelpButtons: boolean;
showPanel: boolean | null;
sidebarExpanded: boolean;
sidebarScrollable: boolean;
};
serverRoutes: {
selectedRoute: ServerRouteInfo | null;
view: 'tree' | 'list';
inputDefaults: Record<string, ServerRouteInput[]>;
sendFrom: 'app' | 'devtools';
};
serverTasks: {
enabled: boolean;
selectedTask: ServerTaskInfo | null;
view: 'tree' | 'list';
inputDefaults: Record<string, ServerRouteInput[]>;
};
assets: {
view: 'grid' | 'list';
};
}
interface AnalyzeBuildMeta extends NuxtAnalyzeMeta {
features: {
bundleClient: boolean;
bundleNitro: boolean;
viteInspect: boolean;
};
size: {
clientBundle?: number;
nitroBundle?: number;
};
}
interface AnalyzeBuildsInfo {
isBuilding: boolean;
builds: AnalyzeBuildMeta[];
}
interface TerminalBase {
id: string;
name: string;
description?: string;
icon?: string;
}
type TerminalAction = 'restart' | 'terminate' | 'clear' | 'remove';
interface SubprocessOptions extends Options {
command: string;
args?: string[];
}
interface TerminalInfo extends TerminalBase {
/**
* Whether the terminal can be restarted
*/
restartable?: boolean;
/**
* Whether the terminal can be terminated
*/
terminatable?: boolean;
/**
* Whether the terminal is terminated
*/
isTerminated?: boolean;
/**
* Content buffer
*/
buffer?: string;
}
interface TerminalState extends TerminalInfo {
/**
* User action to restart the terminal, when not provided, this action will be disabled
*/
onActionRestart?: () => Promise<void> | void;
/**
* User action to terminate the terminal, when not provided, this action will be disabled
*/
onActionTerminate?: () => Promise<void> | void;
}
interface WizardFunctions {
enablePages: (nuxt: any) => Promise<void>;
}
type WizardActions = keyof WizardFunctions;
type GetWizardArgs<T extends WizardActions> = WizardFunctions[T] extends (nuxt: any, ...args: infer A) => any ? A : never;
interface ServerFunctions {
getServerConfig: () => NuxtOptions;
getServerDebugContext: () => Promise<ServerDebugContext | undefined>;
getServerData: (token: string) => Promise<NuxtServerData>;
getServerRuntimeConfig: () => Record<string, any>;
getModuleOptions: () => ModuleOptions;
getComponents: () => Component[];
getComponentsRelationships: () => Promise<ComponentRelationship[]>;
getAutoImports: () => AutoImportsWithMetadata;
getServerPages: () => NuxtPage[];
getCustomTabs: () => ModuleCustomTab[];
getServerHooks: () => HookInfo[];
getServerLayouts: () => NuxtLayout[];
getStaticAssets: () => Promise<AssetInfo[]>;
getServerRoutes: () => ServerRouteInfo[];
getServerTasks: () => ScannedNitroTasks | null;
getServerApp: () => NuxtApp | undefined;
getOptions: <T extends keyof NuxtDevToolsOptions>(tab: T) => Promise<NuxtDevToolsOptions[T]>;
updateOptions: <T extends keyof NuxtDevToolsOptions>(tab: T, settings: Partial<NuxtDevToolsOptions[T]>) => Promise<void>;
clearOptions: () => Promise<void>;
checkForUpdateFor: (name: string) => Promise<PackageUpdateInfo | undefined>;
getNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<string[] | undefined>;
runNpmCommand: (token: string, command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{
processId: string;
} | undefined>;
getTerminals: () => TerminalInfo[];
getTerminalDetail: (token: string, id: string) => Promise<TerminalInfo | undefined>;
runTerminalAction: (token: string, id: string, action: TerminalAction) => Promise<boolean>;
getStorageMounts: () => Promise<StorageMounts>;
getStorageKeys: (base?: string) => Promise<string[]>;
getStorageItem: (token: string, key: string) => Promise<StorageValue>;
setStorageItem: (token: string, key: string, value: StorageValue) => Promise<void>;
removeStorageItem: (token: string, key: string) => Promise<void>;
getAnalyzeBuildInfo: () => Promise<AnalyzeBuildsInfo>;
generateAnalyzeBuildName: () => Promise<string>;
startAnalyzeBuild: (token: string, name: string) => Promise<string>;
clearAnalyzeBuilds: (token: string, names?: string[]) => Promise<void>;
getImageMeta: (token: string, filepath: string) => Promise<ImageMeta | undefined>;
getTextAssetContent: (token: string, filepath: string, limit?: number) => Promise<string | undefined>;
writeStaticAssets: (token: string, file: AssetEntry[], folder: string) => Promise<string[]>;
deleteStaticAsset: (token: string, filepath: string) => Promise<void>;
renameStaticAsset: (token: string, oldPath: string, newPath: string) => Promise<void>;
telemetryEvent: (payload: object, immediate?: boolean) => void;
customTabAction: (name: string, action: number) => Promise<boolean>;
runWizard: <T extends WizardActions>(token: string, name: T, ...args: GetWizardArgs<T>) => Promise<void>;
openInEditor: (filepath: string) => Promise<boolean>;
restartNuxt: (token: string, hard?: boolean) => Promise<void>;
installNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>;
uninstallNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>;
enableTimeline: (dry: boolean) => Promise<[string, string]>;
requestForAuth: (info?: string, origin?: string) => Promise<void>;
verifyAuthToken: (token: string) => Promise<boolean>;
}
interface ClientFunctions {
refresh: (event: ClientUpdateEvent) => void;
callHook: (hook: string, ...args: any[]) => Promise<void>;
navigateTo: (path: string) => void;
onTerminalData: (_: {
id: string;
data: string;
}) => void;
onTerminalExit: (_: {
id: string;
code?: number;
}) => void;
}
interface NuxtServerData {
nuxt: NuxtOptions;
nitro?: Nitro['options'];
vite: {
server?: ResolvedConfig;
client?: ResolvedConfig;
};
}
type ClientUpdateEvent = keyof ServerFunctions;
/**
* @internal
*/
interface NuxtDevtoolsServerContext {
nuxt: Nuxt;
options: ModuleOptions;
rpc: BirpcGroup<ClientFunctions, ServerFunctions>;
/**
* Hook to open file in editor
*/
openInEditorHooks: ((filepath: string) => boolean | void | Promise<boolean | void>)[];
/**
* Invalidate client cache for a function and ask for re-fetching
*/
refresh: (event: keyof ServerFunctions) => void;
/**
* Ensure dev auth token is valid, throw if not
*/
ensureDevAuthToken: (token: string) => Promise<void>;
extendServerRpc: <ClientFunctions = Record<string, never>, ServerFunctions = Record<string, never>>(name: string, functions: ServerFunctions) => BirpcGroup<ClientFunctions, ServerFunctions>;
}
interface NuxtDevtoolsInfo {
version: string;
packagePath: string;
isGlobalInstall: boolean;
}
interface InstallModuleReturn {
configOriginal: string;
configGenerated: string;
commands: string[];
processId: string;
}
type ServerDebugModuleMutationRecord = (Omit<NuxtDebugModuleMutationRecord, 'module'> & {
name: string;
});
interface ServerDebugContext {
moduleMutationRecords: ServerDebugModuleMutationRecord[];
}
declare module '@nuxt/schema' {
interface NuxtHooks {
/**
* Called before devtools starts. Useful to detect if devtools is enabled.
*/
'devtools:before': () => void;
/**
* Called after devtools is initialized.
*/
'devtools:initialized': (info: NuxtDevtoolsInfo) => void;
/**
* Hooks to extend devtools tabs.
*/
'devtools:customTabs': (tabs: ModuleCustomTab[]) => void;
/**
* Retrigger update for custom tabs, `devtools:customTabs` will be called again.
*/
'devtools:customTabs:refresh': () => void;
/**
* Register a terminal.
*/
'devtools:terminal:register': (terminal: TerminalState) => void;
/**
* Write to a terminal.
*
* Returns true if terminal is found.
*/
'devtools:terminal:write': (_: {
id: string;
data: string;
}) => void;
/**
* Remove a terminal from devtools.
*
* Returns true if terminal is found and deleted.
*/
'devtools:terminal:remove': (_: {
id: string;
}) => void;
/**
* Mark a terminal as terminated.
*/
'devtools:terminal:exit': (_: {
id: string;
code?: number;
}) => void;
}
}
declare module '@nuxt/schema' {
/**
* Runtime Hooks
*/
interface RuntimeNuxtHooks {
/**
* On terminal data.
*/
'devtools:terminal:data': (payload: {
id: string;
data: string;
}) => void;
}
}
export type { CodeServerType as $, AnalyzeBuildMeta as A, BasicModuleInfo as B, ClientFunctions as C, ModuleCompatibility as D, ModuleStats as E, CompatibilityStatus as F, ModuleType as G, HookInfo as H, ImageMeta as I, MaintainerInfo as J, GitHubContributor as K, LoadingTimeMetric as L, ModuleCustomTab as M, NuxtDevtoolsInfo as N, VueInspectorData as O, PluginMetric as P, AssetType as Q, RouteInfo as R, SubprocessOptions as S, TerminalState as T, AssetInfo as U, VueInspectorClient as V, AssetEntry as W, CodeSnippet as X, ComponentRelationship as Y, ComponentWithRelationships as Z, CodeServerOptions as _, ServerFunctions as a, ModuleOptions as a0, ModuleGlobalOptions as a1, VSCodeIntegrationOptions as a2, VSCodeTunnelOptions as a3, NuxtDevToolsOptions as a4, NuxtServerData as a5, ClientUpdateEvent as a6, NuxtDevtoolsServerContext as a7, InstallModuleReturn as a8, ServerDebugModuleMutationRecord as a9, ServerDebugContext as aa, TerminalBase as ab, TerminalAction as ac, TerminalInfo as ad, WizardFunctions as ae, WizardActions as af, GetWizardArgs as ag, AnalyzeBuildsInfo as b, TabCategory as c, ModuleLaunchView as d, ModuleIframeView as e, ModuleVNodeView as f, ModuleLaunchAction as g, ModuleView as h, ModuleIframeTabLazyOptions as i, ModuleBuiltinTab as j, ModuleTabInfo as k, CategorizedTabs as l, PackageUpdateInfo as m, PackageManagerName as n, NpmCommandType as o, NpmCommandOptions as p, AutoImportsWithMetadata as q, ServerRouteInfo as r, ServerRouteInputType as s, ServerRouteInput as t, Payload as u, ServerTaskInfo as v, ScannedNitroTasks as w, PluginInfoWithMetic as x, InstalledModuleInfo as y, ModuleStaticInfo as z };

View file

@ -0,0 +1,2 @@
'use strict';

View file

@ -0,0 +1,181 @@
import { H as HookInfo, P as PluginMetric, L as LoadingTimeMetric, a as ServerFunctions, C as ClientFunctions } from './shared/devtools-kit.r2McQC71.cjs';
export { A as AnalyzeBuildMeta, b as AnalyzeBuildsInfo, W as AssetEntry, U as AssetInfo, Q as AssetType, q as AutoImportsWithMetadata, B as BasicModuleInfo, l as CategorizedTabs, a6 as ClientUpdateEvent, _ as CodeServerOptions, $ as CodeServerType, X as CodeSnippet, F as CompatibilityStatus, Y as ComponentRelationship, Z as ComponentWithRelationships, ag as GetWizardArgs, K as GitHubContributor, I as ImageMeta, a8 as InstallModuleReturn, y as InstalledModuleInfo, J as MaintainerInfo, j as ModuleBuiltinTab, D as ModuleCompatibility, M as ModuleCustomTab, a1 as ModuleGlobalOptions, i as ModuleIframeTabLazyOptions, e as ModuleIframeView, g as ModuleLaunchAction, d as ModuleLaunchView, a0 as ModuleOptions, z as ModuleStaticInfo, E as ModuleStats, k as ModuleTabInfo, G as ModuleType, f as ModuleVNodeView, h as ModuleView, p as NpmCommandOptions, o as NpmCommandType, a4 as NuxtDevToolsOptions, N as NuxtDevtoolsInfo, a7 as NuxtDevtoolsServerContext, a5 as NuxtServerData, n as PackageManagerName, m as PackageUpdateInfo, u as Payload, x as PluginInfoWithMetic, R as RouteInfo, w as ScannedNitroTasks, aa as ServerDebugContext, a9 as ServerDebugModuleMutationRecord, r as ServerRouteInfo, t as ServerRouteInput, s as ServerRouteInputType, v as ServerTaskInfo, S as SubprocessOptions, c as TabCategory, ac as TerminalAction, ab as TerminalBase, ad as TerminalInfo, T as TerminalState, a2 as VSCodeIntegrationOptions, a3 as VSCodeTunnelOptions, V as VueInspectorClient, O as VueInspectorData, af as WizardActions, ae as WizardFunctions } from './shared/devtools-kit.r2McQC71.cjs';
import { BirpcReturn } from 'birpc';
import { Hookable } from 'hookable';
import { NuxtApp } from 'nuxt/app';
import { AppConfig } from 'nuxt/schema';
import { $Fetch } from 'ofetch';
import { BuiltinLanguage } from 'shiki';
import { Ref } from 'vue';
import { StackFrame } from 'error-stack-parser-es';
import 'unimport';
import 'vue-router';
import 'nitropack';
import 'unstorage';
import 'vite';
import '@nuxt/schema';
import 'execa';
interface TimelineEventFunction {
type: 'function';
start: number;
end?: number;
name: string;
args?: any[];
result?: any;
stacktrace?: StackFrame[];
isPromise?: boolean;
}
interface TimelineServerState {
timeSsrStart?: number;
}
interface TimelineEventRoute {
type: 'route';
start: number;
end?: number;
from: string;
to: string;
}
interface TimelineOptions {
enabled: boolean;
stacktrace: boolean;
arguments: boolean;
}
type TimelineEvent = TimelineEventFunction | TimelineEventRoute;
interface TimelineMetrics {
events: TimelineEvent[];
nonLiteralSymbol: symbol;
options: TimelineOptions;
}
interface TimelineEventNormalized<T> {
event: T;
segment: TimelineEventsSegment;
relativeStart: number;
relativeWidth: number;
layer: number;
}
interface TimelineEventsSegment {
start: number;
end: number;
events: TimelineEvent[];
functions: TimelineEventNormalized<TimelineEventFunction>[];
route?: TimelineEventNormalized<TimelineEventRoute>;
duration: number;
previousGap?: number;
}
interface DevToolsFrameState {
width: number;
height: number;
top: number;
left: number;
open: boolean;
route: string;
position: 'left' | 'right' | 'bottom' | 'top';
closeOnOutsideClick: boolean;
minimizePanelInactive: number;
}
interface NuxtDevtoolsClientHooks {
/**
* When the DevTools navigates, used for persisting the current tab
*/
'devtools:navigate': (path: string) => void;
/**
* Event emitted when the component inspector is clicked
*/
'host:inspector:click': (path: string) => void;
/**
* Event to close the component inspector
*/
'host:inspector:close': () => void;
/**
* Triggers reactivity manually, since Vue won't be reactive across frames)
*/
'host:update:reactivity': () => void;
/**
* Host action to control the DevTools navigation
*/
'host:action:navigate': (path: string) => void;
/**
* Host action to reload the DevTools
*/
'host:action:reload': () => void;
}
/**
* Host client from the App
*/
interface NuxtDevtoolsHostClient {
nuxt: NuxtApp;
hooks: Hookable<NuxtDevtoolsClientHooks>;
getIframe: () => HTMLIFrameElement | undefined;
inspector?: {
enable: () => void;
disable: () => void;
toggle: () => void;
isEnabled: Ref<boolean>;
isAvailable: Ref<boolean>;
};
devtools: {
close: () => void;
open: () => void;
toggle: () => void;
reload: () => void;
navigate: (path: string) => void;
/**
* Popup the DevTools frame into Picture-in-Picture mode
*
* Requires Chrome 111 with experimental flag enabled.
*
* Function is undefined when not supported.
*
* @see https://developer.chrome.com/docs/web-platform/document-picture-in-picture/
*/
popup?: () => any;
};
app: {
reload: () => void;
navigate: (path: string, hard?: boolean) => void;
appConfig: AppConfig;
colorMode: Ref<'dark' | 'light'>;
frameState: Ref<DevToolsFrameState>;
$fetch: $Fetch;
};
metrics: {
clientHooks: () => HookInfo[];
clientPlugins: () => PluginMetric[] | undefined;
clientTimeline: () => TimelineMetrics | undefined;
loading: () => LoadingTimeMetric;
};
/**
* A counter to trigger reactivity updates
*/
revision: Ref<number>;
/**
* Update client
* @internal
*/
syncClient: () => NuxtDevtoolsHostClient;
}
interface CodeHighlightOptions {
grammarContextCode?: string;
}
interface NuxtDevtoolsClient {
rpc: BirpcReturn<ServerFunctions, ClientFunctions>;
renderCodeHighlight: (code: string, lang?: BuiltinLanguage, options?: CodeHighlightOptions) => {
code: string;
supported: boolean;
};
renderMarkdown: (markdown: string) => string;
colorMode: string;
extendClientRpc: <ServerFunctions = Record<string, never>, ClientFunctions = Record<string, never>>(name: string, functions: ClientFunctions) => BirpcReturn<ServerFunctions, ClientFunctions>;
}
interface NuxtDevtoolsIframeClient {
host: NuxtDevtoolsHostClient;
devtools: NuxtDevtoolsClient;
}
interface NuxtDevtoolsGlobal {
setClient: (client: NuxtDevtoolsHostClient) => void;
}
export { ClientFunctions, HookInfo, LoadingTimeMetric, PluginMetric, ServerFunctions };
export type { CodeHighlightOptions, DevToolsFrameState, NuxtDevtoolsClient, NuxtDevtoolsClientHooks, NuxtDevtoolsGlobal, NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient, TimelineEvent, TimelineEventFunction, TimelineEventNormalized, TimelineEventRoute, TimelineEventsSegment, TimelineMetrics, TimelineOptions, TimelineServerState };

View file

@ -0,0 +1,181 @@
import { H as HookInfo, P as PluginMetric, L as LoadingTimeMetric, a as ServerFunctions, C as ClientFunctions } from './shared/devtools-kit.r2McQC71.mjs';
export { A as AnalyzeBuildMeta, b as AnalyzeBuildsInfo, W as AssetEntry, U as AssetInfo, Q as AssetType, q as AutoImportsWithMetadata, B as BasicModuleInfo, l as CategorizedTabs, a6 as ClientUpdateEvent, _ as CodeServerOptions, $ as CodeServerType, X as CodeSnippet, F as CompatibilityStatus, Y as ComponentRelationship, Z as ComponentWithRelationships, ag as GetWizardArgs, K as GitHubContributor, I as ImageMeta, a8 as InstallModuleReturn, y as InstalledModuleInfo, J as MaintainerInfo, j as ModuleBuiltinTab, D as ModuleCompatibility, M as ModuleCustomTab, a1 as ModuleGlobalOptions, i as ModuleIframeTabLazyOptions, e as ModuleIframeView, g as ModuleLaunchAction, d as ModuleLaunchView, a0 as ModuleOptions, z as ModuleStaticInfo, E as ModuleStats, k as ModuleTabInfo, G as ModuleType, f as ModuleVNodeView, h as ModuleView, p as NpmCommandOptions, o as NpmCommandType, a4 as NuxtDevToolsOptions, N as NuxtDevtoolsInfo, a7 as NuxtDevtoolsServerContext, a5 as NuxtServerData, n as PackageManagerName, m as PackageUpdateInfo, u as Payload, x as PluginInfoWithMetic, R as RouteInfo, w as ScannedNitroTasks, aa as ServerDebugContext, a9 as ServerDebugModuleMutationRecord, r as ServerRouteInfo, t as ServerRouteInput, s as ServerRouteInputType, v as ServerTaskInfo, S as SubprocessOptions, c as TabCategory, ac as TerminalAction, ab as TerminalBase, ad as TerminalInfo, T as TerminalState, a2 as VSCodeIntegrationOptions, a3 as VSCodeTunnelOptions, V as VueInspectorClient, O as VueInspectorData, af as WizardActions, ae as WizardFunctions } from './shared/devtools-kit.r2McQC71.mjs';
import { BirpcReturn } from 'birpc';
import { Hookable } from 'hookable';
import { NuxtApp } from 'nuxt/app';
import { AppConfig } from 'nuxt/schema';
import { $Fetch } from 'ofetch';
import { BuiltinLanguage } from 'shiki';
import { Ref } from 'vue';
import { StackFrame } from 'error-stack-parser-es';
import 'unimport';
import 'vue-router';
import 'nitropack';
import 'unstorage';
import 'vite';
import '@nuxt/schema';
import 'execa';
interface TimelineEventFunction {
type: 'function';
start: number;
end?: number;
name: string;
args?: any[];
result?: any;
stacktrace?: StackFrame[];
isPromise?: boolean;
}
interface TimelineServerState {
timeSsrStart?: number;
}
interface TimelineEventRoute {
type: 'route';
start: number;
end?: number;
from: string;
to: string;
}
interface TimelineOptions {
enabled: boolean;
stacktrace: boolean;
arguments: boolean;
}
type TimelineEvent = TimelineEventFunction | TimelineEventRoute;
interface TimelineMetrics {
events: TimelineEvent[];
nonLiteralSymbol: symbol;
options: TimelineOptions;
}
interface TimelineEventNormalized<T> {
event: T;
segment: TimelineEventsSegment;
relativeStart: number;
relativeWidth: number;
layer: number;
}
interface TimelineEventsSegment {
start: number;
end: number;
events: TimelineEvent[];
functions: TimelineEventNormalized<TimelineEventFunction>[];
route?: TimelineEventNormalized<TimelineEventRoute>;
duration: number;
previousGap?: number;
}
interface DevToolsFrameState {
width: number;
height: number;
top: number;
left: number;
open: boolean;
route: string;
position: 'left' | 'right' | 'bottom' | 'top';
closeOnOutsideClick: boolean;
minimizePanelInactive: number;
}
interface NuxtDevtoolsClientHooks {
/**
* When the DevTools navigates, used for persisting the current tab
*/
'devtools:navigate': (path: string) => void;
/**
* Event emitted when the component inspector is clicked
*/
'host:inspector:click': (path: string) => void;
/**
* Event to close the component inspector
*/
'host:inspector:close': () => void;
/**
* Triggers reactivity manually, since Vue won't be reactive across frames)
*/
'host:update:reactivity': () => void;
/**
* Host action to control the DevTools navigation
*/
'host:action:navigate': (path: string) => void;
/**
* Host action to reload the DevTools
*/
'host:action:reload': () => void;
}
/**
* Host client from the App
*/
interface NuxtDevtoolsHostClient {
nuxt: NuxtApp;
hooks: Hookable<NuxtDevtoolsClientHooks>;
getIframe: () => HTMLIFrameElement | undefined;
inspector?: {
enable: () => void;
disable: () => void;
toggle: () => void;
isEnabled: Ref<boolean>;
isAvailable: Ref<boolean>;
};
devtools: {
close: () => void;
open: () => void;
toggle: () => void;
reload: () => void;
navigate: (path: string) => void;
/**
* Popup the DevTools frame into Picture-in-Picture mode
*
* Requires Chrome 111 with experimental flag enabled.
*
* Function is undefined when not supported.
*
* @see https://developer.chrome.com/docs/web-platform/document-picture-in-picture/
*/
popup?: () => any;
};
app: {
reload: () => void;
navigate: (path: string, hard?: boolean) => void;
appConfig: AppConfig;
colorMode: Ref<'dark' | 'light'>;
frameState: Ref<DevToolsFrameState>;
$fetch: $Fetch;
};
metrics: {
clientHooks: () => HookInfo[];
clientPlugins: () => PluginMetric[] | undefined;
clientTimeline: () => TimelineMetrics | undefined;
loading: () => LoadingTimeMetric;
};
/**
* A counter to trigger reactivity updates
*/
revision: Ref<number>;
/**
* Update client
* @internal
*/
syncClient: () => NuxtDevtoolsHostClient;
}
interface CodeHighlightOptions {
grammarContextCode?: string;
}
interface NuxtDevtoolsClient {
rpc: BirpcReturn<ServerFunctions, ClientFunctions>;
renderCodeHighlight: (code: string, lang?: BuiltinLanguage, options?: CodeHighlightOptions) => {
code: string;
supported: boolean;
};
renderMarkdown: (markdown: string) => string;
colorMode: string;
extendClientRpc: <ServerFunctions = Record<string, never>, ClientFunctions = Record<string, never>>(name: string, functions: ClientFunctions) => BirpcReturn<ServerFunctions, ClientFunctions>;
}
interface NuxtDevtoolsIframeClient {
host: NuxtDevtoolsHostClient;
devtools: NuxtDevtoolsClient;
}
interface NuxtDevtoolsGlobal {
setClient: (client: NuxtDevtoolsHostClient) => void;
}
export { ClientFunctions, HookInfo, LoadingTimeMetric, PluginMetric, ServerFunctions };
export type { CodeHighlightOptions, DevToolsFrameState, NuxtDevtoolsClient, NuxtDevtoolsClientHooks, NuxtDevtoolsGlobal, NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient, TimelineEvent, TimelineEventFunction, TimelineEventNormalized, TimelineEventRoute, TimelineEventsSegment, TimelineMetrics, TimelineOptions, TimelineServerState };

View file

@ -0,0 +1,181 @@
import { H as HookInfo, P as PluginMetric, L as LoadingTimeMetric, a as ServerFunctions, C as ClientFunctions } from './shared/devtools-kit.r2McQC71.js';
export { A as AnalyzeBuildMeta, b as AnalyzeBuildsInfo, W as AssetEntry, U as AssetInfo, Q as AssetType, q as AutoImportsWithMetadata, B as BasicModuleInfo, l as CategorizedTabs, a6 as ClientUpdateEvent, _ as CodeServerOptions, $ as CodeServerType, X as CodeSnippet, F as CompatibilityStatus, Y as ComponentRelationship, Z as ComponentWithRelationships, ag as GetWizardArgs, K as GitHubContributor, I as ImageMeta, a8 as InstallModuleReturn, y as InstalledModuleInfo, J as MaintainerInfo, j as ModuleBuiltinTab, D as ModuleCompatibility, M as ModuleCustomTab, a1 as ModuleGlobalOptions, i as ModuleIframeTabLazyOptions, e as ModuleIframeView, g as ModuleLaunchAction, d as ModuleLaunchView, a0 as ModuleOptions, z as ModuleStaticInfo, E as ModuleStats, k as ModuleTabInfo, G as ModuleType, f as ModuleVNodeView, h as ModuleView, p as NpmCommandOptions, o as NpmCommandType, a4 as NuxtDevToolsOptions, N as NuxtDevtoolsInfo, a7 as NuxtDevtoolsServerContext, a5 as NuxtServerData, n as PackageManagerName, m as PackageUpdateInfo, u as Payload, x as PluginInfoWithMetic, R as RouteInfo, w as ScannedNitroTasks, aa as ServerDebugContext, a9 as ServerDebugModuleMutationRecord, r as ServerRouteInfo, t as ServerRouteInput, s as ServerRouteInputType, v as ServerTaskInfo, S as SubprocessOptions, c as TabCategory, ac as TerminalAction, ab as TerminalBase, ad as TerminalInfo, T as TerminalState, a2 as VSCodeIntegrationOptions, a3 as VSCodeTunnelOptions, V as VueInspectorClient, O as VueInspectorData, af as WizardActions, ae as WizardFunctions } from './shared/devtools-kit.r2McQC71.js';
import { BirpcReturn } from 'birpc';
import { Hookable } from 'hookable';
import { NuxtApp } from 'nuxt/app';
import { AppConfig } from 'nuxt/schema';
import { $Fetch } from 'ofetch';
import { BuiltinLanguage } from 'shiki';
import { Ref } from 'vue';
import { StackFrame } from 'error-stack-parser-es';
import 'unimport';
import 'vue-router';
import 'nitropack';
import 'unstorage';
import 'vite';
import '@nuxt/schema';
import 'execa';
interface TimelineEventFunction {
type: 'function';
start: number;
end?: number;
name: string;
args?: any[];
result?: any;
stacktrace?: StackFrame[];
isPromise?: boolean;
}
interface TimelineServerState {
timeSsrStart?: number;
}
interface TimelineEventRoute {
type: 'route';
start: number;
end?: number;
from: string;
to: string;
}
interface TimelineOptions {
enabled: boolean;
stacktrace: boolean;
arguments: boolean;
}
type TimelineEvent = TimelineEventFunction | TimelineEventRoute;
interface TimelineMetrics {
events: TimelineEvent[];
nonLiteralSymbol: symbol;
options: TimelineOptions;
}
interface TimelineEventNormalized<T> {
event: T;
segment: TimelineEventsSegment;
relativeStart: number;
relativeWidth: number;
layer: number;
}
interface TimelineEventsSegment {
start: number;
end: number;
events: TimelineEvent[];
functions: TimelineEventNormalized<TimelineEventFunction>[];
route?: TimelineEventNormalized<TimelineEventRoute>;
duration: number;
previousGap?: number;
}
interface DevToolsFrameState {
width: number;
height: number;
top: number;
left: number;
open: boolean;
route: string;
position: 'left' | 'right' | 'bottom' | 'top';
closeOnOutsideClick: boolean;
minimizePanelInactive: number;
}
interface NuxtDevtoolsClientHooks {
/**
* When the DevTools navigates, used for persisting the current tab
*/
'devtools:navigate': (path: string) => void;
/**
* Event emitted when the component inspector is clicked
*/
'host:inspector:click': (path: string) => void;
/**
* Event to close the component inspector
*/
'host:inspector:close': () => void;
/**
* Triggers reactivity manually, since Vue won't be reactive across frames)
*/
'host:update:reactivity': () => void;
/**
* Host action to control the DevTools navigation
*/
'host:action:navigate': (path: string) => void;
/**
* Host action to reload the DevTools
*/
'host:action:reload': () => void;
}
/**
* Host client from the App
*/
interface NuxtDevtoolsHostClient {
nuxt: NuxtApp;
hooks: Hookable<NuxtDevtoolsClientHooks>;
getIframe: () => HTMLIFrameElement | undefined;
inspector?: {
enable: () => void;
disable: () => void;
toggle: () => void;
isEnabled: Ref<boolean>;
isAvailable: Ref<boolean>;
};
devtools: {
close: () => void;
open: () => void;
toggle: () => void;
reload: () => void;
navigate: (path: string) => void;
/**
* Popup the DevTools frame into Picture-in-Picture mode
*
* Requires Chrome 111 with experimental flag enabled.
*
* Function is undefined when not supported.
*
* @see https://developer.chrome.com/docs/web-platform/document-picture-in-picture/
*/
popup?: () => any;
};
app: {
reload: () => void;
navigate: (path: string, hard?: boolean) => void;
appConfig: AppConfig;
colorMode: Ref<'dark' | 'light'>;
frameState: Ref<DevToolsFrameState>;
$fetch: $Fetch;
};
metrics: {
clientHooks: () => HookInfo[];
clientPlugins: () => PluginMetric[] | undefined;
clientTimeline: () => TimelineMetrics | undefined;
loading: () => LoadingTimeMetric;
};
/**
* A counter to trigger reactivity updates
*/
revision: Ref<number>;
/**
* Update client
* @internal
*/
syncClient: () => NuxtDevtoolsHostClient;
}
interface CodeHighlightOptions {
grammarContextCode?: string;
}
interface NuxtDevtoolsClient {
rpc: BirpcReturn<ServerFunctions, ClientFunctions>;
renderCodeHighlight: (code: string, lang?: BuiltinLanguage, options?: CodeHighlightOptions) => {
code: string;
supported: boolean;
};
renderMarkdown: (markdown: string) => string;
colorMode: string;
extendClientRpc: <ServerFunctions = Record<string, never>, ClientFunctions = Record<string, never>>(name: string, functions: ClientFunctions) => BirpcReturn<ServerFunctions, ClientFunctions>;
}
interface NuxtDevtoolsIframeClient {
host: NuxtDevtoolsHostClient;
devtools: NuxtDevtoolsClient;
}
interface NuxtDevtoolsGlobal {
setClient: (client: NuxtDevtoolsHostClient) => void;
}
export { ClientFunctions, HookInfo, LoadingTimeMetric, PluginMetric, ServerFunctions };
export type { CodeHighlightOptions, DevToolsFrameState, NuxtDevtoolsClient, NuxtDevtoolsClientHooks, NuxtDevtoolsGlobal, NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient, TimelineEvent, TimelineEventFunction, TimelineEventNormalized, TimelineEventRoute, TimelineEventsSegment, TimelineMetrics, TimelineOptions, TimelineServerState };

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@
export * from './dist/runtime/host-client'

View file

@ -0,0 +1 @@
export * from './dist/runtime/host-client.mjs'

View file

@ -0,0 +1 @@
export * from './dist/runtime/iframe-client'

View file

@ -0,0 +1 @@
export * from './dist/runtime/iframe-client.mjs'

View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016-present - Nuxt Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,117 @@
[![Nuxt banner](https://github.com/nuxt/nuxt/blob/main/.github/assets/banner.svg)](https://nuxt.com)
# Nuxt
<p>
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
<a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
<a href="https://github.com/nuxt/nuxt/blob/main/LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
<a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt" alt="Website"></a>
<a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
<a href="https://securityscorecards.dev/"><img src="https://api.securityscorecards.dev/projects/github.com/nuxt/nuxt/badge" alt="Nuxt openssf scorecard score"></a>
</p>
Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
It provides a number of features that make it easy to build fast, SEO-friendly, and scalable web applications, including:
- Server-side rendering, static site generation, hybrid rendering and edge-side rendering
- Automatic routing with code-splitting and pre-fetching
- Data fetching and state management
- Search engine optimization and defining meta tags
- Auto imports of components, composables and utils
- TypeScript with zero configuration
- Go full-stack with our server/ directory
- Extensible with [200+ modules](https://nuxt.com/modules)
- Deployment to a variety of [hosting platforms](https://nuxt.com/deploy)
- ...[and much more](https://nuxt.com) 🚀
### Table of Contents
- 🚀 [Getting Started](#getting-started)
- 💻 [ Vue Development](#vue-development)
- 📖 [Documentation](#documentation)
- 🧩 [Modules](#modules)
- ❤️ [Contribute](#contribute)
- 🏠 [Local Development](#local-development)
- 🛟 [Professional Support](#professional-support)
- 🔗 [Follow Us](#follow-us)
- ⚖️ [License](#license)
---
## <a name="getting-started">🚀 Getting Started</a>
Use the following command to create a new starter project. This will create a starter project with all the necessary files and dependencies:
```bash
npm create nuxt@latest <my-project>
```
> [!TIP]
> Discover also [nuxt.new](https://nuxt.new): Open a Nuxt starter on CodeSandbox, StackBlitz or locally to get up and running in a few seconds.
## <a name="vue-development">💻 Vue Development</a>
Simple, intuitive and powerful, Nuxt lets you write Vue components in a way that makes sense. Every repetitive task is automated, so you can focus on writing your full-stack Vue application with confidence.
Example of an `app.vue`:
```vue
<script setup lang="ts">
useSeoMeta({
title: 'Meet Nuxt',
description: 'The Intuitive Vue Framework.',
})
</script>
<template>
<div id="app">
<AppHeader />
<NuxtPage />
<AppFooter />
</div>
</template>
<style scoped>
#app {
background-color: #020420;
color: #00DC82;
}
</style>
```
## <a name="documentation">📖 Documentation</a>
We highly recommend you take a look at the [Nuxt documentation](https://nuxt.com/docs) to level up. Its a great resource for learning more about the framework. It covers everything from getting started to advanced topics.
## <a name="modules">🧩 Modules</a>
Discover our [list of modules](https://nuxt.com/modules) to supercharge your Nuxt project, created by the Nuxt team and community.
## <a name="contribute">❤️ Contribute</a>
We invite you to contribute and help improve Nuxt 💚
Here are a few ways you can get involved:
- **Reporting Bugs:** If you come across any bugs or issues, please check out the [reporting bugs guide](https://nuxt.com/docs/4.x/community/reporting-bugs) to learn how to submit a bug report.
- **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/4.x/community/contribution) to share your suggestions.
- **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/4.x/community/getting-help) provides resources to help you out.
## <a name="local-development">🏠 Local Development</a>
Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/4.x/community/framework-contribution#setup) to contribute to the framework and documentation.
## <a name="professional-support">🛟 Professional Support</a>
- Technical audit & consulting: [Nuxt Experts](https://nuxt.com/enterprise/support)
- Custom development & more: [Nuxt Agencies Partners](https://nuxt.com/enterprise/agencies)
## <a name="follow-us">🔗 Follow Us</a>
<p valign="center">
<a href="https://go.nuxt.com/discord"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/discord.svg" alt="Discord"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/x"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/twitter.svg" alt="Twitter"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/github"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/github.svg" alt="GitHub"></a>&nbsp;&nbsp;<a href="https://go.nuxt.com/bluesky"><img width="20px" src="https://github.com/nuxt/nuxt/blob/main/.github/assets/bluesky.svg" alt="Bluesky"></a>
</p>
## <a name="license">⚖️ License</a>
[MIT](https://github.com/nuxt/nuxt/blob/main/LICENSE)

View file

@ -0,0 +1,552 @@
import * as _nuxt_schema from '@nuxt/schema';
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
import { LoadConfigOptions } from 'c12';
import { Import, InlinePreset } from 'unimport';
import { WebpackPluginInstance, Configuration } from 'webpack';
import { RspackPluginInstance } from '@rspack/core';
import { Plugin, UserConfig } from 'vite';
import * as unctx from 'unctx';
import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack/types';
import { GlobOptions } from 'tinyglobby';
import * as consola from 'consola';
import { ConsolaOptions } from 'consola';
/**
* Define a Nuxt module, automatically merging defaults with user provided options, installing
* any hooks that are provided, and calling an optional setup function for full control.
*/
declare function defineNuxtModule<TOptions extends ModuleOptions>(definition: ModuleDefinition<TOptions, Partial<TOptions>, false> | NuxtModule<TOptions, Partial<TOptions>, false>): NuxtModule<TOptions, TOptions, false>;
declare function defineNuxtModule<TOptions extends ModuleOptions>(): {
with: <TOptionsDefaults extends Partial<TOptions>>(definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>) => NuxtModule<TOptions, TOptionsDefaults, true>;
};
type ModuleToInstall = string | NuxtModule<ModuleOptions, Partial<ModuleOptions>, false>;
/**
* Installs a set of modules on a Nuxt instance.
* @internal
*/
declare function installModules(modulesToInstall: Map<ModuleToInstall, Record<string, any>>, resolvedModulePaths: Set<string>, nuxt?: Nuxt): Promise<void>;
/**
* Installs a module on a Nuxt instance.
* @deprecated Use module dependencies.
*/
declare function installModule<T extends string | NuxtModule, Config extends Extract<NonNullable<NuxtConfig['modules']>[number], [T, any]>>(moduleToInstall: T, inlineOptions?: [Config] extends [never] ? any : Config[1], nuxt?: Nuxt): Promise<void>;
declare function resolveModuleWithOptions(definition: NuxtModule<any> | string | false | undefined | null | [(NuxtModule | string)?, Record<string, any>?], nuxt: Nuxt): {
resolvedPath?: string;
module: string | NuxtModule<any>;
options: Record<string, any>;
} | undefined;
declare function loadNuxtModuleInstance(nuxtModule: string | NuxtModule, nuxt?: Nuxt): Promise<{
nuxtModule: NuxtModule<any>;
buildTimeModuleMeta: ModuleMeta;
resolvedModulePath?: string;
}>;
declare function getDirectory(p: string): string;
declare const normalizeModuleTranspilePath: (p: string) => string;
/**
* Check if a Nuxt module is installed by name.
*
* This will check both the installed modules and the modules to be installed. Note
* that it cannot detect if a module is _going to be_ installed programmatically by another module.
*/
declare function hasNuxtModule(moduleName: string, nuxt?: Nuxt): boolean;
/**
* Checks if a Nuxt Module is compatible with a given semver version.
*/
declare function hasNuxtModuleCompatibility(module: string | NuxtModule, semverVersion: string, nuxt?: Nuxt): Promise<boolean>;
/**
* Get the version of a Nuxt module.
*
* Scans installed modules for the version, if it's not found it will attempt to load the module instance and get the version from there.
*/
declare function getNuxtModuleVersion(module: string | NuxtModule, nuxt?: Nuxt | any): Promise<string | false>;
interface LoadNuxtConfigOptions extends Omit<LoadConfigOptions<NuxtConfig>, 'overrides'> {
overrides?: Exclude<LoadConfigOptions<NuxtConfig>['overrides'], Promise<any> | Function>;
}
declare function loadNuxtConfig(opts: LoadNuxtConfigOptions): Promise<NuxtOptions>;
declare function extendNuxtSchema(def: SchemaDefinition | (() => SchemaDefinition)): void;
interface LoadNuxtOptions extends LoadNuxtConfigOptions {
/** Load nuxt with development mode */
dev?: boolean;
/** Use lazy initialization of nuxt if set to false */
ready?: boolean;
}
declare function loadNuxt(opts: LoadNuxtOptions): Promise<Nuxt>;
declare function buildNuxt(nuxt: Nuxt): Promise<any>;
interface LayerDirectories {
/** Nuxt rootDir (`/` by default) */
readonly root: string;
/** Nitro source directory (`/server` by default) */
readonly server: string;
/** Local modules directory (`/modules` by default) */
readonly modules: string;
/** Shared directory (`/shared` by default) */
readonly shared: string;
/** Public directory (`/public` by default) */
readonly public: string;
/** Nuxt srcDir (`/app/` by default) */
readonly app: string;
/** Layouts directory (`/app/layouts` by default) */
readonly appLayouts: string;
/** Middleware directory (`/app/middleware` by default) */
readonly appMiddleware: string;
/** Pages directory (`/app/pages` by default) */
readonly appPages: string;
/** Plugins directory (`/app/plugins` by default) */
readonly appPlugins: string;
}
/**
* Get the resolved directory paths for all layers in a Nuxt application.
*
* Returns an array of LayerDirectories objects, ordered by layer priority:
* - The first layer is the user/project layer (highest priority)
* - Earlier layers override later layers in the array
* - Base layers appear last in the array (lowest priority)
*
* @param nuxt - The Nuxt instance to get layers from. Defaults to the current Nuxt context.
* @returns Array of LayerDirectories objects, ordered by priority (user layer first)
*/
declare function getLayerDirectories(nuxt?: _nuxt_schema.Nuxt): LayerDirectories[];
declare function setGlobalHead(head: NuxtAppConfig['head']): void;
declare function addImports(imports: Import | Import[]): void;
declare function addImportsDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
declare function addImportsSources(presets: InlinePreset | InlinePreset[]): void;
/**
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
*
* This mirrors the runtime behavior of Nitro.
*/
declare function useRuntimeConfig(): Record<string, any>;
/**
* Update Nuxt runtime configuration.
*/
declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
interface ExtendConfigOptions {
/**
* Install plugin on dev
* @default true
*/
dev?: boolean;
/**
* Install plugin on build
* @default true
*/
build?: boolean;
/**
* Install plugin on server side
* @default true
*/
server?: boolean;
/**
* Install plugin on client side
* @default true
*/
client?: boolean;
/**
* Prepends the plugin to the array with `unshift()` instead of `push()`.
*/
prepend?: boolean;
}
interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
}
interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | 'client'> {
/**
* Extend server Vite configuration
* @default true
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
* You can likely use a Vite plugin to achieve the same result.
*/
server?: boolean;
/**
* Extend client Vite configuration
* @default true
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
* You can likely use a Vite plugin to achieve the same result.
*/
client?: boolean;
}
/**
* Extend webpack config
*
* The fallback function might be called multiple times
* when applying to both client and server builds.
*/
declare const extendWebpackConfig: (fn: ((config: Configuration) => void), options?: ExtendWebpackConfigOptions) => void;
/**
* Extend rspack config
*
* The fallback function might be called multiple times
* when applying to both client and server builds.
*/
declare const extendRspackConfig: (fn: ((config: Configuration) => void), options?: ExtendWebpackConfigOptions) => void;
/**
* Extend Vite config
*/
declare function extendViteConfig(fn: ((config: UserConfig) => void), options?: ExtendViteConfigOptions): (() => void) | undefined;
/**
* Append webpack plugin to the config.
*/
declare function addWebpackPlugin(pluginOrGetter: WebpackPluginInstance | WebpackPluginInstance[] | (() => WebpackPluginInstance | WebpackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
/**
* Append rspack plugin to the config.
*/
declare function addRspackPlugin(pluginOrGetter: RspackPluginInstance | RspackPluginInstance[] | (() => RspackPluginInstance | RspackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
/**
* Append Vite plugin to the config.
*/
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendConfigOptions): void;
interface AddBuildPluginFactory {
vite?: () => Plugin | Plugin[];
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
rspack?: () => RspackPluginInstance | RspackPluginInstance[];
}
declare function addBuildPlugin(pluginFactory: AddBuildPluginFactory, options?: ExtendConfigOptions): void;
declare function normalizeSemanticVersion(version: string): string;
/**
* Check version constraints and return incompatibility issues as an array
*/
declare function checkNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<NuxtCompatibilityIssues>;
/**
* Check version constraints and throw a detailed error if has any, otherwise returns true
*/
declare function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<true>;
/**
* Check version constraints and return true if passed, otherwise returns false
*/
declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>;
/**
* Check if current Nuxt instance is of specified major version
*/
declare function isNuxtMajorVersion(majorVersion: 2 | 3 | 4, nuxt?: Nuxt): boolean;
/**
* @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
*/
declare function isNuxt2(nuxt?: Nuxt): boolean;
/**
* @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
*/
declare function isNuxt3(nuxt?: Nuxt): boolean;
/**
* Get nuxt version
*/
declare function getNuxtVersion(nuxt?: Nuxt | any): string;
/**
* Register a directory to be scanned for components and imported only when used.
*/
declare function addComponentsDir(dir: ComponentsDir, opts?: {
prepend?: boolean;
}): void;
type AddComponentOptions = {
name: string;
filePath: string;
} & Partial<Exclude<Component, 'shortPath' | 'async' | 'level' | 'import' | 'asyncImport'>>;
/**
* This utility takes a file path or npm package that is scanned for named exports, which are get added automatically
*/
declare function addComponentExports(opts: Omit<AddComponentOptions, 'name'> & {
prefix?: string;
}): void;
/**
* Register a component by its name and filePath.
*/
declare function addComponent(opts: AddComponentOptions): void;
/**
* Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
* @deprecated Use `getNuxtCtx` instead
*/
declare const nuxtCtx: unctx.UseContext<Nuxt>;
/** Direct access to the Nuxt context with asyncLocalStorage - see https://github.com/unjs/unctx. */
declare const getNuxtCtx: () => Nuxt | null;
/**
* Get access to Nuxt instance.
*
* Throws an error if Nuxt instance is unavailable.
* @example
* ```js
* const nuxt = useNuxt()
* ```
*/
declare function useNuxt(): Nuxt;
/**
* Get access to Nuxt instance.
*
* Returns null if Nuxt instance is unavailable.
* @example
* ```js
* const nuxt = tryUseNuxt()
* if (nuxt) {
* // Do something
* }
* ```
*/
declare function tryUseNuxt(): Nuxt | null;
declare function runWithNuxtContext<T extends (...args: any[]) => any>(nuxt: Nuxt, fn: T): ReturnType<T>;
declare function createIsIgnored(nuxt?: _nuxt_schema.Nuxt | null): (pathname: string, stats?: unknown) => boolean;
/**
* Return a filter function to filter an array of paths
*/
declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: _nuxt_schema.Nuxt | null): boolean;
declare function resolveIgnorePatterns(relativePath?: string): string[];
declare function addLayout(template: NuxtTemplate | string, name?: string): void;
declare function extendPages(cb: NuxtHooks['pages:extend']): void;
interface ExtendRouteRulesOptions {
/**
* Override route rule config
* @default false
*/
override?: boolean;
}
declare function extendRouteRules(route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void;
interface AddRouteMiddlewareOptions {
/**
* Override existing middleware with the same name, if it exists
* @default false
*/
override?: boolean;
/**
* Prepend middleware to the list
* @default false
*/
prepend?: boolean;
}
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
/**
* Registers a nuxt plugin and to the plugins array.
*
* Note: You can use mode or .client and .server modifiers with fileName option
* to use plugin only in client or server side.
*
* Note: By default plugin is prepended to the plugins array. You can use second argument to append (push) instead.
* @example
* ```js
* import { createResolver } from '@nuxt/kit'
* const resolver = createResolver(import.meta.url)
*
* addPlugin({
* src: resolver.resolve('templates/foo.js'),
* filename: 'foo.server.js' // [optional] only include in server bundle
* })
* ```
*/
interface AddPluginOptions {
append?: boolean;
}
declare function addPlugin(_plugin: NuxtPlugin | string, opts?: AddPluginOptions): NuxtPlugin;
/**
* Adds a template and registers as a nuxt plugin.
*/
declare function addPluginTemplate(plugin: NuxtPluginTemplate | string, opts?: AddPluginOptions): NuxtPlugin;
interface ResolvePathOptions {
/** Base for resolving paths from. Default is Nuxt rootDir. */
cwd?: string;
/** An object of aliases. Default is Nuxt configured aliases. */
alias?: Record<string, string>;
/**
* The file extensions to try.
* Default is Nuxt configured extensions.
*
* Isn't considered when `type` is set to `'dir'`.
*/
extensions?: string[];
/**
* Whether to resolve files that exist in the Nuxt VFS (for example, as a Nuxt template).
* @default false
*/
virtual?: boolean;
/**
* Whether to fallback to the original path if the resolved path does not exist instead of returning the normalized input path.
* @default false
*/
fallbackToOriginal?: boolean;
/**
* The type of the path to be resolved.
* @default 'file'
*/
type?: PathType;
}
/**
* Resolve the full path to a file or a directory (based on the provided type), respecting Nuxt alias and extensions options.
*
* If a path cannot be resolved, normalized input will be returned unless the `fallbackToOriginal` option is set to `true`,
* in which case the original input path will be returned.
*/
declare function resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
/**
* Try to resolve first existing file in paths
*/
declare function findPath(paths: string | string[], opts?: ResolvePathOptions, pathType?: PathType): Promise<string | null>;
/**
* Resolve path aliases respecting Nuxt alias options
*/
declare function resolveAlias(path: string, alias?: Record<string, string>): string;
interface Resolver {
resolve(...path: string[]): string;
resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
}
/**
* Create a relative resolver
*/
declare function createResolver(base: string | URL): Resolver;
declare function resolveNuxtModule(base: string, paths: string[]): Promise<string[]>;
type PathType = 'file' | 'dir';
/**
* Resolve absolute file paths in the provided directory with respect to `.nuxtignore` and return them sorted.
* @param path path to the directory to resolve files in
* @param pattern glob pattern or an array of glob patterns to match files
* @param opts options for globbing
* @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
* @param opts.ignore additional glob patterns to ignore
* @returns sorted array of absolute file paths
*/
declare function resolveFiles(path: string, pattern: string | string[], opts?: {
followSymbolicLinks?: boolean;
ignore?: GlobOptions['ignore'];
}): Promise<string[]>;
/**
* Adds a nitro server handler
*
*/
declare function addServerHandler(handler: NitroEventHandler): void;
/**
* Adds a nitro server handler for development-only
*
*/
declare function addDevServerHandler(handler: NitroDevEventHandler): void;
/**
* Adds a Nitro plugin
*/
declare function addServerPlugin(plugin: string): void;
/**
* Adds routes to be prerendered
*/
declare function addPrerenderRoutes(routes: string | string[]): void;
/**
* Access to the Nitro instance
*
* **Note:** You can call `useNitro()` only after `ready` hook.
*
* **Note:** Changes to the Nitro instance configuration are not applied.
* @example
*
* ```ts
* nuxt.hook('ready', () => {
* console.log(useNitro())
* })
* ```
*/
declare function useNitro(): Nitro;
/**
* Add server imports to be auto-imported by Nitro
*/
declare function addServerImports(imports: Import | Import[]): void;
/**
* Add directories to be scanned for auto-imports by Nitro
*/
declare function addServerImportsDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
/**
* Add directories to be scanned by Nitro. It will check for subdirectories,
* which will be registered just like the `~/server` folder is.
*/
declare function addServerScanDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
/**
* Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
*/
declare function addTemplate<T>(_template: NuxtTemplate<T> | string): ResolvedNuxtTemplate<T>;
/**
* Adds a virtual file that can be used within the Nuxt Nitro server build.
*/
declare function addServerTemplate(template: NuxtServerTemplate): NuxtServerTemplate;
/**
* Renders given types during build to disk in the project `buildDir`
* and register them as types.
*
* You can pass a second context object to specify in which context the type should be added.
*
* If no context object is passed, then it will only be added to the nuxt context.
*/
declare function addTypeTemplate<T>(_template: NuxtTypeTemplate<T>, context?: {
nitro?: boolean;
nuxt?: boolean;
node?: boolean;
shared?: boolean;
}): ResolvedNuxtTemplate<T>;
/**
* Normalize a nuxt template object
*/
declare function normalizeTemplate<T>(template: NuxtTemplate<T> | string, buildDir?: string): ResolvedNuxtTemplate<T>;
/**
* Trigger rebuilding Nuxt templates
*
* You can pass a filter within the options to selectively regenerate a subset of templates.
*/
declare function updateTemplates(options?: {
filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
}): Promise<any>;
declare function writeTypes(nuxt: Nuxt): Promise<void>;
declare const logger: consola.ConsolaInstance;
declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): consola.ConsolaInstance;
interface ResolveModuleOptions {
/** @deprecated use `url` with URLs pointing at a file - never a directory */
paths?: string | string[];
url?: URL | URL[];
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
extensions?: string[];
}
declare function directoryToURL(dir: string): URL;
/**
* Resolve a module from a given root path using an algorithm patterned on
* the upcoming `import.meta.resolve`. It returns a file URL
*
* @internal
*/
declare function tryResolveModule(id: string, url: URL | URL[]): Promise<string | undefined>;
/** @deprecated pass URLs pointing at files */
declare function tryResolveModule(id: string, url: string | string[]): Promise<string | undefined>;
declare function resolveModule(id: string, options?: ResolveModuleOptions): string;
interface ImportModuleOptions extends ResolveModuleOptions {
/** Automatically de-default the result of requiring the module. */
interopDefault?: boolean;
}
declare function importModule<T = unknown>(id: string, opts?: ImportModuleOptions): Promise<T>;
declare function tryImportModule<T = unknown>(id: string, opts?: ImportModuleOptions): Promise<T | undefined> | undefined;
/**
* @deprecated Please use `importModule` instead.
*/
declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T;
/**
* @deprecated Please use `tryImportModule` instead.
*/
declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };

View file

@ -0,0 +1,552 @@
import * as _nuxt_schema from '@nuxt/schema';
import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
import { LoadConfigOptions } from 'c12';
import { Import, InlinePreset } from 'unimport';
import { WebpackPluginInstance, Configuration } from 'webpack';
import { RspackPluginInstance } from '@rspack/core';
import { Plugin, UserConfig } from 'vite';
import * as unctx from 'unctx';
import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack/types';
import { GlobOptions } from 'tinyglobby';
import * as consola from 'consola';
import { ConsolaOptions } from 'consola';
/**
* Define a Nuxt module, automatically merging defaults with user provided options, installing
* any hooks that are provided, and calling an optional setup function for full control.
*/
declare function defineNuxtModule<TOptions extends ModuleOptions>(definition: ModuleDefinition<TOptions, Partial<TOptions>, false> | NuxtModule<TOptions, Partial<TOptions>, false>): NuxtModule<TOptions, TOptions, false>;
declare function defineNuxtModule<TOptions extends ModuleOptions>(): {
with: <TOptionsDefaults extends Partial<TOptions>>(definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>) => NuxtModule<TOptions, TOptionsDefaults, true>;
};
type ModuleToInstall = string | NuxtModule<ModuleOptions, Partial<ModuleOptions>, false>;
/**
* Installs a set of modules on a Nuxt instance.
* @internal
*/
declare function installModules(modulesToInstall: Map<ModuleToInstall, Record<string, any>>, resolvedModulePaths: Set<string>, nuxt?: Nuxt): Promise<void>;
/**
* Installs a module on a Nuxt instance.
* @deprecated Use module dependencies.
*/
declare function installModule<T extends string | NuxtModule, Config extends Extract<NonNullable<NuxtConfig['modules']>[number], [T, any]>>(moduleToInstall: T, inlineOptions?: [Config] extends [never] ? any : Config[1], nuxt?: Nuxt): Promise<void>;
declare function resolveModuleWithOptions(definition: NuxtModule<any> | string | false | undefined | null | [(NuxtModule | string)?, Record<string, any>?], nuxt: Nuxt): {
resolvedPath?: string;
module: string | NuxtModule<any>;
options: Record<string, any>;
} | undefined;
declare function loadNuxtModuleInstance(nuxtModule: string | NuxtModule, nuxt?: Nuxt): Promise<{
nuxtModule: NuxtModule<any>;
buildTimeModuleMeta: ModuleMeta;
resolvedModulePath?: string;
}>;
declare function getDirectory(p: string): string;
declare const normalizeModuleTranspilePath: (p: string) => string;
/**
* Check if a Nuxt module is installed by name.
*
* This will check both the installed modules and the modules to be installed. Note
* that it cannot detect if a module is _going to be_ installed programmatically by another module.
*/
declare function hasNuxtModule(moduleName: string, nuxt?: Nuxt): boolean;
/**
* Checks if a Nuxt Module is compatible with a given semver version.
*/
declare function hasNuxtModuleCompatibility(module: string | NuxtModule, semverVersion: string, nuxt?: Nuxt): Promise<boolean>;
/**
* Get the version of a Nuxt module.
*
* Scans installed modules for the version, if it's not found it will attempt to load the module instance and get the version from there.
*/
declare function getNuxtModuleVersion(module: string | NuxtModule, nuxt?: Nuxt | any): Promise<string | false>;
interface LoadNuxtConfigOptions extends Omit<LoadConfigOptions<NuxtConfig>, 'overrides'> {
overrides?: Exclude<LoadConfigOptions<NuxtConfig>['overrides'], Promise<any> | Function>;
}
declare function loadNuxtConfig(opts: LoadNuxtConfigOptions): Promise<NuxtOptions>;
declare function extendNuxtSchema(def: SchemaDefinition | (() => SchemaDefinition)): void;
interface LoadNuxtOptions extends LoadNuxtConfigOptions {
/** Load nuxt with development mode */
dev?: boolean;
/** Use lazy initialization of nuxt if set to false */
ready?: boolean;
}
declare function loadNuxt(opts: LoadNuxtOptions): Promise<Nuxt>;
declare function buildNuxt(nuxt: Nuxt): Promise<any>;
interface LayerDirectories {
/** Nuxt rootDir (`/` by default) */
readonly root: string;
/** Nitro source directory (`/server` by default) */
readonly server: string;
/** Local modules directory (`/modules` by default) */
readonly modules: string;
/** Shared directory (`/shared` by default) */
readonly shared: string;
/** Public directory (`/public` by default) */
readonly public: string;
/** Nuxt srcDir (`/app/` by default) */
readonly app: string;
/** Layouts directory (`/app/layouts` by default) */
readonly appLayouts: string;
/** Middleware directory (`/app/middleware` by default) */
readonly appMiddleware: string;
/** Pages directory (`/app/pages` by default) */
readonly appPages: string;
/** Plugins directory (`/app/plugins` by default) */
readonly appPlugins: string;
}
/**
* Get the resolved directory paths for all layers in a Nuxt application.
*
* Returns an array of LayerDirectories objects, ordered by layer priority:
* - The first layer is the user/project layer (highest priority)
* - Earlier layers override later layers in the array
* - Base layers appear last in the array (lowest priority)
*
* @param nuxt - The Nuxt instance to get layers from. Defaults to the current Nuxt context.
* @returns Array of LayerDirectories objects, ordered by priority (user layer first)
*/
declare function getLayerDirectories(nuxt?: _nuxt_schema.Nuxt): LayerDirectories[];
declare function setGlobalHead(head: NuxtAppConfig['head']): void;
declare function addImports(imports: Import | Import[]): void;
declare function addImportsDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
declare function addImportsSources(presets: InlinePreset | InlinePreset[]): void;
/**
* Access 'resolved' Nuxt runtime configuration, with values updated from environment.
*
* This mirrors the runtime behavior of Nitro.
*/
declare function useRuntimeConfig(): Record<string, any>;
/**
* Update Nuxt runtime configuration.
*/
declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
interface ExtendConfigOptions {
/**
* Install plugin on dev
* @default true
*/
dev?: boolean;
/**
* Install plugin on build
* @default true
*/
build?: boolean;
/**
* Install plugin on server side
* @default true
*/
server?: boolean;
/**
* Install plugin on client side
* @default true
*/
client?: boolean;
/**
* Prepends the plugin to the array with `unshift()` instead of `push()`.
*/
prepend?: boolean;
}
interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
}
interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | 'client'> {
/**
* Extend server Vite configuration
* @default true
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
* You can likely use a Vite plugin to achieve the same result.
*/
server?: boolean;
/**
* Extend client Vite configuration
* @default true
* @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
* Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
* You can likely use a Vite plugin to achieve the same result.
*/
client?: boolean;
}
/**
* Extend webpack config
*
* The fallback function might be called multiple times
* when applying to both client and server builds.
*/
declare const extendWebpackConfig: (fn: ((config: Configuration) => void), options?: ExtendWebpackConfigOptions) => void;
/**
* Extend rspack config
*
* The fallback function might be called multiple times
* when applying to both client and server builds.
*/
declare const extendRspackConfig: (fn: ((config: Configuration) => void), options?: ExtendWebpackConfigOptions) => void;
/**
* Extend Vite config
*/
declare function extendViteConfig(fn: ((config: UserConfig) => void), options?: ExtendViteConfigOptions): (() => void) | undefined;
/**
* Append webpack plugin to the config.
*/
declare function addWebpackPlugin(pluginOrGetter: WebpackPluginInstance | WebpackPluginInstance[] | (() => WebpackPluginInstance | WebpackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
/**
* Append rspack plugin to the config.
*/
declare function addRspackPlugin(pluginOrGetter: RspackPluginInstance | RspackPluginInstance[] | (() => RspackPluginInstance | RspackPluginInstance[]), options?: ExtendWebpackConfigOptions): void;
/**
* Append Vite plugin to the config.
*/
declare function addVitePlugin(pluginOrGetter: Plugin | Plugin[] | (() => Plugin | Plugin[]), options?: ExtendConfigOptions): void;
interface AddBuildPluginFactory {
vite?: () => Plugin | Plugin[];
webpack?: () => WebpackPluginInstance | WebpackPluginInstance[];
rspack?: () => RspackPluginInstance | RspackPluginInstance[];
}
declare function addBuildPlugin(pluginFactory: AddBuildPluginFactory, options?: ExtendConfigOptions): void;
declare function normalizeSemanticVersion(version: string): string;
/**
* Check version constraints and return incompatibility issues as an array
*/
declare function checkNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<NuxtCompatibilityIssues>;
/**
* Check version constraints and throw a detailed error if has any, otherwise returns true
*/
declare function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<true>;
/**
* Check version constraints and return true if passed, otherwise returns false
*/
declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>;
/**
* Check if current Nuxt instance is of specified major version
*/
declare function isNuxtMajorVersion(majorVersion: 2 | 3 | 4, nuxt?: Nuxt): boolean;
/**
* @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
*/
declare function isNuxt2(nuxt?: Nuxt): boolean;
/**
* @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
*/
declare function isNuxt3(nuxt?: Nuxt): boolean;
/**
* Get nuxt version
*/
declare function getNuxtVersion(nuxt?: Nuxt | any): string;
/**
* Register a directory to be scanned for components and imported only when used.
*/
declare function addComponentsDir(dir: ComponentsDir, opts?: {
prepend?: boolean;
}): void;
type AddComponentOptions = {
name: string;
filePath: string;
} & Partial<Exclude<Component, 'shortPath' | 'async' | 'level' | 'import' | 'asyncImport'>>;
/**
* This utility takes a file path or npm package that is scanned for named exports, which are get added automatically
*/
declare function addComponentExports(opts: Omit<AddComponentOptions, 'name'> & {
prefix?: string;
}): void;
/**
* Register a component by its name and filePath.
*/
declare function addComponent(opts: AddComponentOptions): void;
/**
* Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
* @deprecated Use `getNuxtCtx` instead
*/
declare const nuxtCtx: unctx.UseContext<Nuxt>;
/** Direct access to the Nuxt context with asyncLocalStorage - see https://github.com/unjs/unctx. */
declare const getNuxtCtx: () => Nuxt | null;
/**
* Get access to Nuxt instance.
*
* Throws an error if Nuxt instance is unavailable.
* @example
* ```js
* const nuxt = useNuxt()
* ```
*/
declare function useNuxt(): Nuxt;
/**
* Get access to Nuxt instance.
*
* Returns null if Nuxt instance is unavailable.
* @example
* ```js
* const nuxt = tryUseNuxt()
* if (nuxt) {
* // Do something
* }
* ```
*/
declare function tryUseNuxt(): Nuxt | null;
declare function runWithNuxtContext<T extends (...args: any[]) => any>(nuxt: Nuxt, fn: T): ReturnType<T>;
declare function createIsIgnored(nuxt?: _nuxt_schema.Nuxt | null): (pathname: string, stats?: unknown) => boolean;
/**
* Return a filter function to filter an array of paths
*/
declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: _nuxt_schema.Nuxt | null): boolean;
declare function resolveIgnorePatterns(relativePath?: string): string[];
declare function addLayout(template: NuxtTemplate | string, name?: string): void;
declare function extendPages(cb: NuxtHooks['pages:extend']): void;
interface ExtendRouteRulesOptions {
/**
* Override route rule config
* @default false
*/
override?: boolean;
}
declare function extendRouteRules(route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void;
interface AddRouteMiddlewareOptions {
/**
* Override existing middleware with the same name, if it exists
* @default false
*/
override?: boolean;
/**
* Prepend middleware to the list
* @default false
*/
prepend?: boolean;
}
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
/**
* Registers a nuxt plugin and to the plugins array.
*
* Note: You can use mode or .client and .server modifiers with fileName option
* to use plugin only in client or server side.
*
* Note: By default plugin is prepended to the plugins array. You can use second argument to append (push) instead.
* @example
* ```js
* import { createResolver } from '@nuxt/kit'
* const resolver = createResolver(import.meta.url)
*
* addPlugin({
* src: resolver.resolve('templates/foo.js'),
* filename: 'foo.server.js' // [optional] only include in server bundle
* })
* ```
*/
interface AddPluginOptions {
append?: boolean;
}
declare function addPlugin(_plugin: NuxtPlugin | string, opts?: AddPluginOptions): NuxtPlugin;
/**
* Adds a template and registers as a nuxt plugin.
*/
declare function addPluginTemplate(plugin: NuxtPluginTemplate | string, opts?: AddPluginOptions): NuxtPlugin;
interface ResolvePathOptions {
/** Base for resolving paths from. Default is Nuxt rootDir. */
cwd?: string;
/** An object of aliases. Default is Nuxt configured aliases. */
alias?: Record<string, string>;
/**
* The file extensions to try.
* Default is Nuxt configured extensions.
*
* Isn't considered when `type` is set to `'dir'`.
*/
extensions?: string[];
/**
* Whether to resolve files that exist in the Nuxt VFS (for example, as a Nuxt template).
* @default false
*/
virtual?: boolean;
/**
* Whether to fallback to the original path if the resolved path does not exist instead of returning the normalized input path.
* @default false
*/
fallbackToOriginal?: boolean;
/**
* The type of the path to be resolved.
* @default 'file'
*/
type?: PathType;
}
/**
* Resolve the full path to a file or a directory (based on the provided type), respecting Nuxt alias and extensions options.
*
* If a path cannot be resolved, normalized input will be returned unless the `fallbackToOriginal` option is set to `true`,
* in which case the original input path will be returned.
*/
declare function resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
/**
* Try to resolve first existing file in paths
*/
declare function findPath(paths: string | string[], opts?: ResolvePathOptions, pathType?: PathType): Promise<string | null>;
/**
* Resolve path aliases respecting Nuxt alias options
*/
declare function resolveAlias(path: string, alias?: Record<string, string>): string;
interface Resolver {
resolve(...path: string[]): string;
resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
}
/**
* Create a relative resolver
*/
declare function createResolver(base: string | URL): Resolver;
declare function resolveNuxtModule(base: string, paths: string[]): Promise<string[]>;
type PathType = 'file' | 'dir';
/**
* Resolve absolute file paths in the provided directory with respect to `.nuxtignore` and return them sorted.
* @param path path to the directory to resolve files in
* @param pattern glob pattern or an array of glob patterns to match files
* @param opts options for globbing
* @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
* @param opts.ignore additional glob patterns to ignore
* @returns sorted array of absolute file paths
*/
declare function resolveFiles(path: string, pattern: string | string[], opts?: {
followSymbolicLinks?: boolean;
ignore?: GlobOptions['ignore'];
}): Promise<string[]>;
/**
* Adds a nitro server handler
*
*/
declare function addServerHandler(handler: NitroEventHandler): void;
/**
* Adds a nitro server handler for development-only
*
*/
declare function addDevServerHandler(handler: NitroDevEventHandler): void;
/**
* Adds a Nitro plugin
*/
declare function addServerPlugin(plugin: string): void;
/**
* Adds routes to be prerendered
*/
declare function addPrerenderRoutes(routes: string | string[]): void;
/**
* Access to the Nitro instance
*
* **Note:** You can call `useNitro()` only after `ready` hook.
*
* **Note:** Changes to the Nitro instance configuration are not applied.
* @example
*
* ```ts
* nuxt.hook('ready', () => {
* console.log(useNitro())
* })
* ```
*/
declare function useNitro(): Nitro;
/**
* Add server imports to be auto-imported by Nitro
*/
declare function addServerImports(imports: Import | Import[]): void;
/**
* Add directories to be scanned for auto-imports by Nitro
*/
declare function addServerImportsDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
/**
* Add directories to be scanned by Nitro. It will check for subdirectories,
* which will be registered just like the `~/server` folder is.
*/
declare function addServerScanDir(dirs: string | string[], opts?: {
prepend?: boolean;
}): void;
/**
* Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
*/
declare function addTemplate<T>(_template: NuxtTemplate<T> | string): ResolvedNuxtTemplate<T>;
/**
* Adds a virtual file that can be used within the Nuxt Nitro server build.
*/
declare function addServerTemplate(template: NuxtServerTemplate): NuxtServerTemplate;
/**
* Renders given types during build to disk in the project `buildDir`
* and register them as types.
*
* You can pass a second context object to specify in which context the type should be added.
*
* If no context object is passed, then it will only be added to the nuxt context.
*/
declare function addTypeTemplate<T>(_template: NuxtTypeTemplate<T>, context?: {
nitro?: boolean;
nuxt?: boolean;
node?: boolean;
shared?: boolean;
}): ResolvedNuxtTemplate<T>;
/**
* Normalize a nuxt template object
*/
declare function normalizeTemplate<T>(template: NuxtTemplate<T> | string, buildDir?: string): ResolvedNuxtTemplate<T>;
/**
* Trigger rebuilding Nuxt templates
*
* You can pass a filter within the options to selectively regenerate a subset of templates.
*/
declare function updateTemplates(options?: {
filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
}): Promise<any>;
declare function writeTypes(nuxt: Nuxt): Promise<void>;
declare const logger: consola.ConsolaInstance;
declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): consola.ConsolaInstance;
interface ResolveModuleOptions {
/** @deprecated use `url` with URLs pointing at a file - never a directory */
paths?: string | string[];
url?: URL | URL[];
/** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
extensions?: string[];
}
declare function directoryToURL(dir: string): URL;
/**
* Resolve a module from a given root path using an algorithm patterned on
* the upcoming `import.meta.resolve`. It returns a file URL
*
* @internal
*/
declare function tryResolveModule(id: string, url: URL | URL[]): Promise<string | undefined>;
/** @deprecated pass URLs pointing at files */
declare function tryResolveModule(id: string, url: string | string[]): Promise<string | undefined>;
declare function resolveModule(id: string, options?: ResolveModuleOptions): string;
interface ImportModuleOptions extends ResolveModuleOptions {
/** Automatically de-default the result of requiring the module. */
interopDefault?: boolean;
}
declare function importModule<T = unknown>(id: string, opts?: ImportModuleOptions): Promise<T>;
declare function tryImportModule<T = unknown>(id: string, opts?: ImportModuleOptions): Promise<T | undefined> | undefined;
/**
* @deprecated Please use `importModule` instead.
*/
declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T;
/**
* @deprecated Please use `tryImportModule` instead.
*/
declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, ResolveModuleOptions, ResolvePathOptions, Resolver };

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,65 @@
{
"name": "@nuxt/kit",
"version": "4.2.2",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/nuxt.git",
"directory": "packages/kit"
},
"homepage": "https://nuxt.com/docs/4.x/api/kit",
"description": "Toolkit for authoring modules and interacting with Nuxt",
"license": "MIT",
"type": "module",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.mjs"
},
"./package.json": "./package.json"
},
"files": [
"dist"
],
"dependencies": {
"c12": "^3.3.2",
"consola": "^3.4.2",
"defu": "^6.1.4",
"destr": "^2.0.5",
"errx": "^0.1.0",
"exsolve": "^1.0.8",
"ignore": "^7.0.5",
"jiti": "^2.6.1",
"klona": "^2.0.6",
"mlly": "^1.8.0",
"ohash": "^2.0.11",
"pathe": "^2.0.3",
"pkg-types": "^2.3.0",
"rc9": "^2.1.2",
"scule": "^1.3.0",
"semver": "^7.7.3",
"tinyglobby": "^0.2.15",
"ufo": "^1.6.1",
"unctx": "^2.4.1",
"untyped": "^2.0.0"
},
"devDependencies": {
"@rspack/core": "1.6.7",
"@types/semver": "7.7.1",
"hookable": "5.5.3",
"nitropack": "2.12.9",
"unbuild": "3.6.1",
"unimport": "5.5.0",
"vite": "7.2.7",
"vitest": "3.2.4",
"webpack": "5.103.0",
"@nuxt/schema": "4.2.2"
},
"engines": {
"node": ">=18.12.0"
},
"scripts": {
"test:attw": "attw --pack"
}
}

View file

@ -0,0 +1,61 @@
{
"name": "@nuxt/devtools-kit",
"type": "module",
"version": "3.1.1",
"license": "MIT",
"homepage": "https://devtools.nuxt.com/module/utils-kit",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/devtools.git",
"directory": "packages/devtools-kit"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"./types": {
"types": "./types.d.ts",
"import": "./dist/types.mjs",
"require": "./dist/types.cjs"
},
"./iframe-client": {
"types": "./iframe-client.d.ts",
"import": "./iframe-client.mjs"
},
"./host-client": {
"types": "./host-client.d.ts",
"import": "./host-client.mjs"
}
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"files": [
"*.cjs",
"*.d.ts",
"*.mjs",
"dist"
],
"peerDependencies": {
"vite": ">=6.0"
},
"dependencies": {
"@nuxt/kit": "^4.2.1",
"execa": "^8.0.1"
},
"devDependencies": {
"@nuxt/schema": "^4.2.1",
"birpc": "^2.8.0",
"error-stack-parser-es": "^1.0.5",
"hookable": "^5.5.3",
"unbuild": "^3.6.1",
"unimport": "^5.5.0",
"vue-router": "^4.6.3"
},
"scripts": {
"build": "unbuild",
"stub": "unbuild --stub",
"dev:prepare": "nr stub"
}
}

View file

@ -0,0 +1 @@
export type * from './dist/types.d.mts'