@vincenthanxiaodu/pi-web 1.202608.63 → 1.202608.64
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/dist/client/assets/{CodeViewer-CTOcX8zb.js → CodeViewer-DU68bqY-.js} +2 -2
- package/dist/client/assets/{TerminalPanel-Ct37Z_rb.js → TerminalPanel-CB_TYCEU.js} +43 -43
- package/dist/client/assets/{index-DWGvlk0o.js → index-cMhKKTsH.js} +298 -269
- package/dist/client/index.html +1 -1
- package/dist/server/sessions/piSessionService.js +5 -0
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/readableMessageCount.js +24 -4
- package/dist/server/sessions/readableMessageCount.js.map +1 -1
- package/dist/server/sessions/subagentRuns.js +156 -11
- package/dist/server/sessions/subagentRuns.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{P as e,S as t,X as n,Y as r,et as i,l as a,q as o,y as s}from"./vendor-editor-core-CXO8gGab.js";import{c,i as l,l as u,n as d,r as f,s as p,t as m,u as h}from"./vendor-editor-languages-CpW4sJsX.js";import{_ as g,f as _,
|
|
1
|
+
import{P as e,S as t,X as n,Y as r,et as i,l as a,q as o,y as s}from"./vendor-editor-core-CXO8gGab.js";import{c,i as l,l as u,n as d,r as f,s as p,t as m,u as h}from"./vendor-editor-languages-CpW4sJsX.js";import{_ as g,f as _,h as v,n as y,p as b,u as x,v as S}from"./index-cMhKKTsH.js";import{t as C}from"./vendor-editor-legacy-CYBnW6ZU.js";var w=class extends v{constructor(...e){super(...e),this.content=``}firstUpdated(){this.recreateEditor()}updated(e){(e.has(`content`)||e.has(`language`))&&this.recreateEditor()}disconnectedCallback(){this.view?.destroy(),this.view=void 0,super.disconnectedCallback()}render(){return g`<div class="host"></div>`}recreateEditor(){this.editorHost&&(this.view?.destroy(),this.view=new o({parent:this.editorHost,state:i.create({doc:this.content,extensions:[n(),r.of(a),e(t,{fallback:!0}),i.readOnly.of(!0),o.editable.of(!1),o.lineWrapping,T,...D(this.language),...O(this.language)]})}))}static{this.styles=S`
|
|
2
2
|
:host { display: block; min-height: 0; height: 100%; }
|
|
3
3
|
.host { height: 100%; min-height: 0; overflow: auto; }
|
|
4
|
-
`}};
|
|
4
|
+
`}};y([_()],w.prototype,`content`,void 0),y([_()],w.prototype,`language`,void 0),y([x(`.host`)],w.prototype,`editorHost`,void 0),w=y([b(`code-viewer`)],w);var T=o.theme({"&":{height:`100%`,color:`var(--pi-text)`,backgroundColor:`var(--pi-bg)`,fontSize:`12px`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,lineHeight:`1.45`},".cm-gutters":{backgroundColor:`var(--pi-bg)`,color:`var(--pi-dim)`,borderRight:`1px solid var(--pi-border-muted)`},".cm-activeLineGutter":{backgroundColor:`transparent`},".cm-activeLine":{backgroundColor:`transparent`},".cm-content":{caretColor:`transparent`},"&.cm-focused":{outline:`none`}}),E=o.theme({".cm-content":{textAlign:`start`},".cm-line":{unicodeBidi:`plaintext`}});function D(e){return e===`markdown`?[o.contentAttributes.of({dir:`auto`}),E]:[]}function O(e){if(e===void 0)return[];switch(e){case`typescript`:return[u({typescript:!0})];case`javascript`:return[u()];case`json`:return[l()];case`markdown`:return[p()];case`css`:return[h()];case`html`:return[c()];case`python`:return[f()];case`rust`:return[d()];case`go`:return[m()];case`diff`:return[s.define(C)];default:return[]}}export{w as CodeViewer};
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as
|
|
2
|
-
`),lines:p,physicalLineCount:f.length,viewportLine:Math.min(d,Math.max(0,e.viewportY))}}function
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _}from"./index-cMhKKTsH.js";import{n as v,t as y}from"./vendor-terminal-D8k4UKM2.js";var ee=`important`,te=` !important`,ne=p(class extends s{constructor(e){if(super(e),e.type!==t.ATTRIBUTE||e.name!==`style`||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return r==null?t:t+`${n=n.includes(`-`)?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,`-$&`).toLowerCase()}:${r};`},``)}update(e,[t]){let{style:n}=e.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let e of this.ft)t[e]??(this.ft.delete(e),e.includes(`-`)?n.removeProperty(e):n[e]=null);for(let e in t){let r=t[e];if(r!=null){this.ft.add(e);let t=typeof r==`string`&&r.endsWith(te);e.includes(`-`)||t?n.setProperty(e,t?r.slice(0,-11):r,t?ee:``):n[e]=r}}return a}}),re=`#ffffff`,ie=`#000000`,b=[`#2e3436`,`#cc0000`,`#4e9a06`,`#c4a000`,`#3465a4`,`#75507b`,`#06989a`,`#d3d7cf`,`#555753`,`#ef2929`,`#8ae234`,`#fce94f`,`#729fcf`,`#ad7fa8`,`#34e2e2`,`#eeeeec`],x=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],S={black:b[0],red:b[1],green:b[2],yellow:b[3],blue:b[4],magenta:b[5],cyan:b[6],white:b[7],brightBlack:b[8],brightRed:b[9],brightGreen:b[10],brightYellow:b[11],brightBlue:b[12],brightMagenta:b[13],brightCyan:b[14],brightWhite:b[15]};function C(e,t,n={}){let r=Math.max(0,Math.floor(t));if(e.length<=0||r===0)return{text:``,lines:[],physicalLineCount:0,viewportLine:0};let i=le(n.theme),a=n.theme?.foreground??re,o=n.theme?.background??ie,s=[],c=e.getNullCell(),l=-1;for(let t=0;t<e.length;t+=1){let u=e.getLine(t);if(u===void 0){s.push({text:``,runs:[],wrapped:!1});continue}let d=w(u,r,c,{palette:i,foreground:a,background:o,drawBoldTextInBrightColors:n.drawBoldTextInBrightColors!==!1});s.push(d),(d.text!==``||d.runs.some(e=>e.style.background!==o))&&(l=t)}let u=Math.min(e.length-1,Math.max(0,e.baseY+e.cursorY)),d=Math.max(l,u),f=s.slice(0,d+1),p=[];for(let e of f){let t=p.at(-1);if(e.wrapped&&t!==void 0){t.text+=e.text,se(t.runs,e.runs);continue}p.push({text:e.text,runs:e.runs.map(e=>({text:e.text,style:e.style}))})}return{text:p.map(e=>e.text).join(`
|
|
2
|
+
`),lines:p,physicalLineCount:f.length,viewportLine:Math.min(d,Math.max(0,e.viewportY))}}function w(e,t,n,r){let i=[],a=Math.min(t,e.length);for(let t=0;t<a;t+=1){let a=e.getCell(t,n);if(a===void 0){i.push({text:` `,meaningful:!1,style:oe(r)});continue}let o=a.getWidth();if(o===0)continue;let s=a.getChars();i.push({text:s===``?` `.repeat(Math.max(1,o)):s,meaningful:s!==``||!a.isAttributeDefault(),style:ae(a,r)})}let o=i.length-1;for(;o>=0&&i[o]?.meaningful!==!0;)--o;let s=[],c=``;for(let e=0;e<=o;e+=1){let t=i[e];t!==void 0&&(c+=t.text,E(s,{text:t.text,style:t.style}))}return{text:c,runs:s,wrapped:e.isWrapped}}function ae(e,t){let n=e.isInverse()!==0,r=T(e,`foreground`,t),i=T(e,`background`,t);if(n&&([r,i]=[i,r]),e.isBold()!==0&&t.drawBoldTextInBrightColors){let i=n?e.isBgPalette()?e.getBgColor():void 0:e.isFgPalette()?e.getFgColor():void 0;i!==void 0&&i>=0&&i<8&&(r=t.palette[i+8]??r)}return{foreground:r,background:i,bold:e.isBold()!==0,italic:e.isItalic()!==0,dim:e.isDim()!==0,underline:e.isUnderline()!==0,invisible:e.isInvisible()!==0,strikethrough:e.isStrikethrough()!==0,overline:e.isOverline()!==0}}function T(e,t,n){let r=t===`foreground`?e.isFgRGB():e.isBgRGB(),i=t===`foreground`?e.isFgPalette():e.isBgPalette(),a=t===`foreground`?e.getFgColor():e.getBgColor();return r?ue(a):i?n.palette[a]??(t===`foreground`?n.foreground:n.background):t===`foreground`?n.foreground:n.background}function oe(e){return{foreground:e.foreground,background:e.background,bold:!1,italic:!1,dim:!1,underline:!1,invisible:!1,strikethrough:!1,overline:!1}}function se(e,t){for(let n of t)E(e,n)}function E(e,t){if(t.text===``)return;let n=e.at(-1);if(n!==void 0&&ce(n.style,t.style)){n.text+=t.text;return}e.push({text:t.text,style:t.style})}function ce(e,t){return e.foreground===t.foreground&&e.background===t.background&&e.bold===t.bold&&e.italic===t.italic&&e.dim===t.dim&&e.underline===t.underline&&e.invisible===t.invisible&&e.strikethrough===t.strikethrough&&e.overline===t.overline}function le(e){let t=[...b];for(let n=0;n<x.length;n+=1){let r=x[n];if(r===void 0)continue;let i=e?.[r];typeof i==`string`&&(t[n]=i)}let n=[0,95,135,175,215,255];for(let e=0;e<216;e+=1){let r=n[Math.floor(e/36)%6]??0,i=n[Math.floor(e/6)%6]??0,a=n[e%6]??0;t.push(D(r,i,a))}for(let e=0;e<24;e+=1){let n=8+e*10;t.push(D(n,n,n))}for(let n=0;n<Math.min(e?.extendedAnsi?.length??0,240);n+=1){let r=e?.extendedAnsi?.[n];r!==void 0&&(t[n+16]=r)}return t}function ue(e){return`#${(e&16777215).toString(16).padStart(6,`0`)}`}function D(e,t,n){return`#${e.toString(16).padStart(2,`0`)}${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}`}var O=`pi-web.terminal.softKeys`,de=`(pointer: coarse), (max-width: 760px)`;function fe(e,t){return e??t}function pe(e){if(e===`true`)return!0;if(e===`false`)return!1}function k(){return typeof window<`u`&&`matchMedia`in window?window.matchMedia(de):void 0}function A(e){return e?.matches===!0}function j(e=k()){return fe(N(),A(e))}function M(){return N()!==void 0}function N(e=F()){if(e!==void 0)try{return pe(e.getItem(O))}catch{return}}function P(e,t=F()){if(t!==void 0)try{t.setItem(O,String(e))}catch{}}function F(){if(!(typeof window>`u`))try{return window.localStorage}catch{return}}var I=[{id:`escape`,label:`Esc`,ariaLabel:`Escape`,title:`Send Escape`},{id:`tab`,label:`Tab`,ariaLabel:`Tab`,title:`Send Tab`},{id:`ctrl-c`,label:`Ctrl+C`,ariaLabel:`Control C`,title:`Interrupt the foreground process`},{id:`ctrl-d`,label:`Ctrl+D`,ariaLabel:`Control D`,title:`Send EOF / close input`},{id:`ctrl-z`,label:`Ctrl+Z`,ariaLabel:`Control Z`,title:`Suspend the foreground process`},{id:`ctrl-l`,label:`Ctrl+L`,ariaLabel:`Control L`,title:`Clear / redraw the terminal`},{id:`ctrl-r`,label:`Ctrl+R`,ariaLabel:`Control R`,title:`Reverse search history`},{id:`ctrl-u`,label:`Ctrl+U`,ariaLabel:`Control U`,title:`Delete to the start of the line`},{id:`ctrl-w`,label:`Ctrl+W`,ariaLabel:`Control W`,title:`Delete the previous word`},{id:`arrow-left`,label:`←`,ariaLabel:`Left arrow`,title:`Move left`},{id:`arrow-up`,label:`↑`,ariaLabel:`Up arrow`,title:`Move up / previous command`},{id:`arrow-down`,label:`↓`,ariaLabel:`Down arrow`,title:`Move down / next command`},{id:`arrow-right`,label:`→`,ariaLabel:`Right arrow`,title:`Move right`},{id:`home`,label:`Home`,ariaLabel:`Home`,title:`Move to the start`},{id:`end`,label:`End`,ariaLabel:`End`,title:`Move to the end`},{id:`page-up`,label:`PgUp`,ariaLabel:`Page up`,title:`Page up`},{id:`page-down`,label:`PgDn`,ariaLabel:`Page down`,title:`Page down`},{id:`delete`,label:`Del`,ariaLabel:`Delete`,title:`Delete forward`},{id:`backspace`,label:`⌫`,ariaLabel:`Backspace`,title:`Backspace`},{id:`meta-backward-word`,label:`M-B`,ariaLabel:`Meta B`,title:`Move backward one word`},{id:`meta-forward-word`,label:`M-F`,ariaLabel:`Meta F`,title:`Move forward one word`}],L=`\x1B`,R=``;function z(e,t){switch(e){case`escape`:return L;case`tab`:return` `;case`ctrl-c`:return B(`c`);case`ctrl-d`:return B(`d`);case`ctrl-z`:return B(`z`);case`ctrl-l`:return B(`l`);case`ctrl-r`:return B(`r`);case`ctrl-u`:return B(`u`);case`ctrl-w`:return B(`w`);case`arrow-left`:return V(`D`,t);case`arrow-up`:return V(`A`,t);case`arrow-down`:return V(`B`,t);case`arrow-right`:return V(`C`,t);case`home`:return H(`H`,t);case`end`:return H(`F`,t);case`page-up`:return`${L}[5~`;case`page-down`:return`${L}[6~`;case`delete`:return`${L}[3~`;case`backspace`:return R;case`meta-backward-word`:return`${L}b`;case`meta-forward-word`:return`${L}f`}}function B(e){return String.fromCharCode(e.toUpperCase().charCodeAt(0)-64)}function V(e,t){return t?.applicationCursorKeysMode===!0?`${L}O${e}`:`${L}[${e}`}function H(e,t){return t?.applicationCursorKeysMode===!0?`${L}O${e}`:`${L}[${e}`}var me=8,he=500,U=class extends o{constructor(...e){super(...e),this.refocusOnClick=!0,this.onInput=()=>void 0,this.lastPointerFinishedAt=0}sendSoftKey(e,t){this.onInput(z(e.id,this.modes),t)}onSoftKeyPointerDown(e,t){e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),this.pointerStart={pointerId:e.pointerId,key:t,clientX:e.clientX,clientY:e.clientY})}onSoftKeyPointerMove(e){let t=this.pointerStart;t?.pointerId===e.pointerId&&W(t,e)&&this.finishSoftKeyPointer()}onSoftKeyPointerUp(e,t){let n=this.pointerStart;n?.pointerId===e.pointerId&&(e.preventDefault(),this.finishSoftKeyPointer(),!(n.key.id!==t.id||W(n,e))&&this.sendSoftKey(t,{refocus:e.pointerType===`mouse`}))}onSoftKeyPointerCancel(e){this.pointerStart?.pointerId===e.pointerId&&this.finishSoftKeyPointer()}finishSoftKeyPointer(){this.pointerStart=void 0,this.lastPointerFinishedAt=Date.now()}onSoftKeyClick(e,t){if(Date.now()-this.lastPointerFinishedAt<he){e.preventDefault();return}this.sendSoftKey(t,{refocus:this.refocusOnClick})}render(){return e`
|
|
3
3
|
<div class="terminal-soft-keys" role="toolbar" aria-label="Terminal soft keys">
|
|
4
|
-
${I.map(e
|
|
4
|
+
${I.map(t=>e`
|
|
5
5
|
<button
|
|
6
6
|
type="button"
|
|
7
7
|
class="soft-key"
|
|
8
|
-
title=${
|
|
9
|
-
aria-label=${
|
|
10
|
-
@pointerdown=${
|
|
8
|
+
title=${t.title}
|
|
9
|
+
aria-label=${t.ariaLabel}
|
|
10
|
+
@pointerdown=${e=>{this.onSoftKeyPointerDown(e,t)}}
|
|
11
11
|
@pointermove=${e=>{this.onSoftKeyPointerMove(e)}}
|
|
12
|
-
@pointerup=${
|
|
12
|
+
@pointerup=${e=>{this.onSoftKeyPointerUp(e,t)}}
|
|
13
13
|
@pointercancel=${e=>{this.onSoftKeyPointerCancel(e)}}
|
|
14
|
-
@click=${
|
|
15
|
-
>${
|
|
14
|
+
@click=${e=>{this.onSoftKeyClick(e,t)}}
|
|
15
|
+
>${t.label}</button>
|
|
16
16
|
`)}
|
|
17
17
|
</div>
|
|
18
|
-
`}static{this.styles=
|
|
18
|
+
`}static{this.styles=_`
|
|
19
19
|
:host { flex: 0 0 auto; display: block; }
|
|
20
20
|
.terminal-soft-keys { display: flex; gap: 6px; align-items: center; padding: 6px; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; touch-action: pan-x; }
|
|
21
21
|
.terminal-soft-keys::-webkit-scrollbar { display: none; }
|
|
22
22
|
button { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; max-width: none; min-height: 34px; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 6px 9px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; touch-action: pan-x; -webkit-touch-callout: none; user-select: none; }
|
|
23
23
|
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
24
|
-
`}};u([i({attribute:!1})],U.prototype,`modes`,void 0),u([i({type:Boolean})],U.prototype,`refocusOnClick`,void 0),u([i({attribute:!1})],U.prototype,`onInput`,void 0),U=u([f(`terminal-soft-keys`)],U);function W(e,t){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)>pe}var he={cursorBlink:!0,convertEol:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:13},ge={cols:100,rows:30},_e=1e3,G=class extends l{constructor(...e){super(...e),this.machineId=`local`,this.autoStart=!1,this.onSelectTerminal=()=>void 0,this.terminals=[],this.commandRuns=[],this.loading=!1,this.visible=!1,this.cancellingRunIds=[],this.continuingTerminalIds=[],this.defaultSoftKeysEnvironment=!1,this.softKeysEnabled=j(),this.suppressTerminalInput=!1,this.softKeysDefaultEnvironmentMedia=k(),this.softKeysPreferenceStored=M(),this.onSoftKeysDefaultEnvironmentChange=()=>{this.syncDefaultSoftKeysEnvironment()}}connectedCallback(){super.connectedCallback(),this.syncDefaultSoftKeysEnvironment(),this.softKeysDefaultEnvironmentMedia?.addEventListener(`change`,this.onSoftKeysDefaultEnvironmentChange),this.themeObserver=new MutationObserver(()=>{this.applyTerminalTheme()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]})}firstUpdated(){this.intersectionObserver=new IntersectionObserver(e=>{this.visible=e[0]?.isIntersecting===!0}),this.intersectionObserver.observe(this)}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.themeObserver?.disconnect(),this.themeObserver=void 0,this.softKeysDefaultEnvironmentMedia?.removeEventListener(`change`,this.onSoftKeysDefaultEnvironmentChange),this.updateCommandRunPolling(!1),this.disposeTerminalView(),super.disconnectedCallback()}syncDefaultSoftKeysEnvironment(){let e=A(this.softKeysDefaultEnvironmentMedia),t=this.softKeysEnabled;this.defaultSoftKeysEnvironment=e,this.softKeysPreferenceStored||(this.softKeysEnabled=e),this.softKeysEnabled!==t&&this.scheduleFitAndNotify()}scheduleFitAndNotify(){this.updateComplete.then(()=>{this.fitAndNotify()})}willUpdate(e){let t=this.workspace===void 0?void 0:JSON.stringify([this.machineId,this.workspace.path]);if(t!==this.observedWorkspaceScope){this.observedWorkspaceScope=t,this.loadedCwd=void 0,this.autoStartConsumedCwd=void 0,this.terminals=[],this.commandRuns=[],this.selectedId=void 0,this.cancellingRunIds=[],this.continuingTerminalIds=[],this.updateCommandRunPolling(!1),this.disposeTerminalView();return}if(e.has(`selectedTerminalId`)){if(e.get(`selectedTerminalId`)!==void 0&&this.selectedTerminalId===void 0){this.loadedCwd=void 0,this.selectTerminalIdInView(void 0);return}this.applyRequestedTerminalSelection()}}updated(e){this.visible?this.hasPendingCommandRuns()&&this.updateCommandRunPolling(!0):this.updateCommandRunPolling(!1),this.loadVisibleWorkspaceTerminals(),e.has(`selectedTerminalId`)&&this.shouldReloadForRequestedTerminal()&&this.loadTerminals(),this.ensureTerminalView()}loadVisibleWorkspaceTerminals(){let e=this.workspace?.path;!this.visible||e===void 0||e===this.loadedCwd||(this.loadedCwd=e,this.loadTerminals())}async loadTerminals(){this.loading=!0,this.error=void 0;try{let e=this.workspace;if(e===void 0)return;let t=this.consumeAutoStart(),[n,r]=await Promise.all([c.terminals(e.projectId,e.id,this.machineId),c.listCommandRuns({projectId:e.projectId,workspaceId:e.id},this.machineId)]);this.terminals=n,this.commandRuns=r,this.selectPreferredLoadedTerminal({replaceUrl:!0}),this.updateCommandRunPolling(this.hasPendingCommandRuns(r)),n.length===0&&t&&await this.startTerminal()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.loading=!1}}applyRequestedTerminalSelection(){this.selectedTerminalId!==void 0&&!this.terminals.some(e=>e.id===this.selectedTerminalId)||this.selectPreferredLoadedTerminal({replaceUrl:!0})}consumeAutoStart(){let e=this.workspace?.path;return!this.autoStart||e===void 0||this.autoStartConsumedCwd===e?!1:(this.autoStartConsumedCwd=e,!0)}shouldReloadForRequestedTerminal(){let e=this.workspace?.path;return this.visible&&e!==void 0&&e===this.loadedCwd&&this.selectedTerminalId!==void 0&&!this.loading&&!this.terminals.some(e=>e.id===this.selectedTerminalId)}selectPreferredLoadedTerminal(e){let t=m(this.terminals,{targetTerminalId:this.selectedTerminalId});t===void 0&&this.selectedTerminalId!==void 0&&(t=d(this.terminals)),this.selectTerminalIdInView(t?.id),(t?.id!==this.selectedTerminalId||t===void 0&&this.selectedTerminalId!==void 0)&&this.onSelectTerminal(t?.id,{replace:e?.replaceUrl===!0})}selectTerminalIdInView(e){this.selectedId!==e&&(this.selectedId=e,this.disposeTerminalView())}async startTerminal(){if(this.workspace!==void 0){this.error=void 0;try{let e=this.measureTerminalSize()??ge,t=await c.startTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);this.terminals=[...this.terminals,t],this.selectTerminal(t.id)}catch(e){this.error=e instanceof Error?e.message:String(e)}}}async closeTerminal(e,t){t.stopPropagation();try{if(this.workspace===void 0)return;await c.closeTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);let t=this.terminals.filter(t=>t.id!==e);if(this.terminals=t,this.selectedId===e||this.selectedTerminalId===e){let e=d(t)?.id;this.selectTerminalIdInView(e),this.onSelectTerminal(e,{replace:!0})}}catch(e){this.error=e instanceof Error?e.message:String(e)}}selectTerminal(e){this.selectedId!==e&&this.selectTerminalIdInView(e),this.onSelectTerminal(e)}selectedTerminalInfo(){return this.terminals.find(e=>e.id===this.selectedId)}selectedCommandRun(){let e=this.selectedTerminalInfo()?.commandRunId;if(e!==void 0)return this.commandRuns.find(t=>t.id===e)}async loadCommandRuns(){let e=this.workspace;if(e!==void 0)try{let t=await c.listCommandRuns({projectId:e.projectId,workspaceId:e.id},this.machineId);this.commandRuns=t,this.cancellingRunIds=this.cancellingRunIds.filter(e=>t.some(t=>t.id===e&&J(t))),this.updateCommandRunPolling(this.hasPendingCommandRuns(t))}catch(e){this.error=e instanceof Error?e.message:String(e)}}updateCommandRunPolling(e){if(e&&this.commandRunPollTimer===void 0){this.commandRunPollTimer=window.setInterval(()=>{this.loadCommandRuns()},_e);return}!e&&this.commandRunPollTimer!==void 0&&(window.clearInterval(this.commandRunPollTimer),this.commandRunPollTimer=void 0)}hasPendingCommandRuns(e=this.commandRuns){return e.some(J)}async cancelCommandRun(e){if(!(!J(e)||this.cancellingRunIds.includes(e.id))){this.error=void 0,this.cancellingRunIds=[...this.cancellingRunIds,e.id];try{await c.cancelCommandRun(e.id,this.machineId),await this.loadCommandRuns()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.cancellingRunIds=this.cancellingRunIds.filter(t=>t!==e.id)}}}async continueTerminal(e){if(!(this.workspace===void 0||this.continuingTerminalIds.includes(e))){this.error=void 0,this.continuingTerminalIds=[...this.continuingTerminalIds,e];try{let t=await c.continueTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);this.terminals=this.terminals.map(n=>n.id===e?t:n),this.socket===void 0&&this.disposeTerminalView(),this.fitAndNotify(),this.terminal?.focus()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.continuingTerminalIds=this.continuingTerminalIds.filter(t=>t!==e)}}}ensureTerminalView(){let e=this.workspace,t=this.terminalHostElement();if(!this.visible||this.terminal!==void 0||this.selectedId===void 0||t===void 0||e===void 0)return;let n=new g(X(this)),r=new _;n.loadAddon(r),n.open(t),this.terminal=n,this.fitAddon=r,this.resizeObserver=new ResizeObserver(()=>{this.fitAndNotify()}),this.resizeObserver.observe(t),n.onData(e=>{this.suppressTerminalInput||this.copySnapshot!==void 0||this.sendTerminalInput(e)});let i=this.fitTerminal();this.connectSocket(e.projectId,e.id,this.selectedId,n,i),requestAnimationFrame(()=>{this.fitAndNotify()}),n.focus()}connectSocket(e,t,r,i,a){let o=n(e,t,r,a,this.machineId);o.binaryType=`arraybuffer`,this.socket=o,o.addEventListener(`open`,()=>{this.fitAndNotify()}),o.addEventListener(`message`,e=>{this.handleSocketMessage(e.data,r,i)}),o.addEventListener(`close`,()=>{this.socket===o&&(this.socket=void 0)})}async handleSocketMessage(e,t,n){try{let r=be(await xe(e));r.type===`output`&&this.writeTerminalOutput(n,r.data,r.replay===!0),r.type===`exit`&&(n.writeln(`\r\n[process exited${r.exitCode===void 0?``:` with code ${String(r.exitCode)}`}]`),this.terminals=this.terminals.map(e=>e.id===t?{...e,exited:!0,...r.exitCode===void 0?{}:{exitCode:r.exitCode}}:e),this.loadCommandRuns()),r.type===`error`&&n.writeln(`\r\n[terminal error: ${r.message}]`)}catch(e){n.writeln(`\r\n[terminal error: ${e instanceof Error?e.message:String(e)}]`)}}writeTerminalOutput(e,t,n){if(!n){e.write(t);return}this.suppressTerminalInput=!0,e.write(t,()=>{this.suppressTerminalInput=!1})}fitAndNotify(){let e=this.fitTerminal();e!==void 0&&this.send({type:`resize`,...e})}fitTerminal(){if(this.fitAddon===void 0||this.terminal===void 0)return;let e=$(this.fitAddon.proposeDimensions());if(e!==void 0)return this.fitAddon.fit(),e}measureTerminalSize(){let e=this.fitTerminal();if(e!==void 0)return e;let t=this.terminalHostElement();if(this.terminal!==void 0||t===void 0)return;let n=new g(X(this)),r=new _;n.loadAddon(r),n.open(t);let i=$(r.proposeDimensions());return n.dispose(),i}terminalHostElement(){let e=this.terminalHost;return e instanceof HTMLDivElement?e:void 0}applyTerminalTheme(){this.terminal!==void 0&&(this.terminal.options.theme=Z(this))}sendTerminalInput(e){let t=Y(e);t!==``&&this.send({type:`input`,data:t})}sendSoftKeyInput(e,t){this.copySnapshot===void 0&&(this.sendTerminalInput(e),t.refocus&&this.focusTerminal())}focusTerminal(){let e=this.terminal;e!==void 0&&(e.focus(),requestAnimationFrame(()=>{e.focus()}))}send(e){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))}disposeTerminalView(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.socket?.close(),this.socket=void 0,this.terminal?.dispose(),this.terminal=void 0,this.fitAddon=void 0,this.copySnapshot=void 0,this.copyStatus=void 0}renderCommandRunNotice(){let e=this.selectedCommandRun();if(e===void 0)return null;let t=this.selectedTerminalInfo();if(J(e)){let t=this.cancellingRunIds.includes(e.id);return a`
|
|
24
|
+
`}};u([i({attribute:!1})],U.prototype,`modes`,void 0),u([i({type:Boolean})],U.prototype,`refocusOnClick`,void 0),u([i({attribute:!1})],U.prototype,`onInput`,void 0),U=u([f(`terminal-soft-keys`)],U);function W(e,t){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)>me}var ge={cursorBlink:!0,convertEol:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:13},_e={cols:100,rows:30},ve=1e3,G=class extends o{constructor(...e){super(...e),this.machineId=`local`,this.autoStart=!1,this.onSelectTerminal=()=>void 0,this.terminals=[],this.commandRuns=[],this.loading=!1,this.visible=!1,this.cancellingRunIds=[],this.continuingTerminalIds=[],this.defaultSoftKeysEnvironment=!1,this.softKeysEnabled=j(),this.suppressTerminalInput=!1,this.softKeysDefaultEnvironmentMedia=k(),this.softKeysPreferenceStored=M(),this.onSoftKeysDefaultEnvironmentChange=()=>{this.syncDefaultSoftKeysEnvironment()}}connectedCallback(){super.connectedCallback(),this.syncDefaultSoftKeysEnvironment(),this.softKeysDefaultEnvironmentMedia?.addEventListener(`change`,this.onSoftKeysDefaultEnvironmentChange),this.themeObserver=new MutationObserver(()=>{this.applyTerminalTheme()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]})}firstUpdated(){this.intersectionObserver=new IntersectionObserver(e=>{this.visible=e[0]?.isIntersecting===!0}),this.intersectionObserver.observe(this)}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.themeObserver?.disconnect(),this.themeObserver=void 0,this.softKeysDefaultEnvironmentMedia?.removeEventListener(`change`,this.onSoftKeysDefaultEnvironmentChange),this.updateCommandRunPolling(!1),this.disposeTerminalView(),super.disconnectedCallback()}syncDefaultSoftKeysEnvironment(){let e=A(this.softKeysDefaultEnvironmentMedia),t=this.softKeysEnabled;this.defaultSoftKeysEnvironment=e,this.softKeysPreferenceStored||(this.softKeysEnabled=e),this.softKeysEnabled!==t&&this.scheduleFitAndNotify()}scheduleFitAndNotify(){this.updateComplete.then(()=>{this.fitAndNotify()})}willUpdate(e){let t=this.workspace===void 0?void 0:JSON.stringify([this.machineId,this.workspace.path]);if(t!==this.observedWorkspaceScope){this.observedWorkspaceScope=t,this.loadedCwd=void 0,this.autoStartConsumedCwd=void 0,this.terminals=[],this.commandRuns=[],this.selectedId=void 0,this.cancellingRunIds=[],this.continuingTerminalIds=[],this.updateCommandRunPolling(!1),this.disposeTerminalView();return}if(e.has(`selectedTerminalId`)){if(e.get(`selectedTerminalId`)!==void 0&&this.selectedTerminalId===void 0){this.loadedCwd=void 0,this.selectTerminalIdInView(void 0);return}this.applyRequestedTerminalSelection()}}updated(e){this.visible?this.hasPendingCommandRuns()&&this.updateCommandRunPolling(!0):this.updateCommandRunPolling(!1),this.loadVisibleWorkspaceTerminals(),e.has(`selectedTerminalId`)&&this.shouldReloadForRequestedTerminal()&&this.loadTerminals(),this.ensureTerminalView()}loadVisibleWorkspaceTerminals(){let e=this.workspace?.path;!this.visible||e===void 0||e===this.loadedCwd||(this.loadedCwd=e,this.loadTerminals())}async loadTerminals(){this.loading=!0,this.error=void 0;try{let e=this.workspace;if(e===void 0)return;let t=this.consumeAutoStart(),[n,r]=await Promise.all([c.terminals(e.projectId,e.id,this.machineId),c.listCommandRuns({projectId:e.projectId,workspaceId:e.id},this.machineId)]);this.terminals=n,this.commandRuns=r,this.selectPreferredLoadedTerminal({replaceUrl:!0}),this.updateCommandRunPolling(this.hasPendingCommandRuns(r)),n.length===0&&t&&await this.startTerminal()}catch(e){this.error=l(e)}finally{this.loading=!1}}applyRequestedTerminalSelection(){this.selectedTerminalId!==void 0&&!this.terminals.some(e=>e.id===this.selectedTerminalId)||this.selectPreferredLoadedTerminal({replaceUrl:!0})}consumeAutoStart(){let e=this.workspace?.path;return!this.autoStart||e===void 0||this.autoStartConsumedCwd===e?!1:(this.autoStartConsumedCwd=e,!0)}shouldReloadForRequestedTerminal(){let e=this.workspace?.path;return this.visible&&e!==void 0&&e===this.loadedCwd&&this.selectedTerminalId!==void 0&&!this.loading&&!this.terminals.some(e=>e.id===this.selectedTerminalId)}selectPreferredLoadedTerminal(e){let t=m(this.terminals,{targetTerminalId:this.selectedTerminalId});t===void 0&&this.selectedTerminalId!==void 0&&(t=d(this.terminals)),this.selectTerminalIdInView(t?.id),(t?.id!==this.selectedTerminalId||t===void 0&&this.selectedTerminalId!==void 0)&&this.onSelectTerminal(t?.id,{replace:e?.replaceUrl===!0})}selectTerminalIdInView(e){this.selectedId!==e&&(this.selectedId=e,this.disposeTerminalView())}async startTerminal(){if(this.workspace!==void 0){this.error=void 0;try{let e=this.measureTerminalSize()??_e,t=await c.startTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);this.terminals=[...this.terminals,t],this.selectTerminal(t.id)}catch(e){this.error=l(e)}}}async closeTerminal(e,t){t.stopPropagation();try{if(this.workspace===void 0)return;await c.closeTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);let t=this.terminals.filter(t=>t.id!==e);if(this.terminals=t,this.selectedId===e||this.selectedTerminalId===e){let e=d(t)?.id;this.selectTerminalIdInView(e),this.onSelectTerminal(e,{replace:!0})}}catch(e){this.error=l(e)}}selectTerminal(e){this.selectedId!==e&&this.selectTerminalIdInView(e),this.onSelectTerminal(e)}selectedTerminalInfo(){return this.terminals.find(e=>e.id===this.selectedId)}selectedCommandRun(){let e=this.selectedTerminalInfo()?.commandRunId;if(e!==void 0)return this.commandRuns.find(t=>t.id===e)}async loadCommandRuns(){let e=this.workspace;if(e!==void 0)try{let t=await c.listCommandRuns({projectId:e.projectId,workspaceId:e.id},this.machineId);this.commandRuns=t,this.cancellingRunIds=this.cancellingRunIds.filter(e=>t.some(t=>t.id===e&&J(t))),this.updateCommandRunPolling(this.hasPendingCommandRuns(t))}catch(e){this.error=l(e)}}updateCommandRunPolling(e){if(e&&this.commandRunPollTimer===void 0){this.commandRunPollTimer=window.setInterval(()=>{this.loadCommandRuns()},ve);return}!e&&this.commandRunPollTimer!==void 0&&(window.clearInterval(this.commandRunPollTimer),this.commandRunPollTimer=void 0)}hasPendingCommandRuns(e=this.commandRuns){return e.some(J)}async cancelCommandRun(e){if(!(!J(e)||this.cancellingRunIds.includes(e.id))){this.error=void 0,this.cancellingRunIds=[...this.cancellingRunIds,e.id];try{await c.cancelCommandRun(e.id,this.machineId),await this.loadCommandRuns()}catch(e){this.error=l(e)}finally{this.cancellingRunIds=this.cancellingRunIds.filter(t=>t!==e.id)}}}async continueTerminal(e){if(!(this.workspace===void 0||this.continuingTerminalIds.includes(e))){this.error=void 0,this.continuingTerminalIds=[...this.continuingTerminalIds,e];try{let t=await c.continueTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);this.terminals=this.terminals.map(n=>n.id===e?t:n),this.socket===void 0&&this.disposeTerminalView(),this.fitAndNotify(),this.terminal?.focus()}catch(e){this.error=l(e)}finally{this.continuingTerminalIds=this.continuingTerminalIds.filter(t=>t!==e)}}}ensureTerminalView(){let e=this.workspace,t=this.terminalHostElement();if(!this.visible||this.terminal!==void 0||this.selectedId===void 0||t===void 0||e===void 0)return;let n=new v(X(this)),r=new y;n.loadAddon(r),n.open(t),this.terminal=n,this.fitAddon=r,this.resizeObserver=new ResizeObserver(()=>{this.fitAndNotify()}),this.resizeObserver.observe(t),n.onData(e=>{this.suppressTerminalInput||this.copySnapshot!==void 0||this.sendTerminalInput(e)});let i=this.fitTerminal();this.connectSocket(e.projectId,e.id,this.selectedId,n,i),requestAnimationFrame(()=>{this.fitAndNotify()}),n.focus()}connectSocket(e,t,r,i,a){let o=n(e,t,r,a,this.machineId);o.binaryType=`arraybuffer`,this.socket=o,o.addEventListener(`open`,()=>{this.fitAndNotify()}),o.addEventListener(`message`,e=>{this.handleSocketMessage(e.data,r,i)}),o.addEventListener(`close`,()=>{this.socket===o&&(this.socket=void 0)})}async handleSocketMessage(e,t,n){try{let r=xe(await Se(e));r.type===`output`&&this.writeTerminalOutput(n,r.data,r.replay===!0),r.type===`exit`&&(n.writeln(`\r\n[process exited${r.exitCode===void 0?``:` with code ${String(r.exitCode)}`}]`),this.terminals=this.terminals.map(e=>e.id===t?{...e,exited:!0,...r.exitCode===void 0?{}:{exitCode:r.exitCode}}:e),this.loadCommandRuns()),r.type===`error`&&n.writeln(`\r\n[terminal error: ${r.message}]`)}catch(e){n.writeln(`\r\n[terminal error: ${l(e)}]`)}}writeTerminalOutput(e,t,n){if(!n){e.write(t);return}this.suppressTerminalInput=!0,e.write(t,()=>{this.suppressTerminalInput=!1})}fitAndNotify(){let e=this.fitTerminal();e!==void 0&&this.send({type:`resize`,...e})}fitTerminal(){if(this.fitAddon===void 0||this.terminal===void 0)return;let e=$(this.fitAddon.proposeDimensions());if(e!==void 0)return this.fitAddon.fit(),e}measureTerminalSize(){let e=this.fitTerminal();if(e!==void 0)return e;let t=this.terminalHostElement();if(this.terminal!==void 0||t===void 0)return;let n=new v(X(this)),r=new y;n.loadAddon(r),n.open(t);let i=$(r.proposeDimensions());return n.dispose(),i}terminalHostElement(){let e=this.terminalHost;return e instanceof HTMLDivElement?e:void 0}applyTerminalTheme(){this.terminal!==void 0&&(this.terminal.options.theme=Z(this))}sendTerminalInput(e){let t=Y(e);t!==``&&this.send({type:`input`,data:t})}sendSoftKeyInput(e,t){this.copySnapshot===void 0&&(this.sendTerminalInput(e),t.refocus&&this.focusTerminal())}focusTerminal(){let e=this.terminal;e!==void 0&&(e.focus(),requestAnimationFrame(()=>{e.focus()}))}send(e){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))}disposeTerminalView(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.socket?.close(),this.socket=void 0,this.terminal?.dispose(),this.terminal=void 0,this.fitAddon=void 0,this.copySnapshot=void 0,this.copyStatus=void 0}renderCommandRunNotice(){let t=this.selectedCommandRun();if(t===void 0)return null;let n=this.selectedTerminalInfo();if(J(t)){let n=this.cancellingRunIds.includes(t.id);return e`
|
|
25
25
|
<section class="command-run-notice running">
|
|
26
26
|
<div>
|
|
27
|
-
<strong>${
|
|
27
|
+
<strong>${t.title}</strong>
|
|
28
28
|
<p>Command is running. Press <kbd>Ctrl</kbd>+<kbd>C</kbd> or use the button to cancel.</p>
|
|
29
|
-
<code>${
|
|
29
|
+
<code>${t.command}</code>
|
|
30
30
|
</div>
|
|
31
|
-
<button class="danger" ?disabled=${
|
|
31
|
+
<button class="danger" ?disabled=${n} @click=${()=>{this.cancelCommandRun(t)}}>${n?`Cancel sent…`:`Cancel command`}</button>
|
|
32
32
|
</section>
|
|
33
|
-
`}if(
|
|
34
|
-
<section class=${`command-run-notice ${
|
|
33
|
+
`}if(n?.exited===!0){let r=this.continuingTerminalIds.includes(n.id);return e`
|
|
34
|
+
<section class=${`command-run-notice ${t.status}`}>
|
|
35
35
|
<div>
|
|
36
|
-
<strong>${
|
|
36
|
+
<strong>${be(t)}</strong>
|
|
37
37
|
<p>Output is preserved. Continue in a shell to inspect or run follow-up commands.</p>
|
|
38
|
-
<code>${
|
|
38
|
+
<code>${t.command}</code>
|
|
39
39
|
</div>
|
|
40
|
-
<button ?disabled=${
|
|
40
|
+
<button ?disabled=${r} @click=${()=>{this.continueTerminal(n.id)}}>${r?`Starting shell…`:`Continue in shell`}</button>
|
|
41
41
|
</section>
|
|
42
|
-
`}return null}enterCopyMode(){this.copySnapshot===void 0&&this.captureCopySnapshot()}refreshCopyMode(){this.copySnapshot!==void 0&&this.captureCopySnapshot()}captureCopySnapshot(){let e=this.terminal;if(e===void 0)return;let t=
|
|
42
|
+
`}return null}enterCopyMode(){this.copySnapshot===void 0&&this.captureCopySnapshot()}refreshCopyMode(){this.copySnapshot!==void 0&&this.captureCopySnapshot()}captureCopySnapshot(){let e=this.terminal;if(e===void 0)return;let t=C(e.buffer.active,e.cols,{theme:e.options.theme,drawBoldTextInBrightColors:e.options.drawBoldTextInBrightColors});this.copySnapshot=t,this.copyStatus=void 0,e.blur(),this.updateComplete.then(()=>{let n=this.terminalCopySelector;if(n==null)return;let r=Math.max(0,t.physicalLineCount-e.rows),i=Math.min(r,t.viewportLine);n.scrollTop=(r===0?0:i/r)*Math.max(0,n.scrollHeight-n.clientHeight),this.syncCopySnapshotScroll()})}exitCopyMode(){this.copySnapshot!==void 0&&(this.copySnapshot=void 0,this.copyStatus=void 0)}syncCopySnapshotScroll(){let e=this.terminalCopySelector,t=this.terminalCopyContent;if(e==null||t==null)return;let n=Math.max(0,e.scrollHeight-e.clientHeight),r=Math.max(0,t.scrollHeight-t.clientHeight),i=Math.max(0,e.scrollWidth-e.clientWidth),a=Math.max(0,t.scrollWidth-t.clientWidth);t.scrollTop=K(e.scrollTop,n,r),t.scrollLeft=K(e.scrollLeft,i,a)}async copyAllSnapshotText(){let e=this.copySnapshot?.text??``;if(e===``){this.copyStatus=`No terminal output to copy.`;return}this.copyStatus=await h(e)?`Copied all terminal output.`:`Unable to copy terminal output.`}renderCopyModeToggle(){if(this.selectedId===void 0)return null;let t=this.copySnapshot!==void 0;return e`
|
|
43
43
|
<button
|
|
44
44
|
type="button"
|
|
45
|
-
class=${
|
|
46
|
-
title=${
|
|
47
|
-
aria-label=${
|
|
48
|
-
aria-pressed=${String(
|
|
49
|
-
@click=${()=>{
|
|
45
|
+
class=${t?`copy-mode-toggle selected`:`copy-mode-toggle`}
|
|
46
|
+
title=${t?`Return to the interactive terminal`:`Select and copy terminal output`}
|
|
47
|
+
aria-label=${t?`Close terminal copy mode`:`Open terminal copy mode`}
|
|
48
|
+
aria-pressed=${String(t)}
|
|
49
|
+
@click=${()=>{t?this.exitCopyMode():this.enterCopyMode()}}
|
|
50
50
|
>
|
|
51
|
-
<span>${
|
|
51
|
+
<span>${t?`Done`:`Select`}</span>
|
|
52
52
|
</button>
|
|
53
|
-
`}renderCopyModeToolbar(){let
|
|
53
|
+
`}renderCopyModeToolbar(){let t=this.copySnapshot;return t===void 0?null:e`
|
|
54
54
|
<div class="terminal-copy-toolbar" role="toolbar" aria-label="Terminal copy controls">
|
|
55
55
|
<span aria-live="polite">${this.copyStatus??`Snapshot · long-press and select text`}</span>
|
|
56
|
-
<small>${
|
|
56
|
+
<small>${t.physicalLineCount} ${t.physicalLineCount===1?`row`:`rows`}</small>
|
|
57
57
|
<button type="button" @click=${()=>{this.refreshCopyMode()}}>Refresh</button>
|
|
58
58
|
<button type="button" @click=${()=>{this.copyAllSnapshotText()}}>Copy all</button>
|
|
59
59
|
</div>
|
|
60
|
-
`}renderCopyMode(){let
|
|
60
|
+
`}renderCopyMode(){let t=this.copySnapshot;return t===void 0?null:e`
|
|
61
61
|
<section class="terminal-copy-view" aria-label="Terminal copy mode">
|
|
62
62
|
${this.copyToolbarReplacesSoftKeys()?null:this.renderCopyModeToolbar()}
|
|
63
63
|
<div class="terminal-copy-layers">
|
|
64
|
-
<pre class="terminal-copy-content" aria-hidden="true">${
|
|
65
|
-
`}${
|
|
64
|
+
<pre class="terminal-copy-content" aria-hidden="true">${t.lines.map((t,n)=>e`${n===0?null:`
|
|
65
|
+
`}${t.runs.map(t=>e`<span style=${ne(q(t.style))}>${t.text}</span>`)}`)}</pre>
|
|
66
66
|
<textarea
|
|
67
67
|
class="terminal-copy-selector"
|
|
68
68
|
readonly
|
|
@@ -72,12 +72,12 @@ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n a
|
|
|
72
72
|
autocapitalize="off"
|
|
73
73
|
autocomplete="off"
|
|
74
74
|
aria-label="Selectable terminal output"
|
|
75
|
-
.value=${
|
|
75
|
+
.value=${t.text}
|
|
76
76
|
@scroll=${()=>{this.syncCopySnapshotScroll()}}
|
|
77
77
|
></textarea>
|
|
78
78
|
</div>
|
|
79
79
|
</section>
|
|
80
|
-
`}selectedTerminalAcceptsInput(){let e=this.selectedTerminalInfo();return e!==void 0&&!e.exited}copyToolbarReplacesSoftKeys(){return this.copySnapshot!==void 0&&this.selectedTerminalAcceptsInput()&&this.softKeysEnabled}renderTerminalAccessoryBar(){return this.copySnapshot===void 0?this.shouldShowSoftKeys()?this.renderSoftKeys():null:this.copyToolbarReplacesSoftKeys()?this.renderCopyModeToolbar():null}shouldShowSoftKeys(){return this.selectedTerminalAcceptsInput()&&this.softKeysEnabled}shouldShowSoftKeysToggle(){return this.copySnapshot===void 0&&this.selectedTerminalAcceptsInput()}toggleSoftKeys(){this.copySnapshot===void 0&&(this.softKeysEnabled=!this.softKeysEnabled,this.softKeysPreferenceStored=!0,P(this.softKeysEnabled),this.scheduleFitAndNotify())}renderSoftKeysToggle(){return this.shouldShowSoftKeysToggle()?
|
|
80
|
+
`}selectedTerminalAcceptsInput(){let e=this.selectedTerminalInfo();return e!==void 0&&!e.exited}copyToolbarReplacesSoftKeys(){return this.copySnapshot!==void 0&&this.selectedTerminalAcceptsInput()&&this.softKeysEnabled}renderTerminalAccessoryBar(){return this.copySnapshot===void 0?this.shouldShowSoftKeys()?this.renderSoftKeys():null:this.copyToolbarReplacesSoftKeys()?this.renderCopyModeToolbar():null}shouldShowSoftKeys(){return this.selectedTerminalAcceptsInput()&&this.softKeysEnabled}shouldShowSoftKeysToggle(){return this.copySnapshot===void 0&&this.selectedTerminalAcceptsInput()}toggleSoftKeys(){this.copySnapshot===void 0&&(this.softKeysEnabled=!this.softKeysEnabled,this.softKeysPreferenceStored=!0,P(this.softKeysEnabled),this.scheduleFitAndNotify())}renderSoftKeysToggle(){return this.shouldShowSoftKeysToggle()?e`
|
|
81
81
|
<button
|
|
82
82
|
type="button"
|
|
83
83
|
class=${this.softKeysEnabled?`soft-keys-toggle selected`:`soft-keys-toggle`}
|
|
@@ -92,35 +92,35 @@ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n a
|
|
|
92
92
|
</svg>
|
|
93
93
|
<span>Keys</span>
|
|
94
94
|
</button>
|
|
95
|
-
`:null}renderSoftKeys(){return
|
|
95
|
+
`:null}renderSoftKeys(){return e`
|
|
96
96
|
<terminal-soft-keys
|
|
97
97
|
.modes=${this.terminal?.modes}
|
|
98
98
|
.refocusOnClick=${!this.defaultSoftKeysEnvironment}
|
|
99
99
|
.onInput=${(e,t)=>{this.sendSoftKeyInput(e,t)}}
|
|
100
100
|
></terminal-soft-keys>
|
|
101
|
-
`}render(){return
|
|
101
|
+
`}render(){return e`
|
|
102
102
|
<section class="terminal-shell">
|
|
103
103
|
<div class="terminal-tabs">
|
|
104
104
|
${this.renderCopyModeToggle()}
|
|
105
105
|
${this.renderSoftKeysToggle()}
|
|
106
|
-
${this.terminals.map(e
|
|
107
|
-
<button class=${this.selectedId===
|
|
108
|
-
<span>${
|
|
109
|
-
<small @click=${
|
|
106
|
+
${this.terminals.map(t=>e`
|
|
107
|
+
<button class=${this.selectedId===t.id?`selected`:``} @click=${()=>{this.selectTerminal(t.id)}}>
|
|
108
|
+
<span>${t.name}${t.exited?` · exited`:``}</span>
|
|
109
|
+
<small @click=${e=>{this.closeTerminal(t.id,e)}}>×</small>
|
|
110
110
|
</button>
|
|
111
111
|
`)}
|
|
112
112
|
<button class="new" ?disabled=${this.workspace===void 0} @click=${()=>{this.startTerminal()}}>+ Shell</button>
|
|
113
113
|
</div>
|
|
114
|
-
${this.error===void 0?null:
|
|
114
|
+
${this.error===void 0?null:e`<p class="error">${this.error}</p>`}
|
|
115
115
|
${this.renderCommandRunNotice()}
|
|
116
116
|
${this.renderTerminalAccessoryBar()}
|
|
117
|
-
${this.loading?
|
|
117
|
+
${this.loading?e`<p class="muted">Loading terminals…</p>`:null}
|
|
118
118
|
<div class="terminal-stage">
|
|
119
119
|
<div class=${this.copySnapshot===void 0?`terminal-host`:`terminal-host copying`} ?inert=${this.copySnapshot!==void 0}></div>
|
|
120
120
|
${this.renderCopyMode()}
|
|
121
121
|
</div>
|
|
122
122
|
</section>
|
|
123
|
-
`}static{this.styles=
|
|
123
|
+
`}static{this.styles=_`
|
|
124
124
|
:host { flex: 1 1 auto; min-height: 0; display: flex; }
|
|
125
125
|
.terminal-shell { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--pi-terminal-bg); }
|
|
126
126
|
.terminal-tabs { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; padding: 6px; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); overflow: auto; }
|
|
@@ -190,4 +190,4 @@ import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n a
|
|
|
190
190
|
.error { flex: 0 0 auto; margin: 0; padding: 8px; color: var(--pi-danger); border-bottom: 1px solid var(--pi-border); background: var(--pi-surface); }
|
|
191
191
|
.muted { margin: 10px; color: var(--pi-muted); }
|
|
192
192
|
.xterm { height: 100%; }
|
|
193
|
-
`}};u([i({attribute:!1})],G.prototype,`workspace`,void 0),u([i()],G.prototype,`machineId`,void 0),u([i({attribute:!1})],G.prototype,`selectedTerminalId`,void 0),u([i({type:Boolean})],G.prototype,`autoStart`,void 0),u([i({attribute:!1})],G.prototype,`onSelectTerminal`,void 0),u([
|
|
193
|
+
`}};u([i({attribute:!1})],G.prototype,`workspace`,void 0),u([i()],G.prototype,`machineId`,void 0),u([i({attribute:!1})],G.prototype,`selectedTerminalId`,void 0),u([i({type:Boolean})],G.prototype,`autoStart`,void 0),u([i({attribute:!1})],G.prototype,`onSelectTerminal`,void 0),u([g(`.terminal-host`)],G.prototype,`terminalHost`,void 0),u([g(`.terminal-copy-content`)],G.prototype,`terminalCopyContent`,void 0),u([g(`.terminal-copy-selector`)],G.prototype,`terminalCopySelector`,void 0),u([r()],G.prototype,`terminals`,void 0),u([r()],G.prototype,`commandRuns`,void 0),u([r()],G.prototype,`selectedId`,void 0),u([r()],G.prototype,`loading`,void 0),u([r()],G.prototype,`error`,void 0),u([r()],G.prototype,`visible`,void 0),u([r()],G.prototype,`cancellingRunIds`,void 0),u([r()],G.prototype,`continuingTerminalIds`,void 0),u([r()],G.prototype,`defaultSoftKeysEnvironment`,void 0),u([r()],G.prototype,`softKeysEnabled`,void 0),u([r()],G.prototype,`copySnapshot`,void 0),u([r()],G.prototype,`copyStatus`,void 0),G=u([f(`terminal-panel`)],G);function K(e,t,n){return t<=0||n<=0?0:Math.min(1,Math.max(0,e/t))*n}function ye(e){return/^#[\da-f]{6}$/i.test(e)?`${e}80`:`color-mix(in srgb, ${e} 50%, transparent)`}function q(e){let t=[e.underline?`underline`:void 0,e.strikethrough?`line-through`:void 0,e.overline?`overline`:void 0].filter(e=>e!==void 0).join(` `);return{color:e.invisible?`transparent`:e.dim?ye(e.foreground):e.foreground,backgroundColor:e.background,fontWeight:e.bold?`700`:void 0,fontStyle:e.italic?`italic`:void 0,textDecorationLine:t===``?void 0:t}}function J(e){return e.status===`queued`||e.status===`running`}function be(e){return e.status===`succeeded`?`Command succeeded${e.exitCode===void 0?``:` with exit code ${String(e.exitCode)}`}`:`Command failed${e.exitCode===void 0?``:` with exit code ${String(e.exitCode)}`}`}function xe(e){let t=JSON.parse(e);if(!we(t))return{type:`error`,message:`Invalid terminal message`};let n=t;return n.type===`output`&&typeof n.data==`string`?{type:`output`,data:n.data,...typeof n.replay==`boolean`?{replay:n.replay}:{}}:n.type===`exit`?{type:`exit`,...typeof n.exitCode==`number`?{exitCode:n.exitCode}:{}}:n.type===`error`&&typeof n.message==`string`?{type:`error`,message:n.message}:{type:`error`,message:`Invalid terminal message`}}function Y(e){return e.replaceAll(`\x1B[I`,``).replaceAll(`\x1B[O`,``)}async function Se(e){return typeof e==`string`?e:e instanceof ArrayBuffer?new TextDecoder().decode(e):e instanceof Blob?await e.text():String(e)}function X(e){return{...ge,theme:Z(e)}}function Z(e){return{...S,background:Q(e,`--pi-terminal-bg`,`#05070a`),foreground:Q(e,`--pi-terminal-text`,`#e6edf3`),cursor:Q(e,`--pi-accent`,`#58a6ff`),selectionBackground:Q(e,`--pi-terminal-selection`,`#264f78`)}}function Q(e,t,n){let r=getComputedStyle(e).getPropertyValue(t).trim();return r===``?n:r}function $(e){if(!(e===void 0||!Ce(e.cols,e.rows)))return{cols:Math.floor(e.cols),rows:Math.floor(e.rows)}}function Ce(e,t){return Number.isFinite(e)&&Number.isFinite(t)&&e>0&&t>0}function we(e){return typeof e==`object`&&!!e}export{G as TerminalPanel,Y as filterTerminalInput};
|