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,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,eAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxE,CAAC;IACH,eAAC;AAAD,CAAC,AAjLD,IAiLC;AAjLY,4BAAQ",
10 "sourcesContent": [
11 "import { UrlMatcherFactory } from './url/urlMatcherFactory';\nimport { UrlRouter } from './url/urlRouter';\nimport { TransitionService } from './transition/transitionService';\nimport { ViewService } from './view/view';\nimport { StateRegistry } from './state/stateRegistry';\nimport { StateService } from './state/stateService';\nimport { UIRouterGlobals } from './globals';\nimport { UIRouterPlugin, Disposable } from './interface';\nimport { values, removeFrom } from './common/common';\nimport { isFunction } from './common/predicates';\nimport { UrlService } from './url/urlService';\nimport { LocationServices, LocationConfig } from './common/coreservices';\nimport { Trace, trace } from './common/trace';\nimport { makeStub } from './common';\n\n/** @internal */\nlet _routerInstance = 0;\n\n/** @internal */\nconst locSvcFns: (keyof LocationServices)[] = ['url', 'path', 'search', 'hash', 'onChange'];\n/** @internal */\nconst locCfgFns: (keyof LocationConfig)[] = ['port', 'protocol', 'host', 'baseHref', 'html5Mode', 'hashPrefix'];\n/** @internal */\nconst locationServiceStub = makeStub<LocationServices>('LocationServices', locSvcFns);\n/** @internal */\nconst locationConfigStub = makeStub<LocationConfig>('LocationConfig', locCfgFns);\n\n/**\n * An instance of UI-Router.\n *\n * This object contains references to service APIs which define your application's routing behavior.\n */\nexport class UIRouter {\n /** @internal */ $id = _routerInstance++;\n /** @internal */ _disposed = false;\n /** @internal */ private _disposables: Disposable[] = [];\n\n /** Enable/disable tracing to the javascript console */\n trace: Trace = trace;\n\n /** Provides services related to ui-view synchronization */\n viewService = new ViewService(this);\n\n /** An object that contains global router state, such as the current state and params */\n globals: UIRouterGlobals = new UIRouterGlobals();\n\n /** A service that exposes global Transition Hooks */\n transitionService: TransitionService = new TransitionService(this);\n\n /**\n * Deprecated for public use. Use [[urlService]] instead.\n * @deprecated Use [[urlService]] instead\n */\n urlMatcherFactory: UrlMatcherFactory = new UrlMatcherFactory(this);\n\n /**\n * Deprecated for public use. Use [[urlService]] instead.\n * @deprecated Use [[urlService]] instead\n */\n urlRouter: UrlRouter = new UrlRouter(this);\n\n /** Provides services related to the URL */\n urlService: UrlService = new UrlService(this);\n\n /** Provides a registry for states, and related registration services */\n stateRegistry: StateRegistry = new StateRegistry(this);\n\n /** Provides services related to states */\n stateService = new StateService(this);\n\n /** @internal plugin instances are registered here */\n private _plugins: { [key: string]: UIRouterPlugin } = {};\n\n /** Registers an object to be notified when the router is disposed */\n disposable(disposable: Disposable) {\n this._disposables.push(disposable);\n }\n\n /**\n * Disposes this router instance\n *\n * When called, clears resources retained by the router by calling `dispose(this)` on all\n * registered [[disposable]] objects.\n *\n * Or, if a `disposable` object is provided, calls `dispose(this)` on that object only.\n *\n * @internal\n * @param disposable (optional) the disposable to dispose\n */\n dispose(disposable?: any): void {\n if (disposable && isFunction(disposable.dispose)) {\n disposable.dispose(this);\n return undefined;\n }\n\n this._disposed = true;\n this._disposables.slice().forEach((d) => {\n try {\n typeof d.dispose === 'function' && d.dispose(this);\n removeFrom(this._disposables, d);\n } catch (ignored) {}\n });\n }\n\n /**\n * Creates a new `UIRouter` object\n *\n * @param locationService a [[LocationServices]] implementation\n * @param locationConfig a [[LocationConfig]] implementation\n * @internal\n */\n constructor(\n public locationService: LocationServices = locationServiceStub,\n public locationConfig: LocationConfig = locationConfigStub\n ) {\n this.viewService._pluginapi._rootViewContext(this.stateRegistry.root());\n this.globals.$current = this.stateRegistry.root();\n this.globals.current = this.globals.$current.self;\n\n this.disposable(this.globals);\n this.disposable(this.stateService);\n this.disposable(this.stateRegistry);\n this.disposable(this.transitionService);\n this.disposable(this.urlService);\n this.disposable(locationService);\n this.disposable(locationConfig);\n }\n\n /** Add plugin (as ES6 class) */\n plugin<T extends UIRouterPlugin>(plugin: { new (router: UIRouter, options?: any): T }, options?: any): T;\n /** Add plugin (as javascript constructor function) */\n plugin<T extends UIRouterPlugin>(plugin: { (router: UIRouter, options?: any): void }, options?: any): T;\n /** Add plugin (as javascript factory function) */\n plugin<T extends UIRouterPlugin>(plugin: PluginFactory<T>, options?: any): T;\n /**\n * Adds a plugin to UI-Router\n *\n * This method adds a UI-Router Plugin.\n * A plugin can enhance or change UI-Router behavior using any public API.\n *\n * #### Example:\n * ```js\n * import { MyCoolPlugin } from \"ui-router-cool-plugin\";\n *\n * var plugin = router.addPlugin(MyCoolPlugin);\n * ```\n *\n * ### Plugin authoring\n *\n * A plugin is simply a class (or constructor function) which accepts a [[UIRouter]] instance and (optionally) an options object.\n *\n * The plugin can implement its functionality using any of the public APIs of [[UIRouter]].\n * For example, it may configure router options or add a Transition Hook.\n *\n * The plugin can then be published as a separate module.\n *\n * #### Example:\n * ```js\n * export class MyAuthPlugin implements UIRouterPlugin {\n * constructor(router: UIRouter, options: any) {\n * this.name = \"MyAuthPlugin\";\n * let $transitions = router.transitionService;\n * let $state = router.stateService;\n *\n * let authCriteria = {\n * to: (state) => state.data && state.data.requiresAuth\n * };\n *\n * function authHook(transition: Transition) {\n * let authService = transition.injector().get('AuthService');\n * if (!authService.isAuthenticated()) {\n * return $state.target('login');\n * }\n * }\n *\n * $transitions.onStart(authCriteria, authHook);\n * }\n * }\n * ```\n *\n * @param plugin one of:\n * - a plugin class which implements [[UIRouterPlugin]]\n * - a constructor function for a [[UIRouterPlugin]] which accepts a [[UIRouter]] instance\n * - a factory function which accepts a [[UIRouter]] instance and returns a [[UIRouterPlugin]] instance\n * @param options options to pass to the plugin class/factory\n * @returns the registered plugin instance\n */\n plugin<T extends UIRouterPlugin>(plugin: any, options: any = {}): T {\n const pluginInstance = new plugin(this, options);\n if (!pluginInstance.name) throw new Error('Required property `name` missing on plugin: ' + pluginInstance);\n this._disposables.push(pluginInstance);\n return (this._plugins[pluginInstance.name] = pluginInstance);\n }\n\n /**\n * Returns a plugin registered with the given `pluginName`.\n *\n * @param pluginName the name of the plugin to get\n * @return the plugin, or undefined\n */\n getPlugin(pluginName: string): UIRouterPlugin;\n /**\n * Returns all registered plugins\n * @return all registered plugins\n */\n getPlugin(): UIRouterPlugin[];\n getPlugin(pluginName?: string): UIRouterPlugin | UIRouterPlugin[] {\n return pluginName ? this._plugins[pluginName] : values(this._plugins);\n }\n}\n\n/** @internal */\nexport type PluginFactory<T> = (router: UIRouter, options?: any) => T;\n"
12 ]
13}
\No newline at end of file