From fa6623265c75818595fdbb1c1d0857c850fe6053 Mon Sep 17 00:00:00 2001 From: Xander Smalbil Date: Sat, 13 Jun 2015 15:31:23 +0200 Subject: [PATCH 01/26] Update webpack.config.js I noticed a duplicate require path. --- webpack.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 5a1d1d4..dbd5282 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,7 +2,6 @@ var webpack = require('webpack'); var HtmlWebpackPlugin = require("html-webpack-plugin"); var path = require('path'); var sliceArgs = Function.prototype.call.bind(Array.prototype.slice); -var path = require('path'); module.exports = { devtool: 'source-map', From b4dc28d96f103a878d570b7ea023de728ec40b0d Mon Sep 17 00:00:00 2001 From: gdi2290 Date: Tue, 7 Jul 2015 03:16:50 -0700 Subject: [PATCH 02/26] chore: update to alpha 29 --- package.json | 11 +- src/app/LoggedInOutlet.ts | 16 +- src/app/app.html | 3 +- src/app/app.ts | 36 +- src/common/formInjectables.ts | 6 - src/home/home.ts | 9 +- src/index.ts | 9 +- src/login/login.ts | 3 +- src/signup/signup.ts | 11 +- typings/_custom/ng2.d.ts | 887 ++++++++++++++++++++++++++++++---- 10 files changed, 835 insertions(+), 156 deletions(-) delete mode 100644 src/common/formInjectables.ts diff --git a/package.json b/package.json index adc7239..0d197e7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "angular2-full-app-demo", + "name": "angular2-authentication-sample", "version": "0.0.0", "description": "This is a sample that shows how to add authentication to an Angular 2 (ng2) app", "main": "", @@ -11,17 +11,20 @@ "type": "git", "url": "https://github.com/auth0/angular2-authentication-sample.git" }, - "author": "Martin Gontovnikas (http://gon.to) ", + "contributors": [ + "Martin Gontovnikas (http://gon.to) ", + "PatrickJS " + ], "license": "MIT", "bugs": { "url": "https://github.com/auth0/angular2-authentication-sample/issues" }, "homepage": "https://github.com/auth0/angular2-authentication-sample", "dependencies": { - "angular2": "2.0.0-alpha.26", + "angular2": "2.0.0-alpha.29", "raw-loader": "^0.5.1", "reflect-metadata": "^0.1.0", - "rtts_assert": "2.0.0-alpha.26", + "rtts_assert": "2.0.0-alpha.29", "rx": "^2.5.3", "zone.js": "^0.5.0", "bootstrap": "~3.3.4", diff --git a/src/app/LoggedInOutlet.ts b/src/app/LoggedInOutlet.ts index bfae6b2..590a326 100644 --- a/src/app/LoggedInOutlet.ts +++ b/src/app/LoggedInOutlet.ts @@ -3,22 +3,20 @@ import {Router, RouterOutlet} from 'angular2/router'; import {Injector} from 'angular2/di'; import {Login} from '../login/login'; -@Directive({selector: 'router-outlet'}) +@Directive({ + selector: 'router-outlet' +}) export class LoggedInRouterOutlet extends RouterOutlet { publicRoutes: any - constructor( - elementRef: ElementRef, - _loader: DynamicComponentLoader, - _parentRouter: Router, - _injector: Injector, - @Attribute('name') nameAttr: string) { + constructor(public _elementRef: ElementRef, public _loader: DynamicComponentLoader, + public _parentRouter: Router, @Attribute('name') nameAttr: string) { + super(_elementRef, _loader, _parentRouter, nameAttr); this.publicRoutes = { '/login': true, '/signup': true }; - super(elementRef, _loader, _parentRouter, _injector, nameAttr); } activate(instruction) { @@ -26,6 +24,6 @@ export class LoggedInRouterOutlet extends RouterOutlet { if (!this.publicRoutes[url] && !localStorage.getItem('jwt')) { instruction.component = Login; } - super.activate(instruction); + return super.activate(instruction); } } diff --git a/src/app/app.html b/src/app/app.html index aedcdf3..0680b43 100644 --- a/src/app/app.html +++ b/src/app/app.html @@ -1,2 +1 @@ - - + diff --git a/src/app/app.ts b/src/app/app.ts index df81abf..f28ea01 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -1,12 +1,11 @@ /// import {View, Component} from 'angular2/angular2'; +import {Location, RouteConfig, RouterLink, Router} from 'angular2/router'; +import {LoggedInRouterOutlet} from './LoggedInOutlet'; import {Home} from '../home/home'; import {Login} from '../login/login'; import {Signup} from '../signup/signup'; -import {RouteConfig, RouterOutlet, RouterLink, Router} from 'angular2/router'; -import {BrowserLocation} from 'angular2/src/router/browser_location'; -import {LoggedInRouterOutlet} from './LoggedInOutlet'; let template = require('./app.html'); @@ -15,33 +14,16 @@ let template = require('./app.html'); selector: 'auth-app' }) @View({ - template:`${template}`, - directives: [LoggedInRouterOutlet] + template: template, + directives: [ LoggedInRouterOutlet ] }) @RouteConfig([ - { path: '/home', as: 'home', component: Home }, - { path: '/login', as: 'login', component: Login }, - { path: '/signup', as: 'signup', component: Signup } + { path: '/', redirectTo: '/home' }, + { path: '/home', as: 'home', component: Home }, + { path: '/login', as: 'login', component: Login }, + { path: '/signup', as: 'signup', component: Signup } ]) export class App { - router: Router; - constructor(router: Router, browserLocation: BrowserLocation) { - // we need to manually go to the correct uri until the router is fixed - this.router = router; - let uri = browserLocation.path(); - if (uri === '' || uri === '/') { - router.navigate('/home'); - } else { - router.navigate(uri); - } - } - - goTo(event, url) { - event.preventDefault(); - this.router.navigate(url).then(() => { - console.log("Router successfully to", url); - }, () => { - console.log("Error going to URL", url); - }); + constructor(public router: Router) { } } diff --git a/src/common/formInjectables.ts b/src/common/formInjectables.ts deleted file mode 100644 index d996d92..0000000 --- a/src/common/formInjectables.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// -import {FormBuilder} from 'angular2/forms'; - -export var formInjectables: Array = [ - FormBuilder -]; diff --git a/src/home/home.ts b/src/home/home.ts index 41c11d9..a10ffea 100644 --- a/src/home/home.ts +++ b/src/home/home.ts @@ -13,18 +13,17 @@ let template = require('./home.html'); selector: 'home' }) @View({ - template:`\n${template}`, - directives: [coreDirectives] + styles: [ styles ], + template: template, + directives: [ coreDirectives ] }) export class Home { jwt: string; decodedJwt: string; - router: Router; response: string; api: string; - constructor(router: Router) { - this.router = router; + constructor(public router: Router) { this.jwt = localStorage.getItem('jwt'); this.decodedJwt = this.jwt && window.jwt_decode(this.jwt); } diff --git a/src/index.ts b/src/index.ts index f9fc1eb..fc05dba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ /// -import {routerInjectables} from 'angular2/router'; -import {formInjectables} from './common/formInjectables'; import { bootstrap } from 'angular2/angular2'; import { bind } from 'angular2/di'; -import { PipeRegistry } from 'angular2/change_detection'; +import { routerInjectables } from 'angular2/router'; +import { formInjectables } from 'angular2/forms'; +import { httpInjectables } from 'angular2/http'; import { App } from './app/app'; @@ -12,6 +12,7 @@ bootstrap( App, [ formInjectables, - routerInjectables + routerInjectables, + httpInjectables ] ); diff --git a/src/login/login.ts b/src/login/login.ts index 380f20d..9bfd200 100644 --- a/src/login/login.ts +++ b/src/login/login.ts @@ -13,7 +13,8 @@ let template = require('./login.html'); selector: 'login' }) @View({ - template:`\n${template}`, + styles: [ styles ], + template: template, directives: [RouterLink] }) export class Login { diff --git a/src/signup/signup.ts b/src/signup/signup.ts index b29a48e..a4f0f27 100644 --- a/src/signup/signup.ts +++ b/src/signup/signup.ts @@ -12,15 +12,12 @@ let template = require('./signup.html'); selector: 'signup' }) @View({ - directives: [RouterLink, coreDirectives], - template:`\n${template}` - + directives: [ RouterLink, coreDirectives ], + styles: [ styles ], + template: template }) export class Signup { - router: Router; - - constructor(router: Router) { - this.router = router; + constructor(public router: Router) { } signup(event, username, password) { diff --git a/typings/_custom/ng2.d.ts b/typings/_custom/ng2.d.ts index ac375bf..7a4e30a 100644 --- a/typings/_custom/ng2.d.ts +++ b/typings/_custom/ng2.d.ts @@ -1,49 +1,271 @@ 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/change_detection" { - class Pipe {} - class NullPipeFactory {} - class PipeRegistry { - constructor(pipes: any) +declare module "angular2/src/http/backends/browser_xhr" { + class BrowserXhr { + constructor(); + build(): any; } - class JitChangeDetection {} - class ChangeDetection {} - class DynamicChangeDetection {} - var defaultPipes: 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/src/core/zone/ng_zone" { - class NgZone { - runOutsideAngular(func: Function): any +declare module "angular2/mock" { +} + +declare module "angular2/src/core/life_cycle/life_cycle" { + class LifeCycle { + constructor(...args) + tick(): any; } } -declare module 'angular2/src/services/url_resolver' { - class UrlResolver {} +declare module "angular2/src/render/dom/compiler/view_loader" { + class ViewLoader {} } -declare module "angular2/src/facade/async" { - class Observable {} - class EventEmitter { - next(val:any) - return(val:any) - throw(val:any) +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 } - class PromiseWrapper { +} + +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/dom/shadow_dom/style_url_resolver" { - class StyleUrlResolver {} +declare module "angular2/src/render/xhr_impl" { + class XHRImpl {} } -declare module "angular2/src/core/life_cycle/life_cycle" { - class LifeCycle { - tick(): any; +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 { + } } @@ -52,6 +274,10 @@ declare module "zone.js" { var Zone: any; } +declare module "rtts_assert/rtts_assert" { + var assert: any; +} + declare module "angular2/directives" { function NgSwitch(): void; function NgSwitchWhen(): void; @@ -65,111 +291,398 @@ declare module "angular2/directives" { } +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(controls: any): any; + group(config: any): any + array(): any + } + class Validators { + static required(): any + } + class ControlGroup { + value: any + controls: any + include(): any + exclude(): any } class Control { - constructor(controls: any) - updateValue(value: any) - _valueChanges: any - valueChanges: any + valueChanges(): any } class ControlArray { - removeAt(index: any) - push(item: any) + push(): any + removeAt(): any } - class ControlGroup { - constructor(controls: any) - controls: any; - valueChanges: any; + + class NgControlName { + } - class Validators { - static required: any; + 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 EmulatedScopedShadowDomStrategy { - constructor(styleInliner: any, styleUrlResolver: any, styleHost: any) + 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 EmulatedUnscopedShadowDomStrategy { - constructor(styleUrlResolver: any, styleHost: any) + 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 NativeShadowDomStrategy { - constructor(styleUrlResolver: any) + 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; } - class ShadowDomStrategy {} +} + +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; - const Event: any; - const MouseEvent: any; - const KeyboardEvent: any; + var Event: any; + var MouseEvent: any; + var KeyboardEvent: any; } -declare module "angular2/src/router/browser_location" { - class BrowserLocation { - path(): string +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/router/location" { - class Location { - normalize(url: string): string +declare module "angular2/src/core/compiler/directive_resolver" { + class DirectiveResolver { + resolve(appComponent: any): any } } declare module "angular2/router" { - class Instruction {} + class Instruction { + + } class Router { - _registry: any; - _pipeline: any; - hostComponent: any; - navigating: boolean; lastNavigationAttempt: string; - previousUrl: string; - _currentInstruction: any; - _outlets: any; - _subject: any; - navigate(url: string): Promise; - config(config: any): Promise; - deactivate(): Promise; - activate(instruction: Instruction): Promise; + navigate(url: string): any; + config(config: any): any; + deactivate(): any; + activate(instruction: Instruction): any; recognize(url: string): Instruction; recognize(url: string): Instruction; - renavigate(): Promise; + renavigate(): any; generate(name:string, params:any): string; subscribe(onNext: Function): void; - parent: Router; + parent: any } + class LocationStrategy {} + class HashLocationStrategy {} + class HTML5LocationStrategy {} class RouterOutlet { - constructor(elementRef: any, _loader: any, _parentRouter: any, _injector: any, nameAttr: any) + _elementRef: any; _loader: any; _parentRouter: any; - _injector: any; - _childRouter: any; - _componentRef: any; - _elementRef: any; - _currentInstruction: any; - /** - * Given an instruction, update the contents of this viewport. - */ - activate(instruction: any): any; - deactivate(): any; - canDeactivate(instruction: any): 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; } - class RouteParams {} var RouterLink: any; + var RouteParams: any; var routerInjectables: any; var RouteConfigAnnotation: any; var RouteConfig: any; + var routerDirectives: any; } @@ -264,15 +777,212 @@ declare module "angular2/src/dom/browser_adapter" { } } -declare module "angular2/di" { +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 Binding: any; - var ResolvedBinding: 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; @@ -291,9 +1001,4 @@ declare module "angular2/di" { var OptionalAnnotation: any; var InjectableAnnotation: any; var DependencyAnnotation: any; - var Inject: any; - var InjectPromise: any; - var InjectLazy: any; - var Optional: any; - var Injectable: any; } From 6eb299a0602abe3fe00bbadfba9d41e5a36d4672 Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Tue, 7 Jul 2015 09:47:56 -0700 Subject: [PATCH 03/26] Update Readme.md --- Readme.md | 184 +++--------------------------------------------------- 1 file changed, 9 insertions(+), 175 deletions(-) diff --git a/Readme.md b/Readme.md index 5567d08..5f5b682 100644 --- a/Readme.md +++ b/Readme.md @@ -1,179 +1,13 @@ -

- Webpack and Angular 2 -

+# Angular 2: Authentication sample. -# Angular2 Webpack Starter [![Join the chat at https://gitter.im/angular-class/angular2-webpack-starter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/angular-class/angular2-webpack-starter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +This sample shows how to create an angular 2 app that: +* Has **lots of different routes** +* Performs **authentication with JWTs** +* **Calls APIs** authenticated and not. +* Extends the **RouterOutlet** for route pipeline changes. -> A starter kit featuring [Angular 2](https://angular.io) ([Router](https://angular.io/docs/js/latest/api/router/), [Forms](https://angular.io/docs/js/latest/api/forms/), [Services](https://gist.github.com/gdi2290/634101fec1671ee12b3e#_follow_@AngularClass_on_twitter)), [TypeScript](http://www.typescriptlang.org/), and [Webpack](http://webpack.github.io/) by [AngularClass](https://angularclass.com). +> You can **learn more about how it works [in this blogpost](https://auth0.com/blog/2015/05/14/creating-your-first-real-world-angular-2-app-from-authentication-to-calling-an-api-and-everything-in-between/)** -> If you're looking for Angular 1.x please use [NG6-starter](https://github.com/angular-class/NG6-starter) +## Running it -This repo serves as an extremely minimal starter for anyone looking to get up and running with Angular 2 and TypeScript. Using a [Webpack](http://webpack.github.io/) for building our files and assisting with boilerplate. -* Best practice in file organization for Angular 2. -* Ready to go build system using Webpack for working with TypeScript. - -### Quick start -> Clone/Download the repo then edit `app.ts` inside [`/src/app/components/app.ts`](/src/app/components/app.ts) - -```bash -$ npm start # then open your browser and go to http://localhost:8080 -``` - - -## File Structure -We use the component approach in our starter. This is the new standard for developing Angular apps and a great way to ensure maintainable code by encapsulation of our behavior logic. A component is basically a self contained app usually in a single file or a folder with each concern as a file: style, template, specs, e2e, and component class. Here's how it looks: -``` -angular2-webpack-starter/ - ├──public/ * static assets are served here - │ ├──lib/ * static libraries - │ │ └──traceur-runtime.min.js * ignore this file. This is needed to polyfill the browser to for ES6 features to similarly - │ │ - │ ├──favicon.ico * replace me with your own favicon.ico - │ ├──service-worker.js * ignore this. Web App service worker that's not complete yet - │ ├──robots.txt * for search engines to crawl your website - │ ├──human.txt * for humans to know who the developers are - │ │ - │ └──index.html * Index.html: where we place our script tags - │ - ├──src/ * our source files that will be compiled to javascript - │ ├──app/ * WebApp folder - │ │ ├──bootstrap.ts * entry file for app - │ │ │ - │ │ ├──components/ * where most of components live - │ │ │ ├──todo.ts * an example of a component using a service and forms - │ │ │ ├──dashboard.ts * a simple Component with a simple Directive example - │ │ │ │ - │ │ │ ├──home/ * example component as a folder - │ │ │ │ ├──home.ts * how you would require your template and style files - │ │ │ │ ├──home.css * simple css file for home styles - │ │ │ │ └──home.html * simple html file for home template - │ │ │ │ - │ │ │ └──app.ts * App.ts: entry file for components - │ │ │ - │ │ ├──services/ * where we keep our services used throughout our app - │ │ │ ├──TodoService.ts * an example of a simple service - │ │ │ └──services.ts * where we gather our injectables from our services - │ │ │ - │ │ └──directives/ * where we keep our directives used throughout our app - │ │ ├──Autofocus.ts * another simple directive to fix a problem with the router - │ │ └──directives.ts * where we gather our directives from our directives - │ │ - │ └──common/ * where common files used throughout our app - │ ├──shadowDomInjectables.ts * determind if the user is on chrome and use ShadowDom - │ ├──jitInjectables.ts * turn on Just-In-Time Change Detection - │ ├──formInjectables.ts * services exported by angular/forms which is the FormBuilder - │ └──BrowserDomAdapter.ts * ignore this. we need to set the DomAdapter to the browser - │ - ├──typings/ * where tsd defines it's types definitions - │ ├──_custom/ * where we define our custom types - │ │ ├──ng2.d.ts * where we patch angular2 types with our own types until it's fixed - │ │ └──custom.d.ts * we include all of our custom types here - │ │ - │ ├──angular2/ - │ │ └──angular2.d.ts * our Angular 2 type definitions - │ │ - │ ├──es6-promise/ - │ │ └──es6-promise.d.ts * ES6 promises type definitions - │ │ - │ ├──rx/ - │ │ ├──rx-lite.d.ts * rx-lite type definitions - │ │ └──rx.d.ts * rx type definitions - │ │ - │ └──tsd.d.ts.ts * our main file for all of our type definitions - │ - ├──tsconfig.json * config that webpack uses for typescript - ├──tsd.json * config that tsd uses for managing it's definitions - ├──package.json * what npm uses to manage it's dependencies - └──webpack.config.js * our webpack config -``` - -# Getting Started -## Dependencies -What you need to run this app: -* `node` and `npm` (`brew install node`) -* Ensure you're running the latest versions Node `v0.12.2`+ and NPM `2.10.0`+ - -Once you have those, you should install these globals with `npm install -global`: -* `webpack` (`npm install -global webpack`) -* `webpack-dev-server` (`npm install -global webpack-dev-server`) - -## Installing -* `fork` this repo -* `clone` your fork -* `npm install` to install all dependencies -* `npm run server` to start the server - -## Running the app -After you have installed all dependencies you can now run the app. Run `npm server` to start a local server using `webpack-dev-server` which will watch, build (in-memory), and reload for you. The port will be displayed to you as `http://localhost:8080`. - -### server -```bash -$ npm run server -``` - -### build files -```bash -$ npm run build -``` - -### watch and build files -```bash -$ npm run watch -``` - -# TypeScript -> To take full advantage of TypeScript with autocomplete you would have to install it globally and use an editor with the correct TypeScript plugins. - -## Use latest TypeScript compiler -TypeScript 1.5 beta includes everything you need. Make sure to upgrade, even if you installed TypeScript previously. - - $ npm install -global typescript@^1.5.0-beta - -## .d.ts Typings -The typings in `typings/` are partially autogenerated, partially hand -written. All the symbols should be present, but probably have wrong paramaters -and missing members. Modify them as you go. - - $ npm install -global tsd - > You may need to require `reference path` for your editor to autocomplete correctly - ``` - /// - /// - ``` - Otherwise including them in `tsd.json` is prefered - -## Use a TypeScript-aware editor -We have good experience using these editors: - -* [Visual Studio Code](https://code.visualstudio.com/) -* [Webstorm 10](https://www.jetbrains.com/webstorm/download/) -* [Atom](https://atom.io/) with [TypeScript plugin](https://atom.io/packages/atom-typescript) -* [Sublime Text](http://www.sublimetext.com/3) with [Typescript-Sublime-Plugin](https://github.com/Microsoft/Typescript-Sublime-plugin#installation) - -## Frequently asked questions -* Why we are using traceur? This is due to Angular 2 not being fully migrated to TypeScript and will be removed soon. -* What's the current browser support for Angular 2 Alpha? as of version 2.0.0-alpha.26: Chrome (43, 44, 45), Firefox (37, 39, 40), IE 11, Safari 8, iOS 8, Android 5.1 (Chrome Mobile 39). -* What is the TypeScript warning "Value of type 'typeof Directive' is not callable. Did you mean to include 'new'?"? This is an error with the typings defined in DefinitelyTyped (please ignore until it's fixed) - -### Todo -- [ ] production/development environments -- [ ] testing -- [ ] e2e -- [ ] production services examples -- [ ] hot-component-reloading - -# Starter Kit Support and Questions -> Contact us anytime for anything about this repo - -* [Gitter: angular-class/angular2-webpack-starter](https://gitter.im/angular-class/angular2-webpack-starter) -* [Twitter: @AngularClass](https://twitter.com/AngularClass) - -___ - -enjoy — **AngularClass** - -

- -[![AngularClass](https://angularclass.com/images/ng-crown.svg "Angular Class")](https://angularclass.com) -##[AngularClass](https://angularclass.com) -> Learn Angular in 2 days from the best +Just install `node` and run `npm install` and then `npm start` :boom:. From 92203ee9fc71e372ed84c868045b6c7d331e5162 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Wed, 8 Jul 2015 10:54:56 -0700 Subject: [PATCH 04/26] Update to Angular 2.0.0-alpha.30 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d197e7..f3d0ccb 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "homepage": "https://github.com/auth0/angular2-authentication-sample", "dependencies": { - "angular2": "2.0.0-alpha.29", + "angular2": "2.0.0-alpha.30", "raw-loader": "^0.5.1", "reflect-metadata": "^0.1.0", "rtts_assert": "2.0.0-alpha.29", From f2d440b8c1fc424b7e9a6c23e41ff08a0d2a5272 Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Fri, 24 Jul 2015 08:52:08 -0700 Subject: [PATCH 05/26] Update Readme.md --- Readme.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 5f5b682..b5726fd 100644 --- a/Readme.md +++ b/Readme.md @@ -10,4 +10,9 @@ This sample shows how to create an angular 2 app that: ## Running it -Just install `node` and run `npm install` and then `npm start` :boom:. +Clone this repository as well as [the server](https://github.com/auth0/nodejs-jwt-authentication-sample) for this example. + +First, run the server app in the port `3001`. + +Then, run `npm install` on this project and run `npm startwatch` to start the app. Then just navigate to [http://localhost:3000](http://localhost:3000) :boom: + From 4d97d190610d089e288d221ce5a4e9779470bea0 Mon Sep 17 00:00:00 2001 From: Dmitriy Shekhovtsov Date: Mon, 19 Oct 2015 16:18:35 +0300 Subject: [PATCH 06/26] chore(dependencies): updated to latest and made immutable --- .gitignore | 1 + package.json | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 82756e3..d53c195 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ build/Release ehthumbs.db Icon? Thumbs.db +.idea # Node Files # node_modules diff --git a/package.json b/package.json index f3d0ccb..3caa896 100644 --- a/package.json +++ b/package.json @@ -21,32 +21,32 @@ }, "homepage": "https://github.com/auth0/angular2-authentication-sample", "dependencies": { - "angular2": "2.0.0-alpha.30", - "raw-loader": "^0.5.1", - "reflect-metadata": "^0.1.0", - "rtts_assert": "2.0.0-alpha.29", - "rx": "^2.5.3", - "zone.js": "^0.5.0", - "bootstrap": "~3.3.4", - "jwt-decode": "~1.1.0", - "whatwg-fetch": "~0.7.0", - "when": "~3.7.3" + "angular2": "2.0.0-alpha.44", + "raw-loader": "0.5.1", + "reflect-metadata": "0.1.2", + "rtts_assert": "2.0.0-alpha.37", + "rx": "4.0.6", + "zone.js": "0.5.8", + "bootstrap": "3.3.5", + "jwt-decode": "1.4.0", + "whatwg-fetch": "0.10.0", + "when": "3.7.3" }, "devDependencies": { - "css-loader": "^0.14.4", - "xtend": "^4.0.0", - "loader-utils": "^0.2.9", - "exports-loader": "^0.6.2", - "expose-loader": "^0.7.0", - "file-loader": "^0.8.1", - "html-webpack-plugin": "^1.4.0", - "imports-loader": "^0.6.3", - "json-loader": "^0.5.1", - "style-loader": "^0.12.2", - "typescript": "^1.5.0-beta", - "typescript-simple-loader": "^0.1.2", - "url-loader": "^0.5.5", - "webpack": "^1.9.6", - "webpack-dev-server": "^1.8.2" + "css-loader": "0.20.1", + "xtend": "4.0.0", + "loader-utils": "0.2.11", + "exports-loader": "0.6.2", + "expose-loader": "0.7.0", + "file-loader": "0.8.4", + "html-webpack-plugin": "1.6.2", + "imports-loader": "0.6.5", + "json-loader": "0.5.3", + "style-loader": "0.12.4", + "typescript": "1.6.2", + "typescript-simple-loader": "0.3.8", + "url-loader": "0.5.6", + "webpack": "1.12.2", + "webpack-dev-server": "1.12.1" } } From fc56f85f040f71b2e6466f23469c68363a84fd00 Mon Sep 17 00:00:00 2001 From: Dmitriy Shekhovtsov Date: Mon, 19 Oct 2015 17:51:46 +0300 Subject: [PATCH 07/26] chore(start): updated ng2 0.44 --- package.json | 8 +- src/app/LoggedInOutlet.ts | 28 +- src/app/app.ts | 9 +- src/home/home.ts | 56 +- src/index.ts | 16 +- src/login/login.ts | 14 +- src/signup/signup.ts | 15 +- tsconfig.json | 14 +- tsd.json | 21 - typings/_custom/custom.d.ts | 1 - typings/_custom/ng2.d.ts | 1004 ----- typings/angular2/angular2.d.ts | 4625 ------------------------ typings/es6-promise/es6-promise.d.ts | 73 - typings/rx/rx-lite.d.ts | 644 ---- typings/rx/rx.d.ts | 67 - typings/tsd.d.ts | 5 - typings/whatwg-fetch/whatwg-fetch.d.ts | 2 +- webpack.config.js | 11 +- 18 files changed, 79 insertions(+), 6534 deletions(-) delete mode 100644 tsd.json delete mode 100644 typings/_custom/ng2.d.ts delete mode 100644 typings/angular2/angular2.d.ts delete mode 100644 typings/es6-promise/es6-promise.d.ts delete mode 100644 typings/rx/rx-lite.d.ts delete mode 100644 typings/rx/rx.d.ts diff --git a/package.json b/package.json index 3caa896..3e6f3f0 100644 --- a/package.json +++ b/package.json @@ -34,19 +34,19 @@ }, "devDependencies": { "css-loader": "0.20.1", - "xtend": "4.0.0", - "loader-utils": "0.2.11", "exports-loader": "0.6.2", "expose-loader": "0.7.0", "file-loader": "0.8.4", "html-webpack-plugin": "1.6.2", "imports-loader": "0.6.5", "json-loader": "0.5.3", + "loader-utils": "0.2.11", "style-loader": "0.12.4", + "ts-loader": "0.5.6", "typescript": "1.6.2", - "typescript-simple-loader": "0.3.8", "url-loader": "0.5.6", "webpack": "1.12.2", - "webpack-dev-server": "1.12.1" + "webpack-dev-server": "1.12.1", + "xtend": "4.0.0" } } diff --git a/src/app/LoggedInOutlet.ts b/src/app/LoggedInOutlet.ts index 590a326..46cc165 100644 --- a/src/app/LoggedInOutlet.ts +++ b/src/app/LoggedInOutlet.ts @@ -1,28 +1,30 @@ import {Directive, Attribute, ElementRef, DynamicComponentLoader} from 'angular2/angular2'; -import {Router, RouterOutlet} from 'angular2/router'; -import {Injector} from 'angular2/di'; +import {Router, RouterOutlet, ComponentInstruction} from 'angular2/router'; import {Login} from '../login/login'; @Directive({ selector: 'router-outlet' }) export class LoggedInRouterOutlet extends RouterOutlet { - publicRoutes: any - constructor(public _elementRef: ElementRef, public _loader: DynamicComponentLoader, - public _parentRouter: Router, @Attribute('name') nameAttr: string) { - super(_elementRef, _loader, _parentRouter, nameAttr); + publicRoutes:any; + private parentRouter:Router; - this.publicRoutes = { - '/login': true, - '/signup': true - }; + constructor(_elementRef:ElementRef, _loader:DynamicComponentLoader, + _parentRouter:Router, @Attribute('name') nameAttr:string) { + super(_elementRef, _loader, _parentRouter, nameAttr); + this.parentRouter = _parentRouter; + this.publicRoutes = { + '/login': true, + '/signup': true + }; } - activate(instruction) { - var url = this._parentRouter.lastNavigationAttempt; + activate(instruction: ComponentInstruction) { + var url = this.parentRouter.lastNavigationAttempt; if (!this.publicRoutes[url] && !localStorage.getItem('jwt')) { - instruction.component = Login; + // todo: redirect to Login + //instruction.component = Login; } return super.activate(instruction); } diff --git a/src/app/app.ts b/src/app/app.ts index f28ea01..33ed910 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -1,7 +1,6 @@ -/// - import {View, Component} from 'angular2/angular2'; import {Location, RouteConfig, RouterLink, Router} from 'angular2/router'; + import {LoggedInRouterOutlet} from './LoggedInOutlet'; import {Home} from '../home/home'; import {Login} from '../login/login'; @@ -19,9 +18,9 @@ let template = require('./app.html'); }) @RouteConfig([ { path: '/', redirectTo: '/home' }, - { path: '/home', as: 'home', component: Home }, - { path: '/login', as: 'login', component: Login }, - { path: '/signup', as: 'signup', component: Signup } + { path: '/home', as: 'Home', component: Home }, + { path: '/login', as: 'Login', component: Login }, + { path: '/signup', as: 'Signup', component: Signup } ]) export class App { constructor(public router: Router) { diff --git a/src/home/home.ts b/src/home/home.ts index a10ffea..e790783 100644 --- a/src/home/home.ts +++ b/src/home/home.ts @@ -1,11 +1,9 @@ -/// +import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'; +import { Router } from 'angular2/router'; -import {Component, View} from 'angular2/angular2'; -import {coreDirectives} from 'angular2/directives'; import {status, text} from '../utils/fetch' -import { Router} from 'angular2/router'; -let styles = require('./home.css'); +let styles = require('./home.css'); let template = require('./home.html'); @@ -13,24 +11,24 @@ let template = require('./home.html'); selector: 'home' }) @View({ - styles: [ styles ], + directives: [CORE_DIRECTIVES], template: template, - directives: [ coreDirectives ] + styles: [styles] }) export class Home { - jwt: string; - decodedJwt: string; - response: string; - api: string; + jwt:string; + decodedJwt:string; + response:string; + api:string; - constructor(public router: Router) { + constructor(public router:Router) { this.jwt = localStorage.getItem('jwt'); this.decodedJwt = this.jwt && window.jwt_decode(this.jwt); } logout() { localStorage.removeItem('jwt'); - this.router.parent.navigate('/login'); + this.router.parent.navigate(['/login']); } callAnonymousApi() { @@ -40,25 +38,25 @@ export class Home { callSecuredApi() { this._callApi('Secured', 'http://localhost:3001/api/protected/random-quote'); } + _callApi(type, url) { this.response = null; this.api = type; window.fetch(url, { - method: 'GET', - 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; - }); + method: 'GET', + 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; + }); } - } diff --git a/src/index.ts b/src/index.ts index fc05dba..00eaa03 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,18 +1,14 @@ -/// - -import { bootstrap } from 'angular2/angular2'; -import { bind } from 'angular2/di'; -import { routerInjectables } from 'angular2/router'; -import { formInjectables } from 'angular2/forms'; -import { httpInjectables } from 'angular2/http'; +import { bootstrap, FORM_PROVIDERS } from 'angular2/angular2'; +import { ROUTER_PROVIDERS } from 'angular2/router'; +import { HTTP_PROVIDERS } from 'angular2/http'; import { App } from './app/app'; bootstrap( App, [ - formInjectables, - routerInjectables, - httpInjectables + FORM_PROVIDERS, + ROUTER_PROVIDERS, + HTTP_PROVIDERS ] ); diff --git a/src/login/login.ts b/src/login/login.ts index 9bfd200..5f170be 100644 --- a/src/login/login.ts +++ b/src/login/login.ts @@ -1,21 +1,17 @@ -/// - import {Component, View} from 'angular2/angular2'; -import {status, json} from '../utils/fetch' import { Router, RouterLink } from 'angular2/router'; - +import {status, json} from '../utils/fetch' let styles = require('./login.css'); let template = require('./login.html'); - @Component({ selector: 'login' }) @View({ - styles: [ styles ], + directives: [RouterLink], template: template, - directives: [RouterLink] + styles: [ styles ] }) export class Login { constructor(public router: Router) { @@ -37,7 +33,7 @@ export class Login { .then(json) .then((response) => { localStorage.setItem('jwt', response.id_token); - this.router.parent.navigate('/home'); + this.router.parent.navigate(['/home']); }) .catch((error) => { alert(error.message); @@ -47,6 +43,6 @@ export class Login { signup(event) { event.preventDefault(); - this.router.parent.navigate('/signup'); + this.router.parent.navigate(['/signup']); } } diff --git a/src/signup/signup.ts b/src/signup/signup.ts index a4f0f27..6fb66d4 100644 --- a/src/signup/signup.ts +++ b/src/signup/signup.ts @@ -1,7 +1,4 @@ -/// - -import {coreDirectives} from 'angular2/directives'; -import {Component, View} from 'angular2/angular2'; +import {CORE_DIRECTIVES, Component, View} from 'angular2/angular2'; import {status, json} from '../utils/fetch'; import { Router, RouterLink } from 'angular2/router'; @@ -12,9 +9,9 @@ let template = require('./signup.html'); selector: 'signup' }) @View({ - directives: [ RouterLink, coreDirectives ], - styles: [ styles ], - template: template + directives: [ RouterLink, CORE_DIRECTIVES ], + template: template, + styles: [ styles ] }) export class Signup { constructor(public router: Router) { @@ -36,7 +33,7 @@ export class Signup { .then(json) .then((response) => { localStorage.setItem('jwt', response.id_token); - this.router.navigate('/home'); + this.router.navigate(['/home']); }) .catch((error) => { alert(error.message); @@ -46,7 +43,7 @@ export class Signup { login(event) { event.preventDefault(); - this.router.parent.navigate('/login'); + this.router.parent.navigate(['/login']); } } diff --git a/tsconfig.json b/tsconfig.json index bbe0232..c9fa060 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,20 +3,20 @@ "compilerOptions": { "target": "es5", "module": "commonjs", - "declaration": false, + "declaration": true, "noImplicitAny": false, - "removeComments": true, + "removeComments": false, "noLib": false, "emitDecoratorMetadata": true, + "experimentalDecorators": true, "sourceMap": true, "listFiles": true, "outDir": "dist" }, + "exclude": [ + "node_modules" + ], "files": [ - "node_modules/typescript/bin/dom.d.ts", - "src/custom_typings/ng2.d.ts", - "typings/tsd.d.ts", - "src/components/app.ts", - "src/bootstrap.ts" + "src/index.ts" ] } diff --git a/tsd.json b/tsd.json deleted file mode 100644 index f9029ed..0000000 --- a/tsd.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": "v4", - "repo": "borisyankov/DefinitelyTyped", - "ref": "master", - "path": "typings", - "bundle": "typings/tsd.d.ts", - "installed": { - "angular2/angular2.d.ts": { - "commit": "2a5858c16563634453533009242b8e0b18521370" - }, - "rx/rx.d.ts": { - "commit": "8c7444882a2bc2ab87387f8f736a7d97e89b9c90" - }, - "rx/rx-lite.d.ts": { - "commit": "8c7444882a2bc2ab87387f8f736a7d97e89b9c90" - }, - "es6-promise/es6-promise.d.ts": { - "commit": "8c7444882a2bc2ab87387f8f736a7d97e89b9c90" - } - } -} diff --git a/typings/_custom/custom.d.ts b/typings/_custom/custom.d.ts index a1ad680..42be85c 100644 --- a/typings/_custom/custom.d.ts +++ b/typings/_custom/custom.d.ts @@ -1,4 +1,3 @@ /// -/// /// /// 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 deleted file mode 100644 index a4af962..0000000 --- a/typings/angular2/angular2.d.ts +++ /dev/null @@ -1,4625 +0,0 @@ -// Type definitions for Angular v2.0.0-alpha.26 -// Project: http://angular.io/ -// Definitions by: angular team -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -// *********************************************************** -// This file is generated by the Angular build process. -// Please do not create manual edits or send pull requests -// modifying this file. -// *********************************************************** - -// Angular depends transitively on these libraries. -// If you don't have them installed you can run -// $ tsd query es6-promise rx rx-lite --action install --save -/// -/// - -interface List extends Array {} -interface Map {} -interface StringMap {} -interface Type {} - -declare module "angular2/angular2" { - type SetterFn = typeof Function; - type int = number; - - // See https://github.com/Microsoft/TypeScript/issues/1168 - class BaseException /* extends Error */ { - message: any; - stack: any; - toString(): string; - } -} - - -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 `