@nuxt/devtools 3.2.3 → 4.0.0-alpha.1
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/README.md +3 -0
- package/dist/chunks/module-main.mjs +264 -140
- package/dist/chunks/timeline.mjs +0 -1
- package/dist/chunks/vscode.mjs +14 -41
- package/dist/chunks/vue-devtools.mjs +0 -1
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/__blank-cpzbm3dn.js +1 -0
- package/dist/client/_nuxt/analyze-build-e7v5vkef.js +1 -0
- package/dist/client/_nuxt/{assets-fjp0hrmh.js → assets-b5c187l4.js} +2 -2
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/25fc8778-785e-4df1-8047-b131fc1cd4b2.json +1 -0
- package/dist/client/_nuxt/{client-lh91kcpv.js → client-im47u3kz.js} +1 -1
- package/dist/client/_nuxt/code-diff-idsu3m0z.js +8 -0
- package/dist/client/_nuxt/{code-snippets-ho13b87l.js → code-snippets-k81hoi4s.js} +1 -1
- package/dist/client/_nuxt/components-bmictfph.js +1 -0
- package/dist/client/_nuxt/composable-item-cza22cup.js +1 -0
- package/dist/client/_nuxt/composables-b2ccklz4.js +1 -0
- package/dist/client/_nuxt/constants-ih922r91.js +1 -0
- package/dist/client/_nuxt/copkoh3j.js +4 -0
- package/dist/client/_nuxt/custom-_name_-gqm5kr56.js +1 -0
- package/dist/client/_nuxt/{data-schema-button-ke4komn6.js → data-schema-button-b308wyi0.js} +1 -1
- package/dist/client/_nuxt/data-schema-drawer-lr34uwsh.js +2 -0
- package/dist/client/_nuxt/debug-kgc8fptp.js +1 -0
- package/dist/client/_nuxt/{default-bunv5fnq.js → default-jvhm51ri.js} +1 -1
- package/dist/client/_nuxt/dev-auth-ojiqold5.js +1 -0
- package/dist/client/_nuxt/{duration-display-20xlusue.js → duration-display-f7ucshmo.js} +1 -1
- package/dist/client/_nuxt/entry.css-me26coxn.css +1 -0
- package/dist/client/_nuxt/error-404-nggtc73s.js +1 -0
- package/dist/client/_nuxt/error-404.css-j1aav08u.css +1 -0
- package/dist/client/_nuxt/error-500-dym2gzqx.js +1 -0
- package/dist/client/_nuxt/error-500.css-eu9fz4va.css +1 -0
- package/dist/client/_nuxt/{error-isnb18yz.js → error-fqinfa1x.js} +2 -2
- package/dist/client/_nuxt/{filepath-item-fnp9jxof.js → filepath-item-e1s52fbh.js} +1 -1
- package/dist/client/_nuxt/full-et0weok9.js +1 -0
- package/dist/client/_nuxt/{help-fab-oc1qudll.js → help-fab-hz6r2oxa.js} +1 -1
- package/dist/client/_nuxt/hooks-i7nsduqp.js +1 -0
- package/dist/client/_nuxt/imports-9o2qs53q.js +1 -0
- package/dist/client/_nuxt/{launch-page-kf0w74wk.js → launch-page-hpkkqhit.js} +1 -1
- package/dist/client/_nuxt/mitt.es-fjx0h8xe.js +1 -0
- package/dist/client/_nuxt/modules-jok0opuq.js +1 -0
- package/dist/client/_nuxt/nbadge-m66xoquo.js +1 -0
- package/dist/client/_nuxt/{nbutton-oi1rfqiz.js → nbutton-gygn07c2.js} +1 -1
- package/dist/client/_nuxt/ncard-mqcl8pso.js +1 -0
- package/dist/client/_nuxt/ncheckbox-c0r45qtu.js +1 -0
- package/dist/client/_nuxt/{ncode-block-coc4sua0.js → ncode-block-figzf35k.js} +1 -1
- package/dist/client/_nuxt/ndrawer-bgqyrlmt.js +1 -0
- package/dist/client/_nuxt/ndropdown-cip8lboe.js +1 -0
- package/dist/client/_nuxt/{nicon-m5br9nvg.js → nicon-m1crov2l.js} +1 -1
- package/dist/client/_nuxt/{nicon-title-e35pdr21.js → nicon-title-tqdvw0w0.js} +1 -1
- package/dist/client/_nuxt/{nlink-dmk2d6qc.js → nlink-od4lllbl.js} +1 -1
- package/dist/client/_nuxt/{nmarkdown-nct1w6kn.js → nmarkdown-hw0hmqw7.js} +1 -1
- package/dist/client/_nuxt/{nnavbar-n3j7iul1.js → nnavbar-lpozm5fj.js} +1 -1
- package/dist/client/_nuxt/none-bdxkqeml.js +1 -0
- package/dist/client/_nuxt/npanel-grids-dd23ifsw.js +1 -0
- package/dist/client/_nuxt/nsection-block-lqrohs9v.js +1 -0
- package/dist/client/_nuxt/nselect-gczoit0g.js +1 -0
- package/dist/client/_nuxt/nselect-tabs-bsw5fg3d.js +1 -0
- package/dist/client/_nuxt/{nswitch-b36trghq.js → nswitch-ke379yjx.js} +1 -1
- package/dist/client/_nuxt/ntext-input-cygthohl.js +1 -0
- package/dist/client/_nuxt/ntip-ke63ovgc.js +1 -0
- package/dist/client/_nuxt/nuxt-link-bumooa9d.js +1 -0
- package/dist/client/_nuxt/nuxt-otp6bp04.js +1 -0
- package/dist/client/_nuxt/{open-graph-m7wd1sxi.js → open-graph-lumhcitx.js} +2 -2
- package/dist/client/_nuxt/overview-c1ufrox9.js +1 -0
- package/dist/client/_nuxt/pages-cf1hvns3.js +1 -0
- package/dist/client/_nuxt/pages-lgihsvbt.js +1 -0
- package/dist/client/_nuxt/payload-fvgw4hh9.js +1 -0
- package/dist/client/_nuxt/pinia-lmrgyjxw.js +1 -0
- package/dist/client/_nuxt/plugins-ccaip8nh.js +1 -0
- package/dist/client/_nuxt/ready-dadbdj5i.js +1 -0
- package/dist/client/_nuxt/render-tree-corj3giw.js +1 -0
- package/dist/client/_nuxt/rpc-ez4fzlum.js +1 -0
- package/dist/client/_nuxt/runtime-configs-im0uu24n.js +1 -0
- package/dist/client/_nuxt/server-discovery-ffkkczqi.js +1 -0
- package/dist/client/_nuxt/server-route-inputs-lspeoiem.js +1 -0
- package/dist/client/_nuxt/server-routes-dhvqrowz.js +7 -0
- package/dist/client/_nuxt/server-tasks-mr9ezn8q.js +1 -0
- package/dist/client/_nuxt/settings-issronwn.js +1 -0
- package/dist/client/_nuxt/{splitpanes.es-ceqv8417.js → splitpanes.es-bxyirks2.js} +1 -1
- package/dist/client/_nuxt/{stacktrace-list-m1sv2uvd.js → stacktrace-list-hiui24c3.js} +1 -1
- package/dist/client/_nuxt/state-components-fbls8ka7.js +1 -0
- package/dist/client/_nuxt/state-editor-c7e04uj2.js +1 -0
- package/dist/client/_nuxt/state-modules-inqbwd7z.js +1 -0
- package/dist/client/_nuxt/{state-routes-m6gv5n9v.js → state-routes-jln33b1m.js} +1 -1
- package/dist/client/_nuxt/state-tabs-etl5jr30.js +1 -0
- package/dist/client/_nuxt/storage-husj5pg6.js +1 -0
- package/dist/client/_nuxt/storage-options-cth3coln.js +1 -0
- package/dist/client/_nuxt/telemetry-eqv6a0hn.js +1 -0
- package/dist/client/_nuxt/terminals-kitd8oja.js +1 -0
- package/dist/client/_nuxt/timeline-gr4tcvcz.js +31 -0
- package/dist/client/_nuxt/unocss-runtime-cpug61u1.js +1 -0
- package/dist/client/_nuxt/utils-nbkl6byi.js +2 -0
- package/dist/client/_nuxt/vendor/{json-editor-vue-hkofgjf7.js → json-editor-vue-eojr4v24.js} +3 -3
- package/dist/client/_nuxt/vendor/{markdown-it-bcxn77q6.js → markdown-it-ckeo8pwp.js} +1 -1
- package/dist/client/_nuxt/vendor/{shiki-niqic03h.js → shiki-lqo1hg2n.js} +3 -3
- package/dist/client/_nuxt/vendor/{unocss-bj3ln324.js → unocss-k727ub0h.js} +1 -1
- package/dist/client/_nuxt/virtual-files-ky9cc4av.js +1 -0
- package/dist/client/_nuxt/vue-devtools-dunhx2nz.js +4 -0
- package/dist/client/_nuxt/{vue-router-dxks01bs.js → vue-router-jbnxw7nb.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/dirs.d.mts +1 -2
- package/dist/dirs.mjs +1 -21
- package/dist/module.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -5
- package/dist/runtime/plugins/devtools.client.js +1 -1
- package/dist/runtime/plugins/view/client.js +22 -72
- package/dist/runtime/plugins/view/state.d.ts +0 -1
- package/dist/runtime/plugins/view/state.js +0 -2
- package/dist/shared/devtools.COlX0Gls.mjs +114 -0
- package/dist/shared/{devtools.C1a10l_c.d.mts → devtools.LsRDzDTD.d.mts} +0 -12
- package/dist/types.d.mts +1 -1
- package/dist/webcomponents/index.d.mts +1 -3
- package/dist/webcomponents/index.mjs +38 -1185
- package/package.json +24 -32
- package/cli.mjs +0 -2
- package/dist/client/_nuxt/__blank-gayjf0ih.js +0 -1
- package/dist/client/_nuxt/analyze-build-bnq2cil8.js +0 -1
- package/dist/client/_nuxt/builds/meta/f343c68e-9061-4942-a0df-50170dc001bd.json +0 -1
- package/dist/client/_nuxt/client-s5g5n0ac.js +0 -2
- package/dist/client/_nuxt/code-diff-cb7twqkt.js +0 -8
- package/dist/client/_nuxt/components-peth8amc.js +0 -1
- package/dist/client/_nuxt/composable-item-b09pj4ca.js +0 -1
- package/dist/client/_nuxt/composables-cwesk2q8.js +0 -1
- package/dist/client/_nuxt/constants-lof1c7kz.js +0 -1
- package/dist/client/_nuxt/custom-_name_-lfwzilnd.js +0 -1
- package/dist/client/_nuxt/data-schema-drawer-dqe6w00i.js +0 -2
- package/dist/client/_nuxt/debug-itzra6gt.js +0 -1
- package/dist/client/_nuxt/dev-auth-j4vxv6a1.js +0 -1
- package/dist/client/_nuxt/entry.css-ckq2wff8.css +0 -1
- package/dist/client/_nuxt/error-404-c73bftho.js +0 -1
- package/dist/client/_nuxt/error-404.css-pazrj6fo.css +0 -1
- package/dist/client/_nuxt/error-500-75llnfh8.js +0 -1
- package/dist/client/_nuxt/error-500.css-hlldh6hu.css +0 -1
- package/dist/client/_nuxt/full-h8pokapo.js +0 -1
- package/dist/client/_nuxt/head-c2jgvqd9.js +0 -1
- package/dist/client/_nuxt/hooks-i5p6cuw0.js +0 -1
- package/dist/client/_nuxt/imports-ia8eldh8.js +0 -1
- package/dist/client/_nuxt/l471sqq0.js +0 -4
- package/dist/client/_nuxt/modules-obwfskfp.js +0 -1
- package/dist/client/_nuxt/nbadge-hpznun17.js +0 -1
- package/dist/client/_nuxt/ncard-ech06vlh.js +0 -1
- package/dist/client/_nuxt/ncheckbox-k9nxqa1w.js +0 -1
- package/dist/client/_nuxt/ndrawer-ijwn9421.js +0 -1
- package/dist/client/_nuxt/ndropdown-moy416uy.js +0 -1
- package/dist/client/_nuxt/none-bs12srzp.js +0 -1
- package/dist/client/_nuxt/npanel-grids-bl37sfq7.js +0 -1
- package/dist/client/_nuxt/nsection-block-l0c6dpg8.js +0 -1
- package/dist/client/_nuxt/nselect-kgjpj17v.js +0 -1
- package/dist/client/_nuxt/nselect-tabs-if6er1us.js +0 -1
- package/dist/client/_nuxt/ntext-input-ngomk0u2.js +0 -1
- package/dist/client/_nuxt/nuxt-bfozs29x.js +0 -1
- package/dist/client/_nuxt/nuxt-link-mev16ngd.js +0 -1
- package/dist/client/_nuxt/overview-dbrpdvvy.js +0 -1
- package/dist/client/_nuxt/pages-gnfgydad.js +0 -1
- package/dist/client/_nuxt/pages-izgjpbm4.js +0 -1
- package/dist/client/_nuxt/payload-hc17espa.js +0 -1
- package/dist/client/_nuxt/pinia-ns87k5yi.js +0 -1
- package/dist/client/_nuxt/plugins-mswypwe4.js +0 -1
- package/dist/client/_nuxt/ready-szdlhgcr.js +0 -1
- package/dist/client/_nuxt/render-tree-hec27xi7.js +0 -1
- package/dist/client/_nuxt/runtime-configs-chx5ggf0.js +0 -1
- package/dist/client/_nuxt/server-discovery-cjcj8emm.js +0 -1
- package/dist/client/_nuxt/server-route-inputs-lqwnul2k.js +0 -1
- package/dist/client/_nuxt/server-routes-e0uqj8di.js +0 -7
- package/dist/client/_nuxt/server-tasks-izz5mcrk.js +0 -1
- package/dist/client/_nuxt/settings-dhxjcakv.js +0 -1
- package/dist/client/_nuxt/state-components-mnfvrbtw.js +0 -1
- package/dist/client/_nuxt/state-dkywakbf.js +0 -1
- package/dist/client/_nuxt/state-editor-epijodsw.js +0 -1
- package/dist/client/_nuxt/state-modules-ehax0fup.js +0 -1
- package/dist/client/_nuxt/state-tabs-mo8r9nzk.js +0 -1
- package/dist/client/_nuxt/storage-hdyfvofj.js +0 -1
- package/dist/client/_nuxt/storage-options-owy2vf04.js +0 -1
- package/dist/client/_nuxt/telemetry-bagjjni2.js +0 -1
- package/dist/client/_nuxt/terminals-hem69799.js +0 -1
- package/dist/client/_nuxt/timeline-luryae8h.js +0 -31
- package/dist/client/_nuxt/unocss-runtime-jcr8lucj.js +0 -1
- package/dist/client/_nuxt/virtual-files-o2l5arel.js +0 -1
- package/dist/client/_nuxt/vue-devtools-na2nb82m.js +0 -3
- package/dist/client/_nuxt/vue-virtual-scroller.esm-d0igfpwe.js +0 -2
- package/dist/shared/devtools.DuFZOCNN.mjs +0 -122
- /package/dist/client/_nuxt/{_plugin-vue_export-helper-dp8rxgcg.js → _plugin-vue_export-helper-n58akrbk.js} +0 -0
- /package/dist/client/_nuxt/vendor/{quicktype-core-f8dnflnv.js → quicktype-core-k4qx3809.js} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import fs, { existsSync, promises, statSync, realpathSync, readFileSync, accessSync, constants } from 'node:fs';
|
|
2
|
-
import
|
|
1
|
+
import fs$1, { existsSync, promises, statSync, realpathSync, readFileSync, accessSync, constants } from 'node:fs';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
3
|
import os, { homedir } from 'node:os';
|
|
4
4
|
import { logger, useNuxt, addVitePlugin, addPlugin, addTemplate, extendViteConfig, addImports } from '@nuxt/kit';
|
|
5
5
|
import { colors } from 'consola/utils';
|
|
6
6
|
import { join, dirname as dirname$1, resolve, isAbsolute } from 'pathe';
|
|
7
7
|
import sirv from 'sirv';
|
|
8
8
|
import { searchForWorkspaceRoot } from 'vite';
|
|
9
|
-
import { d as defaultAllowedExtensions, a as defaultTabOptions, W as WS_EVENT_NAME } from '../shared/devtools.
|
|
9
|
+
import { d as defaultAllowedExtensions, a as defaultTabOptions, W as WS_EVENT_NAME } from '../shared/devtools.COlX0Gls.mjs';
|
|
10
10
|
import path, { dirname, join as join$1, relative, parse } from 'node:path';
|
|
11
11
|
import { hash } from 'ohash';
|
|
12
|
-
import { runtimeDir, clientDir, packageDir
|
|
12
|
+
import { runtimeDir, clientDir, packageDir } from '../dirs.mjs';
|
|
13
13
|
import { createBirpcGroup } from 'birpc';
|
|
14
14
|
import { parse as parse$1, stringify } from 'structured-clone-es';
|
|
15
15
|
import { startSubprocess } from '@nuxt/devtools-kit';
|
|
16
|
-
import
|
|
16
|
+
import { x } from 'tinyexec';
|
|
17
17
|
import { glob } from 'tinyglobby';
|
|
18
18
|
import { imageMeta } from 'image-meta';
|
|
19
19
|
import { debounce } from 'perfect-debounce';
|
|
@@ -27,14 +27,12 @@ import assert from 'node:assert';
|
|
|
27
27
|
import v8 from 'node:v8';
|
|
28
28
|
import { format, inspect } from 'node:util';
|
|
29
29
|
import { resolveModule, getPackageInfo } from 'local-pkg';
|
|
30
|
-
import isInstalledGlobally from 'is-installed-globally';
|
|
31
30
|
import { parseModule } from 'magicast';
|
|
32
31
|
import { getDefaultExportOptions, addNuxtModule } from 'magicast/helpers';
|
|
33
|
-
import { detectPackageManager } from 'nypm';
|
|
34
32
|
import semver from 'semver';
|
|
35
33
|
import { normalizeBaseKey, normalizeKey } from 'unstorage';
|
|
36
34
|
|
|
37
|
-
const version$1 = "
|
|
35
|
+
const version$1 = "4.0.0-alpha.1";
|
|
38
36
|
|
|
39
37
|
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
40
38
|
function randomStr(size = 16, dict = urlAlphabet) {
|
|
@@ -55,7 +53,7 @@ async function readLocalOptions(defaults, options) {
|
|
|
55
53
|
try {
|
|
56
54
|
const options2 = {
|
|
57
55
|
...defaults,
|
|
58
|
-
...JSON.parse(await
|
|
56
|
+
...JSON.parse(await fs.readFile(filePath, "utf-8")).settings || {}
|
|
59
57
|
};
|
|
60
58
|
return options2;
|
|
61
59
|
} catch (e) {
|
|
@@ -83,12 +81,12 @@ function getOptionsFilepath(options) {
|
|
|
83
81
|
async function clearLocalOptions(options) {
|
|
84
82
|
const { filePath } = getOptionsFilepath(options);
|
|
85
83
|
if (existsSync(filePath))
|
|
86
|
-
await
|
|
84
|
+
await fs.unlink(filePath);
|
|
87
85
|
}
|
|
88
86
|
async function writeLocalOptions(settings, options) {
|
|
89
87
|
const { filePath, hashedKey } = getOptionsFilepath(options);
|
|
90
|
-
await
|
|
91
|
-
await
|
|
88
|
+
await fs.mkdir(dirname(filePath), { recursive: true });
|
|
89
|
+
await fs.writeFile(
|
|
92
90
|
filePath,
|
|
93
91
|
JSON.stringify(
|
|
94
92
|
{
|
|
@@ -111,11 +109,11 @@ async function getDevAuthToken() {
|
|
|
111
109
|
const dir = join$1(home, ".nuxt/devtools");
|
|
112
110
|
const filepath = join$1(dir, "dev-auth-token.txt");
|
|
113
111
|
if (existsSync(filepath))
|
|
114
|
-
token = (await
|
|
112
|
+
token = (await fs.readFile(filepath, "utf-8")).trim();
|
|
115
113
|
if (!token)
|
|
116
114
|
token = randomStr(16);
|
|
117
|
-
await
|
|
118
|
-
await
|
|
115
|
+
await fs.mkdir(dir, { recursive: true });
|
|
116
|
+
await fs.writeFile(filepath, token, "utf-8");
|
|
119
117
|
return token;
|
|
120
118
|
}
|
|
121
119
|
|
|
@@ -140,7 +138,7 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
140
138
|
}, nuxt);
|
|
141
139
|
refresh("getAnalyzeBuildInfo");
|
|
142
140
|
initalized = void 0;
|
|
143
|
-
promise = result.
|
|
141
|
+
promise = Promise.resolve(result.getResult()).then(() => {
|
|
144
142
|
refresh("getAnalyzeBuildInfo");
|
|
145
143
|
return readBuildInfo();
|
|
146
144
|
}).finally(() => {
|
|
@@ -162,10 +160,10 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
162
160
|
absolute: true
|
|
163
161
|
});
|
|
164
162
|
for (const file of files2) {
|
|
165
|
-
const slug = JSON.parse(await
|
|
163
|
+
const slug = JSON.parse(await fs.readFile(file, "utf-8")).slug;
|
|
166
164
|
const dir2 = dirname$1(file);
|
|
167
|
-
await
|
|
168
|
-
await
|
|
165
|
+
await fs.mkdir(devtoolsAnalyzeDir, { recursive: true });
|
|
166
|
+
await fs.rename(dir2, join(devtoolsAnalyzeDir, slug));
|
|
169
167
|
}
|
|
170
168
|
}
|
|
171
169
|
const files = await glob(["**/meta.json"], {
|
|
@@ -175,26 +173,29 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
175
173
|
});
|
|
176
174
|
builds = await Promise.all(files.map(async (file) => {
|
|
177
175
|
const dir = dirname$1(file);
|
|
178
|
-
const json = JSON.parse(await
|
|
176
|
+
const json = JSON.parse(await fs.readFile(file, "utf-8"));
|
|
179
177
|
return {
|
|
180
178
|
...json,
|
|
181
179
|
features: {
|
|
182
|
-
bundleClient: fs.existsSync(join(dir, "client.html")),
|
|
183
|
-
bundleNitro: fs.existsSync(join(dir, "nitro.html")),
|
|
184
|
-
viteInspect: fs.existsSync(join(dir, ".vite-inspect"))
|
|
180
|
+
bundleClient: fs$1.existsSync(join(dir, "client.html")),
|
|
181
|
+
bundleNitro: fs$1.existsSync(join(dir, "nitro.html")),
|
|
182
|
+
viteInspect: fs$1.existsSync(join(dir, ".vite-inspect"))
|
|
185
183
|
}
|
|
186
184
|
};
|
|
187
185
|
}));
|
|
188
186
|
return builds.sort((a, b) => b.endTime - a.endTime);
|
|
189
187
|
}
|
|
188
|
+
async function git(...args) {
|
|
189
|
+
const result = await x("git", args, { nodeOptions: { cwd: nuxt.options.rootDir }, throwOnError: true });
|
|
190
|
+
return result.stdout.trim();
|
|
191
|
+
}
|
|
190
192
|
async function generateAnalyzeBuildName() {
|
|
191
193
|
try {
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
if (isWorkingTreeClean)
|
|
194
|
+
const branchName = await git("rev-parse", "--abbrev-ref", "HEAD") || "head";
|
|
195
|
+
const sha = await git("rev-parse", "--short", "HEAD");
|
|
196
|
+
const status = await git("status", "--porcelain");
|
|
197
|
+
const isClean = status === "";
|
|
198
|
+
if (isClean)
|
|
198
199
|
return `${branchName}#${sha}`;
|
|
199
200
|
return `${branchName}#${sha}-dirty`;
|
|
200
201
|
} catch {
|
|
@@ -214,10 +215,10 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
214
215
|
async clearAnalyzeBuilds(token, names) {
|
|
215
216
|
await ensureDevAuthToken(token);
|
|
216
217
|
if (!names) {
|
|
217
|
-
await
|
|
218
|
+
await fs.rm(devtoolsAnalyzeDir, { recursive: true, force: true });
|
|
218
219
|
} else {
|
|
219
220
|
const targets = builds.filter((build) => names.includes(build.name));
|
|
220
|
-
await Promise.all(targets.map((target) =>
|
|
221
|
+
await Promise.all(targets.map((target) => fs.rm(join(devtoolsAnalyzeDir, target.slug), { recursive: true, force: true })));
|
|
221
222
|
}
|
|
222
223
|
initalized = readBuildInfo();
|
|
223
224
|
refresh("getAnalyzeBuildInfo");
|
|
@@ -264,7 +265,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
264
265
|
const filePath = resolve(layerDir, path);
|
|
265
266
|
if (!filePath.startsWith(layerDir))
|
|
266
267
|
continue;
|
|
267
|
-
const stat = await
|
|
268
|
+
const stat = await fs.lstat(filePath);
|
|
268
269
|
const fullPath = join(baseURL, path);
|
|
269
270
|
if (!uniquePaths.has(fullPath)) {
|
|
270
271
|
cache.push({
|
|
@@ -291,7 +292,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
291
292
|
if (_imageMetaCache.has(filepath))
|
|
292
293
|
return _imageMetaCache.get(filepath);
|
|
293
294
|
try {
|
|
294
|
-
const meta = imageMeta(await
|
|
295
|
+
const meta = imageMeta(await fs.readFile(filepath));
|
|
295
296
|
_imageMetaCache.set(filepath, meta);
|
|
296
297
|
return meta;
|
|
297
298
|
} catch (e) {
|
|
@@ -303,7 +304,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
303
304
|
async getTextAssetContent(token, filepath, limit = 300) {
|
|
304
305
|
await ensureDevAuthToken(token);
|
|
305
306
|
try {
|
|
306
|
-
const content = await
|
|
307
|
+
const content = await fs.readFile(filepath, "utf-8");
|
|
307
308
|
return content.slice(0, limit);
|
|
308
309
|
} catch (e) {
|
|
309
310
|
console.error(e);
|
|
@@ -326,16 +327,16 @@ You can configure it in Nuxt config at \`devtools.assets.uploadExtensions\`.`);
|
|
|
326
327
|
}
|
|
327
328
|
if (!override) {
|
|
328
329
|
try {
|
|
329
|
-
await
|
|
330
|
+
await fs.stat(finalPath);
|
|
330
331
|
const base = finalPath.slice(0, finalPath.length - ext.length - 1);
|
|
331
332
|
let i = 1;
|
|
332
|
-
while (await
|
|
333
|
+
while (await fs.access(`${base}-${i}.${ext}`).then(() => true).catch(() => false))
|
|
333
334
|
i++;
|
|
334
335
|
finalPath = `${base}-${i}.${ext}`;
|
|
335
336
|
} catch {
|
|
336
337
|
}
|
|
337
338
|
}
|
|
338
|
-
await
|
|
339
|
+
await fs.writeFile(finalPath, content, {
|
|
339
340
|
encoding: encoding ?? "utf-8"
|
|
340
341
|
});
|
|
341
342
|
return finalPath;
|
|
@@ -344,14 +345,14 @@ You can configure it in Nuxt config at \`devtools.assets.uploadExtensions\`.`);
|
|
|
344
345
|
},
|
|
345
346
|
async deleteStaticAsset(token, path) {
|
|
346
347
|
await ensureDevAuthToken(token);
|
|
347
|
-
return await
|
|
348
|
+
return await fs.unlink(path);
|
|
348
349
|
},
|
|
349
350
|
async renameStaticAsset(token, oldPath, newPath) {
|
|
350
351
|
await ensureDevAuthToken(token);
|
|
351
352
|
const exist = cache?.find((asset) => asset.filePath === newPath);
|
|
352
353
|
if (exist)
|
|
353
354
|
throw new Error(`[Nuxt DevTools] File ${newPath} already exists, failed to rename`);
|
|
354
|
-
return await
|
|
355
|
+
return await fs.rename(oldPath, newPath);
|
|
355
356
|
}
|
|
356
357
|
};
|
|
357
358
|
}
|
|
@@ -7464,7 +7465,7 @@ function read(jsonPath, {base, specifier}) {
|
|
|
7464
7465
|
let string;
|
|
7465
7466
|
|
|
7466
7467
|
try {
|
|
7467
|
-
string = fs.readFileSync(path.toNamespacedPath(jsonPath), 'utf8');
|
|
7468
|
+
string = fs$1.readFileSync(path.toNamespacedPath(jsonPath), 'utf8');
|
|
7468
7469
|
} catch (error) {
|
|
7469
7470
|
const exception = /** @type {ErrnoException} */ (error);
|
|
7470
7471
|
|
|
@@ -10306,6 +10307,7 @@ function setupOptionsRPC({ nuxt }) {
|
|
|
10306
10307
|
const ABSOLUTE_PATH_RE = /^[a-z]:|^\//i;
|
|
10307
10308
|
const FILE_LINE_COL_RE = /^(.*?)(:[:\d]*)$/;
|
|
10308
10309
|
const MULTIPLE_SLASHES_RE$1 = /\/+/g;
|
|
10310
|
+
const NUXT_WELCOME_RE = /<NuxtWelcome\s*\/>/;
|
|
10309
10311
|
function setupGeneralRPC({
|
|
10310
10312
|
nuxt,
|
|
10311
10313
|
options,
|
|
@@ -10494,6 +10496,36 @@ function setupGeneralRPC({
|
|
|
10494
10496
|
return false;
|
|
10495
10497
|
}
|
|
10496
10498
|
},
|
|
10499
|
+
async enablePages(token) {
|
|
10500
|
+
await ensureDevAuthToken(token);
|
|
10501
|
+
const baseDir = nuxt.options.future.compatibilityVersion === 4 ? nuxt.options.dir.app : nuxt.options.srcDir;
|
|
10502
|
+
const pathApp = join(baseDir, "app.vue");
|
|
10503
|
+
const pathPageIndex = join(baseDir, "pages/index.vue");
|
|
10504
|
+
if (existsSync(pathPageIndex)) {
|
|
10505
|
+
logger.warn("pages/index.vue already exists, skipping");
|
|
10506
|
+
return;
|
|
10507
|
+
}
|
|
10508
|
+
const pagesIndexTemplate = `<script setup lang="ts">
|
|
10509
|
+
const route = useRoute()
|
|
10510
|
+
<\/script>
|
|
10511
|
+
|
|
10512
|
+
<template>
|
|
10513
|
+
<div>
|
|
10514
|
+
<h1>Nuxt Routing set up successfully!</h1>
|
|
10515
|
+
<p>Current route: {{ route.path }}</p>
|
|
10516
|
+
<a href="https://nuxt.com/docs/getting-started/routing" target="_blank">Learn more about Nuxt Routing</a>
|
|
10517
|
+
</div>
|
|
10518
|
+
</template>
|
|
10519
|
+
`;
|
|
10520
|
+
await fs.mkdir(dirname$1(pathPageIndex), { recursive: true });
|
|
10521
|
+
await fs.writeFile(pathPageIndex, pagesIndexTemplate, "utf-8");
|
|
10522
|
+
let appContent = existsSync(pathApp) ? await fs.readFile(pathApp, "utf-8") : void 0;
|
|
10523
|
+
if (appContent && !appContent.includes("<NuxtPage")) {
|
|
10524
|
+
appContent = appContent.replace("</template>", " <NuxtPage />\n</template>").replace(NUXT_WELCOME_RE, "");
|
|
10525
|
+
await fs.writeFile(pathApp, appContent, "utf-8");
|
|
10526
|
+
}
|
|
10527
|
+
logger.success("Routing creation completed");
|
|
10528
|
+
},
|
|
10497
10529
|
async restartNuxt(token, hard = true) {
|
|
10498
10530
|
await ensureDevAuthToken(token);
|
|
10499
10531
|
logger.info("Restarting Nuxt...");
|
|
@@ -10532,6 +10564,161 @@ function setupGeneralRPC({
|
|
|
10532
10564
|
};
|
|
10533
10565
|
}
|
|
10534
10566
|
|
|
10567
|
+
const AGENTS = [
|
|
10568
|
+
"npm",
|
|
10569
|
+
"yarn",
|
|
10570
|
+
"yarn@berry",
|
|
10571
|
+
"pnpm",
|
|
10572
|
+
"pnpm@6",
|
|
10573
|
+
"bun",
|
|
10574
|
+
"deno"
|
|
10575
|
+
];
|
|
10576
|
+
const LOCKS = {
|
|
10577
|
+
"bun.lock": "bun",
|
|
10578
|
+
"bun.lockb": "bun",
|
|
10579
|
+
"deno.lock": "deno",
|
|
10580
|
+
"pnpm-lock.yaml": "pnpm",
|
|
10581
|
+
"pnpm-workspace.yaml": "pnpm",
|
|
10582
|
+
"yarn.lock": "yarn",
|
|
10583
|
+
"package-lock.json": "npm",
|
|
10584
|
+
"npm-shrinkwrap.json": "npm"
|
|
10585
|
+
};
|
|
10586
|
+
const INSTALL_METADATA = {
|
|
10587
|
+
"node_modules/.deno/": "deno",
|
|
10588
|
+
"node_modules/.pnpm/": "pnpm",
|
|
10589
|
+
"node_modules/.yarn-state.yml": "yarn",
|
|
10590
|
+
// yarn v2+ (node-modules)
|
|
10591
|
+
"node_modules/.yarn_integrity": "yarn",
|
|
10592
|
+
// yarn v1
|
|
10593
|
+
"node_modules/.package-lock.json": "npm",
|
|
10594
|
+
".pnp.cjs": "yarn",
|
|
10595
|
+
// yarn v3+ (pnp)
|
|
10596
|
+
".pnp.js": "yarn",
|
|
10597
|
+
// yarn v2 (pnp)
|
|
10598
|
+
"bun.lock": "bun",
|
|
10599
|
+
"bun.lockb": "bun"
|
|
10600
|
+
};
|
|
10601
|
+
|
|
10602
|
+
async function pathExists(path2, type) {
|
|
10603
|
+
try {
|
|
10604
|
+
const stat = await fs.stat(path2);
|
|
10605
|
+
return type === "file" ? stat.isFile() : stat.isDirectory();
|
|
10606
|
+
} catch {
|
|
10607
|
+
return false;
|
|
10608
|
+
}
|
|
10609
|
+
}
|
|
10610
|
+
function* lookup(cwd = process$1.cwd()) {
|
|
10611
|
+
let directory = path.resolve(cwd);
|
|
10612
|
+
const { root } = path.parse(directory);
|
|
10613
|
+
while (directory && directory !== root) {
|
|
10614
|
+
yield directory;
|
|
10615
|
+
directory = path.dirname(directory);
|
|
10616
|
+
}
|
|
10617
|
+
}
|
|
10618
|
+
async function parsePackageJson(filepath, options) {
|
|
10619
|
+
if (!filepath || !await pathExists(filepath, "file"))
|
|
10620
|
+
return null;
|
|
10621
|
+
return await handlePackageManager(filepath, options);
|
|
10622
|
+
}
|
|
10623
|
+
async function detect(options = {}) {
|
|
10624
|
+
const {
|
|
10625
|
+
cwd,
|
|
10626
|
+
strategies = ["lockfile", "packageManager-field", "devEngines-field"]
|
|
10627
|
+
} = options;
|
|
10628
|
+
let stopDir;
|
|
10629
|
+
if (typeof options.stopDir === "string") {
|
|
10630
|
+
const resolved = path.resolve(options.stopDir);
|
|
10631
|
+
stopDir = (dir) => dir === resolved;
|
|
10632
|
+
} else {
|
|
10633
|
+
stopDir = options.stopDir;
|
|
10634
|
+
}
|
|
10635
|
+
for (const directory of lookup(cwd)) {
|
|
10636
|
+
for (const strategy of strategies) {
|
|
10637
|
+
switch (strategy) {
|
|
10638
|
+
case "lockfile": {
|
|
10639
|
+
for (const lock of Object.keys(LOCKS)) {
|
|
10640
|
+
if (await pathExists(path.join(directory, lock), "file")) {
|
|
10641
|
+
const name = LOCKS[lock];
|
|
10642
|
+
const result = await parsePackageJson(path.join(directory, "package.json"), options);
|
|
10643
|
+
if (result)
|
|
10644
|
+
return result;
|
|
10645
|
+
else
|
|
10646
|
+
return { name, agent: name };
|
|
10647
|
+
}
|
|
10648
|
+
}
|
|
10649
|
+
break;
|
|
10650
|
+
}
|
|
10651
|
+
case "packageManager-field":
|
|
10652
|
+
case "devEngines-field": {
|
|
10653
|
+
const result = await parsePackageJson(path.join(directory, "package.json"), options);
|
|
10654
|
+
if (result)
|
|
10655
|
+
return result;
|
|
10656
|
+
break;
|
|
10657
|
+
}
|
|
10658
|
+
case "install-metadata": {
|
|
10659
|
+
for (const metadata of Object.keys(INSTALL_METADATA)) {
|
|
10660
|
+
const fileOrDir = metadata.endsWith("/") ? "dir" : "file";
|
|
10661
|
+
if (await pathExists(path.join(directory, metadata), fileOrDir)) {
|
|
10662
|
+
const name = INSTALL_METADATA[metadata];
|
|
10663
|
+
const agent = name === "yarn" ? isMetadataYarnClassic(metadata) ? "yarn" : "yarn@berry" : name;
|
|
10664
|
+
return { name, agent };
|
|
10665
|
+
}
|
|
10666
|
+
}
|
|
10667
|
+
break;
|
|
10668
|
+
}
|
|
10669
|
+
}
|
|
10670
|
+
}
|
|
10671
|
+
if (stopDir?.(directory))
|
|
10672
|
+
break;
|
|
10673
|
+
}
|
|
10674
|
+
return null;
|
|
10675
|
+
}
|
|
10676
|
+
function getNameAndVer(pkg) {
|
|
10677
|
+
const handelVer = (version) => version?.match(/\d+(\.\d+){0,2}/)?.[0] ?? version;
|
|
10678
|
+
if (typeof pkg.packageManager === "string") {
|
|
10679
|
+
const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
|
|
10680
|
+
return { name, ver: handelVer(ver) };
|
|
10681
|
+
}
|
|
10682
|
+
if (typeof pkg.devEngines?.packageManager?.name === "string") {
|
|
10683
|
+
return {
|
|
10684
|
+
name: pkg.devEngines.packageManager.name,
|
|
10685
|
+
ver: handelVer(pkg.devEngines.packageManager.version)
|
|
10686
|
+
};
|
|
10687
|
+
}
|
|
10688
|
+
return void 0;
|
|
10689
|
+
}
|
|
10690
|
+
async function handlePackageManager(filepath, options) {
|
|
10691
|
+
try {
|
|
10692
|
+
const content = await fs.readFile(filepath, "utf8");
|
|
10693
|
+
const pkg = options.packageJsonParser ? await options.packageJsonParser(content, filepath) : JSON.parse(content);
|
|
10694
|
+
let agent;
|
|
10695
|
+
const nameAndVer = getNameAndVer(pkg);
|
|
10696
|
+
if (nameAndVer) {
|
|
10697
|
+
const name = nameAndVer.name;
|
|
10698
|
+
const ver = nameAndVer.ver;
|
|
10699
|
+
let version = ver;
|
|
10700
|
+
if (name === "yarn" && ver && Number.parseInt(ver) > 1) {
|
|
10701
|
+
agent = "yarn@berry";
|
|
10702
|
+
version = "berry";
|
|
10703
|
+
return { name, agent, version };
|
|
10704
|
+
} else if (name === "pnpm" && ver && Number.parseInt(ver) < 7) {
|
|
10705
|
+
agent = "pnpm@6";
|
|
10706
|
+
return { name, agent, version };
|
|
10707
|
+
} else if (AGENTS.includes(name)) {
|
|
10708
|
+
agent = name;
|
|
10709
|
+
return { name, agent, version };
|
|
10710
|
+
} else {
|
|
10711
|
+
return options.onUnknown?.(pkg.packageManager) ?? null;
|
|
10712
|
+
}
|
|
10713
|
+
}
|
|
10714
|
+
} catch {
|
|
10715
|
+
}
|
|
10716
|
+
return null;
|
|
10717
|
+
}
|
|
10718
|
+
function isMetadataYarnClassic(metadataPath) {
|
|
10719
|
+
return metadataPath.endsWith(".yarn_integrity");
|
|
10720
|
+
}
|
|
10721
|
+
|
|
10535
10722
|
class FetchError extends Error {
|
|
10536
10723
|
constructor(message, opts) {
|
|
10537
10724
|
super(message, opts);
|
|
@@ -10944,13 +11131,12 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
10944
11131
|
let detectPromise;
|
|
10945
11132
|
const updatesPromise = /* @__PURE__ */ new Map();
|
|
10946
11133
|
function getPackageManager() {
|
|
10947
|
-
detectPromise ||=
|
|
11134
|
+
detectPromise ||= detect({ cwd: nuxt.options.rootDir });
|
|
10948
11135
|
return detectPromise;
|
|
10949
11136
|
}
|
|
10950
11137
|
async function getNpmCommand(command, packageName, options = {}) {
|
|
10951
11138
|
const {
|
|
10952
|
-
dev = true
|
|
10953
|
-
global = packageName === "@nuxt/devtools" && isInstalledGlobally
|
|
11139
|
+
dev = true
|
|
10954
11140
|
} = options;
|
|
10955
11141
|
const agent = await getPackageManager();
|
|
10956
11142
|
const name = agent?.name || "npm";
|
|
@@ -10960,7 +11146,6 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
10960
11146
|
name === "npm" ? "install" : "add",
|
|
10961
11147
|
`${packageName}@latest`,
|
|
10962
11148
|
dev ? "-D" : "",
|
|
10963
|
-
global ? "-g" : "",
|
|
10964
11149
|
// In yarn berry, `--ignore-scripts` is removed
|
|
10965
11150
|
name === "yarn" && !agent?.version?.startsWith("1.") ? "" : "--ignore-scripts"
|
|
10966
11151
|
].filter(Boolean);
|
|
@@ -10969,8 +11154,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
10969
11154
|
return [
|
|
10970
11155
|
name,
|
|
10971
11156
|
name === "npm" ? "uninstall" : "remove",
|
|
10972
|
-
packageName
|
|
10973
|
-
global ? "-g" : ""
|
|
11157
|
+
packageName
|
|
10974
11158
|
].filter(Boolean);
|
|
10975
11159
|
}
|
|
10976
11160
|
}
|
|
@@ -11010,7 +11194,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11010
11194
|
const commands = await getNpmCommand("install", name, { dev: true });
|
|
11011
11195
|
const filepath = nuxt.options._nuxtConfigFile;
|
|
11012
11196
|
let source = latestGenerated;
|
|
11013
|
-
source ??= await
|
|
11197
|
+
source ??= await fs.readFile(filepath, "utf-8");
|
|
11014
11198
|
const generated = await magicastGuard(async () => {
|
|
11015
11199
|
const mod = parseModule(source, { sourceFileName: filepath });
|
|
11016
11200
|
addNuxtModule(mod, name);
|
|
@@ -11029,8 +11213,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11029
11213
|
icon: "carbon:intent-request-create",
|
|
11030
11214
|
restartable: false
|
|
11031
11215
|
});
|
|
11032
|
-
const
|
|
11033
|
-
const result = await execa;
|
|
11216
|
+
const result = await process.getResult();
|
|
11034
11217
|
await Promise.resolve();
|
|
11035
11218
|
installSet.delete(name);
|
|
11036
11219
|
const code = result.exitCode;
|
|
@@ -11040,7 +11223,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11040
11223
|
}
|
|
11041
11224
|
if (installSet.size === 0) {
|
|
11042
11225
|
latestGenerated = null;
|
|
11043
|
-
await
|
|
11226
|
+
await fs.writeFile(filepath, generated, "utf-8");
|
|
11044
11227
|
}
|
|
11045
11228
|
}
|
|
11046
11229
|
return {
|
|
@@ -11054,7 +11237,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11054
11237
|
await ensureDevAuthToken(token);
|
|
11055
11238
|
const commands = await getNpmCommand("uninstall", name);
|
|
11056
11239
|
const filepath = nuxt.options._nuxtConfigFile;
|
|
11057
|
-
const source = await
|
|
11240
|
+
const source = await fs.readFile(filepath, "utf-8");
|
|
11058
11241
|
const generated = await magicastGuard(async () => {
|
|
11059
11242
|
const mod = parseModule(source, { sourceFileName: filepath });
|
|
11060
11243
|
const config = getDefaultExportOptions(mod);
|
|
@@ -11078,15 +11261,14 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11078
11261
|
icon: "carbon:intent-request-uninstall",
|
|
11079
11262
|
restartable: false
|
|
11080
11263
|
});
|
|
11081
|
-
const
|
|
11082
|
-
const result = await execa;
|
|
11264
|
+
const result = await process.getResult();
|
|
11083
11265
|
await Promise.resolve();
|
|
11084
11266
|
const code = result.exitCode;
|
|
11085
11267
|
if (code !== 0) {
|
|
11086
11268
|
console.error(result.stderr);
|
|
11087
11269
|
throw new Error(`[Nuxt DevTools] Failed to uninstall module, process exited with ${code}`);
|
|
11088
11270
|
}
|
|
11089
|
-
await
|
|
11271
|
+
await fs.writeFile(filepath, generated, "utf-8");
|
|
11090
11272
|
}
|
|
11091
11273
|
return {
|
|
11092
11274
|
configOriginal: source,
|
|
@@ -11500,7 +11682,7 @@ function setupTimelineRPC({ nuxt }) {
|
|
|
11500
11682
|
return {
|
|
11501
11683
|
async enableTimeline(dry) {
|
|
11502
11684
|
const filepath = nuxt.options._nuxtConfigFile;
|
|
11503
|
-
const source = await
|
|
11685
|
+
const source = await fs.readFile(filepath, "utf-8");
|
|
11504
11686
|
const generated = await magicastGuard(async () => {
|
|
11505
11687
|
const mod = parseModule(source, { sourceFileName: filepath });
|
|
11506
11688
|
const options = getDefaultExportOptions(mod);
|
|
@@ -11510,7 +11692,7 @@ function setupTimelineRPC({ nuxt }) {
|
|
|
11510
11692
|
return mod.generate().code;
|
|
11511
11693
|
}, "\nYou can enable timeline manually by adding `devtools: { timeline: { enabled: true } }`");
|
|
11512
11694
|
if (!dry) {
|
|
11513
|
-
await
|
|
11695
|
+
await fs.writeFile(filepath, generated, "utf-8");
|
|
11514
11696
|
await nuxt.callHook("restart", { hard: true });
|
|
11515
11697
|
}
|
|
11516
11698
|
return [source, generated];
|
|
@@ -11518,53 +11700,6 @@ function setupTimelineRPC({ nuxt }) {
|
|
|
11518
11700
|
};
|
|
11519
11701
|
}
|
|
11520
11702
|
|
|
11521
|
-
const LOG_PREFIX = colors.cyan("Nuxt DevTools:");
|
|
11522
|
-
|
|
11523
|
-
const NUXT_WELCOME_RE = /<NuxtWelcome\s*\/>/;
|
|
11524
|
-
const pagesIndexTemplate = `<script setup lang="ts">
|
|
11525
|
-
const route = useRoute()
|
|
11526
|
-
<\/script>
|
|
11527
|
-
|
|
11528
|
-
<template>
|
|
11529
|
-
<div>
|
|
11530
|
-
<h1>Nuxt Routing set up successfully!</h1>
|
|
11531
|
-
<p>Current route: {{ route.path }}</p>
|
|
11532
|
-
<a href="https://nuxt.com/docs/getting-started/routing" target="_blank">Learn more about Nuxt Routing</a>
|
|
11533
|
-
</div>
|
|
11534
|
-
</template>
|
|
11535
|
-
`;
|
|
11536
|
-
async function enablePages(nuxt) {
|
|
11537
|
-
const baseDir = nuxt.options.future.compatibilityVersion === 4 ? nuxt.options.dir.app : nuxt.options.srcDir;
|
|
11538
|
-
const pathApp = join(baseDir, "app.vue");
|
|
11539
|
-
const pathPageIndex = join(baseDir, "pages/index.vue");
|
|
11540
|
-
if (fs.existsSync(pathPageIndex)) {
|
|
11541
|
-
logger.warn("pages/index.vue already exists, skipping");
|
|
11542
|
-
return;
|
|
11543
|
-
}
|
|
11544
|
-
let appContent = fs.existsSync(pathApp) ? await fsp.readFile(pathApp, "utf-8") : void 0;
|
|
11545
|
-
await fsp.mkdir(dirname$1(pathPageIndex), { recursive: true });
|
|
11546
|
-
await fsp.writeFile(pathPageIndex, pagesIndexTemplate, "utf-8");
|
|
11547
|
-
if (appContent && !appContent.includes("<NuxtPage")) {
|
|
11548
|
-
appContent = appContent.replace("</template>", " <NuxtPage />\n</template>").replace(NUXT_WELCOME_RE, "");
|
|
11549
|
-
await fsp.writeFile(pathApp, appContent, "utf-8");
|
|
11550
|
-
}
|
|
11551
|
-
logger.success("Routing creation wizard completed");
|
|
11552
|
-
}
|
|
11553
|
-
|
|
11554
|
-
const wizard = {
|
|
11555
|
-
enablePages
|
|
11556
|
-
};
|
|
11557
|
-
|
|
11558
|
-
function setupWizardRPC({ nuxt, ensureDevAuthToken }) {
|
|
11559
|
-
return {
|
|
11560
|
-
async runWizard(token, name, ...args) {
|
|
11561
|
-
await ensureDevAuthToken(token);
|
|
11562
|
-
logger.info(LOG_PREFIX, `Running wizard ${colors.green(name)}...`);
|
|
11563
|
-
return wizard[name](nuxt, ...args);
|
|
11564
|
-
}
|
|
11565
|
-
};
|
|
11566
|
-
}
|
|
11567
|
-
|
|
11568
11703
|
function setupRPC(nuxt, options) {
|
|
11569
11704
|
const serverFunctions = {};
|
|
11570
11705
|
const extendedRpcMap = /* @__PURE__ */ new Map();
|
|
@@ -11625,7 +11760,6 @@ function setupRPC(nuxt, options) {
|
|
|
11625
11760
|
...setupStorageRPC(ctx),
|
|
11626
11761
|
...setupAssetsRPC(ctx),
|
|
11627
11762
|
...setupNpmRPC(ctx),
|
|
11628
|
-
...setupWizardRPC(ctx),
|
|
11629
11763
|
...setupTerminalRPC(ctx),
|
|
11630
11764
|
...setupServerRoutesRPC(ctx),
|
|
11631
11765
|
...setupServerTasksRPC(ctx),
|
|
@@ -11695,7 +11829,6 @@ async function enableModule(options, nuxt) {
|
|
|
11695
11829
|
await import('./analyze-build.mjs').then(({ setup }) => setup(nuxt, options));
|
|
11696
11830
|
return;
|
|
11697
11831
|
}
|
|
11698
|
-
const enabledExplicitly = nuxt.options.devtools === true || nuxt.options.devtools && nuxt.options.devtools.enabled || nuxt.options.modules.some((m) => m === "@nuxt/devtools" || m === "@nuxt/devtools-edge" || m === "@nuxt/devtools-nightly");
|
|
11699
11832
|
await nuxt.callHook("devtools:before");
|
|
11700
11833
|
if (options.iframeProps) {
|
|
11701
11834
|
nuxt.options.runtimeConfig.app.devtools ||= {};
|
|
@@ -11710,38 +11843,32 @@ async function enableModule(options, nuxt) {
|
|
|
11710
11843
|
src: join(runtimeDir, "plugins/devtools.server"),
|
|
11711
11844
|
mode: "server"
|
|
11712
11845
|
});
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
url: "/__nuxt_devtools__/client/"
|
|
11727
|
-
});
|
|
11728
|
-
}
|
|
11846
|
+
const DevTools = await import('@vitejs/devtools').then((r) => r.DevTools());
|
|
11847
|
+
addVitePlugin(DevTools);
|
|
11848
|
+
addVitePlugin(defineViteDevToolsPlugin({
|
|
11849
|
+
name: "nuxt:devtools",
|
|
11850
|
+
devtools: {
|
|
11851
|
+
setup(ctx2) {
|
|
11852
|
+
ctx2.docks.register({
|
|
11853
|
+
id: "nuxt:devtools",
|
|
11854
|
+
type: "iframe",
|
|
11855
|
+
icon: "https://nuxt.com/assets/design-kit/icon-green.svg",
|
|
11856
|
+
title: "Nuxt DevTools",
|
|
11857
|
+
url: "/__nuxt_devtools__/client/"
|
|
11858
|
+
});
|
|
11729
11859
|
}
|
|
11730
|
-
}
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
}
|
|
11860
|
+
}
|
|
11861
|
+
}));
|
|
11862
|
+
addPlugin({
|
|
11863
|
+
src: join(runtimeDir, "plugins/vite-devtools.client"),
|
|
11864
|
+
mode: "client"
|
|
11865
|
+
});
|
|
11736
11866
|
addTemplate({
|
|
11737
11867
|
filename: "devtools/settings.mjs",
|
|
11738
11868
|
async getContents() {
|
|
11739
11869
|
const uiOptions = await readLocalOptions(
|
|
11740
11870
|
{
|
|
11741
|
-
...defaultTabOptions.ui
|
|
11742
|
-
// When not enabled explicitly, we hide the panel by default
|
|
11743
|
-
// When Vite DevTools is enabled, we hide the panel by default
|
|
11744
|
-
showPanel: options.viteDevTools ? false : enabledExplicitly ? true : null
|
|
11871
|
+
...defaultTabOptions.ui
|
|
11745
11872
|
},
|
|
11746
11873
|
{ root: nuxt.options.rootDir }
|
|
11747
11874
|
);
|
|
@@ -11804,7 +11931,7 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11804
11931
|
server.middlewares.use(ROUTE_ANALYZE, sirv(devtoolsAnalyzeDir, { single: false, dev: true, dotfiles: true, ignores: false }));
|
|
11805
11932
|
if (clientDirExists) {
|
|
11806
11933
|
const indexHtmlPath = join(clientDir, "index.html");
|
|
11807
|
-
const indexContent =
|
|
11934
|
+
const indexContent = fs.readFile(indexHtmlPath, "utf-8");
|
|
11808
11935
|
const handleStatic = sirv(clientDir, {
|
|
11809
11936
|
dev: true,
|
|
11810
11937
|
single: false
|
|
@@ -11857,8 +11984,7 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11857
11984
|
await Promise.all(integrations);
|
|
11858
11985
|
nuxt.hook("modules:done", () => nuxt.callHook("devtools:initialized", {
|
|
11859
11986
|
version: version$1,
|
|
11860
|
-
packagePath: packageDir
|
|
11861
|
-
isGlobalInstall: isGlobalInstall()
|
|
11987
|
+
packagePath: packageDir
|
|
11862
11988
|
}));
|
|
11863
11989
|
const isMac = os.platform() === "darwin";
|
|
11864
11990
|
logger.log([
|
|
@@ -11873,10 +11999,8 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11873
11999
|
"\n"
|
|
11874
12000
|
].join(""));
|
|
11875
12001
|
}
|
|
12002
|
+
function defineViteDevToolsPlugin(plugin) {
|
|
12003
|
+
return plugin;
|
|
12004
|
+
}
|
|
11876
12005
|
|
|
11877
|
-
|
|
11878
|
-
__proto__: null,
|
|
11879
|
-
enableModule: enableModule
|
|
11880
|
-
};
|
|
11881
|
-
|
|
11882
|
-
export { LOG_PREFIX as L, moduleMain as m };
|
|
12006
|
+
export { enableModule };
|