import { Wrapper } from '../abstraction/types/abstraction'; import { Delegation, WrapperFunctionDefinition } from '../decorators/wrapper-definition'; /** Represents the metadata for a wrapper object defined by decorators. Use `extractWrapperMetadata()` to retreive. */ export interface WrapperMetadata { /** The constructor of the wrapper. */ type: Function; /** Custom wrapping definitions defined for the wrapper class using the `@NativeObjectWrapper()` decorator. */ definition: {}; /** Map of manually decorated methods for execution outside angular. Structured as a map for O(1) access through the proxy object. */ outsideAngular: { [methodName: string]: Delegation.OutsideAngular; }; } /** * Creates a proxy object trapping calls to the native object held by the wrapper. * Calls are delegated according to delegation rules and definitions. See `@NativeObjectWrapper()` decorator for default behavior. * * @param {Wrapper} wrapper The wrapper which will be used to proxy calls to the native object. * @returns A proxy object delegating calls from the wrapper to the native object according to the rules defined by the library. * See `@NativeObjectWrapper()` decorator for default behavior. */ export declare function createNativeProxy(wrapper: TWrapper): TWrapper; /** * Extracts decorators metadata from a wrapper object. * * @param {Wrapper} wrapper The wrapper object to extract metadata from. * @returns {WrapperMetadata} The metadata defined for that type of wrapper. */ export declare function extractWrapperMetadata(wrapper: Wrapper): WrapperMetadata; /** * Determines how the wrapper method should be executed and returns a function that implements it accordingly. * If the method should be executed outside angular, it will be wrapped and returned. * Otherwise, the method itself will be returned. * * Note: This is defined here and not as a private method of the extending class to avoid exposing it to the object's user. * * @param {Wrapper} wrapper The wrapper object holding the method to execute. * @param {string} methodName The name of the method to delegate. * @param {boolean} outside `true` if the method should be executed outside angular; otherwise `false`. * @returns {Function} A function that will execute the wrapper method by its wrapping definition. */ export declare function delegateWrapperMethod(wrapper: Wrapper, methodName: string, outside: boolean): Function; /** * Determines how the native function should be executed and returns a function that implements it accordingly. * If a wrapping definition is provided for the function, it will be wrapped accordingly. * Otherwise: * - getXXX() functions will be returned as-is. * - setXXX() functions will be wrapped with a function executing outside angular. * - Anything else will be considered as an excluded function and will throw an error. * * Note: This is defined here and not as a private method of the extending class to avoid exposing it to the object's user. * * @template TWrapper The type of wrapper pointing to the native object. * @param {Wrapper} wrapper The wrapper holding the native object. * @param {string} functionName The name of the function to delegate. * @param {WrapperFunctionDefinition} wrappingDef The wrapping definition for the function. * @param {Type} wrapperName The name of the wrapper class. * @returns {Function} A function that will execute the native function by its wrapping definition or by the defined default behaviour. */ export declare function delegateNativeFunction(wrapper: Wrapper, functionName: string, wrappingDef: WrapperFunctionDefinition, wrapperName: string): Function; /** * Wraps the specified function in a function that will execute it outside angular. * * @param {Function} exec The function which actually implements the work to execute. * @param {Wrapper} wrapper The wrapper to bind the function to. * @returns {Function} A wrapping function that will execute the specified function outside angular. */ export declare function delegateOutside(exec: Function, wrapper: Wrapper): Function; /** * Checks whether the given property name matches a setter method name pattern of `set`. * * * @export * @param {string} property The name of the property to evaluate. * @returns {boolean} `true` if the property name matches the setter pattern; otherwise `false`. */ export declare function isSetter(property: string): boolean; /** * Checks whether the given property name matches a getter method name pattern of `get`. * * * @export * @param {string} property The name of the property to evaluate. * @returns {boolean} `true` if the property name matches the getter pattern; otherwise `false`. */ export declare function isGetter(property: string): boolean; /** * Throws the error for method execution attemps of excluded properties on a proxy object with an explanatory message. * * @export * @param {string} wrapperTypeName The name of the wrapper class which was being accessed. * @param {string} property The name of the excluded property which was being accessed. */ export declare function throwExcludedError(wrapperTypeName: string, property: string): void;