New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular2-universal

Package Overview
Dependencies
Maintainers
5
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-universal - npm Package Compare versions

Comparing version 0.100.5 to 0.101.0

10

dist/node/bootloader.d.ts

@@ -8,3 +8,2 @@ import { ComponentRef, PlatformRef, ApplicationRef } from '@angular/core';

template?: string;
document?: string;
platformProviders?: Array<any>;

@@ -28,2 +27,7 @@ providers?: Array<any>;

}
export interface AppConfig {
template?: string;
directives?: Array<any>;
providers?: Array<any>;
}
export declare class Bootloader {

@@ -44,7 +48,7 @@ private _config;

serialize(Component?: any | Array<any>): Promise<any>;
serializeApplication(Component?: any | Array<any>, componentProviders?: Array<any>): Promise<any>;
serializeApplication(config?: AppConfig): Promise<any>;
_bootstrapAll(Components?: Array<any>, componentProviders?: Array<any>): Promise<Array<any>>;
_applicationAll(Components?: Array<any>, providers?: any): Promise<Array<any>>;
_applicationAll(config?: AppConfig): Promise<Array<any>>;
dispose(): void;
}
export declare function bootloader(config?: BootloaderConfig): Bootloader;

@@ -39,3 +39,3 @@ "use strict";

if (document === void 0) { document = null; }
var doc = document || this._config.template || this._config.document;
var doc = document || this._config.template;
if (typeof doc === 'string') {

@@ -72,10 +72,7 @@ return Bootloader.parseDocument(doc);

};
Bootloader.prototype.serializeApplication = function (Component, componentProviders) {
Bootloader.prototype.serializeApplication = function (config) {
var _this = this;
var component = Component || this._config.component;
var providers = componentProviders || this._config.componentProviders || [];
// let customProviders = ReflectiveInjector.resolveAndCreate(providers);
var ngDoCheck = this._config.ngDoCheck || null;
var maxZoneTurns = Math.max(this._config.maxZoneTurns || 2000, 1);
return this._applicationAll(component, providers)
return this._applicationAll(config)
.then(function (configRefs) {

@@ -202,5 +199,5 @@ if ('ngOnInit' in _this._config) {

for (var i = 0; i < configRefs.length; i++) {
var config = configRefs[i];
config.componentRef.destroy();
config.applicationRef.dispose();
var config_1 = configRefs[i];
config_1.componentRef.destroy();
config_1.applicationRef.dispose();
}

@@ -245,6 +242,8 @@ return rendered;

};
Bootloader.prototype._applicationAll = function (Components, providers) {
Bootloader.prototype._applicationAll = function (config) {
var _this = this;
var components = Components || this._config.directives;
var doc = this.document(this._config.template || this._config.document);
if (config === void 0) { config = {}; }
var components = config.directives || this._config.directives;
var providers = config.providers || this._config.providers;
var doc = this.document(config.template || this._config.template);
var directives = components.map(function (component) {

@@ -251,0 +250,0 @@ // var applicationRef = this.application(doc, providers);

export * from './node_http';
export * from './preload_cache';
export declare var NODE_HTTP_PROVIDERS: Array<any>;
export declare const NODE_HTTP_PROVIDERS_COMMON: Array<any>;
export declare const NODE_HTTP_PROVIDERS: Array<any>;
export declare const NODE_JSONP_PROVIDERS: Array<any>;
export declare const HTTP_PROVIDERS: any[];
export declare const NODE_PRELOAD_CACHE_HTTP_PROVIDERS: any[];

@@ -25,5 +25,7 @@ "use strict";

// ];
exports.NODE_HTTP_PROVIDERS = [
exports.NODE_HTTP_PROVIDERS_COMMON = [
core_1.provide(http_1.RequestOptions, { useClass: http_1.BaseRequestOptions }),
core_1.provide(http_1.ResponseOptions, { useClass: http_1.BaseResponseOptions }),
core_1.provide(http_1.ResponseOptions, { useClass: http_1.BaseResponseOptions })
];
exports.NODE_HTTP_PROVIDERS = exports.NODE_HTTP_PROVIDERS_COMMON.concat([
core_1.provide(http_1.BrowserXhr, { useClass: preloadCache.NodeXhr }),

@@ -33,3 +35,9 @@ // provide(ConnectionBackend, {useClass: preloadCache.NodeXhrBackend}),

core_1.provide(http_1.Http, { useClass: preloadCache.NgPreloadCacheHttp })
];
]);
exports.NODE_JSONP_PROVIDERS = exports.NODE_HTTP_PROVIDERS_COMMON.concat([
core_1.provide(http_1.BrowserXhr, { useClass: preloadCache.NodeXhr }),
// provide(ConnectionBackend, {useClass: preloadCache.NodeXhrBackend}),
core_1.provide(http_1.ConnectionBackend, { useClass: nodeHttp.NodeJsonpBackend }),
core_1.provide(http_1.Jsonp, { useClass: preloadCache.NgPreloadCacheHttp })
]);
exports.HTTP_PROVIDERS = exports.NODE_HTTP_PROVIDERS.concat([

@@ -36,0 +44,0 @@ core_1.provide(core_1.PLATFORM_INITIALIZER, { useValue: function () {

@@ -19,1 +19,9 @@ import { Connection, ConnectionBackend, ReadyState, Request, Response, ResponseOptions } from '@angular/http';

}
export declare class NodeJsonpBackend implements ConnectionBackend {
private _baseResponseOptions;
private _ngZone;
private _baseUrl;
private _originUrl;
constructor(_baseResponseOptions: ResponseOptions, _ngZone: NgZone, _baseUrl: string, _originUrl: string);
createConnection(request: Request): NodeConnection;
}

@@ -18,2 +18,3 @@ "use strict";

var core_1 = require('@angular/core');
var exceptions_1 = require('@angular/core/src/facade/exceptions');
var Observable_1 = require('rxjs/Observable');

@@ -25,2 +26,4 @@ require('rxjs/add/operator/map');

var common_1 = require('../../common');
var JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
var JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
var NodeConnection = (function () {

@@ -99,2 +102,93 @@ function NodeConnection(req, baseResponseOptions, ngZone, originUrl, baseUrl) {

exports.NodeConnection = NodeConnection;
var NodeJSONPConnection = (function () {
function NodeJSONPConnection(req, baseResponseOptions, ngZone, originUrl, baseUrl) {
if (originUrl === void 0) { originUrl = ''; }
if (req.method !== http_1.RequestMethod.Get) {
throw exceptions_1.makeTypeError(JSONP_ERR_WRONG_METHOD);
}
var rawUrl = req.url;
if (rawUrl.indexOf('=JSONP_CALLBACK&') > -1) {
rawUrl = lang_1.StringWrapper.replace(rawUrl, '=JSONP_CALLBACK&', "=callback&");
}
else if (rawUrl.lastIndexOf('=JSONP_CALLBACK') === rawUrl.length - '=JSONP_CALLBACK'.length) {
rawUrl = rawUrl.substring(0, rawUrl.length - '=JSONP_CALLBACK'.length) + "=callback";
}
this.request = req;
baseUrl = baseUrl || '/';
if (originUrl === null) {
throw new Error('ERROR: Please move ORIGIN_URL to platformProviders');
}
var _reqInfo = url.parse(url.resolve(url.resolve(originUrl, baseUrl), rawUrl));
_reqInfo.method = http_1.RequestMethod[req.method].toUpperCase();
if (lang_1.isPresent(req.headers)) {
_reqInfo.headers = {};
req.headers.forEach(function (values, name) { return _reqInfo.headers[name] = values.join(','); });
}
this.response = new Observable_1.Observable(function (responseObserver) {
var nodeReq;
ngZone.run(function () {
// http or https
var xhrHttp = http;
if (_reqInfo.protocol === 'https:') {
xhrHttp = https;
}
nodeReq = xhrHttp.request(_reqInfo, function (res) {
var body = '';
res.on('data', function (chunk) { return body += chunk; });
var status = res.statusCode;
var headers = new http_1.Headers(res.headers);
var url = res.url;
res.on('end', function () {
var responseJson;
try {
var responseFactory = new Function('', 'function callback(json) { return json } \n return ' + body);
responseJson = responseFactory();
}
catch (e) {
throw e;
}
var responseOptions = new http_1.ResponseOptions({ body: responseJson, status: status, headers: headers, url: url });
var response = new http_1.Response(responseOptions);
if (utils.isSuccess(status)) {
ngZone.run(function () {
responseObserver.next(response);
});
ngZone.run(function () {
responseObserver.complete();
});
return;
}
ngZone.run(function () {
responseObserver.error(response);
});
});
});
});
var onError = function (err) {
var responseOptions = new http_1.ResponseOptions({ body: err, type: http_1.ResponseType.Error });
if (lang_1.isPresent(baseResponseOptions)) {
responseOptions = baseResponseOptions.merge(responseOptions);
}
ngZone.run(function () {
responseObserver.error(new http_1.Response(responseOptions));
});
};
nodeReq.on('error', onError);
nodeReq.write(req.text());
nodeReq.end();
return function () {
nodeReq.removeListener('error', onError);
nodeReq.abort();
};
});
}
NodeJSONPConnection = __decorate([
__param(3, core_1.Optional()),
__param(3, core_1.Inject(common_1.ORIGIN_URL)),
__param(4, core_1.Optional()),
__param(4, core_1.Inject(common_1.BASE_URL)),
__metadata('design:paramtypes', [http_1.Request, http_1.ResponseOptions, core_1.NgZone, String, String])
], NodeJSONPConnection);
return NodeJSONPConnection;
}());
var NodeBackend = (function () {

@@ -119,2 +213,21 @@ function NodeBackend(_baseResponseOptions, _ngZone, _baseUrl, _originUrl) {

exports.NodeBackend = NodeBackend;
var NodeJsonpBackend = (function () {
function NodeJsonpBackend(_baseResponseOptions, _ngZone, _baseUrl, _originUrl) {
this._baseResponseOptions = _baseResponseOptions;
this._ngZone = _ngZone;
this._baseUrl = _baseUrl;
this._originUrl = _originUrl;
}
NodeJsonpBackend.prototype.createConnection = function (request) {
return new NodeJSONPConnection(request, this._baseResponseOptions, this._ngZone, this._baseUrl, this._originUrl);
};
NodeJsonpBackend = __decorate([
core_1.Injectable(),
__param(2, core_1.Inject(common_1.BASE_URL)),
__param(3, core_1.Inject(common_1.ORIGIN_URL)),
__metadata('design:paramtypes', [http_1.ResponseOptions, core_1.NgZone, String, String])
], NodeJsonpBackend);
return NodeJsonpBackend;
}());
exports.NodeJsonpBackend = NodeJsonpBackend;
//# sourceMappingURL=node_http.js.map

@@ -38,8 +38,2 @@ import { EventEmitter, NgZone } from '@angular/core';

request(url: string | Request, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any>;
get(url: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any>;
post(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any>;
put(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any>;
delete(url: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any>;
patch(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any>;
head(url: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any>;
}

@@ -182,26 +182,2 @@ "use strict";

};
NgPreloadCacheHttp.prototype.get = function (url, options) {
var _this = this;
return this.preload(url, function () { return _super.prototype.get.call(_this, url, options); });
};
NgPreloadCacheHttp.prototype.post = function (url, body, options) {
var _this = this;
return this.preload(url, function () { return _super.prototype.post.call(_this, url, body, options); });
};
NgPreloadCacheHttp.prototype.put = function (url, body, options) {
var _this = this;
return this.preload(url, function () { return _super.prototype.put.call(_this, url, body, options); });
};
NgPreloadCacheHttp.prototype.delete = function (url, options) {
var _this = this;
return this.preload(url, function () { return _super.prototype.delete.call(_this, url, options); });
};
NgPreloadCacheHttp.prototype.patch = function (url, body, options) {
var _this = this;
return this.preload(url, function () { return _super.prototype.patch.call(_this, url, body, options); });
};
NgPreloadCacheHttp.prototype.head = function (url, options) {
var _this = this;
return this.preload(url, function () { return _super.prototype.head.call(_this, url, options); });
};
NgPreloadCacheHttp = __decorate([

@@ -208,0 +184,0 @@ core_1.Injectable(),

{
"name": "angular2-universal",
"version": "0.100.5",
"version": "0.101.0",
"description": "Universal (isomorphic) javascript support for Angular2",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/angular/universal",

@@ -30,3 +30,2 @@ import {DOCUMENT} from '@angular/platform-browser';

template?: string;
document?: string;

@@ -52,2 +51,9 @@ platformProviders?: Array<any>;

export interface AppConfig {
template?: string;
directives?: Array<any>;
providers?: Array<any>;
}
export class Bootloader {

@@ -81,3 +87,3 @@ private _config: BootloaderConfig = { async: true, preboot: false };

document(document: string | Object = null): Object {
var doc = document || this._config.template || this._config.document;
var doc = document || this._config.template;
if (typeof doc === 'string') {

@@ -121,10 +127,7 @@ return Bootloader.parseDocument(doc);

serializeApplication(Component?: any | Array<any>, componentProviders?: Array<any>): Promise<any> {
let component = Component || this._config.component;
let providers = componentProviders || this._config.componentProviders || [];
// let customProviders = ReflectiveInjector.resolveAndCreate(providers);
serializeApplication(config?: AppConfig): Promise<any> {
let ngDoCheck = this._config.ngDoCheck || null;
let maxZoneTurns = Math.max(this._config.maxZoneTurns || 2000, 1);
return this._applicationAll(component, providers)
return this._applicationAll(config)
.then((configRefs: any) => {

@@ -281,5 +284,6 @@ if ('ngOnInit' in this._config) {

_applicationAll(Components?: Array<any>, providers?: any): Promise<Array<any>> {
let components = Components || this._config.directives;
let doc = this.document(this._config.template || this._config.document);
_applicationAll(config: AppConfig = {}): Promise<Array<any>> {
let components = config.directives || this._config.directives;
let providers = config.providers || this._config.providers;
let doc = this.document(config.template || this._config.template);

@@ -286,0 +290,0 @@ let directives = components.map(component => {

@@ -8,3 +8,4 @@ import {

BaseRequestOptions,
BaseResponseOptions
BaseResponseOptions,
Jsonp
} from '@angular/http';

@@ -32,7 +33,10 @@ import {provide, NgZone, PLATFORM_INITIALIZER} from '@angular/core';

// ];
export var NODE_HTTP_PROVIDERS: Array<any> = [
export const NODE_HTTP_PROVIDERS_COMMON: Array<any> = [
provide(RequestOptions, {useClass: BaseRequestOptions}),
provide(ResponseOptions, {useClass: BaseResponseOptions}),
provide(ResponseOptions, {useClass: BaseResponseOptions})
];
export const NODE_HTTP_PROVIDERS: Array<any> = [
...NODE_HTTP_PROVIDERS_COMMON,
provide(BrowserXhr, {useClass: preloadCache.NodeXhr}),

@@ -46,7 +50,15 @@ // provide(ConnectionBackend, {useClass: preloadCache.NodeXhrBackend}),

export const NODE_JSONP_PROVIDERS: Array<any> = [
...NODE_HTTP_PROVIDERS_COMMON,
provide(BrowserXhr, {useClass: preloadCache.NodeXhr}),
// provide(ConnectionBackend, {useClass: preloadCache.NodeXhrBackend}),
provide(ConnectionBackend, {useClass: nodeHttp.NodeJsonpBackend}),
provide(Jsonp, {useClass: preloadCache.NgPreloadCacheHttp})
];
export const HTTP_PROVIDERS = NODE_HTTP_PROVIDERS.concat([

@@ -53,0 +65,0 @@ provide(PLATFORM_INITIALIZER, {useValue: () => {

@@ -13,4 +13,5 @@ import {

import * as utils from '@angular/http/src/http_utils';
import {isPresent} from '@angular/core/src/facade/lang';
import {isPresent, StringWrapper} from '@angular/core/src/facade/lang';
import {Injectable, NgZone, Inject, Optional} from '@angular/core';
import {makeTypeError} from '@angular/core/src/facade/exceptions';
import {Observable} from 'rxjs/Observable';

@@ -24,2 +25,6 @@ import 'rxjs/add/operator/map';

const JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
const JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
export class NodeConnection implements Connection {

@@ -113,2 +118,107 @@ public readyState: ReadyState;

class NodeJSONPConnection {
public readyState: ReadyState;
public request: Request;
public response: Observable<Response> | Observable<any>;
constructor(
req: Request,
baseResponseOptions: ResponseOptions,
ngZone: NgZone,
@Optional() @Inject(ORIGIN_URL) originUrl: string = '',
@Optional() @Inject(BASE_URL) baseUrl?: string) {
if (req.method !== RequestMethod.Get) {
throw makeTypeError(JSONP_ERR_WRONG_METHOD);
}
let rawUrl: string = req.url;
if (rawUrl.indexOf('=JSONP_CALLBACK&') > -1) {
rawUrl = StringWrapper.replace(rawUrl, '=JSONP_CALLBACK&', `=callback&`);
} else if (rawUrl.lastIndexOf('=JSONP_CALLBACK') === rawUrl.length - '=JSONP_CALLBACK'.length) {
rawUrl = rawUrl.substring(0, rawUrl.length - '=JSONP_CALLBACK'.length) + `=callback`;
}
this.request = req;
baseUrl = baseUrl || '/';
if (originUrl === null) {
throw new Error('ERROR: Please move ORIGIN_URL to platformProviders');
}
let _reqInfo: any = url.parse(url.resolve(url.resolve(originUrl, baseUrl), rawUrl));
_reqInfo.method = RequestMethod[req.method].toUpperCase();
if (isPresent(req.headers)) {
_reqInfo.headers = {};
req.headers.forEach((values, name) => _reqInfo.headers[name] = values.join(','));
}
this.response = new Observable(responseObserver => {
let nodeReq;
ngZone.run(() => {
// http or https
let xhrHttp: any = http;
if (_reqInfo.protocol === 'https:') {
xhrHttp = https;
}
nodeReq = xhrHttp.request(_reqInfo, (res: http.IncomingMessage) => {
let body = '';
res.on('data', (chunk) => body += chunk);
let status = res.statusCode;
let headers = new Headers(res.headers);
let url = res.url;
res.on('end', () => {
var responseJson;
try {
var responseFactory = new Function('', 'function callback(json) { return json } \n return ' + body);
responseJson = responseFactory();
} catch (e) {
throw e;
}
let responseOptions = new ResponseOptions({body: responseJson, status, headers, url});
let response = new Response(responseOptions);
if (utils.isSuccess(status)) {
ngZone.run(() => {
responseObserver.next(response);
});
ngZone.run(() => {
responseObserver.complete();
});
return;
}
ngZone.run(() => {
responseObserver.error(response);
});
});
});
});
let onError = (err) => {
let responseOptions = new ResponseOptions({body: err, type: ResponseType.Error});
if (isPresent(baseResponseOptions)) {
responseOptions = baseResponseOptions.merge(responseOptions);
}
ngZone.run(() => {
responseObserver.error(new Response(responseOptions));
});
};
nodeReq.on('error', onError);
nodeReq.write(req.text());
nodeReq.end();
return () => {
nodeReq.removeListener('error', onError);
nodeReq.abort();
};
});
}
}
@Injectable()

@@ -126,1 +236,14 @@ export class NodeBackend implements ConnectionBackend {

}
@Injectable()
export class NodeJsonpBackend implements ConnectionBackend {
constructor(
private _baseResponseOptions: ResponseOptions,
private _ngZone: NgZone,
@Inject(BASE_URL) private _baseUrl: string,
@Inject(ORIGIN_URL) private _originUrl: string) {}
public createConnection(request: Request): NodeConnection {
return new NodeJSONPConnection(request, this._baseResponseOptions, this._ngZone, this._baseUrl, this._originUrl);
}
}

@@ -217,29 +217,2 @@ import {

get(url: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any> {
return this.preload(url, () => super.get(url, options));
}
post(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any> {
return this.preload(url, () => super.post(url, body, options));
}
put(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any> {
return this.preload(url, () => super.put(url, body, options));
}
delete(url: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any> {
return this.preload(url, () => super.delete(url, options));
}
patch(url: string, body: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any> {
return this.preload(url, () => super.patch(url, body, options));
}
head(url: string, options?: RequestOptionsArgs): Observable<Response> | EventEmitter<any> {
return this.preload(url, () => super.head(url, options));
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc