|
"use strict";(self.webpackChunk_JUPYTERLAB_CORE_OUTPUT=self.webpackChunk_JUPYTERLAB_CORE_OUTPUT||[]).push([[5912],{15912:(e,n,t)=>{t.r(n),t.d(n,{default:()=>p});var a,r=t(44604),o=t(53312),i=t(86810),s=t(29879),c=t(9235),l=t(87408),d=t(23295),m=t(5333),h=t(12030),u=t(35613),g=t(63485);!function(e){e.copy="terminal:copy",e.createNew="terminal:create-new",e.open="terminal:open",e.refresh="terminal:refresh",e.increaseFont="terminal:increase-font",e.decreaseFont="terminal:decrease-font",e.paste="terminal:paste",e.setTheme="terminal:set-theme",e.shutdown="terminal:shut-down"}(a||(a={}));const _={activate:function(e,n,t,r,i,s,c,d,h){const p=t.load("jupyterlab"),{serviceManager:f,commands:y}=e,T=p.__("Terminal"),b=new o.WidgetTracker({namespace:"terminal"});if(!f.terminals.isAvailable())return console.warn("Disabling terminals plugin because they are not available on the server"),b;s&&s.restore(b,{command:a.createNew,args:e=>({name:e.content.session.name}),name:e=>e.content.session.name});const v={};function I(e){Object.keys(e.composite).forEach((n=>{v[n]=e.composite[n]}))}function C(){b.forEach((e=>function(e){const n=e.content;n&&Object.keys(v).forEach((e=>{n.setOption(e,v[e])}))}(e)))}if(n.load(_.id).then((e=>{I(e),C(),e.changed.connect((()=>{I(e),C()}))})).catch(w.showErrorMessage),null==d||d.themeChanged.connect(((e,n)=>{b.forEach((e=>{const n=e.content;"inherit"===n.getOption("theme")&&n.setOption("theme","inherit")}))})),function(e,n,t,r,i){var s;const c=r.load("jupyterlab"),{commands:d,serviceManager:h}=e,g=()=>null!==n.currentWidget&&n.currentWidget===e.shell.currentWidget;d.addCommand(a.createNew,{label:e=>e.isPalette?c.__("New Terminal"):c.__("Terminal"),caption:c.__("Start a new terminal session"),icon:e=>e.isPalette?void 0:u.terminalIcon,execute:async t=>{const a=t.name,s=t.cwd,c=s?h.contents.localPath(s):void 0;let d;d=a?(await l.TerminalAPI.listRunning()).map((e=>e.name)).includes(a)?h.terminals.connectTo({model:{name:a}}):await h.terminals.startNew({name:a,cwd:c}):await h.terminals.startNew({cwd:c});const g=new m.Terminal(d,i,r);g.title.icon=u.terminalIcon,g.title.label="...";const _=new o.MainAreaWidget({content:g,reveal:g.ready});return e.shell.add(_,"main",{type:"Terminal"}),n.add(_),e.shell.activateById(_.id),_}}),d.addCommand(a.open,{label:c.__("Open a terminal by its `name`."),execute:t=>{const r=t.name,o=n.find((e=>e.content.session.name===r||!1));if(!o)return d.execute(a.createNew,{name:r});e.shell.activateById(o.id)}}),d.addCommand(a.refresh,{label:c.__("Refresh Terminal"),caption:c.__("Refresh the current terminal session"),execute:async()=>{const t=n.currentWidget;if(t){e.shell.activateById(t.id);try{await t.content.refresh(),t&&t.content.activate()}catch(e){w.showErrorMessage(e)}}},icon:e=>e.isPalette?void 0:u.refreshIcon.bindprops({stylesheet:"menuItem"}),isEnabled:g}),d.addCommand(a.copy,{execute:()=>{var e;const t=null===(e=n.currentWidget)||void 0===e?void 0:e.content;if(!t)return;const a=t.getSelection();a&&o.Clipboard.copyToSystem(a)},isEnabled:()=>{var e;if(!g())return!1;const t=null===(e=n.currentWidget)||void 0===e?void 0:e.content;return!!t&&t.hasSelection()},icon:u.copyIcon.bindprops({stylesheet:"menuItem"}),label:c.__("Copy")}),d.addCommand(a.paste,{execute:async()=>{var e;const t=null===(e=n.currentWidget)||void 0===e?void 0:e.content;if(!t)return;const a=window.navigator.clipboard,r=await a.readText();r&&t.paste(r)},isEnabled:()=>{var e;return Boolean(g()&&(null===(e=n.currentWidget)||void 0===e?void 0:e.content))},icon:u.pasteIcon.bindprops({stylesheet:"menuItem"}),label:c.__("Paste")}),d.addCommand(a.shutdown,{label:c.__("Shutdown Terminal"),execute:()=>{const e=n.currentWidget;if(e)return e.content.session.shutdown()},isEnabled:g}),d.addCommand(a.increaseFont,{label:c.__("Increase Terminal Font Size"),execute:async()=>{const{fontSize:e}=i;if(e&&e<72)try{await t.set(_.id,"fontSize",e+1)}catch(e){w.showErrorMessage(e)}}}),d.addCommand(a.decreaseFont,{label:c.__("Decrease Terminal Font Size"),execute:async()=>{const{fontSize:e}=i;if(e&&e>9)try{await t.set(_.id,"fontSize",e-1)}catch(e){w.showErrorMessage(e)}}});const p={inherit:c.__("Inherit"),light:c.__("Light"),dark:c.__("Dark")};d.addCommand(a.setTheme,{label:e=>{if(void 0===e.theme)return c.__("Set terminal theme to the provided `theme`.");const n=e.theme,t=n in p?p[n]:c.__(n[0].toUpperCase()+n.slice(1));return e.isPalette?c.__("Use Terminal Theme: %1",t):t},caption:c.__("Set the terminal theme"),isToggled:e=>{const{theme:n}=i;return e.theme===n},execute:async e=>{const n=e.theme;try{await t.set(_.id,"theme",n),d.notifyCommandChanged(a.setTheme)}catch(e){console.log(e),w.showErrorMessage(e)}}});const f=[a.refresh,a.copy,a.paste,a.shutdown],y=()=>{f.forEach((e=>d.notifyCommandChanged(e)))};n.currentChanged.connect(y),null===(s=e.shell.currentChanged)||void 0===s||s.connect(y)}(e,b,n,t,v),c){const e=new g.Menu({commands:y});e.title.label=p._p("menu","Terminal Theme"),e.addItem({command:a.setTheme,args:{theme:"inherit",displayName:p.__("Inherit"),isPalette:!1}}),e.addItem({command:a.setTheme,args:{theme:"light",displayName:p.__("Light"),isPalette:!1}}),e.addItem({command:a.setTheme,args:{theme:"dark",displayName:p.__("Dark"),isPalette:!1}}),c.settingsMenu.addGroup([{command:a.increaseFont},{command:a.decreaseFont},{type:"submenu",submenu:e}],40),c.fileMenu.newMenu.addItem({command:a.createNew,rank:20}),c.fileMenu.closeAndCleaners.add({id:a.shutdown,isEnabled:e=>null!==b.currentWidget&&b.has(e)})}return r&&([a.createNew,a.refresh,a.increaseFont,a.decreaseFont].forEach((e=>{r.addItem({command:e,category:T,args:{isPalette:!0}})})),r.addItem({command:a.setTheme,category:T,args:{theme:"inherit",displayName:p.__("Inherit"),isPalette:!0}}),r.addItem({command:a.setTheme,category:T,args:{theme:"light",displayName:p.__("Light"),isPalette:!0}}),r.addItem({command:a.setTheme,category:T,args:{theme:"dark",displayName:p.__("Dark"),isPalette:!0}})),i&&i.add({command:a.createNew,category:p.__("Other"),rank:0}),h&&function(e,n,t){const a=t.load("jupyterlab"),r=n.serviceManager.terminals;class o{constructor(e){this._model=e}open(){n.commands.execute("terminal:open",{name:this._model.name})}icon(){return u.terminalIcon}label(){return`terminals/${this._model.name}`}shutdown(){return r.shutdown(this._model.name)}}e.add({name:a.__("Terminals"),running:()=>Array.from(r.running()).map((e=>new o(e))),shutdownAll:()=>r.shutdownAll(),refreshRunning:()=>r.refreshRunning(),runningChanged:r.runningChanged,shutdownLabel:a.__("Shut Down"),shutdownAllLabel:a.__("Shut Down All"),shutdownAllConfirmationText:a.__("Are you sure you want to permanently shut down all running terminals?")})}(h,e,t),b},id:"@jupyterlab/terminal-extension:plugin",description:"Adds terminal and provides its tracker.",provides:m.ITerminalTracker,requires:[d.ISettingRegistry,h.ITranslator],optional:[o.ICommandPalette,i.ILauncher,r.ILayoutRestorer,s.IMainMenu,o.IThemeManager,c.IRunningSessionManagers],autoStart:!0},p=_;var w;!function(e){e.showErrorMessage=function(e){console.error(`Failed to configure ${_.id}: ${e.message}`)}}(w||(w={}))}}]); |