@nuxt/devtools 4.0.0-alpha.1 → 4.0.0-alpha.10

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.
Files changed (230) hide show
  1. package/README.md +86 -7
  2. package/dist/chunks/analyze-build.mjs +33 -2
  3. package/dist/chunks/code-server.mjs +75 -0
  4. package/dist/chunks/module-main.mjs +844 -548
  5. package/dist/chunks/timeline.mjs +2 -2
  6. package/dist/chunks/vite-inspect.mjs +93 -53
  7. package/dist/client/200.html +1 -1
  8. package/dist/client/404.html +1 -1
  9. package/dist/client/_nuxt/__blank-dil3nwfh.js +1 -0
  10. package/dist/client/_nuxt/analyze-build-2e03hfez.js +1 -0
  11. package/dist/client/_nuxt/assets-fyld29gf.js +6 -0
  12. package/dist/client/_nuxt/auth-required-panel-mm5lidl3.js +1 -0
  13. package/dist/client/_nuxt/builds/latest.json +1 -1
  14. package/dist/client/_nuxt/builds/meta/dbb6f1eb-fdec-4078-b409-19d1ed6035a2.json +1 -0
  15. package/dist/client/_nuxt/{client-im47u3kz.js → client-botfq0nw.js} +1 -1
  16. package/dist/client/_nuxt/code-diff-oxve94ak.js +8 -0
  17. package/dist/client/_nuxt/code-snippets-mcrkbsd4.js +1 -0
  18. package/dist/client/_nuxt/components-k5rsm3c3.js +1 -0
  19. package/dist/client/_nuxt/composable-item-o8crh7o9.js +1 -0
  20. package/dist/client/_nuxt/composables-ml69kqh9.js +1 -0
  21. package/dist/client/_nuxt/custom-_name_-j6w4b10b.js +1 -0
  22. package/dist/client/_nuxt/data-schema-button-j2dsypzz.js +1 -0
  23. package/dist/client/_nuxt/data-schema-drawer-9s1351p5.js +2 -0
  24. package/dist/client/_nuxt/debug-muupfuzb.js +1 -0
  25. package/dist/client/_nuxt/default-k6jiq1wt.js +1 -0
  26. package/dist/client/_nuxt/dialog-c7wnj3nl.js +1 -0
  27. package/dist/client/_nuxt/dist-2c3gpsw0.js +1 -0
  28. package/dist/client/_nuxt/dist-d6zuldkp.js +1 -0
  29. package/dist/client/_nuxt/duration-display-kup58tqe.js +1 -0
  30. package/dist/client/_nuxt/editor-bzxz1rcq.js +1 -0
  31. package/dist/client/_nuxt/entry.css-meav5jmw.css +1 -0
  32. package/dist/client/_nuxt/error-404-25vom0cq.js +1 -0
  33. package/dist/client/_nuxt/error-404.css-mpcol2vk.css +1 -0
  34. package/dist/client/_nuxt/error-500-htafeoa3.js +1 -0
  35. package/dist/client/_nuxt/error-500.css-273x0c3h.css +1 -0
  36. package/dist/client/_nuxt/error-lj28vdr1.js +9 -0
  37. package/dist/client/_nuxt/filepath-item-jdy5gc4m.js +1 -0
  38. package/dist/client/_nuxt/full-gpj1mlf5.js +1 -0
  39. package/dist/client/_nuxt/fuse-blwyun20.js +1 -0
  40. package/dist/client/_nuxt/help-fab-ll6mbhgs.js +1 -0
  41. package/dist/client/_nuxt/hooks-hgffr865.js +1 -0
  42. package/dist/client/_nuxt/imports-i2fnwttt.js +1 -0
  43. package/dist/client/_nuxt/launch-page-ksxhzp2z.js +1 -0
  44. package/dist/client/_nuxt/modules-dae72omf.js +1 -0
  45. package/dist/client/_nuxt/nbadge-oyy0wjng.js +1 -0
  46. package/dist/client/_nuxt/nbutton-mtj8qzr9.js +1 -0
  47. package/dist/client/_nuxt/ncard-mtvdl2wf.js +1 -0
  48. package/dist/client/_nuxt/ncheckbox-mksfz5p0.js +1 -0
  49. package/dist/client/_nuxt/ncode-block-pfi5niis.js +2 -0
  50. package/dist/client/_nuxt/{ncode-block.css-o2ixs97j.css → ncode-block.css-ivoxtfjk.css} +1 -1
  51. package/dist/client/_nuxt/ndialog-dj1ywkc1.js +3 -0
  52. package/dist/client/_nuxt/ndrawer-h46qfenr.js +1 -0
  53. package/dist/client/_nuxt/ndropdown-ow0z3stn.js +1 -0
  54. package/dist/client/_nuxt/nicon-obdu3k9r.js +3 -0
  55. package/dist/client/_nuxt/nicon-title-e2gzkzl3.js +1 -0
  56. package/dist/client/_nuxt/nju74r39.js +2 -0
  57. package/dist/client/_nuxt/nlink-j55iyj5x.js +1 -0
  58. package/dist/client/_nuxt/nloading-k4sy0f8c.js +1 -0
  59. package/dist/client/_nuxt/nmarkdown-mnxob7ua.js +1 -0
  60. package/dist/client/_nuxt/nnavbar-dwxbkqvw.js +1 -0
  61. package/dist/client/_nuxt/none-md25735q.js +1 -0
  62. package/dist/client/_nuxt/npanel-grids-ga8arlvs.js +1 -0
  63. package/dist/client/_nuxt/npm-febdntx4.js +1 -0
  64. package/dist/client/_nuxt/nsection-block-cb29dqkc.js +1 -0
  65. package/dist/client/_nuxt/nsection-block.css-h1lgpwgm.css +1 -0
  66. package/dist/client/_nuxt/nselect-glgbbae4.js +1 -0
  67. package/dist/client/_nuxt/nselect-tabs-jzyd56a1.js +1 -0
  68. package/dist/client/_nuxt/nsplit-pane-b5ki4jwa.js +1 -0
  69. package/dist/client/_nuxt/nsplit-pane.css-k1gopk47.css +1 -0
  70. package/dist/client/_nuxt/ntext-input-lzyyx3ym.js +1 -0
  71. package/dist/client/_nuxt/ntip-oohvtkqd.js +1 -0
  72. package/dist/client/_nuxt/nuxt-f4tmbbs7.js +1 -0
  73. package/dist/client/_nuxt/nuxt-link-dgri2bli.js +1 -0
  74. package/dist/client/_nuxt/nuxt-logo-gzcu6lh0.js +1 -0
  75. package/dist/client/_nuxt/open-graph-mc8dh9qn.js +3 -0
  76. package/dist/client/_nuxt/overview-lpfgamus.js +1 -0
  77. package/dist/client/_nuxt/pages-bv99uu3p.js +1 -0
  78. package/dist/client/_nuxt/payload-k2hrsm04.js +1 -0
  79. package/dist/client/_nuxt/plugins-ljid8ktq.js +1 -0
  80. package/dist/client/_nuxt/ready-h6bi8le4.js +1 -0
  81. package/dist/client/_nuxt/rolldown-runtime-ln9q81id.js +1 -0
  82. package/dist/client/_nuxt/runtime-configs-lvgzbcdu.js +1 -0
  83. package/dist/client/_nuxt/server-route-inputs-iwv9ewrw.js +1 -0
  84. package/dist/client/_nuxt/server-routes-mkqbltfh.js +7 -0
  85. package/dist/client/_nuxt/server-tasks-kbf4txeq.js +1 -0
  86. package/dist/client/_nuxt/settings-ngc5p8qn.js +1 -0
  87. package/dist/client/_nuxt/stacktrace-list-chmjyp53.js +1 -0
  88. package/dist/client/_nuxt/state-commands-f4h87cfl.js +1 -0
  89. package/dist/client/_nuxt/state-components-jymg7dj7.js +1 -0
  90. package/dist/client/_nuxt/state-editor-bg13n53w.js +1 -0
  91. package/dist/client/_nuxt/state-modules-bewlxq5o.js +1 -0
  92. package/dist/client/_nuxt/state-routes-f5cna95h.js +1 -0
  93. package/dist/client/_nuxt/state-schema-espdew31.js +1 -0
  94. package/dist/client/_nuxt/state-tabs-m7neqayd.js +1 -0
  95. package/dist/client/_nuxt/storage-cep8dxy9.js +1 -0
  96. package/dist/client/_nuxt/tab-icon-nktg799o.js +1 -0
  97. package/dist/client/_nuxt/telemetry-9f19c0i9.js +1 -0
  98. package/dist/client/_nuxt/timeline-o9hhhb94.js +31 -0
  99. package/dist/client/_nuxt/unhead.dgx-hwv-uc-gaht5h60.js +1 -0
  100. package/dist/client/_nuxt/unocss-runtime-bjggyd5e.js +1 -0
  101. package/dist/client/_nuxt/utils-bisj7255.js +1 -0
  102. package/dist/client/_nuxt/vendor/json-editor-vue-lmhxk84q.js +3862 -0
  103. package/dist/client/_nuxt/vendor/{json-editor-vue.css-lkbe0qhh.css → json-editor-vue.css-lb1ewor6.css} +1 -1
  104. package/dist/client/_nuxt/vendor/markdown-exit-n4f1gsja.js +12 -0
  105. package/dist/client/_nuxt/vendor/quicktype-core-b6sxxdgw.js +929 -0
  106. package/dist/client/_nuxt/vendor/shiki-abzmnals.js +152 -0
  107. package/dist/client/_nuxt/vendor/unocss-hqrnsbiy.js +3 -0
  108. package/dist/client/_nuxt/vendor/unocss.css-bhad58wt.css +1 -0
  109. package/dist/client/_nuxt/vendor/vis-i54ppuvk.js +26 -0
  110. package/dist/client/_nuxt/virtual-files-kcs310xn.js +1 -0
  111. package/dist/client/index.html +1 -1
  112. package/dist/module.json +2 -2
  113. package/dist/module.mjs +1 -1
  114. package/dist/runtime/plugins/devtools.client.js +1 -1
  115. package/dist/runtime/plugins/view/client.js +8 -9
  116. package/dist/shared/devtools.CCWq4fFE.mjs +113 -0
  117. package/dist/types.d.mts +1 -5
  118. package/dist/webcomponents/index.mjs +28 -31
  119. package/package.json +76 -69
  120. package/.discoveryrc.cjs +0 -13
  121. package/dist/chunks/vscode.mjs +0 -170
  122. package/dist/chunks/vue-devtools.mjs +0 -18
  123. package/dist/client/_nuxt/__blank-cpzbm3dn.js +0 -1
  124. package/dist/client/_nuxt/analyze-build-e7v5vkef.js +0 -1
  125. package/dist/client/_nuxt/assets-b5c187l4.js +0 -6
  126. package/dist/client/_nuxt/builds/meta/25fc8778-785e-4df1-8047-b131fc1cd4b2.json +0 -1
  127. package/dist/client/_nuxt/code-diff-idsu3m0z.js +0 -8
  128. package/dist/client/_nuxt/code-snippets-k81hoi4s.js +0 -1
  129. package/dist/client/_nuxt/components-bmictfph.js +0 -1
  130. package/dist/client/_nuxt/composable-item-cza22cup.js +0 -1
  131. package/dist/client/_nuxt/copkoh3j.js +0 -4
  132. package/dist/client/_nuxt/custom-_name_-gqm5kr56.js +0 -1
  133. package/dist/client/_nuxt/data-schema-button-b308wyi0.js +0 -1
  134. package/dist/client/_nuxt/data-schema-drawer-lr34uwsh.js +0 -2
  135. package/dist/client/_nuxt/debug-kgc8fptp.js +0 -1
  136. package/dist/client/_nuxt/default-jvhm51ri.js +0 -1
  137. package/dist/client/_nuxt/dev-auth-ojiqold5.js +0 -1
  138. package/dist/client/_nuxt/dist-duc3zu0y.js +0 -1
  139. package/dist/client/_nuxt/dist-mnod32r1.js +0 -1
  140. package/dist/client/_nuxt/duration-display-f7ucshmo.js +0 -1
  141. package/dist/client/_nuxt/entry.css-me26coxn.css +0 -1
  142. package/dist/client/_nuxt/error-404-nggtc73s.js +0 -1
  143. package/dist/client/_nuxt/error-404.css-j1aav08u.css +0 -1
  144. package/dist/client/_nuxt/error-500-dym2gzqx.js +0 -1
  145. package/dist/client/_nuxt/error-500.css-eu9fz4va.css +0 -1
  146. package/dist/client/_nuxt/error-fqinfa1x.js +0 -9
  147. package/dist/client/_nuxt/filepath-item-e1s52fbh.js +0 -1
  148. package/dist/client/_nuxt/full-et0weok9.js +0 -1
  149. package/dist/client/_nuxt/help-fab-hz6r2oxa.js +0 -1
  150. package/dist/client/_nuxt/hooks-i7nsduqp.js +0 -1
  151. package/dist/client/_nuxt/imports-9o2qs53q.js +0 -1
  152. package/dist/client/_nuxt/launch-page-hpkkqhit.js +0 -1
  153. package/dist/client/_nuxt/mitt.es-fjx0h8xe.js +0 -1
  154. package/dist/client/_nuxt/modules-jok0opuq.js +0 -1
  155. package/dist/client/_nuxt/nbadge-m66xoquo.js +0 -1
  156. package/dist/client/_nuxt/nbutton-gygn07c2.js +0 -1
  157. package/dist/client/_nuxt/ncard-mqcl8pso.js +0 -1
  158. package/dist/client/_nuxt/ncheckbox-c0r45qtu.js +0 -1
  159. package/dist/client/_nuxt/ncode-block-figzf35k.js +0 -2
  160. package/dist/client/_nuxt/ndrawer-bgqyrlmt.js +0 -1
  161. package/dist/client/_nuxt/ndropdown-cip8lboe.js +0 -1
  162. package/dist/client/_nuxt/nicon-m1crov2l.js +0 -1
  163. package/dist/client/_nuxt/nicon-title-tqdvw0w0.js +0 -1
  164. package/dist/client/_nuxt/nlink-od4lllbl.js +0 -1
  165. package/dist/client/_nuxt/nmarkdown-hw0hmqw7.js +0 -1
  166. package/dist/client/_nuxt/nnavbar-lpozm5fj.js +0 -1
  167. package/dist/client/_nuxt/none-bdxkqeml.js +0 -1
  168. package/dist/client/_nuxt/npanel-grids-dd23ifsw.js +0 -1
  169. package/dist/client/_nuxt/nsection-block-lqrohs9v.js +0 -1
  170. package/dist/client/_nuxt/nsection-block.css-h05mpq8x.css +0 -1
  171. package/dist/client/_nuxt/nselect-gczoit0g.js +0 -1
  172. package/dist/client/_nuxt/nselect-tabs-bsw5fg3d.js +0 -1
  173. package/dist/client/_nuxt/nswitch-ke379yjx.js +0 -1
  174. package/dist/client/_nuxt/ntext-input-cygthohl.js +0 -1
  175. package/dist/client/_nuxt/ntip-ke63ovgc.js +0 -1
  176. package/dist/client/_nuxt/nuxt-link-bumooa9d.js +0 -1
  177. package/dist/client/_nuxt/nuxt-otp6bp04.js +0 -1
  178. package/dist/client/_nuxt/open-graph-lumhcitx.js +0 -3
  179. package/dist/client/_nuxt/overview-c1ufrox9.js +0 -1
  180. package/dist/client/_nuxt/pages-cf1hvns3.js +0 -1
  181. package/dist/client/_nuxt/pages-lgihsvbt.js +0 -1
  182. package/dist/client/_nuxt/payload-fvgw4hh9.js +0 -1
  183. package/dist/client/_nuxt/pinia-lmrgyjxw.js +0 -1
  184. package/dist/client/_nuxt/plugins-ccaip8nh.js +0 -1
  185. package/dist/client/_nuxt/ready-dadbdj5i.js +0 -1
  186. package/dist/client/_nuxt/render-tree-corj3giw.js +0 -1
  187. package/dist/client/_nuxt/rolldown-runtime-oipoa1or.js +0 -1
  188. package/dist/client/_nuxt/rpc-ez4fzlum.js +0 -1
  189. package/dist/client/_nuxt/runtime-configs-im0uu24n.js +0 -1
  190. package/dist/client/_nuxt/server-discovery-ffkkczqi.js +0 -1
  191. package/dist/client/_nuxt/server-route-inputs-lspeoiem.js +0 -1
  192. package/dist/client/_nuxt/server-routes-dhvqrowz.js +0 -7
  193. package/dist/client/_nuxt/server-tasks-mr9ezn8q.js +0 -1
  194. package/dist/client/_nuxt/settings-issronwn.js +0 -1
  195. package/dist/client/_nuxt/splitpanes.es-bxyirks2.js +0 -1
  196. package/dist/client/_nuxt/stacktrace-list-hiui24c3.js +0 -1
  197. package/dist/client/_nuxt/state-components-fbls8ka7.js +0 -1
  198. package/dist/client/_nuxt/state-editor-c7e04uj2.js +0 -1
  199. package/dist/client/_nuxt/state-modules-inqbwd7z.js +0 -1
  200. package/dist/client/_nuxt/state-routes-jln33b1m.js +0 -1
  201. package/dist/client/_nuxt/state-tabs-etl5jr30.js +0 -1
  202. package/dist/client/_nuxt/storage-husj5pg6.js +0 -1
  203. package/dist/client/_nuxt/storage-options-cth3coln.js +0 -1
  204. package/dist/client/_nuxt/telemetry-eqv6a0hn.js +0 -1
  205. package/dist/client/_nuxt/terminals-kitd8oja.js +0 -1
  206. package/dist/client/_nuxt/terminals.css-mejv43xm.css +0 -1
  207. package/dist/client/_nuxt/timeline-gr4tcvcz.js +0 -31
  208. package/dist/client/_nuxt/unocss-runtime-cpug61u1.js +0 -1
  209. package/dist/client/_nuxt/utils-nbkl6byi.js +0 -2
  210. package/dist/client/_nuxt/vendor/json-editor-vue-eojr4v24.js +0 -3869
  211. package/dist/client/_nuxt/vendor/markdown-it-ckeo8pwp.js +0 -14
  212. package/dist/client/_nuxt/vendor/quicktype-core-k4qx3809.js +0 -929
  213. package/dist/client/_nuxt/vendor/shiki-lqo1hg2n.js +0 -153
  214. package/dist/client/_nuxt/vendor/unocss-k727ub0h.js +0 -3
  215. package/dist/client/_nuxt/vendor/unocss.css-3gd0e2sv.css +0 -1
  216. package/dist/client/_nuxt/vendor/vis-id8udisj.js +0 -26
  217. package/dist/client/_nuxt/vendor/xterm-ed0pys2e.js +0 -36
  218. package/dist/client/_nuxt/vendor/xterm.css-jqmddlol.css +0 -1
  219. package/dist/client/_nuxt/virtual-files-ky9cc4av.js +0 -1
  220. package/dist/client/_nuxt/vue-devtools-dunhx2nz.js +0 -4
  221. package/dist/client/_nuxt/vue-router-jbnxw7nb.js +0 -1
  222. package/dist/client/discovery/index.html +0 -611
  223. package/dist/runtime/vue-devtools-client.d.ts +0 -2
  224. package/dist/runtime/vue-devtools-client.js +0 -8
  225. package/dist/shared/devtools.COlX0Gls.mjs +0 -114
  226. /package/dist/client/_nuxt/{_plugin-vue_export-helper-n58akrbk.js → _plugin-vue_export-helper-d9irwgla.js} +0 -0
  227. /package/dist/client/_nuxt/{color-b9xoe9j2.js → color-abaog8vc.js} +0 -0
  228. /package/dist/client/_nuxt/{composables-b2ccklz4.js → composables-ioamscf4.js} +0 -0
  229. /package/dist/client/_nuxt/{constants-ih922r91.js → constants-g2z8m4rs.js} +0 -0
  230. /package/dist/client/_nuxt/{dist-m49wlq01.js → dist-das2ggjj.js} +0 -0
@@ -1,24 +1,24 @@
1
- import fs$1, { existsSync, promises, statSync, realpathSync, readFileSync, accessSync, constants } from 'node:fs';
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 { logger, useNuxt, addVitePlugin, addPlugin, addTemplate, extendViteConfig, addImports } from '@nuxt/kit';
4
+ import { onDevtoolsReady, NUXT_DEVTOOLS_GROUP_ID, deprecate, registerHostDiagnostics } 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 as dirname$1, resolve, isAbsolute } from 'pathe';
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, a as defaultTabOptions, W as WS_EVENT_NAME } from '../shared/devtools.COlX0Gls.mjs';
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.CCWq4fFE.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';
12
+ import { registerDataSource, createDataInspectorDevframe } from '@devframes/plugin-data-inspector';
13
+ import { mountDevframe } from '@vitejs/devtools-kit/node';
16
14
  import { x } from 'tinyexec';
17
15
  import { glob } from 'tinyglobby';
16
+ import path, { relative, parse, dirname as dirname$1 } from 'node:path';
18
17
  import { imageMeta } from 'image-meta';
19
18
  import { debounce } from 'perfect-debounce';
20
19
  import destr from 'destr';
21
20
  import { setupHooksDebug } from '../../dist/runtime/shared/hooks.js';
21
+ import { hash } from 'ohash';
22
22
  import process$1 from 'node:process';
23
23
  import { builtinModules, createRequire } from 'node:module';
24
24
  import { resolvePackageJSON, readPackageJSON } from 'pkg-types';
@@ -29,124 +29,165 @@ import { format, inspect } from 'node:util';
29
29
  import { resolveModule, getPackageInfo } from 'local-pkg';
30
30
  import { parseModule } from 'magicast';
31
31
  import { getDefaultExportOptions, addNuxtModule } from 'magicast/helpers';
32
- import semver from 'semver';
33
- import { normalizeBaseKey, normalizeKey } from 'unstorage';
32
+ import { isLess } from 'verkit';
33
+ import { DEVTOOLS_TERMINALS_DOCK_ID } from '@vitejs/devtools-kit/constants';
34
+ import { normalizeBaseKey, normalizeKey, createStorage, builtinDrivers } from 'unstorage';
34
35
 
35
- const version$1 = "4.0.0-alpha.1";
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
- }
36
+ const version$1 = "4.0.0-alpha.10";
46
37
 
47
- function getHomeDir() {
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`);
38
+ const captured = {};
39
+ function normalizeViteConfig(config) {
76
40
  return {
77
- filePath,
78
- hashedKey
41
+ ...config,
42
+ environments: Object.fromEntries(
43
+ Object.entries(config.env ?? {}).map(([key, _]) => {
44
+ return [key, null];
45
+ })
46
+ ),
47
+ plugins: (config.plugins ?? []).map((i) => {
48
+ const clone = { ...i };
49
+ delete clone.api;
50
+ return clone;
51
+ }),
52
+ inlineConfig: null
79
53
  };
80
54
  }
81
- async function clearLocalOptions(options) {
82
- const { filePath } = getOptionsFilepath(options);
83
- if (existsSync(filePath))
84
- await fs.unlink(filePath);
55
+ function setup(ctx) {
56
+ const { nuxt } = ctx;
57
+ nuxt.hook("nitro:build:before", (nitro) => {
58
+ captured.nitro = nitro;
59
+ });
60
+ nuxt.hook("vite:serverCreated", (server) => {
61
+ captured.vite = server;
62
+ });
63
+ const dataSource = registerDataSource({
64
+ id: "nuxt:application",
65
+ title: "Nuxt Application",
66
+ description: "Live Nuxt, Nitro, and Vite configuration",
67
+ icon: "i-ph:database-duotone",
68
+ static: false,
69
+ data: () => ({
70
+ nuxt: nuxt.options,
71
+ nitro: captured.nitro?.options,
72
+ vite: captured.vite
73
+ }),
74
+ queries: [
75
+ { title: "Overview", query: "", excludeFunctions: true },
76
+ { title: "Nuxt modules", query: "nuxt.modules", excludeFunctions: true },
77
+ { title: "Vite plugins", query: "vite.config.plugins", excludeFunctions: true },
78
+ { title: "Vite config", query: "vite.config", excludeFunctions: true },
79
+ { title: "Vite environments", query: "vite.environments", excludeFunctions: true },
80
+ { title: "Nitro routes", query: "nitro.handlers", excludeFunctions: true }
81
+ ]
82
+ });
83
+ nuxt.hook("close", () => {
84
+ dataSource.unregister();
85
+ captured.nitro = void 0;
86
+ captured.vite = void 0;
87
+ });
88
+ const definition = createDataInspectorDevframe({ exampleSource: false });
89
+ onDevtoolsReady((kit) => {
90
+ return mountDevframe(kit, definition, {
91
+ dock: {
92
+ groupId: NUXT_DEVTOOLS_GROUP_ID,
93
+ category: "advanced"
94
+ }
95
+ });
96
+ }, nuxt);
85
97
  }
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
- );
98
+ function getServerData(nuxt) {
99
+ deprecate(nuxt, "NDT_DEP_0009", {
100
+ api: "getServerData()",
101
+ replacement: "the Nuxt Application source in the Data Inspector panel"
102
+ });
103
+ const config = captured.vite?.config;
104
+ return {
105
+ nuxt: nuxt.options,
106
+ nitro: captured.nitro?.options,
107
+ vite: {
108
+ server: config ? normalizeViteConfig(config) : void 0,
109
+ client: config ? normalizeViteConfig(config) : void 0
110
+ }
111
+ // `nuxt.options` is `@nuxt/schema`'s `NuxtOptions` while `NuxtServerData`
112
+ // pins the structurally-identical `nuxt/schema` one; bridge the two.
113
+ };
102
114
  }
103
115
 
104
- let token;
105
- async function getDevAuthToken() {
106
- if (token)
107
- return token;
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;
116
+ const dataInspector = {
117
+ __proto__: null,
118
+ getServerData: getServerData,
119
+ setup: setup
120
+ };
121
+
122
+ const RPC_NAMESPACE = "nuxt:devtools";
123
+
124
+ let counter = 0;
125
+ function createUniqueSessionId(baseId) {
126
+ counter += 1;
127
+ return `${baseId}#${counter}`;
118
128
  }
119
129
 
120
130
  const COLON_RE = /:/g;
121
- function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
131
+ function setupAnalyzeBuildRPC(ctx) {
132
+ const { nuxt, refresh } = ctx;
122
133
  let builds = [];
123
134
  let promise;
124
135
  let initalized;
125
- const processId = "devtools:analyze-build";
136
+ let activeSessionId;
126
137
  const devtoolsAnalyzeDir = join(nuxt.options.rootDir, "node_modules/.cache/nuxt-devtools/analyze");
127
138
  async function startAnalyzeBuild(name) {
128
139
  if (promise)
129
140
  throw new Error("[Nuxt DevTools] A building process is already running");
130
- const result = startSubprocess({
141
+ const kit = ctx.devtoolsKit;
142
+ if (!kit)
143
+ throw new Error("[Nuxt DevTools] Vite DevTools kit is not connected yet.");
144
+ const sessionId = createUniqueSessionId("devtools:analyze-build");
145
+ activeSessionId = sessionId;
146
+ const session = await kit.terminals.startChildProcess({
131
147
  command: "npx",
132
148
  args: ["nuxi", "analyze", "--no-serve", "--name", name],
133
149
  cwd: nuxt.options.rootDir
134
150
  }, {
135
- id: processId,
136
- name: "Analyze Build",
151
+ id: sessionId,
152
+ title: "Analyze Build",
137
153
  icon: "logos-nuxt-icon"
138
- }, nuxt);
154
+ });
139
155
  refresh("getAnalyzeBuildInfo");
140
156
  initalized = void 0;
141
- promise = Promise.resolve(result.getResult()).then(() => {
157
+ promise = Promise.resolve(session.getResult()).then((result) => {
158
+ if (result.exitCode && result.exitCode !== 0) {
159
+ ctx.notify({
160
+ message: `Build analysis "${name}" failed`,
161
+ level: "error",
162
+ description: `Process exited with code ${result.exitCode}. Check the Analyze Build terminal for details.`,
163
+ category: "build",
164
+ notify: true
165
+ });
166
+ } else {
167
+ ctx.notify({
168
+ message: `Build analysis "${name}" complete`,
169
+ level: "success",
170
+ category: "build",
171
+ notify: true
172
+ });
173
+ }
142
174
  refresh("getAnalyzeBuildInfo");
143
175
  return readBuildInfo();
176
+ }).catch((error) => {
177
+ ctx.notify({
178
+ message: `Build analysis "${name}" failed`,
179
+ level: "error",
180
+ description: error instanceof Error ? error.message : String(error),
181
+ category: "build",
182
+ notify: true
183
+ });
144
184
  }).finally(() => {
145
185
  promise = void 0;
146
186
  initalized = void 0;
187
+ activeSessionId = void 0;
147
188
  refresh("getAnalyzeBuildInfo");
148
189
  });
149
- return processId;
190
+ return sessionId;
150
191
  }
151
192
  async function readBuildInfo() {
152
193
  for (const dir of /* @__PURE__ */ new Set([
@@ -161,7 +202,7 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
161
202
  });
162
203
  for (const file of files2) {
163
204
  const slug = JSON.parse(await fs.readFile(file, "utf-8")).slug;
164
- const dir2 = dirname$1(file);
205
+ const dir2 = dirname(file);
165
206
  await fs.mkdir(devtoolsAnalyzeDir, { recursive: true });
166
207
  await fs.rename(dir2, join(devtoolsAnalyzeDir, slug));
167
208
  }
@@ -172,7 +213,7 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
172
213
  absolute: true
173
214
  });
174
215
  builds = await Promise.all(files.map(async (file) => {
175
- const dir = dirname$1(file);
216
+ const dir = dirname(file);
176
217
  const json = JSON.parse(await fs.readFile(file, "utf-8"));
177
218
  return {
178
219
  ...json,
@@ -209,11 +250,11 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
209
250
  await initalized;
210
251
  return {
211
252
  isBuilding: !!promise,
253
+ activeSessionId,
212
254
  builds
213
255
  };
214
256
  },
215
- async clearAnalyzeBuilds(token, names) {
216
- await ensureDevAuthToken(token);
257
+ async clearAnalyzeBuilds(names) {
217
258
  if (!names) {
218
259
  await fs.rm(devtoolsAnalyzeDir, { recursive: true, force: true });
219
260
  } else {
@@ -224,14 +265,13 @@ function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }) {
224
265
  refresh("getAnalyzeBuildInfo");
225
266
  },
226
267
  generateAnalyzeBuildName,
227
- async startAnalyzeBuild(token, ...args) {
228
- await ensureDevAuthToken(token);
268
+ async startAnalyzeBuild(...args) {
229
269
  return startAnalyzeBuild(...args);
230
270
  }
231
271
  };
232
272
  }
233
273
 
234
- function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
274
+ function setupAssetsRPC({ nuxt, refresh, options }) {
235
275
  const _imageMetaCache = /* @__PURE__ */ new Map();
236
276
  let cache = null;
237
277
  const extensions = options.assets?.uploadExtensions || defaultAllowedExtensions;
@@ -287,8 +327,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
287
327
  async getStaticAssets() {
288
328
  return await scan();
289
329
  },
290
- async getImageMeta(token, filepath) {
291
- await ensureDevAuthToken(token);
330
+ async getImageMeta(filepath) {
292
331
  if (_imageMetaCache.has(filepath))
293
332
  return _imageMetaCache.get(filepath);
294
333
  try {
@@ -301,8 +340,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
301
340
  return void 0;
302
341
  }
303
342
  },
304
- async getTextAssetContent(token, filepath, limit = 300) {
305
- await ensureDevAuthToken(token);
343
+ async getTextAssetContent(filepath, limit = 300) {
306
344
  try {
307
345
  const content = await fs.readFile(filepath, "utf-8");
308
346
  return content.slice(0, limit);
@@ -311,8 +349,7 @@ function setupAssetsRPC({ nuxt, ensureDevAuthToken, refresh, options }) {
311
349
  return void 0;
312
350
  }
313
351
  },
314
- async writeStaticAssets(token, files, folder) {
315
- await ensureDevAuthToken(token);
352
+ async writeStaticAssets(files, folder) {
316
353
  const baseDir = resolve(nuxt.options.srcDir, nuxt.options.dir.public + folder);
317
354
  return await Promise.all(
318
355
  files.map(async ({ path, content, encoding, override }) => {
@@ -343,12 +380,10 @@ You can configure it in Nuxt config at \`devtools.assets.uploadExtensions\`.`);
343
380
  })
344
381
  );
345
382
  },
346
- async deleteStaticAsset(token, path) {
347
- await ensureDevAuthToken(token);
383
+ async deleteStaticAsset(path) {
348
384
  return await fs.unlink(path);
349
385
  },
350
- async renameStaticAsset(token, oldPath, newPath) {
351
- await ensureDevAuthToken(token);
386
+ async renameStaticAsset(oldPath, newPath) {
352
387
  const exist = cache?.find((asset) => asset.filePath === newPath);
353
388
  if (exist)
354
389
  throw new Error(`[Nuxt DevTools] File ${newPath} already exists, failed to rename`);
@@ -818,6 +853,9 @@ var defaultOptions = {
818
853
  // Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
819
854
  // strict mode and parsing of `import` and `export` declarations.
820
855
  sourceType: "script",
856
+ // When set to true, enable strict parsing mode even if `sourceType`
857
+ // is `"script"`.
858
+ strict: false,
821
859
  // `onInsertedSemicolon` can be a callback that will be called when
822
860
  // a semicolon is automatically inserted. It will be passed the
823
861
  // position of the inserted semicolon as an offset, and if
@@ -859,6 +897,11 @@ var defaultOptions = {
859
897
  // line being 1-based and column 0-based) will be attached to the
860
898
  // nodes.
861
899
  locations: false,
900
+ // Pass an optional `{line, column}` object to use for the start of
901
+ // the parse. This is mostly useful when using `parseExpressionAt`
902
+ // with `locations: true`, to prevent the parser from having to
903
+ // determine the line position at the start position.
904
+ startLocation: null,
862
905
  // A function can be passed as `onToken` option, which will
863
906
  // cause Acorn to call that function with object in the same
864
907
  // format as tokens returned from `tokenizer().getToken()`. Note
@@ -1012,13 +1055,17 @@ var Parser = function Parser(options, input, startPos) {
1012
1055
  // Set up token state
1013
1056
 
1014
1057
  // The current position of the tokenizer in the input.
1015
- if (startPos) {
1016
- this.pos = startPos;
1058
+ this.pos = startPos || 0;
1059
+ this.curLine = 1;
1060
+ if (options.startLocation) {
1061
+ this.lineStart = this.pos - options.startLocation.column;
1062
+ this.curLine = options.startLocation.line;
1063
+ } else if (startPos) {
1017
1064
  this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
1018
- this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
1065
+ if (this.options.locations)
1066
+ { this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; }
1019
1067
  } else {
1020
- this.pos = this.lineStart = 0;
1021
- this.curLine = 1;
1068
+ this.lineStart = 0;
1022
1069
  }
1023
1070
 
1024
1071
  // Properties of the current token:
@@ -1044,7 +1091,7 @@ var Parser = function Parser(options, input, startPos) {
1044
1091
 
1045
1092
  // Figure out if it's a module code.
1046
1093
  this.inModule = options.sourceType === "module";
1047
- this.strict = this.inModule || this.strictDirective(this.pos);
1094
+ this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
1048
1095
 
1049
1096
  // Used to signify the start of a potential arrow function
1050
1097
  this.potentialArrowAt = -1;
@@ -1082,9 +1129,11 @@ var Parser = function Parser(options, input, startPos) {
1082
1129
  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
1130
 
1084
1131
  Parser.prototype.parse = function parse () {
1132
+ var this$1$1 = this;
1133
+
1085
1134
  var node = this.options.program || this.startNode();
1086
1135
  this.nextToken();
1087
- return this.parseTopLevel(node)
1136
+ return this.catchStackOverflow(function () { return this$1$1.parseTopLevel(node); })
1088
1137
  };
1089
1138
 
1090
1139
  prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
@@ -1223,6 +1272,17 @@ pp$9.eatContextual = function(name) {
1223
1272
  return true
1224
1273
  };
1225
1274
 
1275
+ pp$9.catchStackOverflow = function(f) {
1276
+ try {
1277
+ return f()
1278
+ } catch (e) {
1279
+ if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message)))
1280
+ { this.raise(this.start, "Not enough stack space to parse input"); }
1281
+ else
1282
+ { throw e }
1283
+ }
1284
+ };
1285
+
1226
1286
  // Asserts that following token is given contextual keyword.
1227
1287
 
1228
1288
  pp$9.expectContextual = function(name) {
@@ -1418,7 +1478,18 @@ pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
1418
1478
  while (isIdentifierChar(ch = this.fullCharCodeAt(next)))
1419
1479
  if (ch === 92) { return true }
1420
1480
  var id = this.input.slice(idStart, next);
1421
- if (keywordRelationalOperator.test(id) || isFor && id === "of") { return false }
1481
+ if (keywordRelationalOperator.test(id)) { return false }
1482
+ if (isFor && !isAwaitUsing && id === "of") {
1483
+ // Look ahead for using declaration with initializer, i.e., `for (using of = ...)`
1484
+ skipWhiteSpace.lastIndex = next;
1485
+ var skipAfterOf = skipWhiteSpace.exec(this.input);
1486
+ next = next + skipAfterOf[0].length;
1487
+ if (this.input.charCodeAt(next) !== 61 /* '=' */ ||
1488
+ // Check for ==, === and => operators
1489
+ (ch = this.input.charCodeAt(next + 1)) === 61 /* '=' */ || ch === 62 /* '>' */) {
1490
+ return false
1491
+ }
1492
+ }
1422
1493
  return true
1423
1494
  };
1424
1495
 
@@ -1511,6 +1582,10 @@ pp$8.parseStatement = function(context, topLevel, exports$1) {
1511
1582
  if (!this.allowUsing) {
1512
1583
  this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
1513
1584
  }
1585
+ if (context) {
1586
+ // Cases like `for (;;) using x = ...;`, `if (true) await using x = ...;`, etc. are not allowed.
1587
+ this.raise(this.start, "Using declaration is not allowed in single-statement positions");
1588
+ }
1514
1589
  if (usingKind === "await using") {
1515
1590
  if (!this.canAwait) {
1516
1591
  this.raise(this.start, "Await using cannot appear outside of async function");
@@ -1644,11 +1719,12 @@ pp$8.parseForStatement = function(node) {
1644
1719
  // Helper method to parse for loop after variable initialization
1645
1720
  pp$8.parseForAfterInit = function(node, init, awaitAt) {
1646
1721
  if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) {
1647
- if (this.options.ecmaVersion >= 9) {
1648
- if (this.type === types$1._in) {
1649
- if (awaitAt > -1) { this.unexpected(awaitAt); }
1650
- } else { node.await = awaitAt > -1; }
1651
- }
1722
+ if (this.type === types$1._in) {
1723
+ if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) {
1724
+ this.raise(this.start, "Using declaration is not allowed in for-in loops");
1725
+ }
1726
+ if (this.options.ecmaVersion >= 9 && awaitAt > -1) { this.unexpected(awaitAt); }
1727
+ } else if (this.options.ecmaVersion >= 9) { node.await = awaitAt > -1; }
1652
1728
  return this.parseForIn(node, init)
1653
1729
  }
1654
1730
  if (awaitAt > -1) { this.unexpected(awaitAt); }
@@ -3155,15 +3231,19 @@ pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
3155
3231
  // delayed syntax error at correct position).
3156
3232
 
3157
3233
  pp$5.parseExpression = function(forInit, refDestructuringErrors) {
3158
- var startPos = this.start, startLoc = this.startLoc;
3159
- var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
3160
- if (this.type === types$1.comma) {
3161
- var node = this.startNodeAt(startPos, startLoc);
3162
- node.expressions = [expr];
3163
- while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
3164
- return this.finishNode(node, "SequenceExpression")
3165
- }
3166
- return expr
3234
+ var this$1$1 = this;
3235
+
3236
+ return this.catchStackOverflow(function () {
3237
+ var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
3238
+ var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
3239
+ if (this$1$1.type === types$1.comma) {
3240
+ var node = this$1$1.startNodeAt(startPos, startLoc);
3241
+ node.expressions = [expr];
3242
+ while (this$1$1.eat(types$1.comma)) { node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors)); }
3243
+ return this$1$1.finishNode(node, "SequenceExpression")
3244
+ }
3245
+ return expr
3246
+ })
3167
3247
  };
3168
3248
 
3169
3249
  // Parse an assignment expression. This includes applications of
@@ -3228,7 +3308,7 @@ pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
3228
3308
  var startPos = this.start, startLoc = this.startLoc;
3229
3309
  var expr = this.parseExprOps(forInit, refDestructuringErrors);
3230
3310
  if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
3231
- if (this.eat(types$1.question)) {
3311
+ if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
3232
3312
  var node = this.startNodeAt(startPos, startLoc);
3233
3313
  node.test = expr;
3234
3314
  node.consequent = this.parseMaybeAssign();
@@ -3328,7 +3408,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
3328
3408
  }
3329
3409
  }
3330
3410
 
3331
- if (!incDec && this.eat(types$1.starstar)) {
3411
+ if (!incDec && !(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.starstar)) {
3332
3412
  if (sawUnary)
3333
3413
  { this.unexpected(this.lastTokStart); }
3334
3414
  else
@@ -3780,6 +3860,8 @@ pp$5.parseNew = function() {
3780
3860
  }
3781
3861
  var startPos = this.start, startLoc = this.startLoc;
3782
3862
  node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
3863
+ if (node.callee.type === "Super")
3864
+ { this.raiseRecoverable(startPos, "Invalid use of 'super'"); }
3783
3865
  if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
3784
3866
  else { node.arguments = empty; }
3785
3867
  return this.finishNode(node, "NewExpression")
@@ -6696,7 +6778,7 @@ pp.readWord = function() {
6696
6778
  // [ghbt]: https://github.com/acornjs/acorn/issues
6697
6779
 
6698
6780
 
6699
- var version = "8.16.0";
6781
+ var version = "8.18.0";
6700
6782
 
6701
6783
  Parser.acorn = {
6702
6784
  Parser: Parser,
@@ -9068,7 +9150,11 @@ function _extractExtraNames(extraNamesStr) {
9068
9150
  angleDepth++;
9069
9151
  continue;
9070
9152
  }
9071
- if (inTypeAnnotation && char === ">" && angleDepth > 0) {
9153
+ if (!inTypeAnnotation && char === "<" && depth === 0 && i > 0 && _isIdentifierBeforeAngleBracket(extraNamesStr, i)) {
9154
+ angleDepth++;
9155
+ continue;
9156
+ }
9157
+ if (char === ">" && angleDepth > 0 && extraNamesStr[i - 1] !== "=") {
9072
9158
  angleDepth--;
9073
9159
  continue;
9074
9160
  }
@@ -9233,6 +9319,14 @@ function _getLocations(code, label) {
9233
9319
  }
9234
9320
  return locations;
9235
9321
  }
9322
+ function _isIdentifierBeforeAngleBracket(str, i) {
9323
+ let j = i - 1;
9324
+ while (j >= 0 && /[A-Za-z0-9_$]/.test(str[j])) {
9325
+ j--;
9326
+ }
9327
+ const wordStart = j + 1;
9328
+ return wordStart < i && /[A-Za-z_$]/.test(str[wordStart]);
9329
+ }
9236
9330
 
9237
9331
  function defineUnimportPreset(preset) {
9238
9332
  return preset;
@@ -9275,7 +9369,7 @@ async function extractExports(name, url, cache = true) {
9275
9369
  return JSON.parse(await promises.readFile(cachePath, "utf-8"));
9276
9370
  const scanned = await resolveModuleExportNames(name, { url });
9277
9371
  if (useCache) {
9278
- await promises.mkdir(dirname$1(cachePath), { recursive: true });
9372
+ await promises.mkdir(dirname(cachePath), { recursive: true });
9279
9373
  await promises.writeFile(cachePath, JSON.stringify(scanned), "utf-8");
9280
9374
  }
9281
9375
  return scanned;
@@ -10256,23 +10350,82 @@ function safeKey(key) {
10256
10350
  return JSON.stringify(key);
10257
10351
  }
10258
10352
 
10353
+ function getHomeDir() {
10354
+ return process.env.XDG_CONFIG_HOME || homedir();
10355
+ }
10356
+ async function readLocalOptions(defaults, options) {
10357
+ const { filePath } = getOptionsFilepath(options);
10358
+ if (existsSync(filePath)) {
10359
+ try {
10360
+ const options2 = {
10361
+ ...defaults,
10362
+ ...JSON.parse(await fs.readFile(filePath, "utf-8")).settings || {}
10363
+ };
10364
+ return options2;
10365
+ } catch (e) {
10366
+ console.error(`[DevTools] failed to parse local options file: ${filePath}, fallback to defaults`);
10367
+ console.error(e);
10368
+ return { ...defaults };
10369
+ }
10370
+ } else {
10371
+ return { ...defaults };
10372
+ }
10373
+ }
10374
+ function getOptionsFilepath(options) {
10375
+ let hashedKey;
10376
+ if (options.key)
10377
+ hashedKey = hash(`${options.root}:${options.key}`);
10378
+ else
10379
+ hashedKey = hash(options.root);
10380
+ const home = getHomeDir();
10381
+ const filePath = join(home, ".nuxt/devtools", `${hashedKey}.json`);
10382
+ return {
10383
+ filePath,
10384
+ hashedKey
10385
+ };
10386
+ }
10387
+ async function clearLocalOptions(options) {
10388
+ const { filePath } = getOptionsFilepath(options);
10389
+ if (existsSync(filePath))
10390
+ await fs.unlink(filePath);
10391
+ }
10392
+ async function writeLocalOptions(settings, options) {
10393
+ const { filePath, hashedKey } = getOptionsFilepath(options);
10394
+ await fs.mkdir(dirname$1(filePath), { recursive: true });
10395
+ await fs.writeFile(
10396
+ filePath,
10397
+ JSON.stringify(
10398
+ {
10399
+ root: options.root,
10400
+ hash: hashedKey,
10401
+ settings
10402
+ },
10403
+ null,
10404
+ 2
10405
+ ),
10406
+ "utf-8"
10407
+ );
10408
+ }
10409
+
10259
10410
  let options;
10260
10411
  function getOptions() {
10261
10412
  return options;
10262
10413
  }
10263
10414
  function setupOptionsRPC({ nuxt }) {
10415
+ const hasReadOnce = /* @__PURE__ */ new Set();
10264
10416
  async function getOptions2(tab) {
10265
- if (!options || options[tab]) {
10266
- options = defaultTabOptions;
10417
+ if (!options)
10418
+ options = createDefaultTabOptions();
10419
+ if (!hasReadOnce.has(tab))
10267
10420
  await read(tab);
10268
- }
10269
10421
  return options[tab];
10270
10422
  }
10271
10423
  async function read(tab) {
10272
- options[tab] = await readLocalOptions(defaultTabOptions[tab], {
10424
+ options[tab] = await readLocalOptions(createDefaultTabOptions()[tab], {
10273
10425
  root: nuxt.options.rootDir,
10274
10426
  key: tab !== "ui" && tab
10275
10427
  });
10428
+ hasReadOnce.add(tab);
10276
10429
  return options;
10277
10430
  }
10278
10431
  getOptions2("ui");
@@ -10306,13 +10459,11 @@ function setupOptionsRPC({ nuxt }) {
10306
10459
 
10307
10460
  const ABSOLUTE_PATH_RE = /^[a-z]:|^\//i;
10308
10461
  const FILE_LINE_COL_RE = /^(.*?)(:[:\d]*)$/;
10309
- const MULTIPLE_SLASHES_RE$1 = /\/+/g;
10310
10462
  const NUXT_WELCOME_RE = /<NuxtWelcome\s*\/>/;
10311
10463
  function setupGeneralRPC({
10312
10464
  nuxt,
10313
10465
  options,
10314
10466
  refresh,
10315
- ensureDevAuthToken,
10316
10467
  openInEditorHooks
10317
10468
  }) {
10318
10469
  const components = [];
@@ -10496,8 +10647,7 @@ function setupGeneralRPC({
10496
10647
  return false;
10497
10648
  }
10498
10649
  },
10499
- async enablePages(token) {
10500
- await ensureDevAuthToken(token);
10650
+ async enablePages() {
10501
10651
  const baseDir = nuxt.options.future.compatibilityVersion === 4 ? nuxt.options.dir.app : nuxt.options.srcDir;
10502
10652
  const pathApp = join(baseDir, "app.vue");
10503
10653
  const pathPageIndex = join(baseDir, "pages/index.vue");
@@ -10517,7 +10667,7 @@ const route = useRoute()
10517
10667
  </div>
10518
10668
  </template>
10519
10669
  `;
10520
- await fs.mkdir(dirname$1(pathPageIndex), { recursive: true });
10670
+ await fs.mkdir(dirname(pathPageIndex), { recursive: true });
10521
10671
  await fs.writeFile(pathPageIndex, pagesIndexTemplate, "utf-8");
10522
10672
  let appContent = existsSync(pathApp) ? await fs.readFile(pathApp, "utf-8") : void 0;
10523
10673
  if (appContent && !appContent.includes("<NuxtPage")) {
@@ -10526,40 +10676,63 @@ const route = useRoute()
10526
10676
  }
10527
10677
  logger.success("Routing creation completed");
10528
10678
  },
10529
- async restartNuxt(token, hard = true) {
10530
- await ensureDevAuthToken(token);
10679
+ async restartNuxt(hard = true) {
10531
10680
  logger.info("Restarting Nuxt...");
10532
10681
  return nuxt.callHook("restart", { hard });
10533
10682
  },
10534
- async requestForAuth(info, origin) {
10535
- if (options.disableAuthorization)
10536
- return;
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
- });
10683
+ /** @deprecated Auth is now handled by Vite DevTools */
10684
+ async requestForAuth() {
10685
+ logger.warn("[nuxt-devtools] `requestForAuth` is deprecated. Auth is now handled by Vite DevTools.");
10558
10686
  },
10559
- async verifyAuthToken(token) {
10560
- if (options.disableAuthorization)
10561
- return true;
10562
- return token === await getDevAuthToken();
10687
+ /** @deprecated Auth is now handled by Vite DevTools */
10688
+ async verifyAuthToken() {
10689
+ logger.warn("[nuxt-devtools] `verifyAuthToken` is deprecated. Auth is now handled by Vite DevTools.");
10690
+ return true;
10691
+ }
10692
+ };
10693
+ }
10694
+
10695
+ function toEntryInput(input) {
10696
+ return {
10697
+ message: input.message,
10698
+ level: input.level ?? "info",
10699
+ description: input.description,
10700
+ labels: input.labels,
10701
+ category: input.category,
10702
+ filePosition: input.filePosition,
10703
+ stacktrace: input.stacktrace,
10704
+ notify: input.notify,
10705
+ autoDismiss: input.autoDismiss,
10706
+ autoDelete: input.autoDelete
10707
+ };
10708
+ }
10709
+ function createNotifier(nuxt) {
10710
+ let messages;
10711
+ const pending = [];
10712
+ function add(input) {
10713
+ void messages.add(toEntryInput(input)).catch(() => {
10714
+ });
10715
+ }
10716
+ function notify(input) {
10717
+ if (!messages) {
10718
+ pending.push(input);
10719
+ return;
10720
+ }
10721
+ add(input);
10722
+ }
10723
+ onDevtoolsReady((kit) => {
10724
+ messages = kit.messages;
10725
+ for (const input of pending)
10726
+ add(input);
10727
+ pending.length = 0;
10728
+ }, nuxt);
10729
+ nuxt.hook("devtools:notify", notify);
10730
+ return notify;
10731
+ }
10732
+ function setupMessagesRPC(ctx) {
10733
+ return {
10734
+ async notify(input) {
10735
+ ctx.notify(input);
10563
10736
  }
10564
10737
  };
10565
10738
  }
@@ -10570,13 +10743,19 @@ const AGENTS = [
10570
10743
  "yarn@berry",
10571
10744
  "pnpm",
10572
10745
  "pnpm@6",
10746
+ "pnpm-rush",
10573
10747
  "bun",
10574
- "deno"
10748
+ "deno",
10749
+ "nub",
10750
+ "aube"
10575
10751
  ];
10576
10752
  const LOCKS = {
10753
+ "aube-lock.yaml": "aube",
10754
+ "aube-workspace.yaml": "aube",
10577
10755
  "bun.lock": "bun",
10578
10756
  "bun.lockb": "bun",
10579
10757
  "deno.lock": "deno",
10758
+ "nub.lock": "nub",
10580
10759
  "pnpm-lock.yaml": "pnpm",
10581
10760
  "pnpm-workspace.yaml": "pnpm",
10582
10761
  "yarn.lock": "yarn",
@@ -10584,6 +10763,7 @@ const LOCKS = {
10584
10763
  "npm-shrinkwrap.json": "npm"
10585
10764
  };
10586
10765
  const INSTALL_METADATA = {
10766
+ "node_modules/.aube/": "aube",
10587
10767
  "node_modules/.deno/": "deno",
10588
10768
  "node_modules/.pnpm/": "pnpm",
10589
10769
  "node_modules/.yarn-state.yml": "yarn",
@@ -10636,6 +10816,9 @@ async function detect(options = {}) {
10636
10816
  for (const strategy of strategies) {
10637
10817
  switch (strategy) {
10638
10818
  case "lockfile": {
10819
+ if (await pathExists(path.join(directory, "rush.json"), "file")) {
10820
+ return { name: "pnpm", agent: "pnpm-rush" };
10821
+ }
10639
10822
  for (const lock of Object.keys(LOCKS)) {
10640
10823
  if (await pathExists(path.join(directory, lock), "file")) {
10641
10824
  const name = LOCKS[lock];
@@ -11103,7 +11286,7 @@ async function checkForUpdateOf(name, current, nuxt = useNuxt()) {
11103
11286
  const { version: latest } = await getLatestVersion(name, {
11104
11287
  fetch
11105
11288
  });
11106
- const needsUpdate = !!latest && latest !== current && semver.lt(current, latest);
11289
+ const needsUpdate = !!latest && latest !== current && isLess(current, latest);
11107
11290
  return {
11108
11291
  name,
11109
11292
  current,
@@ -11127,7 +11310,179 @@ async function magicastGuard(fn, message = "") {
11127
11310
  return generated;
11128
11311
  }
11129
11312
 
11130
- function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
11313
+ function removeNuxtModuleFromCode(source, name, filepath) {
11314
+ const mod = parseModule(source, filepath ? { sourceFileName: filepath } : void 0);
11315
+ const config = getDefaultExportOptions(mod);
11316
+ if (!Array.isArray(config.modules))
11317
+ return mod.generate().code;
11318
+ for (let i = config.modules.length - 1; i >= 0; i--) {
11319
+ const entry = config.modules[i];
11320
+ const matches = typeof entry === "string" ? entry === name : Array.isArray(entry) && entry[0] === name;
11321
+ if (matches)
11322
+ config.modules.splice(i, 1);
11323
+ }
11324
+ return mod.generate().code;
11325
+ }
11326
+
11327
+ function broadcastTerminalExit(ctx, id, code) {
11328
+ ctx.devtoolsKit?.rpc.broadcast({ method: "onTerminalExit", args: [{ id, code }], event: true });
11329
+ }
11330
+ function statusForExit(code) {
11331
+ return code == null || code === 0 ? "stopped" : "error";
11332
+ }
11333
+ function setupTerminalsBridge(ctx) {
11334
+ const { nuxt } = ctx;
11335
+ const runs = /* @__PURE__ */ new Map();
11336
+ const generations = /* @__PURE__ */ new Map();
11337
+ let host;
11338
+ function createRun(terminal) {
11339
+ const legacyId = terminal.id;
11340
+ const generation = (generations.get(legacyId) ?? 0) + 1;
11341
+ generations.set(legacyId, generation);
11342
+ let controller;
11343
+ const stream = new ReadableStream({
11344
+ start(c) {
11345
+ controller = c;
11346
+ }
11347
+ });
11348
+ const session = {
11349
+ id: createUniqueSessionId(legacyId),
11350
+ title: terminal.name,
11351
+ description: terminal.description,
11352
+ icon: terminal.icon,
11353
+ status: "running",
11354
+ interactive: false,
11355
+ stream
11356
+ };
11357
+ return {
11358
+ legacyId,
11359
+ sessionId: session.id,
11360
+ generation,
11361
+ session,
11362
+ controller,
11363
+ registered: false,
11364
+ streamClosed: false,
11365
+ pendingChunks: []
11366
+ };
11367
+ }
11368
+ function isCurrent(run) {
11369
+ return runs.get(run.legacyId) === run;
11370
+ }
11371
+ function closeStream(run) {
11372
+ if (run.streamClosed)
11373
+ return;
11374
+ run.streamClosed = true;
11375
+ try {
11376
+ run.controller?.close();
11377
+ } catch {
11378
+ }
11379
+ }
11380
+ function applyExit(run, code) {
11381
+ if (!isCurrent(run) || run.streamClosed)
11382
+ return;
11383
+ closeStream(run);
11384
+ run.session.status = statusForExit(code);
11385
+ host?.update(run.session);
11386
+ }
11387
+ function registerWithHost(run) {
11388
+ if (!host || run.registered || !isCurrent(run))
11389
+ return;
11390
+ host.register(run.session);
11391
+ run.registered = true;
11392
+ for (const chunk of run.pendingChunks) {
11393
+ try {
11394
+ run.controller?.enqueue(chunk);
11395
+ } catch {
11396
+ }
11397
+ }
11398
+ run.pendingChunks.length = 0;
11399
+ if (run.pendingExit) {
11400
+ const { code } = run.pendingExit;
11401
+ run.pendingExit = void 0;
11402
+ applyExit(run, code);
11403
+ }
11404
+ }
11405
+ nuxt.hook("devtools:terminal:register", (terminal) => {
11406
+ const existing = runs.get(terminal.id);
11407
+ if (existing) {
11408
+ closeStream(existing);
11409
+ if (host && existing.registered)
11410
+ host.remove(existing.session);
11411
+ }
11412
+ const run = createRun(terminal);
11413
+ runs.set(terminal.id, run);
11414
+ if (host)
11415
+ registerWithHost(run);
11416
+ return terminal.id;
11417
+ });
11418
+ nuxt.hook("devtools:terminal:write", ({ id, data }) => {
11419
+ const run = runs.get(id);
11420
+ if (!run || run.streamClosed)
11421
+ return false;
11422
+ if (run.registered) {
11423
+ try {
11424
+ run.controller?.enqueue(data);
11425
+ } catch {
11426
+ }
11427
+ } else {
11428
+ run.pendingChunks.push(data);
11429
+ }
11430
+ return true;
11431
+ });
11432
+ nuxt.hook("devtools:terminal:exit", ({ id, code }) => {
11433
+ const run = runs.get(id);
11434
+ if (!run)
11435
+ return false;
11436
+ if (run.registered)
11437
+ applyExit(run, code);
11438
+ else
11439
+ run.pendingExit = { code };
11440
+ return true;
11441
+ });
11442
+ nuxt.hook("devtools:terminal:remove", ({ id }) => {
11443
+ const run = runs.get(id);
11444
+ if (!run)
11445
+ return false;
11446
+ closeStream(run);
11447
+ runs.delete(id);
11448
+ if (host && run.registered)
11449
+ host.remove(run.session);
11450
+ return true;
11451
+ });
11452
+ nuxt.hook("devtools:ready", (kit) => {
11453
+ host = kit.terminals;
11454
+ for (const run of runs.values())
11455
+ registerWithHost(run);
11456
+ });
11457
+ return {
11458
+ /**
11459
+ * Focus the built-in **Terminals** dock on a session (Devframe 0.7
11460
+ * `docks.activate`, driven by the `hub:docks:activate` RPC). Replaces the
11461
+ * old in-client "go to Terminals tab" navigation now that terminals live in
11462
+ * the hub dock. `id` is a unique Devframe session id (from a bridged run or
11463
+ * a `startChildProcess` call). Returns `false` when the kit isn't connected
11464
+ * or the session is unknown.
11465
+ */
11466
+ async revealTerminal(id) {
11467
+ const kit = ctx.devtoolsKit;
11468
+ if (!kit)
11469
+ return false;
11470
+ if (!kit.terminals.sessions.has(id))
11471
+ return false;
11472
+ kit.docks.activate(DEVTOOLS_TERMINALS_DOCK_ID, { sessionId: id });
11473
+ return true;
11474
+ }
11475
+ };
11476
+ }
11477
+
11478
+ function setupNpmRPC(ctx) {
11479
+ const { nuxt } = ctx;
11480
+ function getTerminals() {
11481
+ const kit = ctx.devtoolsKit;
11482
+ if (!kit)
11483
+ throw new Error("[Nuxt DevTools] Vite DevTools kit is not connected yet.");
11484
+ return kit.terminals;
11485
+ }
11131
11486
  let detectPromise;
11132
11487
  const updatesPromise = /* @__PURE__ */ new Map();
11133
11488
  function getPackageManager() {
@@ -11162,15 +11517,18 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
11162
11517
  const args = await getNpmCommand(command, packageName, options);
11163
11518
  if (!args)
11164
11519
  return;
11165
- const processId = `npm:${command}:${packageName}`;
11166
- startSubprocess({
11520
+ const processId = createUniqueSessionId(`npm:${command}:${packageName}`);
11521
+ const session = await getTerminals().startChildProcess({
11167
11522
  command: args[0],
11168
11523
  args: args.slice(1)
11169
11524
  }, {
11170
11525
  id: processId,
11171
- name: `${command} ${packageName}`,
11172
- icon: "i-logos-npm-icon",
11173
- restartable: false
11526
+ title: `${command} ${packageName}`,
11527
+ icon: "i-logos-npm-icon"
11528
+ });
11529
+ void Promise.resolve(session.getResult()).then((result) => {
11530
+ broadcastTerminalExit(ctx, processId, result.exitCode);
11531
+ }).catch(() => {
11174
11532
  });
11175
11533
  return {
11176
11534
  processId
@@ -11185,12 +11543,10 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
11185
11543
  return updatesPromise.get(name);
11186
11544
  },
11187
11545
  getNpmCommand,
11188
- async runNpmCommand(token, ...args) {
11189
- await ensureDevAuthToken(token);
11546
+ async runNpmCommand(...args) {
11190
11547
  return runNpmCommand(...args);
11191
11548
  },
11192
- async installNuxtModule(token, name, dry = true) {
11193
- await ensureDevAuthToken(token);
11549
+ async installNuxtModule(name, dry = true, sessionId) {
11194
11550
  const commands = await getNpmCommand("install", name, { dev: true });
11195
11551
  const filepath = nuxt.options._nuxtConfigFile;
11196
11552
  let source = latestGenerated;
@@ -11200,27 +11556,39 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
11200
11556
  addNuxtModule(mod, name);
11201
11557
  return mod.generate().code;
11202
11558
  });
11203
- const processId = `nuxt:add-module:${name}`;
11559
+ const processId = sessionId ?? createUniqueSessionId(`nuxt:add-module:${name}`);
11204
11560
  if (!dry) {
11205
11561
  latestGenerated = generated;
11206
11562
  installSet.add(name);
11207
- const process = startSubprocess({
11563
+ const session = await getTerminals().startChildProcess({
11208
11564
  command: commands[0],
11209
11565
  args: commands.slice(1)
11210
11566
  }, {
11211
11567
  id: processId,
11212
- name: `Install ${name}`,
11213
- icon: "carbon:intent-request-create",
11214
- restartable: false
11568
+ title: `Install ${name}`,
11569
+ icon: "carbon:intent-request-create"
11215
11570
  });
11216
- const result = await process.getResult();
11571
+ const result = await session.getResult();
11217
11572
  await Promise.resolve();
11218
11573
  installSet.delete(name);
11219
11574
  const code = result.exitCode;
11220
11575
  if (code !== 0) {
11221
11576
  console.error(result.stderr);
11577
+ ctx.notify({
11578
+ message: `Failed to install ${name}`,
11579
+ level: "error",
11580
+ description: `Process exited with code ${code}. Check the Install ${name} terminal for details.`,
11581
+ category: "module",
11582
+ notify: true
11583
+ });
11222
11584
  throw new Error(`[Nuxt DevTools] Failed to install module, process exited with ${code}`);
11223
11585
  }
11586
+ ctx.notify({
11587
+ message: `Installed ${name}`,
11588
+ level: "success",
11589
+ category: "module",
11590
+ notify: true
11591
+ });
11224
11592
  if (installSet.size === 0) {
11225
11593
  latestGenerated = null;
11226
11594
  await fs.writeFile(filepath, generated, "utf-8");
@@ -11233,41 +11601,43 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
11233
11601
  processId
11234
11602
  };
11235
11603
  },
11236
- async uninstallNuxtModule(token, name, dry = true) {
11237
- await ensureDevAuthToken(token);
11604
+ async uninstallNuxtModule(name, dry = true, sessionId) {
11238
11605
  const commands = await getNpmCommand("uninstall", name);
11239
11606
  const filepath = nuxt.options._nuxtConfigFile;
11240
11607
  const source = await fs.readFile(filepath, "utf-8");
11241
11608
  const generated = await magicastGuard(async () => {
11242
- const mod = parseModule(source, { sourceFileName: filepath });
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;
11609
+ return removeNuxtModuleFromCode(source, name, filepath);
11252
11610
  });
11253
- const processId = `nuxt:remove-module:${name}`;
11611
+ const processId = sessionId ?? createUniqueSessionId(`nuxt:remove-module:${name}`);
11254
11612
  if (!dry) {
11255
- const process = startSubprocess({
11613
+ const session = await getTerminals().startChildProcess({
11256
11614
  command: commands[0],
11257
11615
  args: commands.slice(1)
11258
11616
  }, {
11259
11617
  id: processId,
11260
- name: `Uninstall ${name}`,
11261
- icon: "carbon:intent-request-uninstall",
11262
- restartable: false
11618
+ title: `Uninstall ${name}`,
11619
+ icon: "carbon:intent-request-uninstall"
11263
11620
  });
11264
- const result = await process.getResult();
11621
+ const result = await session.getResult();
11265
11622
  await Promise.resolve();
11266
11623
  const code = result.exitCode;
11267
11624
  if (code !== 0) {
11268
11625
  console.error(result.stderr);
11626
+ ctx.notify({
11627
+ message: `Failed to uninstall ${name}`,
11628
+ level: "error",
11629
+ description: `Process exited with code ${code}. Check the Uninstall ${name} terminal for details.`,
11630
+ category: "module",
11631
+ notify: true
11632
+ });
11269
11633
  throw new Error(`[Nuxt DevTools] Failed to uninstall module, process exited with ${code}`);
11270
11634
  }
11635
+ ctx.notify({
11636
+ message: `Uninstalled ${name}`,
11637
+ level: "success",
11638
+ category: "module",
11639
+ notify: true
11640
+ });
11271
11641
  await fs.writeFile(filepath, generated, "utf-8");
11272
11642
  }
11273
11643
  return {
@@ -11280,112 +11650,24 @@ function setupNpmRPC({ nuxt, ensureDevAuthToken }) {
11280
11650
  };
11281
11651
  }
11282
11652
 
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
11653
  function setupServerRoutesRPC({ nuxt, refresh }) {
11365
11654
  let nitro;
11366
- let unwatchStorage;
11655
+ let unhookDevReload;
11367
11656
  let cache = null;
11368
11657
  const refreshDebounced = debounce(() => {
11369
11658
  cache = null;
11370
11659
  refresh("getServerRoutes");
11371
11660
  }, 500);
11372
- nuxt.hook("nitro:init", (_) => {
11373
- nitro = _;
11661
+ nuxt.hook("nitro:init", (_nitro) => {
11662
+ nitro = _nitro;
11374
11663
  cache = null;
11375
11664
  refresh("getServerRoutes");
11665
+ unhookDevReload?.();
11666
+ unhookDevReload = _nitro.hooks.hook("dev:reload", () => refreshDebounced());
11376
11667
  });
11377
- nuxt.hook("ready", async () => {
11378
- if (!nitro)
11379
- return;
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;
11668
+ nuxt.hook("close", () => {
11669
+ unhookDevReload?.();
11670
+ unhookDevReload = void 0;
11389
11671
  });
11390
11672
  function scan() {
11391
11673
  if (cache)
@@ -11419,29 +11701,22 @@ function setupServerRoutesRPC({ nuxt, refresh }) {
11419
11701
 
11420
11702
  function setupServerTasksRPC({ nuxt, refresh }) {
11421
11703
  let nitro;
11422
- let unwatchStorage;
11704
+ let unhookDevReload;
11423
11705
  let cache = null;
11424
11706
  const refreshDebounced = debounce(() => {
11425
11707
  cache = null;
11426
11708
  refresh("getServerTasks");
11427
11709
  }, 500);
11428
- nuxt.hook("nitro:init", (_) => {
11429
- nitro = _;
11710
+ nuxt.hook("nitro:init", (_nitro) => {
11711
+ nitro = _nitro;
11430
11712
  cache = null;
11431
11713
  refresh("getServerTasks");
11714
+ unhookDevReload?.();
11715
+ unhookDevReload = _nitro.hooks.hook("dev:reload", () => refreshDebounced());
11432
11716
  });
11433
- nuxt.hook("ready", async () => {
11434
- if (!nitro)
11435
- return;
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;
11717
+ nuxt.hook("close", () => {
11718
+ unhookDevReload?.();
11719
+ unhookDevReload = void 0;
11445
11720
  });
11446
11721
  function scan() {
11447
11722
  if (cache)
@@ -11454,7 +11729,15 @@ function setupServerTasksRPC({ nuxt, refresh }) {
11454
11729
  };
11455
11730
  }
11456
11731
  return {
11457
- tasks: nitro.options.tasks,
11732
+ // Nitro v3's task config types `handler`/`description` as optional
11733
+ // (they're always populated in practice by Nitro's own task scanner),
11734
+ // so normalize with fallbacks to satisfy `ScannedNitroTasks`.
11735
+ tasks: Object.fromEntries(
11736
+ Object.entries(nitro.options.tasks ?? {}).map(([name, task]) => [
11737
+ name,
11738
+ { handler: task.handler ?? "", description: task.description ?? "" }
11739
+ ])
11740
+ ),
11458
11741
  scheduledTasks: Object.entries(nitro.options.scheduledTasks ?? {}).reduce((acc, [cron, tasks]) => {
11459
11742
  acc[cron] = Array.isArray(tasks) ? tasks : [tasks];
11460
11743
  return acc;
@@ -11470,24 +11753,53 @@ function setupServerTasksRPC({ nuxt, refresh }) {
11470
11753
  };
11471
11754
  }
11472
11755
 
11756
+ function skipInSSR(ctx) {
11757
+ return Boolean(ctx?.viteConfig?.build?.ssr);
11758
+ }
11759
+
11760
+ async function watchStorageMount(storage, mountName, onChange) {
11761
+ const mountKey = normalizeBaseKey(mountName);
11762
+ const mount = storage.getMount(mountKey);
11763
+ if (!mount || normalizeBaseKey(mount.base) !== mountKey || !mount.driver?.watch)
11764
+ return () => {
11765
+ };
11766
+ const unwatch = await mount.driver.watch((event, key) => {
11767
+ const fullKey = key.startsWith(mountKey) ? key : `${mountKey}${key}`;
11768
+ onChange(event, normalizeKey(fullKey));
11769
+ });
11770
+ return unwatch ?? (() => {
11771
+ });
11772
+ }
11773
+
11473
11774
  const IGNORE_STORAGE_MOUNTS = ["root", "build", "src", "cache"];
11474
11775
  function shouldIgnoreStorageKey(key) {
11475
11776
  return IGNORE_STORAGE_MOUNTS.includes(key.split(":")[0]);
11476
11777
  }
11477
- function setupStorageRPC({
11478
- nuxt,
11479
- rpc,
11480
- ensureDevAuthToken
11481
- }) {
11778
+ function setupStorageRPC(ctx) {
11779
+ const { nuxt } = ctx;
11482
11780
  const storageMounts = {};
11483
11781
  let storage;
11484
11782
  let unwatchStorageMounts = [];
11485
- nuxt.hook("nitro:init", (nitro) => {
11486
- storage = nitro.storage;
11783
+ nuxt.hook("nitro:init", async (nitro) => {
11487
11784
  const mounts = {
11488
11785
  ...nitro.options.storage,
11489
11786
  ...nitro.options.devStorage
11490
11787
  };
11788
+ const nextStorage = createStorage();
11789
+ for (const [path, opts] of Object.entries(mounts)) {
11790
+ if (!opts?.driver) {
11791
+ nitro.logger.warn(`No \`driver\` set for storage mount point "${path}".`);
11792
+ continue;
11793
+ }
11794
+ try {
11795
+ const driverImport = builtinDrivers[opts.driver] || opts.driver;
11796
+ const driverFactory = await import(driverImport).then((r) => r.default || r);
11797
+ nextStorage.mount(path, driverFactory(opts));
11798
+ } catch (err) {
11799
+ nitro.logger.warn(`Failed to mount storage driver "${opts.driver}" for the DevTools storage browser:`, err);
11800
+ }
11801
+ }
11802
+ storage = nextStorage;
11491
11803
  for (const key of Object.keys(storageMounts))
11492
11804
  delete storageMounts[key];
11493
11805
  for (const name of Object.keys(mounts)) {
@@ -11502,7 +11814,7 @@ function setupStorageRPC({
11502
11814
  return;
11503
11815
  await Promise.all(unwatchStorageMounts.map((unwatch) => unwatch()));
11504
11816
  unwatchStorageMounts = await Promise.all(Object.keys(storageMounts).map((mountName) => watchStorageMount(activeStorage, mountName, (event, key) => {
11505
- rpc.broadcast.callHook.asEvent("storage:key:update", key, event);
11817
+ ctx.devtoolsKit?.rpc.broadcast({ method: "callHook", args: ["storage:key:update", key, event], event: true });
11506
11818
  })));
11507
11819
  });
11508
11820
  nuxt.hook("close", async () => {
@@ -11524,20 +11836,17 @@ function setupStorageRPC({
11524
11836
  return [];
11525
11837
  }
11526
11838
  },
11527
- async getStorageItem(token, key) {
11528
- await ensureDevAuthToken(token);
11839
+ async getStorageItem(key) {
11529
11840
  if (!storage)
11530
11841
  return null;
11531
11842
  return await storage.getItem(key);
11532
11843
  },
11533
- async setStorageItem(token, key, value) {
11534
- await ensureDevAuthToken(token);
11844
+ async setStorageItem(key, value) {
11535
11845
  if (!storage)
11536
11846
  return;
11537
11847
  return await storage.setItem(key, value);
11538
11848
  },
11539
- async removeStorageItem(token, key) {
11540
- await ensureDevAuthToken(token);
11849
+ async removeStorageItem(key) {
11541
11850
  if (!storage)
11542
11851
  return;
11543
11852
  return await storage.removeItem(key);
@@ -11593,91 +11902,6 @@ function telemetryEvent(payload, immediate = false) {
11593
11902
  throttledSend();
11594
11903
  }
11595
11904
 
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
11905
  function setupTimelineRPC({ nuxt }) {
11682
11906
  return {
11683
11907
  async enableTimeline(dry) {
@@ -11703,115 +11927,155 @@ function setupTimelineRPC({ nuxt }) {
11703
11927
  function setupRPC(nuxt, options) {
11704
11928
  const serverFunctions = {};
11705
11929
  const extendedRpcMap = /* @__PURE__ */ new Map();
11706
- const rpc = createBirpcGroup(
11707
- serverFunctions,
11708
- [],
11709
- {
11710
- resolver: (name, fn) => {
11711
- if (fn)
11712
- return fn;
11713
- if (!name.includes(":"))
11930
+ let devtoolsKitCtx;
11931
+ const pendingBroadcasts = [];
11932
+ function broadcast(method, ...args) {
11933
+ if (!devtoolsKitCtx) {
11934
+ pendingBroadcasts.push({ method, args });
11935
+ return;
11936
+ }
11937
+ devtoolsKitCtx.rpc.broadcast({
11938
+ method,
11939
+ args,
11940
+ event: true
11941
+ });
11942
+ }
11943
+ function createBroadcastProxy(prefix = "") {
11944
+ return new Proxy({}, {
11945
+ get: (_, method) => {
11946
+ if (typeof method !== "string")
11714
11947
  return;
11715
- const [namespace, fnName] = name.split(":");
11716
- return extendedRpcMap.get(namespace)?.[fnName];
11717
- },
11718
- onFunctionError(error, name) {
11719
- logger.error(
11720
- colors.yellow(`[nuxt-devtools] RPC error on executing "${colors.bold(name)}":
11721
- `) + colors.red(error?.message || "")
11722
- );
11723
- },
11724
- timeout: 12e4
11948
+ const fullMethod = prefix ? `${prefix}:${method}` : method;
11949
+ const fn = (...args) => broadcast(fullMethod, ...args);
11950
+ fn.asEvent = (...args) => broadcast(fullMethod, ...args);
11951
+ return fn;
11952
+ }
11953
+ });
11954
+ }
11955
+ const functionsProxy = new Proxy(serverFunctions, {
11956
+ set(target, prop, value) {
11957
+ target[prop] = value;
11958
+ if (devtoolsKitCtx && typeof prop === "string") {
11959
+ if (devtoolsKitCtx.rpc.has(prop)) {
11960
+ devtoolsKitCtx.rpc.update({ name: prop, handler: value });
11961
+ } else {
11962
+ devtoolsKitCtx.rpc.register({ name: prop, handler: value });
11963
+ }
11964
+ }
11965
+ return true;
11725
11966
  }
11726
- );
11967
+ });
11968
+ const rpc = new Proxy({
11969
+ broadcast: createBroadcastProxy(),
11970
+ functions: functionsProxy
11971
+ }, {
11972
+ get(target, prop, receiver) {
11973
+ if (prop === "broadcast" || prop === "functions") {
11974
+ deprecate(nuxt, "NDT_DEP_0007", {
11975
+ api: `nuxt.devtools.rpc.${prop}`,
11976
+ replacement: "the connected ctx.rpc from onDevtoolsReady((ctx) => ...)"
11977
+ }, { key: prop });
11978
+ }
11979
+ return Reflect.get(target, prop, receiver);
11980
+ }
11981
+ });
11727
11982
  function refresh(event) {
11728
- rpc.broadcast.refresh.asEvent(event);
11983
+ broadcast("refresh", event);
11729
11984
  }
11985
+ const notify = createNotifier(nuxt);
11730
11986
  function extendServerRpc(namespace, functions) {
11987
+ deprecate(nuxt, "NDT_DEP_0003", {
11988
+ api: "extendServerRpc",
11989
+ replacement: "onDevtoolsReady((ctx) => ctx.rpc.register(defineRpcFunction(...)))"
11990
+ }, { key: namespace });
11731
11991
  extendedRpcMap.set(namespace, functions);
11732
- return {
11733
- broadcast: new Proxy({}, {
11734
- get: (_, key) => {
11735
- if (typeof key !== "string")
11736
- return;
11737
- return rpc.broadcast[`${namespace}:${key}`];
11992
+ if (devtoolsKitCtx) {
11993
+ for (const [fnName, handler] of Object.entries(functions)) {
11994
+ if (typeof handler === "function") {
11995
+ devtoolsKitCtx.rpc.register({ name: `${namespace}:${fnName}`, handler });
11738
11996
  }
11739
- })
11997
+ }
11998
+ }
11999
+ return {
12000
+ broadcast: createBroadcastProxy(namespace),
12001
+ functions,
12002
+ clients: [],
12003
+ updateChannels: () => []
11740
12004
  };
11741
12005
  }
11742
12006
  const ctx = {
11743
12007
  nuxt,
11744
12008
  options,
11745
12009
  rpc,
12010
+ get devtoolsKit() {
12011
+ return devtoolsKitCtx;
12012
+ },
11746
12013
  refresh,
12014
+ notify,
11747
12015
  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
- }
12016
+ openInEditorHooks: []
11755
12017
  };
11756
12018
  nuxt.devtools = ctx;
11757
12019
  Object.assign(serverFunctions, {
11758
12020
  ...setupGeneralRPC(ctx),
12021
+ ...setupMessagesRPC(ctx),
11759
12022
  ...setupCustomTabRPC(ctx),
11760
12023
  ...setupStorageRPC(ctx),
11761
12024
  ...setupAssetsRPC(ctx),
11762
12025
  ...setupNpmRPC(ctx),
11763
- ...setupTerminalRPC(ctx),
12026
+ // Bridge the `devtools:terminal:*` hooks onto the Vite DevTools terminals
12027
+ // host so module terminals surface in the built-in Terminals dock. Also
12028
+ // registers its own hook listeners (including `devtools:ready`) as a side
12029
+ // effect, and contributes the `revealTerminal` RPC.
12030
+ ...setupTerminalsBridge(ctx),
11764
12031
  ...setupServerRoutesRPC(ctx),
11765
12032
  ...setupServerTasksRPC(ctx),
11766
12033
  ...setupAnalyzeBuildRPC(ctx),
11767
12034
  ...setupOptionsRPC(ctx),
11768
12035
  ...setupTimelineRPC(ctx),
11769
12036
  ...setupTelemetryRPC(ctx),
11770
- ...setupServerDataRPC(ctx)
12037
+ // Deprecated compat shim (NDT_DEP_0009). The capture + live source now live
12038
+ // in the Data Inspector integration; `getServerConfig` is served by the
12039
+ // canonical `setupGeneralRPC` above.
12040
+ getServerData: async () => getServerData(nuxt)
11771
12041
  });
11772
- const wsClients = /* @__PURE__ */ new Set();
11773
- const vitePlugin = {
11774
- name: "nuxt:devtools:rpc",
11775
- configureServer(server) {
11776
- server.ws.on("connection", (ws) => {
11777
- wsClients.add(ws);
11778
- const channel = {
11779
- post: (d) => ws.send(JSON.stringify({
11780
- type: "custom",
11781
- event: WS_EVENT_NAME,
11782
- data: d
11783
- })),
11784
- on: (fn) => {
11785
- ws.on("message", (e) => {
11786
- try {
11787
- const data = JSON.parse(String(e)) || {};
11788
- if (data.type === "custom" && data.event === WS_EVENT_NAME) {
11789
- fn(data.data);
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
- });
12042
+ async function connectDevToolsKit(kitCtx) {
12043
+ if (devtoolsKitCtx || skipInSSR(kitCtx))
12044
+ return;
12045
+ devtoolsKitCtx = kitCtx;
12046
+ const host = kitCtx.rpc;
12047
+ for (const { method, args } of pendingBroadcasts) {
12048
+ broadcast(method, ...args);
12049
+ }
12050
+ pendingBroadcasts.length = 0;
12051
+ registerHostDiagnostics(ctx);
12052
+ function registerFn(name, handler) {
12053
+ try {
12054
+ host.register({ name, handler });
12055
+ } catch (e) {
12056
+ logger.warn(
12057
+ colors.yellow(`[nuxt-devtools] Failed to register RPC function "${name}":
12058
+ `) + colors.red(e?.message || "")
12059
+ );
12060
+ }
11810
12061
  }
11811
- };
12062
+ for (const [name, handler] of Object.entries(serverFunctions)) {
12063
+ if (typeof handler !== "function")
12064
+ continue;
12065
+ registerFn(`${RPC_NAMESPACE}:${name}`, handler);
12066
+ registerFn(name, handler);
12067
+ }
12068
+ for (const [namespace, fns] of extendedRpcMap) {
12069
+ for (const [fnName, handler] of Object.entries(fns)) {
12070
+ if (typeof handler === "function")
12071
+ registerFn(`${namespace}:${fnName}`, handler);
12072
+ }
12073
+ }
12074
+ await nuxt.callHook("devtools:ready", kitCtx);
12075
+ }
11812
12076
  return {
11813
- vitePlugin,
11814
- ...ctx
12077
+ connectDevToolsKit,
12078
+ ctx
11815
12079
  };
11816
12080
  }
11817
12081
 
@@ -11830,6 +12094,13 @@ async function enableModule(options, nuxt) {
11830
12094
  return;
11831
12095
  }
11832
12096
  await nuxt.callHook("devtools:before");
12097
+ if (options.disableAuthorization) {
12098
+ extendViteConfig((config) => {
12099
+ const devtoolsConfig = config.devtools ||= {};
12100
+ if (devtoolsConfig.clientAuth === void 0)
12101
+ devtoolsConfig.clientAuth = false;
12102
+ });
12103
+ }
11833
12104
  if (options.iframeProps) {
11834
12105
  nuxt.options.runtimeConfig.app.devtools ||= {};
11835
12106
  nuxt.options.runtimeConfig.app.devtools.iframeProps = options.iframeProps;
@@ -11843,19 +12114,56 @@ async function enableModule(options, nuxt) {
11843
12114
  src: join(runtimeDir, "plugins/devtools.server"),
11844
12115
  mode: "server"
11845
12116
  });
12117
+ if (nuxt.options.dev) {
12118
+ nuxt.options.vite.optimizeDeps ||= {};
12119
+ nuxt.options.vite.optimizeDeps.include ||= [];
12120
+ nuxt.options.vite.optimizeDeps.include.push(
12121
+ "nuxt > @nuxt/devtools > @vitejs/devtools/client/inject",
12122
+ "nuxt > @nuxt/devtools > @vitejs/devtools-kit/client",
12123
+ "nuxt > @nuxt/devtools > error-stack-parser-es",
12124
+ "nuxt > @nuxt/devtools > vite-plugin-vue-tracer/client/overlay"
12125
+ );
12126
+ }
11846
12127
  const DevTools = await import('@vitejs/devtools').then((r) => r.DevTools());
11847
12128
  addVitePlugin(DevTools);
12129
+ let connectDevToolsKit;
11848
12130
  addVitePlugin(defineViteDevToolsPlugin({
11849
12131
  name: "nuxt:devtools",
11850
12132
  devtools: {
11851
- setup(ctx2) {
11852
- ctx2.docks.register({
11853
- id: "nuxt:devtools",
11854
- type: "iframe",
11855
- icon: "https://nuxt.com/assets/design-kit/icon-green.svg",
11856
- title: "Nuxt DevTools",
11857
- url: "/__nuxt_devtools__/client/"
11858
- });
12133
+ async setup(ctx2) {
12134
+ if (!skipInSSR(ctx2)) {
12135
+ ctx2.docks.register({
12136
+ id: NUXT_DEVTOOLS_GROUP_ID,
12137
+ type: "group",
12138
+ title: "Nuxt",
12139
+ icon: "/__nuxt_devtools__/client/nuxt.svg",
12140
+ category: "framework",
12141
+ defaultOrder: -2e3,
12142
+ defaultChildId: "nuxt:devtools",
12143
+ categoryOrder: {
12144
+ pinned: 0,
12145
+ app: 1,
12146
+ analyze: 2,
12147
+ server: 3,
12148
+ modules: 4,
12149
+ documentation: 5,
12150
+ advanced: 6
12151
+ }
12152
+ });
12153
+ ctx2.docks.register({
12154
+ id: "nuxt:devtools",
12155
+ type: "iframe",
12156
+ title: "Nuxt DevTools",
12157
+ icon: "/__nuxt_devtools__/client/nuxt.svg",
12158
+ url: "/__nuxt_devtools__/client/",
12159
+ groupId: NUXT_DEVTOOLS_GROUP_ID,
12160
+ frameId: "nuxt:devtools",
12161
+ subTabs: { protocol: "postmessage" },
12162
+ visibility: "false",
12163
+ defaultOrder: -300
12164
+ });
12165
+ }
12166
+ await connectDevToolsKit?.(ctx2);
11859
12167
  }
11860
12168
  }
11861
12169
  }));
@@ -11867,9 +12175,7 @@ async function enableModule(options, nuxt) {
11867
12175
  filename: "devtools/settings.mjs",
11868
12176
  async getContents() {
11869
12177
  const uiOptions = await readLocalOptions(
11870
- {
11871
- ...defaultTabOptions.ui
11872
- },
12178
+ createDefaultTabOptions().ui,
11873
12179
  { root: nuxt.options.rootDir }
11874
12180
  );
11875
12181
  return `export default ${JSON.stringify({
@@ -11879,10 +12185,18 @@ async function enableModule(options, nuxt) {
11879
12185
  });
11880
12186
  nuxt.hook("nitro:config", (config) => {
11881
12187
  if (config.experimental?.tasks)
11882
- defaultTabOptions.serverTasks.enabled = true;
11883
- config.externals = config.externals || {};
11884
- config.externals.inline = config.externals.inline || [];
11885
- config.externals.inline.push(join(runtimeDir, "nitro"));
12188
+ setServerTasksEnabledByDefault(true);
12189
+ const inlinePath = join(runtimeDir, "nitro");
12190
+ if ("externals" in config) {
12191
+ config.externals ||= {};
12192
+ config.externals.inline ||= [];
12193
+ config.externals.inline.push(inlinePath);
12194
+ }
12195
+ if ("noExternals" in config && Array.isArray(config.noExternals)) {
12196
+ config.noExternals.push(inlinePath);
12197
+ } else if (!("noExternals" in config) || config.noExternals === void 0) {
12198
+ config.noExternals = [inlinePath];
12199
+ }
11886
12200
  config.virtual = config.virtual || {};
11887
12201
  config.virtual["#nuxt-devtools-inline"] = `export const script = \`
11888
12202
  if (!window.__NUXT_DEVTOOLS_TIME_METRIC__) {
@@ -11898,10 +12212,10 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
11898
12212
  config.plugins.unshift(join(runtimeDir, "nitro/inline"));
11899
12213
  });
11900
12214
  const {
11901
- vitePlugin,
11902
- ...ctx
12215
+ connectDevToolsKit: _connectDevToolsKit,
12216
+ ctx
11903
12217
  } = setupRPC(nuxt, options);
11904
- addVitePlugin(vitePlugin);
12218
+ connectDevToolsKit = _connectDevToolsKit;
11905
12219
  const clientDirExists = existsSync(clientDir);
11906
12220
  extendViteConfig((config) => {
11907
12221
  config.server ||= {};
@@ -11923,8 +12237,6 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
11923
12237
  });
11924
12238
  const ROUTE_PATH = `${nuxt.options.app.baseURL || "/"}/__nuxt_devtools__`.replace(MULTIPLE_SLASHES_RE, "/");
11925
12239
  const ROUTE_CLIENT = `${ROUTE_PATH}/client`;
11926
- const ROUTE_AUTH = `${ROUTE_PATH}/auth`;
11927
- const ROUTE_AUTH_VERIFY = `${ROUTE_PATH}/auth-verify`;
11928
12240
  const ROUTE_ANALYZE = `${ROUTE_PATH}/analyze`;
11929
12241
  nuxt.hook("vite:serverCreated", (server) => {
11930
12242
  const devtoolsAnalyzeDir = join(nuxt.options.rootDir, "node_modules/.cache/nuxt-devtools/analyze");
@@ -11943,42 +12255,21 @@ window.__NUXT_DEVTOOLS_TIME_METRIC__.appInit = Date.now()
11943
12255
  res.end();
11944
12256
  };
11945
12257
  server.middlewares.use(ROUTE_CLIENT, (req, res) => {
11946
- if (req.url === "/")
12258
+ const pathname = (req.url || "/").split("?")[0];
12259
+ if (pathname === "/" || pathname === "")
11947
12260
  return handleIndex(res);
11948
12261
  return handleStatic(req, res, () => handleIndex(res));
11949
12262
  });
11950
12263
  }
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
12264
  });
11973
12265
  await import('./plugin-metrics.mjs').then(({ setup }) => setup(ctx));
11974
- if (options.vueDevTools !== false)
11975
- await import('./vue-devtools.mjs').then(({ setup }) => setup(ctx));
12266
+ await Promise.resolve().then(function () { return dataInspector; }).then(({ setup }) => setup(ctx));
11976
12267
  if (options.viteInspect !== false)
11977
12268
  await import('./vite-inspect.mjs').then(({ setup }) => setup(ctx));
11978
12269
  if (options.componentInspector !== false)
11979
12270
  await import('./vue-tracer.mjs').then(({ setup }) => setup(ctx));
11980
12271
  const integrations = [
11981
- options.vscode?.enabled ? import('./vscode.mjs').then(({ setup }) => setup(ctx)) : null,
12272
+ import('./code-server.mjs').then(({ setup }) => setup(ctx)),
11982
12273
  options.experimental?.timeline || options.timeline?.enabled ? import('./timeline.mjs').then(({ setup }) => setup(ctx)) : null
11983
12274
  ];
11984
12275
  await Promise.all(integrations);
@@ -12003,4 +12294,9 @@ function defineViteDevToolsPlugin(plugin) {
12003
12294
  return plugin;
12004
12295
  }
12005
12296
 
12006
- export { enableModule };
12297
+ const moduleMain = {
12298
+ __proto__: null,
12299
+ enableModule: enableModule
12300
+ };
12301
+
12302
+ export { RPC_NAMESPACE as R, moduleMain as m };