@vitejs/devtools 0.1.5 → 0.1.9

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 (55) hide show
  1. package/dist/{DockIcon-DNt-Vqy4.js → DockIcon-7v-JouW5.js} +27 -27
  2. package/dist/DockStandalone-DZ0INpRC.js +3246 -0
  3. package/dist/{LogItem-CZM2G41b.js → LogItem-Ca0SsU39.js} +23 -20
  4. package/dist/{ViewBuiltinLogs-1ABRTwzd.js → ViewBuiltinLogs-B_CLlali.js} +39 -39
  5. package/dist/{ViewBuiltinTerminals-Co7G-321.js → ViewBuiltinTerminals-ZrMObMte.js} +10 -11
  6. package/dist/{ViewJsonRender-ByPfpKFM.js → ViewJsonRender-Cc5BPfnv.js} +4 -4
  7. package/dist/auth-state-DXCxEqSd.js +54 -0
  8. package/dist/build-static-zB8LrlMJ.js +49 -0
  9. package/dist/cli-commands.js +57 -2
  10. package/dist/cli.js +8 -4
  11. package/dist/client/inject.js +231 -27
  12. package/dist/client/standalone/assets/DockStandalone-BUOgWTCb.js +1 -0
  13. package/dist/client/standalone/assets/LogItem-BnVhub2j.js +1 -0
  14. package/dist/client/standalone/assets/ViewBuiltinLogs-rU-E-8qT.js +1 -0
  15. package/dist/client/standalone/assets/{ViewBuiltinTerminals-UrMq7UXM.js → ViewBuiltinTerminals-UWfUyC_P.js} +2 -2
  16. package/dist/client/standalone/assets/{ViewJsonRender-BURuu55Z.js → ViewJsonRender-De5eeIha.js} +3 -3
  17. package/dist/client/standalone/assets/dist-CAaP5Isp.js +1 -0
  18. package/dist/client/standalone/assets/iconify-C-CPDXMf.js +2 -0
  19. package/dist/client/standalone/assets/index-DtZFMvER.css +1 -0
  20. package/dist/client/standalone/assets/index-hQ4JAD5S.js +3 -0
  21. package/dist/client/standalone/assets/runtime-core.esm-bundler-Bvz2jy0O.js +1 -0
  22. package/dist/client/standalone/index.html +6 -5
  23. package/dist/client/webcomponents.d.ts +1 -21628
  24. package/dist/client/webcomponents.js +54 -51
  25. package/dist/config.js +1 -1
  26. package/dist/constants-DfEeYo9W.js +142 -0
  27. package/dist/{plugins-DiuKIPkS.js → context-DmXts6Ac.js} +116 -673
  28. package/dist/{dist-D2Z6bwqJ.js → dist-CCdqIez-.js} +128 -5
  29. package/dist/dist-DpLy3ojW.js +229 -0
  30. package/dist/index.d.ts +43 -3
  31. package/dist/index.js +3 -1
  32. package/dist/internal.d.ts +1 -1
  33. package/dist/internal.js +1 -1
  34. package/dist/plugins-vfc-N600.js +59 -0
  35. package/dist/{popup-BUPO6e0I.js → popup-DcuzpgO2.js} +114 -55
  36. package/dist/server-C54I1zbj.js +2 -0
  37. package/dist/server-DH39-LHL.js +50 -0
  38. package/dist/server-DSh-GQIq.js +188 -0
  39. package/dist/standalone-w_GYdx1T.js +33 -0
  40. package/dist/static-dump-BqRb_x-O.js +65 -0
  41. package/package.json +12 -15
  42. package/dist/DockStandalone-DxFEMDp2.js +0 -1256
  43. package/dist/cli-commands-CnJ4eqDp.js +0 -180
  44. package/dist/client/standalone/assets/DockStandalone-C8ChyZLh.js +0 -1
  45. package/dist/client/standalone/assets/LogItem-Mx4UyReX.js +0 -1
  46. package/dist/client/standalone/assets/ViewBuiltinLogs-C4j4vgSn.js +0 -1
  47. package/dist/client/standalone/assets/dist-DIlAYcjk.js +0 -1
  48. package/dist/client/standalone/assets/index-BEyoIK7m.css +0 -1
  49. package/dist/client/standalone/assets/index-Rpv7PwRD.js +0 -4
  50. package/dist/client/standalone/assets/runtime-core.esm-bundler-CJlaYmKv.js +0 -1
  51. package/dist/vue.runtime.esm-bundler-CS1wMbap.js +0 -6988
  52. /package/dist/{context-internal-CvIHbZq4.js → context-internal-DZpoJjMz.js} +0 -0
  53. /package/dist/{context-internal-Du6FuGIu.d.ts → context-internal-Ys7Zu3q3.d.ts} +0 -0
  54. /package/dist/{iconify-BW79QmbD.js → iconify-JodklND-.js} +0 -0
  55. /package/dist/{utils-DaaVwEUH.js → utils-HWI9S6d-.js} +0 -0
@@ -1,5 +1,6 @@
1
- import { G as shallowRef, M as watch, V as reactive, z as markRaw } from "./vue.runtime.esm-bundler-CS1wMbap.js";
2
1
  import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
2
+ import { markRaw, reactive, shallowRef, watch } from "vue";
3
+ import { evaluateWhen } from "@vitejs/devtools-kit/utils/when";
3
4
  //#region src/client/webcomponents/constants.ts
4
5
  const BUILTIN_ENTRY_CLIENT_AUTH_NOTICE = Object.freeze({
5
6
  type: "~builtin",
@@ -18,6 +19,113 @@ const DEFAULT_CATEGORIES_ORDER = {
18
19
  "~builtin": 1e3
19
20
  };
20
21
  //#endregion
22
+ //#region src/client/webcomponents/state/docks.ts
23
+ function DEFAULT_DOCK_PANEL_STORE() {
24
+ return {
25
+ mode: "float",
26
+ width: 80,
27
+ height: 80,
28
+ top: 0,
29
+ left: 10,
30
+ position: "bottom",
31
+ open: false,
32
+ inactiveTimeout: 3e3
33
+ };
34
+ }
35
+ function createDockEntryState(entry, selected) {
36
+ const events = createEventEmitter();
37
+ const state = reactive({
38
+ entryMeta: entry,
39
+ get isActive() {
40
+ return selected.value?.id === entry.id;
41
+ },
42
+ domElements: {},
43
+ events: markRaw(events)
44
+ });
45
+ watch(() => selected.value?.id, (newSelectedId) => {
46
+ if (newSelectedId === entry.id) events.emit("entry:activated");
47
+ else events.emit("entry:deactivated");
48
+ }, { immediate: true });
49
+ watch(() => state.domElements.iframe, (newIframe) => {
50
+ if (newIframe) events.emit("dom:iframe:mounted", newIframe);
51
+ }, { immediate: true });
52
+ watch(() => state.domElements.panel, (newPanel) => {
53
+ if (newPanel) events.emit("dom:panel:mounted", newPanel);
54
+ }, { immediate: true });
55
+ return state;
56
+ }
57
+ function sharedStateToRef(sharedState) {
58
+ const ref = shallowRef(sharedState.value());
59
+ sharedState.on("updated", (newState) => {
60
+ ref.value = newState;
61
+ });
62
+ return ref;
63
+ }
64
+ const docksEntriesRefByRpc = /* @__PURE__ */ new WeakMap();
65
+ async function useDocksEntries(rpc) {
66
+ if (docksEntriesRefByRpc.has(rpc)) return docksEntriesRefByRpc.get(rpc);
67
+ const docksEntriesRef = sharedStateToRef(await rpc.sharedState.get("devtoolskit:internal:docks", { initialValue: [] }));
68
+ docksEntriesRefByRpc.set(rpc, docksEntriesRef);
69
+ return docksEntriesRef;
70
+ }
71
+ //#endregion
72
+ //#region src/client/webcomponents/state/keybindings.ts
73
+ const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform ?? "");
74
+ function formatKeybinding(key) {
75
+ return key.split("+").map((part) => {
76
+ if (part === "Mod") return isMac ? "⌘" : "Ctrl";
77
+ if (part === "Shift") return isMac ? "⇧" : "Shift";
78
+ if (part === "Alt") return isMac ? "⌥" : "Alt";
79
+ return part;
80
+ });
81
+ }
82
+ function normalizeKeyEvent(e) {
83
+ const parts = [];
84
+ if (isMac ? e.metaKey : e.ctrlKey) parts.push("Mod");
85
+ if (isMac ? e.ctrlKey : e.metaKey) parts.push(isMac ? "Ctrl" : "Meta");
86
+ if (e.altKey) parts.push("Alt");
87
+ if (e.shiftKey) parts.push("Shift");
88
+ let key = e.key;
89
+ if (key.length === 1) key = key.toUpperCase();
90
+ if (![
91
+ "Control",
92
+ "Meta",
93
+ "Alt",
94
+ "Shift"
95
+ ].includes(key)) parts.push(key);
96
+ return parts.join("+");
97
+ }
98
+ function collectAllKeybindings(commands, getKeybindings) {
99
+ const result = [];
100
+ for (const cmd of commands.value) {
101
+ for (const kb of getKeybindings(cmd.id)) result.push({
102
+ id: cmd.id,
103
+ keybinding: kb
104
+ });
105
+ if (cmd.children) for (const child of cmd.children) for (const kb of getKeybindings(child.id)) result.push({
106
+ id: child.id,
107
+ keybinding: kb
108
+ });
109
+ }
110
+ return result;
111
+ }
112
+ const KNOWN_BROWSER_SHORTCUTS = {
113
+ "Mod+T": "Open new tab",
114
+ "Mod+W": "Close tab",
115
+ "Mod+N": "Open new window",
116
+ "Mod+L": "Focus address bar",
117
+ "Mod+D": "Bookmark page",
118
+ "Mod+Q": "Quit browser",
119
+ "Mod+Shift+T": "Reopen closed tab",
120
+ "Mod+Shift+N": "Open incognito window",
121
+ "Mod+Shift+W": "Close window",
122
+ "Mod+Shift+Q": "Quit browser (Chrome)",
123
+ "Alt+F4": "Close window (Windows)",
124
+ "Mod+R": "Reload page",
125
+ "Mod+Shift+R": "Hard reload page",
126
+ "Mod+F": "Find in page"
127
+ };
128
+ //#endregion
21
129
  //#region src/client/webcomponents/state/dock-settings.ts
22
130
  /**
23
131
  * Group and sort dock entries based on user settings.
@@ -25,10 +133,11 @@ const DEFAULT_CATEGORIES_ORDER = {
25
133
  */
26
134
  function docksGroupByCategories(entries, settings, options) {
27
135
  const { docksHidden, docksCategoriesHidden, docksCustomOrder, docksPinned } = settings;
28
- const { includeHidden = false } = options ?? {};
136
+ const { includeHidden = false, whenContext } = options ?? {};
29
137
  const map = /* @__PURE__ */ new Map();
30
138
  for (const entry of entries) {
31
- if (entry.isHidden && !includeHidden) continue;
139
+ if (entry.when && whenContext && !evaluateWhen(entry.when, whenContext) && !includeHidden) continue;
140
+ if (entry.when && !whenContext && entry.when === "false" && !includeHidden) continue;
32
141
  if (!includeHidden && docksHidden.includes(entry.id)) continue;
33
142
  const category = entry.category ?? "default";
34
143
  if (!includeHidden && docksCategoriesHidden.includes(category)) continue;
@@ -76,56 +185,6 @@ function docksSplitGroupsWithCapacity(groups, capacity) {
76
185
  };
77
186
  }
78
187
  //#endregion
79
- //#region src/client/webcomponents/state/docks.ts
80
- function DEFAULT_DOCK_PANEL_STORE() {
81
- return {
82
- mode: "float",
83
- width: 80,
84
- height: 80,
85
- top: 0,
86
- left: 10,
87
- position: "bottom",
88
- open: false,
89
- inactiveTimeout: 3e3
90
- };
91
- }
92
- function createDockEntryState(entry, selected) {
93
- const events = createEventEmitter();
94
- const state = reactive({
95
- entryMeta: entry,
96
- get isActive() {
97
- return selected.value?.id === entry.id;
98
- },
99
- domElements: {},
100
- events: markRaw(events)
101
- });
102
- watch(() => selected.value?.id, (newSelectedId) => {
103
- if (newSelectedId === entry.id) events.emit("entry:activated");
104
- else events.emit("entry:deactivated");
105
- }, { immediate: true });
106
- watch(() => state.domElements.iframe, (newIframe) => {
107
- if (newIframe) events.emit("dom:iframe:mounted", newIframe);
108
- }, { immediate: true });
109
- watch(() => state.domElements.panel, (newPanel) => {
110
- if (newPanel) events.emit("dom:panel:mounted", newPanel);
111
- }, { immediate: true });
112
- return state;
113
- }
114
- function sharedStateToRef(sharedState) {
115
- const ref = shallowRef(sharedState.value());
116
- sharedState.on("updated", (newState) => {
117
- ref.value = newState;
118
- });
119
- return ref;
120
- }
121
- const docksEntriesRefByRpc = /* @__PURE__ */ new WeakMap();
122
- async function useDocksEntries(rpc) {
123
- if (docksEntriesRefByRpc.has(rpc)) return docksEntriesRefByRpc.get(rpc);
124
- const docksEntriesRef = sharedStateToRef(await rpc.sharedState.get("devtoolskit:internal:docks", { initialValue: [] }));
125
- docksEntriesRefByRpc.set(rpc, docksEntriesRef);
126
- return docksEntriesRef;
127
- }
128
- //#endregion
129
188
  //#region src/client/webcomponents/state/floating-tooltip.ts
130
189
  const tooltip = shallowRef(null);
131
190
  const docksOverflowPanel = shallowRef(null);
@@ -170,7 +229,7 @@ let detachColorModeSync;
170
229
  let popupDockElement;
171
230
  let popupContext;
172
231
  let loadDockStandalone = async () => {
173
- return await import("./DockStandalone-DxFEMDp2.js").then((n) => n.n).then((m) => m.DockStandalone);
232
+ return await import("./DockStandalone-DZ0INpRC.js").then((n) => n.n).then((m) => m.DockStandalone);
174
233
  };
175
234
  popupEvents.on("popup:open-requested", (context) => {
176
235
  openDockPopup(context);
@@ -361,4 +420,4 @@ async function openDockPopup(context) {
361
420
  }
362
421
  }
363
422
  //#endregion
364
- export { BUILTIN_ENTRY_CLIENT_AUTH_NOTICE as S, sharedStateToRef as _, triggerMainFrameDockAction as a, docksSplitGroupsWithCapacity as b, setDocksOverflowPanel as c, useDockContextMenu as d, useDocksOverflowPanel as f, createDockEntryState as g, DEFAULT_DOCK_PANEL_STORE as h, requestDockPopupOpen as i, setEdgePositionDropdown as l, useFloatingTooltip as m, isDockPopupSupported as n, useIsDockPopupOpen as o, useEdgePositionDropdown as p, registerMainFrameDockActionHandler as r, setDockContextMenu as s, closeDockPopup as t, setFloatingTooltip as u, useDocksEntries as v, BUILTIN_ENTRIES as x, docksGroupByCategories as y };
423
+ export { createDockEntryState as C, BUILTIN_ENTRY_CLIENT_AUTH_NOTICE as D, BUILTIN_ENTRIES as E, DEFAULT_DOCK_PANEL_STORE as S, useDocksEntries as T, KNOWN_BROWSER_SHORTCUTS as _, triggerMainFrameDockAction as a, isMac as b, setDocksOverflowPanel as c, useDockContextMenu as d, useDocksOverflowPanel as f, docksSplitGroupsWithCapacity as g, docksGroupByCategories as h, requestDockPopupOpen as i, setEdgePositionDropdown as l, useFloatingTooltip as m, isDockPopupSupported as n, useIsDockPopupOpen as o, useEdgePositionDropdown as p, registerMainFrameDockActionHandler as r, setDockContextMenu as s, closeDockPopup as t, setFloatingTooltip as u, collectAllKeybindings as v, sharedStateToRef as w, normalizeKeyEvent as x, formatKeybinding as y };
@@ -0,0 +1,2 @@
1
+ import { n as renderDockImportsMap } from "./server-DH39-LHL.js";
2
+ export { renderDockImportsMap };
@@ -0,0 +1,50 @@
1
+ import { n as createDevToolsContext } from "./context-DmXts6Ac.js";
2
+ import { t as createDevToolsMiddleware } from "./server-DSh-GQIq.js";
3
+ import { DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID, DEVTOOLS_MOUNT_PATH } from "@vitejs/devtools-kit/constants";
4
+ //#region src/node/plugins/server.ts
5
+ /**
6
+ * Core plugin for enabling Vite DevTools
7
+ */
8
+ function renderDockImportsMap(docks) {
9
+ const map = /* @__PURE__ */ new Map();
10
+ for (const dock of docks) {
11
+ const id = `${dock.type}:${dock.id}`;
12
+ if (dock.type === "action") map.set(id, dock.action);
13
+ else if (dock.type === "custom-render") map.set(id, dock.renderer);
14
+ else if (dock.type === "iframe" && dock.clientScript) map.set(id, dock.clientScript);
15
+ }
16
+ return [
17
+ `export const importsMap = {`,
18
+ ...[...map.entries()].filter(([, entry]) => entry != null).map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName ?? "default")}]),`),
19
+ "}"
20
+ ].join("\n");
21
+ }
22
+ function DevToolsServer() {
23
+ let context;
24
+ return {
25
+ name: "vite:devtools:server",
26
+ enforce: "post",
27
+ apply: "serve",
28
+ async configureServer(viteDevServer) {
29
+ context = await createDevToolsContext(viteDevServer.config, viteDevServer);
30
+ const host = viteDevServer.config.server.host === true ? "0.0.0.0" : viteDevServer.config.server.host || "localhost";
31
+ const { middleware } = await createDevToolsMiddleware({
32
+ cwd: viteDevServer.config.root,
33
+ hostWebSocket: host,
34
+ context
35
+ });
36
+ viteDevServer.middlewares.use(DEVTOOLS_MOUNT_PATH, middleware);
37
+ },
38
+ resolveId(id) {
39
+ if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) return id;
40
+ },
41
+ load(id) {
42
+ if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) {
43
+ if (!context) throw new Error("DevTools context is not initialized");
44
+ return renderDockImportsMap(context.docks.values());
45
+ }
46
+ }
47
+ };
48
+ }
49
+ //#endregion
50
+ export { renderDockImportsMap as n, DevToolsServer as t };
@@ -0,0 +1,188 @@
1
+ import { i as __exportAll, n as ansis_default, t as MARK_INFO } from "./constants-DfEeYo9W.js";
2
+ import { t as getInternalContext } from "./context-internal-DZpoJjMz.js";
3
+ import { n as consumeTempAuthToken } from "./auth-state-DXCxEqSd.js";
4
+ import { dirClientStandalone } from "./dirs.js";
5
+ import { n as getPort } from "./dist-DpLy3ojW.js";
6
+ import { createDebug } from "obug";
7
+ import { DEVTOOLS_CONNECTION_META_FILENAME } from "@vitejs/devtools-kit/constants";
8
+ import process from "node:process";
9
+ import sirv from "sirv";
10
+ import { createApp, eventHandler, fromNodeMiddleware, getQuery, toNodeListener } from "h3";
11
+ import { AsyncLocalStorage } from "node:async_hooks";
12
+ import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
13
+ import { createRpcServer } from "@vitejs/devtools-rpc/server";
14
+ //#region src/node/ws.ts
15
+ const debugInvoked = createDebug("vite:devtools:rpc:invoked");
16
+ const ANONYMOUS_SCOPE = "vite:anonymous:";
17
+ async function createWsServer(options) {
18
+ const rpcHost = options.context.rpc;
19
+ const host = options.hostWebSocket ?? "localhost";
20
+ const https = options.context.viteConfig.server.https;
21
+ const port = options.portWebSocket ?? await getPort({
22
+ port: 7812,
23
+ host,
24
+ random: true
25
+ });
26
+ const wsClients = /* @__PURE__ */ new Set();
27
+ const context = options.context;
28
+ const contextInternal = getInternalContext(context);
29
+ const isClientAuthDisabled = context.mode === "build" || context.viteConfig.devtools?.config?.clientAuth === false || process.env.VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === "true";
30
+ if (isClientAuthDisabled) console.warn("[Vite DevTools] Client authentication is disabled. Any browser can connect to the devtools and access to your server and filesystem.");
31
+ const preset = createWsRpcPreset({
32
+ port,
33
+ host,
34
+ https,
35
+ onConnected: (ws, req, meta) => {
36
+ const authToken = new URL(req.url ?? "", "http://localhost").searchParams.get("vite_devtools_auth_token") ?? void 0;
37
+ if (isClientAuthDisabled) meta.isTrusted = true;
38
+ else if (authToken && contextInternal.storage.auth.value().trusted[authToken]) {
39
+ meta.isTrusted = true;
40
+ meta.clientAuthToken = authToken;
41
+ } else if (authToken && ((context.viteConfig.devtools?.config)?.clientAuthTokens ?? []).includes(authToken)) {
42
+ meta.isTrusted = true;
43
+ meta.clientAuthToken = authToken;
44
+ }
45
+ wsClients.add(ws);
46
+ const color = meta.isTrusted ? ansis_default.green : ansis_default.yellow;
47
+ console.log(color`${MARK_INFO} Websocket client connected. [${meta.id}] [${meta.clientAuthToken}] (${meta.isTrusted ? "trusted" : "untrusted"})`);
48
+ },
49
+ onDisconnected: (ws, meta) => {
50
+ wsClients.delete(ws);
51
+ console.log(ansis_default.red`${MARK_INFO} Websocket client disconnected. [${meta.id}]`);
52
+ }
53
+ });
54
+ const asyncStorage = new AsyncLocalStorage();
55
+ const rpcGroup = createRpcServer(rpcHost.functions, {
56
+ preset,
57
+ rpcOptions: {
58
+ onFunctionError(error, name) {
59
+ console.error(ansis_default.red`⬢ RPC error on executing "${ansis_default.bold(name)}":`);
60
+ console.error(error);
61
+ },
62
+ onGeneralError(error) {
63
+ console.error(ansis_default.red`⬢ RPC error on executing rpc`);
64
+ console.error(error);
65
+ },
66
+ resolver(name, fn) {
67
+ const rpc = this;
68
+ if (!name.startsWith(ANONYMOUS_SCOPE) && !rpc.$meta.isTrusted) return () => {
69
+ throw new Error(`Unauthorized access to method ${JSON.stringify(name)} from client [${rpc.$meta.id}]`);
70
+ };
71
+ if (!fn) return void 0;
72
+ return async function(...args) {
73
+ debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`);
74
+ return await asyncStorage.run({
75
+ rpc,
76
+ meta: rpc.$meta
77
+ }, async () => {
78
+ return (await fn).apply(this, args);
79
+ });
80
+ };
81
+ }
82
+ }
83
+ });
84
+ rpcHost._rpcGroup = rpcGroup;
85
+ rpcHost._asyncStorage = asyncStorage;
86
+ const getConnectionMeta = async () => {
87
+ return {
88
+ backend: "websocket",
89
+ websocket: port
90
+ };
91
+ };
92
+ return {
93
+ port,
94
+ rpc: rpcGroup,
95
+ rpcHost,
96
+ getConnectionMeta
97
+ };
98
+ }
99
+ //#endregion
100
+ //#region src/node/server.ts
101
+ var server_exports = /* @__PURE__ */ __exportAll({ createDevToolsMiddleware: () => createDevToolsMiddleware });
102
+ function generateAuthPageHtml() {
103
+ return `<!DOCTYPE html>
104
+ <html>
105
+ <head>
106
+ <title>Vite DevTools Authorization</title>
107
+ <style>
108
+ html { font-family: system-ui, sans-serif; padding: 2rem; }
109
+ body { height: 80vh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1rem; }
110
+ #message { font-size: 1.2rem; }
111
+ @media (prefers-color-scheme: dark) { html { background: #1a1a1a; color: #e0e0e0; } }
112
+ </style>
113
+ </head>
114
+ <body>
115
+ <div id="message">Verifying...</div>
116
+ <script>
117
+ const query = new URLSearchParams(location.search)
118
+ const id = query.get('id')
119
+ const el = document.getElementById('message')
120
+
121
+ if (!id) {
122
+ el.textContent = '\\u26a0\\ufe0f No auth token found. Please check your URL.'
123
+ el.style.color = '#df513f'
124
+ } else {
125
+ fetch(location.pathname.replace(/\\/$/, '') + '-verify?id=' + encodeURIComponent(id))
126
+ .then(async (r) => {
127
+ if (r.status !== 200) throw new Error(await r.text())
128
+ const data = await r.json()
129
+ const authToken = data.authToken
130
+
131
+ localStorage.setItem('__VITE_DEVTOOLS_CONNECTION_AUTH_TOKEN__', authToken)
132
+
133
+ try {
134
+ const bc = new BroadcastChannel('vite-devtools-auth')
135
+ bc.postMessage({ type: 'auth-update', authToken: authToken })
136
+ } catch {}
137
+
138
+ el.textContent = '\\u2705 Authorized! You can close this window now.'
139
+ window.close()
140
+ })
141
+ .catch((err) => {
142
+ el.textContent = '\\u26a0\\ufe0f Failed to authorize: ' + err.message
143
+ el.style.color = '#df513f'
144
+ })
145
+ }
146
+ <\/script>
147
+ </body>
148
+ </html>`;
149
+ }
150
+ async function createDevToolsMiddleware(options) {
151
+ const h3 = createApp();
152
+ const contextInternal = getInternalContext(options.context);
153
+ const { rpc, getConnectionMeta } = await createWsServer(options);
154
+ h3.use(`/${DEVTOOLS_CONNECTION_META_FILENAME}`, eventHandler(async (event) => {
155
+ event.node.res.setHeader("Content-Type", "application/json");
156
+ return event.node.res.end(JSON.stringify(await getConnectionMeta()));
157
+ }));
158
+ h3.use("/auth-verify", eventHandler((event) => {
159
+ const { id } = getQuery(event);
160
+ if (!id) {
161
+ event.node.res.statusCode = 400;
162
+ return event.node.res.end("Missing id parameter");
163
+ }
164
+ const clientAuthToken = consumeTempAuthToken(id, contextInternal.storage.auth);
165
+ if (!clientAuthToken) {
166
+ event.node.res.statusCode = 403;
167
+ return event.node.res.end("Invalid or expired auth token");
168
+ }
169
+ event.node.res.setHeader("Content-Type", "application/json");
170
+ return event.node.res.end(JSON.stringify({ authToken: clientAuthToken }));
171
+ }));
172
+ h3.use("/auth", eventHandler((event) => {
173
+ event.node.res.setHeader("Content-Type", "text/html");
174
+ return event.node.res.end(generateAuthPageHtml());
175
+ }));
176
+ h3.use(fromNodeMiddleware(sirv(dirClientStandalone, {
177
+ dev: true,
178
+ single: true
179
+ })));
180
+ return {
181
+ h3,
182
+ rpc,
183
+ middleware: toNodeListener(h3),
184
+ getConnectionMeta
185
+ };
186
+ }
187
+ //#endregion
188
+ export { server_exports as n, createDevToolsMiddleware as t };
@@ -0,0 +1,33 @@
1
+ import { n as createDevToolsContext } from "./context-DmXts6Ac.js";
2
+ import { t as DevTools } from "./plugins-vfc-N600.js";
3
+ import process from "node:process";
4
+ //#region src/node/standalone.ts
5
+ async function startStandaloneDevTools(options = {}) {
6
+ const { cwd = process.cwd(), command = "build", mode = "production" } = options;
7
+ const { resolveConfig } = await import("vite");
8
+ const resolved = await resolveConfig({
9
+ configFile: options.config,
10
+ root: cwd,
11
+ plugins: [DevTools()]
12
+ }, command, mode);
13
+ dedupeVitePlugins(resolved.plugins, (plugin) => plugin.name?.startsWith("vite:devtools"));
14
+ return {
15
+ config: resolved,
16
+ context: await createDevToolsContext(resolved)
17
+ };
18
+ }
19
+ function dedupeVitePlugins(plugins, include) {
20
+ const toDelete = [];
21
+ const map = /* @__PURE__ */ new Map();
22
+ for (let i = 0; i < plugins.length; i++) {
23
+ const plugin = plugins[i];
24
+ if (!plugin || !include(plugin)) continue;
25
+ if (map.has(plugin.name)) toDelete.push(i);
26
+ else map.set(plugin.name, plugin);
27
+ }
28
+ toDelete.sort((a, b) => b - a);
29
+ for (const i of toDelete) plugins.splice(i, 1);
30
+ return plugins;
31
+ }
32
+ //#endregion
33
+ export { startStandaloneDevTools };
@@ -0,0 +1,65 @@
1
+ import { DEVTOOLS_RPC_DUMP_DIRNAME } from "@vitejs/devtools-kit/constants";
2
+ import { dumpFunctions, getRpcHandler } from "@vitejs/devtools-rpc";
3
+ //#region src/node/static-dump.ts
4
+ function makeDumpKey(name) {
5
+ return encodeURIComponent(name.replaceAll(":", "~"));
6
+ }
7
+ function makeStaticPath(name) {
8
+ return `${DEVTOOLS_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.static.json`;
9
+ }
10
+ function makeQueryRecordPath(name, hash) {
11
+ return `${DEVTOOLS_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.record.${hash}.json`;
12
+ }
13
+ function makeQueryFallbackPath(name) {
14
+ return `${DEVTOOLS_RPC_DUMP_DIRNAME}/${makeDumpKey(name)}.fallback.json`;
15
+ }
16
+ async function resolveRecord(record) {
17
+ return typeof record === "function" ? await record() : record;
18
+ }
19
+ async function collectStaticRpcDump(definitions, context) {
20
+ const manifest = {};
21
+ const files = {};
22
+ for (const definition of definitions) {
23
+ const type = definition.type ?? "query";
24
+ if (type === "static") {
25
+ const handler = await getRpcHandler(definition, context);
26
+ const path = makeStaticPath(definition.name);
27
+ files[path] = { output: await Promise.resolve(handler()) };
28
+ manifest[definition.name] = {
29
+ type: "static",
30
+ path
31
+ };
32
+ continue;
33
+ }
34
+ if (type !== "query") continue;
35
+ const store = await dumpFunctions([definition], context);
36
+ if (!(definition.name in store.definitions)) continue;
37
+ const queryEntry = {
38
+ type: "query",
39
+ records: {}
40
+ };
41
+ const prefix = `${definition.name}---`;
42
+ for (const [recordKey, recordOrGetter] of Object.entries(store.records)) {
43
+ if (!recordKey.startsWith(prefix)) continue;
44
+ const key = recordKey.slice(prefix.length);
45
+ const record = await resolveRecord(recordOrGetter);
46
+ if (key === "fallback") {
47
+ const path = makeQueryFallbackPath(definition.name);
48
+ files[path] = record;
49
+ queryEntry.fallback = path;
50
+ } else {
51
+ const path = makeQueryRecordPath(definition.name, key);
52
+ files[path] = record;
53
+ queryEntry.records[key] = path;
54
+ }
55
+ }
56
+ if (!Object.keys(queryEntry.records).length && !queryEntry.fallback) continue;
57
+ manifest[definition.name] = queryEntry;
58
+ }
59
+ return {
60
+ manifest,
61
+ files
62
+ };
63
+ }
64
+ //#endregion
65
+ export { collectStaticRpcDump };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitejs/devtools",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.9",
5
5
  "description": "Vite DevTools",
6
6
  "author": "VoidZero Inc.",
7
7
  "license": "MIT",
@@ -44,9 +44,9 @@
44
44
  "dependencies": {
45
45
  "birpc": "^4.0.0",
46
46
  "cac": "^7.0.0",
47
- "h3": "^1.15.9",
47
+ "h3": "^1.15.10",
48
48
  "immer": "^11.1.4",
49
- "launch-editor": "^2.13.1",
49
+ "launch-editor": "^2.13.2",
50
50
  "mlly": "^1.8.2",
51
51
  "obug": "^2.1.1",
52
52
  "open": "^11.0.0",
@@ -54,10 +54,11 @@
54
54
  "perfect-debounce": "^2.1.0",
55
55
  "sirv": "^3.0.2",
56
56
  "tinyexec": "^1.0.4",
57
- "ws": "^8.19.0",
58
- "@vitejs/devtools-rolldown": "0.1.5",
59
- "@vitejs/devtools-kit": "0.1.5",
60
- "@vitejs/devtools-rpc": "0.1.5"
57
+ "vue": "^3.5.30",
58
+ "ws": "^8.20.0",
59
+ "@vitejs/devtools-kit": "0.1.9",
60
+ "@vitejs/devtools-rpc": "0.1.9",
61
+ "@vitejs/devtools-rolldown": "0.1.9"
61
62
  },
62
63
  "devDependencies": {
63
64
  "@clack/prompts": "^1.1.0",
@@ -65,35 +66,31 @@
65
66
  "@xterm/addon-fit": "^0.11.0",
66
67
  "@xterm/xterm": "^6.0.0",
67
68
  "dompurify": "^3.3.3",
69
+ "fuse.js": "^7.1.0",
68
70
  "human-id": "^4.1.3",
69
71
  "tsdown": "^0.21.4",
70
72
  "typescript": "^5.9.3",
71
73
  "unplugin-vue": "^7.1.1",
72
- "vite": "^8.0.1",
74
+ "vite": "^8.0.2",
73
75
  "vue": "^3.5.30",
74
76
  "vue-router": "^5.0.4",
75
77
  "vue-tsc": "^3.2.6",
76
- "@vitejs/devtools-rolldown": "0.1.5"
78
+ "@vitejs/devtools-rolldown": "0.1.9"
77
79
  },
78
80
  "inlinedDependencies": {
79
81
  "@clack/core": "1.1.0",
80
82
  "@clack/prompts": "1.1.0",
81
83
  "@json-render/core": "0.13.0",
82
84
  "@json-render/vue": "0.13.0",
83
- "@vue/reactivity": "3.5.30",
84
- "@vue/runtime-core": "3.5.30",
85
- "@vue/runtime-dom": "3.5.30",
86
- "@vue/shared": "3.5.30",
87
85
  "@vueuse/core": "14.2.1",
88
86
  "@vueuse/shared": "14.2.1",
89
87
  "@xterm/addon-fit": "0.11.0",
90
88
  "@xterm/xterm": "6.0.0",
91
89
  "ansis": "4.2.0",
92
- "csstype": "3.2.3",
93
90
  "dompurify": "3.3.3",
91
+ "fuse.js": "7.1.0",
94
92
  "get-port-please": "3.2.0",
95
93
  "sisteransi": "1.0.5",
96
- "vue": "3.5.30",
97
94
  "zod": "4.3.6"
98
95
  },
99
96
  "scripts": {