@vitejs/devtools 0.0.0-alpha.9 → 0.1.0

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 (36) hide show
  1. package/dist/DockIcon-Jbdv1CYn.js +1720 -0
  2. package/dist/DockStandalone-Dd6Dcd5B.js +81 -0
  3. package/dist/LogItem-CfTxUV6A.js +204 -0
  4. package/dist/ToastOverlay-BVErqkif.js +1048 -0
  5. package/dist/ViewBuiltinLogs-DQLxnQ1c.js +427 -0
  6. package/dist/ViewBuiltinTerminals-B83FB-cT.js +10407 -0
  7. package/dist/cli-commands-DRp01A04.js +178 -0
  8. package/dist/cli-commands.js +3 -5
  9. package/dist/cli.js +3 -6
  10. package/dist/client/inject.js +170 -18
  11. package/dist/client/standalone/assets/DockStandalone-B8W-HO8N.js +1 -0
  12. package/dist/client/standalone/assets/LogItem-B-ayIBi6.js +1 -0
  13. package/dist/client/standalone/assets/ViewBuiltinLogs-B8M7lPbt.js +1 -0
  14. package/dist/client/standalone/assets/ViewBuiltinTerminals-Dkd5qdlN.js +36 -0
  15. package/dist/client/standalone/assets/dist-ZC9UAo6H.js +1 -0
  16. package/dist/client/standalone/assets/index-6F2y1lxr.css +1 -0
  17. package/dist/client/standalone/assets/index-odNIfapG.js +4 -0
  18. package/dist/client/standalone/index.html +5 -3
  19. package/dist/client/webcomponents.d.ts +21657 -31
  20. package/dist/client/webcomponents.js +305 -455
  21. package/dist/config.d.ts +25 -0
  22. package/dist/config.js +14 -0
  23. package/dist/dirs.js +7 -3
  24. package/dist/{dist-2aLfy0Lc.js → dist-3NIYLDlS.js} +2261 -936
  25. package/dist/index.d.ts +256 -13
  26. package/dist/index.js +2 -4
  27. package/dist/plugins-6tW2SoNv.js +2115 -0
  28. package/dist/popup-EDv_a9nQ.js +358 -0
  29. package/dist/utils--qjmgani.js +6 -0
  30. package/package.json +50 -21
  31. package/dist/cli-commands-CWESTkWI.js +0 -97
  32. package/dist/client/standalone/assets/index-CXKamp9k.js +0 -7
  33. package/dist/client/standalone/assets/index-DULlvzQC.css +0 -1
  34. package/dist/dirs-DcSK9l9L.js +0 -9
  35. package/dist/index-C-9eMTqf.d.ts +0 -142
  36. package/dist/plugins-5VE4Mfdt.js +0 -1365
@@ -0,0 +1,81 @@
1
+ import { C as createElementBlock, E as createVNode, I as useTemplateRef, K as unref, L as watch, N as openBlock, O as defineComponent, S as createCommentVNode, U as ref, V as markRaw, _ as Fragment, b as createBaseVNode, f as defineCustomElement, x as createBlock, y as computed, z as withCtx } from "./dist-3NIYLDlS.js";
2
+ import { n as filterPopupDockEntry, r as isDockPopupEntryVisible } from "./popup-EDv_a9nQ.js";
3
+ import { a as VitePlus_default, c as _sfc_main$2, d as css_default, i as _sfc_main$1, n as _sfc_main$4, r as _sfc_main$3, s as PersistedDomViewsManager, t as _sfc_main$5 } from "./ToastOverlay-BVErqkif.js";
4
+ import "./DockIcon-Jbdv1CYn.js";
5
+ //#region src/client/webcomponents/components/DockStandalone.vue
6
+ const _hoisted_1 = {
7
+ key: 0,
8
+ class: "h-screen w-screen of-hidden"
9
+ };
10
+ const _hoisted_2 = {
11
+ key: 1,
12
+ class: "h-screen w-screen of-hidden grid cols-[max-content_1fr]"
13
+ };
14
+ const _hoisted_3 = { class: "border-r border-base flex flex-col" };
15
+ const _hoisted_4 = { class: "p2 border-b border-base flex" };
16
+ const _hoisted_5 = { class: "transition duration-200 p2" };
17
+ //#endregion
18
+ //#region src/client/webcomponents/components/DockStandalone.ts
19
+ const DockStandalone = defineCustomElement(/* @__PURE__ */ defineComponent({
20
+ __name: "DockStandalone",
21
+ props: { context: {} },
22
+ setup(__props) {
23
+ const context = __props.context;
24
+ const viewsContainer = useTemplateRef("viewsContainer");
25
+ const persistedDoms = markRaw(new PersistedDomViewsManager(viewsContainer));
26
+ const isRpcTrusted = ref(context.rpc.isTrusted);
27
+ context.rpc.events.on("rpc:is-trusted:updated", (isTrusted) => {
28
+ isRpcTrusted.value = isTrusted;
29
+ });
30
+ watch(() => context.docks.entries, () => {
31
+ context.docks.selectedId ||= context.docks.entries[0]?.id ?? null;
32
+ }, { immediate: true });
33
+ const groupedEntries = computed(() => {
34
+ if (isDockPopupEntryVisible("standalone")) return context.docks.groupedEntries;
35
+ return filterPopupDockEntry(context.docks.groupedEntries);
36
+ });
37
+ function switchEntry(id) {
38
+ if (id) context.docks.switchEntry(id);
39
+ }
40
+ return (_ctx, _cache) => {
41
+ return openBlock(), createElementBlock(Fragment, null, [
42
+ !isRpcTrusted.value ? (openBlock(), createElementBlock("div", _hoisted_1, [createVNode(_sfc_main$1, { context: unref(context) }, null, 8, ["context"])])) : (openBlock(), createElementBlock("div", _hoisted_2, [createBaseVNode("div", _hoisted_3, [createBaseVNode("div", _hoisted_4, [createVNode(VitePlus_default, { class: "w-7 h-7 ma" })]), createBaseVNode("div", _hoisted_5, [createVNode(_sfc_main$2, {
43
+ context: unref(context),
44
+ groups: groupedEntries.value,
45
+ "is-vertical": false,
46
+ selected: unref(context).docks.selected,
47
+ onSelect: _cache[0] || (_cache[0] = (e) => switchEntry(e?.id))
48
+ }, {
49
+ separator: withCtx(() => [..._cache[1] || (_cache[1] = [createBaseVNode("div", { class: "border-base border-b w-full my-2" }, null, -1)])]),
50
+ _: 1
51
+ }, 8, [
52
+ "context",
53
+ "groups",
54
+ "selected"
55
+ ])])]), createBaseVNode("div", null, [createBaseVNode("div", {
56
+ id: "vite-devtools-views-container",
57
+ ref_key: "viewsContainer",
58
+ ref: viewsContainer,
59
+ class: "pointer-events-auto"
60
+ }, null, 512), unref(context).docks.selected && viewsContainer.value ? (openBlock(), createBlock(_sfc_main$3, {
61
+ key: unref(context).docks.selected.id,
62
+ entry: unref(context).docks.selected,
63
+ context: unref(context),
64
+ "persisted-doms": unref(persistedDoms)
65
+ }, null, 8, [
66
+ "entry",
67
+ "context",
68
+ "persisted-doms"
69
+ ])) : createCommentVNode("v-if", true)])])),
70
+ createVNode(_sfc_main$4),
71
+ createVNode(_sfc_main$5, { context: unref(context) }, null, 8, ["context"])
72
+ ], 64);
73
+ };
74
+ }
75
+ }), {
76
+ shadowRoot: true,
77
+ styles: [css_default]
78
+ });
79
+ if (!customElements.get("vite-devtools-dock-standalone")) customElements.define("vite-devtools-dock-standalone", DockStandalone);
80
+ //#endregion
81
+ export { DockStandalone };
@@ -0,0 +1,204 @@
1
+ import { C as createElementBlock, F as renderSlot, H as reactive, J as normalizeStyle, K as unref, N as openBlock, O as defineComponent, P as renderList, S as createCommentVNode, Y as toDisplayString, _ as Fragment, b as createBaseVNode, o as useTimeAgo, q as normalizeClass, x as createBlock, y as computed } from "./dist-3NIYLDlS.js";
2
+ //#region src/client/webcomponents/state/toasts.ts
3
+ const toasts = reactive([]);
4
+ const timers = /* @__PURE__ */ new Map();
5
+ function useToasts() {
6
+ return toasts;
7
+ }
8
+ function addToast(entry) {
9
+ const existing = toasts.find((t) => t.id === entry.id);
10
+ if (existing) {
11
+ existing.entry = entry;
12
+ const timer = timers.get(entry.id);
13
+ if (timer) clearTimeout(timer);
14
+ const timeout = entry.autoDismiss ?? 5e3;
15
+ timers.set(entry.id, setTimeout(dismissToast, timeout, entry.id));
16
+ return;
17
+ }
18
+ const item = {
19
+ id: entry.id,
20
+ entry
21
+ };
22
+ toasts.push(item);
23
+ const timeout = entry.autoDismiss ?? 5e3;
24
+ timers.set(entry.id, setTimeout(dismissToast, timeout, entry.id));
25
+ }
26
+ function dismissToast(id) {
27
+ const idx = toasts.findIndex((t) => t.id === id);
28
+ if (idx !== -1) toasts.splice(idx, 1);
29
+ const timer = timers.get(id);
30
+ if (timer) {
31
+ clearTimeout(timer);
32
+ timers.delete(id);
33
+ }
34
+ }
35
+ //#endregion
36
+ //#region src/client/webcomponents/state/logs.ts
37
+ let _logsState;
38
+ function useLogs(context) {
39
+ if (_logsState) return _logsState;
40
+ const state = _logsState = reactive({
41
+ entries: [],
42
+ unreadCount: 0
43
+ });
44
+ const entryMap = /* @__PURE__ */ new Map();
45
+ let isInitialFetch = true;
46
+ let lastVersion;
47
+ async function updateLogs() {
48
+ const result = await context.rpc.call("devtoolskit:internal:logs:list", lastVersion);
49
+ let newCount = 0;
50
+ for (const id of result.removedIds) entryMap.delete(id);
51
+ for (const entry of result.entries) {
52
+ const prev = entryMap.get(entry.id);
53
+ if (!prev) {
54
+ newCount++;
55
+ if (isInitialFetch) {
56
+ if (entry.notify && entry.status === "loading") addToast(entry);
57
+ } else if (entry.notify) addToast(entry);
58
+ } else if (entry.notify && JSON.stringify(entry) !== JSON.stringify(prev)) addToast(entry);
59
+ entryMap.set(entry.id, entry);
60
+ }
61
+ state.entries = Array.from(entryMap.values());
62
+ state.unreadCount += newCount;
63
+ lastVersion = result.version;
64
+ isInitialFetch = false;
65
+ }
66
+ context.rpc.client.register({
67
+ name: "devtoolskit:internal:logs:updated",
68
+ type: "action",
69
+ handler: () => updateLogs()
70
+ });
71
+ updateLogs();
72
+ return state;
73
+ }
74
+ function markLogsAsRead() {
75
+ if (_logsState) _logsState.unreadCount = 0;
76
+ }
77
+ //#endregion
78
+ //#region src/client/webcomponents/components/LogItemConstants.ts
79
+ const levels = {
80
+ info: {
81
+ icon: "i-ph:info-duotone",
82
+ color: "text-blue",
83
+ bg: "bg-blue",
84
+ label: "Info"
85
+ },
86
+ warn: {
87
+ icon: "i-ph:warning-duotone",
88
+ color: "text-amber",
89
+ bg: "bg-amber",
90
+ label: "Warning"
91
+ },
92
+ error: {
93
+ icon: "i-ph:x-circle-duotone",
94
+ color: "text-red",
95
+ bg: "bg-red",
96
+ label: "Error"
97
+ },
98
+ success: {
99
+ icon: "i-ph:check-circle-duotone",
100
+ color: "text-green",
101
+ bg: "bg-green",
102
+ label: "Success"
103
+ },
104
+ debug: {
105
+ icon: "i-ph:bug-duotone",
106
+ color: "text-gray",
107
+ bg: "bg-gray",
108
+ label: "Debug"
109
+ }
110
+ };
111
+ const formEntries = {
112
+ server: {
113
+ icon: "i-ph:hexagon-duotone",
114
+ color: "text-green-800 dark:text-green-200",
115
+ label: "Server"
116
+ },
117
+ browser: {
118
+ icon: "i-ph:globe-simple-duotone",
119
+ color: "text-amber-800 dark:text-amber-200",
120
+ label: "Browser"
121
+ }
122
+ };
123
+ function getHashColorFromString(name, opacity = 1) {
124
+ let hash = 0;
125
+ for (let i = 0; i < name.length; i++) hash = name.charCodeAt(i) + ((hash << 5) - hash);
126
+ return `hsla(${hash % 360}, 55%, 55%, ${opacity})`;
127
+ }
128
+ //#endregion
129
+ //#region src/client/webcomponents/components/HashBadge.vue
130
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
131
+ __name: "HashBadge",
132
+ props: { label: {} },
133
+ setup(__props) {
134
+ const props = __props;
135
+ const style = computed(() => ({
136
+ color: getHashColorFromString(props.label),
137
+ backgroundColor: getHashColorFromString(props.label, .1)
138
+ }));
139
+ return (_ctx, _cache) => {
140
+ return openBlock(), createElementBlock("span", {
141
+ class: "text-xs px-1 rounded",
142
+ style: normalizeStyle(style.value)
143
+ }, toDisplayString(__props.label), 5);
144
+ };
145
+ }
146
+ });
147
+ //#endregion
148
+ //#region src/client/webcomponents/components/LogItem.vue
149
+ const _hoisted_1 = { class: "flex items-start gap-2 relative" };
150
+ const _hoisted_2 = {
151
+ key: 0,
152
+ class: "flex-none mt-0.5 border-2 border-current border-t-transparent rounded-full animate-spin op50 w-4 h-4"
153
+ };
154
+ const _hoisted_3 = { class: "flex-1 min-w-0" };
155
+ const _hoisted_4 = {
156
+ key: 0,
157
+ class: "text-xs op80 mt-0.5 whitespace-pre-wrap"
158
+ };
159
+ const _hoisted_5 = {
160
+ key: 1,
161
+ class: "flex items-center gap-2 mt-0.5"
162
+ };
163
+ const _hoisted_6 = ["title"];
164
+ const _sfc_main = /* @__PURE__ */ defineComponent({
165
+ __name: "LogItem",
166
+ props: {
167
+ entry: {},
168
+ compact: { type: Boolean }
169
+ },
170
+ setup(__props) {
171
+ const props = __props;
172
+ const timeAgo = useTimeAgo(() => props.entry.timestamp);
173
+ return (_ctx, _cache) => {
174
+ return openBlock(), createElementBlock("div", _hoisted_1, [
175
+ createBaseVNode("div", { class: normalizeClass(["w-2px flex-none absolute left-0 top-4px bottom-4px rounded-r", [unref(levels)[__props.entry.level]?.bg || "bg-gray"]]) }, null, 2),
176
+ __props.entry.status === "loading" ? (openBlock(), createElementBlock("div", _hoisted_2)) : (openBlock(), createElementBlock("div", {
177
+ key: 1,
178
+ class: normalizeClass(["flex-none mt-0.5 w-4 h-4", [unref(levels)[__props.entry.level]?.icon, unref(levels)[__props.entry.level]?.color]])
179
+ }, null, 2)),
180
+ createBaseVNode("div", _hoisted_3, [
181
+ createBaseVNode("div", { class: normalizeClass(["truncate text-sm font-medium", [__props.entry.status === "loading" ? "op60" : ""]]) }, toDisplayString(__props.entry.message), 3),
182
+ __props.entry.description ? (openBlock(), createElementBlock("div", _hoisted_4, toDisplayString(__props.entry.description), 1)) : createCommentVNode("v-if", true),
183
+ !__props.compact ? (openBlock(), createElementBlock("div", _hoisted_5, [__props.entry.category ? (openBlock(), createBlock(_sfc_main$1, {
184
+ key: 0,
185
+ label: __props.entry.category
186
+ }, null, 8, ["label"])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.entry.labels, (label) => {
187
+ return openBlock(), createBlock(_sfc_main$1, {
188
+ key: label,
189
+ label
190
+ }, null, 8, ["label"]);
191
+ }), 128))])) : createCommentVNode("v-if", true)
192
+ ]),
193
+ !__props.compact ? (openBlock(), createElementBlock("span", {
194
+ key: 2,
195
+ class: "text-xs op40 flex-none",
196
+ title: new Date(__props.entry.timestamp).toLocaleString()
197
+ }, toDisplayString(unref(timeAgo)), 9, _hoisted_6)) : createCommentVNode("v-if", true),
198
+ renderSlot(_ctx.$slots, "actions")
199
+ ]);
200
+ };
201
+ }
202
+ });
203
+ //#endregion
204
+ export { levels as a, dismissToast as c, getHashColorFromString as i, useToasts as l, _sfc_main$1 as n, markLogsAsRead as o, formEntries as r, useLogs as s, _sfc_main as t };