@visulima/pail 1.0.0 → 1.1.1

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 (105) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +3 -3
  3. package/dist/{abstract-pretty-reporter-doXJ0wsq.d.ts → abstract-pretty-reporter-L82dKD7X.d.ts} +1 -2
  4. package/dist/{abstract-pretty-reporter-dDQbeuZX.d.cts → abstract-pretty-reporter-SBWxNXW5.d.cts} +1 -2
  5. package/dist/chunk-2SZMC2SJ.cjs +13 -0
  6. package/dist/chunk-2SZMC2SJ.cjs.map +1 -0
  7. package/dist/chunk-576JQ6DN.js +9 -0
  8. package/dist/chunk-576JQ6DN.js.map +1 -0
  9. package/dist/chunk-5MNFJRLM.cjs +10 -0
  10. package/dist/chunk-5MNFJRLM.cjs.map +1 -0
  11. package/dist/{chunk-4RK45K5E.cjs → chunk-AFMDCM5W.js} +2 -4
  12. package/dist/chunk-AFMDCM5W.js.map +1 -0
  13. package/dist/chunk-ETY4VGL2.js +21 -0
  14. package/dist/chunk-ETY4VGL2.js.map +1 -0
  15. package/dist/chunk-F4FJCQ4L.cjs +9 -0
  16. package/dist/chunk-F4FJCQ4L.cjs.map +1 -0
  17. package/dist/chunk-KERJDMYV.js +8 -0
  18. package/dist/chunk-KERJDMYV.js.map +1 -0
  19. package/dist/{chunk-PVAYQO5O.js → chunk-N2UPJYJR.cjs} +4 -2
  20. package/dist/chunk-N2UPJYJR.cjs.map +1 -0
  21. package/dist/{chunk-EBP7SMYV.js → chunk-NF47XQ47.js} +3 -3
  22. package/dist/{chunk-EBP7SMYV.js.map → chunk-NF47XQ47.js.map} +1 -1
  23. package/dist/chunk-O34IIMWQ.cjs +31 -0
  24. package/dist/chunk-O34IIMWQ.cjs.map +1 -0
  25. package/dist/{chunk-MU2CRXVO.cjs → chunk-QINSQ6TU.cjs} +1 -1
  26. package/dist/{chunk-MU2CRXVO.cjs.map → chunk-QINSQ6TU.cjs.map} +1 -1
  27. package/dist/chunk-SR3Q3EUO.js +7 -0
  28. package/dist/chunk-SR3Q3EUO.js.map +1 -0
  29. package/dist/chunk-TAH23BHM.js +5 -0
  30. package/dist/chunk-TAH23BHM.js.map +1 -0
  31. package/dist/chunk-YP3U3DTV.cjs +10 -0
  32. package/dist/chunk-YP3U3DTV.cjs.map +1 -0
  33. package/dist/chunk-ZB7IIFHO.js +7 -0
  34. package/dist/chunk-ZB7IIFHO.js.map +1 -0
  35. package/dist/chunk-ZJMTPHZR.cjs +7 -0
  36. package/dist/chunk-ZJMTPHZR.cjs.map +1 -0
  37. package/dist/index.browser.cjs +7 -8
  38. package/dist/index.browser.cjs.map +1 -1
  39. package/dist/index.browser.d.cts +4 -5
  40. package/dist/index.browser.d.ts +4 -5
  41. package/dist/index.browser.js +6 -7
  42. package/dist/index.browser.js.map +1 -1
  43. package/dist/index.server.cjs +16 -17
  44. package/dist/index.server.cjs.map +1 -1
  45. package/dist/index.server.d.cts +4 -5
  46. package/dist/index.server.d.ts +4 -5
  47. package/dist/index.server.js +14 -15
  48. package/dist/index.server.js.map +1 -1
  49. package/dist/{pail.browser-DH-2bBhK.d.ts → pail.browser-0Ej0KEkV.d.ts} +1 -2
  50. package/dist/{pail.browser-eQgV1vak.d.cts → pail.browser-qG_FNUeK.d.cts} +1 -2
  51. package/dist/processor.browser.cjs +2 -3
  52. package/dist/processor.browser.d.cts +1 -2
  53. package/dist/processor.browser.d.ts +1 -2
  54. package/dist/processor.browser.js +1 -2
  55. package/dist/processor.server.cjs +2 -3
  56. package/dist/processor.server.cjs.map +1 -1
  57. package/dist/processor.server.d.cts +1 -2
  58. package/dist/processor.server.d.ts +1 -2
  59. package/dist/processor.server.js +1 -2
  60. package/dist/processor.server.js.map +1 -1
  61. package/dist/reporter.browser.cjs +7 -8
  62. package/dist/reporter.browser.cjs.map +1 -1
  63. package/dist/reporter.browser.d.cts +2 -3
  64. package/dist/reporter.browser.d.ts +2 -3
  65. package/dist/reporter.browser.js +5 -6
  66. package/dist/reporter.browser.js.map +1 -1
  67. package/dist/reporter.server.cjs +13 -14
  68. package/dist/reporter.server.cjs.map +1 -1
  69. package/dist/reporter.server.d.cts +2 -3
  70. package/dist/reporter.server.d.ts +2 -3
  71. package/dist/reporter.server.js +10 -11
  72. package/dist/reporter.server.js.map +1 -1
  73. package/dist/{types.d-RNxsa9NR.d.cts → types--_CcxoUw.d.cts} +19 -51
  74. package/dist/{types.d-RNxsa9NR.d.ts → types--_CcxoUw.d.ts} +19 -51
  75. package/package.json +6 -9
  76. package/dist/chunk-32FAOPTJ.cjs +0 -10
  77. package/dist/chunk-32FAOPTJ.cjs.map +0 -1
  78. package/dist/chunk-46NTLZF7.cjs +0 -10
  79. package/dist/chunk-46NTLZF7.cjs.map +0 -1
  80. package/dist/chunk-4RK45K5E.cjs.map +0 -1
  81. package/dist/chunk-57OYT2NC.js +0 -7
  82. package/dist/chunk-57OYT2NC.js.map +0 -1
  83. package/dist/chunk-6ATEEAVC.cjs +0 -9
  84. package/dist/chunk-6ATEEAVC.cjs.map +0 -1
  85. package/dist/chunk-7OFJLC7L.cjs +0 -7
  86. package/dist/chunk-7OFJLC7L.cjs.map +0 -1
  87. package/dist/chunk-FJCEDFRI.js +0 -9
  88. package/dist/chunk-FJCEDFRI.js.map +0 -1
  89. package/dist/chunk-G62M5WJH.js +0 -8
  90. package/dist/chunk-G62M5WJH.js.map +0 -1
  91. package/dist/chunk-GZRIZCRG.cjs +0 -32
  92. package/dist/chunk-GZRIZCRG.cjs.map +0 -1
  93. package/dist/chunk-HKIS52YX.js +0 -22
  94. package/dist/chunk-HKIS52YX.js.map +0 -1
  95. package/dist/chunk-ICPHL4AR.js +0 -8
  96. package/dist/chunk-ICPHL4AR.js.map +0 -1
  97. package/dist/chunk-IQF3SXQR.cjs +0 -10
  98. package/dist/chunk-IQF3SXQR.cjs.map +0 -1
  99. package/dist/chunk-JYHWIRFR.js +0 -5
  100. package/dist/chunk-JYHWIRFR.js.map +0 -1
  101. package/dist/chunk-PVAYQO5O.js.map +0 -1
  102. package/dist/chunk-Y36365SA.cjs +0 -13
  103. package/dist/chunk-Y36365SA.cjs.map +0 -1
  104. package/dist/chunk-YKHMQW6V.js +0 -5
  105. package/dist/chunk-YKHMQW6V.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,30 @@
1
+ ## @visulima/pail [1.1.1](https://github.com/visulima/visulima/compare/@visulima/pail@1.1.0...@visulima/pail@1.1.1) (2024-03-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fixed logger function type, for better input typing ([f08bbd4](https://github.com/visulima/visulima/commit/f08bbd44b33e62dc0f04fb516557541abaec6863))
7
+
8
+ ## @visulima/pail [1.1.0](https://github.com/visulima/visulima/compare/@visulima/pail@1.0.0...@visulima/pail@1.1.0) (2024-03-04)
9
+
10
+
11
+ ### Features
12
+
13
+ * adding new gradient helper ([#324](https://github.com/visulima/visulima/issues/324)) ([49b1ab0](https://github.com/visulima/visulima/commit/49b1ab0c94b1e6c272ae41e2477b064150c9ec49))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * fixed all found type issues ([eaa40d1](https://github.com/visulima/visulima/commit/eaa40d11f3fc056dfddcc25404bf109587ef2862))
19
+ * minifyWhitespace on prod build, removed @tsconfig/* configs ([410cb73](https://github.com/visulima/visulima/commit/410cb737c44c445a0479bdd49b4100d5daf2d83d))
20
+
21
+
22
+
23
+ ### Dependencies
24
+
25
+ * **@visulima/colorize:** upgraded to 1.3.0
26
+ * **@visulima/fmt:** upgraded to 1.1.3
27
+
1
28
  ## @visulima/pail 1.0.0 (2024-02-28)
2
29
 
3
30
 
package/README.md CHANGED
@@ -260,15 +260,15 @@ pail.info("This is a log message 1");
260
260
 
261
261
  setTimeout(() => {
262
262
  interactive.await("[%d/4] - Process A", 1);
263
- setTimeout(() => {
264
- interactive.success("[%d/4] - Process A", 2);
263
+ setTimeout(() => {
264
+ interactive.success("[%d/4] - Process A", 2);
265
265
  setTimeout(() => {
266
266
  interactive.await("[%d/4] - Process B", 3);
267
267
  setTimeout(() => {
268
268
  interactive.error("[%d/4] - Process B", 4);
269
269
  }, 1000);
270
270
  }, 1000);
271
- }, 1000);
271
+ }, 1000);
272
272
  });
273
273
 
274
274
  pail.info("This is a log message 2");
@@ -1,6 +1,5 @@
1
1
  import { stringify } from 'safe-stable-stringify';
2
- import { LiteralUnion } from 'type-fest';
3
- import { g as StringifyAwareReporter, f as ReadonlyMeta, E as ExtendedRfc5424LogLevels, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, a as DefaultLogTypes } from './types.d-RNxsa9NR.js';
2
+ import { h as StringifyAwareReporter, g as ReadonlyMeta, e as LiteralUnion, E as ExtendedRfc5424LogLevels, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, a as DefaultLogTypes } from './types--_CcxoUw.js';
4
3
 
5
4
  declare abstract class AbstractJsonReporter<L extends string = never> implements StringifyAwareReporter<L> {
6
5
  protected _stringify: typeof stringify | undefined;
@@ -1,6 +1,5 @@
1
1
  import { stringify } from 'safe-stable-stringify';
2
- import { LiteralUnion } from 'type-fest';
3
- import { g as StringifyAwareReporter, f as ReadonlyMeta, E as ExtendedRfc5424LogLevels, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, a as DefaultLogTypes } from './types.d-RNxsa9NR.cjs';
2
+ import { h as StringifyAwareReporter, g as ReadonlyMeta, e as LiteralUnion, E as ExtendedRfc5424LogLevels, c as LoggerTypesAwareReporter, d as LoggerTypesConfig, a as DefaultLogTypes } from './types--_CcxoUw.cjs';
4
3
 
5
4
  declare abstract class AbstractJsonReporter<L extends string = never> implements StringifyAwareReporter<L> {
6
5
  protected _stringify: typeof stringify | undefined;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var chunkN2UPJYJR_cjs = require('./chunk-N2UPJYJR.cjs');
4
+ var chunkQINSQ6TU_cjs = require('./chunk-QINSQ6TU.cjs');
5
+ var safeStableStringify = require('safe-stable-stringify');
6
+
7
+ var u=class{log(e){let{context:r=[],message:t,type:o}=e;chunkN2UPJYJR_cjs.a(o.level)(t,...r);}};var w=s=>s===void 0?[]:Array.isArray(s)?s:[s];var v=(s,e)=>{let r={...s};return Object.keys(e).forEach(t=>{r[t]={...r[t],...e[t]};}),r};var x=(s,e)=>s.length>=e?s:s.padEnd(e);var P={badge:void 0,context:void 0,error:void 0,label:void 0,message:void 0,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0},L=class{timersMap;countMap;seqTimers;lastLog;logLevels;disabled;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;constructor(e){this.throttle=e.throttle??1e3,this.throttleMin=e.throttleMin??5,this.stringify=safeStableStringify.configure({strict:!0}),this.startTimerMessage=e.messages?.timerStart??"Initialized timer...",this.endTimerMessage=e.messages?.timerEnd??"Timer run for:",this.types=v(chunkQINSQ6TU_cjs.b,e.types??{}),this.longestLabel=chunkQINSQ6TU_cjs.c(this.types),this.logLevels={...chunkQINSQ6TU_cjs.a,...e.logLevels},this.generalLogLevel=this._normalizeLogLevel(e.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=e.disabled??!1,this.scopeName=w(e.scope).filter(Boolean),this.timersMap=new Map,this.countMap=new Map,this.groups=[],this.seqTimers=new Set;for(let r in this.types)this[r]=this._logger.bind(this,r,!1);this.lastLog={},Array.isArray(e.reporters)&&this.registerReporters(e.reporters),this.rawReporter=this.extendReporter(e.rawReporter??new u),Array.isArray(e.processors)&&this.registerProcessors(e.processors);}wrapConsole(){for(let e in this.types)console["__"+e]||(console["__"+e]=console[e]),console[e]=this[e].log;}restoreConsole(){for(let e in this.types)console["__"+e]&&(console[e]=console["__"+e],delete console["__"+e]);}wrapException(){process.on("uncaughtException",e=>{this.error(e);}),process.on("unhandledRejection",e=>{this.error(e);});}disable(){this.disabled=!0;}enable(){this.disabled=!1;}isEnabled(){return !this.disabled}scope(...e){if(e.length===0)throw new Error("No scope name was defined.");return this.scopeName=e.flat(),this}unscope(){this.scopeName=[];}time(e="default"){this.seqTimers.has(e)?this._logger("warn",!1,{message:"Timer '"+e+"' already exists",prefix:e}):(this.seqTimers.add(e),this.timersMap.set(e,Date.now()),this._logger("start",!1,{message:this.startTimerMessage,prefix:e}));}timeLog(e,...r){if(!e&&this.seqTimers.size>0&&(e=[...this.seqTimers].pop()),e&&this.timersMap.has(e)){let t=Date.now()-this.timersMap.get(e);this._logger("info",!1,{context:r,message:t<1e3?t+" ms":(t/1e3).toFixed(2)+" s",prefix:e});}else this._logger("warn",!1,{context:r,message:"Timer not found",prefix:e});}timeEnd(e){if(!e&&this.seqTimers.size>0&&(e=[...this.seqTimers].pop()),e&&this.timersMap.has(e)){let r=Date.now()-this.timersMap.get(e);this.timersMap.delete(e),this._logger("stop",!1,{message:this.endTimerMessage+" "+(r<1e3?r+" ms":(r/1e3).toFixed(2)+" s"),prefix:e});}}group(e="console.group"){typeof window>"u"?console.group(e):this.groups.push(e);}groupEnd(){typeof window>"u"?console.groupEnd():this.groups.pop();}count(e="default"){let r=this.countMap.get(e)??0;this.countMap.set(e,r+1),this._logger("log",!1,{message:e+": "+(r+1),prefix:e});}countReset(e="default"){this.countMap.has(e)?this.countMap.delete(e):this._logger("warn",!1,{message:"Count for "+e+" does not exist",prefix:e});}clear(){console.clear();}raw(e,...r){this.disabled||this._logger("log",!0,{context:r,message:e});}extendReporter(e){return typeof e.setLoggerTypes=="function"&&e.setLoggerTypes(this.types),typeof e.setStringify=="function"&&e.setStringify(this.stringify),e}registerReporters(e){for(let r of e)this.reporters.add(this.extendReporter(r));}_report(e,r){if(r)this.rawReporter.log(Object.freeze(e));else for(let t of this.reporters)t.log(Object.freeze(e));}registerProcessors(e){for(let r of e)typeof r.setStringify=="function"&&r.setStringify(this.stringify),this.processors.add(r);}_normalizeLogLevel(e){return e&&this.logLevels[e]?e:"debug"}_buildMeta(e,r,...t){let o={...P};if(o.type={level:r.logLevel,name:e},o.groups=this.groups,o.scope=this.scopeName,o.date=new Date,t.length===1&&typeof t[0]=="object"&&t[0]!==null)if(t[0]instanceof Error)o.error=t[0];else if("message"in t[0]){let{context:i,message:c,prefix:d,suffix:n}=t[0];i&&(o.context=i),d&&(o.prefix=d),n&&(o.suffix=n),o.message=c;}else o.message=t[0];else t.length>1&&typeof t[0]=="string"?(o.message=t[0],o.context=t.slice(1)):o.message=t[0];return r.logLevel==="trace"&&(o.traceError=new Error("Trace")),r.badge&&(o.badge=x(r.badge,r.badge.length+1)),r.label&&(o.label=r.label),o}_logger(e,r,...t){if(this.disabled)return;let o=this._normalizeLogLevel(this.types[e].logLevel);if(this.logLevels[o]>=this.logLevels[this.generalLogLevel]){let i=this._buildMeta(e,this.types[e],...t),c=(n=!1)=>{let p=(this.lastLog.count||0)-this.throttleMin;if(this.lastLog.object&&p>0){let f={...this.lastLog.object};p>1&&(f.repeated=p),this._report(f,r),this.lastLog.count=1;}if(n){for(let f of this.processors)i={...f.process(i)};this.lastLog.object=i,this._report(i,r);}};clearTimeout(this.lastLog.timeout);let d=this.lastLog.time&&i.date?new Date(i.date).getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=new Date(i.date),d<this.throttle)try{let n=JSON.stringify([i.label,i.scope,i.type,i.message,i.prefix,i.suffix,i.context]),p=this.lastLog.serialized===n;if(this.lastLog.serialized=n,p&&(this.lastLog.count=(this.lastLog.count||0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(c,this.throttle);return}}catch{}c(!0);}}},V=L;var l=Symbol("circular-reference-tag"),y=Symbol("raw-error-ref"),E=Object.create({},{aggregateErrors:{enumerable:!0,value:void 0,writable:!0},cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},raw:{enumerable:!1,get(){return this[y]},set(s){this[y]=s;}},stack:{enumerable:!0,value:void 0,writable:!0}});Object.defineProperty(E,y,{value:{},writable:!0});var M=E;var g=(s,e={})=>{s[l]=void 0;let r=Object.create(M);r.name=Object.prototype.toString.call(s.constructor)==="[object Function]"?s.constructor.name:s.name,r.message=s.message,r.stack=s.stack,Array.isArray(s.errors)&&(r.aggregateErrors=s.errors.map(t=>g(t,e))),s.cause instanceof Error&&!Object.prototype.hasOwnProperty.call(s.cause,l)&&(r.cause=g(s.cause,e));for(let t in s)if(r[t]===void 0){let o=s[t];if(o instanceof Error)Object.prototype.hasOwnProperty.call(o,l)||(r[t]=g(o,e));else if(typeof o=="function")r[t]="[Function: "+(o.name||"anonymous");else try{r[t]=o;}catch{}}return delete s[l],r.raw=s,r};var R=class{_options;constructor(e={}){this._options={maxDepth:Number.POSITIVE_INFINITY,useToJSON:!0,...e};}process(e){return e.error&&(e.error=g(e.error,this._options)),e}};
8
+
9
+ exports.a = L;
10
+ exports.b = V;
11
+ exports.c = R;
12
+ //# sourceMappingURL=out.js.map
13
+ //# sourceMappingURL=chunk-2SZMC2SJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pail.browser.ts","../src/reporter/raw/raw.browser.ts","../src/util/arrayify.ts","../src/util/merge-types.ts","../src/util/pad-end.ts","../src/processor/error/error-proto.ts","../src/processor/error/error-with-cause-serializer.ts","../src/processor/error/error-processor.ts"],"names":["stringifyConfigure","RawReporter","meta","context","message","type","writeConsoleLogBasedOnLevel","arrayify","x","mergeTypes","standard","custom","types","padEnd","string_","targetLength","EMPTY_META","PailBrowserImpl","options","LOG_TYPES","getLongestLabel","EXTENDED_RFC_5424_LOG_LEVELS","error","name","label","data","span","current","arguments_","reporter","reporters","raw","processors","processor","level","typeName","prefix","suffix","messageObject","logLevel","resolveLog","newLog","repeated","lastMeta","diffTime","serializedLog","isSameLog","PailBrowser","seen","rawSymbol","errorProto","value","ErrorProto","errorWithCauseSerializer","protoError","error_","key","ErrorProcessor"],"mappings":"gGACA,OAAS,aAAaA,MAA0B,wBCEzC,IAAMC,EAAN,KAAmE,CAE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BAAmBhC,EAAyB,OAAO,IAAKiC,GAAmCF,EAAyBE,EAAQrC,CAAO,CAAC,GAI9II,EAAqB,iBAAiB,OAAS,CAAC,OAAO,UAAU,eAAe,KAAMA,EAAqB,MAAO0B,CAAmB,IACtIM,EAAW,MAAQD,EAA0B/B,EAAqB,MAAOJ,CAAO,GAIpF,QAAWsC,KAAOlC,EAEd,GAAIgC,EAAWE,CAAG,IAAM,OAAW,CAE/B,IAAML,EAAQ7B,EAAMkC,CAAkB,EAEtC,GAAIL,aAAiB,MACZ,OAAO,UAAU,eAAe,KAAKA,EAAOH,CAAmB,IAEhEM,EAAWE,CAAG,EAAIH,EAAyBF,EAAOjC,CAAO,WAEtD,OAAOiC,GAAU,WAExBG,EAAWE,CAAG,EAAI,eAAiBL,EAAM,MAAQ,iBAGjD,IAAI,CAEAG,EAAWE,CAAG,EAAIL,CACtB,MAAQ,CAER,CAER,CAIJ,cAAO7B,EAAM0B,CAA8B,EAE3CM,EAAW,IAAMhC,EAEVgC,CACX,EC/DO,IAAMG,EAAN,KAAuE,CACzD,SAEV,YAAYvC,EAAsD,CAAC,EAAG,CACzE,KAAK,SAAW,CACZ,SAAU,OAAO,kBACjB,UAAW,GACX,GAAGA,CACP,CACJ,CAEO,QAAQhB,EAAwB,CACnC,OAAIA,EAAK,QAELA,EAAK,MAAQmD,EAAyBnD,EAAK,MAAO,KAAK,QAAQ,GAG5DA,CACX,CACJ","sourcesContent":["import type { stringify } from \"safe-stable-stringify\";\nimport { configure as stringifyConfigure } from \"safe-stable-stringify\";\n\nimport { EXTENDED_RFC_5424_LOG_LEVELS, LOG_TYPES } from \"./constants\";\nimport { RawReporter } from \"./reporter/raw/raw.browser\";\nimport type {\n ConstructorOptions,\n DefaultLogTypes,\n ExtendedRfc5424LogLevels,\n LiteralUnion,\n LoggerConfiguration,\n LoggerFunction,\n LoggerTypesAwareReporter,\n LoggerTypesConfig,\n Message,\n Meta,\n Primitive,\n Processor,\n Reporter,\n StringifyAwareProcessor,\n StringifyAwareReporter,\n} from \"./types\";\nimport { arrayify } from \"./util/arrayify\";\nimport { getLongestLabel } from \"./util/get-longest-label\";\nimport { mergeTypes } from \"./util/merge-types\";\nimport { padEnd } from \"./util/pad-end\";\n\nconst EMPTY_META = {\n badge: undefined,\n context: undefined,\n error: undefined,\n label: undefined,\n message: undefined,\n prefix: undefined,\n repeated: undefined,\n scope: undefined,\n suffix: undefined,\n};\n\nexport class PailBrowserImpl<T extends string = never, L extends string = never> {\n protected timersMap: Map<string, number>;\n\n protected countMap: Map<string, number>;\n\n protected seqTimers: Set<string>;\n\n protected readonly lastLog: {\n count?: number;\n object?: Meta<L>;\n serialized?: string;\n time?: Date;\n timeout?: ReturnType<typeof setTimeout>;\n };\n\n protected readonly logLevels: Record<string, number>;\n\n protected disabled: boolean;\n\n protected scopeName: string[];\n\n protected readonly types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;\n\n protected readonly longestLabel: string;\n\n protected readonly processors: Set<Processor<L>>;\n\n protected readonly generalLogLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>;\n\n protected reporters: Set<Reporter<L>>;\n\n protected readonly throttle: number;\n\n protected readonly throttleMin: number;\n\n protected readonly stringify: typeof stringify;\n\n protected groups: string[];\n\n protected readonly startTimerMessage: string;\n\n protected readonly endTimerMessage: string;\n\n protected rawReporter: Reporter<L>;\n\n public constructor(options: ConstructorOptions<T, L>) {\n this.throttle = options.throttle ?? 1000;\n this.throttleMin = options.throttleMin ?? 5;\n\n this.stringify = stringifyConfigure({\n strict: true,\n });\n\n this.startTimerMessage = options.messages?.timerStart ?? \"Initialized timer...\";\n this.endTimerMessage = options.messages?.timerEnd ?? \"Timer run for:\";\n this.types = mergeTypes<L, T>(LOG_TYPES, (options.types ?? {}) as LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>);\n this.longestLabel = getLongestLabel<L, T>(this.types);\n\n this.logLevels = { ...EXTENDED_RFC_5424_LOG_LEVELS, ...options.logLevels };\n this.generalLogLevel = this._normalizeLogLevel(options.logLevel);\n\n this.reporters = new Set();\n this.processors = new Set();\n\n this.disabled = options.disabled ?? false;\n\n this.scopeName = arrayify(options.scope).filter(Boolean) as string[];\n\n this.timersMap = new Map();\n this.countMap = new Map();\n\n this.groups = [];\n\n this.seqTimers = new Set();\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,guard-for-in\n for (const type in this.types) {\n // @ts-expect-error - dynamic property\n // eslint-disable-next-line security/detect-object-injection\n this[type] = this._logger.bind(this, type as T, false);\n }\n\n // Track of last log\n this.lastLog = {};\n\n if (Array.isArray(options.reporters)) {\n this.registerReporters(options.reporters);\n }\n\n this.rawReporter = this.extendReporter(options.rawReporter ?? new RawReporter<L>());\n\n if (Array.isArray(options.processors)) {\n this.registerProcessors(options.processors);\n }\n }\n\n public wrapConsole(): void {\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const type in this.types) {\n // Backup original value\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (!(console as any)[\"__\" + type]) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,security/detect-object-injection\n (console as any)[\"__\" + type] = (console as any)[type];\n }\n // Override\n // @TODO: Fix typings\n // @ts-expect-error - dynamic property\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,security/detect-object-injection\n (console as any)[type] = (this as unknown as PailBrowserImpl<T, L>)[type as keyof PailBrowserImpl<T, L>].log;\n }\n }\n\n public restoreConsole(): void {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const type in this.types) {\n // Restore if backup is available\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((console as any)[\"__\" + type]) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,security/detect-object-injection\n (console as any)[type] = (console as any)[\"__\" + type];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-dynamic-delete\n delete (console as any)[\"__\" + type];\n }\n }\n }\n\n public wrapException(): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n process.on(\"uncaughtException\", (error: any) => {\n // @TODO: Fix typings\n // @ts-expect-error - dynamic property\n (this as unknown as PailBrowserImpl<T, L>).error(error);\n });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n process.on(\"unhandledRejection\", (error: any) => {\n // @TODO: Fix typings\n // @ts-expect-error - dynamic property\n (this as unknown as PailBrowserImpl<T, L>).error(error);\n });\n }\n\n /**\n * Disables logging\n */\n public disable(): void {\n this.disabled = true;\n }\n\n /**\n * Enables logging\n */\n public enable(): void {\n this.disabled = false;\n }\n\n public isEnabled(): boolean {\n return !this.disabled;\n }\n\n public scope<N extends string = T>(...name: string[]): PailBrowserType<N, L> {\n if (name.length === 0) {\n throw new Error(\"No scope name was defined.\");\n }\n\n this.scopeName = name.flat();\n\n return this as unknown as PailBrowserType<N, L>;\n }\n\n public unscope(): void {\n this.scopeName = [];\n }\n\n public time(label = \"default\"): void {\n if (this.seqTimers.has(label)) {\n this._logger(\"warn\", false, {\n message: \"Timer '\" + label + \"' already exists\",\n prefix: label,\n });\n } else {\n this.seqTimers.add(label);\n this.timersMap.set(label, Date.now());\n\n this._logger(\"start\", false, {\n message: this.startTimerMessage,\n prefix: label,\n });\n }\n }\n\n public timeLog(label?: string, ...data: unknown[]): void {\n if (!label && this.seqTimers.size > 0) {\n // eslint-disable-next-line no-param-reassign\n label = [...this.seqTimers].pop();\n }\n\n if (label && this.timersMap.has(label)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const span = Date.now() - this.timersMap.get(label)!;\n\n this._logger(\"info\", false, {\n context: data,\n message: span < 1000 ? span + \" ms\" : (span / 1000).toFixed(2) + \" s\",\n prefix: label,\n });\n } else {\n this._logger(\"warn\", false, {\n context: data,\n message: \"Timer not found\",\n prefix: label,\n });\n }\n }\n\n public timeEnd(label?: string): void {\n if (!label && this.seqTimers.size > 0) {\n // eslint-disable-next-line no-param-reassign\n label = [...this.seqTimers].pop();\n }\n\n if (label && this.timersMap.has(label)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const span = Date.now() - this.timersMap.get(label)!;\n\n this.timersMap.delete(label);\n\n this._logger(\"stop\", false, {\n message: this.endTimerMessage + \" \" + (span < 1000 ? span + \" ms\" : (span / 1000).toFixed(2) + \" s\"),\n prefix: label,\n });\n }\n }\n\n public group(label = \"console.group\"): void {\n if (typeof window === \"undefined\") {\n // eslint-disable-next-line no-console\n console.group(label);\n } else {\n this.groups.push(label);\n }\n }\n\n public groupEnd(): void {\n if (typeof window === \"undefined\") {\n // eslint-disable-next-line no-console\n console.groupEnd();\n } else {\n this.groups.pop();\n }\n }\n\n public count(label = \"default\"): void {\n const current = this.countMap.get(label) ?? 0;\n\n this.countMap.set(label, current + 1);\n\n this._logger(\"log\", false, {\n message: label + \": \" + (current + 1),\n prefix: label,\n });\n }\n\n public countReset(label = \"default\"): void {\n if (this.countMap.has(label)) {\n this.countMap.delete(label);\n } else {\n this._logger(\"warn\", false, {\n message: \"Count for \" + label + \" does not exist\",\n prefix: label,\n });\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n public clear(): void {\n // eslint-disable-next-line no-console\n console.clear();\n }\n\n public raw(message: string, ...arguments_: unknown[]): void {\n if (this.disabled) {\n return;\n }\n\n this._logger(\"log\", true, {\n context: arguments_,\n message,\n });\n }\n\n protected extendReporter(reporter: Reporter<L>): Reporter<L> {\n if (typeof (reporter as LoggerTypesAwareReporter<T, L>).setLoggerTypes === \"function\") {\n (reporter as LoggerTypesAwareReporter<T, L>).setLoggerTypes(this.types);\n }\n\n if (typeof (reporter as StringifyAwareReporter<L>).setStringify === \"function\") {\n (reporter as StringifyAwareReporter<L>).setStringify(this.stringify);\n }\n\n return reporter;\n }\n\n protected registerReporters(reporters: Reporter<L>[]): void {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const reporter of reporters) {\n this.reporters.add(this.extendReporter(reporter));\n }\n }\n\n private _report(meta: Meta<L>, raw: boolean): void {\n if (raw) {\n this.rawReporter.log(Object.freeze(meta));\n } else {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const reporter of this.reporters) {\n reporter.log(Object.freeze(meta));\n }\n }\n }\n\n private registerProcessors(processors: Processor<L>[]): void {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const processor of processors) {\n if (typeof (processor as StringifyAwareProcessor<L>).setStringify === \"function\") {\n (processor as StringifyAwareProcessor<L>).setStringify(this.stringify);\n }\n\n this.processors.add(processor as Processor<L>);\n }\n }\n\n private _normalizeLogLevel(level: LiteralUnion<ExtendedRfc5424LogLevels, L> | undefined): LiteralUnion<ExtendedRfc5424LogLevels, L> {\n // eslint-disable-next-line security/detect-object-injection\n return level && this.logLevels[level] ? level : \"debug\";\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity,@typescript-eslint/no-explicit-any\n private _buildMeta(typeName: string, type: Partial<LoggerConfiguration<L>>, ...arguments_: any[]): Meta<L> {\n const meta = { ...EMPTY_META } as Meta<L>;\n\n meta.type = {\n level: type.logLevel as LiteralUnion<ExtendedRfc5424LogLevels, L>,\n name: typeName,\n };\n\n meta.groups = this.groups;\n meta.scope = this.scopeName;\n meta.date = new Date();\n\n if (arguments_.length === 1 && typeof arguments_[0] === \"object\" && arguments_[0] !== null) {\n if (arguments_[0] instanceof Error) {\n // eslint-disable-next-line prefer-destructuring\n meta.error = arguments_[0];\n } else if (\"message\" in arguments_[0]) {\n const { context, message, prefix, suffix } = arguments_[0] as Message;\n\n if (context) {\n meta.context = context;\n }\n\n if (prefix) {\n meta.prefix = prefix;\n }\n\n if (suffix) {\n meta.suffix = suffix;\n }\n\n meta.message = message;\n } else {\n meta.message = arguments_[0] as Primitive | ReadonlyArray<unknown> | Record<PropertyKey, unknown>;\n }\n } else if (arguments_.length > 1 && typeof arguments_[0] === \"string\") {\n meta.message = arguments_[0] as string;\n meta.context = arguments_.slice(1);\n } else {\n // eslint-disable-next-line prefer-destructuring\n meta.message = arguments_[0];\n }\n\n if (type.logLevel === \"trace\") {\n meta.traceError = new Error(\"Trace\");\n }\n\n if (type.badge) {\n meta.badge = padEnd(type.badge, type.badge.length + 1);\n }\n\n if (type.label) {\n meta.label = type.label;\n }\n\n return meta;\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity,@typescript-eslint/no-explicit-any\n private _logger(type: LiteralUnion<DefaultLogTypes, T>, raw: boolean, ...messageObject: any[]): void {\n if (this.disabled) {\n return;\n }\n\n // eslint-disable-next-line security/detect-object-injection\n const logLevel = this._normalizeLogLevel(this.types[type].logLevel);\n\n // eslint-disable-next-line security/detect-object-injection\n if ((this.logLevels[logLevel] as number) >= (this.logLevels[this.generalLogLevel] as number)) {\n // eslint-disable-next-line security/detect-object-injection\n let meta = this._buildMeta(type, this.types[type], ...messageObject);\n\n /**\n * @param newLog false if the throttle expired and we don't want to log a duplicate\n */\n const resolveLog = (newLog = false) => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const repeated = (this.lastLog.count || 0) - this.throttleMin;\n\n if (this.lastLog.object && repeated > 0) {\n const lastMeta = { ...this.lastLog.object };\n\n if (repeated > 1) {\n lastMeta.repeated = repeated;\n }\n\n this._report(lastMeta, raw);\n\n this.lastLog.count = 1;\n }\n\n if (newLog) {\n // Apply global processors\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const processor of this.processors) {\n meta = { ...processor.process(meta) };\n }\n\n this.lastLog.object = meta;\n\n this._report(meta, raw);\n }\n };\n\n clearTimeout(this.lastLog.timeout);\n\n const diffTime = this.lastLog.time && meta.date ? new Date(meta.date as Date | string).getTime() - this.lastLog.time.getTime() : 0;\n\n this.lastLog.time = new Date(meta.date as Date | string);\n\n if (diffTime < this.throttle) {\n try {\n const serializedLog = JSON.stringify([meta.label, meta.scope, meta.type, meta.message, meta.prefix, meta.suffix, meta.context]);\n const isSameLog = this.lastLog.serialized === serializedLog;\n\n this.lastLog.serialized = serializedLog;\n\n if (isSameLog) {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n this.lastLog.count = (this.lastLog.count || 0) + 1;\n\n if (this.lastLog.count > this.throttleMin) {\n // Auto-resolve when throttle is timed out\n this.lastLog.timeout = setTimeout(resolveLog, this.throttle);\n\n return; // SPAM!\n }\n }\n } catch {\n // Circular References\n }\n }\n\n resolveLog(true);\n }\n }\n}\n\nexport type PailBrowserType<T extends string = never, L extends string = never> = PailBrowserImpl<T, L> &\n Record<DefaultLogTypes, LoggerFunction> &\n Record<T, LoggerFunction> &\n (new<TC extends string = never, LC extends string = never>(options?: ConstructorOptions<TC, LC>) => PailBrowserType<TC, LC>);\n\nexport type PailConstructor<T extends string = never, L extends string = never> = new (options?: ConstructorOptions<T, L>) => PailBrowserType<T, L>;\n\nexport const PailBrowser = PailBrowserImpl as unknown as PailBrowserType;\n","import type { ReadonlyMeta, Reporter } from \"../../types\";\nimport { writeConsoleLogBasedOnLevel } from \"../../util/write-console-log\";\n\nexport class RawReporter<L extends string = never> implements Reporter<L> {\n // eslint-disable-next-line class-methods-use-this\n public log(meta: ReadonlyMeta<L>): void {\n const { context = [], message, type } = meta;\n\n const consoleLogFunction = writeConsoleLogBasedOnLevel(type.level);\n\n consoleLogFunction(message, ...context);\n }\n}\n","export const arrayify = <T>(x: T | T[]): T[] => {\n if (x === undefined) {\n return [] as T[];\n }\n\n return Array.isArray(x) ? x : ([x] as T[]);\n};\n","import type { DefaultLoggerTypes, DefaultLogTypes, LiteralUnion, LoggerTypesConfig } from \"../types\";\n\nexport const mergeTypes = <L extends string, T extends string>(\n standard: DefaultLoggerTypes<L>,\n custom: LoggerTypesConfig<T, L>,\n): LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L> => {\n const types = { ...standard } as LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;\n\n Object.keys(custom).forEach((type) => {\n types[type as T] = { ...types[type as T], ...custom[type as T] };\n });\n\n return types;\n};\n","export const padEnd = (string_: string, targetLength: number): string => {\n if (string_.length >= targetLength) {\n return string_;\n }\n\n return string_.padEnd(targetLength);\n};\n","// eslint-disable-next-line import/exports-last\nexport const seen = Symbol(\"circular-reference-tag\");\n\n// eslint-disable-next-line import/exports-last,import/no-unused-modules\nexport const rawSymbol = Symbol(\"raw-error-ref\");\n\nconst errorProto = Object.create(\n {},\n {\n aggregateErrors: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n cause: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n code: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n message: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n name: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n raw: {\n enumerable: false,\n get() {\n // eslint-disable-next-line security/detect-object-injection\n return this[rawSymbol];\n },\n set(value) {\n // eslint-disable-next-line security/detect-object-injection\n this[rawSymbol] = value;\n },\n },\n stack: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n },\n) as SerializedError;\n\nObject.defineProperty(errorProto, rawSymbol, {\n value: {},\n writable: true,\n});\n\nexport const ErrorProto = errorProto;\n\nexport type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {\n aggregateErrors?: SerializedError<ErrorType>[];\n cause?: unknown;\n code?: string;\n message: string;\n name: string;\n raw?: ErrorType;\n stack?: string;\n};\n","import type { SerializedError } from \"./error-proto\";\nimport { ErrorProto, seen } from \"./error-proto\";\n\ntype CauseError = Error & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n cause: any;\n};\n\ntype Options = {\n readonly maxDepth?: number;\n readonly useToJSON?: boolean;\n};\n\n/**\n * Serialize an `Error` object into a plain object.\n *\n * - Non-error values are passed through.\n * - Custom properties are preserved.\n * - Buffer properties are replaced with `[object Buffer]`.\n * - Circular references are handled.\n * - If the input object has a `.toJSON()` method, then it's called instead of serializing the object's properties.\n * - It's up to `.toJSON()` implementation to handle circular references and enumerability of the properties.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const errorWithCauseSerializer = (error: AggregateError | Error, options: Options = {}): SerializedError => {\n // @ts-expect-error - dynamic property\n // eslint-disable-next-line no-param-reassign\n error[seen as keyof Error] = undefined; // tag to prevent re-looking at this\n\n const protoError = Object.create(ErrorProto as object) as SerializedError;\n\n protoError.name = Object.prototype.toString.call(error.constructor) === \"[object Function]\" ? error.constructor.name : error.name;\n protoError.message = error.message;\n protoError.stack = error.stack;\n\n if (Array.isArray((error as AggregateError).errors)) {\n protoError.aggregateErrors = (error as AggregateError).errors.map((error_: AggregateError | Error) => errorWithCauseSerializer(error_, options));\n }\n\n // Handle aggregate errors\n if ((error as CauseError).cause instanceof Error && !Object.prototype.hasOwnProperty.call((error as CauseError).cause, seen as PropertyKey)) {\n protoError.cause = errorWithCauseSerializer((error as CauseError).cause, options);\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const key in error) {\n // eslint-disable-next-line security/detect-object-injection\n if (protoError[key] === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const value = error[key as keyof Error] as any;\n\n if (value instanceof Error) {\n if (!Object.prototype.hasOwnProperty.call(value, seen as PropertyKey)) {\n // eslint-disable-next-line security/detect-object-injection\n protoError[key] = errorWithCauseSerializer(value, options);\n }\n } else if (typeof value === \"function\") {\n // eslint-disable-next-line security/detect-object-injection\n protoError[key] = \"[Function: \" + (value.name || \"anonymous\");\n } else {\n // Gracefully handle non-configurable errors like `DOMException`.\n try {\n // eslint-disable-next-line security/detect-object-injection\n protoError[key] = value;\n } catch {\n /* empty */\n }\n }\n }\n }\n\n // eslint-disable-next-line no-param-reassign,@typescript-eslint/no-dynamic-delete\n delete error[seen as unknown as keyof Error]; // clean up tag in case err is serialized again later\n\n protoError.raw = error;\n\n return protoError;\n};\n","import type { Meta, Processor } from \"../../types\";\nimport type { SerializedError } from \"./error-proto\";\nimport { errorWithCauseSerializer } from \"./error-with-cause-serializer\";\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace VisulimaPail {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface CustomMeta<L> {\n error: SerializedError | undefined;\n }\n }\n}\n\nexport class ErrorProcessor<L extends string = never> implements Processor<L> {\n private readonly _options: { maxDepth: number; useToJSON: boolean };\n\n public constructor(options: { maxDepth?: number; useToJSON?: boolean } = {}) {\n this._options = {\n maxDepth: Number.POSITIVE_INFINITY,\n useToJSON: true,\n ...options,\n };\n }\n\n public process(meta: Meta<L>): Meta<L> {\n if (meta.error) {\n // eslint-disable-next-line no-param-reassign\n meta.error = errorWithCauseSerializer(meta.error, this._options);\n }\n\n return meta;\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { a as a$1 } from './chunk-AFMDCM5W.js';
2
+ import { b, c as c$1, a } from './chunk-NF47XQ47.js';
3
+ import { configure } from 'safe-stable-stringify';
4
+
5
+ var L=class{log(e){let{context:r=[],message:t,type:o}=e;a$1(o.level)(t,...r);}};var v=s=>s===void 0?[]:Array.isArray(s)?s:[s];var x=(s,e)=>{let r={...s};return Object.keys(e).forEach(t=>{r[t]={...r[t],...e[t]};}),r};var E=(s,e)=>s.length>=e?s:s.padEnd(e);var C={badge:void 0,context:void 0,error:void 0,label:void 0,message:void 0,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0},y=class{timersMap;countMap;seqTimers;lastLog;logLevels;disabled;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;constructor(e){this.throttle=e.throttle??1e3,this.throttleMin=e.throttleMin??5,this.stringify=configure({strict:!0}),this.startTimerMessage=e.messages?.timerStart??"Initialized timer...",this.endTimerMessage=e.messages?.timerEnd??"Timer run for:",this.types=x(b,e.types??{}),this.longestLabel=c$1(this.types),this.logLevels={...a,...e.logLevels},this.generalLogLevel=this._normalizeLogLevel(e.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=e.disabled??!1,this.scopeName=v(e.scope).filter(Boolean),this.timersMap=new Map,this.countMap=new Map,this.groups=[],this.seqTimers=new Set;for(let r in this.types)this[r]=this._logger.bind(this,r,!1);this.lastLog={},Array.isArray(e.reporters)&&this.registerReporters(e.reporters),this.rawReporter=this.extendReporter(e.rawReporter??new L),Array.isArray(e.processors)&&this.registerProcessors(e.processors);}wrapConsole(){for(let e in this.types)console["__"+e]||(console["__"+e]=console[e]),console[e]=this[e].log;}restoreConsole(){for(let e in this.types)console["__"+e]&&(console[e]=console["__"+e],delete console["__"+e]);}wrapException(){process.on("uncaughtException",e=>{this.error(e);}),process.on("unhandledRejection",e=>{this.error(e);});}disable(){this.disabled=!0;}enable(){this.disabled=!1;}isEnabled(){return !this.disabled}scope(...e){if(e.length===0)throw new Error("No scope name was defined.");return this.scopeName=e.flat(),this}unscope(){this.scopeName=[];}time(e="default"){this.seqTimers.has(e)?this._logger("warn",!1,{message:"Timer '"+e+"' already exists",prefix:e}):(this.seqTimers.add(e),this.timersMap.set(e,Date.now()),this._logger("start",!1,{message:this.startTimerMessage,prefix:e}));}timeLog(e,...r){if(!e&&this.seqTimers.size>0&&(e=[...this.seqTimers].pop()),e&&this.timersMap.has(e)){let t=Date.now()-this.timersMap.get(e);this._logger("info",!1,{context:r,message:t<1e3?t+" ms":(t/1e3).toFixed(2)+" s",prefix:e});}else this._logger("warn",!1,{context:r,message:"Timer not found",prefix:e});}timeEnd(e){if(!e&&this.seqTimers.size>0&&(e=[...this.seqTimers].pop()),e&&this.timersMap.has(e)){let r=Date.now()-this.timersMap.get(e);this.timersMap.delete(e),this._logger("stop",!1,{message:this.endTimerMessage+" "+(r<1e3?r+" ms":(r/1e3).toFixed(2)+" s"),prefix:e});}}group(e="console.group"){typeof window>"u"?console.group(e):this.groups.push(e);}groupEnd(){typeof window>"u"?console.groupEnd():this.groups.pop();}count(e="default"){let r=this.countMap.get(e)??0;this.countMap.set(e,r+1),this._logger("log",!1,{message:e+": "+(r+1),prefix:e});}countReset(e="default"){this.countMap.has(e)?this.countMap.delete(e):this._logger("warn",!1,{message:"Count for "+e+" does not exist",prefix:e});}clear(){console.clear();}raw(e,...r){this.disabled||this._logger("log",!0,{context:r,message:e});}extendReporter(e){return typeof e.setLoggerTypes=="function"&&e.setLoggerTypes(this.types),typeof e.setStringify=="function"&&e.setStringify(this.stringify),e}registerReporters(e){for(let r of e)this.reporters.add(this.extendReporter(r));}_report(e,r){if(r)this.rawReporter.log(Object.freeze(e));else for(let t of this.reporters)t.log(Object.freeze(e));}registerProcessors(e){for(let r of e)typeof r.setStringify=="function"&&r.setStringify(this.stringify),this.processors.add(r);}_normalizeLogLevel(e){return e&&this.logLevels[e]?e:"debug"}_buildMeta(e,r,...t){let o={...C};if(o.type={level:r.logLevel,name:e},o.groups=this.groups,o.scope=this.scopeName,o.date=new Date,t.length===1&&typeof t[0]=="object"&&t[0]!==null)if(t[0]instanceof Error)o.error=t[0];else if("message"in t[0]){let{context:i,message:d,prefix:f,suffix:n}=t[0];i&&(o.context=i),f&&(o.prefix=f),n&&(o.suffix=n),o.message=d;}else o.message=t[0];else t.length>1&&typeof t[0]=="string"?(o.message=t[0],o.context=t.slice(1)):o.message=t[0];return r.logLevel==="trace"&&(o.traceError=new Error("Trace")),r.badge&&(o.badge=E(r.badge,r.badge.length+1)),r.label&&(o.label=r.label),o}_logger(e,r,...t){if(this.disabled)return;let o=this._normalizeLogLevel(this.types[e].logLevel);if(this.logLevels[o]>=this.logLevels[this.generalLogLevel]){let i=this._buildMeta(e,this.types[e],...t),d=(n=!1)=>{let l=(this.lastLog.count||0)-this.throttleMin;if(this.lastLog.object&&l>0){let u={...this.lastLog.object};l>1&&(u.repeated=l),this._report(u,r),this.lastLog.count=1;}if(n){for(let u of this.processors)i={...u.process(i)};this.lastLog.object=i,this._report(i,r);}};clearTimeout(this.lastLog.timeout);let f=this.lastLog.time&&i.date?new Date(i.date).getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=new Date(i.date),f<this.throttle)try{let n=JSON.stringify([i.label,i.scope,i.type,i.message,i.prefix,i.suffix,i.context]),l=this.lastLog.serialized===n;if(this.lastLog.serialized=n,l&&(this.lastLog.count=(this.lastLog.count||0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(d,this.throttle);return}}catch{}d(!0);}}},Y=y;var g=Symbol("circular-reference-tag"),m=Symbol("raw-error-ref"),M=Object.create({},{aggregateErrors:{enumerable:!0,value:void 0,writable:!0},cause:{enumerable:!0,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},message:{enumerable:!0,value:void 0,writable:!0},name:{enumerable:!0,value:void 0,writable:!0},raw:{enumerable:!1,get(){return this[m]},set(s){this[m]=s;}},stack:{enumerable:!0,value:void 0,writable:!0}});Object.defineProperty(M,m,{value:{},writable:!0});var R=M;var c=(s,e={})=>{s[g]=void 0;let r=Object.create(R);r.name=Object.prototype.toString.call(s.constructor)==="[object Function]"?s.constructor.name:s.name,r.message=s.message,r.stack=s.stack,Array.isArray(s.errors)&&(r.aggregateErrors=s.errors.map(t=>c(t,e))),s.cause instanceof Error&&!Object.prototype.hasOwnProperty.call(s.cause,g)&&(r.cause=c(s.cause,e));for(let t in s)if(r[t]===void 0){let o=s[t];if(o instanceof Error)Object.prototype.hasOwnProperty.call(o,g)||(r[t]=c(o,e));else if(typeof o=="function")r[t]="[Function: "+(o.name||"anonymous");else try{r[t]=o;}catch{}}return delete s[g],r.raw=s,r};var S=class{_options;constructor(e={}){this._options={maxDepth:Number.POSITIVE_INFINITY,useToJSON:!0,...e};}process(e){return e.error&&(e.error=c(e.error,this._options)),e}};
6
+
7
+ export { y as a, Y as b, S as c };
8
+ //# sourceMappingURL=out.js.map
9
+ //# sourceMappingURL=chunk-576JQ6DN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/pail.browser.ts","../src/reporter/raw/raw.browser.ts","../src/util/arrayify.ts","../src/util/merge-types.ts","../src/util/pad-end.ts","../src/processor/error/error-proto.ts","../src/processor/error/error-with-cause-serializer.ts","../src/processor/error/error-processor.ts"],"names":["stringifyConfigure","RawReporter","meta","context","message","type","writeConsoleLogBasedOnLevel","arrayify","x","mergeTypes","standard","custom","types","padEnd","string_","targetLength","EMPTY_META","PailBrowserImpl","options","LOG_TYPES","getLongestLabel","EXTENDED_RFC_5424_LOG_LEVELS","error","name","label","data","span","current","arguments_","reporter","reporters","raw","processors","processor","level","typeName","prefix","suffix","messageObject","logLevel","resolveLog","newLog","repeated","lastMeta","diffTime","serializedLog","isSameLog","PailBrowser","seen","rawSymbol","errorProto","value","ErrorProto","errorWithCauseSerializer","protoError","error_","key","ErrorProcessor"],"mappings":"8FACA,OAAS,aAAaA,MAA0B,wBCEzC,IAAMC,EAAN,KAAmE,CAE/D,IAAIC,EAA6B,CACpC,GAAM,CAAE,QAAAC,EAAU,CAAC,EAAG,QAAAC,EAAS,KAAAC,CAAK,EAAIH,EAEbI,EAA4BD,EAAK,KAAK,EAE9CD,EAAS,GAAGD,CAAO,CAC1C,CACJ,ECZO,IAAMI,EAAeC,GACpBA,IAAM,OACC,CAAC,EAGL,MAAM,QAAQA,CAAC,EAAIA,EAAK,CAACA,CAAC,ECH9B,IAAMC,EAAa,CACtBC,EACAC,IACyD,CACzD,IAAMC,EAAQ,CAAE,GAAGF,CAAS,EAE5B,cAAO,KAAKC,CAAM,EAAE,QAASN,GAAS,CAClCO,EAAMP,CAAS,EAAI,CAAE,GAAGO,EAAMP,CAAS,EAAG,GAAGM,EAAON,CAAS,CAAE,CACnE,CAAC,EAEMO,CACX,ECbO,IAAMC,EAAS,CAACC,EAAiBC,IAChCD,EAAQ,QAAUC,EACXD,EAGJA,EAAQ,OAAOC,CAAY,EJsBtC,IAAMC,EAAa,CACf,MAAO,OACP,QAAS,OACT,MAAO,OACP,MAAO,OACP,QAAS,OACT,OAAQ,OACR,SAAU,OACV,MAAO,OACP,OAAQ,MACZ,EAEaC,EAAN,KAA0E,CACnE,UAEA,SAEA,UAES,QAQA,UAET,SAEA,UAES,MAEA,aAEA,WAEA,gBAET,UAES,SAEA,YAEA,UAET,OAES,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QmD,EAAyBnD,EAAK,MAAO,KAAK,QAAQ,GAG5DA,CACX,CACJ","sourcesContent":["import type { stringify } from \"safe-stable-stringify\";\nimport { configure as stringifyConfigure } from \"safe-stable-stringify\";\n\nimport { EXTENDED_RFC_5424_LOG_LEVELS, LOG_TYPES } from \"./constants\";\nimport { RawReporter } from \"./reporter/raw/raw.browser\";\nimport type {\n ConstructorOptions,\n DefaultLogTypes,\n ExtendedRfc5424LogLevels,\n LiteralUnion,\n LoggerConfiguration,\n LoggerFunction,\n LoggerTypesAwareReporter,\n LoggerTypesConfig,\n Message,\n Meta,\n Primitive,\n Processor,\n Reporter,\n StringifyAwareProcessor,\n StringifyAwareReporter,\n} from \"./types\";\nimport { arrayify } from \"./util/arrayify\";\nimport { getLongestLabel } from \"./util/get-longest-label\";\nimport { mergeTypes } from \"./util/merge-types\";\nimport { padEnd } from \"./util/pad-end\";\n\nconst EMPTY_META = {\n badge: undefined,\n context: undefined,\n error: undefined,\n label: undefined,\n message: undefined,\n prefix: undefined,\n repeated: undefined,\n scope: undefined,\n suffix: undefined,\n};\n\nexport class PailBrowserImpl<T extends string = never, L extends string = never> {\n protected timersMap: Map<string, number>;\n\n protected countMap: Map<string, number>;\n\n protected seqTimers: Set<string>;\n\n protected readonly lastLog: {\n count?: number;\n object?: Meta<L>;\n serialized?: string;\n time?: Date;\n timeout?: ReturnType<typeof setTimeout>;\n };\n\n protected readonly logLevels: Record<string, number>;\n\n protected disabled: boolean;\n\n protected scopeName: string[];\n\n protected readonly types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;\n\n protected readonly longestLabel: string;\n\n protected readonly processors: Set<Processor<L>>;\n\n protected readonly generalLogLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>;\n\n protected reporters: Set<Reporter<L>>;\n\n protected readonly throttle: number;\n\n protected readonly throttleMin: number;\n\n protected readonly stringify: typeof stringify;\n\n protected groups: string[];\n\n protected readonly startTimerMessage: string;\n\n protected readonly endTimerMessage: string;\n\n protected rawReporter: Reporter<L>;\n\n public constructor(options: ConstructorOptions<T, L>) {\n this.throttle = options.throttle ?? 1000;\n this.throttleMin = options.throttleMin ?? 5;\n\n this.stringify = stringifyConfigure({\n strict: true,\n });\n\n this.startTimerMessage = options.messages?.timerStart ?? \"Initialized timer...\";\n this.endTimerMessage = options.messages?.timerEnd ?? \"Timer run for:\";\n this.types = mergeTypes<L, T>(LOG_TYPES, (options.types ?? {}) as LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>);\n this.longestLabel = getLongestLabel<L, T>(this.types);\n\n this.logLevels = { ...EXTENDED_RFC_5424_LOG_LEVELS, ...options.logLevels };\n this.generalLogLevel = this._normalizeLogLevel(options.logLevel);\n\n this.reporters = new Set();\n this.processors = new Set();\n\n this.disabled = options.disabled ?? false;\n\n this.scopeName = arrayify(options.scope).filter(Boolean) as string[];\n\n this.timersMap = new Map();\n this.countMap = new Map();\n\n this.groups = [];\n\n this.seqTimers = new Set();\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax,guard-for-in\n for (const type in this.types) {\n // @ts-expect-error - dynamic property\n // eslint-disable-next-line security/detect-object-injection\n this[type] = this._logger.bind(this, type as T, false);\n }\n\n // Track of last log\n this.lastLog = {};\n\n if (Array.isArray(options.reporters)) {\n this.registerReporters(options.reporters);\n }\n\n this.rawReporter = this.extendReporter(options.rawReporter ?? new RawReporter<L>());\n\n if (Array.isArray(options.processors)) {\n this.registerProcessors(options.processors);\n }\n }\n\n public wrapConsole(): void {\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const type in this.types) {\n // Backup original value\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (!(console as any)[\"__\" + type]) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,security/detect-object-injection\n (console as any)[\"__\" + type] = (console as any)[type];\n }\n // Override\n // @TODO: Fix typings\n // @ts-expect-error - dynamic property\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,security/detect-object-injection\n (console as any)[type] = (this as unknown as PailBrowserImpl<T, L>)[type as keyof PailBrowserImpl<T, L>].log;\n }\n }\n\n public restoreConsole(): void {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const type in this.types) {\n // Restore if backup is available\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((console as any)[\"__\" + type]) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,security/detect-object-injection\n (console as any)[type] = (console as any)[\"__\" + type];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-dynamic-delete\n delete (console as any)[\"__\" + type];\n }\n }\n }\n\n public wrapException(): void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n process.on(\"uncaughtException\", (error: any) => {\n // @TODO: Fix typings\n // @ts-expect-error - dynamic property\n (this as unknown as PailBrowserImpl<T, L>).error(error);\n });\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n process.on(\"unhandledRejection\", (error: any) => {\n // @TODO: Fix typings\n // @ts-expect-error - dynamic property\n (this as unknown as PailBrowserImpl<T, L>).error(error);\n });\n }\n\n /**\n * Disables logging\n */\n public disable(): void {\n this.disabled = true;\n }\n\n /**\n * Enables logging\n */\n public enable(): void {\n this.disabled = false;\n }\n\n public isEnabled(): boolean {\n return !this.disabled;\n }\n\n public scope<N extends string = T>(...name: string[]): PailBrowserType<N, L> {\n if (name.length === 0) {\n throw new Error(\"No scope name was defined.\");\n }\n\n this.scopeName = name.flat();\n\n return this as unknown as PailBrowserType<N, L>;\n }\n\n public unscope(): void {\n this.scopeName = [];\n }\n\n public time(label = \"default\"): void {\n if (this.seqTimers.has(label)) {\n this._logger(\"warn\", false, {\n message: \"Timer '\" + label + \"' already exists\",\n prefix: label,\n });\n } else {\n this.seqTimers.add(label);\n this.timersMap.set(label, Date.now());\n\n this._logger(\"start\", false, {\n message: this.startTimerMessage,\n prefix: label,\n });\n }\n }\n\n public timeLog(label?: string, ...data: unknown[]): void {\n if (!label && this.seqTimers.size > 0) {\n // eslint-disable-next-line no-param-reassign\n label = [...this.seqTimers].pop();\n }\n\n if (label && this.timersMap.has(label)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const span = Date.now() - this.timersMap.get(label)!;\n\n this._logger(\"info\", false, {\n context: data,\n message: span < 1000 ? span + \" ms\" : (span / 1000).toFixed(2) + \" s\",\n prefix: label,\n });\n } else {\n this._logger(\"warn\", false, {\n context: data,\n message: \"Timer not found\",\n prefix: label,\n });\n }\n }\n\n public timeEnd(label?: string): void {\n if (!label && this.seqTimers.size > 0) {\n // eslint-disable-next-line no-param-reassign\n label = [...this.seqTimers].pop();\n }\n\n if (label && this.timersMap.has(label)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const span = Date.now() - this.timersMap.get(label)!;\n\n this.timersMap.delete(label);\n\n this._logger(\"stop\", false, {\n message: this.endTimerMessage + \" \" + (span < 1000 ? span + \" ms\" : (span / 1000).toFixed(2) + \" s\"),\n prefix: label,\n });\n }\n }\n\n public group(label = \"console.group\"): void {\n if (typeof window === \"undefined\") {\n // eslint-disable-next-line no-console\n console.group(label);\n } else {\n this.groups.push(label);\n }\n }\n\n public groupEnd(): void {\n if (typeof window === \"undefined\") {\n // eslint-disable-next-line no-console\n console.groupEnd();\n } else {\n this.groups.pop();\n }\n }\n\n public count(label = \"default\"): void {\n const current = this.countMap.get(label) ?? 0;\n\n this.countMap.set(label, current + 1);\n\n this._logger(\"log\", false, {\n message: label + \": \" + (current + 1),\n prefix: label,\n });\n }\n\n public countReset(label = \"default\"): void {\n if (this.countMap.has(label)) {\n this.countMap.delete(label);\n } else {\n this._logger(\"warn\", false, {\n message: \"Count for \" + label + \" does not exist\",\n prefix: label,\n });\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n public clear(): void {\n // eslint-disable-next-line no-console\n console.clear();\n }\n\n public raw(message: string, ...arguments_: unknown[]): void {\n if (this.disabled) {\n return;\n }\n\n this._logger(\"log\", true, {\n context: arguments_,\n message,\n });\n }\n\n protected extendReporter(reporter: Reporter<L>): Reporter<L> {\n if (typeof (reporter as LoggerTypesAwareReporter<T, L>).setLoggerTypes === \"function\") {\n (reporter as LoggerTypesAwareReporter<T, L>).setLoggerTypes(this.types);\n }\n\n if (typeof (reporter as StringifyAwareReporter<L>).setStringify === \"function\") {\n (reporter as StringifyAwareReporter<L>).setStringify(this.stringify);\n }\n\n return reporter;\n }\n\n protected registerReporters(reporters: Reporter<L>[]): void {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const reporter of reporters) {\n this.reporters.add(this.extendReporter(reporter));\n }\n }\n\n private _report(meta: Meta<L>, raw: boolean): void {\n if (raw) {\n this.rawReporter.log(Object.freeze(meta));\n } else {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const reporter of this.reporters) {\n reporter.log(Object.freeze(meta));\n }\n }\n }\n\n private registerProcessors(processors: Processor<L>[]): void {\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const processor of processors) {\n if (typeof (processor as StringifyAwareProcessor<L>).setStringify === \"function\") {\n (processor as StringifyAwareProcessor<L>).setStringify(this.stringify);\n }\n\n this.processors.add(processor as Processor<L>);\n }\n }\n\n private _normalizeLogLevel(level: LiteralUnion<ExtendedRfc5424LogLevels, L> | undefined): LiteralUnion<ExtendedRfc5424LogLevels, L> {\n // eslint-disable-next-line security/detect-object-injection\n return level && this.logLevels[level] ? level : \"debug\";\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity,@typescript-eslint/no-explicit-any\n private _buildMeta(typeName: string, type: Partial<LoggerConfiguration<L>>, ...arguments_: any[]): Meta<L> {\n const meta = { ...EMPTY_META } as Meta<L>;\n\n meta.type = {\n level: type.logLevel as LiteralUnion<ExtendedRfc5424LogLevels, L>,\n name: typeName,\n };\n\n meta.groups = this.groups;\n meta.scope = this.scopeName;\n meta.date = new Date();\n\n if (arguments_.length === 1 && typeof arguments_[0] === \"object\" && arguments_[0] !== null) {\n if (arguments_[0] instanceof Error) {\n // eslint-disable-next-line prefer-destructuring\n meta.error = arguments_[0];\n } else if (\"message\" in arguments_[0]) {\n const { context, message, prefix, suffix } = arguments_[0] as Message;\n\n if (context) {\n meta.context = context;\n }\n\n if (prefix) {\n meta.prefix = prefix;\n }\n\n if (suffix) {\n meta.suffix = suffix;\n }\n\n meta.message = message;\n } else {\n meta.message = arguments_[0] as Primitive | ReadonlyArray<unknown> | Record<PropertyKey, unknown>;\n }\n } else if (arguments_.length > 1 && typeof arguments_[0] === \"string\") {\n meta.message = arguments_[0] as string;\n meta.context = arguments_.slice(1);\n } else {\n // eslint-disable-next-line prefer-destructuring\n meta.message = arguments_[0];\n }\n\n if (type.logLevel === \"trace\") {\n meta.traceError = new Error(\"Trace\");\n }\n\n if (type.badge) {\n meta.badge = padEnd(type.badge, type.badge.length + 1);\n }\n\n if (type.label) {\n meta.label = type.label;\n }\n\n return meta;\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity,@typescript-eslint/no-explicit-any\n private _logger(type: LiteralUnion<DefaultLogTypes, T>, raw: boolean, ...messageObject: any[]): void {\n if (this.disabled) {\n return;\n }\n\n // eslint-disable-next-line security/detect-object-injection\n const logLevel = this._normalizeLogLevel(this.types[type].logLevel);\n\n // eslint-disable-next-line security/detect-object-injection\n if ((this.logLevels[logLevel] as number) >= (this.logLevels[this.generalLogLevel] as number)) {\n // eslint-disable-next-line security/detect-object-injection\n let meta = this._buildMeta(type, this.types[type], ...messageObject);\n\n /**\n * @param newLog false if the throttle expired and we don't want to log a duplicate\n */\n const resolveLog = (newLog = false) => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const repeated = (this.lastLog.count || 0) - this.throttleMin;\n\n if (this.lastLog.object && repeated > 0) {\n const lastMeta = { ...this.lastLog.object };\n\n if (repeated > 1) {\n lastMeta.repeated = repeated;\n }\n\n this._report(lastMeta, raw);\n\n this.lastLog.count = 1;\n }\n\n if (newLog) {\n // Apply global processors\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const processor of this.processors) {\n meta = { ...processor.process(meta) };\n }\n\n this.lastLog.object = meta;\n\n this._report(meta, raw);\n }\n };\n\n clearTimeout(this.lastLog.timeout);\n\n const diffTime = this.lastLog.time && meta.date ? new Date(meta.date as Date | string).getTime() - this.lastLog.time.getTime() : 0;\n\n this.lastLog.time = new Date(meta.date as Date | string);\n\n if (diffTime < this.throttle) {\n try {\n const serializedLog = JSON.stringify([meta.label, meta.scope, meta.type, meta.message, meta.prefix, meta.suffix, meta.context]);\n const isSameLog = this.lastLog.serialized === serializedLog;\n\n this.lastLog.serialized = serializedLog;\n\n if (isSameLog) {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n this.lastLog.count = (this.lastLog.count || 0) + 1;\n\n if (this.lastLog.count > this.throttleMin) {\n // Auto-resolve when throttle is timed out\n this.lastLog.timeout = setTimeout(resolveLog, this.throttle);\n\n return; // SPAM!\n }\n }\n } catch {\n // Circular References\n }\n }\n\n resolveLog(true);\n }\n }\n}\n\nexport type PailBrowserType<T extends string = never, L extends string = never> = PailBrowserImpl<T, L> &\n Record<DefaultLogTypes, LoggerFunction> &\n Record<T, LoggerFunction> &\n (new<TC extends string = never, LC extends string = never>(options?: ConstructorOptions<TC, LC>) => PailBrowserType<TC, LC>);\n\nexport type PailConstructor<T extends string = never, L extends string = never> = new (options?: ConstructorOptions<T, L>) => PailBrowserType<T, L>;\n\nexport const PailBrowser = PailBrowserImpl as unknown as PailBrowserType;\n","import type { ReadonlyMeta, Reporter } from \"../../types\";\nimport { writeConsoleLogBasedOnLevel } from \"../../util/write-console-log\";\n\nexport class RawReporter<L extends string = never> implements Reporter<L> {\n // eslint-disable-next-line class-methods-use-this\n public log(meta: ReadonlyMeta<L>): void {\n const { context = [], message, type } = meta;\n\n const consoleLogFunction = writeConsoleLogBasedOnLevel(type.level);\n\n consoleLogFunction(message, ...context);\n }\n}\n","export const arrayify = <T>(x: T | T[]): T[] => {\n if (x === undefined) {\n return [] as T[];\n }\n\n return Array.isArray(x) ? x : ([x] as T[]);\n};\n","import type { DefaultLoggerTypes, DefaultLogTypes, LiteralUnion, LoggerTypesConfig } from \"../types\";\n\nexport const mergeTypes = <L extends string, T extends string>(\n standard: DefaultLoggerTypes<L>,\n custom: LoggerTypesConfig<T, L>,\n): LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L> => {\n const types = { ...standard } as LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;\n\n Object.keys(custom).forEach((type) => {\n types[type as T] = { ...types[type as T], ...custom[type as T] };\n });\n\n return types;\n};\n","export const padEnd = (string_: string, targetLength: number): string => {\n if (string_.length >= targetLength) {\n return string_;\n }\n\n return string_.padEnd(targetLength);\n};\n","// eslint-disable-next-line import/exports-last\nexport const seen = Symbol(\"circular-reference-tag\");\n\n// eslint-disable-next-line import/exports-last,import/no-unused-modules\nexport const rawSymbol = Symbol(\"raw-error-ref\");\n\nconst errorProto = Object.create(\n {},\n {\n aggregateErrors: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n cause: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n code: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n message: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n name: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n raw: {\n enumerable: false,\n get() {\n // eslint-disable-next-line security/detect-object-injection\n return this[rawSymbol];\n },\n set(value) {\n // eslint-disable-next-line security/detect-object-injection\n this[rawSymbol] = value;\n },\n },\n stack: {\n enumerable: true,\n value: undefined,\n writable: true,\n },\n },\n) as SerializedError;\n\nObject.defineProperty(errorProto, rawSymbol, {\n value: {},\n writable: true,\n});\n\nexport const ErrorProto = errorProto;\n\nexport type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {\n aggregateErrors?: SerializedError<ErrorType>[];\n cause?: unknown;\n code?: string;\n message: string;\n name: string;\n raw?: ErrorType;\n stack?: string;\n};\n","import type { SerializedError } from \"./error-proto\";\nimport { ErrorProto, seen } from \"./error-proto\";\n\ntype CauseError = Error & {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n cause: any;\n};\n\ntype Options = {\n readonly maxDepth?: number;\n readonly useToJSON?: boolean;\n};\n\n/**\n * Serialize an `Error` object into a plain object.\n *\n * - Non-error values are passed through.\n * - Custom properties are preserved.\n * - Buffer properties are replaced with `[object Buffer]`.\n * - Circular references are handled.\n * - If the input object has a `.toJSON()` method, then it's called instead of serializing the object's properties.\n * - It's up to `.toJSON()` implementation to handle circular references and enumerability of the properties.\n */\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport const errorWithCauseSerializer = (error: AggregateError | Error, options: Options = {}): SerializedError => {\n // @ts-expect-error - dynamic property\n // eslint-disable-next-line no-param-reassign\n error[seen as keyof Error] = undefined; // tag to prevent re-looking at this\n\n const protoError = Object.create(ErrorProto as object) as SerializedError;\n\n protoError.name = Object.prototype.toString.call(error.constructor) === \"[object Function]\" ? error.constructor.name : error.name;\n protoError.message = error.message;\n protoError.stack = error.stack;\n\n if (Array.isArray((error as AggregateError).errors)) {\n protoError.aggregateErrors = (error as AggregateError).errors.map((error_: AggregateError | Error) => errorWithCauseSerializer(error_, options));\n }\n\n // Handle aggregate errors\n if ((error as CauseError).cause instanceof Error && !Object.prototype.hasOwnProperty.call((error as CauseError).cause, seen as PropertyKey)) {\n protoError.cause = errorWithCauseSerializer((error as CauseError).cause, options);\n }\n\n // eslint-disable-next-line no-loops/no-loops,no-restricted-syntax\n for (const key in error) {\n // eslint-disable-next-line security/detect-object-injection\n if (protoError[key] === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const value = error[key as keyof Error] as any;\n\n if (value instanceof Error) {\n if (!Object.prototype.hasOwnProperty.call(value, seen as PropertyKey)) {\n // eslint-disable-next-line security/detect-object-injection\n protoError[key] = errorWithCauseSerializer(value, options);\n }\n } else if (typeof value === \"function\") {\n // eslint-disable-next-line security/detect-object-injection\n protoError[key] = \"[Function: \" + (value.name || \"anonymous\");\n } else {\n // Gracefully handle non-configurable errors like `DOMException`.\n try {\n // eslint-disable-next-line security/detect-object-injection\n protoError[key] = value;\n } catch {\n /* empty */\n }\n }\n }\n }\n\n // eslint-disable-next-line no-param-reassign,@typescript-eslint/no-dynamic-delete\n delete error[seen as unknown as keyof Error]; // clean up tag in case err is serialized again later\n\n protoError.raw = error;\n\n return protoError;\n};\n","import type { Meta, Processor } from \"../../types\";\nimport type { SerializedError } from \"./error-proto\";\nimport { errorWithCauseSerializer } from \"./error-with-cause-serializer\";\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace VisulimaPail {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface CustomMeta<L> {\n error: SerializedError | undefined;\n }\n }\n}\n\nexport class ErrorProcessor<L extends string = never> implements Processor<L> {\n private readonly _options: { maxDepth: number; useToJSON: boolean };\n\n public constructor(options: { maxDepth?: number; useToJSON?: boolean } = {}) {\n this._options = {\n maxDepth: Number.POSITIVE_INFINITY,\n useToJSON: true,\n ...options,\n };\n }\n\n public process(meta: Meta<L>): Meta<L> {\n if (meta.error) {\n // eslint-disable-next-line no-param-reassign\n meta.error = errorWithCauseSerializer(meta.error, this._options);\n }\n\n return meta;\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var chunkN2UPJYJR_cjs = require('./chunk-N2UPJYJR.cjs');
4
+ var chunkZJMTPHZR_cjs = require('./chunk-ZJMTPHZR.cjs');
5
+
6
+ var t=class extends chunkZJMTPHZR_cjs.a{constructor(){super();}_log(n,r){chunkN2UPJYJR_cjs.a(r)(n);}};
7
+
8
+ exports.a = t;
9
+ //# sourceMappingURL=out.js.map
10
+ //# sourceMappingURL=chunk-5MNFJRLM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/reporter/json/json.browser.ts"],"names":["JsonReporter","AbstractJsonReporter","message","logLevel","writeConsoleLogBasedOnLevel"],"mappings":"kFAIO,IAAMA,EAAN,cAAqDC,CAAwB,CACzE,aAAc,CACjB,MAAM,CACV,CAGmB,KAAKC,EAAiBC,EAA2D,CACrEC,EAA4BD,CAAQ,EAE5CD,CAAO,CAC9B,CACJ","sourcesContent":["import type { ExtendedRfc5424LogLevels, LiteralUnion } from \"../../types\";\nimport { writeConsoleLogBasedOnLevel } from \"../../util/write-console-log\";\nimport { AbstractJsonReporter } from \"./abstract-json-reporter\";\n\nexport class JsonReporter<L extends string = never> extends AbstractJsonReporter<L> {\n public constructor() {\n super();\n }\n\n // eslint-disable-next-line class-methods-use-this\n protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void {\n const consoleLogFunction = writeConsoleLogBasedOnLevel(logLevel);\n\n consoleLogFunction(message);\n }\n}\n"]}
@@ -1,7 +1,5 @@
1
- 'use strict';
2
-
3
1
  var r=e=>e==="error"?console.__error??console.error:e==="warn"?console.__warn??console.warn:e==="trace"?console.__trace??console.trace:console.__log??console.log;
4
2
 
5
- exports.a = r;
3
+ export { r as a };
6
4
  //# sourceMappingURL=out.js.map
7
- //# sourceMappingURL=chunk-4RK45K5E.cjs.map
5
+ //# sourceMappingURL=chunk-AFMDCM5W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/util/write-console-log.ts"],"names":["writeConsoleLogBasedOnLevel","level"],"mappings":"AAGO,IAAMA,EAAyDC,GAC9DA,IAAU,QAEF,QAAgB,SAAW,QAAQ,MAG3CA,IAAU,OAEF,QAAgB,QAAU,QAAQ,KAG1CA,IAAU,QAEF,QAAgB,SAAW,QAAQ,MAIvC,QAAgB,OAAS,QAAQ","sourcesContent":["import type { ExtendedRfc5424LogLevels, LiteralUnion } from \"../types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const writeConsoleLogBasedOnLevel = <L extends string = never>(level: LiteralUnion<ExtendedRfc5424LogLevels, L>): ((...data: any[]) => void) => {\n if (level === \"error\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__error ?? console.error;\n }\n\n if (level === \"warn\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__warn ?? console.warn;\n }\n\n if (level === \"trace\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__trace ?? console.trace;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__log ?? console.log;\n};\n"]}
@@ -0,0 +1,21 @@
1
+ import { b, a } from './chunk-ZB7IIFHO.js';
2
+ import { c } from './chunk-NF47XQ47.js';
3
+ import U, { white, grey, bgGrey, underline, red, cyan, bold } from '@visulima/colorize';
4
+ import L from 'string-length';
5
+ import F from 'terminal-size';
6
+ import z from 'wrap-ansi';
7
+
8
+ var W=(v,e)=>(e.__write??e.write).call(e,v);var A=class extends b{#e;#t;#r;#s=!1;constructor(e={}){super({uppercase:{label:!0,...e.uppercase},...e}),this.#e=process.stdout,this.#t=process.stderr;}setStdout(e){this.#e=e;}setStderr(e){this.#t=e;}setInteractiveManager(e){this.#r=e;}setIsInteractive(e){this.#s=e;}log(e){this._log(this._formatMessage(e),e.type.level);}_formatMessage(e){let{columns:r}=F(),s=r;typeof this._styles.messageLength=="number"&&(s=this._styles.messageLength);let{badge:o,context:u,date:y,error:g,file:a$1,groups:f,label:n,message:p,prefix:c$1,repeated:S,scope:d,suffix:b,traceError:M,type:J}=e,{color:w}=this._loggerTypes[J.name],x=w?U[w]:white,h=f.map(()=>" ").join(""),t=[];if(f.length>0&&t.push(h+grey("["+f.at(-1)+"] ")),y&&t.push(grey(this._styles.dateFormatter(new Date(y)))+" "),o)t.push(x(o));else {let l=a(this._loggerTypes);l.length>0&&t.push(grey(".".repeat(l.length))+" ");}let T=c(this._loggerTypes);n?t.push(x(this._formatLabel(n))+" ",grey(".".repeat(T.length-L(n)))):t.push(grey(".".repeat(T.length+2))),S&&t.push(bgGrey.white("["+S+"x]")+" "),Array.isArray(d)&&d.length>0&&t.push(grey(" ["+d.join(" > ")+"] ")),c$1&&t.push(grey((Array.isArray(d)&&d.length>0?". ":" ")+"["+(this._styles.underline.prefix?underline(c$1):c$1)+"] "));let E=L(t.join(" "));if(a$1){let l=a$1.name+(a$1.line?":"+a$1.line:""),m=L(l);t.push(grey(".".repeat(s-E-m-2)+" "+l));}else t.push(grey(".".repeat(s-E-1)));if(t.length>0&&t.push(`
9
+
10
+ `),p){let l=typeof p=="string"?p:this._stringify(p);t.push(h+z(l??"undefined",s-3,{hard:!0,trim:!0,wordWrap:!0})),u&&t.push(...u.map(m=>typeof m=="object"?" "+this._stringify(m):" "+m));}return g&&t.push(this._formatError(g,s,h)),M&&t.push(this._formatError(M,s,h,!0)),b&&t.push(`
11
+ `,h+grey(this._styles.underline.suffix?underline(b):b)),t.join("")+`
12
+ `}_log(e,r){let s=["error","trace","warn"].includes(r)?"stderr":"stdout",o=s==="stderr"?this.#t:this.#e;this.#s&&this.#r!==void 0&&o.isTTY?this.#r.update(s,e.split(`
13
+ `),0):W(e+`
14
+ `,o);}_formatError(e,r,s,o=!1){let{message:u,name:y,stack:g}=e,a=[];if(a.push(...o?[]:[s+red(y),": "],z(u,r-3,{hard:!0,trim:!0,wordWrap:!0})),g){let f=g.split(`
15
+ `).splice(1).map(n=>s+n.trim().replace("file://","")).filter(n=>!n.includes("/pail/dist"));a.push(`
16
+ `,f.map(n=>" "+n.replace(/^at +/,p=>grey(p)).replace(/\((.+)\)/,(p,c)=>"("+cyan(c)+")")).join(`
17
+ `));}return a.join("")}_formatLabel(e){let r=this._styles.uppercase.label?e.toUpperCase():e;return r=this._styles.underline.label?underline(r):r,this._styles.bold.label&&(r=bold(r)),r}};
18
+
19
+ export { W as a, A as b };
20
+ //# sourceMappingURL=out.js.map
21
+ //# sourceMappingURL=chunk-ETY4VGL2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/reporter/pretty/pretty.server.ts","../src/util/write-stream.ts"],"names":["colorize","bgGrey","bold","cyan","grey","red","underline","white","stringLength","terminalSize","wrapAnsi","writeStream","data","stream","PrettyReporter","AbstractPrettyReporter","#stdout","#stderr","#interactiveManager","#interactive","options","stdout","stderr","manager","interactive","meta","columns","size","badge","context","date","error","file","groups","label","message","prefix","repeated","scope","suffix","traceError","type","color","colorized","groupSpaces","items","longestBadge","getLongestBadge","longestLabel","getLongestLabel","titleSize","fileMessage","fileMessageSize","formattedMessage","value","logLevel","streamType","hideName","name","stack","lines","line","m","_","formattedLabel"],"mappings":"uFAAA,OAAOA,GAAY,UAAAC,EAAQ,QAAAC,EAAM,QAAAC,EAAM,QAAAC,EAAM,OAAAC,EAAK,aAAAC,EAAW,SAAAC,MAAa,qBAE1E,OAAOC,MAAkB,gBACzB,OAAOC,MAAkB,gBACzB,OAAOC,MAAc,YCJd,IAAMC,EAAc,CAACC,EAAcC,KAEvBA,EAAe,SAAWA,EAAO,OAEnC,KAAKA,EAAQD,CAAI,EDU3B,IAAME,EAAN,cAAiFC,CAAqE,CACzJC,GAEAC,GAEAC,GAEAC,GAAe,GAER,YAAYC,EAAuC,CAAC,EAAG,CAC1D,MAAM,CACF,UAAW,CACP,MAAO,GACP,GAAGA,EAAQ,SACf,EACA,GAAGA,CACP,CAAC,EAED,KAAKJ,GAAU,QAAQ,OACvB,KAAKC,GAAU,QAAQ,MAC3B,CAEO,UAAUI,EAAkC,CAC/C,KAAKL,GAAUK,CACnB,CAEO,UAAUC,EAAkC,CAC/C,KAAKL,GAAUK,CACnB,CAEO,sBAAsBC,EAAoC,CAC7D,KAAKL,GAAsBK,CAC/B,CAEO,iBAAiBC,EAA4B,CAChD,KAAKL,GAAeK,CACxB,CAEO,IAAIC,EAA6B,CACpC,KAAK,KAAK,KAAK,eAAeA,CAAuB,EAAGA,EAAK,KAAK,KAAK,CAC3E,CAGU,eAAeb,EAA+B,CACpD,GAAM,CAAE,QAAAc,CAAQ,EAAIjB,EAAa,EAE7BkB,EAAOD,EAEP,OAAO,KAAK,QAAQ,eAAkB,WACtCC,EAAO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AK,QAAQ,UAAU,MAAQ1D,EAAU0D,CAAc,EAAIA,EAExE,KAAK,QAAQ,KAAK,QAClBA,EAAiB9D,EAAK8D,CAAc,GAGjCA,CACX,CACJ","sourcesContent":["import colorize, { bgGrey, bold, cyan, grey, red, underline, white } from \"@visulima/colorize\";\nimport type { stringify } from \"safe-stable-stringify\";\nimport stringLength from \"string-length\";\nimport terminalSize from \"terminal-size\";\nimport wrapAnsi from \"wrap-ansi\";\n\nimport type { InteractiveManager } from \"../../interactive/interactive-manager\";\nimport type { ExtendedRfc5424LogLevels, InteractiveStreamReporter, LiteralUnion, ReadonlyMeta } from \"../../types\";\nimport { getLongestBadge } from \"../../util/get-longest-badge\";\nimport { getLongestLabel } from \"../../util/get-longest-label\";\nimport { writeStream } from \"../../util/write-stream\";\nimport type { PrettyStyleOptions } from \"./abstract-pretty-reporter\";\nimport { AbstractPrettyReporter } from \"./abstract-pretty-reporter\";\n\nexport class PrettyReporter<T extends string = never, L extends string = never> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {\n #stdout: NodeJS.WriteStream;\n\n #stderr: NodeJS.WriteStream;\n\n #interactiveManager: InteractiveManager | undefined;\n\n #interactive = false;\n\n public constructor(options: Partial<PrettyStyleOptions> = {}) {\n super({\n uppercase: {\n label: true,\n ...options.uppercase,\n },\n ...options,\n });\n\n this.#stdout = process.stdout;\n this.#stderr = process.stderr;\n }\n\n public setStdout(stdout: NodeJS.WriteStream): void {\n this.#stdout = stdout;\n }\n\n public setStderr(stderr: NodeJS.WriteStream): void {\n this.#stderr = stderr;\n }\n\n public setInteractiveManager(manager?: InteractiveManager): void {\n this.#interactiveManager = manager;\n }\n\n public setIsInteractive(interactive: boolean): void {\n this.#interactive = interactive;\n }\n\n public log(meta: ReadonlyMeta<L>): void {\n this._log(this._formatMessage(meta as ReadonlyMeta<L>), meta.type.level);\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n protected _formatMessage(data: ReadonlyMeta<L>): string {\n const { columns } = terminalSize();\n\n let size = columns;\n\n if (typeof this._styles.messageLength === \"number\") {\n size = this._styles.messageLength;\n }\n\n const { badge, context, date, error, file, groups, label, message, prefix, repeated, scope, suffix, traceError, type } = data;\n\n const { color } = this._loggerTypes[type.name as keyof typeof this._loggerTypes];\n // eslint-disable-next-line security/detect-object-injection\n const colorized = color ? colorize[color] : white;\n\n const groupSpaces: string = groups.map(() => \" \").join(\"\");\n const items: string[] = [];\n\n if (groups.length > 0) {\n items.push((groupSpaces + grey(\"[\" + groups.at(-1) + \"] \")) as string);\n }\n\n if (date) {\n items.push(grey(this._styles.dateFormatter(new Date(date))) + \" \");\n }\n\n if (badge) {\n items.push(colorized(badge) as string);\n } else {\n const longestBadge: string = getLongestBadge<L, T>(this._loggerTypes);\n\n if (longestBadge.length > 0) {\n items.push(grey(\".\".repeat(longestBadge.length)) + \" \");\n }\n }\n\n const longestLabel: string = getLongestLabel<L, T>(this._loggerTypes);\n\n if (label) {\n items.push(colorized(this._formatLabel(label as string)) + \" \", grey(\".\".repeat(longestLabel.length - stringLength(label as string))));\n } else {\n // plus 2 for the space and the dot\n items.push(grey(\".\".repeat(longestLabel.length + 2)));\n }\n\n if (repeated) {\n items.push(bgGrey.white(\"[\" + repeated + \"x]\") + \" \");\n }\n\n if (Array.isArray(scope) && scope.length > 0) {\n items.push(grey(\" [\" + scope.join(\" > \") + \"] \"));\n }\n\n if (prefix) {\n items.push(\n grey(\n (Array.isArray(scope) && scope.length > 0 ? \". \" : \" \") +\n \"[\" +\n (this._styles.underline.prefix ? underline(prefix as string) : prefix) +\n \"] \",\n ),\n );\n }\n\n const titleSize = stringLength(items.join(\" \"));\n\n if (file) {\n const fileMessage = file.name + (file.line ? \":\" + file.line : \"\");\n const fileMessageSize = stringLength(fileMessage);\n\n items.push(grey(\".\".repeat(size - titleSize - fileMessageSize - 2) + \" \" + fileMessage));\n } else {\n items.push(grey(\".\".repeat(size - titleSize - 1)));\n }\n\n if (items.length > 0) {\n items.push(\"\\n\\n\");\n }\n\n if (message) {\n const formattedMessage: string | undefined = typeof message === \"string\" ? message : (this._stringify as typeof stringify)(message);\n\n items.push(\n groupSpaces +\n wrapAnsi(formattedMessage ?? \"undefined\", size - 3, {\n hard: true,\n trim: true,\n wordWrap: true,\n }),\n );\n\n if (context) {\n items.push(\n ...context.map((value) => {\n if (typeof value === \"object\") {\n return \" \" + (this._stringify as typeof stringify)(value);\n }\n\n return \" \" + value;\n }),\n );\n }\n }\n\n if (error) {\n items.push(this._formatError(error as Error, size, groupSpaces));\n }\n\n if (traceError) {\n items.push(this._formatError(traceError as Error, size, groupSpaces, true));\n }\n\n if (suffix) {\n items.push(\"\\n\", groupSpaces + grey(this._styles.underline.suffix ? underline(suffix as string) : suffix));\n }\n\n return items.join(\"\") + \"\\n\";\n }\n\n protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void {\n const streamType = [\"error\", \"trace\", \"warn\"].includes(logLevel as string) ? \"stderr\" : \"stdout\";\n const stream = streamType === \"stderr\" ? this.#stderr : this.#stdout;\n\n if (this.#interactive && this.#interactiveManager !== undefined && stream.isTTY) {\n this.#interactiveManager.update(streamType, message.split(\"\\n\"), 0);\n } else {\n writeStream(message + \"\\n\", stream);\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n private _formatError(error: Error, size: number, groupSpaces: string, hideName = false): string {\n const { message, name, stack } = error;\n\n const items: string[] = [];\n\n items.push(\n ...(hideName ? [] : [groupSpaces + red(name), \": \"]),\n wrapAnsi(message, size - 3, {\n hard: true,\n trim: true,\n wordWrap: true,\n }),\n );\n\n if (stack) {\n const lines = stack\n .split(\"\\n\")\n .splice(1)\n .map((line: string) => groupSpaces + line.trim().replace(\"file://\", \"\"))\n .filter((line: string) => !line.includes(\"/pail/dist\"));\n\n items.push(\n \"\\n\",\n lines\n .map((line: string) => \" \" + line.replace(/^at +/, (m) => grey(m)).replace(/\\((.+)\\)/, (_, m) => \"(\" + cyan(m as string) + \")\"))\n .join(\"\\n\"),\n );\n }\n\n return items.join(\"\");\n }\n\n private _formatLabel(label: string): string {\n let formattedLabel = this._styles.uppercase.label ? label.toUpperCase() : label;\n\n formattedLabel = this._styles.underline.label ? underline(formattedLabel) : formattedLabel;\n\n if (this._styles.bold.label) {\n formattedLabel = bold(formattedLabel);\n }\n\n return formattedLabel;\n }\n}\n","export const writeStream = (data: string, stream: NodeJS.WriteStream): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/unbound-method\n const write = (stream as any).__write ?? stream.write;\n\n return write.call(stream, data);\n};\n"]}
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var fmt = require('@visulima/fmt');
4
+
5
+ var o=class{#t;#n;constructor(t={}){this.#n=t.formatters;}setStringify(t){this.#t=t;}process(t){let n=fmt.build({formatters:this.#n,stringify:r=>{let i=this.#t(r);return i===void 0?(console.warn("Unable to stringify value of type "+typeof r,r),"undefined"):i}});return t.message!==void 0&&(t.message=this._format(n,t.message,t.context??[])),t}_format(t,n,r=[]){if(typeof n=="string")return t(n,r);if(typeof n=="object"&&n!==null)for(let i in n){let e=n[i];(typeof e=="string"||Array.isArray(e)||typeof e=="object")&&(n[i]=this._format(t,e,r));}return n}};
6
+
7
+ exports.a = o;
8
+ //# sourceMappingURL=out.js.map
9
+ //# sourceMappingURL=chunk-F4FJCQ4L.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/processor/message-formatter-processor.ts"],"names":["build","MessageFormatterProcessor","#stringify","#formatters","options","function_","meta","formatter","value","stringified","data","arguments_","index"],"mappings":"AACA,OAAS,SAAAA,MAAa,gBAKf,IAAMC,EAAN,KAAiG,CAEpGC,GAESC,GAEF,YAAYC,EAA8D,CAAC,EAAG,CACjF,KAAKD,GAAcC,EAAQ,UAC/B,CAGO,aAAaC,EAAsB,CACtC,KAAKH,GAAaG,CACtB,CAEO,QAAQC,EAAwB,CACnC,IAAMC,EAAYP,EAAM,CACpB,WAAY,KAAKG,GACjB,UAAYK,GAAmB,CAC3B,IAAMC,EAAe,KAAKP,GAAgCM,CAAK,EAE/D,OAAIC,IAAgB,QAEhB,QAAQ,KAAK,qCAAuC,OAAOD,EAAOA,CAAK,EAEhE,aAGJC,CACX,CACJ,CAAY,EAEZ,OAAIH,EAAK,UAAY,SAEjBA,EAAK,QAAU,KAAK,QAAQC,EAAWD,EAAK,QAASA,EAAK,SAAW,CAAC,CAAC,GAGpEA,CACX,CAGQ,QAAQC,EAA0BG,EAAWC,EAAwB,CAAC,EAAQ,CAClF,GAAI,OAAOD,GAAS,SAChB,OAAOH,EAAUG,EAAgBC,CAAU,EAG/C,GAAI,OAAOD,GAAS,UAAYA,IAAS,KAErC,QAAWE,KAASF,EAAuD,CAEvE,IAAMF,EAASE,EAAaE,CAAK,GAE7B,OAAOJ,GAAU,UAAY,MAAM,QAAQA,CAAK,GAAK,OAAOA,GAAU,YAEtEE,EAAKE,CAAK,EAAI,KAAK,QAAQL,EAAWC,EAAOG,CAAU,EAE/D,CAGJ,OAAOD,CACX,CACJ","sourcesContent":["import type { format, FormatterFunction, Options } from \"@visulima/fmt\";\nimport { build } from \"@visulima/fmt\";\nimport type { stringify } from \"safe-stable-stringify\";\n\nimport type { Meta, StringifyAwareProcessor } from \"../types\";\n\nexport class MessageFormatterProcessor<L extends string = string> implements StringifyAwareProcessor<L> {\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n #stringify: typeof stringify | undefined;\n\n readonly #formatters: Record<string, FormatterFunction> | undefined;\n\n public constructor(options: { formatters?: Record<string, FormatterFunction> } = {}) {\n this.#formatters = options.formatters;\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n public setStringify(function_: any): void {\n this.#stringify = function_;\n }\n\n public process(meta: Meta<L>): Meta<L> {\n const formatter = build({\n formatters: this.#formatters,\n stringify: (value: unknown) => {\n const stringified = (this.#stringify as typeof stringify)(value);\n\n if (stringified === undefined) {\n // eslint-disable-next-line no-console\n console.warn(\"Unable to stringify value of type \" + typeof value, value);\n\n return \"undefined\";\n }\n\n return stringified;\n },\n } as Options);\n\n if (meta.message !== undefined) {\n // eslint-disable-next-line no-param-reassign\n meta.message = this._format(formatter, meta.message, meta.context ?? []);\n }\n\n return meta;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _format(formatter: typeof format, data: any, arguments_: unknown[] = []): any {\n if (typeof data === \"string\") {\n return formatter(data as string, arguments_);\n }\n\n if (typeof data === \"object\" && data !== null) {\n // eslint-disable-next-line guard-for-in,no-loops/no-loops,no-restricted-syntax\n for (const index in data as Record<string, unknown> | [string, unknown[]]) {\n // eslint-disable-next-line security/detect-object-injection,@typescript-eslint/no-explicit-any\n const value = (data as any)[index];\n\n if (typeof value === \"string\" || Array.isArray(value) || typeof value === \"object\") {\n // eslint-disable-next-line no-param-reassign,security/detect-object-injection\n data[index] = this._format(formatter, value, arguments_);\n }\n }\n }\n\n return data;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { a as a$1 } from './chunk-AFMDCM5W.js';
2
+ import { a } from './chunk-TAH23BHM.js';
3
+
4
+ var t=class extends a{constructor(){super();}_log(n,r){a$1(r)(n);}};
5
+
6
+ export { t as a };
7
+ //# sourceMappingURL=out.js.map
8
+ //# sourceMappingURL=chunk-KERJDMYV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/reporter/json/json.browser.ts"],"names":["JsonReporter","AbstractJsonReporter","message","logLevel","writeConsoleLogBasedOnLevel"],"mappings":"gFAIO,IAAMA,EAAN,cAAqDC,CAAwB,CACzE,aAAc,CACjB,MAAM,CACV,CAGmB,KAAKC,EAAiBC,EAA2D,CACrEC,EAA4BD,CAAQ,EAE5CD,CAAO,CAC9B,CACJ","sourcesContent":["import type { ExtendedRfc5424LogLevels, LiteralUnion } from \"../../types\";\nimport { writeConsoleLogBasedOnLevel } from \"../../util/write-console-log\";\nimport { AbstractJsonReporter } from \"./abstract-json-reporter\";\n\nexport class JsonReporter<L extends string = never> extends AbstractJsonReporter<L> {\n public constructor() {\n super();\n }\n\n // eslint-disable-next-line class-methods-use-this\n protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void {\n const consoleLogFunction = writeConsoleLogBasedOnLevel(logLevel);\n\n consoleLogFunction(message);\n }\n}\n"]}
@@ -1,5 +1,7 @@
1
+ 'use strict';
2
+
1
3
  var n=e=>e==="error"?console.__error??console.error:e==="warn"?console.__warn??console.warn:e==="trace"?console.__trace??console.trace:console.__log??console.log;
2
4
 
3
- export { n as a };
5
+ exports.a = n;
4
6
  //# sourceMappingURL=out.js.map
5
- //# sourceMappingURL=chunk-PVAYQO5O.js.map
7
+ //# sourceMappingURL=chunk-N2UPJYJR.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/util/write-console-log.ts"],"names":["writeConsoleLogBasedOnLevel","level"],"mappings":"AAGO,IAAMA,EAAyDC,GAC9DA,IAAU,QAEF,QAAgB,SAAW,QAAQ,MAG3CA,IAAU,OAEF,QAAgB,QAAU,QAAQ,KAG1CA,IAAU,QAEF,QAAgB,SAAW,QAAQ,MAIvC,QAAgB,OAAS,QAAQ","sourcesContent":["import type { ExtendedRfc5424LogLevels, LiteralUnion } from \"../types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const writeConsoleLogBasedOnLevel = <L extends string = never>(level: LiteralUnion<ExtendedRfc5424LogLevels, L>): ((...data: any[]) => void) => {\n if (level === \"error\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__error ?? console.error;\n }\n\n if (level === \"warn\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__warn ?? console.warn;\n }\n\n if (level === \"trace\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__trace ?? console.trace;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-console\n return (console as any).__log ?? console.log;\n};\n"]}
@@ -1,5 +1,5 @@
1
- var n={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},i={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"red",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"red",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blue",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"blue",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"green",label:"start",logLevel:"informational"},stop:{color:"yellow",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"magenta",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellow",label:"watching",logLevel:"informational"}};var L=l=>{let o=Object.keys(l).map(e=>l[e].label??"");return o.length===0?"":o.reduce((e,r)=>e.length>r.length?e:r)};
1
+ var n={alert:7,critical:6,debug:1,emergency:8,error:5,informational:2,notice:3,trace:2,warning:4},g={alert:{color:"red",label:"alert",logLevel:"alert"},await:{color:"blue",label:"awaiting",logLevel:"informational"},complete:{color:"cyan",label:"complete",logLevel:"informational"},critical:{color:"red",label:"critical",logLevel:"critical"},debug:{color:"gray",label:"debug",logLevel:"debug"},emergency:{color:"red",label:"emergency",logLevel:"emergency"},error:{color:"red",label:"error",logLevel:"error"},info:{color:"blue",label:"info",logLevel:"informational"},log:{label:"",logLevel:"informational"},notice:{color:"blue",label:"notice",logLevel:"notice"},pending:{color:"magenta",label:"pending",logLevel:"informational"},start:{color:"green",label:"start",logLevel:"informational"},stop:{color:"yellow",label:"stop",logLevel:"informational"},success:{color:"green",label:"success",logLevel:"informational"},trace:{color:"magenta",label:"trace",logLevel:"trace"},wait:{color:"blue",label:"waiting",logLevel:"informational"},warn:{color:"yellow",label:"warning",logLevel:"warning"},watch:{color:"yellow",label:"watching",logLevel:"informational"}};var L=l=>{let o=Object.keys(l).map(e=>l[e].label??"");return o.length===0?"":o.reduce((e,r)=>e.length>r.length?e:r)};
2
2
 
3
- export { n as a, i as b, L as c };
3
+ export { n as a, g as b, L as c };
4
4
  //# sourceMappingURL=out.js.map
5
- //# sourceMappingURL=chunk-EBP7SMYV.js.map
5
+ //# sourceMappingURL=chunk-NF47XQ47.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts","../src/util/get-longest-label.ts"],"names":["EXTENDED_RFC_5424_LOG_LEVELS","LOG_TYPES","getLongestLabel","types","labels","x","y"],"mappings":"AAMO,IAAMA,EAA+B,CACxC,MAAO,EACP,SAAU,EACV,MAAO,EACP,UAAW,EACX,MAAO,EACP,cAAe,EACf,OAAQ,EACR,MAAO,EACP,QAAS,CACb,EAEaC,EAAgC,CACzC,MAAO,CACH,MAAO,MACP,MAAO,QACP,SAAU,OACd,EACA,MAAO,CACH,MAAO,OACP,MAAO,WACP,SAAU,eACd,EACA,SAAU,CACN,MAAO,OACP,MAAO,WACP,SAAU,eACd,EACA,SAAU,CACN,MAAO,MACP,MAAO,WACP,SAAU,UACd,EACA,MAAO,CACH,MAAO,OACP,MAAO,QACP,SAAU,OACd,EACA,UAAW,CACP,MAAO,MACP,MAAO,YACP,SAAU,WACd,EACA,MAAO,CACH,MAAO,MACP,MAAO,QACP,SAAU,OACd,EACA,KAAM,CACF,MAAO,OACP,MAAO,OACP,SAAU,eACd,EACA,IAAK,CACD,MAAO,GACP,SAAU,eACd,EACA,OAAQ,CACJ,MAAO,OACP,MAAO,SACP,SAAU,QACd,EACA,QAAS,CACL,MAAO,UACP,MAAO,UACP,SAAU,eACd,EACA,MAAO,CACH,MAAO,QACP,MAAO,QACP,SAAU,eACd,EACA,KAAM,CACF,MAAO,SACP,MAAO,OACP,SAAU,eACd,EACA,QAAS,CACL,MAAO,QACP,MAAO,UACP,SAAU,eACd,EACA,MAAO,CACH,MAAO,UACP,MAAO,QACP,SAAU,OACd,EACA,KAAM,CACF,MAAO,OACP,MAAO,UACP,SAAU,eACd,EACA,KAAM,CACF,MAAO,SACP,MAAO,UACP,SAAU,SACd,EACA,MAAO,CACH,MAAO,SACP,MAAO,WACP,SAAU,eACd,CACJ,ECxGO,IAAMC,EAAuDC,GAA0E,CAE1I,IAAMC,EAAS,OAAO,KAAKD,CAAK,EAAE,IAAKE,GAAMF,EAAME,CAAM,EAAE,OAAS,EAAE,EAEtE,OAAID,EAAO,SAAW,EACX,GAIJA,EAAO,OAAO,CAACC,EAAGC,IAAOD,EAAE,OAASC,EAAE,OAASD,EAAIC,CAAE,CAChE","sourcesContent":["import type { DefaultLoggerTypes } from \"./types\";\n\n/**\n * Log Levels\n * The log levels pail uses are those defined in the syslog protocol @see https://datatracker.ietf.org/doc/html/rfc5424#page-36, which are:\n */\nexport const EXTENDED_RFC_5424_LOG_LEVELS = {\n alert: 7, // Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.\n critical: 6, // Critical conditions. Example: Application component unavailable, unexpected exception.\n debug: 1, // Detailed debug information.\n emergency: 8, // Emergency: system is unusable.\n error: 5, // Runtime errors that do not require immediate action but should typically be logged and monitored.\n informational: 2, // Interesting events. Examples: User logs in, SQL logs.\n notice: 3, // Normal but significant events.\n trace: 2, // Trace information.\n warning: 4, // Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.\n};\n\nexport const LOG_TYPES: DefaultLoggerTypes = {\n alert: {\n color: \"red\",\n label: \"alert\",\n logLevel: \"alert\",\n },\n await: {\n color: \"blue\",\n label: \"awaiting\",\n logLevel: \"informational\",\n },\n complete: {\n color: \"cyan\",\n label: \"complete\",\n logLevel: \"informational\",\n },\n critical: {\n color: \"red\",\n label: \"critical\",\n logLevel: \"critical\",\n },\n debug: {\n color: \"gray\",\n label: \"debug\",\n logLevel: \"debug\",\n },\n emergency: {\n color: \"red\",\n label: \"emergency\",\n logLevel: \"emergency\",\n },\n error: {\n color: \"red\",\n label: \"error\",\n logLevel: \"error\",\n },\n info: {\n color: \"blue\",\n label: \"info\",\n logLevel: \"informational\",\n },\n log: {\n label: \"\",\n logLevel: \"informational\",\n },\n notice: {\n color: \"blue\",\n label: \"notice\",\n logLevel: \"notice\",\n },\n pending: {\n color: \"magenta\",\n label: \"pending\",\n logLevel: \"informational\",\n },\n start: {\n color: \"green\",\n label: \"start\",\n logLevel: \"informational\",\n },\n stop: {\n color: \"yellow\",\n label: \"stop\",\n logLevel: \"informational\",\n },\n success: {\n color: \"green\",\n label: \"success\",\n logLevel: \"informational\",\n },\n trace: {\n color: \"magenta\",\n label: \"trace\",\n logLevel: \"trace\",\n },\n wait: {\n color: \"blue\",\n label: \"waiting\",\n logLevel: \"informational\",\n },\n warn: {\n color: \"yellow\",\n label: \"warning\",\n logLevel: \"warning\",\n },\n watch: {\n color: \"yellow\",\n label: \"watching\",\n logLevel: \"informational\",\n },\n};\n","import type { LiteralUnion } from \"type-fest\";\n\nimport type { DefaultLogTypes, LoggerTypesConfig } from \"../types\";\n\nexport const getLongestLabel = <L extends string, T extends string>(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): string => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n const labels = Object.keys(types).map((x) => types[x as T].label ?? \"\");\n\n if (labels.length === 0) {\n return \"\";\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce\n return labels.reduce((x, y) => (x.length > y.length ? x : y));\n};\n"]}
1
+ {"version":3,"sources":["../src/constants.ts","../src/util/get-longest-label.ts"],"names":["EXTENDED_RFC_5424_LOG_LEVELS","LOG_TYPES","getLongestLabel","types","labels","x","y"],"mappings":"AAMO,IAAMA,EAA+B,CACxC,MAAO,EACP,SAAU,EACV,MAAO,EACP,UAAW,EACX,MAAO,EACP,cAAe,EACf,OAAQ,EACR,MAAO,EACP,QAAS,CACb,EAEaC,EAAgC,CACzC,MAAO,CACH,MAAO,MACP,MAAO,QACP,SAAU,OACd,EACA,MAAO,CACH,MAAO,OACP,MAAO,WACP,SAAU,eACd,EACA,SAAU,CACN,MAAO,OACP,MAAO,WACP,SAAU,eACd,EACA,SAAU,CACN,MAAO,MACP,MAAO,WACP,SAAU,UACd,EACA,MAAO,CACH,MAAO,OACP,MAAO,QACP,SAAU,OACd,EACA,UAAW,CACP,MAAO,MACP,MAAO,YACP,SAAU,WACd,EACA,MAAO,CACH,MAAO,MACP,MAAO,QACP,SAAU,OACd,EACA,KAAM,CACF,MAAO,OACP,MAAO,OACP,SAAU,eACd,EACA,IAAK,CACD,MAAO,GACP,SAAU,eACd,EACA,OAAQ,CACJ,MAAO,OACP,MAAO,SACP,SAAU,QACd,EACA,QAAS,CACL,MAAO,UACP,MAAO,UACP,SAAU,eACd,EACA,MAAO,CACH,MAAO,QACP,MAAO,QACP,SAAU,eACd,EACA,KAAM,CACF,MAAO,SACP,MAAO,OACP,SAAU,eACd,EACA,QAAS,CACL,MAAO,QACP,MAAO,UACP,SAAU,eACd,EACA,MAAO,CACH,MAAO,UACP,MAAO,QACP,SAAU,OACd,EACA,KAAM,CACF,MAAO,OACP,MAAO,UACP,SAAU,eACd,EACA,KAAM,CACF,MAAO,SACP,MAAO,UACP,SAAU,SACd,EACA,MAAO,CACH,MAAO,SACP,MAAO,WACP,SAAU,eACd,CACJ,EC1GO,IAAMC,EAAuDC,GAA0E,CAC1I,IAAMC,EAAS,OAAO,KAAKD,CAAK,EAAE,IAAKE,GAAMF,EAAME,CAAM,EAAE,OAAS,EAAE,EAEtE,OAAID,EAAO,SAAW,EACX,GAIJA,EAAO,OAAO,CAACC,EAAGC,IAAOD,EAAE,OAASC,EAAE,OAASD,EAAIC,CAAE,CAChE","sourcesContent":["import type { DefaultLoggerTypes } from \"./types\";\n\n/**\n * Log Levels\n * The log levels pail uses are those defined in the syslog protocol @see https://datatracker.ietf.org/doc/html/rfc5424#page-36, which are:\n */\nexport const EXTENDED_RFC_5424_LOG_LEVELS = {\n alert: 7, // Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.\n critical: 6, // Critical conditions. Example: Application component unavailable, unexpected exception.\n debug: 1, // Detailed debug information.\n emergency: 8, // Emergency: system is unusable.\n error: 5, // Runtime errors that do not require immediate action but should typically be logged and monitored.\n informational: 2, // Interesting events. Examples: User logs in, SQL logs.\n notice: 3, // Normal but significant events.\n trace: 2, // Trace information.\n warning: 4, // Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.\n};\n\nexport const LOG_TYPES: DefaultLoggerTypes = {\n alert: {\n color: \"red\",\n label: \"alert\",\n logLevel: \"alert\",\n },\n await: {\n color: \"blue\",\n label: \"awaiting\",\n logLevel: \"informational\",\n },\n complete: {\n color: \"cyan\",\n label: \"complete\",\n logLevel: \"informational\",\n },\n critical: {\n color: \"red\",\n label: \"critical\",\n logLevel: \"critical\",\n },\n debug: {\n color: \"gray\",\n label: \"debug\",\n logLevel: \"debug\",\n },\n emergency: {\n color: \"red\",\n label: \"emergency\",\n logLevel: \"emergency\",\n },\n error: {\n color: \"red\",\n label: \"error\",\n logLevel: \"error\",\n },\n info: {\n color: \"blue\",\n label: \"info\",\n logLevel: \"informational\",\n },\n log: {\n label: \"\",\n logLevel: \"informational\",\n },\n notice: {\n color: \"blue\",\n label: \"notice\",\n logLevel: \"notice\",\n },\n pending: {\n color: \"magenta\",\n label: \"pending\",\n logLevel: \"informational\",\n },\n start: {\n color: \"green\",\n label: \"start\",\n logLevel: \"informational\",\n },\n stop: {\n color: \"yellow\",\n label: \"stop\",\n logLevel: \"informational\",\n },\n success: {\n color: \"green\",\n label: \"success\",\n logLevel: \"informational\",\n },\n trace: {\n color: \"magenta\",\n label: \"trace\",\n logLevel: \"trace\",\n },\n wait: {\n color: \"blue\",\n label: \"waiting\",\n logLevel: \"informational\",\n },\n warn: {\n color: \"yellow\",\n label: \"warning\",\n logLevel: \"warning\",\n },\n watch: {\n color: \"yellow\",\n label: \"watching\",\n logLevel: \"informational\",\n },\n};\n","import type { DefaultLogTypes, LiteralUnion, LoggerTypesConfig } from \"../types\";\n\nexport const getLongestLabel = <L extends string, T extends string>(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): string => {\n const labels = Object.keys(types).map((x) => types[x as T].label ?? \"\");\n\n if (labels.length === 0) {\n return \"\";\n }\n\n // eslint-disable-next-line unicorn/no-array-reduce\n return labels.reduce((x, y) => (x.length > y.length ? x : y));\n};\n"]}
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var chunkYP3U3DTV_cjs = require('./chunk-YP3U3DTV.cjs');
4
+ var chunkQINSQ6TU_cjs = require('./chunk-QINSQ6TU.cjs');
5
+ var P = require('@visulima/colorize');
6
+ var L = require('string-length');
7
+ var D = require('terminal-size');
8
+ var z = require('wrap-ansi');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var P__default = /*#__PURE__*/_interopDefault(P);
13
+ var L__default = /*#__PURE__*/_interopDefault(L);
14
+ var D__default = /*#__PURE__*/_interopDefault(D);
15
+ var z__default = /*#__PURE__*/_interopDefault(z);
16
+
17
+ var W=(v,e)=>(e.__write??e.write).call(e,v);var A=class extends chunkYP3U3DTV_cjs.b{#e;#t;#r;#s=!1;constructor(e={}){super({uppercase:{label:!0,...e.uppercase},...e}),this.#e=process.stdout,this.#t=process.stderr;}setStdout(e){this.#e=e;}setStderr(e){this.#t=e;}setInteractiveManager(e){this.#r=e;}setIsInteractive(e){this.#s=e;}log(e){this._log(this._formatMessage(e),e.type.level);}_formatMessage(e){let{columns:r}=D__default.default(),s=r;typeof this._styles.messageLength=="number"&&(s=this._styles.messageLength);let{badge:o,context:u,date:y,error:g,file:a,groups:f,label:n,message:p,prefix:c,repeated:S,scope:d,suffix:b,traceError:M,type:J}=e,{color:w}=this._loggerTypes[J.name],x=w?P__default.default[w]:P.white,h=f.map(()=>" ").join(""),t=[];if(f.length>0&&t.push(h+P.grey("["+f.at(-1)+"] ")),y&&t.push(P.grey(this._styles.dateFormatter(new Date(y)))+" "),o)t.push(x(o));else {let l=chunkYP3U3DTV_cjs.a(this._loggerTypes);l.length>0&&t.push(P.grey(".".repeat(l.length))+" ");}let T=chunkQINSQ6TU_cjs.c(this._loggerTypes);n?t.push(x(this._formatLabel(n))+" ",P.grey(".".repeat(T.length-L__default.default(n)))):t.push(P.grey(".".repeat(T.length+2))),S&&t.push(P.bgGrey.white("["+S+"x]")+" "),Array.isArray(d)&&d.length>0&&t.push(P.grey(" ["+d.join(" > ")+"] ")),c&&t.push(P.grey((Array.isArray(d)&&d.length>0?". ":" ")+"["+(this._styles.underline.prefix?P.underline(c):c)+"] "));let E=L__default.default(t.join(" "));if(a){let l=a.name+(a.line?":"+a.line:""),m=L__default.default(l);t.push(P.grey(".".repeat(s-E-m-2)+" "+l));}else t.push(P.grey(".".repeat(s-E-1)));if(t.length>0&&t.push(`
18
+
19
+ `),p){let l=typeof p=="string"?p:this._stringify(p);t.push(h+z__default.default(l??"undefined",s-3,{hard:!0,trim:!0,wordWrap:!0})),u&&t.push(...u.map(m=>typeof m=="object"?" "+this._stringify(m):" "+m));}return g&&t.push(this._formatError(g,s,h)),M&&t.push(this._formatError(M,s,h,!0)),b&&t.push(`
20
+ `,h+P.grey(this._styles.underline.suffix?P.underline(b):b)),t.join("")+`
21
+ `}_log(e,r){let s=["error","trace","warn"].includes(r)?"stderr":"stdout",o=s==="stderr"?this.#t:this.#e;this.#s&&this.#r!==void 0&&o.isTTY?this.#r.update(s,e.split(`
22
+ `),0):W(e+`
23
+ `,o);}_formatError(e,r,s,o=!1){let{message:u,name:y,stack:g}=e,a=[];if(a.push(...o?[]:[s+P.red(y),": "],z__default.default(u,r-3,{hard:!0,trim:!0,wordWrap:!0})),g){let f=g.split(`
24
+ `).splice(1).map(n=>s+n.trim().replace("file://","")).filter(n=>!n.includes("/pail/dist"));a.push(`
25
+ `,f.map(n=>" "+n.replace(/^at +/,p=>P.grey(p)).replace(/\((.+)\)/,(p,c)=>"("+P.cyan(c)+")")).join(`
26
+ `));}return a.join("")}_formatLabel(e){let r=this._styles.uppercase.label?e.toUpperCase():e;return r=this._styles.underline.label?P.underline(r):r,this._styles.bold.label&&(r=P.bold(r)),r}};
27
+
28
+ exports.a = W;
29
+ exports.b = A;
30
+ //# sourceMappingURL=out.js.map
31
+ //# sourceMappingURL=chunk-O34IIMWQ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/reporter/pretty/pretty.server.ts","../src/util/write-stream.ts"],"names":["colorize","bgGrey","bold","cyan","grey","red","underline","white","stringLength","terminalSize","wrapAnsi","writeStream","data","stream","PrettyReporter","AbstractPrettyReporter","#stdout","#stderr","#interactiveManager","#interactive","options","stdout","stderr","manager","interactive","meta","columns","size","badge","context","date","error","file","groups","label","message","prefix","repeated","scope","suffix","traceError","type","color","colorized","groupSpaces","items","longestBadge","getLongestBadge","longestLabel","getLongestLabel","titleSize","fileMessage","fileMessageSize","formattedMessage","value","logLevel","streamType","hideName","name","stack","lines","line","m","_","formattedLabel"],"mappings":"yFAAA,OAAOA,GAAY,UAAAC,EAAQ,QAAAC,EAAM,QAAAC,EAAM,QAAAC,EAAM,OAAAC,EAAK,aAAAC,EAAW,SAAAC,MAAa,qBAE1E,OAAOC,MAAkB,gBACzB,OAAOC,MAAkB,gBACzB,OAAOC,MAAc,YCJd,IAAMC,EAAc,CAACC,EAAcC,KAEvBA,EAAe,SAAWA,EAAO,OAEnC,KAAKA,EAAQD,CAAI,EDU3B,IAAME,EAAN,cAAiFC,CAAqE,CACzJC,GAEAC,GAEAC,GAEAC,GAAe,GAER,YAAYC,EAAuC,CAAC,EAAG,CAC1D,MAAM,CACF,UAAW,CACP,MAAO,GACP,GAAGA,EAAQ,SACf,EACA,GAAGA,CACP,CAAC,EAED,KAAKJ,GAAU,QAAQ,OACvB,KA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,EAAE,CAAC,EACtE,OAAQA,GAAiB,CAACA,EAAK,SAAS,YAAY,CAAC,EAE1DhB,EAAM,KACF;AAAA,EACAe,EACK,IAAKC,GAAiB,KAAOA,EAAK,QAAQ,QAAUC,GAAM1D,EAAK0D,CAAC,CAAC,EAAE,QAAQ,WAAY,CAACC,EAAGD,IAAM,IAAM3D,EAAK2D,CAAW,EAAI,GAAG,CAAC,EAC/H,KAAK;AAAA,CAAI,CAClB,CACJ,CAEA,OAAOjB,EAAM,KAAK,EAAE,CACxB,CAEQ,aAAaX,EAAuB,CACxC,IAAI8B,EAAiB,KAAK,QAAQ,UAAU,MAAQ9B,EAAM,YAAY,EAAIA,EAE1E,OAAA8B,EAAiB,KAAK,QAAQ,UAAU,MAAQ1D,EAAU0D,CAAc,EAAIA,EAExE,KAAK,QAAQ,KAAK,QAClBA,EAAiB9D,EAAK8D,CAAc,GAGjCA,CACX,CACJ","sourcesContent":["import colorize, { bgGrey, bold, cyan, grey, red, underline, white } from \"@visulima/colorize\";\nimport type { stringify } from \"safe-stable-stringify\";\nimport stringLength from \"string-length\";\nimport terminalSize from \"terminal-size\";\nimport wrapAnsi from \"wrap-ansi\";\n\nimport type { InteractiveManager } from \"../../interactive/interactive-manager\";\nimport type { ExtendedRfc5424LogLevels, InteractiveStreamReporter, LiteralUnion, ReadonlyMeta } from \"../../types\";\nimport { getLongestBadge } from \"../../util/get-longest-badge\";\nimport { getLongestLabel } from \"../../util/get-longest-label\";\nimport { writeStream } from \"../../util/write-stream\";\nimport type { PrettyStyleOptions } from \"./abstract-pretty-reporter\";\nimport { AbstractPrettyReporter } from \"./abstract-pretty-reporter\";\n\nexport class PrettyReporter<T extends string = never, L extends string = never> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {\n #stdout: NodeJS.WriteStream;\n\n #stderr: NodeJS.WriteStream;\n\n #interactiveManager: InteractiveManager | undefined;\n\n #interactive = false;\n\n public constructor(options: Partial<PrettyStyleOptions> = {}) {\n super({\n uppercase: {\n label: true,\n ...options.uppercase,\n },\n ...options,\n });\n\n this.#stdout = process.stdout;\n this.#stderr = process.stderr;\n }\n\n public setStdout(stdout: NodeJS.WriteStream): void {\n this.#stdout = stdout;\n }\n\n public setStderr(stderr: NodeJS.WriteStream): void {\n this.#stderr = stderr;\n }\n\n public setInteractiveManager(manager?: InteractiveManager): void {\n this.#interactiveManager = manager;\n }\n\n public setIsInteractive(interactive: boolean): void {\n this.#interactive = interactive;\n }\n\n public log(meta: ReadonlyMeta<L>): void {\n this._log(this._formatMessage(meta as ReadonlyMeta<L>), meta.type.level);\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n protected _formatMessage(data: ReadonlyMeta<L>): string {\n const { columns } = terminalSize();\n\n let size = columns;\n\n if (typeof this._styles.messageLength === \"number\") {\n size = this._styles.messageLength;\n }\n\n const { badge, context, date, error, file, groups, label, message, prefix, repeated, scope, suffix, traceError, type } = data;\n\n const { color } = this._loggerTypes[type.name as keyof typeof this._loggerTypes];\n // eslint-disable-next-line security/detect-object-injection\n const colorized = color ? colorize[color] : white;\n\n const groupSpaces: string = groups.map(() => \" \").join(\"\");\n const items: string[] = [];\n\n if (groups.length > 0) {\n items.push((groupSpaces + grey(\"[\" + groups.at(-1) + \"] \")) as string);\n }\n\n if (date) {\n items.push(grey(this._styles.dateFormatter(new Date(date))) + \" \");\n }\n\n if (badge) {\n items.push(colorized(badge) as string);\n } else {\n const longestBadge: string = getLongestBadge<L, T>(this._loggerTypes);\n\n if (longestBadge.length > 0) {\n items.push(grey(\".\".repeat(longestBadge.length)) + \" \");\n }\n }\n\n const longestLabel: string = getLongestLabel<L, T>(this._loggerTypes);\n\n if (label) {\n items.push(colorized(this._formatLabel(label as string)) + \" \", grey(\".\".repeat(longestLabel.length - stringLength(label as string))));\n } else {\n // plus 2 for the space and the dot\n items.push(grey(\".\".repeat(longestLabel.length + 2)));\n }\n\n if (repeated) {\n items.push(bgGrey.white(\"[\" + repeated + \"x]\") + \" \");\n }\n\n if (Array.isArray(scope) && scope.length > 0) {\n items.push(grey(\" [\" + scope.join(\" > \") + \"] \"));\n }\n\n if (prefix) {\n items.push(\n grey(\n (Array.isArray(scope) && scope.length > 0 ? \". \" : \" \") +\n \"[\" +\n (this._styles.underline.prefix ? underline(prefix as string) : prefix) +\n \"] \",\n ),\n );\n }\n\n const titleSize = stringLength(items.join(\" \"));\n\n if (file) {\n const fileMessage = file.name + (file.line ? \":\" + file.line : \"\");\n const fileMessageSize = stringLength(fileMessage);\n\n items.push(grey(\".\".repeat(size - titleSize - fileMessageSize - 2) + \" \" + fileMessage));\n } else {\n items.push(grey(\".\".repeat(size - titleSize - 1)));\n }\n\n if (items.length > 0) {\n items.push(\"\\n\\n\");\n }\n\n if (message) {\n const formattedMessage: string | undefined = typeof message === \"string\" ? message : (this._stringify as typeof stringify)(message);\n\n items.push(\n groupSpaces +\n wrapAnsi(formattedMessage ?? \"undefined\", size - 3, {\n hard: true,\n trim: true,\n wordWrap: true,\n }),\n );\n\n if (context) {\n items.push(\n ...context.map((value) => {\n if (typeof value === \"object\") {\n return \" \" + (this._stringify as typeof stringify)(value);\n }\n\n return \" \" + value;\n }),\n );\n }\n }\n\n if (error) {\n items.push(this._formatError(error as Error, size, groupSpaces));\n }\n\n if (traceError) {\n items.push(this._formatError(traceError as Error, size, groupSpaces, true));\n }\n\n if (suffix) {\n items.push(\"\\n\", groupSpaces + grey(this._styles.underline.suffix ? underline(suffix as string) : suffix));\n }\n\n return items.join(\"\") + \"\\n\";\n }\n\n protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void {\n const streamType = [\"error\", \"trace\", \"warn\"].includes(logLevel as string) ? \"stderr\" : \"stdout\";\n const stream = streamType === \"stderr\" ? this.#stderr : this.#stdout;\n\n if (this.#interactive && this.#interactiveManager !== undefined && stream.isTTY) {\n this.#interactiveManager.update(streamType, message.split(\"\\n\"), 0);\n } else {\n writeStream(message + \"\\n\", stream);\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n private _formatError(error: Error, size: number, groupSpaces: string, hideName = false): string {\n const { message, name, stack } = error;\n\n const items: string[] = [];\n\n items.push(\n ...(hideName ? [] : [groupSpaces + red(name), \": \"]),\n wrapAnsi(message, size - 3, {\n hard: true,\n trim: true,\n wordWrap: true,\n }),\n );\n\n if (stack) {\n const lines = stack\n .split(\"\\n\")\n .splice(1)\n .map((line: string) => groupSpaces + line.trim().replace(\"file://\", \"\"))\n .filter((line: string) => !line.includes(\"/pail/dist\"));\n\n items.push(\n \"\\n\",\n lines\n .map((line: string) => \" \" + line.replace(/^at +/, (m) => grey(m)).replace(/\\((.+)\\)/, (_, m) => \"(\" + cyan(m as string) + \")\"))\n .join(\"\\n\"),\n );\n }\n\n return items.join(\"\");\n }\n\n private _formatLabel(label: string): string {\n let formattedLabel = this._styles.uppercase.label ? label.toUpperCase() : label;\n\n formattedLabel = this._styles.underline.label ? underline(formattedLabel) : formattedLabel;\n\n if (this._styles.bold.label) {\n formattedLabel = bold(formattedLabel);\n }\n\n return formattedLabel;\n }\n}\n","export const writeStream = (data: string, stream: NodeJS.WriteStream): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/unbound-method\n const write = (stream as any).__write ?? stream.write;\n\n return write.call(stream, data);\n};\n"]}
@@ -6,4 +6,4 @@ exports.a = t;
6
6
  exports.b = n;
7
7
  exports.c = c;
8
8
  //# sourceMappingURL=out.js.map
9
- //# sourceMappingURL=chunk-MU2CRXVO.cjs.map
9
+ //# sourceMappingURL=chunk-QINSQ6TU.cjs.map