@nuxt/devtools-kit 4.0.0-alpha.1 → 4.0.0-alpha.11

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.
@@ -1,15 +1,17 @@
1
+ import { DevToolsMessageLevel, DevToolsMessageFilePosition, ViteDevToolsNodeContext } from '@vitejs/devtools-kit';
1
2
  import { VNode, MaybeRefOrGetter } from 'vue';
2
3
  import { BirpcGroup } from 'birpc';
3
- import { Component, NuxtOptions, NuxtPage, NuxtLayout, NuxtApp, NuxtDebugModuleMutationRecord, Nuxt } from 'nuxt/schema';
4
+ import { Component, NuxtOptions, NuxtPage, NuxtLayout, NuxtApp, Nuxt, NuxtDebugModuleMutationRecord } from 'nuxt/schema';
4
5
  import { Import, UnimportMeta } from 'unimport';
5
6
  import { RouteRecordNormalized } from 'vue-router';
6
- import { Nitro, StorageMounts } from 'nitropack';
7
7
  import { StorageValue } from 'unstorage';
8
8
  import { ResolvedConfig } from 'vite';
9
9
  import { NuxtAnalyzeMeta } from '@nuxt/schema';
10
+ import { Nitro as Nitro$1, StorageMounts as StorageMounts$1 } from 'nitro/types';
11
+ import { Nitro, StorageMounts } from 'nitropack';
10
12
  import { SpawnOptions } from 'node:child_process';
11
13
 
12
- type TabCategory = 'pinned' | 'app' | 'vue-devtools' | 'analyze' | 'server' | 'modules' | 'documentation' | 'advanced';
14
+ type TabCategory = 'pinned' | 'app' | 'analyze' | 'server' | 'modules' | 'documentation' | 'advanced';
13
15
 
14
16
  interface ModuleCustomTab {
15
17
  /**
@@ -129,6 +131,7 @@ interface ModuleBuiltinTab {
129
131
  title?: string;
130
132
  path?: string;
131
133
  category?: TabCategory;
134
+ defaultOrder?: number;
132
135
  show?: () => MaybeRefOrGetter<any>;
133
136
  badge?: () => MaybeRefOrGetter<number | string | undefined>;
134
137
  onClick?: () => void;
@@ -136,6 +139,51 @@ interface ModuleBuiltinTab {
136
139
  type ModuleTabInfo = ModuleCustomTab | ModuleBuiltinTab;
137
140
  type CategorizedTabs = [TabCategory, (ModuleCustomTab | ModuleBuiltinTab)[]][];
138
141
 
142
+ /**
143
+ * Severity level of a notification, mirroring devframe's message levels.
144
+ *
145
+ * Determines the color/icon of the entry in the Vite DevTools **Messages** dock
146
+ * and its toast.
147
+ */
148
+ type NuxtDevtoolsNotifyLevel = DevToolsMessageLevel;
149
+ /**
150
+ * A Nuxt-friendly subset of devframe's `DevframeMessageEntryInput`.
151
+ *
152
+ * This is the input accepted by the `devtools:notify` Nuxt hook, the `notify`
153
+ * RPC function and the injected client's `notify()` — all of which forward to
154
+ * the connected `ctx.messages` host so notifications flow through the single
155
+ * devframe Messages system (persistent dock list + toast overlay).
156
+ *
157
+ * Tiers are expressed through the flags below:
158
+ * - **Ephemeral** (toast-only feedback like "Copied!"): `notify: true` with an
159
+ * `autoDismiss` (toast lifetime) and `autoDelete` (entry lifetime) so it never
160
+ * builds up history in the Messages dock.
161
+ * - **Persistent** (server-originated, leveled): omit `autoDelete` so the entry
162
+ * is kept in the Messages dock list.
163
+ */
164
+ interface NuxtDevtoolsNotifyInput {
165
+ /** Short title / summary of the message. */
166
+ message: string;
167
+ /** Severity level. Defaults to `'info'`. */
168
+ level?: NuxtDevtoolsNotifyLevel;
169
+ /** Optional detailed description or explanation. */
170
+ description?: string;
171
+ /** Optional tags/labels for filtering in the Messages dock. */
172
+ labels?: string[];
173
+ /** Optional grouping category (e.g. `'build'`, `'lint'`, `'runtime'`). */
174
+ category?: string;
175
+ /** Optional source file position (e.g. for a build/lint error). */
176
+ filePosition?: DevToolsMessageFilePosition;
177
+ /** Optional stack trace string. */
178
+ stacktrace?: string;
179
+ /** Whether this message should also appear as a transient toast. */
180
+ notify?: boolean;
181
+ /** Time in ms to auto-dismiss the toast (client-side). */
182
+ autoDismiss?: number;
183
+ /** Time in ms to auto-delete the entry from the persistent list (server-side). */
184
+ autoDelete?: number;
185
+ }
186
+
139
187
  interface HookInfo {
140
188
  name: string;
141
189
  start: number;
@@ -337,13 +385,8 @@ interface ComponentWithRelationships {
337
385
  dependencies?: string[];
338
386
  dependents?: string[];
339
387
  }
340
- interface CodeServerOptions {
341
- codeBinary: string;
342
- launchArg: string;
343
- licenseTermsArg: string;
344
- connectionTokenArg: string;
345
- }
346
388
 
389
+ /** @deprecated Part of the removed `vscode` integration. */
347
390
  type CodeServerType = 'ms-code-cli' | 'ms-code-server' | 'coder-code-server';
348
391
  interface ModuleOptions {
349
392
  /**
@@ -358,8 +401,12 @@ interface ModuleOptions {
358
401
  * This is in static format, for dynamic injection, call `nuxt.hook('devtools:customTabs')` instead
359
402
  */
360
403
  customTabs?: ModuleCustomTab[];
404
+ /** Code Server integration options. */
405
+ codeServer?: CodeServerIntegrationOptions;
361
406
  /**
362
- * VS Code Server integration options.
407
+ * Legacy VS Code Server integration options.
408
+ *
409
+ * @deprecated Use `codeServer`. Legacy modes are no longer supported.
363
410
  */
364
411
  vscode?: VSCodeIntegrationOptions;
365
412
  /**
@@ -369,22 +416,32 @@ interface ModuleOptions {
369
416
  */
370
417
  componentInspector?: boolean;
371
418
  /**
372
- * Enable Vue DevTools integration
419
+ * Enable the Vite Inspect integration.
420
+ *
421
+ * `vite-plugin-inspect` is an optional peer dependency. When it isn't
422
+ * installed, DevTools shows an install launcher in its place (like Vite Plus
423
+ * DevTools); once installed, the real Inspect view is mounted. Set this to
424
+ * `false` to disable the integration (and its launcher) entirely.
425
+ *
426
+ * @default true
373
427
  */
374
- vueDevTools?: boolean;
428
+ viteInspect?: boolean;
375
429
  /**
376
- * Enable vite-plugin-inspect
430
+ * Enable the Data Inspector integration, which registers the live
431
+ * `Nuxt Application` data source and mounts the Data Inspector panel.
377
432
  *
378
433
  * @default true
379
434
  */
380
- viteInspect?: boolean;
435
+ dataInspector?: boolean;
381
436
  /**
382
- * Disable dev time authorization check.
437
+ * Disable the DevTools client authorization prompt, allowing any browser to
438
+ * connect without approving it first.
383
439
  *
384
- * **NOT RECOMMENDED**, only use this if you know what you are doing.
440
+ * Defaults to `true` in sandboxed environments (StackBlitz, CodeSandbox).
385
441
  *
386
- * @see https://github.com/nuxt/devtools/pull/257
387
- * @default false
442
+ * Note: disabling authorization lets any browser (including other devices, if
443
+ * you expose the dev server to your LAN/WAN) connect to DevTools and access
444
+ * your server and filesystem. Only disable it in trusted environments.
388
445
  */
389
446
  disableAuthorization?: boolean;
390
447
  /**
@@ -446,6 +503,31 @@ interface ModuleOptions {
446
503
  */
447
504
  telemetry?: boolean;
448
505
  }
506
+ interface CodeServerIntegrationOptions {
507
+ /**
508
+ * Enable the Code Server integration.
509
+ *
510
+ * @default true
511
+ */
512
+ enabled?: boolean;
513
+ /** Path or command name for Coder's `code-server` binary. */
514
+ bin?: string;
515
+ /** Workspace opened by Code Server. Defaults to the Nuxt root directory. */
516
+ cwd?: string;
517
+ /** Port for the Code Server process. Defaults to the plugin's free-port behavior. */
518
+ serverPort?: number;
519
+ /** Host for the Code Server process. Defaults to the plugin's loopback host. */
520
+ host?: string;
521
+ /** Additional safe arguments passed to `code-server`. */
522
+ args?: string[];
523
+ /** Additional safe environment variables passed to `code-server`. */
524
+ env?: Record<string, string>;
525
+ /** Suffix used to isolate the authenticated Code Server session cookie. */
526
+ cookieSuffix?: string;
527
+ /** Milliseconds to wait for Code Server to become ready. */
528
+ startTimeout?: number;
529
+ }
530
+ /** @deprecated Use {@link CodeServerIntegrationOptions}. */
449
531
  interface VSCodeIntegrationOptions {
450
532
  /**
451
533
  * Enable VS Code Server integration
@@ -491,6 +573,7 @@ interface VSCodeIntegrationOptions {
491
573
  */
492
574
  host?: string;
493
575
  }
576
+ /** @deprecated Tunnels are not supported by the Code Server integration. */
494
577
  interface VSCodeTunnelOptions {
495
578
  /**
496
579
  * the machine name for port forwarding service
@@ -513,13 +596,10 @@ interface NuxtDevToolsOptions {
513
596
  componentsView: 'list' | 'graph';
514
597
  hiddenTabCategories: string[];
515
598
  hiddenTabs: string[];
516
- interactionCloseOnOutsideClick: boolean;
517
599
  pinnedTabs: string[];
518
600
  scale: number;
519
601
  showExperimentalFeatures: boolean;
520
602
  showHelpButtons: boolean;
521
- sidebarExpanded: boolean;
522
- sidebarScrollable: boolean;
523
603
  };
524
604
  serverRoutes: {
525
605
  selectedRoute: ServerRouteInfo | null;
@@ -551,56 +631,38 @@ interface AnalyzeBuildMeta extends NuxtAnalyzeMeta {
551
631
  }
552
632
  interface AnalyzeBuildsInfo {
553
633
  isBuilding: boolean;
554
- builds: AnalyzeBuildMeta[];
555
- }
556
-
557
- interface TerminalBase {
558
- id: string;
559
- name: string;
560
- description?: string;
561
- icon?: string;
562
- }
563
- type TerminalAction = 'restart' | 'terminate' | 'clear' | 'remove';
564
- interface SubprocessOptions {
565
- command: string;
566
- args?: string[];
567
- cwd?: string;
568
- env?: Record<string, string | undefined>;
569
- nodeOptions?: SpawnOptions;
570
- }
571
- interface TerminalInfo extends TerminalBase {
572
- /**
573
- * Whether the terminal can be restarted
574
- */
575
- restartable?: boolean;
576
- /**
577
- * Whether the terminal can be terminated
578
- */
579
- terminatable?: boolean;
580
- /**
581
- * Whether the terminal is terminated
582
- */
583
- isTerminated?: boolean;
584
- /**
585
- * Content buffer
586
- */
587
- buffer?: string;
588
- }
589
- interface TerminalState extends TerminalInfo {
590
- /**
591
- * User action to restart the terminal, when not provided, this action will be disabled
592
- */
593
- onActionRestart?: () => Promise<void> | void;
594
634
  /**
595
- * User action to terminate the terminal, when not provided, this action will be disabled
635
+ * Unique id of the terminal session for the build currently in flight, or
636
+ * `undefined` when idle. The client reveals this session and derives its
637
+ * "Building…" state from it instead of an `onTerminalExit` broadcast.
596
638
  */
597
- onActionTerminate?: () => Promise<void> | void;
639
+ activeSessionId?: string;
640
+ builds: AnalyzeBuildMeta[];
598
641
  }
599
642
 
643
+ /**
644
+ * `nitropack` (Nitro v2) and `nitro` (Nitro v3) are both declared as *optional*
645
+ * peer dependencies, so a consumer only ever has one installed (Nuxt 4 →
646
+ * `nitropack`, Nuxt 5 → `nitro`). A missing peer resolves its `import type` to
647
+ * `any`, which would collapse a naive `V2 | V3` union to `any`. Detect which
648
+ * package actually resolved — `keyof any` matches every key, so probing an
649
+ * impossible `'___INVALID'` key tells a real Nitro type from the `any`
650
+ * fallback — and resolve to just that one. Mirrors `@nuxt/kit`'s own detection.
651
+ */
652
+ type HasNitroV2 = 'options' extends keyof Nitro ? ('___INVALID' extends keyof Nitro ? false : true) : false;
653
+ type HasNitroV3 = 'options' extends keyof Nitro$1 ? ('___INVALID' extends keyof Nitro$1 ? false : true) : false;
654
+ type AnyNitro = HasNitroV2 extends true ? (HasNitroV3 extends true ? Nitro | Nitro$1 : Nitro) : Nitro$1;
655
+ type AnyStorageMounts = HasNitroV2 extends true ? (HasNitroV3 extends true ? StorageMounts | StorageMounts$1 : StorageMounts) : StorageMounts$1;
656
+
600
657
  interface ServerFunctions {
601
658
  getServerConfig: () => NuxtOptions;
602
659
  getServerDebugContext: () => Promise<ServerDebugContext | undefined>;
603
- getServerData: (token: string) => Promise<NuxtServerData>;
660
+ /**
661
+ * @deprecated Replaced by the Data Inspector panel's live `Nuxt Application`
662
+ * source. Kept as a compatibility shim (emits `NDT_DEP_0009`) for one
663
+ * migration window and will be removed in a future major.
664
+ */
665
+ getServerData: () => Promise<NuxtServerData>;
604
666
  getServerRuntimeConfig: () => Record<string, any>;
605
667
  getModuleOptions: () => ModuleOptions;
606
668
  getComponents: () => Component[];
@@ -619,53 +681,60 @@ interface ServerFunctions {
619
681
  clearOptions: () => Promise<void>;
620
682
  checkForUpdateFor: (name: string) => Promise<PackageUpdateInfo | undefined>;
621
683
  getNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<string[] | undefined>;
622
- runNpmCommand: (token: string, command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{
684
+ runNpmCommand: (command: NpmCommandType, packageName: string, options?: NpmCommandOptions) => Promise<{
623
685
  processId: string;
624
686
  } | undefined>;
625
- getTerminals: () => TerminalInfo[];
626
- getTerminalDetail: (token: string, id: string) => Promise<TerminalInfo | undefined>;
627
- runTerminalAction: (token: string, id: string, action: TerminalAction) => Promise<boolean>;
628
- getStorageMounts: () => Promise<StorageMounts>;
687
+ revealTerminal: (id: string) => Promise<boolean>;
688
+ getStorageMounts: () => Promise<AnyStorageMounts>;
629
689
  getStorageKeys: (base?: string) => Promise<string[]>;
630
- getStorageItem: (token: string, key: string) => Promise<StorageValue>;
631
- setStorageItem: (token: string, key: string, value: StorageValue) => Promise<void>;
632
- removeStorageItem: (token: string, key: string) => Promise<void>;
690
+ getStorageItem: (key: string) => Promise<StorageValue>;
691
+ setStorageItem: (key: string, value: StorageValue) => Promise<void>;
692
+ removeStorageItem: (key: string) => Promise<void>;
633
693
  getAnalyzeBuildInfo: () => Promise<AnalyzeBuildsInfo>;
634
694
  generateAnalyzeBuildName: () => Promise<string>;
635
- startAnalyzeBuild: (token: string, name: string) => Promise<string>;
636
- clearAnalyzeBuilds: (token: string, names?: string[]) => Promise<void>;
637
- getImageMeta: (token: string, filepath: string) => Promise<ImageMeta | undefined>;
638
- getTextAssetContent: (token: string, filepath: string, limit?: number) => Promise<string | undefined>;
639
- writeStaticAssets: (token: string, file: AssetEntry[], folder: string) => Promise<string[]>;
640
- deleteStaticAsset: (token: string, filepath: string) => Promise<void>;
641
- renameStaticAsset: (token: string, oldPath: string, newPath: string) => Promise<void>;
695
+ startAnalyzeBuild: (name: string) => Promise<string>;
696
+ clearAnalyzeBuilds: (names?: string[]) => Promise<void>;
697
+ getImageMeta: (filepath: string) => Promise<ImageMeta | undefined>;
698
+ getTextAssetContent: (filepath: string, limit?: number) => Promise<string | undefined>;
699
+ writeStaticAssets: (file: AssetEntry[], folder: string) => Promise<string[]>;
700
+ deleteStaticAsset: (filepath: string) => Promise<void>;
701
+ renameStaticAsset: (oldPath: string, newPath: string) => Promise<void>;
702
+ notify: (input: NuxtDevtoolsNotifyInput) => Promise<void>;
642
703
  telemetryEvent: (payload: object, immediate?: boolean) => void;
643
704
  customTabAction: (name: string, action: number) => Promise<boolean>;
644
- enablePages: (token: string) => Promise<void>;
705
+ enablePages: () => Promise<void>;
645
706
  openInEditor: (filepath: string) => Promise<boolean>;
646
- restartNuxt: (token: string, hard?: boolean) => Promise<void>;
647
- installNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>;
648
- uninstallNuxtModule: (token: string, name: string, dry?: boolean) => Promise<InstallModuleReturn>;
707
+ restartNuxt: (hard?: boolean) => Promise<void>;
708
+ installNuxtModule: (name: string, dry?: boolean, sessionId?: string) => Promise<InstallModuleReturn>;
709
+ uninstallNuxtModule: (name: string, dry?: boolean, sessionId?: string) => Promise<InstallModuleReturn>;
649
710
  enableTimeline: (dry: boolean) => Promise<[string, string]>;
650
711
  requestForAuth: (info?: string, origin?: string) => Promise<void>;
651
- verifyAuthToken: (token: string) => Promise<boolean>;
712
+ verifyAuthToken: () => Promise<boolean>;
652
713
  }
653
714
  interface ClientFunctions {
654
715
  refresh: (event: ClientUpdateEvent) => void;
655
716
  callHook: (hook: string, ...args: any[]) => Promise<void>;
656
717
  navigateTo: (path: string) => void;
657
- onTerminalData: (_: {
658
- id: string;
659
- data: string;
660
- }) => void;
718
+ /**
719
+ * Minimal server→client completion signal for generic package updates only
720
+ * (`runNpmCommand`): the run RPC returns before the process exits, so this
721
+ * lets `usePackageUpdate` and the restart prompt settle once it finishes. It
722
+ * carries only `{ id, code }` and is not a terminal-data transport. Module
723
+ * install/uninstall and analyze-build no longer rely on it — they clear their
724
+ * UI from the awaited RPC / refreshed info instead.
725
+ */
661
726
  onTerminalExit: (_: {
662
727
  id: string;
663
728
  code?: number;
664
729
  }) => void;
665
730
  }
731
+ /**
732
+ * @deprecated The payload of the deprecated {@link ServerFunctions.getServerData}
733
+ * shim. Use the Data Inspector panel's live `Nuxt Application` source instead.
734
+ */
666
735
  interface NuxtServerData {
667
736
  nuxt: NuxtOptions;
668
- nitro?: Nitro['options'];
737
+ nitro?: AnyNitro['options'];
669
738
  vite: {
670
739
  server?: ResolvedConfig;
671
740
  client?: ResolvedConfig;
@@ -673,13 +742,44 @@ interface NuxtServerData {
673
742
  }
674
743
  type ClientUpdateEvent = keyof ServerFunctions;
675
744
 
745
+ /**
746
+ * Legacy Nuxt DevTools RPC compatibility surface exposed on `nuxt.devtools.rpc`.
747
+ *
748
+ * For new integrations prefer {@link onDevtoolsReady}, where the connected
749
+ * `ViteDevToolsNodeContext` gives you the full devframe `ctx.rpc`
750
+ * (`register`/`invokeLocal`/`broadcast`/`sharedState`/…).
751
+ */
752
+ interface NuxtDevtoolsRpc {
753
+ /**
754
+ * Broadcast proxy for calling client functions.
755
+ * Supports `rpc.broadcast.refresh.asEvent(event)` for backward compatibility.
756
+ */
757
+ broadcast: {
758
+ [K in keyof ClientFunctions]: ClientFunctions[K] & {
759
+ asEvent: ClientFunctions[K];
760
+ };
761
+ };
762
+ /**
763
+ * Proxy for reading/writing server functions locally.
764
+ */
765
+ functions: ServerFunctions;
766
+ }
676
767
  /**
677
768
  * @internal
678
769
  */
679
770
  interface NuxtDevtoolsServerContext {
680
771
  nuxt: Nuxt;
681
772
  options: ModuleOptions;
682
- rpc: BirpcGroup<ClientFunctions, ServerFunctions>;
773
+ rpc: NuxtDevtoolsRpc;
774
+ /**
775
+ * The connected Vite DevTools kit context (`docks`/`terminals`/`messages`/
776
+ * `commands`/`rpc`/`diagnostics`/…).
777
+ *
778
+ * This is the raw escape hatch and is `undefined` until the Vite DevTools
779
+ * plugin connects. Prefer {@link onDevtoolsReady}, which hands you the
780
+ * connected context.
781
+ */
782
+ devtoolsKit: ViteDevToolsNodeContext | undefined;
683
783
  /**
684
784
  * Hook to open file in editor
685
785
  */
@@ -689,9 +789,18 @@ interface NuxtDevtoolsServerContext {
689
789
  */
690
790
  refresh: (event: keyof ServerFunctions) => void;
691
791
  /**
692
- * Ensure dev auth token is valid, throw if not
792
+ * Push a notification through the devframe Messages system (`ctx.messages`).
793
+ *
794
+ * The connected messages host surfaces it in the Vite DevTools **Messages**
795
+ * dock and/or as a toast. Calls made before the kit connects are buffered and
796
+ * replayed on connect. Used by the `devtools:notify` hook, the `notify` RPC
797
+ * function and the curated built-in notification sources.
798
+ */
799
+ notify: (input: NuxtDevtoolsNotifyInput) => void;
800
+ /**
801
+ * @deprecated Use the Vite DevTools RPC registration instead:
802
+ * `nuxt.devtools.rpc.register(defineRpcFunction(...))`. Kept working as a shim.
693
803
  */
694
- ensureDevAuthToken: (token: string) => Promise<void>;
695
804
  extendServerRpc: <ClientFunctions extends object = Record<string, unknown>, ServerFunctions extends object = Record<string, unknown>>(name: string, functions: ServerFunctions) => BirpcGroup<ClientFunctions, ServerFunctions>;
696
805
  }
697
806
  interface NuxtDevtoolsInfo {
@@ -711,6 +820,64 @@ interface ServerDebugContext {
711
820
  moduleMutationRecords: ServerDebugModuleMutationRecord[];
712
821
  }
713
822
 
823
+ interface TerminalBase {
824
+ id: string;
825
+ name: string;
826
+ description?: string;
827
+ icon?: string;
828
+ }
829
+ type TerminalAction = 'restart' | 'terminate' | 'clear' | 'remove';
830
+ interface SubprocessOptions {
831
+ command: string;
832
+ args?: string[];
833
+ cwd?: string;
834
+ env?: Record<string, string | undefined>;
835
+ nodeOptions?: SpawnOptions;
836
+ }
837
+ interface TerminalInfo extends TerminalBase {
838
+ /**
839
+ * Whether the terminal can be restarted.
840
+ *
841
+ * @deprecated Ignored since v4: legacy terminals are bridged onto the built-in
842
+ * Terminals dock as read-only, output-only sessions, so Devframe shows no
843
+ * restart control. Restart a `startSubprocess()`-owned process through its
844
+ * returned handle instead. Will be removed in v5.
845
+ */
846
+ restartable?: boolean;
847
+ /**
848
+ * Whether the terminal can be terminated.
849
+ *
850
+ * @deprecated Ignored since v4 (see {@link TerminalInfo.restartable}). Will be
851
+ * removed in v5.
852
+ */
853
+ terminatable?: boolean;
854
+ /**
855
+ * Whether the terminal is terminated
856
+ */
857
+ isTerminated?: boolean;
858
+ /**
859
+ * Content buffer
860
+ */
861
+ buffer?: string;
862
+ }
863
+ interface TerminalState extends TerminalInfo {
864
+ /**
865
+ * User action to restart the terminal, when not provided, this action will be disabled.
866
+ *
867
+ * @deprecated Ignored since v4: the bridge to the built-in Terminals dock
868
+ * cannot attach action callbacks to an externally registered session. Will be
869
+ * removed in v5.
870
+ */
871
+ onActionRestart?: () => Promise<void> | void;
872
+ /**
873
+ * User action to terminate the terminal, when not provided, this action will be disabled.
874
+ *
875
+ * @deprecated Ignored since v4 (see {@link TerminalState.onActionRestart}).
876
+ * Will be removed in v5.
877
+ */
878
+ onActionTerminate?: () => Promise<void> | void;
879
+ }
880
+
714
881
  declare module '@nuxt/schema' {
715
882
  interface NuxtHooks {
716
883
  /**
@@ -721,6 +888,30 @@ declare module '@nuxt/schema' {
721
888
  * Called after devtools is initialized.
722
889
  */
723
890
  'devtools:initialized': (info: NuxtDevtoolsInfo) => void;
891
+ /**
892
+ * Called once the Vite DevTools kit has connected, with the connected
893
+ * `ViteDevToolsNodeContext`.
894
+ *
895
+ * This is the recommended place to do all DevTools integration
896
+ * (registering docks, terminals, messages, commands, RPC functions,
897
+ * diagnostics, …): the kit is guaranteed to be available here, so you don't
898
+ * need the connect-safe accessors on `nuxt.devtools`.
899
+ */
900
+ 'devtools:ready': (ctx: ViteDevToolsNodeContext) => void | Promise<void>;
901
+ /**
902
+ * Push a notification through the devframe Messages system.
903
+ *
904
+ * Forwarded to the connected `ctx.messages` host, so it surfaces in the
905
+ * Vite DevTools **Messages** dock (persistent, when leveled) and/or as a
906
+ * transient toast (when `notify` is set). Calls made before the kit connects
907
+ * are buffered and replayed once it does.
908
+ *
909
+ * @example
910
+ * ```ts
911
+ * nuxt.callHook('devtools:notify', { message: 'Build failed', level: 'error' })
912
+ * ```
913
+ */
914
+ 'devtools:notify': (input: NuxtDevtoolsNotifyInput) => void;
724
915
  /**
725
916
  * Hooks to extend devtools tabs.
726
917
  */
@@ -730,7 +921,11 @@ declare module '@nuxt/schema' {
730
921
  */
731
922
  'devtools:customTabs:refresh': () => void;
732
923
  /**
733
- * Register a terminal.
924
+ * Register a terminal whose process is owned by the caller (module).
925
+ *
926
+ * The registered session is surfaced **read-only** in the built-in Vite
927
+ * DevTools **Terminals** dock; stream output into it via
928
+ * `devtools:terminal:write`.
734
929
  */
735
930
  'devtools:terminal:register': (terminal: TerminalState) => void;
736
931
  /**
@@ -759,19 +954,5 @@ declare module '@nuxt/schema' {
759
954
  }) => void;
760
955
  }
761
956
  }
762
- declare module '@nuxt/schema' {
763
- /**
764
- * Runtime Hooks
765
- */
766
- interface RuntimeNuxtHooks {
767
- /**
768
- * On terminal data.
769
- */
770
- 'devtools:terminal:data': (payload: {
771
- id: string;
772
- data: string;
773
- }) => void;
774
- }
775
- }
776
957
 
777
- export type { ServerDebugContext as $, AnalyzeBuildMeta as A, BasicModuleInfo as B, ClientFunctions as C, ModuleTabInfo as D, ModuleType as E, ModuleVNodeView as F, GitHubContributor as G, HookInfo as H, ImageMeta as I, ModuleView as J, NpmCommandOptions as K, LoadingTimeMetric as L, ModuleCustomTab as M, NuxtDevtoolsInfo as N, NpmCommandType as O, PluginMetric as P, NuxtDevToolsOptions as Q, NuxtDevtoolsServerContext as R, SubprocessOptions as S, TerminalState as T, NuxtServerData as U, PackageManagerName as V, PackageUpdateInfo as W, Payload as X, PluginInfoWithMetic as Y, RouteInfo as Z, ScannedNitroTasks as _, ServerFunctions as a, ServerDebugModuleMutationRecord as a0, ServerRouteInfo as a1, ServerRouteInput as a2, ServerRouteInputType as a3, ServerTaskInfo as a4, TabCategory as a5, TerminalAction as a6, TerminalBase as a7, TerminalInfo as a8, VSCodeIntegrationOptions as a9, VSCodeTunnelOptions as aa, VueInspectorClient as ab, VueInspectorData as ac, AnalyzeBuildsInfo as b, AssetEntry as c, AssetInfo as d, AssetType as e, AutoImportsWithMetadata as f, CategorizedTabs as g, ClientUpdateEvent as h, CodeServerOptions as i, CodeServerType as j, CodeSnippet as k, CompatibilityStatus as l, ComponentRelationship as m, ComponentWithRelationships as n, InstallModuleReturn as o, InstalledModuleInfo as p, MaintainerInfo as q, ModuleBuiltinTab as r, ModuleCompatibility as s, ModuleIframeTabLazyOptions as t, ModuleIframeView as u, ModuleLaunchAction as v, ModuleLaunchView as w, ModuleOptions as x, ModuleStaticInfo as y, ModuleStats as z };
958
+ export type { PluginInfoWithMetic as $, AnalyzeBuildMeta as A, BasicModuleInfo as B, CategorizedTabs as C, ModuleStaticInfo as D, ModuleStats as E, ModuleTabInfo as F, GitHubContributor as G, HookInfo as H, ImageMeta as I, ModuleType as J, ModuleVNodeView as K, LoadingTimeMetric as L, ModuleCustomTab as M, NuxtDevtoolsServerContext as N, ModuleView as O, PluginMetric as P, NpmCommandOptions as Q, NpmCommandType as R, SubprocessOptions as S, TerminalState as T, NuxtDevToolsOptions as U, NuxtDevtoolsNotifyLevel as V, NuxtDevtoolsRpc as W, NuxtServerData as X, PackageManagerName as Y, PackageUpdateInfo as Z, Payload as _, NuxtDevtoolsInfo as a, RouteInfo as a0, ScannedNitroTasks as a1, ServerDebugContext as a2, ServerDebugModuleMutationRecord as a3, ServerRouteInfo as a4, ServerRouteInput as a5, ServerRouteInputType as a6, ServerTaskInfo as a7, TabCategory as a8, TerminalAction as a9, TerminalBase as aa, TerminalInfo as ab, VSCodeIntegrationOptions as ac, VSCodeTunnelOptions as ad, VueInspectorClient as ae, VueInspectorData as af, ServerFunctions as b, NuxtDevtoolsNotifyInput as c, AnalyzeBuildsInfo as d, AssetEntry as e, AssetInfo as f, AssetType as g, AutoImportsWithMetadata as h, ClientFunctions as i, ClientUpdateEvent as j, CodeServerIntegrationOptions as k, CodeServerType as l, CodeSnippet as m, CompatibilityStatus as n, ComponentRelationship as o, ComponentWithRelationships as p, InstallModuleReturn as q, InstalledModuleInfo as r, MaintainerInfo as s, ModuleBuiltinTab as t, ModuleCompatibility as u, ModuleIframeTabLazyOptions as v, ModuleIframeView as w, ModuleLaunchAction as x, ModuleLaunchView as y, ModuleOptions as z };
package/dist/types.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as ServerFunctions, C as ClientFunctions, H as HookInfo, P as PluginMetric, L as LoadingTimeMetric } from './shared/devtools-kit.f1VcjZlm.cjs';
2
- export { A as AnalyzeBuildMeta, b as AnalyzeBuildsInfo, c as AssetEntry, d as AssetInfo, e as AssetType, f as AutoImportsWithMetadata, B as BasicModuleInfo, g as CategorizedTabs, h as ClientUpdateEvent, i as CodeServerOptions, j as CodeServerType, k as CodeSnippet, l as CompatibilityStatus, m as ComponentRelationship, n as ComponentWithRelationships, G as GitHubContributor, I as ImageMeta, o as InstallModuleReturn, p as InstalledModuleInfo, q as MaintainerInfo, r as ModuleBuiltinTab, s as ModuleCompatibility, M as ModuleCustomTab, t as ModuleIframeTabLazyOptions, u as ModuleIframeView, v as ModuleLaunchAction, w as ModuleLaunchView, x as ModuleOptions, y as ModuleStaticInfo, z as ModuleStats, D as ModuleTabInfo, E as ModuleType, F as ModuleVNodeView, J as ModuleView, K as NpmCommandOptions, O as NpmCommandType, Q as NuxtDevToolsOptions, N as NuxtDevtoolsInfo, R as NuxtDevtoolsServerContext, U as NuxtServerData, V as PackageManagerName, W as PackageUpdateInfo, X as Payload, Y as PluginInfoWithMetic, Z as RouteInfo, _ as ScannedNitroTasks, $ as ServerDebugContext, a0 as ServerDebugModuleMutationRecord, a1 as ServerRouteInfo, a2 as ServerRouteInput, a3 as ServerRouteInputType, a4 as ServerTaskInfo, S as SubprocessOptions, a5 as TabCategory, a6 as TerminalAction, a7 as TerminalBase, a8 as TerminalInfo, T as TerminalState, a9 as VSCodeIntegrationOptions, aa as VSCodeTunnelOptions, ab as VueInspectorClient, ac as VueInspectorData } from './shared/devtools-kit.f1VcjZlm.cjs';
3
- import { BirpcReturn } from 'birpc';
1
+ import { b as ServerFunctions, c as NuxtDevtoolsNotifyInput, H as HookInfo, P as PluginMetric, L as LoadingTimeMetric } from './shared/devtools-kit.ClPv9w-a.cjs';
2
+ export { A as AnalyzeBuildMeta, d as AnalyzeBuildsInfo, e as AssetEntry, f as AssetInfo, g as AssetType, h as AutoImportsWithMetadata, B as BasicModuleInfo, C as CategorizedTabs, i as ClientFunctions, j as ClientUpdateEvent, k as CodeServerIntegrationOptions, l as CodeServerType, m as CodeSnippet, n as CompatibilityStatus, o as ComponentRelationship, p as ComponentWithRelationships, G as GitHubContributor, I as ImageMeta, q as InstallModuleReturn, r as InstalledModuleInfo, s as MaintainerInfo, t as ModuleBuiltinTab, u as ModuleCompatibility, M as ModuleCustomTab, v as ModuleIframeTabLazyOptions, w as ModuleIframeView, x as ModuleLaunchAction, y as ModuleLaunchView, z as ModuleOptions, D as ModuleStaticInfo, E as ModuleStats, F as ModuleTabInfo, J as ModuleType, K as ModuleVNodeView, O as ModuleView, Q as NpmCommandOptions, R as NpmCommandType, U as NuxtDevToolsOptions, a as NuxtDevtoolsInfo, V as NuxtDevtoolsNotifyLevel, W as NuxtDevtoolsRpc, N as NuxtDevtoolsServerContext, X as NuxtServerData, Y as PackageManagerName, Z as PackageUpdateInfo, _ as Payload, $ as PluginInfoWithMetic, a0 as RouteInfo, a1 as ScannedNitroTasks, a2 as ServerDebugContext, a3 as ServerDebugModuleMutationRecord, a4 as ServerRouteInfo, a5 as ServerRouteInput, a6 as ServerRouteInputType, a7 as ServerTaskInfo, S as SubprocessOptions, a8 as TabCategory, a9 as TerminalAction, aa as TerminalBase, ab as TerminalInfo, T as TerminalState, ac as VSCodeIntegrationOptions, ad as VSCodeTunnelOptions, ae as VueInspectorClient, af as VueInspectorData } from './shared/devtools-kit.ClPv9w-a.cjs';
3
+ import { DevToolsRpcClient } from '@vitejs/devtools-kit/client';
4
4
  import { Hookable } from 'hookable';
5
5
  import { NuxtApp } from 'nuxt/app';
6
6
  import { AppConfig } from 'nuxt/schema';
@@ -8,12 +8,15 @@ import { $Fetch } from 'ofetch';
8
8
  import { BuiltinLanguage } from 'shiki';
9
9
  import { Ref } from 'vue';
10
10
  import { StackFrame } from 'error-stack-parser-es';
11
+ import '@vitejs/devtools-kit';
12
+ import 'birpc';
11
13
  import 'unimport';
12
14
  import 'vue-router';
13
- import 'nitropack';
14
15
  import 'unstorage';
15
16
  import 'vite';
16
17
  import '@nuxt/schema';
18
+ import 'nitro/types';
19
+ import 'nitropack';
17
20
  import 'node:child_process';
18
21
 
19
22
  interface TimelineEventFunction {
@@ -149,15 +152,41 @@ interface NuxtDevtoolsHostClient {
149
152
  interface CodeHighlightOptions {
150
153
  grammarContextCode?: string;
151
154
  }
155
+ type AsyncServerFunctions = {
156
+ [K in keyof ServerFunctions]: (...args: Parameters<ServerFunctions[K]>) => Promise<Awaited<ReturnType<ServerFunctions[K]>>>;
157
+ };
152
158
  interface NuxtDevtoolsClient {
153
- rpc: BirpcReturn<ServerFunctions, ClientFunctions>;
159
+ rpc: AsyncServerFunctions;
154
160
  renderCodeHighlight: (code: string, lang?: BuiltinLanguage, options?: CodeHighlightOptions) => {
155
161
  code: string;
156
162
  supported: boolean;
157
163
  };
158
164
  renderMarkdown: (markdown: string) => string;
159
165
  colorMode: string;
160
- extendClientRpc: <ServerFunctions extends object = Record<string, unknown>, ClientFunctions extends object = Record<string, unknown>>(name: string, functions: ClientFunctions) => BirpcReturn<ServerFunctions, ClientFunctions>;
166
+ /**
167
+ * Push a notification through the devframe Messages system.
168
+ *
169
+ * Routes to the shared Messages host, so it surfaces in the Vite DevTools
170
+ * **Messages** dock and/or as a transient toast (when `notify` is set — the
171
+ * default). Use this from custom tabs / in-client code to give feedback
172
+ * through the same notification system as the rest of DevTools.
173
+ */
174
+ notify: (input: NuxtDevtoolsNotifyInput) => Promise<void>;
175
+ /**
176
+ * The connected Vite DevTools RPC client, mirroring `nuxt.devtools.devtoolsKit`
177
+ * on the server. Use it for full devframe-native access — register client RPC
178
+ * functions (`devtoolsKit.client.register(...)`), call server functions
179
+ * (`devtoolsKit.call(...)`), shared state, streaming, scoping, etc.
180
+ *
181
+ * `undefined` until the DevTools client has connected.
182
+ */
183
+ devtoolsKit: DevToolsRpcClient | undefined;
184
+ /**
185
+ * @deprecated Use `onDevtoolsReady((kit) => kit.client.register(...))` from
186
+ * `@nuxt/devtools-kit/iframe-client`, or the exposed `devtoolsKit` client
187
+ * directly (`client.devtools.devtoolsKit?.client.register(...)`).
188
+ */
189
+ extendClientRpc: <ServerFunctions extends object = Record<string, unknown>, ClientFunctions extends object = Record<string, unknown>>(name: string, functions: ClientFunctions) => ServerFunctions;
161
190
  }
162
191
  interface NuxtDevtoolsIframeClient {
163
192
  host: NuxtDevtoolsHostClient;
@@ -167,5 +196,5 @@ interface NuxtDevtoolsGlobal {
167
196
  setClient: (client: NuxtDevtoolsHostClient) => void;
168
197
  }
169
198
 
170
- export { ClientFunctions, HookInfo, LoadingTimeMetric, PluginMetric, ServerFunctions };
171
- export type { CodeHighlightOptions, DevToolsFrameState, NuxtDevtoolsClient, NuxtDevtoolsClientHooks, NuxtDevtoolsGlobal, NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient, TimelineEvent, TimelineEventFunction, TimelineEventNormalized, TimelineEventRoute, TimelineEventsSegment, TimelineMetrics, TimelineOptions, TimelineServerState };
199
+ export { HookInfo, LoadingTimeMetric, NuxtDevtoolsNotifyInput, PluginMetric, ServerFunctions };
200
+ export type { AsyncServerFunctions, CodeHighlightOptions, DevToolsFrameState, NuxtDevtoolsClient, NuxtDevtoolsClientHooks, NuxtDevtoolsGlobal, NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient, TimelineEvent, TimelineEventFunction, TimelineEventNormalized, TimelineEventRoute, TimelineEventsSegment, TimelineMetrics, TimelineOptions, TimelineServerState };