@nuxt/devtools-kit 4.0.0-alpha.11 → 4.0.0-alpha.13
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/runtime/host-client.d.mts +7 -0
- package/dist/runtime/host-client.mjs +6 -3
- package/dist/runtime/iframe-client.d.mts +42 -0
- package/dist/runtime/iframe-client.mjs +7 -7
- package/dist/shared/{devtools-kit.ClPv9w-a.d.cts → devtools-kit.BmlL8jmc.d.mts} +0 -4
- package/dist/types.d.mts +3 -24
- package/package.json +10 -26
- package/dist/index.cjs +0 -251
- package/dist/index.d.cts +0 -277
- package/dist/index.d.ts +0 -277
- package/dist/runtime/host-client.d.ts +0 -4
- package/dist/runtime/iframe-client.d.ts +0 -22
- package/dist/shared/devtools-kit.ClPv9w-a.d.mts +0 -958
- package/dist/shared/devtools-kit.ClPv9w-a.d.ts +0 -958
- package/dist/types.cjs +0 -2
- package/dist/types.d.cts +0 -200
- package/dist/types.d.ts +0 -200
- package/host-client.d.ts +0 -1
- package/host-client.mjs +0 -1
- package/iframe-client.d.ts +0 -1
- package/iframe-client.mjs +0 -1
- package/types.d.ts +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NuxtDevtoolsHostClient } from '@nuxt/devtools-kit/types';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
declare function onDevtoolsHostClientConnected(fn: (client: NuxtDevtoolsHostClient) => void): (() => void) | undefined;
|
|
5
|
+
declare function useDevtoolsHostClient(): Ref<NuxtDevtoolsHostClient | undefined>;
|
|
6
|
+
|
|
7
|
+
export { onDevtoolsHostClientConnected, useDevtoolsHostClient };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { shallowRef } from
|
|
1
|
+
import { shallowRef } from 'vue';
|
|
2
|
+
|
|
2
3
|
let clientRef;
|
|
3
4
|
const fns = [];
|
|
4
|
-
|
|
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
|
-
|
|
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.BmlL8jmc.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 };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { shallowRef, triggerRef } from
|
|
1
|
+
import { shallowRef, triggerRef } from 'vue';
|
|
2
|
+
|
|
2
3
|
let clientRef;
|
|
3
|
-
const hasSetup = false;
|
|
4
4
|
const fns = [];
|
|
5
|
-
|
|
5
|
+
function onDevtoolsClientConnected(fn) {
|
|
6
6
|
fns.push(fn);
|
|
7
|
-
if (hasSetup)
|
|
8
|
-
return;
|
|
9
7
|
if (typeof window === "undefined")
|
|
10
8
|
return;
|
|
11
9
|
if (window.__NUXT_DEVTOOLS__) {
|
|
@@ -25,14 +23,14 @@ export function onDevtoolsClientConnected(fn) {
|
|
|
25
23
|
fns.splice(fns.indexOf(fn), 1);
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
|
-
|
|
26
|
+
function onDevtoolsReady(fn) {
|
|
29
27
|
return onDevtoolsClientConnected((client) => {
|
|
30
28
|
const kit = client.devtools.devtoolsKit;
|
|
31
29
|
if (kit)
|
|
32
30
|
fn(kit);
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
|
-
|
|
33
|
+
function useDevtoolsClient() {
|
|
36
34
|
if (!clientRef) {
|
|
37
35
|
clientRef = shallowRef();
|
|
38
36
|
onDevtoolsClientConnected(setup);
|
|
@@ -49,3 +47,5 @@ export function useDevtoolsClient() {
|
|
|
49
47
|
}
|
|
50
48
|
return clientRef;
|
|
51
49
|
}
|
|
50
|
+
|
|
51
|
+
export { onDevtoolsClientConnected, onDevtoolsReady, useDevtoolsClient };
|
|
@@ -444,10 +444,6 @@ interface ModuleOptions {
|
|
|
444
444
|
* your server and filesystem. Only disable it in trusted environments.
|
|
445
445
|
*/
|
|
446
446
|
disableAuthorization?: boolean;
|
|
447
|
-
/**
|
|
448
|
-
* Props for the iframe element, useful for environment with stricter CSP
|
|
449
|
-
*/
|
|
450
|
-
iframeProps?: Record<string, string | boolean>;
|
|
451
447
|
/**
|
|
452
448
|
* Experimental features
|
|
453
449
|
*/
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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.
|
|
1
|
+
import { H as HookInfo, P as PluginMetric, L as LoadingTimeMetric, b as ServerFunctions, c as NuxtDevtoolsNotifyInput } from './shared/devtools-kit.BmlL8jmc.mjs';
|
|
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.BmlL8jmc.mjs';
|
|
3
3
|
import { DevToolsRpcClient } from '@vitejs/devtools-kit/client';
|
|
4
4
|
import { Hookable } from 'hookable';
|
|
5
5
|
import { NuxtApp } from 'nuxt/app';
|
|
@@ -67,17 +67,6 @@ interface TimelineEventsSegment {
|
|
|
67
67
|
previousGap?: number;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
interface DevToolsFrameState {
|
|
71
|
-
width: number;
|
|
72
|
-
height: number;
|
|
73
|
-
top: number;
|
|
74
|
-
left: number;
|
|
75
|
-
open: boolean;
|
|
76
|
-
route: string;
|
|
77
|
-
position: 'left' | 'right' | 'bottom' | 'top';
|
|
78
|
-
closeOnOutsideClick: boolean;
|
|
79
|
-
minimizePanelInactive: number;
|
|
80
|
-
}
|
|
81
70
|
interface NuxtDevtoolsClientHooks {
|
|
82
71
|
/**
|
|
83
72
|
* When the DevTools navigates, used for persisting the current tab
|
|
@@ -110,7 +99,6 @@ interface NuxtDevtoolsClientHooks {
|
|
|
110
99
|
interface NuxtDevtoolsHostClient {
|
|
111
100
|
nuxt: NuxtApp;
|
|
112
101
|
hooks: Hookable<NuxtDevtoolsClientHooks>;
|
|
113
|
-
getIframe: () => HTMLIFrameElement | undefined;
|
|
114
102
|
inspector?: {
|
|
115
103
|
enable: () => void;
|
|
116
104
|
disable: () => void;
|
|
@@ -130,7 +118,6 @@ interface NuxtDevtoolsHostClient {
|
|
|
130
118
|
navigate: (path: string, hard?: boolean) => void;
|
|
131
119
|
appConfig: AppConfig;
|
|
132
120
|
colorMode: Ref<'dark' | 'light'>;
|
|
133
|
-
frameState: Ref<DevToolsFrameState>;
|
|
134
121
|
$fetch: $Fetch;
|
|
135
122
|
};
|
|
136
123
|
metrics: {
|
|
@@ -143,11 +130,6 @@ interface NuxtDevtoolsHostClient {
|
|
|
143
130
|
* A counter to trigger reactivity updates
|
|
144
131
|
*/
|
|
145
132
|
revision: Ref<number>;
|
|
146
|
-
/**
|
|
147
|
-
* Update client
|
|
148
|
-
* @internal
|
|
149
|
-
*/
|
|
150
|
-
syncClient: () => NuxtDevtoolsHostClient;
|
|
151
133
|
}
|
|
152
134
|
interface CodeHighlightOptions {
|
|
153
135
|
grammarContextCode?: string;
|
|
@@ -192,9 +174,6 @@ interface NuxtDevtoolsIframeClient {
|
|
|
192
174
|
host: NuxtDevtoolsHostClient;
|
|
193
175
|
devtools: NuxtDevtoolsClient;
|
|
194
176
|
}
|
|
195
|
-
interface NuxtDevtoolsGlobal {
|
|
196
|
-
setClient: (client: NuxtDevtoolsHostClient) => void;
|
|
197
|
-
}
|
|
198
177
|
|
|
199
178
|
export { HookInfo, LoadingTimeMetric, NuxtDevtoolsNotifyInput, PluginMetric, ServerFunctions };
|
|
200
|
-
export type { AsyncServerFunctions, CodeHighlightOptions,
|
|
179
|
+
export type { AsyncServerFunctions, CodeHighlightOptions, NuxtDevtoolsClient, NuxtDevtoolsClientHooks, NuxtDevtoolsHostClient, NuxtDevtoolsIframeClient, TimelineEvent, TimelineEventFunction, TimelineEventNormalized, TimelineEventRoute, TimelineEventsSegment, TimelineMetrics, TimelineOptions, TimelineServerState };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/devtools-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.13",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://devtools.nuxt.com/module/utils-kit",
|
|
7
7
|
"repository": {
|
|
@@ -10,34 +10,18 @@
|
|
|
10
10
|
"directory": "packages/devtools-kit"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
|
-
".":
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
"./types": {
|
|
19
|
-
"types": "./types.d.ts",
|
|
20
|
-
"import": "./dist/types.mjs",
|
|
21
|
-
"require": "./dist/types.cjs"
|
|
22
|
-
},
|
|
23
|
-
"./iframe-client": {
|
|
24
|
-
"types": "./iframe-client.d.ts",
|
|
25
|
-
"import": "./iframe-client.mjs"
|
|
26
|
-
},
|
|
27
|
-
"./host-client": {
|
|
28
|
-
"types": "./host-client.d.ts",
|
|
29
|
-
"import": "./host-client.mjs"
|
|
30
|
-
}
|
|
13
|
+
".": "./dist/index.mjs",
|
|
14
|
+
"./types": "./dist/types.mjs",
|
|
15
|
+
"./iframe-client": "./dist/runtime/iframe-client.mjs",
|
|
16
|
+
"./host-client": "./dist/runtime/host-client.mjs"
|
|
31
17
|
},
|
|
32
|
-
"main": "./dist/index.
|
|
33
|
-
"types": "./dist/index.d.
|
|
18
|
+
"main": "./dist/index.mjs",
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
34
20
|
"files": [
|
|
35
|
-
"*.cjs",
|
|
36
|
-
"*.d.ts",
|
|
37
|
-
"*.mjs",
|
|
38
21
|
"dist"
|
|
39
22
|
],
|
|
40
23
|
"peerDependencies": {
|
|
24
|
+
"@nuxt/kit": "^4.0.0-0 || ^5.0.0-0",
|
|
41
25
|
"nitro": "^3.0.0-0",
|
|
42
26
|
"nitropack": "^2.0.0",
|
|
43
27
|
"vite": ">=6.0"
|
|
@@ -51,13 +35,13 @@
|
|
|
51
35
|
}
|
|
52
36
|
},
|
|
53
37
|
"dependencies": {
|
|
54
|
-
"@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-29755283.b4586ef2",
|
|
55
38
|
"nostics": "^1.2.0",
|
|
56
39
|
"tinyexec": "^1.3.0"
|
|
57
40
|
},
|
|
58
41
|
"devDependencies": {
|
|
42
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-29755283.b4586ef2",
|
|
59
43
|
"@nuxt/schema": "npm:@nuxt/schema-nightly@5.0.0-29755283.b4586ef2",
|
|
60
|
-
"birpc": "^4.
|
|
44
|
+
"birpc": "^4.2.0",
|
|
61
45
|
"error-stack-parser-es": "^2.0.1",
|
|
62
46
|
"hookable": "^6.1.1",
|
|
63
47
|
"nitro": "^3.0.260610-beta",
|
package/dist/index.cjs
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const kit = require('@nuxt/kit');
|
|
4
|
-
const tinyexec = require('tinyexec');
|
|
5
|
-
const nostics = require('nostics');
|
|
6
|
-
|
|
7
|
-
function diagnosticsDocsBase(code) {
|
|
8
|
-
return `https://devtools.nuxt.com/module/migration-v4#${String(code).toLowerCase()}`;
|
|
9
|
-
}
|
|
10
|
-
const diagnosticCodes = {
|
|
11
|
-
/** `startSubprocess().getProcess()` → `getResult()`. */
|
|
12
|
-
NDT_DEP_0001: {
|
|
13
|
-
why: (p) => `\`${p.api}\` is deprecated.`,
|
|
14
|
-
fix: (p) => `Use \`${p.replacement}\` instead.`
|
|
15
|
-
},
|
|
16
|
-
// NDT_DEP_0002 is retired (was `disableAuthorization`, now a supported
|
|
17
|
-
// first-class option). The code is left unused so numbers stay stable.
|
|
18
|
-
/** `extendServerRpc` → `onDevtoolsReady((ctx) => ctx.rpc.register(...))`. */
|
|
19
|
-
NDT_DEP_0003: {
|
|
20
|
-
why: (p) => `\`${p.api}\` is deprecated.`,
|
|
21
|
-
fix: (p) => `Use \`${p.replacement}\` instead.`
|
|
22
|
-
},
|
|
23
|
-
/** `startSubprocess` → `onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))`. */
|
|
24
|
-
NDT_DEP_0004: {
|
|
25
|
-
why: (p) => `\`${p.api}\` is deprecated.`,
|
|
26
|
-
fix: (p) => `Use \`${p.replacement}\` instead.`
|
|
27
|
-
},
|
|
28
|
-
/** `addCustomTab` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
|
|
29
|
-
NDT_DEP_0005: {
|
|
30
|
-
why: (p) => `\`${p.api}\` is deprecated.`,
|
|
31
|
-
fix: (p) => `Use \`${p.replacement}\` instead.`
|
|
32
|
-
},
|
|
33
|
-
/** `refreshCustomTabs` → `onDevtoolsReady((ctx) => ctx.docks.register(...))`. */
|
|
34
|
-
NDT_DEP_0006: {
|
|
35
|
-
why: (p) => `\`${p.api}\` is deprecated.`,
|
|
36
|
-
fix: (p) => `Use \`${p.replacement}\` instead.`
|
|
37
|
-
},
|
|
38
|
-
/** Direct `nuxt.devtools.rpc` access (`broadcast` / `functions`). */
|
|
39
|
-
NDT_DEP_0007: {
|
|
40
|
-
why: (p) => `\`${p.api}\` is deprecated.`,
|
|
41
|
-
fix: (p) => `Use \`${p.replacement}\` instead.`
|
|
42
|
-
},
|
|
43
|
-
/** Removed `vscode` module option → `codeServer`. */
|
|
44
|
-
NDT_DEP_0008: {
|
|
45
|
-
why: (p) => `\`${p.api}\` is deprecated and its legacy modes are no longer supported.`,
|
|
46
|
-
fix: (p) => `Use \`${p.replacement}\` instead. The legacy value is ignored rather than partially translated.`
|
|
47
|
-
},
|
|
48
|
-
/** `getServerData()` RPC → the Data Inspector panel's `Nuxt Application` source. */
|
|
49
|
-
NDT_DEP_0009: {
|
|
50
|
-
why: (p) => `\`${p.api}\` is deprecated.`,
|
|
51
|
-
fix: (p) => `Use \`${p.replacement}\` instead.`
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const consoleDiagnostics = nostics.defineDiagnostics({
|
|
55
|
-
docsBase: diagnosticsDocsBase,
|
|
56
|
-
reporters: [nostics.createConsoleReporter()],
|
|
57
|
-
codes: diagnosticCodes
|
|
58
|
-
});
|
|
59
|
-
const stateByCtx = /* @__PURE__ */ new WeakMap();
|
|
60
|
-
const fallbackState = { emitted: /* @__PURE__ */ new Set() };
|
|
61
|
-
function getState(ctx) {
|
|
62
|
-
if (!ctx)
|
|
63
|
-
return fallbackState;
|
|
64
|
-
let state = stateByCtx.get(ctx);
|
|
65
|
-
if (!state) {
|
|
66
|
-
state = { emitted: /* @__PURE__ */ new Set() };
|
|
67
|
-
stateByCtx.set(ctx, state);
|
|
68
|
-
}
|
|
69
|
-
return state;
|
|
70
|
-
}
|
|
71
|
-
function getServerContext(nuxt) {
|
|
72
|
-
return nuxt?.devtools;
|
|
73
|
-
}
|
|
74
|
-
function registerHostDiagnostics(ctx) {
|
|
75
|
-
const host = ctx.devtoolsKit?.diagnostics;
|
|
76
|
-
if (!host)
|
|
77
|
-
return;
|
|
78
|
-
const catalog = host.defineDiagnostics({
|
|
79
|
-
docsBase: diagnosticsDocsBase,
|
|
80
|
-
codes: diagnosticCodes
|
|
81
|
-
});
|
|
82
|
-
host.register(catalog);
|
|
83
|
-
getState(ctx).hostCatalog = catalog;
|
|
84
|
-
}
|
|
85
|
-
function deprecate(nuxt, code, params, options = {}) {
|
|
86
|
-
const ctx = getServerContext(nuxt);
|
|
87
|
-
const state = getState(ctx);
|
|
88
|
-
const dedupeKey = `${code}:${options.key ?? code}`;
|
|
89
|
-
if (state.emitted.has(dedupeKey))
|
|
90
|
-
return;
|
|
91
|
-
state.emitted.add(dedupeKey);
|
|
92
|
-
const method = options.method ?? "warn";
|
|
93
|
-
const hostHandle = state.hostCatalog?.[code];
|
|
94
|
-
if (hostHandle)
|
|
95
|
-
return hostHandle(params, { method });
|
|
96
|
-
const handle = consoleDiagnostics[code];
|
|
97
|
-
return handle(params, { method });
|
|
98
|
-
}
|
|
99
|
-
function defineStandaloneDiagnostics(options) {
|
|
100
|
-
return nostics.defineDiagnostics({
|
|
101
|
-
...options,
|
|
102
|
-
reporters: options.reporters ?? [nostics.createConsoleReporter()]
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function deprecateWithNuxt(code, params, options) {
|
|
106
|
-
return deprecate(kit.useNuxt(), code, params, options);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const NUXT_DEVTOOLS_GROUP_ID = "nuxt";
|
|
110
|
-
function addCustomTab(tab, nuxt = kit.useNuxt()) {
|
|
111
|
-
deprecate(nuxt, "NDT_DEP_0005", {
|
|
112
|
-
api: "addCustomTab",
|
|
113
|
-
replacement: "onDevtoolsReady((ctx) => ctx.docks.register(...))"
|
|
114
|
-
}, { key: typeof tab === "function" ? void 0 : tab.name });
|
|
115
|
-
nuxt.hook("devtools:customTabs", async (tabs) => {
|
|
116
|
-
if (typeof tab === "function")
|
|
117
|
-
tab = await tab();
|
|
118
|
-
tabs.push(tab);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function refreshCustomTabs(nuxt = kit.useNuxt()) {
|
|
122
|
-
deprecate(nuxt, "NDT_DEP_0006", {
|
|
123
|
-
api: "refreshCustomTabs",
|
|
124
|
-
replacement: "onDevtoolsReady((ctx) => ctx.docks.register(...).update(...))"
|
|
125
|
-
});
|
|
126
|
-
return nuxt.callHook("devtools:customTabs:refresh");
|
|
127
|
-
}
|
|
128
|
-
function startSubprocess(execaOptions, tabOptions, nuxt = kit.useNuxt()) {
|
|
129
|
-
deprecate(nuxt, "NDT_DEP_0004", {
|
|
130
|
-
api: "startSubprocess",
|
|
131
|
-
replacement: "onDevtoolsReady((ctx) => ctx.terminals.startChildProcess(...))"
|
|
132
|
-
}, { key: tabOptions.id });
|
|
133
|
-
const id = tabOptions.id;
|
|
134
|
-
let restarting = false;
|
|
135
|
-
function start() {
|
|
136
|
-
const proc = tinyexec.x(
|
|
137
|
-
execaOptions.command,
|
|
138
|
-
execaOptions.args,
|
|
139
|
-
{
|
|
140
|
-
nodeOptions: {
|
|
141
|
-
...execaOptions.nodeOptions,
|
|
142
|
-
cwd: execaOptions.cwd ?? execaOptions.nodeOptions?.cwd,
|
|
143
|
-
env: {
|
|
144
|
-
...process.env,
|
|
145
|
-
COLORS: "true",
|
|
146
|
-
FORCE_COLOR: "true",
|
|
147
|
-
...execaOptions.env,
|
|
148
|
-
...execaOptions.nodeOptions?.env,
|
|
149
|
-
__CLI_ARGV__: void 0
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
nuxt.callHook("devtools:terminal:write", { id, data: `> ${[execaOptions.command, ...execaOptions.args || []].join(" ")}
|
|
155
|
-
|
|
156
|
-
` });
|
|
157
|
-
proc.process?.stdout?.on("data", (data) => {
|
|
158
|
-
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
|
|
159
|
-
});
|
|
160
|
-
proc.process?.stderr?.on("data", (data) => {
|
|
161
|
-
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
|
|
162
|
-
});
|
|
163
|
-
proc.process?.on("exit", (code) => {
|
|
164
|
-
if (!restarting) {
|
|
165
|
-
nuxt.callHook("devtools:terminal:write", { id, data: `
|
|
166
|
-
> process terminated with ${code}
|
|
167
|
-
` });
|
|
168
|
-
nuxt.callHook("devtools:terminal:exit", { id, code: code || 0 });
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
return proc;
|
|
172
|
-
}
|
|
173
|
-
register();
|
|
174
|
-
nuxt.hook("close", () => {
|
|
175
|
-
terminate();
|
|
176
|
-
});
|
|
177
|
-
let result = start();
|
|
178
|
-
function restart() {
|
|
179
|
-
restarting = true;
|
|
180
|
-
result.kill();
|
|
181
|
-
clear();
|
|
182
|
-
result = start();
|
|
183
|
-
restarting = false;
|
|
184
|
-
}
|
|
185
|
-
function clear() {
|
|
186
|
-
tabOptions.buffer = "";
|
|
187
|
-
register();
|
|
188
|
-
}
|
|
189
|
-
function terminate() {
|
|
190
|
-
restarting = false;
|
|
191
|
-
try {
|
|
192
|
-
result.kill();
|
|
193
|
-
} catch {
|
|
194
|
-
}
|
|
195
|
-
nuxt.callHook("devtools:terminal:remove", { id });
|
|
196
|
-
}
|
|
197
|
-
function register() {
|
|
198
|
-
nuxt.callHook("devtools:terminal:register", {
|
|
199
|
-
onActionRestart: tabOptions.restartable === false ? void 0 : restart,
|
|
200
|
-
onActionTerminate: tabOptions.terminatable === false ? void 0 : terminate,
|
|
201
|
-
isTerminated: false,
|
|
202
|
-
...tabOptions
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
/** @deprecated Use `getResult()` instead */
|
|
207
|
-
getProcess: () => {
|
|
208
|
-
deprecate(nuxt, "NDT_DEP_0001", {
|
|
209
|
-
api: "startSubprocess().getProcess()",
|
|
210
|
-
replacement: "getResult()"
|
|
211
|
-
}, { key: id });
|
|
212
|
-
return result.process;
|
|
213
|
-
},
|
|
214
|
-
getResult: () => result,
|
|
215
|
-
terminate,
|
|
216
|
-
restart,
|
|
217
|
-
clear
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function extendServerRpc(namespace, functions, nuxt = kit.useNuxt()) {
|
|
221
|
-
const ctx = _getContext(nuxt);
|
|
222
|
-
if (!ctx)
|
|
223
|
-
throw new Error("[Nuxt DevTools] Failed to get devtools context.");
|
|
224
|
-
return ctx.extendServerRpc(namespace, functions);
|
|
225
|
-
}
|
|
226
|
-
function onDevToolsInitialized(fn, nuxt = kit.useNuxt()) {
|
|
227
|
-
nuxt.hook("devtools:initialized", fn);
|
|
228
|
-
}
|
|
229
|
-
function onDevtoolsReady(fn, nuxt = kit.useNuxt()) {
|
|
230
|
-
nuxt.hook("devtools:ready", fn);
|
|
231
|
-
}
|
|
232
|
-
function _getContext(nuxt = kit.useNuxt()) {
|
|
233
|
-
return nuxt?.devtools;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
exports.createConsoleReporter = nostics.createConsoleReporter;
|
|
237
|
-
exports.defineDiagnostics = nostics.defineDiagnostics;
|
|
238
|
-
exports.NUXT_DEVTOOLS_GROUP_ID = NUXT_DEVTOOLS_GROUP_ID;
|
|
239
|
-
exports.addCustomTab = addCustomTab;
|
|
240
|
-
exports.consoleDiagnostics = consoleDiagnostics;
|
|
241
|
-
exports.defineStandaloneDiagnostics = defineStandaloneDiagnostics;
|
|
242
|
-
exports.deprecate = deprecate;
|
|
243
|
-
exports.deprecateWithNuxt = deprecateWithNuxt;
|
|
244
|
-
exports.diagnosticCodes = diagnosticCodes;
|
|
245
|
-
exports.diagnosticsDocsBase = diagnosticsDocsBase;
|
|
246
|
-
exports.extendServerRpc = extendServerRpc;
|
|
247
|
-
exports.onDevToolsInitialized = onDevToolsInitialized;
|
|
248
|
-
exports.onDevtoolsReady = onDevtoolsReady;
|
|
249
|
-
exports.refreshCustomTabs = refreshCustomTabs;
|
|
250
|
-
exports.registerHostDiagnostics = registerHostDiagnostics;
|
|
251
|
-
exports.startSubprocess = startSubprocess;
|