( props: ExecutorPluginsProviderProps, )
| 487 | } |
| 488 | |
| 489 | export function ExecutorPluginsProvider( |
| 490 | props: ExecutorPluginsProviderProps, |
| 491 | ): ReturnType<typeof createElement> { |
| 492 | const { plugins, children } = props; |
| 493 | const value = useMemo<ExecutorPluginsContextValue>( |
| 494 | () => ({ |
| 495 | plugins, |
| 496 | integrationPlugins: plugins.flatMap((p) => |
| 497 | p.integrationPlugin ? [p.integrationPlugin] : [], |
| 498 | ), |
| 499 | secretProviderPlugins: plugins.flatMap((p) => |
| 500 | p.secretProviderPlugin ? [p.secretProviderPlugin] : [], |
| 501 | ), |
| 502 | }), |
| 503 | [plugins], |
| 504 | ); |
| 505 | // Kick off lazy chunk downloads for every integration plugin once the host |
| 506 | // mounts, so navigating into an add/edit page doesn't suspend. |
| 507 | useEffect(() => { |
| 508 | for (const ip of value.integrationPlugins) ip.preload?.(); |
| 509 | }, [value.integrationPlugins]); |
| 510 | return createElement(ExecutorPluginsContext.Provider, { value }, children); |
| 511 | } |
| 512 | |
| 513 | const usePluginsCtx = (hookName: string): ExecutorPluginsContextValue => { |
| 514 | const ctx = useContext(ExecutorPluginsContext); |
nothing calls this directly
no outgoing calls
no test coverage detected