a zip code crypto-currency system good for red ONLY

module-loader.js 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { Injectable, InjectionToken, Injector } from '@angular/core';
  2. import { NgModuleLoader } from './ng-module-loader';
  3. import { requestIonicCallback } from './util';
  4. export var LAZY_LOADED_TOKEN = new InjectionToken('LZYCMP');
  5. /**
  6. * @hidden
  7. */
  8. var ModuleLoader = (function () {
  9. function ModuleLoader(_ngModuleLoader, _injector) {
  10. this._ngModuleLoader = _ngModuleLoader;
  11. this._injector = _injector;
  12. /** @internal */
  13. this._cfrMap = new Map();
  14. this._promiseMap = new Map();
  15. }
  16. ModuleLoader.prototype.load = function (modulePath) {
  17. var _this = this;
  18. (void 0) /* console.time */;
  19. var splitString = modulePath.split(SPLITTER);
  20. var promise = this._promiseMap.get(modulePath);
  21. if (!promise) {
  22. promise = this._ngModuleLoader.load(splitString[0], splitString[1]);
  23. this._promiseMap.set(modulePath, promise);
  24. }
  25. return promise.then(function (loadedModule) {
  26. (void 0) /* console.timeEnd */;
  27. var ref = loadedModule.create(_this._injector);
  28. var component = ref.injector.get(LAZY_LOADED_TOKEN);
  29. _this._cfrMap.set(component, ref.componentFactoryResolver);
  30. return {
  31. componentFactoryResolver: ref.componentFactoryResolver,
  32. component: component
  33. };
  34. });
  35. };
  36. ModuleLoader.prototype.getComponentFactoryResolver = function (component) {
  37. return this._cfrMap.get(component);
  38. };
  39. ModuleLoader.decorators = [
  40. { type: Injectable },
  41. ];
  42. /** @nocollapse */
  43. ModuleLoader.ctorParameters = function () { return [
  44. { type: NgModuleLoader, },
  45. { type: Injector, },
  46. ]; };
  47. return ModuleLoader;
  48. }());
  49. export { ModuleLoader };
  50. var SPLITTER = '#';
  51. /**
  52. * @hidden
  53. */
  54. export function provideModuleLoader(ngModuleLoader, injector) {
  55. return new ModuleLoader(ngModuleLoader, injector);
  56. }
  57. /**
  58. * @hidden
  59. */
  60. export function setupPreloadingImplementation(config, deepLinkConfig, moduleLoader) {
  61. if (!deepLinkConfig || !deepLinkConfig.links || !config.getBoolean('preloadModules')) {
  62. return Promise.resolve();
  63. }
  64. var linksToLoad = deepLinkConfig.links.filter(function (link) { return !!link.loadChildren && link.priority !== 'off'; });
  65. // Load the high priority modules first
  66. var highPriorityPromises = linksToLoad
  67. .filter(function (link) { return link.priority === 'high'; })
  68. .map(function (link) { return moduleLoader.load(link.loadChildren); });
  69. return Promise.all(highPriorityPromises).then(function () {
  70. // Load the low priority modules after the high priority are done
  71. var lowPriorityPromises = linksToLoad
  72. .filter(function (link) { return link.priority === 'low'; })
  73. .map(function (link) { return moduleLoader.load(link.loadChildren); });
  74. return Promise.all(lowPriorityPromises);
  75. }).catch(function (err) {
  76. console.error(err.message);
  77. });
  78. }
  79. /**
  80. * @hidden
  81. */
  82. export function setupPreloading(config, deepLinkConfig, moduleLoader, ngZone) {
  83. return function () {
  84. requestIonicCallback(function () {
  85. ngZone.runOutsideAngular(function () {
  86. setupPreloadingImplementation(config, deepLinkConfig, moduleLoader);
  87. });
  88. });
  89. };
  90. }
  91. //# sourceMappingURL=module-loader.js.map