@nuxt/devtools 4.0.0-alpha.1 → 4.0.0-alpha.11
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 +88 -7
- package/dist/chunks/analyze-build.mjs +32 -2
- package/dist/chunks/code-server.mjs +74 -0
- package/dist/chunks/data-inspector.mjs +82 -0
- package/dist/chunks/module-main.mjs +780 -554
- package/dist/chunks/timeline.mjs +2 -2
- package/dist/chunks/vite-inspect.mjs +92 -53
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/__blank-ki8oaugs.js +1 -0
- package/dist/client/_nuxt/analyze-build-ne41xjd4.js +1 -0
- package/dist/client/_nuxt/assets-f8xklgq9.js +6 -0
- package/dist/client/_nuxt/auth-required-panel-hlhmg87z.js +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/491c94f8-60b1-4f88-a55c-3cb1bf18dd79.json +1 -0
- package/dist/client/_nuxt/cd81saaa.js +2 -0
- package/dist/client/_nuxt/{client-im47u3kz.js → client-iet3i2jx.js} +1 -1
- package/dist/client/_nuxt/code-diff-f21wjzw6.js +8 -0
- package/dist/client/_nuxt/code-snippets-e28cw1b6.js +1 -0
- package/dist/client/_nuxt/components-o6uyjkn7.js +1 -0
- package/dist/client/_nuxt/composable-item-ocorhvb4.js +1 -0
- package/dist/client/_nuxt/composables-li5sexni.js +1 -0
- package/dist/client/_nuxt/custom-_name_-m5d1q22j.js +1 -0
- package/dist/client/_nuxt/data-schema-button-kil5d35s.js +1 -0
- package/dist/client/_nuxt/data-schema-drawer-pb9ef6ns.js +2 -0
- package/dist/client/_nuxt/debug-nrr1l0ts.js +1 -0
- package/dist/client/_nuxt/default-m4s11ttb.js +1 -0
- package/dist/client/_nuxt/dialog-loe55arg.js +1 -0
- package/dist/client/_nuxt/dist-2c3gpsw0.js +1 -0
- package/dist/client/_nuxt/dist-gklva25a.js +1 -0
- package/dist/client/_nuxt/duration-display-fjuy04uz.js +1 -0
- package/dist/client/_nuxt/editor-eakm7xzk.js +1 -0
- package/dist/client/_nuxt/entry.css-meav5jmw.css +1 -0
- package/dist/client/_nuxt/error-404-nauqrial.js +1 -0
- package/dist/client/_nuxt/error-404.css-k0vnbfeq.css +1 -0
- package/dist/client/_nuxt/error-500-h4c50p0t.js +1 -0
- package/dist/client/_nuxt/error-500.css-lhh2zs4d.css +1 -0
- package/dist/client/_nuxt/error-nukkk3mr.js +9 -0
- package/dist/client/_nuxt/filepath-item-l8m3u23m.js +1 -0
- package/dist/client/_nuxt/full-kcw32vsy.js +1 -0
- package/dist/client/_nuxt/fuse-ipb957gg.js +1 -0
- package/dist/client/_nuxt/help-fab-ccbj2zxc.js +1 -0
- package/dist/client/_nuxt/hooks-d7ream10.js +1 -0
- package/dist/client/_nuxt/imports-eqmikopw.js +1 -0
- package/dist/client/_nuxt/launch-page-l2e581he.js +1 -0
- package/dist/client/_nuxt/modules-j9bs520l.js +1 -0
- package/dist/client/_nuxt/nbadge-n73p68uz.js +1 -0
- package/dist/client/_nuxt/nbutton-np26z5og.js +1 -0
- package/dist/client/_nuxt/ncard-kyrmtdmn.js +1 -0
- package/dist/client/_nuxt/ncheckbox-hmazj87n.js +1 -0
- package/dist/client/_nuxt/ncode-block-ltlsxf5u.js +2 -0
- package/dist/client/_nuxt/{ncode-block.css-o2ixs97j.css → ncode-block.css-ivoxtfjk.css} +1 -1
- package/dist/client/_nuxt/ndialog-mpi6dkdo.js +3 -0
- package/dist/client/_nuxt/ndrawer-hw8gqgye.js +1 -0
- package/dist/client/_nuxt/ndropdown-l76w9qwv.js +1 -0
- package/dist/client/_nuxt/nicon-co5pnhft.js +4 -0
- package/dist/client/_nuxt/nicon-title-ejbxuupx.js +1 -0
- package/dist/client/_nuxt/nlink-h3jrz76l.js +1 -0
- package/dist/client/_nuxt/nloading-lhpm96ki.js +1 -0
- package/dist/client/_nuxt/nmarkdown-7qnv8atx.js +1 -0
- package/dist/client/_nuxt/nnavbar-g38amume.js +1 -0
- package/dist/client/_nuxt/none-ju85xmqv.js +1 -0
- package/dist/client/_nuxt/npanel-grids-fa3ah9jo.js +1 -0
- package/dist/client/_nuxt/npm-napoklx5.js +1 -0
- package/dist/client/_nuxt/nsection-block-kzcj1vk3.js +1 -0
- package/dist/client/_nuxt/nsection-block.css-h1lgpwgm.css +1 -0
- package/dist/client/_nuxt/nselect-md65qzv8.js +1 -0
- package/dist/client/_nuxt/nselect-tabs-brv0wfuv.js +1 -0
- package/dist/client/_nuxt/nsplit-pane-bs5dfe16.js +1 -0
- package/dist/client/_nuxt/nsplit-pane.css-k1gopk47.css +1 -0
- package/dist/client/_nuxt/ntext-input-obq09i2s.js +1 -0
- package/dist/client/_nuxt/ntip-nv65xhm1.js +1 -0
- package/dist/client/_nuxt/nuxt-hj3jyofn.js +1 -0
- package/dist/client/_nuxt/nuxt-link-nsgkom6k.js +1 -0
- package/dist/client/_nuxt/nuxt-logo-dead1uws.js +1 -0
- package/dist/client/_nuxt/open-graph-d1iodawb.js +3 -0
- package/dist/client/_nuxt/overview-cbabgv3v.js +1 -0
- package/dist/client/_nuxt/pages-oi6j0pbk.js +1 -0
- package/dist/client/_nuxt/payload-ie12v3te.js +1 -0
- package/dist/client/_nuxt/plugins-20xi1djl.js +1 -0
- package/dist/client/_nuxt/ready-ikhds7hc.js +2 -0
- package/dist/client/_nuxt/rolldown-runtime-f96lzs6p.js +1 -0
- package/dist/client/_nuxt/runtime-configs-fq4qn3y8.js +1 -0
- package/dist/client/_nuxt/server-route-inputs-c90qumt8.js +1 -0
- package/dist/client/_nuxt/server-routes-mcizq24b.js +7 -0
- package/dist/client/_nuxt/server-tasks-cicwbkvm.js +1 -0
- package/dist/client/_nuxt/settings-noeex3c7.js +1 -0
- package/dist/client/_nuxt/stacktrace-list-gmhj3wmk.js +1 -0
- package/dist/client/_nuxt/state-commands-bzr47er3.js +1 -0
- package/dist/client/_nuxt/state-components-jvq23n80.js +1 -0
- package/dist/client/_nuxt/state-editor-h7d9pjpa.js +1 -0
- package/dist/client/_nuxt/state-modules-fie7gkqb.js +1 -0
- package/dist/client/_nuxt/state-routes-ntw79bv6.js +1 -0
- package/dist/client/_nuxt/state-schema-eifqm6o4.js +1 -0
- package/dist/client/_nuxt/state-tabs-dhcec3o6.js +1 -0
- package/dist/client/_nuxt/storage-m9yh2hjt.js +1 -0
- package/dist/client/_nuxt/tab-icon-bw4o7q2t.js +1 -0
- package/dist/client/_nuxt/telemetry-mienojg2.js +1 -0
- package/dist/client/_nuxt/timeline-ce3m8i2h.js +31 -0
- package/dist/client/_nuxt/unhead.dnki-vlv7-jmz34zx6.js +1 -0
- package/dist/client/_nuxt/unocss-runtime-htk43m9c.js +1 -0
- package/dist/client/_nuxt/utils-d6zq4cvn.js +1 -0
- package/dist/client/_nuxt/vendor/json-editor-vue-h1waqukq.js +3862 -0
- package/dist/client/_nuxt/vendor/{json-editor-vue.css-lkbe0qhh.css → json-editor-vue.css-lb1ewor6.css} +1 -1
- package/dist/client/_nuxt/vendor/markdown-exit-nzr6hp55.js +12 -0
- package/dist/client/_nuxt/vendor/quicktype-core-lz5bp16m.js +929 -0
- package/dist/client/_nuxt/vendor/shiki-g3svwmfz.js +152 -0
- package/dist/client/_nuxt/vendor/unocss-hvwio62w.js +3 -0
- package/dist/client/_nuxt/vendor/unocss.css-bhad58wt.css +1 -0
- package/dist/client/_nuxt/vendor/vis-bjkylbfi.js +30 -0
- package/dist/client/_nuxt/virtual-files-la0ohl9t.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +1 -1
- package/dist/runtime/plugins/devtools.client.js +1 -1
- package/dist/runtime/plugins/view/client.js +8 -9
- package/dist/runtime/plugins/vite-devtools.client.js +5 -1
- package/dist/shared/devtools.BNZC-DT8.mjs +114 -0
- package/dist/types.d.mts +1 -5
- package/dist/webcomponents/index.mjs +28 -31
- package/package.json +78 -71
- package/.discoveryrc.cjs +0 -13
- package/dist/chunks/vscode.mjs +0 -170
- package/dist/chunks/vue-devtools.mjs +0 -18
- package/dist/client/_nuxt/__blank-cpzbm3dn.js +0 -1
- package/dist/client/_nuxt/analyze-build-e7v5vkef.js +0 -1
- package/dist/client/_nuxt/assets-b5c187l4.js +0 -6
- package/dist/client/_nuxt/builds/meta/25fc8778-785e-4df1-8047-b131fc1cd4b2.json +0 -1
- package/dist/client/_nuxt/code-diff-idsu3m0z.js +0 -8
- package/dist/client/_nuxt/code-snippets-k81hoi4s.js +0 -1
- package/dist/client/_nuxt/components-bmictfph.js +0 -1
- package/dist/client/_nuxt/composable-item-cza22cup.js +0 -1
- package/dist/client/_nuxt/copkoh3j.js +0 -4
- package/dist/client/_nuxt/custom-_name_-gqm5kr56.js +0 -1
- package/dist/client/_nuxt/data-schema-button-b308wyi0.js +0 -1
- package/dist/client/_nuxt/data-schema-drawer-lr34uwsh.js +0 -2
- package/dist/client/_nuxt/debug-kgc8fptp.js +0 -1
- package/dist/client/_nuxt/default-jvhm51ri.js +0 -1
- package/dist/client/_nuxt/dev-auth-ojiqold5.js +0 -1
- package/dist/client/_nuxt/dist-duc3zu0y.js +0 -1
- package/dist/client/_nuxt/dist-mnod32r1.js +0 -1
- package/dist/client/_nuxt/duration-display-f7ucshmo.js +0 -1
- package/dist/client/_nuxt/entry.css-me26coxn.css +0 -1
- package/dist/client/_nuxt/error-404-nggtc73s.js +0 -1
- package/dist/client/_nuxt/error-404.css-j1aav08u.css +0 -1
- package/dist/client/_nuxt/error-500-dym2gzqx.js +0 -1
- package/dist/client/_nuxt/error-500.css-eu9fz4va.css +0 -1
- package/dist/client/_nuxt/error-fqinfa1x.js +0 -9
- package/dist/client/_nuxt/filepath-item-e1s52fbh.js +0 -1
- package/dist/client/_nuxt/full-et0weok9.js +0 -1
- package/dist/client/_nuxt/help-fab-hz6r2oxa.js +0 -1
- package/dist/client/_nuxt/hooks-i7nsduqp.js +0 -1
- package/dist/client/_nuxt/imports-9o2qs53q.js +0 -1
- package/dist/client/_nuxt/launch-page-hpkkqhit.js +0 -1
- package/dist/client/_nuxt/mitt.es-fjx0h8xe.js +0 -1
- package/dist/client/_nuxt/modules-jok0opuq.js +0 -1
- package/dist/client/_nuxt/nbadge-m66xoquo.js +0 -1
- package/dist/client/_nuxt/nbutton-gygn07c2.js +0 -1
- package/dist/client/_nuxt/ncard-mqcl8pso.js +0 -1
- package/dist/client/_nuxt/ncheckbox-c0r45qtu.js +0 -1
- package/dist/client/_nuxt/ncode-block-figzf35k.js +0 -2
- package/dist/client/_nuxt/ndrawer-bgqyrlmt.js +0 -1
- package/dist/client/_nuxt/ndropdown-cip8lboe.js +0 -1
- package/dist/client/_nuxt/nicon-m1crov2l.js +0 -1
- package/dist/client/_nuxt/nicon-title-tqdvw0w0.js +0 -1
- package/dist/client/_nuxt/nlink-od4lllbl.js +0 -1
- package/dist/client/_nuxt/nmarkdown-hw0hmqw7.js +0 -1
- package/dist/client/_nuxt/nnavbar-lpozm5fj.js +0 -1
- package/dist/client/_nuxt/none-bdxkqeml.js +0 -1
- package/dist/client/_nuxt/npanel-grids-dd23ifsw.js +0 -1
- package/dist/client/_nuxt/nsection-block-lqrohs9v.js +0 -1
- package/dist/client/_nuxt/nsection-block.css-h05mpq8x.css +0 -1
- package/dist/client/_nuxt/nselect-gczoit0g.js +0 -1
- package/dist/client/_nuxt/nselect-tabs-bsw5fg3d.js +0 -1
- package/dist/client/_nuxt/nswitch-ke379yjx.js +0 -1
- package/dist/client/_nuxt/ntext-input-cygthohl.js +0 -1
- package/dist/client/_nuxt/ntip-ke63ovgc.js +0 -1
- package/dist/client/_nuxt/nuxt-link-bumooa9d.js +0 -1
- package/dist/client/_nuxt/nuxt-otp6bp04.js +0 -1
- package/dist/client/_nuxt/open-graph-lumhcitx.js +0 -3
- package/dist/client/_nuxt/overview-c1ufrox9.js +0 -1
- package/dist/client/_nuxt/pages-cf1hvns3.js +0 -1
- package/dist/client/_nuxt/pages-lgihsvbt.js +0 -1
- package/dist/client/_nuxt/payload-fvgw4hh9.js +0 -1
- package/dist/client/_nuxt/pinia-lmrgyjxw.js +0 -1
- package/dist/client/_nuxt/plugins-ccaip8nh.js +0 -1
- package/dist/client/_nuxt/ready-dadbdj5i.js +0 -1
- package/dist/client/_nuxt/render-tree-corj3giw.js +0 -1
- package/dist/client/_nuxt/rolldown-runtime-oipoa1or.js +0 -1
- package/dist/client/_nuxt/rpc-ez4fzlum.js +0 -1
- package/dist/client/_nuxt/runtime-configs-im0uu24n.js +0 -1
- package/dist/client/_nuxt/server-discovery-ffkkczqi.js +0 -1
- package/dist/client/_nuxt/server-route-inputs-lspeoiem.js +0 -1
- package/dist/client/_nuxt/server-routes-dhvqrowz.js +0 -7
- package/dist/client/_nuxt/server-tasks-mr9ezn8q.js +0 -1
- package/dist/client/_nuxt/settings-issronwn.js +0 -1
- package/dist/client/_nuxt/splitpanes.es-bxyirks2.js +0 -1
- package/dist/client/_nuxt/stacktrace-list-hiui24c3.js +0 -1
- package/dist/client/_nuxt/state-components-fbls8ka7.js +0 -1
- package/dist/client/_nuxt/state-editor-c7e04uj2.js +0 -1
- package/dist/client/_nuxt/state-modules-inqbwd7z.js +0 -1
- package/dist/client/_nuxt/state-routes-jln33b1m.js +0 -1
- package/dist/client/_nuxt/state-tabs-etl5jr30.js +0 -1
- package/dist/client/_nuxt/storage-husj5pg6.js +0 -1
- package/dist/client/_nuxt/storage-options-cth3coln.js +0 -1
- package/dist/client/_nuxt/telemetry-eqv6a0hn.js +0 -1
- package/dist/client/_nuxt/terminals-kitd8oja.js +0 -1
- package/dist/client/_nuxt/terminals.css-mejv43xm.css +0 -1
- package/dist/client/_nuxt/timeline-gr4tcvcz.js +0 -31
- package/dist/client/_nuxt/unocss-runtime-cpug61u1.js +0 -1
- package/dist/client/_nuxt/utils-nbkl6byi.js +0 -2
- package/dist/client/_nuxt/vendor/json-editor-vue-eojr4v24.js +0 -3869
- package/dist/client/_nuxt/vendor/markdown-it-ckeo8pwp.js +0 -14
- package/dist/client/_nuxt/vendor/quicktype-core-k4qx3809.js +0 -929
- package/dist/client/_nuxt/vendor/shiki-lqo1hg2n.js +0 -153
- package/dist/client/_nuxt/vendor/unocss-k727ub0h.js +0 -3
- package/dist/client/_nuxt/vendor/unocss.css-3gd0e2sv.css +0 -1
- package/dist/client/_nuxt/vendor/vis-id8udisj.js +0 -26
- package/dist/client/_nuxt/vendor/xterm-ed0pys2e.js +0 -36
- package/dist/client/_nuxt/vendor/xterm.css-jqmddlol.css +0 -1
- package/dist/client/_nuxt/virtual-files-ky9cc4av.js +0 -1
- package/dist/client/_nuxt/vue-devtools-dunhx2nz.js +0 -4
- package/dist/client/_nuxt/vue-router-jbnxw7nb.js +0 -1
- package/dist/client/discovery/index.html +0 -611
- package/dist/runtime/vue-devtools-client.d.ts +0 -2
- package/dist/runtime/vue-devtools-client.js +0 -8
- package/dist/shared/devtools.COlX0Gls.mjs +0 -114
- /package/dist/client/_nuxt/{_plugin-vue_export-helper-n58akrbk.js → _plugin-vue_export-helper-d9irwgla.js} +0 -0
- /package/dist/client/_nuxt/{color-b9xoe9j2.js → color-abaog8vc.js} +0 -0
- /package/dist/client/_nuxt/{composables-b2ccklz4.js → composables-ioamscf4.js} +0 -0
- /package/dist/client/_nuxt/{constants-ih922r91.js → constants-g2z8m4rs.js} +0 -0
- /package/dist/client/_nuxt/{dist-m49wlq01.js → dist-das2ggjj.js} +0 -0
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import fs$1, {
|
|
1
|
+
import fs$1, { promises, statSync, realpathSync, readFileSync, existsSync, accessSync, constants } from 'node:fs';
|
|
2
2
|
import fs from 'node:fs/promises';
|
|
3
3
|
import os, { homedir } from 'node:os';
|
|
4
|
-
import {
|
|
4
|
+
import { onDevtoolsReady, deprecate, registerHostDiagnostics, NUXT_DEVTOOLS_GROUP_ID } from '@nuxt/devtools-kit';
|
|
5
|
+
import { logger, useNuxt, extendViteConfig, addPlugin, addVitePlugin, addTemplate, addImports } from '@nuxt/kit';
|
|
5
6
|
import { colors } from 'consola/utils';
|
|
6
|
-
import { join, dirname
|
|
7
|
+
import { join, dirname, resolve, isAbsolute } from 'pathe';
|
|
7
8
|
import sirv from 'sirv';
|
|
8
9
|
import { searchForWorkspaceRoot } from 'vite';
|
|
9
|
-
import { d as defaultAllowedExtensions,
|
|
10
|
-
import path, { dirname, join as join$1, relative, parse } from 'node:path';
|
|
11
|
-
import { hash } from 'ohash';
|
|
10
|
+
import { d as defaultAllowedExtensions, c as createDefaultTabOptions, s as setServerTasksEnabledByDefault } from '../shared/devtools.BNZC-DT8.mjs';
|
|
12
11
|
import { runtimeDir, clientDir, packageDir } from '../dirs.mjs';
|
|
13
|
-
import { createBirpcGroup } from 'birpc';
|
|
14
|
-
import { parse as parse$1, stringify } from 'structured-clone-es';
|
|
15
|
-
import { startSubprocess } from '@nuxt/devtools-kit';
|
|
16
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';
|
|
@@ -29,124 +27,81 @@ import { format, inspect } from 'node:util';
|
|
|
29
27
|
import { resolveModule, getPackageInfo } from 'local-pkg';
|
|
30
28
|
import { parseModule } from 'magicast';
|
|
31
29
|
import { getDefaultExportOptions, addNuxtModule } from 'magicast/helpers';
|
|
32
|
-
import
|
|
33
|
-
import {
|
|
30
|
+
import { isLess } from 'verkit';
|
|
31
|
+
import { DEVTOOLS_TERMINALS_DOCK_ID } from '@vitejs/devtools-kit/constants';
|
|
32
|
+
import { normalizeBaseKey, normalizeKey, createStorage, builtinDrivers } from 'unstorage';
|
|
34
33
|
|
|
35
|
-
const version$1 = "4.0.0-alpha.
|
|
36
|
-
|
|
37
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
38
|
-
function randomStr(size = 16, dict = urlAlphabet) {
|
|
39
|
-
let id = "";
|
|
40
|
-
let i = size;
|
|
41
|
-
const len = dict.length;
|
|
42
|
-
while (i--)
|
|
43
|
-
id += dict[Math.random() * len | 0];
|
|
44
|
-
return id;
|
|
45
|
-
}
|
|
34
|
+
const version$1 = "4.0.0-alpha.11";
|
|
46
35
|
|
|
47
|
-
|
|
48
|
-
return process.env.XDG_CONFIG_HOME || homedir();
|
|
49
|
-
}
|
|
50
|
-
async function readLocalOptions(defaults, options) {
|
|
51
|
-
const { filePath } = getOptionsFilepath(options);
|
|
52
|
-
if (existsSync(filePath)) {
|
|
53
|
-
try {
|
|
54
|
-
const options2 = {
|
|
55
|
-
...defaults,
|
|
56
|
-
...JSON.parse(await fs.readFile(filePath, "utf-8")).settings || {}
|
|
57
|
-
};
|
|
58
|
-
return options2;
|
|
59
|
-
} catch (e) {
|
|
60
|
-
console.error(`[DevTools] failed to parse local options file: ${filePath}, fallback to defaults`);
|
|
61
|
-
console.error(e);
|
|
62
|
-
return { ...defaults };
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
return { ...defaults };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function getOptionsFilepath(options) {
|
|
69
|
-
let hashedKey;
|
|
70
|
-
if (options.key)
|
|
71
|
-
hashedKey = hash(`${options.root}:${options.key}`);
|
|
72
|
-
else
|
|
73
|
-
hashedKey = hash(options.root);
|
|
74
|
-
const home = getHomeDir();
|
|
75
|
-
const filePath = join(home, ".nuxt/devtools", `${hashedKey}.json`);
|
|
76
|
-
return {
|
|
77
|
-
filePath,
|
|
78
|
-
hashedKey
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
async function clearLocalOptions(options) {
|
|
82
|
-
const { filePath } = getOptionsFilepath(options);
|
|
83
|
-
if (existsSync(filePath))
|
|
84
|
-
await fs.unlink(filePath);
|
|
85
|
-
}
|
|
86
|
-
async function writeLocalOptions(settings, options) {
|
|
87
|
-
const { filePath, hashedKey } = getOptionsFilepath(options);
|
|
88
|
-
await fs.mkdir(dirname(filePath), { recursive: true });
|
|
89
|
-
await fs.writeFile(
|
|
90
|
-
filePath,
|
|
91
|
-
JSON.stringify(
|
|
92
|
-
{
|
|
93
|
-
root: options.root,
|
|
94
|
-
hash: hashedKey,
|
|
95
|
-
settings
|
|
96
|
-
},
|
|
97
|
-
null,
|
|
98
|
-
2
|
|
99
|
-
),
|
|
100
|
-
"utf-8"
|
|
101
|
-
);
|
|
102
|
-
}
|
|
36
|
+
const RPC_NAMESPACE = "nuxt:devtools";
|
|
103
37
|
|
|
104
|
-
let
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const home = getHomeDir();
|
|
109
|
-
const dir = join$1(home, ".nuxt/devtools");
|
|
110
|
-
const filepath = join$1(dir, "dev-auth-token.txt");
|
|
111
|
-
if (existsSync(filepath))
|
|
112
|
-
token = (await fs.readFile(filepath, "utf-8")).trim();
|
|
113
|
-
if (!token)
|
|
114
|
-
token = randomStr(16);
|
|
115
|
-
await fs.mkdir(dir, { recursive: true });
|
|
116
|
-
await fs.writeFile(filepath, token, "utf-8");
|
|
117
|
-
return token;
|
|
38
|
+
let counter = 0;
|
|
39
|
+
function createUniqueSessionId(baseId) {
|
|
40
|
+
counter += 1;
|
|
41
|
+
return `${baseId}#${counter}`;
|
|
118
42
|
}
|
|
119
43
|
|
|
120
44
|
const COLON_RE = /:/g;
|
|
121
|
-
function setupAnalyzeBuildRPC(
|
|
45
|
+
function setupAnalyzeBuildRPC(ctx) {
|
|
46
|
+
const { nuxt, refresh } = ctx;
|
|
122
47
|
let builds = [];
|
|
123
48
|
let promise;
|
|
124
49
|
let initalized;
|
|
125
|
-
|
|
50
|
+
let activeSessionId;
|
|
126
51
|
const devtoolsAnalyzeDir = join(nuxt.options.rootDir, "node_modules/.cache/nuxt-devtools/analyze");
|
|
127
52
|
async function startAnalyzeBuild(name) {
|
|
128
53
|
if (promise)
|
|
129
54
|
throw new Error("[Nuxt DevTools] A building process is already running");
|
|
130
|
-
const
|
|
55
|
+
const kit = ctx.devtoolsKit;
|
|
56
|
+
if (!kit)
|
|
57
|
+
throw new Error("[Nuxt DevTools] Vite DevTools kit is not connected yet.");
|
|
58
|
+
const sessionId = createUniqueSessionId("devtools:analyze-build");
|
|
59
|
+
activeSessionId = sessionId;
|
|
60
|
+
const session = await kit.terminals.startChildProcess({
|
|
131
61
|
command: "npx",
|
|
132
62
|
args: ["nuxi", "analyze", "--no-serve", "--name", name],
|
|
133
63
|
cwd: nuxt.options.rootDir
|
|
134
64
|
}, {
|
|
135
|
-
id:
|
|
136
|
-
|
|
65
|
+
id: sessionId,
|
|
66
|
+
title: "Analyze Build",
|
|
137
67
|
icon: "logos-nuxt-icon"
|
|
138
|
-
}
|
|
68
|
+
});
|
|
139
69
|
refresh("getAnalyzeBuildInfo");
|
|
140
70
|
initalized = void 0;
|
|
141
|
-
promise = Promise.resolve(
|
|
71
|
+
promise = Promise.resolve(session.getResult()).then((result) => {
|
|
72
|
+
if (result.exitCode && result.exitCode !== 0) {
|
|
73
|
+
ctx.notify({
|
|
74
|
+
message: `Build analysis "${name}" failed`,
|
|
75
|
+
level: "error",
|
|
76
|
+
description: `Process exited with code ${result.exitCode}. Check the Analyze Build terminal for details.`,
|
|
77
|
+
category: "build",
|
|
78
|
+
notify: true
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
ctx.notify({
|
|
82
|
+
message: `Build analysis "${name}" complete`,
|
|
83
|
+
level: "success",
|
|
84
|
+
category: "build",
|
|
85
|
+
notify: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
142
88
|
refresh("getAnalyzeBuildInfo");
|
|
143
89
|
return readBuildInfo();
|
|
90
|
+
}).catch((error) => {
|
|
91
|
+
ctx.notify({
|
|
92
|
+
message: `Build analysis "${name}" failed`,
|
|
93
|
+
level: "error",
|
|
94
|
+
description: error instanceof Error ? error.message : String(error),
|
|
95
|
+
category: "build",
|
|
96
|
+
notify: true
|
|
97
|
+
});
|
|
144
98
|
}).finally(() => {
|
|
145
99
|
promise = void 0;
|
|
146
100
|
initalized = void 0;
|
|
101
|
+
activeSessionId = void 0;
|
|
147
102
|
refresh("getAnalyzeBuildInfo");
|
|
148
103
|
});
|
|
149
|
-
return
|
|
104
|
+
return sessionId;
|
|
150
105
|
}
|
|
151
106
|
async function readBuildInfo() {
|
|
152
107
|
for (const dir of /* @__PURE__ */ new Set([
|
|
@@ -161,7 +116,7 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
161
116
|
});
|
|
162
117
|
for (const file of files2) {
|
|
163
118
|
const slug = JSON.parse(await fs.readFile(file, "utf-8")).slug;
|
|
164
|
-
const dir2 = dirname
|
|
119
|
+
const dir2 = dirname(file);
|
|
165
120
|
await fs.mkdir(devtoolsAnalyzeDir, { recursive: true });
|
|
166
121
|
await fs.rename(dir2, join(devtoolsAnalyzeDir, slug));
|
|
167
122
|
}
|
|
@@ -172,7 +127,7 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
172
127
|
absolute: true
|
|
173
128
|
});
|
|
174
129
|
builds = await Promise.all(files.map(async (file) => {
|
|
175
|
-
const dir = dirname
|
|
130
|
+
const dir = dirname(file);
|
|
176
131
|
const json = JSON.parse(await fs.readFile(file, "utf-8"));
|
|
177
132
|
return {
|
|
178
133
|
...json,
|
|
@@ -209,11 +164,11 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
209
164
|
await initalized;
|
|
210
165
|
return {
|
|
211
166
|
isBuilding: !!promise,
|
|
167
|
+
activeSessionId,
|
|
212
168
|
builds
|
|
213
169
|
};
|
|
214
170
|
},
|
|
215
|
-
async clearAnalyzeBuilds(
|
|
216
|
-
await ensureDevAuthToken(token);
|
|
171
|
+
async clearAnalyzeBuilds(names) {
|
|
217
172
|
if (!names) {
|
|
218
173
|
await fs.rm(devtoolsAnalyzeDir, { recursive: true, force: true });
|
|
219
174
|
} else {
|
|
@@ -224,14 +179,13 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
|
|
|
224
179
|
refresh("getAnalyzeBuildInfo");
|
|
225
180
|
},
|
|
226
181
|
generateAnalyzeBuildName,
|
|
227
|
-
async startAnalyzeBuild(
|
|
228
|
-
await ensureDevAuthToken(token);
|
|
182
|
+
async startAnalyzeBuild(...args) {
|
|
229
183
|
return startAnalyzeBuild(...args);
|
|
230
184
|
}
|
|
231
185
|
};
|
|
232
186
|
}
|
|
233
187
|
|
|
234
|
-
function setupAssetsRPC({ nuxt,
|
|
188
|
+
function setupAssetsRPC({ nuxt, refresh, options }) {
|
|
235
189
|
const _imageMetaCache = /* @__PURE__ */ new Map();
|
|
236
190
|
let cache = null;
|
|
237
191
|
const extensions = options.assets?.uploadExtensions || defaultAllowedExtensions;
|
|
@@ -287,8 +241,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
287
241
|
async getStaticAssets() {
|
|
288
242
|
return await scan();
|
|
289
243
|
},
|
|
290
|
-
async getImageMeta(
|
|
291
|
-
await ensureDevAuthToken(token);
|
|
244
|
+
async getImageMeta(filepath) {
|
|
292
245
|
if (_imageMetaCache.has(filepath))
|
|
293
246
|
return _imageMetaCache.get(filepath);
|
|
294
247
|
try {
|
|
@@ -301,8 +254,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
301
254
|
return void 0;
|
|
302
255
|
}
|
|
303
256
|
},
|
|
304
|
-
async getTextAssetContent(
|
|
305
|
-
await ensureDevAuthToken(token);
|
|
257
|
+
async getTextAssetContent(filepath, limit = 300) {
|
|
306
258
|
try {
|
|
307
259
|
const content = await fs.readFile(filepath, "utf-8");
|
|
308
260
|
return content.slice(0, limit);
|
|
@@ -311,8 +263,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
|
|
|
311
263
|
return void 0;
|
|
312
264
|
}
|
|
313
265
|
},
|
|
314
|
-
async writeStaticAssets(
|
|
315
|
-
await ensureDevAuthToken(token);
|
|
266
|
+
async writeStaticAssets(files, folder) {
|
|
316
267
|
const baseDir = resolve(nuxt.options.srcDir, nuxt.options.dir.public + folder);
|
|
317
268
|
return await Promise.all(
|
|
318
269
|
files.map(async ({ path, content, encoding, override }) => {
|
|
@@ -343,12 +294,10 @@ You can configure it in Nuxt config at \`devtools.assets.uploadExtensions\`.`);
|
|
|
343
294
|
})
|
|
344
295
|
);
|
|
345
296
|
},
|
|
346
|
-
async deleteStaticAsset(
|
|
347
|
-
await ensureDevAuthToken(token);
|
|
297
|
+
async deleteStaticAsset(path) {
|
|
348
298
|
return await fs.unlink(path);
|
|
349
299
|
},
|
|
350
|
-
async renameStaticAsset(
|
|
351
|
-
await ensureDevAuthToken(token);
|
|
300
|
+
async renameStaticAsset(oldPath, newPath) {
|
|
352
301
|
const exist = cache?.find((asset) => asset.filePath === newPath);
|
|
353
302
|
if (exist)
|
|
354
303
|
throw new Error(`[Nuxt DevTools] File ${newPath} already exists, failed to rename`);
|
|
@@ -818,6 +767,9 @@ var defaultOptions = {
|
|
|
818
767
|
// Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
|
|
819
768
|
// strict mode and parsing of `import` and `export` declarations.
|
|
820
769
|
sourceType: "script",
|
|
770
|
+
// When set to true, enable strict parsing mode even if `sourceType`
|
|
771
|
+
// is `"script"`.
|
|
772
|
+
strict: false,
|
|
821
773
|
// `onInsertedSemicolon` can be a callback that will be called when
|
|
822
774
|
// a semicolon is automatically inserted. It will be passed the
|
|
823
775
|
// position of the inserted semicolon as an offset, and if
|
|
@@ -859,6 +811,11 @@ var defaultOptions = {
|
|
|
859
811
|
// line being 1-based and column 0-based) will be attached to the
|
|
860
812
|
// nodes.
|
|
861
813
|
locations: false,
|
|
814
|
+
// Pass an optional `{line, column}` object to use for the start of
|
|
815
|
+
// the parse. This is mostly useful when using `parseExpressionAt`
|
|
816
|
+
// with `locations: true`, to prevent the parser from having to
|
|
817
|
+
// determine the line position at the start position.
|
|
818
|
+
startLocation: null,
|
|
862
819
|
// A function can be passed as `onToken` option, which will
|
|
863
820
|
// cause Acorn to call that function with object in the same
|
|
864
821
|
// format as tokens returned from `tokenizer().getToken()`. Note
|
|
@@ -1012,13 +969,17 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
1012
969
|
// Set up token state
|
|
1013
970
|
|
|
1014
971
|
// The current position of the tokenizer in the input.
|
|
1015
|
-
|
|
1016
|
-
|
|
972
|
+
this.pos = startPos || 0;
|
|
973
|
+
this.curLine = 1;
|
|
974
|
+
if (options.startLocation) {
|
|
975
|
+
this.lineStart = this.pos - options.startLocation.column;
|
|
976
|
+
this.curLine = options.startLocation.line;
|
|
977
|
+
} else if (startPos) {
|
|
1017
978
|
this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
|
|
1018
|
-
|
|
979
|
+
if (this.options.locations)
|
|
980
|
+
{ this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; }
|
|
1019
981
|
} else {
|
|
1020
|
-
this.
|
|
1021
|
-
this.curLine = 1;
|
|
982
|
+
this.lineStart = 0;
|
|
1022
983
|
}
|
|
1023
984
|
|
|
1024
985
|
// Properties of the current token:
|
|
@@ -1044,7 +1005,7 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
1044
1005
|
|
|
1045
1006
|
// Figure out if it's a module code.
|
|
1046
1007
|
this.inModule = options.sourceType === "module";
|
|
1047
|
-
this.strict = this.inModule || this.strictDirective(this.pos);
|
|
1008
|
+
this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
|
|
1048
1009
|
|
|
1049
1010
|
// Used to signify the start of a potential arrow function
|
|
1050
1011
|
this.potentialArrowAt = -1;
|
|
@@ -1082,9 +1043,11 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
1082
1043
|
var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowReturn: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },allowUsing: { configurable: true },inClassStaticBlock: { configurable: true } };
|
|
1083
1044
|
|
|
1084
1045
|
Parser.prototype.parse = function parse () {
|
|
1046
|
+
var this$1$1 = this;
|
|
1047
|
+
|
|
1085
1048
|
var node = this.options.program || this.startNode();
|
|
1086
1049
|
this.nextToken();
|
|
1087
|
-
return this.parseTopLevel(node)
|
|
1050
|
+
return this.catchStackOverflow(function () { return this$1$1.parseTopLevel(node); })
|
|
1088
1051
|
};
|
|
1089
1052
|
|
|
1090
1053
|
prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
|
|
@@ -1223,6 +1186,17 @@ pp$9.eatContextual = function(name) {
|
|
|
1223
1186
|
return true
|
|
1224
1187
|
};
|
|
1225
1188
|
|
|
1189
|
+
pp$9.catchStackOverflow = function(f) {
|
|
1190
|
+
try {
|
|
1191
|
+
return f()
|
|
1192
|
+
} catch (e) {
|
|
1193
|
+
if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message)))
|
|
1194
|
+
{ this.raise(this.start, "Not enough stack space to parse input"); }
|
|
1195
|
+
else
|
|
1196
|
+
{ throw e }
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1226
1200
|
// Asserts that following token is given contextual keyword.
|
|
1227
1201
|
|
|
1228
1202
|
pp$9.expectContextual = function(name) {
|
|
@@ -1418,7 +1392,18 @@ pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
|
|
|
1418
1392
|
while (isIdentifierChar(ch = this.fullCharCodeAt(next)))
|
|
1419
1393
|
if (ch === 92) { return true }
|
|
1420
1394
|
var id = this.input.slice(idStart, next);
|
|
1421
|
-
if (keywordRelationalOperator.test(id)
|
|
1395
|
+
if (keywordRelationalOperator.test(id)) { return false }
|
|
1396
|
+
if (isFor && !isAwaitUsing && id === "of") {
|
|
1397
|
+
// Look ahead for using declaration with initializer, i.e., `for (using of = ...)`
|
|
1398
|
+
skipWhiteSpace.lastIndex = next;
|
|
1399
|
+
var skipAfterOf = skipWhiteSpace.exec(this.input);
|
|
1400
|
+
next = next + skipAfterOf[0].length;
|
|
1401
|
+
if (this.input.charCodeAt(next) !== 61 /* '=' */ ||
|
|
1402
|
+
// Check for ==, === and => operators
|
|
1403
|
+
(ch = this.input.charCodeAt(next + 1)) === 61 /* '=' */ || ch === 62 /* '>' */) {
|
|
1404
|
+
return false
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1422
1407
|
return true
|
|
1423
1408
|
};
|
|
1424
1409
|
|
|
@@ -1511,6 +1496,10 @@ pp$8.parseStatement = function(context, topLevel, exports$1) {
|
|
|
1511
1496
|
if (!this.allowUsing) {
|
|
1512
1497
|
this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
|
|
1513
1498
|
}
|
|
1499
|
+
if (context) {
|
|
1500
|
+
// Cases like `for (;;) using x = ...;`, `if (true) await using x = ...;`, etc. are not allowed.
|
|
1501
|
+
this.raise(this.start, "Using declaration is not allowed in single-statement positions");
|
|
1502
|
+
}
|
|
1514
1503
|
if (usingKind === "await using") {
|
|
1515
1504
|
if (!this.canAwait) {
|
|
1516
1505
|
this.raise(this.start, "Await using cannot appear outside of async function");
|
|
@@ -1644,11 +1633,12 @@ pp$8.parseForStatement = function(node) {
|
|
|
1644
1633
|
// Helper method to parse for loop after variable initialization
|
|
1645
1634
|
pp$8.parseForAfterInit = function(node, init, awaitAt) {
|
|
1646
1635
|
if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) {
|
|
1647
|
-
if (this.
|
|
1648
|
-
if (
|
|
1649
|
-
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1636
|
+
if (this.type === types$1._in) {
|
|
1637
|
+
if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) {
|
|
1638
|
+
this.raise(this.start, "Using declaration is not allowed in for-in loops");
|
|
1639
|
+
}
|
|
1640
|
+
if (this.options.ecmaVersion >= 9 && awaitAt > -1) { this.unexpected(awaitAt); }
|
|
1641
|
+
} else if (this.options.ecmaVersion >= 9) { node.await = awaitAt > -1; }
|
|
1652
1642
|
return this.parseForIn(node, init)
|
|
1653
1643
|
}
|
|
1654
1644
|
if (awaitAt > -1) { this.unexpected(awaitAt); }
|
|
@@ -3155,15 +3145,19 @@ pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
|
|
|
3155
3145
|
// delayed syntax error at correct position).
|
|
3156
3146
|
|
|
3157
3147
|
pp$5.parseExpression = function(forInit, refDestructuringErrors) {
|
|
3158
|
-
var
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
var
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3148
|
+
var this$1$1 = this;
|
|
3149
|
+
|
|
3150
|
+
return this.catchStackOverflow(function () {
|
|
3151
|
+
var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
|
|
3152
|
+
var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
|
|
3153
|
+
if (this$1$1.type === types$1.comma) {
|
|
3154
|
+
var node = this$1$1.startNodeAt(startPos, startLoc);
|
|
3155
|
+
node.expressions = [expr];
|
|
3156
|
+
while (this$1$1.eat(types$1.comma)) { node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors)); }
|
|
3157
|
+
return this$1$1.finishNode(node, "SequenceExpression")
|
|
3158
|
+
}
|
|
3159
|
+
return expr
|
|
3160
|
+
})
|
|
3167
3161
|
};
|
|
3168
3162
|
|
|
3169
3163
|
// Parse an assignment expression. This includes applications of
|
|
@@ -3228,7 +3222,7 @@ pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
|
|
|
3228
3222
|
var startPos = this.start, startLoc = this.startLoc;
|
|
3229
3223
|
var expr = this.parseExprOps(forInit, refDestructuringErrors);
|
|
3230
3224
|
if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
|
|
3231
|
-
if (this.eat(types$1.question)) {
|
|
3225
|
+
if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
|
|
3232
3226
|
var node = this.startNodeAt(startPos, startLoc);
|
|
3233
3227
|
node.test = expr;
|
|
3234
3228
|
node.consequent = this.parseMaybeAssign();
|
|
@@ -3328,7 +3322,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
|
|
|
3328
3322
|
}
|
|
3329
3323
|
}
|
|
3330
3324
|
|
|
3331
|
-
if (!incDec && this.eat(types$1.starstar)) {
|
|
3325
|
+
if (!incDec && !(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.starstar)) {
|
|
3332
3326
|
if (sawUnary)
|
|
3333
3327
|
{ this.unexpected(this.lastTokStart); }
|
|
3334
3328
|
else
|
|
@@ -3780,6 +3774,8 @@ pp$5.parseNew = function() {
|
|
|
3780
3774
|
}
|
|
3781
3775
|
var startPos = this.start, startLoc = this.startLoc;
|
|
3782
3776
|
node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
|
|
3777
|
+
if (node.callee.type === "Super")
|
|
3778
|
+
{ this.raiseRecoverable(startPos, "Invalid use of 'super'"); }
|
|
3783
3779
|
if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
|
|
3784
3780
|
else { node.arguments = empty; }
|
|
3785
3781
|
return this.finishNode(node, "NewExpression")
|
|
@@ -6696,7 +6692,7 @@ pp.readWord = function() {
|
|
|
6696
6692
|
// [ghbt]: https://github.com/acornjs/acorn/issues
|
|
6697
6693
|
|
|
6698
6694
|
|
|
6699
|
-
var version = "8.
|
|
6695
|
+
var version = "8.18.0";
|
|
6700
6696
|
|
|
6701
6697
|
Parser.acorn = {
|
|
6702
6698
|
Parser: Parser,
|
|
@@ -9068,7 +9064,11 @@ function _extractExtraNames(extraNamesStr) {
|
|
|
9068
9064
|
angleDepth++;
|
|
9069
9065
|
continue;
|
|
9070
9066
|
}
|
|
9071
|
-
if (inTypeAnnotation && char === "
|
|
9067
|
+
if (!inTypeAnnotation && char === "<" && depth === 0 && i > 0 && _isIdentifierBeforeAngleBracket(extraNamesStr, i)) {
|
|
9068
|
+
angleDepth++;
|
|
9069
|
+
continue;
|
|
9070
|
+
}
|
|
9071
|
+
if (char === ">" && angleDepth > 0 && extraNamesStr[i - 1] !== "=") {
|
|
9072
9072
|
angleDepth--;
|
|
9073
9073
|
continue;
|
|
9074
9074
|
}
|
|
@@ -9233,6 +9233,14 @@ function _getLocations(code, label) {
|
|
|
9233
9233
|
}
|
|
9234
9234
|
return locations;
|
|
9235
9235
|
}
|
|
9236
|
+
function _isIdentifierBeforeAngleBracket(str, i) {
|
|
9237
|
+
let j = i - 1;
|
|
9238
|
+
while (j >= 0 && /[A-Za-z0-9_$]/.test(str[j])) {
|
|
9239
|
+
j--;
|
|
9240
|
+
}
|
|
9241
|
+
const wordStart = j + 1;
|
|
9242
|
+
return wordStart < i && /[A-Za-z_$]/.test(str[wordStart]);
|
|
9243
|
+
}
|
|
9236
9244
|
|
|
9237
9245
|
function defineUnimportPreset(preset) {
|
|
9238
9246
|
return preset;
|
|
@@ -9275,7 +9283,7 @@ async function extractExports(name, url, cache = true) {
|
|
|
9275
9283
|
return JSON.parse(await promises.readFile(cachePath, "utf-8"));
|
|
9276
9284
|
const scanned = await resolveModuleExportNames(name, { url });
|
|
9277
9285
|
if (useCache) {
|
|
9278
|
-
await promises.mkdir(dirname
|
|
9286
|
+
await promises.mkdir(dirname(cachePath), { recursive: true });
|
|
9279
9287
|
await promises.writeFile(cachePath, JSON.stringify(scanned), "utf-8");
|
|
9280
9288
|
}
|
|
9281
9289
|
return scanned;
|
|
@@ -10256,23 +10264,82 @@ function safeKey(key) {
|
|
|
10256
10264
|
return JSON.stringify(key);
|
|
10257
10265
|
}
|
|
10258
10266
|
|
|
10267
|
+
function getHomeDir() {
|
|
10268
|
+
return process.env.XDG_CONFIG_HOME || homedir();
|
|
10269
|
+
}
|
|
10270
|
+
async function readLocalOptions(defaults, options) {
|
|
10271
|
+
const { filePath } = getOptionsFilepath(options);
|
|
10272
|
+
if (existsSync(filePath)) {
|
|
10273
|
+
try {
|
|
10274
|
+
const options2 = {
|
|
10275
|
+
...defaults,
|
|
10276
|
+
...JSON.parse(await fs.readFile(filePath, "utf-8")).settings || {}
|
|
10277
|
+
};
|
|
10278
|
+
return options2;
|
|
10279
|
+
} catch (e) {
|
|
10280
|
+
console.error(`[DevTools] failed to parse local options file: ${filePath}, fallback to defaults`);
|
|
10281
|
+
console.error(e);
|
|
10282
|
+
return { ...defaults };
|
|
10283
|
+
}
|
|
10284
|
+
} else {
|
|
10285
|
+
return { ...defaults };
|
|
10286
|
+
}
|
|
10287
|
+
}
|
|
10288
|
+
function getOptionsFilepath(options) {
|
|
10289
|
+
let hashedKey;
|
|
10290
|
+
if (options.key)
|
|
10291
|
+
hashedKey = hash(`${options.root}:${options.key}`);
|
|
10292
|
+
else
|
|
10293
|
+
hashedKey = hash(options.root);
|
|
10294
|
+
const home = getHomeDir();
|
|
10295
|
+
const filePath = join(home, ".nuxt/devtools", `${hashedKey}.json`);
|
|
10296
|
+
return {
|
|
10297
|
+
filePath,
|
|
10298
|
+
hashedKey
|
|
10299
|
+
};
|
|
10300
|
+
}
|
|
10301
|
+
async function clearLocalOptions(options) {
|
|
10302
|
+
const { filePath } = getOptionsFilepath(options);
|
|
10303
|
+
if (existsSync(filePath))
|
|
10304
|
+
await fs.unlink(filePath);
|
|
10305
|
+
}
|
|
10306
|
+
async function writeLocalOptions(settings, options) {
|
|
10307
|
+
const { filePath, hashedKey } = getOptionsFilepath(options);
|
|
10308
|
+
await fs.mkdir(dirname$1(filePath), { recursive: true });
|
|
10309
|
+
await fs.writeFile(
|
|
10310
|
+
filePath,
|
|
10311
|
+
JSON.stringify(
|
|
10312
|
+
{
|
|
10313
|
+
root: options.root,
|
|
10314
|
+
hash: hashedKey,
|
|
10315
|
+
settings
|
|
10316
|
+
},
|
|
10317
|
+
null,
|
|
10318
|
+
2
|
|
10319
|
+
),
|
|
10320
|
+
"utf-8"
|
|
10321
|
+
);
|
|
10322
|
+
}
|
|
10323
|
+
|
|
10259
10324
|
let options;
|
|
10260
10325
|
function getOptions() {
|
|
10261
10326
|
return options;
|
|
10262
10327
|
}
|
|
10263
10328
|
function setupOptionsRPC({ nuxt }) {
|
|
10329
|
+
const hasReadOnce = /* @__PURE__ */ new Set();
|
|
10264
10330
|
async function getOptions2(tab) {
|
|
10265
|
-
if (!options
|
|
10266
|
-
options =
|
|
10331
|
+
if (!options)
|
|
10332
|
+
options = createDefaultTabOptions();
|
|
10333
|
+
if (!hasReadOnce.has(tab))
|
|
10267
10334
|
await read(tab);
|
|
10268
|
-
}
|
|
10269
10335
|
return options[tab];
|
|
10270
10336
|
}
|
|
10271
10337
|
async function read(tab) {
|
|
10272
|
-
options[tab] = await readLocalOptions(
|
|
10338
|
+
options[tab] = await readLocalOptions(createDefaultTabOptions()[tab], {
|
|
10273
10339
|
root: nuxt.options.rootDir,
|
|
10274
10340
|
key: tab !== "ui" && tab
|
|
10275
10341
|
});
|
|
10342
|
+
hasReadOnce.add(tab);
|
|
10276
10343
|
return options;
|
|
10277
10344
|
}
|
|
10278
10345
|
getOptions2("ui");
|
|
@@ -10306,13 +10373,11 @@ function setupOptionsRPC({ nuxt }) {
|
|
|
10306
10373
|
|
|
10307
10374
|
const ABSOLUTE_PATH_RE = /^[a-z]:|^\//i;
|
|
10308
10375
|
const FILE_LINE_COL_RE = /^(.*?)(:[:\d]*)$/;
|
|
10309
|
-
const MULTIPLE_SLASHES_RE$1 = /\/+/g;
|
|
10310
10376
|
const NUXT_WELCOME_RE = /<NuxtWelcome\s*\/>/;
|
|
10311
10377
|
function setupGeneralRPC({
|
|
10312
10378
|
nuxt,
|
|
10313
10379
|
options,
|
|
10314
10380
|
refresh,
|
|
10315
|
-
ensureDevAuthToken,
|
|
10316
10381
|
openInEditorHooks
|
|
10317
10382
|
}) {
|
|
10318
10383
|
const components = [];
|
|
@@ -10496,8 +10561,7 @@ function setupGeneralRPC({
|
|
|
10496
10561
|
return false;
|
|
10497
10562
|
}
|
|
10498
10563
|
},
|
|
10499
|
-
async enablePages(
|
|
10500
|
-
await ensureDevAuthToken(token);
|
|
10564
|
+
async enablePages() {
|
|
10501
10565
|
const baseDir = nuxt.options.future.compatibilityVersion === 4 ? nuxt.options.dir.app : nuxt.options.srcDir;
|
|
10502
10566
|
const pathApp = join(baseDir, "app.vue");
|
|
10503
10567
|
const pathPageIndex = join(baseDir, "pages/index.vue");
|
|
@@ -10517,7 +10581,7 @@ const route = useRoute()
|
|
|
10517
10581
|
</div>
|
|
10518
10582
|
</template>
|
|
10519
10583
|
`;
|
|
10520
|
-
await fs.mkdir(dirname
|
|
10584
|
+
await fs.mkdir(dirname(pathPageIndex), { recursive: true });
|
|
10521
10585
|
await fs.writeFile(pathPageIndex, pagesIndexTemplate, "utf-8");
|
|
10522
10586
|
let appContent = existsSync(pathApp) ? await fs.readFile(pathApp, "utf-8") : void 0;
|
|
10523
10587
|
if (appContent && !appContent.includes("<NuxtPage")) {
|
|
@@ -10526,40 +10590,63 @@ const route = useRoute()
|
|
|
10526
10590
|
}
|
|
10527
10591
|
logger.success("Routing creation completed");
|
|
10528
10592
|
},
|
|
10529
|
-
async restartNuxt(
|
|
10530
|
-
await ensureDevAuthToken(token);
|
|
10593
|
+
async restartNuxt(hard = true) {
|
|
10531
10594
|
logger.info("Restarting Nuxt...");
|
|
10532
10595
|
return nuxt.callHook("restart", { hard });
|
|
10533
10596
|
},
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
const token = await getDevAuthToken();
|
|
10538
|
-
origin ||= `${nuxt.options.devServer.https ? "https" : "http"}://${nuxt.options.devServer.host === "::" ? "localhost" : nuxt.options.devServer.host || "localhost"}:${nuxt.options.devServer.port}`;
|
|
10539
|
-
const ROUTE_AUTH = `${nuxt.options.app.baseURL || "/"}/__nuxt_devtools__/auth`.replace(MULTIPLE_SLASHES_RE$1, "/");
|
|
10540
|
-
const message = [
|
|
10541
|
-
`A browser is requesting permissions of ${colors.bold(colors.yellow("writing files and running commands"))} from the DevTools UI.`,
|
|
10542
|
-
colors.bold(info || "Unknown"),
|
|
10543
|
-
"",
|
|
10544
|
-
"Please open the following URL in the browser:",
|
|
10545
|
-
colors.bold(colors.green(`${origin}${ROUTE_AUTH}?token=${token}`)),
|
|
10546
|
-
"",
|
|
10547
|
-
"Or manually copy and paste the following token:",
|
|
10548
|
-
colors.bold(colors.cyan(token))
|
|
10549
|
-
];
|
|
10550
|
-
logger.box({
|
|
10551
|
-
message: message.join("\n"),
|
|
10552
|
-
title: colors.bold(colors.yellow(" Permission Request ")),
|
|
10553
|
-
style: {
|
|
10554
|
-
borderColor: "yellow",
|
|
10555
|
-
borderStyle: "rounded"
|
|
10556
|
-
}
|
|
10557
|
-
});
|
|
10597
|
+
/** @deprecated Auth is now handled by Vite DevTools */
|
|
10598
|
+
async requestForAuth() {
|
|
10599
|
+
logger.warn("[nuxt-devtools] `requestForAuth` is deprecated. Auth is now handled by Vite DevTools.");
|
|
10558
10600
|
},
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
return
|
|
10601
|
+
/** @deprecated Auth is now handled by Vite DevTools */
|
|
10602
|
+
async verifyAuthToken() {
|
|
10603
|
+
logger.warn("[nuxt-devtools] `verifyAuthToken` is deprecated. Auth is now handled by Vite DevTools.");
|
|
10604
|
+
return true;
|
|
10605
|
+
}
|
|
10606
|
+
};
|
|
10607
|
+
}
|
|
10608
|
+
|
|
10609
|
+
function toEntryInput(input) {
|
|
10610
|
+
return {
|
|
10611
|
+
message: input.message,
|
|
10612
|
+
level: input.level ?? "info",
|
|
10613
|
+
description: input.description,
|
|
10614
|
+
labels: input.labels,
|
|
10615
|
+
category: input.category,
|
|
10616
|
+
filePosition: input.filePosition,
|
|
10617
|
+
stacktrace: input.stacktrace,
|
|
10618
|
+
notify: input.notify,
|
|
10619
|
+
autoDismiss: input.autoDismiss,
|
|
10620
|
+
autoDelete: input.autoDelete
|
|
10621
|
+
};
|
|
10622
|
+
}
|
|
10623
|
+
function createNotifier(nuxt) {
|
|
10624
|
+
let messages;
|
|
10625
|
+
const pending = [];
|
|
10626
|
+
function add(input) {
|
|
10627
|
+
void messages.add(toEntryInput(input)).catch(() => {
|
|
10628
|
+
});
|
|
10629
|
+
}
|
|
10630
|
+
function notify(input) {
|
|
10631
|
+
if (!messages) {
|
|
10632
|
+
pending.push(input);
|
|
10633
|
+
return;
|
|
10634
|
+
}
|
|
10635
|
+
add(input);
|
|
10636
|
+
}
|
|
10637
|
+
onDevtoolsReady((kit) => {
|
|
10638
|
+
messages = kit.messages;
|
|
10639
|
+
for (const input of pending)
|
|
10640
|
+
add(input);
|
|
10641
|
+
pending.length = 0;
|
|
10642
|
+
}, nuxt);
|
|
10643
|
+
nuxt.hook("devtools:notify", notify);
|
|
10644
|
+
return notify;
|
|
10645
|
+
}
|
|
10646
|
+
function setupMessagesRPC(ctx) {
|
|
10647
|
+
return {
|
|
10648
|
+
async notify(input) {
|
|
10649
|
+
ctx.notify(input);
|
|
10563
10650
|
}
|
|
10564
10651
|
};
|
|
10565
10652
|
}
|
|
@@ -10570,13 +10657,19 @@ const AGENTS = [
|
|
|
10570
10657
|
"yarn@berry",
|
|
10571
10658
|
"pnpm",
|
|
10572
10659
|
"pnpm@6",
|
|
10660
|
+
"pnpm-rush",
|
|
10573
10661
|
"bun",
|
|
10574
|
-
"deno"
|
|
10662
|
+
"deno",
|
|
10663
|
+
"nub",
|
|
10664
|
+
"aube"
|
|
10575
10665
|
];
|
|
10576
10666
|
const LOCKS = {
|
|
10667
|
+
"aube-lock.yaml": "aube",
|
|
10668
|
+
"aube-workspace.yaml": "aube",
|
|
10577
10669
|
"bun.lock": "bun",
|
|
10578
10670
|
"bun.lockb": "bun",
|
|
10579
10671
|
"deno.lock": "deno",
|
|
10672
|
+
"nub.lock": "nub",
|
|
10580
10673
|
"pnpm-lock.yaml": "pnpm",
|
|
10581
10674
|
"pnpm-workspace.yaml": "pnpm",
|
|
10582
10675
|
"yarn.lock": "yarn",
|
|
@@ -10584,6 +10677,7 @@ const LOCKS = {
|
|
|
10584
10677
|
"npm-shrinkwrap.json": "npm"
|
|
10585
10678
|
};
|
|
10586
10679
|
const INSTALL_METADATA = {
|
|
10680
|
+
"node_modules/.aube/": "aube",
|
|
10587
10681
|
"node_modules/.deno/": "deno",
|
|
10588
10682
|
"node_modules/.pnpm/": "pnpm",
|
|
10589
10683
|
"node_modules/.yarn-state.yml": "yarn",
|
|
@@ -10636,6 +10730,9 @@ async function detect(options = {}) {
|
|
|
10636
10730
|
for (const strategy of strategies) {
|
|
10637
10731
|
switch (strategy) {
|
|
10638
10732
|
case "lockfile": {
|
|
10733
|
+
if (await pathExists(path.join(directory, "rush.json"), "file")) {
|
|
10734
|
+
return { name: "pnpm", agent: "pnpm-rush" };
|
|
10735
|
+
}
|
|
10639
10736
|
for (const lock of Object.keys(LOCKS)) {
|
|
10640
10737
|
if (await pathExists(path.join(directory, lock), "file")) {
|
|
10641
10738
|
const name = LOCKS[lock];
|
|
@@ -11103,7 +11200,7 @@ async function checkForUpdateOf(name, current, nuxt = useNuxt()) {
|
|
|
11103
11200
|
const { version: latest } = await getLatestVersion(name, {
|
|
11104
11201
|
fetch
|
|
11105
11202
|
});
|
|
11106
|
-
const needsUpdate = !!latest && latest !== current &&
|
|
11203
|
+
const needsUpdate = !!latest && latest !== current && isLess(current, latest);
|
|
11107
11204
|
return {
|
|
11108
11205
|
name,
|
|
11109
11206
|
current,
|
|
@@ -11127,7 +11224,179 @@ async function magicastGuard(fn, message = "") {
|
|
|
11127
11224
|
return generated;
|
|
11128
11225
|
}
|
|
11129
11226
|
|
|
11130
|
-
function
|
|
11227
|
+
function removeNuxtModuleFromCode(source, name, filepath) {
|
|
11228
|
+
const mod = parseModule(source, filepath ? { sourceFileName: filepath } : void 0);
|
|
11229
|
+
const config = getDefaultExportOptions(mod);
|
|
11230
|
+
if (!Array.isArray(config.modules))
|
|
11231
|
+
return mod.generate().code;
|
|
11232
|
+
for (let i = config.modules.length - 1; i >= 0; i--) {
|
|
11233
|
+
const entry = config.modules[i];
|
|
11234
|
+
const matches = typeof entry === "string" ? entry === name : Array.isArray(entry) && entry[0] === name;
|
|
11235
|
+
if (matches)
|
|
11236
|
+
config.modules.splice(i, 1);
|
|
11237
|
+
}
|
|
11238
|
+
return mod.generate().code;
|
|
11239
|
+
}
|
|
11240
|
+
|
|
11241
|
+
function broadcastTerminalExit(ctx, id, code) {
|
|
11242
|
+
ctx.devtoolsKit?.rpc.broadcast({ method: "onTerminalExit", args: [{ id, code }], event: true });
|
|
11243
|
+
}
|
|
11244
|
+
function statusForExit(code) {
|
|
11245
|
+
return code == null || code === 0 ? "stopped" : "error";
|
|
11246
|
+
}
|
|
11247
|
+
function setupTerminalsBridge(ctx) {
|
|
11248
|
+
const { nuxt } = ctx;
|
|
11249
|
+
const runs = /* @__PURE__ */ new Map();
|
|
11250
|
+
const generations = /* @__PURE__ */ new Map();
|
|
11251
|
+
let host;
|
|
11252
|
+
function createRun(terminal) {
|
|
11253
|
+
const legacyId = terminal.id;
|
|
11254
|
+
const generation = (generations.get(legacyId) ?? 0) + 1;
|
|
11255
|
+
generations.set(legacyId, generation);
|
|
11256
|
+
let controller;
|
|
11257
|
+
const stream = new ReadableStream({
|
|
11258
|
+
start(c) {
|
|
11259
|
+
controller = c;
|
|
11260
|
+
}
|
|
11261
|
+
});
|
|
11262
|
+
const session = {
|
|
11263
|
+
id: createUniqueSessionId(legacyId),
|
|
11264
|
+
title: terminal.name,
|
|
11265
|
+
description: terminal.description,
|
|
11266
|
+
icon: terminal.icon,
|
|
11267
|
+
status: "running",
|
|
11268
|
+
interactive: false,
|
|
11269
|
+
stream
|
|
11270
|
+
};
|
|
11271
|
+
return {
|
|
11272
|
+
legacyId,
|
|
11273
|
+
sessionId: session.id,
|
|
11274
|
+
generation,
|
|
11275
|
+
session,
|
|
11276
|
+
controller,
|
|
11277
|
+
registered: false,
|
|
11278
|
+
streamClosed: false,
|
|
11279
|
+
pendingChunks: []
|
|
11280
|
+
};
|
|
11281
|
+
}
|
|
11282
|
+
function isCurrent(run) {
|
|
11283
|
+
return runs.get(run.legacyId) === run;
|
|
11284
|
+
}
|
|
11285
|
+
function closeStream(run) {
|
|
11286
|
+
if (run.streamClosed)
|
|
11287
|
+
return;
|
|
11288
|
+
run.streamClosed = true;
|
|
11289
|
+
try {
|
|
11290
|
+
run.controller?.close();
|
|
11291
|
+
} catch {
|
|
11292
|
+
}
|
|
11293
|
+
}
|
|
11294
|
+
function applyExit(run, code) {
|
|
11295
|
+
if (!isCurrent(run) || run.streamClosed)
|
|
11296
|
+
return;
|
|
11297
|
+
closeStream(run);
|
|
11298
|
+
run.session.status = statusForExit(code);
|
|
11299
|
+
host?.update(run.session);
|
|
11300
|
+
}
|
|
11301
|
+
function registerWithHost(run) {
|
|
11302
|
+
if (!host || run.registered || !isCurrent(run))
|
|
11303
|
+
return;
|
|
11304
|
+
host.register(run.session);
|
|
11305
|
+
run.registered = true;
|
|
11306
|
+
for (const chunk of run.pendingChunks) {
|
|
11307
|
+
try {
|
|
11308
|
+
run.controller?.enqueue(chunk);
|
|
11309
|
+
} catch {
|
|
11310
|
+
}
|
|
11311
|
+
}
|
|
11312
|
+
run.pendingChunks.length = 0;
|
|
11313
|
+
if (run.pendingExit) {
|
|
11314
|
+
const { code } = run.pendingExit;
|
|
11315
|
+
run.pendingExit = void 0;
|
|
11316
|
+
applyExit(run, code);
|
|
11317
|
+
}
|
|
11318
|
+
}
|
|
11319
|
+
nuxt.hook("devtools:terminal:register", (terminal) => {
|
|
11320
|
+
const existing = runs.get(terminal.id);
|
|
11321
|
+
if (existing) {
|
|
11322
|
+
closeStream(existing);
|
|
11323
|
+
if (host && existing.registered)
|
|
11324
|
+
host.remove(existing.session);
|
|
11325
|
+
}
|
|
11326
|
+
const run = createRun(terminal);
|
|
11327
|
+
runs.set(terminal.id, run);
|
|
11328
|
+
if (host)
|
|
11329
|
+
registerWithHost(run);
|
|
11330
|
+
return terminal.id;
|
|
11331
|
+
});
|
|
11332
|
+
nuxt.hook("devtools:terminal:write", ({ id, data }) => {
|
|
11333
|
+
const run = runs.get(id);
|
|
11334
|
+
if (!run || run.streamClosed)
|
|
11335
|
+
return false;
|
|
11336
|
+
if (run.registered) {
|
|
11337
|
+
try {
|
|
11338
|
+
run.controller?.enqueue(data);
|
|
11339
|
+
} catch {
|
|
11340
|
+
}
|
|
11341
|
+
} else {
|
|
11342
|
+
run.pendingChunks.push(data);
|
|
11343
|
+
}
|
|
11344
|
+
return true;
|
|
11345
|
+
});
|
|
11346
|
+
nuxt.hook("devtools:terminal:exit", ({ id, code }) => {
|
|
11347
|
+
const run = runs.get(id);
|
|
11348
|
+
if (!run)
|
|
11349
|
+
return false;
|
|
11350
|
+
if (run.registered)
|
|
11351
|
+
applyExit(run, code);
|
|
11352
|
+
else
|
|
11353
|
+
run.pendingExit = { code };
|
|
11354
|
+
return true;
|
|
11355
|
+
});
|
|
11356
|
+
nuxt.hook("devtools:terminal:remove", ({ id }) => {
|
|
11357
|
+
const run = runs.get(id);
|
|
11358
|
+
if (!run)
|
|
11359
|
+
return false;
|
|
11360
|
+
closeStream(run);
|
|
11361
|
+
runs.delete(id);
|
|
11362
|
+
if (host && run.registered)
|
|
11363
|
+
host.remove(run.session);
|
|
11364
|
+
return true;
|
|
11365
|
+
});
|
|
11366
|
+
nuxt.hook("devtools:ready", (kit) => {
|
|
11367
|
+
host = kit.terminals;
|
|
11368
|
+
for (const run of runs.values())
|
|
11369
|
+
registerWithHost(run);
|
|
11370
|
+
});
|
|
11371
|
+
return {
|
|
11372
|
+
/**
|
|
11373
|
+
* Focus the built-in **Terminals** dock on a session (Devframe 0.7
|
|
11374
|
+
* `docks.activate`, driven by the `hub:docks:activate` RPC). Replaces the
|
|
11375
|
+
* old in-client "go to Terminals tab" navigation now that terminals live in
|
|
11376
|
+
* the hub dock. `id` is a unique Devframe session id (from a bridged run or
|
|
11377
|
+
* a `startChildProcess` call). Returns `false` when the kit isn't connected
|
|
11378
|
+
* or the session is unknown.
|
|
11379
|
+
*/
|
|
11380
|
+
async revealTerminal(id) {
|
|
11381
|
+
const kit = ctx.devtoolsKit;
|
|
11382
|
+
if (!kit)
|
|
11383
|
+
return false;
|
|
11384
|
+
if (!kit.terminals.sessions.has(id))
|
|
11385
|
+
return false;
|
|
11386
|
+
kit.docks.activate(DEVTOOLS_TERMINALS_DOCK_ID, { sessionId: id });
|
|
11387
|
+
return true;
|
|
11388
|
+
}
|
|
11389
|
+
};
|
|
11390
|
+
}
|
|
11391
|
+
|
|
11392
|
+
function setupNpmRPC(ctx) {
|
|
11393
|
+
const { nuxt } = ctx;
|
|
11394
|
+
function getTerminals() {
|
|
11395
|
+
const kit = ctx.devtoolsKit;
|
|
11396
|
+
if (!kit)
|
|
11397
|
+
throw new Error("[Nuxt DevTools] Vite DevTools kit is not connected yet.");
|
|
11398
|
+
return kit.terminals;
|
|
11399
|
+
}
|
|
11131
11400
|
let detectPromise;
|
|
11132
11401
|
const updatesPromise = /* @__PURE__ */ new Map();
|
|
11133
11402
|
function getPackageManager() {
|
|
@@ -11162,15 +11431,18 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11162
11431
|
const args = await getNpmCommand(command, packageName, options);
|
|
11163
11432
|
if (!args)
|
|
11164
11433
|
return;
|
|
11165
|
-
const processId = `npm:${command}:${packageName}
|
|
11166
|
-
|
|
11434
|
+
const processId = createUniqueSessionId(`npm:${command}:${packageName}`);
|
|
11435
|
+
const session = await getTerminals().startChildProcess({
|
|
11167
11436
|
command: args[0],
|
|
11168
11437
|
args: args.slice(1)
|
|
11169
11438
|
}, {
|
|
11170
11439
|
id: processId,
|
|
11171
|
-
|
|
11172
|
-
icon: "i-logos-npm-icon"
|
|
11173
|
-
|
|
11440
|
+
title: `${command} ${packageName}`,
|
|
11441
|
+
icon: "i-logos-npm-icon"
|
|
11442
|
+
});
|
|
11443
|
+
void Promise.resolve(session.getResult()).then((result) => {
|
|
11444
|
+
broadcastTerminalExit(ctx, processId, result.exitCode);
|
|
11445
|
+
}).catch(() => {
|
|
11174
11446
|
});
|
|
11175
11447
|
return {
|
|
11176
11448
|
processId
|
|
@@ -11185,12 +11457,10 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11185
11457
|
return updatesPromise.get(name);
|
|
11186
11458
|
},
|
|
11187
11459
|
getNpmCommand,
|
|
11188
|
-
async runNpmCommand(
|
|
11189
|
-
await ensureDevAuthToken(token);
|
|
11460
|
+
async runNpmCommand(...args) {
|
|
11190
11461
|
return runNpmCommand(...args);
|
|
11191
11462
|
},
|
|
11192
|
-
async installNuxtModule(
|
|
11193
|
-
await ensureDevAuthToken(token);
|
|
11463
|
+
async installNuxtModule(name, dry = true, sessionId) {
|
|
11194
11464
|
const commands = await getNpmCommand("install", name, { dev: true });
|
|
11195
11465
|
const filepath = nuxt.options._nuxtConfigFile;
|
|
11196
11466
|
let source = latestGenerated;
|
|
@@ -11200,27 +11470,39 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11200
11470
|
addNuxtModule(mod, name);
|
|
11201
11471
|
return mod.generate().code;
|
|
11202
11472
|
});
|
|
11203
|
-
const processId = `nuxt:add-module:${name}
|
|
11473
|
+
const processId = sessionId ?? createUniqueSessionId(`nuxt:add-module:${name}`);
|
|
11204
11474
|
if (!dry) {
|
|
11205
11475
|
latestGenerated = generated;
|
|
11206
11476
|
installSet.add(name);
|
|
11207
|
-
const
|
|
11477
|
+
const session = await getTerminals().startChildProcess({
|
|
11208
11478
|
command: commands[0],
|
|
11209
11479
|
args: commands.slice(1)
|
|
11210
11480
|
}, {
|
|
11211
11481
|
id: processId,
|
|
11212
|
-
|
|
11213
|
-
icon: "carbon:intent-request-create"
|
|
11214
|
-
restartable: false
|
|
11482
|
+
title: `Install ${name}`,
|
|
11483
|
+
icon: "carbon:intent-request-create"
|
|
11215
11484
|
});
|
|
11216
|
-
const result = await
|
|
11485
|
+
const result = await session.getResult();
|
|
11217
11486
|
await Promise.resolve();
|
|
11218
11487
|
installSet.delete(name);
|
|
11219
11488
|
const code = result.exitCode;
|
|
11220
11489
|
if (code !== 0) {
|
|
11221
11490
|
console.error(result.stderr);
|
|
11491
|
+
ctx.notify({
|
|
11492
|
+
message: `Failed to install ${name}`,
|
|
11493
|
+
level: "error",
|
|
11494
|
+
description: `Process exited with code ${code}. Check the Install ${name} terminal for details.`,
|
|
11495
|
+
category: "module",
|
|
11496
|
+
notify: true
|
|
11497
|
+
});
|
|
11222
11498
|
throw new Error(`[Nuxt DevTools] Failed to install module, process exited with ${code}`);
|
|
11223
11499
|
}
|
|
11500
|
+
ctx.notify({
|
|
11501
|
+
message: `Installed ${name}`,
|
|
11502
|
+
level: "success",
|
|
11503
|
+
category: "module",
|
|
11504
|
+
notify: true
|
|
11505
|
+
});
|
|
11224
11506
|
if (installSet.size === 0) {
|
|
11225
11507
|
latestGenerated = null;
|
|
11226
11508
|
await fs.writeFile(filepath, generated, "utf-8");
|
|
@@ -11233,41 +11515,43 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11233
11515
|
processId
|
|
11234
11516
|
};
|
|
11235
11517
|
},
|
|
11236
|
-
async uninstallNuxtModule(
|
|
11237
|
-
await ensureDevAuthToken(token);
|
|
11518
|
+
async uninstallNuxtModule(name, dry = true, sessionId) {
|
|
11238
11519
|
const commands = await getNpmCommand("uninstall", name);
|
|
11239
11520
|
const filepath = nuxt.options._nuxtConfigFile;
|
|
11240
11521
|
const source = await fs.readFile(filepath, "utf-8");
|
|
11241
11522
|
const generated = await magicastGuard(async () => {
|
|
11242
|
-
|
|
11243
|
-
const config = getDefaultExportOptions(mod);
|
|
11244
|
-
config.modules ||= [];
|
|
11245
|
-
if (config.modules.includes(name)) {
|
|
11246
|
-
Object.values(config.modules).forEach((value, index) => {
|
|
11247
|
-
if (value === name)
|
|
11248
|
-
config.modules.splice(index - 1, 1);
|
|
11249
|
-
});
|
|
11250
|
-
}
|
|
11251
|
-
return mod.generate().code;
|
|
11523
|
+
return removeNuxtModuleFromCode(source, name, filepath);
|
|
11252
11524
|
});
|
|
11253
|
-
const processId = `nuxt:remove-module:${name}
|
|
11525
|
+
const processId = sessionId ?? createUniqueSessionId(`nuxt:remove-module:${name}`);
|
|
11254
11526
|
if (!dry) {
|
|
11255
|
-
const
|
|
11527
|
+
const session = await getTerminals().startChildProcess({
|
|
11256
11528
|
command: commands[0],
|
|
11257
11529
|
args: commands.slice(1)
|
|
11258
11530
|
}, {
|
|
11259
11531
|
id: processId,
|
|
11260
|
-
|
|
11261
|
-
icon: "carbon:intent-request-uninstall"
|
|
11262
|
-
restartable: false
|
|
11532
|
+
title: `Uninstall ${name}`,
|
|
11533
|
+
icon: "carbon:intent-request-uninstall"
|
|
11263
11534
|
});
|
|
11264
|
-
const result = await
|
|
11535
|
+
const result = await session.getResult();
|
|
11265
11536
|
await Promise.resolve();
|
|
11266
11537
|
const code = result.exitCode;
|
|
11267
11538
|
if (code !== 0) {
|
|
11268
11539
|
console.error(result.stderr);
|
|
11540
|
+
ctx.notify({
|
|
11541
|
+
message: `Failed to uninstall ${name}`,
|
|
11542
|
+
level: "error",
|
|
11543
|
+
description: `Process exited with code ${code}. Check the Uninstall ${name} terminal for details.`,
|
|
11544
|
+
category: "module",
|
|
11545
|
+
notify: true
|
|
11546
|
+
});
|
|
11269
11547
|
throw new Error(`[Nuxt DevTools] Failed to uninstall module, process exited with ${code}`);
|
|
11270
11548
|
}
|
|
11549
|
+
ctx.notify({
|
|
11550
|
+
message: `Uninstalled ${name}`,
|
|
11551
|
+
level: "success",
|
|
11552
|
+
category: "module",
|
|
11553
|
+
notify: true
|
|
11554
|
+
});
|
|
11271
11555
|
await fs.writeFile(filepath, generated, "utf-8");
|
|
11272
11556
|
}
|
|
11273
11557
|
return {
|
|
@@ -11280,112 +11564,24 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
|
|
|
11280
11564
|
};
|
|
11281
11565
|
}
|
|
11282
11566
|
|
|
11283
|
-
function setupServerDataRPC({
|
|
11284
|
-
nuxt,
|
|
11285
|
-
ensureDevAuthToken
|
|
11286
|
-
}) {
|
|
11287
|
-
let nitro;
|
|
11288
|
-
let viteServer;
|
|
11289
|
-
let viteClient;
|
|
11290
|
-
function normalizeViteConfig(config) {
|
|
11291
|
-
return {
|
|
11292
|
-
...config,
|
|
11293
|
-
environments: Object.fromEntries(
|
|
11294
|
-
Object.entries(config.env).map(([key, _]) => {
|
|
11295
|
-
return [key, null];
|
|
11296
|
-
})
|
|
11297
|
-
),
|
|
11298
|
-
plugins: config.plugins.map((i) => {
|
|
11299
|
-
const clone = { ...i };
|
|
11300
|
-
delete clone.api;
|
|
11301
|
-
return clone;
|
|
11302
|
-
}),
|
|
11303
|
-
inlineConfig: null
|
|
11304
|
-
};
|
|
11305
|
-
}
|
|
11306
|
-
nuxt.hook("nitro:build:before", (_nitro) => {
|
|
11307
|
-
nitro = _nitro;
|
|
11308
|
-
});
|
|
11309
|
-
addVitePlugin({
|
|
11310
|
-
name: "nuxt:devtools:config",
|
|
11311
|
-
applyToEnvironment(environment) {
|
|
11312
|
-
if (environment.name === "ssr") {
|
|
11313
|
-
return {
|
|
11314
|
-
name: "nuxt:devtools:config-retriever",
|
|
11315
|
-
enforce: "post",
|
|
11316
|
-
configResolved(config) {
|
|
11317
|
-
viteServer = normalizeViteConfig(config);
|
|
11318
|
-
}
|
|
11319
|
-
};
|
|
11320
|
-
}
|
|
11321
|
-
if (environment.name === "client") {
|
|
11322
|
-
return {
|
|
11323
|
-
name: "nuxt:devtools:config-retriever",
|
|
11324
|
-
enforce: "post",
|
|
11325
|
-
configResolved(config) {
|
|
11326
|
-
viteClient = normalizeViteConfig(config);
|
|
11327
|
-
}
|
|
11328
|
-
};
|
|
11329
|
-
}
|
|
11330
|
-
}
|
|
11331
|
-
});
|
|
11332
|
-
return {
|
|
11333
|
-
getServerConfig() {
|
|
11334
|
-
return nuxt.options;
|
|
11335
|
-
},
|
|
11336
|
-
async getServerData(token) {
|
|
11337
|
-
await ensureDevAuthToken(token);
|
|
11338
|
-
return {
|
|
11339
|
-
nuxt: nuxt.options,
|
|
11340
|
-
nitro: nitro?.options,
|
|
11341
|
-
vite: {
|
|
11342
|
-
server: viteServer,
|
|
11343
|
-
client: viteClient
|
|
11344
|
-
}
|
|
11345
|
-
};
|
|
11346
|
-
}
|
|
11347
|
-
};
|
|
11348
|
-
}
|
|
11349
|
-
|
|
11350
|
-
async function watchStorageMount(storage, mountName, onChange) {
|
|
11351
|
-
const mountKey = normalizeBaseKey(mountName);
|
|
11352
|
-
const mount = storage.getMount(mountKey);
|
|
11353
|
-
if (!mount || normalizeBaseKey(mount.base) !== mountKey || !mount.driver?.watch)
|
|
11354
|
-
return () => {
|
|
11355
|
-
};
|
|
11356
|
-
const unwatch = await mount.driver.watch((event, key) => {
|
|
11357
|
-
const fullKey = key.startsWith(mountKey) ? key : `${mountKey}${key}`;
|
|
11358
|
-
onChange(event, normalizeKey(fullKey));
|
|
11359
|
-
});
|
|
11360
|
-
return unwatch ?? (() => {
|
|
11361
|
-
});
|
|
11362
|
-
}
|
|
11363
|
-
|
|
11364
11567
|
function setupServerRoutesRPC({ nuxt, refresh }) {
|
|
11365
11568
|
let nitro;
|
|
11366
|
-
let
|
|
11569
|
+
let unhookDevReload;
|
|
11367
11570
|
let cache = null;
|
|
11368
11571
|
const refreshDebounced = debounce(() => {
|
|
11369
11572
|
cache = null;
|
|
11370
11573
|
refresh("getServerRoutes");
|
|
11371
11574
|
}, 500);
|
|
11372
|
-
nuxt.hook("nitro:init", (
|
|
11373
|
-
nitro =
|
|
11575
|
+
nuxt.hook("nitro:init", (_nitro) => {
|
|
11576
|
+
nitro = _nitro;
|
|
11374
11577
|
cache = null;
|
|
11375
11578
|
refresh("getServerRoutes");
|
|
11579
|
+
unhookDevReload?.();
|
|
11580
|
+
unhookDevReload = _nitro.hooks.hook("dev:reload", () => refreshDebounced());
|
|
11376
11581
|
});
|
|
11377
|
-
nuxt.hook("
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
await unwatchStorage?.();
|
|
11381
|
-
unwatchStorage = await watchStorageMount(nitro.storage, "src", (_event, key) => {
|
|
11382
|
-
if (key.startsWith("src:api:") || key.startsWith("src:routes:"))
|
|
11383
|
-
refreshDebounced();
|
|
11384
|
-
});
|
|
11385
|
-
});
|
|
11386
|
-
nuxt.hook("close", async () => {
|
|
11387
|
-
await unwatchStorage?.();
|
|
11388
|
-
unwatchStorage = void 0;
|
|
11582
|
+
nuxt.hook("close", () => {
|
|
11583
|
+
unhookDevReload?.();
|
|
11584
|
+
unhookDevReload = void 0;
|
|
11389
11585
|
});
|
|
11390
11586
|
function scan() {
|
|
11391
11587
|
if (cache)
|
|
@@ -11419,29 +11615,22 @@ function setupServerRoutesRPC({ nuxt, refresh }) {
|
|
|
11419
11615
|
|
|
11420
11616
|
function setupServerTasksRPC({ nuxt, refresh }) {
|
|
11421
11617
|
let nitro;
|
|
11422
|
-
let
|
|
11618
|
+
let unhookDevReload;
|
|
11423
11619
|
let cache = null;
|
|
11424
11620
|
const refreshDebounced = debounce(() => {
|
|
11425
11621
|
cache = null;
|
|
11426
11622
|
refresh("getServerTasks");
|
|
11427
11623
|
}, 500);
|
|
11428
|
-
nuxt.hook("nitro:init", (
|
|
11429
|
-
nitro =
|
|
11624
|
+
nuxt.hook("nitro:init", (_nitro) => {
|
|
11625
|
+
nitro = _nitro;
|
|
11430
11626
|
cache = null;
|
|
11431
11627
|
refresh("getServerTasks");
|
|
11628
|
+
unhookDevReload?.();
|
|
11629
|
+
unhookDevReload = _nitro.hooks.hook("dev:reload", () => refreshDebounced());
|
|
11432
11630
|
});
|
|
11433
|
-
nuxt.hook("
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
await unwatchStorage?.();
|
|
11437
|
-
unwatchStorage = await watchStorageMount(nitro.storage, "src", (_event, key) => {
|
|
11438
|
-
if (key.startsWith("src:tasks:"))
|
|
11439
|
-
refreshDebounced();
|
|
11440
|
-
});
|
|
11441
|
-
});
|
|
11442
|
-
nuxt.hook("close", async () => {
|
|
11443
|
-
await unwatchStorage?.();
|
|
11444
|
-
unwatchStorage = void 0;
|
|
11631
|
+
nuxt.hook("close", () => {
|
|
11632
|
+
unhookDevReload?.();
|
|
11633
|
+
unhookDevReload = void 0;
|
|
11445
11634
|
});
|
|
11446
11635
|
function scan() {
|
|
11447
11636
|
if (cache)
|
|
@@ -11454,7 +11643,15 @@ function setupServerTasksRPC({ nuxt, refresh }) {
|
|
|
11454
11643
|
};
|
|
11455
11644
|
}
|
|
11456
11645
|
return {
|
|
11457
|
-
|
|
11646
|
+
// Nitro v3's task config types `handler`/`description` as optional
|
|
11647
|
+
// (they're always populated in practice by Nitro's own task scanner),
|
|
11648
|
+
// so normalize with fallbacks to satisfy `ScannedNitroTasks`.
|
|
11649
|
+
tasks: Object.fromEntries(
|
|
11650
|
+
Object.entries(nitro.options.tasks ?? {}).map(([name, task]) => [
|
|
11651
|
+
name,
|
|
11652
|
+
{ handler: task.handler ?? "", description: task.description ?? "" }
|
|
11653
|
+
])
|
|
11654
|
+
),
|
|
11458
11655
|
scheduledTasks: Object.entries(nitro.options.scheduledTasks ?? {}).reduce((acc, [cron, tasks]) => {
|
|
11459
11656
|
acc[cron] = Array.isArray(tasks) ? tasks : [tasks];
|
|
11460
11657
|
return acc;
|
|
@@ -11470,24 +11667,53 @@ function setupServerTasksRPC({ nuxt, refresh }) {
|
|
|
11470
11667
|
};
|
|
11471
11668
|
}
|
|
11472
11669
|
|
|
11670
|
+
function skipInSSR(ctx) {
|
|
11671
|
+
return Boolean(ctx?.viteConfig?.build?.ssr);
|
|
11672
|
+
}
|
|
11673
|
+
|
|
11674
|
+
async function watchStorageMount(storage, mountName, onChange) {
|
|
11675
|
+
const mountKey = normalizeBaseKey(mountName);
|
|
11676
|
+
const mount = storage.getMount(mountKey);
|
|
11677
|
+
if (!mount || normalizeBaseKey(mount.base) !== mountKey || !mount.driver?.watch)
|
|
11678
|
+
return () => {
|
|
11679
|
+
};
|
|
11680
|
+
const unwatch = await mount.driver.watch((event, key) => {
|
|
11681
|
+
const fullKey = key.startsWith(mountKey) ? key : `${mountKey}${key}`;
|
|
11682
|
+
onChange(event, normalizeKey(fullKey));
|
|
11683
|
+
});
|
|
11684
|
+
return unwatch ?? (() => {
|
|
11685
|
+
});
|
|
11686
|
+
}
|
|
11687
|
+
|
|
11473
11688
|
const IGNORE_STORAGE_MOUNTS = ["root", "build", "src", "cache"];
|
|
11474
11689
|
function shouldIgnoreStorageKey(key) {
|
|
11475
11690
|
return IGNORE_STORAGE_MOUNTS.includes(key.split(":")[0]);
|
|
11476
11691
|
}
|
|
11477
|
-
function setupStorageRPC({
|
|
11478
|
-
nuxt
|
|
11479
|
-
rpc,
|
|
11480
|
-
ensureDevAuthToken
|
|
11481
|
-
}) {
|
|
11692
|
+
function setupStorageRPC(ctx) {
|
|
11693
|
+
const { nuxt } = ctx;
|
|
11482
11694
|
const storageMounts = {};
|
|
11483
11695
|
let storage;
|
|
11484
11696
|
let unwatchStorageMounts = [];
|
|
11485
|
-
nuxt.hook("nitro:init", (nitro) => {
|
|
11486
|
-
storage = nitro.storage;
|
|
11697
|
+
nuxt.hook("nitro:init", async (nitro) => {
|
|
11487
11698
|
const mounts = {
|
|
11488
11699
|
...nitro.options.storage,
|
|
11489
11700
|
...nitro.options.devStorage
|
|
11490
11701
|
};
|
|
11702
|
+
const nextStorage = createStorage();
|
|
11703
|
+
for (const [path, opts] of Object.entries(mounts)) {
|
|
11704
|
+
if (!opts?.driver) {
|
|
11705
|
+
nitro.logger.warn(`No \`driver\` set for storage mount point "${path}".`);
|
|
11706
|
+
continue;
|
|
11707
|
+
}
|
|
11708
|
+
try {
|
|
11709
|
+
const driverImport = builtinDrivers[opts.driver] || opts.driver;
|
|
11710
|
+
const driverFactory = await import(driverImport).then((r) => r.default || r);
|
|
11711
|
+
nextStorage.mount(path, driverFactory(opts));
|
|
11712
|
+
} catch (err) {
|
|
11713
|
+
nitro.logger.warn(`Failed to mount storage driver "${opts.driver}" for the DevTools storage browser:`, err);
|
|
11714
|
+
}
|
|
11715
|
+
}
|
|
11716
|
+
storage = nextStorage;
|
|
11491
11717
|
for (const key of Object.keys(storageMounts))
|
|
11492
11718
|
delete storageMounts[key];
|
|
11493
11719
|
for (const name of Object.keys(mounts)) {
|
|
@@ -11502,7 +11728,7 @@ function setupStorageRPC({
|
|
|
11502
11728
|
return;
|
|
11503
11729
|
await Promise.all(unwatchStorageMounts.map((unwatch) => unwatch()));
|
|
11504
11730
|
unwatchStorageMounts = await Promise.all(Object.keys(storageMounts).map((mountName) => watchStorageMount(activeStorage, mountName, (event, key) => {
|
|
11505
|
-
rpc.broadcast
|
|
11731
|
+
ctx.devtoolsKit?.rpc.broadcast({ method: "callHook", args: ["storage:key:update", key, event], event: true });
|
|
11506
11732
|
})));
|
|
11507
11733
|
});
|
|
11508
11734
|
nuxt.hook("close", async () => {
|
|
@@ -11524,20 +11750,17 @@ function setupStorageRPC({
|
|
|
11524
11750
|
return [];
|
|
11525
11751
|
}
|
|
11526
11752
|
},
|
|
11527
|
-
async getStorageItem(
|
|
11528
|
-
await ensureDevAuthToken(token);
|
|
11753
|
+
async getStorageItem(key) {
|
|
11529
11754
|
if (!storage)
|
|
11530
11755
|
return null;
|
|
11531
11756
|
return await storage.getItem(key);
|
|
11532
11757
|
},
|
|
11533
|
-
async setStorageItem(
|
|
11534
|
-
await ensureDevAuthToken(token);
|
|
11758
|
+
async setStorageItem(key, value) {
|
|
11535
11759
|
if (!storage)
|
|
11536
11760
|
return;
|
|
11537
11761
|
return await storage.setItem(key, value);
|
|
11538
11762
|
},
|
|
11539
|
-
async removeStorageItem(
|
|
11540
|
-
await ensureDevAuthToken(token);
|
|
11763
|
+
async removeStorageItem(key) {
|
|
11541
11764
|
if (!storage)
|
|
11542
11765
|
return;
|
|
11543
11766
|
return await storage.removeItem(key);
|
|
@@ -11546,6 +11769,10 @@ function setupStorageRPC({
|
|
|
11546
11769
|
}
|
|
11547
11770
|
|
|
11548
11771
|
const SEND_DELAY = 5e3;
|
|
11772
|
+
function isDoNotTrackEnabled() {
|
|
11773
|
+
const value = process.env.DO_NOT_TRACK;
|
|
11774
|
+
return value === "1" || value?.toLowerCase() === "true";
|
|
11775
|
+
}
|
|
11549
11776
|
function throttle(fn, delay) {
|
|
11550
11777
|
let timer;
|
|
11551
11778
|
return () => {
|
|
@@ -11562,7 +11789,7 @@ const throttledSend = throttle(() => {
|
|
|
11562
11789
|
telemetry?.sendEvents();
|
|
11563
11790
|
}, SEND_DELAY);
|
|
11564
11791
|
function setupTelemetryRPC({ nuxt, options }) {
|
|
11565
|
-
if (options.telemetry !== false) {
|
|
11792
|
+
if (options.telemetry !== false && !isDoNotTrackEnabled()) {
|
|
11566
11793
|
nuxt.hook("telemetry:setup", (t) => {
|
|
11567
11794
|
telemetry = t;
|
|
11568
11795
|
t.eventFactories.devtools = (_, payload) => {
|
|
@@ -11586,6 +11813,8 @@ function telemetryEvent(payload, immediate = false) {
|
|
|
11586
11813
|
return;
|
|
11587
11814
|
if (getOptions()?.behavior.telemetry === false)
|
|
11588
11815
|
return;
|
|
11816
|
+
if (isDoNotTrackEnabled())
|
|
11817
|
+
return;
|
|
11589
11818
|
telemetry.createEvent("devtools", payload);
|
|
11590
11819
|
if (immediate)
|
|
11591
11820
|
telemetry.sendEvents();
|
|
@@ -11593,91 +11822,6 @@ function telemetryEvent(payload, immediate = false) {
|
|
|
11593
11822
|
throttledSend();
|
|
11594
11823
|
}
|
|
11595
11824
|
|
|
11596
|
-
function setupTerminalRPC({ nuxt, rpc, refresh, ensureDevAuthToken }) {
|
|
11597
|
-
const terminals = /* @__PURE__ */ new Map();
|
|
11598
|
-
nuxt.hook("devtools:terminal:register", (terminal) => {
|
|
11599
|
-
terminals.set(terminal.id, terminal);
|
|
11600
|
-
refresh("getTerminals");
|
|
11601
|
-
return terminal.id;
|
|
11602
|
-
});
|
|
11603
|
-
nuxt.hook("devtools:terminal:remove", ({ id }) => {
|
|
11604
|
-
if (!terminals.has(id))
|
|
11605
|
-
return false;
|
|
11606
|
-
terminals.delete(id);
|
|
11607
|
-
refresh("getTerminals");
|
|
11608
|
-
return true;
|
|
11609
|
-
});
|
|
11610
|
-
nuxt.hook("devtools:terminal:write", ({ id, data }) => {
|
|
11611
|
-
const terminal = terminals.get(id);
|
|
11612
|
-
if (!terminal)
|
|
11613
|
-
return false;
|
|
11614
|
-
terminal.buffer ||= "";
|
|
11615
|
-
terminal.buffer += data;
|
|
11616
|
-
rpc.broadcast.onTerminalData.asEvent({ id, data });
|
|
11617
|
-
return true;
|
|
11618
|
-
});
|
|
11619
|
-
nuxt.hook("devtools:terminal:exit", ({ id, code }) => {
|
|
11620
|
-
const terminal = terminals.get(id);
|
|
11621
|
-
if (!terminal)
|
|
11622
|
-
return false;
|
|
11623
|
-
terminal.isTerminated = true;
|
|
11624
|
-
rpc.broadcast.onTerminalExit.asEvent({ id, code });
|
|
11625
|
-
refresh("getTerminals");
|
|
11626
|
-
return true;
|
|
11627
|
-
});
|
|
11628
|
-
function serializeTerminal(terminal, buffer = false) {
|
|
11629
|
-
if (!terminal)
|
|
11630
|
-
return;
|
|
11631
|
-
return {
|
|
11632
|
-
id: terminal.id,
|
|
11633
|
-
name: terminal.name,
|
|
11634
|
-
description: terminal.description,
|
|
11635
|
-
icon: terminal.icon,
|
|
11636
|
-
terminatable: terminal.terminatable ?? !!terminal.onActionTerminate,
|
|
11637
|
-
restartable: terminal.restartable ?? !!terminal.onActionRestart,
|
|
11638
|
-
isTerminated: terminal.isTerminated,
|
|
11639
|
-
buffer: buffer ? terminal.buffer : void 0
|
|
11640
|
-
};
|
|
11641
|
-
}
|
|
11642
|
-
return {
|
|
11643
|
-
getTerminals() {
|
|
11644
|
-
return Array.from(terminals.values(), (i) => serializeTerminal(i));
|
|
11645
|
-
},
|
|
11646
|
-
async getTerminalDetail(token, id) {
|
|
11647
|
-
await ensureDevAuthToken(token);
|
|
11648
|
-
return serializeTerminal(terminals.get(id), true);
|
|
11649
|
-
},
|
|
11650
|
-
async runTerminalAction(token, id, action) {
|
|
11651
|
-
await ensureDevAuthToken(token);
|
|
11652
|
-
const terminal = terminals.get(id);
|
|
11653
|
-
if (!terminal)
|
|
11654
|
-
return false;
|
|
11655
|
-
switch (action) {
|
|
11656
|
-
case "restart":
|
|
11657
|
-
if (!terminal.onActionRestart)
|
|
11658
|
-
return false;
|
|
11659
|
-
await terminal.onActionRestart();
|
|
11660
|
-
return true;
|
|
11661
|
-
case "terminate":
|
|
11662
|
-
if (!terminal.onActionTerminate)
|
|
11663
|
-
return false;
|
|
11664
|
-
await terminal.onActionTerminate();
|
|
11665
|
-
return true;
|
|
11666
|
-
case "remove":
|
|
11667
|
-
if (!terminal.isTerminated)
|
|
11668
|
-
terminal.onActionTerminate?.();
|
|
11669
|
-
terminals.delete(id);
|
|
11670
|
-
refresh("getTerminals");
|
|
11671
|
-
return true;
|
|
11672
|
-
case "clear":
|
|
11673
|
-
terminal.buffer = "";
|
|
11674
|
-
refresh("getTerminals");
|
|
11675
|
-
return true;
|
|
11676
|
-
}
|
|
11677
|
-
}
|
|
11678
|
-
};
|
|
11679
|
-
}
|
|
11680
|
-
|
|
11681
11825
|
function setupTimelineRPC({ nuxt }) {
|
|
11682
11826
|
return {
|
|
11683
11827
|
async enableTimeline(dry) {
|
|
@@ -11703,115 +11847,155 @@ function setupTimelineRPC({ nuxt }) {
|
|
|
11703
11847
|
function setupRPC(nuxt, options) {
|
|
11704
11848
|
const serverFunctions = {};
|
|
11705
11849
|
const extendedRpcMap = /* @__PURE__ */ new Map();
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
{
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11850
|
+
let devtoolsKitCtx;
|
|
11851
|
+
const pendingBroadcasts = [];
|
|
11852
|
+
function broadcast(method, ...args) {
|
|
11853
|
+
if (!devtoolsKitCtx) {
|
|
11854
|
+
pendingBroadcasts.push({ method, args });
|
|
11855
|
+
return;
|
|
11856
|
+
}
|
|
11857
|
+
devtoolsKitCtx.rpc.broadcast({
|
|
11858
|
+
method,
|
|
11859
|
+
args,
|
|
11860
|
+
event: true
|
|
11861
|
+
});
|
|
11862
|
+
}
|
|
11863
|
+
function createBroadcastProxy(prefix = "") {
|
|
11864
|
+
return new Proxy({}, {
|
|
11865
|
+
get: (_, method) => {
|
|
11866
|
+
if (typeof method !== "string")
|
|
11714
11867
|
return;
|
|
11715
|
-
const
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11868
|
+
const fullMethod = prefix ? `${prefix}:${method}` : method;
|
|
11869
|
+
const fn = (...args) => broadcast(fullMethod, ...args);
|
|
11870
|
+
fn.asEvent = (...args) => broadcast(fullMethod, ...args);
|
|
11871
|
+
return fn;
|
|
11872
|
+
}
|
|
11873
|
+
});
|
|
11874
|
+
}
|
|
11875
|
+
const functionsProxy = new Proxy(serverFunctions, {
|
|
11876
|
+
set(target, prop, value) {
|
|
11877
|
+
target[prop] = value;
|
|
11878
|
+
if (devtoolsKitCtx && typeof prop === "string") {
|
|
11879
|
+
if (devtoolsKitCtx.rpc.has(prop)) {
|
|
11880
|
+
devtoolsKitCtx.rpc.update({ name: prop, handler: value });
|
|
11881
|
+
} else {
|
|
11882
|
+
devtoolsKitCtx.rpc.register({ name: prop, handler: value });
|
|
11883
|
+
}
|
|
11884
|
+
}
|
|
11885
|
+
return true;
|
|
11725
11886
|
}
|
|
11726
|
-
);
|
|
11887
|
+
});
|
|
11888
|
+
const rpc = new Proxy({
|
|
11889
|
+
broadcast: createBroadcastProxy(),
|
|
11890
|
+
functions: functionsProxy
|
|
11891
|
+
}, {
|
|
11892
|
+
get(target, prop, receiver) {
|
|
11893
|
+
if (prop === "broadcast" || prop === "functions") {
|
|
11894
|
+
deprecate(nuxt, "NDT_DEP_0007", {
|
|
11895
|
+
api: `nuxt.devtools.rpc.${prop}`,
|
|
11896
|
+
replacement: "the connected ctx.rpc from onDevtoolsReady((ctx) => ...)"
|
|
11897
|
+
}, { key: prop });
|
|
11898
|
+
}
|
|
11899
|
+
return Reflect.get(target, prop, receiver);
|
|
11900
|
+
}
|
|
11901
|
+
});
|
|
11727
11902
|
function refresh(event) {
|
|
11728
|
-
|
|
11903
|
+
broadcast("refresh", event);
|
|
11729
11904
|
}
|
|
11905
|
+
const notify = createNotifier(nuxt);
|
|
11730
11906
|
function extendServerRpc(namespace, functions) {
|
|
11907
|
+
deprecate(nuxt, "NDT_DEP_0003", {
|
|
11908
|
+
api: "extendServerRpc",
|
|
11909
|
+
replacement: "onDevtoolsReady((ctx) => ctx.rpc.register(defineRpcFunction(...)))"
|
|
11910
|
+
}, { key: namespace });
|
|
11731
11911
|
extendedRpcMap.set(namespace, functions);
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
return;
|
|
11737
|
-
return rpc.broadcast[`${namespace}:${key}`];
|
|
11912
|
+
if (devtoolsKitCtx) {
|
|
11913
|
+
for (const [fnName, handler] of Object.entries(functions)) {
|
|
11914
|
+
if (typeof handler === "function") {
|
|
11915
|
+
devtoolsKitCtx.rpc.register({ name: `${namespace}:${fnName}`, handler });
|
|
11738
11916
|
}
|
|
11739
|
-
}
|
|
11917
|
+
}
|
|
11918
|
+
}
|
|
11919
|
+
return {
|
|
11920
|
+
broadcast: createBroadcastProxy(namespace),
|
|
11921
|
+
functions,
|
|
11922
|
+
clients: [],
|
|
11923
|
+
updateChannels: () => []
|
|
11740
11924
|
};
|
|
11741
11925
|
}
|
|
11742
11926
|
const ctx = {
|
|
11743
11927
|
nuxt,
|
|
11744
11928
|
options,
|
|
11745
11929
|
rpc,
|
|
11930
|
+
get devtoolsKit() {
|
|
11931
|
+
return devtoolsKitCtx;
|
|
11932
|
+
},
|
|
11746
11933
|
refresh,
|
|
11934
|
+
notify,
|
|
11747
11935
|
extendServerRpc,
|
|
11748
|
-
openInEditorHooks: []
|
|
11749
|
-
async ensureDevAuthToken(token) {
|
|
11750
|
-
if (options.disableAuthorization)
|
|
11751
|
-
return;
|
|
11752
|
-
if (token !== await getDevAuthToken())
|
|
11753
|
-
throw new Error("[Nuxt DevTools] Invalid dev auth token.");
|
|
11754
|
-
}
|
|
11936
|
+
openInEditorHooks: []
|
|
11755
11937
|
};
|
|
11756
11938
|
nuxt.devtools = ctx;
|
|
11757
11939
|
Object.assign(serverFunctions, {
|
|
11758
11940
|
...setupGeneralRPC(ctx),
|
|
11941
|
+
...setupMessagesRPC(ctx),
|
|
11759
11942
|
...setupCustomTabRPC(ctx),
|
|
11760
11943
|
...setupStorageRPC(ctx),
|
|
11761
11944
|
...setupAssetsRPC(ctx),
|
|
11762
11945
|
...setupNpmRPC(ctx),
|
|
11763
|
-
|
|
11946
|
+
// Bridge the `devtools:terminal:*` hooks onto the Vite DevTools terminals
|
|
11947
|
+
// host so module terminals surface in the built-in Terminals dock. Also
|
|
11948
|
+
// registers its own hook listeners (including `devtools:ready`) as a side
|
|
11949
|
+
// effect, and contributes the `revealTerminal` RPC.
|
|
11950
|
+
...setupTerminalsBridge(ctx),
|
|
11764
11951
|
...setupServerRoutesRPC(ctx),
|
|
11765
11952
|
...setupServerTasksRPC(ctx),
|
|
11766
11953
|
...setupAnalyzeBuildRPC(ctx),
|
|
11767
11954
|
...setupOptionsRPC(ctx),
|
|
11768
11955
|
...setupTimelineRPC(ctx),
|
|
11769
11956
|
...setupTelemetryRPC(ctx),
|
|
11770
|
-
|
|
11957
|
+
// Deprecated compat shim (NDT_DEP_0009). The capture + live source now live
|
|
11958
|
+
// in the Data Inspector integration; `getServerConfig` is served by the
|
|
11959
|
+
// canonical `setupGeneralRPC` above.
|
|
11960
|
+
getServerData: async () => import('./data-inspector.mjs').then(({ getServerData }) => getServerData(nuxt))
|
|
11771
11961
|
});
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11782
|
-
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
} catch {
|
|
11792
|
-
}
|
|
11793
|
-
});
|
|
11794
|
-
},
|
|
11795
|
-
serialize: stringify,
|
|
11796
|
-
deserialize: parse$1
|
|
11797
|
-
};
|
|
11798
|
-
rpc.updateChannels((c) => {
|
|
11799
|
-
c.push(channel);
|
|
11800
|
-
});
|
|
11801
|
-
ws.on("close", () => {
|
|
11802
|
-
wsClients.delete(ws);
|
|
11803
|
-
rpc.updateChannels((c) => {
|
|
11804
|
-
const index = c.indexOf(channel);
|
|
11805
|
-
if (index >= 0)
|
|
11806
|
-
c.splice(index, 1);
|
|
11807
|
-
});
|
|
11808
|
-
});
|
|
11809
|
-
});
|
|
11962
|
+
async function connectDevToolsKit(kitCtx) {
|
|
11963
|
+
if (devtoolsKitCtx || skipInSSR(kitCtx))
|
|
11964
|
+
return;
|
|
11965
|
+
devtoolsKitCtx = kitCtx;
|
|
11966
|
+
const host = kitCtx.rpc;
|
|
11967
|
+
for (const { method, args } of pendingBroadcasts) {
|
|
11968
|
+
broadcast(method, ...args);
|
|
11969
|
+
}
|
|
11970
|
+
pendingBroadcasts.length = 0;
|
|
11971
|
+
registerHostDiagnostics(ctx);
|
|
11972
|
+
function registerFn(name, handler) {
|
|
11973
|
+
try {
|
|
11974
|
+
host.register({ name, handler });
|
|
11975
|
+
} catch (e) {
|
|
11976
|
+
logger.warn(
|
|
11977
|
+
colors.yellow(`[nuxt-devtools] Failed to register RPC function "${name}":
|
|
11978
|
+
`) + colors.red(e?.message || "")
|
|
11979
|
+
);
|
|
11980
|
+
}
|
|
11810
11981
|
}
|
|
11811
|
-
|
|
11982
|
+
for (const [name, handler] of Object.entries(serverFunctions)) {
|
|
11983
|
+
if (typeof handler !== "function")
|
|
11984
|
+
continue;
|
|
11985
|
+
registerFn(`${RPC_NAMESPACE}:${name}`, handler);
|
|
11986
|
+
registerFn(name, handler);
|
|
11987
|
+
}
|
|
11988
|
+
for (const [namespace, fns] of extendedRpcMap) {
|
|
11989
|
+
for (const [fnName, handler] of Object.entries(fns)) {
|
|
11990
|
+
if (typeof handler === "function")
|
|
11991
|
+
registerFn(`${namespace}:${fnName}`, handler);
|
|
11992
|
+
}
|
|
11993
|
+
}
|
|
11994
|
+
await nuxt.callHook("devtools:ready", kitCtx);
|
|
11995
|
+
}
|
|
11812
11996
|
return {
|
|
11813
|
-
|
|
11814
|
-
|
|
11997
|
+
connectDevToolsKit,
|
|
11998
|
+
ctx
|
|
11815
11999
|
};
|
|
11816
12000
|
}
|
|
11817
12001
|
|
|
@@ -11830,6 +12014,13 @@ async function enableModule(options, nuxt) {
|
|
|
11830
12014
|
return;
|
|
11831
12015
|
}
|
|
11832
12016
|
await nuxt.callHook("devtools:before");
|
|
12017
|
+
if (options.disableAuthorization) {
|
|
12018
|
+
extendViteConfig((config) => {
|
|
12019
|
+
const devtoolsConfig = config.devtools ||= {};
|
|
12020
|
+
if (devtoolsConfig.clientAuth === void 0)
|
|
12021
|
+
devtoolsConfig.clientAuth = false;
|
|
12022
|
+
});
|
|
12023
|
+
}
|
|
11833
12024
|
if (options.iframeProps) {
|
|
11834
12025
|
nuxt.options.runtimeConfig.app.devtools ||= {};
|
|
11835
12026
|
nuxt.options.runtimeConfig.app.devtools.iframeProps = options.iframeProps;
|
|
@@ -11843,19 +12034,59 @@ async function enableModule(options, nuxt) {
|
|
|
11843
12034
|
src: join(runtimeDir, "plugins/devtools.server"),
|
|
11844
12035
|
mode: "server"
|
|
11845
12036
|
});
|
|
12037
|
+
if (nuxt.options.dev) {
|
|
12038
|
+
nuxt.options.vite.optimizeDeps ||= {};
|
|
12039
|
+
nuxt.options.vite.optimizeDeps.include ||= [];
|
|
12040
|
+
nuxt.options.vite.optimizeDeps.include.push(
|
|
12041
|
+
// Vite DevTools 0.5's embedded client is served by the hub as an external
|
|
12042
|
+
// `embedded.js` script (see `runtime/plugins/vite-devtools.client`), so it
|
|
12043
|
+
// is no longer a bundler-resolved `@vitejs/devtools/client/inject` import to
|
|
12044
|
+
// pre-bundle here.
|
|
12045
|
+
"nuxt > @nuxt/devtools > @vitejs/devtools-kit/client",
|
|
12046
|
+
"nuxt > @nuxt/devtools > error-stack-parser-es",
|
|
12047
|
+
"nuxt > @nuxt/devtools > vite-plugin-vue-tracer/client/overlay"
|
|
12048
|
+
);
|
|
12049
|
+
}
|
|
11846
12050
|
const DevTools = await import('@vitejs/devtools').then((r) => r.DevTools());
|
|
11847
12051
|
addVitePlugin(DevTools);
|
|
12052
|
+
let connectDevToolsKit;
|
|
11848
12053
|
addVitePlugin(defineViteDevToolsPlugin({
|
|
11849
12054
|
name: "nuxt:devtools",
|
|
11850
12055
|
devtools: {
|
|
11851
|
-
setup(ctx2) {
|
|
11852
|
-
ctx2
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
12056
|
+
async setup(ctx2) {
|
|
12057
|
+
if (!skipInSSR(ctx2)) {
|
|
12058
|
+
ctx2.docks.register({
|
|
12059
|
+
id: NUXT_DEVTOOLS_GROUP_ID,
|
|
12060
|
+
type: "group",
|
|
12061
|
+
title: "Nuxt",
|
|
12062
|
+
icon: "/__nuxt_devtools__/client/nuxt.svg",
|
|
12063
|
+
category: "framework",
|
|
12064
|
+
defaultOrder: -2e3,
|
|
12065
|
+
defaultChildId: "nuxt:devtools",
|
|
12066
|
+
categoryOrder: {
|
|
12067
|
+
pinned: 0,
|
|
12068
|
+
app: 1,
|
|
12069
|
+
analyze: 2,
|
|
12070
|
+
server: 3,
|
|
12071
|
+
modules: 4,
|
|
12072
|
+
documentation: 5,
|
|
12073
|
+
advanced: 6
|
|
12074
|
+
}
|
|
12075
|
+
});
|
|
12076
|
+
ctx2.docks.register({
|
|
12077
|
+
id: "nuxt:devtools",
|
|
12078
|
+
type: "iframe",
|
|
12079
|
+
title: "Nuxt DevTools",
|
|
12080
|
+
icon: "/__nuxt_devtools__/client/nuxt.svg",
|
|
12081
|
+
url: "/__nuxt_devtools__/client/",
|
|
12082
|
+
groupId: NUXT_DEVTOOLS_GROUP_ID,
|
|
12083
|
+
frameId: "nuxt:devtools",
|
|
12084
|
+
subTabs: { protocol: "postmessage" },
|
|
12085
|
+
visibility: "false",
|
|
12086
|
+
defaultOrder: -300
|
|
12087
|
+
});
|
|
12088
|
+
}
|
|
12089
|
+
await connectDevToolsKit?.(ctx2);
|
|
11859
12090
|
}
|
|
11860
12091
|
}
|
|
11861
12092
|
}));
|
|
@@ -11867,9 +12098,7 @@ async function enableModule(options, nuxt) {
|
|
|
11867
12098
|
filename: "devtools/settings.mjs",
|
|
11868
12099
|
async getContents() {
|
|
11869
12100
|
const uiOptions = await readLocalOptions(
|
|
11870
|
-
|
|
11871
|
-
...defaultTabOptions.ui
|
|
11872
|
-
},
|
|
12101
|
+
createDefaultTabOptions().ui,
|
|
11873
12102
|
{ root: nuxt.options.rootDir }
|
|
11874
12103
|
);
|
|
11875
12104
|
return `export default ${JSON.stringify({
|
|
@@ -11879,10 +12108,18 @@ async function enableModule(options, nuxt) {
|
|
|
11879
12108
|
});
|
|
11880
12109
|
nuxt.hook("nitro:config", (config) => {
|
|
11881
12110
|
if (config.experimental?.tasks)
|
|
11882
|
-
|
|
11883
|
-
|
|
11884
|
-
|
|
11885
|
-
|
|
12111
|
+
setServerTasksEnabledByDefault(true);
|
|
12112
|
+
const inlinePath = join(runtimeDir, "nitro");
|
|
12113
|
+
if ("externals" in config) {
|
|
12114
|
+
config.externals ||= {};
|
|
12115
|
+
config.externals.inline ||= [];
|
|
12116
|
+
config.externals.inline.push(inlinePath);
|
|
12117
|
+
}
|
|
12118
|
+
if ("noExternals" in config && Array.isArray(config.noExternals)) {
|
|
12119
|
+
config.noExternals.push(inlinePath);
|
|
12120
|
+
} else if (!("noExternals" in config) || config.noExternals === void 0) {
|
|
12121
|
+
config.noExternals = [inlinePath];
|
|
12122
|
+
}
|
|
11886
12123
|
config.virtual = config.virtual || {};
|
|
11887
12124
|
config.virtual["#nuxt-devtools-inline"] = `export const script = \`
|
|
11888
12125
|
if (!window.__NUXT_DEVTOOLS_TIME_METRIC__) {
|
|
@@ -11898,10 +12135,10 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11898
12135
|
config.plugins.unshift(join(runtimeDir, "nitro/inline"));
|
|
11899
12136
|
});
|
|
11900
12137
|
const {
|
|
11901
|
-
|
|
11902
|
-
|
|
12138
|
+
connectDevToolsKit: _connectDevToolsKit,
|
|
12139
|
+
ctx
|
|
11903
12140
|
} = setupRPC(nuxt, options);
|
|
11904
|
-
|
|
12141
|
+
connectDevToolsKit = _connectDevToolsKit;
|
|
11905
12142
|
const clientDirExists = existsSync(clientDir);
|
|
11906
12143
|
extendViteConfig((config) => {
|
|
11907
12144
|
config.server ||= {};
|
|
@@ -11923,8 +12160,6 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11923
12160
|
});
|
|
11924
12161
|
const ROUTE_PATH = `${nuxt.options.app.baseURL || "/"}/__nuxt_devtools__`.replace(MULTIPLE_SLASHES_RE, "/");
|
|
11925
12162
|
const ROUTE_CLIENT = `${ROUTE_PATH}/client`;
|
|
11926
|
-
const ROUTE_AUTH = `${ROUTE_PATH}/auth`;
|
|
11927
|
-
const ROUTE_AUTH_VERIFY = `${ROUTE_PATH}/auth-verify`;
|
|
11928
12163
|
const ROUTE_ANALYZE = `${ROUTE_PATH}/analyze`;
|
|
11929
12164
|
nuxt.hook("vite:serverCreated", (server) => {
|
|
11930
12165
|
const devtoolsAnalyzeDir = join(nuxt.options.rootDir, "node_modules/.cache/nuxt-devtools/analyze");
|
|
@@ -11943,42 +12178,28 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
|
|
|
11943
12178
|
res.end();
|
|
11944
12179
|
};
|
|
11945
12180
|
server.middlewares.use(ROUTE_CLIENT, (req, res) => {
|
|
11946
|
-
|
|
12181
|
+
const pathname = (req.url || "/").split("?")[0];
|
|
12182
|
+
if (pathname === "/" || pathname === "")
|
|
11947
12183
|
return handleIndex(res);
|
|
11948
12184
|
return handleStatic(req, res, () => handleIndex(res));
|
|
11949
12185
|
});
|
|
11950
12186
|
}
|
|
11951
|
-
server.middlewares.use(ROUTE_AUTH, sirv(join(runtimeDir, "auth"), { single: true, dev: true }));
|
|
11952
|
-
server.middlewares.use(ROUTE_AUTH_VERIFY, async (req, res) => {
|
|
11953
|
-
const search = req.url?.split("?")[1];
|
|
11954
|
-
if (!search) {
|
|
11955
|
-
res.statusCode = 400;
|
|
11956
|
-
res.end("No token provided");
|
|
11957
|
-
}
|
|
11958
|
-
const query = new URLSearchParams(search);
|
|
11959
|
-
const token = query.get("token");
|
|
11960
|
-
if (!token) {
|
|
11961
|
-
res.statusCode = 400;
|
|
11962
|
-
res.end("No token provided");
|
|
11963
|
-
}
|
|
11964
|
-
if (token === await getDevAuthToken()) {
|
|
11965
|
-
res.statusCode = 200;
|
|
11966
|
-
res.end("Valid token");
|
|
11967
|
-
} else {
|
|
11968
|
-
res.statusCode = 403;
|
|
11969
|
-
res.end("Invalid token");
|
|
11970
|
-
}
|
|
11971
|
-
});
|
|
11972
12187
|
});
|
|
11973
12188
|
await import('./plugin-metrics.mjs').then(({ setup }) => setup(ctx));
|
|
11974
|
-
if (options.
|
|
11975
|
-
await import('./
|
|
12189
|
+
if (options.dataInspector !== false)
|
|
12190
|
+
await import('./data-inspector.mjs').then(({ setup }) => setup(ctx));
|
|
11976
12191
|
if (options.viteInspect !== false)
|
|
11977
12192
|
await import('./vite-inspect.mjs').then(({ setup }) => setup(ctx));
|
|
11978
12193
|
if (options.componentInspector !== false)
|
|
11979
12194
|
await import('./vue-tracer.mjs').then(({ setup }) => setup(ctx));
|
|
12195
|
+
if (options.codeServer?.enabled === false && options.vscode !== void 0) {
|
|
12196
|
+
deprecate(nuxt, "NDT_DEP_0008", {
|
|
12197
|
+
api: "devtools.vscode",
|
|
12198
|
+
replacement: "devtools.codeServer"
|
|
12199
|
+
});
|
|
12200
|
+
}
|
|
11980
12201
|
const integrations = [
|
|
11981
|
-
options.
|
|
12202
|
+
options.codeServer?.enabled !== false ? import('./code-server.mjs').then(({ setup }) => setup(ctx)) : null,
|
|
11982
12203
|
options.experimental?.timeline || options.timeline?.enabled ? import('./timeline.mjs').then(({ setup }) => setup(ctx)) : null
|
|
11983
12204
|
];
|
|
11984
12205
|
await Promise.all(integrations);
|
|
@@ -12003,4 +12224,9 @@ function defineViteDevToolsPlugin(plugin) {
|
|
|
12003
12224
|
return plugin;
|
|
12004
12225
|
}
|
|
12005
12226
|
|
|
12006
|
-
|
|
12227
|
+
const moduleMain = {
|
|
12228
|
+
__proto__: null,
|
|
12229
|
+
enableModule: enableModule
|
|
12230
|
+
};
|
|
12231
|
+
|
|
12232
|
+
export { RPC_NAMESPACE as R, moduleMain as m };
|