texlite 0.10.0 → 0.12.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/DESIGN.md +44 -26
- package/OPERATIONS.md +12 -6
- package/README.md +9 -4
- package/README.zh-CN.md +7 -4
- package/dist/client/assets/AdminUsers-DMsBqC48.js +1 -0
- package/dist/client/assets/{CitationLibraryDialog-CU2b0xtm.js → CitationLibraryDialog-C_333dTc.js} +1 -1
- package/dist/client/assets/Dashboard-EOaNnS1A.js +2 -0
- package/dist/client/assets/GitDialog-DU-sVP-o.js +3 -0
- package/dist/client/assets/GitHubAccountDialog-IrB3M7nt.js +1 -0
- package/dist/client/assets/HistoryDialog-CDUbT7yG.js +7 -0
- package/dist/client/assets/LatexEditor-BYgW2otE.js +138 -0
- package/dist/client/assets/PdfPreview--HsIb8Fn.js +1 -0
- package/dist/client/assets/ProjectIconPickerDialog-CaF7Kkda.js +1 -0
- package/dist/client/assets/{ProjectNavigationDialogs-_JY0yVob.js → ProjectNavigationDialogs-3Ce7-tVp.js} +1 -1
- package/dist/client/assets/ProjectSettings-9hYSUKDo.js +1 -0
- package/dist/client/assets/ProjectWorkspace-D9zmy0KR.js +32 -0
- package/dist/client/assets/{SelectionHistoryDialog-D8CeqjLD.js → SelectionHistoryDialog-COpXO4kL.js} +2 -2
- package/dist/client/assets/SystemMetricsDialog-D9dthbAB.js +1 -0
- package/dist/client/assets/{TagManagementDialog-4R1Gs43j.js → TagManagementDialog-S8zDQAaB.js} +1 -1
- package/dist/client/assets/{WordCountDialog-C-MCscAu.js → WordCountDialog-CMsFa_pM.js} +1 -1
- package/dist/client/assets/check-Hv1kodh8.js +1 -0
- package/dist/client/assets/chktex-BFELQm91.js +3 -0
- package/dist/client/assets/{editor-B9HNwtsd.js → editor-taw1iptB.js} +1 -1
- package/dist/client/assets/external-link-C2GCFJxP.js +1 -0
- package/dist/client/assets/github-B_Eh2y6s.js +1 -0
- package/dist/client/assets/{hard-drive-Bsk-RETn.js → hard-drive-bzz70DQ5.js} +1 -1
- package/dist/client/assets/{index-Csp5J5aI.js → index-CXtmuEUm.js} +1 -1
- package/dist/client/assets/index-CxrDisif.css +1 -0
- package/dist/client/assets/index-Dik-2GCl.js +10 -0
- package/dist/client/assets/{minimize-2-92UqFWI9.js → minimize-2-CmPZ9Iwp.js} +1 -1
- package/dist/client/assets/{minus-bx4ZLZnb.js → minus-Dzy8rgfA.js} +1 -1
- package/dist/client/assets/{plus-DQg_bV50.js → plus-DlX82JCl.js} +1 -1
- package/dist/client/assets/{refresh-cw-BoMEkk5J.js → refresh-cw-BWndInnG.js} +1 -1
- package/dist/client/assets/{search-UZspmceH.js → search-DMqOy-Ex.js} +1 -1
- package/dist/client/assets/{sigma-C0IvFdKV.js → sigma-B0zOJKVj.js} +1 -1
- package/dist/client/assets/{spellCheck-DyKIHf5C.js → spellCheck-BjkrQxRU.js} +1 -1
- package/dist/client/assets/{tags-BTUtvaAc.js → tags-XvdXg-yc.js} +1 -1
- package/dist/client/assets/{type-XvvfEJRs.js → type-DsGlKUKR.js} +1 -1
- package/dist/client/assets/{user-plus-Chr9T97G.js → user-plus-Bcq_EsqH.js} +1 -1
- package/dist/client/assets/{x-DlFXD9Vl.js → x-BJOMjm8Z.js} +1 -1
- package/dist/client/index.html +3 -3
- package/dist/server/app.js +8 -0
- package/dist/server/chktex.js +377 -0
- package/dist/server/collaboration.js +6 -0
- package/dist/server/db.js +35 -1
- package/dist/server/environment.js +1 -0
- package/dist/server/git.js +64 -29
- package/dist/server/harper.js +14 -0
- package/dist/server/history.js +18 -9
- package/dist/server/i18n.js +14 -4
- package/dist/server/projectImportUploads.js +133 -0
- package/dist/server/routes/projectFiles.js +3 -0
- package/dist/server/routes/projectGit.js +10 -11
- package/dist/server/routes/projectHistory.js +32 -5
- package/dist/server/routes/projectMembers.js +0 -5
- package/dist/server/routes/projectShared.js +1 -0
- package/dist/server/routes/projects.js +97 -15
- package/dist/server/routes/users.js +0 -2
- package/dist/shared/historyFiles.js +6 -0
- package/dist/shared/writingChecks.js +4 -0
- package/package.json +1 -1
- package/dist/client/assets/AdminUsers-C7oU_1Y_.js +0 -1
- package/dist/client/assets/Dashboard-BB4RO4x2.js +0 -2
- package/dist/client/assets/GitDialog-C2Np1i8v.js +0 -3
- package/dist/client/assets/HistoryDialog-CdoYeLyX.js +0 -7
- package/dist/client/assets/LatexEditor-Dmy6_gqt.js +0 -138
- package/dist/client/assets/PdfPreview-fDxKh6hP.js +0 -1
- package/dist/client/assets/ProjectIconPickerDialog-CsjMKq7h.js +0 -1
- package/dist/client/assets/ProjectSettings-DXGA-lmB.js +0 -1
- package/dist/client/assets/ProjectWorkspace-mCYjyc6e.js +0 -32
- package/dist/client/assets/SystemMetricsDialog-BZx7ZMQt.js +0 -1
- package/dist/client/assets/check-Jf8WBxDX.js +0 -1
- package/dist/client/assets/index-B6rP7QsM.js +0 -12
- package/dist/client/assets/index-DGZNAyxW.css +0 -1
- package/dist/client/assets/key-round-DqptHHKC.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as k,j as e,r as c}from"./react-BVUjbTTn.js";import{g as u,h,M as y,d as x}from"./index-Dik-2GCl.js";import{G as b}from"./github-B_Eh2y6s.js";import{T}from"./x-BJOMjm8Z.js";import{E as A}from"./external-link-C2GCFJxP.js";function C(){const{t:i}=k();return e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:i("git.recommendedAccessTitle")}),e.jsxs("span",{children:[i("git.recommendedAccessBeforeAll"),e.jsx("em",{className:"git-token-highlight",children:"All repositories"}),i("git.recommendedAccessBeforeAdministration"),e.jsx("em",{className:"git-token-highlight",children:"Administration"}),i("git.recommendedAccessBetweenPermissions"),e.jsx("em",{className:"git-token-highlight",children:"Contents"}),i("git.recommendedAccessAfterPermissions")]})]})}function G({open:i,onOpenChange:p}){const{t}=k(),[r,m]=c.useState(null),[g,d]=c.useState(""),[a,n]=c.useState(""),[j,o]=c.useState(""),[f,l]=c.useState("");c.useEffect(()=>{i&&(n("load"),o(""),l(""),d(""),u("/api/account/github").then(s=>m(s.status)).catch(s=>o(h(s))).finally(()=>n(s=>s==="load"?"":s)))},[i]);const v=async()=>{n("save"),o(""),l("");try{const s=await u("/api/account/github",{method:"PUT",body:JSON.stringify({token:g})});m(s.status),d(""),l(t("account.githubSaved"))}catch(s){o(h(s))}finally{n("")}},N=async()=>{n("remove"),o(""),l("");try{const s=await u("/api/account/github",{method:"DELETE"});m(s.status),d(""),l(t("account.githubRemoved"))}catch(s){o(h(s))}finally{n("")}};return e.jsx(y,{open:i,title:t("account.githubTitle"),description:t("account.githubDescription"),onOpenChange:s=>{a||p(s)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:!!a,onClick:()=>p(!1),children:t("common.close")}),e.jsxs("button",{className:"primary",disabled:!!a||g.trim().length<20,onClick:()=>{v()},children:[a==="save"&&e.jsx(x,{className:"spin",size:14}),t("git.saveToken")]})]}),children:e.jsxs("div",{className:"git-dialog account-github-dialog",children:[a==="load"&&!r&&e.jsxs("div",{className:"git-loading",children:[e.jsx(x,{className:"spin",size:20}),t("common.loading")]}),j&&e.jsx("p",{className:"git-message error dialog-error",children:j}),f&&e.jsxs("p",{className:"git-message success",children:[e.jsx(b,{size:14}),f]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),r.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(b,{size:17}),e.jsx("span",{children:t("git.connectedAs",{login:r.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:()=>{N()},children:[a==="remove"?e.jsx(x,{className:"spin",size:14}):e.jsx(T,{size:14}),t("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[r.tokenConfigured?t("git.replaceToken"):t("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:g,placeholder:t("git.tokenPlaceholder"),onChange:s=>d(s.target.value)})]}),e.jsx("div",{className:"git-inline-actions",children:e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[t("git.createToken"),e.jsx(A,{size:12})]})}),e.jsx("p",{className:"muted account-github-encryption-note",children:t("account.githubEncryption")})]})]})})}export{G as GitHubAccountDialog};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{u as He,r as a,j as e}from"./react-BVUjbTTn.js";import{c as Be,g as _,M as Ve,d as le,C as Ce,A as we}from"./index-Dik-2GCl.js";import{d as _e,C as $e}from"./index-CXtmuEUm.js";import{H as Ie}from"./hard-drive-bzz70DQ5.js";import{T as Se,c as Oe,e as ue}from"./x-BJOMjm8Z.js";import{F as Te,R as Ee,S as Ue,B as We}from"./ProjectWorkspace-D9zmy0KR.js";import{M as Ye,a as qe}from"./minus-Dzy8rgfA.js";import{P as Ge}from"./plus-DlX82JCl.js";import{M as Je}from"./minimize-2-CmPZ9Iwp.js";import"./check-Hv1kodh8.js";import"./search-DMqOy-Ex.js";import"./user-plus-Bcq_EsqH.js";import"./refresh-cw-BWndInnG.js";const Ke=Be("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);function Fe(i,c,C,j="历史版本",s="当前版本",p=3){const S=c.replace(/\r\n/g,`
|
|
2
|
+
`),R=C.replace(/\r\n/g,`
|
|
3
|
+
`);if(S===R)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const h=new _e,k=h.diff_linesToChars_(S,R),b=h.diff_main(k.chars1,k.chars2,!1);h.diff_charsToLines_(b,k.lineArray);const w=[];let n=1,T=1,u=0,z=0;for(const[d,v]of b){if(!v)continue;const f=v.split(`
|
|
4
|
+
`);f[f.length-1]===""&&f.pop();for(const A of f)d===0?w.push({op:0,text:A,oldNum:n++,newNum:T++}):d===-1?(z++,w.push({op:-1,text:A,oldNum:n++,newNum:T})):d===1&&(u++,w.push({op:1,text:A,oldNum:n,newNum:T++}))}if(u===0&&z===0)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const g=[];let y=-1,P=-1;for(let d=0;d<w.length;d++)if(w[d].op!==0){const v=Math.max(0,d-p),f=Math.min(w.length-1,d+p);y===-1?(y=v,P=f):v<=P+1?P=Math.max(P,f):(g.push({start:y,end:P}),y=v,P=f)}y!==-1&&g.push({start:y,end:P});const G=[`--- a/${i} (${j})`,`+++ b/${i} (${s})`];for(const d of g){const v=w.slice(d.start,d.end+1),f=v.filter($=>$.op<=0).length,A=v.filter($=>$.op>=0).length,E=v[0],O=f===0?0:E.oldNum,J=A===0?0:E.newNum;G.push(`@@ -${O},${f} +${J},${A} @@`);for(const $ of v){const U=$.op===-1?"-":$.op===1?"+":" ";G.push(`${U}${$.text}`)}}return{diffText:G.join(`
|
|
5
|
+
`),additions:u,deletions:z,hasChanges:!0}}function me(i,c){try{const C=new Date(i);if(Number.isNaN(C.getTime()))return i;const j=new Date;return C.getFullYear()===j.getFullYear()&&C.getMonth()===j.getMonth()&&C.getDate()===j.getDate()?C.toLocaleTimeString(c,{hour:"2-digit",minute:"2-digit"}):C.toLocaleString(c,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function fe(i,c,C){if(i.label)return i.label;const j=me(i.createdAt,C);if(i.changedPaths.length===1)return`${i.changedPaths[0].split("/").pop()||i.changedPaths[0]} (${j})`;if(i.changedPaths.length===2){const p=i.changedPaths[0].split("/").pop()||i.changedPaths[0],S=i.changedPaths[1].split("/").pop()||i.changedPaths[1];return`${p}, ${S} (${j})`}if(i.changedPaths.length>2)return`${i.changedPaths[0].split("/").pop()||i.changedPaths[0]} +${i.changedPaths.length-1} (${j})`;const s=i.author?.name||i.author?.username;return s?`${s} @ ${j}`:`${c} (${j})`}function Ze(i){const c=i.split("/").at(-1)??"";return/\.(?:tex|bib|bst|sty|cls|txt|md|rst|dat|csv|tsv|json|ya?ml|toml|xml|html?|css|[cm]?js|tsx?|py|sh|r|log|bbl|aux|idx|ind|gls)$/i.test(c)||/^(?:\.?latexmkrc|readme|licen[cs]e|makefile)$/i.test(c)}const De=100;function ht({open:i,project:c,onOpenChange:C,onBeforeMutation:j}){const{t:s,i18n:p}=He(),[S,R]=a.useState([]),[h,k]=a.useState(null),[b,w]=a.useState(""),[n,T]=a.useState(null),[u,z]=a.useState(""),[g,y]=a.useState(null),[P,G]=a.useState(0),[d,v]=a.useState("commit"),[f,A]=a.useState(11),[E,O]=a.useState(!1),[J,$]=a.useState(""),[U,te]=a.useState(null),[M,se]=a.useState(null),[K,m]=a.useState(""),[pe,re]=a.useState(null),[Z,ie]=a.useState(!1),[ge,x]=a.useState(""),ce=a.useRef(null),F=a.useRef(null),D=a.useRef(null),ye=a.useRef(b),xe=a.useRef(c.id),ne=a.useRef(!1),H=a.useRef(null);ye.current=b,xe.current=c.id;const ae=c.permission!=="read",de=c.permission==="owner",W=!!K||Z;a.useEffect(()=>{if(!i){D.current?.abort(),D.current=null,H.current!==null&&window.clearTimeout(H.current),H.current=null,F.current?.abort(),F.current=null,ie(!1),document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),O(!1);return}F.current?.abort(),F.current=null;const t=new AbortController;return m("load"),x(""),y(null),re(null),ie(!1),_(`/api/projects/${c.id}/history?limit=${De}`,{signal:t.signal}).then(r=>{R(r.versions),k(r.stats),re(r.nextCursor),w(l=>r.versions.some(o=>o.id===l)?l:r.versions[0]?.id??"")}).catch(r=>{q(r)||x(I(r))}).finally(()=>{t.signal.aborted||m("")}),()=>t.abort()},[i,c.id]),a.useEffect(()=>()=>{F.current?.abort(),F.current=null,D.current?.abort(),D.current=null,H.current!==null&&window.clearTimeout(H.current)},[c.id]),a.useEffect(()=>{D.current?.abort(),D.current=null},[b]);const Le=async()=>{const t=pe;if(!t||Z||K)return;F.current?.abort();const r=new AbortController;F.current=r,ie(!0),x("");try{const l=new URLSearchParams({limit:String(De),before:t}),o=await _(`/api/projects/${c.id}/history?${l.toString()}`,{signal:r.signal});if(r.signal.aborted)return;R(N=>{const V=new Set(N.map(L=>L.id));return[...N,...o.versions.filter(L=>!V.has(L.id))]}),k(o.stats),re(o.nextCursor)}catch(l){q(l)||x(I(l))}finally{F.current===r&&(F.current=null,ie(!1))}};a.useEffect(()=>{const t=()=>O(document.fullscreenElement===ce.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),a.useEffect(()=>{if(!E)return;const t=r=>{r.key==="Escape"&&!document.fullscreenElement&&O(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[E]),a.useEffect(()=>{if(!i||!b){T(null);return}const t=new AbortController;return m("detail"),y(null),_(`/api/projects/${c.id}/history/${b}`,{signal:t.signal}).then(r=>{if(t.signal.aborted)return;T(r),$(r.version.label??"");const l=r.version.changedPaths.find(o=>r.files.some(N=>N.path===o))??"";z(l)}).catch(r=>{!t.signal.aborted&&!q(r)&&x(I(r))}).finally(()=>{t.signal.aborted||m(r=>r==="detail"?"":r)}),()=>t.abort()},[i,c.id,b]);const Y=g?.previousVersion??null,he=Ze(u),je=n?.files.find(t=>t.path===u)?.deleted===!0;a.useEffect(()=>{if(!i||!b||!u||!he){ne.current=!1,y(null),m(o=>o==="compare"?"":o);return}const t=new AbortController;y(null),m("compare");const r=ne.current;ne.current=!1,r||x("");const l=d==="commit"?"&against=__previous__":"";return _(`/api/projects/${c.id}/history/${b}/file?path=${encodeURIComponent(u)}${l}`,{signal:t.signal}).then(o=>{t.signal.aborted||y(o)}).catch(o=>{!t.signal.aborted&&!q(o)&&x(I(o))}).finally(()=>{t.signal.aborted||m(o=>o==="compare"?"":o)}),()=>t.abort()},[i,c.id,b,u,he,d,P]);const B=a.useMemo(()=>{if(!n)return[];const t=new Set(n.version.changedPaths);return n.files.filter(r=>t.has(r.path))},[n]);a.useEffect(()=>{B.length>0&&!B.some(t=>t.path===u)?z(B[0].path):B.length===0&&u&&z("")},[B,u]);const Re=async()=>{if(E){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),O(!1);return}const t=ce.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}O(!0)},be=async(t,r=!1)=>{const l=c.id;D.current?.abort();const o=new AbortController;D.current=o;try{const N=await _(`/api/projects/${l}/history/${t}`,{signal:o.signal});return o.signal.aborted||xe.current!==l||ye.current!==t?!1:(T(N),$(N.version.label??""),z(V=>V&&N.files.some(L=>L.path===V)?V:N.version.changedPaths.find(L=>N.files.some(Me=>Me.path===L))??""),y(null),r&&(ne.current=!0),G(V=>V+1),R(V=>V.map(L=>L.id===N.version.id?N.version:L)),!0)}finally{D.current===o&&(D.current=null)}},ke=async()=>{if(n){m("label"),x("");try{const t=await _(`/api/projects/${c.id}/history/${n.version.id}`,{method:"PATCH",body:JSON.stringify({label:J.trim()||null,snapshotHash:n.version.snapshotHash})});T(r=>r&&{...r,version:t.version}),R(r=>r.map(l=>l.id===t.version.id?t.version:l)),k(t.stats),t.retentionScheduled&&(H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(()=>{H.current=null,_(`/api/projects/${c.id}/history?limit=1`).then(r=>{k(r.stats)}).catch(()=>{})},t.retentionRefreshAfterMs))}catch(t){if(t instanceof we&&t.code==="HISTORY_VERSION_CHANGED")try{if(!await be(n.version.id,!0))return}catch(r){if(q(r))return;x(I(r));return}x(I(t))}finally{m("")}}},ze=async()=>{const t=M;if(t){se(null),m("delete"),x("");try{if(!await j())throw new Error(s("errors.collaborationUnavailable"));const r=t==="all"?`/api/projects/${c.id}/history`:`/api/projects/${c.id}/history/${t.id}`,l=await _(r,{method:"DELETE"});if(k(l.stats),t==="all")R([]),w(""),T(null),y(null),re(null);else{const o=S.filter(N=>N.id!==t.id);R(o),b===t.id&&(w(o[0]?.id??""),T(null),y(null))}}catch(r){x(I(r))}finally{m("")}}},Pe=async()=>{const t=U;if(!(!t||!n)){te(null),m("restore"),x("");try{if(!await j())throw new Error(s("errors.collaborationUnavailable"));await _(`/api/projects/${c.id}/history/${n.version.id}/restore`,{method:"POST",body:JSON.stringify(t==="project"?{snapshotHash:n.version.snapshotHash}:{path:t,snapshotHash:n.version.snapshotHash})}),window.location.reload()}catch(r){if(r instanceof we&&r.code==="HISTORY_VERSION_CHANGED")try{if(!await be(n.version.id,!0)){m("");return}}catch(l){if(q(l)){m("");return}x(I(l)),m("");return}x(I(r)),m("")}}},oe=n?.version.author?.name||n?.version.author?.username||(n?.version.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser")),Q=n?me(n.version.createdAt,p.resolvedLanguage):"",X=a.useMemo(()=>{if(!g||!n)return{diffText:"",additions:0,deletions:0,hasChanges:!1};if(d==="commit"){const t=g.comparison,r=g.historical,l=Y?`${Y.label||s(`history.reasons.${Y.reason}`)} (${me(Y.createdAt,p.resolvedLanguage)})`:"/dev/null",o=`${oe} @ ${Q}`;return Fe(g.path,t,r,l,o)}else{const t=g.historical,r=g.comparison,l=`${n.version.label||s(`history.reasons.${n.version.reason}`)} (${Q})`,o=s("history.currentVersion");return Fe(g.path,t,r,l,o)}},[g,n,d,Y,oe,Q,s,p.resolvedLanguage]),ve=n?s(`history.reasons.${n.version.reason}`):"",Ne=n?fe(n.version,ve,p.resolvedLanguage):"",Ae=M&&M!=="all"?fe(M,s(`history.reasons.${M.reason}`),p.resolvedLanguage):"";return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{open:i,extraWide:!0,draggable:!0,className:"history-dialog-modal",title:s("history.projectSnapshots"),description:s("history.description"),onOpenChange:C,footer:e.jsx("button",{onClick:()=>C(!1),children:s("common.close")}),children:e.jsxs("div",{className:"history-dialog",children:[ge&&e.jsx("p",{className:"error history-message",children:ge}),K==="load"&&S.length===0?e.jsxs("div",{className:"history-loading",children:[e.jsx(le,{className:"spin",size:22}),s("common.loading")]}):e.jsxs("div",{className:"history-dialog-layout",children:[e.jsxs("aside",{className:"history-timeline",children:[de&&h&&e.jsxs("div",{className:`history-stats${h.storageLimitExceeded?" exceeded":""}`,children:[e.jsxs("header",{children:[e.jsxs("span",{children:[e.jsx(Ie,{size:14}),s("history.storage")]}),e.jsx("button",{type:"button",disabled:W||S.length===0,title:s("history.clearAll"),"aria-label":s("history.clearAll"),onClick:()=>se("all"),children:e.jsx(Se,{size:13})})]}),e.jsx("strong",{children:s("history.storageUsage",{used:ee(h.totalBytes),limit:ee(h.maxStorageBytes)})}),e.jsx("progress",{max:h.maxStorageBytes,value:Math.min(h.totalBytes,h.maxStorageBytes)}),e.jsx("small",{children:s("history.storageBreakdown",{objects:ee(h.objectBytes),metadata:ee(h.metadataBytes),protected:ee(h.protectedBytes)})}),e.jsxs("small",{children:[s("history.versionUsage",{count:h.ordinaryVersionCount,limit:h.maxVersions>0?h.maxVersions:"∞"}),h.labeledVersionCount>0?` · ${s("history.protectedVersions",{count:h.labeledVersionCount})}`:""]}),h.storageLimitExceeded&&e.jsx("small",{className:"history-storage-warning",children:s("history.storageExceeded")})]}),S.map(t=>{const r=s(`history.reasons.${t.reason}`),l=fe(t,r,p.resolvedLanguage),o=t.author?.name||t.author?.username||(t.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser"));return e.jsxs("button",{className:t.id===b?"active":"",onClick:()=>w(t.id),children:[e.jsx(Te,{size:15}),e.jsxs("span",{children:[e.jsxs("div",{className:"history-item-heading",children:[e.jsx("strong",{title:l,children:l}),e.jsx("span",{className:`history-reason-badge reason-${t.reason}`,children:r})]}),e.jsx("small",{children:new Date(t.createdAt).toLocaleString(p.resolvedLanguage)}),e.jsxs("small",{children:[o," · ",s("history.changedCount",{count:t.changedPaths.length})]})]})]},t.id)}),pe&&e.jsx("div",{className:"history-load-more",children:e.jsxs("button",{type:"button",disabled:W,"aria-busy":Z,onClick:()=>{Le()},children:[Z?e.jsx(le,{className:"spin",size:13}):e.jsx($e,{size:13}),s(Z?"common.loading":"history.loadOlder")]})}),S.length===0&&e.jsx("p",{className:"muted padded",children:s("history.empty")})]}),e.jsx("section",{className:"history-detail",children:n&&e.jsxs(e.Fragment,{children:[e.jsx("header",{className:"history-detail-header",children:e.jsxs("div",{children:[e.jsxs("div",{className:"history-detail-title-row",children:[e.jsx("strong",{title:Ne,children:Ne}),e.jsx("span",{className:`history-reason-badge reason-${n.version.reason}`,children:ve})]}),e.jsxs("small",{children:[e.jsx($e,{size:12}),new Date(n.version.createdAt).toLocaleString(p.resolvedLanguage)," · ",oe," · ",s("history.fileCount",{count:n.version.fileCount})]})]})}),(de||ae)&&e.jsxs("div",{className:"history-snapshot-actions",children:[de&&e.jsxs("button",{type:"button",className:"history-delete-action",disabled:W,title:s("history.deleteVersionTitle"),onClick:()=>se(n.version),children:[e.jsx(Se,{size:14}),s("history.deleteVersion")]}),ae&&e.jsxs("button",{type:"button",className:"history-restore-project",disabled:W,title:s("history.restoreProjectTitle"),onClick:()=>te("project"),children:[e.jsx(Ee,{size:14}),s("history.restoreProject")]})]}),ae&&e.jsxs("div",{className:"history-label",children:[e.jsxs("label",{children:[e.jsx(Ke,{size:14}),e.jsx("input",{value:J,maxLength:80,placeholder:s("history.labelPlaceholder"),onChange:t=>$(t.target.value)})]}),e.jsxs("button",{disabled:W||J.trim()===(n.version.label??""),onClick:()=>{ke()},children:[K==="label"?e.jsx(le,{className:"spin",size:13}):e.jsx(Ue,{size:13}),s("history.saveLabel")]})]}),e.jsxs("div",{className:"history-files",children:[e.jsx("div",{className:"history-files-toolbar",children:e.jsxs("div",{className:"history-files-heading",children:[e.jsx(Oe,{size:13}),e.jsx("span",{children:s("history.changedFilesHeading",{count:B.length})})]})}),B.length>0?e.jsxs("div",{className:"history-file-tabs-row",children:[e.jsx("div",{className:"history-file-list",children:B.map(t=>e.jsxs("button",{type:"button",className:t.path===u?"active":"",title:t.path,onClick:()=>z(t.path),children:[e.jsx(ue,{size:13}),e.jsx("span",{children:t.path})]},t.path))}),ae&&e.jsx("div",{className:"history-file-actions",children:e.jsxs("button",{type:"button",disabled:!u||je||W,title:s("history.restoreFileTitle"),onClick:()=>te(u),children:[e.jsx(Ee,{size:13}),s("history.restoreFile")]})})]}):e.jsx("p",{className:"muted padded-small",children:s("history.noChangedFiles")})]}),u&&!he?e.jsxs("p",{className:"history-attachment-change",children:[e.jsx(ue,{size:14}),e.jsx("span",{children:s(je?"history.nonTextFileDeleted":"history.nonTextFileChanged",{path:u})})]}):e.jsx("div",{ref:ce,className:`history-comparison${E?" is-fullscreen":""}`,children:u?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsxs("div",{className:"history-comparison-meta",children:[e.jsx("strong",{children:u}),e.jsxs("small",{className:"history-commit-summary",children:[d==="commit"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"history-commit-author",children:oe}),e.jsx("span",{children:Y?s("history.changedAt",{time:Q}):s("history.createdAt",{time:Q})})]}):e.jsx("span",{children:s("history.comparingCurrent")}),X.hasChanges&&e.jsxs("span",{className:"history-diff-stats",children:[e.jsxs("span",{className:"addition",children:["+",X.additions]})," ",e.jsxs("span",{className:"deletion",children:["-",X.deletions]})]})]})]}),e.jsxs("div",{className:"history-diff-controls",children:[e.jsx("div",{className:"history-diff-control-group",children:e.jsxs("div",{className:"history-mode-toggle",role:"group","aria-label":s("history.diffMode"),children:[e.jsx("button",{type:"button",className:d==="commit"?"active":"","aria-pressed":d==="commit",onClick:()=>v("commit"),title:s("history.diffModeCommitHint"),children:e.jsx("span",{children:s("history.diffModeCommit")})}),e.jsx("button",{type:"button",className:d==="current"?"active":"","aria-pressed":d==="current",onClick:()=>v("current"),title:s("history.diffModeCurrentHint"),children:e.jsx("span",{children:s("history.diffModeCurrent")})})]})}),e.jsx("span",{className:"history-diff-control-divider","aria-hidden":"true"}),e.jsx("div",{className:"history-diff-control-group",children:e.jsxs("div",{className:"git-diff-font-controls",role:"group","aria-label":s("git.diffFontSize"),children:[e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:f<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>A(t=>Math.max(8,t-1)),children:e.jsx(Ye,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[f,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:f>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>A(t=>Math.min(24,t+1)),children:e.jsx(Ge,{size:14})})]})}),e.jsx("span",{className:"history-diff-control-divider","aria-hidden":"true"}),e.jsx("div",{className:"history-diff-control-group",children:e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(E?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(E?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{Re()},children:E?e.jsx(Je,{size:15}):e.jsx(qe,{size:15})})})]})]}),K==="compare"&&!g?e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(le,{className:"spin",size:24}),e.jsx("span",{children:s("common.loading")})]}):g?X.hasChanges?e.jsx("pre",{className:"git-diff history-git-diff",style:{fontSize:`${f}px`},children:X.diffText.split(`
|
|
6
|
+
`).map((t,r)=>{const l=t.startsWith("+")&&!t.startsWith("+++")?"addition":t.startsWith("-")&&!t.startsWith("---")?"deletion":t.startsWith("@@")?"hunk":t.startsWith("diff ")||t.startsWith("---")||t.startsWith("+++")?"header":"";return e.jsxs("span",{className:l,children:[t,`
|
|
7
|
+
`]},r)})}):e.jsxs("div",{className:"git-diff-empty history-diff-empty",children:[e.jsx(We,{size:24}),e.jsx("span",{children:s(d==="commit"?"history.noDifferencesInCommit":"history.noDifferences")})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(ue,{size:24}),e.jsx("span",{children:s("apiErrors.historyPreviewUnsupported")})]})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(Te,{size:25}),e.jsx("span",{children:B.length===0?s("history.noChangedFiles"):s("history.chooseFile")})]})})]})})]})]})}),e.jsx(Ce,{open:!!U,title:s(U==="project"?"history.restoreProjectTitle":"history.restoreFileTitle"),description:U==="project"?s("history.restoreProjectDescription"):s("history.restoreFileDescription",{path:U??""}),confirmLabel:s("history.restore"),danger:!0,onCancel:()=>te(null),onConfirm:()=>{Pe()}}),e.jsx(Ce,{open:!!M,title:s(M==="all"?"history.clearAllTitle":"history.deleteVersionTitle"),description:M==="all"?s("history.clearAllDescription"):s("history.deleteVersionDescription",{name:Ae}),confirmLabel:s(M==="all"?"history.clearAll":"history.deleteVersion"),danger:!0,onCancel:()=>se(null),onConfirm:()=>{ze()}})]})}function ee(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/102.4)/10} KB`:i<1024*1024*1024?`${Math.round(i/(1024*1024)*10)/10} MB`:`${Math.round(i/(1024*1024*1024)*10)/10} GB`}function I(i){return i instanceof Error?i.message:String(i)}function q(i){return i instanceof Error&&i.name==="AbortError"}export{ht as HistoryDialog};
|