@smplkit/sdk 3.0.103 → 3.0.104

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/index.cjs CHANGED
@@ -13321,541 +13321,436 @@ var require_caller = __commonJS({
13321
13321
  }
13322
13322
  });
13323
13323
 
13324
- // node_modules/fast-redact/lib/validator.js
13325
- var require_validator = __commonJS({
13326
- "node_modules/fast-redact/lib/validator.js"(exports2, module2) {
13324
+ // node_modules/@pinojs/redact/index.js
13325
+ var require_redact = __commonJS({
13326
+ "node_modules/@pinojs/redact/index.js"(exports2, module2) {
13327
13327
  "use strict";
13328
- module2.exports = validator;
13329
- function validator(opts = {}) {
13330
- const {
13331
- ERR_PATHS_MUST_BE_STRINGS = () => "fast-redact - Paths must be (non-empty) strings",
13332
- ERR_INVALID_PATH = (s) => `fast-redact \u2013 Invalid path (${s})`
13333
- } = opts;
13334
- return function validate({ paths }) {
13335
- paths.forEach((s) => {
13336
- if (typeof s !== "string") {
13337
- throw Error(ERR_PATHS_MUST_BE_STRINGS());
13338
- }
13339
- try {
13340
- if (/〇/.test(s)) throw Error();
13341
- const expr = (s[0] === "[" ? "" : ".") + s.replace(/^\*/, "\u3007").replace(/\.\*/g, ".\u3007").replace(/\[\*\]/g, "[\u3007]");
13342
- if (/\n|\r|;/.test(expr)) throw Error();
13343
- if (/\/\*/.test(expr)) throw Error();
13344
- Function(`
13345
- 'use strict'
13346
- const o = new Proxy({}, { get: () => o, set: () => { throw Error() } });
13347
- const \u3007 = null;
13348
- o${expr}
13349
- if ([o${expr}].length !== 1) throw Error()`)();
13350
- } catch (e) {
13351
- throw Error(ERR_INVALID_PATH(s));
13328
+ function deepClone(obj) {
13329
+ if (obj === null || typeof obj !== "object") {
13330
+ return obj;
13331
+ }
13332
+ if (obj instanceof Date) {
13333
+ return new Date(obj.getTime());
13334
+ }
13335
+ if (obj instanceof Array) {
13336
+ const cloned = [];
13337
+ for (let i = 0; i < obj.length; i++) {
13338
+ cloned[i] = deepClone(obj[i]);
13339
+ }
13340
+ return cloned;
13341
+ }
13342
+ if (typeof obj === "object") {
13343
+ const cloned = Object.create(Object.getPrototypeOf(obj));
13344
+ for (const key in obj) {
13345
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
13346
+ cloned[key] = deepClone(obj[key]);
13352
13347
  }
13353
- });
13354
- };
13355
- }
13356
- }
13357
- });
13358
-
13359
- // node_modules/fast-redact/lib/rx.js
13360
- var require_rx = __commonJS({
13361
- "node_modules/fast-redact/lib/rx.js"(exports2, module2) {
13362
- "use strict";
13363
- module2.exports = /[^.[\]]+|\[((?:.)*?)\]/g;
13364
- }
13365
- });
13366
-
13367
- // node_modules/fast-redact/lib/parse.js
13368
- var require_parse = __commonJS({
13369
- "node_modules/fast-redact/lib/parse.js"(exports2, module2) {
13370
- "use strict";
13371
- var rx = require_rx();
13372
- module2.exports = parse2;
13373
- function parse2({ paths }) {
13374
- const wildcards = [];
13375
- var wcLen = 0;
13376
- const secret = paths.reduce(function(o, strPath, ix) {
13377
- var path = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
13378
- const leadingBracket = strPath[0] === "[";
13379
- path = path.map((p) => {
13380
- if (p[0] === "[") return p.substr(1, p.length - 2);
13381
- else return p;
13382
- });
13383
- const star = path.indexOf("*");
13384
- if (star > -1) {
13385
- const before = path.slice(0, star);
13386
- const beforeStr = before.join(".");
13387
- const after = path.slice(star + 1, path.length);
13388
- const nested = after.length > 0;
13389
- wcLen++;
13390
- wildcards.push({
13391
- before,
13392
- beforeStr,
13393
- after,
13394
- nested
13395
- });
13396
- } else {
13397
- o[strPath] = {
13398
- path,
13399
- val: void 0,
13400
- precensored: false,
13401
- circle: "",
13402
- escPath: JSON.stringify(strPath),
13403
- leadingBracket
13404
- };
13405
13348
  }
13406
- return o;
13407
- }, {});
13408
- return { wildcards, wcLen, secret };
13409
- }
13410
- }
13411
- });
13412
-
13413
- // node_modules/fast-redact/lib/redactor.js
13414
- var require_redactor = __commonJS({
13415
- "node_modules/fast-redact/lib/redactor.js"(exports2, module2) {
13416
- "use strict";
13417
- var rx = require_rx();
13418
- module2.exports = redactor;
13419
- function redactor({ secret, serialize, wcLen, strict, isCensorFct, censorFctTakesPath }, state) {
13420
- const redact = Function("o", `
13421
- if (typeof o !== 'object' || o == null) {
13422
- ${strictImpl(strict, serialize)}
13423
- }
13424
- const { censor, secret } = this
13425
- const originalSecret = {}
13426
- const secretKeys = Object.keys(secret)
13427
- for (var i = 0; i < secretKeys.length; i++) {
13428
- originalSecret[secretKeys[i]] = secret[secretKeys[i]]
13349
+ return cloned;
13350
+ }
13351
+ return obj;
13429
13352
  }
13430
-
13431
- ${redactTmpl(secret, isCensorFct, censorFctTakesPath)}
13432
- this.compileRestore()
13433
- ${dynamicRedactTmpl(wcLen > 0, isCensorFct, censorFctTakesPath)}
13434
- this.secret = originalSecret
13435
- ${resultTmpl(serialize)}
13436
- `).bind(state);
13437
- redact.state = state;
13438
- if (serialize === false) {
13439
- redact.restore = (o) => state.restore(o);
13440
- }
13441
- return redact;
13442
- }
13443
- function redactTmpl(secret, isCensorFct, censorFctTakesPath) {
13444
- return Object.keys(secret).map((path) => {
13445
- const { escPath, leadingBracket, path: arrPath } = secret[path];
13446
- const skip = leadingBracket ? 1 : 0;
13447
- const delim = leadingBracket ? "" : ".";
13448
- const hops = [];
13449
- var match;
13450
- while ((match = rx.exec(path)) !== null) {
13451
- const [, ix] = match;
13452
- const { index, input } = match;
13453
- if (index > skip) hops.push(input.substring(0, index - (ix ? 0 : 1)));
13454
- }
13455
- var existence = hops.map((p) => `o${delim}${p}`).join(" && ");
13456
- if (existence.length === 0) existence += `o${delim}${path} != null`;
13457
- else existence += ` && o${delim}${path} != null`;
13458
- const circularDetection = `
13459
- switch (true) {
13460
- ${hops.reverse().map((p) => `
13461
- case o${delim}${p} === censor:
13462
- secret[${escPath}].circle = ${JSON.stringify(p)}
13463
- break
13464
- `).join("\n")}
13465
- }
13466
- `;
13467
- const censorArgs = censorFctTakesPath ? `val, ${JSON.stringify(arrPath)}` : `val`;
13468
- return `
13469
- if (${existence}) {
13470
- const val = o${delim}${path}
13471
- if (val === censor) {
13472
- secret[${escPath}].precensored = true
13353
+ function parsePath(path) {
13354
+ const parts = [];
13355
+ let current = "";
13356
+ let inBrackets = false;
13357
+ let inQuotes = false;
13358
+ let quoteChar = "";
13359
+ for (let i = 0; i < path.length; i++) {
13360
+ const char = path[i];
13361
+ if (!inBrackets && char === ".") {
13362
+ if (current) {
13363
+ parts.push(current);
13364
+ current = "";
13365
+ }
13366
+ } else if (char === "[") {
13367
+ if (current) {
13368
+ parts.push(current);
13369
+ current = "";
13370
+ }
13371
+ inBrackets = true;
13372
+ } else if (char === "]" && inBrackets) {
13373
+ parts.push(current);
13374
+ current = "";
13375
+ inBrackets = false;
13376
+ inQuotes = false;
13377
+ } else if ((char === '"' || char === "'") && inBrackets) {
13378
+ if (!inQuotes) {
13379
+ inQuotes = true;
13380
+ quoteChar = char;
13381
+ } else if (char === quoteChar) {
13382
+ inQuotes = false;
13383
+ quoteChar = "";
13384
+ } else {
13385
+ current += char;
13386
+ }
13473
13387
  } else {
13474
- secret[${escPath}].val = val
13475
- o${delim}${path} = ${isCensorFct ? `censor(${censorArgs})` : "censor"}
13476
- ${circularDetection}
13388
+ current += char;
13477
13389
  }
13478
13390
  }
13479
- `;
13480
- }).join("\n");
13481
- }
13482
- function dynamicRedactTmpl(hasWildcards, isCensorFct, censorFctTakesPath) {
13483
- return hasWildcards === true ? `
13484
- {
13485
- const { wildcards, wcLen, groupRedact, nestedRedact } = this
13486
- for (var i = 0; i < wcLen; i++) {
13487
- const { before, beforeStr, after, nested } = wildcards[i]
13488
- if (nested === true) {
13489
- secret[beforeStr] = secret[beforeStr] || []
13490
- nestedRedact(secret[beforeStr], o, before, after, censor, ${isCensorFct}, ${censorFctTakesPath})
13491
- } else secret[beforeStr] = groupRedact(o, before, censor, ${isCensorFct}, ${censorFctTakesPath})
13391
+ if (current) {
13392
+ parts.push(current);
13492
13393
  }
13394
+ return parts;
13493
13395
  }
13494
- ` : "";
13495
- }
13496
- function resultTmpl(serialize) {
13497
- return serialize === false ? `return o` : `
13498
- var s = this.serialize(o)
13499
- this.restore(o)
13500
- return s
13501
- `;
13502
- }
13503
- function strictImpl(strict, serialize) {
13504
- return strict === true ? `throw Error('fast-redact: primitives cannot be redacted')` : serialize === false ? `return o` : `return this.serialize(o)`;
13396
+ function setValue(obj, parts, value) {
13397
+ let current = obj;
13398
+ for (let i = 0; i < parts.length - 1; i++) {
13399
+ const key = parts[i];
13400
+ if (typeof current !== "object" || current === null || !(key in current)) {
13401
+ return false;
13402
+ }
13403
+ if (typeof current[key] !== "object" || current[key] === null) {
13404
+ return false;
13405
+ }
13406
+ current = current[key];
13407
+ }
13408
+ const lastKey = parts[parts.length - 1];
13409
+ if (lastKey === "*") {
13410
+ if (Array.isArray(current)) {
13411
+ for (let i = 0; i < current.length; i++) {
13412
+ current[i] = value;
13413
+ }
13414
+ } else if (typeof current === "object" && current !== null) {
13415
+ for (const key in current) {
13416
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
13417
+ current[key] = value;
13418
+ }
13419
+ }
13420
+ }
13421
+ } else {
13422
+ if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
13423
+ current[lastKey] = value;
13424
+ }
13425
+ }
13426
+ return true;
13505
13427
  }
13506
- }
13507
- });
13508
-
13509
- // node_modules/fast-redact/lib/modifiers.js
13510
- var require_modifiers = __commonJS({
13511
- "node_modules/fast-redact/lib/modifiers.js"(exports2, module2) {
13512
- "use strict";
13513
- module2.exports = {
13514
- groupRedact,
13515
- groupRestore,
13516
- nestedRedact,
13517
- nestedRestore
13518
- };
13519
- function groupRestore({ keys, values, target }) {
13520
- if (target == null || typeof target === "string") return;
13521
- const length = keys.length;
13522
- for (var i = 0; i < length; i++) {
13523
- const k = keys[i];
13524
- target[k] = values[i];
13525
- }
13526
- }
13527
- function groupRedact(o, path, censor, isCensorFct, censorFctTakesPath) {
13528
- const target = get(o, path);
13529
- if (target == null || typeof target === "string") return { keys: null, values: null, target, flat: true };
13530
- const keys = Object.keys(target);
13531
- const keysLength = keys.length;
13532
- const pathLength = path.length;
13533
- const pathWithKey = censorFctTakesPath ? [...path] : void 0;
13534
- const values = new Array(keysLength);
13535
- for (var i = 0; i < keysLength; i++) {
13536
- const key = keys[i];
13537
- values[i] = target[key];
13538
- if (censorFctTakesPath) {
13539
- pathWithKey[pathLength] = key;
13540
- target[key] = censor(target[key], pathWithKey);
13541
- } else if (isCensorFct) {
13542
- target[key] = censor(target[key]);
13543
- } else {
13544
- target[key] = censor;
13428
+ function removeKey(obj, parts) {
13429
+ let current = obj;
13430
+ for (let i = 0; i < parts.length - 1; i++) {
13431
+ const key = parts[i];
13432
+ if (typeof current !== "object" || current === null || !(key in current)) {
13433
+ return false;
13434
+ }
13435
+ if (typeof current[key] !== "object" || current[key] === null) {
13436
+ return false;
13437
+ }
13438
+ current = current[key];
13439
+ }
13440
+ const lastKey = parts[parts.length - 1];
13441
+ if (lastKey === "*") {
13442
+ if (Array.isArray(current)) {
13443
+ for (let i = 0; i < current.length; i++) {
13444
+ current[i] = void 0;
13445
+ }
13446
+ } else if (typeof current === "object" && current !== null) {
13447
+ for (const key in current) {
13448
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
13449
+ delete current[key];
13450
+ }
13451
+ }
13452
+ }
13453
+ } else {
13454
+ if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
13455
+ delete current[lastKey];
13545
13456
  }
13546
13457
  }
13547
- return { keys, values, target, flat: true };
13458
+ return true;
13548
13459
  }
13549
- function nestedRestore(instructions) {
13550
- for (let i = 0; i < instructions.length; i++) {
13551
- const { target, path, value } = instructions[i];
13552
- let current = target;
13553
- for (let i2 = path.length - 1; i2 > 0; i2--) {
13554
- current = current[path[i2]];
13460
+ var PATH_NOT_FOUND = /* @__PURE__ */ Symbol("PATH_NOT_FOUND");
13461
+ function getValueIfExists(obj, parts) {
13462
+ let current = obj;
13463
+ for (const part of parts) {
13464
+ if (current === null || current === void 0) {
13465
+ return PATH_NOT_FOUND;
13466
+ }
13467
+ if (typeof current !== "object" || current === null) {
13468
+ return PATH_NOT_FOUND;
13469
+ }
13470
+ if (!(part in current)) {
13471
+ return PATH_NOT_FOUND;
13555
13472
  }
13556
- current[path[0]] = value;
13473
+ current = current[part];
13557
13474
  }
13475
+ return current;
13558
13476
  }
13559
- function nestedRedact(store, o, path, ns, censor, isCensorFct, censorFctTakesPath) {
13560
- const target = get(o, path);
13561
- if (target == null) return;
13562
- const keys = Object.keys(target);
13563
- const keysLength = keys.length;
13564
- for (var i = 0; i < keysLength; i++) {
13565
- const key = keys[i];
13566
- specialSet(store, target, key, path, ns, censor, isCensorFct, censorFctTakesPath);
13477
+ function getValue(obj, parts) {
13478
+ let current = obj;
13479
+ for (const part of parts) {
13480
+ if (current === null || current === void 0) {
13481
+ return void 0;
13482
+ }
13483
+ if (typeof current !== "object" || current === null) {
13484
+ return void 0;
13485
+ }
13486
+ current = current[part];
13567
13487
  }
13568
- return store;
13488
+ return current;
13569
13489
  }
13570
- function has(obj, prop) {
13571
- return obj !== void 0 && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false;
13490
+ function redactPaths(obj, paths, censor, remove = false) {
13491
+ for (const path of paths) {
13492
+ const parts = parsePath(path);
13493
+ if (parts.includes("*")) {
13494
+ redactWildcardPath(obj, parts, censor, path, remove);
13495
+ } else {
13496
+ if (remove) {
13497
+ removeKey(obj, parts);
13498
+ } else {
13499
+ const value = getValueIfExists(obj, parts);
13500
+ if (value === PATH_NOT_FOUND) {
13501
+ continue;
13502
+ }
13503
+ const actualCensor = typeof censor === "function" ? censor(value, parts) : censor;
13504
+ setValue(obj, parts, actualCensor);
13505
+ }
13506
+ }
13507
+ }
13572
13508
  }
13573
- function specialSet(store, o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) {
13574
- const afterPathLen = afterPath.length;
13575
- const lastPathIndex = afterPathLen - 1;
13576
- const originalKey = k;
13577
- var i = -1;
13578
- var n;
13579
- var nv;
13580
- var ov;
13581
- var oov = null;
13582
- var wc = null;
13583
- var kIsWc;
13584
- var wcov;
13585
- var consecutive = false;
13586
- var level = 0;
13587
- var depth = 0;
13588
- var redactPathCurrent = tree();
13589
- ov = n = o[k];
13590
- if (typeof n !== "object") return;
13591
- while (n != null && ++i < afterPathLen) {
13592
- depth += 1;
13593
- k = afterPath[i];
13594
- oov = ov;
13595
- if (k !== "*" && !wc && !(typeof n === "object" && k in n)) {
13596
- break;
13509
+ function redactWildcardPath(obj, parts, censor, originalPath, remove = false) {
13510
+ const wildcardIndex = parts.indexOf("*");
13511
+ if (wildcardIndex === parts.length - 1) {
13512
+ const parentParts = parts.slice(0, -1);
13513
+ let current = obj;
13514
+ for (const part of parentParts) {
13515
+ if (current === null || current === void 0) return;
13516
+ if (typeof current !== "object" || current === null) return;
13517
+ current = current[part];
13597
13518
  }
13598
- if (k === "*") {
13599
- if (wc === "*") {
13600
- consecutive = true;
13519
+ if (Array.isArray(current)) {
13520
+ if (remove) {
13521
+ for (let i = 0; i < current.length; i++) {
13522
+ current[i] = void 0;
13523
+ }
13524
+ } else {
13525
+ for (let i = 0; i < current.length; i++) {
13526
+ const indexPath = [...parentParts, i.toString()];
13527
+ const actualCensor = typeof censor === "function" ? censor(current[i], indexPath) : censor;
13528
+ current[i] = actualCensor;
13529
+ }
13601
13530
  }
13602
- wc = k;
13603
- if (i !== lastPathIndex) {
13604
- continue;
13531
+ } else if (typeof current === "object" && current !== null) {
13532
+ if (remove) {
13533
+ const keysToDelete = [];
13534
+ for (const key in current) {
13535
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
13536
+ keysToDelete.push(key);
13537
+ }
13538
+ }
13539
+ for (const key of keysToDelete) {
13540
+ delete current[key];
13541
+ }
13542
+ } else {
13543
+ for (const key in current) {
13544
+ const keyPath = [...parentParts, key];
13545
+ const actualCensor = typeof censor === "function" ? censor(current[key], keyPath) : censor;
13546
+ current[key] = actualCensor;
13547
+ }
13605
13548
  }
13606
13549
  }
13607
- if (wc) {
13608
- const wcKeys = Object.keys(n);
13609
- for (var j = 0; j < wcKeys.length; j++) {
13610
- const wck = wcKeys[j];
13611
- wcov = n[wck];
13612
- kIsWc = k === "*";
13613
- if (consecutive) {
13614
- redactPathCurrent = node(redactPathCurrent, wck, depth);
13615
- level = i;
13616
- ov = iterateNthLevel(wcov, level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, o[originalKey], depth + 1);
13617
- } else {
13618
- if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
13619
- if (kIsWc) {
13620
- ov = wcov;
13621
- } else {
13622
- ov = wcov[k];
13623
- }
13624
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
13625
- if (kIsWc) {
13626
- const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]);
13627
- store.push(rv);
13628
- n[wck] = nv;
13629
- } else {
13630
- if (wcov[k] === nv) {
13631
- } else if (nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov) {
13632
- redactPathCurrent = node(redactPathCurrent, wck, depth);
13633
- } else {
13634
- redactPathCurrent = node(redactPathCurrent, wck, depth);
13635
- const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, o[originalKey]);
13636
- store.push(rv);
13637
- wcov[k] = nv;
13638
- }
13639
- }
13640
- }
13550
+ } else {
13551
+ redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove);
13552
+ }
13553
+ }
13554
+ function redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove = false) {
13555
+ const beforeWildcard = parts.slice(0, wildcardIndex);
13556
+ const afterWildcard = parts.slice(wildcardIndex + 1);
13557
+ const pathArray = [];
13558
+ function traverse(current, pathLength) {
13559
+ if (pathLength === beforeWildcard.length) {
13560
+ if (Array.isArray(current)) {
13561
+ for (let i = 0; i < current.length; i++) {
13562
+ pathArray[pathLength] = i.toString();
13563
+ traverse(current[i], pathLength + 1);
13564
+ }
13565
+ } else if (typeof current === "object" && current !== null) {
13566
+ for (const key in current) {
13567
+ pathArray[pathLength] = key;
13568
+ traverse(current[key], pathLength + 1);
13641
13569
  }
13642
13570
  }
13643
- wc = null;
13571
+ } else if (pathLength < beforeWildcard.length) {
13572
+ const nextKey = beforeWildcard[pathLength];
13573
+ if (current && typeof current === "object" && current !== null && nextKey in current) {
13574
+ pathArray[pathLength] = nextKey;
13575
+ traverse(current[nextKey], pathLength + 1);
13576
+ }
13644
13577
  } else {
13645
- ov = n[k];
13646
- redactPathCurrent = node(redactPathCurrent, k, depth);
13647
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
13648
- if (has(n, k) && nv === ov || nv === void 0 && censor !== void 0) {
13578
+ if (afterWildcard.includes("*")) {
13579
+ const wrappedCensor = typeof censor === "function" ? (value, path) => {
13580
+ const fullPath = [...pathArray.slice(0, pathLength), ...path];
13581
+ return censor(value, fullPath);
13582
+ } : censor;
13583
+ redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
13649
13584
  } else {
13650
- const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]);
13651
- store.push(rv);
13652
- n[k] = nv;
13585
+ if (remove) {
13586
+ removeKey(current, afterWildcard);
13587
+ } else {
13588
+ const actualCensor = typeof censor === "function" ? censor(getValue(current, afterWildcard), [...pathArray.slice(0, pathLength), ...afterWildcard]) : censor;
13589
+ setValue(current, afterWildcard, actualCensor);
13590
+ }
13653
13591
  }
13654
- n = n[k];
13655
13592
  }
13656
- if (typeof n !== "object") break;
13657
- if (ov === oov || typeof ov === "undefined") {
13593
+ }
13594
+ if (beforeWildcard.length === 0) {
13595
+ traverse(obj, 0);
13596
+ } else {
13597
+ let current = obj;
13598
+ for (let i = 0; i < beforeWildcard.length; i++) {
13599
+ const part = beforeWildcard[i];
13600
+ if (current === null || current === void 0) return;
13601
+ if (typeof current !== "object" || current === null) return;
13602
+ current = current[part];
13603
+ pathArray[i] = part;
13604
+ }
13605
+ if (current !== null && current !== void 0) {
13606
+ traverse(current, beforeWildcard.length);
13658
13607
  }
13659
13608
  }
13660
13609
  }
13661
- function get(o, p) {
13662
- var i = -1;
13663
- var l = p.length;
13664
- var n = o;
13665
- while (n != null && ++i < l) {
13666
- n = n[p[i]];
13610
+ function buildPathStructure(pathsToClone) {
13611
+ if (pathsToClone.length === 0) {
13612
+ return null;
13667
13613
  }
13668
- return n;
13614
+ const pathStructure = /* @__PURE__ */ new Map();
13615
+ for (const path of pathsToClone) {
13616
+ const parts = parsePath(path);
13617
+ let current = pathStructure;
13618
+ for (let i = 0; i < parts.length; i++) {
13619
+ const part = parts[i];
13620
+ if (!current.has(part)) {
13621
+ current.set(part, /* @__PURE__ */ new Map());
13622
+ }
13623
+ current = current.get(part);
13624
+ }
13625
+ }
13626
+ return pathStructure;
13669
13627
  }
13670
- function iterateNthLevel(wcov, level, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
13671
- if (level === 0) {
13672
- if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
13673
- if (kIsWc) {
13674
- ov = wcov;
13675
- } else {
13676
- ov = wcov[k];
13628
+ function selectiveClone(obj, pathStructure) {
13629
+ if (!pathStructure) {
13630
+ return obj;
13631
+ }
13632
+ function cloneSelectively(source, pathMap, depth = 0) {
13633
+ if (!pathMap || pathMap.size === 0) {
13634
+ return source;
13635
+ }
13636
+ if (source === null || typeof source !== "object") {
13637
+ return source;
13638
+ }
13639
+ if (source instanceof Date) {
13640
+ return new Date(source.getTime());
13641
+ }
13642
+ if (Array.isArray(source)) {
13643
+ const cloned2 = [];
13644
+ for (let i = 0; i < source.length; i++) {
13645
+ const indexStr = i.toString();
13646
+ if (pathMap.has(indexStr) || pathMap.has("*")) {
13647
+ cloned2[i] = cloneSelectively(source[i], pathMap.get(indexStr) || pathMap.get("*"));
13648
+ } else {
13649
+ cloned2[i] = source[i];
13650
+ }
13677
13651
  }
13678
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
13679
- if (kIsWc) {
13680
- const rv = restoreInstr(redactPathCurrent, ov, parent);
13681
- store.push(rv);
13682
- n[wck] = nv;
13683
- } else {
13684
- if (wcov[k] === nv) {
13685
- } else if (nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov) {
13652
+ return cloned2;
13653
+ }
13654
+ const cloned = Object.create(Object.getPrototypeOf(source));
13655
+ for (const key in source) {
13656
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
13657
+ if (pathMap.has(key) || pathMap.has("*")) {
13658
+ cloned[key] = cloneSelectively(source[key], pathMap.get(key) || pathMap.get("*"));
13686
13659
  } else {
13687
- const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, parent);
13688
- store.push(rv);
13689
- wcov[k] = nv;
13660
+ cloned[key] = source[key];
13690
13661
  }
13691
13662
  }
13692
13663
  }
13664
+ return cloned;
13665
+ }
13666
+ return cloneSelectively(obj, pathStructure);
13667
+ }
13668
+ function validatePath(path) {
13669
+ if (typeof path !== "string") {
13670
+ throw new Error("Paths must be (non-empty) strings");
13693
13671
  }
13694
- for (const key in wcov) {
13695
- if (typeof wcov[key] === "object") {
13696
- redactPathCurrent = node(redactPathCurrent, key, depth);
13697
- iterateNthLevel(wcov[key], level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
13672
+ if (path === "") {
13673
+ throw new Error("Invalid redaction path ()");
13674
+ }
13675
+ if (path.includes("..")) {
13676
+ throw new Error(`Invalid redaction path (${path})`);
13677
+ }
13678
+ if (path.includes(",")) {
13679
+ throw new Error(`Invalid redaction path (${path})`);
13680
+ }
13681
+ let bracketCount = 0;
13682
+ let inQuotes = false;
13683
+ let quoteChar = "";
13684
+ for (let i = 0; i < path.length; i++) {
13685
+ const char = path[i];
13686
+ if ((char === '"' || char === "'") && bracketCount > 0) {
13687
+ if (!inQuotes) {
13688
+ inQuotes = true;
13689
+ quoteChar = char;
13690
+ } else if (char === quoteChar) {
13691
+ inQuotes = false;
13692
+ quoteChar = "";
13693
+ }
13694
+ } else if (char === "[" && !inQuotes) {
13695
+ bracketCount++;
13696
+ } else if (char === "]" && !inQuotes) {
13697
+ bracketCount--;
13698
+ if (bracketCount < 0) {
13699
+ throw new Error(`Invalid redaction path (${path})`);
13700
+ }
13698
13701
  }
13699
13702
  }
13700
- }
13701
- function tree() {
13702
- return { parent: null, key: null, children: [], depth: 0 };
13703
- }
13704
- function node(parent, key, depth) {
13705
- if (parent.depth === depth) {
13706
- return node(parent.parent, key, depth);
13703
+ if (bracketCount !== 0) {
13704
+ throw new Error(`Invalid redaction path (${path})`);
13707
13705
  }
13708
- var child = {
13709
- parent,
13710
- key,
13711
- depth,
13712
- children: []
13713
- };
13714
- parent.children.push(child);
13715
- return child;
13716
13706
  }
13717
- function restoreInstr(node2, value, target) {
13718
- let current = node2;
13719
- const path = [];
13720
- do {
13721
- path.push(current.key);
13722
- current = current.parent;
13723
- } while (current.parent != null);
13724
- return { path, value, target };
13707
+ function validatePaths(paths) {
13708
+ if (!Array.isArray(paths)) {
13709
+ throw new TypeError("paths must be an array");
13710
+ }
13711
+ for (const path of paths) {
13712
+ validatePath(path);
13713
+ }
13725
13714
  }
13726
- }
13727
- });
13728
-
13729
- // node_modules/fast-redact/lib/restorer.js
13730
- var require_restorer = __commonJS({
13731
- "node_modules/fast-redact/lib/restorer.js"(exports2, module2) {
13732
- "use strict";
13733
- var { groupRestore, nestedRestore } = require_modifiers();
13734
- module2.exports = restorer;
13735
- function restorer() {
13736
- return function compileRestore() {
13737
- if (this.restore) {
13738
- this.restore.state.secret = this.secret;
13739
- return;
13715
+ function slowRedact(options = {}) {
13716
+ const {
13717
+ paths = [],
13718
+ censor = "[REDACTED]",
13719
+ serialize = JSON.stringify,
13720
+ strict = true,
13721
+ remove = false
13722
+ } = options;
13723
+ validatePaths(paths);
13724
+ const pathStructure = buildPathStructure(paths);
13725
+ return function redact(obj) {
13726
+ if (strict && (obj === null || typeof obj !== "object")) {
13727
+ if (obj === null || obj === void 0) {
13728
+ return serialize ? serialize(obj) : obj;
13729
+ }
13730
+ if (typeof obj !== "object") {
13731
+ return serialize ? serialize(obj) : obj;
13732
+ }
13733
+ }
13734
+ const cloned = selectiveClone(obj, pathStructure);
13735
+ const original = obj;
13736
+ let actualCensor = censor;
13737
+ if (typeof censor === "function") {
13738
+ actualCensor = censor;
13739
+ }
13740
+ redactPaths(cloned, paths, actualCensor, remove);
13741
+ if (serialize === false) {
13742
+ cloned.restore = function() {
13743
+ return deepClone(original);
13744
+ };
13745
+ return cloned;
13746
+ }
13747
+ if (typeof serialize === "function") {
13748
+ return serialize(cloned);
13740
13749
  }
13741
- const { secret, wcLen } = this;
13742
- const paths = Object.keys(secret);
13743
- const resetters = resetTmpl(secret, paths);
13744
- const hasWildcards = wcLen > 0;
13745
- const state = hasWildcards ? { secret, groupRestore, nestedRestore } : { secret };
13746
- this.restore = Function(
13747
- "o",
13748
- restoreTmpl(resetters, paths, hasWildcards)
13749
- ).bind(state);
13750
- this.restore.state = state;
13750
+ return JSON.stringify(cloned);
13751
13751
  };
13752
13752
  }
13753
- function resetTmpl(secret, paths) {
13754
- return paths.map((path) => {
13755
- const { circle, escPath, leadingBracket } = secret[path];
13756
- const delim = leadingBracket ? "" : ".";
13757
- const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path} = secret[${escPath}].val`;
13758
- const clear = `secret[${escPath}].val = undefined`;
13759
- return `
13760
- if (secret[${escPath}].val !== undefined) {
13761
- try { ${reset} } catch (e) {}
13762
- ${clear}
13763
- }
13764
- `;
13765
- }).join("");
13766
- }
13767
- function restoreTmpl(resetters, paths, hasWildcards) {
13768
- const dynamicReset = hasWildcards === true ? `
13769
- const keys = Object.keys(secret)
13770
- const len = keys.length
13771
- for (var i = len - 1; i >= ${paths.length}; i--) {
13772
- const k = keys[i]
13773
- const o = secret[k]
13774
- if (o) {
13775
- if (o.flat === true) this.groupRestore(o)
13776
- else this.nestedRestore(o)
13777
- secret[k] = null
13778
- }
13779
- }
13780
- ` : "";
13781
- return `
13782
- const secret = this.secret
13783
- ${dynamicReset}
13784
- ${resetters}
13785
- return o
13786
- `;
13787
- }
13788
- }
13789
- });
13790
-
13791
- // node_modules/fast-redact/lib/state.js
13792
- var require_state3 = __commonJS({
13793
- "node_modules/fast-redact/lib/state.js"(exports2, module2) {
13794
- "use strict";
13795
- module2.exports = state;
13796
- function state(o) {
13797
- const {
13798
- secret,
13799
- censor,
13800
- compileRestore,
13801
- serialize,
13802
- groupRedact,
13803
- nestedRedact,
13804
- wildcards,
13805
- wcLen
13806
- } = o;
13807
- const builder = [{ secret, censor, compileRestore }];
13808
- if (serialize !== false) builder.push({ serialize });
13809
- if (wcLen > 0) builder.push({ groupRedact, nestedRedact, wildcards, wcLen });
13810
- return Object.assign(...builder);
13811
- }
13812
- }
13813
- });
13814
-
13815
- // node_modules/fast-redact/index.js
13816
- var require_fast_redact = __commonJS({
13817
- "node_modules/fast-redact/index.js"(exports2, module2) {
13818
- "use strict";
13819
- var validator = require_validator();
13820
- var parse2 = require_parse();
13821
- var redactor = require_redactor();
13822
- var restorer = require_restorer();
13823
- var { groupRedact, nestedRedact } = require_modifiers();
13824
- var state = require_state3();
13825
- var rx = require_rx();
13826
- var validate = validator();
13827
- var noop = (o) => o;
13828
- noop.restore = noop;
13829
- var DEFAULT_CENSOR = "[REDACTED]";
13830
- fastRedact.rx = rx;
13831
- fastRedact.validator = validator;
13832
- module2.exports = fastRedact;
13833
- function fastRedact(opts = {}) {
13834
- const paths = Array.from(new Set(opts.paths || []));
13835
- const serialize = "serialize" in opts ? opts.serialize === false ? opts.serialize : typeof opts.serialize === "function" ? opts.serialize : JSON.stringify : JSON.stringify;
13836
- const remove = opts.remove;
13837
- if (remove === true && serialize !== JSON.stringify) {
13838
- throw Error("fast-redact \u2013 remove option may only be set when serializer is JSON.stringify");
13839
- }
13840
- const censor = remove === true ? void 0 : "censor" in opts ? opts.censor : DEFAULT_CENSOR;
13841
- const isCensorFct = typeof censor === "function";
13842
- const censorFctTakesPath = isCensorFct && censor.length > 1;
13843
- if (paths.length === 0) return serialize || noop;
13844
- validate({ paths, serialize, censor });
13845
- const { wildcards, wcLen, secret } = parse2({ paths, censor });
13846
- const compileRestore = restorer();
13847
- const strict = "strict" in opts ? opts.strict : true;
13848
- return redactor({ secret, wcLen, serialize, strict, isCensorFct, censorFctTakesPath }, state({
13849
- secret,
13850
- censor,
13851
- compileRestore,
13852
- serialize,
13853
- groupRedact,
13854
- nestedRedact,
13855
- wildcards,
13856
- wcLen
13857
- }));
13858
- }
13753
+ module2.exports = slowRedact;
13859
13754
  }
13860
13755
  });
13861
13756
 
@@ -13934,17 +13829,13 @@ var require_symbols = __commonJS({
13934
13829
  var require_redaction = __commonJS({
13935
13830
  "node_modules/pino/lib/redaction.js"(exports2, module2) {
13936
13831
  "use strict";
13937
- var fastRedact = require_fast_redact();
13832
+ var Redact = require_redact();
13938
13833
  var { redactFmtSym, wildcardFirstSym } = require_symbols();
13939
- var { rx, validator } = fastRedact;
13940
- var validate = validator({
13941
- ERR_PATHS_MUST_BE_STRINGS: () => "pino \u2013 redacted paths must be strings",
13942
- ERR_INVALID_PATH: (s) => `pino \u2013 redact paths array contains an invalid path (${s})`
13943
- });
13834
+ var rx = /[^.[\]]+|\[([^[\]]*?)\]/g;
13944
13835
  var CENSOR = "[Redacted]";
13945
13836
  var strict = false;
13946
13837
  function redaction(opts, serialize) {
13947
- const { paths, censor } = handle(opts);
13838
+ const { paths, censor, remove } = handle(opts);
13948
13839
  const shape = paths.reduce((o, str) => {
13949
13840
  rx.lastIndex = 0;
13950
13841
  const first = rx.exec(str);
@@ -13977,7 +13868,7 @@ var require_redaction = __commonJS({
13977
13868
  return o;
13978
13869
  }, {});
13979
13870
  const result = {
13980
- [redactFmtSym]: fastRedact({ paths, censor, serialize, strict })
13871
+ [redactFmtSym]: Redact({ paths, censor, serialize, strict, remove })
13981
13872
  };
13982
13873
  const topCensor = (...args) => {
13983
13874
  return typeof censor === "function" ? serialize(censor(...args)) : serialize(censor);
@@ -13989,11 +13880,12 @@ var require_redaction = __commonJS({
13989
13880
  const wrappedCensor = typeof censor === "function" ? (value, path) => {
13990
13881
  return censor(value, [k, ...path]);
13991
13882
  } : censor;
13992
- o[k] = fastRedact({
13883
+ o[k] = Redact({
13993
13884
  paths: shape[k],
13994
13885
  censor: wrappedCensor,
13995
13886
  serialize,
13996
- strict
13887
+ strict,
13888
+ remove
13997
13889
  });
13998
13890
  }
13999
13891
  return o;
@@ -14002,7 +13894,6 @@ var require_redaction = __commonJS({
14002
13894
  function handle(opts) {
14003
13895
  if (Array.isArray(opts)) {
14004
13896
  opts = { paths: opts, censor: CENSOR };
14005
- validate(opts);
14006
13897
  return opts;
14007
13898
  }
14008
13899
  let { paths, censor = CENSOR, remove } = opts;
@@ -14010,8 +13901,7 @@ var require_redaction = __commonJS({
14010
13901
  throw Error("pino \u2013 redact must contain an array of strings");
14011
13902
  }
14012
13903
  if (remove === true) censor = void 0;
14013
- validate({ paths, censor });
14014
- return { paths, censor };
13904
+ return { paths, censor, remove };
14015
13905
  }
14016
13906
  module2.exports = redaction;
14017
13907
  }
@@ -14025,7 +13915,26 @@ var require_time = __commonJS({
14025
13915
  var epochTime = () => `,"time":${Date.now()}`;
14026
13916
  var unixTime = () => `,"time":${Math.round(Date.now() / 1e3)}`;
14027
13917
  var isoTime = () => `,"time":"${new Date(Date.now()).toISOString()}"`;
14028
- module2.exports = { nullTime, epochTime, unixTime, isoTime };
13918
+ var NS_PER_MS = 1000000n;
13919
+ var NS_PER_SEC = 1000000000n;
13920
+ var startWallTimeNs = BigInt(Date.now()) * NS_PER_MS;
13921
+ var startHrTime = process.hrtime.bigint();
13922
+ var isoTimeNano = () => {
13923
+ const elapsedNs = process.hrtime.bigint() - startHrTime;
13924
+ const currentTimeNs = startWallTimeNs + elapsedNs;
13925
+ const secondsSinceEpoch = currentTimeNs / NS_PER_SEC;
13926
+ const nanosWithinSecond = currentTimeNs % NS_PER_SEC;
13927
+ const msSinceEpoch = Number(secondsSinceEpoch * 1000n + nanosWithinSecond / 1000000n);
13928
+ const date = new Date(msSinceEpoch);
13929
+ const year = date.getUTCFullYear();
13930
+ const month = (date.getUTCMonth() + 1).toString().padStart(2, "0");
13931
+ const day = date.getUTCDate().toString().padStart(2, "0");
13932
+ const hours = date.getUTCHours().toString().padStart(2, "0");
13933
+ const minutes = date.getUTCMinutes().toString().padStart(2, "0");
13934
+ const seconds = date.getUTCSeconds().toString().padStart(2, "0");
13935
+ return `,"time":"${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${nanosWithinSecond.toString().padStart(9, "0")}Z"`;
13936
+ };
13937
+ module2.exports = { nullTime, epochTime, unixTime, isoTime, isoTimeNano };
14029
13938
  }
14030
13939
  });
14031
13940
 
@@ -14192,11 +14101,14 @@ var require_sonic_boom = __commonJS({
14192
14101
  var inherits = require("util").inherits;
14193
14102
  var path = require("path");
14194
14103
  var sleep = require_atomic_sleep();
14104
+ var assert = require("assert");
14195
14105
  var BUSY_WRITE_TIMEOUT = 100;
14196
14106
  var kEmptyBuffer = Buffer.allocUnsafe(0);
14197
14107
  var MAX_WRITE = 16 * 1024;
14198
14108
  var kContentModeBuffer = "buffer";
14199
14109
  var kContentModeUtf8 = "utf8";
14110
+ var [major, minor] = (process.versions.node || "0.0").split(".").map(Number);
14111
+ var kCopyBuffer = major >= 22 && minor >= 7;
14200
14112
  function openFile(file, sonic) {
14201
14113
  sonic._opening = true;
14202
14114
  sonic._writing = true;
@@ -14261,7 +14173,7 @@ var require_sonic_boom = __commonJS({
14261
14173
  if (!(this instanceof SonicBoom)) {
14262
14174
  return new SonicBoom(opts);
14263
14175
  }
14264
- let { fd, dest, minLength, maxLength, maxWrite, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {};
14176
+ let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {};
14265
14177
  fd = fd || dest;
14266
14178
  this._len = 0;
14267
14179
  this.fd = -1;
@@ -14278,6 +14190,8 @@ var require_sonic_boom = __commonJS({
14278
14190
  this.minLength = minLength || 0;
14279
14191
  this.maxLength = maxLength || 0;
14280
14192
  this.maxWrite = maxWrite || MAX_WRITE;
14193
+ this._periodicFlush = periodicFlush || 0;
14194
+ this._periodicFlushTimer = void 0;
14281
14195
  this.sync = sync || false;
14282
14196
  this.writable = true;
14283
14197
  this._fsync = fsync || false;
@@ -14301,8 +14215,18 @@ var require_sonic_boom = __commonJS({
14301
14215
  this.flush = flush;
14302
14216
  this.flushSync = flushSync;
14303
14217
  this._actualWrite = actualWrite;
14304
- fsWriteSync = () => fs.writeSync(this.fd, this._writingBuf, "utf8");
14305
- fsWrite = () => fs.write(this.fd, this._writingBuf, "utf8", this.release);
14218
+ fsWriteSync = () => {
14219
+ if (Buffer.isBuffer(this._writingBuf)) {
14220
+ return fs.writeSync(this.fd, this._writingBuf);
14221
+ }
14222
+ return fs.writeSync(this.fd, this._writingBuf, "utf8");
14223
+ };
14224
+ fsWrite = () => {
14225
+ if (Buffer.isBuffer(this._writingBuf)) {
14226
+ return fs.write(this.fd, this._writingBuf, this.release);
14227
+ }
14228
+ return fs.write(this.fd, this._writingBuf, "utf8", this.release);
14229
+ };
14306
14230
  } else {
14307
14231
  throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
14308
14232
  }
@@ -14391,13 +14315,17 @@ var require_sonic_boom = __commonJS({
14391
14315
  this._asyncDrainScheduled = false;
14392
14316
  }
14393
14317
  });
14318
+ if (this._periodicFlush !== 0) {
14319
+ this._periodicFlushTimer = setInterval(() => this.flush(null), this._periodicFlush);
14320
+ this._periodicFlushTimer.unref();
14321
+ }
14394
14322
  }
14395
14323
  function releaseWritingBuf(writingBuf, len, n) {
14396
- if (typeof writingBuf === "string" && Buffer.byteLength(writingBuf) !== n) {
14397
- n = Buffer.from(writingBuf).subarray(0, n).toString().length;
14324
+ if (typeof writingBuf === "string") {
14325
+ writingBuf = Buffer.from(writingBuf);
14398
14326
  }
14399
14327
  len = Math.max(len - n, 0);
14400
- writingBuf = writingBuf.slice(n);
14328
+ writingBuf = writingBuf.subarray(n);
14401
14329
  return { writingBuf, len };
14402
14330
  }
14403
14331
  function emitDrain(sonic) {
@@ -14420,14 +14348,16 @@ var require_sonic_boom = __commonJS({
14420
14348
  if (this.destroyed) {
14421
14349
  throw new Error("SonicBoom destroyed");
14422
14350
  }
14423
- const len = this._len + data.length;
14351
+ data = "" + data;
14352
+ const dataLen = Buffer.byteLength(data);
14353
+ const len = this._len + dataLen;
14424
14354
  const bufs = this._bufs;
14425
14355
  if (this.maxLength && len > this.maxLength) {
14426
14356
  this.emit("drop", data);
14427
14357
  return this._len < this._hwm;
14428
14358
  }
14429
- if (bufs.length === 0 || bufs[bufs.length - 1].length + data.length > this.maxWrite) {
14430
- bufs.push("" + data);
14359
+ if (bufs.length === 0 || Buffer.byteLength(bufs[bufs.length - 1]) + dataLen > this.maxWrite) {
14360
+ bufs.push(data);
14431
14361
  } else {
14432
14362
  bufs[bufs.length - 1] += data;
14433
14363
  }
@@ -14465,10 +14395,14 @@ var require_sonic_boom = __commonJS({
14465
14395
  this._flushPending = true;
14466
14396
  const onDrain = () => {
14467
14397
  if (!this._fsync) {
14468
- fs.fsync(this.fd, (err) => {
14469
- this._flushPending = false;
14398
+ try {
14399
+ fs.fsync(this.fd, (err) => {
14400
+ this._flushPending = false;
14401
+ cb(err);
14402
+ });
14403
+ } catch (err) {
14470
14404
  cb(err);
14471
- });
14405
+ }
14472
14406
  } else {
14473
14407
  this._flushPending = false;
14474
14408
  cb();
@@ -14608,12 +14542,12 @@ var require_sonic_boom = __commonJS({
14608
14542
  this._writingBuf = "";
14609
14543
  }
14610
14544
  let buf = "";
14611
- while (this._bufs.length || buf) {
14545
+ while (this._bufs.length || buf.length) {
14612
14546
  if (buf.length <= 0) {
14613
14547
  buf = this._bufs[0];
14614
14548
  }
14615
14549
  try {
14616
- const n = fs.writeSync(this.fd, buf, "utf8");
14550
+ const n = Buffer.isBuffer(buf) ? fs.writeSync(this.fd, buf) : fs.writeSync(this.fd, buf, "utf8");
14617
14551
  const releasedBufObj = releaseWritingBuf(buf, this._len, n);
14618
14552
  buf = releasedBufObj.writingBuf;
14619
14553
  this._len = releasedBufObj.len;
@@ -14675,16 +14609,16 @@ var require_sonic_boom = __commonJS({
14675
14609
  function actualWrite() {
14676
14610
  const release = this.release;
14677
14611
  this._writing = true;
14678
- this._writingBuf = this._writingBuf || this._bufs.shift() || "";
14612
+ this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
14679
14613
  if (this.sync) {
14680
14614
  try {
14681
- const written = fs.writeSync(this.fd, this._writingBuf, "utf8");
14615
+ const written = Buffer.isBuffer(this._writingBuf) ? fs.writeSync(this.fd, this._writingBuf) : fs.writeSync(this.fd, this._writingBuf, "utf8");
14682
14616
  release(null, written);
14683
14617
  } catch (err) {
14684
14618
  release(err);
14685
14619
  }
14686
14620
  } else {
14687
- fs.write(this.fd, this._writingBuf, "utf8", release);
14621
+ fs.write(this.fd, this._writingBuf, release);
14688
14622
  }
14689
14623
  }
14690
14624
  function actualWriteBuffer() {
@@ -14699,6 +14633,9 @@ var require_sonic_boom = __commonJS({
14699
14633
  release(err);
14700
14634
  }
14701
14635
  } else {
14636
+ if (kCopyBuffer) {
14637
+ this._writingBuf = Buffer.from(this._writingBuf);
14638
+ }
14702
14639
  fs.write(this.fd, this._writingBuf, release);
14703
14640
  }
14704
14641
  }
@@ -14707,10 +14644,17 @@ var require_sonic_boom = __commonJS({
14707
14644
  sonic.once("ready", actualClose.bind(null, sonic));
14708
14645
  return;
14709
14646
  }
14647
+ if (sonic._periodicFlushTimer !== void 0) {
14648
+ clearInterval(sonic._periodicFlushTimer);
14649
+ }
14710
14650
  sonic.destroyed = true;
14711
14651
  sonic._bufs = [];
14712
14652
  sonic._lens = [];
14713
- fs.fsync(sonic.fd, closeWrapped);
14653
+ assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
14654
+ try {
14655
+ fs.fsync(sonic.fd, closeWrapped);
14656
+ } catch {
14657
+ }
14714
14658
  function closeWrapped() {
14715
14659
  if (sonic.fd !== 1 && sonic.fd !== 2) {
14716
14660
  fs.close(sonic.fd, done);
@@ -14834,41 +14778,36 @@ var require_package2 = __commonJS({
14834
14778
  "node_modules/thread-stream/package.json"(exports2, module2) {
14835
14779
  module2.exports = {
14836
14780
  name: "thread-stream",
14837
- version: "2.7.0",
14781
+ version: "4.2.0",
14838
14782
  description: "A streaming way to send data to a Node.js Worker Thread",
14839
14783
  main: "index.js",
14840
14784
  types: "index.d.ts",
14785
+ engines: {
14786
+ node: ">=20"
14787
+ },
14841
14788
  dependencies: {
14842
- "real-require": "^0.2.0"
14789
+ "real-require": "^1.0.0"
14843
14790
  },
14844
14791
  devDependencies: {
14845
- "@types/node": "^20.1.0",
14846
- "@types/tap": "^15.0.0",
14847
- "@yao-pkg/pkg": "^5.11.5",
14792
+ "@types/node": "^25.0.2",
14793
+ "@yao-pkg/pkg": "^6.0.0",
14794
+ borp: "^1.0.0",
14848
14795
  desm: "^1.3.0",
14796
+ eslint: "^9.39.1",
14849
14797
  fastbench: "^1.0.1",
14850
- husky: "^9.0.6",
14851
- "pino-elasticsearch": "^8.0.0",
14852
- "sonic-boom": "^3.0.0",
14853
- standard: "^17.0.0",
14854
- tap: "^16.2.0",
14798
+ neostandard: "^0.13.0",
14799
+ "pino-elasticsearch": "^9.0.0",
14800
+ "sonic-boom": "^5.0.0",
14855
14801
  "ts-node": "^10.8.0",
14856
- typescript: "^5.3.2",
14857
- "why-is-node-running": "^2.2.2"
14802
+ typescript: "~5.7.3"
14858
14803
  },
14859
14804
  scripts: {
14860
- test: 'standard && npm run transpile && tap "test/**/*.test.*js" && tap --ts test/*.test.*ts',
14861
- "test:ci": "standard && npm run transpile && npm run test:ci:js && npm run test:ci:ts",
14862
- "test:ci:js": 'tap --no-check-coverage --timeout=120 --coverage-report=lcovonly "test/**/*.test.*js"',
14863
- "test:ci:ts": 'tap --ts --no-check-coverage --coverage-report=lcovonly "test/**/*.test.*ts"',
14864
- "test:yarn": 'npm run transpile && tap "test/**/*.test.js" --no-check-coverage',
14865
- transpile: "sh ./test/ts/transpile.sh",
14866
- prepare: "husky install"
14867
- },
14868
- standard: {
14869
- ignore: [
14870
- "test/ts/**/*"
14871
- ]
14805
+ build: "tsc --noEmit",
14806
+ lint: "eslint",
14807
+ test: 'npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',
14808
+ "test:ci": 'npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',
14809
+ "test:yarn": 'npm run transpile && borp --pattern "test/*.test.js"',
14810
+ transpile: "sh ./test/ts/transpile.sh"
14872
14811
  },
14873
14812
  repository: {
14874
14813
  type: "git",
@@ -14894,55 +14833,56 @@ var require_package2 = __commonJS({
14894
14833
  var require_wait = __commonJS({
14895
14834
  "node_modules/thread-stream/lib/wait.js"(exports2, module2) {
14896
14835
  "use strict";
14897
- var MAX_TIMEOUT = 1e3;
14836
+ var WAIT_MS = 1e4;
14898
14837
  function wait(state, index, expected, timeout, done) {
14899
- const max = Date.now() + timeout;
14900
- let current = Atomics.load(state, index);
14901
- if (current === expected) {
14902
- done(null, "ok");
14903
- return;
14904
- }
14905
- let prior = current;
14906
- const check = (backoff) => {
14907
- if (Date.now() > max) {
14838
+ const max = timeout === Infinity ? Infinity : Date.now() + timeout;
14839
+ const check = () => {
14840
+ const current = Atomics.load(state, index);
14841
+ if (current === expected) {
14842
+ done(null, "ok");
14843
+ return;
14844
+ }
14845
+ if (max !== Infinity && Date.now() > max) {
14908
14846
  done(null, "timed-out");
14847
+ return;
14848
+ }
14849
+ const remaining = max === Infinity ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
14850
+ const result = Atomics.waitAsync(state, index, current, remaining);
14851
+ if (result.async) {
14852
+ result.value.then(check);
14909
14853
  } else {
14910
- setTimeout(() => {
14911
- prior = current;
14912
- current = Atomics.load(state, index);
14913
- if (current === prior) {
14914
- check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
14915
- } else {
14916
- if (current === expected) done(null, "ok");
14917
- else done(null, "not-equal");
14918
- }
14919
- }, backoff);
14854
+ setImmediate(check);
14920
14855
  }
14921
14856
  };
14922
- check(1);
14857
+ check();
14923
14858
  }
14924
14859
  function waitDiff(state, index, expected, timeout, done) {
14925
- const max = Date.now() + timeout;
14926
- let current = Atomics.load(state, index);
14927
- if (current !== expected) {
14928
- done(null, "ok");
14929
- return;
14930
- }
14931
- const check = (backoff) => {
14932
- if (Date.now() > max) {
14860
+ const max = timeout === Infinity ? Infinity : Date.now() + timeout;
14861
+ const check = () => {
14862
+ const current = Atomics.load(state, index);
14863
+ if (current !== expected) {
14864
+ done(null, "ok");
14865
+ return;
14866
+ }
14867
+ if (max !== Infinity && Date.now() > max) {
14933
14868
  done(null, "timed-out");
14934
- } else {
14935
- setTimeout(() => {
14936
- current = Atomics.load(state, index);
14937
- if (current !== expected) {
14869
+ return;
14870
+ }
14871
+ const remaining = max === Infinity ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
14872
+ const result = Atomics.waitAsync(state, index, expected, remaining);
14873
+ if (result.async) {
14874
+ result.value.then((res) => {
14875
+ if (res === "ok") {
14938
14876
  done(null, "ok");
14939
- } else {
14940
- check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
14877
+ return;
14941
14878
  }
14942
- }, backoff);
14879
+ check();
14880
+ });
14881
+ } else {
14882
+ setImmediate(check);
14943
14883
  }
14944
14884
  };
14945
- check(1);
14885
+ check();
14946
14886
  }
14947
14887
  module2.exports = { wait, waitDiff };
14948
14888
  }
@@ -14952,11 +14892,13 @@ var require_wait = __commonJS({
14952
14892
  var require_indexes = __commonJS({
14953
14893
  "node_modules/thread-stream/lib/indexes.js"(exports2, module2) {
14954
14894
  "use strict";
14895
+ var SEQ_INDEX = 2;
14955
14896
  var WRITE_INDEX = 4;
14956
14897
  var READ_INDEX = 8;
14957
14898
  module2.exports = {
14958
14899
  WRITE_INDEX,
14959
- READ_INDEX
14900
+ READ_INDEX,
14901
+ SEQ_INDEX
14960
14902
  };
14961
14903
  }
14962
14904
  });
@@ -14973,12 +14915,27 @@ var require_thread_stream = __commonJS({
14973
14915
  var { wait } = require_wait();
14974
14916
  var {
14975
14917
  WRITE_INDEX,
14976
- READ_INDEX
14918
+ READ_INDEX,
14919
+ SEQ_INDEX
14977
14920
  } = require_indexes();
14978
14921
  var buffer = require("buffer");
14979
14922
  var assert = require("assert");
14980
14923
  var kImpl = /* @__PURE__ */ Symbol("kImpl");
14981
14924
  var MAX_STRING = buffer.constants.MAX_STRING_LENGTH;
14925
+ function noop() {
14926
+ }
14927
+ function updateState(stream, fn) {
14928
+ Atomics.add(stream[kImpl].state, SEQ_INDEX, 1);
14929
+ fn();
14930
+ Atomics.add(stream[kImpl].state, SEQ_INDEX, 1);
14931
+ Atomics.notify(stream[kImpl].state, SEQ_INDEX);
14932
+ }
14933
+ function resetIndexes(stream) {
14934
+ updateState(stream, () => {
14935
+ Atomics.store(stream[kImpl].state, READ_INDEX, 0);
14936
+ Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
14937
+ });
14938
+ }
14982
14939
  var FakeWeakRef = class {
14983
14940
  constructor(value) {
14984
14941
  this._value = value;
@@ -15007,6 +14964,7 @@ var require_thread_stream = __commonJS({
15007
14964
  const toExecute = bundlerOverrides["thread-stream-worker"] || join2(__dirname, "lib", "worker.js");
15008
14965
  const worker = new Worker(toExecute, {
15009
14966
  ...opts.workerOpts,
14967
+ name: opts.workerOpts?.name || "thread-stream",
15010
14968
  trackUnmanagedFds: false,
15011
14969
  workerData: {
15012
14970
  filename: filename.indexOf("file://") === 0 ? filename : pathToFileURL(filename).href,
@@ -15034,50 +14992,37 @@ var require_thread_stream = __commonJS({
15034
14992
  }
15035
14993
  }
15036
14994
  function nextFlush(stream) {
15037
- const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
15038
- let leftover = stream[kImpl].data.length - writeIndex;
15039
- if (leftover > 0) {
15040
- if (stream[kImpl].buf.length === 0) {
15041
- stream[kImpl].flushing = false;
15042
- if (stream[kImpl].ending) {
15043
- end(stream);
15044
- } else if (stream[kImpl].needDrain) {
15045
- process.nextTick(drain, stream);
14995
+ while (true) {
14996
+ const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
14997
+ const leftover = stream[kImpl].data.length - writeIndex;
14998
+ if (leftover > 0) {
14999
+ if (stream[kImpl].bufLen === 0) {
15000
+ stream[kImpl].flushing = false;
15001
+ if (stream[kImpl].ending) {
15002
+ end(stream);
15003
+ } else if (stream[kImpl].needDrain) {
15004
+ process.nextTick(drain, stream);
15005
+ }
15006
+ return;
15046
15007
  }
15047
- return;
15008
+ write(stream, leftover, noop);
15009
+ continue;
15048
15010
  }
15049
- let toWrite = stream[kImpl].buf.slice(0, leftover);
15050
- let toWriteBytes = Buffer.byteLength(toWrite);
15051
- if (toWriteBytes <= leftover) {
15052
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
15053
- write(stream, toWrite, nextFlush.bind(null, stream));
15054
- } else {
15055
- stream.flush(() => {
15011
+ if (leftover === 0) {
15012
+ if (writeIndex === 0 && stream[kImpl].bufLen === 0) {
15013
+ return;
15014
+ }
15015
+ waitForRead(stream, () => {
15056
15016
  if (stream.destroyed) {
15057
15017
  return;
15058
15018
  }
15059
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
15060
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
15061
- while (toWriteBytes > stream[kImpl].data.length) {
15062
- leftover = leftover / 2;
15063
- toWrite = stream[kImpl].buf.slice(0, leftover);
15064
- toWriteBytes = Buffer.byteLength(toWrite);
15065
- }
15066
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
15067
- write(stream, toWrite, nextFlush.bind(null, stream));
15019
+ resetIndexes(stream);
15020
+ nextFlush(stream);
15068
15021
  });
15069
- }
15070
- } else if (leftover === 0) {
15071
- if (writeIndex === 0 && stream[kImpl].buf.length === 0) {
15072
15022
  return;
15073
15023
  }
15074
- stream.flush(() => {
15075
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
15076
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
15077
- nextFlush(stream);
15078
- });
15079
- } else {
15080
15024
  destroy(stream, new Error("overwritten"));
15025
+ return;
15081
15026
  }
15082
15027
  }
15083
15028
  function onWorkerMessage(msg) {
@@ -15087,10 +15032,13 @@ var require_thread_stream = __commonJS({
15087
15032
  this.terminate();
15088
15033
  return;
15089
15034
  }
15035
+ if (msg?.code == null) {
15036
+ return;
15037
+ }
15090
15038
  switch (msg.code) {
15091
15039
  case "READY":
15092
15040
  this.stream = new WeakRef2(stream);
15093
- stream.flush(() => {
15041
+ waitForRead(stream, () => {
15094
15042
  stream[kImpl].ready = true;
15095
15043
  stream.emit("ready");
15096
15044
  });
@@ -15105,6 +15053,18 @@ var require_thread_stream = __commonJS({
15105
15053
  stream.emit(msg.name, msg.args);
15106
15054
  }
15107
15055
  break;
15056
+ case "FLUSHED": {
15057
+ if (msg.context !== "thread-stream") {
15058
+ destroy(stream, new Error("this should not happen: " + msg.code));
15059
+ break;
15060
+ }
15061
+ const cb = stream[kImpl].flushCallbacks.get(msg.id);
15062
+ if (cb) {
15063
+ stream[kImpl].flushCallbacks.delete(msg.id);
15064
+ process.nextTick(cb);
15065
+ }
15066
+ break;
15067
+ }
15108
15068
  case "WARNING":
15109
15069
  process.emitWarning(msg.err);
15110
15070
  break;
@@ -15143,13 +15103,18 @@ var require_thread_stream = __commonJS({
15143
15103
  this[kImpl].finished = false;
15144
15104
  this[kImpl].errored = null;
15145
15105
  this[kImpl].closed = false;
15146
- this[kImpl].buf = "";
15106
+ this[kImpl].buf = [];
15107
+ this[kImpl].bufHead = 0;
15108
+ this[kImpl].bufLen = 0;
15109
+ this[kImpl].flushCallbacks = /* @__PURE__ */ new Map();
15110
+ this[kImpl].nextFlushId = 0;
15147
15111
  this.worker = createWorker(this, opts);
15148
15112
  this.on("message", (message, transferList) => {
15149
15113
  this.worker.postMessage(message, transferList);
15150
15114
  });
15151
15115
  }
15152
15116
  write(data) {
15117
+ const dataBuf = Buffer.isBuffer(data) ? data : Buffer.from(data);
15153
15118
  if (this[kImpl].destroyed) {
15154
15119
  error(this, new Error("the worker has exited"));
15155
15120
  return false;
@@ -15158,7 +15123,7 @@ var require_thread_stream = __commonJS({
15158
15123
  error(this, new Error("the worker is ending"));
15159
15124
  return false;
15160
15125
  }
15161
- if (this[kImpl].flushing && this[kImpl].buf.length + data.length >= MAX_STRING) {
15126
+ if (this[kImpl].flushing && this[kImpl].bufLen + dataBuf.length >= MAX_STRING) {
15162
15127
  try {
15163
15128
  writeSync(this);
15164
15129
  this[kImpl].flushing = true;
@@ -15167,7 +15132,8 @@ var require_thread_stream = __commonJS({
15167
15132
  return false;
15168
15133
  }
15169
15134
  }
15170
- this[kImpl].buf += data;
15135
+ this[kImpl].buf.push(dataBuf);
15136
+ this[kImpl].bufLen += dataBuf.length;
15171
15137
  if (this[kImpl].sync) {
15172
15138
  try {
15173
15139
  writeSync(this);
@@ -15181,7 +15147,7 @@ var require_thread_stream = __commonJS({
15181
15147
  this[kImpl].flushing = true;
15182
15148
  setImmediate(nextFlush, this);
15183
15149
  }
15184
- this[kImpl].needDrain = this[kImpl].data.length - this[kImpl].buf.length - Atomics.load(this[kImpl].state, WRITE_INDEX) <= 0;
15150
+ this[kImpl].needDrain = this[kImpl].data.length - this[kImpl].bufLen - Atomics.load(this[kImpl].state, WRITE_INDEX) <= 0;
15185
15151
  return !this[kImpl].needDrain;
15186
15152
  }
15187
15153
  end() {
@@ -15192,24 +15158,13 @@ var require_thread_stream = __commonJS({
15192
15158
  end(this);
15193
15159
  }
15194
15160
  flush(cb) {
15195
- if (this[kImpl].destroyed) {
15196
- if (typeof cb === "function") {
15197
- process.nextTick(cb, new Error("the worker has exited"));
15198
- }
15199
- return;
15200
- }
15201
- const writeIndex = Atomics.load(this[kImpl].state, WRITE_INDEX);
15202
- wait(this[kImpl].state, READ_INDEX, writeIndex, Infinity, (err, res) => {
15161
+ cb = typeof cb === "function" ? cb : noop;
15162
+ flushBuffer(this, (err) => {
15203
15163
  if (err) {
15204
- destroy(this, err);
15205
15164
  process.nextTick(cb, err);
15206
15165
  return;
15207
15166
  }
15208
- if (res === "not-equal") {
15209
- this.flush(cb);
15210
- return;
15211
- }
15212
- process.nextTick(cb);
15167
+ requestWorkerFlush(this, cb);
15213
15168
  });
15214
15169
  }
15215
15170
  flushSync() {
@@ -15253,6 +15208,79 @@ var require_thread_stream = __commonJS({
15253
15208
  return this[kImpl].errored;
15254
15209
  }
15255
15210
  };
15211
+ function flushBuffer(stream, cb) {
15212
+ if (stream[kImpl].destroyed) {
15213
+ process.nextTick(cb, new Error("the worker has exited"));
15214
+ return;
15215
+ }
15216
+ if (!stream[kImpl].sync && (stream[kImpl].flushing || stream[kImpl].bufLen > 0)) {
15217
+ setImmediate(flushBuffer, stream, cb);
15218
+ return;
15219
+ }
15220
+ waitForRead(stream, cb);
15221
+ }
15222
+ function waitForRead(stream, cb) {
15223
+ const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
15224
+ wait(stream[kImpl].state, READ_INDEX, writeIndex, Infinity, (err, res) => {
15225
+ if (err) {
15226
+ destroy(stream, err);
15227
+ cb(err);
15228
+ return;
15229
+ }
15230
+ if (res !== "ok") {
15231
+ waitForRead(stream, cb);
15232
+ return;
15233
+ }
15234
+ cb();
15235
+ });
15236
+ }
15237
+ function requestWorkerFlush(stream, cb) {
15238
+ if (stream[kImpl].destroyed) {
15239
+ process.nextTick(cb, new Error("the worker has exited"));
15240
+ return;
15241
+ }
15242
+ if (!stream[kImpl].ready) {
15243
+ const onReady = () => {
15244
+ cleanup();
15245
+ requestWorkerFlush(stream, cb);
15246
+ };
15247
+ const onClose = () => {
15248
+ cleanup();
15249
+ process.nextTick(cb, new Error("the worker has exited"));
15250
+ };
15251
+ const cleanup = () => {
15252
+ stream.off("ready", onReady);
15253
+ stream.off("close", onClose);
15254
+ };
15255
+ stream.once("ready", onReady);
15256
+ stream.once("close", onClose);
15257
+ return;
15258
+ }
15259
+ const id = ++stream[kImpl].nextFlushId;
15260
+ stream[kImpl].flushCallbacks.set(id, cb);
15261
+ try {
15262
+ stream.worker.postMessage({
15263
+ code: "FLUSH",
15264
+ context: "thread-stream",
15265
+ id
15266
+ });
15267
+ } catch (err) {
15268
+ stream[kImpl].flushCallbacks.delete(id);
15269
+ destroy(stream, err);
15270
+ process.nextTick(cb, err);
15271
+ }
15272
+ }
15273
+ function failPendingFlushCallbacks(stream, err) {
15274
+ const callbacks = stream[kImpl].flushCallbacks;
15275
+ if (callbacks.size === 0) {
15276
+ return;
15277
+ }
15278
+ const flushErr = err || new Error("the worker has exited");
15279
+ for (const cb of callbacks.values()) {
15280
+ process.nextTick(cb, flushErr);
15281
+ }
15282
+ callbacks.clear();
15283
+ }
15256
15284
  function error(stream, err) {
15257
15285
  setImmediate(() => {
15258
15286
  stream.emit("error", err);
@@ -15263,6 +15291,7 @@ var require_thread_stream = __commonJS({
15263
15291
  return;
15264
15292
  }
15265
15293
  stream[kImpl].destroyed = true;
15294
+ failPendingFlushCallbacks(stream, err);
15266
15295
  if (err) {
15267
15296
  stream[kImpl].errored = err;
15268
15297
  error(stream, err);
@@ -15280,12 +15309,37 @@ var require_thread_stream = __commonJS({
15280
15309
  });
15281
15310
  }
15282
15311
  }
15283
- function write(stream, data, cb) {
15312
+ function write(stream, maxBytes, cb) {
15284
15313
  const current = Atomics.load(stream[kImpl].state, WRITE_INDEX);
15285
- const length = Buffer.byteLength(data);
15286
- stream[kImpl].data.write(data, current);
15287
- Atomics.store(stream[kImpl].state, WRITE_INDEX, current + length);
15288
- Atomics.notify(stream[kImpl].state, WRITE_INDEX);
15314
+ let offset = current;
15315
+ let remaining = maxBytes;
15316
+ while (remaining > 0 && stream[kImpl].bufLen !== 0) {
15317
+ const head = stream[kImpl].bufHead;
15318
+ const buf = stream[kImpl].buf[head];
15319
+ if (buf.length <= remaining) {
15320
+ buf.copy(stream[kImpl].data, offset);
15321
+ offset += buf.length;
15322
+ remaining -= buf.length;
15323
+ stream[kImpl].bufLen -= buf.length;
15324
+ stream[kImpl].bufHead = head + 1;
15325
+ if (stream[kImpl].bufHead === stream[kImpl].buf.length) {
15326
+ stream[kImpl].buf.length = 0;
15327
+ stream[kImpl].bufHead = 0;
15328
+ } else if (stream[kImpl].bufHead >= 1024 && stream[kImpl].bufHead * 2 >= stream[kImpl].buf.length) {
15329
+ stream[kImpl].buf.splice(0, stream[kImpl].bufHead);
15330
+ stream[kImpl].bufHead = 0;
15331
+ }
15332
+ continue;
15333
+ }
15334
+ buf.copy(stream[kImpl].data, offset, 0, remaining);
15335
+ stream[kImpl].buf[head] = buf.subarray(remaining);
15336
+ stream[kImpl].bufLen -= remaining;
15337
+ offset += remaining;
15338
+ remaining = 0;
15339
+ }
15340
+ updateState(stream, () => {
15341
+ Atomics.store(stream[kImpl].state, WRITE_INDEX, offset);
15342
+ });
15289
15343
  cb();
15290
15344
  return true;
15291
15345
  }
@@ -15297,8 +15351,9 @@ var require_thread_stream = __commonJS({
15297
15351
  try {
15298
15352
  stream.flushSync();
15299
15353
  let readIndex = Atomics.load(stream[kImpl].state, READ_INDEX);
15300
- Atomics.store(stream[kImpl].state, WRITE_INDEX, -1);
15301
- Atomics.notify(stream[kImpl].state, WRITE_INDEX);
15354
+ updateState(stream, () => {
15355
+ Atomics.store(stream[kImpl].state, WRITE_INDEX, -1);
15356
+ });
15302
15357
  let spins = 0;
15303
15358
  while (readIndex !== -1) {
15304
15359
  Atomics.wait(stream[kImpl].state, READ_INDEX, readIndex, 1e3);
@@ -15329,34 +15384,17 @@ var require_thread_stream = __commonJS({
15329
15384
  }
15330
15385
  };
15331
15386
  stream[kImpl].flushing = false;
15332
- while (stream[kImpl].buf.length !== 0) {
15387
+ while (stream[kImpl].bufLen !== 0) {
15333
15388
  const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
15334
- let leftover = stream[kImpl].data.length - writeIndex;
15389
+ const leftover = stream[kImpl].data.length - writeIndex;
15335
15390
  if (leftover === 0) {
15336
15391
  flushSync(stream);
15337
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
15338
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
15392
+ resetIndexes(stream);
15339
15393
  continue;
15340
15394
  } else if (leftover < 0) {
15341
15395
  throw new Error("overwritten");
15342
15396
  }
15343
- let toWrite = stream[kImpl].buf.slice(0, leftover);
15344
- let toWriteBytes = Buffer.byteLength(toWrite);
15345
- if (toWriteBytes <= leftover) {
15346
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
15347
- write(stream, toWrite, cb);
15348
- } else {
15349
- flushSync(stream);
15350
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
15351
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
15352
- while (toWriteBytes > stream[kImpl].buf.length) {
15353
- leftover = leftover / 2;
15354
- toWrite = stream[kImpl].buf.slice(0, leftover);
15355
- toWriteBytes = Buffer.byteLength(toWrite);
15356
- }
15357
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
15358
- write(stream, toWrite, cb);
15359
- }
15397
+ write(stream, leftover, cb);
15360
15398
  }
15361
15399
  }
15362
15400
  function flushSync(stream) {
@@ -15389,8 +15427,10 @@ var require_transport = __commonJS({
15389
15427
  "node_modules/pino/lib/transport.js"(exports2, module2) {
15390
15428
  "use strict";
15391
15429
  var { createRequire } = require("module");
15430
+ var { existsSync } = require("fs");
15392
15431
  var getCallers = require_caller();
15393
15432
  var { join: join2, isAbsolute, sep } = require("path");
15433
+ var { fileURLToPath } = require("url");
15394
15434
  var sleep = require_atomic_sleep();
15395
15435
  var onExit = require_on_exit_leak_free();
15396
15436
  var ThreadStream = require_thread_stream();
@@ -15401,11 +15441,101 @@ var require_transport = __commonJS({
15401
15441
  onExit.unregister(stream);
15402
15442
  });
15403
15443
  }
15404
- function buildStream(filename, workerData, workerOpts) {
15444
+ function hasPreloadFlags() {
15445
+ const execArgv = process.execArgv;
15446
+ for (let i = 0; i < execArgv.length; i++) {
15447
+ const arg = execArgv[i];
15448
+ if (arg === "--import" || arg === "--require" || arg === "-r") {
15449
+ return true;
15450
+ }
15451
+ if (arg.startsWith("--import=") || arg.startsWith("--require=") || arg.startsWith("-r=")) {
15452
+ return true;
15453
+ }
15454
+ }
15455
+ return false;
15456
+ }
15457
+ function sanitizeNodeOptions(nodeOptions) {
15458
+ const tokens = nodeOptions.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);
15459
+ if (!tokens) {
15460
+ return nodeOptions;
15461
+ }
15462
+ const sanitized = [];
15463
+ let changed = false;
15464
+ for (let i = 0; i < tokens.length; i++) {
15465
+ const token2 = tokens[i];
15466
+ if (token2 === "--require" || token2 === "-r" || token2 === "--import") {
15467
+ const next = tokens[i + 1];
15468
+ if (next && shouldDropPreload(next)) {
15469
+ changed = true;
15470
+ i++;
15471
+ continue;
15472
+ }
15473
+ sanitized.push(token2);
15474
+ if (next) {
15475
+ sanitized.push(next);
15476
+ i++;
15477
+ }
15478
+ continue;
15479
+ }
15480
+ if (token2.startsWith("--require=") || token2.startsWith("-r=") || token2.startsWith("--import=")) {
15481
+ const value = token2.slice(token2.indexOf("=") + 1);
15482
+ if (shouldDropPreload(value)) {
15483
+ changed = true;
15484
+ continue;
15485
+ }
15486
+ }
15487
+ sanitized.push(token2);
15488
+ }
15489
+ return changed ? sanitized.join(" ") : nodeOptions;
15490
+ }
15491
+ function shouldDropPreload(value) {
15492
+ const unquoted = stripQuotes(value);
15493
+ if (!unquoted) {
15494
+ return false;
15495
+ }
15496
+ let path = unquoted;
15497
+ if (path.startsWith("file://")) {
15498
+ try {
15499
+ path = fileURLToPath(path);
15500
+ } catch {
15501
+ return false;
15502
+ }
15503
+ }
15504
+ return isAbsolute(path) && !existsSync(path);
15505
+ }
15506
+ function stripQuotes(value) {
15507
+ const first = value[0];
15508
+ const last = value[value.length - 1];
15509
+ if (first === '"' && last === '"' || first === "'" && last === "'") {
15510
+ return value.slice(1, -1);
15511
+ }
15512
+ return value;
15513
+ }
15514
+ function buildStream(filename, workerData, workerOpts, sync, name) {
15515
+ if (!workerOpts.execArgv && hasPreloadFlags() && require.main === void 0) {
15516
+ workerOpts = {
15517
+ ...workerOpts,
15518
+ execArgv: []
15519
+ };
15520
+ }
15521
+ if (!workerOpts.env && process.env.NODE_OPTIONS) {
15522
+ const nodeOptions = sanitizeNodeOptions(process.env.NODE_OPTIONS);
15523
+ if (nodeOptions !== process.env.NODE_OPTIONS) {
15524
+ workerOpts = {
15525
+ ...workerOpts,
15526
+ env: {
15527
+ ...process.env,
15528
+ NODE_OPTIONS: nodeOptions
15529
+ }
15530
+ };
15531
+ }
15532
+ }
15533
+ workerOpts = { ...workerOpts, name };
15405
15534
  const stream = new ThreadStream({
15406
15535
  filename,
15407
15536
  workerData,
15408
- workerOpts
15537
+ workerOpts,
15538
+ sync
15409
15539
  });
15410
15540
  stream.on("ready", onReady);
15411
15541
  stream.on("close", function() {
@@ -15441,29 +15571,42 @@ var require_transport = __commonJS({
15441
15571
  stream.flushSync();
15442
15572
  }
15443
15573
  function transport(fullOptions) {
15444
- const { pipeline, targets, levels, dedupe, options = {}, worker = {}, caller = getCallers() } = fullOptions;
15574
+ const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
15575
+ const options = {
15576
+ ...fullOptions.options
15577
+ };
15445
15578
  const callers = typeof caller === "string" ? [caller] : caller;
15446
- const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
15579
+ const bundlerOverrides = typeof globalThis === "object" && Object.prototype.hasOwnProperty.call(globalThis, "__bundlerPathsOverrides") && globalThis.__bundlerPathsOverrides && typeof globalThis.__bundlerPathsOverrides === "object" ? globalThis.__bundlerPathsOverrides : /* @__PURE__ */ Object.create(null);
15447
15580
  let target = fullOptions.target;
15448
15581
  if (target && targets) {
15449
15582
  throw new Error("only one of target or targets can be specified");
15450
15583
  }
15451
15584
  if (targets) {
15452
15585
  target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
15453
- options.targets = targets.map((dest) => {
15586
+ options.targets = targets.filter((dest) => dest.target).map((dest) => {
15454
15587
  return {
15455
15588
  ...dest,
15456
15589
  target: fixTarget(dest.target)
15457
15590
  };
15458
15591
  });
15592
+ options.pipelines = targets.filter((dest) => dest.pipeline).map((dest) => {
15593
+ return dest.pipeline.map((t) => {
15594
+ return {
15595
+ ...t,
15596
+ level: dest.level,
15597
+ // duplicate the pipeline `level` property defined in the upper level
15598
+ target: fixTarget(t.target)
15599
+ };
15600
+ });
15601
+ });
15459
15602
  } else if (pipeline) {
15460
- target = bundlerOverrides["pino-pipeline-worker"] || join2(__dirname, "worker-pipeline.js");
15461
- options.targets = pipeline.map((dest) => {
15603
+ target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
15604
+ options.pipelines = [pipeline.map((dest) => {
15462
15605
  return {
15463
15606
  ...dest,
15464
15607
  target: fixTarget(dest.target)
15465
15608
  };
15466
- });
15609
+ })];
15467
15610
  }
15468
15611
  if (levels) {
15469
15612
  options.levels = levels;
@@ -15472,7 +15615,8 @@ var require_transport = __commonJS({
15472
15615
  options.dedupe = dedupe;
15473
15616
  }
15474
15617
  options.pinoWillSendConfig = true;
15475
- return buildStream(fixTarget(target), options, worker);
15618
+ const name = targets || pipeline ? "pino.transport" : target;
15619
+ return buildStream(fixTarget(target), options, worker, sync, name);
15476
15620
  function fixTarget(origin) {
15477
15621
  origin = bundlerOverrides[origin] || origin;
15478
15622
  if (isAbsolute(origin) || origin.indexOf("file://") === 0) {
@@ -15505,6 +15649,7 @@ var require_transport = __commonJS({
15505
15649
  var require_tools = __commonJS({
15506
15650
  "node_modules/pino/lib/tools.js"(exports2, module2) {
15507
15651
  "use strict";
15652
+ var diagChan = require("diagnostics_channel");
15508
15653
  var format2 = require_quick_format_unescaped();
15509
15654
  var { mapHttpRequest, mapHttpResponse } = require_pino_std_serializers();
15510
15655
  var SonicBoom = require_sonic_boom();
@@ -15529,6 +15674,9 @@ var require_tools = __commonJS({
15529
15674
  } = require_symbols();
15530
15675
  var { isMainThread } = require("worker_threads");
15531
15676
  var transport = require_transport();
15677
+ var [nodeMajor] = process.versions.node.split(".").map((v) => Number(v));
15678
+ var asJsonChan = diagChan.tracingChannel("pino_asJson");
15679
+ var asString = nodeMajor >= 25 ? (str) => JSON.stringify(str) : _asString;
15532
15680
  function noop() {
15533
15681
  }
15534
15682
  function genLog(level, hook) {
@@ -15566,7 +15714,7 @@ var require_tools = __commonJS({
15566
15714
  }
15567
15715
  }
15568
15716
  }
15569
- function asString(str) {
15717
+ function _asString(str) {
15570
15718
  let result = "";
15571
15719
  let last = 0;
15572
15720
  let found = false;
@@ -15591,6 +15739,13 @@ var require_tools = __commonJS({
15591
15739
  return point < 32 ? JSON.stringify(str) : '"' + result + '"';
15592
15740
  }
15593
15741
  function asJson(obj, msg, num, time) {
15742
+ if (asJsonChan.hasSubscribers === false) {
15743
+ return _asJson.call(this, obj, msg, num, time);
15744
+ }
15745
+ const store = { instance: this, arguments };
15746
+ return asJsonChan.traceSync(_asJson, store, this, obj, msg, num, time);
15747
+ }
15748
+ function _asJson(obj, msg, num, time) {
15594
15749
  const stringify2 = this[stringifySym];
15595
15750
  const stringifySafe = this[stringifySafeSym];
15596
15751
  const stringifiers = this[stringifiersSym];
@@ -15683,7 +15838,7 @@ var require_tools = __commonJS({
15683
15838
  bindings = formatter(bindings);
15684
15839
  for (const key in bindings) {
15685
15840
  value = bindings[key];
15686
- const valid = key !== "level" && key !== "serializers" && key !== "formatters" && key !== "customLevels" && bindings.hasOwnProperty(key) && value !== void 0;
15841
+ const valid = (key.length < 5 || key !== "level" && key !== "serializers" && key !== "formatters" && key !== "customLevels") && bindings.hasOwnProperty(key) && value !== void 0;
15687
15842
  if (valid === true) {
15688
15843
  value = serializers[key] ? serializers[key](value) : value;
15689
15844
  value = (stringifiers[key] || wildcardStringifier || stringify2)(value, stringifySafe);
@@ -15696,11 +15851,10 @@ var require_tools = __commonJS({
15696
15851
  function hasBeenTampered(stream) {
15697
15852
  return stream.write !== stream.constructor.prototype.write;
15698
15853
  }
15699
- var hasNodeCodeCoverage = process.env.NODE_V8_COVERAGE || process.env.V8_COVERAGE;
15700
15854
  function buildSafeSonicBoom(opts) {
15701
15855
  const stream = new SonicBoom(opts);
15702
15856
  stream.on("error", filterBrokenPipe);
15703
- if (!hasNodeCodeCoverage && !opts.sync && isMainThread) {
15857
+ if (!opts.sync && isMainThread) {
15704
15858
  onExit.register(stream, autoEnd);
15705
15859
  stream.on("close", function() {
15706
15860
  onExit.unregister(stream);
@@ -16040,7 +16194,7 @@ var require_levels2 = __commonJS({
16040
16194
  var require_meta = __commonJS({
16041
16195
  "node_modules/pino/lib/meta.js"(exports2, module2) {
16042
16196
  "use strict";
16043
- module2.exports = { version: "8.21.0" };
16197
+ module2.exports = { version: "10.3.1" };
16044
16198
  }
16045
16199
  });
16046
16200
 
@@ -16055,7 +16209,6 @@ var require_proto = __commonJS({
16055
16209
  setLevelSym,
16056
16210
  getLevelSym,
16057
16211
  chindingsSym,
16058
- parsedChindingsSym,
16059
16212
  mixinSym,
16060
16213
  asJsonSym,
16061
16214
  writeSym,
@@ -16073,7 +16226,8 @@ var require_proto = __commonJS({
16073
16226
  stringifySym,
16074
16227
  formatOptsSym,
16075
16228
  stringifiersSym,
16076
- msgPrefixSym
16229
+ msgPrefixSym,
16230
+ hooksSym
16077
16231
  } = require_symbols();
16078
16232
  var {
16079
16233
  getLevel,
@@ -16088,7 +16242,8 @@ var require_proto = __commonJS({
16088
16242
  asChindings,
16089
16243
  asJson,
16090
16244
  buildFormatters,
16091
- stringify
16245
+ stringify,
16246
+ noop
16092
16247
  } = require_tools();
16093
16248
  var {
16094
16249
  version
@@ -16116,6 +16271,12 @@ var require_proto = __commonJS({
16116
16271
  set levelVal(n) {
16117
16272
  throw Error("levelVal is read-only");
16118
16273
  },
16274
+ get msgPrefix() {
16275
+ return this[msgPrefixSym];
16276
+ },
16277
+ get [Symbol.toStringTag]() {
16278
+ return "Pino";
16279
+ },
16119
16280
  [lsCacheSym]: initialLsCache,
16120
16281
  [writeSym]: write,
16121
16282
  [asJsonSym]: asJson,
@@ -16131,10 +16292,23 @@ var require_proto = __commonJS({
16131
16292
  if (!bindings2) {
16132
16293
  throw Error("missing bindings for child Pino");
16133
16294
  }
16134
- options = options || {};
16135
16295
  const serializers = this[serializersSym];
16136
16296
  const formatters = this[formattersSym];
16137
16297
  const instance = Object.create(this);
16298
+ if (options == null) {
16299
+ if (instance[formattersSym].bindings !== resetChildingsFormatter) {
16300
+ instance[formattersSym] = buildFormatters(
16301
+ formatters.level,
16302
+ resetChildingsFormatter,
16303
+ formatters.log
16304
+ );
16305
+ }
16306
+ instance[chindingsSym] = asChindings(instance, bindings2);
16307
+ if (this.onChild !== noop) {
16308
+ this.onChild(instance);
16309
+ }
16310
+ return instance;
16311
+ }
16138
16312
  if (options.hasOwnProperty("serializers") === true) {
16139
16313
  instance[serializersSym] = /* @__PURE__ */ Object.create(null);
16140
16314
  for (const k in serializers) {
@@ -16185,8 +16359,10 @@ var require_proto = __commonJS({
16185
16359
  instance[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
16186
16360
  }
16187
16361
  instance[chindingsSym] = asChindings(instance, bindings2);
16188
- const childLevel = options.level || this.level;
16189
- instance[setLevelSym](childLevel);
16362
+ if (options.level !== void 0 && options.level !== this.level || options.hasOwnProperty("customLevels")) {
16363
+ const childLevel = options.level || this.level;
16364
+ instance[setLevelSym](childLevel);
16365
+ }
16190
16366
  this.onChild(instance);
16191
16367
  return instance;
16192
16368
  }
@@ -16201,7 +16377,6 @@ var require_proto = __commonJS({
16201
16377
  function setBindings(newBindings) {
16202
16378
  const chindings = asChindings(this, newBindings);
16203
16379
  this[chindingsSym] = chindings;
16204
- delete this[parsedChindingsSym];
16205
16380
  }
16206
16381
  function defaultMixinMergeStrategy(mergeObject, mixinObject) {
16207
16382
  return Object.assign(mixinObject, mergeObject);
@@ -16213,6 +16388,7 @@ var require_proto = __commonJS({
16213
16388
  const messageKey = this[messageKeySym];
16214
16389
  const mixinMergeStrategy = this[mixinMergeStrategySym] || defaultMixinMergeStrategy;
16215
16390
  let obj;
16391
+ const streamWriteHook = this[hooksSym].streamWrite;
16216
16392
  if (_obj === void 0 || _obj === null) {
16217
16393
  obj = {};
16218
16394
  } else if (_obj instanceof Error) {
@@ -16238,9 +16414,7 @@ var require_proto = __commonJS({
16238
16414
  stream.lastTime = t.slice(this[timeSliceIndexSym]);
16239
16415
  stream.lastLogger = this;
16240
16416
  }
16241
- stream.write(s);
16242
- }
16243
- function noop() {
16417
+ stream.write(streamWriteHook ? streamWriteHook(s) : s);
16244
16418
  }
16245
16419
  function flush(cb) {
16246
16420
  if (cb != null && typeof cb !== "function") {
@@ -16262,7 +16436,6 @@ var require_multistream = __commonJS({
16262
16436
  var { DEFAULT_LEVELS } = require_constants();
16263
16437
  var DEFAULT_INFO_LEVEL = DEFAULT_LEVELS.info;
16264
16438
  function multistream(streamsArray, opts) {
16265
- let counter = 0;
16266
16439
  streamsArray = streamsArray || [];
16267
16440
  opts = opts || { dedupe: false };
16268
16441
  const streamLevels = Object.create(DEFAULT_LEVELS);
@@ -16275,10 +16448,12 @@ var require_multistream = __commonJS({
16275
16448
  const res = {
16276
16449
  write,
16277
16450
  add,
16451
+ remove,
16278
16452
  emit,
16279
16453
  flushSync,
16280
16454
  end,
16281
16455
  minLevel: 0,
16456
+ lastId: 0,
16282
16457
  streams: [],
16283
16458
  clone,
16284
16459
  [metadata]: true,
@@ -16359,13 +16534,23 @@ var require_multistream = __commonJS({
16359
16534
  stream: stream_,
16360
16535
  level,
16361
16536
  levelVal: void 0,
16362
- id: counter++
16537
+ id: ++res.lastId
16363
16538
  };
16364
16539
  streams.unshift(dest_);
16365
16540
  streams.sort(compareByLevel);
16366
16541
  this.minLevel = streams[0].level;
16367
16542
  return res;
16368
16543
  }
16544
+ function remove(id) {
16545
+ const { streams } = this;
16546
+ const index = streams.findIndex((s) => s.id === id);
16547
+ if (index >= 0) {
16548
+ streams.splice(index, 1);
16549
+ streams.sort(compareByLevel);
16550
+ this.minLevel = streams.length > 0 ? streams[0].level : -1;
16551
+ }
16552
+ return res;
16553
+ }
16369
16554
  function end() {
16370
16555
  for (const { stream } of this.streams) {
16371
16556
  if (typeof stream.flushSync === "function") {
@@ -16385,6 +16570,7 @@ var require_multistream = __commonJS({
16385
16570
  return {
16386
16571
  write,
16387
16572
  add,
16573
+ remove,
16388
16574
  minLevel: level,
16389
16575
  streams,
16390
16576
  clone,
@@ -16484,7 +16670,8 @@ var require_pino = __commonJS({
16484
16670
  }
16485
16671
  }),
16486
16672
  hooks: {
16487
- logMethod: void 0
16673
+ logMethod: void 0,
16674
+ streamWrite: void 0
16488
16675
  },
16489
16676
  timestamp: epochTime,
16490
16677
  name: void 0,
@@ -16499,6 +16686,7 @@ var require_pino = __commonJS({
16499
16686
  function pino(...args) {
16500
16687
  const instance = {};
16501
16688
  const { opts, stream } = normalize(instance, caller(), ...args);
16689
+ if (opts.level && typeof opts.level === "string" && DEFAULT_LEVELS[opts.level.toLowerCase()] !== void 0) opts.level = opts.level.toLowerCase();
16502
16690
  const {
16503
16691
  redact,
16504
16692
  crlf,