@vitejs/devtools 0.1.8 → 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.
- package/dist/{DockIcon-zZkKuxFy.js → DockIcon-7v-JouW5.js} +25 -25
- package/dist/DockStandalone-DZ0INpRC.js +3246 -0
- package/dist/{LogItem-D-AbVX5q.js → LogItem-Ca0SsU39.js} +20 -17
- package/dist/{ViewBuiltinLogs-D9GVXA00.js → ViewBuiltinLogs-B_CLlali.js} +2 -2
- package/dist/{ViewBuiltinTerminals-afgLtRQP.js → ViewBuiltinTerminals-ZrMObMte.js} +2 -3
- package/dist/auth-state-DXCxEqSd.js +54 -0
- package/dist/build-static-zB8LrlMJ.js +49 -0
- package/dist/cli-commands.js +10 -45
- package/dist/client/inject.js +186 -3
- package/dist/client/standalone/assets/DockStandalone-BUOgWTCb.js +1 -0
- package/dist/client/standalone/assets/LogItem-BnVhub2j.js +1 -0
- package/dist/client/standalone/assets/ViewBuiltinLogs-rU-E-8qT.js +1 -0
- package/dist/client/standalone/assets/{ViewBuiltinTerminals-CpNVjAgX.js → ViewBuiltinTerminals-UWfUyC_P.js} +2 -2
- package/dist/client/standalone/assets/{ViewJsonRender-CbWAIBeO.js → ViewJsonRender-De5eeIha.js} +3 -3
- package/dist/client/standalone/assets/dist-CAaP5Isp.js +1 -0
- package/dist/client/standalone/assets/iconify-C-CPDXMf.js +2 -0
- package/dist/client/standalone/assets/index-DtZFMvER.css +1 -0
- package/dist/client/standalone/assets/index-hQ4JAD5S.js +3 -0
- package/dist/client/standalone/assets/runtime-core.esm-bundler-Bvz2jy0O.js +1 -0
- package/dist/client/standalone/index.html +6 -5
- package/dist/client/webcomponents.js +28 -25
- package/dist/{server-DhChc9gv.js → context-DmXts6Ac.js} +112 -53
- package/dist/{dist-CBtGbo90.js → dist-CCdqIez-.js} +124 -1
- package/dist/index.d.ts +42 -2
- package/dist/index.js +3 -4
- package/dist/internal.d.ts +1 -1
- package/dist/plugins-vfc-N600.js +59 -0
- package/dist/{popup-CAT8YohS.js → popup-DcuzpgO2.js} +113 -54
- package/dist/server-C54I1zbj.js +2 -0
- package/dist/server-DH39-LHL.js +50 -0
- package/dist/{server-BuWZ1h8p.js → server-DSh-GQIq.js} +3 -56
- package/dist/{standalone-CAJbdnf4.js → standalone-w_GYdx1T.js} +2 -3
- package/package.json +8 -6
- package/dist/DockStandalone-BuMVHLt_.js +0 -1256
- package/dist/client/standalone/assets/DockStandalone-DvxQ5kAU.js +0 -1
- package/dist/client/standalone/assets/LogItem-Mx4UyReX.js +0 -1
- package/dist/client/standalone/assets/ViewBuiltinLogs-C4j4vgSn.js +0 -1
- package/dist/client/standalone/assets/dist-DIlAYcjk.js +0 -1
- package/dist/client/standalone/assets/index-BEyoIK7m.css +0 -1
- package/dist/client/standalone/assets/index-BGGAiDua.js +0 -4
- package/dist/client/standalone/assets/runtime-core.esm-bundler-CJlaYmKv.js +0 -1
- package/dist/plugins-DfC1vp4w.js +0 -31
- package/dist/server-Ca6LOTxO.js +0 -3
- /package/dist/{ViewJsonRender-DtluXw3F.js → ViewJsonRender-Cc5BPfnv.js} +0 -0
- /package/dist/{context-internal-BA4ba-FN.d.ts → context-internal-Ys7Zu3q3.d.ts} +0 -0
- /package/dist/{static-dump-Q0iG9hz3.js → static-dump-BqRb_x-O.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as useTimeAgo } from "./dist-CCdqIez-.js";
|
|
2
2
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, reactive, renderList, renderSlot, toDisplayString, unref } from "vue";
|
|
3
3
|
//#region src/client/webcomponents/state/toasts.ts
|
|
4
4
|
const toasts = reactive([]);
|
|
@@ -154,16 +154,17 @@ const _hoisted_2 = {
|
|
|
154
154
|
key: 0,
|
|
155
155
|
class: "flex-none mt-0.5 border-2 border-current border-t-transparent rounded-full animate-spin op50 w-4 h-4"
|
|
156
156
|
};
|
|
157
|
-
const _hoisted_3 = { class: "flex-1 min-w-0" };
|
|
158
|
-
const _hoisted_4 = {
|
|
157
|
+
const _hoisted_3 = { class: "flex-1 min-w-0 space-y-0.5" };
|
|
158
|
+
const _hoisted_4 = { class: "flex items-center gap-2" };
|
|
159
|
+
const _hoisted_5 = ["title"];
|
|
160
|
+
const _hoisted_6 = {
|
|
159
161
|
key: 0,
|
|
160
|
-
class: "text-xs op80
|
|
162
|
+
class: "text-xs op80 whitespace-pre-wrap"
|
|
161
163
|
};
|
|
162
|
-
const
|
|
164
|
+
const _hoisted_7 = {
|
|
163
165
|
key: 1,
|
|
164
|
-
class: "flex items-center gap-2
|
|
166
|
+
class: "flex flex-wrap items-center gap-x-2 gap-y-0.5"
|
|
165
167
|
};
|
|
166
|
-
const _hoisted_6 = ["title"];
|
|
167
168
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
168
169
|
__name: "LogItem",
|
|
169
170
|
props: {
|
|
@@ -181,9 +182,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
181
182
|
class: normalizeClass(["flex-none mt-0.5 w-4 h-4", [unref(levels)[__props.entry.level]?.icon, unref(levels)[__props.entry.level]?.color]])
|
|
182
183
|
}, null, 2)),
|
|
183
184
|
createElementVNode("div", _hoisted_3, [
|
|
184
|
-
createElementVNode("div",
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
createElementVNode("div", _hoisted_4, [
|
|
186
|
+
createElementVNode("div", { class: normalizeClass(["flex-1 min-w-0 truncate text-sm font-medium", [__props.entry.status === "loading" ? "op60" : ""]]) }, toDisplayString(__props.entry.message), 3),
|
|
187
|
+
!__props.compact ? (openBlock(), createElementBlock("span", {
|
|
188
|
+
key: 0,
|
|
189
|
+
class: "text-xs op40 flex-none",
|
|
190
|
+
title: new Date(__props.entry.timestamp).toLocaleString()
|
|
191
|
+
}, toDisplayString(unref(timeAgo)), 9, _hoisted_5)) : createCommentVNode("v-if", true),
|
|
192
|
+
renderSlot(_ctx.$slots, "actions")
|
|
193
|
+
]),
|
|
194
|
+
__props.entry.description ? (openBlock(), createElementBlock("div", _hoisted_6, toDisplayString(__props.entry.description), 1)) : createCommentVNode("v-if", true),
|
|
195
|
+
!__props.compact ? (openBlock(), createElementBlock("div", _hoisted_7, [__props.entry.category ? (openBlock(), createBlock(_sfc_main$1, {
|
|
187
196
|
key: 0,
|
|
188
197
|
label: __props.entry.category
|
|
189
198
|
}, null, 8, ["label"])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.entry.labels, (label) => {
|
|
@@ -192,13 +201,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
192
201
|
label
|
|
193
202
|
}, null, 8, ["label"]);
|
|
194
203
|
}), 128))])) : createCommentVNode("v-if", true)
|
|
195
|
-
])
|
|
196
|
-
!__props.compact ? (openBlock(), createElementBlock("span", {
|
|
197
|
-
key: 2,
|
|
198
|
-
class: "text-xs op40 flex-none",
|
|
199
|
-
title: new Date(__props.entry.timestamp).toLocaleString()
|
|
200
|
-
}, toDisplayString(unref(timeAgo)), 9, _hoisted_6)) : createCommentVNode("v-if", true),
|
|
201
|
-
renderSlot(_ctx.$slots, "actions")
|
|
204
|
+
])
|
|
202
205
|
]);
|
|
203
206
|
};
|
|
204
207
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as levels, i as getHashColorFromString, n as _sfc_main$3, o as markLogsAsRead, r as formEntries, s as useLogs, t as _sfc_main$2 } from "./LogItem-
|
|
1
|
+
import { s as useTimeAgo } from "./dist-CCdqIez-.js";
|
|
2
|
+
import { a as levels, i as getHashColorFromString, n as _sfc_main$3, o as markLogsAsRead, r as formEntries, s as useLogs, t as _sfc_main$2 } from "./LogItem-Ca0SsU39.js";
|
|
3
3
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onMounted, openBlock, ref, renderList, toDisplayString, unref, vModelText, withCtx, withDirectives, withModifiers } from "vue";
|
|
4
4
|
//#region src/client/webcomponents/components/display/FilterToggles.vue
|
|
5
5
|
const _hoisted_1$1 = { class: "text-xs op40" };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as _sfc_main$2 } from "./DockIcon-
|
|
3
|
-
import "./iconify-JodklND-.js";
|
|
1
|
+
import { d as watchImmediate, i as useEventListener } from "./dist-CCdqIez-.js";
|
|
2
|
+
import { t as _sfc_main$2 } from "./DockIcon-7v-JouW5.js";
|
|
4
3
|
import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, markRaw, nextTick, normalizeClass, onMounted, onUnmounted, openBlock, reactive, ref, renderList, shallowRef, toDisplayString, unref, watch } from "vue";
|
|
5
4
|
//#region src/client/webcomponents/state/terminals.ts
|
|
6
5
|
let _terminalsMap;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { humanId } from "@vitejs/devtools-kit/utils/human-id";
|
|
2
|
+
//#region src/node/auth-state.ts
|
|
3
|
+
let pendingAuth = null;
|
|
4
|
+
let tempAuthToken = generateTempId();
|
|
5
|
+
function generateTempId() {
|
|
6
|
+
return humanId({
|
|
7
|
+
separator: "-",
|
|
8
|
+
capitalize: false
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function getTempAuthToken() {
|
|
12
|
+
return tempAuthToken;
|
|
13
|
+
}
|
|
14
|
+
function refreshTempAuthToken() {
|
|
15
|
+
tempAuthToken = generateTempId();
|
|
16
|
+
return tempAuthToken;
|
|
17
|
+
}
|
|
18
|
+
function setPendingAuth(request) {
|
|
19
|
+
pendingAuth = request;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Abort and clean up any existing pending auth request.
|
|
23
|
+
*/
|
|
24
|
+
function abortPendingAuth() {
|
|
25
|
+
if (pendingAuth) {
|
|
26
|
+
pendingAuth.abortController.abort();
|
|
27
|
+
clearTimeout(pendingAuth.timeout);
|
|
28
|
+
pendingAuth = null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Consume the temp auth ID: verify it matches, trust the pending client, and clean up.
|
|
33
|
+
* Returns the client's authToken if successful, null otherwise.
|
|
34
|
+
*/
|
|
35
|
+
function consumeTempAuthToken(id, storage) {
|
|
36
|
+
if (id !== tempAuthToken || !pendingAuth) return null;
|
|
37
|
+
const { clientAuthToken, session, ua, origin, resolve } = pendingAuth;
|
|
38
|
+
storage.mutate((state) => {
|
|
39
|
+
state.trusted[clientAuthToken] = {
|
|
40
|
+
authToken: clientAuthToken,
|
|
41
|
+
ua,
|
|
42
|
+
origin,
|
|
43
|
+
timestamp: Date.now()
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
session.meta.clientAuthToken = clientAuthToken;
|
|
47
|
+
session.meta.isTrusted = true;
|
|
48
|
+
resolve({ isTrusted: true });
|
|
49
|
+
abortPendingAuth();
|
|
50
|
+
refreshTempAuthToken();
|
|
51
|
+
return clientAuthToken;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { setPendingAuth as a, refreshTempAuthToken as i, consumeTempAuthToken as n, getTempAuthToken as r, abortPendingAuth as t };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { n as ansis_default } from "./constants-DfEeYo9W.js";
|
|
2
|
+
import { dirClientStandalone } from "./dirs.js";
|
|
3
|
+
import { DEVTOOLS_CONNECTION_META_FILENAME, DEVTOOLS_DIRNAME, DEVTOOLS_DOCK_IMPORTS_FILENAME, DEVTOOLS_MOUNT_PATH, DEVTOOLS_RPC_DUMP_DIRNAME, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME } from "@vitejs/devtools-kit/constants";
|
|
4
|
+
import { dirname, join, relative, resolve } from "pathe";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import fs$1 from "node:fs/promises";
|
|
7
|
+
//#region src/node/build-static.ts
|
|
8
|
+
async function buildStaticDevTools(options) {
|
|
9
|
+
const { context, outDir } = options;
|
|
10
|
+
if (existsSync(outDir)) await fs$1.rm(outDir, { recursive: true });
|
|
11
|
+
const devToolsRoot = join(outDir, DEVTOOLS_DIRNAME);
|
|
12
|
+
await fs$1.mkdir(devToolsRoot, { recursive: true });
|
|
13
|
+
await fs$1.cp(dirClientStandalone, devToolsRoot, { recursive: true });
|
|
14
|
+
for (const { baseUrl, distDir } of context.views.buildStaticDirs) {
|
|
15
|
+
console.log(ansis_default.cyan`${"⬢"} Copying static files from ${distDir} to ${join(outDir, baseUrl)}`);
|
|
16
|
+
await fs$1.mkdir(join(outDir, baseUrl), { recursive: true });
|
|
17
|
+
await fs$1.cp(distDir, join(outDir, baseUrl), { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
const { renderDockImportsMap } = await import("./server-C54I1zbj.js");
|
|
20
|
+
await fs$1.mkdir(resolve(devToolsRoot, DEVTOOLS_RPC_DUMP_DIRNAME), { recursive: true });
|
|
21
|
+
await fs$1.writeFile(resolve(devToolsRoot, DEVTOOLS_CONNECTION_META_FILENAME), JSON.stringify({ backend: "static" }, null, 2), "utf-8");
|
|
22
|
+
await fs$1.writeFile(resolve(devToolsRoot, DEVTOOLS_DOCK_IMPORTS_FILENAME), renderDockImportsMap(context.docks.values()), "utf-8");
|
|
23
|
+
console.log(ansis_default.cyan`${"⬢"} Writing RPC dump to ${resolve(devToolsRoot, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME)}`);
|
|
24
|
+
const { collectStaticRpcDump } = await import("./static-dump-BqRb_x-O.js");
|
|
25
|
+
const dump = await collectStaticRpcDump(context.rpc.definitions.values(), context);
|
|
26
|
+
for (const [filepath, data] of Object.entries(dump.files)) {
|
|
27
|
+
const fullpath = resolve(devToolsRoot, filepath);
|
|
28
|
+
await fs$1.mkdir(dirname(fullpath), { recursive: true });
|
|
29
|
+
await fs$1.writeFile(fullpath, JSON.stringify(data, null, 2), "utf-8");
|
|
30
|
+
}
|
|
31
|
+
await fs$1.writeFile(resolve(devToolsRoot, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME), JSON.stringify(dump.manifest, null, 2), "utf-8");
|
|
32
|
+
await fs$1.writeFile(resolve(outDir, "index.html"), [
|
|
33
|
+
"<!doctype html>",
|
|
34
|
+
"<html lang=\"en\">",
|
|
35
|
+
"<head>",
|
|
36
|
+
" <meta charset=\"UTF-8\">",
|
|
37
|
+
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
|
|
38
|
+
" <title>Vite DevTools</title>",
|
|
39
|
+
` <meta http-equiv="refresh" content="0; url=${DEVTOOLS_MOUNT_PATH}">`,
|
|
40
|
+
"</head>",
|
|
41
|
+
"<body>",
|
|
42
|
+
` <script>location.replace(${JSON.stringify(DEVTOOLS_MOUNT_PATH)})<\/script>`,
|
|
43
|
+
"</body>",
|
|
44
|
+
"</html>"
|
|
45
|
+
].join("\n"), "utf-8");
|
|
46
|
+
console.log(ansis_default.green`${"⬢"} Built DevTools to ${relative(context.cwd, outDir)}`);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { buildStaticDevTools };
|
package/dist/cli-commands.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { n as ansis_default } from "./constants-DfEeYo9W.js";
|
|
2
2
|
import { n as normalizeHttpServerUrl } from "./utils-HWI9S6d-.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { dirname, join, relative, resolve } from "pathe";
|
|
6
|
-
import { existsSync } from "node:fs";
|
|
7
|
-
import fs$1 from "node:fs/promises";
|
|
3
|
+
import { DEVTOOLS_MOUNT_PATH } from "@vitejs/devtools-kit/constants";
|
|
4
|
+
import { resolve } from "pathe";
|
|
8
5
|
//#region src/node/cli-commands.ts
|
|
9
6
|
async function start(options) {
|
|
10
7
|
const { host } = options;
|
|
@@ -14,8 +11,8 @@ async function start(options) {
|
|
|
14
11
|
port: options.port == null ? void 0 : +options.port,
|
|
15
12
|
portRange: [9999, 15e3]
|
|
16
13
|
});
|
|
17
|
-
const { startStandaloneDevTools } = await import("./standalone-
|
|
18
|
-
const { createDevToolsMiddleware } = await import("./server-
|
|
14
|
+
const { startStandaloneDevTools } = await import("./standalone-w_GYdx1T.js");
|
|
15
|
+
const { createDevToolsMiddleware } = await import("./server-DSh-GQIq.js").then((n) => n.n);
|
|
19
16
|
const devtools = await startStandaloneDevTools({ cwd: options.root });
|
|
20
17
|
const { h3 } = await createDevToolsMiddleware({
|
|
21
18
|
cwd: devtools.config.root,
|
|
@@ -43,49 +40,17 @@ async function start(options) {
|
|
|
43
40
|
}
|
|
44
41
|
async function build(options) {
|
|
45
42
|
console.log(ansis_default.cyan`${"⬢"} Building static Vite DevTools...`);
|
|
46
|
-
const { startStandaloneDevTools } = await import("./standalone-
|
|
43
|
+
const { startStandaloneDevTools } = await import("./standalone-w_GYdx1T.js");
|
|
47
44
|
const devtools = await startStandaloneDevTools({
|
|
48
45
|
cwd: options.root,
|
|
49
46
|
config: options.config
|
|
50
47
|
});
|
|
51
48
|
const outDir = resolve(devtools.config.root, options.outDir);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
console.log(ansis_default.cyan`${"⬢"} Copying static files from ${distDir} to ${join(outDir, baseUrl)}`);
|
|
58
|
-
await fs$1.mkdir(join(outDir, baseUrl), { recursive: true });
|
|
59
|
-
await fs$1.cp(distDir, join(outDir, baseUrl), { recursive: true });
|
|
60
|
-
}
|
|
61
|
-
const { renderDockImportsMap } = await import("./server-Ca6LOTxO.js");
|
|
62
|
-
await fs$1.mkdir(resolve(devToolsRoot, DEVTOOLS_RPC_DUMP_DIRNAME), { recursive: true });
|
|
63
|
-
await fs$1.writeFile(resolve(devToolsRoot, DEVTOOLS_CONNECTION_META_FILENAME), JSON.stringify({ backend: "static" }, null, 2), "utf-8");
|
|
64
|
-
await fs$1.writeFile(resolve(devToolsRoot, DEVTOOLS_DOCK_IMPORTS_FILENAME), renderDockImportsMap(devtools.context.docks.values()), "utf-8");
|
|
65
|
-
console.log(ansis_default.cyan`${"⬢"} Writing RPC dump to ${resolve(devToolsRoot, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME)}`);
|
|
66
|
-
const { collectStaticRpcDump } = await import("./static-dump-Q0iG9hz3.js");
|
|
67
|
-
const dump = await collectStaticRpcDump(devtools.context.rpc.definitions.values(), devtools.context);
|
|
68
|
-
for (const [filepath, data] of Object.entries(dump.files)) {
|
|
69
|
-
const fullpath = resolve(devToolsRoot, filepath);
|
|
70
|
-
await fs$1.mkdir(dirname(fullpath), { recursive: true });
|
|
71
|
-
await fs$1.writeFile(fullpath, JSON.stringify(data, null, 2), "utf-8");
|
|
72
|
-
}
|
|
73
|
-
await fs$1.writeFile(resolve(devToolsRoot, DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME), JSON.stringify(dump.manifest, null, 2), "utf-8");
|
|
74
|
-
await fs$1.writeFile(resolve(outDir, "index.html"), [
|
|
75
|
-
"<!doctype html>",
|
|
76
|
-
"<html lang=\"en\">",
|
|
77
|
-
"<head>",
|
|
78
|
-
" <meta charset=\"UTF-8\">",
|
|
79
|
-
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
|
|
80
|
-
" <title>Vite DevTools</title>",
|
|
81
|
-
` <meta http-equiv="refresh" content="0; url=${DEVTOOLS_MOUNT_PATH}">`,
|
|
82
|
-
"</head>",
|
|
83
|
-
"<body>",
|
|
84
|
-
` <script>location.replace(${JSON.stringify(DEVTOOLS_MOUNT_PATH)})<\/script>`,
|
|
85
|
-
"</body>",
|
|
86
|
-
"</html>"
|
|
87
|
-
].join("\n"), "utf-8");
|
|
88
|
-
console.log(ansis_default.green`${"⬢"} Built to ${relative(devtools.config.root, outDir)}`);
|
|
49
|
+
const { buildStaticDevTools } = await import("./build-static-zB8LrlMJ.js");
|
|
50
|
+
await buildStaticDevTools({
|
|
51
|
+
context: devtools.context,
|
|
52
|
+
outDir
|
|
53
|
+
});
|
|
89
54
|
console.warn(ansis_default.yellow`${"⬢"} Static build is still experimental and not yet complete.`);
|
|
90
55
|
console.warn(ansis_default.yellow`${"⬢"} Generated output may be missing features and can change without notice.`);
|
|
91
56
|
}
|
package/dist/client/inject.js
CHANGED
|
@@ -1,8 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as useLocalStorage } from "../dist-CCdqIez-.js";
|
|
2
|
+
import { C as createDockEntryState, E as BUILTIN_ENTRIES, S as DEFAULT_DOCK_PANEL_STORE, T as useDocksEntries, a as triggerMainFrameDockAction, h as docksGroupByCategories, r as registerMainFrameDockActionHandler, v as collectAllKeybindings, w as sharedStateToRef, x as normalizeKeyEvent } from "../popup-DcuzpgO2.js";
|
|
3
3
|
import { DEFAULT_STATE_USER_SETTINGS, DEVTOOLS_DOCK_IMPORTS_FILENAME, DEVTOOLS_DOCK_IMPORTS_VIRTUAL_ID, DEVTOOLS_MOUNT_PATH } from "@vitejs/devtools-kit/constants";
|
|
4
4
|
import { CLIENT_CONTEXT_KEY, getDevToolsRpcClient } from "@vitejs/devtools-kit/client";
|
|
5
5
|
import { computed, markRaw, reactive, ref, toRefs, watchEffect } from "vue";
|
|
6
|
+
import { evaluateWhen } from "@vitejs/devtools-kit/utils/when";
|
|
7
|
+
//#region src/client/webcomponents/state/commands.ts
|
|
8
|
+
const commandsContextByRpc = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
async function createCommandsContext(clientType, rpc, whenContextProvider) {
|
|
10
|
+
if (commandsContextByRpc.has(rpc)) return commandsContextByRpc.get(rpc);
|
|
11
|
+
const serverCommands = sharedStateToRef(await rpc.sharedState.get("devtoolskit:internal:commands", { initialValue: [] }));
|
|
12
|
+
const clientCommands = reactive(/* @__PURE__ */ new Map());
|
|
13
|
+
const shortcutOverridesState = await rpc.sharedState.get("devtoolskit:internal:command-shortcuts", { initialValue: {} });
|
|
14
|
+
const shortcutOverrides = sharedStateToRef(shortcutOverridesState);
|
|
15
|
+
const paletteOpen = ref(false);
|
|
16
|
+
const getWhenContext = () => {
|
|
17
|
+
if (whenContextProvider) return whenContextProvider();
|
|
18
|
+
return {
|
|
19
|
+
clientType,
|
|
20
|
+
dockOpen: false,
|
|
21
|
+
paletteOpen: paletteOpen.value,
|
|
22
|
+
dockSelectedId: ""
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const commands = computed(() => [...serverCommands.value, ...Array.from(clientCommands.values())]);
|
|
26
|
+
const paletteCommands = computed(() => {
|
|
27
|
+
const ctx = getWhenContext();
|
|
28
|
+
return commands.value.filter((cmd) => {
|
|
29
|
+
if (cmd.showInPalette === false) return false;
|
|
30
|
+
if (cmd.when && !evaluateWhen(cmd.when, ctx)) return false;
|
|
31
|
+
return true;
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
function register(cmd) {
|
|
35
|
+
const cmds = Array.isArray(cmd) ? cmd : [cmd];
|
|
36
|
+
for (const c of cmds) clientCommands.set(c.id, c);
|
|
37
|
+
return () => {
|
|
38
|
+
for (const c of cmds) clientCommands.delete(c.id);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function findCommand(id) {
|
|
42
|
+
const topLevel = commands.value.find((c) => c.id === id);
|
|
43
|
+
if (topLevel) return topLevel;
|
|
44
|
+
for (const cmd of commands.value) if (cmd.children) {
|
|
45
|
+
const child = cmd.children.find((c) => c.id === id);
|
|
46
|
+
if (child) return child;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function execute(id, ...args) {
|
|
50
|
+
const cmd = findCommand(id);
|
|
51
|
+
if (!cmd) throw new Error(`Command "${id}" not found`);
|
|
52
|
+
if (cmd.when) {
|
|
53
|
+
const ctx = getWhenContext();
|
|
54
|
+
if (!evaluateWhen(cmd.when, ctx)) throw new Error(`Command "${id}" is not available in the current context`);
|
|
55
|
+
}
|
|
56
|
+
if (cmd.source === "server") return rpc.call("devtoolskit:internal:commands:execute", id, ...args);
|
|
57
|
+
if (cmd.action) return cmd.action(...args);
|
|
58
|
+
throw new Error(`Command "${id}" has no action`);
|
|
59
|
+
}
|
|
60
|
+
function getKeybindings(id) {
|
|
61
|
+
const overrides = shortcutOverrides.value[id];
|
|
62
|
+
if (overrides !== void 0) return overrides;
|
|
63
|
+
return findCommand(id)?.keybindings ?? [];
|
|
64
|
+
}
|
|
65
|
+
if (typeof window !== "undefined") setupShortcutListener(getWhenContext, commands, getKeybindings, execute);
|
|
66
|
+
const commandsContext = reactive({
|
|
67
|
+
commands,
|
|
68
|
+
paletteCommands,
|
|
69
|
+
register,
|
|
70
|
+
execute,
|
|
71
|
+
getKeybindings,
|
|
72
|
+
shortcutOverrides: markRaw(shortcutOverridesState),
|
|
73
|
+
paletteOpen
|
|
74
|
+
});
|
|
75
|
+
commandsContextByRpc.set(rpc, commandsContext);
|
|
76
|
+
return commandsContext;
|
|
77
|
+
}
|
|
78
|
+
function setupShortcutListener(getWhenContext, commands, getKeybindings, execute) {
|
|
79
|
+
const handler = (e) => {
|
|
80
|
+
const pressed = normalizeKeyEvent(e);
|
|
81
|
+
if (!pressed || pressed === "Mod" || pressed === "Shift" || pressed === "Alt") return;
|
|
82
|
+
const whenCtx = getWhenContext();
|
|
83
|
+
const allBindings = collectAllKeybindings(commands, getKeybindings);
|
|
84
|
+
for (const { id, keybinding } of allBindings) {
|
|
85
|
+
if (keybinding.key !== pressed) continue;
|
|
86
|
+
const cmd = commands.value.find((c) => c.id === id) ?? commands.value.flatMap((c) => c.children ?? []).find((c) => c.id === id);
|
|
87
|
+
if (cmd?.when && !evaluateWhen(cmd.when, whenCtx)) continue;
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
execute(id).catch(console.error);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener("keydown", handler, { capture: true });
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
6
97
|
//#region src/client/webcomponents/state/logs-client.ts
|
|
7
98
|
function createClientLogsClient(rpc) {
|
|
8
99
|
const buffer = [];
|
|
@@ -148,8 +239,96 @@ async function createDocksContext(clientType, rpc, panelStore) {
|
|
|
148
239
|
};
|
|
149
240
|
const settingsStore = markRaw(await getSettingsStore());
|
|
150
241
|
const settings = sharedStateToRef(settingsStore);
|
|
242
|
+
let commandsContext;
|
|
243
|
+
const getWhenContext = () => ({
|
|
244
|
+
clientType,
|
|
245
|
+
dockOpen: panelStore.value.open,
|
|
246
|
+
paletteOpen: commandsContext?.paletteOpen ?? false,
|
|
247
|
+
dockSelectedId: selectedId.value ?? ""
|
|
248
|
+
});
|
|
151
249
|
const groupedEntries = computed(() => {
|
|
152
|
-
return docksGroupByCategories(dockEntries.value, settings.value);
|
|
250
|
+
return docksGroupByCategories(dockEntries.value, settings.value, { whenContext: getWhenContext() });
|
|
251
|
+
});
|
|
252
|
+
commandsContext = await createCommandsContext(clientType, rpc, getWhenContext);
|
|
253
|
+
commandsContext.register([
|
|
254
|
+
{
|
|
255
|
+
id: "devtools:toggle-palette",
|
|
256
|
+
source: "client",
|
|
257
|
+
title: "Toggle Command Palette",
|
|
258
|
+
icon: "ph:magnifying-glass-duotone",
|
|
259
|
+
showInPalette: false,
|
|
260
|
+
keybindings: [{ key: "Mod+K" }],
|
|
261
|
+
action: () => {
|
|
262
|
+
commandsContext.paletteOpen = !commandsContext.paletteOpen;
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
id: "devtools:close-panel",
|
|
267
|
+
source: "client",
|
|
268
|
+
title: "Close Panel",
|
|
269
|
+
icon: "ph:x-circle-duotone",
|
|
270
|
+
when: "dockOpen",
|
|
271
|
+
keybindings: [],
|
|
272
|
+
action: () => {
|
|
273
|
+
panelStore.value.open = false;
|
|
274
|
+
selectedId.value = null;
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
id: "devtools:open-settings",
|
|
279
|
+
source: "client",
|
|
280
|
+
title: "Open Settings",
|
|
281
|
+
icon: "ph:gear-duotone",
|
|
282
|
+
action: () => {
|
|
283
|
+
switchEntry("~settings");
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
id: "devtools:dock-mode",
|
|
288
|
+
source: "client",
|
|
289
|
+
title: "Dock Mode",
|
|
290
|
+
icon: "ph:layout-duotone",
|
|
291
|
+
when: clientType === "embedded" ? "clientType == embedded" : void 0,
|
|
292
|
+
children: [{
|
|
293
|
+
id: "devtools:dock-mode:float",
|
|
294
|
+
source: "client",
|
|
295
|
+
title: "Float Mode",
|
|
296
|
+
icon: "ph:cards-three-duotone",
|
|
297
|
+
action: () => {
|
|
298
|
+
panelStore.value.mode = "float";
|
|
299
|
+
}
|
|
300
|
+
}, {
|
|
301
|
+
id: "devtools:dock-mode:edge",
|
|
302
|
+
source: "client",
|
|
303
|
+
title: "Edge Mode",
|
|
304
|
+
icon: "ph:square-half-bottom-duotone",
|
|
305
|
+
action: () => {
|
|
306
|
+
panelStore.value.mode = "edge";
|
|
307
|
+
}
|
|
308
|
+
}]
|
|
309
|
+
}
|
|
310
|
+
]);
|
|
311
|
+
let cleanupDocksCommand;
|
|
312
|
+
watchEffect(() => {
|
|
313
|
+
cleanupDocksCommand?.();
|
|
314
|
+
const dockChildren = dockEntries.value.filter((entry) => entry.type !== "~builtin").map((entry) => {
|
|
315
|
+
return {
|
|
316
|
+
id: `devtools:docks:${entry.id}`,
|
|
317
|
+
source: "client",
|
|
318
|
+
title: entry.title,
|
|
319
|
+
icon: typeof entry.icon === "string" ? entry.icon : void 0,
|
|
320
|
+
action: () => {
|
|
321
|
+
switchEntry(entry.id);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
if (dockChildren.length > 0) cleanupDocksCommand = commandsContext.register({
|
|
326
|
+
id: "devtools:docks",
|
|
327
|
+
source: "client",
|
|
328
|
+
title: "Docks",
|
|
329
|
+
icon: "ph:layout-duotone",
|
|
330
|
+
children: dockChildren
|
|
331
|
+
});
|
|
153
332
|
});
|
|
154
333
|
docksContext = reactive({
|
|
155
334
|
panel: {
|
|
@@ -169,6 +348,10 @@ async function createDocksContext(clientType, rpc, panelStore) {
|
|
|
169
348
|
switchEntry,
|
|
170
349
|
toggleEntry
|
|
171
350
|
},
|
|
351
|
+
commands: commandsContext,
|
|
352
|
+
when: { get context() {
|
|
353
|
+
return getWhenContext();
|
|
354
|
+
} },
|
|
172
355
|
rpc,
|
|
173
356
|
clientType
|
|
174
357
|
});
|