@vitejs/devtools 0.0.0-alpha.2 → 0.0.0-alpha.20
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/cli-commands-BBPbCd8A.js +95 -0
- package/dist/cli-commands.d.ts +18 -0
- package/dist/cli-commands.js +4 -0
- package/dist/cli.js +4 -71
- package/dist/client/inject.js +86 -14
- package/dist/client/standalone/assets/index-CsLZ-29s.css +1 -0
- package/dist/client/standalone/assets/index-g0E0pe2M.js +7 -0
- package/dist/client/standalone/index.html +3 -3
- package/dist/client/webcomponents.d.ts +26 -30
- package/dist/client/webcomponents.js +741 -302
- package/dist/{dirs-B7dOX6eI.js → dirs-C0s1Ghvy.js} +1 -1
- package/dist/dirs.js +1 -1
- package/dist/{core-uTAXYiA1.js → docks-B3cDUs1u.js} +1133 -994
- package/dist/index-C5iw-7QZ.d.ts +401 -0
- package/dist/index.d.ts +26 -5
- package/dist/index.js +1 -55
- package/dist/{server-B_q0HJ88.js → plugins-DfJlAQ2j.js} +501 -193
- package/package.json +26 -16
- package/dist/client/standalone/assets/index-7RajWZLR.css +0 -1
- package/dist/client/standalone/assets/index-BZuCeFpb.js +0 -7
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { dirClientStandalone } from "./dirs-
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
1
|
+
import { n as dirDist, t as dirClientStandalone } from "./dirs-C0s1Ghvy.js";
|
|
3
2
|
import Debug from "debug";
|
|
3
|
+
import { debounce } from "perfect-debounce";
|
|
4
|
+
import { toDataURL } from "mlly";
|
|
5
|
+
import { createEventEmitter } from "@vitejs/devtools-kit/utils/events";
|
|
6
|
+
import { RpcFunctionsCollectorBase } from "birpc-x";
|
|
7
|
+
import process$1 from "node:process";
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
4
9
|
import sirv from "sirv";
|
|
5
|
-
import { defineRpcFunction
|
|
10
|
+
import { defineRpcFunction } from "@vitejs/devtools-kit";
|
|
6
11
|
import { join } from "node:path";
|
|
12
|
+
import { normalizePath } from "vite";
|
|
7
13
|
import { createRpcServer } from "@vitejs/devtools-rpc";
|
|
8
14
|
import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
|
|
9
15
|
import { createServer } from "node:net";
|
|
@@ -17,16 +23,18 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
17
23
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
18
24
|
var __getProtoOf = Object.getPrototypeOf;
|
|
19
25
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
20
|
-
var
|
|
21
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
22
|
-
};
|
|
26
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
23
27
|
var __copyProps = (to, from, except, desc) => {
|
|
24
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
30
|
+
key = keys[i];
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
32
|
+
__defProp(to, key, {
|
|
33
|
+
get: ((k) => from[k]).bind(null, key),
|
|
34
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
return to;
|
|
32
40
|
};
|
|
@@ -35,69 +43,253 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
43
|
enumerable: true
|
|
36
44
|
}) : target, mod));
|
|
37
45
|
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/node/context-utils.ts
|
|
48
|
+
const ContextUtils = { createSimpleClientScript(fn) {
|
|
49
|
+
return {
|
|
50
|
+
importFrom: toDataURL(`const fn = ${fn.toString()}; export default fn`),
|
|
51
|
+
importName: "default"
|
|
52
|
+
};
|
|
53
|
+
} };
|
|
54
|
+
|
|
38
55
|
//#endregion
|
|
39
56
|
//#region src/node/host-docks.ts
|
|
40
57
|
var DevToolsDockHost = class {
|
|
41
58
|
views = /* @__PURE__ */ new Map();
|
|
42
|
-
|
|
59
|
+
events = createEventEmitter();
|
|
60
|
+
constructor(context) {
|
|
61
|
+
this.context = context;
|
|
62
|
+
}
|
|
43
63
|
values() {
|
|
44
64
|
return Array.from(this.views.values());
|
|
45
65
|
}
|
|
46
|
-
register(view) {
|
|
66
|
+
register(view, force) {
|
|
67
|
+
if (this.views.has(view.id) && !force) throw new Error(`Dock with id "${view.id}" is already registered`);
|
|
68
|
+
this.views.set(view.id, view);
|
|
69
|
+
this.events.emit("dock:entry:updated", view);
|
|
70
|
+
return { update: (patch) => {
|
|
71
|
+
if (patch.id && patch.id !== view.id) throw new Error(`Cannot change the id of a dock. Use register() to add new docks.`);
|
|
72
|
+
this.update(Object.assign(this.views.get(view.id), patch));
|
|
73
|
+
} };
|
|
74
|
+
}
|
|
75
|
+
update(view) {
|
|
76
|
+
if (!this.views.has(view.id)) throw new Error(`Dock with id "${view.id}" is not registered. Use register() to add new docks.`);
|
|
47
77
|
this.views.set(view.id, view);
|
|
78
|
+
this.events.emit("dock:entry:updated", view);
|
|
48
79
|
}
|
|
49
80
|
};
|
|
50
81
|
|
|
51
82
|
//#endregion
|
|
52
83
|
//#region src/node/host-functions.ts
|
|
53
|
-
var RpcFunctionsHost = class {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
var RpcFunctionsHost = class extends RpcFunctionsCollectorBase {
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
rpcGroup = void 0;
|
|
89
|
+
constructor(context) {
|
|
90
|
+
super(context);
|
|
91
|
+
}
|
|
92
|
+
boardcast(name, ...args) {
|
|
93
|
+
if (!this.rpcGroup) throw new Error("RpcFunctionsHost.rpcGroup is not set, it likely to be an internal bug of Vite DevTools");
|
|
94
|
+
return this.rpcGroup.broadcast.$callOptional(name, ...args);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/node/host-terminals.ts
|
|
100
|
+
var DevToolsTerminalHost = class {
|
|
101
|
+
sessions = /* @__PURE__ */ new Map();
|
|
102
|
+
events = createEventEmitter();
|
|
103
|
+
_boundStreams = /* @__PURE__ */ new Map();
|
|
104
|
+
constructor(context) {
|
|
105
|
+
this.context = context;
|
|
106
|
+
}
|
|
107
|
+
register(session) {
|
|
108
|
+
if (this.sessions.has(session.id)) throw new Error(`Terminal session with id "${session.id}" already registered`);
|
|
109
|
+
this.sessions.set(session.id, session);
|
|
110
|
+
this.bindStream(session);
|
|
111
|
+
this.events.emit("terminal:session:updated", session);
|
|
112
|
+
return session;
|
|
113
|
+
}
|
|
114
|
+
update(patch) {
|
|
115
|
+
if (!this.sessions.has(patch.id)) throw new Error(`Terminal session with id "${patch.id}" not registered`);
|
|
116
|
+
const session = this.sessions.get(patch.id);
|
|
117
|
+
Object.assign(session, patch);
|
|
118
|
+
this.sessions.set(patch.id, session);
|
|
119
|
+
this.bindStream(session);
|
|
120
|
+
this.events.emit("terminal:session:updated", session);
|
|
121
|
+
}
|
|
122
|
+
remove(session) {
|
|
123
|
+
this.sessions.delete(session.id);
|
|
124
|
+
this.events.emit("terminal:session:updated", session);
|
|
125
|
+
this._boundStreams.delete(session.id);
|
|
126
|
+
}
|
|
127
|
+
bindStream(session) {
|
|
128
|
+
if (this._boundStreams.has(session.id) && this._boundStreams.get(session.id)?.stream === session.stream) return;
|
|
129
|
+
this._boundStreams.get(session.id)?.dispose();
|
|
130
|
+
this._boundStreams.delete(session.id);
|
|
131
|
+
if (!session.stream) return;
|
|
132
|
+
session.buffer ||= [];
|
|
133
|
+
const events = this.events;
|
|
134
|
+
const writer = new WritableStream({ write(chunk) {
|
|
135
|
+
session.buffer.push(chunk);
|
|
136
|
+
events.emit("terminal:session:stream-chunk", {
|
|
137
|
+
id: session.id,
|
|
138
|
+
chunks: [chunk],
|
|
139
|
+
ts: Date.now()
|
|
140
|
+
});
|
|
141
|
+
} });
|
|
142
|
+
session.stream.pipeTo(writer);
|
|
143
|
+
this._boundStreams.set(session.id, {
|
|
144
|
+
dispose: () => {
|
|
145
|
+
writer.close();
|
|
75
146
|
},
|
|
76
|
-
|
|
77
|
-
return Array.from(definitions.keys());
|
|
78
|
-
}
|
|
147
|
+
stream: session.stream
|
|
79
148
|
});
|
|
80
149
|
}
|
|
81
|
-
|
|
82
|
-
this.
|
|
150
|
+
async startChildProcess(executeOptions, terminal) {
|
|
151
|
+
if (this.sessions.has(terminal.id)) throw new Error(`Terminal session with id "${terminal.id}" already registered`);
|
|
152
|
+
const { exec } = await import("tinyexec");
|
|
153
|
+
let controller;
|
|
154
|
+
const stream = new ReadableStream({ start(_controller) {
|
|
155
|
+
controller = _controller;
|
|
156
|
+
} });
|
|
157
|
+
function createChildProcess() {
|
|
158
|
+
const cp$1 = exec(executeOptions.command, executeOptions.args || [], { nodeOptions: {
|
|
159
|
+
env: {
|
|
160
|
+
COLORS: "true",
|
|
161
|
+
FORCE_COLOR: "true",
|
|
162
|
+
...executeOptions.env || {}
|
|
163
|
+
},
|
|
164
|
+
cwd: executeOptions.cwd ?? process$1.cwd(),
|
|
165
|
+
stdio: "pipe"
|
|
166
|
+
} });
|
|
167
|
+
(async () => {
|
|
168
|
+
for await (const chunk of cp$1) controller?.enqueue(chunk);
|
|
169
|
+
})();
|
|
170
|
+
return cp$1;
|
|
171
|
+
}
|
|
172
|
+
let cp = createChildProcess();
|
|
173
|
+
const restart = async () => {
|
|
174
|
+
cp?.kill();
|
|
175
|
+
cp = createChildProcess();
|
|
176
|
+
};
|
|
177
|
+
const terminate = async () => {
|
|
178
|
+
cp?.kill();
|
|
179
|
+
cp = void 0;
|
|
180
|
+
};
|
|
181
|
+
const session = {
|
|
182
|
+
...terminal,
|
|
183
|
+
status: "running",
|
|
184
|
+
stream,
|
|
185
|
+
type: "child-process",
|
|
186
|
+
executeOptions,
|
|
187
|
+
getChildProcess: () => cp?.process,
|
|
188
|
+
terminate,
|
|
189
|
+
restart
|
|
190
|
+
};
|
|
191
|
+
this.register(session);
|
|
192
|
+
return Promise.resolve(session);
|
|
83
193
|
}
|
|
84
194
|
};
|
|
85
195
|
|
|
86
196
|
//#endregion
|
|
87
|
-
//#region src/node/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
197
|
+
//#region src/node/host-views.ts
|
|
198
|
+
var DevToolsViewHost = class {
|
|
199
|
+
/**
|
|
200
|
+
* @internal
|
|
201
|
+
*/
|
|
202
|
+
buildStaticDirs = [];
|
|
203
|
+
constructor(context) {
|
|
204
|
+
this.context = context;
|
|
205
|
+
}
|
|
206
|
+
hostStatic(baseUrl, distDir) {
|
|
207
|
+
if (!existsSync(distDir)) throw new Error(`[Vite DevTools] distDir ${distDir} does not exist`);
|
|
208
|
+
this.buildStaticDirs.push({
|
|
209
|
+
baseUrl,
|
|
210
|
+
distDir
|
|
211
|
+
});
|
|
212
|
+
if (this.context.viteConfig.command === "serve") {
|
|
213
|
+
if (!this.context.viteServer) throw new Error("[Vite DevTools] viteServer is required in dev mode");
|
|
214
|
+
this.context.viteServer.middlewares.use(baseUrl, sirv(distDir, {
|
|
215
|
+
dev: true,
|
|
216
|
+
single: true
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/node/rpc/internal/docks-list.ts
|
|
224
|
+
const docksList = defineRpcFunction({
|
|
225
|
+
name: "vite:internal:docks:list",
|
|
226
|
+
type: "static",
|
|
91
227
|
setup: (context) => {
|
|
92
|
-
|
|
228
|
+
const builtinDocksEntries = [{
|
|
229
|
+
type: "~builtin",
|
|
230
|
+
id: "~terminals",
|
|
231
|
+
title: "Terminals",
|
|
232
|
+
icon: "ph:terminal-duotone",
|
|
233
|
+
get isHidden() {
|
|
234
|
+
return context.terminals.sessions.size === 0;
|
|
235
|
+
}
|
|
236
|
+
}];
|
|
237
|
+
return { handler: () => [...Array.from(context.docks.values()), ...builtinDocksEntries] };
|
|
93
238
|
}
|
|
94
239
|
});
|
|
95
240
|
|
|
96
241
|
//#endregion
|
|
97
|
-
//#region src/node/rpc/
|
|
98
|
-
const
|
|
99
|
-
name: "vite:
|
|
242
|
+
//#region src/node/rpc/internal/docks-on-launch.ts
|
|
243
|
+
const docksOnLaunch = defineRpcFunction({
|
|
244
|
+
name: "vite:internal:docks:on-launch",
|
|
100
245
|
type: "action",
|
|
246
|
+
setup: (context) => {
|
|
247
|
+
const launchMap = /* @__PURE__ */ new Map();
|
|
248
|
+
return { handler: async (entryId) => {
|
|
249
|
+
if (launchMap.has(entryId)) return launchMap.get(entryId);
|
|
250
|
+
const entry = context.docks.values().find((entry$1) => entry$1.id === entryId);
|
|
251
|
+
if (!entry) throw new Error(`Dock entry with id "${entryId}" not found`);
|
|
252
|
+
if (entry.type !== "launcher") throw new Error(`Dock entry with id "${entryId}" is not a launcher`);
|
|
253
|
+
try {
|
|
254
|
+
context.docks.update({
|
|
255
|
+
...entry,
|
|
256
|
+
launcher: {
|
|
257
|
+
...entry.launcher,
|
|
258
|
+
status: "loading"
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
const promise = entry.launcher.onLaunch();
|
|
262
|
+
launchMap.set(entryId, promise);
|
|
263
|
+
const result = await promise;
|
|
264
|
+
const newEntry = context.docks.values().find((entry$1) => entry$1.id === entryId) || entry;
|
|
265
|
+
if (newEntry.type === "launcher") context.docks.update({
|
|
266
|
+
...newEntry,
|
|
267
|
+
launcher: {
|
|
268
|
+
...newEntry.launcher,
|
|
269
|
+
status: "success"
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
return result;
|
|
273
|
+
} catch (error) {
|
|
274
|
+
console.error(`[VITE DEVTOOLS] Error launching dock entry "${entryId}"`, error);
|
|
275
|
+
context.docks.update({
|
|
276
|
+
...entry,
|
|
277
|
+
launcher: {
|
|
278
|
+
...entry.launcher,
|
|
279
|
+
status: "error",
|
|
280
|
+
error: error instanceof Error ? error.message : String(error)
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
} };
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/node/rpc/internal/rpc-server-list.ts
|
|
290
|
+
const rpcServerList = defineRpcFunction({
|
|
291
|
+
name: "vite:internal:rpc:server:list",
|
|
292
|
+
type: "static",
|
|
101
293
|
setup: (context) => {
|
|
102
294
|
return { async handler() {
|
|
103
295
|
return Object.fromEntries(Array.from(context.rpc.definitions.entries()).map(([name, fn]) => [name, { type: fn.type }]));
|
|
@@ -106,70 +298,111 @@ const listRpcFunctions = defineRpcFunction({
|
|
|
106
298
|
});
|
|
107
299
|
|
|
108
300
|
//#endregion
|
|
109
|
-
//#region src/node/rpc/
|
|
301
|
+
//#region src/node/rpc/internal/terminals-list.ts
|
|
302
|
+
const terminalsList = defineRpcFunction({
|
|
303
|
+
name: "vite:internal:terminals:list",
|
|
304
|
+
type: "static",
|
|
305
|
+
setup: (context) => {
|
|
306
|
+
return { async handler() {
|
|
307
|
+
return Array.from(context.terminals.sessions.values()).map((i) => {
|
|
308
|
+
return {
|
|
309
|
+
id: i.id,
|
|
310
|
+
title: i.title,
|
|
311
|
+
description: i.description,
|
|
312
|
+
status: i.status
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
} };
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/node/rpc/internal/terminals-read.ts
|
|
321
|
+
const terminalsRead = defineRpcFunction({
|
|
322
|
+
name: "vite:internal:terminals:read",
|
|
323
|
+
type: "query",
|
|
324
|
+
setup: (context) => {
|
|
325
|
+
return { async handler(id) {
|
|
326
|
+
const seesion = context.terminals.sessions.get(id);
|
|
327
|
+
if (!seesion) throw new Error(`Terminal session with id "${id}" not found`);
|
|
328
|
+
return {
|
|
329
|
+
buffer: seesion.buffer ?? [],
|
|
330
|
+
ts: Date.now()
|
|
331
|
+
};
|
|
332
|
+
} };
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/node/rpc/public/open-in-editor.ts
|
|
110
338
|
const openInEditor = defineRpcFunction({
|
|
111
339
|
name: "vite:core:open-in-editor",
|
|
112
340
|
type: "action",
|
|
113
341
|
setup: () => {
|
|
114
342
|
return { handler: async (path) => {
|
|
115
|
-
await import("launch-editor").then((r$
|
|
343
|
+
await import("launch-editor").then((r$1) => r$1.default(path));
|
|
116
344
|
} };
|
|
117
345
|
}
|
|
118
346
|
});
|
|
119
347
|
|
|
120
348
|
//#endregion
|
|
121
|
-
//#region src/node/rpc/open-in-finder.ts
|
|
349
|
+
//#region src/node/rpc/public/open-in-finder.ts
|
|
122
350
|
const openInFinder = defineRpcFunction({
|
|
123
351
|
name: "vite:core:open-in-finder",
|
|
124
352
|
type: "action",
|
|
125
353
|
setup: () => {
|
|
126
354
|
return { handler: async (path) => {
|
|
127
|
-
await import("open").then((r$
|
|
355
|
+
await import("open").then((r$1) => r$1.default(path));
|
|
128
356
|
} };
|
|
129
357
|
}
|
|
130
358
|
});
|
|
131
359
|
|
|
132
360
|
//#endregion
|
|
133
361
|
//#region src/node/rpc/index.ts
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
362
|
+
const builtinPublicRpcDecalrations = [openInEditor, openInFinder];
|
|
363
|
+
const builtinInternalRpcDecalrations = [
|
|
364
|
+
docksList,
|
|
365
|
+
docksOnLaunch,
|
|
366
|
+
rpcServerList,
|
|
367
|
+
terminalsList,
|
|
368
|
+
terminalsRead
|
|
139
369
|
];
|
|
370
|
+
const builtinRpcDecalrations = [...builtinPublicRpcDecalrations, ...builtinInternalRpcDecalrations];
|
|
140
371
|
|
|
141
372
|
//#endregion
|
|
142
373
|
//#region src/node/context.ts
|
|
143
374
|
const debug = Debug("vite:devtools:context");
|
|
144
375
|
async function createDevToolsContext(viteConfig, viteServer) {
|
|
145
|
-
const cwd = viteConfig.root;
|
|
146
|
-
const rpcHost = new RpcFunctionsHost();
|
|
147
|
-
const docksHost = new DevToolsDockHost();
|
|
148
376
|
const context = {
|
|
149
|
-
cwd,
|
|
377
|
+
cwd: viteConfig.root,
|
|
150
378
|
viteConfig,
|
|
151
379
|
viteServer,
|
|
152
380
|
mode: viteConfig.command === "serve" ? "dev" : "build",
|
|
153
|
-
rpc:
|
|
154
|
-
docks:
|
|
155
|
-
|
|
156
|
-
|
|
381
|
+
rpc: void 0,
|
|
382
|
+
docks: void 0,
|
|
383
|
+
views: void 0,
|
|
384
|
+
utils: ContextUtils,
|
|
385
|
+
terminals: void 0
|
|
157
386
|
};
|
|
158
|
-
rpcHost
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
387
|
+
const rpcHost = new RpcFunctionsHost(context);
|
|
388
|
+
const docksHost = new DevToolsDockHost(context);
|
|
389
|
+
const viewsHost = new DevToolsViewHost(context);
|
|
390
|
+
const terminalsHost = new DevToolsTerminalHost(context);
|
|
391
|
+
context.rpc = rpcHost;
|
|
392
|
+
context.docks = docksHost;
|
|
393
|
+
context.views = viewsHost;
|
|
394
|
+
context.terminals = terminalsHost;
|
|
395
|
+
for (const fn of builtinRpcDecalrations) rpcHost.register(fn);
|
|
396
|
+
docksHost.events.on("dock:entry:updated", debounce(() => {
|
|
397
|
+
rpcHost.boardcast("vite:internal:docks:updated");
|
|
398
|
+
}, 10));
|
|
399
|
+
terminalsHost.events.on("terminal:session:updated", debounce(() => {
|
|
400
|
+
rpcHost.boardcast("vite:internal:terminals:updated");
|
|
401
|
+
rpcHost.boardcast("vite:internal:docks:updated");
|
|
402
|
+
}, 10));
|
|
403
|
+
terminalsHost.events.on("terminal:session:stream-chunk", (data) => {
|
|
404
|
+
rpcHost.boardcast("vite:internal:terminals:stream-chunk", data);
|
|
405
|
+
});
|
|
173
406
|
const plugins = viteConfig.plugins.filter((plugin) => "devtools" in plugin);
|
|
174
407
|
for (const plugin of plugins) {
|
|
175
408
|
if (!plugin.devtools?.setup) continue;
|
|
@@ -184,9 +417,28 @@ async function createDevToolsContext(viteConfig, viteServer) {
|
|
|
184
417
|
return context;
|
|
185
418
|
}
|
|
186
419
|
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/node/plugins/injection.ts
|
|
422
|
+
function DevToolsInjection() {
|
|
423
|
+
return {
|
|
424
|
+
name: "vite:devtools:injection",
|
|
425
|
+
enforce: "post",
|
|
426
|
+
transformIndexHtml() {
|
|
427
|
+
return [{
|
|
428
|
+
tag: "script",
|
|
429
|
+
attrs: {
|
|
430
|
+
src: `/@fs/${process$1.env.VITE_DEVTOOLS_LOCAL_DEV ? normalizePath(join(dirDist, "..", "src/client/inject/index.ts")) : normalizePath(join(dirDist, "client/inject.js"))}`,
|
|
431
|
+
type: "module"
|
|
432
|
+
},
|
|
433
|
+
injectTo: "body"
|
|
434
|
+
}];
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
187
439
|
//#endregion
|
|
188
440
|
//#region ../../node_modules/.pnpm/ufo@1.6.1/node_modules/ufo/dist/index.mjs
|
|
189
|
-
const r
|
|
441
|
+
const r = String.fromCharCode;
|
|
190
442
|
const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
|
|
191
443
|
const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
|
|
192
444
|
const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
|
|
@@ -211,8 +463,8 @@ function withoutTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
211
463
|
path = input.slice(0, fragmentIndex);
|
|
212
464
|
fragment = input.slice(fragmentIndex);
|
|
213
465
|
}
|
|
214
|
-
const [s0, ...s
|
|
215
|
-
return ((s0.endsWith("/") ? s0.slice(0, -1) : s0) || "/") + (s
|
|
466
|
+
const [s0, ...s] = path.split("?");
|
|
467
|
+
return ((s0.endsWith("/") ? s0.slice(0, -1) : s0) || "/") + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
216
468
|
}
|
|
217
469
|
function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
218
470
|
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
|
@@ -225,8 +477,8 @@ function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
225
477
|
fragment = input.slice(fragmentIndex);
|
|
226
478
|
if (!path) return fragment;
|
|
227
479
|
}
|
|
228
|
-
const [s0, ...s
|
|
229
|
-
return s0 + "/" + (s
|
|
480
|
+
const [s0, ...s] = path.split("?");
|
|
481
|
+
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
230
482
|
}
|
|
231
483
|
function isNonEmptyURL(url) {
|
|
232
484
|
return url && url !== "/";
|
|
@@ -303,7 +555,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
|
303
555
|
return object;
|
|
304
556
|
}
|
|
305
557
|
function createDefu(merger) {
|
|
306
|
-
return (...arguments_) => arguments_.reduce((p
|
|
558
|
+
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
307
559
|
}
|
|
308
560
|
const defu = createDefu();
|
|
309
561
|
const defuFn = createDefu((object, key, currentValue) => {
|
|
@@ -385,10 +637,9 @@ function sendError(event, error, debug$1) {
|
|
|
385
637
|
stack: [],
|
|
386
638
|
data: h3Error.data
|
|
387
639
|
};
|
|
388
|
-
if (debug$1) responseBody.stack = (h3Error.stack || "").split("\n").map((l
|
|
640
|
+
if (debug$1) responseBody.stack = (h3Error.stack || "").split("\n").map((l) => l.trim());
|
|
389
641
|
if (event.handled) return;
|
|
390
|
-
|
|
391
|
-
setResponseStatus(event, _code, h3Error.statusMessage);
|
|
642
|
+
setResponseStatus(event, Number.parseInt(h3Error.statusCode), h3Error.statusMessage);
|
|
392
643
|
event.node.res.setHeader("content-type", MIMES.json);
|
|
393
644
|
event.node.res.end(JSON.stringify(responseBody, void 0, 2));
|
|
394
645
|
}
|
|
@@ -412,7 +663,7 @@ function sanitizeStatusCode(statusCode, defaultStatusCode = 200) {
|
|
|
412
663
|
return statusCode;
|
|
413
664
|
}
|
|
414
665
|
function splitCookiesString(cookiesString) {
|
|
415
|
-
if (Array.isArray(cookiesString)) return cookiesString.flatMap((c
|
|
666
|
+
if (Array.isArray(cookiesString)) return cookiesString.flatMap((c) => splitCookiesString(c));
|
|
416
667
|
if (typeof cookiesString !== "string") return [];
|
|
417
668
|
const cookiesStrings = [];
|
|
418
669
|
let pos = 0;
|
|
@@ -480,8 +731,7 @@ function defaultContentType(event, type) {
|
|
|
480
731
|
function sendRedirect(event, location, code = 302) {
|
|
481
732
|
event.node.res.statusCode = sanitizeStatusCode(code, event.node.res.statusCode);
|
|
482
733
|
event.node.res.setHeader("location", location);
|
|
483
|
-
|
|
484
|
-
return send(event, html, MIMES.html);
|
|
734
|
+
return send(event, `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${location.replace(/"/g, "%22")}"></head></html>`, MIMES.html);
|
|
485
735
|
}
|
|
486
736
|
function isStream(data) {
|
|
487
737
|
if (!data || typeof data !== "object") return false;
|
|
@@ -536,7 +786,6 @@ function sendWebResponse(event, response) {
|
|
|
536
786
|
}
|
|
537
787
|
return sendStream(event, response.body);
|
|
538
788
|
}
|
|
539
|
-
const getSessionPromise = Symbol("getSession");
|
|
540
789
|
var H3Event = class {
|
|
541
790
|
"__is_event__" = true;
|
|
542
791
|
node;
|
|
@@ -640,17 +889,17 @@ function defineLazyEventHandler(factory) {
|
|
|
640
889
|
let _resolved;
|
|
641
890
|
const resolveHandler = () => {
|
|
642
891
|
if (_resolved) return Promise.resolve(_resolved);
|
|
643
|
-
if (!_promise) _promise = Promise.resolve(factory()).then((r$
|
|
644
|
-
const handler2 = r$
|
|
892
|
+
if (!_promise) _promise = Promise.resolve(factory()).then((r$1) => {
|
|
893
|
+
const handler2 = r$1.default || r$1;
|
|
645
894
|
if (typeof handler2 !== "function") throw new TypeError("Invalid lazy handler result. It should be a function:", handler2);
|
|
646
|
-
_resolved = { handler: toEventHandler(r$
|
|
895
|
+
_resolved = { handler: toEventHandler(r$1.default || r$1) };
|
|
647
896
|
return _resolved;
|
|
648
897
|
});
|
|
649
898
|
return _promise;
|
|
650
899
|
};
|
|
651
900
|
const handler = eventHandler((event) => {
|
|
652
901
|
if (_resolved) return _resolved.handler(event);
|
|
653
|
-
return resolveHandler().then((r$
|
|
902
|
+
return resolveHandler().then((r$1) => r$1.handler(event));
|
|
654
903
|
});
|
|
655
904
|
handler.__resolve__ = resolveHandler;
|
|
656
905
|
return handler;
|
|
@@ -677,8 +926,8 @@ function createApp(options = {}) {
|
|
|
677
926
|
return app;
|
|
678
927
|
}
|
|
679
928
|
function use(app, arg1, arg2, arg3) {
|
|
680
|
-
if (Array.isArray(arg1)) for (const i
|
|
681
|
-
else if (Array.isArray(arg2)) for (const i
|
|
929
|
+
if (Array.isArray(arg1)) for (const i of arg1) use(app, i, arg2, arg3);
|
|
930
|
+
else if (Array.isArray(arg2)) for (const i of arg2) use(app, arg1, i, arg3);
|
|
682
931
|
else if (typeof arg1 === "string") app.stack.push(normalizeLayer({
|
|
683
932
|
...arg3,
|
|
684
933
|
route: arg1,
|
|
@@ -863,85 +1112,85 @@ function callNodeListener(handler, req, res) {
|
|
|
863
1112
|
|
|
864
1113
|
//#endregion
|
|
865
1114
|
//#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.cjs
|
|
866
|
-
var require_ansis = /* @__PURE__ */
|
|
867
|
-
let e, t, r, { defineProperty: l, setPrototypeOf: n, create: o, keys: s } = Object, i = "", { round: c, max: a
|
|
868
|
-
let t
|
|
1115
|
+
var require_ansis = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1116
|
+
let e, t, r, { defineProperty: l, setPrototypeOf: n, create: o, keys: s } = Object, i = "", { round: c, max: a } = Math, p = (e) => {
|
|
1117
|
+
let t = /([a-f\d]{3,6})/i.exec(e)?.[1], r$1 = t?.length, l = parseInt(6 ^ r$1 ? 3 ^ r$1 ? "0" : t[0] + t[0] + t[1] + t[1] + t[2] + t[2] : t, 16);
|
|
869
1118
|
return [
|
|
870
|
-
l
|
|
871
|
-
l
|
|
872
|
-
255 & l
|
|
1119
|
+
l >> 16 & 255,
|
|
1120
|
+
l >> 8 & 255,
|
|
1121
|
+
255 & l
|
|
873
1122
|
];
|
|
874
|
-
}, u = (e
|
|
875
|
-
let t
|
|
876
|
-
return 8 > e
|
|
1123
|
+
}, u = (e, t, r$1) => e ^ t || t ^ r$1 ? 16 + 36 * c(e / 51) + 6 * c(t / 51) + c(r$1 / 51) : 8 > e ? 16 : e > 248 ? 231 : c(24 * (e - 8) / 247) + 232, d = (e) => {
|
|
1124
|
+
let t, r$1, l, n, o;
|
|
1125
|
+
return 8 > e ? 30 + e : 16 > e ? e - 8 + 90 : (232 > e ? (o = (e -= 16) % 36, t = (e / 36 | 0) / 5, r$1 = (o / 6 | 0) / 5, l = o % 6 / 5) : t = r$1 = l = (10 * (e - 232) + 8) / 255, n = 2 * a(t, r$1, l), n ? 30 + (c(l) << 2 | c(r$1) << 1 | c(t)) + (2 ^ n ? 0 : 60) : 30);
|
|
877
1126
|
}, f = (() => {
|
|
878
|
-
let r$
|
|
1127
|
+
let r$1 = (e) => o.some(((t) => e.test(t))), l = globalThis, n = l.process ?? {}, o = n.argv ?? [], i = n.env ?? {}, c = -1;
|
|
879
1128
|
try {
|
|
880
|
-
e = "," + s(i
|
|
881
|
-
} catch (e
|
|
882
|
-
i
|
|
1129
|
+
e = "," + s(i).join(",");
|
|
1130
|
+
} catch (e) {
|
|
1131
|
+
i = {}, c = 0;
|
|
883
1132
|
}
|
|
884
|
-
let a$
|
|
1133
|
+
let a$1 = "FORCE_COLOR", p = {
|
|
885
1134
|
false: 0,
|
|
886
1135
|
0: 0,
|
|
887
1136
|
1: 1,
|
|
888
1137
|
2: 2,
|
|
889
1138
|
3: 3
|
|
890
|
-
}[i
|
|
891
|
-
return u
|
|
1139
|
+
}[i[a$1]] ?? -1, u = a$1 in i && p || r$1(/^--color=?(true|always)?$/);
|
|
1140
|
+
return u && (c = p), ~c || (c = ((r$2, l$1, n$1) => (t = r$2.TERM, {
|
|
892
1141
|
"24bit": 3,
|
|
893
1142
|
truecolor: 3,
|
|
894
1143
|
ansi256: 2,
|
|
895
1144
|
ansi: 1
|
|
896
|
-
}[r$
|
|
1145
|
+
}[r$2.COLORTERM] || (r$2.CI ? /,GITHUB/.test(e) ? 3 : 1 : l$1 && "dumb" !== t ? n$1 ? 3 : /-256/.test(t) ? 2 : 1 : 0)))(i, !!i.PM2_HOME || i.NEXT_RUNTIME?.includes("edge") || !!n.stdout?.isTTY, "win32" === n.platform)), !p || i.NO_COLOR || r$1(/^--(no-color|color=(false|never))$/) ? 0 : l.window?.chrome || u && !c ? 3 : c;
|
|
897
1146
|
})(), g = {
|
|
898
1147
|
open: i,
|
|
899
1148
|
close: i
|
|
900
|
-
}, h = 39, b = 49, O = {}, m = ({ p: e
|
|
901
|
-
let o
|
|
902
|
-
if (!e$
|
|
903
|
-
if (t
|
|
904
|
-
if ((e$
|
|
1149
|
+
}, h = 39, b = 49, O = {}, m = ({ p: e }, { open: t, close: l }) => {
|
|
1150
|
+
let o = (e$1, ...r$1) => {
|
|
1151
|
+
if (!e$1) {
|
|
1152
|
+
if (t && t === l) return t;
|
|
1153
|
+
if ((e$1 ?? i) === i) return i;
|
|
905
1154
|
}
|
|
906
|
-
let n
|
|
907
|
-
if (s$
|
|
908
|
-
let { open: e$
|
|
909
|
-
if (r$
|
|
910
|
-
s$
|
|
1155
|
+
let n, s$1 = e$1.raw ? String.raw({ raw: e$1 }, ...r$1) : i + e$1, c$1 = o.p, a$1 = c$1.o, p = c$1.c;
|
|
1156
|
+
if (s$1.includes("\x1B")) for (; c$1; c$1 = c$1.p) {
|
|
1157
|
+
let { open: e$2, close: t$1 } = c$1, r$2 = t$1.length, l$1 = i, o$1 = 0;
|
|
1158
|
+
if (r$2) for (; ~(n = s$1.indexOf(t$1, o$1)); o$1 = n + r$2) l$1 += s$1.slice(o$1, n) + e$2;
|
|
1159
|
+
s$1 = l$1 + s$1.slice(o$1);
|
|
911
1160
|
}
|
|
912
|
-
return a$
|
|
913
|
-
}, s
|
|
914
|
-
return e
|
|
915
|
-
open: t
|
|
916
|
-
close: l
|
|
917
|
-
o: s
|
|
918
|
-
c
|
|
919
|
-
p: e
|
|
920
|
-
}, o
|
|
1161
|
+
return a$1 + (s$1.includes("\n") ? s$1.replace(/(\r?\n)/g, p + "$1" + a$1) : s$1) + p;
|
|
1162
|
+
}, s = t, c = l;
|
|
1163
|
+
return e && (s = e.o + t, c = l + e.c), n(o, r), o.p = {
|
|
1164
|
+
open: t,
|
|
1165
|
+
close: l,
|
|
1166
|
+
o: s,
|
|
1167
|
+
c,
|
|
1168
|
+
p: e
|
|
1169
|
+
}, o.open = s, o.close = c, o;
|
|
921
1170
|
};
|
|
922
|
-
const w = new function e
|
|
923
|
-
let s
|
|
924
|
-
Ansis: e
|
|
925
|
-
level: t
|
|
926
|
-
isSupported: () => a$
|
|
927
|
-
strip: (e$
|
|
928
|
-
extend(e$
|
|
929
|
-
for (let t$
|
|
930
|
-
let r$
|
|
931
|
-
"s" === l
|
|
1171
|
+
const w = new function e(t = f) {
|
|
1172
|
+
let s = {
|
|
1173
|
+
Ansis: e,
|
|
1174
|
+
level: t,
|
|
1175
|
+
isSupported: () => a$1,
|
|
1176
|
+
strip: (e$1) => e$1.replace(/[][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, i),
|
|
1177
|
+
extend(e$1) {
|
|
1178
|
+
for (let t$1 in e$1) {
|
|
1179
|
+
let r$1 = e$1[t$1], l = (typeof r$1)[0];
|
|
1180
|
+
"s" === l ? (c(t$1, T(...p(r$1))), c(_(t$1), v(...p(r$1)))) : c(t$1, r$1, "f" === l);
|
|
932
1181
|
}
|
|
933
|
-
return r = o({}, O), n(s
|
|
1182
|
+
return r = o({}, O), n(s, r), s;
|
|
934
1183
|
}
|
|
935
|
-
}, c
|
|
936
|
-
O[e$
|
|
937
|
-
let n
|
|
938
|
-
return l(this, e$
|
|
1184
|
+
}, c = (e$1, t$1, r$1) => {
|
|
1185
|
+
O[e$1] = { get() {
|
|
1186
|
+
let n = r$1 ? (...e$2) => m(this, t$1(...e$2)) : m(this, t$1);
|
|
1187
|
+
return l(this, e$1, { value: n }), n;
|
|
939
1188
|
} };
|
|
940
|
-
}, a$
|
|
941
|
-
open: `[${e$
|
|
942
|
-
close: `[${t$
|
|
943
|
-
} : g, y = (e$
|
|
944
|
-
2 === t
|
|
1189
|
+
}, a$1 = t > 0, w = (e$1, t$1) => a$1 ? {
|
|
1190
|
+
open: `[${e$1}m`,
|
|
1191
|
+
close: `[${t$1}m`
|
|
1192
|
+
} : g, y = (e$1) => (t$1) => e$1(...p(t$1)), R = (e$1, t$1) => (r$1, l, n) => w(`${e$1}8;2;${r$1};${l};${n}`, t$1), $ = (e$1, t$1) => (r$1, l, n) => w(((e$2, t$2, r$2) => d(u(e$2, t$2, r$2)))(r$1, l, n) + e$1, t$1), x = (e$1) => (t$1, r$1, l) => e$1(u(t$1, r$1, l)), T = R(3, h), v = R(4, b), C = (e$1) => w("38;5;" + e$1, h), E = (e$1) => w("48;5;" + e$1, b);
|
|
1193
|
+
2 === t ? (T = x(C), v = x(E)) : 1 === t && (T = $(0, h), v = $(10, b), C = (e$1) => w(d(e$1), h), E = (e$1) => w(d(e$1) + 10, b));
|
|
945
1194
|
let M, I = {
|
|
946
1195
|
fg: C,
|
|
947
1196
|
bg: E,
|
|
@@ -950,21 +1199,21 @@ var require_ansis = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ansis
|
|
|
950
1199
|
hex: y(T),
|
|
951
1200
|
bgHex: y(v),
|
|
952
1201
|
visible: g,
|
|
953
|
-
reset: w
|
|
954
|
-
bold: w
|
|
955
|
-
dim: w
|
|
956
|
-
italic: w
|
|
957
|
-
underline: w
|
|
958
|
-
inverse: w
|
|
959
|
-
hidden: w
|
|
960
|
-
strikethrough: w
|
|
961
|
-
}, _ = (e$
|
|
962
|
-
return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e$
|
|
963
|
-
M = _(e$
|
|
964
|
-
})), s
|
|
1202
|
+
reset: w(0, 0),
|
|
1203
|
+
bold: w(1, 22),
|
|
1204
|
+
dim: w(2, 22),
|
|
1205
|
+
italic: w(3, 23),
|
|
1206
|
+
underline: w(4, 24),
|
|
1207
|
+
inverse: w(7, 27),
|
|
1208
|
+
hidden: w(8, 28),
|
|
1209
|
+
strikethrough: w(9, 29)
|
|
1210
|
+
}, _ = (e$1) => "bg" + e$1[0].toUpperCase() + e$1.slice(1), k = "Bright";
|
|
1211
|
+
return "black,red,green,yellow,blue,magenta,cyan,white,gray".split(",").map(((e$1, t$1) => {
|
|
1212
|
+
M = _(e$1), 8 > t$1 ? (I[e$1 + k] = w(90 + t$1, h), I[M + k] = w(100 + t$1, b)) : t$1 = 60, I[e$1] = w(30 + t$1, h), I[M] = w(40 + t$1, b);
|
|
1213
|
+
})), s.extend(I);
|
|
965
1214
|
}();
|
|
966
1215
|
module.exports = w, w.default = w;
|
|
967
|
-
})
|
|
1216
|
+
}));
|
|
968
1217
|
|
|
969
1218
|
//#endregion
|
|
970
1219
|
//#region ../../node_modules/.pnpm/ansis@4.2.0/node_modules/ansis/index.mjs
|
|
@@ -1074,9 +1323,9 @@ function _log(verbose, message) {
|
|
|
1074
1323
|
}
|
|
1075
1324
|
function _generateRange(from, to) {
|
|
1076
1325
|
if (to < from) return [];
|
|
1077
|
-
const r$
|
|
1078
|
-
for (let index = from; index <= to; index++) r$
|
|
1079
|
-
return r$
|
|
1326
|
+
const r$1 = [];
|
|
1327
|
+
for (let index = from; index <= to; index++) r$1.push(index);
|
|
1328
|
+
return r$1;
|
|
1080
1329
|
}
|
|
1081
1330
|
function _tryPort(port, host) {
|
|
1082
1331
|
return new Promise((resolve) => {
|
|
@@ -1103,8 +1352,8 @@ function _getLocalHosts(additional) {
|
|
|
1103
1352
|
}
|
|
1104
1353
|
async function _findPort(ports, host) {
|
|
1105
1354
|
for (const port of ports) {
|
|
1106
|
-
const r$
|
|
1107
|
-
if (r$
|
|
1355
|
+
const r$1 = await _tryPort(port, host);
|
|
1356
|
+
if (r$1) return r$1;
|
|
1108
1357
|
}
|
|
1109
1358
|
}
|
|
1110
1359
|
function _fmtOnHost(hostname) {
|
|
@@ -1216,15 +1465,21 @@ async function createWsServer(options) {
|
|
|
1216
1465
|
console.log(ansis_default.red`${MARK_CHECK} Websocket client disconnected`);
|
|
1217
1466
|
}
|
|
1218
1467
|
});
|
|
1219
|
-
const
|
|
1468
|
+
const rpcGroup = createRpcServer(rpcHost.functions, {
|
|
1220
1469
|
preset,
|
|
1221
|
-
rpcOptions: {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1470
|
+
rpcOptions: {
|
|
1471
|
+
onFunctionError(error, name) {
|
|
1472
|
+
console.error(ansis_default.red`⬢ RPC error on executing "${ansis_default.bold(name)}":`);
|
|
1473
|
+
console.error(error);
|
|
1474
|
+
},
|
|
1475
|
+
onGeneralError(error) {
|
|
1476
|
+
console.error(ansis_default.red`⬢ RPC error on executing rpc`);
|
|
1477
|
+
console.error(error);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1226
1480
|
});
|
|
1227
|
-
|
|
1481
|
+
rpcHost.rpcGroup = rpcGroup;
|
|
1482
|
+
const getConnectionMeta = async () => {
|
|
1228
1483
|
return {
|
|
1229
1484
|
backend: "websocket",
|
|
1230
1485
|
websocket: port
|
|
@@ -1232,31 +1487,84 @@ async function createWsServer(options) {
|
|
|
1232
1487
|
};
|
|
1233
1488
|
return {
|
|
1234
1489
|
port,
|
|
1235
|
-
rpc,
|
|
1236
|
-
|
|
1237
|
-
|
|
1490
|
+
rpc: rpcGroup,
|
|
1491
|
+
rpcHost,
|
|
1492
|
+
getConnectionMeta
|
|
1238
1493
|
};
|
|
1239
1494
|
}
|
|
1240
1495
|
|
|
1241
1496
|
//#endregion
|
|
1242
1497
|
//#region src/node/server.ts
|
|
1243
1498
|
async function createDevToolsMiddleware(options) {
|
|
1244
|
-
const
|
|
1245
|
-
const { rpc,
|
|
1246
|
-
|
|
1499
|
+
const h3 = createApp();
|
|
1500
|
+
const { rpc, getConnectionMeta } = await createWsServer(options);
|
|
1501
|
+
h3.use("/.vdt-connection.json", eventHandler(async (event) => {
|
|
1247
1502
|
event.node.res.setHeader("Content-Type", "application/json");
|
|
1248
|
-
return event.node.res.end(JSON.stringify(await
|
|
1503
|
+
return event.node.res.end(JSON.stringify(await getConnectionMeta()));
|
|
1249
1504
|
}));
|
|
1250
|
-
|
|
1505
|
+
h3.use(fromNodeMiddleware(sirv(dirClientStandalone, {
|
|
1251
1506
|
dev: true,
|
|
1252
1507
|
single: true
|
|
1253
1508
|
})));
|
|
1254
1509
|
return {
|
|
1255
|
-
h3
|
|
1256
|
-
|
|
1257
|
-
|
|
1510
|
+
h3,
|
|
1511
|
+
rpc,
|
|
1512
|
+
middleware: toNodeListener(h3),
|
|
1513
|
+
getConnectionMeta
|
|
1258
1514
|
};
|
|
1259
1515
|
}
|
|
1260
1516
|
|
|
1261
1517
|
//#endregion
|
|
1262
|
-
|
|
1518
|
+
//#region src/node/plugins/server.ts
|
|
1519
|
+
/**
|
|
1520
|
+
* Core plugin for enabling Vite DevTools
|
|
1521
|
+
*/
|
|
1522
|
+
function DevToolsServer() {
|
|
1523
|
+
let context;
|
|
1524
|
+
return {
|
|
1525
|
+
name: "vite:devtools:server",
|
|
1526
|
+
enforce: "post",
|
|
1527
|
+
apply: "serve",
|
|
1528
|
+
async configureServer(viteDevServer) {
|
|
1529
|
+
context = await createDevToolsContext(viteDevServer.config, viteDevServer);
|
|
1530
|
+
const { middleware } = await createDevToolsMiddleware({
|
|
1531
|
+
cwd: viteDevServer.config.root,
|
|
1532
|
+
context
|
|
1533
|
+
});
|
|
1534
|
+
viteDevServer.middlewares.use("/.devtools/", middleware);
|
|
1535
|
+
},
|
|
1536
|
+
resolveId(id) {
|
|
1537
|
+
if (id === "/.devtools-imports") return id;
|
|
1538
|
+
},
|
|
1539
|
+
load(id) {
|
|
1540
|
+
if (id === "/.devtools-imports") {
|
|
1541
|
+
if (!context) throw new Error("DevTools context is not initialized");
|
|
1542
|
+
const docks = Array.from(context.docks.values());
|
|
1543
|
+
const map = /* @__PURE__ */ new Map();
|
|
1544
|
+
for (const dock of docks) {
|
|
1545
|
+
const id$1 = `${dock.type}:${dock.id}`;
|
|
1546
|
+
if (dock.type === "action") map.set(id$1, dock.action);
|
|
1547
|
+
else if (dock.type === "custom-render") map.set(id$1, dock.renderer);
|
|
1548
|
+
else if (dock.type === "iframe" && dock.clientScript) map.set(id$1, dock.clientScript);
|
|
1549
|
+
}
|
|
1550
|
+
return [
|
|
1551
|
+
`export const importsMap = {`,
|
|
1552
|
+
...[...map.entries()].filter(([, entry]) => entry != null).map(([id$1, { importFrom, importName }]) => ` [${JSON.stringify(id$1)}]: () => import(${JSON.stringify(importFrom)}).then(r => r[${JSON.stringify(importName)}]),`),
|
|
1553
|
+
"}"
|
|
1554
|
+
].join("\n");
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
//#endregion
|
|
1561
|
+
//#region src/node/plugins/index.ts
|
|
1562
|
+
async function DevTools(options = {}) {
|
|
1563
|
+
const { builtinDevTools = true } = options;
|
|
1564
|
+
const plugins = [DevToolsInjection(), DevToolsServer()];
|
|
1565
|
+
if (builtinDevTools) plugins.push(await import("@vitejs/devtools-vite").then((m) => m.DevToolsViteUI()));
|
|
1566
|
+
return plugins;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
//#endregion
|
|
1570
|
+
export { ansis_default as a, fromNodeMiddleware as c, createDevToolsContext as d, getPort as i, sendRedirect as l, createDevToolsMiddleware as n, createApp as o, MARK_NODE as r, eventHandler as s, DevTools as t, toNodeListener as u };
|