/** * 第三方 client 插件接入示例:把自己的快捷入口挂上 2D Palette Board。 * * ★ 软依赖模式(推荐):不要把 'paletteHub' 写进模块级 inject——那是硬 * 契约,palette-board 停用/未安装时你的插件会永远 pending,整个 web * GUI 都会启动失败。改用 ctx.inject(...) 命令式声明:本插件照常激活, * 一个内部子作用域等待服务出现;palette-board 未启用则回调永不执行 * (零开销跳过),启用(或宿主重载)后自动执行。 * * `import type {} from 'dsh-plugin-palette-board/client'` 是纯类型导入: * 触发 ctx.paletteHub 类型合并,编译期擦除、不产生运行时依赖。 */ import type {} from 'dsh-plugin-palette-board/client' import type { Context } from '@deepseek-ai/cordis' export function apply(ctx: Context): void { ctx.inject(['paletteHub'], (sctx) => { const unregister = sctx.paletteHub.register({ id: 'my-plugin:telemetry', title: 'Container Live Telemetry', description: 'Real-time Docker & GPU kernel metrics inspector with live stream.', category: 'Developer Tools', color: 'emerald', badge: 'v1.4', shortcut: 'Alt+M', actionLabel: 'Inspect', order: 50, onClick: () => { // 在这里打开你的插件 UI、调用自己的服务或触发任何动作。 console.log('[my-plugin] telemetry launched') }, }) // disposer 挂在子作用域上:palette-board 停用 / HMR 时自动注销。 sctx.effect(() => unregister, 'my-plugin: palette entry') }) }