mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 14:15:24 +00:00
feat: load plugin frontends at runtime and remove plugin ids from the shell
This commit is contained in:
1 parent
49f0286a14
commit
e88d5a52e3
721 files changed
+54265
-44416
No files matched your search
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Frontend half of the ssh-terminal plugin.
|
||||
*
|
||||
* Registers the existing Terminal component through the extension seams that
|
||||
* already exist in the shell (registerRailItem / registerTabComponent). The
|
||||
* component itself is unchanged and still lives in src/ui/features/terminal -
|
||||
* this only controls whether the shell knows about it.
|
||||
*
|
||||
* register() is called when the plugin is enabled, unregister() when it is
|
||||
* disabled, so the tab and rail entry appear and disappear with the plugin.
|
||||
*/
|
||||
|
||||
export const id = "ssh-terminal";
|
||||
export const tabId = "terminal";
|
||||
export const toolbarSlotId = "terminal.toolbar";
|
||||
|
||||
export async function register({
|
||||
registerRailItem,
|
||||
registerTabComponent,
|
||||
declareActionSlot,
|
||||
icons,
|
||||
}) {
|
||||
registerTabComponent(tabId, () =>
|
||||
import("@/features/terminal/Terminal").then((m) => ({
|
||||
default: m.Terminal,
|
||||
})),
|
||||
);
|
||||
|
||||
registerRailItem({
|
||||
id: tabId,
|
||||
icon: icons.SquareTerminal,
|
||||
labelKey: "nav.terminal",
|
||||
kind: "tab",
|
||||
});
|
||||
|
||||
// Offers other plugins a place in the terminal toolbar. The terminal does
|
||||
// not know or care who fills it.
|
||||
declareActionSlot({ id: toolbarSlotId, accepts: ["button"] });
|
||||
}
|
||||
|
||||
export async function unregister({
|
||||
unregisterRailItem,
|
||||
unregisterTabComponent,
|
||||
undeclareActionSlot,
|
||||
}) {
|
||||
unregisterRailItem(tabId);
|
||||
unregisterTabComponent(tabId);
|
||||
undeclareActionSlot(toolbarSlotId);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import type { ComponentType } from "react";
|
||||
import { Terminal } from "lucide-react";
|
||||
import type {
|
||||
StandaloneViewProps,
|
||||
TabProps,
|
||||
TermixApp,
|
||||
} from "@termix/plugin-sdk/frontend";
|
||||
import {
|
||||
TerminalTabContent,
|
||||
loadTerminal,
|
||||
} from "@/features/terminal/TerminalTabContent";
|
||||
import TerminalApp from "@/features/terminal/TerminalApp";
|
||||
import {
|
||||
TERMINAL_DOCK_SLOT,
|
||||
TERMINAL_OVERLAY_SLOT,
|
||||
TERMINAL_TOOLBAR_SLOT,
|
||||
} from "@/features/terminal/terminal-slots";
|
||||
|
||||
/** `?view=terminal` full-screen links. */
|
||||
function TerminalStandalone({ hostId, params }: StandaloneViewProps) {
|
||||
return (
|
||||
<TerminalApp
|
||||
hostId={hostId}
|
||||
tmuxSession={params.get("tmuxSession") ?? undefined}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The SSH terminal. Its component still lives in core until the terminal's
|
||||
* own Phase B step; this plugin decides whether the shell offers it.
|
||||
*/
|
||||
export function activate(app: TermixApp): void {
|
||||
app.registerTab(
|
||||
"terminal",
|
||||
TerminalTabContent as unknown as ComponentType<TabProps>,
|
||||
{
|
||||
icon: Terminal,
|
||||
titleKey: "nav.terminal",
|
||||
persistent: true,
|
||||
session: true,
|
||||
restore: (host) => !!host.enableSsh,
|
||||
activityTypes: ["terminal"],
|
||||
standalone: TerminalStandalone,
|
||||
preload: loadTerminal,
|
||||
},
|
||||
);
|
||||
|
||||
app.registerHostAction({
|
||||
id: "terminal",
|
||||
titleKey: "nav.terminal",
|
||||
icon: Terminal,
|
||||
kind: "connect",
|
||||
priority: 100,
|
||||
order: 10,
|
||||
tabType: "terminal",
|
||||
copyUrlView: "terminal",
|
||||
when: (host) => !!host.enableSsh && host.enableTerminal !== false,
|
||||
});
|
||||
|
||||
// Places other plugins can fill: toolbar buttons, a docked side panel and
|
||||
// overlays that follow the session's connection flow.
|
||||
app.declareActionSlot({ id: TERMINAL_TOOLBAR_SLOT, accepts: ["button"] });
|
||||
app.declareActionSlot({ id: TERMINAL_DOCK_SLOT, accepts: ["component"] });
|
||||
app.declareActionSlot({ id: TERMINAL_OVERLAY_SLOT, accepts: ["component"] });
|
||||
}
|
||||
Reference in new issue
Block a user