@fungi.computer/inkcap 0.3.3 → 0.4.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/dist/assets/{FileTab-BIzFBzDK.js → FileTab-ZK1QFAd5.js} +25 -25
- package/dist/assets/InkcapFileTree-DTYIjm_0.js +1 -0
- package/dist/assets/InkcapRepositoryApp-q1CrI-Kd.js +1 -0
- package/dist/assets/empty-state-BPRNo51e.js +1 -0
- package/dist/assets/index-B5ZsAojZ.js +2 -0
- package/dist/assets/index-dbf7RxFf.css +2 -0
- package/dist/assets/refresh-cw-xZ5ayQTq.js +1 -0
- package/dist/assets/{dialog-C49TyOKM.js → tree-path-B5mQdKbM.js} +3 -2
- package/dist/assets/{useFileTree-Dyiqmbq-.js → useFileTree-grDspEh1.js} +1 -1
- package/dist/assets/useForm-DF2JFOTS.js +1 -0
- package/dist/index.html +4 -4
- package/package.json +8 -7
- package/dist/assets/InkcapFileTree-WCY0DAx7.js +0 -1
- package/dist/assets/InkcapRepositoryApp-C74ueO0p.js +0 -1
- package/dist/assets/index-BfmirAP5.css +0 -2
- package/dist/assets/index-D89bIeb6.js +0 -2
- package/dist/assets/refresh-cw-LAlYuFfb.js +0 -1
- package/dist/assets/tree-path-BjPaqwnl.js +0 -1
- package/dist/assets/useForm-LW3qRsbm.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$t as t,Bn as n,Ir as r,Ln as i,Lr as a,Rn as o,en as s,i as c,o as l,r as u,s as d,t as f,tn as p}from"./dialog-C49TyOKM.js";import{bt as m,ht as h,kt as g,r as _}from"./tree-path-BjPaqwnl.js";import{a as v,c as y,d as b,i as x,l as S,n as C,o as w,r as T,s as E,t as D,u as O}from"./useFileTree-Dyiqmbq-.js";import{t as k}from"./refresh-cw-LAlYuFfb.js";import{_ as A,c as j,d as M,f as N,g as P,h as F,l as I,m as L,n as R,p as z,s as B,t as V,u as H,v as U,y as W}from"./index-D89bIeb6.js";var G=e(a(),1);function K(e,t,n){let r=O(),i=S(),a=g(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,T(o),w(o,i,s),y(i);let[l]=G.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&c;if(G.useSyncExternalStore(G.useCallback(e=>{let t=d?l.subscribe(h.batchCalls(e)):m;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),G.useEffect(()=>{l.setOptions(o)},[o,l]),v(o,u))throw x(o,l,i);if(E({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:l.trackResult(u)}function q(e,t){return K(e,b,t)}var J=i(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Y=i(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),X=r(),Z=(0,G.forwardRef)(function({className:e,message:t,...n},r){return(0,X.jsxs)(`div`,{...n,className:o(`caps-loading-state`,e),ref:r,role:`status`,children:[(0,X.jsx)(p,{decorative:!0,size:`sm`}),(0,X.jsx)(`span`,{children:t})]})}),Q=256;async function ee(e,t,r,i,a){i.throwIfAborted();let o=await r(e,t);if(!P.safeParse(o).success)return o;a(!0);try{let a=null,o=!1;for(let e=0;e<Q&&!o;e++){i.throwIfAborted();let e=j.parse(await r(`rebuildCopies`,{cursor:a}));o=e.done,a=e.cursor}if(!o)throw new n(`Bonsai is still preparing this repository. Try again shortly.`,{code:`TIMEOUT`,retryable:!0});i.throwIfAborted();let s=await r(e,t);if(P.safeParse(s).success)throw Error(`The repository changed while loading. Refresh to retry.`);return s}finally{a(!1)}}function te({repository:e,branch:t,request:r,onSaved:i,onSaveState:a}){let o=new Map;async function s(i,a){a.throwIfAborted();let o=I.parse(await r(`files.read`,{repo:e,ref:t,path:i}));if(a.throwIfAborted(),o.binary)throw Error(`This Bonsai file is not a text document.`);if(o.text===null&&o.blob!==null)throw new n(`This Bonsai file is too large to edit.`,{code:`FILE_TOO_LARGE`,retryable:!1});return o}async function c(s,c){c.throwIfAborted();let l=F.parse(await r(`files.sync`,{}));c.throwIfAborted();let u=l.settled.find(n=>n.repo===e&&n.branch===t&&n.path===s);if(u){if(u.result.kind===`refused`)throw new n(`Bonsai refused sync: ${u.result.reason}`,{code:`CAPABILITY_DENIED`,retryable:u.result.reason===`background-unavailable`});let e=o.get(s);if(u.result.revision!==e?.version)throw new n(`Your saved file changed. Compare before syncing.`,{code:`CONFLICT`,retryable:!0});a(s,u.result)}i()}async function l(l,u,d,f){f.throwIfAborted();let p=o.get(l);if(d===void 0){let e=await s(l,f);p={file:e,contents:e.pending?.text??e.text??``,version:e.version}}if(!p)throw Error(`Reopen this Bonsai file before saving.`);if(d!==void 0&&p.contents!==d)throw new n(`The file baseline changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});if(d!==void 0){let e=await s(l,f);if(e.version!==p.version||(e.pending?.text??e.text??``)!==p.contents)throw new n(`The file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});e.pending===void 0&&(p.file=e)}let m=z.parse({repo:e,branch:t,path:l,baseCommit:p.file.commit,baseBlob:p.file.blob,text:u,revision:p.version}),h=L.parse(await r(`files.save`,m));if(h.kind===`refused`)throw new n(`Bonsai refused this save: ${h.reason}`,{code:`CAPABILITY_DENIED`,retryable:h.reason===`background-unavailable`});if(a(l,h),h.kind===`conflict`)throw new n(`Your saved file changed. Compare before saving.`,{code:`CONFLICT`,retryable:!0});o.set(l,{file:p.file,contents:u,version:h.revision}),i(),h.kind===`saved`&&c(l,f).catch(e=>{console.error(`Bonsai sync status could not be refreshed`,e),!(o.get(l)?.version!==h.revision||f.aborted)&&a(l,{kind:`failed`,revision:h.revision,reason:`sync_failed`})})}return{kind:`repository`,id:`${e}:${t}`,label:`${e} · ${t}`,async read(e,t,n){let r=n?.revision,i=await s(e,t);if(n?.closed)return{kind:`closed`};if(n&&n.revision!==r)return{kind:`changed`};let c=i.pending?.text??i.text??``;o.set(e,{file:i,contents:c,version:i.version});let l=i.pending;return l?.state===`pending`?a(e,{kind:`saved`,revision:l.revision,state:`pending`}):l?.state===`conflict`?a(e,{kind:`conflict`,revision:l.revision,theirs:l.theirs}):l?.state===`failed`?a(e,{kind:`failed`,revision:l.revision,reason:l.failure??`sync_failed`}):i.version!==null&&a(e,{kind:`synced`,revision:i.version,commit:i.commit}),{kind:`text`,contents:c}},replace:(e,t,n,r)=>l(e,t,n,r),write:(e,t,n)=>l(e,t,void 0,n),retry:c,async discard(s,c){c.throwIfAborted();let l=o.get(s);if(!l)throw Error(`Reopen this saved file before discarding it.`);if(l.version===null)return;let u=H.parse({repo:e,branch:t,path:s,revision:l.version}),d=M.parse(await r(`files.discard`,u));if(c.throwIfAborted(),d.kind===`conflict`)throw new n(`Your saved file changed. Refresh before discarding.`,{code:`CONFLICT`,retryable:!0});o.delete(s),a(s,null),i()},async readCommitted(e,t){let n=await s(e,t),r=n.text??``;return o.has(e)||o.set(e,{file:n,contents:r,version:n.version}),r}}}async function ne(e,t,n){let r={repo:t,ref:n},i=A.parse(await e(`files.tree`,{...r,path:``})),a=N.parse(await e(`files.list`,r)),o=B.parse(await e(`commits.list`,{...r,limit:20}));if(i.commit.hash!==a.commit.hash)throw Error(`The repository changed while loading. Refresh to retry.`);return{head:i.commit.hash,branch:n,files:a.paths.map(e=>({path:e})),history:o.commits.map(e=>e.commit),truncated:a.truncated}}function re({files:e,dirtyPaths:n,activePath:r,busy:i,onRefresh:a,onOpenFile:o}){let s=(0,G.useRef)({files:e,onOpenFile:o});s.current={files:e,onOpenFile:o};let{model:c}=D({paths:[],initialExpansion:`open`,itemHeight:32,onSelectionChange(e){let t=e[0];t&&!t.endsWith(`/`)&&s.current.files.some(e=>e.path===t)&&s.current.onOpenFile(t)}}),l=(0,G.useMemo)(()=>{let t=new Set(n);return e.flatMap(e=>t.has(e.path)?[{path:e.path,status:`modified`}]:[])},[e,n]);return(0,G.useEffect)(()=>{c.resetPaths(e.map(e=>e.path))},[c,e]),(0,G.useEffect)(()=>{c.setGitStatus(l)},[c,l]),(0,G.useEffect)(()=>{for(let e of c.getSelectedPaths())e!==r&&c.getItem(e)?.deselect();r&&c.getItem(r)?.select()},[c,r]),(0,X.jsxs)(`aside`,{className:`inkcap-tree`,"aria-label":`Repository files`,children:[(0,X.jsxs)(`div`,{className:`inkcap-tree-toolbar`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(_,{"aria-hidden":`true`}),` Explorer`]}),(0,X.jsx)(t,{icon:(0,X.jsx)(k,{}),"aria-label":`Refresh repository`,variant:`ghost`,size:`xs`,disabled:i,onClick:a})]}),(0,X.jsx)(`p`,{className:`inkcap-repository-legend`,children:`Changes in latest commit · drafts marked modified`}),(0,X.jsx)(C,{model:c,style:{flex:`1`,"--trees-item-height":`32px`,"--trees-padding-inline-override":`var(--spacing-xs)`,"--trees-item-margin-x-override":`0px`,"--trees-item-padding-x-override":`var(--spacing-xs)`,"--trees-item-row-gap-override":`var(--spacing-xs)`,"--trees-border-radius-override":`var(--radius-field)`,"--trees-bg-override":`var(--color-base-100)`,"--trees-fg-override":`var(--color-base-content)`,"--trees-bg-muted-override":`var(--color-base-200)`,"--trees-selected-bg-override":`var(--color-base-300)`,"--trees-font-family-override":`var(--font-sans)`,"--trees-font-size-override":`12px`}})]})}var $={all:(e,t)=>[`inkcap-repository`,e,t],branch:(e,t,n)=>[...$.all(e,t),n]};function ie({connection:e,repository:t,initialBranch:n,initialPath:r,openRequestId:i,transport:a,onReady:o}){let p=g(),[m,h]=(0,G.useState)(!1),[_,v]=(0,G.useState)(0),[y,b]=(0,G.useState)(new Map),[x,S]=(0,G.useState)(``),C=(0,G.useRef)(new AbortController);(0,G.useEffect)(()=>{let e=new AbortController;return C.current=e,()=>{e.abort()}},[]);let w=(0,G.useCallback)((t,n)=>a?a(t,n):e.app.capabilities.require(W).call(`app_bonsai`,t,JSON.stringify(n)),[e.app,a]),T=(0,G.useCallback)((e,t)=>ee(e,t,w,C.current.signal,e=>{v(t=>t+(e?1:-1))}),[w]),E=(0,G.useCallback)(()=>{p.invalidateQueries({queryKey:$.all(e.app.identity.surfaceId,t)})},[p,e.app,t]),D=(0,G.useRef)(new Map),O=(0,G.useMemo)(()=>{let r=`${e.app.identity.surfaceId}:${t}:${n}`,i=D.current.get(r);if(i?.app===e.app)return i;let a=te({repository:t,branch:n,request:T,onSaved:E,onSaveState:(e,r)=>{C.current.signal.aborted||b(i=>{let a=new Map(i),o=`${t}:${n}:${e}`;return r===null?a.delete(o):a.set(o,r),a})}}),o={app:e.app,source:a};return D.current.set(r,o),o},[t,n,T,E,e.app]),k=V({connection:O}),A=q({queryKey:$.branch(e.app.identity.surfaceId,t,n),queryFn:()=>ne(T,t,n),refetchInterval:15e3});(0,G.useEffect)(()=>e.app.window.onBeforeClose(k.requestWindowClose),[e.app,k.requestWindowClose]),(0,G.useEffect)(()=>{o?.({requestWindowClose:k.requestWindowClose})},[o,k.requestWindowClose]);let j=(0,G.useRef)(),M=(0,G.useRef)(new Map),N=(0,G.useRef)(new Set);(0,G.useEffect)(()=>{if(!A.data)return;let e=`${O.app.identity.surfaceId}:${O.source.id}:${i}`;j.current!==e&&(j.current=e,k.onOpenFile(r));let t=M.current.get(O.source.id),n=t!==void 0&&t!==A.data.head;M.current.set(O.source.id,A.data.head);let a=new Set(k.tabs.map(e=>e.tabKey));for(let e of N.current)a.has(e)||N.current.delete(e);for(let e of k.tabs)if(!(e.target.closed||e.connection!==O||!n&&!N.current.has(e.tabKey))){if(e.target.saving){N.current.add(e.tabKey);continue}N.current.delete(e.tabKey),e.target.dirty||k.onReopen(e,{background:!0})}},[A.data,O,r,i,k]);let P=k.tabs.find(e=>e.tabKey===k.active),F=P?.connection?.source?y.get(`${P.connection.source.id}:${P.path}`):void 0,I=F?.kind===`saved`?`Saved · syncing`:F?.kind===`synced`?`Synced · ${F.commit.slice(0,7)}`:F?.kind===`conflict`?`Sync conflict · Compare`:F?.kind===`failed`?`Sync failed · Retry`:void 0;async function L(){if(!P?.connection?.source)return;let e=D.current.get(`${P.connection.app.identity.surfaceId}:${P.connection.source.id}`);if(e)try{S(``),await e.source.retry(P.path,C.current.signal)}catch(e){console.error(`Bonsai sync retry failed`,e),S(`Could not retry sync. Your saved text remains in Bonsai.`)}}async function z(){if(!P?.connection?.source)return;let e=()=>!P.target.dirty&&!P.target.saving&&!P.target.closed;if(!e())return;let t=D.current.get(`${P.connection.app.identity.surfaceId}:${P.connection.source.id}`);if(t)try{S(``);let n=await t.source.read(P.path,C.current.signal);if(n.kind!==`text`)throw Error(`This saved text is unavailable.`);if(!e())return;await t.source.replace(P.path,n.contents,n.contents,C.current.signal)}catch(e){console.error(`Bonsai explicit re-save failed`,e),S(`Could not save again. Your saved text and open edits remain available.`)}}return(0,X.jsxs)(`div`,{className:`inkcap-repository`,children:[(0,X.jsxs)(`div`,{className:`inkcap-repository-toolbar`,children:[(0,X.jsxs)(`span`,{className:`inkcap-repository-name`,children:[(0,X.jsx)(J,{"aria-hidden":`true`}),` `,t,` · `,n]}),(0,X.jsxs)(s,{size:`sm`,variant:`outline`,onClick:()=>{h(!0)},children:[(0,X.jsx)(Y,{"aria-hidden":`true`,className:`size-[var(--stipe-icon-size-sm)]`}),` `,`History`]})]}),_>0&&(0,X.jsx)(Z,{message:`Loading this repository…`}),A.data?.truncated&&(0,X.jsx)(U,{tone:`info`,title:`Only the indexed files are shown`}),x&&(0,X.jsx)(U,{tone:`error`,title:`Sync unavailable`,description:x}),F?.kind===`failed`&&(0,X.jsx)(U,{tone:`warning`,title:F.reason===`permanent_material`?`Sync needs a new save`:`Sync failed`,description:F.reason===`permanent_material`?`Your text is saved. Save again using the current repository state to retry sync.`:`Your file is saved in Bonsai. Retry when access is available.`,action:(0,X.jsx)(s,{size:`sm`,disabled:F.reason===`permanent_material`&&P!==void 0&&(P.target.dirty||P.target.saving),onClick:()=>void(F.reason===`permanent_material`?z():L()),children:F.reason===`permanent_material`?`Save again`:`Retry`})}),(0,X.jsx)(R,{model:{...k,repositoryStatus:I,repositoryStates:y,canList:!0,sourceLabel:O.source.label,onReadCurrent:async(e,t)=>{if(e.connection?.source?.kind!==`repository`)return k.onReadCurrent(e);let n=D.current.get(`${e.connection.app.identity.surfaceId}:${e.connection.source.id}`);if(!n||e.target.closed)throw Error(`This Bonsai file is no longer open.`);return t&&await n.source.discard(e.path,C.current.signal),n.source.readCommitted(e.path,C.current.signal)},error:A.error?`Could not refresh this repository. Your open edits remain available.`:k.error,fileTree:e=>(0,X.jsx)(re,{files:A.data?.files??[],dirtyPaths:k.tabs.filter(e=>e.connection===O&&e.dirty).map(e=>e.path),activePath:P?.connection===O?P.path:null,busy:A.isFetching,onRefresh:E,onOpenFile:e})}}),(0,X.jsx)(f,{open:m,onOpenChange:h,children:(0,X.jsxs)(u,{children:[(0,X.jsxs)(l,{children:[(0,X.jsx)(d,{children:`Commit history`}),(0,X.jsxs)(c,{children:[t,` · `,n]})]}),(0,X.jsx)(`ol`,{className:`inkcap-repository-history`,children:A.data?.history.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`code`,{children:e.hash.slice(0,7)}),` `,e.message,(0,X.jsx)(`span`,{className:`text-dim`,children:e.author.name})]},e.hash))})]})})]})}export{ie as InkcapRepositoryApp};
|