@visulima/pail 4.1.0 → 5.0.0

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 (69) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE.md +5 -811
  3. package/dist/error.js +3 -3
  4. package/dist/index.browser.d.ts +2 -4
  5. package/dist/index.browser.js +19 -19
  6. package/dist/index.server.d.ts +2 -3
  7. package/dist/index.server.js +27 -28
  8. package/dist/middleware/elysia.js +1 -1
  9. package/dist/middleware/express.js +1 -1
  10. package/dist/middleware/fastify.js +1 -1
  11. package/dist/middleware/hono.js +1 -1
  12. package/dist/middleware/next/handler.d.ts +0 -1
  13. package/dist/middleware/next/handler.js +1 -1
  14. package/dist/middleware/sveltekit.js +1 -1
  15. package/dist/object-tree.js +2 -2
  16. package/dist/packem_shared/AbstractJsonReporter-DPsVS6w5.js +1 -0
  17. package/dist/packem_shared/AbstractJsonReporter-elZG6xkO.js +1 -0
  18. package/dist/packem_shared/JsonReporter-CY90KVxK.js +2 -0
  19. package/dist/packem_shared/JsonReporter-DX9fJfwQ.js +1 -0
  20. package/dist/packem_shared/{PailError-CbU1Ogfa.js → PailError-BgUh0gyX.js} +3 -3
  21. package/dist/packem_shared/PrettyReporter-B3yHM4Cb.js +47 -0
  22. package/dist/packem_shared/PrettyReporter-ClyBiPyQ.js +5 -0
  23. package/dist/packem_shared/abstract-pretty-reporter-C1W1vIw-.js +36 -0
  24. package/dist/packem_shared/headers-BjUW0cAm.js +1 -0
  25. package/dist/packem_shared/{index-CbkPnylC.js → index-pjyHJq0E.js} +1 -1
  26. package/dist/packem_shared/pailMiddleware-lhLj-hzE.js +1 -0
  27. package/dist/packem_shared/serializeError-Kr3JL9UN-zwOuO-gY.js +1 -0
  28. package/dist/packem_shared/storage-DP9QMOmG.js +1 -0
  29. package/dist/packem_shared/{types.d-DGHeA2iJ.d.ts → types.d-DNoig6eq.d.ts} +37 -3
  30. package/dist/packem_shared/{types.d-BW8kAXUv.d.ts → types.d-OiMbrp8C.d.ts} +37 -2
  31. package/dist/packem_shared/{useLogger-7p55yvvc.js → useLogger-HtOIBW7n.js} +1 -1
  32. package/dist/packem_shared/write-console-log-based-on-level-CG0mniaO.js +1 -0
  33. package/dist/packem_shared/write-stream-D2XwCKdN.js +1 -0
  34. package/dist/processor/caller/caller-processor.js +1 -1
  35. package/dist/processor/environment-processor.js +1 -1
  36. package/dist/processor/message-formatter-processor.js +1 -1
  37. package/dist/processor/opentelemetry-processor.js +1 -1
  38. package/dist/processor/redact-processor.d.ts +58 -0
  39. package/dist/processor/redact-processor.js +1 -1
  40. package/dist/processor/sampling-processor.js +1 -1
  41. package/dist/reporter/file/json-file-reporter.js +2 -2
  42. package/dist/reporter/http/abstract-http-reporter.js +2 -2
  43. package/dist/reporter/http/http-reporter.edge-light.d.ts +0 -2
  44. package/dist/reporter/http/http-reporter.edge-light.js +2 -2
  45. package/dist/reporter/http/http-reporter.js +1 -1
  46. package/dist/reporter/json/index.browser.d.ts +1 -3
  47. package/dist/reporter/json/index.browser.js +1 -1
  48. package/dist/reporter/json/index.js +1 -1
  49. package/dist/reporter/pretty/index.browser.d.ts +1 -3
  50. package/dist/reporter/pretty/index.browser.js +1 -1
  51. package/dist/reporter/pretty/index.d.ts +41 -5
  52. package/dist/reporter/pretty/index.js +1 -1
  53. package/dist/reporter/simple/simple-reporter.server.d.ts +40 -5
  54. package/dist/reporter/simple/simple-reporter.server.js +7 -7
  55. package/dist/wide-event.js +1 -1
  56. package/package.json +3 -3
  57. package/dist/packem_shared/AbstractJsonReporter-BpWRnN0L.js +0 -1
  58. package/dist/packem_shared/AbstractJsonReporter-DxZwImm5.js +0 -1
  59. package/dist/packem_shared/JsonReporter-9IcELa1m.js +0 -2
  60. package/dist/packem_shared/JsonReporter-Dd3kuj8X.js +0 -1
  61. package/dist/packem_shared/PrettyReporter-BUWNEg3_.js +0 -5
  62. package/dist/packem_shared/PrettyReporter-DbgD89ck.js +0 -70
  63. package/dist/packem_shared/abstract-pretty-reporter-CyfTvmKf.js +0 -59
  64. package/dist/packem_shared/headers-DI58djdG.js +0 -1
  65. package/dist/packem_shared/pailMiddleware-B5DJoBYl.js +0 -1
  66. package/dist/packem_shared/serializeError-52C4oiKx-CrnRcq9R.js +0 -1
  67. package/dist/packem_shared/storage-DVcJumyk.js +0 -1
  68. package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +0 -1
  69. package/dist/packem_shared/write-stream-ytl_vhg_.js +0 -1
@@ -1 +1 @@
1
- let h;const B=()=>(h!==void 0||(h=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),h),$=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,A=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,S=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,v=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,k=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),x=/\s+/,m=e=>{const t=B();t.has(e)&&(e=t.get(e));const r=$.exec(e);if(r)return[Number.parseInt(r[1],16),Number.parseInt(r[2],16),Number.parseInt(r[3],16)];const l=A.exec(e);if(l)return[Number.parseInt(`${l[1]}${l[1]}`,16),Number.parseInt(`${l[2]}${l[2]}`,16),Number.parseInt(`${l[3]}${l[3]}`,16)];const f=S.exec(e);if(f)return[Math.round(Math.max(0,Math.min(255,Number(f[1])))),Math.round(Math.max(0,Math.min(255,Number(f[2])))),Math.round(Math.max(0,Math.min(255,Number(f[3]))))];const n=v.exec(e);if(n){let a=Number(n[1])%360;a<0&&(a+=360);const i=Math.max(0,Math.min(100,Number(n[2])))/100,s=Math.max(0,Math.min(100,Number(n[3])))/100,u=(1-Math.abs(2*s-1))*i,b=u*(1-Math.abs(a/60%2-1)),o=s-u/2;let d,c,g;return a<60?{0:d,1:c,2:g}=[u,b,0]:a<120?{0:d,1:c,2:g}=[b,u,0]:a<180?{0:d,1:c,2:g}=[0,u,b]:a<240?{0:d,1:c,2:g}=[0,b,u]:a<300?{0:d,1:c,2:g}=[b,0,u]:{0:d,1:c,2:g}=[u,0,b],[Math.round((d+o)*255),Math.round((c+o)*255),Math.round((g+o)*255)]}return null},y=(e,t)=>typeof e=="string"||typeof t=="string"?e===t:e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],N=e=>{if(typeof e!="string")return k();const t=k(),r=[];let l=!1,f=null,n=0,a="";for(const i of e){if(i==="(")n+=1;else if(n>0)i===")"&&(n-=1);else if(l){if(i===";"){const s=a.trim();s!==""&&r.push([f,s]),f=null,a="",l=!1;continue}}else if(i===":"){f=a.trim(),a="",l=!0;continue}a+=i}if(l&&n===0){const i=a.trim();i!==""&&r.push([f,i]),f=null,a=""}for(const{0:i,1:s}of r)switch(i){case"background-color":{s!=null&&(t.backgroundColor=s);break}case"color":{s!=null&&(t.color=s);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(s)&&(t.fontStyle="italic");break}case"font-weight":{s==="bold"&&(t.fontWeight=s);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const u=s.split(x);for(const b of u){const o=m(b);o!=null?t.textDecorationColor=o:["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b)}break}case"text-decoration-color":{const u=m(s);u!=null&&(t.textDecorationColor=u);break}case"text-decoration-line":{t.textDecorationLine=[];const u=s.split(x);for(const b of u)["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b);break}}return t},D=(e,t)=>{t=t??k();let r="";if(!y(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)r+="\x1B[49m";else switch(e.backgroundColor){case"black":{r+="\x1B[40m";break}case"blue":{r+="\x1B[44m";break}case"cyan":{r+="\x1B[46m";break}case"green":{r+="\x1B[42m";break}case"magenta":{r+="\x1B[45m";break}case"red":{r+="\x1B[41m";break}case"white":{r+="\x1B[47m";break}case"yellow":{r+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:l,1:f,2:n}=e.backgroundColor;r+=`\x1B[48;2;${String(l)};${String(f)};${String(n)}m`}else{const l=m(e.backgroundColor);if(l===null)r+="\x1B[49m";else{const{0:f,1:n,2:a}=l;r+=`\x1B[48;2;${String(f)};${String(n)};${String(a)}m`}}}if(!y(e.color,t.color))if(e.color==null)r+="\x1B[39m";else switch(e.color){case"black":{r+="\x1B[30m";break}case"blue":{r+="\x1B[34m";break}case"cyan":{r+="\x1B[36m";break}case"green":{r+="\x1B[32m";break}case"magenta":{r+="\x1B[35m";break}case"red":{r+="\x1B[31m";break}case"white":{r+="\x1B[37m";break}case"yellow":{r+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:l,1:f,2:n}=e.color;r+=`\x1B[38;2;${String(l)};${String(f)};${String(n)}m`}else{const l=m(e.color);if(l===null)r+="\x1B[39m";else{const{0:f,1:n,2:a}=l;r+=`\x1B[38;2;${String(f)};${String(n)};${String(a)}m`}}}if(e.fontWeight!==t.fontWeight&&(r+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(r+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!y(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)r+="\x1B[59m";else{const{0:l,1:f,2:n}=e.textDecorationColor;r+=`\x1B[58;2;${String(l)};${String(f)};${String(n)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(r+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(r+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(r+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),r},M=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},p="%".codePointAt(0),C="s".codePointAt(0),j="d".codePointAt(0),L="f".codePointAt(0),F="i".codePointAt(0),P="O".codePointAt(0),q="o".codePointAt(0),E="j".codePointAt(0),O="c".codePointAt(0),w=(e,t=[],r={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const l=r.stringify??M,f=1;if(typeof e=="object"){const o=t.length+f;if(o===1)return"{}";const d=Array.from({length:o});d[0]=l(e);for(let c=1;c<o;c+=1)d[c]=l(t[c-f]);return d.join(" ")}if(t.length===0)return e;let n="",a=1-f,i=-1,s=!1,u;const b=r.colors??globalThis.window===void 0;for(let o=0;o<e.length;){if(e.codePointAt(o)===p&&o+1<e.length){i=i>-1?i:0;const d=e.codePointAt(o+1);switch(d){case O:{if(i<o&&(n+=e.slice(i,o)),b){const c=N(t[a]),g=D(c,u);n+=g,g!==""&&(s=!0,u=c)}i=o+2,o+=1;break}case j:case L:{const c=t[a];if(a>=t.length||c==null)break;i<o&&(n+=e.slice(i,o)),n+=(typeof c=="symbol"?Number.NaN:Number(c)).toString(),i=o+2,o+=1;break}case F:{const c=t[a];if(a>=t.length||c==null)break;i<o&&(n+=e.slice(i,o)),n+=Math.floor(typeof c=="symbol"?Number.NaN:Number(c)).toString(),i=o+2,o+=1;break}case E:case P:case q:{if(a>=t.length||t[a]===void 0)break;i<o&&(n+=e.slice(i,o));const c=t[a],g=typeof c;if(g==="string"){n+=`'${c}'`,i=o+2,o+=1;break}if(g==="function"){n+=c.name?`[Function: ${c.name}]`:"[Function: <anonymous>]",i=o+2,o+=1;break}n+=l(c),i=o+2,o+=1;break}case p:{i<o&&(n+=e.slice(i,o)),n+="%",i=o+2,o+=1,a-=1;break}case C:{if(a>=t.length)break;i<o&&(n+=e.slice(i,o));const c=t[a];n+=typeof c=="object"&&c!==null?l(c):String(c),i=o+2,o+=1;break}default:typeof r.formatters?.[d]=="function"?(i<o&&(n+=e.slice(i,o)),n+=r.formatters[d](t[a]),i=o+2,o+=1):a-=1}a+=1}o+=1}if(i===-1&&!(r.appendExtraArguments&&a<t.length))return e;if(i===-1?n=e:i<e.length&&(n+=e.slice(i)),i!==-1&&s&&(n+="\x1B[0m"),r.appendExtraArguments&&a<t.length)for(let o=Math.max(a,0);o<t.length;o+=1){const d=t[o];n+=` ${typeof d=="object"&&d!==null?l(d):String(d)}`}return n},I=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([f,n])=>{if(f.length===0)throw new Error(`Formatter %${f} has no characters`);if(f.length>1)throw new Error(`Formatter %${f} has more than one character`);if(typeof n!="function")throw new TypeError(`Formatter for %${f} is not a function`);const a=f.codePointAt(0);if(a===void 0)throw new Error(`${f}.codePointAt(0) failed to return a value, please report this issue`);t[a]=n});const r={...e};delete r.formatters;const l=Object.freeze({...r,formatters:t});return(f,n=[],a)=>a===void 0?w(f,n,l):w(f,n,{...r,...a,formatters:t})},W='"[Circular]"';class _{#e;#r;#t;constructor(t={}){this.#r=t.formatters}setStringify(t){this.#e=t}process(t){this.#t===void 0&&(this.#t=I({formatters:this.#r,stringify:l=>this.#n(l)}));const r=this.#t;return t.message!==void 0&&(t.message=this.#o(r,t.message,t.context??[])),t}#n(t){if(this.#e===void 0)try{return JSON.stringify(t)}catch{return W}try{return this.#e(t)}catch(r){return JSON.stringify(`[unserializable: ${r instanceof Error?r.message:String(r)}]`)}}#o(t,r,l=[]){if(typeof r=="string")return t(r,l);if(typeof r=="object"&&r!==null){const f=r,n=Object.keys(f);for(let a=0;a<n.length;a+=1){const i=n[a],s=f[i];(typeof s=="string"||Array.isArray(s)||typeof s=="object")&&(f[i]=this.#o(t,s,l))}}return r}}export{_ as default};
1
+ let h;const B=()=>(h!==void 0||(h=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),h),$=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,A=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,S=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,v=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,k=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),x=/\s+/,m=e=>{const t=B();t.has(e)&&(e=t.get(e));const r=$.exec(e);if(r)return[Number.parseInt(r[1],16),Number.parseInt(r[2],16),Number.parseInt(r[3],16)];const c=A.exec(e);if(c)return[Number.parseInt(`${c[1]}${c[1]}`,16),Number.parseInt(`${c[2]}${c[2]}`,16),Number.parseInt(`${c[3]}${c[3]}`,16)];const f=S.exec(e);if(f)return[Math.round(Math.max(0,Math.min(255,Number(f[1])))),Math.round(Math.max(0,Math.min(255,Number(f[2])))),Math.round(Math.max(0,Math.min(255,Number(f[3]))))];const n=v.exec(e);if(n){let a=Number(n[1])%360;a<0&&(a+=360);const i=Math.max(0,Math.min(100,Number(n[2])))/100,s=Math.max(0,Math.min(100,Number(n[3])))/100,u=(1-Math.abs(2*s-1))*i,b=u*(1-Math.abs(a/60%2-1)),o=s-u/2;let d,l,g;return a<60?{0:d,1:l,2:g}=[u,b,0]:a<120?{0:d,1:l,2:g}=[b,u,0]:a<180?{0:d,1:l,2:g}=[0,u,b]:a<240?{0:d,1:l,2:g}=[0,b,u]:a<300?{0:d,1:l,2:g}=[b,0,u]:{0:d,1:l,2:g}=[u,0,b],[Math.round((d+o)*255),Math.round((l+o)*255),Math.round((g+o)*255)]}return null},y=(e,t)=>typeof e=="string"||typeof t=="string"?e===t:e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],D=e=>{if(typeof e!="string")return k();const t=k(),r=[];let c=!1,f=null,n=0,a="";for(const i of e){if(i==="(")n+=1;else if(n>0)i===")"&&(n-=1);else if(c){if(i===";"){const s=a.trim();s!==""&&r.push([f,s]),f=null,a="",c=!1;continue}}else if(i===":"){f=a.trim(),a="",c=!0;continue}a+=i}if(c&&n===0){const i=a.trim();i!==""&&r.push([f,i]),f=null,a=""}for(const{0:i,1:s}of r)switch(i){case"background-color":{s!=null&&(t.backgroundColor=s);break}case"color":{s!=null&&(t.color=s);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(s)&&(t.fontStyle="italic");break}case"font-weight":{s==="bold"&&(t.fontWeight=s);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const u=s.split(x);for(const b of u){const o=m(b);o!=null?t.textDecorationColor=o:["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b)}break}case"text-decoration-color":{const u=m(s);u!=null&&(t.textDecorationColor=u);break}case"text-decoration-line":{t.textDecorationLine=[];const u=s.split(x);for(const b of u)["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b);break}}return t},N=(e,t)=>{t=t??k();let r="";if(!y(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)r+="\x1B[49m";else switch(e.backgroundColor){case"black":{r+="\x1B[40m";break}case"blue":{r+="\x1B[44m";break}case"cyan":{r+="\x1B[46m";break}case"green":{r+="\x1B[42m";break}case"magenta":{r+="\x1B[45m";break}case"red":{r+="\x1B[41m";break}case"white":{r+="\x1B[47m";break}case"yellow":{r+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:c,1:f,2:n}=e.backgroundColor;r+=`\x1B[48;2;${String(c)};${String(f)};${String(n)}m`}else{const c=m(e.backgroundColor);if(c===null)r+="\x1B[49m";else{const{0:f,1:n,2:a}=c;r+=`\x1B[48;2;${String(f)};${String(n)};${String(a)}m`}}}if(!y(e.color,t.color))if(e.color==null)r+="\x1B[39m";else switch(e.color){case"black":{r+="\x1B[30m";break}case"blue":{r+="\x1B[34m";break}case"cyan":{r+="\x1B[36m";break}case"green":{r+="\x1B[32m";break}case"magenta":{r+="\x1B[35m";break}case"red":{r+="\x1B[31m";break}case"white":{r+="\x1B[37m";break}case"yellow":{r+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:c,1:f,2:n}=e.color;r+=`\x1B[38;2;${String(c)};${String(f)};${String(n)}m`}else{const c=m(e.color);if(c===null)r+="\x1B[39m";else{const{0:f,1:n,2:a}=c;r+=`\x1B[38;2;${String(f)};${String(n)};${String(a)}m`}}}if(e.fontWeight!==t.fontWeight&&(r+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(r+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!y(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)r+="\x1B[59m";else{const{0:c,1:f,2:n}=e.textDecorationColor;r+=`\x1B[58;2;${String(c)};${String(f)};${String(n)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(r+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(r+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(r+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),r},C=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},p="%".codePointAt(0),M="s".codePointAt(0),L="d".codePointAt(0),P="f".codePointAt(0),j="i".codePointAt(0),F="O".codePointAt(0),q="o".codePointAt(0),E="j".codePointAt(0),O="c".codePointAt(0),w=(e,t=[],r={})=>{if(typeof e!="string"&&typeof e!="object"||e===null)throw new TypeError(`fmt must be a string or object, got ${e===null?"null":typeof e}`);const c=r.stringify??C,f=1;if(typeof e=="object"){const o=t.length+f;if(o===1)return"{}";const d=Array.from({length:o});d[0]=c(e);for(let l=1;l<o;l+=1)d[l]=c(t[l-f]);return d.join(" ")}if(t.length===0)return e;let n="",a=1-f,i=-1,s=!1,u;const b=r.colors??globalThis.window===void 0;for(let o=0;o<e.length;){if(e.codePointAt(o)===p&&o+1<e.length){i=i>-1?i:0;const d=e.codePointAt(o+1);switch(d){case O:{if(i<o&&(n+=e.slice(i,o)),b){const l=D(t[a]),g=N(l,u);n+=g,g!==""&&(s=!0,u=l)}i=o+2,o+=1;break}case L:case P:{const l=t[a];if(a>=t.length||l==null)break;i<o&&(n+=e.slice(i,o)),n+=(typeof l=="symbol"?Number.NaN:Number(l)).toString(),i=o+2,o+=1;break}case j:{const l=t[a];if(a>=t.length||l==null)break;i<o&&(n+=e.slice(i,o)),n+=Math.floor(typeof l=="symbol"?Number.NaN:Number(l)).toString(),i=o+2,o+=1;break}case E:case F:case q:{if(a>=t.length||t[a]===void 0)break;i<o&&(n+=e.slice(i,o));const l=t[a],g=typeof l;if(g==="string"){n+=`'${l}'`,i=o+2,o+=1;break}if(g==="function"){n+=l.name?`[Function: ${l.name}]`:"[Function: <anonymous>]",i=o+2,o+=1;break}n+=c(l),i=o+2,o+=1;break}case p:{i<o&&(n+=e.slice(i,o)),n+="%",i=o+2,o+=1,a-=1;break}case M:{if(a>=t.length)break;i<o&&(n+=e.slice(i,o));const l=t[a];n+=typeof l=="object"&&l!==null?c(l):String(l),i=o+2,o+=1;break}default:typeof r.formatters?.[d]=="function"?(i<o&&(n+=e.slice(i,o)),n+=r.formatters[d](t[a]),i=o+2,o+=1):a-=1}a+=1}o+=1}if(i===-1&&!(r.appendExtraArguments&&a<t.length))return e;if(i===-1?n=e:i<e.length&&(n+=e.slice(i)),i!==-1&&s&&(n+="\x1B[0m"),r.appendExtraArguments&&a<t.length)for(let o=Math.max(a,0);o<t.length;o+=1){const d=t[o];n+=` ${typeof d=="object"&&d!==null?c(d):String(d)}`}return n},I=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([f,n])=>{if(f.length===0)throw new Error(`Formatter %${f} has no characters`);if(f.length>1)throw new Error(`Formatter %${f} has more than one character`);if(typeof n!="function")throw new TypeError(`Formatter for %${f} is not a function`);const a=f.codePointAt(0);if(a===void 0)throw new Error(`${f}.codePointAt(0) failed to return a value, please report this issue`);t[a]=n});const r={...e};delete r.formatters;const c=Object.freeze({...r,formatters:t});return(f,n=[],a)=>a===void 0?w(f,n,c):w(f,n,{...r,...a,formatters:t})},W='"[Circular]"';class z{#e;#r;#t;constructor(t={}){this.#r=t.formatters}setStringify(t){this.#e=t}process(t){this.#t===void 0&&(this.#t=I({formatters:this.#r,stringify:c=>this.#n(c)}));const r=this.#t;return t.message!==void 0&&(t.message=this.#o(r,t.message,t.context??[])),t}#n(t){if(this.#e===void 0)try{return JSON.stringify(t)}catch{return W}try{return this.#e(t)}catch(r){return JSON.stringify(`[unserializable: ${r instanceof Error?r.message:String(r)}]`)}}#o(t,r,c=[]){if(typeof r=="string")return t(r,c);if(typeof r=="object"&&r!==null){const f=r,n=Object.keys(f);for(let a=0;a<n.length;a+=1){const i=n[a],s=f[i];(typeof s=="string"||Array.isArray(s)||typeof s=="object")&&(f[i]=this.#o(t,s,c))}}return r}}export{z as default};
@@ -1 +1 @@
1
- import{trace as i,context as c,isSpanContextValid as n}from"@opentelemetry/api";class l{#s;#e;#r;#t;constructor(t={}){this.#s=t.traceIdFieldName??"trace_id",this.#e=t.spanIdFieldName??"span_id",this.#r=t.traceFlagsFieldName??"trace_flags",this.#t=t.traceFieldName}process(t){const e=i.getSpan(c.active());if(!e)return t;const s=e.spanContext();if(!n(s))return t;const r={[this.#e]:s.spanId,[this.#r]:`0${s.traceFlags.toString(16)}`,[this.#s]:s.traceId},a=this.#t?{[this.#t]:r}:r;return t.context=[...t.context??[],a],t}}export{l as OpenTelemetryProcessor};
1
+ import{trace as c,context as i,isSpanContextValid as n}from"@opentelemetry/api";class o{#e;#a;#s;#t;constructor(t={}){this.#e=t.traceIdFieldName??"trace_id",this.#a=t.spanIdFieldName??"span_id",this.#s=t.traceFlagsFieldName??"trace_flags",this.#t=t.traceFieldName}process(t){const a=c.getSpan(i.active());if(!a)return t;const e=a.spanContext();if(!n(e))return t;const s={[this.#a]:e.spanId,[this.#s]:`0${e.traceFlags.toString(16)}`,[this.#e]:e.traceId},r=this.#t?{[this.#t]:s}:s;return t.context=[...t.context??[],r],t}}export{o as OpenTelemetryProcessor};
@@ -44,11 +44,58 @@ type Anonymize = {
44
44
  replacement?: unknown;
45
45
  };
46
46
  type Rules = (Anonymize | StringAnonymize | number | string)[];
47
+ /** A single entity located in a string by an {@link NlpScanner}. */
48
+ type NlpMatch = {
49
+ /** Index of the match within the scanned input. */
50
+ start: number;
51
+ /** The rule key/type this match belongs to (e.g. `FirstName`); cased freely, matched case-insensitively. */
52
+ tag: string;
53
+ /** The exact matched text, which is what gets replaced. */
54
+ text: string;
55
+ };
56
+ /**
57
+ * Locates named entities (people, organizations, money, ...) that no regular expression can
58
+ * describe. Redact ships no scanner by default — natural-language detection costs a
59
+ * multi-hundred-kilobyte lexicon and a parse per string, so it is opt-in.
60
+ *
61
+ * Pass {@link https://www.npmjs.com/package/compromise | compromise}-backed detection via
62
+ * `@visulima/redact/nlp`, or implement this signature against any other engine.
63
+ * @example
64
+ * ```ts
65
+ * import { createRedactor, standardRules } from "@visulima/redact";
66
+ * import { compromiseScanner } from "@visulima/redact/nlp";
67
+ *
68
+ * const scrub = createRedactor(standardRules, { nlp: compromiseScanner });
69
+ * ```
70
+ * A scanner is called for EVERY string the walk reaches, not only the ones carrying an entity
71
+ * it handles — the core cannot know which types a given engine serves. Check `types` first and
72
+ * return an empty array cheaply when none of them apply to you; that early exit is what keeps a
73
+ * pure key/pattern rule set from paying for the scan.
74
+ * @param input The string being redacted.
75
+ * @param types The rule keys in play, lowercased. Return only matches whose `tag` is one of
76
+ * them — the core masks whatever it is handed, so an out-of-contract tag would redact under a
77
+ * label the caller never asked for.
78
+ * @param logger Optional debug logger forwarded from {@link RedactOptions}.
79
+ * @returns Every entity found, in any order. `start` must be the index of `text` within
80
+ * `input`: the mask is applied at that offset, so a match reported at the wrong position would
81
+ * redact the wrong occurrence. Overlapping matches are resolved in favour of the first by
82
+ * `start` (longest wins on a tie), and the rest are dropped.
83
+ */
84
+ type NlpScanner = (input: string, types: string[], logger?: {
85
+ debug: (message?: unknown, ...optionalParameters: unknown[]) => void;
86
+ }) => NlpMatch[];
47
87
  type RedactOptions = {
48
88
  exclude?: (number | string)[];
49
89
  logger?: {
50
90
  debug: (message?: unknown, ...optionalParameters: unknown[]) => void;
51
91
  };
92
+ /**
93
+ * Opt in to natural-language entity detection (names, organizations, money).
94
+ * Without it, key-name and `pattern` rules still apply — only the four rule keys that have
95
+ * no regex shape (`firstname`, `lastname`, `organization`, `money`) go unmatched inside
96
+ * prose. They still match object keys of the same name either way.
97
+ */
98
+ nlp?: NlpScanner;
52
99
  };
53
100
  /**
54
101
  * Redact Processor.
@@ -72,6 +119,17 @@ type RedactOptions = {
72
119
  * apiKey: "sk-123456" // Will be redacted
73
120
  * });
74
121
  * ```
122
+ *
123
+ * Key names, credit cards, tokens, IPs, SSNs and emails are matched out of the box. Detecting
124
+ * people's names, organizations and money amounts inside free-form prose additionally needs a
125
+ * natural-language scanner, which `@visulima/redact` no longer bundles — install `compromise`
126
+ * and pass it through, and only then does the lexicon enter your bundle:
127
+ * @example
128
+ * ```typescript
129
+ * import { compromiseScanner } from "@visulima/redact/nlp";
130
+ *
131
+ * new RedactProcessor(undefined, { nlp: compromiseScanner });
132
+ * ```
75
133
  */
76
134
  declare class RedactProcessor<L extends string = string> implements Processor<L> {
77
135
  #private;
@@ -1 +1 @@
1
- import{redact as e,standardRules as a}from"@visulima/redact";class n{#t;constructor(t,s){const r=t??a;this.#t=o=>e(o,r,s)}process(t){return t.message=this.#t(t.message),t.context=this.#t(t.context),t.error=this.#t(t.error),t}}export{n as default};
1
+ import{redact as o,standardRules as c}from"@visulima/redact";class n{#s;constructor(s,r){const e=s??c;this.#s=t=>o(t,e,r)}process(s){return s.message=this.#s(s.message),s.context=this.#s(s.context),s.error=this.#s(s.error),s}}export{n as default};
@@ -1 +1 @@
1
- class e{#r;#t;constructor(t={}){this.#r=t.head??{},this.#t=t.tail??[]}process(t){const r=t.type.level;return this.#s(r)&&!this.#e(t)?{...t,dropped:!0}:t}#s(t){const r=this.#r[t];return r===void 0?!1:r<=0?!0:r>=100?!1:Math.random()*100>=r}#e(t){for(let r=0;r<this.#t.length;r+=1)if(this.#t[r](t))return!0;return!1}}export{e as default};
1
+ class s{#e;#r;constructor(r={}){this.#e=r.head??{},this.#r=r.tail??[]}process(r){const e=r.type.level;return this.#t(e)&&!this.#s(r)?{...r,dropped:!0}:r}#t(r){const e=this.#e[r];return e===void 0?!1:e<=0?!0:e>=100?!1:Math.random()*100>=e}#s(r){for(let e=0;e<this.#r.length;e+=1)if(this.#r[e](r))return!0;return!1}}export{s as default};
@@ -1,2 +1,2 @@
1
- import{AbstractJsonReporter as a}from"../../packem_shared/AbstractJsonReporter-DxZwImm5.js";class h{#t=!0;#s;#e;#i;constructor(t,e,s){this.#s=t,this.#e=e,this.#i=s??((i,o)=>{console.error(`Stream error: ${o}. Writes will be dropped.`,i)}),this.#s.on("error",i=>{this.#t=!1,this.#i(i,this.#e)}),this.#s.on("drain",()=>{this.#t=!0}),this.#s.on("finish",()=>{this.#t=!0})}write(t){this.writeStream(t)}end(...t){this.#s.end(...t)}get isReady(){return this.#t}writeStream(t){if(!this.#t){console.warn(`Stream busy: ${this.#e}. Write will be dropped: "${t}"`);return}this.#t=!1,this.#t=this.#s.write(t,()=>{})}}class n{#t;#s;#e;#i;#r;#h;constructor(t,e=!1,s={}){this.#t=t,this.#s=e,this.#i=s;try{this.#r=require("rotating-file-stream").createStream}catch{throw new Error("The 'rotating-file-stream' package is missing. Make sure to install the 'rotating-file-stream' package.")}this.#s||(this.#e=this.#r(this.#t,s),this.#h=new h(this.#e,this.#t))}write(t){if(this.#s){const e=this.#r(this.#t,this.#i),s=new h(e,this.#t);s.write(t),s.end();return}this.#h.write(t)}end(){this.#e!==void 0&&this.#e.end()}}class c extends a{stream;constructor(t){super();const{filePath:e,writeImmediately:s=!1,...i}=t;this.stream=new n(e,s,{compress:"gzip",interval:"1d",size:"10M",...i})}close(){this.stream.end()}dispose(){this.close()}_log(t){this.stream.write(`${t}
2
- `)}}export{c as JsonFileReporter};
1
+ import{AbstractJsonReporter as o}from"../../packem_shared/AbstractJsonReporter-DPsVS6w5.js";class h{#t=!0;#e;#s;#i;constructor(t,s,e){this.#e=t,this.#s=s,this.#i=e??((i,a)=>{console.error(`Stream error: ${a}. Writes will be dropped.`,i)}),this.#e.on("error",i=>{this.#t=!1,this.#i(i,this.#s)}),this.#e.on("drain",()=>{this.#t=!0}),this.#e.on("finish",()=>{this.#t=!0})}write(t){this.writeStream(t)}end(...t){this.#e.end(...t)}get isReady(){return this.#t}writeStream(t){if(!this.#t){console.warn(`Stream busy: ${this.#s}. Write will be dropped: "${t}"`);return}this.#t=!1,this.#t=this.#e.write(t,()=>{})}}class n{#t;#e;#s;#i;#r;#h;constructor(t,s=!1,e={}){this.#t=t,this.#e=s,this.#i=e;try{this.#r=require("rotating-file-stream").createStream}catch{throw new Error("The 'rotating-file-stream' package is missing. Make sure to install the 'rotating-file-stream' package.")}this.#e||(this.#s=this.#r(this.#t,e),this.#h=new h(this.#s,this.#t))}write(t){if(this.#e){const s=this.#r(this.#t,this.#i),e=new h(s,this.#t);e.write(t),e.end();return}this.#h.write(t)}end(){this.#s!==void 0&&this.#s.end()}}class m extends o{stream;constructor(t){super();const{filePath:s,writeImmediately:e=!1,...i}=t;this.stream=new n(s,e,{compress:"gzip",interval:"1d",size:"10M",...i})}close(){this.stream.end()}dispose(){this.close()}_log(t){this.stream.write(`${t}
2
+ `)}}export{m as JsonFileReporter};
@@ -1,2 +1,2 @@
1
- import{AbstractJsonReporter as z}from"../../packem_shared/AbstractJsonReporter-DxZwImm5.js";const T=async()=>{try{const{gzipSync:e}=await import("node:zlib");return typeof e=="function"?e:void 0}catch{return}},w=async e=>{const t=globalThis.CompressionStream;if(t){const i=new t("gzip"),a=i.writable.getWriter(),r=i.readable.getReader(),o=new TextEncoder,h=[];await a.write(o.encode(e)),await a.close();let l=!1;for(;!l;){const u=await r.read();l=u.done,u.value&&h.push(u.value)}const c=h.reduce((u,m)=>u+m.length,0),n=new Uint8Array(c);let d=0;for(let u=0;u<h.length;u+=1){const m=h[u];n.set(m,d),d+=m.length}return n}const s=await T();if(s===void 0)throw new Error("gzip compression is unavailable: this runtime provides neither CompressionStream nor node:zlib.");return s(e)};class x extends Error{logData;actualSize;maxSize;constructor(t,s,i,a){super(t),this.name="LogSizeError",this.logData=s,this.actualSize=i,this.maxSize=a}}let S=class extends Error{};const b=(e,t)=>e*2**t,g=6e4,D=/^\d+$/,E=e=>{const t=e.trim();if(D.test(t)){const a=Number.parseInt(t,10);return Math.min(Math.max(a,0)*1e3,g)}const s=Date.parse(t);if(Number.isNaN(s))return;const i=s-Date.now();return Math.min(Math.max(i,0),g)},f=e=>new Promise(t=>{setTimeout(t,e)}),R=e=>typeof e=="string"?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),B=async(e,t,s,i,a,r,o)=>{const h={};e.headers.forEach((n,d)=>{h[d]=n});const l=await e.text(),c={req:{body:a,headers:i,method:s,url:t},res:{body:l,headers:h,status:e.status,statusText:e.statusText}};if(r&&r(c),e.ok)return!1;if(e.status<500&&e.status!==429){const n=new S(`HTTP ${String(e.status)}: ${e.statusText}`);throw o&&o(n),n}return!0},Q=(e,t,s,i,a)=>{if(e.status===429&&t&&i<a){const r=e.headers.get("retry-after");return(r?E(r):void 0)??b(s,i)}},P=(e,t,s,i)=>{if(e.status>=500&&s<i)return b(t,s)},L=(e,t,s,i,a)=>{const r=Q(e,t,s,i,a);return r!==void 0?r:P(e,s,i,a)},N=async(e,t,s,i,a)=>{if(t<s){const r=b(i,t);return await f(r),!0}return a&&a(e),!1},v=async(e,t)=>{const{body:s,headers:i,maxRetries:a,method:r,onDebugRequestResponse:o,onError:h,respectRateLimit:l,retryDelay:c,url:n}=e,d=R(s),u=await fetch(n,{body:d,headers:i,method:r});if(!await B(u,n,r,i,s,o,h))return{done:!0};const m=L(u,l,c,t,a);if(m!==void 0)return{retryInMs:m};if(!u.ok){const p=new Error(`HTTP ${String(u.status)}: ${u.statusText}`);throw h&&h(p),p}return{done:!0}},M=async(e,t,s,i,a,r,o,h,l)=>{const c={body:i,headers:s,maxRetries:a,method:t,onDebugRequestResponse:h,onError:l,respectRateLimit:o,retryDelay:r,url:e};let n=0;for(;n<=a;)try{const d=await v(c,n);if("retryInMs"in d)await f(d.retryInMs),n+=1;else return}catch(d){if(d instanceof S||!await N(d,n,a,r,l))throw d;n+=1}},$=e=>{let t=0;for(const s of e){const i=s.codePointAt(0);i<128?t+=1:i<2048?t+=2:i<65536?t+=3:t+=4}return t};let y;const C=e=>typeof TextEncoder=="function"?(y??=new TextEncoder,y.encode(e).length):$(e);class k extends z{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchSizeQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(t){if(super(t),this.url=t.url,this.method=t.method??"POST",this.headers=t.headers??{},this.contentType=t.contentType??"application/json",this.batchContentType=t.batchContentType??"application/json",this.onError=t.onError,this.onDrop=t.onDrop,this.maxQueueSize=t.maxQueueSize??1e4,this.onDebug=t.onDebug,this.onDebugRequestResponse=t.onDebugRequestResponse,this.payloadTemplate=t.payloadTemplate??(s=>JSON.stringify(s)),this.compression=t.compression??!1,this.maxRetries=t.maxRetries??3,this.retryDelay=t.retryDelay??1e3,this.respectRateLimit=t.respectRateLimit??!0,this.enableBatchSend=t.enableBatchSend??!0,this.batchSize=t.batchSize??100,this.batchSendTimeout=t.batchSendTimeout??5e3,this.batchSendDelimiter=t.batchSendDelimiter??`
2
- `,this.batchMode=t.batchMode??"delimiter",this.batchFieldName=t.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=t.maxLogSize??1048576,this.maxPayloadSize=t.maxPayloadSize??5242880,this.edgeCompat=t.edgeCompat??!1}async flush(){for(this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);this.batchQueue.length>0||this.isProcessingBatch;){if(this.isProcessingBatch){await new Promise(t=>setTimeout(t,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(t,s){try{const i=JSON.parse(t),a=s,r=i.message,o={logLevel:a,message:r??""};if(i.data)o.data=i.data;else if(i.context)o.data=i.context;else{const c={...i};delete c.message,Object.keys(c).length>0&&(o.data=c)}const h=this.payloadTemplate(o);this.onDebug&&this.onDebug({data:o.data,logLevel:a,message:r});const l=C(h);if(l>this.maxLogSize){const c=new x(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(l)} bytes`,{data:o.data,logLevel:a,message:r},l,this.maxLogSize);this.onError&&this.onError(c);return}this.enableBatchSend?this.addToBatch(h,l):this.sendPayload(h).catch(c=>{this.onError&&this.onError(c)})}catch(i){this.onError&&this.onError(i)}}addToBatch(t,s){const i=this.currentBatchSize+s+this.batchSendDelimiter.length,a=this.maxPayloadSize*.9;if(i>a&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.batchSizeQueue.push(s),this.currentBatchSize+=s+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const r=this.batchQueue.length-this.maxQueueSize,o=this.batchQueue.splice(0,r);this.batchSizeQueue.splice(0,r),this.currentBatchSize=this.#t(),this.onDrop&&this.onDrop(o.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#t(){let t=0;for(let s=0;s<this.batchSizeQueue.length;s+=1)t+=this.batchSizeQueue[s]+(s<this.batchSizeQueue.length-1?this.batchSendDelimiter.length:0);return t}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const t=this.batchQueue.splice(0,this.batchSize);this.batchSizeQueue.splice(0,this.batchSize),this.currentBatchSize=this.#t();try{await this.sendBatch(t)}catch(s){this.onError&&this.onError(s)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let s;switch(this.batchMode){case"array":{const i=t.map(a=>JSON.parse(a));s=JSON.stringify(i);break}case"field":{const i=t.map(r=>JSON.parse(r)),a=this.batchFieldName?{[this.batchFieldName]:i}:{};s=JSON.stringify(a);break}default:{s=t.join(this.batchSendDelimiter);break}}await this.sendPayload(s,this.batchContentType)}async sendPayload(t,s){const i=typeof this.headers=="function"?this.headers():{...this.headers};i["content-type"]??=s??this.contentType;let a=t;if(this.compression&&!this.edgeCompat)try{a=await w(t),i["content-encoding"]="gzip"}catch(r){this.onError&&this.onError(new Error(`Compression failed: ${String(r)}`))}await M(this.url,this.method,i,a,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}export{k as AbstractHttpReporter};
1
+ import{AbstractJsonReporter as T}from"../../packem_shared/AbstractJsonReporter-DPsVS6w5.js";const w=async()=>{try{const{gzipSync:e}=await import("node:zlib");return typeof e=="function"?e:void 0}catch{return}},x=async e=>{const t=globalThis.CompressionStream;if(t){const i=new t("gzip"),a=i.writable.getWriter(),r=i.readable.getReader(),o=new TextEncoder,h=[];await a.write(o.encode(e)),await a.close();let l=!1;for(;!l;){const c=await r.read();l=c.done,c.value&&h.push(c.value)}const u=h.reduce((c,m)=>c+m.length,0),n=new Uint8Array(u);let d=0;for(let c=0;c<h.length;c+=1){const m=h[c];n.set(m,d),d+=m.length}return n}const s=await w();if(s===void 0)throw new Error("gzip compression is unavailable: this runtime provides neither CompressionStream nor node:zlib.");return s(e)};class D extends Error{logData;actualSize;maxSize;constructor(t,s,i,a){super(t),this.name="LogSizeError",this.logData=s,this.actualSize=i,this.maxSize=a}}class g extends Error{}const p=(e,t)=>e*2**t,S=6e4,E=/^\d+$/,R=e=>{const t=e.trim();if(E.test(t)){const a=Number.parseInt(t,10);return Math.min(Math.max(a,0)*1e3,S)}const s=Date.parse(t);if(Number.isNaN(s))return;const i=s-Date.now();return Math.min(Math.max(i,0),S)},z=e=>new Promise(t=>{setTimeout(t,e)}),B=e=>typeof e=="string"?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),L=async(e,t,s,i,a,r,o)=>{const h={};e.headers.forEach((n,d)=>{h[d]=n});const l=await e.text(),u={req:{body:a,headers:i,method:s,url:t},res:{body:l,headers:h,status:e.status,statusText:e.statusText}};if(r&&r(u),e.ok)return!1;if(e.status<500&&e.status!==429){const n=new g(`HTTP ${String(e.status)}: ${e.statusText}`);throw o&&o(n),n}return!0},v=(e,t,s,i,a)=>{if(e.status===429&&t&&i<a){const r=e.headers.get("retry-after");return(r?R(r):void 0)??p(s,i)}},Q=(e,t,s,i)=>{if(e.status>=500&&s<i)return p(t,s)},P=(e,t,s,i,a)=>{const r=v(e,t,s,i,a);return r!==void 0?r:Q(e,s,i,a)},N=async(e,t,s,i,a)=>{if(t<s){const r=p(i,t);return await z(r),!0}return a&&a(e),!1},M=async(e,t)=>{const{body:s,headers:i,maxRetries:a,method:r,onDebugRequestResponse:o,onError:h,respectRateLimit:l,retryDelay:u,url:n}=e,d=B(s),c=await fetch(n,{body:d,headers:i,method:r});if(!await L(c,n,r,i,s,o,h))return{done:!0};const b=P(c,l,u,t,a);if(b!==void 0)return{retryInMs:b};if(!c.ok){const y=new Error(`HTTP ${String(c.status)}: ${c.statusText}`);throw h&&h(y),y}return{done:!0}},C=async(e,t,s,i,a,r,o,h,l)=>{const u={body:i,headers:s,maxRetries:a,method:t,onDebugRequestResponse:h,onError:l,respectRateLimit:o,retryDelay:r,url:e};let n=0;for(;n<=a;)try{const d=await M(u,n);if("retryInMs"in d)await z(d.retryInMs),n+=1;else return}catch(d){if(d instanceof g||!await N(d,n,a,r,l))throw d;n+=1}},O=e=>{let t=0;for(const s of e){const i=s.codePointAt(0);i<128?t+=1:i<2048?t+=2:i<65536?t+=3:t+=4}return t};let f;const A=e=>typeof TextEncoder=="function"?(f??=new TextEncoder,f.encode(e).length):O(e);class k extends T{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchSizeQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(t){if(super(t),this.url=t.url,this.method=t.method??"POST",this.headers=t.headers??{},this.contentType=t.contentType??"application/json",this.batchContentType=t.batchContentType??"application/json",this.onError=t.onError,this.onDrop=t.onDrop,this.maxQueueSize=t.maxQueueSize??1e4,this.onDebug=t.onDebug,this.onDebugRequestResponse=t.onDebugRequestResponse,this.payloadTemplate=t.payloadTemplate??(s=>JSON.stringify(s)),this.compression=t.compression??!1,this.maxRetries=t.maxRetries??3,this.retryDelay=t.retryDelay??1e3,this.respectRateLimit=t.respectRateLimit??!0,this.enableBatchSend=t.enableBatchSend??!0,this.batchSize=t.batchSize??100,this.batchSendTimeout=t.batchSendTimeout??5e3,this.batchSendDelimiter=t.batchSendDelimiter??`
2
+ `,this.batchMode=t.batchMode??"delimiter",this.batchFieldName=t.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=t.maxLogSize??1048576,this.maxPayloadSize=t.maxPayloadSize??5242880,this.edgeCompat=t.edgeCompat??!1}async flush(){for(this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);this.batchQueue.length>0||this.isProcessingBatch;){if(this.isProcessingBatch){await new Promise(t=>setTimeout(t,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(t,s){try{const i=JSON.parse(t),a=s,r=i.message,o={logLevel:a,message:r??""};if(i.data)o.data=i.data;else if(i.context)o.data=i.context;else{const u={...i};delete u.message,Object.keys(u).length>0&&(o.data=u)}const h=this.payloadTemplate(o);this.onDebug&&this.onDebug({data:o.data,logLevel:a,message:r});const l=A(h);if(l>this.maxLogSize){const u=new D(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(l)} bytes`,{data:o.data,logLevel:a,message:r},l,this.maxLogSize);this.onError&&this.onError(u);return}this.enableBatchSend?this.addToBatch(h,l):this.sendPayload(h).catch(u=>{this.onError&&this.onError(u)})}catch(i){this.onError&&this.onError(i)}}addToBatch(t,s){const i=this.currentBatchSize+s+this.batchSendDelimiter.length,a=this.maxPayloadSize*.9;if(i>a&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.batchSizeQueue.push(s),this.currentBatchSize+=s+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const r=this.batchQueue.length-this.maxQueueSize,o=this.batchQueue.splice(0,r);this.batchSizeQueue.splice(0,r),this.currentBatchSize=this.#t(),this.onDrop&&this.onDrop(o.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#t(){let t=0;for(let s=0;s<this.batchSizeQueue.length;s+=1)t+=this.batchSizeQueue[s]+(s<this.batchSizeQueue.length-1?this.batchSendDelimiter.length:0);return t}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const t=this.batchQueue.splice(0,this.batchSize);this.batchSizeQueue.splice(0,this.batchSize),this.currentBatchSize=this.#t();try{await this.sendBatch(t)}catch(s){this.onError&&this.onError(s)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let s;switch(this.batchMode){case"array":{const i=t.map(a=>JSON.parse(a));s=JSON.stringify(i);break}case"field":{const i=t.map(r=>JSON.parse(r)),a=this.batchFieldName?{[this.batchFieldName]:i}:{};s=JSON.stringify(a);break}default:{s=t.join(this.batchSendDelimiter);break}}await this.sendPayload(s,this.batchContentType)}async sendPayload(t,s){const i=typeof this.headers=="function"?this.headers():{...this.headers};i["content-type"]??=s??this.contentType;let a=t;if(this.compression&&!this.edgeCompat)try{a=await x(t),i["content-encoding"]="gzip"}catch(r){this.onError&&this.onError(new Error(`Compression failed: ${String(r)}`))}await C(this.url,this.method,i,a,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}export{k as AbstractHttpReporter};
@@ -1,5 +1,3 @@
1
- import '@visulima/colorize';
2
- import '@visulima/interactive-manager';
3
1
  /**
4
2
  Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
5
3
 
@@ -1,2 +1,2 @@
1
- const D=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),E=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},p=new WeakSet,P=e=>{if(Object.hasOwn(e,"name")&&typeof e.name=="string"&&e.name!=="")return e.name;const t=e.constructor?.name;return typeof t=="string"&&t!==""?t:e.name},O=e=>{const t=Object.getOwnPropertyNames(e);for(const s of t){const r=Object.getOwnPropertyDescriptor(e,s);r&&(r.enumerable||Object.defineProperty(e,s,{...r,enumerable:!0}),r.value&&typeof r.value=="object"&&!Array.isArray(r.value)&&(Object.getPrototypeOf(r.value)===Object.prototype||Object.getPrototypeOf(r.value)===null)&&O(r.value))}},N=e=>{p.add(e);const t=e.toJSON();return p.delete(e),Object.isExtensible(t)&&O(t),t},d=(e,t,s,r,a=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.has(e)?"[Circular]":(s+=1,m(e,r,t,s));if(r.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const i=[];for(const[n,o]of e.entries())i.push([d(n,t,s,r,a),d(o,t,s,r,a)]);return{__dataType:"Map",value:i}}if(e instanceof Set){const i=[];for(const n of e.values())i.push(d(n,t,s,r,a));return{__dataType:"Set",value:i}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(E(e)){if(a.has(e))return"[Circular]";if(r.maxDepth!==void 0&&r.maxDepth!==Number.POSITIVE_INFINITY&&s+1>=r.maxDepth)return{};s+=1,a.add(e);const i={};for(const n in e)i[n]=d(e[n],t,s,r,a);return a.delete(e),i}try{return e}catch{return"[Not Available]"}},m=(e,t,s,r)=>{if(s.add(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return N(e);const a=Object.create(D);if(Object.defineProperty(a,"name",{configurable:!0,enumerable:!0,value:P(e),writable:!0}),Object.defineProperty(a,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(a,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const n=[];for(const o of e.errors){if(!(o instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(s.has(o))return Object.defineProperty(a,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),a;n.push(m(o,t,s,r))}Object.defineProperty(a,"errors",{configurable:!0,enumerable:!0,value:n,writable:!0})}const i=e.cause;if(i!=null)if(i instanceof Error)s.has(i)?Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:m(i,t,s,r),writable:!0});else{const n=d(i,s,r,t);Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:n,writable:!0})}for(const n in e){if(n==="name"||n==="message"||n==="stack"||n==="cause"||n==="errors")continue;const o=e[n],u=d(o,s,r,t);Object.defineProperty(a,n,{configurable:!0,enumerable:!0,value:u,writable:!0})}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const n of t.exclude)try{delete a[n]}catch{}return a},S=(e,t={})=>m(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},new Set,0),w=Symbol("EMPTY");class j{stringify;errorOptions;constructor(t={}){this.errorOptions=t.error??{}}setStringify(t){this.stringify=t}log(t){const{context:s,error:r,file:a,message:i,type:n,...o}=t;if(o.label&&(o.label=o.label.trim()),a&&(o.file=`${a.name??""}:${String(a.line)}${a.column?`:${String(a.column)}`:""}`),o.message=i===w?void 0:i,r&&(o.error=S(r,this.errorOptions)),s){const u=[];for(let h=0;h<s.length;h+=1){const c=s[h];c!==w&&(c instanceof Error?u.push(S(c,this.errorOptions)):u.push(c))}o.context=u}this._log(this.stringify(o),n.level)}}const R=async()=>{try{const{gzipSync:e}=await import("node:zlib");return typeof e=="function"?e:void 0}catch{return}},B=async e=>{const t=globalThis.CompressionStream;if(t){const r=new t("gzip"),a=r.writable.getWriter(),i=r.readable.getReader(),n=new TextEncoder,o=[];await a.write(n.encode(e)),await a.close();let u=!1;for(;!u;){const l=await i.read();u=l.done,l.value&&o.push(l.value)}const h=o.reduce((l,f)=>l+f.length,0),c=new Uint8Array(h);let b=0;for(let l=0;l<o.length;l+=1){const f=o[l];c.set(f,b),b+=f.length}return c}const s=await R();if(s===void 0)throw new Error("gzip compression is unavailable: this runtime provides neither CompressionStream nor node:zlib.");return s(e)};class Q extends Error{logData;actualSize;maxSize;constructor(t,s,r,a){super(t),this.name="LogSizeError",this.logData=s,this.actualSize=r,this.maxSize=a}}let v=class extends Error{};const y=(e,t)=>e*2**t,x=6e4,$=/^\d+$/,L=e=>{const t=e.trim();if($.test(t)){const a=Number.parseInt(t,10);return Math.min(Math.max(a,0)*1e3,x)}const s=Date.parse(t);if(Number.isNaN(s))return;const r=s-Date.now();return Math.min(Math.max(r,0),x)},z=e=>new Promise(t=>{setTimeout(t,e)}),M=e=>typeof e=="string"?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),J=async(e,t,s,r,a,i,n)=>{const o={};e.headers.forEach((c,b)=>{o[b]=c});const u=await e.text(),h={req:{body:a,headers:r,method:s,url:t},res:{body:u,headers:o,status:e.status,statusText:e.statusText}};if(i&&i(h),e.ok)return!1;if(e.status<500&&e.status!==429){const c=new v(`HTTP ${String(e.status)}: ${e.statusText}`);throw n&&n(c),c}return!0},A=(e,t,s,r,a)=>{if(e.status===429&&t&&r<a){const i=e.headers.get("retry-after");return(i?L(i):void 0)??y(s,r)}},C=(e,t,s,r)=>{if(e.status>=500&&s<r)return y(t,s)},I=(e,t,s,r,a)=>{const i=A(e,t,s,r,a);return i!==void 0?i:C(e,s,r,a)},k=async(e,t,s,r,a)=>{if(t<s){const i=y(r,t);return await z(i),!0}return a&&a(e),!1},F=async(e,t)=>{const{body:s,headers:r,maxRetries:a,method:i,onDebugRequestResponse:n,onError:o,respectRateLimit:u,retryDelay:h,url:c}=e,b=M(s),l=await fetch(c,{body:b,headers:r,method:i});if(!await J(l,c,i,r,s,n,o))return{done:!0};const f=I(l,u,h,t,a);if(f!==void 0)return{retryInMs:f};if(!l.ok){const g=new Error(`HTTP ${String(l.status)}: ${l.statusText}`);throw o&&o(g),g}return{done:!0}},q=async(e,t,s,r,a,i,n,o,u)=>{const h={body:r,headers:s,maxRetries:a,method:t,onDebugRequestResponse:o,onError:u,respectRateLimit:n,retryDelay:i,url:e};let c=0;for(;c<=a;)try{const b=await F(h,c);if("retryInMs"in b)await z(b.retryInMs),c+=1;else return}catch(b){if(b instanceof v||!await k(b,c,a,i,u))throw b;c+=1}},_=e=>{let t=0;for(const s of e){const r=s.codePointAt(0);r<128?t+=1:r<2048?t+=2:r<65536?t+=3:t+=4}return t};let T;const U=e=>typeof TextEncoder=="function"?(T??=new TextEncoder,T.encode(e).length):_(e);class Y extends j{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchSizeQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(t){if(super(t),this.url=t.url,this.method=t.method??"POST",this.headers=t.headers??{},this.contentType=t.contentType??"application/json",this.batchContentType=t.batchContentType??"application/json",this.onError=t.onError,this.onDrop=t.onDrop,this.maxQueueSize=t.maxQueueSize??1e4,this.onDebug=t.onDebug,this.onDebugRequestResponse=t.onDebugRequestResponse,this.payloadTemplate=t.payloadTemplate??(s=>JSON.stringify(s)),this.compression=t.compression??!1,this.maxRetries=t.maxRetries??3,this.retryDelay=t.retryDelay??1e3,this.respectRateLimit=t.respectRateLimit??!0,this.enableBatchSend=t.enableBatchSend??!0,this.batchSize=t.batchSize??100,this.batchSendTimeout=t.batchSendTimeout??5e3,this.batchSendDelimiter=t.batchSendDelimiter??`
2
- `,this.batchMode=t.batchMode??"delimiter",this.batchFieldName=t.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=t.maxLogSize??1048576,this.maxPayloadSize=t.maxPayloadSize??5242880,this.edgeCompat=t.edgeCompat??!1}async flush(){for(this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);this.batchQueue.length>0||this.isProcessingBatch;){if(this.isProcessingBatch){await new Promise(t=>setTimeout(t,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(t,s){try{const r=JSON.parse(t),a=s,i=r.message,n={logLevel:a,message:i??""};if(r.data)n.data=r.data;else if(r.context)n.data=r.context;else{const h={...r};delete h.message,Object.keys(h).length>0&&(n.data=h)}const o=this.payloadTemplate(n);this.onDebug&&this.onDebug({data:n.data,logLevel:a,message:i});const u=U(o);if(u>this.maxLogSize){const h=new Q(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(u)} bytes`,{data:n.data,logLevel:a,message:i},u,this.maxLogSize);this.onError&&this.onError(h);return}this.enableBatchSend?this.addToBatch(o,u):this.sendPayload(o).catch(h=>{this.onError&&this.onError(h)})}catch(r){this.onError&&this.onError(r)}}addToBatch(t,s){const r=this.currentBatchSize+s+this.batchSendDelimiter.length,a=this.maxPayloadSize*.9;if(r>a&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.batchSizeQueue.push(s),this.currentBatchSize+=s+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const i=this.batchQueue.length-this.maxQueueSize,n=this.batchQueue.splice(0,i);this.batchSizeQueue.splice(0,i),this.currentBatchSize=this.#e(),this.onDrop&&this.onDrop(n.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#e(){let t=0;for(let s=0;s<this.batchSizeQueue.length;s+=1)t+=this.batchSizeQueue[s]+(s<this.batchSizeQueue.length-1?this.batchSendDelimiter.length:0);return t}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const t=this.batchQueue.splice(0,this.batchSize);this.batchSizeQueue.splice(0,this.batchSize),this.currentBatchSize=this.#e();try{await this.sendBatch(t)}catch(s){this.onError&&this.onError(s)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let s;switch(this.batchMode){case"array":{const r=t.map(a=>JSON.parse(a));s=JSON.stringify(r);break}case"field":{const r=t.map(i=>JSON.parse(i)),a=this.batchFieldName?{[this.batchFieldName]:r}:{};s=JSON.stringify(a);break}default:{s=t.join(this.batchSendDelimiter);break}}await this.sendPayload(s,this.batchContentType)}async sendPayload(t,s){const r=typeof this.headers=="function"?this.headers():{...this.headers};r["content-type"]??=s??this.contentType;let a=t;if(this.compression&&!this.edgeCompat)try{a=await B(t),r["content-encoding"]="gzip"}catch(i){this.onError&&this.onError(new Error(`Compression failed: ${String(i)}`))}await q(this.url,this.method,r,a,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}class V extends Y{constructor(t){super({...t,edgeCompat:!0})}}export{V as default};
1
+ const D=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),P=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},p=new WeakSet,R=e=>{if(Object.hasOwn(e,"name")&&typeof e.name=="string"&&e.name!=="")return e.name;const t=e.constructor?.name;return typeof t=="string"&&t!==""?t:e.name},x=e=>{const t=Object.getOwnPropertyNames(e);for(const s of t){const r=Object.getOwnPropertyDescriptor(e,s);r&&(r.enumerable||Object.defineProperty(e,s,{...r,enumerable:!0}),r.value&&typeof r.value=="object"&&!Array.isArray(r.value)&&(Object.getPrototypeOf(r.value)===Object.prototype||Object.getPrototypeOf(r.value)===null)&&x(r.value))}},N=e=>{p.add(e);const t=e.toJSON();return p.delete(e),Object.isExtensible(t)&&x(t),t},f=(e,t,s,r,a=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return t.has(e)?"[Circular]":(s+=1,m(e,r,t,s));if(r.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const i=[];for(const[o,n]of e.entries())i.push([f(o,t,s,r,a),f(n,t,s,r,a)]);return{__dataType:"Map",value:i}}if(e instanceof Set){const i=[];for(const o of e.values())i.push(f(o,t,s,r,a));return{__dataType:"Set",value:i}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(P(e)){if(a.has(e))return"[Circular]";if(r.maxDepth!==void 0&&r.maxDepth!==Number.POSITIVE_INFINITY&&s+1>=r.maxDepth)return{};s+=1,a.add(e);const i={};for(const o in e)i[o]=f(e[o],t,s,r,a);return a.delete(e),i}try{return e}catch{return"[Not Available]"}},m=(e,t,s,r)=>{if(s.add(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return N(e);const a=Object.create(D);if(Object.defineProperty(a,"name",{configurable:!0,enumerable:!0,value:R(e),writable:!0}),Object.defineProperty(a,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(a,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const o=[];for(const n of e.errors){if(!(n instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(s.has(n))return Object.defineProperty(a,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),a;o.push(m(n,t,s,r))}Object.defineProperty(a,"errors",{configurable:!0,enumerable:!0,value:o,writable:!0})}const i=e.cause;if(i!=null)if(i instanceof Error)s.has(i)?Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:m(i,t,s,r),writable:!0});else{const o=f(i,s,r,t);Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:o,writable:!0})}for(const o in e){if(o==="name"||o==="message"||o==="stack"||o==="cause"||o==="errors")continue;const n=e[o],u=f(n,s,r,t);Object.defineProperty(a,o,{configurable:!0,enumerable:!0,value:u,writable:!0})}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const o of t.exclude)try{delete a[o]}catch{}return a},w=(e,t={})=>m(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},new Set,0),T=Symbol("EMPTY");class B{stringify;errorOptions;constructor(t={}){this.errorOptions=t.error??{}}setStringify(t){this.stringify=t}log(t){const{context:s,error:r,file:a,message:i,type:o,...n}=t;if(n.label&&(n.label=n.label.trim()),a&&(n.file=`${a.name??""}:${String(a.line)}${a.column?`:${String(a.column)}`:""}`),n.message=i===T?void 0:i,r&&(n.error=w(r,this.errorOptions)),s){const u=[];for(let h=0;h<s.length;h+=1){const c=s[h];c!==T&&(c instanceof Error?u.push(w(c,this.errorOptions)):u.push(c))}n.context=u}this._log(this.stringify(n),o.level)}}const j=async()=>{try{const{gzipSync:e}=await import("node:zlib");return typeof e=="function"?e:void 0}catch{return}},L=async e=>{const t=globalThis.CompressionStream;if(t){const r=new t("gzip"),a=r.writable.getWriter(),i=r.readable.getReader(),o=new TextEncoder,n=[];await a.write(o.encode(e)),await a.close();let u=!1;for(;!u;){const l=await i.read();u=l.done,l.value&&n.push(l.value)}const h=n.reduce((l,b)=>l+b.length,0),c=new Uint8Array(h);let d=0;for(let l=0;l<n.length;l+=1){const b=n[l];c.set(b,d),d+=b.length}return c}const s=await j();if(s===void 0)throw new Error("gzip compression is unavailable: this runtime provides neither CompressionStream nor node:zlib.");return s(e)};class Q extends Error{logData;actualSize;maxSize;constructor(t,s,r,a){super(t),this.name="LogSizeError",this.logData=s,this.actualSize=r,this.maxSize=a}}class z extends Error{}const y=(e,t)=>e*2**t,O=6e4,M=/^\d+$/,A=e=>{const t=e.trim();if(M.test(t)){const a=Number.parseInt(t,10);return Math.min(Math.max(a,0)*1e3,O)}const s=Date.parse(t);if(Number.isNaN(s))return;const r=s-Date.now();return Math.min(Math.max(r,0),O)},E=e=>new Promise(t=>{setTimeout(t,e)}),C=e=>typeof e=="string"?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),J=async(e,t,s,r,a,i,o)=>{const n={};e.headers.forEach((c,d)=>{n[d]=c});const u=await e.text(),h={req:{body:a,headers:r,method:s,url:t},res:{body:u,headers:n,status:e.status,statusText:e.statusText}};if(i&&i(h),e.ok)return!1;if(e.status<500&&e.status!==429){const c=new z(`HTTP ${String(e.status)}: ${e.statusText}`);throw o&&o(c),c}return!0},I=(e,t,s,r,a)=>{if(e.status===429&&t&&r<a){const i=e.headers.get("retry-after");return(i?A(i):void 0)??y(s,r)}},k=(e,t,s,r)=>{if(e.status>=500&&s<r)return y(t,s)},_=(e,t,s,r,a)=>{const i=I(e,t,s,r,a);return i!==void 0?i:k(e,s,r,a)},$=async(e,t,s,r,a)=>{if(t<s){const i=y(r,t);return await E(i),!0}return a&&a(e),!1},F=async(e,t)=>{const{body:s,headers:r,maxRetries:a,method:i,onDebugRequestResponse:o,onError:n,respectRateLimit:u,retryDelay:h,url:c}=e,d=C(s),l=await fetch(c,{body:d,headers:r,method:i});if(!await J(l,c,i,r,s,o,n))return{done:!0};const S=_(l,u,h,t,a);if(S!==void 0)return{retryInMs:S};if(!l.ok){const g=new Error(`HTTP ${String(l.status)}: ${l.statusText}`);throw n&&n(g),g}return{done:!0}},q=async(e,t,s,r,a,i,o,n,u)=>{const h={body:r,headers:s,maxRetries:a,method:t,onDebugRequestResponse:n,onError:u,respectRateLimit:o,retryDelay:i,url:e};let c=0;for(;c<=a;)try{const d=await F(h,c);if("retryInMs"in d)await E(d.retryInMs),c+=1;else return}catch(d){if(d instanceof z||!await $(d,c,a,i,u))throw d;c+=1}},H=e=>{let t=0;for(const s of e){const r=s.codePointAt(0);r<128?t+=1:r<2048?t+=2:r<65536?t+=3:t+=4}return t};let v;const Y=e=>typeof TextEncoder=="function"?(v??=new TextEncoder,v.encode(e).length):H(e);class U extends B{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchSizeQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(t){if(super(t),this.url=t.url,this.method=t.method??"POST",this.headers=t.headers??{},this.contentType=t.contentType??"application/json",this.batchContentType=t.batchContentType??"application/json",this.onError=t.onError,this.onDrop=t.onDrop,this.maxQueueSize=t.maxQueueSize??1e4,this.onDebug=t.onDebug,this.onDebugRequestResponse=t.onDebugRequestResponse,this.payloadTemplate=t.payloadTemplate??(s=>JSON.stringify(s)),this.compression=t.compression??!1,this.maxRetries=t.maxRetries??3,this.retryDelay=t.retryDelay??1e3,this.respectRateLimit=t.respectRateLimit??!0,this.enableBatchSend=t.enableBatchSend??!0,this.batchSize=t.batchSize??100,this.batchSendTimeout=t.batchSendTimeout??5e3,this.batchSendDelimiter=t.batchSendDelimiter??`
2
+ `,this.batchMode=t.batchMode??"delimiter",this.batchFieldName=t.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=t.maxLogSize??1048576,this.maxPayloadSize=t.maxPayloadSize??5242880,this.edgeCompat=t.edgeCompat??!1}async flush(){for(this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);this.batchQueue.length>0||this.isProcessingBatch;){if(this.isProcessingBatch){await new Promise(t=>setTimeout(t,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(t,s){try{const r=JSON.parse(t),a=s,i=r.message,o={logLevel:a,message:i??""};if(r.data)o.data=r.data;else if(r.context)o.data=r.context;else{const h={...r};delete h.message,Object.keys(h).length>0&&(o.data=h)}const n=this.payloadTemplate(o);this.onDebug&&this.onDebug({data:o.data,logLevel:a,message:i});const u=Y(n);if(u>this.maxLogSize){const h=new Q(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(u)} bytes`,{data:o.data,logLevel:a,message:i},u,this.maxLogSize);this.onError&&this.onError(h);return}this.enableBatchSend?this.addToBatch(n,u):this.sendPayload(n).catch(h=>{this.onError&&this.onError(h)})}catch(r){this.onError&&this.onError(r)}}addToBatch(t,s){const r=this.currentBatchSize+s+this.batchSendDelimiter.length,a=this.maxPayloadSize*.9;if(r>a&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.batchSizeQueue.push(s),this.currentBatchSize+=s+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const i=this.batchQueue.length-this.maxQueueSize,o=this.batchQueue.splice(0,i);this.batchSizeQueue.splice(0,i),this.currentBatchSize=this.#e(),this.onDrop&&this.onDrop(o.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#e(){let t=0;for(let s=0;s<this.batchSizeQueue.length;s+=1)t+=this.batchSizeQueue[s]+(s<this.batchSizeQueue.length-1?this.batchSendDelimiter.length:0);return t}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const t=this.batchQueue.splice(0,this.batchSize);this.batchSizeQueue.splice(0,this.batchSize),this.currentBatchSize=this.#e();try{await this.sendBatch(t)}catch(s){this.onError&&this.onError(s)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let s;switch(this.batchMode){case"array":{const r=t.map(a=>JSON.parse(a));s=JSON.stringify(r);break}case"field":{const r=t.map(i=>JSON.parse(i)),a=this.batchFieldName?{[this.batchFieldName]:r}:{};s=JSON.stringify(a);break}default:{s=t.join(this.batchSendDelimiter);break}}await this.sendPayload(s,this.batchContentType)}async sendPayload(t,s){const r=typeof this.headers=="function"?this.headers():{...this.headers};r["content-type"]??=s??this.contentType;let a=t;if(this.compression&&!this.edgeCompat)try{a=await L(t),r["content-encoding"]="gzip"}catch(i){this.onError&&this.onError(new Error(`Compression failed: ${String(i)}`))}await q(this.url,this.method,r,a,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}class W extends U{constructor(t){super({...t,edgeCompat:!0})}}export{W as default};
@@ -1 +1 @@
1
- import{AbstractHttpReporter as r}from"./abstract-http-reporter.js";class o extends r{constructor(t){super(t)}}export{o as default};
1
+ import{AbstractHttpReporter as r}from"./abstract-http-reporter.js";class p extends r{constructor(t){super(t)}}export{p as default};
@@ -1,8 +1,6 @@
1
1
  import { s as stringify } from "../../packem_shared/index.d-T71KjNAr.js";
2
- import { LiteralUnion } from 'type-fest';
3
- import { R as ReadonlyMeta, E as ExtendedRfc5424LogLevels, S as StringifyAwareReporter } from "../../packem_shared/types.d-DGHeA2iJ.js";
2
+ import { R as ReadonlyMeta, E as ExtendedRfc5424LogLevels, L as LiteralUnion, S as StringifyAwareReporter } from "../../packem_shared/types.d-DNoig6eq.js";
4
3
  import '@visulima/colorize';
5
- import '@visulima/interactive-manager';
6
4
  /**
7
5
  * Options for configuring JSON reporters.
8
6
  */
@@ -1 +1 @@
1
- import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-BpWRnN0L.js";import{default as p}from"../../packem_shared/JsonReporter-Dd3kuj8X.js";export{e as AbstractJsonReporter,p as JsonReporter};
1
+ import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-elZG6xkO.js";import{default as p}from"../../packem_shared/JsonReporter-DX9fJfwQ.js";export{e as AbstractJsonReporter,p as JsonReporter};
@@ -1 +1 @@
1
- import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-DxZwImm5.js";import{default as p}from"../../packem_shared/JsonReporter-9IcELa1m.js";export{e as AbstractJsonReporter,p as JsonReporter};
1
+ import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-DPsVS6w5.js";import{default as p}from"../../packem_shared/JsonReporter-CY90KVxK.js";export{e as AbstractJsonReporter,p as JsonReporter};
@@ -1,7 +1,5 @@
1
- import { LiteralUnion } from 'type-fest';
2
- import { D as DefaultLogTypes, L as LoggerTypesConfig, R as ReadonlyMeta, a as LoggerTypesAwareReporter } from "../../packem_shared/types.d-DGHeA2iJ.js";
1
+ import { D as DefaultLogTypes, L as LiteralUnion, a as LoggerTypesConfig, R as ReadonlyMeta, b as LoggerTypesAwareReporter } from "../../packem_shared/types.d-DNoig6eq.js";
3
2
  import '@visulima/colorize';
4
- import '@visulima/interactive-manager';
5
3
  /**
6
4
  * Abstract Pretty Reporter.
7
5
  *
@@ -1 +1 @@
1
- import{default as t}from"../../packem_shared/PrettyReporter-BUWNEg3_.js";export{t as PrettyReporter};
1
+ import{default as t}from"../../packem_shared/PrettyReporter-ClyBiPyQ.js";export{t as PrettyReporter};
@@ -1,5 +1,5 @@
1
- import { L as LiteralUnion, D as DefaultLogTypes, d as LoggerTypesConfig, R as ReadonlyMeta, f as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-4ge_rME4.js";
2
1
  import { InteractiveManager } from '@visulima/interactive-manager';
2
+ import { D as DefaultLogTypes, L as LiteralUnion$1, d as LoggerTypesConfig, R as ReadonlyMeta, f as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-4ge_rME4.js";
3
3
  import '@visulima/colorize';
4
4
  type ColorizeMethod = (value: string) => string;
5
5
  type CodeFrameOptions = {
@@ -70,6 +70,42 @@ type Options$1 = {
70
70
  /** Optional source-map resolver to map compiled frame positions back to original source. */
71
71
  sourceMap?: SourceMapResolver;
72
72
  } & Omit<CodeFrameOptions, "message | prefix">;
73
+ /**
74
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
75
+
76
+ @category Type
77
+ */
78
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
79
+ /**
80
+ Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
81
+
82
+ Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
83
+
84
+ This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
85
+
86
+ @example
87
+ ```
88
+ import type {LiteralUnion} from 'type-fest';
89
+
90
+ // Before
91
+
92
+ type Pet = 'dog' | 'cat' | string;
93
+
94
+ const petWithoutAutocomplete: Pet = '';
95
+ // Start typing in your TypeScript-enabled IDE.
96
+ // You **will not** get auto-completion for `dog` and `cat` literals.
97
+
98
+ // After
99
+
100
+ type Pet2 = LiteralUnion<'dog' | 'cat', string>;
101
+
102
+ const petWithAutoComplete: Pet2 = '';
103
+ // You **will** get auto-completion for `dog` and `cat` literals.
104
+ ```
105
+
106
+ @category Type
107
+ */
108
+ type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
73
109
  interface Options {
74
110
  /**
75
111
  * When `true`, honour custom inspectors: a value's
@@ -152,7 +188,7 @@ declare abstract class AbstractPrettyReporter<T extends string = string, L exten
152
188
  /** Styling options for pretty formatting */
153
189
  protected readonly styles: PrettyStyleOptions;
154
190
  /** Logger type configurations for styling */
155
- protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
191
+ protected loggerTypes: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>;
156
192
  /**
157
193
  * Creates a new AbstractPrettyReporter instance.
158
194
  * @param options Styling options for pretty formatting
@@ -163,7 +199,7 @@ declare abstract class AbstractPrettyReporter<T extends string = string, L exten
163
199
  * Sets the logger types configuration for styling.
164
200
  * @param types Logger type configurations with colors and labels
165
201
  */
166
- setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
202
+ setLoggerTypes(types: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>): void;
167
203
  /**
168
204
  * Logs a message with pretty formatting.
169
205
  * @param meta The log metadata to format and output
@@ -242,7 +278,7 @@ declare class PrettyReporter<T extends string = string, L extends string = strin
242
278
  * Sets the logger types configuration and refreshes cached badge/label widths.
243
279
  * @param types Logger type configurations with colors and labels
244
280
  */
245
- override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
281
+ override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>): void;
246
282
  /**
247
283
  * Sets the stdout stream for the reporter.
248
284
  * @param stdout_ The writable stream to use for standard output
@@ -265,6 +301,6 @@ declare class PrettyReporter<T extends string = string, L extends string = strin
265
301
  setIsInteractive(interactive: boolean): void;
266
302
  log(meta: ReadonlyMeta<L>): void;
267
303
  protected _formatMessage(data: ReadonlyMeta<L>): string;
268
- protected _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
304
+ protected _log(message: string, logLevel: LiteralUnion$1<ExtendedRfc5424LogLevels, L>): void;
269
305
  }
270
306
  export { PrettyReporter, type PrettyReporterOptions };
@@ -1 +1 @@
1
- import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-DbgD89ck.js";export{t as PrettyReporter};
1
+ import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-B3yHM4Cb.js";export{t as PrettyReporter};
@@ -1,6 +1,5 @@
1
- import { LiteralUnion } from 'type-fest';
2
1
  import { InteractiveManager } from '@visulima/interactive-manager';
3
- import { D as DefaultLogTypes, L as LoggerTypesConfig, f as ReadonlyMeta, d as LoggerTypesAwareReporter, I as InteractiveStreamReporter } from "../../packem_shared/types.d-BW8kAXUv.js";
2
+ import { D as DefaultLogTypes, L as LiteralUnion$1, a as LoggerTypesConfig, g as ReadonlyMeta, e as LoggerTypesAwareReporter, I as InteractiveStreamReporter } from "../../packem_shared/types.d-OiMbrp8C.js";
4
3
  import '@visulima/colorize';
5
4
  type ColorizeMethod = (value: string) => string;
6
5
  type CodeFrameOptions = {
@@ -71,6 +70,42 @@ type Options$1 = {
71
70
  /** Optional source-map resolver to map compiled frame positions back to original source. */
72
71
  sourceMap?: SourceMapResolver;
73
72
  } & Omit<CodeFrameOptions, "message | prefix">;
73
+ /**
74
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
75
+
76
+ @category Type
77
+ */
78
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
79
+ /**
80
+ Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
81
+
82
+ Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
83
+
84
+ This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
85
+
86
+ @example
87
+ ```
88
+ import type {LiteralUnion} from 'type-fest';
89
+
90
+ // Before
91
+
92
+ type Pet = 'dog' | 'cat' | string;
93
+
94
+ const petWithoutAutocomplete: Pet = '';
95
+ // Start typing in your TypeScript-enabled IDE.
96
+ // You **will not** get auto-completion for `dog` and `cat` literals.
97
+
98
+ // After
99
+
100
+ type Pet2 = LiteralUnion<'dog' | 'cat', string>;
101
+
102
+ const petWithAutoComplete: Pet2 = '';
103
+ // You **will** get auto-completion for `dog` and `cat` literals.
104
+ ```
105
+
106
+ @category Type
107
+ */
108
+ type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
74
109
  interface Options {
75
110
  /**
76
111
  * When `true`, honour custom inspectors: a value's
@@ -153,7 +188,7 @@ declare abstract class AbstractPrettyReporter<T extends string = string, L exten
153
188
  /** Styling options for pretty formatting */
154
189
  protected readonly styles: PrettyStyleOptions;
155
190
  /** Logger type configurations for styling */
156
- protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
191
+ protected loggerTypes: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>;
157
192
  /**
158
193
  * Creates a new AbstractPrettyReporter instance.
159
194
  * @param options Styling options for pretty formatting
@@ -164,7 +199,7 @@ declare abstract class AbstractPrettyReporter<T extends string = string, L exten
164
199
  * Sets the logger types configuration for styling.
165
200
  * @param types Logger type configurations with colors and labels
166
201
  */
167
- setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
202
+ setLoggerTypes(types: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>): void;
168
203
  /**
169
204
  * Logs a message with pretty formatting.
170
205
  * @param meta The log metadata to format and output
@@ -207,7 +242,7 @@ type SimpleReporterOptions = PrettyStyleOptions & {
207
242
  declare class SimpleReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
208
243
  #private;
209
244
  constructor(options?: Partial<SimpleReporterOptions>);
210
- override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
245
+ override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion$1<DefaultLogTypes, T>, L>): void;
211
246
  setStdout(stdout_: NodeJS.WriteStream): void;
212
247
  setStderr(stderr_: NodeJS.WriteStream): void;
213
248
  setInteractiveManager(manager?: InteractiveManager): void;
@@ -1,11 +1,11 @@
1
- import{createRequire as re}from"node:module";import I from"@visulima/colorize";import{A as W,c as z,r as B,b as D,d as G,g as O,e as F,f as c,h as H,a as K,Y as C,V as Q,G as $,S as X}from"../../packem_shared/abstract-pretty-reporter-CyfTvmKf.js";const A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:P,stderr:V}=A,{bgGrey:Z,bold:E,cyan:J,green:N,greenBright:U,grey:h,red:b,underline:R,white:ee}=I,te=/[\\/]pail[\\/]dist/,x=S=>!te.test(S);class ae extends W{#e;#r;#i;#h=!1;#o;#s;#t;#a=!1;#n="";#p="";constructor(t={}){const{error:o,inspect:n,...i}=t;super({uppercase:{label:!0,...i.uppercase},...i}),this.#o={...z,indent:void 0,...n},this.#s={...o,color:{fileLine:N,hint:J,marker:b,message:b,method:U,title:b}},this.#e=P,this.#r=V,this.#l()}setLoggerTypes(t){super.setLoggerTypes(t),this.#l()}setStdout(t){this.#e=t,this.#t=void 0,this.#a=!1}setStderr(t){this.#r=t}setInteractiveManager(t){this.#i=t}setIsInteractive(t){this.#h=t}log(t){const o=this.formatMessage(t),n=t.type.level,i=B(n)?"stderr":"stdout",a=i==="stderr"?this.#r:this.#e;this.#h&&this.#i!==void 0&&a.isTTY?this.#i.update(i,o.split(`
1
+ import{createRequire as re}from"node:module";import R from"@visulima/colorize";import{A as Y,d as k,i as q,w as D,b as F,g as W,t as G,c as f,f as X,a as H,Y as j,z as J,v as K,e as S}from"../../packem_shared/abstract-pretty-reporter-C1W1vIw-.js";const P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:B,stderr:V}=P,{bgGrey:N,bold:v,cyan:Q,green:U,greenBright:Z,grey:a,red:$,underline:z,white:ee}=R,te=/[\\/]pail[\\/]dist/,b=L=>!te.test(L);class ne extends Y{#e;#r;#i;#a=!1;#o;#s;#t;#n=!1;#h="";#l="";constructor(t={}){const{error:o,inspect:h,...i}=t;super({uppercase:{label:!0,...i.uppercase},...i}),this.#o={...k,indent:void 0,...h},this.#s={...o,color:{fileLine:U,hint:Q,marker:$,message:$,method:Z,title:$}},this.#e=B,this.#r=V,this.#p()}setLoggerTypes(t){super.setLoggerTypes(t),this.#p()}setStdout(t){this.#e=t,this.#t=void 0,this.#n=!1}setStderr(t){this.#r=t}setInteractiveManager(t){this.#i=t}setIsInteractive(t){this.#a=t}log(t){const o=this.formatMessage(t),h=t.type.level,i=q(h)?"stderr":"stdout",n=i==="stderr"?this.#r:this.#e;this.#a&&this.#i!==void 0&&n.isTTY?this.#i.update(i,o.split(`
2
2
  `),0):D(`${o}
3
- `,a)}#l(){this.#n=G(this.loggerTypes),this.#p=O(this.loggerTypes)}#u(){return!this.#a&&typeof this.#e.on=="function"&&(this.#a=!0,this.#e.on("resize",()=>{this.#t=void 0})),this.#t===void 0&&(this.#t=F().columns),this.#t}formatMessage(t){let o=this.#u();typeof this.styles.messageLength=="number"&&(o=this.styles.messageLength);const{badge:n,context:i,date:a,error:T,file:l,groups:f,label:g,message:u,prefix:d,repeated:_,scope:m,suffix:y,traceError:j,type:L}=t,{color:M}=this.loggerTypes[L.name],v=M?I[M]:ee,p=f.map(()=>" ").join(""),e=[];if(f.length>0&&e.push(`${p+h(`[${f.at(-1)??""}]`)} `),a&&e.push(`${h(this.styles.dateFormatter(typeof a=="string"?new Date(a):a))} `),n)e.push(E(v(n)));else{const s=this.#n;s.length>0&&e.push(h(" ".repeat(s.length)))}const q=this.#p,w=c(q);if(g){const s=c(g),r=Math.max(0,w-s);e.push(`${E(v(H(g,this.styles)))} `," ".repeat(r))}else e.push(" ".repeat(w+1));_&&e.push(`${Z.white(`[${String(_)}x]`)} `),Array.isArray(m)&&m.length>0&&e.push(`${h(`[${m.join(" > ")}]`)} `),d&&e.push(`${h(`[${this.styles.underline.prefix?R(d):d}]`)} `);const Y=c(e.join(""));if(u!==K){const s=typeof u=="string"?u:C(u,this.#o);e.push(p+Q(s,{trim:!1,width:o-3,wrapMode:X.STRICT_WIDTH}))}if(i){let s=!1;e.push(...i.map(r=>{if(r instanceof Error)return s=!0,`
3
+ `,n)}#p(){this.#h=F(this.loggerTypes),this.#l=W(this.loggerTypes)}#c(){return!this.#n&&typeof this.#e.on=="function"&&(this.#n=!0,this.#e.on("resize",()=>{this.#t=void 0})),this.#t===void 0&&(this.#t=G().columns),this.#t}formatMessage(t){let o=this.#c();typeof this.styles.messageLength=="number"&&(o=this.styles.messageLength);const{badge:h,context:i,date:n,error:_,file:p,groups:g,label:d,message:c,prefix:u,repeated:x,scope:m,suffix:y,traceError:E,type:C}=t,{color:T}=this.loggerTypes[C.name],M=T?R[T]:ee,l=g.map(()=>" ").join(""),e=[];if(g.length>0&&e.push(`${l+a(`[${g.at(-1)??""}]`)} `),n&&e.push(`${a(this.styles.dateFormatter(typeof n=="string"?new Date(n):n))} `),h)e.push(v(M(h)));else{const s=this.#h;s.length>0&&e.push(a(" ".repeat(s.length)))}const A=this.#l,w=f(A);if(d){const s=f(d),r=Math.max(0,w-s);e.push(`${v(M(X(d,this.styles)))} `," ".repeat(r))}else e.push(" ".repeat(w+1));x&&e.push(`${N.white(`[${String(x)}x]`)} `),Array.isArray(m)&&m.length>0&&e.push(`${a(`[${m.join(" > ")}]`)} `),u&&e.push(`${a(`[${this.styles.underline.prefix?z(u):u}]`)} `);const I=f(e.join(""));if(c!==H){const s=typeof c=="string"?c:j(c,this.#o);e.push(l+J(s,{trim:!1,width:o-3,wrapMode:K.PRESERVE_WORDS}))}if(i){let s=!1;e.push(...i.map(r=>{if(r instanceof Error)return s=!0,`
4
4
 
5
- ${$(r,{...this.#s,filterStacktrace:x,prefix:p})}`;if(typeof r=="object")return` ${C(r,this.#o)}`;const k=(s?`
5
+ ${S(r,{...this.#s,filterStacktrace:b,prefix:l})}`;if(typeof r=="object")return` ${j(r,this.#o)}`;const O=(s?`
6
6
 
7
- `:" ")+String(r);return s=!1,k}))}if(T&&e.push($(T,{...this.#s,filterStacktrace:x,prefix:p})),j&&e.push(`
7
+ `:" ")+String(r);return s=!1,O}))}if(_&&e.push(S(_,{...this.#s,filterStacktrace:b,prefix:l})),E&&e.push(`
8
8
 
9
- ${$(j,{...this.#s,filterStacktrace:x,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:p})}`),y&&e.push(` ${p}${h(this.styles.underline.suffix?R(y):y)}`),l){const s=(l.name??"")+(l.line?`:${String(l.line)}`:""),r=Math.max(0,Y-c("Caller: "));e.push(`
10
- `,h("Caller: ")," ".repeat(r),s,`
11
- `)}return e.join("")}}export{ae as SimpleReporter};
9
+ ${S(E,{...this.#s,filterStacktrace:b,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:l})}`),y&&e.push(` ${l}${a(this.styles.underline.suffix?z(y):y)}`),p){const s=(p.name??"")+(p.line?`:${String(p.line)}`:""),r=Math.max(0,I-f("Caller: "));e.push(`
10
+ `,a("Caller: ")," ".repeat(r),s,`
11
+ `)}return e.join("")}}export{ne as SimpleReporter};
@@ -1 +1 @@
1
- import{d as c}from"./packem_shared/serializeError-52C4oiKx-CrnRcq9R.js";const m=8,h={debug:0,error:3,info:1,warn:2},l={debug:"debug",error:"error",info:"info",warn:"warn"},u=(s,t)=>{const e={...s},r=Object.keys(t);for(let i=0;i<r.length;i+=1){const a=r[i],o=t[a],n=e[a];o!==null&&typeof o=="object"&&!Array.isArray(o)&&n!==null&&typeof n=="object"&&!Array.isArray(n)?e[a]=u(n,o):e[a]=o}return e},g=s=>s<1e3?`${String(s)}ms`:`${(s/1e3).toFixed(2)}s`,d=(s,t)=>{const e={message:typeof s.message=="string"?s.message:"",name:typeof s.name=="string"?s.name:"Error"};if(s.stack&&(e.stack=s.stack),s.status!==void 0?e.status=s.status:s.statusCode!==void 0&&(e.status=s.statusCode),s.data!==void 0&&(e.data=s.data),t.cause instanceof Error){const{cause:r}=s;r==="[Circular]"?e.cause="[Circular]":r!==null&&typeof r=="object"&&(e.cause=d(r,t.cause))}return e},p=s=>d(c(s,{maxDepth:m}),s);class v{name;autoEmit;data;emitted;attachedError;level;pail;requestLogs;service;startTime;status;timestamp;_type;constructor(t){this.name=t.name,this.pail=t.pail,this.data={},this.startTime=performance.now(),this.timestamp=new Date().toISOString(),this.emitted=!1,this.autoEmit=t.autoEmit??!0,this._type=t.type??"info",this.level="info",this.requestLogs=[],this.service=t.service}debug(t,e){return this.addLogEntry("debug",t,e)}emit(t){if(this.emitted)return;this.emitted=!0;const e=Math.round(performance.now()-this.startTime),r=this.attachedError?"error":this.level,i=t??l[r],a={duration:g(e),duration_ms:e,event:this.name,timestamp:this.timestamp,...this.data};this.service&&(a.service=this.service),this.status!==void 0&&(a.status=this.status),this.attachedError&&(a.error=p(this.attachedError)),this.requestLogs.length>0&&(a.requestLogs=this.requestLogs);const o=this.pail[i];o({message:a})}error(t,e,r){return e&&(this.attachedError=e),this.addLogEntry("error",t,r)}finish(t){t?.status!==void 0&&(this.status=t.status),t?.error&&(this.attachedError=t.error),this.emit()}getData(){return this.data}getLevel(){return this.attachedError?"error":this.level}getRequestLogs(){return this.requestLogs}info(t,e){return this.addLogEntry("info",t,e)}set(t){return this.data=u(this.data,t),this}setError(t){return this.attachedError=t,this}setStatus(t){return this.status=t,this}warn(t,e){return this.addLogEntry("warn",t,e)}[Symbol.dispose](){this.autoEmit&&!this.emitted&&this.emit()}addLogEntry(t,e,r){const i={level:t,message:e,timestamp:new Date().toISOString()};return r&&(i.context=r),this.requestLogs.push(i),this.escalateLevel(t),this}escalateLevel(t){(h[t]??0)>(h[this.level]??0)&&(this.level=t)}}const f=s=>new v(s);export{v as WideEvent,f as createWideEvent};
1
+ import{g as d}from"./packem_shared/serializeError-Kr3JL9UN-zwOuO-gY.js";const l=8,h={debug:0,error:3,info:1,warn:2},m={debug:"debug",error:"error",info:"info",warn:"warn"},u=(r,t)=>{const e={...r},s=Object.keys(t);for(let a=0;a<s.length;a+=1){const i=s[a],o=t[i],n=e[i];o!==null&&typeof o=="object"&&!Array.isArray(o)&&n!==null&&typeof n=="object"&&!Array.isArray(n)?e[i]=u(n,o):e[i]=o}return e},f=r=>r<1e3?`${String(r)}ms`:`${(r/1e3).toFixed(2)}s`,c=(r,t)=>{const e={message:typeof r.message=="string"?r.message:"",name:typeof r.name=="string"?r.name:"Error"};if(r.stack&&(e.stack=r.stack),r.status!==void 0?e.status=r.status:r.statusCode!==void 0&&(e.status=r.statusCode),r.data!==void 0&&(e.data=r.data),t.cause instanceof Error){const{cause:s}=r;s==="[Circular]"?e.cause="[Circular]":s!==null&&typeof s=="object"&&(e.cause=c(s,t.cause))}return e},g=r=>c(d(r,{maxDepth:l}),r);class E{name;autoEmit;data;emitted;attachedError;level;pail;requestLogs;service;startTime;status;timestamp;_type;constructor(t){this.name=t.name,this.pail=t.pail,this.data={},this.startTime=performance.now(),this.timestamp=new Date().toISOString(),this.emitted=!1,this.autoEmit=t.autoEmit??!0,this._type=t.type??"info",this.level="info",this.requestLogs=[],this.service=t.service}debug(t,e){return this.addLogEntry("debug",t,e)}emit(t){if(this.emitted)return;this.emitted=!0;const e=Math.round(performance.now()-this.startTime),s=this.attachedError?"error":this.level,a=t??m[s],i={duration:f(e),duration_ms:e,event:this.name,timestamp:this.timestamp,...this.data};this.service&&(i.service=this.service),this.status!==void 0&&(i.status=this.status),this.attachedError&&(i.error=g(this.attachedError)),this.requestLogs.length>0&&(i.requestLogs=this.requestLogs);const o=this.pail[a];o({message:i})}error(t,e,s){return e&&(this.attachedError=e),this.addLogEntry("error",t,s)}finish(t){t?.status!==void 0&&(this.status=t.status),t?.error&&(this.attachedError=t.error),this.emit()}getData(){return this.data}getLevel(){return this.attachedError?"error":this.level}getRequestLogs(){return this.requestLogs}info(t,e){return this.addLogEntry("info",t,e)}set(t){return this.data=u(this.data,t),this}setError(t){return this.attachedError=t,this}setStatus(t){return this.status=t,this}warn(t,e){return this.addLogEntry("warn",t,e)}[Symbol.dispose](){this.autoEmit&&!this.emitted&&this.emit()}addLogEntry(t,e,s){const a={level:t,message:e,timestamp:new Date().toISOString()};return s&&(a.context=s),this.requestLogs.push(a),this.escalateLevel(t),this}escalateLevel(t){(h[t]??0)>(h[this.level]??0)&&(this.level=t)}}const v=r=>new E(r);export{E as WideEvent,v as createWideEvent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/pail",
3
- "version": "4.1.0",
3
+ "version": "5.0.0",
4
4
  "description": "Highly configurable Logger for Node.js, Edge and Browser.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -251,13 +251,13 @@
251
251
  "MIGRATION-GUIDE.md"
252
252
  ],
253
253
  "dependencies": {
254
- "@visulima/colorize": "2.1.0",
254
+ "@visulima/colorize": "2.1.1",
255
255
  "@visulima/interactive-manager": "1.0.1"
256
256
  },
257
257
  "peerDependencies": {
258
258
  "@opentelemetry/api": "^1.9.1",
259
259
  "@sveltejs/kit": ">=2.0",
260
- "@visulima/redact": "3.1.0",
260
+ "@visulima/redact": "5.0.0",
261
261
  "elysia": ">=1.0",
262
262
  "express": ">=4.0",
263
263
  "fastify": ">=4.0",