@vitejs/devtools 0.0.0-alpha.33 → 0.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DockIcon-BxTh1m5v.js → DockIcon-LqhTiyo7.js} +2 -2
- package/dist/DockStandalone-D15T7P8h.js +82 -0
- package/dist/FloatingElements-DiZY-fXn.js +988 -0
- package/dist/{ViewBuiltinLogs-BwyIDX5w.js → ViewBuiltinLogs-DAC3EpNy.js} +2 -2
- package/dist/{ViewBuiltinTerminals-yFL0jGW0.js → ViewBuiltinTerminals-CaCzY10v.js} +3 -3
- package/dist/cli-commands-B8AbW52w.js +178 -0
- package/dist/cli-commands.js +2 -2
- package/dist/cli.js +2 -2
- package/dist/client/inject.js +37 -13
- package/dist/client/standalone/assets/DockStandalone-Be2ebLC6.js +8 -0
- package/dist/client/standalone/assets/ViewBuiltinLogs-gqCacjSC.js +1 -0
- package/dist/client/standalone/assets/{ViewBuiltinTerminals-BoJR1xWn.js → ViewBuiltinTerminals-EMrVQ_he.js} +2 -2
- package/dist/client/standalone/assets/_plugin-vue_export-helper-DdUndd8v.js +1 -0
- package/dist/client/standalone/assets/{index-7t5UlDkF.css → index-CkMgpkZF.css} +1 -1
- package/dist/client/standalone/assets/index-xigFHEkA.js +4 -0
- package/dist/client/standalone/index.html +3 -3
- package/dist/client/webcomponents.d.ts +20329 -145
- package/dist/client/webcomponents.js +54 -1043
- package/dist/config.js +1 -5
- package/dist/{dist-C5wFunwn.js → dist-CnHQWaMb.js} +3 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/{plugins-C3h3TsXX.js → plugins-tIIgS7bh.js} +78 -37
- package/dist/popup-CqYAUdYG.js +366 -0
- package/dist/utils--qjmgani.js +6 -0
- package/dist/{vue.runtime.esm-bundler-DL9ItCI-.js → vue.runtime.esm-bundler-Bou7Nbd4.js} +75 -30
- package/package.json +27 -9
- package/dist/cli-commands-BRi5CDUR.js +0 -94
- package/dist/client/standalone/assets/ViewBuiltinLogs-B6YocKEt.js +0 -1
- package/dist/client/standalone/assets/_plugin-vue_export-helper-DCOpKI5t.js +0 -1
- package/dist/client/standalone/assets/index-BmL7atlP.js +0 -3
- package/dist/docks-YFmtkjZj.js +0 -127
- /package/dist/{export-helper-C1Zyf6xf.js → export-helper-DOmNQzh6.js} +0 -0
package/dist/config.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
function isObject(value) {
|
|
3
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
1
|
+
import { t as isObject } from "./utils--qjmgani.js";
|
|
6
2
|
//#region src/node/config.ts
|
|
7
3
|
function normalizeDevToolsConfig(config, host) {
|
|
8
4
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as toRef$1, F as onScopeDispose, H as toValue, L as readonly, M as customRef, N as getCurrentScope, O as watch, R as ref, S as onMounted, U as unref, _ as getCurrentInstance, b as inject, k as watchEffect, s as computed, x as nextTick, y as hasInjectionContext, z as shallowRef } from "./vue.runtime.esm-bundler-
|
|
2
|
-
//#region ../../node_modules/.pnpm/@vueuse+shared@14.2.1_vue@3.5.
|
|
1
|
+
import { B as toRef$1, F as onScopeDispose, H as toValue, L as readonly, M as customRef, N as getCurrentScope, O as watch, R as ref, S as onMounted, U as unref, _ as getCurrentInstance, b as inject, k as watchEffect, s as computed, x as nextTick, y as hasInjectionContext, z as shallowRef } from "./vue.runtime.esm-bundler-Bou7Nbd4.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/@vueuse+shared@14.2.1_vue@3.5.30_typescript@5.9.3_/node_modules/@vueuse/shared/dist/index.js
|
|
3
3
|
/**
|
|
4
4
|
* Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
|
|
5
5
|
*
|
|
@@ -224,7 +224,7 @@ function watchImmediate(source, cb, options) {
|
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
//#endregion
|
|
227
|
-
//#region ../../node_modules/.pnpm/@vueuse+core@14.2.1_vue@3.5.
|
|
227
|
+
//#region ../../node_modules/.pnpm/@vueuse+core@14.2.1_vue@3.5.30_typescript@5.9.3_/node_modules/@vueuse/core/dist/index.js
|
|
228
228
|
const defaultWindow = isClient ? window : void 0;
|
|
229
229
|
isClient && window.document;
|
|
230
230
|
isClient && window.navigator;
|
package/dist/index.d.ts
CHANGED
|
@@ -103,11 +103,11 @@ declare const builtinRpcDeclarations: readonly [{
|
|
|
103
103
|
cacheable?: boolean;
|
|
104
104
|
args?: undefined;
|
|
105
105
|
returns?: undefined;
|
|
106
|
-
setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[
|
|
107
|
-
handler?: ((
|
|
108
|
-
dump?: _vitejs_devtools_rpc0.RpcDump<[
|
|
109
|
-
__resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[
|
|
110
|
-
__promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[
|
|
106
|
+
setup?: ((context: _vitejs_devtools_kit0.DevToolsNodeContext) => _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[string], Promise<any>>>) | undefined;
|
|
107
|
+
handler?: ((args_0: string) => Promise<any>) | undefined;
|
|
108
|
+
dump?: _vitejs_devtools_rpc0.RpcDump<[string], Promise<any>, _vitejs_devtools_kit0.DevToolsNodeContext> | undefined;
|
|
109
|
+
__resolved?: _vitejs_devtools_rpc0.RpcFunctionSetupResult<[string], Promise<any>> | undefined;
|
|
110
|
+
__promise?: _vitejs_devtools_rpc0.Thenable<_vitejs_devtools_rpc0.RpcFunctionSetupResult<[string], Promise<any>>> | undefined;
|
|
111
111
|
}, {
|
|
112
112
|
name: "devtoolskit:internal:rpc:server-state:patch";
|
|
113
113
|
type?: "query" | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as createDevToolsContext, r as createDevToolsMiddleware, t as DevTools } from "./plugins-tIIgS7bh.js";
|
|
2
2
|
export { DevTools, createDevToolsContext, createDevToolsMiddleware };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { t as isObject } from "./utils--qjmgani.js";
|
|
1
2
|
import { dirClientStandalone, dirDist } from "./dirs.js";
|
|
2
3
|
import { createDebug } from "obug";
|
|
3
4
|
import { debounce } from "perfect-debounce";
|
|
4
5
|
import { normalizePath, searchForWorkspaceRoot } from "vite";
|
|
5
6
|
import { toDataURL } from "mlly";
|
|
6
|
-
import { DEFAULT_STATE_USER_SETTINGS } from "@vitejs/devtools-kit/constants";
|
|
7
|
+
import { DEFAULT_STATE_USER_SETTINGS, DEVTOOLS_CONNECTION_META_FILENAME, DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID, DEVTOOLS_MOUNT_PATH } from "@vitejs/devtools-kit/constants";
|
|
7
8
|
import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
|
|
8
9
|
import { dirname, join } from "pathe";
|
|
9
10
|
import fs, { existsSync } from "node:fs";
|
|
@@ -61,11 +62,15 @@ function createStorage(options) {
|
|
|
61
62
|
...initialValue,
|
|
62
63
|
...savedValue
|
|
63
64
|
}), debounce: debounceTime = 100 } = options;
|
|
64
|
-
let initialValue;
|
|
65
|
-
if (fs.existsSync(options.filepath)) {
|
|
65
|
+
let initialValue = options.initialValue;
|
|
66
|
+
if (fs.existsSync(options.filepath)) try {
|
|
66
67
|
const savedValue = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
|
|
67
68
|
initialValue = mergeInitialValue ? mergeInitialValue(options.initialValue, savedValue) : savedValue;
|
|
68
|
-
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.warn(`[Vite DevTools] Failed to parse storage file: ${options.filepath}, falling back to defaults.`);
|
|
71
|
+
console.warn(error);
|
|
72
|
+
initialValue = options.initialValue;
|
|
73
|
+
}
|
|
69
74
|
const state = createSharedState({
|
|
70
75
|
initialValue,
|
|
71
76
|
enablePatches: false
|
|
@@ -112,6 +117,13 @@ var DevToolsDockHost = class {
|
|
|
112
117
|
category: "~builtin",
|
|
113
118
|
isHidden: true
|
|
114
119
|
},
|
|
120
|
+
{
|
|
121
|
+
type: "~builtin",
|
|
122
|
+
id: "~popup",
|
|
123
|
+
title: "Popup",
|
|
124
|
+
category: "~builtin",
|
|
125
|
+
icon: "ph:arrow-square-out-duotone"
|
|
126
|
+
},
|
|
115
127
|
{
|
|
116
128
|
type: "~builtin",
|
|
117
129
|
id: "~settings",
|
|
@@ -179,18 +191,23 @@ function createRpcSharedStateServerHost(rpc) {
|
|
|
179
191
|
for (const off of offs) off();
|
|
180
192
|
};
|
|
181
193
|
}
|
|
182
|
-
return {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
return {
|
|
195
|
+
get: async (key, options) => {
|
|
196
|
+
if (sharedState.has(key)) return sharedState.get(key);
|
|
197
|
+
if (options?.initialValue === void 0 && options?.sharedState === void 0) throw new Error(`Shared state of "${key}" is not found, please provide an initial value for the first time`);
|
|
198
|
+
debug$1("new-state", key);
|
|
199
|
+
const state = options.sharedState ?? createSharedState({
|
|
200
|
+
initialValue: options.initialValue,
|
|
201
|
+
enablePatches: false
|
|
202
|
+
});
|
|
203
|
+
registerSharedState(key, state);
|
|
204
|
+
sharedState.set(key, state);
|
|
205
|
+
return state;
|
|
206
|
+
},
|
|
207
|
+
keys() {
|
|
208
|
+
return Array.from(sharedState.keys());
|
|
209
|
+
}
|
|
210
|
+
};
|
|
194
211
|
}
|
|
195
212
|
//#endregion
|
|
196
213
|
//#region src/node/host-functions.ts
|
|
@@ -206,8 +223,16 @@ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
|
|
|
206
223
|
this.sharedState = createRpcSharedStateServerHost(this);
|
|
207
224
|
}
|
|
208
225
|
sharedState;
|
|
226
|
+
async invokeLocal(method, ...args) {
|
|
227
|
+
if (!this.definitions.has(method)) throw new Error(`RPC function "${String(method)}" is not registered`);
|
|
228
|
+
const handler = await this.getHandler(method);
|
|
229
|
+
return await Promise.resolve(handler(...args));
|
|
230
|
+
}
|
|
209
231
|
async broadcast(options) {
|
|
210
|
-
if (!this._rpcGroup)
|
|
232
|
+
if (!this._rpcGroup) {
|
|
233
|
+
if (this.context.mode === "build") return;
|
|
234
|
+
throw new Error("RpcFunctionsHost] RpcGroup is not set, it likely to be an internal bug of Vite DevTools");
|
|
235
|
+
}
|
|
211
236
|
debugBroadcast(JSON.stringify(options.method));
|
|
212
237
|
await Promise.all(this._rpcGroup.clients.map((client) => {
|
|
213
238
|
if (options.filter?.(client) === false) return void 0;
|
|
@@ -248,6 +273,7 @@ var DevToolsTerminalHost = class {
|
|
|
248
273
|
this.events.emit("terminal:session:updated", session);
|
|
249
274
|
}
|
|
250
275
|
remove(session) {
|
|
276
|
+
this._boundStreams.get(session.id)?.dispose();
|
|
251
277
|
this.sessions.delete(session.id);
|
|
252
278
|
this.events.emit("terminal:session:updated", session);
|
|
253
279
|
this._boundStreams.delete(session.id);
|
|
@@ -1302,6 +1328,9 @@ const rpcServerList = defineRpcFunction({
|
|
|
1302
1328
|
const sharedStateGet = defineRpcFunction({
|
|
1303
1329
|
name: "devtoolskit:internal:rpc:server-state:get",
|
|
1304
1330
|
type: "query",
|
|
1331
|
+
dump: (context) => {
|
|
1332
|
+
return { inputs: context.rpc.sharedState.keys().map((key) => [key]) };
|
|
1333
|
+
},
|
|
1305
1334
|
setup: (context) => {
|
|
1306
1335
|
return { handler: async (key) => {
|
|
1307
1336
|
return (await context.rpc.sharedState.get(key)).value();
|
|
@@ -1420,6 +1449,12 @@ const builtinRpcDeclarations = [
|
|
|
1420
1449
|
//#endregion
|
|
1421
1450
|
//#region src/node/context.ts
|
|
1422
1451
|
const debugSetup = createDebug("vite:devtools:context:setup");
|
|
1452
|
+
function shouldSkipSetupByCapabilities(plugin, mode) {
|
|
1453
|
+
const modeCapabilities = plugin.devtools?.capabilities?.[mode];
|
|
1454
|
+
if (modeCapabilities === false) return true;
|
|
1455
|
+
if (!isObject(modeCapabilities)) return false;
|
|
1456
|
+
return Object.values(modeCapabilities).includes(false);
|
|
1457
|
+
}
|
|
1423
1458
|
async function createDevToolsContext(viteConfig, viteServer) {
|
|
1424
1459
|
const cwd = viteConfig.root;
|
|
1425
1460
|
const context = {
|
|
@@ -1447,14 +1482,14 @@ async function createDevToolsContext(viteConfig, viteServer) {
|
|
|
1447
1482
|
const docksSharedState = await rpcHost.sharedState.get("devtoolskit:internal:docks", { initialValue: [] });
|
|
1448
1483
|
docksHost.events.on("dock:entry:updated", debounce(() => {
|
|
1449
1484
|
docksSharedState.mutate(() => context.docks.values());
|
|
1450
|
-
}, 10));
|
|
1485
|
+
}, context.mode === "build" ? 0 : 10));
|
|
1451
1486
|
terminalsHost.events.on("terminal:session:updated", debounce(() => {
|
|
1452
1487
|
rpcHost.broadcast({
|
|
1453
1488
|
method: "devtoolskit:internal:terminals:updated",
|
|
1454
1489
|
args: []
|
|
1455
1490
|
});
|
|
1456
1491
|
docksSharedState.mutate(() => context.docks.values());
|
|
1457
|
-
}, 10));
|
|
1492
|
+
}, context.mode === "build" ? 0 : 10));
|
|
1458
1493
|
terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
|
|
1459
1494
|
rpcHost.broadcast({
|
|
1460
1495
|
method: "devtoolskit:internal:terminals:stream-chunk",
|
|
@@ -1464,6 +1499,10 @@ async function createDevToolsContext(viteConfig, viteServer) {
|
|
|
1464
1499
|
const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
|
|
1465
1500
|
for (const plugin of plugins) {
|
|
1466
1501
|
if (!plugin.devtools?.setup) continue;
|
|
1502
|
+
if (shouldSkipSetupByCapabilities(plugin, context.mode)) {
|
|
1503
|
+
debugSetup(`skipping plugin ${JSON.stringify(plugin.name)} due to disabled capabilities in ${context.mode} mode`);
|
|
1504
|
+
continue;
|
|
1505
|
+
}
|
|
1467
1506
|
try {
|
|
1468
1507
|
debugSetup(`setting up plugin ${JSON.stringify(plugin.name)}`);
|
|
1469
1508
|
await plugin.devtools?.setup?.(context);
|
|
@@ -1799,7 +1838,7 @@ async function createWsServer(options) {
|
|
|
1799
1838
|
async function createDevToolsMiddleware(options) {
|
|
1800
1839
|
const h3 = createApp();
|
|
1801
1840
|
const { rpc, getConnectionMeta } = await createWsServer(options);
|
|
1802
|
-
h3.use(
|
|
1841
|
+
h3.use(`/${DEVTOOLS_CONNECTION_META_FILENAME}`, eventHandler(async (event) => {
|
|
1803
1842
|
event.node.res.setHeader("Content-Type", "application/json");
|
|
1804
1843
|
return event.node.res.end(JSON.stringify(await getConnectionMeta()));
|
|
1805
1844
|
}));
|
|
@@ -1819,6 +1858,20 @@ async function createDevToolsMiddleware(options) {
|
|
|
1819
1858
|
/**
|
|
1820
1859
|
* Core plugin for enabling Vite DevTools
|
|
1821
1860
|
*/
|
|
1861
|
+
function renderDockImportsMap(docks) {
|
|
1862
|
+
const map = /* @__PURE__ */ new Map();
|
|
1863
|
+
for (const dock of docks) {
|
|
1864
|
+
const id = `${dock.type}:${dock.id}`;
|
|
1865
|
+
if (dock.type === "action") map.set(id, dock.action);
|
|
1866
|
+
else if (dock.type === "custom-render") map.set(id, dock.renderer);
|
|
1867
|
+
else if (dock.type === "iframe" && dock.clientScript) map.set(id, dock.clientScript);
|
|
1868
|
+
}
|
|
1869
|
+
return [
|
|
1870
|
+
`export const importsMap = {`,
|
|
1871
|
+
...[...map.entries()].filter(([, entry]) => entry != null).map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName ?? "default")}]),`),
|
|
1872
|
+
"}"
|
|
1873
|
+
].join("\n");
|
|
1874
|
+
}
|
|
1822
1875
|
function DevToolsServer() {
|
|
1823
1876
|
let context;
|
|
1824
1877
|
return {
|
|
@@ -1833,27 +1886,15 @@ function DevToolsServer() {
|
|
|
1833
1886
|
hostWebSocket: host,
|
|
1834
1887
|
context
|
|
1835
1888
|
});
|
|
1836
|
-
viteDevServer.middlewares.use(
|
|
1889
|
+
viteDevServer.middlewares.use(DEVTOOLS_MOUNT_PATH, middleware);
|
|
1837
1890
|
},
|
|
1838
1891
|
resolveId(id) {
|
|
1839
|
-
if (id ===
|
|
1892
|
+
if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) return id;
|
|
1840
1893
|
},
|
|
1841
1894
|
load(id) {
|
|
1842
|
-
if (id ===
|
|
1895
|
+
if (id === DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID) {
|
|
1843
1896
|
if (!context) throw new Error("DevTools context is not initialized");
|
|
1844
|
-
|
|
1845
|
-
const map = /* @__PURE__ */ new Map();
|
|
1846
|
-
for (const dock of docks) {
|
|
1847
|
-
const id = `${dock.type}:${dock.id}`;
|
|
1848
|
-
if (dock.type === "action") map.set(id, dock.action);
|
|
1849
|
-
else if (dock.type === "custom-render") map.set(id, dock.renderer);
|
|
1850
|
-
else if (dock.type === "iframe" && dock.clientScript) map.set(id, dock.clientScript);
|
|
1851
|
-
}
|
|
1852
|
-
return [
|
|
1853
|
-
`export const importsMap = {`,
|
|
1854
|
-
...[...map.entries()].filter(([, entry]) => entry != null).map(([id, { importFrom, importName }]) => ` [${JSON.stringify(id)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName)}]),`),
|
|
1855
|
-
"}"
|
|
1856
|
-
].join("\n");
|
|
1897
|
+
return renderDockImportsMap(context.docks.values());
|
|
1857
1898
|
}
|
|
1858
1899
|
}
|
|
1859
1900
|
};
|
|
@@ -1867,4 +1908,4 @@ async function DevTools(options = {}) {
|
|
|
1867
1908
|
return plugins;
|
|
1868
1909
|
}
|
|
1869
1910
|
//#endregion
|
|
1870
|
-
export {
|
|
1911
|
+
export { createDevToolsContext as a, getPort as i, renderDockImportsMap as n, ansis_default as o, createDevToolsMiddleware as r, DevTools as t };
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { I as reactive, O as watch, P as markRaw, z as shallowRef } from "./vue.runtime.esm-bundler-Bou7Nbd4.js";
|
|
2
|
+
import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
|
|
3
|
+
//#region src/client/webcomponents/constants.ts
|
|
4
|
+
const BUILTIN_ENTRY_CLIENT_AUTH_NOTICE = Object.freeze({
|
|
5
|
+
type: "~builtin",
|
|
6
|
+
id: "~client-auth-notice",
|
|
7
|
+
title: "Unauthorized",
|
|
8
|
+
icon: "i-fluent-emoji-flat-warning"
|
|
9
|
+
});
|
|
10
|
+
const BUILTIN_ENTRIES = Object.freeze([BUILTIN_ENTRY_CLIENT_AUTH_NOTICE]);
|
|
11
|
+
const DEFAULT_CATEGORIES_ORDER = {
|
|
12
|
+
"~viteplus": -1e3,
|
|
13
|
+
"default": 0,
|
|
14
|
+
"app": 100,
|
|
15
|
+
"framework": 200,
|
|
16
|
+
"web": 300,
|
|
17
|
+
"advanced": 400,
|
|
18
|
+
"~builtin": 1e3
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/client/webcomponents/state/dock-settings.ts
|
|
22
|
+
/**
|
|
23
|
+
* Group and sort dock entries based on user settings.
|
|
24
|
+
* Filters out hidden entries and categories, sorts by pinned status, custom order, and default order.
|
|
25
|
+
*/
|
|
26
|
+
function docksGroupByCategories(entries, settings, options) {
|
|
27
|
+
const { docksHidden, docksCategoriesHidden, docksCustomOrder, docksPinned } = settings;
|
|
28
|
+
const { includeHidden = false } = options ?? {};
|
|
29
|
+
const map = /* @__PURE__ */ new Map();
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
if (entry.isHidden && !includeHidden) continue;
|
|
32
|
+
if (!includeHidden && docksHidden.includes(entry.id)) continue;
|
|
33
|
+
const category = entry.category ?? "default";
|
|
34
|
+
if (!includeHidden && docksCategoriesHidden.includes(category)) continue;
|
|
35
|
+
if (!map.has(category)) map.set(category, []);
|
|
36
|
+
map.get(category).push(entry);
|
|
37
|
+
}
|
|
38
|
+
const grouped = Array.from(map.entries()).sort(([a], [b]) => {
|
|
39
|
+
const ia = DEFAULT_CATEGORIES_ORDER[a] || 0;
|
|
40
|
+
const ib = DEFAULT_CATEGORIES_ORDER[b] || 0;
|
|
41
|
+
return ib === ia ? b.localeCompare(a) : ia - ib;
|
|
42
|
+
});
|
|
43
|
+
grouped.forEach(([_, items]) => {
|
|
44
|
+
items.sort((a, b) => {
|
|
45
|
+
const aPinned = docksPinned.includes(a.id);
|
|
46
|
+
if (aPinned !== docksPinned.includes(b.id)) return aPinned ? -1 : 1;
|
|
47
|
+
const customOrderA = docksCustomOrder[a.id] ?? 0;
|
|
48
|
+
const customOrderB = docksCustomOrder[b.id] ?? 0;
|
|
49
|
+
if (customOrderA !== customOrderB) return customOrderA - customOrderB;
|
|
50
|
+
const ia = a.defaultOrder ?? 0;
|
|
51
|
+
const ib = b.defaultOrder ?? 0;
|
|
52
|
+
return ib === ia ? b.title.localeCompare(a.title) : ia - ib;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
return grouped;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Split grouped entries into visible and overflow based on capacity.
|
|
59
|
+
*/
|
|
60
|
+
function docksSplitGroupsWithCapacity(groups, capacity) {
|
|
61
|
+
const visible = [];
|
|
62
|
+
const overflow = [];
|
|
63
|
+
let left = capacity;
|
|
64
|
+
for (const [category, items] of groups) if (left <= 0) overflow.push([category, items]);
|
|
65
|
+
else if (items.length > left) {
|
|
66
|
+
visible.push([category, items.slice(0, left)]);
|
|
67
|
+
overflow.push([category, items.slice(left)]);
|
|
68
|
+
left = 0;
|
|
69
|
+
} else {
|
|
70
|
+
left -= items.length;
|
|
71
|
+
visible.push([category, items]);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
visible,
|
|
75
|
+
overflow
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/client/webcomponents/state/docks.ts
|
|
80
|
+
function DEFAULT_DOCK_PANEL_STORE() {
|
|
81
|
+
return {
|
|
82
|
+
width: 80,
|
|
83
|
+
height: 80,
|
|
84
|
+
top: 0,
|
|
85
|
+
left: 10,
|
|
86
|
+
position: "bottom",
|
|
87
|
+
open: false,
|
|
88
|
+
inactiveTimeout: 3e3
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function createDockEntryState(entry, selected) {
|
|
92
|
+
const events = createEventEmitter();
|
|
93
|
+
const state = reactive({
|
|
94
|
+
entryMeta: entry,
|
|
95
|
+
get isActive() {
|
|
96
|
+
return selected.value?.id === entry.id;
|
|
97
|
+
},
|
|
98
|
+
domElements: {},
|
|
99
|
+
events: markRaw(events)
|
|
100
|
+
});
|
|
101
|
+
watch(() => selected.value?.id, (newSelectedId) => {
|
|
102
|
+
if (newSelectedId === entry.id) events.emit("entry:activated");
|
|
103
|
+
else events.emit("entry:deactivated");
|
|
104
|
+
}, { immediate: true });
|
|
105
|
+
watch(() => state.domElements.iframe, (newIframe) => {
|
|
106
|
+
if (newIframe) events.emit("dom:iframe:mounted", newIframe);
|
|
107
|
+
}, { immediate: true });
|
|
108
|
+
watch(() => state.domElements.panel, (newPanel) => {
|
|
109
|
+
if (newPanel) events.emit("dom:panel:mounted", newPanel);
|
|
110
|
+
}, { immediate: true });
|
|
111
|
+
return state;
|
|
112
|
+
}
|
|
113
|
+
function sharedStateToRef(sharedState) {
|
|
114
|
+
const ref = shallowRef(sharedState.value());
|
|
115
|
+
sharedState.on("updated", (newState) => {
|
|
116
|
+
ref.value = newState;
|
|
117
|
+
});
|
|
118
|
+
return ref;
|
|
119
|
+
}
|
|
120
|
+
const docksEntriesRefByRpc = /* @__PURE__ */ new WeakMap();
|
|
121
|
+
async function useDocksEntries(rpc) {
|
|
122
|
+
if (docksEntriesRefByRpc.has(rpc)) return docksEntriesRefByRpc.get(rpc);
|
|
123
|
+
const docksEntriesRef = sharedStateToRef(await rpc.sharedState.get("devtoolskit:internal:docks", { initialValue: [] }));
|
|
124
|
+
docksEntriesRefByRpc.set(rpc, docksEntriesRef);
|
|
125
|
+
return docksEntriesRef;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/client/webcomponents/state/floating-tooltip.ts
|
|
129
|
+
const tooltip = shallowRef(null);
|
|
130
|
+
const docksOverflowPanel = shallowRef(null);
|
|
131
|
+
const dockContextMenu = shallowRef(null);
|
|
132
|
+
function setFloatingTooltip(info) {
|
|
133
|
+
tooltip.value = info;
|
|
134
|
+
}
|
|
135
|
+
function useFloatingTooltip() {
|
|
136
|
+
return tooltip;
|
|
137
|
+
}
|
|
138
|
+
function setDocksOverflowPanel(info) {
|
|
139
|
+
docksOverflowPanel.value = info;
|
|
140
|
+
}
|
|
141
|
+
function useDocksOverflowPanel() {
|
|
142
|
+
return docksOverflowPanel;
|
|
143
|
+
}
|
|
144
|
+
function setDockContextMenu(info) {
|
|
145
|
+
dockContextMenu.value = info;
|
|
146
|
+
}
|
|
147
|
+
function useDockContextMenu() {
|
|
148
|
+
return dockContextMenu;
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/client/webcomponents/state/popup.ts
|
|
152
|
+
const PANEL_MIN_SIZE = 20;
|
|
153
|
+
const PANEL_MAX_SIZE = 100;
|
|
154
|
+
const POPUP_MIN_WIDTH = 320;
|
|
155
|
+
const POPUP_MIN_HEIGHT = 240;
|
|
156
|
+
const POPUP_DOCK_ID = "~popup";
|
|
157
|
+
const POPUP_WINDOW_ATTRIBUTE = "data-vite-devtools-popup-window";
|
|
158
|
+
const MAIN_FRAME_ACTION_HANDLER_KEY = "__VITE_DEVTOOLS_TRIGGER_DOCK_ACTION__";
|
|
159
|
+
const popupWindow = shallowRef(null);
|
|
160
|
+
const isPopupOpen = shallowRef(false);
|
|
161
|
+
const popupEvents = createEventEmitter();
|
|
162
|
+
let detachPopupListeners;
|
|
163
|
+
let detachColorModeSync;
|
|
164
|
+
let popupDockElement;
|
|
165
|
+
let loadDockStandalone = async () => {
|
|
166
|
+
return await import("./DockStandalone-D15T7P8h.js").then((m) => m.DockStandalone);
|
|
167
|
+
};
|
|
168
|
+
popupEvents.on("popup:open-requested", (context) => {
|
|
169
|
+
openDockPopup(context);
|
|
170
|
+
});
|
|
171
|
+
function getDocumentPictureInPicture() {
|
|
172
|
+
if (typeof window === "undefined") return;
|
|
173
|
+
return window.documentPictureInPicture;
|
|
174
|
+
}
|
|
175
|
+
function clearListeners() {
|
|
176
|
+
detachPopupListeners?.();
|
|
177
|
+
detachPopupListeners = void 0;
|
|
178
|
+
detachColorModeSync?.();
|
|
179
|
+
detachColorModeSync = void 0;
|
|
180
|
+
}
|
|
181
|
+
function resolveColorMode() {
|
|
182
|
+
const sourceWindow = window;
|
|
183
|
+
const elements = [sourceWindow.document?.documentElement, sourceWindow.document?.body].filter(Boolean);
|
|
184
|
+
for (const element of elements) {
|
|
185
|
+
if (element?.classList?.contains("dark")) return "dark";
|
|
186
|
+
if (element?.classList?.contains("light")) return "light";
|
|
187
|
+
const dataTheme = element?.getAttribute?.("data-theme");
|
|
188
|
+
if (dataTheme === "dark" || dataTheme === "light") return dataTheme;
|
|
189
|
+
}
|
|
190
|
+
if (sourceWindow.matchMedia?.("(prefers-color-scheme: dark)").matches) return "dark";
|
|
191
|
+
return "light";
|
|
192
|
+
}
|
|
193
|
+
function applyPopupColorMode(popup, mode) {
|
|
194
|
+
popup.document.documentElement?.setAttribute("data-vite-devtools-color-mode", mode);
|
|
195
|
+
popup.document.documentElement?.style.setProperty("color-scheme", mode);
|
|
196
|
+
popupDockElement?.setAttribute("data-vite-devtools-color-mode", mode);
|
|
197
|
+
}
|
|
198
|
+
function setupPopupColorModeSync(popup) {
|
|
199
|
+
const cleanups = [];
|
|
200
|
+
const update = () => applyPopupColorMode(popup, resolveColorMode());
|
|
201
|
+
update();
|
|
202
|
+
const sourceWindow = window;
|
|
203
|
+
const sourceDocument = sourceWindow.document;
|
|
204
|
+
if (typeof MutationObserver !== "undefined" && sourceDocument) {
|
|
205
|
+
const observer = new MutationObserver(update);
|
|
206
|
+
for (const element of [sourceDocument.documentElement, sourceDocument.body]) {
|
|
207
|
+
if (!element) continue;
|
|
208
|
+
observer.observe(element, {
|
|
209
|
+
attributes: true,
|
|
210
|
+
attributeFilter: [
|
|
211
|
+
"class",
|
|
212
|
+
"data-theme",
|
|
213
|
+
"style"
|
|
214
|
+
]
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
cleanups.push(() => observer.disconnect());
|
|
218
|
+
}
|
|
219
|
+
if (sourceWindow.matchMedia) {
|
|
220
|
+
const darkQuery = sourceWindow.matchMedia("(prefers-color-scheme: dark)");
|
|
221
|
+
const lightQuery = sourceWindow.matchMedia("(prefers-color-scheme: light)");
|
|
222
|
+
darkQuery.addEventListener("change", update);
|
|
223
|
+
lightQuery.addEventListener("change", update);
|
|
224
|
+
cleanups.push(() => {
|
|
225
|
+
darkQuery.removeEventListener("change", update);
|
|
226
|
+
lightQuery.removeEventListener("change", update);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
return () => {
|
|
230
|
+
cleanups.forEach((fn) => fn());
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function unmountPopupElement() {
|
|
234
|
+
popupDockElement?.remove();
|
|
235
|
+
popupDockElement = void 0;
|
|
236
|
+
}
|
|
237
|
+
function clearPopupState() {
|
|
238
|
+
clearListeners();
|
|
239
|
+
unmountPopupElement();
|
|
240
|
+
popupWindow.value = null;
|
|
241
|
+
isPopupOpen.value = false;
|
|
242
|
+
}
|
|
243
|
+
function clamp(value, min, max) {
|
|
244
|
+
return Math.min(Math.max(value, min), max);
|
|
245
|
+
}
|
|
246
|
+
function syncPanelSizeFromPopup(context, popup) {
|
|
247
|
+
if (window.innerWidth <= 0 || window.innerHeight <= 0) return;
|
|
248
|
+
context.panel.store.width = clamp(Math.round(popup.innerWidth / window.innerWidth * 100), PANEL_MIN_SIZE, PANEL_MAX_SIZE);
|
|
249
|
+
context.panel.store.height = clamp(Math.round(popup.innerHeight / window.innerHeight * 100), PANEL_MIN_SIZE, PANEL_MAX_SIZE);
|
|
250
|
+
}
|
|
251
|
+
async function mountStandaloneApp(context, popup) {
|
|
252
|
+
const DockStandaloneElement = await loadDockStandalone();
|
|
253
|
+
const baseStyle = popup.document.createElement("style");
|
|
254
|
+
baseStyle.textContent = [
|
|
255
|
+
"html, body {",
|
|
256
|
+
" margin: 0;",
|
|
257
|
+
" padding: 0;",
|
|
258
|
+
" width: 100%;",
|
|
259
|
+
" height: 100%;",
|
|
260
|
+
" overflow: hidden;",
|
|
261
|
+
" background: transparent;",
|
|
262
|
+
"}",
|
|
263
|
+
"#vite-devtools-popup-root {",
|
|
264
|
+
" width: 100vw;",
|
|
265
|
+
" height: 100vh;",
|
|
266
|
+
"}",
|
|
267
|
+
"#vite-devtools-popup-root > vite-devtools-dock-standalone {",
|
|
268
|
+
" display: block;",
|
|
269
|
+
" width: 100%;",
|
|
270
|
+
" height: 100%;",
|
|
271
|
+
"}"
|
|
272
|
+
].join("\n");
|
|
273
|
+
popup.document.title = "Vite DevTools";
|
|
274
|
+
popup.document.documentElement?.setAttribute(POPUP_WINDOW_ATTRIBUTE, "");
|
|
275
|
+
popup.document.head?.appendChild(baseStyle);
|
|
276
|
+
popup.document.body.textContent = "";
|
|
277
|
+
const appRoot = popup.document.createElement("div");
|
|
278
|
+
appRoot.id = "vite-devtools-popup-root";
|
|
279
|
+
popup.document.body.appendChild(appRoot);
|
|
280
|
+
const dockElement = new DockStandaloneElement({ context });
|
|
281
|
+
popupDockElement = dockElement;
|
|
282
|
+
appRoot.appendChild(dockElement);
|
|
283
|
+
}
|
|
284
|
+
function isDockPopupSupported() {
|
|
285
|
+
return !!getDocumentPictureInPicture()?.requestWindow;
|
|
286
|
+
}
|
|
287
|
+
function isRunningInDockPopupWindow() {
|
|
288
|
+
if (typeof window === "undefined") return false;
|
|
289
|
+
return !!window.document?.documentElement?.hasAttribute?.(POPUP_WINDOW_ATTRIBUTE);
|
|
290
|
+
}
|
|
291
|
+
function registerMainFrameDockActionHandler(handler) {
|
|
292
|
+
if (typeof window === "undefined") return;
|
|
293
|
+
if (isRunningInDockPopupWindow()) return;
|
|
294
|
+
window[MAIN_FRAME_ACTION_HANDLER_KEY] = handler;
|
|
295
|
+
}
|
|
296
|
+
async function triggerMainFrameDockAction(entryId) {
|
|
297
|
+
if (typeof window === "undefined") return void 0;
|
|
298
|
+
if (!isRunningInDockPopupWindow()) return void 0;
|
|
299
|
+
try {
|
|
300
|
+
const opener = window.opener;
|
|
301
|
+
if (!opener || opener.closed) return void 0;
|
|
302
|
+
const handler = opener[MAIN_FRAME_ACTION_HANDLER_KEY];
|
|
303
|
+
if (typeof handler !== "function") return void 0;
|
|
304
|
+
return await handler(entryId);
|
|
305
|
+
} catch {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function isDockPopupEntryVisible() {
|
|
310
|
+
return isDockPopupSupported() && !isPopupOpen.value && !isRunningInDockPopupWindow();
|
|
311
|
+
}
|
|
312
|
+
function filterPopupDockEntry(groups) {
|
|
313
|
+
return groups.map(([category, entries]) => [category, entries.filter((entry) => entry.id !== POPUP_DOCK_ID)]).filter(([, entries]) => entries.length > 0);
|
|
314
|
+
}
|
|
315
|
+
function useIsDockPopupOpen() {
|
|
316
|
+
return isPopupOpen;
|
|
317
|
+
}
|
|
318
|
+
function requestDockPopupOpen(context) {
|
|
319
|
+
popupEvents.emit("popup:open-requested", context);
|
|
320
|
+
}
|
|
321
|
+
function closeDockPopup() {
|
|
322
|
+
const popup = popupWindow.value;
|
|
323
|
+
clearPopupState();
|
|
324
|
+
if (!popup || popup.closed) return;
|
|
325
|
+
popup.close();
|
|
326
|
+
}
|
|
327
|
+
async function openDockPopup(context) {
|
|
328
|
+
setDocksOverflowPanel(null);
|
|
329
|
+
const currentPopup = popupWindow.value;
|
|
330
|
+
if (currentPopup?.closed) clearPopupState();
|
|
331
|
+
else if (currentPopup) {
|
|
332
|
+
currentPopup.focus();
|
|
333
|
+
return currentPopup;
|
|
334
|
+
}
|
|
335
|
+
const documentPictureInPicture = getDocumentPictureInPicture();
|
|
336
|
+
if (!documentPictureInPicture?.requestWindow) return null;
|
|
337
|
+
let openedPopup;
|
|
338
|
+
try {
|
|
339
|
+
const popup = openedPopup = await documentPictureInPicture.requestWindow({
|
|
340
|
+
width: Math.max(POPUP_MIN_WIDTH, Math.round(window.innerWidth * context.panel.store.width / 100)),
|
|
341
|
+
height: Math.max(POPUP_MIN_HEIGHT, Math.round(window.innerHeight * context.panel.store.height / 100))
|
|
342
|
+
});
|
|
343
|
+
await mountStandaloneApp(context, popup);
|
|
344
|
+
detachColorModeSync = setupPopupColorModeSync(popup);
|
|
345
|
+
const onResize = () => syncPanelSizeFromPopup(context, popup);
|
|
346
|
+
const onPageHide = () => {
|
|
347
|
+
if (popupWindow.value !== popup) return;
|
|
348
|
+
clearPopupState();
|
|
349
|
+
};
|
|
350
|
+
popup.addEventListener("resize", onResize);
|
|
351
|
+
popup.addEventListener("pagehide", onPageHide);
|
|
352
|
+
detachPopupListeners = () => {
|
|
353
|
+
popup.removeEventListener("resize", onResize);
|
|
354
|
+
popup.removeEventListener("pagehide", onPageHide);
|
|
355
|
+
};
|
|
356
|
+
popupWindow.value = popup;
|
|
357
|
+
isPopupOpen.value = true;
|
|
358
|
+
return popup;
|
|
359
|
+
} catch {
|
|
360
|
+
if (openedPopup && !openedPopup.closed) openedPopup.close();
|
|
361
|
+
clearPopupState();
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
//#endregion
|
|
366
|
+
export { useDocksEntries as _, requestDockPopupOpen as a, BUILTIN_ENTRIES as b, setDockContextMenu as c, useDockContextMenu as d, useDocksOverflowPanel as f, sharedStateToRef as g, createDockEntryState as h, registerMainFrameDockActionHandler as i, setDocksOverflowPanel as l, DEFAULT_DOCK_PANEL_STORE as m, filterPopupDockEntry as n, triggerMainFrameDockAction as o, useFloatingTooltip as p, isDockPopupEntryVisible as r, useIsDockPopupOpen as s, closeDockPopup as t, setFloatingTooltip as u, docksGroupByCategories as v, BUILTIN_ENTRY_CLIENT_AUTH_NOTICE as x, docksSplitGroupsWithCapacity as y };
|