UNPKG

miniflare

Version:

Fun, full-featured, fully-local simulator for Cloudflare Workers

1 lines 5.29 kB
import{t as e}from"./label-latndvb1ngem7we8-CO7sxSXt.js";import{t}from"./Breadcrumbs-CEo9kTmA.js";import{t as n}from"./table-inweecadl3her7pd-BOgC5mM4.js";import{$t as r,Bn as i,Dt as a,Gn as o,Hn as s,Jn as c,Kn as l,Ln as u,Tn as d,Tt as f,a as p,lt as m,ot as h}from"./index-BPLH0X4i.js";var g=l(),_=c(o(),1),v=e=>(0,g.jsxs)(`svg`,{width:`1em`,height:`1em`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`link-external-icon`,...e,children:[(0,g.jsx)(`path`,{d:`M9 4H8.8C7.11984 4 6.27976 4 5.63803 4.32698C5.07354 4.6146 4.6146 5.07354 4.32698 5.63803C4 6.27976 4 7.11984 4 8.8V15.2C4 16.8802 4 17.7202 4.32698 18.362C4.6146 18.9265 5.07354 19.3854 5.63803 19.673C6.27976 20 7.11984 20 8.8 20H15.2C16.8802 20 17.7202 20 18.362 19.673C18.9265 19.3854 19.3854 18.9265 19.673 18.362C20 17.7202 20 16.8802 20 15.2V15`}),(0,g.jsx)(`path`,{d:`M14 4H20M20 4V10M20 4L11 13`})]});v.displayName=`Link.ExternalIcon`;var y={variant:{inline:{classes:`text-kumo-link underline underline-offset-[0.15em] decoration-[0.0625em] link-current transition-colors`,description:`Inline text link that flows with content`},current:{classes:`text-current underline underline-offset-[0.15em] decoration-[0.0625em] link-current transition-colors`,description:`Link that inherits color from parent text`},plain:{classes:`text-kumo-link hover:text-kumo-link/70 transition-colors`,description:`Link without underline decoration`}}},b={variant:`inline`};function x({variant:e=b.variant}={}){return u(y.variant[e].classes)}var S=(0,_.forwardRef)(function({className:e,variant:t=`inline`,render:n,...i},o){let s=a(),c={className:u(x({variant:t}),`group/link inline-flex items-center gap-[0.1875em]`)};return d({render:n??(0,g.jsx)(s,{}),ref:o,props:r(c,i,{className:e})})});S.displayName=`Link`;var C=Object.assign(S,{ExternalIcon:v});function w(){let r=p.useParams(),a=p.useLoaderData(),{namespaceId:o}=a,c=s(),[l,u]=(0,_.useState)(a.cursor),[d,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(a.hasMore),[x,S]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(a.objects),[O,k]=(0,_.useState)(``);(0,_.useEffect)(()=>{D(a.objects),u(a.cursor),b(a.hasMore),v(null),S(!1),T(!1)},[a]);let A=(0,_.useCallback)(async e=>{try{e?T(!0):(S(!0),D([])),v(null);let t=await m({path:{id:o},query:{cursor:e,limit:50}}),n=t.data?.result??[];D(e?e=>[...e,...n]:n);let r=t.data?.result_info?.cursor;u(r??null),b(!!r)}catch(e){v(e instanceof Error?e.message:`Failed to fetch objects`)}finally{S(!1),T(!1)}},[o]);function j(){l&&!w&&A(l)}function M(e){e.preventDefault();let t=O.trim();t&&c({params:{className:r.className,objectId:t},search:{table:void 0},to:`/do/$className/$objectId`})}return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(t,{icon:h,items:[(0,g.jsx)(`span`,{className:`flex items-center gap-1.5`,children:r.className},`class-name`)],title:`Durable Objects`}),(0,g.jsxs)(`div`,{className:`px-6 py-6`,children:[(0,g.jsxs)(`form`,{className:`mb-6 flex items-end gap-2`,onSubmit:M,children:[(0,g.jsxs)(`div`,{className:`max-w-100 flex-1`,children:[(0,g.jsx)(e,{htmlFor:`open-instance`,tooltip:`Get an instance by its name (i.e. idFromName) or by its ID (Cloudflare-generated 64 digit hex ID)`,children:`View specific DO instance`}),(0,g.jsx)(`input`,{id:`open-instance`,className:`bg-bg text-text focus:ring-kumo-ring mt-1.5 h-9 w-full rounded-lg border border-kumo-line px-3 font-mono text-sm focus:ring focus:outline-none`,placeholder:`Enter instance name or hex ID...`,value:O,onChange:e=>k(e.target.value)})]}),(0,g.jsx)(f,{type:`submit`,variant:`secondary`,disabled:!O.trim(),children:`Open Studio`})]}),d&&(0,g.jsx)(`div`,{className:`mb-4 rounded-md border border-kumo-danger/20 bg-kumo-danger/8 p-4 text-kumo-danger`,children:d}),x?(0,g.jsx)(`div`,{className:`p-12 text-center text-kumo-subtle`,children:`Loading...`}):E.length===0?(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center space-y-2 p-12 text-center text-kumo-subtle`,children:[(0,g.jsx)(`h2`,{className:`text-2xl font-medium`,children:`No Durable Objects with stored data`}),(0,g.jsx)(`p`,{className:`text-sm font-light`,children:`Create a Durable Object with SQLite storage to see it here.`})]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-kumo-fill`,children:(0,g.jsxs)(n,{children:[(0,g.jsx)(n.Header,{children:(0,g.jsxs)(n.Row,{children:[(0,g.jsx)(n.Head,{children:`Name`}),(0,g.jsx)(n.Head,{children:`Object ID`}),(0,g.jsx)(n.Head,{})]})}),(0,g.jsx)(n.Body,{children:E.map(e=>(0,g.jsxs)(n.Row,{children:[(0,g.jsx)(n.Cell,{className:`font-mono text-xs`,children:e.name??`—`}),(0,g.jsx)(n.Cell,{className:`text-text-secondary font-mono text-xs`,children:e.id}),(0,g.jsx)(n.Cell,{className:`text-right`,children:(0,g.jsxs)(i,{className:`inline-flex h-6.5 items-center gap-1 rounded-md px-2 text-xs hover:bg-kumo-fill`,params:{className:r.className,objectId:e.id},search:{table:void 0},to:`/do/$className/$objectId`,children:[`Open Studio`,(0,g.jsx)(C.ExternalIcon,{})]})})]},e.id))})]})}),y&&(0,g.jsx)(`div`,{className:`py-4 text-center`,children:(0,g.jsx)(f,{variant:`secondary`,disabled:w,loading:w,onClick:j,children:w?`Loading...`:`Load More`})})]})]})]})}export{w as component};