angular2-platform-node
Advanced tools
Comparing version 2.0.7 to 2.0.8
@@ -0,2 +1,3 @@ | ||
export { BROWSER_SANITIZATION_PROVIDERS, SharedStylesHost, DomSharedStylesHost, DomRootRenderer, DomEventsPlugin, DomAdapter, setRootDomAdapter, KeyEventsPlugin, getDOM, HammerGesturesPlugin, SelectorMatcher, CssSelector, ViewUtils, AnimationKeyframe, AnimationPlayer, AnimationStyles, RenderDebugInfo }; | ||
declare var __empty: any; | ||
export default __empty; |
@@ -103,3 +103,3 @@ "use strict"; | ||
var k2 = Object.keys(m2); | ||
if (k1.length != k2.length) { | ||
if (k1.length !== k2.length) { | ||
return false; | ||
@@ -106,0 +106,0 @@ } |
@@ -0,1 +1,2 @@ | ||
export { getDOM } from './__private_imports__'; | ||
export * from './helper'; | ||
@@ -2,0 +3,0 @@ export * from './node-document'; |
@@ -5,2 +5,4 @@ "use strict"; | ||
} | ||
var __private_imports__1 = require('./__private_imports__'); | ||
exports.getDOM = __private_imports__1.getDOM; | ||
__export(require('./helper')); | ||
@@ -7,0 +9,0 @@ __export(require('./node-document')); |
@@ -212,2 +212,5 @@ "use strict"; | ||
try { | ||
if (body.indexOf('JSONP_CALLBACK') === -1) { | ||
throw new Error('Http request ' + req.url + ' did not return the response with JSONP_CALLBACK()'); | ||
} | ||
var responseFactory = new Function('JSONP_CALLBACK', body); | ||
@@ -220,3 +223,3 @@ responseFactory(function (json) { | ||
console.log('JSONP Error:', e); | ||
throw e; | ||
return onError(e); | ||
} | ||
@@ -234,3 +237,3 @@ var responseOptions = new http_1.ResponseOptions({ body: responseJson, status: status, headers: headers, url: url }); | ||
}); | ||
var onError = function (err) { | ||
function onError(err) { | ||
var responseOptions = new http_1.ResponseOptions({ body: err, type: http_1.ResponseType.Error }); | ||
@@ -240,6 +243,5 @@ if (helper_1.isPresent(baseResponseOptions)) { | ||
} | ||
ngZone.run(function () { | ||
responseObserver.error(new http_1.Response(responseOptions)); | ||
}); | ||
}; | ||
responseObserver.error(new http_1.Response(responseOptions)); | ||
} | ||
; | ||
nodeReq.on('error', onError); | ||
@@ -246,0 +248,0 @@ nodeReq.end(); |
@@ -14,2 +14,3 @@ import { EventManager } from '@angular/platform-browser'; | ||
constructor(_platformRef: PlatformRef); | ||
cacheModuleFactory<T>(moduleType: any, compilerOptions?: any): Promise<NgModuleRef<T>>; | ||
serializeModule<T>(ModuleType: any, config?: any): Promise<T>; | ||
@@ -19,3 +20,3 @@ serializeModuleFactory<T>(ModuleType: any, config?: any): Promise<T> | T; | ||
readonly injector: Injector; | ||
bootstrapModule<T>(moduleType: any, compilerOptions: any): Promise<NgModuleRef<T>>; | ||
bootstrapModule<T>(moduleType: any, compilerOptions?: any): Promise<NgModuleRef<T>>; | ||
bootstrapModuleFactory<T>(moduleFactory: any): Promise<NgModuleRef<T>>; | ||
@@ -22,0 +23,0 @@ readonly disposed: boolean; |
@@ -37,5 +37,7 @@ "use strict"; | ||
} | ||
var doc = node_document_1.parseDocument(document); | ||
domSharedStylesHost.addHost(doc.head); | ||
return doc; | ||
if (typeof document === 'string') { | ||
document = node_document_1.parseDocument(document); | ||
} | ||
domSharedStylesHost.addHost(document.head); | ||
return document; | ||
} | ||
@@ -77,2 +79,20 @@ exports._document = _document; | ||
}); | ||
NodePlatform.prototype.cacheModuleFactory = function (moduleType, compilerOptions) { | ||
if (NodePlatform._cache.has(moduleType)) { | ||
return Promise.resolve(NodePlatform._cache.get(moduleType)); | ||
} | ||
var compilerFactory = this._platformRef.injector.get(core_1.CompilerFactory); | ||
var compiler; | ||
if (compilerOptions) { | ||
compiler = compilerFactory.createCompiler(compilerOptions instanceof Array ? compilerOptions : [compilerOptions]); | ||
} | ||
else { | ||
compiler = compilerFactory.createCompiler(); | ||
} | ||
return compiler.compileModuleAsync(moduleType) | ||
.then(function (moduleFactory) { | ||
NodePlatform._cache.set(moduleType, moduleFactory); | ||
return moduleFactory; | ||
}); | ||
}; | ||
NodePlatform.prototype.serializeModule = function (ModuleType, config) { | ||
@@ -86,3 +106,6 @@ var _this = this; | ||
config.time && console.time('id: ' + config.id + ' ngApp: '); | ||
return this.platformRef.bootstrapModule(ModuleType, config.compilerOptions) | ||
return (config.compilerOptions ? | ||
this.bootstrapModule(ModuleType, config.compilerOptions) | ||
: | ||
this.bootstrapModule(ModuleType)) | ||
.then(function (moduleRef) { | ||
@@ -105,3 +128,3 @@ config.time && console.timeEnd('id: ' + config.id + ' bootstrapModule: '); | ||
config.time && console.time('id: ' + config.id + ' ngApp: '); | ||
return this.platformRef.bootstrapModuleFactory(ModuleType) | ||
return this.bootstrapModuleFactory(ModuleType) | ||
.then(function (moduleRef) { | ||
@@ -155,2 +178,3 @@ config.time && console.timeEnd('id: ' + config.id + ' bootstrapModuleFactory: '); | ||
store.set('APP_ID', modInjector.get(core_1.APP_ID, null)); | ||
store.set('NODE_APP_ID', s4()); | ||
store.set('DOCUMENT', modInjector.get(platform_browser_1.DOCUMENT)); | ||
@@ -203,3 +227,3 @@ store.set('DOM', __private_imports__1.getDOM()); | ||
return checkStable(done, ref); | ||
}, 1); | ||
}, 0); | ||
}); | ||
@@ -230,4 +254,9 @@ } | ||
var preboot = store.get('preboot'); | ||
if (typeof preboot === 'boolean' && !preboot) { | ||
return moduleRef; | ||
if (typeof preboot === 'boolean') { | ||
if (!preboot) { | ||
return moduleRef; | ||
} | ||
else { | ||
preboot = {}; | ||
} | ||
} | ||
@@ -297,3 +326,3 @@ config.time && console.time('id: ' + config.id + ' preboot: '); | ||
config.time && console.time('id: ' + config.id + ' universal cache: '); | ||
var appId = store.get('APP_ID', null); | ||
var appId = store.get('NODE_APP_ID', null); | ||
var UNIVERSAL_CACHE = store.get('UNIVERSAL_CACHE'); | ||
@@ -347,2 +376,3 @@ var universalDoDehydrate = store.get('universalDoDehydrate'); | ||
var document = store.get('DOCUMENT'); | ||
var appId = store.get('NODE_APP_ID'); | ||
var appRef = store.get('ApplicationRef'); | ||
@@ -352,3 +382,3 @@ var html = null; | ||
var destroyModule = null; | ||
html = node_document_1.serializeDocument(document); | ||
html = node_document_1.serializeDocument(document).replace(/%cmp%/g, appId); | ||
universalOnRendered(html); | ||
@@ -386,3 +416,19 @@ document = null; | ||
NodePlatform.prototype.bootstrapModule = function (moduleType, compilerOptions) { | ||
return this.platformRef.bootstrapModule(moduleType, compilerOptions); | ||
var _this = this; | ||
if (NodePlatform._cache.has(moduleType)) { | ||
return this.platformRef.bootstrapModuleFactory(NodePlatform._cache.get(moduleType)); | ||
} | ||
var compilerFactory = this._platformRef.injector.get(core_1.CompilerFactory); | ||
var compiler; | ||
if (compilerOptions) { | ||
compiler = compilerFactory.createCompiler(compilerOptions instanceof Array ? compilerOptions : [compilerOptions]); | ||
} | ||
else { | ||
compiler = compilerFactory.createCompiler(); | ||
} | ||
return compiler.compileModuleAsync(moduleType) | ||
.then(function (moduleFactory) { | ||
NodePlatform._cache.set(moduleType, moduleFactory); | ||
return _this.platformRef.bootstrapModuleFactory(moduleFactory); | ||
}); | ||
}; | ||
@@ -439,3 +485,3 @@ NodePlatform.prototype.bootstrapModuleFactory = function (moduleFactory) { | ||
} | ||
}, timer); | ||
}, 0); | ||
}); | ||
@@ -584,3 +630,4 @@ }).catch(function (err) { | ||
{ provide: tokens_1.REQUEST_URL, useFactory: _REQUEST_URL, deps: [core_1.NgZone] }, | ||
{ provide: tokens_1.ORIGIN_URL, useFactory: _ORIGIN_URL, deps: [core_1.NgZone] } | ||
{ provide: tokens_1.ORIGIN_URL, useFactory: _ORIGIN_URL, deps: [core_1.NgZone] }, | ||
{ provide: core_1.APP_ID, useValue: '%cmp%' }, | ||
], | ||
@@ -587,0 +634,0 @@ exports: [common_1.CommonModule, core_1.ApplicationModule] |
@@ -420,2 +420,5 @@ "use strict"; | ||
} | ||
if ((propertyName === 'autofocus' || propertyName === 'spellcheck') && propertyValue === false) { | ||
return; | ||
} | ||
var setProp = _super.prototype.setElementProperty.call(this, renderElement, propertyName, propertyValue); | ||
@@ -422,0 +425,0 @@ if (exports.IGNORE_ATTRIBUTES[propertyName]) { |
@@ -49,3 +49,3 @@ { | ||
], | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"homepage": "https://github.com/angular/universal", | ||
@@ -52,0 +52,0 @@ "license": "MIT", |
@@ -88,3 +88,3 @@ import { DomAdapter } from './__private_imports__'; | ||
getTitle(): string; | ||
setTitle(newTitle: string): void; | ||
setTitle(newTitle: string): string; | ||
isTemplateElement(el: any): boolean; | ||
@@ -123,4 +123,4 @@ isTextNode(node: any): boolean; | ||
getCookie(name: string): string; | ||
setCookie(name: string, value: string): void; | ||
setCookie(name: string, value: string): string; | ||
animate(element: any, keyframes: any[], options: any): any; | ||
} |
@@ -61,3 +61,6 @@ "use strict"; | ||
Parse5DomAdapter.prototype.querySelector = function (el, selector) { | ||
return this.querySelectorAll(el, selector)[0]; | ||
console.time('querySelector' + selector); | ||
var $el = this.querySelectorAll(el, selector)[0]; | ||
console.timeEnd('querySelector' + selector); | ||
return $el; | ||
}; | ||
@@ -504,2 +507,6 @@ Parse5DomAdapter.prototype.querySelectorAll = function (el, selector) { | ||
Parse5DomAdapter.prototype.defaultDoc = function () { | ||
var document = Zone.current.get('document'); | ||
if (document) { | ||
return document; | ||
} | ||
return { documentMode: false }; | ||
@@ -511,5 +518,13 @@ }; | ||
Parse5DomAdapter.prototype.getTitle = function () { | ||
var document = Zone.current.get('document'); | ||
if (document && document.title) { | ||
return document.title; | ||
} | ||
throw _notImplemented('getTitle'); | ||
}; | ||
Parse5DomAdapter.prototype.setTitle = function (newTitle) { | ||
var document = Zone.current.get('document'); | ||
if (document && document.title) { | ||
return document.title = newTitle; | ||
} | ||
throw _notImplemented('setTitle'); | ||
@@ -628,5 +643,13 @@ }; | ||
Parse5DomAdapter.prototype.getCookie = function (name) { | ||
var document = Zone.current.get('document'); | ||
if (document && document.cookie) { | ||
return document.cookie; | ||
} | ||
throw _notImplemented('Parse5DomAdapter#getCookie'); | ||
}; | ||
Parse5DomAdapter.prototype.setCookie = function (name, value) { | ||
var document = Zone.current.get('document'); | ||
if (document && document.cookie) { | ||
return document.cookie[name] = value; | ||
} | ||
throw _notImplemented('Parse5DomAdapter#setCookie'); | ||
@@ -633,0 +656,0 @@ }; |
147170
3537