@nuxt/devtools-kit-nightly 3.2.4-29563355.8807be5 → 4.0.0-29884714.dcb247f

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/README.md CHANGED
@@ -24,15 +24,15 @@ Unleash Nuxt Developer Experience.
24
24
  </p>
25
25
 
26
26
  > [!NOTE]
27
- > You are current at the `main` branch for v4 development. The latest stable branch is [`v3`](https://github.com/nuxt/devtools/tree/v3).
27
+ > You are at the `main` branch for v4. The v3 branch is [`v3`](https://github.com/nuxt/devtools/tree/v3).
28
28
 
29
29
  <br>
30
30
 
31
31
  ## Installation
32
32
 
33
- > Nuxt DevTools v2 requires **Nuxt v3.15.0 or higher**.
33
+ > Nuxt DevTools v4 requires **Nuxt v4.5.0 or higher** (Vite 8). It is built on [Vite DevTools](https://github.com/vitejs/devtools) and shows up as the `Nuxt` group inside the Vite DevTools panel.
34
34
 
35
- Nuxt DevTools is **enabled by default** in Nuxt v3.8.0. You can press <kbd>Shift</kbd> + <kbd>Alt</kbd> / <kbd>⇧ Shift</kbd> + <kbd>⌥ Option</kbd> + <kbd>D</kbd> in your app to open it up.
35
+ Nuxt DevTools is **enabled by default**. You can press <kbd>Shift</kbd> + <kbd>Alt</kbd> / <kbd>⇧ Shift</kbd> + <kbd>⌥ Option</kbd> + <kbd>D</kbd> in your app to open it up.
36
36
 
37
37
  If you want to explicitly enable or disable Nuxt DevTools, you can update your `nuxt.config` with:
38
38
 
@@ -44,21 +44,57 @@ export default defineNuxtConfig({
44
44
  })
45
45
  ```
46
46
 
47
+ ### Nuxt 4
48
+
49
+ Nuxt 5 ships with Nuxt DevTools v4. Nuxt 4.5+ still bundles v3; override `@nuxt/devtools` to `^4.0.0` with your package manager (`overrides` for npm and pnpm, `resolutions` for yarn), remove your lockfile and reinstall. See the [upgrade guide](https://devtools.nuxt.com/guide/upgrading-to-v4) for details and for what changed.
50
+
47
51
  ### Nightly Release Channel
48
52
 
49
53
  Similar to [Nuxt's Nightly Channel](https://nuxt.com/docs/guide/going-further/nightly-release-channel), DevTools also offers a nightly release channel, that automatically releases for every commit to `main` branch.
50
54
 
51
- You can opt-in to the nightly release channel by running:
55
+ You can opt-in to the nightly release channel by using package manager resolutions:
56
+
57
+ <details>
58
+ <summary>npm</summary>
59
+
60
+ ```json
61
+ {
62
+ "overrides": {
63
+ "@nuxt/devtools": "npm:@nuxt/devtools-nightly@latest"
64
+ }
65
+ }
66
+ ```
67
+
68
+ </details>
69
+
70
+ <details>
71
+ <summary>yarn</summary>
52
72
 
53
- ```diff
73
+ ```json
54
74
  {
55
- "devDependencies": {
56
- -- "@nuxt/devtools": "^0.1.0"
57
- ++ "@nuxt/devtools": "npm:@nuxt/devtools-nightly@latest"
75
+ "resolutions": {
76
+ "@nuxt/devtools": "npm:@nuxt/devtools-nightly@latest"
58
77
  }
59
78
  }
60
79
  ```
61
80
 
81
+ </details>
82
+
83
+ <details>
84
+ <summary>pnpm</summary>
85
+
86
+ ```json
87
+ {
88
+ "pnpm": {
89
+ "overrides": {
90
+ "@nuxt/devtools": "npm:@nuxt/devtools-nightly@latest"
91
+ }
92
+ }
93
+ }
94
+ ```
95
+
96
+ </details>
97
+
62
98
  Remove lockfile (`package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`) and reinstall dependencies.
63
99
 
64
100
  ### Module Options
@@ -71,8 +107,8 @@ export default defineNuxtConfig({
71
107
  devtools: {
72
108
  // Enable devtools (default: true)
73
109
  enabled: true,
74
- // VS Code Server options
75
- vscode: {},
110
+ // Coder code-server options (enabled by default)
111
+ codeServer: {},
76
112
  // ...other options
77
113
  }
78
114
  })
@@ -98,6 +134,8 @@ Nuxt DevTools collects anonymous telemetry data about general usage. This helps
98
134
 
99
135
  Nuxt DevTools' telemetry data is piped through [Nuxt Telemetry](https://github.com/nuxt/telemetry), meaning that Nuxt DevTools will respect your local and global Nuxt Telemetry settings. You can also opt-out Nuxt DevTools' telemetry in the Nuxt DevTools settings.
100
136
 
137
+ Nuxt DevTools also respects the [`DO_NOT_TRACK`](https://donottrack.sh/) environment variable convention — set `DO_NOT_TRACK=1` in your environment to disable Nuxt DevTools telemetry regardless of any other setting.
138
+
101
139
  The data we collect is completely anonymous, not traceable to the source (using hash+seed), and only meaningful in aggregate form. No data we collect is personally identifiable or trackable.
102
140
 
103
141
  ### Events
package/dist/index.d.mts CHANGED
@@ -1,38 +1,277 @@
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 { M as ModuleCustomTab, N as NuxtDevtoolsInfo, S as SubprocessOptions, T as TerminalState } from './shared/devtools-kit-nightly.f1VcjZlm.mjs';
6
+ import { NuxtDevtoolsServerContext, ModuleCustomTab, NuxtDevtoolsInfo, SubprocessOptions, TerminalState } from './types.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 'nuxt/schema';
8
12
  import 'unimport';
9
13
  import 'vue-router';
10
- import 'nitropack';
11
14
  import 'unstorage';
12
15
  import 'vite';
16
+ import 'nitro/types';
17
+ import 'nitropack';
18
+
19
+ /**
20
+ * Canonical docs URL for a Nuxt DevTools diagnostic code.
21
+ *
22
+ * Each code links to a per-code anchor in the v4 migration guide, e.g.
23
+ * `NDT_DEP_0001` → `.../module/migration-v4#ndt_dep_0001`.
24
+ */
25
+ declare function diagnosticsDocsBase(code: string | number): string;
26
+ /**
27
+ * Parameters shared by every deprecation code: the API being used and its
28
+ * recommended replacement. Interpolated into the `why`/`fix` messages.
29
+ */
30
+ interface DeprecationParams {
31
+ /** The deprecated API / option being used. */
32
+ api: string;
33
+ /** The recommended replacement to migrate to. */
34
+ replacement: string;
35
+ }
36
+ /**
37
+ * The Nuxt DevTools diagnostics catalog.
38
+ *
39
+ * Codes are grouped by prefix:
40
+ * - `NDT_DEP_xxxx` — soft/hard deprecations (this is the only range used today).
41
+ *
42
+ * Severity is **not** encoded here; it is chosen per emission via the reporter
43
+ * `method` (`warn` by default, `error` for hard breaks).
44
+ */
45
+ declare const diagnosticCodes: {
46
+ /** `startSubprocess().getProcess()` → `getResult()`. */
47
+ NDT_DEP_0001: {
48
+ why: (p: DeprecationParams) => string;
49
+ fix: (p: DeprecationParams) => string;
50
+ };
51
+ /** `extendServerRpc` → `onDevtoolsReady((ctx) => ctx.rpc.register(...))`. */
52
+ NDT_DEP_0003: {
53
+ why: (p: DeprecationParams) => string;
54
+ fix: (p: DeprecationParams) => string;
55
+ };
56
+ /** `startSubprocess` → `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`. */
57
+ NDT_DEP_0004: {
58
+ why: (p: DeprecationParams) => string;
59
+ fix: (p: DeprecationParams) => string;
60
+ };
61
+ /** `addCustomTab` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
62
+ NDT_DEP_0005: {
63
+ why: (p: DeprecationParams) => string;
64
+ fix: (p: DeprecationParams) => string;
65
+ };
66
+ /** `refreshCustomTabs` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
67
+ NDT_DEP_0006: {
68
+ why: (p: DeprecationParams) => string;
69
+ fix: (p: DeprecationParams) => string;
70
+ };
71
+ /** Direct `nuxt.devtools.rpc` access (`broadcast` / `functions`). */
72
+ NDT_DEP_0007: {
73
+ why: (p: DeprecationParams) => string;
74
+ fix: (p: DeprecationParams) => string;
75
+ };
76
+ /** Removed `vscode` module option → `codeServer`. */
77
+ NDT_DEP_0008: {
78
+ why: (p: DeprecationParams) => string;
79
+ fix: (p: DeprecationParams) => string;
80
+ };
81
+ /** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
82
+ NDT_DEP_0009: {
83
+ why: (p: DeprecationParams) => string;
84
+ fix: (p: DeprecationParams) => string;
85
+ };
86
+ };
87
+ type NuxtDiagnosticCode = keyof typeof diagnosticCodes;
88
+ /**
89
+ * Standalone catalog that prints to the terminal via nostics'
90
+ * {@link createConsoleReporter} (default method `warn`). Works before the Vite
91
+ * DevTools kit connects, so it is the fallback sink for pre-connect emissions.
92
+ */
93
+ declare const consoleDiagnostics: nostics.Diagnostics<{
94
+ /** `startSubprocess().getProcess()` → `getResult()`. */
95
+ NDT_DEP_0001: {
96
+ why: (p: DeprecationParams) => string;
97
+ fix: (p: DeprecationParams) => string;
98
+ };
99
+ /** `extendServerRpc` → `onDevtoolsReady((ctx) => ctx.rpc.register(...))`. */
100
+ NDT_DEP_0003: {
101
+ why: (p: DeprecationParams) => string;
102
+ fix: (p: DeprecationParams) => string;
103
+ };
104
+ /** `startSubprocess` → `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`. */
105
+ NDT_DEP_0004: {
106
+ why: (p: DeprecationParams) => string;
107
+ fix: (p: DeprecationParams) => string;
108
+ };
109
+ /** `addCustomTab` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
110
+ NDT_DEP_0005: {
111
+ why: (p: DeprecationParams) => string;
112
+ fix: (p: DeprecationParams) => string;
113
+ };
114
+ /** `refreshCustomTabs` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
115
+ NDT_DEP_0006: {
116
+ why: (p: DeprecationParams) => string;
117
+ fix: (p: DeprecationParams) => string;
118
+ };
119
+ /** Direct `nuxt.devtools.rpc` access (`broadcast` / `functions`). */
120
+ NDT_DEP_0007: {
121
+ why: (p: DeprecationParams) => string;
122
+ fix: (p: DeprecationParams) => string;
123
+ };
124
+ /** Removed `vscode` module option → `codeServer`. */
125
+ NDT_DEP_0008: {
126
+ why: (p: DeprecationParams) => string;
127
+ fix: (p: DeprecationParams) => string;
128
+ };
129
+ /** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
130
+ NDT_DEP_0009: {
131
+ why: (p: DeprecationParams) => string;
132
+ fix: (p: DeprecationParams) => string;
133
+ };
134
+ }, readonly [nostics.DiagnosticReporter<{
135
+ method?: nostics.ConsoleMethod;
136
+ }, any>], never>;
137
+ /**
138
+ * Register the Nuxt deprecation codes into the connected Vite DevTools kit's
139
+ * diagnostics host so they are known to DevTools and post-connect emissions
140
+ * surface in the DevTools diagnostics UI. Safe to call when no host is present.
141
+ *
142
+ * Called from `connectDevToolsKit`.
143
+ */
144
+ declare function registerHostDiagnostics(ctx: NuxtDevtoolsServerContext): void;
145
+ /**
146
+ * Options for {@link deprecate}.
147
+ */
148
+ interface DeprecateOptions {
149
+ /**
150
+ * Dedupe key appended to the code. Defaults to the code itself, i.e. the
151
+ * deprecation warns once per process. Pass a finer key (e.g. a subprocess id)
152
+ * to warn once per distinct call site instead.
153
+ */
154
+ key?: string;
155
+ /**
156
+ * Reporter method / severity. `warn` (default) for soft deprecations, `error`
157
+ * for hard breaks. The returned {@link Diagnostic} can be thrown to abort.
158
+ */
159
+ method?: 'warn' | 'error';
160
+ }
161
+ /**
162
+ * Emit a Nuxt DevTools deprecation diagnostic.
163
+ *
164
+ * Routing: when the Vite DevTools kit is connected the emission goes through the
165
+ * DevTools host catalog (terminal **and** the DevTools diagnostics UI); before
166
+ * connect it falls back to the terminal-only console catalog. A single emission
167
+ * per call — no double printing.
168
+ *
169
+ * Deduped per `${code}:${key ?? code}` on the resolved server context, so a hot
170
+ * path warns only once.
171
+ *
172
+ * @returns the built `Diagnostic` (which extends `Error`, so it can be thrown
173
+ * for hard breaks), or `undefined` if the emission was deduped.
174
+ */
175
+ declare function deprecate(nuxt: Nuxt, code: NuxtDiagnosticCode, params: DeprecationParams, options?: DeprecateOptions): Error | undefined;
176
+ /**
177
+ * Build a standalone nostics catalog that prints to the terminal.
178
+ *
179
+ * Used by the connect-safe `nuxt.devtools.diagnostics` accessor so module
180
+ * authors can define + emit diagnostics before the Vite DevTools kit connects.
181
+ * A `createConsoleReporter()` is added automatically unless the caller supplies
182
+ * its own `reporters`.
183
+ */
184
+ declare function defineStandaloneDiagnostics(options: Parameters<typeof defineDiagnostics>[0]): ReturnType<typeof defineDiagnostics>;
185
+ /**
186
+ * Convenience wrapper for call sites that don't already hold the Nuxt instance.
187
+ */
188
+ declare function deprecateWithNuxt(code: NuxtDiagnosticCode, params: DeprecationParams, options?: DeprecateOptions): Error | undefined;
13
189
 
190
+ /**
191
+ * The public `Nuxt` dock group id registered on the Vite DevTools framework
192
+ * category. Module authors join the group natively by pointing their own
193
+ * dock entries at it — no special Nuxt API required:
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * import { NUXT_DEVTOOLS_GROUP_ID, onDevtoolsReady } from '@nuxt/devtools-kit'
198
+ *
199
+ * onDevtoolsReady((ctx) => {
200
+ * ctx.docks.register({
201
+ * id: 'my-module',
202
+ * type: 'iframe',
203
+ * title: 'My Module',
204
+ * icon: 'i-ph-puzzle-piece',
205
+ * url: '/my-module/',
206
+ * groupId: NUXT_DEVTOOLS_GROUP_ID,
207
+ * })
208
+ * })
209
+ * ```
210
+ */
211
+ declare const NUXT_DEVTOOLS_GROUP_ID = "nuxt";
14
212
  /**
15
213
  * Hooks to extend a custom tab in devtools.
16
214
  *
17
215
  * Provide a function to pass a factory that can be updated dynamically.
216
+ *
217
+ * @deprecated Register a dock entry from the `devtools:ready` hook instead:
218
+ * `onDevtoolsReady((ctx) => ctx.docks.register(...))`. Still works as a shim, but
219
+ * emits the `NDT_DEP_0005` deprecation diagnostic. Note the docks host does not
220
+ * yet cover `vnode` views or tab categories.
18
221
  */
19
222
  declare function addCustomTab(tab: ModuleCustomTab | (() => ModuleCustomTab | Promise<ModuleCustomTab>), nuxt?: _nuxt_schema.Nuxt): void;
20
223
  /**
21
224
  * Retrigger update for custom tabs, `devtools:customTabs` will be called again.
225
+ *
226
+ * @deprecated Update dock entries directly via the handle returned by
227
+ * `ctx.docks.register(...)` inside the `devtools:ready` hook. Still works as a
228
+ * shim, but emits the `NDT_DEP_0006` deprecation diagnostic.
22
229
  */
23
230
  declare function refreshCustomTabs(nuxt?: _nuxt_schema.Nuxt): void | Promise<any>;
24
- /**
25
- * Create a subprocess that handled by the DevTools.
26
- */
27
- declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): {
231
+ interface StartSubprocessReturn {
28
232
  /** @deprecated Use `getResult()` instead */
29
233
  getProcess: () => ChildProcess | undefined;
30
234
  getResult: () => Result;
31
235
  terminate: () => void;
32
236
  restart: () => void;
33
237
  clear: () => void;
34
- };
238
+ }
239
+ /**
240
+ * Create a subprocess that handled by the DevTools.
241
+ *
242
+ * @deprecated Use the Vite DevTools terminals host from the `devtools:ready`
243
+ * hook instead: `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`.
244
+ * Still works as a shim, but emits the `NDT_DEP_0004` deprecation diagnostic.
245
+ */
246
+ declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): StartSubprocessReturn;
247
+ /**
248
+ * Extend server RPC with namespaced functions.
249
+ *
250
+ * Returns an object with a `broadcast` proxy for calling client functions.
251
+ *
252
+ * @deprecated Register RPC functions from the `devtools:ready` hook instead:
253
+ * `onDevtoolsReady((ctx) => ctx.rpc.register(defineRpcFunction(...)))`. Still
254
+ * works as a shim, but emits the `NDT_DEP_0003` deprecation diagnostic.
255
+ */
35
256
  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>;
36
257
  declare function onDevToolsInitialized(fn: (info: NuxtDevtoolsInfo) => void, nuxt?: _nuxt_schema.Nuxt): void;
258
+ /**
259
+ * Run a callback once the Vite DevTools kit has connected, receiving the
260
+ * connected `ViteDevToolsNodeContext`.
261
+ *
262
+ * This is the recommended entry point for DevTools integration: the kit is
263
+ * guaranteed available, so you can use `ctx.docks` / `ctx.terminals` /
264
+ * `ctx.messages` / `ctx.commands` / `ctx.rpc` / `ctx.diagnostics` directly
265
+ * without the connect-safe accessors on `nuxt.devtools`.
266
+ *
267
+ * @example
268
+ * ```ts
269
+ * onDevtoolsReady((ctx) => {
270
+ * ctx.docks.register({ id: 'my-module', title: 'My Module', type: 'iframe', url: '/…' })
271
+ * })
272
+ * ```
273
+ */
274
+ declare function onDevtoolsReady(fn: (ctx: ViteDevToolsNodeContext) => void | Promise<void>, nuxt?: _nuxt_schema.Nuxt): void;
37
275
 
38
- export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };
276
+ export { NUXT_DEVTOOLS_GROUP_ID, addCustomTab, consoleDiagnostics, defineStandaloneDiagnostics, deprecate, deprecateWithNuxt, diagnosticCodes, diagnosticsDocsBase, extendServerRpc, onDevToolsInitialized, onDevtoolsReady, refreshCustomTabs, registerHostDiagnostics, startSubprocess };
277
+ export type { DeprecateOptions, DeprecationParams, NuxtDiagnosticCode, StartSubprocessReturn };
package/dist/index.mjs CHANGED
@@ -1,7 +1,126 @@
1
1
  import { useNuxt } from '@nuxt/kit';
2
2
  import { x } from 'tinyexec';
3
+ import { defineDiagnostics, createConsoleReporter } from 'nostics';
4
+ export { createConsoleReporter, defineDiagnostics } from 'nostics';
3
5
 
6
+ function diagnosticsDocsBase(code) {
7
+ return `https://devtools.nuxt.com/module/migration-v4#${String(code).toLowerCase()}`;
8
+ }
9
+ const diagnosticCodes = {
10
+ /** `startSubprocess().getProcess()` → `getResult()`. */
11
+ NDT_DEP_0001: {
12
+ why: (p) => `\`${p.api}\` is deprecated.`,
13
+ fix: (p) => `Use \`${p.replacement}\` instead.`
14
+ },
15
+ // NDT_DEP_0002 is retired (was `disableAuthorization`, now a supported
16
+ // first-class option). The code is left unused so numbers stay stable.
17
+ /** `extendServerRpc` → `onDevtoolsReady((ctx) => ctx.rpc.register(...))`. */
18
+ NDT_DEP_0003: {
19
+ why: (p) => `\`${p.api}\` is deprecated.`,
20
+ fix: (p) => `Use \`${p.replacement}\` instead.`
21
+ },
22
+ /** `startSubprocess` → `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`. */
23
+ NDT_DEP_0004: {
24
+ why: (p) => `\`${p.api}\` is deprecated.`,
25
+ fix: (p) => `Use \`${p.replacement}\` instead.`
26
+ },
27
+ /** `addCustomTab` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
28
+ NDT_DEP_0005: {
29
+ why: (p) => `\`${p.api}\` is deprecated.`,
30
+ fix: (p) => `Use \`${p.replacement}\` instead.`
31
+ },
32
+ /** `refreshCustomTabs` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
33
+ NDT_DEP_0006: {
34
+ why: (p) => `\`${p.api}\` is deprecated.`,
35
+ fix: (p) => `Use \`${p.replacement}\` instead.`
36
+ },
37
+ /** Direct `nuxt.devtools.rpc` access (`broadcast` / `functions`). */
38
+ NDT_DEP_0007: {
39
+ why: (p) => `\`${p.api}\` is deprecated.`,
40
+ fix: (p) => `Use \`${p.replacement}\` instead.`
41
+ },
42
+ /** Removed `vscode` module option → `codeServer`. */
43
+ NDT_DEP_0008: {
44
+ why: (p) => `\`${p.api}\` is deprecated and its legacy modes are no longer supported.`,
45
+ fix: (p) => `Use \`${p.replacement}\` instead. The legacy value is ignored rather than partially translated.`
46
+ },
47
+ /** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
48
+ NDT_DEP_0009: {
49
+ why: (p) => `\`${p.api}\` is deprecated.`,
50
+ fix: (p) => `Use \`${p.replacement}\` instead.`
51
+ }
52
+ };
53
+ const consoleDiagnostics = defineDiagnostics({
54
+ docsBase: diagnosticsDocsBase,
55
+ reporters: [
56
+ createConsoleReporter()
57
+ ],
58
+ codes: diagnosticCodes
59
+ });
60
+ const stateByCtx = /* @__PURE__ */ new WeakMap();
61
+ const fallbackState = {
62
+ emitted: /* @__PURE__ */ new Set()
63
+ };
64
+ function getState(ctx) {
65
+ if (!ctx)
66
+ return fallbackState;
67
+ let state = stateByCtx.get(ctx);
68
+ if (!state) {
69
+ state = {
70
+ emitted: /* @__PURE__ */ new Set()
71
+ };
72
+ stateByCtx.set(ctx, state);
73
+ }
74
+ return state;
75
+ }
76
+ function getServerContext(nuxt) {
77
+ return nuxt?.devtools;
78
+ }
79
+ function registerHostDiagnostics(ctx) {
80
+ const host = ctx.devtoolsKit?.diagnostics;
81
+ if (!host)
82
+ return;
83
+ const catalog = host.defineDiagnostics({
84
+ docsBase: diagnosticsDocsBase,
85
+ codes: diagnosticCodes
86
+ });
87
+ host.register(catalog);
88
+ getState(ctx).hostCatalog = catalog;
89
+ }
90
+ function deprecate(nuxt, code, params, options = {}) {
91
+ const ctx = getServerContext(nuxt);
92
+ const state = getState(ctx);
93
+ const dedupeKey = `${code}:${options.key ?? code}`;
94
+ if (state.emitted.has(dedupeKey))
95
+ return;
96
+ state.emitted.add(dedupeKey);
97
+ const method = options.method ?? "warn";
98
+ const hostHandle = state.hostCatalog?.[code];
99
+ if (hostHandle)
100
+ return hostHandle(params, { method });
101
+ const handle = consoleDiagnostics[code];
102
+ return handle(params, { method });
103
+ }
104
+ function defineStandaloneDiagnostics(options) {
105
+ return defineDiagnostics({
106
+ ...options,
107
+ reporters: options.reporters ?? [
108
+ createConsoleReporter()
109
+ ]
110
+ });
111
+ }
112
+ function deprecateWithNuxt(code, params, options) {
113
+ return deprecate(useNuxt(), code, params, options);
114
+ }
115
+
116
+ const NUXT_DEVTOOLS_GROUP_ID = "nuxt";
4
117
  function addCustomTab(tab, nuxt = useNuxt()) {
118
+ deprecate(nuxt, "NDT_DEP_0005", {
119
+ api: "addCustomTab",
120
+ replacement: "onDevtoolsReady((ctx) => ctx.docks.register(...))"
121
+ }, {
122
+ key: typeof tab === "function" ? void 0 : tab.name
123
+ });
5
124
  nuxt.hook("devtools:customTabs", async (tabs) => {
6
125
  if (typeof tab === "function")
7
126
  tab = await tab();
@@ -9,9 +128,17 @@ function addCustomTab(tab, nuxt = useNuxt()) {
9
128
  });
10
129
  }
11
130
  function refreshCustomTabs(nuxt = useNuxt()) {
131
+ deprecate(nuxt, "NDT_DEP_0006", {
132
+ api: "refreshCustomTabs",
133
+ replacement: "onDevtoolsReady((ctx) => ctx.docks.register(...).update(...))"
134
+ });
12
135
  return nuxt.callHook("devtools:customTabs:refresh");
13
136
  }
14
137
  function startSubprocess(execaOptions, tabOptions, nuxt = useNuxt()) {
138
+ deprecate(nuxt, "NDT_DEP_0004", {
139
+ api: "startSubprocess",
140
+ replacement: "onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))"
141
+ }, { key: tabOptions.id });
15
142
  const id = tabOptions.id;
16
143
  let restarting = false;
17
144
  function start() {
@@ -21,6 +148,7 @@ function startSubprocess(execaOptions, tabOptions, nuxt = useNuxt()) {
21
148
  {
22
149
  nodeOptions: {
23
150
  ...execaOptions.nodeOptions,
151
+ cwd: execaOptions.cwd ?? execaOptions.nodeOptions?.cwd,
24
152
  env: {
25
153
  ...process.env,
26
154
  COLORS: "true",
@@ -32,14 +160,23 @@ function startSubprocess(execaOptions, tabOptions, nuxt = useNuxt()) {
32
160
  }
33
161
  }
34
162
  );
35
- nuxt.callHook("devtools:terminal:write", { id, data: `> ${[execaOptions.command, ...execaOptions.args || []].join(" ")}
163
+ nuxt.callHook("devtools:terminal:write", { id, data: `> ${[
164
+ execaOptions.command,
165
+ ...execaOptions.args || []
166
+ ].join(" ")}
36
167
 
37
168
  ` });
38
169
  proc.process?.stdout?.on("data", (data) => {
39
- nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
170
+ nuxt.callHook("devtools:terminal:write", {
171
+ id,
172
+ data: data.toString()
173
+ });
40
174
  });
41
175
  proc.process?.stderr?.on("data", (data) => {
42
- nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
176
+ nuxt.callHook("devtools:terminal:write", {
177
+ id,
178
+ data: data.toString()
179
+ });
43
180
  });
44
181
  proc.process?.on("exit", (code) => {
45
182
  if (!restarting) {
@@ -86,7 +223,10 @@ function startSubprocess(execaOptions, tabOptions, nuxt = useNuxt()) {
86
223
  return {
87
224
  /** @deprecated Use `getResult()` instead */
88
225
  getProcess: () => {
89
- console.warn("[nuxt-devtools] `getProcess()` is deprecated, use `getResult()` instead.");
226
+ deprecate(nuxt, "NDT_DEP_0001", {
227
+ api: "startSubprocess().getProcess()",
228
+ replacement: "getResult()"
229
+ }, { key: id });
90
230
  return result.process;
91
231
  },
92
232
  getResult: () => result,
@@ -104,8 +244,11 @@ function extendServerRpc(namespace, functions, nuxt = useNuxt()) {
104
244
  function onDevToolsInitialized(fn, nuxt = useNuxt()) {
105
245
  nuxt.hook("devtools:initialized", fn);
106
246
  }
247
+ function onDevtoolsReady(fn, nuxt = useNuxt()) {
248
+ nuxt.hook("devtools:ready", fn);
249
+ }
107
250
  function _getContext(nuxt = useNuxt()) {
108
251
  return nuxt?.devtools;
109
252
  }
110
253
 
111
- export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };
254
+ export { NUXT_DEVTOOLS_GROUP_ID, addCustomTab, consoleDiagnostics, defineStandaloneDiagnostics, deprecate, deprecateWithNuxt, diagnosticCodes, diagnosticsDocsBase, extendServerRpc, onDevToolsInitialized, onDevtoolsReady, refreshCustomTabs, registerHostDiagnostics, startSubprocess };
@@ -0,0 +1,25 @@
1
+ import { Ref } from 'vue';
2
+ import '../shared/devtools-kit-nightly.CtfaEBN3.mjs';
3
+ import { NuxtDevtoolsHostClient } from '../types.mjs';
4
+ import '@vitejs/devtools-kit';
5
+ import 'birpc';
6
+ import 'nuxt/schema';
7
+ import 'unimport';
8
+ import 'vue-router';
9
+ import 'unstorage';
10
+ import 'vite';
11
+ import '@nuxt/schema';
12
+ import 'nitro/types';
13
+ import 'nitropack';
14
+ import 'node:child_process';
15
+ import '@vitejs/devtools-kit/client';
16
+ import 'hookable';
17
+ import 'nuxt/app';
18
+ import 'ofetch';
19
+ import 'shiki';
20
+ import 'error-stack-parser-es';
21
+
22
+ declare function onDevtoolsHostClientConnected(fn: (client: NuxtDevtoolsHostClient) => void): (() => void) | undefined;
23
+ declare function useDevtoolsHostClient(): Ref<NuxtDevtoolsHostClient | undefined>;
24
+
25
+ export { onDevtoolsHostClientConnected, useDevtoolsHostClient };
@@ -1,7 +1,8 @@
1
- import { shallowRef } from "vue";
1
+ import { shallowRef } from 'vue';
2
+
2
3
  let clientRef;
3
4
  const fns = [];
4
- export function onDevtoolsHostClientConnected(fn) {
5
+ function onDevtoolsHostClientConnected(fn) {
5
6
  fns.push(fn);
6
7
  if (typeof window === "undefined")
7
8
  return;
@@ -22,7 +23,7 @@ export function onDevtoolsHostClientConnected(fn) {
22
23
  fns.splice(fns.indexOf(fn), 1);
23
24
  };
24
25
  }
25
- export function useDevtoolsHostClient() {
26
+ function useDevtoolsHostClient() {
26
27
  if (!clientRef) {
27
28
  clientRef = shallowRef();
28
29
  onDevtoolsHostClientConnected(setup);
@@ -32,3 +33,5 @@ export function useDevtoolsHostClient() {
32
33
  }
33
34
  return clientRef;
34
35
  }
36
+
37
+ export { onDevtoolsHostClientConnected, useDevtoolsHostClient };
@@ -0,0 +1,42 @@
1
+ import { DevToolsRpcClient } from '@vitejs/devtools-kit/client';
2
+ import { Ref } from 'vue';
3
+ import '../shared/devtools-kit-nightly.CtfaEBN3.mjs';
4
+ import { NuxtDevtoolsIframeClient } from '../types.mjs';
5
+ import '@vitejs/devtools-kit';
6
+ import 'birpc';
7
+ import 'nuxt/schema';
8
+ import 'unimport';
9
+ import 'vue-router';
10
+ import 'unstorage';
11
+ import 'vite';
12
+ import '@nuxt/schema';
13
+ import 'nitro/types';
14
+ import 'nitropack';
15
+ import 'node:child_process';
16
+ import 'hookable';
17
+ import 'nuxt/app';
18
+ import 'ofetch';
19
+ import 'shiki';
20
+ import 'error-stack-parser-es';
21
+
22
+ declare function onDevtoolsClientConnected(fn: (client: NuxtDevtoolsIframeClient) => void): (() => void) | undefined;
23
+ /**
24
+ * Run a callback once the Vite DevTools client is ready, receiving the connected
25
+ * `DevToolsRpcClient` — the client-side mirror of the server's
26
+ * `onDevtoolsReady((ctx) => …)`.
27
+ *
28
+ * This is the recommended way to do client-side DevTools integration (register
29
+ * client RPC functions, call server functions, shared state, streaming, …):
30
+ *
31
+ * ```ts
32
+ * import { onDevtoolsReady } from '@nuxt/devtools-kit/iframe-client'
33
+ *
34
+ * onDevtoolsReady((kit) => {
35
+ * kit.client.register({ name: 'my-module:on-update', type: 'event', handler })
36
+ * })
37
+ * ```
38
+ */
39
+ declare function onDevtoolsReady(fn: (kit: DevToolsRpcClient) => void): (() => void) | undefined;
40
+ declare function useDevtoolsClient(): Ref<NuxtDevtoolsIframeClient | undefined, NuxtDevtoolsIframeClient | undefined>;
41
+
42
+ export { onDevtoolsClientConnected, onDevtoolsReady, useDevtoolsClient };