mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 07:54:38 +00:00
* feat(plugins): unify panel props and persist tab state * refactor(plugins): make agent panel registration canonical * docs(plugins): update Chinese panel API reference and migration
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { PluginClientStateProvider } from "@getpaseo/plugin/client/host";
|
|
import type { PluginFilePanelProps } from "@getpaseo/plugin/client";
|
|
import { useMemo } from "react";
|
|
import { createPluginClientStateSource } from "@/plugins/client-state/source";
|
|
import { PluginInstallationProvider } from "@/plugins/installation-provider";
|
|
import { SurfaceErrorBoundary } from "@/plugins/surface-error-boundary";
|
|
import type { PluginFilePanel } from "./panels";
|
|
|
|
export function PluginFilePanelHost({
|
|
panel,
|
|
...props
|
|
}: PluginFilePanelProps & { panel: PluginFilePanel }) {
|
|
const { plugin, contribution } = panel;
|
|
const stateSource = useMemo(
|
|
() => createPluginClientStateSource(plugin.serverId),
|
|
[plugin.serverId],
|
|
);
|
|
const Component = contribution.Component;
|
|
return (
|
|
<SurfaceErrorBoundary installation={plugin} Surface={Component} key={panel.id}>
|
|
<PluginInstallationProvider plugin={plugin}>
|
|
<PluginClientStateProvider source={stateSource}>
|
|
<Component {...props} />
|
|
</PluginClientStateProvider>
|
|
</PluginInstallationProvider>
|
|
</SurfaceErrorBoundary>
|
|
);
|
|
}
|