import type { GetClassNameForKeyFn } from './processProps.js'; import type { CacheObject } from './types.js'; type InsertRuleCallback = (rule: string) => void; export interface StyleCacheOptions { getClassName?: GetClassNameForKeyFn; onInsertRule?: InsertRuleCallback; } /** * A jsxstyle style cache designed for client-side use. * Injects styles directly into the DOM. * * @example * const cache = new StyleCache(); * // or with custom options: * const cache = new StyleCache({ * getClassName: (key) => `my-${hash(key)}`, * onInsertRule: (rule) => console.log(rule), * }); */ export declare class StyleCache { #private; constructor(options?: StyleCacheOptions); /** Reset the cache to its initial state. */ reset(): void; /** A copy of the current class name cache. */ get classNameCache(): CacheObject; /** A copy of the current insert rule cache. */ get insertRuleCache(): Record; /** * @deprecated Create a new `StyleCache` with options instead. * @example * // Old approach: * cache.injectOptions({ getClassName: myFn }); * * // New approach: * const cache = new StyleCache({ getClassName: myFn }); */ injectOptions(options: StyleCacheOptions): void; /** Insert a CSS rule into the document. */ insertRule(rule: string): void; /** * Given a synchronous or asynchronous callback, this function executes the * callback and collects all styles that were injected as a side effect of * the callback running. It returns both the injected styles and the * return value of the callback. * * @deprecated Use `RequestStyleCache` with `flushStyles()` for SSR instead. This method is not concurrent-safe. * @example * // Old approach (not concurrent-safe): * const { css, returnValue } = await cache.run(() => renderToString()); * * // New approach (concurrent-safe): * import { RequestStyleCache } from '@jsxstyle/core'; * import { JsxstyleCacheProvider } from '@jsxstyle/react'; * * const cache = new RequestStyleCache(); * const html = renderToString( * * * * ); * const css = cache.flushStyles(); */ run(callback: () => T, getClassName?: GetClassNameForKeyFn): Promise<{ returnValue: Awaited; css: string; }>; /** * Given an object of component props, this function splits style props and * component props, turns style props into CSS, and calls `onInsertRule` * for each generated CSS rule. * It returns an object of updated component props. */ getComponentProps(props: Record, classNamePropKey: string): Record | null; } /** * Creates a style cache for client-side use. * * @deprecated Use `new StyleCache()` instead. */ export declare function getStyleCache(options?: StyleCacheOptions): StyleCache; export {}; //# sourceMappingURL=getStyleCache.d.ts.map