Advertisement
Guest User

Untitled

a guest
May 30th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.33 KB | None | 0 0
  1. "format register";
  2.  
  3. System.register("jiff/di/util", [], function($__export) {
  4. "use strict";
  5. var __moduleName = "jiff/di/util";
  6. function isUpperCase(char) {
  7. return char.toUpperCase() === char;
  8. }
  9. function isClass(clsOrFunction) {
  10. if (clsOrFunction.name) {
  11. return isUpperCase(clsOrFunction.name.charAt(0));
  12. }
  13. return Object.keys(clsOrFunction.prototype).length > 0;
  14. }
  15. function isFunction(value) {
  16. return typeof value === 'function';
  17. }
  18. function isObject(value) {
  19. return typeof value === 'object';
  20. }
  21. function toString(token) {
  22. if (typeof token === 'string') {
  23. return token;
  24. }
  25. if (token === undefined || token === null) {
  26. return '' + token;
  27. }
  28. if (token.name) {
  29. return token.name;
  30. }
  31. return token.toString();
  32. }
  33. return {
  34. setters: [],
  35. execute: function() {
  36. $__export("isUpperCase", isUpperCase), $__export("isClass", isClass), $__export("isFunction", isFunction), $__export("isObject", isObject), $__export("toString", toString);
  37. }
  38. };
  39. });
  40.  
  41. System.register("jiff/di/profiler", ["./util"], function($__export) {
  42. "use strict";
  43. var __moduleName = "jiff/di/profiler";
  44. var toString,
  45. IS_DEBUG,
  46. _global,
  47. globalCounter;
  48. function getUniqueId() {
  49. return ++globalCounter;
  50. }
  51. function serializeToken(token, tokens) {
  52. if (!tokens.has(token)) {
  53. tokens.set(token, getUniqueId().toString());
  54. }
  55. return tokens.get(token);
  56. }
  57. function serializeProvider(provider, key, tokens) {
  58. return {
  59. id: serializeToken(key, tokens),
  60. name: toString(key),
  61. isPromise: provider.isPromise,
  62. dependencies: provider.params.map(function(param) {
  63. return {
  64. token: serializeToken(param.token, tokens),
  65. isPromise: param.isPromise,
  66. isLazy: param.isLazy
  67. };
  68. })
  69. };
  70. }
  71. function serializeInjector(injector, tokens, Injector) {
  72. var serializedInjector = {
  73. id: serializeToken(injector, tokens),
  74. parent_id: injector.parent ? serializeToken(injector.parent, tokens) : null,
  75. providers: {}
  76. };
  77. var injectorClassId = serializeToken(Injector, tokens);
  78. serializedInjector.providers[injectorClassId] = {
  79. id: injectorClassId,
  80. name: toString(Injector),
  81. isPromise: false,
  82. dependencies: []
  83. };
  84. injector.providers.forEach(function(provider, key) {
  85. var serializedProvider = serializeProvider(provider, key, tokens);
  86. serializedInjector.providers[serializedProvider.id] = serializedProvider;
  87. });
  88. return serializedInjector;
  89. }
  90. function profileInjector(injector, Injector) {
  91. if (!IS_DEBUG) {
  92. return ;
  93. }
  94. if (!_global.__di_dump__) {
  95. _global.__di_dump__ = {
  96. injectors: [],
  97. tokens: new Map()
  98. };
  99. }
  100. _global.__di_dump__.injectors.push(serializeInjector(injector, _global.__di_dump__.tokens, Injector));
  101. }
  102. $__export("profileInjector", profileInjector);
  103. return {
  104. setters: [function($__m) {
  105. toString = $__m.toString;
  106. }],
  107. execute: function() {
  108. IS_DEBUG = false;
  109. _global = null;
  110. if (typeof process === 'object' && process.env) {
  111. IS_DEBUG = !!process.env['DEBUG'];
  112. _global = global;
  113. } else if (typeof location === 'object' && location.search) {
  114. IS_DEBUG = /di_debug/.test(location.search);
  115. _global = window;
  116. }
  117. globalCounter = 0;
  118. }
  119. };
  120. });
  121.  
  122. System.register("jiff/di/providers", ["./annotations", "./util"], function($__export) {
  123. "use strict";
  124. var __moduleName = "jiff/di/providers";
  125. var SuperConstructorAnnotation,
  126. readAnnotations,
  127. isClass,
  128. isFunction,
  129. isObject,
  130. toString,
  131. EmptyFunction,
  132. ClassProvider,
  133. FactoryProvider,
  134. ValueProvider;
  135. function createProviderFromFnOrClass(fnOrClass, annotations) {
  136. if (isClass(fnOrClass)) {
  137. return new ClassProvider(fnOrClass, annotations.params, annotations.provide.isPromise);
  138. }
  139. return new FactoryProvider(fnOrClass, annotations.params, annotations.provide.isPromise);
  140. }
  141. function createProviderFromValue(value) {
  142. return new ValueProvider(value);
  143. }
  144. $__export("createProviderFromFnOrClass", createProviderFromFnOrClass);
  145. $__export("createProviderFromValue", createProviderFromValue);
  146. return {
  147. setters: [function($__m) {
  148. SuperConstructorAnnotation = $__m.SuperConstructor;
  149. readAnnotations = $__m.readAnnotations;
  150. }, function($__m) {
  151. isClass = $__m.isClass;
  152. isFunction = $__m.isFunction;
  153. isObject = $__m.isObject;
  154. toString = $__m.toString;
  155. }],
  156. execute: function() {
  157. EmptyFunction = Object.getPrototypeOf(Function);
  158. ClassProvider = (function() {
  159. var ClassProvider = function ClassProvider(clazz, params, isPromise) {
  160. this.provider = clazz;
  161. this.isPromise = isPromise;
  162. this.params = [];
  163. this.constructors = [];
  164. this._flattenParams(clazz, params);
  165. this.constructors.unshift([clazz, 0, this.params.length - 1]);
  166. };
  167. return ($traceurRuntime.createClass)(ClassProvider, {
  168. _flattenParams: function(constructor, params) {
  169. var SuperConstructor;
  170. var constructorInfo;
  171. for (var $__1 = params[$traceurRuntime.toProperty(Symbol.iterator)](),
  172. $__2 = void 0; !($__2 = $__1.next()).done; ) {
  173. var param = $__2.value;
  174. {
  175. if (param.token === SuperConstructorAnnotation) {
  176. SuperConstructor = Object.getPrototypeOf(constructor);
  177. if (SuperConstructor === EmptyFunction) {
  178. throw new Error((toString(constructor) + " does not have a parent constructor. Only classes with a parent can ask for SuperConstructor!"));
  179. }
  180. constructorInfo = [SuperConstructor, this.params.length];
  181. this.constructors.push(constructorInfo);
  182. this._flattenParams(SuperConstructor, readAnnotations(SuperConstructor).params);
  183. constructorInfo.push(this.params.length - 1);
  184. } else {
  185. this.params.push(param);
  186. }
  187. }
  188. }
  189. },
  190. _createConstructor: function(currentConstructorIdx, context, allArguments) {
  191. var constructorInfo = this.constructors[currentConstructorIdx];
  192. var nextConstructorInfo = this.constructors[currentConstructorIdx + 1];
  193. var argsForCurrentConstructor;
  194. if (nextConstructorInfo) {
  195. argsForCurrentConstructor = allArguments.slice(constructorInfo[1], nextConstructorInfo[1]).concat([this._createConstructor(currentConstructorIdx + 1, context, allArguments)]).concat(allArguments.slice(nextConstructorInfo[2] + 1, constructorInfo[2] + 1));
  196. } else {
  197. argsForCurrentConstructor = allArguments.slice(constructorInfo[1], constructorInfo[2] + 1);
  198. }
  199. return function InjectedAndBoundSuperConstructor() {
  200. return constructorInfo[0].apply(context, argsForCurrentConstructor);
  201. };
  202. },
  203. create: function(args) {
  204. var context = Object.create(this.provider.prototype);
  205. var constructor = this._createConstructor(0, context, args);
  206. var returnedValue = constructor();
  207. if (isFunction(returnedValue) || isObject(returnedValue)) {
  208. return returnedValue;
  209. }
  210. return context;
  211. }
  212. }, {});
  213. }());
  214. FactoryProvider = (function() {
  215. var FactoryProvider = function FactoryProvider(factoryFunction, params, isPromise) {
  216. this.provider = factoryFunction;
  217. this.params = params;
  218. this.isPromise = isPromise;
  219. for (var $__1 = params[$traceurRuntime.toProperty(Symbol.iterator)](),
  220. $__2 = void 0; !($__2 = $__1.next()).done; ) {
  221. var param = $__2.value;
  222. {
  223. if (param.token === SuperConstructorAnnotation) {
  224. throw new Error((toString(factoryFunction) + " is not a class. Only classes with a parent can ask for SuperConstructor!"));
  225. }
  226. }
  227. }
  228. };
  229. return ($traceurRuntime.createClass)(FactoryProvider, {create: function(args) {
  230. return this.provider.apply(undefined, args);
  231. }}, {});
  232. }());
  233. ValueProvider = (function() {
  234. var ValueProvider = function ValueProvider(value) {
  235. this.provider = function() {};
  236. this.params = [];
  237. this.isPromise = false;
  238. this._value = value;
  239. };
  240. return ($traceurRuntime.createClass)(ValueProvider, {create: function() {
  241. return this._value;
  242. }}, {});
  243. }());
  244. }
  245. };
  246. });
  247.  
  248. System.register("jiff/di/annotations", ["./util"], function($__export) {
  249. "use strict";
  250. var __moduleName = "jiff/di/annotations";
  251. var isFunction,
  252. SuperConstructor,
  253. TransientScope,
  254. Inject,
  255. InjectPromise,
  256. InjectLazy,
  257. Provide,
  258. ProvidePromise;
  259. function annotate(fn, annotation) {
  260. fn.annotations = fn.annotations || [];
  261. fn.annotations.push(annotation);
  262. }
  263. function hasAnnotation(fn, annotationClass) {
  264. if (!fn.annotations || fn.annotations.length === 0) {
  265. return false;
  266. }
  267. for (var $__1 = fn.annotations[$traceurRuntime.toProperty(Symbol.iterator)](),
  268. $__2 = void 0; !($__2 = $__1.next()).done; ) {
  269. var annotation = $__2.value;
  270. {
  271. if (annotation instanceof annotationClass) {
  272. return true;
  273. }
  274. }
  275. }
  276. return false;
  277. }
  278. function hasParameterAnnotation(fn, AnnotationClass) {
  279. if (!fn.parameters || fn.parameters.length === 0) {
  280. return false;
  281. }
  282. for (var $__3 = fn.parameters[$traceurRuntime.toProperty(Symbol.iterator)](),
  283. $__4 = void 0; !($__4 = $__3.next()).done; ) {
  284. var parameterAnnotations = $__4.value;
  285. {
  286. for (var $__1 = parameterAnnotations[$traceurRuntime.toProperty(Symbol.iterator)](),
  287. $__2 = void 0; !($__2 = $__1.next()).done; ) {
  288. var annotation = $__2.value;
  289. {
  290. if (annotation instanceof AnnotationClass) {
  291. return true;
  292. }
  293. }
  294. }
  295. }
  296. }
  297. return false;
  298. }
  299. function readAnnotations(fn) {
  300. var collectedAnnotations = {
  301. provide: {
  302. token: null,
  303. isPromise: false
  304. },
  305. params: []
  306. };
  307. if (fn.annotations && fn.annotations.length) {
  308. for (var $__1 = fn.annotations[$traceurRuntime.toProperty(Symbol.iterator)](),
  309. $__2 = void 0; !($__2 = $__1.next()).done; ) {
  310. var annotation = $__2.value;
  311. {
  312. if (annotation instanceof Inject) {
  313. collectedAnnotations.params = annotation.tokens.map((function(token) {
  314. return {
  315. token: token,
  316. isPromise: annotation.isPromise,
  317. isLazy: annotation.isLazy
  318. };
  319. }));
  320. }
  321. if (annotation instanceof Provide) {
  322. collectedAnnotations.provide.token = annotation.token;
  323. collectedAnnotations.provide.isPromise = annotation.isPromise;
  324. }
  325. }
  326. }
  327. }
  328. if (fn.parameters) {
  329. fn.parameters.forEach((function(param, idx) {
  330. for (var $__3 = param[$traceurRuntime.toProperty(Symbol.iterator)](),
  331. $__4 = void 0; !($__4 = $__3.next()).done; ) {
  332. var paramAnnotation = $__4.value;
  333. {
  334. if (isFunction(paramAnnotation) && !collectedAnnotations.params[idx]) {
  335. collectedAnnotations.params[idx] = {
  336. token: paramAnnotation,
  337. isPromise: false,
  338. isLazy: false
  339. };
  340. } else if (paramAnnotation instanceof Inject) {
  341. collectedAnnotations.params[idx] = {
  342. token: paramAnnotation.tokens[0],
  343. isPromise: paramAnnotation.isPromise,
  344. isLazy: paramAnnotation.isLazy
  345. };
  346. }
  347. }
  348. }
  349. }));
  350. }
  351. return collectedAnnotations;
  352. }
  353. return {
  354. setters: [function($__m) {
  355. isFunction = $__m.isFunction;
  356. }],
  357. execute: function() {
  358. SuperConstructor = (function() {
  359. var SuperConstructor = function SuperConstructor() {};
  360. return ($traceurRuntime.createClass)(SuperConstructor, {}, {});
  361. }());
  362. TransientScope = (function() {
  363. var TransientScope = function TransientScope() {};
  364. return ($traceurRuntime.createClass)(TransientScope, {}, {});
  365. }());
  366. Inject = (function() {
  367. var Inject = function Inject() {
  368. for (var tokens = [],
  369. $__5 = 0; $__5 < arguments.length; $__5++)
  370. tokens[$__5] = arguments[$__5];
  371. this.tokens = tokens;
  372. this.isPromise = false;
  373. this.isLazy = false;
  374. };
  375. return ($traceurRuntime.createClass)(Inject, {}, {});
  376. }());
  377. InjectPromise = (function($__super) {
  378. var InjectPromise = function InjectPromise() {
  379. var $__6;
  380. for (var tokens = [],
  381. $__5 = 0; $__5 < arguments.length; $__5++)
  382. tokens[$__5] = arguments[$__5];
  383. ($__6 = $traceurRuntime.superConstructor(InjectPromise)).call.apply($__6, $traceurRuntime.spread([this], tokens));
  384. this.tokens = tokens;
  385. this.isPromise = true;
  386. this.isLazy = false;
  387. };
  388. return ($traceurRuntime.createClass)(InjectPromise, {}, {}, $__super);
  389. }(Inject));
  390. InjectLazy = (function($__super) {
  391. var InjectLazy = function InjectLazy() {
  392. var $__6;
  393. for (var tokens = [],
  394. $__5 = 0; $__5 < arguments.length; $__5++)
  395. tokens[$__5] = arguments[$__5];
  396. ($__6 = $traceurRuntime.superConstructor(InjectLazy)).call.apply($__6, $traceurRuntime.spread([this], tokens));
  397. this.tokens = tokens;
  398. this.isPromise = false;
  399. this.isLazy = true;
  400. };
  401. return ($traceurRuntime.createClass)(InjectLazy, {}, {}, $__super);
  402. }(Inject));
  403. Provide = (function() {
  404. var Provide = function Provide(token) {
  405. this.token = token;
  406. this.isPromise = false;
  407. };
  408. return ($traceurRuntime.createClass)(Provide, {}, {});
  409. }());
  410. ProvidePromise = (function($__super) {
  411. var ProvidePromise = function ProvidePromise(token) {
  412. $traceurRuntime.superConstructor(ProvidePromise).call(this, token);
  413. this.token = token;
  414. this.isPromise = true;
  415. };
  416. return ($traceurRuntime.createClass)(ProvidePromise, {}, {}, $__super);
  417. }(Provide));
  418. $__export("annotate", annotate), $__export("hasAnnotation", hasAnnotation), $__export("hasParameterAnnotation", hasParameterAnnotation), $__export("readAnnotations", readAnnotations), $__export("SuperConstructor", SuperConstructor), $__export("TransientScope", TransientScope), $__export("Inject", Inject), $__export("InjectPromise", InjectPromise), $__export("InjectLazy", InjectLazy), $__export("Provide", Provide), $__export("ProvidePromise", ProvidePromise);
  419. }
  420. };
  421. });
  422.  
  423. System.register("jiff/di/injector", ["./annotations", "./util", "./profiler", "./providers"], function($__export) {
  424. "use strict";
  425. var __moduleName = "jiff/di/injector";
  426. var annotate,
  427. readAnnotations,
  428. hasAnnotation,
  429. hasParameterAnnotation,
  430. ProvideAnnotation,
  431. InjectAnnotation,
  432. TransientScopeAnnotation,
  433. isFunction,
  434. isObject,
  435. toString,
  436. profileInjector,
  437. createProviderFromFnOrClass,
  438. createProviderFromValue,
  439. Injector;
  440. function constructResolvingMessage(resolving, token) {
  441. if (arguments.length > 1) {
  442. resolving.push(token);
  443. }
  444. if (resolving.length > 1) {
  445. return (" (" + resolving.map(toString).join(' -> ') + ")");
  446. }
  447. return '';
  448. }
  449. return {
  450. setters: [function($__m) {
  451. annotate = $__m.annotate;
  452. readAnnotations = $__m.readAnnotations;
  453. hasAnnotation = $__m.hasAnnotation;
  454. hasParameterAnnotation = $__m.hasParameterAnnotation;
  455. ProvideAnnotation = $__m.Provide;
  456. InjectAnnotation = $__m.Inject;
  457. TransientScopeAnnotation = $__m.TransientScope;
  458. }, function($__m) {
  459. isFunction = $__m.isFunction;
  460. isObject = $__m.isObject;
  461. toString = $__m.toString;
  462. }, function($__m) {
  463. profileInjector = $__m.profileInjector;
  464. }, function($__m) {
  465. createProviderFromFnOrClass = $__m.createProviderFromFnOrClass;
  466. createProviderFromValue = $__m.createProviderFromValue;
  467. }],
  468. execute: function() {
  469. Injector = (function() {
  470. var Injector = function Injector() {
  471. var modules = arguments[0] !== (void 0) ? arguments[0] : [];
  472. var parentInjector = arguments[1] !== (void 0) ? arguments[1] : null;
  473. var providers = arguments[2] !== (void 0) ? arguments[2] : new Map();
  474. this.cache = new Map();
  475. this.providers = providers;
  476. this.parent = parentInjector;
  477. this._loadModules(modules);
  478. profileInjector(this, Injector);
  479. };
  480. return ($traceurRuntime.createClass)(Injector, {
  481. _collectProvidersWithAnnotation: function(annotationClass, collectedProviders) {
  482. this.providers.forEach((function(provider, token) {
  483. if (!collectedProviders.has(token) && hasAnnotation(provider.provider, annotationClass)) {
  484. collectedProviders.set(token, provider);
  485. }
  486. }));
  487. if (this.parent) {
  488. this.parent._collectProvidersWithAnnotation(annotationClass, collectedProviders);
  489. }
  490. },
  491. _loadModules: function(modules) {
  492. for (var $__2 = modules[$traceurRuntime.toProperty(Symbol.iterator)](),
  493. $__3 = void 0; !($__3 = $__2.next()).done; ) {
  494. var module = $__3.value;
  495. {
  496. if (isFunction(module)) {
  497. this._loadFnOrClass(module);
  498. continue;
  499. }
  500. throw new Error('Invalid module!');
  501. }
  502. }
  503. },
  504. _loadFnOrClass: function(fnOrClass) {
  505. var annotations = readAnnotations(fnOrClass);
  506. var token = annotations.provide.token || fnOrClass;
  507. var provider = createProviderFromFnOrClass(fnOrClass, annotations);
  508. this.providers.set(token, provider);
  509. },
  510. _hasProviderFor: function(token) {
  511. if (this.providers.has(token)) {
  512. return true;
  513. }
  514. if (this.parent) {
  515. return this.parent._hasProviderFor(token);
  516. }
  517. return false;
  518. },
  519. get: function(token) {
  520. var resolving = arguments[1] !== (void 0) ? arguments[1] : [];
  521. var wantPromise = arguments[2] !== (void 0) ? arguments[2] : false;
  522. var wantLazy = arguments[3] !== (void 0) ? arguments[3] : false;
  523. var $__0 = this;
  524. var resolvingMsg = '';
  525. var provider;
  526. var instance;
  527. var injector = this;
  528. if (token === null || token === undefined) {
  529. resolvingMsg = constructResolvingMessage(resolving, token);
  530. throw new Error(("Invalid token \"" + token + "\" requested!" + resolvingMsg));
  531. }
  532. if (token === Injector) {
  533. if (wantPromise) {
  534. return Promise.resolve(this);
  535. }
  536. return this;
  537. }
  538. if (wantLazy) {
  539. return function createLazyInstance() {
  540. var lazyInjector = injector;
  541. if (arguments.length) {
  542. var locals = [];
  543. var args = arguments;
  544. for (var i = 0; i < args.length; i += 2) {
  545. locals.push((function(ii) {
  546. var fn = function createLocalInstance() {
  547. return args[ii + 1];
  548. };
  549. annotate(fn, new InjectAnnotation());
  550. annotate(fn, new ProvideAnnotation(args[ii]));
  551. return fn;
  552. })(i));
  553. }
  554. lazyInjector = injector.createChild(locals);
  555. }
  556. return lazyInjector.get(token, resolving, wantPromise, false);
  557. };
  558. }
  559. if (this.cache.has(token)) {
  560. instance = this.cache.get(token);
  561. provider = this.providers.get(token);
  562. if (provider.isPromise && !wantPromise) {
  563. resolvingMsg = constructResolvingMessage(resolving, token);
  564. throw new Error(("Cannot instantiate " + toString(token) + " synchronously. It is provided as a promise!" + resolvingMsg));
  565. }
  566. if (!provider.isPromise && wantPromise) {
  567. return Promise.resolve(instance);
  568. }
  569. return instance;
  570. }
  571. provider = this.providers.get(token);
  572. if (!provider && !this._hasProviderFor(token)) {
  573. if (isFunction(token) && (hasAnnotation(token, InjectAnnotation)) || hasParameterAnnotation(token, InjectAnnotation)) {
  574. provider = createProviderFromFnOrClass(token, readAnnotations(token));
  575. this.providers.set(token, provider);
  576. } else if (isFunction(token) || isObject(token)) {
  577. provider = createProviderFromValue(token);
  578. this.providers.set(token, provider);
  579. }
  580. }
  581. if (!provider) {
  582. if (!this.parent) {
  583. resolvingMsg = constructResolvingMessage(resolving, token);
  584. throw new Error(("No provider for " + toString(token) + "!" + resolvingMsg));
  585. }
  586. return this.parent.get(token, resolving, wantPromise, wantLazy);
  587. }
  588. if (resolving.indexOf(token) !== -1) {
  589. resolvingMsg = constructResolvingMessage(resolving, token);
  590. throw new Error(("Cannot instantiate cyclic dependency!" + resolvingMsg));
  591. }
  592. resolving.push(token);
  593. var delayingInstantiation = wantPromise && provider.params.some((function(param) {
  594. return !param.isPromise;
  595. }));
  596. var args = provider.params.map((function(param) {
  597. if (delayingInstantiation) {
  598. return $__0.get(param.token, resolving, true, param.isLazy);
  599. }
  600. return $__0.get(param.token, resolving, param.isPromise, param.isLazy);
  601. }));
  602. if (delayingInstantiation) {
  603. var delayedResolving = resolving.slice();
  604. resolving.pop();
  605. return Promise.all(args).then(function(args) {
  606. try {
  607. instance = provider.create(args);
  608. } catch (e) {
  609. resolvingMsg = constructResolvingMessage(delayedResolving);
  610. var originalMsg = 'ORIGINAL ERROR: ' + e.message;
  611. e.message = ("Error during instantiation of " + toString(token) + "!" + resolvingMsg + "\n" + originalMsg);
  612. throw e;
  613. }
  614. if (!hasAnnotation(provider.provider, TransientScopeAnnotation)) {
  615. injector.cache.set(token, instance);
  616. }
  617. return instance;
  618. });
  619. }
  620. try {
  621. instance = provider.create(args);
  622. } catch (e) {
  623. resolvingMsg = constructResolvingMessage(resolving);
  624. var originalMsg = 'ORIGINAL ERROR: ' + e.message;
  625. e.message = ("Error during instantiation of " + toString(token) + "!" + resolvingMsg + "\n" + originalMsg);
  626. throw e;
  627. }
  628. if (!hasAnnotation(provider.provider, TransientScopeAnnotation)) {
  629. this.cache.set(token, instance);
  630. }
  631. if (!wantPromise && provider.isPromise) {
  632. resolvingMsg = constructResolvingMessage(resolving);
  633. throw new Error(("Cannot instantiate " + toString(token) + " synchronously. It is provided as a promise!" + resolvingMsg));
  634. }
  635. if (wantPromise && !provider.isPromise) {
  636. instance = Promise.resolve(instance);
  637. }
  638. resolving.pop();
  639. return instance;
  640. },
  641. getPromise: function(token) {
  642. return this.get(token, [], true);
  643. },
  644. createChild: function() {
  645. var modules = arguments[0] !== (void 0) ? arguments[0] : [];
  646. var forceNewInstancesOf = arguments[1] !== (void 0) ? arguments[1] : [];
  647. var forcedProviders = new Map();
  648. for (var $__2 = forceNewInstancesOf[$traceurRuntime.toProperty(Symbol.iterator)](),
  649. $__3 = void 0; !($__3 = $__2.next()).done; ) {
  650. var annotation = $__3.value;
  651. {
  652. this._collectProvidersWithAnnotation(annotation, forcedProviders);
  653. }
  654. }
  655. return new Injector(modules, this, forcedProviders);
  656. }
  657. }, {});
  658. }());
  659. $__export("Injector", Injector);
  660. }
  661. };
  662. });
  663.  
  664. System.register("jiff/di/decorators", ["./annotations"], function($__export) {
  665. "use strict";
  666. var __moduleName = "jiff/di/decorators";
  667. var di,
  668. Inject,
  669. Provide;
  670. return {
  671. setters: [function($__m) {
  672. di = $__m;
  673. }],
  674. execute: function() {
  675. Inject = (function() {
  676. for (var dependencies = [],
  677. $__0 = 0; $__0 < arguments.length; $__0++)
  678. dependencies[$__0] = arguments[$__0];
  679. return (function(classDef) {
  680. di.annotate(classDef, new (Function.prototype.bind.apply(di.Inject, $traceurRuntime.spread([null], dependencies)))());
  681. });
  682. });
  683. Provide = (function(targetClassDef) {
  684. return (function(classDef) {
  685. di.annotate(classDef, new di.Provide(targetClassDef));
  686. });
  687. });
  688. $__export("Provide", Provide), $__export("Inject", Inject);
  689. }
  690. };
  691. });
  692.  
  693. System.register("jiff/di", ["./di/decorators", "./di/injector"], function($__export) {
  694. "use strict";
  695. var __moduleName = "jiff/di";
  696. var $__exportNames = {};
  697. var $__exportNames = {};
  698. return {
  699. setters: [function($__m) {
  700. Object.keys($__m).forEach(function(p) {
  701. if (!$__exportNames[p])
  702. $__export(p, $__m[p]);
  703. });
  704. }, function($__m) {
  705. Object.keys($__m).forEach(function(p) {
  706. if (!$__exportNames[p])
  707. $__export(p, $__m[p]);
  708. });
  709. }],
  710. execute: function() {}
  711. };
  712. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement