angular2-platform-node
Advanced tools
Comparing version 1.0.6 to 2.0.0
@@ -148,3 +148,3 @@ "use strict"; | ||
__param(3, core_1.Optional()), | ||
__param(3, core_1.Inject(tokens_1.BASE_URL)), | ||
__param(3, core_1.Inject(tokens_1.APP_BASE_HREF)), | ||
__metadata('design:paramtypes', [http_1.Request, http_1.ResponseOptions, String, String]) | ||
@@ -167,3 +167,3 @@ ], NodeConnection); | ||
core_1.Injectable(), | ||
__param(2, core_1.Inject(tokens_1.BASE_URL)), | ||
__param(2, core_1.Inject(tokens_1.APP_BASE_HREF)), | ||
__param(3, core_1.Inject(tokens_1.ORIGIN_URL)), | ||
@@ -255,3 +255,3 @@ __metadata('design:paramtypes', [http_1.ResponseOptions, core_1.NgZone, String, String]) | ||
__param(4, core_1.Optional()), | ||
__param(4, core_1.Inject(tokens_1.BASE_URL)), | ||
__param(4, core_1.Inject(tokens_1.APP_BASE_HREF)), | ||
__metadata('design:paramtypes', [http_1.Request, http_1.ResponseOptions, core_1.NgZone, String, String]) | ||
@@ -284,3 +284,3 @@ ], NodeJSONPConnection); | ||
core_1.Injectable(), | ||
__param(2, core_1.Inject(tokens_1.BASE_URL)), | ||
__param(2, core_1.Inject(tokens_1.APP_BASE_HREF)), | ||
__param(3, core_1.Inject(tokens_1.ORIGIN_URL)), | ||
@@ -323,3 +323,3 @@ __metadata('design:paramtypes', [http_1.ResponseOptions, core_1.NgZone, String, String]) | ||
if (config.baseUrl) { | ||
providers.push({ provide: tokens_1.BASE_URL, useValue: config.baseUrl }); | ||
providers.push({ provide: tokens_1.APP_BASE_HREF, useValue: config.baseUrl }); | ||
} | ||
@@ -357,3 +357,3 @@ if (config.requestUrl) { | ||
if (config.baseUrl) { | ||
providers.push({ provide: tokens_1.BASE_URL, useValue: config.baseUrl }); | ||
providers.push({ provide: tokens_1.APP_BASE_HREF, useValue: config.baseUrl }); | ||
} | ||
@@ -360,0 +360,0 @@ if (config.requestUrl) { |
import { EventManager } from '@angular/platform-browser'; | ||
import { Injector, PlatformRef, NgModuleRef, NgZone } from '@angular/core'; | ||
import { Injector, OpaqueToken, PlatformRef, NgModuleRef, NgZone } from '@angular/core'; | ||
import { NodeSharedStylesHost } from './node-shared-styles-host'; | ||
export declare function _document(domSharedStylesHost: NodeSharedStylesHost, config: any): any; | ||
export declare function _document(domSharedStylesHost: NodeSharedStylesHost, zone: any): any; | ||
export declare function removePlatformRef(): void; | ||
@@ -50,10 +50,19 @@ export declare function getPlatformRef(): PlatformRef; | ||
} | ||
export declare function _APP_BASE_HREF(zone: any): any; | ||
export declare function _REQUEST_URL(zone: any): any; | ||
export declare function _ORIGIN_URL(zone: any): any; | ||
export declare class NodeModule { | ||
static forRoot(document: string, config?: any): { | ||
ngModule: typeof NodeModule; | ||
providers: any[]; | ||
providers: { | ||
provide: OpaqueToken; | ||
useValue: string; | ||
}[]; | ||
}; | ||
static withConfig(config?: any): { | ||
ngModule: typeof NodeModule; | ||
providers: any[]; | ||
providers: { | ||
provide: OpaqueToken; | ||
useValue: string; | ||
}[]; | ||
}; | ||
@@ -60,0 +69,0 @@ constructor(parentModule: NodeModule); |
@@ -31,8 +31,9 @@ "use strict"; | ||
exports._errorHandler = _errorHandler; | ||
var _documentDeps = [node_shared_styles_host_1.NodeSharedStylesHost, tokens_1.UNIVERSAL_CONFIG]; | ||
function _document(domSharedStylesHost, config) { | ||
if (!config.document) { | ||
var _documentDeps = [node_shared_styles_host_1.NodeSharedStylesHost, core_1.NgZone]; | ||
function _document(domSharedStylesHost, zone) { | ||
var document = Zone.current.get('document'); | ||
if (!document) { | ||
throw new Error('Please provide a document in the universal config'); | ||
} | ||
var doc = node_document_1.parseDocument(config.document); | ||
var doc = node_document_1.parseDocument(document); | ||
domSharedStylesHost.addHost(doc.head); | ||
@@ -121,3 +122,3 @@ return doc; | ||
set: function (key, value, defaultValue) { | ||
_map.set(key, value || defaultValue); | ||
_map.set(key, (value !== undefined) ? value : defaultValue); | ||
}, | ||
@@ -134,3 +135,3 @@ get: function (key, defaultValue) { | ||
function errorHandler(err, store, modRef, currentIndex, currentArray) { | ||
var document = store.get('UNIVERSAL_CONFIG').document; | ||
var document = store.get('DOCUMENT'); | ||
_store && _store.clear(); | ||
@@ -151,3 +152,3 @@ return document; | ||
store.set('NgZone', modInjector.get(core_1.NgZone)); | ||
store.set('UNIVERSAL_CONFIG', modInjector.get(tokens_1.UNIVERSAL_CONFIG, {})); | ||
store.set('preboot', config.preboot, false); | ||
store.set('APP_ID', modInjector.get(core_1.APP_ID, null)); | ||
@@ -161,3 +162,2 @@ store.set('DOCUMENT', modInjector.get(platform_browser_1.DOCUMENT)); | ||
config.time && console.time('id: ' + config.id + ' stable: '); | ||
var UNIVERSAL_CONFIG = store.get('UNIVERSAL_CONFIG'); | ||
var universalDoCheck = store.get('universalDoCheck'); | ||
@@ -169,3 +169,3 @@ var universalOnInit = store.get('universalOnInit'); | ||
universalOnInit(); | ||
function outsideNg(compRef, ngZone, config, http, jsonp) { | ||
function outsideNg(compRef, ngZone, http, jsonp) { | ||
function checkStable(done, ref) { | ||
@@ -187,3 +187,3 @@ ngZone.runOutsideAngular(function () { | ||
if (ngZone.isStable === true) { | ||
var isStable = universalDoCheck(ref, ngZone, config); | ||
var isStable = universalDoCheck(ref, ngZone); | ||
if (universalDoCheck !== NodePlatform._noop) { | ||
@@ -216,3 +216,3 @@ if (typeof isStable !== 'boolean') { | ||
var jsonp = cmpInjector.get(http_1.Jsonp, null); | ||
return rootNgZone.runOutsideAngular(outsideNg.bind(null, compRef, ngZone, UNIVERSAL_CONFIG, http, jsonp)); | ||
return rootNgZone.runOutsideAngular(outsideNg.bind(null, compRef, ngZone, http, jsonp)); | ||
}); | ||
@@ -228,4 +228,4 @@ return rootNgZone.runOutsideAngular(function () { | ||
function injectPreboot(store, moduleRef) { | ||
var UNIVERSAL_CONFIG = store.get('UNIVERSAL_CONFIG'); | ||
if (typeof UNIVERSAL_CONFIG.preboot === 'boolean' && !UNIVERSAL_CONFIG.preboot) { | ||
var preboot = store.get('preboot'); | ||
if (typeof preboot === 'boolean' && !preboot) { | ||
return moduleRef; | ||
@@ -242,3 +242,3 @@ } | ||
var prebootConfig = null; | ||
var key = (typeof UNIVERSAL_CONFIG.preboot === 'object') && JSON.stringify(UNIVERSAL_CONFIG.preboot) || null; | ||
var key = (typeof preboot === 'object') && JSON.stringify(preboot) || null; | ||
var prebootEl = null; | ||
@@ -256,3 +256,3 @@ var el = null; | ||
catch (e) { | ||
prebootConfig = UNIVERSAL_CONFIG.preboot; | ||
prebootConfig = preboot; | ||
} | ||
@@ -524,2 +524,14 @@ if (!prebootConfig.appRoot) { | ||
exports.NodeDomEventsPlugin = NodeDomEventsPlugin; | ||
function _APP_BASE_HREF(zone) { | ||
return Zone.current.get('baseUrl'); | ||
} | ||
exports._APP_BASE_HREF = _APP_BASE_HREF; | ||
function _REQUEST_URL(zone) { | ||
return Zone.current.get('requestUrl'); | ||
} | ||
exports._REQUEST_URL = _REQUEST_URL; | ||
function _ORIGIN_URL(zone) { | ||
return Zone.current.get('originUrl'); | ||
} | ||
exports._ORIGIN_URL = _ORIGIN_URL; | ||
var NodeModule = (function () { | ||
@@ -541,5 +553,3 @@ function NodeModule(parentModule) { | ||
ngModule: NodeModule, | ||
providers: [ | ||
{ provide: tokens_1.UNIVERSAL_CONFIG, useValue: config } | ||
].concat(providers) | ||
providers: providers.slice() | ||
}; | ||
@@ -550,3 +560,2 @@ }; | ||
providers: [ | ||
{ provide: tokens_1.UNIVERSAL_CONFIG, useValue: {} }, | ||
{ provide: common_1.PlatformLocation, useClass: node_location_1.NodePlatformLocation }, | ||
@@ -570,2 +579,5 @@ __private_imports__1.BROWSER_SANITIZATION_PROVIDERS, | ||
{ provide: __private_imports__1.DomSharedStylesHost, useExisting: node_shared_styles_host_1.NodeSharedStylesHost }, | ||
{ provide: common_1.APP_BASE_HREF, useFactory: _APP_BASE_HREF, deps: [core_1.NgZone] }, | ||
{ provide: tokens_1.REQUEST_URL, useFactory: _REQUEST_URL, deps: [core_1.NgZone] }, | ||
{ provide: tokens_1.ORIGIN_URL, useFactory: _ORIGIN_URL, deps: [core_1.NgZone] } | ||
], | ||
@@ -572,0 +584,0 @@ exports: [common_1.CommonModule, core_1.ApplicationModule] |
@@ -49,3 +49,3 @@ { | ||
], | ||
"version": "1.0.6", | ||
"version": "2.0.0", | ||
"homepage": "https://github.com/angular/universal", | ||
@@ -52,0 +52,0 @@ "license": "MIT", |
import { OpaqueToken } from '@angular/core'; | ||
export declare const BASE_URL: OpaqueToken; | ||
export { APP_BASE_HREF } from '@angular/common'; | ||
export declare const ORIGIN_URL: OpaqueToken; | ||
@@ -8,2 +8,1 @@ export declare const REQUEST_URL: OpaqueToken; | ||
export declare const NODE_APP_ID: OpaqueToken; | ||
export declare const UNIVERSAL_CONFIG: OpaqueToken; |
"use strict"; | ||
var core_1 = require('@angular/core'); | ||
var common_1 = require('@angular/common'); | ||
exports.BASE_URL = common_1.APP_BASE_HREF; | ||
var common_2 = require('@angular/common'); | ||
exports.APP_BASE_HREF = common_2.APP_BASE_HREF; | ||
exports.ORIGIN_URL = new core_1.OpaqueToken('ORIGIN_URL'); | ||
@@ -10,6 +11,4 @@ exports.REQUEST_URL = new core_1.OpaqueToken('REQUEST_URL'); | ||
exports.NODE_APP_ID = new core_1.OpaqueToken('NODE_APP_ID'); | ||
exports.UNIVERSAL_CONFIG = new core_1.OpaqueToken('UNIVERSAL_CONFIG'); | ||
function getUrlConfig() { | ||
return [ | ||
{ provide: exports.BASE_URL, useValue: 'baseUrl' }, | ||
{ provide: common_1.APP_BASE_HREF, useValue: 'baseUrl' }, | ||
@@ -22,13 +21,10 @@ { provide: exports.REQUEST_URL, useValue: 'requestUrl' }, | ||
function createUrlProviders(config) { | ||
var providers = getUrlConfig() | ||
.reduce(function (memo, provider) { | ||
return getUrlConfig() | ||
.filter(function (provider) { return (provider.useValue in config); }) | ||
.map(function (provider) { | ||
var key = provider.useValue; | ||
if (key in config) { | ||
provider.useValue = config[key]; | ||
memo.push(provider); | ||
} | ||
return memo; | ||
}, []); | ||
return providers; | ||
provider.useValue = config[key]; | ||
return provider; | ||
}); | ||
} | ||
exports.createUrlProviders = createUrlProviders; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143089
3451