routeweb 0.1.0 → 0.1.2

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/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -44072,7 +44073,7 @@ import { Command } from "commander";
44072
44073
  import { serve } from "@hono/node-server";
44073
44074
  import open from "open";
44074
44075
 
44075
- // ../core/dist/chunk-O7OBO7YN.js
44076
+ // ../core/dist/chunk-Q4Y3A7MR.js
44076
44077
  var import_parser = __toESM(require_lib(), 1);
44077
44078
  var import_traverse = __toESM(require_lib8(), 1);
44078
44079
  function toPosix(p) {
@@ -44623,6 +44624,16 @@ function analyzeFile(file, fileSet, tsConfig) {
44623
44624
  node: d.init,
44624
44625
  line: d.loc?.start.line ?? 1
44625
44626
  });
44627
+ } else if (d.id.type === "ObjectPattern" && d.init) {
44628
+ for (const prop of d.id.properties) {
44629
+ if (prop.type === "ObjectProperty" && prop.value.type === "Identifier") {
44630
+ exports.set(prop.value.name, {
44631
+ name: prop.value.name,
44632
+ node: d.init,
44633
+ line: prop.loc?.start.line ?? d.loc?.start.line ?? 1
44634
+ });
44635
+ }
44636
+ }
44626
44637
  }
44627
44638
  }
44628
44639
  }
@@ -1 +1 @@
1
- import{a as l,j as s}from"./react-D71YmLB6.js";import{g as f}from"./index-Co71Z6SJ.js";import{r as u,X as p}from"./vendor-DBc_8COV.js";import"./graph-Dp3lBNo7.js";function j({open:i,routes:x,onClose:n,onSelectRoute:d}){const[m,h]=l.useState(""),[o,c]=l.useState(0);l.useEffect(()=>{i&&(h(""),c(0))},[i]);const a=l.useMemo(()=>{const e=m.trim().toLowerCase();return e?x.filter(t=>`${t.method} ${t.fullPath} ${t.controller??""} ${t.file}`.toLowerCase().includes(e)).slice(0,20):x.slice(0,20)},[x,m]);return l.useEffect(()=>{if(!i)return;const e=t=>{t.key==="Escape"?n():t.key==="ArrowDown"?(t.preventDefault(),c(r=>Math.min(r+1,Math.max(0,a.length-1)))):t.key==="ArrowUp"?(t.preventDefault(),c(r=>Math.max(r-1,0))):t.key==="Enter"&&a[o]&&(t.preventDefault(),d(a[o]),n())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i,a,o,n,d]),i?s.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/65 pt-24 backdrop-blur-sm",onClick:n,children:s.jsxs("div",{className:"w-full max-w-xl overflow-hidden rounded-2xl border border-white/15 bg-zinc-950/95 shadow-2xl",onClick:e=>e.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center gap-2.5 border-b border-white/10 px-4 py-3",children:[s.jsx(u,{className:"h-4 w-4 text-zinc-400"}),s.jsx("input",{autoFocus:!0,type:"text",value:m,onChange:e=>{h(e.target.value),c(0)},placeholder:"Search routes, methods, controllers, or files...",className:"flex-1 bg-transparent text-sm text-zinc-100 outline-none placeholder:text-zinc-500"}),s.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:text-zinc-200",children:s.jsx(p,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"max-h-80 overflow-y-auto p-2",children:a.length===0?s.jsx("div",{className:"py-8 text-center text-xs text-zinc-500",children:"No matching routes"}):a.map((e,t)=>{const r=f(e.method);return s.jsxs("button",{onClick:()=>{d(e),n()},className:`flex w-full items-center justify-between gap-3 rounded-xl px-3 py-2 text-left transition ${t===o?"bg-white/10":"hover:bg-white/5"}`,children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("span",{className:`w-14 shrink-0 rounded border px-1.5 py-0.5 text-center font-mono text-[10px] font-bold ${r.bg} ${r.text} ${r.border}`,children:e.method}),s.jsx("span",{className:"truncate font-mono text-xs text-zinc-100",children:e.fullPath})]}),s.jsx("span",{className:"shrink-0 font-mono text-[10px] text-zinc-500",children:e.controller??e.file})]},e.id)})})]})}):null}export{j as SearchModal};
1
+ import{a as l,j as s}from"./react-D71YmLB6.js";import{g as f}from"./index-CHRlXsqI.js";import{r as u,X as p}from"./vendor-DBc_8COV.js";import"./graph-Dp3lBNo7.js";function j({open:i,routes:x,onClose:n,onSelectRoute:d}){const[m,h]=l.useState(""),[o,c]=l.useState(0);l.useEffect(()=>{i&&(h(""),c(0))},[i]);const a=l.useMemo(()=>{const e=m.trim().toLowerCase();return e?x.filter(t=>`${t.method} ${t.fullPath} ${t.controller??""} ${t.file}`.toLowerCase().includes(e)).slice(0,20):x.slice(0,20)},[x,m]);return l.useEffect(()=>{if(!i)return;const e=t=>{t.key==="Escape"?n():t.key==="ArrowDown"?(t.preventDefault(),c(r=>Math.min(r+1,Math.max(0,a.length-1)))):t.key==="ArrowUp"?(t.preventDefault(),c(r=>Math.max(r-1,0))):t.key==="Enter"&&a[o]&&(t.preventDefault(),d(a[o]),n())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i,a,o,n,d]),i?s.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/65 pt-24 backdrop-blur-sm",onClick:n,children:s.jsxs("div",{className:"w-full max-w-xl overflow-hidden rounded-2xl border border-white/15 bg-zinc-950/95 shadow-2xl",onClick:e=>e.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center gap-2.5 border-b border-white/10 px-4 py-3",children:[s.jsx(u,{className:"h-4 w-4 text-zinc-400"}),s.jsx("input",{autoFocus:!0,type:"text",value:m,onChange:e=>{h(e.target.value),c(0)},placeholder:"Search routes, methods, controllers, or files...",className:"flex-1 bg-transparent text-sm text-zinc-100 outline-none placeholder:text-zinc-500"}),s.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:text-zinc-200",children:s.jsx(p,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"max-h-80 overflow-y-auto p-2",children:a.length===0?s.jsx("div",{className:"py-8 text-center text-xs text-zinc-500",children:"No matching routes"}):a.map((e,t)=>{const r=f(e.method);return s.jsxs("button",{onClick:()=>{d(e),n()},className:`flex w-full items-center justify-between gap-3 rounded-xl px-3 py-2 text-left transition ${t===o?"bg-white/10":"hover:bg-white/5"}`,children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("span",{className:`w-14 shrink-0 rounded border px-1.5 py-0.5 text-center font-mono text-[10px] font-bold ${r.bg} ${r.text} ${r.border}`,children:e.method}),s.jsx("span",{className:"truncate font-mono text-xs text-zinc-100",children:e.fullPath})]}),s.jsx("span",{className:"shrink-0 font-mono text-[10px] text-zinc-500",children:e.controller??e.file})]},e.id)})})]})}):null}export{j as SearchModal};
@@ -1,4 +1,4 @@
1
- import{j as e,a as d}from"./react-D71YmLB6.js";import{g as D}from"./index-Co71Z6SJ.js";import{X as G,F as K,S as M,x as V,T as X,A as _,B as Q,D as W,y as Y}from"./vendor-DBc_8COV.js";import"./graph-Dp3lBNo7.js";function Z(t){const f=/("(?:\\.|[^"\\])*")\s*:|("(?:\\.|[^"\\])*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|\b(true|false|null)\b/g,i=[];let c=0,l;for(;(l=f.exec(t))!==null;)l.index>c&&i.push({text:t.slice(c,l.index),cls:"text-zinc-500"}),l[1]?(i.push({text:l[1],cls:"text-sky-300"}),i.push({text:":",cls:"text-zinc-500"})):l[2]?i.push({text:l[2],cls:"text-emerald-300"}):l[3]?i.push({text:l[3],cls:"text-amber-300"}):l[4]&&i.push({text:l[4],cls:"text-violet-400"}),c=f.lastIndex;return c<t.length&&i.push({text:t.slice(c),cls:"text-zinc-500"}),i}function H({data:t}){const i=(typeof t=="string"?t:JSON.stringify(t,null,2)).split(`
1
+ import{j as e,a as d}from"./react-D71YmLB6.js";import{g as D}from"./index-CHRlXsqI.js";import{X as G,F as K,S as M,x as V,T as X,A as _,B as Q,D as W,y as Y}from"./vendor-DBc_8COV.js";import"./graph-Dp3lBNo7.js";function Z(t){const f=/("(?:\\.|[^"\\])*")\s*:|("(?:\\.|[^"\\])*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|\b(true|false|null)\b/g,i=[];let c=0,l;for(;(l=f.exec(t))!==null;)l.index>c&&i.push({text:t.slice(c,l.index),cls:"text-zinc-500"}),l[1]?(i.push({text:l[1],cls:"text-sky-300"}),i.push({text:":",cls:"text-zinc-500"})):l[2]?i.push({text:l[2],cls:"text-emerald-300"}):l[3]?i.push({text:l[3],cls:"text-amber-300"}):l[4]&&i.push({text:l[4],cls:"text-violet-400"}),c=f.lastIndex;return c<t.length&&i.push({text:t.slice(c),cls:"text-zinc-500"}),i}function H({data:t}){const i=(typeof t=="string"?t:JSON.stringify(t,null,2)).split(`
2
2
  `);return e.jsx("pre",{className:"overflow-x-auto font-mono text-[11px] leading-relaxed",children:i.map((c,l)=>e.jsx("div",{className:"whitespace-pre",children:Z(c).map((u,y)=>e.jsx(d.Fragment,{children:e.jsx("span",{className:u.cls,children:u.text})},y))},l))})}function ee(t=0){return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function re({route:t,targetBaseUrl:f,globalAuth:i,isStaticMode:c,onClose:l}){const[u,y]=d.useState({}),[w,k]=d.useState({}),[m,N]=d.useState("{}"),[$,J]=d.useState(`{
3
3
  "Content-Type": "application/json"
4
4
  }`),[j,S]=d.useState("body"),[z,E]=d.useState("pretty"),[C,P]=d.useState(!1),[a,b]=d.useState(null),[L,O]=d.useState(!1);d.useEffect(()=>{if(!t)return;const s={};for(const r of t.pathParams??[])s[r]="";y(s);const n={};for(const r of t.queryParams??[])n[r]="";if(k(n),t.bodyFields&&t.bodyFields.length>0){const r={};for(const o of t.bodyFields)r[o]="";N(JSON.stringify(r,null,2))}else N("{}");b(null),S(["POST","PUT","PATCH"].includes((t.method??"").toUpperCase())?"body":"trace")},[t]);const g=d.useMemo(()=>{if(!t)return"";let s=t.fullPath??"/";for(const[o,x]of Object.entries(u))x&&(s=s.replace(`:${o}`,encodeURIComponent(x)));const n=Object.entries(w).filter(([,o])=>o!=="").map(([o,x])=>`${encodeURIComponent(o)}=${encodeURIComponent(x)}`).join("&");return`${f.replace(/\/+$/,"")}${s}${n?`?${n}`:""}`},[t,u,w,f]),B=()=>{let s={};try{s=JSON.parse($)}catch{s={}}if(i.trim()&&!s.Authorization&&!s.authorization){const n=i.trim();s.Authorization=/\s/.test(n)?n:`Bearer ${n}`}return s},R=async()=>{if(!t||C)return;P(!0),b(null);const s=(t.method??"GET").toUpperCase(),n=B(),r=!["GET","HEAD"].includes(s)&&m.trim().length>0;let o;if(r)try{o=JSON.parse(m)}catch{o=m}try{const p=await fetch(c?g:"/api/proxy",c?{method:s,headers:n,body:r?typeof o=="string"?o:JSON.stringify(o):void 0}:{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:s,url:g,headers:n,body:o})});if(c){const h=await p.text();let v=h;try{v=JSON.parse(h)}catch{}const F={};p.headers.forEach((q,A)=>{F[A]=q}),b({status:p.status,statusText:p.statusText,durationMs:0,sizeBytes:h.length,headers:F,data:v})}else{const h=await p.json();b(h)}}catch(x){b({error:x instanceof Error?x.message:"Request failed"})}finally{P(!1)}};if(d.useEffect(()=>{if(!t)return;const s=n=>{(n.metaKey||n.ctrlKey)&&n.key==="Enter"&&(n.preventDefault(),R())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)}),!t)return null;const T=D(t.method),U=()=>{const s=(t.method??"GET").toUpperCase(),n=B(),r=Object.entries(n).map(([h,v])=>`-H '${h}: ${v}'`).join(" "),x=!["GET","HEAD"].includes(s)&&m.trim()&&m.trim()!=="{}"?`-d '${m.replace(/\n/g," ")}'`:"",p=["curl","-X",s,`'${g}'`,r,x].filter(Boolean).join(" ");navigator.clipboard.writeText(p),O(!0),setTimeout(()=>O(!1),1500)},I=a!=null&&a.status?a.status<300?"bg-emerald-500/15 text-emerald-400 border-emerald-500/30":a.status<400?"bg-amber-500/15 text-amber-400 border-amber-500/30":"bg-rose-500/15 text-rose-400 border-rose-500/30":"bg-rose-500/15 text-rose-400 border-rose-500/30";return e.jsxs("aside",{className:"pointer-events-auto fixed right-3 top-16 bottom-3 z-40 flex w-[440px] max-w-[94vw] flex-col rounded-2xl border border-white/15 bg-zinc-950/92 shadow-2xl shadow-black/80 backdrop-blur-xl",children:[e.jsxs("div",{className:"border-b border-white/10 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:`rounded-md border px-2 py-0.5 font-mono text-xs font-bold ${T.bg} ${T.text} ${T.border}`,children:t.method??"GET"}),e.jsx("span",{className:"truncate font-mono text-sm font-semibold text-zinc-100",children:t.fullPath})]}),e.jsx("button",{onClick:l,className:"rounded-lg p-1 text-zinc-400 hover:bg-white/10 hover:text-zinc-100",children:e.jsx(G,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 font-mono text-[11px] text-zinc-400",children:[e.jsx(K,{className:"h-3.5 w-3.5 text-zinc-500"}),e.jsxs("span",{className:"truncate",children:[t.controllerFile??t.file,":",t.controllerLine??t.line]})]}),t.middlewares&&t.middlewares.length>0&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1",children:t.middlewares.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-violet-500/25 bg-violet-500/10 px-1.5 py-0.5 font-mono text-[10px] text-violet-300",children:[e.jsx(M,{className:"h-2.5 w-2.5"}),s]},s))}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:g,className:"min-w-0 flex-1 rounded-lg border border-white/10 bg-zinc-900/90 px-2.5 py-1.5 font-mono text-[11px] text-zinc-200 outline-none"}),e.jsx("button",{onClick:U,title:"Copy as cURL",className:"rounded-lg border border-white/10 bg-white/5 p-2 text-zinc-300 hover:border-white/25 hover:text-zinc-100",children:L?e.jsx(V,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(X,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:R,disabled:C,title:"Send Request (Cmd+Enter)",className:"flex items-center gap-1.5 rounded-lg bg-sky-500 px-3 py-1.5 text-xs font-semibold text-zinc-950 shadow-[0_0_16px_rgba(56,189,248,0.35)] transition hover:bg-sky-400 disabled:opacity-50",children:[C?e.jsx(_,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Q,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{children:"Send"})]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[t.pathParams&&t.pathParams.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-zinc-400",children:"Path Parameters"}),e.jsx("div",{className:"space-y-1.5",children:t.pathParams.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"w-24 truncate font-mono text-xs text-amber-300",children:[":",s]}),e.jsx("input",{type:"text",value:u[s]??"",onChange:n=>y(r=>({...r,[s]:n.target.value})),placeholder:`Enter ${s}...`,className:"flex-1 rounded-lg border border-white/10 bg-zinc-900/80 px-2.5 py-1 font-mono text-xs text-zinc-100 outline-none focus:border-sky-500/60"})]},s))})]}),t.queryParams&&t.queryParams.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-zinc-400",children:"Query Parameters"}),e.jsx("div",{className:"space-y-1.5",children:t.queryParams.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"w-24 truncate font-mono text-xs text-sky-300",children:["?",s]}),e.jsx("input",{type:"text",value:w[s]??"",onChange:n=>k(r=>({...r,[s]:n.target.value})),placeholder:`Optional ${s}...`,className:"flex-1 rounded-lg border border-white/10 bg-zinc-900/80 px-2.5 py-1 font-mono text-xs text-zinc-100 outline-none focus:border-sky-500/60"})]},s))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-1 border-b border-white/10 pb-2",children:["body","headers","trace"].map(s=>e.jsx("button",{onClick:()=>S(s),className:`rounded-md px-2.5 py-1 text-xs font-medium capitalize transition ${j===s?"bg-white/10 text-zinc-100":"text-zinc-500 hover:text-zinc-300"}`,children:s==="body"?"Body (JSON)":s==="trace"?"Code Trace":"Headers"},s))}),e.jsxs("div",{className:"mt-2.5",children:[j==="body"&&e.jsx("textarea",{value:m,onChange:s=>N(s.target.value),rows:6,spellCheck:!1,className:"w-full rounded-xl border border-white/10 bg-zinc-900/90 p-3 font-mono text-xs text-zinc-100 outline-none focus:border-sky-500/60"}),j==="headers"&&e.jsxs("div",{className:"space-y-2",children:[i&&e.jsxs("div",{className:"rounded-lg border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1.5 font-mono text-[11px] text-emerald-300",children:["Global Auth active: Authorization: ",i.slice(0,28),"…"]}),e.jsx("textarea",{value:$,onChange:s=>J(s.target.value),rows:5,spellCheck:!1,className:"w-full rounded-xl border border-white/10 bg-zinc-900/90 p-3 font-mono text-xs text-zinc-100 outline-none focus:border-sky-500/60"})]}),j==="trace"&&e.jsxs("div",{className:"space-y-2 rounded-xl border border-white/10 bg-zinc-900/60 p-3 font-mono text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 text-zinc-400",children:[e.jsx(W,{className:"h-3.5 w-3.5 text-sky-400"}),e.jsxs("span",{children:["Route: ",t.file,":",t.line]})]}),t.middlewares&&t.middlewares.length>0&&e.jsxs("div",{className:"pl-5 text-violet-300",children:["↳ Middleware: [",t.middlewares.join(" → "),"]"]}),e.jsxs("div",{className:"pl-5 text-cyan-300",children:["↳ Controller: ",t.controller??"inlineHandler"," (",t.controllerFile??t.file,":",t.controllerLine??t.line,")"]})]})]})]}),a&&e.jsxs("div",{className:"rounded-xl border border-white/10 bg-zinc-900/70 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-white/10 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`rounded-md border px-2 py-0.5 font-mono text-[11px] font-bold ${I}`,children:a.status?`${a.status} ${a.statusText??""}`:"ERROR"}),a.durationMs!==void 0&&e.jsxs("span",{className:"font-mono text-[11px] text-zinc-400",children:[a.durationMs," ms"]}),a.sizeBytes!==void 0&&e.jsx("span",{className:"font-mono text-[11px] text-zinc-500",children:ee(a.sizeBytes)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>E("pretty"),className:`rounded px-2 py-0.5 text-[11px] ${z==="pretty"?"bg-white/10 text-zinc-100":"text-zinc-500"}`,children:"Body"}),e.jsx("button",{onClick:()=>E("headers"),className:`rounded px-2 py-0.5 text-[11px] ${z==="headers"?"bg-white/10 text-zinc-100":"text-zinc-500"}`,children:"Headers"}),e.jsx("button",{onClick:()=>void navigator.clipboard.writeText(JSON.stringify(a.data??a,null,2)),title:"Copy response",className:"rounded p-1 text-zinc-400 hover:bg-white/10 hover:text-zinc-100",children:e.jsx(Y,{className:"h-3 w-3"})})]})]}),e.jsx("div",{className:"mt-2.5 max-h-72 overflow-auto",children:a.error?e.jsxs("div",{className:"font-mono text-xs text-rose-400",children:[e.jsx("div",{children:a.error}),a.details&&e.jsx("div",{className:"mt-1 text-zinc-500",children:a.details})]}):z==="pretty"?e.jsx(H,{data:a.data}):e.jsx(H,{data:a.headers??{}})})]})]})]})}export{re as TesterDrawer};