@rife/logger 0.0.6-beta.16 → 0.0.6-beta.18
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/cjs/common.cjs +9 -5
- package/dist/cjs/env.cjs +13 -9
- package/dist/cjs/index.cjs +9 -5
- package/dist/cjs/pino/index.cjs +9 -5
- package/dist/cjs/pino/rotate.cjs +12 -8
- package/dist/cjs/pino/worker/pino-file.cjs +177 -93
- package/dist/cjs/pino/worker/pino-pretty.cjs +9 -19
- package/dist/cjs/pino/worker/pino-rotate.cjs +12 -8
- package/dist/cjs/pino/worker/pino-worker.cjs +177 -93
- package/dist/cjs/pino/worker/thread-stream.cjs +107 -13
- package/dist/cjs/trace.cjs +9 -5
- package/dist/esm/common.mjs +2 -2
- package/dist/esm/pino/index.mjs +10 -10
- package/dist/esm/pino/rotate.mjs +2 -2
- package/dist/esm/pino/worker/pino-file.cjs +177 -93
- package/dist/esm/pino/worker/pino-pretty.cjs +9 -19
- package/dist/esm/pino/worker/pino-rotate.cjs +12 -8
- package/dist/esm/pino/worker/pino-worker.cjs +177 -93
- package/dist/esm/pino/worker/thread-stream.cjs +107 -13
- package/dist/worker/pino-file.cjs +177 -93
- package/dist/worker/pino-pretty.cjs +9 -19
- package/dist/worker/pino-rotate.cjs +12 -8
- package/dist/worker/pino-worker.cjs +177 -93
- package/dist/worker/thread-stream.cjs +107 -13
- package/package.json +3 -3
- package/src/pino/index.ts +3 -4
|
@@ -554,11 +554,15 @@ function __webpack_require__(moduleId) {
|
|
|
554
554
|
return module1.exports;
|
|
555
555
|
}
|
|
556
556
|
(()=>{
|
|
557
|
-
__webpack_require__.d = (exports,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
557
|
+
__webpack_require__.d = (exports, getters, values)=>{
|
|
558
|
+
var define = (defs, kind)=>{
|
|
559
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
560
|
+
enumerable: true,
|
|
561
|
+
[kind]: defs[key]
|
|
562
|
+
});
|
|
563
|
+
};
|
|
564
|
+
define(getters, "get");
|
|
565
|
+
define(values, "value");
|
|
562
566
|
};
|
|
563
567
|
})();
|
|
564
568
|
(()=>{
|
|
@@ -577,9 +581,6 @@ function __webpack_require__(moduleId) {
|
|
|
577
581
|
var __webpack_exports__ = {};
|
|
578
582
|
(()=>{
|
|
579
583
|
__webpack_require__.r(__webpack_exports__);
|
|
580
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
581
|
-
default: ()=>__rspack_default_export
|
|
582
|
-
});
|
|
583
584
|
const generator = (time, index)=>{
|
|
584
585
|
if (!time) return 'server.log';
|
|
585
586
|
time = new Date(time);
|
|
@@ -601,5 +602,8 @@ var __webpack_exports__ = {};
|
|
|
601
602
|
path
|
|
602
603
|
});
|
|
603
604
|
};
|
|
605
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
606
|
+
default: __rspack_default_export
|
|
607
|
+
});
|
|
604
608
|
})();
|
|
605
609
|
module.exports = __webpack_exports__;
|
|
@@ -1151,19 +1151,32 @@ var __webpack_modules__ = {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
module1.exports = split;
|
|
1153
1153
|
},
|
|
1154
|
-
"../../node_modules/.pnpm/thread-stream@4.
|
|
1154
|
+
"../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/index.js" (module1, __unused_rspack_exports, __webpack_require__) {
|
|
1155
1155
|
"use strict";
|
|
1156
|
-
const { version } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.
|
|
1156
|
+
const { version } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/package.json");
|
|
1157
1157
|
const { EventEmitter } = __webpack_require__("events");
|
|
1158
1158
|
const { Worker } = __webpack_require__("worker_threads");
|
|
1159
1159
|
const { join } = __webpack_require__("path");
|
|
1160
1160
|
const { pathToFileURL } = __webpack_require__("url");
|
|
1161
|
-
const { wait } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.
|
|
1162
|
-
const { WRITE_INDEX, READ_INDEX } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.
|
|
1161
|
+
const { wait } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/wait.js");
|
|
1162
|
+
const { WRITE_INDEX, READ_INDEX, SEQ_INDEX } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/indexes.js");
|
|
1163
1163
|
const buffer = __webpack_require__("buffer");
|
|
1164
1164
|
const assert = __webpack_require__("assert");
|
|
1165
1165
|
const kImpl = Symbol('kImpl');
|
|
1166
1166
|
const MAX_STRING = buffer.constants.MAX_STRING_LENGTH;
|
|
1167
|
+
function noop() {}
|
|
1168
|
+
function updateState(stream, fn) {
|
|
1169
|
+
Atomics.add(stream[kImpl].state, SEQ_INDEX, 1);
|
|
1170
|
+
fn();
|
|
1171
|
+
Atomics.add(stream[kImpl].state, SEQ_INDEX, 1);
|
|
1172
|
+
Atomics.notify(stream[kImpl].state, SEQ_INDEX);
|
|
1173
|
+
}
|
|
1174
|
+
function resetIndexes(stream) {
|
|
1175
|
+
updateState(stream, ()=>{
|
|
1176
|
+
Atomics.store(stream[kImpl].state, READ_INDEX, 0);
|
|
1177
|
+
Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1167
1180
|
class FakeWeakRef {
|
|
1168
1181
|
constructor(value){
|
|
1169
1182
|
this._value = value;
|
|
@@ -1188,6 +1201,7 @@ var __webpack_modules__ = {
|
|
|
1188
1201
|
const toExecute = bundlerOverrides['thread-stream-worker'] || join(__dirname, 'lib', 'worker.js');
|
|
1189
1202
|
const worker = new Worker(toExecute, {
|
|
1190
1203
|
...opts.workerOpts,
|
|
1204
|
+
name: opts.workerOpts?.name || 'thread-stream',
|
|
1191
1205
|
trackUnmanagedFds: false,
|
|
1192
1206
|
workerData: {
|
|
1193
1207
|
filename: 0 === filename.indexOf('file://') ? filename : pathToFileURL(filename).href,
|
|
@@ -1215,42 +1229,31 @@ var __webpack_modules__ = {
|
|
|
1215
1229
|
}
|
|
1216
1230
|
}
|
|
1217
1231
|
function nextFlush(stream) {
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
if (
|
|
1222
|
-
stream[kImpl].
|
|
1223
|
-
|
|
1224
|
-
|
|
1232
|
+
while(true){
|
|
1233
|
+
const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
|
|
1234
|
+
const leftover = stream[kImpl].data.length - writeIndex;
|
|
1235
|
+
if (leftover > 0) {
|
|
1236
|
+
if (0 === stream[kImpl].bufLen) {
|
|
1237
|
+
stream[kImpl].flushing = false;
|
|
1238
|
+
if (stream[kImpl].ending) end(stream);
|
|
1239
|
+
else if (stream[kImpl].needDrain) process.nextTick(drain, stream);
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
write(stream, leftover, noop);
|
|
1243
|
+
continue;
|
|
1244
|
+
}
|
|
1245
|
+
if (0 === leftover) {
|
|
1246
|
+
if (0 === writeIndex && 0 === stream[kImpl].bufLen) return;
|
|
1247
|
+
waitForRead(stream, ()=>{
|
|
1248
|
+
if (stream.destroyed) return;
|
|
1249
|
+
resetIndexes(stream);
|
|
1250
|
+
nextFlush(stream);
|
|
1251
|
+
});
|
|
1225
1252
|
return;
|
|
1226
1253
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
|
|
1231
|
-
write(stream, toWrite, nextFlush.bind(null, stream));
|
|
1232
|
-
} else stream.flush(()=>{
|
|
1233
|
-
if (stream.destroyed) return;
|
|
1234
|
-
Atomics.store(stream[kImpl].state, READ_INDEX, 0);
|
|
1235
|
-
Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
|
|
1236
|
-
Atomics.notify(stream[kImpl].state, READ_INDEX);
|
|
1237
|
-
while(toWriteBytes > stream[kImpl].data.length){
|
|
1238
|
-
leftover /= 2;
|
|
1239
|
-
toWrite = stream[kImpl].buf.slice(0, leftover);
|
|
1240
|
-
toWriteBytes = Buffer.byteLength(toWrite);
|
|
1241
|
-
}
|
|
1242
|
-
stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
|
|
1243
|
-
write(stream, toWrite, nextFlush.bind(null, stream));
|
|
1244
|
-
});
|
|
1245
|
-
} else if (0 === leftover) {
|
|
1246
|
-
if (0 === writeIndex && 0 === stream[kImpl].buf.length) return;
|
|
1247
|
-
stream.flush(()=>{
|
|
1248
|
-
Atomics.store(stream[kImpl].state, READ_INDEX, 0);
|
|
1249
|
-
Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
|
|
1250
|
-
Atomics.notify(stream[kImpl].state, READ_INDEX);
|
|
1251
|
-
nextFlush(stream);
|
|
1252
|
-
});
|
|
1253
|
-
} else destroy(stream, new Error('overwritten'));
|
|
1254
|
+
destroy(stream, new Error('overwritten'));
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1254
1257
|
}
|
|
1255
1258
|
function onWorkerMessage(msg) {
|
|
1256
1259
|
const stream = this.stream.deref();
|
|
@@ -1259,10 +1262,11 @@ var __webpack_modules__ = {
|
|
|
1259
1262
|
this.terminate();
|
|
1260
1263
|
return;
|
|
1261
1264
|
}
|
|
1265
|
+
if (msg?.code == null) return;
|
|
1262
1266
|
switch(msg.code){
|
|
1263
1267
|
case 'READY':
|
|
1264
1268
|
this.stream = new WeakRef1(stream);
|
|
1265
|
-
stream
|
|
1269
|
+
waitForRead(stream, ()=>{
|
|
1266
1270
|
stream[kImpl].ready = true;
|
|
1267
1271
|
stream.emit('ready');
|
|
1268
1272
|
});
|
|
@@ -1274,6 +1278,19 @@ var __webpack_modules__ = {
|
|
|
1274
1278
|
if (Array.isArray(msg.args)) stream.emit(msg.name, ...msg.args);
|
|
1275
1279
|
else stream.emit(msg.name, msg.args);
|
|
1276
1280
|
break;
|
|
1281
|
+
case 'FLUSHED':
|
|
1282
|
+
{
|
|
1283
|
+
if ('thread-stream' !== msg.context) {
|
|
1284
|
+
destroy(stream, new Error('this should not happen: ' + msg.code));
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
const cb = stream[kImpl].flushCallbacks.get(msg.id);
|
|
1288
|
+
if (cb) {
|
|
1289
|
+
stream[kImpl].flushCallbacks.delete(msg.id);
|
|
1290
|
+
process.nextTick(cb);
|
|
1291
|
+
}
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1277
1294
|
case 'WARNING':
|
|
1278
1295
|
process.emitWarning(msg.err);
|
|
1279
1296
|
break;
|
|
@@ -1308,13 +1325,18 @@ var __webpack_modules__ = {
|
|
|
1308
1325
|
this[kImpl].finished = false;
|
|
1309
1326
|
this[kImpl].errored = null;
|
|
1310
1327
|
this[kImpl].closed = false;
|
|
1311
|
-
this[kImpl].buf =
|
|
1328
|
+
this[kImpl].buf = [];
|
|
1329
|
+
this[kImpl].bufHead = 0;
|
|
1330
|
+
this[kImpl].bufLen = 0;
|
|
1331
|
+
this[kImpl].flushCallbacks = new Map();
|
|
1332
|
+
this[kImpl].nextFlushId = 0;
|
|
1312
1333
|
this.worker = createWorker(this, opts);
|
|
1313
1334
|
this.on('message', (message, transferList)=>{
|
|
1314
1335
|
this.worker.postMessage(message, transferList);
|
|
1315
1336
|
});
|
|
1316
1337
|
}
|
|
1317
1338
|
write(data) {
|
|
1339
|
+
const dataBuf = Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
1318
1340
|
if (this[kImpl].destroyed) {
|
|
1319
1341
|
error(this, new Error('the worker has exited'));
|
|
1320
1342
|
return false;
|
|
@@ -1323,14 +1345,15 @@ var __webpack_modules__ = {
|
|
|
1323
1345
|
error(this, new Error('the worker is ending'));
|
|
1324
1346
|
return false;
|
|
1325
1347
|
}
|
|
1326
|
-
if (this[kImpl].flushing && this[kImpl].
|
|
1348
|
+
if (this[kImpl].flushing && this[kImpl].bufLen + dataBuf.length >= MAX_STRING) try {
|
|
1327
1349
|
writeSync(this);
|
|
1328
1350
|
this[kImpl].flushing = true;
|
|
1329
1351
|
} catch (err) {
|
|
1330
1352
|
destroy(this, err);
|
|
1331
1353
|
return false;
|
|
1332
1354
|
}
|
|
1333
|
-
this[kImpl].buf
|
|
1355
|
+
this[kImpl].buf.push(dataBuf);
|
|
1356
|
+
this[kImpl].bufLen += dataBuf.length;
|
|
1334
1357
|
if (this[kImpl].sync) try {
|
|
1335
1358
|
writeSync(this);
|
|
1336
1359
|
return true;
|
|
@@ -1342,7 +1365,7 @@ var __webpack_modules__ = {
|
|
|
1342
1365
|
this[kImpl].flushing = true;
|
|
1343
1366
|
setImmediate(nextFlush, this);
|
|
1344
1367
|
}
|
|
1345
|
-
this[kImpl].needDrain = this[kImpl].data.length - this[kImpl].
|
|
1368
|
+
this[kImpl].needDrain = this[kImpl].data.length - this[kImpl].bufLen - Atomics.load(this[kImpl].state, WRITE_INDEX) <= 0;
|
|
1346
1369
|
return !this[kImpl].needDrain;
|
|
1347
1370
|
}
|
|
1348
1371
|
end() {
|
|
@@ -1351,19 +1374,10 @@ var __webpack_modules__ = {
|
|
|
1351
1374
|
end(this);
|
|
1352
1375
|
}
|
|
1353
1376
|
flush(cb) {
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
return;
|
|
1357
|
-
|
|
1358
|
-
const writeIndex = Atomics.load(this[kImpl].state, WRITE_INDEX);
|
|
1359
|
-
wait(this[kImpl].state, READ_INDEX, writeIndex, 1 / 0, (err, res)=>{
|
|
1360
|
-
if (err) {
|
|
1361
|
-
destroy(this, err);
|
|
1362
|
-
process.nextTick(cb, err);
|
|
1363
|
-
return;
|
|
1364
|
-
}
|
|
1365
|
-
if ('not-equal' === res) return void this.flush(cb);
|
|
1366
|
-
process.nextTick(cb);
|
|
1377
|
+
cb = 'function' == typeof cb ? cb : noop;
|
|
1378
|
+
flushBuffer(this, (err)=>{
|
|
1379
|
+
if (err) return void process.nextTick(cb, err);
|
|
1380
|
+
requestWorkerFlush(this, cb);
|
|
1367
1381
|
});
|
|
1368
1382
|
}
|
|
1369
1383
|
flushSync() {
|
|
@@ -1405,6 +1419,63 @@ var __webpack_modules__ = {
|
|
|
1405
1419
|
return this[kImpl].errored;
|
|
1406
1420
|
}
|
|
1407
1421
|
}
|
|
1422
|
+
function flushBuffer(stream, cb) {
|
|
1423
|
+
if (stream[kImpl].destroyed) return void process.nextTick(cb, new Error('the worker has exited'));
|
|
1424
|
+
if (!stream[kImpl].sync && (stream[kImpl].flushing || stream[kImpl].bufLen > 0)) return void setImmediate(flushBuffer, stream, cb);
|
|
1425
|
+
waitForRead(stream, cb);
|
|
1426
|
+
}
|
|
1427
|
+
function waitForRead(stream, cb) {
|
|
1428
|
+
const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
|
|
1429
|
+
wait(stream[kImpl].state, READ_INDEX, writeIndex, 1 / 0, (err, res)=>{
|
|
1430
|
+
if (err) {
|
|
1431
|
+
destroy(stream, err);
|
|
1432
|
+
cb(err);
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
if ('ok' !== res) return void waitForRead(stream, cb);
|
|
1436
|
+
cb();
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
function requestWorkerFlush(stream, cb) {
|
|
1440
|
+
if (stream[kImpl].destroyed) return void process.nextTick(cb, new Error('the worker has exited'));
|
|
1441
|
+
if (!stream[kImpl].ready) {
|
|
1442
|
+
const onReady = ()=>{
|
|
1443
|
+
cleanup();
|
|
1444
|
+
requestWorkerFlush(stream, cb);
|
|
1445
|
+
};
|
|
1446
|
+
const onClose = ()=>{
|
|
1447
|
+
cleanup();
|
|
1448
|
+
process.nextTick(cb, new Error('the worker has exited'));
|
|
1449
|
+
};
|
|
1450
|
+
const cleanup = ()=>{
|
|
1451
|
+
stream.off('ready', onReady);
|
|
1452
|
+
stream.off('close', onClose);
|
|
1453
|
+
};
|
|
1454
|
+
stream.once('ready', onReady);
|
|
1455
|
+
stream.once('close', onClose);
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const id = ++stream[kImpl].nextFlushId;
|
|
1459
|
+
stream[kImpl].flushCallbacks.set(id, cb);
|
|
1460
|
+
try {
|
|
1461
|
+
stream.worker.postMessage({
|
|
1462
|
+
code: 'FLUSH',
|
|
1463
|
+
context: 'thread-stream',
|
|
1464
|
+
id
|
|
1465
|
+
});
|
|
1466
|
+
} catch (err) {
|
|
1467
|
+
stream[kImpl].flushCallbacks.delete(id);
|
|
1468
|
+
destroy(stream, err);
|
|
1469
|
+
process.nextTick(cb, err);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
function failPendingFlushCallbacks(stream, err) {
|
|
1473
|
+
const callbacks = stream[kImpl].flushCallbacks;
|
|
1474
|
+
if (0 === callbacks.size) return;
|
|
1475
|
+
const flushErr = err || new Error('the worker has exited');
|
|
1476
|
+
for (const cb of callbacks.values())process.nextTick(cb, flushErr);
|
|
1477
|
+
callbacks.clear();
|
|
1478
|
+
}
|
|
1408
1479
|
function error(stream, err) {
|
|
1409
1480
|
setImmediate(()=>{
|
|
1410
1481
|
stream.emit('error', err);
|
|
@@ -1413,6 +1484,7 @@ var __webpack_modules__ = {
|
|
|
1413
1484
|
function destroy(stream, err) {
|
|
1414
1485
|
if (stream[kImpl].destroyed) return;
|
|
1415
1486
|
stream[kImpl].destroyed = true;
|
|
1487
|
+
failPendingFlushCallbacks(stream, err);
|
|
1416
1488
|
if (err) {
|
|
1417
1489
|
stream[kImpl].errored = err;
|
|
1418
1490
|
error(stream, err);
|
|
@@ -1426,12 +1498,37 @@ var __webpack_modules__ = {
|
|
|
1426
1498
|
stream.emit('close');
|
|
1427
1499
|
});
|
|
1428
1500
|
}
|
|
1429
|
-
function write(stream,
|
|
1501
|
+
function write(stream, maxBytes, cb) {
|
|
1430
1502
|
const current = Atomics.load(stream[kImpl].state, WRITE_INDEX);
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1503
|
+
let offset = current;
|
|
1504
|
+
let remaining = maxBytes;
|
|
1505
|
+
while(remaining > 0 && 0 !== stream[kImpl].bufLen){
|
|
1506
|
+
const head = stream[kImpl].bufHead;
|
|
1507
|
+
const buf = stream[kImpl].buf[head];
|
|
1508
|
+
if (buf.length <= remaining) {
|
|
1509
|
+
buf.copy(stream[kImpl].data, offset);
|
|
1510
|
+
offset += buf.length;
|
|
1511
|
+
remaining -= buf.length;
|
|
1512
|
+
stream[kImpl].bufLen -= buf.length;
|
|
1513
|
+
stream[kImpl].bufHead = head + 1;
|
|
1514
|
+
if (stream[kImpl].bufHead === stream[kImpl].buf.length) {
|
|
1515
|
+
stream[kImpl].buf.length = 0;
|
|
1516
|
+
stream[kImpl].bufHead = 0;
|
|
1517
|
+
} else if (stream[kImpl].bufHead >= 1024 && 2 * stream[kImpl].bufHead >= stream[kImpl].buf.length) {
|
|
1518
|
+
stream[kImpl].buf.splice(0, stream[kImpl].bufHead);
|
|
1519
|
+
stream[kImpl].bufHead = 0;
|
|
1520
|
+
}
|
|
1521
|
+
continue;
|
|
1522
|
+
}
|
|
1523
|
+
buf.copy(stream[kImpl].data, offset, 0, remaining);
|
|
1524
|
+
stream[kImpl].buf[head] = buf.subarray(remaining);
|
|
1525
|
+
stream[kImpl].bufLen -= remaining;
|
|
1526
|
+
offset += remaining;
|
|
1527
|
+
remaining = 0;
|
|
1528
|
+
}
|
|
1529
|
+
updateState(stream, ()=>{
|
|
1530
|
+
Atomics.store(stream[kImpl].state, WRITE_INDEX, offset);
|
|
1531
|
+
});
|
|
1435
1532
|
cb();
|
|
1436
1533
|
return true;
|
|
1437
1534
|
}
|
|
@@ -1441,8 +1538,9 @@ var __webpack_modules__ = {
|
|
|
1441
1538
|
try {
|
|
1442
1539
|
stream.flushSync();
|
|
1443
1540
|
let readIndex = Atomics.load(stream[kImpl].state, READ_INDEX);
|
|
1444
|
-
|
|
1445
|
-
|
|
1541
|
+
updateState(stream, ()=>{
|
|
1542
|
+
Atomics.store(stream[kImpl].state, WRITE_INDEX, -1);
|
|
1543
|
+
});
|
|
1446
1544
|
let spins = 0;
|
|
1447
1545
|
while(-1 !== readIndex){
|
|
1448
1546
|
Atomics.wait(stream[kImpl].state, READ_INDEX, readIndex, 1000);
|
|
@@ -1464,35 +1562,16 @@ var __webpack_modules__ = {
|
|
|
1464
1562
|
else if (stream[kImpl].needDrain) process.nextTick(drain, stream);
|
|
1465
1563
|
};
|
|
1466
1564
|
stream[kImpl].flushing = false;
|
|
1467
|
-
while(0 !== stream[kImpl].
|
|
1565
|
+
while(0 !== stream[kImpl].bufLen){
|
|
1468
1566
|
const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
|
|
1469
|
-
|
|
1567
|
+
const leftover = stream[kImpl].data.length - writeIndex;
|
|
1470
1568
|
if (0 === leftover) {
|
|
1471
1569
|
flushSync(stream);
|
|
1472
|
-
|
|
1473
|
-
Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
|
|
1474
|
-
Atomics.notify(stream[kImpl].state, READ_INDEX);
|
|
1570
|
+
resetIndexes(stream);
|
|
1475
1571
|
continue;
|
|
1476
1572
|
}
|
|
1477
1573
|
if (leftover < 0) throw new Error('overwritten');
|
|
1478
|
-
|
|
1479
|
-
let toWriteBytes = Buffer.byteLength(toWrite);
|
|
1480
|
-
if (toWriteBytes <= leftover) {
|
|
1481
|
-
stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
|
|
1482
|
-
write(stream, toWrite, cb);
|
|
1483
|
-
} else {
|
|
1484
|
-
flushSync(stream);
|
|
1485
|
-
Atomics.store(stream[kImpl].state, READ_INDEX, 0);
|
|
1486
|
-
Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
|
|
1487
|
-
Atomics.notify(stream[kImpl].state, READ_INDEX);
|
|
1488
|
-
while(toWriteBytes > stream[kImpl].buf.length){
|
|
1489
|
-
leftover /= 2;
|
|
1490
|
-
toWrite = stream[kImpl].buf.slice(0, leftover);
|
|
1491
|
-
toWriteBytes = Buffer.byteLength(toWrite);
|
|
1492
|
-
}
|
|
1493
|
-
stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
|
|
1494
|
-
write(stream, toWrite, cb);
|
|
1495
|
-
}
|
|
1574
|
+
write(stream, leftover, cb);
|
|
1496
1575
|
}
|
|
1497
1576
|
}
|
|
1498
1577
|
function flushSync(stream) {
|
|
@@ -1509,16 +1588,18 @@ var __webpack_modules__ = {
|
|
|
1509
1588
|
}
|
|
1510
1589
|
module1.exports = ThreadStream;
|
|
1511
1590
|
},
|
|
1512
|
-
"../../node_modules/.pnpm/thread-stream@4.
|
|
1591
|
+
"../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/indexes.js" (module1) {
|
|
1513
1592
|
"use strict";
|
|
1593
|
+
const SEQ_INDEX = 2;
|
|
1514
1594
|
const WRITE_INDEX = 4;
|
|
1515
1595
|
const READ_INDEX = 8;
|
|
1516
1596
|
module1.exports = {
|
|
1517
1597
|
WRITE_INDEX,
|
|
1518
|
-
READ_INDEX
|
|
1598
|
+
READ_INDEX,
|
|
1599
|
+
SEQ_INDEX
|
|
1519
1600
|
};
|
|
1520
1601
|
},
|
|
1521
|
-
"../../node_modules/.pnpm/thread-stream@4.
|
|
1602
|
+
"../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/wait.js" (module1) {
|
|
1522
1603
|
"use strict";
|
|
1523
1604
|
const WAIT_MS = 10000;
|
|
1524
1605
|
function wait(state, index, expected, timeout, done) {
|
|
@@ -1542,7 +1623,10 @@ var __webpack_modules__ = {
|
|
|
1542
1623
|
if (max !== 1 / 0 && Date.now() > max) return void done(null, 'timed-out');
|
|
1543
1624
|
const remaining = max === 1 / 0 ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
|
|
1544
1625
|
const result = Atomics.waitAsync(state, index, expected, remaining);
|
|
1545
|
-
if (result.async) result.value.then(
|
|
1626
|
+
if (result.async) result.value.then((res)=>{
|
|
1627
|
+
if ('ok' === res) return void done(null, 'ok');
|
|
1628
|
+
check();
|
|
1629
|
+
});
|
|
1546
1630
|
else setImmediate(check);
|
|
1547
1631
|
};
|
|
1548
1632
|
check();
|
|
@@ -2898,7 +2982,7 @@ var __webpack_modules__ = {
|
|
|
2898
2982
|
const { fileURLToPath } = __webpack_require__("node:url");
|
|
2899
2983
|
const sleep = __webpack_require__("../../node_modules/.pnpm/atomic-sleep@1.0.0/node_modules/atomic-sleep/index.js");
|
|
2900
2984
|
const onExit = __webpack_require__("../../node_modules/.pnpm/on-exit-leak-free@2.1.2/node_modules/on-exit-leak-free/index.js");
|
|
2901
|
-
const ThreadStream = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.
|
|
2985
|
+
const ThreadStream = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/index.js");
|
|
2902
2986
|
function setupOnExit(stream) {
|
|
2903
2987
|
onExit.register(stream, autoEnd);
|
|
2904
2988
|
onExit.registerBeforeExit(stream, flush);
|
|
@@ -3745,10 +3829,10 @@ var __webpack_modules__ = {
|
|
|
3745
3829
|
SonicBoom.default = SonicBoom;
|
|
3746
3830
|
module1.exports = SonicBoom;
|
|
3747
3831
|
},
|
|
3748
|
-
"../../node_modules/.pnpm/thread-stream@4.
|
|
3832
|
+
"../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/package.json" (module1) {
|
|
3749
3833
|
"use strict";
|
|
3750
3834
|
module1.exports = {
|
|
3751
|
-
version: "4.
|
|
3835
|
+
version: "4.2.0"
|
|
3752
3836
|
};
|
|
3753
3837
|
}
|
|
3754
3838
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
"../../node_modules/.pnpm/real-require@0.
|
|
3
|
+
"../../node_modules/.pnpm/real-require@1.0.0/node_modules/real-require/src/index.js" (module1) {
|
|
4
4
|
const realImport = new Function('modulePath', 'return import(modulePath)');
|
|
5
5
|
function realRequire(modulePath) {
|
|
6
6
|
if ('function' == typeof __non_webpack__require__) return __non_webpack__require__(modulePath);
|
|
@@ -11,16 +11,18 @@ var __webpack_modules__ = {
|
|
|
11
11
|
realRequire
|
|
12
12
|
};
|
|
13
13
|
},
|
|
14
|
-
"../../node_modules/.pnpm/thread-stream@4.
|
|
14
|
+
"../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/indexes.js" (module1) {
|
|
15
15
|
"use strict";
|
|
16
|
+
const SEQ_INDEX = 2;
|
|
16
17
|
const WRITE_INDEX = 4;
|
|
17
18
|
const READ_INDEX = 8;
|
|
18
19
|
module1.exports = {
|
|
19
20
|
WRITE_INDEX,
|
|
20
|
-
READ_INDEX
|
|
21
|
+
READ_INDEX,
|
|
22
|
+
SEQ_INDEX
|
|
21
23
|
};
|
|
22
24
|
},
|
|
23
|
-
"../../node_modules/.pnpm/thread-stream@4.
|
|
25
|
+
"../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/wait.js" (module1) {
|
|
24
26
|
"use strict";
|
|
25
27
|
const WAIT_MS = 10000;
|
|
26
28
|
function wait(state, index, expected, timeout, done) {
|
|
@@ -44,7 +46,10 @@ var __webpack_modules__ = {
|
|
|
44
46
|
if (max !== 1 / 0 && Date.now() > max) return void done(null, 'timed-out');
|
|
45
47
|
const remaining = max === 1 / 0 ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
|
|
46
48
|
const result = Atomics.waitAsync(state, index, expected, remaining);
|
|
47
|
-
if (result.async) result.value.then(
|
|
49
|
+
if (result.async) result.value.then((res)=>{
|
|
50
|
+
if ('ok' === res) return void done(null, 'ok');
|
|
51
|
+
check();
|
|
52
|
+
});
|
|
48
53
|
else setImmediate(check);
|
|
49
54
|
};
|
|
50
55
|
check();
|
|
@@ -54,6 +59,10 @@ var __webpack_modules__ = {
|
|
|
54
59
|
waitDiff
|
|
55
60
|
};
|
|
56
61
|
},
|
|
62
|
+
string_decoder (module1) {
|
|
63
|
+
"use strict";
|
|
64
|
+
module1.exports = require("string_decoder");
|
|
65
|
+
},
|
|
57
66
|
worker_threads (module1) {
|
|
58
67
|
"use strict";
|
|
59
68
|
module1.exports = require("worker_threads");
|
|
@@ -72,15 +81,81 @@ function __webpack_require__(moduleId) {
|
|
|
72
81
|
var __webpack_exports__ = {};
|
|
73
82
|
(()=>{
|
|
74
83
|
"use strict";
|
|
75
|
-
const { realImport, realRequire } = __webpack_require__("../../node_modules/.pnpm/real-require@0.
|
|
84
|
+
const { realImport, realRequire } = __webpack_require__("../../node_modules/.pnpm/real-require@1.0.0/node_modules/real-require/src/index.js");
|
|
76
85
|
const { workerData, parentPort } = __webpack_require__("worker_threads");
|
|
77
|
-
const {
|
|
78
|
-
const {
|
|
86
|
+
const { StringDecoder } = __webpack_require__("string_decoder");
|
|
87
|
+
const { WRITE_INDEX, READ_INDEX, SEQ_INDEX } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/indexes.js");
|
|
88
|
+
const { waitDiff } = __webpack_require__("../../node_modules/.pnpm/thread-stream@4.2.0/node_modules/thread-stream/lib/wait.js");
|
|
79
89
|
const { dataBuf, filename, stateBuf } = workerData;
|
|
80
90
|
let destination;
|
|
91
|
+
const flushQueue = [];
|
|
92
|
+
let flushing = false;
|
|
81
93
|
const state = new Int32Array(stateBuf);
|
|
82
94
|
const data = Buffer.from(dataBuf);
|
|
95
|
+
const decoder = new StringDecoder('utf8');
|
|
83
96
|
const keepAlive = setInterval(()=>{}, 3600000);
|
|
97
|
+
function onParentPortMessage(msg) {
|
|
98
|
+
if (!msg || 'FLUSH' !== msg.code || 'thread-stream' !== msg.context) return;
|
|
99
|
+
flushQueue.push(msg.id);
|
|
100
|
+
processFlushQueue();
|
|
101
|
+
}
|
|
102
|
+
function processFlushQueue() {
|
|
103
|
+
if (flushing || !destination) return;
|
|
104
|
+
const id = flushQueue.shift();
|
|
105
|
+
if (void 0 === id) return;
|
|
106
|
+
flushing = true;
|
|
107
|
+
flushDestination((err)=>{
|
|
108
|
+
flushing = false;
|
|
109
|
+
if (err) return void parentPort.postMessage({
|
|
110
|
+
code: 'ERROR',
|
|
111
|
+
err
|
|
112
|
+
});
|
|
113
|
+
parentPort.postMessage({
|
|
114
|
+
code: 'FLUSHED',
|
|
115
|
+
context: 'thread-stream',
|
|
116
|
+
id
|
|
117
|
+
});
|
|
118
|
+
processFlushQueue();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function flushDestination(cb) {
|
|
122
|
+
if ('function' == typeof destination?.flush) {
|
|
123
|
+
if (0 === destination.flush.length) {
|
|
124
|
+
try {
|
|
125
|
+
const result = destination.flush();
|
|
126
|
+
if (result && 'function' == typeof result.then) result.then(()=>cb(), cb);
|
|
127
|
+
else cb();
|
|
128
|
+
} catch (err) {
|
|
129
|
+
cb(err);
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
let done = false;
|
|
134
|
+
const onDone = (err)=>{
|
|
135
|
+
if (done) return;
|
|
136
|
+
done = true;
|
|
137
|
+
cb(err);
|
|
138
|
+
};
|
|
139
|
+
try {
|
|
140
|
+
const result = destination.flush(onDone);
|
|
141
|
+
if (result && 'function' == typeof result.then) result.then(()=>onDone(), onDone);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
onDone(err);
|
|
144
|
+
}
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if ('function' == typeof destination?.flushSync) {
|
|
148
|
+
try {
|
|
149
|
+
destination.flushSync();
|
|
150
|
+
cb();
|
|
151
|
+
} catch (err) {
|
|
152
|
+
cb(err);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (destination?.writableNeedDrain && !destination?.writableEnded) return void destination.once('drain', cb);
|
|
157
|
+
cb();
|
|
158
|
+
}
|
|
84
159
|
async function start() {
|
|
85
160
|
let worker;
|
|
86
161
|
try {
|
|
@@ -124,19 +199,38 @@ var __webpack_exports__ = {};
|
|
|
124
199
|
process.exit(0);
|
|
125
200
|
});
|
|
126
201
|
});
|
|
202
|
+
processFlushQueue();
|
|
127
203
|
}
|
|
128
204
|
start().then(function() {
|
|
205
|
+
parentPort.on('message', onParentPortMessage);
|
|
129
206
|
parentPort.postMessage({
|
|
130
207
|
code: 'READY'
|
|
131
208
|
});
|
|
132
209
|
process.nextTick(run);
|
|
133
210
|
});
|
|
211
|
+
function readState() {
|
|
212
|
+
while(true){
|
|
213
|
+
const seq = Atomics.load(state, SEQ_INDEX);
|
|
214
|
+
if ((1 & seq) !== 0) continue;
|
|
215
|
+
const current = Atomics.load(state, READ_INDEX);
|
|
216
|
+
const end = Atomics.load(state, WRITE_INDEX);
|
|
217
|
+
if (seq === Atomics.load(state, SEQ_INDEX)) return {
|
|
218
|
+
current,
|
|
219
|
+
end,
|
|
220
|
+
seq
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
134
224
|
function run() {
|
|
135
|
-
const current =
|
|
136
|
-
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
225
|
+
const { current, end, seq } = readState();
|
|
226
|
+
if (end === current) return void waitDiff(state, SEQ_INDEX, seq, 1 / 0, run);
|
|
227
|
+
if (-1 === end) {
|
|
228
|
+
const remaining = decoder.end();
|
|
229
|
+
if (remaining.length > 0) destination.write(remaining);
|
|
230
|
+
destination.end();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const toWrite = decoder.write(data.subarray(current, end));
|
|
140
234
|
const res = destination.write(toWrite);
|
|
141
235
|
if (res) {
|
|
142
236
|
Atomics.store(state, READ_INDEX, end);
|