angular2-polyfills.js 115 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284
  1. /**
  2. @license
  3. Copyright 2014-2015 Google, Inc. http://angularjs.org
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  15. (function (global){
  16. 'use strict';
  17. var core = require('../core');
  18. var microtask = require('../microtask');
  19. var browserPatch = require('../patch/browser');
  20. var es6Promise = require('es6-promise');
  21. if (global.Zone) {
  22. console.warn('Zone already exported on window the object!');
  23. }
  24. global.Zone = microtask.addMicrotaskSupport(core.Zone);
  25. global.zone = new global.Zone();
  26. // Monkey patch the Promise implementation to add support for microtasks
  27. global.Promise = es6Promise.Promise;
  28. browserPatch.apply();
  29. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  30. },{"../core":2,"../microtask":4,"../patch/browser":5,"es6-promise":17}],2:[function(require,module,exports){
  31. (function (global){
  32. 'use strict';
  33. var keys = require('./keys');
  34. function Zone(parentZone, data) {
  35. var zone = (arguments.length) ? Object.create(parentZone) : this;
  36. zone.parent = parentZone || null;
  37. Object.keys(data || {}).forEach(function(property) {
  38. var _property = property.substr(1);
  39. // augment the new zone with a hook decorates the parent's hook
  40. if (property[0] === '$') {
  41. zone[_property] = data[property](parentZone[_property] || function () {});
  42. // augment the new zone with a hook that runs after the parent's hook
  43. } else if (property[0] === '+') {
  44. if (parentZone[_property]) {
  45. zone[_property] = function () {
  46. var result = parentZone[_property].apply(this, arguments);
  47. data[property].apply(this, arguments);
  48. return result;
  49. };
  50. } else {
  51. zone[_property] = data[property];
  52. }
  53. // augment the new zone with a hook that runs before the parent's hook
  54. } else if (property[0] === '-') {
  55. if (parentZone[_property]) {
  56. zone[_property] = function () {
  57. data[property].apply(this, arguments);
  58. return parentZone[_property].apply(this, arguments);
  59. };
  60. } else {
  61. zone[_property] = data[property];
  62. }
  63. // set the new zone's hook (replacing the parent zone's)
  64. } else {
  65. zone[property] = (typeof data[property] === 'object') ?
  66. JSON.parse(JSON.stringify(data[property])) :
  67. data[property];
  68. }
  69. });
  70. zone.$id = Zone.nextId++;
  71. return zone;
  72. }
  73. Zone.prototype = {
  74. constructor: Zone,
  75. fork: function (locals) {
  76. this.onZoneCreated();
  77. return new Zone(this, locals);
  78. },
  79. bind: function (fn, skipEnqueue) {
  80. if (typeof fn !== 'function') {
  81. throw new Error('Expecting function got: ' + fn);
  82. }
  83. skipEnqueue || this.enqueueTask(fn);
  84. var zone = this.isRootZone() ? this : this.fork();
  85. return function zoneBoundFn() {
  86. return zone.run(fn, this, arguments);
  87. };
  88. },
  89. bindOnce: function (fn) {
  90. var boundZone = this;
  91. return this.bind(function () {
  92. var result = fn.apply(this, arguments);
  93. boundZone.dequeueTask(fn);
  94. return result;
  95. });
  96. },
  97. isRootZone: function() {
  98. return this.parent === null;
  99. },
  100. run: function run (fn, applyTo, applyWith) {
  101. applyWith = applyWith || [];
  102. var oldZone = global.zone;
  103. // MAKE THIS ZONE THE CURRENT ZONE
  104. global.zone = this;
  105. try {
  106. this.beforeTask();
  107. return fn.apply(applyTo, applyWith);
  108. } catch (e) {
  109. if (this.onError) {
  110. this.onError(e);
  111. } else {
  112. throw e;
  113. }
  114. } finally {
  115. this.afterTask();
  116. // REVERT THE CURRENT ZONE BACK TO THE ORIGINAL ZONE
  117. global.zone = oldZone;
  118. }
  119. },
  120. // onError is used to override error handling.
  121. // When a custom error handler is provided, it should most probably rethrow the exception
  122. // not to break the expected control flow:
  123. //
  124. // `promise.then(fnThatThrows).catch(fn);`
  125. //
  126. // When this code is executed in a zone with a custom onError handler that doesn't rethrow, the
  127. // `.catch()` branch will not be taken as the `fnThatThrows` exception will be swallowed by the
  128. // handler.
  129. onError: null,
  130. beforeTask: function () {},
  131. onZoneCreated: function () {},
  132. afterTask: function () {},
  133. enqueueTask: function () {},
  134. dequeueTask: function () {},
  135. addEventListener: function () {
  136. return this[keys.common.addEventListener].apply(this, arguments);
  137. },
  138. removeEventListener: function () {
  139. return this[keys.common.removeEventListener].apply(this, arguments);
  140. }
  141. };
  142. // Root zone ID === 1
  143. Zone.nextId = 1;
  144. Zone.bindPromiseFn = require('./patch/promise').bindPromiseFn;
  145. module.exports = {
  146. Zone: Zone
  147. };
  148. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  149. },{"./keys":3,"./patch/promise":12}],3:[function(require,module,exports){
  150. /**
  151. * Creates keys for `private` properties on exposed objects to minimize interactions with other codebases.
  152. */
  153. function create(name) {
  154. // `Symbol` implementation is broken in Chrome 39.0.2171, do not use them even if they are available
  155. return '_zone$' + name;
  156. }
  157. var commonKeys = {
  158. addEventListener: create('addEventListener'),
  159. removeEventListener: create('removeEventListener')
  160. };
  161. module.exports = {
  162. create: create,
  163. common: commonKeys
  164. };
  165. },{}],4:[function(require,module,exports){
  166. (function (global){
  167. 'use strict';
  168. // TODO(vicb): Create a benchmark for the different methods & the usage of the queue
  169. // see https://github.com/angular/zone.js/issues/97
  170. // It is required to initialize hasNativePromise before requiring es6-promise otherwise es6-promise would
  171. // overwrite the native Promise implementation on v8 and the check would always return false.
  172. // see https://github.com/jakearchibald/es6-promise/issues/140
  173. var hasNativePromise = typeof Promise !== "undefined" &&
  174. Promise.toString().indexOf("[native code]") !== -1;
  175. var isFirefox = global.navigator &&
  176. global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  177. var resolvedPromise;
  178. // TODO(vicb): remove '!isFirefox' when the bug gets fixed:
  179. // https://bugzilla.mozilla.org/show_bug.cgi?id=1162013
  180. if (hasNativePromise && !isFirefox) {
  181. // When available use a native Promise to schedule microtasks.
  182. // When not available, es6-promise fallback will be used
  183. resolvedPromise = Promise.resolve();
  184. }
  185. var es6Promise = require('es6-promise').Promise;
  186. if (resolvedPromise) {
  187. es6Promise._setScheduler(function(fn) {
  188. resolvedPromise.then(fn);
  189. });
  190. }
  191. // es6-promise asap should schedule microtasks via zone.scheduleMicrotask so that any
  192. // user defined hooks are triggered
  193. es6Promise._setAsap(function(fn, arg) {
  194. global.zone.scheduleMicrotask(function() {
  195. fn(arg);
  196. });
  197. });
  198. // The default implementation of scheduleMicrotask use the original es6-promise implementation
  199. // to schedule a microtask
  200. function scheduleMicrotask(fn) {
  201. es6Promise._asap(this.bind(fn));
  202. }
  203. function addMicrotaskSupport(zoneClass) {
  204. zoneClass.prototype.scheduleMicrotask = scheduleMicrotask;
  205. return zoneClass;
  206. }
  207. module.exports = {
  208. addMicrotaskSupport: addMicrotaskSupport
  209. };
  210. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  211. },{"es6-promise":17}],5:[function(require,module,exports){
  212. (function (global){
  213. 'use strict';
  214. var fnPatch = require('./functions');
  215. var promisePatch = require('./promise');
  216. var mutationObserverPatch = require('./mutation-observer');
  217. var definePropertyPatch = require('./define-property');
  218. var registerElementPatch = require('./register-element');
  219. var webSocketPatch = require('./websocket');
  220. var eventTargetPatch = require('./event-target');
  221. var propertyDescriptorPatch = require('./property-descriptor');
  222. var geolocationPatch = require('./geolocation');
  223. var fileReaderPatch = require('./file-reader');
  224. function apply() {
  225. fnPatch.patchSetClearFunction(global, [
  226. 'timeout',
  227. 'interval',
  228. 'immediate'
  229. ]);
  230. fnPatch.patchRequestAnimationFrame(global, [
  231. 'requestAnimationFrame',
  232. 'mozRequestAnimationFrame',
  233. 'webkitRequestAnimationFrame'
  234. ]);
  235. fnPatch.patchFunction(global, [
  236. 'alert',
  237. 'prompt'
  238. ]);
  239. eventTargetPatch.apply();
  240. propertyDescriptorPatch.apply();
  241. promisePatch.apply();
  242. mutationObserverPatch.patchClass('MutationObserver');
  243. mutationObserverPatch.patchClass('WebKitMutationObserver');
  244. definePropertyPatch.apply();
  245. registerElementPatch.apply();
  246. geolocationPatch.apply();
  247. fileReaderPatch.apply();
  248. }
  249. module.exports = {
  250. apply: apply
  251. };
  252. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  253. },{"./define-property":6,"./event-target":7,"./file-reader":8,"./functions":9,"./geolocation":10,"./mutation-observer":11,"./promise":12,"./property-descriptor":13,"./register-element":14,"./websocket":15}],6:[function(require,module,exports){
  254. 'use strict';
  255. var keys = require('../keys');
  256. // might need similar for object.freeze
  257. // i regret nothing
  258. var _defineProperty = Object.defineProperty;
  259. var _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  260. var _create = Object.create;
  261. var unconfigurablesKey = keys.create('unconfigurables');
  262. function apply() {
  263. Object.defineProperty = function (obj, prop, desc) {
  264. if (isUnconfigurable(obj, prop)) {
  265. throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj);
  266. }
  267. if (prop !== 'prototype') {
  268. desc = rewriteDescriptor(obj, prop, desc);
  269. }
  270. return _defineProperty(obj, prop, desc);
  271. };
  272. Object.defineProperties = function (obj, props) {
  273. Object.keys(props).forEach(function (prop) {
  274. Object.defineProperty(obj, prop, props[prop]);
  275. });
  276. return obj;
  277. };
  278. Object.create = function (obj, proto) {
  279. if (typeof proto === 'object') {
  280. Object.keys(proto).forEach(function (prop) {
  281. proto[prop] = rewriteDescriptor(obj, prop, proto[prop]);
  282. });
  283. }
  284. return _create(obj, proto);
  285. };
  286. Object.getOwnPropertyDescriptor = function (obj, prop) {
  287. var desc = _getOwnPropertyDescriptor(obj, prop);
  288. if (isUnconfigurable(obj, prop)) {
  289. desc.configurable = false;
  290. }
  291. return desc;
  292. };
  293. };
  294. function _redefineProperty(obj, prop, desc) {
  295. desc = rewriteDescriptor(obj, prop, desc);
  296. return _defineProperty(obj, prop, desc);
  297. };
  298. function isUnconfigurable (obj, prop) {
  299. return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop];
  300. }
  301. function rewriteDescriptor (obj, prop, desc) {
  302. desc.configurable = true;
  303. if (!desc.configurable) {
  304. if (!obj[unconfigurablesKey]) {
  305. _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} });
  306. }
  307. obj[unconfigurablesKey][prop] = true;
  308. }
  309. return desc;
  310. }
  311. module.exports = {
  312. apply: apply,
  313. _redefineProperty: _redefineProperty
  314. };
  315. },{"../keys":3}],7:[function(require,module,exports){
  316. (function (global){
  317. 'use strict';
  318. var utils = require('../utils');
  319. function apply() {
  320. // patched properties depend on addEventListener, so this needs to come first
  321. if (global.EventTarget) {
  322. utils.patchEventTargetMethods(global.EventTarget.prototype);
  323. // Note: EventTarget is not available in all browsers,
  324. // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget
  325. } else {
  326. var apis = [
  327. 'ApplicationCache',
  328. 'EventSource',
  329. 'FileReader',
  330. 'InputMethodContext',
  331. 'MediaController',
  332. 'MessagePort',
  333. 'Node',
  334. 'Performance',
  335. 'SVGElementInstance',
  336. 'SharedWorker',
  337. 'TextTrack',
  338. 'TextTrackCue',
  339. 'TextTrackList',
  340. 'WebKitNamedFlow',
  341. 'Worker',
  342. 'WorkerGlobalScope',
  343. 'XMLHttpRequest',
  344. 'XMLHttpRequestEventTarget',
  345. 'XMLHttpRequestUpload'
  346. ];
  347. apis.forEach(function(api) {
  348. var proto = global[api] && global[api].prototype;
  349. // Some browsers e.g. Android 4.3's don't actually implement
  350. // the EventTarget methods for all of these e.g. FileReader.
  351. // In this case, there is nothing to patch.
  352. if (proto && proto.addEventListener) {
  353. utils.patchEventTargetMethods(proto);
  354. }
  355. });
  356. // Patch the methods on `window` instead of `Window.prototype`
  357. // `Window` is not accessible on Android 4.3
  358. if (typeof(window) !== 'undefined') {
  359. utils.patchEventTargetMethods(window);
  360. }
  361. }
  362. }
  363. module.exports = {
  364. apply: apply
  365. };
  366. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  367. },{"../utils":16}],8:[function(require,module,exports){
  368. 'use strict';
  369. var utils = require('../utils');
  370. function apply() {
  371. utils.patchClass('FileReader');
  372. }
  373. module.exports = {
  374. apply: apply
  375. };
  376. },{"../utils":16}],9:[function(require,module,exports){
  377. (function (global){
  378. 'use strict';
  379. var utils = require('../utils');
  380. function patchSetClearFunction(obj, fnNames) {
  381. fnNames.map(function (name) {
  382. return name[0].toUpperCase() + name.substr(1);
  383. }).forEach(function (name) {
  384. var setName = 'set' + name;
  385. var delegate = obj[setName];
  386. if (delegate) {
  387. var clearName = 'clear' + name;
  388. var ids = {};
  389. var bindArgs = setName === 'setInterval' ? utils.bindArguments : utils.bindArgumentsOnce;
  390. global.zone[setName] = function (fn) {
  391. var id, fnRef = fn;
  392. arguments[0] = function () {
  393. delete ids[id];
  394. return fnRef.apply(this, arguments);
  395. };
  396. var args = bindArgs(arguments);
  397. id = delegate.apply(obj, args);
  398. ids[id] = true;
  399. return id;
  400. };
  401. obj[setName] = function () {
  402. return global.zone[setName].apply(this, arguments);
  403. };
  404. var clearDelegate = obj[clearName];
  405. global.zone[clearName] = function (id) {
  406. if (ids[id]) {
  407. delete ids[id];
  408. global.zone.dequeueTask();
  409. }
  410. return clearDelegate.apply(this, arguments);
  411. };
  412. obj[clearName] = function () {
  413. return global.zone[clearName].apply(this, arguments);
  414. };
  415. }
  416. });
  417. };
  418. /**
  419. * requestAnimationFrame is typically recursively called from within the callback function
  420. * that it executes. To handle this case, only fork a zone if this is executed
  421. * within the root zone.
  422. */
  423. function patchRequestAnimationFrame(obj, fnNames) {
  424. fnNames.forEach(function (name) {
  425. var delegate = obj[name];
  426. if (delegate) {
  427. global.zone[name] = function (fn) {
  428. var callZone = global.zone.isRootZone() ? global.zone.fork() : global.zone;
  429. if (fn) {
  430. arguments[0] = function () {
  431. return callZone.run(fn, this, arguments);
  432. };
  433. }
  434. return delegate.apply(obj, arguments);
  435. };
  436. obj[name] = function () {
  437. return global.zone[name].apply(this, arguments);
  438. };
  439. }
  440. });
  441. };
  442. function patchSetFunction(obj, fnNames) {
  443. fnNames.forEach(function (name) {
  444. var delegate = obj[name];
  445. if (delegate) {
  446. global.zone[name] = function (fn) {
  447. arguments[0] = function () {
  448. return fn.apply(this, arguments);
  449. };
  450. var args = utils.bindArgumentsOnce(arguments);
  451. return delegate.apply(obj, args);
  452. };
  453. obj[name] = function () {
  454. return zone[name].apply(this, arguments);
  455. };
  456. }
  457. });
  458. };
  459. function patchFunction(obj, fnNames) {
  460. fnNames.forEach(function (name) {
  461. var delegate = obj[name];
  462. global.zone[name] = function () {
  463. return delegate.apply(obj, arguments);
  464. };
  465. obj[name] = function () {
  466. return global.zone[name].apply(this, arguments);
  467. };
  468. });
  469. };
  470. module.exports = {
  471. patchSetClearFunction: patchSetClearFunction,
  472. patchSetFunction: patchSetFunction,
  473. patchRequestAnimationFrame: patchRequestAnimationFrame,
  474. patchFunction: patchFunction
  475. };
  476. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  477. },{"../utils":16}],10:[function(require,module,exports){
  478. (function (global){
  479. 'use strict';
  480. var utils = require('../utils');
  481. function apply() {
  482. if (global.navigator && global.navigator.geolocation) {
  483. utils.patchPrototype(global.navigator.geolocation, [
  484. 'getCurrentPosition',
  485. 'watchPosition'
  486. ]);
  487. }
  488. }
  489. module.exports = {
  490. apply: apply
  491. }
  492. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  493. },{"../utils":16}],11:[function(require,module,exports){
  494. (function (global){
  495. 'use strict';
  496. var keys = require('../keys');
  497. var originalInstanceKey = keys.create('originalInstance');
  498. var creationZoneKey = keys.create('creationZone');
  499. var isActiveKey = keys.create('isActive');
  500. // wrap some native API on `window`
  501. function patchClass(className) {
  502. var OriginalClass = global[className];
  503. if (!OriginalClass) return;
  504. global[className] = function (fn) {
  505. this[originalInstanceKey] = new OriginalClass(global.zone.bind(fn, true));
  506. // Remember where the class was instantiate to execute the enqueueTask and dequeueTask hooks
  507. this[creationZoneKey] = global.zone;
  508. };
  509. var instance = new OriginalClass(function () {});
  510. global[className].prototype.disconnect = function () {
  511. var result = this[originalInstanceKey].disconnect.apply(this[originalInstanceKey], arguments);
  512. if (this[isActiveKey]) {
  513. this[creationZoneKey].dequeueTask();
  514. this[isActiveKey] = false;
  515. }
  516. return result;
  517. };
  518. global[className].prototype.observe = function () {
  519. if (!this[isActiveKey]) {
  520. this[creationZoneKey].enqueueTask();
  521. this[isActiveKey] = true;
  522. }
  523. return this[originalInstanceKey].observe.apply(this[originalInstanceKey], arguments);
  524. };
  525. var prop;
  526. for (prop in instance) {
  527. (function (prop) {
  528. if (typeof global[className].prototype !== 'undefined') {
  529. return;
  530. }
  531. if (typeof instance[prop] === 'function') {
  532. global[className].prototype[prop] = function () {
  533. return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments);
  534. };
  535. } else {
  536. Object.defineProperty(global[className].prototype, prop, {
  537. set: function (fn) {
  538. if (typeof fn === 'function') {
  539. this[originalInstanceKey][prop] = global.zone.bind(fn);
  540. } else {
  541. this[originalInstanceKey][prop] = fn;
  542. }
  543. },
  544. get: function () {
  545. return this[originalInstanceKey][prop];
  546. }
  547. });
  548. }
  549. }(prop));
  550. }
  551. };
  552. module.exports = {
  553. patchClass: patchClass
  554. };
  555. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  556. },{"../keys":3}],12:[function(require,module,exports){
  557. (function (global){
  558. 'use strict';
  559. var utils = require('../utils');
  560. /*
  561. * Patches a function that returns a Promise-like instance.
  562. *
  563. * This function must be used when either:
  564. * - Native Promises are not available,
  565. * - The function returns a Promise-like object.
  566. *
  567. * This is required because zones rely on a Promise monkey patch that could not be applied when
  568. * Promise is not natively available or when the returned object is not an instance of Promise.
  569. *
  570. * Note that calling `bindPromiseFn` on a function that returns a native Promise will also work
  571. * with minimal overhead.
  572. *
  573. * ```
  574. * var boundFunction = bindPromiseFn(FunctionReturningAPromise);
  575. *
  576. * boundFunction.then(successHandler, errorHandler);
  577. * ```
  578. */
  579. var bindPromiseFn;
  580. if (global.Promise) {
  581. bindPromiseFn = function (delegate) {
  582. return function() {
  583. var delegatePromise = delegate.apply(this, arguments);
  584. // if the delegate returned an instance of Promise, forward it.
  585. if (delegatePromise instanceof Promise) {
  586. return delegatePromise;
  587. }
  588. // Otherwise wrap the Promise-like in a global Promise
  589. return new Promise(function(resolve, reject) {
  590. delegatePromise.then(resolve, reject);
  591. });
  592. };
  593. };
  594. } else {
  595. bindPromiseFn = function (delegate) {
  596. return function () {
  597. return _patchThenable(delegate.apply(this, arguments));
  598. };
  599. };
  600. }
  601. function _patchPromiseFnsOnObject(objectPath, fnNames) {
  602. var obj = global;
  603. var exists = objectPath.every(function (segment) {
  604. obj = obj[segment];
  605. return obj;
  606. });
  607. if (!exists) {
  608. return;
  609. }
  610. fnNames.forEach(function (name) {
  611. var fn = obj[name];
  612. if (fn) {
  613. obj[name] = bindPromiseFn(fn);
  614. }
  615. });
  616. }
  617. function _patchThenable(thenable) {
  618. var then = thenable.then;
  619. thenable.then = function () {
  620. var args = utils.bindArguments(arguments);
  621. var nextThenable = then.apply(thenable, args);
  622. return _patchThenable(nextThenable);
  623. };
  624. var ocatch = thenable.catch;
  625. thenable.catch = function () {
  626. var args = utils.bindArguments(arguments);
  627. var nextThenable = ocatch.apply(thenable, args);
  628. return _patchThenable(nextThenable);
  629. };
  630. return thenable;
  631. }
  632. function apply() {
  633. // Patch .then() and .catch() on native Promises to execute callbacks in the zone where
  634. // those functions are called.
  635. if (global.Promise) {
  636. utils.patchPrototype(Promise.prototype, [
  637. 'then',
  638. 'catch'
  639. ]);
  640. // Patch browser APIs that return a Promise
  641. var patchFns = [
  642. // fetch
  643. [[], ['fetch']],
  644. [['Response', 'prototype'], ['arrayBuffer', 'blob', 'json', 'text']]
  645. ];
  646. patchFns.forEach(function(objPathAndFns) {
  647. _patchPromiseFnsOnObject(objPathAndFns[0], objPathAndFns[1]);
  648. });
  649. }
  650. }
  651. module.exports = {
  652. apply: apply,
  653. bindPromiseFn: bindPromiseFn
  654. };
  655. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  656. },{"../utils":16}],13:[function(require,module,exports){
  657. (function (global){
  658. 'use strict';
  659. var webSocketPatch = require('./websocket');
  660. var utils = require('../utils');
  661. var keys = require('../keys');
  662. var eventNames = 'copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror'.split(' ');
  663. function apply() {
  664. if (utils.isWebWorker()){
  665. // on WebWorker so don't apply patch
  666. return;
  667. }
  668. var supportsWebSocket = typeof WebSocket !== 'undefined';
  669. if (canPatchViaPropertyDescriptor()) {
  670. // for browsers that we can patch the descriptor: Chrome & Firefox
  671. var onEventNames = eventNames.map(function (property) {
  672. return 'on' + property;
  673. });
  674. utils.patchProperties(HTMLElement.prototype, onEventNames);
  675. utils.patchProperties(XMLHttpRequest.prototype);
  676. if (supportsWebSocket) {
  677. utils.patchProperties(WebSocket.prototype);
  678. }
  679. } else {
  680. // Safari, Android browsers (Jelly Bean)
  681. patchViaCapturingAllTheEvents();
  682. utils.patchClass('XMLHttpRequest');
  683. if (supportsWebSocket) {
  684. webSocketPatch.apply();
  685. }
  686. }
  687. }
  688. function canPatchViaPropertyDescriptor() {
  689. if (!Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') {
  690. // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364
  691. // IDL interface attributes are not configurable
  692. var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick');
  693. if (desc && !desc.configurable) return false;
  694. }
  695. Object.defineProperty(HTMLElement.prototype, 'onclick', {
  696. get: function () {
  697. return true;
  698. }
  699. });
  700. var elt = document.createElement('div');
  701. var result = !!elt.onclick;
  702. Object.defineProperty(HTMLElement.prototype, 'onclick', {});
  703. return result;
  704. };
  705. var unboundKey = keys.create('unbound');
  706. // Whenever any event fires, we check the event target and all parents
  707. // for `onwhatever` properties and replace them with zone-bound functions
  708. // - Chrome (for now)
  709. function patchViaCapturingAllTheEvents() {
  710. eventNames.forEach(function (property) {
  711. var onproperty = 'on' + property;
  712. document.addEventListener(property, function (event) {
  713. var elt = event.target, bound;
  714. while (elt) {
  715. if (elt[onproperty] && !elt[onproperty][unboundKey]) {
  716. bound = global.zone.bind(elt[onproperty]);
  717. bound[unboundKey] = elt[onproperty];
  718. elt[onproperty] = bound;
  719. }
  720. elt = elt.parentElement;
  721. }
  722. }, true);
  723. });
  724. };
  725. module.exports = {
  726. apply: apply
  727. };
  728. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  729. },{"../keys":3,"../utils":16,"./websocket":15}],14:[function(require,module,exports){
  730. (function (global){
  731. 'use strict';
  732. var _redefineProperty = require('./define-property')._redefineProperty;
  733. var utils = require("../utils");
  734. function apply() {
  735. if (utils.isWebWorker() || !('registerElement' in global.document)) {
  736. return;
  737. }
  738. var _registerElement = document.registerElement;
  739. var callbacks = [
  740. 'createdCallback',
  741. 'attachedCallback',
  742. 'detachedCallback',
  743. 'attributeChangedCallback'
  744. ];
  745. document.registerElement = function (name, opts) {
  746. if (opts && opts.prototype) {
  747. callbacks.forEach(function (callback) {
  748. if (opts.prototype.hasOwnProperty(callback)) {
  749. var descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback);
  750. if (descriptor && descriptor.value) {
  751. descriptor.value = global.zone.bind(descriptor.value);
  752. _redefineProperty(opts.prototype, callback, descriptor);
  753. } else {
  754. opts.prototype[callback] = global.zone.bind(opts.prototype[callback]);
  755. }
  756. } else if (opts.prototype[callback]) {
  757. opts.prototype[callback] = global.zone.bind(opts.prototype[callback]);
  758. }
  759. });
  760. }
  761. return _registerElement.apply(document, [name, opts]);
  762. };
  763. }
  764. module.exports = {
  765. apply: apply
  766. };
  767. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  768. },{"../utils":16,"./define-property":6}],15:[function(require,module,exports){
  769. (function (global){
  770. 'use strict';
  771. var utils = require('../utils');
  772. // we have to patch the instance since the proto is non-configurable
  773. function apply() {
  774. var WS = global.WebSocket;
  775. utils.patchEventTargetMethods(WS.prototype);
  776. global.WebSocket = function(a, b) {
  777. var socket = arguments.length > 1 ? new WS(a, b) : new WS(a);
  778. var proxySocket;
  779. // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance
  780. var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage');
  781. if (onmessageDesc && onmessageDesc.configurable === false) {
  782. proxySocket = Object.create(socket);
  783. ['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function(propName) {
  784. proxySocket[propName] = function() {
  785. return socket[propName].apply(socket, arguments);
  786. };
  787. });
  788. } else {
  789. // we can patch the real socket
  790. proxySocket = socket;
  791. }
  792. utils.patchProperties(proxySocket, ['onclose', 'onerror', 'onmessage', 'onopen']);
  793. return proxySocket;
  794. };
  795. }
  796. module.exports = {
  797. apply: apply
  798. };
  799. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  800. },{"../utils":16}],16:[function(require,module,exports){
  801. (function (global){
  802. 'use strict';
  803. var keys = require('./keys');
  804. function bindArguments(args) {
  805. for (var i = args.length - 1; i >= 0; i--) {
  806. if (typeof args[i] === 'function') {
  807. args[i] = global.zone.bind(args[i]);
  808. }
  809. }
  810. return args;
  811. };
  812. function bindArgumentsOnce(args) {
  813. for (var i = args.length - 1; i >= 0; i--) {
  814. if (typeof args[i] === 'function') {
  815. args[i] = global.zone.bindOnce(args[i]);
  816. }
  817. }
  818. return args;
  819. };
  820. function patchPrototype(obj, fnNames) {
  821. fnNames.forEach(function (name) {
  822. var delegate = obj[name];
  823. if (delegate) {
  824. obj[name] = function () {
  825. return delegate.apply(this, bindArguments(arguments));
  826. };
  827. }
  828. });
  829. };
  830. function isWebWorker() {
  831. return (typeof document === "undefined");
  832. }
  833. function patchProperty(obj, prop) {
  834. var desc = Object.getOwnPropertyDescriptor(obj, prop) || {
  835. enumerable: true,
  836. configurable: true
  837. };
  838. // A property descriptor cannot have getter/setter and be writable
  839. // deleting the writable and value properties avoids this error:
  840. //
  841. // TypeError: property descriptors must not specify a value or be writable when a
  842. // getter or setter has been specified
  843. delete desc.writable;
  844. delete desc.value;
  845. // substr(2) cuz 'onclick' -> 'click', etc
  846. var eventName = prop.substr(2);
  847. var _prop = '_' + prop;
  848. desc.set = function (fn) {
  849. if (this[_prop]) {
  850. this.removeEventListener(eventName, this[_prop]);
  851. }
  852. if (typeof fn === 'function') {
  853. this[_prop] = fn;
  854. this.addEventListener(eventName, fn, false);
  855. } else {
  856. this[_prop] = null;
  857. }
  858. };
  859. desc.get = function () {
  860. return this[_prop];
  861. };
  862. Object.defineProperty(obj, prop, desc);
  863. };
  864. function patchProperties(obj, properties) {
  865. (properties || (function () {
  866. var props = [];
  867. for (var prop in obj) {
  868. props.push(prop);
  869. }
  870. return props;
  871. }()).
  872. filter(function (propertyName) {
  873. return propertyName.substr(0,2) === 'on';
  874. })).
  875. forEach(function (eventName) {
  876. patchProperty(obj, eventName);
  877. });
  878. };
  879. var originalFnKey = keys.create('originalFn');
  880. var boundFnsKey = keys.create('boundFns');
  881. function patchEventTargetMethods(obj) {
  882. // This is required for the addEventListener hook on the root zone.
  883. obj[keys.common.addEventListener] = obj.addEventListener;
  884. obj.addEventListener = function (eventName, handler, useCapturing) {
  885. //Ignore special listeners of IE11 & Edge dev tools, see https://github.com/angular/zone.js/issues/150
  886. if (handler && handler.toString() !== "[object FunctionWrapper]") {
  887. var eventType = eventName + (useCapturing ? '$capturing' : '$bubbling');
  888. var fn;
  889. if (handler.handleEvent) {
  890. // Have to pass in 'handler' reference as an argument here, otherwise it gets clobbered in
  891. // IE9 by the arguments[1] assignment at end of this function.
  892. fn = (function(handler) {
  893. return function() {
  894. handler.handleEvent.apply(handler, arguments);
  895. };
  896. })(handler);
  897. } else {
  898. fn = handler;
  899. }
  900. handler[originalFnKey] = fn;
  901. handler[boundFnsKey] = handler[boundFnsKey] || {};
  902. handler[boundFnsKey][eventType] = handler[boundFnsKey][eventType] || zone.bind(fn);
  903. arguments[1] = handler[boundFnsKey][eventType];
  904. }
  905. // - Inside a Web Worker, `this` is undefined, the context is `global` (= `self`)
  906. // - When `addEventListener` is called on the global context in strict mode, `this` is undefined
  907. // see https://github.com/angular/zone.js/issues/190
  908. var target = this || global;
  909. return global.zone.addEventListener.apply(target, arguments);
  910. };
  911. // This is required for the removeEventListener hook on the root zone.
  912. obj[keys.common.removeEventListener] = obj.removeEventListener;
  913. obj.removeEventListener = function (eventName, handler, useCapturing) {
  914. var eventType = eventName + (useCapturing ? '$capturing' : '$bubbling');
  915. if (handler && handler[boundFnsKey] && handler[boundFnsKey][eventType]) {
  916. var _bound = handler[boundFnsKey];
  917. arguments[1] = _bound[eventType];
  918. delete _bound[eventType];
  919. global.zone.dequeueTask(handler[originalFnKey]);
  920. }
  921. // - Inside a Web Worker, `this` is undefined, the context is `global`
  922. // - When `addEventListener` is called on the global context in strict mode, `this` is undefined
  923. // see https://github.com/angular/zone.js/issues/190
  924. var target = this || global;
  925. var result = global.zone.removeEventListener.apply(target, arguments);
  926. return result;
  927. };
  928. };
  929. var originalInstanceKey = keys.create('originalInstance');
  930. // wrap some native API on `window`
  931. function patchClass(className) {
  932. var OriginalClass = global[className];
  933. if (!OriginalClass) return;
  934. global[className] = function () {
  935. var a = bindArguments(arguments);
  936. switch (a.length) {
  937. case 0: this[originalInstanceKey] = new OriginalClass(); break;
  938. case 1: this[originalInstanceKey] = new OriginalClass(a[0]); break;
  939. case 2: this[originalInstanceKey] = new OriginalClass(a[0], a[1]); break;
  940. case 3: this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); break;
  941. case 4: this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); break;
  942. default: throw new Error('what are you even doing?');
  943. }
  944. };
  945. var instance = new OriginalClass();
  946. var prop;
  947. for (prop in instance) {
  948. (function (prop) {
  949. if (typeof instance[prop] === 'function') {
  950. global[className].prototype[prop] = function () {
  951. return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments);
  952. };
  953. } else {
  954. Object.defineProperty(global[className].prototype, prop, {
  955. set: function (fn) {
  956. if (typeof fn === 'function') {
  957. this[originalInstanceKey][prop] = global.zone.bind(fn);
  958. } else {
  959. this[originalInstanceKey][prop] = fn;
  960. }
  961. },
  962. get: function () {
  963. return this[originalInstanceKey][prop];
  964. }
  965. });
  966. }
  967. }(prop));
  968. }
  969. for (prop in OriginalClass) {
  970. if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) {
  971. global[className][prop] = OriginalClass[prop];
  972. }
  973. }
  974. };
  975. module.exports = {
  976. bindArguments: bindArguments,
  977. bindArgumentsOnce: bindArgumentsOnce,
  978. patchPrototype: patchPrototype,
  979. patchProperty: patchProperty,
  980. patchProperties: patchProperties,
  981. patchEventTargetMethods: patchEventTargetMethods,
  982. patchClass: patchClass,
  983. isWebWorker: isWebWorker
  984. };
  985. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  986. },{"./keys":3}],17:[function(require,module,exports){
  987. (function (process,global){
  988. /*!
  989. * @overview es6-promise - a tiny implementation of Promises/A+.
  990. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
  991. * @license Licensed under MIT license
  992. * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE
  993. * @version 3.0.2
  994. */
  995. (function() {
  996. "use strict";
  997. function lib$es6$promise$utils$$objectOrFunction(x) {
  998. return typeof x === 'function' || (typeof x === 'object' && x !== null);
  999. }
  1000. function lib$es6$promise$utils$$isFunction(x) {
  1001. return typeof x === 'function';
  1002. }
  1003. function lib$es6$promise$utils$$isMaybeThenable(x) {
  1004. return typeof x === 'object' && x !== null;
  1005. }
  1006. var lib$es6$promise$utils$$_isArray;
  1007. if (!Array.isArray) {
  1008. lib$es6$promise$utils$$_isArray = function (x) {
  1009. return Object.prototype.toString.call(x) === '[object Array]';
  1010. };
  1011. } else {
  1012. lib$es6$promise$utils$$_isArray = Array.isArray;
  1013. }
  1014. var lib$es6$promise$utils$$isArray = lib$es6$promise$utils$$_isArray;
  1015. var lib$es6$promise$asap$$len = 0;
  1016. var lib$es6$promise$asap$$toString = {}.toString;
  1017. var lib$es6$promise$asap$$vertxNext;
  1018. var lib$es6$promise$asap$$customSchedulerFn;
  1019. var lib$es6$promise$asap$$asap = function asap(callback, arg) {
  1020. lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len] = callback;
  1021. lib$es6$promise$asap$$queue[lib$es6$promise$asap$$len + 1] = arg;
  1022. lib$es6$promise$asap$$len += 2;
  1023. if (lib$es6$promise$asap$$len === 2) {
  1024. // If len is 2, that means that we need to schedule an async flush.
  1025. // If additional callbacks are queued before the queue is flushed, they
  1026. // will be processed by this flush that we are scheduling.
  1027. if (lib$es6$promise$asap$$customSchedulerFn) {
  1028. lib$es6$promise$asap$$customSchedulerFn(lib$es6$promise$asap$$flush);
  1029. } else {
  1030. lib$es6$promise$asap$$scheduleFlush();
  1031. }
  1032. }
  1033. }
  1034. function lib$es6$promise$asap$$setScheduler(scheduleFn) {
  1035. lib$es6$promise$asap$$customSchedulerFn = scheduleFn;
  1036. }
  1037. function lib$es6$promise$asap$$setAsap(asapFn) {
  1038. lib$es6$promise$asap$$asap = asapFn;
  1039. }
  1040. var lib$es6$promise$asap$$browserWindow = (typeof window !== 'undefined') ? window : undefined;
  1041. var lib$es6$promise$asap$$browserGlobal = lib$es6$promise$asap$$browserWindow || {};
  1042. var lib$es6$promise$asap$$BrowserMutationObserver = lib$es6$promise$asap$$browserGlobal.MutationObserver || lib$es6$promise$asap$$browserGlobal.WebKitMutationObserver;
  1043. var lib$es6$promise$asap$$isNode = typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
  1044. // test for web worker but not in IE10
  1045. var lib$es6$promise$asap$$isWorker = typeof Uint8ClampedArray !== 'undefined' &&
  1046. typeof importScripts !== 'undefined' &&
  1047. typeof MessageChannel !== 'undefined';
  1048. // node
  1049. function lib$es6$promise$asap$$useNextTick() {
  1050. // node version 0.10.x displays a deprecation warning when nextTick is used recursively
  1051. // see https://github.com/cujojs/when/issues/410 for details
  1052. return function() {
  1053. process.nextTick(lib$es6$promise$asap$$flush);
  1054. };
  1055. }
  1056. // vertx
  1057. function lib$es6$promise$asap$$useVertxTimer() {
  1058. return function() {
  1059. lib$es6$promise$asap$$vertxNext(lib$es6$promise$asap$$flush);
  1060. };
  1061. }
  1062. function lib$es6$promise$asap$$useMutationObserver() {
  1063. var iterations = 0;
  1064. var observer = new lib$es6$promise$asap$$BrowserMutationObserver(lib$es6$promise$asap$$flush);
  1065. var node = document.createTextNode('');
  1066. observer.observe(node, { characterData: true });
  1067. return function() {
  1068. node.data = (iterations = ++iterations % 2);
  1069. };
  1070. }
  1071. // web worker
  1072. function lib$es6$promise$asap$$useMessageChannel() {
  1073. var channel = new MessageChannel();
  1074. channel.port1.onmessage = lib$es6$promise$asap$$flush;
  1075. return function () {
  1076. channel.port2.postMessage(0);
  1077. };
  1078. }
  1079. function lib$es6$promise$asap$$useSetTimeout() {
  1080. return function() {
  1081. setTimeout(lib$es6$promise$asap$$flush, 1);
  1082. };
  1083. }
  1084. var lib$es6$promise$asap$$queue = new Array(1000);
  1085. function lib$es6$promise$asap$$flush() {
  1086. for (var i = 0; i < lib$es6$promise$asap$$len; i+=2) {
  1087. var callback = lib$es6$promise$asap$$queue[i];
  1088. var arg = lib$es6$promise$asap$$queue[i+1];
  1089. callback(arg);
  1090. lib$es6$promise$asap$$queue[i] = undefined;
  1091. lib$es6$promise$asap$$queue[i+1] = undefined;
  1092. }
  1093. lib$es6$promise$asap$$len = 0;
  1094. }
  1095. function lib$es6$promise$asap$$attemptVertx() {
  1096. try {
  1097. var r = require;
  1098. var vertx = r('vertx');
  1099. lib$es6$promise$asap$$vertxNext = vertx.runOnLoop || vertx.runOnContext;
  1100. return lib$es6$promise$asap$$useVertxTimer();
  1101. } catch(e) {
  1102. return lib$es6$promise$asap$$useSetTimeout();
  1103. }
  1104. }
  1105. var lib$es6$promise$asap$$scheduleFlush;
  1106. // Decide what async method to use to triggering processing of queued callbacks:
  1107. if (lib$es6$promise$asap$$isNode) {
  1108. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useNextTick();
  1109. } else if (lib$es6$promise$asap$$BrowserMutationObserver) {
  1110. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMutationObserver();
  1111. } else if (lib$es6$promise$asap$$isWorker) {
  1112. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useMessageChannel();
  1113. } else if (lib$es6$promise$asap$$browserWindow === undefined && typeof require === 'function') {
  1114. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$attemptVertx();
  1115. } else {
  1116. lib$es6$promise$asap$$scheduleFlush = lib$es6$promise$asap$$useSetTimeout();
  1117. }
  1118. function lib$es6$promise$$internal$$noop() {}
  1119. var lib$es6$promise$$internal$$PENDING = void 0;
  1120. var lib$es6$promise$$internal$$FULFILLED = 1;
  1121. var lib$es6$promise$$internal$$REJECTED = 2;
  1122. var lib$es6$promise$$internal$$GET_THEN_ERROR = new lib$es6$promise$$internal$$ErrorObject();
  1123. function lib$es6$promise$$internal$$selfFulfillment() {
  1124. return new TypeError("You cannot resolve a promise with itself");
  1125. }
  1126. function lib$es6$promise$$internal$$cannotReturnOwn() {
  1127. return new TypeError('A promises callback cannot return that same promise.');
  1128. }
  1129. function lib$es6$promise$$internal$$getThen(promise) {
  1130. try {
  1131. return promise.then;
  1132. } catch(error) {
  1133. lib$es6$promise$$internal$$GET_THEN_ERROR.error = error;
  1134. return lib$es6$promise$$internal$$GET_THEN_ERROR;
  1135. }
  1136. }
  1137. function lib$es6$promise$$internal$$tryThen(then, value, fulfillmentHandler, rejectionHandler) {
  1138. try {
  1139. then.call(value, fulfillmentHandler, rejectionHandler);
  1140. } catch(e) {
  1141. return e;
  1142. }
  1143. }
  1144. function lib$es6$promise$$internal$$handleForeignThenable(promise, thenable, then) {
  1145. lib$es6$promise$asap$$asap(function(promise) {
  1146. var sealed = false;
  1147. var error = lib$es6$promise$$internal$$tryThen(then, thenable, function(value) {
  1148. if (sealed) { return; }
  1149. sealed = true;
  1150. if (thenable !== value) {
  1151. lib$es6$promise$$internal$$resolve(promise, value);
  1152. } else {
  1153. lib$es6$promise$$internal$$fulfill(promise, value);
  1154. }
  1155. }, function(reason) {
  1156. if (sealed) { return; }
  1157. sealed = true;
  1158. lib$es6$promise$$internal$$reject(promise, reason);
  1159. }, 'Settle: ' + (promise._label || ' unknown promise'));
  1160. if (!sealed && error) {
  1161. sealed = true;
  1162. lib$es6$promise$$internal$$reject(promise, error);
  1163. }
  1164. }, promise);
  1165. }
  1166. function lib$es6$promise$$internal$$handleOwnThenable(promise, thenable) {
  1167. if (thenable._state === lib$es6$promise$$internal$$FULFILLED) {
  1168. lib$es6$promise$$internal$$fulfill(promise, thenable._result);
  1169. } else if (thenable._state === lib$es6$promise$$internal$$REJECTED) {
  1170. lib$es6$promise$$internal$$reject(promise, thenable._result);
  1171. } else {
  1172. lib$es6$promise$$internal$$subscribe(thenable, undefined, function(value) {
  1173. lib$es6$promise$$internal$$resolve(promise, value);
  1174. }, function(reason) {
  1175. lib$es6$promise$$internal$$reject(promise, reason);
  1176. });
  1177. }
  1178. }
  1179. function lib$es6$promise$$internal$$handleMaybeThenable(promise, maybeThenable) {
  1180. if (maybeThenable.constructor === promise.constructor) {
  1181. lib$es6$promise$$internal$$handleOwnThenable(promise, maybeThenable);
  1182. } else {
  1183. var then = lib$es6$promise$$internal$$getThen(maybeThenable);
  1184. if (then === lib$es6$promise$$internal$$GET_THEN_ERROR) {
  1185. lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$GET_THEN_ERROR.error);
  1186. } else if (then === undefined) {
  1187. lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
  1188. } else if (lib$es6$promise$utils$$isFunction(then)) {
  1189. lib$es6$promise$$internal$$handleForeignThenable(promise, maybeThenable, then);
  1190. } else {
  1191. lib$es6$promise$$internal$$fulfill(promise, maybeThenable);
  1192. }
  1193. }
  1194. }
  1195. function lib$es6$promise$$internal$$resolve(promise, value) {
  1196. if (promise === value) {
  1197. lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$selfFulfillment());
  1198. } else if (lib$es6$promise$utils$$objectOrFunction(value)) {
  1199. lib$es6$promise$$internal$$handleMaybeThenable(promise, value);
  1200. } else {
  1201. lib$es6$promise$$internal$$fulfill(promise, value);
  1202. }
  1203. }
  1204. function lib$es6$promise$$internal$$publishRejection(promise) {
  1205. if (promise._onerror) {
  1206. promise._onerror(promise._result);
  1207. }
  1208. lib$es6$promise$$internal$$publish(promise);
  1209. }
  1210. function lib$es6$promise$$internal$$fulfill(promise, value) {
  1211. if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
  1212. promise._result = value;
  1213. promise._state = lib$es6$promise$$internal$$FULFILLED;
  1214. if (promise._subscribers.length !== 0) {
  1215. lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, promise);
  1216. }
  1217. }
  1218. function lib$es6$promise$$internal$$reject(promise, reason) {
  1219. if (promise._state !== lib$es6$promise$$internal$$PENDING) { return; }
  1220. promise._state = lib$es6$promise$$internal$$REJECTED;
  1221. promise._result = reason;
  1222. lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publishRejection, promise);
  1223. }
  1224. function lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection) {
  1225. var subscribers = parent._subscribers;
  1226. var length = subscribers.length;
  1227. parent._onerror = null;
  1228. subscribers[length] = child;
  1229. subscribers[length + lib$es6$promise$$internal$$FULFILLED] = onFulfillment;
  1230. subscribers[length + lib$es6$promise$$internal$$REJECTED] = onRejection;
  1231. if (length === 0 && parent._state) {
  1232. lib$es6$promise$asap$$asap(lib$es6$promise$$internal$$publish, parent);
  1233. }
  1234. }
  1235. function lib$es6$promise$$internal$$publish(promise) {
  1236. var subscribers = promise._subscribers;
  1237. var settled = promise._state;
  1238. if (subscribers.length === 0) { return; }
  1239. var child, callback, detail = promise._result;
  1240. for (var i = 0; i < subscribers.length; i += 3) {
  1241. child = subscribers[i];
  1242. callback = subscribers[i + settled];
  1243. if (child) {
  1244. lib$es6$promise$$internal$$invokeCallback(settled, child, callback, detail);
  1245. } else {
  1246. callback(detail);
  1247. }
  1248. }
  1249. promise._subscribers.length = 0;
  1250. }
  1251. function lib$es6$promise$$internal$$ErrorObject() {
  1252. this.error = null;
  1253. }
  1254. var lib$es6$promise$$internal$$TRY_CATCH_ERROR = new lib$es6$promise$$internal$$ErrorObject();
  1255. function lib$es6$promise$$internal$$tryCatch(callback, detail) {
  1256. try {
  1257. return callback(detail);
  1258. } catch(e) {
  1259. lib$es6$promise$$internal$$TRY_CATCH_ERROR.error = e;
  1260. return lib$es6$promise$$internal$$TRY_CATCH_ERROR;
  1261. }
  1262. }
  1263. function lib$es6$promise$$internal$$invokeCallback(settled, promise, callback, detail) {
  1264. var hasCallback = lib$es6$promise$utils$$isFunction(callback),
  1265. value, error, succeeded, failed;
  1266. if (hasCallback) {
  1267. value = lib$es6$promise$$internal$$tryCatch(callback, detail);
  1268. if (value === lib$es6$promise$$internal$$TRY_CATCH_ERROR) {
  1269. failed = true;
  1270. error = value.error;
  1271. value = null;
  1272. } else {
  1273. succeeded = true;
  1274. }
  1275. if (promise === value) {
  1276. lib$es6$promise$$internal$$reject(promise, lib$es6$promise$$internal$$cannotReturnOwn());
  1277. return;
  1278. }
  1279. } else {
  1280. value = detail;
  1281. succeeded = true;
  1282. }
  1283. if (promise._state !== lib$es6$promise$$internal$$PENDING) {
  1284. // noop
  1285. } else if (hasCallback && succeeded) {
  1286. lib$es6$promise$$internal$$resolve(promise, value);
  1287. } else if (failed) {
  1288. lib$es6$promise$$internal$$reject(promise, error);
  1289. } else if (settled === lib$es6$promise$$internal$$FULFILLED) {
  1290. lib$es6$promise$$internal$$fulfill(promise, value);
  1291. } else if (settled === lib$es6$promise$$internal$$REJECTED) {
  1292. lib$es6$promise$$internal$$reject(promise, value);
  1293. }
  1294. }
  1295. function lib$es6$promise$$internal$$initializePromise(promise, resolver) {
  1296. try {
  1297. resolver(function resolvePromise(value){
  1298. lib$es6$promise$$internal$$resolve(promise, value);
  1299. }, function rejectPromise(reason) {
  1300. lib$es6$promise$$internal$$reject(promise, reason);
  1301. });
  1302. } catch(e) {
  1303. lib$es6$promise$$internal$$reject(promise, e);
  1304. }
  1305. }
  1306. function lib$es6$promise$enumerator$$Enumerator(Constructor, input) {
  1307. var enumerator = this;
  1308. enumerator._instanceConstructor = Constructor;
  1309. enumerator.promise = new Constructor(lib$es6$promise$$internal$$noop);
  1310. if (enumerator._validateInput(input)) {
  1311. enumerator._input = input;
  1312. enumerator.length = input.length;
  1313. enumerator._remaining = input.length;
  1314. enumerator._init();
  1315. if (enumerator.length === 0) {
  1316. lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
  1317. } else {
  1318. enumerator.length = enumerator.length || 0;
  1319. enumerator._enumerate();
  1320. if (enumerator._remaining === 0) {
  1321. lib$es6$promise$$internal$$fulfill(enumerator.promise, enumerator._result);
  1322. }
  1323. }
  1324. } else {
  1325. lib$es6$promise$$internal$$reject(enumerator.promise, enumerator._validationError());
  1326. }
  1327. }
  1328. lib$es6$promise$enumerator$$Enumerator.prototype._validateInput = function(input) {
  1329. return lib$es6$promise$utils$$isArray(input);
  1330. };
  1331. lib$es6$promise$enumerator$$Enumerator.prototype._validationError = function() {
  1332. return new Error('Array Methods must be provided an Array');
  1333. };
  1334. lib$es6$promise$enumerator$$Enumerator.prototype._init = function() {
  1335. this._result = new Array(this.length);
  1336. };
  1337. var lib$es6$promise$enumerator$$default = lib$es6$promise$enumerator$$Enumerator;
  1338. lib$es6$promise$enumerator$$Enumerator.prototype._enumerate = function() {
  1339. var enumerator = this;
  1340. var length = enumerator.length;
  1341. var promise = enumerator.promise;
  1342. var input = enumerator._input;
  1343. for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
  1344. enumerator._eachEntry(input[i], i);
  1345. }
  1346. };
  1347. lib$es6$promise$enumerator$$Enumerator.prototype._eachEntry = function(entry, i) {
  1348. var enumerator = this;
  1349. var c = enumerator._instanceConstructor;
  1350. if (lib$es6$promise$utils$$isMaybeThenable(entry)) {
  1351. if (entry.constructor === c && entry._state !== lib$es6$promise$$internal$$PENDING) {
  1352. entry._onerror = null;
  1353. enumerator._settledAt(entry._state, i, entry._result);
  1354. } else {
  1355. enumerator._willSettleAt(c.resolve(entry), i);
  1356. }
  1357. } else {
  1358. enumerator._remaining--;
  1359. enumerator._result[i] = entry;
  1360. }
  1361. };
  1362. lib$es6$promise$enumerator$$Enumerator.prototype._settledAt = function(state, i, value) {
  1363. var enumerator = this;
  1364. var promise = enumerator.promise;
  1365. if (promise._state === lib$es6$promise$$internal$$PENDING) {
  1366. enumerator._remaining--;
  1367. if (state === lib$es6$promise$$internal$$REJECTED) {
  1368. lib$es6$promise$$internal$$reject(promise, value);
  1369. } else {
  1370. enumerator._result[i] = value;
  1371. }
  1372. }
  1373. if (enumerator._remaining === 0) {
  1374. lib$es6$promise$$internal$$fulfill(promise, enumerator._result);
  1375. }
  1376. };
  1377. lib$es6$promise$enumerator$$Enumerator.prototype._willSettleAt = function(promise, i) {
  1378. var enumerator = this;
  1379. lib$es6$promise$$internal$$subscribe(promise, undefined, function(value) {
  1380. enumerator._settledAt(lib$es6$promise$$internal$$FULFILLED, i, value);
  1381. }, function(reason) {
  1382. enumerator._settledAt(lib$es6$promise$$internal$$REJECTED, i, reason);
  1383. });
  1384. };
  1385. function lib$es6$promise$promise$all$$all(entries) {
  1386. return new lib$es6$promise$enumerator$$default(this, entries).promise;
  1387. }
  1388. var lib$es6$promise$promise$all$$default = lib$es6$promise$promise$all$$all;
  1389. function lib$es6$promise$promise$race$$race(entries) {
  1390. /*jshint validthis:true */
  1391. var Constructor = this;
  1392. var promise = new Constructor(lib$es6$promise$$internal$$noop);
  1393. if (!lib$es6$promise$utils$$isArray(entries)) {
  1394. lib$es6$promise$$internal$$reject(promise, new TypeError('You must pass an array to race.'));
  1395. return promise;
  1396. }
  1397. var length = entries.length;
  1398. function onFulfillment(value) {
  1399. lib$es6$promise$$internal$$resolve(promise, value);
  1400. }
  1401. function onRejection(reason) {
  1402. lib$es6$promise$$internal$$reject(promise, reason);
  1403. }
  1404. for (var i = 0; promise._state === lib$es6$promise$$internal$$PENDING && i < length; i++) {
  1405. lib$es6$promise$$internal$$subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
  1406. }
  1407. return promise;
  1408. }
  1409. var lib$es6$promise$promise$race$$default = lib$es6$promise$promise$race$$race;
  1410. function lib$es6$promise$promise$resolve$$resolve(object) {
  1411. /*jshint validthis:true */
  1412. var Constructor = this;
  1413. if (object && typeof object === 'object' && object.constructor === Constructor) {
  1414. return object;
  1415. }
  1416. var promise = new Constructor(lib$es6$promise$$internal$$noop);
  1417. lib$es6$promise$$internal$$resolve(promise, object);
  1418. return promise;
  1419. }
  1420. var lib$es6$promise$promise$resolve$$default = lib$es6$promise$promise$resolve$$resolve;
  1421. function lib$es6$promise$promise$reject$$reject(reason) {
  1422. /*jshint validthis:true */
  1423. var Constructor = this;
  1424. var promise = new Constructor(lib$es6$promise$$internal$$noop);
  1425. lib$es6$promise$$internal$$reject(promise, reason);
  1426. return promise;
  1427. }
  1428. var lib$es6$promise$promise$reject$$default = lib$es6$promise$promise$reject$$reject;
  1429. var lib$es6$promise$promise$$counter = 0;
  1430. function lib$es6$promise$promise$$needsResolver() {
  1431. throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
  1432. }
  1433. function lib$es6$promise$promise$$needsNew() {
  1434. throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
  1435. }
  1436. var lib$es6$promise$promise$$default = lib$es6$promise$promise$$Promise;
  1437. /**
  1438. Promise objects represent the eventual result of an asynchronous operation. The
  1439. primary way of interacting with a promise is through its `then` method, which
  1440. registers callbacks to receive either a promise's eventual value or the reason
  1441. why the promise cannot be fulfilled.
  1442. Terminology
  1443. -----------
  1444. - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
  1445. - `thenable` is an object or function that defines a `then` method.
  1446. - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
  1447. - `exception` is a value that is thrown using the throw statement.
  1448. - `reason` is a value that indicates why a promise was rejected.
  1449. - `settled` the final resting state of a promise, fulfilled or rejected.
  1450. A promise can be in one of three states: pending, fulfilled, or rejected.
  1451. Promises that are fulfilled have a fulfillment value and are in the fulfilled
  1452. state. Promises that are rejected have a rejection reason and are in the
  1453. rejected state. A fulfillment value is never a thenable.
  1454. Promises can also be said to *resolve* a value. If this value is also a
  1455. promise, then the original promise's settled state will match the value's
  1456. settled state. So a promise that *resolves* a promise that rejects will
  1457. itself reject, and a promise that *resolves* a promise that fulfills will
  1458. itself fulfill.
  1459. Basic Usage:
  1460. ------------
  1461. ```js
  1462. var promise = new Promise(function(resolve, reject) {
  1463. // on success
  1464. resolve(value);
  1465. // on failure
  1466. reject(reason);
  1467. });
  1468. promise.then(function(value) {
  1469. // on fulfillment
  1470. }, function(reason) {
  1471. // on rejection
  1472. });
  1473. ```
  1474. Advanced Usage:
  1475. ---------------
  1476. Promises shine when abstracting away asynchronous interactions such as
  1477. `XMLHttpRequest`s.
  1478. ```js
  1479. function getJSON(url) {
  1480. return new Promise(function(resolve, reject){
  1481. var xhr = new XMLHttpRequest();
  1482. xhr.open('GET', url);
  1483. xhr.onreadystatechange = handler;
  1484. xhr.responseType = 'json';
  1485. xhr.setRequestHeader('Accept', 'application/json');
  1486. xhr.send();
  1487. function handler() {
  1488. if (this.readyState === this.DONE) {
  1489. if (this.status === 200) {
  1490. resolve(this.response);
  1491. } else {
  1492. reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
  1493. }
  1494. }
  1495. };
  1496. });
  1497. }
  1498. getJSON('/posts.json').then(function(json) {
  1499. // on fulfillment
  1500. }, function(reason) {
  1501. // on rejection
  1502. });
  1503. ```
  1504. Unlike callbacks, promises are great composable primitives.
  1505. ```js
  1506. Promise.all([
  1507. getJSON('/posts'),
  1508. getJSON('/comments')
  1509. ]).then(function(values){
  1510. values[0] // => postsJSON
  1511. values[1] // => commentsJSON
  1512. return values;
  1513. });
  1514. ```
  1515. @class Promise
  1516. @param {function} resolver
  1517. Useful for tooling.
  1518. @constructor
  1519. */
  1520. function lib$es6$promise$promise$$Promise(resolver) {
  1521. this._id = lib$es6$promise$promise$$counter++;
  1522. this._state = undefined;
  1523. this._result = undefined;
  1524. this._subscribers = [];
  1525. if (lib$es6$promise$$internal$$noop !== resolver) {
  1526. if (!lib$es6$promise$utils$$isFunction(resolver)) {
  1527. lib$es6$promise$promise$$needsResolver();
  1528. }
  1529. if (!(this instanceof lib$es6$promise$promise$$Promise)) {
  1530. lib$es6$promise$promise$$needsNew();
  1531. }
  1532. lib$es6$promise$$internal$$initializePromise(this, resolver);
  1533. }
  1534. }
  1535. lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default;
  1536. lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default;
  1537. lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default;
  1538. lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default;
  1539. lib$es6$promise$promise$$Promise._setScheduler = lib$es6$promise$asap$$setScheduler;
  1540. lib$es6$promise$promise$$Promise._setAsap = lib$es6$promise$asap$$setAsap;
  1541. lib$es6$promise$promise$$Promise._asap = lib$es6$promise$asap$$asap;
  1542. lib$es6$promise$promise$$Promise.prototype = {
  1543. constructor: lib$es6$promise$promise$$Promise,
  1544. /**
  1545. The primary way of interacting with a promise is through its `then` method,
  1546. which registers callbacks to receive either a promise's eventual value or the
  1547. reason why the promise cannot be fulfilled.
  1548. ```js
  1549. findUser().then(function(user){
  1550. // user is available
  1551. }, function(reason){
  1552. // user is unavailable, and you are given the reason why
  1553. });
  1554. ```
  1555. Chaining
  1556. --------
  1557. The return value of `then` is itself a promise. This second, 'downstream'
  1558. promise is resolved with the return value of the first promise's fulfillment
  1559. or rejection handler, or rejected if the handler throws an exception.
  1560. ```js
  1561. findUser().then(function (user) {
  1562. return user.name;
  1563. }, function (reason) {
  1564. return 'default name';
  1565. }).then(function (userName) {
  1566. // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
  1567. // will be `'default name'`
  1568. });
  1569. findUser().then(function (user) {
  1570. throw new Error('Found user, but still unhappy');
  1571. }, function (reason) {
  1572. throw new Error('`findUser` rejected and we're unhappy');
  1573. }).then(function (value) {
  1574. // never reached
  1575. }, function (reason) {
  1576. // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
  1577. // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
  1578. });
  1579. ```
  1580. If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
  1581. ```js
  1582. findUser().then(function (user) {
  1583. throw new PedagogicalException('Upstream error');
  1584. }).then(function (value) {
  1585. // never reached
  1586. }).then(function (value) {
  1587. // never reached
  1588. }, function (reason) {
  1589. // The `PedgagocialException` is propagated all the way down to here
  1590. });
  1591. ```
  1592. Assimilation
  1593. ------------
  1594. Sometimes the value you want to propagate to a downstream promise can only be
  1595. retrieved asynchronously. This can be achieved by returning a promise in the
  1596. fulfillment or rejection handler. The downstream promise will then be pending
  1597. until the returned promise is settled. This is called *assimilation*.
  1598. ```js
  1599. findUser().then(function (user) {
  1600. return findCommentsByAuthor(user);
  1601. }).then(function (comments) {
  1602. // The user's comments are now available
  1603. });
  1604. ```
  1605. If the assimliated promise rejects, then the downstream promise will also reject.
  1606. ```js
  1607. findUser().then(function (user) {
  1608. return findCommentsByAuthor(user);
  1609. }).then(function (comments) {
  1610. // If `findCommentsByAuthor` fulfills, we'll have the value here
  1611. }, function (reason) {
  1612. // If `findCommentsByAuthor` rejects, we'll have the reason here
  1613. });
  1614. ```
  1615. Simple Example
  1616. --------------
  1617. Synchronous Example
  1618. ```javascript
  1619. var result;
  1620. try {
  1621. result = findResult();
  1622. // success
  1623. } catch(reason) {
  1624. // failure
  1625. }
  1626. ```
  1627. Errback Example
  1628. ```js
  1629. findResult(function(result, err){
  1630. if (err) {
  1631. // failure
  1632. } else {
  1633. // success
  1634. }
  1635. });
  1636. ```
  1637. Promise Example;
  1638. ```javascript
  1639. findResult().then(function(result){
  1640. // success
  1641. }, function(reason){
  1642. // failure
  1643. });
  1644. ```
  1645. Advanced Example
  1646. --------------
  1647. Synchronous Example
  1648. ```javascript
  1649. var author, books;
  1650. try {
  1651. author = findAuthor();
  1652. books = findBooksByAuthor(author);
  1653. // success
  1654. } catch(reason) {
  1655. // failure
  1656. }
  1657. ```
  1658. Errback Example
  1659. ```js
  1660. function foundBooks(books) {
  1661. }
  1662. function failure(reason) {
  1663. }
  1664. findAuthor(function(author, err){
  1665. if (err) {
  1666. failure(err);
  1667. // failure
  1668. } else {
  1669. try {
  1670. findBoooksByAuthor(author, function(books, err) {
  1671. if (err) {
  1672. failure(err);
  1673. } else {
  1674. try {
  1675. foundBooks(books);
  1676. } catch(reason) {
  1677. failure(reason);
  1678. }
  1679. }
  1680. });
  1681. } catch(error) {
  1682. failure(err);
  1683. }
  1684. // success
  1685. }
  1686. });
  1687. ```
  1688. Promise Example;
  1689. ```javascript
  1690. findAuthor().
  1691. then(findBooksByAuthor).
  1692. then(function(books){
  1693. // found books
  1694. }).catch(function(reason){
  1695. // something went wrong
  1696. });
  1697. ```
  1698. @method then
  1699. @param {Function} onFulfilled
  1700. @param {Function} onRejected
  1701. Useful for tooling.
  1702. @return {Promise}
  1703. */
  1704. then: function(onFulfillment, onRejection) {
  1705. var parent = this;
  1706. var state = parent._state;
  1707. if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) {
  1708. return this;
  1709. }
  1710. var child = new this.constructor(lib$es6$promise$$internal$$noop);
  1711. var result = parent._result;
  1712. if (state) {
  1713. var callback = arguments[state - 1];
  1714. lib$es6$promise$asap$$asap(function(){
  1715. lib$es6$promise$$internal$$invokeCallback(state, child, callback, result);
  1716. });
  1717. } else {
  1718. lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection);
  1719. }
  1720. return child;
  1721. },
  1722. /**
  1723. `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
  1724. as the catch block of a try/catch statement.
  1725. ```js
  1726. function findAuthor(){
  1727. throw new Error('couldn't find that author');
  1728. }
  1729. // synchronous
  1730. try {
  1731. findAuthor();
  1732. } catch(reason) {
  1733. // something went wrong
  1734. }
  1735. // async with promises
  1736. findAuthor().catch(function(reason){
  1737. // something went wrong
  1738. });
  1739. ```
  1740. @method catch
  1741. @param {Function} onRejection
  1742. Useful for tooling.
  1743. @return {Promise}
  1744. */
  1745. 'catch': function(onRejection) {
  1746. return this.then(null, onRejection);
  1747. }
  1748. };
  1749. function lib$es6$promise$polyfill$$polyfill() {
  1750. var local;
  1751. if (typeof global !== 'undefined') {
  1752. local = global;
  1753. } else if (typeof self !== 'undefined') {
  1754. local = self;
  1755. } else {
  1756. try {
  1757. local = Function('return this')();
  1758. } catch (e) {
  1759. throw new Error('polyfill failed because global object is unavailable in this environment');
  1760. }
  1761. }
  1762. var P = local.Promise;
  1763. if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
  1764. return;
  1765. }
  1766. local.Promise = lib$es6$promise$promise$$default;
  1767. }
  1768. var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill;
  1769. var lib$es6$promise$umd$$ES6Promise = {
  1770. 'Promise': lib$es6$promise$promise$$default,
  1771. 'polyfill': lib$es6$promise$polyfill$$default
  1772. };
  1773. /* global define:true module:true window: true */
  1774. if (typeof define === 'function' && define['amd']) {
  1775. define(function() { return lib$es6$promise$umd$$ES6Promise; });
  1776. } else if (typeof module !== 'undefined' && module['exports']) {
  1777. module['exports'] = lib$es6$promise$umd$$ES6Promise;
  1778. } else if (typeof this !== 'undefined') {
  1779. this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise;
  1780. }
  1781. lib$es6$promise$polyfill$$default();
  1782. }).call(this);
  1783. }).call(this,{},typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1784. },{}]},{},[1]);
  1785. (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  1786. (function (global){
  1787. 'use strict';
  1788. if (!global.Zone) {
  1789. throw new Error('zone.js should be installed before loading the long stack trace zone');
  1790. }
  1791. global.Zone.longStackTraceZone = require('../zones/long-stack-trace.js');
  1792. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1793. },{"../zones/long-stack-trace.js":2}],2:[function(require,module,exports){
  1794. (function (global){
  1795. /*
  1796. * Wrapped stacktrace
  1797. *
  1798. * We need this because in some implementations, constructing a trace is slow
  1799. * and so we want to defer accessing the trace for as long as possible
  1800. */
  1801. 'use strict';
  1802. function _Stacktrace(e) {
  1803. this._e = e;
  1804. };
  1805. _Stacktrace.prototype.get = function () {
  1806. if (global.zone.stackFramesFilter && this._e.stack) {
  1807. return this._e.stack
  1808. .split('\n')
  1809. .filter(global.zone.stackFramesFilter)
  1810. .join('\n');
  1811. }
  1812. return this._e.stack;
  1813. }
  1814. function _getStacktraceWithUncaughtError () {
  1815. return new _Stacktrace(new Error());
  1816. }
  1817. function _getStacktraceWithCaughtError () {
  1818. try {
  1819. throw new Error();
  1820. } catch (e) {
  1821. return new _Stacktrace(e);
  1822. }
  1823. }
  1824. // Some implementations of exception handling don't create a stack trace if the exception
  1825. // isn't thrown, however it's faster not to actually throw the exception.
  1826. var stack = _getStacktraceWithUncaughtError();
  1827. var _getStacktrace = stack && stack._e.stack
  1828. ? _getStacktraceWithUncaughtError
  1829. : _getStacktraceWithCaughtError;
  1830. module.exports = {
  1831. getLongStacktrace: function (exception) {
  1832. var traces = [];
  1833. var currentZone = this;
  1834. if (exception) {
  1835. if (currentZone.stackFramesFilter && exception.stack) {
  1836. traces.push(exception.stack.split('\n')
  1837. .filter(currentZone.stackFramesFilter)
  1838. .join('\n'));
  1839. } else {
  1840. traces.push(exception.stack);
  1841. }
  1842. }
  1843. var now = Date.now();
  1844. while (currentZone && currentZone.constructedAtException) {
  1845. traces.push(
  1846. '--- ' + (Date(currentZone.constructedAtTime)).toString() +
  1847. ' - ' + (now - currentZone.constructedAtTime) + 'ms ago',
  1848. currentZone.constructedAtException.get());
  1849. currentZone = currentZone.parent;
  1850. }
  1851. return traces.join('\n');
  1852. },
  1853. stackFramesFilter: function (line) {
  1854. return !/zone(-microtask)?(\.min)?\.js/.test(line);
  1855. },
  1856. onError: function (exception) {
  1857. var reporter = this.reporter || console.log.bind(console);
  1858. reporter(exception.toString());
  1859. reporter(this.getLongStacktrace(exception));
  1860. },
  1861. '$fork': function (parentFork) {
  1862. return function() {
  1863. var newZone = parentFork.apply(this, arguments);
  1864. newZone.constructedAtException = _getStacktrace();
  1865. newZone.constructedAtTime = Date.now();
  1866. return newZone;
  1867. }
  1868. }
  1869. };
  1870. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1871. },{}]},{},[1]);
  1872. /**
  1873. @license
  1874. Apache License
  1875. Version 2.0, January 2004
  1876. http://www.apache.org/licenses/
  1877. TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  1878. 1. Definitions.
  1879. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
  1880. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
  1881. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
  1882. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
  1883. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
  1884. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
  1885. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
  1886. "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
  1887. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
  1888. "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
  1889. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
  1890. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
  1891. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
  1892. You must give any other recipients of the Work or Derivative Works a copy of this License; and
  1893. You must cause any modified files to carry prominent notices stating that You changed the files; and
  1894. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
  1895. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
  1896. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
  1897. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
  1898. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
  1899. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
  1900. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
  1901. END OF TERMS AND CONDITIONS
  1902. */
  1903. /*! *****************************************************************************
  1904. Copyright (C) Microsoft. All rights reserved.
  1905. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  1906. this file except in compliance with the License. You may obtain a copy of the
  1907. License at http://www.apache.org/licenses/LICENSE-2.0
  1908. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1909. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  1910. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  1911. MERCHANTABLITY OR NON-INFRINGEMENT.
  1912. See the Apache Version 2.0 License for specific language governing permissions
  1913. and limitations under the License.
  1914. ***************************************************************************** */
  1915. "use strict";
  1916. var Reflect;
  1917. (function (Reflect) {
  1918. // Load global or shim versions of Map, Set, and WeakMap
  1919. var functionPrototype = Object.getPrototypeOf(Function);
  1920. var _Map = typeof Map === "function" ? Map : CreateMapPolyfill();
  1921. var _Set = typeof Set === "function" ? Set : CreateSetPolyfill();
  1922. var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
  1923. // [[Metadata]] internal slot
  1924. var __Metadata__ = new _WeakMap();
  1925. /**
  1926. * Applies a set of decorators to a property of a target object.
  1927. * @param decorators An array of decorators.
  1928. * @param target The target object.
  1929. * @param targetKey (Optional) The property key to decorate.
  1930. * @param targetDescriptor (Optional) The property descriptor for the target key
  1931. * @remarks Decorators are applied in reverse order.
  1932. * @example
  1933. *
  1934. * class C {
  1935. * // property declarations are not part of ES6, though they are valid in TypeScript:
  1936. * // static staticProperty;
  1937. * // property;
  1938. *
  1939. * constructor(p) { }
  1940. * static staticMethod(p) { }
  1941. * method(p) { }
  1942. * }
  1943. *
  1944. * // constructor
  1945. * C = Reflect.decorate(decoratorsArray, C);
  1946. *
  1947. * // property (on constructor)
  1948. * Reflect.decorate(decoratorsArray, C, "staticProperty");
  1949. *
  1950. * // property (on prototype)
  1951. * Reflect.decorate(decoratorsArray, C.prototype, "property");
  1952. *
  1953. * // method (on constructor)
  1954. * Object.defineProperty(C, "staticMethod",
  1955. * Reflect.decorate(decoratorsArray, C, "staticMethod",
  1956. * Object.getOwnPropertyDescriptor(C, "staticMethod")));
  1957. *
  1958. * // method (on prototype)
  1959. * Object.defineProperty(C.prototype, "method",
  1960. * Reflect.decorate(decoratorsArray, C.prototype, "method",
  1961. * Object.getOwnPropertyDescriptor(C.prototype, "method")));
  1962. *
  1963. */
  1964. function decorate(decorators, target, targetKey, targetDescriptor) {
  1965. if (!IsUndefined(targetDescriptor)) {
  1966. if (!IsArray(decorators)) {
  1967. throw new TypeError();
  1968. }
  1969. else if (!IsObject(target)) {
  1970. throw new TypeError();
  1971. }
  1972. else if (IsUndefined(targetKey)) {
  1973. throw new TypeError();
  1974. }
  1975. else if (!IsObject(targetDescriptor)) {
  1976. throw new TypeError();
  1977. }
  1978. targetKey = ToPropertyKey(targetKey);
  1979. return DecoratePropertyWithDescriptor(decorators, target, targetKey, targetDescriptor);
  1980. }
  1981. else if (!IsUndefined(targetKey)) {
  1982. if (!IsArray(decorators)) {
  1983. throw new TypeError();
  1984. }
  1985. else if (!IsObject(target)) {
  1986. throw new TypeError();
  1987. }
  1988. targetKey = ToPropertyKey(targetKey);
  1989. return DecoratePropertyWithoutDescriptor(decorators, target, targetKey);
  1990. }
  1991. else {
  1992. if (!IsArray(decorators)) {
  1993. throw new TypeError();
  1994. }
  1995. else if (!IsConstructor(target)) {
  1996. throw new TypeError();
  1997. }
  1998. return DecorateConstructor(decorators, target);
  1999. }
  2000. }
  2001. Reflect.decorate = decorate;
  2002. /**
  2003. * A default metadata decorator factory that can be used on a class, class member, or parameter.
  2004. * @param metadataKey The key for the metadata entry.
  2005. * @param metadataValue The value for the metadata entry.
  2006. * @returns A decorator function.
  2007. * @remarks
  2008. * If `metadataKey` is already defined for the target and target key, the
  2009. * metadataValue for that key will be overwritten.
  2010. * @example
  2011. *
  2012. * // constructor
  2013. * @Reflect.metadata(key, value)
  2014. * class C {
  2015. * }
  2016. *
  2017. * // property (on constructor, TypeScript only)
  2018. * class C {
  2019. * @Reflect.metadata(key, value)
  2020. * static staticProperty;
  2021. * }
  2022. *
  2023. * // property (on prototype, TypeScript only)
  2024. * class C {
  2025. * @Reflect.metadata(key, value)
  2026. * property;
  2027. * }
  2028. *
  2029. * // method (on constructor)
  2030. * class C {
  2031. * @Reflect.metadata(key, value)
  2032. * static staticMethod() { }
  2033. * }
  2034. *
  2035. * // method (on prototype)
  2036. * class C {
  2037. * @Reflect.metadata(key, value)
  2038. * method() { }
  2039. * }
  2040. *
  2041. */
  2042. function metadata(metadataKey, metadataValue) {
  2043. function decorator(target, targetKey) {
  2044. if (!IsUndefined(targetKey)) {
  2045. if (!IsObject(target)) {
  2046. throw new TypeError();
  2047. }
  2048. targetKey = ToPropertyKey(targetKey);
  2049. OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
  2050. }
  2051. else {
  2052. if (!IsConstructor(target)) {
  2053. throw new TypeError();
  2054. }
  2055. OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, undefined);
  2056. }
  2057. }
  2058. return decorator;
  2059. }
  2060. Reflect.metadata = metadata;
  2061. /**
  2062. * Define a unique metadata entry on the target.
  2063. * @param metadataKey A key used to store and retrieve metadata.
  2064. * @param metadataValue A value that contains attached metadata.
  2065. * @param target The target object on which to define metadata.
  2066. * @param targetKey (Optional) The property key for the target.
  2067. * @example
  2068. *
  2069. * class C {
  2070. * // property declarations are not part of ES6, though they are valid in TypeScript:
  2071. * // static staticProperty;
  2072. * // property;
  2073. *
  2074. * constructor(p) { }
  2075. * static staticMethod(p) { }
  2076. * method(p) { }
  2077. * }
  2078. *
  2079. * // constructor
  2080. * Reflect.defineMetadata("custom:annotation", options, C);
  2081. *
  2082. * // property (on constructor)
  2083. * Reflect.defineMetadata("custom:annotation", options, C, "staticProperty");
  2084. *
  2085. * // property (on prototype)
  2086. * Reflect.defineMetadata("custom:annotation", options, C.prototype, "property");
  2087. *
  2088. * // method (on constructor)
  2089. * Reflect.defineMetadata("custom:annotation", options, C, "staticMethod");
  2090. *
  2091. * // method (on prototype)
  2092. * Reflect.defineMetadata("custom:annotation", options, C.prototype, "method");
  2093. *
  2094. * // decorator factory as metadata-producing annotation.
  2095. * function MyAnnotation(options): Decorator {
  2096. * return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key);
  2097. * }
  2098. *
  2099. */
  2100. function defineMetadata(metadataKey, metadataValue, target, targetKey) {
  2101. if (!IsObject(target)) {
  2102. throw new TypeError();
  2103. }
  2104. else if (!IsUndefined(targetKey)) {
  2105. targetKey = ToPropertyKey(targetKey);
  2106. }
  2107. return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
  2108. }
  2109. Reflect.defineMetadata = defineMetadata;
  2110. /**
  2111. * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
  2112. * @param metadataKey A key used to store and retrieve metadata.
  2113. * @param target The target object on which the metadata is defined.
  2114. * @param targetKey (Optional) The property key for the target.
  2115. * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
  2116. * @example
  2117. *
  2118. * class C {
  2119. * // property declarations are not part of ES6, though they are valid in TypeScript:
  2120. * // static staticProperty;
  2121. * // property;
  2122. *
  2123. * constructor(p) { }
  2124. * static staticMethod(p) { }
  2125. * method(p) { }
  2126. * }
  2127. *
  2128. * // constructor
  2129. * result = Reflect.hasMetadata("custom:annotation", C);
  2130. *
  2131. * // property (on constructor)
  2132. * result = Reflect.hasMetadata("custom:annotation", C, "staticProperty");
  2133. *
  2134. * // property (on prototype)
  2135. * result = Reflect.hasMetadata("custom:annotation", C.prototype, "property");
  2136. *
  2137. * // method (on constructor)
  2138. * result = Reflect.hasMetadata("custom:annotation", C, "staticMethod");
  2139. *
  2140. * // method (on prototype)
  2141. * result = Reflect.hasMetadata("custom:annotation", C.prototype, "method");
  2142. *
  2143. */
  2144. function hasMetadata(metadataKey, target, targetKey) {
  2145. if (!IsObject(target)) {
  2146. throw new TypeError();
  2147. }
  2148. else if (!IsUndefined(targetKey)) {
  2149. targetKey = ToPropertyKey(targetKey);
  2150. }
  2151. return OrdinaryHasMetadata(metadataKey, target, targetKey);
  2152. }
  2153. Reflect.hasMetadata = hasMetadata;
  2154. /**
  2155. * Gets a value indicating whether the target object has the provided metadata key defined.
  2156. * @param metadataKey A key used to store and retrieve metadata.
  2157. * @param target The target object on which the metadata is defined.
  2158. * @param targetKey (Optional) The property key for the target.
  2159. * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
  2160. * @example
  2161. *
  2162. * class C {
  2163. * // property declarations are not part of ES6, though they are valid in TypeScript:
  2164. * // static staticProperty;
  2165. * // property;
  2166. *
  2167. * constructor(p) { }
  2168. * static staticMethod(p) { }
  2169. * method(p) { }
  2170. * }
  2171. *
  2172. * // constructor
  2173. * result = Reflect.hasOwnMetadata("custom:annotation", C);
  2174. *
  2175. * // property (on constructor)
  2176. * result = Reflect.hasOwnMetadata("custom:annotation", C, "staticProperty");
  2177. *
  2178. * // property (on prototype)
  2179. * result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "property");
  2180. *
  2181. * // method (on constructor)
  2182. * result = Reflect.hasOwnMetadata("custom:annotation", C, "staticMethod");
  2183. *
  2184. * // method (on prototype)
  2185. * result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "method");
  2186. *
  2187. */
  2188. function hasOwnMetadata(metadataKey, target, targetKey) {
  2189. if (!IsObject(target)) {
  2190. throw new TypeError();
  2191. }
  2192. else if (!IsUndefined(targetKey)) {
  2193. targetKey = ToPropertyKey(targetKey);
  2194. }
  2195. return OrdinaryHasOwnMetadata(metadataKey, target, targetKey);
  2196. }
  2197. Reflect.hasOwnMetadata = hasOwnMetadata;
  2198. /**
  2199. * Gets the metadata value for the provided metadata key on the target object or its prototype chain.
  2200. * @param metadataKey A key used to store and retrieve metadata.
  2201. * @param target The target object on which the metadata is defined.
  2202. * @param targetKey (Optional) The property key for the target.
  2203. * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
  2204. * @example
  2205. *
  2206. * class C {
  2207. * // property declarations are not part of ES6, though they are valid in TypeScript:
  2208. * // static staticProperty;
  2209. * // property;
  2210. *
  2211. * constructor(p) { }
  2212. * static staticMethod(p) { }
  2213. * method(p) { }
  2214. * }
  2215. *
  2216. * // constructor
  2217. * result = Reflect.getMetadata("custom:annotation", C);
  2218. *
  2219. * // property (on constructor)
  2220. * result = Reflect.getMetadata("custom:annotation", C, "staticProperty");
  2221. *
  2222. * // property (on prototype)
  2223. * result = Reflect.getMetadata("custom:annotation", C.prototype, "property");
  2224. *
  2225. * // method (on constructor)
  2226. * result = Reflect.getMetadata("custom:annotation", C, "staticMethod");
  2227. *
  2228. * // method (on prototype)
  2229. * result = Reflect.getMetadata("custom:annotation", C.prototype, "method");
  2230. *
  2231. */
  2232. function getMetadata(metadataKey, target, targetKey) {
  2233. if (!IsObject(target)) {
  2234. throw new TypeError();
  2235. }
  2236. else if (!IsUndefined(targetKey)) {
  2237. targetKey = ToPropertyKey(targetKey);
  2238. }
  2239. return OrdinaryGetMetadata(metadataKey, target, targetKey);
  2240. }
  2241. Reflect.getMetadata = getMetadata;
  2242. /**
  2243. * Gets the metadata value for the provided metadata key on the target object.
  2244. * @param metadataKey A key used to store and retrieve metadata.
  2245. * @param target The target object on which the metadata is defined.
  2246. * @param targetKey (Optional) The property key for the target.
  2247. * @returns The metadata value for the metadata key if found; otherwise, `undefined`.
  2248. * @example
  2249. *
  2250. * class C {
  2251. * // property declarations are not part of ES6, though they are valid in TypeScript:
  2252. * // static staticProperty;
  2253. * // property;
  2254. *
  2255. * constructor(p) { }
  2256. * static staticMethod(p) { }
  2257. * method(p) { }
  2258. * }
  2259. *
  2260. * // constructor
  2261. * result = Reflect.getOwnMetadata("custom:annotation", C);
  2262. *
  2263. * // property (on constructor)
  2264. * result = Reflect.getOwnMetadata("custom:annotation", C, "staticProperty");
  2265. *
  2266. * // property (on prototype)
  2267. * result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "property");
  2268. *
  2269. * // method (on constructor)
  2270. * result = Reflect.getOwnMetadata("custom:annotation", C, "staticMethod");
  2271. *
  2272. * // method (on prototype)
  2273. * result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "method");
  2274. *
  2275. */
  2276. function getOwnMetadata(metadataKey, target, targetKey) {
  2277. if (!IsObject(target)) {
  2278. throw new TypeError();
  2279. }
  2280. else if (!IsUndefined(targetKey)) {
  2281. targetKey = ToPropertyKey(targetKey);
  2282. }
  2283. return OrdinaryGetOwnMetadata(metadataKey, target, targetKey);
  2284. }
  2285. Reflect.getOwnMetadata = getOwnMetadata;
  2286. /**
  2287. * Gets the metadata keys defined on the target object or its prototype chain.
  2288. * @param target The target object on which the metadata is defined.
  2289. * @param targetKey (Optional) The property key for the target.
  2290. * @returns An array of unique metadata keys.
  2291. * @example
  2292. *
  2293. * class C {
  2294. * // property declarations are not part of ES6, though they are valid in TypeScript:
  2295. * // static staticProperty;
  2296. * // property;
  2297. *
  2298. * constructor(p) { }
  2299. * static staticMethod(p) { }
  2300. * method(p) { }
  2301. * }
  2302. *
  2303. * // constructor
  2304. * result = Reflect.getMetadataKeys(C);
  2305. *
  2306. * // property (on constructor)
  2307. * result = Reflect.getMetadataKeys(C, "staticProperty");
  2308. *
  2309. * // property (on prototype)
  2310. * result = Reflect.getMetadataKeys(C.prototype, "property");
  2311. *
  2312. * // method (on constructor)
  2313. * result = Reflect.getMetadataKeys(C, "staticMethod");
  2314. *
  2315. * // method (on prototype)
  2316. * result = Reflect.getMetadataKeys(C.prototype, "method");
  2317. *
  2318. */
  2319. function getMetadataKeys(target, targetKey) {
  2320. if (!IsObject(target)) {
  2321. throw new TypeError();
  2322. }
  2323. else if (!IsUndefined(targetKey)) {
  2324. targetKey = ToPropertyKey(targetKey);
  2325. }
  2326. return OrdinaryMetadataKeys(target, targetKey);
  2327. }
  2328. Reflect.getMetadataKeys = getMetadataKeys;
  2329. /**
  2330. * Gets the unique metadata keys defined on the target object.
  2331. * @param target The target object on which the metadata is defined.
  2332. * @param targetKey (Optional) The property key for the target.
  2333. * @returns An array of unique metadata keys.
  2334. * @example
  2335. *
  2336. * class C {
  2337. * // property declarations are not part of ES6, though they are valid in TypeScript:
  2338. * // static staticProperty;
  2339. * // property;
  2340. *
  2341. * constructor(p) { }
  2342. * static staticMethod(p) { }
  2343. * method(p) { }
  2344. * }
  2345. *
  2346. * // constructor
  2347. * result = Reflect.getOwnMetadataKeys(C);
  2348. *
  2349. * // property (on constructor)
  2350. * result = Reflect.getOwnMetadataKeys(C, "staticProperty");
  2351. *
  2352. * // property (on prototype)
  2353. * result = Reflect.getOwnMetadataKeys(C.prototype, "property");
  2354. *
  2355. * // method (on constructor)
  2356. * result = Reflect.getOwnMetadataKeys(C, "staticMethod");
  2357. *
  2358. * // method (on prototype)
  2359. * result = Reflect.getOwnMetadataKeys(C.prototype, "method");
  2360. *
  2361. */
  2362. function getOwnMetadataKeys(target, targetKey) {
  2363. if (!IsObject(target)) {
  2364. throw new TypeError();
  2365. }
  2366. else if (!IsUndefined(targetKey)) {
  2367. targetKey = ToPropertyKey(targetKey);
  2368. }
  2369. return OrdinaryOwnMetadataKeys(target, targetKey);
  2370. }
  2371. Reflect.getOwnMetadataKeys = getOwnMetadataKeys;
  2372. /**
  2373. * Deletes the metadata entry from the target object with the provided key.
  2374. * @param metadataKey A key used to store and retrieve metadata.
  2375. * @param target The target object on which the metadata is defined.
  2376. * @param targetKey (Optional) The property key for the target.
  2377. * @returns `true` if the metadata entry was found and deleted; otherwise, false.
  2378. * @example
  2379. *
  2380. * class C {
  2381. * // property declarations are not part of ES6, though they are valid in TypeScript:
  2382. * // static staticProperty;
  2383. * // property;
  2384. *
  2385. * constructor(p) { }
  2386. * static staticMethod(p) { }
  2387. * method(p) { }
  2388. * }
  2389. *
  2390. * // constructor
  2391. * result = Reflect.deleteMetadata("custom:annotation", C);
  2392. *
  2393. * // property (on constructor)
  2394. * result = Reflect.deleteMetadata("custom:annotation", C, "staticProperty");
  2395. *
  2396. * // property (on prototype)
  2397. * result = Reflect.deleteMetadata("custom:annotation", C.prototype, "property");
  2398. *
  2399. * // method (on constructor)
  2400. * result = Reflect.deleteMetadata("custom:annotation", C, "staticMethod");
  2401. *
  2402. * // method (on prototype)
  2403. * result = Reflect.deleteMetadata("custom:annotation", C.prototype, "method");
  2404. *
  2405. */
  2406. function deleteMetadata(metadataKey, target, targetKey) {
  2407. if (!IsObject(target)) {
  2408. throw new TypeError();
  2409. }
  2410. else if (!IsUndefined(targetKey)) {
  2411. targetKey = ToPropertyKey(targetKey);
  2412. }
  2413. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#deletemetadata-metadatakey-p-
  2414. var metadataMap = GetOrCreateMetadataMap(target, targetKey, false);
  2415. if (IsUndefined(metadataMap)) {
  2416. return false;
  2417. }
  2418. if (!metadataMap.delete(metadataKey)) {
  2419. return false;
  2420. }
  2421. if (metadataMap.size > 0) {
  2422. return true;
  2423. }
  2424. var targetMetadata = __Metadata__.get(target);
  2425. targetMetadata.delete(targetKey);
  2426. if (targetMetadata.size > 0) {
  2427. return true;
  2428. }
  2429. __Metadata__.delete(target);
  2430. return true;
  2431. }
  2432. Reflect.deleteMetadata = deleteMetadata;
  2433. function DecorateConstructor(decorators, target) {
  2434. for (var i = decorators.length - 1; i >= 0; --i) {
  2435. var decorator = decorators[i];
  2436. var decorated = decorator(target);
  2437. if (!IsUndefined(decorated)) {
  2438. if (!IsConstructor(decorated)) {
  2439. throw new TypeError();
  2440. }
  2441. target = decorated;
  2442. }
  2443. }
  2444. return target;
  2445. }
  2446. function DecoratePropertyWithDescriptor(decorators, target, propertyKey, descriptor) {
  2447. for (var i = decorators.length - 1; i >= 0; --i) {
  2448. var decorator = decorators[i];
  2449. var decorated = decorator(target, propertyKey, descriptor);
  2450. if (!IsUndefined(decorated)) {
  2451. if (!IsObject(decorated)) {
  2452. throw new TypeError();
  2453. }
  2454. descriptor = decorated;
  2455. }
  2456. }
  2457. return descriptor;
  2458. }
  2459. function DecoratePropertyWithoutDescriptor(decorators, target, propertyKey) {
  2460. for (var i = decorators.length - 1; i >= 0; --i) {
  2461. var decorator = decorators[i];
  2462. decorator(target, propertyKey);
  2463. }
  2464. }
  2465. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#getorcreatemetadatamap--o-p-create-
  2466. function GetOrCreateMetadataMap(target, targetKey, create) {
  2467. var targetMetadata = __Metadata__.get(target);
  2468. if (!targetMetadata) {
  2469. if (!create) {
  2470. return undefined;
  2471. }
  2472. targetMetadata = new _Map();
  2473. __Metadata__.set(target, targetMetadata);
  2474. }
  2475. var keyMetadata = targetMetadata.get(targetKey);
  2476. if (!keyMetadata) {
  2477. if (!create) {
  2478. return undefined;
  2479. }
  2480. keyMetadata = new _Map();
  2481. targetMetadata.set(targetKey, keyMetadata);
  2482. }
  2483. return keyMetadata;
  2484. }
  2485. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasmetadata--metadatakey-o-p-
  2486. function OrdinaryHasMetadata(MetadataKey, O, P) {
  2487. var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
  2488. if (hasOwn) {
  2489. return true;
  2490. }
  2491. var parent = GetPrototypeOf(O);
  2492. if (parent !== null) {
  2493. return OrdinaryHasMetadata(MetadataKey, parent, P);
  2494. }
  2495. return false;
  2496. }
  2497. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasownmetadata--metadatakey-o-p-
  2498. function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
  2499. var metadataMap = GetOrCreateMetadataMap(O, P, false);
  2500. if (metadataMap === undefined) {
  2501. return false;
  2502. }
  2503. return Boolean(metadataMap.has(MetadataKey));
  2504. }
  2505. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetmetadata--metadatakey-o-p-
  2506. function OrdinaryGetMetadata(MetadataKey, O, P) {
  2507. var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
  2508. if (hasOwn) {
  2509. return OrdinaryGetOwnMetadata(MetadataKey, O, P);
  2510. }
  2511. var parent = GetPrototypeOf(O);
  2512. if (parent !== null) {
  2513. return OrdinaryGetMetadata(MetadataKey, parent, P);
  2514. }
  2515. return undefined;
  2516. }
  2517. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetownmetadata--metadatakey-o-p-
  2518. function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
  2519. var metadataMap = GetOrCreateMetadataMap(O, P, false);
  2520. if (metadataMap === undefined) {
  2521. return undefined;
  2522. }
  2523. return metadataMap.get(MetadataKey);
  2524. }
  2525. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p-
  2526. function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
  2527. var metadataMap = GetOrCreateMetadataMap(O, P, true);
  2528. metadataMap.set(MetadataKey, MetadataValue);
  2529. }
  2530. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarymetadatakeys--o-p-
  2531. function OrdinaryMetadataKeys(O, P) {
  2532. var ownKeys = OrdinaryOwnMetadataKeys(O, P);
  2533. var parent = GetPrototypeOf(O);
  2534. if (parent === null) {
  2535. return ownKeys;
  2536. }
  2537. var parentKeys = OrdinaryMetadataKeys(parent, P);
  2538. if (parentKeys.length <= 0) {
  2539. return ownKeys;
  2540. }
  2541. if (ownKeys.length <= 0) {
  2542. return parentKeys;
  2543. }
  2544. var set = new _Set();
  2545. var keys = [];
  2546. for (var _i = 0; _i < ownKeys.length; _i++) {
  2547. var key = ownKeys[_i];
  2548. var hasKey = set.has(key);
  2549. if (!hasKey) {
  2550. set.add(key);
  2551. keys.push(key);
  2552. }
  2553. }
  2554. for (var _a = 0; _a < parentKeys.length; _a++) {
  2555. var key = parentKeys[_a];
  2556. var hasKey = set.has(key);
  2557. if (!hasKey) {
  2558. set.add(key);
  2559. keys.push(key);
  2560. }
  2561. }
  2562. return keys;
  2563. }
  2564. // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryownmetadatakeys--o-p-
  2565. function OrdinaryOwnMetadataKeys(target, targetKey) {
  2566. var metadataMap = GetOrCreateMetadataMap(target, targetKey, false);
  2567. var keys = [];
  2568. if (metadataMap) {
  2569. metadataMap.forEach(function (_, key) { return keys.push(key); });
  2570. }
  2571. return keys;
  2572. }
  2573. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-undefined-type
  2574. function IsUndefined(x) {
  2575. return x === undefined;
  2576. }
  2577. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
  2578. function IsArray(x) {
  2579. return Array.isArray(x);
  2580. }
  2581. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-type
  2582. function IsObject(x) {
  2583. return typeof x === "object" ? x !== null : typeof x === "function";
  2584. }
  2585. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
  2586. function IsConstructor(x) {
  2587. return typeof x === "function";
  2588. }
  2589. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-symbol-type
  2590. function IsSymbol(x) {
  2591. return typeof x === "symbol";
  2592. }
  2593. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
  2594. function ToPropertyKey(value) {
  2595. if (IsSymbol(value)) {
  2596. return value;
  2597. }
  2598. return String(value);
  2599. }
  2600. function GetPrototypeOf(O) {
  2601. var proto = Object.getPrototypeOf(O);
  2602. if (typeof O !== "function" || O === functionPrototype) {
  2603. return proto;
  2604. }
  2605. // TypeScript doesn't set __proto__ in ES5, as it's non-standard.
  2606. // Try to determine the superclass constructor. Compatible implementations
  2607. // must either set __proto__ on a subclass constructor to the superclass constructor,
  2608. // or ensure each class has a valid `constructor` property on its prototype that
  2609. // points back to the constructor.
  2610. // If this is not the same as Function.[[Prototype]], then this is definately inherited.
  2611. // This is the case when in ES6 or when using __proto__ in a compatible browser.
  2612. if (proto !== functionPrototype) {
  2613. return proto;
  2614. }
  2615. // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
  2616. var prototype = O.prototype;
  2617. var prototypeProto = Object.getPrototypeOf(prototype);
  2618. if (prototypeProto == null || prototypeProto === Object.prototype) {
  2619. return proto;
  2620. }
  2621. // if the constructor was not a function, then we cannot determine the heritage.
  2622. var constructor = prototypeProto.constructor;
  2623. if (typeof constructor !== "function") {
  2624. return proto;
  2625. }
  2626. // if we have some kind of self-reference, then we cannot determine the heritage.
  2627. if (constructor === O) {
  2628. return proto;
  2629. }
  2630. // we have a pretty good guess at the heritage.
  2631. return constructor;
  2632. }
  2633. // naive Map shim
  2634. function CreateMapPolyfill() {
  2635. var cacheSentinel = {};
  2636. function Map() {
  2637. this._keys = [];
  2638. this._values = [];
  2639. this._cache = cacheSentinel;
  2640. }
  2641. Map.prototype = {
  2642. get size() {
  2643. return this._keys.length;
  2644. },
  2645. has: function (key) {
  2646. if (key === this._cache) {
  2647. return true;
  2648. }
  2649. if (this._find(key) >= 0) {
  2650. this._cache = key;
  2651. return true;
  2652. }
  2653. return false;
  2654. },
  2655. get: function (key) {
  2656. var index = this._find(key);
  2657. if (index >= 0) {
  2658. this._cache = key;
  2659. return this._values[index];
  2660. }
  2661. return undefined;
  2662. },
  2663. set: function (key, value) {
  2664. this.delete(key);
  2665. this._keys.push(key);
  2666. this._values.push(value);
  2667. this._cache = key;
  2668. return this;
  2669. },
  2670. delete: function (key) {
  2671. var index = this._find(key);
  2672. if (index >= 0) {
  2673. this._keys.splice(index, 1);
  2674. this._values.splice(index, 1);
  2675. this._cache = cacheSentinel;
  2676. return true;
  2677. }
  2678. return false;
  2679. },
  2680. clear: function () {
  2681. this._keys.length = 0;
  2682. this._values.length = 0;
  2683. this._cache = cacheSentinel;
  2684. },
  2685. forEach: function (callback, thisArg) {
  2686. var size = this.size;
  2687. for (var i = 0; i < size; ++i) {
  2688. var key = this._keys[i];
  2689. var value = this._values[i];
  2690. this._cache = key;
  2691. callback.call(this, value, key, this);
  2692. }
  2693. },
  2694. _find: function (key) {
  2695. var keys = this._keys;
  2696. var size = keys.length;
  2697. for (var i = 0; i < size; ++i) {
  2698. if (keys[i] === key) {
  2699. return i;
  2700. }
  2701. }
  2702. return -1;
  2703. }
  2704. };
  2705. return Map;
  2706. }
  2707. // naive Set shim
  2708. function CreateSetPolyfill() {
  2709. var cacheSentinel = {};
  2710. function Set() {
  2711. this._map = new _Map();
  2712. }
  2713. Set.prototype = {
  2714. get size() {
  2715. return this._map.length;
  2716. },
  2717. has: function (value) {
  2718. return this._map.has(value);
  2719. },
  2720. add: function (value) {
  2721. this._map.set(value, value);
  2722. return this;
  2723. },
  2724. delete: function (value) {
  2725. return this._map.delete(value);
  2726. },
  2727. clear: function () {
  2728. this._map.clear();
  2729. },
  2730. forEach: function (callback, thisArg) {
  2731. this._map.forEach(callback, thisArg);
  2732. }
  2733. };
  2734. return Set;
  2735. }
  2736. // naive WeakMap shim
  2737. function CreateWeakMapPolyfill() {
  2738. var UUID_SIZE = 16;
  2739. var isNode = typeof global !== "undefined" && Object.prototype.toString.call(global.process) === '[object process]';
  2740. var nodeCrypto = isNode && require("crypto");
  2741. var hasOwn = Object.prototype.hasOwnProperty;
  2742. var keys = {};
  2743. var rootKey = CreateUniqueKey();
  2744. function WeakMap() {
  2745. this._key = CreateUniqueKey();
  2746. }
  2747. WeakMap.prototype = {
  2748. has: function (target) {
  2749. var table = GetOrCreateWeakMapTable(target, false);
  2750. if (table) {
  2751. return this._key in table;
  2752. }
  2753. return false;
  2754. },
  2755. get: function (target) {
  2756. var table = GetOrCreateWeakMapTable(target, false);
  2757. if (table) {
  2758. return table[this._key];
  2759. }
  2760. return undefined;
  2761. },
  2762. set: function (target, value) {
  2763. var table = GetOrCreateWeakMapTable(target, true);
  2764. table[this._key] = value;
  2765. return this;
  2766. },
  2767. delete: function (target) {
  2768. var table = GetOrCreateWeakMapTable(target, false);
  2769. if (table && this._key in table) {
  2770. return delete table[this._key];
  2771. }
  2772. return false;
  2773. },
  2774. clear: function () {
  2775. // NOTE: not a real clear, just makes the previous data unreachable
  2776. this._key = CreateUniqueKey();
  2777. }
  2778. };
  2779. function FillRandomBytes(buffer, size) {
  2780. for (var i = 0; i < size; ++i) {
  2781. buffer[i] = Math.random() * 255 | 0;
  2782. }
  2783. }
  2784. function GenRandomBytes(size) {
  2785. if (nodeCrypto) {
  2786. var data = nodeCrypto.randomBytes(size);
  2787. return data;
  2788. }
  2789. else if (typeof Uint8Array === "function") {
  2790. var data = new Uint8Array(size);
  2791. if (typeof crypto !== "undefined") {
  2792. crypto.getRandomValues(data);
  2793. }
  2794. else if (typeof msCrypto !== "undefined") {
  2795. msCrypto.getRandomValues(data);
  2796. }
  2797. else {
  2798. FillRandomBytes(data, size);
  2799. }
  2800. return data;
  2801. }
  2802. else {
  2803. var data = new Array(size);
  2804. FillRandomBytes(data, size);
  2805. return data;
  2806. }
  2807. }
  2808. function CreateUUID() {
  2809. var data = GenRandomBytes(UUID_SIZE);
  2810. // mark as random - RFC 4122 § 4.4
  2811. data[6] = data[6] & 0x4f | 0x40;
  2812. data[8] = data[8] & 0xbf | 0x80;
  2813. var result = "";
  2814. for (var offset = 0; offset < UUID_SIZE; ++offset) {
  2815. var byte = data[offset];
  2816. if (offset === 4 || offset === 6 || offset === 8) {
  2817. result += "-";
  2818. }
  2819. if (byte < 16) {
  2820. result += "0";
  2821. }
  2822. result += byte.toString(16).toLowerCase();
  2823. }
  2824. return result;
  2825. }
  2826. function CreateUniqueKey() {
  2827. var key;
  2828. do {
  2829. key = "@@WeakMap@@" + CreateUUID();
  2830. } while (hasOwn.call(keys, key));
  2831. keys[key] = true;
  2832. return key;
  2833. }
  2834. function GetOrCreateWeakMapTable(target, create) {
  2835. if (!hasOwn.call(target, rootKey)) {
  2836. if (!create) {
  2837. return undefined;
  2838. }
  2839. Object.defineProperty(target, rootKey, { value: Object.create(null) });
  2840. }
  2841. return target[rootKey];
  2842. }
  2843. return WeakMap;
  2844. }
  2845. // hook global Reflect
  2846. (function (__global) {
  2847. if (typeof __global.Reflect !== "undefined") {
  2848. if (__global.Reflect !== Reflect) {
  2849. for (var p in Reflect) {
  2850. __global.Reflect[p] = Reflect[p];
  2851. }
  2852. }
  2853. }
  2854. else {
  2855. __global.Reflect = Reflect;
  2856. }
  2857. })(typeof window !== "undefined" ? window :
  2858. typeof WorkerGlobalScope !== "undefined" ? self :
  2859. typeof global !== "undefined" ? global :
  2860. Function("return this;")());
  2861. })(Reflect || (Reflect = {}));
  2862. //# sourceMappingURLDisabled=Reflect.js.map