import { shallowReactive , markRaw , unref } from 'vue' ; import { activateOrAddTerminalTab , useTerminalTabs } from '../../renderer/hooks/terminal' ; import { createIDGenerator } from '../../renderer/utils/helper' ; import type { TerminalTab , TerminalTabPane } from '../../typings/terminal' ; import type { CommasContext } from '../types' ; const tabs = shallowReactive < Record < string , TerminalTab > > ( { } ) ; const generateID = createIDGenerator ( ) ; function registerTabPane ( this , name , pane ) { tabs [ name ] = markRaw ( { pid : generateID ( ) , process : '' , title : '' , cwd : '' , pane , } as TerminalTab ) ; this . $ . app . onCleanup ( ( ) => { delete tabs [ name ] ; } ) ; } function getPaneTab ( name ) { return tabs [ name ] ; } function openPaneTab ( name ) { activateOrAddTerminalTab ( getPaneTab ( name ) ) ; } function getTerminalTabs ( ) { return unref ( useTerminalTabs ( ) ) ; } export { registerTabPane , getPaneTab , openPaneTab , getTerminalTabs , } ;