@visulima/error-handler 1.0.4 → 1.0.5

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,10 @@
1
+ ## @visulima/error-handler [1.0.5](https://github.com/visulima/visulima/compare/@visulima/error-handler@1.0.4...@visulima/error-handler@1.0.5) (2025-09-23)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/error:** upgraded to 4.6.2
7
+
1
8
  ## @visulima/error-handler [1.0.4](https://github.com/visulima/visulima/compare/@visulima/error-handler@1.0.3...@visulima/error-handler@1.0.4) (2025-09-20)
2
9
 
3
10
  ### Bug Fixes
@@ -1,3 +1,3 @@
1
- var o=Object.defineProperty;var a=(r,e)=>o(r,"name",{value:e,configurable:!0});import{buildOutput as i}from"../packem_shared/cliHandler-B3-YFZRV.js";import{terminalOutput as f}from"../packem_shared/cliHandler-B3-YFZRV.js";var u=Object.defineProperty,l=a((r,e)=>u(r,"name",{value:e,configurable:!0}),"o");const d=l(async(r,e={})=>{const{errorAnsi:t,solutionBox:n}=await i(r,e);return n===void 0?t:`${t}
1
+ var o=Object.defineProperty;var a=(r,e)=>o(r,"name",{value:e,configurable:!0});import{buildOutput as i}from"../packem_shared/cliHandler-CFffArNH.js";import{terminalOutput as f}from"../packem_shared/cliHandler-CFffArNH.js";var u=Object.defineProperty,l=a((r,e)=>u(r,"name",{value:e,configurable:!0}),"o");const d=l(async(r,e={})=>{const{errorAnsi:t,solutionBox:n}=await i(r,e);return n===void 0?t:`${t}
2
2
 
3
3
  ${n}`},"ansiHandler");export{d as ansiHandler,f as cliHandler};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var u=(e,r)=>d(e,"name",{value:r,configurable:!0});import{parseStacktrace as g}from"@visulima/error/stacktrace";import{boxen as y}from"@visulima/boxen";import{renderError as h}from"@visulima/error/error";import{readFile as x}from"node:fs/promises";import{fileURLToPath as j}from"node:url";import{ruleBasedFinder as v,errorHintFinder as b}from"@visulima/error/solution";var w=Object.defineProperty,O=u((e,r)=>w(e,"name",{value:r,configurable:!0}),"t");const F=["cjs","mjs"],A=["mdoc"],B=O(e=>{const r=(e.split("?")[0]??e).split(".").pop()?.toLowerCase();if(!r||F.includes(r))return"javascript";if(A.includes(r))return"markdown";switch(r){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";default:return"javascript"}},"findLanguageBasedOnExtension");var k=Object.defineProperty,L=u((e,r)=>k(e,"name",{value:r,configurable:!0}),"s");const c=new Map,P=L(async e=>{if(/^(?:http|https|file|data):/.test(e)){if(c.has(e))return c.get(e);if(e.startsWith("file:"))try{const r=j(e),t=await x(r,"utf8");return c.set(e,t),t}catch{return}try{const r=await fetch(e);if(!r.ok)return;const t=await r.text();return c.set(e,t),t}catch{return}}},"getFileSource");var S=Object.defineProperty,l=u((e,r)=>S(e,"name",{value:r,configurable:!0}),"d");const T=l(e=>e.replace(/^\s*#+\s*/,"").trim(),"sanitizeTitle"),$=l(async(e,r,t=!1)=>{const i=[...r,v,b],s=g(e,{frameLimit:1})[0]??{};for await(const o of i.sort((a,n)=>a.priority-n.priority)){const{handle:a}=o;if(typeof a!="function")continue;const n=await a(e,{file:s.file??"",language:B(s.file??""),line:s.line??0,snippet:s.file?await P(s.file):""});if(n)return n}},"runSolutionFinders"),q=l(async(e,r)=>{const{solutionFinders:t=[],solutionTitle:i,color:s,debug:o=!1,...a}=r,n=h(e,{...a,...s?.codeFrame}),f=await $(e,t,o);if(!f)return{errorAnsi:n,solutionBox:void 0};const m=T(f.header??i??"A possible solution to this error"),p=y(f.body,{borderStyle:"round",padding:{top:1,right:2,bottom:1,left:2},margin:{top:0,right:0,bottom:0,left:0},headerText:`💡 ${m}`,headerAlignment:"left",textAlignment:"left",...s?.boxen});return{errorAnsi:n,solutionBox:p}},"buildOutput"),W=l(async(e,r={})=>{const{logger:t=console,...i}=r,{errorAnsi:s,solutionBox:o}=await q(e,i);t.error(s),o&&(t.log(""),t.log(o))},"terminalOutput");export{q as buildOutput,W as terminalOutput};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/error-handler",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Error handlers for use in development and production environments.",
5
5
  "keywords": [
6
6
  "visulima",
@@ -135,7 +135,7 @@
135
135
  "dependencies": {
136
136
  "@tinyhttp/accepts": "^2.2.4",
137
137
  "@visulima/boxen": "2.0.3",
138
- "@visulima/error": "4.6.1",
138
+ "@visulima/error": "4.6.2",
139
139
  "http-errors": "^2.0.0",
140
140
  "http-status-codes": "^2.3.0",
141
141
  "jstoxml": "^7.0.1",
@@ -1 +0,0 @@
1
- var m=Object.defineProperty;var u=(e,r)=>m(e,"name",{value:r,configurable:!0});import{parseStacktrace as g}from"@visulima/error/stacktrace";import{boxen as x}from"@visulima/boxen";import{renderError as b}from"@visulima/error/error";import{readFile as j}from"node:fs/promises";import{fileURLToPath as h}from"node:url";import{ruleBasedFinder as y,errorHintFinder as v}from"@visulima/error/solution";var w=Object.defineProperty,O=u((e,r)=>w(e,"name",{value:r,configurable:!0}),"r");const F=["cjs","mjs"],A=["mdoc"],B=O(e=>{const r=(e.split("?")[0]??e).split(".").pop()?.toLowerCase();if(!r||F.includes(r))return"javascript";if(A.includes(r))return"markdown";switch(r){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";default:return"javascript"}},"findLanguageBasedOnExtension");var k=Object.defineProperty,L=u((e,r)=>k(e,"name",{value:r,configurable:!0}),"o");const c=new Map,P=L(async e=>{if(/^(?:http|https|file|data):/.test(e)){if(c.has(e))return c.get(e);if(e.startsWith("file:"))try{const r=h(e),t=await j(r,"utf8");return c.set(e,t),t}catch(r){console.log(r);return}try{const r=await fetch(e);if(!r.ok)return;const t=await r.text();return c.set(e,t),t}catch(r){console.log(r);return}}},"getFileSource");var S=Object.defineProperty,f=u((e,r)=>S(e,"name",{value:r,configurable:!0}),"d");const T=f(e=>e.replace(/^\s*#+\s*/,"").trim(),"sanitizeTitle"),$=f(async(e,r,t=!1)=>{const l=[...r,y,v],n=g(e,{frameLimit:1})[0]??{};for await(const o of l.sort((i,s)=>i.priority-s.priority)){const{handle:i,name:s}=o;if(t&&console.debug(`Running solution finder: ${s}`),typeof i!="function")continue;const a=await i(e,{file:n.file??"",language:B(n.file??""),line:n.line??0,snippet:n.file?await P(n.file):""});if(a)return a}},"runSolutionFinders"),q=f(async(e,r)=>{const{solutionFinders:t=[],solutionTitle:l,color:n,debug:o=!1,...i}=r,s=b(e,{...i,...n?.codeFrame}),a=await $(e,t,o);if(!a)return{errorAnsi:s,solutionBox:void 0};const d=T(a.header??l??"A possible solution to this error"),p=x(a.body,{borderStyle:"round",padding:{top:1,right:2,bottom:1,left:2},margin:{top:0,right:0,bottom:0,left:0},headerText:`💡 ${d}`,headerAlignment:"left",textAlignment:"left",...n?.boxen});return{errorAnsi:s,solutionBox:p}},"buildOutput"),W=f(async(e,r={})=>{const{logger:t=console,...l}=r,{errorAnsi:n,solutionBox:o}=await q(e,l);t.error(n),o&&(t.log(""),t.log(o))},"terminalOutput");export{q as buildOutput,W as terminalOutput};