From 6df7231e8ffbc422b36286829a0e62c54b3df61d Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Wed, 15 Jul 2015 00:58:11 -0700 Subject: [PATCH 1/2] Update to Angular 2.0.0-alpha.31...Swapped out fetch with Http. --- package.json | 4 ++-- src/home/home.ts | 27 +++++++++++++++------------ src/login/login.ts | 31 +++++++++++++++++-------------- src/signup/signup.ts | 29 ++++++++++++++++------------- 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index f3d0ccb..eeeada9 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,10 @@ }, "homepage": "https://github.com/auth0/angular2-authentication-sample", "dependencies": { - "angular2": "2.0.0-alpha.30", + "angular2": "2.0.0-alpha.31", "raw-loader": "^0.5.1", "reflect-metadata": "^0.1.0", - "rtts_assert": "2.0.0-alpha.29", + "rtts_assert": "2.0.0-alpha.31", "rx": "^2.5.3", "zone.js": "^0.5.0", "bootstrap": "~3.3.4", diff --git a/src/home/home.ts b/src/home/home.ts index a10ffea..28f8502 100644 --- a/src/home/home.ts +++ b/src/home/home.ts @@ -2,7 +2,8 @@ import {Component, View} from 'angular2/angular2'; import {coreDirectives} from 'angular2/directives'; -import {status, text} from '../utils/fetch' +import {status, text} from '../utils/fetch'; +import {Http} from 'angular2/http'; import { Router} from 'angular2/router'; let styles = require('./home.css'); @@ -23,7 +24,7 @@ export class Home { response: string; api: string; - constructor(public router: Router) { + constructor(public router: Router, public http: Http) { this.jwt = localStorage.getItem('jwt'); this.decodedJwt = this.jwt && window.jwt_decode(this.jwt); } @@ -43,22 +44,24 @@ export class Home { _callApi(type, url) { this.response = null; this.api = type; - window.fetch(url, { - method: 'GET', + this.http.get(url, { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'bearer ' + this.jwt } }) - .then(status) - .then(text) - .then((response) => { - this.response = response; - }) - .catch((error) => { - this.response = error.message; - }); + .toRx() + .map(status) + .map(text) + .subscribe( + response => { + this.response = response; + }, + error => { + this.response = error.message; + } + ) } } diff --git a/src/login/login.ts b/src/login/login.ts index 9bfd200..87f1109 100644 --- a/src/login/login.ts +++ b/src/login/login.ts @@ -1,7 +1,8 @@ /// import {Component, View} from 'angular2/angular2'; -import {status, json} from '../utils/fetch' +import {status, json} from '../utils/fetch'; +import {Http} from 'angular2/http'; import { Router, RouterLink } from 'angular2/router'; @@ -18,13 +19,12 @@ let template = require('./login.html'); directives: [RouterLink] }) export class Login { - constructor(public router: Router) { + constructor(public router: Router, public http: Http) { } login(event, username, password) { event.preventDefault(); - window.fetch('http://localhost:3001/sessions/create', { - method: 'POST', + this.http.post('http://localhost:3001/sessions/create', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' @@ -33,16 +33,19 @@ export class Login { username, password }) }) - .then(status) - .then(json) - .then((response) => { - localStorage.setItem('jwt', response.id_token); - this.router.parent.navigate('/home'); - }) - .catch((error) => { - alert(error.message); - console.log(error.message); - }); + .toRx() + .map(status) + .map(json) + .subscribe( + response => { + localStorage.setItem('jwt', response.id_token); + this.router.parent.navigate('/home'); + }, + error => { + alert(error.message); + console.log(error.message); + } + ); } signup(event) { diff --git a/src/signup/signup.ts b/src/signup/signup.ts index a4f0f27..64accce 100644 --- a/src/signup/signup.ts +++ b/src/signup/signup.ts @@ -3,6 +3,7 @@ import {coreDirectives} from 'angular2/directives'; import {Component, View} from 'angular2/angular2'; import {status, json} from '../utils/fetch'; +import {Http} from 'angular2/http'; import { Router, RouterLink } from 'angular2/router'; let styles = require('./signup.css'); @@ -17,13 +18,12 @@ let template = require('./signup.html'); template: template }) export class Signup { - constructor(public router: Router) { + constructor(public router: Router, public http: Http) { } signup(event, username, password) { event.preventDefault(); - window.fetch('http://localhost:3001/users', { - method: 'POST', + this.http.post('http://localhost:3001/users', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' @@ -32,16 +32,19 @@ export class Signup { username, password }) }) - .then(status) - .then(json) - .then((response) => { - localStorage.setItem('jwt', response.id_token); - this.router.navigate('/home'); - }) - .catch((error) => { - alert(error.message); - console.log(error.message); - }); + .toRx() + .map(status) + .map(json) + .subscribe( + response => { + localStorage.setItem('jwt', response.id_token); + this.router.navigate('/home'); + }, + error => { + alert(error.message); + console.log(error.message); + } + ); } login(event) { From b09f359741f232ee21e4e0a741e2cc971048e030 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sun, 19 Jul 2015 16:09:56 -0700 Subject: [PATCH 2/2] chore(Typings): refactored typings to follow a similar pattern suggested by @gdi2290 here: https://github.com/auth0/angular2-authentication-sample/issues/27 ... Fixed Http api to match latest change in alpha.31 closes https://github.com/auth0/angular2-authentication-sample/issues/27 --- src/app/LoggedInOutlet.ts | 8 +- src/common/BrowserDomAdapter.ts | 2 +- src/common/jitInjectables.ts | 2 +- src/home/home.ts | 18 +- src/index.ts | 7 +- src/login/login.ts | 23 +- src/signup/signup.ts | 24 +- src/typings/browser.d.ts | 95 + {typings/_custom => src/typings}/custom.d.ts | 9 +- .../_custom => src/typings}/jwt_decode.d.ts | 0 {typings/_custom => src/typings}/webpack.d.ts | 0 src/utils/fetch.ts | 2 +- tsd.json | 5 +- typings/_custom/browser.d.ts | 4 - typings/_custom/ng2.d.ts | 1004 -- typings/angular2/angular2.d.ts | 8612 ++++++++++------- typings/angular2/router.d.ts | 459 + typings/tsd.d.ts | 7 +- typings/whatwg-fetch/whatwg-fetch.d.ts | 84 - 19 files changed, 5671 insertions(+), 4694 deletions(-) create mode 100644 src/typings/browser.d.ts rename {typings/_custom => src/typings}/custom.d.ts (52%) rename {typings/_custom => src/typings}/jwt_decode.d.ts (100%) rename {typings/_custom => src/typings}/webpack.d.ts (100%) delete mode 100644 typings/_custom/browser.d.ts delete mode 100644 typings/_custom/ng2.d.ts create mode 100644 typings/angular2/router.d.ts delete mode 100644 typings/whatwg-fetch/whatwg-fetch.d.ts diff --git a/src/app/LoggedInOutlet.ts b/src/app/LoggedInOutlet.ts index 590a326..5de5272 100644 --- a/src/app/LoggedInOutlet.ts +++ b/src/app/LoggedInOutlet.ts @@ -1,6 +1,6 @@ -import {Directive, Attribute, ElementRef, DynamicComponentLoader} from 'angular2/angular2'; +/// +import {Directive, Attribute, ElementRef, DynamicComponentLoader, Injector} from 'angular2/angular2'; import {Router, RouterOutlet} from 'angular2/router'; -import {Injector} from 'angular2/di'; import {Login} from '../login/login'; @Directive({ @@ -19,11 +19,11 @@ export class LoggedInRouterOutlet extends RouterOutlet { } - activate(instruction) { + commit(instruction) { var url = this._parentRouter.lastNavigationAttempt; if (!this.publicRoutes[url] && !localStorage.getItem('jwt')) { instruction.component = Login; } - return super.activate(instruction); + return super.commit(instruction); } } diff --git a/src/common/BrowserDomAdapter.ts b/src/common/BrowserDomAdapter.ts index a451b4a..63f510d 100644 --- a/src/common/BrowserDomAdapter.ts +++ b/src/common/BrowserDomAdapter.ts @@ -1,3 +1,3 @@ -/// +/// import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter'; BrowserDomAdapter.makeCurrent(); diff --git a/src/common/jitInjectables.ts b/src/common/jitInjectables.ts index 3453398..6dc44b8 100644 --- a/src/common/jitInjectables.ts +++ b/src/common/jitInjectables.ts @@ -1,4 +1,4 @@ -/// +/// import {ChangeDetection, JitChangeDetection} from 'angular2/change_detection'; import {bind} from 'angular2/di'; diff --git a/src/home/home.ts b/src/home/home.ts index 28f8502..6ae19be 100644 --- a/src/home/home.ts +++ b/src/home/home.ts @@ -1,9 +1,7 @@ -/// +/// -import {Component, View} from 'angular2/angular2'; -import {coreDirectives} from 'angular2/directives'; +import {Component, View, coreDirectives, Http, Headers} from 'angular2/angular2'; import {status, text} from '../utils/fetch'; -import {Http} from 'angular2/http'; import { Router} from 'angular2/router'; let styles = require('./home.css'); @@ -44,13 +42,11 @@ export class Home { _callApi(type, url) { this.response = null; this.api = type; - this.http.get(url, { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': 'bearer ' + this.jwt - } - }) + var headers = new Headers(); + headers.append('Accept', 'application/json'); + headers.append('Content-Type', 'application/json'); + headers.append('Authorization', 'bearer ' + this.jwt); + this.http.get(url, {headers: headers}) .toRx() .map(status) .map(text) diff --git a/src/index.ts b/src/index.ts index fc05dba..b8fee21 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,7 @@ -/// +/// -import { bootstrap } from 'angular2/angular2'; -import { bind } from 'angular2/di'; +import { bootstrap, bind, formInjectables, httpInjectables } from 'angular2/angular2'; import { routerInjectables } from 'angular2/router'; -import { formInjectables } from 'angular2/forms'; -import { httpInjectables } from 'angular2/http'; import { App } from './app/app'; diff --git a/src/login/login.ts b/src/login/login.ts index 87f1109..2a96dfe 100644 --- a/src/login/login.ts +++ b/src/login/login.ts @@ -1,8 +1,7 @@ -/// +/// -import {Component, View} from 'angular2/angular2'; +import {Component, View, Http, Headers} from 'angular2/angular2'; import {status, json} from '../utils/fetch'; -import {Http} from 'angular2/http'; import { Router, RouterLink } from 'angular2/router'; @@ -24,15 +23,17 @@ export class Login { login(event, username, password) { event.preventDefault(); - this.http.post('http://localhost:3001/sessions/create', { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ + var headers = new Headers(); + headers.append('Accept', 'application/json'); + headers.append('Content-Type', 'application/json'); + this.http.post('http://localhost:3001/sessions/create', + JSON.stringify({ username, password - }) - }) + }), + { + headers: headers + } + ) .toRx() .map(status) .map(json) diff --git a/src/signup/signup.ts b/src/signup/signup.ts index 64accce..34f6175 100644 --- a/src/signup/signup.ts +++ b/src/signup/signup.ts @@ -1,9 +1,7 @@ -/// +/// -import {coreDirectives} from 'angular2/directives'; -import {Component, View} from 'angular2/angular2'; +import {Component, View, coreDirectives, Http, Headers} from 'angular2/angular2'; import {status, json} from '../utils/fetch'; -import {Http} from 'angular2/http'; import { Router, RouterLink } from 'angular2/router'; let styles = require('./signup.css'); @@ -23,15 +21,17 @@ export class Signup { signup(event, username, password) { event.preventDefault(); - this.http.post('http://localhost:3001/users', { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ + var headers = new Headers(); + headers.append('Accept', 'application/json'); + headers.append('Content-Type', 'application/json'); + this.http.post('http://localhost:3001/users', + JSON.stringify({ username, password - }) - }) + }), + { + headers: headers + } + ) .toRx() .map(status) .map(json) diff --git a/src/typings/browser.d.ts b/src/typings/browser.d.ts new file mode 100644 index 0000000..5549e7c --- /dev/null +++ b/src/typings/browser.d.ts @@ -0,0 +1,95 @@ +interface ObjectConstructor { + assign(target: any, ...sources: any[]): any; + observe(target: any, callback: Function, acceptList?: Array): void; +} + +declare module "angular2/src/dom/browser_adapter" { + class BrowserDomAdapter { + static makeCurrent(): void; + logError(error: any): void; + attrToPropMap: any; + query(selector: string): any; + querySelector(el: any, selector: string): Node; + querySelectorAll(el: any, selector: string): List; + on(el: any, evt: any, listener: any): void; + onAndCancel(el: any, evt: any, listener: any): Function; + dispatchEvent(el: any, evt: any): void; + createMouseEvent(eventType: string): MouseEvent; + createEvent(eventType: any): Event; + getInnerHTML(el: any): any; + getOuterHTML(el: any): any; + nodeName(node: Node): string; + nodeValue(node: Node): string; + type(node: HTMLInputElement): string; + content(node: Node): Node; + firstChild(el: any): Node; + nextSibling(el: any): Node; + parentElement(el: any): any; + childNodes(el: any): List; + childNodesAsList(el: any): List; + clearNodes(el: any): void; + appendChild(el: any, node: any): void; + removeChild(el: any, node: any): void; + replaceChild(el: Node, newChild: any, oldChild: any): void; + remove(el: any): any; + insertBefore(el: any, node: any): void; + insertAllBefore(el: any, nodes: any): void; + insertAfter(el: any, node: any): void; + setInnerHTML(el: any, value: any): void; + getText(el: any): any; + setText(el: any, value: string): void; + getValue(el: any): any; + setValue(el: any, value: string): void; + getChecked(el: any): any; + setChecked(el: any, value: boolean): void; + createTemplate(html: any): HTMLElement; + createElement(tagName: any, doc?: Document): HTMLElement; + createTextNode(text: string, doc?: Document): Text; + createScriptTag(attrName: string, attrValue: string, doc?: Document): HTMLScriptElement; + createStyleElement(css: string, doc?: Document): HTMLStyleElement; + createShadowRoot(el: HTMLElement): DocumentFragment; + getShadowRoot(el: HTMLElement): DocumentFragment; + getHost(el: HTMLElement): HTMLElement; + clone(node: Node): Node; + hasProperty(element: any, name: string): boolean; + getElementsByClassName(element: any, name: string): any; + getElementsByTagName(element: any, name: string): any; + classList(element: any): List; + addClass(element: any, classname: string): void; + removeClass(element: any, classname: string): void; + hasClass(element: any, classname: string): any; + setStyle(element: any, stylename: string, stylevalue: string): void; + removeStyle(element: any, stylename: string): void; + getStyle(element: any, stylename: string): any; + tagName(element: any): string; + attributeMap(element: any): any; + hasAttribute(element: any, attribute: string): any; + getAttribute(element: any, attribute: string): any; + setAttribute(element: any, name: string, value: string): void; + removeAttribute(element: any, attribute: string): any; + templateAwareRoot(el: any): any; + createHtmlDocument(): Document; + defaultDoc(): Document; + getBoundingClientRect(el: any): any; + getTitle(): string; + setTitle(newTitle: string): void; + elementMatches(n: any, selector: string): boolean; + isTemplateElement(el: any): boolean; + isTextNode(node: Node): boolean; + isCommentNode(node: Node): boolean; + isElementNode(node: Node): boolean; + hasShadowRoot(node: any): boolean; + isShadowRoot(node: any): boolean; + importIntoDoc(node: Node): Node; + isPageRule(rule: any): boolean; + isStyleRule(rule: any): boolean; + isMediaRule(rule: any): boolean; + isKeyframesRule(rule: any): boolean; + getHref(el: Element): string; + getEventKey(event: any): string; + getGlobalEventTarget(target: string): EventTarget; + getHistory(): History; + getLocation(): Location; + getBaseHref(): any; + } +} diff --git a/typings/_custom/custom.d.ts b/src/typings/custom.d.ts similarity index 52% rename from typings/_custom/custom.d.ts rename to src/typings/custom.d.ts index a1ad680..f2a207a 100644 --- a/typings/_custom/custom.d.ts +++ b/src/typings/custom.d.ts @@ -1,4 +1,11 @@ +/* + * Our custom types + */ /// -/// /// /// + +/* + * tsd generated types + */ +/// \ No newline at end of file diff --git a/typings/_custom/jwt_decode.d.ts b/src/typings/jwt_decode.d.ts similarity index 100% rename from typings/_custom/jwt_decode.d.ts rename to src/typings/jwt_decode.d.ts diff --git a/typings/_custom/webpack.d.ts b/src/typings/webpack.d.ts similarity index 100% rename from typings/_custom/webpack.d.ts rename to src/typings/webpack.d.ts diff --git a/src/utils/fetch.ts b/src/utils/fetch.ts index 9e64aa9..2918876 100644 --- a/src/utils/fetch.ts +++ b/src/utils/fetch.ts @@ -1,4 +1,4 @@ -/// +/// export function status(response) { if (response.status >= 200 && response.status < 300) { diff --git a/tsd.json b/tsd.json index f9029ed..c9840e5 100644 --- a/tsd.json +++ b/tsd.json @@ -6,7 +6,10 @@ "bundle": "typings/tsd.d.ts", "installed": { "angular2/angular2.d.ts": { - "commit": "2a5858c16563634453533009242b8e0b18521370" + "commit": "212793c4be051977f73675fa9bb125d891df037a" + }, + "angular2/router.d.ts": { + "commit": "212793c4be051977f73675fa9bb125d891df037a" }, "rx/rx.d.ts": { "commit": "8c7444882a2bc2ab87387f8f736a7d97e89b9c90" diff --git a/typings/_custom/browser.d.ts b/typings/_custom/browser.d.ts deleted file mode 100644 index c4c5e2c..0000000 --- a/typings/_custom/browser.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -interface ObjectConstructor { - assign(target: any, ...sources: any[]): any; - observe(target: any, callback: Function, acceptList?: Array): void; -} diff --git a/typings/_custom/ng2.d.ts b/typings/_custom/ng2.d.ts deleted file mode 100644 index 7a4e30a..0000000 --- a/typings/_custom/ng2.d.ts +++ /dev/null @@ -1,1004 +0,0 @@ -declare var zone: any; -declare var Zone: any; - -declare module "angular2/annotations" { - var Component: any; - var View: any; - var Directive: any; - var Query: any; -} - -declare module "angular2/src/http/backends/browser_xhr" { - class BrowserXhr { - constructor(); - build(): any; - } -} -declare module "angular2/http" { - import {BrowserXhr} from "angular2/src/http/backends/browser_xhr" - class Http { - _backend: any; - _defaultOptions: any; - constructor(_backend?: any, _defaultOptions?: any); - request(url: string, options?: any): any; - get(url: string, options?: any): any; - post(url: string, body: any, options?: any): any; - put(url: string, body: any, options?: any): any; - delete(url: string, options?: any): any; - patch(url: string, body: any, options?: any): any; - head(url: string, options?: any): any; - } - class HttpFactory {} - class ResponseOptions {} - class XHRBackend { - private _browserXHR: BrowserXhr; - private _baseResponseOptions: ResponseOptions; - constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions) - createConnection(request: any): any; - } - class ConnectionBackend { - constructor(req: any, browserXHR: any, baseResponseOptions?: any) - } - class RequestOptions {} - class BaseRequestOptions {} - class BaseResponseOptions {} - class MockBackend { - constructor(browserXHR: any, baseResponseOptions: any) - } - var httpInjectables: Array; -} - - -declare module "angular2/mock" { -} - -declare module "angular2/src/core/life_cycle/life_cycle" { - class LifeCycle { - constructor(...args) - tick(): any; - } -} - -declare module "angular2/src/render/dom/compiler/view_loader" { - class ViewLoader {} -} - -declare module "angular2/src/render/dom/compiler/style_url_resolver" { - class StyleUrlResolver {} -} - -declare module "angular2/src/render/dom/compiler/style_inliner" { - class StyleInliner {} -} - -declare module "angular2/src/core/compiler/view_resolver" { - class ViewResolver { - resolve(appComponent: any): any - } -} - -declare module "angular2/src/services/app_root_url" { - class AppRootUrl {} -} - -declare module "angular2/src/core/compiler/view_listener" { - class AppViewListener {} -} - -declare module "angular2/src/render/dom/compiler/template_loader" { - class TemplateLoader { - - } -} - -declare module "angular2/src/core/compiler/template_resolver" { - class TemplateResolver { - - } -} - -declare module "angular2/src/render/xhr_impl" { - class XHRImpl {} -} - -declare module "angular2/src/services/xhr_impl" { - class XHRImpl { - - } -} - -declare module "angular2/src/render/dom/events/key_events" { - class KeyEventsPlugin { - static getEventFullKey: any - getEventFullKey: any - } -} -declare module "angular2/src/render/dom/events/hammer_gestures" { - class HammerGesturesPlugin { - - } -} -declare module "angular2/src/core/compiler/component_url_mapper" { - class ComponentUrlMapper { - - } -} -declare module "angular2/src/services/url_resolver" { - class UrlResolver { - - } - -} -declare module "angular2/src/render/dom/shadow_dom/style_inliner" { - class StyleInliner{} - -} -declare module "angular2/src/core/compiler/dynamic_component_loader" { - class ComponentRef { - constructor(newLocation: any, component: any, dispose: any) - location: any - instance: any - dispose: any - } - class DynamicComponentLoader { - loadAsRoot(appComponentType: any, bindings: any, injector: any): any - } -} -declare module "angular2/src/core/testability/testability" { - class TestabilityRegistry { - - } - class Testability { - - } -} -declare module "angular2/src/core/compiler/view_pool" { - class AppViewPool { - - } - var APP_VIEW_POOL_CAPACITY: any -} -declare module "angular2/src/core/compiler/view_manager" { - class AppViewManager { - - } - -} -declare module "angular2/src/core/compiler/view_manager_utils" { - class AppViewManagerUtils { - - } -} -declare module "angular2/src/core/compiler/proto_view_factory" { - class ProtoViewFactory { - - } -} -declare module "angular2/src/render/dom/compiler/compiler" { - class DefaultDomCompiler { - - } -} -declare module "angular2/src/core/compiler/view_ref" { - var internalView:any -} - -declare module "angular2/src/reflection/reflection" { - var reflector:any - class Reflector { - - } -} -declare module "angular2/src/reflection/reflection_capabilities" { - class ReflectionCapabilities { - - } -} - -declare module "angular2/src/render/dom/view/proto_view" { - class DomProtoView { - rootBindingOffset: any; - element: any; - isTemplateElement(): any - elementBinders(): any - } - -} - -declare module "angular2/src/render/dom/view/view_container" { - class DomViewContainer{} -} - -declare module "angular2/src/render/dom/util" { - var NG_BINDING_CLASS_SELECTOR: any; - var NG_BINDING_CLASS: any ; -} - - -declare module "angular2/src/render/dom/dom_renderer" { - class DomRenderer { - _moveViewNodesIntoParent(): any - _createGlobalEventListener(): any - _createEventListener(): any - } - var DOCUMENT_TOKEN: any; -} - -declare module "angular2/src/render/api" { - class RenderCompiler { - - } - class Renderer { - - } - class RenderViewRef { - - } - class RenderProtoViewRef { - - } - -} -declare module "angular2/src/render/dom/shadow_dom/content_tag" { - function Content(element: any, contentTagSelector:any): void; -} -declare module "angular2/src/render/dom/view/view" { - class DomViewRef { - - } - class DomView { - viewContainers(): any - } - function resolveInternalDomView(viewRef: any): any; -} -declare module "angular2/src/render/dom/shadow_dom/shadow_dom_strategy" { - class ShadowDomStrategy { - prepareShadowRoot(element: any): any - constructLightDom(lightDomView: any, el: any): any - } -} - -declare module "angular2/src/render/dom/events/event_manager" { - class EventManager { - constructor(...args) - addEventListener(element: any, eventName: string, handler: Function): any - addGlobalEventListener(target: string, eventName: string, handler: Function): any - } - class DomEventsPlugin { - - } -} - -declare module "zone.js" { - var zone: any; - var Zone: any; -} - -declare module "rtts_assert/rtts_assert" { - var assert: any; -} - -declare module "angular2/directives" { - function NgSwitch(): void; - function NgSwitchWhen(): void; - function NgSwitchDefault(): void; - function NgNonBindable(): void; - function NgIf(): void; - function NgFor(): void; - - var formDirectives: any; - var coreDirectives: any; - -} - -declare module "angular2/src/change_detection/pipes/pipe" { - class PipeFactory { - } -} - -declare module "angular2/src/change_detection/change_detection" { - var async: any; -} - -declare module "angular2/pipes" { - class ObservablePipe { - constructor(ref: any) - _subscription: any; - _observable: any; - _updateLatestValue(value: any): any; - _subscribe(obs: any): any; - } -} - -declare module "angular2/change_detection" { - interface PipeFactory {} - class Pipe {} - class NullPipeFactory {} - class PipeRegistry { - constructor(pipes: any) - } - var defaultPipeRegistry: any; - var defaultPipes: any; - class Parser { - - } - class Lexer { - - } - class ChangeDetection { - - } - class DynamicChangeDetection { - - } - class PreGeneratedChangeDetection { - static isSupported(): boolean; - } - class JitChangeDetection { - static isSupported(): boolean; - } -} - -declare module "angular2/src/core/zone/ng_zone" { - class NgZone { - constructor(config: any) - initCallbacks(config: any): any - run(context: any): any - } -} - - -declare module "angular2/src/core/compiler/element_ref" { - class ElementRef { - constructor(host: any, location?: any) - nativeElement: any; - } -} - -declare module "angular2/src/core/exception_handler" { - class ExceptionHandler { - - } -} - -declare module "angular2/src/render/xhr" { - class XHR { - - } -} - -declare module "angular2/src/core/application_tokens" { - var appComponentRefToken: any; - var appComponentTypeToken: any; -} - -declare module "angular2/src/core/compiler/compiler" { - class Compiler { - - } - class CompilerCache { - - } -} - -declare module "angular2/forms" { - var formDirectives: any; - var formInjectables: any; - class FormBuilder { - group(config: any): any - array(): any - } - class Validators { - static required(): any - } - class ControlGroup { - value: any - controls: any - include(): any - exclude(): any - } - class Control { - valueChanges(): any - } - class ControlArray { - push(): any - removeAt(): any - } - - class NgControlName { - - } - class NgControlGroup { - - } - class NgFormControl { - - } - class NgModel { - - } - class NgFormModel { - - } - class NgForm { - - } - class NgSelectOption { - - } - class NgRequiredValidator { - - } - class NgControl { - control: any; - valueAccessor: any; - } - -} - -declare module "angular2/src/render/dom/shadow_dom/emulated_unscoped_shadow_dom_strategy" { - class EmulatedUnscopedShadowDomStrategy { - styleHost: any; - constructor(styleHost: any); - hasNativeContentElement(): boolean; - prepareShadowRoot(el: any): any; - constructLightDom(lightDomView: any, el: any): any; - processStyleElement(hostComponentId: string, templateUrl: string, styleEl: any): void; - - } -} - -declare module "angular2/core" { - class ElementRef { - constructor(host: any, location?: any) - nativeElement: any; - } - class QueryList { - onChange(callback: any): void; - } - class DirectiveResolver { - resolve(appComponent: any): any - } -} - -declare module "angular2/render" { - class ShadowDomStrategy { - hasNativeContentElement(): boolean; - prepareShadowRoot(el: any): any; - constructLightDom(lightDomView: any, el: any): any; - processStyleElement(hostComponentId: string, templateUrl: string, styleElement: any): void; - processElement(hostComponentId: string, elementComponentId: string, element: any): void; - } - class NativeShadowDomStrategy extends ShadowDomStrategy { - prepareShadowRoot(el: any): any; - } - class EmulatedUnscopedShadowDomStrategy extends ShadowDomStrategy { - styleHost: any; - constructor(styleHost: any); - hasNativeContentElement(): boolean; - prepareShadowRoot(el: any): any; - constructLightDom(lightDomView: any, el: any): any; - processStyleElement(hostComponentId: string, templateUrl: string, styleEl: any): void; - - } - class EmulatedScopedShadowDomStrategy extends EmulatedUnscopedShadowDomStrategy { - constructor(styleHost: any); - processStyleElement(hostComponentId: string, templateUrl: string, styleEl: any): void; - _moveToStyleHost(styleEl: any): void; - processElement(hostComponentId: string, elementComponentId: string, element: any): void; - - } - class Renderer { -/** - * Creates a root host view that includes the given element. - * @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) - * @return {RenderViewRef} the created view - */ - createRootHostView(hostProtoViewRef: any, hostElementSelector: string): any; - /** - * Creates a regular view out of the given ProtoView - */ - createView(protoViewRef: any): any; - /** - * Destroys the given view after it has been dehydrated and detached - */ - destroyView(viewRef: any): void; - /** - * Attaches a componentView into the given hostView at the given element - */ - attachComponentView(location: any, componentViewRef: any): void; - /** - * Detaches a componentView into the given hostView at the given element - */ - detachComponentView(location: any, componentViewRef: any): void; - /** - * Attaches a view into a ViewContainer (in the given parentView at the given element) at the - * given index. - */ - attachViewInContainer(location: any, atIndex: number, viewRef: any): void; - /** - * Detaches a view into a ViewContainer (in the given parentView at the given element) at the - * given index. - */ - detachViewInContainer(location: any, atIndex: number, viewRef: any): void; - /** - * Hydrates a view after it has been attached. Hydration/dehydration is used for reusing views - * inside of the view pool. - */ - hydrateView(viewRef: any): void; - /** - * Dehydrates a view after it has been attached. Hydration/dehydration is used for reusing views - * inside of the view pool. - */ - dehydrateView(viewRef: any): void; - /** - * Returns the native element at the given location. - * Attention: In a WebWorker scenario, this should always return null! - */ - getNativeElementSync(location: any): any; - /** - * Sets a property on an element. - */ - setElementProperty(location: any, propertyName: string, propertyValue: any): void; - /** - * Sets an attribute on an element. - */ - setElementAttribute(location: any, attributeName: string, attributeValue: string): void; - /** - * Sets a class on an element. - */ - setElementClass(location: any, className: string, isAdd: boolean): void; - /** - * Sets a style on an element. - */ - setElementStyle(location: any, styleName: string, styleValue: string): void; - /** - * Calls a method on an element. - */ - invokeElementMethod(location: any, methodName: string, args: List): void; - /** - * Sets the value of a text node. - */ - setText(viewRef: any, textNodeIndex: number, text: string): void; - /** - * Sets the dispatcher for all events of the given view - */ - setEventDispatcher(viewRef: any, dispatcher: any): void; - } -} - -declare module "angular2/src/render/dom/shadow_dom/style_url_resolver" { - class StyleUrlResolver { - - } -} - -declare module "angular2/src/facade/async" { - class ObservableWrapper { - static callNext(next:any): any; - static subscribe(observer:any): any; - } - class Promise { - then(pro:any): any; - all(all:any): any; - } - class PromiseWrapper { - static completer(): any; - static all(all: any): any; - static then(pro:any, sucess?: any, failure?: any): any; - static wrap(pro:any): any; - } -} - -declare module "angular2/src/facade/collection" { - var List: Array; - var Map: any; - var ListWrapper: any; - var MapWrapper: any; - var StringMapWrapper: any; -} - -declare module "angular2/src/facade/browser" { - var __esModule: boolean; - var win: any; - var window: any; - var document: any; - var location: any; - var gc: () => void; - var Event: any; - var MouseEvent: any; - var KeyboardEvent: any; -} - -declare module "angular2/src/facade/lang" { - var int: any; - var Type: Function; - var assertionsEnabled: any; - function isPresent(bool: any): boolean; - function isBlank(bool: any): boolean; - function isString(bool: any): boolean; - class BaseException { - - } - class RegExpWrapper { - - } - class NumberWrapper { - - } - class StringWrapper { - static toLowerCase(str: string): string; - static toUpperCase(str: string): string; - } - function print(str: any):any; - function stringify(str: any):any; -} - -declare module "angular2/src/core/compiler/directive_resolver" { - class DirectiveResolver { - resolve(appComponent: any): any - } -} - -declare module "angular2/router" { - class Instruction { - - } - class Router { - lastNavigationAttempt: string; - navigate(url: string): any; - config(config: any): any; - deactivate(): any; - activate(instruction: Instruction): any; - recognize(url: string): Instruction; - recognize(url: string): Instruction; - renavigate(): any; - generate(name:string, params:any): string; - subscribe(onNext: Function): void; - parent: any - } - class LocationStrategy {} - class HashLocationStrategy {} - class HTML5LocationStrategy {} - class RouterOutlet { - _elementRef: any; - _loader: any; - _parentRouter: any; - constructor(_elementRef: any, _loader: any, _parentRouter: any, nameAttr?: string) - activate(instruction: any): any - } - class Location { - path(): string; - go(url: string): void; - forward(): void; - back(): void - subscribe(onNext: any, onThrow?: any, onReturn?: any): void; - } - var RouterLink: any; - var RouteParams: any; - var routerInjectables: any; - var RouteConfigAnnotation: any; - var RouteConfig: any; - var routerDirectives: any; -} - - -declare module "angular2/src/dom/browser_adapter" { - class BrowserDomAdapter { - static makeCurrent(): void; - logError(error: any): void; - attrToPropMap: any; - query(selector: string): any; - querySelector(el: any, selector: string): Node; - querySelectorAll(el: any, selector: string): List; - on(el: any, evt: any, listener: any): void; - onAndCancel(el: any, evt: any, listener: any): Function; - dispatchEvent(el: any, evt: any): void; - createMouseEvent(eventType: string): MouseEvent; - createEvent(eventType: any): Event; - getInnerHTML(el: any): any; - getOuterHTML(el: any): any; - nodeName(node: Node): string; - nodeValue(node: Node): string; - type(node: HTMLInputElement): string; - content(node: Node): Node; - firstChild(el: any): Node; - nextSibling(el: any): Node; - parentElement(el: any): any; - childNodes(el: any): List; - childNodesAsList(el: any): List; - clearNodes(el: any): void; - appendChild(el: any, node: any): void; - removeChild(el: any, node: any): void; - replaceChild(el: Node, newChild: any, oldChild: any): void; - remove(el: any): any; - insertBefore(el: any, node: any): void; - insertAllBefore(el: any, nodes: any): void; - insertAfter(el: any, node: any): void; - setInnerHTML(el: any, value: any): void; - getText(el: any): any; - setText(el: any, value: string): void; - getValue(el: any): any; - setValue(el: any, value: string): void; - getChecked(el: any): any; - setChecked(el: any, value: boolean): void; - createTemplate(html: any): HTMLElement; - createElement(tagName: any, doc?: Document): HTMLElement; - createTextNode(text: string, doc?: Document): Text; - createScriptTag(attrName: string, attrValue: string, doc?: Document): HTMLScriptElement; - createStyleElement(css: string, doc?: Document): HTMLStyleElement; - createShadowRoot(el: HTMLElement): DocumentFragment; - getShadowRoot(el: HTMLElement): DocumentFragment; - getHost(el: HTMLElement): HTMLElement; - clone(node: Node): Node; - hasProperty(element: any, name: string): boolean; - getElementsByClassName(element: any, name: string): any; - getElementsByTagName(element: any, name: string): any; - classList(element: any): List; - addClass(element: any, classname: string): void; - removeClass(element: any, classname: string): void; - hasClass(element: any, classname: string): any; - setStyle(element: any, stylename: string, stylevalue: string): void; - removeStyle(element: any, stylename: string): void; - getStyle(element: any, stylename: string): any; - tagName(element: any): string; - attributeMap(element: any): any; - hasAttribute(element: any, attribute: string): any; - getAttribute(element: any, attribute: string): any; - setAttribute(element: any, name: string, value: string): void; - removeAttribute(element: any, attribute: string): any; - templateAwareRoot(el: any): any; - createHtmlDocument(): Document; - defaultDoc(): Document; - getBoundingClientRect(el: any): any; - getTitle(): string; - setTitle(newTitle: string): void; - elementMatches(n: any, selector: string): boolean; - isTemplateElement(el: any): boolean; - isTextNode(node: Node): boolean; - isCommentNode(node: Node): boolean; - isElementNode(node: Node): boolean; - hasShadowRoot(node: any): boolean; - isShadowRoot(node: any): boolean; - importIntoDoc(node: Node): Node; - isPageRule(rule: any): boolean; - isStyleRule(rule: any): boolean; - isMediaRule(rule: any): boolean; - isKeyframesRule(rule: any): boolean; - getHref(el: Element): string; - getEventKey(event: any): string; - getGlobalEventTarget(target: string): EventTarget; - getHistory(): History; - getLocation(): Location; - getBaseHref(): any; - } -} - -declare module "angular2/src/dom/dom_adapter" { - class DomAdapter { - static makeCurrent(): void; - logError(error: any): void; - attrToPropMap: any; - query(selector: string): any; - querySelector(el: any, selector: string): Node; - querySelectorAll(el: any, selector: string): List; - on(el: any, evt: any, listener: any): void; - onAndCancel(el: any, evt: any, listener: any): Function; - dispatchEvent(el: any, evt: any): void; - createMouseEvent(eventType: string): MouseEvent; - createEvent(eventType: any): Event; - getInnerHTML(el: any): any; - getOuterHTML(el: any): any; - nodeName(node: Node): string; - nodeValue(node: Node): string; - type(node: HTMLInputElement): string; - content(node: Node): Node; - firstChild(el: any): Node; - nextSibling(el: any): Node; - parentElement(el: any): any; - childNodes(el: any): List; - childNodesAsList(el: any): List; - clearNodes(el: any): void; - appendChild(el: any, node: any): void; - removeChild(el: any, node: any): void; - replaceChild(el: Node, newChild: any, oldChild: any): void; - remove(el: any): any; - insertBefore(el: any, node: any): void; - insertAllBefore(el: any, nodes: any): void; - insertAfter(el: any, node: any): void; - setInnerHTML(el: any, value: any): void; - getText(el: any): any; - setText(el: any, value: string): void; - getValue(el: any): any; - setValue(el: any, value: string): void; - getChecked(el: any): any; - setChecked(el: any, value: boolean): void; - createTemplate(html: any): HTMLElement; - createElement(tagName: any, doc?: Document): HTMLElement; - createTextNode(text: string, doc?: Document): Text; - createScriptTag(attrName: string, attrValue: string, doc?: Document): HTMLScriptElement; - createStyleElement(css: string, doc?: Document): HTMLStyleElement; - createShadowRoot(el: HTMLElement): DocumentFragment; - getShadowRoot(el: HTMLElement): DocumentFragment; - getHost(el: HTMLElement): HTMLElement; - clone(node: Node): Node; - hasProperty(element: any, name: string): boolean; - getElementsByClassName(element: any, name: string): any; - getElementsByTagName(element: any, name: string): any; - classList(element: any): List; - addClass(element: any, classname: string): void; - removeClass(element: any, classname: string): void; - hasClass(element: any, classname: string): any; - setStyle(element: any, stylename: string, stylevalue: string): void; - removeStyle(element: any, stylename: string): void; - getStyle(element: any, stylename: string): any; - tagName(element: any): string; - attributeMap(element: any): any; - hasAttribute(element: any, attribute: string): any; - getAttribute(element: any, attribute: string): any; - setAttribute(element: any, name: string, value: string): void; - removeAttribute(element: any, attribute: string): any; - templateAwareRoot(el: any): any; - createHtmlDocument(): Document; - defaultDoc(): Document; - getBoundingClientRect(el: any): any; - getTitle(): string; - setTitle(newTitle: string): void; - elementMatches(n: any, selector: string): boolean; - isTemplateElement(el: any): boolean; - isTextNode(node: Node): boolean; - isCommentNode(node: Node): boolean; - isElementNode(node: Node): boolean; - hasShadowRoot(node: any): boolean; - isShadowRoot(node: any): boolean; - importIntoDoc(node: Node): Node; - isPageRule(rule: any): boolean; - isStyleRule(rule: any): boolean; - isMediaRule(rule: any): boolean; - isKeyframesRule(rule: any): boolean; - getHref(el: Element): string; - getEventKey(event: any): string; - getGlobalEventTarget(target: string): EventTarget; - getHistory(): History; - getLocation(): Location; - getBaseHref(): any; - } - var DOM: DomAdapter; -} -declare module "angular2/src/dom/parse5_adapter" { - class Parse5DomAdapter { - static makeCurrent(): void; - logError(error: any): void; - attrToPropMap: any; - query(selector: string): any; - querySelector(el: any, selector: string): Node; - querySelectorAll(el: any, selector: string): List; - on(el: any, evt: any, listener: any): void; - onAndCancel(el: any, evt: any, listener: any): Function; - dispatchEvent(el: any, evt: any): void; - createMouseEvent(eventType: string): MouseEvent; - createEvent(eventType: any): Event; - getInnerHTML(el: any): any; - getOuterHTML(el: any): any; - nodeName(node: Node): string; - nodeValue(node: Node): string; - type(node: HTMLInputElement): string; - content(node: Node): Node; - firstChild(el: any): Node; - nextSibling(el: any): Node; - parentElement(el: any): any; - childNodes(el: any): List; - childNodesAsList(el: any): List; - clearNodes(el: any): void; - appendChild(el: any, node: any): void; - removeChild(el: any, node: any): void; - replaceChild(el: Node, newChild: any, oldChild: any): void; - remove(el: any): any; - insertBefore(el: any, node: any): void; - insertAllBefore(el: any, nodes: any): void; - insertAfter(el: any, node: any): void; - setInnerHTML(el: any, value: any): void; - getText(el: any): any; - setText(el: any, value: string): void; - getValue(el: any): any; - setValue(el: any, value: string): void; - getChecked(el: any): any; - setChecked(el: any, value: boolean): void; - createTemplate(html: any): HTMLElement; - createElement(tagName: any, doc?: Document): HTMLElement; - createTextNode(text: string, doc?: Document): Text; - createScriptTag(attrName: string, attrValue: string, doc?: Document): HTMLScriptElement; - createStyleElement(css: string, doc?: Document): HTMLStyleElement; - createShadowRoot(el: HTMLElement): DocumentFragment; - getShadowRoot(el: HTMLElement): DocumentFragment; - getHost(el: HTMLElement): HTMLElement; - clone(node: Node): Node; - hasProperty(element: any, name: string): boolean; - getElementsByClassName(element: any, name: string): any; - getElementsByTagName(element: any, name: string): any; - classList(element: any): List; - addClass(element: any, classname: string): void; - removeClass(element: any, classname: string): void; - hasClass(element: any, classname: string): any; - setStyle(element: any, stylename: string, stylevalue: string): void; - removeStyle(element: any, stylename: string): void; - getStyle(element: any, stylename: string): any; - tagName(element: any): string; - attributeMap(element: any): any; - hasAttribute(element: any, attribute: string): any; - getAttribute(element: any, attribute: string): any; - setAttribute(element: any, name: string, value: string): void; - removeAttribute(element: any, attribute: string): any; - templateAwareRoot(el: any): any; - createHtmlDocument(): Document; - defaultDoc(): Document; - getBoundingClientRect(el: any): any; - getTitle(): string; - setTitle(newTitle: string): void; - elementMatches(n: any, selector: string): boolean; - isTemplateElement(el: any): boolean; - isTextNode(node: Node): boolean; - isCommentNode(node: Node): boolean; - isElementNode(node: Node): boolean; - hasShadowRoot(node: any): boolean; - isShadowRoot(node: any): boolean; - importIntoDoc(node: Node): Node; - isPageRule(rule: any): boolean; - isStyleRule(rule: any): boolean; - isMediaRule(rule: any): boolean; - isKeyframesRule(rule: any): boolean; - getHref(el: Element): string; - getEventKey(event: any): string; - getGlobalEventTarget(target: string): EventTarget; - getHistory(): History; - getLocation(): Location; - getBaseHref(): any; - } -} - - - -declare module "angular2/src/di/binding" { - class Binding { - - } -} - -declare module "angular2/di" { - class Binding {} - function bind(token: any): any; - class Injector { - resolveAndCreateChild(bindings: [any]): Injector; - static resolveAndCreate(bindings: any): any; - static fromResolvedBindings(bindings: any): any; - asyncGet(di: any):any - get(di: any):any - } - var Inject: any; - var Injectable: any; - var Dependency: any; - var Optional: any; - - var ResolvedBinding: any; - var Key: any; - var KeyRegistry: any; - var TypeLiteral: any; - var NoBindingError: any; - var AbstractBindingError: any; - var AsyncBindingError: any; - var CyclicDependencyError: any; - var InstantiationError: any; - var InvalidBindingError: any; - var NoAnnotationError: any; - var OpaqueToken: any; - var ___esModule: any; - var InjectAnnotation: any; - var InjectPromiseAnnotation: any; - var InjectLazyAnnotation: any; - var OptionalAnnotation: any; - var InjectableAnnotation: any; - var DependencyAnnotation: any; -} diff --git a/typings/angular2/angular2.d.ts b/typings/angular2/angular2.d.ts index a4af962..dfad7d3 100644 --- a/typings/angular2/angular2.d.ts +++ b/typings/angular2/angular2.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular v2.0.0-alpha.26 +// Type definitions for Angular v2.0.0-alpha.31 // Project: http://angular.io/ // Definitions by: angular team // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -17,1612 +17,1286 @@ interface List extends Array {} interface Map {} -interface StringMap {} -interface Type {} +interface StringMap extends Map {} -declare module "angular2/angular2" { +declare module ng { type SetterFn = typeof Function; type int = number; + interface Type extends Function { + new (...args:any[]):any; + } // See https://github.com/Microsoft/TypeScript/issues/1168 class BaseException /* extends Error */ { - message: any; - stack: any; + message: string; + stack: string; toString(): string; } + interface InjectableReference {} } -declare module "angular2/angular2" { - class AbstractChangeDetector extends ChangeDetector { - addChild(cd: ChangeDetector): any; - addShadowDomChild(cd: ChangeDetector): any; - callOnAllChangesDone(): any; - checkNoChanges(): any; - detectChanges(): any; - detectChangesInRecords(throwOnChange: boolean): any; - lightDomChildren: List; - markAsCheckOnce(): any; - markPathToRootAsCheckOnce(): any; - mode: string; - parent: ChangeDetector; - ref: ChangeDetectorRef; - remove(): any; - removeChild(cd: ChangeDetector): any; - removeShadowDomChild(cd: ChangeDetector): any; - shadowDomChildren: List; - } - - class ProtoRecord { - args: List; - bindingRecord: BindingRecord; - contextIndex: number; - directiveIndex: DirectiveIndex; - expressionAsString: string; - fixedArgs: List; - funcOrValue: any; - isLifeCycleRecord(): boolean; - isPipeRecord(): boolean; - isPureFunction(): boolean; - lastInBinding: boolean; - lastInDirective: boolean; - mode: number; - name: string; - selfIndex: number; - } - - class LifecycleEvent { - name: string; - } - - interface FormDirective { - addControl(dir: ControlDirective): void; - addControlGroup(dir: ControlGroupDirective): void; - getControl(dir: ControlDirective): Control; - removeControl(dir: ControlDirective): void; - removeControlGroup(dir: ControlGroupDirective): void; - updateModel(dir: ControlDirective, value: any): void; - } - - - /** - * A directive that contains a group of [ControlDirective]. - * - * @exportedAs angular2/forms - */ - class ControlContainerDirective { - formDirective: FormDirective; - name: string; - path: List; - } - - - /** - * A marker annotation that marks a class as available to `Injector` for creation. Used by tooling - * for generating constructor stubs. - * - * ``` - * class NeedsService { - * constructor(svc:UsefulService) {} - * } - * - * @Injectable - * class UsefulService {} - * ``` - * @exportedAs angular2/di_annotations - */ - class Injectable { - } - - /** - * Injectable Objects that contains a live list of child directives in the light Dom of a directive. - * The directives are kept in depth-first pre-order traversal of the DOM. - * - * In the future this class will implement an Observable interface. - * For now it uses a plain list of observable callbacks. - * - * @exportedAs angular2/view - */ - class BaseQueryList { - add(obj: any): any; - fireCallbacks(): any; - onChange(callback: any): any; - removeCallback(callback: any): any; - reset(newList: any): any; - } - - class AppProtoView { - bindElement(parent: ElementBinder, distanceToParent: int, protoElementInjector: ProtoElementInjector, componentDirective?: DirectiveBinding): ElementBinder; - - /** - * Adds an event binding for the last created ElementBinder via bindElement. - * - * If the directive index is a positive integer, the event is evaluated in the context of - * the given directive. - * - * If the directive index is -1, the event is evaluated in the context of the enclosing view. - * - * @param {string} eventName - * @param {AST} expression - * @param {int} directiveIndex The directive index in the binder or -1 when the event is not bound - * to a directive - */ - bindEvent(eventBindings: List, boundElementIndex: number, directiveIndex?: int): void; - elementBinders: List; - protoChangeDetector: ProtoChangeDetector; - protoLocals: Map; - render: RenderProtoViewRef; - variableBindings: Map; - } - - - /** - * Const of making objects: http://jsperf.com/instantiate-size-of-object - */ - class AppView implements ChangeDispatcher, EventDispatcher { - callAction(elementIndex: number, actionExpression: string, action: Object): any; - changeDetector: ChangeDetector; - componentChildViews: List; - - /** - * The context against which data-binding expressions in this view are evaluated against. - * This is always a component instance. - */ - context: any; - dispatchEvent(elementIndex: number, eventName: string, locals: Map): boolean; - elementInjectors: List; - freeHostViews: List; - getDetectorFor(directive: DirectiveIndex): any; - getDirectiveFor(directive: DirectiveIndex): any; - hydrated(): boolean; - init(changeDetector: ChangeDetector, elementInjectors: List, rootElementInjectors: List, preBuiltObjects: List, componentChildViews: List): any; - - /** - * Variables, local to this view, that can be used in binding expressions (in addition to the - * context). This is used for thing like `