refactor: core, http & platform-webworker to remove public private class separation (#19143)
The private classes `ApplicationRef_`, `PlatformRef_`, `JSONPConnection_`, `JSONPBackend_`, `ClientMessageBrokerFactory_`, `ServiceMessageBroker_`, `ClientMessageBroker_` and `ServiceMessageBrokerFactory_` have been removed and merged into their public equivalents. The size of the minified umd bundles have been slightly decreased: | package | before | after | | -------------------|------------|------------| | core | 217.791 kb | 217.144 kb | | http | 33.260 kb | 32.838 kb | | platform-webworker | 56.015 kb | 54.933 kb | PR Close #19143
This commit is contained in:

committed by
Matias Niemelä

parent
0c44e733ad
commit
b6431c60e6
@ -22,11 +22,16 @@ const JSONP_ERR_NO_CALLBACK = 'JSONP injected script did not invoke callback.';
|
||||
const JSONP_ERR_WRONG_METHOD = 'JSONP requests must use GET request method.';
|
||||
|
||||
/**
|
||||
* Abstract base class for an in-flight JSONP request.
|
||||
* Base class for an in-flight JSONP request.
|
||||
*
|
||||
* @deprecated use @angular/common/http instead
|
||||
*/
|
||||
export abstract class JSONPConnection implements Connection {
|
||||
export class JSONPConnection implements Connection {
|
||||
private _id: string;
|
||||
private _script: Element;
|
||||
private _responseData: any;
|
||||
private _finished: boolean = false;
|
||||
|
||||
/**
|
||||
* The {@link ReadyState} of this request.
|
||||
*/
|
||||
@ -42,22 +47,9 @@ export abstract class JSONPConnection implements Connection {
|
||||
*/
|
||||
response: Observable<Response>;
|
||||
|
||||
/**
|
||||
* Callback called when the JSONP request completes, to notify the application
|
||||
* of the new data.
|
||||
*/
|
||||
abstract finished(data?: any): void;
|
||||
}
|
||||
|
||||
export class JSONPConnection_ extends JSONPConnection {
|
||||
private _id: string;
|
||||
private _script: Element;
|
||||
private _responseData: any;
|
||||
private _finished: boolean = false;
|
||||
|
||||
/** @internal */
|
||||
constructor(
|
||||
req: Request, private _dom: BrowserJsonp, private baseResponseOptions?: ResponseOptions) {
|
||||
super();
|
||||
if (req.method !== RequestMethod.Get) {
|
||||
throw new TypeError(JSONP_ERR_WRONG_METHOD);
|
||||
}
|
||||
@ -129,6 +121,10 @@ export class JSONPConnection_ extends JSONPConnection {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback called when the JSONP request completes, to notify the application
|
||||
* of the new data.
|
||||
*/
|
||||
finished(data?: any) {
|
||||
// Don't leak connections
|
||||
this._finished = true;
|
||||
@ -143,15 +139,14 @@ export class JSONPConnection_ extends JSONPConnection {
|
||||
*
|
||||
* @deprecated use @angular/common/http instead
|
||||
*/
|
||||
export abstract class JSONPBackend extends ConnectionBackend {}
|
||||
|
||||
@Injectable()
|
||||
export class JSONPBackend_ extends JSONPBackend {
|
||||
export class JSONPBackend extends ConnectionBackend {
|
||||
/** @internal */
|
||||
constructor(private _browserJSONP: BrowserJsonp, private _baseResponseOptions: ResponseOptions) {
|
||||
super();
|
||||
}
|
||||
|
||||
createConnection(request: Request): JSONPConnection {
|
||||
return new JSONPConnection_(request, this._browserJSONP, this._baseResponseOptions);
|
||||
return new JSONPConnection(request, this._browserJSONP, this._baseResponseOptions);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import {NgModule} from '@angular/core';
|
||||
|
||||
import {BrowserJsonp} from './backends/browser_jsonp';
|
||||
import {BrowserXhr} from './backends/browser_xhr';
|
||||
import {JSONPBackend, JSONPBackend_} from './backends/jsonp_backend';
|
||||
import {JSONPBackend} from './backends/jsonp_backend';
|
||||
import {CookieXSRFStrategy, XHRBackend} from './backends/xhr_backend';
|
||||
import {BaseRequestOptions, RequestOptions} from './base_request_options';
|
||||
import {BaseResponseOptions, ResponseOptions} from './base_response_options';
|
||||
@ -70,7 +70,7 @@ export class HttpModule {
|
||||
BrowserJsonp,
|
||||
{provide: RequestOptions, useClass: BaseRequestOptions},
|
||||
{provide: ResponseOptions, useClass: BaseResponseOptions},
|
||||
{provide: JSONPBackend, useClass: JSONPBackend_},
|
||||
JSONPBackend,
|
||||
],
|
||||
})
|
||||
export class JsonpModule {
|
||||
|
Reference in New Issue
Block a user