index.d.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. /**
  2. * @license Angular v16.2.9
  3. * (c) 2010-2022 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import * as i0 from '@angular/core';
  7. import * as i1 from '@angular/common';
  8. import { InjectionToken } from '@angular/core';
  9. import { Location as Location_2 } from '@angular/common';
  10. import { LocationStrategy } from '@angular/common';
  11. import { ModuleWithProviders } from '@angular/core';
  12. import { PlatformLocation } from '@angular/common';
  13. import { UpgradeModule } from '@angular/upgrade/static';
  14. /**
  15. * Location service that provides a drop-in replacement for the $location service
  16. * provided in AngularJS.
  17. *
  18. * @see [Using the Angular Unified Location Service](guide/upgrade#using-the-unified-angular-location-service)
  19. *
  20. * @publicApi
  21. */
  22. export declare class $locationShim {
  23. private location;
  24. private platformLocation;
  25. private urlCodec;
  26. private locationStrategy;
  27. private initializing;
  28. private updateBrowser;
  29. private $$absUrl;
  30. private $$url;
  31. private $$protocol;
  32. private $$host;
  33. private $$port;
  34. private $$replace;
  35. private $$path;
  36. private $$search;
  37. private $$hash;
  38. private $$state;
  39. private $$changeListeners;
  40. private cachedState;
  41. private urlChanges;
  42. constructor($injector: any, location: Location_2, platformLocation: PlatformLocation, urlCodec: UrlCodec, locationStrategy: LocationStrategy);
  43. private initialize;
  44. private resetBrowserUpdate;
  45. private lastHistoryState;
  46. private lastBrowserUrl;
  47. private browserUrl;
  48. private lastCachedState;
  49. private cacheState;
  50. /**
  51. * This function emulates the $browser.state() function from AngularJS. It will cause
  52. * history.state to be cached unless changed with deep equality check.
  53. */
  54. private browserState;
  55. private stripBaseUrl;
  56. private getServerBase;
  57. private parseAppUrl;
  58. /**
  59. * Registers listeners for URL changes. This API is used to catch updates performed by the
  60. * AngularJS framework. These changes are a subset of the `$locationChangeStart` and
  61. * `$locationChangeSuccess` events which fire when AngularJS updates its internally-referenced
  62. * version of the browser URL.
  63. *
  64. * It's possible for `$locationChange` events to happen, but for the browser URL
  65. * (window.location) to remain unchanged. This `onChange` callback will fire only when AngularJS
  66. * actually updates the browser URL (window.location).
  67. *
  68. * @param fn The callback function that is triggered for the listener when the URL changes.
  69. * @param err The callback function that is triggered when an error occurs.
  70. */
  71. onChange(fn: (url: string, state: unknown, oldUrl: string, oldState: unknown) => void, err?: (e: Error) => void): void;
  72. /**
  73. * Parses the provided URL, and sets the current URL to the parsed result.
  74. *
  75. * @param url The URL string.
  76. */
  77. $$parse(url: string): void;
  78. /**
  79. * Parses the provided URL and its relative URL.
  80. *
  81. * @param url The full URL string.
  82. * @param relHref A URL string relative to the full URL string.
  83. */
  84. $$parseLinkUrl(url: string, relHref?: string | null): boolean;
  85. private setBrowserUrlWithFallback;
  86. private composeUrls;
  87. /**
  88. * Retrieves the full URL representation with all segments encoded according to
  89. * rules specified in
  90. * [RFC 3986](https://tools.ietf.org/html/rfc3986).
  91. *
  92. *
  93. * ```js
  94. * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
  95. * let absUrl = $location.absUrl();
  96. * // => "http://example.com/#/some/path?foo=bar&baz=xoxo"
  97. * ```
  98. */
  99. absUrl(): string;
  100. /**
  101. * Retrieves the current URL, or sets a new URL. When setting a URL,
  102. * changes the path, search, and hash, and returns a reference to its own instance.
  103. *
  104. * ```js
  105. * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
  106. * let url = $location.url();
  107. * // => "/some/path?foo=bar&baz=xoxo"
  108. * ```
  109. */
  110. url(): string;
  111. url(url: string): this;
  112. /**
  113. * Retrieves the protocol of the current URL.
  114. *
  115. * ```js
  116. * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
  117. * let protocol = $location.protocol();
  118. * // => "http"
  119. * ```
  120. */
  121. protocol(): string;
  122. /**
  123. * Retrieves the protocol of the current URL.
  124. *
  125. * In contrast to the non-AngularJS version `location.host` which returns `hostname:port`, this
  126. * returns the `hostname` portion only.
  127. *
  128. *
  129. * ```js
  130. * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
  131. * let host = $location.host();
  132. * // => "example.com"
  133. *
  134. * // given URL http://user:password@example.com:8080/#/some/path?foo=bar&baz=xoxo
  135. * host = $location.host();
  136. * // => "example.com"
  137. * host = location.host;
  138. * // => "example.com:8080"
  139. * ```
  140. */
  141. host(): string;
  142. /**
  143. * Retrieves the port of the current URL.
  144. *
  145. * ```js
  146. * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
  147. * let port = $location.port();
  148. * // => 80
  149. * ```
  150. */
  151. port(): number | null;
  152. /**
  153. * Retrieves the path of the current URL, or changes the path and returns a reference to its own
  154. * instance.
  155. *
  156. * Paths should always begin with forward slash (/). This method adds the forward slash
  157. * if it is missing.
  158. *
  159. * ```js
  160. * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
  161. * let path = $location.path();
  162. * // => "/some/path"
  163. * ```
  164. */
  165. path(): string;
  166. path(path: string | number | null): this;
  167. /**
  168. * Retrieves a map of the search parameters of the current URL, or changes a search
  169. * part and returns a reference to its own instance.
  170. *
  171. *
  172. * ```js
  173. * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo
  174. * let searchObject = $location.search();
  175. * // => {foo: 'bar', baz: 'xoxo'}
  176. *
  177. * // set foo to 'yipee'
  178. * $location.search('foo', 'yipee');
  179. * // $location.search() => {foo: 'yipee', baz: 'xoxo'}
  180. * ```
  181. *
  182. * @param {string|Object.<string>|Object.<Array.<string>>} search New search params - string or
  183. * hash object.
  184. *
  185. * When called with a single argument the method acts as a setter, setting the `search` component
  186. * of `$location` to the specified value.
  187. *
  188. * If the argument is a hash object containing an array of values, these values will be encoded
  189. * as duplicate search parameters in the URL.
  190. *
  191. * @param {(string|Number|Array<string>|boolean)=} paramValue If `search` is a string or number,
  192. * then `paramValue`
  193. * will override only a single search property.
  194. *
  195. * If `paramValue` is an array, it will override the property of the `search` component of
  196. * `$location` specified via the first argument.
  197. *
  198. * If `paramValue` is `null`, the property specified via the first argument will be deleted.
  199. *
  200. * If `paramValue` is `true`, the property specified via the first argument will be added with no
  201. * value nor trailing equal sign.
  202. *
  203. * @return {Object} The parsed `search` object of the current URL, or the changed `search` object.
  204. */
  205. search(): {
  206. [key: string]: unknown;
  207. };
  208. search(search: string | number | {
  209. [key: string]: unknown;
  210. }): this;
  211. search(search: string | number | {
  212. [key: string]: unknown;
  213. }, paramValue: null | undefined | string | number | boolean | string[]): this;
  214. /**
  215. * Retrieves the current hash fragment, or changes the hash fragment and returns a reference to
  216. * its own instance.
  217. *
  218. * ```js
  219. * // given URL http://example.com/#/some/path?foo=bar&baz=xoxo#hashValue
  220. * let hash = $location.hash();
  221. * // => "hashValue"
  222. * ```
  223. */
  224. hash(): string;
  225. hash(hash: string | number | null): this;
  226. /**
  227. * Changes to `$location` during the current `$digest` will replace the current
  228. * history record, instead of adding a new one.
  229. */
  230. replace(): this;
  231. /**
  232. * Retrieves the history state object when called without any parameter.
  233. *
  234. * Change the history state object when called with one parameter and return `$location`.
  235. * The state object is later passed to `pushState` or `replaceState`.
  236. *
  237. * This method is supported only in HTML5 mode and only in browsers supporting
  238. * the HTML5 History API methods such as `pushState` and `replaceState`. If you need to support
  239. * older browsers (like Android < 4.0), don't use this method.
  240. *
  241. */
  242. state(): unknown;
  243. state(state: unknown): this;
  244. }
  245. /**
  246. * The factory function used to create an instance of the `$locationShim` in Angular,
  247. * and provides an API-compatible `$locationProvider` for AngularJS.
  248. *
  249. * @publicApi
  250. */
  251. export declare class $locationShimProvider {
  252. private ngUpgrade;
  253. private location;
  254. private platformLocation;
  255. private urlCodec;
  256. private locationStrategy;
  257. constructor(ngUpgrade: UpgradeModule, location: Location_2, platformLocation: PlatformLocation, urlCodec: UrlCodec, locationStrategy: LocationStrategy);
  258. /**
  259. * Factory method that returns an instance of the $locationShim
  260. */
  261. $get(): $locationShim;
  262. /**
  263. * Stub method used to keep API compatible with AngularJS. This setting is configured through
  264. * the LocationUpgradeModule's `config` method in your Angular app.
  265. */
  266. hashPrefix(prefix?: string): void;
  267. /**
  268. * Stub method used to keep API compatible with AngularJS. This setting is configured through
  269. * the LocationUpgradeModule's `config` method in your Angular app.
  270. */
  271. html5Mode(mode?: any): void;
  272. }
  273. /**
  274. * A `UrlCodec` that uses logic from AngularJS to serialize and parse URLs
  275. * and URL parameters.
  276. *
  277. * @publicApi
  278. */
  279. export declare class AngularJSUrlCodec implements UrlCodec {
  280. encodePath(path: string): string;
  281. encodeSearch(search: string | {
  282. [k: string]: unknown;
  283. }): string;
  284. encodeHash(hash: string): string;
  285. decodePath(path: string, html5Mode?: boolean): string;
  286. decodeSearch(search: string): {
  287. [k: string]: unknown;
  288. };
  289. decodeHash(hash: string): string;
  290. normalize(href: string): string;
  291. normalize(path: string, search: {
  292. [k: string]: unknown;
  293. }, hash: string, baseUrl?: string): string;
  294. areEqual(valA: string, valB: string): boolean;
  295. parse(url: string, base?: string): {
  296. href: string;
  297. protocol: string;
  298. host: string;
  299. search: string;
  300. hash: string;
  301. hostname: string;
  302. port: string;
  303. pathname: string;
  304. };
  305. }
  306. /**
  307. * A provider token used to configure the location upgrade module.
  308. *
  309. * @publicApi
  310. */
  311. export declare const LOCATION_UPGRADE_CONFIGURATION: InjectionToken<LocationUpgradeConfig>;
  312. /**
  313. * Configuration options for LocationUpgrade.
  314. *
  315. * @publicApi
  316. */
  317. export declare interface LocationUpgradeConfig {
  318. /**
  319. * Configures whether the location upgrade module should use the `HashLocationStrategy`
  320. * or the `PathLocationStrategy`
  321. */
  322. useHash?: boolean;
  323. /**
  324. * Configures the hash prefix used in the URL when using the `HashLocationStrategy`
  325. */
  326. hashPrefix?: string;
  327. /**
  328. * Configures the URL codec for encoding and decoding URLs. Default is the `AngularJSCodec`
  329. */
  330. urlCodec?: typeof UrlCodec;
  331. /**
  332. * Configures the base href when used in server-side rendered applications
  333. */
  334. serverBaseHref?: string;
  335. /**
  336. * Configures the base href when used in client-side rendered applications
  337. */
  338. appBaseHref?: string;
  339. }
  340. /**
  341. * `NgModule` used for providing and configuring Angular's Unified Location Service for upgrading.
  342. *
  343. * @see [Using the Unified Angular Location Service](guide/upgrade#using-the-unified-angular-location-service)
  344. *
  345. * @publicApi
  346. */
  347. export declare class LocationUpgradeModule {
  348. static config(config?: LocationUpgradeConfig): ModuleWithProviders<LocationUpgradeModule>;
  349. static ɵfac: i0.ɵɵFactoryDeclaration<LocationUpgradeModule, never>;
  350. static ɵmod: i0.ɵɵNgModuleDeclaration<LocationUpgradeModule, never, [typeof i1.CommonModule], never>;
  351. static ɵinj: i0.ɵɵInjectorDeclaration<LocationUpgradeModule>;
  352. }
  353. /**
  354. * A codec for encoding and decoding URL parts.
  355. *
  356. * @publicApi
  357. **/
  358. export declare abstract class UrlCodec {
  359. /**
  360. * Encodes the path from the provided string
  361. *
  362. * @param path The path string
  363. */
  364. abstract encodePath(path: string): string;
  365. /**
  366. * Decodes the path from the provided string
  367. *
  368. * @param path The path string
  369. */
  370. abstract decodePath(path: string): string;
  371. /**
  372. * Encodes the search string from the provided string or object
  373. *
  374. * @param path The path string or object
  375. */
  376. abstract encodeSearch(search: string | {
  377. [k: string]: unknown;
  378. }): string;
  379. /**
  380. * Decodes the search objects from the provided string
  381. *
  382. * @param path The path string
  383. */
  384. abstract decodeSearch(search: string): {
  385. [k: string]: unknown;
  386. };
  387. /**
  388. * Encodes the hash from the provided string
  389. *
  390. * @param path The hash string
  391. */
  392. abstract encodeHash(hash: string): string;
  393. /**
  394. * Decodes the hash from the provided string
  395. *
  396. * @param path The hash string
  397. */
  398. abstract decodeHash(hash: string): string;
  399. /**
  400. * Normalizes the URL from the provided string
  401. *
  402. * @param path The URL string
  403. */
  404. abstract normalize(href: string): string;
  405. /**
  406. * Normalizes the URL from the provided string, search, hash, and base URL parameters
  407. *
  408. * @param path The URL path
  409. * @param search The search object
  410. * @param hash The has string
  411. * @param baseUrl The base URL for the URL
  412. */
  413. abstract normalize(path: string, search: {
  414. [k: string]: unknown;
  415. }, hash: string, baseUrl?: string): string;
  416. /**
  417. * Checks whether the two strings are equal
  418. * @param valA First string for comparison
  419. * @param valB Second string for comparison
  420. */
  421. abstract areEqual(valA: string, valB: string): boolean;
  422. /**
  423. * Parses the URL string based on the base URL
  424. *
  425. * @param url The full URL string
  426. * @param base The base for the URL
  427. */
  428. abstract parse(url: string, base?: string): {
  429. href: string;
  430. protocol: string;
  431. host: string;
  432. search: string;
  433. hash: string;
  434. hostname: string;
  435. port: string;
  436. pathname: string;
  437. };
  438. }
  439. export { }