@alpacachen/dsh-simple-worktree 1.0.7 → 1.0.8
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/client/client.js +1 -1
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -171,7 +171,7 @@ Path: {path}`,retryRegister:"Retry registration and open",cleanupCreated:"Clean
|
|
|
171
171
|
|
|
172
172
|
If you want to hide the \`${a.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
173
173
|
|
|
174
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${a.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(t))},[t,e]),null},Or="DialogDescriptionWarning",Er=({contentRef:e,descriptionId:a})=>{let o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zt(Or).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute("aria-describedby");a&&r&&(document.getElementById(a)||console.warn(o))},[o,e,a]),null},$t=Et;var Jt=Ht,Qt=Wt,Yt=Nt,eo=Vt,ao=_t,to=Kt;var Z=require("react/jsx-runtime");function H({className:e="",...a}){return(0,Z.jsx)("button",{className:`dswt-button ${e}`,...a})}function oo({className:e="",...a}){return(0,Z.jsx)("input",{className:`dswt-input ${e}`,...a})}function ro({children:e,...a}){return(0,Z.jsx)($t,{...a,children:e})}function uo({children:e}){let a=te();return(0,Z.jsxs)(Jt,{children:[(0,Z.jsx)(Qt,{className:"dswt-dialog-overlay"}),(0,Z.jsxs)(Yt,{className:"dswt-dialog-content",children:[e,(0,Z.jsx)(to,{className:"dswt-dialog-close","aria-label":a("close"),children:(0,Z.jsx)(ye,{size:16})})]})]})}var lo=eo,so=ao;var v=require("react/jsx-runtime");function fo({target:e,api:a,workspaces:t,sessions:o,defaultBaseChoice:r="current",onCreated:u,onClose:s}){let l=te(),[i,n]=(0,Y.useState)(null),[c,m]=(0,Y.useState)(""),[x,I]=(0,Y.useState)(r),[h,d]=(0,Y.useState)(""),[p,L]=(0,Y.useState)(!1),[f,C]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let P=!0;return n(null),d(""),m(""),I(r),a.list(e.path).then(W=>{P&&n(W)}).catch(W=>{P&&d(String(W?.message??W))}),()=>{P=!1}},[a,r,e.path]);let S=i?.repoPath,w=Ua(c),y=`task/${w}`,g=S?Ha(S,w):"",T=i?.worktrees.find(P=>F(P.path)===F(e.path))?.branch??"HEAD",$=i?.defaultBranch??i?.worktrees.find(P=>P.isMain)?.branch??T,le=x==="main"?i?.defaultRef??$:T,me=async(P,W)=>{let J=await t.create({path:P});await t.rename(J.workspaceId,`${e.title}/${W}`);let Le=await t.connectWorkspace(J.workspaceId);u(P),o.open(Le),s()},Te=async()=>{if(f){L(!0),d("");try{await me(f.path,f.branch.replace(/^task\//,"")),C(null)}catch(P){d(`${l("registerFailed")} ${String(P?.message??P)}`)}finally{L(!1)}}},Lo=async()=>{if(f){L(!0),d("");try{await a.remove({repoPath:f.repoPath,path:f.path}),C(null),s()}catch(P){d(oe(l("cleanupFailed"),{error:String(P?.message??P),path:f.path}))}finally{L(!1)}}},xo=async()=>{if(!S||!c.trim()){d(l("fillTaskName"));return}L(!0),d("");let P,W;try{let J=await a.create({repoPath:S,path:g,branch:y,baseRef:le});P=J.path,W=await t.create({path:J.path}),await t.rename(W.workspaceId,`${e.title}/${w}`);let Le=await t.connectWorkspace(W.workspaceId);u(J.path),o.open(Le),s()}catch(J){if(W?.workspaceId)try{await t.delete(W.workspaceId)}catch(Le){P&&C({repoPath:S,path:P,branch:y}),d(oe(l("cleanupFailed"),{error:String(Le?.message??Le),path:P??""}));return}P?(C({repoPath:S,path:P,branch:y}),d(l("registerFailed"))):d(`${l("operationFailed")}${String(J?.message??J)}`)}finally{L(!1)}};return(0,v.jsx)(ro,{open:!0,onOpenChange:P=>{!P&&!p&&s()},children:(0,v.jsxs)(uo,{children:[(0,v.jsx)(lo,{className:"dswt-dialog-title",children:oe(l("dialogTitle"),{name:e.title})}),(0,v.jsx)(so,{className:"dswt-visually-hidden",children:e.title}),h?(0,v.jsxs)("div",{className:"dswt-error",role:"alert",children:[(0,v.jsx)(X,{size:14})," ",h]}):null,(0,v.jsxs)("label",{className:"dswt-field",children:[(0,v.jsx)("span",{className:"dswt-field-label",children:l("taskName")}),(0,v.jsx)(oo,{"aria-label":l("taskName"),value:c,disabled:p,onChange:P=>m(P.target.value),placeholder:l("taskNamePlaceholder"),autoFocus:!0})]}),(0,v.jsxs)("fieldset",{className:"dswt-field dswt-base-fieldset",disabled:p||!i,children:[(0,v.jsx)("legend",{className:"dswt-field-label",children:l("basedOn")}),(0,v.jsxs)("div",{className:"dswt-radio-group",role:"radiogroup","aria-label":l("basedOn"),children:[(0,v.jsxs)("label",{className:"dswt-radio-option","data-selected":x==="current"?"true":void 0,children:[(0,v.jsx)("input",{className:"dswt-radio-input",type:"radio",name:"dswt-base-branch",value:"current",checked:x==="current",onChange:()=>I("current")}),(0,v.jsxs)("span",{className:"dswt-radio-copy",children:[(0,v.jsx)("span",{className:"dswt-radio-label",children:l("currentBranch")}),(0,v.jsx)("span",{className:"dswt-radio-branch",children:T})]})]}),(0,v.jsxs)("label",{className:"dswt-radio-option","data-selected":x==="main"?"true":void 0,children:[(0,v.jsx)("input",{className:"dswt-radio-input",type:"radio",name:"dswt-base-branch",value:"main",checked:x==="main",onChange:()=>I("main")}),(0,v.jsxs)("span",{className:"dswt-radio-copy",children:[(0,v.jsx)("span",{className:"dswt-radio-label",children:l("mainBranch")}),(0,v.jsx)("span",{className:"dswt-radio-branch",children:$})]})]})]})]}),f?(0,v.jsxs)("div",{className:"dswt-dialog-actions",children:[(0,v.jsx)(H,{type:"button",disabled:p,onClick:()=>{Te()},children:l("retryRegister")}),(0,v.jsx)(H,{type:"button",disabled:p,onClick:()=>{Lo()},children:l("cleanupCreated")})]}):null,f?null:(0,v.jsxs)("div",{className:"dswt-dialog-actions",children:[(0,v.jsx)(H,{type:"button",disabled:p,onClick:s,children:l("cancel")}),(0,v.jsxs)(H,{type:"button",className:"dswt-button-primary",disabled:p||!c.trim()||!i,onClick:xo,children:[p?(0,v.jsx)(K,{size:14,className:"dswt-spin"}):null,l(p?"creating":"createAndOpen")]})]})]})})}var pe=require("react/jsx-runtime");function Me(){return(0,pe.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,pe.jsx)("path",{d:"M4 2.25v8.5a2.25 2.25 0 1 0 1.5 0V7.75h4v3a2.25 2.25 0 1 0 1.5 0V6.25H5.5v-4H4Z",fill:"currentColor"}),(0,pe.jsx)("circle",{cx:"4.75",cy:"12.75",r:"1.5",fill:"currentColor"}),(0,pe.jsx)("circle",{cx:"10.25",cy:"12.75",r:"1.5",fill:"currentColor"}),(0,pe.jsx)("circle",{cx:"4.75",cy:"2.25",r:"1.5",fill:"currentColor"})]})}var Fe=require("react/jsx-runtime");function no({session:e,useWorkspaces:a,onOpen:t}){let o=te(),r=a(u=>u.items.find(s=>s.sessionIds?.includes(e.sessionId)));return!e.blank||!r?null:(0,Fe.jsx)("div",{className:"dswt-new-session-action",children:(0,Fe.jsxs)(H,{type:"button",className:"dswt-new-session-button",onClick:()=>t(r),children:[(0,Fe.jsx)(Me,{}),o("createWorktree")]})})}var ee=require("react");var R=require("react/jsx-runtime");function io({api:e,workspaces:a,sessions:t}){let o=te(),[r,u]=(0,ee.useState)([]),[s,l]=(0,ee.useState)(!1),[i,n]=(0,ee.useState)(""),[c,m]=(0,ee.useState)(null),x=(0,ee.useCallback)(async()=>{l(!0),n("");try{let L=new Set,f=[];for(let C of a.list.getSnapshot().items)try{let S=await e.list(C.path),w=F(S.repoPath);if(w&&!L.has(w)){L.add(w);let y=await Promise.all(S.worktrees.map(async g=>{try{return{...g,...await e.status(g.path)}}catch(T){return{...g,statusError:String(T?.message??T)}}}));f.push({...S,worktrees:y})}}catch{}u(f)}catch(L){n(String(L?.message??L))}finally{l(!1)}},[e,a]);(0,ee.useEffect)(()=>{x()},[x]);let I=L=>L.statusError==="worktree-unavailable"?o("unavailable"):L.statusError==="not-git-repository"?o("notGitWorkspace"):L.statusError,h=async(L,f)=>{m(f.path),n("");try{let C=a.list.getSnapshot().items.find(y=>F(y.path)===F(f.path)),S=!C;if(C||(C=await a.create({path:f.path})),S){let y=f.isMain?o("mainRepository"):`${L.defaultBranch??"worktree"}/${f.branch??"detached"}`;await a.rename(C.workspaceId,y)}let w=await a.connectWorkspace(C.workspaceId);t.open(w)}catch(C){n(`${o("operationError")}${String(C?.message??C)}`)}finally{m(null)}},d=async(L,f)=>{if(f.isMain)return;let C=f.statusError?o("unavailable"):f.changedFiles?oe(o("dirty"),{count:String(f.changedFiles)}):o("clean");if(f.changedFiles||f.statusError){n(f.statusError?`${o("operationError")}${I(f)}`:o("dirtyRemoveBlocked"));return}if(window.confirm(oe(o("removeConfirm"),{path:f.path,status:C}))){m(f.path),n("");try{await e.remove({repoPath:L.repoPath,path:f.path});let S=a.list.getSnapshot().items.find(w=>F(w.path)===F(f.path));S&&await a.delete(S.workspaceId),await x()}catch(S){n(`${o("operationError")}${String(S?.message??S)}`)}finally{m(null)}}},p=async L=>{m(L.repoPath),n("");try{await e.prune(L.repoPath),await x()}catch(f){n(`${o("operationError")}${String(f?.message??f)}`)}finally{m(null)}};return(0,R.jsxs)("section",{className:"dswt-settings","aria-label":o("worktrees"),children:[(0,R.jsxs)("div",{className:"dswt-settings-header",children:[(0,R.jsx)("h2",{children:o("worktrees")}),(0,R.jsx)(H,{type:"button","aria-label":o("refresh"),title:o("refresh"),disabled:s,onClick:()=>{x()},children:(0,R.jsx)(ke,{size:14,className:s?"dswt-spin":void 0})})]}),i?(0,R.jsxs)("div",{className:"dswt-error",role:"alert",children:[(0,R.jsx)(X,{size:14})," ",i]}):null,r.length===0&&!s?(0,R.jsx)("p",{className:"dswt-muted",children:o("noWorktrees")}):null,r.map(L=>(0,R.jsxs)("div",{className:"dswt-repo",children:[(0,R.jsxs)("div",{className:"dswt-repo-path",children:[L.repoPath,(0,R.jsx)(H,{type:"button",disabled:c===L.repoPath,onClick:()=>{p(L)},children:o("prune")})]}),L.worktrees.map(f=>(0,R.jsxs)("div",{className:"dswt-worktree",children:[(0,R.jsxs)("div",{className:"dswt-worktree-main",children:[(0,R.jsx)("strong",{children:f.branch??o("detached")}),(0,R.jsx)("span",{className:"dswt-worktree-path",title:f.path,children:f.path}),(0,R.jsx)("span",{children:f.isMain?o("mainRepository"):o("linkedWorktree")}),(0,R.jsx)("span",{children:f.statusError?I(f):f.changedFiles?oe(o("dirty"),{count:String(f.changedFiles)}):o("clean")}),f.locked?(0,R.jsx)("span",{children:o("locked")}):null,f.prunable?(0,R.jsx)("span",{children:o("prunable")}):null]}),(0,R.jsxs)("div",{className:"dswt-worktree-actions",children:[(0,R.jsxs)(H,{type:"button",disabled:c===f.path||!!f.statusError,onClick:()=>{h(L,f)},children:[c===f.path?(0,R.jsx)(K,{size:14,className:"dswt-spin"}):null,o("open")]}),!f.isMain&&(f.prunable||f.statusError)?(0,R.jsx)(H,{type:"button",disabled:c===f.path,onClick:()=>{p(L)},children:o("prune")}):null,!f.isMain&&!f.prunable&&!f.statusError?(0,R.jsx)(H,{type:"button",disabled:c===f.path,onClick:()=>{d(L,f)},children:o("remove")}):null]})]},f.path))]},L.repoPath))]})}var Ur="/dsh-simple-worktree";function co(e){async function a(t,o){let r=await e.rpc.call(Ur,t,o);if(!r?.ok){let u=r?.error?.code,s=new Error(u==="worktree-unavailable"?"worktree-unavailable":u==="not-git-repository"?"not-git-repository":r?.error?.message??"worktree operation failed");throw s.code=r?.error?.code,s}return r.value}return{list:t=>a("worktree.list",{path:t}),classify:t=>a("worktree.classify",{path:t}),create:t=>a("worktree.create",t),remove:t=>a("worktree.remove",t),status:t=>a("worktree.status",{path:t}),prune:t=>a("worktree.prune",{path:t})}}var we=require("react/jsx-runtime"),po="data-dsh-simple-worktree-style";function Hr(){if(typeof document>"u"||document.querySelector(`style[${po}]`))return;let e=document.createElement("style");return e.setAttribute(po,""),e.textContent=Da,document.head.appendChild(e),()=>e.remove()}var mo={name:"@alpacachen/dsh-simple-worktree",inject:["slots","connection","locale","workspaces","sessions","workspaceExtensions"],apply(e){e.effect(Hr,"dsh-simple-worktree styles"),e.effect(()=>qa(e),"dsh-simple-worktree locale");let a=co(e.connection),t=e.workspaces,o=e.sessions,r=e.get("locale"),u=e.workspaceExtensions,s=new Set;e.effect(()=>{if(!(!r||typeof r.subscribe!="function"))return r.subscribe(()=>u.invalidate())},"dsh-simple-worktree locale refresh");let l=new Set,i=!0,n=()=>{},c=0,m=async()=>{let I=++c,h=t.list.getSnapshot().items,d=await Promise.all(h.map(async p=>{try{return await a.classify(p.path)}catch{return}}));if(!(!i||I!==c)){s.clear(),l.clear();for(let p of d)p?.isGit&&p.path&&s.add(F(p.path)),p?.isWorktree&&p.path&&l.add(F(p.path));u.invalidate()}};e.effect(()=>u.register({id:"dsh-simple-worktree",menuItem(h){let d=F(h.path);if(!(!s.has(d)||l.has(d)))return{id:"dsh-simple-worktree.create",label:Pe("createWorktree"),icon:(0,we.jsx)(Me,{}),order:30,onSelect:()=>n(h)}},deleteWorkspace(h){let d=F(h.path);if(l.has(d))return(async()=>{let p=await a.classify(h.path);!p.isWorktree||!p.repoPath||(await a.remove({repoPath:p.repoPath,path:h.path}),await t.delete(h.workspaceId),s.delete(d),l.delete(d),u.invalidate())})()},icon(h){return l.has(F(h.path))?(0,we.jsx)(Me,{}):void 0}}),"dsh-simple-worktree workspace extensions"),e.effect(()=>{i=!0;let I=t.list.subscribe(()=>{m()});return m(),()=>{i=!1,c+=1,I()}},"dsh-simple-worktree workspace classification");function x(){let[I,h]=(0,Qe.useState)(null);return(0,Qe.useEffect)(()=>(n=(d,p="current")=>h({target:d,defaultBaseChoice:p}),()=>{n=()=>{}}),[]),I?(0,we.jsx)(fo,{target:I.target,api:a,workspaces:t,sessions:o,defaultBaseChoice:I.defaultBaseChoice,onCreated:d=>{s.add(F(d)),l.add(F(d)),u.invalidate()},onClose:()=>h(null)}):null}e.slots.inject("conversation.input.dock",()=>e.slots.register({name:"conversation.input.dock",id:"dsh-simple-worktree-new-session",order:-30,locale:se,label:()=>Pe("createWorktree")},I=>(0,we.jsx)(no,{session:I.session,useWorkspaces:I.useWorkspaces,onOpen:h=>n(h,"main")}))),e.slots.inject("shell.overlay",()=>e.slots.register({name:"shell.overlay",id:"dsh-simple-worktree-create",order:30,locale:se,label:()=>Pe("createWorktree")},x)),e.slots.inject("settings.plugin.item",()=>e.slots.register({name:"settings.plugin.item",key:se,locale:se,inject:()=>({})},()=>(0,we.jsx)(io,{api:a,workspaces:t,sessions:o})))}};var Wr=mo;
|
|
174
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${a.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(t))},[t,e]),null},Or="DialogDescriptionWarning",Er=({contentRef:e,descriptionId:a})=>{let o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zt(Or).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute("aria-describedby");a&&r&&(document.getElementById(a)||console.warn(o))},[o,e,a]),null},$t=Et;var Jt=Ht,Qt=Wt,Yt=Nt,eo=Vt,ao=_t,to=Kt;var Z=require("react/jsx-runtime");function H({className:e="",...a}){return(0,Z.jsx)("button",{className:`dswt-button ${e}`,...a})}function oo({className:e="",...a}){return(0,Z.jsx)("input",{className:`dswt-input ${e}`,...a})}function ro({children:e,...a}){return(0,Z.jsx)($t,{...a,children:e})}function uo({children:e}){let a=te();return(0,Z.jsxs)(Jt,{children:[(0,Z.jsx)(Qt,{className:"dswt-dialog-overlay"}),(0,Z.jsxs)(Yt,{className:"dswt-dialog-content",children:[e,(0,Z.jsx)(to,{className:"dswt-dialog-close","aria-label":a("close"),children:(0,Z.jsx)(ye,{size:16})})]})]})}var lo=eo,so=ao;var v=require("react/jsx-runtime");function fo({target:e,api:a,workspaces:t,sessions:o,defaultBaseChoice:r="current",onCreated:u,onClose:s}){let l=te(),[i,n]=(0,Y.useState)(null),[c,m]=(0,Y.useState)(""),[x,I]=(0,Y.useState)(r),[h,d]=(0,Y.useState)(""),[p,L]=(0,Y.useState)(!1),[f,C]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let P=!0;return n(null),d(""),m(""),I(r),a.list(e.path).then(W=>{P&&n(W)}).catch(W=>{P&&d(String(W?.message??W))}),()=>{P=!1}},[a,r,e.path]);let S=i?.repoPath,w=Ua(c),y=`task/${w}`,g=S?Ha(S,w):"",T=i?.worktrees.find(P=>F(P.path)===F(e.path))?.branch??"HEAD",$=i?.defaultBranch??i?.worktrees.find(P=>P.isMain)?.branch??T,le=x==="main"?i?.defaultRef??$:T,me=async(P,W)=>{let J=await t.create({path:P});await t.rename(J.workspaceId,`${e.title}/${W}`);let Le=await t.connectWorkspace(J.workspaceId);u(P),o.open(Le),s()},Te=async()=>{if(f){L(!0),d("");try{await me(f.path,f.branch.replace(/^task\//,"")),C(null)}catch(P){d(`${l("registerFailed")} ${String(P?.message??P)}`)}finally{L(!1)}}},Lo=async()=>{if(f){L(!0),d("");try{await a.remove({repoPath:f.repoPath,path:f.path}),C(null),s()}catch(P){d(oe(l("cleanupFailed"),{error:String(P?.message??P),path:f.path}))}finally{L(!1)}}},xo=async()=>{if(!S||!c.trim()){d(l("fillTaskName"));return}L(!0),d("");let P,W;try{let J=await a.create({repoPath:S,path:g,branch:y,baseRef:le});P=J.path,W=await t.create({path:J.path}),await t.rename(W.workspaceId,`${e.title}/${w}`);let Le=await t.connectWorkspace(W.workspaceId);u(J.path),o.open(Le),s()}catch(J){if(W?.workspaceId)try{await t.delete(W.workspaceId)}catch(Le){P&&C({repoPath:S,path:P,branch:y}),d(oe(l("cleanupFailed"),{error:String(Le?.message??Le),path:P??""}));return}P?(C({repoPath:S,path:P,branch:y}),d(l("registerFailed"))):d(`${l("operationFailed")}${String(J?.message??J)}`)}finally{L(!1)}};return(0,v.jsx)(ro,{open:!0,onOpenChange:P=>{!P&&!p&&s()},children:(0,v.jsxs)(uo,{children:[(0,v.jsx)(lo,{className:"dswt-dialog-title",children:oe(l("dialogTitle"),{name:e.title})}),(0,v.jsx)(so,{className:"dswt-visually-hidden",children:e.title}),h?(0,v.jsxs)("div",{className:"dswt-error",role:"alert",children:[(0,v.jsx)(X,{size:14})," ",h]}):null,(0,v.jsxs)("label",{className:"dswt-field",children:[(0,v.jsx)("span",{className:"dswt-field-label",children:l("taskName")}),(0,v.jsx)(oo,{"aria-label":l("taskName"),value:c,disabled:p,onChange:P=>m(P.target.value),placeholder:l("taskNamePlaceholder"),autoFocus:!0})]}),(0,v.jsxs)("fieldset",{className:"dswt-field dswt-base-fieldset",disabled:p||!i,children:[(0,v.jsx)("legend",{className:"dswt-field-label",children:l("basedOn")}),(0,v.jsxs)("div",{className:"dswt-radio-group",role:"radiogroup","aria-label":l("basedOn"),children:[(0,v.jsxs)("label",{className:"dswt-radio-option","data-selected":x==="current"?"true":void 0,children:[(0,v.jsx)("input",{className:"dswt-radio-input",type:"radio",name:"dswt-base-branch",value:"current",checked:x==="current",onChange:()=>I("current")}),(0,v.jsxs)("span",{className:"dswt-radio-copy",children:[(0,v.jsx)("span",{className:"dswt-radio-label",children:l("currentBranch")}),(0,v.jsx)("span",{className:"dswt-radio-branch",children:T})]})]}),(0,v.jsxs)("label",{className:"dswt-radio-option","data-selected":x==="main"?"true":void 0,children:[(0,v.jsx)("input",{className:"dswt-radio-input",type:"radio",name:"dswt-base-branch",value:"main",checked:x==="main",onChange:()=>I("main")}),(0,v.jsxs)("span",{className:"dswt-radio-copy",children:[(0,v.jsx)("span",{className:"dswt-radio-label",children:l("mainBranch")}),(0,v.jsx)("span",{className:"dswt-radio-branch",children:$})]})]})]})]}),f?(0,v.jsxs)("div",{className:"dswt-dialog-actions",children:[(0,v.jsx)(H,{type:"button",disabled:p,onClick:()=>{Te()},children:l("retryRegister")}),(0,v.jsx)(H,{type:"button",disabled:p,onClick:()=>{Lo()},children:l("cleanupCreated")})]}):null,f?null:(0,v.jsxs)("div",{className:"dswt-dialog-actions",children:[(0,v.jsx)(H,{type:"button",disabled:p,onClick:s,children:l("cancel")}),(0,v.jsxs)(H,{type:"button",className:"dswt-button-primary",disabled:p||!c.trim()||!i,onClick:xo,children:[p?(0,v.jsx)(K,{size:14,className:"dswt-spin"}):null,l(p?"creating":"createAndOpen")]})]})]})})}var pe=require("react/jsx-runtime");function Me(){return(0,pe.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[(0,pe.jsx)("path",{d:"M4 2.25v8.5a2.25 2.25 0 1 0 1.5 0V7.75h4v3a2.25 2.25 0 1 0 1.5 0V6.25H5.5v-4H4Z",fill:"currentColor"}),(0,pe.jsx)("circle",{cx:"4.75",cy:"12.75",r:"1.5",fill:"currentColor"}),(0,pe.jsx)("circle",{cx:"10.25",cy:"12.75",r:"1.5",fill:"currentColor"}),(0,pe.jsx)("circle",{cx:"4.75",cy:"2.25",r:"1.5",fill:"currentColor"})]})}var Fe=require("react/jsx-runtime");function no({session:e,useWorkspaces:a,onOpen:t}){let o=te(),r=a(u=>u.items.find(s=>s.sessionIds?.includes(e.sessionId)));return!e.blank||!r?null:(0,Fe.jsx)("div",{className:"dswt-new-session-action",children:(0,Fe.jsxs)(H,{type:"button",className:"dswt-new-session-button",onClick:()=>t(r),children:[(0,Fe.jsx)(Me,{}),o("createWorktree")]})})}var ee=require("react");var R=require("react/jsx-runtime");function io({api:e,workspaces:a,sessions:t}){let o=te(),[r,u]=(0,ee.useState)([]),[s,l]=(0,ee.useState)(!1),[i,n]=(0,ee.useState)(""),[c,m]=(0,ee.useState)(null),x=(0,ee.useCallback)(async()=>{l(!0),n("");try{let L=new Set,f=[];for(let C of a.list.getSnapshot().items)try{let S=await e.list(C.path),w=F(S.repoPath);if(w&&!L.has(w)){L.add(w);let y=await Promise.all(S.worktrees.map(async g=>{try{return{...g,...await e.status(g.path)}}catch(T){return{...g,statusError:String(T?.message??T)}}}));f.push({...S,worktrees:y})}}catch{}u(f)}catch(L){n(String(L?.message??L))}finally{l(!1)}},[e,a]);(0,ee.useEffect)(()=>{x()},[x]);let I=L=>L.statusError==="worktree-unavailable"?o("unavailable"):L.statusError==="not-git-repository"?o("notGitWorkspace"):L.statusError,h=async(L,f)=>{m(f.path),n("");try{let C=a.list.getSnapshot().items.find(y=>F(y.path)===F(f.path)),S=!C;if(C||(C=await a.create({path:f.path})),S){let y=f.isMain?o("mainRepository"):`${L.defaultBranch??"worktree"}/${f.branch??"detached"}`;await a.rename(C.workspaceId,y)}let w=await a.connectWorkspace(C.workspaceId);t.open(w)}catch(C){n(`${o("operationError")}${String(C?.message??C)}`)}finally{m(null)}},d=async(L,f)=>{if(f.isMain)return;let C=f.statusError?o("unavailable"):f.changedFiles?oe(o("dirty"),{count:String(f.changedFiles)}):o("clean");if(f.changedFiles||f.statusError){n(f.statusError?`${o("operationError")}${I(f)}`:o("dirtyRemoveBlocked"));return}if(window.confirm(oe(o("removeConfirm"),{path:f.path,status:C}))){m(f.path),n("");try{await e.remove({repoPath:L.repoPath,path:f.path});let S=a.list.getSnapshot().items.find(w=>F(w.path)===F(f.path));S&&await a.delete(S.workspaceId),await x()}catch(S){n(`${o("operationError")}${String(S?.message??S)}`)}finally{m(null)}}},p=async L=>{m(L.repoPath),n("");try{await e.prune(L.repoPath),await x()}catch(f){n(`${o("operationError")}${String(f?.message??f)}`)}finally{m(null)}};return(0,R.jsxs)("section",{className:"dswt-settings","aria-label":o("worktrees"),children:[(0,R.jsxs)("div",{className:"dswt-settings-header",children:[(0,R.jsx)("h2",{children:o("worktrees")}),(0,R.jsx)(H,{type:"button","aria-label":o("refresh"),title:o("refresh"),disabled:s,onClick:()=>{x()},children:(0,R.jsx)(ke,{size:14,className:s?"dswt-spin":void 0})})]}),i?(0,R.jsxs)("div",{className:"dswt-error",role:"alert",children:[(0,R.jsx)(X,{size:14})," ",i]}):null,r.length===0&&!s?(0,R.jsx)("p",{className:"dswt-muted",children:o("noWorktrees")}):null,r.map(L=>(0,R.jsxs)("div",{className:"dswt-repo",children:[(0,R.jsxs)("div",{className:"dswt-repo-path",children:[L.repoPath,(0,R.jsx)(H,{type:"button",disabled:c===L.repoPath,onClick:()=>{p(L)},children:o("prune")})]}),L.worktrees.map(f=>(0,R.jsxs)("div",{className:"dswt-worktree",children:[(0,R.jsxs)("div",{className:"dswt-worktree-main",children:[(0,R.jsx)("strong",{children:f.branch??o("detached")}),(0,R.jsx)("span",{className:"dswt-worktree-path",title:f.path,children:f.path}),(0,R.jsx)("span",{children:f.isMain?o("mainRepository"):o("linkedWorktree")}),(0,R.jsx)("span",{children:f.statusError?I(f):f.changedFiles?oe(o("dirty"),{count:String(f.changedFiles)}):o("clean")}),f.locked?(0,R.jsx)("span",{children:o("locked")}):null,f.prunable?(0,R.jsx)("span",{children:o("prunable")}):null]}),(0,R.jsxs)("div",{className:"dswt-worktree-actions",children:[(0,R.jsxs)(H,{type:"button",disabled:c===f.path||!!f.statusError,onClick:()=>{h(L,f)},children:[c===f.path?(0,R.jsx)(K,{size:14,className:"dswt-spin"}):null,o("open")]}),!f.isMain&&(f.prunable||f.statusError)?(0,R.jsx)(H,{type:"button",disabled:c===f.path,onClick:()=>{p(L)},children:o("prune")}):null,!f.isMain&&!f.prunable&&!f.statusError?(0,R.jsx)(H,{type:"button",disabled:c===f.path,onClick:()=>{d(L,f)},children:o("remove")}):null]})]},f.path))]},L.repoPath))]})}var Ur="/dsh-simple-worktree";function co(e){async function a(t,o){let r=await e.rpc.call(Ur,t,o);if(!r?.ok){let u=r?.error?.code,s=new Error(u==="worktree-unavailable"?"worktree-unavailable":u==="not-git-repository"?"not-git-repository":r?.error?.message??"worktree operation failed");throw s.code=r?.error?.code,s}return r.value}return{list:t=>a("worktree.list",{path:t}),classify:t=>a("worktree.classify",{path:t}),create:t=>a("worktree.create",t),remove:t=>a("worktree.remove",t),status:t=>a("worktree.status",{path:t}),prune:t=>a("worktree.prune",{path:t})}}var we=require("react/jsx-runtime"),po="data-dsh-simple-worktree-style";function Hr(){if(typeof document>"u"||document.querySelector(`style[${po}]`))return;let e=document.createElement("style");return e.setAttribute(po,""),e.textContent=Da,document.head.appendChild(e),()=>e.remove()}var mo={name:"@alpacachen/dsh-simple-worktree",inject:["slots","connection","locale","workspaces","sessions"],apply(e){e.effect(Hr,"dsh-simple-worktree styles"),e.effect(()=>qa(e),"dsh-simple-worktree locale");let a=co(e.connection),t=e.workspaces,o=e.sessions,r=e.get("locale"),u=e.get("workspaceExtensions"),s=new Set;e.effect(()=>{if(!(!r||typeof r.subscribe!="function"||!u))return r.subscribe(()=>u.invalidate())},"dsh-simple-worktree locale refresh");let l=new Set,i=!0,n=()=>{},c=0,m=async()=>{let I=++c,h=t.list.getSnapshot().items,d=await Promise.all(h.map(async p=>{try{return await a.classify(p.path)}catch{return}}));if(!(!i||I!==c)){s.clear(),l.clear();for(let p of d)p?.isGit&&p.path&&s.add(F(p.path)),p?.isWorktree&&p.path&&l.add(F(p.path));u?.invalidate()}};e.effect(()=>u?u.register({id:"dsh-simple-worktree",menuItem(h){let d=F(h.path);if(!(!s.has(d)||l.has(d)))return{id:"dsh-simple-worktree.create",label:Pe("createWorktree"),icon:(0,we.jsx)(Me,{}),order:30,onSelect:()=>n(h)}},deleteWorkspace(h){let d=F(h.path);if(l.has(d))return(async()=>{let p=await a.classify(h.path);!p.isWorktree||!p.repoPath||(await a.remove({repoPath:p.repoPath,path:h.path}),await t.delete(h.workspaceId),s.delete(d),l.delete(d),u?.invalidate())})()},icon(h){return l.has(F(h.path))?(0,we.jsx)(Me,{}):void 0}}):void 0,"dsh-simple-worktree workspace extensions"),e.effect(()=>{i=!0;let I=t.list.subscribe(()=>{m()});return m(),()=>{i=!1,c+=1,I()}},"dsh-simple-worktree workspace classification");function x(){let[I,h]=(0,Qe.useState)(null);return(0,Qe.useEffect)(()=>(n=(d,p="current")=>h({target:d,defaultBaseChoice:p}),()=>{n=()=>{}}),[]),I?(0,we.jsx)(fo,{target:I.target,api:a,workspaces:t,sessions:o,defaultBaseChoice:I.defaultBaseChoice,onCreated:d=>{s.add(F(d)),l.add(F(d)),u?.invalidate()},onClose:()=>h(null)}):null}e.slots.inject("conversation.input.dock",()=>e.slots.register({name:"conversation.input.dock",id:"dsh-simple-worktree-new-session",order:-30,locale:se,label:()=>Pe("createWorktree")},I=>(0,we.jsx)(no,{session:I.session,useWorkspaces:I.useWorkspaces,onOpen:h=>n(h,"main")}))),e.slots.inject("shell.overlay",()=>e.slots.register({name:"shell.overlay",id:"dsh-simple-worktree-create",order:30,locale:se,label:()=>Pe("createWorktree")},x)),e.slots.inject("settings.plugin.item",()=>e.slots.register({name:"settings.plugin.item",key:se,locale:se,inject:()=>({})},()=>(0,we.jsx)(io,{api:a,workspaces:t,sessions:o})))}};var Wr=mo;
|
|
175
175
|
/*! Bundled license information:
|
|
176
176
|
|
|
177
177
|
lucide-react/dist/esm/shared/src/utils.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alpacachen/dsh-simple-worktree",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A Git worktree plugin for DeepSeek Harness that creates task branches, registers worktrees as DSH Workspaces, and opens isolated sessions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|