@hienlh/ppm 0.13.75 → 0.13.77
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/CHANGELOG.md +11 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/{audio-preview-BQUzmaMW.js → audio-preview-CAkLsTgJ.js} +1 -1
- package/dist/web/assets/{chat-tab-B80a21gx.js → chat-tab-DNSelhRT.js} +5 -5
- package/dist/web/assets/{code-editor-hFO6vAKT.js → code-editor-ClG-6IDZ.js} +2 -2
- package/dist/web/assets/{conflict-editor-CrpXDFE1.js → conflict-editor-CcmoCxAD.js} +1 -1
- package/dist/web/assets/{database-viewer-CAjJc7bL.js → database-viewer-C57quEhw.js} +1 -1
- package/dist/web/assets/{diff-viewer-CdZ15fOk.js → diff-viewer-1ETGHhmC.js} +1 -1
- package/dist/web/assets/{docx-preview-AgoO5zwo.js → docx-preview-CSIdvMph.js} +1 -1
- package/dist/web/assets/{extension-webview-C4D4PnO3.js → extension-webview-DyapNP2E.js} +1 -1
- package/dist/web/assets/{git-log-panel-J0pVWvZl.js → git-log-panel-BSNVzOrq.js} +1 -1
- package/dist/web/assets/glide-data-grid-CZVrZJpS.js +138 -0
- package/dist/web/assets/{image-preview-CyL9Lj_O.js → image-preview-DprBBsHy.js} +1 -1
- package/dist/web/assets/{index-Dd6YEaE6.js → index-BlRGbnAE.js} +3 -3
- package/dist/web/assets/keybindings-store-CqcGrKcu.js +1 -0
- package/dist/web/assets/{markdown-renderer-Cat4uT8B.js → markdown-renderer-pJFF8cN8.js} +1 -1
- package/dist/web/assets/notification-store-DQprLwk6.js +1 -0
- package/dist/web/assets/{pdf-preview-BSrz_N0g.js → pdf-preview-D4iOenvs.js} +1 -1
- package/dist/web/assets/{port-forwarding-tab-BpeFzbAM.js → port-forwarding-tab-Hkq3Oj4T.js} +1 -1
- package/dist/web/assets/{postgres-viewer-GpXLzmnT.js → postgres-viewer-BG4CkX-_.js} +1 -1
- package/dist/web/assets/{settings-tab-Cjiu2egJ.js → settings-tab-Dwcs9hK5.js} +1 -1
- package/dist/web/assets/sql-query-editor-DRON0V_j.js +1 -0
- package/dist/web/assets/{sqlite-viewer-ONh1tmxh.js → sqlite-viewer-BabBjC5D.js} +1 -1
- package/dist/web/assets/{system-monitor-tab-BznIBj8p.js → system-monitor-tab-9fc9tob6.js} +1 -1
- package/dist/web/assets/{terminal-tab-D2OwQv1h.js → terminal-tab-c-SljqL9.js} +1 -1
- package/dist/web/assets/{video-preview-49zZk7VQ.js → video-preview-C8lRIJQT.js} +1 -1
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/src/providers/claude-agent-sdk.ts +6 -2
- package/src/server/routes/chat.ts +7 -6
- package/src/web/components/chat/chat-tab.tsx +10 -0
- package/src/web/components/database/sql-completion-provider.ts +28 -1
- package/src/web/components/database/sql-query-editor.tsx +1 -30
- package/dist/web/assets/glide-data-grid-BfXnM2CC.js +0 -136
- package/dist/web/assets/keybindings-store-C1yHwKEc.js +0 -1
- package/dist/web/assets/notification-store-CBTVrgEf.js +0 -1
- package/dist/web/assets/sql-query-editor-PFN7evxv.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-UXCWAcmi.js";import{t as r}from"./createLucideIcon-BjHrJDVb.js";import{t as i}from"./database-NmqHg29g.js";import{t as a}from"./chevron-right-BzAdxJRG.js";import{a as o,l as s,n as c,o as l,r as u,s as d,t as f}from"./input-CArJe9WS.js";import{t as p}from"./code-CuravVys.js";import{i as m,r as h}from"./trash-2-D5P4y8p_.js";import{t as ee}from"./file-exclamation-point-Baz81y5z.js";import{i as g,r as te,t as _}from"./glide-data-grid-BfXnM2CC.js";import{t as ne}from"./shield-check-77W0OMbn.js";import{t as re}from"./shield-off-C_MK1u09.js";import{t as v}from"./table-BzjWcs87.js";import{t as y}from"./text-wrap-DJz9Bgpa.js";import{t as b}from"./x-Dx3jsRgu.js";import{i as ie,t as x}from"./api-client-BK4NPNoY.js";import{n as ae}from"./settings-store-DQUFTPk2.js";import{K as S}from"./vendor-mermaid-DkqjpqJK.js";import{t as C}from"./utils-CSCvNZxE.js";import{t as oe}from"./panel-store-C9VAhbZz.js";import{n as w}from"./project-store-DlbHpIq0.js";import{t as se}from"./tab-store-CIcbSn0c.js";import{C as T,Ct as ce,D as le,Et as ue,O as E,Q as D,R as O,S as k,St as A,_t as j,b as M,bt as N,mt as P,o as de,pt as F,s as fe,st as pe,v as me,vt as he,w as ge,x as _e,xt as I,y as ve,yt as ye}from"./index-Dd6YEaE6.js";import"./data-grid-types-DzL5W2em.js";import{n as be,t as xe}from"./use-monaco-theme-BLIgarH5.js";var Se=r(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),L=e(n(),1),R=t(),Ce={ts:I,tsx:I,js:I,jsx:I,py:I,rs:I,go:I,html:I,css:I,scss:I,json:A,md:N,txt:N,yaml:ye,yml:ye};function z(e,t){return t?j:Ce[e.split(`.`).pop()?.toLowerCase()??``]??he}function we(e,t){let n=[],r=e,i=``;for(let e=0;e<t.length;e++){let a=t[e],o=t.slice(0,e+1).join(`/`),s=r.find(e=>e.name===a);if(n.push({name:a,fullPath:o,node:s??null,siblings:r,parentPath:i}),s?.children)i=s.path,r=s.children;else{for(let r=e+1;r<t.length;r++)n.push({name:t[r],fullPath:t.slice(0,r+1).join(`/`),node:null,siblings:[],parentPath:t.slice(0,r).join(`/`)});break}}return n}function B(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function Te({filePath:e,projectName:t,tabId:n,className:r}){let i=O(e=>e.tree),{updateTab:o,openTab:s}=se(le(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=w(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,L.useRef)(null),{prefixParts:u,relativePath:d}=(0,L.useMemo)(()=>{let t=e.startsWith(`/`)?e.slice(1):e,n=c.startsWith(`/`)?c.slice(1):c;if(n&&t.startsWith(n+`/`)){let e=t.slice(n.length+1);return{prefixParts:n.split(`/`),relativePath:e}}return{prefixParts:[],relativePath:t}},[e,c]),f=(0,L.useMemo)(()=>we(i,d.split(`/`).filter(Boolean)),[i,d]);(0,L.useEffect)(()=>{l.current&&(l.current.scrollLeft=l.current.scrollWidth)},[f]);function p(e,r){let i=C(e);r.metaKey||r.ctrlKey?s({type:`editor`,title:i,metadata:{filePath:e,projectName:t},projectId:t,closable:!0}):o(n,{title:i,metadata:{filePath:e,projectName:t}})}return(0,R.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,R.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),f.map((e,n)=>(0,R.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,R.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,R.jsx)(Ee,{segment:e,isLast:n===f.length-1,projectName:t,onFileClick:p})]},e.fullPath))]})}function Ee({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=O(e=>e.loadChildren),a=O(e=>e.loadedPaths),o=(0,L.useMemo)(()=>B(e.siblings),[e.siblings]),s=a.has(e.parentPath);function c(t){if(t&&!s){let t=e.parentPath.split(`/`).filter(Boolean);(async()=>{for(let e=0;e<=t.length;e++)await i(n,t.slice(0,e).join(`/`))})()}}return(0,R.jsxs)(me,{onOpenChange:c,children:[(0,R.jsx)(ge,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,R.jsx)(ve,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,R.jsx)(M,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,R.jsx)(V,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function V({node:e,projectName:t,activePath:n,onFileClick:r}){let i=z(e.name,e.type===`directory`),a=e.path===n,o=O(e=>e.loadChildren),s=O(e=>e.loadedPaths);if(e.type===`directory`){let c=e.children??[],l=s.has(e.path);function u(n){n&&!l&&o(t,e.path)}return(0,R.jsxs)(_e,{onOpenChange:u,children:[(0,R.jsxs)(T,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,R.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,R.jsx)(k,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,R.jsx)(M,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):B(c).map(e=>(0,R.jsx)(V,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,R.jsxs)(M,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,R.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]})}function H({active:e,onClick:t,icon:n,label:r}){return(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,R.jsx)(n,{className:`size-3`}),(0,R.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function De({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,filePath:s,projectName:c,className:l}){return(0,R.jsxs)(`div`,{className:l,children:[(e===`md`||e===`mdx`)&&n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{active:t===`edit`,onClick:()=>n(`edit`),icon:p,label:`Edit`}),(0,R.jsx)(H,{active:t===`preview`,onClick:()=>n(`preview`),icon:h,label:`Preview`})]}),e===`csv`&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{active:r===`table`,onClick:()=>i(`table`),icon:v,label:`Table`}),(0,R.jsx)(H,{active:r===`raw`,onClick:()=>i(`raw`),icon:p,label:`Raw`})]}),(0,R.jsx)(H,{active:a,onClick:o,icon:y,label:`Wrap`}),s&&c&&(0,R.jsx)(H,{active:!1,onClick:()=>E(c,s),icon:m,label:`Download`})]})}function Oe({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[a,p]=(0,L.useState)(t),[m,h]=(0,L.useState)(!1),[ee,g]=(0,L.useState)(``),te=w(e=>e.activeProject),_=(0,L.useCallback)(()=>{let e=a.trim();if(!e){g(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){g(`Filename cannot contain / or \\`);return}g(``),h(!0)},[a]),ne=(0,L.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${a.trim()}`:`${e}${t}${a.trim()}`,n)},[a,n,r]);return m?(0,R.jsx)(fe,{open:!0,mode:`folder`,root:te?.path,title:`Save "${a.trim()}" to...`,onSelect:ne,onCancel:()=>h(!1)}):(0,R.jsx)(c,{open:e,onOpenChange:e=>{e||i()},children:(0,R.jsxs)(u,{className:`sm:max-w-md`,children:[(0,R.jsx)(l,{children:(0,R.jsx)(d,{children:`Save As`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,R.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,R.jsx)(f,{value:a,onChange:e=>{p(e.target.value),g(``)},onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),ee&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:ee})]}),(0,R.jsxs)(o,{children:[(0,R.jsx)(s,{variant:`outline`,onClick:i,children:`Cancel`}),(0,R.jsx)(s,{onClick:_,children:`Choose Folder...`})]})]})})}var U=typeof window<`u`&&window.isSecureContext,W=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],G=`px-2 py-1.5 rounded text-xs min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,ke=`px-3 py-1.5 rounded text-xs font-mono min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,K=`w-px h-5 bg-border mx-0.5 shrink-0`;function Ae({editorRef:e,readOnly:t}){let n=(0,L.useCallback)(()=>e.current,[e]),r=(0,L.useCallback)(e=>{let t=n();if(!t)return;t.focus();let r=t.getSelection();r&&t.executeEdits(`mobile-toolbar`,[{range:r,text:e}])},[n]),[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null),s=(0,L.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,L.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,L.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,L.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,L.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,L.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!U&&i&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,R.jsx)(`textarea`,{ref:o,onPaste:l,placeholder:`Long-press here → Paste`,className:`flex-1 h-8 rounded border border-border bg-background text-foreground text-xs px-2 py-1.5 resize-none focus:outline-none focus:ring-1 focus:ring-primary`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,R.jsx)(b,{size:14})})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:U?s:c,className:G,title:`Paste`,children:(0,R.jsx)(ue,{size:14})}),(0,R.jsx)(`button`,{type:`button`,onClick:u,className:G,title:`Undo`,children:(0,R.jsx)(D,{size:14})}),(0,R.jsx)(`button`,{type:`button`,onClick:d,className:G,title:`Redo`,children:(0,R.jsx)(Se,{size:14})}),(0,R.jsx)(`div`,{className:K}),(0,R.jsx)(`button`,{type:`button`,onClick:f,className:ke,children:`Tab`}),(0,R.jsx)(`div`,{className:K}),W.map(e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:ke,children:e},e))]})]})}var q=(0,L.lazy)(()=>S(()=>import(`./markdown-renderer-Cat4uT8B.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),je=(0,L.lazy)(()=>S(()=>import(`./csv-preview-asMfgR0r.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([24,1,4,5,25,26,8,27,28]))),Me=(0,L.lazy)(()=>S(()=>import(`./image-preview-CyL9Lj_O.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([29,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30,31]))),Ne=(0,L.lazy)(()=>S(()=>import(`./pdf-preview-BSrz_N0g.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([32,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30]))),Pe=(0,L.lazy)(()=>S(()=>import(`./video-preview-49zZk7VQ.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([33,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30,31]))),Fe=(0,L.lazy)(()=>S(()=>import(`./audio-preview-BQUzmaMW.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([34,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30,31]))),Ie=(0,L.lazy)(()=>S(()=>import(`./docx-preview-AgoO5zwo.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30]))),Le=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Re=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),ze=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),Be=new Set([`db`,`sqlite`,`sqlite3`]);function Ve(e){return e.split(`.`).pop()?.toLowerCase()??``}function He(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,sql:`sql`}[Ve(e)]??`plaintext`}var Ue=(0,L.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,a=e?.inlineContent,o=e?.inlineLanguage,[s,c]=(0,L.useState)(a??null),[l,u]=(0,L.useState)(`utf-8`),[d,f]=(0,L.useState)(!0),[p,m]=(0,L.useState)(null),[h,_]=(0,L.useState)(!1),v=(0,L.useRef)(null),y=(0,L.useRef)(``),b=(0,L.useRef)(null),{tabs:S,updateTab:w}=se(le(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:T,toggleWordWrap:ce}=ae(le(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),ue=xe(),E=e?.isUntitled===!0,D=e?.unsavedContent,[O,k]=(0,L.useState)(!1),A=S.find(e=>e.id===t),j=n?Ve(n):``,M=Le.has(j),N=j===`pdf`,P=j===`docx`,fe=Re.has(j),me=ze.has(j),he=Be.has(j),ge=j===`md`||j===`mdx`,_e=j===`csv`,I=j===`sql`,[ve,ye]=(0,L.useState)(`preview`),[Se,Ce]=(0,L.useState)(`table`),{connections:z,cachedTables:we,refreshTables:B,updateConnection:Ee}=de(),[V,H]=(0,L.useState)(()=>{if(!I||!n)return null;let e=localStorage.getItem(`ppm:sql-conn:${n}`);return e?Number(e):null}),U=(0,L.useRef)(null),W=(0,L.useRef)(null),G=(0,L.useMemo)(()=>z.find(e=>e.id===V)??null,[z,V]),ke=a!=null&&(o===`json`||o===`xml`),[K,q]=(0,L.useState)(!1),Ue=(0,L.useCallback)(()=>{if(a)if(K)c(a),q(!1);else{let e=a.trimStart();if(o===`json`)try{c(JSON.stringify(JSON.parse(e),null,2)),q(!0)}catch{}else if(o===`xml`){let t=0;c(e.replace(/(>)(<)(\/*)/g,`$1
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-pJFF8cN8.js","assets/rolldown-runtime-FhOqtrmT.js","assets/index-BlRGbnAE.js","assets/vendor-mermaid-DkqjpqJK.js","assets/vendor-ui-UXCWAcmi.js","assets/vendor-markdown-0Mxgxy0L.js","assets/input-CArJe9WS.js","assets/utils-CSCvNZxE.js","assets/createLucideIcon-BjHrJDVb.js","assets/x-Dx3jsRgu.js","assets/settings-store-DQUFTPk2.js","assets/react-DHBl6KRc.js","assets/api-client-BK4NPNoY.js","assets/eye-off-BacF7RVS.js","assets/chevron-down-CiFNPrfI.js","assets/database-NmqHg29g.js","assets/chevron-right-BzAdxJRG.js","assets/search-BEy08Exr.js","assets/trash-2-D5P4y8p_.js","assets/api-settings-BJTjIG4U.js","assets/panel-store-C9VAhbZz.js","assets/project-store-DlbHpIq0.js","assets/tab-store-CIcbSn0c.js","assets/index-fyMt5gpO.css","assets/csv-preview-asMfgR0r.js","assets/lib-LPmTkMu4.js","assets/arrow-down-D825m4vm.js","assets/arrow-up-Rcw6_KKu.js","assets/csv-parser-D1b_lg2T.js","assets/image-preview-DprBBsHy.js","assets/file-exclamation-point-Baz81y5z.js","assets/use-blob-url-DrPfBQBM.js","assets/pdf-preview-D4iOenvs.js","assets/video-preview-C8lRIJQT.js","assets/audio-preview-CAkLsTgJ.js","assets/docx-preview-CSIdvMph.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-UXCWAcmi.js";import{t as r}from"./createLucideIcon-BjHrJDVb.js";import{t as i}from"./database-NmqHg29g.js";import{t as a}from"./chevron-right-BzAdxJRG.js";import{a as o,l as s,n as c,o as l,r as u,s as d,t as f}from"./input-CArJe9WS.js";import{t as p}from"./code-CuravVys.js";import{i as m,r as h}from"./trash-2-D5P4y8p_.js";import{t as ee}from"./file-exclamation-point-Baz81y5z.js";import{i as g,r as te,t as _}from"./glide-data-grid-CZVrZJpS.js";import{t as ne}from"./shield-check-77W0OMbn.js";import{t as re}from"./shield-off-C_MK1u09.js";import{t as v}from"./table-BzjWcs87.js";import{t as y}from"./text-wrap-DJz9Bgpa.js";import{t as b}from"./x-Dx3jsRgu.js";import{i as ie,t as x}from"./api-client-BK4NPNoY.js";import{n as ae}from"./settings-store-DQUFTPk2.js";import{K as S}from"./vendor-mermaid-DkqjpqJK.js";import{t as C}from"./utils-CSCvNZxE.js";import{t as oe}from"./panel-store-C9VAhbZz.js";import{n as w}from"./project-store-DlbHpIq0.js";import{t as se}from"./tab-store-CIcbSn0c.js";import{C as T,Ct as ce,D as le,Et as ue,O as E,Q as D,R as O,S as k,St as A,_t as j,b as M,bt as N,mt as P,o as de,pt as F,s as fe,st as pe,v as me,vt as he,w as ge,x as _e,xt as I,y as ve,yt as ye}from"./index-BlRGbnAE.js";import"./data-grid-types-DzL5W2em.js";import{n as be,t as xe}from"./use-monaco-theme-BLIgarH5.js";var Se=r(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),L=e(n(),1),R=t(),Ce={ts:I,tsx:I,js:I,jsx:I,py:I,rs:I,go:I,html:I,css:I,scss:I,json:A,md:N,txt:N,yaml:ye,yml:ye};function z(e,t){return t?j:Ce[e.split(`.`).pop()?.toLowerCase()??``]??he}function we(e,t){let n=[],r=e,i=``;for(let e=0;e<t.length;e++){let a=t[e],o=t.slice(0,e+1).join(`/`),s=r.find(e=>e.name===a);if(n.push({name:a,fullPath:o,node:s??null,siblings:r,parentPath:i}),s?.children)i=s.path,r=s.children;else{for(let r=e+1;r<t.length;r++)n.push({name:t[r],fullPath:t.slice(0,r+1).join(`/`),node:null,siblings:[],parentPath:t.slice(0,r).join(`/`)});break}}return n}function B(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function Te({filePath:e,projectName:t,tabId:n,className:r}){let i=O(e=>e.tree),{updateTab:o,openTab:s}=se(le(e=>({updateTab:e.updateTab,openTab:e.openTab}))),c=w(e=>e.projects.find(e=>e.name===t)?.path??``),l=(0,L.useRef)(null),{prefixParts:u,relativePath:d}=(0,L.useMemo)(()=>{let t=e.startsWith(`/`)?e.slice(1):e,n=c.startsWith(`/`)?c.slice(1):c;if(n&&t.startsWith(n+`/`)){let e=t.slice(n.length+1);return{prefixParts:n.split(`/`),relativePath:e}}return{prefixParts:[],relativePath:t}},[e,c]),f=(0,L.useMemo)(()=>we(i,d.split(`/`).filter(Boolean)),[i,d]);(0,L.useEffect)(()=>{l.current&&(l.current.scrollLeft=l.current.scrollWidth)},[f]);function p(e,r){let i=C(e);r.metaKey||r.ctrlKey?s({type:`editor`,title:i,metadata:{filePath:e,projectName:t},projectId:t,closable:!0}):o(n,{title:i,metadata:{filePath:e,projectName:t}})}return(0,R.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,R.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),f.map((e,n)=>(0,R.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,R.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,R.jsx)(Ee,{segment:e,isLast:n===f.length-1,projectName:t,onFileClick:p})]},e.fullPath))]})}function Ee({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=O(e=>e.loadChildren),a=O(e=>e.loadedPaths),o=(0,L.useMemo)(()=>B(e.siblings),[e.siblings]),s=a.has(e.parentPath);function c(t){if(t&&!s){let t=e.parentPath.split(`/`).filter(Boolean);(async()=>{for(let e=0;e<=t.length;e++)await i(n,t.slice(0,e).join(`/`))})()}}return(0,R.jsxs)(me,{onOpenChange:c,children:[(0,R.jsx)(ge,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`text-xs px-1 py-0.5 rounded hover:bg-muted transition-colors truncate max-w-[120px] ${t?`text-foreground font-medium`:`text-muted-foreground`}`,children:e.name})}),(0,R.jsx)(ve,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,R.jsx)(M,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,R.jsx)(V,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function V({node:e,projectName:t,activePath:n,onFileClick:r}){let i=z(e.name,e.type===`directory`),a=e.path===n,o=O(e=>e.loadChildren),s=O(e=>e.loadedPaths);if(e.type===`directory`){let c=e.children??[],l=s.has(e.path);function u(n){n&&!l&&o(t,e.path)}return(0,R.jsxs)(_e,{onOpenChange:u,children:[(0,R.jsxs)(T,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,R.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,R.jsx)(k,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,R.jsx)(M,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):B(c).map(e=>(0,R.jsx)(V,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,R.jsxs)(M,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,R.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name})]})}function H({active:e,onClick:t,icon:n,label:r}){return(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${e?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,R.jsx)(n,{className:`size-3`}),(0,R.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function De({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,filePath:s,projectName:c,className:l}){return(0,R.jsxs)(`div`,{className:l,children:[(e===`md`||e===`mdx`)&&n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{active:t===`edit`,onClick:()=>n(`edit`),icon:p,label:`Edit`}),(0,R.jsx)(H,{active:t===`preview`,onClick:()=>n(`preview`),icon:h,label:`Preview`})]}),e===`csv`&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(H,{active:r===`table`,onClick:()=>i(`table`),icon:v,label:`Table`}),(0,R.jsx)(H,{active:r===`raw`,onClick:()=>i(`raw`),icon:p,label:`Raw`})]}),(0,R.jsx)(H,{active:a,onClick:o,icon:y,label:`Wrap`}),s&&c&&(0,R.jsx)(H,{active:!1,onClick:()=>E(c,s),icon:m,label:`Download`})]})}function Oe({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[a,p]=(0,L.useState)(t),[m,h]=(0,L.useState)(!1),[ee,g]=(0,L.useState)(``),te=w(e=>e.activeProject),_=(0,L.useCallback)(()=>{let e=a.trim();if(!e){g(`Filename cannot be empty`);return}if(/[/\\]/.test(e)){g(`Filename cannot contain / or \\`);return}g(``),h(!0)},[a]),ne=(0,L.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${a.trim()}`:`${e}${t}${a.trim()}`,n)},[a,n,r]);return m?(0,R.jsx)(fe,{open:!0,mode:`folder`,root:te?.path,title:`Save "${a.trim()}" to...`,onSelect:ne,onCancel:()=>h(!1)}):(0,R.jsx)(c,{open:e,onOpenChange:e=>{e||i()},children:(0,R.jsxs)(u,{className:`sm:max-w-md`,children:[(0,R.jsx)(l,{children:(0,R.jsx)(d,{children:`Save As`})}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,R.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,R.jsx)(f,{value:a,onChange:e=>{p(e.target.value),g(``)},onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`e.g. my-file.ts`,autoFocus:!0}),ee&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:ee})]}),(0,R.jsxs)(o,{children:[(0,R.jsx)(s,{variant:`outline`,onClick:i,children:`Cancel`}),(0,R.jsx)(s,{onClick:_,children:`Choose Folder...`})]})]})})}var U=typeof window<`u`&&window.isSecureContext,W=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],G=`px-2 py-1.5 rounded text-xs min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,ke=`px-3 py-1.5 rounded text-xs font-mono min-w-[36px] min-h-[32px] bg-surface-elevated text-text-primary active:bg-primary active:text-primary-foreground transition-colors select-none`,K=`w-px h-5 bg-border mx-0.5 shrink-0`;function Ae({editorRef:e,readOnly:t}){let n=(0,L.useCallback)(()=>e.current,[e]),r=(0,L.useCallback)(e=>{let t=n();if(!t)return;t.focus();let r=t.getSelection();r&&t.executeEdits(`mobile-toolbar`,[{range:r,text:e}])},[n]),[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null),s=(0,L.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,L.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,L.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,L.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,L.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,L.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!U&&i&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,R.jsx)(`textarea`,{ref:o,onPaste:l,placeholder:`Long-press here → Paste`,className:`flex-1 h-8 rounded border border-border bg-background text-foreground text-xs px-2 py-1.5 resize-none focus:outline-none focus:ring-1 focus:ring-primary`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,R.jsx)(b,{size:14})})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:U?s:c,className:G,title:`Paste`,children:(0,R.jsx)(ue,{size:14})}),(0,R.jsx)(`button`,{type:`button`,onClick:u,className:G,title:`Undo`,children:(0,R.jsx)(D,{size:14})}),(0,R.jsx)(`button`,{type:`button`,onClick:d,className:G,title:`Redo`,children:(0,R.jsx)(Se,{size:14})}),(0,R.jsx)(`div`,{className:K}),(0,R.jsx)(`button`,{type:`button`,onClick:f,className:ke,children:`Tab`}),(0,R.jsx)(`div`,{className:K}),W.map(e=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:ke,children:e},e))]})]})}var q=(0,L.lazy)(()=>S(()=>import(`./markdown-renderer-pJFF8cN8.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),je=(0,L.lazy)(()=>S(()=>import(`./csv-preview-asMfgR0r.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([24,1,4,5,25,26,8,27,28]))),Me=(0,L.lazy)(()=>S(()=>import(`./image-preview-DprBBsHy.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([29,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30,31]))),Ne=(0,L.lazy)(()=>S(()=>import(`./pdf-preview-D4iOenvs.js`).then(e=>({default:e.PdfPreview})),__vite__mapDeps([32,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30]))),Pe=(0,L.lazy)(()=>S(()=>import(`./video-preview-C8lRIJQT.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([33,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30,31]))),Fe=(0,L.lazy)(()=>S(()=>import(`./audio-preview-CAkLsTgJ.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([34,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30,31]))),Ie=(0,L.lazy)(()=>S(()=>import(`./docx-preview-CSIdvMph.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30]))),Le=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Re=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),ze=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),Be=new Set([`db`,`sqlite`,`sqlite3`]);function Ve(e){return e.split(`.`).pop()?.toLowerCase()??``}function He(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,sql:`sql`}[Ve(e)]??`plaintext`}var Ue=(0,L.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,a=e?.inlineContent,o=e?.inlineLanguage,[s,c]=(0,L.useState)(a??null),[l,u]=(0,L.useState)(`utf-8`),[d,f]=(0,L.useState)(!0),[p,m]=(0,L.useState)(null),[h,_]=(0,L.useState)(!1),v=(0,L.useRef)(null),y=(0,L.useRef)(``),b=(0,L.useRef)(null),{tabs:S,updateTab:w}=se(le(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:T,toggleWordWrap:ce}=ae(le(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),ue=xe(),E=e?.isUntitled===!0,D=e?.unsavedContent,[O,k]=(0,L.useState)(!1),A=S.find(e=>e.id===t),j=n?Ve(n):``,M=Le.has(j),N=j===`pdf`,P=j===`docx`,fe=Re.has(j),me=ze.has(j),he=Be.has(j),ge=j===`md`||j===`mdx`,_e=j===`csv`,I=j===`sql`,[ve,ye]=(0,L.useState)(`preview`),[Se,Ce]=(0,L.useState)(`table`),{connections:z,cachedTables:we,refreshTables:B,updateConnection:Ee}=de(),[V,H]=(0,L.useState)(()=>{if(!I||!n)return null;let e=localStorage.getItem(`ppm:sql-conn:${n}`);return e?Number(e):null}),U=(0,L.useRef)(null),W=(0,L.useRef)(null),G=(0,L.useMemo)(()=>z.find(e=>e.id===V)??null,[z,V]),ke=a!=null&&(o===`json`||o===`xml`),[K,q]=(0,L.useState)(!1),Ue=(0,L.useCallback)(()=>{if(a)if(K)c(a),q(!1);else{let e=a.trimStart();if(o===`json`)try{c(JSON.stringify(JSON.parse(e),null,2)),q(!0)}catch{}else if(o===`xml`){let t=0;c(e.replace(/(>)(<)(\/*)/g,`$1
|
|
3
3
|
$2$3`).split(`
|
|
4
4
|
`).map(e=>{let n=e.trim();n.startsWith(`</`)&&(t=Math.max(0,t-1));let r=` `.repeat(t)+n;return n.startsWith(`<`)&&!n.startsWith(`</`)&&!n.endsWith(`/>`)&&!n.includes(`</`)&&t++,r}).join(`
|
|
5
5
|
`)),q(!0)}}},[a,o,K]),J=(0,L.useCallback)(e=>{H(e),n&&localStorage.setItem(`ppm:sql-conn:${n}`,String(e)),B(e).catch(()=>{})},[n,B]),X=(0,L.useMemo)(()=>{if(!I||!V)return;let e=(we.get(V)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>x.get(`/api/db/connections/${V}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[I,V,we]);(0,L.useEffect)(()=>{if(!(!U.current||!X))return W.current?.dispose(),te(),W.current=U.current.languages.registerCompletionItemProvider(`sql`,g(U.current,X)),()=>{W.current?.dispose()}},[X]);let Ke=se(e=>e.openTab),[qe,Je]=(0,L.useState)(null),[Ye,Xe]=(0,L.useState)(null),[Ze,Qe]=(0,L.useState)(!1),[$e,et]=(0,L.useState)(``),Z=(0,L.useCallback)(async e=>{if(G){Qe(!0),Xe(null),et(e);try{Je(await x.post(`/api/db/connections/${G.id}/query`,{sql:e}))}catch(e){Xe(e.message),Je(null)}finally{Qe(!1)}}},[G]),tt=(0,L.useCallback)(()=>{!G||!$e||Ke({type:`database`,title:`${G.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:G.id,connectionName:G.name,dbType:G.type,initialSql:$e}})},[G,Ke,$e]),nt=(0,L.useCallback)(()=>{if(!b.current||!G)return;let e=b.current,t=e.getSelection();Z(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[G,Z]),rt=typeof window<`u`&&`ontouchstart`in window,it=(0,L.useRef)(null),[at,ot]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(!rt)return;let e=window.visualViewport;if(!e)return;let t=()=>{let t=it.current;if(!t)return;let n=t.getBoundingClientRect().top;ot(e.height-Math.max(0,n))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[rt]);let Q=(0,L.useRef)([]),st=(0,L.useRef)(Z);st.current=Z,(0,L.useEffect)(()=>()=>{Q.current.forEach(e=>e.dispose()),Q.current=[]},[]),(0,L.useEffect)(()=>{he&&t&&w(t,{type:`sqlite`})},[he,t,w]);let $=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,L.useEffect)(()=>{if(a!=null){f(!1);return}if(E){c(D??``),y.current=D??``,f(!1),D&&_(!0);return}if(!n||!$&&!r)return;if(M||N||P||fe||me){f(!1);return}f(!0),m(null);let e=$?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ie(r)}/files/read?path=${encodeURIComponent(n)}`;return x.get(e).then(e=>{c(e.content),e.encoding&&u(e.encoding),y.current=e.content,f(!1)}).catch(e=>{m(e instanceof Error?e.message:`Failed to load file`),f(!1)}),()=>{v.current&&clearTimeout(v.current)}},[n,r,M,N,P,$,E]);let ct=(0,L.useRef)(h);ct.current=h,(0,L.useEffect)(()=>{if(!n||!r||a!=null||E)return;let e=e=>{let t=e.detail;if(t.projectName!==r||t.path!==n||ct.current)return;let i=$?`/api/fs/read?path=${encodeURIComponent(n)}`:`${ie(r)}/files/read?path=${encodeURIComponent(n)}`;x.get(i).then(e=>{e.content!==y.current&&(c(e.content),y.current=e.content,e.encoding&&u(e.encoding))}).catch(()=>{})};return window.addEventListener(`file:changed`,e),()=>window.removeEventListener(`file:changed`,e)},[n,r,$,a,E]),(0,L.useEffect)(()=>{if(!A||a!=null)return;let t=E?`Untitled-${e?.untitledNumber??1}`:n?C(n):`Untitled`,r=h?`${t} \u25CF`:t;A.title!==r&&w(A.id,{title:r})},[h]);let lt=(0,L.useCallback)(async e=>{if(n&&!(!$&&!r))try{$?await x.put(`/api/fs/write`,{path:n,content:e}):await x.put(`${ie(r)}/files/write`,{path:n,content:e}),_(!1)}catch{}},[n,r,$]);function ut(n){let r=n??``;c(r),y.current=r,_(!0),v.current&&clearTimeout(v.current),E?v.current=setTimeout(()=>{t&&w(t,{metadata:{...e,unsavedContent:y.current}})},2e3):v.current=setTimeout(()=>lt(y.current),1e3)}let dt=(0,L.useCallback)(async(e,n)=>{try{if(v.current&&clearTimeout(v.current),await x.put(`/api/fs/write`,{path:e,content:n}),t){let{closeTab:n,openTab:r}=oe.getState();n(t),r({type:`editor`,title:C(e),projectId:null,metadata:{filePath:e},closable:!0})}_(!1),k(!1)}catch{}},[t]),ft=e?.lineNumber,pt=(0,L.useCallback)((e,t)=>{if(b.current=e,U.current=t,ft&&ft>0&&setTimeout(()=>{e.revealLineInCenter(ft),e.setPosition({lineNumber:ft,column:1}),e.focus()},100),E&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>k(!0)),e.addCommand(t.KeyMod.Alt|t.KeyCode.KeyZ,()=>ae.getState().toggleWordWrap()),t.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),t.languages.typescript.javascriptDefaults.setDiagnosticsOptions({noSemanticValidation:!0,noSyntaxValidation:!0,noSuggestionDiagnostics:!0}),X&&(W.current?.dispose(),W.current=t.languages.registerCompletionItemProvider(`sql`,g(t,X))),I){Q.current.forEach(e=>e.dispose()),Q.current=[];let n=e.getModel(),r=e.addCommand(0,(e,t)=>{t&&st.current(t)});if(r&&n){let e=t.languages.registerCodeLensProvider(`sql`,{provideCodeLenses:e=>{if(e!==n)return{lenses:[],dispose:()=>{}};let t=[],i=e.getValue().split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{i as r,t as i}from"./api-client-BK4NPNoY.js";import{n as a}from"./settings-store-DQUFTPk2.js";import"./vendor-mermaid-DkqjpqJK.js";import{D as o,pt as s}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{i as r,t as i}from"./api-client-BK4NPNoY.js";import{n as a}from"./settings-store-DQUFTPk2.js";import"./vendor-mermaid-DkqjpqJK.js";import{D as o,pt as s}from"./index-BlRGbnAE.js";import{n as c,t as l}from"./use-monaco-theme-BLIgarH5.js";var u=e(n(),1),d=t();function f(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`,go:`go`,rs:`rust`,java:`java`,rb:`ruby`,php:`php`,swift:`swift`,sql:`sql`,xml:`xml`,toml:`toml`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function p(e){let t=e.split(`
|
|
2
2
|
`),n=[],r=0,i=0;for(;r<t.length;){let e=t[r];if(e.startsWith(`<<<<<<<`)){let a=r,o=e.substring(7).trim(),s=[];for(r++;r<t.length&&!t[r].startsWith(`=======`);)s.push(t[r]),r++;if(r>=t.length)break;let c=r,l=[];for(r++;r<t.length&&!t[r].startsWith(`>>>>>>>`);)l.push(t[r]),r++;if(r>=t.length)break;let u=t[r].substring(7).trim();n.push({id:i++,startLine:a+1,separatorLine:c+1,endLine:r+1,currentContent:s.join(`
|
|
3
3
|
`),incomingContent:l.join(`
|
|
4
4
|
`),currentLabel:o,incomingLabel:u})}r++}return n}function m({metadata:e}){let t=e?.filePath,n=e?.projectName,[m,g]=(0,u.useState)(null),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)(null),[x,S]=(0,u.useState)(0),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=(0,u.useRef)([]),E=(0,u.useRef)(null),{wordWrap:D}=a(o(e=>({wordWrap:e.wordWrap}))),O=l(),k=(0,u.useRef)(null),[A,j]=(0,u.useState)();(0,u.useEffect)(()=>{let e=k.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&j(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]),(0,u.useEffect)(()=>{!t||!n||(v(!0),i.get(`${r(n)}/files/read?path=${encodeURIComponent(t)}`).then(e=>{g(e.content),v(!1)}).catch(e=>{b(e.message||`Failed to load file`),v(!1)}))},[t,n]);let M=(0,u.useCallback)(()=>{let e=C.current,t=w.current;if(!e||!t)return;let n=p(e.getModel()?.getValue()||``);S(n.length);for(let t of T.current)e.removeContentWidget(t);if(T.current=[],E.current&&E.current.clear(),n.length===0)return;let r=[];for(let e of n)r.push({range:new t.Range(e.startLine,1,e.startLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-current`}}),r.push({range:new t.Range(e.separatorLine,1,e.separatorLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`}}),r.push({range:new t.Range(e.endLine,1,e.endLine,1),options:{isWholeLine:!0,className:`conflict-marker-line`,glyphMarginClassName:`conflict-glyph-incoming`}}),e.separatorLine-e.startLine>1&&r.push({range:new t.Range(e.startLine+1,1,e.separatorLine-1,1),options:{isWholeLine:!0,className:`conflict-current-content`}}),e.endLine-e.separatorLine>1&&r.push({range:new t.Range(e.separatorLine+1,1,e.endLine-1,1),options:{isWholeLine:!0,className:`conflict-incoming-content`}});E.current=e.createDecorationsCollection(r);for(let r of n){let n=`conflict-widget-${r.id}`,i=document.createElement(`div`);i.className=`conflict-actions`,i.innerHTML=`<span class="conflict-label">Current Change (${h(r.currentLabel||`HEAD`)})</span><button class="conflict-btn conflict-btn-current" data-action="current">Accept Current</button><button class="conflict-btn conflict-btn-incoming" data-action="incoming">Accept Incoming</button><button class="conflict-btn conflict-btn-both" data-action="both">Accept Both</button>`,i.addEventListener(`click`,e=>{let t=e.target.closest(`[data-action]`);if(!t)return;let n=t.getAttribute(`data-action`);N(r.id,n)});let a={getId:()=>n,getDomNode:()=>i,getPosition:()=>({position:{lineNumber:r.startLine,column:1},preference:[t.editor.ContentWidgetPositionPreference.ABOVE]})};e.addContentWidget(a),T.current.push(a)}},[]),N=(0,u.useCallback)((e,t)=>{let n=C.current,r=w.current;if(!n||!r)return;let i=n.getModel();if(!i)return;let a=p(i.getValue()).find(t=>t.id===e);if(!a)return;let o;switch(t){case`current`:o=a.currentContent;break;case`incoming`:o=a.incomingContent;break;case`both`:o=a.currentContent+`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-UXCWAcmi.js";import{t as r}from"./database-NmqHg29g.js";import{n as i,t as a}from"./glide-data-grid-BfXnM2CC.js";import{t as o}from"./shield-check-77W0OMbn.js";import{t as s}from"./shield-off-C_MK1u09.js";import{t as c}from"./api-client-BK4NPNoY.js";import"./settings-store-DQUFTPk2.js";import"./vendor-mermaid-DkqjpqJK.js";import"./panel-store-C9VAhbZz.js";import{t as l}from"./tab-store-CIcbSn0c.js";import{mt as u,o as d,ot as f,pt as p}from"./index-Dd6YEaE6.js";import"./data-grid-types-DzL5W2em.js";import"./use-monaco-theme-BLIgarH5.js";import{t as m}from"./sql-query-editor-PFN7evxv.js";var h=e(n(),1);function g(e,t,n,r){return`ppm-db-${e}-${n}.${t}-p${r}`}function _(e,t,n,r){try{let i=sessionStorage.getItem(g(e,t,n,r));return i?JSON.parse(i):null}catch{return null}}function v(e,t,n,r,i,a){try{sessionStorage.setItem(g(e,t,n,r),JSON.stringify({data:i,cols:a}))}catch{}}function y(e){let t=`/api/db/connections/${e}`,[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)(`public`),[o,s]=(0,h.useState)(null),[l,u]=(0,h.useState)([]),[d,f]=(0,h.useState)(!1),[p,m]=(0,h.useState)(null),[g,y]=(0,h.useState)(1),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(null),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(null),[O,k]=(0,h.useState)(`ASC`),A=(0,h.useCallback)(async(r,a,o,l,d)=>{let p=r??n,h=a??i;if(!p)return;f(!0);let _=l===void 0?E:l,y=d??O;try{let n=_?`&orderBy=${encodeURIComponent(_)}&orderDir=${y}`:``,[r,i]=await Promise.all([c.get(`${t}/data?table=${encodeURIComponent(p)}&schema=${h}&page=${o??g}&limit=100${n}`),c.get(`${t}/schema?table=${encodeURIComponent(p)}&schema=${h}`)]);s(r),u(i),v(e,p,h,o??g,r,i)}catch(e){m(e.message)}finally{f(!1)}},[t,e,n,i,g,E,O]),j=(0,h.useCallback)((t,n=`public`)=>{r(t),a(n),y(1),x(null);let i=_(e,t,n,1);i?(s(i.data),u(i.cols),f(!1),A(t,n,1)):A(t,n,1)},[e,A]),M=(0,h.useCallback)(e=>{y(e),A(void 0,void 0,e)},[A]),N=(0,h.useCallback)(async e=>{T(!0),C(null);try{let r=await c.post(`${t}/query`,{sql:e});x(r),r.changeType===`modify`&&A(n??void 0,i)}catch(e){C(e.message)}finally{T(!1)}},[t,n,i,A]),P=(0,h.useCallback)(async(e,r,a,o)=>{if(!n)return;let s=n,l=i;try{await c.put(`${t}/cell`,{table:s,schema:l,pkColumn:e,pkValue:r,column:a,value:o}),A(s,l)}catch(e){m(e.message)}},[t,n,i,A]),F=(0,h.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await c.del(`${t}/row`,{table:a,schema:o,pkColumn:e,pkValue:r}),A(a,o)}catch(e){m(e.message)}},[t,n,i,A]);return{selectedTable:n,selectedSchema:i,selectTable:j,tableData:o,schema:l,loading:d,error:p,page:g,setPage:M,orderBy:E,orderDir:O,toggleSort:(0,h.useCallback)(e=>{let t,n=`ASC`;E===e?O===`ASC`?(t=e,n=`DESC`):(t=null,n=`ASC`):(t=e,n=`ASC`),D(t),k(n),y(1),A(void 0,void 0,1,t,n)},[E,O,A]),clearSort:(0,h.useCallback)(()=>{D(null),k(`ASC`),y(1),A(void 0,void 0,1,null,`ASC`)},[A]),queryResult:b,queryError:S,queryLoading:w,executeQuery:N,updateCell:P,deleteRow:F,bulkDelete:(0,h.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await c.post(`${t}/rows/delete`,{table:a,schema:o,pkColumn:e,pkValues:r}),A(a,o)}catch(e){m(e.message)}},[t,n,i,A]),insertRow:(0,h.useCallback)(async e=>{if(!n)return;let r=n,a=i;try{await c.post(`${t}/row`,{table:r,schema:a,values:e}),A(r,a)}catch(e){throw m(e.message),e}},[t,n,i,A]),refreshData:A,queryAsTable:(0,h.useCallback)(async e=>{f(!0);try{let n=await c.post(`${t}/query`,{sql:e});n.changeType===`select`&&s({columns:n.columns,rows:n.rows,total:n.rows.length,page:1,limit:n.rows.length})}catch(e){m(e.message)}finally{f(!1)}},[t])}}var b=t();function x(e){let t={},n=/"(\w+)"\s+ILIKE\s+'%([^']*?)%'/gi,r;for(;(r=n.exec(e))!==null;)t[r[1]]=r[2].replace(/''/g,`'`);return t}function S({metadata:e,tabId:t}){let n=e?.connectionId,p=e?.connectionName,g=e?.tableName,_=e?.schemaName??`public`,v=e?.initialSql,S=e?.currentSql,C=l(e=>e.updateTab),T=(0,h.useRef)(e);T.current=e;let E=(0,h.useCallback)(e=>{t&&C(t,{metadata:{...T.current,currentSql:e}})},[t,C]),D=y(n),{connections:O,updateConnection:k}=d(),A=(0,h.useMemo)(()=>O.find(e=>e.id===n),[O,n]),[j,M]=(0,h.useState)([]),[N,P]=(0,h.useState)(180),F=(0,h.useRef)(null),[I,L]=(0,h.useState)({}),R=(0,h.useMemo)(()=>{if(v&&!D.selectedTable)return v;if(D.selectedTable){let e=`SELECT * FROM "${D.selectedTable}"`,t=Object.entries(I).filter(([,e])=>e.trim()).map(([e,t])=>`"${e}" ILIKE '%${t.replace(/'/g,`''`)}%'`);t.length>0&&(e+=` WHERE ${t.join(` AND `)}`),D.orderBy&&(e+=` ORDER BY "${D.orderBy}" ${D.orderDir}`);let n=(D.page-1)*100;return e+=` LIMIT 100`,n>0&&(e+=` OFFSET ${n}`),e}return`SELECT * FROM `},[v,D.selectedTable,D.orderBy,D.orderDir,D.page,I]),z=(0,h.useCallback)(e=>{L(e)},[]),B=(0,h.useRef)(void 0);(0,h.useEffect)(()=>{if(!(!D.selectedTable||Object.keys(I).length===0))return clearTimeout(B.current),B.current=setTimeout(()=>{D.queryAsTable(R)},500),()=>clearTimeout(B.current)},[I]);let V=(0,h.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=N,r=e=>{let r=e.clientY-t;P(Math.max(80,Math.min(n+r,(F.current?.clientHeight??600)-100)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[N]);(0,h.useEffect)(()=>{c.get(`/api/db/connections/${n}/tables?cached=1`).then(e=>M(e.map(e=>({name:e.name,schema:e.schema})))).catch(()=>{})},[n]);let H=(0,h.useMemo)(()=>{if(j.length!==0)return{tables:j,getColumns:async(e,t)=>await c.get(`/api/db/connections/${n}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[n,j]),U=(0,h.useRef)(!1);(0,h.useEffect)(()=>{U.current||(U.current=!0,v?D.executeQuery(v):g&&D.selectTable(g,_))},[g,_,v]);let[W,G]=(0,h.useState)(!!v),K=(0,h.useCallback)(e=>{let t=e.trim();if(D.selectedTable&&RegExp(`^SELECT\\s+\\*\\s+FROM\\s+"?${D.selectedTable.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}"?\\b`,`i`).test(t)){L(x(t)),D.queryAsTable(t);return}G(!0),D.executeQuery(e)},[D.executeQuery,D.queryAsTable,D.selectedTable]),q=(0,h.useCallback)(e=>{G(!1),D.toggleSort(e)},[D.toggleSort]),J=(0,h.useCallback)(()=>{G(!1),D.clearSort()},[D.clearSort]),Y=(0,h.useCallback)(e=>{G(!1),D.setPage(e)},[D.setPage]),X=D.queryResult,Z=W&&!!(X||D.queryError),Q=D.selectedTable&&!Z;return(0,b.jsx)(`div`,{ref:F,className:`flex h-full w-full overflow-hidden`,children:(0,b.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,b.jsx)(r,{className:`size-3.5 text-muted-foreground`}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:p??`Database`}),D.selectedTable&&(0,b.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,D.selectedTable]}),(0,b.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[D.tableData&&(0,b.jsx)(i,{columns:D.tableData.columns,rows:D.tableData.rows,filename:p?`${p}-${D.selectedTable??`data`}`:D.selectedTable??`data`,exportAllUrl:D.selectedTable?`/api/db/connections/${n}/export?table=${encodeURIComponent(D.selectedTable)}&schema=${D.selectedSchema}`:void 0}),A&&(0,b.jsx)(`button`,{type:`button`,onClick:()=>k(A.id,{readonly:A.readonly?0:1}),className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] transition-colors ${A.readonly?`text-muted-foreground hover:text-foreground`:`bg-destructive/15 text-destructive`}`,title:A.readonly?`Readonly — click to allow writes`:`WRITE mode — click to enable readonly`,children:A.readonly?(0,b.jsx)(o,{className:`size-3`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s,{className:`size-3`}),(0,b.jsx)(`span`,{className:`font-medium`,children:`WRITE`})]})}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>D.refreshData(),title:`Reload data`,className:`p-1 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,b.jsx)(f,{className:`size-3 ${D.loading?`animate-spin`:``}`})})]})]}),(0,b.jsx)(`div`,{className:`shrink-0 border-b border-border`,style:{height:N},children:(0,b.jsx)(m,{onExecute:K,loading:D.queryLoading,defaultValue:R,schemaInfo:H,onSqlChange:E,persistedSql:S})}),(0,b.jsx)(`div`,{onMouseDown:V,className:`shrink-0 h-1.5 cursor-row-resize bg-border/50 hover:bg-primary/30 flex items-center justify-center transition-colors`,children:(0,b.jsx)(u,{className:`size-3 text-muted-foreground/50`})}),(0,b.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[Q&&D.tableData&&(0,b.jsx)(a,{columns:D.tableData.columns,rows:D.tableData.rows,total:D.tableData.total,limit:D.tableData.limit,schema:D.schema,loading:D.loading,page:D.page,onPageChange:Y,onCellUpdate:D.updateCell,onRowDelete:D.deleteRow,orderBy:D.orderBy,orderDir:D.orderDir,onToggleSort:q,onClearSort:J,onBulkDelete:D.bulkDelete,onInsertRow:D.insertRow,connectionId:n,selectedTable:D.selectedTable,selectedSchema:D.selectedSchema,connectionName:p,columnFilters:I,onColumnFilter:z}),Z&&(0,b.jsx)(w,{result:X,error:D.queryError,loading:D.queryLoading,schema:D.schema,connectionName:p})]})]})})}var C=()=>{};function w({result:e,error:t,loading:n,schema:r,connectionName:i}){let o=(0,h.useMemo)(()=>e?.changeType===`select`&&e.rows.length>0?{columns:e.columns,rows:e.rows,total:e.rows.length,limit:e.rows.length}:null,[e]),s=(0,h.useMemo)(()=>r?.length?r:(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[r,e?.columns]);return(0,b.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden text-xs`,children:[t&&(0,b.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5 shrink-0`,children:t}),e?.changeType===`modify`&&(0,b.jsxs)(`div`,{className:`px-3 py-2 text-green-500 shrink-0`,children:[e.rowsAffected,` row(s) affected`,e.executionTimeMs!=null&&(0,b.jsxs)(`span`,{className:`text-muted-foreground ml-2`,children:[e.executionTimeMs,`ms`]})]}),o&&(0,b.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[(0,b.jsx)(a,{columns:o.columns,rows:o.rows,total:o.total,limit:o.limit,schema:s,loading:!!n,page:1,onPageChange:C,onCellUpdate:C,orderBy:null,orderDir:`ASC`,onToggleSort:C,connectionName:i}),e?.executionTimeMs!=null&&(0,b.jsxs)(`div`,{className:`px-3 py-0.5 border-t border-border text-[10px] text-muted-foreground shrink-0`,children:[e.rows.length,` rows · `,e.executionTimeMs,`ms`]})]}),e?.changeType===`select`&&e.rows.length===0&&(0,b.jsxs)(`div`,{className:`px-3 py-2 text-muted-foreground shrink-0`,children:[`No results`,e.executionTimeMs!=null&&(0,b.jsxs)(`span`,{className:`ml-2 text-muted-foreground/60`,children:[e.executionTimeMs,`ms`]})]}),!e&&!t&&(0,b.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:n?(0,b.jsx)(p,{className:`size-4 animate-spin`}):`Run a query to see results`})]})}export{S as DatabaseViewer};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-UXCWAcmi.js";import{t as r}from"./database-NmqHg29g.js";import{n as i,t as a}from"./glide-data-grid-CZVrZJpS.js";import{t as o}from"./shield-check-77W0OMbn.js";import{t as s}from"./shield-off-C_MK1u09.js";import{t as c}from"./api-client-BK4NPNoY.js";import"./settings-store-DQUFTPk2.js";import"./vendor-mermaid-DkqjpqJK.js";import"./panel-store-C9VAhbZz.js";import{t as l}from"./tab-store-CIcbSn0c.js";import{mt as u,o as d,ot as f,pt as p}from"./index-BlRGbnAE.js";import"./data-grid-types-DzL5W2em.js";import"./use-monaco-theme-BLIgarH5.js";import{t as m}from"./sql-query-editor-DRON0V_j.js";var h=e(n(),1);function g(e,t,n,r){return`ppm-db-${e}-${n}.${t}-p${r}`}function _(e,t,n,r){try{let i=sessionStorage.getItem(g(e,t,n,r));return i?JSON.parse(i):null}catch{return null}}function v(e,t,n,r,i,a){try{sessionStorage.setItem(g(e,t,n,r),JSON.stringify({data:i,cols:a}))}catch{}}function y(e){let t=`/api/db/connections/${e}`,[n,r]=(0,h.useState)(null),[i,a]=(0,h.useState)(`public`),[o,s]=(0,h.useState)(null),[l,u]=(0,h.useState)([]),[d,f]=(0,h.useState)(!1),[p,m]=(0,h.useState)(null),[g,y]=(0,h.useState)(1),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(null),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(null),[O,k]=(0,h.useState)(`ASC`),A=(0,h.useCallback)(async(r,a,o,l,d)=>{let p=r??n,h=a??i;if(!p)return;f(!0);let _=l===void 0?E:l,y=d??O;try{let n=_?`&orderBy=${encodeURIComponent(_)}&orderDir=${y}`:``,[r,i]=await Promise.all([c.get(`${t}/data?table=${encodeURIComponent(p)}&schema=${h}&page=${o??g}&limit=100${n}`),c.get(`${t}/schema?table=${encodeURIComponent(p)}&schema=${h}`)]);s(r),u(i),v(e,p,h,o??g,r,i)}catch(e){m(e.message)}finally{f(!1)}},[t,e,n,i,g,E,O]),j=(0,h.useCallback)((t,n=`public`)=>{r(t),a(n),y(1),x(null);let i=_(e,t,n,1);i?(s(i.data),u(i.cols),f(!1),A(t,n,1)):A(t,n,1)},[e,A]),M=(0,h.useCallback)(e=>{y(e),A(void 0,void 0,e)},[A]),N=(0,h.useCallback)(async e=>{T(!0),C(null);try{let r=await c.post(`${t}/query`,{sql:e});x(r),r.changeType===`modify`&&A(n??void 0,i)}catch(e){C(e.message)}finally{T(!1)}},[t,n,i,A]),P=(0,h.useCallback)(async(e,r,a,o)=>{if(!n)return;let s=n,l=i;try{await c.put(`${t}/cell`,{table:s,schema:l,pkColumn:e,pkValue:r,column:a,value:o}),A(s,l)}catch(e){m(e.message)}},[t,n,i,A]),F=(0,h.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await c.del(`${t}/row`,{table:a,schema:o,pkColumn:e,pkValue:r}),A(a,o)}catch(e){m(e.message)}},[t,n,i,A]);return{selectedTable:n,selectedSchema:i,selectTable:j,tableData:o,schema:l,loading:d,error:p,page:g,setPage:M,orderBy:E,orderDir:O,toggleSort:(0,h.useCallback)(e=>{let t,n=`ASC`;E===e?O===`ASC`?(t=e,n=`DESC`):(t=null,n=`ASC`):(t=e,n=`ASC`),D(t),k(n),y(1),A(void 0,void 0,1,t,n)},[E,O,A]),clearSort:(0,h.useCallback)(()=>{D(null),k(`ASC`),y(1),A(void 0,void 0,1,null,`ASC`)},[A]),queryResult:b,queryError:S,queryLoading:w,executeQuery:N,updateCell:P,deleteRow:F,bulkDelete:(0,h.useCallback)(async(e,r)=>{if(!n)return;let a=n,o=i;try{await c.post(`${t}/rows/delete`,{table:a,schema:o,pkColumn:e,pkValues:r}),A(a,o)}catch(e){m(e.message)}},[t,n,i,A]),insertRow:(0,h.useCallback)(async e=>{if(!n)return;let r=n,a=i;try{await c.post(`${t}/row`,{table:r,schema:a,values:e}),A(r,a)}catch(e){throw m(e.message),e}},[t,n,i,A]),refreshData:A,queryAsTable:(0,h.useCallback)(async e=>{f(!0);try{let n=await c.post(`${t}/query`,{sql:e});n.changeType===`select`&&s({columns:n.columns,rows:n.rows,total:n.rows.length,page:1,limit:n.rows.length})}catch(e){m(e.message)}finally{f(!1)}},[t])}}var b=t();function x(e){let t={},n=/"(\w+)"\s+ILIKE\s+'%([^']*?)%'/gi,r;for(;(r=n.exec(e))!==null;)t[r[1]]=r[2].replace(/''/g,`'`);return t}function S({metadata:e,tabId:t}){let n=e?.connectionId,p=e?.connectionName,g=e?.tableName,_=e?.schemaName??`public`,v=e?.initialSql,S=e?.currentSql,C=l(e=>e.updateTab),T=(0,h.useRef)(e);T.current=e;let E=(0,h.useCallback)(e=>{t&&C(t,{metadata:{...T.current,currentSql:e}})},[t,C]),D=y(n),{connections:O,updateConnection:k}=d(),A=(0,h.useMemo)(()=>O.find(e=>e.id===n),[O,n]),[j,M]=(0,h.useState)([]),[N,P]=(0,h.useState)(180),F=(0,h.useRef)(null),[I,L]=(0,h.useState)({}),R=(0,h.useMemo)(()=>{if(v&&!D.selectedTable)return v;if(D.selectedTable){let e=`SELECT * FROM "${D.selectedTable}"`,t=Object.entries(I).filter(([,e])=>e.trim()).map(([e,t])=>`"${e}" ILIKE '%${t.replace(/'/g,`''`)}%'`);t.length>0&&(e+=` WHERE ${t.join(` AND `)}`),D.orderBy&&(e+=` ORDER BY "${D.orderBy}" ${D.orderDir}`);let n=(D.page-1)*100;return e+=` LIMIT 100`,n>0&&(e+=` OFFSET ${n}`),e}return`SELECT * FROM `},[v,D.selectedTable,D.orderBy,D.orderDir,D.page,I]),z=(0,h.useCallback)(e=>{L(e)},[]),B=(0,h.useRef)(void 0);(0,h.useEffect)(()=>{if(!(!D.selectedTable||Object.keys(I).length===0))return clearTimeout(B.current),B.current=setTimeout(()=>{D.queryAsTable(R)},500),()=>clearTimeout(B.current)},[I]);let V=(0,h.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=N,r=e=>{let r=e.clientY-t;P(Math.max(80,Math.min(n+r,(F.current?.clientHeight??600)-100)))},i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[N]);(0,h.useEffect)(()=>{c.get(`/api/db/connections/${n}/tables?cached=1`).then(e=>M(e.map(e=>({name:e.name,schema:e.schema})))).catch(()=>{})},[n]);let H=(0,h.useMemo)(()=>{if(j.length!==0)return{tables:j,getColumns:async(e,t)=>await c.get(`/api/db/connections/${n}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[n,j]),U=(0,h.useRef)(!1);(0,h.useEffect)(()=>{U.current||(U.current=!0,v?D.executeQuery(v):g&&D.selectTable(g,_))},[g,_,v]);let[W,G]=(0,h.useState)(!!v),K=(0,h.useCallback)(e=>{let t=e.trim();if(D.selectedTable&&RegExp(`^SELECT\\s+\\*\\s+FROM\\s+"?${D.selectedTable.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}"?\\b`,`i`).test(t)){L(x(t)),D.queryAsTable(t);return}G(!0),D.executeQuery(e)},[D.executeQuery,D.queryAsTable,D.selectedTable]),q=(0,h.useCallback)(e=>{G(!1),D.toggleSort(e)},[D.toggleSort]),J=(0,h.useCallback)(()=>{G(!1),D.clearSort()},[D.clearSort]),Y=(0,h.useCallback)(e=>{G(!1),D.setPage(e)},[D.setPage]),X=D.queryResult,Z=W&&!!(X||D.queryError),Q=D.selectedTable&&!Z;return(0,b.jsx)(`div`,{ref:F,className:`flex h-full w-full overflow-hidden`,children:(0,b.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,b.jsx)(r,{className:`size-3.5 text-muted-foreground`}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:p??`Database`}),D.selectedTable&&(0,b.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,D.selectedTable]}),(0,b.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[D.tableData&&(0,b.jsx)(i,{columns:D.tableData.columns,rows:D.tableData.rows,filename:p?`${p}-${D.selectedTable??`data`}`:D.selectedTable??`data`,exportAllUrl:D.selectedTable?`/api/db/connections/${n}/export?table=${encodeURIComponent(D.selectedTable)}&schema=${D.selectedSchema}`:void 0}),A&&(0,b.jsx)(`button`,{type:`button`,onClick:()=>k(A.id,{readonly:A.readonly?0:1}),className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] transition-colors ${A.readonly?`text-muted-foreground hover:text-foreground`:`bg-destructive/15 text-destructive`}`,title:A.readonly?`Readonly — click to allow writes`:`WRITE mode — click to enable readonly`,children:A.readonly?(0,b.jsx)(o,{className:`size-3`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s,{className:`size-3`}),(0,b.jsx)(`span`,{className:`font-medium`,children:`WRITE`})]})}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>D.refreshData(),title:`Reload data`,className:`p-1 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,b.jsx)(f,{className:`size-3 ${D.loading?`animate-spin`:``}`})})]})]}),(0,b.jsx)(`div`,{className:`shrink-0 border-b border-border`,style:{height:N},children:(0,b.jsx)(m,{onExecute:K,loading:D.queryLoading,defaultValue:R,schemaInfo:H,onSqlChange:E,persistedSql:S})}),(0,b.jsx)(`div`,{onMouseDown:V,className:`shrink-0 h-1.5 cursor-row-resize bg-border/50 hover:bg-primary/30 flex items-center justify-center transition-colors`,children:(0,b.jsx)(u,{className:`size-3 text-muted-foreground/50`})}),(0,b.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[Q&&D.tableData&&(0,b.jsx)(a,{columns:D.tableData.columns,rows:D.tableData.rows,total:D.tableData.total,limit:D.tableData.limit,schema:D.schema,loading:D.loading,page:D.page,onPageChange:Y,onCellUpdate:D.updateCell,onRowDelete:D.deleteRow,orderBy:D.orderBy,orderDir:D.orderDir,onToggleSort:q,onClearSort:J,onBulkDelete:D.bulkDelete,onInsertRow:D.insertRow,connectionId:n,selectedTable:D.selectedTable,selectedSchema:D.selectedSchema,connectionName:p,columnFilters:I,onColumnFilter:z}),Z&&(0,b.jsx)(w,{result:X,error:D.queryError,loading:D.queryLoading,schema:D.schema,connectionName:p})]})]})})}var C=()=>{};function w({result:e,error:t,loading:n,schema:r,connectionName:i}){let o=(0,h.useMemo)(()=>e?.changeType===`select`&&e.rows.length>0?{columns:e.columns,rows:e.rows,total:e.rows.length,limit:e.rows.length}:null,[e]),s=(0,h.useMemo)(()=>r?.length?r:(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[r,e?.columns]);return(0,b.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden text-xs`,children:[t&&(0,b.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5 shrink-0`,children:t}),e?.changeType===`modify`&&(0,b.jsxs)(`div`,{className:`px-3 py-2 text-green-500 shrink-0`,children:[e.rowsAffected,` row(s) affected`,e.executionTimeMs!=null&&(0,b.jsxs)(`span`,{className:`text-muted-foreground ml-2`,children:[e.executionTimeMs,`ms`]})]}),o&&(0,b.jsxs)(`div`,{className:`flex-1 overflow-hidden`,children:[(0,b.jsx)(a,{columns:o.columns,rows:o.rows,total:o.total,limit:o.limit,schema:s,loading:!!n,page:1,onPageChange:C,onCellUpdate:C,orderBy:null,orderDir:`ASC`,onToggleSort:C,connectionName:i}),e?.executionTimeMs!=null&&(0,b.jsxs)(`div`,{className:`px-3 py-0.5 border-t border-border text-[10px] text-muted-foreground shrink-0`,children:[e.rows.length,` rows · `,e.executionTimeMs,`ms`]})]}),e?.changeType===`select`&&e.rows.length===0&&(0,b.jsxs)(`div`,{className:`px-3 py-2 text-muted-foreground shrink-0`,children:[`No results`,e.executionTimeMs!=null&&(0,b.jsxs)(`span`,{className:`ml-2 text-muted-foreground/60`,children:[e.executionTimeMs,`ms`]})]}),!e&&!t&&(0,b.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:n?(0,b.jsx)(p,{className:`size-4 animate-spin`}):`Run a query to see results`})]})}export{S as DatabaseViewer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{t as r}from"./text-wrap-DJz9Bgpa.js";import{i,t as a}from"./api-client-BK4NPNoY.js";import{n as o}from"./settings-store-DQUFTPk2.js";import"./vendor-mermaid-DkqjpqJK.js";import{D as s,pt as c,xt as l}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{t as r}from"./text-wrap-DJz9Bgpa.js";import{i,t as a}from"./api-client-BK4NPNoY.js";import{n as o}from"./settings-store-DQUFTPk2.js";import"./vendor-mermaid-DkqjpqJK.js";import{D as s,pt as c,xt as l}from"./index-BlRGbnAE.js";import{r as u,t as d}from"./use-monaco-theme-BLIgarH5.js";var f=e(n(),1),p=t();function m(e){return{js:`javascript`,jsx:`javascript`,ts:`typescript`,tsx:`typescript`,py:`python`,html:`html`,css:`css`,scss:`scss`,json:`json`,md:`markdown`,mdx:`markdown`,yaml:`yaml`,yml:`yaml`,sh:`shell`,bash:`shell`}[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function h({metadata:e}){let t=e?.filePath,n=e?.projectName,h=e?.ref1,_=e?.ref2,v=e?.file1,y=e?.file2,b=e?.original,x=e?.modified,S=b!=null||x!=null,C=!!(v&&y),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(!S),[M,N]=(0,f.useState)(null),{wordWrap:P,toggleWordWrap:F}=o(s(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),I=d(),L=(0,f.useRef)(null),R=(0,f.useRef)(null),[z,B]=(0,f.useState)(!1),[V,H]=(0,f.useState)();(0,f.useEffect)(()=>{let e=L.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&H(Math.floor(e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[A,M]),(0,f.useEffect)(()=>{if(S||!n)return;if(j(!0),N(null),k(null),D(null),T(null),v&&y){let e=new URLSearchParams({file1:v,file2:y});a.get(`${i(n)}/files/compare?${e}`).then(e=>{D(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to compare files`),j(!1)});return}if(t){let e=new URLSearchParams({file:t});h&&e.set(`ref`,h),_&&e.set(`ref2`,_),a.get(`${i(n)}/git/file-full-diff?${e}`).then(e=>{k(e),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)});return}let e;if(h||_){let t=new URLSearchParams;h&&t.set(`ref1`,h),_&&t.set(`ref2`,_),e=`${i(n)}/git/diff?${t}`}else e=`${i(n)}/git/diff`;a.get(e).then(e=>{T(e.diff),j(!1)}).catch(e=>{N(e instanceof Error?e.message:`Failed to load diff`),j(!1)})},[t,n,h,_,v,y,S]);let{original:U,modified:W}=(0,f.useMemo)(()=>S?{original:b??``,modified:x??``}:C&&E?E:O||(w?g(w):{original:``,modified:``}),[w,S,b,x,C,E,O]),G=(0,f.useMemo)(()=>{let e=t??y??v;return e?m(e):`plaintext`},[t,v,y]),K=typeof window<`u`&&window.innerWidth<768,q=!K;return(0,f.useEffect)(()=>{let e=R.current;if(!e)return;let t=K||P?`on`:`off`;e.updateOptions({diffWordWrap:t}),e.getOriginalEditor().updateOptions({wordWrapOverride2:t}),e.getModifiedEditor().updateOptions({wordWrapOverride2:t})},[P,K,z]),!n&&!S?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No project selected.`}):A?(0,p.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,p.jsx)(c,{className:`size-5 animate-spin`}),(0,p.jsx)(`span`,{className:`text-sm`,children:`Loading diff...`})]}):M?(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full text-destructive text-sm`,children:M}):!S&&!C&&!O&&!U&&!W?(0,p.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-2 text-muted-foreground`,children:[(0,p.jsx)(l,{className:`size-8`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`No content changes`}),t&&(0,p.jsx)(`p`,{className:`text-xs font-mono`,children:t})]}):(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!K&&(0,p.jsx)(`div`,{className:`flex items-center justify-end gap-0.5 px-2 py-0.5 border-b border-border shrink-0`,children:(0,p.jsx)(`button`,{type:`button`,onClick:F,title:`Toggle word wrap`,className:`p-1 rounded hover:bg-muted transition-colors ${P?`bg-muted text-foreground`:``}`,children:(0,p.jsx)(r,{className:`size-3.5`})})}),(0,p.jsx)(`div`,{ref:L,className:`flex-1 overflow-hidden`,children:V&&V>0?(0,p.jsx)(u,{height:V,language:G,original:U,modified:W,theme:I,onMount:e=>{R.current=e,B(!0)},options:{fontSize:K?11:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,diffWordWrap:K||P?`on`:`off`,renderSideBySide:q,useInlineViewWhenSpaceIsLimited:!1,readOnly:!0,automaticLayout:!0,scrollBeyondLastLine:!1},loading:(0,p.jsx)(c,{className:`size-5 animate-spin text-muted-foreground`})}):(0,p.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,p.jsx)(c,{className:`size-5 animate-spin text-muted-foreground`})})})]})}function g(e){let t=e.split(`
|
|
2
2
|
`),n=[],r=[],i=!1;for(let e of t)if(!(e.startsWith(`diff --git`)||e.startsWith(`diff --no-index`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`---`)||e.startsWith(`+++`)||e.startsWith(`Binary files`)||e.startsWith(`\\ No newline`))){if(e.startsWith(`@@`)){i=!0;continue}if(i)if(e.startsWith(`-`))n.push(e.slice(1));else if(e.startsWith(`+`))r.push(e.slice(1));else{let t=e.startsWith(` `)?e.slice(1):e;n.push(t),r.push(t)}}return{original:n.join(`
|
|
3
3
|
`),modified:r.join(`
|
|
4
4
|
`)}}export{h as DiffViewer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{t as r}from"./file-exclamation-point-Baz81y5z.js";import{i,t as a}from"./api-client-BK4NPNoY.js";import{pt as o}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{t as r}from"./file-exclamation-point-Baz81y5z.js";import{i,t as a}from"./api-client-BK4NPNoY.js";import{pt as o}from"./index-BlRGbnAE.js";var s=e(n(),1),c=t();function l({filePath:e,projectName:t}){let[n,l]=(0,s.useState)(null),[u,d]=(0,s.useState)(!0),[f,p]=(0,s.useState)(null);return(0,s.useEffect)(()=>{d(!0),p(null);let n=/^(\/|[A-Za-z]:[/\\])/.test(e)?`/api/fs/docx-html?path=${encodeURIComponent(e)}`:`${i(t)}/files/docx-html?path=${encodeURIComponent(e)}`;a.get(n).then(e=>{l(e.html),d(!1)}).catch(e=>{p(e instanceof Error?e.message:`Failed to convert docx`),d(!1)})},[e,t]),(0,s.useEffect)(()=>{let n=n=>{let r=n.detail;if(r.projectName!==t||r.path!==e)return;let o=/^(\/|[A-Za-z]:[/\\])/.test(e)?`/api/fs/docx-html?path=${encodeURIComponent(e)}`:`${i(t)}/files/docx-html?path=${encodeURIComponent(e)}`;a.get(o).then(e=>l(e.html)).catch(()=>{})};return window.addEventListener(`file:changed`,n),()=>window.removeEventListener(`file:changed`,n)},[e,t]),u?(0,c.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,c.jsx)(o,{className:`size-5 animate-spin`}),(0,c.jsx)(`span`,{className:`text-sm`,children:`Converting document...`})]}):f?(0,c.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,c.jsx)(r,{className:`size-10 text-text-subtle`}),(0,c.jsx)(`p`,{className:`text-sm`,children:`Failed to load document.`}),(0,c.jsx)(`p`,{className:`text-xs text-text-subtle`,children:f})]}):(0,c.jsx)(`div`,{className:`h-full overflow-auto bg-white dark:bg-zinc-900`,children:(0,c.jsx)(`div`,{className:`docx-preview max-w-3xl mx-auto px-6 py-8 text-sm text-foreground leading-relaxed
|
|
2
2
|
[&_table]:border-collapse [&_table]:w-full [&_table]:my-3
|
|
3
3
|
[&_td]:border [&_td]:border-border [&_td]:px-2 [&_td]:py-1
|
|
4
4
|
[&_th]:border [&_th]:border-border [&_th]:px-2 [&_th]:py-1 [&_th]:font-semibold [&_th]:bg-muted/50
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{r}from"./api-client-BK4NPNoY.js";import{j as i,pt as a}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{r}from"./api-client-BK4NPNoY.js";import{j as i,pt as a}from"./index-BlRGbnAE.js";var o=e(n(),1),s=t(),c=`<script>
|
|
2
2
|
function acquireVsCodeApi(){return{postMessage:function(m){window.parent.postMessage(m,"*")},getState:function(){try{return JSON.parse(sessionStorage.getItem("vscode-state")||"null")}catch{return null}},setState:function(s){sessionStorage.setItem("vscode-state",JSON.stringify(s));return s}}}
|
|
3
3
|
<\/script>`;function l(e){if(!e)return e;let t=e.indexOf(`<head>`);return t===-1?c+e:e.slice(0,t+6)+c+e.slice(t+6)}function u({metadata:e}){let t=e?.panelId,n=e?.viewType,c=e?.projectName||void 0,[u,d]=(0,o.useState)(!1),f=i(e=>e.contributions!==null),p=i(e=>{if(t&&e.webviewPanels[t])return e.webviewPanels[t];if(n){let t=n.includes(`.`)?n:`${n}.view`;return Object.values(e.webviewPanels).find(e=>e.viewType===n||e.viewType===t)}}),m=p?.id??t,h=(0,o.useRef)(null),g=p?.html??``,_=l(g),v=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(p||!n||!f||c&&c===v.current)return;c&&(v.current=c);let e=n.includes(`.`)?n:`${n}.view`,t=!1;async function i(){let n=[];if(c)try{let e=r(),t=(await(await fetch(`/api/projects`,e?{headers:{Authorization:`Bearer ${e}`}}:{})).json()).data?.find(e=>e.name===c);t&&(n=[t.path])}catch{}t||window.dispatchEvent(new CustomEvent(`ext:command:execute`,{detail:{command:e,args:n,recovery:!0}}))}return i(),()=>{t=!0}},[p,n,c,f]);let y=e?.extensionId,b=i(e=>{if(y&&e.activationErrors[y])return e.activationErrors[y];if(n){for(let[t,r]of Object.entries(e.activationErrors))if(t===`ext-${n}`)return r}}),x=(0,o.useCallback)(()=>{if(d(!1),!n)return;let e=n.includes(`.`)?n:`${n}.view`;(async()=>{try{let t=r(),n=(await(await fetch(`/api/projects`,t?{headers:{Authorization:`Bearer ${t}`}}:{})).json()).data?.find(e=>e.name===c),i=n?[n.path]:[];window.dispatchEvent(new CustomEvent(`ext:command:execute`,{detail:{command:e,args:i,recovery:!0}}))}catch{}})()},[n,c]),S=(0,o.useRef)(null),C=(0,o.useRef)(n);return(0,o.useEffect)(()=>{S.current=m??null},[m]),(0,o.useEffect)(()=>{C.current=n},[n]),(0,o.useEffect)(()=>()=>{let e=S.current;if(e){let t=C.current;i.getState().removeWebviewPanel(e),window.dispatchEvent(new CustomEvent(`ext:webview:close`,{detail:{panelId:e,viewType:t}}))}},[]),(0,o.useEffect)(()=>{if(p){d(!1);return}if(!f||!n)return;let e=0,t=setInterval(()=>{if(e++,e>3){clearInterval(t),d(!0);return}x()},2e3);return()=>clearInterval(t)},[p,f,n,x]),(0,o.useEffect)(()=>{if(!m)return;let e=e=>{h.current&&e.source===h.current.contentWindow&&window.dispatchEvent(new CustomEvent(`ext:webview:send`,{detail:{panelId:m,message:e.data}}))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[m]),(0,o.useEffect)(()=>{if(!m)return;let e=e=>{let{panelId:t,message:n}=e.detail;t===m&&h.current?.contentWindow?.postMessage(n,`*`)};return window.addEventListener(`ext:webview:message`,e),()=>window.removeEventListener(`ext:webview:message`,e)},[m]),!p||!g?(0,s.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-sm text-text-subtle`,children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`span`,{className:`text-destructive font-medium`,children:`Extension failed to load`}),b&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground max-w-md text-center`,children:b}),(0,s.jsx)(`button`,{onClick:x,className:`text-xs text-primary hover:underline`,children:`Retry`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a,{className:`size-5 animate-spin`}),(0,s.jsx)(`span`,{children:`Loading extension...`})]})}):(0,s.jsx)(`div`,{className:`h-full w-full relative`,children:(0,s.jsx)(`iframe`,{ref:h,srcDoc:_,sandbox:`allow-scripts`,className:`w-full h-full border-0 bg-white dark:bg-zinc-900`,title:p.title},m)})}export{u as ExtensionWebview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-UXCWAcmi.js";import{t as r}from"./createLucideIcon-BjHrJDVb.js";import{t as i}from"./arrow-down-D825m4vm.js";import{t as a}from"./arrow-up-Rcw6_KKu.js";import{i as o,t as s}from"./api-client-BK4NPNoY.js";import{n as c}from"./utils-CSCvNZxE.js";import{n as l}from"./project-store-DlbHpIq0.js";import{D as u,Tt as d,et as f,gt as p,ot as m,pt as h}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import"./vendor-ui-UXCWAcmi.js";import{t as r}from"./createLucideIcon-BjHrJDVb.js";import{t as i}from"./arrow-down-D825m4vm.js";import{t as a}from"./arrow-up-Rcw6_KKu.js";import{i as o,t as s}from"./api-client-BK4NPNoY.js";import{n as c}from"./utils-CSCvNZxE.js";import{n as l}from"./project-store-DlbHpIq0.js";import{D as u,Tt as d,et as f,gt as p,ot as m,pt as h}from"./index-BlRGbnAE.js";var g=r(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),_=e(n(),1),v=t(),y=[`#2563eb`,`#16a34a`,`#d97706`,`#9333ea`,`#dc2626`,`#0891b2`,`#c026d3`,`#ea580c`];function b(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return y[Math.abs(t)%y.length]}function x({name:e,syncState:t,isHead:n,isTag:r,className:o}){let s=r?`#d97706`:b(e),l=r?f:t===`synced`?d:t===`ahead`?a:t===`behind`?i:t===`remote-only`?d:g,u=r?`Tag: ${e}`:t===`synced`?`${e} — synced with remote`:t===`ahead`?`${e} — ahead of remote`:t===`behind`?`${e} — behind remote`:t===`remote-only`?`${e} — remote only`:`${e} — local only`;return(0,v.jsxs)(`span`,{className:c(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium leading-tight max-w-[220px]`,n&&`ring-1 ring-offset-1 ring-offset-background`,t===`remote-only`&&`opacity-70`,o),style:{borderColor:s,backgroundColor:s+`1A`,color:`#1a1a1a`,...n?{"--tw-ring-color":s}:{}},title:u,children:[(0,v.jsx)(l,{className:`size-3 shrink-0`,style:{color:s}}),(0,v.jsx)(`span`,{className:`truncate`,children:e})]})}function S(e,t,n,r){let i=[],a=e===r;for(let e of t)e.startsWith(`tag: `)&&i.push({name:e.slice(5),syncState:`synced`,isTag:!0});let o=n.filter(t=>t.commitHash===e),s=o.filter(e=>!e.remote),c=o.filter(e=>e.remote);new Set(s.map(e=>e.name));let l=new Set;for(let e of s){let t=`local-only`;e.remotes.length>0&&(t=e.ahead>0&&e.behind===0?`ahead`:e.behind>0&&e.ahead===0?`behind`:`synced`),i.push({name:e.name,syncState:t,isHead:a&&e.current});for(let t of c){let n=t.name.replace(/^remotes\//,``),r=n.indexOf(`/`);r<0||n.slice(r+1)===e.name&&l.add(t.name)}}for(let e of c){if(l.has(e.name))continue;let t=e.name.replace(/^remotes\//,``);i.push({name:t,syncState:`remote-only`})}return i}var C=100;function w({metadata:e}){let t=e?.projectName??l(u(e=>e.activeProject))?.name,[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!1),[c,d]=(0,_.useState)(!0),f=(0,_.useRef)(null),g=(0,_.useCallback)(async(e=0,n=!1)=>{if(t){a(!0);try{let i=await s.get(`${o(t)}/git/graph?max=${C}&skip=${e}`);r(e=>n&&e?{...i,commits:[...e.commits,...i.commits]}:i),d(i.commits.length===C)}catch{}a(!1)}},[t]);(0,_.useEffect)(()=>{g()},[g]);let y=(0,_.useCallback)(()=>{i||!c||!n||g(n.commits.length,!0)},[i,c,n,g]),b=(0,_.useCallback)(e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<200&&y()},[y]);return t?(0,v.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border shrink-0`,children:[(0,v.jsx)(p,{className:`size-4 text-text-secondary`}),(0,v.jsx)(`span`,{className:`text-xs font-medium text-text-primary`,children:`Git Log`}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle`,children:n?`${n.commits.length} commits`:``}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsx)(`button`,{onClick:()=>g(),disabled:i,className:`p-1 rounded text-text-subtle hover:text-text-secondary transition-colors`,title:`Refresh`,children:(0,v.jsx)(m,{className:`size-3.5 ${i?`animate-spin`:``}`})})]}),!n&&i?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(h,{className:`size-5 animate-spin text-primary`})}):n&&n.commits.length===0?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No commits yet`}):n?(0,v.jsxs)(`div`,{ref:f,className:`flex-1 overflow-y-auto min-h-0`,onScroll:b,children:[n.commits.map(e=>(0,v.jsx)(T,{commit:e,branches:n.branches,head:n.head},e.hash)),i&&(0,v.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,v.jsx)(h,{className:`size-4 animate-spin text-text-subtle`})}),!c&&n.commits.length>0&&(0,v.jsx)(`div`,{className:`text-center text-[10px] text-text-subtle py-3`,children:`End of history`})]}):null]}):(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`Select a project to view git log`})}function T({commit:e,branches:t,head:n}){let r=e.hash===n,i=S(e.hash,e.refs,t,n);return(0,v.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-1.5 border-b border-border/50 hover:bg-surface-elevated transition-colors ${r?`bg-primary/5`:``}`,children:[(0,v.jsx)(`div`,{className:`flex items-center pt-1 shrink-0`,children:(0,v.jsx)(`span`,{className:`size-2.5 rounded-full border-2 ${r?`border-primary bg-primary`:`border-text-subtle bg-transparent`}`})}),(0,v.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[i.length>0&&(0,v.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 mb-0.5`,children:i.map(e=>(0,v.jsx)(x,{...e},`${e.name}-${e.syncState}`))}),(0,v.jsx)(`p`,{className:`text-xs text-text-primary truncate leading-snug`,children:e.subject}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,v.jsx)(`span`,{className:`text-[10px] font-mono text-text-subtle`,children:e.abbreviatedHash}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle truncate`,children:e.authorName}),(0,v.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:E(e.authorDate)})]})]})]})}function E(e){let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<30?`${a}d`:t.toLocaleDateString(`en`,{month:`short`,day:`numeric`})}export{w as GitLogPanel};
|