@angular/common 21.2.0-rc.0 → 21.2.1
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.
- package/fesm2022/_common_module-chunk.mjs +94 -87
- package/fesm2022/_common_module-chunk.mjs.map +1 -1
- package/fesm2022/_location-chunk.mjs +16 -16
- package/fesm2022/_location-chunk.mjs.map +1 -1
- package/fesm2022/_module-chunk.mjs +46 -46
- package/fesm2022/_module-chunk.mjs.map +1 -1
- package/fesm2022/_platform_location-chunk.mjs +7 -7
- package/fesm2022/_platform_location-chunk.mjs.map +1 -1
- package/fesm2022/_platform_navigation-chunk.mjs +4 -4
- package/fesm2022/_platform_navigation-chunk.mjs.map +1 -1
- package/fesm2022/_xhr-chunk.mjs +1 -1
- package/fesm2022/_xhr-chunk.mjs.map +1 -1
- package/fesm2022/common.mjs +62 -29
- package/fesm2022/common.mjs.map +1 -1
- package/fesm2022/http-testing.mjs +8 -8
- package/fesm2022/http-testing.mjs.map +1 -1
- package/fesm2022/http.mjs +226 -165
- package/fesm2022/http.mjs.map +1 -1
- package/fesm2022/testing.mjs +13 -13
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/upgrade.mjs +5 -5
- package/fesm2022/upgrade.mjs.map +1 -1
- package/package.json +2 -2
- package/types/_common_module-chunk.d.ts +1 -1
- package/types/_module-chunk.d.ts +1 -1
- package/types/_platform_location-chunk.d.ts +1 -1
- package/types/_xhr-chunk.d.ts +1 -1
- package/types/common.d.ts +1 -1
- package/types/http-testing.d.ts +1 -1
- package/types/http.d.ts +1 -1
- package/types/testing.d.ts +1 -1
- package/types/upgrade.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.2.
|
|
2
|
+
* @license Angular v21.2.1
|
|
3
3
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -227,7 +227,7 @@ class HttpClientTestingBackend {
|
|
|
227
227
|
}
|
|
228
228
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
229
229
|
minVersion: "12.0.0",
|
|
230
|
-
version: "21.2.
|
|
230
|
+
version: "21.2.1",
|
|
231
231
|
ngImport: i0,
|
|
232
232
|
type: HttpClientTestingBackend,
|
|
233
233
|
deps: [],
|
|
@@ -235,14 +235,14 @@ class HttpClientTestingBackend {
|
|
|
235
235
|
});
|
|
236
236
|
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
237
237
|
minVersion: "12.0.0",
|
|
238
|
-
version: "21.2.
|
|
238
|
+
version: "21.2.1",
|
|
239
239
|
ngImport: i0,
|
|
240
240
|
type: HttpClientTestingBackend
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
243
|
i0.ɵɵngDeclareClassMetadata({
|
|
244
244
|
minVersion: "12.0.0",
|
|
245
|
-
version: "21.2.
|
|
245
|
+
version: "21.2.1",
|
|
246
246
|
ngImport: i0,
|
|
247
247
|
type: HttpClientTestingBackend,
|
|
248
248
|
decorators: [{
|
|
@@ -271,7 +271,7 @@ function provideHttpClientTesting() {
|
|
|
271
271
|
class HttpClientTestingModule {
|
|
272
272
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
273
273
|
minVersion: "12.0.0",
|
|
274
|
-
version: "21.2.
|
|
274
|
+
version: "21.2.1",
|
|
275
275
|
ngImport: i0,
|
|
276
276
|
type: HttpClientTestingModule,
|
|
277
277
|
deps: [],
|
|
@@ -279,14 +279,14 @@ class HttpClientTestingModule {
|
|
|
279
279
|
});
|
|
280
280
|
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
281
281
|
minVersion: "14.0.0",
|
|
282
|
-
version: "21.2.
|
|
282
|
+
version: "21.2.1",
|
|
283
283
|
ngImport: i0,
|
|
284
284
|
type: HttpClientTestingModule,
|
|
285
285
|
imports: [HttpClientModule]
|
|
286
286
|
});
|
|
287
287
|
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
288
288
|
minVersion: "12.0.0",
|
|
289
|
-
version: "21.2.
|
|
289
|
+
version: "21.2.1",
|
|
290
290
|
ngImport: i0,
|
|
291
291
|
type: HttpClientTestingModule,
|
|
292
292
|
providers: [provideHttpClientTesting()],
|
|
@@ -295,7 +295,7 @@ class HttpClientTestingModule {
|
|
|
295
295
|
}
|
|
296
296
|
i0.ɵɵngDeclareClassMetadata({
|
|
297
297
|
minVersion: "12.0.0",
|
|
298
|
-
version: "21.2.
|
|
298
|
+
version: "21.2.1",
|
|
299
299
|
ngImport: i0,
|
|
300
300
|
type: HttpClientTestingModule,
|
|
301
301
|
decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/api.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/request.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/backend.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/provider.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {HttpRequest} from '../../index';\n\nimport {TestRequest} from './request';\n\n/**\n * Defines a matcher for requests based on URL, method, or both.\n *\n * @publicApi\n */\nexport interface RequestMatch {\n method?: string;\n url?: string;\n}\n\n/**\n * Controller to be injected into tests, that allows for mocking and flushing\n * of requests.\n *\n * @publicApi\n */\nexport abstract class HttpTestingController {\n /**\n * Search for requests that match the given parameter, without any expectations.\n */\n abstract match(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n ): TestRequest[];\n\n /**\n * Expect that a single request has been made which matches the given URL, and return its\n * mock.\n *\n * If no such request has been made, or more than one such request has been made, fail with an\n * error message including the given request description, if any.\n */\n abstract expectOne(url: string, description?: string): TestRequest;\n\n /**\n * Expect that a single request has been made which matches the given parameters, and return\n * its mock.\n *\n * If no such request has been made, or more than one such request has been made, fail with an\n * error message including the given request description, if any.\n */\n abstract expectOne(params: RequestMatch, description?: string): TestRequest;\n\n /**\n * Expect that a single request has been made which matches the given predicate function, and\n * return its mock.\n *\n * If no such request has been made, or more than one such request has been made, fail with an\n * error message including the given request description, if any.\n */\n abstract expectOne(\n matchFn: (req: HttpRequest<any>) => boolean,\n description?: string,\n ): TestRequest;\n\n /**\n * Expect that a single request has been made which matches the given condition, and return\n * its mock.\n *\n * If no such request has been made, or more than one such request has been made, fail with an\n * error message including the given request description, if any.\n */\n abstract expectOne(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n description?: string,\n ): TestRequest;\n\n /**\n * Expect that no requests have been made which match the given URL.\n *\n * If a matching request has been made, fail with an error message including the given request\n * description, if any.\n */\n abstract expectNone(url: string, description?: string): void;\n\n /**\n * Expect that no requests have been made which match the given parameters.\n *\n * If a matching request has been made, fail with an error message including the given request\n * description, if any.\n */\n abstract expectNone(params: RequestMatch, description?: string): void;\n\n /**\n * Expect that no requests have been made which match the given predicate function.\n *\n * If a matching request has been made, fail with an error message including the given request\n * description, if any.\n */\n abstract expectNone(matchFn: (req: HttpRequest<any>) => boolean, description?: string): void;\n\n /**\n * Expect that no requests have been made which match the given condition.\n *\n * If a matching request has been made, fail with an error message including the given request\n * description, if any.\n */\n abstract expectNone(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n description?: string,\n ): void;\n\n /**\n * Verify that no unmatched requests are outstanding.\n *\n * If any requests are outstanding, fail with an error message indicating which requests were not\n * handled.\n *\n * If `ignoreCancelled` is not set (the default), `verify()` will also fail if cancelled requests\n * were not explicitly matched.\n */\n abstract verify(opts?: {ignoreCancelled?: boolean}): void;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n HttpErrorResponse,\n HttpEvent,\n HttpHeaders,\n HttpRequest,\n HttpResponse,\n HttpStatusCode,\n} from '../../index';\nimport {Observer} from 'rxjs';\n\n/**\n * Type that describes options that can be used to create an error\n * in `TestRequest`.\n */\ntype TestRequestErrorOptions = {\n headers?: HttpHeaders | {[name: string]: string | string[]};\n status?: number;\n statusText?: string;\n};\n\n/**\n * A mock requests that was received and is ready to be answered.\n *\n * This interface allows access to the underlying `HttpRequest`, and allows\n * responding with `HttpEvent`s or `HttpErrorResponse`s.\n *\n * @publicApi\n */\nexport class TestRequest {\n /**\n * Whether the request was cancelled after it was sent.\n */\n get cancelled(): boolean {\n return this._cancelled;\n }\n\n /**\n * @internal set by `HttpClientTestingBackend`\n */\n _cancelled = false;\n\n constructor(\n public request: HttpRequest<any>,\n private observer: Observer<HttpEvent<any>>,\n ) {}\n\n /**\n * Resolve the request by returning a body plus additional HTTP information (such as response\n * headers) if provided.\n * If the request specifies an expected body type, the body is converted into the requested type.\n * Otherwise, the body is converted to `JSON` by default.\n *\n * Both successful and unsuccessful responses can be delivered via `flush()`.\n */\n flush(\n body:\n | ArrayBuffer\n | Blob\n | boolean\n | string\n | number\n | Object\n | (boolean | string | number | Object | null)[]\n | null,\n opts: {\n headers?: HttpHeaders | {[name: string]: string | string[]};\n status?: number;\n statusText?: string;\n } = {},\n ): void {\n if (this.cancelled) {\n throw new Error(`Cannot flush a cancelled request.`);\n }\n const url = this.request.urlWithParams;\n const headers =\n opts.headers instanceof HttpHeaders ? opts.headers : new HttpHeaders(opts.headers);\n body = _maybeConvertBody(this.request.responseType, body);\n let statusText: string | undefined = opts.statusText;\n let status: number = opts.status !== undefined ? opts.status : HttpStatusCode.Ok;\n if (opts.status === undefined) {\n if (body === null) {\n status = HttpStatusCode.NoContent;\n statusText ||= 'No Content';\n } else {\n statusText ||= 'OK';\n }\n }\n if (statusText === undefined) {\n throw new Error('statusText is required when setting a custom status.');\n }\n if (status >= 200 && status < 300) {\n this.observer.next(new HttpResponse<any>({body, headers, status, statusText, url}));\n this.observer.complete();\n } else {\n this.observer.error(new HttpErrorResponse({error: body, headers, status, statusText, url}));\n }\n }\n\n /**\n * Resolve the request by returning an `ErrorEvent` (e.g. simulating a network failure).\n * @deprecated Http requests never emit an `ErrorEvent`. Please specify a `ProgressEvent`.\n */\n error(error: ErrorEvent, opts?: TestRequestErrorOptions): void;\n /**\n * Resolve the request by returning an `ProgressEvent` (e.g. simulating a network failure).\n */\n error(error: ProgressEvent, opts?: TestRequestErrorOptions): void;\n error(error: ProgressEvent | ErrorEvent, opts: TestRequestErrorOptions = {}): void {\n if (this.cancelled) {\n throw new Error(`Cannot return an error for a cancelled request.`);\n }\n const headers =\n opts.headers instanceof HttpHeaders ? opts.headers : new HttpHeaders(opts.headers);\n this.observer.error(\n new HttpErrorResponse({\n error,\n headers,\n status: opts.status || 0,\n statusText: opts.statusText || '',\n url: this.request.urlWithParams,\n }),\n );\n }\n\n /**\n * Deliver an arbitrary `HttpEvent` (such as a progress event) on the response stream for this\n * request.\n */\n event(event: HttpEvent<any>): void {\n if (this.cancelled) {\n throw new Error(`Cannot send events to a cancelled request.`);\n }\n this.observer.next(event);\n }\n}\n\n/**\n * Helper function to convert a response body to an ArrayBuffer.\n */\nfunction _toArrayBufferBody(\n body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[],\n): ArrayBuffer {\n if (typeof ArrayBuffer === 'undefined') {\n throw new Error('ArrayBuffer responses are not supported on this platform.');\n }\n if (body instanceof ArrayBuffer) {\n return body;\n }\n throw new Error('Automatic conversion to ArrayBuffer is not supported for response type.');\n}\n\n/**\n * Helper function to convert a response body to a Blob.\n */\nfunction _toBlob(\n body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[],\n): Blob {\n if (typeof Blob === 'undefined') {\n throw new Error('Blob responses are not supported on this platform.');\n }\n if (body instanceof Blob) {\n return body;\n }\n if (ArrayBuffer && body instanceof ArrayBuffer) {\n return new Blob([body]);\n }\n throw new Error('Automatic conversion to Blob is not supported for response type.');\n}\n\n/**\n * Helper function to convert a response body to JSON data.\n */\nfunction _toJsonBody(\n body:\n | ArrayBuffer\n | Blob\n | boolean\n | string\n | number\n | Object\n | (boolean | string | number | Object | null)[],\n format: string = 'JSON',\n): Object | string | number | (Object | string | number)[] {\n if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {\n throw new Error(`Automatic conversion to ${format} is not supported for ArrayBuffers.`);\n }\n if (typeof Blob !== 'undefined' && body instanceof Blob) {\n throw new Error(`Automatic conversion to ${format} is not supported for Blobs.`);\n }\n if (\n typeof body === 'string' ||\n typeof body === 'number' ||\n typeof body === 'object' ||\n typeof body === 'boolean' ||\n Array.isArray(body)\n ) {\n return body;\n }\n throw new Error(`Automatic conversion to ${format} is not supported for response type.`);\n}\n\n/**\n * Helper function to convert a response body to a string.\n */\nfunction _toTextBody(\n body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[],\n): string {\n if (typeof body === 'string') {\n return body;\n }\n if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {\n throw new Error('Automatic conversion to text is not supported for ArrayBuffers.');\n }\n if (typeof Blob !== 'undefined' && body instanceof Blob) {\n throw new Error('Automatic conversion to text is not supported for Blobs.');\n }\n return JSON.stringify(_toJsonBody(body, 'text'));\n}\n\n/**\n * Convert a response body to the requested type.\n */\nfunction _maybeConvertBody(\n responseType: string,\n body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null,\n): ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null {\n if (body === null) {\n return null;\n }\n switch (responseType) {\n case 'arraybuffer':\n return _toArrayBufferBody(body);\n case 'blob':\n return _toBlob(body);\n case 'json':\n return _toJsonBody(body);\n case 'text':\n return _toTextBody(body);\n default:\n throw new Error(`Unsupported responseType: ${responseType}`);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {HttpBackend, HttpEvent, HttpEventType, HttpRequest} from '../../index';\nimport {Injectable} from '@angular/core';\nimport {Observable, Observer} from 'rxjs';\n\nimport {HttpTestingController, RequestMatch} from './api';\nimport {TestRequest} from './request';\n\n/**\n * A testing backend for `HttpClient` which both acts as an `HttpBackend`\n * and as the `HttpTestingController`.\n *\n * `HttpClientTestingBackend` works by keeping a list of all open requests.\n * As requests come in, they're added to the list. Users can assert that specific\n * requests were made and then flush them. In the end, a verify() method asserts\n * that no unexpected requests were made.\n *\n *\n */\n@Injectable()\nexport class HttpClientTestingBackend implements HttpBackend, HttpTestingController {\n /**\n * List of pending requests which have not yet been expected.\n */\n private open: TestRequest[] = [];\n\n /**\n * Used when checking if we need to throw the NOT_USING_FETCH_BACKEND_IN_SSR error\n */\n private isTestingBackend = true;\n\n /**\n * Handle an incoming request by queueing it in the list of open requests.\n */\n handle(req: HttpRequest<any>): Observable<HttpEvent<any>> {\n return new Observable((observer: Observer<any>) => {\n const testReq = new TestRequest(req, observer);\n this.open.push(testReq);\n observer.next({type: HttpEventType.Sent} as HttpEvent<any>);\n return () => {\n testReq._cancelled = true;\n };\n });\n }\n\n /**\n * Helper function to search for requests in the list of open requests.\n */\n private _match(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n ): TestRequest[] {\n if (typeof match === 'string') {\n return this.open.filter((testReq) => testReq.request.urlWithParams === match);\n } else if (typeof match === 'function') {\n return this.open.filter((testReq) => match(testReq.request));\n } else {\n return this.open.filter(\n (testReq) =>\n (!match.method || testReq.request.method === match.method.toUpperCase()) &&\n (!match.url || testReq.request.urlWithParams === match.url),\n );\n }\n }\n\n /**\n * Search for requests in the list of open requests, and return all that match\n * without asserting anything about the number of matches.\n */\n match(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest[] {\n const results = this._match(match);\n results.forEach((result) => {\n const index = this.open.indexOf(result);\n if (index !== -1) {\n this.open.splice(index, 1);\n }\n });\n return results;\n }\n\n /**\n * Expect that a single outstanding request matches the given matcher, and return\n * it.\n *\n * Requests returned through this API will no longer be in the list of open requests,\n * and thus will not match twice.\n */\n expectOne(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n description?: string,\n ): TestRequest {\n description ||= this.descriptionFromMatcher(match);\n const matches = this.match(match);\n if (matches.length > 1) {\n throw new Error(\n `Expected one matching request for criteria \"${description}\", found ${matches.length} requests.`,\n );\n }\n if (matches.length === 0) {\n let message = `Expected one matching request for criteria \"${description}\", found none.`;\n if (this.open.length > 0) {\n // Show the methods and URLs of open requests in the error, for convenience.\n const requests = this.open.map(describeRequest).join(', ');\n message += ` Requests received are: ${requests}.`;\n }\n throw new Error(message);\n }\n return matches[0];\n }\n\n /**\n * Expect that no outstanding requests match the given matcher, and throw an error\n * if any do.\n */\n expectNone(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n description?: string,\n ): void {\n description ||= this.descriptionFromMatcher(match);\n const matches = this.match(match);\n if (matches.length > 0) {\n throw new Error(\n `Expected zero matching requests for criteria \"${description}\", found ${matches.length}.`,\n );\n }\n }\n\n /**\n * Validate that there are no outstanding requests.\n */\n verify(opts: {ignoreCancelled?: boolean} = {}): void {\n let open = this.open;\n // It's possible that some requests may be cancelled, and this is expected.\n // The user can ask to ignore open requests which have been cancelled.\n if (opts.ignoreCancelled) {\n open = open.filter((testReq) => !testReq.cancelled);\n }\n if (open.length > 0) {\n // Show the methods and URLs of open requests in the error, for convenience.\n const requests = open.map(describeRequest).join(', ');\n throw new Error(`Expected no open requests, found ${open.length}: ${requests}`);\n }\n }\n\n private descriptionFromMatcher(\n matcher: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n ): string {\n if (typeof matcher === 'string') {\n return `Match URL: ${matcher}`;\n } else if (typeof matcher === 'object') {\n const method = matcher.method || '(any)';\n const url = matcher.url || '(any)';\n return `Match method: ${method}, URL: ${url}`;\n } else {\n return `Match by function: ${matcher.name}`;\n }\n }\n}\n\nfunction describeRequest(testRequest: TestRequest): string {\n const url = testRequest.request.urlWithParams;\n const method = testRequest.request.method;\n return `${method} ${url}`;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {HttpBackend, ɵREQUESTS_CONTRIBUTE_TO_STABILITY} from '../../index';\nimport {Provider} from '@angular/core';\n\nimport {HttpTestingController} from './api';\nimport {HttpClientTestingBackend} from './backend';\n\nexport function provideHttpClientTesting(): Provider[] {\n return [\n HttpClientTestingBackend,\n {provide: HttpBackend, useExisting: HttpClientTestingBackend},\n {provide: HttpTestingController, useExisting: HttpClientTestingBackend},\n {provide: ɵREQUESTS_CONTRIBUTE_TO_STABILITY, useValue: false},\n ];\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {HttpClientModule} from '../../index';\nimport {NgModule} from '@angular/core';\n\nimport {provideHttpClientTesting} from './provider';\n\n/**\n * Configures `HttpClientTestingBackend` as the `HttpBackend` used by `HttpClient`.\n *\n * Inject `HttpTestingController` to expect and flush requests in your tests.\n *\n * @publicApi\n *\n * @deprecated Add `provideHttpClientTesting()` to your providers instead.\n */\n@NgModule({\n imports: [HttpClientModule],\n providers: [provideHttpClientTesting()],\n})\nexport class HttpClientTestingModule {}\n"],"names":["HttpTestingController","TestRequest","request","observer","cancelled","_cancelled","constructor","flush","body","opts","Error","url","urlWithParams","headers","HttpHeaders","_maybeConvertBody","responseType","statusText","status","undefined","HttpStatusCode","Ok","NoContent","next","HttpResponse","complete","error","HttpErrorResponse","event","_toArrayBufferBody","ArrayBuffer","_toBlob","Blob","_toJsonBody","format","Array","isArray","_toTextBody","JSON","stringify","HttpClientTestingBackend","open","isTestingBackend","handle","req","Observable","testReq","push","type","HttpEventType","Sent","_match","match","filter","method","toUpperCase","results","forEach","result","index","indexOf","splice","expectOne","description","descriptionFromMatcher","matches","length","message","requests","map","describeRequest","join","expectNone","verify","ignoreCancelled","matcher","name","deps","target","i0","ɵɵFactoryTarget","Injectable","decorators","testRequest","provideHttpClientTesting","provide","HttpBackend","useExisting","ɵREQUESTS_CONTRIBUTE_TO_STABILITY","useValue","HttpClientTestingModule","NgModule","ɵmod","ɵɵngDeclareNgModule","minVersion","version","ngImport","HttpClientModule","ɵinj","ɵɵngDeclareInjector","args","imports","providers"],"mappings":";;;;;;;;;;;;;;MA4BsBA,qBAAqB,CAAA;;MCQ9BC,WAAW,CAAA;EAcbC,OAAA;EACCC,QAAA;EAXV,IAAIC,SAASA,GAAA;IACX,OAAO,IAAI,CAACC,UAAU;AACxB;AAKAA,EAAAA,UAAU,GAAG,KAAK;AAElBC,EAAAA,WACSA,CAAAJ,OAAyB,EACxBC,QAAkC,EAAA;IADnC,IAAO,CAAAD,OAAA,GAAPA,OAAO;IACN,IAAQ,CAAAC,QAAA,GAARA,QAAQ;AACf;AAUHI,EAAAA,KAAKA,CACHC,IAQQ,EACRC,IAAA,GAII,EAAE,EAAA;IAEN,IAAI,IAAI,CAACL,SAAS,EAAE;AAClB,MAAA,MAAM,IAAIM,KAAK,CAAC,CAAA,iCAAA,CAAmC,CAAC;AACtD;AACA,IAAA,MAAMC,GAAG,GAAG,IAAI,CAACT,OAAO,CAACU,aAAa;AACtC,IAAA,MAAMC,OAAO,GACXJ,IAAI,CAACI,OAAO,YAAYC,WAAW,GAAGL,IAAI,CAACI,OAAO,GAAG,IAAIC,WAAW,CAACL,IAAI,CAACI,OAAO,CAAC;IACpFL,IAAI,GAAGO,iBAAiB,CAAC,IAAI,CAACb,OAAO,CAACc,YAAY,EAAER,IAAI,CAAC;AACzD,IAAA,IAAIS,UAAU,GAAuBR,IAAI,CAACQ,UAAU;AACpD,IAAA,IAAIC,MAAM,GAAWT,IAAI,CAACS,MAAM,KAAKC,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WAAW,EAAE/C;AAAyB,GAAA,EACvE;AAAC6C,IAAAA,OAAO,EAAEG,gCAAiC;AAAEC,IAAAA,QAAQ,EAAE;AAAM,GAAA,CAC9D;AACH;;MCKaC,uBAAuB,CAAA;;;;;UAAvBA,uBAAuB;AAAAb,IAAAA,IAAA,EAAA,EAAA;AAAAC,IAAAA,MAAA,EAAAC,EAAA,CAAAC,eAAA,CAAAW;AAAA,GAAA,CAAA;AAAvB,EAAA,OAAAC,IAAA,GAAAb,EAAA,CAAAc,mBAAA,CAAA;AAAAC,IAAAA,UAAA,EAAA,QAAA;AAAAC,IAAAA,OAAA,EAAA,mBAAA;AAAAC,IAAAA,QAAA,EAAAjB,EAAA;AAAA/B,IAAAA,IAAA,EAAA0C,uBAAuB;cAHxBO,gBAAgB;AAAA,GAAA,CAAA;AAGf,EAAA,OAAAC,IAAA,GAAAnB,EAAA,CAAAoB,mBAAA,CAAA;AAAAL,IAAAA,UAAA,EAAA,QAAA;AAAAC,IAAAA,OAAA,EAAA,mBAAA;AAAAC,IAAAA,QAAA,EAAAjB,EAAA;AAAA/B,IAAAA,IAAA,EAAA0C,uBAAuB;eAFvB,CAACN,wBAAwB,EAAE,CAAC;cAD7Ba,gBAAgB;AAAA,GAAA,CAAA;;;;;;QAGfP,uBAAuB;AAAAR,EAAAA,UAAA,EAAA,CAAA;UAJnCS,QAAQ;AAACS,IAAAA,IAAA,EAAA,CAAA;MACRC,OAAO,EAAE,CAACJ,gBAAgB,CAAC;AAC3BK,MAAAA,SAAS,EAAE,CAAClB,wBAAwB,EAAE;KACvC;;;;;;"}
|
|
1
|
+
{"version":3,"file":"http-testing.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/api.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/request.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/backend.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/provider.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/common/http/testing/src/module.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {HttpRequest} from '../../index';\n\nimport {TestRequest} from './request';\n\n/**\n * Defines a matcher for requests based on URL, method, or both.\n *\n * @publicApi\n */\nexport interface RequestMatch {\n method?: string;\n url?: string;\n}\n\n/**\n * Controller to be injected into tests, that allows for mocking and flushing\n * of requests.\n *\n * @publicApi\n */\nexport abstract class HttpTestingController {\n /**\n * Search for requests that match the given parameter, without any expectations.\n */\n abstract match(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n ): TestRequest[];\n\n /**\n * Expect that a single request has been made which matches the given URL, and return its\n * mock.\n *\n * If no such request has been made, or more than one such request has been made, fail with an\n * error message including the given request description, if any.\n */\n abstract expectOne(url: string, description?: string): TestRequest;\n\n /**\n * Expect that a single request has been made which matches the given parameters, and return\n * its mock.\n *\n * If no such request has been made, or more than one such request has been made, fail with an\n * error message including the given request description, if any.\n */\n abstract expectOne(params: RequestMatch, description?: string): TestRequest;\n\n /**\n * Expect that a single request has been made which matches the given predicate function, and\n * return its mock.\n *\n * If no such request has been made, or more than one such request has been made, fail with an\n * error message including the given request description, if any.\n */\n abstract expectOne(\n matchFn: (req: HttpRequest<any>) => boolean,\n description?: string,\n ): TestRequest;\n\n /**\n * Expect that a single request has been made which matches the given condition, and return\n * its mock.\n *\n * If no such request has been made, or more than one such request has been made, fail with an\n * error message including the given request description, if any.\n */\n abstract expectOne(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n description?: string,\n ): TestRequest;\n\n /**\n * Expect that no requests have been made which match the given URL.\n *\n * If a matching request has been made, fail with an error message including the given request\n * description, if any.\n */\n abstract expectNone(url: string, description?: string): void;\n\n /**\n * Expect that no requests have been made which match the given parameters.\n *\n * If a matching request has been made, fail with an error message including the given request\n * description, if any.\n */\n abstract expectNone(params: RequestMatch, description?: string): void;\n\n /**\n * Expect that no requests have been made which match the given predicate function.\n *\n * If a matching request has been made, fail with an error message including the given request\n * description, if any.\n */\n abstract expectNone(matchFn: (req: HttpRequest<any>) => boolean, description?: string): void;\n\n /**\n * Expect that no requests have been made which match the given condition.\n *\n * If a matching request has been made, fail with an error message including the given request\n * description, if any.\n */\n abstract expectNone(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n description?: string,\n ): void;\n\n /**\n * Verify that no unmatched requests are outstanding.\n *\n * If any requests are outstanding, fail with an error message indicating which requests were not\n * handled.\n *\n * If `ignoreCancelled` is not set (the default), `verify()` will also fail if cancelled requests\n * were not explicitly matched.\n */\n abstract verify(opts?: {ignoreCancelled?: boolean}): void;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n HttpErrorResponse,\n HttpEvent,\n HttpHeaders,\n HttpRequest,\n HttpResponse,\n HttpStatusCode,\n} from '../../index';\nimport {Observer} from 'rxjs';\n\n/**\n * Type that describes options that can be used to create an error\n * in `TestRequest`.\n */\ntype TestRequestErrorOptions = {\n headers?: HttpHeaders | {[name: string]: string | string[]};\n status?: number;\n statusText?: string;\n};\n\n/**\n * A mock requests that was received and is ready to be answered.\n *\n * This interface allows access to the underlying `HttpRequest`, and allows\n * responding with `HttpEvent`s or `HttpErrorResponse`s.\n *\n * @publicApi\n */\nexport class TestRequest {\n /**\n * Whether the request was cancelled after it was sent.\n */\n get cancelled(): boolean {\n return this._cancelled;\n }\n\n /**\n * @internal set by `HttpClientTestingBackend`\n */\n _cancelled = false;\n\n constructor(\n public request: HttpRequest<any>,\n private observer: Observer<HttpEvent<any>>,\n ) {}\n\n /**\n * Resolve the request by returning a body plus additional HTTP information (such as response\n * headers) if provided.\n * If the request specifies an expected body type, the body is converted into the requested type.\n * Otherwise, the body is converted to `JSON` by default.\n *\n * Both successful and unsuccessful responses can be delivered via `flush()`.\n */\n flush(\n body:\n | ArrayBuffer\n | Blob\n | boolean\n | string\n | number\n | Object\n | (boolean | string | number | Object | null)[]\n | null,\n opts: {\n headers?: HttpHeaders | {[name: string]: string | string[]};\n status?: number;\n statusText?: string;\n } = {},\n ): void {\n if (this.cancelled) {\n throw new Error(`Cannot flush a cancelled request.`);\n }\n const url = this.request.urlWithParams;\n const headers =\n opts.headers instanceof HttpHeaders ? opts.headers : new HttpHeaders(opts.headers);\n body = _maybeConvertBody(this.request.responseType, body);\n let statusText: string | undefined = opts.statusText;\n let status: number = opts.status !== undefined ? opts.status : HttpStatusCode.Ok;\n if (opts.status === undefined) {\n if (body === null) {\n status = HttpStatusCode.NoContent;\n statusText ||= 'No Content';\n } else {\n statusText ||= 'OK';\n }\n }\n if (statusText === undefined) {\n throw new Error('statusText is required when setting a custom status.');\n }\n if (status >= 200 && status < 300) {\n this.observer.next(new HttpResponse<any>({body, headers, status, statusText, url}));\n this.observer.complete();\n } else {\n this.observer.error(new HttpErrorResponse({error: body, headers, status, statusText, url}));\n }\n }\n\n /**\n * Resolve the request by returning an `ErrorEvent` (e.g. simulating a network failure).\n * @deprecated Http requests never emit an `ErrorEvent`. Please specify a `ProgressEvent`.\n */\n error(error: ErrorEvent, opts?: TestRequestErrorOptions): void;\n /**\n * Resolve the request by returning an `ProgressEvent` (e.g. simulating a network failure).\n */\n error(error: ProgressEvent, opts?: TestRequestErrorOptions): void;\n error(error: ProgressEvent | ErrorEvent, opts: TestRequestErrorOptions = {}): void {\n if (this.cancelled) {\n throw new Error(`Cannot return an error for a cancelled request.`);\n }\n const headers =\n opts.headers instanceof HttpHeaders ? opts.headers : new HttpHeaders(opts.headers);\n this.observer.error(\n new HttpErrorResponse({\n error,\n headers,\n status: opts.status || 0,\n statusText: opts.statusText || '',\n url: this.request.urlWithParams,\n }),\n );\n }\n\n /**\n * Deliver an arbitrary `HttpEvent` (such as a progress event) on the response stream for this\n * request.\n */\n event(event: HttpEvent<any>): void {\n if (this.cancelled) {\n throw new Error(`Cannot send events to a cancelled request.`);\n }\n this.observer.next(event);\n }\n}\n\n/**\n * Helper function to convert a response body to an ArrayBuffer.\n */\nfunction _toArrayBufferBody(\n body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[],\n): ArrayBuffer {\n if (typeof ArrayBuffer === 'undefined') {\n throw new Error('ArrayBuffer responses are not supported on this platform.');\n }\n if (body instanceof ArrayBuffer) {\n return body;\n }\n throw new Error('Automatic conversion to ArrayBuffer is not supported for response type.');\n}\n\n/**\n * Helper function to convert a response body to a Blob.\n */\nfunction _toBlob(\n body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[],\n): Blob {\n if (typeof Blob === 'undefined') {\n throw new Error('Blob responses are not supported on this platform.');\n }\n if (body instanceof Blob) {\n return body;\n }\n if (ArrayBuffer && body instanceof ArrayBuffer) {\n return new Blob([body]);\n }\n throw new Error('Automatic conversion to Blob is not supported for response type.');\n}\n\n/**\n * Helper function to convert a response body to JSON data.\n */\nfunction _toJsonBody(\n body:\n | ArrayBuffer\n | Blob\n | boolean\n | string\n | number\n | Object\n | (boolean | string | number | Object | null)[],\n format: string = 'JSON',\n): Object | string | number | (Object | string | number)[] {\n if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {\n throw new Error(`Automatic conversion to ${format} is not supported for ArrayBuffers.`);\n }\n if (typeof Blob !== 'undefined' && body instanceof Blob) {\n throw new Error(`Automatic conversion to ${format} is not supported for Blobs.`);\n }\n if (\n typeof body === 'string' ||\n typeof body === 'number' ||\n typeof body === 'object' ||\n typeof body === 'boolean' ||\n Array.isArray(body)\n ) {\n return body;\n }\n throw new Error(`Automatic conversion to ${format} is not supported for response type.`);\n}\n\n/**\n * Helper function to convert a response body to a string.\n */\nfunction _toTextBody(\n body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[],\n): string {\n if (typeof body === 'string') {\n return body;\n }\n if (typeof ArrayBuffer !== 'undefined' && body instanceof ArrayBuffer) {\n throw new Error('Automatic conversion to text is not supported for ArrayBuffers.');\n }\n if (typeof Blob !== 'undefined' && body instanceof Blob) {\n throw new Error('Automatic conversion to text is not supported for Blobs.');\n }\n return JSON.stringify(_toJsonBody(body, 'text'));\n}\n\n/**\n * Convert a response body to the requested type.\n */\nfunction _maybeConvertBody(\n responseType: string,\n body: ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null,\n): ArrayBuffer | Blob | string | number | Object | (string | number | Object | null)[] | null {\n if (body === null) {\n return null;\n }\n switch (responseType) {\n case 'arraybuffer':\n return _toArrayBufferBody(body);\n case 'blob':\n return _toBlob(body);\n case 'json':\n return _toJsonBody(body);\n case 'text':\n return _toTextBody(body);\n default:\n throw new Error(`Unsupported responseType: ${responseType}`);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {HttpBackend, HttpEvent, HttpEventType, HttpRequest} from '../../index';\nimport {Injectable} from '@angular/core';\nimport {Observable, Observer} from 'rxjs';\n\nimport {HttpTestingController, RequestMatch} from './api';\nimport {TestRequest} from './request';\n\n/**\n * A testing backend for `HttpClient` which both acts as an `HttpBackend`\n * and as the `HttpTestingController`.\n *\n * `HttpClientTestingBackend` works by keeping a list of all open requests.\n * As requests come in, they're added to the list. Users can assert that specific\n * requests were made and then flush them. In the end, a verify() method asserts\n * that no unexpected requests were made.\n *\n *\n */\n@Injectable()\nexport class HttpClientTestingBackend implements HttpBackend, HttpTestingController {\n /**\n * List of pending requests which have not yet been expected.\n */\n private open: TestRequest[] = [];\n\n /**\n * Used when checking if we need to throw the NOT_USING_FETCH_BACKEND_IN_SSR error\n */\n private isTestingBackend = true;\n\n /**\n * Handle an incoming request by queueing it in the list of open requests.\n */\n handle(req: HttpRequest<any>): Observable<HttpEvent<any>> {\n return new Observable((observer: Observer<any>) => {\n const testReq = new TestRequest(req, observer);\n this.open.push(testReq);\n observer.next({type: HttpEventType.Sent} as HttpEvent<any>);\n return () => {\n testReq._cancelled = true;\n };\n });\n }\n\n /**\n * Helper function to search for requests in the list of open requests.\n */\n private _match(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n ): TestRequest[] {\n if (typeof match === 'string') {\n return this.open.filter((testReq) => testReq.request.urlWithParams === match);\n } else if (typeof match === 'function') {\n return this.open.filter((testReq) => match(testReq.request));\n } else {\n return this.open.filter(\n (testReq) =>\n (!match.method || testReq.request.method === match.method.toUpperCase()) &&\n (!match.url || testReq.request.urlWithParams === match.url),\n );\n }\n }\n\n /**\n * Search for requests in the list of open requests, and return all that match\n * without asserting anything about the number of matches.\n */\n match(match: string | RequestMatch | ((req: HttpRequest<any>) => boolean)): TestRequest[] {\n const results = this._match(match);\n results.forEach((result) => {\n const index = this.open.indexOf(result);\n if (index !== -1) {\n this.open.splice(index, 1);\n }\n });\n return results;\n }\n\n /**\n * Expect that a single outstanding request matches the given matcher, and return\n * it.\n *\n * Requests returned through this API will no longer be in the list of open requests,\n * and thus will not match twice.\n */\n expectOne(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n description?: string,\n ): TestRequest {\n description ||= this.descriptionFromMatcher(match);\n const matches = this.match(match);\n if (matches.length > 1) {\n throw new Error(\n `Expected one matching request for criteria \"${description}\", found ${matches.length} requests.`,\n );\n }\n if (matches.length === 0) {\n let message = `Expected one matching request for criteria \"${description}\", found none.`;\n if (this.open.length > 0) {\n // Show the methods and URLs of open requests in the error, for convenience.\n const requests = this.open.map(describeRequest).join(', ');\n message += ` Requests received are: ${requests}.`;\n }\n throw new Error(message);\n }\n return matches[0];\n }\n\n /**\n * Expect that no outstanding requests match the given matcher, and throw an error\n * if any do.\n */\n expectNone(\n match: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n description?: string,\n ): void {\n description ||= this.descriptionFromMatcher(match);\n const matches = this.match(match);\n if (matches.length > 0) {\n throw new Error(\n `Expected zero matching requests for criteria \"${description}\", found ${matches.length}.`,\n );\n }\n }\n\n /**\n * Validate that there are no outstanding requests.\n */\n verify(opts: {ignoreCancelled?: boolean} = {}): void {\n let open = this.open;\n // It's possible that some requests may be cancelled, and this is expected.\n // The user can ask to ignore open requests which have been cancelled.\n if (opts.ignoreCancelled) {\n open = open.filter((testReq) => !testReq.cancelled);\n }\n if (open.length > 0) {\n // Show the methods and URLs of open requests in the error, for convenience.\n const requests = open.map(describeRequest).join(', ');\n throw new Error(`Expected no open requests, found ${open.length}: ${requests}`);\n }\n }\n\n private descriptionFromMatcher(\n matcher: string | RequestMatch | ((req: HttpRequest<any>) => boolean),\n ): string {\n if (typeof matcher === 'string') {\n return `Match URL: ${matcher}`;\n } else if (typeof matcher === 'object') {\n const method = matcher.method || '(any)';\n const url = matcher.url || '(any)';\n return `Match method: ${method}, URL: ${url}`;\n } else {\n return `Match by function: ${matcher.name}`;\n }\n }\n}\n\nfunction describeRequest(testRequest: TestRequest): string {\n const url = testRequest.request.urlWithParams;\n const method = testRequest.request.method;\n return `${method} ${url}`;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {HttpBackend, ɵREQUESTS_CONTRIBUTE_TO_STABILITY} from '../../index';\nimport {Provider} from '@angular/core';\n\nimport {HttpTestingController} from './api';\nimport {HttpClientTestingBackend} from './backend';\n\nexport function provideHttpClientTesting(): Provider[] {\n return [\n HttpClientTestingBackend,\n {provide: HttpBackend, useExisting: HttpClientTestingBackend},\n {provide: HttpTestingController, useExisting: HttpClientTestingBackend},\n {provide: ɵREQUESTS_CONTRIBUTE_TO_STABILITY, useValue: false},\n ];\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {HttpClientModule} from '../../index';\nimport {NgModule} from '@angular/core';\n\nimport {provideHttpClientTesting} from './provider';\n\n/**\n * Configures `HttpClientTestingBackend` as the `HttpBackend` used by `HttpClient`.\n *\n * Inject `HttpTestingController` to expect and flush requests in your tests.\n *\n * @publicApi\n *\n * @deprecated Add `provideHttpClientTesting()` to your providers instead.\n */\n@NgModule({\n imports: [HttpClientModule],\n providers: [provideHttpClientTesting()],\n})\nexport class HttpClientTestingModule {}\n"],"names":["HttpTestingController","TestRequest","request","observer","cancelled","_cancelled","constructor","flush","body","opts","Error","url","urlWithParams","headers","HttpHeaders","_maybeConvertBody","responseType","statusText","status","undefined","HttpStatusCode","Ok","NoContent","next","HttpResponse","complete","error","HttpErrorResponse","event","_toArrayBufferBody","ArrayBuffer","_toBlob","Blob","_toJsonBody","format","Array","isArray","_toTextBody","JSON","stringify","HttpClientTestingBackend","open","isTestingBackend","handle","req","Observable","testReq","push","type","HttpEventType","Sent","_match","match","filter","method","toUpperCase","results","forEach","result","index","indexOf","splice","expectOne","description","descriptionFromMatcher","matches","length","message","requests","map","describeRequest","join","expectNone","verify","ignoreCancelled","matcher","name","deps","target","i0","ɵɵFactoryTarget","Injectable","decorators","testRequest","provideHttpClientTesting","provide","HttpBackend","useExisting","ɵREQUESTS_CONTRIBUTE_TO_STABILITY","useValue","HttpClientTestingModule","NgModule","ɵmod","ɵɵngDeclareNgModule","minVersion","version","ngImport","HttpClientModule","ɵinj","ɵɵngDeclareInjector","args","imports","providers"],"mappings":";;;;;;;;;;;;;;MA4BsBA,qBAAqB,CAAA;;MCQ9BC,WAAW,CAAA;EAcbC,OAAA;EACCC,QAAA;EAXV,IAAIC,SAASA,GAAA;IACX,OAAO,IAAI,CAACC,UAAU;AACxB;AAKAA,EAAAA,UAAU,GAAG,KAAK;AAElBC,EAAAA,WACSA,CAAAJ,OAAyB,EACxBC,QAAkC,EAAA;IADnC,IAAO,CAAAD,OAAA,GAAPA,OAAO;IACN,IAAQ,CAAAC,QAAA,GAARA,QAAQ;AACf;AAUHI,EAAAA,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IAAA,EAAA0C,uBAAuB;eAFvB,CAACN,wBAAwB,EAAE,CAAC;cAD7Ba,gBAAgB;AAAA,GAAA,CAAA;;;;;;QAGfP,uBAAuB;AAAAR,EAAAA,UAAA,EAAA,CAAA;UAJnCS,QAAQ;AAACS,IAAAA,IAAA,EAAA,CAAA;MACRC,OAAO,EAAE,CAACJ,gBAAgB,CAAC;AAC3BK,MAAAA,SAAS,EAAE,CAAClB,wBAAwB,EAAE;KACvC;;;;;;"}
|
package/fesm2022/http.mjs
CHANGED
|
@@ -1,166 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v21.2.
|
|
2
|
+
* @license Angular v21.2.1
|
|
3
3
|
* (c) 2010-2026 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { HttpHeaders, HttpParams, HttpRequest, HttpEventType, HttpErrorResponse, HttpClient
|
|
7
|
+
import { HTTP_ROOT_INTERCEPTOR_FNS, HttpResponse, HttpHeaders, HttpParams, HttpRequest, HttpEventType, HttpErrorResponse, HttpClient } from './_module-chunk.mjs';
|
|
8
8
|
export { FetchBackend, HTTP_INTERCEPTORS, HttpBackend, HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpContext, HttpContextToken, HttpFeatureKind, HttpHandler, HttpHeaderResponse, HttpResponseBase, HttpStatusCode, HttpUrlEncodingCodec, HttpXhrBackend, HttpXsrfTokenExtractor, JsonpClientBackend, JsonpInterceptor, provideHttpClient, withFetch, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNoXsrfProtection, withRequestsMadeViaParent, withXsrfConfiguration, HttpInterceptorHandler as ɵHttpInterceptingHandler, REQUESTS_CONTRIBUTE_TO_STABILITY as ɵREQUESTS_CONTRIBUTE_TO_STABILITY } from './_module-chunk.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import { InjectionToken, ɵperformanceMarkFeature as _performanceMarkFeature, APP_BOOTSTRAP_LISTENER, inject, ApplicationRef, TransferState, makeStateKey, ɵRuntimeError as _RuntimeError, ɵtruncateMiddle as _truncateMiddle, ɵformatRuntimeError as _formatRuntimeError, assertInInjectionContext, Injector, ɵResourceImpl as _ResourceImpl, linkedSignal, computed, signal, ɵencapsulateResourceError as _encapsulateResourceError } from '@angular/core';
|
|
10
10
|
import { of } from 'rxjs';
|
|
11
11
|
import { tap } from 'rxjs/operators';
|
|
12
12
|
import './_xhr-chunk.mjs';
|
|
13
13
|
import './_platform_location-chunk.mjs';
|
|
14
14
|
|
|
15
|
-
const httpResource = (() => {
|
|
16
|
-
const jsonFn = makeHttpResourceFn('json');
|
|
17
|
-
jsonFn.arrayBuffer = makeHttpResourceFn('arraybuffer');
|
|
18
|
-
jsonFn.blob = makeHttpResourceFn('blob');
|
|
19
|
-
jsonFn.text = makeHttpResourceFn('text');
|
|
20
|
-
return jsonFn;
|
|
21
|
-
})();
|
|
22
|
-
function makeHttpResourceFn(responseType) {
|
|
23
|
-
return function httpResource(request, options) {
|
|
24
|
-
if (ngDevMode && !options?.injector) {
|
|
25
|
-
assertInInjectionContext(httpResource);
|
|
26
|
-
}
|
|
27
|
-
const injector = options?.injector ?? inject(Injector);
|
|
28
|
-
return new HttpResourceImpl(injector, () => normalizeRequest(request, responseType), options?.defaultValue, options?.debugName, options?.parse, options?.equal);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function normalizeRequest(request, responseType) {
|
|
32
|
-
let unwrappedRequest = typeof request === 'function' ? request() : request;
|
|
33
|
-
if (unwrappedRequest === undefined) {
|
|
34
|
-
return undefined;
|
|
35
|
-
} else if (typeof unwrappedRequest === 'string') {
|
|
36
|
-
unwrappedRequest = {
|
|
37
|
-
url: unwrappedRequest
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const headers = unwrappedRequest.headers instanceof HttpHeaders ? unwrappedRequest.headers : new HttpHeaders(unwrappedRequest.headers);
|
|
41
|
-
const params = unwrappedRequest.params instanceof HttpParams ? unwrappedRequest.params : new HttpParams({
|
|
42
|
-
fromObject: unwrappedRequest.params
|
|
43
|
-
});
|
|
44
|
-
return new HttpRequest(unwrappedRequest.method ?? 'GET', unwrappedRequest.url, unwrappedRequest.body ?? null, {
|
|
45
|
-
headers,
|
|
46
|
-
params,
|
|
47
|
-
reportProgress: unwrappedRequest.reportProgress,
|
|
48
|
-
withCredentials: unwrappedRequest.withCredentials,
|
|
49
|
-
keepalive: unwrappedRequest.keepalive,
|
|
50
|
-
cache: unwrappedRequest.cache,
|
|
51
|
-
priority: unwrappedRequest.priority,
|
|
52
|
-
mode: unwrappedRequest.mode,
|
|
53
|
-
redirect: unwrappedRequest.redirect,
|
|
54
|
-
responseType,
|
|
55
|
-
context: unwrappedRequest.context,
|
|
56
|
-
transferCache: unwrappedRequest.transferCache,
|
|
57
|
-
credentials: unwrappedRequest.credentials,
|
|
58
|
-
referrer: unwrappedRequest.referrer,
|
|
59
|
-
referrerPolicy: unwrappedRequest.referrerPolicy,
|
|
60
|
-
integrity: unwrappedRequest.integrity,
|
|
61
|
-
timeout: unwrappedRequest.timeout
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
class HttpResourceImpl extends _ResourceImpl {
|
|
65
|
-
client;
|
|
66
|
-
_headers = linkedSignal({
|
|
67
|
-
...(ngDevMode ? {
|
|
68
|
-
debugName: "_headers"
|
|
69
|
-
} : {}),
|
|
70
|
-
source: this.extRequest,
|
|
71
|
-
computation: () => undefined
|
|
72
|
-
});
|
|
73
|
-
_progress = linkedSignal({
|
|
74
|
-
...(ngDevMode ? {
|
|
75
|
-
debugName: "_progress"
|
|
76
|
-
} : {}),
|
|
77
|
-
source: this.extRequest,
|
|
78
|
-
computation: () => undefined
|
|
79
|
-
});
|
|
80
|
-
_statusCode = linkedSignal({
|
|
81
|
-
...(ngDevMode ? {
|
|
82
|
-
debugName: "_statusCode"
|
|
83
|
-
} : {}),
|
|
84
|
-
source: this.extRequest,
|
|
85
|
-
computation: () => undefined
|
|
86
|
-
});
|
|
87
|
-
headers = computed(() => this.status() === 'resolved' || this.status() === 'error' ? this._headers() : undefined, ...(ngDevMode ? [{
|
|
88
|
-
debugName: "headers"
|
|
89
|
-
}] : []));
|
|
90
|
-
progress = this._progress.asReadonly();
|
|
91
|
-
statusCode = this._statusCode.asReadonly();
|
|
92
|
-
constructor(injector, request, defaultValue, debugName, parse, equal) {
|
|
93
|
-
super(request, ({
|
|
94
|
-
params: request,
|
|
95
|
-
abortSignal
|
|
96
|
-
}) => {
|
|
97
|
-
let sub;
|
|
98
|
-
const onAbort = () => sub.unsubscribe();
|
|
99
|
-
abortSignal.addEventListener('abort', onAbort);
|
|
100
|
-
const stream = signal({
|
|
101
|
-
value: undefined
|
|
102
|
-
}, ...(ngDevMode ? [{
|
|
103
|
-
debugName: "stream"
|
|
104
|
-
}] : []));
|
|
105
|
-
let resolve;
|
|
106
|
-
const promise = new Promise(r => resolve = r);
|
|
107
|
-
const send = value => {
|
|
108
|
-
stream.set(value);
|
|
109
|
-
resolve?.(stream);
|
|
110
|
-
resolve = undefined;
|
|
111
|
-
};
|
|
112
|
-
sub = this.client.request(request).subscribe({
|
|
113
|
-
next: event => {
|
|
114
|
-
switch (event.type) {
|
|
115
|
-
case HttpEventType.Response:
|
|
116
|
-
this._headers.set(event.headers);
|
|
117
|
-
this._statusCode.set(event.status);
|
|
118
|
-
try {
|
|
119
|
-
send({
|
|
120
|
-
value: parse ? parse(event.body) : event.body
|
|
121
|
-
});
|
|
122
|
-
} catch (error) {
|
|
123
|
-
send({
|
|
124
|
-
error: _encapsulateResourceError(error)
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
case HttpEventType.DownloadProgress:
|
|
129
|
-
this._progress.set(event);
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
error: error => {
|
|
134
|
-
if (error instanceof HttpErrorResponse) {
|
|
135
|
-
this._headers.set(error.headers);
|
|
136
|
-
this._statusCode.set(error.status);
|
|
137
|
-
}
|
|
138
|
-
send({
|
|
139
|
-
error
|
|
140
|
-
});
|
|
141
|
-
abortSignal.removeEventListener('abort', onAbort);
|
|
142
|
-
},
|
|
143
|
-
complete: () => {
|
|
144
|
-
if (resolve) {
|
|
145
|
-
send({
|
|
146
|
-
error: new _RuntimeError(991, ngDevMode && 'Resource completed before producing a value')
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
abortSignal.removeEventListener('abort', onAbort);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
return promise;
|
|
153
|
-
}, defaultValue, equal, debugName, injector);
|
|
154
|
-
this.client = injector.get(HttpClient);
|
|
155
|
-
}
|
|
156
|
-
set(value) {
|
|
157
|
-
super.set(value);
|
|
158
|
-
this._headers.set(undefined);
|
|
159
|
-
this._progress.set(undefined);
|
|
160
|
-
this._statusCode.set(undefined);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
15
|
const HTTP_TRANSFER_CACHE_ORIGIN_MAP = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'HTTP_TRANSFER_CACHE_ORIGIN_MAP' : '');
|
|
165
16
|
const BODY = 'b';
|
|
166
17
|
const HEADERS = 'h';
|
|
@@ -170,32 +21,44 @@ const REQ_URL = 'u';
|
|
|
170
21
|
const RESPONSE_TYPE = 'rt';
|
|
171
22
|
const CACHE_OPTIONS = new InjectionToken(typeof ngDevMode !== 'undefined' && ngDevMode ? 'HTTP_TRANSFER_STATE_CACHE_OPTIONS' : '');
|
|
172
23
|
const ALLOWED_METHODS = ['GET', 'HEAD'];
|
|
173
|
-
function
|
|
24
|
+
function shouldCacheRequest(req, options) {
|
|
174
25
|
const {
|
|
175
26
|
isCacheActive,
|
|
176
27
|
...globalOptions
|
|
177
|
-
} =
|
|
28
|
+
} = options;
|
|
178
29
|
const {
|
|
179
30
|
transferCache: requestOptions,
|
|
180
31
|
method: requestMethod
|
|
181
32
|
} = req;
|
|
182
33
|
if (!isCacheActive || requestOptions === false || requestMethod === 'POST' && !globalOptions.includePostRequests && !requestOptions || requestMethod !== 'POST' && !ALLOWED_METHODS.includes(requestMethod) || !globalOptions.includeRequestsWithAuthHeaders && hasAuthHeaders(req) || globalOptions.filter?.(req) === false) {
|
|
183
|
-
return
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
function getHeadersToInclude(options, requestOptions) {
|
|
39
|
+
const {
|
|
40
|
+
includeHeaders: globalHeaders
|
|
41
|
+
} = options;
|
|
42
|
+
let headersToInclude = globalHeaders;
|
|
43
|
+
if (typeof requestOptions === 'object' && requestOptions.includeHeaders) {
|
|
44
|
+
headersToInclude = requestOptions.includeHeaders;
|
|
45
|
+
}
|
|
46
|
+
return headersToInclude;
|
|
47
|
+
}
|
|
48
|
+
function retrieveStateFromCache(req, options, transferState, originMap) {
|
|
49
|
+
const {
|
|
50
|
+
transferCache: requestOptions
|
|
51
|
+
} = req;
|
|
52
|
+
if (!shouldCacheRequest(req, options)) {
|
|
53
|
+
return null;
|
|
184
54
|
}
|
|
185
|
-
const transferState = inject(TransferState);
|
|
186
|
-
const originMap = inject(HTTP_TRANSFER_CACHE_ORIGIN_MAP, {
|
|
187
|
-
optional: true
|
|
188
|
-
});
|
|
189
55
|
if (typeof ngServerMode !== 'undefined' && !ngServerMode && originMap) {
|
|
190
56
|
throw new _RuntimeError(2803, ngDevMode && 'Angular detected that the `HTTP_TRANSFER_CACHE_ORIGIN_MAP` token is configured and ' + 'present in the client side code. Please ensure that this token is only provided in the ' + 'server code of the application.');
|
|
191
57
|
}
|
|
192
58
|
const requestUrl = typeof ngServerMode !== 'undefined' && ngServerMode && originMap ? mapRequestOriginUrl(req.url, originMap) : req.url;
|
|
193
59
|
const storeKey = makeCacheKey(req, requestUrl);
|
|
194
60
|
const response = transferState.get(storeKey, null);
|
|
195
|
-
|
|
196
|
-
if (typeof requestOptions === 'object' && requestOptions.includeHeaders) {
|
|
197
|
-
headersToInclude = requestOptions.includeHeaders;
|
|
198
|
-
}
|
|
61
|
+
const headersToInclude = getHeadersToInclude(options, requestOptions);
|
|
199
62
|
if (response) {
|
|
200
63
|
const {
|
|
201
64
|
[BODY]: undecodedBody,
|
|
@@ -218,13 +81,34 @@ function transferCacheInterceptorFn(req, next) {
|
|
|
218
81
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
219
82
|
headers = appendMissingHeadersDetection(req.url, headers, headersToInclude ?? []);
|
|
220
83
|
}
|
|
221
|
-
return
|
|
84
|
+
return new HttpResponse({
|
|
222
85
|
body,
|
|
223
86
|
headers,
|
|
224
87
|
status,
|
|
225
88
|
statusText,
|
|
226
89
|
url
|
|
227
|
-
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
function transferCacheInterceptorFn(req, next) {
|
|
95
|
+
const options = inject(CACHE_OPTIONS);
|
|
96
|
+
const transferState = inject(TransferState);
|
|
97
|
+
const originMap = inject(HTTP_TRANSFER_CACHE_ORIGIN_MAP, {
|
|
98
|
+
optional: true
|
|
99
|
+
});
|
|
100
|
+
const cachedResponse = retrieveStateFromCache(req, options, transferState, originMap);
|
|
101
|
+
if (cachedResponse) {
|
|
102
|
+
return of(cachedResponse);
|
|
103
|
+
}
|
|
104
|
+
const {
|
|
105
|
+
transferCache: requestOptions
|
|
106
|
+
} = req;
|
|
107
|
+
const headersToInclude = getHeadersToInclude(options, requestOptions);
|
|
108
|
+
const requestUrl = typeof ngServerMode !== 'undefined' && ngServerMode && originMap ? mapRequestOriginUrl(req.url, originMap) : req.url;
|
|
109
|
+
const storeKey = makeCacheKey(req, requestUrl);
|
|
110
|
+
if (!shouldCacheRequest(req, options)) {
|
|
111
|
+
return next(req);
|
|
228
112
|
}
|
|
229
113
|
const event$ = next(req);
|
|
230
114
|
if (typeof ngServerMode !== 'undefined' && ngServerMode) {
|
|
@@ -368,5 +252,182 @@ function verifyMappedOrigin(url) {
|
|
|
368
252
|
}
|
|
369
253
|
}
|
|
370
254
|
|
|
255
|
+
const httpResource = (() => {
|
|
256
|
+
const jsonFn = makeHttpResourceFn('json');
|
|
257
|
+
jsonFn.arrayBuffer = makeHttpResourceFn('arraybuffer');
|
|
258
|
+
jsonFn.blob = makeHttpResourceFn('blob');
|
|
259
|
+
jsonFn.text = makeHttpResourceFn('text');
|
|
260
|
+
return jsonFn;
|
|
261
|
+
})();
|
|
262
|
+
function makeHttpResourceFn(responseType) {
|
|
263
|
+
return function httpResource(request, options) {
|
|
264
|
+
if (ngDevMode && !options?.injector) {
|
|
265
|
+
assertInInjectionContext(httpResource);
|
|
266
|
+
}
|
|
267
|
+
const injector = options?.injector ?? inject(Injector);
|
|
268
|
+
const cacheOptions = injector.get(CACHE_OPTIONS, null, {
|
|
269
|
+
optional: true
|
|
270
|
+
});
|
|
271
|
+
const transferState = injector.get(TransferState, null, {
|
|
272
|
+
optional: true
|
|
273
|
+
});
|
|
274
|
+
const originMap = injector.get(HTTP_TRANSFER_CACHE_ORIGIN_MAP, null, {
|
|
275
|
+
optional: true
|
|
276
|
+
});
|
|
277
|
+
const getInitialStream = req => {
|
|
278
|
+
if (cacheOptions && transferState && req) {
|
|
279
|
+
const cachedResponse = retrieveStateFromCache(req, cacheOptions, transferState, originMap);
|
|
280
|
+
if (cachedResponse) {
|
|
281
|
+
try {
|
|
282
|
+
const body = cachedResponse.body;
|
|
283
|
+
const parsed = options?.parse ? options.parse(body) : body;
|
|
284
|
+
return signal({
|
|
285
|
+
value: parsed
|
|
286
|
+
});
|
|
287
|
+
} catch (e) {
|
|
288
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
289
|
+
console.warn(`Angular detected an error while parsing the cached response for the httpResource at \`${req.url}\`. ` + `The resource will fall back to its default value and try again asynchronously.`, e);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return undefined;
|
|
295
|
+
};
|
|
296
|
+
return new HttpResourceImpl(injector, () => normalizeRequest(request, responseType), options?.defaultValue, options?.debugName, options?.parse, options?.equal, getInitialStream);
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function normalizeRequest(request, responseType) {
|
|
300
|
+
let unwrappedRequest = typeof request === 'function' ? request() : request;
|
|
301
|
+
if (unwrappedRequest === undefined) {
|
|
302
|
+
return undefined;
|
|
303
|
+
} else if (typeof unwrappedRequest === 'string') {
|
|
304
|
+
unwrappedRequest = {
|
|
305
|
+
url: unwrappedRequest
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const headers = unwrappedRequest.headers instanceof HttpHeaders ? unwrappedRequest.headers : new HttpHeaders(unwrappedRequest.headers);
|
|
309
|
+
const params = unwrappedRequest.params instanceof HttpParams ? unwrappedRequest.params : new HttpParams({
|
|
310
|
+
fromObject: unwrappedRequest.params
|
|
311
|
+
});
|
|
312
|
+
return new HttpRequest(unwrappedRequest.method ?? 'GET', unwrappedRequest.url, unwrappedRequest.body ?? null, {
|
|
313
|
+
headers,
|
|
314
|
+
params,
|
|
315
|
+
reportProgress: unwrappedRequest.reportProgress,
|
|
316
|
+
withCredentials: unwrappedRequest.withCredentials,
|
|
317
|
+
keepalive: unwrappedRequest.keepalive,
|
|
318
|
+
cache: unwrappedRequest.cache,
|
|
319
|
+
priority: unwrappedRequest.priority,
|
|
320
|
+
mode: unwrappedRequest.mode,
|
|
321
|
+
redirect: unwrappedRequest.redirect,
|
|
322
|
+
responseType,
|
|
323
|
+
context: unwrappedRequest.context,
|
|
324
|
+
transferCache: unwrappedRequest.transferCache,
|
|
325
|
+
credentials: unwrappedRequest.credentials,
|
|
326
|
+
referrer: unwrappedRequest.referrer,
|
|
327
|
+
referrerPolicy: unwrappedRequest.referrerPolicy,
|
|
328
|
+
integrity: unwrappedRequest.integrity,
|
|
329
|
+
timeout: unwrappedRequest.timeout
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
class HttpResourceImpl extends _ResourceImpl {
|
|
333
|
+
client;
|
|
334
|
+
_headers = linkedSignal({
|
|
335
|
+
...(ngDevMode ? {
|
|
336
|
+
debugName: "_headers"
|
|
337
|
+
} : {}),
|
|
338
|
+
source: this.extRequest,
|
|
339
|
+
computation: () => undefined
|
|
340
|
+
});
|
|
341
|
+
_progress = linkedSignal({
|
|
342
|
+
...(ngDevMode ? {
|
|
343
|
+
debugName: "_progress"
|
|
344
|
+
} : {}),
|
|
345
|
+
source: this.extRequest,
|
|
346
|
+
computation: () => undefined
|
|
347
|
+
});
|
|
348
|
+
_statusCode = linkedSignal({
|
|
349
|
+
...(ngDevMode ? {
|
|
350
|
+
debugName: "_statusCode"
|
|
351
|
+
} : {}),
|
|
352
|
+
source: this.extRequest,
|
|
353
|
+
computation: () => undefined
|
|
354
|
+
});
|
|
355
|
+
headers = computed(() => this.status() === 'resolved' || this.status() === 'error' ? this._headers() : undefined, ...(ngDevMode ? [{
|
|
356
|
+
debugName: "headers"
|
|
357
|
+
}] : []));
|
|
358
|
+
progress = this._progress.asReadonly();
|
|
359
|
+
statusCode = this._statusCode.asReadonly();
|
|
360
|
+
constructor(injector, request, defaultValue, debugName, parse, equal, getInitialStream) {
|
|
361
|
+
super(request, ({
|
|
362
|
+
params: request,
|
|
363
|
+
abortSignal
|
|
364
|
+
}) => {
|
|
365
|
+
let sub;
|
|
366
|
+
const onAbort = () => sub.unsubscribe();
|
|
367
|
+
abortSignal.addEventListener('abort', onAbort);
|
|
368
|
+
const stream = signal({
|
|
369
|
+
value: undefined
|
|
370
|
+
}, ...(ngDevMode ? [{
|
|
371
|
+
debugName: "stream"
|
|
372
|
+
}] : []));
|
|
373
|
+
let resolve;
|
|
374
|
+
const promise = new Promise(r => resolve = r);
|
|
375
|
+
const send = value => {
|
|
376
|
+
stream.set(value);
|
|
377
|
+
resolve?.(stream);
|
|
378
|
+
resolve = undefined;
|
|
379
|
+
};
|
|
380
|
+
sub = this.client.request(request).subscribe({
|
|
381
|
+
next: event => {
|
|
382
|
+
switch (event.type) {
|
|
383
|
+
case HttpEventType.Response:
|
|
384
|
+
this._headers.set(event.headers);
|
|
385
|
+
this._statusCode.set(event.status);
|
|
386
|
+
try {
|
|
387
|
+
send({
|
|
388
|
+
value: parse ? parse(event.body) : event.body
|
|
389
|
+
});
|
|
390
|
+
} catch (error) {
|
|
391
|
+
send({
|
|
392
|
+
error: _encapsulateResourceError(error)
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
break;
|
|
396
|
+
case HttpEventType.DownloadProgress:
|
|
397
|
+
this._progress.set(event);
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
error: error => {
|
|
402
|
+
if (error instanceof HttpErrorResponse) {
|
|
403
|
+
this._headers.set(error.headers);
|
|
404
|
+
this._statusCode.set(error.status);
|
|
405
|
+
}
|
|
406
|
+
send({
|
|
407
|
+
error
|
|
408
|
+
});
|
|
409
|
+
abortSignal.removeEventListener('abort', onAbort);
|
|
410
|
+
},
|
|
411
|
+
complete: () => {
|
|
412
|
+
if (resolve) {
|
|
413
|
+
send({
|
|
414
|
+
error: new _RuntimeError(991, ngDevMode && 'Resource completed before producing a value')
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
abortSignal.removeEventListener('abort', onAbort);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
return promise;
|
|
421
|
+
}, defaultValue, equal, debugName, injector, getInitialStream);
|
|
422
|
+
this.client = injector.get(HttpClient);
|
|
423
|
+
}
|
|
424
|
+
set(value) {
|
|
425
|
+
super.set(value);
|
|
426
|
+
this._headers.set(undefined);
|
|
427
|
+
this._progress.set(undefined);
|
|
428
|
+
this._statusCode.set(undefined);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
371
432
|
export { HTTP_TRANSFER_CACHE_ORIGIN_MAP, HttpClient, HttpErrorResponse, HttpEventType, HttpHeaders, HttpParams, HttpRequest, HttpResponse, httpResource, HTTP_ROOT_INTERCEPTOR_FNS as ɵHTTP_ROOT_INTERCEPTOR_FNS, withHttpTransferCache as ɵwithHttpTransferCache };
|
|
372
433
|
//# sourceMappingURL=http.mjs.map
|