import { WeakMapSet } from "./Util"; export type ObjKey = string | symbol; export declare abstract class RecordedRead { abstract equals(other: RecordedRead): boolean; abstract get isChanged(): boolean; /** * * @param listener * @param trackOriginal true to install a tracker on the non-proxied- (by this facade) original object */ abstract onAfterChange(listener: () => void, trackOriginal?: boolean): void; abstract offAfterChange(listener: () => void): void; } export type AfterReadListener = (read: RecordedRead) => void; export type Clazz = { new (...args: any[]): unknown; }; export type GetIteratorValueProxiedFn = (value: T) => T; export type IteratorReturningProxiedValue = Iterator & { _getValueProxied: GetIteratorValueProxiedFn; }; /** * A change operation that may later be serializable. Beeing able to store it in the transaction protocol of membrace-db. Or to syncronize live objects between server->client */ export declare abstract class ChangeOperation { /** * Saved inputs as arguments for the do function */ inputs?: Parameters; abstract _do(...inputs: unknown[]): { result: unknown; undoInfo: unknown; }; _unDo(undoInfo: ReturnType["undoInfo"]): void; constructor(); withInputs(...inputs: Parameters): this; do(): ReturnType["undoInfo"]; } export declare function registerChangeOperationClass(clazz: typeof ChangeOperation): void; export type ChangeListener = (change: ChangeOperation) => void; /** * Registry for one possible potential target event type. I.e. a property of a certain object, or a more abstract one like: "some key of a certain object has changed". */ export declare class EventHook { /** * Called before the change * @param change */ beforeListeners: Set; /** * Called after the change * @param change */ afterListeners: Set; /** * To be able to easily control the before and after for exactly the same change. It's an idea / no good use case found yet. * @param change * @param doChange */ fireBefore(change: ChangeOperation): void; fireAfter(change: ChangeOperation): void; } /** * Like Object.getOwnPropertyDescriptor. But for all parent classes * @param o * @param p */ export declare function getPropertyDescriptor(o: object, p: PropertyKey): PropertyDescriptor | undefined; export type GetterFlags = { origHadGetter?: boolean; }; export type SetterFlags = { origHadSetter?: boolean; }; export declare function checkEsRuntimeBehaviour(): void; /** * Configures tracking behaviour for a certain class */ export declare abstract class ClassTrackingConfiguration { /** * For which is this config? */ abstract clazz: Clazz; worksForSubclasses: boolean; readTracker?: Clazz; changeTracker?: Clazz; /** * Built-in Methods, which are using fields / calling methods on the proxy transparently/loyally, so those methods don't call/use internal stuff directly. * Tested with, see dev_generateEsRuntimeBehaviourCheckerCode.ts * May include read-only / reader methods */ knownHighLevelMethods: Set; /** * Non-high level. These fire `RecordedUnspecificRead`s then. So better implement them instead to fire i.e RecordedArrayValuesRead. */ readOnlyMethods: Set; /** * Non-high level. Same as above: better implement them */ readOnlyFields: Set; /** * Default, if not listed as high-level method */ receiverMustBeNonProxied: boolean; /** * Makes the WatchedProxyFacade's handler also track/fire reads for methods that are not **directly** in the this.readTracker class. */ trackTreads: boolean; /** * (For Array:) Flags to track setting properties, meaning changes are not only done by calling methods. This will use a Proxy (install a Proxy as Prototype). */ trackSettingObjectProperties: boolean; /** * Wrap the results of methods which are not in the readTracker or changeTracker in proxies * Take caution when enabling this. It is not always a good idea. I.e. Map#entries() return new intermediates arrays [] and these will then also be proxied and result in a false positive something-has-changed detection when comparing recorded Reads. */ proxyUnhandledMethodResults: boolean; /** * Lists read and changeTracker as far as they're present */ getTrackerClasses(): Clazz[]; } export declare function recordedReadsArraysAreEqual(a: RecordedRead[], b: RecordedRead[]): boolean; /** * Patches the iterator so it runs the value through the translateFn * @param iterator * @param translateFn */ export declare function makeIteratorTranslateValue>(iterator: IT, translateFn: (value: V) => V): IT; /** * Base for ProxyFacades and change-tracking of original objects (without proxy facades) See {@see changeTrackedOriginaObjects the changeTrackedOriginaObjects global instance} */ export declare class PartialGraph { /** * True means, it spreads it's self when members are read or set. Not yet implemented for non-proxy-facades. * Always true for proxy-facade subclasses (that's their job). */ viral: boolean; /** * Called after a change has been made to any object inside this graph * Note: There are also listeners for specified properties/situations (which are more capable) * @protected */ _changeHook: EventHook; /** * * @param listener Called when a change is made to any object inside this graph. * The listener is called when the change is not yet written unlike {@see onAfterChange}. So throwing an exception in the listener will prevent the actual change from happening. */ onBeforeChange(listener: ChangeListener): void; /** * Unregister listener from {@see PartialGraph#onBeforeChange} * @param listener */ offBeforeChange(listener: ChangeListener): void; /** * * @param listener Called after a change has been made to any object inside this graph */ onAfterChange(listener: ChangeListener): void; /** * Unregister listener from {@see PartialGraph#onAfterChange} * @param listener */ offAfterChange(listener: ChangeListener): void; hasObj(obj: object): boolean | undefined; _register(obj: object): void; _unregister(obj: object): void; } export declare const objectMembershipInGraphs: WeakMapSet; /** * TODO: Implement subclasses */ export declare class UnspecificObjectChange extends ChangeOperation { constructor(target?: object); _do(...inputs: unknown[]): { result: undefined; undoInfo: undefined; }; _unDo(undoInfo: ReturnType["undoInfo"]): void; } //# sourceMappingURL=common.d.ts.map