@rspack/cli 2.0.0-rc.0 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/rspack.js +5 -1
- package/dist/697.js +1406 -0
- package/dist/cli.d.ts +7 -0
- package/dist/exit-hook.js +61 -0
- package/dist/index.js +1 -1319
- package/dist/json-ext.js +772 -0
- package/dist/profile.js +1 -1
- package/package.json +7 -9
package/dist/json-ext.js
ADDED
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./697.js";
|
|
2
|
+
import "./697.js";
|
|
3
|
+
__webpack_require__.add({
|
|
4
|
+
"../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
5
|
+
module.exports = {
|
|
6
|
+
version: __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/version.js"),
|
|
7
|
+
stringifyInfo: __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/stringify-info.js"),
|
|
8
|
+
stringifyStream: __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/stringify-stream.js"),
|
|
9
|
+
parseChunked: __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/parse-chunked.js")
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
"../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/parse-chunked.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
13
|
+
const { isReadableStream } = __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/utils.js");
|
|
14
|
+
const TextDecoder = __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/text-decoder.js");
|
|
15
|
+
const STACK_OBJECT = 1;
|
|
16
|
+
const STACK_ARRAY = 2;
|
|
17
|
+
const decoder = new TextDecoder();
|
|
18
|
+
function isObject(value) {
|
|
19
|
+
return null !== value && 'object' == typeof value;
|
|
20
|
+
}
|
|
21
|
+
function adjustPosition(error, parser) {
|
|
22
|
+
if ('SyntaxError' === error.name && parser.jsonParseOffset) error.message = error.message.replace(/at position (\d+)/, (_, pos)=>'at position ' + (Number(pos) + parser.jsonParseOffset));
|
|
23
|
+
return error;
|
|
24
|
+
}
|
|
25
|
+
function append(array, elements) {
|
|
26
|
+
const initialLength = array.length;
|
|
27
|
+
array.length += elements.length;
|
|
28
|
+
for(let i = 0; i < elements.length; i++)array[initialLength + i] = elements[i];
|
|
29
|
+
}
|
|
30
|
+
module.exports = function(chunkEmitter) {
|
|
31
|
+
let parser = new ChunkParser();
|
|
32
|
+
if (isObject(chunkEmitter) && isReadableStream(chunkEmitter)) return new Promise((resolve, reject)=>{
|
|
33
|
+
chunkEmitter.on('data', (chunk)=>{
|
|
34
|
+
try {
|
|
35
|
+
parser.push(chunk);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(adjustPosition(e, parser));
|
|
38
|
+
parser = null;
|
|
39
|
+
}
|
|
40
|
+
}).on('error', (e)=>{
|
|
41
|
+
parser = null;
|
|
42
|
+
reject(e);
|
|
43
|
+
}).on('end', ()=>{
|
|
44
|
+
try {
|
|
45
|
+
resolve(parser.finish());
|
|
46
|
+
} catch (e) {
|
|
47
|
+
reject(adjustPosition(e, parser));
|
|
48
|
+
} finally{
|
|
49
|
+
parser = null;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
if ('function' == typeof chunkEmitter) {
|
|
54
|
+
const iterator = chunkEmitter();
|
|
55
|
+
if (isObject(iterator) && (Symbol.iterator in iterator || Symbol.asyncIterator in iterator)) return new Promise(async (resolve, reject)=>{
|
|
56
|
+
try {
|
|
57
|
+
for await (const chunk of iterator)parser.push(chunk);
|
|
58
|
+
resolve(parser.finish());
|
|
59
|
+
} catch (e) {
|
|
60
|
+
reject(adjustPosition(e, parser));
|
|
61
|
+
} finally{
|
|
62
|
+
parser = null;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
throw new Error("Chunk emitter should be readable stream, generator, async generator or function returning an iterable object");
|
|
67
|
+
};
|
|
68
|
+
class ChunkParser {
|
|
69
|
+
constructor(){
|
|
70
|
+
this.value = void 0;
|
|
71
|
+
this.valueStack = null;
|
|
72
|
+
this.stack = new Array(100);
|
|
73
|
+
this.lastFlushDepth = 0;
|
|
74
|
+
this.flushDepth = 0;
|
|
75
|
+
this.stateString = false;
|
|
76
|
+
this.stateStringEscape = false;
|
|
77
|
+
this.pendingByteSeq = null;
|
|
78
|
+
this.pendingChunk = null;
|
|
79
|
+
this.chunkOffset = 0;
|
|
80
|
+
this.jsonParseOffset = 0;
|
|
81
|
+
}
|
|
82
|
+
parseAndAppend(fragment, wrap) {
|
|
83
|
+
if (this.stack[this.lastFlushDepth - 1] === STACK_OBJECT) {
|
|
84
|
+
if (wrap) {
|
|
85
|
+
this.jsonParseOffset--;
|
|
86
|
+
fragment = '{' + fragment + '}';
|
|
87
|
+
}
|
|
88
|
+
Object.assign(this.valueStack.value, JSON.parse(fragment));
|
|
89
|
+
} else {
|
|
90
|
+
if (wrap) {
|
|
91
|
+
this.jsonParseOffset--;
|
|
92
|
+
fragment = '[' + fragment + ']';
|
|
93
|
+
}
|
|
94
|
+
append(this.valueStack.value, JSON.parse(fragment));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
prepareAddition(fragment) {
|
|
98
|
+
const { value } = this.valueStack;
|
|
99
|
+
const expectComma = Array.isArray(value) ? 0 !== value.length : 0 !== Object.keys(value).length;
|
|
100
|
+
if (expectComma) {
|
|
101
|
+
if (',' === fragment[0]) {
|
|
102
|
+
this.jsonParseOffset++;
|
|
103
|
+
return fragment.slice(1);
|
|
104
|
+
}
|
|
105
|
+
if ('}' !== fragment[0] && ']' !== fragment[0]) {
|
|
106
|
+
this.jsonParseOffset -= 3;
|
|
107
|
+
return '[[]' + fragment;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return fragment;
|
|
111
|
+
}
|
|
112
|
+
flush(chunk, start, end) {
|
|
113
|
+
let fragment = chunk.slice(start, end);
|
|
114
|
+
this.jsonParseOffset = this.chunkOffset + start;
|
|
115
|
+
if (null !== this.pendingChunk) {
|
|
116
|
+
fragment = this.pendingChunk + fragment;
|
|
117
|
+
this.jsonParseOffset -= this.pendingChunk.length;
|
|
118
|
+
this.pendingChunk = null;
|
|
119
|
+
}
|
|
120
|
+
if (this.flushDepth === this.lastFlushDepth) if (this.flushDepth > 0) this.parseAndAppend(this.prepareAddition(fragment), true);
|
|
121
|
+
else {
|
|
122
|
+
this.value = JSON.parse(fragment);
|
|
123
|
+
this.valueStack = {
|
|
124
|
+
value: this.value,
|
|
125
|
+
prev: null
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
else if (this.flushDepth > this.lastFlushDepth) {
|
|
129
|
+
for(let i = this.flushDepth - 1; i >= this.lastFlushDepth; i--)fragment += this.stack[i] === STACK_OBJECT ? '}' : ']';
|
|
130
|
+
if (0 === this.lastFlushDepth) {
|
|
131
|
+
this.value = JSON.parse(fragment);
|
|
132
|
+
this.valueStack = {
|
|
133
|
+
value: this.value,
|
|
134
|
+
prev: null
|
|
135
|
+
};
|
|
136
|
+
} else this.parseAndAppend(this.prepareAddition(fragment), true);
|
|
137
|
+
for(let i = this.lastFlushDepth || 1; i < this.flushDepth; i++){
|
|
138
|
+
let value = this.valueStack.value;
|
|
139
|
+
if (this.stack[i - 1] === STACK_OBJECT) {
|
|
140
|
+
let key;
|
|
141
|
+
for(key in value);
|
|
142
|
+
value = value[key];
|
|
143
|
+
} else value = value[value.length - 1];
|
|
144
|
+
this.valueStack = {
|
|
145
|
+
value,
|
|
146
|
+
prev: this.valueStack
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
fragment = this.prepareAddition(fragment);
|
|
151
|
+
for(let i = this.lastFlushDepth - 1; i >= this.flushDepth; i--){
|
|
152
|
+
this.jsonParseOffset--;
|
|
153
|
+
fragment = (this.stack[i] === STACK_OBJECT ? '{' : '[') + fragment;
|
|
154
|
+
}
|
|
155
|
+
this.parseAndAppend(fragment, false);
|
|
156
|
+
for(let i = this.lastFlushDepth - 1; i >= this.flushDepth; i--)this.valueStack = this.valueStack.prev;
|
|
157
|
+
}
|
|
158
|
+
this.lastFlushDepth = this.flushDepth;
|
|
159
|
+
}
|
|
160
|
+
push(chunk) {
|
|
161
|
+
if ('string' != typeof chunk) {
|
|
162
|
+
if (null !== this.pendingByteSeq) {
|
|
163
|
+
const origRawChunk = chunk;
|
|
164
|
+
chunk = new Uint8Array(this.pendingByteSeq.length + origRawChunk.length);
|
|
165
|
+
chunk.set(this.pendingByteSeq);
|
|
166
|
+
chunk.set(origRawChunk, this.pendingByteSeq.length);
|
|
167
|
+
this.pendingByteSeq = null;
|
|
168
|
+
}
|
|
169
|
+
if (chunk[chunk.length - 1] > 127) for(let seqLength = 0; seqLength < chunk.length; seqLength++){
|
|
170
|
+
const byte = chunk[chunk.length - 1 - seqLength];
|
|
171
|
+
if (byte >> 6 === 3) {
|
|
172
|
+
seqLength++;
|
|
173
|
+
if (4 !== seqLength && byte >> 3 === 30 || 3 !== seqLength && byte >> 4 === 14 || 2 !== seqLength && byte >> 5 === 6) {
|
|
174
|
+
this.pendingByteSeq = chunk.slice(chunk.length - seqLength);
|
|
175
|
+
chunk = chunk.slice(0, -seqLength);
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
chunk = decoder.decode(chunk);
|
|
181
|
+
}
|
|
182
|
+
const chunkLength = chunk.length;
|
|
183
|
+
let lastFlushPoint = 0;
|
|
184
|
+
let flushPoint = 0;
|
|
185
|
+
scan: for(let i = 0; i < chunkLength; i++){
|
|
186
|
+
if (this.stateString) {
|
|
187
|
+
for(; i < chunkLength; i++)if (this.stateStringEscape) this.stateStringEscape = false;
|
|
188
|
+
else switch(chunk.charCodeAt(i)){
|
|
189
|
+
case 0x22:
|
|
190
|
+
this.stateString = false;
|
|
191
|
+
continue scan;
|
|
192
|
+
case 0x5C:
|
|
193
|
+
this.stateStringEscape = true;
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
switch(chunk.charCodeAt(i)){
|
|
198
|
+
case 0x22:
|
|
199
|
+
this.stateString = true;
|
|
200
|
+
this.stateStringEscape = false;
|
|
201
|
+
break;
|
|
202
|
+
case 0x2C:
|
|
203
|
+
flushPoint = i;
|
|
204
|
+
break;
|
|
205
|
+
case 0x7B:
|
|
206
|
+
flushPoint = i + 1;
|
|
207
|
+
this.stack[this.flushDepth++] = STACK_OBJECT;
|
|
208
|
+
break;
|
|
209
|
+
case 0x5B:
|
|
210
|
+
flushPoint = i + 1;
|
|
211
|
+
this.stack[this.flushDepth++] = STACK_ARRAY;
|
|
212
|
+
break;
|
|
213
|
+
case 0x5D:
|
|
214
|
+
case 0x7D:
|
|
215
|
+
flushPoint = i + 1;
|
|
216
|
+
this.flushDepth--;
|
|
217
|
+
if (this.flushDepth < this.lastFlushDepth) {
|
|
218
|
+
this.flush(chunk, lastFlushPoint, flushPoint);
|
|
219
|
+
lastFlushPoint = flushPoint;
|
|
220
|
+
}
|
|
221
|
+
break;
|
|
222
|
+
case 0x09:
|
|
223
|
+
case 0x0A:
|
|
224
|
+
case 0x0D:
|
|
225
|
+
case 0x20:
|
|
226
|
+
if (lastFlushPoint === i) lastFlushPoint++;
|
|
227
|
+
if (flushPoint === i) flushPoint++;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (flushPoint > lastFlushPoint) this.flush(chunk, lastFlushPoint, flushPoint);
|
|
232
|
+
if (flushPoint < chunkLength) if (null !== this.pendingChunk) this.pendingChunk += chunk;
|
|
233
|
+
else this.pendingChunk = chunk.slice(flushPoint, chunkLength);
|
|
234
|
+
this.chunkOffset += chunkLength;
|
|
235
|
+
}
|
|
236
|
+
finish() {
|
|
237
|
+
if (null !== this.pendingChunk) {
|
|
238
|
+
this.flush('', 0, 0);
|
|
239
|
+
this.pendingChunk = null;
|
|
240
|
+
}
|
|
241
|
+
return this.value;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
"../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/stringify-info.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
246
|
+
const { normalizeReplacer, normalizeSpace, replaceValue, getTypeNative, getTypeAsync, isLeadingSurrogate, isTrailingSurrogate, escapableCharCodeSubstitution, type: { PRIMITIVE, OBJECT, ARRAY, PROMISE, STRING_STREAM, OBJECT_STREAM } } = __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/utils.js");
|
|
247
|
+
const charLength2048 = Array.from({
|
|
248
|
+
length: 2048
|
|
249
|
+
}).map((_, code)=>{
|
|
250
|
+
if (escapableCharCodeSubstitution.hasOwnProperty(code)) return 2;
|
|
251
|
+
if (code < 0x20) return 6;
|
|
252
|
+
return code < 128 ? 1 : 2;
|
|
253
|
+
});
|
|
254
|
+
function stringLength(str) {
|
|
255
|
+
let len = 0;
|
|
256
|
+
let prevLeadingSurrogate = false;
|
|
257
|
+
for(let i = 0; i < str.length; i++){
|
|
258
|
+
const code = str.charCodeAt(i);
|
|
259
|
+
if (code < 2048) len += charLength2048[code];
|
|
260
|
+
else if (isLeadingSurrogate(code)) {
|
|
261
|
+
len += 6;
|
|
262
|
+
prevLeadingSurrogate = true;
|
|
263
|
+
continue;
|
|
264
|
+
} else if (isTrailingSurrogate(code)) len = prevLeadingSurrogate ? len - 2 : len + 6;
|
|
265
|
+
else len += 3;
|
|
266
|
+
prevLeadingSurrogate = false;
|
|
267
|
+
}
|
|
268
|
+
return len + 2;
|
|
269
|
+
}
|
|
270
|
+
function primitiveLength(value) {
|
|
271
|
+
switch(typeof value){
|
|
272
|
+
case 'string':
|
|
273
|
+
return stringLength(value);
|
|
274
|
+
case 'number':
|
|
275
|
+
return Number.isFinite(value) ? String(value).length : 4;
|
|
276
|
+
case 'boolean':
|
|
277
|
+
return value ? 4 : 5;
|
|
278
|
+
case 'undefined':
|
|
279
|
+
case 'object':
|
|
280
|
+
return 4;
|
|
281
|
+
default:
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function spaceLength(space) {
|
|
286
|
+
space = normalizeSpace(space);
|
|
287
|
+
return 'string' == typeof space ? space.length : 0;
|
|
288
|
+
}
|
|
289
|
+
module.exports = function(value, replacer, space, options) {
|
|
290
|
+
function walk(holder, key, value) {
|
|
291
|
+
if (stop) return;
|
|
292
|
+
value = replaceValue(holder, key, value, replacer);
|
|
293
|
+
let type = getType(value);
|
|
294
|
+
if (type !== PRIMITIVE && stack.has(value)) {
|
|
295
|
+
circular.add(value);
|
|
296
|
+
length += 4;
|
|
297
|
+
if (!options.continueOnCircular) stop = true;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
switch(type){
|
|
301
|
+
case PRIMITIVE:
|
|
302
|
+
if (void 0 !== value || Array.isArray(holder)) length += primitiveLength(value);
|
|
303
|
+
else if (holder === root) length += 9;
|
|
304
|
+
break;
|
|
305
|
+
case OBJECT:
|
|
306
|
+
{
|
|
307
|
+
if (visited.has(value)) {
|
|
308
|
+
duplicate.add(value);
|
|
309
|
+
length += visited.get(value);
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
const valueLength = length;
|
|
313
|
+
let entries = 0;
|
|
314
|
+
length += 2;
|
|
315
|
+
stack.add(value);
|
|
316
|
+
for(const key in value)if (hasOwnProperty.call(value, key) && (null === allowlist || allowlist.has(key))) {
|
|
317
|
+
const prevLength = length;
|
|
318
|
+
walk(value, key, value[key]);
|
|
319
|
+
if (prevLength !== length) {
|
|
320
|
+
length += stringLength(key) + 1;
|
|
321
|
+
entries++;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (entries > 1) length += entries - 1;
|
|
325
|
+
stack.delete(value);
|
|
326
|
+
if (space > 0 && entries > 0) {
|
|
327
|
+
length += (1 + (stack.size + 1) * space + 1) * entries;
|
|
328
|
+
length += 1 + stack.size * space;
|
|
329
|
+
}
|
|
330
|
+
visited.set(value, length - valueLength);
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
case ARRAY:
|
|
334
|
+
{
|
|
335
|
+
if (visited.has(value)) {
|
|
336
|
+
duplicate.add(value);
|
|
337
|
+
length += visited.get(value);
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
const valueLength = length;
|
|
341
|
+
length += 2;
|
|
342
|
+
stack.add(value);
|
|
343
|
+
for(let i = 0; i < value.length; i++)walk(value, i, value[i]);
|
|
344
|
+
if (value.length > 1) length += value.length - 1;
|
|
345
|
+
stack.delete(value);
|
|
346
|
+
if (space > 0 && value.length > 0) {
|
|
347
|
+
length += (1 + (stack.size + 1) * space) * value.length;
|
|
348
|
+
length += 1 + stack.size * space;
|
|
349
|
+
}
|
|
350
|
+
visited.set(value, length - valueLength);
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case PROMISE:
|
|
354
|
+
case STRING_STREAM:
|
|
355
|
+
async.add(value);
|
|
356
|
+
break;
|
|
357
|
+
case OBJECT_STREAM:
|
|
358
|
+
length += 2;
|
|
359
|
+
async.add(value);
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
let allowlist = null;
|
|
364
|
+
replacer = normalizeReplacer(replacer);
|
|
365
|
+
if (Array.isArray(replacer)) {
|
|
366
|
+
allowlist = new Set(replacer);
|
|
367
|
+
replacer = null;
|
|
368
|
+
}
|
|
369
|
+
space = spaceLength(space);
|
|
370
|
+
options = options || {};
|
|
371
|
+
const visited = new Map();
|
|
372
|
+
const stack = new Set();
|
|
373
|
+
const duplicate = new Set();
|
|
374
|
+
const circular = new Set();
|
|
375
|
+
const async = new Set();
|
|
376
|
+
const getType = options.async ? getTypeAsync : getTypeNative;
|
|
377
|
+
const root = {
|
|
378
|
+
'': value
|
|
379
|
+
};
|
|
380
|
+
let stop = false;
|
|
381
|
+
let length = 0;
|
|
382
|
+
walk(root, '', value);
|
|
383
|
+
return {
|
|
384
|
+
minLength: isNaN(length) ? 1 / 0 : length,
|
|
385
|
+
circular: [
|
|
386
|
+
...circular
|
|
387
|
+
],
|
|
388
|
+
duplicate: [
|
|
389
|
+
...duplicate
|
|
390
|
+
],
|
|
391
|
+
async: [
|
|
392
|
+
...async
|
|
393
|
+
]
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
},
|
|
397
|
+
"../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/stringify-stream.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
398
|
+
const { Readable } = __webpack_require__("stream");
|
|
399
|
+
const { normalizeReplacer, normalizeSpace, replaceValue, getTypeAsync, type: { PRIMITIVE, OBJECT, ARRAY, PROMISE, STRING_STREAM, OBJECT_STREAM } } = __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/utils.js");
|
|
400
|
+
const noop = ()=>{};
|
|
401
|
+
const hasOwnProperty1 = Object.prototype.hasOwnProperty;
|
|
402
|
+
const wellformedStringStringify = '"\\ud800"' === JSON.stringify('\ud800') ? JSON.stringify : (s)=>JSON.stringify(s).replace(/\p{Surrogate}/gu, (m)=>`\\u${m.charCodeAt(0).toString(16)}`);
|
|
403
|
+
function push() {
|
|
404
|
+
this.push(this._stack.value);
|
|
405
|
+
this.popStack();
|
|
406
|
+
}
|
|
407
|
+
function pushPrimitive(value) {
|
|
408
|
+
switch(typeof value){
|
|
409
|
+
case 'string':
|
|
410
|
+
this.push(this.encodeString(value));
|
|
411
|
+
break;
|
|
412
|
+
case 'number':
|
|
413
|
+
this.push(Number.isFinite(value) ? this.encodeNumber(value) : 'null');
|
|
414
|
+
break;
|
|
415
|
+
case 'boolean':
|
|
416
|
+
this.push(value ? 'true' : 'false');
|
|
417
|
+
break;
|
|
418
|
+
case 'undefined':
|
|
419
|
+
case 'object':
|
|
420
|
+
this.push('null');
|
|
421
|
+
break;
|
|
422
|
+
default:
|
|
423
|
+
this.destroy(new TypeError(`Do not know how to serialize a ${value.constructor && value.constructor.name || typeof value}`));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function processObjectEntry(key) {
|
|
427
|
+
const current = this._stack;
|
|
428
|
+
if (current.first) this.push(',');
|
|
429
|
+
else current.first = true;
|
|
430
|
+
if (this.space) this.push(`\n${this.space.repeat(this._depth)}${this.encodeString(key)}: `);
|
|
431
|
+
else this.push(this.encodeString(key) + ':');
|
|
432
|
+
}
|
|
433
|
+
function processObject() {
|
|
434
|
+
const current = this._stack;
|
|
435
|
+
if (current.index === current.keys.length) {
|
|
436
|
+
if (this.space && current.first) this.push(`\n${this.space.repeat(this._depth - 1)}}`);
|
|
437
|
+
else this.push('}');
|
|
438
|
+
this.popStack();
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const key = current.keys[current.index];
|
|
442
|
+
this.processValue(current.value, key, current.value[key], processObjectEntry);
|
|
443
|
+
current.index++;
|
|
444
|
+
}
|
|
445
|
+
function processArrayItem(index) {
|
|
446
|
+
if (0 !== index) this.push(',');
|
|
447
|
+
if (this.space) this.push(`\n${this.space.repeat(this._depth)}`);
|
|
448
|
+
}
|
|
449
|
+
function processArray() {
|
|
450
|
+
const current = this._stack;
|
|
451
|
+
if (current.index === current.value.length) {
|
|
452
|
+
if (this.space && current.index > 0) this.push(`\n${this.space.repeat(this._depth - 1)}]`);
|
|
453
|
+
else this.push(']');
|
|
454
|
+
this.popStack();
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
this.processValue(current.value, current.index, current.value[current.index], processArrayItem);
|
|
458
|
+
current.index++;
|
|
459
|
+
}
|
|
460
|
+
function createStreamReader(fn) {
|
|
461
|
+
return function() {
|
|
462
|
+
const current = this._stack;
|
|
463
|
+
const data = current.value.read(this._readSize);
|
|
464
|
+
if (null !== data) {
|
|
465
|
+
current.first = false;
|
|
466
|
+
fn.call(this, data, current);
|
|
467
|
+
} else if (current.first && !current.value._readableState.reading || current.ended) this.popStack();
|
|
468
|
+
else {
|
|
469
|
+
current.first = true;
|
|
470
|
+
current.awaiting = true;
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const processReadableObject = createStreamReader(function(data, current) {
|
|
475
|
+
this.processValue(current.value, current.index, data, processArrayItem);
|
|
476
|
+
current.index++;
|
|
477
|
+
});
|
|
478
|
+
const processReadableString = createStreamReader(function(data) {
|
|
479
|
+
this.push(data);
|
|
480
|
+
});
|
|
481
|
+
class JsonStringifyStream extends Readable {
|
|
482
|
+
constructor(value, replacer, space){
|
|
483
|
+
super({
|
|
484
|
+
autoDestroy: true
|
|
485
|
+
});
|
|
486
|
+
this.getKeys = Object.keys;
|
|
487
|
+
this.replacer = normalizeReplacer(replacer);
|
|
488
|
+
if (Array.isArray(this.replacer)) {
|
|
489
|
+
const allowlist = this.replacer;
|
|
490
|
+
this.getKeys = (value)=>allowlist.filter((key)=>hasOwnProperty1.call(value, key));
|
|
491
|
+
this.replacer = null;
|
|
492
|
+
}
|
|
493
|
+
this.space = normalizeSpace(space);
|
|
494
|
+
this._depth = 0;
|
|
495
|
+
this.error = null;
|
|
496
|
+
this._processing = false;
|
|
497
|
+
this._ended = false;
|
|
498
|
+
this._readSize = 0;
|
|
499
|
+
this._buffer = '';
|
|
500
|
+
this._stack = null;
|
|
501
|
+
this._visited = new WeakSet();
|
|
502
|
+
this.pushStack({
|
|
503
|
+
handler: ()=>{
|
|
504
|
+
this.popStack();
|
|
505
|
+
this.processValue({
|
|
506
|
+
'': value
|
|
507
|
+
}, '', value, noop);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
encodeString(value) {
|
|
512
|
+
if (/[^\x20-\uD799]|[\x22\x5c]/.test(value)) return wellformedStringStringify(value);
|
|
513
|
+
return '"' + value + '"';
|
|
514
|
+
}
|
|
515
|
+
encodeNumber(value) {
|
|
516
|
+
return value;
|
|
517
|
+
}
|
|
518
|
+
processValue(holder, key, value, callback) {
|
|
519
|
+
value = replaceValue(holder, key, value, this.replacer);
|
|
520
|
+
let type = getTypeAsync(value);
|
|
521
|
+
switch(type){
|
|
522
|
+
case PRIMITIVE:
|
|
523
|
+
if (callback !== processObjectEntry || void 0 !== value) {
|
|
524
|
+
callback.call(this, key);
|
|
525
|
+
pushPrimitive.call(this, value);
|
|
526
|
+
}
|
|
527
|
+
break;
|
|
528
|
+
case OBJECT:
|
|
529
|
+
callback.call(this, key);
|
|
530
|
+
if (this._visited.has(value)) return this.destroy(new TypeError('Converting circular structure to JSON'));
|
|
531
|
+
this._visited.add(value);
|
|
532
|
+
this._depth++;
|
|
533
|
+
this.push('{');
|
|
534
|
+
this.pushStack({
|
|
535
|
+
handler: processObject,
|
|
536
|
+
value,
|
|
537
|
+
index: 0,
|
|
538
|
+
first: false,
|
|
539
|
+
keys: this.getKeys(value)
|
|
540
|
+
});
|
|
541
|
+
break;
|
|
542
|
+
case ARRAY:
|
|
543
|
+
callback.call(this, key);
|
|
544
|
+
if (this._visited.has(value)) return this.destroy(new TypeError('Converting circular structure to JSON'));
|
|
545
|
+
this._visited.add(value);
|
|
546
|
+
this.push('[');
|
|
547
|
+
this.pushStack({
|
|
548
|
+
handler: processArray,
|
|
549
|
+
value,
|
|
550
|
+
index: 0
|
|
551
|
+
});
|
|
552
|
+
this._depth++;
|
|
553
|
+
break;
|
|
554
|
+
case PROMISE:
|
|
555
|
+
this.pushStack({
|
|
556
|
+
handler: noop,
|
|
557
|
+
awaiting: true
|
|
558
|
+
});
|
|
559
|
+
Promise.resolve(value).then((resolved)=>{
|
|
560
|
+
this.popStack();
|
|
561
|
+
this.processValue(holder, key, resolved, callback);
|
|
562
|
+
this.processStack();
|
|
563
|
+
}).catch((error)=>{
|
|
564
|
+
this.destroy(error);
|
|
565
|
+
});
|
|
566
|
+
break;
|
|
567
|
+
case STRING_STREAM:
|
|
568
|
+
case OBJECT_STREAM:
|
|
569
|
+
callback.call(this, key);
|
|
570
|
+
if (value.readableEnded || value._readableState.endEmitted) return this.destroy(new Error('Readable Stream has ended before it was serialized. All stream data have been lost'));
|
|
571
|
+
if (value.readableFlowing) return this.destroy(new Error('Readable Stream is in flowing mode, data may have been lost. Trying to pause stream.'));
|
|
572
|
+
if (type === OBJECT_STREAM) {
|
|
573
|
+
this.push('[');
|
|
574
|
+
this.pushStack({
|
|
575
|
+
handler: push,
|
|
576
|
+
value: this.space ? '\n' + this.space.repeat(this._depth) + ']' : ']'
|
|
577
|
+
});
|
|
578
|
+
this._depth++;
|
|
579
|
+
}
|
|
580
|
+
const self = this.pushStack({
|
|
581
|
+
handler: type === OBJECT_STREAM ? processReadableObject : processReadableString,
|
|
582
|
+
value,
|
|
583
|
+
index: 0,
|
|
584
|
+
first: false,
|
|
585
|
+
ended: false,
|
|
586
|
+
awaiting: !value.readable || 0 === value.readableLength
|
|
587
|
+
});
|
|
588
|
+
const continueProcessing = ()=>{
|
|
589
|
+
if (self.awaiting) {
|
|
590
|
+
self.awaiting = false;
|
|
591
|
+
this.processStack();
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
value.once('error', (error)=>this.destroy(error));
|
|
595
|
+
value.once('end', ()=>{
|
|
596
|
+
self.ended = true;
|
|
597
|
+
continueProcessing();
|
|
598
|
+
});
|
|
599
|
+
value.on('readable', continueProcessing);
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
pushStack(node) {
|
|
604
|
+
node.prev = this._stack;
|
|
605
|
+
return this._stack = node;
|
|
606
|
+
}
|
|
607
|
+
popStack() {
|
|
608
|
+
const { handler, value } = this._stack;
|
|
609
|
+
if (handler === processObject || handler === processArray || handler === processReadableObject) {
|
|
610
|
+
this._visited.delete(value);
|
|
611
|
+
this._depth--;
|
|
612
|
+
}
|
|
613
|
+
this._stack = this._stack.prev;
|
|
614
|
+
}
|
|
615
|
+
processStack() {
|
|
616
|
+
if (this._processing || this._ended) return;
|
|
617
|
+
try {
|
|
618
|
+
this._processing = true;
|
|
619
|
+
while(null !== this._stack && !this._stack.awaiting){
|
|
620
|
+
this._stack.handler.call(this);
|
|
621
|
+
if (!this._processing) return;
|
|
622
|
+
}
|
|
623
|
+
this._processing = false;
|
|
624
|
+
} catch (error) {
|
|
625
|
+
this.destroy(error);
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
if (null === this._stack && !this._ended) {
|
|
629
|
+
this._finish();
|
|
630
|
+
this.push(null);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
push(data) {
|
|
634
|
+
if (null !== data) {
|
|
635
|
+
this._buffer += data;
|
|
636
|
+
if (this._buffer.length < this._readSize) return;
|
|
637
|
+
data = this._buffer;
|
|
638
|
+
this._buffer = '';
|
|
639
|
+
this._processing = false;
|
|
640
|
+
}
|
|
641
|
+
super.push(data);
|
|
642
|
+
}
|
|
643
|
+
_read(size) {
|
|
644
|
+
this._readSize = size || this.readableHighWaterMark;
|
|
645
|
+
this.processStack();
|
|
646
|
+
}
|
|
647
|
+
_finish() {
|
|
648
|
+
this._ended = true;
|
|
649
|
+
this._processing = false;
|
|
650
|
+
this._stack = null;
|
|
651
|
+
this._visited = null;
|
|
652
|
+
if (this._buffer && this._buffer.length) super.push(this._buffer);
|
|
653
|
+
this._buffer = '';
|
|
654
|
+
}
|
|
655
|
+
_destroy(error, cb) {
|
|
656
|
+
this.error = this.error || error;
|
|
657
|
+
this._finish();
|
|
658
|
+
cb(error);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
module.exports = function(value, replacer, space) {
|
|
662
|
+
return new JsonStringifyStream(value, replacer, space);
|
|
663
|
+
};
|
|
664
|
+
},
|
|
665
|
+
"../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/text-decoder.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
666
|
+
module.exports = __webpack_require__("util").TextDecoder;
|
|
667
|
+
},
|
|
668
|
+
"../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/utils.js" (module) {
|
|
669
|
+
const PrimitiveType = 1;
|
|
670
|
+
const ObjectType = 2;
|
|
671
|
+
const ArrayType = 3;
|
|
672
|
+
const PromiseType = 4;
|
|
673
|
+
const ReadableStringType = 5;
|
|
674
|
+
const ReadableObjectType = 6;
|
|
675
|
+
const escapableCharCodeSubstitution = {
|
|
676
|
+
0x08: '\\b',
|
|
677
|
+
0x09: '\\t',
|
|
678
|
+
0x0a: '\\n',
|
|
679
|
+
0x0c: '\\f',
|
|
680
|
+
0x0d: '\\r',
|
|
681
|
+
0x22: '\\\"',
|
|
682
|
+
0x5c: '\\\\'
|
|
683
|
+
};
|
|
684
|
+
function isLeadingSurrogate(code) {
|
|
685
|
+
return code >= 0xD800 && code <= 0xDBFF;
|
|
686
|
+
}
|
|
687
|
+
function isTrailingSurrogate(code) {
|
|
688
|
+
return code >= 0xDC00 && code <= 0xDFFF;
|
|
689
|
+
}
|
|
690
|
+
function isReadableStream(value) {
|
|
691
|
+
return 'function' == typeof value.pipe && 'function' == typeof value._read && 'object' == typeof value._readableState && null !== value._readableState;
|
|
692
|
+
}
|
|
693
|
+
function replaceValue(holder, key, value, replacer) {
|
|
694
|
+
if (value && 'function' == typeof value.toJSON) value = value.toJSON();
|
|
695
|
+
if (null !== replacer) value = replacer.call(holder, String(key), value);
|
|
696
|
+
switch(typeof value){
|
|
697
|
+
case 'function':
|
|
698
|
+
case 'symbol':
|
|
699
|
+
value = void 0;
|
|
700
|
+
break;
|
|
701
|
+
case 'object':
|
|
702
|
+
if (null !== value) {
|
|
703
|
+
const cls = value.constructor;
|
|
704
|
+
if (cls === String || cls === Number || cls === Boolean) value = value.valueOf();
|
|
705
|
+
}
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
return value;
|
|
709
|
+
}
|
|
710
|
+
function getTypeNative(value) {
|
|
711
|
+
if (null === value || 'object' != typeof value) return PrimitiveType;
|
|
712
|
+
if (Array.isArray(value)) return ArrayType;
|
|
713
|
+
return ObjectType;
|
|
714
|
+
}
|
|
715
|
+
function getTypeAsync(value) {
|
|
716
|
+
if (null === value || 'object' != typeof value) return PrimitiveType;
|
|
717
|
+
if ('function' == typeof value.then) return PromiseType;
|
|
718
|
+
if (isReadableStream(value)) return value._readableState.objectMode ? ReadableObjectType : ReadableStringType;
|
|
719
|
+
if (Array.isArray(value)) return ArrayType;
|
|
720
|
+
return ObjectType;
|
|
721
|
+
}
|
|
722
|
+
function normalizeReplacer(replacer) {
|
|
723
|
+
if ('function' == typeof replacer) return replacer;
|
|
724
|
+
if (Array.isArray(replacer)) {
|
|
725
|
+
const allowlist = new Set(replacer.map((item)=>{
|
|
726
|
+
const cls = item && item.constructor;
|
|
727
|
+
return cls === String || cls === Number ? String(item) : null;
|
|
728
|
+
}).filter((item)=>'string' == typeof item));
|
|
729
|
+
return [
|
|
730
|
+
...allowlist
|
|
731
|
+
];
|
|
732
|
+
}
|
|
733
|
+
return null;
|
|
734
|
+
}
|
|
735
|
+
function normalizeSpace(space) {
|
|
736
|
+
if ('number' == typeof space) {
|
|
737
|
+
if (!Number.isFinite(space) || space < 1) return false;
|
|
738
|
+
return ' '.repeat(Math.min(space, 10));
|
|
739
|
+
}
|
|
740
|
+
if ('string' == typeof space) return space.slice(0, 10) || false;
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
module.exports = {
|
|
744
|
+
escapableCharCodeSubstitution,
|
|
745
|
+
isLeadingSurrogate,
|
|
746
|
+
isTrailingSurrogate,
|
|
747
|
+
type: {
|
|
748
|
+
PRIMITIVE: PrimitiveType,
|
|
749
|
+
PROMISE: PromiseType,
|
|
750
|
+
ARRAY: ArrayType,
|
|
751
|
+
OBJECT: ObjectType,
|
|
752
|
+
STRING_STREAM: ReadableStringType,
|
|
753
|
+
OBJECT_STREAM: ReadableObjectType
|
|
754
|
+
},
|
|
755
|
+
isReadableStream,
|
|
756
|
+
replaceValue,
|
|
757
|
+
getTypeNative,
|
|
758
|
+
getTypeAsync,
|
|
759
|
+
normalizeReplacer,
|
|
760
|
+
normalizeSpace
|
|
761
|
+
};
|
|
762
|
+
},
|
|
763
|
+
"../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/version.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
764
|
+
module.exports = __webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/package.json").version;
|
|
765
|
+
},
|
|
766
|
+
"../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/package.json" (module) {
|
|
767
|
+
module.exports = {
|
|
768
|
+
version: "0.5.7"
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
__webpack_require__("../../node_modules/.pnpm/@discoveryjs+json-ext@0.5.7/node_modules/@discoveryjs/json-ext/src/index.js");
|