@vitejs/devtools 0.1.5 → 0.1.8

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 (38) hide show
  1. package/dist/{DockIcon-DNt-Vqy4.js → DockIcon-zZkKuxFy.js} +2 -2
  2. package/dist/{DockStandalone-DxFEMDp2.js → DockStandalone-BuMVHLt_.js} +64 -64
  3. package/dist/{LogItem-CZM2G41b.js → LogItem-D-AbVX5q.js} +5 -5
  4. package/dist/{ViewBuiltinLogs-1ABRTwzd.js → ViewBuiltinLogs-D9GVXA00.js} +39 -39
  5. package/dist/{ViewBuiltinTerminals-Co7G-321.js → ViewBuiltinTerminals-afgLtRQP.js} +11 -11
  6. package/dist/{ViewJsonRender-ByPfpKFM.js → ViewJsonRender-DtluXw3F.js} +4 -4
  7. package/dist/cli-commands.js +92 -2
  8. package/dist/cli.js +8 -4
  9. package/dist/client/inject.js +49 -28
  10. package/dist/client/standalone/assets/{DockStandalone-C8ChyZLh.js → DockStandalone-DvxQ5kAU.js} +1 -1
  11. package/dist/client/standalone/assets/{ViewBuiltinTerminals-UrMq7UXM.js → ViewBuiltinTerminals-CpNVjAgX.js} +1 -1
  12. package/dist/client/standalone/assets/{ViewJsonRender-BURuu55Z.js → ViewJsonRender-CbWAIBeO.js} +1 -1
  13. package/dist/client/standalone/assets/{index-Rpv7PwRD.js → index-BGGAiDua.js} +3 -3
  14. package/dist/client/standalone/index.html +1 -1
  15. package/dist/client/webcomponents.d.ts +1 -21628
  16. package/dist/client/webcomponents.js +31 -31
  17. package/dist/config.js +1 -1
  18. package/dist/constants-DfEeYo9W.js +142 -0
  19. package/dist/{dist-D2Z6bwqJ.js → dist-CBtGbo90.js} +4 -4
  20. package/dist/dist-DpLy3ojW.js +229 -0
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +4 -1
  23. package/dist/internal.d.ts +1 -1
  24. package/dist/internal.js +1 -1
  25. package/dist/plugins-DfC1vp4w.js +31 -0
  26. package/dist/{popup-BUPO6e0I.js → popup-CAT8YohS.js} +2 -2
  27. package/dist/server-BuWZ1h8p.js +241 -0
  28. package/dist/server-Ca6LOTxO.js +3 -0
  29. package/dist/{plugins-DiuKIPkS.js → server-DhChc9gv.js} +8 -624
  30. package/dist/standalone-CAJbdnf4.js +34 -0
  31. package/dist/static-dump-Q0iG9hz3.js +65 -0
  32. package/package.json +9 -14
  33. package/dist/cli-commands-CnJ4eqDp.js +0 -180
  34. package/dist/vue.runtime.esm-bundler-CS1wMbap.js +0 -6988
  35. /package/dist/{context-internal-Du6FuGIu.d.ts → context-internal-BA4ba-FN.d.ts} +0 -0
  36. /package/dist/{context-internal-CvIHbZq4.js → context-internal-DZpoJjMz.js} +0 -0
  37. /package/dist/{iconify-BW79QmbD.js → iconify-JodklND-.js} +0 -0
  38. /package/dist/{utils-DaaVwEUH.js → utils-HWI9S6d-.js} +0 -0
@@ -0,0 +1,31 @@
1
+ import { t as DevToolsServer } from "./server-DhChc9gv.js";
2
+ import { dirDist } from "./dirs.js";
3
+ import { join, normalize } from "pathe";
4
+ import process from "node:process";
5
+ //#region src/node/plugins/injection.ts
6
+ function DevToolsInjection() {
7
+ return {
8
+ name: "vite:devtools:injection",
9
+ enforce: "post",
10
+ transformIndexHtml() {
11
+ return [{
12
+ tag: "script",
13
+ attrs: {
14
+ src: `/@fs/${process.env.VITE_DEVTOOLS_LOCAL_DEV ? normalize(join(dirDist, "..", "src/client/inject/index.ts")) : normalize(join(dirDist, "client/inject.js"))}`,
15
+ type: "module"
16
+ },
17
+ injectTo: "body"
18
+ }];
19
+ }
20
+ };
21
+ }
22
+ //#endregion
23
+ //#region src/node/plugins/index.ts
24
+ async function DevTools(options = {}) {
25
+ const { builtinDevTools = true } = options;
26
+ const plugins = [DevToolsInjection(), DevToolsServer()];
27
+ if (builtinDevTools) plugins.push(await import("@vitejs/devtools-rolldown").then((m) => m.DevToolsRolldownUI()));
28
+ return plugins;
29
+ }
30
+ //#endregion
31
+ export { DevTools as t };
@@ -1,5 +1,5 @@
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
3
  //#region src/client/webcomponents/constants.ts
4
4
  const BUILTIN_ENTRY_CLIENT_AUTH_NOTICE = Object.freeze({
5
5
  type: "~builtin",
@@ -170,7 +170,7 @@ let detachColorModeSync;
170
170
  let popupDockElement;
171
171
  let popupContext;
172
172
  let loadDockStandalone = async () => {
173
- return await import("./DockStandalone-DxFEMDp2.js").then((n) => n.n).then((m) => m.DockStandalone);
173
+ return await import("./DockStandalone-BuMVHLt_.js").then((n) => n.n).then((m) => m.DockStandalone);
174
174
  };
175
175
  popupEvents.on("popup:open-requested", (context) => {
176
176
  openDockPopup(context);
@@ -0,0 +1,241 @@
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 { dirClientStandalone } from "./dirs.js";
4
+ import { n as getPort } from "./dist-DpLy3ojW.js";
5
+ import { createDebug } from "obug";
6
+ import { DEVTOOLS_CONNECTION_META_FILENAME } from "@vitejs/devtools-kit/constants";
7
+ import process from "node:process";
8
+ import sirv from "sirv";
9
+ import { humanId } from "@vitejs/devtools-kit/utils/human-id";
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/auth-state.ts
15
+ let pendingAuth = null;
16
+ let tempAuthToken = generateTempId();
17
+ function generateTempId() {
18
+ return humanId({
19
+ separator: "-",
20
+ capitalize: false
21
+ });
22
+ }
23
+ function getTempAuthToken() {
24
+ return tempAuthToken;
25
+ }
26
+ function refreshTempAuthToken() {
27
+ tempAuthToken = generateTempId();
28
+ return tempAuthToken;
29
+ }
30
+ function setPendingAuth(request) {
31
+ pendingAuth = request;
32
+ }
33
+ /**
34
+ * Abort and clean up any existing pending auth request.
35
+ */
36
+ function abortPendingAuth() {
37
+ if (pendingAuth) {
38
+ pendingAuth.abortController.abort();
39
+ clearTimeout(pendingAuth.timeout);
40
+ pendingAuth = null;
41
+ }
42
+ }
43
+ /**
44
+ * Consume the temp auth ID: verify it matches, trust the pending client, and clean up.
45
+ * Returns the client's authToken if successful, null otherwise.
46
+ */
47
+ function consumeTempAuthToken(id, storage) {
48
+ if (id !== tempAuthToken || !pendingAuth) return null;
49
+ const { clientAuthToken, session, ua, origin, resolve } = pendingAuth;
50
+ storage.mutate((state) => {
51
+ state.trusted[clientAuthToken] = {
52
+ authToken: clientAuthToken,
53
+ ua,
54
+ origin,
55
+ timestamp: Date.now()
56
+ };
57
+ });
58
+ session.meta.clientAuthToken = clientAuthToken;
59
+ session.meta.isTrusted = true;
60
+ resolve({ isTrusted: true });
61
+ abortPendingAuth();
62
+ refreshTempAuthToken();
63
+ return clientAuthToken;
64
+ }
65
+ //#endregion
66
+ //#region src/node/ws.ts
67
+ const debugInvoked = createDebug("vite:devtools:rpc:invoked");
68
+ const ANONYMOUS_SCOPE = "vite:anonymous:";
69
+ async function createWsServer(options) {
70
+ const rpcHost = options.context.rpc;
71
+ const host = options.hostWebSocket ?? "localhost";
72
+ const https = options.context.viteConfig.server.https;
73
+ const port = options.portWebSocket ?? await getPort({
74
+ port: 7812,
75
+ host,
76
+ random: true
77
+ });
78
+ const wsClients = /* @__PURE__ */ new Set();
79
+ const context = options.context;
80
+ const contextInternal = getInternalContext(context);
81
+ const isClientAuthDisabled = context.mode === "build" || context.viteConfig.devtools?.config?.clientAuth === false || process.env.VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === "true";
82
+ if (isClientAuthDisabled) console.warn("[Vite DevTools] Client authentication is disabled. Any browser can connect to the devtools and access to your server and filesystem.");
83
+ const preset = createWsRpcPreset({
84
+ port,
85
+ host,
86
+ https,
87
+ onConnected: (ws, req, meta) => {
88
+ const authToken = new URL(req.url ?? "", "http://localhost").searchParams.get("vite_devtools_auth_token") ?? void 0;
89
+ if (isClientAuthDisabled) meta.isTrusted = true;
90
+ else if (authToken && contextInternal.storage.auth.value().trusted[authToken]) {
91
+ meta.isTrusted = true;
92
+ meta.clientAuthToken = authToken;
93
+ } else if (authToken && ((context.viteConfig.devtools?.config)?.clientAuthTokens ?? []).includes(authToken)) {
94
+ meta.isTrusted = true;
95
+ meta.clientAuthToken = authToken;
96
+ }
97
+ wsClients.add(ws);
98
+ const color = meta.isTrusted ? ansis_default.green : ansis_default.yellow;
99
+ const trustedKeys = Object.keys(contextInternal.storage.auth.value().trusted);
100
+ console.log(color`${MARK_INFO} Websocket client connected. [${meta.id}] [${meta.clientAuthToken}] (${meta.isTrusted ? "trusted" : "untrusted"}) authToken=${authToken} trustedKeys=${JSON.stringify(trustedKeys)} isClientAuthDisabled=${isClientAuthDisabled}`);
101
+ },
102
+ onDisconnected: (ws, meta) => {
103
+ wsClients.delete(ws);
104
+ console.log(ansis_default.red`${MARK_INFO} Websocket client disconnected. [${meta.id}]`);
105
+ }
106
+ });
107
+ const asyncStorage = new AsyncLocalStorage();
108
+ const rpcGroup = createRpcServer(rpcHost.functions, {
109
+ preset,
110
+ rpcOptions: {
111
+ onFunctionError(error, name) {
112
+ console.error(ansis_default.red`⬢ RPC error on executing "${ansis_default.bold(name)}":`);
113
+ console.error(error);
114
+ },
115
+ onGeneralError(error) {
116
+ console.error(ansis_default.red`⬢ RPC error on executing rpc`);
117
+ console.error(error);
118
+ },
119
+ resolver(name, fn) {
120
+ const rpc = this;
121
+ if (!name.startsWith(ANONYMOUS_SCOPE) && !rpc.$meta.isTrusted) return () => {
122
+ throw new Error(`Unauthorized access to method ${JSON.stringify(name)} from client [${rpc.$meta.id}]`);
123
+ };
124
+ if (!fn) return void 0;
125
+ return async function(...args) {
126
+ debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`);
127
+ return await asyncStorage.run({
128
+ rpc,
129
+ meta: rpc.$meta
130
+ }, async () => {
131
+ return (await fn).apply(this, args);
132
+ });
133
+ };
134
+ }
135
+ }
136
+ });
137
+ rpcHost._rpcGroup = rpcGroup;
138
+ rpcHost._asyncStorage = asyncStorage;
139
+ const getConnectionMeta = async () => {
140
+ return {
141
+ backend: "websocket",
142
+ websocket: port
143
+ };
144
+ };
145
+ return {
146
+ port,
147
+ rpc: rpcGroup,
148
+ rpcHost,
149
+ getConnectionMeta
150
+ };
151
+ }
152
+ //#endregion
153
+ //#region src/node/server.ts
154
+ var server_exports = /* @__PURE__ */ __exportAll({ createDevToolsMiddleware: () => createDevToolsMiddleware });
155
+ function generateAuthPageHtml() {
156
+ return `<!DOCTYPE html>
157
+ <html>
158
+ <head>
159
+ <title>Vite DevTools Authorization</title>
160
+ <style>
161
+ html { font-family: system-ui, sans-serif; padding: 2rem; }
162
+ body { height: 80vh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1rem; }
163
+ #message { font-size: 1.2rem; }
164
+ @media (prefers-color-scheme: dark) { html { background: #1a1a1a; color: #e0e0e0; } }
165
+ </style>
166
+ </head>
167
+ <body>
168
+ <div id="message">Verifying...</div>
169
+ <script>
170
+ const query = new URLSearchParams(location.search)
171
+ const id = query.get('id')
172
+ const el = document.getElementById('message')
173
+
174
+ if (!id) {
175
+ el.textContent = '\\u26a0\\ufe0f No auth token found. Please check your URL.'
176
+ el.style.color = '#df513f'
177
+ } else {
178
+ fetch(location.pathname.replace(/\\/$/, '') + '-verify?id=' + encodeURIComponent(id))
179
+ .then(async (r) => {
180
+ if (r.status !== 200) throw new Error(await r.text())
181
+ const data = await r.json()
182
+ const authToken = data.authToken
183
+
184
+ localStorage.setItem('__VITE_DEVTOOLS_CONNECTION_AUTH_TOKEN__', authToken)
185
+
186
+ try {
187
+ const bc = new BroadcastChannel('vite-devtools-auth')
188
+ bc.postMessage({ type: 'auth-update', authToken: authToken })
189
+ } catch {}
190
+
191
+ el.textContent = '\\u2705 Authorized! You can close this window now.'
192
+ window.close()
193
+ })
194
+ .catch((err) => {
195
+ el.textContent = '\\u26a0\\ufe0f Failed to authorize: ' + err.message
196
+ el.style.color = '#df513f'
197
+ })
198
+ }
199
+ <\/script>
200
+ </body>
201
+ </html>`;
202
+ }
203
+ async function createDevToolsMiddleware(options) {
204
+ const h3 = createApp();
205
+ const contextInternal = getInternalContext(options.context);
206
+ const { rpc, getConnectionMeta } = await createWsServer(options);
207
+ h3.use(`/${DEVTOOLS_CONNECTION_META_FILENAME}`, eventHandler(async (event) => {
208
+ event.node.res.setHeader("Content-Type", "application/json");
209
+ return event.node.res.end(JSON.stringify(await getConnectionMeta()));
210
+ }));
211
+ h3.use("/auth-verify", eventHandler((event) => {
212
+ const { id } = getQuery(event);
213
+ if (!id) {
214
+ event.node.res.statusCode = 400;
215
+ return event.node.res.end("Missing id parameter");
216
+ }
217
+ const clientAuthToken = consumeTempAuthToken(id, contextInternal.storage.auth);
218
+ if (!clientAuthToken) {
219
+ event.node.res.statusCode = 403;
220
+ return event.node.res.end("Invalid or expired auth token");
221
+ }
222
+ event.node.res.setHeader("Content-Type", "application/json");
223
+ return event.node.res.end(JSON.stringify({ authToken: clientAuthToken }));
224
+ }));
225
+ h3.use("/auth", eventHandler((event) => {
226
+ event.node.res.setHeader("Content-Type", "text/html");
227
+ return event.node.res.end(generateAuthPageHtml());
228
+ }));
229
+ h3.use(fromNodeMiddleware(sirv(dirClientStandalone, {
230
+ dev: true,
231
+ single: true
232
+ })));
233
+ return {
234
+ h3,
235
+ rpc,
236
+ middleware: toNodeListener(h3),
237
+ getConnectionMeta
238
+ };
239
+ }
240
+ //#endregion
241
+ export { refreshTempAuthToken as a, getTempAuthToken as i, server_exports as n, setPendingAuth as o, abortPendingAuth as r, createDevToolsMiddleware as t };
@@ -0,0 +1,3 @@
1
+ import { n as renderDockImportsMap } from "./server-DhChc9gv.js";
2
+ import "./dist-DpLy3ojW.js";
3
+ export { renderDockImportsMap };