@angular/common 16.0.0 → 16.1.0-next.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 (54) hide show
  1. package/esm2022/http/src/client.mjs +3 -3
  2. package/esm2022/http/src/interceptor.mjs +3 -3
  3. package/esm2022/http/src/jsonp.mjs +6 -6
  4. package/esm2022/http/src/module.mjs +12 -12
  5. package/esm2022/http/src/request.mjs +1 -1
  6. package/esm2022/http/src/xhr.mjs +243 -232
  7. package/esm2022/http/src/xsrf.mjs +6 -6
  8. package/esm2022/http/testing/src/backend.mjs +3 -3
  9. package/esm2022/http/testing/src/module.mjs +4 -4
  10. package/esm2022/src/common_module.mjs +4 -4
  11. package/esm2022/src/directives/ng_class.mjs +3 -3
  12. package/esm2022/src/directives/ng_component_outlet.mjs +3 -3
  13. package/esm2022/src/directives/ng_for_of.mjs +3 -3
  14. package/esm2022/src/directives/ng_if.mjs +3 -3
  15. package/esm2022/src/directives/ng_optimized_image/lcp_image_observer.mjs +3 -3
  16. package/esm2022/src/directives/ng_optimized_image/ng_optimized_image.mjs +3 -3
  17. package/esm2022/src/directives/ng_optimized_image/preconnect_link_checker.mjs +3 -3
  18. package/esm2022/src/directives/ng_optimized_image/preload-link-creator.mjs +3 -3
  19. package/esm2022/src/directives/ng_plural.mjs +6 -6
  20. package/esm2022/src/directives/ng_style.mjs +3 -3
  21. package/esm2022/src/directives/ng_switch.mjs +9 -9
  22. package/esm2022/src/directives/ng_template_outlet.mjs +3 -3
  23. package/esm2022/src/i18n/localization.mjs +6 -6
  24. package/esm2022/src/location/hash_location_strategy.mjs +3 -3
  25. package/esm2022/src/location/location.mjs +3 -3
  26. package/esm2022/src/location/location_strategy.mjs +6 -6
  27. package/esm2022/src/location/platform_location.mjs +15 -42
  28. package/esm2022/src/pipes/async_pipe.mjs +3 -3
  29. package/esm2022/src/pipes/case_conversion_pipes.mjs +9 -9
  30. package/esm2022/src/pipes/date_pipe.mjs +3 -3
  31. package/esm2022/src/pipes/i18n_plural_pipe.mjs +3 -3
  32. package/esm2022/src/pipes/i18n_select_pipe.mjs +3 -3
  33. package/esm2022/src/pipes/json_pipe.mjs +3 -3
  34. package/esm2022/src/pipes/keyvalue_pipe.mjs +3 -3
  35. package/esm2022/src/pipes/number_pipe.mjs +9 -9
  36. package/esm2022/src/pipes/slice_pipe.mjs +3 -3
  37. package/esm2022/src/version.mjs +1 -1
  38. package/esm2022/testing/src/location_mock.mjs +3 -3
  39. package/esm2022/testing/src/mock_location_strategy.mjs +3 -3
  40. package/esm2022/testing/src/mock_platform_location.mjs +3 -3
  41. package/esm2022/upgrade/src/location_upgrade_module.mjs +4 -4
  42. package/fesm2022/common.mjs +122 -149
  43. package/fesm2022/common.mjs.map +1 -1
  44. package/fesm2022/http/testing.mjs +8 -8
  45. package/fesm2022/http.mjs +273 -263
  46. package/fesm2022/http.mjs.map +1 -1
  47. package/fesm2022/testing.mjs +10 -10
  48. package/fesm2022/upgrade.mjs +5 -5
  49. package/http/index.d.ts +2 -2
  50. package/http/testing/index.d.ts +1 -1
  51. package/index.d.ts +15 -15
  52. package/package.json +2 -2
  53. package/testing/index.d.ts +1 -1
  54. package/upgrade/index.d.ts +1 -1
package/fesm2022/http.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @license Angular v16.0.0
2
+ * @license Angular v16.1.0-next.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
8
  import { Injectable, InjectionToken, inject, Inject, PLATFORM_ID, makeEnvironmentProviders, NgModule, TransferState, makeStateKey, ɵENABLED_SSR_FEATURES, APP_BOOTSTRAP_LISTENER, ApplicationRef, ɵInitialRenderPendingTasks } from '@angular/core';
9
- import { of, Observable } from 'rxjs';
10
- import { concatMap, filter, map, tap, first } from 'rxjs/operators';
9
+ import { of, Observable, from } from 'rxjs';
10
+ import { concatMap, filter, map, switchMap, tap, first } from 'rxjs/operators';
11
11
  import * as i1 from '@angular/common';
12
12
  import { DOCUMENT, ɵparseCookieValue } from '@angular/common';
13
13
 
@@ -1371,10 +1371,10 @@ class HttpClient {
1371
1371
  put(url, body, options = {}) {
1372
1372
  return this.request('PUT', url, addBody(options, body));
1373
1373
  }
1374
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClient, deps: [{ token: HttpHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
1375
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClient }); }
1374
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClient, deps: [{ token: HttpHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
1375
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClient }); }
1376
1376
  }
1377
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClient, decorators: [{
1377
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClient, decorators: [{
1378
1378
  type: Injectable
1379
1379
  }], ctorParameters: function () { return [{ type: HttpHandler }]; } });
1380
1380
 
@@ -1453,10 +1453,10 @@ class HttpInterceptorHandler extends HttpHandler {
1453
1453
  }
1454
1454
  return this.chain(initialRequest, downstreamRequest => this.backend.handle(downstreamRequest));
1455
1455
  }
1456
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpInterceptorHandler, deps: [{ token: HttpBackend }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1457
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpInterceptorHandler }); }
1456
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpInterceptorHandler, deps: [{ token: HttpBackend }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1457
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpInterceptorHandler }); }
1458
1458
  }
1459
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpInterceptorHandler, decorators: [{
1459
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpInterceptorHandler, decorators: [{
1460
1460
  type: Injectable
1461
1461
  }], ctorParameters: function () { return [{ type: HttpBackend }, { type: i0.EnvironmentInjector }]; } });
1462
1462
 
@@ -1658,10 +1658,10 @@ class JsonpClientBackend {
1658
1658
  }
1659
1659
  foreignDocument.adoptNode(script);
1660
1660
  }
1661
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: JsonpClientBackend, deps: [{ token: JsonpCallbackContext }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1662
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: JsonpClientBackend }); }
1661
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: JsonpClientBackend, deps: [{ token: JsonpCallbackContext }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
1662
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: JsonpClientBackend }); }
1663
1663
  }
1664
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: JsonpClientBackend, decorators: [{
1664
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: JsonpClientBackend, decorators: [{
1665
1665
  type: Injectable
1666
1666
  }], ctorParameters: function () { return [{ type: JsonpCallbackContext }, { type: undefined, decorators: [{
1667
1667
  type: Inject,
@@ -1699,10 +1699,10 @@ class JsonpInterceptor {
1699
1699
  intercept(initialRequest, next) {
1700
1700
  return this.injector.runInContext(() => jsonpInterceptorFn(initialRequest, downstreamRequest => next.handle(downstreamRequest)));
1701
1701
  }
1702
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: JsonpInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1703
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: JsonpInterceptor }); }
1702
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: JsonpInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1703
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: JsonpInterceptor }); }
1704
1704
  }
1705
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: JsonpInterceptor, decorators: [{
1705
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: JsonpInterceptor, decorators: [{
1706
1706
  type: Injectable
1707
1707
  }], ctorParameters: function () { return [{ type: i0.EnvironmentInjector }]; } });
1708
1708
 
@@ -1742,252 +1742,262 @@ class HttpXhrBackend {
1742
1742
  if (req.method === 'JSONP') {
1743
1743
  throw new Error(`Attempted to construct Jsonp request without HttpClientJsonpModule installed.`);
1744
1744
  }
1745
- // Everything happens on Observable subscription.
1746
- return new Observable((observer) => {
1747
- // Start by setting up the XHR object with request method, URL, and withCredentials flag.
1748
- const xhr = this.xhrFactory.build();
1749
- xhr.open(req.method, req.urlWithParams);
1750
- if (!!req.withCredentials) {
1751
- xhr.withCredentials = true;
1752
- }
1753
- // Add all the requested headers.
1754
- req.headers.forEach((name, values) => xhr.setRequestHeader(name, values.join(',')));
1755
- // Add an Accept header if one isn't present already.
1756
- if (!req.headers.has('Accept')) {
1757
- xhr.setRequestHeader('Accept', 'application/json, text/plain, */*');
1758
- }
1759
- // Auto-detect the Content-Type header if one isn't present already.
1760
- if (!req.headers.has('Content-Type')) {
1761
- const detectedType = req.detectContentTypeHeader();
1762
- // Sometimes Content-Type detection fails.
1763
- if (detectedType !== null) {
1764
- xhr.setRequestHeader('Content-Type', detectedType);
1745
+ // Check whether this factory has a special function to load an XHR implementation
1746
+ // for various non-browser environments. We currently limit it to only `ServerXhr`
1747
+ // class, which needs to load an XHR implementation.
1748
+ const xhrFactory = this.xhrFactory;
1749
+ const source = xhrFactory.ɵloadImpl ? from(xhrFactory.ɵloadImpl()) : of(null);
1750
+ return source.pipe(switchMap(() => {
1751
+ // Everything happens on Observable subscription.
1752
+ return new Observable((observer) => {
1753
+ // Start by setting up the XHR object with request method, URL, and withCredentials
1754
+ // flag.
1755
+ const xhr = xhrFactory.build();
1756
+ xhr.open(req.method, req.urlWithParams);
1757
+ if (req.withCredentials) {
1758
+ xhr.withCredentials = true;
1765
1759
  }
1766
- }
1767
- // Set the responseType if one was requested.
1768
- if (req.responseType) {
1769
- const responseType = req.responseType.toLowerCase();
1770
- // JSON responses need to be processed as text. This is because if the server
1771
- // returns an XSSI-prefixed JSON response, the browser will fail to parse it,
1772
- // xhr.response will be null, and xhr.responseText cannot be accessed to
1773
- // retrieve the prefixed JSON data in order to strip the prefix. Thus, all JSON
1774
- // is parsed by first requesting text and then applying JSON.parse.
1775
- xhr.responseType = ((responseType !== 'json') ? responseType : 'text');
1776
- }
1777
- // Serialize the request body if one is present. If not, this will be set to null.
1778
- const reqBody = req.serializeBody();
1779
- // If progress events are enabled, response headers will be delivered
1780
- // in two events - the HttpHeaderResponse event and the full HttpResponse
1781
- // event. However, since response headers don't change in between these
1782
- // two events, it doesn't make sense to parse them twice. So headerResponse
1783
- // caches the data extracted from the response whenever it's first parsed,
1784
- // to ensure parsing isn't duplicated.
1785
- let headerResponse = null;
1786
- // partialFromXhr extracts the HttpHeaderResponse from the current XMLHttpRequest
1787
- // state, and memoizes it into headerResponse.
1788
- const partialFromXhr = () => {
1789
- if (headerResponse !== null) {
1790
- return headerResponse;
1760
+ // Add all the requested headers.
1761
+ req.headers.forEach((name, values) => xhr.setRequestHeader(name, values.join(',')));
1762
+ // Add an Accept header if one isn't present already.
1763
+ if (!req.headers.has('Accept')) {
1764
+ xhr.setRequestHeader('Accept', 'application/json, text/plain, */*');
1791
1765
  }
1792
- const statusText = xhr.statusText || 'OK';
1793
- // Parse headers from XMLHttpRequest - this step is lazy.
1794
- const headers = new HttpHeaders(xhr.getAllResponseHeaders());
1795
- // Read the response URL from the XMLHttpResponse instance and fall back on the
1796
- // request URL.
1797
- const url = getResponseUrl(xhr) || req.url;
1798
- // Construct the HttpHeaderResponse and memoize it.
1799
- headerResponse = new HttpHeaderResponse({ headers, status: xhr.status, statusText, url });
1800
- return headerResponse;
1801
- };
1802
- // Next, a few closures are defined for the various events which XMLHttpRequest can
1803
- // emit. This allows them to be unregistered as event listeners later.
1804
- // First up is the load event, which represents a response being fully available.
1805
- const onLoad = () => {
1806
- // Read response state from the memoized partial data.
1807
- let { headers, status, statusText, url } = partialFromXhr();
1808
- // The body will be read out if present.
1809
- let body = null;
1810
- if (status !== 204 /* HttpStatusCode.NoContent */) {
1811
- // Use XMLHttpRequest.response if set, responseText otherwise.
1812
- body = (typeof xhr.response === 'undefined') ? xhr.responseText : xhr.response;
1766
+ // Auto-detect the Content-Type header if one isn't present already.
1767
+ if (!req.headers.has('Content-Type')) {
1768
+ const detectedType = req.detectContentTypeHeader();
1769
+ // Sometimes Content-Type detection fails.
1770
+ if (detectedType !== null) {
1771
+ xhr.setRequestHeader('Content-Type', detectedType);
1772
+ }
1813
1773
  }
1814
- // Normalize another potential bug (this one comes from CORS).
1815
- if (status === 0) {
1816
- status = !!body ? 200 /* HttpStatusCode.Ok */ : 0;
1774
+ // Set the responseType if one was requested.
1775
+ if (req.responseType) {
1776
+ const responseType = req.responseType.toLowerCase();
1777
+ // JSON responses need to be processed as text. This is because if the server
1778
+ // returns an XSSI-prefixed JSON response, the browser will fail to parse it,
1779
+ // xhr.response will be null, and xhr.responseText cannot be accessed to
1780
+ // retrieve the prefixed JSON data in order to strip the prefix. Thus, all JSON
1781
+ // is parsed by first requesting text and then applying JSON.parse.
1782
+ xhr.responseType = ((responseType !== 'json') ? responseType : 'text');
1817
1783
  }
1818
- // ok determines whether the response will be transmitted on the event or
1819
- // error channel. Unsuccessful status codes (not 2xx) will always be errors,
1820
- // but a successful status code can still result in an error if the user
1821
- // asked for JSON data and the body cannot be parsed as such.
1822
- let ok = status >= 200 && status < 300;
1823
- // Check whether the body needs to be parsed as JSON (in many cases the browser
1824
- // will have done that already).
1825
- if (req.responseType === 'json' && typeof body === 'string') {
1826
- // Save the original body, before attempting XSSI prefix stripping.
1827
- const originalBody = body;
1828
- body = body.replace(XSSI_PREFIX, '');
1829
- try {
1830
- // Attempt the parse. If it fails, a parse error should be delivered to the user.
1831
- body = body !== '' ? JSON.parse(body) : null;
1784
+ // Serialize the request body if one is present. If not, this will be set to null.
1785
+ const reqBody = req.serializeBody();
1786
+ // If progress events are enabled, response headers will be delivered
1787
+ // in two events - the HttpHeaderResponse event and the full HttpResponse
1788
+ // event. However, since response headers don't change in between these
1789
+ // two events, it doesn't make sense to parse them twice. So headerResponse
1790
+ // caches the data extracted from the response whenever it's first parsed,
1791
+ // to ensure parsing isn't duplicated.
1792
+ let headerResponse = null;
1793
+ // partialFromXhr extracts the HttpHeaderResponse from the current XMLHttpRequest
1794
+ // state, and memoizes it into headerResponse.
1795
+ const partialFromXhr = () => {
1796
+ if (headerResponse !== null) {
1797
+ return headerResponse;
1832
1798
  }
1833
- catch (error) {
1834
- // Since the JSON.parse failed, it's reasonable to assume this might not have been a
1835
- // JSON response. Restore the original body (including any XSSI prefix) to deliver
1836
- // a better error response.
1837
- body = originalBody;
1838
- // If this was an error request to begin with, leave it as a string, it probably
1839
- // just isn't JSON. Otherwise, deliver the parsing error to the user.
1840
- if (ok) {
1841
- // Even though the response status was 2xx, this is still an error.
1842
- ok = false;
1843
- // The parse error contains the text of the body that failed to parse.
1844
- body = { error, text: body };
1799
+ const statusText = xhr.statusText || 'OK';
1800
+ // Parse headers from XMLHttpRequest - this step is lazy.
1801
+ const headers = new HttpHeaders(xhr.getAllResponseHeaders());
1802
+ // Read the response URL from the XMLHttpResponse instance and fall back on the
1803
+ // request URL.
1804
+ const url = getResponseUrl(xhr) || req.url;
1805
+ // Construct the HttpHeaderResponse and memoize it.
1806
+ headerResponse =
1807
+ new HttpHeaderResponse({ headers, status: xhr.status, statusText, url });
1808
+ return headerResponse;
1809
+ };
1810
+ // Next, a few closures are defined for the various events which XMLHttpRequest can
1811
+ // emit. This allows them to be unregistered as event listeners later.
1812
+ // First up is the load event, which represents a response being fully available.
1813
+ const onLoad = () => {
1814
+ // Read response state from the memoized partial data.
1815
+ let { headers, status, statusText, url } = partialFromXhr();
1816
+ // The body will be read out if present.
1817
+ let body = null;
1818
+ if (status !== 204 /* HttpStatusCode.NoContent */) {
1819
+ // Use XMLHttpRequest.response if set, responseText otherwise.
1820
+ body = (typeof xhr.response === 'undefined') ? xhr.responseText : xhr.response;
1821
+ }
1822
+ // Normalize another potential bug (this one comes from CORS).
1823
+ if (status === 0) {
1824
+ status = !!body ? 200 /* HttpStatusCode.Ok */ : 0;
1825
+ }
1826
+ // ok determines whether the response will be transmitted on the event or
1827
+ // error channel. Unsuccessful status codes (not 2xx) will always be errors,
1828
+ // but a successful status code can still result in an error if the user
1829
+ // asked for JSON data and the body cannot be parsed as such.
1830
+ let ok = status >= 200 && status < 300;
1831
+ // Check whether the body needs to be parsed as JSON (in many cases the browser
1832
+ // will have done that already).
1833
+ if (req.responseType === 'json' && typeof body === 'string') {
1834
+ // Save the original body, before attempting XSSI prefix stripping.
1835
+ const originalBody = body;
1836
+ body = body.replace(XSSI_PREFIX, '');
1837
+ try {
1838
+ // Attempt the parse. If it fails, a parse error should be delivered to the
1839
+ // user.
1840
+ body = body !== '' ? JSON.parse(body) : null;
1841
+ }
1842
+ catch (error) {
1843
+ // Since the JSON.parse failed, it's reasonable to assume this might not have
1844
+ // been a JSON response. Restore the original body (including any XSSI prefix)
1845
+ // to deliver a better error response.
1846
+ body = originalBody;
1847
+ // If this was an error request to begin with, leave it as a string, it
1848
+ // probably just isn't JSON. Otherwise, deliver the parsing error to the user.
1849
+ if (ok) {
1850
+ // Even though the response status was 2xx, this is still an error.
1851
+ ok = false;
1852
+ // The parse error contains the text of the body that failed to parse.
1853
+ body = { error, text: body };
1854
+ }
1845
1855
  }
1846
1856
  }
1847
- }
1848
- if (ok) {
1849
- // A successful response is delivered on the event stream.
1850
- observer.next(new HttpResponse({
1851
- body,
1852
- headers,
1853
- status,
1854
- statusText,
1855
- url: url || undefined,
1856
- }));
1857
- // The full body has been received and delivered, no further events
1858
- // are possible. This request is complete.
1859
- observer.complete();
1860
- }
1861
- else {
1862
- // An unsuccessful request is delivered on the error channel.
1863
- observer.error(new HttpErrorResponse({
1864
- // The error in this case is the response body (error from the server).
1865
- error: body,
1866
- headers,
1867
- status,
1868
- statusText,
1857
+ if (ok) {
1858
+ // A successful response is delivered on the event stream.
1859
+ observer.next(new HttpResponse({
1860
+ body,
1861
+ headers,
1862
+ status,
1863
+ statusText,
1864
+ url: url || undefined,
1865
+ }));
1866
+ // The full body has been received and delivered, no further events
1867
+ // are possible. This request is complete.
1868
+ observer.complete();
1869
+ }
1870
+ else {
1871
+ // An unsuccessful request is delivered on the error channel.
1872
+ observer.error(new HttpErrorResponse({
1873
+ // The error in this case is the response body (error from the server).
1874
+ error: body,
1875
+ headers,
1876
+ status,
1877
+ statusText,
1878
+ url: url || undefined,
1879
+ }));
1880
+ }
1881
+ };
1882
+ // The onError callback is called when something goes wrong at the network level.
1883
+ // Connection timeout, DNS error, offline, etc. These are actual errors, and are
1884
+ // transmitted on the error channel.
1885
+ const onError = (error) => {
1886
+ const { url } = partialFromXhr();
1887
+ const res = new HttpErrorResponse({
1888
+ error,
1889
+ status: xhr.status || 0,
1890
+ statusText: xhr.statusText || 'Unknown Error',
1869
1891
  url: url || undefined,
1870
- }));
1871
- }
1872
- };
1873
- // The onError callback is called when something goes wrong at the network level.
1874
- // Connection timeout, DNS error, offline, etc. These are actual errors, and are
1875
- // transmitted on the error channel.
1876
- const onError = (error) => {
1877
- const { url } = partialFromXhr();
1878
- const res = new HttpErrorResponse({
1879
- error,
1880
- status: xhr.status || 0,
1881
- statusText: xhr.statusText || 'Unknown Error',
1882
- url: url || undefined,
1883
- });
1884
- observer.error(res);
1885
- };
1886
- // The sentHeaders flag tracks whether the HttpResponseHeaders event
1887
- // has been sent on the stream. This is necessary to track if progress
1888
- // is enabled since the event will be sent on only the first download
1889
- // progress event.
1890
- let sentHeaders = false;
1891
- // The download progress event handler, which is only registered if
1892
- // progress events are enabled.
1893
- const onDownProgress = (event) => {
1894
- // Send the HttpResponseHeaders event if it hasn't been sent already.
1895
- if (!sentHeaders) {
1896
- observer.next(partialFromXhr());
1897
- sentHeaders = true;
1898
- }
1899
- // Start building the download progress event to deliver on the response
1900
- // event stream.
1901
- let progressEvent = {
1902
- type: HttpEventType.DownloadProgress,
1903
- loaded: event.loaded,
1892
+ });
1893
+ observer.error(res);
1904
1894
  };
1905
- // Set the total number of bytes in the event if it's available.
1906
- if (event.lengthComputable) {
1907
- progressEvent.total = event.total;
1908
- }
1909
- // If the request was for text content and a partial response is
1910
- // available on XMLHttpRequest, include it in the progress event
1911
- // to allow for streaming reads.
1912
- if (req.responseType === 'text' && !!xhr.responseText) {
1913
- progressEvent.partialText = xhr.responseText;
1914
- }
1915
- // Finally, fire the event.
1916
- observer.next(progressEvent);
1917
- };
1918
- // The upload progress event handler, which is only registered if
1919
- // progress events are enabled.
1920
- const onUpProgress = (event) => {
1921
- // Upload progress events are simpler. Begin building the progress
1922
- // event.
1923
- let progress = {
1924
- type: HttpEventType.UploadProgress,
1925
- loaded: event.loaded,
1895
+ // The sentHeaders flag tracks whether the HttpResponseHeaders event
1896
+ // has been sent on the stream. This is necessary to track if progress
1897
+ // is enabled since the event will be sent on only the first download
1898
+ // progress event.
1899
+ let sentHeaders = false;
1900
+ // The download progress event handler, which is only registered if
1901
+ // progress events are enabled.
1902
+ const onDownProgress = (event) => {
1903
+ // Send the HttpResponseHeaders event if it hasn't been sent already.
1904
+ if (!sentHeaders) {
1905
+ observer.next(partialFromXhr());
1906
+ sentHeaders = true;
1907
+ }
1908
+ // Start building the download progress event to deliver on the response
1909
+ // event stream.
1910
+ let progressEvent = {
1911
+ type: HttpEventType.DownloadProgress,
1912
+ loaded: event.loaded,
1913
+ };
1914
+ // Set the total number of bytes in the event if it's available.
1915
+ if (event.lengthComputable) {
1916
+ progressEvent.total = event.total;
1917
+ }
1918
+ // If the request was for text content and a partial response is
1919
+ // available on XMLHttpRequest, include it in the progress event
1920
+ // to allow for streaming reads.
1921
+ if (req.responseType === 'text' && !!xhr.responseText) {
1922
+ progressEvent.partialText = xhr.responseText;
1923
+ }
1924
+ // Finally, fire the event.
1925
+ observer.next(progressEvent);
1926
1926
  };
1927
- // If the total number of bytes being uploaded is available, include
1928
- // it.
1929
- if (event.lengthComputable) {
1930
- progress.total = event.total;
1931
- }
1932
- // Send the event.
1933
- observer.next(progress);
1934
- };
1935
- // By default, register for load and error events.
1936
- xhr.addEventListener('load', onLoad);
1937
- xhr.addEventListener('error', onError);
1938
- xhr.addEventListener('timeout', onError);
1939
- xhr.addEventListener('abort', onError);
1940
- // Progress events are only enabled if requested.
1941
- if (req.reportProgress) {
1942
- // Download progress is always enabled if requested.
1943
- xhr.addEventListener('progress', onDownProgress);
1944
- // Upload progress depends on whether there is a body to upload.
1945
- if (reqBody !== null && xhr.upload) {
1946
- xhr.upload.addEventListener('progress', onUpProgress);
1947
- }
1948
- }
1949
- let macroTaskCanceller;
1950
- /** Tear down logic to cancel the backround macrotask. */
1951
- const onLoadStart = () => {
1952
- macroTaskCanceller ??= createBackgroundMacroTask();
1953
- };
1954
- const onLoadEnd = () => {
1955
- macroTaskCanceller?.();
1956
- };
1957
- xhr.addEventListener('loadstart', onLoadStart);
1958
- xhr.addEventListener('loadend', onLoadEnd);
1959
- // Fire the request, and notify the event stream that it was fired.
1960
- xhr.send(reqBody);
1961
- observer.next({ type: HttpEventType.Sent });
1962
- // This is the return from the Observable function, which is the
1963
- // request cancellation handler.
1964
- return () => {
1965
- // On a cancellation, remove all registered event listeners.
1966
- xhr.removeEventListener('loadstart', onLoadStart);
1967
- xhr.removeEventListener('loadend', onLoadEnd);
1968
- xhr.removeEventListener('error', onError);
1969
- xhr.removeEventListener('abort', onError);
1970
- xhr.removeEventListener('load', onLoad);
1971
- xhr.removeEventListener('timeout', onError);
1972
- // Cancel the background macrotask.
1973
- macroTaskCanceller?.();
1927
+ // The upload progress event handler, which is only registered if
1928
+ // progress events are enabled.
1929
+ const onUpProgress = (event) => {
1930
+ // Upload progress events are simpler. Begin building the progress
1931
+ // event.
1932
+ let progress = {
1933
+ type: HttpEventType.UploadProgress,
1934
+ loaded: event.loaded,
1935
+ };
1936
+ // If the total number of bytes being uploaded is available, include
1937
+ // it.
1938
+ if (event.lengthComputable) {
1939
+ progress.total = event.total;
1940
+ }
1941
+ // Send the event.
1942
+ observer.next(progress);
1943
+ };
1944
+ // By default, register for load and error events.
1945
+ xhr.addEventListener('load', onLoad);
1946
+ xhr.addEventListener('error', onError);
1947
+ xhr.addEventListener('timeout', onError);
1948
+ xhr.addEventListener('abort', onError);
1949
+ // Progress events are only enabled if requested.
1974
1950
  if (req.reportProgress) {
1975
- xhr.removeEventListener('progress', onDownProgress);
1951
+ // Download progress is always enabled if requested.
1952
+ xhr.addEventListener('progress', onDownProgress);
1953
+ // Upload progress depends on whether there is a body to upload.
1976
1954
  if (reqBody !== null && xhr.upload) {
1977
- xhr.upload.removeEventListener('progress', onUpProgress);
1955
+ xhr.upload.addEventListener('progress', onUpProgress);
1978
1956
  }
1979
1957
  }
1980
- // Finally, abort the in-flight request.
1981
- if (xhr.readyState !== xhr.DONE) {
1982
- xhr.abort();
1983
- }
1984
- };
1985
- });
1958
+ let macroTaskCanceller;
1959
+ /** Tear down logic to cancel the backround macrotask. */
1960
+ const onLoadStart = () => {
1961
+ macroTaskCanceller ??= createBackgroundMacroTask();
1962
+ };
1963
+ const onLoadEnd = () => {
1964
+ macroTaskCanceller?.();
1965
+ };
1966
+ xhr.addEventListener('loadstart', onLoadStart);
1967
+ xhr.addEventListener('loadend', onLoadEnd);
1968
+ // Fire the request, and notify the event stream that it was fired.
1969
+ xhr.send(reqBody);
1970
+ observer.next({ type: HttpEventType.Sent });
1971
+ // This is the return from the Observable function, which is the
1972
+ // request cancellation handler.
1973
+ return () => {
1974
+ // On a cancellation, remove all registered event listeners.
1975
+ xhr.removeEventListener('loadstart', onLoadStart);
1976
+ xhr.removeEventListener('loadend', onLoadEnd);
1977
+ xhr.removeEventListener('error', onError);
1978
+ xhr.removeEventListener('abort', onError);
1979
+ xhr.removeEventListener('load', onLoad);
1980
+ xhr.removeEventListener('timeout', onError);
1981
+ // Cancel the background macrotask.
1982
+ macroTaskCanceller?.();
1983
+ if (req.reportProgress) {
1984
+ xhr.removeEventListener('progress', onDownProgress);
1985
+ if (reqBody !== null && xhr.upload) {
1986
+ xhr.upload.removeEventListener('progress', onUpProgress);
1987
+ }
1988
+ }
1989
+ // Finally, abort the in-flight request.
1990
+ if (xhr.readyState !== xhr.DONE) {
1991
+ xhr.abort();
1992
+ }
1993
+ };
1994
+ });
1995
+ }));
1986
1996
  }
1987
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXhrBackend, deps: [{ token: i1.XhrFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
1988
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXhrBackend }); }
1997
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXhrBackend, deps: [{ token: i1.XhrFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
1998
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXhrBackend }); }
1989
1999
  }
1990
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXhrBackend, decorators: [{
2000
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXhrBackend, decorators: [{
1991
2001
  type: Injectable
1992
2002
  }], ctorParameters: function () { return [{ type: i1.XhrFactory }]; } });
1993
2003
  // Cannot use `Number.MAX_VALUE` as it does not fit into a 32-bit signed integer.
@@ -2051,10 +2061,10 @@ class HttpXsrfCookieExtractor {
2051
2061
  }
2052
2062
  return this.lastToken;
2053
2063
  }
2054
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXsrfCookieExtractor, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: XSRF_COOKIE_NAME }], target: i0.ɵɵFactoryTarget.Injectable }); }
2055
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXsrfCookieExtractor }); }
2064
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXsrfCookieExtractor, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: XSRF_COOKIE_NAME }], target: i0.ɵɵFactoryTarget.Injectable }); }
2065
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXsrfCookieExtractor }); }
2056
2066
  }
2057
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXsrfCookieExtractor, decorators: [{
2067
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXsrfCookieExtractor, decorators: [{
2058
2068
  type: Injectable
2059
2069
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2060
2070
  type: Inject,
@@ -2094,10 +2104,10 @@ class HttpXsrfInterceptor {
2094
2104
  intercept(initialRequest, next) {
2095
2105
  return this.injector.runInContext(() => xsrfInterceptorFn(initialRequest, downstreamRequest => next.handle(downstreamRequest)));
2096
2106
  }
2097
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXsrfInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
2098
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXsrfInterceptor }); }
2107
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXsrfInterceptor, deps: [{ token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Injectable }); }
2108
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXsrfInterceptor }); }
2099
2109
  }
2100
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpXsrfInterceptor, decorators: [{
2110
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpXsrfInterceptor, decorators: [{
2101
2111
  type: Injectable
2102
2112
  }], ctorParameters: function () { return [{ type: i0.EnvironmentInjector }]; } });
2103
2113
 
@@ -2329,9 +2339,9 @@ class HttpClientXsrfModule {
2329
2339
  providers: withXsrfConfiguration(options).ɵproviders,
2330
2340
  };
2331
2341
  }
2332
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientXsrfModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2333
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: HttpClientXsrfModule }); }
2334
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientXsrfModule, providers: [
2342
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientXsrfModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2343
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientXsrfModule }); }
2344
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientXsrfModule, providers: [
2335
2345
  HttpXsrfInterceptor,
2336
2346
  { provide: HTTP_INTERCEPTORS, useExisting: HttpXsrfInterceptor, multi: true },
2337
2347
  { provide: HttpXsrfTokenExtractor, useClass: HttpXsrfCookieExtractor },
@@ -2342,7 +2352,7 @@ class HttpClientXsrfModule {
2342
2352
  { provide: XSRF_ENABLED, useValue: true },
2343
2353
  ] }); }
2344
2354
  }
2345
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientXsrfModule, decorators: [{
2355
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientXsrfModule, decorators: [{
2346
2356
  type: NgModule,
2347
2357
  args: [{
2348
2358
  providers: [
@@ -2367,13 +2377,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImpor
2367
2377
  * @publicApi
2368
2378
  */
2369
2379
  class HttpClientModule {
2370
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2371
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: HttpClientModule }); }
2372
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientModule, providers: [
2380
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2381
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientModule }); }
2382
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientModule, providers: [
2373
2383
  provideHttpClient(withInterceptorsFromDi()),
2374
2384
  ] }); }
2375
2385
  }
2376
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientModule, decorators: [{
2386
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientModule, decorators: [{
2377
2387
  type: NgModule,
2378
2388
  args: [{
2379
2389
  /**
@@ -2394,13 +2404,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImpor
2394
2404
  * @publicApi
2395
2405
  */
2396
2406
  class HttpClientJsonpModule {
2397
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientJsonpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2398
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: HttpClientJsonpModule }); }
2399
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientJsonpModule, providers: [
2407
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientJsonpModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2408
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientJsonpModule }); }
2409
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientJsonpModule, providers: [
2400
2410
  withJsonpSupport().ɵproviders,
2401
2411
  ] }); }
2402
2412
  }
2403
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: HttpClientJsonpModule, decorators: [{
2413
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.0-next.0", ngImport: i0, type: HttpClientJsonpModule, decorators: [{
2404
2414
  type: NgModule,
2405
2415
  args: [{
2406
2416
  providers: [