import * as _$react from "react"; import React from "react"; import { ClientRuntimeConfig, RuntimeConfig, RuntimeConfigInput } from "@yanuaraditia/config"; //#region src/context.d.ts type AnyRuntimeConfig = RuntimeConfig | ClientRuntimeConfig; declare const RuntimeConfigContext: _$react.Context; //#endregion //#region src/provider.d.ts interface RuntimeConfigProviderProps { /** * The **public** config to expose to the React tree. * * Pass the value from `usePublicRuntimeConfig()` in your root loader so that * both the server render and client hydration share the same value. * * ⚠️ Only the `public` key is ever exposed to components. Any private keys * on this object are stripped automatically — but to prevent them from being * sent over the network in the first place, always use `usePublicRuntimeConfig()` * (not `useRuntimeConfig()`) when building your loader return value. * * Omit this prop in SPA mode — the provider reads `window.__RUNTIME_CONFIG__` * that was injected by the Vite plugin or ``. */ config?: AnyRuntimeConfig; children: React.ReactNode; } /** * Provides the runtime config to the entire React tree. * * ### SPA usage * ```tsx * // main.tsx * createRoot(document.getElementById('root')!).render( * * * * ) * ``` * * ### React Router v7 SSR usage * ```tsx * // app/root.tsx * import { usePublicRuntimeConfig } from '@yanuaraditia/config-react/server' * * export async function loader() { * // usePublicRuntimeConfig strips private keys before they reach the client * return { runtimeConfig: usePublicRuntimeConfig() } * } * * export default function Root() { * const { runtimeConfig } = useLoaderData() * return ( * * * * ) * } * ``` */ declare function RuntimeConfigProvider({ config, children }: RuntimeConfigProviderProps): React.FunctionComponentElement>; //#endregion //#region src/hook.d.ts /** * Returns the **public** runtime config from the nearest `RuntimeConfigProvider` * or from `window.__RUNTIME_CONFIG__` (injected by the Vite plugin / ``). * * Private keys are never available here — they exist only on the server. * TypeScript enforces this: accessing anything outside `config.public` is a compile error. * * ```tsx * function ApiClient() { * const { public: { apiBase } } = useRuntimeConfig() * return {apiBase} * } * ``` */ declare function useRuntimeConfig(): ClientRuntimeConfig; //#endregion //#region src/script.d.ts interface RuntimeConfigScriptProps { /** * The runtime config whose **public** portion will be serialised and * embedded in the page as `window.__RUNTIME_CONFIG__`. * * Pass the value from your root loader / `getRuntimeConfig()`. */ config: RuntimeConfigInput; /** * HTML `nonce` attribute for strict Content-Security-Policy environments. */ nonce?: string; } /** * Renders an inline `