Bez popisu

polyfills.js 145KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190
  1. (self["webpackChunkapp"] = self["webpackChunkapp"] || []).push([["polyfills"],{
  2. /***/ 7435:
  3. /*!**************************!*\
  4. !*** ./src/polyfills.ts ***!
  5. \**************************/
  6. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  7. "use strict";
  8. __webpack_require__.r(__webpack_exports__);
  9. /* harmony import */ var _zone_flags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./zone-flags */ 8270);
  10. /* harmony import */ var _zone_flags__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_zone_flags__WEBPACK_IMPORTED_MODULE_0__);
  11. /* harmony import */ var zone_js_dist_zone__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! zone.js/dist/zone */ 3484);
  12. /* harmony import */ var zone_js_dist_zone__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(zone_js_dist_zone__WEBPACK_IMPORTED_MODULE_1__);
  13. /**
  14. * This file includes polyfills needed by Angular and is loaded before the app.
  15. * You can add your own extra polyfills to this file.
  16. *
  17. * This file is divided into 2 sections:
  18. * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
  19. * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
  20. * file.
  21. *
  22. * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
  23. * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
  24. * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
  25. *
  26. * Learn more in https://angular.io/guide/browser-support
  27. */
  28. /***************************************************************************************************
  29. * BROWSER POLYFILLS
  30. */
  31. /** IE11 requires the following for NgClass support on SVG elements */
  32. // import 'classlist.js'; // Run `npm install --save classlist.js`.
  33. /**
  34. * Web Animations `@angular/platform-browser/animations`
  35. * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
  36. * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
  37. */
  38. // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
  39. /**
  40. * By default, zone.js will patch all possible macroTask and DomEvents
  41. * user can disable parts of macroTask/DomEvents patch by setting following flags
  42. * because those flags need to be set before `zone.js` being loaded, and webpack
  43. * will put import in the top of bundle, so user need to create a separate file
  44. * in this directory (for example: zone-flags.ts), and put the following flags
  45. * into that file, and then add the following code before importing zone.js.
  46. * import './zone-flags';
  47. *
  48. * The flags allowed in zone-flags.ts are listed here.
  49. *
  50. * The following flags will work for all browsers.
  51. *
  52. * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
  53. * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
  54. * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
  55. *
  56. * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
  57. * with the following flag, it will bypass `zone.js` patch for IE/Edge
  58. *
  59. * (window as any).__Zone_enable_cross_context_check = true;
  60. *
  61. */
  62. /***************************************************************************************************
  63. * Zone JS is required by default for Angular itself.
  64. */
  65. // Included with Angular CLI.
  66. /***************************************************************************************************
  67. * APPLICATION IMPORTS
  68. */
  69. /***/ }),
  70. /***/ 8270:
  71. /*!***************************!*\
  72. !*** ./src/zone-flags.ts ***!
  73. \***************************/
  74. /***/ (() => {
  75. /**
  76. * Prevents Angular change detection from
  77. * running with certain Web Component callbacks
  78. */
  79. // eslint-disable-next-line no-underscore-dangle
  80. window.__Zone_disable_customElements = true;
  81. /***/ }),
  82. /***/ 3484:
  83. /*!*******************************************!*\
  84. !*** ./node_modules/zone.js/dist/zone.js ***!
  85. \*******************************************/
  86. /***/ (function(module, exports, __webpack_require__) {
  87. "use strict";
  88. var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;
  89. var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
  90. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  91. if (ar || !(i in from)) {
  92. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  93. ar[i] = from[i];
  94. }
  95. }
  96. return to.concat(ar || Array.prototype.slice.call(from));
  97. };
  98. /**
  99. * @license Angular v14.2.0-next.0
  100. * (c) 2010-2022 Google LLC. https://angular.io/
  101. * License: MIT
  102. */
  103. (function (factory) {
  104. true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
  105. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  106. (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
  107. __WEBPACK_AMD_DEFINE_FACTORY__),
  108. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : 0;
  109. })(function () {
  110. 'use strict';
  111. /**
  112. * @license
  113. * Copyright Google LLC All Rights Reserved.
  114. *
  115. * Use of this source code is governed by an MIT-style license that can be
  116. * found in the LICENSE file at https://angular.io/license
  117. */
  118. (function (global) {
  119. var performance = global['performance'];
  120. function mark(name) {
  121. performance && performance['mark'] && performance['mark'](name);
  122. }
  123. function performanceMeasure(name, label) {
  124. performance && performance['measure'] && performance['measure'](name, label);
  125. }
  126. mark('Zone'); // Initialize before it's accessed below.
  127. // __Zone_symbol_prefix global can be used to override the default zone
  128. // symbol prefix with a custom one if needed.
  129. var symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__';
  130. function __symbol__(name) {
  131. return symbolPrefix + name;
  132. }
  133. var checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true;
  134. if (global['Zone']) {
  135. // if global['Zone'] already exists (maybe zone.js was already loaded or
  136. // some other lib also registered a global object named Zone), we may need
  137. // to throw an error, but sometimes user may not want this error.
  138. // For example,
  139. // we have two web pages, page1 includes zone.js, page2 doesn't.
  140. // and the 1st time user load page1 and page2, everything work fine,
  141. // but when user load page2 again, error occurs because global['Zone'] already exists.
  142. // so we add a flag to let user choose whether to throw this error or not.
  143. // By default, if existing Zone is from zone.js, we will not throw the error.
  144. if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') {
  145. throw new Error('Zone already loaded.');
  146. } else {
  147. return global['Zone'];
  148. }
  149. }
  150. var Zone =
  151. /** @class */
  152. function () {
  153. function Zone(parent, zoneSpec) {
  154. this._parent = parent;
  155. this._name = zoneSpec ? zoneSpec.name || 'unnamed' : '<root>';
  156. this._properties = zoneSpec && zoneSpec.properties || {};
  157. this._zoneDelegate = new _ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec);
  158. }
  159. Zone.assertZonePatched = function () {
  160. if (global['Promise'] !== patches['ZoneAwarePromise']) {
  161. throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' + 'has been overwritten.\n' + 'Most likely cause is that a Promise polyfill has been loaded ' + 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' + 'If you must load one, do so before loading zone.js.)');
  162. }
  163. };
  164. Object.defineProperty(Zone, "root", {
  165. get: function () {
  166. var zone = Zone.current;
  167. while (zone.parent) {
  168. zone = zone.parent;
  169. }
  170. return zone;
  171. },
  172. enumerable: false,
  173. configurable: true
  174. });
  175. Object.defineProperty(Zone, "current", {
  176. get: function () {
  177. return _currentZoneFrame.zone;
  178. },
  179. enumerable: false,
  180. configurable: true
  181. });
  182. Object.defineProperty(Zone, "currentTask", {
  183. get: function () {
  184. return _currentTask;
  185. },
  186. enumerable: false,
  187. configurable: true
  188. }); // tslint:disable-next-line:require-internal-with-underscore
  189. Zone.__load_patch = function (name, fn, ignoreDuplicate) {
  190. if (ignoreDuplicate === void 0) {
  191. ignoreDuplicate = false;
  192. }
  193. if (patches.hasOwnProperty(name)) {
  194. // `checkDuplicate` option is defined from global variable
  195. // so it works for all modules.
  196. // `ignoreDuplicate` can work for the specified module
  197. if (!ignoreDuplicate && checkDuplicate) {
  198. throw Error('Already loaded patch: ' + name);
  199. }
  200. } else if (!global['__Zone_disable_' + name]) {
  201. var perfName = 'Zone:' + name;
  202. mark(perfName);
  203. patches[name] = fn(global, Zone, _api);
  204. performanceMeasure(perfName, perfName);
  205. }
  206. };
  207. Object.defineProperty(Zone.prototype, "parent", {
  208. get: function () {
  209. return this._parent;
  210. },
  211. enumerable: false,
  212. configurable: true
  213. });
  214. Object.defineProperty(Zone.prototype, "name", {
  215. get: function () {
  216. return this._name;
  217. },
  218. enumerable: false,
  219. configurable: true
  220. });
  221. Zone.prototype.get = function (key) {
  222. var zone = this.getZoneWith(key);
  223. if (zone) return zone._properties[key];
  224. };
  225. Zone.prototype.getZoneWith = function (key) {
  226. var current = this;
  227. while (current) {
  228. if (current._properties.hasOwnProperty(key)) {
  229. return current;
  230. }
  231. current = current._parent;
  232. }
  233. return null;
  234. };
  235. Zone.prototype.fork = function (zoneSpec) {
  236. if (!zoneSpec) throw new Error('ZoneSpec required!');
  237. return this._zoneDelegate.fork(this, zoneSpec);
  238. };
  239. Zone.prototype.wrap = function (callback, source) {
  240. if (typeof callback !== 'function') {
  241. throw new Error('Expecting function got: ' + callback);
  242. }
  243. var _callback = this._zoneDelegate.intercept(this, callback, source);
  244. var zone = this;
  245. return function () {
  246. return zone.runGuarded(_callback, this, arguments, source);
  247. };
  248. };
  249. Zone.prototype.run = function (callback, applyThis, applyArgs, source) {
  250. _currentZoneFrame = {
  251. parent: _currentZoneFrame,
  252. zone: this
  253. };
  254. try {
  255. return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source);
  256. } finally {
  257. _currentZoneFrame = _currentZoneFrame.parent;
  258. }
  259. };
  260. Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) {
  261. if (applyThis === void 0) {
  262. applyThis = null;
  263. }
  264. _currentZoneFrame = {
  265. parent: _currentZoneFrame,
  266. zone: this
  267. };
  268. try {
  269. try {
  270. return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source);
  271. } catch (error) {
  272. if (this._zoneDelegate.handleError(this, error)) {
  273. throw error;
  274. }
  275. }
  276. } finally {
  277. _currentZoneFrame = _currentZoneFrame.parent;
  278. }
  279. };
  280. Zone.prototype.runTask = function (task, applyThis, applyArgs) {
  281. if (task.zone != this) {
  282. throw new Error('A task can only be run in the zone of creation! (Creation: ' + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')');
  283. } // https://github.com/angular/zone.js/issues/778, sometimes eventTask
  284. // will run in notScheduled(canceled) state, we should not try to
  285. // run such kind of task but just return
  286. if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) {
  287. return;
  288. }
  289. var reEntryGuard = task.state != running;
  290. reEntryGuard && task._transitionTo(running, scheduled);
  291. task.runCount++;
  292. var previousTask = _currentTask;
  293. _currentTask = task;
  294. _currentZoneFrame = {
  295. parent: _currentZoneFrame,
  296. zone: this
  297. };
  298. try {
  299. if (task.type == macroTask && task.data && !task.data.isPeriodic) {
  300. task.cancelFn = undefined;
  301. }
  302. try {
  303. return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs);
  304. } catch (error) {
  305. if (this._zoneDelegate.handleError(this, error)) {
  306. throw error;
  307. }
  308. }
  309. } finally {
  310. // if the task's state is notScheduled or unknown, then it has already been cancelled
  311. // we should not reset the state to scheduled
  312. if (task.state !== notScheduled && task.state !== unknown) {
  313. if (task.type == eventTask || task.data && task.data.isPeriodic) {
  314. reEntryGuard && task._transitionTo(scheduled, running);
  315. } else {
  316. task.runCount = 0;
  317. this._updateTaskCount(task, -1);
  318. reEntryGuard && task._transitionTo(notScheduled, running, notScheduled);
  319. }
  320. }
  321. _currentZoneFrame = _currentZoneFrame.parent;
  322. _currentTask = previousTask;
  323. }
  324. };
  325. Zone.prototype.scheduleTask = function (task) {
  326. if (task.zone && task.zone !== this) {
  327. // check if the task was rescheduled, the newZone
  328. // should not be the children of the original zone
  329. var newZone = this;
  330. while (newZone) {
  331. if (newZone === task.zone) {
  332. throw Error("can not reschedule task to ".concat(this.name, " which is descendants of the original zone ").concat(task.zone.name));
  333. }
  334. newZone = newZone.parent;
  335. }
  336. }
  337. task._transitionTo(scheduling, notScheduled);
  338. var zoneDelegates = [];
  339. task._zoneDelegates = zoneDelegates;
  340. task._zone = this;
  341. try {
  342. task = this._zoneDelegate.scheduleTask(this, task);
  343. } catch (err) {
  344. // should set task's state to unknown when scheduleTask throw error
  345. // because the err may from reschedule, so the fromState maybe notScheduled
  346. task._transitionTo(unknown, scheduling, notScheduled); // TODO: @JiaLiPassion, should we check the result from handleError?
  347. this._zoneDelegate.handleError(this, err);
  348. throw err;
  349. }
  350. if (task._zoneDelegates === zoneDelegates) {
  351. // we have to check because internally the delegate can reschedule the task.
  352. this._updateTaskCount(task, 1);
  353. }
  354. if (task.state == scheduling) {
  355. task._transitionTo(scheduled, scheduling);
  356. }
  357. return task;
  358. };
  359. Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) {
  360. return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined));
  361. };
  362. Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) {
  363. return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel));
  364. };
  365. Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) {
  366. return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel));
  367. };
  368. Zone.prototype.cancelTask = function (task) {
  369. if (task.zone != this) throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')');
  370. task._transitionTo(canceling, scheduled, running);
  371. try {
  372. this._zoneDelegate.cancelTask(this, task);
  373. } catch (err) {
  374. // if error occurs when cancelTask, transit the state to unknown
  375. task._transitionTo(unknown, canceling);
  376. this._zoneDelegate.handleError(this, err);
  377. throw err;
  378. }
  379. this._updateTaskCount(task, -1);
  380. task._transitionTo(notScheduled, canceling);
  381. task.runCount = 0;
  382. return task;
  383. };
  384. Zone.prototype._updateTaskCount = function (task, count) {
  385. var zoneDelegates = task._zoneDelegates;
  386. if (count == -1) {
  387. task._zoneDelegates = null;
  388. }
  389. for (var i = 0; i < zoneDelegates.length; i++) {
  390. zoneDelegates[i]._updateTaskCount(task.type, count);
  391. }
  392. };
  393. return Zone;
  394. }(); // tslint:disable-next-line:require-internal-with-underscore
  395. Zone.__symbol__ = __symbol__;
  396. var DELEGATE_ZS = {
  397. name: '',
  398. onHasTask: function (delegate, _, target, hasTaskState) {
  399. return delegate.hasTask(target, hasTaskState);
  400. },
  401. onScheduleTask: function (delegate, _, target, task) {
  402. return delegate.scheduleTask(target, task);
  403. },
  404. onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) {
  405. return delegate.invokeTask(target, task, applyThis, applyArgs);
  406. },
  407. onCancelTask: function (delegate, _, target, task) {
  408. return delegate.cancelTask(target, task);
  409. }
  410. };
  411. var _ZoneDelegate =
  412. /** @class */
  413. function () {
  414. function _ZoneDelegate(zone, parentDelegate, zoneSpec) {
  415. this._taskCounts = {
  416. 'microTask': 0,
  417. 'macroTask': 0,
  418. 'eventTask': 0
  419. };
  420. this.zone = zone;
  421. this._parentDelegate = parentDelegate;
  422. this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS);
  423. this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt);
  424. this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate._forkCurrZone);
  425. this._interceptZS = zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS);
  426. this._interceptDlgt = zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt);
  427. this._interceptCurrZone = zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate._interceptCurrZone);
  428. this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS);
  429. this._invokeDlgt = zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt);
  430. this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate._invokeCurrZone);
  431. this._handleErrorZS = zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS);
  432. this._handleErrorDlgt = zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt);
  433. this._handleErrorCurrZone = zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate._handleErrorCurrZone);
  434. this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS);
  435. this._scheduleTaskDlgt = zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt);
  436. this._scheduleTaskCurrZone = zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate._scheduleTaskCurrZone);
  437. this._invokeTaskZS = zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS);
  438. this._invokeTaskDlgt = zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt);
  439. this._invokeTaskCurrZone = zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate._invokeTaskCurrZone);
  440. this._cancelTaskZS = zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS);
  441. this._cancelTaskDlgt = zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt);
  442. this._cancelTaskCurrZone = zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate._cancelTaskCurrZone);
  443. this._hasTaskZS = null;
  444. this._hasTaskDlgt = null;
  445. this._hasTaskDlgtOwner = null;
  446. this._hasTaskCurrZone = null;
  447. var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask;
  448. var parentHasTask = parentDelegate && parentDelegate._hasTaskZS;
  449. if (zoneSpecHasTask || parentHasTask) {
  450. // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such
  451. // a case all task related interceptors must go through this ZD. We can't short circuit it.
  452. this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS;
  453. this._hasTaskDlgt = parentDelegate;
  454. this._hasTaskDlgtOwner = this;
  455. this._hasTaskCurrZone = zone;
  456. if (!zoneSpec.onScheduleTask) {
  457. this._scheduleTaskZS = DELEGATE_ZS;
  458. this._scheduleTaskDlgt = parentDelegate;
  459. this._scheduleTaskCurrZone = this.zone;
  460. }
  461. if (!zoneSpec.onInvokeTask) {
  462. this._invokeTaskZS = DELEGATE_ZS;
  463. this._invokeTaskDlgt = parentDelegate;
  464. this._invokeTaskCurrZone = this.zone;
  465. }
  466. if (!zoneSpec.onCancelTask) {
  467. this._cancelTaskZS = DELEGATE_ZS;
  468. this._cancelTaskDlgt = parentDelegate;
  469. this._cancelTaskCurrZone = this.zone;
  470. }
  471. }
  472. }
  473. _ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) {
  474. return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : new Zone(targetZone, zoneSpec);
  475. };
  476. _ZoneDelegate.prototype.intercept = function (targetZone, callback, source) {
  477. return this._interceptZS ? this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : callback;
  478. };
  479. _ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) {
  480. return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs);
  481. };
  482. _ZoneDelegate.prototype.handleError = function (targetZone, error) {
  483. return this._handleErrorZS ? this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : true;
  484. };
  485. _ZoneDelegate.prototype.scheduleTask = function (targetZone, task) {
  486. var returnTask = task;
  487. if (this._scheduleTaskZS) {
  488. if (this._hasTaskZS) {
  489. returnTask._zoneDelegates.push(this._hasTaskDlgtOwner);
  490. } // clang-format off
  491. returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); // clang-format on
  492. if (!returnTask) returnTask = task;
  493. } else {
  494. if (task.scheduleFn) {
  495. task.scheduleFn(task);
  496. } else if (task.type == microTask) {
  497. scheduleMicroTask(task);
  498. } else {
  499. throw new Error('Task is missing scheduleFn.');
  500. }
  501. }
  502. return returnTask;
  503. };
  504. _ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) {
  505. return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs);
  506. };
  507. _ZoneDelegate.prototype.cancelTask = function (targetZone, task) {
  508. var value;
  509. if (this._cancelTaskZS) {
  510. value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task);
  511. } else {
  512. if (!task.cancelFn) {
  513. throw Error('Task is not cancelable');
  514. }
  515. value = task.cancelFn(task);
  516. }
  517. return value;
  518. };
  519. _ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) {
  520. // hasTask should not throw error so other ZoneDelegate
  521. // can still trigger hasTask callback
  522. try {
  523. this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty);
  524. } catch (err) {
  525. this.handleError(targetZone, err);
  526. }
  527. }; // tslint:disable-next-line:require-internal-with-underscore
  528. _ZoneDelegate.prototype._updateTaskCount = function (type, count) {
  529. var counts = this._taskCounts;
  530. var prev = counts[type];
  531. var next = counts[type] = prev + count;
  532. if (next < 0) {
  533. throw new Error('More tasks executed then were scheduled.');
  534. }
  535. if (prev == 0 || next == 0) {
  536. var isEmpty = {
  537. microTask: counts['microTask'] > 0,
  538. macroTask: counts['macroTask'] > 0,
  539. eventTask: counts['eventTask'] > 0,
  540. change: type
  541. };
  542. this.hasTask(this.zone, isEmpty);
  543. }
  544. };
  545. return _ZoneDelegate;
  546. }();
  547. var ZoneTask =
  548. /** @class */
  549. function () {
  550. function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) {
  551. // tslint:disable-next-line:require-internal-with-underscore
  552. this._zone = null;
  553. this.runCount = 0; // tslint:disable-next-line:require-internal-with-underscore
  554. this._zoneDelegates = null; // tslint:disable-next-line:require-internal-with-underscore
  555. this._state = 'notScheduled';
  556. this.type = type;
  557. this.source = source;
  558. this.data = options;
  559. this.scheduleFn = scheduleFn;
  560. this.cancelFn = cancelFn;
  561. if (!callback) {
  562. throw new Error('callback is not defined');
  563. }
  564. this.callback = callback;
  565. var self = this; // TODO: @JiaLiPassion options should have interface
  566. if (type === eventTask && options && options.useG) {
  567. this.invoke = ZoneTask.invokeTask;
  568. } else {
  569. this.invoke = function () {
  570. return ZoneTask.invokeTask.call(global, self, this, arguments);
  571. };
  572. }
  573. }
  574. ZoneTask.invokeTask = function (task, target, args) {
  575. if (!task) {
  576. task = this;
  577. }
  578. _numberOfNestedTaskFrames++;
  579. try {
  580. task.runCount++;
  581. return task.zone.runTask(task, target, args);
  582. } finally {
  583. if (_numberOfNestedTaskFrames == 1) {
  584. drainMicroTaskQueue();
  585. }
  586. _numberOfNestedTaskFrames--;
  587. }
  588. };
  589. Object.defineProperty(ZoneTask.prototype, "zone", {
  590. get: function () {
  591. return this._zone;
  592. },
  593. enumerable: false,
  594. configurable: true
  595. });
  596. Object.defineProperty(ZoneTask.prototype, "state", {
  597. get: function () {
  598. return this._state;
  599. },
  600. enumerable: false,
  601. configurable: true
  602. });
  603. ZoneTask.prototype.cancelScheduleRequest = function () {
  604. this._transitionTo(notScheduled, scheduling);
  605. }; // tslint:disable-next-line:require-internal-with-underscore
  606. ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) {
  607. if (this._state === fromState1 || this._state === fromState2) {
  608. this._state = toState;
  609. if (toState == notScheduled) {
  610. this._zoneDelegates = null;
  611. }
  612. } else {
  613. throw new Error("".concat(this.type, " '").concat(this.source, "': can not transition to '").concat(toState, "', expecting state '").concat(fromState1, "'").concat(fromState2 ? ' or \'' + fromState2 + '\'' : '', ", was '").concat(this._state, "'."));
  614. }
  615. };
  616. ZoneTask.prototype.toString = function () {
  617. if (this.data && typeof this.data.handleId !== 'undefined') {
  618. return this.data.handleId.toString();
  619. } else {
  620. return Object.prototype.toString.call(this);
  621. }
  622. }; // add toJSON method to prevent cyclic error when
  623. // call JSON.stringify(zoneTask)
  624. ZoneTask.prototype.toJSON = function () {
  625. return {
  626. type: this.type,
  627. state: this.state,
  628. source: this.source,
  629. zone: this.zone.name,
  630. runCount: this.runCount
  631. };
  632. };
  633. return ZoneTask;
  634. }(); //////////////////////////////////////////////////////
  635. //////////////////////////////////////////////////////
  636. /// MICROTASK QUEUE
  637. //////////////////////////////////////////////////////
  638. //////////////////////////////////////////////////////
  639. var symbolSetTimeout = __symbol__('setTimeout');
  640. var symbolPromise = __symbol__('Promise');
  641. var symbolThen = __symbol__('then');
  642. var _microTaskQueue = [];
  643. var _isDrainingMicrotaskQueue = false;
  644. var nativeMicroTaskQueuePromise;
  645. function nativeScheduleMicroTask(func) {
  646. if (!nativeMicroTaskQueuePromise) {
  647. if (global[symbolPromise]) {
  648. nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0);
  649. }
  650. }
  651. if (nativeMicroTaskQueuePromise) {
  652. var nativeThen = nativeMicroTaskQueuePromise[symbolThen];
  653. if (!nativeThen) {
  654. // native Promise is not patchable, we need to use `then` directly
  655. // issue 1078
  656. nativeThen = nativeMicroTaskQueuePromise['then'];
  657. }
  658. nativeThen.call(nativeMicroTaskQueuePromise, func);
  659. } else {
  660. global[symbolSetTimeout](func, 0);
  661. }
  662. }
  663. function scheduleMicroTask(task) {
  664. // if we are not running in any task, and there has not been anything scheduled
  665. // we must bootstrap the initial task creation by manually scheduling the drain
  666. if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) {
  667. // We are not running in Task, so we need to kickstart the microtask queue.
  668. nativeScheduleMicroTask(drainMicroTaskQueue);
  669. }
  670. task && _microTaskQueue.push(task);
  671. }
  672. function drainMicroTaskQueue() {
  673. if (!_isDrainingMicrotaskQueue) {
  674. _isDrainingMicrotaskQueue = true;
  675. while (_microTaskQueue.length) {
  676. var queue = _microTaskQueue;
  677. _microTaskQueue = [];
  678. for (var i = 0; i < queue.length; i++) {
  679. var task = queue[i];
  680. try {
  681. task.zone.runTask(task, null, null);
  682. } catch (error) {
  683. _api.onUnhandledError(error);
  684. }
  685. }
  686. }
  687. _api.microtaskDrainDone();
  688. _isDrainingMicrotaskQueue = false;
  689. }
  690. } //////////////////////////////////////////////////////
  691. //////////////////////////////////////////////////////
  692. /// BOOTSTRAP
  693. //////////////////////////////////////////////////////
  694. //////////////////////////////////////////////////////
  695. var NO_ZONE = {
  696. name: 'NO ZONE'
  697. };
  698. var notScheduled = 'notScheduled',
  699. scheduling = 'scheduling',
  700. scheduled = 'scheduled',
  701. running = 'running',
  702. canceling = 'canceling',
  703. unknown = 'unknown';
  704. var microTask = 'microTask',
  705. macroTask = 'macroTask',
  706. eventTask = 'eventTask';
  707. var patches = {};
  708. var _api = {
  709. symbol: __symbol__,
  710. currentZoneFrame: function () {
  711. return _currentZoneFrame;
  712. },
  713. onUnhandledError: noop,
  714. microtaskDrainDone: noop,
  715. scheduleMicroTask: scheduleMicroTask,
  716. showUncaughtError: function () {
  717. return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')];
  718. },
  719. patchEventTarget: function () {
  720. return [];
  721. },
  722. patchOnProperties: noop,
  723. patchMethod: function () {
  724. return noop;
  725. },
  726. bindArguments: function () {
  727. return [];
  728. },
  729. patchThen: function () {
  730. return noop;
  731. },
  732. patchMacroTask: function () {
  733. return noop;
  734. },
  735. patchEventPrototype: function () {
  736. return noop;
  737. },
  738. isIEOrEdge: function () {
  739. return false;
  740. },
  741. getGlobalObjects: function () {
  742. return undefined;
  743. },
  744. ObjectDefineProperty: function () {
  745. return noop;
  746. },
  747. ObjectGetOwnPropertyDescriptor: function () {
  748. return undefined;
  749. },
  750. ObjectCreate: function () {
  751. return undefined;
  752. },
  753. ArraySlice: function () {
  754. return [];
  755. },
  756. patchClass: function () {
  757. return noop;
  758. },
  759. wrapWithCurrentZone: function () {
  760. return noop;
  761. },
  762. filterProperties: function () {
  763. return [];
  764. },
  765. attachOriginToPatched: function () {
  766. return noop;
  767. },
  768. _redefineProperty: function () {
  769. return noop;
  770. },
  771. patchCallbacks: function () {
  772. return noop;
  773. },
  774. nativeScheduleMicroTask: nativeScheduleMicroTask
  775. };
  776. var _currentZoneFrame = {
  777. parent: null,
  778. zone: new Zone(null, null)
  779. };
  780. var _currentTask = null;
  781. var _numberOfNestedTaskFrames = 0;
  782. function noop() {}
  783. performanceMeasure('Zone', 'Zone');
  784. return global['Zone'] = Zone;
  785. })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
  786. /**
  787. * @license
  788. * Copyright Google LLC All Rights Reserved.
  789. *
  790. * Use of this source code is governed by an MIT-style license that can be
  791. * found in the LICENSE file at https://angular.io/license
  792. */
  793. /**
  794. * Suppress closure compiler errors about unknown 'Zone' variable
  795. * @fileoverview
  796. * @suppress {undefinedVars,globalThis,missingRequire}
  797. */
  798. /// <reference types="node"/>
  799. // issue #989, to reduce bundle size, use short name
  800. /** Object.getOwnPropertyDescriptor */
  801. var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  802. /** Object.defineProperty */
  803. var ObjectDefineProperty = Object.defineProperty;
  804. /** Object.getPrototypeOf */
  805. var ObjectGetPrototypeOf = Object.getPrototypeOf;
  806. /** Object.create */
  807. var ObjectCreate = Object.create;
  808. /** Array.prototype.slice */
  809. var ArraySlice = Array.prototype.slice;
  810. /** addEventListener string const */
  811. var ADD_EVENT_LISTENER_STR = 'addEventListener';
  812. /** removeEventListener string const */
  813. var REMOVE_EVENT_LISTENER_STR = 'removeEventListener';
  814. /** zoneSymbol addEventListener */
  815. var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR);
  816. /** zoneSymbol removeEventListener */
  817. var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR);
  818. /** true string const */
  819. var TRUE_STR = 'true';
  820. /** false string const */
  821. var FALSE_STR = 'false';
  822. /** Zone symbol prefix string const. */
  823. var ZONE_SYMBOL_PREFIX = Zone.__symbol__('');
  824. function wrapWithCurrentZone(callback, source) {
  825. return Zone.current.wrap(callback, source);
  826. }
  827. function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) {
  828. return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel);
  829. }
  830. var zoneSymbol$1 = Zone.__symbol__;
  831. var isWindowExists = typeof window !== 'undefined';
  832. var internalWindow = isWindowExists ? window : undefined;
  833. var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global;
  834. var REMOVE_ATTRIBUTE = 'removeAttribute';
  835. function bindArguments(args, source) {
  836. for (var i = args.length - 1; i >= 0; i--) {
  837. if (typeof args[i] === 'function') {
  838. args[i] = wrapWithCurrentZone(args[i], source + '_' + i);
  839. }
  840. }
  841. return args;
  842. }
  843. function patchPrototype(prototype, fnNames) {
  844. var source = prototype.constructor['name'];
  845. var _loop_1 = function (i) {
  846. var name_1 = fnNames[i];
  847. var delegate = prototype[name_1];
  848. if (delegate) {
  849. var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1);
  850. if (!isPropertyWritable(prototypeDesc)) {
  851. return "continue";
  852. }
  853. prototype[name_1] = function (delegate) {
  854. var patched = function () {
  855. return delegate.apply(this, bindArguments(arguments, source + '.' + name_1));
  856. };
  857. attachOriginToPatched(patched, delegate);
  858. return patched;
  859. }(delegate);
  860. }
  861. };
  862. for (var i = 0; i < fnNames.length; i++) {
  863. _loop_1(i);
  864. }
  865. }
  866. function isPropertyWritable(propertyDesc) {
  867. if (!propertyDesc) {
  868. return true;
  869. }
  870. if (propertyDesc.writable === false) {
  871. return false;
  872. }
  873. return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined');
  874. }
  875. var isWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope; // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify
  876. // this code.
  877. var isNode = !('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]';
  878. var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs
  879. // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify
  880. // this code.
  881. var isMix = typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']);
  882. var zoneSymbolEventNames$1 = {};
  883. var wrapFn = function (event) {
  884. // https://github.com/angular/zone.js/issues/911, in IE, sometimes
  885. // event will be undefined, so we need to use window.event
  886. event = event || _global.event;
  887. if (!event) {
  888. return;
  889. }
  890. var eventNameSymbol = zoneSymbolEventNames$1[event.type];
  891. if (!eventNameSymbol) {
  892. eventNameSymbol = zoneSymbolEventNames$1[event.type] = zoneSymbol$1('ON_PROPERTY' + event.type);
  893. }
  894. var target = this || event.target || _global;
  895. var listener = target[eventNameSymbol];
  896. var result;
  897. if (isBrowser && target === internalWindow && event.type === 'error') {
  898. // window.onerror have different signature
  899. // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror
  900. // and onerror callback will prevent default when callback return true
  901. var errorEvent = event;
  902. result = listener && listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error);
  903. if (result === true) {
  904. event.preventDefault();
  905. }
  906. } else {
  907. result = listener && listener.apply(this, arguments);
  908. if (result != undefined && !result) {
  909. event.preventDefault();
  910. }
  911. }
  912. return result;
  913. };
  914. function patchProperty(obj, prop, prototype) {
  915. var desc = ObjectGetOwnPropertyDescriptor(obj, prop);
  916. if (!desc && prototype) {
  917. // when patch window object, use prototype to check prop exist or not
  918. var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop);
  919. if (prototypeDesc) {
  920. desc = {
  921. enumerable: true,
  922. configurable: true
  923. };
  924. }
  925. } // if the descriptor not exists or is not configurable
  926. // just return
  927. if (!desc || !desc.configurable) {
  928. return;
  929. }
  930. var onPropPatchedSymbol = zoneSymbol$1('on' + prop + 'patched');
  931. if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) {
  932. return;
  933. } // A property descriptor cannot have getter/setter and be writable
  934. // deleting the writable and value properties avoids this error:
  935. //
  936. // TypeError: property descriptors must not specify a value or be writable when a
  937. // getter or setter has been specified
  938. delete desc.writable;
  939. delete desc.value;
  940. var originalDescGet = desc.get;
  941. var originalDescSet = desc.set; // slice(2) cuz 'onclick' -> 'click', etc
  942. var eventName = prop.slice(2);
  943. var eventNameSymbol = zoneSymbolEventNames$1[eventName];
  944. if (!eventNameSymbol) {
  945. eventNameSymbol = zoneSymbolEventNames$1[eventName] = zoneSymbol$1('ON_PROPERTY' + eventName);
  946. }
  947. desc.set = function (newValue) {
  948. // in some of windows's onproperty callback, this is undefined
  949. // so we need to check it
  950. var target = this;
  951. if (!target && obj === _global) {
  952. target = _global;
  953. }
  954. if (!target) {
  955. return;
  956. }
  957. var previousValue = target[eventNameSymbol];
  958. if (typeof previousValue === 'function') {
  959. target.removeEventListener(eventName, wrapFn);
  960. } // issue #978, when onload handler was added before loading zone.js
  961. // we should remove it with originalDescSet
  962. originalDescSet && originalDescSet.call(target, null);
  963. target[eventNameSymbol] = newValue;
  964. if (typeof newValue === 'function') {
  965. target.addEventListener(eventName, wrapFn, false);
  966. }
  967. }; // The getter would return undefined for unassigned properties but the default value of an
  968. // unassigned property is null
  969. desc.get = function () {
  970. // in some of windows's onproperty callback, this is undefined
  971. // so we need to check it
  972. var target = this;
  973. if (!target && obj === _global) {
  974. target = _global;
  975. }
  976. if (!target) {
  977. return null;
  978. }
  979. var listener = target[eventNameSymbol];
  980. if (listener) {
  981. return listener;
  982. } else if (originalDescGet) {
  983. // result will be null when use inline event attribute,
  984. // such as <button onclick="func();">OK</button>
  985. // because the onclick function is internal raw uncompiled handler
  986. // the onclick will be evaluated when first time event was triggered or
  987. // the property is accessed, https://github.com/angular/zone.js/issues/525
  988. // so we should use original native get to retrieve the handler
  989. var value = originalDescGet.call(this);
  990. if (value) {
  991. desc.set.call(this, value);
  992. if (typeof target[REMOVE_ATTRIBUTE] === 'function') {
  993. target.removeAttribute(prop);
  994. }
  995. return value;
  996. }
  997. }
  998. return null;
  999. };
  1000. ObjectDefineProperty(obj, prop, desc);
  1001. obj[onPropPatchedSymbol] = true;
  1002. }
  1003. function patchOnProperties(obj, properties, prototype) {
  1004. if (properties) {
  1005. for (var i = 0; i < properties.length; i++) {
  1006. patchProperty(obj, 'on' + properties[i], prototype);
  1007. }
  1008. } else {
  1009. var onProperties = [];
  1010. for (var prop in obj) {
  1011. if (prop.slice(0, 2) == 'on') {
  1012. onProperties.push(prop);
  1013. }
  1014. }
  1015. for (var j = 0; j < onProperties.length; j++) {
  1016. patchProperty(obj, onProperties[j], prototype);
  1017. }
  1018. }
  1019. }
  1020. var originalInstanceKey = zoneSymbol$1('originalInstance'); // wrap some native API on `window`
  1021. function patchClass(className) {
  1022. var OriginalClass = _global[className];
  1023. if (!OriginalClass) return; // keep original class in global
  1024. _global[zoneSymbol$1(className)] = OriginalClass;
  1025. _global[className] = function () {
  1026. var a = bindArguments(arguments, className);
  1027. switch (a.length) {
  1028. case 0:
  1029. this[originalInstanceKey] = new OriginalClass();
  1030. break;
  1031. case 1:
  1032. this[originalInstanceKey] = new OriginalClass(a[0]);
  1033. break;
  1034. case 2:
  1035. this[originalInstanceKey] = new OriginalClass(a[0], a[1]);
  1036. break;
  1037. case 3:
  1038. this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]);
  1039. break;
  1040. case 4:
  1041. this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]);
  1042. break;
  1043. default:
  1044. throw new Error('Arg list too long.');
  1045. }
  1046. }; // attach original delegate to patched function
  1047. attachOriginToPatched(_global[className], OriginalClass);
  1048. var instance = new OriginalClass(function () {});
  1049. var prop;
  1050. for (prop in instance) {
  1051. // https://bugs.webkit.org/show_bug.cgi?id=44721
  1052. if (className === 'XMLHttpRequest' && prop === 'responseBlob') continue;
  1053. (function (prop) {
  1054. if (typeof instance[prop] === 'function') {
  1055. _global[className].prototype[prop] = function () {
  1056. return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments);
  1057. };
  1058. } else {
  1059. ObjectDefineProperty(_global[className].prototype, prop, {
  1060. set: function (fn) {
  1061. if (typeof fn === 'function') {
  1062. this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); // keep callback in wrapped function so we can
  1063. // use it in Function.prototype.toString to return
  1064. // the native one.
  1065. attachOriginToPatched(this[originalInstanceKey][prop], fn);
  1066. } else {
  1067. this[originalInstanceKey][prop] = fn;
  1068. }
  1069. },
  1070. get: function () {
  1071. return this[originalInstanceKey][prop];
  1072. }
  1073. });
  1074. }
  1075. })(prop);
  1076. }
  1077. for (prop in OriginalClass) {
  1078. if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) {
  1079. _global[className][prop] = OriginalClass[prop];
  1080. }
  1081. }
  1082. }
  1083. function patchMethod(target, name, patchFn) {
  1084. var proto = target;
  1085. while (proto && !proto.hasOwnProperty(name)) {
  1086. proto = ObjectGetPrototypeOf(proto);
  1087. }
  1088. if (!proto && target[name]) {
  1089. // somehow we did not find it, but we can see it. This happens on IE for Window properties.
  1090. proto = target;
  1091. }
  1092. var delegateName = zoneSymbol$1(name);
  1093. var delegate = null;
  1094. if (proto && (!(delegate = proto[delegateName]) || !proto.hasOwnProperty(delegateName))) {
  1095. delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable
  1096. // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob
  1097. var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name);
  1098. if (isPropertyWritable(desc)) {
  1099. var patchDelegate_1 = patchFn(delegate, delegateName, name);
  1100. proto[name] = function () {
  1101. return patchDelegate_1(this, arguments);
  1102. };
  1103. attachOriginToPatched(proto[name], delegate);
  1104. }
  1105. }
  1106. return delegate;
  1107. } // TODO: @JiaLiPassion, support cancel task later if necessary
  1108. function patchMacroTask(obj, funcName, metaCreator) {
  1109. var setNative = null;
  1110. function scheduleTask(task) {
  1111. var data = task.data;
  1112. data.args[data.cbIdx] = function () {
  1113. task.invoke.apply(this, arguments);
  1114. };
  1115. setNative.apply(data.target, data.args);
  1116. return task;
  1117. }
  1118. setNative = patchMethod(obj, funcName, function (delegate) {
  1119. return function (self, args) {
  1120. var meta = metaCreator(self, args);
  1121. if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') {
  1122. return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask);
  1123. } else {
  1124. // cause an error by calling it directly.
  1125. return delegate.apply(self, args);
  1126. }
  1127. };
  1128. });
  1129. }
  1130. function attachOriginToPatched(patched, original) {
  1131. patched[zoneSymbol$1('OriginalDelegate')] = original;
  1132. }
  1133. var isDetectedIEOrEdge = false;
  1134. var ieOrEdge = false;
  1135. function isIE() {
  1136. try {
  1137. var ua = internalWindow.navigator.userAgent;
  1138. if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) {
  1139. return true;
  1140. }
  1141. } catch (error) {}
  1142. return false;
  1143. }
  1144. function isIEOrEdge() {
  1145. if (isDetectedIEOrEdge) {
  1146. return ieOrEdge;
  1147. }
  1148. isDetectedIEOrEdge = true;
  1149. try {
  1150. var ua = internalWindow.navigator.userAgent;
  1151. if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) {
  1152. ieOrEdge = true;
  1153. }
  1154. } catch (error) {}
  1155. return ieOrEdge;
  1156. }
  1157. /**
  1158. * @license
  1159. * Copyright Google LLC All Rights Reserved.
  1160. *
  1161. * Use of this source code is governed by an MIT-style license that can be
  1162. * found in the LICENSE file at https://angular.io/license
  1163. */
  1164. Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) {
  1165. var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  1166. var ObjectDefineProperty = Object.defineProperty;
  1167. function readableObjectToString(obj) {
  1168. if (obj && obj.toString === Object.prototype.toString) {
  1169. var className = obj.constructor && obj.constructor.name;
  1170. return (className ? className : '') + ': ' + JSON.stringify(obj);
  1171. }
  1172. return obj ? obj.toString() : Object.prototype.toString.call(obj);
  1173. }
  1174. var __symbol__ = api.symbol;
  1175. var _uncaughtPromiseErrors = [];
  1176. var isDisableWrappingUncaughtPromiseRejection = global[__symbol__('DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION')] === true;
  1177. var symbolPromise = __symbol__('Promise');
  1178. var symbolThen = __symbol__('then');
  1179. var creationTrace = '__creationTrace__';
  1180. api.onUnhandledError = function (e) {
  1181. if (api.showUncaughtError()) {
  1182. var rejection = e && e.rejection;
  1183. if (rejection) {
  1184. console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined);
  1185. } else {
  1186. console.error(e);
  1187. }
  1188. }
  1189. };
  1190. api.microtaskDrainDone = function () {
  1191. var _loop_2 = function () {
  1192. var uncaughtPromiseError = _uncaughtPromiseErrors.shift();
  1193. try {
  1194. uncaughtPromiseError.zone.runGuarded(function () {
  1195. if (uncaughtPromiseError.throwOriginal) {
  1196. throw uncaughtPromiseError.rejection;
  1197. }
  1198. throw uncaughtPromiseError;
  1199. });
  1200. } catch (error) {
  1201. handleUnhandledRejection(error);
  1202. }
  1203. };
  1204. while (_uncaughtPromiseErrors.length) {
  1205. _loop_2();
  1206. }
  1207. };
  1208. var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler');
  1209. function handleUnhandledRejection(e) {
  1210. api.onUnhandledError(e);
  1211. try {
  1212. var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL];
  1213. if (typeof handler === 'function') {
  1214. handler.call(this, e);
  1215. }
  1216. } catch (err) {}
  1217. }
  1218. function isThenable(value) {
  1219. return value && value.then;
  1220. }
  1221. function forwardResolution(value) {
  1222. return value;
  1223. }
  1224. function forwardRejection(rejection) {
  1225. return ZoneAwarePromise.reject(rejection);
  1226. }
  1227. var symbolState = __symbol__('state');
  1228. var symbolValue = __symbol__('value');
  1229. var symbolFinally = __symbol__('finally');
  1230. var symbolParentPromiseValue = __symbol__('parentPromiseValue');
  1231. var symbolParentPromiseState = __symbol__('parentPromiseState');
  1232. var source = 'Promise.then';
  1233. var UNRESOLVED = null;
  1234. var RESOLVED = true;
  1235. var REJECTED = false;
  1236. var REJECTED_NO_CATCH = 0;
  1237. function makeResolver(promise, state) {
  1238. return function (v) {
  1239. try {
  1240. resolvePromise(promise, state, v);
  1241. } catch (err) {
  1242. resolvePromise(promise, false, err);
  1243. } // Do not return value or you will break the Promise spec.
  1244. };
  1245. }
  1246. var once = function () {
  1247. var wasCalled = false;
  1248. return function wrapper(wrappedFunction) {
  1249. return function () {
  1250. if (wasCalled) {
  1251. return;
  1252. }
  1253. wasCalled = true;
  1254. wrappedFunction.apply(null, arguments);
  1255. };
  1256. };
  1257. };
  1258. var TYPE_ERROR = 'Promise resolved with itself';
  1259. var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); // Promise Resolution
  1260. function resolvePromise(promise, state, value) {
  1261. var onceWrapper = once();
  1262. if (promise === value) {
  1263. throw new TypeError(TYPE_ERROR);
  1264. }
  1265. if (promise[symbolState] === UNRESOLVED) {
  1266. // should only get value.then once based on promise spec.
  1267. var then = null;
  1268. try {
  1269. if (typeof value === 'object' || typeof value === 'function') {
  1270. then = value && value.then;
  1271. }
  1272. } catch (err) {
  1273. onceWrapper(function () {
  1274. resolvePromise(promise, false, err);
  1275. })();
  1276. return promise;
  1277. } // if (value instanceof ZoneAwarePromise) {
  1278. if (state !== REJECTED && value instanceof ZoneAwarePromise && value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && value[symbolState] !== UNRESOLVED) {
  1279. clearRejectedNoCatch(value);
  1280. resolvePromise(promise, value[symbolState], value[symbolValue]);
  1281. } else if (state !== REJECTED && typeof then === 'function') {
  1282. try {
  1283. then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)));
  1284. } catch (err) {
  1285. onceWrapper(function () {
  1286. resolvePromise(promise, false, err);
  1287. })();
  1288. }
  1289. } else {
  1290. promise[symbolState] = state;
  1291. var queue = promise[symbolValue];
  1292. promise[symbolValue] = value;
  1293. if (promise[symbolFinally] === symbolFinally) {
  1294. // the promise is generated by Promise.prototype.finally
  1295. if (state === RESOLVED) {
  1296. // the state is resolved, should ignore the value
  1297. // and use parent promise value
  1298. promise[symbolState] = promise[symbolParentPromiseState];
  1299. promise[symbolValue] = promise[symbolParentPromiseValue];
  1300. }
  1301. } // record task information in value when error occurs, so we can
  1302. // do some additional work such as render longStackTrace
  1303. if (state === REJECTED && value instanceof Error) {
  1304. // check if longStackTraceZone is here
  1305. var trace = Zone.currentTask && Zone.currentTask.data && Zone.currentTask.data[creationTrace];
  1306. if (trace) {
  1307. // only keep the long stack trace into error when in longStackTraceZone
  1308. ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, {
  1309. configurable: true,
  1310. enumerable: false,
  1311. writable: true,
  1312. value: trace
  1313. });
  1314. }
  1315. }
  1316. for (var i = 0; i < queue.length;) {
  1317. scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]);
  1318. }
  1319. if (queue.length == 0 && state == REJECTED) {
  1320. promise[symbolState] = REJECTED_NO_CATCH;
  1321. var uncaughtPromiseError = value;
  1322. try {
  1323. // Here we throws a new Error to print more readable error log
  1324. // and if the value is not an error, zone.js builds an `Error`
  1325. // Object here to attach the stack information.
  1326. throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + (value && value.stack ? '\n' + value.stack : ''));
  1327. } catch (err) {
  1328. uncaughtPromiseError = err;
  1329. }
  1330. if (isDisableWrappingUncaughtPromiseRejection) {
  1331. // If disable wrapping uncaught promise reject
  1332. // use the value instead of wrapping it.
  1333. uncaughtPromiseError.throwOriginal = true;
  1334. }
  1335. uncaughtPromiseError.rejection = value;
  1336. uncaughtPromiseError.promise = promise;
  1337. uncaughtPromiseError.zone = Zone.current;
  1338. uncaughtPromiseError.task = Zone.currentTask;
  1339. _uncaughtPromiseErrors.push(uncaughtPromiseError);
  1340. api.scheduleMicroTask(); // to make sure that it is running
  1341. }
  1342. }
  1343. } // Resolving an already resolved promise is a noop.
  1344. return promise;
  1345. }
  1346. var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler');
  1347. function clearRejectedNoCatch(promise) {
  1348. if (promise[symbolState] === REJECTED_NO_CATCH) {
  1349. // if the promise is rejected no catch status
  1350. // and queue.length > 0, means there is a error handler
  1351. // here to handle the rejected promise, we should trigger
  1352. // windows.rejectionhandled eventHandler or nodejs rejectionHandled
  1353. // eventHandler
  1354. try {
  1355. var handler = Zone[REJECTION_HANDLED_HANDLER];
  1356. if (handler && typeof handler === 'function') {
  1357. handler.call(this, {
  1358. rejection: promise[symbolValue],
  1359. promise: promise
  1360. });
  1361. }
  1362. } catch (err) {}
  1363. promise[symbolState] = REJECTED;
  1364. for (var i = 0; i < _uncaughtPromiseErrors.length; i++) {
  1365. if (promise === _uncaughtPromiseErrors[i].promise) {
  1366. _uncaughtPromiseErrors.splice(i, 1);
  1367. }
  1368. }
  1369. }
  1370. }
  1371. function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) {
  1372. clearRejectedNoCatch(promise);
  1373. var promiseState = promise[symbolState];
  1374. var delegate = promiseState ? typeof onFulfilled === 'function' ? onFulfilled : forwardResolution : typeof onRejected === 'function' ? onRejected : forwardRejection;
  1375. zone.scheduleMicroTask(source, function () {
  1376. try {
  1377. var parentPromiseValue = promise[symbolValue];
  1378. var isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally];
  1379. if (isFinallyPromise) {
  1380. // if the promise is generated from finally call, keep parent promise's state and value
  1381. chainPromise[symbolParentPromiseValue] = parentPromiseValue;
  1382. chainPromise[symbolParentPromiseState] = promiseState;
  1383. } // should not pass value to finally callback
  1384. var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]);
  1385. resolvePromise(chainPromise, true, value);
  1386. } catch (error) {
  1387. // if error occurs, should always return this error
  1388. resolvePromise(chainPromise, false, error);
  1389. }
  1390. }, chainPromise);
  1391. }
  1392. var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }';
  1393. var noop = function () {};
  1394. var AggregateError = global.AggregateError;
  1395. var ZoneAwarePromise =
  1396. /** @class */
  1397. function () {
  1398. function ZoneAwarePromise(executor) {
  1399. var promise = this;
  1400. if (!(promise instanceof ZoneAwarePromise)) {
  1401. throw new Error('Must be an instanceof Promise.');
  1402. }
  1403. promise[symbolState] = UNRESOLVED;
  1404. promise[symbolValue] = []; // queue;
  1405. try {
  1406. var onceWrapper = once();
  1407. executor && executor(onceWrapper(makeResolver(promise, RESOLVED)), onceWrapper(makeResolver(promise, REJECTED)));
  1408. } catch (error) {
  1409. resolvePromise(promise, false, error);
  1410. }
  1411. }
  1412. ZoneAwarePromise.toString = function () {
  1413. return ZONE_AWARE_PROMISE_TO_STRING;
  1414. };
  1415. ZoneAwarePromise.resolve = function (value) {
  1416. return resolvePromise(new this(null), RESOLVED, value);
  1417. };
  1418. ZoneAwarePromise.reject = function (error) {
  1419. return resolvePromise(new this(null), REJECTED, error);
  1420. };
  1421. ZoneAwarePromise.any = function (values) {
  1422. if (!values || typeof values[Symbol.iterator] !== 'function') {
  1423. return Promise.reject(new AggregateError([], 'All promises were rejected'));
  1424. }
  1425. var promises = [];
  1426. var count = 0;
  1427. try {
  1428. for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
  1429. var v = values_1[_i];
  1430. count++;
  1431. promises.push(ZoneAwarePromise.resolve(v));
  1432. }
  1433. } catch (err) {
  1434. return Promise.reject(new AggregateError([], 'All promises were rejected'));
  1435. }
  1436. if (count === 0) {
  1437. return Promise.reject(new AggregateError([], 'All promises were rejected'));
  1438. }
  1439. var finished = false;
  1440. var errors = [];
  1441. return new ZoneAwarePromise(function (resolve, reject) {
  1442. for (var i = 0; i < promises.length; i++) {
  1443. promises[i].then(function (v) {
  1444. if (finished) {
  1445. return;
  1446. }
  1447. finished = true;
  1448. resolve(v);
  1449. }, function (err) {
  1450. errors.push(err);
  1451. count--;
  1452. if (count === 0) {
  1453. finished = true;
  1454. reject(new AggregateError(errors, 'All promises were rejected'));
  1455. }
  1456. });
  1457. }
  1458. });
  1459. };
  1460. ;
  1461. ZoneAwarePromise.race = function (values) {
  1462. var resolve;
  1463. var reject;
  1464. var promise = new this(function (res, rej) {
  1465. resolve = res;
  1466. reject = rej;
  1467. });
  1468. function onResolve(value) {
  1469. resolve(value);
  1470. }
  1471. function onReject(error) {
  1472. reject(error);
  1473. }
  1474. for (var _i = 0, values_2 = values; _i < values_2.length; _i++) {
  1475. var value = values_2[_i];
  1476. if (!isThenable(value)) {
  1477. value = this.resolve(value);
  1478. }
  1479. value.then(onResolve, onReject);
  1480. }
  1481. return promise;
  1482. };
  1483. ZoneAwarePromise.all = function (values) {
  1484. return ZoneAwarePromise.allWithCallback(values);
  1485. };
  1486. ZoneAwarePromise.allSettled = function (values) {
  1487. var P = this && this.prototype instanceof ZoneAwarePromise ? this : ZoneAwarePromise;
  1488. return P.allWithCallback(values, {
  1489. thenCallback: function (value) {
  1490. return {
  1491. status: 'fulfilled',
  1492. value: value
  1493. };
  1494. },
  1495. errorCallback: function (err) {
  1496. return {
  1497. status: 'rejected',
  1498. reason: err
  1499. };
  1500. }
  1501. });
  1502. };
  1503. ZoneAwarePromise.allWithCallback = function (values, callback) {
  1504. var resolve;
  1505. var reject;
  1506. var promise = new this(function (res, rej) {
  1507. resolve = res;
  1508. reject = rej;
  1509. }); // Start at 2 to prevent prematurely resolving if .then is called immediately.
  1510. var unresolvedCount = 2;
  1511. var valueIndex = 0;
  1512. var resolvedValues = [];
  1513. var _loop_3 = function (value) {
  1514. if (!isThenable(value)) {
  1515. value = this_1.resolve(value);
  1516. }
  1517. var curValueIndex = valueIndex;
  1518. try {
  1519. value.then(function (value) {
  1520. resolvedValues[curValueIndex] = callback ? callback.thenCallback(value) : value;
  1521. unresolvedCount--;
  1522. if (unresolvedCount === 0) {
  1523. resolve(resolvedValues);
  1524. }
  1525. }, function (err) {
  1526. if (!callback) {
  1527. reject(err);
  1528. } else {
  1529. resolvedValues[curValueIndex] = callback.errorCallback(err);
  1530. unresolvedCount--;
  1531. if (unresolvedCount === 0) {
  1532. resolve(resolvedValues);
  1533. }
  1534. }
  1535. });
  1536. } catch (thenErr) {
  1537. reject(thenErr);
  1538. }
  1539. unresolvedCount++;
  1540. valueIndex++;
  1541. };
  1542. var this_1 = this;
  1543. for (var _i = 0, values_3 = values; _i < values_3.length; _i++) {
  1544. var value = values_3[_i];
  1545. _loop_3(value);
  1546. } // Make the unresolvedCount zero-based again.
  1547. unresolvedCount -= 2;
  1548. if (unresolvedCount === 0) {
  1549. resolve(resolvedValues);
  1550. }
  1551. return promise;
  1552. };
  1553. Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, {
  1554. get: function () {
  1555. return 'Promise';
  1556. },
  1557. enumerable: false,
  1558. configurable: true
  1559. });
  1560. Object.defineProperty(ZoneAwarePromise.prototype, Symbol.species, {
  1561. get: function () {
  1562. return ZoneAwarePromise;
  1563. },
  1564. enumerable: false,
  1565. configurable: true
  1566. });
  1567. ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) {
  1568. var _a; // We must read `Symbol.species` safely because `this` may be anything. For instance, `this`
  1569. // may be an object without a prototype (created through `Object.create(null)`); thus
  1570. // `this.constructor` will be undefined. One of the use cases is SystemJS creating
  1571. // prototype-less objects (modules) via `Object.create(null)`. The SystemJS creates an empty
  1572. // object and copies promise properties into that object (within the `getOrCreateLoad`
  1573. // function). The zone.js then checks if the resolved value has the `then` method and invokes
  1574. // it with the `value` context. Otherwise, this will throw an error: `TypeError: Cannot read
  1575. // properties of undefined (reading 'Symbol(Symbol.species)')`.
  1576. var C = (_a = this.constructor) === null || _a === void 0 ? void 0 : _a[Symbol.species];
  1577. if (!C || typeof C !== 'function') {
  1578. C = this.constructor || ZoneAwarePromise;
  1579. }
  1580. var chainPromise = new C(noop);
  1581. var zone = Zone.current;
  1582. if (this[symbolState] == UNRESOLVED) {
  1583. this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected);
  1584. } else {
  1585. scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected);
  1586. }
  1587. return chainPromise;
  1588. };
  1589. ZoneAwarePromise.prototype.catch = function (onRejected) {
  1590. return this.then(null, onRejected);
  1591. };
  1592. ZoneAwarePromise.prototype.finally = function (onFinally) {
  1593. var _a; // See comment on the call to `then` about why thee `Symbol.species` is safely accessed.
  1594. var C = (_a = this.constructor) === null || _a === void 0 ? void 0 : _a[Symbol.species];
  1595. if (!C || typeof C !== 'function') {
  1596. C = ZoneAwarePromise;
  1597. }
  1598. var chainPromise = new C(noop);
  1599. chainPromise[symbolFinally] = symbolFinally;
  1600. var zone = Zone.current;
  1601. if (this[symbolState] == UNRESOLVED) {
  1602. this[symbolValue].push(zone, chainPromise, onFinally, onFinally);
  1603. } else {
  1604. scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally);
  1605. }
  1606. return chainPromise;
  1607. };
  1608. return ZoneAwarePromise;
  1609. }(); // Protect against aggressive optimizers dropping seemingly unused properties.
  1610. // E.g. Closure Compiler in advanced mode.
  1611. ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve;
  1612. ZoneAwarePromise['reject'] = ZoneAwarePromise.reject;
  1613. ZoneAwarePromise['race'] = ZoneAwarePromise.race;
  1614. ZoneAwarePromise['all'] = ZoneAwarePromise.all;
  1615. var NativePromise = global[symbolPromise] = global['Promise'];
  1616. global['Promise'] = ZoneAwarePromise;
  1617. var symbolThenPatched = __symbol__('thenPatched');
  1618. function patchThen(Ctor) {
  1619. var proto = Ctor.prototype;
  1620. var prop = ObjectGetOwnPropertyDescriptor(proto, 'then');
  1621. if (prop && (prop.writable === false || !prop.configurable)) {
  1622. // check Ctor.prototype.then propertyDescriptor is writable or not
  1623. // in meteor env, writable is false, we should ignore such case
  1624. return;
  1625. }
  1626. var originalThen = proto.then; // Keep a reference to the original method.
  1627. proto[symbolThen] = originalThen;
  1628. Ctor.prototype.then = function (onResolve, onReject) {
  1629. var _this = this;
  1630. var wrapped = new ZoneAwarePromise(function (resolve, reject) {
  1631. originalThen.call(_this, resolve, reject);
  1632. });
  1633. return wrapped.then(onResolve, onReject);
  1634. };
  1635. Ctor[symbolThenPatched] = true;
  1636. }
  1637. api.patchThen = patchThen;
  1638. function zoneify(fn) {
  1639. return function (self, args) {
  1640. var resultPromise = fn.apply(self, args);
  1641. if (resultPromise instanceof ZoneAwarePromise) {
  1642. return resultPromise;
  1643. }
  1644. var ctor = resultPromise.constructor;
  1645. if (!ctor[symbolThenPatched]) {
  1646. patchThen(ctor);
  1647. }
  1648. return resultPromise;
  1649. };
  1650. }
  1651. if (NativePromise) {
  1652. patchThen(NativePromise);
  1653. patchMethod(global, 'fetch', function (delegate) {
  1654. return zoneify(delegate);
  1655. });
  1656. } // This is not part of public API, but it is useful for tests, so we expose it.
  1657. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors;
  1658. return ZoneAwarePromise;
  1659. });
  1660. /**
  1661. * @license
  1662. * Copyright Google LLC All Rights Reserved.
  1663. *
  1664. * Use of this source code is governed by an MIT-style license that can be
  1665. * found in the LICENSE file at https://angular.io/license
  1666. */
  1667. // override Function.prototype.toString to make zone.js patched function
  1668. // look like native function
  1669. Zone.__load_patch('toString', function (global) {
  1670. // patch Func.prototype.toString to let them look like native
  1671. var originalFunctionToString = Function.prototype.toString;
  1672. var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol$1('OriginalDelegate');
  1673. var PROMISE_SYMBOL = zoneSymbol$1('Promise');
  1674. var ERROR_SYMBOL = zoneSymbol$1('Error');
  1675. var newFunctionToString = function toString() {
  1676. if (typeof this === 'function') {
  1677. var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL];
  1678. if (originalDelegate) {
  1679. if (typeof originalDelegate === 'function') {
  1680. return originalFunctionToString.call(originalDelegate);
  1681. } else {
  1682. return Object.prototype.toString.call(originalDelegate);
  1683. }
  1684. }
  1685. if (this === Promise) {
  1686. var nativePromise = global[PROMISE_SYMBOL];
  1687. if (nativePromise) {
  1688. return originalFunctionToString.call(nativePromise);
  1689. }
  1690. }
  1691. if (this === Error) {
  1692. var nativeError = global[ERROR_SYMBOL];
  1693. if (nativeError) {
  1694. return originalFunctionToString.call(nativeError);
  1695. }
  1696. }
  1697. }
  1698. return originalFunctionToString.call(this);
  1699. };
  1700. newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString;
  1701. Function.prototype.toString = newFunctionToString; // patch Object.prototype.toString to let them look like native
  1702. var originalObjectToString = Object.prototype.toString;
  1703. var PROMISE_OBJECT_TO_STRING = '[object Promise]';
  1704. Object.prototype.toString = function () {
  1705. if (typeof Promise === 'function' && this instanceof Promise) {
  1706. return PROMISE_OBJECT_TO_STRING;
  1707. }
  1708. return originalObjectToString.call(this);
  1709. };
  1710. });
  1711. /**
  1712. * @license
  1713. * Copyright Google LLC All Rights Reserved.
  1714. *
  1715. * Use of this source code is governed by an MIT-style license that can be
  1716. * found in the LICENSE file at https://angular.io/license
  1717. */
  1718. var passiveSupported = false;
  1719. if (typeof window !== 'undefined') {
  1720. try {
  1721. var options = Object.defineProperty({}, 'passive', {
  1722. get: function () {
  1723. passiveSupported = true;
  1724. }
  1725. }); // Note: We pass the `options` object as the event handler too. This is not compatible with the
  1726. // signature of `addEventListener` or `removeEventListener` but enables us to remove the handler
  1727. // without an actual handler.
  1728. window.addEventListener('test', options, options);
  1729. window.removeEventListener('test', options, options);
  1730. } catch (err) {
  1731. passiveSupported = false;
  1732. }
  1733. } // an identifier to tell ZoneTask do not create a new invoke closure
  1734. var OPTIMIZED_ZONE_EVENT_TASK_DATA = {
  1735. useG: true
  1736. };
  1737. var zoneSymbolEventNames = {};
  1738. var globalSources = {};
  1739. var EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$');
  1740. var IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol$1('propagationStopped');
  1741. function prepareEventNames(eventName, eventNameToString) {
  1742. var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR;
  1743. var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR;
  1744. var symbol = ZONE_SYMBOL_PREFIX + falseEventName;
  1745. var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName;
  1746. zoneSymbolEventNames[eventName] = {};
  1747. zoneSymbolEventNames[eventName][FALSE_STR] = symbol;
  1748. zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture;
  1749. }
  1750. function patchEventTarget(_global, api, apis, patchOptions) {
  1751. var ADD_EVENT_LISTENER = patchOptions && patchOptions.add || ADD_EVENT_LISTENER_STR;
  1752. var REMOVE_EVENT_LISTENER = patchOptions && patchOptions.rm || REMOVE_EVENT_LISTENER_STR;
  1753. var LISTENERS_EVENT_LISTENER = patchOptions && patchOptions.listeners || 'eventListeners';
  1754. var REMOVE_ALL_LISTENERS_EVENT_LISTENER = patchOptions && patchOptions.rmAll || 'removeAllListeners';
  1755. var zoneSymbolAddEventListener = zoneSymbol$1(ADD_EVENT_LISTENER);
  1756. var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
  1757. var PREPEND_EVENT_LISTENER = 'prependListener';
  1758. var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
  1759. var invokeTask = function (task, target, event) {
  1760. // for better performance, check isRemoved which is set
  1761. // by removeEventListener
  1762. if (task.isRemoved) {
  1763. return;
  1764. }
  1765. var delegate = task.callback;
  1766. if (typeof delegate === 'object' && delegate.handleEvent) {
  1767. // create the bind version of handleEvent when invoke
  1768. task.callback = function (event) {
  1769. return delegate.handleEvent(event);
  1770. };
  1771. task.originalDelegate = delegate;
  1772. } // invoke static task.invoke
  1773. // need to try/catch error here, otherwise, the error in one event listener
  1774. // will break the executions of the other event listeners. Also error will
  1775. // not remove the event listener when `once` options is true.
  1776. var error;
  1777. try {
  1778. task.invoke(task, target, [event]);
  1779. } catch (err) {
  1780. error = err;
  1781. }
  1782. var options = task.options;
  1783. if (options && typeof options === 'object' && options.once) {
  1784. // if options.once is true, after invoke once remove listener here
  1785. // only browser need to do this, nodejs eventEmitter will cal removeListener
  1786. // inside EventEmitter.once
  1787. var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback;
  1788. target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options);
  1789. }
  1790. return error;
  1791. };
  1792. function globalCallback(context, event, isCapture) {
  1793. // https://github.com/angular/zone.js/issues/911, in IE, sometimes
  1794. // event will be undefined, so we need to use window.event
  1795. event = event || _global.event;
  1796. if (!event) {
  1797. return;
  1798. } // event.target is needed for Samsung TV and SourceBuffer
  1799. // || global is needed https://github.com/angular/zone.js/issues/190
  1800. var target = context || event.target || _global;
  1801. var tasks = target[zoneSymbolEventNames[event.type][isCapture ? TRUE_STR : FALSE_STR]];
  1802. if (tasks) {
  1803. var errors = []; // invoke all tasks which attached to current target with given event.type and capture = false
  1804. // for performance concern, if task.length === 1, just invoke
  1805. if (tasks.length === 1) {
  1806. var err = invokeTask(tasks[0], target, event);
  1807. err && errors.push(err);
  1808. } else {
  1809. // https://github.com/angular/zone.js/issues/836
  1810. // copy the tasks array before invoke, to avoid
  1811. // the callback will remove itself or other listener
  1812. var copyTasks = tasks.slice();
  1813. for (var i = 0; i < copyTasks.length; i++) {
  1814. if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
  1815. break;
  1816. }
  1817. var err = invokeTask(copyTasks[i], target, event);
  1818. err && errors.push(err);
  1819. }
  1820. } // Since there is only one error, we don't need to schedule microTask
  1821. // to throw the error.
  1822. if (errors.length === 1) {
  1823. throw errors[0];
  1824. } else {
  1825. var _loop_4 = function (i) {
  1826. var err = errors[i];
  1827. api.nativeScheduleMicroTask(function () {
  1828. throw err;
  1829. });
  1830. };
  1831. for (var i = 0; i < errors.length; i++) {
  1832. _loop_4(i);
  1833. }
  1834. }
  1835. }
  1836. } // global shared zoneAwareCallback to handle all event callback with capture = false
  1837. var globalZoneAwareCallback = function (event) {
  1838. return globalCallback(this, event, false);
  1839. }; // global shared zoneAwareCallback to handle all event callback with capture = true
  1840. var globalZoneAwareCaptureCallback = function (event) {
  1841. return globalCallback(this, event, true);
  1842. };
  1843. function patchEventTargetMethods(obj, patchOptions) {
  1844. if (!obj) {
  1845. return false;
  1846. }
  1847. var useGlobalCallback = true;
  1848. if (patchOptions && patchOptions.useG !== undefined) {
  1849. useGlobalCallback = patchOptions.useG;
  1850. }
  1851. var validateHandler = patchOptions && patchOptions.vh;
  1852. var checkDuplicate = true;
  1853. if (patchOptions && patchOptions.chkDup !== undefined) {
  1854. checkDuplicate = patchOptions.chkDup;
  1855. }
  1856. var returnTarget = false;
  1857. if (patchOptions && patchOptions.rt !== undefined) {
  1858. returnTarget = patchOptions.rt;
  1859. }
  1860. var proto = obj;
  1861. while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) {
  1862. proto = ObjectGetPrototypeOf(proto);
  1863. }
  1864. if (!proto && obj[ADD_EVENT_LISTENER]) {
  1865. // somehow we did not find it, but we can see it. This happens on IE for Window properties.
  1866. proto = obj;
  1867. }
  1868. if (!proto) {
  1869. return false;
  1870. }
  1871. if (proto[zoneSymbolAddEventListener]) {
  1872. return false;
  1873. }
  1874. var eventNameToString = patchOptions && patchOptions.eventNameToString; // a shared global taskData to pass data for scheduleEventTask
  1875. // so we do not need to create a new object just for pass some data
  1876. var taskData = {};
  1877. var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER];
  1878. var nativeRemoveEventListener = proto[zoneSymbol$1(REMOVE_EVENT_LISTENER)] = proto[REMOVE_EVENT_LISTENER];
  1879. var nativeListeners = proto[zoneSymbol$1(LISTENERS_EVENT_LISTENER)] = proto[LISTENERS_EVENT_LISTENER];
  1880. var nativeRemoveAllListeners = proto[zoneSymbol$1(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER];
  1881. var nativePrependEventListener;
  1882. if (patchOptions && patchOptions.prepend) {
  1883. nativePrependEventListener = proto[zoneSymbol$1(patchOptions.prepend)] = proto[patchOptions.prepend];
  1884. }
  1885. /**
  1886. * This util function will build an option object with passive option
  1887. * to handle all possible input from the user.
  1888. */
  1889. function buildEventListenerOptions(options, passive) {
  1890. if (!passiveSupported && typeof options === 'object' && options) {
  1891. // doesn't support passive but user want to pass an object as options.
  1892. // this will not work on some old browser, so we just pass a boolean
  1893. // as useCapture parameter
  1894. return !!options.capture;
  1895. }
  1896. if (!passiveSupported || !passive) {
  1897. return options;
  1898. }
  1899. if (typeof options === 'boolean') {
  1900. return {
  1901. capture: options,
  1902. passive: true
  1903. };
  1904. }
  1905. if (!options) {
  1906. return {
  1907. passive: true
  1908. };
  1909. }
  1910. if (typeof options === 'object' && options.passive !== false) {
  1911. return Object.assign(Object.assign({}, options), {
  1912. passive: true
  1913. });
  1914. }
  1915. return options;
  1916. }
  1917. var customScheduleGlobal = function (task) {
  1918. // if there is already a task for the eventName + capture,
  1919. // just return, because we use the shared globalZoneAwareCallback here.
  1920. if (taskData.isExisting) {
  1921. return;
  1922. }
  1923. return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options);
  1924. };
  1925. var customCancelGlobal = function (task) {
  1926. // if task is not marked as isRemoved, this call is directly
  1927. // from Zone.prototype.cancelTask, we should remove the task
  1928. // from tasksList of target first
  1929. if (!task.isRemoved) {
  1930. var symbolEventNames = zoneSymbolEventNames[task.eventName];
  1931. var symbolEventName = void 0;
  1932. if (symbolEventNames) {
  1933. symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR];
  1934. }
  1935. var existingTasks = symbolEventName && task.target[symbolEventName];
  1936. if (existingTasks) {
  1937. for (var i = 0; i < existingTasks.length; i++) {
  1938. var existingTask = existingTasks[i];
  1939. if (existingTask === task) {
  1940. existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check
  1941. task.isRemoved = true;
  1942. if (existingTasks.length === 0) {
  1943. // all tasks for the eventName + capture have gone,
  1944. // remove globalZoneAwareCallback and remove the task cache from target
  1945. task.allRemoved = true;
  1946. task.target[symbolEventName] = null;
  1947. }
  1948. break;
  1949. }
  1950. }
  1951. }
  1952. } // if all tasks for the eventName + capture have gone,
  1953. // we will really remove the global event callback,
  1954. // if not, return
  1955. if (!task.allRemoved) {
  1956. return;
  1957. }
  1958. return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options);
  1959. };
  1960. var customScheduleNonGlobal = function (task) {
  1961. return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options);
  1962. };
  1963. var customSchedulePrepend = function (task) {
  1964. return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options);
  1965. };
  1966. var customCancelNonGlobal = function (task) {
  1967. return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options);
  1968. };
  1969. var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal;
  1970. var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal;
  1971. var compareTaskCallbackVsDelegate = function (task, delegate) {
  1972. var typeOfDelegate = typeof delegate;
  1973. return typeOfDelegate === 'function' && task.callback === delegate || typeOfDelegate === 'object' && task.originalDelegate === delegate;
  1974. };
  1975. var compare = patchOptions && patchOptions.diff ? patchOptions.diff : compareTaskCallbackVsDelegate;
  1976. var unpatchedEvents = Zone[zoneSymbol$1('UNPATCHED_EVENTS')];
  1977. var passiveEvents = _global[zoneSymbol$1('PASSIVE_EVENTS')];
  1978. var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) {
  1979. if (returnTarget === void 0) {
  1980. returnTarget = false;
  1981. }
  1982. if (prepend === void 0) {
  1983. prepend = false;
  1984. }
  1985. return function () {
  1986. var target = this || _global;
  1987. var eventName = arguments[0];
  1988. if (patchOptions && patchOptions.transferEventName) {
  1989. eventName = patchOptions.transferEventName(eventName);
  1990. }
  1991. var delegate = arguments[1];
  1992. if (!delegate) {
  1993. return nativeListener.apply(this, arguments);
  1994. }
  1995. if (isNode && eventName === 'uncaughtException') {
  1996. // don't patch uncaughtException of nodejs to prevent endless loop
  1997. return nativeListener.apply(this, arguments);
  1998. } // don't create the bind delegate function for handleEvent
  1999. // case here to improve addEventListener performance
  2000. // we will create the bind delegate when invoke
  2001. var isHandleEvent = false;
  2002. if (typeof delegate !== 'function') {
  2003. if (!delegate.handleEvent) {
  2004. return nativeListener.apply(this, arguments);
  2005. }
  2006. isHandleEvent = true;
  2007. }
  2008. if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) {
  2009. return;
  2010. }
  2011. var passive = passiveSupported && !!passiveEvents && passiveEvents.indexOf(eventName) !== -1;
  2012. var options = buildEventListenerOptions(arguments[2], passive);
  2013. if (unpatchedEvents) {
  2014. // check unpatched list
  2015. for (var i = 0; i < unpatchedEvents.length; i++) {
  2016. if (eventName === unpatchedEvents[i]) {
  2017. if (passive) {
  2018. return nativeListener.call(target, eventName, delegate, options);
  2019. } else {
  2020. return nativeListener.apply(this, arguments);
  2021. }
  2022. }
  2023. }
  2024. }
  2025. var capture = !options ? false : typeof options === 'boolean' ? true : options.capture;
  2026. var once = options && typeof options === 'object' ? options.once : false;
  2027. var zone = Zone.current;
  2028. var symbolEventNames = zoneSymbolEventNames[eventName];
  2029. if (!symbolEventNames) {
  2030. prepareEventNames(eventName, eventNameToString);
  2031. symbolEventNames = zoneSymbolEventNames[eventName];
  2032. }
  2033. var symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR];
  2034. var existingTasks = target[symbolEventName];
  2035. var isExisting = false;
  2036. if (existingTasks) {
  2037. // already have task registered
  2038. isExisting = true;
  2039. if (checkDuplicate) {
  2040. for (var i = 0; i < existingTasks.length; i++) {
  2041. if (compare(existingTasks[i], delegate)) {
  2042. // same callback, same capture, same event name, just return
  2043. return;
  2044. }
  2045. }
  2046. }
  2047. } else {
  2048. existingTasks = target[symbolEventName] = [];
  2049. }
  2050. var source;
  2051. var constructorName = target.constructor['name'];
  2052. var targetSource = globalSources[constructorName];
  2053. if (targetSource) {
  2054. source = targetSource[eventName];
  2055. }
  2056. if (!source) {
  2057. source = constructorName + addSource + (eventNameToString ? eventNameToString(eventName) : eventName);
  2058. } // do not create a new object as task.data to pass those things
  2059. // just use the global shared one
  2060. taskData.options = options;
  2061. if (once) {
  2062. // if addEventListener with once options, we don't pass it to
  2063. // native addEventListener, instead we keep the once setting
  2064. // and handle ourselves.
  2065. taskData.options.once = false;
  2066. }
  2067. taskData.target = target;
  2068. taskData.capture = capture;
  2069. taskData.eventName = eventName;
  2070. taskData.isExisting = isExisting;
  2071. var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; // keep taskData into data to allow onScheduleEventTask to access the task information
  2072. if (data) {
  2073. data.taskData = taskData;
  2074. }
  2075. var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); // should clear taskData.target to avoid memory leak
  2076. // issue, https://github.com/angular/angular/issues/20442
  2077. taskData.target = null; // need to clear up taskData because it is a global object
  2078. if (data) {
  2079. data.taskData = null;
  2080. } // have to save those information to task in case
  2081. // application may call task.zone.cancelTask() directly
  2082. if (once) {
  2083. options.once = true;
  2084. }
  2085. if (!(!passiveSupported && typeof task.options === 'boolean')) {
  2086. // if not support passive, and we pass an option object
  2087. // to addEventListener, we should save the options to task
  2088. task.options = options;
  2089. }
  2090. task.target = target;
  2091. task.capture = capture;
  2092. task.eventName = eventName;
  2093. if (isHandleEvent) {
  2094. // save original delegate for compare to check duplicate
  2095. task.originalDelegate = delegate;
  2096. }
  2097. if (!prepend) {
  2098. existingTasks.push(task);
  2099. } else {
  2100. existingTasks.unshift(task);
  2101. }
  2102. if (returnTarget) {
  2103. return target;
  2104. }
  2105. };
  2106. };
  2107. proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget);
  2108. if (nativePrependEventListener) {
  2109. proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true);
  2110. }
  2111. proto[REMOVE_EVENT_LISTENER] = function () {
  2112. var target = this || _global;
  2113. var eventName = arguments[0];
  2114. if (patchOptions && patchOptions.transferEventName) {
  2115. eventName = patchOptions.transferEventName(eventName);
  2116. }
  2117. var options = arguments[2];
  2118. var capture = !options ? false : typeof options === 'boolean' ? true : options.capture;
  2119. var delegate = arguments[1];
  2120. if (!delegate) {
  2121. return nativeRemoveEventListener.apply(this, arguments);
  2122. }
  2123. if (validateHandler && !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) {
  2124. return;
  2125. }
  2126. var symbolEventNames = zoneSymbolEventNames[eventName];
  2127. var symbolEventName;
  2128. if (symbolEventNames) {
  2129. symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR];
  2130. }
  2131. var existingTasks = symbolEventName && target[symbolEventName];
  2132. if (existingTasks) {
  2133. for (var i = 0; i < existingTasks.length; i++) {
  2134. var existingTask = existingTasks[i];
  2135. if (compare(existingTask, delegate)) {
  2136. existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check
  2137. existingTask.isRemoved = true;
  2138. if (existingTasks.length === 0) {
  2139. // all tasks for the eventName + capture have gone,
  2140. // remove globalZoneAwareCallback and remove the task cache from target
  2141. existingTask.allRemoved = true;
  2142. target[symbolEventName] = null; // in the target, we have an event listener which is added by on_property
  2143. // such as target.onclick = function() {}, so we need to clear this internal
  2144. // property too if all delegates all removed
  2145. if (typeof eventName === 'string') {
  2146. var onPropertySymbol = ZONE_SYMBOL_PREFIX + 'ON_PROPERTY' + eventName;
  2147. target[onPropertySymbol] = null;
  2148. }
  2149. }
  2150. existingTask.zone.cancelTask(existingTask);
  2151. if (returnTarget) {
  2152. return target;
  2153. }
  2154. return;
  2155. }
  2156. }
  2157. } // issue 930, didn't find the event name or callback
  2158. // from zone kept existingTasks, the callback maybe
  2159. // added outside of zone, we need to call native removeEventListener
  2160. // to try to remove it.
  2161. return nativeRemoveEventListener.apply(this, arguments);
  2162. };
  2163. proto[LISTENERS_EVENT_LISTENER] = function () {
  2164. var target = this || _global;
  2165. var eventName = arguments[0];
  2166. if (patchOptions && patchOptions.transferEventName) {
  2167. eventName = patchOptions.transferEventName(eventName);
  2168. }
  2169. var listeners = [];
  2170. var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName);
  2171. for (var i = 0; i < tasks.length; i++) {
  2172. var task = tasks[i];
  2173. var delegate = task.originalDelegate ? task.originalDelegate : task.callback;
  2174. listeners.push(delegate);
  2175. }
  2176. return listeners;
  2177. };
  2178. proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () {
  2179. var target = this || _global;
  2180. var eventName = arguments[0];
  2181. if (!eventName) {
  2182. var keys = Object.keys(target);
  2183. for (var i = 0; i < keys.length; i++) {
  2184. var prop = keys[i];
  2185. var match = EVENT_NAME_SYMBOL_REGX.exec(prop);
  2186. var evtName = match && match[1]; // in nodejs EventEmitter, removeListener event is
  2187. // used for monitoring the removeListener call,
  2188. // so just keep removeListener eventListener until
  2189. // all other eventListeners are removed
  2190. if (evtName && evtName !== 'removeListener') {
  2191. this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName);
  2192. }
  2193. } // remove removeListener listener finally
  2194. this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener');
  2195. } else {
  2196. if (patchOptions && patchOptions.transferEventName) {
  2197. eventName = patchOptions.transferEventName(eventName);
  2198. }
  2199. var symbolEventNames = zoneSymbolEventNames[eventName];
  2200. if (symbolEventNames) {
  2201. var symbolEventName = symbolEventNames[FALSE_STR];
  2202. var symbolCaptureEventName = symbolEventNames[TRUE_STR];
  2203. var tasks = target[symbolEventName];
  2204. var captureTasks = target[symbolCaptureEventName];
  2205. if (tasks) {
  2206. var removeTasks = tasks.slice();
  2207. for (var i = 0; i < removeTasks.length; i++) {
  2208. var task = removeTasks[i];
  2209. var delegate = task.originalDelegate ? task.originalDelegate : task.callback;
  2210. this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options);
  2211. }
  2212. }
  2213. if (captureTasks) {
  2214. var removeTasks = captureTasks.slice();
  2215. for (var i = 0; i < removeTasks.length; i++) {
  2216. var task = removeTasks[i];
  2217. var delegate = task.originalDelegate ? task.originalDelegate : task.callback;
  2218. this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options);
  2219. }
  2220. }
  2221. }
  2222. }
  2223. if (returnTarget) {
  2224. return this;
  2225. }
  2226. }; // for native toString patch
  2227. attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener);
  2228. attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener);
  2229. if (nativeRemoveAllListeners) {
  2230. attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners);
  2231. }
  2232. if (nativeListeners) {
  2233. attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners);
  2234. }
  2235. return true;
  2236. }
  2237. var results = [];
  2238. for (var i = 0; i < apis.length; i++) {
  2239. results[i] = patchEventTargetMethods(apis[i], patchOptions);
  2240. }
  2241. return results;
  2242. }
  2243. function findEventTasks(target, eventName) {
  2244. if (!eventName) {
  2245. var foundTasks = [];
  2246. for (var prop in target) {
  2247. var match = EVENT_NAME_SYMBOL_REGX.exec(prop);
  2248. var evtName = match && match[1];
  2249. if (evtName && (!eventName || evtName === eventName)) {
  2250. var tasks = target[prop];
  2251. if (tasks) {
  2252. for (var i = 0; i < tasks.length; i++) {
  2253. foundTasks.push(tasks[i]);
  2254. }
  2255. }
  2256. }
  2257. }
  2258. return foundTasks;
  2259. }
  2260. var symbolEventName = zoneSymbolEventNames[eventName];
  2261. if (!symbolEventName) {
  2262. prepareEventNames(eventName);
  2263. symbolEventName = zoneSymbolEventNames[eventName];
  2264. }
  2265. var captureFalseTasks = target[symbolEventName[FALSE_STR]];
  2266. var captureTrueTasks = target[symbolEventName[TRUE_STR]];
  2267. if (!captureFalseTasks) {
  2268. return captureTrueTasks ? captureTrueTasks.slice() : [];
  2269. } else {
  2270. return captureTrueTasks ? captureFalseTasks.concat(captureTrueTasks) : captureFalseTasks.slice();
  2271. }
  2272. }
  2273. function patchEventPrototype(global, api) {
  2274. var Event = global['Event'];
  2275. if (Event && Event.prototype) {
  2276. api.patchMethod(Event.prototype, 'stopImmediatePropagation', function (delegate) {
  2277. return function (self, args) {
  2278. self[IMMEDIATE_PROPAGATION_SYMBOL] = true; // we need to call the native stopImmediatePropagation
  2279. // in case in some hybrid application, some part of
  2280. // application will be controlled by zone, some are not
  2281. delegate && delegate.apply(self, args);
  2282. };
  2283. });
  2284. }
  2285. }
  2286. /**
  2287. * @license
  2288. * Copyright Google LLC All Rights Reserved.
  2289. *
  2290. * Use of this source code is governed by an MIT-style license that can be
  2291. * found in the LICENSE file at https://angular.io/license
  2292. */
  2293. function patchCallbacks(api, target, targetName, method, callbacks) {
  2294. var symbol = Zone.__symbol__(method);
  2295. if (target[symbol]) {
  2296. return;
  2297. }
  2298. var nativeDelegate = target[symbol] = target[method];
  2299. target[method] = function (name, opts, options) {
  2300. if (opts && opts.prototype) {
  2301. callbacks.forEach(function (callback) {
  2302. var source = "".concat(targetName, ".").concat(method, "::") + callback;
  2303. var prototype = opts.prototype; // Note: the `patchCallbacks` is used for patching the `document.registerElement` and
  2304. // `customElements.define`. We explicitly wrap the patching code into try-catch since
  2305. // callbacks may be already patched by other web components frameworks (e.g. LWC), and they
  2306. // make those properties non-writable. This means that patching callback will throw an error
  2307. // `cannot assign to read-only property`. See this code as an example:
  2308. // https://github.com/salesforce/lwc/blob/master/packages/@lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186
  2309. // We don't want to stop the application rendering if we couldn't patch some
  2310. // callback, e.g. `attributeChangedCallback`.
  2311. try {
  2312. if (prototype.hasOwnProperty(callback)) {
  2313. var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback);
  2314. if (descriptor && descriptor.value) {
  2315. descriptor.value = api.wrapWithCurrentZone(descriptor.value, source);
  2316. api._redefineProperty(opts.prototype, callback, descriptor);
  2317. } else if (prototype[callback]) {
  2318. prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source);
  2319. }
  2320. } else if (prototype[callback]) {
  2321. prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source);
  2322. }
  2323. } catch (_a) {// Note: we leave the catch block empty since there's no way to handle the error related
  2324. // to non-writable property.
  2325. }
  2326. });
  2327. }
  2328. return nativeDelegate.call(target, name, opts, options);
  2329. };
  2330. api.attachOriginToPatched(target[method], nativeDelegate);
  2331. }
  2332. /**
  2333. * @license
  2334. * Copyright Google LLC All Rights Reserved.
  2335. *
  2336. * Use of this source code is governed by an MIT-style license that can be
  2337. * found in the LICENSE file at https://angular.io/license
  2338. */
  2339. function filterProperties(target, onProperties, ignoreProperties) {
  2340. if (!ignoreProperties || ignoreProperties.length === 0) {
  2341. return onProperties;
  2342. }
  2343. var tip = ignoreProperties.filter(function (ip) {
  2344. return ip.target === target;
  2345. });
  2346. if (!tip || tip.length === 0) {
  2347. return onProperties;
  2348. }
  2349. var targetIgnoreProperties = tip[0].ignoreProperties;
  2350. return onProperties.filter(function (op) {
  2351. return targetIgnoreProperties.indexOf(op) === -1;
  2352. });
  2353. }
  2354. function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) {
  2355. // check whether target is available, sometimes target will be undefined
  2356. // because different browser or some 3rd party plugin.
  2357. if (!target) {
  2358. return;
  2359. }
  2360. var filteredProperties = filterProperties(target, onProperties, ignoreProperties);
  2361. patchOnProperties(target, filteredProperties, prototype);
  2362. }
  2363. /**
  2364. * Get all event name properties which the event name startsWith `on`
  2365. * from the target object itself, inherited properties are not considered.
  2366. */
  2367. function getOnEventNames(target) {
  2368. return Object.getOwnPropertyNames(target).filter(function (name) {
  2369. return name.startsWith('on') && name.length > 2;
  2370. }).map(function (name) {
  2371. return name.substring(2);
  2372. });
  2373. }
  2374. function propertyDescriptorPatch(api, _global) {
  2375. if (isNode && !isMix) {
  2376. return;
  2377. }
  2378. if (Zone[api.symbol('patchEvents')]) {
  2379. // events are already been patched by legacy patch.
  2380. return;
  2381. }
  2382. var ignoreProperties = _global['__Zone_ignore_on_properties']; // for browsers that we can patch the descriptor: Chrome & Firefox
  2383. var patchTargets = [];
  2384. if (isBrowser) {
  2385. var internalWindow_1 = window;
  2386. patchTargets = patchTargets.concat(['Document', 'SVGElement', 'Element', 'HTMLElement', 'HTMLBodyElement', 'HTMLMediaElement', 'HTMLFrameSetElement', 'HTMLFrameElement', 'HTMLIFrameElement', 'HTMLMarqueeElement', 'Worker']);
  2387. var ignoreErrorProperties = isIE() ? [{
  2388. target: internalWindow_1,
  2389. ignoreProperties: ['error']
  2390. }] : []; // in IE/Edge, onProp not exist in window object, but in WindowPrototype
  2391. // so we need to pass WindowPrototype to check onProp exist or not
  2392. patchFilteredProperties(internalWindow_1, getOnEventNames(internalWindow_1), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow_1));
  2393. }
  2394. patchTargets = patchTargets.concat(['XMLHttpRequest', 'XMLHttpRequestEventTarget', 'IDBIndex', 'IDBRequest', 'IDBOpenDBRequest', 'IDBDatabase', 'IDBTransaction', 'IDBCursor', 'WebSocket']);
  2395. for (var i = 0; i < patchTargets.length; i++) {
  2396. var target = _global[patchTargets[i]];
  2397. target && target.prototype && patchFilteredProperties(target.prototype, getOnEventNames(target.prototype), ignoreProperties);
  2398. }
  2399. }
  2400. /**
  2401. * @license
  2402. * Copyright Google LLC All Rights Reserved.
  2403. *
  2404. * Use of this source code is governed by an MIT-style license that can be
  2405. * found in the LICENSE file at https://angular.io/license
  2406. */
  2407. Zone.__load_patch('util', function (global, Zone, api) {
  2408. // Collect native event names by looking at properties
  2409. // on the global namespace, e.g. 'onclick'.
  2410. var eventNames = getOnEventNames(global);
  2411. api.patchOnProperties = patchOnProperties;
  2412. api.patchMethod = patchMethod;
  2413. api.bindArguments = bindArguments;
  2414. api.patchMacroTask = patchMacroTask; // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to
  2415. // define which events will not be patched by `Zone.js`.
  2416. // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep
  2417. // the name consistent with angular repo.
  2418. // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for
  2419. // backwards compatibility.
  2420. var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS');
  2421. var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS');
  2422. if (global[SYMBOL_UNPATCHED_EVENTS]) {
  2423. global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS];
  2424. }
  2425. if (global[SYMBOL_BLACK_LISTED_EVENTS]) {
  2426. Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS];
  2427. }
  2428. api.patchEventPrototype = patchEventPrototype;
  2429. api.patchEventTarget = patchEventTarget;
  2430. api.isIEOrEdge = isIEOrEdge;
  2431. api.ObjectDefineProperty = ObjectDefineProperty;
  2432. api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor;
  2433. api.ObjectCreate = ObjectCreate;
  2434. api.ArraySlice = ArraySlice;
  2435. api.patchClass = patchClass;
  2436. api.wrapWithCurrentZone = wrapWithCurrentZone;
  2437. api.filterProperties = filterProperties;
  2438. api.attachOriginToPatched = attachOriginToPatched;
  2439. api._redefineProperty = Object.defineProperty;
  2440. api.patchCallbacks = patchCallbacks;
  2441. api.getGlobalObjects = function () {
  2442. return {
  2443. globalSources: globalSources,
  2444. zoneSymbolEventNames: zoneSymbolEventNames,
  2445. eventNames: eventNames,
  2446. isBrowser: isBrowser,
  2447. isMix: isMix,
  2448. isNode: isNode,
  2449. TRUE_STR: TRUE_STR,
  2450. FALSE_STR: FALSE_STR,
  2451. ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX,
  2452. ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR,
  2453. REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR
  2454. };
  2455. };
  2456. });
  2457. /**
  2458. * @license
  2459. * Copyright Google LLC All Rights Reserved.
  2460. *
  2461. * Use of this source code is governed by an MIT-style license that can be
  2462. * found in the LICENSE file at https://angular.io/license
  2463. */
  2464. /*
  2465. * This is necessary for Chrome and Chrome mobile, to enable
  2466. * things like redefining `createdCallback` on an element.
  2467. */
  2468. var zoneSymbol;
  2469. var _defineProperty;
  2470. var _getOwnPropertyDescriptor;
  2471. var _create;
  2472. var unconfigurablesKey;
  2473. function propertyPatch() {
  2474. zoneSymbol = Zone.__symbol__;
  2475. _defineProperty = Object[zoneSymbol('defineProperty')] = Object.defineProperty;
  2476. _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor;
  2477. _create = Object.create;
  2478. unconfigurablesKey = zoneSymbol('unconfigurables');
  2479. Object.defineProperty = function (obj, prop, desc) {
  2480. if (isUnconfigurable(obj, prop)) {
  2481. throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj);
  2482. }
  2483. var originalConfigurableFlag = desc.configurable;
  2484. if (prop !== 'prototype') {
  2485. desc = rewriteDescriptor(obj, prop, desc);
  2486. }
  2487. return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag);
  2488. };
  2489. Object.defineProperties = function (obj, props) {
  2490. Object.keys(props).forEach(function (prop) {
  2491. Object.defineProperty(obj, prop, props[prop]);
  2492. });
  2493. for (var _i = 0, _b = Object.getOwnPropertySymbols(props); _i < _b.length; _i++) {
  2494. var sym = _b[_i];
  2495. var desc = Object.getOwnPropertyDescriptor(props, sym); // Since `Object.getOwnPropertySymbols` returns *all* symbols,
  2496. // including non-enumerable ones, retrieve property descriptor and check
  2497. // enumerability there. Proceed with the rewrite only when a property is
  2498. // enumerable to make the logic consistent with the way regular
  2499. // properties are retrieved (via `Object.keys`, which respects
  2500. // `enumerable: false` flag). More information:
  2501. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties#retrieval
  2502. if (desc === null || desc === void 0 ? void 0 : desc.enumerable) {
  2503. Object.defineProperty(obj, sym, props[sym]);
  2504. }
  2505. }
  2506. return obj;
  2507. };
  2508. Object.create = function (proto, propertiesObject) {
  2509. if (typeof propertiesObject === 'object' && !Object.isFrozen(propertiesObject)) {
  2510. Object.keys(propertiesObject).forEach(function (prop) {
  2511. propertiesObject[prop] = rewriteDescriptor(proto, prop, propertiesObject[prop]);
  2512. });
  2513. }
  2514. return _create(proto, propertiesObject);
  2515. };
  2516. Object.getOwnPropertyDescriptor = function (obj, prop) {
  2517. var desc = _getOwnPropertyDescriptor(obj, prop);
  2518. if (desc && isUnconfigurable(obj, prop)) {
  2519. desc.configurable = false;
  2520. }
  2521. return desc;
  2522. };
  2523. }
  2524. function _redefineProperty(obj, prop, desc) {
  2525. var originalConfigurableFlag = desc.configurable;
  2526. desc = rewriteDescriptor(obj, prop, desc);
  2527. return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag);
  2528. }
  2529. function isUnconfigurable(obj, prop) {
  2530. return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop];
  2531. }
  2532. function rewriteDescriptor(obj, prop, desc) {
  2533. // issue-927, if the desc is frozen, don't try to change the desc
  2534. if (!Object.isFrozen(desc)) {
  2535. desc.configurable = true;
  2536. }
  2537. if (!desc.configurable) {
  2538. // issue-927, if the obj is frozen, don't try to set the desc to obj
  2539. if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) {
  2540. _defineProperty(obj, unconfigurablesKey, {
  2541. writable: true,
  2542. value: {}
  2543. });
  2544. }
  2545. if (obj[unconfigurablesKey]) {
  2546. obj[unconfigurablesKey][prop] = true;
  2547. }
  2548. }
  2549. return desc;
  2550. }
  2551. function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) {
  2552. try {
  2553. return _defineProperty(obj, prop, desc);
  2554. } catch (error) {
  2555. if (desc.configurable) {
  2556. // In case of errors, when the configurable flag was likely set by rewriteDescriptor(),
  2557. // let's retry with the original flag value
  2558. if (typeof originalConfigurableFlag == 'undefined') {
  2559. delete desc.configurable;
  2560. } else {
  2561. desc.configurable = originalConfigurableFlag;
  2562. }
  2563. try {
  2564. return _defineProperty(obj, prop, desc);
  2565. } catch (error) {
  2566. var swallowError = false;
  2567. if (prop === 'createdCallback' || prop === 'attachedCallback' || prop === 'detachedCallback' || prop === 'attributeChangedCallback') {
  2568. // We only swallow the error in registerElement patch
  2569. // this is the work around since some applications
  2570. // fail if we throw the error
  2571. swallowError = true;
  2572. }
  2573. if (!swallowError) {
  2574. throw error;
  2575. } // TODO: @JiaLiPassion, Some application such as `registerElement` patch
  2576. // still need to swallow the error, in the future after these applications
  2577. // are updated, the following logic can be removed.
  2578. var descJson = null;
  2579. try {
  2580. descJson = JSON.stringify(desc);
  2581. } catch (error) {
  2582. descJson = desc.toString();
  2583. }
  2584. console.log("Attempting to configure '".concat(prop, "' with descriptor '").concat(descJson, "' on object '").concat(obj, "' and got error, giving up: ").concat(error));
  2585. }
  2586. } else {
  2587. throw error;
  2588. }
  2589. }
  2590. }
  2591. /**
  2592. * @license
  2593. * Copyright Google LLC All Rights Reserved.
  2594. *
  2595. * Use of this source code is governed by an MIT-style license that can be
  2596. * found in the LICENSE file at https://angular.io/license
  2597. */
  2598. function eventTargetLegacyPatch(_global, api) {
  2599. var _b = api.getGlobalObjects(),
  2600. eventNames = _b.eventNames,
  2601. globalSources = _b.globalSources,
  2602. zoneSymbolEventNames = _b.zoneSymbolEventNames,
  2603. TRUE_STR = _b.TRUE_STR,
  2604. FALSE_STR = _b.FALSE_STR,
  2605. ZONE_SYMBOL_PREFIX = _b.ZONE_SYMBOL_PREFIX;
  2606. var WTF_ISSUE_555 = 'Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video';
  2607. var NO_EVENT_TARGET = 'ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Window,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex,WebSocket'.split(',');
  2608. var EVENT_TARGET = 'EventTarget';
  2609. var apis = [];
  2610. var isWtf = _global['wtf'];
  2611. var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(',');
  2612. if (isWtf) {
  2613. // Workaround for: https://github.com/google/tracing-framework/issues/555
  2614. apis = WTF_ISSUE_555_ARRAY.map(function (v) {
  2615. return 'HTML' + v + 'Element';
  2616. }).concat(NO_EVENT_TARGET);
  2617. } else if (_global[EVENT_TARGET]) {
  2618. apis.push(EVENT_TARGET);
  2619. } else {
  2620. // Note: EventTarget is not available in all browsers,
  2621. // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget
  2622. apis = NO_EVENT_TARGET;
  2623. }
  2624. var isDisableIECheck = _global['__Zone_disable_IE_check'] || false;
  2625. var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false;
  2626. var ieOrEdge = api.isIEOrEdge();
  2627. var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:';
  2628. var FUNCTION_WRAPPER = '[object FunctionWrapper]';
  2629. var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }';
  2630. var pointerEventsMap = {
  2631. 'MSPointerCancel': 'pointercancel',
  2632. 'MSPointerDown': 'pointerdown',
  2633. 'MSPointerEnter': 'pointerenter',
  2634. 'MSPointerHover': 'pointerhover',
  2635. 'MSPointerLeave': 'pointerleave',
  2636. 'MSPointerMove': 'pointermove',
  2637. 'MSPointerOut': 'pointerout',
  2638. 'MSPointerOver': 'pointerover',
  2639. 'MSPointerUp': 'pointerup'
  2640. }; // predefine all __zone_symbol__ + eventName + true/false string
  2641. for (var i = 0; i < eventNames.length; i++) {
  2642. var eventName = eventNames[i];
  2643. var falseEventName = eventName + FALSE_STR;
  2644. var trueEventName = eventName + TRUE_STR;
  2645. var symbol = ZONE_SYMBOL_PREFIX + falseEventName;
  2646. var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName;
  2647. zoneSymbolEventNames[eventName] = {};
  2648. zoneSymbolEventNames[eventName][FALSE_STR] = symbol;
  2649. zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture;
  2650. } // predefine all task.source string
  2651. for (var i = 0; i < WTF_ISSUE_555_ARRAY.length; i++) {
  2652. var target = WTF_ISSUE_555_ARRAY[i];
  2653. var targets = globalSources[target] = {};
  2654. for (var j = 0; j < eventNames.length; j++) {
  2655. var eventName = eventNames[j];
  2656. targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName;
  2657. }
  2658. }
  2659. var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) {
  2660. if (!isDisableIECheck && ieOrEdge) {
  2661. if (isEnableCrossContextCheck) {
  2662. try {
  2663. var testString = delegate.toString();
  2664. if (testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS) {
  2665. nativeDelegate.apply(target, args);
  2666. return false;
  2667. }
  2668. } catch (error) {
  2669. nativeDelegate.apply(target, args);
  2670. return false;
  2671. }
  2672. } else {
  2673. var testString = delegate.toString();
  2674. if (testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS) {
  2675. nativeDelegate.apply(target, args);
  2676. return false;
  2677. }
  2678. }
  2679. } else if (isEnableCrossContextCheck) {
  2680. try {
  2681. delegate.toString();
  2682. } catch (error) {
  2683. nativeDelegate.apply(target, args);
  2684. return false;
  2685. }
  2686. }
  2687. return true;
  2688. };
  2689. var apiTypes = [];
  2690. for (var i = 0; i < apis.length; i++) {
  2691. var type = _global[apis[i]];
  2692. apiTypes.push(type && type.prototype);
  2693. } // vh is validateHandler to check event handler
  2694. // is valid or not(for security check)
  2695. api.patchEventTarget(_global, api, apiTypes, {
  2696. vh: checkIEAndCrossContext,
  2697. transferEventName: function (eventName) {
  2698. var pointerEventName = pointerEventsMap[eventName];
  2699. return pointerEventName || eventName;
  2700. }
  2701. });
  2702. Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET];
  2703. return true;
  2704. }
  2705. /**
  2706. * @license
  2707. * Copyright Google LLC All Rights Reserved.
  2708. *
  2709. * Use of this source code is governed by an MIT-style license that can be
  2710. * found in the LICENSE file at https://angular.io/license
  2711. */
  2712. // we have to patch the instance since the proto is non-configurable
  2713. function apply(api, _global) {
  2714. var _b = api.getGlobalObjects(),
  2715. ADD_EVENT_LISTENER_STR = _b.ADD_EVENT_LISTENER_STR,
  2716. REMOVE_EVENT_LISTENER_STR = _b.REMOVE_EVENT_LISTENER_STR;
  2717. var WS = _global.WebSocket; // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener
  2718. // On older Chrome, no need since EventTarget was already patched
  2719. if (!_global.EventTarget) {
  2720. api.patchEventTarget(_global, api, [WS.prototype]);
  2721. }
  2722. _global.WebSocket = function (x, y) {
  2723. var socket = arguments.length > 1 ? new WS(x, y) : new WS(x);
  2724. var proxySocket;
  2725. var proxySocketProto; // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance
  2726. var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage');
  2727. if (onmessageDesc && onmessageDesc.configurable === false) {
  2728. proxySocket = api.ObjectCreate(socket); // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror'
  2729. // but proxySocket not, so we will keep socket as prototype and pass it to
  2730. // patchOnProperties method
  2731. proxySocketProto = socket;
  2732. [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) {
  2733. proxySocket[propName] = function () {
  2734. var args = api.ArraySlice.call(arguments);
  2735. if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) {
  2736. var eventName = args.length > 0 ? args[0] : undefined;
  2737. if (eventName) {
  2738. var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName);
  2739. socket[propertySymbol] = proxySocket[propertySymbol];
  2740. }
  2741. }
  2742. return socket[propName].apply(socket, args);
  2743. };
  2744. });
  2745. } else {
  2746. // we can patch the real socket
  2747. proxySocket = socket;
  2748. }
  2749. api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto);
  2750. return proxySocket;
  2751. };
  2752. var globalWebSocket = _global['WebSocket'];
  2753. for (var prop in WS) {
  2754. globalWebSocket[prop] = WS[prop];
  2755. }
  2756. }
  2757. /**
  2758. * @license
  2759. * Copyright Google LLC All Rights Reserved.
  2760. *
  2761. * Use of this source code is governed by an MIT-style license that can be
  2762. * found in the LICENSE file at https://angular.io/license
  2763. */
  2764. function propertyDescriptorLegacyPatch(api, _global) {
  2765. var _b = api.getGlobalObjects(),
  2766. isNode = _b.isNode,
  2767. isMix = _b.isMix;
  2768. if (isNode && !isMix) {
  2769. return;
  2770. }
  2771. if (!canPatchViaPropertyDescriptor(api, _global)) {
  2772. var supportsWebSocket = typeof WebSocket !== 'undefined'; // Safari, Android browsers (Jelly Bean)
  2773. patchViaCapturingAllTheEvents(api);
  2774. api.patchClass('XMLHttpRequest');
  2775. if (supportsWebSocket) {
  2776. apply(api, _global);
  2777. }
  2778. Zone[api.symbol('patchEvents')] = true;
  2779. }
  2780. }
  2781. function canPatchViaPropertyDescriptor(api, _global) {
  2782. var _b = api.getGlobalObjects(),
  2783. isBrowser = _b.isBrowser,
  2784. isMix = _b.isMix;
  2785. if ((isBrowser || isMix) && !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') {
  2786. // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364
  2787. // IDL interface attributes are not configurable
  2788. var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick');
  2789. if (desc && !desc.configurable) return false; // try to use onclick to detect whether we can patch via propertyDescriptor
  2790. // because XMLHttpRequest is not available in service worker
  2791. if (desc) {
  2792. api.ObjectDefineProperty(Element.prototype, 'onclick', {
  2793. enumerable: true,
  2794. configurable: true,
  2795. get: function () {
  2796. return true;
  2797. }
  2798. });
  2799. var div = document.createElement('div');
  2800. var result = !!div.onclick;
  2801. api.ObjectDefineProperty(Element.prototype, 'onclick', desc);
  2802. return result;
  2803. }
  2804. }
  2805. var XMLHttpRequest = _global['XMLHttpRequest'];
  2806. if (!XMLHttpRequest) {
  2807. // XMLHttpRequest is not available in service worker
  2808. return false;
  2809. }
  2810. var ON_READY_STATE_CHANGE = 'onreadystatechange';
  2811. var XMLHttpRequestPrototype = XMLHttpRequest.prototype;
  2812. var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); // add enumerable and configurable here because in opera
  2813. // by default XMLHttpRequest.prototype.onreadystatechange is undefined
  2814. // without adding enumerable and configurable will cause onreadystatechange
  2815. // non-configurable
  2816. // and if XMLHttpRequest.prototype.onreadystatechange is undefined,
  2817. // we should set a real desc instead a fake one
  2818. if (xhrDesc) {
  2819. api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, {
  2820. enumerable: true,
  2821. configurable: true,
  2822. get: function () {
  2823. return true;
  2824. }
  2825. });
  2826. var req = new XMLHttpRequest();
  2827. var result = !!req.onreadystatechange; // restore original desc
  2828. api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {});
  2829. return result;
  2830. } else {
  2831. var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake');
  2832. api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, {
  2833. enumerable: true,
  2834. configurable: true,
  2835. get: function () {
  2836. return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1];
  2837. },
  2838. set: function (value) {
  2839. this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value;
  2840. }
  2841. });
  2842. var req = new XMLHttpRequest();
  2843. var detectFunc = function () {};
  2844. req.onreadystatechange = detectFunc;
  2845. var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc;
  2846. req.onreadystatechange = null;
  2847. return result;
  2848. }
  2849. }
  2850. var globalEventHandlersEventNames = ['abort', 'animationcancel', 'animationend', 'animationiteration', 'auxclick', 'beforeinput', 'blur', 'cancel', 'canplay', 'canplaythrough', 'change', 'compositionstart', 'compositionupdate', 'compositionend', 'cuechange', 'click', 'close', 'contextmenu', 'curechange', 'dblclick', 'drag', 'dragend', 'dragenter', 'dragexit', 'dragleave', 'dragover', 'drop', 'durationchange', 'emptied', 'ended', 'error', 'focus', 'focusin', 'focusout', 'gotpointercapture', 'input', 'invalid', 'keydown', 'keypress', 'keyup', 'load', 'loadstart', 'loadeddata', 'loadedmetadata', 'lostpointercapture', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'mousewheel', 'orientationchange', 'pause', 'play', 'playing', 'pointercancel', 'pointerdown', 'pointerenter', 'pointerleave', 'pointerlockchange', 'mozpointerlockchange', 'webkitpointerlockerchange', 'pointerlockerror', 'mozpointerlockerror', 'webkitpointerlockerror', 'pointermove', 'pointout', 'pointerover', 'pointerup', 'progress', 'ratechange', 'reset', 'resize', 'scroll', 'seeked', 'seeking', 'select', 'selectionchange', 'selectstart', 'show', 'sort', 'stalled', 'submit', 'suspend', 'timeupdate', 'volumechange', 'touchcancel', 'touchmove', 'touchstart', 'touchend', 'transitioncancel', 'transitionend', 'waiting', 'wheel'];
  2851. var documentEventNames = ['afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', 'visibilitychange', 'resume'];
  2852. var windowEventNames = ['absolutedeviceorientation', 'afterinput', 'afterprint', 'appinstalled', 'beforeinstallprompt', 'beforeprint', 'beforeunload', 'devicelight', 'devicemotion', 'deviceorientation', 'deviceorientationabsolute', 'deviceproximity', 'hashchange', 'languagechange', 'message', 'mozbeforepaint', 'offline', 'online', 'paint', 'pageshow', 'pagehide', 'popstate', 'rejectionhandled', 'storage', 'unhandledrejection', 'unload', 'userproximity', 'vrdisplayconnected', 'vrdisplaydisconnected', 'vrdisplaypresentchange'];
  2853. var htmlElementEventNames = ['beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend'];
  2854. var ieElementEventNames = ['activate', 'afterupdate', 'ariarequest', 'beforeactivate', 'beforedeactivate', 'beforeeditfocus', 'beforeupdate', 'cellchange', 'controlselect', 'dataavailable', 'datasetchanged', 'datasetcomplete', 'errorupdate', 'filterchange', 'layoutcomplete', 'losecapture', 'move', 'moveend', 'movestart', 'propertychange', 'resizeend', 'resizestart', 'rowenter', 'rowexit', 'rowsdelete', 'rowsinserted', 'command', 'compassneedscalibration', 'deactivate', 'help', 'mscontentzoom', 'msmanipulationstatechanged', 'msgesturechange', 'msgesturedoubletap', 'msgestureend', 'msgesturehold', 'msgesturestart', 'msgesturetap', 'msgotpointercapture', 'msinertiastart', 'mslostpointercapture', 'mspointercancel', 'mspointerdown', 'mspointerenter', 'mspointerhover', 'mspointerleave', 'mspointermove', 'mspointerout', 'mspointerover', 'mspointerup', 'pointerout', 'mssitemodejumplistitemremoved', 'msthumbnailclick', 'stop', 'storagecommit'];
  2855. var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror'];
  2856. var formEventNames = ['autocomplete', 'autocompleteerror'];
  2857. var detailEventNames = ['toggle'];
  2858. var eventNames = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], globalEventHandlersEventNames, true), webglEventNames, true), formEventNames, true), detailEventNames, true), documentEventNames, true), windowEventNames, true), htmlElementEventNames, true), ieElementEventNames, true); // Whenever any eventListener fires, we check the eventListener target and all parents
  2859. // for `onwhatever` properties and replace them with zone-bound functions
  2860. // - Chrome (for now)
  2861. function patchViaCapturingAllTheEvents(api) {
  2862. var unboundKey = api.symbol('unbound');
  2863. var _loop_5 = function (i) {
  2864. var property = eventNames[i];
  2865. var onproperty = 'on' + property;
  2866. self.addEventListener(property, function (event) {
  2867. var elt = event.target,
  2868. bound,
  2869. source;
  2870. if (elt) {
  2871. source = elt.constructor['name'] + '.' + onproperty;
  2872. } else {
  2873. source = 'unknown.' + onproperty;
  2874. }
  2875. while (elt) {
  2876. if (elt[onproperty] && !elt[onproperty][unboundKey]) {
  2877. bound = api.wrapWithCurrentZone(elt[onproperty], source);
  2878. bound[unboundKey] = elt[onproperty];
  2879. elt[onproperty] = bound;
  2880. }
  2881. elt = elt.parentElement;
  2882. }
  2883. }, true);
  2884. };
  2885. for (var i = 0; i < eventNames.length; i++) {
  2886. _loop_5(i);
  2887. }
  2888. }
  2889. /**
  2890. * @license
  2891. * Copyright Google LLC All Rights Reserved.
  2892. *
  2893. * Use of this source code is governed by an MIT-style license that can be
  2894. * found in the LICENSE file at https://angular.io/license
  2895. */
  2896. function registerElementPatch(_global, api) {
  2897. var _b = api.getGlobalObjects(),
  2898. isBrowser = _b.isBrowser,
  2899. isMix = _b.isMix;
  2900. if (!isBrowser && !isMix || !('registerElement' in _global.document)) {
  2901. return;
  2902. }
  2903. var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback'];
  2904. api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks);
  2905. }
  2906. /**
  2907. * @license
  2908. * Copyright Google LLC All Rights Reserved.
  2909. *
  2910. * Use of this source code is governed by an MIT-style license that can be
  2911. * found in the LICENSE file at https://angular.io/license
  2912. */
  2913. (function (_global) {
  2914. var symbolPrefix = _global['__Zone_symbol_prefix'] || '__zone_symbol__';
  2915. function __symbol__(name) {
  2916. return symbolPrefix + name;
  2917. }
  2918. _global[__symbol__('legacyPatch')] = function () {
  2919. var Zone = _global['Zone'];
  2920. Zone.__load_patch('defineProperty', function (global, Zone, api) {
  2921. api._redefineProperty = _redefineProperty;
  2922. propertyPatch();
  2923. });
  2924. Zone.__load_patch('registerElement', function (global, Zone, api) {
  2925. registerElementPatch(global, api);
  2926. });
  2927. Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) {
  2928. eventTargetLegacyPatch(global, api);
  2929. propertyDescriptorLegacyPatch(api, global);
  2930. });
  2931. };
  2932. })(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {});
  2933. /**
  2934. * @license
  2935. * Copyright Google LLC All Rights Reserved.
  2936. *
  2937. * Use of this source code is governed by an MIT-style license that can be
  2938. * found in the LICENSE file at https://angular.io/license
  2939. */
  2940. var taskSymbol = zoneSymbol$1('zoneTask');
  2941. function patchTimer(window, setName, cancelName, nameSuffix) {
  2942. var setNative = null;
  2943. var clearNative = null;
  2944. setName += nameSuffix;
  2945. cancelName += nameSuffix;
  2946. var tasksByHandleId = {};
  2947. function scheduleTask(task) {
  2948. var data = task.data;
  2949. data.args[0] = function () {
  2950. return task.invoke.apply(this, arguments);
  2951. };
  2952. data.handleId = setNative.apply(window, data.args);
  2953. return task;
  2954. }
  2955. function clearTask(task) {
  2956. return clearNative.call(window, task.data.handleId);
  2957. }
  2958. setNative = patchMethod(window, setName, function (delegate) {
  2959. return function (self, args) {
  2960. if (typeof args[0] === 'function') {
  2961. var options_1 = {
  2962. isPeriodic: nameSuffix === 'Interval',
  2963. delay: nameSuffix === 'Timeout' || nameSuffix === 'Interval' ? args[1] || 0 : undefined,
  2964. args: args
  2965. };
  2966. var callback_1 = args[0];
  2967. args[0] = function timer() {
  2968. try {
  2969. return callback_1.apply(this, arguments);
  2970. } finally {
  2971. // issue-934, task will be cancelled
  2972. // even it is a periodic task such as
  2973. // setInterval
  2974. // https://github.com/angular/angular/issues/40387
  2975. // Cleanup tasksByHandleId should be handled before scheduleTask
  2976. // Since some zoneSpec may intercept and doesn't trigger
  2977. // scheduleFn(scheduleTask) provided here.
  2978. if (!options_1.isPeriodic) {
  2979. if (typeof options_1.handleId === 'number') {
  2980. // in non-nodejs env, we remove timerId
  2981. // from local cache
  2982. delete tasksByHandleId[options_1.handleId];
  2983. } else if (options_1.handleId) {
  2984. // Node returns complex objects as handleIds
  2985. // we remove task reference from timer object
  2986. options_1.handleId[taskSymbol] = null;
  2987. }
  2988. }
  2989. }
  2990. };
  2991. var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options_1, scheduleTask, clearTask);
  2992. if (!task) {
  2993. return task;
  2994. } // Node.js must additionally support the ref and unref functions.
  2995. var handle = task.data.handleId;
  2996. if (typeof handle === 'number') {
  2997. // for non nodejs env, we save handleId: task
  2998. // mapping in local cache for clearTimeout
  2999. tasksByHandleId[handle] = task;
  3000. } else if (handle) {
  3001. // for nodejs env, we save task
  3002. // reference in timerId Object for clearTimeout
  3003. handle[taskSymbol] = task;
  3004. } // check whether handle is null, because some polyfill or browser
  3005. // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame
  3006. if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && typeof handle.unref === 'function') {
  3007. task.ref = handle.ref.bind(handle);
  3008. task.unref = handle.unref.bind(handle);
  3009. }
  3010. if (typeof handle === 'number' || handle) {
  3011. return handle;
  3012. }
  3013. return task;
  3014. } else {
  3015. // cause an error by calling it directly.
  3016. return delegate.apply(window, args);
  3017. }
  3018. };
  3019. });
  3020. clearNative = patchMethod(window, cancelName, function (delegate) {
  3021. return function (self, args) {
  3022. var id = args[0];
  3023. var task;
  3024. if (typeof id === 'number') {
  3025. // non nodejs env.
  3026. task = tasksByHandleId[id];
  3027. } else {
  3028. // nodejs env.
  3029. task = id && id[taskSymbol]; // other environments.
  3030. if (!task) {
  3031. task = id;
  3032. }
  3033. }
  3034. if (task && typeof task.type === 'string') {
  3035. if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) {
  3036. if (typeof id === 'number') {
  3037. delete tasksByHandleId[id];
  3038. } else if (id) {
  3039. id[taskSymbol] = null;
  3040. } // Do not cancel already canceled functions
  3041. task.zone.cancelTask(task);
  3042. }
  3043. } else {
  3044. // cause an error by calling it directly.
  3045. delegate.apply(window, args);
  3046. }
  3047. };
  3048. });
  3049. }
  3050. /**
  3051. * @license
  3052. * Copyright Google LLC All Rights Reserved.
  3053. *
  3054. * Use of this source code is governed by an MIT-style license that can be
  3055. * found in the LICENSE file at https://angular.io/license
  3056. */
  3057. function patchCustomElements(_global, api) {
  3058. var _b = api.getGlobalObjects(),
  3059. isBrowser = _b.isBrowser,
  3060. isMix = _b.isMix;
  3061. if (!isBrowser && !isMix || !_global['customElements'] || !('customElements' in _global)) {
  3062. return;
  3063. }
  3064. var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback'];
  3065. api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks);
  3066. }
  3067. /**
  3068. * @license
  3069. * Copyright Google LLC All Rights Reserved.
  3070. *
  3071. * Use of this source code is governed by an MIT-style license that can be
  3072. * found in the LICENSE file at https://angular.io/license
  3073. */
  3074. function eventTargetPatch(_global, api) {
  3075. if (Zone[api.symbol('patchEventTarget')]) {
  3076. // EventTarget is already patched.
  3077. return;
  3078. }
  3079. var _b = api.getGlobalObjects(),
  3080. eventNames = _b.eventNames,
  3081. zoneSymbolEventNames = _b.zoneSymbolEventNames,
  3082. TRUE_STR = _b.TRUE_STR,
  3083. FALSE_STR = _b.FALSE_STR,
  3084. ZONE_SYMBOL_PREFIX = _b.ZONE_SYMBOL_PREFIX; // predefine all __zone_symbol__ + eventName + true/false string
  3085. for (var i = 0; i < eventNames.length; i++) {
  3086. var eventName = eventNames[i];
  3087. var falseEventName = eventName + FALSE_STR;
  3088. var trueEventName = eventName + TRUE_STR;
  3089. var symbol = ZONE_SYMBOL_PREFIX + falseEventName;
  3090. var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName;
  3091. zoneSymbolEventNames[eventName] = {};
  3092. zoneSymbolEventNames[eventName][FALSE_STR] = symbol;
  3093. zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture;
  3094. }
  3095. var EVENT_TARGET = _global['EventTarget'];
  3096. if (!EVENT_TARGET || !EVENT_TARGET.prototype) {
  3097. return;
  3098. }
  3099. api.patchEventTarget(_global, api, [EVENT_TARGET && EVENT_TARGET.prototype]);
  3100. return true;
  3101. }
  3102. function patchEvent(global, api) {
  3103. api.patchEventPrototype(global, api);
  3104. }
  3105. /**
  3106. * @license
  3107. * Copyright Google LLC All Rights Reserved.
  3108. *
  3109. * Use of this source code is governed by an MIT-style license that can be
  3110. * found in the LICENSE file at https://angular.io/license
  3111. */
  3112. Zone.__load_patch('legacy', function (global) {
  3113. var legacyPatch = global[Zone.__symbol__('legacyPatch')];
  3114. if (legacyPatch) {
  3115. legacyPatch();
  3116. }
  3117. });
  3118. Zone.__load_patch('queueMicrotask', function (global, Zone, api) {
  3119. api.patchMethod(global, 'queueMicrotask', function (delegate) {
  3120. return function (self, args) {
  3121. Zone.current.scheduleMicroTask('queueMicrotask', args[0]);
  3122. };
  3123. });
  3124. });
  3125. Zone.__load_patch('timers', function (global) {
  3126. var set = 'set';
  3127. var clear = 'clear';
  3128. patchTimer(global, set, clear, 'Timeout');
  3129. patchTimer(global, set, clear, 'Interval');
  3130. patchTimer(global, set, clear, 'Immediate');
  3131. });
  3132. Zone.__load_patch('requestAnimationFrame', function (global) {
  3133. patchTimer(global, 'request', 'cancel', 'AnimationFrame');
  3134. patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame');
  3135. patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame');
  3136. });
  3137. Zone.__load_patch('blocking', function (global, Zone) {
  3138. var blockingMethods = ['alert', 'prompt', 'confirm'];
  3139. for (var i = 0; i < blockingMethods.length; i++) {
  3140. var name_2 = blockingMethods[i];
  3141. patchMethod(global, name_2, function (delegate, symbol, name) {
  3142. return function (s, args) {
  3143. return Zone.current.run(delegate, global, args, name);
  3144. };
  3145. });
  3146. }
  3147. });
  3148. Zone.__load_patch('EventTarget', function (global, Zone, api) {
  3149. patchEvent(global, api);
  3150. eventTargetPatch(global, api); // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener
  3151. var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget'];
  3152. if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) {
  3153. api.patchEventTarget(global, api, [XMLHttpRequestEventTarget.prototype]);
  3154. }
  3155. });
  3156. Zone.__load_patch('MutationObserver', function (global, Zone, api) {
  3157. patchClass('MutationObserver');
  3158. patchClass('WebKitMutationObserver');
  3159. });
  3160. Zone.__load_patch('IntersectionObserver', function (global, Zone, api) {
  3161. patchClass('IntersectionObserver');
  3162. });
  3163. Zone.__load_patch('FileReader', function (global, Zone, api) {
  3164. patchClass('FileReader');
  3165. });
  3166. Zone.__load_patch('on_property', function (global, Zone, api) {
  3167. propertyDescriptorPatch(api, global);
  3168. });
  3169. Zone.__load_patch('customElements', function (global, Zone, api) {
  3170. patchCustomElements(global, api);
  3171. });
  3172. Zone.__load_patch('XHR', function (global, Zone) {
  3173. // Treat XMLHttpRequest as a macrotask.
  3174. patchXHR(global);
  3175. var XHR_TASK = zoneSymbol$1('xhrTask');
  3176. var XHR_SYNC = zoneSymbol$1('xhrSync');
  3177. var XHR_LISTENER = zoneSymbol$1('xhrListener');
  3178. var XHR_SCHEDULED = zoneSymbol$1('xhrScheduled');
  3179. var XHR_URL = zoneSymbol$1('xhrURL');
  3180. var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol$1('xhrErrorBeforeScheduled');
  3181. function patchXHR(window) {
  3182. var XMLHttpRequest = window['XMLHttpRequest'];
  3183. if (!XMLHttpRequest) {
  3184. // XMLHttpRequest is not available in service worker
  3185. return;
  3186. }
  3187. var XMLHttpRequestPrototype = XMLHttpRequest.prototype;
  3188. function findPendingTask(target) {
  3189. return target[XHR_TASK];
  3190. }
  3191. var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER];
  3192. var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
  3193. if (!oriAddListener) {
  3194. var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget'];
  3195. if (XMLHttpRequestEventTarget_1) {
  3196. var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype;
  3197. oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER];
  3198. oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
  3199. }
  3200. }
  3201. var READY_STATE_CHANGE = 'readystatechange';
  3202. var SCHEDULED = 'scheduled';
  3203. function scheduleTask(task) {
  3204. var data = task.data;
  3205. var target = data.target;
  3206. target[XHR_SCHEDULED] = false;
  3207. target[XHR_ERROR_BEFORE_SCHEDULED] = false; // remove existing event listener
  3208. var listener = target[XHR_LISTENER];
  3209. if (!oriAddListener) {
  3210. oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER];
  3211. oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
  3212. }
  3213. if (listener) {
  3214. oriRemoveListener.call(target, READY_STATE_CHANGE, listener);
  3215. }
  3216. var newListener = target[XHR_LISTENER] = function () {
  3217. if (target.readyState === target.DONE) {
  3218. // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with
  3219. // readyState=4 multiple times, so we need to check task state here
  3220. if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) {
  3221. // check whether the xhr has registered onload listener
  3222. // if that is the case, the task should invoke after all
  3223. // onload listeners finish.
  3224. // Also if the request failed without response (status = 0), the load event handler
  3225. // will not be triggered, in that case, we should also invoke the placeholder callback
  3226. // to close the XMLHttpRequest::send macroTask.
  3227. // https://github.com/angular/angular/issues/38795
  3228. var loadTasks = target[Zone.__symbol__('loadfalse')];
  3229. if (target.status !== 0 && loadTasks && loadTasks.length > 0) {
  3230. var oriInvoke_1 = task.invoke;
  3231. task.invoke = function () {
  3232. // need to load the tasks again, because in other
  3233. // load listener, they may remove themselves
  3234. var loadTasks = target[Zone.__symbol__('loadfalse')];
  3235. for (var i = 0; i < loadTasks.length; i++) {
  3236. if (loadTasks[i] === task) {
  3237. loadTasks.splice(i, 1);
  3238. }
  3239. }
  3240. if (!data.aborted && task.state === SCHEDULED) {
  3241. oriInvoke_1.call(task);
  3242. }
  3243. };
  3244. loadTasks.push(task);
  3245. } else {
  3246. task.invoke();
  3247. }
  3248. } else if (!data.aborted && target[XHR_SCHEDULED] === false) {
  3249. // error occurs when xhr.send()
  3250. target[XHR_ERROR_BEFORE_SCHEDULED] = true;
  3251. }
  3252. }
  3253. };
  3254. oriAddListener.call(target, READY_STATE_CHANGE, newListener);
  3255. var storedTask = target[XHR_TASK];
  3256. if (!storedTask) {
  3257. target[XHR_TASK] = task;
  3258. }
  3259. sendNative.apply(target, data.args);
  3260. target[XHR_SCHEDULED] = true;
  3261. return task;
  3262. }
  3263. function placeholderCallback() {}
  3264. function clearTask(task) {
  3265. var data = task.data; // Note - ideally, we would call data.target.removeEventListener here, but it's too late
  3266. // to prevent it from firing. So instead, we store info for the event listener.
  3267. data.aborted = true;
  3268. return abortNative.apply(data.target, data.args);
  3269. }
  3270. var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () {
  3271. return function (self, args) {
  3272. self[XHR_SYNC] = args[2] == false;
  3273. self[XHR_URL] = args[1];
  3274. return openNative.apply(self, args);
  3275. };
  3276. });
  3277. var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send';
  3278. var fetchTaskAborting = zoneSymbol$1('fetchTaskAborting');
  3279. var fetchTaskScheduling = zoneSymbol$1('fetchTaskScheduling');
  3280. var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () {
  3281. return function (self, args) {
  3282. if (Zone.current[fetchTaskScheduling] === true) {
  3283. // a fetch is scheduling, so we are using xhr to polyfill fetch
  3284. // and because we already schedule macroTask for fetch, we should
  3285. // not schedule a macroTask for xhr again
  3286. return sendNative.apply(self, args);
  3287. }
  3288. if (self[XHR_SYNC]) {
  3289. // if the XHR is sync there is no task to schedule, just execute the code.
  3290. return sendNative.apply(self, args);
  3291. } else {
  3292. var options = {
  3293. target: self,
  3294. url: self[XHR_URL],
  3295. isPeriodic: false,
  3296. args: args,
  3297. aborted: false
  3298. };
  3299. var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask);
  3300. if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && task.state === SCHEDULED) {
  3301. // xhr request throw error when send
  3302. // we should invoke task instead of leaving a scheduled
  3303. // pending macroTask
  3304. task.invoke();
  3305. }
  3306. }
  3307. };
  3308. });
  3309. var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () {
  3310. return function (self, args) {
  3311. var task = findPendingTask(self);
  3312. if (task && typeof task.type == 'string') {
  3313. // If the XHR has already completed, do nothing.
  3314. // If the XHR has already been aborted, do nothing.
  3315. // Fix #569, call abort multiple times before done will cause
  3316. // macroTask task count be negative number
  3317. if (task.cancelFn == null || task.data && task.data.aborted) {
  3318. return;
  3319. }
  3320. task.zone.cancelTask(task);
  3321. } else if (Zone.current[fetchTaskAborting] === true) {
  3322. // the abort is called from fetch polyfill, we need to call native abort of XHR.
  3323. return abortNative.apply(self, args);
  3324. } // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no
  3325. // task
  3326. // to cancel. Do nothing.
  3327. };
  3328. });
  3329. }
  3330. });
  3331. Zone.__load_patch('geolocation', function (global) {
  3332. /// GEO_LOCATION
  3333. if (global['navigator'] && global['navigator'].geolocation) {
  3334. patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']);
  3335. }
  3336. });
  3337. Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) {
  3338. // handle unhandled promise rejection
  3339. function findPromiseRejectionHandler(evtName) {
  3340. return function (e) {
  3341. var eventTasks = findEventTasks(global, evtName);
  3342. eventTasks.forEach(function (eventTask) {
  3343. // windows has added unhandledrejection event listener
  3344. // trigger the event listener
  3345. var PromiseRejectionEvent = global['PromiseRejectionEvent'];
  3346. if (PromiseRejectionEvent) {
  3347. var evt = new PromiseRejectionEvent(evtName, {
  3348. promise: e.promise,
  3349. reason: e.rejection
  3350. });
  3351. eventTask.invoke(evt);
  3352. }
  3353. });
  3354. };
  3355. }
  3356. if (global['PromiseRejectionEvent']) {
  3357. Zone[zoneSymbol$1('unhandledPromiseRejectionHandler')] = findPromiseRejectionHandler('unhandledrejection');
  3358. Zone[zoneSymbol$1('rejectionHandledHandler')] = findPromiseRejectionHandler('rejectionhandled');
  3359. }
  3360. });
  3361. });
  3362. /***/ })
  3363. },
  3364. /******/ __webpack_require__ => { // webpackRuntimeModules
  3365. /******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
  3366. /******/ var __webpack_exports__ = (__webpack_exec__(7435));
  3367. /******/ }
  3368. ]);
  3369. //# sourceMappingURL=polyfills.js.map