@absolutejs/absolute 0.19.0-beta.1083 → 0.19.0-beta.1084

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 (147) hide show
  1. package/dist/angular/browser.js +18 -18
  2. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  3. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  4. package/dist/angular/components/defer-slot-templates.directive.js +2 -2
  5. package/dist/angular/components/defer-slot.component.js +3 -3
  6. package/dist/angular/components/image.component.js +3 -3
  7. package/dist/angular/components/stream-slot.component.js +3 -3
  8. package/dist/angular/index.js +43 -43
  9. package/dist/angular/server.js +31 -31
  10. package/dist/build.js +42 -42
  11. package/dist/cli/config/server.js +11 -11
  12. package/dist/client/index.js +13 -13
  13. package/dist/index.js +62 -62
  14. package/dist/islands/index.js +14 -14
  15. package/dist/react/browser.js +3 -3
  16. package/dist/react/components/browser/index.js +5 -5
  17. package/dist/react/components/index.js +7 -7
  18. package/dist/react/hooks/index.js +2 -2
  19. package/dist/react/index.js +30 -30
  20. package/dist/react/jsxDevRuntimeCompat.js +1 -1
  21. package/dist/react/router/browser.js +2 -2
  22. package/dist/react/router/index.js +2 -2
  23. package/dist/react/server.js +13 -13
  24. package/dist/svelte/index.js +26 -26
  25. package/dist/svelte/router/page.js +1 -1
  26. package/dist/svelte/server.js +13 -13
  27. package/dist/vue/browser.js +3 -3
  28. package/dist/vue/components/Image.js +1 -1
  29. package/dist/vue/components/index.js +5 -5
  30. package/dist/vue/index.js +36 -36
  31. package/dist/vue/server.js +13 -13
  32. package/package.json +1 -1
  33. package/dist/.absolutejs/generated/angular/indexes/angular-example.1g23yr9r.js +0 -167
  34. package/dist/.absolutejs/generated/react/indexes/ReactExample.e6kzvjqy.js +0 -3
  35. package/dist/.absolutejs/generated/svelte/client/pages/SvelteExample.5pq2wmw6.js +0 -1
  36. package/dist/.absolutejs/generated/svelte/indexes/pages/SvelteExample.9zcw5vtg.js +0 -1
  37. package/dist/.absolutejs/generated/vue/client/pages/VueExample.q47m56s4.js +0 -1
  38. package/dist/.absolutejs/generated/vue/indexes/VueExample.6bqszcxv.js +0 -1
  39. package/dist/_prerendered/angular.html +0 -45
  40. package/dist/_prerendered/angular.meta +0 -1
  41. package/dist/_prerendered/html.html +0 -70
  42. package/dist/_prerendered/html.meta +0 -1
  43. package/dist/_prerendered/htmx.html +0 -239
  44. package/dist/_prerendered/htmx.meta +0 -1
  45. package/dist/_prerendered/index.html +0 -70
  46. package/dist/_prerendered/index.meta +0 -1
  47. package/dist/_prerendered/react.html +0 -1
  48. package/dist/_prerendered/react.meta +0 -1
  49. package/dist/_prerendered/vue.html +0 -41
  50. package/dist/_prerendered/vue.meta +0 -1
  51. package/dist/angular/example/angular/pages/angular-example.djr1v9hj.js +0 -373
  52. package/dist/angular/vendor/angular_common.js +0 -310
  53. package/dist/angular/vendor/angular_common_http.js +0 -129
  54. package/dist/angular/vendor/angular_core.js +0 -1177
  55. package/dist/angular/vendor/angular_core_primitives_di.js +0 -36
  56. package/dist/angular/vendor/angular_core_primitives_signals.js +0 -132
  57. package/dist/angular/vendor/angular_platform-browser.js +0 -117
  58. package/dist/angular/vendor/angular_router.js +0 -6410
  59. package/dist/angular/vendor/chunk-2c9evnn0.js +0 -4764
  60. package/dist/angular/vendor/chunk-3evcs0sk.js +0 -2567
  61. package/dist/angular/vendor/chunk-5h3qyvpj.js +0 -729
  62. package/dist/angular/vendor/chunk-hgg0w52m.js +0 -62
  63. package/dist/angular/vendor/chunk-n6rt7w2y.js +0 -23
  64. package/dist/angular/vendor/chunk-t4tc7c8b.js +0 -28013
  65. package/dist/angular/vendor/chunk-vqd7j0kb.js +0 -1786
  66. package/dist/angular/vendor/chunk-yqjkhk8j.js +0 -145
  67. package/dist/angular/vendor/server/angular_common.js +0 -311
  68. package/dist/angular/vendor/server/angular_common_http.js +0 -130
  69. package/dist/angular/vendor/server/angular_core.js +0 -1178
  70. package/dist/angular/vendor/server/angular_core_primitives_di.js +0 -37
  71. package/dist/angular/vendor/server/angular_core_primitives_signals.js +0 -133
  72. package/dist/angular/vendor/server/angular_platform-browser.js +0 -118
  73. package/dist/angular/vendor/server/angular_platform-server.js +0 -59
  74. package/dist/angular/vendor/server/angular_router.js +0 -261
  75. package/dist/angular/vendor/server/angular_ssr.js +0 -11669
  76. package/dist/angular/vendor/server/chunk-2akxms5e.js +0 -2566
  77. package/dist/angular/vendor/server/chunk-659a9c3p.js +0 -6218
  78. package/dist/angular/vendor/server/chunk-8eecnjd1.js +0 -16686
  79. package/dist/angular/vendor/server/chunk-9jz2apvp.js +0 -743
  80. package/dist/angular/vendor/server/chunk-dhs2bg35.js +0 -48
  81. package/dist/angular/vendor/server/chunk-hs2gc8sr.js +0 -1787
  82. package/dist/angular/vendor/server/chunk-k46n34mb.js +0 -63
  83. package/dist/angular/vendor/server/chunk-p2fdvyh1.js +0 -4767
  84. package/dist/angular/vendor/server/chunk-r0w9r4bg.js +0 -730
  85. package/dist/angular/vendor/server/chunk-vthxj7kd.js +0 -146
  86. package/dist/angular/vendor/server/chunk-xahr7f2f.js +0 -35534
  87. package/dist/assets/css/tailwind.generated.css +0 -218
  88. package/dist/assets/css/vue-example-compiled.abzaxheq.css +0 -32
  89. package/dist/assets/ico/favicon.ico +0 -0
  90. package/dist/assets/png/absolutejs-temp.png +0 -0
  91. package/dist/assets/svg/HTML5_Badge.svg +0 -7
  92. package/dist/assets/svg/angular.svg +0 -18
  93. package/dist/assets/svg/htmx-logo-black.svg +0 -9
  94. package/dist/assets/svg/htmx-logo-white.svg +0 -9
  95. package/dist/assets/svg/react.svg +0 -1
  96. package/dist/assets/svg/svelte-logo.svg +0 -1
  97. package/dist/assets/svg/vue-logo.svg +0 -4
  98. package/dist/chunk-7pp6gkg8.js +0 -2
  99. package/dist/chunk-ek2qyx2c.js +0 -11
  100. package/dist/chunk-ysr5ycdt.js +0 -2
  101. package/dist/client.tsx +0 -15
  102. package/dist/example/html/scripts/typescript-example.fqn9zkdh.js +0 -1
  103. package/dist/html/pages/HTMLExample.html +0 -70
  104. package/dist/htmx/htmx.min.js +0 -1
  105. package/dist/htmx/pages/HTMXExample.html +0 -239
  106. package/dist/htmx.min.js +0 -1
  107. package/dist/indexes/angular-example.xsx88ph0.css +0 -227
  108. package/dist/indexes/html-example.s3banzdc.css +0 -221
  109. package/dist/indexes/htmx-example.5vgssc3f.css +0 -221
  110. package/dist/indexes/react-example.bz1k8xa2.css +0 -245
  111. package/dist/indexes/svelte-example.vy3015es.css +0 -221
  112. package/dist/indexes/vue-example.q4vf2wtq.css +0 -228
  113. package/dist/manifest.json +0 -26
  114. package/dist/nested/dynamic-module.txt +0 -1
  115. package/dist/package-asset.txt +0 -1
  116. package/dist/react/vendor/chunk-2kh60w9b.js +0 -33
  117. package/dist/react/vendor/chunk-9g12fvrw.js +0 -236
  118. package/dist/react/vendor/chunk-rejbymp5.js +0 -837
  119. package/dist/react/vendor/chunk-wwy122hz.js +0 -200
  120. package/dist/react/vendor/react-dom.js +0 -44
  121. package/dist/react/vendor/react-dom_client.js +0 -15864
  122. package/dist/react/vendor/react-refresh_runtime.js +0 -304
  123. package/dist/react/vendor/react.js +0 -103
  124. package/dist/react/vendor/react_jsx-dev-runtime.js +0 -17
  125. package/dist/react/vendor/react_jsx-runtime.js +0 -22
  126. package/dist/robots.txt +0 -2
  127. package/dist/runtime/blob.txt +0 -1
  128. package/dist/runtime/dir-join.txt +0 -1
  129. package/dist/runtime/nested/binary.bin +0 -1
  130. package/dist/runtime/nested/readfile.txt +0 -1
  131. package/dist/runtime/template.html +0 -1
  132. package/dist/server.js +0 -92156
  133. package/dist/sitemap.xml +0 -48
  134. package/dist/svelte/server/pages/SvelteExample.fxs20w1b.js +0 -290
  135. package/dist/svelte/vendor/chunk-5qdxn1p3.js +0 -4586
  136. package/dist/svelte/vendor/chunk-8qdfbbez.js +0 -12
  137. package/dist/svelte/vendor/chunk-r2jyyfjt.js +0 -4495
  138. package/dist/svelte/vendor/svelte.js +0 -49
  139. package/dist/svelte/vendor/svelte_internal.js +0 -2
  140. package/dist/svelte/vendor/svelte_internal_client.js +0 -395
  141. package/dist/svelte/vendor/svelte_internal_disclose-version.js +0 -7
  142. package/dist/svelte/vendor/svelte_internal_flags_async.js +0 -6
  143. package/dist/svelte/vendor/svelte_internal_flags_legacy.js +0 -6
  144. package/dist/svelte/vendor/svelte_store.js +0 -99
  145. package/dist/vue/server/pages/VueExample.fyhmna2p.css +0 -32
  146. package/dist/vue/server/pages/VueExample.fyhmna2p.js +0 -75
  147. package/dist/vue/vendor/vue.js +0 -11011
@@ -1,2567 +0,0 @@
1
- import {
2
- PlatformLocation,
3
- XhrFactory,
4
- parseCookieValue
5
- } from "./chunk-yqjkhk8j.js";
6
- import {
7
- APP_BOOTSTRAP_LISTENER,
8
- ApplicationRef,
9
- Console,
10
- DOCUMENT,
11
- DestroyRef,
12
- EnvironmentInjector,
13
- Inject,
14
- Injectable,
15
- InjectionToken,
16
- Injector,
17
- NgModule,
18
- NgZone,
19
- Observable,
20
- PendingTasks,
21
- ResourceImpl,
22
- RuntimeError,
23
- TracingService,
24
- TransferState,
25
- assertInInjectionContext,
26
- computed,
27
- concatMap,
28
- encapsulateResourceError,
29
- filter,
30
- finalize,
31
- formatRuntimeError,
32
- from,
33
- inject,
34
- linkedSignal,
35
- makeEnvironmentProviders,
36
- makeStateKey,
37
- map,
38
- of,
39
- performanceMarkFeature,
40
- runInInjectionContext,
41
- setClassMetadata,
42
- signal,
43
- switchMap,
44
- tap,
45
- truncateMiddle,
46
- ɵɵdefineInjectable as ɵ_defineInjectable,
47
- ɵɵdefineInjector as ɵ_defineInjector,
48
- ɵɵdefineNgModule as ɵ_defineNgModule,
49
- ɵɵinject as ɵ_inject
50
- } from "./chunk-t4tc7c8b.js";
51
- import {
52
- __export
53
- } from "./chunk-n6rt7w2y.js";
54
-
55
- // node_modules/@angular/common/fesm2022/_module-chunk.mjs
56
- class HttpHeaders {
57
- headers;
58
- normalizedNames = new Map;
59
- lazyInit;
60
- lazyUpdate = null;
61
- constructor(headers) {
62
- if (!headers) {
63
- this.headers = new Map;
64
- } else if (typeof headers === "string") {
65
- this.lazyInit = () => {
66
- this.headers = new Map;
67
- headers.split(`
68
- `).forEach((line) => {
69
- const index = line.indexOf(":");
70
- if (index > 0) {
71
- const name = line.slice(0, index);
72
- const value = line.slice(index + 1).trim();
73
- this.addHeaderEntry(name, value);
74
- }
75
- });
76
- };
77
- } else if (typeof Headers !== "undefined" && headers instanceof Headers) {
78
- this.headers = new Map;
79
- headers.forEach((value, name) => {
80
- this.addHeaderEntry(name, value);
81
- });
82
- } else {
83
- this.lazyInit = () => {
84
- if (typeof ngDevMode === "undefined" || ngDevMode) {
85
- assertValidHeaders(headers);
86
- }
87
- this.headers = new Map;
88
- Object.entries(headers).forEach(([name, values]) => {
89
- this.setHeaderEntries(name, values);
90
- });
91
- };
92
- }
93
- }
94
- has(name) {
95
- this.init();
96
- return this.headers.has(name.toLowerCase());
97
- }
98
- get(name) {
99
- this.init();
100
- const values = this.headers.get(name.toLowerCase());
101
- return values && values.length > 0 ? values[0] : null;
102
- }
103
- keys() {
104
- this.init();
105
- return Array.from(this.normalizedNames.values());
106
- }
107
- getAll(name) {
108
- this.init();
109
- return this.headers.get(name.toLowerCase()) || null;
110
- }
111
- append(name, value) {
112
- return this.clone({
113
- name,
114
- value,
115
- op: "a"
116
- });
117
- }
118
- set(name, value) {
119
- return this.clone({
120
- name,
121
- value,
122
- op: "s"
123
- });
124
- }
125
- delete(name, value) {
126
- return this.clone({
127
- name,
128
- value,
129
- op: "d"
130
- });
131
- }
132
- maybeSetNormalizedName(name, lcName) {
133
- if (!this.normalizedNames.has(lcName)) {
134
- this.normalizedNames.set(lcName, name);
135
- }
136
- }
137
- init() {
138
- if (!!this.lazyInit) {
139
- if (this.lazyInit instanceof HttpHeaders) {
140
- this.copyFrom(this.lazyInit);
141
- } else {
142
- this.lazyInit();
143
- }
144
- this.lazyInit = null;
145
- if (!!this.lazyUpdate) {
146
- this.lazyUpdate.forEach((update) => this.applyUpdate(update));
147
- this.lazyUpdate = null;
148
- }
149
- }
150
- }
151
- copyFrom(other) {
152
- other.init();
153
- Array.from(other.headers.keys()).forEach((key) => {
154
- this.headers.set(key, other.headers.get(key));
155
- this.normalizedNames.set(key, other.normalizedNames.get(key));
156
- });
157
- }
158
- clone(update) {
159
- const clone = new HttpHeaders;
160
- clone.lazyInit = !!this.lazyInit && this.lazyInit instanceof HttpHeaders ? this.lazyInit : this;
161
- clone.lazyUpdate = (this.lazyUpdate || []).concat([update]);
162
- return clone;
163
- }
164
- applyUpdate(update) {
165
- const key = update.name.toLowerCase();
166
- switch (update.op) {
167
- case "a":
168
- case "s":
169
- let value = update.value;
170
- if (typeof value === "string") {
171
- value = [value];
172
- }
173
- if (value.length === 0) {
174
- return;
175
- }
176
- this.maybeSetNormalizedName(update.name, key);
177
- const base = (update.op === "a" ? this.headers.get(key) : undefined) || [];
178
- base.push(...value);
179
- this.headers.set(key, base);
180
- break;
181
- case "d":
182
- const toDelete = update.value;
183
- if (!toDelete) {
184
- this.headers.delete(key);
185
- this.normalizedNames.delete(key);
186
- } else {
187
- let existing = this.headers.get(key);
188
- if (!existing) {
189
- return;
190
- }
191
- existing = existing.filter((value2) => toDelete.indexOf(value2) === -1);
192
- if (existing.length === 0) {
193
- this.headers.delete(key);
194
- this.normalizedNames.delete(key);
195
- } else {
196
- this.headers.set(key, existing);
197
- }
198
- }
199
- break;
200
- }
201
- }
202
- addHeaderEntry(name, value) {
203
- const key = name.toLowerCase();
204
- this.maybeSetNormalizedName(name, key);
205
- if (this.headers.has(key)) {
206
- this.headers.get(key).push(value);
207
- } else {
208
- this.headers.set(key, [value]);
209
- }
210
- }
211
- setHeaderEntries(name, values) {
212
- const headerValues = (Array.isArray(values) ? values : [values]).map((value) => value.toString());
213
- const key = name.toLowerCase();
214
- this.headers.set(key, headerValues);
215
- this.maybeSetNormalizedName(name, key);
216
- }
217
- forEach(fn) {
218
- this.init();
219
- Array.from(this.normalizedNames.keys()).forEach((key) => fn(this.normalizedNames.get(key), this.headers.get(key)));
220
- }
221
- }
222
- function assertValidHeaders(headers) {
223
- for (const [key, value] of Object.entries(headers)) {
224
- if (!(typeof value === "string" || typeof value === "number") && !Array.isArray(value)) {
225
- throw new Error(`Unexpected value of the \`${key}\` header provided. ` + `Expecting either a string, a number or an array, but got: \`${value}\`.`);
226
- }
227
- }
228
- }
229
-
230
- class HttpContextToken {
231
- defaultValue;
232
- constructor(defaultValue) {
233
- this.defaultValue = defaultValue;
234
- }
235
- }
236
-
237
- class HttpContext {
238
- map = new Map;
239
- set(token, value) {
240
- this.map.set(token, value);
241
- return this;
242
- }
243
- get(token) {
244
- if (!this.map.has(token)) {
245
- this.map.set(token, token.defaultValue());
246
- }
247
- return this.map.get(token);
248
- }
249
- delete(token) {
250
- this.map.delete(token);
251
- return this;
252
- }
253
- has(token) {
254
- return this.map.has(token);
255
- }
256
- keys() {
257
- return this.map.keys();
258
- }
259
- }
260
-
261
- class HttpUrlEncodingCodec {
262
- encodeKey(key) {
263
- return standardEncoding(key);
264
- }
265
- encodeValue(value) {
266
- return standardEncoding(value);
267
- }
268
- decodeKey(key) {
269
- return decodeURIComponent(key);
270
- }
271
- decodeValue(value) {
272
- return decodeURIComponent(value);
273
- }
274
- }
275
- function paramParser(rawParams, codec) {
276
- const map2 = new Map;
277
- if (rawParams.length > 0) {
278
- const params = rawParams.replace(/^\?/, "").split("&");
279
- params.forEach((param) => {
280
- const eqIdx = param.indexOf("=");
281
- const [key, val] = eqIdx == -1 ? [codec.decodeKey(param), ""] : [codec.decodeKey(param.slice(0, eqIdx)), codec.decodeValue(param.slice(eqIdx + 1))];
282
- const list = map2.get(key) || [];
283
- list.push(val);
284
- map2.set(key, list);
285
- });
286
- }
287
- return map2;
288
- }
289
- var STANDARD_ENCODING_REGEX = /%(\d[a-f0-9])/gi;
290
- var STANDARD_ENCODING_REPLACEMENTS = {
291
- "40": "@",
292
- "3A": ":",
293
- "24": "$",
294
- "2C": ",",
295
- "3B": ";",
296
- "3D": "=",
297
- "3F": "?",
298
- "2F": "/"
299
- };
300
- function standardEncoding(v) {
301
- return encodeURIComponent(v).replace(STANDARD_ENCODING_REGEX, (s, t) => STANDARD_ENCODING_REPLACEMENTS[t] ?? s);
302
- }
303
- function valueToString(value) {
304
- return `${value}`;
305
- }
306
-
307
- class HttpParams {
308
- map;
309
- encoder;
310
- updates = null;
311
- cloneFrom = null;
312
- constructor(options = {}) {
313
- this.encoder = options.encoder || new HttpUrlEncodingCodec;
314
- if (options.fromString) {
315
- if (options.fromObject) {
316
- throw new RuntimeError(2805, ngDevMode && "Cannot specify both fromString and fromObject.");
317
- }
318
- this.map = paramParser(options.fromString, this.encoder);
319
- } else if (!!options.fromObject) {
320
- this.map = new Map;
321
- Object.keys(options.fromObject).forEach((key) => {
322
- const value = options.fromObject[key];
323
- const values = Array.isArray(value) ? value.map(valueToString) : [valueToString(value)];
324
- this.map.set(key, values);
325
- });
326
- } else {
327
- this.map = null;
328
- }
329
- }
330
- has(param) {
331
- this.init();
332
- return this.map.has(param);
333
- }
334
- get(param) {
335
- this.init();
336
- const res = this.map.get(param);
337
- return res ? res[0] : null;
338
- }
339
- getAll(param) {
340
- this.init();
341
- return this.map.get(param) || null;
342
- }
343
- keys() {
344
- this.init();
345
- return Array.from(this.map.keys());
346
- }
347
- append(param, value) {
348
- return this.clone({
349
- param,
350
- value,
351
- op: "a"
352
- });
353
- }
354
- appendAll(params) {
355
- const updates = [];
356
- Object.keys(params).forEach((param) => {
357
- const value = params[param];
358
- if (Array.isArray(value)) {
359
- value.forEach((_value) => {
360
- updates.push({
361
- param,
362
- value: _value,
363
- op: "a"
364
- });
365
- });
366
- } else {
367
- updates.push({
368
- param,
369
- value,
370
- op: "a"
371
- });
372
- }
373
- });
374
- return this.clone(updates);
375
- }
376
- set(param, value) {
377
- return this.clone({
378
- param,
379
- value,
380
- op: "s"
381
- });
382
- }
383
- delete(param, value) {
384
- return this.clone({
385
- param,
386
- value,
387
- op: "d"
388
- });
389
- }
390
- toString() {
391
- this.init();
392
- return this.keys().map((key) => {
393
- const eKey = this.encoder.encodeKey(key);
394
- return this.map.get(key).map((value) => eKey + "=" + this.encoder.encodeValue(value)).join("&");
395
- }).filter((param) => param !== "").join("&");
396
- }
397
- clone(update) {
398
- const clone = new HttpParams({
399
- encoder: this.encoder
400
- });
401
- clone.cloneFrom = this.cloneFrom || this;
402
- clone.updates = (this.updates || []).concat(update);
403
- return clone;
404
- }
405
- init() {
406
- if (this.map === null) {
407
- this.map = new Map;
408
- }
409
- if (this.cloneFrom !== null) {
410
- this.cloneFrom.init();
411
- this.cloneFrom.keys().forEach((key) => this.map.set(key, this.cloneFrom.map.get(key)));
412
- this.updates.forEach((update) => {
413
- switch (update.op) {
414
- case "a":
415
- case "s":
416
- const base = (update.op === "a" ? this.map.get(update.param) : undefined) || [];
417
- base.push(valueToString(update.value));
418
- this.map.set(update.param, base);
419
- break;
420
- case "d":
421
- if (update.value !== undefined) {
422
- let base2 = this.map.get(update.param) || [];
423
- const idx = base2.indexOf(valueToString(update.value));
424
- if (idx !== -1) {
425
- base2.splice(idx, 1);
426
- }
427
- if (base2.length > 0) {
428
- this.map.set(update.param, base2);
429
- } else {
430
- this.map.delete(update.param);
431
- }
432
- } else {
433
- this.map.delete(update.param);
434
- break;
435
- }
436
- }
437
- });
438
- this.cloneFrom = this.updates = null;
439
- }
440
- }
441
- }
442
- function mightHaveBody(method) {
443
- switch (method) {
444
- case "DELETE":
445
- case "GET":
446
- case "HEAD":
447
- case "OPTIONS":
448
- case "JSONP":
449
- return false;
450
- default:
451
- return true;
452
- }
453
- }
454
- function isArrayBuffer(value) {
455
- return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
456
- }
457
- function isBlob(value) {
458
- return typeof Blob !== "undefined" && value instanceof Blob;
459
- }
460
- function isFormData(value) {
461
- return typeof FormData !== "undefined" && value instanceof FormData;
462
- }
463
- function isUrlSearchParams(value) {
464
- return typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams;
465
- }
466
- var CONTENT_TYPE_HEADER = "Content-Type";
467
- var ACCEPT_HEADER = "Accept";
468
- var TEXT_CONTENT_TYPE = "text/plain";
469
- var JSON_CONTENT_TYPE = "application/json";
470
- var ACCEPT_HEADER_VALUE = `${JSON_CONTENT_TYPE}, ${TEXT_CONTENT_TYPE}, */*`;
471
-
472
- class HttpRequest {
473
- url;
474
- body = null;
475
- headers;
476
- context;
477
- reportProgress = false;
478
- withCredentials = false;
479
- credentials;
480
- keepalive = false;
481
- cache;
482
- priority;
483
- mode;
484
- redirect;
485
- referrer;
486
- integrity;
487
- referrerPolicy;
488
- responseType = "json";
489
- method;
490
- params;
491
- urlWithParams;
492
- transferCache;
493
- timeout;
494
- constructor(method, url, third, fourth) {
495
- this.url = url;
496
- this.method = method.toUpperCase();
497
- let options;
498
- if (mightHaveBody(this.method) || !!fourth) {
499
- this.body = third !== undefined ? third : null;
500
- options = fourth;
501
- } else {
502
- options = third;
503
- }
504
- if (options) {
505
- this.reportProgress = !!options.reportProgress;
506
- this.withCredentials = !!options.withCredentials;
507
- this.keepalive = !!options.keepalive;
508
- if (!!options.responseType) {
509
- this.responseType = options.responseType;
510
- }
511
- if (options.headers) {
512
- this.headers = options.headers;
513
- }
514
- if (options.context) {
515
- this.context = options.context;
516
- }
517
- if (options.params) {
518
- this.params = options.params;
519
- }
520
- if (options.priority) {
521
- this.priority = options.priority;
522
- }
523
- if (options.cache) {
524
- this.cache = options.cache;
525
- }
526
- if (options.credentials) {
527
- this.credentials = options.credentials;
528
- }
529
- if (typeof options.timeout === "number") {
530
- if (options.timeout < 1 || !Number.isInteger(options.timeout)) {
531
- throw new RuntimeError(2822, ngDevMode ? "`timeout` must be a positive integer value" : "");
532
- }
533
- this.timeout = options.timeout;
534
- }
535
- if (options.mode) {
536
- this.mode = options.mode;
537
- }
538
- if (options.redirect) {
539
- this.redirect = options.redirect;
540
- }
541
- if (options.integrity) {
542
- this.integrity = options.integrity;
543
- }
544
- if (options.referrer) {
545
- this.referrer = options.referrer;
546
- }
547
- if (options.referrerPolicy) {
548
- this.referrerPolicy = options.referrerPolicy;
549
- }
550
- this.transferCache = options.transferCache;
551
- }
552
- this.headers ??= new HttpHeaders;
553
- this.context ??= new HttpContext;
554
- if (!this.params) {
555
- this.params = new HttpParams;
556
- this.urlWithParams = url;
557
- } else {
558
- const params = this.params.toString();
559
- if (params.length === 0) {
560
- this.urlWithParams = url;
561
- } else {
562
- const qIdx = url.indexOf("?");
563
- const sep = qIdx === -1 ? "?" : qIdx < url.length - 1 ? "&" : "";
564
- this.urlWithParams = url + sep + params;
565
- }
566
- }
567
- }
568
- serializeBody() {
569
- if (this.body === null) {
570
- return null;
571
- }
572
- if (typeof this.body === "string" || isArrayBuffer(this.body) || isBlob(this.body) || isFormData(this.body) || isUrlSearchParams(this.body)) {
573
- return this.body;
574
- }
575
- if (this.body instanceof HttpParams) {
576
- return this.body.toString();
577
- }
578
- if (typeof this.body === "object" || typeof this.body === "boolean" || Array.isArray(this.body)) {
579
- return JSON.stringify(this.body);
580
- }
581
- return this.body.toString();
582
- }
583
- detectContentTypeHeader() {
584
- if (this.body === null) {
585
- return null;
586
- }
587
- if (isFormData(this.body)) {
588
- return null;
589
- }
590
- if (isBlob(this.body)) {
591
- return this.body.type || null;
592
- }
593
- if (isArrayBuffer(this.body)) {
594
- return null;
595
- }
596
- if (typeof this.body === "string") {
597
- return TEXT_CONTENT_TYPE;
598
- }
599
- if (this.body instanceof HttpParams) {
600
- return "application/x-www-form-urlencoded;charset=UTF-8";
601
- }
602
- if (typeof this.body === "object" || typeof this.body === "number" || typeof this.body === "boolean") {
603
- return JSON_CONTENT_TYPE;
604
- }
605
- return null;
606
- }
607
- clone(update = {}) {
608
- const method = update.method || this.method;
609
- const url = update.url || this.url;
610
- const responseType = update.responseType || this.responseType;
611
- const keepalive = update.keepalive ?? this.keepalive;
612
- const priority = update.priority || this.priority;
613
- const cache = update.cache || this.cache;
614
- const mode = update.mode || this.mode;
615
- const redirect = update.redirect || this.redirect;
616
- const credentials = update.credentials || this.credentials;
617
- const referrer = update.referrer || this.referrer;
618
- const integrity = update.integrity || this.integrity;
619
- const referrerPolicy = update.referrerPolicy || this.referrerPolicy;
620
- const transferCache = update.transferCache ?? this.transferCache;
621
- const timeout = update.timeout ?? this.timeout;
622
- const body = update.body !== undefined ? update.body : this.body;
623
- const withCredentials = update.withCredentials ?? this.withCredentials;
624
- const reportProgress = update.reportProgress ?? this.reportProgress;
625
- let headers = update.headers || this.headers;
626
- let params = update.params || this.params;
627
- const context = update.context ?? this.context;
628
- if (update.setHeaders !== undefined) {
629
- headers = Object.keys(update.setHeaders).reduce((headers2, name) => headers2.set(name, update.setHeaders[name]), headers);
630
- }
631
- if (update.setParams) {
632
- params = Object.keys(update.setParams).reduce((params2, param) => params2.set(param, update.setParams[param]), params);
633
- }
634
- return new HttpRequest(method, url, body, {
635
- params,
636
- headers,
637
- context,
638
- reportProgress,
639
- responseType,
640
- withCredentials,
641
- transferCache,
642
- keepalive,
643
- cache,
644
- priority,
645
- timeout,
646
- mode,
647
- redirect,
648
- credentials,
649
- referrer,
650
- integrity,
651
- referrerPolicy
652
- });
653
- }
654
- }
655
- var HttpEventType;
656
- (function(HttpEventType2) {
657
- HttpEventType2[HttpEventType2["Sent"] = 0] = "Sent";
658
- HttpEventType2[HttpEventType2["UploadProgress"] = 1] = "UploadProgress";
659
- HttpEventType2[HttpEventType2["ResponseHeader"] = 2] = "ResponseHeader";
660
- HttpEventType2[HttpEventType2["DownloadProgress"] = 3] = "DownloadProgress";
661
- HttpEventType2[HttpEventType2["Response"] = 4] = "Response";
662
- HttpEventType2[HttpEventType2["User"] = 5] = "User";
663
- })(HttpEventType || (HttpEventType = {}));
664
-
665
- class HttpResponseBase {
666
- headers;
667
- status;
668
- statusText;
669
- url;
670
- ok;
671
- type;
672
- redirected;
673
- responseType;
674
- constructor(init, defaultStatus = 200, defaultStatusText = "OK") {
675
- this.headers = init.headers || new HttpHeaders;
676
- this.status = init.status !== undefined ? init.status : defaultStatus;
677
- this.statusText = init.statusText || defaultStatusText;
678
- this.url = init.url || null;
679
- this.redirected = init.redirected;
680
- this.responseType = init.responseType;
681
- this.ok = this.status >= 200 && this.status < 300;
682
- }
683
- }
684
-
685
- class HttpHeaderResponse extends HttpResponseBase {
686
- constructor(init = {}) {
687
- super(init);
688
- }
689
- type = HttpEventType.ResponseHeader;
690
- clone(update = {}) {
691
- return new HttpHeaderResponse({
692
- headers: update.headers || this.headers,
693
- status: update.status !== undefined ? update.status : this.status,
694
- statusText: update.statusText || this.statusText,
695
- url: update.url || this.url || undefined
696
- });
697
- }
698
- }
699
-
700
- class HttpResponse extends HttpResponseBase {
701
- body;
702
- constructor(init = {}) {
703
- super(init);
704
- this.body = init.body !== undefined ? init.body : null;
705
- }
706
- type = HttpEventType.Response;
707
- clone(update = {}) {
708
- return new HttpResponse({
709
- body: update.body !== undefined ? update.body : this.body,
710
- headers: update.headers || this.headers,
711
- status: update.status !== undefined ? update.status : this.status,
712
- statusText: update.statusText || this.statusText,
713
- url: update.url || this.url || undefined,
714
- redirected: update.redirected ?? this.redirected,
715
- responseType: update.responseType ?? this.responseType
716
- });
717
- }
718
- }
719
-
720
- class HttpErrorResponse extends HttpResponseBase {
721
- name = "HttpErrorResponse";
722
- message;
723
- error;
724
- ok = false;
725
- constructor(init) {
726
- super(init, 0, "Unknown Error");
727
- if (this.status >= 200 && this.status < 300) {
728
- this.message = `Http failure during parsing for ${init.url || "(unknown url)"}`;
729
- } else {
730
- this.message = `Http failure response for ${init.url || "(unknown url)"}: ${init.status} ${init.statusText}`;
731
- }
732
- this.error = init.error || null;
733
- }
734
- }
735
- var HTTP_STATUS_CODE_OK = 200;
736
- var HTTP_STATUS_CODE_NO_CONTENT = 204;
737
- var HttpStatusCode;
738
- (function(HttpStatusCode2) {
739
- HttpStatusCode2[HttpStatusCode2["Continue"] = 100] = "Continue";
740
- HttpStatusCode2[HttpStatusCode2["SwitchingProtocols"] = 101] = "SwitchingProtocols";
741
- HttpStatusCode2[HttpStatusCode2["Processing"] = 102] = "Processing";
742
- HttpStatusCode2[HttpStatusCode2["EarlyHints"] = 103] = "EarlyHints";
743
- HttpStatusCode2[HttpStatusCode2["Ok"] = 200] = "Ok";
744
- HttpStatusCode2[HttpStatusCode2["Created"] = 201] = "Created";
745
- HttpStatusCode2[HttpStatusCode2["Accepted"] = 202] = "Accepted";
746
- HttpStatusCode2[HttpStatusCode2["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
747
- HttpStatusCode2[HttpStatusCode2["NoContent"] = 204] = "NoContent";
748
- HttpStatusCode2[HttpStatusCode2["ResetContent"] = 205] = "ResetContent";
749
- HttpStatusCode2[HttpStatusCode2["PartialContent"] = 206] = "PartialContent";
750
- HttpStatusCode2[HttpStatusCode2["MultiStatus"] = 207] = "MultiStatus";
751
- HttpStatusCode2[HttpStatusCode2["AlreadyReported"] = 208] = "AlreadyReported";
752
- HttpStatusCode2[HttpStatusCode2["ImUsed"] = 226] = "ImUsed";
753
- HttpStatusCode2[HttpStatusCode2["MultipleChoices"] = 300] = "MultipleChoices";
754
- HttpStatusCode2[HttpStatusCode2["MovedPermanently"] = 301] = "MovedPermanently";
755
- HttpStatusCode2[HttpStatusCode2["Found"] = 302] = "Found";
756
- HttpStatusCode2[HttpStatusCode2["SeeOther"] = 303] = "SeeOther";
757
- HttpStatusCode2[HttpStatusCode2["NotModified"] = 304] = "NotModified";
758
- HttpStatusCode2[HttpStatusCode2["UseProxy"] = 305] = "UseProxy";
759
- HttpStatusCode2[HttpStatusCode2["Unused"] = 306] = "Unused";
760
- HttpStatusCode2[HttpStatusCode2["TemporaryRedirect"] = 307] = "TemporaryRedirect";
761
- HttpStatusCode2[HttpStatusCode2["PermanentRedirect"] = 308] = "PermanentRedirect";
762
- HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
763
- HttpStatusCode2[HttpStatusCode2["Unauthorized"] = 401] = "Unauthorized";
764
- HttpStatusCode2[HttpStatusCode2["PaymentRequired"] = 402] = "PaymentRequired";
765
- HttpStatusCode2[HttpStatusCode2["Forbidden"] = 403] = "Forbidden";
766
- HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
767
- HttpStatusCode2[HttpStatusCode2["MethodNotAllowed"] = 405] = "MethodNotAllowed";
768
- HttpStatusCode2[HttpStatusCode2["NotAcceptable"] = 406] = "NotAcceptable";
769
- HttpStatusCode2[HttpStatusCode2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
770
- HttpStatusCode2[HttpStatusCode2["RequestTimeout"] = 408] = "RequestTimeout";
771
- HttpStatusCode2[HttpStatusCode2["Conflict"] = 409] = "Conflict";
772
- HttpStatusCode2[HttpStatusCode2["Gone"] = 410] = "Gone";
773
- HttpStatusCode2[HttpStatusCode2["LengthRequired"] = 411] = "LengthRequired";
774
- HttpStatusCode2[HttpStatusCode2["PreconditionFailed"] = 412] = "PreconditionFailed";
775
- HttpStatusCode2[HttpStatusCode2["PayloadTooLarge"] = 413] = "PayloadTooLarge";
776
- HttpStatusCode2[HttpStatusCode2["UriTooLong"] = 414] = "UriTooLong";
777
- HttpStatusCode2[HttpStatusCode2["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
778
- HttpStatusCode2[HttpStatusCode2["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
779
- HttpStatusCode2[HttpStatusCode2["ExpectationFailed"] = 417] = "ExpectationFailed";
780
- HttpStatusCode2[HttpStatusCode2["ImATeapot"] = 418] = "ImATeapot";
781
- HttpStatusCode2[HttpStatusCode2["MisdirectedRequest"] = 421] = "MisdirectedRequest";
782
- HttpStatusCode2[HttpStatusCode2["UnprocessableEntity"] = 422] = "UnprocessableEntity";
783
- HttpStatusCode2[HttpStatusCode2["Locked"] = 423] = "Locked";
784
- HttpStatusCode2[HttpStatusCode2["FailedDependency"] = 424] = "FailedDependency";
785
- HttpStatusCode2[HttpStatusCode2["TooEarly"] = 425] = "TooEarly";
786
- HttpStatusCode2[HttpStatusCode2["UpgradeRequired"] = 426] = "UpgradeRequired";
787
- HttpStatusCode2[HttpStatusCode2["PreconditionRequired"] = 428] = "PreconditionRequired";
788
- HttpStatusCode2[HttpStatusCode2["TooManyRequests"] = 429] = "TooManyRequests";
789
- HttpStatusCode2[HttpStatusCode2["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
790
- HttpStatusCode2[HttpStatusCode2["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
791
- HttpStatusCode2[HttpStatusCode2["InternalServerError"] = 500] = "InternalServerError";
792
- HttpStatusCode2[HttpStatusCode2["NotImplemented"] = 501] = "NotImplemented";
793
- HttpStatusCode2[HttpStatusCode2["BadGateway"] = 502] = "BadGateway";
794
- HttpStatusCode2[HttpStatusCode2["ServiceUnavailable"] = 503] = "ServiceUnavailable";
795
- HttpStatusCode2[HttpStatusCode2["GatewayTimeout"] = 504] = "GatewayTimeout";
796
- HttpStatusCode2[HttpStatusCode2["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
797
- HttpStatusCode2[HttpStatusCode2["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
798
- HttpStatusCode2[HttpStatusCode2["InsufficientStorage"] = 507] = "InsufficientStorage";
799
- HttpStatusCode2[HttpStatusCode2["LoopDetected"] = 508] = "LoopDetected";
800
- HttpStatusCode2[HttpStatusCode2["NotExtended"] = 510] = "NotExtended";
801
- HttpStatusCode2[HttpStatusCode2["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
802
- })(HttpStatusCode || (HttpStatusCode = {}));
803
- var XSSI_PREFIX$1 = /^\)\]\}',?\n/;
804
- var FETCH_BACKEND = new InjectionToken(typeof ngDevMode === "undefined" || ngDevMode ? "FETCH_BACKEND" : "");
805
-
806
- class FetchBackend {
807
- fetchImpl = inject(FetchFactory, {
808
- optional: true
809
- })?.fetch ?? ((...args) => globalThis.fetch(...args));
810
- ngZone = inject(NgZone);
811
- destroyRef = inject(DestroyRef);
812
- handle(request) {
813
- return new Observable((observer) => {
814
- const aborter = new AbortController;
815
- this.doRequest(request, aborter.signal, observer).then(noop, (error) => observer.error(new HttpErrorResponse({
816
- error
817
- })));
818
- let timeoutId;
819
- if (request.timeout) {
820
- timeoutId = this.ngZone.runOutsideAngular(() => setTimeout(() => {
821
- if (!aborter.signal.aborted) {
822
- aborter.abort(new DOMException("signal timed out", "TimeoutError"));
823
- }
824
- }, request.timeout));
825
- }
826
- return () => {
827
- if (timeoutId !== undefined) {
828
- clearTimeout(timeoutId);
829
- }
830
- aborter.abort();
831
- };
832
- });
833
- }
834
- async doRequest(request, signal2, observer) {
835
- const init = this.createRequestInit(request);
836
- let response;
837
- try {
838
- const fetchPromise = this.ngZone.runOutsideAngular(() => this.fetchImpl(request.urlWithParams, {
839
- signal: signal2,
840
- ...init
841
- }));
842
- silenceSuperfluousUnhandledPromiseRejection(fetchPromise);
843
- observer.next({
844
- type: HttpEventType.Sent
845
- });
846
- response = await fetchPromise;
847
- } catch (error) {
848
- observer.error(new HttpErrorResponse({
849
- error,
850
- status: error.status ?? 0,
851
- statusText: error.statusText,
852
- url: request.urlWithParams,
853
- headers: error.headers
854
- }));
855
- return;
856
- }
857
- const headers = new HttpHeaders(response.headers);
858
- const statusText = response.statusText;
859
- const url = response.url || request.urlWithParams;
860
- let status = response.status;
861
- let body = null;
862
- if (request.reportProgress) {
863
- observer.next(new HttpHeaderResponse({
864
- headers,
865
- status,
866
- statusText,
867
- url
868
- }));
869
- }
870
- if (response.body) {
871
- const contentLength = response.headers.get("content-length");
872
- const chunks = [];
873
- const reader = response.body.getReader();
874
- let receivedLength = 0;
875
- let decoder;
876
- let partialText;
877
- const reqZone = typeof Zone !== "undefined" && Zone.current;
878
- let canceled = false;
879
- await this.ngZone.runOutsideAngular(async () => {
880
- while (true) {
881
- if (this.destroyRef.destroyed) {
882
- await reader.cancel();
883
- canceled = true;
884
- break;
885
- }
886
- const {
887
- done,
888
- value
889
- } = await reader.read();
890
- if (done) {
891
- break;
892
- }
893
- chunks.push(value);
894
- receivedLength += value.length;
895
- if (request.reportProgress) {
896
- partialText = request.responseType === "text" ? (partialText ?? "") + (decoder ??= new TextDecoder).decode(value, {
897
- stream: true
898
- }) : undefined;
899
- const reportProgress = () => observer.next({
900
- type: HttpEventType.DownloadProgress,
901
- total: contentLength ? +contentLength : undefined,
902
- loaded: receivedLength,
903
- partialText
904
- });
905
- reqZone ? reqZone.run(reportProgress) : reportProgress();
906
- }
907
- }
908
- });
909
- if (canceled) {
910
- observer.complete();
911
- return;
912
- }
913
- const chunksAll = this.concatChunks(chunks, receivedLength);
914
- try {
915
- const contentType = response.headers.get(CONTENT_TYPE_HEADER) ?? "";
916
- body = this.parseBody(request, chunksAll, contentType, status);
917
- } catch (error) {
918
- observer.error(new HttpErrorResponse({
919
- error,
920
- headers: new HttpHeaders(response.headers),
921
- status: response.status,
922
- statusText: response.statusText,
923
- url: response.url || request.urlWithParams
924
- }));
925
- return;
926
- }
927
- }
928
- if (status === 0) {
929
- status = body ? HTTP_STATUS_CODE_OK : 0;
930
- }
931
- const ok = status >= 200 && status < 300;
932
- const redirected = response.redirected;
933
- const responseType = response.type;
934
- if (ok) {
935
- observer.next(new HttpResponse({
936
- body,
937
- headers,
938
- status,
939
- statusText,
940
- url,
941
- redirected,
942
- responseType
943
- }));
944
- observer.complete();
945
- } else {
946
- observer.error(new HttpErrorResponse({
947
- error: body,
948
- headers,
949
- status,
950
- statusText,
951
- url,
952
- redirected,
953
- responseType
954
- }));
955
- }
956
- }
957
- parseBody(request, binContent, contentType, status) {
958
- switch (request.responseType) {
959
- case "json":
960
- const text = new TextDecoder().decode(binContent).replace(XSSI_PREFIX$1, "");
961
- if (text === "") {
962
- return null;
963
- }
964
- try {
965
- return JSON.parse(text);
966
- } catch (e) {
967
- if (status < 200 || status >= 300) {
968
- return text;
969
- }
970
- throw e;
971
- }
972
- case "text":
973
- return new TextDecoder().decode(binContent);
974
- case "blob":
975
- return new Blob([binContent], {
976
- type: contentType
977
- });
978
- case "arraybuffer":
979
- return binContent.buffer;
980
- }
981
- }
982
- createRequestInit(req) {
983
- const headers = {};
984
- let credentials;
985
- credentials = req.credentials;
986
- if (req.withCredentials) {
987
- (typeof ngDevMode === "undefined" || ngDevMode) && warningOptionsMessage(req);
988
- credentials = "include";
989
- }
990
- req.headers.forEach((name, values) => headers[name] = values.join(","));
991
- if (!req.headers.has(ACCEPT_HEADER)) {
992
- headers[ACCEPT_HEADER] = ACCEPT_HEADER_VALUE;
993
- }
994
- if (!req.headers.has(CONTENT_TYPE_HEADER)) {
995
- const detectedType = req.detectContentTypeHeader();
996
- if (detectedType !== null) {
997
- headers[CONTENT_TYPE_HEADER] = detectedType;
998
- }
999
- }
1000
- return {
1001
- body: req.serializeBody(),
1002
- method: req.method,
1003
- headers,
1004
- credentials,
1005
- keepalive: req.keepalive,
1006
- cache: req.cache,
1007
- priority: req.priority,
1008
- mode: req.mode,
1009
- redirect: req.redirect,
1010
- referrer: req.referrer,
1011
- integrity: req.integrity,
1012
- referrerPolicy: req.referrerPolicy
1013
- };
1014
- }
1015
- concatChunks(chunks, totalLength) {
1016
- const chunksAll = new Uint8Array(totalLength);
1017
- let position = 0;
1018
- for (const chunk of chunks) {
1019
- chunksAll.set(chunk, position);
1020
- position += chunk.length;
1021
- }
1022
- return chunksAll;
1023
- }
1024
- static ɵfac = function FetchBackend_Factory(__ngFactoryType__) {
1025
- return new (__ngFactoryType__ || FetchBackend);
1026
- };
1027
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1028
- token: FetchBackend,
1029
- factory: FetchBackend.ɵfac
1030
- });
1031
- }
1032
- (() => {
1033
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(FetchBackend, [{
1034
- type: Injectable
1035
- }], null, null);
1036
- })();
1037
-
1038
- class FetchFactory {
1039
- }
1040
- function noop() {}
1041
- function warningOptionsMessage(req) {
1042
- if (req.credentials && req.withCredentials) {
1043
- console.warn(formatRuntimeError(2819, `Angular detected that a \`HttpClient\` request has both \`withCredentials: true\` and \`credentials: '${req.credentials}'\` options. The \`withCredentials\` option is overriding the explicit \`credentials\` setting to 'include'. Consider removing \`withCredentials\` and using \`credentials: '${req.credentials}'\` directly for clarity.`));
1044
- }
1045
- }
1046
- function silenceSuperfluousUnhandledPromiseRejection(promise) {
1047
- promise.then(noop, noop);
1048
- }
1049
- var XSSI_PREFIX = /^\)\]\}',?\n/;
1050
- function validateXhrCompatibility(req) {
1051
- const unsupportedOptions = [{
1052
- property: "keepalive",
1053
- errorCode: 2813
1054
- }, {
1055
- property: "cache",
1056
- errorCode: 2814
1057
- }, {
1058
- property: "priority",
1059
- errorCode: 2815
1060
- }, {
1061
- property: "mode",
1062
- errorCode: 2816
1063
- }, {
1064
- property: "redirect",
1065
- errorCode: 2817
1066
- }, {
1067
- property: "credentials",
1068
- errorCode: 2818
1069
- }, {
1070
- property: "integrity",
1071
- errorCode: 2820
1072
- }, {
1073
- property: "referrer",
1074
- errorCode: 2821
1075
- }, {
1076
- property: "referrerPolicy",
1077
- errorCode: 2823
1078
- }];
1079
- for (const {
1080
- property,
1081
- errorCode
1082
- } of unsupportedOptions) {
1083
- if (req[property]) {
1084
- console.warn(formatRuntimeError(errorCode, `Angular detected that a \`HttpClient\` request with the \`${property}\` option was sent using XHR, which does not support it. To use the \`${property}\` option, enable Fetch API support by passing \`withFetch()\` as an argument to \`provideHttpClient()\`.`));
1085
- }
1086
- }
1087
- }
1088
-
1089
- class HttpXhrBackend {
1090
- xhrFactory;
1091
- tracingService = inject(TracingService, {
1092
- optional: true
1093
- });
1094
- constructor(xhrFactory) {
1095
- this.xhrFactory = xhrFactory;
1096
- }
1097
- maybePropagateTrace(fn) {
1098
- return this.tracingService?.propagate ? this.tracingService.propagate(fn) : fn;
1099
- }
1100
- handle(req) {
1101
- if (req.method === "JSONP") {
1102
- throw new RuntimeError(-2800, (typeof ngDevMode === "undefined" || ngDevMode) && `Cannot make a JSONP request without JSONP support. To fix the problem, either add the \`withJsonpSupport()\` call (if \`provideHttpClient()\` is used) or import the \`HttpClientJsonpModule\` in the root NgModule.`);
1103
- }
1104
- ngDevMode && validateXhrCompatibility(req);
1105
- const xhrFactory = this.xhrFactory;
1106
- const source = typeof ngServerMode !== "undefined" && ngServerMode && xhrFactory.ɵloadImpl ? from(xhrFactory.ɵloadImpl()) : of(null);
1107
- return source.pipe(switchMap(() => {
1108
- return new Observable((observer) => {
1109
- const xhr = xhrFactory.build();
1110
- xhr.open(req.method, req.urlWithParams);
1111
- if (req.withCredentials) {
1112
- xhr.withCredentials = true;
1113
- }
1114
- req.headers.forEach((name, values) => xhr.setRequestHeader(name, values.join(",")));
1115
- if (!req.headers.has(ACCEPT_HEADER)) {
1116
- xhr.setRequestHeader(ACCEPT_HEADER, ACCEPT_HEADER_VALUE);
1117
- }
1118
- if (!req.headers.has(CONTENT_TYPE_HEADER)) {
1119
- const detectedType = req.detectContentTypeHeader();
1120
- if (detectedType !== null) {
1121
- xhr.setRequestHeader(CONTENT_TYPE_HEADER, detectedType);
1122
- }
1123
- }
1124
- if (req.timeout) {
1125
- xhr.timeout = req.timeout;
1126
- }
1127
- if (req.responseType) {
1128
- const responseType = req.responseType.toLowerCase();
1129
- xhr.responseType = responseType !== "json" ? responseType : "text";
1130
- }
1131
- const reqBody = req.serializeBody();
1132
- let headerResponse = null;
1133
- const partialFromXhr = () => {
1134
- if (headerResponse !== null) {
1135
- return headerResponse;
1136
- }
1137
- const statusText = xhr.statusText || "OK";
1138
- const headers = new HttpHeaders(xhr.getAllResponseHeaders());
1139
- const url = xhr.responseURL || req.url;
1140
- headerResponse = new HttpHeaderResponse({
1141
- headers,
1142
- status: xhr.status,
1143
- statusText,
1144
- url
1145
- });
1146
- return headerResponse;
1147
- };
1148
- const onLoad = this.maybePropagateTrace(() => {
1149
- let {
1150
- headers,
1151
- status,
1152
- statusText,
1153
- url
1154
- } = partialFromXhr();
1155
- let body = null;
1156
- if (status !== HTTP_STATUS_CODE_NO_CONTENT) {
1157
- body = typeof xhr.response === "undefined" ? xhr.responseText : xhr.response;
1158
- }
1159
- if (status === 0) {
1160
- status = body ? HTTP_STATUS_CODE_OK : 0;
1161
- }
1162
- let ok = status >= 200 && status < 300;
1163
- if (req.responseType === "json" && typeof body === "string") {
1164
- const originalBody = body;
1165
- body = body.replace(XSSI_PREFIX, "");
1166
- try {
1167
- body = body !== "" ? JSON.parse(body) : null;
1168
- } catch (error) {
1169
- body = originalBody;
1170
- if (ok) {
1171
- ok = false;
1172
- body = {
1173
- error,
1174
- text: body
1175
- };
1176
- }
1177
- }
1178
- }
1179
- if (ok) {
1180
- observer.next(new HttpResponse({
1181
- body,
1182
- headers,
1183
- status,
1184
- statusText,
1185
- url: url || undefined
1186
- }));
1187
- observer.complete();
1188
- } else {
1189
- observer.error(new HttpErrorResponse({
1190
- error: body,
1191
- headers,
1192
- status,
1193
- statusText,
1194
- url: url || undefined
1195
- }));
1196
- }
1197
- });
1198
- const onError = this.maybePropagateTrace((error) => {
1199
- const {
1200
- url
1201
- } = partialFromXhr();
1202
- const res = new HttpErrorResponse({
1203
- error,
1204
- status: xhr.status || 0,
1205
- statusText: xhr.statusText || "Unknown Error",
1206
- url: url || undefined
1207
- });
1208
- observer.error(res);
1209
- });
1210
- let onTimeout = onError;
1211
- if (req.timeout) {
1212
- onTimeout = this.maybePropagateTrace((_) => {
1213
- const {
1214
- url
1215
- } = partialFromXhr();
1216
- const res = new HttpErrorResponse({
1217
- error: new DOMException("Request timed out", "TimeoutError"),
1218
- status: xhr.status || 0,
1219
- statusText: xhr.statusText || "Request timeout",
1220
- url: url || undefined
1221
- });
1222
- observer.error(res);
1223
- });
1224
- }
1225
- let sentHeaders = false;
1226
- const onDownProgress = this.maybePropagateTrace((event) => {
1227
- if (!sentHeaders) {
1228
- observer.next(partialFromXhr());
1229
- sentHeaders = true;
1230
- }
1231
- let progressEvent = {
1232
- type: HttpEventType.DownloadProgress,
1233
- loaded: event.loaded
1234
- };
1235
- if (event.lengthComputable) {
1236
- progressEvent.total = event.total;
1237
- }
1238
- if (req.responseType === "text" && !!xhr.responseText) {
1239
- progressEvent.partialText = xhr.responseText;
1240
- }
1241
- observer.next(progressEvent);
1242
- });
1243
- const onUpProgress = this.maybePropagateTrace((event) => {
1244
- let progress = {
1245
- type: HttpEventType.UploadProgress,
1246
- loaded: event.loaded
1247
- };
1248
- if (event.lengthComputable) {
1249
- progress.total = event.total;
1250
- }
1251
- observer.next(progress);
1252
- });
1253
- xhr.addEventListener("load", onLoad);
1254
- xhr.addEventListener("error", onError);
1255
- xhr.addEventListener("timeout", onTimeout);
1256
- xhr.addEventListener("abort", onError);
1257
- if (req.reportProgress) {
1258
- xhr.addEventListener("progress", onDownProgress);
1259
- if (reqBody !== null && xhr.upload) {
1260
- xhr.upload.addEventListener("progress", onUpProgress);
1261
- }
1262
- }
1263
- xhr.send(reqBody);
1264
- observer.next({
1265
- type: HttpEventType.Sent
1266
- });
1267
- return () => {
1268
- xhr.removeEventListener("error", onError);
1269
- xhr.removeEventListener("abort", onError);
1270
- xhr.removeEventListener("load", onLoad);
1271
- xhr.removeEventListener("timeout", onTimeout);
1272
- if (req.reportProgress) {
1273
- xhr.removeEventListener("progress", onDownProgress);
1274
- if (reqBody !== null && xhr.upload) {
1275
- xhr.upload.removeEventListener("progress", onUpProgress);
1276
- }
1277
- }
1278
- if (xhr.readyState !== xhr.DONE) {
1279
- xhr.abort();
1280
- }
1281
- };
1282
- });
1283
- }));
1284
- }
1285
- static ɵfac = function HttpXhrBackend_Factory(__ngFactoryType__) {
1286
- return new (__ngFactoryType__ || HttpXhrBackend)(ɵ_inject(XhrFactory));
1287
- };
1288
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1289
- token: HttpXhrBackend,
1290
- factory: HttpXhrBackend.ɵfac,
1291
- providedIn: "root"
1292
- });
1293
- }
1294
- (() => {
1295
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpXhrBackend, [{
1296
- type: Injectable,
1297
- args: [{
1298
- providedIn: "root"
1299
- }]
1300
- }], () => [{
1301
- type: XhrFactory
1302
- }], null);
1303
- })();
1304
- function interceptorChainEndFn(req, finalHandlerFn) {
1305
- return finalHandlerFn(req);
1306
- }
1307
- function adaptLegacyInterceptorToChain(chainTailFn, interceptor) {
1308
- return (initialRequest, finalHandlerFn) => interceptor.intercept(initialRequest, {
1309
- handle: (downstreamRequest) => chainTailFn(downstreamRequest, finalHandlerFn)
1310
- });
1311
- }
1312
- function chainedInterceptorFn(chainTailFn, interceptorFn, injector) {
1313
- return (initialRequest, finalHandlerFn) => runInInjectionContext(injector, () => interceptorFn(initialRequest, (downstreamRequest) => chainTailFn(downstreamRequest, finalHandlerFn)));
1314
- }
1315
- var HTTP_INTERCEPTORS = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "HTTP_INTERCEPTORS" : "");
1316
- var HTTP_INTERCEPTOR_FNS = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "HTTP_INTERCEPTOR_FNS" : "", {
1317
- factory: () => []
1318
- });
1319
- var HTTP_ROOT_INTERCEPTOR_FNS = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "HTTP_ROOT_INTERCEPTOR_FNS" : "");
1320
- var REQUESTS_CONTRIBUTE_TO_STABILITY = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "REQUESTS_CONTRIBUTE_TO_STABILITY" : "", {
1321
- factory: () => true
1322
- });
1323
- function legacyInterceptorFnFactory() {
1324
- let chain = null;
1325
- return (req, handler) => {
1326
- if (chain === null) {
1327
- const interceptors = inject(HTTP_INTERCEPTORS, {
1328
- optional: true
1329
- }) ?? [];
1330
- chain = interceptors.reduceRight(adaptLegacyInterceptorToChain, interceptorChainEndFn);
1331
- }
1332
- const pendingTasks = inject(PendingTasks);
1333
- const contributeToStability = inject(REQUESTS_CONTRIBUTE_TO_STABILITY);
1334
- if (contributeToStability) {
1335
- const removeTask = pendingTasks.add();
1336
- return chain(req, handler).pipe(finalize(removeTask));
1337
- } else {
1338
- return chain(req, handler);
1339
- }
1340
- };
1341
- }
1342
-
1343
- class HttpBackend {
1344
- static ɵfac = function HttpBackend_Factory(__ngFactoryType__) {
1345
- return new (__ngFactoryType__ || HttpBackend);
1346
- };
1347
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1348
- token: HttpBackend,
1349
- factory: function HttpBackend_Factory(__ngFactoryType__) {
1350
- let __ngConditionalFactory__ = null;
1351
- if (__ngFactoryType__) {
1352
- __ngConditionalFactory__ = new (__ngFactoryType__ || HttpBackend);
1353
- } else {
1354
- __ngConditionalFactory__ = ɵ_inject(HttpXhrBackend);
1355
- }
1356
- return __ngConditionalFactory__;
1357
- },
1358
- providedIn: "root"
1359
- });
1360
- }
1361
- (() => {
1362
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpBackend, [{
1363
- type: Injectable,
1364
- args: [{
1365
- providedIn: "root",
1366
- useExisting: HttpXhrBackend
1367
- }]
1368
- }], null, null);
1369
- })();
1370
- var fetchBackendWarningDisplayed = false;
1371
-
1372
- class HttpInterceptorHandler {
1373
- backend;
1374
- injector;
1375
- chain = null;
1376
- pendingTasks = inject(PendingTasks);
1377
- contributeToStability = inject(REQUESTS_CONTRIBUTE_TO_STABILITY);
1378
- constructor(backend, injector) {
1379
- this.backend = backend;
1380
- this.injector = injector;
1381
- if ((typeof ngDevMode === "undefined" || ngDevMode) && !fetchBackendWarningDisplayed) {
1382
- const isTestingBackend = this.backend.isTestingBackend;
1383
- if (typeof ngServerMode !== "undefined" && ngServerMode && !(this.backend instanceof FetchBackend) && !isTestingBackend) {
1384
- fetchBackendWarningDisplayed = true;
1385
- injector.get(Console).warn(formatRuntimeError(2801, "Angular detected that `HttpClient` is not configured " + "to use `fetch` APIs. It's strongly recommended to " + "enable `fetch` for applications that use Server-Side Rendering " + "for better performance and compatibility. " + "To enable `fetch`, add the `withFetch()` to the `provideHttpClient()` " + "call at the root of the application."));
1386
- }
1387
- }
1388
- }
1389
- handle(initialRequest) {
1390
- if (this.chain === null) {
1391
- const dedupedInterceptorFns = Array.from(new Set([...this.injector.get(HTTP_INTERCEPTOR_FNS), ...this.injector.get(HTTP_ROOT_INTERCEPTOR_FNS, [])]));
1392
- this.chain = dedupedInterceptorFns.reduceRight((nextSequencedFn, interceptorFn) => chainedInterceptorFn(nextSequencedFn, interceptorFn, this.injector), interceptorChainEndFn);
1393
- }
1394
- if (this.contributeToStability) {
1395
- const removeTask = this.pendingTasks.add();
1396
- return this.chain(initialRequest, (downstreamRequest) => this.backend.handle(downstreamRequest)).pipe(finalize(removeTask));
1397
- } else {
1398
- return this.chain(initialRequest, (downstreamRequest) => this.backend.handle(downstreamRequest));
1399
- }
1400
- }
1401
- static ɵfac = function HttpInterceptorHandler_Factory(__ngFactoryType__) {
1402
- return new (__ngFactoryType__ || HttpInterceptorHandler)(ɵ_inject(HttpBackend), ɵ_inject(EnvironmentInjector));
1403
- };
1404
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1405
- token: HttpInterceptorHandler,
1406
- factory: HttpInterceptorHandler.ɵfac,
1407
- providedIn: "root"
1408
- });
1409
- }
1410
- (() => {
1411
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpInterceptorHandler, [{
1412
- type: Injectable,
1413
- args: [{
1414
- providedIn: "root"
1415
- }]
1416
- }], () => [{
1417
- type: HttpBackend
1418
- }, {
1419
- type: EnvironmentInjector
1420
- }], null);
1421
- })();
1422
-
1423
- class HttpHandler {
1424
- static ɵfac = function HttpHandler_Factory(__ngFactoryType__) {
1425
- return new (__ngFactoryType__ || HttpHandler);
1426
- };
1427
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1428
- token: HttpHandler,
1429
- factory: function HttpHandler_Factory(__ngFactoryType__) {
1430
- let __ngConditionalFactory__ = null;
1431
- if (__ngFactoryType__) {
1432
- __ngConditionalFactory__ = new (__ngFactoryType__ || HttpHandler);
1433
- } else {
1434
- __ngConditionalFactory__ = ɵ_inject(HttpInterceptorHandler);
1435
- }
1436
- return __ngConditionalFactory__;
1437
- },
1438
- providedIn: "root"
1439
- });
1440
- }
1441
- (() => {
1442
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpHandler, [{
1443
- type: Injectable,
1444
- args: [{
1445
- providedIn: "root",
1446
- useExisting: HttpInterceptorHandler
1447
- }]
1448
- }], null, null);
1449
- })();
1450
- function addBody(options, body) {
1451
- return {
1452
- body,
1453
- headers: options.headers,
1454
- context: options.context,
1455
- observe: options.observe,
1456
- params: options.params,
1457
- reportProgress: options.reportProgress,
1458
- responseType: options.responseType,
1459
- withCredentials: options.withCredentials,
1460
- credentials: options.credentials,
1461
- transferCache: options.transferCache,
1462
- timeout: options.timeout,
1463
- keepalive: options.keepalive,
1464
- priority: options.priority,
1465
- cache: options.cache,
1466
- mode: options.mode,
1467
- redirect: options.redirect,
1468
- integrity: options.integrity,
1469
- referrer: options.referrer,
1470
- referrerPolicy: options.referrerPolicy
1471
- };
1472
- }
1473
-
1474
- class HttpClient {
1475
- handler;
1476
- constructor(handler) {
1477
- this.handler = handler;
1478
- }
1479
- request(first, url, options = {}) {
1480
- let req;
1481
- if (first instanceof HttpRequest) {
1482
- req = first;
1483
- } else {
1484
- let headers = undefined;
1485
- if (options.headers instanceof HttpHeaders) {
1486
- headers = options.headers;
1487
- } else {
1488
- headers = new HttpHeaders(options.headers);
1489
- }
1490
- let params = undefined;
1491
- if (!!options.params) {
1492
- if (options.params instanceof HttpParams) {
1493
- params = options.params;
1494
- } else {
1495
- params = new HttpParams({
1496
- fromObject: options.params
1497
- });
1498
- }
1499
- }
1500
- req = new HttpRequest(first, url, options.body !== undefined ? options.body : null, {
1501
- headers,
1502
- context: options.context,
1503
- params,
1504
- reportProgress: options.reportProgress,
1505
- responseType: options.responseType || "json",
1506
- withCredentials: options.withCredentials,
1507
- transferCache: options.transferCache,
1508
- keepalive: options.keepalive,
1509
- priority: options.priority,
1510
- cache: options.cache,
1511
- mode: options.mode,
1512
- redirect: options.redirect,
1513
- credentials: options.credentials,
1514
- referrer: options.referrer,
1515
- referrerPolicy: options.referrerPolicy,
1516
- integrity: options.integrity,
1517
- timeout: options.timeout
1518
- });
1519
- }
1520
- const events$ = of(req).pipe(concatMap((req2) => this.handler.handle(req2)));
1521
- if (first instanceof HttpRequest || options.observe === "events") {
1522
- return events$;
1523
- }
1524
- const res$ = events$.pipe(filter((event) => event instanceof HttpResponse));
1525
- switch (options.observe || "body") {
1526
- case "body":
1527
- switch (req.responseType) {
1528
- case "arraybuffer":
1529
- return res$.pipe(map((res) => {
1530
- if (res.body !== null && !(res.body instanceof ArrayBuffer)) {
1531
- throw new RuntimeError(2806, ngDevMode && "Response is not an ArrayBuffer.");
1532
- }
1533
- return res.body;
1534
- }));
1535
- case "blob":
1536
- return res$.pipe(map((res) => {
1537
- if (res.body !== null && !(res.body instanceof Blob)) {
1538
- throw new RuntimeError(2807, ngDevMode && "Response is not a Blob.");
1539
- }
1540
- return res.body;
1541
- }));
1542
- case "text":
1543
- return res$.pipe(map((res) => {
1544
- if (res.body !== null && typeof res.body !== "string") {
1545
- throw new RuntimeError(2808, ngDevMode && "Response is not a string.");
1546
- }
1547
- return res.body;
1548
- }));
1549
- case "json":
1550
- default:
1551
- return res$.pipe(map((res) => res.body));
1552
- }
1553
- case "response":
1554
- return res$;
1555
- default:
1556
- throw new RuntimeError(2809, ngDevMode && `Unreachable: unhandled observe type ${options.observe}}`);
1557
- }
1558
- }
1559
- delete(url, options = {}) {
1560
- return this.request("DELETE", url, options);
1561
- }
1562
- get(url, options = {}) {
1563
- return this.request("GET", url, options);
1564
- }
1565
- head(url, options = {}) {
1566
- return this.request("HEAD", url, options);
1567
- }
1568
- jsonp(url, callbackParam) {
1569
- return this.request("JSONP", url, {
1570
- params: new HttpParams().append(callbackParam, "JSONP_CALLBACK"),
1571
- observe: "body",
1572
- responseType: "json"
1573
- });
1574
- }
1575
- options(url, options = {}) {
1576
- return this.request("OPTIONS", url, options);
1577
- }
1578
- patch(url, body, options = {}) {
1579
- return this.request("PATCH", url, addBody(options, body));
1580
- }
1581
- post(url, body, options = {}) {
1582
- return this.request("POST", url, addBody(options, body));
1583
- }
1584
- put(url, body, options = {}) {
1585
- return this.request("PUT", url, addBody(options, body));
1586
- }
1587
- static ɵfac = function HttpClient_Factory(__ngFactoryType__) {
1588
- return new (__ngFactoryType__ || HttpClient)(ɵ_inject(HttpHandler));
1589
- };
1590
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1591
- token: HttpClient,
1592
- factory: HttpClient.ɵfac,
1593
- providedIn: "root"
1594
- });
1595
- }
1596
- (() => {
1597
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpClient, [{
1598
- type: Injectable,
1599
- args: [{
1600
- providedIn: "root"
1601
- }]
1602
- }], () => [{
1603
- type: HttpHandler
1604
- }], null);
1605
- })();
1606
- var nextRequestId = 0;
1607
- var foreignDocument;
1608
- var JSONP_ERR_NO_CALLBACK = "JSONP injected script did not invoke callback.";
1609
- var JSONP_ERR_WRONG_METHOD = "JSONP requests must use JSONP request method.";
1610
- var JSONP_ERR_WRONG_RESPONSE_TYPE = "JSONP requests must use Json response type.";
1611
- var JSONP_ERR_HEADERS_NOT_SUPPORTED = "JSONP requests do not support headers.";
1612
-
1613
- class JsonpCallbackContext {
1614
- }
1615
- function jsonpCallbackContext() {
1616
- if (typeof window === "object") {
1617
- return window;
1618
- }
1619
- return {};
1620
- }
1621
-
1622
- class JsonpClientBackend {
1623
- callbackMap;
1624
- document;
1625
- resolvedPromise = Promise.resolve();
1626
- constructor(callbackMap, document) {
1627
- this.callbackMap = callbackMap;
1628
- this.document = document;
1629
- }
1630
- nextCallback() {
1631
- return `ng_jsonp_callback_${nextRequestId++}`;
1632
- }
1633
- handle(req) {
1634
- if (req.method !== "JSONP") {
1635
- throw new RuntimeError(2810, ngDevMode && JSONP_ERR_WRONG_METHOD);
1636
- } else if (req.responseType !== "json") {
1637
- throw new RuntimeError(2811, ngDevMode && JSONP_ERR_WRONG_RESPONSE_TYPE);
1638
- }
1639
- if (req.headers.keys().length > 0) {
1640
- throw new RuntimeError(2812, ngDevMode && JSONP_ERR_HEADERS_NOT_SUPPORTED);
1641
- }
1642
- return new Observable((observer) => {
1643
- const callback = this.nextCallback();
1644
- const url = req.urlWithParams.replace(/=JSONP_CALLBACK(&|$)/, `=${callback}$1`);
1645
- const node = this.document.createElement("script");
1646
- node.src = url;
1647
- let body = null;
1648
- let finished = false;
1649
- this.callbackMap[callback] = (data) => {
1650
- delete this.callbackMap[callback];
1651
- body = data;
1652
- finished = true;
1653
- };
1654
- const cleanup = () => {
1655
- node.removeEventListener("load", onLoad);
1656
- node.removeEventListener("error", onError);
1657
- node.remove();
1658
- delete this.callbackMap[callback];
1659
- };
1660
- const onLoad = () => {
1661
- this.resolvedPromise.then(() => {
1662
- cleanup();
1663
- if (!finished) {
1664
- observer.error(new HttpErrorResponse({
1665
- url,
1666
- status: 0,
1667
- statusText: "JSONP Error",
1668
- error: new Error(JSONP_ERR_NO_CALLBACK)
1669
- }));
1670
- return;
1671
- }
1672
- observer.next(new HttpResponse({
1673
- body,
1674
- status: HTTP_STATUS_CODE_OK,
1675
- statusText: "OK",
1676
- url
1677
- }));
1678
- observer.complete();
1679
- });
1680
- };
1681
- const onError = (error) => {
1682
- cleanup();
1683
- observer.error(new HttpErrorResponse({
1684
- error,
1685
- status: 0,
1686
- statusText: "JSONP Error",
1687
- url
1688
- }));
1689
- };
1690
- node.addEventListener("load", onLoad);
1691
- node.addEventListener("error", onError);
1692
- this.document.body.appendChild(node);
1693
- observer.next({
1694
- type: HttpEventType.Sent
1695
- });
1696
- return () => {
1697
- if (!finished) {
1698
- this.removeListeners(node);
1699
- }
1700
- cleanup();
1701
- };
1702
- });
1703
- }
1704
- removeListeners(script) {
1705
- foreignDocument ??= this.document.implementation.createHTMLDocument();
1706
- foreignDocument.adoptNode(script);
1707
- }
1708
- static ɵfac = function JsonpClientBackend_Factory(__ngFactoryType__) {
1709
- return new (__ngFactoryType__ || JsonpClientBackend)(ɵ_inject(JsonpCallbackContext), ɵ_inject(DOCUMENT));
1710
- };
1711
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1712
- token: JsonpClientBackend,
1713
- factory: JsonpClientBackend.ɵfac
1714
- });
1715
- }
1716
- (() => {
1717
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(JsonpClientBackend, [{
1718
- type: Injectable
1719
- }], () => [{
1720
- type: JsonpCallbackContext
1721
- }, {
1722
- type: undefined,
1723
- decorators: [{
1724
- type: Inject,
1725
- args: [DOCUMENT]
1726
- }]
1727
- }], null);
1728
- })();
1729
- function jsonpInterceptorFn(req, next) {
1730
- if (req.method === "JSONP") {
1731
- return inject(JsonpClientBackend).handle(req);
1732
- }
1733
- return next(req);
1734
- }
1735
-
1736
- class JsonpInterceptor {
1737
- injector;
1738
- constructor(injector) {
1739
- this.injector = injector;
1740
- }
1741
- intercept(initialRequest, next) {
1742
- return runInInjectionContext(this.injector, () => jsonpInterceptorFn(initialRequest, (downstreamRequest) => next.handle(downstreamRequest)));
1743
- }
1744
- static ɵfac = function JsonpInterceptor_Factory(__ngFactoryType__) {
1745
- return new (__ngFactoryType__ || JsonpInterceptor)(ɵ_inject(EnvironmentInjector));
1746
- };
1747
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1748
- token: JsonpInterceptor,
1749
- factory: JsonpInterceptor.ɵfac
1750
- });
1751
- }
1752
- (() => {
1753
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(JsonpInterceptor, [{
1754
- type: Injectable
1755
- }], () => [{
1756
- type: EnvironmentInjector
1757
- }], null);
1758
- })();
1759
- var XSRF_ENABLED = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "XSRF_ENABLED" : "", {
1760
- factory: () => true
1761
- });
1762
- var XSRF_DEFAULT_COOKIE_NAME = "XSRF-TOKEN";
1763
- var XSRF_COOKIE_NAME = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "XSRF_COOKIE_NAME" : "", {
1764
- factory: () => XSRF_DEFAULT_COOKIE_NAME
1765
- });
1766
- var XSRF_DEFAULT_HEADER_NAME = "X-XSRF-TOKEN";
1767
- var XSRF_HEADER_NAME = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "XSRF_HEADER_NAME" : "", {
1768
- factory: () => XSRF_DEFAULT_HEADER_NAME
1769
- });
1770
-
1771
- class HttpXsrfCookieExtractor {
1772
- cookieName = inject(XSRF_COOKIE_NAME);
1773
- doc = inject(DOCUMENT);
1774
- lastCookieString = "";
1775
- lastToken = null;
1776
- parseCount = 0;
1777
- getToken() {
1778
- if (typeof ngServerMode !== "undefined" && ngServerMode) {
1779
- return null;
1780
- }
1781
- const cookieString = this.doc.cookie || "";
1782
- if (cookieString !== this.lastCookieString) {
1783
- this.parseCount++;
1784
- this.lastToken = parseCookieValue(cookieString, this.cookieName);
1785
- this.lastCookieString = cookieString;
1786
- }
1787
- return this.lastToken;
1788
- }
1789
- static ɵfac = function HttpXsrfCookieExtractor_Factory(__ngFactoryType__) {
1790
- return new (__ngFactoryType__ || HttpXsrfCookieExtractor);
1791
- };
1792
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1793
- token: HttpXsrfCookieExtractor,
1794
- factory: HttpXsrfCookieExtractor.ɵfac,
1795
- providedIn: "root"
1796
- });
1797
- }
1798
- (() => {
1799
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpXsrfCookieExtractor, [{
1800
- type: Injectable,
1801
- args: [{
1802
- providedIn: "root"
1803
- }]
1804
- }], null, null);
1805
- })();
1806
-
1807
- class HttpXsrfTokenExtractor {
1808
- static ɵfac = function HttpXsrfTokenExtractor_Factory(__ngFactoryType__) {
1809
- return new (__ngFactoryType__ || HttpXsrfTokenExtractor);
1810
- };
1811
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1812
- token: HttpXsrfTokenExtractor,
1813
- factory: function HttpXsrfTokenExtractor_Factory(__ngFactoryType__) {
1814
- let __ngConditionalFactory__ = null;
1815
- if (__ngFactoryType__) {
1816
- __ngConditionalFactory__ = new (__ngFactoryType__ || HttpXsrfTokenExtractor);
1817
- } else {
1818
- __ngConditionalFactory__ = ɵ_inject(HttpXsrfCookieExtractor);
1819
- }
1820
- return __ngConditionalFactory__;
1821
- },
1822
- providedIn: "root"
1823
- });
1824
- }
1825
- (() => {
1826
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpXsrfTokenExtractor, [{
1827
- type: Injectable,
1828
- args: [{
1829
- providedIn: "root",
1830
- useExisting: HttpXsrfCookieExtractor
1831
- }]
1832
- }], null, null);
1833
- })();
1834
- function xsrfInterceptorFn(req, next) {
1835
- if (!inject(XSRF_ENABLED) || req.method === "GET" || req.method === "HEAD") {
1836
- return next(req);
1837
- }
1838
- try {
1839
- const locationHref = inject(PlatformLocation).href;
1840
- const {
1841
- origin: locationOrigin
1842
- } = new URL(locationHref);
1843
- const {
1844
- origin: requestOrigin
1845
- } = new URL(req.url, locationOrigin);
1846
- if (locationOrigin !== requestOrigin) {
1847
- return next(req);
1848
- }
1849
- } catch {
1850
- return next(req);
1851
- }
1852
- const token = inject(HttpXsrfTokenExtractor).getToken();
1853
- const headerName = inject(XSRF_HEADER_NAME);
1854
- if (token != null && !req.headers.has(headerName)) {
1855
- req = req.clone({
1856
- headers: req.headers.set(headerName, token)
1857
- });
1858
- }
1859
- return next(req);
1860
- }
1861
-
1862
- class HttpXsrfInterceptor {
1863
- injector = inject(EnvironmentInjector);
1864
- intercept(initialRequest, next) {
1865
- return runInInjectionContext(this.injector, () => xsrfInterceptorFn(initialRequest, (downstreamRequest) => next.handle(downstreamRequest)));
1866
- }
1867
- static ɵfac = function HttpXsrfInterceptor_Factory(__ngFactoryType__) {
1868
- return new (__ngFactoryType__ || HttpXsrfInterceptor);
1869
- };
1870
- static ɵprov = /* @__PURE__ */ ɵ_defineInjectable({
1871
- token: HttpXsrfInterceptor,
1872
- factory: HttpXsrfInterceptor.ɵfac
1873
- });
1874
- }
1875
- (() => {
1876
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpXsrfInterceptor, [{
1877
- type: Injectable
1878
- }], null, null);
1879
- })();
1880
- var HttpFeatureKind;
1881
- (function(HttpFeatureKind2) {
1882
- HttpFeatureKind2[HttpFeatureKind2["Interceptors"] = 0] = "Interceptors";
1883
- HttpFeatureKind2[HttpFeatureKind2["LegacyInterceptors"] = 1] = "LegacyInterceptors";
1884
- HttpFeatureKind2[HttpFeatureKind2["CustomXsrfConfiguration"] = 2] = "CustomXsrfConfiguration";
1885
- HttpFeatureKind2[HttpFeatureKind2["NoXsrfProtection"] = 3] = "NoXsrfProtection";
1886
- HttpFeatureKind2[HttpFeatureKind2["JsonpSupport"] = 4] = "JsonpSupport";
1887
- HttpFeatureKind2[HttpFeatureKind2["RequestsMadeViaParent"] = 5] = "RequestsMadeViaParent";
1888
- HttpFeatureKind2[HttpFeatureKind2["Fetch"] = 6] = "Fetch";
1889
- })(HttpFeatureKind || (HttpFeatureKind = {}));
1890
- function makeHttpFeature(kind, providers) {
1891
- return {
1892
- ɵkind: kind,
1893
- ɵproviders: providers
1894
- };
1895
- }
1896
- function provideHttpClient(...features) {
1897
- if (ngDevMode) {
1898
- const featureKinds = new Set(features.map((f) => f.ɵkind));
1899
- if (featureKinds.has(HttpFeatureKind.NoXsrfProtection) && featureKinds.has(HttpFeatureKind.CustomXsrfConfiguration)) {
1900
- throw new Error(ngDevMode ? `Configuration error: found both withXsrfConfiguration() and withNoXsrfProtection() in the same call to provideHttpClient(), which is a contradiction.` : "");
1901
- }
1902
- }
1903
- const providers = [HttpClient, HttpInterceptorHandler, {
1904
- provide: HttpHandler,
1905
- useExisting: HttpInterceptorHandler
1906
- }, {
1907
- provide: HttpBackend,
1908
- useFactory: () => {
1909
- return inject(FETCH_BACKEND, {
1910
- optional: true
1911
- }) ?? inject(HttpXhrBackend);
1912
- }
1913
- }, {
1914
- provide: HTTP_INTERCEPTOR_FNS,
1915
- useValue: xsrfInterceptorFn,
1916
- multi: true
1917
- }];
1918
- for (const feature of features) {
1919
- providers.push(...feature.ɵproviders);
1920
- }
1921
- return makeEnvironmentProviders(providers);
1922
- }
1923
- function withInterceptors(interceptorFns) {
1924
- return makeHttpFeature(HttpFeatureKind.Interceptors, interceptorFns.map((interceptorFn) => {
1925
- return {
1926
- provide: HTTP_INTERCEPTOR_FNS,
1927
- useValue: interceptorFn,
1928
- multi: true
1929
- };
1930
- }));
1931
- }
1932
- var LEGACY_INTERCEPTOR_FN = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "LEGACY_INTERCEPTOR_FN" : "");
1933
- function withInterceptorsFromDi() {
1934
- return makeHttpFeature(HttpFeatureKind.LegacyInterceptors, [{
1935
- provide: LEGACY_INTERCEPTOR_FN,
1936
- useFactory: legacyInterceptorFnFactory
1937
- }, {
1938
- provide: HTTP_INTERCEPTOR_FNS,
1939
- useExisting: LEGACY_INTERCEPTOR_FN,
1940
- multi: true
1941
- }]);
1942
- }
1943
- function withXsrfConfiguration({
1944
- cookieName,
1945
- headerName
1946
- }) {
1947
- const providers = [];
1948
- if (cookieName !== undefined) {
1949
- providers.push({
1950
- provide: XSRF_COOKIE_NAME,
1951
- useValue: cookieName
1952
- });
1953
- }
1954
- if (headerName !== undefined) {
1955
- providers.push({
1956
- provide: XSRF_HEADER_NAME,
1957
- useValue: headerName
1958
- });
1959
- }
1960
- return makeHttpFeature(HttpFeatureKind.CustomXsrfConfiguration, providers);
1961
- }
1962
- function withNoXsrfProtection() {
1963
- return makeHttpFeature(HttpFeatureKind.NoXsrfProtection, [{
1964
- provide: XSRF_ENABLED,
1965
- useValue: false
1966
- }]);
1967
- }
1968
- function withJsonpSupport() {
1969
- return makeHttpFeature(HttpFeatureKind.JsonpSupport, [JsonpClientBackend, {
1970
- provide: JsonpCallbackContext,
1971
- useFactory: jsonpCallbackContext
1972
- }, {
1973
- provide: HTTP_INTERCEPTOR_FNS,
1974
- useValue: jsonpInterceptorFn,
1975
- multi: true
1976
- }]);
1977
- }
1978
- function withRequestsMadeViaParent() {
1979
- return makeHttpFeature(HttpFeatureKind.RequestsMadeViaParent, [{
1980
- provide: HttpBackend,
1981
- useFactory: () => {
1982
- const handlerFromParent = inject(HttpHandler, {
1983
- skipSelf: true,
1984
- optional: true
1985
- });
1986
- if (ngDevMode && handlerFromParent === null) {
1987
- throw new Error("withRequestsMadeViaParent() can only be used when the parent injector also configures HttpClient");
1988
- }
1989
- return handlerFromParent;
1990
- }
1991
- }]);
1992
- }
1993
- function withFetch() {
1994
- return makeHttpFeature(HttpFeatureKind.Fetch, [FetchBackend, {
1995
- provide: FETCH_BACKEND,
1996
- useExisting: FetchBackend
1997
- }, {
1998
- provide: HttpBackend,
1999
- useExisting: FetchBackend
2000
- }]);
2001
- }
2002
-
2003
- class HttpClientXsrfModule {
2004
- static disable() {
2005
- return {
2006
- ngModule: HttpClientXsrfModule,
2007
- providers: [withNoXsrfProtection().ɵproviders]
2008
- };
2009
- }
2010
- static withOptions(options = {}) {
2011
- return {
2012
- ngModule: HttpClientXsrfModule,
2013
- providers: withXsrfConfiguration(options).ɵproviders
2014
- };
2015
- }
2016
- static ɵfac = function HttpClientXsrfModule_Factory(__ngFactoryType__) {
2017
- return new (__ngFactoryType__ || HttpClientXsrfModule);
2018
- };
2019
- static ɵmod = /* @__PURE__ */ ɵ_defineNgModule({
2020
- type: HttpClientXsrfModule
2021
- });
2022
- static ɵinj = /* @__PURE__ */ ɵ_defineInjector({
2023
- providers: [HttpXsrfInterceptor, {
2024
- provide: HTTP_INTERCEPTORS,
2025
- useExisting: HttpXsrfInterceptor,
2026
- multi: true
2027
- }, {
2028
- provide: HttpXsrfTokenExtractor,
2029
- useClass: HttpXsrfCookieExtractor
2030
- }, withXsrfConfiguration({
2031
- cookieName: XSRF_DEFAULT_COOKIE_NAME,
2032
- headerName: XSRF_DEFAULT_HEADER_NAME
2033
- }).ɵproviders, {
2034
- provide: XSRF_ENABLED,
2035
- useValue: true
2036
- }]
2037
- });
2038
- }
2039
- (() => {
2040
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpClientXsrfModule, [{
2041
- type: NgModule,
2042
- args: [{
2043
- providers: [HttpXsrfInterceptor, {
2044
- provide: HTTP_INTERCEPTORS,
2045
- useExisting: HttpXsrfInterceptor,
2046
- multi: true
2047
- }, {
2048
- provide: HttpXsrfTokenExtractor,
2049
- useClass: HttpXsrfCookieExtractor
2050
- }, withXsrfConfiguration({
2051
- cookieName: XSRF_DEFAULT_COOKIE_NAME,
2052
- headerName: XSRF_DEFAULT_HEADER_NAME
2053
- }).ɵproviders, {
2054
- provide: XSRF_ENABLED,
2055
- useValue: true
2056
- }]
2057
- }]
2058
- }], null, null);
2059
- })();
2060
-
2061
- class HttpClientModule {
2062
- static ɵfac = function HttpClientModule_Factory(__ngFactoryType__) {
2063
- return new (__ngFactoryType__ || HttpClientModule);
2064
- };
2065
- static ɵmod = /* @__PURE__ */ ɵ_defineNgModule({
2066
- type: HttpClientModule
2067
- });
2068
- static ɵinj = /* @__PURE__ */ ɵ_defineInjector({
2069
- providers: [provideHttpClient(withInterceptorsFromDi())]
2070
- });
2071
- }
2072
- (() => {
2073
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpClientModule, [{
2074
- type: NgModule,
2075
- args: [{
2076
- providers: [provideHttpClient(withInterceptorsFromDi())]
2077
- }]
2078
- }], null, null);
2079
- })();
2080
-
2081
- class HttpClientJsonpModule {
2082
- static ɵfac = function HttpClientJsonpModule_Factory(__ngFactoryType__) {
2083
- return new (__ngFactoryType__ || HttpClientJsonpModule);
2084
- };
2085
- static ɵmod = /* @__PURE__ */ ɵ_defineNgModule({
2086
- type: HttpClientJsonpModule
2087
- });
2088
- static ɵinj = /* @__PURE__ */ ɵ_defineInjector({
2089
- providers: [withJsonpSupport().ɵproviders]
2090
- });
2091
- }
2092
- (() => {
2093
- (typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HttpClientJsonpModule, [{
2094
- type: NgModule,
2095
- args: [{
2096
- providers: [withJsonpSupport().ɵproviders]
2097
- }]
2098
- }], null, null);
2099
- })();
2100
-
2101
- // node_modules/@angular/common/fesm2022/http.mjs
2102
- var exports_http = {};
2103
- __export(exports_http, {
2104
- ɵwithHttpTransferCache: () => withHttpTransferCache,
2105
- ɵREQUESTS_CONTRIBUTE_TO_STABILITY: () => REQUESTS_CONTRIBUTE_TO_STABILITY,
2106
- ɵHttpInterceptingHandler: () => HttpInterceptorHandler,
2107
- ɵHTTP_ROOT_INTERCEPTOR_FNS: () => HTTP_ROOT_INTERCEPTOR_FNS,
2108
- withXsrfConfiguration: () => withXsrfConfiguration,
2109
- withRequestsMadeViaParent: () => withRequestsMadeViaParent,
2110
- withNoXsrfProtection: () => withNoXsrfProtection,
2111
- withJsonpSupport: () => withJsonpSupport,
2112
- withInterceptorsFromDi: () => withInterceptorsFromDi,
2113
- withInterceptors: () => withInterceptors,
2114
- withFetch: () => withFetch,
2115
- provideHttpClient: () => provideHttpClient,
2116
- httpResource: () => httpResource,
2117
- JsonpInterceptor: () => JsonpInterceptor,
2118
- JsonpClientBackend: () => JsonpClientBackend,
2119
- HttpXsrfTokenExtractor: () => HttpXsrfTokenExtractor,
2120
- HttpXhrBackend: () => HttpXhrBackend,
2121
- HttpUrlEncodingCodec: () => HttpUrlEncodingCodec,
2122
- HttpStatusCode: () => HttpStatusCode,
2123
- HttpResponseBase: () => HttpResponseBase,
2124
- HttpResponse: () => HttpResponse,
2125
- HttpRequest: () => HttpRequest,
2126
- HttpParams: () => HttpParams,
2127
- HttpHeaders: () => HttpHeaders,
2128
- HttpHeaderResponse: () => HttpHeaderResponse,
2129
- HttpHandler: () => HttpHandler,
2130
- HttpFeatureKind: () => HttpFeatureKind,
2131
- HttpEventType: () => HttpEventType,
2132
- HttpErrorResponse: () => HttpErrorResponse,
2133
- HttpContextToken: () => HttpContextToken,
2134
- HttpContext: () => HttpContext,
2135
- HttpClientXsrfModule: () => HttpClientXsrfModule,
2136
- HttpClientModule: () => HttpClientModule,
2137
- HttpClientJsonpModule: () => HttpClientJsonpModule,
2138
- HttpClient: () => HttpClient,
2139
- HttpBackend: () => HttpBackend,
2140
- HTTP_TRANSFER_CACHE_ORIGIN_MAP: () => HTTP_TRANSFER_CACHE_ORIGIN_MAP,
2141
- HTTP_INTERCEPTORS: () => HTTP_INTERCEPTORS,
2142
- FetchBackend: () => FetchBackend
2143
- });
2144
- var HTTP_TRANSFER_CACHE_ORIGIN_MAP = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "HTTP_TRANSFER_CACHE_ORIGIN_MAP" : "");
2145
- var BODY = "b";
2146
- var HEADERS = "h";
2147
- var STATUS = "s";
2148
- var STATUS_TEXT = "st";
2149
- var REQ_URL = "u";
2150
- var RESPONSE_TYPE = "rt";
2151
- var CACHE_OPTIONS = new InjectionToken(typeof ngDevMode !== "undefined" && ngDevMode ? "HTTP_TRANSFER_STATE_CACHE_OPTIONS" : "");
2152
- var ALLOWED_METHODS = ["GET", "HEAD"];
2153
- function shouldCacheRequest(req, options) {
2154
- const {
2155
- isCacheActive,
2156
- ...globalOptions
2157
- } = options;
2158
- const {
2159
- transferCache: requestOptions,
2160
- method: requestMethod
2161
- } = req;
2162
- if (!isCacheActive || requestOptions === false || requestMethod === "POST" && !globalOptions.includePostRequests && !requestOptions || requestMethod !== "POST" && !ALLOWED_METHODS.includes(requestMethod) || !globalOptions.includeRequestsWithAuthHeaders && hasAuthHeaders(req) || globalOptions.filter?.(req) === false) {
2163
- return false;
2164
- }
2165
- return true;
2166
- }
2167
- function getHeadersToInclude(options, requestOptions) {
2168
- const {
2169
- includeHeaders: globalHeaders
2170
- } = options;
2171
- let headersToInclude = globalHeaders;
2172
- if (typeof requestOptions === "object" && requestOptions.includeHeaders) {
2173
- headersToInclude = requestOptions.includeHeaders;
2174
- }
2175
- return headersToInclude;
2176
- }
2177
- function retrieveStateFromCache(req, options, transferState, originMap) {
2178
- const {
2179
- transferCache: requestOptions
2180
- } = req;
2181
- if (!shouldCacheRequest(req, options)) {
2182
- return null;
2183
- }
2184
- if (typeof ngServerMode !== "undefined" && !ngServerMode && originMap) {
2185
- 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.");
2186
- }
2187
- const requestUrl = typeof ngServerMode !== "undefined" && ngServerMode && originMap ? mapRequestOriginUrl(req.url, originMap) : req.url;
2188
- const storeKey = makeCacheKey(req, requestUrl);
2189
- const response = transferState.get(storeKey, null);
2190
- const headersToInclude = getHeadersToInclude(options, requestOptions);
2191
- if (response) {
2192
- const {
2193
- [BODY]: undecodedBody,
2194
- [RESPONSE_TYPE]: responseType,
2195
- [HEADERS]: httpHeaders,
2196
- [STATUS]: status,
2197
- [STATUS_TEXT]: statusText,
2198
- [REQ_URL]: url
2199
- } = response;
2200
- let body = undecodedBody;
2201
- switch (responseType) {
2202
- case "arraybuffer":
2203
- body = fromBase64(undecodedBody);
2204
- break;
2205
- case "blob":
2206
- body = new Blob([fromBase64(undecodedBody)]);
2207
- break;
2208
- }
2209
- let headers = new HttpHeaders(httpHeaders);
2210
- if (typeof ngDevMode === "undefined" || ngDevMode) {
2211
- headers = appendMissingHeadersDetection(req.url, headers, headersToInclude ?? []);
2212
- }
2213
- return new HttpResponse({
2214
- body,
2215
- headers,
2216
- status,
2217
- statusText,
2218
- url
2219
- });
2220
- }
2221
- return null;
2222
- }
2223
- function transferCacheInterceptorFn(req, next) {
2224
- const options = inject(CACHE_OPTIONS);
2225
- const transferState = inject(TransferState);
2226
- const originMap = inject(HTTP_TRANSFER_CACHE_ORIGIN_MAP, {
2227
- optional: true
2228
- });
2229
- const cachedResponse = retrieveStateFromCache(req, options, transferState, originMap);
2230
- if (cachedResponse) {
2231
- return of(cachedResponse);
2232
- }
2233
- const {
2234
- transferCache: requestOptions
2235
- } = req;
2236
- const headersToInclude = getHeadersToInclude(options, requestOptions);
2237
- const requestUrl = typeof ngServerMode !== "undefined" && ngServerMode && originMap ? mapRequestOriginUrl(req.url, originMap) : req.url;
2238
- const storeKey = makeCacheKey(req, requestUrl);
2239
- if (!shouldCacheRequest(req, options)) {
2240
- return next(req);
2241
- }
2242
- const event$ = next(req);
2243
- if (typeof ngServerMode !== "undefined" && ngServerMode) {
2244
- return event$.pipe(tap((event) => {
2245
- if (event instanceof HttpResponse) {
2246
- transferState.set(storeKey, {
2247
- [BODY]: req.responseType === "arraybuffer" || req.responseType === "blob" ? toBase64(event.body) : event.body,
2248
- [HEADERS]: getFilteredHeaders(event.headers, headersToInclude),
2249
- [STATUS]: event.status,
2250
- [STATUS_TEXT]: event.statusText,
2251
- [REQ_URL]: requestUrl,
2252
- [RESPONSE_TYPE]: req.responseType
2253
- });
2254
- }
2255
- }));
2256
- }
2257
- return event$;
2258
- }
2259
- function hasAuthHeaders(req) {
2260
- return req.headers.has("authorization") || req.headers.has("proxy-authorization");
2261
- }
2262
- function getFilteredHeaders(headers, includeHeaders) {
2263
- if (!includeHeaders) {
2264
- return {};
2265
- }
2266
- const headersMap = {};
2267
- for (const key of includeHeaders) {
2268
- const values = headers.getAll(key);
2269
- if (values !== null) {
2270
- headersMap[key] = values;
2271
- }
2272
- }
2273
- return headersMap;
2274
- }
2275
- function sortAndConcatParams(params) {
2276
- return [...params.keys()].sort().map((k) => `${k}=${params.getAll(k)}`).join("&");
2277
- }
2278
- function makeCacheKey(request, mappedRequestUrl) {
2279
- const {
2280
- params,
2281
- method,
2282
- responseType
2283
- } = request;
2284
- const encodedParams = sortAndConcatParams(params);
2285
- let serializedBody = request.serializeBody();
2286
- if (serializedBody instanceof URLSearchParams) {
2287
- serializedBody = sortAndConcatParams(serializedBody);
2288
- } else if (typeof serializedBody !== "string") {
2289
- serializedBody = "";
2290
- }
2291
- const key = [method, responseType, mappedRequestUrl, serializedBody, encodedParams].join("|");
2292
- const hash = generateHash(key);
2293
- return makeStateKey(hash);
2294
- }
2295
- function generateHash(value) {
2296
- let hash = 0;
2297
- for (const char of value) {
2298
- hash = Math.imul(31, hash) + char.charCodeAt(0) << 0;
2299
- }
2300
- hash += 2147483647 + 1;
2301
- return hash.toString();
2302
- }
2303
- function toBase64(buffer) {
2304
- const bytes = new Uint8Array(buffer);
2305
- const CHUNK_SIZE = 32768;
2306
- let binaryString = "";
2307
- for (let i = 0;i < bytes.length; i += CHUNK_SIZE) {
2308
- const chunk = bytes.subarray(i, i + CHUNK_SIZE);
2309
- binaryString += String.fromCharCode.apply(null, chunk);
2310
- }
2311
- return btoa(binaryString);
2312
- }
2313
- function fromBase64(base64) {
2314
- const binary = atob(base64);
2315
- const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
2316
- return bytes.buffer;
2317
- }
2318
- function withHttpTransferCache(cacheOptions) {
2319
- return [{
2320
- provide: CACHE_OPTIONS,
2321
- useFactory: () => {
2322
- performanceMarkFeature("NgHttpTransferCache");
2323
- return {
2324
- isCacheActive: true,
2325
- ...cacheOptions
2326
- };
2327
- }
2328
- }, {
2329
- provide: HTTP_ROOT_INTERCEPTOR_FNS,
2330
- useValue: transferCacheInterceptorFn,
2331
- multi: true
2332
- }, {
2333
- provide: APP_BOOTSTRAP_LISTENER,
2334
- multi: true,
2335
- useFactory: () => {
2336
- const appRef = inject(ApplicationRef);
2337
- const cacheState = inject(CACHE_OPTIONS);
2338
- return () => {
2339
- appRef.whenStable().then(() => {
2340
- cacheState.isCacheActive = false;
2341
- });
2342
- };
2343
- }
2344
- }];
2345
- }
2346
- function appendMissingHeadersDetection(url, headers, headersToInclude) {
2347
- const warningProduced = new Set;
2348
- return new Proxy(headers, {
2349
- get(target, prop) {
2350
- const value = Reflect.get(target, prop);
2351
- const methods = new Set(["get", "has", "getAll"]);
2352
- if (typeof value !== "function" || !methods.has(prop)) {
2353
- return value;
2354
- }
2355
- return (headerName) => {
2356
- const key = (prop + ":" + headerName).toLowerCase();
2357
- if (!headersToInclude.includes(headerName) && !warningProduced.has(key)) {
2358
- warningProduced.add(key);
2359
- const truncatedUrl = truncateMiddle(url);
2360
- console.warn(formatRuntimeError(-2802, `Angular detected that the \`${headerName}\` header is accessed, but the value of the header ` + `was not transferred from the server to the client by the HttpTransferCache. ` + `To include the value of the \`${headerName}\` header for the \`${truncatedUrl}\` request, ` + `use the \`includeHeaders\` list. The \`includeHeaders\` can be defined either ` + `on a request level by adding the \`transferCache\` parameter, or on an application ` + `level by adding the \`httpCacheTransfer.includeHeaders\` argument to the ` + `\`provideClientHydration()\` call. `));
2361
- }
2362
- return value.apply(target, [headerName]);
2363
- };
2364
- }
2365
- });
2366
- }
2367
- function mapRequestOriginUrl(url, originMap) {
2368
- const origin = new URL(url, "resolve://").origin;
2369
- const mappedOrigin = originMap[origin];
2370
- if (!mappedOrigin) {
2371
- return url;
2372
- }
2373
- if (typeof ngDevMode === "undefined" || ngDevMode) {
2374
- verifyMappedOrigin(mappedOrigin);
2375
- }
2376
- return url.replace(origin, mappedOrigin);
2377
- }
2378
- function verifyMappedOrigin(url) {
2379
- if (new URL(url, "resolve://").pathname !== "/") {
2380
- throw new RuntimeError(2804, "Angular detected a URL with a path segment in the value provided for the " + `\`HTTP_TRANSFER_CACHE_ORIGIN_MAP\` token: ${url}. The map should only contain origins ` + "without any other segments.");
2381
- }
2382
- }
2383
- var httpResource = (() => {
2384
- const jsonFn = makeHttpResourceFn("json");
2385
- jsonFn.arrayBuffer = makeHttpResourceFn("arraybuffer");
2386
- jsonFn.blob = makeHttpResourceFn("blob");
2387
- jsonFn.text = makeHttpResourceFn("text");
2388
- return jsonFn;
2389
- })();
2390
- function makeHttpResourceFn(responseType) {
2391
- return function httpResource2(request, options) {
2392
- if (ngDevMode && !options?.injector) {
2393
- assertInInjectionContext(httpResource2);
2394
- }
2395
- const injector = options?.injector ?? inject(Injector);
2396
- const cacheOptions = injector.get(CACHE_OPTIONS, null, {
2397
- optional: true
2398
- });
2399
- const transferState = injector.get(TransferState, null, {
2400
- optional: true
2401
- });
2402
- const originMap = injector.get(HTTP_TRANSFER_CACHE_ORIGIN_MAP, null, {
2403
- optional: true
2404
- });
2405
- const getInitialStream = (req) => {
2406
- if (cacheOptions && transferState && req) {
2407
- const cachedResponse = retrieveStateFromCache(req, cacheOptions, transferState, originMap);
2408
- if (cachedResponse) {
2409
- try {
2410
- const body = cachedResponse.body;
2411
- const parsed = options?.parse ? options.parse(body) : body;
2412
- return signal({
2413
- value: parsed
2414
- });
2415
- } catch (e) {
2416
- if (typeof ngDevMode === "undefined" || ngDevMode) {
2417
- 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);
2418
- }
2419
- }
2420
- }
2421
- }
2422
- return;
2423
- };
2424
- return new HttpResourceImpl(injector, () => normalizeRequest(request, responseType), options?.defaultValue, options?.debugName, options?.parse, options?.equal, getInitialStream);
2425
- };
2426
- }
2427
- function normalizeRequest(request, responseType) {
2428
- let unwrappedRequest = typeof request === "function" ? request() : request;
2429
- if (unwrappedRequest === undefined) {
2430
- return;
2431
- } else if (typeof unwrappedRequest === "string") {
2432
- unwrappedRequest = {
2433
- url: unwrappedRequest
2434
- };
2435
- }
2436
- const headers = unwrappedRequest.headers instanceof HttpHeaders ? unwrappedRequest.headers : new HttpHeaders(unwrappedRequest.headers);
2437
- const params = unwrappedRequest.params instanceof HttpParams ? unwrappedRequest.params : new HttpParams({
2438
- fromObject: unwrappedRequest.params
2439
- });
2440
- return new HttpRequest(unwrappedRequest.method ?? "GET", unwrappedRequest.url, unwrappedRequest.body ?? null, {
2441
- headers,
2442
- params,
2443
- reportProgress: unwrappedRequest.reportProgress,
2444
- withCredentials: unwrappedRequest.withCredentials,
2445
- keepalive: unwrappedRequest.keepalive,
2446
- cache: unwrappedRequest.cache,
2447
- priority: unwrappedRequest.priority,
2448
- mode: unwrappedRequest.mode,
2449
- redirect: unwrappedRequest.redirect,
2450
- responseType,
2451
- context: unwrappedRequest.context,
2452
- transferCache: unwrappedRequest.transferCache,
2453
- credentials: unwrappedRequest.credentials,
2454
- referrer: unwrappedRequest.referrer,
2455
- referrerPolicy: unwrappedRequest.referrerPolicy,
2456
- integrity: unwrappedRequest.integrity,
2457
- timeout: unwrappedRequest.timeout
2458
- });
2459
- }
2460
-
2461
- class HttpResourceImpl extends ResourceImpl {
2462
- client;
2463
- _headers = linkedSignal({
2464
- ...ngDevMode ? {
2465
- debugName: "_headers"
2466
- } : {},
2467
- source: this.extRequest,
2468
- computation: () => {
2469
- return;
2470
- }
2471
- });
2472
- _progress = linkedSignal({
2473
- ...ngDevMode ? {
2474
- debugName: "_progress"
2475
- } : {},
2476
- source: this.extRequest,
2477
- computation: () => {
2478
- return;
2479
- }
2480
- });
2481
- _statusCode = linkedSignal({
2482
- ...ngDevMode ? {
2483
- debugName: "_statusCode"
2484
- } : {},
2485
- source: this.extRequest,
2486
- computation: () => {
2487
- return;
2488
- }
2489
- });
2490
- headers = computed(() => this.status() === "resolved" || this.status() === "error" ? this._headers() : undefined, ...ngDevMode ? [{
2491
- debugName: "headers"
2492
- }] : []);
2493
- progress = this._progress.asReadonly();
2494
- statusCode = this._statusCode.asReadonly();
2495
- constructor(injector, request, defaultValue, debugName, parse, equal, getInitialStream) {
2496
- super(request, ({
2497
- params: request2,
2498
- abortSignal
2499
- }) => {
2500
- let sub;
2501
- const onAbort = () => sub.unsubscribe();
2502
- abortSignal.addEventListener("abort", onAbort);
2503
- const stream = signal({
2504
- value: undefined
2505
- }, ...ngDevMode ? [{
2506
- debugName: "stream"
2507
- }] : []);
2508
- let resolve;
2509
- const promise = new Promise((r) => resolve = r);
2510
- const send = (value) => {
2511
- stream.set(value);
2512
- resolve?.(stream);
2513
- resolve = undefined;
2514
- };
2515
- sub = this.client.request(request2).subscribe({
2516
- next: (event) => {
2517
- switch (event.type) {
2518
- case HttpEventType.Response:
2519
- this._headers.set(event.headers);
2520
- this._statusCode.set(event.status);
2521
- try {
2522
- send({
2523
- value: parse ? parse(event.body) : event.body
2524
- });
2525
- } catch (error) {
2526
- send({
2527
- error: encapsulateResourceError(error)
2528
- });
2529
- }
2530
- break;
2531
- case HttpEventType.DownloadProgress:
2532
- this._progress.set(event);
2533
- break;
2534
- }
2535
- },
2536
- error: (error) => {
2537
- if (error instanceof HttpErrorResponse) {
2538
- this._headers.set(error.headers);
2539
- this._statusCode.set(error.status);
2540
- }
2541
- send({
2542
- error
2543
- });
2544
- abortSignal.removeEventListener("abort", onAbort);
2545
- },
2546
- complete: () => {
2547
- if (resolve) {
2548
- send({
2549
- error: new RuntimeError(991, ngDevMode && "Resource completed before producing a value")
2550
- });
2551
- }
2552
- abortSignal.removeEventListener("abort", onAbort);
2553
- }
2554
- });
2555
- return promise;
2556
- }, defaultValue, equal, debugName, injector, getInitialStream);
2557
- this.client = injector.get(HttpClient);
2558
- }
2559
- set(value) {
2560
- super.set(value);
2561
- this._headers.set(undefined);
2562
- this._progress.set(undefined);
2563
- this._statusCode.set(undefined);
2564
- }
2565
- }
2566
-
2567
- export { HttpHeaders, HttpContextToken, HttpContext, HttpUrlEncodingCodec, HttpParams, HttpRequest, HttpEventType, HttpResponseBase, HttpHeaderResponse, HttpResponse, HttpErrorResponse, HttpStatusCode, FetchBackend, HttpXhrBackend, HTTP_INTERCEPTORS, HttpBackend, HttpHandler, HttpClient, JsonpClientBackend, JsonpInterceptor, HttpXsrfTokenExtractor, HttpFeatureKind, provideHttpClient, withInterceptors, withInterceptorsFromDi, withXsrfConfiguration, withNoXsrfProtection, withJsonpSupport, withRequestsMadeViaParent, withFetch, HttpClientXsrfModule, HttpClientModule, HttpClientJsonpModule, HTTP_TRANSFER_CACHE_ORIGIN_MAP, withHttpTransferCache, httpResource, exports_http };