polyfills.js 165 KB

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