2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2017-02-14 21:03:18 -08:00
|
|
|
import {InjectionToken, Injector} from '../di';
|
2016-06-08 16:38:52 -07:00
|
|
|
import {ViewEncapsulation} from '../metadata/view';
|
|
|
|
|
2016-05-25 15:00:05 -07:00
|
|
|
/**
|
2017-03-07 16:36:12 -08:00
|
|
|
* @deprecated Use `RendererType2` (and `Renderer2`) instead.
|
2016-05-25 15:00:05 -07:00
|
|
|
*/
|
2015-12-02 10:35:51 -08:00
|
|
|
export class RenderComponentType {
|
2016-06-08 16:38:52 -07:00
|
|
|
constructor(
|
|
|
|
public id: string, public templateUrl: string, public slotCount: number,
|
2016-07-08 17:11:12 -07:00
|
|
|
public encapsulation: ViewEncapsulation, public styles: Array<string|any[]>,
|
2017-02-22 15:14:49 -08:00
|
|
|
public animations: any) {}
|
2015-12-02 10:35:51 -08:00
|
|
|
}
|
2015-09-28 19:58:38 -07:00
|
|
|
|
2017-02-20 08:00:31 -08:00
|
|
|
/**
|
|
|
|
* @deprecated Debug info is handeled internally in the view engine now.
|
|
|
|
*/
|
2016-01-06 14:13:44 -08:00
|
|
|
export abstract class RenderDebugInfo {
|
2017-01-25 22:32:32 -08:00
|
|
|
abstract get injector(): Injector;
|
|
|
|
abstract get component(): any;
|
|
|
|
abstract get providerTokens(): any[];
|
|
|
|
abstract get references(): {[key: string]: any};
|
|
|
|
abstract get context(): any;
|
|
|
|
abstract get source(): string;
|
2016-01-13 21:35:21 -08:00
|
|
|
}
|
|
|
|
|
2017-02-20 08:00:31 -08:00
|
|
|
/**
|
2017-03-07 16:36:12 -08:00
|
|
|
* @deprecated Use the `Renderer2` instead.
|
2017-02-20 08:00:31 -08:00
|
|
|
*/
|
2016-11-02 17:54:05 -07:00
|
|
|
export interface DirectRenderer {
|
|
|
|
remove(node: any): void;
|
|
|
|
appendChild(node: any, parent: any): void;
|
|
|
|
insertBefore(node: any, refNode: any): void;
|
|
|
|
nextSibling(node: any): any;
|
|
|
|
parentElement(node: any): any;
|
|
|
|
}
|
|
|
|
|
2016-05-25 15:00:05 -07:00
|
|
|
/**
|
2017-03-07 16:36:12 -08:00
|
|
|
* @deprecated Use the `Renderer2` instead.
|
2016-05-25 15:00:05 -07:00
|
|
|
*/
|
2016-01-06 14:13:44 -08:00
|
|
|
export abstract class Renderer {
|
2016-06-08 16:38:52 -07:00
|
|
|
abstract selectRootElement(selectorOrNode: string|any, debugInfo?: RenderDebugInfo): any;
|
2015-09-28 19:58:38 -07:00
|
|
|
|
2016-05-26 14:41:33 +01:00
|
|
|
abstract createElement(parentElement: any, name: string, debugInfo?: RenderDebugInfo): any;
|
2015-09-28 19:58:38 -07:00
|
|
|
|
2015-12-02 10:35:51 -08:00
|
|
|
abstract createViewRoot(hostElement: any): any;
|
2015-09-28 19:58:38 -07:00
|
|
|
|
2016-05-26 14:41:33 +01:00
|
|
|
abstract createTemplateAnchor(parentElement: any, debugInfo?: RenderDebugInfo): any;
|
2015-06-24 13:46:39 -07:00
|
|
|
|
2016-05-26 14:41:33 +01:00
|
|
|
abstract createText(parentElement: any, value: string, debugInfo?: RenderDebugInfo): any;
|
2015-09-28 19:58:38 -07:00
|
|
|
|
2016-03-28 14:25:22 -07:00
|
|
|
abstract projectNodes(parentElement: any, nodes: any[]): void;
|
2015-03-23 14:10:55 -07:00
|
|
|
|
2016-03-28 14:25:22 -07:00
|
|
|
abstract attachViewAfter(node: any, viewRootNodes: any[]): void;
|
2015-09-11 13:37:05 -07:00
|
|
|
|
2016-03-28 14:25:22 -07:00
|
|
|
abstract detachView(viewRootNodes: any[]): void;
|
2015-09-11 13:37:05 -07:00
|
|
|
|
2016-03-28 14:25:22 -07:00
|
|
|
abstract destroyView(hostElement: any, viewAllNodes: any[]): void;
|
2015-09-11 13:37:05 -07:00
|
|
|
|
2016-01-25 14:47:25 -08:00
|
|
|
abstract listen(renderElement: any, name: string, callback: Function): Function;
|
2015-09-11 13:37:05 -07:00
|
|
|
|
2015-12-02 10:35:51 -08:00
|
|
|
abstract listenGlobal(target: string, name: string, callback: Function): Function;
|
2015-09-11 13:37:05 -07:00
|
|
|
|
2016-03-28 14:25:22 -07:00
|
|
|
abstract setElementProperty(renderElement: any, propertyName: string, propertyValue: any): void;
|
2015-09-11 13:37:05 -07:00
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
abstract setElementAttribute(renderElement: any, attributeName: string, attributeValue: string):
|
|
|
|
void;
|
2015-09-11 13:37:05 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2016-01-06 14:13:44 -08:00
|
|
|
* Used only in debug mode to serialize property changes to dom nodes as attributes.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2016-06-08 16:38:52 -07:00
|
|
|
abstract setBindingDebugInfo(renderElement: any, propertyName: string, propertyValue: string):
|
|
|
|
void;
|
2015-10-06 06:53:39 -07:00
|
|
|
|
2016-07-12 10:26:54 -07:00
|
|
|
abstract setElementClass(renderElement: any, className: string, isAdd: boolean): void;
|
2015-06-23 11:21:56 -07:00
|
|
|
|
2016-07-12 10:26:54 -07:00
|
|
|
abstract setElementStyle(renderElement: any, styleName: string, styleValue: string): void;
|
2015-12-02 10:35:51 -08:00
|
|
|
|
2016-07-12 10:26:54 -07:00
|
|
|
abstract invokeElementMethod(renderElement: any, methodName: string, args?: any[]): void;
|
2015-12-02 10:35:51 -08:00
|
|
|
|
2016-07-12 10:26:54 -07:00
|
|
|
abstract setText(renderNode: any, text: string): void;
|
2016-05-25 12:46:22 -07:00
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
abstract animate(
|
2017-02-27 23:08:19 -08:00
|
|
|
element: any, startingStyles: any, keyframes: any[], duration: number, delay: number,
|
|
|
|
easing: string, previousPlayers?: any[]): any;
|
2015-11-02 08:39:14 -08:00
|
|
|
}
|
2015-09-28 19:58:38 -07:00
|
|
|
|
2017-03-07 16:36:12 -08:00
|
|
|
export const Renderer2Interceptor = new InjectionToken<Renderer2[]>('Renderer2Interceptor');
|
2017-02-22 15:14:49 -08:00
|
|
|
|
2017-02-16 13:55:55 -08:00
|
|
|
/**
|
|
|
|
* Injectable service that provides a low-level interface for modifying the UI.
|
|
|
|
*
|
|
|
|
* Use this service to bypass Angular's templating and make custom UI changes that can't be
|
|
|
|
* expressed declaratively. For example if you need to set a property or an attribute whose name is
|
|
|
|
* not statically known, use {@link #setElementProperty} or {@link #setElementAttribute}
|
|
|
|
* respectively.
|
|
|
|
*
|
|
|
|
* If you are implementing a custom renderer, you must implement this interface.
|
|
|
|
*
|
|
|
|
* The default Renderer implementation is `DomRenderer`. Also available is `WebWorkerRenderer`.
|
2017-02-20 08:00:31 -08:00
|
|
|
*
|
2017-03-07 16:36:12 -08:00
|
|
|
* @deprecated Use `RendererFactory2` instead.
|
2017-02-16 13:55:55 -08:00
|
|
|
*/
|
|
|
|
export abstract class RootRenderer {
|
|
|
|
abstract renderComponent(componentType: RenderComponentType): Renderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @experimental
|
|
|
|
*/
|
2017-03-07 16:36:12 -08:00
|
|
|
export interface RendererType2 {
|
2017-02-16 13:55:55 -08:00
|
|
|
id: string;
|
|
|
|
encapsulation: ViewEncapsulation;
|
|
|
|
styles: (string|any[])[];
|
2017-02-24 12:10:19 -08:00
|
|
|
data: {[kind: string]: any};
|
2017-02-16 13:55:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @experimental
|
|
|
|
*/
|
2017-03-07 16:36:12 -08:00
|
|
|
export abstract class RendererFactory2 {
|
|
|
|
abstract createRenderer(hostElement: any, type: RendererType2): Renderer2;
|
2017-02-16 13:55:55 -08:00
|
|
|
}
|
|
|
|
|
2017-02-14 21:03:18 -08:00
|
|
|
/**
|
|
|
|
* @experimental
|
|
|
|
*/
|
2017-03-07 16:36:12 -08:00
|
|
|
export abstract class Renderer2 {
|
2017-02-24 12:10:19 -08:00
|
|
|
/**
|
|
|
|
* This field can be used to store arbitrary data on this renderer instance.
|
|
|
|
* This is useful for renderers that delegate to other renderers.
|
|
|
|
*/
|
|
|
|
abstract get data(): {[key: string]: any};
|
|
|
|
|
2017-02-16 13:55:55 -08:00
|
|
|
abstract destroy(): void;
|
|
|
|
abstract createElement(name: string, namespace?: string): any;
|
|
|
|
abstract createComment(value: string): any;
|
|
|
|
abstract createText(value: string): any;
|
|
|
|
/**
|
|
|
|
* This property is allowed to be null / undefined,
|
|
|
|
* in which case the view engine won't call it.
|
|
|
|
* This is used as a performance optimization for production mode.
|
|
|
|
*/
|
|
|
|
destroyNode: (node: any) => void | null;
|
2017-02-14 21:03:18 -08:00
|
|
|
abstract appendChild(parent: any, newChild: any): void;
|
|
|
|
abstract insertBefore(parent: any, newChild: any, refChild: any): void;
|
|
|
|
abstract removeChild(parent: any, oldChild: any): void;
|
2017-02-16 13:55:55 -08:00
|
|
|
abstract selectRootElement(selectorOrNode: string|any): any;
|
2017-02-14 21:03:18 -08:00
|
|
|
/**
|
|
|
|
* Attention: On WebWorkers, this will always return a value,
|
|
|
|
* as we are asking for a result synchronously. I.e.
|
|
|
|
* the caller can't rely on checking whether this is null or not.
|
|
|
|
*/
|
|
|
|
abstract parentNode(node: any): any;
|
|
|
|
/**
|
|
|
|
* Attention: On WebWorkers, this will always return a value,
|
|
|
|
* as we are asking for a result synchronously. I.e.
|
|
|
|
* the caller can't rely on checking whether this is null or not.
|
|
|
|
*/
|
|
|
|
abstract nextSibling(node: any): any;
|
|
|
|
abstract setAttribute(el: any, name: string, value: string, namespace?: string): void;
|
|
|
|
abstract removeAttribute(el: any, name: string, namespace?: string): void;
|
|
|
|
abstract addClass(el: any, name: string): void;
|
|
|
|
abstract removeClass(el: any, name: string): void;
|
|
|
|
abstract setStyle(
|
|
|
|
el: any, style: string, value: any, hasVendorPrefix: boolean, hasImportant: boolean): void;
|
|
|
|
abstract removeStyle(el: any, style: string, hasVendorPrefix: boolean): void;
|
|
|
|
abstract setProperty(el: any, name: string, value: any): void;
|
2017-02-16 13:55:55 -08:00
|
|
|
abstract setValue(node: any, value: string): void;
|
2017-02-14 21:03:18 -08:00
|
|
|
abstract listen(
|
|
|
|
target: 'window'|'document'|'body'|any, eventName: string,
|
2017-03-07 16:36:12 -08:00
|
|
|
callback: (event: any) => boolean | void): () => void;
|
2017-02-14 21:03:18 -08:00
|
|
|
}
|