1a3c134f1a
Co-authored-by: Kandev Agent <agent@kandev.dev> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
28 lines
828 B
TypeScript
28 lines
828 B
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import { useAppStoreApi } from "@/components/state-provider";
|
|
import { bootPlugins } from "./boot";
|
|
import type { ActivePlugin } from "./types";
|
|
|
|
type PluginBootBridgeProps = {
|
|
plugins?: ActivePlugin[];
|
|
};
|
|
|
|
/**
|
|
* Mounted once at the app root (inside `StateProvider`, see `src/main.tsx`).
|
|
* Triggers `bootPlugins` as soon as the store + boot payload plugins are
|
|
* available. Renders nothing — `bootPlugins` itself guards against
|
|
* double-loading a store that has already booted, so repeated effect runs
|
|
* (StrictMode double-invoke, re-renders) are safe no-ops.
|
|
*/
|
|
export function PluginBootBridge({ plugins }: PluginBootBridgeProps) {
|
|
const store = useAppStoreApi();
|
|
|
|
useEffect(() => {
|
|
bootPlugins({ plugins }, store);
|
|
}, [plugins, store]);
|
|
|
|
return null;
|
|
}
|