angular2-hapi-engine
Advanced tools
Comparing version 0.11.2 to 0.13.0
@@ -12,3 +12,9 @@ import { BootloaderConfig } from 'angular2-universal'; | ||
export declare var HAPI_PLATFORM: any; | ||
export declare var HAPI_ANGULAR_APP: { | ||
template: any; | ||
directives: any; | ||
providers: any; | ||
}; | ||
export declare function disposeHapiPlatform(): void; | ||
export declare function disposeHapiAngularApp(): void; | ||
export declare class hapiEngine { | ||
@@ -15,0 +21,0 @@ helpers: any; |
@@ -5,6 +5,22 @@ "use strict"; | ||
exports.HAPI_PLATFORM = null; | ||
exports.HAPI_ANGULAR_APP = { | ||
template: null, | ||
directives: null, | ||
providers: null | ||
}; | ||
function disposeHapiPlatform() { | ||
if (exports.HAPI_PLATFORM && exports.HAPI_PLATFORM.dispose) { | ||
exports.HAPI_PLATFORM.dispose(); | ||
} | ||
exports.HAPI_PLATFORM = null; | ||
} | ||
exports.disposeHapiPlatform = disposeHapiPlatform; | ||
function disposeHapiAngularApp() { | ||
exports.HAPI_ANGULAR_APP = { | ||
template: null, | ||
directives: null, | ||
providers: null | ||
}; | ||
} | ||
exports.disposeHapiAngularApp = disposeHapiAngularApp; | ||
var Runtime = (function () { | ||
@@ -21,21 +37,25 @@ function Runtime(options) { | ||
var _options = this.options; | ||
var _template = template; | ||
var _Bootloader = angular2_universal_1.Bootloader; | ||
var bootloader = _options.bootloader; | ||
if (!exports.HAPI_PLATFORM) { | ||
var _template = _options.template || template; | ||
if (exports.HAPI_ANGULAR_APP.template !== _template) { | ||
disposeHapiPlatform(); | ||
var _directives = _options.directives; | ||
var _Bootloader = angular2_universal_1.Bootloader; | ||
var _bootloader = _options.bootloader; | ||
if (_options.bootloader) { | ||
bootloader = _Bootloader.create(_options.bootloader); | ||
_bootloader = _Bootloader.create(_options.bootloader); | ||
} | ||
else { | ||
var doc = _Bootloader.parseDocument(_template); | ||
_options.document = doc; | ||
_options.template = _options.template || _template; | ||
bootloader = _Bootloader.create(_options); | ||
_bootloader = _Bootloader.create(_options); | ||
} | ||
exports.HAPI_PLATFORM = bootloader; | ||
exports.HAPI_PLATFORM = _bootloader; | ||
exports.HAPI_ANGULAR_APP.directives = _directives; | ||
exports.HAPI_ANGULAR_APP.providers = _options.providers; | ||
exports.HAPI_ANGULAR_APP.template = _template; | ||
} | ||
exports.HAPI_PLATFORM.serializeApplication(null, (_options.reuseProviders === false) ? null : _options.providers) | ||
exports.HAPI_PLATFORM.serializeApplication(exports.HAPI_ANGULAR_APP) | ||
.then(function (html) { return done(null, _this.buildClientScripts(html, context)); }) | ||
.catch(function (e) { | ||
console.error(e.stack); | ||
disposeHapiPlatform(); | ||
// if server fail then return client html | ||
@@ -77,3 +97,3 @@ done(null, _this.buildClientScripts(template, context)); | ||
}, systemConfig); | ||
return "\n <!-- Browser polyfills -->\n <script src=\"" + baseUrl + "/zone.js/dist/zone.js\"></script>\n <script src=\"" + baseUrl + "/reflect-metadata/Reflect.js\"></script>\n\n <!-- SystemJS -->\n <script src=\"" + baseUrl + "/systemjs/dist/system.js\"></script>\n <!-- Angular2: Bundle -->\n <script src=\"" + baseUrl + "/rxjs/bundles/Rx.js\"></script>\n <script src=\"" + baseUrl + "/@angular/core/core.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/router-deprecated/router-deprecated.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/http/http.umd.js\"></script>\n <script type=\"text/javascript\">\n System.config(" + JSON.stringify(newConfig) + ");\n </script>\n "; | ||
return "\n <!-- Browser polyfills -->\n <script src=\"" + baseUrl + "/zone.js/dist/zone.js\"></script>\n <script src=\"" + baseUrl + "/reflect-metadata/Reflect.js\"></script>\n <!-- SystemJS -->\n <script src=\"" + baseUrl + "/systemjs/dist/system.js\"></script>\n <!-- Angular2: Bundle -->\n <script src=\"" + baseUrl + "/rxjs/bundles/Rx.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/core/core.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/common/common.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/compiler/compiler.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/platform-browser/platform-browser.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/platform-browser-dynamic/platform-browser-dynamic.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/router-deprecated/router-deprecated.umd.js\"></script>\n <script src=\"" + baseUrl + "/@angular/http/http.umd.js\"></script>\n <script type=\"text/javascript\">\n System.config(" + JSON.stringify(newConfig) + ");\n </script>\n "; | ||
}; | ||
@@ -80,0 +100,0 @@ return Runtime; |
@@ -5,3 +5,3 @@ { | ||
"typings": "dist/index.d.ts", | ||
"version": "0.11.2", | ||
"version": "0.13.0", | ||
"description": "Universal (isomorphic) javascript support for Angular2", | ||
@@ -16,5 +16,5 @@ "homepage": "https://github.com/angular/universal", | ||
"scripts": { | ||
"remove-modules": "rm -rf node_modules/angular2-universal-preview node_modules/angular2-universal node_modules/angular2-express-engine node_modules/preboot node_modules/angular2-hapi-engine node_modules/angular2-universal-polyfills", | ||
"remove-modules": "rimraf node_modules/angular2-universal-preview node_modules/angular2-universal node_modules/angular2-express-engine node_modules/preboot node_modules/angular2-hapi-engine node_modules/angular2-universal-polyfills", | ||
"reload": "npm run remove-modules && npm install", | ||
"prebuild": "rm -rf dist", | ||
"prebuild": "rimraf dist", | ||
"build": "tsc || true", | ||
@@ -21,0 +21,0 @@ "postbuild": "typings install", |
@@ -25,6 +25,22 @@ import * as fs from 'fs'; | ||
export var HAPI_ANGULAR_APP = { | ||
template: null, | ||
directives: null, | ||
providers: null | ||
}; | ||
export function disposeHapiPlatform() { | ||
if (HAPI_PLATFORM && HAPI_PLATFORM.dispose) { | ||
HAPI_PLATFORM.dispose(); | ||
} | ||
HAPI_PLATFORM = null; | ||
} | ||
export function disposeHapiAngularApp() { | ||
HAPI_ANGULAR_APP = { | ||
template: null, | ||
directives: null, | ||
providers: null | ||
}; | ||
} | ||
@@ -39,21 +55,26 @@ class Runtime { | ||
const _options = this.options; | ||
const _template = template; | ||
const _Bootloader = Bootloader; | ||
let bootloader = _options.bootloader; | ||
if (!HAPI_PLATFORM) { | ||
const _template = _options.template || template; | ||
if (HAPI_ANGULAR_APP.template !== _template) { | ||
disposeHapiPlatform(); | ||
const _directives = _options.directives; | ||
const _Bootloader = Bootloader; | ||
let _bootloader = _options.bootloader; | ||
if (_options.bootloader) { | ||
bootloader = _Bootloader.create(_options.bootloader); | ||
_bootloader = _Bootloader.create(_options.bootloader); | ||
} else { | ||
let doc = _Bootloader.parseDocument(_template); | ||
_options.document = doc; | ||
_options.template = _options.template || _template; | ||
bootloader = _Bootloader.create(_options); | ||
_bootloader = _Bootloader.create(_options); | ||
} | ||
HAPI_PLATFORM = bootloader; | ||
HAPI_PLATFORM = _bootloader; | ||
HAPI_ANGULAR_APP.directives = _directives; | ||
HAPI_ANGULAR_APP.providers = _options.providers; | ||
HAPI_ANGULAR_APP.template = _template; | ||
} | ||
HAPI_PLATFORM.serializeApplication(null, (_options.reuseProviders === false) ? null : _options.providers) | ||
HAPI_PLATFORM.serializeApplication(HAPI_ANGULAR_APP) | ||
.then(html => done(null, this.buildClientScripts(html, context))) | ||
.catch(e => { | ||
console.error(e.stack); | ||
disposeHapiPlatform(); | ||
// if server fail then return client html | ||
@@ -139,8 +160,11 @@ done(null, this.buildClientScripts(template, context)); | ||
<script src="${baseUrl}/reflect-metadata/Reflect.js"></script> | ||
<!-- SystemJS --> | ||
<script src="${baseUrl}/systemjs/dist/system.js"></script> | ||
<!-- Angular2: Bundle --> | ||
<script src="${baseUrl}/rxjs/bundles/Rx.js"></script> | ||
<script src="${baseUrl}/rxjs/bundles/Rx.umd.js"></script> | ||
<script src="${baseUrl}/@angular/core/core.umd.js"></script> | ||
<script src="${baseUrl}/@angular/common/common.umd.js"></script> | ||
<script src="${baseUrl}/@angular/compiler/compiler.umd.js"></script> | ||
<script src="${baseUrl}/@angular/platform-browser/platform-browser.umd.js"></script> | ||
<script src="${baseUrl}/@angular/platform-browser-dynamic/platform-browser-dynamic.umd.js"></script> | ||
<script src="${baseUrl}/@angular/router-deprecated/router-deprecated.umd.js"></script> | ||
@@ -147,0 +171,0 @@ <script src="${baseUrl}/@angular/http/http.umd.js"></script> |
Sorry, the diff of this file is not supported yet
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
237895
5078