| 1 |
/** |
| 2 |
@license |
| 3 |
Apache License |
| 4 |
Version 2.0, January 2004 |
| 5 |
http://www.apache.org/licenses/ |
| 6 |
|
| 7 |
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
| 8 |
|
| 9 |
1. Definitions. |
| 10 |
|
| 11 |
"License" shall mean the terms and conditions for use, reproduction, |
| 12 |
and distribution as defined by Sections 1 through 9 of this document. |
| 13 |
|
| 14 |
"Licensor" shall mean the copyright owner or entity authorized by |
| 15 |
the copyright owner that is granting the License. |
| 16 |
|
| 17 |
"Legal Entity" shall mean the union of the acting entity and all |
| 18 |
other entities that control, are controlled by, or are under common |
| 19 |
control with that entity. For the purposes of this definition, |
| 20 |
"control" means (i) the power, direct or indirect, to cause the |
| 21 |
direction or management of such entity, whether by contract or |
| 22 |
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
| 23 |
outstanding shares, or (iii) beneficial ownership of such entity. |
| 24 |
|
| 25 |
"You" (or "Your") shall mean an individual or Legal Entity |
| 26 |
exercising permissions granted by this License. |
| 27 |
|
| 28 |
"Source" form shall mean the preferred form for making modifications, |
| 29 |
including but not limited to software source code, documentation |
| 30 |
source, and configuration files. |
| 31 |
|
| 32 |
"Object" form shall mean any form resulting from mechanical |
| 33 |
transformation or translation of a Source form, including but |
| 34 |
not limited to compiled object code, generated documentation, |
| 35 |
and conversions to other media types. |
| 36 |
|
| 37 |
"Work" shall mean the work of authorship, whether in Source or |
| 38 |
Object form, made available under the License, as indicated by a |
| 39 |
copyright notice that is included in or attached to the work |
| 40 |
(an example is provided in the Appendix below). |
| 41 |
|
| 42 |
"Derivative Works" shall mean any work, whether in Source or Object |
| 43 |
form, that is based on (or derived from) the Work and for which the |
| 44 |
editorial revisions, annotations, elaborations, or other modifications |
| 45 |
represent, as a whole, an original work of authorship. For the purposes |
| 46 |
of this License, Derivative Works shall not include works that remain |
| 47 |
separable from, or merely link (or bind by name) to the interfaces of, |
| 48 |
the Work and Derivative Works thereof. |
| 49 |
|
| 50 |
"Contribution" shall mean any work of authorship, including |
| 51 |
the original version of the Work and any modifications or additions |
| 52 |
to that Work or Derivative Works thereof, that is intentionally |
| 53 |
submitted to Licensor for inclusion in the Work by the copyright owner |
| 54 |
or by an individual or Legal Entity authorized to submit on behalf of |
| 55 |
the copyright owner. For the purposes of this definition, "submitted" |
| 56 |
means any form of electronic, verbal, or written communication sent |
| 57 |
to the Licensor or its representatives, including but not limited to |
| 58 |
communication on electronic mailing lists, source code control systems, |
| 59 |
and issue tracking systems that are managed by, or on behalf of, the |
| 60 |
Licensor for the purpose of discussing and improving the Work, but |
| 61 |
excluding communication that is conspicuously marked or otherwise |
| 62 |
designated in writing by the copyright owner as "Not a Contribution." |
| 63 |
|
| 64 |
"Contributor" shall mean Licensor and any individual or Legal Entity |
| 65 |
on behalf of whom a Contribution has been received by Licensor and |
| 66 |
subsequently incorporated within the Work. |
| 67 |
|
| 68 |
2. Grant of Copyright License. Subject to the terms and conditions of |
| 69 |
this License, each Contributor hereby grants to You a perpetual, |
| 70 |
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
| 71 |
copyright license to reproduce, prepare Derivative Works of, |
| 72 |
publicly display, publicly perform, sublicense, and distribute the |
| 73 |
Work and such Derivative Works in Source or Object form. |
| 74 |
|
| 75 |
3. Grant of Patent License. Subject to the terms and conditions of |
| 76 |
this License, each Contributor hereby grants to You a perpetual, |
| 77 |
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
| 78 |
(except as stated in this section) patent license to make, have made, |
| 79 |
use, offer to sell, sell, import, and otherwise transfer the Work, |
| 80 |
where such license applies only to those patent claims licensable |
| 81 |
by such Contributor that are necessarily infringed by their |
| 82 |
Contribution(s) alone or by combination of their Contribution(s) |
| 83 |
with the Work to which such Contribution(s) was submitted. If You |
| 84 |
institute patent litigation against any entity (including a |
| 85 |
cross-claim or counterclaim in a lawsuit) alleging that the Work |
| 86 |
or a Contribution incorporated within the Work constitutes direct |
| 87 |
or contributory patent infringement, then any patent licenses |
| 88 |
granted to You under this License for that Work shall terminate |
| 89 |
as of the date such litigation is filed. |
| 90 |
|
| 91 |
4. Redistribution. You may reproduce and distribute copies of the |
| 92 |
Work or Derivative Works thereof in any medium, with or without |
| 93 |
modifications, and in Source or Object form, provided that You |
| 94 |
meet the following conditions: |
| 95 |
|
| 96 |
(a) You must give any other recipients of the Work or |
| 97 |
Derivative Works a copy of this License; and |
| 98 |
|
| 99 |
(b) You must cause any modified files to carry prominent notices |
| 100 |
stating that You changed the files; and |
| 101 |
|
| 102 |
(c) You must retain, in the Source form of any Derivative Works |
| 103 |
that You distribute, all copyright, patent, trademark, and |
| 104 |
attribution notices from the Source form of the Work, |
| 105 |
excluding those notices that do not pertain to any part of |
| 106 |
the Derivative Works; and |
| 107 |
|
| 108 |
(d) If the Work includes a "NOTICE" text file as part of its |
| 109 |
distribution, then any Derivative Works that You distribute must |
| 110 |
include a readable copy of the attribution notices contained |
| 111 |
within such NOTICE file, excluding those notices that do not |
| 112 |
pertain to any part of the Derivative Works, in at least one |
| 113 |
of the following places: within a NOTICE text file distributed |
| 114 |
as part of the Derivative Works; within the Source form or |
| 115 |
documentation, if provided along with the Derivative Works; or, |
| 116 |
within a display generated by the Derivative Works, if and |
| 117 |
wherever such third-party notices normally appear. The contents |
| 118 |
of the NOTICE file are for informational purposes only and |
| 119 |
do not modify the License. You may add Your own attribution |
| 120 |
notices within Derivative Works that You distribute, alongside |
| 121 |
or as an addendum to the NOTICE text from the Work, provided |
| 122 |
that such additional attribution notices cannot be construed |
| 123 |
as modifying the License. |
| 124 |
|
| 125 |
You may add Your own copyright statement to Your modifications and |
| 126 |
may provide additional or different license terms and conditions |
| 127 |
for use, reproduction, or distribution of Your modifications, or |
| 128 |
for any such Derivative Works as a whole, provided Your use, |
| 129 |
reproduction, and distribution of the Work otherwise complies with |
| 130 |
the conditions stated in this License. |
| 131 |
|
| 132 |
5. Submission of Contributions. Unless You explicitly state otherwise, |
| 133 |
any Contribution intentionally submitted for inclusion in the Work |
| 134 |
by You to the Licensor shall be under the terms and conditions of |
| 135 |
this License, without any additional terms or conditions. |
| 136 |
Notwithstanding the above, nothing herein shall supersede or modify |
| 137 |
the terms of any separate license agreement you may have executed |
| 138 |
with Licensor regarding such Contributions. |
| 139 |
|
| 140 |
6. Trademarks. This License does not grant permission to use the trade |
| 141 |
names, trademarks, service marks, or product names of the Licensor, |
| 142 |
except as required for reasonable and customary use in describing the |
| 143 |
origin of the Work and reproducing the content of the NOTICE file. |
| 144 |
|
| 145 |
7. Disclaimer of Warranty. Unless required by applicable law or |
| 146 |
agreed to in writing, Licensor provides the Work (and each |
| 147 |
Contributor provides its Contributions) on an "AS IS" BASIS, |
| 148 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 149 |
implied, including, without limitation, any warranties or conditions |
| 150 |
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
| 151 |
PARTICULAR PURPOSE. You are solely responsible for determining the |
| 152 |
appropriateness of using or redistributing the Work and assume any |
| 153 |
risks associated with Your exercise of permissions under this License. |
| 154 |
|
| 155 |
8. Limitation of Liability. In no event and under no legal theory, |
| 156 |
whether in tort (including negligence), contract, or otherwise, |
| 157 |
unless required by applicable law (such as deliberate and grossly |
| 158 |
negligent acts) or agreed to in writing, shall any Contributor be |
| 159 |
liable to You for damages, including any direct, indirect, special, |
| 160 |
incidental, or consequential damages of any character arising as a |
| 161 |
result of this License or out of the use or inability to use the |
| 162 |
Work (including but not limited to damages for loss of goodwill, |
| 163 |
work stoppage, computer failure or malfunction, or any and all |
| 164 |
other commercial damages or losses), even if such Contributor |
| 165 |
has been advised of the possibility of such damages. |
| 166 |
|
| 167 |
9. Accepting Warranty or Additional Liability. While redistributing |
| 168 |
the Work or Derivative Works thereof, You may choose to offer, |
| 169 |
and charge a fee for, acceptance of support, warranty, indemnity, |
| 170 |
or other liability obligations and/or rights consistent with this |
| 171 |
License. However, in accepting such obligations, You may act only |
| 172 |
on Your own behalf and on Your sole responsibility, not on behalf |
| 173 |
of any other Contributor, and only if You agree to indemnify, |
| 174 |
defend, and hold each Contributor harmless for any liability |
| 175 |
incurred by, or claims asserted against, such Contributor by reason |
| 176 |
of your accepting any such warranty or additional liability. |
| 177 |
|
| 178 |
END OF TERMS AND CONDITIONS |
| 179 |
|
| 180 |
APPENDIX: How to apply the Apache License to your work. |
| 181 |
|
| 182 |
To apply the Apache License to your work, attach the following |
| 183 |
boilerplate notice, with the fields enclosed by brackets "[]" |
| 184 |
replaced with your own identifying information. (Don't include |
| 185 |
the brackets!) The text should be enclosed in the appropriate |
| 186 |
comment syntax for the file format. We also recommend that a |
| 187 |
file or class name and description of purpose be included on the |
| 188 |
same "printed page" as the copyright notice for easier |
| 189 |
identification within third-party archives. |
| 190 |
|
| 191 |
Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors |
| 192 |
|
| 193 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 194 |
you may not use this file except in compliance with the License. |
| 195 |
You may obtain a copy of the License at |
| 196 |
|
| 197 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 198 |
|
| 199 |
Unless required by applicable law or agreed to in writing, software |
| 200 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 201 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 202 |
See the License for the specific language governing permissions and |
| 203 |
limitations under the License. |
| 204 |
|
| 205 |
|
| 206 |
**/ |
| 207 |
/** |
| 208 |
@license |
| 209 |
Apache License |
| 210 |
Version 2.0, January 2004 |
| 211 |
http://www.apache.org/licenses/ |
| 212 |
|
| 213 |
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
| 214 |
|
| 215 |
1. Definitions. |
| 216 |
|
| 217 |
"License" shall mean the terms and conditions for use, reproduction, |
| 218 |
and distribution as defined by Sections 1 through 9 of this document. |
| 219 |
|
| 220 |
"Licensor" shall mean the copyright owner or entity authorized by |
| 221 |
the copyright owner that is granting the License. |
| 222 |
|
| 223 |
"Legal Entity" shall mean the union of the acting entity and all |
| 224 |
other entities that control, are controlled by, or are under common |
| 225 |
control with that entity. For the purposes of this definition, |
| 226 |
"control" means (i) the power, direct or indirect, to cause the |
| 227 |
direction or management of such entity, whether by contract or |
| 228 |
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
| 229 |
outstanding shares, or (iii) beneficial ownership of such entity. |
| 230 |
|
| 231 |
"You" (or "Your") shall mean an individual or Legal Entity |
| 232 |
exercising permissions granted by this License. |
| 233 |
|
| 234 |
"Source" form shall mean the preferred form for making modifications, |
| 235 |
including but not limited to software source code, documentation |
| 236 |
source, and configuration files. |
| 237 |
|
| 238 |
"Object" form shall mean any form resulting from mechanical |
| 239 |
transformation or translation of a Source form, including but |
| 240 |
not limited to compiled object code, generated documentation, |
| 241 |
and conversions to other media types. |
| 242 |
|
| 243 |
"Work" shall mean the work of authorship, whether in Source or |
| 244 |
Object form, made available under the License, as indicated by a |
| 245 |
copyright notice that is included in or attached to the work |
| 246 |
(an example is provided in the Appendix below). |
| 247 |
|
| 248 |
"Derivative Works" shall mean any work, whether in Source or Object |
| 249 |
form, that is based on (or derived from) the Work and for which the |
| 250 |
editorial revisions, annotations, elaborations, or other modifications |
| 251 |
represent, as a whole, an original work of authorship. For the purposes |
| 252 |
of this License, Derivative Works shall not include works that remain |
| 253 |
separable from, or merely link (or bind by name) to the interfaces of, |
| 254 |
the Work and Derivative Works thereof. |
| 255 |
|
| 256 |
"Contribution" shall mean any work of authorship, including |
| 257 |
the original version of the Work and any modifications or additions |
| 258 |
to that Work or Derivative Works thereof, that is intentionally |
| 259 |
submitted to Licensor for inclusion in the Work by the copyright owner |
| 260 |
or by an individual or Legal Entity authorized to submit on behalf of |
| 261 |
the copyright owner. For the purposes of this definition, "submitted" |
| 262 |
means any form of electronic, verbal, or written communication sent |
| 263 |
to the Licensor or its representatives, including but not limited to |
| 264 |
communication on electronic mailing lists, source code control systems, |
| 265 |
and issue tracking systems that are managed by, or on behalf of, the |
| 266 |
Licensor for the purpose of discussing and improving the Work, but |
| 267 |
excluding communication that is conspicuously marked or otherwise |
| 268 |
designated in writing by the copyright owner as "Not a Contribution." |
| 269 |
|
| 270 |
"Contributor" shall mean Licensor and any individual or Legal Entity |
| 271 |
on behalf of whom a Contribution has been received by Licensor and |
| 272 |
subsequently incorporated within the Work. |
| 273 |
|
| 274 |
2. Grant of Copyright License. Subject to the terms and conditions of |
| 275 |
this License, each Contributor hereby grants to You a perpetual, |
| 276 |
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
| 277 |
copyright license to reproduce, prepare Derivative Works of, |
| 278 |
publicly display, publicly perform, sublicense, and distribute the |
| 279 |
Work and such Derivative Works in Source or Object form. |
| 280 |
|
| 281 |
3. Grant of Patent License. Subject to the terms and conditions of |
| 282 |
this License, each Contributor hereby grants to You a perpetual, |
| 283 |
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
| 284 |
(except as stated in this section) patent license to make, have made, |
| 285 |
use, offer to sell, sell, import, and otherwise transfer the Work, |
| 286 |
where such license applies only to those patent claims licensable |
| 287 |
by such Contributor that are necessarily infringed by their |
| 288 |
Contribution(s) alone or by combination of their Contribution(s) |
| 289 |
with the Work to which such Contribution(s) was submitted. If You |
| 290 |
institute patent litigation against any entity (including a |
| 291 |
cross-claim or counterclaim in a lawsuit) alleging that the Work |
| 292 |
or a Contribution incorporated within the Work constitutes direct |
| 293 |
or contributory patent infringement, then any patent licenses |
| 294 |
granted to You under this License for that Work shall terminate |
| 295 |
as of the date such litigation is filed. |
| 296 |
|
| 297 |
4. Redistribution. You may reproduce and distribute copies of the |
| 298 |
Work or Derivative Works thereof in any medium, with or without |
| 299 |
modifications, and in Source or Object form, provided that You |
| 300 |
meet the following conditions: |
| 301 |
|
| 302 |
(a) You must give any other recipients of the Work or |
| 303 |
Derivative Works a copy of this License; and |
| 304 |
|
| 305 |
(b) You must cause any modified files to carry prominent notices |
| 306 |
stating that You changed the files; and |
| 307 |
|
| 308 |
(c) You must retain, in the Source form of any Derivative Works |
| 309 |
that You distribute, all copyright, patent, trademark, and |
| 310 |
attribution notices from the Source form of the Work, |
| 311 |
excluding those notices that do not pertain to any part of |
| 312 |
the Derivative Works; and |
| 313 |
|
| 314 |
(d) If the Work includes a "NOTICE" text file as part of its |
| 315 |
distribution, then any Derivative Works that You distribute must |
| 316 |
include a readable copy of the attribution notices contained |
| 317 |
within such NOTICE file, excluding those notices that do not |
| 318 |
pertain to any part of the Derivative Works, in at least one |
| 319 |
of the following places: within a NOTICE text file distributed |
| 320 |
as part of the Derivative Works; within the Source form or |
| 321 |
documentation, if provided along with the Derivative Works; or, |
| 322 |
within a display generated by the Derivative Works, if and |
| 323 |
wherever such third-party notices normally appear. The contents |
| 324 |
of the NOTICE file are for informational purposes only and |
| 325 |
do not modify the License. You may add Your own attribution |
| 326 |
notices within Derivative Works that You distribute, alongside |
| 327 |
or as an addendum to the NOTICE text from the Work, provided |
| 328 |
that such additional attribution notices cannot be construed |
| 329 |
as modifying the License. |
| 330 |
|
| 331 |
You may add Your own copyright statement to Your modifications and |
| 332 |
may provide additional or different license terms and conditions |
| 333 |
for use, reproduction, or distribution of Your modifications, or |
| 334 |
for any such Derivative Works as a whole, provided Your use, |
| 335 |
reproduction, and distribution of the Work otherwise complies with |
| 336 |
the conditions stated in this License. |
| 337 |
|
| 338 |
5. Submission of Contributions. Unless You explicitly state otherwise, |
| 339 |
any Contribution intentionally submitted for inclusion in the Work |
| 340 |
by You to the Licensor shall be under the terms and conditions of |
| 341 |
this License, without any additional terms or conditions. |
| 342 |
Notwithstanding the above, nothing herein shall supersede or modify |
| 343 |
the terms of any separate license agreement you may have executed |
| 344 |
with Licensor regarding such Contributions. |
| 345 |
|
| 346 |
6. Trademarks. This License does not grant permission to use the trade |
| 347 |
names, trademarks, service marks, or product names of the Licensor, |
| 348 |
except as required for reasonable and customary use in describing the |
| 349 |
origin of the Work and reproducing the content of the NOTICE file. |
| 350 |
|
| 351 |
7. Disclaimer of Warranty. Unless required by applicable law or |
| 352 |
agreed to in writing, Licensor provides the Work (and each |
| 353 |
Contributor provides its Contributions) on an "AS IS" BASIS, |
| 354 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 355 |
implied, including, without limitation, any warranties or conditions |
| 356 |
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
| 357 |
PARTICULAR PURPOSE. You are solely responsible for determining the |
| 358 |
appropriateness of using or redistributing the Work and assume any |
| 359 |
risks associated with Your exercise of permissions under this License. |
| 360 |
|
| 361 |
8. Limitation of Liability. In no event and under no legal theory, |
| 362 |
whether in tort (including negligence), contract, or otherwise, |
| 363 |
unless required by applicable law (such as deliberate and grossly |
| 364 |
negligent acts) or agreed to in writing, shall any Contributor be |
| 365 |
liable to You for damages, including any direct, indirect, special, |
| 366 |
incidental, or consequential damages of any character arising as a |
| 367 |
result of this License or out of the use or inability to use the |
| 368 |
Work (including but not limited to damages for loss of goodwill, |
| 369 |
work stoppage, computer failure or malfunction, or any and all |
| 370 |
other commercial damages or losses), even if such Contributor |
| 371 |
has been advised of the possibility of such damages. |
| 372 |
|
| 373 |
9. Accepting Warranty or Additional Liability. While redistributing |
| 374 |
the Work or Derivative Works thereof, You may choose to offer, |
| 375 |
and charge a fee for, acceptance of support, warranty, indemnity, |
| 376 |
or other liability obligations and/or rights consistent with this |
| 377 |
License. However, in accepting such obligations, You may act only |
| 378 |
on Your own behalf and on Your sole responsibility, not on behalf |
| 379 |
of any other Contributor, and only if You agree to indemnify, |
| 380 |
defend, and hold each Contributor harmless for any liability |
| 381 |
incurred by, or claims asserted against, such Contributor by reason |
| 382 |
of your accepting any such warranty or additional liability. |
| 383 |
|
| 384 |
END OF TERMS AND CONDITIONS |
| 385 |
|
| 386 |
APPENDIX: How to apply the Apache License to your work. |
| 387 |
|
| 388 |
To apply the Apache License to your work, attach the following |
| 389 |
boilerplate notice, with the fields enclosed by brackets "[]" |
| 390 |
replaced with your own identifying information. (Don't include |
| 391 |
the brackets!) The text should be enclosed in the appropriate |
| 392 |
comment syntax for the file format. We also recommend that a |
| 393 |
file or class name and description of purpose be included on the |
| 394 |
same "printed page" as the copyright notice for easier |
| 395 |
identification within third-party archives. |
| 396 |
|
| 397 |
Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors |
| 398 |
|
| 399 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 400 |
you may not use this file except in compliance with the License. |
| 401 |
You may obtain a copy of the License at |
| 402 |
|
| 403 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 404 |
|
| 405 |
Unless required by applicable law or agreed to in writing, software |
| 406 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 407 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 408 |
See the License for the specific language governing permissions and |
| 409 |
limitations under the License. |
| 410 |
|
| 411 |
|
| 412 |
**/ |
| 413 |
(function (global, factory) { |
| 414 |
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
| 415 |
typeof define === 'function' && define.amd ? define('rxjs', ['exports'], factory) : |
| 416 |
(factory((global.rxjs = {}))); |
| 417 |
}(this, (function (exports) { 'use strict'; |
| 418 |
|
| 419 |
/*! ***************************************************************************** |
| 420 |
Copyright (c) Microsoft Corporation. |
| 421 |
|
| 422 |
Permission to use, copy, modify, and/or distribute this software for any |
| 423 |
purpose with or without fee is hereby granted. |
| 424 |
|
| 425 |
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 426 |
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 427 |
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 428 |
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 429 |
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 430 |
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 431 |
PERFORMANCE OF THIS SOFTWARE. |
| 432 |
***************************************************************************** */ |
| 433 |
/* global Reflect, Promise */ |
| 434 |
|
| 435 |
var extendStatics = function(d, b) { |
| 436 |
extendStatics = Object.setPrototypeOf || |
| 437 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 438 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 439 |
return extendStatics(d, b); |
| 440 |
}; |
| 441 |
|
| 442 |
function __extends(d, b) { |
| 443 |
if (typeof b !== "function" && b !== null) |
| 444 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 445 |
extendStatics(d, b); |
| 446 |
function __() { this.constructor = d; } |
| 447 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 448 |
} |
| 449 |
|
| 450 |
var __assign = function() { |
| 451 |
__assign = Object.assign || function __assign(t) { |
| 452 |
for (var s, i = 1, n = arguments.length; i < n; i++) { |
| 453 |
s = arguments[i]; |
| 454 |
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
| 455 |
} |
| 456 |
return t; |
| 457 |
}; |
| 458 |
return __assign.apply(this, arguments); |
| 459 |
}; |
| 460 |
|
| 461 |
function __rest(s, e) { |
| 462 |
var t = {}; |
| 463 |
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
| 464 |
t[p] = s[p]; |
| 465 |
if (s != null && typeof Object.getOwnPropertySymbols === "function") |
| 466 |
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { |
| 467 |
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) |
| 468 |
t[p[i]] = s[p[i]]; |
| 469 |
} |
| 470 |
return t; |
| 471 |
} |
| 472 |
|
| 473 |
function __awaiter(thisArg, _arguments, P, generator) { |
| 474 |
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
| 475 |
return new (P || (P = Promise))(function (resolve, reject) { |
| 476 |
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
| 477 |
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
| 478 |
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
| 479 |
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| 480 |
}); |
| 481 |
} |
| 482 |
|
| 483 |
function __generator(thisArg, body) { |
| 484 |
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
| 485 |
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
| 486 |
function verb(n) { return function (v) { return step([n, v]); }; } |
| 487 |
function step(op) { |
| 488 |
if (f) throw new TypeError("Generator is already executing."); |
| 489 |
while (_) try { |
| 490 |
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
| 491 |
if (y = 0, t) op = [op[0] & 2, t.value]; |
| 492 |
switch (op[0]) { |
| 493 |
case 0: case 1: t = op; break; |
| 494 |
case 4: _.label++; return { value: op[1], done: false }; |
| 495 |
case 5: _.label++; y = op[1]; op = [0]; continue; |
| 496 |
case 7: op = _.ops.pop(); _.trys.pop(); continue; |
| 497 |
default: |
| 498 |
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
| 499 |
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
| 500 |
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
| 501 |
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
| 502 |
if (t[2]) _.ops.pop(); |
| 503 |
_.trys.pop(); continue; |
| 504 |
} |
| 505 |
op = body.call(thisArg, _); |
| 506 |
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
| 507 |
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
function __values(o) { |
| 512 |
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
| 513 |
if (m) return m.call(o); |
| 514 |
if (o && typeof o.length === "number") return { |
| 515 |
next: function () { |
| 516 |
if (o && i >= o.length) o = void 0; |
| 517 |
return { value: o && o[i++], done: !o }; |
| 518 |
} |
| 519 |
}; |
| 520 |
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
| 521 |
} |
| 522 |
|
| 523 |
function __read(o, n) { |
| 524 |
var m = typeof Symbol === "function" && o[Symbol.iterator]; |
| 525 |
if (!m) return o; |
| 526 |
var i = m.call(o), r, ar = [], e; |
| 527 |
try { |
| 528 |
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); |
| 529 |
} |
| 530 |
catch (error) { e = { error: error }; } |
| 531 |
finally { |
| 532 |
try { |
| 533 |
if (r && !r.done && (m = i["return"])) m.call(i); |
| 534 |
} |
| 535 |
finally { if (e) throw e.error; } |
| 536 |
} |
| 537 |
return ar; |
| 538 |
} |
| 539 |
|
| 540 |
function __spreadArray(to, from, pack) { |
| 541 |
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { |
| 542 |
if (ar || !(i in from)) { |
| 543 |
if (!ar) ar = Array.prototype.slice.call(from, 0, i); |
| 544 |
ar[i] = from[i]; |
| 545 |
} |
| 546 |
} |
| 547 |
return to.concat(ar || Array.prototype.slice.call(from)); |
| 548 |
} |
| 549 |
|
| 550 |
function __await(v) { |
| 551 |
return this instanceof __await ? (this.v = v, this) : new __await(v); |
| 552 |
} |
| 553 |
|
| 554 |
function __asyncGenerator(thisArg, _arguments, generator) { |
| 555 |
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
| 556 |
var g = generator.apply(thisArg, _arguments || []), i, q = []; |
| 557 |
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; |
| 558 |
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } |
| 559 |
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } |
| 560 |
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } |
| 561 |
function fulfill(value) { resume("next", value); } |
| 562 |
function reject(value) { resume("throw", value); } |
| 563 |
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } |
| 564 |
} |
| 565 |
|
| 566 |
function __asyncValues(o) { |
| 567 |
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
| 568 |
var m = o[Symbol.asyncIterator], i; |
| 569 |
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); |
| 570 |
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } |
| 571 |
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } |
| 572 |
} |
| 573 |
|
| 574 |
function isFunction(value) { |
| 575 |
return typeof value === 'function'; |
| 576 |
} |
| 577 |
|
| 578 |
function createErrorClass(createImpl) { |
| 579 |
var _super = function (instance) { |
| 580 |
Error.call(instance); |
| 581 |
instance.stack = new Error().stack; |
| 582 |
}; |
| 583 |
var ctorFunc = createImpl(_super); |
| 584 |
ctorFunc.prototype = Object.create(Error.prototype); |
| 585 |
ctorFunc.prototype.constructor = ctorFunc; |
| 586 |
return ctorFunc; |
| 587 |
} |
| 588 |
|
| 589 |
var UnsubscriptionError = createErrorClass(function (_super) { |
| 590 |
return function UnsubscriptionErrorImpl(errors) { |
| 591 |
_super(this); |
| 592 |
this.message = errors |
| 593 |
? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') |
| 594 |
: ''; |
| 595 |
this.name = 'UnsubscriptionError'; |
| 596 |
this.errors = errors; |
| 597 |
}; |
| 598 |
}); |
| 599 |
|
| 600 |
function arrRemove(arr, item) { |
| 601 |
if (arr) { |
| 602 |
var index = arr.indexOf(item); |
| 603 |
0 <= index && arr.splice(index, 1); |
| 604 |
} |
| 605 |
} |
| 606 |
|
| 607 |
var Subscription = (function () { |
| 608 |
function Subscription(initialTeardown) { |
| 609 |
this.initialTeardown = initialTeardown; |
| 610 |
this.closed = false; |
| 611 |
this._parentage = null; |
| 612 |
this._finalizers = null; |
| 613 |
} |
| 614 |
Subscription.prototype.unsubscribe = function () { |
| 615 |
var e_1, _a, e_2, _b; |
| 616 |
var errors; |
| 617 |
if (!this.closed) { |
| 618 |
this.closed = true; |
| 619 |
var _parentage = this._parentage; |
| 620 |
if (_parentage) { |
| 621 |
this._parentage = null; |
| 622 |
if (Array.isArray(_parentage)) { |
| 623 |
try { |
| 624 |
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) { |
| 625 |
var parent_1 = _parentage_1_1.value; |
| 626 |
parent_1.remove(this); |
| 627 |
} |
| 628 |
} |
| 629 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 630 |
finally { |
| 631 |
try { |
| 632 |
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1); |
| 633 |
} |
| 634 |
finally { if (e_1) throw e_1.error; } |
| 635 |
} |
| 636 |
} |
| 637 |
else { |
| 638 |
_parentage.remove(this); |
| 639 |
} |
| 640 |
} |
| 641 |
var initialFinalizer = this.initialTeardown; |
| 642 |
if (isFunction(initialFinalizer)) { |
| 643 |
try { |
| 644 |
initialFinalizer(); |
| 645 |
} |
| 646 |
catch (e) { |
| 647 |
errors = e instanceof UnsubscriptionError ? e.errors : [e]; |
| 648 |
} |
| 649 |
} |
| 650 |
var _finalizers = this._finalizers; |
| 651 |
if (_finalizers) { |
| 652 |
this._finalizers = null; |
| 653 |
try { |
| 654 |
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) { |
| 655 |
var finalizer = _finalizers_1_1.value; |
| 656 |
try { |
| 657 |
execFinalizer(finalizer); |
| 658 |
} |
| 659 |
catch (err) { |
| 660 |
errors = errors !== null && errors !== void 0 ? errors : []; |
| 661 |
if (err instanceof UnsubscriptionError) { |
| 662 |
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors)); |
| 663 |
} |
| 664 |
else { |
| 665 |
errors.push(err); |
| 666 |
} |
| 667 |
} |
| 668 |
} |
| 669 |
} |
| 670 |
catch (e_2_1) { e_2 = { error: e_2_1 }; } |
| 671 |
finally { |
| 672 |
try { |
| 673 |
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1); |
| 674 |
} |
| 675 |
finally { if (e_2) throw e_2.error; } |
| 676 |
} |
| 677 |
} |
| 678 |
if (errors) { |
| 679 |
throw new UnsubscriptionError(errors); |
| 680 |
} |
| 681 |
} |
| 682 |
}; |
| 683 |
Subscription.prototype.add = function (teardown) { |
| 684 |
var _a; |
| 685 |
if (teardown && teardown !== this) { |
| 686 |
if (this.closed) { |
| 687 |
execFinalizer(teardown); |
| 688 |
} |
| 689 |
else { |
| 690 |
if (teardown instanceof Subscription) { |
| 691 |
if (teardown.closed || teardown._hasParent(this)) { |
| 692 |
return; |
| 693 |
} |
| 694 |
teardown._addParent(this); |
| 695 |
} |
| 696 |
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown); |
| 697 |
} |
| 698 |
} |
| 699 |
}; |
| 700 |
Subscription.prototype._hasParent = function (parent) { |
| 701 |
var _parentage = this._parentage; |
| 702 |
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent)); |
| 703 |
}; |
| 704 |
Subscription.prototype._addParent = function (parent) { |
| 705 |
var _parentage = this._parentage; |
| 706 |
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent; |
| 707 |
}; |
| 708 |
Subscription.prototype._removeParent = function (parent) { |
| 709 |
var _parentage = this._parentage; |
| 710 |
if (_parentage === parent) { |
| 711 |
this._parentage = null; |
| 712 |
} |
| 713 |
else if (Array.isArray(_parentage)) { |
| 714 |
arrRemove(_parentage, parent); |
| 715 |
} |
| 716 |
}; |
| 717 |
Subscription.prototype.remove = function (teardown) { |
| 718 |
var _finalizers = this._finalizers; |
| 719 |
_finalizers && arrRemove(_finalizers, teardown); |
| 720 |
if (teardown instanceof Subscription) { |
| 721 |
teardown._removeParent(this); |
| 722 |
} |
| 723 |
}; |
| 724 |
Subscription.EMPTY = (function () { |
| 725 |
var empty = new Subscription(); |
| 726 |
empty.closed = true; |
| 727 |
return empty; |
| 728 |
})(); |
| 729 |
return Subscription; |
| 730 |
}()); |
| 731 |
var EMPTY_SUBSCRIPTION = Subscription.EMPTY; |
| 732 |
function isSubscription(value) { |
| 733 |
return (value instanceof Subscription || |
| 734 |
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe))); |
| 735 |
} |
| 736 |
function execFinalizer(finalizer) { |
| 737 |
if (isFunction(finalizer)) { |
| 738 |
finalizer(); |
| 739 |
} |
| 740 |
else { |
| 741 |
finalizer.unsubscribe(); |
| 742 |
} |
| 743 |
} |
| 744 |
|
| 745 |
var config = { |
| 746 |
onUnhandledError: null, |
| 747 |
onStoppedNotification: null, |
| 748 |
Promise: undefined, |
| 749 |
useDeprecatedSynchronousErrorHandling: false, |
| 750 |
useDeprecatedNextContext: false, |
| 751 |
}; |
| 752 |
|
| 753 |
var timeoutProvider = { |
| 754 |
setTimeout: function (handler, timeout) { |
| 755 |
var args = []; |
| 756 |
for (var _i = 2; _i < arguments.length; _i++) { |
| 757 |
args[_i - 2] = arguments[_i]; |
| 758 |
} |
| 759 |
var delegate = timeoutProvider.delegate; |
| 760 |
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) { |
| 761 |
return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args))); |
| 762 |
} |
| 763 |
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args))); |
| 764 |
}, |
| 765 |
clearTimeout: function (handle) { |
| 766 |
var delegate = timeoutProvider.delegate; |
| 767 |
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle); |
| 768 |
}, |
| 769 |
delegate: undefined, |
| 770 |
}; |
| 771 |
|
| 772 |
function reportUnhandledError(err) { |
| 773 |
timeoutProvider.setTimeout(function () { |
| 774 |
var onUnhandledError = config.onUnhandledError; |
| 775 |
if (onUnhandledError) { |
| 776 |
onUnhandledError(err); |
| 777 |
} |
| 778 |
else { |
| 779 |
throw err; |
| 780 |
} |
| 781 |
}); |
| 782 |
} |
| 783 |
|
| 784 |
function noop() { } |
| 785 |
|
| 786 |
var COMPLETE_NOTIFICATION = (function () { return createNotification('C', undefined, undefined); })(); |
| 787 |
function errorNotification(error) { |
| 788 |
return createNotification('E', undefined, error); |
| 789 |
} |
| 790 |
function nextNotification(value) { |
| 791 |
return createNotification('N', value, undefined); |
| 792 |
} |
| 793 |
function createNotification(kind, value, error) { |
| 794 |
return { |
| 795 |
kind: kind, |
| 796 |
value: value, |
| 797 |
error: error, |
| 798 |
}; |
| 799 |
} |
| 800 |
|
| 801 |
var context = null; |
| 802 |
function errorContext(cb) { |
| 803 |
if (config.useDeprecatedSynchronousErrorHandling) { |
| 804 |
var isRoot = !context; |
| 805 |
if (isRoot) { |
| 806 |
context = { errorThrown: false, error: null }; |
| 807 |
} |
| 808 |
cb(); |
| 809 |
if (isRoot) { |
| 810 |
var _a = context, errorThrown = _a.errorThrown, error = _a.error; |
| 811 |
context = null; |
| 812 |
if (errorThrown) { |
| 813 |
throw error; |
| 814 |
} |
| 815 |
} |
| 816 |
} |
| 817 |
else { |
| 818 |
cb(); |
| 819 |
} |
| 820 |
} |
| 821 |
function captureError(err) { |
| 822 |
if (config.useDeprecatedSynchronousErrorHandling && context) { |
| 823 |
context.errorThrown = true; |
| 824 |
context.error = err; |
| 825 |
} |
| 826 |
} |
| 827 |
|
| 828 |
var Subscriber = (function (_super) { |
| 829 |
__extends(Subscriber, _super); |
| 830 |
function Subscriber(destination) { |
| 831 |
var _this = _super.call(this) || this; |
| 832 |
_this.isStopped = false; |
| 833 |
if (destination) { |
| 834 |
_this.destination = destination; |
| 835 |
if (isSubscription(destination)) { |
| 836 |
destination.add(_this); |
| 837 |
} |
| 838 |
} |
| 839 |
else { |
| 840 |
_this.destination = EMPTY_OBSERVER; |
| 841 |
} |
| 842 |
return _this; |
| 843 |
} |
| 844 |
Subscriber.create = function (next, error, complete) { |
| 845 |
return new SafeSubscriber(next, error, complete); |
| 846 |
}; |
| 847 |
Subscriber.prototype.next = function (value) { |
| 848 |
if (this.isStopped) { |
| 849 |
handleStoppedNotification(nextNotification(value), this); |
| 850 |
} |
| 851 |
else { |
| 852 |
this._next(value); |
| 853 |
} |
| 854 |
}; |
| 855 |
Subscriber.prototype.error = function (err) { |
| 856 |
if (this.isStopped) { |
| 857 |
handleStoppedNotification(errorNotification(err), this); |
| 858 |
} |
| 859 |
else { |
| 860 |
this.isStopped = true; |
| 861 |
this._error(err); |
| 862 |
} |
| 863 |
}; |
| 864 |
Subscriber.prototype.complete = function () { |
| 865 |
if (this.isStopped) { |
| 866 |
handleStoppedNotification(COMPLETE_NOTIFICATION, this); |
| 867 |
} |
| 868 |
else { |
| 869 |
this.isStopped = true; |
| 870 |
this._complete(); |
| 871 |
} |
| 872 |
}; |
| 873 |
Subscriber.prototype.unsubscribe = function () { |
| 874 |
if (!this.closed) { |
| 875 |
this.isStopped = true; |
| 876 |
_super.prototype.unsubscribe.call(this); |
| 877 |
this.destination = null; |
| 878 |
} |
| 879 |
}; |
| 880 |
Subscriber.prototype._next = function (value) { |
| 881 |
this.destination.next(value); |
| 882 |
}; |
| 883 |
Subscriber.prototype._error = function (err) { |
| 884 |
try { |
| 885 |
this.destination.error(err); |
| 886 |
} |
| 887 |
finally { |
| 888 |
this.unsubscribe(); |
| 889 |
} |
| 890 |
}; |
| 891 |
Subscriber.prototype._complete = function () { |
| 892 |
try { |
| 893 |
this.destination.complete(); |
| 894 |
} |
| 895 |
finally { |
| 896 |
this.unsubscribe(); |
| 897 |
} |
| 898 |
}; |
| 899 |
return Subscriber; |
| 900 |
}(Subscription)); |
| 901 |
var _bind = Function.prototype.bind; |
| 902 |
function bind(fn, thisArg) { |
| 903 |
return _bind.call(fn, thisArg); |
| 904 |
} |
| 905 |
var ConsumerObserver = (function () { |
| 906 |
function ConsumerObserver(partialObserver) { |
| 907 |
this.partialObserver = partialObserver; |
| 908 |
} |
| 909 |
ConsumerObserver.prototype.next = function (value) { |
| 910 |
var partialObserver = this.partialObserver; |
| 911 |
if (partialObserver.next) { |
| 912 |
try { |
| 913 |
partialObserver.next(value); |
| 914 |
} |
| 915 |
catch (error) { |
| 916 |
handleUnhandledError(error); |
| 917 |
} |
| 918 |
} |
| 919 |
}; |
| 920 |
ConsumerObserver.prototype.error = function (err) { |
| 921 |
var partialObserver = this.partialObserver; |
| 922 |
if (partialObserver.error) { |
| 923 |
try { |
| 924 |
partialObserver.error(err); |
| 925 |
} |
| 926 |
catch (error) { |
| 927 |
handleUnhandledError(error); |
| 928 |
} |
| 929 |
} |
| 930 |
else { |
| 931 |
handleUnhandledError(err); |
| 932 |
} |
| 933 |
}; |
| 934 |
ConsumerObserver.prototype.complete = function () { |
| 935 |
var partialObserver = this.partialObserver; |
| 936 |
if (partialObserver.complete) { |
| 937 |
try { |
| 938 |
partialObserver.complete(); |
| 939 |
} |
| 940 |
catch (error) { |
| 941 |
handleUnhandledError(error); |
| 942 |
} |
| 943 |
} |
| 944 |
}; |
| 945 |
return ConsumerObserver; |
| 946 |
}()); |
| 947 |
var SafeSubscriber = (function (_super) { |
| 948 |
__extends(SafeSubscriber, _super); |
| 949 |
function SafeSubscriber(observerOrNext, error, complete) { |
| 950 |
var _this = _super.call(this) || this; |
| 951 |
var partialObserver; |
| 952 |
if (isFunction(observerOrNext) || !observerOrNext) { |
| 953 |
partialObserver = { |
| 954 |
next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined), |
| 955 |
error: error !== null && error !== void 0 ? error : undefined, |
| 956 |
complete: complete !== null && complete !== void 0 ? complete : undefined, |
| 957 |
}; |
| 958 |
} |
| 959 |
else { |
| 960 |
var context_1; |
| 961 |
if (_this && config.useDeprecatedNextContext) { |
| 962 |
context_1 = Object.create(observerOrNext); |
| 963 |
context_1.unsubscribe = function () { return _this.unsubscribe(); }; |
| 964 |
partialObserver = { |
| 965 |
next: observerOrNext.next && bind(observerOrNext.next, context_1), |
| 966 |
error: observerOrNext.error && bind(observerOrNext.error, context_1), |
| 967 |
complete: observerOrNext.complete && bind(observerOrNext.complete, context_1), |
| 968 |
}; |
| 969 |
} |
| 970 |
else { |
| 971 |
partialObserver = observerOrNext; |
| 972 |
} |
| 973 |
} |
| 974 |
_this.destination = new ConsumerObserver(partialObserver); |
| 975 |
return _this; |
| 976 |
} |
| 977 |
return SafeSubscriber; |
| 978 |
}(Subscriber)); |
| 979 |
function handleUnhandledError(error) { |
| 980 |
if (config.useDeprecatedSynchronousErrorHandling) { |
| 981 |
captureError(error); |
| 982 |
} |
| 983 |
else { |
| 984 |
reportUnhandledError(error); |
| 985 |
} |
| 986 |
} |
| 987 |
function defaultErrorHandler(err) { |
| 988 |
throw err; |
| 989 |
} |
| 990 |
function handleStoppedNotification(notification, subscriber) { |
| 991 |
var onStoppedNotification = config.onStoppedNotification; |
| 992 |
onStoppedNotification && timeoutProvider.setTimeout(function () { return onStoppedNotification(notification, subscriber); }); |
| 993 |
} |
| 994 |
var EMPTY_OBSERVER = { |
| 995 |
closed: true, |
| 996 |
next: noop, |
| 997 |
error: defaultErrorHandler, |
| 998 |
complete: noop, |
| 999 |
}; |
| 1000 |
|
| 1001 |
var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })(); |
| 1002 |
|
| 1003 |
function identity(x) { |
| 1004 |
return x; |
| 1005 |
} |
| 1006 |
|
| 1007 |
function pipe() { |
| 1008 |
var fns = []; |
| 1009 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 1010 |
fns[_i] = arguments[_i]; |
| 1011 |
} |
| 1012 |
return pipeFromArray(fns); |
| 1013 |
} |
| 1014 |
function pipeFromArray(fns) { |
| 1015 |
if (fns.length === 0) { |
| 1016 |
return identity; |
| 1017 |
} |
| 1018 |
if (fns.length === 1) { |
| 1019 |
return fns[0]; |
| 1020 |
} |
| 1021 |
return function piped(input) { |
| 1022 |
return fns.reduce(function (prev, fn) { return fn(prev); }, input); |
| 1023 |
}; |
| 1024 |
} |
| 1025 |
|
| 1026 |
var Observable = (function () { |
| 1027 |
function Observable(subscribe) { |
| 1028 |
if (subscribe) { |
| 1029 |
this._subscribe = subscribe; |
| 1030 |
} |
| 1031 |
} |
| 1032 |
Observable.prototype.lift = function (operator) { |
| 1033 |
var observable$$1 = new Observable(); |
| 1034 |
observable$$1.source = this; |
| 1035 |
observable$$1.operator = operator; |
| 1036 |
return observable$$1; |
| 1037 |
}; |
| 1038 |
Observable.prototype.subscribe = function (observerOrNext, error, complete) { |
| 1039 |
var _this = this; |
| 1040 |
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete); |
| 1041 |
errorContext(function () { |
| 1042 |
var _a = _this, operator = _a.operator, source = _a.source; |
| 1043 |
subscriber.add(operator |
| 1044 |
? |
| 1045 |
operator.call(subscriber, source) |
| 1046 |
: source |
| 1047 |
? |
| 1048 |
_this._subscribe(subscriber) |
| 1049 |
: |
| 1050 |
_this._trySubscribe(subscriber)); |
| 1051 |
}); |
| 1052 |
return subscriber; |
| 1053 |
}; |
| 1054 |
Observable.prototype._trySubscribe = function (sink) { |
| 1055 |
try { |
| 1056 |
return this._subscribe(sink); |
| 1057 |
} |
| 1058 |
catch (err) { |
| 1059 |
sink.error(err); |
| 1060 |
} |
| 1061 |
}; |
| 1062 |
Observable.prototype.forEach = function (next, promiseCtor) { |
| 1063 |
var _this = this; |
| 1064 |
promiseCtor = getPromiseCtor(promiseCtor); |
| 1065 |
return new promiseCtor(function (resolve, reject) { |
| 1066 |
var subscriber = new SafeSubscriber({ |
| 1067 |
next: function (value) { |
| 1068 |
try { |
| 1069 |
next(value); |
| 1070 |
} |
| 1071 |
catch (err) { |
| 1072 |
reject(err); |
| 1073 |
subscriber.unsubscribe(); |
| 1074 |
} |
| 1075 |
}, |
| 1076 |
error: reject, |
| 1077 |
complete: resolve, |
| 1078 |
}); |
| 1079 |
_this.subscribe(subscriber); |
| 1080 |
}); |
| 1081 |
}; |
| 1082 |
Observable.prototype._subscribe = function (subscriber) { |
| 1083 |
var _a; |
| 1084 |
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber); |
| 1085 |
}; |
| 1086 |
Observable.prototype[observable] = function () { |
| 1087 |
return this; |
| 1088 |
}; |
| 1089 |
Observable.prototype.pipe = function () { |
| 1090 |
var operations = []; |
| 1091 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 1092 |
operations[_i] = arguments[_i]; |
| 1093 |
} |
| 1094 |
return pipeFromArray(operations)(this); |
| 1095 |
}; |
| 1096 |
Observable.prototype.toPromise = function (promiseCtor) { |
| 1097 |
var _this = this; |
| 1098 |
promiseCtor = getPromiseCtor(promiseCtor); |
| 1099 |
return new promiseCtor(function (resolve, reject) { |
| 1100 |
var value; |
| 1101 |
_this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); }); |
| 1102 |
}); |
| 1103 |
}; |
| 1104 |
Observable.create = function (subscribe) { |
| 1105 |
return new Observable(subscribe); |
| 1106 |
}; |
| 1107 |
return Observable; |
| 1108 |
}()); |
| 1109 |
function getPromiseCtor(promiseCtor) { |
| 1110 |
var _a; |
| 1111 |
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise; |
| 1112 |
} |
| 1113 |
function isObserver(value) { |
| 1114 |
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete); |
| 1115 |
} |
| 1116 |
function isSubscriber(value) { |
| 1117 |
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value)); |
| 1118 |
} |
| 1119 |
|
| 1120 |
function hasLift(source) { |
| 1121 |
return isFunction(source === null || source === void 0 ? void 0 : source.lift); |
| 1122 |
} |
| 1123 |
function operate(init) { |
| 1124 |
return function (source) { |
| 1125 |
if (hasLift(source)) { |
| 1126 |
return source.lift(function (liftedSource) { |
| 1127 |
try { |
| 1128 |
return init(liftedSource, this); |
| 1129 |
} |
| 1130 |
catch (err) { |
| 1131 |
this.error(err); |
| 1132 |
} |
| 1133 |
}); |
| 1134 |
} |
| 1135 |
throw new TypeError('Unable to lift unknown Observable type'); |
| 1136 |
}; |
| 1137 |
} |
| 1138 |
|
| 1139 |
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) { |
| 1140 |
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize); |
| 1141 |
} |
| 1142 |
var OperatorSubscriber = (function (_super) { |
| 1143 |
__extends(OperatorSubscriber, _super); |
| 1144 |
function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) { |
| 1145 |
var _this = _super.call(this, destination) || this; |
| 1146 |
_this.onFinalize = onFinalize; |
| 1147 |
_this.shouldUnsubscribe = shouldUnsubscribe; |
| 1148 |
_this._next = onNext |
| 1149 |
? function (value) { |
| 1150 |
try { |
| 1151 |
onNext(value); |
| 1152 |
} |
| 1153 |
catch (err) { |
| 1154 |
destination.error(err); |
| 1155 |
} |
| 1156 |
} |
| 1157 |
: _super.prototype._next; |
| 1158 |
_this._error = onError |
| 1159 |
? function (err) { |
| 1160 |
try { |
| 1161 |
onError(err); |
| 1162 |
} |
| 1163 |
catch (err) { |
| 1164 |
destination.error(err); |
| 1165 |
} |
| 1166 |
finally { |
| 1167 |
this.unsubscribe(); |
| 1168 |
} |
| 1169 |
} |
| 1170 |
: _super.prototype._error; |
| 1171 |
_this._complete = onComplete |
| 1172 |
? function () { |
| 1173 |
try { |
| 1174 |
onComplete(); |
| 1175 |
} |
| 1176 |
catch (err) { |
| 1177 |
destination.error(err); |
| 1178 |
} |
| 1179 |
finally { |
| 1180 |
this.unsubscribe(); |
| 1181 |
} |
| 1182 |
} |
| 1183 |
: _super.prototype._complete; |
| 1184 |
return _this; |
| 1185 |
} |
| 1186 |
OperatorSubscriber.prototype.unsubscribe = function () { |
| 1187 |
var _a; |
| 1188 |
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) { |
| 1189 |
var closed_1 = this.closed; |
| 1190 |
_super.prototype.unsubscribe.call(this); |
| 1191 |
!closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this)); |
| 1192 |
} |
| 1193 |
}; |
| 1194 |
return OperatorSubscriber; |
| 1195 |
}(Subscriber)); |
| 1196 |
|
| 1197 |
function refCount() { |
| 1198 |
return operate(function (source, subscriber) { |
| 1199 |
var connection = null; |
| 1200 |
source._refCount++; |
| 1201 |
var refCounter = createOperatorSubscriber(subscriber, undefined, undefined, undefined, function () { |
| 1202 |
if (!source || source._refCount <= 0 || 0 < --source._refCount) { |
| 1203 |
connection = null; |
| 1204 |
return; |
| 1205 |
} |
| 1206 |
var sharedConnection = source._connection; |
| 1207 |
var conn = connection; |
| 1208 |
connection = null; |
| 1209 |
if (sharedConnection && (!conn || sharedConnection === conn)) { |
| 1210 |
sharedConnection.unsubscribe(); |
| 1211 |
} |
| 1212 |
subscriber.unsubscribe(); |
| 1213 |
}); |
| 1214 |
source.subscribe(refCounter); |
| 1215 |
if (!refCounter.closed) { |
| 1216 |
connection = source.connect(); |
| 1217 |
} |
| 1218 |
}); |
| 1219 |
} |
| 1220 |
|
| 1221 |
var ConnectableObservable = (function (_super) { |
| 1222 |
__extends(ConnectableObservable, _super); |
| 1223 |
function ConnectableObservable(source, subjectFactory) { |
| 1224 |
var _this = _super.call(this) || this; |
| 1225 |
_this.source = source; |
| 1226 |
_this.subjectFactory = subjectFactory; |
| 1227 |
_this._subject = null; |
| 1228 |
_this._refCount = 0; |
| 1229 |
_this._connection = null; |
| 1230 |
if (hasLift(source)) { |
| 1231 |
_this.lift = source.lift; |
| 1232 |
} |
| 1233 |
return _this; |
| 1234 |
} |
| 1235 |
ConnectableObservable.prototype._subscribe = function (subscriber) { |
| 1236 |
return this.getSubject().subscribe(subscriber); |
| 1237 |
}; |
| 1238 |
ConnectableObservable.prototype.getSubject = function () { |
| 1239 |
var subject = this._subject; |
| 1240 |
if (!subject || subject.isStopped) { |
| 1241 |
this._subject = this.subjectFactory(); |
| 1242 |
} |
| 1243 |
return this._subject; |
| 1244 |
}; |
| 1245 |
ConnectableObservable.prototype._teardown = function () { |
| 1246 |
this._refCount = 0; |
| 1247 |
var _connection = this._connection; |
| 1248 |
this._subject = this._connection = null; |
| 1249 |
_connection === null || _connection === void 0 ? void 0 : _connection.unsubscribe(); |
| 1250 |
}; |
| 1251 |
ConnectableObservable.prototype.connect = function () { |
| 1252 |
var _this = this; |
| 1253 |
var connection = this._connection; |
| 1254 |
if (!connection) { |
| 1255 |
connection = this._connection = new Subscription(); |
| 1256 |
var subject_1 = this.getSubject(); |
| 1257 |
connection.add(this.source.subscribe(createOperatorSubscriber(subject_1, undefined, function () { |
| 1258 |
_this._teardown(); |
| 1259 |
subject_1.complete(); |
| 1260 |
}, function (err) { |
| 1261 |
_this._teardown(); |
| 1262 |
subject_1.error(err); |
| 1263 |
}, function () { return _this._teardown(); }))); |
| 1264 |
if (connection.closed) { |
| 1265 |
this._connection = null; |
| 1266 |
connection = Subscription.EMPTY; |
| 1267 |
} |
| 1268 |
} |
| 1269 |
return connection; |
| 1270 |
}; |
| 1271 |
ConnectableObservable.prototype.refCount = function () { |
| 1272 |
return refCount()(this); |
| 1273 |
}; |
| 1274 |
return ConnectableObservable; |
| 1275 |
}(Observable)); |
| 1276 |
|
| 1277 |
var performanceTimestampProvider = { |
| 1278 |
now: function () { |
| 1279 |
return (performanceTimestampProvider.delegate || performance).now(); |
| 1280 |
}, |
| 1281 |
delegate: undefined, |
| 1282 |
}; |
| 1283 |
|
| 1284 |
var animationFrameProvider = { |
| 1285 |
schedule: function (callback) { |
| 1286 |
var request = requestAnimationFrame; |
| 1287 |
var cancel = cancelAnimationFrame; |
| 1288 |
var delegate = animationFrameProvider.delegate; |
| 1289 |
if (delegate) { |
| 1290 |
request = delegate.requestAnimationFrame; |
| 1291 |
cancel = delegate.cancelAnimationFrame; |
| 1292 |
} |
| 1293 |
var handle = request(function (timestamp) { |
| 1294 |
cancel = undefined; |
| 1295 |
callback(timestamp); |
| 1296 |
}); |
| 1297 |
return new Subscription(function () { return cancel === null || cancel === void 0 ? void 0 : cancel(handle); }); |
| 1298 |
}, |
| 1299 |
requestAnimationFrame: function () { |
| 1300 |
var args = []; |
| 1301 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 1302 |
args[_i] = arguments[_i]; |
| 1303 |
} |
| 1304 |
var delegate = animationFrameProvider.delegate; |
| 1305 |
return ((delegate === null || delegate === void 0 ? void 0 : delegate.requestAnimationFrame) || requestAnimationFrame).apply(void 0, __spreadArray([], __read(args))); |
| 1306 |
}, |
| 1307 |
cancelAnimationFrame: function () { |
| 1308 |
var args = []; |
| 1309 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 1310 |
args[_i] = arguments[_i]; |
| 1311 |
} |
| 1312 |
var delegate = animationFrameProvider.delegate; |
| 1313 |
return ((delegate === null || delegate === void 0 ? void 0 : delegate.cancelAnimationFrame) || cancelAnimationFrame).apply(void 0, __spreadArray([], __read(args))); |
| 1314 |
}, |
| 1315 |
delegate: undefined, |
| 1316 |
}; |
| 1317 |
|
| 1318 |
function animationFrames(timestampProvider) { |
| 1319 |
return timestampProvider ? animationFramesFactory(timestampProvider) : DEFAULT_ANIMATION_FRAMES; |
| 1320 |
} |
| 1321 |
function animationFramesFactory(timestampProvider) { |
| 1322 |
return new Observable(function (subscriber) { |
| 1323 |
var provider = timestampProvider || performanceTimestampProvider; |
| 1324 |
var start = provider.now(); |
| 1325 |
var id = 0; |
| 1326 |
var run = function () { |
| 1327 |
if (!subscriber.closed) { |
| 1328 |
id = animationFrameProvider.requestAnimationFrame(function (timestamp) { |
| 1329 |
id = 0; |
| 1330 |
var now = provider.now(); |
| 1331 |
subscriber.next({ |
| 1332 |
timestamp: timestampProvider ? now : timestamp, |
| 1333 |
elapsed: now - start, |
| 1334 |
}); |
| 1335 |
run(); |
| 1336 |
}); |
| 1337 |
} |
| 1338 |
}; |
| 1339 |
run(); |
| 1340 |
return function () { |
| 1341 |
if (id) { |
| 1342 |
animationFrameProvider.cancelAnimationFrame(id); |
| 1343 |
} |
| 1344 |
}; |
| 1345 |
}); |
| 1346 |
} |
| 1347 |
var DEFAULT_ANIMATION_FRAMES = animationFramesFactory(); |
| 1348 |
|
| 1349 |
var ObjectUnsubscribedError = createErrorClass(function (_super) { |
| 1350 |
return function ObjectUnsubscribedErrorImpl() { |
| 1351 |
_super(this); |
| 1352 |
this.name = 'ObjectUnsubscribedError'; |
| 1353 |
this.message = 'object unsubscribed'; |
| 1354 |
}; |
| 1355 |
}); |
| 1356 |
|
| 1357 |
var Subject = (function (_super) { |
| 1358 |
__extends(Subject, _super); |
| 1359 |
function Subject() { |
| 1360 |
var _this = _super.call(this) || this; |
| 1361 |
_this.closed = false; |
| 1362 |
_this.currentObservers = null; |
| 1363 |
_this.observers = []; |
| 1364 |
_this.isStopped = false; |
| 1365 |
_this.hasError = false; |
| 1366 |
_this.thrownError = null; |
| 1367 |
return _this; |
| 1368 |
} |
| 1369 |
Subject.prototype.lift = function (operator) { |
| 1370 |
var subject = new AnonymousSubject(this, this); |
| 1371 |
subject.operator = operator; |
| 1372 |
return subject; |
| 1373 |
}; |
| 1374 |
Subject.prototype._throwIfClosed = function () { |
| 1375 |
if (this.closed) { |
| 1376 |
throw new ObjectUnsubscribedError(); |
| 1377 |
} |
| 1378 |
}; |
| 1379 |
Subject.prototype.next = function (value) { |
| 1380 |
var _this = this; |
| 1381 |
errorContext(function () { |
| 1382 |
var e_1, _a; |
| 1383 |
_this._throwIfClosed(); |
| 1384 |
if (!_this.isStopped) { |
| 1385 |
if (!_this.currentObservers) { |
| 1386 |
_this.currentObservers = Array.from(_this.observers); |
| 1387 |
} |
| 1388 |
try { |
| 1389 |
for (var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) { |
| 1390 |
var observer = _c.value; |
| 1391 |
observer.next(value); |
| 1392 |
} |
| 1393 |
} |
| 1394 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 1395 |
finally { |
| 1396 |
try { |
| 1397 |
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); |
| 1398 |
} |
| 1399 |
finally { if (e_1) throw e_1.error; } |
| 1400 |
} |
| 1401 |
} |
| 1402 |
}); |
| 1403 |
}; |
| 1404 |
Subject.prototype.error = function (err) { |
| 1405 |
var _this = this; |
| 1406 |
errorContext(function () { |
| 1407 |
_this._throwIfClosed(); |
| 1408 |
if (!_this.isStopped) { |
| 1409 |
_this.hasError = _this.isStopped = true; |
| 1410 |
_this.thrownError = err; |
| 1411 |
var observers = _this.observers; |
| 1412 |
while (observers.length) { |
| 1413 |
observers.shift().error(err); |
| 1414 |
} |
| 1415 |
} |
| 1416 |
}); |
| 1417 |
}; |
| 1418 |
Subject.prototype.complete = function () { |
| 1419 |
var _this = this; |
| 1420 |
errorContext(function () { |
| 1421 |
_this._throwIfClosed(); |
| 1422 |
if (!_this.isStopped) { |
| 1423 |
_this.isStopped = true; |
| 1424 |
var observers = _this.observers; |
| 1425 |
while (observers.length) { |
| 1426 |
observers.shift().complete(); |
| 1427 |
} |
| 1428 |
} |
| 1429 |
}); |
| 1430 |
}; |
| 1431 |
Subject.prototype.unsubscribe = function () { |
| 1432 |
this.isStopped = this.closed = true; |
| 1433 |
this.observers = this.currentObservers = null; |
| 1434 |
}; |
| 1435 |
Object.defineProperty(Subject.prototype, "observed", { |
| 1436 |
get: function () { |
| 1437 |
var _a; |
| 1438 |
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0; |
| 1439 |
}, |
| 1440 |
enumerable: false, |
| 1441 |
configurable: true |
| 1442 |
}); |
| 1443 |
Subject.prototype._trySubscribe = function (subscriber) { |
| 1444 |
this._throwIfClosed(); |
| 1445 |
return _super.prototype._trySubscribe.call(this, subscriber); |
| 1446 |
}; |
| 1447 |
Subject.prototype._subscribe = function (subscriber) { |
| 1448 |
this._throwIfClosed(); |
| 1449 |
this._checkFinalizedStatuses(subscriber); |
| 1450 |
return this._innerSubscribe(subscriber); |
| 1451 |
}; |
| 1452 |
Subject.prototype._innerSubscribe = function (subscriber) { |
| 1453 |
var _this = this; |
| 1454 |
var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers; |
| 1455 |
if (hasError || isStopped) { |
| 1456 |
return EMPTY_SUBSCRIPTION; |
| 1457 |
} |
| 1458 |
this.currentObservers = null; |
| 1459 |
observers.push(subscriber); |
| 1460 |
return new Subscription(function () { |
| 1461 |
_this.currentObservers = null; |
| 1462 |
arrRemove(observers, subscriber); |
| 1463 |
}); |
| 1464 |
}; |
| 1465 |
Subject.prototype._checkFinalizedStatuses = function (subscriber) { |
| 1466 |
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped; |
| 1467 |
if (hasError) { |
| 1468 |
subscriber.error(thrownError); |
| 1469 |
} |
| 1470 |
else if (isStopped) { |
| 1471 |
subscriber.complete(); |
| 1472 |
} |
| 1473 |
}; |
| 1474 |
Subject.prototype.asObservable = function () { |
| 1475 |
var observable = new Observable(); |
| 1476 |
observable.source = this; |
| 1477 |
return observable; |
| 1478 |
}; |
| 1479 |
Subject.create = function (destination, source) { |
| 1480 |
return new AnonymousSubject(destination, source); |
| 1481 |
}; |
| 1482 |
return Subject; |
| 1483 |
}(Observable)); |
| 1484 |
var AnonymousSubject = (function (_super) { |
| 1485 |
__extends(AnonymousSubject, _super); |
| 1486 |
function AnonymousSubject(destination, source) { |
| 1487 |
var _this = _super.call(this) || this; |
| 1488 |
_this.destination = destination; |
| 1489 |
_this.source = source; |
| 1490 |
return _this; |
| 1491 |
} |
| 1492 |
AnonymousSubject.prototype.next = function (value) { |
| 1493 |
var _a, _b; |
| 1494 |
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value); |
| 1495 |
}; |
| 1496 |
AnonymousSubject.prototype.error = function (err) { |
| 1497 |
var _a, _b; |
| 1498 |
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err); |
| 1499 |
}; |
| 1500 |
AnonymousSubject.prototype.complete = function () { |
| 1501 |
var _a, _b; |
| 1502 |
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a); |
| 1503 |
}; |
| 1504 |
AnonymousSubject.prototype._subscribe = function (subscriber) { |
| 1505 |
var _a, _b; |
| 1506 |
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION; |
| 1507 |
}; |
| 1508 |
return AnonymousSubject; |
| 1509 |
}(Subject)); |
| 1510 |
|
| 1511 |
var BehaviorSubject = (function (_super) { |
| 1512 |
__extends(BehaviorSubject, _super); |
| 1513 |
function BehaviorSubject(_value) { |
| 1514 |
var _this = _super.call(this) || this; |
| 1515 |
_this._value = _value; |
| 1516 |
return _this; |
| 1517 |
} |
| 1518 |
Object.defineProperty(BehaviorSubject.prototype, "value", { |
| 1519 |
get: function () { |
| 1520 |
return this.getValue(); |
| 1521 |
}, |
| 1522 |
enumerable: false, |
| 1523 |
configurable: true |
| 1524 |
}); |
| 1525 |
BehaviorSubject.prototype._subscribe = function (subscriber) { |
| 1526 |
var subscription = _super.prototype._subscribe.call(this, subscriber); |
| 1527 |
!subscription.closed && subscriber.next(this._value); |
| 1528 |
return subscription; |
| 1529 |
}; |
| 1530 |
BehaviorSubject.prototype.getValue = function () { |
| 1531 |
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, _value = _a._value; |
| 1532 |
if (hasError) { |
| 1533 |
throw thrownError; |
| 1534 |
} |
| 1535 |
this._throwIfClosed(); |
| 1536 |
return _value; |
| 1537 |
}; |
| 1538 |
BehaviorSubject.prototype.next = function (value) { |
| 1539 |
_super.prototype.next.call(this, (this._value = value)); |
| 1540 |
}; |
| 1541 |
return BehaviorSubject; |
| 1542 |
}(Subject)); |
| 1543 |
|
| 1544 |
var dateTimestampProvider = { |
| 1545 |
now: function () { |
| 1546 |
return (dateTimestampProvider.delegate || Date).now(); |
| 1547 |
}, |
| 1548 |
delegate: undefined, |
| 1549 |
}; |
| 1550 |
|
| 1551 |
var ReplaySubject = (function (_super) { |
| 1552 |
__extends(ReplaySubject, _super); |
| 1553 |
function ReplaySubject(_bufferSize, _windowTime, _timestampProvider) { |
| 1554 |
if (_bufferSize === void 0) { _bufferSize = Infinity; } |
| 1555 |
if (_windowTime === void 0) { _windowTime = Infinity; } |
| 1556 |
if (_timestampProvider === void 0) { _timestampProvider = dateTimestampProvider; } |
| 1557 |
var _this = _super.call(this) || this; |
| 1558 |
_this._bufferSize = _bufferSize; |
| 1559 |
_this._windowTime = _windowTime; |
| 1560 |
_this._timestampProvider = _timestampProvider; |
| 1561 |
_this._buffer = []; |
| 1562 |
_this._infiniteTimeWindow = true; |
| 1563 |
_this._infiniteTimeWindow = _windowTime === Infinity; |
| 1564 |
_this._bufferSize = Math.max(1, _bufferSize); |
| 1565 |
_this._windowTime = Math.max(1, _windowTime); |
| 1566 |
return _this; |
| 1567 |
} |
| 1568 |
ReplaySubject.prototype.next = function (value) { |
| 1569 |
var _a = this, isStopped = _a.isStopped, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow, _timestampProvider = _a._timestampProvider, _windowTime = _a._windowTime; |
| 1570 |
if (!isStopped) { |
| 1571 |
_buffer.push(value); |
| 1572 |
!_infiniteTimeWindow && _buffer.push(_timestampProvider.now() + _windowTime); |
| 1573 |
} |
| 1574 |
this._trimBuffer(); |
| 1575 |
_super.prototype.next.call(this, value); |
| 1576 |
}; |
| 1577 |
ReplaySubject.prototype._subscribe = function (subscriber) { |
| 1578 |
this._throwIfClosed(); |
| 1579 |
this._trimBuffer(); |
| 1580 |
var subscription = this._innerSubscribe(subscriber); |
| 1581 |
var _a = this, _infiniteTimeWindow = _a._infiniteTimeWindow, _buffer = _a._buffer; |
| 1582 |
var copy = _buffer.slice(); |
| 1583 |
for (var i = 0; i < copy.length && !subscriber.closed; i += _infiniteTimeWindow ? 1 : 2) { |
| 1584 |
subscriber.next(copy[i]); |
| 1585 |
} |
| 1586 |
this._checkFinalizedStatuses(subscriber); |
| 1587 |
return subscription; |
| 1588 |
}; |
| 1589 |
ReplaySubject.prototype._trimBuffer = function () { |
| 1590 |
var _a = this, _bufferSize = _a._bufferSize, _timestampProvider = _a._timestampProvider, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow; |
| 1591 |
var adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize; |
| 1592 |
_bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize); |
| 1593 |
if (!_infiniteTimeWindow) { |
| 1594 |
var now = _timestampProvider.now(); |
| 1595 |
var last = 0; |
| 1596 |
for (var i = 1; i < _buffer.length && _buffer[i] <= now; i += 2) { |
| 1597 |
last = i; |
| 1598 |
} |
| 1599 |
last && _buffer.splice(0, last + 1); |
| 1600 |
} |
| 1601 |
}; |
| 1602 |
return ReplaySubject; |
| 1603 |
}(Subject)); |
| 1604 |
|
| 1605 |
var AsyncSubject = (function (_super) { |
| 1606 |
__extends(AsyncSubject, _super); |
| 1607 |
function AsyncSubject() { |
| 1608 |
var _this = _super !== null && _super.apply(this, arguments) || this; |
| 1609 |
_this._value = null; |
| 1610 |
_this._hasValue = false; |
| 1611 |
_this._isComplete = false; |
| 1612 |
return _this; |
| 1613 |
} |
| 1614 |
AsyncSubject.prototype._checkFinalizedStatuses = function (subscriber) { |
| 1615 |
var _a = this, hasError = _a.hasError, _hasValue = _a._hasValue, _value = _a._value, thrownError = _a.thrownError, isStopped = _a.isStopped, _isComplete = _a._isComplete; |
| 1616 |
if (hasError) { |
| 1617 |
subscriber.error(thrownError); |
| 1618 |
} |
| 1619 |
else if (isStopped || _isComplete) { |
| 1620 |
_hasValue && subscriber.next(_value); |
| 1621 |
subscriber.complete(); |
| 1622 |
} |
| 1623 |
}; |
| 1624 |
AsyncSubject.prototype.next = function (value) { |
| 1625 |
if (!this.isStopped) { |
| 1626 |
this._value = value; |
| 1627 |
this._hasValue = true; |
| 1628 |
} |
| 1629 |
}; |
| 1630 |
AsyncSubject.prototype.complete = function () { |
| 1631 |
var _a = this, _hasValue = _a._hasValue, _value = _a._value, _isComplete = _a._isComplete; |
| 1632 |
if (!_isComplete) { |
| 1633 |
this._isComplete = true; |
| 1634 |
_hasValue && _super.prototype.next.call(this, _value); |
| 1635 |
_super.prototype.complete.call(this); |
| 1636 |
} |
| 1637 |
}; |
| 1638 |
return AsyncSubject; |
| 1639 |
}(Subject)); |
| 1640 |
|
| 1641 |
var Action = (function (_super) { |
| 1642 |
__extends(Action, _super); |
| 1643 |
function Action(scheduler, work) { |
| 1644 |
return _super.call(this) || this; |
| 1645 |
} |
| 1646 |
Action.prototype.schedule = function (state, delay) { |
| 1647 |
if (delay === void 0) { delay = 0; } |
| 1648 |
return this; |
| 1649 |
}; |
| 1650 |
return Action; |
| 1651 |
}(Subscription)); |
| 1652 |
|
| 1653 |
var intervalProvider = { |
| 1654 |
setInterval: function (handler, timeout) { |
| 1655 |
var args = []; |
| 1656 |
for (var _i = 2; _i < arguments.length; _i++) { |
| 1657 |
args[_i - 2] = arguments[_i]; |
| 1658 |
} |
| 1659 |
var delegate = intervalProvider.delegate; |
| 1660 |
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) { |
| 1661 |
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args))); |
| 1662 |
} |
| 1663 |
return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args))); |
| 1664 |
}, |
| 1665 |
clearInterval: function (handle) { |
| 1666 |
var delegate = intervalProvider.delegate; |
| 1667 |
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearInterval) || clearInterval)(handle); |
| 1668 |
}, |
| 1669 |
delegate: undefined, |
| 1670 |
}; |
| 1671 |
|
| 1672 |
var AsyncAction = (function (_super) { |
| 1673 |
__extends(AsyncAction, _super); |
| 1674 |
function AsyncAction(scheduler, work) { |
| 1675 |
var _this = _super.call(this, scheduler, work) || this; |
| 1676 |
_this.scheduler = scheduler; |
| 1677 |
_this.work = work; |
| 1678 |
_this.pending = false; |
| 1679 |
return _this; |
| 1680 |
} |
| 1681 |
AsyncAction.prototype.schedule = function (state, delay) { |
| 1682 |
var _a; |
| 1683 |
if (delay === void 0) { delay = 0; } |
| 1684 |
if (this.closed) { |
| 1685 |
return this; |
| 1686 |
} |
| 1687 |
this.state = state; |
| 1688 |
var id = this.id; |
| 1689 |
var scheduler = this.scheduler; |
| 1690 |
if (id != null) { |
| 1691 |
this.id = this.recycleAsyncId(scheduler, id, delay); |
| 1692 |
} |
| 1693 |
this.pending = true; |
| 1694 |
this.delay = delay; |
| 1695 |
this.id = (_a = this.id) !== null && _a !== void 0 ? _a : this.requestAsyncId(scheduler, this.id, delay); |
| 1696 |
return this; |
| 1697 |
}; |
| 1698 |
AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) { |
| 1699 |
if (delay === void 0) { delay = 0; } |
| 1700 |
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay); |
| 1701 |
}; |
| 1702 |
AsyncAction.prototype.recycleAsyncId = function (_scheduler, id, delay) { |
| 1703 |
if (delay === void 0) { delay = 0; } |
| 1704 |
if (delay != null && this.delay === delay && this.pending === false) { |
| 1705 |
return id; |
| 1706 |
} |
| 1707 |
if (id != null) { |
| 1708 |
intervalProvider.clearInterval(id); |
| 1709 |
} |
| 1710 |
return undefined; |
| 1711 |
}; |
| 1712 |
AsyncAction.prototype.execute = function (state, delay) { |
| 1713 |
if (this.closed) { |
| 1714 |
return new Error('executing a cancelled action'); |
| 1715 |
} |
| 1716 |
this.pending = false; |
| 1717 |
var error = this._execute(state, delay); |
| 1718 |
if (error) { |
| 1719 |
return error; |
| 1720 |
} |
| 1721 |
else if (this.pending === false && this.id != null) { |
| 1722 |
this.id = this.recycleAsyncId(this.scheduler, this.id, null); |
| 1723 |
} |
| 1724 |
}; |
| 1725 |
AsyncAction.prototype._execute = function (state, _delay) { |
| 1726 |
var errored = false; |
| 1727 |
var errorValue; |
| 1728 |
try { |
| 1729 |
this.work(state); |
| 1730 |
} |
| 1731 |
catch (e) { |
| 1732 |
errored = true; |
| 1733 |
errorValue = e ? e : new Error('Scheduled action threw falsy error'); |
| 1734 |
} |
| 1735 |
if (errored) { |
| 1736 |
this.unsubscribe(); |
| 1737 |
return errorValue; |
| 1738 |
} |
| 1739 |
}; |
| 1740 |
AsyncAction.prototype.unsubscribe = function () { |
| 1741 |
if (!this.closed) { |
| 1742 |
var _a = this, id = _a.id, scheduler = _a.scheduler; |
| 1743 |
var actions = scheduler.actions; |
| 1744 |
this.work = this.state = this.scheduler = null; |
| 1745 |
this.pending = false; |
| 1746 |
arrRemove(actions, this); |
| 1747 |
if (id != null) { |
| 1748 |
this.id = this.recycleAsyncId(scheduler, id, null); |
| 1749 |
} |
| 1750 |
this.delay = null; |
| 1751 |
_super.prototype.unsubscribe.call(this); |
| 1752 |
} |
| 1753 |
}; |
| 1754 |
return AsyncAction; |
| 1755 |
}(Action)); |
| 1756 |
|
| 1757 |
var nextHandle = 1; |
| 1758 |
var resolved; |
| 1759 |
var activeHandles = {}; |
| 1760 |
function findAndClearHandle(handle) { |
| 1761 |
if (handle in activeHandles) { |
| 1762 |
delete activeHandles[handle]; |
| 1763 |
return true; |
| 1764 |
} |
| 1765 |
return false; |
| 1766 |
} |
| 1767 |
var Immediate = { |
| 1768 |
setImmediate: function (cb) { |
| 1769 |
var handle = nextHandle++; |
| 1770 |
activeHandles[handle] = true; |
| 1771 |
if (!resolved) { |
| 1772 |
resolved = Promise.resolve(); |
| 1773 |
} |
| 1774 |
resolved.then(function () { return findAndClearHandle(handle) && cb(); }); |
| 1775 |
return handle; |
| 1776 |
}, |
| 1777 |
clearImmediate: function (handle) { |
| 1778 |
findAndClearHandle(handle); |
| 1779 |
}, |
| 1780 |
}; |
| 1781 |
|
| 1782 |
var setImmediate = Immediate.setImmediate, clearImmediate = Immediate.clearImmediate; |
| 1783 |
var immediateProvider = { |
| 1784 |
setImmediate: function () { |
| 1785 |
var args = []; |
| 1786 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 1787 |
args[_i] = arguments[_i]; |
| 1788 |
} |
| 1789 |
var delegate = immediateProvider.delegate; |
| 1790 |
return ((delegate === null || delegate === void 0 ? void 0 : delegate.setImmediate) || setImmediate).apply(void 0, __spreadArray([], __read(args))); |
| 1791 |
}, |
| 1792 |
clearImmediate: function (handle) { |
| 1793 |
var delegate = immediateProvider.delegate; |
| 1794 |
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearImmediate) || clearImmediate)(handle); |
| 1795 |
}, |
| 1796 |
delegate: undefined, |
| 1797 |
}; |
| 1798 |
|
| 1799 |
var AsapAction = (function (_super) { |
| 1800 |
__extends(AsapAction, _super); |
| 1801 |
function AsapAction(scheduler, work) { |
| 1802 |
var _this = _super.call(this, scheduler, work) || this; |
| 1803 |
_this.scheduler = scheduler; |
| 1804 |
_this.work = work; |
| 1805 |
return _this; |
| 1806 |
} |
| 1807 |
AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) { |
| 1808 |
if (delay === void 0) { delay = 0; } |
| 1809 |
if (delay !== null && delay > 0) { |
| 1810 |
return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); |
| 1811 |
} |
| 1812 |
scheduler.actions.push(this); |
| 1813 |
return scheduler._scheduled || (scheduler._scheduled = immediateProvider.setImmediate(scheduler.flush.bind(scheduler, undefined))); |
| 1814 |
}; |
| 1815 |
AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) { |
| 1816 |
var _a; |
| 1817 |
if (delay === void 0) { delay = 0; } |
| 1818 |
if (delay != null ? delay > 0 : this.delay > 0) { |
| 1819 |
return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); |
| 1820 |
} |
| 1821 |
var actions = scheduler.actions; |
| 1822 |
if (id != null && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) { |
| 1823 |
immediateProvider.clearImmediate(id); |
| 1824 |
if (scheduler._scheduled === id) { |
| 1825 |
scheduler._scheduled = undefined; |
| 1826 |
} |
| 1827 |
} |
| 1828 |
return undefined; |
| 1829 |
}; |
| 1830 |
return AsapAction; |
| 1831 |
}(AsyncAction)); |
| 1832 |
|
| 1833 |
var Scheduler = (function () { |
| 1834 |
function Scheduler(schedulerActionCtor, now) { |
| 1835 |
if (now === void 0) { now = Scheduler.now; } |
| 1836 |
this.schedulerActionCtor = schedulerActionCtor; |
| 1837 |
this.now = now; |
| 1838 |
} |
| 1839 |
Scheduler.prototype.schedule = function (work, delay, state) { |
| 1840 |
if (delay === void 0) { delay = 0; } |
| 1841 |
return new this.schedulerActionCtor(this, work).schedule(state, delay); |
| 1842 |
}; |
| 1843 |
Scheduler.now = dateTimestampProvider.now; |
| 1844 |
return Scheduler; |
| 1845 |
}()); |
| 1846 |
|
| 1847 |
var AsyncScheduler = (function (_super) { |
| 1848 |
__extends(AsyncScheduler, _super); |
| 1849 |
function AsyncScheduler(SchedulerAction, now) { |
| 1850 |
if (now === void 0) { now = Scheduler.now; } |
| 1851 |
var _this = _super.call(this, SchedulerAction, now) || this; |
| 1852 |
_this.actions = []; |
| 1853 |
_this._active = false; |
| 1854 |
return _this; |
| 1855 |
} |
| 1856 |
AsyncScheduler.prototype.flush = function (action) { |
| 1857 |
var actions = this.actions; |
| 1858 |
if (this._active) { |
| 1859 |
actions.push(action); |
| 1860 |
return; |
| 1861 |
} |
| 1862 |
var error; |
| 1863 |
this._active = true; |
| 1864 |
do { |
| 1865 |
if ((error = action.execute(action.state, action.delay))) { |
| 1866 |
break; |
| 1867 |
} |
| 1868 |
} while ((action = actions.shift())); |
| 1869 |
this._active = false; |
| 1870 |
if (error) { |
| 1871 |
while ((action = actions.shift())) { |
| 1872 |
action.unsubscribe(); |
| 1873 |
} |
| 1874 |
throw error; |
| 1875 |
} |
| 1876 |
}; |
| 1877 |
return AsyncScheduler; |
| 1878 |
}(Scheduler)); |
| 1879 |
|
| 1880 |
var AsapScheduler = (function (_super) { |
| 1881 |
__extends(AsapScheduler, _super); |
| 1882 |
function AsapScheduler() { |
| 1883 |
return _super !== null && _super.apply(this, arguments) || this; |
| 1884 |
} |
| 1885 |
AsapScheduler.prototype.flush = function (action) { |
| 1886 |
this._active = true; |
| 1887 |
var flushId = this._scheduled; |
| 1888 |
this._scheduled = undefined; |
| 1889 |
var actions = this.actions; |
| 1890 |
var error; |
| 1891 |
action = action || actions.shift(); |
| 1892 |
do { |
| 1893 |
if ((error = action.execute(action.state, action.delay))) { |
| 1894 |
break; |
| 1895 |
} |
| 1896 |
} while ((action = actions[0]) && action.id === flushId && actions.shift()); |
| 1897 |
this._active = false; |
| 1898 |
if (error) { |
| 1899 |
while ((action = actions[0]) && action.id === flushId && actions.shift()) { |
| 1900 |
action.unsubscribe(); |
| 1901 |
} |
| 1902 |
throw error; |
| 1903 |
} |
| 1904 |
}; |
| 1905 |
return AsapScheduler; |
| 1906 |
}(AsyncScheduler)); |
| 1907 |
|
| 1908 |
var asapScheduler = new AsapScheduler(AsapAction); |
| 1909 |
var asap = asapScheduler; |
| 1910 |
|
| 1911 |
var asyncScheduler = new AsyncScheduler(AsyncAction); |
| 1912 |
var async = asyncScheduler; |
| 1913 |
|
| 1914 |
var QueueAction = (function (_super) { |
| 1915 |
__extends(QueueAction, _super); |
| 1916 |
function QueueAction(scheduler, work) { |
| 1917 |
var _this = _super.call(this, scheduler, work) || this; |
| 1918 |
_this.scheduler = scheduler; |
| 1919 |
_this.work = work; |
| 1920 |
return _this; |
| 1921 |
} |
| 1922 |
QueueAction.prototype.schedule = function (state, delay) { |
| 1923 |
if (delay === void 0) { delay = 0; } |
| 1924 |
if (delay > 0) { |
| 1925 |
return _super.prototype.schedule.call(this, state, delay); |
| 1926 |
} |
| 1927 |
this.delay = delay; |
| 1928 |
this.state = state; |
| 1929 |
this.scheduler.flush(this); |
| 1930 |
return this; |
| 1931 |
}; |
| 1932 |
QueueAction.prototype.execute = function (state, delay) { |
| 1933 |
return delay > 0 || this.closed ? _super.prototype.execute.call(this, state, delay) : this._execute(state, delay); |
| 1934 |
}; |
| 1935 |
QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) { |
| 1936 |
if (delay === void 0) { delay = 0; } |
| 1937 |
if ((delay != null && delay > 0) || (delay == null && this.delay > 0)) { |
| 1938 |
return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); |
| 1939 |
} |
| 1940 |
scheduler.flush(this); |
| 1941 |
return 0; |
| 1942 |
}; |
| 1943 |
return QueueAction; |
| 1944 |
}(AsyncAction)); |
| 1945 |
|
| 1946 |
var QueueScheduler = (function (_super) { |
| 1947 |
__extends(QueueScheduler, _super); |
| 1948 |
function QueueScheduler() { |
| 1949 |
return _super !== null && _super.apply(this, arguments) || this; |
| 1950 |
} |
| 1951 |
return QueueScheduler; |
| 1952 |
}(AsyncScheduler)); |
| 1953 |
|
| 1954 |
var queueScheduler = new QueueScheduler(QueueAction); |
| 1955 |
var queue = queueScheduler; |
| 1956 |
|
| 1957 |
var AnimationFrameAction = (function (_super) { |
| 1958 |
__extends(AnimationFrameAction, _super); |
| 1959 |
function AnimationFrameAction(scheduler, work) { |
| 1960 |
var _this = _super.call(this, scheduler, work) || this; |
| 1961 |
_this.scheduler = scheduler; |
| 1962 |
_this.work = work; |
| 1963 |
return _this; |
| 1964 |
} |
| 1965 |
AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) { |
| 1966 |
if (delay === void 0) { delay = 0; } |
| 1967 |
if (delay !== null && delay > 0) { |
| 1968 |
return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); |
| 1969 |
} |
| 1970 |
scheduler.actions.push(this); |
| 1971 |
return scheduler._scheduled || (scheduler._scheduled = animationFrameProvider.requestAnimationFrame(function () { return scheduler.flush(undefined); })); |
| 1972 |
}; |
| 1973 |
AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) { |
| 1974 |
var _a; |
| 1975 |
if (delay === void 0) { delay = 0; } |
| 1976 |
if (delay != null ? delay > 0 : this.delay > 0) { |
| 1977 |
return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); |
| 1978 |
} |
| 1979 |
var actions = scheduler.actions; |
| 1980 |
if (id != null && id === scheduler._scheduled && ((_a = actions[actions.length - 1]) === null || _a === void 0 ? void 0 : _a.id) !== id) { |
| 1981 |
animationFrameProvider.cancelAnimationFrame(id); |
| 1982 |
scheduler._scheduled = undefined; |
| 1983 |
} |
| 1984 |
return undefined; |
| 1985 |
}; |
| 1986 |
return AnimationFrameAction; |
| 1987 |
}(AsyncAction)); |
| 1988 |
|
| 1989 |
var AnimationFrameScheduler = (function (_super) { |
| 1990 |
__extends(AnimationFrameScheduler, _super); |
| 1991 |
function AnimationFrameScheduler() { |
| 1992 |
return _super !== null && _super.apply(this, arguments) || this; |
| 1993 |
} |
| 1994 |
AnimationFrameScheduler.prototype.flush = function (action) { |
| 1995 |
this._active = true; |
| 1996 |
var flushId; |
| 1997 |
if (action) { |
| 1998 |
flushId = action.id; |
| 1999 |
} |
| 2000 |
else { |
| 2001 |
flushId = this._scheduled; |
| 2002 |
this._scheduled = undefined; |
| 2003 |
} |
| 2004 |
var actions = this.actions; |
| 2005 |
var error; |
| 2006 |
action = action || actions.shift(); |
| 2007 |
do { |
| 2008 |
if ((error = action.execute(action.state, action.delay))) { |
| 2009 |
break; |
| 2010 |
} |
| 2011 |
} while ((action = actions[0]) && action.id === flushId && actions.shift()); |
| 2012 |
this._active = false; |
| 2013 |
if (error) { |
| 2014 |
while ((action = actions[0]) && action.id === flushId && actions.shift()) { |
| 2015 |
action.unsubscribe(); |
| 2016 |
} |
| 2017 |
throw error; |
| 2018 |
} |
| 2019 |
}; |
| 2020 |
return AnimationFrameScheduler; |
| 2021 |
}(AsyncScheduler)); |
| 2022 |
|
| 2023 |
var animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction); |
| 2024 |
var animationFrame = animationFrameScheduler; |
| 2025 |
|
| 2026 |
var VirtualTimeScheduler = (function (_super) { |
| 2027 |
__extends(VirtualTimeScheduler, _super); |
| 2028 |
function VirtualTimeScheduler(schedulerActionCtor, maxFrames) { |
| 2029 |
if (schedulerActionCtor === void 0) { schedulerActionCtor = VirtualAction; } |
| 2030 |
if (maxFrames === void 0) { maxFrames = Infinity; } |
| 2031 |
var _this = _super.call(this, schedulerActionCtor, function () { return _this.frame; }) || this; |
| 2032 |
_this.maxFrames = maxFrames; |
| 2033 |
_this.frame = 0; |
| 2034 |
_this.index = -1; |
| 2035 |
return _this; |
| 2036 |
} |
| 2037 |
VirtualTimeScheduler.prototype.flush = function () { |
| 2038 |
var _a = this, actions = _a.actions, maxFrames = _a.maxFrames; |
| 2039 |
var error; |
| 2040 |
var action; |
| 2041 |
while ((action = actions[0]) && action.delay <= maxFrames) { |
| 2042 |
actions.shift(); |
| 2043 |
this.frame = action.delay; |
| 2044 |
if ((error = action.execute(action.state, action.delay))) { |
| 2045 |
break; |
| 2046 |
} |
| 2047 |
} |
| 2048 |
if (error) { |
| 2049 |
while ((action = actions.shift())) { |
| 2050 |
action.unsubscribe(); |
| 2051 |
} |
| 2052 |
throw error; |
| 2053 |
} |
| 2054 |
}; |
| 2055 |
VirtualTimeScheduler.frameTimeFactor = 10; |
| 2056 |
return VirtualTimeScheduler; |
| 2057 |
}(AsyncScheduler)); |
| 2058 |
var VirtualAction = (function (_super) { |
| 2059 |
__extends(VirtualAction, _super); |
| 2060 |
function VirtualAction(scheduler, work, index) { |
| 2061 |
if (index === void 0) { index = (scheduler.index += 1); } |
| 2062 |
var _this = _super.call(this, scheduler, work) || this; |
| 2063 |
_this.scheduler = scheduler; |
| 2064 |
_this.work = work; |
| 2065 |
_this.index = index; |
| 2066 |
_this.active = true; |
| 2067 |
_this.index = scheduler.index = index; |
| 2068 |
return _this; |
| 2069 |
} |
| 2070 |
VirtualAction.prototype.schedule = function (state, delay) { |
| 2071 |
if (delay === void 0) { delay = 0; } |
| 2072 |
if (Number.isFinite(delay)) { |
| 2073 |
if (!this.id) { |
| 2074 |
return _super.prototype.schedule.call(this, state, delay); |
| 2075 |
} |
| 2076 |
this.active = false; |
| 2077 |
var action = new VirtualAction(this.scheduler, this.work); |
| 2078 |
this.add(action); |
| 2079 |
return action.schedule(state, delay); |
| 2080 |
} |
| 2081 |
else { |
| 2082 |
return Subscription.EMPTY; |
| 2083 |
} |
| 2084 |
}; |
| 2085 |
VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) { |
| 2086 |
if (delay === void 0) { delay = 0; } |
| 2087 |
this.delay = scheduler.frame + delay; |
| 2088 |
var actions = scheduler.actions; |
| 2089 |
actions.push(this); |
| 2090 |
actions.sort(VirtualAction.sortActions); |
| 2091 |
return 1; |
| 2092 |
}; |
| 2093 |
VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) { |
| 2094 |
if (delay === void 0) { delay = 0; } |
| 2095 |
return undefined; |
| 2096 |
}; |
| 2097 |
VirtualAction.prototype._execute = function (state, delay) { |
| 2098 |
if (this.active === true) { |
| 2099 |
return _super.prototype._execute.call(this, state, delay); |
| 2100 |
} |
| 2101 |
}; |
| 2102 |
VirtualAction.sortActions = function (a, b) { |
| 2103 |
if (a.delay === b.delay) { |
| 2104 |
if (a.index === b.index) { |
| 2105 |
return 0; |
| 2106 |
} |
| 2107 |
else if (a.index > b.index) { |
| 2108 |
return 1; |
| 2109 |
} |
| 2110 |
else { |
| 2111 |
return -1; |
| 2112 |
} |
| 2113 |
} |
| 2114 |
else if (a.delay > b.delay) { |
| 2115 |
return 1; |
| 2116 |
} |
| 2117 |
else { |
| 2118 |
return -1; |
| 2119 |
} |
| 2120 |
}; |
| 2121 |
return VirtualAction; |
| 2122 |
}(AsyncAction)); |
| 2123 |
|
| 2124 |
var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); }); |
| 2125 |
function empty(scheduler) { |
| 2126 |
return scheduler ? emptyScheduled(scheduler) : EMPTY; |
| 2127 |
} |
| 2128 |
function emptyScheduled(scheduler) { |
| 2129 |
return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); }); |
| 2130 |
} |
| 2131 |
|
| 2132 |
function isScheduler(value) { |
| 2133 |
return value && isFunction(value.schedule); |
| 2134 |
} |
| 2135 |
|
| 2136 |
function last(arr) { |
| 2137 |
return arr[arr.length - 1]; |
| 2138 |
} |
| 2139 |
function popResultSelector(args) { |
| 2140 |
return isFunction(last(args)) ? args.pop() : undefined; |
| 2141 |
} |
| 2142 |
function popScheduler(args) { |
| 2143 |
return isScheduler(last(args)) ? args.pop() : undefined; |
| 2144 |
} |
| 2145 |
function popNumber(args, defaultValue) { |
| 2146 |
return typeof last(args) === 'number' ? args.pop() : defaultValue; |
| 2147 |
} |
| 2148 |
|
| 2149 |
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; }); |
| 2150 |
|
| 2151 |
function isPromise(value) { |
| 2152 |
return isFunction(value === null || value === void 0 ? void 0 : value.then); |
| 2153 |
} |
| 2154 |
|
| 2155 |
function isInteropObservable(input) { |
| 2156 |
return isFunction(input[observable]); |
| 2157 |
} |
| 2158 |
|
| 2159 |
function isAsyncIterable(obj) { |
| 2160 |
return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]); |
| 2161 |
} |
| 2162 |
|
| 2163 |
function createInvalidObservableTypeError(input) { |
| 2164 |
return new TypeError("You provided " + (input !== null && typeof input === 'object' ? 'an invalid object' : "'" + input + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable."); |
| 2165 |
} |
| 2166 |
|
| 2167 |
function getSymbolIterator() { |
| 2168 |
if (typeof Symbol !== 'function' || !Symbol.iterator) { |
| 2169 |
return '@@iterator'; |
| 2170 |
} |
| 2171 |
return Symbol.iterator; |
| 2172 |
} |
| 2173 |
var iterator = getSymbolIterator(); |
| 2174 |
|
| 2175 |
function isIterable(input) { |
| 2176 |
return isFunction(input === null || input === void 0 ? void 0 : input[iterator]); |
| 2177 |
} |
| 2178 |
|
| 2179 |
function readableStreamLikeToAsyncGenerator(readableStream) { |
| 2180 |
return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() { |
| 2181 |
var reader, _a, value, done; |
| 2182 |
return __generator(this, function (_b) { |
| 2183 |
switch (_b.label) { |
| 2184 |
case 0: |
| 2185 |
reader = readableStream.getReader(); |
| 2186 |
_b.label = 1; |
| 2187 |
case 1: |
| 2188 |
_b.trys.push([1, , 9, 10]); |
| 2189 |
_b.label = 2; |
| 2190 |
case 2: |
| 2191 |
return [4, __await(reader.read())]; |
| 2192 |
case 3: |
| 2193 |
_a = _b.sent(), value = _a.value, done = _a.done; |
| 2194 |
if (!done) return [3, 5]; |
| 2195 |
return [4, __await(void 0)]; |
| 2196 |
case 4: return [2, _b.sent()]; |
| 2197 |
case 5: return [4, __await(value)]; |
| 2198 |
case 6: return [4, _b.sent()]; |
| 2199 |
case 7: |
| 2200 |
_b.sent(); |
| 2201 |
return [3, 2]; |
| 2202 |
case 8: return [3, 10]; |
| 2203 |
case 9: |
| 2204 |
reader.releaseLock(); |
| 2205 |
return [7]; |
| 2206 |
case 10: return [2]; |
| 2207 |
} |
| 2208 |
}); |
| 2209 |
}); |
| 2210 |
} |
| 2211 |
function isReadableStreamLike(obj) { |
| 2212 |
return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader); |
| 2213 |
} |
| 2214 |
|
| 2215 |
function innerFrom(input) { |
| 2216 |
if (input instanceof Observable) { |
| 2217 |
return input; |
| 2218 |
} |
| 2219 |
if (input != null) { |
| 2220 |
if (isInteropObservable(input)) { |
| 2221 |
return fromInteropObservable(input); |
| 2222 |
} |
| 2223 |
if (isArrayLike(input)) { |
| 2224 |
return fromArrayLike(input); |
| 2225 |
} |
| 2226 |
if (isPromise(input)) { |
| 2227 |
return fromPromise(input); |
| 2228 |
} |
| 2229 |
if (isAsyncIterable(input)) { |
| 2230 |
return fromAsyncIterable(input); |
| 2231 |
} |
| 2232 |
if (isIterable(input)) { |
| 2233 |
return fromIterable(input); |
| 2234 |
} |
| 2235 |
if (isReadableStreamLike(input)) { |
| 2236 |
return fromReadableStreamLike(input); |
| 2237 |
} |
| 2238 |
} |
| 2239 |
throw createInvalidObservableTypeError(input); |
| 2240 |
} |
| 2241 |
function fromInteropObservable(obj) { |
| 2242 |
return new Observable(function (subscriber) { |
| 2243 |
var obs = obj[observable](); |
| 2244 |
if (isFunction(obs.subscribe)) { |
| 2245 |
return obs.subscribe(subscriber); |
| 2246 |
} |
| 2247 |
throw new TypeError('Provided object does not correctly implement Symbol.observable'); |
| 2248 |
}); |
| 2249 |
} |
| 2250 |
function fromArrayLike(array) { |
| 2251 |
return new Observable(function (subscriber) { |
| 2252 |
for (var i = 0; i < array.length && !subscriber.closed; i++) { |
| 2253 |
subscriber.next(array[i]); |
| 2254 |
} |
| 2255 |
subscriber.complete(); |
| 2256 |
}); |
| 2257 |
} |
| 2258 |
function fromPromise(promise) { |
| 2259 |
return new Observable(function (subscriber) { |
| 2260 |
promise |
| 2261 |
.then(function (value) { |
| 2262 |
if (!subscriber.closed) { |
| 2263 |
subscriber.next(value); |
| 2264 |
subscriber.complete(); |
| 2265 |
} |
| 2266 |
}, function (err) { return subscriber.error(err); }) |
| 2267 |
.then(null, reportUnhandledError); |
| 2268 |
}); |
| 2269 |
} |
| 2270 |
function fromIterable(iterable) { |
| 2271 |
return new Observable(function (subscriber) { |
| 2272 |
var e_1, _a; |
| 2273 |
try { |
| 2274 |
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) { |
| 2275 |
var value = iterable_1_1.value; |
| 2276 |
subscriber.next(value); |
| 2277 |
if (subscriber.closed) { |
| 2278 |
return; |
| 2279 |
} |
| 2280 |
} |
| 2281 |
} |
| 2282 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 2283 |
finally { |
| 2284 |
try { |
| 2285 |
if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) _a.call(iterable_1); |
| 2286 |
} |
| 2287 |
finally { if (e_1) throw e_1.error; } |
| 2288 |
} |
| 2289 |
subscriber.complete(); |
| 2290 |
}); |
| 2291 |
} |
| 2292 |
function fromAsyncIterable(asyncIterable) { |
| 2293 |
return new Observable(function (subscriber) { |
| 2294 |
process(asyncIterable, subscriber).catch(function (err) { return subscriber.error(err); }); |
| 2295 |
}); |
| 2296 |
} |
| 2297 |
function fromReadableStreamLike(readableStream) { |
| 2298 |
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream)); |
| 2299 |
} |
| 2300 |
function process(asyncIterable, subscriber) { |
| 2301 |
var asyncIterable_1, asyncIterable_1_1; |
| 2302 |
var e_2, _a; |
| 2303 |
return __awaiter(this, void 0, void 0, function () { |
| 2304 |
var value, e_2_1; |
| 2305 |
return __generator(this, function (_b) { |
| 2306 |
switch (_b.label) { |
| 2307 |
case 0: |
| 2308 |
_b.trys.push([0, 5, 6, 11]); |
| 2309 |
asyncIterable_1 = __asyncValues(asyncIterable); |
| 2310 |
_b.label = 1; |
| 2311 |
case 1: return [4, asyncIterable_1.next()]; |
| 2312 |
case 2: |
| 2313 |
if (!(asyncIterable_1_1 = _b.sent(), !asyncIterable_1_1.done)) return [3, 4]; |
| 2314 |
value = asyncIterable_1_1.value; |
| 2315 |
subscriber.next(value); |
| 2316 |
if (subscriber.closed) { |
| 2317 |
return [2]; |
| 2318 |
} |
| 2319 |
_b.label = 3; |
| 2320 |
case 3: return [3, 1]; |
| 2321 |
case 4: return [3, 11]; |
| 2322 |
case 5: |
| 2323 |
e_2_1 = _b.sent(); |
| 2324 |
e_2 = { error: e_2_1 }; |
| 2325 |
return [3, 11]; |
| 2326 |
case 6: |
| 2327 |
_b.trys.push([6, , 9, 10]); |
| 2328 |
if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return))) return [3, 8]; |
| 2329 |
return [4, _a.call(asyncIterable_1)]; |
| 2330 |
case 7: |
| 2331 |
_b.sent(); |
| 2332 |
_b.label = 8; |
| 2333 |
case 8: return [3, 10]; |
| 2334 |
case 9: |
| 2335 |
if (e_2) throw e_2.error; |
| 2336 |
return [7]; |
| 2337 |
case 10: return [7]; |
| 2338 |
case 11: |
| 2339 |
subscriber.complete(); |
| 2340 |
return [2]; |
| 2341 |
} |
| 2342 |
}); |
| 2343 |
}); |
| 2344 |
} |
| 2345 |
|
| 2346 |
function executeSchedule(parentSubscription, scheduler, work, delay, repeat) { |
| 2347 |
if (delay === void 0) { delay = 0; } |
| 2348 |
if (repeat === void 0) { repeat = false; } |
| 2349 |
var scheduleSubscription = scheduler.schedule(function () { |
| 2350 |
work(); |
| 2351 |
if (repeat) { |
| 2352 |
parentSubscription.add(this.schedule(null, delay)); |
| 2353 |
} |
| 2354 |
else { |
| 2355 |
this.unsubscribe(); |
| 2356 |
} |
| 2357 |
}, delay); |
| 2358 |
parentSubscription.add(scheduleSubscription); |
| 2359 |
if (!repeat) { |
| 2360 |
return scheduleSubscription; |
| 2361 |
} |
| 2362 |
} |
| 2363 |
|
| 2364 |
function observeOn(scheduler, delay) { |
| 2365 |
if (delay === void 0) { delay = 0; } |
| 2366 |
return operate(function (source, subscriber) { |
| 2367 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return executeSchedule(subscriber, scheduler, function () { return subscriber.next(value); }, delay); }, function () { return executeSchedule(subscriber, scheduler, function () { return subscriber.complete(); }, delay); }, function (err) { return executeSchedule(subscriber, scheduler, function () { return subscriber.error(err); }, delay); })); |
| 2368 |
}); |
| 2369 |
} |
| 2370 |
|
| 2371 |
function subscribeOn(scheduler, delay) { |
| 2372 |
if (delay === void 0) { delay = 0; } |
| 2373 |
return operate(function (source, subscriber) { |
| 2374 |
subscriber.add(scheduler.schedule(function () { return source.subscribe(subscriber); }, delay)); |
| 2375 |
}); |
| 2376 |
} |
| 2377 |
|
| 2378 |
function scheduleObservable(input, scheduler) { |
| 2379 |
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler)); |
| 2380 |
} |
| 2381 |
|
| 2382 |
function schedulePromise(input, scheduler) { |
| 2383 |
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler)); |
| 2384 |
} |
| 2385 |
|
| 2386 |
function scheduleArray(input, scheduler) { |
| 2387 |
return new Observable(function (subscriber) { |
| 2388 |
var i = 0; |
| 2389 |
return scheduler.schedule(function () { |
| 2390 |
if (i === input.length) { |
| 2391 |
subscriber.complete(); |
| 2392 |
} |
| 2393 |
else { |
| 2394 |
subscriber.next(input[i++]); |
| 2395 |
if (!subscriber.closed) { |
| 2396 |
this.schedule(); |
| 2397 |
} |
| 2398 |
} |
| 2399 |
}); |
| 2400 |
}); |
| 2401 |
} |
| 2402 |
|
| 2403 |
function scheduleIterable(input, scheduler) { |
| 2404 |
return new Observable(function (subscriber) { |
| 2405 |
var iterator$$1; |
| 2406 |
executeSchedule(subscriber, scheduler, function () { |
| 2407 |
iterator$$1 = input[iterator](); |
| 2408 |
executeSchedule(subscriber, scheduler, function () { |
| 2409 |
var _a; |
| 2410 |
var value; |
| 2411 |
var done; |
| 2412 |
try { |
| 2413 |
(_a = iterator$$1.next(), value = _a.value, done = _a.done); |
| 2414 |
} |
| 2415 |
catch (err) { |
| 2416 |
subscriber.error(err); |
| 2417 |
return; |
| 2418 |
} |
| 2419 |
if (done) { |
| 2420 |
subscriber.complete(); |
| 2421 |
} |
| 2422 |
else { |
| 2423 |
subscriber.next(value); |
| 2424 |
} |
| 2425 |
}, 0, true); |
| 2426 |
}); |
| 2427 |
return function () { return isFunction(iterator$$1 === null || iterator$$1 === void 0 ? void 0 : iterator$$1.return) && iterator$$1.return(); }; |
| 2428 |
}); |
| 2429 |
} |
| 2430 |
|
| 2431 |
function scheduleAsyncIterable(input, scheduler) { |
| 2432 |
if (!input) { |
| 2433 |
throw new Error('Iterable cannot be null'); |
| 2434 |
} |
| 2435 |
return new Observable(function (subscriber) { |
| 2436 |
executeSchedule(subscriber, scheduler, function () { |
| 2437 |
var iterator = input[Symbol.asyncIterator](); |
| 2438 |
executeSchedule(subscriber, scheduler, function () { |
| 2439 |
iterator.next().then(function (result) { |
| 2440 |
if (result.done) { |
| 2441 |
subscriber.complete(); |
| 2442 |
} |
| 2443 |
else { |
| 2444 |
subscriber.next(result.value); |
| 2445 |
} |
| 2446 |
}); |
| 2447 |
}, 0, true); |
| 2448 |
}); |
| 2449 |
}); |
| 2450 |
} |
| 2451 |
|
| 2452 |
function scheduleReadableStreamLike(input, scheduler) { |
| 2453 |
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler); |
| 2454 |
} |
| 2455 |
|
| 2456 |
function scheduled(input, scheduler) { |
| 2457 |
if (input != null) { |
| 2458 |
if (isInteropObservable(input)) { |
| 2459 |
return scheduleObservable(input, scheduler); |
| 2460 |
} |
| 2461 |
if (isArrayLike(input)) { |
| 2462 |
return scheduleArray(input, scheduler); |
| 2463 |
} |
| 2464 |
if (isPromise(input)) { |
| 2465 |
return schedulePromise(input, scheduler); |
| 2466 |
} |
| 2467 |
if (isAsyncIterable(input)) { |
| 2468 |
return scheduleAsyncIterable(input, scheduler); |
| 2469 |
} |
| 2470 |
if (isIterable(input)) { |
| 2471 |
return scheduleIterable(input, scheduler); |
| 2472 |
} |
| 2473 |
if (isReadableStreamLike(input)) { |
| 2474 |
return scheduleReadableStreamLike(input, scheduler); |
| 2475 |
} |
| 2476 |
} |
| 2477 |
throw createInvalidObservableTypeError(input); |
| 2478 |
} |
| 2479 |
|
| 2480 |
function from(input, scheduler) { |
| 2481 |
return scheduler ? scheduled(input, scheduler) : innerFrom(input); |
| 2482 |
} |
| 2483 |
|
| 2484 |
function of() { |
| 2485 |
var args = []; |
| 2486 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 2487 |
args[_i] = arguments[_i]; |
| 2488 |
} |
| 2489 |
var scheduler = popScheduler(args); |
| 2490 |
return from(args, scheduler); |
| 2491 |
} |
| 2492 |
|
| 2493 |
function throwError(errorOrErrorFactory, scheduler) { |
| 2494 |
var errorFactory = isFunction(errorOrErrorFactory) ? errorOrErrorFactory : function () { return errorOrErrorFactory; }; |
| 2495 |
var init = function (subscriber) { return subscriber.error(errorFactory()); }; |
| 2496 |
return new Observable(scheduler ? function (subscriber) { return scheduler.schedule(init, 0, subscriber); } : init); |
| 2497 |
} |
| 2498 |
|
| 2499 |
(function (NotificationKind) { |
| 2500 |
NotificationKind["NEXT"] = "N"; |
| 2501 |
NotificationKind["ERROR"] = "E"; |
| 2502 |
NotificationKind["COMPLETE"] = "C"; |
| 2503 |
})(exports.NotificationKind || (exports.NotificationKind = {})); |
| 2504 |
var Notification = (function () { |
| 2505 |
function Notification(kind, value, error) { |
| 2506 |
this.kind = kind; |
| 2507 |
this.value = value; |
| 2508 |
this.error = error; |
| 2509 |
this.hasValue = kind === 'N'; |
| 2510 |
} |
| 2511 |
Notification.prototype.observe = function (observer) { |
| 2512 |
return observeNotification(this, observer); |
| 2513 |
}; |
| 2514 |
Notification.prototype.do = function (nextHandler, errorHandler, completeHandler) { |
| 2515 |
var _a = this, kind = _a.kind, value = _a.value, error = _a.error; |
| 2516 |
return kind === 'N' ? nextHandler === null || nextHandler === void 0 ? void 0 : nextHandler(value) : kind === 'E' ? errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler(error) : completeHandler === null || completeHandler === void 0 ? void 0 : completeHandler(); |
| 2517 |
}; |
| 2518 |
Notification.prototype.accept = function (nextOrObserver, error, complete) { |
| 2519 |
var _a; |
| 2520 |
return isFunction((_a = nextOrObserver) === null || _a === void 0 ? void 0 : _a.next) |
| 2521 |
? this.observe(nextOrObserver) |
| 2522 |
: this.do(nextOrObserver, error, complete); |
| 2523 |
}; |
| 2524 |
Notification.prototype.toObservable = function () { |
| 2525 |
var _a = this, kind = _a.kind, value = _a.value, error = _a.error; |
| 2526 |
var result = kind === 'N' |
| 2527 |
? |
| 2528 |
of(value) |
| 2529 |
: |
| 2530 |
kind === 'E' |
| 2531 |
? |
| 2532 |
throwError(function () { return error; }) |
| 2533 |
: |
| 2534 |
kind === 'C' |
| 2535 |
? |
| 2536 |
EMPTY |
| 2537 |
: |
| 2538 |
0; |
| 2539 |
if (!result) { |
| 2540 |
throw new TypeError("Unexpected notification kind " + kind); |
| 2541 |
} |
| 2542 |
return result; |
| 2543 |
}; |
| 2544 |
Notification.createNext = function (value) { |
| 2545 |
return new Notification('N', value); |
| 2546 |
}; |
| 2547 |
Notification.createError = function (err) { |
| 2548 |
return new Notification('E', undefined, err); |
| 2549 |
}; |
| 2550 |
Notification.createComplete = function () { |
| 2551 |
return Notification.completeNotification; |
| 2552 |
}; |
| 2553 |
Notification.completeNotification = new Notification('C'); |
| 2554 |
return Notification; |
| 2555 |
}()); |
| 2556 |
function observeNotification(notification, observer) { |
| 2557 |
var _a, _b, _c; |
| 2558 |
var _d = notification, kind = _d.kind, value = _d.value, error = _d.error; |
| 2559 |
if (typeof kind !== 'string') { |
| 2560 |
throw new TypeError('Invalid notification, missing "kind"'); |
| 2561 |
} |
| 2562 |
kind === 'N' ? (_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, value) : kind === 'E' ? (_b = observer.error) === null || _b === void 0 ? void 0 : _b.call(observer, error) : (_c = observer.complete) === null || _c === void 0 ? void 0 : _c.call(observer); |
| 2563 |
} |
| 2564 |
|
| 2565 |
function isObservable(obj) { |
| 2566 |
return !!obj && (obj instanceof Observable || (isFunction(obj.lift) && isFunction(obj.subscribe))); |
| 2567 |
} |
| 2568 |
|
| 2569 |
var EmptyError = createErrorClass(function (_super) { |
| 2570 |
return function EmptyErrorImpl() { |
| 2571 |
_super(this); |
| 2572 |
this.name = 'EmptyError'; |
| 2573 |
this.message = 'no elements in sequence'; |
| 2574 |
}; |
| 2575 |
}); |
| 2576 |
|
| 2577 |
function lastValueFrom(source, config) { |
| 2578 |
var hasConfig = typeof config === 'object'; |
| 2579 |
return new Promise(function (resolve, reject) { |
| 2580 |
var _hasValue = false; |
| 2581 |
var _value; |
| 2582 |
source.subscribe({ |
| 2583 |
next: function (value) { |
| 2584 |
_value = value; |
| 2585 |
_hasValue = true; |
| 2586 |
}, |
| 2587 |
error: reject, |
| 2588 |
complete: function () { |
| 2589 |
if (_hasValue) { |
| 2590 |
resolve(_value); |
| 2591 |
} |
| 2592 |
else if (hasConfig) { |
| 2593 |
resolve(config.defaultValue); |
| 2594 |
} |
| 2595 |
else { |
| 2596 |
reject(new EmptyError()); |
| 2597 |
} |
| 2598 |
}, |
| 2599 |
}); |
| 2600 |
}); |
| 2601 |
} |
| 2602 |
|
| 2603 |
function firstValueFrom(source, config) { |
| 2604 |
var hasConfig = typeof config === 'object'; |
| 2605 |
return new Promise(function (resolve, reject) { |
| 2606 |
var subscriber = new SafeSubscriber({ |
| 2607 |
next: function (value) { |
| 2608 |
resolve(value); |
| 2609 |
subscriber.unsubscribe(); |
| 2610 |
}, |
| 2611 |
error: reject, |
| 2612 |
complete: function () { |
| 2613 |
if (hasConfig) { |
| 2614 |
resolve(config.defaultValue); |
| 2615 |
} |
| 2616 |
else { |
| 2617 |
reject(new EmptyError()); |
| 2618 |
} |
| 2619 |
}, |
| 2620 |
}); |
| 2621 |
source.subscribe(subscriber); |
| 2622 |
}); |
| 2623 |
} |
| 2624 |
|
| 2625 |
var ArgumentOutOfRangeError = createErrorClass(function (_super) { |
| 2626 |
return function ArgumentOutOfRangeErrorImpl() { |
| 2627 |
_super(this); |
| 2628 |
this.name = 'ArgumentOutOfRangeError'; |
| 2629 |
this.message = 'argument out of range'; |
| 2630 |
}; |
| 2631 |
}); |
| 2632 |
|
| 2633 |
var NotFoundError = createErrorClass(function (_super) { |
| 2634 |
return function NotFoundErrorImpl(message) { |
| 2635 |
_super(this); |
| 2636 |
this.name = 'NotFoundError'; |
| 2637 |
this.message = message; |
| 2638 |
}; |
| 2639 |
}); |
| 2640 |
|
| 2641 |
var SequenceError = createErrorClass(function (_super) { |
| 2642 |
return function SequenceErrorImpl(message) { |
| 2643 |
_super(this); |
| 2644 |
this.name = 'SequenceError'; |
| 2645 |
this.message = message; |
| 2646 |
}; |
| 2647 |
}); |
| 2648 |
|
| 2649 |
function isValidDate(value) { |
| 2650 |
return value instanceof Date && !isNaN(value); |
| 2651 |
} |
| 2652 |
|
| 2653 |
var TimeoutError = createErrorClass(function (_super) { |
| 2654 |
return function TimeoutErrorImpl(info) { |
| 2655 |
if (info === void 0) { info = null; } |
| 2656 |
_super(this); |
| 2657 |
this.message = 'Timeout has occurred'; |
| 2658 |
this.name = 'TimeoutError'; |
| 2659 |
this.info = info; |
| 2660 |
}; |
| 2661 |
}); |
| 2662 |
function timeout(config, schedulerArg) { |
| 2663 |
var _a = (isValidDate(config) ? { first: config } : typeof config === 'number' ? { each: config } : config), first = _a.first, each = _a.each, _b = _a.with, _with = _b === void 0 ? timeoutErrorFactory : _b, _c = _a.scheduler, scheduler = _c === void 0 ? schedulerArg !== null && schedulerArg !== void 0 ? schedulerArg : asyncScheduler : _c, _d = _a.meta, meta = _d === void 0 ? null : _d; |
| 2664 |
if (first == null && each == null) { |
| 2665 |
throw new TypeError('No timeout provided.'); |
| 2666 |
} |
| 2667 |
return operate(function (source, subscriber) { |
| 2668 |
var originalSourceSubscription; |
| 2669 |
var timerSubscription; |
| 2670 |
var lastValue = null; |
| 2671 |
var seen = 0; |
| 2672 |
var startTimer = function (delay) { |
| 2673 |
timerSubscription = executeSchedule(subscriber, scheduler, function () { |
| 2674 |
try { |
| 2675 |
originalSourceSubscription.unsubscribe(); |
| 2676 |
innerFrom(_with({ |
| 2677 |
meta: meta, |
| 2678 |
lastValue: lastValue, |
| 2679 |
seen: seen, |
| 2680 |
})).subscribe(subscriber); |
| 2681 |
} |
| 2682 |
catch (err) { |
| 2683 |
subscriber.error(err); |
| 2684 |
} |
| 2685 |
}, delay); |
| 2686 |
}; |
| 2687 |
originalSourceSubscription = source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 2688 |
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe(); |
| 2689 |
seen++; |
| 2690 |
subscriber.next((lastValue = value)); |
| 2691 |
each > 0 && startTimer(each); |
| 2692 |
}, undefined, undefined, function () { |
| 2693 |
if (!(timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.closed)) { |
| 2694 |
timerSubscription === null || timerSubscription === void 0 ? void 0 : timerSubscription.unsubscribe(); |
| 2695 |
} |
| 2696 |
lastValue = null; |
| 2697 |
})); |
| 2698 |
!seen && startTimer(first != null ? (typeof first === 'number' ? first : +first - scheduler.now()) : each); |
| 2699 |
}); |
| 2700 |
} |
| 2701 |
function timeoutErrorFactory(info) { |
| 2702 |
throw new TimeoutError(info); |
| 2703 |
} |
| 2704 |
|
| 2705 |
function map(project, thisArg) { |
| 2706 |
return operate(function (source, subscriber) { |
| 2707 |
var index = 0; |
| 2708 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 2709 |
subscriber.next(project.call(thisArg, value, index++)); |
| 2710 |
})); |
| 2711 |
}); |
| 2712 |
} |
| 2713 |
|
| 2714 |
var isArray = Array.isArray; |
| 2715 |
function callOrApply(fn, args) { |
| 2716 |
return isArray(args) ? fn.apply(void 0, __spreadArray([], __read(args))) : fn(args); |
| 2717 |
} |
| 2718 |
function mapOneOrManyArgs(fn) { |
| 2719 |
return map(function (args) { return callOrApply(fn, args); }); |
| 2720 |
} |
| 2721 |
|
| 2722 |
function bindCallbackInternals(isNodeStyle, callbackFunc, resultSelector, scheduler) { |
| 2723 |
if (resultSelector) { |
| 2724 |
if (isScheduler(resultSelector)) { |
| 2725 |
scheduler = resultSelector; |
| 2726 |
} |
| 2727 |
else { |
| 2728 |
return function () { |
| 2729 |
var args = []; |
| 2730 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 2731 |
args[_i] = arguments[_i]; |
| 2732 |
} |
| 2733 |
return bindCallbackInternals(isNodeStyle, callbackFunc, scheduler) |
| 2734 |
.apply(this, args) |
| 2735 |
.pipe(mapOneOrManyArgs(resultSelector)); |
| 2736 |
}; |
| 2737 |
} |
| 2738 |
} |
| 2739 |
if (scheduler) { |
| 2740 |
return function () { |
| 2741 |
var args = []; |
| 2742 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 2743 |
args[_i] = arguments[_i]; |
| 2744 |
} |
| 2745 |
return bindCallbackInternals(isNodeStyle, callbackFunc) |
| 2746 |
.apply(this, args) |
| 2747 |
.pipe(subscribeOn(scheduler), observeOn(scheduler)); |
| 2748 |
}; |
| 2749 |
} |
| 2750 |
return function () { |
| 2751 |
var _this = this; |
| 2752 |
var args = []; |
| 2753 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 2754 |
args[_i] = arguments[_i]; |
| 2755 |
} |
| 2756 |
var subject = new AsyncSubject(); |
| 2757 |
var uninitialized = true; |
| 2758 |
return new Observable(function (subscriber) { |
| 2759 |
var subs = subject.subscribe(subscriber); |
| 2760 |
if (uninitialized) { |
| 2761 |
uninitialized = false; |
| 2762 |
var isAsync_1 = false; |
| 2763 |
var isComplete_1 = false; |
| 2764 |
callbackFunc.apply(_this, __spreadArray(__spreadArray([], __read(args)), [ |
| 2765 |
function () { |
| 2766 |
var results = []; |
| 2767 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 2768 |
results[_i] = arguments[_i]; |
| 2769 |
} |
| 2770 |
if (isNodeStyle) { |
| 2771 |
var err = results.shift(); |
| 2772 |
if (err != null) { |
| 2773 |
subject.error(err); |
| 2774 |
return; |
| 2775 |
} |
| 2776 |
} |
| 2777 |
subject.next(1 < results.length ? results : results[0]); |
| 2778 |
isComplete_1 = true; |
| 2779 |
if (isAsync_1) { |
| 2780 |
subject.complete(); |
| 2781 |
} |
| 2782 |
}, |
| 2783 |
])); |
| 2784 |
if (isComplete_1) { |
| 2785 |
subject.complete(); |
| 2786 |
} |
| 2787 |
isAsync_1 = true; |
| 2788 |
} |
| 2789 |
return subs; |
| 2790 |
}); |
| 2791 |
}; |
| 2792 |
} |
| 2793 |
|
| 2794 |
function bindCallback(callbackFunc, resultSelector, scheduler) { |
| 2795 |
return bindCallbackInternals(false, callbackFunc, resultSelector, scheduler); |
| 2796 |
} |
| 2797 |
|
| 2798 |
function bindNodeCallback(callbackFunc, resultSelector, scheduler) { |
| 2799 |
return bindCallbackInternals(true, callbackFunc, resultSelector, scheduler); |
| 2800 |
} |
| 2801 |
|
| 2802 |
var isArray$1 = Array.isArray; |
| 2803 |
var getPrototypeOf = Object.getPrototypeOf, objectProto = Object.prototype, getKeys = Object.keys; |
| 2804 |
function argsArgArrayOrObject(args) { |
| 2805 |
if (args.length === 1) { |
| 2806 |
var first_1 = args[0]; |
| 2807 |
if (isArray$1(first_1)) { |
| 2808 |
return { args: first_1, keys: null }; |
| 2809 |
} |
| 2810 |
if (isPOJO(first_1)) { |
| 2811 |
var keys = getKeys(first_1); |
| 2812 |
return { |
| 2813 |
args: keys.map(function (key) { return first_1[key]; }), |
| 2814 |
keys: keys, |
| 2815 |
}; |
| 2816 |
} |
| 2817 |
} |
| 2818 |
return { args: args, keys: null }; |
| 2819 |
} |
| 2820 |
function isPOJO(obj) { |
| 2821 |
return obj && typeof obj === 'object' && getPrototypeOf(obj) === objectProto; |
| 2822 |
} |
| 2823 |
|
| 2824 |
function createObject(keys, values) { |
| 2825 |
return keys.reduce(function (result, key, i) { return ((result[key] = values[i]), result); }, {}); |
| 2826 |
} |
| 2827 |
|
| 2828 |
function combineLatest() { |
| 2829 |
var args = []; |
| 2830 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 2831 |
args[_i] = arguments[_i]; |
| 2832 |
} |
| 2833 |
var scheduler = popScheduler(args); |
| 2834 |
var resultSelector = popResultSelector(args); |
| 2835 |
var _a = argsArgArrayOrObject(args), observables = _a.args, keys = _a.keys; |
| 2836 |
if (observables.length === 0) { |
| 2837 |
return from([], scheduler); |
| 2838 |
} |
| 2839 |
var result = new Observable(combineLatestInit(observables, scheduler, keys |
| 2840 |
? |
| 2841 |
function (values) { return createObject(keys, values); } |
| 2842 |
: |
| 2843 |
identity)); |
| 2844 |
return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result; |
| 2845 |
} |
| 2846 |
function combineLatestInit(observables, scheduler, valueTransform) { |
| 2847 |
if (valueTransform === void 0) { valueTransform = identity; } |
| 2848 |
return function (subscriber) { |
| 2849 |
maybeSchedule(scheduler, function () { |
| 2850 |
var length = observables.length; |
| 2851 |
var values = new Array(length); |
| 2852 |
var active = length; |
| 2853 |
var remainingFirstValues = length; |
| 2854 |
var _loop_1 = function (i) { |
| 2855 |
maybeSchedule(scheduler, function () { |
| 2856 |
var source = from(observables[i], scheduler); |
| 2857 |
var hasFirstValue = false; |
| 2858 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 2859 |
values[i] = value; |
| 2860 |
if (!hasFirstValue) { |
| 2861 |
hasFirstValue = true; |
| 2862 |
remainingFirstValues--; |
| 2863 |
} |
| 2864 |
if (!remainingFirstValues) { |
| 2865 |
subscriber.next(valueTransform(values.slice())); |
| 2866 |
} |
| 2867 |
}, function () { |
| 2868 |
if (!--active) { |
| 2869 |
subscriber.complete(); |
| 2870 |
} |
| 2871 |
})); |
| 2872 |
}, subscriber); |
| 2873 |
}; |
| 2874 |
for (var i = 0; i < length; i++) { |
| 2875 |
_loop_1(i); |
| 2876 |
} |
| 2877 |
}, subscriber); |
| 2878 |
}; |
| 2879 |
} |
| 2880 |
function maybeSchedule(scheduler, execute, subscription) { |
| 2881 |
if (scheduler) { |
| 2882 |
executeSchedule(subscription, scheduler, execute); |
| 2883 |
} |
| 2884 |
else { |
| 2885 |
execute(); |
| 2886 |
} |
| 2887 |
} |
| 2888 |
|
| 2889 |
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) { |
| 2890 |
var buffer = []; |
| 2891 |
var active = 0; |
| 2892 |
var index = 0; |
| 2893 |
var isComplete = false; |
| 2894 |
var checkComplete = function () { |
| 2895 |
if (isComplete && !buffer.length && !active) { |
| 2896 |
subscriber.complete(); |
| 2897 |
} |
| 2898 |
}; |
| 2899 |
var outerNext = function (value) { return (active < concurrent ? doInnerSub(value) : buffer.push(value)); }; |
| 2900 |
var doInnerSub = function (value) { |
| 2901 |
expand && subscriber.next(value); |
| 2902 |
active++; |
| 2903 |
var innerComplete = false; |
| 2904 |
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) { |
| 2905 |
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue); |
| 2906 |
if (expand) { |
| 2907 |
outerNext(innerValue); |
| 2908 |
} |
| 2909 |
else { |
| 2910 |
subscriber.next(innerValue); |
| 2911 |
} |
| 2912 |
}, function () { |
| 2913 |
innerComplete = true; |
| 2914 |
}, undefined, function () { |
| 2915 |
if (innerComplete) { |
| 2916 |
try { |
| 2917 |
active--; |
| 2918 |
var _loop_1 = function () { |
| 2919 |
var bufferedValue = buffer.shift(); |
| 2920 |
if (innerSubScheduler) { |
| 2921 |
executeSchedule(subscriber, innerSubScheduler, function () { return doInnerSub(bufferedValue); }); |
| 2922 |
} |
| 2923 |
else { |
| 2924 |
doInnerSub(bufferedValue); |
| 2925 |
} |
| 2926 |
}; |
| 2927 |
while (buffer.length && active < concurrent) { |
| 2928 |
_loop_1(); |
| 2929 |
} |
| 2930 |
checkComplete(); |
| 2931 |
} |
| 2932 |
catch (err) { |
| 2933 |
subscriber.error(err); |
| 2934 |
} |
| 2935 |
} |
| 2936 |
})); |
| 2937 |
}; |
| 2938 |
source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () { |
| 2939 |
isComplete = true; |
| 2940 |
checkComplete(); |
| 2941 |
})); |
| 2942 |
return function () { |
| 2943 |
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer(); |
| 2944 |
}; |
| 2945 |
} |
| 2946 |
|
| 2947 |
function mergeMap(project, resultSelector, concurrent) { |
| 2948 |
if (concurrent === void 0) { concurrent = Infinity; } |
| 2949 |
if (isFunction(resultSelector)) { |
| 2950 |
return mergeMap(function (a, i) { return map(function (b, ii) { return resultSelector(a, b, i, ii); })(innerFrom(project(a, i))); }, concurrent); |
| 2951 |
} |
| 2952 |
else if (typeof resultSelector === 'number') { |
| 2953 |
concurrent = resultSelector; |
| 2954 |
} |
| 2955 |
return operate(function (source, subscriber) { return mergeInternals(source, subscriber, project, concurrent); }); |
| 2956 |
} |
| 2957 |
|
| 2958 |
function mergeAll(concurrent) { |
| 2959 |
if (concurrent === void 0) { concurrent = Infinity; } |
| 2960 |
return mergeMap(identity, concurrent); |
| 2961 |
} |
| 2962 |
|
| 2963 |
function concatAll() { |
| 2964 |
return mergeAll(1); |
| 2965 |
} |
| 2966 |
|
| 2967 |
function concat() { |
| 2968 |
var args = []; |
| 2969 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 2970 |
args[_i] = arguments[_i]; |
| 2971 |
} |
| 2972 |
return concatAll()(from(args, popScheduler(args))); |
| 2973 |
} |
| 2974 |
|
| 2975 |
function defer(observableFactory) { |
| 2976 |
return new Observable(function (subscriber) { |
| 2977 |
innerFrom(observableFactory()).subscribe(subscriber); |
| 2978 |
}); |
| 2979 |
} |
| 2980 |
|
| 2981 |
var DEFAULT_CONFIG = { |
| 2982 |
connector: function () { return new Subject(); }, |
| 2983 |
resetOnDisconnect: true, |
| 2984 |
}; |
| 2985 |
function connectable(source, config) { |
| 2986 |
if (config === void 0) { config = DEFAULT_CONFIG; } |
| 2987 |
var connection = null; |
| 2988 |
var connector = config.connector, _a = config.resetOnDisconnect, resetOnDisconnect = _a === void 0 ? true : _a; |
| 2989 |
var subject = connector(); |
| 2990 |
var result = new Observable(function (subscriber) { |
| 2991 |
return subject.subscribe(subscriber); |
| 2992 |
}); |
| 2993 |
result.connect = function () { |
| 2994 |
if (!connection || connection.closed) { |
| 2995 |
connection = defer(function () { return source; }).subscribe(subject); |
| 2996 |
if (resetOnDisconnect) { |
| 2997 |
connection.add(function () { return (subject = connector()); }); |
| 2998 |
} |
| 2999 |
} |
| 3000 |
return connection; |
| 3001 |
}; |
| 3002 |
return result; |
| 3003 |
} |
| 3004 |
|
| 3005 |
function forkJoin() { |
| 3006 |
var args = []; |
| 3007 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3008 |
args[_i] = arguments[_i]; |
| 3009 |
} |
| 3010 |
var resultSelector = popResultSelector(args); |
| 3011 |
var _a = argsArgArrayOrObject(args), sources = _a.args, keys = _a.keys; |
| 3012 |
var result = new Observable(function (subscriber) { |
| 3013 |
var length = sources.length; |
| 3014 |
if (!length) { |
| 3015 |
subscriber.complete(); |
| 3016 |
return; |
| 3017 |
} |
| 3018 |
var values = new Array(length); |
| 3019 |
var remainingCompletions = length; |
| 3020 |
var remainingEmissions = length; |
| 3021 |
var _loop_1 = function (sourceIndex) { |
| 3022 |
var hasValue = false; |
| 3023 |
innerFrom(sources[sourceIndex]).subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3024 |
if (!hasValue) { |
| 3025 |
hasValue = true; |
| 3026 |
remainingEmissions--; |
| 3027 |
} |
| 3028 |
values[sourceIndex] = value; |
| 3029 |
}, function () { return remainingCompletions--; }, undefined, function () { |
| 3030 |
if (!remainingCompletions || !hasValue) { |
| 3031 |
if (!remainingEmissions) { |
| 3032 |
subscriber.next(keys ? createObject(keys, values) : values); |
| 3033 |
} |
| 3034 |
subscriber.complete(); |
| 3035 |
} |
| 3036 |
})); |
| 3037 |
}; |
| 3038 |
for (var sourceIndex = 0; sourceIndex < length; sourceIndex++) { |
| 3039 |
_loop_1(sourceIndex); |
| 3040 |
} |
| 3041 |
}); |
| 3042 |
return resultSelector ? result.pipe(mapOneOrManyArgs(resultSelector)) : result; |
| 3043 |
} |
| 3044 |
|
| 3045 |
var nodeEventEmitterMethods = ['addListener', 'removeListener']; |
| 3046 |
var eventTargetMethods = ['addEventListener', 'removeEventListener']; |
| 3047 |
var jqueryMethods = ['on', 'off']; |
| 3048 |
function fromEvent(target, eventName, options, resultSelector) { |
| 3049 |
if (isFunction(options)) { |
| 3050 |
resultSelector = options; |
| 3051 |
options = undefined; |
| 3052 |
} |
| 3053 |
if (resultSelector) { |
| 3054 |
return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector)); |
| 3055 |
} |
| 3056 |
var _a = __read(isEventTarget(target) |
| 3057 |
? eventTargetMethods.map(function (methodName) { return function (handler) { return target[methodName](eventName, handler, options); }; }) |
| 3058 |
: |
| 3059 |
isNodeStyleEventEmitter(target) |
| 3060 |
? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName)) |
| 3061 |
: isJQueryStyleEventEmitter(target) |
| 3062 |
? jqueryMethods.map(toCommonHandlerRegistry(target, eventName)) |
| 3063 |
: [], 2), add = _a[0], remove = _a[1]; |
| 3064 |
if (!add) { |
| 3065 |
if (isArrayLike(target)) { |
| 3066 |
return mergeMap(function (subTarget) { return fromEvent(subTarget, eventName, options); })(innerFrom(target)); |
| 3067 |
} |
| 3068 |
} |
| 3069 |
if (!add) { |
| 3070 |
throw new TypeError('Invalid event target'); |
| 3071 |
} |
| 3072 |
return new Observable(function (subscriber) { |
| 3073 |
var handler = function () { |
| 3074 |
var args = []; |
| 3075 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3076 |
args[_i] = arguments[_i]; |
| 3077 |
} |
| 3078 |
return subscriber.next(1 < args.length ? args : args[0]); |
| 3079 |
}; |
| 3080 |
add(handler); |
| 3081 |
return function () { return remove(handler); }; |
| 3082 |
}); |
| 3083 |
} |
| 3084 |
function toCommonHandlerRegistry(target, eventName) { |
| 3085 |
return function (methodName) { return function (handler) { return target[methodName](eventName, handler); }; }; |
| 3086 |
} |
| 3087 |
function isNodeStyleEventEmitter(target) { |
| 3088 |
return isFunction(target.addListener) && isFunction(target.removeListener); |
| 3089 |
} |
| 3090 |
function isJQueryStyleEventEmitter(target) { |
| 3091 |
return isFunction(target.on) && isFunction(target.off); |
| 3092 |
} |
| 3093 |
function isEventTarget(target) { |
| 3094 |
return isFunction(target.addEventListener) && isFunction(target.removeEventListener); |
| 3095 |
} |
| 3096 |
|
| 3097 |
function fromEventPattern(addHandler, removeHandler, resultSelector) { |
| 3098 |
if (resultSelector) { |
| 3099 |
return fromEventPattern(addHandler, removeHandler).pipe(mapOneOrManyArgs(resultSelector)); |
| 3100 |
} |
| 3101 |
return new Observable(function (subscriber) { |
| 3102 |
var handler = function () { |
| 3103 |
var e = []; |
| 3104 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3105 |
e[_i] = arguments[_i]; |
| 3106 |
} |
| 3107 |
return subscriber.next(e.length === 1 ? e[0] : e); |
| 3108 |
}; |
| 3109 |
var retValue = addHandler(handler); |
| 3110 |
return isFunction(removeHandler) ? function () { return removeHandler(handler, retValue); } : undefined; |
| 3111 |
}); |
| 3112 |
} |
| 3113 |
|
| 3114 |
function generate(initialStateOrOptions, condition, iterate, resultSelectorOrScheduler, scheduler) { |
| 3115 |
var _a, _b; |
| 3116 |
var resultSelector; |
| 3117 |
var initialState; |
| 3118 |
if (arguments.length === 1) { |
| 3119 |
(_a = initialStateOrOptions, initialState = _a.initialState, condition = _a.condition, iterate = _a.iterate, _b = _a.resultSelector, resultSelector = _b === void 0 ? identity : _b, scheduler = _a.scheduler); |
| 3120 |
} |
| 3121 |
else { |
| 3122 |
initialState = initialStateOrOptions; |
| 3123 |
if (!resultSelectorOrScheduler || isScheduler(resultSelectorOrScheduler)) { |
| 3124 |
resultSelector = identity; |
| 3125 |
scheduler = resultSelectorOrScheduler; |
| 3126 |
} |
| 3127 |
else { |
| 3128 |
resultSelector = resultSelectorOrScheduler; |
| 3129 |
} |
| 3130 |
} |
| 3131 |
function gen() { |
| 3132 |
var state; |
| 3133 |
return __generator(this, function (_a) { |
| 3134 |
switch (_a.label) { |
| 3135 |
case 0: |
| 3136 |
state = initialState; |
| 3137 |
_a.label = 1; |
| 3138 |
case 1: |
| 3139 |
if (!(!condition || condition(state))) return [3, 4]; |
| 3140 |
return [4, resultSelector(state)]; |
| 3141 |
case 2: |
| 3142 |
_a.sent(); |
| 3143 |
_a.label = 3; |
| 3144 |
case 3: |
| 3145 |
state = iterate(state); |
| 3146 |
return [3, 1]; |
| 3147 |
case 4: return [2]; |
| 3148 |
} |
| 3149 |
}); |
| 3150 |
} |
| 3151 |
return defer((scheduler |
| 3152 |
? |
| 3153 |
function () { return scheduleIterable(gen(), scheduler); } |
| 3154 |
: |
| 3155 |
gen)); |
| 3156 |
} |
| 3157 |
|
| 3158 |
function iif(condition, trueResult, falseResult) { |
| 3159 |
return defer(function () { return (condition() ? trueResult : falseResult); }); |
| 3160 |
} |
| 3161 |
|
| 3162 |
function timer(dueTime, intervalOrScheduler, scheduler) { |
| 3163 |
if (dueTime === void 0) { dueTime = 0; } |
| 3164 |
if (scheduler === void 0) { scheduler = async; } |
| 3165 |
var intervalDuration = -1; |
| 3166 |
if (intervalOrScheduler != null) { |
| 3167 |
if (isScheduler(intervalOrScheduler)) { |
| 3168 |
scheduler = intervalOrScheduler; |
| 3169 |
} |
| 3170 |
else { |
| 3171 |
intervalDuration = intervalOrScheduler; |
| 3172 |
} |
| 3173 |
} |
| 3174 |
return new Observable(function (subscriber) { |
| 3175 |
var due = isValidDate(dueTime) ? +dueTime - scheduler.now() : dueTime; |
| 3176 |
if (due < 0) { |
| 3177 |
due = 0; |
| 3178 |
} |
| 3179 |
var n = 0; |
| 3180 |
return scheduler.schedule(function () { |
| 3181 |
if (!subscriber.closed) { |
| 3182 |
subscriber.next(n++); |
| 3183 |
if (0 <= intervalDuration) { |
| 3184 |
this.schedule(undefined, intervalDuration); |
| 3185 |
} |
| 3186 |
else { |
| 3187 |
subscriber.complete(); |
| 3188 |
} |
| 3189 |
} |
| 3190 |
}, due); |
| 3191 |
}); |
| 3192 |
} |
| 3193 |
|
| 3194 |
function interval(period, scheduler) { |
| 3195 |
if (period === void 0) { period = 0; } |
| 3196 |
if (scheduler === void 0) { scheduler = asyncScheduler; } |
| 3197 |
if (period < 0) { |
| 3198 |
period = 0; |
| 3199 |
} |
| 3200 |
return timer(period, period, scheduler); |
| 3201 |
} |
| 3202 |
|
| 3203 |
function merge() { |
| 3204 |
var args = []; |
| 3205 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3206 |
args[_i] = arguments[_i]; |
| 3207 |
} |
| 3208 |
var scheduler = popScheduler(args); |
| 3209 |
var concurrent = popNumber(args, Infinity); |
| 3210 |
var sources = args; |
| 3211 |
return !sources.length |
| 3212 |
? |
| 3213 |
EMPTY |
| 3214 |
: sources.length === 1 |
| 3215 |
? |
| 3216 |
innerFrom(sources[0]) |
| 3217 |
: |
| 3218 |
mergeAll(concurrent)(from(sources, scheduler)); |
| 3219 |
} |
| 3220 |
|
| 3221 |
var NEVER = new Observable(noop); |
| 3222 |
function never() { |
| 3223 |
return NEVER; |
| 3224 |
} |
| 3225 |
|
| 3226 |
var isArray$2 = Array.isArray; |
| 3227 |
function argsOrArgArray(args) { |
| 3228 |
return args.length === 1 && isArray$2(args[0]) ? args[0] : args; |
| 3229 |
} |
| 3230 |
|
| 3231 |
function onErrorResumeNext() { |
| 3232 |
var sources = []; |
| 3233 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3234 |
sources[_i] = arguments[_i]; |
| 3235 |
} |
| 3236 |
var nextSources = argsOrArgArray(sources); |
| 3237 |
return new Observable(function (subscriber) { |
| 3238 |
var sourceIndex = 0; |
| 3239 |
var subscribeNext = function () { |
| 3240 |
if (sourceIndex < nextSources.length) { |
| 3241 |
var nextSource = void 0; |
| 3242 |
try { |
| 3243 |
nextSource = innerFrom(nextSources[sourceIndex++]); |
| 3244 |
} |
| 3245 |
catch (err) { |
| 3246 |
subscribeNext(); |
| 3247 |
return; |
| 3248 |
} |
| 3249 |
var innerSubscriber = new OperatorSubscriber(subscriber, undefined, noop, noop); |
| 3250 |
nextSource.subscribe(innerSubscriber); |
| 3251 |
innerSubscriber.add(subscribeNext); |
| 3252 |
} |
| 3253 |
else { |
| 3254 |
subscriber.complete(); |
| 3255 |
} |
| 3256 |
}; |
| 3257 |
subscribeNext(); |
| 3258 |
}); |
| 3259 |
} |
| 3260 |
|
| 3261 |
function pairs(obj, scheduler) { |
| 3262 |
return from(Object.entries(obj), scheduler); |
| 3263 |
} |
| 3264 |
|
| 3265 |
function not(pred, thisArg) { |
| 3266 |
return function (value, index) { return !pred.call(thisArg, value, index); }; |
| 3267 |
} |
| 3268 |
|
| 3269 |
function filter(predicate, thisArg) { |
| 3270 |
return operate(function (source, subscriber) { |
| 3271 |
var index = 0; |
| 3272 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return predicate.call(thisArg, value, index++) && subscriber.next(value); })); |
| 3273 |
}); |
| 3274 |
} |
| 3275 |
|
| 3276 |
function partition(source, predicate, thisArg) { |
| 3277 |
return [filter(predicate, thisArg)(innerFrom(source)), filter(not(predicate, thisArg))(innerFrom(source))]; |
| 3278 |
} |
| 3279 |
|
| 3280 |
function race() { |
| 3281 |
var sources = []; |
| 3282 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3283 |
sources[_i] = arguments[_i]; |
| 3284 |
} |
| 3285 |
sources = argsOrArgArray(sources); |
| 3286 |
return sources.length === 1 ? innerFrom(sources[0]) : new Observable(raceInit(sources)); |
| 3287 |
} |
| 3288 |
function raceInit(sources) { |
| 3289 |
return function (subscriber) { |
| 3290 |
var subscriptions = []; |
| 3291 |
var _loop_1 = function (i) { |
| 3292 |
subscriptions.push(innerFrom(sources[i]).subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3293 |
if (subscriptions) { |
| 3294 |
for (var s = 0; s < subscriptions.length; s++) { |
| 3295 |
s !== i && subscriptions[s].unsubscribe(); |
| 3296 |
} |
| 3297 |
subscriptions = null; |
| 3298 |
} |
| 3299 |
subscriber.next(value); |
| 3300 |
}))); |
| 3301 |
}; |
| 3302 |
for (var i = 0; subscriptions && !subscriber.closed && i < sources.length; i++) { |
| 3303 |
_loop_1(i); |
| 3304 |
} |
| 3305 |
}; |
| 3306 |
} |
| 3307 |
|
| 3308 |
function range(start, count, scheduler) { |
| 3309 |
if (count == null) { |
| 3310 |
count = start; |
| 3311 |
start = 0; |
| 3312 |
} |
| 3313 |
if (count <= 0) { |
| 3314 |
return EMPTY; |
| 3315 |
} |
| 3316 |
var end = count + start; |
| 3317 |
return new Observable(scheduler |
| 3318 |
? |
| 3319 |
function (subscriber) { |
| 3320 |
var n = start; |
| 3321 |
return scheduler.schedule(function () { |
| 3322 |
if (n < end) { |
| 3323 |
subscriber.next(n++); |
| 3324 |
this.schedule(); |
| 3325 |
} |
| 3326 |
else { |
| 3327 |
subscriber.complete(); |
| 3328 |
} |
| 3329 |
}); |
| 3330 |
} |
| 3331 |
: |
| 3332 |
function (subscriber) { |
| 3333 |
var n = start; |
| 3334 |
while (n < end && !subscriber.closed) { |
| 3335 |
subscriber.next(n++); |
| 3336 |
} |
| 3337 |
subscriber.complete(); |
| 3338 |
}); |
| 3339 |
} |
| 3340 |
|
| 3341 |
function using(resourceFactory, observableFactory) { |
| 3342 |
return new Observable(function (subscriber) { |
| 3343 |
var resource = resourceFactory(); |
| 3344 |
var result = observableFactory(resource); |
| 3345 |
var source = result ? innerFrom(result) : EMPTY; |
| 3346 |
source.subscribe(subscriber); |
| 3347 |
return function () { |
| 3348 |
if (resource) { |
| 3349 |
resource.unsubscribe(); |
| 3350 |
} |
| 3351 |
}; |
| 3352 |
}); |
| 3353 |
} |
| 3354 |
|
| 3355 |
function zip() { |
| 3356 |
var args = []; |
| 3357 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3358 |
args[_i] = arguments[_i]; |
| 3359 |
} |
| 3360 |
var resultSelector = popResultSelector(args); |
| 3361 |
var sources = argsOrArgArray(args); |
| 3362 |
return sources.length |
| 3363 |
? new Observable(function (subscriber) { |
| 3364 |
var buffers = sources.map(function () { return []; }); |
| 3365 |
var completed = sources.map(function () { return false; }); |
| 3366 |
subscriber.add(function () { |
| 3367 |
buffers = completed = null; |
| 3368 |
}); |
| 3369 |
var _loop_1 = function (sourceIndex) { |
| 3370 |
innerFrom(sources[sourceIndex]).subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3371 |
buffers[sourceIndex].push(value); |
| 3372 |
if (buffers.every(function (buffer) { return buffer.length; })) { |
| 3373 |
var result = buffers.map(function (buffer) { return buffer.shift(); }); |
| 3374 |
subscriber.next(resultSelector ? resultSelector.apply(void 0, __spreadArray([], __read(result))) : result); |
| 3375 |
if (buffers.some(function (buffer, i) { return !buffer.length && completed[i]; })) { |
| 3376 |
subscriber.complete(); |
| 3377 |
} |
| 3378 |
} |
| 3379 |
}, function () { |
| 3380 |
completed[sourceIndex] = true; |
| 3381 |
!buffers[sourceIndex].length && subscriber.complete(); |
| 3382 |
})); |
| 3383 |
}; |
| 3384 |
for (var sourceIndex = 0; !subscriber.closed && sourceIndex < sources.length; sourceIndex++) { |
| 3385 |
_loop_1(sourceIndex); |
| 3386 |
} |
| 3387 |
return function () { |
| 3388 |
buffers = completed = null; |
| 3389 |
}; |
| 3390 |
}) |
| 3391 |
: EMPTY; |
| 3392 |
} |
| 3393 |
|
| 3394 |
function audit(durationSelector) { |
| 3395 |
return operate(function (source, subscriber) { |
| 3396 |
var hasValue = false; |
| 3397 |
var lastValue = null; |
| 3398 |
var durationSubscriber = null; |
| 3399 |
var isComplete = false; |
| 3400 |
var endDuration = function () { |
| 3401 |
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe(); |
| 3402 |
durationSubscriber = null; |
| 3403 |
if (hasValue) { |
| 3404 |
hasValue = false; |
| 3405 |
var value = lastValue; |
| 3406 |
lastValue = null; |
| 3407 |
subscriber.next(value); |
| 3408 |
} |
| 3409 |
isComplete && subscriber.complete(); |
| 3410 |
}; |
| 3411 |
var cleanupDuration = function () { |
| 3412 |
durationSubscriber = null; |
| 3413 |
isComplete && subscriber.complete(); |
| 3414 |
}; |
| 3415 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3416 |
hasValue = true; |
| 3417 |
lastValue = value; |
| 3418 |
if (!durationSubscriber) { |
| 3419 |
innerFrom(durationSelector(value)).subscribe((durationSubscriber = createOperatorSubscriber(subscriber, endDuration, cleanupDuration))); |
| 3420 |
} |
| 3421 |
}, function () { |
| 3422 |
isComplete = true; |
| 3423 |
(!hasValue || !durationSubscriber || durationSubscriber.closed) && subscriber.complete(); |
| 3424 |
})); |
| 3425 |
}); |
| 3426 |
} |
| 3427 |
|
| 3428 |
function auditTime(duration, scheduler) { |
| 3429 |
if (scheduler === void 0) { scheduler = asyncScheduler; } |
| 3430 |
return audit(function () { return timer(duration, scheduler); }); |
| 3431 |
} |
| 3432 |
|
| 3433 |
function buffer(closingNotifier) { |
| 3434 |
return operate(function (source, subscriber) { |
| 3435 |
var currentBuffer = []; |
| 3436 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return currentBuffer.push(value); }, function () { |
| 3437 |
subscriber.next(currentBuffer); |
| 3438 |
subscriber.complete(); |
| 3439 |
})); |
| 3440 |
innerFrom(closingNotifier).subscribe(createOperatorSubscriber(subscriber, function () { |
| 3441 |
var b = currentBuffer; |
| 3442 |
currentBuffer = []; |
| 3443 |
subscriber.next(b); |
| 3444 |
}, noop)); |
| 3445 |
return function () { |
| 3446 |
currentBuffer = null; |
| 3447 |
}; |
| 3448 |
}); |
| 3449 |
} |
| 3450 |
|
| 3451 |
function bufferCount(bufferSize, startBufferEvery) { |
| 3452 |
if (startBufferEvery === void 0) { startBufferEvery = null; } |
| 3453 |
startBufferEvery = startBufferEvery !== null && startBufferEvery !== void 0 ? startBufferEvery : bufferSize; |
| 3454 |
return operate(function (source, subscriber) { |
| 3455 |
var buffers = []; |
| 3456 |
var count = 0; |
| 3457 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3458 |
var e_1, _a, e_2, _b; |
| 3459 |
var toEmit = null; |
| 3460 |
if (count++ % startBufferEvery === 0) { |
| 3461 |
buffers.push([]); |
| 3462 |
} |
| 3463 |
try { |
| 3464 |
for (var buffers_1 = __values(buffers), buffers_1_1 = buffers_1.next(); !buffers_1_1.done; buffers_1_1 = buffers_1.next()) { |
| 3465 |
var buffer = buffers_1_1.value; |
| 3466 |
buffer.push(value); |
| 3467 |
if (bufferSize <= buffer.length) { |
| 3468 |
toEmit = toEmit !== null && toEmit !== void 0 ? toEmit : []; |
| 3469 |
toEmit.push(buffer); |
| 3470 |
} |
| 3471 |
} |
| 3472 |
} |
| 3473 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 3474 |
finally { |
| 3475 |
try { |
| 3476 |
if (buffers_1_1 && !buffers_1_1.done && (_a = buffers_1.return)) _a.call(buffers_1); |
| 3477 |
} |
| 3478 |
finally { if (e_1) throw e_1.error; } |
| 3479 |
} |
| 3480 |
if (toEmit) { |
| 3481 |
try { |
| 3482 |
for (var toEmit_1 = __values(toEmit), toEmit_1_1 = toEmit_1.next(); !toEmit_1_1.done; toEmit_1_1 = toEmit_1.next()) { |
| 3483 |
var buffer = toEmit_1_1.value; |
| 3484 |
arrRemove(buffers, buffer); |
| 3485 |
subscriber.next(buffer); |
| 3486 |
} |
| 3487 |
} |
| 3488 |
catch (e_2_1) { e_2 = { error: e_2_1 }; } |
| 3489 |
finally { |
| 3490 |
try { |
| 3491 |
if (toEmit_1_1 && !toEmit_1_1.done && (_b = toEmit_1.return)) _b.call(toEmit_1); |
| 3492 |
} |
| 3493 |
finally { if (e_2) throw e_2.error; } |
| 3494 |
} |
| 3495 |
} |
| 3496 |
}, function () { |
| 3497 |
var e_3, _a; |
| 3498 |
try { |
| 3499 |
for (var buffers_2 = __values(buffers), buffers_2_1 = buffers_2.next(); !buffers_2_1.done; buffers_2_1 = buffers_2.next()) { |
| 3500 |
var buffer = buffers_2_1.value; |
| 3501 |
subscriber.next(buffer); |
| 3502 |
} |
| 3503 |
} |
| 3504 |
catch (e_3_1) { e_3 = { error: e_3_1 }; } |
| 3505 |
finally { |
| 3506 |
try { |
| 3507 |
if (buffers_2_1 && !buffers_2_1.done && (_a = buffers_2.return)) _a.call(buffers_2); |
| 3508 |
} |
| 3509 |
finally { if (e_3) throw e_3.error; } |
| 3510 |
} |
| 3511 |
subscriber.complete(); |
| 3512 |
}, undefined, function () { |
| 3513 |
buffers = null; |
| 3514 |
})); |
| 3515 |
}); |
| 3516 |
} |
| 3517 |
|
| 3518 |
function bufferTime(bufferTimeSpan) { |
| 3519 |
var _a, _b; |
| 3520 |
var otherArgs = []; |
| 3521 |
for (var _i = 1; _i < arguments.length; _i++) { |
| 3522 |
otherArgs[_i - 1] = arguments[_i]; |
| 3523 |
} |
| 3524 |
var scheduler = (_a = popScheduler(otherArgs)) !== null && _a !== void 0 ? _a : asyncScheduler; |
| 3525 |
var bufferCreationInterval = (_b = otherArgs[0]) !== null && _b !== void 0 ? _b : null; |
| 3526 |
var maxBufferSize = otherArgs[1] || Infinity; |
| 3527 |
return operate(function (source, subscriber) { |
| 3528 |
var bufferRecords = []; |
| 3529 |
var restartOnEmit = false; |
| 3530 |
var emit = function (record) { |
| 3531 |
var buffer = record.buffer, subs = record.subs; |
| 3532 |
subs.unsubscribe(); |
| 3533 |
arrRemove(bufferRecords, record); |
| 3534 |
subscriber.next(buffer); |
| 3535 |
restartOnEmit && startBuffer(); |
| 3536 |
}; |
| 3537 |
var startBuffer = function () { |
| 3538 |
if (bufferRecords) { |
| 3539 |
var subs = new Subscription(); |
| 3540 |
subscriber.add(subs); |
| 3541 |
var buffer = []; |
| 3542 |
var record_1 = { |
| 3543 |
buffer: buffer, |
| 3544 |
subs: subs, |
| 3545 |
}; |
| 3546 |
bufferRecords.push(record_1); |
| 3547 |
executeSchedule(subs, scheduler, function () { return emit(record_1); }, bufferTimeSpan); |
| 3548 |
} |
| 3549 |
}; |
| 3550 |
if (bufferCreationInterval !== null && bufferCreationInterval >= 0) { |
| 3551 |
executeSchedule(subscriber, scheduler, startBuffer, bufferCreationInterval, true); |
| 3552 |
} |
| 3553 |
else { |
| 3554 |
restartOnEmit = true; |
| 3555 |
} |
| 3556 |
startBuffer(); |
| 3557 |
var bufferTimeSubscriber = createOperatorSubscriber(subscriber, function (value) { |
| 3558 |
var e_1, _a; |
| 3559 |
var recordsCopy = bufferRecords.slice(); |
| 3560 |
try { |
| 3561 |
for (var recordsCopy_1 = __values(recordsCopy), recordsCopy_1_1 = recordsCopy_1.next(); !recordsCopy_1_1.done; recordsCopy_1_1 = recordsCopy_1.next()) { |
| 3562 |
var record = recordsCopy_1_1.value; |
| 3563 |
var buffer = record.buffer; |
| 3564 |
buffer.push(value); |
| 3565 |
maxBufferSize <= buffer.length && emit(record); |
| 3566 |
} |
| 3567 |
} |
| 3568 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 3569 |
finally { |
| 3570 |
try { |
| 3571 |
if (recordsCopy_1_1 && !recordsCopy_1_1.done && (_a = recordsCopy_1.return)) _a.call(recordsCopy_1); |
| 3572 |
} |
| 3573 |
finally { if (e_1) throw e_1.error; } |
| 3574 |
} |
| 3575 |
}, function () { |
| 3576 |
while (bufferRecords === null || bufferRecords === void 0 ? void 0 : bufferRecords.length) { |
| 3577 |
subscriber.next(bufferRecords.shift().buffer); |
| 3578 |
} |
| 3579 |
bufferTimeSubscriber === null || bufferTimeSubscriber === void 0 ? void 0 : bufferTimeSubscriber.unsubscribe(); |
| 3580 |
subscriber.complete(); |
| 3581 |
subscriber.unsubscribe(); |
| 3582 |
}, undefined, function () { return (bufferRecords = null); }); |
| 3583 |
source.subscribe(bufferTimeSubscriber); |
| 3584 |
}); |
| 3585 |
} |
| 3586 |
|
| 3587 |
function bufferToggle(openings, closingSelector) { |
| 3588 |
return operate(function (source, subscriber) { |
| 3589 |
var buffers = []; |
| 3590 |
innerFrom(openings).subscribe(createOperatorSubscriber(subscriber, function (openValue) { |
| 3591 |
var buffer = []; |
| 3592 |
buffers.push(buffer); |
| 3593 |
var closingSubscription = new Subscription(); |
| 3594 |
var emitBuffer = function () { |
| 3595 |
arrRemove(buffers, buffer); |
| 3596 |
subscriber.next(buffer); |
| 3597 |
closingSubscription.unsubscribe(); |
| 3598 |
}; |
| 3599 |
closingSubscription.add(innerFrom(closingSelector(openValue)).subscribe(createOperatorSubscriber(subscriber, emitBuffer, noop))); |
| 3600 |
}, noop)); |
| 3601 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3602 |
var e_1, _a; |
| 3603 |
try { |
| 3604 |
for (var buffers_1 = __values(buffers), buffers_1_1 = buffers_1.next(); !buffers_1_1.done; buffers_1_1 = buffers_1.next()) { |
| 3605 |
var buffer = buffers_1_1.value; |
| 3606 |
buffer.push(value); |
| 3607 |
} |
| 3608 |
} |
| 3609 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 3610 |
finally { |
| 3611 |
try { |
| 3612 |
if (buffers_1_1 && !buffers_1_1.done && (_a = buffers_1.return)) _a.call(buffers_1); |
| 3613 |
} |
| 3614 |
finally { if (e_1) throw e_1.error; } |
| 3615 |
} |
| 3616 |
}, function () { |
| 3617 |
while (buffers.length > 0) { |
| 3618 |
subscriber.next(buffers.shift()); |
| 3619 |
} |
| 3620 |
subscriber.complete(); |
| 3621 |
})); |
| 3622 |
}); |
| 3623 |
} |
| 3624 |
|
| 3625 |
function bufferWhen(closingSelector) { |
| 3626 |
return operate(function (source, subscriber) { |
| 3627 |
var buffer = null; |
| 3628 |
var closingSubscriber = null; |
| 3629 |
var openBuffer = function () { |
| 3630 |
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe(); |
| 3631 |
var b = buffer; |
| 3632 |
buffer = []; |
| 3633 |
b && subscriber.next(b); |
| 3634 |
innerFrom(closingSelector()).subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openBuffer, noop))); |
| 3635 |
}; |
| 3636 |
openBuffer(); |
| 3637 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return buffer === null || buffer === void 0 ? void 0 : buffer.push(value); }, function () { |
| 3638 |
buffer && subscriber.next(buffer); |
| 3639 |
subscriber.complete(); |
| 3640 |
}, undefined, function () { return (buffer = closingSubscriber = null); })); |
| 3641 |
}); |
| 3642 |
} |
| 3643 |
|
| 3644 |
function catchError(selector) { |
| 3645 |
return operate(function (source, subscriber) { |
| 3646 |
var innerSub = null; |
| 3647 |
var syncUnsub = false; |
| 3648 |
var handledResult; |
| 3649 |
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) { |
| 3650 |
handledResult = innerFrom(selector(err, catchError(selector)(source))); |
| 3651 |
if (innerSub) { |
| 3652 |
innerSub.unsubscribe(); |
| 3653 |
innerSub = null; |
| 3654 |
handledResult.subscribe(subscriber); |
| 3655 |
} |
| 3656 |
else { |
| 3657 |
syncUnsub = true; |
| 3658 |
} |
| 3659 |
})); |
| 3660 |
if (syncUnsub) { |
| 3661 |
innerSub.unsubscribe(); |
| 3662 |
innerSub = null; |
| 3663 |
handledResult.subscribe(subscriber); |
| 3664 |
} |
| 3665 |
}); |
| 3666 |
} |
| 3667 |
|
| 3668 |
function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete) { |
| 3669 |
return function (source, subscriber) { |
| 3670 |
var hasState = hasSeed; |
| 3671 |
var state = seed; |
| 3672 |
var index = 0; |
| 3673 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3674 |
var i = index++; |
| 3675 |
state = hasState |
| 3676 |
? |
| 3677 |
accumulator(state, value, i) |
| 3678 |
: |
| 3679 |
((hasState = true), value); |
| 3680 |
emitOnNext && subscriber.next(state); |
| 3681 |
}, emitBeforeComplete && |
| 3682 |
(function () { |
| 3683 |
hasState && subscriber.next(state); |
| 3684 |
subscriber.complete(); |
| 3685 |
}))); |
| 3686 |
}; |
| 3687 |
} |
| 3688 |
|
| 3689 |
function reduce(accumulator, seed) { |
| 3690 |
return operate(scanInternals(accumulator, seed, arguments.length >= 2, false, true)); |
| 3691 |
} |
| 3692 |
|
| 3693 |
var arrReducer = function (arr, value) { return (arr.push(value), arr); }; |
| 3694 |
function toArray() { |
| 3695 |
return operate(function (source, subscriber) { |
| 3696 |
reduce(arrReducer, [])(source).subscribe(subscriber); |
| 3697 |
}); |
| 3698 |
} |
| 3699 |
|
| 3700 |
function joinAllInternals(joinFn, project) { |
| 3701 |
return pipe(toArray(), mergeMap(function (sources) { return joinFn(sources); }), project ? mapOneOrManyArgs(project) : identity); |
| 3702 |
} |
| 3703 |
|
| 3704 |
function combineLatestAll(project) { |
| 3705 |
return joinAllInternals(combineLatest, project); |
| 3706 |
} |
| 3707 |
|
| 3708 |
var combineAll = combineLatestAll; |
| 3709 |
|
| 3710 |
function combineLatest$1() { |
| 3711 |
var args = []; |
| 3712 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3713 |
args[_i] = arguments[_i]; |
| 3714 |
} |
| 3715 |
var resultSelector = popResultSelector(args); |
| 3716 |
return resultSelector |
| 3717 |
? pipe(combineLatest$1.apply(void 0, __spreadArray([], __read(args))), mapOneOrManyArgs(resultSelector)) |
| 3718 |
: operate(function (source, subscriber) { |
| 3719 |
combineLatestInit(__spreadArray([source], __read(argsOrArgArray(args))))(subscriber); |
| 3720 |
}); |
| 3721 |
} |
| 3722 |
|
| 3723 |
function combineLatestWith() { |
| 3724 |
var otherSources = []; |
| 3725 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3726 |
otherSources[_i] = arguments[_i]; |
| 3727 |
} |
| 3728 |
return combineLatest$1.apply(void 0, __spreadArray([], __read(otherSources))); |
| 3729 |
} |
| 3730 |
|
| 3731 |
function concatMap(project, resultSelector) { |
| 3732 |
return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1); |
| 3733 |
} |
| 3734 |
|
| 3735 |
function concatMapTo(innerObservable, resultSelector) { |
| 3736 |
return isFunction(resultSelector) ? concatMap(function () { return innerObservable; }, resultSelector) : concatMap(function () { return innerObservable; }); |
| 3737 |
} |
| 3738 |
|
| 3739 |
function concat$1() { |
| 3740 |
var args = []; |
| 3741 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3742 |
args[_i] = arguments[_i]; |
| 3743 |
} |
| 3744 |
var scheduler = popScheduler(args); |
| 3745 |
return operate(function (source, subscriber) { |
| 3746 |
concatAll()(from(__spreadArray([source], __read(args)), scheduler)).subscribe(subscriber); |
| 3747 |
}); |
| 3748 |
} |
| 3749 |
|
| 3750 |
function concatWith() { |
| 3751 |
var otherSources = []; |
| 3752 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3753 |
otherSources[_i] = arguments[_i]; |
| 3754 |
} |
| 3755 |
return concat$1.apply(void 0, __spreadArray([], __read(otherSources))); |
| 3756 |
} |
| 3757 |
|
| 3758 |
function fromSubscribable(subscribable) { |
| 3759 |
return new Observable(function (subscriber) { return subscribable.subscribe(subscriber); }); |
| 3760 |
} |
| 3761 |
|
| 3762 |
var DEFAULT_CONFIG$1 = { |
| 3763 |
connector: function () { return new Subject(); }, |
| 3764 |
}; |
| 3765 |
function connect(selector, config) { |
| 3766 |
if (config === void 0) { config = DEFAULT_CONFIG$1; } |
| 3767 |
var connector = config.connector; |
| 3768 |
return operate(function (source, subscriber) { |
| 3769 |
var subject = connector(); |
| 3770 |
innerFrom(selector(fromSubscribable(subject))).subscribe(subscriber); |
| 3771 |
subscriber.add(source.subscribe(subject)); |
| 3772 |
}); |
| 3773 |
} |
| 3774 |
|
| 3775 |
function count(predicate) { |
| 3776 |
return reduce(function (total, value, i) { return (!predicate || predicate(value, i) ? total + 1 : total); }, 0); |
| 3777 |
} |
| 3778 |
|
| 3779 |
function debounce(durationSelector) { |
| 3780 |
return operate(function (source, subscriber) { |
| 3781 |
var hasValue = false; |
| 3782 |
var lastValue = null; |
| 3783 |
var durationSubscriber = null; |
| 3784 |
var emit = function () { |
| 3785 |
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe(); |
| 3786 |
durationSubscriber = null; |
| 3787 |
if (hasValue) { |
| 3788 |
hasValue = false; |
| 3789 |
var value = lastValue; |
| 3790 |
lastValue = null; |
| 3791 |
subscriber.next(value); |
| 3792 |
} |
| 3793 |
}; |
| 3794 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3795 |
durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe(); |
| 3796 |
hasValue = true; |
| 3797 |
lastValue = value; |
| 3798 |
durationSubscriber = createOperatorSubscriber(subscriber, emit, noop); |
| 3799 |
innerFrom(durationSelector(value)).subscribe(durationSubscriber); |
| 3800 |
}, function () { |
| 3801 |
emit(); |
| 3802 |
subscriber.complete(); |
| 3803 |
}, undefined, function () { |
| 3804 |
lastValue = durationSubscriber = null; |
| 3805 |
})); |
| 3806 |
}); |
| 3807 |
} |
| 3808 |
|
| 3809 |
function debounceTime(dueTime, scheduler) { |
| 3810 |
if (scheduler === void 0) { scheduler = asyncScheduler; } |
| 3811 |
return operate(function (source, subscriber) { |
| 3812 |
var activeTask = null; |
| 3813 |
var lastValue = null; |
| 3814 |
var lastTime = null; |
| 3815 |
var emit = function () { |
| 3816 |
if (activeTask) { |
| 3817 |
activeTask.unsubscribe(); |
| 3818 |
activeTask = null; |
| 3819 |
var value = lastValue; |
| 3820 |
lastValue = null; |
| 3821 |
subscriber.next(value); |
| 3822 |
} |
| 3823 |
}; |
| 3824 |
function emitWhenIdle() { |
| 3825 |
var targetTime = lastTime + dueTime; |
| 3826 |
var now = scheduler.now(); |
| 3827 |
if (now < targetTime) { |
| 3828 |
activeTask = this.schedule(undefined, targetTime - now); |
| 3829 |
subscriber.add(activeTask); |
| 3830 |
return; |
| 3831 |
} |
| 3832 |
emit(); |
| 3833 |
} |
| 3834 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3835 |
lastValue = value; |
| 3836 |
lastTime = scheduler.now(); |
| 3837 |
if (!activeTask) { |
| 3838 |
activeTask = scheduler.schedule(emitWhenIdle, dueTime); |
| 3839 |
subscriber.add(activeTask); |
| 3840 |
} |
| 3841 |
}, function () { |
| 3842 |
emit(); |
| 3843 |
subscriber.complete(); |
| 3844 |
}, undefined, function () { |
| 3845 |
lastValue = activeTask = null; |
| 3846 |
})); |
| 3847 |
}); |
| 3848 |
} |
| 3849 |
|
| 3850 |
function defaultIfEmpty(defaultValue) { |
| 3851 |
return operate(function (source, subscriber) { |
| 3852 |
var hasValue = false; |
| 3853 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3854 |
hasValue = true; |
| 3855 |
subscriber.next(value); |
| 3856 |
}, function () { |
| 3857 |
if (!hasValue) { |
| 3858 |
subscriber.next(defaultValue); |
| 3859 |
} |
| 3860 |
subscriber.complete(); |
| 3861 |
})); |
| 3862 |
}); |
| 3863 |
} |
| 3864 |
|
| 3865 |
function take(count) { |
| 3866 |
return count <= 0 |
| 3867 |
? |
| 3868 |
function () { return EMPTY; } |
| 3869 |
: operate(function (source, subscriber) { |
| 3870 |
var seen = 0; |
| 3871 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3872 |
if (++seen <= count) { |
| 3873 |
subscriber.next(value); |
| 3874 |
if (count <= seen) { |
| 3875 |
subscriber.complete(); |
| 3876 |
} |
| 3877 |
} |
| 3878 |
})); |
| 3879 |
}); |
| 3880 |
} |
| 3881 |
|
| 3882 |
function ignoreElements() { |
| 3883 |
return operate(function (source, subscriber) { |
| 3884 |
source.subscribe(createOperatorSubscriber(subscriber, noop)); |
| 3885 |
}); |
| 3886 |
} |
| 3887 |
|
| 3888 |
function mapTo(value) { |
| 3889 |
return map(function () { return value; }); |
| 3890 |
} |
| 3891 |
|
| 3892 |
function delayWhen(delayDurationSelector, subscriptionDelay) { |
| 3893 |
if (subscriptionDelay) { |
| 3894 |
return function (source) { |
| 3895 |
return concat(subscriptionDelay.pipe(take(1), ignoreElements()), source.pipe(delayWhen(delayDurationSelector))); |
| 3896 |
}; |
| 3897 |
} |
| 3898 |
return mergeMap(function (value, index) { return innerFrom(delayDurationSelector(value, index)).pipe(take(1), mapTo(value)); }); |
| 3899 |
} |
| 3900 |
|
| 3901 |
function delay(due, scheduler) { |
| 3902 |
if (scheduler === void 0) { scheduler = asyncScheduler; } |
| 3903 |
var duration = timer(due, scheduler); |
| 3904 |
return delayWhen(function () { return duration; }); |
| 3905 |
} |
| 3906 |
|
| 3907 |
function dematerialize() { |
| 3908 |
return operate(function (source, subscriber) { |
| 3909 |
source.subscribe(createOperatorSubscriber(subscriber, function (notification) { return observeNotification(notification, subscriber); })); |
| 3910 |
}); |
| 3911 |
} |
| 3912 |
|
| 3913 |
function distinct(keySelector, flushes) { |
| 3914 |
return operate(function (source, subscriber) { |
| 3915 |
var distinctKeys = new Set(); |
| 3916 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3917 |
var key = keySelector ? keySelector(value) : value; |
| 3918 |
if (!distinctKeys.has(key)) { |
| 3919 |
distinctKeys.add(key); |
| 3920 |
subscriber.next(value); |
| 3921 |
} |
| 3922 |
})); |
| 3923 |
flushes && innerFrom(flushes).subscribe(createOperatorSubscriber(subscriber, function () { return distinctKeys.clear(); }, noop)); |
| 3924 |
}); |
| 3925 |
} |
| 3926 |
|
| 3927 |
function distinctUntilChanged(comparator, keySelector) { |
| 3928 |
if (keySelector === void 0) { keySelector = identity; } |
| 3929 |
comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare; |
| 3930 |
return operate(function (source, subscriber) { |
| 3931 |
var previousKey; |
| 3932 |
var first = true; |
| 3933 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3934 |
var currentKey = keySelector(value); |
| 3935 |
if (first || !comparator(previousKey, currentKey)) { |
| 3936 |
first = false; |
| 3937 |
previousKey = currentKey; |
| 3938 |
subscriber.next(value); |
| 3939 |
} |
| 3940 |
})); |
| 3941 |
}); |
| 3942 |
} |
| 3943 |
function defaultCompare(a, b) { |
| 3944 |
return a === b; |
| 3945 |
} |
| 3946 |
|
| 3947 |
function distinctUntilKeyChanged(key, compare) { |
| 3948 |
return distinctUntilChanged(function (x, y) { return (compare ? compare(x[key], y[key]) : x[key] === y[key]); }); |
| 3949 |
} |
| 3950 |
|
| 3951 |
function throwIfEmpty(errorFactory) { |
| 3952 |
if (errorFactory === void 0) { errorFactory = defaultErrorFactory; } |
| 3953 |
return operate(function (source, subscriber) { |
| 3954 |
var hasValue = false; |
| 3955 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3956 |
hasValue = true; |
| 3957 |
subscriber.next(value); |
| 3958 |
}, function () { return (hasValue ? subscriber.complete() : subscriber.error(errorFactory())); })); |
| 3959 |
}); |
| 3960 |
} |
| 3961 |
function defaultErrorFactory() { |
| 3962 |
return new EmptyError(); |
| 3963 |
} |
| 3964 |
|
| 3965 |
function elementAt(index, defaultValue) { |
| 3966 |
if (index < 0) { |
| 3967 |
throw new ArgumentOutOfRangeError(); |
| 3968 |
} |
| 3969 |
var hasDefaultValue = arguments.length >= 2; |
| 3970 |
return function (source) { |
| 3971 |
return source.pipe(filter(function (v, i) { return i === index; }), take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new ArgumentOutOfRangeError(); })); |
| 3972 |
}; |
| 3973 |
} |
| 3974 |
|
| 3975 |
function endWith() { |
| 3976 |
var values = []; |
| 3977 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 3978 |
values[_i] = arguments[_i]; |
| 3979 |
} |
| 3980 |
return function (source) { return concat(source, of.apply(void 0, __spreadArray([], __read(values)))); }; |
| 3981 |
} |
| 3982 |
|
| 3983 |
function every(predicate, thisArg) { |
| 3984 |
return operate(function (source, subscriber) { |
| 3985 |
var index = 0; |
| 3986 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 3987 |
if (!predicate.call(thisArg, value, index++, source)) { |
| 3988 |
subscriber.next(false); |
| 3989 |
subscriber.complete(); |
| 3990 |
} |
| 3991 |
}, function () { |
| 3992 |
subscriber.next(true); |
| 3993 |
subscriber.complete(); |
| 3994 |
})); |
| 3995 |
}); |
| 3996 |
} |
| 3997 |
|
| 3998 |
function exhaustMap(project, resultSelector) { |
| 3999 |
if (resultSelector) { |
| 4000 |
return function (source) { |
| 4001 |
return source.pipe(exhaustMap(function (a, i) { return innerFrom(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); |
| 4002 |
}; |
| 4003 |
} |
| 4004 |
return operate(function (source, subscriber) { |
| 4005 |
var index = 0; |
| 4006 |
var innerSub = null; |
| 4007 |
var isComplete = false; |
| 4008 |
source.subscribe(createOperatorSubscriber(subscriber, function (outerValue) { |
| 4009 |
if (!innerSub) { |
| 4010 |
innerSub = createOperatorSubscriber(subscriber, undefined, function () { |
| 4011 |
innerSub = null; |
| 4012 |
isComplete && subscriber.complete(); |
| 4013 |
}); |
| 4014 |
innerFrom(project(outerValue, index++)).subscribe(innerSub); |
| 4015 |
} |
| 4016 |
}, function () { |
| 4017 |
isComplete = true; |
| 4018 |
!innerSub && subscriber.complete(); |
| 4019 |
})); |
| 4020 |
}); |
| 4021 |
} |
| 4022 |
|
| 4023 |
function exhaustAll() { |
| 4024 |
return exhaustMap(identity); |
| 4025 |
} |
| 4026 |
|
| 4027 |
var exhaust = exhaustAll; |
| 4028 |
|
| 4029 |
function expand(project, concurrent, scheduler) { |
| 4030 |
if (concurrent === void 0) { concurrent = Infinity; } |
| 4031 |
concurrent = (concurrent || 0) < 1 ? Infinity : concurrent; |
| 4032 |
return operate(function (source, subscriber) { |
| 4033 |
return mergeInternals(source, subscriber, project, concurrent, undefined, true, scheduler); |
| 4034 |
}); |
| 4035 |
} |
| 4036 |
|
| 4037 |
function finalize(callback) { |
| 4038 |
return operate(function (source, subscriber) { |
| 4039 |
try { |
| 4040 |
source.subscribe(subscriber); |
| 4041 |
} |
| 4042 |
finally { |
| 4043 |
subscriber.add(callback); |
| 4044 |
} |
| 4045 |
}); |
| 4046 |
} |
| 4047 |
|
| 4048 |
function find(predicate, thisArg) { |
| 4049 |
return operate(createFind(predicate, thisArg, 'value')); |
| 4050 |
} |
| 4051 |
function createFind(predicate, thisArg, emit) { |
| 4052 |
var findIndex = emit === 'index'; |
| 4053 |
return function (source, subscriber) { |
| 4054 |
var index = 0; |
| 4055 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4056 |
var i = index++; |
| 4057 |
if (predicate.call(thisArg, value, i, source)) { |
| 4058 |
subscriber.next(findIndex ? i : value); |
| 4059 |
subscriber.complete(); |
| 4060 |
} |
| 4061 |
}, function () { |
| 4062 |
subscriber.next(findIndex ? -1 : undefined); |
| 4063 |
subscriber.complete(); |
| 4064 |
})); |
| 4065 |
}; |
| 4066 |
} |
| 4067 |
|
| 4068 |
function findIndex(predicate, thisArg) { |
| 4069 |
return operate(createFind(predicate, thisArg, 'index')); |
| 4070 |
} |
| 4071 |
|
| 4072 |
function first(predicate, defaultValue) { |
| 4073 |
var hasDefaultValue = arguments.length >= 2; |
| 4074 |
return function (source) { |
| 4075 |
return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); |
| 4076 |
}; |
| 4077 |
} |
| 4078 |
|
| 4079 |
function groupBy(keySelector, elementOrOptions, duration, connector) { |
| 4080 |
return operate(function (source, subscriber) { |
| 4081 |
var element; |
| 4082 |
if (!elementOrOptions || typeof elementOrOptions === 'function') { |
| 4083 |
element = elementOrOptions; |
| 4084 |
} |
| 4085 |
else { |
| 4086 |
(duration = elementOrOptions.duration, element = elementOrOptions.element, connector = elementOrOptions.connector); |
| 4087 |
} |
| 4088 |
var groups = new Map(); |
| 4089 |
var notify = function (cb) { |
| 4090 |
groups.forEach(cb); |
| 4091 |
cb(subscriber); |
| 4092 |
}; |
| 4093 |
var handleError = function (err) { return notify(function (consumer) { return consumer.error(err); }); }; |
| 4094 |
var activeGroups = 0; |
| 4095 |
var teardownAttempted = false; |
| 4096 |
var groupBySourceSubscriber = new OperatorSubscriber(subscriber, function (value) { |
| 4097 |
try { |
| 4098 |
var key_1 = keySelector(value); |
| 4099 |
var group_1 = groups.get(key_1); |
| 4100 |
if (!group_1) { |
| 4101 |
groups.set(key_1, (group_1 = connector ? connector() : new Subject())); |
| 4102 |
var grouped = createGroupedObservable(key_1, group_1); |
| 4103 |
subscriber.next(grouped); |
| 4104 |
if (duration) { |
| 4105 |
var durationSubscriber_1 = createOperatorSubscriber(group_1, function () { |
| 4106 |
group_1.complete(); |
| 4107 |
durationSubscriber_1 === null || durationSubscriber_1 === void 0 ? void 0 : durationSubscriber_1.unsubscribe(); |
| 4108 |
}, undefined, undefined, function () { return groups.delete(key_1); }); |
| 4109 |
groupBySourceSubscriber.add(innerFrom(duration(grouped)).subscribe(durationSubscriber_1)); |
| 4110 |
} |
| 4111 |
} |
| 4112 |
group_1.next(element ? element(value) : value); |
| 4113 |
} |
| 4114 |
catch (err) { |
| 4115 |
handleError(err); |
| 4116 |
} |
| 4117 |
}, function () { return notify(function (consumer) { return consumer.complete(); }); }, handleError, function () { return groups.clear(); }, function () { |
| 4118 |
teardownAttempted = true; |
| 4119 |
return activeGroups === 0; |
| 4120 |
}); |
| 4121 |
source.subscribe(groupBySourceSubscriber); |
| 4122 |
function createGroupedObservable(key, groupSubject) { |
| 4123 |
var result = new Observable(function (groupSubscriber) { |
| 4124 |
activeGroups++; |
| 4125 |
var innerSub = groupSubject.subscribe(groupSubscriber); |
| 4126 |
return function () { |
| 4127 |
innerSub.unsubscribe(); |
| 4128 |
--activeGroups === 0 && teardownAttempted && groupBySourceSubscriber.unsubscribe(); |
| 4129 |
}; |
| 4130 |
}); |
| 4131 |
result.key = key; |
| 4132 |
return result; |
| 4133 |
} |
| 4134 |
}); |
| 4135 |
} |
| 4136 |
|
| 4137 |
function isEmpty() { |
| 4138 |
return operate(function (source, subscriber) { |
| 4139 |
source.subscribe(createOperatorSubscriber(subscriber, function () { |
| 4140 |
subscriber.next(false); |
| 4141 |
subscriber.complete(); |
| 4142 |
}, function () { |
| 4143 |
subscriber.next(true); |
| 4144 |
subscriber.complete(); |
| 4145 |
})); |
| 4146 |
}); |
| 4147 |
} |
| 4148 |
|
| 4149 |
function takeLast(count) { |
| 4150 |
return count <= 0 |
| 4151 |
? function () { return EMPTY; } |
| 4152 |
: operate(function (source, subscriber) { |
| 4153 |
var buffer = []; |
| 4154 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4155 |
buffer.push(value); |
| 4156 |
count < buffer.length && buffer.shift(); |
| 4157 |
}, function () { |
| 4158 |
var e_1, _a; |
| 4159 |
try { |
| 4160 |
for (var buffer_1 = __values(buffer), buffer_1_1 = buffer_1.next(); !buffer_1_1.done; buffer_1_1 = buffer_1.next()) { |
| 4161 |
var value = buffer_1_1.value; |
| 4162 |
subscriber.next(value); |
| 4163 |
} |
| 4164 |
} |
| 4165 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 4166 |
finally { |
| 4167 |
try { |
| 4168 |
if (buffer_1_1 && !buffer_1_1.done && (_a = buffer_1.return)) _a.call(buffer_1); |
| 4169 |
} |
| 4170 |
finally { if (e_1) throw e_1.error; } |
| 4171 |
} |
| 4172 |
subscriber.complete(); |
| 4173 |
}, undefined, function () { |
| 4174 |
buffer = null; |
| 4175 |
})); |
| 4176 |
}); |
| 4177 |
} |
| 4178 |
|
| 4179 |
function last$1(predicate, defaultValue) { |
| 4180 |
var hasDefaultValue = arguments.length >= 2; |
| 4181 |
return function (source) { |
| 4182 |
return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); |
| 4183 |
}; |
| 4184 |
} |
| 4185 |
|
| 4186 |
function materialize() { |
| 4187 |
return operate(function (source, subscriber) { |
| 4188 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4189 |
subscriber.next(Notification.createNext(value)); |
| 4190 |
}, function () { |
| 4191 |
subscriber.next(Notification.createComplete()); |
| 4192 |
subscriber.complete(); |
| 4193 |
}, function (err) { |
| 4194 |
subscriber.next(Notification.createError(err)); |
| 4195 |
subscriber.complete(); |
| 4196 |
})); |
| 4197 |
}); |
| 4198 |
} |
| 4199 |
|
| 4200 |
function max(comparer) { |
| 4201 |
return reduce(isFunction(comparer) ? function (x, y) { return (comparer(x, y) > 0 ? x : y); } : function (x, y) { return (x > y ? x : y); }); |
| 4202 |
} |
| 4203 |
|
| 4204 |
var flatMap = mergeMap; |
| 4205 |
|
| 4206 |
function mergeMapTo(innerObservable, resultSelector, concurrent) { |
| 4207 |
if (concurrent === void 0) { concurrent = Infinity; } |
| 4208 |
if (isFunction(resultSelector)) { |
| 4209 |
return mergeMap(function () { return innerObservable; }, resultSelector, concurrent); |
| 4210 |
} |
| 4211 |
if (typeof resultSelector === 'number') { |
| 4212 |
concurrent = resultSelector; |
| 4213 |
} |
| 4214 |
return mergeMap(function () { return innerObservable; }, concurrent); |
| 4215 |
} |
| 4216 |
|
| 4217 |
function mergeScan(accumulator, seed, concurrent) { |
| 4218 |
if (concurrent === void 0) { concurrent = Infinity; } |
| 4219 |
return operate(function (source, subscriber) { |
| 4220 |
var state = seed; |
| 4221 |
return mergeInternals(source, subscriber, function (value, index) { return accumulator(state, value, index); }, concurrent, function (value) { |
| 4222 |
state = value; |
| 4223 |
}, false, undefined, function () { return (state = null); }); |
| 4224 |
}); |
| 4225 |
} |
| 4226 |
|
| 4227 |
function merge$1() { |
| 4228 |
var args = []; |
| 4229 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 4230 |
args[_i] = arguments[_i]; |
| 4231 |
} |
| 4232 |
var scheduler = popScheduler(args); |
| 4233 |
var concurrent = popNumber(args, Infinity); |
| 4234 |
return operate(function (source, subscriber) { |
| 4235 |
mergeAll(concurrent)(from(__spreadArray([source], __read(args)), scheduler)).subscribe(subscriber); |
| 4236 |
}); |
| 4237 |
} |
| 4238 |
|
| 4239 |
function mergeWith() { |
| 4240 |
var otherSources = []; |
| 4241 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 4242 |
otherSources[_i] = arguments[_i]; |
| 4243 |
} |
| 4244 |
return merge$1.apply(void 0, __spreadArray([], __read(otherSources))); |
| 4245 |
} |
| 4246 |
|
| 4247 |
function min(comparer) { |
| 4248 |
return reduce(isFunction(comparer) ? function (x, y) { return (comparer(x, y) < 0 ? x : y); } : function (x, y) { return (x < y ? x : y); }); |
| 4249 |
} |
| 4250 |
|
| 4251 |
function multicast(subjectOrSubjectFactory, selector) { |
| 4252 |
var subjectFactory = isFunction(subjectOrSubjectFactory) ? subjectOrSubjectFactory : function () { return subjectOrSubjectFactory; }; |
| 4253 |
if (isFunction(selector)) { |
| 4254 |
return connect(selector, { |
| 4255 |
connector: subjectFactory, |
| 4256 |
}); |
| 4257 |
} |
| 4258 |
return function (source) { return new ConnectableObservable(source, subjectFactory); }; |
| 4259 |
} |
| 4260 |
|
| 4261 |
function onErrorResumeNextWith() { |
| 4262 |
var sources = []; |
| 4263 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 4264 |
sources[_i] = arguments[_i]; |
| 4265 |
} |
| 4266 |
var nextSources = argsOrArgArray(sources); |
| 4267 |
return function (source) { return onErrorResumeNext.apply(void 0, __spreadArray([source], __read(nextSources))); }; |
| 4268 |
} |
| 4269 |
var onErrorResumeNext$1 = onErrorResumeNextWith; |
| 4270 |
|
| 4271 |
function pairwise() { |
| 4272 |
return operate(function (source, subscriber) { |
| 4273 |
var prev; |
| 4274 |
var hasPrev = false; |
| 4275 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4276 |
var p = prev; |
| 4277 |
prev = value; |
| 4278 |
hasPrev && subscriber.next([p, value]); |
| 4279 |
hasPrev = true; |
| 4280 |
})); |
| 4281 |
}); |
| 4282 |
} |
| 4283 |
|
| 4284 |
function pluck() { |
| 4285 |
var properties = []; |
| 4286 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 4287 |
properties[_i] = arguments[_i]; |
| 4288 |
} |
| 4289 |
var length = properties.length; |
| 4290 |
if (length === 0) { |
| 4291 |
throw new Error('list of properties cannot be empty.'); |
| 4292 |
} |
| 4293 |
return map(function (x) { |
| 4294 |
var currentProp = x; |
| 4295 |
for (var i = 0; i < length; i++) { |
| 4296 |
var p = currentProp === null || currentProp === void 0 ? void 0 : currentProp[properties[i]]; |
| 4297 |
if (typeof p !== 'undefined') { |
| 4298 |
currentProp = p; |
| 4299 |
} |
| 4300 |
else { |
| 4301 |
return undefined; |
| 4302 |
} |
| 4303 |
} |
| 4304 |
return currentProp; |
| 4305 |
}); |
| 4306 |
} |
| 4307 |
|
| 4308 |
function publish(selector) { |
| 4309 |
return selector ? function (source) { return connect(selector)(source); } : function (source) { return multicast(new Subject())(source); }; |
| 4310 |
} |
| 4311 |
|
| 4312 |
function publishBehavior(initialValue) { |
| 4313 |
return function (source) { |
| 4314 |
var subject = new BehaviorSubject(initialValue); |
| 4315 |
return new ConnectableObservable(source, function () { return subject; }); |
| 4316 |
}; |
| 4317 |
} |
| 4318 |
|
| 4319 |
function publishLast() { |
| 4320 |
return function (source) { |
| 4321 |
var subject = new AsyncSubject(); |
| 4322 |
return new ConnectableObservable(source, function () { return subject; }); |
| 4323 |
}; |
| 4324 |
} |
| 4325 |
|
| 4326 |
function publishReplay(bufferSize, windowTime, selectorOrScheduler, timestampProvider) { |
| 4327 |
if (selectorOrScheduler && !isFunction(selectorOrScheduler)) { |
| 4328 |
timestampProvider = selectorOrScheduler; |
| 4329 |
} |
| 4330 |
var selector = isFunction(selectorOrScheduler) ? selectorOrScheduler : undefined; |
| 4331 |
return function (source) { return multicast(new ReplaySubject(bufferSize, windowTime, timestampProvider), selector)(source); }; |
| 4332 |
} |
| 4333 |
|
| 4334 |
function raceWith() { |
| 4335 |
var otherSources = []; |
| 4336 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 4337 |
otherSources[_i] = arguments[_i]; |
| 4338 |
} |
| 4339 |
return !otherSources.length |
| 4340 |
? identity |
| 4341 |
: operate(function (source, subscriber) { |
| 4342 |
raceInit(__spreadArray([source], __read(otherSources)))(subscriber); |
| 4343 |
}); |
| 4344 |
} |
| 4345 |
|
| 4346 |
function repeat(countOrConfig) { |
| 4347 |
var _a; |
| 4348 |
var count = Infinity; |
| 4349 |
var delay; |
| 4350 |
if (countOrConfig != null) { |
| 4351 |
if (typeof countOrConfig === 'object') { |
| 4352 |
(_a = countOrConfig.count, count = _a === void 0 ? Infinity : _a, delay = countOrConfig.delay); |
| 4353 |
} |
| 4354 |
else { |
| 4355 |
count = countOrConfig; |
| 4356 |
} |
| 4357 |
} |
| 4358 |
return count <= 0 |
| 4359 |
? function () { return EMPTY; } |
| 4360 |
: operate(function (source, subscriber) { |
| 4361 |
var soFar = 0; |
| 4362 |
var sourceSub; |
| 4363 |
var resubscribe = function () { |
| 4364 |
sourceSub === null || sourceSub === void 0 ? void 0 : sourceSub.unsubscribe(); |
| 4365 |
sourceSub = null; |
| 4366 |
if (delay != null) { |
| 4367 |
var notifier = typeof delay === 'number' ? timer(delay) : innerFrom(delay(soFar)); |
| 4368 |
var notifierSubscriber_1 = createOperatorSubscriber(subscriber, function () { |
| 4369 |
notifierSubscriber_1.unsubscribe(); |
| 4370 |
subscribeToSource(); |
| 4371 |
}); |
| 4372 |
notifier.subscribe(notifierSubscriber_1); |
| 4373 |
} |
| 4374 |
else { |
| 4375 |
subscribeToSource(); |
| 4376 |
} |
| 4377 |
}; |
| 4378 |
var subscribeToSource = function () { |
| 4379 |
var syncUnsub = false; |
| 4380 |
sourceSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, function () { |
| 4381 |
if (++soFar < count) { |
| 4382 |
if (sourceSub) { |
| 4383 |
resubscribe(); |
| 4384 |
} |
| 4385 |
else { |
| 4386 |
syncUnsub = true; |
| 4387 |
} |
| 4388 |
} |
| 4389 |
else { |
| 4390 |
subscriber.complete(); |
| 4391 |
} |
| 4392 |
})); |
| 4393 |
if (syncUnsub) { |
| 4394 |
resubscribe(); |
| 4395 |
} |
| 4396 |
}; |
| 4397 |
subscribeToSource(); |
| 4398 |
}); |
| 4399 |
} |
| 4400 |
|
| 4401 |
function repeatWhen(notifier) { |
| 4402 |
return operate(function (source, subscriber) { |
| 4403 |
var innerSub; |
| 4404 |
var syncResub = false; |
| 4405 |
var completions$; |
| 4406 |
var isNotifierComplete = false; |
| 4407 |
var isMainComplete = false; |
| 4408 |
var checkComplete = function () { return isMainComplete && isNotifierComplete && (subscriber.complete(), true); }; |
| 4409 |
var getCompletionSubject = function () { |
| 4410 |
if (!completions$) { |
| 4411 |
completions$ = new Subject(); |
| 4412 |
innerFrom(notifier(completions$)).subscribe(createOperatorSubscriber(subscriber, function () { |
| 4413 |
if (innerSub) { |
| 4414 |
subscribeForRepeatWhen(); |
| 4415 |
} |
| 4416 |
else { |
| 4417 |
syncResub = true; |
| 4418 |
} |
| 4419 |
}, function () { |
| 4420 |
isNotifierComplete = true; |
| 4421 |
checkComplete(); |
| 4422 |
})); |
| 4423 |
} |
| 4424 |
return completions$; |
| 4425 |
}; |
| 4426 |
var subscribeForRepeatWhen = function () { |
| 4427 |
isMainComplete = false; |
| 4428 |
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, function () { |
| 4429 |
isMainComplete = true; |
| 4430 |
!checkComplete() && getCompletionSubject().next(); |
| 4431 |
})); |
| 4432 |
if (syncResub) { |
| 4433 |
innerSub.unsubscribe(); |
| 4434 |
innerSub = null; |
| 4435 |
syncResub = false; |
| 4436 |
subscribeForRepeatWhen(); |
| 4437 |
} |
| 4438 |
}; |
| 4439 |
subscribeForRepeatWhen(); |
| 4440 |
}); |
| 4441 |
} |
| 4442 |
|
| 4443 |
function retry(configOrCount) { |
| 4444 |
if (configOrCount === void 0) { configOrCount = Infinity; } |
| 4445 |
var config; |
| 4446 |
if (configOrCount && typeof configOrCount === 'object') { |
| 4447 |
config = configOrCount; |
| 4448 |
} |
| 4449 |
else { |
| 4450 |
config = { |
| 4451 |
count: configOrCount, |
| 4452 |
}; |
| 4453 |
} |
| 4454 |
var _a = config.count, count = _a === void 0 ? Infinity : _a, delay = config.delay, _b = config.resetOnSuccess, resetOnSuccess = _b === void 0 ? false : _b; |
| 4455 |
return count <= 0 |
| 4456 |
? identity |
| 4457 |
: operate(function (source, subscriber) { |
| 4458 |
var soFar = 0; |
| 4459 |
var innerSub; |
| 4460 |
var subscribeForRetry = function () { |
| 4461 |
var syncUnsub = false; |
| 4462 |
innerSub = source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4463 |
if (resetOnSuccess) { |
| 4464 |
soFar = 0; |
| 4465 |
} |
| 4466 |
subscriber.next(value); |
| 4467 |
}, undefined, function (err) { |
| 4468 |
if (soFar++ < count) { |
| 4469 |
var resub_1 = function () { |
| 4470 |
if (innerSub) { |
| 4471 |
innerSub.unsubscribe(); |
| 4472 |
innerSub = null; |
| 4473 |
subscribeForRetry(); |
| 4474 |
} |
| 4475 |
else { |
| 4476 |
syncUnsub = true; |
| 4477 |
} |
| 4478 |
}; |
| 4479 |
if (delay != null) { |
| 4480 |
var notifier = typeof delay === 'number' ? timer(delay) : innerFrom(delay(err, soFar)); |
| 4481 |
var notifierSubscriber_1 = createOperatorSubscriber(subscriber, function () { |
| 4482 |
notifierSubscriber_1.unsubscribe(); |
| 4483 |
resub_1(); |
| 4484 |
}, function () { |
| 4485 |
subscriber.complete(); |
| 4486 |
}); |
| 4487 |
notifier.subscribe(notifierSubscriber_1); |
| 4488 |
} |
| 4489 |
else { |
| 4490 |
resub_1(); |
| 4491 |
} |
| 4492 |
} |
| 4493 |
else { |
| 4494 |
subscriber.error(err); |
| 4495 |
} |
| 4496 |
})); |
| 4497 |
if (syncUnsub) { |
| 4498 |
innerSub.unsubscribe(); |
| 4499 |
innerSub = null; |
| 4500 |
subscribeForRetry(); |
| 4501 |
} |
| 4502 |
}; |
| 4503 |
subscribeForRetry(); |
| 4504 |
}); |
| 4505 |
} |
| 4506 |
|
| 4507 |
function retryWhen(notifier) { |
| 4508 |
return operate(function (source, subscriber) { |
| 4509 |
var innerSub; |
| 4510 |
var syncResub = false; |
| 4511 |
var errors$; |
| 4512 |
var subscribeForRetryWhen = function () { |
| 4513 |
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) { |
| 4514 |
if (!errors$) { |
| 4515 |
errors$ = new Subject(); |
| 4516 |
innerFrom(notifier(errors$)).subscribe(createOperatorSubscriber(subscriber, function () { |
| 4517 |
return innerSub ? subscribeForRetryWhen() : (syncResub = true); |
| 4518 |
})); |
| 4519 |
} |
| 4520 |
if (errors$) { |
| 4521 |
errors$.next(err); |
| 4522 |
} |
| 4523 |
})); |
| 4524 |
if (syncResub) { |
| 4525 |
innerSub.unsubscribe(); |
| 4526 |
innerSub = null; |
| 4527 |
syncResub = false; |
| 4528 |
subscribeForRetryWhen(); |
| 4529 |
} |
| 4530 |
}; |
| 4531 |
subscribeForRetryWhen(); |
| 4532 |
}); |
| 4533 |
} |
| 4534 |
|
| 4535 |
function sample(notifier) { |
| 4536 |
return operate(function (source, subscriber) { |
| 4537 |
var hasValue = false; |
| 4538 |
var lastValue = null; |
| 4539 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4540 |
hasValue = true; |
| 4541 |
lastValue = value; |
| 4542 |
})); |
| 4543 |
innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, function () { |
| 4544 |
if (hasValue) { |
| 4545 |
hasValue = false; |
| 4546 |
var value = lastValue; |
| 4547 |
lastValue = null; |
| 4548 |
subscriber.next(value); |
| 4549 |
} |
| 4550 |
}, noop)); |
| 4551 |
}); |
| 4552 |
} |
| 4553 |
|
| 4554 |
function sampleTime(period, scheduler) { |
| 4555 |
if (scheduler === void 0) { scheduler = asyncScheduler; } |
| 4556 |
return sample(interval(period, scheduler)); |
| 4557 |
} |
| 4558 |
|
| 4559 |
function scan(accumulator, seed) { |
| 4560 |
return operate(scanInternals(accumulator, seed, arguments.length >= 2, true)); |
| 4561 |
} |
| 4562 |
|
| 4563 |
function sequenceEqual(compareTo, comparator) { |
| 4564 |
if (comparator === void 0) { comparator = function (a, b) { return a === b; }; } |
| 4565 |
return operate(function (source, subscriber) { |
| 4566 |
var aState = createState(); |
| 4567 |
var bState = createState(); |
| 4568 |
var emit = function (isEqual) { |
| 4569 |
subscriber.next(isEqual); |
| 4570 |
subscriber.complete(); |
| 4571 |
}; |
| 4572 |
var createSubscriber = function (selfState, otherState) { |
| 4573 |
var sequenceEqualSubscriber = createOperatorSubscriber(subscriber, function (a) { |
| 4574 |
var buffer = otherState.buffer, complete = otherState.complete; |
| 4575 |
if (buffer.length === 0) { |
| 4576 |
complete ? emit(false) : selfState.buffer.push(a); |
| 4577 |
} |
| 4578 |
else { |
| 4579 |
!comparator(a, buffer.shift()) && emit(false); |
| 4580 |
} |
| 4581 |
}, function () { |
| 4582 |
selfState.complete = true; |
| 4583 |
var complete = otherState.complete, buffer = otherState.buffer; |
| 4584 |
complete && emit(buffer.length === 0); |
| 4585 |
sequenceEqualSubscriber === null || sequenceEqualSubscriber === void 0 ? void 0 : sequenceEqualSubscriber.unsubscribe(); |
| 4586 |
}); |
| 4587 |
return sequenceEqualSubscriber; |
| 4588 |
}; |
| 4589 |
source.subscribe(createSubscriber(aState, bState)); |
| 4590 |
innerFrom(compareTo).subscribe(createSubscriber(bState, aState)); |
| 4591 |
}); |
| 4592 |
} |
| 4593 |
function createState() { |
| 4594 |
return { |
| 4595 |
buffer: [], |
| 4596 |
complete: false, |
| 4597 |
}; |
| 4598 |
} |
| 4599 |
|
| 4600 |
function share(options) { |
| 4601 |
if (options === void 0) { options = {}; } |
| 4602 |
var _a = options.connector, connector = _a === void 0 ? function () { return new Subject(); } : _a, _b = options.resetOnError, resetOnError = _b === void 0 ? true : _b, _c = options.resetOnComplete, resetOnComplete = _c === void 0 ? true : _c, _d = options.resetOnRefCountZero, resetOnRefCountZero = _d === void 0 ? true : _d; |
| 4603 |
return function (wrapperSource) { |
| 4604 |
var connection; |
| 4605 |
var resetConnection; |
| 4606 |
var subject; |
| 4607 |
var refCount = 0; |
| 4608 |
var hasCompleted = false; |
| 4609 |
var hasErrored = false; |
| 4610 |
var cancelReset = function () { |
| 4611 |
resetConnection === null || resetConnection === void 0 ? void 0 : resetConnection.unsubscribe(); |
| 4612 |
resetConnection = undefined; |
| 4613 |
}; |
| 4614 |
var reset = function () { |
| 4615 |
cancelReset(); |
| 4616 |
connection = subject = undefined; |
| 4617 |
hasCompleted = hasErrored = false; |
| 4618 |
}; |
| 4619 |
var resetAndUnsubscribe = function () { |
| 4620 |
var conn = connection; |
| 4621 |
reset(); |
| 4622 |
conn === null || conn === void 0 ? void 0 : conn.unsubscribe(); |
| 4623 |
}; |
| 4624 |
return operate(function (source, subscriber) { |
| 4625 |
refCount++; |
| 4626 |
if (!hasErrored && !hasCompleted) { |
| 4627 |
cancelReset(); |
| 4628 |
} |
| 4629 |
var dest = (subject = subject !== null && subject !== void 0 ? subject : connector()); |
| 4630 |
subscriber.add(function () { |
| 4631 |
refCount--; |
| 4632 |
if (refCount === 0 && !hasErrored && !hasCompleted) { |
| 4633 |
resetConnection = handleReset(resetAndUnsubscribe, resetOnRefCountZero); |
| 4634 |
} |
| 4635 |
}); |
| 4636 |
dest.subscribe(subscriber); |
| 4637 |
if (!connection && |
| 4638 |
refCount > 0) { |
| 4639 |
connection = new SafeSubscriber({ |
| 4640 |
next: function (value) { return dest.next(value); }, |
| 4641 |
error: function (err) { |
| 4642 |
hasErrored = true; |
| 4643 |
cancelReset(); |
| 4644 |
resetConnection = handleReset(reset, resetOnError, err); |
| 4645 |
dest.error(err); |
| 4646 |
}, |
| 4647 |
complete: function () { |
| 4648 |
hasCompleted = true; |
| 4649 |
cancelReset(); |
| 4650 |
resetConnection = handleReset(reset, resetOnComplete); |
| 4651 |
dest.complete(); |
| 4652 |
}, |
| 4653 |
}); |
| 4654 |
innerFrom(source).subscribe(connection); |
| 4655 |
} |
| 4656 |
})(wrapperSource); |
| 4657 |
}; |
| 4658 |
} |
| 4659 |
function handleReset(reset, on) { |
| 4660 |
var args = []; |
| 4661 |
for (var _i = 2; _i < arguments.length; _i++) { |
| 4662 |
args[_i - 2] = arguments[_i]; |
| 4663 |
} |
| 4664 |
if (on === true) { |
| 4665 |
reset(); |
| 4666 |
return; |
| 4667 |
} |
| 4668 |
if (on === false) { |
| 4669 |
return; |
| 4670 |
} |
| 4671 |
var onSubscriber = new SafeSubscriber({ |
| 4672 |
next: function () { |
| 4673 |
onSubscriber.unsubscribe(); |
| 4674 |
reset(); |
| 4675 |
}, |
| 4676 |
}); |
| 4677 |
return innerFrom(on.apply(void 0, __spreadArray([], __read(args)))).subscribe(onSubscriber); |
| 4678 |
} |
| 4679 |
|
| 4680 |
function shareReplay(configOrBufferSize, windowTime, scheduler) { |
| 4681 |
var _a, _b, _c; |
| 4682 |
var bufferSize; |
| 4683 |
var refCount = false; |
| 4684 |
if (configOrBufferSize && typeof configOrBufferSize === 'object') { |
| 4685 |
(_a = configOrBufferSize.bufferSize, bufferSize = _a === void 0 ? Infinity : _a, _b = configOrBufferSize.windowTime, windowTime = _b === void 0 ? Infinity : _b, _c = configOrBufferSize.refCount, refCount = _c === void 0 ? false : _c, scheduler = configOrBufferSize.scheduler); |
| 4686 |
} |
| 4687 |
else { |
| 4688 |
bufferSize = (configOrBufferSize !== null && configOrBufferSize !== void 0 ? configOrBufferSize : Infinity); |
| 4689 |
} |
| 4690 |
return share({ |
| 4691 |
connector: function () { return new ReplaySubject(bufferSize, windowTime, scheduler); }, |
| 4692 |
resetOnError: true, |
| 4693 |
resetOnComplete: false, |
| 4694 |
resetOnRefCountZero: refCount, |
| 4695 |
}); |
| 4696 |
} |
| 4697 |
|
| 4698 |
function single(predicate) { |
| 4699 |
return operate(function (source, subscriber) { |
| 4700 |
var hasValue = false; |
| 4701 |
var singleValue; |
| 4702 |
var seenValue = false; |
| 4703 |
var index = 0; |
| 4704 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4705 |
seenValue = true; |
| 4706 |
if (!predicate || predicate(value, index++, source)) { |
| 4707 |
hasValue && subscriber.error(new SequenceError('Too many matching values')); |
| 4708 |
hasValue = true; |
| 4709 |
singleValue = value; |
| 4710 |
} |
| 4711 |
}, function () { |
| 4712 |
if (hasValue) { |
| 4713 |
subscriber.next(singleValue); |
| 4714 |
subscriber.complete(); |
| 4715 |
} |
| 4716 |
else { |
| 4717 |
subscriber.error(seenValue ? new NotFoundError('No matching values') : new EmptyError()); |
| 4718 |
} |
| 4719 |
})); |
| 4720 |
}); |
| 4721 |
} |
| 4722 |
|
| 4723 |
function skip(count) { |
| 4724 |
return filter(function (_, index) { return count <= index; }); |
| 4725 |
} |
| 4726 |
|
| 4727 |
function skipLast(skipCount) { |
| 4728 |
return skipCount <= 0 |
| 4729 |
? |
| 4730 |
identity |
| 4731 |
: operate(function (source, subscriber) { |
| 4732 |
var ring = new Array(skipCount); |
| 4733 |
var seen = 0; |
| 4734 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4735 |
var valueIndex = seen++; |
| 4736 |
if (valueIndex < skipCount) { |
| 4737 |
ring[valueIndex] = value; |
| 4738 |
} |
| 4739 |
else { |
| 4740 |
var index = valueIndex % skipCount; |
| 4741 |
var oldValue = ring[index]; |
| 4742 |
ring[index] = value; |
| 4743 |
subscriber.next(oldValue); |
| 4744 |
} |
| 4745 |
})); |
| 4746 |
return function () { |
| 4747 |
ring = null; |
| 4748 |
}; |
| 4749 |
}); |
| 4750 |
} |
| 4751 |
|
| 4752 |
function skipUntil(notifier) { |
| 4753 |
return operate(function (source, subscriber) { |
| 4754 |
var taking = false; |
| 4755 |
var skipSubscriber = createOperatorSubscriber(subscriber, function () { |
| 4756 |
skipSubscriber === null || skipSubscriber === void 0 ? void 0 : skipSubscriber.unsubscribe(); |
| 4757 |
taking = true; |
| 4758 |
}, noop); |
| 4759 |
innerFrom(notifier).subscribe(skipSubscriber); |
| 4760 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return taking && subscriber.next(value); })); |
| 4761 |
}); |
| 4762 |
} |
| 4763 |
|
| 4764 |
function skipWhile(predicate) { |
| 4765 |
return operate(function (source, subscriber) { |
| 4766 |
var taking = false; |
| 4767 |
var index = 0; |
| 4768 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return (taking || (taking = !predicate(value, index++))) && subscriber.next(value); })); |
| 4769 |
}); |
| 4770 |
} |
| 4771 |
|
| 4772 |
function startWith() { |
| 4773 |
var values = []; |
| 4774 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 4775 |
values[_i] = arguments[_i]; |
| 4776 |
} |
| 4777 |
var scheduler = popScheduler(values); |
| 4778 |
return operate(function (source, subscriber) { |
| 4779 |
(scheduler ? concat(values, source, scheduler) : concat(values, source)).subscribe(subscriber); |
| 4780 |
}); |
| 4781 |
} |
| 4782 |
|
| 4783 |
function switchMap(project, resultSelector) { |
| 4784 |
return operate(function (source, subscriber) { |
| 4785 |
var innerSubscriber = null; |
| 4786 |
var index = 0; |
| 4787 |
var isComplete = false; |
| 4788 |
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); }; |
| 4789 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4790 |
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe(); |
| 4791 |
var innerIndex = 0; |
| 4792 |
var outerIndex = index++; |
| 4793 |
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () { |
| 4794 |
innerSubscriber = null; |
| 4795 |
checkComplete(); |
| 4796 |
}))); |
| 4797 |
}, function () { |
| 4798 |
isComplete = true; |
| 4799 |
checkComplete(); |
| 4800 |
})); |
| 4801 |
}); |
| 4802 |
} |
| 4803 |
|
| 4804 |
function switchAll() { |
| 4805 |
return switchMap(identity); |
| 4806 |
} |
| 4807 |
|
| 4808 |
function switchMapTo(innerObservable, resultSelector) { |
| 4809 |
return isFunction(resultSelector) ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; }); |
| 4810 |
} |
| 4811 |
|
| 4812 |
function switchScan(accumulator, seed) { |
| 4813 |
return operate(function (source, subscriber) { |
| 4814 |
var state = seed; |
| 4815 |
switchMap(function (value, index) { return accumulator(state, value, index); }, function (_, innerValue) { return ((state = innerValue), innerValue); })(source).subscribe(subscriber); |
| 4816 |
return function () { |
| 4817 |
state = null; |
| 4818 |
}; |
| 4819 |
}); |
| 4820 |
} |
| 4821 |
|
| 4822 |
function takeUntil(notifier) { |
| 4823 |
return operate(function (source, subscriber) { |
| 4824 |
innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, function () { return subscriber.complete(); }, noop)); |
| 4825 |
!subscriber.closed && source.subscribe(subscriber); |
| 4826 |
}); |
| 4827 |
} |
| 4828 |
|
| 4829 |
function takeWhile(predicate, inclusive) { |
| 4830 |
if (inclusive === void 0) { inclusive = false; } |
| 4831 |
return operate(function (source, subscriber) { |
| 4832 |
var index = 0; |
| 4833 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4834 |
var result = predicate(value, index++); |
| 4835 |
(result || inclusive) && subscriber.next(value); |
| 4836 |
!result && subscriber.complete(); |
| 4837 |
})); |
| 4838 |
}); |
| 4839 |
} |
| 4840 |
|
| 4841 |
function tap(observerOrNext, error, complete) { |
| 4842 |
var tapObserver = isFunction(observerOrNext) || error || complete |
| 4843 |
? |
| 4844 |
{ next: observerOrNext, error: error, complete: complete } |
| 4845 |
: observerOrNext; |
| 4846 |
return tapObserver |
| 4847 |
? operate(function (source, subscriber) { |
| 4848 |
var _a; |
| 4849 |
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver); |
| 4850 |
var isUnsub = true; |
| 4851 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4852 |
var _a; |
| 4853 |
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value); |
| 4854 |
subscriber.next(value); |
| 4855 |
}, function () { |
| 4856 |
var _a; |
| 4857 |
isUnsub = false; |
| 4858 |
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver); |
| 4859 |
subscriber.complete(); |
| 4860 |
}, function (err) { |
| 4861 |
var _a; |
| 4862 |
isUnsub = false; |
| 4863 |
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err); |
| 4864 |
subscriber.error(err); |
| 4865 |
}, function () { |
| 4866 |
var _a, _b; |
| 4867 |
if (isUnsub) { |
| 4868 |
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver); |
| 4869 |
} |
| 4870 |
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver); |
| 4871 |
})); |
| 4872 |
}) |
| 4873 |
: |
| 4874 |
identity; |
| 4875 |
} |
| 4876 |
|
| 4877 |
function throttle(durationSelector, config) { |
| 4878 |
return operate(function (source, subscriber) { |
| 4879 |
var _a = config !== null && config !== void 0 ? config : {}, _b = _a.leading, leading = _b === void 0 ? true : _b, _c = _a.trailing, trailing = _c === void 0 ? false : _c; |
| 4880 |
var hasValue = false; |
| 4881 |
var sendValue = null; |
| 4882 |
var throttled = null; |
| 4883 |
var isComplete = false; |
| 4884 |
var endThrottling = function () { |
| 4885 |
throttled === null || throttled === void 0 ? void 0 : throttled.unsubscribe(); |
| 4886 |
throttled = null; |
| 4887 |
if (trailing) { |
| 4888 |
send(); |
| 4889 |
isComplete && subscriber.complete(); |
| 4890 |
} |
| 4891 |
}; |
| 4892 |
var cleanupThrottling = function () { |
| 4893 |
throttled = null; |
| 4894 |
isComplete && subscriber.complete(); |
| 4895 |
}; |
| 4896 |
var startThrottle = function (value) { |
| 4897 |
return (throttled = innerFrom(durationSelector(value)).subscribe(createOperatorSubscriber(subscriber, endThrottling, cleanupThrottling))); |
| 4898 |
}; |
| 4899 |
var send = function () { |
| 4900 |
if (hasValue) { |
| 4901 |
hasValue = false; |
| 4902 |
var value = sendValue; |
| 4903 |
sendValue = null; |
| 4904 |
subscriber.next(value); |
| 4905 |
!isComplete && startThrottle(value); |
| 4906 |
} |
| 4907 |
}; |
| 4908 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4909 |
hasValue = true; |
| 4910 |
sendValue = value; |
| 4911 |
!(throttled && !throttled.closed) && (leading ? send() : startThrottle(value)); |
| 4912 |
}, function () { |
| 4913 |
isComplete = true; |
| 4914 |
!(trailing && hasValue && throttled && !throttled.closed) && subscriber.complete(); |
| 4915 |
})); |
| 4916 |
}); |
| 4917 |
} |
| 4918 |
|
| 4919 |
function throttleTime(duration, scheduler, config) { |
| 4920 |
if (scheduler === void 0) { scheduler = asyncScheduler; } |
| 4921 |
var duration$ = timer(duration, scheduler); |
| 4922 |
return throttle(function () { return duration$; }, config); |
| 4923 |
} |
| 4924 |
|
| 4925 |
function timeInterval(scheduler) { |
| 4926 |
if (scheduler === void 0) { scheduler = asyncScheduler; } |
| 4927 |
return operate(function (source, subscriber) { |
| 4928 |
var last = scheduler.now(); |
| 4929 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 4930 |
var now = scheduler.now(); |
| 4931 |
var interval = now - last; |
| 4932 |
last = now; |
| 4933 |
subscriber.next(new TimeInterval(value, interval)); |
| 4934 |
})); |
| 4935 |
}); |
| 4936 |
} |
| 4937 |
var TimeInterval = (function () { |
| 4938 |
function TimeInterval(value, interval) { |
| 4939 |
this.value = value; |
| 4940 |
this.interval = interval; |
| 4941 |
} |
| 4942 |
return TimeInterval; |
| 4943 |
}()); |
| 4944 |
|
| 4945 |
function timeoutWith(due, withObservable, scheduler) { |
| 4946 |
var first; |
| 4947 |
var each; |
| 4948 |
var _with; |
| 4949 |
scheduler = scheduler !== null && scheduler !== void 0 ? scheduler : async; |
| 4950 |
if (isValidDate(due)) { |
| 4951 |
first = due; |
| 4952 |
} |
| 4953 |
else if (typeof due === 'number') { |
| 4954 |
each = due; |
| 4955 |
} |
| 4956 |
if (withObservable) { |
| 4957 |
_with = function () { return withObservable; }; |
| 4958 |
} |
| 4959 |
else { |
| 4960 |
throw new TypeError('No observable provided to switch to'); |
| 4961 |
} |
| 4962 |
if (first == null && each == null) { |
| 4963 |
throw new TypeError('No timeout provided.'); |
| 4964 |
} |
| 4965 |
return timeout({ |
| 4966 |
first: first, |
| 4967 |
each: each, |
| 4968 |
scheduler: scheduler, |
| 4969 |
with: _with, |
| 4970 |
}); |
| 4971 |
} |
| 4972 |
|
| 4973 |
function timestamp(timestampProvider) { |
| 4974 |
if (timestampProvider === void 0) { timestampProvider = dateTimestampProvider; } |
| 4975 |
return map(function (value) { return ({ value: value, timestamp: timestampProvider.now() }); }); |
| 4976 |
} |
| 4977 |
|
| 4978 |
function window(windowBoundaries) { |
| 4979 |
return operate(function (source, subscriber) { |
| 4980 |
var windowSubject = new Subject(); |
| 4981 |
subscriber.next(windowSubject.asObservable()); |
| 4982 |
var errorHandler = function (err) { |
| 4983 |
windowSubject.error(err); |
| 4984 |
subscriber.error(err); |
| 4985 |
}; |
| 4986 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.next(value); }, function () { |
| 4987 |
windowSubject.complete(); |
| 4988 |
subscriber.complete(); |
| 4989 |
}, errorHandler)); |
| 4990 |
innerFrom(windowBoundaries).subscribe(createOperatorSubscriber(subscriber, function () { |
| 4991 |
windowSubject.complete(); |
| 4992 |
subscriber.next((windowSubject = new Subject())); |
| 4993 |
}, noop, errorHandler)); |
| 4994 |
return function () { |
| 4995 |
windowSubject === null || windowSubject === void 0 ? void 0 : windowSubject.unsubscribe(); |
| 4996 |
windowSubject = null; |
| 4997 |
}; |
| 4998 |
}); |
| 4999 |
} |
| 5000 |
|
| 5001 |
function windowCount(windowSize, startWindowEvery) { |
| 5002 |
if (startWindowEvery === void 0) { startWindowEvery = 0; } |
| 5003 |
var startEvery = startWindowEvery > 0 ? startWindowEvery : windowSize; |
| 5004 |
return operate(function (source, subscriber) { |
| 5005 |
var windows = [new Subject()]; |
| 5006 |
var count = 0; |
| 5007 |
subscriber.next(windows[0].asObservable()); |
| 5008 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 5009 |
var e_1, _a; |
| 5010 |
try { |
| 5011 |
for (var windows_1 = __values(windows), windows_1_1 = windows_1.next(); !windows_1_1.done; windows_1_1 = windows_1.next()) { |
| 5012 |
var window_1 = windows_1_1.value; |
| 5013 |
window_1.next(value); |
| 5014 |
} |
| 5015 |
} |
| 5016 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 5017 |
finally { |
| 5018 |
try { |
| 5019 |
if (windows_1_1 && !windows_1_1.done && (_a = windows_1.return)) _a.call(windows_1); |
| 5020 |
} |
| 5021 |
finally { if (e_1) throw e_1.error; } |
| 5022 |
} |
| 5023 |
var c = count - windowSize + 1; |
| 5024 |
if (c >= 0 && c % startEvery === 0) { |
| 5025 |
windows.shift().complete(); |
| 5026 |
} |
| 5027 |
if (++count % startEvery === 0) { |
| 5028 |
var window_2 = new Subject(); |
| 5029 |
windows.push(window_2); |
| 5030 |
subscriber.next(window_2.asObservable()); |
| 5031 |
} |
| 5032 |
}, function () { |
| 5033 |
while (windows.length > 0) { |
| 5034 |
windows.shift().complete(); |
| 5035 |
} |
| 5036 |
subscriber.complete(); |
| 5037 |
}, function (err) { |
| 5038 |
while (windows.length > 0) { |
| 5039 |
windows.shift().error(err); |
| 5040 |
} |
| 5041 |
subscriber.error(err); |
| 5042 |
}, function () { |
| 5043 |
windows = null; |
| 5044 |
})); |
| 5045 |
}); |
| 5046 |
} |
| 5047 |
|
| 5048 |
function windowTime(windowTimeSpan) { |
| 5049 |
var _a, _b; |
| 5050 |
var otherArgs = []; |
| 5051 |
for (var _i = 1; _i < arguments.length; _i++) { |
| 5052 |
otherArgs[_i - 1] = arguments[_i]; |
| 5053 |
} |
| 5054 |
var scheduler = (_a = popScheduler(otherArgs)) !== null && _a !== void 0 ? _a : asyncScheduler; |
| 5055 |
var windowCreationInterval = (_b = otherArgs[0]) !== null && _b !== void 0 ? _b : null; |
| 5056 |
var maxWindowSize = otherArgs[1] || Infinity; |
| 5057 |
return operate(function (source, subscriber) { |
| 5058 |
var windowRecords = []; |
| 5059 |
var restartOnClose = false; |
| 5060 |
var closeWindow = function (record) { |
| 5061 |
var window = record.window, subs = record.subs; |
| 5062 |
window.complete(); |
| 5063 |
subs.unsubscribe(); |
| 5064 |
arrRemove(windowRecords, record); |
| 5065 |
restartOnClose && startWindow(); |
| 5066 |
}; |
| 5067 |
var startWindow = function () { |
| 5068 |
if (windowRecords) { |
| 5069 |
var subs = new Subscription(); |
| 5070 |
subscriber.add(subs); |
| 5071 |
var window_1 = new Subject(); |
| 5072 |
var record_1 = { |
| 5073 |
window: window_1, |
| 5074 |
subs: subs, |
| 5075 |
seen: 0, |
| 5076 |
}; |
| 5077 |
windowRecords.push(record_1); |
| 5078 |
subscriber.next(window_1.asObservable()); |
| 5079 |
executeSchedule(subs, scheduler, function () { return closeWindow(record_1); }, windowTimeSpan); |
| 5080 |
} |
| 5081 |
}; |
| 5082 |
if (windowCreationInterval !== null && windowCreationInterval >= 0) { |
| 5083 |
executeSchedule(subscriber, scheduler, startWindow, windowCreationInterval, true); |
| 5084 |
} |
| 5085 |
else { |
| 5086 |
restartOnClose = true; |
| 5087 |
} |
| 5088 |
startWindow(); |
| 5089 |
var loop = function (cb) { return windowRecords.slice().forEach(cb); }; |
| 5090 |
var terminate = function (cb) { |
| 5091 |
loop(function (_a) { |
| 5092 |
var window = _a.window; |
| 5093 |
return cb(window); |
| 5094 |
}); |
| 5095 |
cb(subscriber); |
| 5096 |
subscriber.unsubscribe(); |
| 5097 |
}; |
| 5098 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 5099 |
loop(function (record) { |
| 5100 |
record.window.next(value); |
| 5101 |
maxWindowSize <= ++record.seen && closeWindow(record); |
| 5102 |
}); |
| 5103 |
}, function () { return terminate(function (consumer) { return consumer.complete(); }); }, function (err) { return terminate(function (consumer) { return consumer.error(err); }); })); |
| 5104 |
return function () { |
| 5105 |
windowRecords = null; |
| 5106 |
}; |
| 5107 |
}); |
| 5108 |
} |
| 5109 |
|
| 5110 |
function windowToggle(openings, closingSelector) { |
| 5111 |
return operate(function (source, subscriber) { |
| 5112 |
var windows = []; |
| 5113 |
var handleError = function (err) { |
| 5114 |
while (0 < windows.length) { |
| 5115 |
windows.shift().error(err); |
| 5116 |
} |
| 5117 |
subscriber.error(err); |
| 5118 |
}; |
| 5119 |
innerFrom(openings).subscribe(createOperatorSubscriber(subscriber, function (openValue) { |
| 5120 |
var window = new Subject(); |
| 5121 |
windows.push(window); |
| 5122 |
var closingSubscription = new Subscription(); |
| 5123 |
var closeWindow = function () { |
| 5124 |
arrRemove(windows, window); |
| 5125 |
window.complete(); |
| 5126 |
closingSubscription.unsubscribe(); |
| 5127 |
}; |
| 5128 |
var closingNotifier; |
| 5129 |
try { |
| 5130 |
closingNotifier = innerFrom(closingSelector(openValue)); |
| 5131 |
} |
| 5132 |
catch (err) { |
| 5133 |
handleError(err); |
| 5134 |
return; |
| 5135 |
} |
| 5136 |
subscriber.next(window.asObservable()); |
| 5137 |
closingSubscription.add(closingNotifier.subscribe(createOperatorSubscriber(subscriber, closeWindow, noop, handleError))); |
| 5138 |
}, noop)); |
| 5139 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 5140 |
var e_1, _a; |
| 5141 |
var windowsCopy = windows.slice(); |
| 5142 |
try { |
| 5143 |
for (var windowsCopy_1 = __values(windowsCopy), windowsCopy_1_1 = windowsCopy_1.next(); !windowsCopy_1_1.done; windowsCopy_1_1 = windowsCopy_1.next()) { |
| 5144 |
var window_1 = windowsCopy_1_1.value; |
| 5145 |
window_1.next(value); |
| 5146 |
} |
| 5147 |
} |
| 5148 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 5149 |
finally { |
| 5150 |
try { |
| 5151 |
if (windowsCopy_1_1 && !windowsCopy_1_1.done && (_a = windowsCopy_1.return)) _a.call(windowsCopy_1); |
| 5152 |
} |
| 5153 |
finally { if (e_1) throw e_1.error; } |
| 5154 |
} |
| 5155 |
}, function () { |
| 5156 |
while (0 < windows.length) { |
| 5157 |
windows.shift().complete(); |
| 5158 |
} |
| 5159 |
subscriber.complete(); |
| 5160 |
}, handleError, function () { |
| 5161 |
while (0 < windows.length) { |
| 5162 |
windows.shift().unsubscribe(); |
| 5163 |
} |
| 5164 |
})); |
| 5165 |
}); |
| 5166 |
} |
| 5167 |
|
| 5168 |
function windowWhen(closingSelector) { |
| 5169 |
return operate(function (source, subscriber) { |
| 5170 |
var window; |
| 5171 |
var closingSubscriber; |
| 5172 |
var handleError = function (err) { |
| 5173 |
window.error(err); |
| 5174 |
subscriber.error(err); |
| 5175 |
}; |
| 5176 |
var openWindow = function () { |
| 5177 |
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe(); |
| 5178 |
window === null || window === void 0 ? void 0 : window.complete(); |
| 5179 |
window = new Subject(); |
| 5180 |
subscriber.next(window.asObservable()); |
| 5181 |
var closingNotifier; |
| 5182 |
try { |
| 5183 |
closingNotifier = innerFrom(closingSelector()); |
| 5184 |
} |
| 5185 |
catch (err) { |
| 5186 |
handleError(err); |
| 5187 |
return; |
| 5188 |
} |
| 5189 |
closingNotifier.subscribe((closingSubscriber = createOperatorSubscriber(subscriber, openWindow, openWindow, handleError))); |
| 5190 |
}; |
| 5191 |
openWindow(); |
| 5192 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return window.next(value); }, function () { |
| 5193 |
window.complete(); |
| 5194 |
subscriber.complete(); |
| 5195 |
}, handleError, function () { |
| 5196 |
closingSubscriber === null || closingSubscriber === void 0 ? void 0 : closingSubscriber.unsubscribe(); |
| 5197 |
window = null; |
| 5198 |
})); |
| 5199 |
}); |
| 5200 |
} |
| 5201 |
|
| 5202 |
function withLatestFrom() { |
| 5203 |
var inputs = []; |
| 5204 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 5205 |
inputs[_i] = arguments[_i]; |
| 5206 |
} |
| 5207 |
var project = popResultSelector(inputs); |
| 5208 |
return operate(function (source, subscriber) { |
| 5209 |
var len = inputs.length; |
| 5210 |
var otherValues = new Array(len); |
| 5211 |
var hasValue = inputs.map(function () { return false; }); |
| 5212 |
var ready = false; |
| 5213 |
var _loop_1 = function (i) { |
| 5214 |
innerFrom(inputs[i]).subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 5215 |
otherValues[i] = value; |
| 5216 |
if (!ready && !hasValue[i]) { |
| 5217 |
hasValue[i] = true; |
| 5218 |
(ready = hasValue.every(identity)) && (hasValue = null); |
| 5219 |
} |
| 5220 |
}, noop)); |
| 5221 |
}; |
| 5222 |
for (var i = 0; i < len; i++) { |
| 5223 |
_loop_1(i); |
| 5224 |
} |
| 5225 |
source.subscribe(createOperatorSubscriber(subscriber, function (value) { |
| 5226 |
if (ready) { |
| 5227 |
var values = __spreadArray([value], __read(otherValues)); |
| 5228 |
subscriber.next(project ? project.apply(void 0, __spreadArray([], __read(values))) : values); |
| 5229 |
} |
| 5230 |
})); |
| 5231 |
}); |
| 5232 |
} |
| 5233 |
|
| 5234 |
function zipAll(project) { |
| 5235 |
return joinAllInternals(zip, project); |
| 5236 |
} |
| 5237 |
|
| 5238 |
function zip$1() { |
| 5239 |
var sources = []; |
| 5240 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 5241 |
sources[_i] = arguments[_i]; |
| 5242 |
} |
| 5243 |
return operate(function (source, subscriber) { |
| 5244 |
zip.apply(void 0, __spreadArray([source], __read(sources))).subscribe(subscriber); |
| 5245 |
}); |
| 5246 |
} |
| 5247 |
|
| 5248 |
function zipWith() { |
| 5249 |
var otherInputs = []; |
| 5250 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 5251 |
otherInputs[_i] = arguments[_i]; |
| 5252 |
} |
| 5253 |
return zip$1.apply(void 0, __spreadArray([], __read(otherInputs))); |
| 5254 |
} |
| 5255 |
|
| 5256 |
function partition$1(predicate, thisArg) { |
| 5257 |
return function (source) { |
| 5258 |
return [filter(predicate, thisArg)(source), filter(not(predicate, thisArg))(source)]; |
| 5259 |
}; |
| 5260 |
} |
| 5261 |
|
| 5262 |
function race$1() { |
| 5263 |
var args = []; |
| 5264 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 5265 |
args[_i] = arguments[_i]; |
| 5266 |
} |
| 5267 |
return raceWith.apply(void 0, __spreadArray([], __read(argsOrArgArray(args)))); |
| 5268 |
} |
| 5269 |
|
| 5270 |
|
| 5271 |
|
| 5272 |
var _operators = /*#__PURE__*/Object.freeze({ |
| 5273 |
audit: audit, |
| 5274 |
auditTime: auditTime, |
| 5275 |
buffer: buffer, |
| 5276 |
bufferCount: bufferCount, |
| 5277 |
bufferTime: bufferTime, |
| 5278 |
bufferToggle: bufferToggle, |
| 5279 |
bufferWhen: bufferWhen, |
| 5280 |
catchError: catchError, |
| 5281 |
combineAll: combineAll, |
| 5282 |
combineLatestAll: combineLatestAll, |
| 5283 |
combineLatest: combineLatest$1, |
| 5284 |
combineLatestWith: combineLatestWith, |
| 5285 |
concat: concat$1, |
| 5286 |
concatAll: concatAll, |
| 5287 |
concatMap: concatMap, |
| 5288 |
concatMapTo: concatMapTo, |
| 5289 |
concatWith: concatWith, |
| 5290 |
connect: connect, |
| 5291 |
count: count, |
| 5292 |
debounce: debounce, |
| 5293 |
debounceTime: debounceTime, |
| 5294 |
defaultIfEmpty: defaultIfEmpty, |
| 5295 |
delay: delay, |
| 5296 |
delayWhen: delayWhen, |
| 5297 |
dematerialize: dematerialize, |
| 5298 |
distinct: distinct, |
| 5299 |
distinctUntilChanged: distinctUntilChanged, |
| 5300 |
distinctUntilKeyChanged: distinctUntilKeyChanged, |
| 5301 |
elementAt: elementAt, |
| 5302 |
endWith: endWith, |
| 5303 |
every: every, |
| 5304 |
exhaust: exhaust, |
| 5305 |
exhaustAll: exhaustAll, |
| 5306 |
exhaustMap: exhaustMap, |
| 5307 |
expand: expand, |
| 5308 |
filter: filter, |
| 5309 |
finalize: finalize, |
| 5310 |
find: find, |
| 5311 |
findIndex: findIndex, |
| 5312 |
first: first, |
| 5313 |
groupBy: groupBy, |
| 5314 |
ignoreElements: ignoreElements, |
| 5315 |
isEmpty: isEmpty, |
| 5316 |
last: last$1, |
| 5317 |
map: map, |
| 5318 |
mapTo: mapTo, |
| 5319 |
materialize: materialize, |
| 5320 |
max: max, |
| 5321 |
merge: merge$1, |
| 5322 |
mergeAll: mergeAll, |
| 5323 |
flatMap: flatMap, |
| 5324 |
mergeMap: mergeMap, |
| 5325 |
mergeMapTo: mergeMapTo, |
| 5326 |
mergeScan: mergeScan, |
| 5327 |
mergeWith: mergeWith, |
| 5328 |
min: min, |
| 5329 |
multicast: multicast, |
| 5330 |
observeOn: observeOn, |
| 5331 |
onErrorResumeNext: onErrorResumeNext$1, |
| 5332 |
pairwise: pairwise, |
| 5333 |
partition: partition$1, |
| 5334 |
pluck: pluck, |
| 5335 |
publish: publish, |
| 5336 |
publishBehavior: publishBehavior, |
| 5337 |
publishLast: publishLast, |
| 5338 |
publishReplay: publishReplay, |
| 5339 |
race: race$1, |
| 5340 |
raceWith: raceWith, |
| 5341 |
reduce: reduce, |
| 5342 |
repeat: repeat, |
| 5343 |
repeatWhen: repeatWhen, |
| 5344 |
retry: retry, |
| 5345 |
retryWhen: retryWhen, |
| 5346 |
refCount: refCount, |
| 5347 |
sample: sample, |
| 5348 |
sampleTime: sampleTime, |
| 5349 |
scan: scan, |
| 5350 |
sequenceEqual: sequenceEqual, |
| 5351 |
share: share, |
| 5352 |
shareReplay: shareReplay, |
| 5353 |
single: single, |
| 5354 |
skip: skip, |
| 5355 |
skipLast: skipLast, |
| 5356 |
skipUntil: skipUntil, |
| 5357 |
skipWhile: skipWhile, |
| 5358 |
startWith: startWith, |
| 5359 |
subscribeOn: subscribeOn, |
| 5360 |
switchAll: switchAll, |
| 5361 |
switchMap: switchMap, |
| 5362 |
switchMapTo: switchMapTo, |
| 5363 |
switchScan: switchScan, |
| 5364 |
take: take, |
| 5365 |
takeLast: takeLast, |
| 5366 |
takeUntil: takeUntil, |
| 5367 |
takeWhile: takeWhile, |
| 5368 |
tap: tap, |
| 5369 |
throttle: throttle, |
| 5370 |
throttleTime: throttleTime, |
| 5371 |
throwIfEmpty: throwIfEmpty, |
| 5372 |
timeInterval: timeInterval, |
| 5373 |
timeout: timeout, |
| 5374 |
timeoutWith: timeoutWith, |
| 5375 |
timestamp: timestamp, |
| 5376 |
toArray: toArray, |
| 5377 |
window: window, |
| 5378 |
windowCount: windowCount, |
| 5379 |
windowTime: windowTime, |
| 5380 |
windowToggle: windowToggle, |
| 5381 |
windowWhen: windowWhen, |
| 5382 |
withLatestFrom: withLatestFrom, |
| 5383 |
zip: zip$1, |
| 5384 |
zipAll: zipAll, |
| 5385 |
zipWith: zipWith |
| 5386 |
}); |
| 5387 |
|
| 5388 |
var SubscriptionLog = (function () { |
| 5389 |
function SubscriptionLog(subscribedFrame, unsubscribedFrame) { |
| 5390 |
if (unsubscribedFrame === void 0) { unsubscribedFrame = Infinity; } |
| 5391 |
this.subscribedFrame = subscribedFrame; |
| 5392 |
this.unsubscribedFrame = unsubscribedFrame; |
| 5393 |
} |
| 5394 |
return SubscriptionLog; |
| 5395 |
}()); |
| 5396 |
|
| 5397 |
var SubscriptionLoggable = (function () { |
| 5398 |
function SubscriptionLoggable() { |
| 5399 |
this.subscriptions = []; |
| 5400 |
} |
| 5401 |
SubscriptionLoggable.prototype.logSubscribedFrame = function () { |
| 5402 |
this.subscriptions.push(new SubscriptionLog(this.scheduler.now())); |
| 5403 |
return this.subscriptions.length - 1; |
| 5404 |
}; |
| 5405 |
SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) { |
| 5406 |
var subscriptionLogs = this.subscriptions; |
| 5407 |
var oldSubscriptionLog = subscriptionLogs[index]; |
| 5408 |
subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now()); |
| 5409 |
}; |
| 5410 |
return SubscriptionLoggable; |
| 5411 |
}()); |
| 5412 |
|
| 5413 |
function applyMixins(derivedCtor, baseCtors) { |
| 5414 |
for (var i = 0, len = baseCtors.length; i < len; i++) { |
| 5415 |
var baseCtor = baseCtors[i]; |
| 5416 |
var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype); |
| 5417 |
for (var j = 0, len2 = propertyKeys.length; j < len2; j++) { |
| 5418 |
var name_1 = propertyKeys[j]; |
| 5419 |
derivedCtor.prototype[name_1] = baseCtor.prototype[name_1]; |
| 5420 |
} |
| 5421 |
} |
| 5422 |
} |
| 5423 |
|
| 5424 |
var ColdObservable = (function (_super) { |
| 5425 |
__extends(ColdObservable, _super); |
| 5426 |
function ColdObservable(messages, scheduler) { |
| 5427 |
var _this = _super.call(this, function (subscriber) { |
| 5428 |
var observable = this; |
| 5429 |
var index = observable.logSubscribedFrame(); |
| 5430 |
var subscription = new Subscription(); |
| 5431 |
subscription.add(new Subscription(function () { |
| 5432 |
observable.logUnsubscribedFrame(index); |
| 5433 |
})); |
| 5434 |
observable.scheduleMessages(subscriber); |
| 5435 |
return subscription; |
| 5436 |
}) || this; |
| 5437 |
_this.messages = messages; |
| 5438 |
_this.subscriptions = []; |
| 5439 |
_this.scheduler = scheduler; |
| 5440 |
return _this; |
| 5441 |
} |
| 5442 |
ColdObservable.prototype.scheduleMessages = function (subscriber) { |
| 5443 |
var messagesLength = this.messages.length; |
| 5444 |
for (var i = 0; i < messagesLength; i++) { |
| 5445 |
var message = this.messages[i]; |
| 5446 |
subscriber.add(this.scheduler.schedule(function (state) { |
| 5447 |
var _a = state, notification = _a.message.notification, destination = _a.subscriber; |
| 5448 |
observeNotification(notification, destination); |
| 5449 |
}, message.frame, { message: message, subscriber: subscriber })); |
| 5450 |
} |
| 5451 |
}; |
| 5452 |
return ColdObservable; |
| 5453 |
}(Observable)); |
| 5454 |
applyMixins(ColdObservable, [SubscriptionLoggable]); |
| 5455 |
|
| 5456 |
var HotObservable = (function (_super) { |
| 5457 |
__extends(HotObservable, _super); |
| 5458 |
function HotObservable(messages, scheduler) { |
| 5459 |
var _this = _super.call(this) || this; |
| 5460 |
_this.messages = messages; |
| 5461 |
_this.subscriptions = []; |
| 5462 |
_this.scheduler = scheduler; |
| 5463 |
return _this; |
| 5464 |
} |
| 5465 |
HotObservable.prototype._subscribe = function (subscriber) { |
| 5466 |
var subject = this; |
| 5467 |
var index = subject.logSubscribedFrame(); |
| 5468 |
var subscription = new Subscription(); |
| 5469 |
subscription.add(new Subscription(function () { |
| 5470 |
subject.logUnsubscribedFrame(index); |
| 5471 |
})); |
| 5472 |
subscription.add(_super.prototype._subscribe.call(this, subscriber)); |
| 5473 |
return subscription; |
| 5474 |
}; |
| 5475 |
HotObservable.prototype.setup = function () { |
| 5476 |
var subject = this; |
| 5477 |
var messagesLength = subject.messages.length; |
| 5478 |
var _loop_1 = function (i) { |
| 5479 |
(function () { |
| 5480 |
var _a = subject.messages[i], notification = _a.notification, frame = _a.frame; |
| 5481 |
subject.scheduler.schedule(function () { |
| 5482 |
observeNotification(notification, subject); |
| 5483 |
}, frame); |
| 5484 |
})(); |
| 5485 |
}; |
| 5486 |
for (var i = 0; i < messagesLength; i++) { |
| 5487 |
_loop_1(i); |
| 5488 |
} |
| 5489 |
}; |
| 5490 |
return HotObservable; |
| 5491 |
}(Subject)); |
| 5492 |
applyMixins(HotObservable, [SubscriptionLoggable]); |
| 5493 |
|
| 5494 |
var defaultMaxFrame = 750; |
| 5495 |
var TestScheduler = (function (_super) { |
| 5496 |
__extends(TestScheduler, _super); |
| 5497 |
function TestScheduler(assertDeepEqual) { |
| 5498 |
var _this = _super.call(this, VirtualAction, defaultMaxFrame) || this; |
| 5499 |
_this.assertDeepEqual = assertDeepEqual; |
| 5500 |
_this.hotObservables = []; |
| 5501 |
_this.coldObservables = []; |
| 5502 |
_this.flushTests = []; |
| 5503 |
_this.runMode = false; |
| 5504 |
return _this; |
| 5505 |
} |
| 5506 |
TestScheduler.prototype.createTime = function (marbles) { |
| 5507 |
var indexOf = this.runMode ? marbles.trim().indexOf('|') : marbles.indexOf('|'); |
| 5508 |
if (indexOf === -1) { |
| 5509 |
throw new Error('marble diagram for time should have a completion marker "|"'); |
| 5510 |
} |
| 5511 |
return indexOf * TestScheduler.frameTimeFactor; |
| 5512 |
}; |
| 5513 |
TestScheduler.prototype.createColdObservable = function (marbles, values, error) { |
| 5514 |
if (marbles.indexOf('^') !== -1) { |
| 5515 |
throw new Error('cold observable cannot have subscription offset "^"'); |
| 5516 |
} |
| 5517 |
if (marbles.indexOf('!') !== -1) { |
| 5518 |
throw new Error('cold observable cannot have unsubscription marker "!"'); |
| 5519 |
} |
| 5520 |
var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode); |
| 5521 |
var cold = new ColdObservable(messages, this); |
| 5522 |
this.coldObservables.push(cold); |
| 5523 |
return cold; |
| 5524 |
}; |
| 5525 |
TestScheduler.prototype.createHotObservable = function (marbles, values, error) { |
| 5526 |
if (marbles.indexOf('!') !== -1) { |
| 5527 |
throw new Error('hot observable cannot have unsubscription marker "!"'); |
| 5528 |
} |
| 5529 |
var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode); |
| 5530 |
var subject = new HotObservable(messages, this); |
| 5531 |
this.hotObservables.push(subject); |
| 5532 |
return subject; |
| 5533 |
}; |
| 5534 |
TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) { |
| 5535 |
var _this = this; |
| 5536 |
var messages = []; |
| 5537 |
observable.subscribe({ |
| 5538 |
next: function (value) { |
| 5539 |
messages.push({ frame: _this.frame - outerFrame, notification: nextNotification(value) }); |
| 5540 |
}, |
| 5541 |
error: function (error) { |
| 5542 |
messages.push({ frame: _this.frame - outerFrame, notification: errorNotification(error) }); |
| 5543 |
}, |
| 5544 |
complete: function () { |
| 5545 |
messages.push({ frame: _this.frame - outerFrame, notification: COMPLETE_NOTIFICATION }); |
| 5546 |
}, |
| 5547 |
}); |
| 5548 |
return messages; |
| 5549 |
}; |
| 5550 |
TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) { |
| 5551 |
var _this = this; |
| 5552 |
if (subscriptionMarbles === void 0) { subscriptionMarbles = null; } |
| 5553 |
var actual = []; |
| 5554 |
var flushTest = { actual: actual, ready: false }; |
| 5555 |
var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode); |
| 5556 |
var subscriptionFrame = subscriptionParsed.subscribedFrame === Infinity ? 0 : subscriptionParsed.subscribedFrame; |
| 5557 |
var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame; |
| 5558 |
var subscription; |
| 5559 |
this.schedule(function () { |
| 5560 |
subscription = observable.subscribe({ |
| 5561 |
next: function (x) { |
| 5562 |
var value = x instanceof Observable ? _this.materializeInnerObservable(x, _this.frame) : x; |
| 5563 |
actual.push({ frame: _this.frame, notification: nextNotification(value) }); |
| 5564 |
}, |
| 5565 |
error: function (error) { |
| 5566 |
actual.push({ frame: _this.frame, notification: errorNotification(error) }); |
| 5567 |
}, |
| 5568 |
complete: function () { |
| 5569 |
actual.push({ frame: _this.frame, notification: COMPLETE_NOTIFICATION }); |
| 5570 |
}, |
| 5571 |
}); |
| 5572 |
}, subscriptionFrame); |
| 5573 |
if (unsubscriptionFrame !== Infinity) { |
| 5574 |
this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame); |
| 5575 |
} |
| 5576 |
this.flushTests.push(flushTest); |
| 5577 |
var runMode = this.runMode; |
| 5578 |
return { |
| 5579 |
toBe: function (marbles, values, errorValue) { |
| 5580 |
flushTest.ready = true; |
| 5581 |
flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode); |
| 5582 |
}, |
| 5583 |
toEqual: function (other) { |
| 5584 |
flushTest.ready = true; |
| 5585 |
flushTest.expected = []; |
| 5586 |
_this.schedule(function () { |
| 5587 |
subscription = other.subscribe({ |
| 5588 |
next: function (x) { |
| 5589 |
var value = x instanceof Observable ? _this.materializeInnerObservable(x, _this.frame) : x; |
| 5590 |
flushTest.expected.push({ frame: _this.frame, notification: nextNotification(value) }); |
| 5591 |
}, |
| 5592 |
error: function (error) { |
| 5593 |
flushTest.expected.push({ frame: _this.frame, notification: errorNotification(error) }); |
| 5594 |
}, |
| 5595 |
complete: function () { |
| 5596 |
flushTest.expected.push({ frame: _this.frame, notification: COMPLETE_NOTIFICATION }); |
| 5597 |
}, |
| 5598 |
}); |
| 5599 |
}, subscriptionFrame); |
| 5600 |
}, |
| 5601 |
}; |
| 5602 |
}; |
| 5603 |
TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) { |
| 5604 |
var flushTest = { actual: actualSubscriptionLogs, ready: false }; |
| 5605 |
this.flushTests.push(flushTest); |
| 5606 |
var runMode = this.runMode; |
| 5607 |
return { |
| 5608 |
toBe: function (marblesOrMarblesArray) { |
| 5609 |
var marblesArray = typeof marblesOrMarblesArray === 'string' ? [marblesOrMarblesArray] : marblesOrMarblesArray; |
| 5610 |
flushTest.ready = true; |
| 5611 |
flushTest.expected = marblesArray |
| 5612 |
.map(function (marbles) { return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode); }) |
| 5613 |
.filter(function (marbles) { return marbles.subscribedFrame !== Infinity; }); |
| 5614 |
}, |
| 5615 |
}; |
| 5616 |
}; |
| 5617 |
TestScheduler.prototype.flush = function () { |
| 5618 |
var _this = this; |
| 5619 |
var hotObservables = this.hotObservables; |
| 5620 |
while (hotObservables.length > 0) { |
| 5621 |
hotObservables.shift().setup(); |
| 5622 |
} |
| 5623 |
_super.prototype.flush.call(this); |
| 5624 |
this.flushTests = this.flushTests.filter(function (test) { |
| 5625 |
if (test.ready) { |
| 5626 |
_this.assertDeepEqual(test.actual, test.expected); |
| 5627 |
return false; |
| 5628 |
} |
| 5629 |
return true; |
| 5630 |
}); |
| 5631 |
}; |
| 5632 |
TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) { |
| 5633 |
var _this = this; |
| 5634 |
if (runMode === void 0) { runMode = false; } |
| 5635 |
if (typeof marbles !== 'string') { |
| 5636 |
return new SubscriptionLog(Infinity); |
| 5637 |
} |
| 5638 |
var characters = __spreadArray([], __read(marbles)); |
| 5639 |
var len = characters.length; |
| 5640 |
var groupStart = -1; |
| 5641 |
var subscriptionFrame = Infinity; |
| 5642 |
var unsubscriptionFrame = Infinity; |
| 5643 |
var frame = 0; |
| 5644 |
var _loop_1 = function (i) { |
| 5645 |
var nextFrame = frame; |
| 5646 |
var advanceFrameBy = function (count) { |
| 5647 |
nextFrame += count * _this.frameTimeFactor; |
| 5648 |
}; |
| 5649 |
var c = characters[i]; |
| 5650 |
switch (c) { |
| 5651 |
case ' ': |
| 5652 |
if (!runMode) { |
| 5653 |
advanceFrameBy(1); |
| 5654 |
} |
| 5655 |
break; |
| 5656 |
case '-': |
| 5657 |
advanceFrameBy(1); |
| 5658 |
break; |
| 5659 |
case '(': |
| 5660 |
groupStart = frame; |
| 5661 |
advanceFrameBy(1); |
| 5662 |
break; |
| 5663 |
case ')': |
| 5664 |
groupStart = -1; |
| 5665 |
advanceFrameBy(1); |
| 5666 |
break; |
| 5667 |
case '^': |
| 5668 |
if (subscriptionFrame !== Infinity) { |
| 5669 |
throw new Error("found a second subscription point '^' in a " + 'subscription marble diagram. There can only be one.'); |
| 5670 |
} |
| 5671 |
subscriptionFrame = groupStart > -1 ? groupStart : frame; |
| 5672 |
advanceFrameBy(1); |
| 5673 |
break; |
| 5674 |
case '!': |
| 5675 |
if (unsubscriptionFrame !== Infinity) { |
| 5676 |
throw new Error("found a second unsubscription point '!' in a " + 'subscription marble diagram. There can only be one.'); |
| 5677 |
} |
| 5678 |
unsubscriptionFrame = groupStart > -1 ? groupStart : frame; |
| 5679 |
break; |
| 5680 |
default: |
| 5681 |
if (runMode && c.match(/^[0-9]$/)) { |
| 5682 |
if (i === 0 || characters[i - 1] === ' ') { |
| 5683 |
var buffer = characters.slice(i).join(''); |
| 5684 |
var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /); |
| 5685 |
if (match) { |
| 5686 |
i += match[0].length - 1; |
| 5687 |
var duration = parseFloat(match[1]); |
| 5688 |
var unit = match[2]; |
| 5689 |
var durationInMs = void 0; |
| 5690 |
switch (unit) { |
| 5691 |
case 'ms': |
| 5692 |
durationInMs = duration; |
| 5693 |
break; |
| 5694 |
case 's': |
| 5695 |
durationInMs = duration * 1000; |
| 5696 |
break; |
| 5697 |
case 'm': |
| 5698 |
durationInMs = duration * 1000 * 60; |
| 5699 |
break; |
| 5700 |
default: |
| 5701 |
break; |
| 5702 |
} |
| 5703 |
advanceFrameBy(durationInMs / this_1.frameTimeFactor); |
| 5704 |
break; |
| 5705 |
} |
| 5706 |
} |
| 5707 |
} |
| 5708 |
throw new Error("there can only be '^' and '!' markers in a " + "subscription marble diagram. Found instead '" + c + "'."); |
| 5709 |
} |
| 5710 |
frame = nextFrame; |
| 5711 |
out_i_1 = i; |
| 5712 |
}; |
| 5713 |
var this_1 = this, out_i_1; |
| 5714 |
for (var i = 0; i < len; i++) { |
| 5715 |
_loop_1(i); |
| 5716 |
i = out_i_1; |
| 5717 |
} |
| 5718 |
if (unsubscriptionFrame < 0) { |
| 5719 |
return new SubscriptionLog(subscriptionFrame); |
| 5720 |
} |
| 5721 |
else { |
| 5722 |
return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame); |
| 5723 |
} |
| 5724 |
}; |
| 5725 |
TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) { |
| 5726 |
var _this = this; |
| 5727 |
if (materializeInnerObservables === void 0) { materializeInnerObservables = false; } |
| 5728 |
if (runMode === void 0) { runMode = false; } |
| 5729 |
if (marbles.indexOf('!') !== -1) { |
| 5730 |
throw new Error('conventional marble diagrams cannot have the ' + 'unsubscription marker "!"'); |
| 5731 |
} |
| 5732 |
var characters = __spreadArray([], __read(marbles)); |
| 5733 |
var len = characters.length; |
| 5734 |
var testMessages = []; |
| 5735 |
var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^'); |
| 5736 |
var frame = subIndex === -1 ? 0 : subIndex * -this.frameTimeFactor; |
| 5737 |
var getValue = typeof values !== 'object' |
| 5738 |
? function (x) { return x; } |
| 5739 |
: function (x) { |
| 5740 |
if (materializeInnerObservables && values[x] instanceof ColdObservable) { |
| 5741 |
return values[x].messages; |
| 5742 |
} |
| 5743 |
return values[x]; |
| 5744 |
}; |
| 5745 |
var groupStart = -1; |
| 5746 |
var _loop_2 = function (i) { |
| 5747 |
var nextFrame = frame; |
| 5748 |
var advanceFrameBy = function (count) { |
| 5749 |
nextFrame += count * _this.frameTimeFactor; |
| 5750 |
}; |
| 5751 |
var notification = void 0; |
| 5752 |
var c = characters[i]; |
| 5753 |
switch (c) { |
| 5754 |
case ' ': |
| 5755 |
if (!runMode) { |
| 5756 |
advanceFrameBy(1); |
| 5757 |
} |
| 5758 |
break; |
| 5759 |
case '-': |
| 5760 |
advanceFrameBy(1); |
| 5761 |
break; |
| 5762 |
case '(': |
| 5763 |
groupStart = frame; |
| 5764 |
advanceFrameBy(1); |
| 5765 |
break; |
| 5766 |
case ')': |
| 5767 |
groupStart = -1; |
| 5768 |
advanceFrameBy(1); |
| 5769 |
break; |
| 5770 |
case '|': |
| 5771 |
notification = COMPLETE_NOTIFICATION; |
| 5772 |
advanceFrameBy(1); |
| 5773 |
break; |
| 5774 |
case '^': |
| 5775 |
advanceFrameBy(1); |
| 5776 |
break; |
| 5777 |
case '#': |
| 5778 |
notification = errorNotification(errorValue || 'error'); |
| 5779 |
advanceFrameBy(1); |
| 5780 |
break; |
| 5781 |
default: |
| 5782 |
if (runMode && c.match(/^[0-9]$/)) { |
| 5783 |
if (i === 0 || characters[i - 1] === ' ') { |
| 5784 |
var buffer = characters.slice(i).join(''); |
| 5785 |
var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /); |
| 5786 |
if (match) { |
| 5787 |
i += match[0].length - 1; |
| 5788 |
var duration = parseFloat(match[1]); |
| 5789 |
var unit = match[2]; |
| 5790 |
var durationInMs = void 0; |
| 5791 |
switch (unit) { |
| 5792 |
case 'ms': |
| 5793 |
durationInMs = duration; |
| 5794 |
break; |
| 5795 |
case 's': |
| 5796 |
durationInMs = duration * 1000; |
| 5797 |
break; |
| 5798 |
case 'm': |
| 5799 |
durationInMs = duration * 1000 * 60; |
| 5800 |
break; |
| 5801 |
default: |
| 5802 |
break; |
| 5803 |
} |
| 5804 |
advanceFrameBy(durationInMs / this_2.frameTimeFactor); |
| 5805 |
break; |
| 5806 |
} |
| 5807 |
} |
| 5808 |
} |
| 5809 |
notification = nextNotification(getValue(c)); |
| 5810 |
advanceFrameBy(1); |
| 5811 |
break; |
| 5812 |
} |
| 5813 |
if (notification) { |
| 5814 |
testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification }); |
| 5815 |
} |
| 5816 |
frame = nextFrame; |
| 5817 |
out_i_2 = i; |
| 5818 |
}; |
| 5819 |
var this_2 = this, out_i_2; |
| 5820 |
for (var i = 0; i < len; i++) { |
| 5821 |
_loop_2(i); |
| 5822 |
i = out_i_2; |
| 5823 |
} |
| 5824 |
return testMessages; |
| 5825 |
}; |
| 5826 |
TestScheduler.prototype.createAnimator = function () { |
| 5827 |
var _this = this; |
| 5828 |
if (!this.runMode) { |
| 5829 |
throw new Error('animate() must only be used in run mode'); |
| 5830 |
} |
| 5831 |
var lastHandle = 0; |
| 5832 |
var map; |
| 5833 |
var delegate = { |
| 5834 |
requestAnimationFrame: function (callback) { |
| 5835 |
if (!map) { |
| 5836 |
throw new Error('animate() was not called within run()'); |
| 5837 |
} |
| 5838 |
var handle = ++lastHandle; |
| 5839 |
map.set(handle, callback); |
| 5840 |
return handle; |
| 5841 |
}, |
| 5842 |
cancelAnimationFrame: function (handle) { |
| 5843 |
if (!map) { |
| 5844 |
throw new Error('animate() was not called within run()'); |
| 5845 |
} |
| 5846 |
map.delete(handle); |
| 5847 |
}, |
| 5848 |
}; |
| 5849 |
var animate = function (marbles) { |
| 5850 |
var e_1, _a; |
| 5851 |
if (map) { |
| 5852 |
throw new Error('animate() must not be called more than once within run()'); |
| 5853 |
} |
| 5854 |
if (/[|#]/.test(marbles)) { |
| 5855 |
throw new Error('animate() must not complete or error'); |
| 5856 |
} |
| 5857 |
map = new Map(); |
| 5858 |
var messages = TestScheduler.parseMarbles(marbles, undefined, undefined, undefined, true); |
| 5859 |
try { |
| 5860 |
for (var messages_1 = __values(messages), messages_1_1 = messages_1.next(); !messages_1_1.done; messages_1_1 = messages_1.next()) { |
| 5861 |
var message = messages_1_1.value; |
| 5862 |
_this.schedule(function () { |
| 5863 |
var e_2, _a; |
| 5864 |
var now = _this.now(); |
| 5865 |
var callbacks = Array.from(map.values()); |
| 5866 |
map.clear(); |
| 5867 |
try { |
| 5868 |
for (var callbacks_1 = (e_2 = void 0, __values(callbacks)), callbacks_1_1 = callbacks_1.next(); !callbacks_1_1.done; callbacks_1_1 = callbacks_1.next()) { |
| 5869 |
var callback = callbacks_1_1.value; |
| 5870 |
callback(now); |
| 5871 |
} |
| 5872 |
} |
| 5873 |
catch (e_2_1) { e_2 = { error: e_2_1 }; } |
| 5874 |
finally { |
| 5875 |
try { |
| 5876 |
if (callbacks_1_1 && !callbacks_1_1.done && (_a = callbacks_1.return)) _a.call(callbacks_1); |
| 5877 |
} |
| 5878 |
finally { if (e_2) throw e_2.error; } |
| 5879 |
} |
| 5880 |
}, message.frame); |
| 5881 |
} |
| 5882 |
} |
| 5883 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 5884 |
finally { |
| 5885 |
try { |
| 5886 |
if (messages_1_1 && !messages_1_1.done && (_a = messages_1.return)) _a.call(messages_1); |
| 5887 |
} |
| 5888 |
finally { if (e_1) throw e_1.error; } |
| 5889 |
} |
| 5890 |
}; |
| 5891 |
return { animate: animate, delegate: delegate }; |
| 5892 |
}; |
| 5893 |
TestScheduler.prototype.createDelegates = function () { |
| 5894 |
var _this = this; |
| 5895 |
var lastHandle = 0; |
| 5896 |
var scheduleLookup = new Map(); |
| 5897 |
var run = function () { |
| 5898 |
var now = _this.now(); |
| 5899 |
var scheduledRecords = Array.from(scheduleLookup.values()); |
| 5900 |
var scheduledRecordsDue = scheduledRecords.filter(function (_a) { |
| 5901 |
var due = _a.due; |
| 5902 |
return due <= now; |
| 5903 |
}); |
| 5904 |
var dueImmediates = scheduledRecordsDue.filter(function (_a) { |
| 5905 |
var type = _a.type; |
| 5906 |
return type === 'immediate'; |
| 5907 |
}); |
| 5908 |
if (dueImmediates.length > 0) { |
| 5909 |
var _a = dueImmediates[0], handle = _a.handle, handler = _a.handler; |
| 5910 |
scheduleLookup.delete(handle); |
| 5911 |
handler(); |
| 5912 |
return; |
| 5913 |
} |
| 5914 |
var dueIntervals = scheduledRecordsDue.filter(function (_a) { |
| 5915 |
var type = _a.type; |
| 5916 |
return type === 'interval'; |
| 5917 |
}); |
| 5918 |
if (dueIntervals.length > 0) { |
| 5919 |
var firstDueInterval = dueIntervals[0]; |
| 5920 |
var duration = firstDueInterval.duration, handler = firstDueInterval.handler; |
| 5921 |
firstDueInterval.due = now + duration; |
| 5922 |
firstDueInterval.subscription = _this.schedule(run, duration); |
| 5923 |
handler(); |
| 5924 |
return; |
| 5925 |
} |
| 5926 |
var dueTimeouts = scheduledRecordsDue.filter(function (_a) { |
| 5927 |
var type = _a.type; |
| 5928 |
return type === 'timeout'; |
| 5929 |
}); |
| 5930 |
if (dueTimeouts.length > 0) { |
| 5931 |
var _b = dueTimeouts[0], handle = _b.handle, handler = _b.handler; |
| 5932 |
scheduleLookup.delete(handle); |
| 5933 |
handler(); |
| 5934 |
return; |
| 5935 |
} |
| 5936 |
throw new Error('Expected a due immediate or interval'); |
| 5937 |
}; |
| 5938 |
var immediate = { |
| 5939 |
setImmediate: function (handler) { |
| 5940 |
var handle = ++lastHandle; |
| 5941 |
scheduleLookup.set(handle, { |
| 5942 |
due: _this.now(), |
| 5943 |
duration: 0, |
| 5944 |
handle: handle, |
| 5945 |
handler: handler, |
| 5946 |
subscription: _this.schedule(run, 0), |
| 5947 |
type: 'immediate', |
| 5948 |
}); |
| 5949 |
return handle; |
| 5950 |
}, |
| 5951 |
clearImmediate: function (handle) { |
| 5952 |
var value = scheduleLookup.get(handle); |
| 5953 |
if (value) { |
| 5954 |
value.subscription.unsubscribe(); |
| 5955 |
scheduleLookup.delete(handle); |
| 5956 |
} |
| 5957 |
}, |
| 5958 |
}; |
| 5959 |
var interval = { |
| 5960 |
setInterval: function (handler, duration) { |
| 5961 |
if (duration === void 0) { duration = 0; } |
| 5962 |
var handle = ++lastHandle; |
| 5963 |
scheduleLookup.set(handle, { |
| 5964 |
due: _this.now() + duration, |
| 5965 |
duration: duration, |
| 5966 |
handle: handle, |
| 5967 |
handler: handler, |
| 5968 |
subscription: _this.schedule(run, duration), |
| 5969 |
type: 'interval', |
| 5970 |
}); |
| 5971 |
return handle; |
| 5972 |
}, |
| 5973 |
clearInterval: function (handle) { |
| 5974 |
var value = scheduleLookup.get(handle); |
| 5975 |
if (value) { |
| 5976 |
value.subscription.unsubscribe(); |
| 5977 |
scheduleLookup.delete(handle); |
| 5978 |
} |
| 5979 |
}, |
| 5980 |
}; |
| 5981 |
var timeout = { |
| 5982 |
setTimeout: function (handler, duration) { |
| 5983 |
if (duration === void 0) { duration = 0; } |
| 5984 |
var handle = ++lastHandle; |
| 5985 |
scheduleLookup.set(handle, { |
| 5986 |
due: _this.now() + duration, |
| 5987 |
duration: duration, |
| 5988 |
handle: handle, |
| 5989 |
handler: handler, |
| 5990 |
subscription: _this.schedule(run, duration), |
| 5991 |
type: 'timeout', |
| 5992 |
}); |
| 5993 |
return handle; |
| 5994 |
}, |
| 5995 |
clearTimeout: function (handle) { |
| 5996 |
var value = scheduleLookup.get(handle); |
| 5997 |
if (value) { |
| 5998 |
value.subscription.unsubscribe(); |
| 5999 |
scheduleLookup.delete(handle); |
| 6000 |
} |
| 6001 |
}, |
| 6002 |
}; |
| 6003 |
return { immediate: immediate, interval: interval, timeout: timeout }; |
| 6004 |
}; |
| 6005 |
TestScheduler.prototype.run = function (callback) { |
| 6006 |
var prevFrameTimeFactor = TestScheduler.frameTimeFactor; |
| 6007 |
var prevMaxFrames = this.maxFrames; |
| 6008 |
TestScheduler.frameTimeFactor = 1; |
| 6009 |
this.maxFrames = Infinity; |
| 6010 |
this.runMode = true; |
| 6011 |
var animator = this.createAnimator(); |
| 6012 |
var delegates = this.createDelegates(); |
| 6013 |
animationFrameProvider.delegate = animator.delegate; |
| 6014 |
dateTimestampProvider.delegate = this; |
| 6015 |
immediateProvider.delegate = delegates.immediate; |
| 6016 |
intervalProvider.delegate = delegates.interval; |
| 6017 |
timeoutProvider.delegate = delegates.timeout; |
| 6018 |
performanceTimestampProvider.delegate = this; |
| 6019 |
var helpers = { |
| 6020 |
cold: this.createColdObservable.bind(this), |
| 6021 |
hot: this.createHotObservable.bind(this), |
| 6022 |
flush: this.flush.bind(this), |
| 6023 |
time: this.createTime.bind(this), |
| 6024 |
expectObservable: this.expectObservable.bind(this), |
| 6025 |
expectSubscriptions: this.expectSubscriptions.bind(this), |
| 6026 |
animate: animator.animate, |
| 6027 |
}; |
| 6028 |
try { |
| 6029 |
var ret = callback(helpers); |
| 6030 |
this.flush(); |
| 6031 |
return ret; |
| 6032 |
} |
| 6033 |
finally { |
| 6034 |
TestScheduler.frameTimeFactor = prevFrameTimeFactor; |
| 6035 |
this.maxFrames = prevMaxFrames; |
| 6036 |
this.runMode = false; |
| 6037 |
animationFrameProvider.delegate = undefined; |
| 6038 |
dateTimestampProvider.delegate = undefined; |
| 6039 |
immediateProvider.delegate = undefined; |
| 6040 |
intervalProvider.delegate = undefined; |
| 6041 |
timeoutProvider.delegate = undefined; |
| 6042 |
performanceTimestampProvider.delegate = undefined; |
| 6043 |
} |
| 6044 |
}; |
| 6045 |
TestScheduler.frameTimeFactor = 10; |
| 6046 |
return TestScheduler; |
| 6047 |
}(VirtualTimeScheduler)); |
| 6048 |
|
| 6049 |
|
| 6050 |
|
| 6051 |
var _testing = /*#__PURE__*/Object.freeze({ |
| 6052 |
TestScheduler: TestScheduler |
| 6053 |
}); |
| 6054 |
|
| 6055 |
function getXHRResponse(xhr) { |
| 6056 |
switch (xhr.responseType) { |
| 6057 |
case 'json': { |
| 6058 |
if ('response' in xhr) { |
| 6059 |
return xhr.response; |
| 6060 |
} |
| 6061 |
else { |
| 6062 |
var ieXHR = xhr; |
| 6063 |
return JSON.parse(ieXHR.responseText); |
| 6064 |
} |
| 6065 |
} |
| 6066 |
case 'document': |
| 6067 |
return xhr.responseXML; |
| 6068 |
case 'text': |
| 6069 |
default: { |
| 6070 |
if ('response' in xhr) { |
| 6071 |
return xhr.response; |
| 6072 |
} |
| 6073 |
else { |
| 6074 |
var ieXHR = xhr; |
| 6075 |
return ieXHR.responseText; |
| 6076 |
} |
| 6077 |
} |
| 6078 |
} |
| 6079 |
} |
| 6080 |
|
| 6081 |
var AjaxResponse = (function () { |
| 6082 |
function AjaxResponse(originalEvent, xhr, request, type) { |
| 6083 |
if (type === void 0) { type = 'download_load'; } |
| 6084 |
this.originalEvent = originalEvent; |
| 6085 |
this.xhr = xhr; |
| 6086 |
this.request = request; |
| 6087 |
this.type = type; |
| 6088 |
var status = xhr.status, responseType = xhr.responseType; |
| 6089 |
this.status = status !== null && status !== void 0 ? status : 0; |
| 6090 |
this.responseType = responseType !== null && responseType !== void 0 ? responseType : ''; |
| 6091 |
var allHeaders = xhr.getAllResponseHeaders(); |
| 6092 |
this.responseHeaders = allHeaders |
| 6093 |
? |
| 6094 |
allHeaders.split('\n').reduce(function (headers, line) { |
| 6095 |
var index = line.indexOf(': '); |
| 6096 |
headers[line.slice(0, index)] = line.slice(index + 2); |
| 6097 |
return headers; |
| 6098 |
}, {}) |
| 6099 |
: {}; |
| 6100 |
this.response = getXHRResponse(xhr); |
| 6101 |
var loaded = originalEvent.loaded, total = originalEvent.total; |
| 6102 |
this.loaded = loaded; |
| 6103 |
this.total = total; |
| 6104 |
} |
| 6105 |
return AjaxResponse; |
| 6106 |
}()); |
| 6107 |
|
| 6108 |
var AjaxError = createErrorClass(function (_super) { |
| 6109 |
return function AjaxErrorImpl(message, xhr, request) { |
| 6110 |
this.message = message; |
| 6111 |
this.name = 'AjaxError'; |
| 6112 |
this.xhr = xhr; |
| 6113 |
this.request = request; |
| 6114 |
this.status = xhr.status; |
| 6115 |
this.responseType = xhr.responseType; |
| 6116 |
var response; |
| 6117 |
try { |
| 6118 |
response = getXHRResponse(xhr); |
| 6119 |
} |
| 6120 |
catch (err) { |
| 6121 |
response = xhr.responseText; |
| 6122 |
} |
| 6123 |
this.response = response; |
| 6124 |
}; |
| 6125 |
}); |
| 6126 |
var AjaxTimeoutError = (function () { |
| 6127 |
function AjaxTimeoutErrorImpl(xhr, request) { |
| 6128 |
AjaxError.call(this, 'ajax timeout', xhr, request); |
| 6129 |
this.name = 'AjaxTimeoutError'; |
| 6130 |
return this; |
| 6131 |
} |
| 6132 |
AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype); |
| 6133 |
return AjaxTimeoutErrorImpl; |
| 6134 |
})(); |
| 6135 |
|
| 6136 |
function ajaxGet(url, headers) { |
| 6137 |
return ajax({ method: 'GET', url: url, headers: headers }); |
| 6138 |
} |
| 6139 |
function ajaxPost(url, body, headers) { |
| 6140 |
return ajax({ method: 'POST', url: url, body: body, headers: headers }); |
| 6141 |
} |
| 6142 |
function ajaxDelete(url, headers) { |
| 6143 |
return ajax({ method: 'DELETE', url: url, headers: headers }); |
| 6144 |
} |
| 6145 |
function ajaxPut(url, body, headers) { |
| 6146 |
return ajax({ method: 'PUT', url: url, body: body, headers: headers }); |
| 6147 |
} |
| 6148 |
function ajaxPatch(url, body, headers) { |
| 6149 |
return ajax({ method: 'PATCH', url: url, body: body, headers: headers }); |
| 6150 |
} |
| 6151 |
var mapResponse = map(function (x) { return x.response; }); |
| 6152 |
function ajaxGetJSON(url, headers) { |
| 6153 |
return mapResponse(ajax({ |
| 6154 |
method: 'GET', |
| 6155 |
url: url, |
| 6156 |
headers: headers, |
| 6157 |
})); |
| 6158 |
} |
| 6159 |
var ajax = (function () { |
| 6160 |
var create = function (urlOrConfig) { |
| 6161 |
var config = typeof urlOrConfig === 'string' |
| 6162 |
? { |
| 6163 |
url: urlOrConfig, |
| 6164 |
} |
| 6165 |
: urlOrConfig; |
| 6166 |
return fromAjax(config); |
| 6167 |
}; |
| 6168 |
create.get = ajaxGet; |
| 6169 |
create.post = ajaxPost; |
| 6170 |
create.delete = ajaxDelete; |
| 6171 |
create.put = ajaxPut; |
| 6172 |
create.patch = ajaxPatch; |
| 6173 |
create.getJSON = ajaxGetJSON; |
| 6174 |
return create; |
| 6175 |
})(); |
| 6176 |
var UPLOAD = 'upload'; |
| 6177 |
var DOWNLOAD = 'download'; |
| 6178 |
var LOADSTART = 'loadstart'; |
| 6179 |
var PROGRESS = 'progress'; |
| 6180 |
var LOAD = 'load'; |
| 6181 |
function fromAjax(init) { |
| 6182 |
return new Observable(function (destination) { |
| 6183 |
var _a, _b; |
| 6184 |
var config = __assign({ async: true, crossDomain: false, withCredentials: false, method: 'GET', timeout: 0, responseType: 'json' }, init); |
| 6185 |
var queryParams = config.queryParams, configuredBody = config.body, configuredHeaders = config.headers; |
| 6186 |
var url = config.url; |
| 6187 |
if (!url) { |
| 6188 |
throw new TypeError('url is required'); |
| 6189 |
} |
| 6190 |
if (queryParams) { |
| 6191 |
var searchParams_1; |
| 6192 |
if (url.includes('?')) { |
| 6193 |
var parts = url.split('?'); |
| 6194 |
if (2 < parts.length) { |
| 6195 |
throw new TypeError('invalid url'); |
| 6196 |
} |
| 6197 |
searchParams_1 = new URLSearchParams(parts[1]); |
| 6198 |
new URLSearchParams(queryParams).forEach(function (value, key) { return searchParams_1.set(key, value); }); |
| 6199 |
url = parts[0] + '?' + searchParams_1; |
| 6200 |
} |
| 6201 |
else { |
| 6202 |
searchParams_1 = new URLSearchParams(queryParams); |
| 6203 |
url = url + '?' + searchParams_1; |
| 6204 |
} |
| 6205 |
} |
| 6206 |
var headers = {}; |
| 6207 |
if (configuredHeaders) { |
| 6208 |
for (var key in configuredHeaders) { |
| 6209 |
if (configuredHeaders.hasOwnProperty(key)) { |
| 6210 |
headers[key.toLowerCase()] = configuredHeaders[key]; |
| 6211 |
} |
| 6212 |
} |
| 6213 |
} |
| 6214 |
var crossDomain = config.crossDomain; |
| 6215 |
if (!crossDomain && !('x-requested-with' in headers)) { |
| 6216 |
headers['x-requested-with'] = 'XMLHttpRequest'; |
| 6217 |
} |
| 6218 |
var withCredentials = config.withCredentials, xsrfCookieName = config.xsrfCookieName, xsrfHeaderName = config.xsrfHeaderName; |
| 6219 |
if ((withCredentials || !crossDomain) && xsrfCookieName && xsrfHeaderName) { |
| 6220 |
var xsrfCookie = (_b = (_a = document === null || document === void 0 ? void 0 : document.cookie.match(new RegExp("(^|;\\s*)(" + xsrfCookieName + ")=([^;]*)"))) === null || _a === void 0 ? void 0 : _a.pop()) !== null && _b !== void 0 ? _b : ''; |
| 6221 |
if (xsrfCookie) { |
| 6222 |
headers[xsrfHeaderName] = xsrfCookie; |
| 6223 |
} |
| 6224 |
} |
| 6225 |
var body = extractContentTypeAndMaybeSerializeBody(configuredBody, headers); |
| 6226 |
var _request = __assign(__assign({}, config), { url: url, |
| 6227 |
headers: headers, |
| 6228 |
body: body }); |
| 6229 |
var xhr; |
| 6230 |
xhr = init.createXHR ? init.createXHR() : new XMLHttpRequest(); |
| 6231 |
{ |
| 6232 |
var progressSubscriber_1 = init.progressSubscriber, _c = init.includeDownloadProgress, includeDownloadProgress = _c === void 0 ? false : _c, _d = init.includeUploadProgress, includeUploadProgress = _d === void 0 ? false : _d; |
| 6233 |
var addErrorEvent = function (type, errorFactory) { |
| 6234 |
xhr.addEventListener(type, function () { |
| 6235 |
var _a; |
| 6236 |
var error = errorFactory(); |
| 6237 |
(_a = progressSubscriber_1 === null || progressSubscriber_1 === void 0 ? void 0 : progressSubscriber_1.error) === null || _a === void 0 ? void 0 : _a.call(progressSubscriber_1, error); |
| 6238 |
destination.error(error); |
| 6239 |
}); |
| 6240 |
}; |
| 6241 |
addErrorEvent('timeout', function () { return new AjaxTimeoutError(xhr, _request); }); |
| 6242 |
addErrorEvent('abort', function () { return new AjaxError('aborted', xhr, _request); }); |
| 6243 |
var createResponse_1 = function (direction, event) { |
| 6244 |
return new AjaxResponse(event, xhr, _request, direction + "_" + event.type); |
| 6245 |
}; |
| 6246 |
var addProgressEvent_1 = function (target, type, direction) { |
| 6247 |
target.addEventListener(type, function (event) { |
| 6248 |
destination.next(createResponse_1(direction, event)); |
| 6249 |
}); |
| 6250 |
}; |
| 6251 |
if (includeUploadProgress) { |
| 6252 |
[LOADSTART, PROGRESS, LOAD].forEach(function (type) { return addProgressEvent_1(xhr.upload, type, UPLOAD); }); |
| 6253 |
} |
| 6254 |
if (progressSubscriber_1) { |
| 6255 |
[LOADSTART, PROGRESS].forEach(function (type) { return xhr.upload.addEventListener(type, function (e) { var _a; return (_a = progressSubscriber_1 === null || progressSubscriber_1 === void 0 ? void 0 : progressSubscriber_1.next) === null || _a === void 0 ? void 0 : _a.call(progressSubscriber_1, e); }); }); |
| 6256 |
} |
| 6257 |
if (includeDownloadProgress) { |
| 6258 |
[LOADSTART, PROGRESS].forEach(function (type) { return addProgressEvent_1(xhr, type, DOWNLOAD); }); |
| 6259 |
} |
| 6260 |
var emitError_1 = function (status) { |
| 6261 |
var msg = 'ajax error' + (status ? ' ' + status : ''); |
| 6262 |
destination.error(new AjaxError(msg, xhr, _request)); |
| 6263 |
}; |
| 6264 |
xhr.addEventListener('error', function (e) { |
| 6265 |
var _a; |
| 6266 |
(_a = progressSubscriber_1 === null || progressSubscriber_1 === void 0 ? void 0 : progressSubscriber_1.error) === null || _a === void 0 ? void 0 : _a.call(progressSubscriber_1, e); |
| 6267 |
emitError_1(); |
| 6268 |
}); |
| 6269 |
xhr.addEventListener(LOAD, function (event) { |
| 6270 |
var _a, _b; |
| 6271 |
var status = xhr.status; |
| 6272 |
if (status < 400) { |
| 6273 |
(_a = progressSubscriber_1 === null || progressSubscriber_1 === void 0 ? void 0 : progressSubscriber_1.complete) === null || _a === void 0 ? void 0 : _a.call(progressSubscriber_1); |
| 6274 |
var response = void 0; |
| 6275 |
try { |
| 6276 |
response = createResponse_1(DOWNLOAD, event); |
| 6277 |
} |
| 6278 |
catch (err) { |
| 6279 |
destination.error(err); |
| 6280 |
return; |
| 6281 |
} |
| 6282 |
destination.next(response); |
| 6283 |
destination.complete(); |
| 6284 |
} |
| 6285 |
else { |
| 6286 |
(_b = progressSubscriber_1 === null || progressSubscriber_1 === void 0 ? void 0 : progressSubscriber_1.error) === null || _b === void 0 ? void 0 : _b.call(progressSubscriber_1, event); |
| 6287 |
emitError_1(status); |
| 6288 |
} |
| 6289 |
}); |
| 6290 |
} |
| 6291 |
var user = _request.user, method = _request.method, async = _request.async; |
| 6292 |
if (user) { |
| 6293 |
xhr.open(method, url, async, user, _request.password); |
| 6294 |
} |
| 6295 |
else { |
| 6296 |
xhr.open(method, url, async); |
| 6297 |
} |
| 6298 |
if (async) { |
| 6299 |
xhr.timeout = _request.timeout; |
| 6300 |
xhr.responseType = _request.responseType; |
| 6301 |
} |
| 6302 |
if ('withCredentials' in xhr) { |
| 6303 |
xhr.withCredentials = _request.withCredentials; |
| 6304 |
} |
| 6305 |
for (var key in headers) { |
| 6306 |
if (headers.hasOwnProperty(key)) { |
| 6307 |
xhr.setRequestHeader(key, headers[key]); |
| 6308 |
} |
| 6309 |
} |
| 6310 |
if (body) { |
| 6311 |
xhr.send(body); |
| 6312 |
} |
| 6313 |
else { |
| 6314 |
xhr.send(); |
| 6315 |
} |
| 6316 |
return function () { |
| 6317 |
if (xhr && xhr.readyState !== 4) { |
| 6318 |
xhr.abort(); |
| 6319 |
} |
| 6320 |
}; |
| 6321 |
}); |
| 6322 |
} |
| 6323 |
function extractContentTypeAndMaybeSerializeBody(body, headers) { |
| 6324 |
var _a; |
| 6325 |
if (!body || |
| 6326 |
typeof body === 'string' || |
| 6327 |
isFormData(body) || |
| 6328 |
isURLSearchParams(body) || |
| 6329 |
isArrayBuffer(body) || |
| 6330 |
isFile(body) || |
| 6331 |
isBlob(body) || |
| 6332 |
isReadableStream(body)) { |
| 6333 |
return body; |
| 6334 |
} |
| 6335 |
if (isArrayBufferView(body)) { |
| 6336 |
return body.buffer; |
| 6337 |
} |
| 6338 |
if (typeof body === 'object') { |
| 6339 |
headers['content-type'] = (_a = headers['content-type']) !== null && _a !== void 0 ? _a : 'application/json;charset=utf-8'; |
| 6340 |
return JSON.stringify(body); |
| 6341 |
} |
| 6342 |
throw new TypeError('Unknown body type'); |
| 6343 |
} |
| 6344 |
var _toString = Object.prototype.toString; |
| 6345 |
function toStringCheck(obj, name) { |
| 6346 |
return _toString.call(obj) === "[object " + name + "]"; |
| 6347 |
} |
| 6348 |
function isArrayBuffer(body) { |
| 6349 |
return toStringCheck(body, 'ArrayBuffer'); |
| 6350 |
} |
| 6351 |
function isFile(body) { |
| 6352 |
return toStringCheck(body, 'File'); |
| 6353 |
} |
| 6354 |
function isBlob(body) { |
| 6355 |
return toStringCheck(body, 'Blob'); |
| 6356 |
} |
| 6357 |
function isArrayBufferView(body) { |
| 6358 |
return typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(body); |
| 6359 |
} |
| 6360 |
function isFormData(body) { |
| 6361 |
return typeof FormData !== 'undefined' && body instanceof FormData; |
| 6362 |
} |
| 6363 |
function isURLSearchParams(body) { |
| 6364 |
return typeof URLSearchParams !== 'undefined' && body instanceof URLSearchParams; |
| 6365 |
} |
| 6366 |
function isReadableStream(body) { |
| 6367 |
return typeof ReadableStream !== 'undefined' && body instanceof ReadableStream; |
| 6368 |
} |
| 6369 |
|
| 6370 |
|
| 6371 |
|
| 6372 |
var _ajax = /*#__PURE__*/Object.freeze({ |
| 6373 |
ajax: ajax, |
| 6374 |
AjaxError: AjaxError, |
| 6375 |
AjaxTimeoutError: AjaxTimeoutError, |
| 6376 |
AjaxResponse: AjaxResponse |
| 6377 |
}); |
| 6378 |
|
| 6379 |
var DEFAULT_WEBSOCKET_CONFIG = { |
| 6380 |
url: '', |
| 6381 |
deserializer: function (e) { return JSON.parse(e.data); }, |
| 6382 |
serializer: function (value) { return JSON.stringify(value); }, |
| 6383 |
}; |
| 6384 |
var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }'; |
| 6385 |
var WebSocketSubject = (function (_super) { |
| 6386 |
__extends(WebSocketSubject, _super); |
| 6387 |
function WebSocketSubject(urlConfigOrSource, destination) { |
| 6388 |
var _this = _super.call(this) || this; |
| 6389 |
_this._socket = null; |
| 6390 |
if (urlConfigOrSource instanceof Observable) { |
| 6391 |
_this.destination = destination; |
| 6392 |
_this.source = urlConfigOrSource; |
| 6393 |
} |
| 6394 |
else { |
| 6395 |
var config = (_this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG)); |
| 6396 |
_this._output = new Subject(); |
| 6397 |
if (typeof urlConfigOrSource === 'string') { |
| 6398 |
config.url = urlConfigOrSource; |
| 6399 |
} |
| 6400 |
else { |
| 6401 |
for (var key in urlConfigOrSource) { |
| 6402 |
if (urlConfigOrSource.hasOwnProperty(key)) { |
| 6403 |
config[key] = urlConfigOrSource[key]; |
| 6404 |
} |
| 6405 |
} |
| 6406 |
} |
| 6407 |
if (!config.WebSocketCtor && WebSocket) { |
| 6408 |
config.WebSocketCtor = WebSocket; |
| 6409 |
} |
| 6410 |
else if (!config.WebSocketCtor) { |
| 6411 |
throw new Error('no WebSocket constructor can be found'); |
| 6412 |
} |
| 6413 |
_this.destination = new ReplaySubject(); |
| 6414 |
} |
| 6415 |
return _this; |
| 6416 |
} |
| 6417 |
WebSocketSubject.prototype.lift = function (operator) { |
| 6418 |
var sock = new WebSocketSubject(this._config, this.destination); |
| 6419 |
sock.operator = operator; |
| 6420 |
sock.source = this; |
| 6421 |
return sock; |
| 6422 |
}; |
| 6423 |
WebSocketSubject.prototype._resetState = function () { |
| 6424 |
this._socket = null; |
| 6425 |
if (!this.source) { |
| 6426 |
this.destination = new ReplaySubject(); |
| 6427 |
} |
| 6428 |
this._output = new Subject(); |
| 6429 |
}; |
| 6430 |
WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) { |
| 6431 |
var self = this; |
| 6432 |
return new Observable(function (observer) { |
| 6433 |
try { |
| 6434 |
self.next(subMsg()); |
| 6435 |
} |
| 6436 |
catch (err) { |
| 6437 |
observer.error(err); |
| 6438 |
} |
| 6439 |
var subscription = self.subscribe({ |
| 6440 |
next: function (x) { |
| 6441 |
try { |
| 6442 |
if (messageFilter(x)) { |
| 6443 |
observer.next(x); |
| 6444 |
} |
| 6445 |
} |
| 6446 |
catch (err) { |
| 6447 |
observer.error(err); |
| 6448 |
} |
| 6449 |
}, |
| 6450 |
error: function (err) { return observer.error(err); }, |
| 6451 |
complete: function () { return observer.complete(); }, |
| 6452 |
}); |
| 6453 |
return function () { |
| 6454 |
try { |
| 6455 |
self.next(unsubMsg()); |
| 6456 |
} |
| 6457 |
catch (err) { |
| 6458 |
observer.error(err); |
| 6459 |
} |
| 6460 |
subscription.unsubscribe(); |
| 6461 |
}; |
| 6462 |
}); |
| 6463 |
}; |
| 6464 |
WebSocketSubject.prototype._connectSocket = function () { |
| 6465 |
var _this = this; |
| 6466 |
var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType; |
| 6467 |
var observer = this._output; |
| 6468 |
var socket = null; |
| 6469 |
try { |
| 6470 |
socket = protocol ? new WebSocketCtor(url, protocol) : new WebSocketCtor(url); |
| 6471 |
this._socket = socket; |
| 6472 |
if (binaryType) { |
| 6473 |
this._socket.binaryType = binaryType; |
| 6474 |
} |
| 6475 |
} |
| 6476 |
catch (e) { |
| 6477 |
observer.error(e); |
| 6478 |
return; |
| 6479 |
} |
| 6480 |
var subscription = new Subscription(function () { |
| 6481 |
_this._socket = null; |
| 6482 |
if (socket && socket.readyState === 1) { |
| 6483 |
socket.close(); |
| 6484 |
} |
| 6485 |
}); |
| 6486 |
socket.onopen = function (evt) { |
| 6487 |
var _socket = _this._socket; |
| 6488 |
if (!_socket) { |
| 6489 |
socket.close(); |
| 6490 |
_this._resetState(); |
| 6491 |
return; |
| 6492 |
} |
| 6493 |
var openObserver = _this._config.openObserver; |
| 6494 |
if (openObserver) { |
| 6495 |
openObserver.next(evt); |
| 6496 |
} |
| 6497 |
var queue = _this.destination; |
| 6498 |
_this.destination = Subscriber.create(function (x) { |
| 6499 |
if (socket.readyState === 1) { |
| 6500 |
try { |
| 6501 |
var serializer = _this._config.serializer; |
| 6502 |
socket.send(serializer(x)); |
| 6503 |
} |
| 6504 |
catch (e) { |
| 6505 |
_this.destination.error(e); |
| 6506 |
} |
| 6507 |
} |
| 6508 |
}, function (err) { |
| 6509 |
var closingObserver = _this._config.closingObserver; |
| 6510 |
if (closingObserver) { |
| 6511 |
closingObserver.next(undefined); |
| 6512 |
} |
| 6513 |
if (err && err.code) { |
| 6514 |
socket.close(err.code, err.reason); |
| 6515 |
} |
| 6516 |
else { |
| 6517 |
observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT)); |
| 6518 |
} |
| 6519 |
_this._resetState(); |
| 6520 |
}, function () { |
| 6521 |
var closingObserver = _this._config.closingObserver; |
| 6522 |
if (closingObserver) { |
| 6523 |
closingObserver.next(undefined); |
| 6524 |
} |
| 6525 |
socket.close(); |
| 6526 |
_this._resetState(); |
| 6527 |
}); |
| 6528 |
if (queue && queue instanceof ReplaySubject) { |
| 6529 |
subscription.add(queue.subscribe(_this.destination)); |
| 6530 |
} |
| 6531 |
}; |
| 6532 |
socket.onerror = function (e) { |
| 6533 |
_this._resetState(); |
| 6534 |
observer.error(e); |
| 6535 |
}; |
| 6536 |
socket.onclose = function (e) { |
| 6537 |
if (socket === _this._socket) { |
| 6538 |
_this._resetState(); |
| 6539 |
} |
| 6540 |
var closeObserver = _this._config.closeObserver; |
| 6541 |
if (closeObserver) { |
| 6542 |
closeObserver.next(e); |
| 6543 |
} |
| 6544 |
if (e.wasClean) { |
| 6545 |
observer.complete(); |
| 6546 |
} |
| 6547 |
else { |
| 6548 |
observer.error(e); |
| 6549 |
} |
| 6550 |
}; |
| 6551 |
socket.onmessage = function (e) { |
| 6552 |
try { |
| 6553 |
var deserializer = _this._config.deserializer; |
| 6554 |
observer.next(deserializer(e)); |
| 6555 |
} |
| 6556 |
catch (err) { |
| 6557 |
observer.error(err); |
| 6558 |
} |
| 6559 |
}; |
| 6560 |
}; |
| 6561 |
WebSocketSubject.prototype._subscribe = function (subscriber) { |
| 6562 |
var _this = this; |
| 6563 |
var source = this.source; |
| 6564 |
if (source) { |
| 6565 |
return source.subscribe(subscriber); |
| 6566 |
} |
| 6567 |
if (!this._socket) { |
| 6568 |
this._connectSocket(); |
| 6569 |
} |
| 6570 |
this._output.subscribe(subscriber); |
| 6571 |
subscriber.add(function () { |
| 6572 |
var _socket = _this._socket; |
| 6573 |
if (_this._output.observers.length === 0) { |
| 6574 |
if (_socket && (_socket.readyState === 1 || _socket.readyState === 0)) { |
| 6575 |
_socket.close(); |
| 6576 |
} |
| 6577 |
_this._resetState(); |
| 6578 |
} |
| 6579 |
}); |
| 6580 |
return subscriber; |
| 6581 |
}; |
| 6582 |
WebSocketSubject.prototype.unsubscribe = function () { |
| 6583 |
var _socket = this._socket; |
| 6584 |
if (_socket && (_socket.readyState === 1 || _socket.readyState === 0)) { |
| 6585 |
_socket.close(); |
| 6586 |
} |
| 6587 |
this._resetState(); |
| 6588 |
_super.prototype.unsubscribe.call(this); |
| 6589 |
}; |
| 6590 |
return WebSocketSubject; |
| 6591 |
}(AnonymousSubject)); |
| 6592 |
|
| 6593 |
function webSocket(urlConfigOrSource) { |
| 6594 |
return new WebSocketSubject(urlConfigOrSource); |
| 6595 |
} |
| 6596 |
|
| 6597 |
|
| 6598 |
|
| 6599 |
var _webSocket = /*#__PURE__*/Object.freeze({ |
| 6600 |
webSocket: webSocket, |
| 6601 |
WebSocketSubject: WebSocketSubject |
| 6602 |
}); |
| 6603 |
|
| 6604 |
function fromFetch(input, initWithSelector) { |
| 6605 |
if (initWithSelector === void 0) { initWithSelector = {}; } |
| 6606 |
var selector = initWithSelector.selector, init = __rest(initWithSelector, ["selector"]); |
| 6607 |
return new Observable(function (subscriber) { |
| 6608 |
var controller = new AbortController(); |
| 6609 |
var signal = controller.signal; |
| 6610 |
var abortable = true; |
| 6611 |
var outerSignal = init.signal; |
| 6612 |
if (outerSignal) { |
| 6613 |
if (outerSignal.aborted) { |
| 6614 |
controller.abort(); |
| 6615 |
} |
| 6616 |
else { |
| 6617 |
var outerSignalHandler_1 = function () { |
| 6618 |
if (!signal.aborted) { |
| 6619 |
controller.abort(); |
| 6620 |
} |
| 6621 |
}; |
| 6622 |
outerSignal.addEventListener('abort', outerSignalHandler_1); |
| 6623 |
subscriber.add(function () { return outerSignal.removeEventListener('abort', outerSignalHandler_1); }); |
| 6624 |
} |
| 6625 |
} |
| 6626 |
var perSubscriberInit = __assign(__assign({}, init), { signal: signal }); |
| 6627 |
var handleError = function (err) { |
| 6628 |
abortable = false; |
| 6629 |
subscriber.error(err); |
| 6630 |
}; |
| 6631 |
fetch(input, perSubscriberInit) |
| 6632 |
.then(function (response) { |
| 6633 |
if (selector) { |
| 6634 |
innerFrom(selector(response)).subscribe(createOperatorSubscriber(subscriber, undefined, function () { |
| 6635 |
abortable = false; |
| 6636 |
subscriber.complete(); |
| 6637 |
}, handleError)); |
| 6638 |
} |
| 6639 |
else { |
| 6640 |
abortable = false; |
| 6641 |
subscriber.next(response); |
| 6642 |
subscriber.complete(); |
| 6643 |
} |
| 6644 |
}) |
| 6645 |
.catch(handleError); |
| 6646 |
return function () { |
| 6647 |
if (abortable) { |
| 6648 |
controller.abort(); |
| 6649 |
} |
| 6650 |
}; |
| 6651 |
}); |
| 6652 |
} |
| 6653 |
|
| 6654 |
|
| 6655 |
|
| 6656 |
var _fetch = /*#__PURE__*/Object.freeze({ |
| 6657 |
fromFetch: fromFetch |
| 6658 |
}); |
| 6659 |
|
| 6660 |
var operators = _operators; |
| 6661 |
var testing = _testing; |
| 6662 |
var ajax$1 = _ajax; |
| 6663 |
var webSocket$1 = _webSocket; |
| 6664 |
var fetch$1 = _fetch; |
| 6665 |
|
| 6666 |
exports.operators = operators; |
| 6667 |
exports.testing = testing; |
| 6668 |
exports.ajax = ajax$1; |
| 6669 |
exports.webSocket = webSocket$1; |
| 6670 |
exports.fetch = fetch$1; |
| 6671 |
exports.Observable = Observable; |
| 6672 |
exports.ConnectableObservable = ConnectableObservable; |
| 6673 |
exports.observable = observable; |
| 6674 |
exports.animationFrames = animationFrames; |
| 6675 |
exports.Subject = Subject; |
| 6676 |
exports.BehaviorSubject = BehaviorSubject; |
| 6677 |
exports.ReplaySubject = ReplaySubject; |
| 6678 |
exports.AsyncSubject = AsyncSubject; |
| 6679 |
exports.asap = asap; |
| 6680 |
exports.asapScheduler = asapScheduler; |
| 6681 |
exports.async = async; |
| 6682 |
exports.asyncScheduler = asyncScheduler; |
| 6683 |
exports.queue = queue; |
| 6684 |
exports.queueScheduler = queueScheduler; |
| 6685 |
exports.animationFrame = animationFrame; |
| 6686 |
exports.animationFrameScheduler = animationFrameScheduler; |
| 6687 |
exports.VirtualTimeScheduler = VirtualTimeScheduler; |
| 6688 |
exports.VirtualAction = VirtualAction; |
| 6689 |
exports.Scheduler = Scheduler; |
| 6690 |
exports.Subscription = Subscription; |
| 6691 |
exports.Subscriber = Subscriber; |
| 6692 |
exports.Notification = Notification; |
| 6693 |
exports.pipe = pipe; |
| 6694 |
exports.noop = noop; |
| 6695 |
exports.identity = identity; |
| 6696 |
exports.isObservable = isObservable; |
| 6697 |
exports.lastValueFrom = lastValueFrom; |
| 6698 |
exports.firstValueFrom = firstValueFrom; |
| 6699 |
exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError; |
| 6700 |
exports.EmptyError = EmptyError; |
| 6701 |
exports.NotFoundError = NotFoundError; |
| 6702 |
exports.ObjectUnsubscribedError = ObjectUnsubscribedError; |
| 6703 |
exports.SequenceError = SequenceError; |
| 6704 |
exports.TimeoutError = TimeoutError; |
| 6705 |
exports.UnsubscriptionError = UnsubscriptionError; |
| 6706 |
exports.bindCallback = bindCallback; |
| 6707 |
exports.bindNodeCallback = bindNodeCallback; |
| 6708 |
exports.combineLatest = combineLatest; |
| 6709 |
exports.concat = concat; |
| 6710 |
exports.connectable = connectable; |
| 6711 |
exports.defer = defer; |
| 6712 |
exports.empty = empty; |
| 6713 |
exports.forkJoin = forkJoin; |
| 6714 |
exports.from = from; |
| 6715 |
exports.fromEvent = fromEvent; |
| 6716 |
exports.fromEventPattern = fromEventPattern; |
| 6717 |
exports.generate = generate; |
| 6718 |
exports.iif = iif; |
| 6719 |
exports.interval = interval; |
| 6720 |
exports.merge = merge; |
| 6721 |
exports.never = never; |
| 6722 |
exports.of = of; |
| 6723 |
exports.onErrorResumeNext = onErrorResumeNext; |
| 6724 |
exports.pairs = pairs; |
| 6725 |
exports.partition = partition; |
| 6726 |
exports.race = race; |
| 6727 |
exports.range = range; |
| 6728 |
exports.throwError = throwError; |
| 6729 |
exports.timer = timer; |
| 6730 |
exports.using = using; |
| 6731 |
exports.zip = zip; |
| 6732 |
exports.scheduled = scheduled; |
| 6733 |
exports.EMPTY = EMPTY; |
| 6734 |
exports.NEVER = NEVER; |
| 6735 |
exports.config = config; |
| 6736 |
exports.audit = audit; |
| 6737 |
exports.auditTime = auditTime; |
| 6738 |
exports.buffer = buffer; |
| 6739 |
exports.bufferCount = bufferCount; |
| 6740 |
exports.bufferTime = bufferTime; |
| 6741 |
exports.bufferToggle = bufferToggle; |
| 6742 |
exports.bufferWhen = bufferWhen; |
| 6743 |
exports.catchError = catchError; |
| 6744 |
exports.combineAll = combineAll; |
| 6745 |
exports.combineLatestAll = combineLatestAll; |
| 6746 |
exports.combineLatestWith = combineLatestWith; |
| 6747 |
exports.concatAll = concatAll; |
| 6748 |
exports.concatMap = concatMap; |
| 6749 |
exports.concatMapTo = concatMapTo; |
| 6750 |
exports.concatWith = concatWith; |
| 6751 |
exports.connect = connect; |
| 6752 |
exports.count = count; |
| 6753 |
exports.debounce = debounce; |
| 6754 |
exports.debounceTime = debounceTime; |
| 6755 |
exports.defaultIfEmpty = defaultIfEmpty; |
| 6756 |
exports.delay = delay; |
| 6757 |
exports.delayWhen = delayWhen; |
| 6758 |
exports.dematerialize = dematerialize; |
| 6759 |
exports.distinct = distinct; |
| 6760 |
exports.distinctUntilChanged = distinctUntilChanged; |
| 6761 |
exports.distinctUntilKeyChanged = distinctUntilKeyChanged; |
| 6762 |
exports.elementAt = elementAt; |
| 6763 |
exports.endWith = endWith; |
| 6764 |
exports.every = every; |
| 6765 |
exports.exhaust = exhaust; |
| 6766 |
exports.exhaustAll = exhaustAll; |
| 6767 |
exports.exhaustMap = exhaustMap; |
| 6768 |
exports.expand = expand; |
| 6769 |
exports.filter = filter; |
| 6770 |
exports.finalize = finalize; |
| 6771 |
exports.find = find; |
| 6772 |
exports.findIndex = findIndex; |
| 6773 |
exports.first = first; |
| 6774 |
exports.groupBy = groupBy; |
| 6775 |
exports.ignoreElements = ignoreElements; |
| 6776 |
exports.isEmpty = isEmpty; |
| 6777 |
exports.last = last$1; |
| 6778 |
exports.map = map; |
| 6779 |
exports.mapTo = mapTo; |
| 6780 |
exports.materialize = materialize; |
| 6781 |
exports.max = max; |
| 6782 |
exports.mergeAll = mergeAll; |
| 6783 |
exports.flatMap = flatMap; |
| 6784 |
exports.mergeMap = mergeMap; |
| 6785 |
exports.mergeMapTo = mergeMapTo; |
| 6786 |
exports.mergeScan = mergeScan; |
| 6787 |
exports.mergeWith = mergeWith; |
| 6788 |
exports.min = min; |
| 6789 |
exports.multicast = multicast; |
| 6790 |
exports.observeOn = observeOn; |
| 6791 |
exports.onErrorResumeNextWith = onErrorResumeNextWith; |
| 6792 |
exports.pairwise = pairwise; |
| 6793 |
exports.pluck = pluck; |
| 6794 |
exports.publish = publish; |
| 6795 |
exports.publishBehavior = publishBehavior; |
| 6796 |
exports.publishLast = publishLast; |
| 6797 |
exports.publishReplay = publishReplay; |
| 6798 |
exports.raceWith = raceWith; |
| 6799 |
exports.reduce = reduce; |
| 6800 |
exports.repeat = repeat; |
| 6801 |
exports.repeatWhen = repeatWhen; |
| 6802 |
exports.retry = retry; |
| 6803 |
exports.retryWhen = retryWhen; |
| 6804 |
exports.refCount = refCount; |
| 6805 |
exports.sample = sample; |
| 6806 |
exports.sampleTime = sampleTime; |
| 6807 |
exports.scan = scan; |
| 6808 |
exports.sequenceEqual = sequenceEqual; |
| 6809 |
exports.share = share; |
| 6810 |
exports.shareReplay = shareReplay; |
| 6811 |
exports.single = single; |
| 6812 |
exports.skip = skip; |
| 6813 |
exports.skipLast = skipLast; |
| 6814 |
exports.skipUntil = skipUntil; |
| 6815 |
exports.skipWhile = skipWhile; |
| 6816 |
exports.startWith = startWith; |
| 6817 |
exports.subscribeOn = subscribeOn; |
| 6818 |
exports.switchAll = switchAll; |
| 6819 |
exports.switchMap = switchMap; |
| 6820 |
exports.switchMapTo = switchMapTo; |
| 6821 |
exports.switchScan = switchScan; |
| 6822 |
exports.take = take; |
| 6823 |
exports.takeLast = takeLast; |
| 6824 |
exports.takeUntil = takeUntil; |
| 6825 |
exports.takeWhile = takeWhile; |
| 6826 |
exports.tap = tap; |
| 6827 |
exports.throttle = throttle; |
| 6828 |
exports.throttleTime = throttleTime; |
| 6829 |
exports.throwIfEmpty = throwIfEmpty; |
| 6830 |
exports.timeInterval = timeInterval; |
| 6831 |
exports.timeout = timeout; |
| 6832 |
exports.timeoutWith = timeoutWith; |
| 6833 |
exports.timestamp = timestamp; |
| 6834 |
exports.toArray = toArray; |
| 6835 |
exports.window = window; |
| 6836 |
exports.windowCount = windowCount; |
| 6837 |
exports.windowTime = windowTime; |
| 6838 |
exports.windowToggle = windowToggle; |
| 6839 |
exports.windowWhen = windowWhen; |
| 6840 |
exports.withLatestFrom = withLatestFrom; |
| 6841 |
exports.zipAll = zipAll; |
| 6842 |
exports.zipWith = zipWith; |
| 6843 |
|
| 6844 |
Object.defineProperty(exports, '__esModule', { value: true }); |
| 6845 |
|
| 6846 |
}))); |
| 6847 |
|
| 6848 |
//# sourceMappingURL=rxjs.umd.js.map |
| 6849 |
|