@nuxt/devtools-onboard 0.0.0-stage → 4.0.0-beta.4
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 +23 -2
- package/dist/module.d.mts +5 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +61 -0
- package/dist/types.d.mts +7 -0
- package/package.json +40 -3
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
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nuxt/devtools-onboard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The entry point of [Nuxt DevTools](https://devtools.nuxt.com). It is a tiny Nuxt module that Nuxt 5 ships instead of depending on `@nuxt/devtools` directly:
|
|
4
|
+
|
|
5
|
+
- when `@nuxt/devtools` is installed in your project, it loads it;
|
|
6
|
+
- when it is not, `nuxt dev` shows a floating button (built on [`@devframes/hub-ui-onboard`](https://devfra.me/guide/hub-ui-onboard)) that installs it with your package manager and restarts the dev server, so the real DevTools dock takes its place.
|
|
7
|
+
|
|
8
|
+
Nothing is injected outside `nuxt dev`.
|
|
9
|
+
|
|
10
|
+
## Turning it off
|
|
11
|
+
|
|
12
|
+
- `devtools: false` (or `devtools: { enabled: false }`) in `nuxt.config` disables both the button and DevTools.
|
|
13
|
+
- **Disable entirely** in the button's panel writes `node_modules/.devframe/hub-ui-onboard.json`; the button stays hidden on later starts until you delete that file or set the `devtools` option explicitly.
|
|
14
|
+
- **Hide for now** hides the button for the current tab only.
|
|
15
|
+
|
|
16
|
+
## Nuxt 4
|
|
17
|
+
|
|
18
|
+
Nuxt 4 depends on `@nuxt/devtools` itself, so this package is not needed there. Adding it to `modules` still works: it loads the installed DevTools and never shows the button.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
export default defineNuxtConfig({
|
|
22
|
+
modules: ['@nuxt/devtools-onboard'],
|
|
23
|
+
})
|
|
24
|
+
```
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { createOnboarding } from '@devframes/hub-ui-onboard';
|
|
3
|
+
import { defineNuxtModule, tryResolveModule, installModule } from '@nuxt/kit';
|
|
4
|
+
import { readPackageJSON } from 'pkg-types';
|
|
5
|
+
|
|
6
|
+
const DEVTOOLS = "@nuxt/devtools";
|
|
7
|
+
const DEVTOOLS_MODULES = /* @__PURE__ */ new Set([DEVTOOLS, `${DEVTOOLS}-nightly`, `${DEVTOOLS}-edge`]);
|
|
8
|
+
function listsDevtools(modules) {
|
|
9
|
+
return modules.some((entry) => {
|
|
10
|
+
const id = Array.isArray(entry) ? entry[0] : entry;
|
|
11
|
+
return typeof id === "string" && DEVTOOLS_MODULES.has(id);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async function devtoolsSpec() {
|
|
15
|
+
const { version, peerDependencies } = await readPackageJSON(fileURLToPath(import.meta.url));
|
|
16
|
+
const range = peerDependencies?.[DEVTOOLS] ?? "";
|
|
17
|
+
return `${DEVTOOLS}@${range.startsWith("npm:") ? range : `^${version}`}`;
|
|
18
|
+
}
|
|
19
|
+
const module$1 = defineNuxtModule({
|
|
20
|
+
meta: {
|
|
21
|
+
name: "@nuxt/devtools-onboard"
|
|
22
|
+
},
|
|
23
|
+
async setup(_, nuxt) {
|
|
24
|
+
const { devtools } = nuxt.options;
|
|
25
|
+
if (devtools === false || typeof devtools === "object" && devtools.enabled === false)
|
|
26
|
+
return;
|
|
27
|
+
if (listsDevtools(nuxt.options.modules))
|
|
28
|
+
return;
|
|
29
|
+
const installed = await tryResolveModule(DEVTOOLS, nuxt.options.modulesDir);
|
|
30
|
+
if (installed)
|
|
31
|
+
return installModule(installed);
|
|
32
|
+
if (!nuxt.options.dev)
|
|
33
|
+
return;
|
|
34
|
+
const onboarding = createOnboarding({
|
|
35
|
+
cwd: nuxt.options.rootDir,
|
|
36
|
+
// Where Vite DevTools mounts the hub, so after the restart the real
|
|
37
|
+
// `embedded.js` answers at the URL the button was loaded from.
|
|
38
|
+
base: "/__devtools/",
|
|
39
|
+
packages: [await devtoolsSpec()],
|
|
40
|
+
branding: {
|
|
41
|
+
productName: "Nuxt DevTools",
|
|
42
|
+
primaryColor: "#099e61",
|
|
43
|
+
logo: "https://nuxt.com/assets/design-kit/icon-green.svg"
|
|
44
|
+
},
|
|
45
|
+
messages: {
|
|
46
|
+
restart: "Installed. Restarting the dev server\u2026"
|
|
47
|
+
},
|
|
48
|
+
onInstalled() {
|
|
49
|
+
setTimeout(() => nuxt.callHook("restart", { hard: true }), 100);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
nuxt.hook("vite:serverCreated", (server, { isClient }) => {
|
|
53
|
+
if (isClient)
|
|
54
|
+
server.middlewares.use(onboarding.nodeMiddleware);
|
|
55
|
+
});
|
|
56
|
+
if (!onboarding.disabled)
|
|
57
|
+
(nuxt.options.app.head.script ??= []).push({ type: "module", src: onboarding.scriptSrc, tagPosition: "bodyClose" });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export { module$1 as default };
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/devtools-onboard",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "4.0.0-beta.4",
|
|
5
|
+
"description": "The entry point of Nuxt DevTools: loads it when installed, otherwise offers to install it from a floating button.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://devtools.nuxt.com",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/nuxt/devtools.git",
|
|
11
|
+
"directory": "packages/devtools-onboard"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./dist/module.mjs"
|
|
15
|
+
},
|
|
16
|
+
"types": "./dist/module.d.mts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@nuxt/devtools": "^4.0.0-beta.4",
|
|
22
|
+
"@nuxt/kit": "^4.0.0-0 || ^5.0.0-0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependenciesMeta": {
|
|
25
|
+
"@nuxt/devtools": {
|
|
26
|
+
"optional": true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@devframes/hub-ui-onboard": "^1.2.0",
|
|
31
|
+
"pkg-types": "^2.3.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-2610052343-36eafab",
|
|
35
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@5.0.0-2610052343-36eafab",
|
|
36
|
+
"nuxt": "npm:nuxt-nightly@5.0.0-2610052343-36eafab"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "nuxt-build-module build",
|
|
40
|
+
"stub": "nuxt-build-module build --stub",
|
|
41
|
+
"dev:prepare": "pnpm run stub"
|
|
42
|
+
}
|
|
6
43
|
}
|