@vitejs/devtools-vite 0.0.0-alpha.2 → 0.0.0-alpha.21

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 (94) hide show
  1. package/dist/{dirs-Z7VQHyIZ.js → dirs-BzX7rGLP.mjs} +1 -1
  2. package/dist/dirs.mjs +3 -0
  3. package/dist/index.d.mts +499 -0
  4. package/dist/index.mjs +9607 -0
  5. package/dist/nitro.json +3 -3
  6. package/dist/public/200.html +1 -1
  7. package/dist/public/404.html +1 -1
  8. package/dist/public/_nuxt/B6cncnam.js +1 -0
  9. package/dist/public/_nuxt/BaYRDImg.js +1 -0
  10. package/dist/public/_nuxt/Bij65W5n.js +1 -0
  11. package/dist/public/_nuxt/Bja_t-aS.js +1 -0
  12. package/dist/public/_nuxt/BrNGuicP.js +1 -0
  13. package/dist/public/_nuxt/BwW8gZ6K.js +1 -0
  14. package/dist/public/_nuxt/C8YTjkYM.js +1 -0
  15. package/dist/public/_nuxt/CDPpT6Cf.js +1 -0
  16. package/dist/public/_nuxt/CE23KUMI.js +1 -0
  17. package/dist/public/_nuxt/{BdGMcGSQ.js → CEj_FX93.js} +1 -1
  18. package/dist/public/_nuxt/CNlvL5ez.js +1 -0
  19. package/dist/public/_nuxt/CPYYHqxX.js +1 -0
  20. package/dist/public/_nuxt/CroQ9lcn.js +1 -0
  21. package/dist/public/_nuxt/Cu87lOT3.js +1 -0
  22. package/dist/public/_nuxt/D6yJLdbI.js +1 -0
  23. package/dist/public/_nuxt/DDRvb9yv.js +1 -0
  24. package/dist/public/_nuxt/DDTVi-ZV.js +33 -0
  25. package/dist/public/_nuxt/DHdbcQDR.js +1 -0
  26. package/dist/public/_nuxt/{DSjlpmm-.js → DJFg8Mze.js} +1 -1
  27. package/dist/public/_nuxt/DkNjWA7f.js +1 -0
  28. package/dist/public/_nuxt/DuSH8vtp.js +1 -0
  29. package/dist/public/_nuxt/{BQ-NBLhA.js → EZmie0b_.js} +1 -1
  30. package/dist/public/_nuxt/HyHtDydt.js +1 -0
  31. package/dist/public/_nuxt/L7giCKVM.js +1 -0
  32. package/dist/public/_nuxt/NkHXFX5A.js +1 -0
  33. package/dist/public/_nuxt/OEdZKRk6.js +1 -0
  34. package/dist/public/_nuxt/R6f4Y_SJ.js +1 -0
  35. package/dist/public/_nuxt/XY_il7uL.js +2 -0
  36. package/dist/public/_nuxt/{_session_.B0BbH92J.css → _session_.BXMlcDmB.css} +1 -1
  37. package/dist/public/_nuxt/builds/latest.json +1 -1
  38. package/dist/public/_nuxt/builds/meta/92f58f41-f5d8-4eb9-8df8-90c37ec07cf8.json +1 -0
  39. package/dist/public/_nuxt/diff.worker-CvsEE-qa.js +10 -0
  40. package/dist/public/_nuxt/entry.BVWKKagY.css +1 -0
  41. package/dist/public/_nuxt/error-404.DgDpC6Er.css +1 -0
  42. package/dist/public/_nuxt/error-500.CDOeHf8w.css +1 -0
  43. package/dist/public/_nuxt/jVJLbHmI.js +1 -0
  44. package/dist/public/_nuxt/kgaOZT0B.js +1 -0
  45. package/dist/public/_nuxt/mJg3pdS2.js +1 -0
  46. package/dist/public/_nuxt/s37iQDTO.js +1 -0
  47. package/dist/public/_nuxt/wlAuDjxN.js +4 -0
  48. package/dist/public/_nuxt/x1G1EAUP.js +1 -0
  49. package/dist/public/_nuxt/xtsFKyex.js +1 -0
  50. package/dist/public/index.html +1 -1
  51. package/package.json +25 -24
  52. package/dist/dirs.js +0 -3
  53. package/dist/index.d.ts +0 -118
  54. package/dist/index.js +0 -1465
  55. package/dist/public/_nuxt/B1Vd6rqS.js +0 -1
  56. package/dist/public/_nuxt/B2YLpys2.js +0 -1
  57. package/dist/public/_nuxt/B2fBtupD.js +0 -1
  58. package/dist/public/_nuxt/BBRXmiYk.js +0 -1
  59. package/dist/public/_nuxt/BL9XEsp7.js +0 -1
  60. package/dist/public/_nuxt/BO9hKuA-.js +0 -1
  61. package/dist/public/_nuxt/BcAccMwu.js +0 -1
  62. package/dist/public/_nuxt/BdSZoQls.js +0 -1
  63. package/dist/public/_nuxt/BjbaCuBE.js +0 -1
  64. package/dist/public/_nuxt/Bjr51Ks8.js +0 -1
  65. package/dist/public/_nuxt/BvuqupwD.js +0 -1
  66. package/dist/public/_nuxt/C2X_oPur.js +0 -1
  67. package/dist/public/_nuxt/C5J04JCq.js +0 -1
  68. package/dist/public/_nuxt/CQNn9qP2.js +0 -1
  69. package/dist/public/_nuxt/CS0-317H.js +0 -1
  70. package/dist/public/_nuxt/CciM0jEL.js +0 -1
  71. package/dist/public/_nuxt/CcwEApAr.js +0 -1
  72. package/dist/public/_nuxt/Ci9NHG69.js +0 -1
  73. package/dist/public/_nuxt/D1yk44lc.js +0 -1
  74. package/dist/public/_nuxt/DJTxkAFF.js +0 -11
  75. package/dist/public/_nuxt/DS2MKblJ.js +0 -1
  76. package/dist/public/_nuxt/DZeYNBxL.js +0 -1
  77. package/dist/public/_nuxt/D_Sk_I-u.js +0 -1
  78. package/dist/public/_nuxt/Dl8iHwQo.js +0 -2
  79. package/dist/public/_nuxt/IrMnfQaU.js +0 -1
  80. package/dist/public/_nuxt/Z5tyTJaP.js +0 -1
  81. package/dist/public/_nuxt/builds/meta/c3fb67dd-1302-42f7-af58-b6ed5d47dbe9.json +0 -1
  82. package/dist/public/_nuxt/cRQbgMUp.js +0 -1
  83. package/dist/public/_nuxt/diff.worker-BXxwMoGc.js +0 -10
  84. package/dist/public/_nuxt/entry.BiqpDmeM.css +0 -1
  85. package/dist/public/_nuxt/error-404.yUUAZDjV.css +0 -1
  86. package/dist/public/_nuxt/error-500.BHZzZRS-.css +0 -1
  87. package/dist/public/_nuxt/pXptjyzi.js +0 -1
  88. package/dist/public/_nuxt/rwBDQBzn.js +0 -1
  89. package/dist/public/_nuxt/tS5wJZMm.js +0 -1
  90. package/dist/public/_nuxt/yfNgynAH.js +0 -33
  91. package/dist/public/_nuxt/z9pSC1xM.js +0 -1
  92. /package/dist/{dirs.d.ts → dirs.d.mts} +0 -0
  93. /package/dist/public/_nuxt/{DnpfwSMy.js → Cvg1SSG2.js} +0 -0
  94. /package/dist/public/_nuxt/{l47FwQA-.js → jB8TYliU.js} +0 -0
package/dist/index.js DELETED
@@ -1,1465 +0,0 @@
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
- if (!existsSync(this.dir)) return [];
1002
- const sessions = await fs$1.readdir(this.dir, { withFileTypes: true });
1003
- return await Promise.all(sessions.filter((d) => d.isDirectory()).map(async (d) => {
1004
- const reader = RolldownEventsReader.get(join(this.dir, d.name, "meta.json"));
1005
- await reader.read();
1006
- const meta = reader.manager.events[reader.manager.events.length - 1];
1007
- return {
1008
- id: d.name,
1009
- timestamp: meta.timestamp,
1010
- meta
1011
- };
1012
- }));
1013
- }
1014
- async loadSession(session) {
1015
- const reader = RolldownEventsReader.get(join(this.dir, session, "logs.json"));
1016
- await reader.read();
1017
- if (!reader.meta) {
1018
- const metaReader = RolldownEventsReader.get(join(this.dir, session, "meta.json"));
1019
- await metaReader.read();
1020
- reader.meta = metaReader.manager.events.at(-1);
1021
- }
1022
- return reader;
1023
- }
1024
- };
1025
-
1026
- //#endregion
1027
- //#region src/node/rpc/utils.ts
1028
- const weakMap = /* @__PURE__ */ new WeakMap();
1029
- function getLogsManager(context) {
1030
- let manager = weakMap.get(context);
1031
- if (!manager) {
1032
- const dirs = [join(context.cwd, ".rolldown"), join(process.cwd(), ".rolldown")];
1033
- const dir = dirs.find((dir$1) => existsSync(dir$1));
1034
- if (!dir) console.warn("[Vite DevTools] Rolldown logs directory `.rolldown` not found, you might want to run build with `build.rolldownOptions.debug` enabled first.");
1035
- manager = new RolldownLogsManager(dir ?? dirs[0]);
1036
- }
1037
- return manager;
1038
- }
1039
-
1040
- //#endregion
1041
- //#region src/node/rpc/functions/rolldown-get-asset-details.ts
1042
- const rolldownGetAssetDetails = defineRpcFunction({
1043
- name: "vite:rolldown:get-asset-details",
1044
- type: "query",
1045
- setup: (context) => {
1046
- const manager = getLogsManager(context);
1047
- return { handler: async ({ session, id }) => {
1048
- const reader = await manager.loadSession(session);
1049
- const assets = reader.manager.assets;
1050
- const chunks = reader.manager.chunks;
1051
- const asset = assets.get(id);
1052
- const assetList = Array.from(assets.values());
1053
- const chunkList = Array.from(chunks.values());
1054
- if (asset.chunk_id === null) return { asset };
1055
- const assetChunkId = asset.chunk_id;
1056
- const chunk = chunks.get(assetChunkId);
1057
- const importers = chunkList.filter((mod) => mod.imports.some((i) => i.chunk_id === assetChunkId)).map((c) => assetList.find((a) => a.chunk_id === c.chunk_id));
1058
- const imports = chunk.imports.map((c) => assetList.find((a) => a.chunk_id === c.chunk_id));
1059
- return {
1060
- asset,
1061
- chunk,
1062
- importers,
1063
- imports
1064
- };
1065
- } };
1066
- }
1067
- });
1068
-
1069
- //#endregion
1070
- //#region src/node/rpc/functions/rolldown-get-assets-list.ts
1071
- const rolldownGetAssetsList = defineRpcFunction({
1072
- name: "vite:rolldown:get-assets-list",
1073
- type: "query",
1074
- setup: (context) => {
1075
- const manager = getLogsManager(context);
1076
- return { handler: async ({ session }) => {
1077
- const reader = await manager.loadSession(session);
1078
- return Array.from(reader.manager.assets.values());
1079
- } };
1080
- }
1081
- });
1082
-
1083
- //#endregion
1084
- //#region src/node/rpc/functions/rolldown-get-chunk-info.ts
1085
- const rolldownGetChunkInfo = defineRpcFunction({
1086
- name: "vite:rolldown:get-chunk-info",
1087
- type: "query",
1088
- setup: (context) => {
1089
- const manager = getLogsManager(context);
1090
- return { handler: async ({ session, id }) => {
1091
- return (await manager.loadSession(session)).manager.chunks.get(id);
1092
- } };
1093
- }
1094
- });
1095
-
1096
- //#endregion
1097
- //#region src/node/rpc/functions/rolldown-get-chunks-graph.ts
1098
- const rolldownGetChunksGraph = defineRpcFunction({
1099
- name: "vite:rolldown:get-chunks-graph",
1100
- type: "query",
1101
- setup: (context) => {
1102
- const manager = getLogsManager(context);
1103
- return { handler: async ({ session }) => {
1104
- const reader = await manager.loadSession(session);
1105
- return Array.from(reader.manager.chunks.values());
1106
- } };
1107
- }
1108
- });
1109
-
1110
- //#endregion
1111
- //#region src/node/rpc/functions/rolldown-get-module-info.ts
1112
- const rolldownGetModuleInfo = defineRpcFunction({
1113
- name: "vite:rolldown:get-module-info",
1114
- type: "query",
1115
- setup: (context) => {
1116
- const manager = getLogsManager(context);
1117
- return { handler: async ({ session, module: module$1 }) => {
1118
- const reader = await manager.loadSession(session);
1119
- if (!reader.manager.events.length) return null;
1120
- const moduleInfo = reader.manager.modules.get(module$1);
1121
- const info = {
1122
- id: module$1,
1123
- imports: [],
1124
- importers: [],
1125
- chunks: [],
1126
- assets: [],
1127
- build_metrics: {
1128
- resolve_ids: [],
1129
- loads: [],
1130
- transforms: []
1131
- },
1132
- ...moduleInfo || {},
1133
- loads: moduleInfo?.build_metrics?.loads ?? [],
1134
- resolve_ids: moduleInfo?.build_metrics?.resolve_ids ?? []
1135
- };
1136
- info.chunks = Array.from(reader.manager.chunks.values()).filter((chunk) => chunk.modules.includes(module$1)).map((chunk) => ({
1137
- type: "chunk",
1138
- ...chunk
1139
- }));
1140
- info.assets = Array.from(reader.manager.assets.values()).filter((asset) => info.chunks.some((chunk) => chunk.chunk_id === asset.chunk_id)).map((asset) => ({
1141
- type: "asset",
1142
- ...asset
1143
- }));
1144
- info.loads.sort((a, b) => a.plugin_id - b.plugin_id);
1145
- info.resolve_ids.sort((a, b) => a.plugin_id - b.plugin_id);
1146
- return info;
1147
- } };
1148
- }
1149
- });
1150
-
1151
- //#endregion
1152
- //#region src/node/rpc/functions/rolldown-get-module-raw-events.ts
1153
- const rolldownGetModuleRawEvents = defineRpcFunction({
1154
- name: "vite:rolldown:get-module-raw-events",
1155
- type: "query",
1156
- setup: (context) => {
1157
- const manager = getLogsManager(context);
1158
- return { handler: async ({ session, module: module$1 }) => {
1159
- return { events: (await manager.loadSession(session)).manager.events.filter((event) => "module_id" in event && event.module_id !== module$1) };
1160
- } };
1161
- }
1162
- });
1163
-
1164
- //#endregion
1165
- //#region src/node/rpc/functions/rolldown-get-module-transforms.ts
1166
- const rolldownGetModuleTransforms = defineRpcFunction({
1167
- name: "vite:rolldown:get-module-transforms",
1168
- type: "query",
1169
- setup: (context) => {
1170
- const manager = getLogsManager(context);
1171
- return { handler: async ({ session, module: module$1 }) => {
1172
- const reader = await manager.loadSession(session);
1173
- const events = reader.manager.events;
1174
- const transforms = reader.manager.modules.get(module$1)?.build_metrics?.transforms ?? [];
1175
- if (!events.length) return transforms.map((transform) => ({
1176
- ...transform,
1177
- diff_added: 0,
1178
- diff_removed: 0
1179
- }));
1180
- return transforms.map((transform) => {
1181
- let diff_added = 0;
1182
- let diff_removed = 0;
1183
- if (transform.content_from !== transform.content_to && transform.content_from != null && transform.content_to != null) {
1184
- const delta = diffLines(transform.content_from, transform.content_to);
1185
- diff_added = delta.filter((d) => d.added).map((d) => d.value).join("").split(/\n/g).length;
1186
- diff_removed = delta.filter((d) => d.removed).map((d) => d.value).join("").split(/\n/g).length;
1187
- }
1188
- return {
1189
- ...transform,
1190
- diff_added,
1191
- diff_removed
1192
- };
1193
- }).sort((a, b) => a.plugin_id - b.plugin_id);
1194
- } };
1195
- }
1196
- });
1197
-
1198
- //#endregion
1199
- //#region src/shared/utils/filepath.ts
1200
- function isNodeModulePath(path) {
1201
- return !!path.match(/[/\\]node_modules[/\\]/) || isPackageName(path);
1202
- }
1203
- function isPackageName(name) {
1204
- return name[0] === "#" || !!name.match(/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/);
1205
- }
1206
- function getModuleNameFromPath(path) {
1207
- if (isPackageName(path)) return path;
1208
- const match = path.replace(/\\/g, "/").match(/.*\/node_modules\/(.*)$/)?.[1];
1209
- if (!match) return void 0;
1210
- if (match.startsWith("@")) return match.split("/").slice(0, 2).join("/");
1211
- return match.split("/")[0];
1212
- }
1213
- function getPackageDirPath(path) {
1214
- const nodeModulesPrefix = path.replace(/%2F/g, "/").replace(/\\/g, "/").match(/^(.+\/node_modules\/)/)?.[1];
1215
- const packageName = getModuleNameFromPath(path);
1216
- return nodeModulesPrefix + packageName;
1217
- }
1218
-
1219
- //#endregion
1220
- //#region src/node/rpc/functions/rolldown-get-packages.ts
1221
- const rolldownGetPackages = defineRpcFunction({
1222
- name: "vite:rolldown:get-packages",
1223
- type: "query",
1224
- setup: (context) => {
1225
- const manager = getLogsManager(context);
1226
- return { handler: async ({ session }) => {
1227
- const reader = await manager.loadSession(session);
1228
- const chunks = Array.from(reader.manager.chunks.values());
1229
- const modulesMap = reader.manager.modules;
1230
- const duplicatePackagesMap = /* @__PURE__ */ new Map();
1231
- const packagesManifest = /* @__PURE__ */ new Map();
1232
- const packages = chunks.map((chunk) => chunk.modules.map((module$1) => module$1)).flat().filter(isNodeModulePath).map((p) => {
1233
- const moduleBuildMetrics = modulesMap.get(p)?.build_metrics;
1234
- return {
1235
- path: p,
1236
- dir: getPackageDirPath(p),
1237
- transformedCodeSize: moduleBuildMetrics?.transforms[moduleBuildMetrics?.transforms.length - 1]?.transformed_code_size ?? 0
1238
- };
1239
- });
1240
- await Promise.all(packages.map(async (p) => {
1241
- const manifest = await readProjectManifestOnly(p.dir);
1242
- const packageKey = `${manifest.name}@${manifest.version}`;
1243
- const packageInfo = packagesManifest.get(packageKey);
1244
- const module$1 = modulesMap.get(p.path);
1245
- if (packageInfo) packagesManifest.set(packageKey, {
1246
- ...packageInfo,
1247
- files: [...packageInfo.files, {
1248
- path: p.path,
1249
- transformedCodeSize: p.transformedCodeSize,
1250
- importers: module$1?.importers?.map((i) => ({
1251
- path: i,
1252
- version: ""
1253
- })) ?? []
1254
- }],
1255
- transformedCodeSize: packageInfo.transformedCodeSize + p.transformedCodeSize
1256
- });
1257
- else packagesManifest.set(packageKey, {
1258
- name: manifest.name,
1259
- version: manifest.version,
1260
- dir: p.dir,
1261
- files: [{
1262
- path: p.path,
1263
- transformedCodeSize: p.transformedCodeSize,
1264
- importers: module$1?.importers?.map((i) => ({
1265
- path: i,
1266
- version: ""
1267
- })) ?? []
1268
- }],
1269
- transformedCodeSize: p.transformedCodeSize
1270
- });
1271
- }));
1272
- return (await Promise.all(Array.from(packagesManifest.values()).map((p) => {
1273
- duplicatePackagesMap.set(p.name, (duplicatePackagesMap.get(p.name) ?? 0) + 1);
1274
- return {
1275
- ...p,
1276
- type: p.files.some((f) => modulesMap.get(f.path)?.importers?.some((i) => i.includes(reader.meta.cwd))) ? "direct" : "transitive"
1277
- };
1278
- }).map(async (p) => {
1279
- const duplicated = duplicatePackagesMap.get(p.name) > 1;
1280
- let files = p.files;
1281
- if (duplicated) files = await Promise.all(files.map(async (f) => {
1282
- const importers = await Promise.all(f.importers.map(async (i) => {
1283
- const manifest = isNodeModulePath(i.path) ? await readProjectManifestOnly(getPackageDirPath(i.path)) : null;
1284
- return {
1285
- ...i,
1286
- version: manifest?.version ?? ""
1287
- };
1288
- }));
1289
- return {
1290
- ...f,
1291
- importers
1292
- };
1293
- }));
1294
- return {
1295
- ...p,
1296
- duplicated,
1297
- files
1298
- };
1299
- }))).filter((i) => !!i.transformedCodeSize);
1300
- } };
1301
- }
1302
- });
1303
-
1304
- //#endregion
1305
- //#region src/node/rpc/functions/rolldown-get-plugin-details.ts
1306
- const rolldownGetPluginDetails = defineRpcFunction({
1307
- name: "vite:rolldown:get-plugin-details",
1308
- type: "query",
1309
- setup: (context) => {
1310
- const manager = getLogsManager(context);
1311
- return { handler: async ({ session, id }) => {
1312
- const reader = await manager.loadSession(session);
1313
- const pluginBuildMetrics = reader.manager.plugin_build_metrics.get(+id);
1314
- if (!pluginBuildMetrics) return {
1315
- plugin_name: reader.meta.plugins.find((p) => p.plugin_id === +id)?.name,
1316
- plugin_id: +id,
1317
- calls: [],
1318
- loadMetrics: [],
1319
- resolveIdMetrics: [],
1320
- transformMetrics: []
1321
- };
1322
- const resolveIdMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "resolve");
1323
- const loadMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "load");
1324
- const transformMetrics = pluginBuildMetrics.calls.filter((c) => c.type === "transform");
1325
- return {
1326
- ...pluginBuildMetrics,
1327
- resolveIdMetrics,
1328
- loadMetrics,
1329
- transformMetrics
1330
- };
1331
- } };
1332
- }
1333
- });
1334
-
1335
- //#endregion
1336
- //#region src/node/rpc/functions/rolldown-get-raw-events.ts
1337
- const rolldownGetRawEvents = defineRpcFunction({
1338
- name: "vite:rolldown:get-raw-events",
1339
- type: "query",
1340
- setup: (context) => {
1341
- const manager = getLogsManager(context);
1342
- return { handler: async ({ session }) => {
1343
- return (await manager.loadSession(session)).manager.events;
1344
- } };
1345
- }
1346
- });
1347
-
1348
- //#endregion
1349
- //#region src/node/rpc/functions/rolldown-get-session-compare-summary.ts
1350
- const rolldownGetSessionCompareSummary = defineRpcFunction({
1351
- name: "vite:rolldown:get-session-compare-summary",
1352
- type: "query",
1353
- setup: async (context) => {
1354
- const manager = getLogsManager(context);
1355
- return { handler: async ({ sessions }) => {
1356
- const reader = await Promise.all(sessions.map((s) => manager.loadSession(s)));
1357
- return sessions.map((s, index) => {
1358
- const _reader = reader[index];
1359
- const assets = Array.from(_reader.manager.assets.values());
1360
- const chunks = Array.from(_reader.manager.chunks.values());
1361
- function getInitialChunkIds(chunkIds, visited = /* @__PURE__ */ new Set()) {
1362
- const initialChunkIds$1 = [];
1363
- for (const chunkId of chunkIds) {
1364
- if (visited.has(chunkId)) continue;
1365
- visited.add(chunkId);
1366
- const chunk = chunks.find((c) => c.chunk_id === chunkId);
1367
- if (chunk?.imports) {
1368
- const importChunkIds = chunk.imports.map((imp) => imp.chunk_id);
1369
- initialChunkIds$1.push(...importChunkIds);
1370
- const nestedImports = getInitialChunkIds(importChunkIds, visited);
1371
- initialChunkIds$1.push(...nestedImports);
1372
- }
1373
- }
1374
- return initialChunkIds$1;
1375
- }
1376
- const entryChunkIds = chunks.filter((chunk) => !!chunk.is_user_defined_entry).map((chunk) => chunk.chunk_id);
1377
- const initialChunkIds = [...new Set([...entryChunkIds, ...getInitialChunkIds(entryChunkIds)])];
1378
- return {
1379
- id: s,
1380
- meta: _reader.meta,
1381
- build_duration: _reader.manager.build_end_time - _reader.manager.build_start_time,
1382
- modules: Array.from(_reader.manager.modules.values()).length,
1383
- chunks: chunks.length,
1384
- assets: assets.length,
1385
- bundle_size: assets.reduce((acc, asset) => acc + asset.size, 0),
1386
- initial_js: initialChunkIds.reduce((acc, chunkId) => acc + (assets.find((asset) => asset.chunk_id === chunkId)?.size || 0), 0)
1387
- };
1388
- });
1389
- } };
1390
- }
1391
- });
1392
-
1393
- //#endregion
1394
- //#region src/node/rpc/functions/rolldown-get-session-summary.ts
1395
- const rolldownGetSessionSummary = defineRpcFunction({
1396
- name: "vite:rolldown:get-session-summary",
1397
- type: "query",
1398
- setup: async (context) => {
1399
- const manager = getLogsManager(context);
1400
- return { handler: async ({ session }) => {
1401
- const reader = await manager.loadSession(session);
1402
- return {
1403
- id: session,
1404
- meta: reader.meta,
1405
- build_duration: reader.manager.build_end_time - reader.manager.build_start_time,
1406
- modules: Array.from(reader.manager.modules.values()).sort((a, b) => a.id.localeCompare(b.id))
1407
- };
1408
- } };
1409
- }
1410
- });
1411
-
1412
- //#endregion
1413
- //#region src/node/rpc/functions/rolldown-list-sessions.ts
1414
- const rolldownListSessions = defineRpcFunction({
1415
- name: "vite:rolldown:list-sessions",
1416
- type: "query",
1417
- setup: (context) => {
1418
- const manager = getLogsManager(context);
1419
- return { handler: async () => {
1420
- return (await manager.list()).sort((a, b) => b.timestamp - a.timestamp);
1421
- } };
1422
- }
1423
- });
1424
-
1425
- //#endregion
1426
- //#region src/node/rpc/index.ts
1427
- const rpcFunctions = [
1428
- getPayload,
1429
- rolldownListSessions,
1430
- rolldownGetRawEvents,
1431
- rolldownGetSessionSummary,
1432
- rolldownGetModuleInfo,
1433
- rolldownGetModuleRawEvents,
1434
- rolldownGetModuleTransforms,
1435
- rolldownGetChunksGraph,
1436
- rolldownGetAssetsList,
1437
- rolldownGetAssetDetails,
1438
- rolldownGetPluginDetails,
1439
- rolldownGetSessionCompareSummary,
1440
- rolldownGetChunkInfo,
1441
- rolldownGetPackages
1442
- ];
1443
-
1444
- //#endregion
1445
- //#region src/node/plugin.ts
1446
- function DevToolsViteUI() {
1447
- return {
1448
- name: "vite:devtools:vite-ui",
1449
- devtools: { setup(ctx) {
1450
- console.log("Vite DevTools Vite plugin setup");
1451
- for (const fn of rpcFunctions) ctx.rpc.register(fn);
1452
- ctx.hostStatic("/__vite_devtools_vite__/", clientPublicDir);
1453
- ctx.docks.register({
1454
- id: "vite",
1455
- title: "Vite",
1456
- icon: "https://vite.dev/logo.svg",
1457
- type: "iframe",
1458
- url: "/__vite_devtools_vite__/"
1459
- });
1460
- } }
1461
- };
1462
- }
1463
-
1464
- //#endregion
1465
- export { DevToolsViteUI };