@nuxt/devtools-kit 0.3.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-PRESENT Nuxt Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,64 @@
1
+ import { AppConfig } from 'nuxt/schema';
2
+ import { NuxtApp } from 'nuxt/dist/app/nuxt';
3
+ import { Hookable } from 'hookable';
4
+ import { BirpcReturn } from 'birpc';
5
+ import { u as VueInspectorData, V as VueInspectorClient, H as HookInfo, p as PluginMetric, E as ServerFunctions } from './rpc-5ab26945.js';
6
+
7
+ interface NuxtDevtoolsClientHooks {
8
+ /**
9
+ * When the devtools navigates, used for persisting the current tab
10
+ */
11
+ 'devtools:navigate': (path: string) => void;
12
+ /**
13
+ * Event emitted when the component inspector is updated
14
+ */
15
+ 'host:inspector:update': (data: VueInspectorData) => void;
16
+ /**
17
+ * Event emitted when the component inspector is clicked
18
+ */
19
+ 'host:inspector:click': (baseUrl: string, file: string, line: number, column: number) => void;
20
+ /**
21
+ * Event to close the component inspector
22
+ */
23
+ 'host:inspector:close': () => void;
24
+ /**
25
+ * Triggers reactivity manually, since Vue won't be reactive across frames)
26
+ */
27
+ 'host:update:reactivity': () => void;
28
+ }
29
+ /**
30
+ * Host client from the App
31
+ */
32
+ interface NuxtDevtoolsHostClient {
33
+ nuxt: NuxtApp;
34
+ appConfig: AppConfig;
35
+ hooks: Hookable<NuxtDevtoolsClientHooks>;
36
+ inspector?: {
37
+ instance?: VueInspectorClient;
38
+ enable: () => void;
39
+ disable: () => void;
40
+ };
41
+ getClientHooksMetrics(): HookInfo[];
42
+ getClientPluginMetrics(): PluginMetric[];
43
+ reloadPage(): void;
44
+ closeDevTools(): void;
45
+ }
46
+ interface NuxtDevtoolsClient {
47
+ rpc: BirpcReturn<ServerFunctions>;
48
+ renderCodeHighlight: (code: string, lang: string, lines?: boolean, theme?: string) => {
49
+ code: string;
50
+ supported: boolean;
51
+ };
52
+ renderMarkdown: (markdown: string) => string;
53
+ colorMode: string;
54
+ extendClientRpc: <ServerFunctions = {}, ClientFunctions = {}>(name: string, functions: ClientFunctions) => BirpcReturn<ServerFunctions, ClientFunctions>;
55
+ }
56
+ interface NuxtDevtoolsIframeClient {
57
+ host: NuxtDevtoolsHostClient;
58
+ devtools: NuxtDevtoolsClient;
59
+ }
60
+ interface NuxtDevtoolsGlobal {
61
+ setClient(client: NuxtDevtoolsHostClient): void;
62
+ }
63
+
64
+ export { NuxtDevtoolsClientHooks as N, NuxtDevtoolsHostClient as a, NuxtDevtoolsClient as b, NuxtDevtoolsIframeClient as c, NuxtDevtoolsGlobal as d };
@@ -0,0 +1,164 @@
1
+ import { M as ModuleCustomTab, F as ClientFunctions, E as ServerFunctions, T as TerminalState } from './rpc-5ab26945.js';
2
+ import { BirpcGroup } from 'birpc';
3
+ import { Nuxt } from 'nuxt/schema';
4
+
5
+ interface ModuleOptions {
6
+ /**
7
+ * Enable DevTools
8
+ *
9
+ * @default true
10
+ */
11
+ enabled?: boolean;
12
+ /**
13
+ * Custom tabs
14
+ *
15
+ * This is in static format, for dynamic injection, call `nuxt.hook('devtools:customTabs')` instead
16
+ */
17
+ customTabs?: ModuleCustomTab[];
18
+ /**
19
+ * VS Code Server integration options.
20
+ */
21
+ vscode?: VSCodeIntegrationOptions;
22
+ /**
23
+ * Enable Vue Component Inspector
24
+ *
25
+ * @default true
26
+ */
27
+ componentInspector?: boolean;
28
+ /**
29
+ * Enable vite-plugin-inspect
30
+ *
31
+ * @default true
32
+ */
33
+ viteInspect?: boolean;
34
+ }
35
+ interface ModuleGlobalOptions {
36
+ /**
37
+ * List of projects to enable devtools for. Only works when devtools is installed globally.
38
+ */
39
+ projects?: string[];
40
+ }
41
+ interface VSCodeIntegrationOptions {
42
+ /**
43
+ * Enable VS Code Server integration
44
+ */
45
+ enabled?: boolean;
46
+ /**
47
+ * Start VS Code Server on boot
48
+ *
49
+ * @default false
50
+ */
51
+ startOnBoot?: boolean;
52
+ /**
53
+ * Port to start VS Code Server
54
+ *
55
+ * @default 3080
56
+ */
57
+ port?: number;
58
+ /**
59
+ * Reuse existing server if available (same port)
60
+ */
61
+ reuseExistingServer?: boolean;
62
+ /**
63
+ * Determine whether to use code-server or vs code tunnel
64
+ *
65
+ * @default 'local-serve'
66
+ */
67
+ mode?: 'local-serve' | 'tunnel';
68
+ /**
69
+ * Options for VS Code tunnel
70
+ */
71
+ tunnel?: VSCodeTunnelOptions;
72
+ }
73
+ interface VSCodeTunnelOptions {
74
+ /**
75
+ * the machine name for port forwarding service
76
+ *
77
+ * default: device hostname
78
+ */
79
+ name?: string;
80
+ }
81
+
82
+ /**
83
+ * @internal
84
+ */
85
+ interface NuxtDevtoolsServerContext {
86
+ nuxt: Nuxt;
87
+ options: ModuleOptions;
88
+ rpc: BirpcGroup<ClientFunctions, ServerFunctions>;
89
+ /**
90
+ * Invalidate client cache for a function and ask for re-fetching
91
+ */
92
+ refresh: (event: keyof ServerFunctions) => void;
93
+ extendServerRpc: <ClientFunctions = {}, ServerFunctions = {}>(name: string, functions: ServerFunctions) => BirpcGroup<ClientFunctions, ServerFunctions>;
94
+ }
95
+ interface NuxtDevtoolsInfo {
96
+ version: string;
97
+ packagePath: string;
98
+ isGlobalInstall: boolean;
99
+ }
100
+
101
+ declare module '@nuxt/schema' {
102
+ interface NuxtHooks {
103
+ /**
104
+ * Called before devtools starts. Useful to detect if devtools is enabled.
105
+ */
106
+ 'devtools:before': () => void;
107
+ /**
108
+ * Called after devtools is initialized.
109
+ */
110
+ 'devtools:initialized': (info: NuxtDevtoolsInfo) => void;
111
+ /**
112
+ * Hooks to extend devtools tabs.
113
+ */
114
+ 'devtools:customTabs': (tabs: ModuleCustomTab[]) => void;
115
+ /**
116
+ * Retrigger update for custom tabs, `devtools:customTabs` will be called again.
117
+ */
118
+ 'devtools:customTabs:refresh': () => void;
119
+ /**
120
+ * Register a terminal.
121
+ */
122
+ 'devtools:terminal:register': (terminal: TerminalState) => void;
123
+ /**
124
+ * Write to a terminal.
125
+ *
126
+ * Returns true if terminal is found.
127
+ */
128
+ 'devtools:terminal:write': (_: {
129
+ id: string;
130
+ data: string;
131
+ }) => void;
132
+ /**
133
+ * Remove a terminal from devtools.
134
+ *
135
+ * Returns true if terminal is found and deleted.
136
+ */
137
+ 'devtools:terminal:remove': (_: {
138
+ id: string;
139
+ }) => void;
140
+ /**
141
+ * Mark a terminal as terminated.
142
+ */
143
+ 'devtools:terminal:exit': (_: {
144
+ id: string;
145
+ code?: number;
146
+ }) => void;
147
+ }
148
+ }
149
+ declare module '@nuxt/schema' {
150
+ /**
151
+ * Runtime Hooks
152
+ */
153
+ interface RuntimeNuxtHooks {
154
+ /**
155
+ * On terminal data.
156
+ */
157
+ 'devtools:terminal:data': (payload: {
158
+ id: string;
159
+ data: string;
160
+ }) => void;
161
+ }
162
+ }
163
+
164
+ export { ModuleOptions as M, NuxtDevtoolsInfo as N, VSCodeIntegrationOptions as V, NuxtDevtoolsServerContext as a, ModuleGlobalOptions as b, VSCodeTunnelOptions as c };
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ const vue = require('vue');
4
+
5
+ let clientRef;
6
+ const fns = [];
7
+ function onDevtoolsClientConnected(fn) {
8
+ fns.push(fn);
9
+ if (window.__NUXT_DEVTOOLS__) {
10
+ fns.forEach((fn2) => fn2(window.__NUXT_DEVTOOLS__));
11
+ }
12
+ Object.defineProperty(window, "__NUXT_DEVTOOLS__", {
13
+ set(value) {
14
+ if (value)
15
+ fns.forEach((fn2) => fn2(value));
16
+ },
17
+ get() {
18
+ return clientRef.value;
19
+ },
20
+ configurable: true
21
+ });
22
+ return () => {
23
+ fns.splice(fns.indexOf(fn), 1);
24
+ };
25
+ }
26
+ function useDevtoolsClient() {
27
+ if (!clientRef) {
28
+ clientRef = vue.shallowRef();
29
+ onDevtoolsClientConnected(setup);
30
+ }
31
+ function setup(client) {
32
+ clientRef.value = client;
33
+ if (client.host) {
34
+ client.host.hooks.hook("host:update:reactivity", () => {
35
+ vue.triggerRef(clientRef);
36
+ });
37
+ }
38
+ }
39
+ return clientRef;
40
+ }
41
+
42
+ exports.onDevtoolsClientConnected = onDevtoolsClientConnected;
43
+ exports.useDevtoolsClient = useDevtoolsClient;
@@ -0,0 +1,17 @@
1
+ import { Ref } from 'vue';
2
+ import { c as NuxtDevtoolsIframeClient } from './client-api-34a84dad.js';
3
+ import 'nuxt/schema';
4
+ import 'nuxt/dist/app/nuxt';
5
+ import 'hookable';
6
+ import 'birpc';
7
+ import './rpc-5ab26945.js';
8
+ import 'nitropack';
9
+ import 'unstorage';
10
+ import 'vue-router';
11
+ import 'unimport';
12
+ import 'execa';
13
+
14
+ declare function onDevtoolsClientConnected(fn: (client: NuxtDevtoolsIframeClient) => void): (() => void) | undefined;
15
+ declare function useDevtoolsClient(): Ref<NuxtDevtoolsIframeClient | undefined>;
16
+
17
+ export { onDevtoolsClientConnected, useDevtoolsClient };
@@ -0,0 +1,40 @@
1
+ import { shallowRef, triggerRef } from 'vue';
2
+
3
+ let clientRef;
4
+ const fns = [];
5
+ function onDevtoolsClientConnected(fn) {
6
+ fns.push(fn);
7
+ if (window.__NUXT_DEVTOOLS__) {
8
+ fns.forEach((fn2) => fn2(window.__NUXT_DEVTOOLS__));
9
+ }
10
+ Object.defineProperty(window, "__NUXT_DEVTOOLS__", {
11
+ set(value) {
12
+ if (value)
13
+ fns.forEach((fn2) => fn2(value));
14
+ },
15
+ get() {
16
+ return clientRef.value;
17
+ },
18
+ configurable: true
19
+ });
20
+ return () => {
21
+ fns.splice(fns.indexOf(fn), 1);
22
+ };
23
+ }
24
+ function useDevtoolsClient() {
25
+ if (!clientRef) {
26
+ clientRef = shallowRef();
27
+ onDevtoolsClientConnected(setup);
28
+ }
29
+ function setup(client) {
30
+ clientRef.value = client;
31
+ if (client.host) {
32
+ client.host.hooks.hook("host:update:reactivity", () => {
33
+ triggerRef(clientRef);
34
+ });
35
+ }
36
+ }
37
+ return clientRef;
38
+ }
39
+
40
+ export { onDevtoolsClientConnected, useDevtoolsClient };
package/dist/index.cjs ADDED
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ const kit = require('@nuxt/kit');
4
+ const execa = require('execa');
5
+
6
+ function addCustomTab(tab, nuxt = kit.useNuxt()) {
7
+ nuxt.hook("devtools:customTabs", async (tabs) => {
8
+ if (typeof tab === "function")
9
+ tab = await tab();
10
+ tabs.push(tab);
11
+ });
12
+ }
13
+ function refreshCustomTabs(nuxt = kit.useNuxt()) {
14
+ return nuxt.callHook("devtools:customTabs:refresh");
15
+ }
16
+ function startSubprocess(execaOptions, tabOptions, nuxt = kit.useNuxt()) {
17
+ const id = tabOptions.id;
18
+ let restarting = false;
19
+ function start() {
20
+ const process2 = execa.execa(
21
+ execaOptions.command,
22
+ execaOptions.args,
23
+ {
24
+ ...execaOptions,
25
+ env: {
26
+ COLORS: "true",
27
+ FORCE_COLOR: "true",
28
+ ...execaOptions.env
29
+ }
30
+ }
31
+ );
32
+ nuxt.callHook("devtools:terminal:write", { id, data: `> ${[execaOptions.command, ...execaOptions.args || []].join(" ")}
33
+
34
+ ` });
35
+ process2.stdout.on("data", (data) => {
36
+ nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
37
+ });
38
+ process2.stderr.on("data", (data) => {
39
+ nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
40
+ });
41
+ process2.on("exit", (code) => {
42
+ if (!restarting) {
43
+ nuxt.callHook("devtools:terminal:write", { id, data: `
44
+ > process terminalated with ${code}
45
+ ` });
46
+ nuxt.callHook("devtools:terminal:exit", { id, code: code || 0 });
47
+ }
48
+ });
49
+ return process2;
50
+ }
51
+ register();
52
+ nuxt.hook("close", () => {
53
+ terminate();
54
+ });
55
+ let process = start();
56
+ function restart() {
57
+ restarting = true;
58
+ process?.kill();
59
+ clear();
60
+ process = start();
61
+ restarting = false;
62
+ }
63
+ function clear() {
64
+ tabOptions.buffer = "";
65
+ register();
66
+ }
67
+ function terminate() {
68
+ restarting = false;
69
+ try {
70
+ process?.kill();
71
+ } catch (e) {
72
+ }
73
+ nuxt.callHook("devtools:terminal:remove", { id });
74
+ }
75
+ function register() {
76
+ nuxt.callHook("devtools:terminal:register", {
77
+ onActionRestart: tabOptions.restartable === false ? void 0 : restart,
78
+ onActionTerminate: tabOptions.terminatable === false ? void 0 : terminate,
79
+ isTerminated: false,
80
+ ...tabOptions
81
+ });
82
+ }
83
+ return {
84
+ getProcess() {
85
+ return process;
86
+ },
87
+ terminate,
88
+ restart,
89
+ clear
90
+ };
91
+ }
92
+ function extendServerRpc(namespace, functions, nuxt = kit.useNuxt()) {
93
+ const ctx = _getContext(nuxt);
94
+ if (!ctx)
95
+ throw new Error("Failed to get devtools context.");
96
+ return ctx.extendServerRpc(namespace, functions);
97
+ }
98
+ function onDevToolsInitialized(fn, nuxt = kit.useNuxt()) {
99
+ nuxt.hook("devtools:initialized", fn);
100
+ }
101
+ function _getContext(nuxt = kit.useNuxt()) {
102
+ return nuxt?.devtools;
103
+ }
104
+
105
+ exports.addCustomTab = addCustomTab;
106
+ exports.extendServerRpc = extendServerRpc;
107
+ exports.onDevToolsInitialized = onDevToolsInitialized;
108
+ exports.refreshCustomTabs = refreshCustomTabs;
109
+ exports.startSubprocess = startSubprocess;
@@ -0,0 +1,35 @@
1
+ import * as execa from 'execa';
2
+ import * as _nuxt_schema from '@nuxt/schema';
3
+ import { BirpcGroup } from 'birpc';
4
+ import { N as NuxtDevtoolsInfo } from './hooks-db1f6518.js';
5
+ import { M as ModuleCustomTab, S as SubprocessOptions, T as TerminalState } from './rpc-5ab26945.js';
6
+ import 'nuxt/schema';
7
+ import 'nitropack';
8
+ import 'unstorage';
9
+ import 'vue';
10
+ import 'vue-router';
11
+ import 'unimport';
12
+
13
+ /**
14
+ * Hooks to extend a custom tab in devtools.
15
+ *
16
+ * Provide a function to pass a factory that can be updated dynamically.
17
+ */
18
+ declare function addCustomTab(tab: ModuleCustomTab | (() => ModuleCustomTab | Promise<ModuleCustomTab>), nuxt?: _nuxt_schema.Nuxt): void;
19
+ /**
20
+ * Retrigger update for custom tabs, `devtools:customTabs` will be called again.
21
+ */
22
+ declare function refreshCustomTabs(nuxt?: _nuxt_schema.Nuxt): Promise<any>;
23
+ /**
24
+ * Create a subprocess that handled by the DevTools.
25
+ */
26
+ declare function startSubprocess(execaOptions: SubprocessOptions, tabOptions: TerminalState, nuxt?: _nuxt_schema.Nuxt): {
27
+ getProcess(): execa.ExecaChildProcess<string>;
28
+ terminate: () => void;
29
+ restart: () => void;
30
+ clear: () => void;
31
+ };
32
+ declare function extendServerRpc<ClientFunctions = {}, ServerFunctions = {}>(namespace: string, functions: ServerFunctions, nuxt?: _nuxt_schema.Nuxt): BirpcGroup<ClientFunctions, ServerFunctions>;
33
+ declare function onDevToolsInitialized(fn: (info: NuxtDevtoolsInfo) => void, nuxt?: _nuxt_schema.Nuxt): void;
34
+
35
+ export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };
package/dist/index.mjs ADDED
@@ -0,0 +1,103 @@
1
+ import { useNuxt } from '@nuxt/kit';
2
+ import { execa } from 'execa';
3
+
4
+ function addCustomTab(tab, nuxt = useNuxt()) {
5
+ nuxt.hook("devtools:customTabs", async (tabs) => {
6
+ if (typeof tab === "function")
7
+ tab = await tab();
8
+ tabs.push(tab);
9
+ });
10
+ }
11
+ function refreshCustomTabs(nuxt = useNuxt()) {
12
+ return nuxt.callHook("devtools:customTabs:refresh");
13
+ }
14
+ function startSubprocess(execaOptions, tabOptions, nuxt = useNuxt()) {
15
+ const id = tabOptions.id;
16
+ let restarting = false;
17
+ function start() {
18
+ const process2 = execa(
19
+ execaOptions.command,
20
+ execaOptions.args,
21
+ {
22
+ ...execaOptions,
23
+ env: {
24
+ COLORS: "true",
25
+ FORCE_COLOR: "true",
26
+ ...execaOptions.env
27
+ }
28
+ }
29
+ );
30
+ nuxt.callHook("devtools:terminal:write", { id, data: `> ${[execaOptions.command, ...execaOptions.args || []].join(" ")}
31
+
32
+ ` });
33
+ process2.stdout.on("data", (data) => {
34
+ nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
35
+ });
36
+ process2.stderr.on("data", (data) => {
37
+ nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
38
+ });
39
+ process2.on("exit", (code) => {
40
+ if (!restarting) {
41
+ nuxt.callHook("devtools:terminal:write", { id, data: `
42
+ > process terminalated with ${code}
43
+ ` });
44
+ nuxt.callHook("devtools:terminal:exit", { id, code: code || 0 });
45
+ }
46
+ });
47
+ return process2;
48
+ }
49
+ register();
50
+ nuxt.hook("close", () => {
51
+ terminate();
52
+ });
53
+ let process = start();
54
+ function restart() {
55
+ restarting = true;
56
+ process?.kill();
57
+ clear();
58
+ process = start();
59
+ restarting = false;
60
+ }
61
+ function clear() {
62
+ tabOptions.buffer = "";
63
+ register();
64
+ }
65
+ function terminate() {
66
+ restarting = false;
67
+ try {
68
+ process?.kill();
69
+ } catch (e) {
70
+ }
71
+ nuxt.callHook("devtools:terminal:remove", { id });
72
+ }
73
+ function register() {
74
+ nuxt.callHook("devtools:terminal:register", {
75
+ onActionRestart: tabOptions.restartable === false ? void 0 : restart,
76
+ onActionTerminate: tabOptions.terminatable === false ? void 0 : terminate,
77
+ isTerminated: false,
78
+ ...tabOptions
79
+ });
80
+ }
81
+ return {
82
+ getProcess() {
83
+ return process;
84
+ },
85
+ terminate,
86
+ restart,
87
+ clear
88
+ };
89
+ }
90
+ function extendServerRpc(namespace, functions, nuxt = useNuxt()) {
91
+ const ctx = _getContext(nuxt);
92
+ if (!ctx)
93
+ throw new Error("Failed to get devtools context.");
94
+ return ctx.extendServerRpc(namespace, functions);
95
+ }
96
+ function onDevToolsInitialized(fn, nuxt = useNuxt()) {
97
+ nuxt.hook("devtools:initialized", fn);
98
+ }
99
+ function _getContext(nuxt = useNuxt()) {
100
+ return nuxt?.devtools;
101
+ }
102
+
103
+ export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };
@@ -0,0 +1,332 @@
1
+ import { NuxtOptions, NuxtPage, NuxtLayout } from 'nuxt/schema';
2
+ import { StorageMounts } from 'nitropack';
3
+ import { StorageValue } from 'unstorage';
4
+ import { VNode, Component } from 'vue';
5
+ import { RouteRecordNormalized } from 'vue-router';
6
+ import { Import, UnimportMeta } from 'unimport';
7
+ import { Options } from 'execa';
8
+
9
+ interface ModuleCustomTab {
10
+ /**
11
+ * The name of the tab, must be unique
12
+ */
13
+ name: string;
14
+ /**
15
+ * Icon of the tab, support any Iconify icons, or a url to an image
16
+ */
17
+ icon?: string;
18
+ /**
19
+ * Title of the tab
20
+ */
21
+ title: string;
22
+ /**
23
+ * Main view of the tab
24
+ */
25
+ view: ModuleView;
26
+ /**
27
+ * Insert static vnode to the tab entry
28
+ *
29
+ * Advanced options. You don't usually need this.
30
+ */
31
+ extraTabVNode?: VNode;
32
+ }
33
+ interface ModuleLaunchView {
34
+ /**
35
+ * A view for module to lazy launch some actions
36
+ */
37
+ type: 'launch';
38
+ title?: string;
39
+ icon?: string;
40
+ description: string;
41
+ /**
42
+ * Action buttons
43
+ */
44
+ actions: ModuleLaunchAction[];
45
+ }
46
+ interface ModuleIframeView {
47
+ /**
48
+ * Iframe view
49
+ */
50
+ type: 'iframe';
51
+ /**
52
+ * Url of the iframe
53
+ */
54
+ src: string;
55
+ /**
56
+ * Persist the iframe instance even if the tab is not active
57
+ *
58
+ * @default true
59
+ */
60
+ persistent?: boolean;
61
+ }
62
+ interface ModuleVNodeView {
63
+ /**
64
+ * Vue's VNode view
65
+ */
66
+ type: 'vnode';
67
+ /**
68
+ * Send vnode to the client, they must be static and serializable
69
+ *
70
+ * Call `nuxt.hook('devtools:customTabs:refresh')` to trigger manual refresh
71
+ */
72
+ vnode: VNode;
73
+ }
74
+ interface ModuleLaunchAction {
75
+ /**
76
+ * Label of the action button
77
+ */
78
+ label: string;
79
+ /**
80
+ * Additional HTML attributes to the action button
81
+ */
82
+ attrs?: Record<string, string>;
83
+ /**
84
+ * Indicate if the action is pending, will show a loading indicator and disable the button
85
+ */
86
+ pending?: boolean;
87
+ /**
88
+ * Function to handle the action, this is executed on the server side.
89
+ * Will automatically refresh the tabs after the action is resolved.
90
+ */
91
+ handle?: () => void | Promise<void>;
92
+ /**
93
+ * Treat the action as a link, will open the link in a new tab
94
+ */
95
+ src?: string;
96
+ }
97
+ type ModuleView = ModuleIframeView | ModuleLaunchView | ModuleVNodeView;
98
+ interface ModuleIframeTabLazyOptions {
99
+ description?: string;
100
+ onLoad?: () => Promise<void>;
101
+ }
102
+ interface ModuleBuiltinTab {
103
+ name: string;
104
+ icon?: string;
105
+ title?: string;
106
+ path?: string;
107
+ requireClient?: boolean;
108
+ shouldShow?: () => boolean;
109
+ }
110
+ type ModuleTabInfo = ModuleCustomTab | ModuleBuiltinTab;
111
+
112
+ interface HookInfo {
113
+ name: string;
114
+ start: number;
115
+ end?: number;
116
+ duration?: number;
117
+ listeners: number;
118
+ executions: number[];
119
+ }
120
+ interface ImageMeta {
121
+ width: number;
122
+ height: number;
123
+ orientation?: number;
124
+ type?: string;
125
+ mimeType?: string;
126
+ }
127
+ interface PackageUpdateInfo {
128
+ name: string;
129
+ current: string;
130
+ latest: string;
131
+ needsUpdate: boolean;
132
+ }
133
+ type PackageManagerName = 'npm' | 'yarn' | 'pnpm';
134
+ type NpmCommandType = 'install' | 'uninstall' | 'update';
135
+ interface NpmCommandOptions {
136
+ dev?: boolean;
137
+ global?: boolean;
138
+ }
139
+ interface AutoImportsWithMetadata {
140
+ imports: Import[];
141
+ metadata?: UnimportMeta;
142
+ }
143
+ interface RouteInfo extends Pick<RouteRecordNormalized, 'name' | 'path' | 'meta' | 'props' | 'children'> {
144
+ file?: string;
145
+ }
146
+ interface Payload {
147
+ url: string;
148
+ time: number;
149
+ data?: Record<string, any>;
150
+ state?: Record<string, any>;
151
+ functions?: Record<string, any>;
152
+ }
153
+ interface PluginInfoWithMetic {
154
+ src: string;
155
+ mode?: 'client' | 'server' | 'all';
156
+ ssr?: boolean;
157
+ metric?: PluginMetric;
158
+ }
159
+ interface PluginMetric {
160
+ src: string;
161
+ duration: number;
162
+ }
163
+ interface BasicModuleInfo {
164
+ entryPath?: string;
165
+ meta?: {
166
+ name?: string;
167
+ };
168
+ }
169
+ interface ModuleMetric {
170
+ name: string;
171
+ description: string;
172
+ repo: string;
173
+ npm: string;
174
+ icon?: string;
175
+ github: string;
176
+ website: string;
177
+ learn_more: string;
178
+ category: string;
179
+ type: ModuleType;
180
+ maintainers: MaintainerInfo[];
181
+ contributors: GitHubContributor[];
182
+ compatibility: ModuleCompatibility;
183
+ }
184
+ interface ModuleCompatibility {
185
+ nuxt: string;
186
+ requires: {
187
+ bridge?: boolean | 'optional';
188
+ };
189
+ }
190
+ type CompatibilityStatus = 'working' | 'wip' | 'unknown' | 'not-working';
191
+ type ModuleType = 'community' | 'official' | '3rd-party';
192
+ interface MaintainerInfo {
193
+ name: string;
194
+ github: string;
195
+ twitter?: string;
196
+ }
197
+ interface GitHubContributor {
198
+ login: string;
199
+ name?: string;
200
+ avatar_url?: string;
201
+ }
202
+ interface VueInspectorClient {
203
+ enabled: boolean;
204
+ position: {
205
+ x: number;
206
+ y: number;
207
+ };
208
+ linkParams: {
209
+ file: string;
210
+ line: number;
211
+ column: number;
212
+ };
213
+ enable: () => void;
214
+ disable: () => void;
215
+ toggleEnabled: () => void;
216
+ openInEditor: (baseUrl: string, file: string, line: number, column: number) => void;
217
+ onUpdated: () => void;
218
+ }
219
+ type VueInspectorData = VueInspectorClient['linkParams'] & VueInspectorClient['position'];
220
+ type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'other';
221
+ interface AssetInfo {
222
+ path: string;
223
+ type: AssetType;
224
+ publicPath: string;
225
+ filePath: string;
226
+ size: number;
227
+ mtime: number;
228
+ }
229
+ interface CodeSnippet {
230
+ code: string;
231
+ lang: string;
232
+ name: string;
233
+ docs?: string;
234
+ }
235
+ interface ComponentRelationship {
236
+ id: string;
237
+ deps: string[];
238
+ }
239
+
240
+ interface TerminalBase {
241
+ id: string;
242
+ name: string;
243
+ description?: string;
244
+ icon?: string;
245
+ }
246
+ type TerminalAction = 'restart' | 'terminate' | 'clear' | 'remove';
247
+ interface SubprocessOptions extends Options {
248
+ command: string;
249
+ args?: string[];
250
+ }
251
+ interface TerminalInfo extends TerminalBase {
252
+ /**
253
+ * Whether the terminal can be restarted
254
+ */
255
+ restartable?: boolean;
256
+ /**
257
+ * Whether the terminal can be terminated
258
+ */
259
+ terminatable?: boolean;
260
+ /**
261
+ * Whether the terminal is terminated
262
+ */
263
+ isTerminated?: boolean;
264
+ /**
265
+ * Content buffer
266
+ */
267
+ buffer?: string;
268
+ }
269
+ interface TerminalState extends TerminalInfo {
270
+ /**
271
+ * User action to restart the terminal, when not provided, this action will be disabled
272
+ */
273
+ onActionRestart?: () => Promise<void> | void;
274
+ /**
275
+ * User action to terminate the terminal, when not provided, this action will be disabled
276
+ */
277
+ onActionTerminate?: () => Promise<void> | void;
278
+ }
279
+
280
+ interface WizardFunctions {
281
+ enablePages: (nuxt: any) => Promise<void>;
282
+ }
283
+ type WizardActions = keyof WizardFunctions;
284
+ type GetWizardArgs<T extends WizardActions> = WizardFunctions[T] extends (nuxt: any, ...args: infer A) => any ? A : never;
285
+
286
+ interface ServerFunctions {
287
+ getServerConfig(): NuxtOptions;
288
+ getComponents(): Component[];
289
+ getComponentsRelationships(): Promise<ComponentRelationship[]>;
290
+ getAutoImports(): AutoImportsWithMetadata;
291
+ getServerPages(): NuxtPage[];
292
+ getCustomTabs(): ModuleCustomTab[];
293
+ getServerHooks(): HookInfo[];
294
+ getServerLayouts(): NuxtLayout[];
295
+ getStaticAssets(): Promise<AssetInfo[]>;
296
+ checkForUpdateFor(name: string): Promise<PackageUpdateInfo | undefined>;
297
+ getPackageManager(): Promise<PackageManagerName>;
298
+ getNpmCommand(command: NpmCommandType, packageName: string, options?: NpmCommandOptions): Promise<string[] | undefined>;
299
+ runNpmCommand(command: NpmCommandType, packageName: string, options?: NpmCommandOptions): Promise<{
300
+ processId: string;
301
+ } | undefined>;
302
+ getTerminals(): TerminalInfo[];
303
+ getTerminalDetail(id: string): TerminalInfo | undefined;
304
+ runTerminalAction(id: string, action: TerminalAction): Promise<boolean>;
305
+ getStorageMounts(): Promise<StorageMounts>;
306
+ getStorageKeys(base?: string): Promise<string[]>;
307
+ getStorageItem(key: string): Promise<StorageValue>;
308
+ setStorageItem(key: string, value: StorageValue): Promise<void>;
309
+ removeStorageItem(key: string): Promise<void>;
310
+ getImageMeta(filepath: string): Promise<ImageMeta | undefined>;
311
+ getTextAssetContent(filepath: string, limit?: number): Promise<string | undefined>;
312
+ customTabAction(name: string, action: number): Promise<boolean>;
313
+ runWizard<T extends WizardActions>(name: T, ...args: GetWizardArgs<T>): Promise<void>;
314
+ openInEditor(filepath: string): void;
315
+ restartNuxt(hard?: boolean): Promise<void>;
316
+ }
317
+ interface ClientFunctions {
318
+ refresh(event: ClientUpdateEvent): void;
319
+ callHook(hook: string, ...args: any[]): Promise<void>;
320
+ navigateTo(path: string): void;
321
+ onTerminalData(_: {
322
+ id: string;
323
+ data: string;
324
+ }): void;
325
+ onTerminalExit(_: {
326
+ id: string;
327
+ code?: number;
328
+ }): void;
329
+ }
330
+ type ClientUpdateEvent = keyof ServerFunctions;
331
+
332
+ export { AutoImportsWithMetadata as A, BasicModuleInfo as B, CompatibilityStatus as C, GetWizardArgs as D, ServerFunctions as E, ClientFunctions as F, GitHubContributor as G, HookInfo as H, ImageMeta as I, ClientUpdateEvent as J, ModuleCustomTab as M, NpmCommandType as N, PackageUpdateInfo as P, RouteInfo as R, SubprocessOptions as S, TerminalState as T, VueInspectorClient as V, WizardFunctions as W, ModuleLaunchView as a, ModuleIframeView as b, ModuleVNodeView as c, ModuleLaunchAction as d, ModuleView as e, ModuleIframeTabLazyOptions as f, ModuleBuiltinTab as g, ModuleTabInfo as h, TerminalBase as i, TerminalAction as j, TerminalInfo as k, PackageManagerName as l, NpmCommandOptions as m, Payload as n, PluginInfoWithMetic as o, PluginMetric as p, ModuleMetric as q, ModuleCompatibility as r, ModuleType as s, MaintainerInfo as t, VueInspectorData as u, AssetType as v, AssetInfo as w, CodeSnippet as x, ComponentRelationship as y, WizardActions as z };
package/dist/types.cjs ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,13 @@
1
+ export { b as ModuleGlobalOptions, M as ModuleOptions, N as NuxtDevtoolsInfo, a as NuxtDevtoolsServerContext, V as VSCodeIntegrationOptions, c as VSCodeTunnelOptions } from './hooks-db1f6518.js';
2
+ export { w as AssetInfo, v as AssetType, A as AutoImportsWithMetadata, B as BasicModuleInfo, F as ClientFunctions, J as ClientUpdateEvent, x as CodeSnippet, C as CompatibilityStatus, y as ComponentRelationship, D as GetWizardArgs, G as GitHubContributor, H as HookInfo, I as ImageMeta, t as MaintainerInfo, g as ModuleBuiltinTab, r as ModuleCompatibility, M as ModuleCustomTab, f as ModuleIframeTabLazyOptions, b as ModuleIframeView, d as ModuleLaunchAction, a as ModuleLaunchView, q as ModuleMetric, h as ModuleTabInfo, s as ModuleType, c as ModuleVNodeView, e as ModuleView, m as NpmCommandOptions, N as NpmCommandType, l as PackageManagerName, P as PackageUpdateInfo, n as Payload, o as PluginInfoWithMetic, p as PluginMetric, R as RouteInfo, E as ServerFunctions, S as SubprocessOptions, j as TerminalAction, i as TerminalBase, k as TerminalInfo, T as TerminalState, V as VueInspectorClient, u as VueInspectorData, z as WizardActions, W as WizardFunctions } from './rpc-5ab26945.js';
3
+ export { b as NuxtDevtoolsClient, N as NuxtDevtoolsClientHooks, d as NuxtDevtoolsGlobal, a as NuxtDevtoolsHostClient, c as NuxtDevtoolsIframeClient } from './client-api-34a84dad.js';
4
+ import 'birpc';
5
+ import 'nuxt/schema';
6
+ import 'nitropack';
7
+ import 'unstorage';
8
+ import 'vue';
9
+ import 'vue-router';
10
+ import 'unimport';
11
+ import 'execa';
12
+ import 'nuxt/dist/app/nuxt';
13
+ import 'hookable';
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ export * from './dist/iframe-client'
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@nuxt/devtools-kit",
3
+ "type": "module",
4
+ "version": "0.3.0",
5
+ "license": "MIT",
6
+ "repository": "nuxt/devtools",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.cjs",
11
+ "import": "./dist/index.mjs"
12
+ },
13
+ "./types": {
14
+ "types": "./types.d.ts",
15
+ "require": "./dist/types.cjs",
16
+ "import": "./dist/types.mjs"
17
+ },
18
+ "./iframe-client": {
19
+ "types": "./iframe-client.d.ts",
20
+ "require": "./dist/iframe-client.cjs",
21
+ "import": "./dist/iframe-client.mjs"
22
+ }
23
+ },
24
+ "main": "./dist/index.cjs",
25
+ "types": "./dist/index.d.ts",
26
+ "files": [
27
+ "dist",
28
+ "*.d.ts",
29
+ "*.cjs",
30
+ "*.mjs"
31
+ ],
32
+ "peerDependencies": {
33
+ "nuxt": "^3.3.1",
34
+ "vite": "*"
35
+ },
36
+ "dependencies": {
37
+ "@nuxt/kit": "^3.3.1",
38
+ "@nuxt/schema": "^3.3.1",
39
+ "execa": "^7.1.1"
40
+ },
41
+ "devDependencies": {
42
+ "birpc": "^0.2.10",
43
+ "hookable": "^5.5.1",
44
+ "unbuild": "^1.1.2",
45
+ "unimport": "^3.0.3",
46
+ "vue-router": "^4.1.6"
47
+ },
48
+ "scripts": {
49
+ "build": "unbuild",
50
+ "stub": "unbuild --stub",
51
+ "dev:prepare": "nr stub"
52
+ }
53
+ }
package/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/types'