@visulima/error-handler 2.0.0-alpha.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +463 -0
- package/LICENSE.md +701 -136
- package/README.md +38 -23
- package/dist/error-handler/fetch-utils.d.ts +3 -0
- package/dist/error-handler/fetch-utils.js +1 -0
- package/dist/error-handler/html-error-handler.d.ts +54 -12
- package/dist/error-handler/html-error-handler.js +50 -10
- package/dist/error-handler/json-error-handler.d.ts +13 -12
- package/dist/error-handler/json-error-handler.js +1 -1
- package/dist/error-handler/jsonapi-error-handler.d.ts +3 -2
- package/dist/error-handler/jsonapi-error-handler.js +1 -1
- package/dist/error-handler/jsonp-error-handler.d.ts +14 -13
- package/dist/error-handler/jsonp-error-handler.js +1 -1
- package/dist/error-handler/problem-error-handler.d.ts +6 -5
- package/dist/error-handler/problem-error-handler.js +1 -1
- package/dist/error-handler/text-error-handler.d.ts +12 -11
- package/dist/error-handler/text-error-handler.js +2 -2
- package/dist/error-handler/xml-error-handler.d.ts +24 -23
- package/dist/error-handler/xml-error-handler.js +1 -1
- package/dist/handler/cli-handler.d.ts +27 -4
- package/dist/handler/cli-handler.js +2 -2
- package/dist/handler/http/create-error-middleware.d.ts +31 -0
- package/dist/handler/http/create-error-middleware.js +1 -0
- package/dist/handler/http/fetch-handler.d.ts +9 -7
- package/dist/handler/http/fetch-handler.js +1 -1
- package/dist/handler/http/node-handler.d.ts +9 -8
- package/dist/handler/http/node-handler.js +1 -1
- package/dist/index.d.ts +20 -14
- package/dist/index.js +1 -1
- package/dist/packem_shared/add-status-code-to-response-DwELM1q2.js +1 -0
- package/dist/packem_shared/cliHandler-BGq-ckC0.js +35 -0
- package/dist/packem_shared/createNegotiatedErrorHandler-CcWOSpO5.js +1 -0
- package/dist/packem_shared/extractStatusCode-D0UOgNnr.js +1 -0
- package/dist/packem_shared/fetchCreateNegotiatedErrorHandler-D9YQ8pOH.js +1 -0
- package/dist/packem_shared/fetchHtmlErrorHandler-Cu50Zu5a.js +1 -0
- package/dist/packem_shared/get-file-source-By3_8e1o.js +1 -0
- package/dist/packem_shared/send-json-fz8r6NBW.js +1 -0
- package/dist/packem_shared/sendFetchJson-BNmfrMYp.js +1 -0
- package/dist/packem_shared/set-error-headers-g9hns3cZ.js +1 -0
- package/dist/packem_shared/types.d-Btzbxdod.d.ts +13 -0
- package/package.json +35 -30
- package/dist/error-handler/create-negotiated-error-handler.d.ts +0 -4
- package/dist/error-handler/fetch-create-negotiated-error-handler.d.ts +0 -3
- package/dist/error-handler/fetch-html-error-handler.d.ts +0 -3
- package/dist/error-handler/utils/add-status-code-to-response.d.ts +0 -2
- package/dist/error-handler/utils/send-json.d.ts +0 -8
- package/dist/error-handler/utils/set-error-headers.d.ts +0 -3
- package/dist/packem_shared/add-status-code-to-response-BE6paXjR.js +0 -1
- package/dist/packem_shared/cliHandler-CeQ8tsGj.js +0 -1
- package/dist/packem_shared/createNegotiatedErrorHandler-BLks0_Ak.js +0 -1
- package/dist/packem_shared/send-json-Cedv8-Bt.js +0 -1
- package/dist/packem_shared/set-error-headers-DT9rVGtW.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Accepts as d}from"@tinyhttp/accepts";import{jsonErrorHandler as b}from"../error-handler/json-error-handler.js";import{jsonpErrorHandler as y}from"../error-handler/jsonp-error-handler.js";import n from"../error-handler/problem-error-handler.js";import{textErrorHandler as h}from"../error-handler/text-error-handler.js";const w=y(),k=b(),v=h();let c,l;const E=async()=>(c??=import("../error-handler/jsonapi-error-handler.js").then(a=>a.default),c),u=async()=>(l??=import("../error-handler/xml-error-handler.js").then(a=>a.xmlErrorHandler()),l),H=async(a,p,e)=>{const o=Object.hasOwn(a,"expose"),r=a.expose;p?"expose"in a||(a.expose=!0):a.expose=!1;try{await e()}finally{o?a.expose=r:delete a.expose}},q=(a,p,e)=>async(o,r,x)=>{const s=new d(r).type(["text/html","application/vnd.api+json","application/problem+json","application/json","text/plain","application/javascript","text/javascript","application/xml","text/xml"]);let t=e??n;if(s==="text/html"&&e)t=e;else switch(s){case"application/javascript":case"text/javascript":{t=w;break}case"application/json":{t=k;break}case"application/problem+json":{t=n;break}case"application/vnd.api+json":{t=await E();break}case"application/xml":case"text/xml":{t=await u();break}case"text/plain":{t=v;break}}for(const{handler:m,regex:j}of a){const i=r.headers.accept??"",f=Array.isArray(i)?i.join(","):i;if(j.test(f)){t=m;break}}await H(o,p,()=>t(o,r,x))};export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{StatusCodes as s}from"http-status-codes";const u=(e,r=s.INTERNAL_SERVER_ERROR)=>{if(!e)return r;const t=Number(e.statusCode??e.status);return Number.isInteger(t)&&t>=400&&t<=599?t:r};export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsonErrorHandler as w}from"../error-handler/json-error-handler.js";import{jsonpErrorHandler as g}from"../error-handler/jsonp-error-handler.js";import H from"../error-handler/problem-error-handler.js";import{textErrorHandler as k}from"../error-handler/text-error-handler.js";class v{statusCode=200;headers={};responseBody="";setHeader(t,o){this.headers[t.toLowerCase()]=o}getHeader(t){return this.headers[t.toLowerCase()]}getHeaders(){return{...this.headers}}writeHead(t){this.statusCode=t}write(t){this.responseBody+=t.toString()}end(t){t&&(this.responseBody+=t.toString())}flushHeaders(){}}const C=[{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"]}],E=s=>{if(!s)return"text/html";const t=[];for(const r of s.split(",")){const[n,...e]=r.trim().split(";"),p=(n??"").trim().toLowerCase();if(p==="")continue;let i=1;for(const y of e){const[j,b]=y.trim().split("=");if((j??"").trim().toLowerCase()==="q"){const m=Number.parseFloat((b??"").trim());Number.isNaN(m)||(i=m)}}if(i<=0)continue;const[l="",d=""]=p.split("/");t.push({quality:i,subtype:d,type:l})}if(t.length===0)return"text/html";const o=r=>{const[n,e]=r.split("/");let p=-1;for(const{quality:i,subtype:l,type:d}of t)(d==="*"&&l==="*"||d===n&&l==="*"||d===n&&l===e)&&i>p&&(p=i);return p};let c="text/html",a=-1;for(const{chosen:r,types:n}of C){let e=-1;for(const p of n){const i=o(p);i>e&&(e=i)}e>a&&(a=e,c=r)}return a<0?"text/html":c},h=s=>async(t,o)=>{const c={headers:Object.fromEntries(o.headers.entries()),method:o.method,url:o.url},a=new v;await s(t,c,a);const r={};for(const[n,e]of Object.entries(a.headers))r[n]=Array.isArray(e)?e.join(", "):String(e);return new Response(a.responseBody,{headers:r,status:a.statusCode})},B=h(g()),q=h(w()),f=h(H),L=h(k());let u,x;const N=async()=>(u??=import("../error-handler/jsonapi-error-handler.js").then(s=>h(s.default)),u),O=async()=>(x??=import("../error-handler/xml-error-handler.js").then(s=>h(s.xmlErrorHandler())),x),S=async(s,t,o)=>{const c=Object.hasOwn(s,"expose"),a=s.expose;t?"expose"in s||(s.expose=!0):s.expose=!1;try{return await o()}finally{c?s.expose=a:delete s.expose}},T=(s,t,o)=>async(c,a)=>{const r=a.headers.get("accept"),n=E(r);let e=o??f;if(n==="text/html"&&o)e=o;else switch(n){case"application/javascript":{e=B;break}case"application/json":{e=q;break}case"application/problem+json":{e=f;break}case"application/vnd.api+json":{e=await N();break}case"application/xml":{e=await O();break}case"text/plain":{e=L;break}}for(const{handler:p,regex:i}of s){const l=r??"";if(i.test(l)){e=p;break}}return S(c,t,()=>e(c,a))};export{T as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{htmlErrorHandler as h}from"../error-handler/html-error-handler.js";class l{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,t){return this.headers[e.toLowerCase()]=t,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,t,s){this.statusCode=e;let r=s;return typeof t=="string"&&(this.statusMessage=t),typeof t=="object"&&(r=t),r&&Object.assign(this.headers,r),this}write(e){return this.body+=e.toString(),!0}end(e,t,s){return e&&(this.body+=e.toString()),this.finished=!0,this}flushHeaders(){this.headersSent=!0}addListener=()=>this;on=()=>this;once=()=>this;removeListener=()=>this;off=()=>this;removeAllListeners=()=>this;setMaxListeners=()=>this;getMaxListeners=()=>10;listeners=()=>[];rawListeners=()=>[];emit=()=>!1;eventNames=()=>[];listenerCount=()=>0;prependListener=()=>this;prependOnceListener=()=>this;cork=()=>{};uncork=()=>{};destroy=()=>this;read=()=>{};setEncoding=()=>this;pause=()=>this;resume=()=>this;isPaused=()=>!1;destroySoon=()=>this;pipe=()=>({});unpipe=()=>this;unshift=()=>{};wrap=()=>this;setTimeout=()=>this;assignSocket=()=>{};detachSocket=()=>{};writeContinue=()=>{};writeEarlyHints=()=>{}}const c=(n={})=>{const e=h(n);return async(t,s)=>{const r={headers:Object.fromEntries(s.headers.entries()),method:s.method,url:s.url},a=new l;await e(t,r,a);const d={"content-type":a.getHeader("content-type")??"text/html; charset=utf-8"};for(const[o,i]of Object.entries(a.headers))o!=="content-type"&&(d[o]=Array.isArray(i)?i.join(", "):String(i));return new Response(a.body,{headers:d,status:a.statusCode})}};export{c as default,c as fetchHtmlErrorHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as f}from"node:module";const p=f(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,o=e=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[s,n]=a.versions.node.split(".").map(Number);if(s>22||s===22&&n>=3||s===20&&n>=16)return a.getBuiltinModule(e)}return p(e)},{readFile:l}=o("node:fs/promises"),{isAbsolute:d}=o("node:path"),{fileURLToPath:h}=o("node:url"),m=new Set(["cjs","mjs"]),y=new Set(["cts","mts"]),j=new Set(["mdoc"]),g=e=>{const s=(e.split("?")[0]??e).split(".").pop()?.toLowerCase();if(!s)return"text";if(m.has(s))return"javascript";if(y.has(s))return"typescript";if(j.has(s))return"markdown";switch(s){case"js":return"javascript";case"json":return"json";case"json5":return"json5";case"jsonc":return"jsonc";case"jsx":return"jsx";case"sql":return"sql";case"ts":return"typescript";case"tsx":return"tsx";case"xml":return"xml";case"md":return"markdown";case"mdx":return"mdx";case"svelte":return"svelte";case"vue":return"vue";case"html":return"html";case"css":return"css";case"scss":return"scss";case"less":return"less";case"sass":return"sass";case"stylus":return"stylus";case"styl":return"styl";case"yaml":case"yml":return"yaml";case"toml":return"toml";case"py":return"python";case"go":return"go";case"rs":return"rust";case"rb":return"ruby";case"php":return"php";case"graphql":case"gql":return"graphql";case"dockerfile":return"dockerfile";case"sh":case"bash":return"bash";case"txt":return"text";default:return"text"}},x=50,t=new Map,v=e=>{const s=t.get(e);if(s!==void 0)return t.delete(e),t.set(e,s),s},c=(e,s)=>{if(t.has(e))t.delete(e);else if(t.size>=x){const n=t.keys().next().value;n!==void 0&&t.delete(n)}t.set(e,s)},_=async(e,s={})=>{const{allowRemote:n=!1}=s,u=v(e);if(u!==void 0)return u;if(e.startsWith("file:"))try{const r=await l(h(e),"utf8");return c(e,r),r}catch{return}if(/^(?:https?|data):/.test(e)){if(!n)return;try{const r=await fetch(e);if(!r.ok)return;const i=await r.text();return c(e,i),i}catch{return}}if(d(e))try{const r=await l(e,"utf8");return c(e,r),r}catch{return}};export{g as a,_ as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=(t,e,n="application/json; charset=utf-8")=>{t.setHeader("content-type",n),t.end(JSON.stringify(e))};export{o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a=(t,s,e="application/json; charset=utf-8")=>Response.json(t,{headers:{"content-type":e},status:s});export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=(r,s)=>{const e=s.headers??{};Object.keys(e).forEach(o=>{r.setHeader(o,e[o])})};export{t as o};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
type ErrorHandler = (error: Error, request: IncomingMessage, response: ServerResponse) => Promise<void> | void;
|
|
3
|
+
type FetchErrorHandler = (error: unknown, request: Request) => Promise<Response>;
|
|
4
|
+
type ErrorHandlers = {
|
|
5
|
+
handler: ErrorHandler;
|
|
6
|
+
regex: RegExp;
|
|
7
|
+
}[];
|
|
8
|
+
type FetchErrorHandlers = {
|
|
9
|
+
handler: FetchErrorHandler;
|
|
10
|
+
regex: RegExp;
|
|
11
|
+
}[];
|
|
12
|
+
type ApiFormat = "jsonapi" | "problem" | "html";
|
|
13
|
+
export { ApiFormat as A, ErrorHandler as E, FetchErrorHandlers as F, ErrorHandlers as a, FetchErrorHandler as b };
|
package/package.json
CHANGED
|
@@ -1,43 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/error-handler",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Error handlers for use in development and production environments.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"exception",
|
|
9
|
-
"error-handlers",
|
|
10
|
-
"diagnostics",
|
|
11
|
-
"debugging",
|
|
12
|
-
"stacktrace",
|
|
6
|
+
"anolilab",
|
|
7
|
+
"cli",
|
|
13
8
|
"code-frame",
|
|
14
9
|
"codeframe",
|
|
15
|
-
"
|
|
10
|
+
"connect",
|
|
16
11
|
"content-negotiation",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
12
|
+
"debugging",
|
|
13
|
+
"devtools",
|
|
14
|
+
"diagnostics",
|
|
15
|
+
"error",
|
|
16
|
+
"error-handler",
|
|
17
|
+
"error-handlers",
|
|
18
|
+
"error-reporting",
|
|
19
|
+
"exception",
|
|
20
|
+
"express",
|
|
21
|
+
"html-error",
|
|
22
|
+
"http-errors",
|
|
20
23
|
"json-api",
|
|
24
|
+
"jsonapi",
|
|
21
25
|
"jsonp",
|
|
22
|
-
"xml",
|
|
23
|
-
"html-error",
|
|
24
|
-
"cli",
|
|
25
|
-
"node",
|
|
26
|
-
"express",
|
|
27
|
-
"connect",
|
|
28
26
|
"middleware",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
27
|
+
"node",
|
|
28
|
+
"problem-json",
|
|
29
|
+
"rfc7807",
|
|
30
|
+
"source-code-preview",
|
|
31
|
+
"stacktrace",
|
|
32
|
+
"visulima",
|
|
32
33
|
"whoops",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"error-handler"
|
|
34
|
+
"xml",
|
|
35
|
+
"youch"
|
|
36
36
|
],
|
|
37
37
|
"homepage": "https://visulima.com/packages/error-handler",
|
|
38
|
-
"bugs":
|
|
39
|
-
"url": "https://github.com/visulima/visulima/issues"
|
|
40
|
-
},
|
|
38
|
+
"bugs": "https://github.com/visulima/visulima/issues",
|
|
41
39
|
"repository": {
|
|
42
40
|
"type": "git",
|
|
43
41
|
"url": "git+https://github.com/visulima/visulima.git",
|
|
@@ -73,6 +71,10 @@
|
|
|
73
71
|
"types": "./dist/handler/http/node-handler.d.ts",
|
|
74
72
|
"default": "./dist/handler/http/node-handler.js"
|
|
75
73
|
},
|
|
74
|
+
"./handler/middleware": {
|
|
75
|
+
"types": "./dist/handler/http/create-error-middleware.d.ts",
|
|
76
|
+
"default": "./dist/handler/http/create-error-middleware.js"
|
|
77
|
+
},
|
|
76
78
|
"./handler/http/hono": {
|
|
77
79
|
"types": "./dist/handler/http/fetch-handler.d.ts",
|
|
78
80
|
"default": "./dist/handler/http/fetch-handler.js"
|
|
@@ -125,6 +127,10 @@
|
|
|
125
127
|
"types": "./dist/error-handler/xml-error-handler.d.ts",
|
|
126
128
|
"default": "./dist/error-handler/xml-error-handler.js"
|
|
127
129
|
},
|
|
130
|
+
"./error-handler/fetch-utils": {
|
|
131
|
+
"types": "./dist/error-handler/fetch-utils.d.ts",
|
|
132
|
+
"default": "./dist/error-handler/fetch-utils.js"
|
|
133
|
+
},
|
|
128
134
|
"./package.json": "./package.json"
|
|
129
135
|
},
|
|
130
136
|
"files": [
|
|
@@ -134,15 +140,14 @@
|
|
|
134
140
|
],
|
|
135
141
|
"dependencies": {
|
|
136
142
|
"@tinyhttp/accepts": "^2.3.0",
|
|
137
|
-
"@visulima/
|
|
138
|
-
"@visulima/error": "6.0.0-alpha.5",
|
|
143
|
+
"@visulima/error": "6.0.0",
|
|
139
144
|
"http-errors": "^2.0.1",
|
|
140
145
|
"http-status-codes": "^2.3.0",
|
|
141
146
|
"jstoxml": "^7.1.0",
|
|
142
147
|
"ts-japi": "^1.12.3"
|
|
143
148
|
},
|
|
144
149
|
"engines": {
|
|
145
|
-
"node": "
|
|
150
|
+
"node": "^22.14.0 || >=24.10.0"
|
|
146
151
|
},
|
|
147
152
|
"publishConfig": {
|
|
148
153
|
"access": "public",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
import type { ErrorHandler, ErrorHandlers } from "./types.d.d.ts";
|
|
3
|
-
declare const createNegotiatedErrorHandler: <Request extends IncomingMessage, Response extends ServerResponse>(errorHandlers: ErrorHandlers, showTrace: boolean, defaultHtmlHandler?: ErrorHandler) => (error: Error, request: Request, response: Response) => Promise<void>;
|
|
4
|
-
export default createNegotiatedErrorHandler;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { FetchErrorHandlers } from "./types.d.d.ts";
|
|
2
|
-
declare const createFetchNegotiatedErrorHandler: (errorHandlers: FetchErrorHandlers, showTrace: boolean, defaultHtmlHandler?: (error: Error, request: Request) => Promise<Response>) => (error: Error, request: Request) => Promise<Response>;
|
|
3
|
-
export default createFetchNegotiatedErrorHandler;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ServerResponse } from "node:http";
|
|
2
|
-
/**
|
|
3
|
-
* Send `JSON` object
|
|
4
|
-
* @param response response object
|
|
5
|
-
* @param jsonBody of data
|
|
6
|
-
* @param contentType optional content-type header value
|
|
7
|
-
*/
|
|
8
|
-
export declare const sendJson: (response: ServerResponse, jsonBody: unknown, contentType?: string) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var r=Object.defineProperty;var o=(e,s)=>r(e,"name",{value:s,configurable:!0});import{StatusCodes as u}from"http-status-codes";var d=Object.defineProperty,n=o((e,s)=>d(e,"name",{value:s,configurable:!0}),"s");const i=n((e,s)=>{const a=s,t=Number(a.statusCode??a.status);if(Number.isInteger(t)&&t>=400&&t<=599){e.statusCode=t;return}e.statusCode<400&&(e.statusCode=u.INTERNAL_SERVER_ERROR)},"addStatusCodeToResponse");export{i as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var h=Object.defineProperty;var c=(e,r)=>h(e,"name",{value:r,configurable:!0});import{createRequire as y}from"node:module";import{parseStacktrace as v}from"@visulima/error/stacktrace";import{boxen as x}from"@visulima/boxen";import{renderError as w}from"@visulima/error/error";import{ruleBasedFinder as F,errorHintFinder as B}from"@visulima/error/solution";const b=y(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=c(e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[r,t]=u.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return u.getBuiltinModule(e)}return b(e)},"__cjs_getBuiltinModule"),{readFile:_}=p("node:fs/promises"),{fileURLToPath:O}=p("node:url");var T=Object.defineProperty,A=c((e,r)=>T(e,"name",{value:r,configurable:!0}),"r");const q=["cjs","mjs"],P=["mdoc"],S=A(e=>{const r=(e.split("?")[0]??e).split(".").pop()?.toLowerCase();if(!r||q.includes(r))return"javascript";if(P.includes(r))return"markdown";switch(r){case"js":case"cjs":case"mjs":return"javascript";case"json":return"json";case"json5":return"json5";case"jsonc":return"jsonc";case"jsx":return"jsx";case"sql":return"sql";case"ts":case"cts":case"mts":return"typescript";case"tsx":return"tsx";case"xml":return"xml";case"md":return"markdown";case"mdx":return"mdx";case"svelte":return"svelte";case"vue":return"vue";case"html":return"html";case"css":return"css";case"scss":return"scss";case"less":return"less";case"sass":return"sass";case"stylus":return"stylus";case"styl":return"styl";case"txt":return"text";default:return"javascript"}},"findLanguageBasedOnExtension");var k=Object.defineProperty,m=c((e,r)=>k(e,"name",{value:r,configurable:!0}),"o");const l=new Map,L=m(async e=>{if(/^(?:http|https|file|data):/.test(e)){if(l.has(e))return l.get(e);if(e.startsWith("file:"))try{const r=O(e),t=await _(r,"utf8");return l.set(e,t),t}catch{return}try{const r=await fetch(e);if(!r.ok)return;const t=await r.text();return l.set(e,t),t}catch{return}}},"getFileSource");m(()=>{l.clear()},"clearFileSourceCache");var C=Object.defineProperty,f=c((e,r)=>C(e,"name",{value:r,configurable:!0}),"d");const M=f(e=>e.replace(/^\s*#+\s*/,"").trim(),"sanitizeTitle"),R=f(async(e,r,t=!1)=>{const a=[...r,F,B],s=v(e,{frameLimit:1})[0]??{};for await(const o of a.sort((i,n)=>i.priority-n.priority)){const{handle:i}=o;if(typeof i!="function")continue;const n=await i(e,{file:s.file??"",language:S(s.file??""),line:s.line??0,snippet:s.file?await L(s.file):""});if(n)return n}},"runSolutionFinders"),$=f(async(e,r)=>{const{solutionFinders:t=[],solutionTitle:a,color:s,debug:o=!1,...i}=r,n=w(e,{...i,...s?.codeFrame}),d=await R(e,t,o);if(!d)return{errorAnsi:n,solutionBox:void 0};const g=M(d.header??a??"A possible solution to this error"),j=x(d.body,{borderStyle:"round",padding:{top:1,right:2,bottom:1,left:2},margin:{top:0,right:0,bottom:0,left:0},headerText:`💡 ${g}`,headerAlignment:"left",textAlignment:"left",...s?.boxen});return{errorAnsi:n,solutionBox:j}},"buildOutput"),D=f(async(e,r={})=>{const{logger:t=console,...a}=r,{errorAnsi:s,solutionBox:o}=await $(e,a);t.error(s),o&&(t.log(""),t.log(o))},"terminalOutput");export{$ as buildOutput,D as terminalOutput};
|
|
@@ -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 l 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 y=Object.defineProperty,H=c((r,e)=>y(r,"name",{value:e,configurable:!0}),"i");const q=H((r,e,t)=>async(p,o,s)=>{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||l;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=l;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=o.headers.accept??"",f=Array.isArray(i)?i.join(","):i;if(x.test(f)){a=m;break}}p.expose=e,await a(p,o,s)},"createNegotiatedErrorHandler");export{q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s=Object.defineProperty;var t=(e,n)=>s(e,"name",{value:n,configurable:!0});var a=Object.defineProperty,o=t((e,n)=>a(e,"name",{value:n,configurable:!0}),"t");const i=o((e,n,r="application/json; charset=utf-8")=>{e.setHeader("content-type",r),e.end(JSON.stringify(n))},"sendJson");export{i as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var c=Object.defineProperty;var o=(e,r)=>c(e,"name",{value:r,configurable:!0});var n=Object.defineProperty,s=o((e,r)=>n(e,"name",{value:r,configurable:!0}),"o");const b=s((e,r)=>{const a=r.headers??{};Object.keys(a).forEach(t=>{e.setHeader(t,a[t])})},"setErrorHeaders");export{b as a};
|