@teammy/server 0.1.11 → 0.1.13

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 +1 @@
1
- import{$ as e,A as t,D as n,M as r,O as i,S as a,c as o,d as s,s as c,u as l,v as u}from"./index-BW6ule39.js";var d=e(),f=new Intl.Collator(`zh-CN`,{numeric:!0,sensitivity:`base`});function p(e,t){return f.compare(e,t)||(e<t?-1:+(e>t))}var m=t();function h(e){let t=e.target.closest(`[role="treeitem"]`);if(!t)return;let n=[...e.currentTarget.querySelectorAll(`[role="treeitem"]`)],r=n.indexOf(t),i=Number(t.getAttribute(`aria-level`)),a;switch(e.key){case`ArrowDown`:a=n[r+1];break;case`ArrowUp`:a=n[r-1];break;case`Home`:a=n[0];break;case`End`:a=n.at(-1);break;case`ArrowRight`:t.getAttribute(`aria-expanded`)===`false`?t.click():Number(n[r+1]?.getAttribute(`aria-level`))>i&&(a=n[r+1]);break;case`ArrowLeft`:t.getAttribute(`aria-expanded`)===`true`?t.click():a=n.slice(0,r).reverse().find(e=>Number(e.getAttribute(`aria-level`))<i);break;default:return}e.preventDefault(),a?.focus()}var g=(e,t)=>`${e}/${t}`,_=e=>({"--tree-level":e});function v({members:e,...t}){let[n,r]=(0,d.useState)(`folder:${g(e[0]?.id??``,``)}`);return(0,m.jsx)(`div`,{role:`tree`,"aria-label":`工作区文件`,"data-testid":`workspace-tree`,onKeyDown:h,children:(0,m.jsx)(b,{owner:c,path:``,level:1,members:e.filter(e=>e.hasFiles),context:{...t,focused:n,onFocus:r}})})}function y({owner:e,path:t,level:n,context:r}){let i=r.expanded.has(g(e,t)),a=`folder:${g(e,t)}`;return(0,m.jsxs)(`div`,{role:`none`,children:[(0,m.jsxs)(s,{type:`button`,role:`treeitem`,className:`tree-item tree-folder`,style:_(n),"aria-label":t||e,"aria-level":n,"aria-expanded":i,"aria-selected":r.selected?.kind===`directory`&&r.selected.owner===e&&r.selected.path===t,tabIndex:r.focused===a?0:-1,"data-testid":`directory-row`,"data-owner-id":e,"data-directory-path":t,onFocus:()=>r.onFocus(a),onClick:()=>r.onToggle(e,t),leading:(0,m.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,m.jsx)(u,{name:`chevron`,size:`small`})}),children:[(0,m.jsx)(u,{name:`files`}),(0,m.jsx)(`span`,{className:`tree-name`,children:t.split(`/`).at(-1)||e})]}),i&&(0,m.jsx)(b,{owner:e,path:t,level:n+1,context:r})]})}function b({owner:e,path:t,level:c,context:f,members:h=[]}){let{api:v,projectId:b}=l(),x=(0,d.useCallback)(n=>v.tree(e,t,void 0,``,n),[e,t]),S=n(x,!1,i(b,`file-tree`,e,t)),[C,w]=(0,d.useState)(),[T,E]=(0,d.useState)(!1),[D,O]=(0,d.useState)(``),k=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>k.current?.abort(),[]);let A=C?.revision===S.data?.revision?C:void 0,j=A?A.nextCursor:S.data?.nextCursor;async function M(){if(!j||!S.data||T)return;E(!0),O(``);let n=new AbortController;k.current=n;try{let r=await v.tree(e,t,S.data.revision,j,n.signal);n.signal.aborted||w({...r,entries:[...A?.entries??[],...r.entries]})}catch(e){n.signal.aborted||O(r(e))}finally{n.signal.aborted||E(!1)}}let N=[...(S.data?.entries??[]).filter(e=>!o(e.path)),...(A?.entries??[]).filter(e=>!o(e.path))],P=f.revealed;if(P?.owner===e&&!o(P.path)&&(!t||P.path.startsWith(t+`/`))){let e=t?P.path.slice(t.length+1):P.path,n=e.indexOf(`/`),r=n<0?P.path:[t,e.slice(0,n)].filter(Boolean).join(`/`);N.some(e=>e.path===r)||N.push(n<0?{...P.file,kind:`file`}:{kind:`directory`,path:r})}let F=[...N.map(t=>({...t,owner:e})),...h.map(e=>({kind:`directory`,path:``,owner:e.id}))].sort((e,t)=>e.kind===t.kind?p(e.path.split(`/`).at(-1)||e.owner,t.path.split(`/`).at(-1)||t.owner):e.kind===`directory`?-1:1);return(0,m.jsxs)(`div`,{role:`group`,"aria-label":g(e===`_project`?`workspaces`:e,t),"aria-busy":S.loading||T,children:[S.loading&&(0,m.jsx)(`p`,{className:`tree-status`,role:`status`,children:`正在加载…`}),(0,m.jsx)(a,{error:!0,children:S.error||D}),S.error&&(0,m.jsx)(`button`,{className:`tree-action`,onClick:()=>void S.reload(),children:`重试`}),F.map(t=>t.kind===`directory`?(0,m.jsx)(y,{owner:t.owner,path:t.path,level:c,context:f},g(t.owner,t.path)):(0,m.jsxs)(s,{type:`button`,role:`treeitem`,className:`tree-item`,style:_(c),"aria-label":t.path,"aria-level":c,"aria-selected":f.selected?.kind===`file`&&f.selected.owner===e&&f.selected.path===t.path,tabIndex:f.focused===`file:${g(e,t.path)}`?0:-1,"data-testid":`file-row`,"data-owner-id":e,"data-file-path":t.path,onFocus:()=>f.onFocus(`file:${g(e,t.path)}`),onClick:()=>f.onSelect(e,t.path),leading:(0,m.jsx)(`span`,{className:`tree-chevron`}),children:[(0,m.jsx)(u,{name:`file`}),(0,m.jsx)(`span`,{className:`tree-name`,children:t.path.split(`/`).at(-1)})]},t.path)),j&&(0,m.jsx)(`button`,{className:`tree-action`,"data-testid":`files-load-more`,disabled:T,onClick:()=>void M(),children:T?`正在加载…`:`加载更多`})]})}export{p as i,g as n,h as r,v as t};
1
+ import{$ as e,A as t,D as n,M as r,O as i,S as a,c as o,d as s,s as c,u as l,v as u}from"./index-BTcnf4jy.js";var d=e(),f=new Intl.Collator(`zh-CN`,{numeric:!0,sensitivity:`base`});function p(e,t){return f.compare(e,t)||(e<t?-1:+(e>t))}var m=t();function h(e){let t=e.target.closest(`[role="treeitem"]`);if(!t)return;let n=[...e.currentTarget.querySelectorAll(`[role="treeitem"]`)],r=n.indexOf(t),i=Number(t.getAttribute(`aria-level`)),a;switch(e.key){case`ArrowDown`:a=n[r+1];break;case`ArrowUp`:a=n[r-1];break;case`Home`:a=n[0];break;case`End`:a=n.at(-1);break;case`ArrowRight`:t.getAttribute(`aria-expanded`)===`false`?t.click():Number(n[r+1]?.getAttribute(`aria-level`))>i&&(a=n[r+1]);break;case`ArrowLeft`:t.getAttribute(`aria-expanded`)===`true`?t.click():a=n.slice(0,r).reverse().find(e=>Number(e.getAttribute(`aria-level`))<i);break;default:return}e.preventDefault(),a?.focus()}var g=(e,t)=>`${e}/${t}`,_=e=>({"--tree-level":e});function v({members:e,...t}){let[n,r]=(0,d.useState)(`folder:${g(e[0]?.id??``,``)}`);return(0,m.jsx)(`div`,{role:`tree`,"aria-label":`工作区文件`,"data-testid":`workspace-tree`,onKeyDown:h,children:(0,m.jsx)(b,{owner:c,path:``,level:1,members:e.filter(e=>e.hasFiles),context:{...t,focused:n,onFocus:r}})})}function y({owner:e,path:t,level:n,context:r}){let i=r.expanded.has(g(e,t)),a=`folder:${g(e,t)}`;return(0,m.jsxs)(`div`,{role:`none`,children:[(0,m.jsxs)(s,{type:`button`,role:`treeitem`,className:`tree-item tree-folder`,style:_(n),"aria-label":t||e,"aria-level":n,"aria-expanded":i,"aria-selected":r.selected?.kind===`directory`&&r.selected.owner===e&&r.selected.path===t,tabIndex:r.focused===a?0:-1,"data-testid":`directory-row`,"data-owner-id":e,"data-directory-path":t,onFocus:()=>r.onFocus(a),onClick:()=>r.onToggle(e,t),leading:(0,m.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,m.jsx)(u,{name:`chevron`,size:`small`})}),children:[(0,m.jsx)(u,{name:`files`}),(0,m.jsx)(`span`,{className:`tree-name`,children:t.split(`/`).at(-1)||e})]}),i&&(0,m.jsx)(b,{owner:e,path:t,level:n+1,context:r})]})}function b({owner:e,path:t,level:c,context:f,members:h=[]}){let{api:v,projectId:b}=l(),x=(0,d.useCallback)(n=>v.tree(e,t,void 0,``,n),[e,t]),S=n(x,!1,i(b,`file-tree`,e,t)),[C,w]=(0,d.useState)(),[T,E]=(0,d.useState)(!1),[D,O]=(0,d.useState)(``),k=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>k.current?.abort(),[]);let A=C?.revision===S.data?.revision?C:void 0,j=A?A.nextCursor:S.data?.nextCursor;async function M(){if(!j||!S.data||T)return;E(!0),O(``);let n=new AbortController;k.current=n;try{let r=await v.tree(e,t,S.data.revision,j,n.signal);n.signal.aborted||w({...r,entries:[...A?.entries??[],...r.entries]})}catch(e){n.signal.aborted||O(r(e))}finally{n.signal.aborted||E(!1)}}let N=[...(S.data?.entries??[]).filter(e=>!o(e.path)),...(A?.entries??[]).filter(e=>!o(e.path))],P=f.revealed;if(P?.owner===e&&!o(P.path)&&(!t||P.path.startsWith(t+`/`))){let e=t?P.path.slice(t.length+1):P.path,n=e.indexOf(`/`),r=n<0?P.path:[t,e.slice(0,n)].filter(Boolean).join(`/`);N.some(e=>e.path===r)||N.push(n<0?{...P.file,kind:`file`}:{kind:`directory`,path:r})}let F=[...N.map(t=>({...t,owner:e})),...h.map(e=>({kind:`directory`,path:``,owner:e.id}))].sort((e,t)=>e.kind===t.kind?p(e.path.split(`/`).at(-1)||e.owner,t.path.split(`/`).at(-1)||t.owner):e.kind===`directory`?-1:1);return(0,m.jsxs)(`div`,{role:`group`,"aria-label":g(e===`_project`?`workspaces`:e,t),"aria-busy":S.loading||T,children:[S.loading&&(0,m.jsx)(`p`,{className:`tree-status`,role:`status`,children:`正在加载…`}),(0,m.jsx)(a,{error:!0,children:S.error||D}),S.error&&(0,m.jsx)(`button`,{className:`tree-action`,onClick:()=>void S.reload(),children:`重试`}),F.map(t=>t.kind===`directory`?(0,m.jsx)(y,{owner:t.owner,path:t.path,level:c,context:f},g(t.owner,t.path)):(0,m.jsxs)(s,{type:`button`,role:`treeitem`,className:`tree-item`,style:_(c),"aria-label":t.path,"aria-level":c,"aria-selected":f.selected?.kind===`file`&&f.selected.owner===e&&f.selected.path===t.path,tabIndex:f.focused===`file:${g(e,t.path)}`?0:-1,"data-testid":`file-row`,"data-owner-id":e,"data-file-path":t.path,onFocus:()=>f.onFocus(`file:${g(e,t.path)}`),onClick:()=>f.onSelect(e,t.path),leading:(0,m.jsx)(`span`,{className:`tree-chevron`}),children:[(0,m.jsx)(u,{name:`file`}),(0,m.jsx)(`span`,{className:`tree-name`,children:t.path.split(`/`).at(-1)})]},t.path)),j&&(0,m.jsx)(`button`,{className:`tree-action`,"data-testid":`files-load-more`,disabled:T,onClick:()=>void M(),children:T?`正在加载…`:`加载更多`})]})}export{p as i,g as n,h as r,v as t};
@@ -1 +1 @@
1
- import{L as e}from"./index-BW6ule39.js";function t(t,n){if(!n||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(n))return null;try{let r=n.split(/[?#]/,1)[0],i=r?t.split(`/`).slice(0,-1):t.split(`/`);for(let e of r.split(`/`)){let t=decodeURIComponent(e);if(t&&t!==`.`){if(t===`..`){if(!i.length)return null;i.pop()}else{if(t.includes(`/`)||t.includes(`\\`))return null;i.push(t)}}}return{path:i.length?e.parse(i.join(`/`)):``,directory:r.endsWith(`/`),anchor:n.includes(`#`)?decodeURIComponent(n.slice(n.indexOf(`#`)+1)):``}}catch{return null}}export{t};
1
+ import{L as e}from"./index-BTcnf4jy.js";function t(t,n){if(!n||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(n))return null;try{let r=n.split(/[?#]/,1)[0],i=r?t.split(`/`).slice(0,-1):t.split(`/`);for(let e of r.split(`/`)){let t=decodeURIComponent(e);if(t&&t!==`.`){if(t===`..`){if(!i.length)return null;i.pop()}else{if(t.includes(`/`)||t.includes(`\\`))return null;i.push(t)}}}return{path:i.length?e.parse(i.join(`/`)):``,directory:r.endsWith(`/`),anchor:n.includes(`#`)?decodeURIComponent(n.slice(n.indexOf(`#`)+1)):``}}catch{return null}}export{t};