meshy-node 0.9.4 → 0.9.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.
@@ -1,21 +0,0 @@
1
- import{c as T,j as e,I as ee,B as v,at as F,an as J,r as i,bE as se,bD as re,z as te,A as ne,E as ae,bF as ie,v as le,C as ce}from"./index-BubHGNBS.js";/**
2
- * @license lucide-react v1.7.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const oe=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],de=T("maximize-2",oe);/**
7
- * @license lucide-react v1.7.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const xe=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],me=T("minimize-2",xe);/**
12
- * @license lucide-react v1.7.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const ue=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],he=T("play",ue);/**
17
- * @license lucide-react v1.7.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const fe=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],pe=T("settings-2",fe),ve={getOutput:re,createPreviewSession:se};function we({taskId:s,api:n=ve,allowPortPreview:l=!1}){const[a,d]=i.useState(null),[t,m]=i.useState(null),[x,u]=i.useState(null),[h,f]=i.useState(""),[g,b]=i.useState(!1),[E,S]=i.useState(!0),[w,o]=i.useState(null),[X,z]=i.useState(!1),[R,p]=i.useState(!1),I=i.useCallback(async()=>{S(!0),o(null),d(null),m(null),u(null),p(!1);try{const r=await n.getOutput(s);d(r),S(!1)}catch(r){o(r instanceof Error?r.message:"Failed to load output"),S(!1)}},[n,s]);i.useEffect(()=>{I()},[I]);const N=i.useCallback(async r=>{o(null);try{const c=await n.createPreviewSession(s,r!=null&&r.path?{path:r.path}:void 0);m(c),b(!1),p(!1),r&&u(r)}catch(c){o(c instanceof Error?c.message:"Failed to create preview session")}},[n,s]),M=i.useCallback(async r=>{const c=r??Number.parseInt(h,10);if(!Number.isInteger(c)||c<1||c>65535){o("Enter a port between 1 and 65535");return}o(null);try{const C=await n.createPreviewSession(s,{port:c});m(C),u(null),f(String(c)),b(!0),p(!1)}catch(C){o(C instanceof Error?C.message:"Failed to create preview session")}},[n,h,s]),k=i.useMemo(()=>V(a),[a]);i.useEffect(()=>{if(g||!(a!=null&&a.available)||k.length===0||t&&t.kind!=="service")return;const r=x??k[0];r&&N(r)},[x,a,k,g,t,N]);const j=i.useCallback(()=>{if((t==null?void 0:t.kind)==="service"&&typeof t.port=="number"){M(t.port);return}m(null);const r=x??V(a)[0];r&&N(r)},[x,a,t,M,N]);if(i.useEffect(()=>{if(!t)return;const r=t.expiresAt-Date.now()-5e3;if(r<=0){j();return}const c=window.setTimeout(j,r);return()=>window.clearTimeout(c)},[j,t]),E)return e.jsx(P,{children:"Loading preview..."});const y=l&&g;if(w&&t&&!y)return e.jsx(P,{children:e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"text-[11px] text-destructive",children:w}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(v,{variant:"outline",size:"sm",onClick:j,className:"rounded-full",children:[e.jsx(F,{className:"h-3.5 w-3.5"}),"Retry"]})})]})});const L=!!(a!=null&&a.available);if(!L&&!l)return e.jsx(P,{children:"Task output is not available yet."});if(!t)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-1.5",children:e.jsx($,{session:null,serviceModeOpen:y,allowPortPreview:l,servicePort:h,previewEntries:k,activeEntry:x,filesMenuOpen:R,onRefresh:j,onFullscreen:()=>z(!0),onServiceModeToggle:()=>{p(!1),b(r=>!r)},onServicePortChange:f,onServiceStart:()=>void M(),onFileMenuToggle:()=>p(r=>!r),onEntrySelect:r=>{p(!1),N(r)}})}),y?e.jsx(A,{serviceSession:null,error:w}):e.jsx(P,{children:w?e.jsx("span",{className:"text-[11px] text-destructive",children:w}):L?k.length>0?"Starting preview session...":"No HTML or Markdown files were found in this task output.":"Task output is not available yet."})]});const U=W(t),Y=_(t),H=K(t),B=Q(t),O=t.kind==="service"?t:null,Z=y?O:t,q=e.jsx("iframe",{src:H,className:"h-full w-full border-0",sandbox:B,title:"Task Preview"});return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{className:"shrink-0 border-b border-border/60 px-3 py-1.5",children:e.jsx($,{session:Z,serviceModeOpen:y,allowPortPreview:l,servicePort:h,previewEntries:k,activeEntry:x,filesMenuOpen:R,onRefresh:j,onFullscreen:()=>z(!0),onServiceModeToggle:()=>{p(!1),b(r=>!r)},onServicePortChange:f,onServiceStart:()=>void M(),onFileMenuToggle:()=>p(r=>!r),onEntrySelect:r=>{p(!1),N(r)}})}),y?e.jsx(A,{serviceSession:O,error:w,children:O?q:null}):e.jsx("div",{className:"min-h-0 flex-1 p-2",children:e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:q})}),e.jsx(te,{open:X,onOpenChange:z,children:e.jsxs(ne,{className:"flex h-[95vh] max-w-[95vw] flex-col gap-0 overflow-hidden p-0",children:[e.jsxs(ae,{className:"sr-only",children:["Preview: ",U]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/60 px-3 py-1.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-[12px] font-semibold text-foreground",children:U}),e.jsx("span",{className:"text-xs text-muted-foreground",children:D(t.expiresAt)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:j,title:"Refresh",children:e.jsx(F,{className:"h-3.5 w-3.5"})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:Y,target:"_blank",rel:"noopener noreferrer",children:e.jsx(J,{className:"h-3.5 w-3.5"})})}),e.jsx(ie,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:"h-6 rounded-sm px-2 text-[11px]",title:"Exit fullscreen",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Exit fullscreen"]})})]})]}),e.jsx("div",{className:"min-h-0 flex-1",children:e.jsx("iframe",{src:H,className:"h-full w-full border-0",sandbox:B,title:"Task Preview Fullscreen"})})]})})]})}function V(s){var a,d;const n=((a=s==null?void 0:s.summary)==null?void 0:a.htmlEntries)??[],l=((d=s==null?void 0:s.summary)==null?void 0:d.markdownEntries)??[];return[...n.map(t=>({...t,kind:"html"})),...l.map(t=>({...t,kind:"markdown"}))]}function be({entries:s,activeEntry:n,open:l,onToggle:a,onEntrySelect:d}){const t=s[0];if(!t)return null;const m=n??t,x=G(m);return e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("button",{type:"button","aria-expanded":l,"aria-haspopup":"menu","aria-label":"Preview files",onClick:a,className:"flex h-6 max-w-[min(24rem,calc(100vw-7rem))] items-center gap-1.5 rounded-sm px-1.5 text-left text-[12px] font-semibold text-foreground transition-colors hover:bg-background/70",children:[e.jsx("span",{className:"truncate",children:m.label}),e.jsx(le,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),l&&e.jsx("div",{role:"menu","aria-label":"Preview files",className:"absolute left-0 top-full z-30 mt-1 max-h-64 min-w-[14rem] max-w-[min(28rem,calc(100vw-4rem))] overflow-y-auto rounded-sm border border-border/70 bg-popover/95 p-1 text-popover-foreground shadow-[0_16px_48px_-34px_rgba(0,0,0,0.45)] backdrop-blur-xl",children:s.map(u=>{const h=G(u),f=h===x;return e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":f,onClick:()=>d(u),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1 text-left text-[11px] leading-4 text-foreground transition-colors hover:bg-accent/75 hover:text-accent-foreground",children:[e.jsx("span",{className:"w-3.5 shrink-0 text-primary",children:f?e.jsx(ce,{className:"h-3.5 w-3.5"}):null}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:u.label})]},h)})})]})}function G(s){return`${s.kind}:${s.path}`}function $({session:s,serviceModeOpen:n,allowPortPreview:l,servicePort:a,previewEntries:d=[],activeEntry:t=null,filesMenuOpen:m=!1,onRefresh:x,onFullscreen:u,onServiceModeToggle:h,onServicePortChange:f,onServiceStart:g,onFileMenuToggle:b,onEntrySelect:E}){const S=s?_(s):null,w=!n&&d.length>0&&b&&E;return e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:n&&f&&g?e.jsxs("form",{className:"flex min-w-0 items-center gap-1.5",onSubmit:o=>{o.preventDefault(),g()},children:[e.jsx("span",{className:"shrink-0 text-[12px] font-semibold text-foreground",children:"Preview service"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:["Port",e.jsx(ee,{type:"number",min:1,max:65535,inputMode:"numeric",value:a??"",onChange:o=>f(o.target.value),placeholder:"12345","aria-label":"Service preview port",className:"h-6 w-20 rounded-sm px-2 text-[11px]"})]}),e.jsxs(v,{type:"submit",variant:"ghost",size:"sm",className:"h-6 rounded-sm border-0 bg-primary/10 px-2 text-[11px] text-primary shadow-none hover:bg-primary/15 hover:text-primary",children:[e.jsx(he,{className:"h-3.5 w-3.5"}),"Run"]}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:D(s.expiresAt)})]}):e.jsxs(e.Fragment,{children:[w?e.jsx(be,{entries:d,activeEntry:t,open:m,onToggle:b,onEntrySelect:E}):e.jsx("span",{className:"truncate text-[12px] font-semibold text-foreground",children:s?W(s):"Preview"}),s&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:D(s.expiresAt)})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:x,title:"Refresh",children:e.jsx(F,{className:"h-3.5 w-3.5"})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",asChild:!0,title:"Open in new tab",children:e.jsx("a",{href:S??s.previewUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(J,{className:"h-3.5 w-3.5"})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-sm",onClick:u,title:"Fullscreen",children:e.jsx(de,{className:"h-3.5 w-3.5"})})]}),l&&e.jsxs(v,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:h,className:"h-6 shrink-0 rounded-sm px-2 text-[11px]",children:[e.jsx(pe,{className:"h-3.5 w-3.5"}),"Advanced"]})]})]})}function A({serviceSession:s,error:n,children:l}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[n&&e.jsx("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-xs text-destructive",children:n}),e.jsx("div",{className:"min-h-0 flex-1 p-2",children:s&&l?e.jsx("div",{className:"h-full overflow-hidden rounded-sm border border-border/60 bg-white shadow-none",children:l}):e.jsx(P,{children:"No service preview running."})})]})}function _(s){return s.openUrl??s.previewUrl}function K(s){return s.kind==="service"?_(s):s.previewUrl}function Q(s){return s.kind==="service"?void 0:"allow-scripts allow-same-origin"}function W(s){if(s.kind==="service"&&typeof s.port=="number"){const n=s.entryPath?`/${s.entryPath.replace(/^\/+/,"")}`:"";return`127.0.0.1:${s.port}${n}`}return s.entryPath}function P({children:s}){return e.jsx("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:s})}function D(s){const n=Math.max(0,Math.round((s-Date.now())/1e3));if(n<60)return`${n}s`;const l=Math.floor(n/60),a=n%60;return`${l}m ${a}s`}const ge=Object.freeze(Object.defineProperty({__proto__:null,PreviewHeader:$,PreviewServicePanel:A,PreviewTab:we,getPreviewIframeSandbox:Q,getPreviewIframeSrc:K,getPreviewOpenUrl:_},Symbol.toStringTag,{value:"Module"}));export{he as P,Q as a,K as b,ge as c,_ as g};