/** * Cross-environment deprecation utilities for the Rayfin SDK. * * `@microsoft/rayfin-lib` is universal: it runs in browsers, Node, and workers. * That rules out Node's `util.deprecate` / `process.emitWarning` (Node-only), so * this module provides a browser-safe equivalent inspired by `util.deprecate`. * * One shared emit path ({@link deprecate}) handles message formatting, dedupe by * a stable `code`, and silencing. {@link deprecateFn} and {@link deprecateField} * are thin call-shapes on top of it for deprecated methods and properties. */ /** * Options shared by every deprecation call-shape. * * @internal */ export interface DeprecateOptions { /** * Emit at most once per `code` (default `true`). When `false`, the warning * fires on every call and the `code` is never recorded in the dedupe set. */ once?: boolean; } /** * Whether deprecation warnings are currently silenced. * * Precedence: an explicit {@link setDeprecationsSilenced} override wins; otherwise * the `RAYFIN_NO_DEPRECATION` environment variable (`'1'` or `'true'`, * case-insensitive) silences; otherwise warnings are emitted. */ export declare function isDeprecationSilenced(): boolean; /** * Programmatically silence or unsilence all deprecation warnings. This override * takes precedence over the `RAYFIN_NO_DEPRECATION` environment variable and is * the browser-safe way to quiet warnings. * * @param silenced - `true` to suppress all deprecation warnings, `false` to re-enable them. */ export declare function setDeprecationsSilenced(silenced: boolean): void; /** * Emit a `[rayfin]`-prefixed deprecation warning via `console.warn`. * * This is the consumption-site call-shape: invoke it where a deprecated config * field is read (detect that the consumer set it, e.g. `field !== undefined`, * rather than testing truthiness). {@link deprecateFn} and {@link deprecateField} * delegate here so formatting, dedupe, and silencing live in one place. * * @param code - Stable identifier (e.g. `RAYFIN_DEP_USE_PROXY`) used for dedupe and * appended to the message so warnings are greppable/filterable. * @param message - Human-readable explanation of what is deprecated and the migration. * @param options - See {@link DeprecateOptions}. * @internal */ export declare function deprecate(code: string, message: string, options?: DeprecateOptions): void; /** * Cross-environment equivalent of Node's `util.deprecate` for deprecated * *methods*: wraps `fn` so the warning fires when it is called, returning a * function with the same signature. Preserves arguments, `this`, and the return * value. * * @param fn - The function to wrap. * @param code - Stable dedupe/identification code. * @param message - Human-readable deprecation message. * @param options - See {@link DeprecateOptions}. * @internal */ export declare function deprecateFn unknown>(fn: F, code: string, message: string, options?: DeprecateOptions): F; /** * Redefine a deprecated property on an object/instance *you own* as an accessor * that warns on get and set while preserving the underlying value. * * ⚠️ Use this only for objects the SDK constructs and hands back to consumers. * Do not trap fields on a config bag the consumer builds: that would mutate their * object and make the warning depend on property access order. For deprecated * config fields, call {@link deprecate} at the consumption site instead. * * @param obj - The object whose property is deprecated. * @param key - The deprecated property key. * @param code - Stable dedupe/identification code. * @param message - Human-readable deprecation message. * @param options - See {@link DeprecateOptions}. * @internal */ export declare function deprecateField(obj: T, key: K, code: string, message: string, options?: DeprecateOptions): void; /** * Clear emitted-code memory and the programmatic silence override. * * Test-only helper; intentionally NOT exported from the package index. Tests * import it directly from this module. */ export declare function __resetDeprecationsForTesting(): void; //# sourceMappingURL=deprecation.d.ts.map