@smplkit/sdk 3.0.103 → 3.0.105

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.js CHANGED
@@ -13316,541 +13316,436 @@ var require_caller = __commonJS({
13316
13316
  }
13317
13317
  });
13318
13318
 
13319
- // node_modules/fast-redact/lib/validator.js
13320
- var require_validator = __commonJS({
13321
- "node_modules/fast-redact/lib/validator.js"(exports, module) {
13319
+ // node_modules/@pinojs/redact/index.js
13320
+ var require_redact = __commonJS({
13321
+ "node_modules/@pinojs/redact/index.js"(exports, module) {
13322
13322
  "use strict";
13323
- module.exports = validator;
13324
- function validator(opts = {}) {
13325
- const {
13326
- ERR_PATHS_MUST_BE_STRINGS = () => "fast-redact - Paths must be (non-empty) strings",
13327
- ERR_INVALID_PATH = (s) => `fast-redact \u2013 Invalid path (${s})`
13328
- } = opts;
13329
- return function validate({ paths }) {
13330
- paths.forEach((s) => {
13331
- if (typeof s !== "string") {
13332
- throw Error(ERR_PATHS_MUST_BE_STRINGS());
13333
- }
13334
- try {
13335
- if (/〇/.test(s)) throw Error();
13336
- const expr = (s[0] === "[" ? "" : ".") + s.replace(/^\*/, "\u3007").replace(/\.\*/g, ".\u3007").replace(/\[\*\]/g, "[\u3007]");
13337
- if (/\n|\r|;/.test(expr)) throw Error();
13338
- if (/\/\*/.test(expr)) throw Error();
13339
- Function(`
13340
- 'use strict'
13341
- const o = new Proxy({}, { get: () => o, set: () => { throw Error() } });
13342
- const \u3007 = null;
13343
- o${expr}
13344
- if ([o${expr}].length !== 1) throw Error()`)();
13345
- } catch (e) {
13346
- throw Error(ERR_INVALID_PATH(s));
13323
+ function deepClone(obj) {
13324
+ if (obj === null || typeof obj !== "object") {
13325
+ return obj;
13326
+ }
13327
+ if (obj instanceof Date) {
13328
+ return new Date(obj.getTime());
13329
+ }
13330
+ if (obj instanceof Array) {
13331
+ const cloned = [];
13332
+ for (let i = 0; i < obj.length; i++) {
13333
+ cloned[i] = deepClone(obj[i]);
13334
+ }
13335
+ return cloned;
13336
+ }
13337
+ if (typeof obj === "object") {
13338
+ const cloned = Object.create(Object.getPrototypeOf(obj));
13339
+ for (const key in obj) {
13340
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
13341
+ cloned[key] = deepClone(obj[key]);
13347
13342
  }
13348
- });
13349
- };
13350
- }
13351
- }
13352
- });
13353
-
13354
- // node_modules/fast-redact/lib/rx.js
13355
- var require_rx = __commonJS({
13356
- "node_modules/fast-redact/lib/rx.js"(exports, module) {
13357
- "use strict";
13358
- module.exports = /[^.[\]]+|\[((?:.)*?)\]/g;
13359
- }
13360
- });
13361
-
13362
- // node_modules/fast-redact/lib/parse.js
13363
- var require_parse = __commonJS({
13364
- "node_modules/fast-redact/lib/parse.js"(exports, module) {
13365
- "use strict";
13366
- var rx = require_rx();
13367
- module.exports = parse2;
13368
- function parse2({ paths }) {
13369
- const wildcards = [];
13370
- var wcLen = 0;
13371
- const secret = paths.reduce(function(o, strPath, ix) {
13372
- var path = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ""));
13373
- const leadingBracket = strPath[0] === "[";
13374
- path = path.map((p) => {
13375
- if (p[0] === "[") return p.substr(1, p.length - 2);
13376
- else return p;
13377
- });
13378
- const star = path.indexOf("*");
13379
- if (star > -1) {
13380
- const before = path.slice(0, star);
13381
- const beforeStr = before.join(".");
13382
- const after = path.slice(star + 1, path.length);
13383
- const nested = after.length > 0;
13384
- wcLen++;
13385
- wildcards.push({
13386
- before,
13387
- beforeStr,
13388
- after,
13389
- nested
13390
- });
13391
- } else {
13392
- o[strPath] = {
13393
- path,
13394
- val: void 0,
13395
- precensored: false,
13396
- circle: "",
13397
- escPath: JSON.stringify(strPath),
13398
- leadingBracket
13399
- };
13400
13343
  }
13401
- return o;
13402
- }, {});
13403
- return { wildcards, wcLen, secret };
13404
- }
13405
- }
13406
- });
13407
-
13408
- // node_modules/fast-redact/lib/redactor.js
13409
- var require_redactor = __commonJS({
13410
- "node_modules/fast-redact/lib/redactor.js"(exports, module) {
13411
- "use strict";
13412
- var rx = require_rx();
13413
- module.exports = redactor;
13414
- function redactor({ secret, serialize, wcLen, strict, isCensorFct, censorFctTakesPath }, state) {
13415
- const redact = Function("o", `
13416
- if (typeof o !== 'object' || o == null) {
13417
- ${strictImpl(strict, serialize)}
13418
- }
13419
- const { censor, secret } = this
13420
- const originalSecret = {}
13421
- const secretKeys = Object.keys(secret)
13422
- for (var i = 0; i < secretKeys.length; i++) {
13423
- originalSecret[secretKeys[i]] = secret[secretKeys[i]]
13344
+ return cloned;
13345
+ }
13346
+ return obj;
13424
13347
  }
13425
-
13426
- ${redactTmpl(secret, isCensorFct, censorFctTakesPath)}
13427
- this.compileRestore()
13428
- ${dynamicRedactTmpl(wcLen > 0, isCensorFct, censorFctTakesPath)}
13429
- this.secret = originalSecret
13430
- ${resultTmpl(serialize)}
13431
- `).bind(state);
13432
- redact.state = state;
13433
- if (serialize === false) {
13434
- redact.restore = (o) => state.restore(o);
13435
- }
13436
- return redact;
13437
- }
13438
- function redactTmpl(secret, isCensorFct, censorFctTakesPath) {
13439
- return Object.keys(secret).map((path) => {
13440
- const { escPath, leadingBracket, path: arrPath } = secret[path];
13441
- const skip = leadingBracket ? 1 : 0;
13442
- const delim = leadingBracket ? "" : ".";
13443
- const hops = [];
13444
- var match;
13445
- while ((match = rx.exec(path)) !== null) {
13446
- const [, ix] = match;
13447
- const { index, input } = match;
13448
- if (index > skip) hops.push(input.substring(0, index - (ix ? 0 : 1)));
13449
- }
13450
- var existence = hops.map((p) => `o${delim}${p}`).join(" && ");
13451
- if (existence.length === 0) existence += `o${delim}${path} != null`;
13452
- else existence += ` && o${delim}${path} != null`;
13453
- const circularDetection = `
13454
- switch (true) {
13455
- ${hops.reverse().map((p) => `
13456
- case o${delim}${p} === censor:
13457
- secret[${escPath}].circle = ${JSON.stringify(p)}
13458
- break
13459
- `).join("\n")}
13460
- }
13461
- `;
13462
- const censorArgs = censorFctTakesPath ? `val, ${JSON.stringify(arrPath)}` : `val`;
13463
- return `
13464
- if (${existence}) {
13465
- const val = o${delim}${path}
13466
- if (val === censor) {
13467
- secret[${escPath}].precensored = true
13348
+ function parsePath(path) {
13349
+ const parts = [];
13350
+ let current = "";
13351
+ let inBrackets = false;
13352
+ let inQuotes = false;
13353
+ let quoteChar = "";
13354
+ for (let i = 0; i < path.length; i++) {
13355
+ const char = path[i];
13356
+ if (!inBrackets && char === ".") {
13357
+ if (current) {
13358
+ parts.push(current);
13359
+ current = "";
13360
+ }
13361
+ } else if (char === "[") {
13362
+ if (current) {
13363
+ parts.push(current);
13364
+ current = "";
13365
+ }
13366
+ inBrackets = true;
13367
+ } else if (char === "]" && inBrackets) {
13368
+ parts.push(current);
13369
+ current = "";
13370
+ inBrackets = false;
13371
+ inQuotes = false;
13372
+ } else if ((char === '"' || char === "'") && inBrackets) {
13373
+ if (!inQuotes) {
13374
+ inQuotes = true;
13375
+ quoteChar = char;
13376
+ } else if (char === quoteChar) {
13377
+ inQuotes = false;
13378
+ quoteChar = "";
13379
+ } else {
13380
+ current += char;
13381
+ }
13468
13382
  } else {
13469
- secret[${escPath}].val = val
13470
- o${delim}${path} = ${isCensorFct ? `censor(${censorArgs})` : "censor"}
13471
- ${circularDetection}
13383
+ current += char;
13472
13384
  }
13473
13385
  }
13474
- `;
13475
- }).join("\n");
13476
- }
13477
- function dynamicRedactTmpl(hasWildcards, isCensorFct, censorFctTakesPath) {
13478
- return hasWildcards === true ? `
13479
- {
13480
- const { wildcards, wcLen, groupRedact, nestedRedact } = this
13481
- for (var i = 0; i < wcLen; i++) {
13482
- const { before, beforeStr, after, nested } = wildcards[i]
13483
- if (nested === true) {
13484
- secret[beforeStr] = secret[beforeStr] || []
13485
- nestedRedact(secret[beforeStr], o, before, after, censor, ${isCensorFct}, ${censorFctTakesPath})
13486
- } else secret[beforeStr] = groupRedact(o, before, censor, ${isCensorFct}, ${censorFctTakesPath})
13386
+ if (current) {
13387
+ parts.push(current);
13487
13388
  }
13389
+ return parts;
13488
13390
  }
13489
- ` : "";
13490
- }
13491
- function resultTmpl(serialize) {
13492
- return serialize === false ? `return o` : `
13493
- var s = this.serialize(o)
13494
- this.restore(o)
13495
- return s
13496
- `;
13497
- }
13498
- function strictImpl(strict, serialize) {
13499
- return strict === true ? `throw Error('fast-redact: primitives cannot be redacted')` : serialize === false ? `return o` : `return this.serialize(o)`;
13391
+ function setValue(obj, parts, value) {
13392
+ let current = obj;
13393
+ for (let i = 0; i < parts.length - 1; i++) {
13394
+ const key = parts[i];
13395
+ if (typeof current !== "object" || current === null || !(key in current)) {
13396
+ return false;
13397
+ }
13398
+ if (typeof current[key] !== "object" || current[key] === null) {
13399
+ return false;
13400
+ }
13401
+ current = current[key];
13402
+ }
13403
+ const lastKey = parts[parts.length - 1];
13404
+ if (lastKey === "*") {
13405
+ if (Array.isArray(current)) {
13406
+ for (let i = 0; i < current.length; i++) {
13407
+ current[i] = value;
13408
+ }
13409
+ } else if (typeof current === "object" && current !== null) {
13410
+ for (const key in current) {
13411
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
13412
+ current[key] = value;
13413
+ }
13414
+ }
13415
+ }
13416
+ } else {
13417
+ if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
13418
+ current[lastKey] = value;
13419
+ }
13420
+ }
13421
+ return true;
13500
13422
  }
13501
- }
13502
- });
13503
-
13504
- // node_modules/fast-redact/lib/modifiers.js
13505
- var require_modifiers = __commonJS({
13506
- "node_modules/fast-redact/lib/modifiers.js"(exports, module) {
13507
- "use strict";
13508
- module.exports = {
13509
- groupRedact,
13510
- groupRestore,
13511
- nestedRedact,
13512
- nestedRestore
13513
- };
13514
- function groupRestore({ keys, values, target }) {
13515
- if (target == null || typeof target === "string") return;
13516
- const length = keys.length;
13517
- for (var i = 0; i < length; i++) {
13518
- const k = keys[i];
13519
- target[k] = values[i];
13520
- }
13521
- }
13522
- function groupRedact(o, path, censor, isCensorFct, censorFctTakesPath) {
13523
- const target = get(o, path);
13524
- if (target == null || typeof target === "string") return { keys: null, values: null, target, flat: true };
13525
- const keys = Object.keys(target);
13526
- const keysLength = keys.length;
13527
- const pathLength = path.length;
13528
- const pathWithKey = censorFctTakesPath ? [...path] : void 0;
13529
- const values = new Array(keysLength);
13530
- for (var i = 0; i < keysLength; i++) {
13531
- const key = keys[i];
13532
- values[i] = target[key];
13533
- if (censorFctTakesPath) {
13534
- pathWithKey[pathLength] = key;
13535
- target[key] = censor(target[key], pathWithKey);
13536
- } else if (isCensorFct) {
13537
- target[key] = censor(target[key]);
13538
- } else {
13539
- target[key] = censor;
13423
+ function removeKey(obj, parts) {
13424
+ let current = obj;
13425
+ for (let i = 0; i < parts.length - 1; i++) {
13426
+ const key = parts[i];
13427
+ if (typeof current !== "object" || current === null || !(key in current)) {
13428
+ return false;
13429
+ }
13430
+ if (typeof current[key] !== "object" || current[key] === null) {
13431
+ return false;
13432
+ }
13433
+ current = current[key];
13434
+ }
13435
+ const lastKey = parts[parts.length - 1];
13436
+ if (lastKey === "*") {
13437
+ if (Array.isArray(current)) {
13438
+ for (let i = 0; i < current.length; i++) {
13439
+ current[i] = void 0;
13440
+ }
13441
+ } else if (typeof current === "object" && current !== null) {
13442
+ for (const key in current) {
13443
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
13444
+ delete current[key];
13445
+ }
13446
+ }
13447
+ }
13448
+ } else {
13449
+ if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
13450
+ delete current[lastKey];
13540
13451
  }
13541
13452
  }
13542
- return { keys, values, target, flat: true };
13453
+ return true;
13543
13454
  }
13544
- function nestedRestore(instructions) {
13545
- for (let i = 0; i < instructions.length; i++) {
13546
- const { target, path, value } = instructions[i];
13547
- let current = target;
13548
- for (let i2 = path.length - 1; i2 > 0; i2--) {
13549
- current = current[path[i2]];
13455
+ var PATH_NOT_FOUND = /* @__PURE__ */ Symbol("PATH_NOT_FOUND");
13456
+ function getValueIfExists(obj, parts) {
13457
+ let current = obj;
13458
+ for (const part of parts) {
13459
+ if (current === null || current === void 0) {
13460
+ return PATH_NOT_FOUND;
13461
+ }
13462
+ if (typeof current !== "object" || current === null) {
13463
+ return PATH_NOT_FOUND;
13464
+ }
13465
+ if (!(part in current)) {
13466
+ return PATH_NOT_FOUND;
13550
13467
  }
13551
- current[path[0]] = value;
13468
+ current = current[part];
13552
13469
  }
13470
+ return current;
13553
13471
  }
13554
- function nestedRedact(store, o, path, ns, censor, isCensorFct, censorFctTakesPath) {
13555
- const target = get(o, path);
13556
- if (target == null) return;
13557
- const keys = Object.keys(target);
13558
- const keysLength = keys.length;
13559
- for (var i = 0; i < keysLength; i++) {
13560
- const key = keys[i];
13561
- specialSet(store, target, key, path, ns, censor, isCensorFct, censorFctTakesPath);
13472
+ function getValue(obj, parts) {
13473
+ let current = obj;
13474
+ for (const part of parts) {
13475
+ if (current === null || current === void 0) {
13476
+ return void 0;
13477
+ }
13478
+ if (typeof current !== "object" || current === null) {
13479
+ return void 0;
13480
+ }
13481
+ current = current[part];
13562
13482
  }
13563
- return store;
13483
+ return current;
13564
13484
  }
13565
- function has(obj, prop) {
13566
- return obj !== void 0 && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false;
13485
+ function redactPaths(obj, paths, censor, remove = false) {
13486
+ for (const path of paths) {
13487
+ const parts = parsePath(path);
13488
+ if (parts.includes("*")) {
13489
+ redactWildcardPath(obj, parts, censor, path, remove);
13490
+ } else {
13491
+ if (remove) {
13492
+ removeKey(obj, parts);
13493
+ } else {
13494
+ const value = getValueIfExists(obj, parts);
13495
+ if (value === PATH_NOT_FOUND) {
13496
+ continue;
13497
+ }
13498
+ const actualCensor = typeof censor === "function" ? censor(value, parts) : censor;
13499
+ setValue(obj, parts, actualCensor);
13500
+ }
13501
+ }
13502
+ }
13567
13503
  }
13568
- function specialSet(store, o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) {
13569
- const afterPathLen = afterPath.length;
13570
- const lastPathIndex = afterPathLen - 1;
13571
- const originalKey = k;
13572
- var i = -1;
13573
- var n;
13574
- var nv;
13575
- var ov;
13576
- var oov = null;
13577
- var wc = null;
13578
- var kIsWc;
13579
- var wcov;
13580
- var consecutive = false;
13581
- var level = 0;
13582
- var depth = 0;
13583
- var redactPathCurrent = tree();
13584
- ov = n = o[k];
13585
- if (typeof n !== "object") return;
13586
- while (n != null && ++i < afterPathLen) {
13587
- depth += 1;
13588
- k = afterPath[i];
13589
- oov = ov;
13590
- if (k !== "*" && !wc && !(typeof n === "object" && k in n)) {
13591
- break;
13504
+ function redactWildcardPath(obj, parts, censor, originalPath, remove = false) {
13505
+ const wildcardIndex = parts.indexOf("*");
13506
+ if (wildcardIndex === parts.length - 1) {
13507
+ const parentParts = parts.slice(0, -1);
13508
+ let current = obj;
13509
+ for (const part of parentParts) {
13510
+ if (current === null || current === void 0) return;
13511
+ if (typeof current !== "object" || current === null) return;
13512
+ current = current[part];
13592
13513
  }
13593
- if (k === "*") {
13594
- if (wc === "*") {
13595
- consecutive = true;
13514
+ if (Array.isArray(current)) {
13515
+ if (remove) {
13516
+ for (let i = 0; i < current.length; i++) {
13517
+ current[i] = void 0;
13518
+ }
13519
+ } else {
13520
+ for (let i = 0; i < current.length; i++) {
13521
+ const indexPath = [...parentParts, i.toString()];
13522
+ const actualCensor = typeof censor === "function" ? censor(current[i], indexPath) : censor;
13523
+ current[i] = actualCensor;
13524
+ }
13596
13525
  }
13597
- wc = k;
13598
- if (i !== lastPathIndex) {
13599
- continue;
13526
+ } else if (typeof current === "object" && current !== null) {
13527
+ if (remove) {
13528
+ const keysToDelete = [];
13529
+ for (const key in current) {
13530
+ if (Object.prototype.hasOwnProperty.call(current, key)) {
13531
+ keysToDelete.push(key);
13532
+ }
13533
+ }
13534
+ for (const key of keysToDelete) {
13535
+ delete current[key];
13536
+ }
13537
+ } else {
13538
+ for (const key in current) {
13539
+ const keyPath = [...parentParts, key];
13540
+ const actualCensor = typeof censor === "function" ? censor(current[key], keyPath) : censor;
13541
+ current[key] = actualCensor;
13542
+ }
13600
13543
  }
13601
13544
  }
13602
- if (wc) {
13603
- const wcKeys = Object.keys(n);
13604
- for (var j = 0; j < wcKeys.length; j++) {
13605
- const wck = wcKeys[j];
13606
- wcov = n[wck];
13607
- kIsWc = k === "*";
13608
- if (consecutive) {
13609
- redactPathCurrent = node(redactPathCurrent, wck, depth);
13610
- level = i;
13611
- 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);
13612
- } else {
13613
- if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
13614
- if (kIsWc) {
13615
- ov = wcov;
13616
- } else {
13617
- ov = wcov[k];
13618
- }
13619
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
13620
- if (kIsWc) {
13621
- const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]);
13622
- store.push(rv);
13623
- n[wck] = nv;
13624
- } else {
13625
- if (wcov[k] === nv) {
13626
- } else if (nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov) {
13627
- redactPathCurrent = node(redactPathCurrent, wck, depth);
13628
- } else {
13629
- redactPathCurrent = node(redactPathCurrent, wck, depth);
13630
- const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, o[originalKey]);
13631
- store.push(rv);
13632
- wcov[k] = nv;
13633
- }
13634
- }
13635
- }
13545
+ } else {
13546
+ redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove);
13547
+ }
13548
+ }
13549
+ function redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove = false) {
13550
+ const beforeWildcard = parts.slice(0, wildcardIndex);
13551
+ const afterWildcard = parts.slice(wildcardIndex + 1);
13552
+ const pathArray = [];
13553
+ function traverse(current, pathLength) {
13554
+ if (pathLength === beforeWildcard.length) {
13555
+ if (Array.isArray(current)) {
13556
+ for (let i = 0; i < current.length; i++) {
13557
+ pathArray[pathLength] = i.toString();
13558
+ traverse(current[i], pathLength + 1);
13559
+ }
13560
+ } else if (typeof current === "object" && current !== null) {
13561
+ for (const key in current) {
13562
+ pathArray[pathLength] = key;
13563
+ traverse(current[key], pathLength + 1);
13636
13564
  }
13637
13565
  }
13638
- wc = null;
13566
+ } else if (pathLength < beforeWildcard.length) {
13567
+ const nextKey = beforeWildcard[pathLength];
13568
+ if (current && typeof current === "object" && current !== null && nextKey in current) {
13569
+ pathArray[pathLength] = nextKey;
13570
+ traverse(current[nextKey], pathLength + 1);
13571
+ }
13639
13572
  } else {
13640
- ov = n[k];
13641
- redactPathCurrent = node(redactPathCurrent, k, depth);
13642
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
13643
- if (has(n, k) && nv === ov || nv === void 0 && censor !== void 0) {
13573
+ if (afterWildcard.includes("*")) {
13574
+ const wrappedCensor = typeof censor === "function" ? (value, path) => {
13575
+ const fullPath = [...pathArray.slice(0, pathLength), ...path];
13576
+ return censor(value, fullPath);
13577
+ } : censor;
13578
+ redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
13644
13579
  } else {
13645
- const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]);
13646
- store.push(rv);
13647
- n[k] = nv;
13580
+ if (remove) {
13581
+ removeKey(current, afterWildcard);
13582
+ } else {
13583
+ const actualCensor = typeof censor === "function" ? censor(getValue(current, afterWildcard), [...pathArray.slice(0, pathLength), ...afterWildcard]) : censor;
13584
+ setValue(current, afterWildcard, actualCensor);
13585
+ }
13648
13586
  }
13649
- n = n[k];
13650
13587
  }
13651
- if (typeof n !== "object") break;
13652
- if (ov === oov || typeof ov === "undefined") {
13588
+ }
13589
+ if (beforeWildcard.length === 0) {
13590
+ traverse(obj, 0);
13591
+ } else {
13592
+ let current = obj;
13593
+ for (let i = 0; i < beforeWildcard.length; i++) {
13594
+ const part = beforeWildcard[i];
13595
+ if (current === null || current === void 0) return;
13596
+ if (typeof current !== "object" || current === null) return;
13597
+ current = current[part];
13598
+ pathArray[i] = part;
13599
+ }
13600
+ if (current !== null && current !== void 0) {
13601
+ traverse(current, beforeWildcard.length);
13653
13602
  }
13654
13603
  }
13655
13604
  }
13656
- function get(o, p) {
13657
- var i = -1;
13658
- var l = p.length;
13659
- var n = o;
13660
- while (n != null && ++i < l) {
13661
- n = n[p[i]];
13605
+ function buildPathStructure(pathsToClone) {
13606
+ if (pathsToClone.length === 0) {
13607
+ return null;
13662
13608
  }
13663
- return n;
13609
+ const pathStructure = /* @__PURE__ */ new Map();
13610
+ for (const path of pathsToClone) {
13611
+ const parts = parsePath(path);
13612
+ let current = pathStructure;
13613
+ for (let i = 0; i < parts.length; i++) {
13614
+ const part = parts[i];
13615
+ if (!current.has(part)) {
13616
+ current.set(part, /* @__PURE__ */ new Map());
13617
+ }
13618
+ current = current.get(part);
13619
+ }
13620
+ }
13621
+ return pathStructure;
13664
13622
  }
13665
- function iterateNthLevel(wcov, level, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) {
13666
- if (level === 0) {
13667
- if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) {
13668
- if (kIsWc) {
13669
- ov = wcov;
13670
- } else {
13671
- ov = wcov[k];
13623
+ function selectiveClone(obj, pathStructure) {
13624
+ if (!pathStructure) {
13625
+ return obj;
13626
+ }
13627
+ function cloneSelectively(source, pathMap, depth = 0) {
13628
+ if (!pathMap || pathMap.size === 0) {
13629
+ return source;
13630
+ }
13631
+ if (source === null || typeof source !== "object") {
13632
+ return source;
13633
+ }
13634
+ if (source instanceof Date) {
13635
+ return new Date(source.getTime());
13636
+ }
13637
+ if (Array.isArray(source)) {
13638
+ const cloned2 = [];
13639
+ for (let i = 0; i < source.length; i++) {
13640
+ const indexStr = i.toString();
13641
+ if (pathMap.has(indexStr) || pathMap.has("*")) {
13642
+ cloned2[i] = cloneSelectively(source[i], pathMap.get(indexStr) || pathMap.get("*"));
13643
+ } else {
13644
+ cloned2[i] = source[i];
13645
+ }
13672
13646
  }
13673
- nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor;
13674
- if (kIsWc) {
13675
- const rv = restoreInstr(redactPathCurrent, ov, parent);
13676
- store.push(rv);
13677
- n[wck] = nv;
13678
- } else {
13679
- if (wcov[k] === nv) {
13680
- } else if (nv === void 0 && censor !== void 0 || has(wcov, k) && nv === ov) {
13647
+ return cloned2;
13648
+ }
13649
+ const cloned = Object.create(Object.getPrototypeOf(source));
13650
+ for (const key in source) {
13651
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
13652
+ if (pathMap.has(key) || pathMap.has("*")) {
13653
+ cloned[key] = cloneSelectively(source[key], pathMap.get(key) || pathMap.get("*"));
13681
13654
  } else {
13682
- const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, parent);
13683
- store.push(rv);
13684
- wcov[k] = nv;
13655
+ cloned[key] = source[key];
13685
13656
  }
13686
13657
  }
13687
13658
  }
13659
+ return cloned;
13660
+ }
13661
+ return cloneSelectively(obj, pathStructure);
13662
+ }
13663
+ function validatePath(path) {
13664
+ if (typeof path !== "string") {
13665
+ throw new Error("Paths must be (non-empty) strings");
13688
13666
  }
13689
- for (const key in wcov) {
13690
- if (typeof wcov[key] === "object") {
13691
- redactPathCurrent = node(redactPathCurrent, key, depth);
13692
- iterateNthLevel(wcov[key], level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1);
13667
+ if (path === "") {
13668
+ throw new Error("Invalid redaction path ()");
13669
+ }
13670
+ if (path.includes("..")) {
13671
+ throw new Error(`Invalid redaction path (${path})`);
13672
+ }
13673
+ if (path.includes(",")) {
13674
+ throw new Error(`Invalid redaction path (${path})`);
13675
+ }
13676
+ let bracketCount = 0;
13677
+ let inQuotes = false;
13678
+ let quoteChar = "";
13679
+ for (let i = 0; i < path.length; i++) {
13680
+ const char = path[i];
13681
+ if ((char === '"' || char === "'") && bracketCount > 0) {
13682
+ if (!inQuotes) {
13683
+ inQuotes = true;
13684
+ quoteChar = char;
13685
+ } else if (char === quoteChar) {
13686
+ inQuotes = false;
13687
+ quoteChar = "";
13688
+ }
13689
+ } else if (char === "[" && !inQuotes) {
13690
+ bracketCount++;
13691
+ } else if (char === "]" && !inQuotes) {
13692
+ bracketCount--;
13693
+ if (bracketCount < 0) {
13694
+ throw new Error(`Invalid redaction path (${path})`);
13695
+ }
13693
13696
  }
13694
13697
  }
13695
- }
13696
- function tree() {
13697
- return { parent: null, key: null, children: [], depth: 0 };
13698
- }
13699
- function node(parent, key, depth) {
13700
- if (parent.depth === depth) {
13701
- return node(parent.parent, key, depth);
13698
+ if (bracketCount !== 0) {
13699
+ throw new Error(`Invalid redaction path (${path})`);
13702
13700
  }
13703
- var child = {
13704
- parent,
13705
- key,
13706
- depth,
13707
- children: []
13708
- };
13709
- parent.children.push(child);
13710
- return child;
13711
13701
  }
13712
- function restoreInstr(node2, value, target) {
13713
- let current = node2;
13714
- const path = [];
13715
- do {
13716
- path.push(current.key);
13717
- current = current.parent;
13718
- } while (current.parent != null);
13719
- return { path, value, target };
13702
+ function validatePaths(paths) {
13703
+ if (!Array.isArray(paths)) {
13704
+ throw new TypeError("paths must be an array");
13705
+ }
13706
+ for (const path of paths) {
13707
+ validatePath(path);
13708
+ }
13720
13709
  }
13721
- }
13722
- });
13723
-
13724
- // node_modules/fast-redact/lib/restorer.js
13725
- var require_restorer = __commonJS({
13726
- "node_modules/fast-redact/lib/restorer.js"(exports, module) {
13727
- "use strict";
13728
- var { groupRestore, nestedRestore } = require_modifiers();
13729
- module.exports = restorer;
13730
- function restorer() {
13731
- return function compileRestore() {
13732
- if (this.restore) {
13733
- this.restore.state.secret = this.secret;
13734
- return;
13710
+ function slowRedact(options = {}) {
13711
+ const {
13712
+ paths = [],
13713
+ censor = "[REDACTED]",
13714
+ serialize = JSON.stringify,
13715
+ strict = true,
13716
+ remove = false
13717
+ } = options;
13718
+ validatePaths(paths);
13719
+ const pathStructure = buildPathStructure(paths);
13720
+ return function redact(obj) {
13721
+ if (strict && (obj === null || typeof obj !== "object")) {
13722
+ if (obj === null || obj === void 0) {
13723
+ return serialize ? serialize(obj) : obj;
13724
+ }
13725
+ if (typeof obj !== "object") {
13726
+ return serialize ? serialize(obj) : obj;
13727
+ }
13728
+ }
13729
+ const cloned = selectiveClone(obj, pathStructure);
13730
+ const original = obj;
13731
+ let actualCensor = censor;
13732
+ if (typeof censor === "function") {
13733
+ actualCensor = censor;
13734
+ }
13735
+ redactPaths(cloned, paths, actualCensor, remove);
13736
+ if (serialize === false) {
13737
+ cloned.restore = function() {
13738
+ return deepClone(original);
13739
+ };
13740
+ return cloned;
13741
+ }
13742
+ if (typeof serialize === "function") {
13743
+ return serialize(cloned);
13735
13744
  }
13736
- const { secret, wcLen } = this;
13737
- const paths = Object.keys(secret);
13738
- const resetters = resetTmpl(secret, paths);
13739
- const hasWildcards = wcLen > 0;
13740
- const state = hasWildcards ? { secret, groupRestore, nestedRestore } : { secret };
13741
- this.restore = Function(
13742
- "o",
13743
- restoreTmpl(resetters, paths, hasWildcards)
13744
- ).bind(state);
13745
- this.restore.state = state;
13745
+ return JSON.stringify(cloned);
13746
13746
  };
13747
13747
  }
13748
- function resetTmpl(secret, paths) {
13749
- return paths.map((path) => {
13750
- const { circle, escPath, leadingBracket } = secret[path];
13751
- const delim = leadingBracket ? "" : ".";
13752
- const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path} = secret[${escPath}].val`;
13753
- const clear = `secret[${escPath}].val = undefined`;
13754
- return `
13755
- if (secret[${escPath}].val !== undefined) {
13756
- try { ${reset} } catch (e) {}
13757
- ${clear}
13758
- }
13759
- `;
13760
- }).join("");
13761
- }
13762
- function restoreTmpl(resetters, paths, hasWildcards) {
13763
- const dynamicReset = hasWildcards === true ? `
13764
- const keys = Object.keys(secret)
13765
- const len = keys.length
13766
- for (var i = len - 1; i >= ${paths.length}; i--) {
13767
- const k = keys[i]
13768
- const o = secret[k]
13769
- if (o) {
13770
- if (o.flat === true) this.groupRestore(o)
13771
- else this.nestedRestore(o)
13772
- secret[k] = null
13773
- }
13774
- }
13775
- ` : "";
13776
- return `
13777
- const secret = this.secret
13778
- ${dynamicReset}
13779
- ${resetters}
13780
- return o
13781
- `;
13782
- }
13783
- }
13784
- });
13785
-
13786
- // node_modules/fast-redact/lib/state.js
13787
- var require_state3 = __commonJS({
13788
- "node_modules/fast-redact/lib/state.js"(exports, module) {
13789
- "use strict";
13790
- module.exports = state;
13791
- function state(o) {
13792
- const {
13793
- secret,
13794
- censor,
13795
- compileRestore,
13796
- serialize,
13797
- groupRedact,
13798
- nestedRedact,
13799
- wildcards,
13800
- wcLen
13801
- } = o;
13802
- const builder = [{ secret, censor, compileRestore }];
13803
- if (serialize !== false) builder.push({ serialize });
13804
- if (wcLen > 0) builder.push({ groupRedact, nestedRedact, wildcards, wcLen });
13805
- return Object.assign(...builder);
13806
- }
13807
- }
13808
- });
13809
-
13810
- // node_modules/fast-redact/index.js
13811
- var require_fast_redact = __commonJS({
13812
- "node_modules/fast-redact/index.js"(exports, module) {
13813
- "use strict";
13814
- var validator = require_validator();
13815
- var parse2 = require_parse();
13816
- var redactor = require_redactor();
13817
- var restorer = require_restorer();
13818
- var { groupRedact, nestedRedact } = require_modifiers();
13819
- var state = require_state3();
13820
- var rx = require_rx();
13821
- var validate = validator();
13822
- var noop = (o) => o;
13823
- noop.restore = noop;
13824
- var DEFAULT_CENSOR = "[REDACTED]";
13825
- fastRedact.rx = rx;
13826
- fastRedact.validator = validator;
13827
- module.exports = fastRedact;
13828
- function fastRedact(opts = {}) {
13829
- const paths = Array.from(new Set(opts.paths || []));
13830
- const serialize = "serialize" in opts ? opts.serialize === false ? opts.serialize : typeof opts.serialize === "function" ? opts.serialize : JSON.stringify : JSON.stringify;
13831
- const remove = opts.remove;
13832
- if (remove === true && serialize !== JSON.stringify) {
13833
- throw Error("fast-redact \u2013 remove option may only be set when serializer is JSON.stringify");
13834
- }
13835
- const censor = remove === true ? void 0 : "censor" in opts ? opts.censor : DEFAULT_CENSOR;
13836
- const isCensorFct = typeof censor === "function";
13837
- const censorFctTakesPath = isCensorFct && censor.length > 1;
13838
- if (paths.length === 0) return serialize || noop;
13839
- validate({ paths, serialize, censor });
13840
- const { wildcards, wcLen, secret } = parse2({ paths, censor });
13841
- const compileRestore = restorer();
13842
- const strict = "strict" in opts ? opts.strict : true;
13843
- return redactor({ secret, wcLen, serialize, strict, isCensorFct, censorFctTakesPath }, state({
13844
- secret,
13845
- censor,
13846
- compileRestore,
13847
- serialize,
13848
- groupRedact,
13849
- nestedRedact,
13850
- wildcards,
13851
- wcLen
13852
- }));
13853
- }
13748
+ module.exports = slowRedact;
13854
13749
  }
13855
13750
  });
13856
13751
 
@@ -13929,17 +13824,13 @@ var require_symbols = __commonJS({
13929
13824
  var require_redaction = __commonJS({
13930
13825
  "node_modules/pino/lib/redaction.js"(exports, module) {
13931
13826
  "use strict";
13932
- var fastRedact = require_fast_redact();
13827
+ var Redact = require_redact();
13933
13828
  var { redactFmtSym, wildcardFirstSym } = require_symbols();
13934
- var { rx, validator } = fastRedact;
13935
- var validate = validator({
13936
- ERR_PATHS_MUST_BE_STRINGS: () => "pino \u2013 redacted paths must be strings",
13937
- ERR_INVALID_PATH: (s) => `pino \u2013 redact paths array contains an invalid path (${s})`
13938
- });
13829
+ var rx = /[^.[\]]+|\[([^[\]]*?)\]/g;
13939
13830
  var CENSOR = "[Redacted]";
13940
13831
  var strict = false;
13941
13832
  function redaction(opts, serialize) {
13942
- const { paths, censor } = handle(opts);
13833
+ const { paths, censor, remove } = handle(opts);
13943
13834
  const shape = paths.reduce((o, str) => {
13944
13835
  rx.lastIndex = 0;
13945
13836
  const first = rx.exec(str);
@@ -13972,7 +13863,7 @@ var require_redaction = __commonJS({
13972
13863
  return o;
13973
13864
  }, {});
13974
13865
  const result = {
13975
- [redactFmtSym]: fastRedact({ paths, censor, serialize, strict })
13866
+ [redactFmtSym]: Redact({ paths, censor, serialize, strict, remove })
13976
13867
  };
13977
13868
  const topCensor = (...args) => {
13978
13869
  return typeof censor === "function" ? serialize(censor(...args)) : serialize(censor);
@@ -13984,11 +13875,12 @@ var require_redaction = __commonJS({
13984
13875
  const wrappedCensor = typeof censor === "function" ? (value, path) => {
13985
13876
  return censor(value, [k, ...path]);
13986
13877
  } : censor;
13987
- o[k] = fastRedact({
13878
+ o[k] = Redact({
13988
13879
  paths: shape[k],
13989
13880
  censor: wrappedCensor,
13990
13881
  serialize,
13991
- strict
13882
+ strict,
13883
+ remove
13992
13884
  });
13993
13885
  }
13994
13886
  return o;
@@ -13997,7 +13889,6 @@ var require_redaction = __commonJS({
13997
13889
  function handle(opts) {
13998
13890
  if (Array.isArray(opts)) {
13999
13891
  opts = { paths: opts, censor: CENSOR };
14000
- validate(opts);
14001
13892
  return opts;
14002
13893
  }
14003
13894
  let { paths, censor = CENSOR, remove } = opts;
@@ -14005,8 +13896,7 @@ var require_redaction = __commonJS({
14005
13896
  throw Error("pino \u2013 redact must contain an array of strings");
14006
13897
  }
14007
13898
  if (remove === true) censor = void 0;
14008
- validate({ paths, censor });
14009
- return { paths, censor };
13899
+ return { paths, censor, remove };
14010
13900
  }
14011
13901
  module.exports = redaction;
14012
13902
  }
@@ -14020,7 +13910,26 @@ var require_time = __commonJS({
14020
13910
  var epochTime = () => `,"time":${Date.now()}`;
14021
13911
  var unixTime = () => `,"time":${Math.round(Date.now() / 1e3)}`;
14022
13912
  var isoTime = () => `,"time":"${new Date(Date.now()).toISOString()}"`;
14023
- module.exports = { nullTime, epochTime, unixTime, isoTime };
13913
+ var NS_PER_MS = 1000000n;
13914
+ var NS_PER_SEC = 1000000000n;
13915
+ var startWallTimeNs = BigInt(Date.now()) * NS_PER_MS;
13916
+ var startHrTime = process.hrtime.bigint();
13917
+ var isoTimeNano = () => {
13918
+ const elapsedNs = process.hrtime.bigint() - startHrTime;
13919
+ const currentTimeNs = startWallTimeNs + elapsedNs;
13920
+ const secondsSinceEpoch = currentTimeNs / NS_PER_SEC;
13921
+ const nanosWithinSecond = currentTimeNs % NS_PER_SEC;
13922
+ const msSinceEpoch = Number(secondsSinceEpoch * 1000n + nanosWithinSecond / 1000000n);
13923
+ const date = new Date(msSinceEpoch);
13924
+ const year = date.getUTCFullYear();
13925
+ const month = (date.getUTCMonth() + 1).toString().padStart(2, "0");
13926
+ const day = date.getUTCDate().toString().padStart(2, "0");
13927
+ const hours = date.getUTCHours().toString().padStart(2, "0");
13928
+ const minutes = date.getUTCMinutes().toString().padStart(2, "0");
13929
+ const seconds = date.getUTCSeconds().toString().padStart(2, "0");
13930
+ return `,"time":"${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${nanosWithinSecond.toString().padStart(9, "0")}Z"`;
13931
+ };
13932
+ module.exports = { nullTime, epochTime, unixTime, isoTime, isoTimeNano };
14024
13933
  }
14025
13934
  });
14026
13935
 
@@ -14187,11 +14096,14 @@ var require_sonic_boom = __commonJS({
14187
14096
  var inherits = __require("util").inherits;
14188
14097
  var path = __require("path");
14189
14098
  var sleep = require_atomic_sleep();
14099
+ var assert = __require("assert");
14190
14100
  var BUSY_WRITE_TIMEOUT = 100;
14191
14101
  var kEmptyBuffer = Buffer.allocUnsafe(0);
14192
14102
  var MAX_WRITE = 16 * 1024;
14193
14103
  var kContentModeBuffer = "buffer";
14194
14104
  var kContentModeUtf8 = "utf8";
14105
+ var [major, minor] = (process.versions.node || "0.0").split(".").map(Number);
14106
+ var kCopyBuffer = major >= 22 && minor >= 7;
14195
14107
  function openFile(file, sonic) {
14196
14108
  sonic._opening = true;
14197
14109
  sonic._writing = true;
@@ -14256,7 +14168,7 @@ var require_sonic_boom = __commonJS({
14256
14168
  if (!(this instanceof SonicBoom)) {
14257
14169
  return new SonicBoom(opts);
14258
14170
  }
14259
- let { fd, dest, minLength, maxLength, maxWrite, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {};
14171
+ let { fd, dest, minLength, maxLength, maxWrite, periodicFlush, sync, append = true, mkdir, retryEAGAIN, fsync, contentMode, mode } = opts || {};
14260
14172
  fd = fd || dest;
14261
14173
  this._len = 0;
14262
14174
  this.fd = -1;
@@ -14273,6 +14185,8 @@ var require_sonic_boom = __commonJS({
14273
14185
  this.minLength = minLength || 0;
14274
14186
  this.maxLength = maxLength || 0;
14275
14187
  this.maxWrite = maxWrite || MAX_WRITE;
14188
+ this._periodicFlush = periodicFlush || 0;
14189
+ this._periodicFlushTimer = void 0;
14276
14190
  this.sync = sync || false;
14277
14191
  this.writable = true;
14278
14192
  this._fsync = fsync || false;
@@ -14296,8 +14210,18 @@ var require_sonic_boom = __commonJS({
14296
14210
  this.flush = flush;
14297
14211
  this.flushSync = flushSync;
14298
14212
  this._actualWrite = actualWrite;
14299
- fsWriteSync = () => fs.writeSync(this.fd, this._writingBuf, "utf8");
14300
- fsWrite = () => fs.write(this.fd, this._writingBuf, "utf8", this.release);
14213
+ fsWriteSync = () => {
14214
+ if (Buffer.isBuffer(this._writingBuf)) {
14215
+ return fs.writeSync(this.fd, this._writingBuf);
14216
+ }
14217
+ return fs.writeSync(this.fd, this._writingBuf, "utf8");
14218
+ };
14219
+ fsWrite = () => {
14220
+ if (Buffer.isBuffer(this._writingBuf)) {
14221
+ return fs.write(this.fd, this._writingBuf, this.release);
14222
+ }
14223
+ return fs.write(this.fd, this._writingBuf, "utf8", this.release);
14224
+ };
14301
14225
  } else {
14302
14226
  throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
14303
14227
  }
@@ -14386,13 +14310,17 @@ var require_sonic_boom = __commonJS({
14386
14310
  this._asyncDrainScheduled = false;
14387
14311
  }
14388
14312
  });
14313
+ if (this._periodicFlush !== 0) {
14314
+ this._periodicFlushTimer = setInterval(() => this.flush(null), this._periodicFlush);
14315
+ this._periodicFlushTimer.unref();
14316
+ }
14389
14317
  }
14390
14318
  function releaseWritingBuf(writingBuf, len, n) {
14391
- if (typeof writingBuf === "string" && Buffer.byteLength(writingBuf) !== n) {
14392
- n = Buffer.from(writingBuf).subarray(0, n).toString().length;
14319
+ if (typeof writingBuf === "string") {
14320
+ writingBuf = Buffer.from(writingBuf);
14393
14321
  }
14394
14322
  len = Math.max(len - n, 0);
14395
- writingBuf = writingBuf.slice(n);
14323
+ writingBuf = writingBuf.subarray(n);
14396
14324
  return { writingBuf, len };
14397
14325
  }
14398
14326
  function emitDrain(sonic) {
@@ -14415,14 +14343,16 @@ var require_sonic_boom = __commonJS({
14415
14343
  if (this.destroyed) {
14416
14344
  throw new Error("SonicBoom destroyed");
14417
14345
  }
14418
- const len = this._len + data.length;
14346
+ data = "" + data;
14347
+ const dataLen = Buffer.byteLength(data);
14348
+ const len = this._len + dataLen;
14419
14349
  const bufs = this._bufs;
14420
14350
  if (this.maxLength && len > this.maxLength) {
14421
14351
  this.emit("drop", data);
14422
14352
  return this._len < this._hwm;
14423
14353
  }
14424
- if (bufs.length === 0 || bufs[bufs.length - 1].length + data.length > this.maxWrite) {
14425
- bufs.push("" + data);
14354
+ if (bufs.length === 0 || Buffer.byteLength(bufs[bufs.length - 1]) + dataLen > this.maxWrite) {
14355
+ bufs.push(data);
14426
14356
  } else {
14427
14357
  bufs[bufs.length - 1] += data;
14428
14358
  }
@@ -14460,10 +14390,14 @@ var require_sonic_boom = __commonJS({
14460
14390
  this._flushPending = true;
14461
14391
  const onDrain = () => {
14462
14392
  if (!this._fsync) {
14463
- fs.fsync(this.fd, (err) => {
14464
- this._flushPending = false;
14393
+ try {
14394
+ fs.fsync(this.fd, (err) => {
14395
+ this._flushPending = false;
14396
+ cb(err);
14397
+ });
14398
+ } catch (err) {
14465
14399
  cb(err);
14466
- });
14400
+ }
14467
14401
  } else {
14468
14402
  this._flushPending = false;
14469
14403
  cb();
@@ -14603,12 +14537,12 @@ var require_sonic_boom = __commonJS({
14603
14537
  this._writingBuf = "";
14604
14538
  }
14605
14539
  let buf = "";
14606
- while (this._bufs.length || buf) {
14540
+ while (this._bufs.length || buf.length) {
14607
14541
  if (buf.length <= 0) {
14608
14542
  buf = this._bufs[0];
14609
14543
  }
14610
14544
  try {
14611
- const n = fs.writeSync(this.fd, buf, "utf8");
14545
+ const n = Buffer.isBuffer(buf) ? fs.writeSync(this.fd, buf) : fs.writeSync(this.fd, buf, "utf8");
14612
14546
  const releasedBufObj = releaseWritingBuf(buf, this._len, n);
14613
14547
  buf = releasedBufObj.writingBuf;
14614
14548
  this._len = releasedBufObj.len;
@@ -14670,16 +14604,16 @@ var require_sonic_boom = __commonJS({
14670
14604
  function actualWrite() {
14671
14605
  const release = this.release;
14672
14606
  this._writing = true;
14673
- this._writingBuf = this._writingBuf || this._bufs.shift() || "";
14607
+ this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
14674
14608
  if (this.sync) {
14675
14609
  try {
14676
- const written = fs.writeSync(this.fd, this._writingBuf, "utf8");
14610
+ const written = Buffer.isBuffer(this._writingBuf) ? fs.writeSync(this.fd, this._writingBuf) : fs.writeSync(this.fd, this._writingBuf, "utf8");
14677
14611
  release(null, written);
14678
14612
  } catch (err) {
14679
14613
  release(err);
14680
14614
  }
14681
14615
  } else {
14682
- fs.write(this.fd, this._writingBuf, "utf8", release);
14616
+ fs.write(this.fd, this._writingBuf, release);
14683
14617
  }
14684
14618
  }
14685
14619
  function actualWriteBuffer() {
@@ -14694,6 +14628,9 @@ var require_sonic_boom = __commonJS({
14694
14628
  release(err);
14695
14629
  }
14696
14630
  } else {
14631
+ if (kCopyBuffer) {
14632
+ this._writingBuf = Buffer.from(this._writingBuf);
14633
+ }
14697
14634
  fs.write(this.fd, this._writingBuf, release);
14698
14635
  }
14699
14636
  }
@@ -14702,10 +14639,17 @@ var require_sonic_boom = __commonJS({
14702
14639
  sonic.once("ready", actualClose.bind(null, sonic));
14703
14640
  return;
14704
14641
  }
14642
+ if (sonic._periodicFlushTimer !== void 0) {
14643
+ clearInterval(sonic._periodicFlushTimer);
14644
+ }
14705
14645
  sonic.destroyed = true;
14706
14646
  sonic._bufs = [];
14707
14647
  sonic._lens = [];
14708
- fs.fsync(sonic.fd, closeWrapped);
14648
+ assert(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
14649
+ try {
14650
+ fs.fsync(sonic.fd, closeWrapped);
14651
+ } catch {
14652
+ }
14709
14653
  function closeWrapped() {
14710
14654
  if (sonic.fd !== 1 && sonic.fd !== 2) {
14711
14655
  fs.close(sonic.fd, done);
@@ -14829,41 +14773,36 @@ var require_package2 = __commonJS({
14829
14773
  "node_modules/thread-stream/package.json"(exports, module) {
14830
14774
  module.exports = {
14831
14775
  name: "thread-stream",
14832
- version: "2.7.0",
14776
+ version: "4.2.0",
14833
14777
  description: "A streaming way to send data to a Node.js Worker Thread",
14834
14778
  main: "index.js",
14835
14779
  types: "index.d.ts",
14780
+ engines: {
14781
+ node: ">=20"
14782
+ },
14836
14783
  dependencies: {
14837
- "real-require": "^0.2.0"
14784
+ "real-require": "^1.0.0"
14838
14785
  },
14839
14786
  devDependencies: {
14840
- "@types/node": "^20.1.0",
14841
- "@types/tap": "^15.0.0",
14842
- "@yao-pkg/pkg": "^5.11.5",
14787
+ "@types/node": "^25.0.2",
14788
+ "@yao-pkg/pkg": "^6.0.0",
14789
+ borp: "^1.0.0",
14843
14790
  desm: "^1.3.0",
14791
+ eslint: "^9.39.1",
14844
14792
  fastbench: "^1.0.1",
14845
- husky: "^9.0.6",
14846
- "pino-elasticsearch": "^8.0.0",
14847
- "sonic-boom": "^3.0.0",
14848
- standard: "^17.0.0",
14849
- tap: "^16.2.0",
14793
+ neostandard: "^0.13.0",
14794
+ "pino-elasticsearch": "^9.0.0",
14795
+ "sonic-boom": "^5.0.0",
14850
14796
  "ts-node": "^10.8.0",
14851
- typescript: "^5.3.2",
14852
- "why-is-node-running": "^2.2.2"
14797
+ typescript: "~5.7.3"
14853
14798
  },
14854
14799
  scripts: {
14855
- test: 'standard && npm run transpile && tap "test/**/*.test.*js" && tap --ts test/*.test.*ts',
14856
- "test:ci": "standard && npm run transpile && npm run test:ci:js && npm run test:ci:ts",
14857
- "test:ci:js": 'tap --no-check-coverage --timeout=120 --coverage-report=lcovonly "test/**/*.test.*js"',
14858
- "test:ci:ts": 'tap --ts --no-check-coverage --coverage-report=lcovonly "test/**/*.test.*ts"',
14859
- "test:yarn": 'npm run transpile && tap "test/**/*.test.js" --no-check-coverage',
14860
- transpile: "sh ./test/ts/transpile.sh",
14861
- prepare: "husky install"
14862
- },
14863
- standard: {
14864
- ignore: [
14865
- "test/ts/**/*"
14866
- ]
14800
+ build: "tsc --noEmit",
14801
+ lint: "eslint",
14802
+ test: 'npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',
14803
+ "test:ci": 'npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',
14804
+ "test:yarn": 'npm run transpile && borp --pattern "test/*.test.js"',
14805
+ transpile: "sh ./test/ts/transpile.sh"
14867
14806
  },
14868
14807
  repository: {
14869
14808
  type: "git",
@@ -14889,55 +14828,56 @@ var require_package2 = __commonJS({
14889
14828
  var require_wait = __commonJS({
14890
14829
  "node_modules/thread-stream/lib/wait.js"(exports, module) {
14891
14830
  "use strict";
14892
- var MAX_TIMEOUT = 1e3;
14831
+ var WAIT_MS = 1e4;
14893
14832
  function wait(state, index, expected, timeout, done) {
14894
- const max = Date.now() + timeout;
14895
- let current = Atomics.load(state, index);
14896
- if (current === expected) {
14897
- done(null, "ok");
14898
- return;
14899
- }
14900
- let prior = current;
14901
- const check = (backoff) => {
14902
- if (Date.now() > max) {
14833
+ const max = timeout === Infinity ? Infinity : Date.now() + timeout;
14834
+ const check = () => {
14835
+ const current = Atomics.load(state, index);
14836
+ if (current === expected) {
14837
+ done(null, "ok");
14838
+ return;
14839
+ }
14840
+ if (max !== Infinity && Date.now() > max) {
14903
14841
  done(null, "timed-out");
14842
+ return;
14843
+ }
14844
+ const remaining = max === Infinity ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
14845
+ const result = Atomics.waitAsync(state, index, current, remaining);
14846
+ if (result.async) {
14847
+ result.value.then(check);
14904
14848
  } else {
14905
- setTimeout(() => {
14906
- prior = current;
14907
- current = Atomics.load(state, index);
14908
- if (current === prior) {
14909
- check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
14910
- } else {
14911
- if (current === expected) done(null, "ok");
14912
- else done(null, "not-equal");
14913
- }
14914
- }, backoff);
14849
+ setImmediate(check);
14915
14850
  }
14916
14851
  };
14917
- check(1);
14852
+ check();
14918
14853
  }
14919
14854
  function waitDiff(state, index, expected, timeout, done) {
14920
- const max = Date.now() + timeout;
14921
- let current = Atomics.load(state, index);
14922
- if (current !== expected) {
14923
- done(null, "ok");
14924
- return;
14925
- }
14926
- const check = (backoff) => {
14927
- if (Date.now() > max) {
14855
+ const max = timeout === Infinity ? Infinity : Date.now() + timeout;
14856
+ const check = () => {
14857
+ const current = Atomics.load(state, index);
14858
+ if (current !== expected) {
14859
+ done(null, "ok");
14860
+ return;
14861
+ }
14862
+ if (max !== Infinity && Date.now() > max) {
14928
14863
  done(null, "timed-out");
14929
- } else {
14930
- setTimeout(() => {
14931
- current = Atomics.load(state, index);
14932
- if (current !== expected) {
14864
+ return;
14865
+ }
14866
+ const remaining = max === Infinity ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
14867
+ const result = Atomics.waitAsync(state, index, expected, remaining);
14868
+ if (result.async) {
14869
+ result.value.then((res) => {
14870
+ if (res === "ok") {
14933
14871
  done(null, "ok");
14934
- } else {
14935
- check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
14872
+ return;
14936
14873
  }
14937
- }, backoff);
14874
+ check();
14875
+ });
14876
+ } else {
14877
+ setImmediate(check);
14938
14878
  }
14939
14879
  };
14940
- check(1);
14880
+ check();
14941
14881
  }
14942
14882
  module.exports = { wait, waitDiff };
14943
14883
  }
@@ -14947,11 +14887,13 @@ var require_wait = __commonJS({
14947
14887
  var require_indexes = __commonJS({
14948
14888
  "node_modules/thread-stream/lib/indexes.js"(exports, module) {
14949
14889
  "use strict";
14890
+ var SEQ_INDEX = 2;
14950
14891
  var WRITE_INDEX = 4;
14951
14892
  var READ_INDEX = 8;
14952
14893
  module.exports = {
14953
14894
  WRITE_INDEX,
14954
- READ_INDEX
14895
+ READ_INDEX,
14896
+ SEQ_INDEX
14955
14897
  };
14956
14898
  }
14957
14899
  });
@@ -14968,12 +14910,27 @@ var require_thread_stream = __commonJS({
14968
14910
  var { wait } = require_wait();
14969
14911
  var {
14970
14912
  WRITE_INDEX,
14971
- READ_INDEX
14913
+ READ_INDEX,
14914
+ SEQ_INDEX
14972
14915
  } = require_indexes();
14973
14916
  var buffer = __require("buffer");
14974
14917
  var assert = __require("assert");
14975
14918
  var kImpl = /* @__PURE__ */ Symbol("kImpl");
14976
14919
  var MAX_STRING = buffer.constants.MAX_STRING_LENGTH;
14920
+ function noop() {
14921
+ }
14922
+ function updateState(stream, fn) {
14923
+ Atomics.add(stream[kImpl].state, SEQ_INDEX, 1);
14924
+ fn();
14925
+ Atomics.add(stream[kImpl].state, SEQ_INDEX, 1);
14926
+ Atomics.notify(stream[kImpl].state, SEQ_INDEX);
14927
+ }
14928
+ function resetIndexes(stream) {
14929
+ updateState(stream, () => {
14930
+ Atomics.store(stream[kImpl].state, READ_INDEX, 0);
14931
+ Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
14932
+ });
14933
+ }
14977
14934
  var FakeWeakRef = class {
14978
14935
  constructor(value) {
14979
14936
  this._value = value;
@@ -15002,6 +14959,7 @@ var require_thread_stream = __commonJS({
15002
14959
  const toExecute = bundlerOverrides["thread-stream-worker"] || join2(__dirname, "lib", "worker.js");
15003
14960
  const worker = new Worker(toExecute, {
15004
14961
  ...opts.workerOpts,
14962
+ name: opts.workerOpts?.name || "thread-stream",
15005
14963
  trackUnmanagedFds: false,
15006
14964
  workerData: {
15007
14965
  filename: filename.indexOf("file://") === 0 ? filename : pathToFileURL(filename).href,
@@ -15029,50 +14987,37 @@ var require_thread_stream = __commonJS({
15029
14987
  }
15030
14988
  }
15031
14989
  function nextFlush(stream) {
15032
- const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
15033
- let leftover = stream[kImpl].data.length - writeIndex;
15034
- if (leftover > 0) {
15035
- if (stream[kImpl].buf.length === 0) {
15036
- stream[kImpl].flushing = false;
15037
- if (stream[kImpl].ending) {
15038
- end(stream);
15039
- } else if (stream[kImpl].needDrain) {
15040
- process.nextTick(drain, stream);
14990
+ while (true) {
14991
+ const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
14992
+ const leftover = stream[kImpl].data.length - writeIndex;
14993
+ if (leftover > 0) {
14994
+ if (stream[kImpl].bufLen === 0) {
14995
+ stream[kImpl].flushing = false;
14996
+ if (stream[kImpl].ending) {
14997
+ end(stream);
14998
+ } else if (stream[kImpl].needDrain) {
14999
+ process.nextTick(drain, stream);
15000
+ }
15001
+ return;
15041
15002
  }
15042
- return;
15003
+ write(stream, leftover, noop);
15004
+ continue;
15043
15005
  }
15044
- let toWrite = stream[kImpl].buf.slice(0, leftover);
15045
- let toWriteBytes = Buffer.byteLength(toWrite);
15046
- if (toWriteBytes <= leftover) {
15047
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
15048
- write(stream, toWrite, nextFlush.bind(null, stream));
15049
- } else {
15050
- stream.flush(() => {
15006
+ if (leftover === 0) {
15007
+ if (writeIndex === 0 && stream[kImpl].bufLen === 0) {
15008
+ return;
15009
+ }
15010
+ waitForRead(stream, () => {
15051
15011
  if (stream.destroyed) {
15052
15012
  return;
15053
15013
  }
15054
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
15055
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
15056
- while (toWriteBytes > stream[kImpl].data.length) {
15057
- leftover = leftover / 2;
15058
- toWrite = stream[kImpl].buf.slice(0, leftover);
15059
- toWriteBytes = Buffer.byteLength(toWrite);
15060
- }
15061
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
15062
- write(stream, toWrite, nextFlush.bind(null, stream));
15014
+ resetIndexes(stream);
15015
+ nextFlush(stream);
15063
15016
  });
15064
- }
15065
- } else if (leftover === 0) {
15066
- if (writeIndex === 0 && stream[kImpl].buf.length === 0) {
15067
15017
  return;
15068
15018
  }
15069
- stream.flush(() => {
15070
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
15071
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
15072
- nextFlush(stream);
15073
- });
15074
- } else {
15075
15019
  destroy(stream, new Error("overwritten"));
15020
+ return;
15076
15021
  }
15077
15022
  }
15078
15023
  function onWorkerMessage(msg) {
@@ -15082,10 +15027,13 @@ var require_thread_stream = __commonJS({
15082
15027
  this.terminate();
15083
15028
  return;
15084
15029
  }
15030
+ if (msg?.code == null) {
15031
+ return;
15032
+ }
15085
15033
  switch (msg.code) {
15086
15034
  case "READY":
15087
15035
  this.stream = new WeakRef2(stream);
15088
- stream.flush(() => {
15036
+ waitForRead(stream, () => {
15089
15037
  stream[kImpl].ready = true;
15090
15038
  stream.emit("ready");
15091
15039
  });
@@ -15100,6 +15048,18 @@ var require_thread_stream = __commonJS({
15100
15048
  stream.emit(msg.name, msg.args);
15101
15049
  }
15102
15050
  break;
15051
+ case "FLUSHED": {
15052
+ if (msg.context !== "thread-stream") {
15053
+ destroy(stream, new Error("this should not happen: " + msg.code));
15054
+ break;
15055
+ }
15056
+ const cb = stream[kImpl].flushCallbacks.get(msg.id);
15057
+ if (cb) {
15058
+ stream[kImpl].flushCallbacks.delete(msg.id);
15059
+ process.nextTick(cb);
15060
+ }
15061
+ break;
15062
+ }
15103
15063
  case "WARNING":
15104
15064
  process.emitWarning(msg.err);
15105
15065
  break;
@@ -15138,13 +15098,18 @@ var require_thread_stream = __commonJS({
15138
15098
  this[kImpl].finished = false;
15139
15099
  this[kImpl].errored = null;
15140
15100
  this[kImpl].closed = false;
15141
- this[kImpl].buf = "";
15101
+ this[kImpl].buf = [];
15102
+ this[kImpl].bufHead = 0;
15103
+ this[kImpl].bufLen = 0;
15104
+ this[kImpl].flushCallbacks = /* @__PURE__ */ new Map();
15105
+ this[kImpl].nextFlushId = 0;
15142
15106
  this.worker = createWorker(this, opts);
15143
15107
  this.on("message", (message, transferList) => {
15144
15108
  this.worker.postMessage(message, transferList);
15145
15109
  });
15146
15110
  }
15147
15111
  write(data) {
15112
+ const dataBuf = Buffer.isBuffer(data) ? data : Buffer.from(data);
15148
15113
  if (this[kImpl].destroyed) {
15149
15114
  error(this, new Error("the worker has exited"));
15150
15115
  return false;
@@ -15153,7 +15118,7 @@ var require_thread_stream = __commonJS({
15153
15118
  error(this, new Error("the worker is ending"));
15154
15119
  return false;
15155
15120
  }
15156
- if (this[kImpl].flushing && this[kImpl].buf.length + data.length >= MAX_STRING) {
15121
+ if (this[kImpl].flushing && this[kImpl].bufLen + dataBuf.length >= MAX_STRING) {
15157
15122
  try {
15158
15123
  writeSync(this);
15159
15124
  this[kImpl].flushing = true;
@@ -15162,7 +15127,8 @@ var require_thread_stream = __commonJS({
15162
15127
  return false;
15163
15128
  }
15164
15129
  }
15165
- this[kImpl].buf += data;
15130
+ this[kImpl].buf.push(dataBuf);
15131
+ this[kImpl].bufLen += dataBuf.length;
15166
15132
  if (this[kImpl].sync) {
15167
15133
  try {
15168
15134
  writeSync(this);
@@ -15176,7 +15142,7 @@ var require_thread_stream = __commonJS({
15176
15142
  this[kImpl].flushing = true;
15177
15143
  setImmediate(nextFlush, this);
15178
15144
  }
15179
- this[kImpl].needDrain = this[kImpl].data.length - this[kImpl].buf.length - Atomics.load(this[kImpl].state, WRITE_INDEX) <= 0;
15145
+ this[kImpl].needDrain = this[kImpl].data.length - this[kImpl].bufLen - Atomics.load(this[kImpl].state, WRITE_INDEX) <= 0;
15180
15146
  return !this[kImpl].needDrain;
15181
15147
  }
15182
15148
  end() {
@@ -15187,24 +15153,13 @@ var require_thread_stream = __commonJS({
15187
15153
  end(this);
15188
15154
  }
15189
15155
  flush(cb) {
15190
- if (this[kImpl].destroyed) {
15191
- if (typeof cb === "function") {
15192
- process.nextTick(cb, new Error("the worker has exited"));
15193
- }
15194
- return;
15195
- }
15196
- const writeIndex = Atomics.load(this[kImpl].state, WRITE_INDEX);
15197
- wait(this[kImpl].state, READ_INDEX, writeIndex, Infinity, (err, res) => {
15156
+ cb = typeof cb === "function" ? cb : noop;
15157
+ flushBuffer(this, (err) => {
15198
15158
  if (err) {
15199
- destroy(this, err);
15200
15159
  process.nextTick(cb, err);
15201
15160
  return;
15202
15161
  }
15203
- if (res === "not-equal") {
15204
- this.flush(cb);
15205
- return;
15206
- }
15207
- process.nextTick(cb);
15162
+ requestWorkerFlush(this, cb);
15208
15163
  });
15209
15164
  }
15210
15165
  flushSync() {
@@ -15248,6 +15203,79 @@ var require_thread_stream = __commonJS({
15248
15203
  return this[kImpl].errored;
15249
15204
  }
15250
15205
  };
15206
+ function flushBuffer(stream, cb) {
15207
+ if (stream[kImpl].destroyed) {
15208
+ process.nextTick(cb, new Error("the worker has exited"));
15209
+ return;
15210
+ }
15211
+ if (!stream[kImpl].sync && (stream[kImpl].flushing || stream[kImpl].bufLen > 0)) {
15212
+ setImmediate(flushBuffer, stream, cb);
15213
+ return;
15214
+ }
15215
+ waitForRead(stream, cb);
15216
+ }
15217
+ function waitForRead(stream, cb) {
15218
+ const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
15219
+ wait(stream[kImpl].state, READ_INDEX, writeIndex, Infinity, (err, res) => {
15220
+ if (err) {
15221
+ destroy(stream, err);
15222
+ cb(err);
15223
+ return;
15224
+ }
15225
+ if (res !== "ok") {
15226
+ waitForRead(stream, cb);
15227
+ return;
15228
+ }
15229
+ cb();
15230
+ });
15231
+ }
15232
+ function requestWorkerFlush(stream, cb) {
15233
+ if (stream[kImpl].destroyed) {
15234
+ process.nextTick(cb, new Error("the worker has exited"));
15235
+ return;
15236
+ }
15237
+ if (!stream[kImpl].ready) {
15238
+ const onReady = () => {
15239
+ cleanup();
15240
+ requestWorkerFlush(stream, cb);
15241
+ };
15242
+ const onClose = () => {
15243
+ cleanup();
15244
+ process.nextTick(cb, new Error("the worker has exited"));
15245
+ };
15246
+ const cleanup = () => {
15247
+ stream.off("ready", onReady);
15248
+ stream.off("close", onClose);
15249
+ };
15250
+ stream.once("ready", onReady);
15251
+ stream.once("close", onClose);
15252
+ return;
15253
+ }
15254
+ const id = ++stream[kImpl].nextFlushId;
15255
+ stream[kImpl].flushCallbacks.set(id, cb);
15256
+ try {
15257
+ stream.worker.postMessage({
15258
+ code: "FLUSH",
15259
+ context: "thread-stream",
15260
+ id
15261
+ });
15262
+ } catch (err) {
15263
+ stream[kImpl].flushCallbacks.delete(id);
15264
+ destroy(stream, err);
15265
+ process.nextTick(cb, err);
15266
+ }
15267
+ }
15268
+ function failPendingFlushCallbacks(stream, err) {
15269
+ const callbacks = stream[kImpl].flushCallbacks;
15270
+ if (callbacks.size === 0) {
15271
+ return;
15272
+ }
15273
+ const flushErr = err || new Error("the worker has exited");
15274
+ for (const cb of callbacks.values()) {
15275
+ process.nextTick(cb, flushErr);
15276
+ }
15277
+ callbacks.clear();
15278
+ }
15251
15279
  function error(stream, err) {
15252
15280
  setImmediate(() => {
15253
15281
  stream.emit("error", err);
@@ -15258,6 +15286,7 @@ var require_thread_stream = __commonJS({
15258
15286
  return;
15259
15287
  }
15260
15288
  stream[kImpl].destroyed = true;
15289
+ failPendingFlushCallbacks(stream, err);
15261
15290
  if (err) {
15262
15291
  stream[kImpl].errored = err;
15263
15292
  error(stream, err);
@@ -15275,12 +15304,37 @@ var require_thread_stream = __commonJS({
15275
15304
  });
15276
15305
  }
15277
15306
  }
15278
- function write(stream, data, cb) {
15307
+ function write(stream, maxBytes, cb) {
15279
15308
  const current = Atomics.load(stream[kImpl].state, WRITE_INDEX);
15280
- const length = Buffer.byteLength(data);
15281
- stream[kImpl].data.write(data, current);
15282
- Atomics.store(stream[kImpl].state, WRITE_INDEX, current + length);
15283
- Atomics.notify(stream[kImpl].state, WRITE_INDEX);
15309
+ let offset = current;
15310
+ let remaining = maxBytes;
15311
+ while (remaining > 0 && stream[kImpl].bufLen !== 0) {
15312
+ const head = stream[kImpl].bufHead;
15313
+ const buf = stream[kImpl].buf[head];
15314
+ if (buf.length <= remaining) {
15315
+ buf.copy(stream[kImpl].data, offset);
15316
+ offset += buf.length;
15317
+ remaining -= buf.length;
15318
+ stream[kImpl].bufLen -= buf.length;
15319
+ stream[kImpl].bufHead = head + 1;
15320
+ if (stream[kImpl].bufHead === stream[kImpl].buf.length) {
15321
+ stream[kImpl].buf.length = 0;
15322
+ stream[kImpl].bufHead = 0;
15323
+ } else if (stream[kImpl].bufHead >= 1024 && stream[kImpl].bufHead * 2 >= stream[kImpl].buf.length) {
15324
+ stream[kImpl].buf.splice(0, stream[kImpl].bufHead);
15325
+ stream[kImpl].bufHead = 0;
15326
+ }
15327
+ continue;
15328
+ }
15329
+ buf.copy(stream[kImpl].data, offset, 0, remaining);
15330
+ stream[kImpl].buf[head] = buf.subarray(remaining);
15331
+ stream[kImpl].bufLen -= remaining;
15332
+ offset += remaining;
15333
+ remaining = 0;
15334
+ }
15335
+ updateState(stream, () => {
15336
+ Atomics.store(stream[kImpl].state, WRITE_INDEX, offset);
15337
+ });
15284
15338
  cb();
15285
15339
  return true;
15286
15340
  }
@@ -15292,8 +15346,9 @@ var require_thread_stream = __commonJS({
15292
15346
  try {
15293
15347
  stream.flushSync();
15294
15348
  let readIndex = Atomics.load(stream[kImpl].state, READ_INDEX);
15295
- Atomics.store(stream[kImpl].state, WRITE_INDEX, -1);
15296
- Atomics.notify(stream[kImpl].state, WRITE_INDEX);
15349
+ updateState(stream, () => {
15350
+ Atomics.store(stream[kImpl].state, WRITE_INDEX, -1);
15351
+ });
15297
15352
  let spins = 0;
15298
15353
  while (readIndex !== -1) {
15299
15354
  Atomics.wait(stream[kImpl].state, READ_INDEX, readIndex, 1e3);
@@ -15324,34 +15379,17 @@ var require_thread_stream = __commonJS({
15324
15379
  }
15325
15380
  };
15326
15381
  stream[kImpl].flushing = false;
15327
- while (stream[kImpl].buf.length !== 0) {
15382
+ while (stream[kImpl].bufLen !== 0) {
15328
15383
  const writeIndex = Atomics.load(stream[kImpl].state, WRITE_INDEX);
15329
- let leftover = stream[kImpl].data.length - writeIndex;
15384
+ const leftover = stream[kImpl].data.length - writeIndex;
15330
15385
  if (leftover === 0) {
15331
15386
  flushSync(stream);
15332
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
15333
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
15387
+ resetIndexes(stream);
15334
15388
  continue;
15335
15389
  } else if (leftover < 0) {
15336
15390
  throw new Error("overwritten");
15337
15391
  }
15338
- let toWrite = stream[kImpl].buf.slice(0, leftover);
15339
- let toWriteBytes = Buffer.byteLength(toWrite);
15340
- if (toWriteBytes <= leftover) {
15341
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
15342
- write(stream, toWrite, cb);
15343
- } else {
15344
- flushSync(stream);
15345
- Atomics.store(stream[kImpl].state, READ_INDEX, 0);
15346
- Atomics.store(stream[kImpl].state, WRITE_INDEX, 0);
15347
- while (toWriteBytes > stream[kImpl].buf.length) {
15348
- leftover = leftover / 2;
15349
- toWrite = stream[kImpl].buf.slice(0, leftover);
15350
- toWriteBytes = Buffer.byteLength(toWrite);
15351
- }
15352
- stream[kImpl].buf = stream[kImpl].buf.slice(leftover);
15353
- write(stream, toWrite, cb);
15354
- }
15392
+ write(stream, leftover, cb);
15355
15393
  }
15356
15394
  }
15357
15395
  function flushSync(stream) {
@@ -15384,8 +15422,10 @@ var require_transport = __commonJS({
15384
15422
  "node_modules/pino/lib/transport.js"(exports, module) {
15385
15423
  "use strict";
15386
15424
  var { createRequire } = __require("module");
15425
+ var { existsSync } = __require("fs");
15387
15426
  var getCallers = require_caller();
15388
15427
  var { join: join2, isAbsolute, sep } = __require("path");
15428
+ var { fileURLToPath } = __require("url");
15389
15429
  var sleep = require_atomic_sleep();
15390
15430
  var onExit = require_on_exit_leak_free();
15391
15431
  var ThreadStream = require_thread_stream();
@@ -15396,11 +15436,101 @@ var require_transport = __commonJS({
15396
15436
  onExit.unregister(stream);
15397
15437
  });
15398
15438
  }
15399
- function buildStream(filename, workerData, workerOpts) {
15439
+ function hasPreloadFlags() {
15440
+ const execArgv = process.execArgv;
15441
+ for (let i = 0; i < execArgv.length; i++) {
15442
+ const arg = execArgv[i];
15443
+ if (arg === "--import" || arg === "--require" || arg === "-r") {
15444
+ return true;
15445
+ }
15446
+ if (arg.startsWith("--import=") || arg.startsWith("--require=") || arg.startsWith("-r=")) {
15447
+ return true;
15448
+ }
15449
+ }
15450
+ return false;
15451
+ }
15452
+ function sanitizeNodeOptions(nodeOptions) {
15453
+ const tokens = nodeOptions.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);
15454
+ if (!tokens) {
15455
+ return nodeOptions;
15456
+ }
15457
+ const sanitized = [];
15458
+ let changed = false;
15459
+ for (let i = 0; i < tokens.length; i++) {
15460
+ const token2 = tokens[i];
15461
+ if (token2 === "--require" || token2 === "-r" || token2 === "--import") {
15462
+ const next = tokens[i + 1];
15463
+ if (next && shouldDropPreload(next)) {
15464
+ changed = true;
15465
+ i++;
15466
+ continue;
15467
+ }
15468
+ sanitized.push(token2);
15469
+ if (next) {
15470
+ sanitized.push(next);
15471
+ i++;
15472
+ }
15473
+ continue;
15474
+ }
15475
+ if (token2.startsWith("--require=") || token2.startsWith("-r=") || token2.startsWith("--import=")) {
15476
+ const value = token2.slice(token2.indexOf("=") + 1);
15477
+ if (shouldDropPreload(value)) {
15478
+ changed = true;
15479
+ continue;
15480
+ }
15481
+ }
15482
+ sanitized.push(token2);
15483
+ }
15484
+ return changed ? sanitized.join(" ") : nodeOptions;
15485
+ }
15486
+ function shouldDropPreload(value) {
15487
+ const unquoted = stripQuotes(value);
15488
+ if (!unquoted) {
15489
+ return false;
15490
+ }
15491
+ let path = unquoted;
15492
+ if (path.startsWith("file://")) {
15493
+ try {
15494
+ path = fileURLToPath(path);
15495
+ } catch {
15496
+ return false;
15497
+ }
15498
+ }
15499
+ return isAbsolute(path) && !existsSync(path);
15500
+ }
15501
+ function stripQuotes(value) {
15502
+ const first = value[0];
15503
+ const last = value[value.length - 1];
15504
+ if (first === '"' && last === '"' || first === "'" && last === "'") {
15505
+ return value.slice(1, -1);
15506
+ }
15507
+ return value;
15508
+ }
15509
+ function buildStream(filename, workerData, workerOpts, sync, name) {
15510
+ if (!workerOpts.execArgv && hasPreloadFlags() && __require.main === void 0) {
15511
+ workerOpts = {
15512
+ ...workerOpts,
15513
+ execArgv: []
15514
+ };
15515
+ }
15516
+ if (!workerOpts.env && process.env.NODE_OPTIONS) {
15517
+ const nodeOptions = sanitizeNodeOptions(process.env.NODE_OPTIONS);
15518
+ if (nodeOptions !== process.env.NODE_OPTIONS) {
15519
+ workerOpts = {
15520
+ ...workerOpts,
15521
+ env: {
15522
+ ...process.env,
15523
+ NODE_OPTIONS: nodeOptions
15524
+ }
15525
+ };
15526
+ }
15527
+ }
15528
+ workerOpts = { ...workerOpts, name };
15400
15529
  const stream = new ThreadStream({
15401
15530
  filename,
15402
15531
  workerData,
15403
- workerOpts
15532
+ workerOpts,
15533
+ sync
15404
15534
  });
15405
15535
  stream.on("ready", onReady);
15406
15536
  stream.on("close", function() {
@@ -15436,29 +15566,42 @@ var require_transport = __commonJS({
15436
15566
  stream.flushSync();
15437
15567
  }
15438
15568
  function transport(fullOptions) {
15439
- const { pipeline, targets, levels, dedupe, options = {}, worker = {}, caller = getCallers() } = fullOptions;
15569
+ const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
15570
+ const options = {
15571
+ ...fullOptions.options
15572
+ };
15440
15573
  const callers = typeof caller === "string" ? [caller] : caller;
15441
- const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
15574
+ const bundlerOverrides = typeof globalThis === "object" && Object.prototype.hasOwnProperty.call(globalThis, "__bundlerPathsOverrides") && globalThis.__bundlerPathsOverrides && typeof globalThis.__bundlerPathsOverrides === "object" ? globalThis.__bundlerPathsOverrides : /* @__PURE__ */ Object.create(null);
15442
15575
  let target = fullOptions.target;
15443
15576
  if (target && targets) {
15444
15577
  throw new Error("only one of target or targets can be specified");
15445
15578
  }
15446
15579
  if (targets) {
15447
15580
  target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
15448
- options.targets = targets.map((dest) => {
15581
+ options.targets = targets.filter((dest) => dest.target).map((dest) => {
15449
15582
  return {
15450
15583
  ...dest,
15451
15584
  target: fixTarget(dest.target)
15452
15585
  };
15453
15586
  });
15587
+ options.pipelines = targets.filter((dest) => dest.pipeline).map((dest) => {
15588
+ return dest.pipeline.map((t) => {
15589
+ return {
15590
+ ...t,
15591
+ level: dest.level,
15592
+ // duplicate the pipeline `level` property defined in the upper level
15593
+ target: fixTarget(t.target)
15594
+ };
15595
+ });
15596
+ });
15454
15597
  } else if (pipeline) {
15455
- target = bundlerOverrides["pino-pipeline-worker"] || join2(__dirname, "worker-pipeline.js");
15456
- options.targets = pipeline.map((dest) => {
15598
+ target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
15599
+ options.pipelines = [pipeline.map((dest) => {
15457
15600
  return {
15458
15601
  ...dest,
15459
15602
  target: fixTarget(dest.target)
15460
15603
  };
15461
- });
15604
+ })];
15462
15605
  }
15463
15606
  if (levels) {
15464
15607
  options.levels = levels;
@@ -15467,7 +15610,8 @@ var require_transport = __commonJS({
15467
15610
  options.dedupe = dedupe;
15468
15611
  }
15469
15612
  options.pinoWillSendConfig = true;
15470
- return buildStream(fixTarget(target), options, worker);
15613
+ const name = targets || pipeline ? "pino.transport" : target;
15614
+ return buildStream(fixTarget(target), options, worker, sync, name);
15471
15615
  function fixTarget(origin) {
15472
15616
  origin = bundlerOverrides[origin] || origin;
15473
15617
  if (isAbsolute(origin) || origin.indexOf("file://") === 0) {
@@ -15500,6 +15644,7 @@ var require_transport = __commonJS({
15500
15644
  var require_tools = __commonJS({
15501
15645
  "node_modules/pino/lib/tools.js"(exports, module) {
15502
15646
  "use strict";
15647
+ var diagChan = __require("diagnostics_channel");
15503
15648
  var format2 = require_quick_format_unescaped();
15504
15649
  var { mapHttpRequest, mapHttpResponse } = require_pino_std_serializers();
15505
15650
  var SonicBoom = require_sonic_boom();
@@ -15524,6 +15669,9 @@ var require_tools = __commonJS({
15524
15669
  } = require_symbols();
15525
15670
  var { isMainThread } = __require("worker_threads");
15526
15671
  var transport = require_transport();
15672
+ var [nodeMajor] = process.versions.node.split(".").map((v) => Number(v));
15673
+ var asJsonChan = diagChan.tracingChannel("pino_asJson");
15674
+ var asString = nodeMajor >= 25 ? (str) => JSON.stringify(str) : _asString;
15527
15675
  function noop() {
15528
15676
  }
15529
15677
  function genLog(level, hook) {
@@ -15561,7 +15709,7 @@ var require_tools = __commonJS({
15561
15709
  }
15562
15710
  }
15563
15711
  }
15564
- function asString(str) {
15712
+ function _asString(str) {
15565
15713
  let result = "";
15566
15714
  let last = 0;
15567
15715
  let found = false;
@@ -15586,6 +15734,13 @@ var require_tools = __commonJS({
15586
15734
  return point < 32 ? JSON.stringify(str) : '"' + result + '"';
15587
15735
  }
15588
15736
  function asJson(obj, msg, num, time) {
15737
+ if (asJsonChan.hasSubscribers === false) {
15738
+ return _asJson.call(this, obj, msg, num, time);
15739
+ }
15740
+ const store = { instance: this, arguments };
15741
+ return asJsonChan.traceSync(_asJson, store, this, obj, msg, num, time);
15742
+ }
15743
+ function _asJson(obj, msg, num, time) {
15589
15744
  const stringify2 = this[stringifySym];
15590
15745
  const stringifySafe = this[stringifySafeSym];
15591
15746
  const stringifiers = this[stringifiersSym];
@@ -15678,7 +15833,7 @@ var require_tools = __commonJS({
15678
15833
  bindings = formatter(bindings);
15679
15834
  for (const key in bindings) {
15680
15835
  value = bindings[key];
15681
- const valid = key !== "level" && key !== "serializers" && key !== "formatters" && key !== "customLevels" && bindings.hasOwnProperty(key) && value !== void 0;
15836
+ const valid = (key.length < 5 || key !== "level" && key !== "serializers" && key !== "formatters" && key !== "customLevels") && bindings.hasOwnProperty(key) && value !== void 0;
15682
15837
  if (valid === true) {
15683
15838
  value = serializers[key] ? serializers[key](value) : value;
15684
15839
  value = (stringifiers[key] || wildcardStringifier || stringify2)(value, stringifySafe);
@@ -15691,11 +15846,10 @@ var require_tools = __commonJS({
15691
15846
  function hasBeenTampered(stream) {
15692
15847
  return stream.write !== stream.constructor.prototype.write;
15693
15848
  }
15694
- var hasNodeCodeCoverage = process.env.NODE_V8_COVERAGE || process.env.V8_COVERAGE;
15695
15849
  function buildSafeSonicBoom(opts) {
15696
15850
  const stream = new SonicBoom(opts);
15697
15851
  stream.on("error", filterBrokenPipe);
15698
- if (!hasNodeCodeCoverage && !opts.sync && isMainThread) {
15852
+ if (!opts.sync && isMainThread) {
15699
15853
  onExit.register(stream, autoEnd);
15700
15854
  stream.on("close", function() {
15701
15855
  onExit.unregister(stream);
@@ -16035,7 +16189,7 @@ var require_levels2 = __commonJS({
16035
16189
  var require_meta = __commonJS({
16036
16190
  "node_modules/pino/lib/meta.js"(exports, module) {
16037
16191
  "use strict";
16038
- module.exports = { version: "8.21.0" };
16192
+ module.exports = { version: "10.3.1" };
16039
16193
  }
16040
16194
  });
16041
16195
 
@@ -16050,7 +16204,6 @@ var require_proto = __commonJS({
16050
16204
  setLevelSym,
16051
16205
  getLevelSym,
16052
16206
  chindingsSym,
16053
- parsedChindingsSym,
16054
16207
  mixinSym,
16055
16208
  asJsonSym,
16056
16209
  writeSym,
@@ -16068,7 +16221,8 @@ var require_proto = __commonJS({
16068
16221
  stringifySym,
16069
16222
  formatOptsSym,
16070
16223
  stringifiersSym,
16071
- msgPrefixSym
16224
+ msgPrefixSym,
16225
+ hooksSym
16072
16226
  } = require_symbols();
16073
16227
  var {
16074
16228
  getLevel,
@@ -16083,7 +16237,8 @@ var require_proto = __commonJS({
16083
16237
  asChindings,
16084
16238
  asJson,
16085
16239
  buildFormatters,
16086
- stringify
16240
+ stringify,
16241
+ noop
16087
16242
  } = require_tools();
16088
16243
  var {
16089
16244
  version
@@ -16111,6 +16266,12 @@ var require_proto = __commonJS({
16111
16266
  set levelVal(n) {
16112
16267
  throw Error("levelVal is read-only");
16113
16268
  },
16269
+ get msgPrefix() {
16270
+ return this[msgPrefixSym];
16271
+ },
16272
+ get [Symbol.toStringTag]() {
16273
+ return "Pino";
16274
+ },
16114
16275
  [lsCacheSym]: initialLsCache,
16115
16276
  [writeSym]: write,
16116
16277
  [asJsonSym]: asJson,
@@ -16126,10 +16287,23 @@ var require_proto = __commonJS({
16126
16287
  if (!bindings2) {
16127
16288
  throw Error("missing bindings for child Pino");
16128
16289
  }
16129
- options = options || {};
16130
16290
  const serializers = this[serializersSym];
16131
16291
  const formatters = this[formattersSym];
16132
16292
  const instance = Object.create(this);
16293
+ if (options == null) {
16294
+ if (instance[formattersSym].bindings !== resetChildingsFormatter) {
16295
+ instance[formattersSym] = buildFormatters(
16296
+ formatters.level,
16297
+ resetChildingsFormatter,
16298
+ formatters.log
16299
+ );
16300
+ }
16301
+ instance[chindingsSym] = asChindings(instance, bindings2);
16302
+ if (this.onChild !== noop) {
16303
+ this.onChild(instance);
16304
+ }
16305
+ return instance;
16306
+ }
16133
16307
  if (options.hasOwnProperty("serializers") === true) {
16134
16308
  instance[serializersSym] = /* @__PURE__ */ Object.create(null);
16135
16309
  for (const k in serializers) {
@@ -16180,8 +16354,10 @@ var require_proto = __commonJS({
16180
16354
  instance[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
16181
16355
  }
16182
16356
  instance[chindingsSym] = asChindings(instance, bindings2);
16183
- const childLevel = options.level || this.level;
16184
- instance[setLevelSym](childLevel);
16357
+ if (options.level !== void 0 && options.level !== this.level || options.hasOwnProperty("customLevels")) {
16358
+ const childLevel = options.level || this.level;
16359
+ instance[setLevelSym](childLevel);
16360
+ }
16185
16361
  this.onChild(instance);
16186
16362
  return instance;
16187
16363
  }
@@ -16196,7 +16372,6 @@ var require_proto = __commonJS({
16196
16372
  function setBindings(newBindings) {
16197
16373
  const chindings = asChindings(this, newBindings);
16198
16374
  this[chindingsSym] = chindings;
16199
- delete this[parsedChindingsSym];
16200
16375
  }
16201
16376
  function defaultMixinMergeStrategy(mergeObject, mixinObject) {
16202
16377
  return Object.assign(mixinObject, mergeObject);
@@ -16208,6 +16383,7 @@ var require_proto = __commonJS({
16208
16383
  const messageKey = this[messageKeySym];
16209
16384
  const mixinMergeStrategy = this[mixinMergeStrategySym] || defaultMixinMergeStrategy;
16210
16385
  let obj;
16386
+ const streamWriteHook = this[hooksSym].streamWrite;
16211
16387
  if (_obj === void 0 || _obj === null) {
16212
16388
  obj = {};
16213
16389
  } else if (_obj instanceof Error) {
@@ -16233,9 +16409,7 @@ var require_proto = __commonJS({
16233
16409
  stream.lastTime = t.slice(this[timeSliceIndexSym]);
16234
16410
  stream.lastLogger = this;
16235
16411
  }
16236
- stream.write(s);
16237
- }
16238
- function noop() {
16412
+ stream.write(streamWriteHook ? streamWriteHook(s) : s);
16239
16413
  }
16240
16414
  function flush(cb) {
16241
16415
  if (cb != null && typeof cb !== "function") {
@@ -16257,7 +16431,6 @@ var require_multistream = __commonJS({
16257
16431
  var { DEFAULT_LEVELS } = require_constants();
16258
16432
  var DEFAULT_INFO_LEVEL = DEFAULT_LEVELS.info;
16259
16433
  function multistream(streamsArray, opts) {
16260
- let counter = 0;
16261
16434
  streamsArray = streamsArray || [];
16262
16435
  opts = opts || { dedupe: false };
16263
16436
  const streamLevels = Object.create(DEFAULT_LEVELS);
@@ -16270,10 +16443,12 @@ var require_multistream = __commonJS({
16270
16443
  const res = {
16271
16444
  write,
16272
16445
  add,
16446
+ remove,
16273
16447
  emit,
16274
16448
  flushSync,
16275
16449
  end,
16276
16450
  minLevel: 0,
16451
+ lastId: 0,
16277
16452
  streams: [],
16278
16453
  clone,
16279
16454
  [metadata]: true,
@@ -16354,13 +16529,23 @@ var require_multistream = __commonJS({
16354
16529
  stream: stream_,
16355
16530
  level,
16356
16531
  levelVal: void 0,
16357
- id: counter++
16532
+ id: ++res.lastId
16358
16533
  };
16359
16534
  streams.unshift(dest_);
16360
16535
  streams.sort(compareByLevel);
16361
16536
  this.minLevel = streams[0].level;
16362
16537
  return res;
16363
16538
  }
16539
+ function remove(id) {
16540
+ const { streams } = this;
16541
+ const index = streams.findIndex((s) => s.id === id);
16542
+ if (index >= 0) {
16543
+ streams.splice(index, 1);
16544
+ streams.sort(compareByLevel);
16545
+ this.minLevel = streams.length > 0 ? streams[0].level : -1;
16546
+ }
16547
+ return res;
16548
+ }
16364
16549
  function end() {
16365
16550
  for (const { stream } of this.streams) {
16366
16551
  if (typeof stream.flushSync === "function") {
@@ -16380,6 +16565,7 @@ var require_multistream = __commonJS({
16380
16565
  return {
16381
16566
  write,
16382
16567
  add,
16568
+ remove,
16383
16569
  minLevel: level,
16384
16570
  streams,
16385
16571
  clone,
@@ -16479,7 +16665,8 @@ var require_pino = __commonJS({
16479
16665
  }
16480
16666
  }),
16481
16667
  hooks: {
16482
- logMethod: void 0
16668
+ logMethod: void 0,
16669
+ streamWrite: void 0
16483
16670
  },
16484
16671
  timestamp: epochTime,
16485
16672
  name: void 0,
@@ -16494,6 +16681,7 @@ var require_pino = __commonJS({
16494
16681
  function pino(...args) {
16495
16682
  const instance = {};
16496
16683
  const { opts, stream } = normalize(instance, caller(), ...args);
16684
+ if (opts.level && typeof opts.level === "string" && DEFAULT_LEVELS[opts.level.toLowerCase()] !== void 0) opts.level = opts.level.toLowerCase();
16497
16685
  const {
16498
16686
  redact,
16499
16687
  crlf,