2015-10-01 20:47:49 -07:00
|
|
|
import {Map} from 'angular2/src/core/facade/collection';
|
2015-03-23 14:10:55 -07:00
|
|
|
|
2015-06-09 15:20:33 +02:00
|
|
|
export enum ViewType {
|
|
|
|
// A view that contains the host element with bound component directive.
|
|
|
|
// Contains a COMPONENT view
|
|
|
|
HOST,
|
2015-04-15 21:51:30 -07:00
|
|
|
// The view of the component
|
2015-06-09 15:20:33 +02:00
|
|
|
// Can contain 0 to n EMBEDDED views
|
|
|
|
COMPONENT,
|
2015-04-29 15:07:55 -07:00
|
|
|
// A view that is embedded into another View via a <template> element
|
2015-06-09 15:20:33 +02:00
|
|
|
// inside of a COMPONENT view
|
|
|
|
EMBEDDED
|
|
|
|
}
|
2015-04-15 21:51:30 -07:00
|
|
|
|
2015-09-10 23:08:44 -07:00
|
|
|
// An opaque reference to a render proto view
|
2015-05-18 11:57:20 -07:00
|
|
|
export class RenderProtoViewRef {}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
2015-06-24 13:46:39 -07:00
|
|
|
// An opaque reference to a part of a view
|
|
|
|
export class RenderFragmentRef {}
|
|
|
|
|
|
|
|
// An opaque reference to a view
|
2015-05-18 11:57:20 -07:00
|
|
|
export class RenderViewRef {}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
2015-07-24 15:28:44 -07:00
|
|
|
/**
|
|
|
|
* How the template and styles of a view should be encapsulated.
|
|
|
|
*/
|
|
|
|
export enum ViewEncapsulation {
|
|
|
|
/**
|
|
|
|
* Emulate scoping of styles by preprocessing the style rules
|
|
|
|
* and adding additional attributes to elements. This is the default.
|
|
|
|
*/
|
2015-08-28 21:03:19 -07:00
|
|
|
Emulated,
|
2015-07-24 15:28:44 -07:00
|
|
|
/**
|
|
|
|
* Uses the native mechanism of the renderer. For the DOM this means creating a ShadowRoot.
|
|
|
|
*/
|
2015-08-28 21:03:19 -07:00
|
|
|
Native,
|
2015-07-24 15:28:44 -07:00
|
|
|
/**
|
|
|
|
* Don't scope the template nor the styles.
|
|
|
|
*/
|
2015-08-28 21:03:19 -07:00
|
|
|
None
|
2015-07-24 15:28:44 -07:00
|
|
|
}
|
|
|
|
|
2015-09-18 10:33:23 -07:00
|
|
|
export var VIEW_ENCAPSULATION_VALUES =
|
|
|
|
[ViewEncapsulation.Emulated, ViewEncapsulation.Native, ViewEncapsulation.None];
|
2015-09-11 13:35:46 -07:00
|
|
|
|
2015-09-11 13:37:05 -07:00
|
|
|
export interface RenderTemplateCmd { visit(visitor: RenderCommandVisitor, context: any): any; }
|
|
|
|
|
|
|
|
export interface RenderBeginCmd extends RenderTemplateCmd {
|
|
|
|
ngContentIndex: number;
|
|
|
|
isBound: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RenderTextCmd extends RenderBeginCmd { value: string; }
|
|
|
|
|
2015-09-18 10:33:23 -07:00
|
|
|
export interface RenderNgContentCmd { ngContentIndex: number; }
|
2015-09-11 13:37:05 -07:00
|
|
|
|
|
|
|
export interface RenderBeginElementCmd extends RenderBeginCmd {
|
|
|
|
name: string;
|
|
|
|
attrNameAndValues: string[];
|
2015-09-18 10:33:23 -07:00
|
|
|
eventTargetAndNames: string[];
|
2015-09-11 13:37:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface RenderBeginComponentCmd extends RenderBeginElementCmd {
|
|
|
|
nativeShadow: boolean;
|
2015-09-14 15:59:09 -07:00
|
|
|
templateId: number;
|
2015-09-11 13:37:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface RenderEmbeddedTemplateCmd extends RenderBeginElementCmd {
|
|
|
|
isMerged: boolean;
|
|
|
|
children: RenderTemplateCmd[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RenderCommandVisitor {
|
2015-09-18 10:33:23 -07:00
|
|
|
visitText(cmd: RenderTextCmd, context: any): any;
|
|
|
|
visitNgContent(cmd: RenderNgContentCmd, context: any): any;
|
|
|
|
visitBeginElement(cmd: RenderBeginElementCmd, context: any): any;
|
2015-09-11 13:37:05 -07:00
|
|
|
visitEndElement(context: any): any;
|
2015-09-18 10:33:23 -07:00
|
|
|
visitBeginComponent(cmd: RenderBeginComponentCmd, context: any): any;
|
2015-09-11 13:37:05 -07:00
|
|
|
visitEndComponent(context: any): any;
|
2015-09-18 10:33:23 -07:00
|
|
|
visitEmbeddedTemplate(cmd: RenderEmbeddedTemplateCmd, context: any): any;
|
2015-09-11 13:37:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-24 13:46:39 -07:00
|
|
|
export class RenderViewWithFragments {
|
|
|
|
constructor(public viewRef: RenderViewRef, public fragmentRefs: RenderFragmentRef[]) {}
|
2015-05-06 10:17:38 -07:00
|
|
|
}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-07-11 17:26:48 +02:00
|
|
|
* Abstract reference to the element which can be marshaled across web-worker boundary.
|
2015-07-07 08:15:58 +02:00
|
|
|
*
|
2015-07-22 22:07:51 -07:00
|
|
|
* This interface is used by the Renderer API.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-06-23 11:21:56 -07:00
|
|
|
export interface RenderElementRef {
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-07-22 22:07:51 -07:00
|
|
|
* Reference to the `RenderViewRef` where the `RenderElementRef` is inside of.
|
2015-07-07 08:15:58 +02:00
|
|
|
*/
|
2015-06-23 11:21:56 -07:00
|
|
|
renderView: RenderViewRef;
|
2015-07-07 08:15:58 +02:00
|
|
|
/**
|
2015-07-22 22:07:51 -07:00
|
|
|
* Index of the element inside the `RenderViewRef`.
|
2015-07-07 08:15:58 +02:00
|
|
|
*
|
|
|
|
* This is used internally by the Angular framework to locate elements.
|
|
|
|
*/
|
2015-10-01 20:47:49 -07:00
|
|
|
boundElementIndex: number;
|
2015-06-23 11:21:56 -07:00
|
|
|
}
|
|
|
|
|
2015-05-06 10:17:38 -07:00
|
|
|
export class Renderer {
|
2015-10-01 10:07:49 -07:00
|
|
|
/**
|
|
|
|
* Registers the template of a component
|
|
|
|
*/
|
|
|
|
registerComponentTemplate(templateId: number, commands: RenderTemplateCmd[], styles: string[]) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new RenderProtoViewRef gfrom RenderTemplateCmds.
|
|
|
|
*/
|
|
|
|
createProtoView(cmds: RenderTemplateCmd[]): RenderProtoViewRef { return null; }
|
|
|
|
|
2015-03-23 14:10:55 -07:00
|
|
|
/**
|
2015-05-15 09:55:43 -07:00
|
|
|
* Creates a root host view that includes the given element.
|
2015-06-24 13:46:39 -07:00
|
|
|
* Note that the fragmentCount needs to be passed in so that we can create a result
|
|
|
|
* synchronously even when dealing with webworkers!
|
|
|
|
*
|
2015-05-18 11:57:20 -07:00
|
|
|
* @param {RenderProtoViewRef} hostProtoViewRef a RenderProtoViewRef of type
|
|
|
|
* ProtoViewDto.HOST_VIEW_TYPE
|
|
|
|
* @param {any} hostElementSelector css selector for the host element (will be queried against the
|
|
|
|
* main document)
|
2015-06-24 13:46:39 -07:00
|
|
|
* @return {RenderViewWithFragments} the created view including fragments
|
2015-03-23 14:10:55 -07:00
|
|
|
*/
|
2015-06-24 13:46:39 -07:00
|
|
|
createRootHostView(hostProtoViewRef: RenderProtoViewRef, fragmentCount: number,
|
|
|
|
hostElementSelector: string): RenderViewWithFragments {
|
2015-05-06 10:49:42 -07:00
|
|
|
return null;
|
|
|
|
}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
|
|
|
/**
|
2015-06-24 13:46:39 -07:00
|
|
|
* Creates a regular view out of the given ProtoView.
|
|
|
|
* Note that the fragmentCount needs to be passed in so that we can create a result
|
|
|
|
* synchronously even when dealing with webworkers!
|
2015-03-23 14:10:55 -07:00
|
|
|
*/
|
2015-06-24 13:46:39 -07:00
|
|
|
createView(protoViewRef: RenderProtoViewRef, fragmentCount: number): RenderViewWithFragments {
|
|
|
|
return null;
|
|
|
|
}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
|
|
|
/**
|
2015-05-06 10:49:42 -07:00
|
|
|
* Destroys the given view after it has been dehydrated and detached
|
2015-03-23 14:10:55 -07:00
|
|
|
*/
|
2015-05-18 11:57:20 -07:00
|
|
|
destroyView(viewRef: RenderViewRef) {}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
2015-04-15 21:51:30 -07:00
|
|
|
/**
|
2015-06-24 13:46:39 -07:00
|
|
|
* Attaches a fragment after another fragment.
|
2015-04-15 21:51:30 -07:00
|
|
|
*/
|
2015-06-24 13:46:39 -07:00
|
|
|
attachFragmentAfterFragment(previousFragmentRef: RenderFragmentRef,
|
|
|
|
fragmentRef: RenderFragmentRef) {}
|
2015-04-15 21:51:30 -07:00
|
|
|
|
|
|
|
/**
|
2015-06-24 13:46:39 -07:00
|
|
|
* Attaches a fragment after an element.
|
2015-04-15 21:51:30 -07:00
|
|
|
*/
|
2015-06-24 13:46:39 -07:00
|
|
|
attachFragmentAfterElement(elementRef: RenderElementRef, fragmentRef: RenderFragmentRef) {}
|
2015-04-15 21:51:30 -07:00
|
|
|
|
|
|
|
/**
|
2015-06-24 13:46:39 -07:00
|
|
|
* Detaches a fragment.
|
2015-04-15 21:51:30 -07:00
|
|
|
*/
|
2015-06-24 13:46:39 -07:00
|
|
|
detachFragment(fragmentRef: RenderFragmentRef) {}
|
2015-04-15 21:51:30 -07:00
|
|
|
|
2015-03-23 14:10:55 -07:00
|
|
|
/**
|
2015-05-18 11:57:20 -07:00
|
|
|
* Hydrates a view after it has been attached. Hydration/dehydration is used for reusing views
|
|
|
|
* inside of the view pool.
|
2015-03-23 14:10:55 -07:00
|
|
|
*/
|
2015-05-18 11:57:20 -07:00
|
|
|
hydrateView(viewRef: RenderViewRef) {}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
|
|
|
/**
|
2015-05-18 11:57:20 -07:00
|
|
|
* Dehydrates a view after it has been attached. Hydration/dehydration is used for reusing views
|
|
|
|
* inside of the view pool.
|
2015-03-23 14:10:55 -07:00
|
|
|
*/
|
2015-05-18 11:57:20 -07:00
|
|
|
dehydrateView(viewRef: RenderViewRef) {}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
2015-06-23 14:26:02 -07:00
|
|
|
/**
|
|
|
|
* Returns the native element at the given location.
|
|
|
|
* Attention: In a WebWorker scenario, this should always return null!
|
|
|
|
*/
|
|
|
|
getNativeElementSync(location: RenderElementRef): any { return null; }
|
|
|
|
|
2015-03-23 14:10:55 -07:00
|
|
|
/**
|
2015-05-11 12:31:16 -07:00
|
|
|
* Sets a property on an element.
|
2015-03-23 14:10:55 -07:00
|
|
|
*/
|
2015-06-23 11:21:56 -07:00
|
|
|
setElementProperty(location: RenderElementRef, propertyName: string, propertyValue: any) {}
|
2015-05-06 10:49:42 -07:00
|
|
|
|
2015-05-11 12:31:16 -07:00
|
|
|
/**
|
2015-06-18 15:44:44 -07:00
|
|
|
* Sets an attribute on an element.
|
|
|
|
*/
|
2015-06-23 11:21:56 -07:00
|
|
|
setElementAttribute(location: RenderElementRef, attributeName: string, attributeValue: string) {}
|
2015-06-18 15:44:44 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a class on an element.
|
|
|
|
*/
|
2015-06-23 11:21:56 -07:00
|
|
|
setElementClass(location: RenderElementRef, className: string, isAdd: boolean) {}
|
2015-06-18 15:44:44 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a style on an element.
|
|
|
|
*/
|
2015-06-23 11:21:56 -07:00
|
|
|
setElementStyle(location: RenderElementRef, styleName: string, styleValue: string) {}
|
2015-06-18 15:44:44 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls a method on an element.
|
2015-05-11 12:31:16 -07:00
|
|
|
*/
|
2015-08-28 11:29:19 -07:00
|
|
|
invokeElementMethod(location: RenderElementRef, methodName: string, args: any[]) {}
|
2015-05-11 12:31:16 -07:00
|
|
|
|
|
|
|
/**
|
2015-05-06 10:49:42 -07:00
|
|
|
* Sets the value of a text node.
|
|
|
|
*/
|
2015-05-18 11:57:20 -07:00
|
|
|
setText(viewRef: RenderViewRef, textNodeIndex: number, text: string) {}
|
2015-03-23 14:10:55 -07:00
|
|
|
|
|
|
|
/**
|
2015-05-06 10:49:42 -07:00
|
|
|
* Sets the dispatcher for all events of the given view
|
2015-03-23 14:10:55 -07:00
|
|
|
*/
|
2015-06-24 13:46:39 -07:00
|
|
|
setEventDispatcher(viewRef: RenderViewRef, dispatcher: RenderEventDispatcher) {}
|
2015-03-23 14:10:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A dispatcher for all events happening in a view.
|
|
|
|
*/
|
2015-06-24 13:46:39 -07:00
|
|
|
export interface RenderEventDispatcher {
|
2015-03-23 14:10:55 -07:00
|
|
|
/**
|
|
|
|
* Called when an event was triggered for a on-* attribute on an element.
|
2015-04-07 20:54:20 -07:00
|
|
|
* @param {Map<string, any>} locals Locals to be used to evaluate the
|
2015-03-23 14:10:55 -07:00
|
|
|
* event expressions
|
2015-08-26 13:25:00 -07:00
|
|
|
* @return {boolean} False if `preventDefault` should be called on the DOM event.
|
2015-03-23 14:10:55 -07:00
|
|
|
*/
|
2015-08-26 13:25:00 -07:00
|
|
|
dispatchRenderEvent(elementIndex: number, eventName: string, locals: Map<string, any>): boolean;
|
2015-03-23 14:10:55 -07:00
|
|
|
}
|