refactor: deprecate `RootRenderer` / `Renderer`
Use `RendererV2` instead of `Renderer` now. `Renderer` can still be injected and delegates to `RendererV2`. Use `RendererFactoryV2` instead of `RootRenderer`. `RootRenderer` cannot be used anymore. BREAKING CHANGE: - `RootRenderer` cannot be used any more, use `RendererFactoryV2` instead. Note: `Renderer` can still be injected/used, but is deprecated.
This commit is contained in:
parent
d3a98c74d6
commit
ccb636c2e9
|
@ -15,7 +15,10 @@ import {RenderComponentType, RenderDebugInfo, Renderer, RootRenderer} from '../r
|
|||
import {DebugElement, DebugNode, EventListener, getDebugNode, indexDebugNode, removeDebugNodeFromIndex} from './debug_node';
|
||||
|
||||
export class DebugDomRootRenderer implements RootRenderer {
|
||||
constructor(private _delegate: RootRenderer) {}
|
||||
constructor(private _delegate: RootRenderer) {
|
||||
throw new Error(
|
||||
'RootRenderer is no longer supported. Please use the `RendererFactoryV2` instead!');
|
||||
}
|
||||
|
||||
renderComponent(componentProto: RenderComponentType): Renderer {
|
||||
return new DebugDomRenderer(this._delegate.renderComponent(componentProto));
|
||||
|
|
|
@ -13,9 +13,8 @@ import {InjectionToken, Injector} from '../di';
|
|||
import {ViewEncapsulation} from '../metadata/view';
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* @deprecated Use `RendererTypeV2` (and `RendererV2`) instead.
|
||||
*/
|
||||
// TODO (matsko): add typing for the animation function
|
||||
export class RenderComponentType {
|
||||
constructor(
|
||||
public id: string, public templateUrl: string, public slotCount: number,
|
||||
|
@ -23,6 +22,9 @@ export class RenderComponentType {
|
|||
public animations: any) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Debug info is handeled internally in the view engine now.
|
||||
*/
|
||||
export abstract class RenderDebugInfo {
|
||||
abstract get injector(): Injector;
|
||||
abstract get component(): any;
|
||||
|
@ -32,6 +34,9 @@ export abstract class RenderDebugInfo {
|
|||
abstract get source(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use the `RendererV2` instead.
|
||||
*/
|
||||
export interface DirectRenderer {
|
||||
remove(node: any): void;
|
||||
appendChild(node: any, parent: any): void;
|
||||
|
@ -41,7 +46,7 @@ export interface DirectRenderer {
|
|||
}
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* @deprecated Use the `RendererV2` instead.
|
||||
*/
|
||||
export abstract class Renderer {
|
||||
abstract selectRootElement(selectorOrNode: string|any, debugInfo?: RenderDebugInfo): any;
|
||||
|
@ -104,7 +109,8 @@ export const RendererV2Interceptor = new InjectionToken<RendererV2[]>('RendererV
|
|||
* If you are implementing a custom renderer, you must implement this interface.
|
||||
*
|
||||
* The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
|
||||
* @experimental
|
||||
*
|
||||
* @deprecated Use `RendererFactoryV2` instead.
|
||||
*/
|
||||
export abstract class RootRenderer {
|
||||
abstract renderComponent(componentType: RenderComponentType): Renderer;
|
||||
|
|
|
@ -20,7 +20,8 @@ let destroyViewLogs: any[];
|
|||
export function main() {
|
||||
// Don't run on server...
|
||||
if (!getDOM().supportsDOMEvents()) return;
|
||||
describe('direct dom integration tests', function() {
|
||||
// TODO(tbosch): delete the tests here as they use the old renderer.
|
||||
xdescribe('direct dom integration tests', function() {
|
||||
|
||||
beforeEach(() => {
|
||||
directRenderer = DIRECT_DOM_RENDERER;
|
||||
|
|
|
@ -50,6 +50,8 @@ export class DomRootRenderer_ extends DomRootRenderer {
|
|||
sharedStylesHost: DomSharedStylesHost, animationDriver: AnimationDriver,
|
||||
@Inject(APP_ID) appId: string) {
|
||||
super(_document, _eventManager, sharedStylesHost, animationDriver, appId);
|
||||
throw new Error(
|
||||
'RootRenderer is no longer supported. Please use the `RendererFactoryV2` instead!');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,11 @@ export class ServerRootRenderer implements RootRenderer {
|
|||
constructor(
|
||||
@Inject(DOCUMENT) public document: any, public sharedStylesHost: SharedStylesHost,
|
||||
public animationDriver: AnimationDriver, @Inject(APP_ID) public appId: string,
|
||||
private _zone: NgZone) {}
|
||||
private _zone: NgZone) {
|
||||
throw new Error(
|
||||
'RootRenderer is no longer supported. Please use the `RendererFactoryV2` instead!');
|
||||
}
|
||||
|
||||
renderComponent(componentProto: RenderComponentType): Renderer {
|
||||
let renderer = this.registeredComponents.get(componentProto.id);
|
||||
if (!renderer) {
|
||||
|
|
|
@ -63,6 +63,8 @@ export class WebWorkerRootRenderer implements RootRenderer {
|
|||
bus.initChannel(EVENT_CHANNEL);
|
||||
const source = bus.from(EVENT_CHANNEL);
|
||||
source.subscribe({next: (message: any) => this._dispatchEvent(message)});
|
||||
throw new Error(
|
||||
'RootRenderer is no longer supported. Please use the `RendererFactoryV2` instead!');
|
||||
}
|
||||
|
||||
private _dispatchEvent(message: {[key: string]: any}): void {
|
||||
|
|
|
@ -17,7 +17,7 @@ import {PostMessageBus, PostMessageBusSink, PostMessageBusSource} from './web_wo
|
|||
import {RenderStore} from './web_workers/shared/render_store';
|
||||
import {Serializer} from './web_workers/shared/serializer';
|
||||
import {ServiceMessageBrokerFactory, ServiceMessageBrokerFactory_} from './web_workers/shared/service_message_broker';
|
||||
import {MessageBasedRenderer} from './web_workers/ui/renderer';
|
||||
import {MessageBasedRenderer, MessageBasedRendererV2} from './web_workers/ui/renderer';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -47,16 +47,20 @@ export const WORKER_SCRIPT = new InjectionToken<string>('WebWorkerScript');
|
|||
* A multi-provider used to automatically call the `start()` method after the service is
|
||||
* created.
|
||||
*
|
||||
* TODO(vicb): create an interface for startable services to implement
|
||||
* @experimental WebWorker support is currently experimental.
|
||||
*/
|
||||
export const WORKER_UI_STARTABLE_MESSAGING_SERVICE =
|
||||
new InjectionToken<MessageBasedRenderer[]>('WorkerRenderStartableMsgService');
|
||||
new InjectionToken<({start: () => void})[]>('WorkerRenderStartableMsgService');
|
||||
|
||||
export const _WORKER_UI_PLATFORM_PROVIDERS: Provider[] = [
|
||||
{provide: NgZone, useFactory: createNgZone, deps: []},
|
||||
MessageBasedRenderer,
|
||||
{provide: WORKER_UI_STARTABLE_MESSAGING_SERVICE, useExisting: MessageBasedRenderer, multi: true},
|
||||
MessageBasedRendererV2,
|
||||
{
|
||||
provide: WORKER_UI_STARTABLE_MESSAGING_SERVICE,
|
||||
useExisting: MessageBasedRendererV2,
|
||||
multi: true
|
||||
},
|
||||
BROWSER_SANITIZATION_PROVIDERS,
|
||||
{provide: ErrorHandler, useFactory: _exceptionHandler, deps: []},
|
||||
{provide: DOCUMENT, useFactory: _document, deps: []},
|
||||
|
|
|
@ -56,7 +56,8 @@ export function main() {
|
|||
return new DebugDomRootRenderer(workerRootRenderer);
|
||||
}
|
||||
|
||||
describe('Web Worker Renderer', () => {
|
||||
// TODO(tbosch): delete the tests here as they use the old renderer.
|
||||
xdescribe('Web Worker Renderer', () => {
|
||||
// Don't run on server...
|
||||
if (!getDOM().supportsDOMEvents()) return;
|
||||
|
||||
|
|
|
@ -62,7 +62,8 @@ describe('tree benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for ng2 ftl', (done) => {
|
||||
// TODO(tbosch): delete ftl benchmarks as they use the old renderer / view engine.
|
||||
xit('should run for ng2 ftl', (done) => {
|
||||
runTreeBenchmark({
|
||||
id: `deepTree.ng2.ftl.${worker.id}`,
|
||||
url: 'all/benchmarks/src/tree/ng2_ftl/index.html',
|
||||
|
@ -83,7 +84,8 @@ describe('tree benchmark perf', () => {
|
|||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for ng2 static ftl', (done) => {
|
||||
// TODO(tbosch): delete ftl benchmarks as they use the old renderer / view engine.
|
||||
xit('should run for ng2 static ftl', (done) => {
|
||||
runTreeBenchmark({
|
||||
id: `deepTree.ng2.ftl.${worker.id}`,
|
||||
url: 'all/benchmarks/src/tree/ng2_static_ftl/index.html',
|
||||
|
|
|
@ -49,7 +49,8 @@ describe('tree benchmark spec', () => {
|
|||
expect($('#numberOfChecks').getText()).toContain('10');
|
||||
});
|
||||
|
||||
it('should work for ng2 ftl', () => {
|
||||
// TODO: delete ftl benchmarks
|
||||
xit('should work for ng2 ftl', () => {
|
||||
testTreeBenchmark({
|
||||
url: 'all/benchmarks/src/tree/ng2_ftl/index.html',
|
||||
// Can't use bundles as we use AoT generated code
|
||||
|
@ -64,7 +65,8 @@ describe('tree benchmark spec', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should work for ng2 static ftl', () => {
|
||||
// TODO: delete ftl benchmarks
|
||||
xit('should work for ng2 static ftl', () => {
|
||||
testTreeBenchmark({
|
||||
url: 'all/benchmarks/src/tree/ng2_static_ftl/index.html',
|
||||
// Can't use bundles as we use AoT generated code
|
||||
|
|
|
@ -812,7 +812,7 @@ export declare class ReflectiveKey {
|
|||
static get(token: Object): ReflectiveKey;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare class RenderComponentType {
|
||||
animations: any;
|
||||
encapsulation: ViewEncapsulation;
|
||||
|
@ -823,7 +823,7 @@ export declare class RenderComponentType {
|
|||
constructor(id: string, templateUrl: string, slotCount: number, encapsulation: ViewEncapsulation, styles: Array<string | any[]>, animations: any);
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare abstract class Renderer {
|
||||
abstract animate(element: any, startingStyles: AnimationStyles, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string, previousPlayers?: AnimationPlayer[]): AnimationPlayer;
|
||||
abstract attachViewAfter(node: any, viewRootNodes: any[]): void;
|
||||
|
@ -904,7 +904,7 @@ export interface ResolvedReflectiveProvider {
|
|||
/** @experimental */
|
||||
export declare function resolveForwardRef(type: any): any;
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare abstract class RootRenderer {
|
||||
abstract renderComponent(componentType: RenderComponentType): Renderer;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue