source: trip-planner-front/node_modules/@angular/common/esm2015/upgrade/src/location_upgrade_module.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 11.7 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { APP_BASE_HREF, CommonModule, HashLocationStrategy, Location, LocationStrategy, PathLocationStrategy, PlatformLocation } from '@angular/common';
9import { Inject, InjectionToken, NgModule, Optional } from '@angular/core';
10import { UpgradeModule } from '@angular/upgrade/static';
11import { $locationShim, $locationShimProvider } from './location_shim';
12import { AngularJSUrlCodec, UrlCodec } from './params';
13/**
14 * A provider token used to configure the location upgrade module.
15 *
16 * @publicApi
17 */
18export const LOCATION_UPGRADE_CONFIGURATION = new InjectionToken('LOCATION_UPGRADE_CONFIGURATION');
19const APP_BASE_HREF_RESOLVED = new InjectionToken('APP_BASE_HREF_RESOLVED');
20/**
21 * `NgModule` used for providing and configuring Angular's Unified Location Service for upgrading.
22 *
23 * @see [Using the Unified Angular Location Service](guide/upgrade#using-the-unified-angular-location-service)
24 *
25 * @publicApi
26 */
27export class LocationUpgradeModule {
28 static config(config) {
29 return {
30 ngModule: LocationUpgradeModule,
31 providers: [
32 Location,
33 {
34 provide: $locationShim,
35 useFactory: provide$location,
36 deps: [UpgradeModule, Location, PlatformLocation, UrlCodec, LocationStrategy]
37 },
38 { provide: LOCATION_UPGRADE_CONFIGURATION, useValue: config ? config : {} },
39 { provide: UrlCodec, useFactory: provideUrlCodec, deps: [LOCATION_UPGRADE_CONFIGURATION] },
40 {
41 provide: APP_BASE_HREF_RESOLVED,
42 useFactory: provideAppBaseHref,
43 deps: [LOCATION_UPGRADE_CONFIGURATION, [new Inject(APP_BASE_HREF), new Optional()]]
44 },
45 {
46 provide: LocationStrategy,
47 useFactory: provideLocationStrategy,
48 deps: [
49 PlatformLocation,
50 APP_BASE_HREF_RESOLVED,
51 LOCATION_UPGRADE_CONFIGURATION,
52 ]
53 },
54 ],
55 };
56 }
57}
58LocationUpgradeModule.decorators = [
59 { type: NgModule, args: [{ imports: [CommonModule] },] }
60];
61export function provideAppBaseHref(config, appBaseHref) {
62 if (config && config.appBaseHref != null) {
63 return config.appBaseHref;
64 }
65 else if (appBaseHref != null) {
66 return appBaseHref;
67 }
68 return '';
69}
70export function provideUrlCodec(config) {
71 const codec = config && config.urlCodec || AngularJSUrlCodec;
72 return new codec();
73}
74export function provideLocationStrategy(platformLocation, baseHref, options = {}) {
75 return options.useHash ? new HashLocationStrategy(platformLocation, baseHref) :
76 new PathLocationStrategy(platformLocation, baseHref);
77}
78export function provide$location(ngUpgrade, location, platformLocation, urlCodec, locationStrategy) {
79 const $locationProvider = new $locationShimProvider(ngUpgrade, location, platformLocation, urlCodec, locationStrategy);
80 return $locationProvider.$get();
81}
82//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYXRpb25fdXBncmFkZV9tb2R1bGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21tb24vdXBncmFkZS9zcmMvbG9jYXRpb25fdXBncmFkZV9tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGFBQWEsRUFBRSxZQUFZLEVBQUUsb0JBQW9CLEVBQUUsUUFBUSxFQUFFLGdCQUFnQixFQUFFLG9CQUFvQixFQUFFLGdCQUFnQixFQUFDLE1BQU0saUJBQWlCLENBQUM7QUFDdEosT0FBTyxFQUFDLE1BQU0sRUFBRSxjQUFjLEVBQXVCLFFBQVEsRUFBRSxRQUFRLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFDOUYsT0FBTyxFQUFDLGFBQWEsRUFBQyxNQUFNLHlCQUF5QixDQUFDO0FBR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biwgYmFzZUhyZWYpIDpcbiAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQYXRoTG9jYXRpb25TdHJhdGVneShwbGF0Zm9ybUxvY2F0aW9uLCBiYXNlSHJlZik7XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBwcm92aWRlJGxvY2F0aW9uKFxuICAgIG5nVXBncmFkZTogVXBncmFkZU1vZHVsZSwgbG9jYXRpb246IExvY2F0aW9uLCBwbGF0Zm9ybUxvY2F0aW9uOiBQbGF0Zm9ybUxvY2F0aW9uLFxuICAgIHVybENvZGVjOiBVcmxDb2RlYywgbG9jYXRpb25TdHJhdGVneTogTG9jYXRpb25TdHJhdGVneSkge1xuICBjb25zdCAkbG9jYXRpb25Qcm92aWRlciA9XG4gICAgICBuZXcgJGxvY2F0aW9uU2hpbVByb3ZpZGVyKG5nVXBncmFkZSwgbG9jYXRpb24sIHBsYXRmb3JtTG9jYXRpb24sIHVybENvZGVjLCBsb2NhdGlvblN0cmF0ZWd5KTtcblxuICByZXR1cm4gJGxvY2F0aW9uUHJvdmlkZXIuJGdldCgpO1xufVxuIl19
Note: See TracBrowser for help on using the repository browser.