UNPKG

4.09 kBSource Map (JSON)View Raw
1{
2 "version": 3,
3 "file": "coreservices.js",
4 "sourceRoot": "",
5 "sources": [
6 "@uirouter/core/common/coreservices.ts"
7 ],
8 "names": [],
9 "mappings": ";;;AAUA,IAAM,MAAM,GAAG,UAAC,MAAc,IAAK,OAAA;IACjC,MAAM,IAAI,KAAK,CAAC,2BAAyB,MAAM,iEAA8D,CAAC,CAAC;AACjH,CAAC,EAFkC,CAElC,CAAC;AAEW,QAAA,QAAQ,GAAG,UAAI,OAAe,EAAE,OAAoB;IAC/D,OAAA,OAAO,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,GAAG,IAAK,OAAA,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAI,OAAO,SAAI,GAAG,OAAI,CAAQ,CAAC,EAAE,GAAG,CAAC,EAAxD,CAAwD,EAAE,EAAO,CAAC;AAA/F,CAA+F,CAAC;AAElG,IAAM,QAAQ,GAAiB;IAC7B,EAAE,EAAE,SAAS;IACb,SAAS,EAAE,SAAS;CACrB,CAAC;AA0EO,4BAAQ",
10 "sourcesContent": [
11 "/**\n * This module is a stub for core services such as Dependency Injection or Browser Location.\n * Core services may be implemented by a specific framework, such as ng1 or ng2, or be pure javascript.\n *\n * @packageDocumentation\n */\nimport { IInjectable, Obj } from './common';\nimport { Disposable } from '../interface';\nimport { UrlConfig, UrlService } from '../url';\n\nconst noImpl = (fnname: string) => () => {\n throw new Error(`No implementation for ${fnname}. The framework specific code did not implement this method.`);\n};\n\nexport const makeStub = <T>(service: string, methods: (keyof T)[]): T =>\n methods.reduce((acc, key) => ((acc[key] = noImpl(`${service}.${key}()`) as any), acc), {} as T);\n\nconst services: CoreServices = {\n $q: undefined,\n $injector: undefined,\n};\n\nexport interface $QLikeDeferred {\n resolve: (val?: any) => void;\n reject: (reason?: any) => void;\n promise: Promise<any>;\n}\n\nexport interface $QLike {\n when<T>(value?: T | PromiseLike<T>): Promise<T>;\n reject<T>(reason: any): Promise<T>;\n defer(): $QLikeDeferred;\n all(promises: { [key: string]: Promise<any> }): Promise<any>;\n all(promises: Promise<any>[]): Promise<any[]>;\n}\n\nexport interface $InjectorLike {\n strictDi?: boolean;\n get(token: any): any;\n get<T>(token: any): T;\n has(token: any): boolean;\n invoke(fn: IInjectable, context?: any, locals?: Obj): any;\n annotate(fn: IInjectable, strictDi?: boolean): any[];\n}\n\nexport interface CoreServices {\n $q: $QLike;\n $injector: $InjectorLike;\n}\n\n/**\n * Handles low level URL read/write\n *\n * This service handles low level reads and updates of the URL and listens for url changes.\n * Implementors should pass these through to the underlying URL mechanism.\n * The underlying URL mechanism might be browser APIs, framework APIs, or some 3rd party URL management library.\n *\n * UI-Router Core includes three basic implementations:\n *\n * - [[PushStateLocationService]]\n * - [[HashLocationService]]\n * - [[MemoryLocationService]]\n */\nexport interface LocationServices extends Disposable {\n /** See: [[UrlService.url]] */ url: UrlService['url'];\n /** See: [[UrlService.path]] */ path: UrlService['path'];\n /** See: [[UrlService.search]] */ search: UrlService['search'];\n /** See: [[UrlService.hash]] */ hash: UrlService['hash'];\n /** See: [[UrlService.onChange]] */ onChange: UrlService['onChange'];\n}\n\n/**\n * Returns low level URL configuration and metadata\n *\n * This service returns information about the location configuration.\n * This service is primarily used when building URLs (e.g., for `hrefs`)\n *\n * Implementors should pass these through to the underlying URL APIs.\n * The underlying URL mechanism might be browser APIs, framework APIs, or some 3rd party URL management library.\n *\n * UI-Router Core includes two basic implementations:\n *\n * - [[BrowserLocationConfig]]\n * - [[MemoryLocationConfig]]\n */\nexport interface LocationConfig extends Disposable {\n /** See: [[UrlConfig.port]] */ port: UrlConfig['port'];\n /** See: [[UrlConfig.protocol]] */ protocol: UrlConfig['protocol'];\n /** See: [[UrlConfig.host]] */ host: UrlConfig['host'];\n /** See: [[UrlConfig.baseHref]] */ baseHref: UrlConfig['baseHref'];\n /** See: [[UrlConfig.html5Mode]] */ html5Mode: UrlConfig['html5Mode'];\n /** See: [[UrlConfig.hashPrefix]] */ hashPrefix: UrlConfig['hashPrefix'];\n}\n\nexport { services };\n"
12 ]
13}
\No newline at end of file