import { StateObject } from "./stateObject"; import { StateMatcher } from "./stateMatcher"; import { UrlMatcherFactory } from "../url/urlMatcherFactory"; import { Resolvable } from "../resolve/resolvable"; export declare type BuilderFunction = (state: StateObject, parent?: BuilderFunction) => any; /** * This is a [[StateBuilder.builder]] function for the `resolve:` block on a [[StateDeclaration]]. * * When the [[StateBuilder]] builds a [[StateObject]] object from a raw [[StateDeclaration]], this builder * validates the `resolve` property and converts it to a [[Resolvable]] array. * * resolve: input value can be: * * { * // analyzed but not injected * myFooResolve: function() { return "myFooData"; }, * * // function.toString() parsed, "DependencyName" dep as string (not min-safe) * myBarResolve: function(DependencyName) { return DependencyName.fetchSomethingAsPromise() }, * * // Array split; "DependencyName" dep as string * myBazResolve: [ "DependencyName", function(dep) { return dep.fetchSomethingAsPromise() }, * * // Array split; DependencyType dep as token (compared using ===) * myQuxResolve: [ DependencyType, function(dep) { return dep.fetchSometingAsPromise() }, * * // val.$inject used as deps * // where: * // corgeResolve.$inject = ["DependencyName"]; * // function corgeResolve(dep) { dep.fetchSometingAsPromise() } * // then "DependencyName" dep as string * myCorgeResolve: corgeResolve, * * // inject service by name * // When a string is found, desugar creating a resolve that injects the named service * myGraultResolve: "SomeService" * } * * or: * * [ * new Resolvable("myFooResolve", function() { return "myFooData" }), * new Resolvable("myBarResolve", function(dep) { return dep.fetchSomethingAsPromise() }, [ "DependencyName" ]), * { provide: "myBazResolve", useFactory: function(dep) { dep.fetchSomethingAsPromise() }, deps: [ "DependencyName" ] } * ] */ export declare function resolvablesBuilder(state: StateObject): Resolvable[]; /** * @internalapi A internal global service * * StateBuilder is a factory for the internal [[StateObject]] objects. * * When you register a state with the [[StateRegistry]], you register a plain old javascript object which * conforms to the [[StateDeclaration]] interface. This factory takes that object and builds the corresponding * [[StateObject]] object, which has an API and is used internally. * * Custom properties or API may be added to the internal [[StateObject]] object by registering a decorator function * using the [[builder]] method. */ export declare class StateBuilder { private matcher; /** An object that contains all the BuilderFunctions registered, key'd by the name of the State property they build */ private builders; constructor(matcher: StateMatcher, urlMatcherFactory: UrlMatcherFactory); /** * Registers a [[BuilderFunction]] for a specific [[StateObject]] property (e.g., `parent`, `url`, or `path`). * More than one BuilderFunction can be registered for a given property. * * The BuilderFunction(s) will be used to define the property on any subsequently built [[StateObject]] objects. * * @param name The name of the State property being registered for. * @param fn The BuilderFunction which will be used to build the State property * @returns a function which deregisters the BuilderFunction */ builder(name: string, fn: BuilderFunction): (BuilderFunction | BuilderFunction[] | Function); /** * Builds all of the properties on an essentially blank State object, returning a State object which has all its * properties and API built. * * @param state an uninitialized State object * @returns the built State object */ build(state: StateObject): StateObject; parentName(state: StateObject): string; name(state: StateObject): string; }