@nuxt/devtools-kit-nightly 2.0.0-beta.0-28940159.3b2c84c
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 +21 -0
- package/README.md +129 -0
- package/dist/index.cjs +112 -0
- package/dist/index.d.cts +35 -0
- package/dist/index.d.mts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.mjs +106 -0
- package/dist/runtime/host-client.d.ts +4 -0
- package/dist/runtime/host-client.mjs +34 -0
- package/dist/runtime/iframe-client.d.ts +4 -0
- package/dist/runtime/iframe-client.mjs +44 -0
- package/dist/shared/devtools-kit-nightly.s0VF6R5p.d.cts +761 -0
- package/dist/shared/devtools-kit-nightly.s0VF6R5p.d.mts +761 -0
- package/dist/shared/devtools-kit-nightly.s0VF6R5p.d.ts +761 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +181 -0
- package/dist/types.d.mts +181 -0
- package/dist/types.d.ts +181 -0
- package/dist/types.mjs +1 -0
- package/host-client.d.ts +1 -0
- package/host-client.mjs +1 -0
- package/iframe-client.d.ts +1 -0
- package/iframe-client.mjs +1 -0
- package/package.json +62 -0
- package/types.d.ts +1 -0
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<a href="https://devtools.nuxt.com"><img width="1200" alt="Nuxt DevTools" src="https://github-production-user-asset-6210df.s3.amazonaws.com/904724/261577617-a10567bd-ad33-48cc-9bda-9e37dbe1929f.png"></a>
|
|
2
|
+
<br>
|
|
3
|
+
|
|
4
|
+
<h1>
|
|
5
|
+
Nuxt DevTools
|
|
6
|
+
</h1>
|
|
7
|
+
|
|
8
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
9
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
10
|
+
[![License][license-src]][license-href]
|
|
11
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
12
|
+
[![Volta][volta-src]][volta-href]
|
|
13
|
+
|
|
14
|
+
<p>
|
|
15
|
+
Unleash Nuxt Developer Experience.
|
|
16
|
+
<br>Nuxt DevTools is a set of visual tools that help you to know your app better.
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p>
|
|
20
|
+
<a href="https://nuxt.com/blog/nuxt-devtools-v1-0">π Introduction</a> |
|
|
21
|
+
<a href="https://github.com/nuxt/devtools/discussions/29">π‘ Ideas & Suggestions</a> |
|
|
22
|
+
<a href="https://github.com/nuxt/devtools/discussions/31">πΊοΈ Project Roadmap</a> |
|
|
23
|
+
<a href="https://devtools.nuxt.com/">π Documentation</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
<br>
|
|
27
|
+
|
|
28
|
+
> [!NOTE]
|
|
29
|
+
> You are viewing the v2.x branch which are in active development. For the latest stable version, please refer to the [v1.x branch](https://github.com/nuxt/devtools/tree/v1)
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
> Nuxt DevTools v2 requires **Nuxt v3.15.0 or higher**.
|
|
34
|
+
|
|
35
|
+
Nuxt DevTools is **enabled by default** in Nuxt v3.8.0. You can press <kbd>Shift</kbd> + <kbd>Alt</kbd> / <kbd>β§ Shift</kbd> + <kbd>β₯ Option</kbd> + <kbd>D</kbd> in your app to open it up.
|
|
36
|
+
|
|
37
|
+
If you want to explicitly enable or disable Nuxt DevTools, you can update your `nuxt.config` with:
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
export default defineNuxtConfig({
|
|
41
|
+
devtools: {
|
|
42
|
+
enabled: true // or false to disable
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Nightly Release Channel
|
|
48
|
+
|
|
49
|
+
Similar to [Nuxt's Nightly Channel](https://nuxt.com/docs/guide/going-further/nightly-release-channel), DevTools also offers a nightly release channel, that automatically releases for every commit to `main` branch.
|
|
50
|
+
|
|
51
|
+
You can opt-in to the nightly release channel by running:
|
|
52
|
+
|
|
53
|
+
```diff
|
|
54
|
+
{
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
-- "@nuxt/devtools": "^0.1.0"
|
|
57
|
+
++ "@nuxt/devtools": "npm:@nuxt/devtools-nightly@latest"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Remove lockfile (`package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`) and reinstall dependencies.
|
|
63
|
+
|
|
64
|
+
### Module Options
|
|
65
|
+
|
|
66
|
+
To configure Nuxt DevTools, you can pass the `devtools` options.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
// nuxt.config.ts
|
|
70
|
+
export default defineNuxtConfig({
|
|
71
|
+
devtools: {
|
|
72
|
+
// Enable devtools (default: true)
|
|
73
|
+
enabled: true,
|
|
74
|
+
// VS Code Server options
|
|
75
|
+
vscode: {},
|
|
76
|
+
// ...other options
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For all options available, please refer to TSDocs in your IDE, or the [type definition file](https://github.com/nuxt/devtools/blob/main/packages/devtools-kit/src/_types/options.ts).
|
|
82
|
+
|
|
83
|
+
## Features
|
|
84
|
+
|
|
85
|
+
Read the [**Announcement Blog Post π**](https://nuxt.com/blog/nuxt-devtools-v1-0) for why we built Nuxt DevTools and what it can do!
|
|
86
|
+
|
|
87
|
+
## Module Authors
|
|
88
|
+
|
|
89
|
+
Please refer to the [Module Authors Guide](https://devtools.nuxt.com/module/guide).
|
|
90
|
+
|
|
91
|
+
## Contribution Guide
|
|
92
|
+
|
|
93
|
+
Please refer to the [Contribution Guide](https://devtools.nuxt.com/development/contributing).
|
|
94
|
+
|
|
95
|
+
## Anonymous Usage Analytics
|
|
96
|
+
|
|
97
|
+
Nuxt DevTools collects anonymous telemetry data about general usage. This helps us to accurately gauge feature usage and customization across all our users. This data will let us better understand how each features in Nuxt DevTools are used, measuring improvements made (DX and performances) and their relevance. It would also help us to prioritize our efforts and focus on the features that matter the most to our users.
|
|
98
|
+
|
|
99
|
+
Nuxt DevTools' telemetry data is piped through [Nuxt Telemetry](https://github.com/nuxt/telemetry), meaning that Nuxt DevTools will respect your local and global Nuxt Telemetry settings. You can also opt-out Nuxt DevTools' telemetry in the Nuxt DevTools settings.
|
|
100
|
+
|
|
101
|
+
The data we collect is completely anonymous, not traceable to the source (using hash+seed), and only meaningful in aggregate form. No data we collect is personally identifiable or trackable.
|
|
102
|
+
|
|
103
|
+
### Events
|
|
104
|
+
|
|
105
|
+
On top of the [default Nuxt Telemetry events](https://github.com/nuxt/telemetry#events), Nuxt DevTools also collects the following events:
|
|
106
|
+
|
|
107
|
+
- Versions of Nuxt DevTools
|
|
108
|
+
- Navigations between tabs/feature
|
|
109
|
+
- This helps us to understand which features are used the most to prioritize our efforts.
|
|
110
|
+
- Browser and OS names and versions
|
|
111
|
+
- This helps us improve compatibility across different browsers and operating systems.
|
|
112
|
+
- Click event on some action buttons
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
[MIT](./LICENSE)
|
|
117
|
+
|
|
118
|
+
<!-- Badges -->
|
|
119
|
+
|
|
120
|
+
[npm-version-src]: https://img.shields.io/npm/v/@nuxt/devtools/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
121
|
+
[npm-version-href]: https://npmjs.com/package/@nuxt/devtools
|
|
122
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/@nuxt/devtools.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
123
|
+
[npm-downloads-href]: https://npm.chart.dev/@nuxt/devtools
|
|
124
|
+
[license-src]: https://img.shields.io/npm/l/@nuxt/devtools.svg?style=flat&colorA=18181B&colorB=28CF8D
|
|
125
|
+
[license-href]: https://npmjs.com/package/@nuxt/devtools
|
|
126
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
|
|
127
|
+
[nuxt-href]: https://nuxt.com
|
|
128
|
+
[volta-src]: https://user-images.githubusercontent.com/904724/209143798-32345f6c-3cf8-4e06-9659-f4ace4a6acde.svg
|
|
129
|
+
[volta-href]: https://volta.net/nuxt/devtools?utm_source=nuxt_devtools_readme
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
reject: false,
|
|
25
|
+
...execaOptions,
|
|
26
|
+
env: {
|
|
27
|
+
COLORS: "true",
|
|
28
|
+
FORCE_COLOR: "true",
|
|
29
|
+
...execaOptions.env,
|
|
30
|
+
// Force disable Nuxi CLI override
|
|
31
|
+
__CLI_ARGV__: void 0
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
nuxt.callHook("devtools:terminal:write", { id, data: `> ${[execaOptions.command, ...execaOptions.args || []].join(" ")}
|
|
36
|
+
|
|
37
|
+
` });
|
|
38
|
+
process2.stdout.on("data", (data) => {
|
|
39
|
+
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
|
|
40
|
+
});
|
|
41
|
+
process2.stderr.on("data", (data) => {
|
|
42
|
+
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
|
|
43
|
+
});
|
|
44
|
+
process2.on("exit", (code) => {
|
|
45
|
+
if (!restarting) {
|
|
46
|
+
nuxt.callHook("devtools:terminal:write", { id, data: `
|
|
47
|
+
> process terminalated with ${code}
|
|
48
|
+
` });
|
|
49
|
+
nuxt.callHook("devtools:terminal:exit", { id, code: code || 0 });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return process2;
|
|
53
|
+
}
|
|
54
|
+
register();
|
|
55
|
+
nuxt.hook("close", () => {
|
|
56
|
+
terminate();
|
|
57
|
+
});
|
|
58
|
+
let process = start();
|
|
59
|
+
function restart() {
|
|
60
|
+
restarting = true;
|
|
61
|
+
process?.kill();
|
|
62
|
+
clear();
|
|
63
|
+
process = start();
|
|
64
|
+
restarting = false;
|
|
65
|
+
}
|
|
66
|
+
function clear() {
|
|
67
|
+
tabOptions.buffer = "";
|
|
68
|
+
register();
|
|
69
|
+
}
|
|
70
|
+
function terminate() {
|
|
71
|
+
restarting = false;
|
|
72
|
+
try {
|
|
73
|
+
process?.kill();
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
nuxt.callHook("devtools:terminal:remove", { id });
|
|
77
|
+
}
|
|
78
|
+
function register() {
|
|
79
|
+
nuxt.callHook("devtools:terminal:register", {
|
|
80
|
+
onActionRestart: tabOptions.restartable === false ? void 0 : restart,
|
|
81
|
+
onActionTerminate: tabOptions.terminatable === false ? void 0 : terminate,
|
|
82
|
+
isTerminated: false,
|
|
83
|
+
...tabOptions
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
getProcess() {
|
|
88
|
+
return process;
|
|
89
|
+
},
|
|
90
|
+
terminate,
|
|
91
|
+
restart,
|
|
92
|
+
clear
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function extendServerRpc(namespace, functions, nuxt = kit.useNuxt()) {
|
|
96
|
+
const ctx = _getContext(nuxt);
|
|
97
|
+
if (!ctx)
|
|
98
|
+
throw new Error("Failed to get devtools context.");
|
|
99
|
+
return ctx.extendServerRpc(namespace, functions);
|
|
100
|
+
}
|
|
101
|
+
function onDevToolsInitialized(fn, nuxt = kit.useNuxt()) {
|
|
102
|
+
nuxt.hook("devtools:initialized", fn);
|
|
103
|
+
}
|
|
104
|
+
function _getContext(nuxt = kit.useNuxt()) {
|
|
105
|
+
return nuxt?.devtools;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
exports.addCustomTab = addCustomTab;
|
|
109
|
+
exports.extendServerRpc = extendServerRpc;
|
|
110
|
+
exports.onDevToolsInitialized = onDevToolsInitialized;
|
|
111
|
+
exports.refreshCustomTabs = refreshCustomTabs;
|
|
112
|
+
exports.startSubprocess = startSubprocess;
|
package/dist/index.d.cts
ADDED
|
@@ -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 { M as ModuleCustomTab, S as SubprocessOptions, T as TerminalState, N as NuxtDevtoolsInfo } from './shared/devtools-kit-nightly.s0VF6R5p.cjs';
|
|
5
|
+
import 'vue';
|
|
6
|
+
import 'nuxt/schema';
|
|
7
|
+
import 'unimport';
|
|
8
|
+
import 'vite-plugin-vue-inspector';
|
|
9
|
+
import 'vue-router';
|
|
10
|
+
import 'nitropack';
|
|
11
|
+
import 'unstorage';
|
|
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 = Record<string, never>, ServerFunctions = Record<string, never>>(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.d.mts
ADDED
|
@@ -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 { M as ModuleCustomTab, S as SubprocessOptions, T as TerminalState, N as NuxtDevtoolsInfo } from './shared/devtools-kit-nightly.s0VF6R5p.mjs';
|
|
5
|
+
import 'vue';
|
|
6
|
+
import 'nuxt/schema';
|
|
7
|
+
import 'unimport';
|
|
8
|
+
import 'vite-plugin-vue-inspector';
|
|
9
|
+
import 'vue-router';
|
|
10
|
+
import 'nitropack';
|
|
11
|
+
import 'unstorage';
|
|
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 = Record<string, never>, ServerFunctions = Record<string, never>>(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.d.ts
ADDED
|
@@ -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 { M as ModuleCustomTab, S as SubprocessOptions, T as TerminalState, N as NuxtDevtoolsInfo } from './shared/devtools-kit-nightly.s0VF6R5p.js';
|
|
5
|
+
import 'vue';
|
|
6
|
+
import 'nuxt/schema';
|
|
7
|
+
import 'unimport';
|
|
8
|
+
import 'vite-plugin-vue-inspector';
|
|
9
|
+
import 'vue-router';
|
|
10
|
+
import 'nitropack';
|
|
11
|
+
import 'unstorage';
|
|
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 = Record<string, never>, ServerFunctions = Record<string, never>>(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,106 @@
|
|
|
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
|
+
reject: false,
|
|
23
|
+
...execaOptions,
|
|
24
|
+
env: {
|
|
25
|
+
COLORS: "true",
|
|
26
|
+
FORCE_COLOR: "true",
|
|
27
|
+
...execaOptions.env,
|
|
28
|
+
// Force disable Nuxi CLI override
|
|
29
|
+
__CLI_ARGV__: void 0
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
nuxt.callHook("devtools:terminal:write", { id, data: `> ${[execaOptions.command, ...execaOptions.args || []].join(" ")}
|
|
34
|
+
|
|
35
|
+
` });
|
|
36
|
+
process2.stdout.on("data", (data) => {
|
|
37
|
+
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
|
|
38
|
+
});
|
|
39
|
+
process2.stderr.on("data", (data) => {
|
|
40
|
+
nuxt.callHook("devtools:terminal:write", { id, data: data.toString() });
|
|
41
|
+
});
|
|
42
|
+
process2.on("exit", (code) => {
|
|
43
|
+
if (!restarting) {
|
|
44
|
+
nuxt.callHook("devtools:terminal:write", { id, data: `
|
|
45
|
+
> process terminalated with ${code}
|
|
46
|
+
` });
|
|
47
|
+
nuxt.callHook("devtools:terminal:exit", { id, code: code || 0 });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return process2;
|
|
51
|
+
}
|
|
52
|
+
register();
|
|
53
|
+
nuxt.hook("close", () => {
|
|
54
|
+
terminate();
|
|
55
|
+
});
|
|
56
|
+
let process = start();
|
|
57
|
+
function restart() {
|
|
58
|
+
restarting = true;
|
|
59
|
+
process?.kill();
|
|
60
|
+
clear();
|
|
61
|
+
process = start();
|
|
62
|
+
restarting = false;
|
|
63
|
+
}
|
|
64
|
+
function clear() {
|
|
65
|
+
tabOptions.buffer = "";
|
|
66
|
+
register();
|
|
67
|
+
}
|
|
68
|
+
function terminate() {
|
|
69
|
+
restarting = false;
|
|
70
|
+
try {
|
|
71
|
+
process?.kill();
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
nuxt.callHook("devtools:terminal:remove", { id });
|
|
75
|
+
}
|
|
76
|
+
function register() {
|
|
77
|
+
nuxt.callHook("devtools:terminal:register", {
|
|
78
|
+
onActionRestart: tabOptions.restartable === false ? void 0 : restart,
|
|
79
|
+
onActionTerminate: tabOptions.terminatable === false ? void 0 : terminate,
|
|
80
|
+
isTerminated: false,
|
|
81
|
+
...tabOptions
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
getProcess() {
|
|
86
|
+
return process;
|
|
87
|
+
},
|
|
88
|
+
terminate,
|
|
89
|
+
restart,
|
|
90
|
+
clear
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function extendServerRpc(namespace, functions, nuxt = useNuxt()) {
|
|
94
|
+
const ctx = _getContext(nuxt);
|
|
95
|
+
if (!ctx)
|
|
96
|
+
throw new Error("Failed to get devtools context.");
|
|
97
|
+
return ctx.extendServerRpc(namespace, functions);
|
|
98
|
+
}
|
|
99
|
+
function onDevToolsInitialized(fn, nuxt = useNuxt()) {
|
|
100
|
+
nuxt.hook("devtools:initialized", fn);
|
|
101
|
+
}
|
|
102
|
+
function _getContext(nuxt = useNuxt()) {
|
|
103
|
+
return nuxt?.devtools;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { addCustomTab, extendServerRpc, onDevToolsInitialized, refreshCustomTabs, startSubprocess };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NuxtDevtoolsHostClient } from '@nuxt/devtools-kit/types';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
export declare function onDevtoolsHostClientConnected(fn: (client: NuxtDevtoolsHostClient) => void): (() => void) | undefined;
|
|
4
|
+
export declare function useDevtoolsHostClient(): Ref<any, any>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { shallowRef } from "vue";
|
|
2
|
+
let clientRef;
|
|
3
|
+
const fns = [];
|
|
4
|
+
export function onDevtoolsHostClientConnected(fn) {
|
|
5
|
+
fns.push(fn);
|
|
6
|
+
if (typeof window === "undefined")
|
|
7
|
+
return;
|
|
8
|
+
if (window.__NUXT_DEVTOOLS_HOST__) {
|
|
9
|
+
fns.forEach((fn2) => fn2(window.__NUXT_DEVTOOLS_HOST__));
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(window, "__NUXT_DEVTOOLS_HOST__", {
|
|
12
|
+
set(value) {
|
|
13
|
+
if (value)
|
|
14
|
+
fns.forEach((fn2) => fn2(value));
|
|
15
|
+
},
|
|
16
|
+
get() {
|
|
17
|
+
return clientRef.value;
|
|
18
|
+
},
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
return () => {
|
|
22
|
+
fns.splice(fns.indexOf(fn), 1);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function useDevtoolsHostClient() {
|
|
26
|
+
if (!clientRef) {
|
|
27
|
+
clientRef = shallowRef();
|
|
28
|
+
onDevtoolsHostClientConnected(setup);
|
|
29
|
+
}
|
|
30
|
+
function setup(client) {
|
|
31
|
+
clientRef.value = client;
|
|
32
|
+
}
|
|
33
|
+
return clientRef;
|
|
34
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NuxtDevtoolsIframeClient } from '@nuxt/devtools-kit/types';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
export declare function onDevtoolsClientConnected(fn: (client: NuxtDevtoolsIframeClient) => void): (() => void) | undefined;
|
|
4
|
+
export declare function useDevtoolsClient(): Ref<any, any>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { shallowRef, triggerRef } from "vue";
|
|
2
|
+
let clientRef;
|
|
3
|
+
const hasSetup = false;
|
|
4
|
+
const fns = [];
|
|
5
|
+
export function onDevtoolsClientConnected(fn) {
|
|
6
|
+
fns.push(fn);
|
|
7
|
+
if (hasSetup)
|
|
8
|
+
return;
|
|
9
|
+
if (typeof window === "undefined")
|
|
10
|
+
return;
|
|
11
|
+
if (window.__NUXT_DEVTOOLS__) {
|
|
12
|
+
fns.forEach((fn2) => fn2(window.__NUXT_DEVTOOLS__));
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(window, "__NUXT_DEVTOOLS__", {
|
|
15
|
+
set(value) {
|
|
16
|
+
if (value)
|
|
17
|
+
fns.forEach((fn2) => fn2(value));
|
|
18
|
+
},
|
|
19
|
+
get() {
|
|
20
|
+
return clientRef.value;
|
|
21
|
+
},
|
|
22
|
+
configurable: true
|
|
23
|
+
});
|
|
24
|
+
return () => {
|
|
25
|
+
fns.splice(fns.indexOf(fn), 1);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function useDevtoolsClient() {
|
|
29
|
+
if (!clientRef) {
|
|
30
|
+
clientRef = shallowRef();
|
|
31
|
+
onDevtoolsClientConnected(setup);
|
|
32
|
+
}
|
|
33
|
+
function onUpdateReactivity() {
|
|
34
|
+
if (clientRef) {
|
|
35
|
+
triggerRef(clientRef);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function setup(client) {
|
|
39
|
+
clientRef.value = client;
|
|
40
|
+
if (client.host)
|
|
41
|
+
client.host.hooks.hook("host:update:reactivity", onUpdateReactivity);
|
|
42
|
+
}
|
|
43
|
+
return clientRef;
|
|
44
|
+
}
|