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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/LICENSE.md +841 -6
  3. package/README.md +53 -24
  4. package/dist/index.browser.d.ts +16 -5
  5. package/dist/index.browser.js +19 -19
  6. package/dist/index.server.d.ts +30 -5
  7. package/dist/index.server.js +28 -27
  8. package/dist/middleware/elysia.d.ts +5 -4
  9. package/dist/middleware/elysia.js +1 -1
  10. package/dist/middleware/express.d.ts +5 -4
  11. package/dist/middleware/express.js +1 -1
  12. package/dist/middleware/fastify.d.ts +5 -4
  13. package/dist/middleware/fastify.js +1 -1
  14. package/dist/middleware/hono.d.ts +5 -4
  15. package/dist/middleware/hono.js +1 -1
  16. package/dist/middleware/next/handler.d.ts +5 -4
  17. package/dist/middleware/next/handler.js +1 -1
  18. package/dist/middleware/sveltekit.d.ts +5 -4
  19. package/dist/middleware/sveltekit.js +1 -1
  20. package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +1 -0
  21. package/dist/packem_shared/AbstractJsonReporter-C6iu_u9-.js +1 -0
  22. package/dist/packem_shared/JsonReporter-BXktpC__.js +2 -0
  23. package/dist/packem_shared/JsonReporter-bmem9lcg.js +1 -0
  24. package/dist/packem_shared/{PrettyReporter-D75CJT0C.js → PrettyReporter-DsHfKOU7.js} +3 -3
  25. package/dist/packem_shared/PrettyReporter-LXeSlx8P.js +44 -0
  26. package/dist/packem_shared/{abstract-json-reporter.d-Boj5w068.d.ts → abstract-json-reporter.d-wfESoEa-.d.ts} +3 -2
  27. package/dist/packem_shared/abstract-pretty-reporter-eLxhddj0.js +57 -0
  28. package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-f9no2VNI.js +25 -0
  29. package/dist/packem_shared/{create-middleware-logger.d-MK7moe4r.d.ts → create-middleware-logger.d-B-JmQ1Sl.d.ts} +2 -2
  30. package/dist/packem_shared/{headers-D-K_EnkH.js → headers-DH0H2s8W.js} +1 -1
  31. package/dist/packem_shared/index-Q1764hvO.js +1 -0
  32. package/dist/packem_shared/index.d-T71KjNAr.d.ts +16 -0
  33. package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +1 -0
  34. package/dist/packem_shared/{types.d-Ck_RSjLg.d.ts → types.d-bWnqHJKL.d.ts} +2 -37
  35. package/dist/packem_shared/{wide-event.d-DkYD7YVK.d.ts → wide-event.d-D3ATYpoK.d.ts} +17 -5
  36. package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +1 -0
  37. package/dist/packem_shared/write-stream-C7jxLxIT.js +1 -0
  38. package/dist/processor/caller/caller-processor.d.ts +2 -1
  39. package/dist/processor/environment-processor.d.ts +2 -1
  40. package/dist/processor/message-formatter-processor.d.ts +9 -1
  41. package/dist/processor/message-formatter-processor.js +1 -1
  42. package/dist/processor/opentelemetry-processor.d.ts +2 -1
  43. package/dist/processor/redact-processor.d.ts +41 -2
  44. package/dist/processor/sampling-processor.d.ts +2 -1
  45. package/dist/reporter/file/json-file-reporter.d.ts +21 -3
  46. package/dist/reporter/file/json-file-reporter.js +1 -1
  47. package/dist/reporter/http/abstract-http-reporter.d.ts +46 -3
  48. package/dist/reporter/http/abstract-http-reporter.js +2 -2
  49. package/dist/reporter/http/http-reporter.d.ts +4 -3
  50. package/dist/reporter/http/http-reporter.edge-light.d.ts +57 -1
  51. package/dist/reporter/http/http-reporter.edge-light.js +2 -2
  52. package/dist/reporter/json/index.browser.d.ts +1 -1
  53. package/dist/reporter/json/index.browser.js +1 -1
  54. package/dist/reporter/json/index.d.ts +6 -4
  55. package/dist/reporter/json/index.js +1 -1
  56. package/dist/reporter/pretty/index.browser.js +1 -1
  57. package/dist/reporter/pretty/index.d.ts +58 -38
  58. package/dist/reporter/pretty/index.js +1 -1
  59. package/dist/reporter/simple/simple-reporter.server.d.ts +87 -5
  60. package/dist/reporter/simple/simple-reporter.server.js +8 -8
  61. package/dist/wide-event.d.ts +4 -3
  62. package/dist/wide-event.js +1 -1
  63. package/package.json +5 -5
  64. package/dist/packem_shared/AbstractJsonReporter-CF0KKdQS.js +0 -1
  65. package/dist/packem_shared/AbstractJsonReporter-CVwjgboT.js +0 -1
  66. package/dist/packem_shared/JsonReporter-BJFnahby.js +0 -1
  67. package/dist/packem_shared/JsonReporter-CnLM-d0U.js +0 -2
  68. package/dist/packem_shared/PrettyReporter-D9aBMmxI.js +0 -45
  69. package/dist/packem_shared/abstract-pretty-reporter-zijeSUgy.js +0 -34
  70. package/dist/packem_shared/index-COQEZODZ.js +0 -1
  71. package/dist/packem_shared/write-console-log-based-on-level-DDSKGBKj.js +0 -1
  72. package/dist/packem_shared/write-stream-B6BXco86.js +0 -1
  73. /package/dist/packem_shared/{createPailError-CbU1Ogfa.js → PailError-CbU1Ogfa.js} +0 -0
@@ -0,0 +1,25 @@
1
+ import{createRequire as H}from"node:module";const K=H(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Q=r=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[e,i]=w.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return w.getBuiltinModule(r)}return K(r)},{createRequire:j}=Q("node:module"),X=j(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=r=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[e,i]=b.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return b.getBuiltinModule(r)}return X(r)};Z("node:util");const ee=globalThis.process??Object.create(null),T={versions:{}},A=new Proxy(ee,{get(r,e){if(e in r)return r[e];if(e in T)return T[e]}}),re=r=>r.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
2
+ `),ie=(r,e,i,t)=>{const s={column:0,line:-1,...r.start},n={...s,...r.end},o=s.line,d=s.column,l=n.line,c=n.column;let a=Math.max(o-(i+1),0),m=Math.min(e.length,l+t);o===-1&&(a=0),l===-1&&(m=e.length);const p=l-o,f={};if(p)for(let u=0;u<=p;u++){const h=u+o;if(!d)f[h]=!0;else if(u===0){const v=e[h-1]?.length;f[h]=[d,(v??0)-d+1]}else if(u===p)f[h]=[0,c];else{const v=e[h-u]?.length;f[h]=[0,v]}}else d===c?f[o]=d?[d,0]:!0:f[o]=[d,(c??0)-(d??0)];return{end:m,markerLines:f,start:a}},te=A.platform==="win32"&&!A.env?.WT_SESSION?">":"❯",ne=(r,e,i)=>{const t={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...i,color:{gutter:u=>u,marker:u=>u,message:u=>u,...i?.color}},s=typeof e.start.column=="number";let n=(r.includes("\r")?re(r):r).split(`
3
+ `);typeof t.tabWidth=="number"&&r.includes(" ")&&(n=n.map(u=>u.replaceAll(" "," ".repeat(t.tabWidth))));const{end:o,markerLines:d,start:l}=ie(e,n,t.linesAbove,t.linesBelow),c=String(o).length,{gutter:a,marker:m,message:p}=t.color;let f=n.slice(l,o).map((u,h)=>{const v=l+1+h,E=d[v],U=String(v).padStart(c),z=!d[v+1],S=` ${U}${t.showGutter?" |":""}`;if(E){let N="";if(Array.isArray(E)){const D=u.replaceAll(/[^\t]/g," ").slice(0,Math.max(E[0]-1,0)),Y=E[1]||1;N=[`
4
+ `,t.prefix+a(S.replaceAll(/\d/g," "))," ",D,m("^").repeat(Y)].join(""),z&&t.message&&(N+=` ${p(t.message)}`)}return[t.prefix+m(te),a(S),u.length>0?` ${u}`:"",N].join("")}return`${t.prefix} ${a(S)}${u.length>0?` ${u}`:""}`}).join(`
5
+ `);return t.message&&!s&&(f=`${t.prefix+" ".repeat(c+1)+t.message}
6
+ ${f}`),f},oe=()=>A.env?.DEBUG==="true",$=(r,...e)=>{if(oe()){const i=e.map(t=>typeof t=="function"?t():t);console.debug(`error:parse-stacktrace: ${r}`,...i)}},g="<unknown>",se=/^(?:node:internal\/|node:|internal\/)/,le=r=>r!==void 0&&se.test(r),ae=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ce=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,de=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,ue=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,fe=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,me=/in\s(.*)\s\(at\s(.+)\)\sat/,pe=/^(?:.*@)?(.*):(\d+):(\d+)$/,he=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ve=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,$e=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,L=/\(error: (.*)\)/,ge=/at\s/,ye=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,xe=/\S*(?:Error: |AggregateError:)/,_=/^Anonymous function$/,we=/^\s*in\s.*/,be=/^.*?\s*at\s.*/,Ee=/^.*?\s*@.*|\[native code\]/,C=(r,e)=>{const i=r.includes("safari-extension"),t=r.includes("safari-web-extension");return i||t?[r.includes("@")?r.split("@")[0]:g,i?`safari-extension:${e}`:`safari-web-extension:${e}`]:[r,e]},B=(r,e)=>{const i=de.exec(e);i&&(r.file=i[1],r.line=+i[2],r.column=+i[3])},Se=r=>{const e=me.exec(r);if(e){$(`parse nested node error stack line: "${r}"`,()=>`found: ${JSON.stringify(e)}`);const t=e[2].split(":");return{column:t[2]?+t[2]:void 0,file:t[0],line:t[1]?+t[1]:void 0,methodName:e[1]??g,raw:r,type:void 0}}const i=fe.exec(r);if(i){$(`parse node error stack line: "${r}"`,()=>`found: ${JSON.stringify(i)}`);const t={column:i[4]?+i[4]:void 0,file:i[2]?i[2].replace(ge,""):void 0,line:i[3]?+i[3]:void 0,methodName:i[1]??g,raw:r,type:r.startsWith("internal")?"internal":void 0};return B(t,`${i[2]}:${i[3]}:${i[4]}`),t}},Ne=r=>{const e=ae.exec(r);if(e){$(`parse chrome error stack line: "${r}"`,()=>`found: ${JSON.stringify(e)}`);const i=e[2]?.startsWith("native"),t=e[2]?.startsWith("eval")||e[1]?.startsWith("eval");let s,n;if(t){const c=ce.exec(r);if(c){const a=ye.exec(c[1]);a?(e[2]=a[4]??a[1],e[3]=a[5]??a[2],e[4]=a[3]):c[2]&&(e[2]=c[1]),c[2]&&(s={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0,methodName:"eval",raw:r,type:"eval"})}else{const a=ue.exec(r);a&&(n={column:a[4]?+a[4]:void 0,file:a[2],line:a[3]?+a[3]:void 0},s={column:a[6]?+a[6]:void 0,file:a[1],line:a[5]?+a[5]:void 0,methodName:"eval",raw:a[0],type:"eval"})}}const[o,d]=C(e[1]?e[1].replace(_,"<anonymous>"):g,e[2]),l={column:e[4]?+e[4]:void 0,evalOrigin:s,file:d,line:e[3]?+e[3]:void 0,methodName:o,raw:r,type:t?"eval":i?"native":le(d)?"internal":void 0};return n?(l.column=n.column,l.file=n.file,l.line=n.line):B(l,`${d}:${e[3]}:${e[4]}`),l}},Ae=(r,e)=>{const i=he.exec(r);if(i){$(`parse gecko error stack line: "${r}"`,()=>`found: ${JSON.stringify(i)}`);const t=i[3]?.includes(" > eval"),s=t&&i[3]&&ve.exec(i[3]);let n;t&&s&&(i[3]=s[1],n={column:i[5]?+i[5]:void 0,file:i[3],line:i[4]?+i[4]:void 0,methodName:"eval",raw:r,type:"eval"},i[4]=s[2]);const[o,d]=C(i[1]?i[1].replace(_,"<anonymous>"):g,i[3]);let l;(e?.type==="safari"||!t&&e?.type==="firefox")&&e.column?l=e.column:!t&&i[5]&&(l=+i[5]);let c;return(e?.type==="safari"||!t&&e?.type==="firefox")&&e.line?c=e.line:i[4]&&(c=+i[4]),{column:l,evalOrigin:n,file:d,line:c,methodName:o,raw:r,type:t?"eval":d.includes("[native code]")?"native":void 0}}},ke=(r,e)=>{const i=$e.exec(r);if(!(i&&i[2].includes(" > eval"))&&i)return $(`parse firefox error stack line: "${r}"`,()=>`found: ${JSON.stringify(i)}`),{column:i[4]?+i[4]:e?.column??void 0,file:i[2],line:i[3]?+i[3]:e?.line??void 0,methodName:i[1]||g,raw:r,type:void 0}},Me=r=>{const e=pe.exec(r);if(e)return $(`parse react android native error stack line: "${r}"`,()=>`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:g,raw:r,type:void 0}},O=(r,{filter:e,frameLimit:i=50}={})=>{const t=r;let s=(typeof t.stacktrace=="string"?t.stacktrace:r.stack??"").split(`
7
+ `).map(n=>(L.test(n)?n.replace(L,"$1"):n).trim()).filter(n=>!xe.test(n)&&n!=="eval code");return e&&(s=s.filter(n=>e(n))),s=s.slice(0,i),s.reduce((n,o,d)=>{if(!o||o.length>1024)return n;let l;if(we.test(o))l=Se(o);else if(be.test(o))l=Ne(o);else if(Ee.test(o)){let c;if(d===0){const a=r,m=a.columnNumber,p=a.lineNumber,f=a.line,u=a.column;m||p?c={column:m,line:p,type:"firefox"}:(f||u)&&(c={column:u,line:f,type:"safari"})}l=ke(o,c)??Ae(o,c)}else l=Me(o);return l?n.push(l):$(`parse error stack line: "${o}"`,"not parser found"),n},[])},Te=j(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=r=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,i]=x.versions.node.split(".").map(Number);if(e>22||e===22&&i>=3||e===20&&i>=16)return x.getBuiltinModule(r)}return Te(r)},{existsSync:Le,readFileSync:We}=k("node:fs"),{relative:je,resolve:W,sep:_e}=k("node:path"),{cwd:Ce}=x,{fileURLToPath:Be}=k("node:url"),y=(r,e,i)=>i===0?r:e===" "?r+" ".repeat(i):r+" ".repeat(e*i),R=r=>r.replaceAll("\\","/"),Oe=(r,e)=>{const i=r.replace("async file:","file:");return R(je(e,i.startsWith("file:")?Be(i):i))},Re=(r,e,i)=>{if(e)return i.title(r.message);const t=r.message?`: ${r.message}`:"";return i.title(r.name+t)},I=(r,{color:e,hideErrorTitle:i,indentation:t,prefix:s},n)=>`${y(s,t,n)}${Re(r,i,e)}
8
+ `,P=(r,{color:e,indentation:i,prefix:t},s)=>{if(r.hint===void 0)return;const n=y(t,i,s);let o="";if(Array.isArray(r.hint))for(const d of r.hint)o+=`${n+d}
9
+ `;else o+=n+r.hint;return e.hint(o)},V=(r,e)=>{if(!e||r.file===void 0||r.line===void 0)return{trace:r};try{const i=e({column:r.column,file:r.file,line:r.line});return i?{source:i.source,trace:{...r,column:i.column??r.column,file:i.file??r.file,line:i.line??r.line}}:{trace:r}}catch{return{trace:r}}},M=(r,e,i=0)=>{const{color:t,cwd:s,displayShortPath:n,indentation:o,prefix:d}=e,{trace:l}=V(r,e.sourceMap),c=n?Oe(l.file,s):R(l.file),{fileLine:a,method:m}=t;return`${y(d,o,i)}at ${l.methodName?`${m(l.methodName)} `:""}${a(c)}:${a(l.line?.toString()??"")}`},Ie=(r,e)=>{if(e.allowAllFilePaths)return!0;const i=W(e.cwd),t=W(i,r);return t===i||t.startsWith(i+_e)},G=(r,e,i)=>{const{color:t,indentation:s,linesAbove:n,linesBelow:o,prefix:d,showGutter:l,showLineNumbers:c,tabWidth:a}=e,{source:m,trace:p}=V(r,e.sourceMap);if(p.file===void 0)return;let f;if(m===void 0){const u=p.file.replace("file://","");if(!Ie(u,e)||!Le(u))return;f=We(u,"utf8")}else f=m;return ne(f,{start:{column:p.column,line:p.line}},{color:t,linesAbove:n,linesBelow:o,prefix:y(d,s,i),showGutter:l,showLineNumbers:c,tabWidth:a})},J=(r,e,i)=>{if(r.errors.length===0)return;let t=`${y(e.prefix,e.indentation,i)}Errors:
10
+
11
+ `,s=!0;for(const n of r.errors)s?s=!1:t+=`
12
+
13
+ `,t+=F(n,{...e,framesMaxLimit:1,hideErrorCodeView:e.hideErrorErrorsCodeView},i+1);return`
14
+ ${t}`},q=(r,e,i,t=new Set)=>{t.add(r);let s=`${y(e.prefix,e.indentation,i)}Caused by:
15
+
16
+ `;const n=r.cause;s+=I(n,e,i);const o=O(n).shift(),d=P(n,e,i);if(d&&(s+=`${d}
17
+ `),o&&(s+=M(o,e,i),!e.hideErrorCauseCodeView)){const l=G(o,e,i);l!==void 0&&(s+=`
18
+ ${l}`)}if(n instanceof AggregateError){const l=J(n,e,i);l!==void 0&&(s+=`
19
+ ${l}`)}return n.cause&&(s+=t.has(n)?`
20
+ ${y(e.prefix,e.indentation,i+1)}Caused by: [Circular]`:`
21
+ ${q(n,e,i+1,t)}`),`
22
+ ${s}`},Pe=(r,e)=>(r.length>0?`
23
+ `:"")+r.map(i=>M(i,e)).join(`
24
+ `),F=(r,e,i)=>{const t={allowAllFilePaths:!1,cwd:Ce(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...e,color:{fileLine:o=>o,gutter:o=>o,hint:o=>o,marker:o=>o,message:o=>o,method:o=>o,title:o=>o,...e.color}},s=O(r,{filter:e.filterStacktrace,frameLimit:t.framesMaxLimit}),n=s.shift();return[e.hideMessage?void 0:I(r,t,i),P(r,t,i),n?M(n,t,i):void 0,n&&!t.hideErrorCodeView?G(n,t,i):void 0,r instanceof AggregateError?J(r,t,i):void 0,r.cause===void 0?void 0:q(r,t,i),s.length>0?Pe(s,t):void 0].filter(Boolean).join(`
25
+ `)},Je=(r,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return F(r,e,0)},Ve=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&Ve.set("AggregateError",AggregateError);export{Je as U};
@@ -1,5 +1,5 @@
1
- import { P as PailBrowserImpl } from "./wide-event.d-DkYD7YVK.js";
2
- import { D as DefaultLogTypes, e as LoggerFunction } from "./types.d-Ck_RSjLg.js";
1
+ import { P as PailBrowserImpl } from "./wide-event.d-D3ATYpoK.js";
2
+ import { D as DefaultLogTypes, L as LoggerFunction } from "./types.d-bWnqHJKL.js";
3
3
  /**
4
4
  * Route configuration for a specific path pattern.
5
5
  */
@@ -1 +1 @@
1
- import{WideEvent as u}from"../wide-event.js";const m=s=>{let e="^",t=0;for(;t<s.length;){const r=s[t];if(r==="*"&&s[t+1]==="*")t+=2,s[t]==="/"&&(t+=1),t>=s.length&&e.endsWith("/")?e=`${e.slice(0,-1)}(/.*)?`:t>=s.length?e+=".*":e+="(.*/)?";else switch(r){case"*":{e+="[^/]*",t+=1;break}case".":{e+=String.raw`\.`,t+=1;break}case"?":{e+="[^/]",t+=1;break}default:e+=r,t+=1}}return e+="$",new RegExp(e)},l=(s,e)=>m(e).test(s),k=(s,e,t)=>t?.some(r=>l(s,r))?!1:e?.length?e.some(r=>l(s,r)):!0,x=(s,e)=>{if(!e)return;const t=Object.entries(e);for(let r=0;r<t.length;r+=1){const[a,o]=t[r];if(l(s,a))return o.service}},L=(s,e)=>{const{exclude:t,include:r,pail:a,routes:o,service:g}=s,{headers:d,method:n,path:i,requestId:p}=e;if(!k(i,r,t)){const h=new u({autoEmit:!1,name:`${n} ${i}`,pail:a});return{finish:()=>{},logger:h,skipped:!0}}const w=x(i,o)??g,c=new u({name:`${n} ${i}`,pail:a,service:w});return c.set({method:n,path:i,requestId:p,...d?{headers:d}:{}}),{finish:h=>{c.finish(h)},logger:c,skipped:!1}},f=new Set(["authorization","cookie","proxy-authorization","set-cookie","x-api-key","x-auth-token"]),$=s=>{const e={};return s.forEach((t,r)=>{f.has(r.toLowerCase())||(e[r.toLowerCase()]=t)}),e},b=s=>{const e={},t=Object.entries(s);for(let r=0;r<t.length;r+=1){const[a,o]=t[r];!f.has(a.toLowerCase())&&o!==void 0&&(e[a.toLowerCase()]=Array.isArray(o)?o.join(", "):o)}return e};export{$ as a,L as c,b as e};
1
+ import{WideEvent as u}from"../wide-event.js";const m=s=>{let e="^",t=0;for(;t<s.length;){const r=s[t];if(r==="*"&&s[t+1]==="*")t+=2,s[t]==="/"&&(t+=1),t>=s.length&&e.endsWith("/")?e=`${e.slice(0,-1)}(/.*)?`:t>=s.length?e+=".*":e+="(.*/)?";else switch(r){case"*":{e+="[^/]*",t+=1;break}case".":{e+=String.raw`\.`,t+=1;break}case"?":{e+="[^/]",t+=1;break}default:e+=r,t+=1}}return e+="$",new RegExp(e)},l=(s,e)=>m(e).test(s),k=(s,e,t)=>t?.some(r=>l(s,r))?!1:e?.length?e.some(r=>l(s,r)):!0,x=(s,e)=>{if(!e)return;const t=Object.entries(e);for(let r=0;r<t.length;r+=1){const[a,o]=t[r];if(l(s,a))return o.service}},L=(s,e)=>{const{exclude:t,include:r,pail:a,routes:o,service:g}=s,{headers:d,method:n,path:i,requestId:p}=e;if(!k(i,r,t)){const h=new u({autoEmit:!1,name:`${n} ${i}`,pail:a});return{finish:()=>{},logger:h,skipped:!0}}const w=x(i,o)??g,c=new u({name:`${n} ${i}`,pail:a,service:w});return c.set({method:n,path:i,requestId:p,...d?{headers:d}:{}}),{finish:h=>{c.finish(h)},logger:c,skipped:!1}},f=new Set(["authorization","cookie","proxy-authorization","set-cookie","x-api-key","x-auth-token"]),$=s=>{const e={};return s.forEach((t,r)=>{f.has(r.toLowerCase())||(e[r.toLowerCase()]=t)}),e},b=s=>{const e={},t=Object.entries(s);for(let r=0;r<t.length;r+=1){const[a,o]=t[r];!f.has(a.toLowerCase())&&o!==void 0&&(e[a.toLowerCase()]=Array.isArray(o)?o.join(", "):o)}return e};export{b as a,L as c,$ as e};
@@ -0,0 +1 @@
1
+ const O=e=>{const t=Object.keys(e).map(o=>e[o].label??"");return t.length===0?"":t.reduce((o,a)=>o.length>a.length?o:a,"")};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,v=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,S=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,x=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),y=/\s+/,m=e=>{const t=B();t.has(e)&&(e=t.get(e));const o=$.exec(e);if(o)return[Number.parseInt(o[1],16),Number.parseInt(o[2],16),Number.parseInt(o[3],16)];const a=A.exec(e);if(a)return[Number.parseInt(`${a[1]}${a[1]}`,16),Number.parseInt(`${a[2]}${a[2]}`,16),Number.parseInt(`${a[3]}${a[3]}`,16)];const c=v.exec(e);if(c)return[Math.round(Math.max(0,Math.min(255,Number(c[1])))),Math.round(Math.max(0,Math.min(255,Number(c[2])))),Math.round(Math.max(0,Math.min(255,Number(c[3]))))];const r=S.exec(e);if(r){let i=Number(r[1])%360;i<0&&(i+=360);const l=Math.max(0,Math.min(100,Number(r[2])))/100,d=Math.max(0,Math.min(100,Number(r[3])))/100,u=(1-Math.abs(2*d-1))*l,b=u*(1-Math.abs(i/60%2-1)),n=d-u/2;let s,f,g;return i<60?{0:s,1:f,2:g}=[u,b,0]:i<120?{0:s,1:f,2:g}=[b,u,0]:i<180?{0:s,1:f,2:g}=[0,u,b]:i<240?{0:s,1:f,2:g}=[0,b,u]:i<300?{0:s,1:f,2:g}=[b,0,u]:{0:s,1:f,2:g}=[u,0,b],[Math.round((s+n)*255),Math.round((f+n)*255),Math.round((g+n)*255)]}return null},k=(e,t)=>e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],D=e=>{if(typeof e!="string")return x();const t=x(),o=[];let a=!1,c=null,r=0,i="";for(const l of e){if(l==="(")r+=1;else if(r>0)l===")"&&(r-=1);else if(a){if(l===";"){const d=i.trim();d!==""&&o.push([c,d]),c=null,i="",a=!1;continue}}else if(l===":"){c=i.trim(),i="",a=!0;continue}i+=l}if(a&&r===0){const l=i.trim();l!==""&&o.push([c,l]),c=null,i=""}for(const{0:l,1:d}of o)switch(l){case"background-color":{d!=null&&(t.backgroundColor=d);break}case"color":{d!=null&&(t.color=d);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(d)&&(t.fontStyle="italic");break}case"font-weight":{d==="bold"&&(t.fontWeight=d);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const u=d.split(y);for(const b of u){const n=m(b);n!=null?t.textDecorationColor=n:["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b)}break}case"text-decoration-color":{const u=m(d);u!=null&&(t.textDecorationColor=u);break}case"text-decoration-line":{t.textDecorationLine=[];const u=d.split(y);for(const b of u)["line-through","overline","underline"].includes(b)&&t.textDecorationLine.push(b);break}}return t},M=(e,t)=>{t=t??x();let o="";if(!k(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)o+="\x1B[49m";else switch(e.backgroundColor){case"black":{o+="\x1B[40m";break}case"blue":{o+="\x1B[44m";break}case"cyan":{o+="\x1B[46m";break}case"green":{o+="\x1B[42m";break}case"magenta":{o+="\x1B[45m";break}case"red":{o+="\x1B[41m";break}case"white":{o+="\x1B[47m";break}case"yellow":{o+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:a,1:c,2:r}=e.backgroundColor;o+=`\x1B[48;2;${String(a)};${String(c)};${String(r)}m`}else{const a=m(e.backgroundColor);if(a===null)o+="\x1B[49m";else{const{0:c,1:r,2:i}=a;o+=`\x1B[48;2;${String(c)};${String(r)};${String(i)}m`}}}if(!k(e.color,t.color))if(e.color==null)o+="\x1B[39m";else switch(e.color){case"black":{o+="\x1B[30m";break}case"blue":{o+="\x1B[34m";break}case"cyan":{o+="\x1B[36m";break}case"green":{o+="\x1B[32m";break}case"magenta":{o+="\x1B[35m";break}case"red":{o+="\x1B[31m";break}case"white":{o+="\x1B[37m";break}case"yellow":{o+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:a,1:c,2:r}=e.color;o+=`\x1B[38;2;${String(a)};${String(c)};${String(r)}m`}else{const a=m(e.color);if(a===null)o+="\x1B[39m";else{const{0:c,1:r,2:i}=a;o+=`\x1B[38;2;${String(c)};${String(r)};${String(i)}m`}}}if(e.fontWeight!==t.fontWeight&&(o+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(o+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!k(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)o+="\x1B[59m";else{const{0:a,1:c,2:r}=e.textDecorationColor;o+=`\x1B[58;2;${String(a)};${String(c)};${String(r)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(o+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(o+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(o+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),o},N=e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},p="%".codePointAt(0),C="s".codePointAt(0),L="d".codePointAt(0),F="f".codePointAt(0),P="i".codePointAt(0),j="O".codePointAt(0),q="o".codePointAt(0),E="j".codePointAt(0),I="c".codePointAt(0),w=(e,t=[],o={})=>{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 a=o.stringify??N,c=1;if(typeof e=="object"){const n=t.length+c;if(n===1)return"{}";const s=Array.from({length:n});s[0]=a(e);for(let f=1;f<n;f+=1)s[f]=a(t[f-c]);return s.join(" ")}if(t.length===0)return e;let r="",i=1-c,l=-1,d=!1,u;const b=o.colors??globalThis.window===void 0;for(let n=0;n<e.length;){if(e.codePointAt(n)===p&&n+1<e.length){l=l>-1?l:0;const s=e.codePointAt(n+1);switch(s){case I:{if(b){const f=D(t[i]);l<n&&(r+=e.slice(l,n));const g=M(f,u);r+=g,g!==""&&(d=!0,u=f)}l=n+2,n+=1;break}case L:case F:{const f=t[i];if(i>=t.length||f==null)break;l<n&&(r+=e.slice(l,n)),r+=(typeof f=="symbol"?Number.NaN:Number(f)).toString(),l=n+2,n+=1;break}case P:{const f=t[i];if(i>=t.length||f==null)break;l<n&&(r+=e.slice(l,n)),r+=Math.floor(typeof f=="symbol"?Number.NaN:Number(f)).toString(),l=n+2,n+=1;break}case E:case j:case q:{if(i>=t.length||t[i]===void 0)break;l<n&&(r+=e.slice(l,n));const f=t[i],g=typeof f;if(g==="string"){r+=`'${f}'`,l=n+2,n+=1;break}if(g==="function"){r+=f.name?`[Function: ${f.name}]`:"[Function: <anonymous>]",l=n+2,n+=1;break}r+=a(f),l=n+2,n+=1;break}case p:{l<n&&(r+=e.slice(l,n)),r+="%",l=n+2,n+=1,i-=1;break}case C:{if(i>=t.length)break;l<n&&(r+=e.slice(l,n));const f=t[i];r+=typeof f=="object"&&f!==null?a(f):String(f),l=n+2,n+=1;break}default:typeof o.formatters?.[s]=="function"?(l<n&&(r+=e.slice(l,n)),r+=o.formatters[s](t[i]),l=n+2,n+=1):i-=1}i+=1}n+=1}if(l===-1&&!(o.appendExtraArguments&&i<t.length))return e;if(l===-1?r=e:l<e.length&&(r+=e.slice(l)),l!==-1&&d&&(r+="\x1B[0m"),o.appendExtraArguments&&i<t.length)for(let n=Math.max(i,0);n<t.length;n+=1){const s=t[n];r+=` ${typeof s=="object"&&s!==null?a(s):String(s)}`}return r},W=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([a,c])=>{if(a.length===0)throw new Error(`Formatter %${a} has no characters`);if(a.length>1)throw new Error(`Formatter %${a} has more than one character`);if(typeof c!="function")throw new TypeError(`Formatter for %${a} is not a function`);const r=a.codePointAt(0);if(r===void 0)throw new Error(`${a}.codePointAt(0) failed to return a value, please report this issue`);t[r]=c});const o=Object.freeze({formatters:t});return(a,c=[],r)=>r===void 0?w(a,c,o):w(a,c,{...r,formatters:t})};export{W as O,O as g,w as y};
@@ -0,0 +1,16 @@
1
+ type Replacer = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null | object);
2
+ declare function stringify(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer, space?: string | number): undefined;
3
+ declare function stringify(value: string | number | unknown[] | null | boolean | object, replacer?: Replacer, space?: string | number): string;
4
+ declare function stringify(value: unknown, replacer?: ((key: string, value: unknown) => unknown) | (number | string)[] | null | undefined, space?: string | number): string | undefined;
5
+ declare namespace stringify {
6
+ export function configure(options: StringifyOptions): typeof stringify;
7
+ }
8
+ interface StringifyOptions {
9
+ bigint?: boolean;
10
+ circularValue?: string | null | TypeErrorConstructor | ErrorConstructor;
11
+ deterministic?: boolean | ((a: string, b: string) => number);
12
+ maximumBreadth?: number;
13
+ maximumDepth?: number;
14
+ strict?: boolean;
15
+ }
16
+ export { stringify as s };
@@ -0,0 +1 @@
1
+ const p=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}}),y=e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},f=new WeakSet,s=e=>{const r=Object.getOwnPropertyNames(e);for(const a of r){const t=Object.getOwnPropertyDescriptor(e,a);t&&(t.enumerable||Object.defineProperty(e,a,{...t,enumerable:!0}),t.value&&typeof t.value=="object"&&!Array.isArray(t.value)&&(Object.getPrototypeOf(t.value)===Object.prototype||Object.getPrototypeOf(t.value)===null)&&s(t.value))}},m=e=>{f.add(e);const r=e.toJSON();return f.delete(e),Object.isExtensible(r)&&s(r),r},c=(e,r,a,t,u=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.has(e)?"[Circular]":(a+=1,l(e,t,r,a));if(t.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const o=[];for(const[n,i]of e.entries())o.push([c(n,r,a,t,u),c(i,r,a,t,u)]);return{__dataType:"Map",value:o}}if(e instanceof Set){const o=[];for(const n of e.values())o.push(c(n,r,a,t,u));return{__dataType:"Set",value:o}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(y(e)){if(u.has(e))return"[Circular]";if(t.maxDepth!==void 0&&t.maxDepth!==Number.POSITIVE_INFINITY&&a+1>=t.maxDepth)return{};a+=1,u.add(e);const o={};for(const n in e)o[n]=c(e[n],r,a,t,u);return u.delete(e),o}try{return e}catch{return"[Not Available]"}},l=(e,r,a,t)=>{if(a.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!f.has(e))return m(e);const u=Object.create(p);if(Object.defineProperty(u,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(u,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(u,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const n=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(a.has(i))return Object.defineProperty(u,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),u;n.push(l(i,r,a,t))}Object.defineProperty(u,"errors",{configurable:!0,enumerable:!0,value:n,writable:!0})}const o=e.cause;if(o!=null)if(o instanceof Error)a.has(o)?Object.defineProperty(u,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(u,"cause",{configurable:!0,enumerable:!0,value:l(o,r,a,t),writable:!0});else{const n=c(o,a,t,r);Object.defineProperty(u,"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 i=e[n],b=c(i,a,t,r);Object.defineProperty(u,n,{configurable:!0,enumerable:!0,value:b,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const n of r.exclude)try{delete u[n]}catch{}return u},O=(e,r={})=>l(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0);export{O};
@@ -1,41 +1,6 @@
1
1
  import { AnsiColors } from '@visulima/colorize';
2
2
  import { InteractiveManager } from '@visulima/interactive-manager';
3
- /**
4
- Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
5
-
6
- @category Type
7
- */
8
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
9
- /**
10
- 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.
11
-
12
- 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.
13
-
14
- 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.
15
-
16
- @example
17
- ```
18
- import type {LiteralUnion} from 'type-fest';
19
-
20
- // Before
21
-
22
- type Pet = 'dog' | 'cat' | string;
23
-
24
- const petWithoutAutocomplete: Pet = '';
25
- // Start typing in your TypeScript-enabled IDE.
26
- // You **will not** get auto-completion for `dog` and `cat` literals.
27
-
28
- // After
29
-
30
- type Pet2 = LiteralUnion<'dog' | 'cat', string>;
31
-
32
- const petWithAutoComplete: Pet2 = '';
33
- // You **will** get auto-completion for `dog` and `cat` literals.
34
- ```
35
-
36
- @category Type
37
- */
38
- type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
3
+ import { Primitive, LiteralUnion } from 'type-fest';
39
4
  /**
40
5
  * Global namespace for extending Pail's metadata interface.
41
6
  *
@@ -243,4 +208,4 @@ type Message = {
243
208
  prefix?: string;
244
209
  suffix?: string;
245
210
  };
246
- export { ConstructorOptions as C, DefaultLogTypes as D, ExtendedRfc5424LogLevels as E, InteractiveStreamReporter as I, LiteralUnion as L, Meta as M, Processor as P, ReadonlyMeta as R, StreamAwareReporter as S, StringifyAwareReporter as a, StringifyAwareProcessor as b, LoggerTypesConfig as c, Reporter as d, LoggerFunction as e, LoggerTypesAwareReporter as f };
211
+ export { ConstructorOptions as C, DefaultLogTypes as D, ExtendedRfc5424LogLevels as E, InteractiveStreamReporter as I, LoggerFunction as L, Meta as M, Processor as P, ReadonlyMeta as R, StringifyAwareReporter as S, StreamAwareReporter as a, StringifyAwareProcessor as b, LoggerTypesConfig as c, Reporter as d, LoggerTypesAwareReporter as e };
@@ -1,5 +1,6 @@
1
- import { stringify } from 'safe-stable-stringify';
2
- import { M as Meta, D as DefaultLogTypes, L as LiteralUnion, c as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, d as Reporter, e as LoggerFunction, C as ConstructorOptions } from "./types.d-Ck_RSjLg.js";
1
+ import { s as stringify } from "./index.d-T71KjNAr.js";
2
+ import { LiteralUnion } from 'type-fest';
3
+ import { M as Meta, D as DefaultLogTypes, c as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, d as Reporter, L as LoggerFunction, C as ConstructorOptions } from "./types.d-bWnqHJKL.js";
3
4
  /**
4
5
  * Pail Browser Implementation.
5
6
  *
@@ -25,9 +26,6 @@ import { M as Meta, D as DefaultLogTypes, L as LiteralUnion, c as LoggerTypesCon
25
26
  */
26
27
  declare class PailBrowserImpl<T extends string = string, L extends string = string> {
27
28
  #private;
28
- protected timersMap: Map<string, number>;
29
- protected countMap: Map<string, number>;
30
- protected seqTimers: Set<string>;
31
29
  protected readonly lastLog: {
32
30
  count?: number;
33
31
  object?: Meta<L>;
@@ -116,6 +114,20 @@ declare class PailBrowserImpl<T extends string = string, L extends string = stri
116
114
  */
117
115
  wrapException(): void;
118
116
  /**
117
+ * Removes the global exception/rejection handlers installed by {@link wrapException}.
118
+ *
119
+ * Counterpart to `wrapException()` (mirrors `wrapConsole()`/`restoreConsole()`).
120
+ * Safe to call when no handlers are installed.
121
+ * @example
122
+ * ```typescript
123
+ * const logger = createPail();
124
+ * logger.wrapException();
125
+ * // ... later ...
126
+ * logger.restoreException(); // global handlers removed
127
+ * ```
128
+ */
129
+ restoreException(): void;
130
+ /**
119
131
  * Disables all logging output.
120
132
  *
121
133
  * When disabled, all log calls will be silently ignored and no output
@@ -0,0 +1 @@
1
+ const o=new Set(["alert","critical","emergency","error"]),n=r=>{const e=console;return o.has(r)?e.__error??console.error:r==="warning"?e.__warn??console.warn:r==="trace"?e.__trace??console.trace:e.__log??console.log};export{n as t};
@@ -0,0 +1 @@
1
+ const a=new Set(["alert","critical","emergency","error","trace","warning"]),e=t=>a.has(t),c=(t,r)=>(r.__write??r.write.bind(r)).call(r,t);export{c as a,e as r};
@@ -1,6 +1,7 @@
1
- import { M as Meta, P as Processor } from "../../packem_shared/types.d-Ck_RSjLg.js";
1
+ import { M as Meta, P as Processor } from "../../packem_shared/types.d-bWnqHJKL.js";
2
2
  import '@visulima/colorize';
3
3
  import '@visulima/interactive-manager';
4
+ import 'type-fest';
4
5
  /**
5
6
  * Global namespace extension for caller file metadata.
6
7
  *
@@ -1,6 +1,7 @@
1
- import { M as Meta, P as Processor } from "../packem_shared/types.d-Ck_RSjLg.js";
1
+ import { M as Meta, P as Processor } from "../packem_shared/types.d-bWnqHJKL.js";
2
2
  import '@visulima/colorize';
3
3
  import '@visulima/interactive-manager';
4
+ import 'type-fest';
4
5
  /**
5
6
  * Detected environment information.
6
7
  *
@@ -1,8 +1,16 @@
1
- import { M as Meta, b as StringifyAwareProcessor } from "../packem_shared/types.d-Ck_RSjLg.js";
1
+ import { M as Meta, b as StringifyAwareProcessor } from "../packem_shared/types.d-bWnqHJKL.js";
2
2
  import '@visulima/colorize';
3
3
  import '@visulima/interactive-manager';
4
+ import 'type-fest';
5
+ /**
6
+ * A custom specifier formatter: receives the matched argument and returns its string form.
7
+ */
4
8
  type FormatterFunction = (argument: any) => string;
5
9
  /**
10
+ * Internal map of custom formatters keyed by the specifier character's codepoint, as produced by
11
+ * {@link build}.
12
+ */
13
+ /**
6
14
  * Message Formatter Processor.
7
15
  *
8
16
  * A processor that formats log messages using the {@link https://visulima.com/packages/fmt/|@visulima/fmt} library.
@@ -1 +1 @@
1
- var $=Object.defineProperty,B=(e,t)=>$(e,"name",{value:t,configurable:!0}),v=Object.defineProperty,g=B((e,t)=>v(e,"name",{value:t,configurable:!0}),"g$1");const x=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"]]),A=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,S=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,D=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,C=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,y=g(()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),"getDefaultCss"),p=/\s+/,m=g(e=>{x.has(e)&&(e=x.get(e));const t=A.exec(e);if(t)return[Number.parseInt(t[1],16),Number.parseInt(t[2],16),Number.parseInt(t[3],16)];const r=S.exec(e);if(r)return[Number.parseInt(`${r[1]}${r[1]}`,16),Number.parseInt(`${r[2]}${r[2]}`,16),Number.parseInt(`${r[3]}${r[3]}`,16)];const i=D.exec(e);if(i)return[Math.round(Math.max(0,Math.min(255,Number(i[1])))),Math.round(Math.max(0,Math.min(255,Number(i[2])))),Math.round(Math.max(0,Math.min(255,Number(i[3]))))];const l=C.exec(e);if(l){let a=Number(l[1])%360;a<0&&(a+=360);const f=Math.max(0,Math.min(100,Number(l[2])))/100,n=Math.max(0,Math.min(100,Number(l[3])))/100,c=(1-Math.abs(2*n-1))*f,u=c*(1-Math.abs(a/60%2-1)),o=n-c/2;let d,s,b;return a<60?{0:d,1:s,2:b}=[c,u,0]:a<120?{0:d,1:s,2:b}=[u,c,0]:a<180?{0:d,1:s,2:b}=[0,c,u]:a<240?{0:d,1:s,2:b}=[0,u,c]:a<300?{0:d,1:s,2:b}=[u,0,c]:{0:d,1:s,2:b}=[c,0,u],[Math.round((d+o)*255),Math.round((s+o)*255),Math.round((b+o)*255)]}return null},"parseCssColor"),h=g((e,t)=>e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],"colorEquals"),N=g(e=>{if(typeof e!="string")return y();const t=y(),r=[];let i=!1,l=null,a=0,f="";for(const n of e){if(n==="(")a+=1;else if(a>0)n===")"&&(a-=1);else if(i){if(n===";"){const c=f.trim();c!==""&&r.push([l,c]),l=null,f="",i=!1;continue}}else if(n===":"){l=f.trim(),f="",i=!0;continue}f+=n}if(i&&a===0){const n=f.trim();n!==""&&r.push([l,n]),l=null,f=""}for(const{0:n,1:c}of r)switch(n){case"background-color":{c!=null&&(t.backgroundColor=c);break}case"color":{c!=null&&(t.color=c);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(c)&&(t.fontStyle="italic");break}case"font-weight":{c==="bold"&&(t.fontWeight=c);break}case"text-decoration":{t.textDecorationColor=null,t.textDecorationLine=[];const u=c.split(p);for(const o of u){const d=m(o);d!=null?t.textDecorationColor=d:["line-through","overline","underline"].includes(o)&&t.textDecorationLine.push(o)}break}case"text-decoration-color":{const u=m(c);u!=null&&(t.textDecorationColor=u);break}case"text-decoration-line":{t.textDecorationLine=[];const u=c.split(p);for(const o of u)["line-through","overline","underline"].includes(o)&&t.textDecorationLine.push(o);break}}return t},"parseCss"),M=g((e,t)=>{t=t??y();let r="";if(!h(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:i,1:l,2:a}=e.backgroundColor;r+=`\x1B[48;2;${String(i)};${String(l)};${String(a)}m`}else{const i=m(e.backgroundColor);if(i===null)r+="\x1B[49m";else{const{0:l,1:a,2:f}=i;r+=`\x1B[48;2;${String(l)};${String(a)};${String(f)}m`}}}if(!h(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:i,1:l,2:a}=e.color;r+=`\x1B[38;2;${String(i)};${String(l)};${String(a)}m`}else{const i=m(e.color);if(i===null)r+="\x1B[39m";else{const{0:l,1:a,2:f}=i;r+=`\x1B[38;2;${String(l)};${String(a)};${String(f)}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"),!h(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)r+="\x1B[59m";else{const{0:i,1:l,2:a}=e.textDecorationColor;r+=`\x1B[58;2;${String(i)};${String(l)};${String(a)}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},"cssToAnsi");var P=Object.defineProperty,k=B((e,t)=>P(e,"name",{value:t,configurable:!0}),"u");const j=k(e=>{try{return JSON.stringify(e)}catch{return'"[Circular]"'}},"tryStringify"),w="%".codePointAt(0),L="s".codePointAt(0),F="d".codePointAt(0),q="f".codePointAt(0),O="i".codePointAt(0),E="O".codePointAt(0),I="o".codePointAt(0),W="j".codePointAt(0),T="c".codePointAt(0),_=k((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 i=r.stringify??j,l=1;if(typeof e=="object"){const o=t.length+l;if(o===1)return"{}";const d=Array.from({length:o});d[0]=i(e);for(let s=1;s<o;s+=1)d[s]=i(t[s-l]);return d.join(" ")}if(t.length===0)return e;let a="",f=1-l,n=-1,c=!1,u;for(let o=0;o<e.length;){if(e.codePointAt(o)===w&&o+1<e.length){n=n>-1?n:0;const d=e.codePointAt(o+1);if(d===void 0){f+=1;break}switch(d){case T:{if(globalThis.window===void 0){const s=N(t[f]);n<o&&(a+=e.slice(n,o));const b=M(s,u);a+=b,b!==""&&(c=!0,u=s)}n=o+2,o+=1;break}case F:case q:{if(f>=t.length||t[f]==null)break;n<o&&(a+=e.slice(n,o));const s=t[f];a+=(typeof s=="symbol"?Number.NaN:Number(s)).toString(),n=o+2,o+=1;break}case O:{if(f>=t.length||t[f]==null)break;n<o&&(a+=e.slice(n,o));const s=t[f];a+=Math.floor(typeof s=="symbol"?Number.NaN:Number(s)).toString(),n=o+2,o+=1;break}case W:case E:case I:{if(f>=t.length||t[f]===void 0)break;n<o&&(a+=e.slice(n,o));const s=t[f],b=typeof s;if(b==="string"){a+=`'${s}'`,n=o+2,o+=1;break}if(b==="function"){a+=s.name?`[Function: ${s.name}]`:"[Function: <anonymous>]",n=o+2,o+=1;break}a+=i(s),n=o+2,o+=1;break}case w:{n<o&&(a+=e.slice(n,o)),a+="%",n=o+2,o+=1,f-=1;break}case L:{if(f>=t.length)break;n<o&&(a+=e.slice(n,o)),a+=typeof t[f]=="object"?i(t[f]):String(t[f]),n=o+2,o+=1;break}default:typeof r.formatters?.[d]=="function"&&(n<o&&(a+=e.slice(n,o)),a+=r.formatters[d](t[f]),n=o+2,o+=1)}f+=1}o+=1}return n===-1?e:(n<e.length&&(a+=e.slice(n)),c&&(a+="\x1B[0m"),a)},"format"),J=k((e={})=>{const t={};return typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([r,i])=>{if(r.length===0)throw new Error(`Formatter %${r} has no characters`);if(r.length>1)throw new Error(`Formatter %${r} has more than one character`);if(typeof i!="function")throw new TypeError(`Formatter for %${r} is not a function`);const l=r.codePointAt(0);if(l===void 0)throw new Error(`${r}.codePointAt(0) failed to return a value, please report this issue`);t[l]=i}),(r,i=[],l={})=>_(r,i,{...l,formatters:t})},"build");class z{#e;#r;#t;constructor(t={}){this.#r=t.formatters}setStringify(t){this.#e=t}process(t){this.#t===void 0&&(this.#t=J({formatters:this.#r,stringify:i=>this.#e?this.#e(i):JSON.stringify(i)}));const r=this.#t;return t.message!==void 0&&(t.message=this.#o(r,t.message,t.context??[])),t}#o(t,r,i=[]){if(typeof r=="string")return t(r,i);if(typeof r=="object"&&r!==null){const l=r,a=Object.keys(l);for(let f=0;f<a.length;f+=1){const n=a[f],c=l[n];(typeof c=="string"||Array.isArray(c)||typeof c=="object")&&(l[n]=this.#o(t,c,i))}}return r}}export{z 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,v=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,S=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,y=()=>({__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 o=$.exec(e);if(o)return[Number.parseInt(o[1],16),Number.parseInt(o[2],16),Number.parseInt(o[3],16)];const i=A.exec(e);if(i)return[Number.parseInt(`${i[1]}${i[1]}`,16),Number.parseInt(`${i[2]}${i[2]}`,16),Number.parseInt(`${i[3]}${i[3]}`,16)];const f=v.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=S.exec(e);if(n){let l=Number(n[1])%360;l<0&&(l+=360);const a=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))*a,b=u*(1-Math.abs(l/60%2-1)),r=s-u/2;let d,c,g;return l<60?{0:d,1:c,2:g}=[u,b,0]:l<120?{0:d,1:c,2:g}=[b,u,0]:l<180?{0:d,1:c,2:g}=[0,u,b]:l<240?{0:d,1:c,2:g}=[0,b,u]:l<300?{0:d,1:c,2:g}=[b,0,u]:{0:d,1:c,2:g}=[u,0,b],[Math.round((d+r)*255),Math.round((c+r)*255),Math.round((g+r)*255)]}return null},k=(e,t)=>e?.[0]===t?.[0]&&e?.[1]===t?.[1]&&e?.[2]===t?.[2],D=e=>{if(typeof e!="string")return y();const t=y(),o=[];let i=!1,f=null,n=0,l="";for(const a of e){if(a==="(")n+=1;else if(n>0)a===")"&&(n-=1);else if(i){if(a===";"){const s=l.trim();s!==""&&o.push([f,s]),f=null,l="",i=!1;continue}}else if(a===":"){f=l.trim(),l="",i=!0;continue}l+=a}if(i&&n===0){const a=l.trim();a!==""&&o.push([f,a]),f=null,l=""}for(const{0:a,1:s}of o)switch(a){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 r=m(b);r!=null?t.textDecorationColor=r:["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},M=(e,t)=>{t=t??y();let o="";if(!k(e.backgroundColor,t.backgroundColor))if(e.backgroundColor==null)o+="\x1B[49m";else switch(e.backgroundColor){case"black":{o+="\x1B[40m";break}case"blue":{o+="\x1B[44m";break}case"cyan":{o+="\x1B[46m";break}case"green":{o+="\x1B[42m";break}case"magenta":{o+="\x1B[45m";break}case"red":{o+="\x1B[41m";break}case"white":{o+="\x1B[47m";break}case"yellow":{o+="\x1B[43m";break}default:if(Array.isArray(e.backgroundColor)){const{0:i,1:f,2:n}=e.backgroundColor;o+=`\x1B[48;2;${String(i)};${String(f)};${String(n)}m`}else{const i=m(e.backgroundColor);if(i===null)o+="\x1B[49m";else{const{0:f,1:n,2:l}=i;o+=`\x1B[48;2;${String(f)};${String(n)};${String(l)}m`}}}if(!k(e.color,t.color))if(e.color==null)o+="\x1B[39m";else switch(e.color){case"black":{o+="\x1B[30m";break}case"blue":{o+="\x1B[34m";break}case"cyan":{o+="\x1B[36m";break}case"green":{o+="\x1B[32m";break}case"magenta":{o+="\x1B[35m";break}case"red":{o+="\x1B[31m";break}case"white":{o+="\x1B[37m";break}case"yellow":{o+="\x1B[33m";break}default:if(Array.isArray(e.color)){const{0:i,1:f,2:n}=e.color;o+=`\x1B[38;2;${String(i)};${String(f)};${String(n)}m`}else{const i=m(e.color);if(i===null)o+="\x1B[39m";else{const{0:f,1:n,2:l}=i;o+=`\x1B[38;2;${String(f)};${String(n)};${String(l)}m`}}}if(e.fontWeight!==t.fontWeight&&(o+=e.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),e.fontStyle!==t.fontStyle&&(o+=e.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!k(e.textDecorationColor,t.textDecorationColor))if(e.textDecorationColor==null)o+="\x1B[59m";else{const{0:i,1:f,2:n}=e.textDecorationColor;o+=`\x1B[58;2;${String(i)};${String(f)};${String(n)}m`}return e.textDecorationLine.includes("line-through")!==t.textDecorationLine.includes("line-through")&&(o+=e.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),e.textDecorationLine.includes("overline")!==t.textDecorationLine.includes("overline")&&(o+=e.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),e.textDecorationLine.includes("underline")!==t.textDecorationLine.includes("underline")&&(o+=e.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),o},N=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),I="c".codePointAt(0),w=(e,t=[],o={})=>{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 i=o.stringify??N,f=1;if(typeof e=="object"){const r=t.length+f;if(r===1)return"{}";const d=Array.from({length:r});d[0]=i(e);for(let c=1;c<r;c+=1)d[c]=i(t[c-f]);return d.join(" ")}if(t.length===0)return e;let n="",l=1-f,a=-1,s=!1,u;const b=o.colors??globalThis.window===void 0;for(let r=0;r<e.length;){if(e.codePointAt(r)===p&&r+1<e.length){a=a>-1?a:0;const d=e.codePointAt(r+1);switch(d){case I:{if(b){const c=D(t[l]);a<r&&(n+=e.slice(a,r));const g=M(c,u);n+=g,g!==""&&(s=!0,u=c)}a=r+2,r+=1;break}case j:case L:{const c=t[l];if(l>=t.length||c==null)break;a<r&&(n+=e.slice(a,r)),n+=(typeof c=="symbol"?Number.NaN:Number(c)).toString(),a=r+2,r+=1;break}case F:{const c=t[l];if(l>=t.length||c==null)break;a<r&&(n+=e.slice(a,r)),n+=Math.floor(typeof c=="symbol"?Number.NaN:Number(c)).toString(),a=r+2,r+=1;break}case E:case P:case q:{if(l>=t.length||t[l]===void 0)break;a<r&&(n+=e.slice(a,r));const c=t[l],g=typeof c;if(g==="string"){n+=`'${c}'`,a=r+2,r+=1;break}if(g==="function"){n+=c.name?`[Function: ${c.name}]`:"[Function: <anonymous>]",a=r+2,r+=1;break}n+=i(c),a=r+2,r+=1;break}case p:{a<r&&(n+=e.slice(a,r)),n+="%",a=r+2,r+=1,l-=1;break}case C:{if(l>=t.length)break;a<r&&(n+=e.slice(a,r));const c=t[l];n+=typeof c=="object"&&c!==null?i(c):String(c),a=r+2,r+=1;break}default:typeof o.formatters?.[d]=="function"?(a<r&&(n+=e.slice(a,r)),n+=o.formatters[d](t[l]),a=r+2,r+=1):l-=1}l+=1}r+=1}if(a===-1&&!(o.appendExtraArguments&&l<t.length))return e;if(a===-1?n=e:a<e.length&&(n+=e.slice(a)),a!==-1&&s&&(n+="\x1B[0m"),o.appendExtraArguments&&l<t.length)for(let r=Math.max(l,0);r<t.length;r+=1){const d=t[r];n+=` ${typeof d=="object"&&d!==null?i(d):String(d)}`}return n},O=(e={})=>{const t={};typeof e.formatters=="object"&&Object.entries(e.formatters).forEach(([i,f])=>{if(i.length===0)throw new Error(`Formatter %${i} has no characters`);if(i.length>1)throw new Error(`Formatter %${i} has more than one character`);if(typeof f!="function")throw new TypeError(`Formatter for %${i} is not a function`);const n=i.codePointAt(0);if(n===void 0)throw new Error(`${i}.codePointAt(0) failed to return a value, please report this issue`);t[n]=f});const o=Object.freeze({formatters:t});return(i,f=[],n)=>n===void 0?w(i,f,o):w(i,f,{...n,formatters:t})};class W{#r;#t;#e;constructor(t={}){this.#t=t.formatters}setStringify(t){this.#r=t}process(t){this.#e===void 0&&(this.#e=O({formatters:this.#t}));const o=this.#e;return t.message!==void 0&&(t.message=this.#o(o,t.message,t.context??[])),t}#o(t,o,i=[]){if(typeof o=="string")return t(o,i);if(typeof o=="object"&&o!==null){const f=o,n=Object.keys(f);for(let l=0;l<n.length;l+=1){const a=n[l],s=f[a];(typeof s=="string"||Array.isArray(s)||typeof s=="object")&&(f[a]=this.#o(t,s,i))}}return o}}export{W as default};
@@ -1,6 +1,7 @@
1
- import { M as Meta, P as Processor } from "../packem_shared/types.d-Ck_RSjLg.js";
1
+ import { M as Meta, P as Processor } from "../packem_shared/types.d-bWnqHJKL.js";
2
2
  import '@visulima/colorize';
3
3
  import '@visulima/interactive-manager';
4
+ import 'type-fest';
4
5
  /**
5
6
  * Configuration options for the OpenTelemetry processor.
6
7
  */
@@ -1,15 +1,47 @@
1
- import { M as Meta, P as Processor } from "../packem_shared/types.d-Ck_RSjLg.js";
1
+ import { M as Meta, P as Processor } from "../packem_shared/types.d-bWnqHJKL.js";
2
2
  import '@visulima/colorize';
3
3
  import '@visulima/interactive-manager';
4
+ import 'type-fest';
5
+ /**
6
+ * A censor function receives the original value being redacted plus the dot-path
7
+ * identifier of where it was found, and returns the value to store in its place.
8
+ *
9
+ * Use it for partial masking — e.g. keep the last four digits of a card number, or
10
+ * mask the local part of an email — instead of a static replacement string.
11
+ * @example
12
+ * ```ts
13
+ * const keepLast4: Censor = (value) =>
14
+ * typeof value === "string" ? "****" + value.slice(-4) : value;
15
+ * ```
16
+ * @param value The original value matched by the rule.
17
+ * @param path The dot-path of the matched key (e.g. `user.card`), or `undefined`
18
+ * for matches that have no key path (string-anonymizer / array-index matches).
19
+ */
20
+ type Censor = (value: unknown, path: string | undefined) => unknown;
4
21
  type StringAnonymize = {
5
22
  key: string;
6
23
  pattern: RegExp | string;
7
- replacement?: string;
24
+ replacement?: Censor | string;
8
25
  };
9
26
  type Anonymize = {
27
+ /**
28
+ * When `true`, the rule is also applied to nested string values (NLP / regex based),
29
+ * not just to matching object keys.
30
+ */
10
31
  deep?: boolean;
32
+ /** The key (or wildcard pattern, or NLP type) to match. Case-insensitive. */
11
33
  key: string;
34
+ /** Optional regular expression matched against nested string values. */
12
35
  pattern?: RegExp | string;
36
+ /**
37
+ * When `true`, the matching key is deleted from the output object instead of being
38
+ * replaced with `replacement`. Ignored for array elements and string-anonymizer matches.
39
+ */
40
+ remove?: boolean;
41
+ /**
42
+ * The value (or {@link Censor} function) to put in place of a match. Defaults to
43
+ * the `&lt;KEY&gt;` placeholder when omitted.
44
+ */
13
45
  replacement?: unknown;
14
46
  };
15
47
  type Rules = (Anonymize | StringAnonymize | number | string)[];
@@ -20,6 +52,13 @@ type RedactOptions = {
20
52
  };
21
53
  };
22
54
  /**
55
+ * Credential / secret rules: API keys, AWS keys, bearer/JWT/Slack tokens, crypto wallets,
56
+ * basic-auth strings, and the broad key-name rules (`auth`, `password`, `secret`, ...).
57
+ *
58
+ * These are the safest default rules — they target high-entropy or unambiguous shapes — and are
59
+ * what most logger-scrubbing use cases need.
60
+ */
61
+ /**
23
62
  * Redact Processor.
24
63
  *
25
64
  * A processor that redacts sensitive information from log messages and metadata.
@@ -1,6 +1,7 @@
1
- import { M as Meta, P as Processor } from "../packem_shared/types.d-Ck_RSjLg.js";
1
+ import { M as Meta, P as Processor } from "../packem_shared/types.d-bWnqHJKL.js";
2
2
  import '@visulima/colorize';
3
3
  import '@visulima/interactive-manager';
4
+ import 'type-fest';
4
5
  /**
5
6
  * Head sampling configuration.
6
7
  *
@@ -1,7 +1,8 @@
1
1
  import { Options } from 'rotating-file-stream';
2
- import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-Boj5w068.js";
3
- import 'safe-stable-stringify';
4
- import "../../packem_shared/types.d-Ck_RSjLg.js";
2
+ import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
3
+ import "../../packem_shared/index.d-T71KjNAr.js";
4
+ import 'type-fest';
5
+ import "../../packem_shared/types.d-bWnqHJKL.js";
5
6
  import '@visulima/colorize';
6
7
  import '@visulima/interactive-manager';
7
8
  /**
@@ -86,6 +87,23 @@ declare class JsonFileReporter<L extends string = string> extends AbstractJsonRe
86
87
  */
87
88
  constructor(options: FileReporterOptions);
88
89
  /**
90
+ * Closes the underlying rotating file stream.
91
+ *
92
+ * Ends the buffered stream so any queued writes are flushed to disk before the
93
+ * process exits. Without this the tail of the log can be lost on a short-lived
94
+ * process. After calling `close()` no further writes should be made (unless
95
+ * `writeImmediately` was enabled, in which case each write owns its own stream).
96
+ * @example
97
+ * ```typescript
98
+ * process.on("beforeExit", () => reporter.close());
99
+ * ```
100
+ */
101
+ close(): void;
102
+ /**
103
+ * Alias for {@link close} to match common transport `dispose` conventions.
104
+ */
105
+ dispose(): void;
106
+ /**
89
107
  * Writes a JSON message to the rotating file stream.
90
108
  * @param message The JSON-formatted log message to write
91
109
  * @protected
@@ -1,2 +1,2 @@
1
- import{AbstractJsonReporter as a}from"../../packem_shared/AbstractJsonReporter-CF0KKdQS.js";class r{#t=!0;#s;#e;constructor(t,e){this.#s=t,this.#e=e,this.#s.on("error",s=>{throw s}),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;#r;#i;#h;constructor(t,e=!1,s={}){this.#t=t,this.#s=e,this.#r=s;try{this.#i=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.#i(this.#t,s),this.#h=new r(this.#e,this.#t))}write(t){if(this.#s){const e=this.#i(this.#t,this.#r),s=new r(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,...h}=t;this.stream=new n(e,s,{compress:"gzip",interval:"1d",size:"10M",...h})}_log(t){this.stream.write(`${t}
1
+ import{AbstractJsonReporter as a}from"../../packem_shared/AbstractJsonReporter-C6iu_u9-.js";class r{#t=!0;#s;#e;constructor(t,e){this.#s=t,this.#e=e,this.#s.on("error",s=>{throw s}),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 o{#t;#s;#e;#r;#i;#h;constructor(t,e=!1,s={}){this.#t=t,this.#s=e,this.#r=s;try{this.#i=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.#i(this.#t,s),this.#h=new r(this.#e,this.#t))}write(t){if(this.#s){const e=this.#i(this.#t,this.#r),s=new r(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,...h}=t;this.stream=new o(e,s,{compress:"gzip",interval:"1d",size:"10M",...h})}close(){this.stream.end()}dispose(){this.close()}_log(t){this.stream.write(`${t}
2
2
  `)}}export{c as JsonFileReporter};
@@ -1,8 +1,9 @@
1
- import { E as ExtendedRfc5424LogLevels, L as LiteralUnion, a as StringifyAwareReporter } from "../../packem_shared/types.d-Ck_RSjLg.js";
2
- import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-Boj5w068.js";
1
+ import { LiteralUnion } from 'type-fest';
2
+ import { E as ExtendedRfc5424LogLevels, S as StringifyAwareReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
3
+ import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
3
4
  import '@visulima/colorize';
4
5
  import '@visulima/interactive-manager';
5
- import 'safe-stable-stringify';
6
+ import "../../packem_shared/index.d-T71KjNAr.js";
6
7
  /**
7
8
  * Configuration options for the HTTP reporter.
8
9
  */
@@ -76,6 +77,13 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
76
77
  */
77
78
  maxPayloadSize?: number;
78
79
  /**
80
+ * Maximum number of entries to keep queued while the endpoint is unavailable.
81
+ * When the queue exceeds this limit, the oldest entries are dropped (drop-oldest)
82
+ * so a sustained outage cannot grow memory without bound.
83
+ * @default 10000
84
+ */
85
+ maxQueueSize?: number;
86
+ /**
79
87
  * Number of retry attempts before giving up
80
88
  * @default 3
81
89
  */
@@ -107,6 +115,11 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
107
115
  };
108
116
  }) => void;
109
117
  /**
118
+ * Optional callback invoked when queued log entries are dropped because the queue
119
+ * exceeded `maxQueueSize`. Receives the number of dropped entries.
120
+ */
121
+ onDrop?: (droppedCount: number) => void;
122
+ /**
110
123
  * Optional callback for error handling
111
124
  */
112
125
  onError?: (error: Error) => void;
@@ -142,12 +155,15 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
142
155
  * @template L - The log level type
143
156
  */
144
157
  declare abstract class AbstractHttpReporter<L extends string = string> extends AbstractJsonReporter<L> implements StringifyAwareReporter<L> {
158
+ #private;
145
159
  protected url: string;
146
160
  protected method: string;
147
161
  protected headers: Record<string, string> | (() => Record<string, string>);
148
162
  protected contentType: string;
149
163
  protected batchContentType: string;
150
164
  protected onError?: (error: Error) => void;
165
+ protected onDrop?: (droppedCount: number) => void;
166
+ protected maxQueueSize: number;
151
167
  protected onDebug?: (entry: Record<string, unknown>) => void;
152
168
  protected onDebugRequestResponse?: (requestResponse: {
153
169
  req: {
@@ -191,6 +207,33 @@ declare abstract class AbstractHttpReporter<L extends string = string> extends A
191
207
  */
192
208
  constructor(config: AbstractHttpReporterOptions);
193
209
  /**
210
+ * Flushes all queued log entries to the HTTP endpoint immediately.
211
+ *
212
+ * Returns a promise that resolves once the queue has been drained (or rejects
213
+ * if a batch send fails terminally). Use this before a serverless function or
214
+ * short-lived process exits so the tail of the batch is not lost.
215
+ * @example
216
+ * ```typescript
217
+ * await reporter.flush();
218
+ * ```
219
+ */
220
+ flush(): Promise<void>;
221
+ /**
222
+ * Flushes any remaining queued entries and clears pending timers.
223
+ *
224
+ * Counterpart to a transport lifecycle `end`/`dispose`. After calling `close()`
225
+ * the reporter can still be used, but any pending batch timeout is cleared.
226
+ * @example
227
+ * ```typescript
228
+ * process.on("beforeExit", () => reporter.close());
229
+ * ```
230
+ */
231
+ close(): Promise<void>;
232
+ /**
233
+ * Alias for {@link close} to match common transport `dispose` conventions.
234
+ */
235
+ dispose(): Promise<void>;
236
+ /**
194
237
  * Processes and ships log entries to the HTTP endpoint.
195
238
  * @param message The JSON-formatted log message
196
239
  * @param logLevel The log level of the message
@@ -1,2 +1,2 @@
1
- import{createRequire as S}from"node:module";import{AbstractJsonReporter as w}from"../../packem_shared/AbstractJsonReporter-CF0KKdQS.js";const T=S(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=i=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,e]=m.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return m.getBuiltinModule(i)}return T(i)},{Buffer:p}=f("node:buffer"),{gzipSync:x}=f("node:zlib"),z=async i=>{const t=globalThis.CompressionStream;if(t){const e=new t("gzip"),s=e.writable.getWriter(),a=e.readable.getReader(),o=new TextEncoder,h=[];await s.write(o.encode(i)),await s.close();let u=!1;for(;!u;){const n=await a.read();u=n.done,n.value&&h.push(n.value)}const c=h.reduce((n,l)=>n+l.length,0),r=new Uint8Array(c);let d=0;for(let n=0;n<h.length;n+=1){const l=h[n];r.set(l,d),d+=l.length}return r}return x(i)};class E extends Error{logData;actualSize;maxSize;constructor(t,e,s,a){super(t),this.name="LogSizeError",this.logData=e,this.actualSize=s,this.maxSize=a}}const b=(i,t)=>i*2**t,y=i=>new Promise(t=>{setTimeout(t,i)}),B=i=>typeof i=="string"?i:new Uint8Array(i.buffer,i.byteOffset,i.byteLength),D=async(i,t,e,s,a,o,h)=>{const u={};i.headers.forEach((d,n)=>{u[n]=d});const c=await i.text(),r={req:{body:a,headers:s,method:e,url:t},res:{body:c,headers:u,status:i.status,statusText:i.statusText}};if(o&&o(r),i.ok)return!1;if(i.status<500&&i.status!==429){const d=new Error(`HTTP ${String(i.status)}: ${i.statusText}`);throw h&&h(d),d}return!0},R=(i,t,e,s,a)=>{if(i.status===429&&t&&s<a){const o=i.headers.get("retry-after");return o?Number.parseInt(o,10)*1e3:b(e,s)}},L=(i,t,e,s)=>{if(i.status>=500&&e<s)return b(t,e)},P=(i,t,e,s,a)=>{const o=R(i,t,e,s,a);return o!==void 0?o:L(i,e,s,a)},N=async(i,t,e,s,a)=>{if(t<e){const o=b(s,t);return await y(o),!0}return a&&a(i),!1},_=async(i,t,e,s,a,o,h,u,c)=>{let r=0;for(;r<=a;)try{const d=B(s),n=await fetch(i,{body:d,headers:e,method:t});if(!await D(n,i,t,e,s,u,c))return;const l=P(n,h,o,r,a);if(l!==void 0){await y(l),r+=1;continue}if(!n.ok){const g=new Error(`HTTP ${String(n.status)}: ${n.statusText}`);throw c&&c(g),g}return}catch(d){if(await N(d,r,a,o,c)){r+=1;continue}throw d}};class Q extends w{url;method;headers;contentType;batchContentType;onError;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(t){if(super(t),this.url=t.url,this.method=t.method??"POST",this.headers=t.headers??{},this.contentType=t.contentType??"application/json",this.batchContentType=t.batchContentType??"application/json",this.onError=t.onError,this.onDebug=t.onDebug,this.onDebugRequestResponse=t.onDebugRequestResponse,this.payloadTemplate=t.payloadTemplate??(e=>JSON.stringify(e)),this.compression=t.compression??!1,this.maxRetries=t.maxRetries??3,this.retryDelay=t.retryDelay??1e3,this.respectRateLimit=t.respectRateLimit??!0,this.enableBatchSend=t.enableBatchSend??!0,this.batchSize=t.batchSize??100,this.batchSendTimeout=t.batchSendTimeout??5e3,this.batchSendDelimiter=t.batchSendDelimiter??`
2
- `,this.batchMode=t.batchMode??"delimiter",this.batchFieldName=t.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=t.maxLogSize??1048576,this.maxPayloadSize=t.maxPayloadSize??5242880,this.edgeCompat=t.edgeCompat??!1}_log(t,e){try{const s=JSON.parse(t),a=e,o=s.message,h={logLevel:a,message:o??""};if(s.data)h.data=s.data;else if(s.context)h.data=s.context;else{const r={...s};delete r.message,Object.keys(r).length>0&&(h.data=r)}const u=this.payloadTemplate(h);this.onDebug&&this.onDebug({data:h.data,logLevel:a,message:o});const c=this.edgeCompat||typeof TextEncoder>"u"?p.byteLength(u,"utf8"):new TextEncoder().encode(u).length;if(c>this.maxLogSize){const r=new E(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(c)} bytes`,{data:h.data,logLevel:a,message:o},c,this.maxLogSize);this.onError&&this.onError(r);return}this.enableBatchSend?this.addToBatch(u,c):this.sendPayload(u).catch(r=>{this.onError&&this.onError(r)})}catch(s){this.onError&&this.onError(s)}}addToBatch(t,e){const s=this.currentBatchSize+e+this.batchSendDelimiter.length,a=this.maxPayloadSize*.9;s>a&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.currentBatchSize+=e+this.batchSendDelimiter.length,this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const t=this.batchQueue.splice(0,this.batchSize);this.currentBatchSize=0;for(let e=0;e<this.batchQueue.length;e+=1){const s=this.batchQueue[e],a=this.edgeCompat||typeof TextEncoder>"u"?p.byteLength(s,"utf8"):new TextEncoder().encode(s).length;this.currentBatchSize+=a+(e<this.batchQueue.length-1?this.batchSendDelimiter.length:0)}try{await this.sendBatch(t)}catch(e){this.onError&&this.onError(e)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let e;switch(this.batchMode){case"array":{const s=t.map(a=>JSON.parse(a));e=JSON.stringify(s);break}case"field":{const s=t.map(o=>JSON.parse(o)),a=this.batchFieldName?{[this.batchFieldName]:s}:{};e=JSON.stringify(a);break}default:{e=t.join(this.batchSendDelimiter);break}}await this.sendPayload(e,this.batchContentType)}async sendPayload(t,e){const s=typeof this.headers=="function"?this.headers():{...this.headers};s["content-type"]??=e??this.contentType;let a=t;if(this.compression&&!this.edgeCompat)try{a=await z(t),s["content-encoding"]="gzip"}catch(o){this.onError&&this.onError(new Error(`Compression failed: ${String(o)}`))}await _(this.url,this.method,s,a,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}export{Q as AbstractHttpReporter};
1
+ import{createRequire as S}from"node:module";import{AbstractJsonReporter as w}from"../../packem_shared/AbstractJsonReporter-C6iu_u9-.js";const T=S(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=i=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,e]=m.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return m.getBuiltinModule(i)}return T(i)},{Buffer:g}=f("node:buffer"),{gzipSync:x}=f("node:zlib"),z=async i=>{const t=globalThis.CompressionStream;if(t){const e=new t("gzip"),s=e.writable.getWriter(),a=e.readable.getReader(),o=new TextEncoder,n=[];await s.write(o.encode(i)),await s.close();let u=!1;for(;!u;){const h=await a.read();u=h.done,h.value&&n.push(h.value)}const c=n.reduce((h,d)=>h+d.length,0),r=new Uint8Array(c);let l=0;for(let h=0;h<n.length;h+=1){const d=n[h];r.set(d,l),l+=d.length}return r}return x(i)};class D extends Error{logData;actualSize;maxSize;constructor(t,e,s,a){super(t),this.name="LogSizeError",this.logData=e,this.actualSize=s,this.maxSize=a}}const b=(i,t)=>i*2**t,B=/^\d+$/,E=i=>{const t=i.trim();if(B.test(t)){const a=Number.parseInt(t,10);return Math.min(Math.max(a,0)*1e3,6e4)}const e=Date.parse(t);if(Number.isNaN(e))return;const s=e-Date.now();return Math.min(Math.max(s,0),6e4)},y=i=>new Promise(t=>{setTimeout(t,i)}),R=i=>typeof i=="string"?i:new Uint8Array(i.buffer,i.byteOffset,i.byteLength),P=async(i,t,e,s,a,o,n)=>{const u={};i.headers.forEach((l,h)=>{u[h]=l});const c=await i.text(),r={req:{body:a,headers:s,method:e,url:t},res:{body:c,headers:u,status:i.status,statusText:i.statusText}};if(o&&o(r),i.ok)return!1;if(i.status<500&&i.status!==429){const l=new Error(`HTTP ${String(i.status)}: ${i.statusText}`);throw n&&n(l),l}return!0},Q=(i,t,e,s,a)=>{if(i.status===429&&t&&s<a){const o=i.headers.get("retry-after");return(o?E(o):void 0)??b(e,s)}},L=(i,t,e,s)=>{if(i.status>=500&&e<s)return b(t,e)},N=(i,t,e,s,a)=>{const o=Q(i,t,e,s,a);return o!==void 0?o:L(i,e,s,a)},v=async(i,t,e,s,a)=>{if(t<e){const o=b(s,t);return await y(o),!0}return a&&a(i),!1},_=async(i,t,e,s,a,o,n,u,c)=>{let r=0;for(;r<=a;)try{const l=R(s),h=await fetch(i,{body:l,headers:e,method:t});if(!await P(h,i,t,e,s,u,c))return;const d=N(h,n,o,r,a);if(d!==void 0){await y(d),r+=1;continue}if(!h.ok){const p=new Error(`HTTP ${String(h.status)}: ${h.statusText}`);throw c&&c(p),p}return}catch(l){if(await v(l,r,a,o,c)){r+=1;continue}throw l}};class $ extends w{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(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??(e=>JSON.stringify(e)),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,e){try{const s=JSON.parse(t),a=e,o=s.message,n={logLevel:a,message:o??""};if(s.data)n.data=s.data;else if(s.context)n.data=s.context;else{const r={...s};delete r.message,Object.keys(r).length>0&&(n.data=r)}const u=this.payloadTemplate(n);this.onDebug&&this.onDebug({data:n.data,logLevel:a,message:o});const c=this.edgeCompat||typeof TextEncoder>"u"?g.byteLength(u,"utf8"):new TextEncoder().encode(u).length;if(c>this.maxLogSize){const r=new D(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(c)} bytes`,{data:n.data,logLevel:a,message:o},c,this.maxLogSize);this.onError&&this.onError(r);return}this.enableBatchSend?this.addToBatch(u,c):this.sendPayload(u).catch(r=>{this.onError&&this.onError(r)})}catch(s){this.onError&&this.onError(s)}}addToBatch(t,e){const s=this.currentBatchSize+e+this.batchSendDelimiter.length,a=this.maxPayloadSize*.9;if(s>a&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.currentBatchSize+=e+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const o=this.batchQueue.splice(0,this.batchQueue.length-this.maxQueueSize);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 e=0;e<this.batchQueue.length;e+=1){const s=this.batchQueue[e],a=this.edgeCompat||typeof TextEncoder>"u"?g.byteLength(s,"utf8"):new TextEncoder().encode(s).length;t+=a+(e<this.batchQueue.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.currentBatchSize=this.#t();try{await this.sendBatch(t)}catch(e){this.onError&&this.onError(e)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let e;switch(this.batchMode){case"array":{const s=t.map(a=>JSON.parse(a));e=JSON.stringify(s);break}case"field":{const s=t.map(o=>JSON.parse(o)),a=this.batchFieldName?{[this.batchFieldName]:s}:{};e=JSON.stringify(a);break}default:{e=t.join(this.batchSendDelimiter);break}}await this.sendPayload(e,this.batchContentType)}async sendPayload(t,e){const s=typeof this.headers=="function"?this.headers():{...this.headers};s["content-type"]??=e??this.contentType;let a=t;if(this.compression&&!this.edgeCompat)try{a=await z(t),s["content-encoding"]="gzip"}catch(o){this.onError&&this.onError(new Error(`Compression failed: ${String(o)}`))}await _(this.url,this.method,s,a,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}export{$ as AbstractHttpReporter};