@vitejs/devtools 0.0.0-alpha.0 → 0.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{bin.mjs → bin.js} +1 -1
- package/dist/cli.js +83 -0
- package/dist/client/inject.d.ts +4 -0
- package/dist/client/inject.js +33 -0
- package/dist/client/standalone/assets/index-7RajWZLR.css +1 -0
- package/dist/client/standalone/assets/index-BZuCeFpb.js +7 -0
- package/dist/client/standalone/index.html +14 -0
- package/dist/client/webcomponents.d.ts +45 -0
- package/dist/client/webcomponents.js +796 -0
- package/dist/core-uTAXYiA1.js +6650 -0
- package/dist/dirs-B7dOX6eI.js +9 -0
- package/dist/dirs.d.ts +5 -0
- package/dist/dirs.js +3 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +57 -0
- package/dist/server-B_q0HJ88.js +1262 -0
- package/package.json +49 -56
- package/dist/cli-CkEkRmBL.mjs +0 -176
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -3
- package/dist/dirs-6LDFDMFM.mjs +0 -7
- package/dist/dirs.d.mts +0 -4
- package/dist/dirs.mjs +0 -3
- package/dist/functions-CKJw6Oxo.mjs +0 -1066
- package/dist/functions-peYM_6iz.mjs +0 -3
- package/dist/index.d.mts +0 -13
- package/dist/index.mjs +0 -7
- package/dist/nitro.json +0 -15
- package/dist/node/cli.d.mts +0 -1
- package/dist/node/cli.mjs +0 -3
- package/dist/public/200.html +0 -25
- package/dist/public/404.html +0 -25
- package/dist/public/_nuxt/B0gvptKi.js +0 -1
- package/dist/public/_nuxt/B1XPhBbs.js +0 -4
- package/dist/public/_nuxt/B4YzJ31L.js +0 -1
- package/dist/public/_nuxt/BHxVjsIi.js +0 -1
- package/dist/public/_nuxt/BKXf1uMu.js +0 -1
- package/dist/public/_nuxt/BKZ3jkBI.js +0 -1
- package/dist/public/_nuxt/Bnn-hxaI.js +0 -1
- package/dist/public/_nuxt/BrR0v-Bn.js +0 -1
- package/dist/public/_nuxt/BuzEimhA.js +0 -33
- package/dist/public/_nuxt/C4K5k6WM.js +0 -1
- package/dist/public/_nuxt/COxwzm_n.js +0 -12
- package/dist/public/_nuxt/CaCHQCx7.js +0 -1
- package/dist/public/_nuxt/CcGHFnjf.js +0 -1
- package/dist/public/_nuxt/CmTKMvEX.js +0 -1
- package/dist/public/_nuxt/CwDtpcut.js +0 -1
- package/dist/public/_nuxt/DKLzMrv9.js +0 -1
- package/dist/public/_nuxt/I6F6kbCC.js +0 -1
- package/dist/public/_nuxt/WiKH-0vv.js +0 -1
- package/dist/public/_nuxt/YnXJxoTD.js +0 -1
- package/dist/public/_nuxt/builds/latest.json +0 -1
- package/dist/public/_nuxt/builds/meta/4e2f12bf-362f-48e3-9beb-2b83e6e986dc.json +0 -1
- package/dist/public/_nuxt/diff.worker-394KunD7.js +0 -4
- package/dist/public/_nuxt/entry.DadeTU15.css +0 -1
- package/dist/public/_nuxt/error-404.RpxUbdEP.css +0 -1
- package/dist/public/_nuxt/error-500.tfCn4Lmz.css +0 -1
- package/dist/public/_nuxt/flow.CT0fChr5.css +0 -1
- package/dist/public/_nuxt/kgs9XIg8.js +0 -1
- package/dist/public/dot-grid-dark.png +0 -0
- package/dist/public/dot-grid-light.png +0 -0
- package/dist/public/fonts/dmmono-612bc94f.woff2 +0 -0
- package/dist/public/fonts/dmmono-cbe07c46.woff2 +0 -0
- package/dist/public/fonts/dmsans-b28079ff.woff2 +0 -0
- package/dist/public/fonts/dmsans-b4f1d45c.woff2 +0 -0
- package/dist/public/index.html +0 -25
- /package/{LICENSE.md → LICENSE} +0 -0
- /package/dist/{cli-C3YoliaZ.d.mts → cli.d.ts} +0 -0
|
@@ -1,1066 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import fs$1 from "node:fs/promises";
|
|
4
|
-
import { join } from "pathe";
|
|
5
|
-
import { diffLines } from "diff";
|
|
6
|
-
|
|
7
|
-
//#region rolldown:runtime
|
|
8
|
-
var __create = Object.create;
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __commonJS = (cb, mod) => function() {
|
|
15
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
-
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
-
key = keys[i];
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
-
get: ((k) => from[k]).bind(null, key),
|
|
22
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/node/rpc/utils.ts
|
|
35
|
-
function defineRpcFunction(definition) {
|
|
36
|
-
return definition;
|
|
37
|
-
}
|
|
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 src/node/rpc/functions/open-in-editor.ts
|
|
51
|
-
const openInEditor = defineRpcFunction({
|
|
52
|
-
name: "vite:open-in-editor",
|
|
53
|
-
type: "action",
|
|
54
|
-
setup: () => ({ handler: async (path) => {
|
|
55
|
-
await import("launch-editor").then((r) => r.default(path));
|
|
56
|
-
} })
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/node/rpc/functions/open-in-finder.ts
|
|
61
|
-
const openInFinder = defineRpcFunction({
|
|
62
|
-
name: "vite:open-in-finder",
|
|
63
|
-
type: "action",
|
|
64
|
-
setup: () => ({ handler: async (path) => {
|
|
65
|
-
await import("open").then((r) => r.default(path));
|
|
66
|
-
} })
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/Utf8Stream.js
|
|
71
|
-
var require_Utf8Stream = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/Utf8Stream.js"(exports, module) {
|
|
72
|
-
const { Transform } = __require("stream");
|
|
73
|
-
const { StringDecoder } = __require("string_decoder");
|
|
74
|
-
var Utf8Stream$1 = class extends Transform {
|
|
75
|
-
constructor(options) {
|
|
76
|
-
super(Object.assign({}, options, { writableObjectMode: false }));
|
|
77
|
-
this._buffer = "";
|
|
78
|
-
}
|
|
79
|
-
_transform(chunk, encoding, callback) {
|
|
80
|
-
if (typeof chunk == "string") this._transform = this._transformString;
|
|
81
|
-
else {
|
|
82
|
-
this._stringDecoder = new StringDecoder();
|
|
83
|
-
this._transform = this._transformBuffer;
|
|
84
|
-
}
|
|
85
|
-
this._transform(chunk, encoding, callback);
|
|
86
|
-
}
|
|
87
|
-
_transformBuffer(chunk, _, callback) {
|
|
88
|
-
this._buffer += this._stringDecoder.write(chunk);
|
|
89
|
-
this._processBuffer(callback);
|
|
90
|
-
}
|
|
91
|
-
_transformString(chunk, _, callback) {
|
|
92
|
-
this._buffer += chunk.toString();
|
|
93
|
-
this._processBuffer(callback);
|
|
94
|
-
}
|
|
95
|
-
_processBuffer(callback) {
|
|
96
|
-
if (this._buffer) {
|
|
97
|
-
this.push(this._buffer, "utf8");
|
|
98
|
-
this._buffer = "";
|
|
99
|
-
}
|
|
100
|
-
callback(null);
|
|
101
|
-
}
|
|
102
|
-
_flushInput() {
|
|
103
|
-
if (this._stringDecoder) this._buffer += this._stringDecoder.end();
|
|
104
|
-
}
|
|
105
|
-
_flush(callback) {
|
|
106
|
-
this._flushInput();
|
|
107
|
-
this._processBuffer(callback);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
module.exports = Utf8Stream$1;
|
|
111
|
-
} });
|
|
112
|
-
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Parser.js
|
|
115
|
-
var require_Parser = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Parser.js"(exports, module) {
|
|
116
|
-
const Utf8Stream = require_Utf8Stream();
|
|
117
|
-
const patterns = {
|
|
118
|
-
value1: /^(?:[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256})/,
|
|
119
|
-
string: /^(?:[^\x00-\x1f\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\")/,
|
|
120
|
-
key1: /^(?:[\"\}]|\s{1,256})/,
|
|
121
|
-
colon: /^(?:\:|\s{1,256})/,
|
|
122
|
-
comma: /^(?:[\,\]\}]|\s{1,256})/,
|
|
123
|
-
ws: /^\s{1,256}/,
|
|
124
|
-
numberStart: /^\d/,
|
|
125
|
-
numberDigit: /^\d{0,256}/,
|
|
126
|
-
numberFraction: /^[\.eE]/,
|
|
127
|
-
numberExponent: /^[eE]/,
|
|
128
|
-
numberExpSign: /^[-+]/
|
|
129
|
-
};
|
|
130
|
-
const MAX_PATTERN_SIZE = 16;
|
|
131
|
-
let noSticky = true;
|
|
132
|
-
try {
|
|
133
|
-
new RegExp(".", "y");
|
|
134
|
-
noSticky = false;
|
|
135
|
-
} catch (e) {}
|
|
136
|
-
!noSticky && Object.keys(patterns).forEach((key) => {
|
|
137
|
-
let src = patterns[key].source.slice(1);
|
|
138
|
-
if (src.slice(0, 3) === "(?:" && src.slice(-1) === ")") src = src.slice(3, -1);
|
|
139
|
-
patterns[key] = new RegExp(src, "y");
|
|
140
|
-
});
|
|
141
|
-
patterns.numberFracStart = patterns.numberExpStart = patterns.numberStart;
|
|
142
|
-
patterns.numberFracDigit = patterns.numberExpDigit = patterns.numberDigit;
|
|
143
|
-
const values = {
|
|
144
|
-
true: true,
|
|
145
|
-
false: false,
|
|
146
|
-
null: null
|
|
147
|
-
}, expected = {
|
|
148
|
-
object: "objectStop",
|
|
149
|
-
array: "arrayStop",
|
|
150
|
-
"": "done"
|
|
151
|
-
};
|
|
152
|
-
const fromHex = (s) => String.fromCharCode(parseInt(s.slice(2), 16));
|
|
153
|
-
const codes = {
|
|
154
|
-
b: "\b",
|
|
155
|
-
f: "\f",
|
|
156
|
-
n: "\n",
|
|
157
|
-
r: "\r",
|
|
158
|
-
t: " ",
|
|
159
|
-
"\"": "\"",
|
|
160
|
-
"\\": "\\",
|
|
161
|
-
"/": "/"
|
|
162
|
-
};
|
|
163
|
-
var Parser$1 = class Parser$1 extends Utf8Stream {
|
|
164
|
-
static make(options) {
|
|
165
|
-
return new Parser$1(options);
|
|
166
|
-
}
|
|
167
|
-
constructor(options) {
|
|
168
|
-
super(Object.assign({}, options, { readableObjectMode: true }));
|
|
169
|
-
this._packKeys = this._packStrings = this._packNumbers = this._streamKeys = this._streamStrings = this._streamNumbers = true;
|
|
170
|
-
if (options) {
|
|
171
|
-
"packValues" in options && (this._packKeys = this._packStrings = this._packNumbers = options.packValues);
|
|
172
|
-
"packKeys" in options && (this._packKeys = options.packKeys);
|
|
173
|
-
"packStrings" in options && (this._packStrings = options.packStrings);
|
|
174
|
-
"packNumbers" in options && (this._packNumbers = options.packNumbers);
|
|
175
|
-
"streamValues" in options && (this._streamKeys = this._streamStrings = this._streamNumbers = options.streamValues);
|
|
176
|
-
"streamKeys" in options && (this._streamKeys = options.streamKeys);
|
|
177
|
-
"streamStrings" in options && (this._streamStrings = options.streamStrings);
|
|
178
|
-
"streamNumbers" in options && (this._streamNumbers = options.streamNumbers);
|
|
179
|
-
this._jsonStreaming = options.jsonStreaming;
|
|
180
|
-
}
|
|
181
|
-
!this._packKeys && (this._streamKeys = true);
|
|
182
|
-
!this._packStrings && (this._streamStrings = true);
|
|
183
|
-
!this._packNumbers && (this._streamNumbers = true);
|
|
184
|
-
this._done = false;
|
|
185
|
-
this._expect = this._jsonStreaming ? "done" : "value";
|
|
186
|
-
this._stack = [];
|
|
187
|
-
this._parent = "";
|
|
188
|
-
this._open_number = false;
|
|
189
|
-
this._accumulator = "";
|
|
190
|
-
}
|
|
191
|
-
_flush(callback) {
|
|
192
|
-
this._done = true;
|
|
193
|
-
super._flush((error) => {
|
|
194
|
-
if (error) return callback(error);
|
|
195
|
-
if (this._open_number) {
|
|
196
|
-
if (this._streamNumbers) this.push({ name: "endNumber" });
|
|
197
|
-
this._open_number = false;
|
|
198
|
-
if (this._packNumbers) {
|
|
199
|
-
this.push({
|
|
200
|
-
name: "numberValue",
|
|
201
|
-
value: this._accumulator
|
|
202
|
-
});
|
|
203
|
-
this._accumulator = "";
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
callback(null);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
_processBuffer(callback) {
|
|
210
|
-
let match, value, index = 0;
|
|
211
|
-
main: for (;;) switch (this._expect) {
|
|
212
|
-
case "value1":
|
|
213
|
-
case "value":
|
|
214
|
-
patterns.value1.lastIndex = index;
|
|
215
|
-
match = patterns.value1.exec(this._buffer);
|
|
216
|
-
if (!match) {
|
|
217
|
-
if (this._done || index + MAX_PATTERN_SIZE < this._buffer.length) {
|
|
218
|
-
if (index < this._buffer.length) return callback(new Error("Parser cannot parse input: expected a value"));
|
|
219
|
-
return callback(new Error("Parser has expected a value"));
|
|
220
|
-
}
|
|
221
|
-
break main;
|
|
222
|
-
}
|
|
223
|
-
value = match[0];
|
|
224
|
-
switch (value) {
|
|
225
|
-
case "\"":
|
|
226
|
-
this._streamStrings && this.push({ name: "startString" });
|
|
227
|
-
this._expect = "string";
|
|
228
|
-
break;
|
|
229
|
-
case "{":
|
|
230
|
-
this.push({ name: "startObject" });
|
|
231
|
-
this._stack.push(this._parent);
|
|
232
|
-
this._parent = "object";
|
|
233
|
-
this._expect = "key1";
|
|
234
|
-
break;
|
|
235
|
-
case "[":
|
|
236
|
-
this.push({ name: "startArray" });
|
|
237
|
-
this._stack.push(this._parent);
|
|
238
|
-
this._parent = "array";
|
|
239
|
-
this._expect = "value1";
|
|
240
|
-
break;
|
|
241
|
-
case "]":
|
|
242
|
-
if (this._expect !== "value1") return callback(new Error("Parser cannot parse input: unexpected token ']'"));
|
|
243
|
-
if (this._open_number) {
|
|
244
|
-
this._streamNumbers && this.push({ name: "endNumber" });
|
|
245
|
-
this._open_number = false;
|
|
246
|
-
if (this._packNumbers) {
|
|
247
|
-
this.push({
|
|
248
|
-
name: "numberValue",
|
|
249
|
-
value: this._accumulator
|
|
250
|
-
});
|
|
251
|
-
this._accumulator = "";
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
this.push({ name: "endArray" });
|
|
255
|
-
this._parent = this._stack.pop();
|
|
256
|
-
this._expect = expected[this._parent];
|
|
257
|
-
break;
|
|
258
|
-
case "-":
|
|
259
|
-
this._open_number = true;
|
|
260
|
-
if (this._streamNumbers) {
|
|
261
|
-
this.push({ name: "startNumber" });
|
|
262
|
-
this.push({
|
|
263
|
-
name: "numberChunk",
|
|
264
|
-
value: "-"
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
this._packNumbers && (this._accumulator = "-");
|
|
268
|
-
this._expect = "numberStart";
|
|
269
|
-
break;
|
|
270
|
-
case "0":
|
|
271
|
-
this._open_number = true;
|
|
272
|
-
if (this._streamNumbers) {
|
|
273
|
-
this.push({ name: "startNumber" });
|
|
274
|
-
this.push({
|
|
275
|
-
name: "numberChunk",
|
|
276
|
-
value: "0"
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
this._packNumbers && (this._accumulator = "0");
|
|
280
|
-
this._expect = "numberFraction";
|
|
281
|
-
break;
|
|
282
|
-
case "1":
|
|
283
|
-
case "2":
|
|
284
|
-
case "3":
|
|
285
|
-
case "4":
|
|
286
|
-
case "5":
|
|
287
|
-
case "6":
|
|
288
|
-
case "7":
|
|
289
|
-
case "8":
|
|
290
|
-
case "9":
|
|
291
|
-
this._open_number = true;
|
|
292
|
-
if (this._streamNumbers) {
|
|
293
|
-
this.push({ name: "startNumber" });
|
|
294
|
-
this.push({
|
|
295
|
-
name: "numberChunk",
|
|
296
|
-
value
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
this._packNumbers && (this._accumulator = value);
|
|
300
|
-
this._expect = "numberDigit";
|
|
301
|
-
break;
|
|
302
|
-
case "true":
|
|
303
|
-
case "false":
|
|
304
|
-
case "null":
|
|
305
|
-
if (this._buffer.length - index === value.length && !this._done) break main;
|
|
306
|
-
this.push({
|
|
307
|
-
name: value + "Value",
|
|
308
|
-
value: values[value]
|
|
309
|
-
});
|
|
310
|
-
this._expect = expected[this._parent];
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
314
|
-
else index += value.length;
|
|
315
|
-
break;
|
|
316
|
-
case "keyVal":
|
|
317
|
-
case "string":
|
|
318
|
-
patterns.string.lastIndex = index;
|
|
319
|
-
match = patterns.string.exec(this._buffer);
|
|
320
|
-
if (!match) {
|
|
321
|
-
if (index < this._buffer.length && (this._done || this._buffer.length - index >= 6)) return callback(new Error("Parser cannot parse input: escaped characters"));
|
|
322
|
-
if (this._done) return callback(new Error("Parser has expected a string value"));
|
|
323
|
-
break main;
|
|
324
|
-
}
|
|
325
|
-
value = match[0];
|
|
326
|
-
if (value === "\"") if (this._expect === "keyVal") {
|
|
327
|
-
this._streamKeys && this.push({ name: "endKey" });
|
|
328
|
-
if (this._packKeys) {
|
|
329
|
-
this.push({
|
|
330
|
-
name: "keyValue",
|
|
331
|
-
value: this._accumulator
|
|
332
|
-
});
|
|
333
|
-
this._accumulator = "";
|
|
334
|
-
}
|
|
335
|
-
this._expect = "colon";
|
|
336
|
-
} else {
|
|
337
|
-
this._streamStrings && this.push({ name: "endString" });
|
|
338
|
-
if (this._packStrings) {
|
|
339
|
-
this.push({
|
|
340
|
-
name: "stringValue",
|
|
341
|
-
value: this._accumulator
|
|
342
|
-
});
|
|
343
|
-
this._accumulator = "";
|
|
344
|
-
}
|
|
345
|
-
this._expect = expected[this._parent];
|
|
346
|
-
}
|
|
347
|
-
else if (value.length > 1 && value.charAt(0) === "\\") {
|
|
348
|
-
const t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value);
|
|
349
|
-
if (this._expect === "keyVal" ? this._streamKeys : this._streamStrings) this.push({
|
|
350
|
-
name: "stringChunk",
|
|
351
|
-
value: t
|
|
352
|
-
});
|
|
353
|
-
if (this._expect === "keyVal" ? this._packKeys : this._packStrings) this._accumulator += t;
|
|
354
|
-
} else {
|
|
355
|
-
if (this._expect === "keyVal" ? this._streamKeys : this._streamStrings) this.push({
|
|
356
|
-
name: "stringChunk",
|
|
357
|
-
value
|
|
358
|
-
});
|
|
359
|
-
if (this._expect === "keyVal" ? this._packKeys : this._packStrings) this._accumulator += value;
|
|
360
|
-
}
|
|
361
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
362
|
-
else index += value.length;
|
|
363
|
-
break;
|
|
364
|
-
case "key1":
|
|
365
|
-
case "key":
|
|
366
|
-
patterns.key1.lastIndex = index;
|
|
367
|
-
match = patterns.key1.exec(this._buffer);
|
|
368
|
-
if (!match) {
|
|
369
|
-
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected an object key"));
|
|
370
|
-
break main;
|
|
371
|
-
}
|
|
372
|
-
value = match[0];
|
|
373
|
-
if (value === "\"") {
|
|
374
|
-
this._streamKeys && this.push({ name: "startKey" });
|
|
375
|
-
this._expect = "keyVal";
|
|
376
|
-
} else if (value === "}") {
|
|
377
|
-
if (this._expect !== "key1") return callback(new Error("Parser cannot parse input: unexpected token '}'"));
|
|
378
|
-
this.push({ name: "endObject" });
|
|
379
|
-
this._parent = this._stack.pop();
|
|
380
|
-
this._expect = expected[this._parent];
|
|
381
|
-
}
|
|
382
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
383
|
-
else index += value.length;
|
|
384
|
-
break;
|
|
385
|
-
case "colon":
|
|
386
|
-
patterns.colon.lastIndex = index;
|
|
387
|
-
match = patterns.colon.exec(this._buffer);
|
|
388
|
-
if (!match) {
|
|
389
|
-
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected ':'"));
|
|
390
|
-
break main;
|
|
391
|
-
}
|
|
392
|
-
value = match[0];
|
|
393
|
-
value === ":" && (this._expect = "value");
|
|
394
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
395
|
-
else index += value.length;
|
|
396
|
-
break;
|
|
397
|
-
case "arrayStop":
|
|
398
|
-
case "objectStop":
|
|
399
|
-
patterns.comma.lastIndex = index;
|
|
400
|
-
match = patterns.comma.exec(this._buffer);
|
|
401
|
-
if (!match) {
|
|
402
|
-
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected ','"));
|
|
403
|
-
break main;
|
|
404
|
-
}
|
|
405
|
-
if (this._open_number) {
|
|
406
|
-
this._streamNumbers && this.push({ name: "endNumber" });
|
|
407
|
-
this._open_number = false;
|
|
408
|
-
if (this._packNumbers) {
|
|
409
|
-
this.push({
|
|
410
|
-
name: "numberValue",
|
|
411
|
-
value: this._accumulator
|
|
412
|
-
});
|
|
413
|
-
this._accumulator = "";
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
value = match[0];
|
|
417
|
-
if (value === ",") this._expect = this._expect === "arrayStop" ? "value" : "key";
|
|
418
|
-
else if (value === "}" || value === "]") {
|
|
419
|
-
if (value === "}" ? this._expect === "arrayStop" : this._expect !== "arrayStop") return callback(new Error("Parser cannot parse input: expected '" + (this._expect === "arrayStop" ? "]" : "}") + "'"));
|
|
420
|
-
this.push({ name: value === "}" ? "endObject" : "endArray" });
|
|
421
|
-
this._parent = this._stack.pop();
|
|
422
|
-
this._expect = expected[this._parent];
|
|
423
|
-
}
|
|
424
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
425
|
-
else index += value.length;
|
|
426
|
-
break;
|
|
427
|
-
case "numberStart":
|
|
428
|
-
patterns.numberStart.lastIndex = index;
|
|
429
|
-
match = patterns.numberStart.exec(this._buffer);
|
|
430
|
-
if (!match) {
|
|
431
|
-
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected a starting digit"));
|
|
432
|
-
break main;
|
|
433
|
-
}
|
|
434
|
-
value = match[0];
|
|
435
|
-
this._streamNumbers && this.push({
|
|
436
|
-
name: "numberChunk",
|
|
437
|
-
value
|
|
438
|
-
});
|
|
439
|
-
this._packNumbers && (this._accumulator += value);
|
|
440
|
-
this._expect = value === "0" ? "numberFraction" : "numberDigit";
|
|
441
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
442
|
-
else index += value.length;
|
|
443
|
-
break;
|
|
444
|
-
case "numberDigit":
|
|
445
|
-
patterns.numberDigit.lastIndex = index;
|
|
446
|
-
match = patterns.numberDigit.exec(this._buffer);
|
|
447
|
-
if (!match) {
|
|
448
|
-
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected a digit"));
|
|
449
|
-
break main;
|
|
450
|
-
}
|
|
451
|
-
value = match[0];
|
|
452
|
-
if (value) {
|
|
453
|
-
this._streamNumbers && this.push({
|
|
454
|
-
name: "numberChunk",
|
|
455
|
-
value
|
|
456
|
-
});
|
|
457
|
-
this._packNumbers && (this._accumulator += value);
|
|
458
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
459
|
-
else index += value.length;
|
|
460
|
-
} else {
|
|
461
|
-
if (index < this._buffer.length) {
|
|
462
|
-
this._expect = "numberFraction";
|
|
463
|
-
break;
|
|
464
|
-
}
|
|
465
|
-
if (this._done) {
|
|
466
|
-
this._expect = expected[this._parent];
|
|
467
|
-
break;
|
|
468
|
-
}
|
|
469
|
-
break main;
|
|
470
|
-
}
|
|
471
|
-
break;
|
|
472
|
-
case "numberFraction":
|
|
473
|
-
patterns.numberFraction.lastIndex = index;
|
|
474
|
-
match = patterns.numberFraction.exec(this._buffer);
|
|
475
|
-
if (!match) {
|
|
476
|
-
if (index < this._buffer.length || this._done) {
|
|
477
|
-
this._expect = expected[this._parent];
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
break main;
|
|
481
|
-
}
|
|
482
|
-
value = match[0];
|
|
483
|
-
this._streamNumbers && this.push({
|
|
484
|
-
name: "numberChunk",
|
|
485
|
-
value
|
|
486
|
-
});
|
|
487
|
-
this._packNumbers && (this._accumulator += value);
|
|
488
|
-
this._expect = value === "." ? "numberFracStart" : "numberExpSign";
|
|
489
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
490
|
-
else index += value.length;
|
|
491
|
-
break;
|
|
492
|
-
case "numberFracStart":
|
|
493
|
-
patterns.numberFracStart.lastIndex = index;
|
|
494
|
-
match = patterns.numberFracStart.exec(this._buffer);
|
|
495
|
-
if (!match) {
|
|
496
|
-
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected a fractional part of a number"));
|
|
497
|
-
break main;
|
|
498
|
-
}
|
|
499
|
-
value = match[0];
|
|
500
|
-
this._streamNumbers && this.push({
|
|
501
|
-
name: "numberChunk",
|
|
502
|
-
value
|
|
503
|
-
});
|
|
504
|
-
this._packNumbers && (this._accumulator += value);
|
|
505
|
-
this._expect = "numberFracDigit";
|
|
506
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
507
|
-
else index += value.length;
|
|
508
|
-
break;
|
|
509
|
-
case "numberFracDigit":
|
|
510
|
-
patterns.numberFracDigit.lastIndex = index;
|
|
511
|
-
match = patterns.numberFracDigit.exec(this._buffer);
|
|
512
|
-
value = match[0];
|
|
513
|
-
if (value) {
|
|
514
|
-
this._streamNumbers && this.push({
|
|
515
|
-
name: "numberChunk",
|
|
516
|
-
value
|
|
517
|
-
});
|
|
518
|
-
this._packNumbers && (this._accumulator += value);
|
|
519
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
520
|
-
else index += value.length;
|
|
521
|
-
} else {
|
|
522
|
-
if (index < this._buffer.length) {
|
|
523
|
-
this._expect = "numberExponent";
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
if (this._done) {
|
|
527
|
-
this._expect = expected[this._parent];
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
break main;
|
|
531
|
-
}
|
|
532
|
-
break;
|
|
533
|
-
case "numberExponent":
|
|
534
|
-
patterns.numberExponent.lastIndex = index;
|
|
535
|
-
match = patterns.numberExponent.exec(this._buffer);
|
|
536
|
-
if (!match) {
|
|
537
|
-
if (index < this._buffer.length) {
|
|
538
|
-
this._expect = expected[this._parent];
|
|
539
|
-
break;
|
|
540
|
-
}
|
|
541
|
-
if (this._done) {
|
|
542
|
-
this._expect = "done";
|
|
543
|
-
break;
|
|
544
|
-
}
|
|
545
|
-
break main;
|
|
546
|
-
}
|
|
547
|
-
value = match[0];
|
|
548
|
-
this._streamNumbers && this.push({
|
|
549
|
-
name: "numberChunk",
|
|
550
|
-
value
|
|
551
|
-
});
|
|
552
|
-
this._packNumbers && (this._accumulator += value);
|
|
553
|
-
this._expect = "numberExpSign";
|
|
554
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
555
|
-
else index += value.length;
|
|
556
|
-
break;
|
|
557
|
-
case "numberExpSign":
|
|
558
|
-
patterns.numberExpSign.lastIndex = index;
|
|
559
|
-
match = patterns.numberExpSign.exec(this._buffer);
|
|
560
|
-
if (!match) {
|
|
561
|
-
if (index < this._buffer.length) {
|
|
562
|
-
this._expect = "numberExpStart";
|
|
563
|
-
break;
|
|
564
|
-
}
|
|
565
|
-
if (this._done) return callback(new Error("Parser has expected an exponent value of a number"));
|
|
566
|
-
break main;
|
|
567
|
-
}
|
|
568
|
-
value = match[0];
|
|
569
|
-
this._streamNumbers && this.push({
|
|
570
|
-
name: "numberChunk",
|
|
571
|
-
value
|
|
572
|
-
});
|
|
573
|
-
this._packNumbers && (this._accumulator += value);
|
|
574
|
-
this._expect = "numberExpStart";
|
|
575
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
576
|
-
else index += value.length;
|
|
577
|
-
break;
|
|
578
|
-
case "numberExpStart":
|
|
579
|
-
patterns.numberExpStart.lastIndex = index;
|
|
580
|
-
match = patterns.numberExpStart.exec(this._buffer);
|
|
581
|
-
if (!match) {
|
|
582
|
-
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected an exponent part of a number"));
|
|
583
|
-
break main;
|
|
584
|
-
}
|
|
585
|
-
value = match[0];
|
|
586
|
-
this._streamNumbers && this.push({
|
|
587
|
-
name: "numberChunk",
|
|
588
|
-
value
|
|
589
|
-
});
|
|
590
|
-
this._packNumbers && (this._accumulator += value);
|
|
591
|
-
this._expect = "numberExpDigit";
|
|
592
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
593
|
-
else index += value.length;
|
|
594
|
-
break;
|
|
595
|
-
case "numberExpDigit":
|
|
596
|
-
patterns.numberExpDigit.lastIndex = index;
|
|
597
|
-
match = patterns.numberExpDigit.exec(this._buffer);
|
|
598
|
-
value = match[0];
|
|
599
|
-
if (value) {
|
|
600
|
-
this._streamNumbers && this.push({
|
|
601
|
-
name: "numberChunk",
|
|
602
|
-
value
|
|
603
|
-
});
|
|
604
|
-
this._packNumbers && (this._accumulator += value);
|
|
605
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
606
|
-
else index += value.length;
|
|
607
|
-
} else {
|
|
608
|
-
if (index < this._buffer.length || this._done) {
|
|
609
|
-
this._expect = expected[this._parent];
|
|
610
|
-
break;
|
|
611
|
-
}
|
|
612
|
-
break main;
|
|
613
|
-
}
|
|
614
|
-
break;
|
|
615
|
-
case "done":
|
|
616
|
-
patterns.ws.lastIndex = index;
|
|
617
|
-
match = patterns.ws.exec(this._buffer);
|
|
618
|
-
if (!match) {
|
|
619
|
-
if (index < this._buffer.length) {
|
|
620
|
-
if (this._jsonStreaming) {
|
|
621
|
-
this._expect = "value";
|
|
622
|
-
break;
|
|
623
|
-
}
|
|
624
|
-
return callback(new Error("Parser cannot parse input: unexpected characters"));
|
|
625
|
-
}
|
|
626
|
-
break main;
|
|
627
|
-
}
|
|
628
|
-
value = match[0];
|
|
629
|
-
if (this._open_number) {
|
|
630
|
-
this._streamNumbers && this.push({ name: "endNumber" });
|
|
631
|
-
this._open_number = false;
|
|
632
|
-
if (this._packNumbers) {
|
|
633
|
-
this.push({
|
|
634
|
-
name: "numberValue",
|
|
635
|
-
value: this._accumulator
|
|
636
|
-
});
|
|
637
|
-
this._accumulator = "";
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
641
|
-
else index += value.length;
|
|
642
|
-
break;
|
|
643
|
-
}
|
|
644
|
-
!noSticky && (this._buffer = this._buffer.slice(index));
|
|
645
|
-
callback(null);
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
Parser$1.parser = Parser$1.make;
|
|
649
|
-
Parser$1.make.Constructor = Parser$1;
|
|
650
|
-
module.exports = Parser$1;
|
|
651
|
-
} });
|
|
652
|
-
|
|
653
|
-
//#endregion
|
|
654
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/emit.js
|
|
655
|
-
var require_emit = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/emit.js"(exports, module) {
|
|
656
|
-
const emit$1 = (stream) => stream.on("data", (item) => stream.emit(item.name, item.value));
|
|
657
|
-
module.exports = emit$1;
|
|
658
|
-
} });
|
|
659
|
-
|
|
660
|
-
//#endregion
|
|
661
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/index.js
|
|
662
|
-
var require_stream_json = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/index.js"(exports, module) {
|
|
663
|
-
const Parser = require_Parser();
|
|
664
|
-
const emit = require_emit();
|
|
665
|
-
const make = (options) => emit(new Parser(options));
|
|
666
|
-
make.Parser = Parser;
|
|
667
|
-
make.parser = Parser.parser;
|
|
668
|
-
module.exports = make;
|
|
669
|
-
} });
|
|
670
|
-
|
|
671
|
-
//#endregion
|
|
672
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Assembler.js
|
|
673
|
-
var require_Assembler = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Assembler.js"(exports, module) {
|
|
674
|
-
const EventEmitter = __require("events");
|
|
675
|
-
const startObject = (Ctr) => function() {
|
|
676
|
-
if (this.done) this.done = false;
|
|
677
|
-
else this.stack.push(this.current, this.key);
|
|
678
|
-
this.current = new Ctr();
|
|
679
|
-
this.key = null;
|
|
680
|
-
};
|
|
681
|
-
var Assembler$1 = class Assembler$1 extends EventEmitter {
|
|
682
|
-
static connectTo(stream, options) {
|
|
683
|
-
return new Assembler$1(options).connectTo(stream);
|
|
684
|
-
}
|
|
685
|
-
constructor(options) {
|
|
686
|
-
super();
|
|
687
|
-
this.stack = [];
|
|
688
|
-
this.current = this.key = null;
|
|
689
|
-
this.done = true;
|
|
690
|
-
if (options) {
|
|
691
|
-
this.reviver = typeof options.reviver == "function" && options.reviver;
|
|
692
|
-
if (this.reviver) this.stringValue = this._saveValue = this._saveValueWithReviver;
|
|
693
|
-
if (options.numberAsString) this.numberValue = this.stringValue;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
connectTo(stream) {
|
|
697
|
-
stream.on("data", (chunk) => {
|
|
698
|
-
if (this[chunk.name]) {
|
|
699
|
-
this[chunk.name](chunk.value);
|
|
700
|
-
if (this.done) this.emit("done", this);
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
return this;
|
|
704
|
-
}
|
|
705
|
-
get depth() {
|
|
706
|
-
return (this.stack.length >> 1) + (this.done ? 0 : 1);
|
|
707
|
-
}
|
|
708
|
-
get path() {
|
|
709
|
-
const path = [];
|
|
710
|
-
for (let i = 0; i < this.stack.length; i += 2) {
|
|
711
|
-
const key = this.stack[i + 1];
|
|
712
|
-
path.push(key === null ? this.stack[i].length : key);
|
|
713
|
-
}
|
|
714
|
-
return path;
|
|
715
|
-
}
|
|
716
|
-
dropToLevel(level) {
|
|
717
|
-
if (level < this.depth) if (level) {
|
|
718
|
-
const index = level - 1 << 1;
|
|
719
|
-
this.current = this.stack[index];
|
|
720
|
-
this.key = this.stack[index + 1];
|
|
721
|
-
this.stack.splice(index);
|
|
722
|
-
} else {
|
|
723
|
-
this.stack = [];
|
|
724
|
-
this.current = this.key = null;
|
|
725
|
-
this.done = true;
|
|
726
|
-
}
|
|
727
|
-
return this;
|
|
728
|
-
}
|
|
729
|
-
consume(chunk) {
|
|
730
|
-
this[chunk.name] && this[chunk.name](chunk.value);
|
|
731
|
-
return this;
|
|
732
|
-
}
|
|
733
|
-
keyValue(value) {
|
|
734
|
-
this.key = value;
|
|
735
|
-
}
|
|
736
|
-
numberValue(value) {
|
|
737
|
-
this._saveValue(parseFloat(value));
|
|
738
|
-
}
|
|
739
|
-
nullValue() {
|
|
740
|
-
this._saveValue(null);
|
|
741
|
-
}
|
|
742
|
-
trueValue() {
|
|
743
|
-
this._saveValue(true);
|
|
744
|
-
}
|
|
745
|
-
falseValue() {
|
|
746
|
-
this._saveValue(false);
|
|
747
|
-
}
|
|
748
|
-
endObject() {
|
|
749
|
-
if (this.stack.length) {
|
|
750
|
-
const value = this.current;
|
|
751
|
-
this.key = this.stack.pop();
|
|
752
|
-
this.current = this.stack.pop();
|
|
753
|
-
this._saveValue(value);
|
|
754
|
-
} else this.done = true;
|
|
755
|
-
}
|
|
756
|
-
_saveValue(value) {
|
|
757
|
-
if (this.done) this.current = value;
|
|
758
|
-
else if (this.current instanceof Array) this.current.push(value);
|
|
759
|
-
else {
|
|
760
|
-
this.current[this.key] = value;
|
|
761
|
-
this.key = null;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
_saveValueWithReviver(value) {
|
|
765
|
-
if (this.done) this.current = this.reviver("", value);
|
|
766
|
-
else if (this.current instanceof Array) {
|
|
767
|
-
value = this.reviver("" + this.current.length, value);
|
|
768
|
-
this.current.push(value);
|
|
769
|
-
if (value === void 0) delete this.current[this.current.length - 1];
|
|
770
|
-
} else {
|
|
771
|
-
value = this.reviver(this.key, value);
|
|
772
|
-
if (value !== void 0) this.current[this.key] = value;
|
|
773
|
-
this.key = null;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
Assembler$1.prototype.stringValue = Assembler$1.prototype._saveValue;
|
|
778
|
-
Assembler$1.prototype.startObject = startObject(Object);
|
|
779
|
-
Assembler$1.prototype.startArray = startObject(Array);
|
|
780
|
-
Assembler$1.prototype.endArray = Assembler$1.prototype.endObject;
|
|
781
|
-
module.exports = Assembler$1;
|
|
782
|
-
} });
|
|
783
|
-
|
|
784
|
-
//#endregion
|
|
785
|
-
//#region src/node/utils/json-parse-stream.ts
|
|
786
|
-
var import_stream_json = __toESM(require_stream_json(), 1);
|
|
787
|
-
var import_Assembler = __toESM(require_Assembler(), 1);
|
|
788
|
-
function parseJsonStreamWithConcatArrays(stream, processor) {
|
|
789
|
-
const assembler = new import_Assembler.default();
|
|
790
|
-
const parser = import_stream_json.default.parser({ jsonStreaming: true });
|
|
791
|
-
const values$1 = [];
|
|
792
|
-
return new Promise((resolve$1) => {
|
|
793
|
-
parser.on("data", (chunk) => {
|
|
794
|
-
assembler[chunk.name]?.(chunk.value);
|
|
795
|
-
if (assembler.done) values$1.push(processor ? processor(assembler.current) : assembler.current);
|
|
796
|
-
});
|
|
797
|
-
stream.pipe(parser);
|
|
798
|
-
parser.on("end", () => {
|
|
799
|
-
resolve$1(values$1);
|
|
800
|
-
});
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
//#endregion
|
|
805
|
-
//#region src/node/rolldown/events-manager.ts
|
|
806
|
-
var RolldownEventsManager = class {
|
|
807
|
-
events = [];
|
|
808
|
-
modules = new Map();
|
|
809
|
-
handleEvent(raw) {
|
|
810
|
-
const event = {
|
|
811
|
-
...raw,
|
|
812
|
-
event_id: `${raw.timestamp}#${this.events.length}`
|
|
813
|
-
};
|
|
814
|
-
this.events.push(event);
|
|
815
|
-
if ("module_id" in event) {
|
|
816
|
-
if (this.modules.has(event.module_id)) return;
|
|
817
|
-
this.modules.set(event.module_id, {
|
|
818
|
-
id: event.module_id,
|
|
819
|
-
is_external: false,
|
|
820
|
-
imports: [],
|
|
821
|
-
importers: []
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
if (event.action === "ModuleGraphReady") for (const module$1 of event.modules) {
|
|
825
|
-
this.modules.set(module$1.id, module$1);
|
|
826
|
-
module$1.importers = Array.from(new Set(module$1.importers || [])).sort((a, b) => a.localeCompare(b));
|
|
827
|
-
module$1.imports = Array.from(new Set(module$1.imports || [])).sort((a, b) => a.id.localeCompare(b.id));
|
|
828
|
-
}
|
|
829
|
-
return event;
|
|
830
|
-
}
|
|
831
|
-
dispose() {
|
|
832
|
-
this.events = [];
|
|
833
|
-
}
|
|
834
|
-
[Symbol.dispose]() {
|
|
835
|
-
this.dispose();
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
//#endregion
|
|
840
|
-
//#region src/node/rolldown/events-reader.ts
|
|
841
|
-
const readers = new Map();
|
|
842
|
-
var RolldownEventsReader = class RolldownEventsReader {
|
|
843
|
-
lastBytes = 0;
|
|
844
|
-
lastTimestamp = 0;
|
|
845
|
-
manager = new RolldownEventsManager();
|
|
846
|
-
constructor(filepath) {
|
|
847
|
-
this.filepath = filepath;
|
|
848
|
-
}
|
|
849
|
-
static get(filepath) {
|
|
850
|
-
if (readers.has(filepath)) return readers.get(filepath);
|
|
851
|
-
const reader = new RolldownEventsReader(filepath);
|
|
852
|
-
readers.set(filepath, reader);
|
|
853
|
-
return reader;
|
|
854
|
-
}
|
|
855
|
-
async read() {
|
|
856
|
-
const { mtime, size } = await fs.promises.stat(this.filepath);
|
|
857
|
-
if (mtime.getTime() <= this.lastTimestamp) return;
|
|
858
|
-
const stream = fs.createReadStream(this.filepath, { start: this.lastBytes });
|
|
859
|
-
this.lastTimestamp = mtime.getTime();
|
|
860
|
-
this.lastBytes = size;
|
|
861
|
-
await parseJsonStreamWithConcatArrays(stream, (event) => {
|
|
862
|
-
this.manager.handleEvent(event);
|
|
863
|
-
return event;
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
dispose() {
|
|
867
|
-
readers.delete(this.filepath);
|
|
868
|
-
this.manager.dispose();
|
|
869
|
-
}
|
|
870
|
-
[Symbol.dispose]() {
|
|
871
|
-
this.dispose();
|
|
872
|
-
}
|
|
873
|
-
};
|
|
874
|
-
|
|
875
|
-
//#endregion
|
|
876
|
-
//#region src/node/rpc/functions/rolldown-get-module-info.ts
|
|
877
|
-
const DURATION_THRESHOLD = 10;
|
|
878
|
-
const rolldownGetModuleInfo = defineRpcFunction({
|
|
879
|
-
name: "vite:rolldown:get-module-info",
|
|
880
|
-
type: "query",
|
|
881
|
-
setup: ({ cwd }) => {
|
|
882
|
-
return { handler: async ({ session, module: module$1 }) => {
|
|
883
|
-
const reader = RolldownEventsReader.get(join(cwd, ".rolldown", session, "logs.json"));
|
|
884
|
-
await reader.read();
|
|
885
|
-
const events = reader.manager.events;
|
|
886
|
-
if (!events.length) return null;
|
|
887
|
-
const info = {
|
|
888
|
-
id: module$1,
|
|
889
|
-
loads: [],
|
|
890
|
-
transforms: [],
|
|
891
|
-
imports: [],
|
|
892
|
-
importers: [],
|
|
893
|
-
resolve_ids: [],
|
|
894
|
-
...reader.manager.modules.get(module$1) || {}
|
|
895
|
-
};
|
|
896
|
-
events.forEach((start, index) => {
|
|
897
|
-
if (start.action !== "HookLoadCallStart" || start.module_id !== module$1) return;
|
|
898
|
-
const end = events.find((e) => e.action === "HookLoadCallEnd" && e.call_id === start.call_id, index);
|
|
899
|
-
if (!end || end.action !== "HookLoadCallEnd") {
|
|
900
|
-
console.error(`[rolldown] Load call end not found for ${start.call_id}`);
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
const duration = +end.timestamp - +start.timestamp;
|
|
904
|
-
if (!end.source && duration < DURATION_THRESHOLD) return;
|
|
905
|
-
info.loads.push({
|
|
906
|
-
type: "load",
|
|
907
|
-
id: start.event_id,
|
|
908
|
-
plugin_name: start.plugin_name,
|
|
909
|
-
plugin_index: start.plugin_index,
|
|
910
|
-
source: end.source,
|
|
911
|
-
timestamp_start: +start.timestamp,
|
|
912
|
-
timestamp_end: +end.timestamp,
|
|
913
|
-
duration
|
|
914
|
-
});
|
|
915
|
-
});
|
|
916
|
-
events.forEach((start, index) => {
|
|
917
|
-
if (start.action !== "HookTransformCallStart" || start.module_id !== module$1) return;
|
|
918
|
-
const end = events.find((e) => e.action === "HookTransformCallEnd" && e.call_id === start.call_id, index);
|
|
919
|
-
if (!end || end.action !== "HookTransformCallEnd") {
|
|
920
|
-
console.error(`[rolldown] Transform call end not found for ${start.event_id}`);
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
const duration = +end.timestamp - +start.timestamp;
|
|
924
|
-
if (end.transformed_source === start.source && duration < DURATION_THRESHOLD) return;
|
|
925
|
-
let diff_added = 0;
|
|
926
|
-
let diff_removed = 0;
|
|
927
|
-
if (start.source !== end.transformed_source && start.source != null && end.transformed_source != null) {
|
|
928
|
-
const delta = diffLines(end.transformed_source, start.source);
|
|
929
|
-
diff_added = delta.filter((d) => d.added).map((d) => d.value).join("").split(/\n/g).length;
|
|
930
|
-
diff_removed = delta.filter((d) => d.removed).map((d) => d.value).join("").split(/\n/g).length;
|
|
931
|
-
}
|
|
932
|
-
info.transforms.push({
|
|
933
|
-
type: "transform",
|
|
934
|
-
id: start.event_id,
|
|
935
|
-
plugin_name: start.plugin_name,
|
|
936
|
-
plugin_index: start.plugin_index,
|
|
937
|
-
source_from: start.source,
|
|
938
|
-
source_to: end.transformed_source,
|
|
939
|
-
diff_added,
|
|
940
|
-
diff_removed,
|
|
941
|
-
timestamp_start: +start.timestamp,
|
|
942
|
-
timestamp_end: +end.timestamp,
|
|
943
|
-
duration
|
|
944
|
-
});
|
|
945
|
-
});
|
|
946
|
-
events.forEach((end) => {
|
|
947
|
-
if (end.action !== "HookResolveIdCallEnd" || end.resolved_id !== module$1) return;
|
|
948
|
-
const start = events.find((e) => e.action === "HookResolveIdCallStart" && e.call_id === end.call_id);
|
|
949
|
-
if (!start || start.action !== "HookResolveIdCallStart") {
|
|
950
|
-
console.error(`[rolldown] resolveId call start not found for ${end.event_id}`);
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
953
|
-
const duration = +end.timestamp - +start.timestamp;
|
|
954
|
-
const data = {
|
|
955
|
-
type: "resolve",
|
|
956
|
-
id: end.event_id,
|
|
957
|
-
importer: start.importer,
|
|
958
|
-
module_request: start.module_request,
|
|
959
|
-
import_kind: start.import_kind,
|
|
960
|
-
plugin_name: end.plugin_name,
|
|
961
|
-
plugin_index: end.plugin_index,
|
|
962
|
-
resolved_id: end.resolved_id,
|
|
963
|
-
timestamp_start: +start.timestamp,
|
|
964
|
-
timestamp_end: +end.timestamp,
|
|
965
|
-
duration
|
|
966
|
-
};
|
|
967
|
-
const existingIndex = info.resolve_ids.findIndex((r) => r.importer === start.importer && r.module_request === start.module_request && r.import_kind === start.import_kind && r.plugin_index === end.plugin_index);
|
|
968
|
-
if (existingIndex >= 0) info.resolve_ids.splice(existingIndex, 1);
|
|
969
|
-
info.resolve_ids.push(data);
|
|
970
|
-
});
|
|
971
|
-
info.loads.sort((a, b) => a.plugin_index - b.plugin_index);
|
|
972
|
-
info.transforms.sort((a, b) => a.plugin_index - b.plugin_index);
|
|
973
|
-
info.resolve_ids.sort((a, b) => a.plugin_index - b.plugin_index);
|
|
974
|
-
return info;
|
|
975
|
-
} };
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
|
|
979
|
-
//#endregion
|
|
980
|
-
//#region src/node/rpc/functions/rolldown-get-module-raw-events.ts
|
|
981
|
-
const rolldownGetModuleRawEvents = defineRpcFunction({
|
|
982
|
-
name: "vite:rolldown:get-module-raw-events",
|
|
983
|
-
type: "query",
|
|
984
|
-
setup: ({ cwd }) => {
|
|
985
|
-
return { handler: async ({ session, module: module$1 }) => {
|
|
986
|
-
const reader = RolldownEventsReader.get(join(cwd, ".rolldown", session, "logs.json"));
|
|
987
|
-
await reader.read();
|
|
988
|
-
const events = reader.manager.events.filter((event) => "module_id" in event && event.module_id === module$1);
|
|
989
|
-
return { events };
|
|
990
|
-
} };
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
|
|
994
|
-
//#endregion
|
|
995
|
-
//#region src/node/rpc/functions/rolldown-get-raw-events.ts
|
|
996
|
-
const rolldownGetRawEvents = defineRpcFunction({
|
|
997
|
-
name: "vite:rolldown:get-raw-events",
|
|
998
|
-
type: "query",
|
|
999
|
-
setup: ({ cwd }) => {
|
|
1000
|
-
return { handler: async ({ session }) => {
|
|
1001
|
-
const reader = RolldownEventsReader.get(join(cwd, ".rolldown", session, "logs.json"));
|
|
1002
|
-
await reader.read();
|
|
1003
|
-
return reader.manager.events;
|
|
1004
|
-
} };
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
|
|
1008
|
-
//#endregion
|
|
1009
|
-
//#region src/node/rpc/functions/rolldown-get-session-summary.ts
|
|
1010
|
-
const rolldownGetSessionSummary = defineRpcFunction({
|
|
1011
|
-
name: "vite:rolldown:get-session-summary",
|
|
1012
|
-
type: "query",
|
|
1013
|
-
setup: async ({ cwd }) => {
|
|
1014
|
-
return { handler: async ({ session }) => {
|
|
1015
|
-
const reader = RolldownEventsReader.get(join(cwd, ".rolldown", session, "logs.json"));
|
|
1016
|
-
await reader.read();
|
|
1017
|
-
return {
|
|
1018
|
-
id: session,
|
|
1019
|
-
rootDir: cwd,
|
|
1020
|
-
modules: Array.from(reader.manager.modules.values()).sort((a, b) => a.id.localeCompare(b.id))
|
|
1021
|
-
};
|
|
1022
|
-
} };
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
|
|
1026
|
-
//#endregion
|
|
1027
|
-
//#region src/node/rpc/functions/rolldown-list-sessions.ts
|
|
1028
|
-
const rolldownListSessions = defineRpcFunction({
|
|
1029
|
-
name: "vite:rolldown:list-sessions",
|
|
1030
|
-
type: "query",
|
|
1031
|
-
setup: ({ cwd }) => {
|
|
1032
|
-
return { handler: async () => {
|
|
1033
|
-
const sessions = await fs$1.readdir(join(cwd, ".rolldown"), { withFileTypes: true });
|
|
1034
|
-
return await Promise.all(sessions.filter((d) => d.isDirectory()).map(async (d) => {
|
|
1035
|
-
const stats = await fs$1.stat(join(cwd, ".rolldown", d.name));
|
|
1036
|
-
return {
|
|
1037
|
-
id: d.name,
|
|
1038
|
-
createdAt: stats.birthtime.getTime()
|
|
1039
|
-
};
|
|
1040
|
-
}));
|
|
1041
|
-
} };
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
|
|
1045
|
-
//#endregion
|
|
1046
|
-
//#region src/node/rpc/index.ts
|
|
1047
|
-
const rpcFunctions = [
|
|
1048
|
-
openInEditor,
|
|
1049
|
-
openInFinder,
|
|
1050
|
-
getPayload,
|
|
1051
|
-
rolldownListSessions,
|
|
1052
|
-
rolldownGetRawEvents,
|
|
1053
|
-
rolldownGetSessionSummary,
|
|
1054
|
-
rolldownGetModuleInfo,
|
|
1055
|
-
rolldownGetModuleRawEvents
|
|
1056
|
-
];
|
|
1057
|
-
|
|
1058
|
-
//#endregion
|
|
1059
|
-
//#region src/node/functions.ts
|
|
1060
|
-
async function createServerFunctions(options) {
|
|
1061
|
-
const functions = await Promise.all(rpcFunctions.map(async (fn) => [fn.name, (await fn.setup(options)).handler]));
|
|
1062
|
-
return Object.fromEntries(functions);
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
//#endregion
|
|
1066
|
-
export { createServerFunctions };
|