@angular/common 16.0.0-next.6 → 16.0.0-next.7

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 +136 -0
  7. package/esm2022/http/src/xhr.mjs +3 -3
  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 +170 -40
  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 +14 -1
  51. package/http/testing/index.d.ts +1 -1
  52. package/index.d.ts +1 -1
  53. package/package.json +2 -2
  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-next.7
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-next.7", ngImport: i0, type: HttpClientTestingBackend, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
312
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.7", 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-next.7", 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-next.7", ngImport: i0, type: HttpClientTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
340
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientTestingModule, imports: [HttpClientModule] }); }
341
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.7", 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-next.7", 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-next.7
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, APP_BOOTSTRAP_LISTENER, 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-next.7", 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.7", 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-next.7", 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-next.7", 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-next.7", 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-next.7", 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-next.7", 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-next.7", 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-next.7", 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-next.7", 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-next.7", 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-next.7", ngImport: i0, type: JsonpInterceptor, decorators: [{
1693
1700
  type: Injectable
1694
1701
  }], ctorParameters: function () { return [{ type: i0.EnvironmentInjector }]; } });
1695
1702
 
@@ -1973,10 +1980,10 @@ class HttpXhrBackend {
1973
1980
  ngOnDestroy() {
1974
1981
  this.macroTaskCanceller?.();
1975
1982
  }
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 }); }
1983
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXhrBackend, deps: [{ token: i1.XhrFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
1984
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXhrBackend }); }
1978
1985
  }
1979
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXhrBackend, decorators: [{
1986
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXhrBackend, decorators: [{
1980
1987
  type: Injectable
1981
1988
  }], ctorParameters: function () { return [{ type: i1.XhrFactory }]; } });
1982
1989
  // Cannot use `Number.MAX_VALUE` as it does not fit into a 32-bit signed integer.
@@ -2040,10 +2047,10 @@ class HttpXsrfCookieExtractor {
2040
2047
  }
2041
2048
  return this.lastToken;
2042
2049
  }
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 }); }
2050
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXsrfCookieExtractor, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: XSRF_COOKIE_NAME }], target: i0.ɵɵFactoryTarget.Injectable }); }
2051
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXsrfCookieExtractor }); }
2045
2052
  }
2046
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXsrfCookieExtractor, decorators: [{
2053
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXsrfCookieExtractor, decorators: [{
2047
2054
  type: Injectable
2048
2055
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2049
2056
  type: Inject,
@@ -2083,10 +2090,10 @@ class HttpXsrfInterceptor {
2083
2090
  intercept(initialRequest, next) {
2084
2091
  return this.injector.runInContext(() => xsrfInterceptorFn(initialRequest, downstreamRequest => next.handle(downstreamRequest)));
2085
2092
  }
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 }); }
2093
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXsrfInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
2094
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXsrfInterceptor }); }
2088
2095
  }
2089
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpXsrfInterceptor, decorators: [{
2096
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpXsrfInterceptor, decorators: [{
2090
2097
  type: Injectable
2091
2098
  }], ctorParameters: function () { return [{ type: i0.EnvironmentInjector }]; } });
2092
2099
 
@@ -2318,9 +2325,9 @@ class HttpClientXsrfModule {
2318
2325
  providers: withXsrfConfiguration(options).ɵproviders,
2319
2326
  };
2320
2327
  }
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: [
2328
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientXsrfModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2329
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientXsrfModule }); }
2330
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientXsrfModule, providers: [
2324
2331
  HttpXsrfInterceptor,
2325
2332
  { provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true },
2326
2333
  { provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor },
@@ -2331,7 +2338,7 @@ class HttpClientXsrfModule {
2331
2338
  { provide: XSRF_ENABLED, useValue: true },
2332
2339
  ] }); }
2333
2340
  }
2334
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientXsrfModule, decorators: [{
2341
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientXsrfModule, decorators: [{
2335
2342
  type: NgModule,
2336
2343
  args: [{
2337
2344
  providers: [
@@ -2356,13 +2363,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6",
2356
2363
  * @publicApi
2357
2364
  */
2358
2365
  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: [
2366
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2367
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientModule }); }
2368
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientModule, providers: [
2362
2369
  provideHttpClient(withInterceptorsFromDi()),
2363
2370
  ] }); }
2364
2371
  }
2365
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientModule, decorators: [{
2372
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientModule, decorators: [{
2366
2373
  type: NgModule,
2367
2374
  args: [{
2368
2375
  /**
@@ -2383,13 +2390,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6",
2383
2390
  * @publicApi
2384
2391
  */
2385
2392
  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: [
2393
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientJsonpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2394
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientJsonpModule }); }
2395
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientJsonpModule, providers: [
2389
2396
  withJsonpSupport().ɵproviders,
2390
2397
  ] }); }
2391
2398
  }
2392
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: HttpClientJsonpModule, decorators: [{
2399
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.7", ngImport: i0, type: HttpClientJsonpModule, decorators: [{
2393
2400
  type: NgModule,
2394
2401
  args: [{
2395
2402
  providers: [
@@ -2398,11 +2405,134 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6",
2398
2405
  }]
2399
2406
  }] });
2400
2407
 
2408
+ const CACHE_STATE = new InjectionToken(ngDevMode ? 'HTTP_TRANSFER_STATE_CACHE_STATE' : '');
2409
+ /**
2410
+ * A list of allowed HTTP methods to cache.
2411
+ */
2412
+ const ALLOWED_METHODS = ['GET', 'HEAD'];
2413
+ function transferCacheInterceptorFn(req, next) {
2414
+ const { isCacheActive } = inject(CACHE_STATE);
2415
+ // Stop using the cache if the application has stabilized, indicating initial rendering
2416
+ // is complete.
2417
+ if (!isCacheActive || !ALLOWED_METHODS.includes(req.method)) {
2418
+ // Cache is no longer active or method is not HEAD or GET.
2419
+ // Pass the request through.
2420
+ return next(req);
2421
+ }
2422
+ const transferState = inject(TransferState);
2423
+ const storeKey = makeCacheKey(req);
2424
+ const response = transferState.get(storeKey, null);
2425
+ if (response) {
2426
+ // Request found in cache. Respond using it.
2427
+ let body = response.body;
2428
+ switch (response.responseType) {
2429
+ case 'arraybuffer':
2430
+ body = new TextEncoder().encode(response.body).buffer;
2431
+ break;
2432
+ case 'blob':
2433
+ body = new Blob([response.body]);
2434
+ break;
2435
+ }
2436
+ return of(new HttpResponse({
2437
+ body,
2438
+ headers: new HttpHeaders(response.headers),
2439
+ status: response.status,
2440
+ statusText: response.statusText,
2441
+ url: response.url,
2442
+ }));
2443
+ }
2444
+ // Request not found in cache. Make the request and cache it.
2445
+ return next(req).pipe(tap((event) => {
2446
+ if (event instanceof HttpResponse) {
2447
+ transferState.set(storeKey, {
2448
+ body: event.body,
2449
+ headers: getHeadersMap(event.headers),
2450
+ status: event.status,
2451
+ statusText: event.statusText,
2452
+ url: event.url || '',
2453
+ responseType: req.responseType,
2454
+ });
2455
+ }
2456
+ }));
2457
+ }
2458
+ function getHeadersMap(headers) {
2459
+ const headersMap = {};
2460
+ for (const key of headers.keys()) {
2461
+ const values = headers.getAll(key);
2462
+ if (values !== null) {
2463
+ headersMap[key] = values;
2464
+ }
2465
+ }
2466
+ return headersMap;
2467
+ }
2468
+ function makeCacheKey(request) {
2469
+ // make the params encoded same as a url so it's easy to identify
2470
+ const { params, method, responseType, url } = request;
2471
+ const encodedParams = params.keys().sort().map((k) => `${k}=${params.getAll(k)}`).join('&');
2472
+ const key = method + '.' + responseType + '.' + url + '?' + encodedParams;
2473
+ const hash = generateHash(key);
2474
+ return makeStateKey(hash);
2475
+ }
2476
+ /**
2477
+ * A method that returns a hash representation of a string using a variant of DJB2 hash
2478
+ * algorithm.
2479
+ *
2480
+ * This is the same hashing logic that is used to generate component ids.
2481
+ */
2482
+ function generateHash(value) {
2483
+ let hash = 0;
2484
+ for (const char of value) {
2485
+ hash = Math.imul(31, hash) + char.charCodeAt(0) << 0;
2486
+ }
2487
+ // Force positive number hash.
2488
+ // 2147483647 = equivalent of Integer.MAX_VALUE.
2489
+ hash += 2147483647 + 1;
2490
+ return hash.toString();
2491
+ }
2492
+ /**
2493
+ * Returns the DI providers needed to enable HTTP transfer cache.
2494
+ *
2495
+ * By default, when using server rendering, requests are performed twice: once on the server and
2496
+ * other one on the browser.
2497
+ *
2498
+ * When these providers are added, requests performed on the server are cached and reused during the
2499
+ * bootstrapping of the application in the browser thus avoiding duplicate requests and reducing
2500
+ * load time.
2501
+ *
2502
+ */
2503
+ function withHttpTransferCache() {
2504
+ return [
2505
+ { provide: CACHE_STATE, useValue: { isCacheActive: true } }, {
2506
+ provide: HTTP_ROOT_INTERCEPTOR_FNS,
2507
+ useValue: transferCacheInterceptorFn,
2508
+ multi: true,
2509
+ deps: [TransferState, CACHE_STATE]
2510
+ },
2511
+ {
2512
+ provide: APP_BOOTSTRAP_LISTENER,
2513
+ multi: true,
2514
+ useFactory: () => {
2515
+ const appRef = inject(ApplicationRef);
2516
+ const cacheState = inject(CACHE_STATE);
2517
+ const pendingTasks = inject(ɵInitialRenderPendingTasks);
2518
+ return () => {
2519
+ const isStablePromise = appRef.isStable.pipe(first((isStable) => isStable)).toPromise();
2520
+ const pendingTasksPromise = pendingTasks.whenAllTasksComplete;
2521
+ Promise.allSettled([isStablePromise, pendingTasksPromise]).then(() => {
2522
+ cacheState.isCacheActive = false;
2523
+ });
2524
+ };
2525
+ },
2526
+ deps: [ApplicationRef, CACHE_STATE, ɵInitialRenderPendingTasks]
2527
+ }
2528
+ ];
2529
+ }
2530
+
2401
2531
  // This file is not used to build this module. It is only used during editing
2402
2532
 
2403
2533
  /**
2404
2534
  * Generated bundle index. Do not edit.
2405
2535
  */
2406
2536
 
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 };
2537
+ 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
2538
  //# sourceMappingURL=http.mjs.map