@vitejs/devtools 0.0.0-alpha.1 → 0.0.0-alpha.10
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-commands-CWESTkWI.js +97 -0
- package/dist/cli-commands.d.ts +18 -0
- package/dist/cli-commands.js +5 -0
- package/dist/cli.js +17 -0
- package/dist/client/inject.d.ts +4 -0
- package/dist/client/inject.js +33 -0
- package/dist/client/standalone/assets/index-BGdE2uyE.css +1 -0
- package/dist/client/standalone/assets/index-BXYGGkRo.js +7 -0
- package/dist/client/standalone/index.html +14 -0
- package/dist/client/webcomponents.d.ts +45 -0
- package/dist/client/webcomponents.js +1063 -0
- package/dist/dirs-DcSK9l9L.js +9 -0
- package/dist/dirs.d.ts +5 -0
- package/dist/dirs.js +3 -0
- package/dist/dist-B0hQ6r05.js +6779 -0
- package/dist/index-C-9eMTqf.d.ts +142 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +4 -0
- package/dist/plugins-5VE4Mfdt.js +1365 -0
- package/package.json +50 -57
- package/dist/cli-B_fm1Ing.mjs +0 -1039
- 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-BdbZxtmk.mjs +0 -3
- package/dist/functions-d6vvbndK.mjs +0 -234
- 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 -16
- package/dist/public/404.html +0 -16
- package/dist/public/_nuxt/B4lqwDon.js +0 -1
- package/dist/public/_nuxt/BMB3EEfo.js +0 -1
- package/dist/public/_nuxt/BYYDnj5Q.js +0 -1
- package/dist/public/_nuxt/BeSFnMzD.js +0 -1
- package/dist/public/_nuxt/BfzgVO01.js +0 -1
- package/dist/public/_nuxt/BpyJ-U40.js +0 -1
- package/dist/public/_nuxt/BxkFQq1F.js +0 -1
- package/dist/public/_nuxt/C1DPtPHu.js +0 -1
- package/dist/public/_nuxt/C8oXVTvZ.js +0 -1
- package/dist/public/_nuxt/CWPvh8od.js +0 -1
- package/dist/public/_nuxt/CiwsH4Q6.js +0 -33
- package/dist/public/_nuxt/CsnZqsGp.js +0 -16
- package/dist/public/_nuxt/CzEHI6hC.js +0 -1
- package/dist/public/_nuxt/D-iXojuv.js +0 -1
- package/dist/public/_nuxt/DHpfOFMA.js +0 -1
- package/dist/public/_nuxt/DsbJux3u.js +0 -1
- package/dist/public/_nuxt/builds/latest.json +0 -1
- package/dist/public/_nuxt/builds/meta/3597016d-955b-44d8-83dd-f083d7311779.json +0 -1
- package/dist/public/_nuxt/diff.worker-9IK9E-UB.js +0 -10
- package/dist/public/_nuxt/entry.BHghYYEP.css +0 -1
- package/dist/public/_nuxt/error-404.7Y6KY23b.css +0 -1
- package/dist/public/_nuxt/error-500.CaUb23JJ.css +0 -1
- package/dist/public/_nuxt/graph.BGBTj9Q7.css +0 -1
- package/dist/public/dot-grid-dark.png +0 -0
- package/dist/public/dot-grid-light.png +0 -0
- package/dist/public/favicon.svg +0 -15
- 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 -16
- package/dist/public/vite-devtools.svg +0 -17
- /package/{LICENSE.md → LICENSE} +0 -0
- /package/dist/{cli-C3YoliaZ.d.mts → cli.d.ts} +0 -0
package/dist/cli-B_fm1Ing.mjs
DELETED
|
@@ -1,1039 +0,0 @@
|
|
|
1
|
-
import { distDir } from "./dirs-6LDFDMFM.mjs";
|
|
2
|
-
import { createServerFunctions } from "./functions-d6vvbndK.mjs";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import fs, { existsSync } from "node:fs";
|
|
5
|
-
import fs$1, { readFile, stat } from "node:fs/promises";
|
|
6
|
-
import { join } from "node:path";
|
|
7
|
-
import process from "node:process";
|
|
8
|
-
import c from "ansis";
|
|
9
|
-
import cac from "cac";
|
|
10
|
-
import { getPort } from "get-port-please";
|
|
11
|
-
import open from "open";
|
|
12
|
-
import { join as join$1, relative, resolve } from "pathe";
|
|
13
|
-
import { stringify } from "structured-clone-es";
|
|
14
|
-
import { glob } from "tinyglobby";
|
|
15
|
-
import { createServer } from "node:http";
|
|
16
|
-
import { createApp, eventHandler, serveStatic, toNodeListener } from "h3";
|
|
17
|
-
import { lookup } from "mrmime";
|
|
18
|
-
import { createRpcServer } from "@vitejs/devtools-rpc";
|
|
19
|
-
import { createWsRpcPreset } from "@vitejs/devtools-rpc/presets/ws/server";
|
|
20
|
-
|
|
21
|
-
//#region rolldown:runtime
|
|
22
|
-
var __create = Object.create;
|
|
23
|
-
var __defProp = Object.defineProperty;
|
|
24
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
25
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
26
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
27
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
28
|
-
var __commonJS = (cb, mod) => function() {
|
|
29
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
30
|
-
};
|
|
31
|
-
var __copyProps = (to, from, except, desc) => {
|
|
32
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
33
|
-
key = keys[i];
|
|
34
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
35
|
-
get: ((k) => from[k]).bind(null, key),
|
|
36
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return to;
|
|
40
|
-
};
|
|
41
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
42
|
-
value: mod,
|
|
43
|
-
enumerable: true
|
|
44
|
-
}) : target, mod));
|
|
45
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/node/constants.ts
|
|
49
|
-
const MARK_CHECK = c.green("✔");
|
|
50
|
-
const MARK_INFO = c.blue("ℹ");
|
|
51
|
-
const MARK_ERROR = c.red("✖");
|
|
52
|
-
const MARK_NODE = "⬢";
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/Utf8Stream.js
|
|
56
|
-
var require_Utf8Stream = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/Utf8Stream.js"(exports, module) {
|
|
57
|
-
const { Transform } = __require("stream");
|
|
58
|
-
const { StringDecoder } = __require("string_decoder");
|
|
59
|
-
var Utf8Stream$1 = class extends Transform {
|
|
60
|
-
constructor(options) {
|
|
61
|
-
super(Object.assign({}, options, { writableObjectMode: false }));
|
|
62
|
-
this._buffer = "";
|
|
63
|
-
}
|
|
64
|
-
_transform(chunk, encoding, callback) {
|
|
65
|
-
if (typeof chunk == "string") this._transform = this._transformString;
|
|
66
|
-
else {
|
|
67
|
-
this._stringDecoder = new StringDecoder();
|
|
68
|
-
this._transform = this._transformBuffer;
|
|
69
|
-
}
|
|
70
|
-
this._transform(chunk, encoding, callback);
|
|
71
|
-
}
|
|
72
|
-
_transformBuffer(chunk, _, callback) {
|
|
73
|
-
this._buffer += this._stringDecoder.write(chunk);
|
|
74
|
-
this._processBuffer(callback);
|
|
75
|
-
}
|
|
76
|
-
_transformString(chunk, _, callback) {
|
|
77
|
-
this._buffer += chunk.toString();
|
|
78
|
-
this._processBuffer(callback);
|
|
79
|
-
}
|
|
80
|
-
_processBuffer(callback) {
|
|
81
|
-
if (this._buffer) {
|
|
82
|
-
this.push(this._buffer, "utf8");
|
|
83
|
-
this._buffer = "";
|
|
84
|
-
}
|
|
85
|
-
callback(null);
|
|
86
|
-
}
|
|
87
|
-
_flushInput() {
|
|
88
|
-
if (this._stringDecoder) this._buffer += this._stringDecoder.end();
|
|
89
|
-
}
|
|
90
|
-
_flush(callback) {
|
|
91
|
-
this._flushInput();
|
|
92
|
-
this._processBuffer(callback);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
module.exports = Utf8Stream$1;
|
|
96
|
-
} });
|
|
97
|
-
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Parser.js
|
|
100
|
-
var require_Parser = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Parser.js"(exports, module) {
|
|
101
|
-
const Utf8Stream = require_Utf8Stream();
|
|
102
|
-
const patterns = {
|
|
103
|
-
value1: /^(?:[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256})/,
|
|
104
|
-
string: /^(?:[^\x00-\x1f\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\")/,
|
|
105
|
-
key1: /^(?:[\"\}]|\s{1,256})/,
|
|
106
|
-
colon: /^(?:\:|\s{1,256})/,
|
|
107
|
-
comma: /^(?:[\,\]\}]|\s{1,256})/,
|
|
108
|
-
ws: /^\s{1,256}/,
|
|
109
|
-
numberStart: /^\d/,
|
|
110
|
-
numberDigit: /^\d{0,256}/,
|
|
111
|
-
numberFraction: /^[\.eE]/,
|
|
112
|
-
numberExponent: /^[eE]/,
|
|
113
|
-
numberExpSign: /^[-+]/
|
|
114
|
-
};
|
|
115
|
-
const MAX_PATTERN_SIZE = 16;
|
|
116
|
-
let noSticky = true;
|
|
117
|
-
try {
|
|
118
|
-
new RegExp(".", "y");
|
|
119
|
-
noSticky = false;
|
|
120
|
-
} catch (e) {}
|
|
121
|
-
!noSticky && Object.keys(patterns).forEach((key) => {
|
|
122
|
-
let src = patterns[key].source.slice(1);
|
|
123
|
-
if (src.slice(0, 3) === "(?:" && src.slice(-1) === ")") src = src.slice(3, -1);
|
|
124
|
-
patterns[key] = new RegExp(src, "y");
|
|
125
|
-
});
|
|
126
|
-
patterns.numberFracStart = patterns.numberExpStart = patterns.numberStart;
|
|
127
|
-
patterns.numberFracDigit = patterns.numberExpDigit = patterns.numberDigit;
|
|
128
|
-
const values = {
|
|
129
|
-
true: true,
|
|
130
|
-
false: false,
|
|
131
|
-
null: null
|
|
132
|
-
}, expected = {
|
|
133
|
-
object: "objectStop",
|
|
134
|
-
array: "arrayStop",
|
|
135
|
-
"": "done"
|
|
136
|
-
};
|
|
137
|
-
const fromHex = (s) => String.fromCharCode(parseInt(s.slice(2), 16));
|
|
138
|
-
const codes = {
|
|
139
|
-
b: "\b",
|
|
140
|
-
f: "\f",
|
|
141
|
-
n: "\n",
|
|
142
|
-
r: "\r",
|
|
143
|
-
t: " ",
|
|
144
|
-
"\"": "\"",
|
|
145
|
-
"\\": "\\",
|
|
146
|
-
"/": "/"
|
|
147
|
-
};
|
|
148
|
-
var Parser$1 = class Parser$1 extends Utf8Stream {
|
|
149
|
-
static make(options) {
|
|
150
|
-
return new Parser$1(options);
|
|
151
|
-
}
|
|
152
|
-
constructor(options) {
|
|
153
|
-
super(Object.assign({}, options, { readableObjectMode: true }));
|
|
154
|
-
this._packKeys = this._packStrings = this._packNumbers = this._streamKeys = this._streamStrings = this._streamNumbers = true;
|
|
155
|
-
if (options) {
|
|
156
|
-
"packValues" in options && (this._packKeys = this._packStrings = this._packNumbers = options.packValues);
|
|
157
|
-
"packKeys" in options && (this._packKeys = options.packKeys);
|
|
158
|
-
"packStrings" in options && (this._packStrings = options.packStrings);
|
|
159
|
-
"packNumbers" in options && (this._packNumbers = options.packNumbers);
|
|
160
|
-
"streamValues" in options && (this._streamKeys = this._streamStrings = this._streamNumbers = options.streamValues);
|
|
161
|
-
"streamKeys" in options && (this._streamKeys = options.streamKeys);
|
|
162
|
-
"streamStrings" in options && (this._streamStrings = options.streamStrings);
|
|
163
|
-
"streamNumbers" in options && (this._streamNumbers = options.streamNumbers);
|
|
164
|
-
this._jsonStreaming = options.jsonStreaming;
|
|
165
|
-
}
|
|
166
|
-
!this._packKeys && (this._streamKeys = true);
|
|
167
|
-
!this._packStrings && (this._streamStrings = true);
|
|
168
|
-
!this._packNumbers && (this._streamNumbers = true);
|
|
169
|
-
this._done = false;
|
|
170
|
-
this._expect = this._jsonStreaming ? "done" : "value";
|
|
171
|
-
this._stack = [];
|
|
172
|
-
this._parent = "";
|
|
173
|
-
this._open_number = false;
|
|
174
|
-
this._accumulator = "";
|
|
175
|
-
}
|
|
176
|
-
_flush(callback) {
|
|
177
|
-
this._done = true;
|
|
178
|
-
super._flush((error) => {
|
|
179
|
-
if (error) return callback(error);
|
|
180
|
-
if (this._open_number) {
|
|
181
|
-
if (this._streamNumbers) this.push({ name: "endNumber" });
|
|
182
|
-
this._open_number = false;
|
|
183
|
-
if (this._packNumbers) {
|
|
184
|
-
this.push({
|
|
185
|
-
name: "numberValue",
|
|
186
|
-
value: this._accumulator
|
|
187
|
-
});
|
|
188
|
-
this._accumulator = "";
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
callback(null);
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
_processBuffer(callback) {
|
|
195
|
-
let match, value, index = 0;
|
|
196
|
-
main: for (;;) switch (this._expect) {
|
|
197
|
-
case "value1":
|
|
198
|
-
case "value":
|
|
199
|
-
patterns.value1.lastIndex = index;
|
|
200
|
-
match = patterns.value1.exec(this._buffer);
|
|
201
|
-
if (!match) {
|
|
202
|
-
if (this._done || index + MAX_PATTERN_SIZE < this._buffer.length) {
|
|
203
|
-
if (index < this._buffer.length) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected a value"));
|
|
204
|
-
return callback(/* @__PURE__ */ new Error("Parser has expected a value"));
|
|
205
|
-
}
|
|
206
|
-
break main;
|
|
207
|
-
}
|
|
208
|
-
value = match[0];
|
|
209
|
-
switch (value) {
|
|
210
|
-
case "\"":
|
|
211
|
-
this._streamStrings && this.push({ name: "startString" });
|
|
212
|
-
this._expect = "string";
|
|
213
|
-
break;
|
|
214
|
-
case "{":
|
|
215
|
-
this.push({ name: "startObject" });
|
|
216
|
-
this._stack.push(this._parent);
|
|
217
|
-
this._parent = "object";
|
|
218
|
-
this._expect = "key1";
|
|
219
|
-
break;
|
|
220
|
-
case "[":
|
|
221
|
-
this.push({ name: "startArray" });
|
|
222
|
-
this._stack.push(this._parent);
|
|
223
|
-
this._parent = "array";
|
|
224
|
-
this._expect = "value1";
|
|
225
|
-
break;
|
|
226
|
-
case "]":
|
|
227
|
-
if (this._expect !== "value1") return callback(/* @__PURE__ */ new Error("Parser cannot parse input: unexpected token ']'"));
|
|
228
|
-
if (this._open_number) {
|
|
229
|
-
this._streamNumbers && this.push({ name: "endNumber" });
|
|
230
|
-
this._open_number = false;
|
|
231
|
-
if (this._packNumbers) {
|
|
232
|
-
this.push({
|
|
233
|
-
name: "numberValue",
|
|
234
|
-
value: this._accumulator
|
|
235
|
-
});
|
|
236
|
-
this._accumulator = "";
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
this.push({ name: "endArray" });
|
|
240
|
-
this._parent = this._stack.pop();
|
|
241
|
-
this._expect = expected[this._parent];
|
|
242
|
-
break;
|
|
243
|
-
case "-":
|
|
244
|
-
this._open_number = true;
|
|
245
|
-
if (this._streamNumbers) {
|
|
246
|
-
this.push({ name: "startNumber" });
|
|
247
|
-
this.push({
|
|
248
|
-
name: "numberChunk",
|
|
249
|
-
value: "-"
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
this._packNumbers && (this._accumulator = "-");
|
|
253
|
-
this._expect = "numberStart";
|
|
254
|
-
break;
|
|
255
|
-
case "0":
|
|
256
|
-
this._open_number = true;
|
|
257
|
-
if (this._streamNumbers) {
|
|
258
|
-
this.push({ name: "startNumber" });
|
|
259
|
-
this.push({
|
|
260
|
-
name: "numberChunk",
|
|
261
|
-
value: "0"
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
this._packNumbers && (this._accumulator = "0");
|
|
265
|
-
this._expect = "numberFraction";
|
|
266
|
-
break;
|
|
267
|
-
case "1":
|
|
268
|
-
case "2":
|
|
269
|
-
case "3":
|
|
270
|
-
case "4":
|
|
271
|
-
case "5":
|
|
272
|
-
case "6":
|
|
273
|
-
case "7":
|
|
274
|
-
case "8":
|
|
275
|
-
case "9":
|
|
276
|
-
this._open_number = true;
|
|
277
|
-
if (this._streamNumbers) {
|
|
278
|
-
this.push({ name: "startNumber" });
|
|
279
|
-
this.push({
|
|
280
|
-
name: "numberChunk",
|
|
281
|
-
value
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
this._packNumbers && (this._accumulator = value);
|
|
285
|
-
this._expect = "numberDigit";
|
|
286
|
-
break;
|
|
287
|
-
case "true":
|
|
288
|
-
case "false":
|
|
289
|
-
case "null":
|
|
290
|
-
if (this._buffer.length - index === value.length && !this._done) break main;
|
|
291
|
-
this.push({
|
|
292
|
-
name: value + "Value",
|
|
293
|
-
value: values[value]
|
|
294
|
-
});
|
|
295
|
-
this._expect = expected[this._parent];
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
299
|
-
else index += value.length;
|
|
300
|
-
break;
|
|
301
|
-
case "keyVal":
|
|
302
|
-
case "string":
|
|
303
|
-
patterns.string.lastIndex = index;
|
|
304
|
-
match = patterns.string.exec(this._buffer);
|
|
305
|
-
if (!match) {
|
|
306
|
-
if (index < this._buffer.length && (this._done || this._buffer.length - index >= 6)) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: escaped characters"));
|
|
307
|
-
if (this._done) return callback(/* @__PURE__ */ new Error("Parser has expected a string value"));
|
|
308
|
-
break main;
|
|
309
|
-
}
|
|
310
|
-
value = match[0];
|
|
311
|
-
if (value === "\"") if (this._expect === "keyVal") {
|
|
312
|
-
this._streamKeys && this.push({ name: "endKey" });
|
|
313
|
-
if (this._packKeys) {
|
|
314
|
-
this.push({
|
|
315
|
-
name: "keyValue",
|
|
316
|
-
value: this._accumulator
|
|
317
|
-
});
|
|
318
|
-
this._accumulator = "";
|
|
319
|
-
}
|
|
320
|
-
this._expect = "colon";
|
|
321
|
-
} else {
|
|
322
|
-
this._streamStrings && this.push({ name: "endString" });
|
|
323
|
-
if (this._packStrings) {
|
|
324
|
-
this.push({
|
|
325
|
-
name: "stringValue",
|
|
326
|
-
value: this._accumulator
|
|
327
|
-
});
|
|
328
|
-
this._accumulator = "";
|
|
329
|
-
}
|
|
330
|
-
this._expect = expected[this._parent];
|
|
331
|
-
}
|
|
332
|
-
else if (value.length > 1 && value.charAt(0) === "\\") {
|
|
333
|
-
const t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value);
|
|
334
|
-
if (this._expect === "keyVal" ? this._streamKeys : this._streamStrings) this.push({
|
|
335
|
-
name: "stringChunk",
|
|
336
|
-
value: t
|
|
337
|
-
});
|
|
338
|
-
if (this._expect === "keyVal" ? this._packKeys : this._packStrings) this._accumulator += t;
|
|
339
|
-
} else {
|
|
340
|
-
if (this._expect === "keyVal" ? this._streamKeys : this._streamStrings) this.push({
|
|
341
|
-
name: "stringChunk",
|
|
342
|
-
value
|
|
343
|
-
});
|
|
344
|
-
if (this._expect === "keyVal" ? this._packKeys : this._packStrings) this._accumulator += value;
|
|
345
|
-
}
|
|
346
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
347
|
-
else index += value.length;
|
|
348
|
-
break;
|
|
349
|
-
case "key1":
|
|
350
|
-
case "key":
|
|
351
|
-
patterns.key1.lastIndex = index;
|
|
352
|
-
match = patterns.key1.exec(this._buffer);
|
|
353
|
-
if (!match) {
|
|
354
|
-
if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected an object key"));
|
|
355
|
-
break main;
|
|
356
|
-
}
|
|
357
|
-
value = match[0];
|
|
358
|
-
if (value === "\"") {
|
|
359
|
-
this._streamKeys && this.push({ name: "startKey" });
|
|
360
|
-
this._expect = "keyVal";
|
|
361
|
-
} else if (value === "}") {
|
|
362
|
-
if (this._expect !== "key1") return callback(/* @__PURE__ */ new Error("Parser cannot parse input: unexpected token '}'"));
|
|
363
|
-
this.push({ name: "endObject" });
|
|
364
|
-
this._parent = this._stack.pop();
|
|
365
|
-
this._expect = expected[this._parent];
|
|
366
|
-
}
|
|
367
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
368
|
-
else index += value.length;
|
|
369
|
-
break;
|
|
370
|
-
case "colon":
|
|
371
|
-
patterns.colon.lastIndex = index;
|
|
372
|
-
match = patterns.colon.exec(this._buffer);
|
|
373
|
-
if (!match) {
|
|
374
|
-
if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected ':'"));
|
|
375
|
-
break main;
|
|
376
|
-
}
|
|
377
|
-
value = match[0];
|
|
378
|
-
value === ":" && (this._expect = "value");
|
|
379
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
380
|
-
else index += value.length;
|
|
381
|
-
break;
|
|
382
|
-
case "arrayStop":
|
|
383
|
-
case "objectStop":
|
|
384
|
-
patterns.comma.lastIndex = index;
|
|
385
|
-
match = patterns.comma.exec(this._buffer);
|
|
386
|
-
if (!match) {
|
|
387
|
-
if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected ','"));
|
|
388
|
-
break main;
|
|
389
|
-
}
|
|
390
|
-
if (this._open_number) {
|
|
391
|
-
this._streamNumbers && this.push({ name: "endNumber" });
|
|
392
|
-
this._open_number = false;
|
|
393
|
-
if (this._packNumbers) {
|
|
394
|
-
this.push({
|
|
395
|
-
name: "numberValue",
|
|
396
|
-
value: this._accumulator
|
|
397
|
-
});
|
|
398
|
-
this._accumulator = "";
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
value = match[0];
|
|
402
|
-
if (value === ",") this._expect = this._expect === "arrayStop" ? "value" : "key";
|
|
403
|
-
else if (value === "}" || value === "]") {
|
|
404
|
-
if (value === "}" ? this._expect === "arrayStop" : this._expect !== "arrayStop") return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected '" + (this._expect === "arrayStop" ? "]" : "}") + "'"));
|
|
405
|
-
this.push({ name: value === "}" ? "endObject" : "endArray" });
|
|
406
|
-
this._parent = this._stack.pop();
|
|
407
|
-
this._expect = expected[this._parent];
|
|
408
|
-
}
|
|
409
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
410
|
-
else index += value.length;
|
|
411
|
-
break;
|
|
412
|
-
case "numberStart":
|
|
413
|
-
patterns.numberStart.lastIndex = index;
|
|
414
|
-
match = patterns.numberStart.exec(this._buffer);
|
|
415
|
-
if (!match) {
|
|
416
|
-
if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected a starting digit"));
|
|
417
|
-
break main;
|
|
418
|
-
}
|
|
419
|
-
value = match[0];
|
|
420
|
-
this._streamNumbers && this.push({
|
|
421
|
-
name: "numberChunk",
|
|
422
|
-
value
|
|
423
|
-
});
|
|
424
|
-
this._packNumbers && (this._accumulator += value);
|
|
425
|
-
this._expect = value === "0" ? "numberFraction" : "numberDigit";
|
|
426
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
427
|
-
else index += value.length;
|
|
428
|
-
break;
|
|
429
|
-
case "numberDigit":
|
|
430
|
-
patterns.numberDigit.lastIndex = index;
|
|
431
|
-
match = patterns.numberDigit.exec(this._buffer);
|
|
432
|
-
if (!match) {
|
|
433
|
-
if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected a digit"));
|
|
434
|
-
break main;
|
|
435
|
-
}
|
|
436
|
-
value = match[0];
|
|
437
|
-
if (value) {
|
|
438
|
-
this._streamNumbers && this.push({
|
|
439
|
-
name: "numberChunk",
|
|
440
|
-
value
|
|
441
|
-
});
|
|
442
|
-
this._packNumbers && (this._accumulator += value);
|
|
443
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
444
|
-
else index += value.length;
|
|
445
|
-
} else {
|
|
446
|
-
if (index < this._buffer.length) {
|
|
447
|
-
this._expect = "numberFraction";
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
if (this._done) {
|
|
451
|
-
this._expect = expected[this._parent];
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
break main;
|
|
455
|
-
}
|
|
456
|
-
break;
|
|
457
|
-
case "numberFraction":
|
|
458
|
-
patterns.numberFraction.lastIndex = index;
|
|
459
|
-
match = patterns.numberFraction.exec(this._buffer);
|
|
460
|
-
if (!match) {
|
|
461
|
-
if (index < this._buffer.length || this._done) {
|
|
462
|
-
this._expect = expected[this._parent];
|
|
463
|
-
break;
|
|
464
|
-
}
|
|
465
|
-
break main;
|
|
466
|
-
}
|
|
467
|
-
value = match[0];
|
|
468
|
-
this._streamNumbers && this.push({
|
|
469
|
-
name: "numberChunk",
|
|
470
|
-
value
|
|
471
|
-
});
|
|
472
|
-
this._packNumbers && (this._accumulator += value);
|
|
473
|
-
this._expect = value === "." ? "numberFracStart" : "numberExpSign";
|
|
474
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
475
|
-
else index += value.length;
|
|
476
|
-
break;
|
|
477
|
-
case "numberFracStart":
|
|
478
|
-
patterns.numberFracStart.lastIndex = index;
|
|
479
|
-
match = patterns.numberFracStart.exec(this._buffer);
|
|
480
|
-
if (!match) {
|
|
481
|
-
if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected a fractional part of a number"));
|
|
482
|
-
break main;
|
|
483
|
-
}
|
|
484
|
-
value = match[0];
|
|
485
|
-
this._streamNumbers && this.push({
|
|
486
|
-
name: "numberChunk",
|
|
487
|
-
value
|
|
488
|
-
});
|
|
489
|
-
this._packNumbers && (this._accumulator += value);
|
|
490
|
-
this._expect = "numberFracDigit";
|
|
491
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
492
|
-
else index += value.length;
|
|
493
|
-
break;
|
|
494
|
-
case "numberFracDigit":
|
|
495
|
-
patterns.numberFracDigit.lastIndex = index;
|
|
496
|
-
match = patterns.numberFracDigit.exec(this._buffer);
|
|
497
|
-
value = match[0];
|
|
498
|
-
if (value) {
|
|
499
|
-
this._streamNumbers && this.push({
|
|
500
|
-
name: "numberChunk",
|
|
501
|
-
value
|
|
502
|
-
});
|
|
503
|
-
this._packNumbers && (this._accumulator += value);
|
|
504
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
505
|
-
else index += value.length;
|
|
506
|
-
} else {
|
|
507
|
-
if (index < this._buffer.length) {
|
|
508
|
-
this._expect = "numberExponent";
|
|
509
|
-
break;
|
|
510
|
-
}
|
|
511
|
-
if (this._done) {
|
|
512
|
-
this._expect = expected[this._parent];
|
|
513
|
-
break;
|
|
514
|
-
}
|
|
515
|
-
break main;
|
|
516
|
-
}
|
|
517
|
-
break;
|
|
518
|
-
case "numberExponent":
|
|
519
|
-
patterns.numberExponent.lastIndex = index;
|
|
520
|
-
match = patterns.numberExponent.exec(this._buffer);
|
|
521
|
-
if (!match) {
|
|
522
|
-
if (index < this._buffer.length) {
|
|
523
|
-
this._expect = expected[this._parent];
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
if (this._done) {
|
|
527
|
-
this._expect = "done";
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
break main;
|
|
531
|
-
}
|
|
532
|
-
value = match[0];
|
|
533
|
-
this._streamNumbers && this.push({
|
|
534
|
-
name: "numberChunk",
|
|
535
|
-
value
|
|
536
|
-
});
|
|
537
|
-
this._packNumbers && (this._accumulator += value);
|
|
538
|
-
this._expect = "numberExpSign";
|
|
539
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
540
|
-
else index += value.length;
|
|
541
|
-
break;
|
|
542
|
-
case "numberExpSign":
|
|
543
|
-
patterns.numberExpSign.lastIndex = index;
|
|
544
|
-
match = patterns.numberExpSign.exec(this._buffer);
|
|
545
|
-
if (!match) {
|
|
546
|
-
if (index < this._buffer.length) {
|
|
547
|
-
this._expect = "numberExpStart";
|
|
548
|
-
break;
|
|
549
|
-
}
|
|
550
|
-
if (this._done) return callback(/* @__PURE__ */ new Error("Parser has expected an exponent value of a number"));
|
|
551
|
-
break main;
|
|
552
|
-
}
|
|
553
|
-
value = match[0];
|
|
554
|
-
this._streamNumbers && this.push({
|
|
555
|
-
name: "numberChunk",
|
|
556
|
-
value
|
|
557
|
-
});
|
|
558
|
-
this._packNumbers && (this._accumulator += value);
|
|
559
|
-
this._expect = "numberExpStart";
|
|
560
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
561
|
-
else index += value.length;
|
|
562
|
-
break;
|
|
563
|
-
case "numberExpStart":
|
|
564
|
-
patterns.numberExpStart.lastIndex = index;
|
|
565
|
-
match = patterns.numberExpStart.exec(this._buffer);
|
|
566
|
-
if (!match) {
|
|
567
|
-
if (index < this._buffer.length || this._done) return callback(/* @__PURE__ */ new Error("Parser cannot parse input: expected an exponent part of a number"));
|
|
568
|
-
break main;
|
|
569
|
-
}
|
|
570
|
-
value = match[0];
|
|
571
|
-
this._streamNumbers && this.push({
|
|
572
|
-
name: "numberChunk",
|
|
573
|
-
value
|
|
574
|
-
});
|
|
575
|
-
this._packNumbers && (this._accumulator += value);
|
|
576
|
-
this._expect = "numberExpDigit";
|
|
577
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
578
|
-
else index += value.length;
|
|
579
|
-
break;
|
|
580
|
-
case "numberExpDigit":
|
|
581
|
-
patterns.numberExpDigit.lastIndex = index;
|
|
582
|
-
match = patterns.numberExpDigit.exec(this._buffer);
|
|
583
|
-
value = match[0];
|
|
584
|
-
if (value) {
|
|
585
|
-
this._streamNumbers && this.push({
|
|
586
|
-
name: "numberChunk",
|
|
587
|
-
value
|
|
588
|
-
});
|
|
589
|
-
this._packNumbers && (this._accumulator += value);
|
|
590
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
591
|
-
else index += value.length;
|
|
592
|
-
} else {
|
|
593
|
-
if (index < this._buffer.length || this._done) {
|
|
594
|
-
this._expect = expected[this._parent];
|
|
595
|
-
break;
|
|
596
|
-
}
|
|
597
|
-
break main;
|
|
598
|
-
}
|
|
599
|
-
break;
|
|
600
|
-
case "done":
|
|
601
|
-
patterns.ws.lastIndex = index;
|
|
602
|
-
match = patterns.ws.exec(this._buffer);
|
|
603
|
-
if (!match) {
|
|
604
|
-
if (index < this._buffer.length) {
|
|
605
|
-
if (this._jsonStreaming) {
|
|
606
|
-
this._expect = "value";
|
|
607
|
-
break;
|
|
608
|
-
}
|
|
609
|
-
return callback(/* @__PURE__ */ new Error("Parser cannot parse input: unexpected characters"));
|
|
610
|
-
}
|
|
611
|
-
break main;
|
|
612
|
-
}
|
|
613
|
-
value = match[0];
|
|
614
|
-
if (this._open_number) {
|
|
615
|
-
this._streamNumbers && this.push({ name: "endNumber" });
|
|
616
|
-
this._open_number = false;
|
|
617
|
-
if (this._packNumbers) {
|
|
618
|
-
this.push({
|
|
619
|
-
name: "numberValue",
|
|
620
|
-
value: this._accumulator
|
|
621
|
-
});
|
|
622
|
-
this._accumulator = "";
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (noSticky) this._buffer = this._buffer.slice(value.length);
|
|
626
|
-
else index += value.length;
|
|
627
|
-
break;
|
|
628
|
-
}
|
|
629
|
-
!noSticky && (this._buffer = this._buffer.slice(index));
|
|
630
|
-
callback(null);
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
Parser$1.parser = Parser$1.make;
|
|
634
|
-
Parser$1.make.Constructor = Parser$1;
|
|
635
|
-
module.exports = Parser$1;
|
|
636
|
-
} });
|
|
637
|
-
|
|
638
|
-
//#endregion
|
|
639
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/emit.js
|
|
640
|
-
var require_emit = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/utils/emit.js"(exports, module) {
|
|
641
|
-
const emit$1 = (stream) => stream.on("data", (item) => stream.emit(item.name, item.value));
|
|
642
|
-
module.exports = emit$1;
|
|
643
|
-
} });
|
|
644
|
-
|
|
645
|
-
//#endregion
|
|
646
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/index.js
|
|
647
|
-
var require_stream_json = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/index.js"(exports, module) {
|
|
648
|
-
const Parser = require_Parser();
|
|
649
|
-
const emit = require_emit();
|
|
650
|
-
const make = (options) => emit(new Parser(options));
|
|
651
|
-
make.Parser = Parser;
|
|
652
|
-
make.parser = Parser.parser;
|
|
653
|
-
module.exports = make;
|
|
654
|
-
} });
|
|
655
|
-
|
|
656
|
-
//#endregion
|
|
657
|
-
//#region ../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Assembler.js
|
|
658
|
-
var require_Assembler = __commonJS({ "../../node_modules/.pnpm/stream-json@1.9.1/node_modules/stream-json/Assembler.js"(exports, module) {
|
|
659
|
-
const EventEmitter = __require("events");
|
|
660
|
-
const startObject = (Ctr) => function() {
|
|
661
|
-
if (this.done) this.done = false;
|
|
662
|
-
else this.stack.push(this.current, this.key);
|
|
663
|
-
this.current = new Ctr();
|
|
664
|
-
this.key = null;
|
|
665
|
-
};
|
|
666
|
-
var Assembler$1 = class Assembler$1 extends EventEmitter {
|
|
667
|
-
static connectTo(stream, options) {
|
|
668
|
-
return new Assembler$1(options).connectTo(stream);
|
|
669
|
-
}
|
|
670
|
-
constructor(options) {
|
|
671
|
-
super();
|
|
672
|
-
this.stack = [];
|
|
673
|
-
this.current = this.key = null;
|
|
674
|
-
this.done = true;
|
|
675
|
-
if (options) {
|
|
676
|
-
this.reviver = typeof options.reviver == "function" && options.reviver;
|
|
677
|
-
if (this.reviver) this.stringValue = this._saveValue = this._saveValueWithReviver;
|
|
678
|
-
if (options.numberAsString) this.numberValue = this.stringValue;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
connectTo(stream) {
|
|
682
|
-
stream.on("data", (chunk) => {
|
|
683
|
-
if (this[chunk.name]) {
|
|
684
|
-
this[chunk.name](chunk.value);
|
|
685
|
-
if (this.done) this.emit("done", this);
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
return this;
|
|
689
|
-
}
|
|
690
|
-
get depth() {
|
|
691
|
-
return (this.stack.length >> 1) + (this.done ? 0 : 1);
|
|
692
|
-
}
|
|
693
|
-
get path() {
|
|
694
|
-
const path = [];
|
|
695
|
-
for (let i = 0; i < this.stack.length; i += 2) {
|
|
696
|
-
const key = this.stack[i + 1];
|
|
697
|
-
path.push(key === null ? this.stack[i].length : key);
|
|
698
|
-
}
|
|
699
|
-
return path;
|
|
700
|
-
}
|
|
701
|
-
dropToLevel(level) {
|
|
702
|
-
if (level < this.depth) if (level) {
|
|
703
|
-
const index = level - 1 << 1;
|
|
704
|
-
this.current = this.stack[index];
|
|
705
|
-
this.key = this.stack[index + 1];
|
|
706
|
-
this.stack.splice(index);
|
|
707
|
-
} else {
|
|
708
|
-
this.stack = [];
|
|
709
|
-
this.current = this.key = null;
|
|
710
|
-
this.done = true;
|
|
711
|
-
}
|
|
712
|
-
return this;
|
|
713
|
-
}
|
|
714
|
-
consume(chunk) {
|
|
715
|
-
this[chunk.name] && this[chunk.name](chunk.value);
|
|
716
|
-
return this;
|
|
717
|
-
}
|
|
718
|
-
keyValue(value) {
|
|
719
|
-
this.key = value;
|
|
720
|
-
}
|
|
721
|
-
numberValue(value) {
|
|
722
|
-
this._saveValue(parseFloat(value));
|
|
723
|
-
}
|
|
724
|
-
nullValue() {
|
|
725
|
-
this._saveValue(null);
|
|
726
|
-
}
|
|
727
|
-
trueValue() {
|
|
728
|
-
this._saveValue(true);
|
|
729
|
-
}
|
|
730
|
-
falseValue() {
|
|
731
|
-
this._saveValue(false);
|
|
732
|
-
}
|
|
733
|
-
endObject() {
|
|
734
|
-
if (this.stack.length) {
|
|
735
|
-
const value = this.current;
|
|
736
|
-
this.key = this.stack.pop();
|
|
737
|
-
this.current = this.stack.pop();
|
|
738
|
-
this._saveValue(value);
|
|
739
|
-
} else this.done = true;
|
|
740
|
-
}
|
|
741
|
-
_saveValue(value) {
|
|
742
|
-
if (this.done) this.current = value;
|
|
743
|
-
else if (this.current instanceof Array) this.current.push(value);
|
|
744
|
-
else {
|
|
745
|
-
this.current[this.key] = value;
|
|
746
|
-
this.key = null;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
_saveValueWithReviver(value) {
|
|
750
|
-
if (this.done) this.current = this.reviver("", value);
|
|
751
|
-
else if (this.current instanceof Array) {
|
|
752
|
-
value = this.reviver("" + this.current.length, value);
|
|
753
|
-
this.current.push(value);
|
|
754
|
-
if (value === void 0) delete this.current[this.current.length - 1];
|
|
755
|
-
} else {
|
|
756
|
-
value = this.reviver(this.key, value);
|
|
757
|
-
if (value !== void 0) this.current[this.key] = value;
|
|
758
|
-
this.key = null;
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
Assembler$1.prototype.stringValue = Assembler$1.prototype._saveValue;
|
|
763
|
-
Assembler$1.prototype.startObject = startObject(Object);
|
|
764
|
-
Assembler$1.prototype.startArray = startObject(Array);
|
|
765
|
-
Assembler$1.prototype.endArray = Assembler$1.prototype.endObject;
|
|
766
|
-
module.exports = Assembler$1;
|
|
767
|
-
} });
|
|
768
|
-
|
|
769
|
-
//#endregion
|
|
770
|
-
//#region src/node/utils/json-parse-stream.ts
|
|
771
|
-
var import_stream_json = __toESM(require_stream_json(), 1);
|
|
772
|
-
var import_Assembler = __toESM(require_Assembler(), 1);
|
|
773
|
-
function parseJsonStreamWithConcatArrays(stream, processor) {
|
|
774
|
-
const assembler = new import_Assembler.default();
|
|
775
|
-
const parser = import_stream_json.default.parser({ jsonStreaming: true });
|
|
776
|
-
const values$1 = [];
|
|
777
|
-
return new Promise((resolve$1) => {
|
|
778
|
-
parser.on("data", (chunk) => {
|
|
779
|
-
assembler[chunk.name]?.(chunk.value);
|
|
780
|
-
if (assembler.done) values$1.push(processor ? processor(assembler.current) : assembler.current);
|
|
781
|
-
});
|
|
782
|
-
stream.pipe(parser);
|
|
783
|
-
parser.on("end", () => {
|
|
784
|
-
resolve$1(values$1);
|
|
785
|
-
});
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
//#endregion
|
|
790
|
-
//#region src/node/rolldown/events-manager.ts
|
|
791
|
-
var RolldownEventsManager = class {
|
|
792
|
-
events = [];
|
|
793
|
-
modules = /* @__PURE__ */ new Map();
|
|
794
|
-
source_refs = /* @__PURE__ */ new Map();
|
|
795
|
-
interpretSourceRefs(event, key) {
|
|
796
|
-
if (key in event && typeof event[key] === "string") {
|
|
797
|
-
if (event[key].startsWith("$ref:")) {
|
|
798
|
-
const refKey = event[key].slice(5);
|
|
799
|
-
if (this.source_refs.has(refKey)) event[key] = this.source_refs.get(refKey);
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
handleEvent(raw) {
|
|
804
|
-
const event = {
|
|
805
|
-
...raw,
|
|
806
|
-
event_id: `${"timestamp" in raw ? raw.timestamp : "x"}#${this.events.length}`
|
|
807
|
-
};
|
|
808
|
-
this.events.push(event);
|
|
809
|
-
if (event.action === "StringRef") {
|
|
810
|
-
this.source_refs.set(event.id, event.content);
|
|
811
|
-
return;
|
|
812
|
-
}
|
|
813
|
-
this.interpretSourceRefs(event, "source");
|
|
814
|
-
this.interpretSourceRefs(event, "transformed_source");
|
|
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 = /* @__PURE__ */ new Map();
|
|
842
|
-
var RolldownEventsReader = class RolldownEventsReader {
|
|
843
|
-
lastBytes = 0;
|
|
844
|
-
lastTimestamp = 0;
|
|
845
|
-
manager = new RolldownEventsManager();
|
|
846
|
-
meta;
|
|
847
|
-
constructor(filepath) {
|
|
848
|
-
this.filepath = filepath;
|
|
849
|
-
}
|
|
850
|
-
static get(filepath) {
|
|
851
|
-
if (readers.has(filepath)) return readers.get(filepath);
|
|
852
|
-
const reader = new RolldownEventsReader(filepath);
|
|
853
|
-
readers.set(filepath, reader);
|
|
854
|
-
return reader;
|
|
855
|
-
}
|
|
856
|
-
async read() {
|
|
857
|
-
const { mtime, size } = await fs.promises.stat(this.filepath);
|
|
858
|
-
if (mtime.getTime() <= this.lastTimestamp) return;
|
|
859
|
-
const stream = fs.createReadStream(this.filepath, { start: this.lastBytes });
|
|
860
|
-
this.lastTimestamp = mtime.getTime();
|
|
861
|
-
this.lastBytes = size;
|
|
862
|
-
await parseJsonStreamWithConcatArrays(stream, (event) => {
|
|
863
|
-
this.manager.handleEvent(event);
|
|
864
|
-
return event;
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
dispose() {
|
|
868
|
-
readers.delete(this.filepath);
|
|
869
|
-
this.manager.dispose();
|
|
870
|
-
}
|
|
871
|
-
[Symbol.dispose]() {
|
|
872
|
-
this.dispose();
|
|
873
|
-
}
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
//#endregion
|
|
877
|
-
//#region src/node/rolldown/logs-manager.ts
|
|
878
|
-
var RolldownLogsManager = class {
|
|
879
|
-
constructor(dir) {
|
|
880
|
-
this.dir = dir;
|
|
881
|
-
}
|
|
882
|
-
async list() {
|
|
883
|
-
const sessions = await fs$1.readdir(this.dir, { withFileTypes: true });
|
|
884
|
-
return await Promise.all(sessions.filter((d) => d.isDirectory()).map(async (d) => {
|
|
885
|
-
const meta = JSON.parse(await fs$1.readFile(join$1(this.dir, d.name, "meta.json"), "utf-8"));
|
|
886
|
-
return {
|
|
887
|
-
id: d.name,
|
|
888
|
-
timestamp: meta.timestamp,
|
|
889
|
-
meta
|
|
890
|
-
};
|
|
891
|
-
}));
|
|
892
|
-
}
|
|
893
|
-
async loadSession(session) {
|
|
894
|
-
const reader = RolldownEventsReader.get(join$1(this.dir, session, "logs.json"));
|
|
895
|
-
reader.meta ||= JSON.parse(await fs$1.readFile(join$1(this.dir, session, "meta.json"), "utf-8"));
|
|
896
|
-
await reader.read();
|
|
897
|
-
return reader;
|
|
898
|
-
}
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
//#endregion
|
|
902
|
-
//#region src/node/ws.ts
|
|
903
|
-
async function createWsServer(options) {
|
|
904
|
-
const port = options.port ?? await getPort({
|
|
905
|
-
port: 7812,
|
|
906
|
-
random: true
|
|
907
|
-
});
|
|
908
|
-
const wsClients = /* @__PURE__ */ new Set();
|
|
909
|
-
const serverFunctions = await createServerFunctions(options);
|
|
910
|
-
const preset = createWsRpcPreset({
|
|
911
|
-
port,
|
|
912
|
-
onConnected: (ws) => {
|
|
913
|
-
wsClients.add(ws);
|
|
914
|
-
console.log(c.green`${MARK_CHECK} Websocket client connected`);
|
|
915
|
-
},
|
|
916
|
-
onDisconnected: (ws) => {
|
|
917
|
-
wsClients.delete(ws);
|
|
918
|
-
console.log(c.red`${MARK_CHECK} Websocket client disconnected`);
|
|
919
|
-
}
|
|
920
|
-
});
|
|
921
|
-
const rpc = createRpcServer(serverFunctions, {
|
|
922
|
-
preset,
|
|
923
|
-
rpcOptions: { onError(error, name) {
|
|
924
|
-
console.error(c.red`⬢ RPC error on executing "${c.bold(name)}":`);
|
|
925
|
-
console.error(error);
|
|
926
|
-
throw error;
|
|
927
|
-
} }
|
|
928
|
-
});
|
|
929
|
-
const getMetadata = async () => {
|
|
930
|
-
return {
|
|
931
|
-
backend: "websocket",
|
|
932
|
-
websocket: port
|
|
933
|
-
};
|
|
934
|
-
};
|
|
935
|
-
return {
|
|
936
|
-
port,
|
|
937
|
-
rpc,
|
|
938
|
-
serverFunctions,
|
|
939
|
-
getMetadata
|
|
940
|
-
};
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
//#endregion
|
|
944
|
-
//#region src/node/server.ts
|
|
945
|
-
async function createHostServer(options) {
|
|
946
|
-
const app = createApp();
|
|
947
|
-
const { rpc, getMetadata } = await createWsServer(options);
|
|
948
|
-
const fileMap = /* @__PURE__ */ new Map();
|
|
949
|
-
const readCachedFile = (id) => {
|
|
950
|
-
if (!fileMap.has(id)) fileMap.set(id, readFile(id).catch(() => void 0));
|
|
951
|
-
return fileMap.get(id);
|
|
952
|
-
};
|
|
953
|
-
app.use("/api/metadata.json", eventHandler(async (event) => {
|
|
954
|
-
event.node.res.setHeader("Content-Type", "application/json");
|
|
955
|
-
return event.node.res.end(JSON.stringify(await getMetadata()));
|
|
956
|
-
}));
|
|
957
|
-
app.use("/", eventHandler(async (event) => {
|
|
958
|
-
const result = await serveStatic(event, {
|
|
959
|
-
fallthrough: true,
|
|
960
|
-
getContents: (id) => readCachedFile(join$1(distDir, id)),
|
|
961
|
-
getMeta: async (id) => {
|
|
962
|
-
const stats = await stat(join$1(distDir, id)).catch(() => {});
|
|
963
|
-
if (!stats || !stats.isFile()) return;
|
|
964
|
-
return {
|
|
965
|
-
type: lookup(id),
|
|
966
|
-
size: stats.size,
|
|
967
|
-
mtime: stats.mtimeMs
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
});
|
|
971
|
-
if (result === false) return readCachedFile(join$1(distDir, "index.html"));
|
|
972
|
-
}));
|
|
973
|
-
return {
|
|
974
|
-
server: createServer(toNodeListener(app)),
|
|
975
|
-
rpc
|
|
976
|
-
};
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
//#endregion
|
|
980
|
-
//#region src/node/cli.ts
|
|
981
|
-
const cli = cac("vite-devtools");
|
|
982
|
-
cli.command("build", "Build devtools with current config file for static hosting").option("--root <root>", "Root directory", { default: process.cwd() }).option("--config <config>", "Config file").option("--depth <depth>", "Max depth to list dependencies", { default: 8 }).option("--base <baseURL>", "Base URL for deployment", { default: "/" }).option("--outDir <dir>", "Output directory", { default: ".vite-devtools" }).action(async (options) => {
|
|
983
|
-
console.log(c.cyan`${MARK_NODE} Building static Vite DevTools...`);
|
|
984
|
-
const cwd = process.cwd();
|
|
985
|
-
const outDir = resolve(cwd, options.outDir);
|
|
986
|
-
const rpc = await import("./functions-BdbZxtmk.mjs").then(async (r) => await r.createServerFunctions({
|
|
987
|
-
cwd,
|
|
988
|
-
mode: "build",
|
|
989
|
-
manager: new RolldownLogsManager(join(cwd, ".rolldown"))
|
|
990
|
-
}));
|
|
991
|
-
const rpcDump = { "vite:get-payload": await rpc["vite:get-payload"]() };
|
|
992
|
-
let baseURL = options.base;
|
|
993
|
-
if (!baseURL.endsWith("/")) baseURL += "/";
|
|
994
|
-
if (!baseURL.startsWith("/")) baseURL = `/${baseURL}`;
|
|
995
|
-
baseURL = baseURL.replace(/\/+/g, "/");
|
|
996
|
-
if (existsSync(outDir)) await fs$1.rm(outDir, { recursive: true });
|
|
997
|
-
await fs$1.mkdir(outDir, { recursive: true });
|
|
998
|
-
await fs$1.cp(distDir, outDir, { recursive: true });
|
|
999
|
-
const htmlFiles = await glob("**/*.html", {
|
|
1000
|
-
cwd: distDir,
|
|
1001
|
-
onlyFiles: true,
|
|
1002
|
-
dot: true,
|
|
1003
|
-
expandDirectories: false
|
|
1004
|
-
});
|
|
1005
|
-
if (baseURL !== "/") for (const file of htmlFiles) {
|
|
1006
|
-
const content = await fs$1.readFile(resolve(distDir, file), "utf-8");
|
|
1007
|
-
const newContent = content.replaceAll(/\s(href|src)="\//g, ` $1="${baseURL}`).replaceAll("baseURL:\"/\"", `baseURL:"${baseURL}"`);
|
|
1008
|
-
await fs$1.writeFile(resolve(outDir, file), newContent, "utf-8");
|
|
1009
|
-
}
|
|
1010
|
-
await fs$1.mkdir(resolve(outDir, "api"), { recursive: true });
|
|
1011
|
-
await fs$1.writeFile(resolve(outDir, "api/metadata.json"), JSON.stringify({ backend: "static" }, null, 2), "utf-8");
|
|
1012
|
-
await fs$1.writeFile(resolve(outDir, "api/rpc-dump.json"), stringify(rpcDump), "utf-8");
|
|
1013
|
-
console.log(c.green`${MARK_CHECK} Built to ${relative(cwd, outDir)}`);
|
|
1014
|
-
console.log(c.blue`${MARK_NODE} You can use static server like \`npx serve ${relative(cwd, outDir)}\` to serve the devtools`);
|
|
1015
|
-
});
|
|
1016
|
-
cli.command("", "Start devtools").option("--root <root>", "Root directory", { default: process.cwd() }).option("--config <config>", "Config file").option("--depth <depth>", "Max depth to list dependencies", { default: 8 }).option("--host <host>", "Host", { default: process.env.HOST || "127.0.0.1" }).option("--port <port>", "Port", { default: process.env.PORT || 9999 }).option("--open", "Open browser", { default: true }).action(async (options) => {
|
|
1017
|
-
const host = options.host;
|
|
1018
|
-
const port = await getPort({
|
|
1019
|
-
port: options.port,
|
|
1020
|
-
portRange: [9999, 15e3],
|
|
1021
|
-
host
|
|
1022
|
-
});
|
|
1023
|
-
console.log(c.green`${MARK_NODE} Starting Vite DevTools at`, c.green(`http://${host === "127.0.0.1" ? "localhost" : host}:${port}`), "\n");
|
|
1024
|
-
const { server, rpc } = await createHostServer({
|
|
1025
|
-
cwd: options.root,
|
|
1026
|
-
mode: "dev",
|
|
1027
|
-
manager: new RolldownLogsManager(join(options.root, ".rolldown"))
|
|
1028
|
-
});
|
|
1029
|
-
setTimeout(() => {
|
|
1030
|
-
rpc.functions["vite:get-payload"]();
|
|
1031
|
-
}, 1);
|
|
1032
|
-
server.listen(port, host, async () => {
|
|
1033
|
-
if (options.open) await open(`http://${host === "127.0.0.1" ? "localhost" : host}:${port}`);
|
|
1034
|
-
});
|
|
1035
|
-
});
|
|
1036
|
-
cli.help();
|
|
1037
|
-
cli.parse();
|
|
1038
|
-
|
|
1039
|
-
//#endregion
|