lakutata
Version:
An IoC-based universal application framework.
2,129 lines (1,845 loc) • 375 kB
JavaScript
import { _ as e, a as t } from "./Package.1.mjs";
import { Component as n } from "../src/lib/core/Component.mjs";
import { Singleton as r } from "../src/decorators/di/Lifetime.mjs";
import { Configurable as i } from "../src/decorators/di/Configurable.mjs";
import { D as s } from "./Package.2.mjs";
import { g as o, c as a, a as l } from "./Package.5.mjs";
import "./Package.8.mjs";
import "./Package.10.mjs";
import u from "fs";
import f from "events";
import c from "util";
import d from "path";
import h from "worker_threads";
import { r as p } from "./Package.132.mjs";
import "./Package.11.mjs";
import "./Package.14.mjs";
import "./Package.18.mjs";
import y from "url";
import g from "buffer";
import b from "assert";
import m from "module";
import w from "os";
import { GetBasicInfo as _ } from "../src/lib/base/internal/BasicInfo.mjs";
import v from "tty";
import S from "stream";
import E from "string_decoder";
import { As as A } from "../src/lib/helpers/As.mjs";
import { Stream as O } from "node:stream";
// -- Shims --
import cjsUrl from 'node:url';
import cjsPath from 'node:path';
import cjsModule from 'node:module';
const __filename = cjsUrl.fileURLToPath(import.meta.url);
const __dirname = cjsPath.dirname(__filename);
const require = cjsModule.createRequire(import.meta.url);
var R = {
exports: {}
};
"use strict";
const L = e => e && typeof e.message === "string";
const k = e => {
if (!e) return;
const t = e.cause;
if (typeof t === "function") {
const t = e.cause();
return L(t) ? t : undefined;
} else {
return L(t) ? t : undefined;
}
};
const x = (e, t) => {
if (!L(e)) return "";
const n = e.stack || "";
if (t.has(e)) {
return n + "\ncauses have become circular...";
}
const r = k(e);
if (r) {
t.add(e);
return n + "\ncaused by: " + x(r, t);
} else {
return n;
}
};
const T = e => x(e, new Set);
const j = (e, t, n) => {
if (!L(e)) return "";
const r = n ? "" : e.message || "";
if (t.has(e)) {
return r + ": ...";
}
const i = k(e);
if (i) {
t.add(e);
const n = typeof e.cause === "function";
return r + (n ? "" : ": ") + j(i, t, n);
} else {
return r;
}
};
const N = e => j(e, new Set);
var P = {
isErrorLike: L,
getErrorCause: k,
stackWithCauses: T,
messageWithCauses: N
};
const D = o(P);
"use strict";
const M = Symbol("circular-ref-tag");
const B = Symbol("pino-raw-err-ref");
const I = Object.create({}, {
type: {
enumerable: true,
writable: true,
value: undefined
},
message: {
enumerable: true,
writable: true,
value: undefined
},
stack: {
enumerable: true,
writable: true,
value: undefined
},
aggregateErrors: {
enumerable: true,
writable: true,
value: undefined
},
raw: {
enumerable: false,
get: function() {
return this[B];
},
set: function(e) {
this[B] = e;
}
}
});
Object.defineProperty(I, B, {
writable: true,
value: {}
});
var C = {
pinoErrProto: I,
pinoErrorSymbols: {
seen: M,
rawSymbol: B
}
};
const $ = o(C);
"use strict";
var W = Y;
const {messageWithCauses: F, stackWithCauses: U, isErrorLike: G} = P;
const {pinoErrProto: K, pinoErrorSymbols: V} = C;
const {seen: z} = V;
const {toString: H} = Object.prototype;
function Y(e) {
if (!G(e)) {
return e;
}
e[z] = undefined;
const t = Object.create(K);
t.type = H.call(e.constructor) === "[object Function]" ? e.constructor.name : e.name;
t.message = F(e);
t.stack = U(e);
if (Array.isArray(e.errors)) {
t.aggregateErrors = e.errors.map((e => Y(e)));
}
for (const n in e) {
if (t[n] === undefined) {
const r = e[n];
if (G(r)) {
if (n !== "cause" && !Object.prototype.hasOwnProperty.call(r, z)) {
t[n] = Y(r);
}
} else {
t[n] = r;
}
}
}
delete e[z];
t.raw = e;
return t;
}
const J = o(W);
"use strict";
var q = ne;
const {isErrorLike: X} = P;
const {pinoErrProto: Z, pinoErrorSymbols: Q} = C;
const {seen: ee} = Q;
const {toString: te} = Object.prototype;
function ne(e) {
if (!X(e)) {
return e;
}
e[ee] = undefined;
const t = Object.create(Z);
t.type = te.call(e.constructor) === "[object Function]" ? e.constructor.name : e.name;
t.message = e.message;
t.stack = e.stack;
if (Array.isArray(e.errors)) {
t.aggregateErrors = e.errors.map((e => ne(e)));
}
if (X(e.cause) && !Object.prototype.hasOwnProperty.call(e.cause, ee)) {
t.cause = ne(e.cause);
}
for (const n in e) {
if (t[n] === undefined) {
const r = e[n];
if (X(r)) {
if (!Object.prototype.hasOwnProperty.call(r, ee)) {
t[n] = ne(r);
}
} else {
t[n] = r;
}
}
}
delete e[ee];
t.raw = e;
return t;
}
const re = o(q);
"use strict";
var ie = {
mapHttpRequest: le,
reqSerializer: ae
};
const se = Symbol("pino-raw-req-ref");
const oe = Object.create({}, {
id: {
enumerable: true,
writable: true,
value: ""
},
method: {
enumerable: true,
writable: true,
value: ""
},
url: {
enumerable: true,
writable: true,
value: ""
},
query: {
enumerable: true,
writable: true,
value: ""
},
params: {
enumerable: true,
writable: true,
value: ""
},
headers: {
enumerable: true,
writable: true,
value: {}
},
remoteAddress: {
enumerable: true,
writable: true,
value: ""
},
remotePort: {
enumerable: true,
writable: true,
value: ""
},
raw: {
enumerable: false,
get: function() {
return this[se];
},
set: function(e) {
this[se] = e;
}
}
});
Object.defineProperty(oe, se, {
writable: true,
value: {}
});
function ae(e) {
const t = e.info || e.socket;
const n = Object.create(oe);
n.id = typeof e.id === "function" ? e.id() : e.id || (e.info ? e.info.id : undefined);
n.method = e.method;
if (e.originalUrl) {
n.url = e.originalUrl;
} else {
const t = e.path;
n.url = typeof t === "string" ? t : e.url ? e.url.path || e.url : undefined;
}
if (e.query) {
n.query = e.query;
}
if (e.params) {
n.params = e.params;
}
n.headers = e.headers;
n.remoteAddress = t && t.remoteAddress;
n.remotePort = t && t.remotePort;
n.raw = e.raw || e;
return n;
}
function le(e) {
return {
req: ae(e)
};
}
const ue = o(ie);
"use strict";
var fe = {
mapHttpResponse: pe,
resSerializer: he
};
const ce = Symbol("pino-raw-res-ref");
const de = Object.create({}, {
statusCode: {
enumerable: true,
writable: true,
value: 0
},
headers: {
enumerable: true,
writable: true,
value: ""
},
raw: {
enumerable: false,
get: function() {
return this[ce];
},
set: function(e) {
this[ce] = e;
}
}
});
Object.defineProperty(de, ce, {
writable: true,
value: {}
});
function he(e) {
const t = Object.create(de);
t.statusCode = e.headersSent ? e.statusCode : null;
t.headers = e.getHeaders ? e.getHeaders() : e._headers;
t.raw = e;
return t;
}
function pe(e) {
return {
res: he(e)
};
}
const ye = o(fe);
"use strict";
const ge = W;
const be = q;
const me = ie;
const we = fe;
var _e = {
err: ge,
errWithCause: be,
mapHttpRequest: me.mapHttpRequest,
mapHttpResponse: we.mapHttpResponse,
req: me.reqSerializer,
res: we.resSerializer,
wrapErrorSerializer: function e(t) {
if (t === ge) return t;
return function e(n) {
return t(ge(n));
};
},
wrapRequestSerializer: function e(t) {
if (t === me.reqSerializer) return t;
return function e(n) {
return t(me.reqSerializer(n));
};
},
wrapResponseSerializer: function e(t) {
if (t === we.resSerializer) return t;
return function e(n) {
return t(we.resSerializer(n));
};
}
};
const ve = o(_e);
"use strict";
function Se(e, t) {
return t;
}
var Ee = function e() {
const t = Error.prepareStackTrace;
Error.prepareStackTrace = Se;
const n = (new Error).stack;
Error.prepareStackTrace = t;
if (!Array.isArray(n)) {
return undefined;
}
const r = n.slice(2);
const i = [];
for (const e of r) {
if (!e) {
continue;
}
i.push(e.getFileName());
}
return i;
};
const Ae = o(Ee);
"use strict";
var Oe = Re;
function Re(e = {}) {
const {ERR_PATHS_MUST_BE_STRINGS: t = () => "fast-redact - Paths must be (non-empty) strings", ERR_INVALID_PATH: n = e => `fast-redact – Invalid path (${e})`} = e;
return function e({paths: r}) {
r.forEach((e => {
if (typeof e !== "string") {
throw Error(t());
}
try {
if (/〇/.test(e)) throw Error();
const t = (e[0] === "[" ? "" : ".") + e.replace(/^\*/, "〇").replace(/\.\*/g, ".〇").replace(/\[\*\]/g, "[〇]");
if (/\n|\r|;/.test(t)) throw Error();
if (/\/\*/.test(t)) throw Error();
Function(`\n 'use strict'\n const o = new Proxy({}, { get: () => o, set: () => { throw Error() } });\n const 〇 = null;\n o${t}\n if ([o${t}].length !== 1) throw Error()`)();
} catch (t) {
throw Error(n(e));
}
}));
};
}
const Le = o(Oe);
"use strict";
var ke = /[^.[\]]+|\[((?:.)*?)\]/g;
const xe = o(ke);
"use strict";
const Te = ke;
var je = Ne;
function Ne({paths: e}) {
const t = [];
var n = 0;
const r = e.reduce((function(e, r, i) {
var s = r.match(Te).map((e => e.replace(/'|"|`/g, "")));
const o = r[0] === "[";
s = s.map((e => {
if (e[0] === "[") return e.substr(1, e.length - 2); else return e;
}));
const a = s.indexOf("*");
if (a > -1) {
const e = s.slice(0, a);
const r = e.join(".");
const i = s.slice(a + 1, s.length);
const o = i.length > 0;
n++;
t.push({
before: e,
beforeStr: r,
after: i,
nested: o
});
} else {
e[r] = {
path: s,
val: undefined,
precensored: false,
circle: "",
escPath: JSON.stringify(r),
leadingBracket: o
};
}
return e;
}), {});
return {
wildcards: t,
wcLen: n,
secret: r
};
}
const Pe = o(je);
"use strict";
const De = ke;
var Me = Be;
function Be({secret: e, serialize: t, wcLen: n, strict: r, isCensorFct: i, censorFctTakesPath: s}, o) {
const a = Function("o", `\n if (typeof o !== 'object' || o == null) {\n ${We(r, t)}\n }\n const { censor, secret } = this\n const originalSecret = {}\n const secretKeys = Object.keys(secret)\n for (var i = 0; i < secretKeys.length; i++) {\n originalSecret[secretKeys[i]] = secret[secretKeys[i]]\n }\n\n ${Ie(e, i, s)}\n this.compileRestore()\n ${Ce(n > 0, i, s)}\n this.secret = originalSecret\n ${$e(t)}\n `).bind(o);
a.state = o;
if (t === false) {
a.restore = e => o.restore(e);
}
return a;
}
function Ie(e, t, n) {
return Object.keys(e).map((r => {
const {escPath: i, leadingBracket: s, path: o} = e[r];
const a = s ? 1 : 0;
const l = s ? "" : ".";
const u = [];
var f;
while ((f = De.exec(r)) !== null) {
const [, e] = f;
const {index: t, input: n} = f;
if (t > a) u.push(n.substring(0, t - (e ? 0 : 1)));
}
var c = u.map((e => `o${l}${e}`)).join(" && ");
if (c.length === 0) c += `o${l}${r} != null`; else c += ` && o${l}${r} != null`;
const d = `\n switch (true) {\n ${u.reverse().map((e => `\n case o${l}${e} === censor:\n secret[${i}].circle = ${JSON.stringify(e)}\n break\n `)).join("\n")}\n }\n `;
const h = n ? `val, ${JSON.stringify(o)}` : `val`;
return `\n if (${c}) {\n const val = o${l}${r}\n if (val === censor) {\n secret[${i}].precensored = true\n } else {\n secret[${i}].val = val\n o${l}${r} = ${t ? `censor(${h})` : "censor"}\n ${d}\n }\n }\n `;
})).join("\n");
}
function Ce(e, t, n) {
return e === true ? `\n {\n const { wildcards, wcLen, groupRedact, nestedRedact } = this\n for (var i = 0; i < wcLen; i++) {\n const { before, beforeStr, after, nested } = wildcards[i]\n if (nested === true) {\n secret[beforeStr] = secret[beforeStr] || []\n nestedRedact(secret[beforeStr], o, before, after, censor, ${t}, ${n})\n } else secret[beforeStr] = groupRedact(o, before, censor, ${t}, ${n})\n }\n }\n ` : "";
}
function $e(e) {
return e === false ? `return o` : `\n var s = this.serialize(o)\n this.restore(o)\n return s\n `;
}
function We(e, t) {
return e === true ? `throw Error('fast-redact: primitives cannot be redacted')` : t === false ? `return o` : `return this.serialize(o)`;
}
const Fe = o(Me);
"use strict";
var Ue = {
groupRedact: Ke,
groupRestore: Ge,
nestedRedact: ze,
nestedRestore: Ve
};
function Ge({keys: e, values: t, target: n}) {
if (n == null || typeof n === "string") return;
const r = e.length;
for (var i = 0; i < r; i++) {
const r = e[i];
n[r] = t[i];
}
}
function Ke(e, t, n, r, i) {
const s = Je(e, t);
if (s == null || typeof s === "string") return {
keys: null,
values: null,
target: s,
flat: true
};
const o = Object.keys(s);
const a = o.length;
const l = t.length;
const u = i ? [ ...t ] : undefined;
const f = new Array(a);
for (var c = 0; c < a; c++) {
const e = o[c];
f[c] = s[e];
if (i) {
u[l] = e;
s[e] = n(s[e], u);
} else if (r) {
s[e] = n(s[e]);
} else {
s[e] = n;
}
}
return {
keys: o,
values: f,
target: s,
flat: true
};
}
function Ve(e) {
for (let t = 0; t < e.length; t++) {
const {target: n, path: r, value: i} = e[t];
let s = n;
for (let e = r.length - 1; e > 0; e--) {
s = s[r[e]];
}
s[r[0]] = i;
}
}
function ze(e, t, n, r, i, s, o) {
const a = Je(t, n);
if (a == null) return;
const l = Object.keys(a);
const u = l.length;
for (var f = 0; f < u; f++) {
const t = l[f];
Ye(e, a, t, n, r, i, s, o);
}
return e;
}
function He(e, t) {
return e !== undefined && e !== null ? "hasOwn" in Object ? Object.hasOwn(e, t) : Object.prototype.hasOwnProperty.call(e, t) : false;
}
function Ye(e, t, n, r, i, s, o, a) {
const l = i.length;
const u = l - 1;
const f = n;
var c = -1;
var d;
var h;
var p;
var y = null;
var g = null;
var b;
var m;
var w = false;
var _ = 0;
var v = 0;
var S = Xe();
p = d = t[n];
if (typeof d !== "object") return;
while (d != null && ++c < l) {
v += 1;
n = i[c];
y = p;
if (n !== "*" && !g && !(typeof d === "object" && n in d)) {
break;
}
if (n === "*") {
if (g === "*") {
w = true;
}
g = n;
if (c !== u) {
continue;
}
}
if (g) {
const l = Object.keys(d);
for (var E = 0; E < l.length; E++) {
const y = l[E];
m = d[y];
b = n === "*";
if (w) {
S = Ze(S, y, v);
_ = c;
p = qe(m, _ - 1, n, r, i, s, o, a, f, d, h, p, b, y, c, u, S, e, t[f], v + 1);
} else {
if (b || typeof m === "object" && m !== null && n in m) {
if (b) {
p = m;
} else {
p = m[n];
}
h = c !== u ? p : o ? a ? s(p, [ ...r, f, ...i ]) : s(p) : s;
if (b) {
const n = Qe(Ze(S, y, v), p, t[f]);
e.push(n);
d[y] = h;
} else {
if (m[n] === h) {} else if (h === undefined && s !== undefined || He(m, n) && h === p) {
S = Ze(S, y, v);
} else {
S = Ze(S, y, v);
const r = Qe(Ze(S, n, v + 1), p, t[f]);
e.push(r);
m[n] = h;
}
}
}
}
}
g = null;
} else {
p = d[n];
S = Ze(S, n, v);
h = c !== u ? p : o ? a ? s(p, [ ...r, f, ...i ]) : s(p) : s;
if (He(d, n) && h === p || h === undefined && s !== undefined) {} else {
const r = Qe(S, p, t[f]);
e.push(r);
d[n] = h;
}
d = d[n];
}
if (typeof d !== "object") break;
if (p === y || typeof p === "undefined") {}
}
}
function Je(e, t) {
var n = -1;
var r = t.length;
var i = e;
while (i != null && ++n < r) {
i = i[t[n]];
}
return i;
}
function qe(e, t, n, r, i, s, o, a, l, u, f, c, d, h, p, y, g, b, m, w) {
if (t === 0) {
if (d || typeof e === "object" && e !== null && n in e) {
if (d) {
c = e;
} else {
c = e[n];
}
f = p !== y ? c : o ? a ? s(c, [ ...r, l, ...i ]) : s(c) : s;
if (d) {
const e = Qe(g, c, m);
b.push(e);
u[h] = f;
} else {
if (e[n] === f) {} else if (f === undefined && s !== undefined || He(e, n) && f === c) {} else {
const t = Qe(Ze(g, n, w + 1), c, m);
b.push(t);
e[n] = f;
}
}
}
}
for (const _ in e) {
if (typeof e[_] === "object") {
g = Ze(g, _, w);
qe(e[_], t - 1, n, r, i, s, o, a, l, u, f, c, d, h, p, y, g, b, m, w + 1);
}
}
}
function Xe() {
return {
parent: null,
key: null,
children: [],
depth: 0
};
}
function Ze(e, t, n) {
if (e.depth === n) {
return Ze(e.parent, t, n);
}
var r = {
parent: e,
key: t,
depth: n,
children: []
};
e.children.push(r);
return r;
}
function Qe(e, t, n) {
let r = e;
const i = [];
do {
i.push(r.key);
r = r.parent;
} while (r.parent != null);
return {
path: i,
value: t,
target: n
};
}
const et = o(Ue);
"use strict";
const {groupRestore: tt, nestedRestore: nt} = Ue;
var rt = it;
function it() {
return function e() {
if (this.restore) {
this.restore.state.secret = this.secret;
return;
}
const {secret: t, wcLen: n} = this;
const r = Object.keys(t);
const i = st(t, r);
const s = n > 0;
const o = s ? {
secret: t,
groupRestore: tt,
nestedRestore: nt
} : {
secret: t
};
this.restore = Function("o", ot(i, r, s)).bind(o);
this.restore.state = o;
};
}
function st(e, t) {
return t.map((t => {
const {circle: n, escPath: r, leadingBracket: i} = e[t];
const s = i ? "" : ".";
const o = n ? `o.${n} = secret[${r}].val` : `o${s}${t} = secret[${r}].val`;
const a = `secret[${r}].val = undefined`;
return `\n if (secret[${r}].val !== undefined) {\n try { ${o} } catch (e) {}\n ${a}\n }\n `;
})).join("");
}
function ot(e, t, n) {
const r = n === true ? `\n const keys = Object.keys(secret)\n const len = keys.length\n for (var i = len - 1; i >= ${t.length}; i--) {\n const k = keys[i]\n const o = secret[k]\n if (o) {\n if (o.flat === true) this.groupRestore(o)\n else this.nestedRestore(o)\n secret[k] = null\n }\n }\n ` : "";
return `\n const secret = this.secret\n ${r}\n ${e}\n return o\n `;
}
const at = o(rt);
"use strict";
var lt = ut;
function ut(e) {
const {secret: t, censor: n, compileRestore: r, serialize: i, groupRedact: s, nestedRedact: o, wildcards: a, wcLen: l} = e;
const u = [ {
secret: t,
censor: n,
compileRestore: r
} ];
if (i !== false) u.push({
serialize: i
});
if (l > 0) u.push({
groupRedact: s,
nestedRedact: o,
wildcards: a,
wcLen: l
});
return Object.assign(...u);
}
const ft = o(lt);
"use strict";
const ct = Oe;
const dt = je;
const ht = Me;
const pt = rt;
const {groupRedact: yt, nestedRedact: gt} = Ue;
const bt = lt;
const mt = ke;
const wt = ct();
const _t = e => e;
_t.restore = _t;
const vt = "[REDACTED]";
Et.rx = mt;
Et.validator = ct;
var St = Et;
function Et(e = {}) {
const t = Array.from(new Set(e.paths || []));
const n = "serialize" in e ? e.serialize === false ? e.serialize : typeof e.serialize === "function" ? e.serialize : JSON.stringify : JSON.stringify;
const r = e.remove;
if (r === true && n !== JSON.stringify) {
throw Error("fast-redact – remove option may only be set when serializer is JSON.stringify");
}
const i = r === true ? undefined : "censor" in e ? e.censor : vt;
const s = typeof i === "function";
const o = s && i.length > 1;
if (t.length === 0) return n || _t;
wt({
paths: t,
serialize: n,
censor: i
});
const {wildcards: a, wcLen: l, secret: u} = dt({
paths: t,
censor: i
});
const f = pt();
const c = "strict" in e ? e.strict : true;
return ht({
secret: u,
wcLen: l,
serialize: n,
strict: c,
isCensorFct: s,
censorFctTakesPath: o
}, bt({
secret: u,
censor: i,
compileRestore: f,
serialize: n,
groupRedact: yt,
nestedRedact: gt,
wildcards: a,
wcLen: l
}));
}
const At = o(St);
"use strict";
const Ot = Symbol("pino.setLevel");
const Rt = Symbol("pino.getLevel");
const Lt = Symbol("pino.levelVal");
const kt = Symbol("pino.levelComp");
const xt = Symbol("pino.useLevelLabels");
const Tt = Symbol("pino.useOnlyCustomLevels");
const jt = Symbol("pino.mixin");
const Nt = Symbol("pino.lsCache");
const Pt = Symbol("pino.chindings");
const Dt = Symbol("pino.asJson");
const Mt = Symbol("pino.write");
const Bt = Symbol("pino.redactFmt");
const It = Symbol("pino.time");
const Ct = Symbol("pino.timeSliceIndex");
const $t = Symbol("pino.stream");
const Wt = Symbol("pino.stringify");
const Ft = Symbol("pino.stringifySafe");
const Ut = Symbol("pino.stringifiers");
const Gt = Symbol("pino.end");
const Kt = Symbol("pino.formatOpts");
const Vt = Symbol("pino.messageKey");
const zt = Symbol("pino.errorKey");
const Ht = Symbol("pino.nestedKey");
const Yt = Symbol("pino.nestedKeyStr");
const Jt = Symbol("pino.mixinMergeStrategy");
const qt = Symbol("pino.msgPrefix");
const Xt = Symbol("pino.wildcardFirst");
const Zt = Symbol.for("pino.serializers");
const Qt = Symbol.for("pino.formatters");
const en = Symbol.for("pino.hooks");
const tn = Symbol.for("pino.metadata");
var nn = {
setLevelSym: Ot,
getLevelSym: Rt,
levelValSym: Lt,
levelCompSym: kt,
useLevelLabelsSym: xt,
mixinSym: jt,
lsCacheSym: Nt,
chindingsSym: Pt,
asJsonSym: Dt,
writeSym: Mt,
serializersSym: Zt,
redactFmtSym: Bt,
timeSym: It,
timeSliceIndexSym: Ct,
streamSym: $t,
stringifySym: Wt,
stringifySafeSym: Ft,
stringifiersSym: Ut,
endSym: Gt,
formatOptsSym: Kt,
messageKeySym: Vt,
errorKeySym: zt,
nestedKeySym: Ht,
wildcardFirstSym: Xt,
needsMetadataGsym: tn,
useOnlyCustomLevelsSym: Tt,
formattersSym: Qt,
hooksSym: en,
nestedKeyStrSym: Yt,
mixinMergeStrategySym: Jt,
msgPrefixSym: qt
};
const rn = o(nn);
"use strict";
const sn = St;
const {redactFmtSym: on, wildcardFirstSym: an} = nn;
const {rx: ln, validator: un} = sn;
const fn = un({
ERR_PATHS_MUST_BE_STRINGS: () => "pino – redacted paths must be strings",
ERR_INVALID_PATH: e => `pino – redact paths array contains an invalid path (${e})`
});
const cn = "[Redacted]";
const dn = false;
function hn(e, t) {
const {paths: n, censor: r} = pn(e);
const i = n.reduce(((e, t) => {
ln.lastIndex = 0;
const n = ln.exec(t);
const r = ln.exec(t);
let i = n[1] !== undefined ? n[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/, "$1") : n[0];
if (i === "*") {
i = an;
}
if (r === null) {
e[i] = null;
return e;
}
if (e[i] === null) {
return e;
}
const {index: s} = r;
const o = `${t.substr(s, t.length - 1)}`;
e[i] = e[i] || [];
if (i !== an && e[i].length === 0) {
e[i].push(...e[an] || []);
}
if (i === an) {
Object.keys(e).forEach((function(t) {
if (e[t]) {
e[t].push(o);
}
}));
}
e[i].push(o);
return e;
}), {});
const s = {
[on]: sn({
paths: n,
censor: r,
serialize: t,
strict: dn
})
};
const o = (...e) => typeof r === "function" ? t(r(...e)) : t(r);
return [ ...Object.keys(i), ...Object.getOwnPropertySymbols(i) ].reduce(((e, n) => {
if (i[n] === null) {
e[n] = e => o(e, [ n ]);
} else {
const s = typeof r === "function" ? (e, t) => r(e, [ n, ...t ]) : r;
e[n] = sn({
paths: i[n],
censor: s,
serialize: t,
strict: dn
});
}
return e;
}), s);
}
function pn(e) {
if (Array.isArray(e)) {
e = {
paths: e,
censor: cn
};
fn(e);
return e;
}
let {paths: t, censor: n = cn, remove: r} = e;
if (Array.isArray(t) === false) {
throw Error("pino – redact must contain an array of strings");
}
if (r === true) n = undefined;
fn({
paths: t,
censor: n
});
return {
paths: t,
censor: n
};
}
var yn = hn;
const gn = o(yn);
"use strict";
const bn = () => "";
const mn = () => `,"time":${Date.now()}`;
const wn = () => `,"time":${Math.round(Date.now() / 1e3)}`;
const _n = () => `,"time":"${new Date(Date.now()).toISOString()}"`;
var vn = {
nullTime: bn,
epochTime: mn,
unixTime: wn,
isoTime: _n
};
const Sn = o(vn);
"use strict";
function En(e) {
try {
return JSON.stringify(e);
} catch (e) {
return '"[Circular]"';
}
}
var An = On;
function On(e, t, n) {
var r = n && n.stringify || En;
var i = 1;
if (typeof e === "object" && e !== null) {
var s = t.length + i;
if (s === 1) return e;
var o = new Array(s);
o[0] = r(e);
for (var a = 1; a < s; a++) {
o[a] = r(t[a]);
}
return o.join(" ");
}
if (typeof e !== "string") {
return e;
}
var l = t.length;
if (l === 0) return e;
var u = "";
var f = 1 - i;
var c = -1;
var d = e && e.length || 0;
for (var h = 0; h < d; ) {
if (e.charCodeAt(h) === 37 && h + 1 < d) {
c = c > -1 ? c : 0;
switch (e.charCodeAt(h + 1)) {
case 100:
case 102:
if (f >= l) break;
if (t[f] == null) break;
if (c < h) u += e.slice(c, h);
u += Number(t[f]);
c = h + 2;
h++;
break;
case 105:
if (f >= l) break;
if (t[f] == null) break;
if (c < h) u += e.slice(c, h);
u += Math.floor(Number(t[f]));
c = h + 2;
h++;
break;
case 79:
case 111:
case 106:
if (f >= l) break;
if (t[f] === undefined) break;
if (c < h) u += e.slice(c, h);
var p = typeof t[f];
if (p === "string") {
u += "'" + t[f] + "'";
c = h + 2;
h++;
break;
}
if (p === "function") {
u += t[f].name || "<anonymous>";
c = h + 2;
h++;
break;
}
u += r(t[f]);
c = h + 2;
h++;
break;
case 115:
if (f >= l) break;
if (c < h) u += e.slice(c, h);
u += String(t[f]);
c = h + 2;
h++;
break;
case 37:
if (c < h) u += e.slice(c, h);
u += "%";
c = h + 2;
h++;
f--;
break;
}
++f;
}
++h;
}
if (c === -1) return e; else if (c < d) {
u += e.slice(c);
}
return u;
}
const Rn = o(An);
var Ln = {
exports: {}
};
var kn = Ln.exports;
var xn;
function Tn() {
if (xn) return Ln.exports;
xn = 1;
"use strict";
if (typeof SharedArrayBuffer !== "undefined" && typeof Atomics !== "undefined") {
const e = new Int32Array(new SharedArrayBuffer(4));
function t(t) {
const n = t > 0 && t < Infinity;
if (n === false) {
if (typeof t !== "number" && typeof t !== "bigint") {
throw TypeError("sleep: ms must be a number");
}
throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");
}
Atomics.wait(e, 0, 0, Number(t));
}
Ln.exports = t;
} else {
function n(e) {
const t = e > 0 && e < Infinity;
if (t === false) {
if (typeof e !== "number" && typeof e !== "bigint") {
throw TypeError("sleep: ms must be a number");
}
throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");
}
const n = Date.now() + Number(e);
while (n > Date.now()) {}
}
Ln.exports = n;
}
return Ln.exports;
}
"use strict";
const jn = u;
const Nn = f;
const Pn = c.inherits;
const Dn = d;
const Mn = Tn();
const Bn = 100;
const In = Buffer.allocUnsafe(0);
const Cn = 16 * 1024;
const $n = "buffer";
const Wn = "utf8";
function Fn(e, t) {
t._opening = true;
t._writing = true;
t._asyncDrainScheduled = false;
function n(n, r) {
if (n) {
t._reopening = false;
t._writing = false;
t._opening = false;
if (t.sync) {
process.nextTick((() => {
if (t.listenerCount("error") > 0) {
t.emit("error", n);
}
}));
} else {
t.emit("error", n);
}
return;
}
const i = t._reopening;
t.fd = r;
t.file = e;
t._reopening = false;
t._opening = false;
t._writing = false;
if (t.sync) {
process.nextTick((() => t.emit("ready")));
} else {
t.emit("ready");
}
if (t.destroyed) {
return;
}
if (!t._writing && t._len > t.minLength || t._flushPending) {
t._actualWrite();
} else if (i) {
process.nextTick((() => t.emit("drain")));
}
}
const r = t.append ? "a" : "w";
const i = t.mode;
if (t.sync) {
try {
if (t.mkdir) jn.mkdirSync(Dn.dirname(e), {
recursive: true
});
const s = jn.openSync(e, r, i);
n(null, s);
} catch (e) {
n(e);
throw e;
}
} else if (t.mkdir) {
jn.mkdir(Dn.dirname(e), {
recursive: true
}, (t => {
if (t) return n(t);
jn.open(e, r, i, n);
}));
} else {
jn.open(e, r, i, n);
}
}
function Un(e) {
if (!(this instanceof Un)) {
return new Un(e);
}
let {fd: t, dest: n, minLength: r, maxLength: i, maxWrite: s, sync: o, append: a = true, mkdir: l, retryEAGAIN: u, fsync: f, contentMode: c, mode: d} = e || {};
t = t || n;
this._len = 0;
this.fd = -1;
this._bufs = [];
this._lens = [];
this._writing = false;
this._ending = false;
this._reopening = false;
this._asyncDrainScheduled = false;
this._flushPending = false;
this._hwm = Math.max(r || 0, 16387);
this.file = null;
this.destroyed = false;
this.minLength = r || 0;
this.maxLength = i || 0;
this.maxWrite = s || Cn;
this.sync = o || false;
this.writable = true;
this._fsync = f || false;
this.append = a || false;
this.mode = d;
this.retryEAGAIN = u || (() => true);
this.mkdir = l || false;
let h;
let p;
if (c === $n) {
this._writingBuf = In;
this.write = Hn;
this.flush = qn;
this.flushSync = Zn;
this._actualWrite = er;
h = () => jn.writeSync(this.fd, this._writingBuf);
p = () => jn.write(this.fd, this._writingBuf, this.release);
} else if (c === undefined || c === Wn) {
this._writingBuf = "";
this.write = zn;
this.flush = Jn;
this.flushSync = Xn;
this._actualWrite = Qn;
h = () => jn.writeSync(this.fd, this._writingBuf, "utf8");
p = () => jn.write(this.fd, this._writingBuf, "utf8", this.release);
} else {
throw new Error(`SonicBoom supports "${Wn}" and "${$n}", but passed ${c}`);
}
if (typeof t === "number") {
this.fd = t;
process.nextTick((() => this.emit("ready")));
} else if (typeof t === "string") {
Fn(t, this);
} else {
throw new Error("SonicBoom supports only file descriptors and files");
}
if (this.minLength >= this.maxWrite) {
throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);
}
this.release = (e, t) => {
if (e) {
if ((e.code === "EAGAIN" || e.code === "EBUSY") && this.retryEAGAIN(e, this._writingBuf.length, this._len - this._writingBuf.length)) {
if (this.sync) {
try {
Mn(Bn);
this.release(undefined, 0);
} catch (e) {
this.release(e);
}
} else {
setTimeout(p, Bn);
}
} else {
this._writing = false;
this.emit("error", e);
}
return;
}
this.emit("write", t);
const n = Gn(this._writingBuf, this._len, t);
this._len = n.len;
this._writingBuf = n.writingBuf;
if (this._writingBuf.length) {
if (!this.sync) {
p();
return;
}
try {
do {
const e = h();
const t = Gn(this._writingBuf, this._len, e);
this._len = t.len;
this._writingBuf = t.writingBuf;
} while (this._writingBuf.length);
} catch (e) {
this.release(e);
return;
}
}
if (this._fsync) {
jn.fsyncSync(this.fd);
}
const r = this._len;
if (this._reopening) {
this._writing = false;
this._reopening = false;
this.reopen();
} else if (r > this.minLength) {
this._actualWrite();
} else if (this._ending) {
if (r > 0) {
this._actualWrite();
} else {
this._writing = false;
tr(this);
}
} else {
this._writing = false;
if (this.sync) {
if (!this._asyncDrainScheduled) {
this._asyncDrainScheduled = true;
process.nextTick(Kn, this);
}
} else {
this.emit("drain");
}
}
};
this.on("newListener", (function(e) {
if (e === "drain") {
this._asyncDrainScheduled = false;
}
}));
}
function Gn(e, t, n) {
if (typeof e === "string" && Buffer.byteLength(e) !== n) {
n = Buffer.from(e).subarray(0, n).toString().length;
}
t = Math.max(t - n, 0);
e = e.slice(n);
return {
writingBuf: e,
len: t
};
}
function Kn(e) {
const t = e.listenerCount("drain") > 0;
if (!t) return;
e._asyncDrainScheduled = false;
e.emit("drain");
}
Pn(Un, Nn);
function Vn(e, t) {
if (e.length === 0) {
return In;
}
if (e.length === 1) {
return e[0];
}
return Buffer.concat(e, t);
}
function zn(e) {
if (this.destroyed) {
throw new Error("SonicBoom destroyed");
}
const t = this._len + e.length;
const n = this._bufs;
if (this.maxLength && t > this.maxLength) {
this.emit("drop", e);
return this._len < this._hwm;
}
if (n.length === 0 || n[n.length - 1].length + e.length > this.maxWrite) {
n.push("" + e);
} else {
n[n.length - 1] += e;
}
this._len = t;
if (!this._writing && this._len >= this.minLength) {
this._actualWrite();
}
return this._len < this._hwm;
}
function Hn(e) {
if (this.destroyed) {
throw new Error("SonicBoom destroyed");
}
const t = this._len + e.length;
const n = this._bufs;
const r = this._lens;
if (this.maxLength && t > this.maxLength) {
this.emit("drop", e);
return this._len < this._hwm;
}
if (n.length === 0 || r[r.length - 1] + e.length > this.maxWrite) {
n.push([ e ]);
r.push(e.length);
} else {
n[n.length - 1].push(e);
r[r.length - 1] += e.length;
}
this._len = t;
if (!this._writing && this._len >= this.minLength) {
this._actualWrite();
}
return this._len < this._hwm;
}
function Yn(e) {
this._flushPending = true;
const t = () => {
if (!this._fsync) {
jn.fsync(this.fd, (t => {
this._flushPending = false;
e(t);
}));
} else {
this._flushPending = false;
e();
}
this.off("error", n);
};
const n = n => {
this._flushPending = false;
e(n);
this.off("drain", t);
};
this.once("drain", t);
this.once("error", n);
}
function Jn(e) {
if (e != null && typeof e !== "function") {
throw new Error("flush cb must be a function");
}
if (this.destroyed) {
const t = new Error("SonicBoom destroyed");
if (e) {
e(t);
return;
}
throw t;
}
if (this.minLength <= 0) {
e?.();
return;
}
if (e) {
Yn.call(this, e);
}
if (this._writing) {
return;
}
if (this._bufs.length === 0) {
this._bufs.push("");
}
this._actualWrite();
}
function qn(e) {
if (e != null && typeof e !== "function") {
throw new Error("flush cb must be a function");
}
if (this.destroyed) {
const t = new Error("SonicBoom destroyed");
if (e) {
e(t);
return;
}
throw t;
}
if (this.minLength <= 0) {
e?.();
return;
}
if (e) {
Yn.call(this, e);
}
if (this._writing) {
return;
}
if (this._bufs.length === 0) {
this._bufs.push([]);
this._lens.push(0);
}
this._actualWrite();
}
Un.prototype.reopen = function(e) {
if (this.destroyed) {
throw new Error("SonicBoom destroyed");
}
if (this._opening) {
this.once("ready", (() => {
this.reopen(e);
}));
return;
}
if (this._ending) {
return;
}
if (!this.file) {
throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");
}
if (e) {
this.file = e;
}
this._reopening = true;
if (this._writing) {
return;
}
const t = this.fd;
this.once("ready", (() => {
if (t !== this.fd) {
jn.close(t, (e => {
if (e) {
return this.emit("error", e);
}
}));
}
}));
Fn(this.file, this);
};
Un.prototype.end = function() {
if (this.destroyed) {
throw new Error("SonicBoom destroyed");
}
if (this._opening) {
this.once("ready", (() => {
this.end();
}));
return;
}
if (this._ending) {
return;
}
this._ending = true;
if (this._writing) {
return;
}
if (this._len > 0 && this.fd >= 0) {
this._actualWrite();
} else {
tr(this);
}
};
function Xn() {
if (this.destroyed) {
throw new Error("SonicBoom destroyed");
}
if (this.fd < 0) {
throw new Error("sonic boom is not ready yet");
}
if (!this._writing && this._writingBuf.length > 0) {
this._bufs.unshift(this._writingBuf);
this._writingBuf = "";
}
let e = "";
while (this._bufs.length || e) {
if (e.length <= 0) {
e = this._bufs[0];
}
try {
const t = jn.writeSync(this.fd, e, "utf8");
const n = Gn(e, this._len, t);
e = n.writingBuf;
this._len = n.len;
if (e.length <= 0) {
this._bufs.shift();
}
} catch (t) {
const n = t.code === "EAGAIN" || t.code === "EBUSY";
if (n && !this.retryEAGAIN(t, e.length, this._len - e.length)) {
throw t;
}
Mn(Bn);
}
}
try {
jn.fsyncSync(this.fd);
} catch {}
}
function Zn() {
if (this.destroyed) {
throw new Error("SonicBoom destroyed");
}
if (this.fd < 0) {
throw new Error("sonic boom is not ready yet");
}
if (!this._writing && this._writingBuf.length > 0) {
this._bufs.unshift([ this._writingBuf ]);
this._writingBuf = In;
}
let e = In;
while (this._bufs.length || e.length) {
if (e.length <= 0) {
e = Vn(this._bufs[0], this._lens[0]);
}
try {
const t = jn.writeSync(this.fd, e);
e = e.subarray(t);
this._len = Math.max(this._len - t, 0);
if (e.length <= 0) {
this._bufs.shift();
this._lens.shift();
}
} catch (t) {
const n = t.code === "EAGAIN" || t.code === "EBUSY";
if (n && !this.retryEAGAIN(t, e.length, this._len - e.length)) {
throw t;
}
Mn(Bn);
}
}
}
Un.prototype.destroy = function() {
if (this.destroyed) {
return;
}
tr(this);
};
function Qn() {
const e = this.release;
this._writing = true;
this._writingBuf = this._writingBuf || this._bufs.shift() || "";
if (this.sync) {
try {
const t = jn.writeSync(this.fd, this._writingBuf, "utf8");
e(null, t);
} catch (t) {
e(t);
}
} else {
jn.write(this.fd, this._writingBuf, "utf8", e);
}
}
function er() {
const e = this.release;
this._writing = true;
this._writingBuf = this._writingBuf.length ? this._writingBuf : Vn(this._bufs.shift(), this._lens.shift());
if (this.sync) {
try {
const t = jn.writeSync(this.fd, this._writingBuf);
e(null, t);
} catch (t) {
e(t);
}
} else {
jn.write(this.fd, this._writingBuf, e);
}
}
function tr(e) {
if (e.fd === -1) {
e.once("ready", tr.bind(null, e));
return;
}
e.destroyed = true;
e._bufs = [];
e._lens = [];
jn.fsync(e.fd, t);
function t() {
if (e.fd !== 1 && e.fd !== 2) {
jn.close(e.fd, n);
} else {
n();
}
}
function n(t) {
if (t) {
e.emit("error", t);
return;
}
if (e._ending && !e._writing) {
e.emit("finish");
}
e.emit("close");
}
}
Un.SonicBoom = Un;
Un.default = Un;
var nr = Un;
const rr = o(nr);
"use strict";
const ir = {
exit: [],
beforeExit: []
};
const sr = {
exit: fr,
beforeExit: cr
};
let or;
function ar() {
if (or === undefined) {
or = new FinalizationRegistry(hr);
}
}
function lr(e) {
if (ir[e].length > 0) {
return;
}
process.on(e, sr[e]);
}
function ur(e) {
if (ir[e].length > 0) {
return;
}
process.removeListener(e, sr[e]);
if (ir.exit.length === 0 && ir.beforeExit.length === 0) {
or = undefined;
}
}
function fr() {
dr("exit");
}
function cr() {
dr("beforeExit");
}
function dr(e) {
for (const t of ir[e]) {
const n = t.deref();
const r = t.fn;
if (n !== undefined) {
r(n, e);
}
}
ir[e] = [];
}
function hr(e) {
for (const t of [ "exit", "beforeExit" ]) {
const n = ir[t].indexOf(e);
ir[t].splice(n, n + 1);
ur(t);
}
}
function pr(e, t, n) {
if (t === undefined) {
throw new Error("the object can't be undefined");
}
lr(e);
const r = new WeakRef(t);
r.fn = n;
ar();
or.register(t, r);
ir[e].push(r);
}
function yr(e, t) {
pr("exit", e, t);
}
function gr(e, t) {
pr("beforeExit", e, t);
}
function br(e) {
if (or === undefined) {
return;
}
or.unregister(e);
for (const t of [ "exit", "beforeExit" ]) {
ir[t] = ir[t].filter((t => {
const n = t.deref();
return n && n !== e;
}));
ur(t);
}
}
var mr = {
register: yr,
registerBeforeExit: gr,
unregister: br
};
const wr = o(mr);
var _r = "thread-stream";
var vr = "2.7.0";
var Sr = "A streaming way to send data to a Node.js Worker Thread";
var Er = "index.js";
var Ar = "index.d.ts";
var Or = {
"real-require": "^0.2.0"
};
var Rr = {
"@types/node": "^20.1.0",
"@types/tap": "^15.0.0",
"@yao-pkg/pkg": "^5.11.5",
desm: "^1.3.0",
fastbench: "^1.0.1",
husky: "^9.0.6",
"pino-elasticsearch": "^8.0.0",
"sonic-boom": "^3.0.0",
standard: "^17.0.0",
tap: "^16.2.0",
"ts-node": "^10.8.0",
typescript: "^5.3.2",
"why-is-node-running": "^2.2.2"
};
var Lr = {
test: 'standard && npm run transpile && tap "test/**/*.test.*js" && tap --ts test/*.test.*ts',
"test:ci": "standard && npm run transpile && npm run test:ci:js && npm run test:ci:ts",
"test:ci:js": 'tap --no-check-coverage --timeout=120 --coverage-report=lcovonly "test/**/*.test.*js"',
"test:ci:ts": 'tap --ts --no-check-coverage --coverage-report=lcovonly "test/**/*.test.*ts"',
"test:yarn": 'npm run transpile && tap "test/**/*.test.js" --no-check-coverage',
transpile: "sh ./test/ts/transpile.sh",
prepare: "husky install"
};
var kr = {
ignore: [ "test/ts/**/*" ]
};
var xr = {
type: "git",
url: "git+https://github.com/mcollina/thread-stream.git"
};
var Tr = [ "worker", "thread", "threads", "stream" ];
var jr = "Matteo Collina <hello@matteocollina.com>";
var Nr = "MIT";
var Pr = {
url: "https://github.com/mcollina/thread-stream/issues"
};
var Dr = "https://github.com/mcollina/thread-stream#readme";