|
1 | 1 | /**
|
2 | 2 | * Naive, pure JS implementation of core ui-router services
|
3 | 3 | *
|
4 |
| - * @module vanilla |
| 4 | + * @internalapi @module vanilla |
5 | 5 | */ /** */
|
6 | 6 | import { UIRouter } from "../router";
|
7 | 7 |
|
8 |
| -import { services as coreservices } from "../common/coreservices"; |
| 8 | +import { services, LocationServices, LocationConfig } from "../common/coreservices"; |
| 9 | +import { LocationPlugin, ServicesPlugin } from "./interface"; |
| 10 | +import { extend } from "../common/common"; |
| 11 | +import { hashLocationService, hashLocationConfig } from "./hashLocation"; |
| 12 | +import { pushStateLocationService, pushStateLocationConfig } from "./pushStateLocation"; |
9 | 13 | import { $q } from "./$q";
|
10 | 14 | import { $injector } from "./$injector";
|
11 |
| -import { hashHistory } from "./hashHistory"; |
12 |
| -import { browserHistory } from "./browserHistory"; |
13 |
| -import { HistoryImplementationPlugin, ServicesPlugin, HistoryImplementation } from "./interface"; |
14 |
| -import { extend } from "../common/common"; |
15 | 15 |
|
16 |
| -export { $q, $injector, hashHistory, browserHistory }; |
| 16 | +export { $q, $injector }; |
17 | 17 |
|
18 |
| -export function services(router: UIRouter): ServicesPlugin { |
19 |
| - coreservices.$injector = $injector; |
20 |
| - coreservices.$q = $q; |
| 18 | +export function servicesPlugin(router: UIRouter): ServicesPlugin { |
| 19 | + services.$injector = $injector; |
| 20 | + services.$q = $q; |
21 | 21 |
|
22 | 22 | return { name: "vanilla.services", $q, $injector };
|
23 | 23 | }
|
24 | 24 |
|
25 |
| -const HistoryImplementationPluginFactory = (name: string, historyImpl: HistoryImplementation) => |
| 25 | +const locationPluginFactory = (name: string, service: LocationServices, configuration: LocationConfig) => |
26 | 26 | (router: UIRouter) => {
|
27 |
| - const { service, configuration } = historyImpl; |
28 |
| - extend(coreservices.location, service); |
29 |
| - extend(coreservices.locationConfig, configuration); |
30 |
| - |
| 27 | + extend(services.location, service); |
| 28 | + extend(services.locationConfig, configuration); |
31 | 29 | return { name, service, configuration };
|
32 | 30 | };
|
33 | 31 |
|
34 |
| -export const hashLocation: (router: UIRouter) => HistoryImplementationPlugin = |
35 |
| - HistoryImplementationPluginFactory("vanilla.hashBangLocation", hashHistory); |
36 |
| -export const pushStateLocation: (router: UIRouter) => HistoryImplementationPlugin = |
37 |
| - HistoryImplementationPluginFactory("vanilla.pushStateLocation", browserHistory); |
| 32 | +export const hashLocationPlugin: (router: UIRouter) => LocationPlugin = |
| 33 | + locationPluginFactory("vanilla.hashBangLocation", hashLocationService, hashLocationConfig); |
| 34 | + |
| 35 | +export const pushStateLocationPlugin: (router: UIRouter) => LocationPlugin = |
| 36 | + locationPluginFactory("vanilla.pushStateLocation", pushStateLocationService, pushStateLocationConfig); |
38 | 37 |
|
0 commit comments