@visulima/ono 2.0.10 → 2.1.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 +10 -0
- package/dist/error-inspector/page/create-request-context.d.ts +1 -1
- package/dist/error-inspector/page/create-request-context.js +46 -46
- package/dist/index.d.ts +39 -39
- package/dist/index.js +135 -230
- package/dist/packem_shared/sanitize-SjW6ExLy.js +1 -0
- package/dist/packem_shared/{types.d-D1UE67tt.d.ts → types.d-Dm3db2h3.d.ts} +1 -1
- package/dist/server/open-in-editor.d.ts +12 -12
- package/dist/server/open-in-editor.js +1 -1
- package/package.json +22 -20
- package/dist/packem_shared/sanitize-D2LcyiFA.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## @visulima/ono [2.1.0](https://github.com/visulima/visulima/compare/%40visulima%2Fono%402.0.11...%40visulima%2Fono%402.1.0) (2026-08-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Dependencies
|
|
5
|
+
|
|
6
|
+
* **@visulima/error:** upgraded to 6.1.0
|
|
7
|
+
* **@visulima/path:** upgraded to 3.1.0
|
|
8
|
+
|
|
9
|
+
## @visulima/ono [2.0.11](https://github.com/visulima/visulima/compare/%40visulima%2Fono%402.0.10...%40visulima%2Fono%402.0.11) (2026-07-27)
|
|
10
|
+
|
|
1
11
|
## @visulima/ono [2.0.10](https://github.com/visulima/visulima/compare/%40visulima%2Fono%402.0.9...%40visulima%2Fono%402.0.10) (2026-07-27)
|
|
2
12
|
|
|
3
13
|
## @visulima/ono [2.0.9](https://github.com/visulima/visulima/compare/%40visulima%2Fono%402.0.8...%40visulima%2Fono%402.0.9) (2026-07-27)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ContentPage } from "../../packem_shared/types.d-
|
|
1
|
+
import { C as ContentPage } from "../../packem_shared/types.d-Dm3db2h3.js";
|
|
2
2
|
import { IncomingMessage } from 'node:http';
|
|
3
3
|
type NativeRequest = typeof globalThis.Request;
|
|
4
4
|
type NativeHeaders = typeof globalThis.Headers;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import{s as
|
|
1
|
+
import{s as U,a as q,l as Q,b as Y,c as ve,d as ue,e as pe}from"../../packem_shared/sanitize-SjW6ExLy.js";const J="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-braces%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Cpath%20d%3D%22M8%203H7a2%202%200%200%200-2%202v5a2%202%200%200%201-2%202%202%202%200%200%201%202%202v5c0%201.1.9%202%202%202h1%22%20%2F%3E%20%3Cpath%20d%3D%22M16%2021h1a2%202%200%200%200%202-2v-5c0-1.1.9-2%202-2a2%202%200%200%201-2-2V5a2%202%200%200%200-2-2h-1%22%20%2F%3E%20%3C%2Fsvg%3E",N="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-cookie%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Cpath%20d%3D%22M12%202a10%2010%200%201%200%2010%2010%204%204%200%200%201-5-5%204%204%200%200%201-5-5%22%20%2F%3E%20%3Cpath%20d%3D%22M8.5%208.5v.01%22%20%2F%3E%20%3Cpath%20d%3D%22M16%2015.5v.01%22%20%2F%3E%20%3Cpath%20d%3D%22M12%2012v.01%22%20%2F%3E%20%3Cpath%20d%3D%22M11%2017v.01%22%20%2F%3E%20%3Cpath%20d%3D%22M7%2014v.01%22%20%2F%3E%20%3C%2Fsvg%3E",j="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-file-text%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Cpath%20d%3D%22M6%2022a2%202%200%200%201-2-2V4a2%202%200%200%201%202-2h8a2.4%202.4%200%200%201%201.704.706l3.588%203.588A2.4%202.4%200%200%201%2020%208v12a2%202%200%200%201-2%202z%22%20%2F%3E%20%3Cpath%20d%3D%22M14%202v5a1%201%200%200%200%201%201h5%22%20%2F%3E%20%3Cpath%20d%3D%22M10%209H8%22%20%2F%3E%20%3Cpath%20d%3D%22M16%2013H8%22%20%2F%3E%20%3Cpath%20d%3D%22M16%2017H8%22%20%2F%3E%20%3C%2Fsvg%3E",L="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-globe%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%2210%22%20%2F%3E%20%3Cpath%20d%3D%22M12%202a14.5%2014.5%200%200%200%200%2020%2014.5%2014.5%200%200%200%200-20%22%20%2F%3E%20%3Cpath%20d%3D%22M2%2012h20%22%20%2F%3E%20%3C%2Fsvg%3E",B="data:image/svg+xml;charset=utf-8,%3Csvg%20class%3D%22lucide%20lucide-user%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20%3E%20%3Cpath%20d%3D%22M19%2021v-2a4%204%200%200%200-4-4H9a4%204%200%200%200-4%204v2%22%20%2F%3E%20%3Ccircle%20cx%3D%2212%22%20cy%3D%227%22%20r%3D%224%22%20%2F%3E%20%3C%2Fsvg%3E",E=({label:t="Copy",successText:o="Copied!",targetId:r})=>{const i=U(r),a=U(t),l=q(t),v=q(o);return{html:`
|
|
2
2
|
<button
|
|
3
3
|
type="button"
|
|
4
|
-
aria-label="${
|
|
5
|
-
title="${
|
|
4
|
+
aria-label="${a}"
|
|
5
|
+
title="${l}"
|
|
6
6
|
class="ono-copy-btn relative inline-flex justify-center items-center size-8 rounded-[var(--ono-radius-md)] shadow-[var(--ono-elevation-1)] bg-[var(--ono-surface)] text-[var(--ono-text)] hover:bg-[var(--ono-hover-overlay)] focus:outline-hidden focus:bg-[var(--ono-hover-overlay)] disabled:opacity-50 disabled:pointer-events-none cursor-pointer"
|
|
7
|
-
data-target="#${
|
|
8
|
-
data-success-text="${
|
|
7
|
+
data-target="#${i}"
|
|
8
|
+
data-success-text="${v}"
|
|
9
9
|
>
|
|
10
|
-
<span class="ono-copy-default dui size-4 transition" style="-webkit-mask-image: url('${
|
|
11
|
-
<span class="ono-copy-success dui hidden size-4 text-[var(--ono-red-orange)]" style="-webkit-mask-image: url('${
|
|
12
|
-
<span class="sr-only">${
|
|
10
|
+
<span class="ono-copy-default dui size-4 transition" style="-webkit-mask-image: url('${Q}'); mask-image: url('${Q}')"></span>
|
|
11
|
+
<span class="ono-copy-success dui hidden size-4 text-[var(--ono-red-orange)]" style="-webkit-mask-image: url('${Y}'); mask-image: url('${Y}')"></span>
|
|
12
|
+
<span class="sr-only">${l}</span>
|
|
13
13
|
</button>
|
|
14
|
-
`}},
|
|
15
|
-
… [truncated]`);return}
|
|
16
|
-
`)}`),
|
|
14
|
+
`}},xe=(t,o)=>o in t,Z=(t,o)=>xe(t,o)&&typeof t[o]=="function",R=t=>typeof t=="object"&&t!==null&&Z(t,"forEach")&&Z(t,"get"),te=[/authorization/i,/cookie/i,/set-cookie/i,/x-api-key/i,/api-key/i,/x-auth/i,/token/i,/secret/i],M=(t,o)=>{if(typeof t=="object"&&t!==null&&o in t)return t[o]},b=(t,o)=>{const r=M(t,o);return typeof r=="function"?r.bind(t):void 0},F=(t,o)=>{const r=M(t,o);return typeof r=="string"?r:void 0},re=(t,o)=>o?.some(r=>r.toLowerCase()===t.toLowerCase())?!0:te.some(r=>r.test(t)),me=[...te,/passw(?:or)?d/i,/pwd/i,/credential/i,/passphrase/i],G=(t,o)=>o?.some(r=>r.toLowerCase()===t.toLowerCase())?!0:me.some(r=>r.test(t)),be=t=>{const o={};return new URLSearchParams(t).forEach((r,i)=>{const a=o[i];a===void 0?o[i]=r:Array.isArray(a)?a.push(r):o[i]=[a,r]}),o},ge=(t,o,r)=>t.replaceAll(/(?<![^\s&=?#])([^\s&=?#]+)=([^&\s#]*)/g,(i,a,l)=>l&&G(a,r)?`${a}=${o}`:i).replaceAll(/("(?:[^"\\]|\\.)*")(\s*:\s*)"(?:[^"\\]|\\.)*"/g,(i,a,l)=>{const v=a.slice(1,-1);return G(v,r)?`${a}${l}${JSON.stringify(o)}`:i}),he=t=>{if(!t)return[];if(R(t)){const o=b(t,"entries");if(o){const r=o();return Array.from(r,([i,a])=>[i,a])}}return Object.entries(t)},fe=(t,o)=>!o||o.length===0?!0:o.some(r=>r.toLowerCase()===t.toLowerCase()),ye=(t,o)=>!t||!o?t:Array.isArray(t)?t.map(()=>o):o,we=(t,o,r,i="[masked]")=>{const a=he(t);if(a.length===0)return;const l={};return a.forEach(([v,c])=>{if(!fe(v,o)||c===void 0)return;const u=re(v.toLowerCase(),r)?i:void 0;l[v]=ye(c,u)}),l},ee=t=>{try{return JSON.stringify(t,null,2)}catch{return String(t)}},$e=t=>{if(!t)return{};const o={};return t.split(";").map(r=>r.trim()).filter(Boolean).forEach(r=>{const i=r.indexOf("=");if(i===-1)return;const a=r.slice(0,i).trim(),l=r.slice(i+1).trim();o[a]=l}),o},ke=async(t,o)=>{try{const r=(F(t,"method")??"GET").toUpperCase();if(r==="GET"||r==="HEAD")return;const i=M(t,"headers"),a=R(i)?b(i,"get")?.("content-type")??"":String(i["content-type"]??""),l=b(t,"clone"),v=l?l():t;if(b(v,"json")&&a.includes("application/json"))try{const c=b(v,"json");return c?await c():void 0}catch{try{const c=b(v,"text");return c?await c()??"":void 0}catch{return}}if(b(v,"text"))try{const c=b(v,"text"),u=c?await c():void 0;return typeof u=="string"&&a.includes("application/x-www-form-urlencoded")?be(u):u}catch{return}return b(t,"on")?await new Promise(c=>{try{let u="",H=!1;const $=b(t,"setEncoding");$&&$("utf8");const k=g=>{if(H)return;const f=typeof g=="string"?g:String(g);if(u.length+f.length>o){const I=Math.max(0,o-u.length);u+=f.slice(0,I),H=!0,O(),c(`${u}
|
|
15
|
+
… [truncated]`);return}u+=f},A=()=>{O(),c(u||void 0)},D=()=>{O(),c(void 0)},O=()=>{const g=b(t,"off");g?.("data",k),g?.("end",A),g?.("error",D)},S=b(t,"on");S?.("data",k),S?.("end",A),S?.("error",D)}catch{c(void 0)}}):void 0}catch{return}},Ce=async(t,o)=>{const r=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,11)}`,{headerAllowlist:i,headerDenylist:a,maskValue:l="[masked]"}=o,v=we(M(t,"headers"),i,a,l),c=e=>{if(e!==void 0)return Array.isArray(e)?e.join(", "):e},u=e=>`'${e.replaceAll("'",String.raw`'\''`)}'`,H=e=>{if(!e)return;const s=[];return Object.entries(e).forEach(([n,d])=>{const x=c(d)??"";s.push(`${n}=${x}`)}),s.length>0?s.join("; "):void 0};let $;const k=M(t,"headers");if(R(k)){const e=b(k,"get")?.("cookie");$=typeof e=="string"?e:void 0}else if(k!==void 0){const e=k;if(Array.isArray(e.cookie))[$]=e.cookie;else{const s=e.cookie;$=typeof s=="string"?s:void 0}}const A=$e($),D=l&&re("cookie",a)?Object.fromEntries(Object.keys(A).map(e=>[e,l])):A,O=Math.max(0,o.previewBytes??64e3),S=await ke(t,O),g=(e,s)=>{if(!l)return e;if(typeof e=="string")return ge(e,l,a);if(e===null||typeof e!="object")return e;if(s.has(e))return"[Circular]";s.add(e);let n;return Array.isArray(e)?n=e.map(d=>g(d,s)):n=Object.fromEntries(Object.entries(e).map(([d,x])=>[d,G(d,a)?l:g(x,s)])),s.delete(e),n},f=g(S,new WeakSet),I=t.session,V=g(I,new WeakSet),W=(()=>{const e=(F(t,"method")??"GET").toUpperCase(),s=F(t,"url")??"",n=[],d={};v&&Object.entries(v).forEach(([m,T])=>{const K=c(T);K!==void 0&&(d[m]=K)});const x=H(D),h=Object.keys(d).some(m=>m.toLowerCase()==="cookie");x&&!h&&(d.Cookie=x),Object.entries(d).forEach(([m,T])=>{n.push(`-H ${u(`${m}: ${T}`)}`)});let p="";if(f!=null&&e!=="GET"){const m=typeof f=="string"?f:ee(f);p=`--data ${u(m)}`}const w=["curl","-X",e];return n.length>0&&w.push("\\",` ${n.join(` \\
|
|
16
|
+
`)}`),p&&w.push("\\",` ${p}`),w.push("\\",` ${u(s)}`),w.join(" ")})(),oe=(await ve(["bash"])).codeToHtml(W,{lang:"bash",themes:{dark:"min-dark",light:"min-light"}}),se=ue(oe),C=e=>U(e),y=e=>q(e),_=e=>!e||Object.keys(e).length===0?'<div class="px-4 pb-4 pt-2 text-xs text-[var(--ono-text-muted)]">(empty)</div>':`<div class="px-4 pb-4">${Object.entries(e).map(([s,n])=>{const d=Array.isArray(n)?n.join(", "):n;return`<div class="grid grid-cols-[200px_1fr] gap-3 items-start py-2 border-b border-[var(--ono-border)]">
|
|
17
17
|
<div class="text-[11px] uppercase tracking-wide text-[var(--ono-text-muted)]">${y(s)}</div>
|
|
18
|
-
<div class="text-sm break-words whitespace-pre-wrap text-[var(--ono-text)]">${y(
|
|
19
|
-
</div>`}).join("")}</div>`,
|
|
18
|
+
<div class="text-sm break-words whitespace-pre-wrap text-[var(--ono-text)]">${y(d)}</div>
|
|
19
|
+
</div>`}).join("")}</div>`,ae=e=>`<span class="text-[var(--ono-red-orange)]">${typeof e=="string"?`"${y(e)}"`:String(e)}</span>`,ie=e=>`<span class="italic text-[var(--ono-text-muted)]">${e===null?"null":"undefined"}</span>`,ne=(e,s)=>{if(Object.keys(e).length===0)return'<span class="italic text-[var(--ono-text-muted)]">(empty object)</span>';if(s>=3)return`<span class="italic text-[var(--ono-text-muted)]">{Object with ${String(Object.keys(e).length)} keys}</span>`;const n=Object.entries(e).slice(0,10).map(([x,h])=>{const p=z(h,s+1);return`
|
|
20
20
|
<div class="ml-4 pl-3 py-1 border-l-2 border-[var(--ono-border)]">
|
|
21
|
-
<span class="font-medium text-[var(--ono-text)]">${y(
|
|
22
|
-
</div>`}).join(""),
|
|
21
|
+
<span class="font-medium text-[var(--ono-text)]">${y(x)}:</span> ${p}
|
|
22
|
+
</div>`}).join(""),d=Object.keys(e).length>10?`<div class="ml-4 italic text-[var(--ono-text-muted)]">... and ${String(Object.keys(e).length-10)} more keys</div>`:"";return`<div class="space-y-1">${n}${d}</div>`},z=(e,s=0)=>{if(e==null)return ie(e);if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return ae(e);if(Array.isArray(e)){if(e.length===0)return'<span class="italic text-[var(--ono-text-muted)]">(empty array)</span>';if(s>=3)return`<span class="italic text-[var(--ono-text-muted)]">[Array with ${String(e.length)} items]</span>`;const d=e.slice(0,10).map((h,p)=>{const w=z(h,s+1);return`
|
|
23
23
|
<div class="ml-4 pl-3 py-1 border-l-2 border-[var(--ono-border)]">
|
|
24
|
-
<span class="text-xs text-[var(--ono-text-muted)]">[${String(
|
|
25
|
-
</div>`}).join(""),
|
|
24
|
+
<span class="text-xs text-[var(--ono-text-muted)]">[${String(p)}]:</span> ${w}
|
|
25
|
+
</div>`}).join(""),x=e.length>10?`<div class="ml-4 text-sm italic text-[var(--ono-text-muted)]">... and ${String(e.length-10)} more items</div>`:"";return`<div class="space-y-1">${d}${x}</div>`}if(typeof e=="object")return ne(e,s);const n=typeof e=="symbol"||typeof e=="bigint"||typeof e=="function"?e.toString():JSON.stringify(e);return`<span class="text-[var(--ono-text)]">${y(n)}</span>`},P=e=>!e||Object.keys(e).length===0?'<div class="px-4 pb-4 pt-2 text-xs text-[var(--ono-text-muted)]">(empty)</div>':`<div class="px-4 pb-4">${Object.entries(e).map(([s,n])=>{const d=z(n);return`<div class="grid grid-cols-[200px_1fr] gap-3 items-start py-2 border-b border-[var(--ono-border)]">
|
|
26
26
|
<div class="text-[11px] uppercase tracking-wide text-[var(--ono-text-muted)]">${y(s)}</div>
|
|
27
|
-
<div class="text-sm break-words text-[var(--ono-text)]">${
|
|
28
|
-
</div>`}).join("")}</div>`,
|
|
27
|
+
<div class="text-sm break-words text-[var(--ono-text)]">${d}</div>
|
|
28
|
+
</div>`}).join("")}</div>`,de=e=>{if(e==null)return'<div class="px-4 pb-4 pt-2 text-xs text-[var(--ono-text-muted)]">(no body)</div>';if(typeof e=="string")return e.trim()===""?'<div class="px-4 pb-4 pt-2 text-xs text-[var(--ono-text-muted)]">(empty string)</div>':`<div class="px-4 pb-4">
|
|
29
29
|
<div class="text-sm break-words whitespace-pre-wrap font-mono p-3 rounded border border-[var(--ono-border)] bg-[var(--ono-surface-muted)] text-[var(--ono-text)]">${y(e)}</div>
|
|
30
30
|
</div>`;if(typeof e=="object")return Array.isArray(e)?e.length===0?'<div class="px-4 pb-4 pt-2 text-xs text-[var(--ono-text-muted)]">(empty array)</div>':`<div class="px-4 pb-4">
|
|
31
31
|
<div class="text-sm break-words p-3 rounded border border-[var(--ono-border)] bg-[var(--ono-surface-muted)] text-[var(--ono-text)]">${z(e)}</div>
|
|
@@ -33,7 +33,7 @@ import{s as q,a as G,l as _,b as K,c as de,d as le,e as ce}from"../../packem_sha
|
|
|
33
33
|
<div class="text-sm break-words p-3 rounded border border-[var(--ono-border)] bg-[var(--ono-surface-muted)] text-[var(--ono-text)]">${z(e)}</div>
|
|
34
34
|
</div>`;const s=e.toString();return`<div class="px-4 pb-4">
|
|
35
35
|
<div class="text-sm break-words whitespace-pre-wrap font-mono p-3 rounded border border-[var(--ono-border)] bg-[var(--ono-surface-muted)] text-[var(--ono-text)]">${y(s)}</div>
|
|
36
|
-
</div>`},
|
|
36
|
+
</div>`},X=(e=>{if(!e)return{content:"",sidebar:""};const s=new Set(["request"]),n=Object.keys(e).filter(h=>!s.has(h));if(n.length===0)return{content:"",sidebar:""};let d="",x="";return n.forEach(h=>{const p=e[h];if(p&&typeof p=="object"&&(Array.isArray(p)||Object.keys(p).length>0)){const w=h.charAt(0).toUpperCase()+h.slice(1),m=`context-${h}`;d+=`
|
|
37
37
|
<div>
|
|
38
38
|
<div class="text-[11px] uppercase tracking-wide mb-2 text-[var(--ono-text-muted)]">${w}</div>
|
|
39
39
|
<ul class="space-y-1 text-sm">
|
|
@@ -44,8 +44,8 @@ import{s as q,a as G,l as _,b as K,c as de,d as le,e as ce}from"../../packem_sha
|
|
|
44
44
|
</a>
|
|
45
45
|
</li>
|
|
46
46
|
</ul>
|
|
47
|
-
</div>`,
|
|
48
|
-
<input type="hidden" id="clipboard-${m}-${r}" value="${C(JSON.stringify(
|
|
47
|
+
</div>`,x+=`
|
|
48
|
+
<input type="hidden" id="clipboard-${m}-${r}" value="${C(JSON.stringify(p))}">
|
|
49
49
|
<section id="${m}" class="mb-4 rounded-[var(--ono-radius-lg)] shadow-[var(--ono-elevation-1)] overflow-hidden bg-[var(--ono-surface)] border border-[var(--ono-border)]">
|
|
50
50
|
<div class="px-4 py-2 flex items-center gap-2 bg-[var(--ono-surface-muted)] border-b border-[var(--ono-border)]">
|
|
51
51
|
<h3 class="text-sm font-semibold text-[var(--ono-text)]">${w}</h3>
|
|
@@ -53,8 +53,8 @@ import{s as q,a as G,l as _,b as K,c as de,d as le,e as ce}from"../../packem_sha
|
|
|
53
53
|
<a href="#${m}" class="text-xs text-[var(--ono-text-muted)]" aria-label="Anchor">#</a>
|
|
54
54
|
${E({label:"Copy JSON",targetId:`clipboard-${m}-${r}`}).html}
|
|
55
55
|
</div>
|
|
56
|
-
<div class="max-w-full overflow-auto mt-2">${
|
|
57
|
-
</section>`}}),{content:
|
|
56
|
+
<div class="max-w-full overflow-auto mt-2">${P(p)}</div>
|
|
57
|
+
</section>`}}),{content:x,sidebar:d}})(o.context),le=`
|
|
58
58
|
<aside class="shrink-0 w-64 sticky top-4 self-start">
|
|
59
59
|
<nav aria-label="Context sections" class="p-3 rounded-[var(--ono-radius-md)] shadow-[var(--ono-elevation-1)] space-y-4 overflow-auto bg-[var(--ono-surface)] border border-[var(--ono-border)] max-h-[calc(100dvh-2rem)]">
|
|
60
60
|
<div>
|
|
@@ -74,41 +74,41 @@ import{s as q,a as G,l as _,b as K,c as de,d as le,e as ce}from"../../packem_sha
|
|
|
74
74
|
</li>
|
|
75
75
|
<li>
|
|
76
76
|
<a href="#context-body" class="flex items-center gap-2 px-2 py-1 rounded text-[var(--ono-text)] hover:bg-[var(--ono-surface-muted)]">
|
|
77
|
-
<span class="dui size-3" style="-webkit-mask-image:url('${
|
|
77
|
+
<span class="dui size-3" style="-webkit-mask-image:url('${J}'); mask-image:url('${J}')"></span>
|
|
78
78
|
<span>Body</span>
|
|
79
79
|
</a>
|
|
80
80
|
</li>
|
|
81
81
|
<li>
|
|
82
82
|
<a href="#context-session" class="flex items-center gap-2 px-2 py-1 rounded text-[var(--ono-text)] hover:bg-[var(--ono-surface-muted)]">
|
|
83
|
-
<span class="dui size-3" style="-webkit-mask-image:url('${
|
|
83
|
+
<span class="dui size-3" style="-webkit-mask-image:url('${B}'); mask-image:url('${B}')"></span>
|
|
84
84
|
<span>Session</span>
|
|
85
85
|
</a>
|
|
86
86
|
</li>
|
|
87
87
|
<li>
|
|
88
88
|
<a href="#context-cookies" class="flex items-center gap-2 px-2 py-1 rounded text-[var(--ono-text)] hover:bg-[var(--ono-surface-muted)]">
|
|
89
|
-
<span class="dui size-3" style="-webkit-mask-image:url('${
|
|
89
|
+
<span class="dui size-3" style="-webkit-mask-image:url('${N}'); mask-image:url('${N}')"></span>
|
|
90
90
|
<span>Cookies</span>
|
|
91
91
|
</a>
|
|
92
92
|
</li>
|
|
93
93
|
</ul>
|
|
94
|
-
</div>${
|
|
94
|
+
</div>${X.sidebar}
|
|
95
95
|
</nav>
|
|
96
|
-
</aside>`,
|
|
96
|
+
</aside>`,ce=`
|
|
97
97
|
<div class="grow min-w-0">
|
|
98
|
-
<input type="hidden" id="clipboard-curl-${r}" value="${C(
|
|
98
|
+
<input type="hidden" id="clipboard-curl-${r}" value="${C(W)}">
|
|
99
99
|
<section id="context-request" class="mb-4 rounded-[var(--ono-radius-lg)] shadow-[var(--ono-elevation-1)] overflow-hidden bg-[var(--ono-surface)] border border-[var(--ono-border)]">
|
|
100
100
|
<div class="px-4 py-2 flex items-center gap-3 min-w-0 bg-[var(--ono-surface-muted)] border-b border-[var(--ono-border)]">
|
|
101
101
|
<span class="dui size-4" style="-webkit-mask-image:url('${L}'); mask-image:url('${L}')"></span>
|
|
102
102
|
<h2 class="text-sm font-semibold text-[var(--ono-text)]">Request</h2>
|
|
103
|
-
<a class="text-sm truncate text-[var(--ono-red-orange)]" href="${
|
|
103
|
+
<a class="text-sm truncate text-[var(--ono-red-orange)]" href="${pe(F(t,"url")??"#")}">${y(F(t,"url")??"")}</a>
|
|
104
104
|
<span class="inline-block text-[10px] px-2 py-0.5 rounded-full bg-[var(--ono-chip-bg)] text-[var(--ono-chip-text)]">${y(F(t,"method")??"GET")}</span>
|
|
105
105
|
<div class="grow"></div>
|
|
106
106
|
${E({label:"Copy cURL",targetId:`clipboard-curl-${r}`}).html}
|
|
107
107
|
</div>
|
|
108
|
-
<div class="px-4 pb-4 overflow-auto mt-2">${
|
|
108
|
+
<div class="px-4 pb-4 overflow-auto mt-2">${se}</div>
|
|
109
109
|
</section>
|
|
110
110
|
|
|
111
|
-
<input type="hidden" id="clipboard-headers-${r}" value="${C(JSON.stringify(
|
|
111
|
+
<input type="hidden" id="clipboard-headers-${r}" value="${C(JSON.stringify(v??{}))}">
|
|
112
112
|
<section id="context-headers" class="mb-4 rounded-[var(--ono-radius-lg)] shadow-[var(--ono-elevation-1)] overflow-hidden bg-[var(--ono-surface)] border border-[var(--ono-border)]">
|
|
113
113
|
<div class="px-4 py-2 flex items-center gap-2 bg-[var(--ono-surface-muted)] border-b border-[var(--ono-border)]">
|
|
114
114
|
<span class="dui size-4" style="-webkit-mask-image:url('${j}'); mask-image:url('${j}')"></span>
|
|
@@ -117,47 +117,47 @@ import{s as q,a as G,l as _,b as K,c as de,d as le,e as ce}from"../../packem_sha
|
|
|
117
117
|
<a href="#context-headers" class="text-xs text-[var(--ono-text-muted)]" aria-label="Anchor">#</a>
|
|
118
118
|
${E({label:"Copy JSON",targetId:`clipboard-headers-${r}`}).html}
|
|
119
119
|
</div>
|
|
120
|
-
<div class="max-w-full overflow-auto mt-2">${
|
|
120
|
+
<div class="max-w-full overflow-auto mt-2">${_(v)}</div>
|
|
121
121
|
</section>
|
|
122
122
|
|
|
123
|
-
<input type="hidden" id="clipboard-body-${r}" value="${C(
|
|
123
|
+
<input type="hidden" id="clipboard-body-${r}" value="${C(ee(f??{}))}">
|
|
124
124
|
<section id="context-body" class="mb-4 rounded-[var(--ono-radius-lg)] shadow-[var(--ono-elevation-1)] overflow-hidden bg-[var(--ono-surface)] border border-[var(--ono-border)]">
|
|
125
125
|
<div class="px-4 py-2 flex items-center gap-2 bg-[var(--ono-surface-muted)] border-b border-[var(--ono-border)]">
|
|
126
|
-
<span class="dui size-4" style="-webkit-mask-image:url('${
|
|
126
|
+
<span class="dui size-4" style="-webkit-mask-image:url('${J}'); mask-image:url('${J}')"></span>
|
|
127
127
|
<h3 class="text-sm font-semibold text-[var(--ono-text)]">Body</h3>
|
|
128
128
|
<div class="grow"></div>
|
|
129
129
|
<a href="#context-body" class="text-xs text-[var(--ono-text-muted)]" aria-label="Anchor">#</a>
|
|
130
130
|
${E({label:"Copy JSON",targetId:`clipboard-body-${r}`}).html}
|
|
131
131
|
</div>
|
|
132
|
-
<div class="max-w-full overflow-auto mt-2">${
|
|
132
|
+
<div class="max-w-full overflow-auto mt-2">${de(f)}</div>
|
|
133
133
|
</section>
|
|
134
134
|
|
|
135
|
-
<input type="hidden" id="clipboard-session-${r}" value="${C(JSON.stringify(
|
|
135
|
+
<input type="hidden" id="clipboard-session-${r}" value="${C(JSON.stringify(V??{}))}">
|
|
136
136
|
<section id="context-session" class="mb-4 rounded-[var(--ono-radius-lg)] shadow-[var(--ono-elevation-1)] overflow-hidden bg-[var(--ono-surface)] border border-[var(--ono-border)]">
|
|
137
137
|
<div class="px-4 py-2 flex items-center gap-2 bg-[var(--ono-surface-muted)] border-b border-[var(--ono-border)]">
|
|
138
|
-
<span class="dui size-4" style="-webkit-mask-image:url('${
|
|
138
|
+
<span class="dui size-4" style="-webkit-mask-image:url('${B}'); mask-image:url('${B}')"></span>
|
|
139
139
|
<h3 class="text-sm font-semibold text-[var(--ono-text)]">Session</h3>
|
|
140
140
|
<div class="grow"></div>
|
|
141
141
|
<a href="#context-session" class="text-xs text-[var(--ono-text-muted)]" aria-label="Anchor">#</a>
|
|
142
142
|
${E({label:"Copy JSON",targetId:`clipboard-session-${r}`}).html}
|
|
143
143
|
</div>
|
|
144
|
-
<div class="max-w-full overflow-auto mt-2">${V
|
|
144
|
+
<div class="max-w-full overflow-auto mt-2">${P(V)}</div>
|
|
145
145
|
</section>
|
|
146
146
|
|
|
147
147
|
<input type="hidden" id="clipboard-cookies-${r}" value="${C(JSON.stringify(D))}">
|
|
148
148
|
<section id="context-cookies" class="mb-4 rounded-[var(--ono-radius-lg)] shadow-[var(--ono-elevation-1)] overflow-hidden bg-[var(--ono-surface)] border border-[var(--ono-border)]">
|
|
149
149
|
<div class="px-4 py-2 flex items-center gap-2 bg-[var(--ono-surface-muted)] border-b border-[var(--ono-border)]">
|
|
150
|
-
<span class="dui size-4" style="-webkit-mask-image:url('${
|
|
150
|
+
<span class="dui size-4" style="-webkit-mask-image:url('${N}'); mask-image:url('${N}')"></span>
|
|
151
151
|
<h3 class="text-sm font-semibold text-[var(--ono-text)]">Cookies</h3>
|
|
152
152
|
<div class="grow"></div>
|
|
153
153
|
<a href="#context-cookies" class="text-xs text-[var(--ono-text-muted)]" aria-label="Anchor">#</a>
|
|
154
154
|
${E({label:"Copy JSON",targetId:`clipboard-cookies-${r}`}).html}
|
|
155
155
|
</div>
|
|
156
|
-
<div class="max-w-full overflow-auto mt-2">${
|
|
156
|
+
<div class="max-w-full overflow-auto mt-2">${_(D)}
|
|
157
157
|
</div>
|
|
158
|
-
</section>${
|
|
158
|
+
</section>${X.content}
|
|
159
159
|
</div>`;return{code:{html:`
|
|
160
160
|
<div class="w-full flex gap-4 relative">
|
|
161
|
-
${
|
|
162
|
-
${
|
|
163
|
-
</div>`,script:""},id:"context",name:"Context"}};export{
|
|
161
|
+
${le}
|
|
162
|
+
${ce}
|
|
163
|
+
</div>`,script:""},id:"context",name:"Context"}};export{Ce as default};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SolutionFinder } from '@visulima/error/solution';
|
|
2
2
|
import { RenderErrorOptions } from '@visulima/error/error';
|
|
3
|
-
import { T as TemplateOptions$1 } from "./packem_shared/types.d-
|
|
3
|
+
import { T as TemplateOptions$1 } from "./packem_shared/types.d-Dm3db2h3.js";
|
|
4
4
|
/** A single parsed stack frame in the structured error payload. */
|
|
5
5
|
interface OnoJsonFrame {
|
|
6
6
|
column?: number;
|
|
@@ -32,21 +32,21 @@ type ToJsonOptions = {
|
|
|
32
32
|
solutionFinders?: SolutionFinder[];
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
-
* Build a structured, JSON-serializable representation of an error — its name/message, the parsed
|
|
36
|
-
* stack frames for the error and every entry in its `cause` chain, the detected runtime, and a
|
|
37
|
-
* suggested solution (using the same solution-finder protocol as the HTML/ANSI renderers).
|
|
38
|
-
*
|
|
39
|
-
* Useful for API servers that want to return parsed error data when the client requests
|
|
40
|
-
* `Accept: application/json`, mirroring Youch's `toJSON()`.
|
|
41
|
-
* @param error the value thrown (any value is coerced to an `Error`).
|
|
42
|
-
* @param options optional custom solution finders.
|
|
43
|
-
* @returns a plain object safe to pass to `JSON.stringify`.
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const payload = await toJSON(error);
|
|
47
|
-
* response.json(payload);
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
35
|
+
* Build a structured, JSON-serializable representation of an error — its name/message, the parsed
|
|
36
|
+
* stack frames for the error and every entry in its `cause` chain, the detected runtime, and a
|
|
37
|
+
* suggested solution (using the same solution-finder protocol as the HTML/ANSI renderers).
|
|
38
|
+
*
|
|
39
|
+
* Useful for API servers that want to return parsed error data when the client requests
|
|
40
|
+
* `Accept: application/json`, mirroring Youch's `toJSON()`.
|
|
41
|
+
* @param error the value thrown (any value is coerced to an `Error`).
|
|
42
|
+
* @param options optional custom solution finders.
|
|
43
|
+
* @returns a plain object safe to pass to `JSON.stringify`.
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const payload = await toJSON(error);
|
|
47
|
+
* response.json(payload);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
50
|
declare const toJSON: (error: unknown, options?: ToJsonOptions) => Promise<OnoJson>;
|
|
51
51
|
type ColorizeMethod = (value: string) => string;
|
|
52
52
|
type BaseCliOptions = {
|
|
@@ -68,47 +68,47 @@ type TemplateOptions = TemplateOptions$1 & {
|
|
|
68
68
|
};
|
|
69
69
|
type CliOptions = BaseCliOptions;
|
|
70
70
|
/**
|
|
71
|
-
* Render an error to a Shiki-highlighted HTML error page.
|
|
72
|
-
* @param error the value thrown (any value is coerced to an `Error`).
|
|
73
|
-
* @param options template options, including custom `solutionFinders`.
|
|
74
|
-
*/
|
|
71
|
+
* Render an error to a Shiki-highlighted HTML error page.
|
|
72
|
+
* @param error the value thrown (any value is coerced to an `Error`).
|
|
73
|
+
* @param options template options, including custom `solutionFinders`.
|
|
74
|
+
*/
|
|
75
75
|
declare const renderHtml: (error: unknown, options?: TemplateOptions) => Promise<string>;
|
|
76
76
|
/**
|
|
77
|
-
* Render an error to ANSI terminal output.
|
|
78
|
-
* @param error the value thrown (any value is coerced to an `Error`).
|
|
79
|
-
* @param options CLI options forwarded to the shared ANSI builder.
|
|
80
|
-
*/
|
|
77
|
+
* Render an error to ANSI terminal output.
|
|
78
|
+
* @param error the value thrown (any value is coerced to an `Error`).
|
|
79
|
+
* @param options CLI options forwarded to the shared ANSI builder.
|
|
80
|
+
*/
|
|
81
81
|
declare const renderAnsi: (error: unknown, options?: CliOptions) => Promise<{
|
|
82
82
|
errorAnsi: string;
|
|
83
83
|
solutionBox: undefined | string;
|
|
84
84
|
}>;
|
|
85
85
|
/**
|
|
86
|
-
* Render an error to a structured, JSON-serializable payload (parsed frames, cause chain, runtime,
|
|
87
|
-
* suggested solution). Useful for SPA/REST error responses (`Accept: application/json`).
|
|
88
|
-
* @param error the value thrown (any value is coerced to an `Error`).
|
|
89
|
-
* @param options optional custom `solutionFinders`.
|
|
90
|
-
*/
|
|
86
|
+
* Render an error to a structured, JSON-serializable payload (parsed frames, cause chain, runtime,
|
|
87
|
+
* suggested solution). Useful for SPA/REST error responses (`Accept: application/json`).
|
|
88
|
+
* @param error the value thrown (any value is coerced to an `Error`).
|
|
89
|
+
* @param options optional custom `solutionFinders`.
|
|
90
|
+
*/
|
|
91
91
|
declare const renderJson: typeof toJSON;
|
|
92
92
|
/**
|
|
93
|
-
* Convenience class wrapping the standalone {@link renderHtml}, {@link renderAnsi} and
|
|
94
|
-
* {@link renderJson} renderers. The standalone functions are preferred for tree-shaking; the class
|
|
95
|
-
* remains for backwards compatibility.
|
|
96
|
-
*/
|
|
93
|
+
* Convenience class wrapping the standalone {@link renderHtml}, {@link renderAnsi} and
|
|
94
|
+
* {@link renderJson} renderers. The standalone functions are preferred for tree-shaking; the class
|
|
95
|
+
* remains for backwards compatibility.
|
|
96
|
+
*/
|
|
97
97
|
declare class Ono {
|
|
98
98
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
* Render error to HTML.
|
|
100
|
+
*/
|
|
101
101
|
toHTML(error: unknown, options?: TemplateOptions): Promise<string>;
|
|
102
102
|
/**
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
* Render error to ANSI output.
|
|
104
|
+
*/
|
|
105
105
|
toANSI(error: unknown, options?: CliOptions): Promise<{
|
|
106
106
|
errorAnsi: string;
|
|
107
107
|
solutionBox: undefined | string;
|
|
108
108
|
}>;
|
|
109
109
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
* Render error to a structured JSON payload.
|
|
111
|
+
*/
|
|
112
112
|
toJSON(error: unknown, options?: ToJsonOptions): ReturnType<typeof toJSON>;
|
|
113
113
|
}
|
|
114
114
|
export { CliOptions, Ono, type OnoJson, type OnoJsonError, type OnoJsonFrame, TemplateOptions, type ToJsonOptions, renderAnsi, renderHtml, renderJson };
|