@vitejs/devtools-vite 0.0.0-alpha.9 → 0.4.3

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 (91) hide show
  1. package/dist/{dirs-K_XnRVOr.js → dirs.mjs} +1 -3
  2. package/dist/index.d.mts +101 -0
  3. package/dist/index.mjs +2254 -0
  4. package/dist/nitro.json +3 -3
  5. package/dist/public/200.html +1 -1
  6. package/dist/public/404.html +1 -1
  7. package/dist/public/_nuxt/0fZFclj2.js +2 -0
  8. package/dist/public/_nuxt/457Jr4Pr.js +1 -0
  9. package/dist/public/_nuxt/B1xYalZA.js +1 -0
  10. package/dist/public/_nuxt/BDNMzG2s.js +1 -0
  11. package/dist/public/_nuxt/BJv-YGcz.js +1 -0
  12. package/dist/public/_nuxt/BKuuhLmM.js +1 -0
  13. package/dist/public/_nuxt/BjJFp2QE.js +1 -0
  14. package/dist/public/_nuxt/C3lVFA1Q.js +1 -0
  15. package/dist/public/_nuxt/CAlSLYmJ.js +1 -0
  16. package/dist/public/_nuxt/CHXuaNaj.js +1 -0
  17. package/dist/public/_nuxt/CJwKXY9k.js +1 -0
  18. package/dist/public/_nuxt/CQYaOgKz.js +1 -0
  19. package/dist/public/_nuxt/CWPpjZx6.js +1 -0
  20. package/dist/public/_nuxt/CeVkPjP7.js +12 -0
  21. package/dist/public/_nuxt/D3MExTHO.js +3 -0
  22. package/dist/public/_nuxt/K3CNNOBf.js +2 -0
  23. package/dist/public/_nuxt/NLJpu4QF.js +1 -0
  24. package/dist/public/_nuxt/QSP1yWcH.js +1 -0
  25. package/dist/public/_nuxt/builds/latest.json +1 -1
  26. package/dist/public/_nuxt/builds/meta/d3f7ed61-b5b0-435f-9c70-ecd6f63b3201.json +1 -0
  27. package/dist/public/_nuxt/diff.worker-DFeiLCV8.js +10 -0
  28. package/dist/public/_nuxt/entry.CzwuNVVL.css +1 -0
  29. package/dist/public/_nuxt/error-404.YVLV_SWG.css +1 -0
  30. package/dist/public/_nuxt/error-500.DoVxOHYG.css +1 -0
  31. package/dist/public/_nuxt/filepath.CX8PXv9n.css +1 -0
  32. package/dist/public/_nuxt/graph.qvMalRQi.css +1 -0
  33. package/dist/public/_nuxt/plugins.CtM-Tp_V.css +1 -0
  34. package/dist/public/_nuxt/rpc.CVTFzytL.css +1 -0
  35. package/dist/public/favicon.svg +127 -12
  36. package/dist/public/fonts/dmmono-53a90e28.woff2 +0 -0
  37. package/dist/public/fonts/dmmono-cd6ed524.woff2 +0 -0
  38. package/dist/public/fonts/dmsans-54dbf8a8.woff2 +0 -0
  39. package/dist/public/fonts/dmsans-c55bbe7a.woff2 +0 -0
  40. package/dist/public/index.html +1 -1
  41. package/package.json +30 -51
  42. package/dist/dirs.js +0 -3
  43. package/dist/index.d.ts +0 -146
  44. package/dist/index.js +0 -1508
  45. package/dist/public/_nuxt/17ealR8P.js +0 -1
  46. package/dist/public/_nuxt/2OALqkc2.js +0 -1
  47. package/dist/public/_nuxt/AuXMpmu_.js +0 -1
  48. package/dist/public/_nuxt/B-LCQpq9.js +0 -2
  49. package/dist/public/_nuxt/B-MkobAt.js +0 -1
  50. package/dist/public/_nuxt/BFwdTbGt.js +0 -1
  51. package/dist/public/_nuxt/BQPGP7j8.js +0 -1
  52. package/dist/public/_nuxt/B_mZ82Ef.js +0 -1
  53. package/dist/public/_nuxt/BkcJ9YuP.js +0 -33
  54. package/dist/public/_nuxt/Bs1eUuZt.js +0 -1
  55. package/dist/public/_nuxt/C2Zn9dj_.js +0 -1
  56. package/dist/public/_nuxt/CIZ7KSXz.js +0 -1
  57. package/dist/public/_nuxt/CSwEzrF7.js +0 -11
  58. package/dist/public/_nuxt/CbzAqNxs.js +0 -1
  59. package/dist/public/_nuxt/ChaI2u-J.js +0 -1
  60. package/dist/public/_nuxt/CmZYssbg.js +0 -1
  61. package/dist/public/_nuxt/Cnct9GAr.js +0 -1
  62. package/dist/public/_nuxt/Cq2KqeQT.js +0 -1
  63. package/dist/public/_nuxt/Cql2HFZJ.js +0 -1
  64. package/dist/public/_nuxt/D-ZnEyqr.js +0 -1
  65. package/dist/public/_nuxt/D03ETnho.js +0 -1
  66. package/dist/public/_nuxt/D2Zr4_9a.js +0 -1
  67. package/dist/public/_nuxt/D7AVRXB9.js +0 -1
  68. package/dist/public/_nuxt/DL1ysgP5.js +0 -1
  69. package/dist/public/_nuxt/DP5rIU2b.js +0 -1
  70. package/dist/public/_nuxt/DQtLZa7C.js +0 -1
  71. package/dist/public/_nuxt/DcamI1aQ.js +0 -1
  72. package/dist/public/_nuxt/DnpfwSMy.js +0 -1
  73. package/dist/public/_nuxt/HzvsUJ0F.js +0 -1
  74. package/dist/public/_nuxt/Jdu9jmuG.js +0 -1
  75. package/dist/public/_nuxt/LMGHh3hZ.js +0 -1
  76. package/dist/public/_nuxt/SO3ppn9m.js +0 -1
  77. package/dist/public/_nuxt/VirtualList.lGV_3v2U.css +0 -1
  78. package/dist/public/_nuxt/X7aOo9pb.js +0 -1
  79. package/dist/public/_nuxt/_hSlj5r4.js +0 -1
  80. package/dist/public/_nuxt/_session_.B0BbH92J.css +0 -1
  81. package/dist/public/_nuxt/builds/meta/ef0d166a-8482-442c-9350-f2a451006de7.json +0 -1
  82. package/dist/public/_nuxt/diff.worker-DCsgdfuV.js +0 -10
  83. package/dist/public/_nuxt/entry.D6FiGaDn.css +0 -1
  84. package/dist/public/_nuxt/error-404.CCdr3eE4.css +0 -1
  85. package/dist/public/_nuxt/error-500.D-vBsHK_.css +0 -1
  86. package/dist/public/_nuxt/lxg2Cb0s.js +0 -1
  87. package/dist/public/_nuxt/mIZU4Om9.js +0 -1
  88. package/dist/public/_nuxt/qkzn-X0p.js +0 -1
  89. package/dist/public/_nuxt/vzoJapJG.js +0 -1
  90. package/dist/public/vite-devtools.svg +0 -17
  91. /package/dist/{dirs.d.ts → dirs.d.mts} +0 -0
package/dist/index.js DELETED
@@ -1,1508 +0,0 @@
1
- import { t as clientPublicDir } from "./dirs-K_XnRVOr.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
- await parseJsonStreamWithConcatArrays(fs.createReadStream(this.filepath, { start: this.lastBytes }), (event) => {
978
- this.manager.handleEvent(event);
979
- return event;
980
- });
981
- this.lastTimestamp = mtime.getTime();
982
- this.lastBytes = size;
983
- }
984
- dispose() {
985
- readers.delete(this.filepath);
986
- this.manager.dispose();
987
- }
988
- [Symbol.dispose]() {
989
- this.dispose();
990
- }
991
- };
992
-
993
- //#endregion
994
- //#region src/node/rolldown/logs-manager.ts
995
- var RolldownLogsManager = class {
996
- constructor(dir) {
997
- this.dir = dir;
998
- }
999
- async list() {
1000
- if (!existsSync(this.dir)) return [];
1001
- const sessions = await fs$1.readdir(this.dir, { withFileTypes: true });
1002
- return await Promise.all(sessions.filter((d) => d.isDirectory()).filter((d) => existsSync(join(this.dir, d.name, "meta.json"))).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 dirs = [join(context.cwd, ".rolldown"), join(process.cwd(), ".rolldown")];
1032
- const dir = dirs.find((dir$1) => existsSync(dir$1));
1033
- if (!dir) console.warn("[Vite DevTools] Rolldown logs directory `.rolldown` not found, you might want to run build with `build.rolldownOptions.debug` enabled first.");
1034
- manager = new RolldownLogsManager(dir ?? dirs[0]);
1035
- }
1036
- return manager;
1037
- }
1038
-
1039
- //#endregion
1040
- //#region src/node/rpc/functions/rolldown-get-asset-details.ts
1041
- const rolldownGetAssetDetails = defineRpcFunction({
1042
- name: "vite:rolldown:get-asset-details",
1043
- type: "query",
1044
- setup: (context) => {
1045
- const manager = getLogsManager(context);
1046
- return { handler: async ({ session, id }) => {
1047
- const reader = await manager.loadSession(session);
1048
- const assets = reader.manager.assets;
1049
- const chunks = reader.manager.chunks;
1050
- const asset = assets.get(id);
1051
- const assetList = Array.from(assets.values());
1052
- const chunkList = Array.from(chunks.values());
1053
- if (asset.chunk_id === null) return { asset };
1054
- const assetChunkId = asset.chunk_id;
1055
- const chunk = chunks.get(assetChunkId);
1056
- return {
1057
- asset,
1058
- chunk,
1059
- importers: chunkList.filter((mod) => mod.imports.some((i) => i.chunk_id === assetChunkId)).map((c) => assetList.find((a) => a.chunk_id === c.chunk_id)),
1060
- imports: chunk.imports.map((c) => assetList.find((a) => a.chunk_id === c.chunk_id))
1061
- };
1062
- } };
1063
- }
1064
- });
1065
-
1066
- //#endregion
1067
- //#region src/node/rpc/functions/rolldown-get-assets-list.ts
1068
- const rolldownGetAssetsList = defineRpcFunction({
1069
- name: "vite:rolldown:get-assets-list",
1070
- type: "query",
1071
- setup: (context) => {
1072
- const manager = getLogsManager(context);
1073
- return { handler: async ({ session }) => {
1074
- const reader = await manager.loadSession(session);
1075
- return Array.from(reader.manager.assets.values());
1076
- } };
1077
- }
1078
- });
1079
-
1080
- //#endregion
1081
- //#region src/shared/utils/guess-chunk-name.ts
1082
- function guessChunkName(chunk) {
1083
- if (chunk.name) return chunk.name;
1084
- if (chunk.modules.length === 1) return `[${simplifyModuleName(chunk.modules[0])}]`;
1085
- if (chunk.modules.length > 1) return `[${simplifyModuleName(`${chunk.modules[0]}`)}_${chunk.modules.length}]`;
1086
- return "[unnamed]";
1087
- }
1088
- function simplifyModuleName(module$1) {
1089
- let parts = module$1.replace(/^.*(\.pnpm|node_modules|src|app|packages)\//gi, "").replace(/\b(index|main|dist|test|component|components)\b/gi, "").replace(/\/+/g, "/").replace(/\?.*$/, "").replace(/\.\w+$/, "").replace(/\W/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase().split("_").filter(Boolean);
1090
- parts = Array.from(new Set(parts));
1091
- if (parts.length > 5) parts = parts.slice(0, 5);
1092
- return parts.join("_");
1093
- }
1094
-
1095
- //#endregion
1096
- //#region src/node/rpc/functions/rolldown-get-chunk-info.ts
1097
- const rolldownGetChunkInfo = defineRpcFunction({
1098
- name: "vite:rolldown:get-chunk-info",
1099
- type: "query",
1100
- setup: (context) => {
1101
- const manager = getLogsManager(context);
1102
- return { handler: async ({ session, id }) => {
1103
- const chunk = (await manager.loadSession(session)).manager.chunks.get(id);
1104
- if (chunk && !chunk.name) chunk.name = guessChunkName(chunk);
1105
- return chunk;
1106
- } };
1107
- }
1108
- });
1109
-
1110
- //#endregion
1111
- //#region src/node/rpc/functions/rolldown-get-chunks-graph.ts
1112
- const rolldownGetChunksGraph = defineRpcFunction({
1113
- name: "vite:rolldown:get-chunks-graph",
1114
- type: "query",
1115
- setup: (context) => {
1116
- const manager = getLogsManager(context);
1117
- return { handler: async ({ session }) => {
1118
- const reader = await manager.loadSession(session);
1119
- const chunks = Array.from(reader.manager.chunks.values());
1120
- chunks.forEach((chunk) => {
1121
- if (chunk && !chunk.name) chunk.name = guessChunkName(chunk);
1122
- });
1123
- return chunks;
1124
- } };
1125
- }
1126
- });
1127
-
1128
- //#endregion
1129
- //#region src/node/rpc/functions/rolldown-get-module-info.ts
1130
- const rolldownGetModuleInfo = defineRpcFunction({
1131
- name: "vite:rolldown:get-module-info",
1132
- type: "query",
1133
- setup: (context) => {
1134
- const manager = getLogsManager(context);
1135
- return { handler: async ({ session, module: module$1 }) => {
1136
- const reader = await manager.loadSession(session);
1137
- if (!reader.manager.events.length) return null;
1138
- const moduleInfo = reader.manager.modules.get(module$1);
1139
- const info = {
1140
- id: module$1,
1141
- imports: [],
1142
- importers: [],
1143
- chunks: [],
1144
- assets: [],
1145
- build_metrics: {
1146
- resolve_ids: [],
1147
- loads: [],
1148
- transforms: []
1149
- },
1150
- ...moduleInfo || {},
1151
- loads: moduleInfo?.build_metrics?.loads ?? [],
1152
- resolve_ids: moduleInfo?.build_metrics?.resolve_ids ?? []
1153
- };
1154
- info.chunks = Array.from(reader.manager.chunks.values()).filter((chunk) => chunk.modules.includes(module$1)).map((chunk) => ({
1155
- type: "chunk",
1156
- ...chunk
1157
- }));
1158
- info.assets = Array.from(reader.manager.assets.values()).filter((asset) => info.chunks.some((chunk) => chunk.chunk_id === asset.chunk_id)).map((asset) => ({
1159
- type: "asset",
1160
- ...asset
1161
- }));
1162
- info.loads.sort((a, b) => a.plugin_id - b.plugin_id);
1163
- info.resolve_ids.sort((a, b) => a.plugin_id - b.plugin_id);
1164
- return info;
1165
- } };
1166
- }
1167
- });
1168
-
1169
- //#endregion
1170
- //#region src/node/rpc/functions/rolldown-get-module-raw-events.ts
1171
- const rolldownGetModuleRawEvents = defineRpcFunction({
1172
- name: "vite:rolldown:get-module-raw-events",
1173
- type: "query",
1174
- setup: (context) => {
1175
- const manager = getLogsManager(context);
1176
- return { handler: async ({ session, module: module$1 }) => {
1177
- return { events: (await manager.loadSession(session)).manager.events.filter((event) => "module_id" in event && event.module_id !== module$1) };
1178
- } };
1179
- }
1180
- });
1181
-
1182
- //#endregion
1183
- //#region src/node/rpc/functions/rolldown-get-module-transforms.ts
1184
- const rolldownGetModuleTransforms = defineRpcFunction({
1185
- name: "vite:rolldown:get-module-transforms",
1186
- type: "query",
1187
- setup: (context) => {
1188
- const manager = getLogsManager(context);
1189
- return { handler: async ({ session, module: module$1 }) => {
1190
- const reader = await manager.loadSession(session);
1191
- const events = reader.manager.events;
1192
- const transforms = reader.manager.modules.get(module$1)?.build_metrics?.transforms ?? [];
1193
- if (!events.length) return transforms.map((transform) => ({
1194
- ...transform,
1195
- diff_added: 0,
1196
- diff_removed: 0
1197
- }));
1198
- return transforms.map((transform) => {
1199
- let diff_added = 0;
1200
- let diff_removed = 0;
1201
- if (transform.content_from !== transform.content_to && transform.content_from != null && transform.content_to != null) {
1202
- const delta = diffLines(transform.content_from, transform.content_to);
1203
- diff_added = delta.filter((d) => d.added).map((d) => d.value).join("").split(/\n/g).length;
1204
- diff_removed = delta.filter((d) => d.removed).map((d) => d.value).join("").split(/\n/g).length;
1205
- }
1206
- return {
1207
- ...transform,
1208
- diff_added,
1209
- diff_removed
1210
- };
1211
- }).sort((a, b) => a.plugin_id - b.plugin_id);
1212
- } };
1213
- }
1214
- });
1215
-
1216
- //#endregion
1217
- //#region src/shared/utils/filepath.ts
1218
- function isNodeModulePath(path) {
1219
- return !!path.match(/[/\\]node_modules[/\\]/) || isPackageName(path);
1220
- }
1221
- function isPackageName(name) {
1222
- return name[0] === "#" || !!name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
1223
- }
1224
- function getModuleNameFromPath(path) {
1225
- if (isPackageName(path)) return path;
1226
- const match = path.replace(/\\/g, "/").match(/.*\/node_modules\/(.*)$/)?.[1];
1227
- if (!match) return void 0;
1228
- if (match.startsWith("@")) return match.split("/").slice(0, 2).join("/");
1229
- return match.split("/")[0];
1230
- }
1231
- function getPackageDirPath(path) {
1232
- return path.replace(/%2F/g, "/").replace(/\\/g, "/").match(/^(.+\/node_modules\/)/)?.[1] + getModuleNameFromPath(path);
1233
- }
1234
-
1235
- //#endregion
1236
- //#region src/node/rpc/functions/rolldown-get-packages.ts
1237
- async function getPackagesManifest(reader) {
1238
- const modulesMap = reader.manager.modules;
1239
- const chunks = Array.from(reader.manager.chunks.values());
1240
- const packagesManifest = /* @__PURE__ */ new Map();
1241
- const getImporters = (path, packageDir, visited = /* @__PURE__ */ new Set()) => {
1242
- const importers = modulesMap.get(path)?.importers || [];
1243
- const result = [];
1244
- for (const importer of importers) {
1245
- if (visited.has(importer)) continue;
1246
- visited.add(importer);
1247
- if ((modulesMap.get(importer)?.imports?.map((i) => i.module_id) || []).some((i) => getPackageDirPath(i) === packageDir)) result.push(importer);
1248
- result.push(...getImporters(importer, packageDir, visited));
1249
- }
1250
- return result;
1251
- };
1252
- const packages = chunks.map((chunk) => chunk.modules.map((module$1) => module$1)).flat().filter(isNodeModulePath).map((p) => {
1253
- const moduleBuildMetrics = modulesMap.get(p)?.build_metrics;
1254
- return {
1255
- path: p,
1256
- dir: getPackageDirPath(p),
1257
- transformedCodeSize: moduleBuildMetrics?.transforms[moduleBuildMetrics?.transforms.length - 1]?.transformed_code_size ?? 0
1258
- };
1259
- });
1260
- await Promise.all(packages.map(async (p) => {
1261
- const manifest = await readProjectManifestOnly(p.dir);
1262
- const packageKey = `${manifest.name}@${manifest.version}`;
1263
- const packageInfo = packagesManifest.get(packageKey);
1264
- const importers = getImporters(p.path, p.dir).map((i) => ({
1265
- path: i,
1266
- version: ""
1267
- }));
1268
- if (packageInfo) packagesManifest.set(packageKey, {
1269
- ...packageInfo,
1270
- files: [...packageInfo.files, {
1271
- path: p.path,
1272
- transformedCodeSize: p.transformedCodeSize,
1273
- importers
1274
- }],
1275
- transformedCodeSize: packageInfo.transformedCodeSize + p.transformedCodeSize
1276
- });
1277
- else packagesManifest.set(packageKey, {
1278
- name: manifest.name,
1279
- version: manifest.version,
1280
- dir: p.dir,
1281
- files: [{
1282
- path: p.path,
1283
- transformedCodeSize: p.transformedCodeSize,
1284
- importers
1285
- }],
1286
- transformedCodeSize: p.transformedCodeSize
1287
- });
1288
- }));
1289
- return packagesManifest;
1290
- }
1291
- const rolldownGetPackages = defineRpcFunction({
1292
- name: "vite:rolldown:get-packages",
1293
- type: "query",
1294
- setup: (context) => {
1295
- const manager = getLogsManager(context);
1296
- return { handler: async ({ session }) => {
1297
- const reader = await manager.loadSession(session);
1298
- const modulesMap = reader.manager.modules;
1299
- const duplicatePackagesMap = /* @__PURE__ */ new Map();
1300
- const packagesManifest = await getPackagesManifest(reader);
1301
- return (await Promise.all(Array.from(packagesManifest.values()).map((p) => {
1302
- duplicatePackagesMap.set(p.name, (duplicatePackagesMap.get(p.name) ?? 0) + 1);
1303
- return {
1304
- ...p,
1305
- type: p.files.some((f) => modulesMap.get(f.path)?.importers?.some((i) => i.includes(reader.meta.cwd))) ? "direct" : "transitive"
1306
- };
1307
- }).map(async (p) => {
1308
- const duplicated = duplicatePackagesMap.get(p.name) > 1;
1309
- let files = p.files;
1310
- if (duplicated) files = await Promise.all(files.map(async (f) => {
1311
- const importers = await Promise.all(f.importers.map(async (i) => {
1312
- const manifest = isNodeModulePath(i.path) ? await readProjectManifestOnly(getPackageDirPath(i.path)) : null;
1313
- return {
1314
- ...i,
1315
- version: manifest?.version ?? ""
1316
- };
1317
- }));
1318
- return {
1319
- ...f,
1320
- importers
1321
- };
1322
- }));
1323
- return {
1324
- ...p,
1325
- duplicated,
1326
- files
1327
- };
1328
- }))).filter((i) => !!i.transformedCodeSize);
1329
- } };
1330
- }
1331
- });
1332
-
1333
- //#endregion
1334
- //#region src/node/rpc/functions/rolldown-get-package-details.ts
1335
- const rolldownGetPackageDetails = defineRpcFunction({
1336
- name: "vite:rolldown:get-package-details",
1337
- type: "query",
1338
- setup: (context) => {
1339
- const manager = getLogsManager(context);
1340
- return { handler: async ({ session, id }) => {
1341
- return (await getPackagesManifest(await manager.loadSession(session))).get(id);
1342
- } };
1343
- }
1344
- });
1345
-
1346
- //#endregion
1347
- //#region src/node/rpc/functions/rolldown-get-plugin-details.ts
1348
- const rolldownGetPluginDetails = defineRpcFunction({
1349
- name: "vite:rolldown:get-plugin-details",
1350
- type: "query",
1351
- setup: (context) => {
1352
- const manager = getLogsManager(context);
1353
- return { handler: async ({ session, id }) => {
1354
- const reader = await manager.loadSession(session);
1355
- const pluginBuildMetrics = reader.manager.plugin_build_metrics.get(+id);
1356
- if (!pluginBuildMetrics) return {
1357
- plugin_name: reader.meta.plugins.find((p) => p.plugin_id === +id)?.name,
1358
- plugin_id: +id,
1359
- calls: [],
1360
- loadMetrics: [],
1361
- resolveIdMetrics: [],
1362
- transformMetrics: []
1363
- };
1364
- const resolveIdMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "resolve");
1365
- const loadMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "load");
1366
- const transformMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "transform");
1367
- return {
1368
- ...pluginBuildMetrics,
1369
- resolveIdMetrics,
1370
- loadMetrics,
1371
- transformMetrics
1372
- };
1373
- } };
1374
- }
1375
- });
1376
-
1377
- //#endregion
1378
- //#region src/node/rpc/functions/rolldown-get-raw-events.ts
1379
- const rolldownGetRawEvents = defineRpcFunction({
1380
- name: "vite:rolldown:get-raw-events",
1381
- type: "query",
1382
- setup: (context) => {
1383
- const manager = getLogsManager(context);
1384
- return { handler: async ({ session }) => {
1385
- return (await manager.loadSession(session)).manager.events;
1386
- } };
1387
- }
1388
- });
1389
-
1390
- //#endregion
1391
- //#region src/node/rpc/functions/rolldown-get-session-compare-summary.ts
1392
- const rolldownGetSessionCompareSummary = defineRpcFunction({
1393
- name: "vite:rolldown:get-session-compare-summary",
1394
- type: "query",
1395
- setup: async (context) => {
1396
- const manager = getLogsManager(context);
1397
- return { handler: async ({ sessions }) => {
1398
- const reader = await Promise.all(sessions.map((s) => manager.loadSession(s)));
1399
- return sessions.map((s, index) => {
1400
- const _reader = reader[index];
1401
- const assets = Array.from(_reader.manager.assets.values());
1402
- const chunks = Array.from(_reader.manager.chunks.values());
1403
- function getInitialChunkIds(chunkIds, visited = /* @__PURE__ */ new Set()) {
1404
- const initialChunkIds$1 = [];
1405
- for (const chunkId of chunkIds) {
1406
- if (visited.has(chunkId)) continue;
1407
- visited.add(chunkId);
1408
- const chunk = chunks.find((c) => c.chunk_id === chunkId);
1409
- if (chunk?.imports) {
1410
- const importChunkIds = chunk.imports.map((imp) => imp.chunk_id);
1411
- initialChunkIds$1.push(...importChunkIds);
1412
- const nestedImports = getInitialChunkIds(importChunkIds, visited);
1413
- initialChunkIds$1.push(...nestedImports);
1414
- }
1415
- }
1416
- return initialChunkIds$1;
1417
- }
1418
- const entryChunkIds = chunks.filter((chunk) => !!chunk.is_user_defined_entry).map((chunk) => chunk.chunk_id);
1419
- const initialChunkIds = [...new Set([...entryChunkIds, ...getInitialChunkIds(entryChunkIds)])];
1420
- return {
1421
- id: s,
1422
- meta: _reader.meta,
1423
- build_duration: _reader.manager.build_end_time - _reader.manager.build_start_time,
1424
- modules: Array.from(_reader.manager.modules.values()).length,
1425
- chunks: chunks.length,
1426
- assets: assets.length,
1427
- bundle_size: assets.reduce((acc, asset) => acc + asset.size, 0),
1428
- initial_js: initialChunkIds.reduce((acc, chunkId) => acc + (assets.find((asset) => asset.chunk_id === chunkId)?.size || 0), 0)
1429
- };
1430
- });
1431
- } };
1432
- }
1433
- });
1434
-
1435
- //#endregion
1436
- //#region src/node/rpc/functions/rolldown-get-session-summary.ts
1437
- const rolldownGetSessionSummary = defineRpcFunction({
1438
- name: "vite:rolldown:get-session-summary",
1439
- type: "query",
1440
- setup: async (context) => {
1441
- const manager = getLogsManager(context);
1442
- return { handler: async ({ session }) => {
1443
- const reader = await manager.loadSession(session);
1444
- return {
1445
- id: session,
1446
- meta: reader.meta,
1447
- build_duration: reader.manager.build_end_time - reader.manager.build_start_time,
1448
- modules: Array.from(reader.manager.modules.values()).sort((a, b) => a.id.localeCompare(b.id))
1449
- };
1450
- } };
1451
- }
1452
- });
1453
-
1454
- //#endregion
1455
- //#region src/node/rpc/functions/rolldown-list-sessions.ts
1456
- const rolldownListSessions = defineRpcFunction({
1457
- name: "vite:rolldown:list-sessions",
1458
- type: "query",
1459
- setup: (context) => {
1460
- const manager = getLogsManager(context);
1461
- return { handler: async () => {
1462
- return (await manager.list()).sort((a, b) => b.timestamp - a.timestamp);
1463
- } };
1464
- }
1465
- });
1466
-
1467
- //#endregion
1468
- //#region src/node/rpc/index.ts
1469
- const rpcFunctions = [
1470
- getPayload,
1471
- rolldownListSessions,
1472
- rolldownGetRawEvents,
1473
- rolldownGetSessionSummary,
1474
- rolldownGetModuleInfo,
1475
- rolldownGetModuleRawEvents,
1476
- rolldownGetModuleTransforms,
1477
- rolldownGetChunksGraph,
1478
- rolldownGetAssetsList,
1479
- rolldownGetAssetDetails,
1480
- rolldownGetPluginDetails,
1481
- rolldownGetSessionCompareSummary,
1482
- rolldownGetChunkInfo,
1483
- rolldownGetPackages,
1484
- rolldownGetPackageDetails
1485
- ];
1486
-
1487
- //#endregion
1488
- //#region src/node/plugin.ts
1489
- function DevToolsViteUI() {
1490
- return {
1491
- name: "vite:devtools:vite-ui",
1492
- devtools: { setup(ctx) {
1493
- console.log("Vite DevTools Vite plugin setup");
1494
- for (const fn of rpcFunctions) ctx.rpc.register(fn);
1495
- ctx.views.hostStatic("/.devtools-vite/", clientPublicDir);
1496
- ctx.docks.register({
1497
- id: "vite",
1498
- title: "Vite",
1499
- icon: "https://vite.dev/logo.svg",
1500
- type: "iframe",
1501
- url: "/.devtools-vite/"
1502
- });
1503
- } }
1504
- };
1505
- }
1506
-
1507
- //#endregion
1508
- export { DevToolsViteUI };