UNPKG

4.28 kBTypeScriptView Raw
1/**
2 * @coreapi
3 * @module core
4 */ /** */
5import { UrlMatcherFactory } from "./url/urlMatcherFactory";
6import { UrlRouter } from "./url/urlRouter";
7import { TransitionService } from "./transition/transitionService";
8import { ViewService } from "./view/view";
9import { StateRegistry } from "./state/stateRegistry";
10import { StateService } from "./state/stateService";
11import { UIRouterGlobals } from "./globals";
12import { UIRouterPlugin, Disposable } from "./interface";
13import { UrlService } from "./url/urlService";
14import { LocationServices, LocationConfig } from "./common/coreservices";
15import { Trace } from "./common/trace";
16/**
17 * The master class used to instantiate an instance of UI-Router.
18 *
19 * UI-Router (for each specific framework) will create an instance of this class during bootstrap.
20 * This class instantiates and wires the UI-Router services together.
21 *
22 * After a new instance of the UIRouter class is created, it should be configured for your app.
23 * For instance, app states should be registered with the [[UIRouter.stateRegistry]].
24 *
25 * ---
26 *
27 * Normally the framework code will bootstrap UI-Router.
28 * If you are bootstrapping UIRouter manually, tell it to monitor the URL by calling
29 * [[UrlService.listen]] then [[UrlService.sync]].
30 */
31export declare class UIRouter {
32 locationService: LocationServices;
33 locationConfig: LocationConfig;
34 /** @hidden */ $id: number;
35 /** @hidden */ _disposed: boolean;
36 /** @hidden */ private _disposables;
37 /** Provides trace information to the console */
38 trace: Trace;
39 /** Provides services related to ui-view synchronization */
40 viewService: ViewService;
41 /** Provides services related to Transitions */
42 transitionService: TransitionService;
43 /** Global router state */
44 globals: UIRouterGlobals;
45 /**
46 * Deprecated for public use. Use [[urlService]] instead.
47 * @deprecated Use [[urlService]] instead
48 */
49 urlMatcherFactory: UrlMatcherFactory;
50 /**
51 * Deprecated for public use. Use [[urlService]] instead.
52 * @deprecated Use [[urlService]] instead
53 */
54 urlRouter: UrlRouter;
55 /** Provides a registry for states, and related registration services */
56 stateRegistry: StateRegistry;
57 /** Provides services related to states */
58 stateService: StateService;
59 /** Provides services related to the URL */
60 urlService: UrlService;
61 /** Registers an object to be notified when the router is disposed */
62 disposable(disposable: Disposable): void;
63 /**
64 * Disposes this router instance
65 *
66 * When called, clears resources retained by the router by calling `dispose(this)` on all
67 * registered [[disposable]] objects.
68 *
69 * Or, if a `disposable` object is provided, calls `dispose(this)` on that object only.
70 *
71 * @param disposable (optional) the disposable to dispose
72 */
73 dispose(disposable?: any): void;
74 /**
75 * Creates a new `UIRouter` object
76 *
77 * @param locationService a [[LocationServices]] implementation
78 * @param locationConfig a [[LocationConfig]] implementation
79 * @internalapi
80 */
81 constructor(locationService?: LocationServices, locationConfig?: LocationConfig);
82 /** @hidden */
83 private _plugins;
84 /** Add plugin (as ES6 class) */
85 plugin<T extends UIRouterPlugin>(plugin: {
86 new (router: UIRouter, options?: any): T;
87 }, options?: any): T;
88 /** Add plugin (as javascript constructor function) */
89 plugin<T extends UIRouterPlugin>(plugin: {
90 (router: UIRouter, options?: any): void;
91 }, options?: any): T;
92 /** Add plugin (as javascript factory function) */
93 plugin<T extends UIRouterPlugin>(plugin: PluginFactory<T>, options?: any): T;
94 /**
95 * Returns registered plugins
96 *
97 * Returns the registered plugin of the given `pluginName`.
98 * If no `pluginName` is given, returns all registered plugins
99 *
100 * @param pluginName (optional) the name of the plugin to get
101 * @return the named plugin (undefined if not found), or all plugins (if `pluginName` is omitted)
102 */
103 getPlugin(pluginName: string): UIRouterPlugin;
104 getPlugin(): UIRouterPlugin[];
105}
106/** @internalapi */
107export declare type PluginFactory<T> = (router: UIRouter, options?: any) => T;