@vitejs/devtools 0.0.0-alpha.22 → 0.0.0-alpha.23
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-B3uZMhP_.js +1719 -0
- package/dist/ViewBuiltinLogs-FLr_sRZn.js +12 -0
- package/dist/ViewBuiltinTerminals-D-EWWPT5.js +10418 -0
- package/dist/{cli-commands-91HuPBSu.js → cli-commands-pPPvq6oG.js} +4 -3
- package/dist/cli-commands.js +2 -2
- package/dist/cli.js +2 -2
- package/dist/client/inject.js +3 -1
- package/dist/client/standalone/assets/ViewBuiltinLogs-CnVEaSMm.js +1 -0
- package/dist/client/standalone/assets/ViewBuiltinTerminals-x7geWavo.js +36 -0
- package/dist/client/standalone/assets/index-BQSrRIa9.css +1 -0
- package/dist/client/standalone/assets/index-BTGj0xT1.js +2 -0
- package/dist/client/standalone/index.html +3 -3
- package/dist/client/webcomponents.d.ts +1 -1
- package/dist/client/webcomponents.js +263 -7634
- package/dist/dirs.js +1 -1
- package/dist/dist-Ce2tZLIf.js +815 -0
- package/dist/docks-C4bgrO3z.js +71 -0
- package/dist/export-helper-Dw-qygE5.js +9 -0
- package/dist/{index-CLc-E8sF.d.ts → index-BYIZX1ss.d.ts} +6 -3
- package/dist/index.d.ts +8 -6
- package/dist/index.js +1 -1
- package/dist/{plugins-C1AF2q2c.js → plugins-BTYJ2nZg.js} +137 -66
- package/dist/{docks-C4khS_Su.js → vue.runtime.esm-bundler-B98sE5ly.js} +479 -949
- package/package.json +15 -14
- package/dist/chunk-CwIu-FEx.js +0 -29
- package/dist/client/standalone/assets/index-DvusdnNm.js +0 -7
- package/dist/client/standalone/assets/index-bVBlMYV3.css +0 -1
- /package/dist/{dirs-BJIz1OY5.js → dirs-C0s1Ghvy.js} +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { I as shallowRef, N as reactive, T as watch, j as markRaw } from "./vue.runtime.esm-bundler-B98sE5ly.js";
|
|
2
|
+
import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
|
|
3
|
+
|
|
4
|
+
//#region src/client/webcomponents/constants.ts
|
|
5
|
+
const BUILTIN_ENTRY_CLIENT_AUTH_NOTICE = Object.freeze({
|
|
6
|
+
type: "~builtin",
|
|
7
|
+
id: "~client-auth-notice",
|
|
8
|
+
title: "Unauthorized",
|
|
9
|
+
icon: "i-fluent-emoji-flat-warning"
|
|
10
|
+
});
|
|
11
|
+
const BUILTIN_ENTRIES = Object.freeze([BUILTIN_ENTRY_CLIENT_AUTH_NOTICE]);
|
|
12
|
+
const DEFAULT_CATEGORIES_ORDER = {
|
|
13
|
+
default: 0,
|
|
14
|
+
app: 100,
|
|
15
|
+
framework: 200,
|
|
16
|
+
web: 300,
|
|
17
|
+
advanced: 400,
|
|
18
|
+
builtin: 500
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/client/webcomponents/state/docks.ts
|
|
23
|
+
function DEFAULT_DOCK_PANEL_STORE() {
|
|
24
|
+
return {
|
|
25
|
+
width: 80,
|
|
26
|
+
height: 80,
|
|
27
|
+
top: 0,
|
|
28
|
+
left: 10,
|
|
29
|
+
position: "bottom",
|
|
30
|
+
open: false,
|
|
31
|
+
inactiveTimeout: 3e3
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function createDockEntryState(entry, selected) {
|
|
35
|
+
const events = createEventEmitter();
|
|
36
|
+
const state = reactive({
|
|
37
|
+
entryMeta: entry,
|
|
38
|
+
get isActive() {
|
|
39
|
+
return selected.value?.id === entry.id;
|
|
40
|
+
},
|
|
41
|
+
domElements: {},
|
|
42
|
+
events: markRaw(events)
|
|
43
|
+
});
|
|
44
|
+
watch(() => selected.value?.id, (newSelectedId) => {
|
|
45
|
+
if (newSelectedId === entry.id) events.emit("entry:activated");
|
|
46
|
+
else events.emit("entry:deactivated");
|
|
47
|
+
}, { immediate: true });
|
|
48
|
+
watch(() => state.domElements.iframe, (newIframe) => {
|
|
49
|
+
if (newIframe) events.emit("dom:iframe:mounted", newIframe);
|
|
50
|
+
}, { immediate: true });
|
|
51
|
+
watch(() => state.domElements.panel, (newPanel) => {
|
|
52
|
+
if (newPanel) events.emit("dom:panel:mounted", newPanel);
|
|
53
|
+
}, { immediate: true });
|
|
54
|
+
return state;
|
|
55
|
+
}
|
|
56
|
+
function sharedStateToRef(sharedState) {
|
|
57
|
+
const ref = shallowRef(sharedState.value());
|
|
58
|
+
sharedState.on("updated", (newState) => {
|
|
59
|
+
ref.value = newState;
|
|
60
|
+
});
|
|
61
|
+
return ref;
|
|
62
|
+
}
|
|
63
|
+
let _docksEntriesRef;
|
|
64
|
+
async function useDocksEntries(rpc) {
|
|
65
|
+
if (_docksEntriesRef) return _docksEntriesRef;
|
|
66
|
+
_docksEntriesRef = sharedStateToRef(await rpc.sharedState.get("vite:internal:docks", { initialValue: [] }));
|
|
67
|
+
return _docksEntriesRef;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { BUILTIN_ENTRY_CLIENT_AUTH_NOTICE as a, BUILTIN_ENTRIES as i, createDockEntryState as n, DEFAULT_CATEGORIES_ORDER as o, useDocksEntries as r, DEFAULT_DOCK_PANEL_STORE as t };
|
|
@@ -87,9 +87,11 @@ interface DevToolsDockHost {
|
|
|
87
87
|
update: (patch: Partial<T>) => void;
|
|
88
88
|
};
|
|
89
89
|
update: (entry: DevToolsDockUserEntry) => void;
|
|
90
|
-
values: (
|
|
90
|
+
values: (options?: {
|
|
91
|
+
includeBuiltin?: boolean;
|
|
92
|
+
}) => DevToolsDockEntry[];
|
|
91
93
|
}
|
|
92
|
-
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default';
|
|
94
|
+
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default' | 'builtin';
|
|
93
95
|
type DevToolsDockEntryIcon = string | {
|
|
94
96
|
light: string;
|
|
95
97
|
dark: string;
|
|
@@ -165,7 +167,7 @@ interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
|
|
|
165
167
|
}
|
|
166
168
|
interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
|
|
167
169
|
type: '~builtin';
|
|
168
|
-
id: '~terminals' | '~logs' | '~client-auth-notice';
|
|
170
|
+
id: '~terminals' | '~logs' | '~client-auth-notice' | '~settings';
|
|
169
171
|
}
|
|
170
172
|
type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher;
|
|
171
173
|
type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
|
|
@@ -176,6 +178,7 @@ interface DevToolsNodeRpcSessionMeta {
|
|
|
176
178
|
ws?: WebSocket;
|
|
177
179
|
clientAuthId?: string;
|
|
178
180
|
isTrusted?: boolean;
|
|
181
|
+
subscribedStates: Set<string>;
|
|
179
182
|
}
|
|
180
183
|
//#endregion
|
|
181
184
|
//#region ../kit/src/utils/shared-state.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as RpcDefinitionsToFunctions, c as DevToolsTerminalSessionBase, d as DevToolsRpcServerFunctions, f as SharedStatePatch, l as DevToolsTerminalSessionStreamChunkEvent, o as ConnectionMeta, p as DevToolsDockEntry, s as DevToolsNodeContext, u as DevToolsRpcClientFunctions } from "./index-
|
|
1
|
+
import { a as RpcDefinitionsToFunctions, c as DevToolsTerminalSessionBase, d as DevToolsRpcServerFunctions, f as SharedStatePatch, l as DevToolsTerminalSessionStreamChunkEvent, o as ConnectionMeta, p as DevToolsDockEntry, s as DevToolsNodeContext, u as DevToolsRpcClientFunctions } from "./index-BYIZX1ss.js";
|
|
2
2
|
import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
|
|
3
3
|
import * as birpc_x0 from "birpc-x";
|
|
4
4
|
import { RpcFunctionsCollectorBase } from "birpc-x";
|
|
@@ -20,24 +20,26 @@ interface DevToolsAuthReturn {
|
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region src/node/rpc/index.d.ts
|
|
23
|
-
declare const
|
|
23
|
+
declare const builtinRpcDeclarations: readonly [birpc_x0.RpcFunctionDefinition<"vite:core:open-in-editor", "action", [path: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:core:open-in-finder", "action", [path: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:anonymous:auth", "action", [query: DevToolsAuthInput], Promise<DevToolsAuthReturn>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:docks:on-launch", "action", [entryId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server:list", "static", [], Promise<{
|
|
24
24
|
[k: string]: {
|
|
25
25
|
type: any;
|
|
26
26
|
};
|
|
27
|
-
}>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:get", "query", [key: string], Promise<any>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:patch", "query", [key: string, patches: SharedStatePatch[], syncId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:set", "query", [key: string, value: any, syncId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:list", "static", [], Promise<DevToolsTerminalSessionBase[]>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:read", "query", [id: string], Promise<{
|
|
27
|
+
}>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:get", "query", [key: string], Promise<any>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:patch", "query", [key: string, patches: SharedStatePatch[], syncId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:set", "query", [key: string, value: any, syncId: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:rpc:server-state:subscribe", "event", [key: string], Promise<void>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:list", "static", [], Promise<DevToolsTerminalSessionBase[]>, DevToolsNodeContext>, birpc_x0.RpcFunctionDefinition<"vite:internal:terminals:read", "query", [id: string], Promise<{
|
|
28
28
|
buffer: string[];
|
|
29
29
|
ts: number;
|
|
30
30
|
}>, DevToolsNodeContext>];
|
|
31
|
-
type BuiltinServerFunctions = RpcDefinitionsToFunctions<typeof
|
|
31
|
+
type BuiltinServerFunctions = RpcDefinitionsToFunctions<typeof builtinRpcDeclarations>;
|
|
32
32
|
declare module '@vitejs/devtools-kit' {
|
|
33
33
|
interface DevToolsRpcServerFunctions extends BuiltinServerFunctions {}
|
|
34
34
|
interface DevToolsRpcClientFunctions {
|
|
35
|
-
'vite:internal:docks:updated': () => Promise<void>;
|
|
36
35
|
'vite:internal:rpc:client-state:patch': (key: string, patches: SharedStatePatch[], syncId: string) => Promise<void>;
|
|
37
|
-
'vite:internal:rpc:client-state:updated': (key: string, syncId: string) => Promise<void>;
|
|
36
|
+
'vite:internal:rpc:client-state:updated': (key: string, fullState: any, syncId: string) => Promise<void>;
|
|
38
37
|
'vite:internal:terminals:stream-chunk': (data: DevToolsTerminalSessionStreamChunkEvent) => Promise<void>;
|
|
39
38
|
'vite:internal:terminals:updated': () => Promise<void>;
|
|
40
39
|
}
|
|
40
|
+
interface DevToolsRpcSharedStates {
|
|
41
|
+
'vite:internal:docks': DevToolsDockEntry[];
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
//#endregion
|
|
43
45
|
//#region src/node/plugins/index.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as createDevToolsMiddleware, t as DevTools, u as createDevToolsContext } from "./plugins-
|
|
1
|
+
import { n as createDevToolsMiddleware, t as DevTools, u as createDevToolsContext } from "./plugins-BTYJ2nZg.js";
|
|
2
2
|
|
|
3
3
|
export { DevTools, createDevToolsContext, createDevToolsMiddleware };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import Debug from "debug";
|
|
1
|
+
import { n as dirDist, t as dirClientStandalone } from "./dirs-C0s1Ghvy.js";
|
|
2
|
+
import { createDebug } from "obug";
|
|
4
3
|
import { debounce } from "perfect-debounce";
|
|
5
4
|
import { normalizePath, searchForWorkspaceRoot } from "vite";
|
|
6
5
|
import { toDataURL } from "mlly";
|
|
@@ -24,6 +23,34 @@ import { createServer } from "node:net";
|
|
|
24
23
|
import { networkInterfaces } from "node:os";
|
|
25
24
|
import "node:fs/promises";
|
|
26
25
|
|
|
26
|
+
//#region rolldown:runtime
|
|
27
|
+
var __create = Object.create;
|
|
28
|
+
var __defProp = Object.defineProperty;
|
|
29
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
30
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
31
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
32
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
33
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __copyProps = (to, from, except, desc) => {
|
|
35
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
36
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
37
|
+
key = keys[i];
|
|
38
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
39
|
+
__defProp(to, key, {
|
|
40
|
+
get: ((k$2) => from[k$2]).bind(null, key),
|
|
41
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
49
|
+
value: mod,
|
|
50
|
+
enumerable: true
|
|
51
|
+
}) : target, mod));
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
27
54
|
//#region src/node/context-utils.ts
|
|
28
55
|
const ContextUtils = { createSimpleClientScript(fn) {
|
|
29
56
|
return {
|
|
@@ -40,8 +67,36 @@ var DevToolsDockHost = class {
|
|
|
40
67
|
constructor(context) {
|
|
41
68
|
this.context = context;
|
|
42
69
|
}
|
|
43
|
-
values() {
|
|
44
|
-
|
|
70
|
+
values({ includeBuiltin = true } = {}) {
|
|
71
|
+
const context = this.context;
|
|
72
|
+
const builtinDocksEntries = [
|
|
73
|
+
{
|
|
74
|
+
type: "~builtin",
|
|
75
|
+
id: "~terminals",
|
|
76
|
+
title: "Terminals",
|
|
77
|
+
icon: "ph:terminal-duotone",
|
|
78
|
+
category: "builtin",
|
|
79
|
+
get isHidden() {
|
|
80
|
+
return context.terminals.sessions.size === 0;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "~builtin",
|
|
85
|
+
id: "~logs",
|
|
86
|
+
title: "Logs",
|
|
87
|
+
icon: "ph:notification-duotone",
|
|
88
|
+
category: "builtin",
|
|
89
|
+
isHidden: true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: "~builtin",
|
|
93
|
+
id: "~settings",
|
|
94
|
+
title: "Settings",
|
|
95
|
+
category: "builtin",
|
|
96
|
+
icon: "ph:gear-duotone"
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
return [...Array.from(this.views.values()), ...includeBuiltin ? builtinDocksEntries : []];
|
|
45
100
|
}
|
|
46
101
|
register(view, force) {
|
|
47
102
|
if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
|
|
@@ -61,23 +116,41 @@ var DevToolsDockHost = class {
|
|
|
61
116
|
|
|
62
117
|
//#endregion
|
|
63
118
|
//#region src/node/rpc-shared-state.ts
|
|
119
|
+
const debug$1 = createDebug("vite:devtools:rpc:state:changed");
|
|
64
120
|
function createRpcSharedStateServerHost(rpc) {
|
|
65
121
|
const sharedState = /* @__PURE__ */ new Map();
|
|
66
122
|
function registerSharedState(key, state) {
|
|
67
123
|
const offs = [];
|
|
68
|
-
offs.push(state.on("updated", (
|
|
69
|
-
if (patches)
|
|
70
|
-
|
|
71
|
-
args: [
|
|
124
|
+
offs.push(state.on("updated", (fullState, patches, syncId) => {
|
|
125
|
+
if (patches) {
|
|
126
|
+
debug$1("patch", {
|
|
72
127
|
key,
|
|
73
|
-
patches,
|
|
74
128
|
syncId
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
129
|
+
});
|
|
130
|
+
rpc.broadcast({
|
|
131
|
+
method: "vite:internal:rpc:client-state:patch",
|
|
132
|
+
args: [
|
|
133
|
+
key,
|
|
134
|
+
patches,
|
|
135
|
+
syncId
|
|
136
|
+
],
|
|
137
|
+
filter: (client) => client.$meta.subscribedStates.has(key)
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
debug$1("updated", {
|
|
141
|
+
key,
|
|
142
|
+
syncId
|
|
143
|
+
});
|
|
144
|
+
rpc.broadcast({
|
|
145
|
+
method: "vite:internal:rpc:client-state:updated",
|
|
146
|
+
args: [
|
|
147
|
+
key,
|
|
148
|
+
fullState,
|
|
149
|
+
syncId
|
|
150
|
+
],
|
|
151
|
+
filter: (client) => client.$meta.subscribedStates.has(key)
|
|
152
|
+
});
|
|
153
|
+
}
|
|
81
154
|
}));
|
|
82
155
|
return () => {
|
|
83
156
|
for (const off of offs) off();
|
|
@@ -86,8 +159,9 @@ function createRpcSharedStateServerHost(rpc) {
|
|
|
86
159
|
return { get: async (key, options) => {
|
|
87
160
|
if (sharedState.has(key)) return sharedState.get(key);
|
|
88
161
|
if (options?.initialValue === void 0) throw new Error(`Shared state of "${key}" is not found, please provide an initial value for the first time`);
|
|
162
|
+
debug$1("new-state", key);
|
|
89
163
|
const state = createSharedState({
|
|
90
|
-
|
|
164
|
+
initialValue: options.initialValue,
|
|
91
165
|
enablePatches: false
|
|
92
166
|
});
|
|
93
167
|
registerSharedState(key, state);
|
|
@@ -98,6 +172,7 @@ function createRpcSharedStateServerHost(rpc) {
|
|
|
98
172
|
|
|
99
173
|
//#endregion
|
|
100
174
|
//#region src/node/host-functions.ts
|
|
175
|
+
const debugBroadcast = createDebug("vite:devtools:rpc:broadcast");
|
|
101
176
|
var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
|
|
102
177
|
/**
|
|
103
178
|
* @internal
|
|
@@ -111,6 +186,7 @@ var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
|
|
|
111
186
|
sharedState;
|
|
112
187
|
async broadcast(options) {
|
|
113
188
|
if (!this._rpcGroup) throw new Error("RpcFunctionsHost] RpcGroup is not set, it likely to be an internal bug of Vite DevTools");
|
|
189
|
+
debugBroadcast(JSON.stringify(options.method));
|
|
114
190
|
await Promise.all(this._rpcGroup.clients.map((client) => {
|
|
115
191
|
if (options.filter?.(client) === false) return void 0;
|
|
116
192
|
return client.$callRaw({
|
|
@@ -1550,11 +1626,11 @@ const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible,
|
|
|
1550
1626
|
//#endregion
|
|
1551
1627
|
//#region src/node/storage.ts
|
|
1552
1628
|
function createStorage(options) {
|
|
1553
|
-
let
|
|
1554
|
-
if (fs.existsSync(options.filepath))
|
|
1555
|
-
else
|
|
1629
|
+
let initialValue;
|
|
1630
|
+
if (fs.existsSync(options.filepath)) initialValue = JSON.parse(fs.readFileSync(options.filepath, "utf-8"));
|
|
1631
|
+
else initialValue = options.initialValue;
|
|
1556
1632
|
const state = createSharedState({
|
|
1557
|
-
|
|
1633
|
+
initialValue,
|
|
1558
1634
|
enablePatches: false
|
|
1559
1635
|
});
|
|
1560
1636
|
state.on("updated", (newState) => {
|
|
@@ -1627,27 +1703,6 @@ const anonymousAuth = defineRpcFunction({
|
|
|
1627
1703
|
}
|
|
1628
1704
|
});
|
|
1629
1705
|
|
|
1630
|
-
//#endregion
|
|
1631
|
-
//#region src/node/rpc/internal/docks-list.ts
|
|
1632
|
-
const docksList = defineRpcFunction({
|
|
1633
|
-
name: "vite:internal:docks:list",
|
|
1634
|
-
type: "static",
|
|
1635
|
-
setup: (context) => {
|
|
1636
|
-
const builtinDocksEntries = [{
|
|
1637
|
-
type: "~builtin",
|
|
1638
|
-
id: "~terminals",
|
|
1639
|
-
title: "Terminals",
|
|
1640
|
-
icon: "ph:terminal-duotone",
|
|
1641
|
-
get isHidden() {
|
|
1642
|
-
return context.terminals.sessions.size === 0;
|
|
1643
|
-
}
|
|
1644
|
-
}];
|
|
1645
|
-
return { handler() {
|
|
1646
|
-
return [...Array.from(context.docks.values()), ...builtinDocksEntries];
|
|
1647
|
-
} };
|
|
1648
|
-
}
|
|
1649
|
-
});
|
|
1650
|
-
|
|
1651
1706
|
//#endregion
|
|
1652
1707
|
//#region src/node/rpc/internal/docks-on-launch.ts
|
|
1653
1708
|
const docksOnLaunch = defineRpcFunction({
|
|
@@ -1743,6 +1798,25 @@ const sharedStateSet = defineRpcFunction({
|
|
|
1743
1798
|
}
|
|
1744
1799
|
});
|
|
1745
1800
|
|
|
1801
|
+
//#endregion
|
|
1802
|
+
//#region src/node/rpc/internal/state/subscribe.ts
|
|
1803
|
+
const debug = createDebug("vite:devtools:rpc:state:subscribe");
|
|
1804
|
+
const sharedStateSubscribe = defineRpcFunction({
|
|
1805
|
+
name: "vite:internal:rpc:server-state:subscribe",
|
|
1806
|
+
type: "event",
|
|
1807
|
+
setup: (context) => {
|
|
1808
|
+
return { handler: async (key) => {
|
|
1809
|
+
const session = context.rpc.getCurrentRpcSession();
|
|
1810
|
+
if (!session) return;
|
|
1811
|
+
debug("subscribe", {
|
|
1812
|
+
key,
|
|
1813
|
+
session: session.meta.id
|
|
1814
|
+
});
|
|
1815
|
+
session.meta.subscribedStates.add(key);
|
|
1816
|
+
} };
|
|
1817
|
+
}
|
|
1818
|
+
});
|
|
1819
|
+
|
|
1746
1820
|
//#endregion
|
|
1747
1821
|
//#region src/node/rpc/internal/terminals-list.ts
|
|
1748
1822
|
const terminalsList = defineRpcFunction({
|
|
@@ -1769,10 +1843,10 @@ const terminalsRead = defineRpcFunction({
|
|
|
1769
1843
|
type: "query",
|
|
1770
1844
|
setup: (context) => {
|
|
1771
1845
|
return { async handler(id) {
|
|
1772
|
-
const
|
|
1773
|
-
if (!
|
|
1846
|
+
const session = context.terminals.sessions.get(id);
|
|
1847
|
+
if (!session) throw new Error(`Terminal session with id "${id}" not found`);
|
|
1774
1848
|
return {
|
|
1775
|
-
buffer:
|
|
1849
|
+
buffer: session.buffer ?? [],
|
|
1776
1850
|
ts: Date.now()
|
|
1777
1851
|
};
|
|
1778
1852
|
} };
|
|
@@ -1805,27 +1879,27 @@ const openInFinder = defineRpcFunction({
|
|
|
1805
1879
|
|
|
1806
1880
|
//#endregion
|
|
1807
1881
|
//#region src/node/rpc/index.ts
|
|
1808
|
-
const
|
|
1809
|
-
const
|
|
1810
|
-
const
|
|
1811
|
-
docksList,
|
|
1882
|
+
const builtinPublicRpcDeclarations = [openInEditor, openInFinder];
|
|
1883
|
+
const builtinAnonymousRpcDeclarations = [anonymousAuth];
|
|
1884
|
+
const builtinInternalRpcDeclarations = [
|
|
1812
1885
|
docksOnLaunch,
|
|
1813
1886
|
rpcServerList,
|
|
1814
1887
|
sharedStateGet,
|
|
1815
1888
|
sharedStatePatch,
|
|
1816
1889
|
sharedStateSet,
|
|
1890
|
+
sharedStateSubscribe,
|
|
1817
1891
|
terminalsList,
|
|
1818
1892
|
terminalsRead
|
|
1819
1893
|
];
|
|
1820
|
-
const
|
|
1821
|
-
...
|
|
1822
|
-
...
|
|
1823
|
-
...
|
|
1894
|
+
const builtinRpcDeclarations = [
|
|
1895
|
+
...builtinPublicRpcDeclarations,
|
|
1896
|
+
...builtinAnonymousRpcDeclarations,
|
|
1897
|
+
...builtinInternalRpcDeclarations
|
|
1824
1898
|
];
|
|
1825
1899
|
|
|
1826
1900
|
//#endregion
|
|
1827
1901
|
//#region src/node/context.ts
|
|
1828
|
-
const
|
|
1902
|
+
const debugSetup = createDebug("vite:devtools:context:setup");
|
|
1829
1903
|
async function createDevToolsContext(viteConfig, viteServer) {
|
|
1830
1904
|
const cwd = viteConfig.root;
|
|
1831
1905
|
const context = {
|
|
@@ -1848,22 +1922,17 @@ async function createDevToolsContext(viteConfig, viteServer) {
|
|
|
1848
1922
|
context.docks = docksHost;
|
|
1849
1923
|
context.views = viewsHost;
|
|
1850
1924
|
context.terminals = terminalsHost;
|
|
1851
|
-
for (const fn of
|
|
1925
|
+
for (const fn of builtinRpcDeclarations) rpcHost.register(fn);
|
|
1926
|
+
const docksSharedState = await rpcHost.sharedState.get("vite:internal:docks", { initialValue: [] });
|
|
1852
1927
|
docksHost.events.on("dock:entry:updated", debounce(() => {
|
|
1853
|
-
|
|
1854
|
-
method: "vite:internal:docks:updated",
|
|
1855
|
-
args: []
|
|
1856
|
-
});
|
|
1928
|
+
docksSharedState.mutate(() => context.docks.values());
|
|
1857
1929
|
}, 10));
|
|
1858
1930
|
terminalsHost.events.on("terminal:session:updated", debounce(() => {
|
|
1859
1931
|
rpcHost.broadcast({
|
|
1860
1932
|
method: "vite:internal:terminals:updated",
|
|
1861
1933
|
args: []
|
|
1862
1934
|
});
|
|
1863
|
-
|
|
1864
|
-
method: "vite:internal:docks:updated",
|
|
1865
|
-
args: []
|
|
1866
|
-
});
|
|
1935
|
+
docksSharedState.mutate(() => context.docks.values());
|
|
1867
1936
|
}, 10));
|
|
1868
1937
|
terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
|
|
1869
1938
|
rpcHost.broadcast({
|
|
@@ -1875,7 +1944,7 @@ async function createDevToolsContext(viteConfig, viteServer) {
|
|
|
1875
1944
|
for (const plugin of plugins) {
|
|
1876
1945
|
if (!plugin.devtools?.setup) continue;
|
|
1877
1946
|
try {
|
|
1878
|
-
|
|
1947
|
+
debugSetup(`setting up plugin ${JSON.stringify(plugin.name)}`);
|
|
1879
1948
|
await plugin.devtools?.setup?.(context);
|
|
1880
1949
|
} catch (error) {
|
|
1881
1950
|
console.error(`[Vite DevTools] Error setting up plugin ${plugin.name}:`, error);
|
|
@@ -2096,7 +2165,7 @@ function createError(input) {
|
|
|
2096
2165
|
if (input.unhandled !== void 0) err.unhandled = input.unhandled;
|
|
2097
2166
|
return err;
|
|
2098
2167
|
}
|
|
2099
|
-
function sendError(event, error, debug$
|
|
2168
|
+
function sendError(event, error, debug$2) {
|
|
2100
2169
|
if (event.handled) return;
|
|
2101
2170
|
const h3Error = isError(error) ? error : createError(error);
|
|
2102
2171
|
const responseBody = {
|
|
@@ -2105,7 +2174,7 @@ function sendError(event, error, debug$1) {
|
|
|
2105
2174
|
stack: [],
|
|
2106
2175
|
data: h3Error.data
|
|
2107
2176
|
};
|
|
2108
|
-
if (debug$
|
|
2177
|
+
if (debug$2) responseBody.stack = (h3Error.stack || "").split("\n").map((l$1) => l$1.trim());
|
|
2109
2178
|
if (event.handled) return;
|
|
2110
2179
|
setResponseStatus(event, Number.parseInt(h3Error.statusCode), h3Error.statusMessage);
|
|
2111
2180
|
event.node.res.setHeader("content-type", MIMES.json);
|
|
@@ -2804,6 +2873,7 @@ const MARK_NODE = "⬢";
|
|
|
2804
2873
|
|
|
2805
2874
|
//#endregion
|
|
2806
2875
|
//#region src/node/ws.ts
|
|
2876
|
+
const debugInvoked = createDebug("vite:devtools:rpc:invoked");
|
|
2807
2877
|
const ANONYMOUS_SCOPE = "vite:anonymous:";
|
|
2808
2878
|
async function createWsServer(options) {
|
|
2809
2879
|
const rpcHost = options.context.rpc;
|
|
@@ -2855,6 +2925,7 @@ async function createWsServer(options) {
|
|
|
2855
2925
|
};
|
|
2856
2926
|
if (!fn) return void 0;
|
|
2857
2927
|
return async function(...args) {
|
|
2928
|
+
debugInvoked(`${JSON.stringify(name)} from #${rpc.$meta.id}`);
|
|
2858
2929
|
return await asyncStorage.run({
|
|
2859
2930
|
rpc,
|
|
2860
2931
|
meta: rpc.$meta
|