platform_location.d-Lbv6Ueec.d.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @license Angular v19.2.13
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import * as i0 from '@angular/core';
  7. import { InjectionToken } from '@angular/core';
  8. /**
  9. * This class should not be used directly by an application developer. Instead, use
  10. * {@link Location}.
  11. *
  12. * `PlatformLocation` encapsulates all calls to DOM APIs, which allows the Router to be
  13. * platform-agnostic.
  14. * This means that we can have different implementation of `PlatformLocation` for the different
  15. * platforms that Angular supports. For example, `@angular/platform-browser` provides an
  16. * implementation specific to the browser environment, while `@angular/platform-server` provides
  17. * one suitable for use with server-side rendering.
  18. *
  19. * The `PlatformLocation` class is used directly by all implementations of {@link LocationStrategy}
  20. * when they need to interact with the DOM APIs like pushState, popState, etc.
  21. *
  22. * {@link LocationStrategy} in turn is used by the {@link Location} service which is used directly
  23. * by the {@link /api/router/Router Router} in order to navigate between routes. Since all interactions between
  24. * {@link /api/router/Router Router} /
  25. * {@link Location} / {@link LocationStrategy} and DOM APIs flow through the `PlatformLocation`
  26. * class, they are all platform-agnostic.
  27. *
  28. * @publicApi
  29. */
  30. declare abstract class PlatformLocation {
  31. abstract getBaseHrefFromDOM(): string;
  32. abstract getState(): unknown;
  33. /**
  34. * Returns a function that, when executed, removes the `popstate` event handler.
  35. */
  36. abstract onPopState(fn: LocationChangeListener): VoidFunction;
  37. /**
  38. * Returns a function that, when executed, removes the `hashchange` event handler.
  39. */
  40. abstract onHashChange(fn: LocationChangeListener): VoidFunction;
  41. abstract get href(): string;
  42. abstract get protocol(): string;
  43. abstract get hostname(): string;
  44. abstract get port(): string;
  45. abstract get pathname(): string;
  46. abstract get search(): string;
  47. abstract get hash(): string;
  48. abstract replaceState(state: any, title: string, url: string): void;
  49. abstract pushState(state: any, title: string, url: string): void;
  50. abstract forward(): void;
  51. abstract back(): void;
  52. historyGo?(relativePosition: number): void;
  53. static ɵfac: i0.ɵɵFactoryDeclaration<PlatformLocation, never>;
  54. static ɵprov: i0.ɵɵInjectableDeclaration<PlatformLocation>;
  55. }
  56. /**
  57. * @description
  58. * Indicates when a location is initialized.
  59. *
  60. * @publicApi
  61. */
  62. declare const LOCATION_INITIALIZED: InjectionToken<Promise<any>>;
  63. /**
  64. * @description
  65. * A serializable version of the event from `onPopState` or `onHashChange`
  66. *
  67. * @publicApi
  68. */
  69. interface LocationChangeEvent {
  70. type: string;
  71. state: any;
  72. }
  73. /**
  74. * @publicApi
  75. */
  76. interface LocationChangeListener {
  77. (event: LocationChangeEvent): any;
  78. }
  79. /**
  80. * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
  81. * This class should not be used directly by an application developer. Instead, use
  82. * {@link Location}.
  83. *
  84. * @publicApi
  85. */
  86. declare class BrowserPlatformLocation extends PlatformLocation {
  87. private _location;
  88. private _history;
  89. private _doc;
  90. constructor();
  91. getBaseHrefFromDOM(): string;
  92. onPopState(fn: LocationChangeListener): VoidFunction;
  93. onHashChange(fn: LocationChangeListener): VoidFunction;
  94. get href(): string;
  95. get protocol(): string;
  96. get hostname(): string;
  97. get port(): string;
  98. get pathname(): string;
  99. get search(): string;
  100. get hash(): string;
  101. set pathname(newPath: string);
  102. pushState(state: any, title: string, url: string): void;
  103. replaceState(state: any, title: string, url: string): void;
  104. forward(): void;
  105. back(): void;
  106. historyGo(relativePosition?: number): void;
  107. getState(): unknown;
  108. static ɵfac: i0.ɵɵFactoryDeclaration<BrowserPlatformLocation, never>;
  109. static ɵprov: i0.ɵɵInjectableDeclaration<BrowserPlatformLocation>;
  110. }
  111. export { BrowserPlatformLocation, LOCATION_INITIALIZED, PlatformLocation };
  112. export type { LocationChangeEvent, LocationChangeListener };