@alterior/http 3.13.3 → 3.13.4

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 (156) hide show
  1. package/dist/backend.d.ts +38 -38
  2. package/dist/backend.js +38 -38
  3. package/dist/client.d.ts +2108 -2108
  4. package/dist/client.js +265 -265
  5. package/dist/client.js.map +1 -1
  6. package/dist/headers.d.ts +57 -57
  7. package/dist/headers.js +187 -187
  8. package/dist/headers.js.map +1 -1
  9. package/dist/index.d.ts +18 -18
  10. package/dist/index.js +42 -42
  11. package/dist/interceptor.d.ts +63 -63
  12. package/dist/interceptor.js +43 -43
  13. package/dist/interceptor.js.map +1 -1
  14. package/dist/module.d.ts +101 -101
  15. package/dist/module.js +188 -188
  16. package/dist/module.js.map +1 -1
  17. package/dist/params.d.ts +98 -98
  18. package/dist/params.js +184 -184
  19. package/dist/params.js.map +1 -1
  20. package/dist/request.d.ts +130 -130
  21. package/dist/request.js +260 -260
  22. package/dist/request.js.map +1 -1
  23. package/dist/response.d.ts +267 -267
  24. package/dist/response.js +165 -165
  25. package/dist/response.js.map +1 -1
  26. package/dist/server.d.ts +28 -28
  27. package/dist/server.js +119 -119
  28. package/dist/server.js.map +1 -1
  29. package/dist/test/client.test.d.ts +8 -8
  30. package/dist/test/client.test.js +163 -163
  31. package/dist/test/client.test.js.map +1 -1
  32. package/dist/test/headers.test.d.ts +1 -1
  33. package/dist/test/headers.test.js +126 -126
  34. package/dist/test/module.test.d.ts +1 -1
  35. package/dist/test/module.test.js +117 -117
  36. package/dist/test/module.test.js.map +1 -1
  37. package/dist/test/params.test.d.ts +1 -1
  38. package/dist/test/params.test.js +63 -63
  39. package/dist/test/request.test.d.ts +8 -8
  40. package/dist/test/request.test.js +159 -159
  41. package/dist/test/request.test.js.map +1 -1
  42. package/dist/test/response.test.d.ts +1 -1
  43. package/dist/test/response.test.js +79 -79
  44. package/dist/test/response.test.js.map +1 -1
  45. package/dist/test/test.d.ts +1 -1
  46. package/dist/test/test.js +16 -16
  47. package/dist/test/xhr.mock.d.ts +48 -48
  48. package/dist/test/xhr.mock.js +94 -94
  49. package/dist/test/xhr.mock.js.map +1 -1
  50. package/dist/test/xhr.test.d.ts +1 -1
  51. package/dist/test/xhr.test.js +344 -344
  52. package/dist/test/xhr.test.js.map +1 -1
  53. package/dist/test/xsrf.test.d.ts +1 -1
  54. package/dist/test/xsrf.test.js +63 -63
  55. package/dist/test/xsrf.test.js.map +1 -1
  56. package/dist/testing/api.d.ts +102 -102
  57. package/dist/testing/api.js +19 -19
  58. package/dist/testing/backend.d.ts +63 -63
  59. package/dist/testing/backend.js +141 -141
  60. package/dist/testing/backend.js.map +1 -1
  61. package/dist/testing/index.d.ts +10 -10
  62. package/dist/testing/index.js +16 -16
  63. package/dist/testing/module.d.ts +16 -16
  64. package/dist/testing/module.js +38 -38
  65. package/dist/testing/module.js.map +1 -1
  66. package/dist/testing/request.d.ts +56 -56
  67. package/dist/testing/request.js +177 -177
  68. package/dist/testing/request.js.map +1 -1
  69. package/dist/testing/request.test.d.ts +8 -8
  70. package/dist/testing/request.test.js +24 -24
  71. package/dist/xhr.d.ts +42 -42
  72. package/dist/xhr.js +298 -298
  73. package/dist/xhr.js.map +1 -1
  74. package/dist/xsrf.d.ts +37 -37
  75. package/dist/xsrf.js +55 -55
  76. package/dist/xsrf.js.map +1 -1
  77. package/dist.esm/backend.d.ts +38 -38
  78. package/dist.esm/backend.js +33 -33
  79. package/dist.esm/client.d.ts +2108 -2108
  80. package/dist.esm/client.js +262 -262
  81. package/dist.esm/client.js.map +1 -1
  82. package/dist.esm/headers.d.ts +57 -57
  83. package/dist.esm/headers.js +183 -183
  84. package/dist.esm/headers.js.map +1 -1
  85. package/dist.esm/index.d.ts +18 -18
  86. package/dist.esm/index.js +18 -18
  87. package/dist.esm/interceptor.d.ts +63 -63
  88. package/dist.esm/interceptor.js +39 -39
  89. package/dist.esm/interceptor.js.map +1 -1
  90. package/dist.esm/module.d.ts +101 -101
  91. package/dist.esm/module.js +183 -183
  92. package/dist.esm/module.js.map +1 -1
  93. package/dist.esm/params.d.ts +98 -98
  94. package/dist.esm/params.js +179 -179
  95. package/dist.esm/params.js.map +1 -1
  96. package/dist.esm/request.d.ts +130 -130
  97. package/dist.esm/request.js +256 -256
  98. package/dist.esm/request.js.map +1 -1
  99. package/dist.esm/response.d.ts +267 -267
  100. package/dist.esm/response.js +158 -158
  101. package/dist.esm/response.js.map +1 -1
  102. package/dist.esm/server.d.ts +28 -28
  103. package/dist.esm/server.js +113 -113
  104. package/dist.esm/server.js.map +1 -1
  105. package/dist.esm/test/client.test.d.ts +8 -8
  106. package/dist.esm/test/client.test.js +161 -161
  107. package/dist.esm/test/client.test.js.map +1 -1
  108. package/dist.esm/test/headers.test.d.ts +1 -1
  109. package/dist.esm/test/headers.test.js +124 -124
  110. package/dist.esm/test/module.test.d.ts +1 -1
  111. package/dist.esm/test/module.test.js +115 -115
  112. package/dist.esm/test/module.test.js.map +1 -1
  113. package/dist.esm/test/params.test.d.ts +1 -1
  114. package/dist.esm/test/params.test.js +61 -61
  115. package/dist.esm/test/request.test.d.ts +8 -8
  116. package/dist.esm/test/request.test.js +157 -157
  117. package/dist.esm/test/request.test.js.map +1 -1
  118. package/dist.esm/test/response.test.d.ts +1 -1
  119. package/dist.esm/test/response.test.js +77 -77
  120. package/dist.esm/test/response.test.js.map +1 -1
  121. package/dist.esm/test/test.d.ts +1 -1
  122. package/dist.esm/test/test.js +14 -14
  123. package/dist.esm/test/xhr.mock.d.ts +48 -48
  124. package/dist.esm/test/xhr.mock.js +88 -88
  125. package/dist.esm/test/xhr.mock.js.map +1 -1
  126. package/dist.esm/test/xhr.test.d.ts +1 -1
  127. package/dist.esm/test/xhr.test.js +342 -342
  128. package/dist.esm/test/xhr.test.js.map +1 -1
  129. package/dist.esm/test/xsrf.test.d.ts +1 -1
  130. package/dist.esm/test/xsrf.test.js +61 -61
  131. package/dist.esm/test/xsrf.test.js.map +1 -1
  132. package/dist.esm/testing/api.d.ts +102 -102
  133. package/dist.esm/testing/api.js +15 -15
  134. package/dist.esm/testing/backend.d.ts +63 -63
  135. package/dist.esm/testing/backend.js +138 -138
  136. package/dist.esm/testing/backend.js.map +1 -1
  137. package/dist.esm/testing/index.d.ts +10 -10
  138. package/dist.esm/testing/index.js +10 -10
  139. package/dist.esm/testing/module.d.ts +16 -16
  140. package/dist.esm/testing/module.js +35 -35
  141. package/dist.esm/testing/module.js.map +1 -1
  142. package/dist.esm/testing/request.d.ts +56 -56
  143. package/dist.esm/testing/request.js +173 -173
  144. package/dist.esm/testing/request.js.map +1 -1
  145. package/dist.esm/testing/request.test.d.ts +8 -8
  146. package/dist.esm/testing/request.test.js +22 -22
  147. package/dist.esm/xhr.d.ts +42 -42
  148. package/dist.esm/xhr.js +294 -294
  149. package/dist.esm/xhr.js.map +1 -1
  150. package/dist.esm/xsrf.d.ts +37 -37
  151. package/dist.esm/xsrf.js +51 -51
  152. package/dist.esm/xsrf.js.map +1 -1
  153. package/package.json +9 -9
  154. package/tsconfig.esm.tsbuildinfo +1 -0
  155. package/tsconfig.json +0 -2
  156. package/tsconfig.tsbuildinfo +1 -8046
package/dist/response.js CHANGED
@@ -1,166 +1,166 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google Inc. All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.HttpErrorResponse = exports.HttpResponse = exports.HttpHeaderResponse = exports.HttpResponseBase = exports.HttpEventType = void 0;
11
- const headers_1 = require("./headers");
12
- /**
13
- * Type enumeration for the different kinds of `HttpEvent`.
14
- *
15
- *
16
- */
17
- var HttpEventType;
18
- (function (HttpEventType) {
19
- /**
20
- * The request was sent out over the wire.
21
- */
22
- HttpEventType[HttpEventType["Sent"] = 0] = "Sent";
23
- /**
24
- * An upload progress event was received.
25
- */
26
- HttpEventType[HttpEventType["UploadProgress"] = 1] = "UploadProgress";
27
- /**
28
- * The response status code and headers were received.
29
- */
30
- HttpEventType[HttpEventType["ResponseHeader"] = 2] = "ResponseHeader";
31
- /**
32
- * A download progress event was received.
33
- */
34
- HttpEventType[HttpEventType["DownloadProgress"] = 3] = "DownloadProgress";
35
- /**
36
- * The full response including the body was received.
37
- */
38
- HttpEventType[HttpEventType["Response"] = 4] = "Response";
39
- /**
40
- * A custom event from an interceptor or a backend.
41
- */
42
- HttpEventType[HttpEventType["User"] = 5] = "User";
43
- })(HttpEventType = exports.HttpEventType || (exports.HttpEventType = {}));
44
- /**
45
- * Base class for both `HttpResponse` and `HttpHeaderResponse`.
46
- *
47
- *
48
- */
49
- class HttpResponseBase {
50
- /**
51
- * Super-constructor for all responses.
52
- *
53
- * The single parameter accepted is an initialization hash. Any properties
54
- * of the response passed there will override the default values.
55
- */
56
- constructor(init, defaultStatus = 200, defaultStatusText = 'OK') {
57
- // If the hash has values passed, use them to initialize the response.
58
- // Otherwise use the default values.
59
- this.headers = init.headers || new headers_1.HttpHeaders();
60
- this.status = init.status !== undefined ? init.status : defaultStatus;
61
- this.statusText = init.statusText || defaultStatusText;
62
- this.url = init.url || null;
63
- // Cache the ok value to avoid defining a getter.
64
- this.ok = this.status >= 200 && this.status < 300;
65
- }
66
- }
67
- exports.HttpResponseBase = HttpResponseBase;
68
- /**
69
- * A partial HTTP response which only includes the status and header data,
70
- * but no response body.
71
- *
72
- * `HttpHeaderResponse` is a `HttpEvent` available on the response
73
- * event stream, only when progress events are requested.
74
- *
75
- *
76
- */
77
- class HttpHeaderResponse extends HttpResponseBase {
78
- /**
79
- * Create a new `HttpHeaderResponse` with the given parameters.
80
- */
81
- constructor(init = {}) {
82
- super(init);
83
- this.type = HttpEventType.ResponseHeader;
84
- }
85
- /**
86
- * Copy this `HttpHeaderResponse`, overriding its contents with the
87
- * given parameter hash.
88
- */
89
- clone(update = {}) {
90
- // Perform a straightforward initialization of the new HttpHeaderResponse,
91
- // overriding the current parameters with new ones if given.
92
- return new HttpHeaderResponse({
93
- headers: update.headers || this.headers,
94
- status: update.status !== undefined ? update.status : this.status,
95
- statusText: update.statusText || this.statusText,
96
- url: update.url || this.url || undefined,
97
- });
98
- }
99
- }
100
- exports.HttpHeaderResponse = HttpHeaderResponse;
101
- /**
102
- * A full HTTP response, including a typed response body (which may be `null`
103
- * if one was not returned).
104
- *
105
- * `HttpResponse` is a `HttpEvent` available on the response event
106
- * stream.
107
- *
108
- *
109
- */
110
- class HttpResponse extends HttpResponseBase {
111
- /**
112
- * Construct a new `HttpResponse`.
113
- */
114
- constructor(init = {}) {
115
- super(init);
116
- this.type = HttpEventType.Response;
117
- this.body = init.body !== undefined ? init.body : null;
118
- }
119
- clone(update = {}) {
120
- return new HttpResponse({
121
- body: (update.body !== undefined) ? update.body : this.body,
122
- headers: update.headers || this.headers,
123
- status: (update.status !== undefined) ? update.status : this.status,
124
- statusText: update.statusText || this.statusText,
125
- url: update.url || this.url || undefined,
126
- });
127
- }
128
- }
129
- exports.HttpResponse = HttpResponse;
130
- /**
131
- * A response that represents an error or failure, either from a
132
- * non-successful HTTP status, an error while executing the request,
133
- * or some other failure which occurred during the parsing of the response.
134
- *
135
- * Any error returned on the `Observable` response stream will be
136
- * wrapped in an `HttpErrorResponse` to provide additional context about
137
- * the state of the HTTP layer when the error occurred. The error property
138
- * will contain either a wrapped Error object or the error response returned
139
- * from the server.
140
- *
141
- *
142
- */
143
- class HttpErrorResponse extends HttpResponseBase {
144
- constructor(init) {
145
- // Initialize with a default status of 0 / Unknown Error.
146
- super(init, 0, 'Unknown Error');
147
- this.name = 'HttpErrorResponse';
148
- /**
149
- * Errors are never okay, even when the status code is in the 2xx success range.
150
- */
151
- this.ok = false;
152
- // If the response was successful, then this was a parse error. Otherwise, it was
153
- // a protocol-level failure of some sort. Either the request failed in transit
154
- // or the server returned an unsuccessful status code.
155
- if (this.status >= 200 && this.status < 300) {
156
- this.message = `Http failure during parsing for ${init.url || '(unknown url)'}`;
157
- }
158
- else {
159
- this.message =
160
- `Http failure response for ${init.url || '(unknown url)'}: ${init.status} ${init.statusText}`;
161
- }
162
- this.error = init.error || null;
163
- }
164
- }
165
- exports.HttpErrorResponse = HttpErrorResponse;
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google Inc. All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.HttpErrorResponse = exports.HttpResponse = exports.HttpHeaderResponse = exports.HttpResponseBase = exports.HttpEventType = void 0;
11
+ const headers_1 = require("./headers");
12
+ /**
13
+ * Type enumeration for the different kinds of `HttpEvent`.
14
+ *
15
+ *
16
+ */
17
+ var HttpEventType;
18
+ (function (HttpEventType) {
19
+ /**
20
+ * The request was sent out over the wire.
21
+ */
22
+ HttpEventType[HttpEventType["Sent"] = 0] = "Sent";
23
+ /**
24
+ * An upload progress event was received.
25
+ */
26
+ HttpEventType[HttpEventType["UploadProgress"] = 1] = "UploadProgress";
27
+ /**
28
+ * The response status code and headers were received.
29
+ */
30
+ HttpEventType[HttpEventType["ResponseHeader"] = 2] = "ResponseHeader";
31
+ /**
32
+ * A download progress event was received.
33
+ */
34
+ HttpEventType[HttpEventType["DownloadProgress"] = 3] = "DownloadProgress";
35
+ /**
36
+ * The full response including the body was received.
37
+ */
38
+ HttpEventType[HttpEventType["Response"] = 4] = "Response";
39
+ /**
40
+ * A custom event from an interceptor or a backend.
41
+ */
42
+ HttpEventType[HttpEventType["User"] = 5] = "User";
43
+ })(HttpEventType || (exports.HttpEventType = HttpEventType = {}));
44
+ /**
45
+ * Base class for both `HttpResponse` and `HttpHeaderResponse`.
46
+ *
47
+ *
48
+ */
49
+ class HttpResponseBase {
50
+ /**
51
+ * Super-constructor for all responses.
52
+ *
53
+ * The single parameter accepted is an initialization hash. Any properties
54
+ * of the response passed there will override the default values.
55
+ */
56
+ constructor(init, defaultStatus = 200, defaultStatusText = 'OK') {
57
+ // If the hash has values passed, use them to initialize the response.
58
+ // Otherwise use the default values.
59
+ this.headers = init.headers || new headers_1.HttpHeaders();
60
+ this.status = init.status !== undefined ? init.status : defaultStatus;
61
+ this.statusText = init.statusText || defaultStatusText;
62
+ this.url = init.url || null;
63
+ // Cache the ok value to avoid defining a getter.
64
+ this.ok = this.status >= 200 && this.status < 300;
65
+ }
66
+ }
67
+ exports.HttpResponseBase = HttpResponseBase;
68
+ /**
69
+ * A partial HTTP response which only includes the status and header data,
70
+ * but no response body.
71
+ *
72
+ * `HttpHeaderResponse` is a `HttpEvent` available on the response
73
+ * event stream, only when progress events are requested.
74
+ *
75
+ *
76
+ */
77
+ class HttpHeaderResponse extends HttpResponseBase {
78
+ /**
79
+ * Create a new `HttpHeaderResponse` with the given parameters.
80
+ */
81
+ constructor(init = {}) {
82
+ super(init);
83
+ this.type = HttpEventType.ResponseHeader;
84
+ }
85
+ /**
86
+ * Copy this `HttpHeaderResponse`, overriding its contents with the
87
+ * given parameter hash.
88
+ */
89
+ clone(update = {}) {
90
+ // Perform a straightforward initialization of the new HttpHeaderResponse,
91
+ // overriding the current parameters with new ones if given.
92
+ return new HttpHeaderResponse({
93
+ headers: update.headers || this.headers,
94
+ status: update.status !== undefined ? update.status : this.status,
95
+ statusText: update.statusText || this.statusText,
96
+ url: update.url || this.url || undefined,
97
+ });
98
+ }
99
+ }
100
+ exports.HttpHeaderResponse = HttpHeaderResponse;
101
+ /**
102
+ * A full HTTP response, including a typed response body (which may be `null`
103
+ * if one was not returned).
104
+ *
105
+ * `HttpResponse` is a `HttpEvent` available on the response event
106
+ * stream.
107
+ *
108
+ *
109
+ */
110
+ class HttpResponse extends HttpResponseBase {
111
+ /**
112
+ * Construct a new `HttpResponse`.
113
+ */
114
+ constructor(init = {}) {
115
+ super(init);
116
+ this.type = HttpEventType.Response;
117
+ this.body = init.body !== undefined ? init.body : null;
118
+ }
119
+ clone(update = {}) {
120
+ return new HttpResponse({
121
+ body: (update.body !== undefined) ? update.body : this.body,
122
+ headers: update.headers || this.headers,
123
+ status: (update.status !== undefined) ? update.status : this.status,
124
+ statusText: update.statusText || this.statusText,
125
+ url: update.url || this.url || undefined,
126
+ });
127
+ }
128
+ }
129
+ exports.HttpResponse = HttpResponse;
130
+ /**
131
+ * A response that represents an error or failure, either from a
132
+ * non-successful HTTP status, an error while executing the request,
133
+ * or some other failure which occurred during the parsing of the response.
134
+ *
135
+ * Any error returned on the `Observable` response stream will be
136
+ * wrapped in an `HttpErrorResponse` to provide additional context about
137
+ * the state of the HTTP layer when the error occurred. The error property
138
+ * will contain either a wrapped Error object or the error response returned
139
+ * from the server.
140
+ *
141
+ *
142
+ */
143
+ class HttpErrorResponse extends HttpResponseBase {
144
+ constructor(init) {
145
+ // Initialize with a default status of 0 / Unknown Error.
146
+ super(init, 0, 'Unknown Error');
147
+ this.name = 'HttpErrorResponse';
148
+ /**
149
+ * Errors are never okay, even when the status code is in the 2xx success range.
150
+ */
151
+ this.ok = false;
152
+ // If the response was successful, then this was a parse error. Otherwise, it was
153
+ // a protocol-level failure of some sort. Either the request failed in transit
154
+ // or the server returned an unsuccessful status code.
155
+ if (this.status >= 200 && this.status < 300) {
156
+ this.message = `Http failure during parsing for ${init.url || '(unknown url)'}`;
157
+ }
158
+ else {
159
+ this.message =
160
+ `Http failure response for ${init.url || '(unknown url)'}: ${init.status} ${init.statusText}`;
161
+ }
162
+ this.error = init.error || null;
163
+ }
164
+ }
165
+ exports.HttpErrorResponse = HttpErrorResponse;
166
166
  //# sourceMappingURL=response.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,uCAAsC;AAEtC;;;;GAIG;AACH,IAAY,aA8BX;AA9BD,WAAY,aAAa;IACvB;;OAEG;IACH,iDAAI,CAAA;IAEJ;;OAEG;IACH,qEAAc,CAAA;IAEd;;OAEG;IACH,qEAAc,C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C;QACpG,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;IAClC,CAAC;CACF;AA3BD,8CA2BC"}
package/dist/server.d.ts CHANGED
@@ -1,29 +1,29 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { Injector, Provider } from '@alterior/di';
9
- import { Observable } from 'rxjs';
10
- import { HttpEvent } from './response';
11
- import { HttpRequest } from './request';
12
- import { HttpBackend } from './backend';
13
- import { BrowserXhr } from './xhr';
14
- export declare class ServerXhr implements BrowserXhr {
15
- build(): XMLHttpRequest;
16
- }
17
- export declare abstract class ZoneMacroTaskWrapper<S, R> {
18
- wrap(request: S): Observable<R>;
19
- protected abstract delegate(request: S): Observable<R>;
20
- }
21
- export declare class ZoneClientBackend extends ZoneMacroTaskWrapper<HttpRequest<any>, HttpEvent<any>> implements HttpBackend {
22
- private backend;
23
- constructor(backend: HttpBackend);
24
- handle(request: HttpRequest<any>): Observable<HttpEvent<any>>;
25
- protected delegate(request: HttpRequest<any>): Observable<HttpEvent<any>>;
26
- }
27
- export declare function zoneWrappedInterceptingHandler(backend: HttpBackend, injector: Injector): ZoneClientBackend;
28
- export declare const SERVER_HTTP_PROVIDERS: Provider[];
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { Injector, Provider } from '@alterior/di';
9
+ import { Observable } from 'rxjs';
10
+ import { HttpEvent } from './response';
11
+ import { HttpRequest } from './request';
12
+ import { HttpBackend } from './backend';
13
+ import { BrowserXhr } from './xhr';
14
+ export declare class ServerXhr implements BrowserXhr {
15
+ build(): XMLHttpRequest;
16
+ }
17
+ export declare abstract class ZoneMacroTaskWrapper<S, R> {
18
+ wrap(request: S): Observable<R>;
19
+ protected abstract delegate(request: S): Observable<R>;
20
+ }
21
+ export declare class ZoneClientBackend extends ZoneMacroTaskWrapper<HttpRequest<any>, HttpEvent<any>> implements HttpBackend {
22
+ private backend;
23
+ constructor(backend: HttpBackend);
24
+ handle(request: HttpRequest<any>): Observable<HttpEvent<any>>;
25
+ protected delegate(request: HttpRequest<any>): Observable<HttpEvent<any>>;
26
+ }
27
+ export declare function zoneWrappedInterceptingHandler(backend: HttpBackend, injector: Injector): ZoneClientBackend;
28
+ export declare const SERVER_HTTP_PROVIDERS: Provider[];
29
29
  //# sourceMappingURL=server.d.ts.map
package/dist/server.js CHANGED
@@ -1,120 +1,120 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google Inc. All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.SERVER_HTTP_PROVIDERS = exports.zoneWrappedInterceptingHandler = exports.ZoneClientBackend = exports.ZoneMacroTaskWrapper = exports.ServerXhr = void 0;
11
- const tslib_1 = require("tslib");
12
- const xhr2 = tslib_1.__importStar(require("xhr2"));
13
- const di_1 = require("@alterior/di");
14
- const rxjs_1 = require("rxjs");
15
- const backend_1 = require("./backend");
16
- const xhr_1 = require("./xhr");
17
- const module_1 = require("./module");
18
- const isAbsoluteUrl = /^[a-zA-Z\-\+.]+:\/\//;
19
- function validateRequestUrl(url) {
20
- if (!isAbsoluteUrl.test(url)) {
21
- throw new Error(`URLs requested via Http on the server must be absolute. URL: ${url}`);
22
- }
23
- }
24
- let ServerXhr = class ServerXhr {
25
- build() { return new xhr2.XMLHttpRequest(); }
26
- };
27
- ServerXhr = tslib_1.__decorate([
28
- (0, di_1.Injectable)()
29
- ], ServerXhr);
30
- exports.ServerXhr = ServerXhr;
31
- class ZoneMacroTaskWrapper {
32
- wrap(request) {
33
- return new rxjs_1.Observable((observer) => {
34
- let task = null;
35
- let scheduled = false;
36
- let sub = null;
37
- let savedResult = null;
38
- let savedError = null;
39
- const scheduleTask = (_task) => {
40
- task = _task;
41
- scheduled = true;
42
- const delegate = this.delegate(request);
43
- sub = delegate.subscribe(res => savedResult = res, err => {
44
- if (!scheduled) {
45
- throw new Error('An http observable was completed twice. This shouldn\'t happen, please file a bug.');
46
- }
47
- savedError = err;
48
- scheduled = false;
49
- task.invoke();
50
- }, () => {
51
- if (!scheduled) {
52
- throw new Error('An http observable was completed twice. This shouldn\'t happen, please file a bug.');
53
- }
54
- scheduled = false;
55
- task.invoke();
56
- });
57
- };
58
- const cancelTask = (_task) => {
59
- if (!scheduled) {
60
- return;
61
- }
62
- scheduled = false;
63
- if (sub) {
64
- sub.unsubscribe();
65
- sub = null;
66
- }
67
- };
68
- const onComplete = () => {
69
- if (savedError !== null) {
70
- observer.error(savedError);
71
- }
72
- else {
73
- observer.next(savedResult);
74
- observer.complete();
75
- }
76
- };
77
- // MockBackend for Http is synchronous, which means that if scheduleTask is by
78
- // scheduleMacroTask, the request will hit MockBackend and the response will be
79
- // sent, causing task.invoke() to be called.
80
- const _task = Zone.current.scheduleMacroTask('ZoneMacroTaskWrapper.subscribe', onComplete, {}, () => null, cancelTask);
81
- scheduleTask(_task);
82
- return () => {
83
- if (scheduled && task) {
84
- task.zone.cancelTask(task);
85
- scheduled = false;
86
- }
87
- if (sub) {
88
- sub.unsubscribe();
89
- sub = null;
90
- }
91
- };
92
- });
93
- }
94
- }
95
- exports.ZoneMacroTaskWrapper = ZoneMacroTaskWrapper;
96
- class ZoneClientBackend extends ZoneMacroTaskWrapper {
97
- constructor(backend) {
98
- super();
99
- this.backend = backend;
100
- }
101
- handle(request) { return this.wrap(request); }
102
- delegate(request) {
103
- return this.backend.handle(request);
104
- }
105
- }
106
- exports.ZoneClientBackend = ZoneClientBackend;
107
- function zoneWrappedInterceptingHandler(backend, injector) {
108
- const realBackend = new module_1.HttpInterceptingHandler(backend, injector);
109
- return new ZoneClientBackend(realBackend);
110
- }
111
- exports.zoneWrappedInterceptingHandler = zoneWrappedInterceptingHandler;
112
- exports.SERVER_HTTP_PROVIDERS = [
113
- { provide: xhr_1.XhrFactory, useClass: ServerXhr },
114
- {
115
- provide: backend_1.HttpHandler,
116
- useFactory: zoneWrappedInterceptingHandler,
117
- deps: [backend_1.HttpBackend, di_1.Injector]
118
- }
119
- ];
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google Inc. All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SERVER_HTTP_PROVIDERS = exports.ZoneClientBackend = exports.ZoneMacroTaskWrapper = exports.ServerXhr = void 0;
11
+ exports.zoneWrappedInterceptingHandler = zoneWrappedInterceptingHandler;
12
+ const tslib_1 = require("tslib");
13
+ const xhr2 = tslib_1.__importStar(require("xhr2"));
14
+ const di_1 = require("@alterior/di");
15
+ const rxjs_1 = require("rxjs");
16
+ const backend_1 = require("./backend");
17
+ const xhr_1 = require("./xhr");
18
+ const module_1 = require("./module");
19
+ const isAbsoluteUrl = /^[a-zA-Z\-\+.]+:\/\//;
20
+ function validateRequestUrl(url) {
21
+ if (!isAbsoluteUrl.test(url)) {
22
+ throw new Error(`URLs requested via Http on the server must be absolute. URL: ${url}`);
23
+ }
24
+ }
25
+ let ServerXhr = class ServerXhr {
26
+ build() { return new xhr2.XMLHttpRequest(); }
27
+ };
28
+ exports.ServerXhr = ServerXhr;
29
+ exports.ServerXhr = ServerXhr = tslib_1.__decorate([
30
+ (0, di_1.Injectable)()
31
+ ], ServerXhr);
32
+ class ZoneMacroTaskWrapper {
33
+ wrap(request) {
34
+ return new rxjs_1.Observable((observer) => {
35
+ let task = null;
36
+ let scheduled = false;
37
+ let sub = null;
38
+ let savedResult = null;
39
+ let savedError = null;
40
+ const scheduleTask = (_task) => {
41
+ task = _task;
42
+ scheduled = true;
43
+ const delegate = this.delegate(request);
44
+ sub = delegate.subscribe(res => savedResult = res, err => {
45
+ if (!scheduled) {
46
+ throw new Error('An http observable was completed twice. This shouldn\'t happen, please file a bug.');
47
+ }
48
+ savedError = err;
49
+ scheduled = false;
50
+ task.invoke();
51
+ }, () => {
52
+ if (!scheduled) {
53
+ throw new Error('An http observable was completed twice. This shouldn\'t happen, please file a bug.');
54
+ }
55
+ scheduled = false;
56
+ task.invoke();
57
+ });
58
+ };
59
+ const cancelTask = (_task) => {
60
+ if (!scheduled) {
61
+ return;
62
+ }
63
+ scheduled = false;
64
+ if (sub) {
65
+ sub.unsubscribe();
66
+ sub = null;
67
+ }
68
+ };
69
+ const onComplete = () => {
70
+ if (savedError !== null) {
71
+ observer.error(savedError);
72
+ }
73
+ else {
74
+ observer.next(savedResult);
75
+ observer.complete();
76
+ }
77
+ };
78
+ // MockBackend for Http is synchronous, which means that if scheduleTask is by
79
+ // scheduleMacroTask, the request will hit MockBackend and the response will be
80
+ // sent, causing task.invoke() to be called.
81
+ const _task = Zone.current.scheduleMacroTask('ZoneMacroTaskWrapper.subscribe', onComplete, {}, () => null, cancelTask);
82
+ scheduleTask(_task);
83
+ return () => {
84
+ if (scheduled && task) {
85
+ task.zone.cancelTask(task);
86
+ scheduled = false;
87
+ }
88
+ if (sub) {
89
+ sub.unsubscribe();
90
+ sub = null;
91
+ }
92
+ };
93
+ });
94
+ }
95
+ }
96
+ exports.ZoneMacroTaskWrapper = ZoneMacroTaskWrapper;
97
+ class ZoneClientBackend extends ZoneMacroTaskWrapper {
98
+ constructor(backend) {
99
+ super();
100
+ this.backend = backend;
101
+ }
102
+ handle(request) { return this.wrap(request); }
103
+ delegate(request) {
104
+ return this.backend.handle(request);
105
+ }
106
+ }
107
+ exports.ZoneClientBackend = ZoneClientBackend;
108
+ function zoneWrappedInterceptingHandler(backend, injector) {
109
+ const realBackend = new module_1.HttpInterceptingHandler(backend, injector);
110
+ return new ZoneClientBackend(realBackend);
111
+ }
112
+ exports.SERVER_HTTP_PROVIDERS = [
113
+ { provide: xhr_1.XhrFactory, useClass: ServerXhr },
114
+ {
115
+ provide: backend_1.HttpHandler,
116
+ useFactory: zoneWrappedInterceptingHandler,
117
+ deps: [backend_1.HttpBackend, di_1.Injector]
118
+ }
119
+ ];
120
120
  //# sourceMappingURL=server.js.map