rivet-design 0.17.0 → 0.17.1
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/package.json +2 -2
- package/src/ui/dist/assets/{LibraryApp-B2MZyxIp.js → LibraryApp-Bkawuvcq.js} +5 -5
- package/src/ui/dist/assets/{main-BId3Sa7r.js → main-BluMFKVI.js} +132 -132
- package/src/ui/dist/assets/main-DY9LzvZT.css +1 -0
- package/src/ui/dist/index.html +2 -2
- package/src/ui/dist/assets/main-1IMq5Huu.css +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivet-design",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Local visual web development tool with AI-powered code modification",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"workspaces": [
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"open": "^8.4.0",
|
|
71
71
|
"parse5": "^7.3.0",
|
|
72
72
|
"playwright-core": "^1.58.2",
|
|
73
|
-
"posthog-node": "^5.
|
|
73
|
+
"posthog-node": "^5.52.4",
|
|
74
74
|
"simple-git": "^3.19.1",
|
|
75
75
|
"typescript": "^5.1.6",
|
|
76
76
|
"zod": "^3.24.1"
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var ke=a=>{throw TypeError(a)};var ae=(a,t,e)=>t.has(a)||ke("Cannot "+e);var n=(a,t,e)=>(ae(a,t,"read from private field"),e?e.call(a):t.get(a)),R=(a,t,e)=>t.has(a)?ke("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,e),v=(a,t,e,r)=>(ae(a,t,"write to private field"),r?r.call(a,e):t.set(a,e),e),O=(a,t,e)=>(ae(a,t,"access private method"),e);import{S as qe,s as Me,h as Se,g as ze,n as V,r as Be,Q as Te,u as he,a as Ke,b as De,c as k,e as We,d as Ve,f as Ye,i as Qe,j as Oe,k as Je,l as Ge,m as Xe,o as pe,p as s,q as Ze,B as Ne,t as et,v as tt,w as Re,x as ee,y as L,z as st,A as rt,P as it,T as at,C as nt}from"./main-
|
|
2
|
-
* @license lucide-react v1.
|
|
1
|
+
var ke=a=>{throw TypeError(a)};var ae=(a,t,e)=>t.has(a)||ke("Cannot "+e);var n=(a,t,e)=>(ae(a,t,"read from private field"),e?e.call(a):t.get(a)),R=(a,t,e)=>t.has(a)?ke("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,e),v=(a,t,e,r)=>(ae(a,t,"write to private field"),r?r.call(a,e):t.set(a,e),e),O=(a,t,e)=>(ae(a,t,"access private method"),e);import{S as qe,s as Me,h as Se,g as ze,n as V,r as Be,Q as Te,u as he,a as Ke,b as De,c as k,e as We,d as Ve,f as Ye,i as Qe,j as Oe,k as Je,l as Ge,m as Xe,o as pe,p as s,q as Ze,B as Ne,t as et,v as tt,w as Re,x as ee,y as L,z as st,A as rt,P as it,T as at,C as nt}from"./main-BluMFKVI.js";var M,$,C,T,q,W,ne,Ie,ot=(Ie=class extends qe{constructor(t,e){super();R(this,q);R(this,M);R(this,$);R(this,C);R(this,T);v(this,M,t),this.setOptions(e),this.bindMethods(),O(this,q,W).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const e=this.options;this.options=n(this,M).defaultMutationOptions(t),Me(this.options,e)||n(this,M).getMutationCache().notify({type:"observerOptionsUpdated",mutation:n(this,C),observer:this}),e!=null&&e.mutationKey&&this.options.mutationKey&&Se(e.mutationKey)!==Se(this.options.mutationKey)?this.reset():((r=n(this,C))==null?void 0:r.state.status)==="pending"&&n(this,C).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&n(this,C)&&(n(this,C).addObserver(this),O(this,q,W).call(this))}onUnsubscribe(){var t;this.hasListeners()||(t=n(this,C))==null||t.removeObserver(this)}onMutationUpdate(t){O(this,q,W).call(this),O(this,q,ne).call(this,t)}getCurrentResult(){return n(this,$)}reset(){var t;(t=n(this,C))==null||t.removeObserver(this),v(this,C,void 0),O(this,q,W).call(this),O(this,q,ne).call(this)}mutate(t,e){var r;return v(this,T,e),(r=n(this,C))==null||r.removeObserver(this),v(this,C,n(this,M).getMutationCache().build(n(this,M),this.options)),n(this,C).addObserver(this),n(this,C).execute(t)}},M=new WeakMap,$=new WeakMap,C=new WeakMap,T=new WeakMap,q=new WeakSet,W=function(){var e;const t=((e=n(this,C))==null?void 0:e.state)??ze();v(this,$,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},ne=function(t){V.batch(()=>{var e,r,o,c,d,h,x,N;if(n(this,T)&&this.hasListeners()){const b=n(this,$).variables,m=n(this,$).context,f={client:n(this,M),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(e=n(this,T)).onSuccess)==null||r.call(e,t.data,b,m,f)}catch(g){Promise.reject(g)}try{(c=(o=n(this,T)).onSettled)==null||c.call(o,t.data,null,b,m,f)}catch(g){Promise.reject(g)}}else if((t==null?void 0:t.type)==="error"){try{(h=(d=n(this,T)).onError)==null||h.call(d,t.error,b,m,f)}catch(g){Promise.reject(g)}try{(N=(x=n(this,T)).onSettled)==null||N.call(x,void 0,t.error,b,m,f)}catch(g){Promise.reject(g)}}}this.listeners.forEach(b=>{b(n(this,$))})})},Ie);function Ce(a,t){const e=new Set(t);return a.filter(r=>!e.has(r))}var K,P,D,H,_,U,Y,J,G,X,S,oe,le,Ae,ce,de,ue,Le,lt=(Le=class extends qe{constructor(t,e,r){super();R(this,S);R(this,K);R(this,P);R(this,D);R(this,H);R(this,_);R(this,U);R(this,Y);R(this,J);R(this,G);R(this,X,[]);v(this,K,t),v(this,H,r),v(this,D,[]),v(this,_,[]),v(this,P,[]),this.setQueries(e)}onSubscribe(){this.listeners.size===1&&n(this,_).forEach(t=>{t.subscribe(e=>{O(this,S,de).call(this,t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,n(this,_).forEach(t=>{t.destroy()})}setQueries(t,e){v(this,D,t),v(this,H,e),V.batch(()=>{const r=n(this,_),o=O(this,S,ce).call(this,n(this,D));o.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const c=o.map(m=>m.observer),d=c.map(m=>m.getCurrentResult()),h=r.length!==c.length,x=c.some((m,f)=>m!==r[f]),N=h||x,b=N?!0:d.some((m,f)=>{const g=n(this,P)[f];return!g||!Me(m,g)});!N&&!b||(N&&(v(this,X,o),v(this,_,c)),v(this,P,d),this.hasListeners()&&(N&&(Ce(r,c).forEach(m=>{m.destroy()}),Ce(c,r).forEach(m=>{m.subscribe(f=>{O(this,S,de).call(this,m,f)})})),O(this,S,ue).call(this)))})}getCurrentResult(){return n(this,P)}getQueries(){return n(this,_).map(t=>t.getCurrentQuery())}getObservers(){return n(this,_)}getOptimisticResult(t,e){const r=O(this,S,ce).call(this,t),o=r.map(d=>d.observer.getOptimisticResult(d.defaultedQueryOptions)),c=r.map(d=>d.defaultedQueryOptions.queryHash);return[o,d=>O(this,S,le).call(this,d??o,e,c),()=>O(this,S,oe).call(this,o,r)]}},K=new WeakMap,P=new WeakMap,D=new WeakMap,H=new WeakMap,_=new WeakMap,U=new WeakMap,Y=new WeakMap,J=new WeakMap,G=new WeakMap,X=new WeakMap,S=new WeakSet,oe=function(t,e){const r=new Set;return e.map((o,c)=>{const d=t[c];return o.defaultedQueryOptions.notifyOnChangeProps?d:o.observer.trackResult(d,h=>{r.has(h)||(r.add(h),e.forEach(x=>{x.observer.trackProp(h)}))})})},le=function(t,e,r){if(e){const o=n(this,G),c=r!==void 0&&o!==void 0&&(o.length!==r.length||r.some((d,h)=>d!==o[h]));return(n(this,P)!==n(this,J)||c||e!==n(this,Y))&&(v(this,Y,e),v(this,J,n(this,P)),r!==void 0&&v(this,G,r),v(this,U,Be(n(this,U),e(t)))),n(this,U)}return t},Ae=function(){var t;return!((t=n(this,H))!=null&&t.combine)||n(this,_).some((e,r)=>{var o;return e.options.suspense&&((o=n(this,P)[r])==null?void 0:o.data)===void 0})},ce=function(t){const e=new Map;n(this,_).forEach(o=>{const c=o.options.queryHash;if(!c)return;const d=e.get(c);d?d.push(o):e.set(c,[o])});const r=[];return t.forEach(o=>{var h;const c=n(this,K).defaultQueryOptions(o),d=((h=e.get(c.queryHash))==null?void 0:h.shift())??new Te(n(this,K),c);r.push({defaultedQueryOptions:c,observer:d})}),r},de=function(t,e){const r=n(this,_).indexOf(t);r!==-1&&(v(this,P,n(this,P).slice()),n(this,P)[r]=e,O(this,S,ue).call(this))},ue=function(){var t;if(this.hasListeners()){const e=O(this,S,Ae).call(this),r=n(this,U),o=e?r:O(this,S,le).call(this,O(this,S,oe).call(this,n(this,P),n(this,X)),(t=n(this,H))==null?void 0:t.combine);(e||r!==o)&&V.batch(()=>{this.listeners.forEach(c=>{c(n(this,P))})})}},Le);function ct({queries:a,...t},e){const r=he(),o=Ke(),c=De(),d=t.subscribed!==!1,h=k.useMemo(()=>a.map(l=>{const u=r.defaultQueryOptions(l);return u._optimisticResults=o?"isRestoring":d?"optimistic":void 0,u}),[a,r,o,d]);h.forEach(l=>{We(l);const u=r.getQueryCache().get(l.queryHash);Ve(l,c,u)}),Ye(c);const[x]=k.useState(()=>new lt(r,h,t)),[N,b,m]=x.getOptimisticResult(h,t.combine),f=!o&&d;k.useSyncExternalStore(k.useCallback(l=>f?x.subscribe(V.batchCalls(l)):Qe,[x,f]),()=>x.getCurrentResult(),()=>x.getCurrentResult()),k.useEffect(()=>{x.setQueries(h,t)},[h,t,x]);const g=N.some((l,u)=>Oe(h[u],l))?N.flatMap((l,u)=>{const w=h[u];if(w&&Oe(w,l)){const E=new Te(r,w);return Je(w,E,c)}return[]}):[];if(g.length>0)throw Promise.all(g);const I=N.find((l,u)=>{const w=h[u];return w&&Ge({result:l,errorResetBoundary:c,throwOnError:w.throwOnError,query:r.getQueryCache().get(w.queryHash),suspense:w.suspense})});if(I)throw I.error;return b(m())}function Pe(a,t){const e=he(),[r]=k.useState(()=>new ot(e,a));k.useEffect(()=>{r.setOptions(a)},[r,a]);const o=k.useSyncExternalStore(k.useCallback(d=>r.subscribe(V.batchCalls(d)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),c=k.useCallback((...d)=>{r.mutate(d[0],d[1]).catch(Qe)},[r]);if(o.error&&Xe(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:c,mutateAsync:o.mutate}}/**
|
|
2
|
+
* @license lucide-react v1.47.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/const Fe={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};Fe.node;const dt=pe(Fe);/**
|
|
7
|
-
* @license lucide-react v1.
|
|
7
|
+
* @license lucide-react v1.47.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/const $e={name:"folder-open",size:24,node:[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]};$e.node;const Ee=pe($e);/**
|
|
12
|
-
* @license lucide-react v1.
|
|
12
|
+
* @license lucide-react v1.47.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const He={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};He.node;const ut=pe(He),ht=({projects:a,variants:t,historyError:e,onRetryHistory:r,projectPreviews:o={},selectedProjectId:c,onSelectProject:d,onBrowseLibrary:h,onOpenProject:x,isOpeningProject:N=!1,projectOpenError:b,onSearchCompleted:m,accountMenu:f,children:g})=>{const[I,l]=k.useState(""),u=a.find(y=>y.id===c),w=a.filter(y=>y.name.toLowerCase().includes(I.toLowerCase())),E=new Map;for(const{projectId:y}of t??[])E.set(y,(E.get(y)??0)+1);return s.jsx("div",{className:"ph-no-capture bg-background text-foreground flex h-screen min-h-0","data-rivet-private":!0,children:s.jsxs("main",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden",children:[b?s.jsx("p",{role:"alert",className:"px-10 pt-5 text-xs text-red-200",children:b}):null,g!==void 0?g:s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 py-10 max-sm:px-5",children:[s.jsxs("div",{className:"mb-10 flex items-center justify-between",children:[s.jsx("button",{onClick:h,"aria-label":"Projects",className:"flex items-center",children:s.jsx("img",{src:Ze,alt:"","aria-hidden":!0,draggable:!1,className:"h-8 w-8"})}),s.jsx(Ne,{onClick:()=>x(),variant:"secondary",disabled:N,leadingIcon:Ee,children:"Open project…"})]}),s.jsxs("header",{className:"mb-9 flex flex-wrap items-end justify-between gap-5",children:[s.jsx("div",{children:s.jsx("h1",{className:"text-[26px] font-medium tracking-[-0.035em]",children:"Projects"})}),s.jsxs("label",{className:"flex w-64 items-center gap-2 rounded-lg border border-white/[0.08] bg-white/[0.02] px-3 py-2.5 text-white/35",children:[s.jsx(et,{size:14,"aria-hidden":!0}),s.jsx("input",{onBlur:()=>m==null?void 0:m(I.length),type:"search","aria-label":"Search projects",placeholder:"Search projects…",value:I,onChange:y=>l(y.target.value),className:"min-w-0 flex-1 bg-transparent text-xs text-white outline-none placeholder:text-white/30 [&::-webkit-search-cancel-button]:hidden"})]})]}),e?s.jsxs("div",{role:"alert",className:"mb-6 flex items-center gap-3 text-xs text-white/60",children:[s.jsx("span",{children:e}),s.jsx("button",{onClick:r,className:"shrink-0 underline underline-offset-4",children:"Retry history"})]}):null,u!=null&&u.issue?s.jsx("p",{role:"alert",className:"mb-6 rounded-lg border border-amber-200/10 bg-amber-200/[0.03] p-4 text-xs leading-6 text-white/70",children:u.issue}):null,u&&!u.isAvailable?s.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4 rounded-lg border border-amber-200/10 bg-amber-200/[0.03] p-4 text-xs text-white/60",children:[s.jsxs("span",{children:["Locate ",u.name,"’s working folder to open its workspace."]}),s.jsx("button",{disabled:N,onClick:()=>x(u.id),className:"shrink-0 text-white underline decoration-white/30 underline-offset-4",children:"Locate folder"})]}):null,s.jsxs("div",{className:"grid items-start gap-x-6 gap-y-8 sm:grid-cols-2",children:[w.map(y=>{const Q=E.get(y.id)??0;let A="Loading variants…";t?A=`${Q.toLocaleString()} ${Q===1?"variant":"variants"}`:e&&(A="Variants unavailable");const F=o[y.id];return s.jsxs("button",{onClick:()=>{l(""),d(y.id)},className:"group -m-2 min-w-0 rounded-2xl p-2 text-left hover:bg-white/[0.06] focus-visible:bg-white/[0.06] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-white/60",children:[s.jsx("span",{className:"relative block aspect-video overflow-hidden rounded-xl border border-white/[0.08] bg-white/[0.02] group-hover:border-white/50 group-hover:ring-2 group-hover:ring-white/30",children:F?s.jsx("img",{src:F.dataUrl,alt:`${y.name} — ${F.label}`,draggable:!1,className:"h-full w-full object-cover object-top"}):null}),s.jsxs("span",{className:"mt-3 block",children:[s.jsx("span",{className:"block truncate text-sm font-medium",children:y.name}),s.jsxs("span",{className:"mt-2 flex min-w-0 items-center justify-between gap-3 text-xs text-white/40 group-hover:text-white/65 group-focus-visible:text-white/65",children:[s.jsx("span",{className:"shrink-0",children:A}),F?s.jsx("span",{className:"truncate",title:F.label,children:F.label}):null]}),y.isAvailable?null:s.jsx("span",{className:"mt-2 block text-xs text-amber-200/65",children:"Folder unavailable"})]})]},y.id)}),w.length===0?s.jsxs("div",{className:"col-span-full flex min-h-80 flex-col items-center justify-center rounded-xl border border-dashed border-white/10 px-8 text-center",children:[s.jsx(Ee,{size:26,className:"mb-5 text-white/25"}),s.jsx("h2",{className:"text-sm font-medium",children:I?"No matching projects":"Your projects start here"}),s.jsx("p",{className:"mt-2 max-w-sm text-xs leading-6 text-white/40",children:I?"Try another project name.":"Open an existing project once to bring its saved explorations here. Projects you open or create with Rivet appear automatically after that."}),I?null:s.jsx(Ne,{onClick:()=>x(),variant:"secondary",disabled:N,className:"mt-5",children:"Open project"})]}):null]})]}),(c===null||g===void 0)&&f?s.jsx("footer",{className:"border-main-border bg-main-light shrink-0 border-t px-2.5 py-1.5",children:f}):null]})})},_e=2500,pt=500,mt=6e4,bt=[],xt=[],te=({error:a,retry:t})=>s.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[s.jsx("p",{className:"text-sm text-white/70",children:a.message}),s.jsx("button",{onClick:t,className:"mt-5 rounded-lg border border-white/15 px-4 py-2 text-xs text-white/70",children:"Try again"})]}),vt=()=>{var fe,we,ve,ye,ge,je;const a=tt(),t=he(),[e,r]=k.useState(()=>Re(new URL(window.location.href))),[o]=k.useState(()=>crypto.randomUUID()),c=k.useRef(0),d=k.useRef(null),h=ee({queryKey:["project-library","projects"],queryFn:({signal:i})=>L("/projects",{signal:i}),refetchInterval:_e,retry:!1}),x=((fe=h.data)==null?void 0:fe.projects)??bt,N=x.map(({id:i,projectPath:p})=>({id:i,projectPath:p})).sort((i,p)=>i.id.localeCompare(p.id)),b=ee({queryKey:["project-library","history",N],queryFn:({signal:i})=>L("",{signal:i}),enabled:x.length>0,refetchInterval:_e,retry:!1}),m=new Map((we=b.data)==null?void 0:we.projects.map(i=>[i.id,i.issue])),f=x.map(i=>({...i,issue:i.issue??m.get(i.id)})),g=((ve=b.data)==null?void 0:ve.variants)??xt,I=ct({queries:f.map(i=>({queryKey:["library-project-preview",i.id,i.projectPath],queryFn:({signal:p})=>L(`/projects/${i.id}/thumbnail`,{signal:p}),enabled:e.kind==="library",refetchInterval:mt,retry:!1}))}),l=f.find(i=>i.id===e.projectId),u=g.find(i=>i.projectId===e.projectId&&i.sessionId===e.sessionId&&i.variantId===e.variantId),w=k.useCallback(i=>{window.history.pushState(null,"",st(i)),r(i)},[]);k.useEffect(()=>{const i=()=>r(Re(new URL(window.location.href)));return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]),k.useEffect(()=>{const i=new AbortController;let p;const j=async()=>{try{const z=await L(`/views/${o}`,{method:"PUT",body:{isFocused:document.visibilityState==="visible"&&document.hasFocus()},signal:i.signal});for(const B of z.navigations){if(i.signal.aborted)return;if(B.sequence>c.current){let ie="library";B.projectId&&(ie="workspace"),B.variantId&&(ie="preview"),w({...B,kind:ie}),c.current=B.sequence}await L(`/views/${o}/acknowledgements`,{method:"POST",body:{sequence:B.sequence},signal:i.signal})}}catch{}i.signal.aborted||(p=setTimeout(()=>{j()},pt))};return j(),()=>{i.abort(),clearTimeout(p)}},[o,w]);const E=ee({queryKey:["library-workspace",e.projectId],queryFn:()=>L(`/projects/${e.projectId}/runtime`,{method:"POST"}),enabled:e.kind==="workspace"&&!!e.projectId&&(l==null?void 0:l.isAvailable)===!0,retry:!1,refetchOnWindowFocus:!1}),y=E.data?new URL(E.data.editorUrl).origin:null;k.useEffect(()=>{if(e.kind!=="workspace"||!y)return;const i=p=>{!d.current||p.source!==d.current.contentWindow||p.origin!==y||p.data!==nt||(a==null||a.capture("library_view_changed",{view:"projects"}),w({kind:"library"}))};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e.kind,y,w,a]);const Q=ee({queryKey:["library-preview",e.projectId,e.sessionId,e.variantId],queryFn:()=>L(`/projects/${e.projectId}/variants/${e.sessionId}/${e.variantId}/preview`,{method:"POST"}),enabled:e.kind==="preview"&&!!(u!=null&&u.hasStaticPreview),retry:!1,refetchOnWindowFocus:!1}),A=Pe({mutationFn:i=>L(`/projects/${e.projectId}/variants/${e.sessionId}/${e.variantId}`,{method:"PATCH",body:{label:i}}),onSuccess:()=>t.invalidateQueries({queryKey:["project-library"]})}),F=i=>{const p=f.find(j=>j.id===i);a==null||a.capture("library_project_selected",{project_id:i,workspace_available:(p==null?void 0:p.isAvailable)??!1}),w({kind:"workspace",projectId:i})},Z=Pe({mutationFn:async i=>{const{projectPath:p}=await L("/folder-selections",{method:"POST"});return p===null?null:L(i?`/projects/${i}/workspace`:"/projects",{method:i?"PATCH":"POST",body:{projectPath:p}})},onSuccess:i=>{i&&(t.invalidateQueries({queryKey:["project-library"]}),a==null||a.capture("library_project_selected",{project_id:i.project.id,workspace_available:i.project.isAvailable}),w({kind:"workspace",projectId:i.project.id}))},onSettled:(i,p,j)=>{a==null||a.capture("library_open_project_closed",{is_relink:!!j})}}),Ue=i=>{Z.isPending||(a==null||a.capture("library_open_project_opened",{is_relink:!!i}),Z.mutate(i))},se=()=>{a==null||a.capture("library_view_changed",{view:"projects"}),w({kind:"library"})},me=()=>{a==null||a.capture("library_view_changed",{view:"workspace"}),w({...e,kind:"workspace"})},be=()=>{a==null||a.capture("library_history_retry"),b.refetch()};let xe;if(e.kind!=="library"&&(l==null?void 0:l.isAvailable)!==!1||e.kind==="preview"){let i=!1,p=s.jsxs("div",{className:"m-auto flex items-center gap-2 text-xs text-white/40",children:[s.jsx(ut,{size:14,className:"animate-spin"}),"Opening ",(l==null?void 0:l.name)??"project","…"]});if(h.data&&!l||b.data&&e.variantId&&!u)p=s.jsx("div",{className:"m-auto text-sm text-white/60",children:"This project or direction is no longer in your library."});else if(e.kind==="preview"&&b.error&&!b.data)p=s.jsx(te,{error:b.error,retry:be});else if(e.kind==="workspace"&&E.error)p=s.jsx(te,{error:E.error,retry:()=>{E.refetch()}});else if(e.kind==="workspace"&&E.data){i=!0;const j=new URL(E.data.editorUrl);j.searchParams.set("library","1"),j.searchParams.set("libraryOrigin",window.location.origin),e.sessionId&&e.variantId&&(j.searchParams.set("historySession",e.sessionId),j.searchParams.set("historyVariant",e.variantId)),p=s.jsx("iframe",{ref:d,title:`${(l==null?void 0:l.name)??"Project"} workspace`,src:j.toString(),className:"min-h-0 w-full flex-1 border-0",allow:"clipboard-write"},j.toString())}else e.kind==="preview"&&Q.error?p=s.jsx(te,{error:Q.error,retry:()=>{Q.refetch()}}):e.kind==="preview"&&Q.data?p=s.jsx("iframe",{title:`${(u==null?void 0:u.label)??"Saved direction"} preview`,src:Q.data.url,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",className:"min-h-0 w-full flex-1 border-0 bg-white"}):e.kind==="preview"&&u&&!u.hasStaticPreview&&(p=s.jsxs("div",{className:"m-auto max-w-sm text-center",children:[s.jsx("p",{className:"text-sm",children:u.hasInteractivePreview?"Open this direction in its workspace":"This direction contains saved code changes"}),s.jsx("p",{className:"mt-2 text-xs leading-6 text-white/40",children:u.hasInteractivePreview?"Rivet will start the preview with this project’s dependencies and configuration.":"Open the project to continue working with its saved history."}),s.jsx("button",{onClick:me,disabled:(l==null?void 0:l.isAvailable)===!1,className:"mt-5 rounded-lg bg-white px-4 py-2.5 text-xs font-medium text-black disabled:opacity-30",children:"Open workspace"})]}));xe=s.jsxs(s.Fragment,{children:[e.kind==="preview"?s.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-white/[0.07] px-5",children:[s.jsx("button",{"aria-label":"Back to projects",onClick:se,className:"rounded p-1.5 text-white/45 hover:bg-white/5",children:s.jsx(rt,{size:15})}),s.jsx("span",{className:"text-xs text-white/40",children:l==null?void 0:l.name}),u?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-white/20",children:"/"}),s.jsxs("form",{onSubmit:j=>{j.preventDefault();const z=new FormData(j.currentTarget);A.mutate(String(z.get("label")))},className:"flex min-w-0 flex-1 gap-2",children:[s.jsx("input",{name:"label","aria-label":"Direction name",defaultValue:u.label,className:"max-w-xs min-w-0 flex-1 bg-transparent text-xs text-white/80 outline-none"}),s.jsx("button",{disabled:A.isPending,className:"text-[10px] text-white/30 hover:text-white",children:"Rename"})]},`${u.projectId}:${u.variantId}`)]}):s.jsx("span",{className:"flex-1"}),e.kind==="preview"?s.jsxs("button",{onClick:me,disabled:(l==null?void 0:l.isAvailable)===!1,className:"flex items-center gap-1.5 rounded-md border border-white/10 px-3 py-1.5 text-[11px] text-white/70 disabled:opacity-30",children:["Edit in project",s.jsx(dt,{size:12})]}):null]}):null,e.kind==="workspace"&&!i?s.jsx("button",{onClick:se,className:"absolute top-5 left-5 rounded px-2 py-1 text-xs text-white/50 hover:bg-white/5 hover:text-white",children:"Projects"}):null,A.error?s.jsx("p",{role:"alert",className:"px-5 py-2 text-xs text-red-200",children:A.error.message}):null,p]})}let re=xe;return h.error&&!h.data?re=s.jsx(te,{error:h.error,retry:()=>{h.refetch()}}):h.isPending&&(re=s.jsx("div",{role:"status",className:"m-auto text-xs text-white/40",children:"Loading projects…"})),s.jsxs(s.Fragment,{children:[s.jsx(ht,{projects:f,variants:(ye=b.data)==null?void 0:ye.variants,historyError:(ge=b.error)==null?void 0:ge.message,onRetryHistory:be,projectPreviews:Object.fromEntries(f.map((i,p)=>{var j,z;return[i.id,(z=(j=I[p])==null?void 0:j.data)==null?void 0:z.preview]})),selectedProjectId:e.projectId??null,onSelectProject:F,onBrowseLibrary:se,onOpenProject:Ue,accountMenu:s.jsx(it,{side:"top",align:"start"}),isOpeningProject:Z.isPending,projectOpenError:(je=Z.error)==null?void 0:je.message,onSearchCompleted:i=>a==null?void 0:a.capture("library_search_completed",{query_length:i}),children:re}),s.jsx(at,{position:"bottom-right",theme:"dark"})]})};export{vt as default};
|
|
16
|
+
*/const He={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};He.node;const ut=pe(He),ht=({projects:a,variants:t,historyError:e,onRetryHistory:r,projectPreviews:o={},selectedProjectId:c,onSelectProject:d,onBrowseLibrary:h,onOpenProject:x,isOpeningProject:N=!1,projectOpenError:b,onSearchCompleted:m,accountMenu:f,children:g})=>{const[I,l]=k.useState(""),u=a.find(y=>y.id===c),w=a.filter(y=>y.name.toLowerCase().includes(I.toLowerCase())),E=new Map;for(const{projectId:y}of t??[])E.set(y,(E.get(y)??0)+1);return s.jsx("div",{className:"ph-no-capture bg-background text-foreground flex h-screen min-h-0","data-rivet-private":!0,children:s.jsxs("main",{className:"relative flex min-w-0 flex-1 flex-col overflow-hidden",children:[b?s.jsx("p",{role:"alert",className:"px-10 pt-5 text-xs text-red-200",children:b}):null,g!==void 0?g:s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-10 py-10 max-sm:px-5",children:[s.jsxs("div",{className:"mb-10 flex items-center justify-between",children:[s.jsx("button",{onClick:h,"aria-label":"Projects",className:"flex items-center",children:s.jsx("img",{src:Ze,alt:"","aria-hidden":!0,draggable:!1,className:"h-8 w-8"})}),s.jsx(Ne,{onClick:()=>x(),variant:"secondary",disabled:N,leadingIcon:Ee,children:"Open project…"})]}),s.jsxs("header",{className:"mb-9 flex flex-wrap items-end justify-between gap-5",children:[s.jsx("div",{children:s.jsx("h1",{className:"text-[26px] font-medium tracking-[-0.035em]",children:"Projects"})}),s.jsxs("label",{className:"flex w-64 items-center gap-2 rounded-lg border border-white/[0.08] bg-white/[0.02] px-3 py-2.5 text-white/35",children:[s.jsx(et,{size:14,"aria-hidden":!0}),s.jsx("input",{onBlur:()=>m==null?void 0:m(I.length),type:"search","aria-label":"Search projects",placeholder:"Search projects…",value:I,onChange:y=>l(y.target.value),className:"min-w-0 flex-1 bg-transparent text-xs text-white outline-none placeholder:text-white/30 [&::-webkit-search-cancel-button]:hidden"})]})]}),e?s.jsxs("div",{role:"alert",className:"mb-6 flex items-center gap-3 text-xs text-white/60",children:[s.jsx("span",{children:e}),s.jsx("button",{onClick:r,className:"shrink-0 underline underline-offset-4",children:"Retry history"})]}):null,u!=null&&u.issue?s.jsx("p",{role:"alert",className:"mb-6 rounded-lg border border-amber-200/10 bg-amber-200/[0.03] p-4 text-xs leading-6 text-white/70",children:u.issue}):null,u&&!u.isAvailable?s.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4 rounded-lg border border-amber-200/10 bg-amber-200/[0.03] p-4 text-xs text-white/60",children:[s.jsxs("span",{children:["Locate ",u.name,"’s working folder to open its workspace."]}),s.jsx("button",{disabled:N,onClick:()=>x(u.id),className:"shrink-0 text-white underline decoration-white/30 underline-offset-4",children:"Locate folder"})]}):null,s.jsxs("div",{className:"grid items-start gap-x-6 gap-y-8 sm:grid-cols-2",children:[w.map(y=>{const Q=E.get(y.id)??0;let A="Loading variants…";t?A=`${Q.toLocaleString()} ${Q===1?"variant":"variants"}`:e&&(A="Variants unavailable");const F=o[y.id];return s.jsxs("button",{onClick:()=>{l(""),d(y.id)},className:"group -m-2 min-w-0 rounded-2xl p-2 text-left hover:bg-white/[0.06] focus-visible:bg-white/[0.06] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-white/60",children:[s.jsx("span",{className:"relative block aspect-video overflow-hidden rounded-xl border border-white/[0.08] bg-white/[0.02] group-hover:border-white/50 group-hover:ring-2 group-hover:ring-white/30",children:F?s.jsx("img",{src:F.dataUrl,alt:`${y.name} — ${F.label}`,draggable:!1,className:"h-full w-full object-cover object-top"}):null}),s.jsxs("span",{className:"mt-3 block",children:[s.jsx("span",{className:"block truncate text-sm font-medium",children:y.name}),s.jsxs("span",{className:"mt-2 flex min-w-0 items-center justify-between gap-3 text-xs text-white/40 group-hover:text-white/65 group-focus-visible:text-white/65",children:[s.jsx("span",{className:"shrink-0",children:A}),F?s.jsx("span",{className:"truncate",title:F.label,children:F.label}):null]}),y.isAvailable?null:s.jsx("span",{className:"mt-2 block text-xs text-amber-200/65",children:"Folder unavailable"})]})]},y.id)}),w.length===0?s.jsxs("div",{className:"col-span-full flex min-h-80 flex-col items-center justify-center rounded-xl border border-dashed border-white/10 px-8 text-center",children:[s.jsx(Ee,{size:26,className:"mb-5 text-white/25"}),s.jsx("h2",{className:"text-sm font-medium",children:I?"No matching projects":"Your projects start here"}),s.jsx("p",{className:"mt-2 max-w-sm text-xs leading-6 text-white/40",children:I?"Try another project name.":"Open an existing project once to bring its saved explorations here. Projects you open or create with Rivet appear automatically after that."}),I?null:s.jsx(Ne,{onClick:()=>x(),variant:"secondary",disabled:N,className:"mt-5",children:"Open project"})]}):null]})]}),(c===null||g===void 0)&&f?s.jsx("footer",{className:"border-main-border bg-main-light shrink-0 border-t px-2.5 py-2.5",children:f}):null]})})},_e=2500,pt=500,mt=6e4,bt=[],xt=[],te=({error:a,retry:t})=>s.jsxs("div",{className:"m-auto max-w-md px-8 text-center",children:[s.jsx("p",{className:"text-sm text-white/70",children:a.message}),s.jsx("button",{onClick:t,className:"mt-5 rounded-lg border border-white/15 px-4 py-2 text-xs text-white/70",children:"Try again"})]}),vt=()=>{var fe,we,ve,ye,ge,je;const a=tt(),t=he(),[e,r]=k.useState(()=>Re(new URL(window.location.href))),[o]=k.useState(()=>crypto.randomUUID()),c=k.useRef(0),d=k.useRef(null),h=ee({queryKey:["project-library","projects"],queryFn:({signal:i})=>L("/projects",{signal:i}),refetchInterval:_e,retry:!1}),x=((fe=h.data)==null?void 0:fe.projects)??bt,N=x.map(({id:i,projectPath:p})=>({id:i,projectPath:p})).sort((i,p)=>i.id.localeCompare(p.id)),b=ee({queryKey:["project-library","history",N],queryFn:({signal:i})=>L("",{signal:i}),enabled:x.length>0,refetchInterval:_e,retry:!1}),m=new Map((we=b.data)==null?void 0:we.projects.map(i=>[i.id,i.issue])),f=x.map(i=>({...i,issue:i.issue??m.get(i.id)})),g=((ve=b.data)==null?void 0:ve.variants)??xt,I=ct({queries:f.map(i=>({queryKey:["library-project-preview",i.id,i.projectPath],queryFn:({signal:p})=>L(`/projects/${i.id}/thumbnail`,{signal:p}),enabled:e.kind==="library",refetchInterval:mt,retry:!1}))}),l=f.find(i=>i.id===e.projectId),u=g.find(i=>i.projectId===e.projectId&&i.sessionId===e.sessionId&&i.variantId===e.variantId),w=k.useCallback(i=>{window.history.pushState(null,"",st(i)),r(i)},[]);k.useEffect(()=>{const i=()=>r(Re(new URL(window.location.href)));return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]),k.useEffect(()=>{const i=new AbortController;let p;const j=async()=>{try{const z=await L(`/views/${o}`,{method:"PUT",body:{isFocused:document.visibilityState==="visible"&&document.hasFocus()},signal:i.signal});for(const B of z.navigations){if(i.signal.aborted)return;if(B.sequence>c.current){let ie="library";B.projectId&&(ie="workspace"),B.variantId&&(ie="preview"),w({...B,kind:ie}),c.current=B.sequence}await L(`/views/${o}/acknowledgements`,{method:"POST",body:{sequence:B.sequence},signal:i.signal})}}catch{}i.signal.aborted||(p=setTimeout(()=>{j()},pt))};return j(),()=>{i.abort(),clearTimeout(p)}},[o,w]);const E=ee({queryKey:["library-workspace",e.projectId],queryFn:()=>L(`/projects/${e.projectId}/runtime`,{method:"POST"}),enabled:e.kind==="workspace"&&!!e.projectId&&(l==null?void 0:l.isAvailable)===!0,retry:!1,refetchOnWindowFocus:!1}),y=E.data?new URL(E.data.editorUrl).origin:null;k.useEffect(()=>{if(e.kind!=="workspace"||!y)return;const i=p=>{!d.current||p.source!==d.current.contentWindow||p.origin!==y||p.data!==nt||(a==null||a.capture("library_view_changed",{view:"projects"}),w({kind:"library"}))};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e.kind,y,w,a]);const Q=ee({queryKey:["library-preview",e.projectId,e.sessionId,e.variantId],queryFn:()=>L(`/projects/${e.projectId}/variants/${e.sessionId}/${e.variantId}/preview`,{method:"POST"}),enabled:e.kind==="preview"&&!!(u!=null&&u.hasStaticPreview),retry:!1,refetchOnWindowFocus:!1}),A=Pe({mutationFn:i=>L(`/projects/${e.projectId}/variants/${e.sessionId}/${e.variantId}`,{method:"PATCH",body:{label:i}}),onSuccess:()=>t.invalidateQueries({queryKey:["project-library"]})}),F=i=>{const p=f.find(j=>j.id===i);a==null||a.capture("library_project_selected",{project_id:i,workspace_available:(p==null?void 0:p.isAvailable)??!1}),w({kind:"workspace",projectId:i})},Z=Pe({mutationFn:async i=>{const{projectPath:p}=await L("/folder-selections",{method:"POST"});return p===null?null:L(i?`/projects/${i}/workspace`:"/projects",{method:i?"PATCH":"POST",body:{projectPath:p}})},onSuccess:i=>{i&&(t.invalidateQueries({queryKey:["project-library"]}),a==null||a.capture("library_project_selected",{project_id:i.project.id,workspace_available:i.project.isAvailable}),w({kind:"workspace",projectId:i.project.id}))},onSettled:(i,p,j)=>{a==null||a.capture("library_open_project_closed",{is_relink:!!j})}}),Ue=i=>{Z.isPending||(a==null||a.capture("library_open_project_opened",{is_relink:!!i}),Z.mutate(i))},se=()=>{a==null||a.capture("library_view_changed",{view:"projects"}),w({kind:"library"})},me=()=>{a==null||a.capture("library_view_changed",{view:"workspace"}),w({...e,kind:"workspace"})},be=()=>{a==null||a.capture("library_history_retry"),b.refetch()};let xe;if(e.kind!=="library"&&(l==null?void 0:l.isAvailable)!==!1||e.kind==="preview"){let i=!1,p=s.jsxs("div",{className:"m-auto flex items-center gap-2 text-xs text-white/40",children:[s.jsx(ut,{size:14,className:"animate-spin"}),"Opening ",(l==null?void 0:l.name)??"project","…"]});if(h.data&&!l||b.data&&e.variantId&&!u)p=s.jsx("div",{className:"m-auto text-sm text-white/60",children:"This project or direction is no longer in your library."});else if(e.kind==="preview"&&b.error&&!b.data)p=s.jsx(te,{error:b.error,retry:be});else if(e.kind==="workspace"&&E.error)p=s.jsx(te,{error:E.error,retry:()=>{E.refetch()}});else if(e.kind==="workspace"&&E.data){i=!0;const j=new URL(E.data.editorUrl);j.searchParams.set("library","1"),j.searchParams.set("libraryOrigin",window.location.origin),e.sessionId&&e.variantId&&(j.searchParams.set("historySession",e.sessionId),j.searchParams.set("historyVariant",e.variantId)),p=s.jsx("iframe",{ref:d,title:`${(l==null?void 0:l.name)??"Project"} workspace`,src:j.toString(),className:"min-h-0 w-full flex-1 border-0",allow:"clipboard-write"},j.toString())}else e.kind==="preview"&&Q.error?p=s.jsx(te,{error:Q.error,retry:()=>{Q.refetch()}}):e.kind==="preview"&&Q.data?p=s.jsx("iframe",{title:`${(u==null?void 0:u.label)??"Saved direction"} preview`,src:Q.data.url,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",className:"min-h-0 w-full flex-1 border-0 bg-white"}):e.kind==="preview"&&u&&!u.hasStaticPreview&&(p=s.jsxs("div",{className:"m-auto max-w-sm text-center",children:[s.jsx("p",{className:"text-sm",children:u.hasInteractivePreview?"Open this direction in its workspace":"This direction contains saved code changes"}),s.jsx("p",{className:"mt-2 text-xs leading-6 text-white/40",children:u.hasInteractivePreview?"Rivet will start the preview with this project’s dependencies and configuration.":"Open the project to continue working with its saved history."}),s.jsx("button",{onClick:me,disabled:(l==null?void 0:l.isAvailable)===!1,className:"mt-5 rounded-lg bg-white px-4 py-2.5 text-xs font-medium text-black disabled:opacity-30",children:"Open workspace"})]}));xe=s.jsxs(s.Fragment,{children:[e.kind==="preview"?s.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-3 border-b border-white/[0.07] px-5",children:[s.jsx("button",{"aria-label":"Back to projects",onClick:se,className:"rounded p-1.5 text-white/45 hover:bg-white/5",children:s.jsx(rt,{size:15})}),s.jsx("span",{className:"text-xs text-white/40",children:l==null?void 0:l.name}),u?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-white/20",children:"/"}),s.jsxs("form",{onSubmit:j=>{j.preventDefault();const z=new FormData(j.currentTarget);A.mutate(String(z.get("label")))},className:"flex min-w-0 flex-1 gap-2",children:[s.jsx("input",{name:"label","aria-label":"Direction name",defaultValue:u.label,className:"max-w-xs min-w-0 flex-1 bg-transparent text-xs text-white/80 outline-none"}),s.jsx("button",{disabled:A.isPending,className:"text-[10px] text-white/30 hover:text-white",children:"Rename"})]},`${u.projectId}:${u.variantId}`)]}):s.jsx("span",{className:"flex-1"}),e.kind==="preview"?s.jsxs("button",{onClick:me,disabled:(l==null?void 0:l.isAvailable)===!1,className:"flex items-center gap-1.5 rounded-md border border-white/10 px-3 py-1.5 text-[11px] text-white/70 disabled:opacity-30",children:["Edit in project",s.jsx(dt,{size:12})]}):null]}):null,e.kind==="workspace"&&!i?s.jsx("button",{onClick:se,className:"absolute top-5 left-5 rounded px-2 py-1 text-xs text-white/50 hover:bg-white/5 hover:text-white",children:"Projects"}):null,A.error?s.jsx("p",{role:"alert",className:"px-5 py-2 text-xs text-red-200",children:A.error.message}):null,p]})}let re=xe;return h.error&&!h.data?re=s.jsx(te,{error:h.error,retry:()=>{h.refetch()}}):h.isPending&&(re=s.jsx("div",{role:"status",className:"m-auto text-xs text-white/40",children:"Loading projects…"})),s.jsxs(s.Fragment,{children:[s.jsx(ht,{projects:f,variants:(ye=b.data)==null?void 0:ye.variants,historyError:(ge=b.error)==null?void 0:ge.message,onRetryHistory:be,projectPreviews:Object.fromEntries(f.map((i,p)=>{var j,z;return[i.id,(z=(j=I[p])==null?void 0:j.data)==null?void 0:z.preview]})),selectedProjectId:e.projectId??null,onSelectProject:F,onBrowseLibrary:se,onOpenProject:Ue,accountMenu:s.jsx(it,{side:"top",align:"start"}),isOpeningProject:Z.isPending,projectOpenError:(je=Z.error)==null?void 0:je.message,onSearchCompleted:i=>a==null?void 0:a.capture("library_search_completed",{query_length:i}),children:re}),s.jsx(at,{position:"bottom-right",theme:"dark"})]})};export{vt as default};
|