@visulima/pail 4.0.0-alpha.21 → 4.0.0-alpha.23

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/LICENSE.md +841 -6
  3. package/README.md +53 -24
  4. package/dist/index.browser.d.ts +16 -5
  5. package/dist/index.browser.js +19 -19
  6. package/dist/index.server.d.ts +30 -5
  7. package/dist/index.server.js +28 -27
  8. package/dist/middleware/elysia.d.ts +5 -4
  9. package/dist/middleware/elysia.js +1 -1
  10. package/dist/middleware/express.d.ts +5 -4
  11. package/dist/middleware/express.js +1 -1
  12. package/dist/middleware/fastify.d.ts +5 -4
  13. package/dist/middleware/fastify.js +1 -1
  14. package/dist/middleware/hono.d.ts +5 -4
  15. package/dist/middleware/hono.js +1 -1
  16. package/dist/middleware/next/handler.d.ts +5 -4
  17. package/dist/middleware/next/handler.js +1 -1
  18. package/dist/middleware/sveltekit.d.ts +5 -4
  19. package/dist/middleware/sveltekit.js +1 -1
  20. package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +1 -0
  21. package/dist/packem_shared/AbstractJsonReporter-C6iu_u9-.js +1 -0
  22. package/dist/packem_shared/JsonReporter-BXktpC__.js +2 -0
  23. package/dist/packem_shared/JsonReporter-bmem9lcg.js +1 -0
  24. package/dist/packem_shared/{PrettyReporter-D75CJT0C.js → PrettyReporter-DsHfKOU7.js} +3 -3
  25. package/dist/packem_shared/PrettyReporter-LXeSlx8P.js +44 -0
  26. package/dist/packem_shared/{abstract-json-reporter.d-Boj5w068.d.ts → abstract-json-reporter.d-wfESoEa-.d.ts} +3 -2
  27. package/dist/packem_shared/abstract-pretty-reporter-eLxhddj0.js +57 -0
  28. package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-f9no2VNI.js +25 -0
  29. package/dist/packem_shared/{create-middleware-logger.d-MK7moe4r.d.ts → create-middleware-logger.d-B-JmQ1Sl.d.ts} +2 -2
  30. package/dist/packem_shared/{headers-D-K_EnkH.js → headers-DH0H2s8W.js} +1 -1
  31. package/dist/packem_shared/index-Q1764hvO.js +1 -0
  32. package/dist/packem_shared/index.d-T71KjNAr.d.ts +16 -0
  33. package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +1 -0
  34. package/dist/packem_shared/{types.d-Ck_RSjLg.d.ts → types.d-bWnqHJKL.d.ts} +2 -37
  35. package/dist/packem_shared/{wide-event.d-DkYD7YVK.d.ts → wide-event.d-D3ATYpoK.d.ts} +17 -5
  36. package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +1 -0
  37. package/dist/packem_shared/write-stream-C7jxLxIT.js +1 -0
  38. package/dist/processor/caller/caller-processor.d.ts +2 -1
  39. package/dist/processor/environment-processor.d.ts +2 -1
  40. package/dist/processor/message-formatter-processor.d.ts +9 -1
  41. package/dist/processor/message-formatter-processor.js +1 -1
  42. package/dist/processor/opentelemetry-processor.d.ts +2 -1
  43. package/dist/processor/redact-processor.d.ts +41 -2
  44. package/dist/processor/sampling-processor.d.ts +2 -1
  45. package/dist/reporter/file/json-file-reporter.d.ts +21 -3
  46. package/dist/reporter/file/json-file-reporter.js +1 -1
  47. package/dist/reporter/http/abstract-http-reporter.d.ts +46 -3
  48. package/dist/reporter/http/abstract-http-reporter.js +2 -2
  49. package/dist/reporter/http/http-reporter.d.ts +4 -3
  50. package/dist/reporter/http/http-reporter.edge-light.d.ts +57 -1
  51. package/dist/reporter/http/http-reporter.edge-light.js +2 -2
  52. package/dist/reporter/json/index.browser.d.ts +1 -1
  53. package/dist/reporter/json/index.browser.js +1 -1
  54. package/dist/reporter/json/index.d.ts +6 -4
  55. package/dist/reporter/json/index.js +1 -1
  56. package/dist/reporter/pretty/index.browser.js +1 -1
  57. package/dist/reporter/pretty/index.d.ts +58 -38
  58. package/dist/reporter/pretty/index.js +1 -1
  59. package/dist/reporter/simple/simple-reporter.server.d.ts +87 -5
  60. package/dist/reporter/simple/simple-reporter.server.js +8 -8
  61. package/dist/wide-event.d.ts +4 -3
  62. package/dist/wide-event.js +1 -1
  63. package/package.json +5 -5
  64. package/dist/packem_shared/AbstractJsonReporter-CF0KKdQS.js +0 -1
  65. package/dist/packem_shared/AbstractJsonReporter-CVwjgboT.js +0 -1
  66. package/dist/packem_shared/JsonReporter-BJFnahby.js +0 -1
  67. package/dist/packem_shared/JsonReporter-CnLM-d0U.js +0 -2
  68. package/dist/packem_shared/PrettyReporter-D9aBMmxI.js +0 -45
  69. package/dist/packem_shared/abstract-pretty-reporter-zijeSUgy.js +0 -34
  70. package/dist/packem_shared/index-COQEZODZ.js +0 -1
  71. package/dist/packem_shared/write-console-log-based-on-level-DDSKGBKj.js +0 -1
  72. package/dist/packem_shared/write-stream-B6BXco86.js +0 -1
  73. /package/dist/packem_shared/{createPailError-CbU1Ogfa.js → PailError-CbU1Ogfa.js} +0 -0
@@ -1,9 +1,10 @@
1
1
  import { AbstractHttpReporterOptions, AbstractHttpReporter } from "./abstract-http-reporter.js";
2
- import "../../packem_shared/types.d-Ck_RSjLg.js";
2
+ import 'type-fest';
3
+ import "../../packem_shared/types.d-bWnqHJKL.js";
3
4
  import '@visulima/colorize';
4
5
  import '@visulima/interactive-manager';
5
- import "../../packem_shared/abstract-json-reporter.d-Boj5w068.js";
6
- import 'safe-stable-stringify';
6
+ import "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
7
+ import "../../packem_shared/index.d-T71KjNAr.js";
7
8
  /**
8
9
  * HTTP Reporter.
9
10
  *
@@ -1,6 +1,5 @@
1
1
  import '@visulima/colorize';
2
2
  import '@visulima/interactive-manager';
3
- import { stringify } from 'safe-stable-stringify';
4
3
  /**
5
4
  Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
6
5
 
@@ -123,6 +122,21 @@ interface StringifyAwareReporter<L extends string> extends Reporter<L> {
123
122
  /** Set the stringify function for object serialization */
124
123
  setStringify: (stringify: any) => void;
125
124
  }
125
+ type Replacer = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null | object);
126
+ declare function stringify(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer, space?: string | number): undefined;
127
+ declare function stringify(value: string | number | unknown[] | null | boolean | object, replacer?: Replacer, space?: string | number): string;
128
+ declare function stringify(value: unknown, replacer?: ((key: string, value: unknown) => unknown) | (number | string)[] | null | undefined, space?: string | number): string | undefined;
129
+ declare namespace stringify {
130
+ export function configure(options: StringifyOptions): typeof stringify;
131
+ }
132
+ interface StringifyOptions {
133
+ bigint?: boolean;
134
+ circularValue?: string | null | TypeErrorConstructor | ErrorConstructor;
135
+ deterministic?: boolean | ((a: string, b: string) => number);
136
+ maximumBreadth?: number;
137
+ maximumDepth?: number;
138
+ strict?: boolean;
139
+ }
126
140
  /**
127
141
  * Options for configuring JSON reporters.
128
142
  */
@@ -254,6 +268,13 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
254
268
  */
255
269
  maxPayloadSize?: number;
256
270
  /**
271
+ * Maximum number of entries to keep queued while the endpoint is unavailable.
272
+ * When the queue exceeds this limit, the oldest entries are dropped (drop-oldest)
273
+ * so a sustained outage cannot grow memory without bound.
274
+ * @default 10000
275
+ */
276
+ maxQueueSize?: number;
277
+ /**
257
278
  * Number of retry attempts before giving up
258
279
  * @default 3
259
280
  */
@@ -285,6 +306,11 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
285
306
  };
286
307
  }) => void;
287
308
  /**
309
+ * Optional callback invoked when queued log entries are dropped because the queue
310
+ * exceeded `maxQueueSize`. Receives the number of dropped entries.
311
+ */
312
+ onDrop?: (droppedCount: number) => void;
313
+ /**
288
314
  * Optional callback for error handling
289
315
  */
290
316
  onError?: (error: Error) => void;
@@ -320,12 +346,15 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
320
346
  * @template L - The log level type
321
347
  */
322
348
  declare abstract class AbstractHttpReporter<L extends string = string> extends AbstractJsonReporter<L> implements StringifyAwareReporter<L> {
349
+ #private;
323
350
  protected url: string;
324
351
  protected method: string;
325
352
  protected headers: Record<string, string> | (() => Record<string, string>);
326
353
  protected contentType: string;
327
354
  protected batchContentType: string;
328
355
  protected onError?: (error: Error) => void;
356
+ protected onDrop?: (droppedCount: number) => void;
357
+ protected maxQueueSize: number;
329
358
  protected onDebug?: (entry: Record<string, unknown>) => void;
330
359
  protected onDebugRequestResponse?: (requestResponse: {
331
360
  req: {
@@ -369,6 +398,33 @@ declare abstract class AbstractHttpReporter<L extends string = string> extends A
369
398
  */
370
399
  constructor(config: AbstractHttpReporterOptions);
371
400
  /**
401
+ * Flushes all queued log entries to the HTTP endpoint immediately.
402
+ *
403
+ * Returns a promise that resolves once the queue has been drained (or rejects
404
+ * if a batch send fails terminally). Use this before a serverless function or
405
+ * short-lived process exits so the tail of the batch is not lost.
406
+ * @example
407
+ * ```typescript
408
+ * await reporter.flush();
409
+ * ```
410
+ */
411
+ flush(): Promise<void>;
412
+ /**
413
+ * Flushes any remaining queued entries and clears pending timers.
414
+ *
415
+ * Counterpart to a transport lifecycle `end`/`dispose`. After calling `close()`
416
+ * the reporter can still be used, but any pending batch timeout is cleared.
417
+ * @example
418
+ * ```typescript
419
+ * process.on("beforeExit", () => reporter.close());
420
+ * ```
421
+ */
422
+ close(): Promise<void>;
423
+ /**
424
+ * Alias for {@link close} to match common transport `dispose` conventions.
425
+ */
426
+ dispose(): Promise<void>;
427
+ /**
372
428
  * Processes and ships log entries to the HTTP endpoint.
373
429
  * @param message The JSON-formatted log message
374
430
  * @param logLevel The log level of the message
@@ -1,2 +1,2 @@
1
- import{createRequire as P}from"node:module";const E=P(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,a]=d.versions.node.split(".").map(Number);if(t>22||t===22&&a>=3||t===20&&a>=16)return d.getBuiltinModule(e)}return E(e)},{Buffer:O}=v("node:buffer"),{gzipSync:z}=v("node:zlib");var N=Object.defineProperty,D=(e,t)=>N(e,"name",{value:t,configurable:!0});const B=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}});var R=Object.defineProperty,f=D((e,t)=>R(e,"name",{value:t,configurable:!0}),"i");const L=f(e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},"isPlainObject"),p=new WeakSet,x=f(e=>{const t=Object.getOwnPropertyNames(e);for(const a of t){const r=Object.getOwnPropertyDescriptor(e,a);r&&(r.enumerable||Object.defineProperty(e,a,{...r,enumerable:!0}),r.value&&typeof r.value=="object"&&!Array.isArray(r.value)&&(Object.getPrototypeOf(r.value)===Object.prototype||Object.getPrototypeOf(r.value)===null)&&x(r.value))}},"makePropertiesEnumerable"),$=f(e=>{p.add(e);const t=e.toJSON();return p.delete(e),Object.isExtensible(t)&&x(t),t},"toJSON"),g=f((e,t,a,r,s=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.has(e)?"[Circular]":(a+=1,m(e,r,t,a));if(r.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(L(e)){if(s.has(e))return"[Circular]";if(r.maxDepth!==void 0&&r.maxDepth!==Number.POSITIVE_INFINITY&&a+1>=r.maxDepth)return{};a+=1,s.add(e);const o={};for(const i in e)o[i]=g(e[i],t,a,r,s);return s.delete(e),o}try{return e}catch{return"[Not Available]"}},"serializeValue"),m=f((e,t,a,r)=>{if(a.add(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return $(e);const s=Object.create(B);if(Object.defineProperty(s,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(s,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(s,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const i=[];for(const n of e.errors){if(!(n instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(a.has(n))return Object.defineProperty(s,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),s;i.push(m(n,t,a,r))}Object.defineProperty(s,"errors",{configurable:!0,enumerable:!0,value:i,writable:!0})}const o=e.cause;if(o!=null)if(o instanceof Error)a.has(o)?Object.defineProperty(s,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(s,"cause",{configurable:!0,enumerable:!0,value:m(o,t,a,r),writable:!0});else{const i=g(o,a,r,t);Object.defineProperty(s,"cause",{configurable:!0,enumerable:!0,value:i,writable:!0})}for(const i in e){if(i==="name"||i==="message"||i==="stack"||i==="cause"||i==="errors")continue;const n=e[i],u=g(n,a,r,t);Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:u,writable:!0})}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const i of t.exclude)try{delete s[i]}catch{}return s},"_serialize"),w=f((e,t={})=>m(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},new Set,0),"serialize"),T=Symbol("EMPTY");class _{stringify;errorOptions;constructor(t={}){this.errorOptions=t.error??{}}setStringify(t){this.stringify=t}log(t){const{context:a,error:r,file:s,message:o,type:i,...n}=t;if(n.label&&(n.label=n.label.trim()),s&&(n.file=`${s.name??""}:${String(s.line)}${s.column?`:${String(s.column)}`:""}`),n.message=o===T?void 0:o,r&&(n.error=w(r,this.errorOptions)),a){const u=[];for(let c=0;c<a.length;c+=1){const l=a[c];l!==T&&(l instanceof Error?u.push(w(l,this.errorOptions)):u.push(l))}n.context=u}this._log(this.stringify(n),i.level)}}const J=async e=>{const t=globalThis.CompressionStream;if(t){const a=new t("gzip"),r=a.writable.getWriter(),s=a.readable.getReader(),o=new TextEncoder,i=[];await r.write(o.encode(e)),await r.close();let n=!1;for(;!n;){const h=await s.read();n=h.done,h.value&&i.push(h.value)}const u=i.reduce((h,b)=>h+b.length,0),c=new Uint8Array(u);let l=0;for(let h=0;h<i.length;h+=1){const b=i[h];c.set(b,l),l+=b.length}return c}return z(e)};class C extends Error{logData;actualSize;maxSize;constructor(t,a,r,s){super(t),this.name="LogSizeError",this.logData=a,this.actualSize=r,this.maxSize=s}}const y=(e,t)=>e*2**t,j=e=>new Promise(t=>{setTimeout(t,e)}),k=e=>typeof e=="string"?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),A=async(e,t,a,r,s,o,i)=>{const n={};e.headers.forEach((l,h)=>{n[h]=l});const u=await e.text(),c={req:{body:s,headers:r,method:a,url:t},res:{body:u,headers:n,status:e.status,statusText:e.statusText}};if(o&&o(c),e.ok)return!1;if(e.status<500&&e.status!==429){const l=new Error(`HTTP ${String(e.status)}: ${e.statusText}`);throw i&&i(l),l}return!0},I=(e,t,a,r,s)=>{if(e.status===429&&t&&r<s){const o=e.headers.get("retry-after");return o?Number.parseInt(o,10)*1e3:y(a,r)}},F=(e,t,a,r)=>{if(e.status>=500&&a<r)return y(t,a)},M=(e,t,a,r,s)=>{const o=I(e,t,a,r,s);return o!==void 0?o:F(e,a,r,s)},Q=async(e,t,a,r,s)=>{if(t<a){const o=y(r,t);return await j(o),!0}return s&&s(e),!1},q=async(e,t,a,r,s,o,i,n,u)=>{let c=0;for(;c<=s;)try{const l=k(r),h=await fetch(e,{body:l,headers:a,method:t});if(!await A(h,e,t,a,r,n,u))return;const b=M(h,i,o,c,s);if(b!==void 0){await j(b),c+=1;continue}if(!h.ok){const S=new Error(`HTTP ${String(h.status)}: ${h.statusText}`);throw u&&u(S),S}return}catch(l){if(await Q(l,c,s,o,u)){c+=1;continue}throw l}};class Y extends _{url;method;headers;contentType;batchContentType;onError;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(t){if(super(t),this.url=t.url,this.method=t.method??"POST",this.headers=t.headers??{},this.contentType=t.contentType??"application/json",this.batchContentType=t.batchContentType??"application/json",this.onError=t.onError,this.onDebug=t.onDebug,this.onDebugRequestResponse=t.onDebugRequestResponse,this.payloadTemplate=t.payloadTemplate??(a=>JSON.stringify(a)),this.compression=t.compression??!1,this.maxRetries=t.maxRetries??3,this.retryDelay=t.retryDelay??1e3,this.respectRateLimit=t.respectRateLimit??!0,this.enableBatchSend=t.enableBatchSend??!0,this.batchSize=t.batchSize??100,this.batchSendTimeout=t.batchSendTimeout??5e3,this.batchSendDelimiter=t.batchSendDelimiter??`
2
- `,this.batchMode=t.batchMode??"delimiter",this.batchFieldName=t.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=t.maxLogSize??1048576,this.maxPayloadSize=t.maxPayloadSize??5242880,this.edgeCompat=t.edgeCompat??!1}_log(t,a){try{const r=JSON.parse(t),s=a,o=r.message,i={logLevel:s,message:o??""};if(r.data)i.data=r.data;else if(r.context)i.data=r.context;else{const c={...r};delete c.message,Object.keys(c).length>0&&(i.data=c)}const n=this.payloadTemplate(i);this.onDebug&&this.onDebug({data:i.data,logLevel:s,message:o});const u=this.edgeCompat||typeof TextEncoder>"u"?O.byteLength(n,"utf8"):new TextEncoder().encode(n).length;if(u>this.maxLogSize){const c=new C(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(u)} bytes`,{data:i.data,logLevel:s,message:o},u,this.maxLogSize);this.onError&&this.onError(c);return}this.enableBatchSend?this.addToBatch(n,u):this.sendPayload(n).catch(c=>{this.onError&&this.onError(c)})}catch(r){this.onError&&this.onError(r)}}addToBatch(t,a){const r=this.currentBatchSize+a+this.batchSendDelimiter.length,s=this.maxPayloadSize*.9;r>s&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.currentBatchSize+=a+this.batchSendDelimiter.length,this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const t=this.batchQueue.splice(0,this.batchSize);this.currentBatchSize=0;for(let a=0;a<this.batchQueue.length;a+=1){const r=this.batchQueue[a],s=this.edgeCompat||typeof TextEncoder>"u"?O.byteLength(r,"utf8"):new TextEncoder().encode(r).length;this.currentBatchSize+=s+(a<this.batchQueue.length-1?this.batchSendDelimiter.length:0)}try{await this.sendBatch(t)}catch(a){this.onError&&this.onError(a)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let a;switch(this.batchMode){case"array":{const r=t.map(s=>JSON.parse(s));a=JSON.stringify(r);break}case"field":{const r=t.map(o=>JSON.parse(o)),s=this.batchFieldName?{[this.batchFieldName]:r}:{};a=JSON.stringify(s);break}default:{a=t.join(this.batchSendDelimiter);break}}await this.sendPayload(a,this.batchContentType)}async sendPayload(t,a){const r=typeof this.headers=="function"?this.headers():{...this.headers};r["content-type"]??=a??this.contentType;let s=t;if(this.compression&&!this.edgeCompat)try{s=await J(t),r["content-encoding"]="gzip"}catch(o){this.onError&&this.onError(new Error(`Compression failed: ${String(o)}`))}await q(this.url,this.method,r,s,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}class U extends Y{constructor(t){super({...t,edgeCompat:!0})}}export{U as default};
1
+ import{createRequire as N}from"node:module";const z=N(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=t=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[e,r]=d.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return d.getBuiltinModule(t)}return z(t)},{Buffer:E}=S("node:buffer"),{createRequire:P}=S("node:module"),{gzipSync:B}=S("node:zlib"),R=P(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=t=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,r]=p.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return p.getBuiltinModule(t)}return R(t)};_("node:util");const L=P(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=t=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[e,r]=m.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return m.getBuiltinModule(t)}return L(t)};T("node:fs");T("node:path");T("node:url");const M=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&M.set("AggregateError",AggregateError);const $=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),Q=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null},y=new WeakSet,j=t=>{const e=Object.getOwnPropertyNames(t);for(const r of e){const s=Object.getOwnPropertyDescriptor(t,r);s&&(s.enumerable||Object.defineProperty(t,r,{...s,enumerable:!0}),s.value&&typeof s.value=="object"&&!Array.isArray(s.value)&&(Object.getPrototypeOf(s.value)===Object.prototype||Object.getPrototypeOf(s.value)===null)&&j(s.value))}},A=t=>{y.add(t);const e=t.toJSON();return y.delete(t),Object.isExtensible(e)&&j(e),e},b=(t,e,r,s,o=new Set)=>{if(t&&t instanceof Uint8Array&&t.constructor.name==="Buffer")return"[object Buffer]";if(t!==null&&typeof t=="object"&&"pipe"in t&&typeof t.pipe=="function")return"[object Stream]";if(t instanceof Error)return e.has(t)?"[Circular]":(r+=1,g(t,s,e,r));if(s.useToJSON&&t!==null&&typeof t=="object"&&"toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return t.toString();if(typeof URL<"u"&&t instanceof URL)return t.href;if(t instanceof Map){const i=[];for(const[a,n]of t.entries())i.push([b(a,e,r,s,o),b(n,e,r,s,o)]);return{__dataType:"Map",value:i}}if(t instanceof Set){const i=[];for(const a of t.values())i.push(b(a,e,r,s,o));return{__dataType:"Set",value:i}}if(typeof t=="function")return`[Function: ${t.name||"anonymous"}]`;if(typeof t=="bigint")return`${String(t)}n`;if(Q(t)){if(o.has(t))return"[Circular]";if(s.maxDepth!==void 0&&s.maxDepth!==Number.POSITIVE_INFINITY&&r+1>=s.maxDepth)return{};r+=1,o.add(t);const i={};for(const a in t)i[a]=b(t[a],e,r,s,o);return o.delete(t),i}try{return t}catch{return"[Not Available]"}},g=(t,e,r,s)=>{if(r.add(t),e.maxDepth===0)return{};if(e.useToJSON&&typeof t.toJSON=="function"&&!y.has(t))return A(t);const o=Object.create($);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(t.constructor)==="[object Function]"?t.constructor.name:t.name,writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:t.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:t.stack,writable:!0}),Array.isArray(t.errors)){const a=[];for(const n of t.errors){if(!(n instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.has(n))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;a.push(g(n,e,r,s))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:a,writable:!0})}const i=t.cause;if(i!=null)if(i instanceof Error)r.has(i)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:g(i,e,r,s),writable:!0});else{const a=b(i,r,s,e);Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:a,writable:!0})}for(const a in t){if(a==="name"||a==="message"||a==="stack"||a==="cause"||a==="errors")continue;const n=t[a],u=b(n,r,s,e);Object.defineProperty(o,a,{configurable:!0,enumerable:!0,value:u,writable:!0})}if(Array.isArray(e.exclude)&&e.exclude.length>0)for(const a of e.exclude)try{delete o[a]}catch{}return o},v=(t,e={})=>g(t,{exclude:e.exclude??[],maxDepth:e.maxDepth??Number.POSITIVE_INFINITY,useToJSON:e.useToJSON??!1},new Set,0),O=Symbol("EMPTY");class C{stringify;errorOptions;constructor(e={}){this.errorOptions=e.error??{}}setStringify(e){this.stringify=e}log(e){const{context:r,error:s,file:o,message:i,type:a,...n}=e;if(n.label&&(n.label=n.label.trim()),o&&(n.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),n.message=i===O?void 0:i,s&&(n.error=v(s,this.errorOptions)),r){const u=[];for(let c=0;c<r.length;c+=1){const h=r[c];h!==O&&(h instanceof Error?u.push(v(h,this.errorOptions)):u.push(h))}n.context=u}this._log(this.stringify(n),a.level)}}const J=async t=>{const e=globalThis.CompressionStream;if(e){const r=new e("gzip"),s=r.writable.getWriter(),o=r.readable.getReader(),i=new TextEncoder,a=[];await s.write(i.encode(t)),await s.close();let n=!1;for(;!n;){const l=await o.read();n=l.done,l.value&&a.push(l.value)}const u=a.reduce((l,f)=>l+f.length,0),c=new Uint8Array(u);let h=0;for(let l=0;l<a.length;l+=1){const f=a[l];c.set(f,h),h+=f.length}return c}return B(t)};class I extends Error{logData;actualSize;maxSize;constructor(e,r,s,o){super(e),this.name="LogSizeError",this.logData=r,this.actualSize=s,this.maxSize=o}}const w=(t,e)=>t*2**e,k=/^\d+$/,F=t=>{const e=t.trim();if(k.test(e)){const o=Number.parseInt(e,10);return Math.min(Math.max(o,0)*1e3,6e4)}const r=Date.parse(e);if(Number.isNaN(r))return;const s=r-Date.now();return Math.min(Math.max(s,0),6e4)},D=t=>new Promise(e=>{setTimeout(e,t)}),q=t=>typeof t=="string"?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),U=async(t,e,r,s,o,i,a)=>{const n={};t.headers.forEach((h,l)=>{n[l]=h});const u=await t.text(),c={req:{body:o,headers:s,method:r,url:e},res:{body:u,headers:n,status:t.status,statusText:t.statusText}};if(i&&i(c),t.ok)return!1;if(t.status<500&&t.status!==429){const h=new Error(`HTTP ${String(t.status)}: ${t.statusText}`);throw a&&a(h),h}return!0},Y=(t,e,r,s,o)=>{if(t.status===429&&e&&s<o){const i=t.headers.get("retry-after");return(i?F(i):void 0)??w(r,s)}},H=(t,e,r,s)=>{if(t.status>=500&&r<s)return w(e,r)},V=(t,e,r,s,o)=>{const i=Y(t,e,r,s,o);return i!==void 0?i:H(t,r,s,o)},W=async(t,e,r,s,o)=>{if(e<r){const i=w(s,e);return await D(i),!0}return o&&o(t),!1},G=async(t,e,r,s,o,i,a,n,u)=>{let c=0;for(;c<=o;)try{const h=q(s),l=await fetch(t,{body:h,headers:r,method:e});if(!await U(l,t,e,r,s,n,u))return;const f=V(l,a,i,c,o);if(f!==void 0){await D(f),c+=1;continue}if(!l.ok){const x=new Error(`HTTP ${String(l.status)}: ${l.statusText}`);throw u&&u(x),x}return}catch(h){if(await W(h,c,o,i,u)){c+=1;continue}throw h}};class K extends C{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(e){if(super(e),this.url=e.url,this.method=e.method??"POST",this.headers=e.headers??{},this.contentType=e.contentType??"application/json",this.batchContentType=e.batchContentType??"application/json",this.onError=e.onError,this.onDrop=e.onDrop,this.maxQueueSize=e.maxQueueSize??1e4,this.onDebug=e.onDebug,this.onDebugRequestResponse=e.onDebugRequestResponse,this.payloadTemplate=e.payloadTemplate??(r=>JSON.stringify(r)),this.compression=e.compression??!1,this.maxRetries=e.maxRetries??3,this.retryDelay=e.retryDelay??1e3,this.respectRateLimit=e.respectRateLimit??!0,this.enableBatchSend=e.enableBatchSend??!0,this.batchSize=e.batchSize??100,this.batchSendTimeout=e.batchSendTimeout??5e3,this.batchSendDelimiter=e.batchSendDelimiter??`
2
+ `,this.batchMode=e.batchMode??"delimiter",this.batchFieldName=e.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=e.maxLogSize??1048576,this.maxPayloadSize=e.maxPayloadSize??5242880,this.edgeCompat=e.edgeCompat??!1}async flush(){for(this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);this.batchQueue.length>0||this.isProcessingBatch;){if(this.isProcessingBatch){await new Promise(e=>setTimeout(e,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(e,r){try{const s=JSON.parse(e),o=r,i=s.message,a={logLevel:o,message:i??""};if(s.data)a.data=s.data;else if(s.context)a.data=s.context;else{const c={...s};delete c.message,Object.keys(c).length>0&&(a.data=c)}const n=this.payloadTemplate(a);this.onDebug&&this.onDebug({data:a.data,logLevel:o,message:i});const u=this.edgeCompat||typeof TextEncoder>"u"?E.byteLength(n,"utf8"):new TextEncoder().encode(n).length;if(u>this.maxLogSize){const c=new I(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(u)} bytes`,{data:a.data,logLevel:o,message:i},u,this.maxLogSize);this.onError&&this.onError(c);return}this.enableBatchSend?this.addToBatch(n,u):this.sendPayload(n).catch(c=>{this.onError&&this.onError(c)})}catch(s){this.onError&&this.onError(s)}}addToBatch(e,r){const s=this.currentBatchSize+r+this.batchSendDelimiter.length,o=this.maxPayloadSize*.9;if(s>o&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(e),this.currentBatchSize+=r+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const i=this.batchQueue.splice(0,this.batchQueue.length-this.maxQueueSize);this.currentBatchSize=this.#e(),this.onDrop&&this.onDrop(i.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#e(){let e=0;for(let r=0;r<this.batchQueue.length;r+=1){const s=this.batchQueue[r],o=this.edgeCompat||typeof TextEncoder>"u"?E.byteLength(s,"utf8"):new TextEncoder().encode(s).length;e+=o+(r<this.batchQueue.length-1?this.batchSendDelimiter.length:0)}return e}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const e=this.batchQueue.splice(0,this.batchSize);this.currentBatchSize=this.#e();try{await this.sendBatch(e)}catch(r){this.onError&&this.onError(r)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(e){let r;switch(this.batchMode){case"array":{const s=e.map(o=>JSON.parse(o));r=JSON.stringify(s);break}case"field":{const s=e.map(i=>JSON.parse(i)),o=this.batchFieldName?{[this.batchFieldName]:s}:{};r=JSON.stringify(o);break}default:{r=e.join(this.batchSendDelimiter);break}}await this.sendPayload(r,this.batchContentType)}async sendPayload(e,r){const s=typeof this.headers=="function"?this.headers():{...this.headers};s["content-type"]??=r??this.contentType;let o=e;if(this.compression&&!this.edgeCompat)try{o=await J(e),s["content-encoding"]="gzip"}catch(i){this.onError&&this.onError(new Error(`Compression failed: ${String(i)}`))}await G(this.url,this.method,s,o,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}class Z extends K{constructor(e){super({...e,edgeCompat:!0})}}export{Z as default};
@@ -1,4 +1,4 @@
1
- import { stringify } from 'safe-stable-stringify';
1
+ import { s as stringify } from "../../packem_shared/index.d-T71KjNAr.js";
2
2
  import { R as ReadonlyMeta, E as ExtendedRfc5424LogLevels, L as LiteralUnion, S as StringifyAwareReporter } from "../../packem_shared/types.d-xxE3FOD3.js";
3
3
  import '@visulima/colorize';
4
4
  import '@visulima/interactive-manager';
@@ -1 +1 @@
1
- import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-CVwjgboT.js";import{default as p}from"../../packem_shared/JsonReporter-BJFnahby.js";export{e as AbstractJsonReporter,p as JsonReporter};
1
+ import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-Bp_JCrMQ.js";import{default as p}from"../../packem_shared/JsonReporter-bmem9lcg.js";export{e as AbstractJsonReporter,p as JsonReporter};
@@ -1,6 +1,7 @@
1
- import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-Boj5w068.js";
2
- import { E as ExtendedRfc5424LogLevels, L as LiteralUnion, S as StreamAwareReporter } from "../../packem_shared/types.d-Ck_RSjLg.js";
3
- import 'safe-stable-stringify';
1
+ import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
2
+ import { LiteralUnion } from 'type-fest';
3
+ import { E as ExtendedRfc5424LogLevels, a as StreamAwareReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
4
+ import "../../packem_shared/index.d-T71KjNAr.js";
4
5
  import '@visulima/colorize';
5
6
  import '@visulima/interactive-manager';
6
7
  /**
@@ -41,7 +42,8 @@ declare class JsonReporter<L extends string = string> extends AbstractJsonReport
41
42
  /**
42
43
  * Outputs the JSON message to the appropriate stream.
43
44
  *
44
- * Routes error and warning level messages to stderr, others to stdout.
45
+ * Routes high-severity RFC 5424 levels (warning/error/critical/alert/emergency/trace)
46
+ * to stderr, others to stdout.
45
47
  * @param message The JSON-formatted log message
46
48
  * @param logLevel The log level determining which stream to use
47
49
  * @protected
@@ -1 +1 @@
1
- import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-CF0KKdQS.js";import{default as p}from"../../packem_shared/JsonReporter-CnLM-d0U.js";export{e as AbstractJsonReporter,p as JsonReporter};
1
+ import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-C6iu_u9-.js";import{default as p}from"../../packem_shared/JsonReporter-BXktpC__.js";export{e as AbstractJsonReporter,p as JsonReporter};
@@ -1 +1 @@
1
- import{default as t}from"../../packem_shared/PrettyReporter-D75CJT0C.js";export{t as PrettyReporter};
1
+ import{default as t}from"../../packem_shared/PrettyReporter-DsHfKOU7.js";export{t as PrettyReporter};
@@ -1,51 +1,66 @@
1
- import { L as LiteralUnion, D as DefaultLogTypes, c as LoggerTypesConfig, R as ReadonlyMeta, f as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-Ck_RSjLg.js";
1
+ import { RenderErrorOptions } from '@visulima/error/error';
2
+ import { LiteralUnion } from 'type-fest';
2
3
  import { InteractiveManager } from '@visulima/interactive-manager';
4
+ import { D as DefaultLogTypes, c as LoggerTypesConfig, R as ReadonlyMeta, e as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
3
5
  import '@visulima/colorize';
4
- type ColorizeMethod = (value: string) => string;
5
- type CodeFrameOptions = {
6
- color?: {
7
- gutter?: ColorizeMethod;
8
- marker?: ColorizeMethod;
9
- message?: ColorizeMethod;
10
- };
11
- linesAbove?: number;
12
- linesBelow?: number;
13
- message?: string;
14
- prefix?: string;
15
- showGutter?: boolean;
16
- showLineNumbers?: boolean;
17
- tabWidth?: number | false;
18
- };
19
- type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
20
- color: CodeFrameOptions["color"] & {
21
- fileLine: ColorizeMethod;
22
- hint: ColorizeMethod;
23
- method: ColorizeMethod;
24
- title: ColorizeMethod;
25
- };
26
- cwd: string;
27
- displayShortPath: boolean;
28
- filterStacktrace: ((line: string) => boolean) | undefined;
29
- framesMaxLimit: number;
30
- hideErrorCauseCodeView: boolean;
31
- hideErrorCodeView: boolean;
32
- hideErrorErrorsCodeView: boolean;
33
- hideErrorTitle: boolean;
34
- hideMessage: boolean;
35
- indentation: number | " ";
36
- prefix: string;
37
- };
38
6
  interface Options {
39
- breakLength: number;
7
+ /**
8
+ * When `true`, honour custom inspectors: a value's
9
+ * `Symbol.for("nodejs.util.inspect.custom")` method (Node only),
10
+ * `Symbol.for("chai/inspect")` method, an `.inspect()` method, or a handler
11
+ * registered via `registerConstructor` / `registerStringTag`.
12
+ * @default true
13
+ */
40
14
  customInspect: boolean;
15
+ /**
16
+ * The maximum nesting depth to traverse before collapsing a nested value to
17
+ * `[Object]` / `[Array]`. A value `&lt;= 0` disables the limit.
18
+ * @default 5
19
+ */
41
20
  depth: number;
21
+ /**
22
+ * Pretty-print with indentation. `"\t"` indents with tabs, a positive integer
23
+ * indents with that many spaces, and `undefined` keeps everything on one line.
24
+ * @default undefined
25
+ */
42
26
  indent: number | " " | undefined;
27
+ /**
28
+ * The maximum number of array / typed-array / iterable elements to render
29
+ * before the remainder is replaced with an `… (N more)` marker. Use
30
+ * `Number.POSITIVE_INFINITY` to show every element.
31
+ * @default Number.POSITIVE_INFINITY
32
+ */
43
33
  maxArrayLength: number;
34
+ /**
35
+ * When `true`, render large numbers and bigints with `_` digit-group
36
+ * separators (e.g. `1_000_000`).
37
+ * @default true
38
+ */
44
39
  numericSeparator: boolean;
40
+ /**
41
+ * The quote character used when rendering string values and complex object
42
+ * keys.
43
+ * @default "single"
44
+ */
45
45
  quoteStyle: "double" | "single";
46
+ /**
47
+ * When `true`, also render non-enumerable own properties of plain objects
48
+ * (mirrors `util.inspect`'s `showHidden`).
49
+ * @default false
50
+ */
46
51
  showHidden: boolean;
47
- showProxy: boolean;
52
+ /**
53
+ * Colourize / decorate a rendered fragment. Receives the raw fragment and a
54
+ * style hint and must return the (optionally wrapped) string. Defaults to the
55
+ * identity function.
56
+ */
48
57
  stylize: (value: string, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
58
+ /**
59
+ * The maximum length (in characters) of a single rendered value before it is
60
+ * truncated with an ellipsis. Use `Number.POSITIVE_INFINITY` to disable
61
+ * truncation.
62
+ * @default Number.POSITIVE_INFINITY
63
+ */
49
64
  truncate: number;
50
65
  }
51
66
  /**
@@ -122,7 +137,7 @@ type PrettyStyleOptions = {
122
137
  */
123
138
  type PrettyReporterOptions = PrettyStyleOptions & {
124
139
  /** Error rendering options */
125
- error: Partial<Omit<Options$1, "color" | "prefix" | "indentation">>;
140
+ error: Partial<Omit<RenderErrorOptions, "color" | "prefix" | "indentation">>;
126
141
  /** Object inspection options */
127
142
  inspect: Partial<Options>;
128
143
  };
@@ -157,6 +172,11 @@ declare class PrettyReporter<T extends string = string, L extends string = strin
157
172
  */
158
173
  constructor(options?: Partial<PrettyReporterOptions>);
159
174
  /**
175
+ * Sets the logger types configuration and refreshes cached badge/label widths.
176
+ * @param types Logger type configurations with colors and labels
177
+ */
178
+ override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
179
+ /**
160
180
  * Sets the stdout stream for the reporter.
161
181
  * @param stdout_ The writable stream to use for standard output
162
182
  */
@@ -1 +1 @@
1
- import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-D9aBMmxI.js";export{t as PrettyReporter};
1
+ import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-LXeSlx8P.js";export{t as PrettyReporter};
@@ -17,7 +17,40 @@ type CodeFrameOptions = {
17
17
  showLineNumbers?: boolean;
18
18
  tabWidth?: number | false;
19
19
  };
20
- type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
20
+ /**
21
+ * The compiled position of a stack frame handed to a {@link SourceMapResolver}.
22
+ */
23
+ interface SourceMapLocation {
24
+ column?: number;
25
+ file: string;
26
+ line: number;
27
+ }
28
+ /**
29
+ * The resolved original position returned by a {@link SourceMapResolver}. Any omitted field falls
30
+ * back to the compiled value. `source`, when provided, is used directly as the code-frame content
31
+ * (e.g. from an inlined `sourcesContent`) instead of reading the resolved file from disk.
32
+ */
33
+ interface ResolvedSourceLocation {
34
+ column?: number;
35
+ file?: string;
36
+ line?: number;
37
+ source?: string;
38
+ }
39
+ /**
40
+ * Pluggable hook that maps a compiled `*.js:line:col` position back to its original source position
41
+ * (e.g. TS/JSX). Return `undefined` (or throw) to leave the frame untouched. Synchronous so it can
42
+ * be used by the synchronous `renderError`; resolve/inline your maps ahead of time.
43
+ */
44
+ type SourceMapResolver = (location: SourceMapLocation) => ResolvedSourceLocation | undefined;
45
+ type Options$1 = {
46
+ /**
47
+ * Read source files for code frames from anywhere on disk, including absolute paths outside
48
+ * `cwd`. Defaults to `false`, in which case only files resolving inside `cwd` are read — this
49
+ * prevents local file disclosure when rendering errors whose stack came from untrusted input
50
+ * (e.g. a deserialized error). Enable only for trusted, locally-thrown errors.
51
+ * @default false
52
+ */
53
+ allowAllFilePaths: boolean;
21
54
  color: CodeFrameOptions["color"] & {
22
55
  fileLine: ColorizeMethod;
23
56
  hint: ColorizeMethod;
@@ -34,19 +67,67 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
34
67
  hideErrorTitle: boolean;
35
68
  hideMessage: boolean;
36
69
  indentation: number | " ";
37
- prefix: string;
38
- };
70
+ prefix: string; /** Optional source-map resolver to map compiled frame positions back to original source. */
71
+ sourceMap?: SourceMapResolver;
72
+ } & Omit<CodeFrameOptions, "message | prefix">;
39
73
  interface Options {
40
- breakLength: number;
74
+ /**
75
+ * When `true`, honour custom inspectors: a value's
76
+ * `Symbol.for("nodejs.util.inspect.custom")` method (Node only),
77
+ * `Symbol.for("chai/inspect")` method, an `.inspect()` method, or a handler
78
+ * registered via `registerConstructor` / `registerStringTag`.
79
+ * @default true
80
+ */
41
81
  customInspect: boolean;
82
+ /**
83
+ * The maximum nesting depth to traverse before collapsing a nested value to
84
+ * `[Object]` / `[Array]`. A value `&lt;= 0` disables the limit.
85
+ * @default 5
86
+ */
42
87
  depth: number;
88
+ /**
89
+ * Pretty-print with indentation. `"\t"` indents with tabs, a positive integer
90
+ * indents with that many spaces, and `undefined` keeps everything on one line.
91
+ * @default undefined
92
+ */
43
93
  indent: number | " " | undefined;
94
+ /**
95
+ * The maximum number of array / typed-array / iterable elements to render
96
+ * before the remainder is replaced with an `… (N more)` marker. Use
97
+ * `Number.POSITIVE_INFINITY` to show every element.
98
+ * @default Number.POSITIVE_INFINITY
99
+ */
44
100
  maxArrayLength: number;
101
+ /**
102
+ * When `true`, render large numbers and bigints with `_` digit-group
103
+ * separators (e.g. `1_000_000`).
104
+ * @default true
105
+ */
45
106
  numericSeparator: boolean;
107
+ /**
108
+ * The quote character used when rendering string values and complex object
109
+ * keys.
110
+ * @default "single"
111
+ */
46
112
  quoteStyle: "double" | "single";
113
+ /**
114
+ * When `true`, also render non-enumerable own properties of plain objects
115
+ * (mirrors `util.inspect`'s `showHidden`).
116
+ * @default false
117
+ */
47
118
  showHidden: boolean;
48
- showProxy: boolean;
119
+ /**
120
+ * Colourize / decorate a rendered fragment. Receives the raw fragment and a
121
+ * style hint and must return the (optionally wrapped) string. Defaults to the
122
+ * identity function.
123
+ */
49
124
  stylize: (value: string, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
125
+ /**
126
+ * The maximum length (in characters) of a single rendered value before it is
127
+ * truncated with an ellipsis. Use `Number.POSITIVE_INFINITY` to disable
128
+ * truncation.
129
+ * @default Number.POSITIVE_INFINITY
130
+ */
50
131
  truncate: number;
51
132
  }
52
133
  /**
@@ -125,6 +206,7 @@ type SimpleReporterOptions = PrettyStyleOptions & {
125
206
  declare class SimpleReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
126
207
  #private;
127
208
  constructor(options?: Partial<SimpleReporterOptions>);
209
+ override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
128
210
  setStdout(stdout_: NodeJS.WriteStream): void;
129
211
  setStderr(stderr_: NodeJS.WriteStream): void;
130
212
  setInteractiveManager(manager?: InteractiveManager): void;
@@ -1,11 +1,11 @@
1
- import{createRequire as V}from"node:module";import k from"@visulima/colorize";import{A as O,b as z,r as F,c as G,d as H,g as K,e as g,f as Q,a as U,h as v,U as W,_ as b,i as X}from"../../packem_shared/abstract-pretty-reporter-zijeSUgy.js";const ie=V(import.meta.url),Y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:B,stderr:D}=Y,{bgGrey:Z,bold:I,cyan:J,green:N,greenBright:ee,grey:a,red:x,underline:R,white:te}=k,se=/[\\/]pail[\\/]dist/,_=S=>!se.test(S);class ne extends O{#t;#s;#r;#a=!1;#i;#e;constructor(t={}){const{error:o,inspect:n,...i}=t;super({uppercase:{label:!0,...i.uppercase},...i}),this.#i={...z,indent:void 0,...n},this.#e={...o,color:{fileLine:N,hint:J,marker:x,message:x,method:ee,title:x}},this.#t=B,this.#s=D}setStdout(t){this.#t=t}setStderr(t){this.#s=t}setInteractiveManager(t){this.#r=t}setIsInteractive(t){this.#a=t}log(t){const o=this.formatMessage(t),n=t.type.level,i=["error","trace","warn"].includes(n)?"stderr":"stdout",p=i==="stderr"?this.#s:this.#t;this.#a&&this.#r!==void 0&&p.isTTY?this.#r.update(i,o.split(`
2
- `),0):F(`${o}
3
- `,p)}formatMessage(t){const{columns:o}=G();let n=o;typeof this.styles.messageLength=="number"&&(n=this.styles.messageLength);const{badge:i,context:p,date:l,error:T,file:c,groups:f,label:d,message:u,prefix:m,repeated:w,scope:y,suffix:$,traceError:j,type:A}=t,{color:M}=this.loggerTypes[A.name],C=M?k[M]:te,h=f.map(()=>" ").join(""),e=[];if(f.length>0&&e.push(`${h+a(`[${f.at(-1)??""}]`)} `),l&&e.push(`${a(this.styles.dateFormatter(typeof l=="string"?new Date(l):l))} `),i)e.push(I(C(i)));else{const s=H(this.loggerTypes);s.length>0&&e.push(a(" ".repeat(s.length)))}const q=K(this.loggerTypes),E=g(q);if(d){const s=g(d),r=Math.max(0,E-s);e.push(`${I(C(Q(d,this.styles)))} `," ".repeat(r))}else e.push(" ".repeat(E+1));w&&e.push(`${Z.white(`[${String(w)}x]`)} `),Array.isArray(y)&&y.length>0&&e.push(`${a(`[${y.join(" > ")}]`)} `),m&&e.push(`${a(`[${this.styles.underline.prefix?R(m):m}]`)} `);const L=g(e.join(""));if(u!==U){const s=typeof u=="string"?u:v(u,this.#i);e.push(h+W(s,{trim:!1,width:n-3,wrapMode:X.STRICT_WIDTH}))}if(p){let s=!1;e.push(...p.map(r=>{if(r instanceof Error)return s=!0,`
1
+ import{createRequire as P}from"node:module";import L from"@visulima/colorize";import{A as z,c as B,r as D,b as O,d as F,g as G,e as H,f as c,h as K,a as Q,j as C,V as U,U as $,i as X}from"../../packem_shared/abstract-pretty-reporter-eLxhddj0.js";const ie=P(import.meta.url),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:W,stderr:Y}=V,{bgGrey:Z,bold:E,cyan:J,green:N,greenBright:ee,grey:h,red:b,underline:I,white:te}=L,se=/[\\/]pail[\\/]dist/,x=T=>!se.test(T);class he extends z{#e;#r;#i;#h=!1;#o;#s;#t;#a=!1;#n="";#p="";constructor(t={}){const{error:o,inspect:n,...i}=t;super({uppercase:{label:!0,...i.uppercase},...i}),this.#o={...B,indent:void 0,...n},this.#s={...o,color:{fileLine:N,hint:J,marker:b,message:b,method:ee,title:b}},this.#e=W,this.#r=Y,this.#l()}setLoggerTypes(t){super.setLoggerTypes(t),this.#l()}setStdout(t){this.#e=t,this.#t=void 0,this.#a=!1}setStderr(t){this.#r=t}setInteractiveManager(t){this.#i=t}setIsInteractive(t){this.#h=t}log(t){const o=this.formatMessage(t),n=t.type.level,i=D(n)?"stderr":"stdout",a=i==="stderr"?this.#r:this.#e;this.#h&&this.#i!==void 0&&a.isTTY?this.#i.update(i,o.split(`
2
+ `),0):O(`${o}
3
+ `,a)}#l(){this.#n=F(this.loggerTypes),this.#p=G(this.loggerTypes)}#u(){return!this.#a&&typeof this.#e.on=="function"&&(this.#a=!0,this.#e.on("resize",()=>{this.#t=void 0})),this.#t===void 0&&(this.#t=H().columns),this.#t}formatMessage(t){let o=this.#u();typeof this.styles.messageLength=="number"&&(o=this.styles.messageLength);const{badge:n,context:i,date:a,error:S,file:l,groups:f,label:g,message:u,prefix:d,repeated:j,scope:m,suffix:y,traceError:_,type:R}=t,{color:M}=this.loggerTypes[R.name],v=M?L[M]:te,p=f.map(()=>" ").join(""),e=[];if(f.length>0&&e.push(`${p+h(`[${f.at(-1)??""}]`)} `),a&&e.push(`${h(this.styles.dateFormatter(typeof a=="string"?new Date(a):a))} `),n)e.push(E(v(n)));else{const s=this.#n;s.length>0&&e.push(h(" ".repeat(s.length)))}const A=this.#p,w=c(A);if(g){const s=c(g),r=Math.max(0,w-s);e.push(`${E(v(K(g,this.styles)))} `," ".repeat(r))}else e.push(" ".repeat(w+1));j&&e.push(`${Z.white(`[${String(j)}x]`)} `),Array.isArray(m)&&m.length>0&&e.push(`${h(`[${m.join(" > ")}]`)} `),d&&e.push(`${h(`[${this.styles.underline.prefix?I(d):d}]`)} `);const k=c(e.join(""));if(u!==Q){const s=typeof u=="string"?u:C(u,this.#o);e.push(p+U(s,{trim:!1,width:o-3,wrapMode:X.STRICT_WIDTH}))}if(i){let s=!1;e.push(...i.map(r=>{if(r instanceof Error)return s=!0,`
4
4
 
5
- ${b(r,{...this.#e,filterStacktrace:_,prefix:h})}`;if(typeof r=="object")return` ${v(r,this.#i)}`;const P=(s?`
5
+ ${$(r,{...this.#s,filterStacktrace:x,prefix:p})}`;if(typeof r=="object")return` ${C(r,this.#o)}`;const q=(s?`
6
6
 
7
- `:" ")+String(r);return s=!1,P}))}if(T&&e.push(b(T,{...this.#e,filterStacktrace:_,prefix:h})),j&&e.push(`
7
+ `:" ")+String(r);return s=!1,q}))}if(S&&e.push($(S,{...this.#s,filterStacktrace:x,prefix:p})),_&&e.push(`
8
8
 
9
- ${b(j,{...this.#e,filterStacktrace:_,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:h})}`),$&&e.push(` ${h}${a(this.styles.underline.suffix?R($):$)}`),c){const s=(c.name??"")+(c.line?`:${String(c.line)}`:""),r=Math.max(0,L-g("Caller: "));e.push(`
10
- `,a("Caller: ")," ".repeat(r),s,`
11
- `)}return e.join("")}}export{ne as SimpleReporter};
9
+ ${$(_,{...this.#s,filterStacktrace:x,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:p})}`),y&&e.push(` ${p}${h(this.styles.underline.suffix?I(y):y)}`),l){const s=(l.name??"")+(l.line?`:${String(l.line)}`:""),r=Math.max(0,k-c("Caller: "));e.push(`
10
+ `,h("Caller: ")," ".repeat(r),s,`
11
+ `)}return e.join("")}}export{he as SimpleReporter};
@@ -1,5 +1,6 @@
1
- export { R as RequestLogEntry, S as SerializedError, W as WideEvent, a as WideEventFinishOptions, b as WideEventLevel, c as WideEventOptions, d as createWideEvent } from "./packem_shared/wide-event.d-DkYD7YVK.js";
2
- import "./packem_shared/types.d-Ck_RSjLg.js";
3
- import 'safe-stable-stringify';
1
+ export { R as RequestLogEntry, S as SerializedError, W as WideEvent, a as WideEventFinishOptions, b as WideEventLevel, c as WideEventOptions, d as createWideEvent } from "./packem_shared/wide-event.d-D3ATYpoK.js";
2
+ import "./packem_shared/types.d-bWnqHJKL.js";
3
+ import "./packem_shared/index.d-T71KjNAr.js";
4
+ import 'type-fest';
4
5
  import '@visulima/colorize';
5
6
  import '@visulima/interactive-manager';
@@ -1 +1 @@
1
- const h={debug:0,error:3,info:1,warn:2},c={debug:"debug",error:"error",info:"info",warn:"warn"},u=(s,t)=>{const e={...s},a=Object.keys(t);for(let i=0;i<a.length;i+=1){const r=a[i],o=t[r],n=e[r];o!==null&&typeof o=="object"&&!Array.isArray(o)&&n!==null&&typeof n=="object"&&!Array.isArray(n)?e[r]=u(n,o):e[r]=o}return e},m=s=>s<1e3?`${String(s)}ms`:`${(s/1e3).toFixed(2)}s`,d=s=>{const t={message:s.message,name:s.name};s.stack&&(t.stack=s.stack);const e=s;return e.status!==void 0?t.status=e.status:e.statusCode!==void 0&&(t.status=e.statusCode),e.data!==void 0&&(t.data=e.data),s.cause instanceof Error&&(t.cause=d(s.cause)),t};class l{name;autoEmit;data;emitted;attachedError;level;pail;requestLogs;service;startTime;status;timestamp;_type;constructor(t){this.name=t.name,this.pail=t.pail,this.data={},this.startTime=performance.now(),this.timestamp=new Date().toISOString(),this.emitted=!1,this.autoEmit=t.autoEmit??!0,this._type=t.type??"info",this.level="info",this.requestLogs=[],this.service=t.service}debug(t,e){return this.addLogEntry("debug",t,e)}emit(t){if(this.emitted)return;this.emitted=!0;const e=Math.round(performance.now()-this.startTime),a=this.attachedError?"error":this.level,i=t??c[a],r={duration:m(e),duration_ms:e,event:this.name,timestamp:this.timestamp,...this.data};this.service&&(r.service=this.service),this.status!==void 0&&(r.status=this.status),this.attachedError&&(r.error=d(this.attachedError)),this.requestLogs.length>0&&(r.requestLogs=this.requestLogs);const o=this.pail[i];o({message:r})}error(t,e,a){return e&&(this.attachedError=e),this.addLogEntry("error",t,a)}finish(t){t?.status!==void 0&&(this.status=t.status),t?.error&&(this.attachedError=t.error),this.emit()}getData(){return this.data}getLevel(){return this.attachedError?"error":this.level}getRequestLogs(){return this.requestLogs}info(t,e){return this.addLogEntry("info",t,e)}set(t){return this.data=u(this.data,t),this}setError(t){return this.attachedError=t,this}setStatus(t){return this.status=t,this}warn(t,e){return this.addLogEntry("warn",t,e)}[Symbol.dispose](){this.autoEmit&&!this.emitted&&this.emit()}addLogEntry(t,e,a){const i={level:t,message:e,timestamp:new Date().toISOString()};return a&&(i.context=a),this.requestLogs.push(i),this.escalateLevel(t),this}escalateLevel(t){(h[t]??0)>(h[this.level]??0)&&(this.level=t)}}const g=s=>new l(s);export{l as WideEvent,g as createWideEvent};
1
+ import"./packem_shared/addKnownErrorConstructor-C1OJTj2D-f9no2VNI.js";import{O as c}from"./packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js";const m=8,h={debug:0,error:3,info:1,warn:2},l={debug:"debug",error:"error",info:"info",warn:"warn"},u=(s,t)=>{const e={...s},r=Object.keys(t);for(let i=0;i<r.length;i+=1){const a=r[i],o=t[a],n=e[a];o!==null&&typeof o=="object"&&!Array.isArray(o)&&n!==null&&typeof n=="object"&&!Array.isArray(n)?e[a]=u(n,o):e[a]=o}return e},g=s=>s<1e3?`${String(s)}ms`:`${(s/1e3).toFixed(2)}s`,d=(s,t)=>{const e={message:typeof s.message=="string"?s.message:"",name:typeof s.name=="string"?s.name:"Error"};if(s.stack&&(e.stack=s.stack),s.status!==void 0?e.status=s.status:s.statusCode!==void 0&&(e.status=s.statusCode),s.data!==void 0&&(e.data=s.data),t.cause instanceof Error){const{cause:r}=s;r==="[Circular]"?e.cause="[Circular]":r!==null&&typeof r=="object"&&(e.cause=d(r,t.cause))}return e},p=s=>d(c(s,{maxDepth:m}),s);class v{name;autoEmit;data;emitted;attachedError;level;pail;requestLogs;service;startTime;status;timestamp;_type;constructor(t){this.name=t.name,this.pail=t.pail,this.data={},this.startTime=performance.now(),this.timestamp=new Date().toISOString(),this.emitted=!1,this.autoEmit=t.autoEmit??!0,this._type=t.type??"info",this.level="info",this.requestLogs=[],this.service=t.service}debug(t,e){return this.addLogEntry("debug",t,e)}emit(t){if(this.emitted)return;this.emitted=!0;const e=Math.round(performance.now()-this.startTime),r=this.attachedError?"error":this.level,i=t??l[r],a={duration:g(e),duration_ms:e,event:this.name,timestamp:this.timestamp,...this.data};this.service&&(a.service=this.service),this.status!==void 0&&(a.status=this.status),this.attachedError&&(a.error=p(this.attachedError)),this.requestLogs.length>0&&(a.requestLogs=this.requestLogs);const o=this.pail[i];o({message:a})}error(t,e,r){return e&&(this.attachedError=e),this.addLogEntry("error",t,r)}finish(t){t?.status!==void 0&&(this.status=t.status),t?.error&&(this.attachedError=t.error),this.emit()}getData(){return this.data}getLevel(){return this.attachedError?"error":this.level}getRequestLogs(){return this.requestLogs}info(t,e){return this.addLogEntry("info",t,e)}set(t){return this.data=u(this.data,t),this}setError(t){return this.attachedError=t,this}setStatus(t){return this.status=t,this}warn(t,e){return this.addLogEntry("warn",t,e)}[Symbol.dispose](){this.autoEmit&&!this.emitted&&this.emit()}addLogEntry(t,e,r){const i={level:t,message:e,timestamp:new Date().toISOString()};return r&&(i.context=r),this.requestLogs.push(i),this.escalateLevel(t),this}escalateLevel(t){(h[t]??0)>(h[this.level]??0)&&(this.level=t)}}const y=s=>new v(s);export{v as WideEvent,y as createWideEvent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/pail",
3
- "version": "4.0.0-alpha.21",
3
+ "version": "4.0.0-alpha.23",
4
4
  "description": "Highly configurable Logger for Node.js, Edge and Browser.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -229,19 +229,19 @@
229
229
  "LICENSE.md"
230
230
  ],
231
231
  "dependencies": {
232
- "@visulima/colorize": "2.0.0-alpha.13",
233
- "@visulima/interactive-manager": "1.0.0-alpha.4"
232
+ "@visulima/colorize": "2.0.0-alpha.15",
233
+ "@visulima/interactive-manager": "1.0.0-alpha.5"
234
234
  },
235
235
  "peerDependencies": {
236
236
  "@opentelemetry/api": "^1.9.1",
237
237
  "@sveltejs/kit": ">=2.0",
238
- "@visulima/redact": "3.0.0-alpha.13",
238
+ "@visulima/redact": "3.0.0-alpha.14",
239
239
  "elysia": ">=1.0",
240
240
  "express": ">=4.0",
241
241
  "fastify": ">=4.0",
242
242
  "hono": ">=4.0",
243
243
  "next": ">=14.0",
244
- "rotating-file-stream": "3.2.9"
244
+ "rotating-file-stream": ">=3.2.9"
245
245
  },
246
246
  "peerDependenciesMeta": {
247
247
  "@opentelemetry/api": {
@@ -1 +0,0 @@
1
- import{E as O}from"./constants-ep2nsfdy.js";var d=Object.defineProperty,v=(e,r)=>d(e,"name",{value:r,configurable:!0});const j=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}});var h=Object.defineProperty,l=v((e,r)=>h(e,"name",{value:r,configurable:!0}),"i");const S=l(e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},"isPlainObject"),p=new WeakSet,g=l(e=>{const r=Object.getOwnPropertyNames(e);for(const n of r){const t=Object.getOwnPropertyDescriptor(e,n);t&&(t.enumerable||Object.defineProperty(e,n,{...t,enumerable:!0}),t.value&&typeof t.value=="object"&&!Array.isArray(t.value)&&(Object.getPrototypeOf(t.value)===Object.prototype||Object.getPrototypeOf(t.value)===null)&&g(t.value))}},"makePropertiesEnumerable"),P=l(e=>{p.add(e);const r=e.toJSON();return p.delete(e),Object.isExtensible(r)&&g(r),r},"toJSON"),m=l((e,r,n,t,o=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.has(e)?"[Circular]":(n+=1,f(e,t,r,n));if(t.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(S(e)){if(o.has(e))return"[Circular]";if(t.maxDepth!==void 0&&t.maxDepth!==Number.POSITIVE_INFINITY&&n+1>=t.maxDepth)return{};n+=1,o.add(e);const i={};for(const u in e)i[u]=m(e[u],r,n,t,o);return o.delete(e),i}try{return e}catch{return"[Not Available]"}},"serializeValue"),f=l((e,r,n,t)=>{if(n.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return P(e);const o=Object.create(j);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const u=[];for(const a of e.errors){if(!(a instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(n.has(a))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;u.push(f(a,r,n,t))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:u,writable:!0})}const i=e.cause;if(i!=null)if(i instanceof Error)n.has(i)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:f(i,r,n,t),writable:!0});else{const u=m(i,n,t,r);Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:u,writable:!0})}for(const u in e){if(u==="name"||u==="message"||u==="stack"||u==="cause"||u==="errors")continue;const a=e[u],c=m(a,n,t,r);Object.defineProperty(o,u,{configurable:!0,enumerable:!0,value:c,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const u of r.exclude)try{delete o[u]}catch{}return o},"_serialize"),y=l((e,r={})=>f(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0),"serialize");class N{stringify;errorOptions;constructor(r={}){this.errorOptions=r.error??{}}setStringify(r){this.stringify=r}log(r){const{context:n,error:t,file:o,message:i,type:u,...a}=r;if(a.label&&(a.label=a.label.trim()),o&&(a.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),a.message=i===O?void 0:i,t&&(a.error=y(t,this.errorOptions)),n){const c=[];for(let b=0;b<n.length;b+=1){const s=n[b];s!==O&&(s instanceof Error?c.push(y(s,this.errorOptions)):c.push(s))}a.context=c}this._log(this.stringify(a),u.level)}}export{N as AbstractJsonReporter};
@@ -1 +0,0 @@
1
- import{E as O}from"./constants-DKfCaSUR.js";var d=Object.defineProperty,v=(e,r)=>d(e,"name",{value:r,configurable:!0});const j=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}});var h=Object.defineProperty,l=v((e,r)=>h(e,"name",{value:r,configurable:!0}),"i");const S=l(e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},"isPlainObject"),p=new WeakSet,g=l(e=>{const r=Object.getOwnPropertyNames(e);for(const n of r){const t=Object.getOwnPropertyDescriptor(e,n);t&&(t.enumerable||Object.defineProperty(e,n,{...t,enumerable:!0}),t.value&&typeof t.value=="object"&&!Array.isArray(t.value)&&(Object.getPrototypeOf(t.value)===Object.prototype||Object.getPrototypeOf(t.value)===null)&&g(t.value))}},"makePropertiesEnumerable"),P=l(e=>{p.add(e);const r=e.toJSON();return p.delete(e),Object.isExtensible(r)&&g(r),r},"toJSON"),m=l((e,r,n,t,o=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.has(e)?"[Circular]":(n+=1,f(e,t,r,n));if(t.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(S(e)){if(o.has(e))return"[Circular]";if(t.maxDepth!==void 0&&t.maxDepth!==Number.POSITIVE_INFINITY&&n+1>=t.maxDepth)return{};n+=1,o.add(e);const i={};for(const u in e)i[u]=m(e[u],r,n,t,o);return o.delete(e),i}try{return e}catch{return"[Not Available]"}},"serializeValue"),f=l((e,r,n,t)=>{if(n.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return P(e);const o=Object.create(j);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const u=[];for(const a of e.errors){if(!(a instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(n.has(a))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;u.push(f(a,r,n,t))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:u,writable:!0})}const i=e.cause;if(i!=null)if(i instanceof Error)n.has(i)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:f(i,r,n,t),writable:!0});else{const u=m(i,n,t,r);Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:u,writable:!0})}for(const u in e){if(u==="name"||u==="message"||u==="stack"||u==="cause"||u==="errors")continue;const a=e[u],c=m(a,n,t,r);Object.defineProperty(o,u,{configurable:!0,enumerable:!0,value:c,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const u of r.exclude)try{delete o[u]}catch{}return o},"_serialize"),y=l((e,r={})=>f(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0),"serialize");class N{stringify;errorOptions;constructor(r={}){this.errorOptions=r.error??{}}setStringify(r){this.stringify=r}log(r){const{context:n,error:t,file:o,message:i,type:u,...a}=r;if(a.label&&(a.label=a.label.trim()),o&&(a.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),a.message=i===O?void 0:i,t&&(a.error=y(t,this.errorOptions)),n){const c=[];for(let b=0;b<n.length;b+=1){const s=n[b];s!==O&&(s instanceof Error?c.push(y(s,this.errorOptions)):c.push(s))}a.context=c}this._log(this.stringify(a),u.level)}}export{N as AbstractJsonReporter};
@@ -1 +0,0 @@
1
- import{AbstractJsonReporter as t}from"./AbstractJsonReporter-CVwjgboT.js";import{o as s}from"./write-console-log-based-on-level-DDSKGBKj.js";class c extends t{constructor(o={}){super(o)}_log(o,r){s(r)(o)}}export{c as default};