@nuxt/devtools 3.2.4 → 4.0.0-alpha.2
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 +87 -5
- package/dist/chunks/module-main.mjs +427 -349
- 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-hkoz1rvj.js +1 -0
- package/dist/client/_nuxt/analyze-build-ecjdrn47.js +1 -0
- package/dist/client/_nuxt/assets-neo14xgr.js +6 -0
- package/dist/client/_nuxt/auth-required-panel-eykuzska.js +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/5a29da90-eb92-468e-ae22-3d6e1c14ca84.json +1 -0
- package/dist/client/_nuxt/{client-im47u3kz.js → client-coqmopwz.js} +1 -1
- package/dist/client/_nuxt/code-diff-o5b2z2ie.js +8 -0
- package/dist/client/_nuxt/code-snippets-lje00rjy.js +1 -0
- package/dist/client/_nuxt/components-m6u58eqx.js +1 -0
- package/dist/client/_nuxt/composable-item-imnaiayk.js +1 -0
- package/dist/client/_nuxt/custom-_name_-gto916bz.js +1 -0
- package/dist/client/_nuxt/data-schema-button-g6gxhvpu.js +1 -0
- package/dist/client/_nuxt/data-schema-drawer-iqjxac51.js +2 -0
- package/dist/client/_nuxt/debug-jp25iu97.js +1 -0
- package/dist/client/_nuxt/{default-jvhm51ri.js → default-f17ja76u.js} +1 -1
- package/dist/client/_nuxt/dev-auth-h6radlhi.js +1 -0
- package/dist/client/_nuxt/duration-display-lgba3ul7.js +1 -0
- package/dist/client/_nuxt/emiigkv5.js +4 -0
- package/dist/client/_nuxt/entry.css-d9crsfkn.css +1 -0
- package/dist/client/_nuxt/error-404-fqyiq2ar.js +1 -0
- package/dist/client/_nuxt/error-404.css-h25s2r5c.css +1 -0
- package/dist/client/_nuxt/error-500-k8cd8t39.js +1 -0
- package/dist/client/_nuxt/error-500.css-ne02sjef.css +1 -0
- package/dist/client/_nuxt/error-bgkwva1q.js +9 -0
- package/dist/client/_nuxt/filepath-item-lm7tbw9e.js +1 -0
- package/dist/client/_nuxt/full-h1zczfpi.js +1 -0
- package/dist/client/_nuxt/help-fab-ekagn9f2.js +1 -0
- package/dist/client/_nuxt/hooks-hk8yviqj.js +1 -0
- package/dist/client/_nuxt/imports-ozoiw4bc.js +1 -0
- package/dist/client/_nuxt/launch-page-jvtn5jef.js +1 -0
- package/dist/client/_nuxt/modules-bpsbuvhv.js +1 -0
- package/dist/client/_nuxt/nbadge-ia2sg78l.js +1 -0
- package/dist/client/_nuxt/ncard-bpchuz30.js +1 -0
- package/dist/client/_nuxt/ncheckbox-dqqmiqln.js +1 -0
- package/dist/client/_nuxt/ncode-block-lbvhz228.js +2 -0
- package/dist/client/_nuxt/ndrawer-pdhwqkg2.js +1 -0
- package/dist/client/_nuxt/ndropdown-o0hg8oi1.js +1 -0
- package/dist/client/_nuxt/nicon-o8vtl3nv.js +1 -0
- package/dist/client/_nuxt/nicon-title-f04kekaa.js +1 -0
- package/dist/client/_nuxt/nlink-flm1s7uj.js +1 -0
- package/dist/client/_nuxt/nmarkdown-cu68ujlp.js +1 -0
- package/dist/client/_nuxt/nnavbar-iwf1qrzf.js +1 -0
- package/dist/client/_nuxt/none-b8do2yyn.js +1 -0
- package/dist/client/_nuxt/nsection-block-oc6icst0.js +1 -0
- package/dist/client/_nuxt/nselect-k14i70o0.js +1 -0
- package/dist/client/_nuxt/nselect-tabs-gmel1seg.js +1 -0
- package/dist/client/_nuxt/nswitch-kprd7bwp.js +1 -0
- package/dist/client/_nuxt/ntip-erjk5wo4.js +1 -0
- package/dist/client/_nuxt/{nuxt-otp6bp04.js → nuxt-bl8ryhiw.js} +1 -1
- package/dist/client/_nuxt/{nuxt-link-bumooa9d.js → nuxt-link-h8a2u03t.js} +1 -1
- package/dist/client/_nuxt/open-graph-gqcrbtb4.js +3 -0
- package/dist/client/_nuxt/overview-ode2qvxm.js +1 -0
- package/dist/client/_nuxt/pages-l8ohewdn.js +1 -0
- package/dist/client/_nuxt/pages-nqnq5f5t.js +1 -0
- package/dist/client/_nuxt/payload-5yrt4zvx.js +1 -0
- package/dist/client/_nuxt/pinia-ipoevgwj.js +1 -0
- package/dist/client/_nuxt/plugins-osqpret8.js +1 -0
- package/dist/client/_nuxt/{ready-dadbdj5i.js → ready-nmtplnq5.js} +1 -1
- package/dist/client/_nuxt/render-tree-gskxc5zy.js +1 -0
- package/dist/client/_nuxt/rpc-ga26o8l5.js +1 -0
- package/dist/client/_nuxt/runtime-configs-pz2i8w6q.js +1 -0
- package/dist/client/_nuxt/server-discovery-og33p041.js +1 -0
- package/dist/client/_nuxt/server-route-inputs-kx5eivj6.js +1 -0
- package/dist/client/_nuxt/server-routes-jue52yjp.js +7 -0
- package/dist/client/_nuxt/server-tasks-m1mrolqv.js +1 -0
- package/dist/client/_nuxt/settings-peisguuo.js +1 -0
- package/dist/client/_nuxt/{splitpanes.es-gcsn48te.js → splitpanes.es-krbzt5ww.js} +1 -1
- package/dist/client/_nuxt/stacktrace-list-il2y9pcx.js +1 -0
- package/dist/client/_nuxt/state-components-dtq2t5r4.js +1 -0
- package/dist/client/_nuxt/state-editor-ffp2kcpu.js +1 -0
- package/dist/client/_nuxt/state-modules-dujmynt6.js +1 -0
- package/dist/client/_nuxt/state-tabs-etz9ig65.js +1 -0
- package/dist/client/_nuxt/storage-lyohu7me.js +1 -0
- package/dist/client/_nuxt/storage-options-fmhmng6m.js +1 -0
- package/dist/client/_nuxt/terminals-o5cnogpb.js +1 -0
- package/dist/client/_nuxt/timeline-gl5vzyx1.js +31 -0
- package/dist/client/_nuxt/unocss-runtime-fghua2d1.js +1 -0
- package/dist/client/_nuxt/utils-jkkblreo.js +2 -0
- package/dist/client/_nuxt/vendor/{json-editor-vue-eojr4v24.js → json-editor-vue-mpqfj7dd.js} +5 -5
- package/dist/client/_nuxt/vendor/{quicktype-core-k4qx3809.js → quicktype-core-bxh3g3c2.js} +2 -2
- package/dist/client/_nuxt/vendor/{shiki-lqo1hg2n.js → shiki-ildq90cv.js} +3 -3
- package/dist/client/_nuxt/vendor/{unocss-k727ub0h.js → unocss-hiscr44j.js} +1 -1
- package/dist/client/_nuxt/vendor/{vis-gf06uk37.js → vis-obscvyyi.js} +2 -2
- package/dist/client/_nuxt/vendor/{xterm-k45lhqgb.js → xterm-g6v3jqah.js} +1 -1
- package/dist/client/_nuxt/virtual-files-gg15edds.js +1 -0
- package/dist/client/_nuxt/vue-devtools-o3ws2mcv.js +4 -0
- package/dist/client/_nuxt/{vue-router-jbnxw7nb.js → vue-router-imuzx5c1.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.CT6XRG-F.mjs → devtools.DClER4Dv.mjs} +2 -11
- 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 +11 -1160
- package/package.json +18 -26
- package/cli.mjs +0 -2
- package/dist/client/_nuxt/__blank-cpzbm3dn.js +0 -1
- package/dist/client/_nuxt/analyze-build-isc8qyt9.js +0 -1
- package/dist/client/_nuxt/assets-k3ya1y6b.js +0 -6
- package/dist/client/_nuxt/builds/meta/c954ff6d-891d-44ef-873b-bed085186c32.json +0 -1
- package/dist/client/_nuxt/client-nwyjxodt.js +0 -2
- package/dist/client/_nuxt/code-diff-hjtd937u.js +0 -8
- package/dist/client/_nuxt/code-snippets-cptms1t1.js +0 -1
- package/dist/client/_nuxt/components-h8jl0r8x.js +0 -1
- package/dist/client/_nuxt/composable-item-m56sdpbk.js +0 -1
- package/dist/client/_nuxt/custom-_name_-oczf7kge.js +0 -1
- package/dist/client/_nuxt/d479ufk9.js +0 -4
- package/dist/client/_nuxt/data-schema-button-n0xmsouw.js +0 -1
- package/dist/client/_nuxt/data-schema-drawer-le08obah.js +0 -2
- package/dist/client/_nuxt/debug-hbdh85ek.js +0 -1
- package/dist/client/_nuxt/dev-auth-he0eye7r.js +0 -1
- package/dist/client/_nuxt/duration-display-h5sffkps.js +0 -1
- package/dist/client/_nuxt/entry.css-hn1q325i.css +0 -1
- package/dist/client/_nuxt/error-404-mzw240fb.js +0 -1
- package/dist/client/_nuxt/error-404.css-b4qk08da.css +0 -1
- package/dist/client/_nuxt/error-500-l89qfgc9.js +0 -1
- package/dist/client/_nuxt/error-500.css-awwhwbzo.css +0 -1
- package/dist/client/_nuxt/error-owd7hxtu.js +0 -9
- package/dist/client/_nuxt/filepath-item-h3i1tz3s.js +0 -1
- package/dist/client/_nuxt/full-et0weok9.js +0 -1
- package/dist/client/_nuxt/help-fab-oeo4c53s.js +0 -1
- package/dist/client/_nuxt/hooks-lapcgs2a.js +0 -1
- package/dist/client/_nuxt/imports-lb64tt5j.js +0 -1
- package/dist/client/_nuxt/launch-page-h3hu9uqw.js +0 -1
- package/dist/client/_nuxt/modules-isjfof47.js +0 -1
- package/dist/client/_nuxt/nbadge-f1bvtlf5.js +0 -1
- package/dist/client/_nuxt/nbutton-gygn07c2.js +0 -1
- package/dist/client/_nuxt/ncard-ludmyw2u.js +0 -1
- package/dist/client/_nuxt/ncheckbox-ep01n5y1.js +0 -1
- package/dist/client/_nuxt/ncode-block-figzf35k.js +0 -2
- package/dist/client/_nuxt/ndrawer-hos2o4rf.js +0 -1
- package/dist/client/_nuxt/ndropdown-knvt4ccq.js +0 -1
- package/dist/client/_nuxt/nicon-m1crov2l.js +0 -1
- package/dist/client/_nuxt/nicon-title-kbrt9te7.js +0 -1
- package/dist/client/_nuxt/nlink-od4lllbl.js +0 -1
- package/dist/client/_nuxt/nmarkdown-ciogo2e3.js +0 -1
- package/dist/client/_nuxt/nnavbar-n7gfocyu.js +0 -1
- package/dist/client/_nuxt/none-bdxkqeml.js +0 -1
- package/dist/client/_nuxt/npanel-grids-onrho735.js +0 -1
- package/dist/client/_nuxt/nsection-block-ibsk9arc.js +0 -1
- package/dist/client/_nuxt/nselect-gyaplrph.js +0 -1
- package/dist/client/_nuxt/nselect-tabs-fslk8qg5.js +0 -1
- package/dist/client/_nuxt/nswitch-ke379yjx.js +0 -1
- package/dist/client/_nuxt/ntext-input-e8iut2en.js +0 -1
- package/dist/client/_nuxt/open-graph-iihpwnih.js +0 -3
- package/dist/client/_nuxt/overview-hir7dg5h.js +0 -1
- package/dist/client/_nuxt/pages-etzxihfh.js +0 -1
- package/dist/client/_nuxt/pages-okkqwdpu.js +0 -1
- package/dist/client/_nuxt/payload-hmxfri1t.js +0 -1
- package/dist/client/_nuxt/pinia-bfcvuvfi.js +0 -1
- package/dist/client/_nuxt/plugins-ehtddhxd.js +0 -1
- package/dist/client/_nuxt/render-tree-ke02si46.js +0 -1
- package/dist/client/_nuxt/runtime-configs-ft5vi88d.js +0 -1
- package/dist/client/_nuxt/server-discovery-k9u6ss6f.js +0 -1
- package/dist/client/_nuxt/server-route-inputs-fhqv0c7q.js +0 -1
- package/dist/client/_nuxt/server-routes-dy0m6wq4.js +0 -7
- package/dist/client/_nuxt/server-tasks-naz2m1n0.js +0 -1
- package/dist/client/_nuxt/settings-io1tvmdq.js +0 -1
- package/dist/client/_nuxt/stacktrace-list-ir6dwfsw.js +0 -1
- package/dist/client/_nuxt/state-components-ii0yssci.js +0 -1
- package/dist/client/_nuxt/state-editor-m7poh4fc.js +0 -1
- package/dist/client/_nuxt/state-modules-m990wfjb.js +0 -1
- package/dist/client/_nuxt/state-routes-jownks2o.js +0 -1
- package/dist/client/_nuxt/state-tabs-mtxv3h6t.js +0 -1
- package/dist/client/_nuxt/storage-nebfhfwp.js +0 -1
- package/dist/client/_nuxt/storage-options-nzog3hhp.js +0 -1
- package/dist/client/_nuxt/telemetry-c77tnag3.js +0 -1
- package/dist/client/_nuxt/terminals-j3f24tml.js +0 -1
- package/dist/client/_nuxt/timeline-cg7nhorz.js +0 -31
- package/dist/client/_nuxt/unocss-runtime-g9wlule9.js +0 -1
- package/dist/client/_nuxt/utils-jupbrzo6.js +0 -1
- package/dist/client/_nuxt/virtual-files-bkiu19oo.js +0 -1
- package/dist/client/_nuxt/vue-devtools-fdei7bct.js +0 -4
- /package/dist/client/_nuxt/{color-l56csnpd.js → color-bh8526bd.js} +0 -0
- /package/dist/client/_nuxt/{composables-b2ccklz4.js → composables-f0oa0ya0.js} +0 -0
- /package/dist/client/_nuxt/{constants-mq2c9hze.js → constants-g7ujya00.js} +0 -0
- /package/dist/client/_nuxt/{dist-og16nf4d.js → dist-f16b9vaq.js} +0 -0
- /package/dist/client/_nuxt/{mitt.es-ey5n86su.js → mitt.es-pc7qwi6p.js} +0 -0
- /package/dist/client/_nuxt/vendor/{markdown-it-ckeo8pwp.js → markdown-it-liuu8zo7.js} +0 -0
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import fs, {
|
|
2
|
-
import
|
|
1
|
+
import fs$1, { promises, statSync, realpathSync, readFileSync, existsSync, 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
|
-
import { join, dirname
|
|
6
|
+
import { join, dirname, resolve, isAbsolute } from 'pathe';
|
|
7
7
|
import sirv from 'sirv';
|
|
8
8
|
import { searchForWorkspaceRoot } from 'vite';
|
|
9
|
-
import { d as defaultAllowedExtensions, a as defaultTabOptions
|
|
10
|
-
import
|
|
11
|
-
import { hash } from 'ohash';
|
|
12
|
-
import { runtimeDir, clientDir, packageDir, isGlobalInstall } from '../dirs.mjs';
|
|
13
|
-
import { createBirpcGroup } from 'birpc';
|
|
14
|
-
import { parse as parse$1, stringify } from 'structured-clone-es';
|
|
9
|
+
import { d as defaultAllowedExtensions, a as defaultTabOptions } from '../shared/devtools.DClER4Dv.mjs';
|
|
10
|
+
import { runtimeDir, clientDir, packageDir } from '../dirs.mjs';
|
|
15
11
|
import { startSubprocess } from '@nuxt/devtools-kit';
|
|
16
|
-
import
|
|
12
|
+
import { x } from 'tinyexec';
|
|
17
13
|
import { glob } from 'tinyglobby';
|
|
14
|
+
import path, { relative, parse, dirname as dirname$1 } from 'node:path';
|
|
18
15
|
import { imageMeta } from 'image-meta';
|
|
19
16
|
import { debounce } from 'perfect-debounce';
|
|
20
17
|
import destr from 'destr';
|
|
21
18
|
import { setupHooksDebug } from '../../dist/runtime/shared/hooks.js';
|
|
19
|
+
import { hash } from 'ohash';
|
|
22
20
|
import process$1 from 'node:process';
|
|
23
21
|
import { builtinModules, createRequire } from 'node:module';
|
|
24
22
|
import { resolvePackageJSON, readPackageJSON } from 'pkg-types';
|
|
@@ -27,97 +25,12 @@ import assert from 'node:assert';
|
|
|
27
25
|
import v8 from 'node:v8';
|
|
28
26
|
import { format, inspect } from 'node:util';
|
|
29
27
|
import { resolveModule, getPackageInfo } from 'local-pkg';
|
|
30
|
-
import isInstalledGlobally from 'is-installed-globally';
|
|
31
28
|
import { parseModule } from 'magicast';
|
|
32
29
|
import { getDefaultExportOptions, addNuxtModule } from 'magicast/helpers';
|
|
33
|
-
import { detectPackageManager } from 'nypm';
|
|
34
30
|
import semver from 'semver';
|
|
35
31
|
import { normalizeBaseKey, normalizeKey } from 'unstorage';
|
|
36
32
|
|
|
37
|
-
const version$1 = "
|
|
38
|
-
|
|
39
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
40
|
-
function randomStr(size = 16, dict = urlAlphabet) {
|
|
41
|
-
let id = "";
|
|
42
|
-
let i = size;
|
|
43
|
-
const len = dict.length;
|
|
44
|
-
while (i--)
|
|
45
|
-
id += dict[Math.random() * len | 0];
|
|
46
|
-
return id;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function getHomeDir() {
|
|
50
|
-
return process.env.XDG_CONFIG_HOME || homedir();
|
|
51
|
-
}
|
|
52
|
-
async function readLocalOptions(defaults, options) {
|
|
53
|
-
const { filePath } = getOptionsFilepath(options);
|
|
54
|
-
if (existsSync(filePath)) {
|
|
55
|
-
try {
|
|
56
|
-
const options2 = {
|
|
57
|
-
...defaults,
|
|
58
|
-
...JSON.parse(await fsp.readFile(filePath, "utf-8")).settings || {}
|
|
59
|
-
};
|
|
60
|
-
return options2;
|
|
61
|
-
} catch (e) {
|
|
62
|
-
console.error(`[DevTools] failed to parse local options file: ${filePath}, fallback to defaults`);
|
|
63
|
-
console.error(e);
|
|
64
|
-
return { ...defaults };
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
return { ...defaults };
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function getOptionsFilepath(options) {
|
|
71
|
-
let hashedKey;
|
|
72
|
-
if (options.key)
|
|
73
|
-
hashedKey = hash(`${options.root}:${options.key}`);
|
|
74
|
-
else
|
|
75
|
-
hashedKey = hash(options.root);
|
|
76
|
-
const home = getHomeDir();
|
|
77
|
-
const filePath = join(home, ".nuxt/devtools", `${hashedKey}.json`);
|
|
78
|
-
return {
|
|
79
|
-
filePath,
|
|
80
|
-
hashedKey
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
async function clearLocalOptions(options) {
|
|
84
|
-
const { filePath } = getOptionsFilepath(options);
|
|
85
|
-
if (existsSync(filePath))
|
|
86
|
-
await fsp.unlink(filePath);
|
|
87
|
-
}
|
|
88
|
-
async function writeLocalOptions(settings, options) {
|
|
89
|
-
const { filePath, hashedKey } = getOptionsFilepath(options);
|
|
90
|
-
await fsp.mkdir(dirname(filePath), { recursive: true });
|
|
91
|
-
await fsp.writeFile(
|
|
92
|
-
filePath,
|
|
93
|
-
JSON.stringify(
|
|
94
|
-
{
|
|
95
|
-
root: options.root,
|
|
96
|
-
hash: hashedKey,
|
|
97
|
-
settings
|
|
98
|
-
},
|
|
99
|
-
null,
|
|
100
|
-
2
|
|
101
|
-
),
|
|
102
|
-
"utf-8"
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
let token;
|
|
107
|
-
async function getDevAuthToken() {
|
|
108
|
-
if (token)
|
|
109
|
-
return token;
|
|
110
|
-
const home = getHomeDir();
|
|
111
|
-
const dir = join$1(home, ".nuxt/devtools");
|
|
112
|
-
const filepath = join$1(dir, "dev-auth-token.txt");
|
|
113
|
-
if (existsSync(filepath))
|
|
114
|
-
token = (await fsp.readFile(filepath, "utf-8")).trim();
|
|
115
|
-
if (!token)
|
|
116
|
-
token = randomStr(16);
|
|
117
|
-
await fsp.mkdir(dir, { recursive: true });
|
|
118
|
-
await fsp.writeFile(filepath, token, "utf-8");
|
|
119
|
-
return token;
|
|
120
|
-
}
|
|
33
|
+
const version$1 = "4.0.0-alpha.2";
|
|
121
34
|
|
|
122
35
|
const COLON_RE = /:/g;
|
|
123
36
|
function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
@@ -140,7 +53,7 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
140
53
|
}, nuxt);
|
|
141
54
|
refresh("getAnalyzeBuildInfo");
|
|
142
55
|
initalized = void 0;
|
|
143
|
-
promise = result.
|
|
56
|
+
promise = Promise.resolve(result.getResult()).then(() => {
|
|
144
57
|
refresh("getAnalyzeBuildInfo");
|
|
145
58
|
return readBuildInfo();
|
|
146
59
|
}).finally(() => {
|
|
@@ -162,10 +75,10 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
162
75
|
absolute: true
|
|
163
76
|
});
|
|
164
77
|
for (const file of files2) {
|
|
165
|
-
const slug = JSON.parse(await
|
|
166
|
-
const dir2 = dirname
|
|
167
|
-
await
|
|
168
|
-
await
|
|
78
|
+
const slug = JSON.parse(await fs.readFile(file, "utf-8")).slug;
|
|
79
|
+
const dir2 = dirname(file);
|
|
80
|
+
await fs.mkdir(devtoolsAnalyzeDir, { recursive: true });
|
|
81
|
+
await fs.rename(dir2, join(devtoolsAnalyzeDir, slug));
|
|
169
82
|
}
|
|
170
83
|
}
|
|
171
84
|
const files = await glob(["**/meta.json"], {
|
|
@@ -174,27 +87,30 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
174
87
|
absolute: true
|
|
175
88
|
});
|
|
176
89
|
builds = await Promise.all(files.map(async (file) => {
|
|
177
|
-
const dir = dirname
|
|
178
|
-
const json = JSON.parse(await
|
|
90
|
+
const dir = dirname(file);
|
|
91
|
+
const json = JSON.parse(await fs.readFile(file, "utf-8"));
|
|
179
92
|
return {
|
|
180
93
|
...json,
|
|
181
94
|
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"))
|
|
95
|
+
bundleClient: fs$1.existsSync(join(dir, "client.html")),
|
|
96
|
+
bundleNitro: fs$1.existsSync(join(dir, "nitro.html")),
|
|
97
|
+
viteInspect: fs$1.existsSync(join(dir, ".vite-inspect"))
|
|
185
98
|
}
|
|
186
99
|
};
|
|
187
100
|
}));
|
|
188
101
|
return builds.sort((a, b) => b.endTime - a.endTime);
|
|
189
102
|
}
|
|
103
|
+
async function git(...args) {
|
|
104
|
+
const result = await x("git", args, { nodeOptions: { cwd: nuxt.options.rootDir }, throwOnError: true });
|
|
105
|
+
return result.stdout.trim();
|
|
106
|
+
}
|
|
190
107
|
async function generateAnalyzeBuildName() {
|
|
191
108
|
try {
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
if (isWorkingTreeClean)
|
|
109
|
+
const branchName = await git("rev-parse", "--abbrev-ref", "HEAD") || "head";
|
|
110
|
+
const sha = await git("rev-parse", "--short", "HEAD");
|
|
111
|
+
const status = await git("status", "--porcelain");
|
|
112
|
+
const isClean = status === "";
|
|
113
|
+
if (isClean)
|
|
198
114
|
return `${branchName}#${sha}`;
|
|
199
115
|
return `${branchName}#${sha}-dirty`;
|
|
200
116
|
} catch {
|
|
@@ -214,10 +130,10 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
214
130
|
async clearAnalyzeBuilds(token, names) {
|
|
215
131
|
await ensureDevAuthToken(token);
|
|
216
132
|
if (!names) {
|
|
217
|
-
await
|
|
133
|
+
await fs.rm(devtoolsAnalyzeDir, { recursive: true, force: true });
|
|
218
134
|
} else {
|
|
219
135
|
const targets = builds.filter((build) => names.includes(build.name));
|
|
220
|
-
await Promise.all(targets.map((target) =>
|
|
136
|
+
await Promise.all(targets.map((target) => fs.rm(join(devtoolsAnalyzeDir, target.slug), { recursive: true, force: true })));
|
|
221
137
|
}
|
|
222
138
|
initalized = readBuildInfo();
|
|
223
139
|
refresh("getAnalyzeBuildInfo");
|
|
@@ -264,7 +180,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
264
180
|
const filePath = resolve(layerDir, path);
|
|
265
181
|
if (!filePath.startsWith(layerDir))
|
|
266
182
|
continue;
|
|
267
|
-
const stat = await
|
|
183
|
+
const stat = await fs.lstat(filePath);
|
|
268
184
|
const fullPath = join(baseURL, path);
|
|
269
185
|
if (!uniquePaths.has(fullPath)) {
|
|
270
186
|
cache.push({
|
|
@@ -291,7 +207,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
291
207
|
if (_imageMetaCache.has(filepath))
|
|
292
208
|
return _imageMetaCache.get(filepath);
|
|
293
209
|
try {
|
|
294
|
-
const meta = imageMeta(await
|
|
210
|
+
const meta = imageMeta(await fs.readFile(filepath));
|
|
295
211
|
_imageMetaCache.set(filepath, meta);
|
|
296
212
|
return meta;
|
|
297
213
|
} catch (e) {
|
|
@@ -303,7 +219,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
303
219
|
async getTextAssetContent(token, filepath, limit = 300) {
|
|
304
220
|
await ensureDevAuthToken(token);
|
|
305
221
|
try {
|
|
306
|
-
const content = await
|
|
222
|
+
const content = await fs.readFile(filepath, "utf-8");
|
|
307
223
|
return content.slice(0, limit);
|
|
308
224
|
} catch (e) {
|
|
309
225
|
console.error(e);
|
|
@@ -326,16 +242,16 @@ You can configure it in Nuxt config at \`devtools.assets.uploadExtensions\`.`);
|
|
|
326
242
|
}
|
|
327
243
|
if (!override) {
|
|
328
244
|
try {
|
|
329
|
-
await
|
|
245
|
+
await fs.stat(finalPath);
|
|
330
246
|
const base = finalPath.slice(0, finalPath.length - ext.length - 1);
|
|
331
247
|
let i = 1;
|
|
332
|
-
while (await
|
|
248
|
+
while (await fs.access(`${base}-${i}.${ext}`).then(() => true).catch(() => false))
|
|
333
249
|
i++;
|
|
334
250
|
finalPath = `${base}-${i}.${ext}`;
|
|
335
251
|
} catch {
|
|
336
252
|
}
|
|
337
253
|
}
|
|
338
|
-
await
|
|
254
|
+
await fs.writeFile(finalPath, content, {
|
|
339
255
|
encoding: encoding ?? "utf-8"
|
|
340
256
|
});
|
|
341
257
|
return finalPath;
|
|
@@ -344,14 +260,14 @@ You can configure it in Nuxt config at \`devtools.assets.uploadExtensions\`.`);
|
|
|
344
260
|
},
|
|
345
261
|
async deleteStaticAsset(token, path) {
|
|
346
262
|
await ensureDevAuthToken(token);
|
|
347
|
-
return await
|
|
263
|
+
return await fs.unlink(path);
|
|
348
264
|
},
|
|
349
265
|
async renameStaticAsset(token, oldPath, newPath) {
|
|
350
266
|
await ensureDevAuthToken(token);
|
|
351
267
|
const exist = cache?.find((asset) => asset.filePath === newPath);
|
|
352
268
|
if (exist)
|
|
353
269
|
throw new Error(`[Nuxt DevTools] File ${newPath} already exists, failed to rename`);
|
|
354
|
-
return await
|
|
270
|
+
return await fs.rename(oldPath, newPath);
|
|
355
271
|
}
|
|
356
272
|
};
|
|
357
273
|
}
|
|
@@ -7464,7 +7380,7 @@ function read(jsonPath, {base, specifier}) {
|
|
|
7464
7380
|
let string;
|
|
7465
7381
|
|
|
7466
7382
|
try {
|
|
7467
|
-
string = fs.readFileSync(path.toNamespacedPath(jsonPath), 'utf8');
|
|
7383
|
+
string = fs$1.readFileSync(path.toNamespacedPath(jsonPath), 'utf8');
|
|
7468
7384
|
} catch (error) {
|
|
7469
7385
|
const exception = /** @type {ErrnoException} */ (error);
|
|
7470
7386
|
|
|
@@ -9274,7 +9190,7 @@ async function extractExports(name, url, cache = true) {
|
|
|
9274
9190
|
return JSON.parse(await promises.readFile(cachePath, "utf-8"));
|
|
9275
9191
|
const scanned = await resolveModuleExportNames(name, { url });
|
|
9276
9192
|
if (useCache) {
|
|
9277
|
-
await promises.mkdir(dirname
|
|
9193
|
+
await promises.mkdir(dirname(cachePath), { recursive: true });
|
|
9278
9194
|
await promises.writeFile(cachePath, JSON.stringify(scanned), "utf-8");
|
|
9279
9195
|
}
|
|
9280
9196
|
return scanned;
|
|
@@ -10255,6 +10171,63 @@ function safeKey(key) {
|
|
|
10255
10171
|
return JSON.stringify(key);
|
|
10256
10172
|
}
|
|
10257
10173
|
|
|
10174
|
+
function getHomeDir() {
|
|
10175
|
+
return process.env.XDG_CONFIG_HOME || homedir();
|
|
10176
|
+
}
|
|
10177
|
+
async function readLocalOptions(defaults, options) {
|
|
10178
|
+
const { filePath } = getOptionsFilepath(options);
|
|
10179
|
+
if (existsSync(filePath)) {
|
|
10180
|
+
try {
|
|
10181
|
+
const options2 = {
|
|
10182
|
+
...defaults,
|
|
10183
|
+
...JSON.parse(await fs.readFile(filePath, "utf-8")).settings || {}
|
|
10184
|
+
};
|
|
10185
|
+
return options2;
|
|
10186
|
+
} catch (e) {
|
|
10187
|
+
console.error(`[DevTools] failed to parse local options file: ${filePath}, fallback to defaults`);
|
|
10188
|
+
console.error(e);
|
|
10189
|
+
return { ...defaults };
|
|
10190
|
+
}
|
|
10191
|
+
} else {
|
|
10192
|
+
return { ...defaults };
|
|
10193
|
+
}
|
|
10194
|
+
}
|
|
10195
|
+
function getOptionsFilepath(options) {
|
|
10196
|
+
let hashedKey;
|
|
10197
|
+
if (options.key)
|
|
10198
|
+
hashedKey = hash(`${options.root}:${options.key}`);
|
|
10199
|
+
else
|
|
10200
|
+
hashedKey = hash(options.root);
|
|
10201
|
+
const home = getHomeDir();
|
|
10202
|
+
const filePath = join(home, ".nuxt/devtools", `${hashedKey}.json`);
|
|
10203
|
+
return {
|
|
10204
|
+
filePath,
|
|
10205
|
+
hashedKey
|
|
10206
|
+
};
|
|
10207
|
+
}
|
|
10208
|
+
async function clearLocalOptions(options) {
|
|
10209
|
+
const { filePath } = getOptionsFilepath(options);
|
|
10210
|
+
if (existsSync(filePath))
|
|
10211
|
+
await fs.unlink(filePath);
|
|
10212
|
+
}
|
|
10213
|
+
async function writeLocalOptions(settings, options) {
|
|
10214
|
+
const { filePath, hashedKey } = getOptionsFilepath(options);
|
|
10215
|
+
await fs.mkdir(dirname$1(filePath), { recursive: true });
|
|
10216
|
+
await fs.writeFile(
|
|
10217
|
+
filePath,
|
|
10218
|
+
JSON.stringify(
|
|
10219
|
+
{
|
|
10220
|
+
root: options.root,
|
|
10221
|
+
hash: hashedKey,
|
|
10222
|
+
settings
|
|
10223
|
+
},
|
|
10224
|
+
null,
|
|
10225
|
+
2
|
|
10226
|
+
),
|
|
10227
|
+
"utf-8"
|
|
10228
|
+
);
|
|
10229
|
+
}
|
|
10230
|
+
|
|
10258
10231
|
let options;
|
|
10259
10232
|
function getOptions() {
|
|
10260
10233
|
return options;
|
|
@@ -10305,7 +10278,7 @@ function setupOptionsRPC({ nuxt }) {
|
|
|
10305
10278
|
|
|
10306
10279
|
const ABSOLUTE_PATH_RE = /^[a-z]:|^\//i;
|
|
10307
10280
|
const FILE_LINE_COL_RE = /^(.*?)(:[:\d]*)$/;
|
|
10308
|
-
const
|
|
10281
|
+
const NUXT_WELCOME_RE = /<NuxtWelcome\s*\/>/;
|
|
10309
10282
|
function setupGeneralRPC({
|
|
10310
10283
|
nuxt,
|
|
10311
10284
|
options,
|
|
@@ -10494,44 +10467,208 @@ function setupGeneralRPC({
|
|
|
10494
10467
|
return false;
|
|
10495
10468
|
}
|
|
10496
10469
|
},
|
|
10470
|
+
async enablePages(token) {
|
|
10471
|
+
await ensureDevAuthToken(token);
|
|
10472
|
+
const baseDir = nuxt.options.future.compatibilityVersion === 4 ? nuxt.options.dir.app : nuxt.options.srcDir;
|
|
10473
|
+
const pathApp = join(baseDir, "app.vue");
|
|
10474
|
+
const pathPageIndex = join(baseDir, "pages/index.vue");
|
|
10475
|
+
if (existsSync(pathPageIndex)) {
|
|
10476
|
+
logger.warn("pages/index.vue already exists, skipping");
|
|
10477
|
+
return;
|
|
10478
|
+
}
|
|
10479
|
+
const pagesIndexTemplate = `<script setup lang="ts">
|
|
10480
|
+
const route = useRoute()
|
|
10481
|
+
<\/script>
|
|
10482
|
+
|
|
10483
|
+
<template>
|
|
10484
|
+
<div>
|
|
10485
|
+
<h1>Nuxt Routing set up successfully!</h1>
|
|
10486
|
+
<p>Current route: {{ route.path }}</p>
|
|
10487
|
+
<a href="https://nuxt.com/docs/getting-started/routing" target="_blank">Learn more about Nuxt Routing</a>
|
|
10488
|
+
</div>
|
|
10489
|
+
</template>
|
|
10490
|
+
`;
|
|
10491
|
+
await fs.mkdir(dirname(pathPageIndex), { recursive: true });
|
|
10492
|
+
await fs.writeFile(pathPageIndex, pagesIndexTemplate, "utf-8");
|
|
10493
|
+
let appContent = existsSync(pathApp) ? await fs.readFile(pathApp, "utf-8") : void 0;
|
|
10494
|
+
if (appContent && !appContent.includes("<NuxtPage")) {
|
|
10495
|
+
appContent = appContent.replace("</template>", " <NuxtPage />\n</template>").replace(NUXT_WELCOME_RE, "");
|
|
10496
|
+
await fs.writeFile(pathApp, appContent, "utf-8");
|
|
10497
|
+
}
|
|
10498
|
+
logger.success("Routing creation completed");
|
|
10499
|
+
},
|
|
10497
10500
|
async restartNuxt(token, hard = true) {
|
|
10498
10501
|
await ensureDevAuthToken(token);
|
|
10499
10502
|
logger.info("Restarting Nuxt...");
|
|
10500
10503
|
return nuxt.callHook("restart", { hard });
|
|
10501
10504
|
},
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
const token = await getDevAuthToken();
|
|
10506
|
-
origin ||= `${nuxt.options.devServer.https ? "https" : "http"}://${nuxt.options.devServer.host === "::" ? "localhost" : nuxt.options.devServer.host || "localhost"}:${nuxt.options.devServer.port}`;
|
|
10507
|
-
const ROUTE_AUTH = `${nuxt.options.app.baseURL || "/"}/__nuxt_devtools__/auth`.replace(MULTIPLE_SLASHES_RE$1, "/");
|
|
10508
|
-
const message = [
|
|
10509
|
-
`A browser is requesting permissions of ${colors.bold(colors.yellow("writing files and running commands"))} from the DevTools UI.`,
|
|
10510
|
-
colors.bold(info || "Unknown"),
|
|
10511
|
-
"",
|
|
10512
|
-
"Please open the following URL in the browser:",
|
|
10513
|
-
colors.bold(colors.green(`${origin}${ROUTE_AUTH}?token=${token}`)),
|
|
10514
|
-
"",
|
|
10515
|
-
"Or manually copy and paste the following token:",
|
|
10516
|
-
colors.bold(colors.cyan(token))
|
|
10517
|
-
];
|
|
10518
|
-
logger.box({
|
|
10519
|
-
message: message.join("\n"),
|
|
10520
|
-
title: colors.bold(colors.yellow(" Permission Request ")),
|
|
10521
|
-
style: {
|
|
10522
|
-
borderColor: "yellow",
|
|
10523
|
-
borderStyle: "rounded"
|
|
10524
|
-
}
|
|
10525
|
-
});
|
|
10505
|
+
/** @deprecated Auth is now handled by Vite DevTools */
|
|
10506
|
+
async requestForAuth() {
|
|
10507
|
+
logger.warn("[nuxt-devtools] `requestForAuth` is deprecated. Auth is now handled by Vite DevTools.");
|
|
10526
10508
|
},
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
return
|
|
10509
|
+
/** @deprecated Auth is now handled by Vite DevTools */
|
|
10510
|
+
async verifyAuthToken() {
|
|
10511
|
+
logger.warn("[nuxt-devtools] `verifyAuthToken` is deprecated. Auth is now handled by Vite DevTools.");
|
|
10512
|
+
return true;
|
|
10531
10513
|
}
|
|
10532
10514
|
};
|
|
10533
10515
|
}
|
|
10534
10516
|
|
|
10517
|
+
const AGENTS = [
|
|
10518
|
+
"npm",
|
|
10519
|
+
"yarn",
|
|
10520
|
+
"yarn@berry",
|
|
10521
|
+
"pnpm",
|
|
10522
|
+
"pnpm@6",
|
|
10523
|
+
"bun",
|
|
10524
|
+
"deno"
|
|
10525
|
+
];
|
|
10526
|
+
const LOCKS = {
|
|
10527
|
+
"bun.lock": "bun",
|
|
10528
|
+
"bun.lockb": "bun",
|
|
10529
|
+
"deno.lock": "deno",
|
|
10530
|
+
"pnpm-lock.yaml": "pnpm",
|
|
10531
|
+
"pnpm-workspace.yaml": "pnpm",
|
|
10532
|
+
"yarn.lock": "yarn",
|
|
10533
|
+
"package-lock.json": "npm",
|
|
10534
|
+
"npm-shrinkwrap.json": "npm"
|
|
10535
|
+
};
|
|
10536
|
+
const INSTALL_METADATA = {
|
|
10537
|
+
"node_modules/.deno/": "deno",
|
|
10538
|
+
"node_modules/.pnpm/": "pnpm",
|
|
10539
|
+
"node_modules/.yarn-state.yml": "yarn",
|
|
10540
|
+
// yarn v2+ (node-modules)
|
|
10541
|
+
"node_modules/.yarn_integrity": "yarn",
|
|
10542
|
+
// yarn v1
|
|
10543
|
+
"node_modules/.package-lock.json": "npm",
|
|
10544
|
+
".pnp.cjs": "yarn",
|
|
10545
|
+
// yarn v3+ (pnp)
|
|
10546
|
+
".pnp.js": "yarn",
|
|
10547
|
+
// yarn v2 (pnp)
|
|
10548
|
+
"bun.lock": "bun",
|
|
10549
|
+
"bun.lockb": "bun"
|
|
10550
|
+
};
|
|
10551
|
+
|
|
10552
|
+
async function pathExists(path2, type) {
|
|
10553
|
+
try {
|
|
10554
|
+
const stat = await fs.stat(path2);
|
|
10555
|
+
return type === "file" ? stat.isFile() : stat.isDirectory();
|
|
10556
|
+
} catch {
|
|
10557
|
+
return false;
|
|
10558
|
+
}
|
|
10559
|
+
}
|
|
10560
|
+
function* lookup(cwd = process$1.cwd()) {
|
|
10561
|
+
let directory = path.resolve(cwd);
|
|
10562
|
+
const { root } = path.parse(directory);
|
|
10563
|
+
while (directory && directory !== root) {
|
|
10564
|
+
yield directory;
|
|
10565
|
+
directory = path.dirname(directory);
|
|
10566
|
+
}
|
|
10567
|
+
}
|
|
10568
|
+
async function parsePackageJson(filepath, options) {
|
|
10569
|
+
if (!filepath || !await pathExists(filepath, "file"))
|
|
10570
|
+
return null;
|
|
10571
|
+
return await handlePackageManager(filepath, options);
|
|
10572
|
+
}
|
|
10573
|
+
async function detect(options = {}) {
|
|
10574
|
+
const {
|
|
10575
|
+
cwd,
|
|
10576
|
+
strategies = ["lockfile", "packageManager-field", "devEngines-field"]
|
|
10577
|
+
} = options;
|
|
10578
|
+
let stopDir;
|
|
10579
|
+
if (typeof options.stopDir === "string") {
|
|
10580
|
+
const resolved = path.resolve(options.stopDir);
|
|
10581
|
+
stopDir = (dir) => dir === resolved;
|
|
10582
|
+
} else {
|
|
10583
|
+
stopDir = options.stopDir;
|
|
10584
|
+
}
|
|
10585
|
+
for (const directory of lookup(cwd)) {
|
|
10586
|
+
for (const strategy of strategies) {
|
|
10587
|
+
switch (strategy) {
|
|
10588
|
+
case "lockfile": {
|
|
10589
|
+
for (const lock of Object.keys(LOCKS)) {
|
|
10590
|
+
if (await pathExists(path.join(directory, lock), "file")) {
|
|
10591
|
+
const name = LOCKS[lock];
|
|
10592
|
+
const result = await parsePackageJson(path.join(directory, "package.json"), options);
|
|
10593
|
+
if (result)
|
|
10594
|
+
return result;
|
|
10595
|
+
else
|
|
10596
|
+
return { name, agent: name };
|
|
10597
|
+
}
|
|
10598
|
+
}
|
|
10599
|
+
break;
|
|
10600
|
+
}
|
|
10601
|
+
case "packageManager-field":
|
|
10602
|
+
case "devEngines-field": {
|
|
10603
|
+
const result = await parsePackageJson(path.join(directory, "package.json"), options);
|
|
10604
|
+
if (result)
|
|
10605
|
+
return result;
|
|
10606
|
+
break;
|
|
10607
|
+
}
|
|
10608
|
+
case "install-metadata": {
|
|
10609
|
+
for (const metadata of Object.keys(INSTALL_METADATA)) {
|
|
10610
|
+
const fileOrDir = metadata.endsWith("/") ? "dir" : "file";
|
|
10611
|
+
if (await pathExists(path.join(directory, metadata), fileOrDir)) {
|
|
10612
|
+
const name = INSTALL_METADATA[metadata];
|
|
10613
|
+
const agent = name === "yarn" ? isMetadataYarnClassic(metadata) ? "yarn" : "yarn@berry" : name;
|
|
10614
|
+
return { name, agent };
|
|
10615
|
+
}
|
|
10616
|
+
}
|
|
10617
|
+
break;
|
|
10618
|
+
}
|
|
10619
|
+
}
|
|
10620
|
+
}
|
|
10621
|
+
if (stopDir?.(directory))
|
|
10622
|
+
break;
|
|
10623
|
+
}
|
|
10624
|
+
return null;
|
|
10625
|
+
}
|
|
10626
|
+
function getNameAndVer(pkg) {
|
|
10627
|
+
const handelVer = (version) => version?.match(/\d+(\.\d+){0,2}/)?.[0] ?? version;
|
|
10628
|
+
if (typeof pkg.packageManager === "string") {
|
|
10629
|
+
const [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
|
|
10630
|
+
return { name, ver: handelVer(ver) };
|
|
10631
|
+
}
|
|
10632
|
+
if (typeof pkg.devEngines?.packageManager?.name === "string") {
|
|
10633
|
+
return {
|
|
10634
|
+
name: pkg.devEngines.packageManager.name,
|
|
10635
|
+
ver: handelVer(pkg.devEngines.packageManager.version)
|
|
10636
|
+
};
|
|
10637
|
+
}
|
|
10638
|
+
return void 0;
|
|
10639
|
+
}
|
|
10640
|
+
async function handlePackageManager(filepath, options) {
|
|
10641
|
+
try {
|
|
10642
|
+
const content = await fs.readFile(filepath, "utf8");
|
|
10643
|
+
const pkg = options.packageJsonParser ? await options.packageJsonParser(content, filepath) : JSON.parse(content);
|
|
10644
|
+
let agent;
|
|
10645
|
+
const nameAndVer = getNameAndVer(pkg);
|
|
10646
|
+
if (nameAndVer) {
|
|
10647
|
+
const name = nameAndVer.name;
|
|
10648
|
+
const ver = nameAndVer.ver;
|
|
10649
|
+
let version = ver;
|
|
10650
|
+
if (name === "yarn" && ver && Number.parseInt(ver) > 1) {
|
|
10651
|
+
agent = "yarn@berry";
|
|
10652
|
+
version = "berry";
|
|
10653
|
+
return { name, agent, version };
|
|
10654
|
+
} else if (name === "pnpm" && ver && Number.parseInt(ver) < 7) {
|
|
10655
|
+
agent = "pnpm@6";
|
|
10656
|
+
return { name, agent, version };
|
|
10657
|
+
} else if (AGENTS.includes(name)) {
|
|
10658
|
+
agent = name;
|
|
10659
|
+
return { name, agent, version };
|
|
10660
|
+
} else {
|
|
10661
|
+
return options.onUnknown?.(pkg.packageManager) ?? null;
|
|
10662
|
+
}
|
|
10663
|
+
}
|
|
10664
|
+
} catch {
|
|
10665
|
+
}
|
|
10666
|
+
return null;
|
|
10667
|
+
}
|
|
10668
|
+
function isMetadataYarnClassic(metadataPath) {
|
|
10669
|
+
return metadataPath.endsWith(".yarn_integrity");
|
|
10670
|
+
}
|
|
10671
|
+
|
|
10535
10672
|
class FetchError extends Error {
|
|
10536
10673
|
constructor(message, opts) {
|
|
10537
10674
|
super(message, opts);
|
|
@@ -10944,13 +11081,12 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
10944
11081
|
let detectPromise;
|
|
10945
11082
|
const updatesPromise = /* @__PURE__ */ new Map();
|
|
10946
11083
|
function getPackageManager() {
|
|
10947
|
-
detectPromise ||=
|
|
11084
|
+
detectPromise ||= detect({ cwd: nuxt.options.rootDir });
|
|
10948
11085
|
return detectPromise;
|
|
10949
11086
|
}
|
|
10950
11087
|
async function getNpmCommand(command, packageName, options = {}) {
|
|
10951
11088
|
const {
|
|
10952
|
-
dev = true
|
|
10953
|
-
global = packageName === "@nuxt/devtools" && isInstalledGlobally
|
|
11089
|
+
dev = true
|
|
10954
11090
|
} = options;
|
|
10955
11091
|
const agent = await getPackageManager();
|
|
10956
11092
|
const name = agent?.name || "npm";
|
|
@@ -10960,7 +11096,6 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
10960
11096
|
name === "npm" ? "install" : "add",
|
|
10961
11097
|
`${packageName}@latest`,
|
|
10962
11098
|
dev ? "-D" : "",
|
|
10963
|
-
global ? "-g" : "",
|
|
10964
11099
|
// In yarn berry, `--ignore-scripts` is removed
|
|
10965
11100
|
name === "yarn" && !agent?.version?.startsWith("1.") ? "" : "--ignore-scripts"
|
|
10966
11101
|
].filter(Boolean);
|
|
@@ -10969,8 +11104,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
10969
11104
|
return [
|
|
10970
11105
|
name,
|
|
10971
11106
|
name === "npm" ? "uninstall" : "remove",
|
|
10972
|
-
packageName
|
|
10973
|
-
global ? "-g" : ""
|
|
11107
|
+
packageName
|
|
10974
11108
|
].filter(Boolean);
|
|
10975
11109
|
}
|
|
10976
11110
|
}
|
|
@@ -11010,7 +11144,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11010
11144
|
const commands = await getNpmCommand("install", name, { dev: true });
|
|
11011
11145
|
const filepath = nuxt.options._nuxtConfigFile;
|
|
11012
11146
|
let source = latestGenerated;
|
|
11013
|
-
source ??= await
|
|
11147
|
+
source ??= await fs.readFile(filepath, "utf-8");
|
|
11014
11148
|
const generated = await magicastGuard(async () => {
|
|
11015
11149
|
const mod = parseModule(source, { sourceFileName: filepath });
|
|
11016
11150
|
addNuxtModule(mod, name);
|
|
@@ -11029,8 +11163,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11029
11163
|
icon: "carbon:intent-request-create",
|
|
11030
11164
|
restartable: false
|
|
11031
11165
|
});
|
|
11032
|
-
const
|
|
11033
|
-
const result = await execa;
|
|
11166
|
+
const result = await process.getResult();
|
|
11034
11167
|
await Promise.resolve();
|
|
11035
11168
|
installSet.delete(name);
|
|
11036
11169
|
const code = result.exitCode;
|
|
@@ -11040,7 +11173,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11040
11173
|
}
|
|
11041
11174
|
if (installSet.size === 0) {
|
|
11042
11175
|
latestGenerated = null;
|
|
11043
|
-
await
|
|
11176
|
+
await fs.writeFile(filepath, generated, "utf-8");
|
|
11044
11177
|
}
|
|
11045
11178
|
}
|
|
11046
11179
|
return {
|
|
@@ -11054,7 +11187,7 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11054
11187
|
await ensureDevAuthToken(token);
|
|
11055
11188
|
const commands = await getNpmCommand("uninstall", name);
|
|
11056
11189
|
const filepath = nuxt.options._nuxtConfigFile;
|
|
11057
|
-
const source = await
|
|
11190
|
+
const source = await fs.readFile(filepath, "utf-8");
|
|
11058
11191
|
const generated = await magicastGuard(async () => {
|
|
11059
11192
|
const mod = parseModule(source, { sourceFileName: filepath });
|
|
11060
11193
|
const config = getDefaultExportOptions(mod);
|
|
@@ -11078,15 +11211,14 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11078
11211
|
icon: "carbon:intent-request-uninstall",
|
|
11079
11212
|
restartable: false
|
|
11080
11213
|
});
|
|
11081
|
-
const
|
|
11082
|
-
const result = await execa;
|
|
11214
|
+
const result = await process.getResult();
|
|
11083
11215
|
await Promise.resolve();
|
|
11084
11216
|
const code = result.exitCode;
|
|
11085
11217
|
if (code !== 0) {
|
|
11086
11218
|
console.error(result.stderr);
|
|
11087
11219
|
throw new Error(`[Nuxt DevTools] Failed to uninstall module, process exited with ${code}`);
|
|
11088
11220
|
}
|
|
11089
|
-
await
|
|
11221
|
+
await fs.writeFile(filepath, generated, "utf-8");
|
|
11090
11222
|
}
|
|
11091
11223
|
return {
|
|
11092
11224
|
configOriginal: source,
|
|
@@ -11500,7 +11632,7 @@ function setupTimelineRPC({ nuxt }) {
|
|
|
11500
11632
|
return {
|
|
11501
11633
|
async enableTimeline(dry) {
|
|
11502
11634
|
const filepath = nuxt.options._nuxtConfigFile;
|
|
11503
|
-
const source = await
|
|
11635
|
+
const source = await fs.readFile(filepath, "utf-8");
|
|
11504
11636
|
const generated = await magicastGuard(async () => {
|
|
11505
11637
|
const mod = parseModule(source, { sourceFileName: filepath });
|
|
11506
11638
|
const options = getDefaultExportOptions(mod);
|
|
@@ -11510,7 +11642,7 @@ function setupTimelineRPC({ nuxt }) {
|
|
|
11510
11642
|
return mod.generate().code;
|
|
11511
11643
|
}, "\nYou can enable timeline manually by adding `devtools: { timeline: { enabled: true } }`");
|
|
11512
11644
|
if (!dry) {
|
|
11513
|
-
await
|
|
11645
|
+
await fs.writeFile(filepath, generated, "utf-8");
|
|
11514
11646
|
await nuxt.callHook("restart", { hard: true });
|
|
11515
11647
|
}
|
|
11516
11648
|
return [source, generated];
|
|
@@ -11518,90 +11650,68 @@ function setupTimelineRPC({ nuxt }) {
|
|
|
11518
11650
|
};
|
|
11519
11651
|
}
|
|
11520
11652
|
|
|
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
11653
|
function setupRPC(nuxt, options) {
|
|
11569
11654
|
const serverFunctions = {};
|
|
11570
11655
|
const extendedRpcMap = /* @__PURE__ */ new Map();
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
{
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11656
|
+
let rpcHost;
|
|
11657
|
+
const pendingBroadcasts = [];
|
|
11658
|
+
function broadcast(method, ...args) {
|
|
11659
|
+
if (!rpcHost) {
|
|
11660
|
+
pendingBroadcasts.push({ method, args });
|
|
11661
|
+
return;
|
|
11662
|
+
}
|
|
11663
|
+
rpcHost.broadcast({
|
|
11664
|
+
method,
|
|
11665
|
+
args,
|
|
11666
|
+
event: true
|
|
11667
|
+
});
|
|
11668
|
+
}
|
|
11669
|
+
function createBroadcastProxy(prefix = "") {
|
|
11670
|
+
return new Proxy({}, {
|
|
11671
|
+
get: (_, method) => {
|
|
11672
|
+
if (typeof method !== "string")
|
|
11579
11673
|
return;
|
|
11580
|
-
const
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
|
|
11586
|
-
|
|
11587
|
-
|
|
11588
|
-
|
|
11589
|
-
|
|
11674
|
+
const fullMethod = prefix ? `${prefix}:${method}` : method;
|
|
11675
|
+
const fn = (...args) => broadcast(fullMethod, ...args);
|
|
11676
|
+
fn.asEvent = (...args) => broadcast(fullMethod, ...args);
|
|
11677
|
+
return fn;
|
|
11678
|
+
}
|
|
11679
|
+
});
|
|
11680
|
+
}
|
|
11681
|
+
const functionsProxy = new Proxy(serverFunctions, {
|
|
11682
|
+
set(target, prop, value) {
|
|
11683
|
+
target[prop] = value;
|
|
11684
|
+
if (rpcHost && typeof prop === "string") {
|
|
11685
|
+
if (rpcHost.has(prop)) {
|
|
11686
|
+
rpcHost.update({ name: prop, handler: value });
|
|
11687
|
+
} else {
|
|
11688
|
+
rpcHost.register({ name: prop, handler: value });
|
|
11689
|
+
}
|
|
11690
|
+
}
|
|
11691
|
+
return true;
|
|
11590
11692
|
}
|
|
11591
|
-
);
|
|
11693
|
+
});
|
|
11694
|
+
const rpc = {
|
|
11695
|
+
broadcast: createBroadcastProxy(),
|
|
11696
|
+
functions: functionsProxy
|
|
11697
|
+
};
|
|
11592
11698
|
function refresh(event) {
|
|
11593
|
-
|
|
11699
|
+
broadcast("refresh", event);
|
|
11594
11700
|
}
|
|
11595
11701
|
function extendServerRpc(namespace, functions) {
|
|
11596
11702
|
extendedRpcMap.set(namespace, functions);
|
|
11597
|
-
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
return;
|
|
11602
|
-
return rpc.broadcast[`${namespace}:${key}`];
|
|
11703
|
+
if (rpcHost) {
|
|
11704
|
+
for (const [fnName, handler] of Object.entries(functions)) {
|
|
11705
|
+
if (typeof handler === "function") {
|
|
11706
|
+
rpcHost.register({ name: `${namespace}:${fnName}`, handler });
|
|
11603
11707
|
}
|
|
11604
|
-
}
|
|
11708
|
+
}
|
|
11709
|
+
}
|
|
11710
|
+
return {
|
|
11711
|
+
broadcast: createBroadcastProxy(namespace),
|
|
11712
|
+
functions,
|
|
11713
|
+
clients: [],
|
|
11714
|
+
updateChannels: () => []
|
|
11605
11715
|
};
|
|
11606
11716
|
}
|
|
11607
11717
|
const ctx = {
|
|
@@ -11611,11 +11721,9 @@ function setupRPC(nuxt, options) {
|
|
|
11611
11721
|
refresh,
|
|
11612
11722
|
extendServerRpc,
|
|
11613
11723
|
openInEditorHooks: [],
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
if (token !== await getDevAuthToken())
|
|
11618
|
-
throw new Error("[Nuxt DevTools] Invalid dev auth token.");
|
|
11724
|
+
/** @deprecated Auth is now handled by Vite DevTools */
|
|
11725
|
+
async ensureDevAuthToken(_token) {
|
|
11726
|
+
logger.warn("[nuxt-devtools] `ensureDevAuthToken` is deprecated. Auth is now handled by Vite DevTools.");
|
|
11619
11727
|
}
|
|
11620
11728
|
};
|
|
11621
11729
|
nuxt.devtools = ctx;
|
|
@@ -11625,7 +11733,6 @@ function setupRPC(nuxt, options) {
|
|
|
11625
11733
|
...setupStorageRPC(ctx),
|
|
11626
11734
|
...setupAssetsRPC(ctx),
|
|
11627
11735
|
...setupNpmRPC(ctx),
|
|
11628
|
-
...setupWizardRPC(ctx),
|
|
11629
11736
|
...setupTerminalRPC(ctx),
|
|
11630
11737
|
...setupServerRoutesRPC(ctx),
|
|
11631
11738
|
...setupServerTasksRPC(ctx),
|
|
@@ -11635,48 +11742,47 @@ function setupRPC(nuxt, options) {
|
|
|
11635
11742
|
...setupTelemetryRPC(ctx),
|
|
11636
11743
|
...setupServerDataRPC(ctx)
|
|
11637
11744
|
});
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
on: (fn) => {
|
|
11651
|
-
ws.on("message", (e) => {
|
|
11652
|
-
try {
|
|
11653
|
-
const data = JSON.parse(String(e)) || {};
|
|
11654
|
-
if (data.type === "custom" && data.event === WS_EVENT_NAME) {
|
|
11655
|
-
fn(data.data);
|
|
11656
|
-
}
|
|
11657
|
-
} catch {
|
|
11658
|
-
}
|
|
11659
|
-
});
|
|
11660
|
-
},
|
|
11661
|
-
serialize: stringify,
|
|
11662
|
-
deserialize: parse$1
|
|
11663
|
-
};
|
|
11664
|
-
rpc.updateChannels((c) => {
|
|
11665
|
-
c.push(channel);
|
|
11666
|
-
});
|
|
11667
|
-
ws.on("close", () => {
|
|
11668
|
-
wsClients.delete(ws);
|
|
11669
|
-
rpc.updateChannels((c) => {
|
|
11670
|
-
const index = c.indexOf(channel);
|
|
11671
|
-
if (index >= 0)
|
|
11672
|
-
c.splice(index, 1);
|
|
11745
|
+
function connectRpcHost(host) {
|
|
11746
|
+
rpcHost = host;
|
|
11747
|
+
for (const { method, args } of pendingBroadcasts) {
|
|
11748
|
+
broadcast(method, ...args);
|
|
11749
|
+
}
|
|
11750
|
+
pendingBroadcasts.length = 0;
|
|
11751
|
+
for (const [name, handler] of Object.entries(serverFunctions)) {
|
|
11752
|
+
if (typeof handler === "function") {
|
|
11753
|
+
try {
|
|
11754
|
+
host.register({
|
|
11755
|
+
name,
|
|
11756
|
+
handler
|
|
11673
11757
|
});
|
|
11674
|
-
})
|
|
11675
|
-
|
|
11758
|
+
} catch (e) {
|
|
11759
|
+
logger.warn(
|
|
11760
|
+
colors.yellow(`[nuxt-devtools] Failed to register RPC function "${name}":
|
|
11761
|
+
`) + colors.red(e?.message || "")
|
|
11762
|
+
);
|
|
11763
|
+
}
|
|
11764
|
+
}
|
|
11676
11765
|
}
|
|
11677
|
-
|
|
11766
|
+
for (const [namespace, fns] of extendedRpcMap) {
|
|
11767
|
+
for (const [fnName, handler] of Object.entries(fns)) {
|
|
11768
|
+
if (typeof handler === "function") {
|
|
11769
|
+
try {
|
|
11770
|
+
host.register({
|
|
11771
|
+
name: `${namespace}:${fnName}`,
|
|
11772
|
+
handler
|
|
11773
|
+
});
|
|
11774
|
+
} catch (e) {
|
|
11775
|
+
logger.warn(
|
|
11776
|
+
colors.yellow(`[nuxt-devtools] Failed to register RPC function "${namespace}:${fnName}":
|
|
11777
|
+
`) + colors.red(e?.message || "")
|
|
11778
|
+
);
|
|
11779
|
+
}
|
|
11780
|
+
}
|
|
11781
|
+
}
|
|
11782
|
+
}
|
|
11783
|
+
}
|
|
11678
11784
|
return {
|
|
11679
|
-
|
|
11785
|
+
connectRpcHost,
|
|
11680
11786
|
...ctx
|
|
11681
11787
|
};
|
|
11682
11788
|
}
|
|
@@ -11695,8 +11801,10 @@ async function enableModule(options, nuxt) {
|
|
|
11695
11801
|
await import('./analyze-build.mjs').then(({ setup }) => setup(nuxt, options));
|
|
11696
11802
|
return;
|
|
11697
11803
|
}
|
|
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
11804
|
await nuxt.callHook("devtools:before");
|
|
11805
|
+
if (nuxt.options.devtools && typeof nuxt.options.devtools !== "boolean" && "disableAuthorization" in nuxt.options.devtools) {
|
|
11806
|
+
logger.warn("[nuxt-devtools] `disableAuthorization` option is deprecated. Auth is now handled by Vite DevTools.");
|
|
11807
|
+
}
|
|
11700
11808
|
if (options.iframeProps) {
|
|
11701
11809
|
nuxt.options.runtimeConfig.app.devtools ||= {};
|
|
11702
11810
|
nuxt.options.runtimeConfig.app.devtools.iframeProps = options.iframeProps;
|
|
@@ -11710,38 +11818,34 @@ async function enableModule(options, nuxt) {
|
|
|
11710
11818
|
src: join(runtimeDir, "plugins/devtools.server"),
|
|
11711
11819
|
mode: "server"
|
|
11712
11820
|
});
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
}
|
|
11821
|
+
const DevTools = await import('@vitejs/devtools').then((r) => r.DevTools());
|
|
11822
|
+
addVitePlugin(DevTools);
|
|
11823
|
+
let connectRpcHost;
|
|
11824
|
+
addVitePlugin(defineViteDevToolsPlugin({
|
|
11825
|
+
name: "nuxt:devtools",
|
|
11826
|
+
devtools: {
|
|
11827
|
+
setup(ctx2) {
|
|
11828
|
+
ctx2.docks.register({
|
|
11829
|
+
id: "nuxt:devtools",
|
|
11830
|
+
type: "iframe",
|
|
11831
|
+
icon: "https://nuxt.com/assets/design-kit/icon-green.svg",
|
|
11832
|
+
title: "Nuxt DevTools",
|
|
11833
|
+
url: "/__nuxt_devtools__/client/"
|
|
11834
|
+
});
|
|
11835
|
+
connectRpcHost?.(ctx2.rpc);
|
|
11729
11836
|
}
|
|
11730
|
-
}
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
}
|
|
11837
|
+
}
|
|
11838
|
+
}));
|
|
11839
|
+
addPlugin({
|
|
11840
|
+
src: join(runtimeDir, "plugins/vite-devtools.client"),
|
|
11841
|
+
mode: "client"
|
|
11842
|
+
});
|
|
11736
11843
|
addTemplate({
|
|
11737
11844
|
filename: "devtools/settings.mjs",
|
|
11738
11845
|
async getContents() {
|
|
11739
11846
|
const uiOptions = await readLocalOptions(
|
|
11740
11847
|
{
|
|
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
|
|
11848
|
+
...defaultTabOptions.ui
|
|
11745
11849
|
},
|
|
11746
11850
|
{ root: nuxt.options.rootDir }
|
|
11747
11851
|
);
|
|
@@ -11771,10 +11875,10 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11771
11875
|
config.plugins.unshift(join(runtimeDir, "nitro/inline"));
|
|
11772
11876
|
});
|
|
11773
11877
|
const {
|
|
11774
|
-
|
|
11878
|
+
connectRpcHost: _connectRpcHost,
|
|
11775
11879
|
...ctx
|
|
11776
11880
|
} = setupRPC(nuxt, options);
|
|
11777
|
-
|
|
11881
|
+
connectRpcHost = _connectRpcHost;
|
|
11778
11882
|
const clientDirExists = existsSync(clientDir);
|
|
11779
11883
|
extendViteConfig((config) => {
|
|
11780
11884
|
config.server ||= {};
|
|
@@ -11796,15 +11900,13 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11796
11900
|
});
|
|
11797
11901
|
const ROUTE_PATH = `${nuxt.options.app.baseURL || "/"}/__nuxt_devtools__`.replace(MULTIPLE_SLASHES_RE, "/");
|
|
11798
11902
|
const ROUTE_CLIENT = `${ROUTE_PATH}/client`;
|
|
11799
|
-
const ROUTE_AUTH = `${ROUTE_PATH}/auth`;
|
|
11800
|
-
const ROUTE_AUTH_VERIFY = `${ROUTE_PATH}/auth-verify`;
|
|
11801
11903
|
const ROUTE_ANALYZE = `${ROUTE_PATH}/analyze`;
|
|
11802
11904
|
nuxt.hook("vite:serverCreated", (server) => {
|
|
11803
11905
|
const devtoolsAnalyzeDir = join(nuxt.options.rootDir, "node_modules/.cache/nuxt-devtools/analyze");
|
|
11804
11906
|
server.middlewares.use(ROUTE_ANALYZE, sirv(devtoolsAnalyzeDir, { single: false, dev: true, dotfiles: true, ignores: false }));
|
|
11805
11907
|
if (clientDirExists) {
|
|
11806
11908
|
const indexHtmlPath = join(clientDir, "index.html");
|
|
11807
|
-
const indexContent =
|
|
11909
|
+
const indexContent = fs.readFile(indexHtmlPath, "utf-8");
|
|
11808
11910
|
const handleStatic = sirv(clientDir, {
|
|
11809
11911
|
dev: true,
|
|
11810
11912
|
single: false
|
|
@@ -11821,27 +11923,6 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11821
11923
|
return handleStatic(req, res, () => handleIndex(res));
|
|
11822
11924
|
});
|
|
11823
11925
|
}
|
|
11824
|
-
server.middlewares.use(ROUTE_AUTH, sirv(join(runtimeDir, "auth"), { single: true, dev: true }));
|
|
11825
|
-
server.middlewares.use(ROUTE_AUTH_VERIFY, async (req, res) => {
|
|
11826
|
-
const search = req.url?.split("?")[1];
|
|
11827
|
-
if (!search) {
|
|
11828
|
-
res.statusCode = 400;
|
|
11829
|
-
res.end("No token provided");
|
|
11830
|
-
}
|
|
11831
|
-
const query = new URLSearchParams(search);
|
|
11832
|
-
const token = query.get("token");
|
|
11833
|
-
if (!token) {
|
|
11834
|
-
res.statusCode = 400;
|
|
11835
|
-
res.end("No token provided");
|
|
11836
|
-
}
|
|
11837
|
-
if (token === await getDevAuthToken()) {
|
|
11838
|
-
res.statusCode = 200;
|
|
11839
|
-
res.end("Valid token");
|
|
11840
|
-
} else {
|
|
11841
|
-
res.statusCode = 403;
|
|
11842
|
-
res.end("Invalid token");
|
|
11843
|
-
}
|
|
11844
|
-
});
|
|
11845
11926
|
});
|
|
11846
11927
|
await import('./plugin-metrics.mjs').then(({ setup }) => setup(ctx));
|
|
11847
11928
|
if (options.vueDevTools !== false)
|
|
@@ -11857,8 +11938,7 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11857
11938
|
await Promise.all(integrations);
|
|
11858
11939
|
nuxt.hook("modules:done", () => nuxt.callHook("devtools:initialized", {
|
|
11859
11940
|
version: version$1,
|
|
11860
|
-
packagePath: packageDir
|
|
11861
|
-
isGlobalInstall: isGlobalInstall()
|
|
11941
|
+
packagePath: packageDir
|
|
11862
11942
|
}));
|
|
11863
11943
|
const isMac = os.platform() === "darwin";
|
|
11864
11944
|
logger.log([
|
|
@@ -11873,10 +11953,8 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11873
11953
|
"\n"
|
|
11874
11954
|
].join(""));
|
|
11875
11955
|
}
|
|
11956
|
+
function defineViteDevToolsPlugin(plugin) {
|
|
11957
|
+
return plugin;
|
|
11958
|
+
}
|
|
11876
11959
|
|
|
11877
|
-
|
|
11878
|
-
__proto__: null,
|
|
11879
|
-
enableModule: enableModule
|
|
11880
|
-
};
|
|
11881
|
-
|
|
11882
|
-
export { LOG_PREFIX as L, moduleMain as m };
|
|
11960
|
+
export { enableModule };
|