export type RedactPreset = 'nano' | 'full'; /** * Opt-in feature set. Each flag toggles whether the feature's real * implementation ships (`true`) or is swapped with a stub module that * degrades gracefully (`false`). Missing keys fall back to the preset's * default. Adding a feature to this interface propagates to consumer * configs as autocompleted options. */ export interface RedactFeatures { /** * `createPortal`. When `false`, portal elements render in place as a * Fragment (the `container` prop is ignored). `renderPortal` and its * deps are stripped from the bundle. */ portal?: boolean; /** * `createContext` / `useContext` / `` / ``. When * `false`, Providers render as Fragments (value never propagates), * Consumers invoke their function-children with the context's default * value, and `useContext` returns the default. Provider-walk logic and * `renderProvider` are stripped. */ context?: boolean; /** * `` boundaries + streaming hydration. When `false`, Suspense * elements render as Fragments (children mount inline, `fallback` is * ignored). Thrown thenables still schedule a re-render on settle, so * eventual consistency works — just no fallback UI during the pending * window. Boundary-handler stack and hydration integration are stripped. */ suspense?: boolean; /** * `React.memo`. When `false`, memoized components still render but without * the prop-equality gate — every parent rerender passes through. * `shallowEqual` and the force-rerender bypass are stripped. */ memo?: boolean; /** * `React.forwardRef`. When `false`, forwardRef components still render but * the ref prop isn't forwarded to the inner function. React 19+ treats * refs as normal props on function components anyway, so most apps can * drop this. The dispatcher save/restore machinery is stripped. */ forwardRef?: boolean; /** * `React.lazy`. When `false`, lazy elements still resolve if their payload * is already available synchronously (e.g. pre-awaited RSC Flight); async * resolution throws a clear error. The hydration-deferred-reveal path and * Suspense coordination are stripped. */ lazy?: boolean; /** * Class components (`extends Component`). When `false`, class components * still render but only honor the core contract: constructor + `render()` * + `setState`. Dropped: `contextType`, `getDerivedStateFromProps`, * `shouldComponentUpdate`, `componentDidMount`/`Update`/`WillUnmount`, * `getDerivedStateFromError`/`componentDidCatch` (error boundaries). */ classComponents?: boolean; /** * SSR hydration (`hydrateRoot`). When `false`, `hydrateRoot` throws * (use `createRoot` for SPAs). The HydrationCursor / DOM adoption / * streaming-boundary coordination / event-replay / scroll-guard * machinery is stripped — the biggest single chunk of reducible code. */ hydration?: boolean; } export interface RedactOptions { /** Skip aliasing specific specifiers, e.g. if a consumer wants real React somewhere. */ skip?: ReadonlyArray; /** * Override package resolution root. Defaults to the Vite config root. Useful * for monorepos where the plugin lives in a different workspace than the * consumer app. */ resolveFrom?: string; /** * Explicit package roots, bypassing node_modules lookup. Keys are package * names (e.g. `@tanstack/redact`), values are absolute paths to the package * directory. Handy for cross-workspace testing / bring-your-own-build setups. */ packageRoots?: Record; /** * Starting point for feature selection. `'full'` (default) turns every * feature on — drop-in React parity, opt-out individual features via * `features`. `'nano'` turns everything off — opt in to what you need. */ preset?: RedactPreset; /** * Per-feature overrides merged on top of the preset's defaults. Enables * fine-grained "preset minus X" or "preset plus Y" configurations. */ features?: RedactFeatures; } export declare function redact(options?: RedactOptions): any; export default redact;