@vitejs/devtools-vite 0.0.0-alpha.1

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 (60) hide show
  1. package/LICENSE +21 -0
  2. package/dist/dirs-Z7VQHyIZ.js +7 -0
  3. package/dist/dirs.d.ts +4 -0
  4. package/dist/dirs.js +3 -0
  5. package/dist/index.d.ts +118 -0
  6. package/dist/index.js +1463 -0
  7. package/dist/nitro.json +15 -0
  8. package/dist/public/200.html +1 -0
  9. package/dist/public/404.html +1 -0
  10. package/dist/public/_nuxt/B1Vd6rqS.js +1 -0
  11. package/dist/public/_nuxt/B2YLpys2.js +1 -0
  12. package/dist/public/_nuxt/B2fBtupD.js +1 -0
  13. package/dist/public/_nuxt/BBRXmiYk.js +1 -0
  14. package/dist/public/_nuxt/BL9XEsp7.js +1 -0
  15. package/dist/public/_nuxt/BO9hKuA-.js +1 -0
  16. package/dist/public/_nuxt/BQ-NBLhA.js +1 -0
  17. package/dist/public/_nuxt/BcAccMwu.js +1 -0
  18. package/dist/public/_nuxt/BdGMcGSQ.js +1 -0
  19. package/dist/public/_nuxt/BdSZoQls.js +1 -0
  20. package/dist/public/_nuxt/BjbaCuBE.js +1 -0
  21. package/dist/public/_nuxt/Bjr51Ks8.js +1 -0
  22. package/dist/public/_nuxt/BvuqupwD.js +1 -0
  23. package/dist/public/_nuxt/C2X_oPur.js +1 -0
  24. package/dist/public/_nuxt/C5J04JCq.js +1 -0
  25. package/dist/public/_nuxt/CQNn9qP2.js +1 -0
  26. package/dist/public/_nuxt/CS0-317H.js +1 -0
  27. package/dist/public/_nuxt/CciM0jEL.js +1 -0
  28. package/dist/public/_nuxt/CcwEApAr.js +1 -0
  29. package/dist/public/_nuxt/Ci9NHG69.js +1 -0
  30. package/dist/public/_nuxt/D1yk44lc.js +1 -0
  31. package/dist/public/_nuxt/DKn-LAPX.js +11 -0
  32. package/dist/public/_nuxt/DS2MKblJ.js +1 -0
  33. package/dist/public/_nuxt/DSjlpmm-.js +1 -0
  34. package/dist/public/_nuxt/DZeYNBxL.js +1 -0
  35. package/dist/public/_nuxt/D_Sk_I-u.js +1 -0
  36. package/dist/public/_nuxt/Dl8iHwQo.js +2 -0
  37. package/dist/public/_nuxt/DnpfwSMy.js +1 -0
  38. package/dist/public/_nuxt/IrMnfQaU.js +1 -0
  39. package/dist/public/_nuxt/VirtualList.lGV_3v2U.css +1 -0
  40. package/dist/public/_nuxt/Z5tyTJaP.js +1 -0
  41. package/dist/public/_nuxt/_session_.B0BbH92J.css +1 -0
  42. package/dist/public/_nuxt/builds/latest.json +1 -0
  43. package/dist/public/_nuxt/builds/meta/6f75d3aa-4cfc-4ed3-af3a-9078b8defb8f.json +1 -0
  44. package/dist/public/_nuxt/cRQbgMUp.js +1 -0
  45. package/dist/public/_nuxt/diff.worker-BXxwMoGc.js +10 -0
  46. package/dist/public/_nuxt/entry.Dufqy7qJ.css +1 -0
  47. package/dist/public/_nuxt/error-404.yUUAZDjV.css +1 -0
  48. package/dist/public/_nuxt/error-500.BHZzZRS-.css +1 -0
  49. package/dist/public/_nuxt/l47FwQA-.js +1 -0
  50. package/dist/public/_nuxt/pXptjyzi.js +1 -0
  51. package/dist/public/_nuxt/rwBDQBzn.js +1 -0
  52. package/dist/public/_nuxt/tS5wJZMm.js +1 -0
  53. package/dist/public/_nuxt/yfNgynAH.js +33 -0
  54. package/dist/public/_nuxt/z9pSC1xM.js +1 -0
  55. package/dist/public/dot-grid-dark.png +0 -0
  56. package/dist/public/dot-grid-light.png +0 -0
  57. package/dist/public/favicon.svg +15 -0
  58. package/dist/public/index.html +1 -0
  59. package/dist/public/vite-devtools.svg +17 -0
  60. package/package.json +90 -0
package/dist/index.js ADDED
@@ -0,0 +1,1463 @@
1
+ import { clientPublicDir } from "./dirs-Z7VQHyIZ.js";
2
+ import { createRequire } from "node:module";
3
+ import { defineRpcFunction } from "@vitejs/devtools-kit";
4
+ import fs, { existsSync } from "node:fs";
5
+ import process from "node:process";
6
+ import { join } from "pathe";
7
+ import fs$1 from "node:fs/promises";
8
+ import { pipeline } from "node:stream/promises";
9
+ import split2 from "split2";
10
+ import { diffLines } from "diff";
11
+ import { readProjectManifestOnly } from "@pnpm/read-project-manifest";
12
+
13
+ //#region rolldown:runtime
14
+ var __create = Object.create;
15
+ var __defProp = Object.defineProperty;
16
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
17
+ var __getOwnPropNames = Object.getOwnPropertyNames;
18
+ var __getProtoOf = Object.getPrototypeOf;
19
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
20
+ var __commonJS = (cb, mod) => function() {
21
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
25
+ key = keys[i];
26
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
27
+ get: ((k) => from[k]).bind(null, key),
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
34
+ value: mod,
35
+ enumerable: true
36
+ }) : target, mod));
37
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
38
+
39
+ //#endregion
40
+ //#region src/node/rpc/functions/get-payload.ts
41
+ const getPayload = defineRpcFunction({
42
+ name: "vite:get-payload",
43
+ type: "static",
44
+ setup: () => {
45
+ return { handler: async () => ({ timestamp: Date.now() }) };
46
+ }
47
+ });
48
+
49
+ //#endregion
50
+ //#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/Utf8Stream.js
51
+ var require_Utf8Stream = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/Utf8Stream.js": ((exports, module) => {
52
+ const { Transform } = __require("stream");
53
+ const { StringDecoder } = __require("string_decoder");
54
+ var Utf8Stream$1 = class extends Transform {
55
+ constructor(options) {
56
+ super(Object.assign({}, options, { writableObjectMode: false }));
57
+ this._buffer = "";
58
+ }
59
+ _transform(chunk, encoding, callback) {
60
+ if (typeof chunk == "string") this._transform = this._transformString;
61
+ else {
62
+ this._stringDecoder = new StringDecoder();
63
+ this._transform = this._transformBuffer;
64
+ }
65
+ this._transform(chunk, encoding, callback);
66
+ }
67
+ _transformBuffer(chunk, _, callback) {
68
+ this._buffer += this._stringDecoder.write(chunk);
69
+ this._processBuffer(callback);
70
+ }
71
+ _transformString(chunk, _, callback) {
72
+ this._buffer += chunk.toString();
73
+ this._processBuffer(callback);
74
+ }
75
+ _processBuffer(callback) {
76
+ if (this._buffer) {
77
+ this.push(this._buffer, "utf8");
78
+ this._buffer = "";
79
+ }
80
+ callback(null);
81
+ }
82
+ _flushInput() {
83
+ if (this._stringDecoder) this._buffer += this._stringDecoder.end();
84
+ }
85
+ _flush(callback) {
86
+ this._flushInput();
87
+ this._processBuffer(callback);
88
+ }
89
+ };
90
+ module.exports = Utf8Stream$1;
91
+ }) });
92
+
93
+ //#endregion
94
+ //#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Parser.js
95
+ var require_Parser = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Parser.js": ((exports, module) => {
96
+ const Utf8Stream = require_Utf8Stream();
97
+ const patterns = {
98
+ value1: /^(?:[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256})/,
99
+ string: /^(?:[^\x00-\x1f\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\")/,
100
+ key1: /^(?:[\"\}]|\s{1,256})/,
101
+ colon: /^(?:\:|\s{1,256})/,
102
+ comma: /^(?:[\,\]\}]|\s{1,256})/,
103
+ ws: /^\s{1,256}/,
104
+ numberStart: /^\d/,
105
+ numberDigit: /^\d{0,256}/,
106
+ numberFraction: /^[\.eE]/,
107
+ numberExponent: /^[eE]/,
108
+ numberExpSign: /^[-+]/
109
+ };
110
+ const MAX_PATTERN_SIZE = 16;
111
+ let noSticky = true;
112
+ try {
113
+ new RegExp(".", "y");
114
+ noSticky = false;
115
+ } catch (e) {}
116
+ !noSticky && Object.keys(patterns).forEach((key) => {
117
+ let src = patterns[key].source.slice(1);
118
+ if (src.slice(0, 3) === "(?:" && src.slice(-1) === ")") src = src.slice(3, -1);
119
+ patterns[key] = new RegExp(src, "y");
120
+ });
121
+ patterns.numberFracStart = patterns.numberExpStart = patterns.numberStart;
122
+ patterns.numberFracDigit = patterns.numberExpDigit = patterns.numberDigit;
123
+ const values = {
124
+ true: true,
125
+ false: false,
126
+ null: null
127
+ }, expected = {
128
+ object: "objectStop",
129
+ array: "arrayStop",
130
+ "": "done"
131
+ };
132
+ const fromHex = (s) => String.fromCharCode(parseInt(s.slice(2), 16));
133
+ const codes = {
134
+ b: "\b",
135
+ f: "\f",
136
+ n: "\n",
137
+ r: "\r",
138
+ t: " ",
139
+ "\"": "\"",
140
+ "\\": "\\",
141
+ "/": "/"
142
+ };
143
+ var Parser$1 = class Parser$1 extends Utf8Stream {
144
+ static make(options) {
145
+ return new Parser$1(options);
146
+ }
147
+ constructor(options) {
148
+ super(Object.assign({}, options, { readableObjectMode: true }));
149
+ this._packKeys = this._packStrings = this._packNumbers = this._streamKeys = this._streamStrings = this._streamNumbers = true;
150
+ if (options) {
151
+ "packValues" in options && (this._packKeys = this._packStrings = this._packNumbers = options.packValues);
152
+ "packKeys" in options && (this._packKeys = options.packKeys);
153
+ "packStrings" in options && (this._packStrings = options.packStrings);
154
+ "packNumbers" in options && (this._packNumbers = options.packNumbers);
155
+ "streamValues" in options && (this._streamKeys = this._streamStrings = this._streamNumbers = options.streamValues);
156
+ "streamKeys" in options && (this._streamKeys = options.streamKeys);
157
+ "streamStrings" in options && (this._streamStrings = options.streamStrings);
158
+ "streamNumbers" in options && (this._streamNumbers = options.streamNumbers);
159
+ this._jsonStreaming = options.jsonStreaming;
160
+ }
161
+ !this._packKeys && (this._streamKeys = true);
162
+ !this._packStrings && (this._streamStrings = true);
163
+ !this._packNumbers && (this._streamNumbers = true);
164
+ this._done = false;
165
+ this._expect = this._jsonStreaming ? "done" : "value";
166
+ this._stack = [];
167
+ this._parent = "";
168
+ this._open_number = false;
169
+ this._accumulator = "";
170
+ }
171
+ _flush(callback) {
172
+ this._done = true;
173
+ super._flush((error) => {
174
+ if (error) return callback(error);
175
+ if (this._open_number) {
176
+ if (this._streamNumbers) this.push({ name: "endNumber" });
177
+ this._open_number = false;
178
+ if (this._packNumbers) {
179
+ this.push({
180
+ name: "numberValue",
181
+ value: this._accumulator
182
+ });
183
+ this._accumulator = "";
184
+ }
185
+ }
186
+ callback(null);
187
+ });
188
+ }
189
+ _processBuffer(callback) {
190
+ let match, value, index = 0;
191
+ main: for (;;) switch (this._expect) {
192
+ case "value1":
193
+ case "value":
194
+ patterns.value1.lastIndex = index;
195
+ match = patterns.value1.exec(this._buffer);
196
+ if (!match) {
197
+ if (this._done || index + MAX_PATTERN_SIZE < this._buffer.length) {
198
+ if (index < this._buffer.length) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected a value"));
199
+ return callback(/* @__PURE__ */ new Error("Parser has expected a value"));
200
+ }
201
+ break main;
202
+ }
203
+ value = match[0];
204
+ switch (value) {
205
+ case "\"":
206
+ this._streamStrings && this.push({ name: "startString" });
207
+ this._expect = "string";
208
+ break;
209
+ case "{":
210
+ this.push({ name: "startObject" });
211
+ this._stack.push(this._parent);
212
+ this._parent = "object";
213
+ this._expect = "key1";
214
+ break;
215
+ case "[":
216
+ this.push({ name: "startArray" });
217
+ this._stack.push(this._parent);
218
+ this._parent = "array";
219
+ this._expect = "value1";
220
+ break;
221
+ case "]":
222
+ if (this._expect !== "value1") return callback(/* @__PURE__ */ new Error("Parser cannot parse input: unexpected token ']'"));
223
+ if (this._open_number) {
224
+ this._streamNumbers && this.push({ name: "endNumber" });
225
+ this._open_number = false;
226
+ if (this._packNumbers) {
227
+ this.push({
228
+ name: "numberValue",
229
+ value: this._accumulator
230
+ });
231
+ this._accumulator = "";
232
+ }
233
+ }
234
+ this.push({ name: "endArray" });
235
+ this._parent = this._stack.pop();
236
+ this._expect = expected[this._parent];
237
+ break;
238
+ case "-":
239
+ this._open_number = true;
240
+ if (this._streamNumbers) {
241
+ this.push({ name: "startNumber" });
242
+ this.push({
243
+ name: "numberChunk",
244
+ value: "-"
245
+ });
246
+ }
247
+ this._packNumbers && (this._accumulator = "-");
248
+ this._expect = "numberStart";
249
+ break;
250
+ case "0":
251
+ this._open_number = true;
252
+ if (this._streamNumbers) {
253
+ this.push({ name: "startNumber" });
254
+ this.push({
255
+ name: "numberChunk",
256
+ value: "0"
257
+ });
258
+ }
259
+ this._packNumbers && (this._accumulator = "0");
260
+ this._expect = "numberFraction";
261
+ break;
262
+ case "1":
263
+ case "2":
264
+ case "3":
265
+ case "4":
266
+ case "5":
267
+ case "6":
268
+ case "7":
269
+ case "8":
270
+ case "9":
271
+ this._open_number = true;
272
+ if (this._streamNumbers) {
273
+ this.push({ name: "startNumber" });
274
+ this.push({
275
+ name: "numberChunk",
276
+ value
277
+ });
278
+ }
279
+ this._packNumbers && (this._accumulator = value);
280
+ this._expect = "numberDigit";
281
+ break;
282
+ case "true":
283
+ case "false":
284
+ case "null":
285
+ if (this._buffer.length - index === value.length && !this._done) break main;
286
+ this.push({
287
+ name: value + "Value",
288
+ value: values[value]
289
+ });
290
+ this._expect = expected[this._parent];
291
+ break;
292
+ }
293
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
294
+ else index += value.length;
295
+ break;
296
+ case "keyVal":
297
+ case "string":
298
+ patterns.string.lastIndex = index;
299
+ match = patterns.string.exec(this._buffer);
300
+ if (!match) {
301
+ if (index < this._buffer.length && (this._done || this._buffer.length - index >= 6)) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: escaped characters"));
302
+ if (this._done) return callback(/* @__PURE__ */ new Error("Parser has expected a string value"));
303
+ break main;
304
+ }
305
+ value = match[0];
306
+ if (value === "\"") if (this._expect === "keyVal") {
307
+ this._streamKeys && this.push({ name: "endKey" });
308
+ if (this._packKeys) {
309
+ this.push({
310
+ name: "keyValue",
311
+ value: this._accumulator
312
+ });
313
+ this._accumulator = "";
314
+ }
315
+ this._expect = "colon";
316
+ } else {
317
+ this._streamStrings && this.push({ name: "endString" });
318
+ if (this._packStrings) {
319
+ this.push({
320
+ name: "stringValue",
321
+ value: this._accumulator
322
+ });
323
+ this._accumulator = "";
324
+ }
325
+ this._expect = expected[this._parent];
326
+ }
327
+ else if (value.length > 1 && value.charAt(0) === "\\") {
328
+ const t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value);
329
+ if (this._expect === "keyVal" ? this._streamKeys : this._streamStrings) this.push({
330
+ name: "stringChunk",
331
+ value: t
332
+ });
333
+ if (this._expect === "keyVal" ? this._packKeys : this._packStrings) this._accumulator += t;
334
+ } else {
335
+ if (this._expect === "keyVal" ? this._streamKeys : this._streamStrings) this.push({
336
+ name: "stringChunk",
337
+ value
338
+ });
339
+ if (this._expect === "keyVal" ? this._packKeys : this._packStrings) this._accumulator += value;
340
+ }
341
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
342
+ else index += value.length;
343
+ break;
344
+ case "key1":
345
+ case "key":
346
+ patterns.key1.lastIndex = index;
347
+ match = patterns.key1.exec(this._buffer);
348
+ if (!match) {
349
+ if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected an object key"));
350
+ break main;
351
+ }
352
+ value = match[0];
353
+ if (value === "\"") {
354
+ this._streamKeys && this.push({ name: "startKey" });
355
+ this._expect = "keyVal";
356
+ } else if (value === "}") {
357
+ if (this._expect !== "key1") return callback(/* @__PURE__ */ new Error("Parser cannot parse input: unexpected token '}'"));
358
+ this.push({ name: "endObject" });
359
+ this._parent = this._stack.pop();
360
+ this._expect = expected[this._parent];
361
+ }
362
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
363
+ else index += value.length;
364
+ break;
365
+ case "colon":
366
+ patterns.colon.lastIndex = index;
367
+ match = patterns.colon.exec(this._buffer);
368
+ if (!match) {
369
+ if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected ':'"));
370
+ break main;
371
+ }
372
+ value = match[0];
373
+ value === ":" && (this._expect = "value");
374
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
375
+ else index += value.length;
376
+ break;
377
+ case "arrayStop":
378
+ case "objectStop":
379
+ patterns.comma.lastIndex = index;
380
+ match = patterns.comma.exec(this._buffer);
381
+ if (!match) {
382
+ if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected ','"));
383
+ break main;
384
+ }
385
+ if (this._open_number) {
386
+ this._streamNumbers && this.push({ name: "endNumber" });
387
+ this._open_number = false;
388
+ if (this._packNumbers) {
389
+ this.push({
390
+ name: "numberValue",
391
+ value: this._accumulator
392
+ });
393
+ this._accumulator = "";
394
+ }
395
+ }
396
+ value = match[0];
397
+ if (value === ",") this._expect = this._expect === "arrayStop" ? "value" : "key";
398
+ else if (value === "}" || value === "]") {
399
+ if (value === "}" ? this._expect === "arrayStop" : this._expect !== "arrayStop") return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected '" + (this._expect === "arrayStop" ? "]" : "}") + "'"));
400
+ this.push({ name: value === "}" ? "endObject" : "endArray" });
401
+ this._parent = this._stack.pop();
402
+ this._expect = expected[this._parent];
403
+ }
404
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
405
+ else index += value.length;
406
+ break;
407
+ case "numberStart":
408
+ patterns.numberStart.lastIndex = index;
409
+ match = patterns.numberStart.exec(this._buffer);
410
+ if (!match) {
411
+ if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected a starting digit"));
412
+ break main;
413
+ }
414
+ value = match[0];
415
+ this._streamNumbers && this.push({
416
+ name: "numberChunk",
417
+ value
418
+ });
419
+ this._packNumbers && (this._accumulator += value);
420
+ this._expect = value === "0" ? "numberFraction" : "numberDigit";
421
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
422
+ else index += value.length;
423
+ break;
424
+ case "numberDigit":
425
+ patterns.numberDigit.lastIndex = index;
426
+ match = patterns.numberDigit.exec(this._buffer);
427
+ if (!match) {
428
+ if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected a digit"));
429
+ break main;
430
+ }
431
+ value = match[0];
432
+ if (value) {
433
+ this._streamNumbers && this.push({
434
+ name: "numberChunk",
435
+ value
436
+ });
437
+ this._packNumbers && (this._accumulator += value);
438
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
439
+ else index += value.length;
440
+ } else {
441
+ if (index < this._buffer.length) {
442
+ this._expect = "numberFraction";
443
+ break;
444
+ }
445
+ if (this._done) {
446
+ this._expect = expected[this._parent];
447
+ break;
448
+ }
449
+ break main;
450
+ }
451
+ break;
452
+ case "numberFraction":
453
+ patterns.numberFraction.lastIndex = index;
454
+ match = patterns.numberFraction.exec(this._buffer);
455
+ if (!match) {
456
+ if (index < this._buffer.length || this._done) {
457
+ this._expect = expected[this._parent];
458
+ break;
459
+ }
460
+ break main;
461
+ }
462
+ value = match[0];
463
+ this._streamNumbers && this.push({
464
+ name: "numberChunk",
465
+ value
466
+ });
467
+ this._packNumbers && (this._accumulator += value);
468
+ this._expect = value === "." ? "numberFracStart" : "numberExpSign";
469
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
470
+ else index += value.length;
471
+ break;
472
+ case "numberFracStart":
473
+ patterns.numberFracStart.lastIndex = index;
474
+ match = patterns.numberFracStart.exec(this._buffer);
475
+ if (!match) {
476
+ if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected a fractional part of a number"));
477
+ break main;
478
+ }
479
+ value = match[0];
480
+ this._streamNumbers && this.push({
481
+ name: "numberChunk",
482
+ value
483
+ });
484
+ this._packNumbers && (this._accumulator += value);
485
+ this._expect = "numberFracDigit";
486
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
487
+ else index += value.length;
488
+ break;
489
+ case "numberFracDigit":
490
+ patterns.numberFracDigit.lastIndex = index;
491
+ match = patterns.numberFracDigit.exec(this._buffer);
492
+ value = match[0];
493
+ if (value) {
494
+ this._streamNumbers && this.push({
495
+ name: "numberChunk",
496
+ value
497
+ });
498
+ this._packNumbers && (this._accumulator += value);
499
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
500
+ else index += value.length;
501
+ } else {
502
+ if (index < this._buffer.length) {
503
+ this._expect = "numberExponent";
504
+ break;
505
+ }
506
+ if (this._done) {
507
+ this._expect = expected[this._parent];
508
+ break;
509
+ }
510
+ break main;
511
+ }
512
+ break;
513
+ case "numberExponent":
514
+ patterns.numberExponent.lastIndex = index;
515
+ match = patterns.numberExponent.exec(this._buffer);
516
+ if (!match) {
517
+ if (index < this._buffer.length) {
518
+ this._expect = expected[this._parent];
519
+ break;
520
+ }
521
+ if (this._done) {
522
+ this._expect = "done";
523
+ break;
524
+ }
525
+ break main;
526
+ }
527
+ value = match[0];
528
+ this._streamNumbers && this.push({
529
+ name: "numberChunk",
530
+ value
531
+ });
532
+ this._packNumbers && (this._accumulator += value);
533
+ this._expect = "numberExpSign";
534
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
535
+ else index += value.length;
536
+ break;
537
+ case "numberExpSign":
538
+ patterns.numberExpSign.lastIndex = index;
539
+ match = patterns.numberExpSign.exec(this._buffer);
540
+ if (!match) {
541
+ if (index < this._buffer.length) {
542
+ this._expect = "numberExpStart";
543
+ break;
544
+ }
545
+ if (this._done) return callback(/* @__PURE__ */ new Error("Parser has expected an exponent value of a number"));
546
+ break main;
547
+ }
548
+ value = match[0];
549
+ this._streamNumbers && this.push({
550
+ name: "numberChunk",
551
+ value
552
+ });
553
+ this._packNumbers && (this._accumulator += value);
554
+ this._expect = "numberExpStart";
555
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
556
+ else index += value.length;
557
+ break;
558
+ case "numberExpStart":
559
+ patterns.numberExpStart.lastIndex = index;
560
+ match = patterns.numberExpStart.exec(this._buffer);
561
+ if (!match) {
562
+ if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected an exponent part of a number"));
563
+ break main;
564
+ }
565
+ value = match[0];
566
+ this._streamNumbers && this.push({
567
+ name: "numberChunk",
568
+ value
569
+ });
570
+ this._packNumbers && (this._accumulator += value);
571
+ this._expect = "numberExpDigit";
572
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
573
+ else index += value.length;
574
+ break;
575
+ case "numberExpDigit":
576
+ patterns.numberExpDigit.lastIndex = index;
577
+ match = patterns.numberExpDigit.exec(this._buffer);
578
+ value = match[0];
579
+ if (value) {
580
+ this._streamNumbers && this.push({
581
+ name: "numberChunk",
582
+ value
583
+ });
584
+ this._packNumbers && (this._accumulator += value);
585
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
586
+ else index += value.length;
587
+ } else {
588
+ if (index < this._buffer.length || this._done) {
589
+ this._expect = expected[this._parent];
590
+ break;
591
+ }
592
+ break main;
593
+ }
594
+ break;
595
+ case "done":
596
+ patterns.ws.lastIndex = index;
597
+ match = patterns.ws.exec(this._buffer);
598
+ if (!match) {
599
+ if (index < this._buffer.length) {
600
+ if (this._jsonStreaming) {
601
+ this._expect = "value";
602
+ break;
603
+ }
604
+ return callback(/* @__PURE__ */ new Error("Parser cannot parse input: unexpected characters"));
605
+ }
606
+ break main;
607
+ }
608
+ value = match[0];
609
+ if (this._open_number) {
610
+ this._streamNumbers && this.push({ name: "endNumber" });
611
+ this._open_number = false;
612
+ if (this._packNumbers) {
613
+ this.push({
614
+ name: "numberValue",
615
+ value: this._accumulator
616
+ });
617
+ this._accumulator = "";
618
+ }
619
+ }
620
+ if (noSticky) this._buffer = this._buffer.slice(value.length);
621
+ else index += value.length;
622
+ break;
623
+ }
624
+ !noSticky && (this._buffer = this._buffer.slice(index));
625
+ callback(null);
626
+ }
627
+ };
628
+ Parser$1.parser = Parser$1.make;
629
+ Parser$1.make.Constructor = Parser$1;
630
+ module.exports = Parser$1;
631
+ }) });
632
+
633
+ //#endregion
634
+ //#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/emit.js
635
+ var require_emit = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/emit.js": ((exports, module) => {
636
+ const emit$1 = (stream) => stream.on("data", (item) => stream.emit(item.name, item.value));
637
+ module.exports = emit$1;
638
+ }) });
639
+
640
+ //#endregion
641
+ //#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/index.js
642
+ var require_stream_json = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/index.js": ((exports, module) => {
643
+ const Parser = require_Parser();
644
+ const emit = require_emit();
645
+ const make = (options) => emit(new Parser(options));
646
+ make.Parser = Parser;
647
+ make.parser = Parser.parser;
648
+ module.exports = make;
649
+ }) });
650
+
651
+ //#endregion
652
+ //#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Assembler.js
653
+ var require_Assembler = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Assembler.js": ((exports, module) => {
654
+ const EventEmitter = __require("events");
655
+ const startObject = (Ctr) => function() {
656
+ if (this.done) this.done = false;
657
+ else this.stack.push(this.current, this.key);
658
+ this.current = new Ctr();
659
+ this.key = null;
660
+ };
661
+ var Assembler$1 = class Assembler$1 extends EventEmitter {
662
+ static connectTo(stream, options) {
663
+ return new Assembler$1(options).connectTo(stream);
664
+ }
665
+ constructor(options) {
666
+ super();
667
+ this.stack = [];
668
+ this.current = this.key = null;
669
+ this.done = true;
670
+ if (options) {
671
+ this.reviver = typeof options.reviver == "function" && options.reviver;
672
+ if (this.reviver) this.stringValue = this._saveValue = this._saveValueWithReviver;
673
+ if (options.numberAsString) this.numberValue = this.stringValue;
674
+ }
675
+ }
676
+ connectTo(stream) {
677
+ stream.on("data", (chunk) => {
678
+ if (this[chunk.name]) {
679
+ this[chunk.name](chunk.value);
680
+ if (this.done) this.emit("done", this);
681
+ }
682
+ });
683
+ return this;
684
+ }
685
+ get depth() {
686
+ return (this.stack.length >> 1) + (this.done ? 0 : 1);
687
+ }
688
+ get path() {
689
+ const path = [];
690
+ for (let i = 0; i < this.stack.length; i += 2) {
691
+ const key = this.stack[i + 1];
692
+ path.push(key === null ? this.stack[i].length : key);
693
+ }
694
+ return path;
695
+ }
696
+ dropToLevel(level) {
697
+ if (level < this.depth) if (level) {
698
+ const index = level - 1 << 1;
699
+ this.current = this.stack[index];
700
+ this.key = this.stack[index + 1];
701
+ this.stack.splice(index);
702
+ } else {
703
+ this.stack = [];
704
+ this.current = this.key = null;
705
+ this.done = true;
706
+ }
707
+ return this;
708
+ }
709
+ consume(chunk) {
710
+ this[chunk.name] && this[chunk.name](chunk.value);
711
+ return this;
712
+ }
713
+ keyValue(value) {
714
+ this.key = value;
715
+ }
716
+ numberValue(value) {
717
+ this._saveValue(parseFloat(value));
718
+ }
719
+ nullValue() {
720
+ this._saveValue(null);
721
+ }
722
+ trueValue() {
723
+ this._saveValue(true);
724
+ }
725
+ falseValue() {
726
+ this._saveValue(false);
727
+ }
728
+ endObject() {
729
+ if (this.stack.length) {
730
+ const value = this.current;
731
+ this.key = this.stack.pop();
732
+ this.current = this.stack.pop();
733
+ this._saveValue(value);
734
+ } else this.done = true;
735
+ }
736
+ _saveValue(value) {
737
+ if (this.done) this.current = value;
738
+ else if (this.current instanceof Array) this.current.push(value);
739
+ else {
740
+ this.current[this.key] = value;
741
+ this.key = null;
742
+ }
743
+ }
744
+ _saveValueWithReviver(value) {
745
+ if (this.done) this.current = this.reviver("", value);
746
+ else if (this.current instanceof Array) {
747
+ value = this.reviver("" + this.current.length, value);
748
+ this.current.push(value);
749
+ if (value === void 0) delete this.current[this.current.length - 1];
750
+ } else {
751
+ value = this.reviver(this.key, value);
752
+ if (value !== void 0) this.current[this.key] = value;
753
+ this.key = null;
754
+ }
755
+ }
756
+ };
757
+ Assembler$1.prototype.stringValue = Assembler$1.prototype._saveValue;
758
+ Assembler$1.prototype.startObject = startObject(Object);
759
+ Assembler$1.prototype.startArray = startObject(Array);
760
+ Assembler$1.prototype.endArray = Assembler$1.prototype.endObject;
761
+ module.exports = Assembler$1;
762
+ }) });
763
+
764
+ //#endregion
765
+ //#region src/node/utils/json-parse-stream.ts
766
+ var import_stream_json = /* @__PURE__ */ __toESM(require_stream_json(), 1);
767
+ var import_Assembler = /* @__PURE__ */ __toESM(require_Assembler(), 1);
768
+ async function parseJsonStreamWithConcatArrays(stream, processor) {
769
+ const values$1 = [];
770
+ let lineNumber = 0;
771
+ await pipeline(stream, split2(), async (source) => {
772
+ for await (const line of source) {
773
+ lineNumber += 1;
774
+ if (!line) continue;
775
+ try {
776
+ const parsed = JSON.parse(line);
777
+ const result = processor ? processor(parsed) : parsed;
778
+ values$1.push(result);
779
+ } catch (e) {
780
+ const preview = line.length > 256 ? `${line.slice(0, 256)}...` : line;
781
+ console.warn(`[vite-devtools] JSON parse stream skip bad line ${lineNumber}: ${e.message}\n${preview}`);
782
+ }
783
+ }
784
+ });
785
+ return values$1;
786
+ }
787
+
788
+ //#endregion
789
+ //#region src/node/utils/format.ts
790
+ function getContentByteSize(content) {
791
+ if (!content) return 0;
792
+ return new TextEncoder().encode(content).length;
793
+ }
794
+
795
+ //#endregion
796
+ //#region src/node/rolldown/events-manager.ts
797
+ const DURATION_THRESHOLD = 10;
798
+ const MODULE_BUILD_START_HOOKS = [
799
+ "HookResolveIdCallStart",
800
+ "HookLoadCallStart",
801
+ "HookTransformCallStart"
802
+ ];
803
+ const MODULE_BUILD_END_HOOKS = [
804
+ "HookResolveIdCallEnd",
805
+ "HookLoadCallEnd",
806
+ "HookTransformCallEnd"
807
+ ];
808
+ var RolldownEventsManager = class {
809
+ events = [];
810
+ chunks = /* @__PURE__ */ new Map();
811
+ assets = /* @__PURE__ */ new Map();
812
+ modules = /* @__PURE__ */ new Map();
813
+ source_refs = /* @__PURE__ */ new Map();
814
+ module_build_hook_events = /* @__PURE__ */ new Map();
815
+ module_build_metrics = /* @__PURE__ */ new Map();
816
+ plugin_build_metrics = /* @__PURE__ */ new Map();
817
+ build_start_time = 0;
818
+ build_end_time = 0;
819
+ interpretSourceRefs(event, key) {
820
+ if (key in event && typeof event[key] === "string") {
821
+ if (event[key].startsWith("$ref:")) {
822
+ const refKey = event[key].slice(5);
823
+ if (this.source_refs.has(refKey)) event[key] = this.source_refs.get(refKey);
824
+ }
825
+ }
826
+ }
827
+ recordBuildMetrics(event) {
828
+ if (MODULE_BUILD_START_HOOKS.includes(event.action)) this.module_build_hook_events.set(event.call_id, event);
829
+ else if (MODULE_BUILD_END_HOOKS.includes(event.action)) {
830
+ const start = this.module_build_hook_events.get(event.call_id);
831
+ const module_id = event.action === "HookResolveIdCallEnd" ? event.resolved_id : event.module_id;
832
+ if (start) {
833
+ const pluginId = event.plugin_id;
834
+ const info = {
835
+ id: event.event_id,
836
+ timestamp_start: +start.timestamp,
837
+ timestamp_end: +event.timestamp,
838
+ duration: +event.timestamp - +start.timestamp,
839
+ plugin_id: pluginId,
840
+ plugin_name: event.plugin_name
841
+ };
842
+ const module_build_metrics = this.module_build_metrics.get(module_id) ?? {
843
+ resolve_ids: [],
844
+ loads: [],
845
+ transforms: []
846
+ };
847
+ const plugin_build_metrics = this.plugin_build_metrics.get(pluginId) ?? {
848
+ plugin_id: pluginId,
849
+ plugin_name: event.plugin_name,
850
+ calls: []
851
+ };
852
+ if (event.action === "HookResolveIdCallEnd") {
853
+ module_build_metrics.resolve_ids.push({
854
+ ...info,
855
+ type: "resolve",
856
+ importer: start.importer,
857
+ module_request: start.module_request,
858
+ import_kind: start.import_kind,
859
+ resolved_id: event.resolved_id
860
+ });
861
+ plugin_build_metrics.calls.push({
862
+ ...info,
863
+ type: "resolve",
864
+ module: start.module_request
865
+ });
866
+ } else if (event.action === "HookLoadCallEnd") {
867
+ if (!event.content && info.duration < DURATION_THRESHOLD) return;
868
+ module_build_metrics.loads.push({
869
+ ...info,
870
+ type: "load",
871
+ content: event.content
872
+ });
873
+ plugin_build_metrics.calls.push({
874
+ ...info,
875
+ type: "load",
876
+ module: event.module_id,
877
+ unchanged: !event.content
878
+ });
879
+ } else if (event.action === "HookTransformCallEnd") {
880
+ const _start = start;
881
+ const _end = event;
882
+ if (_start.content === _end.content && info.duration < DURATION_THRESHOLD) return;
883
+ module_build_metrics.transforms.push({
884
+ ...info,
885
+ type: "transform",
886
+ content_from: _start.content,
887
+ content_to: _end.content,
888
+ source_code_size: getContentByteSize(_start.content),
889
+ transformed_code_size: getContentByteSize(_end.content)
890
+ });
891
+ plugin_build_metrics.calls.push({
892
+ ...info,
893
+ type: "transform",
894
+ module: event.module_id,
895
+ unchanged: _start.content === _end.content
896
+ });
897
+ }
898
+ this.plugin_build_metrics.set(pluginId, plugin_build_metrics);
899
+ this.module_build_metrics.set(module_id, module_build_metrics);
900
+ }
901
+ }
902
+ }
903
+ handleEvent(raw) {
904
+ const event = {
905
+ ...raw,
906
+ event_id: `${"timestamp" in raw ? raw.timestamp : "x"}#${this.events.length}`
907
+ };
908
+ this.events.push(event);
909
+ if (event.action === "BuildStart") this.build_start_time = +event.timestamp;
910
+ if (event.action === "BuildEnd") this.build_end_time = +event.timestamp;
911
+ if (event.action === "StringRef") {
912
+ this.source_refs.set(event.id, event.content);
913
+ return;
914
+ }
915
+ if (event.action === "ChunkGraphReady") {
916
+ for (const chunk of event.chunks) this.chunks.set(chunk.chunk_id, chunk);
917
+ return;
918
+ }
919
+ this.interpretSourceRefs(event, "content");
920
+ this.recordBuildMetrics(event);
921
+ if ("module_id" in event) {
922
+ if (this.modules.has(event.module_id)) return;
923
+ this.modules.set(event.module_id, {
924
+ id: event.module_id,
925
+ is_external: false,
926
+ imports: [],
927
+ importers: [],
928
+ build_metrics: {
929
+ resolve_ids: [],
930
+ loads: [],
931
+ transforms: []
932
+ }
933
+ });
934
+ }
935
+ if (event.action === "ModuleGraphReady") {
936
+ this.module_build_hook_events.clear();
937
+ for (const module$1 of event.modules) {
938
+ this.modules.set(module$1.id, {
939
+ ...module$1,
940
+ build_metrics: this.module_build_metrics.get(module$1.id)
941
+ });
942
+ module$1.importers = Array.from(new Set(module$1.importers || [])).sort((a, b) => a.localeCompare(b));
943
+ module$1.imports = Array.from(new Set(module$1.imports || [])).sort((a, b) => a.module_id.localeCompare(b.module_id));
944
+ }
945
+ }
946
+ if (event.action === "AssetsReady") for (const asset of event.assets) this.assets.set(asset.filename, asset);
947
+ return event;
948
+ }
949
+ dispose() {
950
+ this.events = [];
951
+ }
952
+ [Symbol.dispose]() {
953
+ this.dispose();
954
+ }
955
+ };
956
+
957
+ //#endregion
958
+ //#region src/node/rolldown/events-reader.ts
959
+ const readers = /* @__PURE__ */ new Map();
960
+ var RolldownEventsReader = class RolldownEventsReader {
961
+ lastBytes = 0;
962
+ lastTimestamp = 0;
963
+ manager = new RolldownEventsManager();
964
+ meta;
965
+ constructor(filepath) {
966
+ this.filepath = filepath;
967
+ }
968
+ static get(filepath) {
969
+ if (readers.has(filepath)) return readers.get(filepath);
970
+ const reader = new RolldownEventsReader(filepath);
971
+ readers.set(filepath, reader);
972
+ return reader;
973
+ }
974
+ async read() {
975
+ const { mtime, size } = await fs.promises.stat(this.filepath);
976
+ if (mtime.getTime() <= this.lastTimestamp) return;
977
+ const stream = fs.createReadStream(this.filepath, { start: this.lastBytes });
978
+ await parseJsonStreamWithConcatArrays(stream, (event) => {
979
+ this.manager.handleEvent(event);
980
+ return event;
981
+ });
982
+ this.lastTimestamp = mtime.getTime();
983
+ this.lastBytes = size;
984
+ }
985
+ dispose() {
986
+ readers.delete(this.filepath);
987
+ this.manager.dispose();
988
+ }
989
+ [Symbol.dispose]() {
990
+ this.dispose();
991
+ }
992
+ };
993
+
994
+ //#endregion
995
+ //#region src/node/rolldown/logs-manager.ts
996
+ var RolldownLogsManager = class {
997
+ constructor(dir) {
998
+ this.dir = dir;
999
+ }
1000
+ async list() {
1001
+ const sessions = await fs$1.readdir(this.dir, { withFileTypes: true });
1002
+ return await Promise.all(sessions.filter((d) => d.isDirectory()).map(async (d) => {
1003
+ const reader = RolldownEventsReader.get(join(this.dir, d.name, "meta.json"));
1004
+ await reader.read();
1005
+ const meta = reader.manager.events[reader.manager.events.length - 1];
1006
+ return {
1007
+ id: d.name,
1008
+ timestamp: meta.timestamp,
1009
+ meta
1010
+ };
1011
+ }));
1012
+ }
1013
+ async loadSession(session) {
1014
+ const reader = RolldownEventsReader.get(join(this.dir, session, "logs.json"));
1015
+ await reader.read();
1016
+ if (!reader.meta) {
1017
+ const metaReader = RolldownEventsReader.get(join(this.dir, session, "meta.json"));
1018
+ await metaReader.read();
1019
+ reader.meta = metaReader.manager.events.at(-1);
1020
+ }
1021
+ return reader;
1022
+ }
1023
+ };
1024
+
1025
+ //#endregion
1026
+ //#region src/node/rpc/utils.ts
1027
+ const weakMap = /* @__PURE__ */ new WeakMap();
1028
+ function getLogsManager(context) {
1029
+ let manager = weakMap.get(context);
1030
+ if (!manager) {
1031
+ const dir = [join(context.cwd, ".rolldown"), join(process.cwd(), ".rolldown")].find((dir$1) => existsSync(dir$1));
1032
+ if (!dir) throw new Error("Rolldown logs directory not found");
1033
+ manager = new RolldownLogsManager(dir);
1034
+ }
1035
+ return manager;
1036
+ }
1037
+
1038
+ //#endregion
1039
+ //#region src/node/rpc/functions/rolldown-get-asset-details.ts
1040
+ const rolldownGetAssetDetails = defineRpcFunction({
1041
+ name: "vite:rolldown:get-asset-details",
1042
+ type: "query",
1043
+ setup: (context) => {
1044
+ const manager = getLogsManager(context);
1045
+ return { handler: async ({ session, id }) => {
1046
+ const reader = await manager.loadSession(session);
1047
+ const assets = reader.manager.assets;
1048
+ const chunks = reader.manager.chunks;
1049
+ const asset = assets.get(id);
1050
+ const assetList = Array.from(assets.values());
1051
+ const chunkList = Array.from(chunks.values());
1052
+ if (asset.chunk_id === null) return { asset };
1053
+ const assetChunkId = asset.chunk_id;
1054
+ const chunk = chunks.get(assetChunkId);
1055
+ const importers = chunkList.filter((mod) => mod.imports.some((i) => i.chunk_id === assetChunkId)).map((c) => assetList.find((a) => a.chunk_id === c.chunk_id));
1056
+ const imports = chunk.imports.map((c) => assetList.find((a) => a.chunk_id === c.chunk_id));
1057
+ return {
1058
+ asset,
1059
+ chunk,
1060
+ importers,
1061
+ imports
1062
+ };
1063
+ } };
1064
+ }
1065
+ });
1066
+
1067
+ //#endregion
1068
+ //#region src/node/rpc/functions/rolldown-get-assets-list.ts
1069
+ const rolldownGetAssetsList = defineRpcFunction({
1070
+ name: "vite:rolldown:get-assets-list",
1071
+ type: "query",
1072
+ setup: (context) => {
1073
+ const manager = getLogsManager(context);
1074
+ return { handler: async ({ session }) => {
1075
+ const reader = await manager.loadSession(session);
1076
+ return Array.from(reader.manager.assets.values());
1077
+ } };
1078
+ }
1079
+ });
1080
+
1081
+ //#endregion
1082
+ //#region src/node/rpc/functions/rolldown-get-chunk-info.ts
1083
+ const rolldownGetChunkInfo = defineRpcFunction({
1084
+ name: "vite:rolldown:get-chunk-info",
1085
+ type: "query",
1086
+ setup: (context) => {
1087
+ const manager = getLogsManager(context);
1088
+ return { handler: async ({ session, id }) => {
1089
+ return (await manager.loadSession(session)).manager.chunks.get(id);
1090
+ } };
1091
+ }
1092
+ });
1093
+
1094
+ //#endregion
1095
+ //#region src/node/rpc/functions/rolldown-get-chunks-graph.ts
1096
+ const rolldownGetChunksGraph = defineRpcFunction({
1097
+ name: "vite:rolldown:get-chunks-graph",
1098
+ type: "query",
1099
+ setup: (context) => {
1100
+ const manager = getLogsManager(context);
1101
+ return { handler: async ({ session }) => {
1102
+ const reader = await manager.loadSession(session);
1103
+ return Array.from(reader.manager.chunks.values());
1104
+ } };
1105
+ }
1106
+ });
1107
+
1108
+ //#endregion
1109
+ //#region src/node/rpc/functions/rolldown-get-module-info.ts
1110
+ const rolldownGetModuleInfo = defineRpcFunction({
1111
+ name: "vite:rolldown:get-module-info",
1112
+ type: "query",
1113
+ setup: (context) => {
1114
+ const manager = getLogsManager(context);
1115
+ return { handler: async ({ session, module: module$1 }) => {
1116
+ const reader = await manager.loadSession(session);
1117
+ if (!reader.manager.events.length) return null;
1118
+ const moduleInfo = reader.manager.modules.get(module$1);
1119
+ const info = {
1120
+ id: module$1,
1121
+ imports: [],
1122
+ importers: [],
1123
+ chunks: [],
1124
+ assets: [],
1125
+ build_metrics: {
1126
+ resolve_ids: [],
1127
+ loads: [],
1128
+ transforms: []
1129
+ },
1130
+ ...moduleInfo || {},
1131
+ loads: moduleInfo?.build_metrics?.loads ?? [],
1132
+ resolve_ids: moduleInfo?.build_metrics?.resolve_ids ?? []
1133
+ };
1134
+ info.chunks = Array.from(reader.manager.chunks.values()).filter((chunk) => chunk.modules.includes(module$1)).map((chunk) => ({
1135
+ type: "chunk",
1136
+ ...chunk
1137
+ }));
1138
+ info.assets = Array.from(reader.manager.assets.values()).filter((asset) => info.chunks.some((chunk) => chunk.chunk_id === asset.chunk_id)).map((asset) => ({
1139
+ type: "asset",
1140
+ ...asset
1141
+ }));
1142
+ info.loads.sort((a, b) => a.plugin_id - b.plugin_id);
1143
+ info.resolve_ids.sort((a, b) => a.plugin_id - b.plugin_id);
1144
+ return info;
1145
+ } };
1146
+ }
1147
+ });
1148
+
1149
+ //#endregion
1150
+ //#region src/node/rpc/functions/rolldown-get-module-raw-events.ts
1151
+ const rolldownGetModuleRawEvents = defineRpcFunction({
1152
+ name: "vite:rolldown:get-module-raw-events",
1153
+ type: "query",
1154
+ setup: (context) => {
1155
+ const manager = getLogsManager(context);
1156
+ return { handler: async ({ session, module: module$1 }) => {
1157
+ return { events: (await manager.loadSession(session)).manager.events.filter((event) => "module_id" in event && event.module_id !== module$1) };
1158
+ } };
1159
+ }
1160
+ });
1161
+
1162
+ //#endregion
1163
+ //#region src/node/rpc/functions/rolldown-get-module-transforms.ts
1164
+ const rolldownGetModuleTransforms = defineRpcFunction({
1165
+ name: "vite:rolldown:get-module-transforms",
1166
+ type: "query",
1167
+ setup: (context) => {
1168
+ const manager = getLogsManager(context);
1169
+ return { handler: async ({ session, module: module$1 }) => {
1170
+ const reader = await manager.loadSession(session);
1171
+ const events = reader.manager.events;
1172
+ const transforms = reader.manager.modules.get(module$1)?.build_metrics?.transforms ?? [];
1173
+ if (!events.length) return transforms.map((transform) => ({
1174
+ ...transform,
1175
+ diff_added: 0,
1176
+ diff_removed: 0
1177
+ }));
1178
+ return transforms.map((transform) => {
1179
+ let diff_added = 0;
1180
+ let diff_removed = 0;
1181
+ if (transform.content_from !== transform.content_to && transform.content_from != null && transform.content_to != null) {
1182
+ const delta = diffLines(transform.content_from, transform.content_to);
1183
+ diff_added = delta.filter((d) => d.added).map((d) => d.value).join("").split(/\n/g).length;
1184
+ diff_removed = delta.filter((d) => d.removed).map((d) => d.value).join("").split(/\n/g).length;
1185
+ }
1186
+ return {
1187
+ ...transform,
1188
+ diff_added,
1189
+ diff_removed
1190
+ };
1191
+ }).sort((a, b) => a.plugin_id - b.plugin_id);
1192
+ } };
1193
+ }
1194
+ });
1195
+
1196
+ //#endregion
1197
+ //#region src/shared/utils/filepath.ts
1198
+ function isNodeModulePath(path) {
1199
+ return !!path.match(/[/\\]node_modules[/\\]/) || isPackageName(path);
1200
+ }
1201
+ function isPackageName(name) {
1202
+ return name[0] === "#" || !!name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
1203
+ }
1204
+ function getModuleNameFromPath(path) {
1205
+ if (isPackageName(path)) return path;
1206
+ const match = path.replace(/\\/g, "/").match(/.*\/node_modules\/(.*)$/)?.[1];
1207
+ if (!match) return void 0;
1208
+ if (match.startsWith("@")) return match.split("/").slice(0, 2).join("/");
1209
+ return match.split("/")[0];
1210
+ }
1211
+ function getPackageDirPath(path) {
1212
+ const nodeModulesPrefix = path.replace(/%2F/g, "/").replace(/\\/g, "/").match(/^(.+\/node_modules\/)/)?.[1];
1213
+ const packageName = getModuleNameFromPath(path);
1214
+ return nodeModulesPrefix + packageName;
1215
+ }
1216
+
1217
+ //#endregion
1218
+ //#region src/node/rpc/functions/rolldown-get-packages.ts
1219
+ const rolldownGetPackages = defineRpcFunction({
1220
+ name: "vite:rolldown:get-packages",
1221
+ type: "query",
1222
+ setup: (context) => {
1223
+ const manager = getLogsManager(context);
1224
+ return { handler: async ({ session }) => {
1225
+ const reader = await manager.loadSession(session);
1226
+ const chunks = Array.from(reader.manager.chunks.values());
1227
+ const modulesMap = reader.manager.modules;
1228
+ const duplicatePackagesMap = /* @__PURE__ */ new Map();
1229
+ const packagesManifest = /* @__PURE__ */ new Map();
1230
+ const packages = chunks.map((chunk) => chunk.modules.map((module$1) => module$1)).flat().filter(isNodeModulePath).map((p) => {
1231
+ const moduleBuildMetrics = modulesMap.get(p)?.build_metrics;
1232
+ return {
1233
+ path: p,
1234
+ dir: getPackageDirPath(p),
1235
+ transformedCodeSize: moduleBuildMetrics?.transforms[moduleBuildMetrics?.transforms.length - 1]?.transformed_code_size ?? 0
1236
+ };
1237
+ });
1238
+ await Promise.all(packages.map(async (p) => {
1239
+ const manifest = await readProjectManifestOnly(p.dir);
1240
+ const packageKey = `${manifest.name}@${manifest.version}`;
1241
+ const packageInfo = packagesManifest.get(packageKey);
1242
+ const module$1 = modulesMap.get(p.path);
1243
+ if (packageInfo) packagesManifest.set(packageKey, {
1244
+ ...packageInfo,
1245
+ files: [...packageInfo.files, {
1246
+ path: p.path,
1247
+ transformedCodeSize: p.transformedCodeSize,
1248
+ importers: module$1?.importers?.map((i) => ({
1249
+ path: i,
1250
+ version: ""
1251
+ })) ?? []
1252
+ }],
1253
+ transformedCodeSize: packageInfo.transformedCodeSize + p.transformedCodeSize
1254
+ });
1255
+ else packagesManifest.set(packageKey, {
1256
+ name: manifest.name,
1257
+ version: manifest.version,
1258
+ dir: p.dir,
1259
+ files: [{
1260
+ path: p.path,
1261
+ transformedCodeSize: p.transformedCodeSize,
1262
+ importers: module$1?.importers?.map((i) => ({
1263
+ path: i,
1264
+ version: ""
1265
+ })) ?? []
1266
+ }],
1267
+ transformedCodeSize: p.transformedCodeSize
1268
+ });
1269
+ }));
1270
+ return (await Promise.all(Array.from(packagesManifest.values()).map((p) => {
1271
+ duplicatePackagesMap.set(p.name, (duplicatePackagesMap.get(p.name) ?? 0) + 1);
1272
+ return {
1273
+ ...p,
1274
+ type: p.files.some((f) => modulesMap.get(f.path)?.importers?.some((i) => i.includes(reader.meta.cwd))) ? "direct" : "transitive"
1275
+ };
1276
+ }).map(async (p) => {
1277
+ const duplicated = duplicatePackagesMap.get(p.name) > 1;
1278
+ let files = p.files;
1279
+ if (duplicated) files = await Promise.all(files.map(async (f) => {
1280
+ const importers = await Promise.all(f.importers.map(async (i) => {
1281
+ const manifest = isNodeModulePath(i.path) ? await readProjectManifestOnly(getPackageDirPath(i.path)) : null;
1282
+ return {
1283
+ ...i,
1284
+ version: manifest?.version ?? ""
1285
+ };
1286
+ }));
1287
+ return {
1288
+ ...f,
1289
+ importers
1290
+ };
1291
+ }));
1292
+ return {
1293
+ ...p,
1294
+ duplicated,
1295
+ files
1296
+ };
1297
+ }))).filter((i) => !!i.transformedCodeSize);
1298
+ } };
1299
+ }
1300
+ });
1301
+
1302
+ //#endregion
1303
+ //#region src/node/rpc/functions/rolldown-get-plugin-details.ts
1304
+ const rolldownGetPluginDetails = defineRpcFunction({
1305
+ name: "vite:rolldown:get-plugin-details",
1306
+ type: "query",
1307
+ setup: (context) => {
1308
+ const manager = getLogsManager(context);
1309
+ return { handler: async ({ session, id }) => {
1310
+ const reader = await manager.loadSession(session);
1311
+ const pluginBuildMetrics = reader.manager.plugin_build_metrics.get(+id);
1312
+ if (!pluginBuildMetrics) return {
1313
+ plugin_name: reader.meta.plugins.find((p) => p.plugin_id === +id)?.name,
1314
+ plugin_id: +id,
1315
+ calls: [],
1316
+ loadMetrics: [],
1317
+ resolveIdMetrics: [],
1318
+ transformMetrics: []
1319
+ };
1320
+ const resolveIdMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "resolve");
1321
+ const loadMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "load");
1322
+ const transformMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "transform");
1323
+ return {
1324
+ ...pluginBuildMetrics,
1325
+ resolveIdMetrics,
1326
+ loadMetrics,
1327
+ transformMetrics
1328
+ };
1329
+ } };
1330
+ }
1331
+ });
1332
+
1333
+ //#endregion
1334
+ //#region src/node/rpc/functions/rolldown-get-raw-events.ts
1335
+ const rolldownGetRawEvents = defineRpcFunction({
1336
+ name: "vite:rolldown:get-raw-events",
1337
+ type: "query",
1338
+ setup: (context) => {
1339
+ const manager = getLogsManager(context);
1340
+ return { handler: async ({ session }) => {
1341
+ return (await manager.loadSession(session)).manager.events;
1342
+ } };
1343
+ }
1344
+ });
1345
+
1346
+ //#endregion
1347
+ //#region src/node/rpc/functions/rolldown-get-session-compare-summary.ts
1348
+ const rolldownGetSessionCompareSummary = defineRpcFunction({
1349
+ name: "vite:rolldown:get-session-compare-summary",
1350
+ type: "query",
1351
+ setup: async (context) => {
1352
+ const manager = getLogsManager(context);
1353
+ return { handler: async ({ sessions }) => {
1354
+ const reader = await Promise.all(sessions.map((s) => manager.loadSession(s)));
1355
+ return sessions.map((s, index) => {
1356
+ const _reader = reader[index];
1357
+ const assets = Array.from(_reader.manager.assets.values());
1358
+ const chunks = Array.from(_reader.manager.chunks.values());
1359
+ function getInitialChunkIds(chunkIds, visited = /* @__PURE__ */ new Set()) {
1360
+ const initialChunkIds$1 = [];
1361
+ for (const chunkId of chunkIds) {
1362
+ if (visited.has(chunkId)) continue;
1363
+ visited.add(chunkId);
1364
+ const chunk = chunks.find((c) => c.chunk_id === chunkId);
1365
+ if (chunk?.imports) {
1366
+ const importChunkIds = chunk.imports.map((imp) => imp.chunk_id);
1367
+ initialChunkIds$1.push(...importChunkIds);
1368
+ const nestedImports = getInitialChunkIds(importChunkIds, visited);
1369
+ initialChunkIds$1.push(...nestedImports);
1370
+ }
1371
+ }
1372
+ return initialChunkIds$1;
1373
+ }
1374
+ const entryChunkIds = chunks.filter((chunk) => !!chunk.is_user_defined_entry).map((chunk) => chunk.chunk_id);
1375
+ const initialChunkIds = [...new Set([...entryChunkIds, ...getInitialChunkIds(entryChunkIds)])];
1376
+ return {
1377
+ id: s,
1378
+ meta: _reader.meta,
1379
+ build_duration: _reader.manager.build_end_time - _reader.manager.build_start_time,
1380
+ modules: Array.from(_reader.manager.modules.values()).length,
1381
+ chunks: chunks.length,
1382
+ assets: assets.length,
1383
+ bundle_size: assets.reduce((acc, asset) => acc + asset.size, 0),
1384
+ initial_js: initialChunkIds.reduce((acc, chunkId) => acc + (assets.find((asset) => asset.chunk_id === chunkId)?.size || 0), 0)
1385
+ };
1386
+ });
1387
+ } };
1388
+ }
1389
+ });
1390
+
1391
+ //#endregion
1392
+ //#region src/node/rpc/functions/rolldown-get-session-summary.ts
1393
+ const rolldownGetSessionSummary = defineRpcFunction({
1394
+ name: "vite:rolldown:get-session-summary",
1395
+ type: "query",
1396
+ setup: async (context) => {
1397
+ const manager = getLogsManager(context);
1398
+ return { handler: async ({ session }) => {
1399
+ const reader = await manager.loadSession(session);
1400
+ return {
1401
+ id: session,
1402
+ meta: reader.meta,
1403
+ build_duration: reader.manager.build_end_time - reader.manager.build_start_time,
1404
+ modules: Array.from(reader.manager.modules.values()).sort((a, b) => a.id.localeCompare(b.id))
1405
+ };
1406
+ } };
1407
+ }
1408
+ });
1409
+
1410
+ //#endregion
1411
+ //#region src/node/rpc/functions/rolldown-list-sessions.ts
1412
+ const rolldownListSessions = defineRpcFunction({
1413
+ name: "vite:rolldown:list-sessions",
1414
+ type: "query",
1415
+ setup: (context) => {
1416
+ const manager = getLogsManager(context);
1417
+ return { handler: async () => {
1418
+ return (await manager.list()).sort((a, b) => b.timestamp - a.timestamp);
1419
+ } };
1420
+ }
1421
+ });
1422
+
1423
+ //#endregion
1424
+ //#region src/node/rpc/index.ts
1425
+ const rpcFunctions = [
1426
+ getPayload,
1427
+ rolldownListSessions,
1428
+ rolldownGetRawEvents,
1429
+ rolldownGetSessionSummary,
1430
+ rolldownGetModuleInfo,
1431
+ rolldownGetModuleRawEvents,
1432
+ rolldownGetModuleTransforms,
1433
+ rolldownGetChunksGraph,
1434
+ rolldownGetAssetsList,
1435
+ rolldownGetAssetDetails,
1436
+ rolldownGetPluginDetails,
1437
+ rolldownGetSessionCompareSummary,
1438
+ rolldownGetChunkInfo,
1439
+ rolldownGetPackages
1440
+ ];
1441
+
1442
+ //#endregion
1443
+ //#region src/node/plugin.ts
1444
+ function DevToolsViteUI() {
1445
+ return {
1446
+ name: "vite:devtools",
1447
+ devtools: { setup(ctx) {
1448
+ console.log("Vite DevTools Vite plugin setup");
1449
+ for (const fn of rpcFunctions) ctx.rpc.register(fn);
1450
+ ctx.hostStatic("/__vite_devtools_vite__/", clientPublicDir);
1451
+ ctx.docks.register({
1452
+ id: "vite",
1453
+ title: "Vite",
1454
+ icon: "https://vite.dev/logo.svg",
1455
+ type: "iframe",
1456
+ url: "/__vite_devtools_vite__/"
1457
+ });
1458
+ } }
1459
+ };
1460
+ }
1461
+
1462
+ //#endregion
1463
+ export { DevToolsViteUI };