system-production.src.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981
  1. /*
  2. * SystemJS v0.21.6 Production
  3. */
  4. (function () {
  5. 'use strict';
  6. /*
  7. * Environment
  8. */
  9. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
  10. var isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
  11. var isWindows = typeof process !== 'undefined' && typeof process.platform === 'string' && process.platform.match(/^win/);
  12. var envGlobal = typeof self !== 'undefined' ? self : global;
  13. /*
  14. * Simple Symbol() shim
  15. */
  16. var hasSymbol = typeof Symbol !== 'undefined';
  17. function createSymbol (name) {
  18. return hasSymbol ? Symbol() : '@@' + name;
  19. }
  20. var toStringTag = hasSymbol && Symbol.toStringTag;
  21. /*
  22. * Environment baseURI
  23. */
  24. var baseURI;
  25. // environent baseURI detection
  26. if (typeof document != 'undefined' && document.getElementsByTagName) {
  27. baseURI = document.baseURI;
  28. if (!baseURI) {
  29. var bases = document.getElementsByTagName('base');
  30. baseURI = bases[0] && bases[0].href || window.location.href;
  31. }
  32. }
  33. else if (typeof location != 'undefined') {
  34. baseURI = location.href;
  35. }
  36. // sanitize out the hash and querystring
  37. if (baseURI) {
  38. baseURI = baseURI.split('#')[0].split('?')[0];
  39. var slashIndex = baseURI.lastIndexOf('/');
  40. if (slashIndex !== -1)
  41. baseURI = baseURI.substr(0, slashIndex + 1);
  42. }
  43. else if (typeof process !== 'undefined' && process.cwd) {
  44. baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd();
  45. if (isWindows)
  46. baseURI = baseURI.replace(/\\/g, '/');
  47. }
  48. else {
  49. throw new TypeError('No environment baseURI');
  50. }
  51. // ensure baseURI has trailing "/"
  52. if (baseURI[baseURI.length - 1] !== '/')
  53. baseURI += '/';
  54. /*
  55. * LoaderError with chaining for loader stacks
  56. */
  57. var errArgs = new Error(0, '_').fileName == '_';
  58. function LoaderError__Check_error_message_for_loader_stack (childErr, newMessage) {
  59. // Convert file:/// URLs to paths in Node
  60. if (!isBrowser)
  61. newMessage = newMessage.replace(isWindows ? /file:\/\/\//g : /file:\/\//g, '');
  62. var message = (childErr.message || childErr) + '\n ' + newMessage;
  63. var err;
  64. if (errArgs && childErr.fileName)
  65. err = new Error(message, childErr.fileName, childErr.lineNumber);
  66. else
  67. err = new Error(message);
  68. var stack = childErr.originalErr ? childErr.originalErr.stack : childErr.stack;
  69. if (isNode)
  70. // node doesn't show the message otherwise
  71. err.stack = message + '\n ' + stack;
  72. else
  73. err.stack = stack;
  74. err.originalErr = childErr.originalErr || childErr;
  75. return err;
  76. }
  77. /*
  78. * Optimized URL normalization assuming a syntax-valid URL parent
  79. */
  80. function throwResolveError (relUrl, parentUrl) {
  81. throw new RangeError('Unable to resolve "' + relUrl + '" to ' + parentUrl);
  82. }
  83. var backslashRegEx = /\\/g;
  84. function resolveIfNotPlain (relUrl, parentUrl) {
  85. if (relUrl[0] === ' ' || relUrl[relUrl.length - 1] === ' ')
  86. relUrl = relUrl.trim();
  87. var parentProtocol = parentUrl && parentUrl.substr(0, parentUrl.indexOf(':') + 1);
  88. var firstChar = relUrl[0];
  89. var secondChar = relUrl[1];
  90. // protocol-relative
  91. if (firstChar === '/' && secondChar === '/') {
  92. if (!parentProtocol)
  93. throwResolveError(relUrl, parentUrl);
  94. if (relUrl.indexOf('\\') !== -1)
  95. relUrl = relUrl.replace(backslashRegEx, '/');
  96. return parentProtocol + relUrl;
  97. }
  98. // relative-url
  99. else if (firstChar === '.' && (secondChar === '/' || secondChar === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
  100. relUrl.length === 1 && (relUrl += '/')) ||
  101. firstChar === '/') {
  102. if (relUrl.indexOf('\\') !== -1)
  103. relUrl = relUrl.replace(backslashRegEx, '/');
  104. var parentIsPlain = !parentProtocol || parentUrl[parentProtocol.length] !== '/';
  105. // read pathname from parent if a URL
  106. // pathname taken to be part after leading "/"
  107. var pathname;
  108. if (parentIsPlain) {
  109. // resolving to a plain parent -> skip standard URL prefix, and treat entire parent as pathname
  110. if (parentUrl === undefined)
  111. throwResolveError(relUrl, parentUrl);
  112. pathname = parentUrl;
  113. }
  114. else if (parentUrl[parentProtocol.length + 1] === '/') {
  115. // resolving to a :// so we need to read out the auth and host
  116. if (parentProtocol !== 'file:') {
  117. pathname = parentUrl.substr(parentProtocol.length + 2);
  118. pathname = pathname.substr(pathname.indexOf('/') + 1);
  119. }
  120. else {
  121. pathname = parentUrl.substr(8);
  122. }
  123. }
  124. else {
  125. // resolving to :/ so pathname is the /... part
  126. pathname = parentUrl.substr(parentProtocol.length + 1);
  127. }
  128. if (firstChar === '/') {
  129. if (parentIsPlain)
  130. throwResolveError(relUrl, parentUrl);
  131. else
  132. return parentUrl.substr(0, parentUrl.length - pathname.length - 1) + relUrl;
  133. }
  134. // join together and split for removal of .. and . segments
  135. // looping the string instead of anything fancy for perf reasons
  136. // '../../../../../z' resolved to 'x/y' is just 'z' regardless of parentIsPlain
  137. var segmented = pathname.substr(0, pathname.lastIndexOf('/') + 1) + relUrl;
  138. var output = [];
  139. var segmentIndex = -1;
  140. for (var i = 0; i < segmented.length; i++) {
  141. // busy reading a segment - only terminate on '/'
  142. if (segmentIndex !== -1) {
  143. if (segmented[i] === '/') {
  144. output.push(segmented.substring(segmentIndex, i + 1));
  145. segmentIndex = -1;
  146. }
  147. continue;
  148. }
  149. // new segment - check if it is relative
  150. if (segmented[i] === '.') {
  151. // ../ segment
  152. if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
  153. output.pop();
  154. i += 2;
  155. }
  156. // ./ segment
  157. else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
  158. i += 1;
  159. }
  160. else {
  161. // the start of a new segment as below
  162. segmentIndex = i;
  163. continue;
  164. }
  165. // this is the plain URI backtracking error (../, package:x -> error)
  166. if (parentIsPlain && output.length === 0)
  167. throwResolveError(relUrl, parentUrl);
  168. continue;
  169. }
  170. // it is the start of a new segment
  171. segmentIndex = i;
  172. }
  173. // finish reading out the last segment
  174. if (segmentIndex !== -1)
  175. output.push(segmented.substr(segmentIndex));
  176. return parentUrl.substr(0, parentUrl.length - pathname.length) + output.join('');
  177. }
  178. // sanitizes and verifies (by returning undefined if not a valid URL-like form)
  179. // Windows filepath compatibility is an added convenience here
  180. var protocolIndex = relUrl.indexOf(':');
  181. if (protocolIndex !== -1) {
  182. if (isNode) {
  183. // C:\x becomes file:///c:/x (we don't support C|\x)
  184. if (relUrl[1] === ':' && relUrl[2] === '\\' && relUrl[0].match(/[a-z]/i))
  185. return 'file:///' + relUrl.replace(backslashRegEx, '/');
  186. }
  187. return relUrl;
  188. }
  189. }
  190. var resolvedPromise = Promise.resolve();
  191. /*
  192. * Simple Array values shim
  193. */
  194. function arrayValues (arr) {
  195. if (arr.values)
  196. return arr.values();
  197. if (typeof Symbol === 'undefined' || !Symbol.iterator)
  198. throw new Error('Symbol.iterator not supported in this browser');
  199. var iterable = {};
  200. iterable[Symbol.iterator] = function () {
  201. var keys = Object.keys(arr);
  202. var keyIndex = 0;
  203. return {
  204. next: function () {
  205. if (keyIndex < keys.length)
  206. return {
  207. value: arr[keys[keyIndex++]],
  208. done: false
  209. };
  210. else
  211. return {
  212. value: undefined,
  213. done: true
  214. };
  215. }
  216. };
  217. };
  218. return iterable;
  219. }
  220. /*
  221. * 3. Reflect.Loader
  222. *
  223. * We skip the entire native internal pipeline, just providing the bare API
  224. */
  225. // 3.1.1
  226. function Loader () {
  227. this.registry = new Registry();
  228. }
  229. // 3.3.1
  230. Loader.prototype.constructor = Loader;
  231. function ensureInstantiated (module) {
  232. if (module === undefined)
  233. return;
  234. if (module instanceof ModuleNamespace === false && module[toStringTag] !== 'module')
  235. throw new TypeError('Module instantiation did not return a valid namespace object.');
  236. return module;
  237. }
  238. // 3.3.2
  239. Loader.prototype.import = function (key, parent) {
  240. if (typeof key !== 'string')
  241. throw new TypeError('Loader import method must be passed a module key string');
  242. // custom resolveInstantiate combined hook for better perf
  243. var loader = this;
  244. return resolvedPromise
  245. .then(function () {
  246. return loader[RESOLVE_INSTANTIATE](key, parent);
  247. })
  248. .then(ensureInstantiated)
  249. //.then(Module.evaluate)
  250. .catch(function (err) {
  251. throw LoaderError__Check_error_message_for_loader_stack(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));
  252. });
  253. };
  254. // 3.3.3
  255. var RESOLVE = Loader.resolve = createSymbol('resolve');
  256. /*
  257. * Combined resolve / instantiate hook
  258. *
  259. * Not in current reduced spec, but necessary to separate RESOLVE from RESOLVE + INSTANTIATE as described
  260. * in the spec notes of this repo to ensure that loader.resolve doesn't instantiate when not wanted.
  261. *
  262. * We implement RESOLVE_INSTANTIATE as a single hook instead of a separate INSTANTIATE in order to avoid
  263. * the need for double registry lookups as a performance optimization.
  264. */
  265. var RESOLVE_INSTANTIATE = Loader.resolveInstantiate = createSymbol('resolveInstantiate');
  266. // default resolveInstantiate is just to call resolve and then get from the registry
  267. // this provides compatibility for the resolveInstantiate optimization
  268. Loader.prototype[RESOLVE_INSTANTIATE] = function (key, parent) {
  269. var loader = this;
  270. return loader.resolve(key, parent)
  271. .then(function (resolved) {
  272. return loader.registry.get(resolved);
  273. });
  274. };
  275. function ensureResolution (resolvedKey) {
  276. if (resolvedKey === undefined)
  277. throw new RangeError('No resolution found.');
  278. return resolvedKey;
  279. }
  280. Loader.prototype.resolve = function (key, parent) {
  281. var loader = this;
  282. return resolvedPromise
  283. .then(function() {
  284. return loader[RESOLVE](key, parent);
  285. })
  286. .then(ensureResolution)
  287. .catch(function (err) {
  288. throw LoaderError__Check_error_message_for_loader_stack(err, 'Resolving ' + key + (parent ? ' to ' + parent : ''));
  289. });
  290. };
  291. // 3.3.4 (import without evaluate)
  292. // this is not documented because the use of deferred evaluation as in Module.evaluate is not
  293. // documented, as it is not considered a stable feature to be encouraged
  294. // Loader.prototype.load may well be deprecated if this stays disabled
  295. /* Loader.prototype.load = function (key, parent) {
  296. return Promise.resolve(this[RESOLVE_INSTANTIATE](key, parent || this.key))
  297. .catch(function (err) {
  298. throw addToError(err, 'Loading ' + key + (parent ? ' from ' + parent : ''));
  299. });
  300. }; */
  301. /*
  302. * 4. Registry
  303. *
  304. * Instead of structuring through a Map, just use a dictionary object
  305. * We throw for construction attempts so this doesn't affect the public API
  306. *
  307. * Registry has been adjusted to use Namespace objects over ModuleStatus objects
  308. * as part of simplifying loader API implementation
  309. */
  310. var iteratorSupport = typeof Symbol !== 'undefined' && Symbol.iterator;
  311. var REGISTRY = createSymbol('registry');
  312. function Registry() {
  313. this[REGISTRY] = {};
  314. }
  315. // 4.4.1
  316. if (iteratorSupport) {
  317. // 4.4.2
  318. Registry.prototype[Symbol.iterator] = function () {
  319. return this.entries()[Symbol.iterator]();
  320. };
  321. // 4.4.3
  322. Registry.prototype.entries = function () {
  323. var registry = this[REGISTRY];
  324. return arrayValues(Object.keys(registry).map(function (key) {
  325. return [key, registry[key]];
  326. }));
  327. };
  328. }
  329. // 4.4.4
  330. Registry.prototype.keys = function () {
  331. return arrayValues(Object.keys(this[REGISTRY]));
  332. };
  333. // 4.4.5
  334. Registry.prototype.values = function () {
  335. var registry = this[REGISTRY];
  336. return arrayValues(Object.keys(registry).map(function (key) {
  337. return registry[key];
  338. }));
  339. };
  340. // 4.4.6
  341. Registry.prototype.get = function (key) {
  342. return this[REGISTRY][key];
  343. };
  344. // 4.4.7
  345. Registry.prototype.set = function (key, namespace) {
  346. if (!(namespace instanceof ModuleNamespace || namespace[toStringTag] === 'module'))
  347. throw new Error('Registry must be set with an instance of Module Namespace');
  348. this[REGISTRY][key] = namespace;
  349. return this;
  350. };
  351. // 4.4.8
  352. Registry.prototype.has = function (key) {
  353. return Object.hasOwnProperty.call(this[REGISTRY], key);
  354. };
  355. // 4.4.9
  356. Registry.prototype.delete = function (key) {
  357. if (Object.hasOwnProperty.call(this[REGISTRY], key)) {
  358. delete this[REGISTRY][key];
  359. return true;
  360. }
  361. return false;
  362. };
  363. /*
  364. * Simple ModuleNamespace Exotic object based on a baseObject
  365. * We export this for allowing a fast-path for module namespace creation over Module descriptors
  366. */
  367. // var EVALUATE = createSymbol('evaluate');
  368. var BASE_OBJECT = createSymbol('baseObject');
  369. // 8.3.1 Reflect.Module
  370. /*
  371. * Best-effort simplified non-spec implementation based on
  372. * a baseObject referenced via getters.
  373. *
  374. * Allows:
  375. *
  376. * loader.registry.set('x', new Module({ default: 'x' }));
  377. *
  378. * Optional evaluation function provides experimental Module.evaluate
  379. * support for non-executed modules in registry.
  380. */
  381. function ModuleNamespace (baseObject/*, evaluate*/) {
  382. Object.defineProperty(this, BASE_OBJECT, {
  383. value: baseObject
  384. });
  385. // evaluate defers namespace population
  386. /* if (evaluate) {
  387. Object.defineProperty(this, EVALUATE, {
  388. value: evaluate,
  389. configurable: true,
  390. writable: true
  391. });
  392. }
  393. else { */
  394. Object.keys(baseObject).forEach(extendNamespace, this);
  395. //}
  396. }// 8.4.2
  397. ModuleNamespace.prototype = Object.create(null);
  398. if (toStringTag)
  399. Object.defineProperty(ModuleNamespace.prototype, toStringTag, {
  400. value: 'Module'
  401. });
  402. function extendNamespace (key) {
  403. Object.defineProperty(this, key, {
  404. enumerable: true,
  405. get: function () {
  406. return this[BASE_OBJECT][key];
  407. }
  408. });
  409. }
  410. /* function doEvaluate (evaluate, context) {
  411. try {
  412. evaluate.call(context);
  413. }
  414. catch (e) {
  415. return e;
  416. }
  417. }
  418. // 8.4.1 Module.evaluate... not documented or used because this is potentially unstable
  419. Module.evaluate = function (ns) {
  420. var evaluate = ns[EVALUATE];
  421. if (evaluate) {
  422. ns[EVALUATE] = undefined;
  423. var err = doEvaluate(evaluate);
  424. if (err) {
  425. // cache the error
  426. ns[EVALUATE] = function () {
  427. throw err;
  428. };
  429. throw err;
  430. }
  431. Object.keys(ns[BASE_OBJECT]).forEach(extendNamespace, ns);
  432. }
  433. // make chainable
  434. return ns;
  435. }; */
  436. var resolvedPromise$1 = Promise.resolve();
  437. /*
  438. * Register Loader
  439. *
  440. * Builds directly on top of loader polyfill to provide:
  441. * - loader.register support
  442. * - hookable higher-level resolve
  443. * - instantiate hook returning a ModuleNamespace or undefined for es module loading
  444. * - loader error behaviour as in HTML and loader specs, caching load and eval errors separately
  445. * - build tracing support by providing a .trace=true and .loads object format
  446. */
  447. var REGISTER_INTERNAL = createSymbol('register-internal');
  448. function RegisterLoader () {
  449. Loader.call(this);
  450. var registryDelete = this.registry.delete;
  451. this.registry.delete = function (key) {
  452. var deleted = registryDelete.call(this, key);
  453. // also delete from register registry if linked
  454. if (records.hasOwnProperty(key) && !records[key].linkRecord) {
  455. delete records[key];
  456. deleted = true;
  457. }
  458. return deleted;
  459. };
  460. var records = {};
  461. this[REGISTER_INTERNAL] = {
  462. // last anonymous System.register call
  463. lastRegister: undefined,
  464. // in-flight es module load records
  465. records: records
  466. };
  467. // tracing
  468. this.trace = false;
  469. }
  470. RegisterLoader.prototype = Object.create(Loader.prototype);
  471. RegisterLoader.prototype.constructor = RegisterLoader;
  472. var INSTANTIATE = RegisterLoader.instantiate = createSymbol('instantiate');
  473. // default normalize is the WhatWG style normalizer
  474. RegisterLoader.prototype[RegisterLoader.resolve = Loader.resolve] = function (key, parentKey) {
  475. return resolveIfNotPlain(key, parentKey || baseURI);
  476. };
  477. RegisterLoader.prototype[INSTANTIATE] = function (key, processAnonRegister) {};
  478. // once evaluated, the linkRecord is set to undefined leaving just the other load record properties
  479. // this allows tracking new binding listeners for es modules through importerSetters
  480. // for dynamic modules, the load record is removed entirely.
  481. function createLoadRecord (state, key, registration) {
  482. return state.records[key] = {
  483. key: key,
  484. // defined System.register cache
  485. registration: registration,
  486. // module namespace object
  487. module: undefined,
  488. // es-only
  489. // this sticks around so new module loads can listen to binding changes
  490. // for already-loaded modules by adding themselves to their importerSetters
  491. importerSetters: undefined,
  492. loadError: undefined,
  493. evalError: undefined,
  494. // in-flight linking record
  495. linkRecord: {
  496. // promise for instantiated
  497. instantiatePromise: undefined,
  498. dependencies: undefined,
  499. execute: undefined,
  500. executingRequire: false,
  501. // underlying module object bindings
  502. moduleObj: undefined,
  503. // es only, also indicates if es or not
  504. setters: undefined,
  505. // promise for instantiated dependencies (dependencyInstantiations populated)
  506. depsInstantiatePromise: undefined,
  507. // will be the array of dependency load record or a module namespace
  508. dependencyInstantiations: undefined,
  509. // top-level await!
  510. evaluatePromise: undefined,
  511. // NB optimization and way of ensuring module objects in setters
  512. // indicates setters which should run pre-execution of that dependency
  513. // setters is then just for completely executed module objects
  514. // alternatively we just pass the partially filled module objects as
  515. // arguments into the execute function
  516. // hoisted: undefined
  517. }
  518. };
  519. }
  520. RegisterLoader.prototype[Loader.resolveInstantiate] = function (key, parentKey) {
  521. var loader = this;
  522. var state = this[REGISTER_INTERNAL];
  523. var registry = this.registry[REGISTRY];
  524. return resolveInstantiate(loader, key, parentKey, registry, state)
  525. .then(function (instantiated) {
  526. if (instantiated instanceof ModuleNamespace || instantiated[toStringTag] === 'module')
  527. return instantiated;
  528. // resolveInstantiate always returns a load record with a link record and no module value
  529. var link = instantiated.linkRecord;
  530. // if already beaten to done, return
  531. if (!link) {
  532. if (instantiated.module)
  533. return instantiated.module;
  534. throw instantiated.evalError;
  535. }
  536. return deepInstantiateDeps(loader, instantiated, link, registry, state)
  537. .then(function () {
  538. return ensureEvaluate(loader, instantiated, link, registry, state);
  539. });
  540. });
  541. };
  542. function resolveInstantiate (loader, key, parentKey, registry, state) {
  543. // normalization shortpath for already-normalized key
  544. // could add a plain name filter, but doesn't yet seem necessary for perf
  545. var module = registry[key];
  546. if (module)
  547. return Promise.resolve(module);
  548. var load = state.records[key];
  549. // already linked but not in main registry is ignored
  550. if (load && !load.module) {
  551. if (load.loadError)
  552. return Promise.reject(load.loadError);
  553. return instantiate(loader, load, load.linkRecord, registry, state);
  554. }
  555. return loader.resolve(key, parentKey)
  556. .then(function (resolvedKey) {
  557. // main loader registry always takes preference
  558. module = registry[resolvedKey];
  559. if (module)
  560. return module;
  561. load = state.records[resolvedKey];
  562. // already has a module value but not already in the registry (load.module)
  563. // means it was removed by registry.delete, so we should
  564. // disgard the current load record creating a new one over it
  565. // but keep any existing registration
  566. if (!load || load.module)
  567. load = createLoadRecord(state, resolvedKey, load && load.registration);
  568. if (load.loadError)
  569. return Promise.reject(load.loadError);
  570. var link = load.linkRecord;
  571. if (!link)
  572. return load;
  573. return instantiate(loader, load, link, registry, state);
  574. });
  575. }
  576. function createProcessAnonRegister (loader, load, state) {
  577. return function () {
  578. var lastRegister = state.lastRegister;
  579. if (!lastRegister)
  580. return !!load.registration;
  581. state.lastRegister = undefined;
  582. load.registration = lastRegister;
  583. return true;
  584. };
  585. }
  586. function instantiate (loader, load, link, registry, state) {
  587. return link.instantiatePromise || (link.instantiatePromise =
  588. // if there is already an existing registration, skip running instantiate
  589. (load.registration ? resolvedPromise$1 : resolvedPromise$1.then(function () {
  590. state.lastRegister = undefined;
  591. return loader[INSTANTIATE](load.key, loader[INSTANTIATE].length > 1 && createProcessAnonRegister(loader, load, state));
  592. }))
  593. .then(function (instantiation) {
  594. // direct module return from instantiate -> we're done
  595. if (instantiation !== undefined) {
  596. if (!(instantiation instanceof ModuleNamespace || instantiation[toStringTag] === 'module'))
  597. throw new TypeError('Instantiate did not return a valid Module object.');
  598. delete state.records[load.key];
  599. if (loader.trace)
  600. traceLoad(loader, load, link);
  601. return registry[load.key] = instantiation;
  602. }
  603. // run the cached loader.register declaration if there is one
  604. var registration = load.registration;
  605. // clear to allow new registrations for future loads (combined with registry delete)
  606. load.registration = undefined;
  607. if (!registration)
  608. throw new TypeError('Module instantiation did not call an anonymous or correctly named System.register.');
  609. link.dependencies = registration[0];
  610. load.importerSetters = [];
  611. link.moduleObj = {};
  612. // process System.registerDynamic declaration
  613. if (registration[2]) {
  614. link.moduleObj.default = link.moduleObj.__useDefault = {};
  615. link.executingRequire = registration[1];
  616. link.execute = registration[2];
  617. }
  618. // process System.register declaration
  619. else {
  620. registerDeclarative(loader, load, link, registration[1]);
  621. }
  622. return load;
  623. })
  624. .catch(function (err) {
  625. load.linkRecord = undefined;
  626. throw load.loadError = load.loadError || LoaderError__Check_error_message_for_loader_stack(err, 'Instantiating ' + load.key);
  627. }));
  628. }
  629. // like resolveInstantiate, but returning load records for linking
  630. function resolveInstantiateDep (loader, key, parentKey, registry, state, traceDepMap) {
  631. // normalization shortpaths for already-normalized key
  632. // DISABLED to prioritise consistent resolver calls
  633. // could add a plain name filter, but doesn't yet seem necessary for perf
  634. /* var load = state.records[key];
  635. var module = registry[key];
  636. if (module) {
  637. if (traceDepMap)
  638. traceDepMap[key] = key;
  639. // registry authority check in case module was deleted or replaced in main registry
  640. if (load && load.module && load.module === module)
  641. return load;
  642. else
  643. return module;
  644. }
  645. // already linked but not in main registry is ignored
  646. if (load && !load.module) {
  647. if (traceDepMap)
  648. traceDepMap[key] = key;
  649. return instantiate(loader, load, load.linkRecord, registry, state);
  650. } */
  651. return loader.resolve(key, parentKey)
  652. .then(function (resolvedKey) {
  653. if (traceDepMap)
  654. traceDepMap[key] = resolvedKey;
  655. // normalization shortpaths for already-normalized key
  656. var load = state.records[resolvedKey];
  657. var module = registry[resolvedKey];
  658. // main loader registry always takes preference
  659. if (module && (!load || load.module && module !== load.module))
  660. return module;
  661. if (load && load.loadError)
  662. throw load.loadError;
  663. // already has a module value but not already in the registry (load.module)
  664. // means it was removed by registry.delete, so we should
  665. // disgard the current load record creating a new one over it
  666. // but keep any existing registration
  667. if (!load || !module && load.module)
  668. load = createLoadRecord(state, resolvedKey, load && load.registration);
  669. var link = load.linkRecord;
  670. if (!link)
  671. return load;
  672. return instantiate(loader, load, link, registry, state);
  673. });
  674. }
  675. function traceLoad (loader, load, link) {
  676. loader.loads = loader.loads || {};
  677. loader.loads[load.key] = {
  678. key: load.key,
  679. deps: link.dependencies,
  680. dynamicDeps: [],
  681. depMap: link.depMap || {}
  682. };
  683. }
  684. /*
  685. * Convert a CJS module.exports into a valid object for new Module:
  686. *
  687. * new Module(getEsModule(module.exports))
  688. *
  689. * Sets the default value to the module, while also reading off named exports carefully.
  690. */
  691. function registerDeclarative (loader, load, link, declare) {
  692. var moduleObj = link.moduleObj;
  693. var importerSetters = load.importerSetters;
  694. var definedExports = false;
  695. // closure especially not based on link to allow link record disposal
  696. var declared = declare.call(envGlobal, function (name, value) {
  697. if (typeof name === 'object') {
  698. var changed = false;
  699. for (var p in name) {
  700. value = name[p];
  701. if (p !== '__useDefault' && (!(p in moduleObj) || moduleObj[p] !== value)) {
  702. changed = true;
  703. moduleObj[p] = value;
  704. }
  705. }
  706. if (changed === false)
  707. return value;
  708. }
  709. else {
  710. if ((definedExports || name in moduleObj) && moduleObj[name] === value)
  711. return value;
  712. moduleObj[name] = value;
  713. }
  714. for (var i = 0; i < importerSetters.length; i++)
  715. importerSetters[i](moduleObj);
  716. return value;
  717. }, new ContextualLoader(loader, load.key));
  718. link.setters = declared.setters || [];
  719. link.execute = declared.execute;
  720. if (declared.exports) {
  721. link.moduleObj = moduleObj = declared.exports;
  722. definedExports = true;
  723. }
  724. }
  725. function instantiateDeps (loader, load, link, registry, state) {
  726. if (link.depsInstantiatePromise)
  727. return link.depsInstantiatePromise;
  728. var depsInstantiatePromises = Array(link.dependencies.length);
  729. for (var i = 0; i < link.dependencies.length; i++)
  730. depsInstantiatePromises[i] = resolveInstantiateDep(loader, link.dependencies[i], load.key, registry, state, loader.trace && link.depMap || (link.depMap = {}));
  731. var depsInstantiatePromise = Promise.all(depsInstantiatePromises)
  732. .then(function (dependencyInstantiations) {
  733. link.dependencyInstantiations = dependencyInstantiations;
  734. // run setters to set up bindings to instantiated dependencies
  735. if (link.setters) {
  736. for (var i = 0; i < dependencyInstantiations.length; i++) {
  737. var setter = link.setters[i];
  738. if (setter) {
  739. var instantiation = dependencyInstantiations[i];
  740. if (instantiation instanceof ModuleNamespace || instantiation[toStringTag] === 'module') {
  741. setter(instantiation);
  742. }
  743. else {
  744. if (instantiation.loadError)
  745. throw instantiation.loadError;
  746. setter(instantiation.module || instantiation.linkRecord.moduleObj);
  747. // this applies to both es and dynamic registrations
  748. if (instantiation.importerSetters)
  749. instantiation.importerSetters.push(setter);
  750. }
  751. }
  752. }
  753. }
  754. return load;
  755. });
  756. if (loader.trace)
  757. depsInstantiatePromise = depsInstantiatePromise.then(function () {
  758. traceLoad(loader, load, link);
  759. return load;
  760. });
  761. depsInstantiatePromise = depsInstantiatePromise.catch(function (err) {
  762. // throw up the instantiateDeps stack
  763. link.depsInstantiatePromise = undefined;
  764. throw LoaderError__Check_error_message_for_loader_stack(err, 'Loading ' + load.key);
  765. });
  766. depsInstantiatePromise.catch(function () {});
  767. return link.depsInstantiatePromise = depsInstantiatePromise;
  768. }
  769. function deepInstantiateDeps (loader, load, link, registry, state) {
  770. var seen = [];
  771. function addDeps (load, link) {
  772. if (!link)
  773. return resolvedPromise$1;
  774. if (seen.indexOf(load) !== -1)
  775. return resolvedPromise$1;
  776. seen.push(load);
  777. return instantiateDeps(loader, load, link, registry, state)
  778. .then(function () {
  779. var depPromises;
  780. for (var i = 0; i < link.dependencies.length; i++) {
  781. var depLoad = link.dependencyInstantiations[i];
  782. if (!(depLoad instanceof ModuleNamespace || depLoad[toStringTag] === 'module')) {
  783. depPromises = depPromises || [];
  784. depPromises.push(addDeps(depLoad, depLoad.linkRecord));
  785. }
  786. }
  787. if (depPromises)
  788. return Promise.all(depPromises);
  789. });
  790. }
  791. return addDeps(load, link);
  792. }
  793. /*
  794. * System.register
  795. */
  796. RegisterLoader.prototype.register = function (key, deps, declare) {
  797. var state = this[REGISTER_INTERNAL];
  798. // anonymous modules get stored as lastAnon
  799. if (declare === undefined) {
  800. state.lastRegister = [key, deps, undefined];
  801. }
  802. // everything else registers into the register cache
  803. else {
  804. var load = state.records[key] || createLoadRecord(state, key, undefined);
  805. load.registration = [deps, declare, undefined];
  806. }
  807. };
  808. /*
  809. * System.registerDyanmic
  810. */
  811. RegisterLoader.prototype.registerDynamic = function (key, deps, executingRequire, execute) {
  812. var state = this[REGISTER_INTERNAL];
  813. // anonymous modules get stored as lastAnon
  814. if (typeof key !== 'string') {
  815. state.lastRegister = [key, deps, executingRequire];
  816. }
  817. // everything else registers into the register cache
  818. else {
  819. var load = state.records[key] || createLoadRecord(state, key, undefined);
  820. load.registration = [deps, executingRequire, execute];
  821. }
  822. };
  823. // ContextualLoader class
  824. // backwards-compatible with previous System.register context argument by exposing .id, .key
  825. function ContextualLoader (loader, key) {
  826. this.loader = loader;
  827. this.key = this.id = key;
  828. this.meta = {
  829. url: key
  830. // scriptElement: null
  831. };
  832. }
  833. /*ContextualLoader.prototype.constructor = function () {
  834. throw new TypeError('Cannot subclass the contextual loader only Reflect.Loader.');
  835. };*/
  836. ContextualLoader.prototype.import = function (key) {
  837. if (this.loader.trace)
  838. this.loader.loads[this.key].dynamicDeps.push(key);
  839. return this.loader.import(key, this.key);
  840. };
  841. /*ContextualLoader.prototype.resolve = function (key) {
  842. return this.loader.resolve(key, this.key);
  843. };*/
  844. function ensureEvaluate (loader, load, link, registry, state) {
  845. if (load.module)
  846. return load.module;
  847. if (load.evalError)
  848. throw load.evalError;
  849. if (link.evaluatePromise)
  850. return link.evaluatePromise;
  851. if (link.setters) {
  852. var evaluatePromise = doEvaluateDeclarative(loader, load, link, registry, state, [load]);
  853. if (evaluatePromise)
  854. return evaluatePromise;
  855. }
  856. else {
  857. doEvaluateDynamic(loader, load, link, registry, state, [load]);
  858. }
  859. return load.module;
  860. }
  861. function makeDynamicRequire (loader, key, dependencies, dependencyInstantiations, registry, state, seen) {
  862. // we can only require from already-known dependencies
  863. return function (name) {
  864. for (var i = 0; i < dependencies.length; i++) {
  865. if (dependencies[i] === name) {
  866. var depLoad = dependencyInstantiations[i];
  867. var module;
  868. if (depLoad instanceof ModuleNamespace || depLoad[toStringTag] === 'module') {
  869. module = depLoad;
  870. }
  871. else {
  872. if (depLoad.evalError)
  873. throw depLoad.evalError;
  874. if (depLoad.module === undefined && seen.indexOf(depLoad) === -1 && !depLoad.linkRecord.evaluatePromise) {
  875. if (depLoad.linkRecord.setters) {
  876. doEvaluateDeclarative(loader, depLoad, depLoad.linkRecord, registry, state, [depLoad]);
  877. }
  878. else {
  879. seen.push(depLoad);
  880. doEvaluateDynamic(loader, depLoad, depLoad.linkRecord, registry, state, seen);
  881. }
  882. }
  883. module = depLoad.module || depLoad.linkRecord.moduleObj;
  884. }
  885. return '__useDefault' in module ? module.__useDefault : module;
  886. }
  887. }
  888. throw new Error('Module ' + name + ' not declared as a System.registerDynamic dependency of ' + key);
  889. };
  890. }
  891. function evalError (load, err) {
  892. load.linkRecord = undefined;
  893. var evalError = LoaderError__Check_error_message_for_loader_stack(err, 'Evaluating ' + load.key);
  894. if (load.evalError === undefined)
  895. load.evalError = evalError;
  896. throw evalError;
  897. }
  898. // es modules evaluate dependencies first
  899. // returns the error if any
  900. function doEvaluateDeclarative (loader, load, link, registry, state, seen) {
  901. var depLoad, depLink;
  902. var depLoadPromises;
  903. for (var i = 0; i < link.dependencies.length; i++) {
  904. var depLoad = link.dependencyInstantiations[i];
  905. if (depLoad instanceof ModuleNamespace || depLoad[toStringTag] === 'module')
  906. continue;
  907. // custom Module returned from instantiate
  908. depLink = depLoad.linkRecord;
  909. if (depLink) {
  910. if (depLoad.evalError) {
  911. evalError(load, depLoad.evalError);
  912. }
  913. else if (depLink.setters) {
  914. if (seen.indexOf(depLoad) === -1) {
  915. seen.push(depLoad);
  916. try {
  917. var depLoadPromise = doEvaluateDeclarative(loader, depLoad, depLink, registry, state, seen);
  918. }
  919. catch (e) {
  920. evalError(load, e);
  921. }
  922. if (depLoadPromise) {
  923. depLoadPromises = depLoadPromises || [];
  924. depLoadPromises.push(depLoadPromise.catch(function (err) {
  925. evalError(load, err);
  926. }));
  927. }
  928. }
  929. }
  930. else {
  931. try {
  932. doEvaluateDynamic(loader, depLoad, depLink, registry, state, [depLoad]);
  933. }
  934. catch (e) {
  935. evalError(load, e);
  936. }
  937. }
  938. }
  939. }
  940. if (depLoadPromises)
  941. return link.evaluatePromise = Promise.all(depLoadPromises)
  942. .then(function () {
  943. if (link.execute) {
  944. // ES System.register execute
  945. // "this" is null in ES
  946. try {
  947. var execPromise = link.execute.call(nullContext);
  948. }
  949. catch (e) {
  950. evalError(load, e);
  951. }
  952. if (execPromise)
  953. return execPromise.catch(function (e) {
  954. evalError(load, e);
  955. })
  956. .then(function () {
  957. load.linkRecord = undefined;
  958. return registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
  959. });
  960. }
  961. // dispose link record
  962. load.linkRecord = undefined;
  963. registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
  964. });
  965. if (link.execute) {
  966. // ES System.register execute
  967. // "this" is null in ES
  968. try {
  969. var execPromise = link.execute.call(nullContext);
  970. }
  971. catch (e) {
  972. evalError(load, e);
  973. }
  974. if (execPromise)
  975. return link.evaluatePromise = execPromise.catch(function (e) {
  976. evalError(load, e);
  977. })
  978. .then(function () {
  979. load.linkRecord = undefined;
  980. return registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
  981. });
  982. }
  983. // dispose link record
  984. load.linkRecord = undefined;
  985. registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
  986. }
  987. // non es modules explicitly call moduleEvaluate through require
  988. function doEvaluateDynamic (loader, load, link, registry, state, seen) {
  989. // System.registerDynamic execute
  990. // "this" is "exports" in CJS
  991. var module = { id: load.key };
  992. var moduleObj = link.moduleObj;
  993. Object.defineProperty(module, 'exports', {
  994. configurable: true,
  995. set: function (exports) {
  996. moduleObj.default = moduleObj.__useDefault = exports;
  997. },
  998. get: function () {
  999. return moduleObj.__useDefault;
  1000. }
  1001. });
  1002. var require = makeDynamicRequire(loader, load.key, link.dependencies, link.dependencyInstantiations, registry, state, seen);
  1003. // evaluate deps first
  1004. if (!link.executingRequire)
  1005. for (var i = 0; i < link.dependencies.length; i++)
  1006. require(link.dependencies[i]);
  1007. try {
  1008. var output = link.execute.call(envGlobal, require, moduleObj.default, module);
  1009. if (output !== undefined)
  1010. module.exports = output;
  1011. }
  1012. catch (e) {
  1013. evalError(load, e);
  1014. }
  1015. load.linkRecord = undefined;
  1016. // pick up defineProperty calls to module.exports when we can
  1017. if (module.exports !== moduleObj.__useDefault)
  1018. moduleObj.default = moduleObj.__useDefault = module.exports;
  1019. var moduleDefault = moduleObj.default;
  1020. // __esModule flag extension support via lifting
  1021. if (moduleDefault && moduleDefault.__esModule) {
  1022. for (var p in moduleDefault) {
  1023. if (Object.hasOwnProperty.call(moduleDefault, p))
  1024. moduleObj[p] = moduleDefault[p];
  1025. }
  1026. }
  1027. registry[load.key] = load.module = new ModuleNamespace(link.moduleObj);
  1028. // run importer setters and clear them
  1029. // this allows dynamic modules to update themselves into es modules
  1030. // as soon as execution has completed
  1031. if (load.importerSetters)
  1032. for (var i = 0; i < load.importerSetters.length; i++)
  1033. load.importerSetters[i](load.module);
  1034. load.importerSetters = undefined;
  1035. }
  1036. // the closest we can get to call(undefined)
  1037. var nullContext = Object.create(null);
  1038. if (Object.freeze)
  1039. Object.freeze(nullContext);
  1040. var resolvedPromise$2 = Promise.resolve();
  1041. function noop () {}
  1042. var emptyModule = new ModuleNamespace({});
  1043. function isModule (m) {
  1044. return m instanceof ModuleNamespace || m[toStringTag] === 'module';
  1045. }
  1046. var CONFIG = createSymbol('loader-config');
  1047. var PLAIN_RESOLVE = createSymbol('plain-resolve');
  1048. var PLAIN_RESOLVE_SYNC = createSymbol('plain-resolve-sync');
  1049. var isWorker = typeof window === 'undefined' && typeof self !== 'undefined' && typeof importScripts !== 'undefined';
  1050. function extend (a, b) {
  1051. for (var p in b) {
  1052. if (!Object.hasOwnProperty.call(b, p))
  1053. continue;
  1054. a[p] = b[p];
  1055. }
  1056. return a;
  1057. }
  1058. var supportsPreload = false, supportsPrefetch = false;
  1059. if (isBrowser)
  1060. (function () {
  1061. var relList = document.createElement('link').relList;
  1062. if (relList && relList.supports) {
  1063. supportsPrefetch = true;
  1064. try {
  1065. supportsPreload = relList.supports('preload');
  1066. }
  1067. catch (e) {}
  1068. }
  1069. })();
  1070. function preloadScript (url) {
  1071. // fallback to old fashioned image technique which still works in safari
  1072. if (!supportsPreload && !supportsPrefetch) {
  1073. var preloadImage = new Image();
  1074. preloadImage.src = url;
  1075. return;
  1076. }
  1077. var link = document.createElement('link');
  1078. if (supportsPreload) {
  1079. link.rel = 'preload';
  1080. link.as = 'script';
  1081. }
  1082. else {
  1083. // this works for all except Safari (detected by relList.supports lacking)
  1084. link.rel = 'prefetch';
  1085. }
  1086. link.href = url;
  1087. document.head.appendChild(link);
  1088. }
  1089. function workerImport (src, resolve, reject) {
  1090. try {
  1091. importScripts(src);
  1092. }
  1093. catch (e) {
  1094. reject(e);
  1095. }
  1096. resolve();
  1097. }
  1098. if (isBrowser) {
  1099. var onerror = window.onerror;
  1100. window.onerror = function globalOnerror (msg, src) {
  1101. if (onerror)
  1102. onerror.apply(this, arguments);
  1103. };
  1104. }
  1105. function scriptLoad (src, crossOrigin, integrity, resolve, reject) {
  1106. // percent encode just "#" for HTTP requests
  1107. src = src.replace(/#/g, '%23');
  1108. // subresource integrity is not supported in web workers
  1109. if (isWorker)
  1110. return workerImport(src, resolve, reject);
  1111. var script = document.createElement('script');
  1112. script.type = 'text/javascript';
  1113. script.charset = 'utf-8';
  1114. script.async = true;
  1115. if (crossOrigin)
  1116. script.crossOrigin = crossOrigin;
  1117. if (integrity)
  1118. script.integrity = integrity;
  1119. script.addEventListener('load', load, false);
  1120. script.addEventListener('error', error, false);
  1121. script.src = src;
  1122. document.head.appendChild(script);
  1123. function load () {
  1124. resolve();
  1125. cleanup();
  1126. }
  1127. // note this does not catch execution errors
  1128. function error (err) {
  1129. cleanup();
  1130. reject(new Error('Fetching ' + src));
  1131. }
  1132. function cleanup () {
  1133. script.removeEventListener('load', load, false);
  1134. script.removeEventListener('error', error, false);
  1135. document.head.removeChild(script);
  1136. }
  1137. }
  1138. // separate out paths cache as a baseURL lock process
  1139. function applyPaths (baseURL, paths, key) {
  1140. var mapMatch = getMapMatch(paths, key);
  1141. if (mapMatch) {
  1142. var target = paths[mapMatch] + key.substr(mapMatch.length);
  1143. var resolved = resolveIfNotPlain(target, baseURI);
  1144. if (resolved !== undefined)
  1145. return resolved;
  1146. return baseURL + target;
  1147. }
  1148. else if (key.indexOf(':') !== -1) {
  1149. return key;
  1150. }
  1151. else {
  1152. return baseURL + key;
  1153. }
  1154. }
  1155. function checkMap (p) {
  1156. var name = this.name;
  1157. // can add ':' here if we want paths to match the behaviour of map
  1158. if (name.substr(0, p.length) === p && (name.length === p.length || name[p.length] === '/' || p[p.length - 1] === '/' || p[p.length - 1] === ':')) {
  1159. var curLen = p.split('/').length;
  1160. if (curLen > this.len) {
  1161. this.match = p;
  1162. this.len = curLen;
  1163. }
  1164. }
  1165. }
  1166. function getMapMatch (map, name) {
  1167. if (Object.hasOwnProperty.call(map, name))
  1168. return name;
  1169. var bestMatch = {
  1170. name: name,
  1171. match: undefined,
  1172. len: 0
  1173. };
  1174. Object.keys(map).forEach(checkMap, bestMatch);
  1175. return bestMatch.match;
  1176. }
  1177. function setAmdHelper (loader) {
  1178. /*
  1179. AMD-compatible require
  1180. To copy RequireJS, set window.require = window.requirejs = loader.amdRequire
  1181. */
  1182. function require (names, callback, errback, referer) {
  1183. // in amd, first arg can be a config object... we just ignore
  1184. if (typeof names === 'object' && !(names instanceof Array))
  1185. return require.apply(null, Array.prototype.splice.call(arguments, 1, arguments.length - 1));
  1186. // amd require
  1187. if (typeof names === 'string' && typeof callback === 'function')
  1188. names = [names];
  1189. if (names instanceof Array) {
  1190. var dynamicRequires = [];
  1191. for (var i = 0; i < names.length; i++)
  1192. dynamicRequires.push(loader.import(names[i], referer));
  1193. Promise.all(dynamicRequires).then(function (modules) {
  1194. if (callback)
  1195. callback.apply(null, modules);
  1196. }, errback);
  1197. }
  1198. // commonjs require
  1199. else if (typeof names === 'string') {
  1200. var normalized = loader.decanonicalize(names, referer);
  1201. var module = loader.get(normalized);
  1202. if (!module)
  1203. throw new Error('Module not already loaded loading "' + names + '" as ' + normalized + (referer ? ' from "' + referer + '".' : '.'));
  1204. return '__useDefault' in module ? module.__useDefault : module;
  1205. }
  1206. else
  1207. throw new TypeError('Invalid require');
  1208. }
  1209. function define (name, deps, factory) {
  1210. if (typeof name !== 'string') {
  1211. factory = deps;
  1212. deps = name;
  1213. name = null;
  1214. }
  1215. if (!(deps instanceof Array)) {
  1216. factory = deps;
  1217. deps = ['require', 'exports', 'module'].splice(0, factory.length);
  1218. }
  1219. if (typeof factory !== 'function')
  1220. factory = (function (factory) {
  1221. return function() { return factory; }
  1222. })(factory);
  1223. if (!name) {
  1224. if (curMetaDeps) {
  1225. deps = deps.concat(curMetaDeps);
  1226. curMetaDeps = undefined;
  1227. }
  1228. }
  1229. // remove system dependencies
  1230. var requireIndex, exportsIndex, moduleIndex;
  1231. if ((requireIndex = deps.indexOf('require')) !== -1) {
  1232. deps.splice(requireIndex, 1);
  1233. // only trace cjs requires for non-named
  1234. // named defines assume the trace has already been done
  1235. if (!name)
  1236. deps = deps.concat(amdGetCJSDeps(factory.toString(), requireIndex));
  1237. }
  1238. if ((exportsIndex = deps.indexOf('exports')) !== -1)
  1239. deps.splice(exportsIndex, 1);
  1240. if ((moduleIndex = deps.indexOf('module')) !== -1)
  1241. deps.splice(moduleIndex, 1);
  1242. function execute (req, exports, module) {
  1243. var depValues = [];
  1244. for (var i = 0; i < deps.length; i++)
  1245. depValues.push(req(deps[i]));
  1246. module.uri = module.id;
  1247. module.config = noop;
  1248. // add back in system dependencies
  1249. if (moduleIndex !== -1)
  1250. depValues.splice(moduleIndex, 0, module);
  1251. if (exportsIndex !== -1)
  1252. depValues.splice(exportsIndex, 0, exports);
  1253. if (requireIndex !== -1) {
  1254. var contextualRequire = function (names, callback, errback) {
  1255. if (typeof names === 'string' && typeof callback !== 'function')
  1256. return req(names);
  1257. return require.call(loader, names, callback, errback, module.id);
  1258. };
  1259. contextualRequire.toUrl = function (name) {
  1260. return loader.normalizeSync(name, module.id);
  1261. };
  1262. depValues.splice(requireIndex, 0, contextualRequire);
  1263. }
  1264. // set global require to AMD require
  1265. var curRequire = envGlobal.require;
  1266. envGlobal.require = require;
  1267. var output = factory.apply(exportsIndex === -1 ? envGlobal : exports, depValues);
  1268. envGlobal.require = curRequire;
  1269. if (typeof output !== 'undefined')
  1270. module.exports = output;
  1271. }
  1272. // anonymous define
  1273. if (!name) {
  1274. loader.registerDynamic(deps, false, curEsModule ? wrapEsModuleExecute(execute) : execute);
  1275. }
  1276. else {
  1277. loader.registerDynamic(name, deps, false, execute);
  1278. // if we don't have any other defines,
  1279. // then let this be an anonymous define
  1280. // this is just to support single modules of the form:
  1281. // define('jquery')
  1282. // still loading anonymously
  1283. // because it is done widely enough to be useful
  1284. // as soon as there is more than one define, this gets removed though
  1285. if (lastNamedDefine) {
  1286. lastNamedDefine = undefined;
  1287. multipleNamedDefines = true;
  1288. }
  1289. else if (!multipleNamedDefines) {
  1290. lastNamedDefine = [deps, execute];
  1291. }
  1292. }
  1293. }
  1294. define.amd = {};
  1295. loader.amdDefine = define;
  1296. loader.amdRequire = require;
  1297. }
  1298. // CJS
  1299. var windowOrigin;
  1300. if (typeof window !== 'undefined' && typeof document !== 'undefined' && window.location)
  1301. windowOrigin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
  1302. var commentRegEx = /(^|[^\\])(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
  1303. // Global
  1304. // bare minimum ignores
  1305. var ignoredGlobalProps = ['_g', 'sessionStorage', 'localStorage', 'clipboardData', 'frames', 'frameElement', 'external',
  1306. 'mozAnimationStartTime', 'mozPaintCount', 'webkitStorageInfo', 'webkitIndexedDB', 'mozInnerScreenY', 'mozInnerScreenX'];
  1307. function globalIterator (globalName) {
  1308. if (ignoredGlobalProps.indexOf(globalName) !== -1)
  1309. return;
  1310. try {
  1311. var value = envGlobal[globalName];
  1312. }
  1313. catch (e) {
  1314. ignoredGlobalProps.push(globalName);
  1315. }
  1316. this(globalName, value);
  1317. }
  1318. // AMD
  1319. var cjsRequirePre = "(?:^|[^$_a-zA-Z\\xA0-\\uFFFF.])";
  1320. var cjsRequirePost = "\\s*\\(\\s*(\"([^\"]+)\"|'([^']+)')\\s*\\)";
  1321. var fnBracketRegEx = /\(([^\)]*)\)/;
  1322. var wsRegEx = /^\s+|\s+$/g;
  1323. var requireRegExs = {};
  1324. function amdGetCJSDeps(source, requireIndex) {
  1325. // remove comments
  1326. source = source.replace(commentRegEx, '');
  1327. // determine the require alias
  1328. var params = source.match(fnBracketRegEx);
  1329. var requireAlias = (params[1].split(',')[requireIndex] || 'require').replace(wsRegEx, '');
  1330. // find or generate the regex for this requireAlias
  1331. var requireRegEx = requireRegExs[requireAlias] || (requireRegExs[requireAlias] = new RegExp(cjsRequirePre + requireAlias + cjsRequirePost, 'g'));
  1332. requireRegEx.lastIndex = 0;
  1333. var deps = [];
  1334. var match;
  1335. while (match = requireRegEx.exec(source))
  1336. deps.push(match[2] || match[3]);
  1337. return deps;
  1338. }
  1339. function wrapEsModuleExecute (execute) {
  1340. return function (require, exports, module) {
  1341. execute(require, exports, module);
  1342. exports = module.exports;
  1343. if ((typeof exports === 'object' || typeof exports === 'function') && !('__esModule' in exports))
  1344. Object.defineProperty(module.exports, '__esModule', {
  1345. value: true
  1346. });
  1347. };
  1348. }
  1349. // generate anonymous define from singular named define
  1350. var multipleNamedDefines = false;
  1351. var lastNamedDefine;
  1352. var curMetaDeps;
  1353. var curEsModule = false;
  1354. function registerLastDefine (loader) {
  1355. if (lastNamedDefine)
  1356. loader.registerDynamic(curMetaDeps ? lastNamedDefine[0].concat(curMetaDeps) : lastNamedDefine[0],
  1357. false, curEsModule ? wrapEsModuleExecute(lastNamedDefine[1]) : lastNamedDefine[1]);
  1358. // bundles are an empty module
  1359. else if (multipleNamedDefines)
  1360. loader.registerDynamic([], false, noop);
  1361. }
  1362. function SystemJSProductionLoader () {
  1363. RegisterLoader.call(this);
  1364. // internal configuration
  1365. this[CONFIG] = {
  1366. baseURL: baseURI,
  1367. paths: {},
  1368. map: {},
  1369. submap: {},
  1370. depCache: {}
  1371. };
  1372. setAmdHelper(this);
  1373. if (isBrowser)
  1374. envGlobal.define = this.amdDefine;
  1375. }
  1376. SystemJSProductionLoader.plainResolve = PLAIN_RESOLVE;
  1377. SystemJSProductionLoader.plainResolveSync = PLAIN_RESOLVE_SYNC;
  1378. var systemJSPrototype = SystemJSProductionLoader.prototype = Object.create(RegisterLoader.prototype);
  1379. systemJSPrototype.constructor = SystemJSProductionLoader;
  1380. systemJSPrototype[SystemJSProductionLoader.resolve = RegisterLoader.resolve] = function (key, parentKey) {
  1381. var resolved = resolveIfNotPlain(key, parentKey || baseURI);
  1382. if (resolved !== undefined)
  1383. return Promise.resolve(resolved);
  1384. // plain resolution
  1385. var loader = this;
  1386. return resolvedPromise$2
  1387. .then(function () {
  1388. return loader[PLAIN_RESOLVE](key, parentKey);
  1389. })
  1390. .then(function (resolved) {
  1391. resolved = resolved || key;
  1392. // if in the registry then we are done
  1393. if (loader.registry.has(resolved))
  1394. return resolved;
  1395. // then apply paths
  1396. // baseURL is fallback
  1397. var config = loader[CONFIG];
  1398. return applyPaths(config.baseURL, config.paths, resolved);
  1399. });
  1400. };
  1401. systemJSPrototype.newModule = function (bindings) {
  1402. return new ModuleNamespace(bindings);
  1403. };
  1404. systemJSPrototype.isModule = isModule;
  1405. systemJSPrototype.resolveSync = function (key, parentKey) {
  1406. var resolved = resolveIfNotPlain(key, parentKey || baseURI);
  1407. if (resolved !== undefined)
  1408. return resolved;
  1409. // plain resolution
  1410. resolved = this[PLAIN_RESOLVE_SYNC](key, parentKey) || key;
  1411. if (this.registry.has(resolved))
  1412. return resolved;
  1413. // then apply paths
  1414. var config = this[CONFIG];
  1415. return applyPaths(config.baseURL, config.paths, resolved);
  1416. };
  1417. systemJSPrototype[PLAIN_RESOLVE] = systemJSPrototype[PLAIN_RESOLVE_SYNC] = plainResolve;
  1418. systemJSPrototype[SystemJSProductionLoader.instantiate = RegisterLoader.instantiate] = coreInstantiate;
  1419. systemJSPrototype.config = function (cfg) {
  1420. var config = this[CONFIG];
  1421. if (cfg.baseURL) {
  1422. config.baseURL = resolveIfNotPlain(cfg.baseURL, baseURI) || resolveIfNotPlain('./' + cfg.baseURL, baseURI);
  1423. if (config.baseURL[config.baseURL.length - 1] !== '/')
  1424. config.baseURL += '/';
  1425. }
  1426. if (cfg.paths)
  1427. extend(config.paths, cfg.paths);
  1428. if (cfg.map) {
  1429. var val = cfg.map;
  1430. for (var p in val) {
  1431. if (!Object.hasOwnProperty.call(val, p))
  1432. continue;
  1433. var v = val[p];
  1434. if (typeof v === 'string') {
  1435. config.map[p] = v;
  1436. }
  1437. // object submap
  1438. else {
  1439. // normalize parent with URL and paths only
  1440. var resolvedParent = resolveIfNotPlain(p, baseURI) || applyPaths(config.baseURL, config.paths, p);
  1441. extend(config.submap[resolvedParent] || (config.submap[resolvedParent] = {}), v);
  1442. }
  1443. }
  1444. }
  1445. config.wasm = cfg.wasm === true;
  1446. for (var p in cfg) {
  1447. if (!Object.hasOwnProperty.call(cfg, p))
  1448. continue;
  1449. var val = cfg[p];
  1450. switch (p) {
  1451. case 'baseURL':
  1452. case 'paths':
  1453. case 'map':
  1454. case 'wasm':
  1455. break;
  1456. case 'depCache':
  1457. for (var p in val) {
  1458. if (!Object.hasOwnProperty.call(val, p))
  1459. continue;
  1460. var resolvedParent = this.resolveSync(p, undefined);
  1461. config.depCache[resolvedParent] = (config.depCache[resolvedParent] || []).concat(val[p]);
  1462. }
  1463. break;
  1464. default:
  1465. throw new TypeError('The SystemJS production build does not support the "' + p + '" configuration option.');
  1466. }
  1467. }
  1468. };
  1469. // getConfig configuration cloning
  1470. systemJSPrototype.getConfig = function (name) {
  1471. var config = this[CONFIG];
  1472. var map = {};
  1473. extend(map, config.map);
  1474. for (var p in config.submap) {
  1475. if (!Object.hasOwnProperty.call(config.submap, p))
  1476. continue;
  1477. map[p] = extend({}, config.submap[p]);
  1478. }
  1479. var depCache = {};
  1480. for (var p in config.depCache) {
  1481. if (!Object.hasOwnProperty.call(config.depCache, p))
  1482. continue;
  1483. depCache[p] = [].concat(config.depCache[p]);
  1484. }
  1485. return {
  1486. baseURL: config.baseURL,
  1487. paths: extend({}, config.paths),
  1488. depCache: depCache,
  1489. map: map,
  1490. wasm: config.wasm === true
  1491. };
  1492. };
  1493. // ensure System.register and System.registerDynamic decanonicalize
  1494. systemJSPrototype.register = function (key, deps, declare) {
  1495. if (typeof key === 'string')
  1496. key = this.resolveSync(key, undefined);
  1497. return RegisterLoader.prototype.register.call(this, key, deps, declare);
  1498. };
  1499. systemJSPrototype.registerDynamic = function (key, deps, executingRequire, execute) {
  1500. if (typeof key === 'string')
  1501. key = this.resolveSync(key, undefined);
  1502. return RegisterLoader.prototype.registerDynamic.call(this, key, deps, executingRequire, execute);
  1503. };
  1504. function plainResolve (key, parentKey) {
  1505. var config = this[CONFIG];
  1506. // Apply contextual submap
  1507. if (parentKey) {
  1508. var parent = getMapMatch(config.submap, parentKey);
  1509. var submap = config.submap[parent];
  1510. var mapMatch = submap && getMapMatch(submap, key);
  1511. if (mapMatch) {
  1512. var target = submap[mapMatch] + key.substr(mapMatch.length);
  1513. return resolveIfNotPlain(target, parent) || target;
  1514. }
  1515. }
  1516. // Apply global map
  1517. var map = config.map;
  1518. var mapMatch = getMapMatch(map, key);
  1519. if (mapMatch) {
  1520. var target = map[mapMatch] + key.substr(mapMatch.length);
  1521. return resolveIfNotPlain(target, parentKey || config.baseURL) || target;
  1522. }
  1523. }
  1524. function instantiateWasm (loader, response, processAnonRegister) {
  1525. return WebAssembly.compileStreaming(response).then(function (module) {
  1526. var deps = [];
  1527. var setters = [];
  1528. var importObj = {};
  1529. // we can only set imports if supported (eg early Safari doesnt support)
  1530. if (WebAssembly.Module.imports)
  1531. WebAssembly.Module.imports(module).forEach(function (i) {
  1532. var key = i.module;
  1533. setters.push(function (m) {
  1534. importObj[key] = m;
  1535. });
  1536. if (deps.indexOf(key) === -1)
  1537. deps.push(key);
  1538. });
  1539. loader.register(deps, function (_export) {
  1540. return {
  1541. setters: setters,
  1542. execute: function () {
  1543. _export(new WebAssembly.Instance(module, importObj).exports);
  1544. }
  1545. };
  1546. });
  1547. processAnonRegister();
  1548. });
  1549. }
  1550. function doScriptLoad (loader, url, processAnonRegister) {
  1551. // store a global snapshot in case it turns out to be global
  1552. Object.keys(envGlobal).forEach(globalIterator, function (name, value) {
  1553. globalSnapshot$1[name] = value;
  1554. });
  1555. return new Promise(function (resolve, reject) {
  1556. return scriptLoad(url, 'anonymous', undefined, function () {
  1557. // check for System.register call
  1558. var registered = processAnonRegister();
  1559. if (!registered) {
  1560. // no System.register -> support named AMD as anonymous
  1561. registerLastDefine(loader);
  1562. registered = processAnonRegister();
  1563. // still no registration -> attempt a global detection
  1564. if (!registered) {
  1565. var moduleValue = retrieveGlobal();
  1566. loader.register([], function () {
  1567. return {
  1568. exports: moduleValue
  1569. };
  1570. });
  1571. processAnonRegister();
  1572. }
  1573. }
  1574. resolve();
  1575. }, reject);
  1576. });
  1577. }
  1578. function doEvalLoad (loader, url, source, processAnonRegister) {
  1579. // store a global snapshot in case it turns out to be global
  1580. Object.keys(envGlobal).forEach(globalIterator, function (name, value) {
  1581. globalSnapshot$1[name] = value;
  1582. });
  1583. (0, eval)(source + '\n//# sourceURL=' + url);
  1584. // check for System.register call
  1585. var registered = processAnonRegister();
  1586. if (!registered) {
  1587. // no System.register -> support named AMD as anonymous
  1588. registerLastDefine(loader);
  1589. registered = processAnonRegister();
  1590. // still no registration -> attempt a global detection
  1591. if (!registered) {
  1592. var moduleValue = retrieveGlobal();
  1593. loader.register([], function () {
  1594. return {
  1595. exports: moduleValue
  1596. };
  1597. });
  1598. processAnonRegister();
  1599. }
  1600. }
  1601. }
  1602. var globalSnapshot$1 = {};
  1603. function retrieveGlobal () {
  1604. var globalValue = { default: undefined };
  1605. var multipleGlobals = false;
  1606. var globalName = undefined;
  1607. Object.keys(envGlobal).forEach(globalIterator, function (name, value) {
  1608. if (globalSnapshot$1[name] === value)
  1609. return;
  1610. // update global snapshot as we go
  1611. globalSnapshot$1[name] = value;
  1612. if (value === undefined)
  1613. return;
  1614. if (multipleGlobals) {
  1615. globalValue[name] = value;
  1616. }
  1617. else if (globalName) {
  1618. if (globalValue.default !== value) {
  1619. multipleGlobals = true;
  1620. globalValue.__esModule = true;
  1621. globalValue[globalName] = globalValue.default;
  1622. globalValue[name] = value;
  1623. }
  1624. }
  1625. else {
  1626. globalValue.default = value;
  1627. globalName = name;
  1628. }
  1629. });
  1630. return globalValue;
  1631. }
  1632. function coreInstantiate (key, processAnonRegister) {
  1633. var config = this[CONFIG];
  1634. var depCache = config.depCache[key];
  1635. if (depCache) {
  1636. for (var i = 0; i < depCache.length; i++)
  1637. this.resolve(depCache[i], key).then(preloadScript);
  1638. }
  1639. if (config.wasm) {
  1640. var loader = this;
  1641. return fetch(key)
  1642. .then(function (res) {
  1643. if (!res.ok)
  1644. throw new Error('Fetch error: ' + res.status + ' ' + res.statusText);
  1645. if (res.headers.get('content-type').indexOf('application/wasm') === -1) {
  1646. return res.text()
  1647. .then(function (source) {
  1648. doEvalLoad(loader, key, source, processAnonRegister);
  1649. });
  1650. }
  1651. return instantiateWasm(loader, res, processAnonRegister);
  1652. });
  1653. }
  1654. return doScriptLoad(this, key, processAnonRegister);
  1655. }
  1656. SystemJSProductionLoader.prototype.version = "0.21.6 Production";
  1657. var System = new SystemJSProductionLoader();
  1658. // only set the global System on the global in browsers
  1659. if (isBrowser || isWorker) {
  1660. envGlobal.SystemJS = System;
  1661. // dont override an existing System global
  1662. if (!envGlobal.System) {
  1663. envGlobal.System = System;
  1664. }
  1665. // rather just extend or set a System.register on the existing System global
  1666. else {
  1667. var register = envGlobal.System.register;
  1668. envGlobal.System.register = function () {
  1669. if (register)
  1670. register.apply(this, arguments);
  1671. System.register.apply(System, arguments);
  1672. };
  1673. }
  1674. }
  1675. if (typeof module !== 'undefined' && module.exports)
  1676. module.exports = System;
  1677. }());
  1678. //# sourceMappingURL=system-production.src.js.map