import { IIndexable } from '@aurelia/kernel'; import type { CollectionLengthObserver, CollectionSizeObserver } from './collection-length-observer'; export declare const ICoercionConfiguration: import("@aurelia/kernel").InterfaceSymbol; export interface ICoercionConfiguration { /** When set to `true`, enables the automatic type-coercion for bindables globally. */ enableCoercion: boolean; /** When set to `true`, coerces the `null` and `undefined` values to the target types. This is ineffective when `disableCoercion` is set to `true.` */ coerceNullish: boolean; } export type InterceptorFunc = (value: TInput, coercionConfig?: ICoercionConfiguration) => TOutput; export interface IConnectable { observe(obj: object, key: PropertyKey): void; observeExpression(obj: object, expression: string): void; observeCollection(obj: Collection): void; subscribeTo(subscribable: ISubscribable | ICollectionSubscribable): void; } export interface IDirtySubscriber { handleDirty(): void; } /** * Interface of a subscriber or property change handler */ export interface ISubscriber extends Partial { handleChange(newValue: TValue, previousValue: TValue): void; } /** * Interface of a collection subscriber or mutation handler */ export interface ICollectionSubscriber { handleCollectionChange(collection: Collection, indexMap: IndexMap): void; } export interface ISubscribable { subscribe(subscriber: T): void; unsubscribe(subscriber: T): void; } export interface ICollectionSubscribable { subscribe(subscriber: ICollectionSubscriber): void; unsubscribe(subscriber: ICollectionSubscriber): void; } /** * An interface describing the contract of a subscriber list, * with the ability to propagate values to those subscribers */ export interface ISubscriberRecord { readonly count: number; add(subscriber: T): boolean; remove(subscriber: T): boolean; notify(value: unknown, oldValue: unknown): void; notifyCollection(collection: Collection, indexMap: IndexMap): void; notifyDirty(): void; } /** * An internal interface describing the implementation of a ISubscribable of Aurelia that supports batching * * This is usually mixed into a class via the import `subscriberCollection` import from Aurelia. * The `subscriberCollection` import can be used as either a decorator, or a function call. */ export interface ISubscriberCollection extends ISubscribable { /** * The backing subscriber record for all subscriber methods of this collection */ readonly subs: ISubscriberRecord; } /** * An internal interface describing the implementation of a ICollectionSubscribable of Aurelia that supports batching * * This is usually mixed into a class via the import `subscriberCollection` import from Aurelia. * The `subscriberCollection` import can be used as either a decorator, or a function call. */ export interface ICollectionSubscriberCollection extends ICollectionSubscribable { /** * The backing subscriber record for all subscriber methods of this collection */ readonly subs: ISubscriberRecord; } /** * A collection (array, set or map) */ export type Collection = unknown[] | Set | Map; export type CollectionKind = 'indexed' | 'keyed' | 'array' | 'map' | 'set'; export type LengthPropertyName = T extends unknown[] ? 'length' : T extends Set ? 'size' : T extends Map ? 'size' : never; export type CollectionKindToType = T extends 'array' ? unknown[] : T extends 'indexed' ? unknown[] : T extends 'map' ? Map : T extends 'set' ? Set : T extends 'keyed' ? Set | Map : never; export type ObservedCollectionKindToType = T extends 'array' ? unknown[] : T extends 'indexed' ? unknown[] : T extends 'map' ? Map : T extends 'set' ? Set : T extends 'keyed' ? Map | Set : never; export declare const AccessorType: Readonly<{ readonly None: 0; readonly Observer: 1; readonly Node: 2; readonly Layout: 4; }>; export type AccessorType = typeof AccessorType[keyof typeof AccessorType]; /** * Basic interface to normalize getting/setting a value of any property on any object */ export interface IAccessor { type: AccessorType; getValue(obj?: object, key?: PropertyKey): TValue; setValue(newValue: TValue, obj?: object, key?: PropertyKey): void; } /** * An interface describing a standard contract of an observer in Aurelia binding & observation system */ export interface IObserver extends IAccessor, ISubscribable { doNotCache?: boolean; useCallback?(callback: (newValue: TValue, oldValue: TValue) => void): boolean; useCoercer?(coercer: InterceptorFunc, coercionConfig?: ICoercionConfiguration): boolean; useFlush?(flush: 'sync' | 'async'): boolean; } export type AccessorOrObserver = (IAccessor | IObserver) & { doNotCache?: boolean; }; /** * An array of indices, where the index of an element represents the index to map FROM, and the numeric value of the element itself represents the index to map TO * * The deletedIndices property contains the items (in case of an array) or keys (in case of map or set) that have been deleted. */ export type IndexMap = number[] & { deletedIndices: number[]; deletedItems: T[]; isIndexMap: true; }; export declare const hasChanges: (indexMap: IndexMap) => boolean; export declare function copyIndexMap(existing: number[] & { deletedIndices?: number[]; deletedItems?: T[]; }, deletedIndices?: number[], deletedItems?: T[]): IndexMap; export declare function createIndexMap(length?: number): IndexMap; export declare function cloneIndexMap(indexMap: IndexMap): IndexMap; export declare function isIndexMap(value: unknown): value is IndexMap; /** * Describes a type that specifically tracks changes in a collection (map, set or array) */ export interface ICollectionChangeTracker { collection: T; indexMap: IndexMap; } /** * An observer that tracks collection mutations and notifies subscribers (either directly or in batches) */ export interface ICollectionObserver extends ICollectionChangeTracker>, ICollectionSubscribable { type: AccessorType; collection: ObservedCollectionKindToType; getLengthObserver(): T extends 'array' ? CollectionLengthObserver : CollectionSizeObserver; notify(): void; } export type CollectionObserver = ICollectionObserver; export type IObservable = T & { $observers?: IIndexable<{}, AccessorOrObserver>; }; //# sourceMappingURL=interfaces.d.ts.map