/** * MT-side derived SharedValue registry (#710). * * A *derived* SharedValue is computed on the Main Thread from one or more * SOURCE SharedValues via a NAMED reducer (`max` / `min` / `sum` / `scale`). * It exists to compose SVs without the silent-summation footgun: two * `translateY` bindings on one element CONCATENATE (so they SUM — see * `animated-bridge-mt.ts`), which is wrong for "sit above whichever of the * keyboard or the sheet is taller". `useDerivedValue([kbLift, sheetH], 'max')` * yields ONE SV a single `translateY` binds — the max, not the sum. * * Reducers are selected by NAME, mirroring the mapper registry: a string is a * primitive the BG→MT op layer ships trivially, whereas an arbitrary reducer * function can't be captured into the flush loop (the loop is plain MT code, * not a worklet). Custom reducers register via `registerReducer`. * * `flushDerivedValues()` runs FIRST inside the wrapped `__FlushElementTree` * (before publishes and style bindings): for each derived whose sources * changed since the last compute, it folds the live source values through the * reducer and writes the result onto the derived SV's envelope. Because that * write lands before `flushAnimatedStyleBindings`, a `useAnimatedStyle` bound * to the derived sees the fresh value the SAME frame; because the derived SV * is itself a registered auto-flush bridge, `flushAvBridgePublishes` also * ships the new value to BG. */ import type { DerivedReducer } from '@sigx/lynx-runtime-internal'; /** Look up a reducer by name; `undefined` → the derived recompute is skipped. */ export declare function lookupReducer(name: string): DerivedReducer | undefined; /** Register a custom MT-side reducer (last write wins per name). */ export declare function registerReducer(name: string, reducer: DerivedReducer): void; /** Reset hook — restore exactly the built-ins (drops custom reducers AND * any that overrode a built-in name) for HMR / tests. */ export declare function resetReducers(): void; /** * Register (or, for the same `derivedWvid`, RE-register) a derived value. * Re-registration swaps the reducer/params/sources while keeping the derived * SV identity — this is how a reactive factor (e.g. the active sheet's travel) * rebinds without breaking the consumers already bound to the derived SV. */ export declare function registerDerivedValue(derivedWvid: number, reducerName: string, params: unknown, sourceWvids: number[]): void; export declare function unregisterDerivedValue(derivedWvid: number): void; export declare function resetDerivedValues(): void; export declare function derivedValueCount(): number; /** * Recompute every derived whose source values changed since the last flush, * writing the result onto the derived SV's envelope. Runs before the style * bindings and the BG publish so downstream consumers see the fresh value the * same frame. Skip cases are silent: a missing source/derived envelope (race * with unregister) or an unknown reducer name. */ export declare function flushDerivedValues(): void;