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