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