import { YjsProxiableValue } from './types'; /** * Transaction mode for `withYjsProxy`. * - `'auto'`: Synchronous only, wrapped in Yjs transaction. * - `'manual'`: Synchronous and async support, external change detection. */ export type TransactionMode = "auto" | "manual"; /** * Options for auto transaction mode. */ export interface AutoModeOptions { transactionMode?: "auto"; /** Custom transaction origin (auto-generated symbol if not provided) */ origin?: unknown; /** If true, rolls back Y.js changes if the callback throws. Default: false */ rollbackOnError?: boolean; } /** * Options for manual transaction mode. */ export interface ManualModeOptions { transactionMode: "manual"; /** Custom transaction origin (auto-generated symbol if not provided) */ origin?: unknown; /** If true, rolls back Y.js changes if the callback throws. Default: false */ rollbackOnError?: boolean; } /** * Context provided to callbacks in manual transaction mode. */ export interface ManualModeContext { /** * Wraps operations in a Yjs transaction with the scope's origin. * Use to batch multiple changes into a single transaction. */ transact: (fn: () => R) => R; /** * Returns `true` if external Yjs changes were detected and proxies were invalidated. */ isProxyInvalidated: () => boolean; } /** * Checks if we are currently inside a `withYjsProxy` scope. * @internal */ export declare function isInScope(): boolean; /** * Gets the current scope's transaction origin, or undefined if not in a scope. * @internal */ export declare function getScopeOrigin(): unknown; /** * Registers a revocable proxy for the current scope. * When the scope ends, the revoke function will be called. * @internal */ export declare function registerRevocableProxy(proxy: object, revoke: () => void): void; /** * Provides scoped access to a Yjs value as a proxy. * Auto mode: synchronous only, wrapped in Yjs transaction. */ export declare function withYjsProxy(yValue: YjsProxiableValue, callback: (proxy: Draft) => void, options?: AutoModeOptions): void; /** * Manual mode: synchronous callback with context. */ export declare function withYjsProxy(yValue: YjsProxiableValue, callback: (proxy: Draft, ctx: ManualModeContext) => void, options: ManualModeOptions): void; /** * Manual mode: async callback with context. */ export declare function withYjsProxy(yValue: YjsProxiableValue, callback: (proxy: Draft, ctx: ManualModeContext) => Promise, options: ManualModeOptions): Promise; /** * Auto mode with multiple values. */ export declare function withYjsProxy(yValues: readonly YjsProxiableValue[], callback: (proxies: Draft) => void, options?: AutoModeOptions): void; /** * Manual mode with multiple values: synchronous callback. */ export declare function withYjsProxy(yValues: readonly YjsProxiableValue[], callback: (proxies: Draft, ctx: ManualModeContext) => void, options: ManualModeOptions): void; /** * Manual mode with multiple values: async callback. */ export declare function withYjsProxy(yValues: readonly YjsProxiableValue[], callback: (proxies: Draft, ctx: ManualModeContext) => Promise, options: ManualModeOptions): Promise;