@hienlh/ppm 0.13.73 → 0.13.74
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 +2 -1
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/{audio-preview-wwkov12A.js → audio-preview-twszgh6m.js} +1 -1
- package/dist/web/assets/{chat-tab-BzuMv9V1.js → chat-tab-ClW604Oj.js} +3 -3
- package/dist/web/assets/code-editor-CP0Sidni.js +10 -0
- package/dist/web/assets/{conflict-editor-CVg3dbPI.js → conflict-editor-Cjj4IcSV.js} +1 -1
- package/dist/web/assets/{database-viewer-FsKBOOvd.js → database-viewer-Ct8Xe9xA.js} +1 -1
- package/dist/web/assets/{diff-viewer-BG-KpKk7.js → diff-viewer-C8Ee5PH_.js} +1 -1
- package/dist/web/assets/{docx-preview-CSsiGNTj.js → docx-preview-5GXTCC95.js} +1 -1
- package/dist/web/assets/{extension-webview-CFkGbmvp.js → extension-webview-3jX64E_M.js} +1 -1
- package/dist/web/assets/{git-log-panel-DpEykYRH.js → git-log-panel-D-6gt7Pv.js} +1 -1
- package/dist/web/assets/{glide-data-grid-BG03X5LW.js → glide-data-grid-DndbR9Co.js} +1 -1
- package/dist/web/assets/{image-preview-CqcmhMKP.js → image-preview-f92bkvIy.js} +1 -1
- package/dist/web/assets/{index-xoq3_MQL.js → index-BeEfCJbj.js} +3 -3
- package/dist/web/assets/keybindings-store-wnX691Lw.js +1 -0
- package/dist/web/assets/{markdown-renderer-DY8ntmZ9.js → markdown-renderer-Cj104shG.js} +1 -1
- package/dist/web/assets/notification-store-D_Lxdo_k.js +1 -0
- package/dist/web/assets/{pdf-preview-BGi9l4Rr.js → pdf-preview-BDigPZWf.js} +1 -1
- package/dist/web/assets/{port-forwarding-tab-CdvQszdo.js → port-forwarding-tab-c6uH6Kor.js} +1 -1
- package/dist/web/assets/{postgres-viewer-CSQQdobI.js → postgres-viewer-CMVqKks2.js} +1 -1
- package/dist/web/assets/{settings-tab-C-9lTT_Q.js → settings-tab-CRjzY9lj.js} +1 -1
- package/dist/web/assets/{sql-query-editor-DqrdbtmC.js → sql-query-editor-C5zeUzXt.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-CrsPV7g8.js → sqlite-viewer-Re80qgfe.js} +1 -1
- package/dist/web/assets/{system-monitor-tab-DUQUIWMw.js → system-monitor-tab-CbaoNKga.js} +1 -1
- package/dist/web/assets/{terminal-tab-DMXBZNKN.js → terminal-tab-BP6-eJeb.js} +1 -1
- package/dist/web/assets/{video-preview-BZOtuBy_.js → video-preview-BxW3CCRd.js} +1 -1
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/src/web/components/editor/code-editor.tsx +21 -0
- package/dist/web/assets/code-editor-TSmzzErj.js +0 -10
- package/dist/web/assets/keybindings-store-C1nefNJG.js +0 -1
- package/dist/web/assets/notification-store-CfIiISPY.js +0 -1
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-DY8ntmZ9.js","assets/rolldown-runtime-FhOqtrmT.js","assets/index-xoq3_MQL.js","assets/vendor-mermaid-CsBwn--q.js","assets/vendor-ui-UXCWAcmi.js","assets/vendor-markdown-0Mxgxy0L.js","assets/input-DSELw5zU.js","assets/utils-Bs_TFEQf.js","assets/createLucideIcon-BjHrJDVb.js","assets/x-WwAMX3EB.js","assets/settings-store-DRbccx1s.js","assets/react-BXxixfbh.js","assets/api-client-DG9qwosT.js","assets/eye-off-BacF7RVS.js","assets/ai-settings-section-D0VMZ4aE.js","assets/chevron-down-BMo4cBth.js","assets/globe-CQ8NAYvi.js","assets/trash-2-DkIfBY8d.js","assets/refresh-cw-CRD2qr4U.js","assets/api-settings-Byph7lae.js","assets/database-Dc8mr-dP.js","assets/chevron-right-CD8e6Aj4.js","assets/search-D90WJ5fo.js","assets/panel-store-DlvwzOll.js","assets/project-store-CpC02pIv.js","assets/tab-store-Bdw8DIbZ.js","assets/index-fyMt5gpO.css","assets/csv-preview-CwEbP_iZ.js","assets/lib-D4YDpYv4.js","assets/arrow-down-D825m4vm.js","assets/arrow-up-Rcw6_KKu.js","assets/csv-parser-B_TuHmnd.js","assets/image-preview-CqcmhMKP.js","assets/file-exclamation-point-B__2Hrd6.js","assets/use-blob-url-CBi0HMq5.js","assets/pdf-preview-BGi9l4Rr.js","assets/video-preview-BZOtuBy_.js","assets/audio-preview-wwkov12A.js","assets/docx-preview-CSsiGNTj.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-Dc8mr-dP.js";import{t as a}from"./chevron-right-CD8e6Aj4.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-DSELw5zU.js";import{t as p}from"./code-DiNmA3eR.js";import{i as m,r as h}from"./trash-2-DkIfBY8d.js";import{t as ee}from"./file-exclamation-point-B__2Hrd6.js";import{i as g,r as te,t as _}from"./glide-data-grid-BG03X5LW.js";import{t as ne}from"./shield-check-DeIMQtEj.js";import{t as re}from"./shield-off-D4jBmG5E.js";import{t as v}from"./table-DCYlHUNQ.js";import{t as y}from"./text-wrap-B3mYv9Yo.js";import{t as b}from"./x-WwAMX3EB.js";import{i as ie,t as x}from"./api-client-DG9qwosT.js";import{n as ae}from"./settings-store-DRbccx1s.js";import{K as S}from"./vendor-mermaid-CsBwn--q.js";import{t as C}from"./utils-Bs_TFEQf.js";import{t as oe}from"./panel-store-DlvwzOll.js";import{n as w}from"./project-store-CpC02pIv.js";import{t as se}from"./tab-store-Bdw8DIbZ.js";import{H as T,O as E,X as ce,_ as le,at as ue,ct as D,d as O,et as k,f as de,ft as fe,h as A,it as j,l as M,lt as N,m as P,o as pe,ot as F,p as me,rt as he,s as ge,st as I,tt as L,u as _e,v as ve}from"./index-xoq3_MQL.js";import"./data-grid-types-CO_3iSwd.js";import{n as ye,t as be}from"./use-monaco-theme-CKmBga-e.js";var xe=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`}]]),R=e(n(),1),z=t(),Se={ts:I,tsx:I,js:I,jsx:I,py:I,rs:I,go:I,html:I,css:I,scss:I,json:D,md:F,txt:F,yaml:ue,yml:ue};function B(e,t){return t?he:Se[e.split(`.`).pop()?.toLowerCase()??``]??j}function Ce(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 V(e){return[...e].sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1)}function we({filePath:e,projectName:t,tabId:n,className:r}){let i=E(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,R.useRef)(null),{prefixParts:u,relativePath:d}=(0,R.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,R.useMemo)(()=>Ce(i,d.split(`/`).filter(Boolean)),[i,d]);(0,R.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,z.jsxs)(`div`,{ref:l,className:r,children:[u.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[t>0&&(0,z.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground px-1 py-0.5`,children:e})]},`prefix-${t}`)),f.map((e,n)=>(0,z.jsxs)(`div`,{className:`flex items-center shrink-0`,children:[(n>0||u.length>0)&&(0,z.jsx)(a,{className:`size-3 text-muted-foreground shrink-0 mx-0.5`}),(0,z.jsx)(Te,{segment:e,isLast:n===f.length-1,projectName:t,onFileClick:p})]},e.fullPath))]})}function Te({segment:e,isLast:t,projectName:n,onFileClick:r}){let i=E(e=>e.loadChildren),a=E(e=>e.loadedPaths),o=(0,R.useMemo)(()=>V(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,z.jsxs)(M,{onOpenChange:c,children:[(0,z.jsx)(A,{asChild:!0,children:(0,z.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,z.jsx)(_e,{align:`start`,className:`max-h-[300px] p-1`,children:o.length===0?(0,z.jsx)(O,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):o.map(t=>(0,z.jsx)(H,{node:t,projectName:n,activePath:e.fullPath,onFileClick:r},t.path))})]})}function H({node:e,projectName:t,activePath:n,onFileClick:r}){let i=B(e.name,e.type===`directory`),a=e.path===n,o=E(e=>e.loadChildren),s=E(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,z.jsxs)(de,{onOpenChange:u,children:[(0,z.jsxs)(P,{className:`text-xs gap-1.5 ${a?`bg-muted`:``}`,children:[(0,z.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,z.jsx)(me,{className:`max-h-[300px] overflow-y-auto p-1`,children:c.length===0?(0,z.jsx)(O,{disabled:!0,className:`text-xs text-muted-foreground`,children:`Loading…`}):V(c).map(e=>(0,z.jsx)(H,{node:e,projectName:t,activePath:n,onFileClick:r},e.path))})]})}return(0,z.jsxs)(O,{className:`text-xs gap-1.5 cursor-pointer ${a?`bg-muted`:``}`,onSelect:e=>{},onClick:t=>{r(e.path,t)},children:[(0,z.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name})]})}function U({active:e,onClick:t,icon:n,label:r}){return(0,z.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,z.jsx)(n,{className:`size-3`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:r})]})}function Ee({ext:e,mdMode:t,onMdModeChange:n,csvMode:r,onCsvModeChange:i,wordWrap:a,onToggleWordWrap:o,filePath:s,projectName:c,className:l}){return(0,z.jsxs)(`div`,{className:l,children:[(e===`md`||e===`mdx`)&&n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{active:t===`edit`,onClick:()=>n(`edit`),icon:p,label:`Edit`}),(0,z.jsx)(U,{active:t===`preview`,onClick:()=>n(`preview`),icon:h,label:`Preview`})]}),e===`csv`&&i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{active:r===`table`,onClick:()=>i(`table`),icon:v,label:`Table`}),(0,z.jsx)(U,{active:r===`raw`,onClick:()=>i(`raw`),icon:p,label:`Raw`})]}),(0,z.jsx)(U,{active:a,onClick:o,icon:y,label:`Wrap`}),s&&c&&(0,z.jsx)(U,{active:!1,onClick:()=>ve(c,s),icon:m,label:`Download`})]})}function De({open:e,defaultName:t,content:n,onSave:r,onCancel:i}){let[a,p]=(0,R.useState)(t),[m,h]=(0,R.useState)(!1),[ee,g]=(0,R.useState)(``),te=w(e=>e.activeProject),_=(0,R.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,R.useCallback)(e=>{let t=e.includes(`\\`)?`\\`:`/`;r(e.endsWith(t)?`${e}${a.trim()}`:`${e}${t}${a.trim()}`,n)},[a,n,r]);return m?(0,z.jsx)(ge,{open:!0,mode:`folder`,root:te?.path,title:`Save "${a.trim()}" to...`,onSelect:ne,onCancel:()=>h(!1)}):(0,z.jsx)(c,{open:e,onOpenChange:e=>{e||i()},children:(0,z.jsxs)(u,{className:`sm:max-w-md`,children:[(0,z.jsx)(l,{children:(0,z.jsx)(d,{children:`Save As`})}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,z.jsx)(`label`,{className:`text-sm text-muted-foreground`,children:`Filename`}),(0,z.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,z.jsx)(`p`,{className:`text-xs text-destructive`,children:ee})]}),(0,z.jsxs)(o,{children:[(0,z.jsx)(s,{variant:`outline`,onClick:i,children:`Cancel`}),(0,z.jsx)(s,{onClick:_,children:`Choose Folder...`})]})]})})}var W=typeof window<`u`&&window.isSecureContext,G=[`(`,`)`,`{`,`}`,`[`,`]`,`<`,`>`,`;`,`:`,`=`,`"`,`'`,"`",`/`,`\\`,`_`,`#`],K=`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`,Oe=`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`,q=`w-px h-5 bg-border mx-0.5 shrink-0`;function ke({editorRef:e,readOnly:t}){let n=(0,R.useCallback)(()=>e.current,[e]),r=(0,R.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,R.useState)(!1),o=(0,R.useRef)(null),s=(0,R.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&r(e)}catch{}},[r]),c=(0,R.useCallback)(()=>{a(!0),requestAnimationFrame(()=>o.current?.focus())},[]),l=(0,R.useCallback)(e=>{e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(a(!1),r(t))},[r]),u=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`undo`,null))},[n]),d=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`redo`,null))},[n]),f=(0,R.useCallback)(()=>{let e=n();e&&(e.focus(),e.trigger(`mobile-toolbar`,`tab`,null))},[n]);return t?null:(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border bg-surface`,children:[!W&&i&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border bg-muted/50`,children:[(0,z.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,z.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`p-1.5 rounded text-muted-foreground active:bg-muted transition-colors`,children:(0,z.jsx)(b,{size:14})})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5 overflow-x-auto`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:W?s:c,className:K,title:`Paste`,children:(0,z.jsx)(fe,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:u,className:K,title:`Undo`,children:(0,z.jsx)(T,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:d,className:K,title:`Redo`,children:(0,z.jsx)(xe,{size:14})}),(0,z.jsx)(`div`,{className:q}),(0,z.jsx)(`button`,{type:`button`,onClick:f,className:Oe,children:`Tab`}),(0,z.jsx)(`div`,{className:q}),G.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>r(e),className:Oe,children:e},e))]})]})}var J=(0,R.lazy)(()=>S(()=>import(`./markdown-renderer-DY8ntmZ9.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,24,25,26]))),Ae=(0,R.lazy)(()=>S(()=>import(`./csv-preview-CwEbP_iZ.js`).then(e=>({default:e.CsvPreview})),__vite__mapDeps([27,1,4,5,28,29,8,30,31]))),je=(0,R.lazy)(()=>S(()=>import(`./image-preview-CqcmhMKP.js`).then(e=>({default:e.ImagePreview})),__vite__mapDeps([32,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Me=(0,R.lazy)(()=>S(()=>import(`./pdf-preview-BGi9l4Rr.js`).then(e=>({default:e.PdfPreview})),__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,24,25,26,33]))),Ne=(0,R.lazy)(()=>S(()=>import(`./video-preview-BZOtuBy_.js`).then(e=>({default:e.VideoPreview})),__vite__mapDeps([36,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Pe=(0,R.lazy)(()=>S(()=>import(`./audio-preview-wwkov12A.js`).then(e=>({default:e.AudioPreview})),__vite__mapDeps([37,2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33,34]))),Fe=(0,R.lazy)(()=>S(()=>import(`./docx-preview-CSsiGNTj.js`).then(e=>({default:e.DocxPreview})),__vite__mapDeps([38,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,33]))),Ie=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`ico`]),Le=new Set([`mp4`,`webm`,`mov`,`ogg`,`avi`,`mkv`]),Re=new Set([`mp3`,`wav`,`flac`,`aac`,`m4a`,`wma`]),ze=new Set([`db`,`sqlite`,`sqlite3`]);function Be(e){return e.split(`.`).pop()?.toLowerCase()??``}function Ve(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`}[Be(e)]??`plaintext`}var He=(0,R.memo)(function({metadata:e,tabId:t}){let n=e?.filePath,r=e?.projectName,a=e?.inlineContent,o=e?.inlineLanguage,[s,c]=(0,R.useState)(a??null),[l,u]=(0,R.useState)(`utf-8`),[d,f]=(0,R.useState)(!0),[p,m]=(0,R.useState)(null),[h,_]=(0,R.useState)(!1),v=(0,R.useRef)(null),y=(0,R.useRef)(``),b=(0,R.useRef)(null),{tabs:S,updateTab:w}=se(le(e=>({tabs:e.tabs,updateTab:e.updateTab}))),{wordWrap:T,toggleWordWrap:E}=ae(le(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap}))),ue=be(),D=e?.isUntitled===!0,O=e?.unsavedContent,[de,fe]=(0,R.useState)(!1),A=S.find(e=>e.id===t),j=n?Be(n):``,M=Ie.has(j),N=j===`pdf`,P=j===`docx`,F=Le.has(j),me=Re.has(j),he=ze.has(j),ge=j===`md`||j===`mdx`,I=j===`csv`,L=j===`sql`,[_e,ve]=(0,R.useState)(`preview`),[xe,Se]=(0,R.useState)(`table`),{connections:B,cachedTables:Ce,refreshTables:V,updateConnection:Te}=pe(),[H,U]=(0,R.useState)(()=>{if(!L||!n)return null;let e=localStorage.getItem(`ppm:sql-conn:${n}`);return e?Number(e):null}),W=(0,R.useRef)(null),G=(0,R.useRef)(null),K=(0,R.useMemo)(()=>B.find(e=>e.id===H)??null,[B,H]),Oe=a!=null&&(o===`json`||o===`xml`),[q,J]=(0,R.useState)(!1),He=(0,R.useCallback)(()=>{if(a)if(q)c(a),J(!1);else{let e=a.trimStart();if(o===`json`)try{c(JSON.stringify(JSON.parse(e),null,2)),J(!0)}catch{}else if(o===`xml`){let t=0;c(e.replace(/(>)(<)(\/*)/g,`$1
|
|
3
|
-
$2$3`).split(`
|
|
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
|
-
`)),J(!0)}}},[a,o,q]),Y=(0,R.useCallback)(e=>{U(e),n&&localStorage.setItem(`ppm:sql-conn:${n}`,String(e)),V(e).catch(()=>{})},[n,V]),Z=(0,R.useMemo)(()=>{if(!L||!H)return;let e=(Ce.get(H)??[]).map(e=>({name:e.tableName,schema:e.schemaName}));if(e.length!==0)return{tables:e,getColumns:async(e,t)=>x.get(`/api/db/connections/${H}/schema?table=${encodeURIComponent(e)}${t?`&schema=${encodeURIComponent(t)}`:``}`)}},[L,H,Ce]);(0,R.useEffect)(()=>{if(!(!W.current||!Z))return G.current?.dispose(),te(),G.current=W.current.languages.registerCompletionItemProvider(`sql`,g(W.current,Z)),()=>{G.current?.dispose()}},[Z]);let Ge=se(e=>e.openTab),[Ke,qe]=(0,R.useState)(null),[Je,Ye]=(0,R.useState)(null),[Xe,Ze]=(0,R.useState)(!1),[Qe,$e]=(0,R.useState)(``),et=(0,R.useCallback)(async e=>{if(K){Ze(!0),Ye(null),$e(e);try{qe(await x.post(`/api/db/connections/${K.id}/query`,{sql:e}))}catch(e){Ye(e.message),qe(null)}finally{Ze(!1)}}},[K]),tt=(0,R.useCallback)(()=>{!K||!Qe||Ge({type:`database`,title:`${K.name} · Query`,projectId:null,closable:!0,metadata:{connectionId:K.id,connectionName:K.name,dbType:K.type,initialSql:Qe}})},[K,Ge,Qe]),nt=(0,R.useCallback)(()=>{if(!b.current||!K)return;let e=b.current,t=e.getSelection();et(t&&!t.isEmpty()?e.getModel()?.getValueInRange(t)??e.getValue():e.getValue())},[K,et]),rt=typeof window<`u`&&`ontouchstart`in window,it=(0,R.useRef)(null),[at,ot]=(0,R.useState)(null);(0,R.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,R.useRef)([]),st=(0,R.useRef)(et);st.current=et,(0,R.useEffect)(()=>()=>{Q.current.forEach(e=>e.dispose()),Q.current=[]},[]),(0,R.useEffect)(()=>{he&&t&&w(t,{type:`sqlite`})},[he,t,w]);let $=n?/^(\/|[A-Za-z]:[/\\])/.test(n):!1;(0,R.useEffect)(()=>{if(a!=null){f(!1);return}if(D){c(O??``),y.current=O??``,f(!1),O&&_(!0);return}if(!n||!$&&!r)return;if(M||N||P||F||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,$,D]);let ct=(0,R.useRef)(h);ct.current=h,(0,R.useEffect)(()=>{if(!n||!r||a!=null||D)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,D]),(0,R.useEffect)(()=>{if(!A||a!=null)return;let t=D?`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,R.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),D?v.current=setTimeout(()=>{t&&w(t,{metadata:{...e,unsavedContent:y.current}})},2e3):v.current=setTimeout(()=>lt(y.current),1e3)}let dt=(0,R.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),fe(!1)}catch{}},[t]),ft=e?.lineNumber,pt=(0,R.useCallback)((e,t)=>{if(b.current=e,W.current=t,ft&&ft>0&&setTimeout(()=>{e.revealLineInCenter(ft),e.setPosition({lineNumber:ft,column:1}),e.focus()},100),D&&e.addCommand(t.KeyMod.CtrlCmd|t.KeyCode.KeyS,()=>fe(!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}),Z&&(G.current?.dispose(),G.current=t.languages.registerCompletionItemProvider(`sql`,g(t,Z))),L){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(`
|
|
6
|
-
`),a=-1,o=[],s=!1,c=/^(BEGIN|COMMIT|ROLLBACK|END)(;|\s|$)/i,l=-1,u=[],d=(e,n,i=`▷ Run`)=>{let a=n.trim();!a||a.startsWith(`--`)||t.push({range:{startLineNumber:e,startColumn:1,endLineNumber:e,endColumn:1},command:{id:r,title:i,arguments:[a]}})};for(let e=0;e<i.length;e++){let t=i[e].trim();if(a===-1){if(!t||t.startsWith(`--`))continue;a=e+1,o=[]}if(o.push(i[e]),(t.match(/\$\$/g)||[]).length%2==1&&(s=!s),!s&&t.endsWith(`;`)){let e=o.join(`
|
|
7
|
-
`).trim(),t=/^BEGIN(;|\s|$)/i.test(e),n=/^(COMMIT|ROLLBACK|END)(;|\s|$)/i.test(e);l===-1&&t?(l=a,u=[e]):l>-1?(u.push(e),!n&&!c.test(e)&&d(a,e),n&&(d(l,u.join(`
|
|
8
|
-
`),`▷ Run Transaction`),l=-1,u=[])):d(a,e),a=-1,o=[]}}return l>-1&&u.length>1&&d(l,u.join(`
|
|
9
|
-
`),`▷ Run Transaction`),a>0&&o.join(``).trim()&&d(a,o.join(`
|
|
10
|
-
`)),{lenses:t,dispose:()=>{}}}});Q.current.push(e)}}},[Z]);if(!a&&!D&&(!n||!$&&!r))return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-text-secondary text-sm`,children:`No file selected.`});if(d)return(0,z.jsxs)(`div`,{className:`flex items-center justify-center h-full gap-2 text-text-secondary`,children:[(0,z.jsx)(k,{className:`size-5 animate-spin`}),(0,z.jsx)(`span`,{className:`text-sm`,children:`Loading file...`})]});if(p)return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full text-error text-sm`,children:p});if(M)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(je,{filePath:n,projectName:r})});if(N)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Me,{filePath:n,projectName:r})});if(P)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Fe,{filePath:n,projectName:r})});if(F)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Ne,{filePath:n,projectName:r})});if(me)return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(X,{}),children:(0,z.jsx)(Pe,{filePath:n,projectName:r})});if(l===`base64`)return(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-text-secondary`,children:[(0,z.jsx)(ee,{className:`size-10 text-text-subtle`}),(0,z.jsx)(`p`,{className:`text-sm`,children:`This file is a binary format and cannot be displayed.`}),(0,z.jsx)(`p`,{className:`text-xs text-text-subtle`,children:n})]});let mt=L?(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 border-l border-border`,children:[(0,z.jsx)(i,{className:`size-3 text-muted-foreground`}),(0,z.jsxs)(`select`,{value:H??``,onChange:e=>{let t=Number(e.target.value);t&&Y(t)},className:`h-5 text-[10px] bg-transparent border border-border rounded px-1 text-foreground outline-none max-w-[140px]`,title:`Select connection for autocomplete`,children:[(0,z.jsx)(`option`,{value:``,children:`Connection…`}),B.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,z.jsx)(`button`,{type:`button`,onClick:nt,disabled:!K,className:`p-0.5 rounded text-muted-foreground hover:text-primary disabled:opacity-30 transition-colors`,title:`Run SQL`,children:(0,z.jsx)(ce,{className:`size-3.5`})}),K&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>Te(K.id,{readonly:K.readonly?0:1}),className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[10px] transition-colors ${K.readonly?`text-muted-foreground hover:text-foreground`:`bg-destructive/15 text-destructive`}`,title:K.readonly?`Readonly — click to allow writes`:`WRITE mode — click to enable readonly`,children:K.readonly?(0,z.jsx)(ne,{className:`size-3`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(re,{className:`size-3`}),(0,z.jsx)(`span`,{className:`font-medium`,children:`WRITE`})]})})]}):null;return(0,z.jsxs)(`div`,{ref:it,className:`flex flex-col h-full w-full overflow-hidden`,style:at?{height:`${at}px`,maxHeight:`${at}px`}:void 0,children:[a!=null&&Oe&&(0,z.jsx)(`div`,{className:`flex items-center h-7 border-b border-border bg-background shrink-0 px-2 gap-2`,children:(0,z.jsx)(`button`,{type:`button`,onClick:He,className:`text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted transition-colors text-foreground`,children:q?`Raw`:`Beautify`})}),n&&r&&t&&(0,z.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0`,children:[(0,z.jsx)(we,{filePath:n,projectName:r,tabId:t,className:`flex items-center flex-1 min-w-0 overflow-x-auto scrollbar-none px-2 gap-0.5`}),mt,(0,z.jsx)(Ee,{ext:j,mdMode:_e,onMdModeChange:ve,csvMode:xe,onCsvModeChange:Se,wordWrap:T,onToggleWordWrap:E,filePath:n,projectName:r,className:`shrink-0 flex items-center gap-1 px-2`})]}),L&&(!r||!t)&&(0,z.jsxs)(`div`,{className:`hidden md:flex items-center h-7 border-b border-border bg-background shrink-0 px-2`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1`,children:n?C(n):`SQL`}),mt]}),I&&xe===`table`?(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})}),children:(0,z.jsx)(Ae,{content:s??``,onContentChange:ut,wordWrap:T})}):ge&&_e===`preview`?(0,z.jsx)(We,{content:s??``}):(0,z.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0`,children:(0,z.jsx)(ye,{height:`100%`,language:o??Ve(n??``),value:s??``,onChange:a==null?ut:void 0,onMount:pt,theme:ue,options:{fontSize:13,fontFamily:`Menlo, Monaco, Consolas, monospace`,wordWrap:T?`on`:`off`,minimap:{enabled:!1},scrollBeyondLastLine:!1,automaticLayout:!0,lineNumbers:`on`,folding:!0,bracketPairColorization:{enabled:!0},readOnly:a!=null},loading:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})})}),L&&(Ke||Je||Xe)&&(0,z.jsx)(Ue,{result:Ke,error:Je,loading:Xe,connName:K?.name,onClose:()=>{qe(null),Ye(null),Ze(!1)},onOpenInTab:tt}),rt&&(0,z.jsx)(ke,{editorRef:b,readOnly:a!=null}),de&&(0,z.jsx)(De,{open:de,defaultName:`Untitled-${e?.untitledNumber??1}`,content:y.current,onSave:dt,onCancel:()=>fe(!1)})]})}),Y=()=>{};function Ue({result:e,error:t,loading:n,connName:r,onClose:a,onOpenInTab:o}){let s=(0,R.useMemo)(()=>e?.changeType===`select`&&e.rows.length>0?{columns:e.columns,rows:e.rows,total:e.rows.length,limit:e.rows.length}:null,[e]),c=(0,R.useMemo)(()=>(e?.columns??[]).map(e=>({name:e,type:`text`,nullable:!0,pk:!1,defaultValue:null})),[e?.columns]),[l,u]=(0,R.useState)(250),d=(0,R.useCallback)(e=>{e.preventDefault();let t=e.clientY,n=l,r=e=>u(Math.max(80,n+(t-e.clientY))),i=()=>{document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},[l]);return(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border flex flex-col`,style:{height:l},children:[(0,z.jsx)(`div`,{onMouseDown:d,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,z.jsx)(L,{className:`size-3 text-muted-foreground/50`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 bg-muted/50 border-b border-border shrink-0`,children:[(0,z.jsx)(i,{className:`size-3 text-muted-foreground`}),(0,z.jsxs)(`span`,{className:`text-xs font-medium text-foreground truncate flex-1`,children:[r?`${r} · Results`:`Query Results`,e?.executionTimeMs!=null&&(0,z.jsxs)(`span`,{className:`text-muted-foreground ml-1.5 font-normal`,children:[e.executionTimeMs,`ms`]})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:o,title:`Open in DB Viewer tab`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,children:[(0,z.jsx)(N,{className:`size-3`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Open in Tab`})]}),(0,z.jsx)(`button`,{type:`button`,onClick:a,title:`Close results`,className:`p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(b,{className:`size-3`})})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-hidden min-h-0`,children:[n&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-4 animate-spin text-muted-foreground`})}),t&&(0,z.jsx)(`div`,{className:`px-3 py-2 text-xs text-destructive bg-destructive/5`,children:t}),e?.changeType===`modify`&&(0,z.jsxs)(`div`,{className:`px-3 py-2 text-xs text-green-500`,children:[e.rowsAffected,` row(s) affected`]}),s&&(0,z.jsx)(_,{columns:s.columns,rows:s.rows,total:s.total,limit:s.limit,schema:c,loading:!1,page:1,onPageChange:Y,onCellUpdate:Y,orderBy:null,orderDir:`ASC`,onToggleSort:Y,connectionName:r}),e?.changeType===`select`&&e.rows.length===0&&(0,z.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`No results`})]})]})}function X(){return(0,z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,z.jsx)(k,{className:`size-5 animate-spin text-text-subtle`})})}function We({content:e}){return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded m-4`}),children:(0,z.jsx)(J,{content:e,className:`flex-1 overflow-auto p-4`})})}export{He as CodeEditor};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./vendor-markdown-0Mxgxy0L.js";import"./api-client-DG9qwosT.js";import{D as e}from"./index-xoq3_MQL.js";export{e as useKeybindingsStore};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./vendor-markdown-0Mxgxy0L.js";import"./api-client-DG9qwosT.js";import{P as e}from"./index-xoq3_MQL.js";export{e as useNotificationStore};
|