@angular/common 16.0.0-next.6 → 16.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/esm2022/http/public_api.mjs +2 -1
  2. package/esm2022/http/src/client.mjs +3 -3
  3. package/esm2022/http/src/interceptor.mjs +14 -7
  4. package/esm2022/http/src/jsonp.mjs +6 -6
  5. package/esm2022/http/src/module.mjs +12 -12
  6. package/esm2022/http/src/transfer_cache.mjs +142 -0
  7. package/esm2022/http/src/xhr.mjs +8 -10
  8. package/esm2022/http/src/xsrf.mjs +6 -6
  9. package/esm2022/http/testing/src/backend.mjs +3 -3
  10. package/esm2022/http/testing/src/module.mjs +4 -4
  11. package/esm2022/src/common_module.mjs +4 -4
  12. package/esm2022/src/directives/ng_class.mjs +3 -3
  13. package/esm2022/src/directives/ng_component_outlet.mjs +3 -3
  14. package/esm2022/src/directives/ng_for_of.mjs +3 -3
  15. package/esm2022/src/directives/ng_if.mjs +3 -3
  16. package/esm2022/src/directives/ng_optimized_image/lcp_image_observer.mjs +3 -3
  17. package/esm2022/src/directives/ng_optimized_image/ng_optimized_image.mjs +3 -3
  18. package/esm2022/src/directives/ng_optimized_image/preconnect_link_checker.mjs +3 -3
  19. package/esm2022/src/directives/ng_optimized_image/preload-link-creator.mjs +3 -3
  20. package/esm2022/src/directives/ng_plural.mjs +6 -6
  21. package/esm2022/src/directives/ng_style.mjs +3 -3
  22. package/esm2022/src/directives/ng_switch.mjs +9 -9
  23. package/esm2022/src/directives/ng_template_outlet.mjs +3 -3
  24. package/esm2022/src/i18n/localization.mjs +6 -6
  25. package/esm2022/src/location/hash_location_strategy.mjs +3 -3
  26. package/esm2022/src/location/location.mjs +3 -3
  27. package/esm2022/src/location/location_strategy.mjs +6 -6
  28. package/esm2022/src/location/platform_location.mjs +6 -6
  29. package/esm2022/src/pipes/async_pipe.mjs +3 -3
  30. package/esm2022/src/pipes/case_conversion_pipes.mjs +9 -9
  31. package/esm2022/src/pipes/date_pipe.mjs +3 -3
  32. package/esm2022/src/pipes/i18n_plural_pipe.mjs +3 -3
  33. package/esm2022/src/pipes/i18n_select_pipe.mjs +3 -3
  34. package/esm2022/src/pipes/json_pipe.mjs +3 -3
  35. package/esm2022/src/pipes/keyvalue_pipe.mjs +3 -3
  36. package/esm2022/src/pipes/number_pipe.mjs +9 -9
  37. package/esm2022/src/pipes/slice_pipe.mjs +3 -3
  38. package/esm2022/src/version.mjs +1 -1
  39. package/esm2022/testing/src/location_mock.mjs +3 -3
  40. package/esm2022/testing/src/mock_location_strategy.mjs +3 -3
  41. package/esm2022/testing/src/mock_platform_location.mjs +3 -3
  42. package/esm2022/upgrade/src/location_upgrade_module.mjs +4 -4
  43. package/fesm2022/common.mjs +114 -114
  44. package/fesm2022/common.mjs.map +1 -1
  45. package/fesm2022/http/testing.mjs +8 -8
  46. package/fesm2022/http.mjs +180 -46
  47. package/fesm2022/http.mjs.map +1 -1
  48. package/fesm2022/testing.mjs +10 -10
  49. package/fesm2022/upgrade.mjs +5 -5
  50. package/http/index.d.ts +15 -5
  51. package/http/testing/index.d.ts +1 -1
  52. package/index.d.ts +1 -1
  53. package/package.json +3 -3
  54. package/testing/index.d.ts +1 -1
  55. package/upgrade/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v16.0.0-next.6
2
+ * @license Angular v16.0.0-rc.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -308,10 +308,10 @@ class HttpClientTestingBackend {
308
308
  return `Match by function: ${matcher.name}`;
309
309
  }
310
310
  }
311
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientTestingBackend, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
312
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientTestingBackend }); }
311
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientTestingBackend, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
312
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientTestingBackend }); }
313
313
  }
314
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientTestingBackend, decorators: [{
314
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientTestingBackend, decorators: [{
315
315
  type: Injectable
316
316
  }] });
317
317
  function describeRequest(testRequest) {
@@ -336,13 +336,13 @@ function provideHttpClientTesting() {
336
336
  * @publicApi
337
337
  */
338
338
  class HttpClientTestingModule {
339
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
340
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientTestingModule, imports: [HttpClientModule] }); }
341
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientTestingModule, providers: [
339
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
340
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientTestingModule, imports: [HttpClientModule] }); }
341
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientTestingModule, providers: [
342
342
  provideHttpClientTesting(),
343
343
  ], imports: [HttpClientModule] }); }
344
344
  }
345
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientTestingModule, decorators: [{
345
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientTestingModule, decorators: [{
346
346
  type: NgModule,
347
347
  args: [{
348
348
  imports: [
package/fesm2022/http.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @license Angular v16.0.0-next.6
2
+ * @license Angular v16.0.0-rc.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { Injectable, InjectionToken, inject, Inject, PLATFORM_ID, makeEnvironmentProviders, NgModule } from '@angular/core';
8
+ import { Injectable, InjectionToken, inject, Inject, PLATFORM_ID, makeEnvironmentProviders, NgModule, TransferState, makeStateKey, ɵENABLED_SSR_FEATURES, APP_INITIALIZER, ApplicationRef, ɵInitialRenderPendingTasks } from '@angular/core';
9
9
  import { of, Observable } from 'rxjs';
10
- import { concatMap, filter, map } from 'rxjs/operators';
10
+ import { concatMap, filter, map, tap, first } from 'rxjs/operators';
11
11
  import * as i1 from '@angular/common';
12
12
  import { DOCUMENT, ɵparseCookieValue } from '@angular/common';
13
13
 
@@ -1365,10 +1365,10 @@ class HttpClient {
1365
1365
  put(url, body, options = {}) {
1366
1366
  return this.request('PUT', url, addBody(options, body));
1367
1367
  }
1368
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClient, deps: [{ token: HttpHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
1369
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClient }); }
1368
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClient, deps: [{ token: HttpHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
1369
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClient }); }
1370
1370
  }
1371
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClient, decorators: [{
1371
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClient, decorators: [{
1372
1372
  type: Injectable
1373
1373
  }], ctorParameters: function () { return [{ type: HttpHandler }]; } });
1374
1374
 
@@ -1399,11 +1399,15 @@ function chainedInterceptorFn(chainTailFn, interceptorFn, injector) {
1399
1399
  *
1400
1400
  * @publicApi
1401
1401
  */
1402
- const HTTP_INTERCEPTORS = new InjectionToken('HTTP_INTERCEPTORS');
1402
+ const HTTP_INTERCEPTORS = new InjectionToken(ngDevMode ? 'HTTP_INTERCEPTORS' : '');
1403
1403
  /**
1404
1404
  * A multi-provided token of `HttpInterceptorFn`s.
1405
1405
  */
1406
- const HTTP_INTERCEPTOR_FNS = new InjectionToken('HTTP_INTERCEPTOR_FNS');
1406
+ const HTTP_INTERCEPTOR_FNS = new InjectionToken(ngDevMode ? 'HTTP_INTERCEPTOR_FNS' : '');
1407
+ /**
1408
+ * A multi-provided token of `HttpInterceptorFn`s that are only set in root.
1409
+ */
1410
+ const HTTP_ROOT_INTERCEPTOR_FNS = new InjectionToken(ngDevMode ? 'HTTP_ROOT_INTERCEPTOR_FNS' : '');
1407
1411
  /**
1408
1412
  * Creates an `HttpInterceptorFn` which lazily initializes an interceptor chain from the legacy
1409
1413
  * class-based interceptors and runs the request through it.
@@ -1431,7 +1435,10 @@ class HttpInterceptorHandler extends HttpHandler {
1431
1435
  }
1432
1436
  handle(initialRequest) {
1433
1437
  if (this.chain === null) {
1434
- const dedupedInterceptorFns = Array.from(new Set(this.injector.get(HTTP_INTERCEPTOR_FNS)));
1438
+ const dedupedInterceptorFns = Array.from(new Set([
1439
+ ...this.injector.get(HTTP_INTERCEPTOR_FNS),
1440
+ ...this.injector.get(HTTP_ROOT_INTERCEPTOR_FNS, []),
1441
+ ]));
1435
1442
  // Note: interceptors are wrapped right-to-left so that final execution order is
1436
1443
  // left-to-right. That is, if `dedupedInterceptorFns` is the array `[a, b, c]`, we want to
1437
1444
  // produce a chain that is conceptually `c(b(a(end)))`, which we build from the inside
@@ -1440,10 +1447,10 @@ class HttpInterceptorHandler extends HttpHandler {
1440
1447
  }
1441
1448
  return this.chain(initialRequest, downstreamRequest => this.backend.handle(downstreamRequest));
1442
1449
  }
1443
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpInterceptorHandler, deps: [{ token: HttpBackend }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1444
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpInterceptorHandler }); }
1450
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpInterceptorHandler, deps: [{ token: HttpBackend }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1451
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpInterceptorHandler }); }
1445
1452
  }
1446
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpInterceptorHandler, decorators: [{
1453
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpInterceptorHandler, decorators: [{
1447
1454
  type: Injectable
1448
1455
  }], ctorParameters: function () { return [{ type: HttpBackend }, { type: i0.EnvironmentInjector }]; } });
1449
1456
 
@@ -1645,10 +1652,10 @@ class JsonpClientBackend {
1645
1652
  }
1646
1653
  foreignDocument.adoptNode(script);
1647
1654
  }
1648
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: JsonpClientBackend, deps: [{ token: JsonpCallbackContext }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1649
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: JsonpClientBackend }); }
1655
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: JsonpClientBackend, deps: [{ token: JsonpCallbackContext }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1656
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: JsonpClientBackend }); }
1650
1657
  }
1651
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: JsonpClientBackend, decorators: [{
1658
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: JsonpClientBackend, decorators: [{
1652
1659
  type: Injectable
1653
1660
  }], ctorParameters: function () { return [{ type: JsonpCallbackContext }, { type: undefined, decorators: [{
1654
1661
  type: Inject,
@@ -1686,10 +1693,10 @@ class JsonpInterceptor {
1686
1693
  intercept(initialRequest, next) {
1687
1694
  return this.injector.runInContext(() => jsonpInterceptorFn(initialRequest, downstreamRequest => next.handle(downstreamRequest)));
1688
1695
  }
1689
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: JsonpInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1690
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: JsonpInterceptor }); }
1696
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: JsonpInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1697
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: JsonpInterceptor }); }
1691
1698
  }
1692
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: JsonpInterceptor, decorators: [{
1699
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: JsonpInterceptor, decorators: [{
1693
1700
  type: Injectable
1694
1701
  }], ctorParameters: function () { return [{ type: i0.EnvironmentInjector }]; } });
1695
1702
 
@@ -1933,12 +1940,13 @@ class HttpXhrBackend {
1933
1940
  xhr.upload.addEventListener('progress', onUpProgress);
1934
1941
  }
1935
1942
  }
1943
+ let macroTaskCanceller;
1936
1944
  /** Tear down logic to cancel the backround macrotask. */
1937
1945
  const onLoadStart = () => {
1938
- this.macroTaskCanceller ??= createBackgroundMacroTask();
1946
+ macroTaskCanceller ??= createBackgroundMacroTask();
1939
1947
  };
1940
1948
  const onLoadEnd = () => {
1941
- this.macroTaskCanceller?.();
1949
+ macroTaskCanceller?.();
1942
1950
  };
1943
1951
  xhr.addEventListener('loadstart', onLoadStart);
1944
1952
  xhr.addEventListener('loadend', onLoadEnd);
@@ -1956,7 +1964,7 @@ class HttpXhrBackend {
1956
1964
  xhr.removeEventListener('load', onLoad);
1957
1965
  xhr.removeEventListener('timeout', onError);
1958
1966
  // Cancel the background macrotask.
1959
- this.macroTaskCanceller?.();
1967
+ macroTaskCanceller?.();
1960
1968
  if (req.reportProgress) {
1961
1969
  xhr.removeEventListener('progress', onDownProgress);
1962
1970
  if (reqBody !== null && xhr.upload) {
@@ -1970,13 +1978,10 @@ class HttpXhrBackend {
1970
1978
  };
1971
1979
  });
1972
1980
  }
1973
- ngOnDestroy() {
1974
- this.macroTaskCanceller?.();
1975
- }
1976
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXhrBackend, deps: [{ token: i1.XhrFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
1977
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXhrBackend }); }
1981
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXhrBackend, deps: [{ token: i1.XhrFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
1982
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXhrBackend }); }
1978
1983
  }
1979
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXhrBackend, decorators: [{
1984
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXhrBackend, decorators: [{
1980
1985
  type: Injectable
1981
1986
  }], ctorParameters: function () { return [{ type: i1.XhrFactory }]; } });
1982
1987
  // Cannot use `Number.MAX_VALUE` as it does not fit into a 32-bit signed integer.
@@ -2040,10 +2045,10 @@ class HttpXsrfCookieExtractor {
2040
2045
  }
2041
2046
  return this.lastToken;
2042
2047
  }
2043
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXsrfCookieExtractor, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: XSRF_COOKIE_NAME }], target: i0.ɵɵFactoryTarget.Injectable }); }
2044
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXsrfCookieExtractor }); }
2048
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXsrfCookieExtractor, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: XSRF_COOKIE_NAME }], target: i0.ɵɵFactoryTarget.Injectable }); }
2049
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXsrfCookieExtractor }); }
2045
2050
  }
2046
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXsrfCookieExtractor, decorators: [{
2051
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXsrfCookieExtractor, decorators: [{
2047
2052
  type: Injectable
2048
2053
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2049
2054
  type: Inject,
@@ -2083,10 +2088,10 @@ class HttpXsrfInterceptor {
2083
2088
  intercept(initialRequest, next) {
2084
2089
  return this.injector.runInContext(() => xsrfInterceptorFn(initialRequest, downstreamRequest => next.handle(downstreamRequest)));
2085
2090
  }
2086
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXsrfInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
2087
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXsrfInterceptor }); }
2091
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXsrfInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
2092
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXsrfInterceptor }); }
2088
2093
  }
2089
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXsrfInterceptor, decorators: [{
2094
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpXsrfInterceptor, decorators: [{
2090
2095
  type: Injectable
2091
2096
  }], ctorParameters: function () { return [{ type: i0.EnvironmentInjector }]; } });
2092
2097
 
@@ -2318,9 +2323,9 @@ class HttpClientXsrfModule {
2318
2323
  providers: withXsrfConfiguration(options).ɵproviders,
2319
2324
  };
2320
2325
  }
2321
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientXsrfModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2322
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientXsrfModule }); }
2323
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientXsrfModule, providers: [
2326
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientXsrfModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2327
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientXsrfModule }); }
2328
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientXsrfModule, providers: [
2324
2329
  HttpXsrfInterceptor,
2325
2330
  { provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true },
2326
2331
  { provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor },
@@ -2331,7 +2336,7 @@ class HttpClientXsrfModule {
2331
2336
  { provide: XSRF_ENABLED, useValue: true },
2332
2337
  ] }); }
2333
2338
  }
2334
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientXsrfModule, decorators: [{
2339
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientXsrfModule, decorators: [{
2335
2340
  type: NgModule,
2336
2341
  args: [{
2337
2342
  providers: [
@@ -2356,13 +2361,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6",
2356
2361
  * @publicApi
2357
2362
  */
2358
2363
  class HttpClientModule {
2359
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2360
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientModule }); }
2361
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientModule, providers: [
2364
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2365
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientModule }); }
2366
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientModule, providers: [
2362
2367
  provideHttpClient(withInterceptorsFromDi()),
2363
2368
  ] }); }
2364
2369
  }
2365
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientModule, decorators: [{
2370
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientModule, decorators: [{
2366
2371
  type: NgModule,
2367
2372
  args: [{
2368
2373
  /**
@@ -2383,13 +2388,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6",
2383
2388
  * @publicApi
2384
2389
  */
2385
2390
  class HttpClientJsonpModule {
2386
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientJsonpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2387
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientJsonpModule }); }
2388
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientJsonpModule, providers: [
2391
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientJsonpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2392
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientJsonpModule }); }
2393
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientJsonpModule, providers: [
2389
2394
  withJsonpSupport().ɵproviders,
2390
2395
  ] }); }
2391
2396
  }
2392
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientJsonpModule, decorators: [{
2397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-rc.0", ngImport: i0, type: HttpClientJsonpModule, decorators: [{
2393
2398
  type: NgModule,
2394
2399
  args: [{
2395
2400
  providers: [
@@ -2398,11 +2403,140 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6",
2398
2403
  }]
2399
2404
  }] });
2400
2405
 
2406
+ const CACHE_STATE = new InjectionToken(ngDevMode ? 'HTTP_TRANSFER_STATE_CACHE_STATE' : '');
2407
+ /**
2408
+ * A list of allowed HTTP methods to cache.
2409
+ */
2410
+ const ALLOWED_METHODS = ['GET', 'HEAD'];
2411
+ function transferCacheInterceptorFn(req, next) {
2412
+ const { isCacheActive } = inject(CACHE_STATE);
2413
+ // Stop using the cache if the application has stabilized, indicating initial rendering
2414
+ // is complete.
2415
+ if (!isCacheActive || !ALLOWED_METHODS.includes(req.method)) {
2416
+ // Cache is no longer active or method is not HEAD or GET.
2417
+ // Pass the request through.
2418
+ return next(req);
2419
+ }
2420
+ const transferState = inject(TransferState);
2421
+ const storeKey = makeCacheKey(req);
2422
+ const response = transferState.get(storeKey, null);
2423
+ if (response) {
2424
+ // Request found in cache. Respond using it.
2425
+ let body = response.body;
2426
+ switch (response.responseType) {
2427
+ case 'arraybuffer':
2428
+ body = new TextEncoder().encode(response.body).buffer;
2429
+ break;
2430
+ case 'blob':
2431
+ body = new Blob([response.body]);
2432
+ break;
2433
+ }
2434
+ return of(new HttpResponse({
2435
+ body,
2436
+ headers: new HttpHeaders(response.headers),
2437
+ status: response.status,
2438
+ statusText: response.statusText,
2439
+ url: response.url,
2440
+ }));
2441
+ }
2442
+ // Request not found in cache. Make the request and cache it.
2443
+ return next(req).pipe(tap((event) => {
2444
+ if (event instanceof HttpResponse) {
2445
+ transferState.set(storeKey, {
2446
+ body: event.body,
2447
+ headers: getHeadersMap(event.headers),
2448
+ status: event.status,
2449
+ statusText: event.statusText,
2450
+ url: event.url || '',
2451
+ responseType: req.responseType,
2452
+ });
2453
+ }
2454
+ }));
2455
+ }
2456
+ function getHeadersMap(headers) {
2457
+ const headersMap = {};
2458
+ for (const key of headers.keys()) {
2459
+ const values = headers.getAll(key);
2460
+ if (values !== null) {
2461
+ headersMap[key] = values;
2462
+ }
2463
+ }
2464
+ return headersMap;
2465
+ }
2466
+ function makeCacheKey(request) {
2467
+ // make the params encoded same as a url so it's easy to identify
2468
+ const { params, method, responseType, url } = request;
2469
+ const encodedParams = params.keys().sort().map((k) => `${k}=${params.getAll(k)}`).join('&');
2470
+ const key = method + '.' + responseType + '.' + url + '?' + encodedParams;
2471
+ const hash = generateHash(key);
2472
+ return makeStateKey(hash);
2473
+ }
2474
+ /**
2475
+ * A method that returns a hash representation of a string using a variant of DJB2 hash
2476
+ * algorithm.
2477
+ *
2478
+ * This is the same hashing logic that is used to generate component ids.
2479
+ */
2480
+ function generateHash(value) {
2481
+ let hash = 0;
2482
+ for (const char of value) {
2483
+ hash = Math.imul(31, hash) + char.charCodeAt(0) << 0;
2484
+ }
2485
+ // Force positive number hash.
2486
+ // 2147483647 = equivalent of Integer.MAX_VALUE.
2487
+ hash += 2147483647 + 1;
2488
+ return hash.toString();
2489
+ }
2490
+ /**
2491
+ * Returns the DI providers needed to enable HTTP transfer cache.
2492
+ *
2493
+ * By default, when using server rendering, requests are performed twice: once on the server and
2494
+ * other one on the browser.
2495
+ *
2496
+ * When these providers are added, requests performed on the server are cached and reused during the
2497
+ * bootstrapping of the application in the browser thus avoiding duplicate requests and reducing
2498
+ * load time.
2499
+ *
2500
+ */
2501
+ function withHttpTransferCache() {
2502
+ return [
2503
+ {
2504
+ provide: CACHE_STATE,
2505
+ useFactory: () => {
2506
+ inject(ɵENABLED_SSR_FEATURES).add('httpcache');
2507
+ return { isCacheActive: true };
2508
+ }
2509
+ },
2510
+ {
2511
+ provide: HTTP_ROOT_INTERCEPTOR_FNS,
2512
+ useValue: transferCacheInterceptorFn,
2513
+ multi: true,
2514
+ deps: [TransferState, CACHE_STATE]
2515
+ },
2516
+ {
2517
+ provide: APP_INITIALIZER,
2518
+ multi: true,
2519
+ useFactory: () => {
2520
+ const appRef = inject(ApplicationRef);
2521
+ const cacheState = inject(CACHE_STATE);
2522
+ const pendingTasks = inject(ɵInitialRenderPendingTasks);
2523
+ return () => {
2524
+ const isStablePromise = appRef.isStable.pipe(first((isStable) => isStable)).toPromise();
2525
+ isStablePromise.then(() => pendingTasks.whenAllTasksComplete).then(() => {
2526
+ cacheState.isCacheActive = false;
2527
+ });
2528
+ };
2529
+ },
2530
+ deps: [ApplicationRef, CACHE_STATE, ɵInitialRenderPendingTasks]
2531
+ }
2532
+ ];
2533
+ }
2534
+
2401
2535
  // This file is not used to build this module. It is only used during editing
2402
2536
 
2403
2537
  /**
2404
2538
  * Generated bundle index. Do not edit.
2405
2539
  */
2406
2540
 
2407
- export { HTTP_INTERCEPTORS, HttpBackend, HttpClient, HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpContext, HttpContextToken, HttpErrorResponse, HttpEventType, HttpFeatureKind, HttpHandler, HttpHeaderResponse, HttpHeaders, HttpParams, HttpRequest, HttpResponse, HttpResponseBase, HttpUrlEncodingCodec, HttpXhrBackend, HttpXsrfTokenExtractor, JsonpClientBackend, JsonpInterceptor, provideHttpClient, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNoXsrfProtection, withRequestsMadeViaParent, withXsrfConfiguration, HttpInterceptorHandler as ɵHttpInterceptingHandler, HttpInterceptorHandler as ɵHttpInterceptorHandler };
2541
+ export { HTTP_INTERCEPTORS, HttpBackend, HttpClient, HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpContext, HttpContextToken, HttpErrorResponse, HttpEventType, HttpFeatureKind, HttpHandler, HttpHeaderResponse, HttpHeaders, HttpParams, HttpRequest, HttpResponse, HttpResponseBase, HttpUrlEncodingCodec, HttpXhrBackend, HttpXsrfTokenExtractor, JsonpClientBackend, JsonpInterceptor, provideHttpClient, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNoXsrfProtection, withRequestsMadeViaParent, withXsrfConfiguration, HttpInterceptorHandler as ɵHttpInterceptingHandler, HttpInterceptorHandler as ɵHttpInterceptorHandler, withHttpTransferCache as ɵwithHttpTransferCache };
2408
2542
  //# sourceMappingURL=http.mjs.map