@nuxt/devtools-kit 4.0.0-alpha.7 → 4.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,44 +1,276 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
+ import { ViteDevToolsNodeContext } from '@vitejs/devtools-kit';
2
3
  import { BirpcGroup } from 'birpc';
3
4
  import { ChildProcess } from 'node:child_process';
4
5
  import { Result } from 'tinyexec';
5
- import { r as ModuleCustomTab, O as NuxtDevtoolsInfo, a4 as SubprocessOptions, a9 as TerminalState } from './shared/devtools-kit.BwQLAI1z.mjs';
6
+ import { N as NuxtDevtoolsServerContext, M as ModuleCustomTab, a as NuxtDevtoolsInfo, S as SubprocessOptions, T as TerminalState } from './shared/devtools-kit.Do7_fnKq.mjs';
7
+ import * as nostics from 'nostics';
8
+ import { defineDiagnostics } from 'nostics';
9
+ export { createConsoleReporter, defineDiagnostics } from 'nostics';
10
+ import { Nuxt } from 'nuxt/schema';
6
11
  import 'vue';
7
- import '@vitejs/devtools-kit';
8
- import 'nuxt/schema';
9
12
  import 'unimport';
10
13
  import 'vue-router';
11
14
  import 'nitropack';
12
15
  import 'unstorage';
13
16
  import 'vite';
14
17
 
18
+ /**
19
+ * Canonical docs URL for a Nuxt DevTools diagnostic code.
20
+ *
21
+ * Each code links to a per-code anchor in the v4 migration guide, e.g.
22
+ * `NDT_DEP_0001` → `.../module/migration-v4#ndt_dep_0001`.
23
+ */
24
+ declare function diagnosticsDocsBase(code: string | number): string;
25
+ /**
26
+ * Parameters shared by every deprecation code: the API being used and its
27
+ * recommended replacement. Interpolated into the `why`/`fix` messages.
28
+ */
29
+ interface DeprecationParams {
30
+ /** The deprecated API / option being used. */
31
+ api: string;
32
+ /** The recommended replacement to migrate to. */
33
+ replacement: string;
34
+ }
35
+ /**
36
+ * The Nuxt DevTools diagnostics catalog.
37
+ *
38
+ * Codes are grouped by prefix:
39
+ * - `NDT_DEP_xxxx` — soft/hard deprecations (this is the only range used today).
40
+ *
41
+ * Severity is **not** encoded here; it is chosen per emission via the reporter
42
+ * `method` (`warn` by default, `error` for hard breaks).
43
+ */
44
+ declare const diagnosticCodes: {
45
+ /** `startSubprocess().getProcess()` → `getResult()`. */
46
+ NDT_DEP_0001: {
47
+ why: (p: DeprecationParams) => string;
48
+ fix: (p: DeprecationParams) => string;
49
+ };
50
+ /** `extendServerRpc` → `onDevtoolsReady((ctx) => ctx.rpc.register(...))`. */
51
+ NDT_DEP_0003: {
52
+ why: (p: DeprecationParams) => string;
53
+ fix: (p: DeprecationParams) => string;
54
+ };
55
+ /** `startSubprocess` → `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`. */
56
+ NDT_DEP_0004: {
57
+ why: (p: DeprecationParams) => string;
58
+ fix: (p: DeprecationParams) => string;
59
+ };
60
+ /** `addCustomTab` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
61
+ NDT_DEP_0005: {
62
+ why: (p: DeprecationParams) => string;
63
+ fix: (p: DeprecationParams) => string;
64
+ };
65
+ /** `refreshCustomTabs` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
66
+ NDT_DEP_0006: {
67
+ why: (p: DeprecationParams) => string;
68
+ fix: (p: DeprecationParams) => string;
69
+ };
70
+ /** Direct `nuxt.devtools.rpc` access (`broadcast` / `functions`). */
71
+ NDT_DEP_0007: {
72
+ why: (p: DeprecationParams) => string;
73
+ fix: (p: DeprecationParams) => string;
74
+ };
75
+ /** Removed `vscode` module option → `codeServer`. */
76
+ NDT_DEP_0008: {
77
+ why: (p: DeprecationParams) => string;
78
+ fix: (p: DeprecationParams) => string;
79
+ };
80
+ /** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
81
+ NDT_DEP_0009: {
82
+ why: (p: DeprecationParams) => string;
83
+ fix: (p: DeprecationParams) => string;
84
+ };
85
+ };
86
+ type NuxtDiagnosticCode = keyof typeof diagnosticCodes;
87
+ /**
88
+ * Standalone catalog that prints to the terminal via nostics'
89
+ * {@link createConsoleReporter} (default method `warn`). Works before the Vite
90
+ * DevTools kit connects, so it is the fallback sink for pre-connect emissions.
91
+ */
92
+ declare const consoleDiagnostics: nostics.Diagnostics<{
93
+ /** `startSubprocess().getProcess()` → `getResult()`. */
94
+ NDT_DEP_0001: {
95
+ why: (p: DeprecationParams) => string;
96
+ fix: (p: DeprecationParams) => string;
97
+ };
98
+ /** `extendServerRpc` → `onDevtoolsReady((ctx) => ctx.rpc.register(...))`. */
99
+ NDT_DEP_0003: {
100
+ why: (p: DeprecationParams) => string;
101
+ fix: (p: DeprecationParams) => string;
102
+ };
103
+ /** `startSubprocess` → `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`. */
104
+ NDT_DEP_0004: {
105
+ why: (p: DeprecationParams) => string;
106
+ fix: (p: DeprecationParams) => string;
107
+ };
108
+ /** `addCustomTab` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
109
+ NDT_DEP_0005: {
110
+ why: (p: DeprecationParams) => string;
111
+ fix: (p: DeprecationParams) => string;
112
+ };
113
+ /** `refreshCustomTabs` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
114
+ NDT_DEP_0006: {
115
+ why: (p: DeprecationParams) => string;
116
+ fix: (p: DeprecationParams) => string;
117
+ };
118
+ /** Direct `nuxt.devtools.rpc` access (`broadcast` / `functions`). */
119
+ NDT_DEP_0007: {
120
+ why: (p: DeprecationParams) => string;
121
+ fix: (p: DeprecationParams) => string;
122
+ };
123
+ /** Removed `vscode` module option → `codeServer`. */
124
+ NDT_DEP_0008: {
125
+ why: (p: DeprecationParams) => string;
126
+ fix: (p: DeprecationParams) => string;
127
+ };
128
+ /** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
129
+ NDT_DEP_0009: {
130
+ why: (p: DeprecationParams) => string;
131
+ fix: (p: DeprecationParams) => string;
132
+ };
133
+ }, readonly [nostics.DiagnosticReporter<{
134
+ method?: nostics.ConsoleMethod;
135
+ }>]>;
136
+ /**
137
+ * Register the Nuxt deprecation codes into the connected Vite DevTools kit's
138
+ * diagnostics host so they are known to DevTools and post-connect emissions
139
+ * surface in the DevTools diagnostics UI. Safe to call when no host is present.
140
+ *
141
+ * Called from `connectDevToolsKit`.
142
+ */
143
+ declare function registerHostDiagnostics(ctx: NuxtDevtoolsServerContext): void;
144
+ /**
145
+ * Options for {@link deprecate}.
146
+ */
147
+ interface DeprecateOptions {
148
+ /**
149
+ * Dedupe key appended to the code. Defaults to the code itself, i.e. the
150
+ * deprecation warns once per process. Pass a finer key (e.g. a subprocess id)
151
+ * to warn once per distinct call site instead.
152
+ */
153
+ key?: string;
154
+ /**
155
+ * Reporter method / severity. `warn` (default) for soft deprecations, `error`
156
+ * for hard breaks. The returned {@link Diagnostic} can be thrown to abort.
157
+ */
158
+ method?: 'warn' | 'error';
159
+ }
160
+ /**
161
+ * Emit a Nuxt DevTools deprecation diagnostic.
162
+ *
163
+ * Routing: when the Vite DevTools kit is connected the emission goes through the
164
+ * DevTools host catalog (terminal **and** the DevTools diagnostics UI); before
165
+ * connect it falls back to the terminal-only console catalog. A single emission
166
+ * per call — no double printing.
167
+ *
168
+ * Deduped per `${code}:${key ?? code}` on the resolved server context, so a hot
169
+ * path warns only once.
170
+ *
171
+ * @returns the built `Diagnostic` (which extends `Error`, so it can be thrown
172
+ * for hard breaks), or `undefined` if the emission was deduped.
173
+ */
174
+ declare function deprecate(nuxt: Nuxt, code: NuxtDiagnosticCode, params: DeprecationParams, options?: DeprecateOptions): Error | undefined;
175
+ /**
176
+ * Build a standalone nostics catalog that prints to the terminal.
177
+ *
178
+ * Used by the connect-safe `nuxt.devtools.diagnostics` accessor so module
179
+ * authors can define + emit diagnostics before the Vite DevTools kit connects.
180
+ * A `createConsoleReporter()` is added automatically unless the caller supplies
181
+ * its own `reporters`.
182
+ */
183
+ declare function defineStandaloneDiagnostics(options: Parameters<typeof defineDiagnostics>[0]): ReturnType<typeof defineDiagnostics>;
184
+ /**
185
+ * Convenience wrapper for call sites that don't already hold the Nuxt instance.
186
+ */
187
+ declare function deprecateWithNuxt(code: NuxtDiagnosticCode, params: DeprecationParams, options?: DeprecateOptions): Error | undefined;
188
+
189
+ /**
190
+ * The public `Nuxt` dock group id registered on the Vite DevTools framework
191
+ * category. Module authors join the group natively by pointing their own
192
+ * dock entries at it — no special Nuxt API required:
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * import { NUXT_DEVTOOLS_GROUP_ID, onDevtoolsReady } from '@nuxt/devtools-kit'
197
+ *
198
+ * onDevtoolsReady((ctx) => {
199
+ * ctx.docks.register({
200
+ * id: 'my-module',
201
+ * type: 'iframe',
202
+ * title: 'My Module',
203
+ * icon: 'i-ph-puzzle-piece',
204
+ * url: '/my-module/',
205
+ * groupId: NUXT_DEVTOOLS_GROUP_ID,
206
+ * })
207
+ * })
208
+ * ```
209
+ */
210
+ declare const NUXT_DEVTOOLS_GROUP_ID = "nuxt";
15
211
  /**
16
212
  * Hooks to extend a custom tab in devtools.
17
213
  *
18
214
  * Provide a function to pass a factory that can be updated dynamically.
215
+ *
216
+ * @deprecated Register a dock entry from the `devtools:ready` hook instead:
217
+ * `onDevtoolsReady((ctx) => ctx.docks.register(...))`. Still works as a shim, but
218
+ * emits the `NDT_DEP_0005` deprecation diagnostic. Note the docks host does not
219
+ * yet cover `vnode` views or tab categories.
19
220
  */
20
221
  declare function addCustomTab(tab: ModuleCustomTab | (() => ModuleCustomTab | Promise<ModuleCustomTab>), nuxt?: _nuxt_schema.Nuxt): void;
21
222
  /**
22
223
  * Retrigger update for custom tabs, `devtools:customTabs` will be called again.
224
+ *
225
+ * @deprecated Update dock entries directly via the handle returned by
226
+ * `ctx.docks.register(...)` inside the `devtools:ready` hook. Still works as a
227
+ * shim, but emits the `NDT_DEP_0006` deprecation diagnostic.
23
228
  */
24
229
  declare function refreshCustomTabs(nuxt?: _nuxt_schema.Nuxt): void | Promise<any>;
25
- /**
26
- * Create a subprocess that handled by the DevTools.
27
- */
28
- declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): {
230
+ interface StartSubprocessReturn {
29
231
  /** @deprecated Use `getResult()` instead */
30
232
  getProcess: () => ChildProcess | undefined;
31
233
  getResult: () => Result;
32
234
  terminate: () => void;
33
235
  restart: () => void;
34
236
  clear: () => void;
35
- };
237
+ }
238
+ /**
239
+ * Create a subprocess that handled by the DevTools.
240
+ *
241
+ * @deprecated Use the Vite DevTools terminals host from the `devtools:ready`
242
+ * hook instead: `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`.
243
+ * Still works as a shim, but emits the `NDT_DEP_0004` deprecation diagnostic.
244
+ */
245
+ declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): StartSubprocessReturn;
36
246
  /**
37
247
  * Extend server RPC with namespaced functions.
38
248
  *
39
249
  * Returns an object with a `broadcast` proxy for calling client functions.
250
+ *
251
+ * @deprecated Register RPC functions from the `devtools:ready` hook instead:
252
+ * `onDevtoolsReady((ctx) => ctx.rpc.register(defineRpcFunction(...)))`. Still
253
+ * works as a shim, but emits the `NDT_DEP_0003` deprecation diagnostic.
40
254
  */
41
255
  declare function extendServerRpc<ClientFunctions extends object = Record<string, unknown>, ServerFunctions extends object = Record<string, unknown>>(namespace: string, functions: ServerFunctions, nuxt?: _nuxt_schema.Nuxt): BirpcGroup<ClientFunctions, ServerFunctions>;
42
256
  declare function onDevToolsInitialized(fn: (info: NuxtDevtoolsInfo) => void, nuxt?: _nuxt_schema.Nuxt): void;
257
+ /**
258
+ * Run a callback once the Vite DevTools kit has connected, receiving the
259
+ * connected `ViteDevToolsNodeContext`.
260
+ *
261
+ * This is the recommended entry point for DevTools integration: the kit is
262
+ * guaranteed available, so you can use `ctx.docks` / `ctx.terminals` /
263
+ * `ctx.messages` / `ctx.commands` / `ctx.rpc` / `ctx.diagnostics` directly
264
+ * without the connect-safe accessors on `nuxt.devtools`.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * onDevtoolsReady((ctx) => {
269
+ * ctx.docks.register({ id: 'my-module', title: 'My Module', type: 'iframe', url: '/…' })
270
+ * })
271
+ * ```
272
+ */
273
+ declare function onDevtoolsReady(fn: (ctx: ViteDevToolsNodeContext) => void | Promise<void>, nuxt?: _nuxt_schema.Nuxt): void;
43
274
 
44
- export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };
275
+ export { NUXT_DEVTOOLS_GROUP_ID, addCustomTab, consoleDiagnostics, defineStandaloneDiagnostics, deprecate, deprecateWithNuxt, diagnosticCodes, diagnosticsDocsBase, extendServerRpc, onDevToolsInitialized, onDevtoolsReady, refreshCustomTabs, registerHostDiagnostics, startSubprocess };
276
+ export type { DeprecateOptions, DeprecationParams, NuxtDiagnosticCode, StartSubprocessReturn };
package/dist/index.d.ts CHANGED
@@ -1,44 +1,276 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
+ import { ViteDevToolsNodeContext } from '@vitejs/devtools-kit';
2
3
  import { BirpcGroup } from 'birpc';
3
4
  import { ChildProcess } from 'node:child_process';
4
5
  import { Result } from 'tinyexec';
5
- import { r as ModuleCustomTab, O as NuxtDevtoolsInfo, a4 as SubprocessOptions, a9 as TerminalState } from './shared/devtools-kit.BwQLAI1z.js';
6
+ import { N as NuxtDevtoolsServerContext, M as ModuleCustomTab, a as NuxtDevtoolsInfo, S as SubprocessOptions, T as TerminalState } from './shared/devtools-kit.Do7_fnKq.js';
7
+ import * as nostics from 'nostics';
8
+ import { defineDiagnostics } from 'nostics';
9
+ export { createConsoleReporter, defineDiagnostics } from 'nostics';
10
+ import { Nuxt } from 'nuxt/schema';
6
11
  import 'vue';
7
- import '@vitejs/devtools-kit';
8
- import 'nuxt/schema';
9
12
  import 'unimport';
10
13
  import 'vue-router';
11
14
  import 'nitropack';
12
15
  import 'unstorage';
13
16
  import 'vite';
14
17
 
18
+ /**
19
+ * Canonical docs URL for a Nuxt DevTools diagnostic code.
20
+ *
21
+ * Each code links to a per-code anchor in the v4 migration guide, e.g.
22
+ * `NDT_DEP_0001` → `.../module/migration-v4#ndt_dep_0001`.
23
+ */
24
+ declare function diagnosticsDocsBase(code: string | number): string;
25
+ /**
26
+ * Parameters shared by every deprecation code: the API being used and its
27
+ * recommended replacement. Interpolated into the `why`/`fix` messages.
28
+ */
29
+ interface DeprecationParams {
30
+ /** The deprecated API / option being used. */
31
+ api: string;
32
+ /** The recommended replacement to migrate to. */
33
+ replacement: string;
34
+ }
35
+ /**
36
+ * The Nuxt DevTools diagnostics catalog.
37
+ *
38
+ * Codes are grouped by prefix:
39
+ * - `NDT_DEP_xxxx` — soft/hard deprecations (this is the only range used today).
40
+ *
41
+ * Severity is **not** encoded here; it is chosen per emission via the reporter
42
+ * `method` (`warn` by default, `error` for hard breaks).
43
+ */
44
+ declare const diagnosticCodes: {
45
+ /** `startSubprocess().getProcess()` → `getResult()`. */
46
+ NDT_DEP_0001: {
47
+ why: (p: DeprecationParams) => string;
48
+ fix: (p: DeprecationParams) => string;
49
+ };
50
+ /** `extendServerRpc` → `onDevtoolsReady((ctx) => ctx.rpc.register(...))`. */
51
+ NDT_DEP_0003: {
52
+ why: (p: DeprecationParams) => string;
53
+ fix: (p: DeprecationParams) => string;
54
+ };
55
+ /** `startSubprocess` → `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`. */
56
+ NDT_DEP_0004: {
57
+ why: (p: DeprecationParams) => string;
58
+ fix: (p: DeprecationParams) => string;
59
+ };
60
+ /** `addCustomTab` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
61
+ NDT_DEP_0005: {
62
+ why: (p: DeprecationParams) => string;
63
+ fix: (p: DeprecationParams) => string;
64
+ };
65
+ /** `refreshCustomTabs` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
66
+ NDT_DEP_0006: {
67
+ why: (p: DeprecationParams) => string;
68
+ fix: (p: DeprecationParams) => string;
69
+ };
70
+ /** Direct `nuxt.devtools.rpc` access (`broadcast` / `functions`). */
71
+ NDT_DEP_0007: {
72
+ why: (p: DeprecationParams) => string;
73
+ fix: (p: DeprecationParams) => string;
74
+ };
75
+ /** Removed `vscode` module option → `codeServer`. */
76
+ NDT_DEP_0008: {
77
+ why: (p: DeprecationParams) => string;
78
+ fix: (p: DeprecationParams) => string;
79
+ };
80
+ /** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
81
+ NDT_DEP_0009: {
82
+ why: (p: DeprecationParams) => string;
83
+ fix: (p: DeprecationParams) => string;
84
+ };
85
+ };
86
+ type NuxtDiagnosticCode = keyof typeof diagnosticCodes;
87
+ /**
88
+ * Standalone catalog that prints to the terminal via nostics'
89
+ * {@link createConsoleReporter} (default method `warn`). Works before the Vite
90
+ * DevTools kit connects, so it is the fallback sink for pre-connect emissions.
91
+ */
92
+ declare const consoleDiagnostics: nostics.Diagnostics<{
93
+ /** `startSubprocess().getProcess()` → `getResult()`. */
94
+ NDT_DEP_0001: {
95
+ why: (p: DeprecationParams) => string;
96
+ fix: (p: DeprecationParams) => string;
97
+ };
98
+ /** `extendServerRpc` → `onDevtoolsReady((ctx) => ctx.rpc.register(...))`. */
99
+ NDT_DEP_0003: {
100
+ why: (p: DeprecationParams) => string;
101
+ fix: (p: DeprecationParams) => string;
102
+ };
103
+ /** `startSubprocess` → `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`. */
104
+ NDT_DEP_0004: {
105
+ why: (p: DeprecationParams) => string;
106
+ fix: (p: DeprecationParams) => string;
107
+ };
108
+ /** `addCustomTab` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
109
+ NDT_DEP_0005: {
110
+ why: (p: DeprecationParams) => string;
111
+ fix: (p: DeprecationParams) => string;
112
+ };
113
+ /** `refreshCustomTabs` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
114
+ NDT_DEP_0006: {
115
+ why: (p: DeprecationParams) => string;
116
+ fix: (p: DeprecationParams) => string;
117
+ };
118
+ /** Direct `nuxt.devtools.rpc` access (`broadcast` / `functions`). */
119
+ NDT_DEP_0007: {
120
+ why: (p: DeprecationParams) => string;
121
+ fix: (p: DeprecationParams) => string;
122
+ };
123
+ /** Removed `vscode` module option → `codeServer`. */
124
+ NDT_DEP_0008: {
125
+ why: (p: DeprecationParams) => string;
126
+ fix: (p: DeprecationParams) => string;
127
+ };
128
+ /** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
129
+ NDT_DEP_0009: {
130
+ why: (p: DeprecationParams) => string;
131
+ fix: (p: DeprecationParams) => string;
132
+ };
133
+ }, readonly [nostics.DiagnosticReporter<{
134
+ method?: nostics.ConsoleMethod;
135
+ }>]>;
136
+ /**
137
+ * Register the Nuxt deprecation codes into the connected Vite DevTools kit's
138
+ * diagnostics host so they are known to DevTools and post-connect emissions
139
+ * surface in the DevTools diagnostics UI. Safe to call when no host is present.
140
+ *
141
+ * Called from `connectDevToolsKit`.
142
+ */
143
+ declare function registerHostDiagnostics(ctx: NuxtDevtoolsServerContext): void;
144
+ /**
145
+ * Options for {@link deprecate}.
146
+ */
147
+ interface DeprecateOptions {
148
+ /**
149
+ * Dedupe key appended to the code. Defaults to the code itself, i.e. the
150
+ * deprecation warns once per process. Pass a finer key (e.g. a subprocess id)
151
+ * to warn once per distinct call site instead.
152
+ */
153
+ key?: string;
154
+ /**
155
+ * Reporter method / severity. `warn` (default) for soft deprecations, `error`
156
+ * for hard breaks. The returned {@link Diagnostic} can be thrown to abort.
157
+ */
158
+ method?: 'warn' | 'error';
159
+ }
160
+ /**
161
+ * Emit a Nuxt DevTools deprecation diagnostic.
162
+ *
163
+ * Routing: when the Vite DevTools kit is connected the emission goes through the
164
+ * DevTools host catalog (terminal **and** the DevTools diagnostics UI); before
165
+ * connect it falls back to the terminal-only console catalog. A single emission
166
+ * per call — no double printing.
167
+ *
168
+ * Deduped per `${code}:${key ?? code}` on the resolved server context, so a hot
169
+ * path warns only once.
170
+ *
171
+ * @returns the built `Diagnostic` (which extends `Error`, so it can be thrown
172
+ * for hard breaks), or `undefined` if the emission was deduped.
173
+ */
174
+ declare function deprecate(nuxt: Nuxt, code: NuxtDiagnosticCode, params: DeprecationParams, options?: DeprecateOptions): Error | undefined;
175
+ /**
176
+ * Build a standalone nostics catalog that prints to the terminal.
177
+ *
178
+ * Used by the connect-safe `nuxt.devtools.diagnostics` accessor so module
179
+ * authors can define + emit diagnostics before the Vite DevTools kit connects.
180
+ * A `createConsoleReporter()` is added automatically unless the caller supplies
181
+ * its own `reporters`.
182
+ */
183
+ declare function defineStandaloneDiagnostics(options: Parameters<typeof defineDiagnostics>[0]): ReturnType<typeof defineDiagnostics>;
184
+ /**
185
+ * Convenience wrapper for call sites that don't already hold the Nuxt instance.
186
+ */
187
+ declare function deprecateWithNuxt(code: NuxtDiagnosticCode, params: DeprecationParams, options?: DeprecateOptions): Error | undefined;
188
+
189
+ /**
190
+ * The public `Nuxt` dock group id registered on the Vite DevTools framework
191
+ * category. Module authors join the group natively by pointing their own
192
+ * dock entries at it — no special Nuxt API required:
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * import { NUXT_DEVTOOLS_GROUP_ID, onDevtoolsReady } from '@nuxt/devtools-kit'
197
+ *
198
+ * onDevtoolsReady((ctx) => {
199
+ * ctx.docks.register({
200
+ * id: 'my-module',
201
+ * type: 'iframe',
202
+ * title: 'My Module',
203
+ * icon: 'i-ph-puzzle-piece',
204
+ * url: '/my-module/',
205
+ * groupId: NUXT_DEVTOOLS_GROUP_ID,
206
+ * })
207
+ * })
208
+ * ```
209
+ */
210
+ declare const NUXT_DEVTOOLS_GROUP_ID = "nuxt";
15
211
  /**
16
212
  * Hooks to extend a custom tab in devtools.
17
213
  *
18
214
  * Provide a function to pass a factory that can be updated dynamically.
215
+ *
216
+ * @deprecated Register a dock entry from the `devtools:ready` hook instead:
217
+ * `onDevtoolsReady((ctx) => ctx.docks.register(...))`. Still works as a shim, but
218
+ * emits the `NDT_DEP_0005` deprecation diagnostic. Note the docks host does not
219
+ * yet cover `vnode` views or tab categories.
19
220
  */
20
221
  declare function addCustomTab(tab: ModuleCustomTab | (() => ModuleCustomTab | Promise<ModuleCustomTab>), nuxt?: _nuxt_schema.Nuxt): void;
21
222
  /**
22
223
  * Retrigger update for custom tabs, `devtools:customTabs` will be called again.
224
+ *
225
+ * @deprecated Update dock entries directly via the handle returned by
226
+ * `ctx.docks.register(...)` inside the `devtools:ready` hook. Still works as a
227
+ * shim, but emits the `NDT_DEP_0006` deprecation diagnostic.
23
228
  */
24
229
  declare function refreshCustomTabs(nuxt?: _nuxt_schema.Nuxt): void | Promise<any>;
25
- /**
26
- * Create a subprocess that handled by the DevTools.
27
- */
28
- declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): {
230
+ interface StartSubprocessReturn {
29
231
  /** @deprecated Use `getResult()` instead */
30
232
  getProcess: () => ChildProcess | undefined;
31
233
  getResult: () => Result;
32
234
  terminate: () => void;
33
235
  restart: () => void;
34
236
  clear: () => void;
35
- };
237
+ }
238
+ /**
239
+ * Create a subprocess that handled by the DevTools.
240
+ *
241
+ * @deprecated Use the Vite DevTools terminals host from the `devtools:ready`
242
+ * hook instead: `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`.
243
+ * Still works as a shim, but emits the `NDT_DEP_0004` deprecation diagnostic.
244
+ */
245
+ declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): StartSubprocessReturn;
36
246
  /**
37
247
  * Extend server RPC with namespaced functions.
38
248
  *
39
249
  * Returns an object with a `broadcast` proxy for calling client functions.
250
+ *
251
+ * @deprecated Register RPC functions from the `devtools:ready` hook instead:
252
+ * `onDevtoolsReady((ctx) => ctx.rpc.register(defineRpcFunction(...)))`. Still
253
+ * works as a shim, but emits the `NDT_DEP_0003` deprecation diagnostic.
40
254
  */
41
255
  declare function extendServerRpc<ClientFunctions extends object = Record<string, unknown>, ServerFunctions extends object = Record<string, unknown>>(namespace: string, functions: ServerFunctions, nuxt?: _nuxt_schema.Nuxt): BirpcGroup<ClientFunctions, ServerFunctions>;
42
256
  declare function onDevToolsInitialized(fn: (info: NuxtDevtoolsInfo) => void, nuxt?: _nuxt_schema.Nuxt): void;
257
+ /**
258
+ * Run a callback once the Vite DevTools kit has connected, receiving the
259
+ * connected `ViteDevToolsNodeContext`.
260
+ *
261
+ * This is the recommended entry point for DevTools integration: the kit is
262
+ * guaranteed available, so you can use `ctx.docks` / `ctx.terminals` /
263
+ * `ctx.messages` / `ctx.commands` / `ctx.rpc` / `ctx.diagnostics` directly
264
+ * without the connect-safe accessors on `nuxt.devtools`.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * onDevtoolsReady((ctx) => {
269
+ * ctx.docks.register({ id: 'my-module', title: 'My Module', type: 'iframe', url: '/…' })
270
+ * })
271
+ * ```
272
+ */
273
+ declare function onDevtoolsReady(fn: (ctx: ViteDevToolsNodeContext) => void | Promise<void>, nuxt?: _nuxt_schema.Nuxt): void;
43
274
 
44
- export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };
275
+ export { NUXT_DEVTOOLS_GROUP_ID, addCustomTab, consoleDiagnostics, defineStandaloneDiagnostics, deprecate, deprecateWithNuxt, diagnosticCodes, diagnosticsDocsBase, extendServerRpc, onDevToolsInitialized, onDevtoolsReady, refreshCustomTabs, registerHostDiagnostics, startSubprocess };
276
+ export type { DeprecateOptions, DeprecationParams, NuxtDiagnosticCode, StartSubprocessReturn };