@visulima/error-handler 2.0.0-alpha.29 → 2.0.0-alpha.30

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## @visulima/error-handler [2.0.0-alpha.30](https://github.com/visulima/visulima/compare/@visulima/error-handler@2.0.0-alpha.29...@visulima/error-handler@2.0.0-alpha.30) (2026-06-04)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **error-handler:** 3 bug fixes ([550c3f1](https://github.com/visulima/visulima/commit/550c3f16fb702d01c24192c434ea190e83d2a21b))
6
+ * **lint:** clear pre-existing eslint rot across packages ([#674](https://github.com/visulima/visulima/issues/674)) ([5354253](https://github.com/visulima/visulima/commit/5354253b163bd50bcefaf8a3fddf831bdb5df32b))
7
+
8
+
9
+ ### Dependencies
10
+
11
+ * **@visulima/boxen:** upgraded to 3.0.0-alpha.12
12
+ * **@visulima/error:** upgraded to 6.0.0-alpha.32
13
+
1
14
  ## @visulima/error-handler [2.0.0-alpha.29](https://github.com/visulima/visulima/compare/@visulima/error-handler@2.0.0-alpha.28...@visulima/error-handler@2.0.0-alpha.29) (2026-06-02)
2
15
 
3
16
  ### Bug Fixes
@@ -1 +1 @@
1
- var f=Object.defineProperty;var l=(t,a)=>f(t,"name",{value:a,configurable:!0});import{getReasonPhrase as d}from"http-status-codes";import{p as u}from"../packem_shared/add-status-code-to-response-Dc6Pvpeh.js";import{a as h}from"../packem_shared/set-error-headers-DT9rVGtW.js";var g=Object.defineProperty,k=l((t,a)=>g(t,"name",{value:a,configurable:!0}),"c");const b="callback",$=k((t={})=>async(a,c,e)=>{u(e,a),h(e,a);const{statusCode:r}=e,s=d(r),n=new URL(c.url??"http://localhost","http://localhost"),p=t.callbackParamName??b,m=n.searchParams.get(p)??"callback";let o;if(t.formatter)o=await t.formatter({error:a,reasonPhrase:s,request:c,response:e,statusCode:r});else{const{expose:i}=a;o={message:a.message||s,error:s,statusCode:r,...i?{stack:a.stack}:{}}}e.setHeader("content-type","application/javascript; charset=utf-8"),e.end(`${m}(${JSON.stringify(o)});`)},"jsonpErrorHandler");export{$ as jsonpErrorHandler};
1
+ var h=Object.defineProperty;var p=(t,a)=>h(t,"name",{value:a,configurable:!0});import{getReasonPhrase as u}from"http-status-codes";import{p as d}from"../packem_shared/add-status-code-to-response-Dc6Pvpeh.js";import{a as g}from"../packem_shared/set-error-headers-DT9rVGtW.js";var $=Object.defineProperty,P=p((t,a)=>$(t,"name",{value:a,configurable:!0}),"c");const c="callback",y=P((t={})=>async(a,l,e)=>{d(e,a),g(e,a);const{statusCode:s}=e,o=u(s),i=new URL(l.url??"http://localhost","http://localhost"),m=t.callbackParamName??c;let r=i.searchParams.get(m)??c,n;if(t.formatter)n=await t.formatter({error:a,reasonPhrase:o,request:l,response:e,statusCode:s});else{const{expose:f}=a;n={message:a.message||o,error:o,statusCode:s,...f?{stack:a.stack}:{}}}(r.length>64||!/^[A-Za-z_$][\w$.]*$/u.test(r))&&(r=c),e.setHeader("content-type","application/javascript; charset=utf-8"),e.end(`${r}(${JSON.stringify(n)});`)},"jsonpErrorHandler");export{y as jsonpErrorHandler};
@@ -1 +1 @@
1
- var b=Object.defineProperty;var c=(r,e)=>b(r,"name",{value:e,configurable:!0});import{jsonErrorHandler as g}from"../../error-handler/json-error-handler.js";import w from"../../error-handler/jsonapi-error-handler.js";import{jsonpErrorHandler as v}from"../../error-handler/jsonp-error-handler.js";import p from"../../error-handler/problem-error-handler.js";import{textErrorHandler as y}from"../../error-handler/text-error-handler.js";import{xmlErrorHandler as H}from"../../error-handler/xml-error-handler.js";import{htmlErrorHandler as j}from"../../error-handler/html-error-handler.js";var x=Object.defineProperty,h=c((r,e)=>x(r,"name",{value:e,configurable:!0}),"i");class L{static{c(this,"x")}static{h(this,"MockServerResponse")}statusCode=200;headers={};responseBody="";setHeader(e,s){this.headers[e.toLowerCase()]=s}getHeader(e){return this.headers[e.toLowerCase()]}getHeaders(){return{...this.headers}}writeHead(e){this.statusCode=e}write(e){this.responseBody+=e.toString()}end(e){e&&(this.responseBody+=e.toString())}flushHeaders(){}}const k=h(r=>{if(!r)return"text/html";const e=r.toLowerCase();return e.includes("text/html")?"text/html":e.includes("application/vnd.api+json")?"application/vnd.api+json":e.includes("application/problem+json")?"application/problem+json":e.includes("application/json")?"application/json":e.includes("text/plain")?"text/plain":e.includes("application/javascript")||e.includes("text/javascript")?"application/javascript":e.includes("application/xml")||e.includes("text/xml")?"application/xml":"text/html"},"negotiateContentType"),d=h(r=>async(e,s)=>{const n={headers:Object.fromEntries(s.headers.entries()),method:s.method,url:s.url},a=new L;await r(e,n,a);const o={};for(const[l,i]of Object.entries(a.headers))o[l]=Array.isArray(i)?i.join(", "):String(i);return new Response(a.responseBody,{headers:o,status:a.statusCode})},"adaptErrorHandlerToFetch"),E=h((r,e,s)=>async(n,a)=>{const o=a.headers.get("accept"),l=k(o);let i=s??d(p);if(l==="text/html"&&s)i=s;else switch(l){case"application/javascript":{i=d(v());break}case"application/json":{i=d(g());break}case"application/problem+json":{i=d(p);break}case"application/vnd.api+json":{i=d(w);break}case"application/xml":{i=d(H());break}case"text/plain":{i=d(y());break}}for(const{handler:u,regex:m}of r){const f=o??"";if(m.test(f)){i=u;break}}return n.expose=e,i(n,a)},"createFetchNegotiatedErrorHandler");var C=Object.defineProperty,t=c((r,e)=>C(r,"name",{value:e,configurable:!0}),"e");class S{static{c(this,"d")}static{t(this,"MockServerResponse")}statusCode=200;statusMessage="";headers={};headersSent=!1;writable=!0;finished=!1;writableEnded=!1;writableFinished=!1;writableHighWaterMark=16384;writableLength=0;destroyed=!1;writableCorked=0;readable=!1;readableHighWaterMark=16384;readableLength=0;errored=void 0;closed=!1;readableAborted=!1;readableDidRead=!1;readableEncoding=void 0;readableEnded=!1;readableFlowing=void 0;body="";sendDate=!0;strictContentLength=!1;chunkedEncoding=!1;shouldKeepAlive=!0;useChunkedEncodingByDefault=!0;connection=void 0;socket=void 0;setHeader(e,s){return this.headers[e.toLowerCase()]=s,this}getHeader(e){return this.headers[e.toLowerCase()]}getHeaders(){return{...this.headers}}getHeaderNames(){return Object.keys(this.headers)}hasHeader(e){return e.toLowerCase()in this.headers}removeHeader(e){return delete this.headers[e.toLowerCase()],this}writeHead(e,s,n){this.statusCode=e;let a=n;return typeof s=="string"&&(this.statusMessage=s),typeof s=="object"&&(a=s),a&&Object.assign(this.headers,a),this}write(e){return this.body+=e.toString(),!0}end(e,s,n){return e&&(this.body+=e.toString()),this.finished=!0,this}flushHeaders(){this.headersSent=!0}addListener=t(()=>this,"addListener");on=t(()=>this,"on");once=t(()=>this,"once");removeListener=t(()=>this,"removeListener");off=t(()=>this,"off");removeAllListeners=t(()=>this,"removeAllListeners");setMaxListeners=t(()=>this,"setMaxListeners");getMaxListeners=t(()=>10,"getMaxListeners");listeners=t(()=>[],"listeners");rawListeners=t(()=>[],"rawListeners");emit=t(()=>!1,"emit");eventNames=t(()=>[],"eventNames");listenerCount=t(()=>0,"listenerCount");prependListener=t(()=>this,"prependListener");prependOnceListener=t(()=>this,"prependOnceListener");cork=t(()=>{},"cork");uncork=t(()=>{},"uncork");destroy=t(()=>this,"destroy");read=t(()=>{},"read");setEncoding=t(()=>this,"setEncoding");pause=t(()=>this,"pause");resume=t(()=>this,"resume");isPaused=t(()=>!1,"isPaused");destroySoon=t(()=>this,"destroySoon");pipe=t(()=>({}),"pipe");unpipe=t(()=>this,"unpipe");unshift=t(()=>{},"unshift");wrap=t(()=>this,"wrap");setTimeout=t(()=>this,"setTimeout");assignSocket=t(()=>{},"assignSocket");detachSocket=t(()=>{},"detachSocket");writeContinue=t(()=>{},"writeContinue");writeEarlyHints=t(()=>{},"writeEarlyHints")}const M=t((r={})=>{const e=j(r);return async(s,n)=>{const a={headers:Object.fromEntries(n.headers.entries()),method:n.method,url:n.url},o=new S;await e(s,a,o);const l=o.getHeader("content-type")??"text/html; charset=utf-8";return new Response(o.body,{headers:{"content-type":l,...o.headers},status:o.statusCode})}},"fetchHtmlErrorHandler");var O=Object.defineProperty,A=c((r,e)=>O(r,"name",{value:e,configurable:!0}),"t");const K=A((r,e={})=>{const s=M(e),n=E(e.extraHandlers??[],e.showTrace??!0,s);return async a=>(e.onError&&await e.onError(r,a),n(r,a))},"fetchHandler");export{K as default};
1
+ var w=Object.defineProperty;var h=(n,e)=>w(n,"name",{value:e,configurable:!0});import{jsonErrorHandler as v}from"../../error-handler/json-error-handler.js";import H from"../../error-handler/jsonapi-error-handler.js";import{jsonpErrorHandler as x}from"../../error-handler/jsonp-error-handler.js";import b from"../../error-handler/problem-error-handler.js";import{textErrorHandler as j}from"../../error-handler/text-error-handler.js";import{xmlErrorHandler as L}from"../../error-handler/xml-error-handler.js";import{htmlErrorHandler as k}from"../../error-handler/html-error-handler.js";var E=Object.defineProperty,p=h((n,e)=>E(n,"name",{value:e,configurable:!0}),"c");class C{static{h(this,"v")}static{p(this,"MockServerResponse")}statusCode=200;headers={};responseBody="";setHeader(e,s){this.headers[e.toLowerCase()]=s}getHeader(e){return this.headers[e.toLowerCase()]}getHeaders(){return{...this.headers}}writeHead(e){this.statusCode=e}write(e){this.responseBody+=e.toString()}end(e){e&&(this.responseBody+=e.toString())}flushHeaders(){}}const S=[{chosen:"text/html",types:["text/html"]},{chosen:"application/vnd.api+json",types:["application/vnd.api+json"]},{chosen:"application/problem+json",types:["application/problem+json"]},{chosen:"application/json",types:["application/json"]},{chosen:"text/plain",types:["text/plain"]},{chosen:"application/javascript",types:["application/javascript","text/javascript"]},{chosen:"application/xml",types:["application/xml","text/xml"]}],O=p(n=>{if(!n)return"text/html";const e=[];for(const o of n.split(",")){const[a,...i]=o.trim().split(";"),d=(a??"").trim().toLowerCase();if(d==="")continue;let r=1;for(const f of i){const[y,g]=f.trim().split("=");if((y??"").trim().toLowerCase()==="q"){const m=Number.parseFloat((g??"").trim());Number.isNaN(m)||(r=m)}}if(r<=0)continue;const[c="",u=""]=d.split("/");e.push({quality:r,subtype:u,type:c})}if(e.length===0)return"text/html";const s=p(o=>{const[a,i]=o.split("/");return e.some(({subtype:d,type:r})=>r==="*"&&d==="*"||r===a&&d==="*"?!0:r===a&&d===i)},"matches");for(const{chosen:o,types:a}of S)if(a.some(i=>s(i)))return o;return"text/html"},"negotiateContentType"),l=p(n=>async(e,s)=>{const o={headers:Object.fromEntries(s.headers.entries()),method:s.method,url:s.url},a=new C;await n(e,o,a);const i={};for(const[d,r]of Object.entries(a.headers))i[d]=Array.isArray(r)?r.join(", "):String(r);return new Response(a.responseBody,{headers:i,status:a.statusCode})},"adaptErrorHandlerToFetch"),M=p((n,e,s)=>async(o,a)=>{const i=a.headers.get("accept"),d=O(i);let r=s??l(b);if(d==="text/html"&&s)r=s;else switch(d){case"application/javascript":{r=l(x());break}case"application/json":{r=l(v());break}case"application/problem+json":{r=l(b);break}case"application/vnd.api+json":{r=l(H);break}case"application/xml":{r=l(L());break}case"text/plain":{r=l(j());break}}for(const{handler:c,regex:u}of n){const f=i??"";if(u.test(f)){r=c;break}}return e?"expose"in o||(o.expose=!0):o.expose=!1,r(o,a)},"createFetchNegotiatedErrorHandler");var A=Object.defineProperty,t=h((n,e)=>A(n,"name",{value:e,configurable:!0}),"e");class N{static{h(this,"b")}static{t(this,"MockServerResponse")}statusCode=200;statusMessage="";headers={};headersSent=!1;writable=!0;finished=!1;writableEnded=!1;writableFinished=!1;writableHighWaterMark=16384;writableLength=0;destroyed=!1;writableCorked=0;readable=!1;readableHighWaterMark=16384;readableLength=0;errored=void 0;closed=!1;readableAborted=!1;readableDidRead=!1;readableEncoding=void 0;readableEnded=!1;readableFlowing=void 0;body="";sendDate=!0;strictContentLength=!1;chunkedEncoding=!1;shouldKeepAlive=!0;useChunkedEncodingByDefault=!0;connection=void 0;socket=void 0;setHeader(e,s){return this.headers[e.toLowerCase()]=s,this}getHeader(e){return this.headers[e.toLowerCase()]}getHeaders(){return{...this.headers}}getHeaderNames(){return Object.keys(this.headers)}hasHeader(e){return e.toLowerCase()in this.headers}removeHeader(e){return delete this.headers[e.toLowerCase()],this}writeHead(e,s,o){this.statusCode=e;let a=o;return typeof s=="string"&&(this.statusMessage=s),typeof s=="object"&&(a=s),a&&Object.assign(this.headers,a),this}write(e){return this.body+=e.toString(),!0}end(e,s,o){return e&&(this.body+=e.toString()),this.finished=!0,this}flushHeaders(){this.headersSent=!0}addListener=t(()=>this,"addListener");on=t(()=>this,"on");once=t(()=>this,"once");removeListener=t(()=>this,"removeListener");off=t(()=>this,"off");removeAllListeners=t(()=>this,"removeAllListeners");setMaxListeners=t(()=>this,"setMaxListeners");getMaxListeners=t(()=>10,"getMaxListeners");listeners=t(()=>[],"listeners");rawListeners=t(()=>[],"rawListeners");emit=t(()=>!1,"emit");eventNames=t(()=>[],"eventNames");listenerCount=t(()=>0,"listenerCount");prependListener=t(()=>this,"prependListener");prependOnceListener=t(()=>this,"prependOnceListener");cork=t(()=>{},"cork");uncork=t(()=>{},"uncork");destroy=t(()=>this,"destroy");read=t(()=>{},"read");setEncoding=t(()=>this,"setEncoding");pause=t(()=>this,"pause");resume=t(()=>this,"resume");isPaused=t(()=>!1,"isPaused");destroySoon=t(()=>this,"destroySoon");pipe=t(()=>({}),"pipe");unpipe=t(()=>this,"unpipe");unshift=t(()=>{},"unshift");wrap=t(()=>this,"wrap");setTimeout=t(()=>this,"setTimeout");assignSocket=t(()=>{},"assignSocket");detachSocket=t(()=>{},"detachSocket");writeContinue=t(()=>{},"writeContinue");writeEarlyHints=t(()=>{},"writeEarlyHints")}const R=t((n={})=>{const e=k(n);return async(s,o)=>{const a={headers:Object.fromEntries(o.headers.entries()),method:o.method,url:o.url},i=new N;await e(s,a,i);const d={"content-type":i.getHeader("content-type")??"text/html; charset=utf-8"};for(const[r,c]of Object.entries(i.headers))r!=="content-type"&&(d[r]=Array.isArray(c)?c.join(", "):String(c));return new Response(i.body,{headers:d,status:i.statusCode})}},"fetchHtmlErrorHandler");var B=Object.defineProperty,F=h((n,e)=>B(n,"name",{value:e,configurable:!0}),"t");const G=F((n,e={})=>{const s=R(e),o=M(e.extraHandlers??[],e.showTrace??!0,s);return async a=>(e.onError&&await e.onError(n,a),o(n,a))},"fetchHandler");export{G as default};
@@ -1 +1 @@
1
- var i=Object.defineProperty;var o=(a,r)=>i(a,"name",{value:r,configurable:!0});import l from"../../packem_shared/createNegotiatedErrorHandler-b0kjXpZ3.js";import{htmlErrorHandler as s}from"../../error-handler/html-error-handler.js";var c=Object.defineProperty,m=o((a,r)=>c(a,"name",{value:r,configurable:!0}),"t");const v=m((a,r={})=>{const n=s(r),d=l(r.extraHandlers??[],r.showTrace??!0,n);return async(e,t)=>{r.onError&&await r.onError(a,e,t),await d(a,e,t)}},"nodeHandler");export{v as default};
1
+ var i=Object.defineProperty;var o=(a,r)=>i(a,"name",{value:r,configurable:!0});import l from"../../packem_shared/createNegotiatedErrorHandler-DlEHBPFw.js";import{htmlErrorHandler as s}from"../../error-handler/html-error-handler.js";var c=Object.defineProperty,m=o((a,r)=>c(a,"name",{value:r,configurable:!0}),"t");const v=m((a,r={})=>{const n=s(r),d=l(r.extraHandlers??[],r.showTrace??!0,n);return async(e,t)=>{r.onError&&await r.onError(a,e,t),await d(a,e,t)}},"nodeHandler");export{v as default};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{default as e}from"./packem_shared/createNegotiatedErrorHandler-b0kjXpZ3.js";import{htmlErrorHandler as t}from"./error-handler/html-error-handler.js";import{jsonErrorHandler as d}from"./error-handler/json-error-handler.js";import{default as m}from"./error-handler/jsonapi-error-handler.js";import{jsonpErrorHandler as p}from"./error-handler/jsonp-error-handler.js";import{default as E}from"./error-handler/problem-error-handler.js";import{textErrorHandler as s}from"./error-handler/text-error-handler.js";import{xmlErrorHandler as u}from"./error-handler/xml-error-handler.js";export{e as createNegotiatedErrorHandler,t as htmlErrorHandler,d as jsonErrorHandler,m as jsonapiErrorHandler,p as jsonpErrorHandler,E as problemErrorHandler,s as textErrorHandler,u as xmlErrorHandler};
1
+ import{default as e}from"./packem_shared/createNegotiatedErrorHandler-DlEHBPFw.js";import{htmlErrorHandler as t}from"./error-handler/html-error-handler.js";import{jsonErrorHandler as d}from"./error-handler/json-error-handler.js";import{default as m}from"./error-handler/jsonapi-error-handler.js";import{jsonpErrorHandler as p}from"./error-handler/jsonp-error-handler.js";import{default as E}from"./error-handler/problem-error-handler.js";import{textErrorHandler as s}from"./error-handler/text-error-handler.js";import{xmlErrorHandler as u}from"./error-handler/xml-error-handler.js";export{e as createNegotiatedErrorHandler,t as htmlErrorHandler,d as jsonErrorHandler,m as jsonapiErrorHandler,p as jsonpErrorHandler,E as problemErrorHandler,s as textErrorHandler,u as xmlErrorHandler};
@@ -0,0 +1 @@
1
+ var j=Object.defineProperty;var n=(r,e)=>j(r,"name",{value:e,configurable:!0});import{Accepts as d}from"@tinyhttp/accepts";import{jsonErrorHandler as b}from"../error-handler/json-error-handler.js";import v from"../error-handler/jsonapi-error-handler.js";import{jsonpErrorHandler as k}from"../error-handler/jsonp-error-handler.js";import c from"../error-handler/problem-error-handler.js";import{textErrorHandler as E}from"../error-handler/text-error-handler.js";import{xmlErrorHandler as h}from"../error-handler/xml-error-handler.js";var g=Object.defineProperty,u=n((r,e)=>g(r,"name",{value:e,configurable:!0}),"i");const q=u((r,e,o)=>async(t,p,l)=>{const s=new d(p).type(["text/html","application/vnd.api+json","application/problem+json","application/json","text/plain","application/javascript","text/javascript","application/xml","text/xml"]);let a=o??c;if(s==="text/html"&&o)a=o;else switch(s){case"application/javascript":case"text/javascript":{a=k();break}case"application/json":{a=b();break}case"application/problem+json":{a=c;break}case"application/vnd.api+json":{a=v;break}case"application/xml":case"text/xml":{a=h();break}case"text/plain":{a=E();break}}for(const{handler:m,regex:x}of r){const i=p.headers.accept??"",f=Array.isArray(i)?i.join(","):i;if(x.test(f)){a=m;break}}e?"expose"in t||(t.expose=!0):t.expose=!1,await a(t,p,l)},"createNegotiatedErrorHandler");export{q as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/error-handler",
3
- "version": "2.0.0-alpha.29",
3
+ "version": "2.0.0-alpha.30",
4
4
  "description": "Error handlers for use in development and production environments.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -132,8 +132,8 @@
132
132
  ],
133
133
  "dependencies": {
134
134
  "@tinyhttp/accepts": "^2.3.0",
135
- "@visulima/boxen": "3.0.0-alpha.11",
136
- "@visulima/error": "6.0.0-alpha.31",
135
+ "@visulima/boxen": "3.0.0-alpha.12",
136
+ "@visulima/error": "6.0.0-alpha.32",
137
137
  "http-errors": "^2.0.1",
138
138
  "http-status-codes": "^2.3.0",
139
139
  "jstoxml": "^7.1.0",
@@ -1 +0,0 @@
1
- var j=Object.defineProperty;var c=(r,e)=>j(r,"name",{value:e,configurable:!0});import{Accepts as d}from"@tinyhttp/accepts";import{jsonErrorHandler as b}from"../error-handler/json-error-handler.js";import v from"../error-handler/jsonapi-error-handler.js";import{jsonpErrorHandler as k}from"../error-handler/jsonp-error-handler.js";import s from"../error-handler/problem-error-handler.js";import{textErrorHandler as E}from"../error-handler/text-error-handler.js";import{xmlErrorHandler as g}from"../error-handler/xml-error-handler.js";var h=Object.defineProperty,y=c((r,e)=>h(r,"name",{value:e,configurable:!0}),"i");const q=y((r,e,t)=>async(p,o,l)=>{const n=new d(o).type(["text/html","application/vnd.api+json","application/problem+json","application/json","text/plain","application/javascript","text/javascript","application/xml","text/xml"]);let a=t??s;if(n==="text/html"&&t)a=t;else switch(n){case"application/javascript":case"text/javascript":{a=k();break}case"application/json":{a=b();break}case"application/problem+json":{a=s;break}case"application/vnd.api+json":{a=v;break}case"application/xml":case"text/xml":{a=g();break}case"text/plain":{a=E();break}}for(const{handler:m,regex:x}of r){const i=o.headers.accept??"",f=Array.isArray(i)?i.join(","):i;if(x.test(f)){a=m;break}}p.expose=e,await a(p,o,l)},"createNegotiatedErrorHandler");export{q as default};