├── .gitignore ├── LICENSE ├── README.md ├── app ├── app.ts ├── common │ ├── auth.service.ts │ ├── user.service.ts │ ├── webrtc.config.ts │ └── webrtc.service.ts ├── pages │ ├── chat │ │ ├── chat.html │ │ └── chat.ts │ ├── home │ │ ├── home.html │ │ ├── home.scss │ │ └── home.ts │ ├── login │ │ ├── login.html │ │ └── login.ts │ ├── media │ │ ├── media.html │ │ └── media.ts │ ├── tabs │ │ ├── tabs.html │ │ └── tabs.ts │ └── users │ │ ├── users.html │ │ └── users.ts └── theme │ ├── app.core.scss │ ├── app.ios.scss │ ├── app.md.scss │ ├── app.variables.scss │ └── app.wp.scss ├── config.xml ├── gulpfile.js ├── hooks ├── README.md └── after_prepare │ └── 010_add_platform_class.js ├── ionic.config.json ├── package.json ├── resources ├── android │ ├── icon │ │ ├── drawable-hdpi-icon.png │ │ ├── drawable-ldpi-icon.png │ │ ├── drawable-mdpi-icon.png │ │ ├── drawable-xhdpi-icon.png │ │ ├── drawable-xxhdpi-icon.png │ │ └── drawable-xxxhdpi-icon.png │ └── splash │ │ ├── drawable-land-hdpi-screen.png │ │ ├── drawable-land-ldpi-screen.png │ │ ├── drawable-land-mdpi-screen.png │ │ ├── drawable-land-xhdpi-screen.png │ │ ├── drawable-land-xxhdpi-screen.png │ │ ├── drawable-land-xxxhdpi-screen.png │ │ ├── drawable-port-hdpi-screen.png │ │ ├── drawable-port-ldpi-screen.png │ │ ├── drawable-port-mdpi-screen.png │ │ ├── drawable-port-xhdpi-screen.png │ │ ├── drawable-port-xxhdpi-screen.png │ │ └── drawable-port-xxxhdpi-screen.png ├── icon.png ├── ios │ ├── icon │ │ ├── icon-40.png │ │ ├── icon-40@2x.png │ │ ├── icon-50.png │ │ ├── icon-50@2x.png │ │ ├── icon-60.png │ │ ├── icon-60@2x.png │ │ ├── icon-60@3x.png │ │ ├── icon-72.png │ │ ├── icon-72@2x.png │ │ ├── icon-76.png │ │ ├── icon-76@2x.png │ │ ├── icon-small.png │ │ ├── icon-small@2x.png │ │ ├── icon-small@3x.png │ │ ├── icon.png │ │ └── icon@2x.png │ └── splash │ │ ├── Default-568h@2x~iphone.png │ │ ├── Default-667h.png │ │ ├── Default-736h.png │ │ ├── Default-Landscape-736h.png │ │ ├── Default-Landscape@2x~ipad.png │ │ ├── Default-Landscape~ipad.png │ │ ├── Default-Portrait@2x~ipad.png │ │ ├── Default-Portrait~ipad.png │ │ ├── Default@2x~iphone.png │ │ └── Default~iphone.png └── splash.png ├── tsconfig.json ├── typings.json ├── typings ├── browser.d.ts ├── browser │ └── ambient │ │ ├── es6-shim │ │ └── es6-shim.d.ts │ │ ├── firebase │ │ └── index.d.ts │ │ ├── peerjs │ │ └── index.d.ts │ │ └── webrtc │ │ ├── mediastream │ │ └── index.d.ts │ │ └── rtcpeerconnection │ │ └── index.d.ts ├── main.d.ts └── main │ └── ambient │ ├── es6-shim │ └── es6-shim.d.ts │ ├── firebase │ └── index.d.ts │ ├── peerjs │ └── index.d.ts │ └── webrtc │ ├── mediastream │ └── index.d.ts │ └── rtcpeerconnection │ └── index.d.ts ├── webpack.config.js └── www └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | www/build/ 3 | platforms/ 4 | plugins/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Sergey Akopkokhyants 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mobile Text, Audio and Video chat based on WebRTC, Firebase and Ionic 2 2 | ============================== 3 | 4 | There is a simple mobile, audio and video chat application based on: 5 | - WebRTC 6 | - [Angular Firebase 2](https://github.com/angular/angularfire2) 7 | - [Angular 2](https://angular.io) 8 | 9 | to demonstrate how to combine them together inside the [Ionic 2](http://ionic.io/2) project. 10 | 11 | **Note:** This project is not under development!!! 12 | 13 | ### Prerequisite 14 | 15 | - Install latest [Ionic 2 CLI](http://ionicframework.com/docs/v2/getting-started/installation) 16 | 17 | ### Start 18 | 19 | Run following shell script to install NPM modules 20 | ```bash 21 | npm i 22 | ``` 23 | 24 | Add Android or IOS platform to your project 25 | ```bash 26 | ionic platform add ios android 27 | ``` 28 | 29 | Build project for specified platforms 30 | ```bash 31 | ionic build 32 | ``` 33 | 34 | Explore project in your local web browser 35 | ```bash 36 | ionic serve 37 | ``` 38 | -------------------------------------------------------------------------------- /app/app.ts: -------------------------------------------------------------------------------- 1 | import {App, Platform} from 'ionic-angular'; 2 | import {StatusBar} from 'ionic-native'; 3 | 4 | import {HomePage} from './pages/home/home'; 5 | import {TabsPage} from './pages/tabs/tabs'; 6 | 7 | import {FIREBASE_PROVIDERS, defaultFirebase, firebaseAuthConfig, AuthProviders, AuthMethods, FirebaseListObservable} from 'angularfire2'; 8 | 9 | import {UserService} from './common/user.service'; 10 | import {AuthService, User} from './common/auth.service'; 11 | import {WebRTCConfig} from './common/webrtc.config'; 12 | import {WebRTCService} from './common/webrtc.service'; 13 | 14 | @App({ 15 | template: '', 16 | config: {}, // http://ionicframework.com/docs/v2/api/config/Config/ 17 | providers: [ 18 | FIREBASE_PROVIDERS, 19 | defaultFirebase('https://ng2-webrtc.firebaseio.com/'), 20 | firebaseAuthConfig({ 21 | provider: AuthProviders.Google, 22 | method: AuthMethods.Popup, 23 | remember: 'default', 24 | scope: ['email'] 25 | }), 26 | WebRTCConfig, UserService, AuthService, WebRTCService], 27 | }) 28 | export class MyApp { 29 | // We show the fake page here and will change it after success authorization 30 | rootPage: any = HomePage; 31 | 32 | constructor(platform: Platform, webRTC: WebRTCService, authService:AuthService, userService:UserService) { 33 | platform.ready().then(() => { 34 | // Okay, so the platform is ready and our plugins are available. 35 | // Here you can do any higher level native things you might need. 36 | StatusBar.styleDefault(); 37 | // Let's sign in first 38 | authService.login().then((user: User) => { 39 | // Chec is user exists 40 | userService.exists(user.id).then((value: boolean) => { 41 | if (value) { 42 | this._afterLogin(webRTC, user.id); 43 | } else { 44 | // Add user info 45 | userService.create(user.id, user.displayName).then(() => { 46 | this._afterLogin(webRTC, user.id); 47 | }, (error) => { 48 | console.log('Error', error); 49 | }); 50 | } 51 | }); 52 | }); 53 | }); 54 | } 55 | 56 | private _afterLogin(webRTC: WebRTCService, userId: string) { 57 | // Create Peer 58 | webRTC.createPeer(userId); 59 | // Now change the rootPage to tabs 60 | this.rootPage = TabsPage; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/common/auth.service.ts: -------------------------------------------------------------------------------- 1 | import {Inject, Injectable} from 'angular2/core'; 2 | import {isPresent} from 'angular2/src/facade/lang'; 3 | 4 | import {FirebaseAuth, AuthProviders, FirebaseAuthState} from 'angularfire2'; 5 | 6 | export interface User { 7 | displayName?: string; 8 | email?: string; 9 | id?: string; 10 | profileImageUrl?: string; 11 | } 12 | 13 | export class OtherUser { 14 | constructor(public name: string = '', public id: string = '') {} 15 | 16 | notEmpty(): boolean { 17 | return isPresent(this.name) && isPresent(this.id) && this.name.length > 0 && this.id.length > 0; 18 | } 19 | } 20 | 21 | @Injectable() 22 | export class AuthService { 23 | 24 | private _user: User; 25 | 26 | public get user(): User { 27 | return this._user; 28 | } 29 | 30 | otherUser: OtherUser; 31 | 32 | constructor(@Inject(FirebaseAuth) private auth: FirebaseAuth) { } 33 | 34 | login(): Promise { 35 | return this.auth.login({ 36 | provider: AuthProviders.Google 37 | }).then((value: FirebaseAuthState) => { 38 | console.log(value); 39 | this._user = value.google; 40 | return this._user; 41 | }); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /app/common/user.service.ts: -------------------------------------------------------------------------------- 1 | import {Inject, Injectable} from 'angular2/core'; 2 | 3 | import {AngularFire, FirebaseRef, FirebaseListObservable, FirebaseObjectObservable} from 'angularfire2'; 4 | 5 | @Injectable() 6 | export class UserService { 7 | 8 | static USERS: string = 'users'; 9 | 10 | constructor(private angularFire: AngularFire, @Inject(FirebaseRef) private ref: Firebase) {} 11 | 12 | asList(): FirebaseListObservable { 13 | return this.angularFire.list(UserService.USERS); 14 | } 15 | 16 | asObject(userId: string): FirebaseObjectObservable { 17 | return this.angularFire.object(UserService.USERS + '/' + userId); 18 | } 19 | 20 | exists(userId: string): Promise { 21 | let usersRef: Firebase = this.ref.child(UserService.USERS); 22 | return new Promise((resolve, fault) => { 23 | usersRef.child(userId).once('value', (snapshot: FirebaseDataSnapshot) => { 24 | let exists:boolean = (snapshot.val() !== null); 25 | resolve(exists); 26 | }); 27 | }); 28 | } 29 | 30 | create(userId: string, userName: string): Promise { 31 | // Get reference on 'Users' 32 | let userRef: Firebase = this.ref.child(UserService.USERS + '/' + userId); 33 | // Set username 34 | return userRef.set(userName); 35 | } 36 | 37 | // create(user: any): Promise { 38 | // // Get reference on 'Users' 39 | // let usersRef: Firebase = this.ref.child(UserService.USERS); 40 | // // Create new child via 'push' method to get an id 41 | // let userRef: Firebase = usersRef.push(); 42 | // // Now set user info and save it 43 | // return userRef.set(user); 44 | // } 45 | 46 | remove(userId: string): Promise { 47 | // Get a reference on User 48 | let userRef: Firebase = this.ref.child(UserService.USERS + '/' + userId); 49 | // Remove it in Firebase 50 | return userRef.remove(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/common/webrtc.config.ts: -------------------------------------------------------------------------------- 1 | import {Injectable} from 'angular2/core'; 2 | 3 | @Injectable() 4 | export class WebRTCConfig { 5 | 6 | peerServerPort: number = 9000; 7 | 8 | key:string = 'whbzng0p4kq8semi'; 9 | 10 | stun: string = 'stun.l.google.com:19302'; 11 | // turn: string = 'homeo@turn.bistri.com:80'; 12 | // turnCredentials: string = 'homeo'; 13 | 14 | stunServer:RTCIceServer = { 15 | urls: 'stun:' + this.stun 16 | }; 17 | 18 | // turnServer: RTCIceServer = { 19 | // urls: 'turn:' + this.turn, 20 | // credential: this.turnCredentials 21 | // }; 22 | 23 | getPeerJSOption(): PeerJs.PeerJSOption { 24 | return { 25 | // Set API key for cloud server (you don't need this if you're running your own. 26 | key: this.key, 27 | 28 | // Set highest debug level (log everything!). 29 | debug: 3, 30 | // Set it to false because of: 31 | // > PeerJS: ERROR Error: The cloud server currently does not support HTTPS. 32 | // > Please run your own PeerServer to use HTTPS. 33 | secure: false, 34 | 35 | config: { 36 | iceServers: [ 37 | this.stunServer/*, 38 | this.turnServer*/ 39 | ] 40 | } 41 | }; 42 | } 43 | 44 | /**********************/ 45 | 46 | audio: boolean = true; 47 | video: boolean = false; 48 | 49 | getMediaStreamConstraints(): MediaStreamConstraints { 50 | return { 51 | audio: this.audio, 52 | video: this.video 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/common/webrtc.service.ts: -------------------------------------------------------------------------------- 1 | import {Injectable, EventEmitter} from 'angular2/core'; 2 | 3 | import {WebRTCConfig} from './webrtc.config'; 4 | 5 | 6 | @Injectable() 7 | export class WebRTCService { 8 | 9 | private _peer: PeerJs.Peer; 10 | private _localStream: any; 11 | private _existingCall: any; 12 | 13 | myEl: HTMLMediaElement; 14 | otherEl: HTMLMediaElement; 15 | onCalling: Function; 16 | 17 | constructor(private config: WebRTCConfig) { 18 | navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; 19 | } 20 | 21 | /** 22 | * Create the Peer with User Id and PeerJSOption 23 | */ 24 | createPeer(userId: string) { 25 | // Create the Peer object where we create and receive connections. 26 | this._peer = new Peer(userId, this.config.getPeerJSOption()); 27 | } 28 | 29 | init(myEl: HTMLMediaElement, otherEl: HTMLMediaElement, onCalling: Function) { 30 | this.myEl = myEl; 31 | this.otherEl = otherEl; 32 | this.onCalling = onCalling; 33 | 34 | // Receiving a call 35 | this._peer.on('call', (call) => { 36 | // Answer the call automatically (instead of prompting user) for demo purposes 37 | call.answer(this._localStream); 38 | this._step3(call); 39 | }); 40 | this._peer.on('error', (err) => { 41 | console.log(err.message); 42 | // Return to step 2 if error occurs 43 | if (this.onCalling) { 44 | this.onCalling(); 45 | } 46 | // this._step2(); 47 | }); 48 | 49 | this._step1(); 50 | } 51 | 52 | call(otherUserId: string) { 53 | // Initiate a call! 54 | var call = this._peer.call(otherUserId, this._localStream); 55 | 56 | this._step3(call); 57 | } 58 | 59 | endCall() { 60 | this._existingCall.close(); 61 | // this._step2(); 62 | if (this.onCalling) { 63 | this.onCalling(); 64 | } 65 | } 66 | 67 | private _step1() { 68 | // Get audio/video stream 69 | navigator.getUserMedia({ audio: true, video: true }, (stream) => { 70 | // Set your video displays 71 | this.myEl.src = URL.createObjectURL(stream); 72 | 73 | this._localStream = stream; 74 | // this._step2(); 75 | if (this.onCalling) { 76 | this.onCalling(); 77 | } 78 | }, (error) => { 79 | console.log(error); 80 | }); 81 | } 82 | 83 | // private _step2() { 84 | // console.log('Hide Step1, Step3. Show Step2'); 85 | // // $('#_step1, #_step3').hide(); 86 | // // $('#_step2').show(); 87 | // } 88 | 89 | private _step3(call) { 90 | // Hang up on an existing call if present 91 | if (this._existingCall) { 92 | this._existingCall.close(); 93 | } 94 | 95 | // Wait for stream on the call, then set peer video display 96 | call.on('stream', (stream) => { 97 | this.otherEl.src = URL.createObjectURL(stream); 98 | }); 99 | 100 | // UI stuff 101 | this._existingCall = call; 102 | // $('#their-id').text(call.peer); 103 | call.on('close', () => { 104 | // this._step2(); 105 | if (this.onCalling) { 106 | this.onCalling(); 107 | } 108 | }); 109 | // $('#_step1, #_step2').hide(); 110 | // $('#_step3').show(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /app/pages/chat/chat.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | Chat 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {{getOtherUserName()}} 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/pages/chat/chat.ts: -------------------------------------------------------------------------------- 1 | import {Page, Modal, NavController} from 'ionic-angular'; 2 | import {ElementRef, OnInit} from 'angular2/core'; 3 | 4 | import {UsersPage} from '../users/users'; 5 | 6 | import {UserService} from '../../common/user.service'; 7 | import {User, OtherUser, AuthService} from '../../common/auth.service'; 8 | import {WebRTCService} from '../../common/webrtc.service'; 9 | 10 | @Page({ 11 | templateUrl: 'build/pages/chat/chat.html' 12 | }) 13 | export class ChatPage implements OnInit { 14 | myVideo: HTMLMediaElement; 15 | otherVideo: HTMLMediaElement; 16 | 17 | me: User = {}; 18 | otherUser: OtherUser = new OtherUser(); 19 | 20 | constructor(private userService: UserService, private authService: AuthService, private webRTCService: WebRTCService, 21 | private nav: NavController, private elRef: ElementRef) { 22 | 23 | this.me = authService.user; 24 | } 25 | 26 | ngOnInit(): any { 27 | // Find video elements 28 | this.myVideo = this.elRef.nativeElement.querySelector('#my-video'); 29 | this.otherVideo = this.elRef.nativeElement.querySelector('#other-video'); 30 | // 31 | this.webRTCService.init(this.myVideo, this.otherVideo, () => { 32 | console.log('I\'m calling'); 33 | }); 34 | } 35 | 36 | getOtherUserName(): string { 37 | if (this.otherUser.notEmpty()) { 38 | return this.otherUser.name; 39 | } else { 40 | return 'Choose the User to call...'; 41 | } 42 | } 43 | 44 | chooseOtherUser() { 45 | console.log('Choose other user'); 46 | let modal = Modal.create(UsersPage); 47 | modal.onDismiss((value: any) => { 48 | console.log('Selected user', value); 49 | this.otherUser = value; 50 | }); 51 | this.nav.present(modal); 52 | } 53 | 54 | startCall() { 55 | console.log('Call to ', this.otherUser.id); 56 | this.webRTCService.call(this.otherUser.id); 57 | } 58 | 59 | stopCall() { 60 | console.log('Stop calling to other user', this.otherUser.name); 61 | this.webRTCService.endCall(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Authentication 4 | 5 | 6 | 7 | 8 |
9 |
10 | Awaiting authentication 11 | 12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /app/pages/home/home.scss: -------------------------------------------------------------------------------- 1 | .home { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /app/pages/home/home.ts: -------------------------------------------------------------------------------- 1 | import {Page} from 'ionic-angular'; 2 | 3 | @Page({ 4 | templateUrl: 'build/pages/home/home.html' 5 | }) 6 | export class HomePage { } 7 | -------------------------------------------------------------------------------- /app/pages/login/login.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | Authentication 6 | 7 | 8 | 9 |
10 | 14 |
15 | 16 | 19 |
-------------------------------------------------------------------------------- /app/pages/login/login.ts: -------------------------------------------------------------------------------- 1 | import {Page, ViewController} from 'ionic-angular'; 2 | import {Inject} from 'angular2/core'; 3 | 4 | import {AngularFire, FirebaseListObservable, FirebaseObjectObservable, FirebaseRef} from 'angularfire2'; 5 | import {Observable} from 'rxjs/Observable'; 6 | 7 | @Page({ 8 | templateUrl: 'build/pages/login/login.html' 9 | }) 10 | export class LoginPage { 11 | 12 | username: string = ''; 13 | ref: Firebase; 14 | users: FirebaseListObservable; 15 | // 16 | constructor(private af: AngularFire, private viewCtrl: ViewController, @Inject(FirebaseRef) ref:Firebase){ 17 | this.users = this.af.list('/users'); 18 | this.ref = ref; 19 | } 20 | 21 | login(): void { 22 | console.log(`Adding user to users in chat room: ${this.username} `); 23 | 24 | let users: Firebase = this.ref.child('/users'); 25 | // We need to check is user exists in DB 26 | users.child(this.username).on('value', (snaphot:FirebaseDataSnapshot) => { 27 | let name = snaphot.val(); 28 | console.log(name); 29 | if (name) { 30 | // User exists 31 | this.viewCtrl.dismiss(this.username); 32 | } else { 33 | // User must be created 34 | // push(value?: any, onComplete?: (error: any) => void): FirebaseWithPromise; 35 | users.push({ 36 | name: this.username 37 | }).then((value: any) => { 38 | this.viewCtrl.dismiss(this.username); 39 | }, (error: any) => { 40 | console.log('Error', error); 41 | }); 42 | } 43 | }, (error: any) => { 44 | console.log('Error', error); 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/pages/media/media.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | Peer connecton 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
-------------------------------------------------------------------------------- /app/pages/media/media.ts: -------------------------------------------------------------------------------- 1 | import {Page, Platform} from 'ionic-angular'; 2 | 3 | import {AngularFire, FirebaseListObservable} from 'angularfire2'; 4 | import {Observable} from 'rxjs/Observable'; 5 | 6 | import {WebRTCService} from '../../common/webrtc.service'; 7 | 8 | @Page({ 9 | templateUrl: 'build/pages/home/home.html' 10 | }) 11 | export class MediaPage { 12 | 13 | users: FirebaseListObservable; 14 | 15 | constructor(private platform: Platform, private af: AngularFire, private rtc:WebRTCService){ 16 | this.users = this.af.list('/users'); 17 | } 18 | 19 | join(task : HTMLInputElement): void { 20 | 21 | console.log(`Adding user to users in chat room: ${task.value} `); 22 | this.users.add(task.value); 23 | } 24 | 25 | leave(id){ 26 | this.users.remove(id); 27 | } 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/pages/tabs/tabs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/pages/tabs/tabs.ts: -------------------------------------------------------------------------------- 1 | import {Page} from 'ionic-angular'; 2 | import {ChatPage} from '../chat/chat'; 3 | 4 | 5 | @Page({ 6 | templateUrl: 'build/pages/tabs/tabs.html' 7 | }) 8 | export class TabsPage { 9 | // this tells the tabs component which Pages 10 | // should be each tab's root Page 11 | chatPage: any = ChatPage; 12 | } 13 | -------------------------------------------------------------------------------- /app/pages/users/users.html: -------------------------------------------------------------------------------- 1 | 2 | Online Users 3 | 4 | 5 | 6 | 7 | {{user.$value}} 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/pages/users/users.ts: -------------------------------------------------------------------------------- 1 | import {Page, ViewController, NavController} from 'ionic-angular'; 2 | import {COMMON_DIRECTIVES} from 'angular2/common'; 3 | 4 | import {AngularFire, FirebaseRef, FirebaseListObservable, FirebaseObjectObservable} from 'angularfire2'; 5 | 6 | import {UserService} from '../../common/user.service'; 7 | import {User, OtherUser, AuthService} from '../../common/auth.service'; 8 | 9 | @Page({ 10 | templateUrl: 'build/pages/users/users.html', 11 | directives: [COMMON_DIRECTIVES] 12 | }) 13 | export class UsersPage { 14 | 15 | me: User; 16 | users: FirebaseListObservable; 17 | 18 | constructor(private userService: UserService, private authService: AuthService, 19 | private viewCtrl: ViewController) { 20 | this.me = authService.user; 21 | this.users = userService.asList(); 22 | } 23 | 24 | chooseUser(user: any) { 25 | console.log('Choose user', user); 26 | this.viewCtrl.dismiss(new OtherUser(user.$value, user.$key)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/theme/app.core.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Shared Imports 5 | // -------------------------------------------------- 6 | // These are the imports which make up the design of this app. 7 | // By default each design mode includes these shared imports. 8 | // App Shared Sass variables belong in app.variables.scss. 9 | 10 | @import '../pages/home/home'; 11 | -------------------------------------------------------------------------------- /app/theme/app.ios.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Shared Variables 5 | // -------------------------------------------------- 6 | // Shared Sass variables go in the app.variables.scss file 7 | @import 'app.variables'; 8 | 9 | 10 | // App iOS Variables 11 | // -------------------------------------------------- 12 | // iOS only Sass variables can go here 13 | 14 | 15 | // Ionic iOS Sass 16 | // -------------------------------------------------- 17 | // Custom App variables must be declared before importing Ionic. 18 | // Ionic will use its default values when a custom variable isn't provided. 19 | @import 'ionic.ios'; 20 | 21 | 22 | // App Shared Sass 23 | // -------------------------------------------------- 24 | // All Sass files that make up this app goes into the app.core.scss file. 25 | // For simpler CSS overrides, custom app CSS must come after Ionic's CSS. 26 | @import 'app.core'; 27 | 28 | 29 | // App iOS Only Sass 30 | // -------------------------------------------------- 31 | // CSS that should only apply to the iOS app 32 | -------------------------------------------------------------------------------- /app/theme/app.md.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Shared Variables 5 | // -------------------------------------------------- 6 | // Shared Sass variables go in the app.variables.scss file 7 | @import 'app.variables'; 8 | 9 | 10 | // App Material Design Variables 11 | // -------------------------------------------------- 12 | // Material Design only Sass variables can go here 13 | 14 | 15 | // Ionic Material Design Sass 16 | // -------------------------------------------------- 17 | // Custom App variables must be declared before importing Ionic. 18 | // Ionic will use its default values when a custom variable isn't provided. 19 | @import 'ionic.md'; 20 | 21 | 22 | // App Shared Sass 23 | // -------------------------------------------------- 24 | // All Sass files that make up this app goes into the app.core.scss file. 25 | // For simpler CSS overrides, custom app CSS must come after Ionic's CSS. 26 | @import 'app.core'; 27 | 28 | 29 | // App Material Design Only Sass 30 | // -------------------------------------------------- 31 | // CSS that should only apply to the Material Design app 32 | -------------------------------------------------------------------------------- /app/theme/app.variables.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Shared Variables 5 | // -------------------------------------------------- 6 | // To customize the look and feel of this app, you can override 7 | // the Sass variables found in Ionic's source scss files. Setting 8 | // variables before Ionic's Sass will use these variables rather than 9 | // Ionic's default Sass variable values. App Shared Sass imports belong 10 | // in the app.core.scss file and not this file. Sass variables specific 11 | // to the mode belong in either the app.ios.scss or app.md.scss files. 12 | 13 | 14 | // App Shared Color Variables 15 | // -------------------------------------------------- 16 | // It's highly recommended to change the default colors 17 | // to match your app's branding. Ionic uses a Sass map of 18 | // colors so you can add, rename and remove colors as needed. 19 | // The "primary" color is the only required color in the map. 20 | // Both iOS and MD colors can be further customized if colors 21 | // are different per mode. 22 | 23 | $colors: ( 24 | primary: #387ef5, 25 | secondary: #32db64, 26 | danger: #f53d3d, 27 | light: #f4f4f4, 28 | dark: #222, 29 | favorite: #69BB7B 30 | ); 31 | -------------------------------------------------------------------------------- /app/theme/app.wp.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/v2/theming/ 2 | 3 | 4 | // App Shared Variables 5 | // -------------------------------------------------- 6 | // Shared Sass variables go in the app.variables.scss file 7 | @import 'app.variables'; 8 | 9 | 10 | // App Windows Variables 11 | // -------------------------------------------------- 12 | // Windows only Sass variables can go here 13 | 14 | 15 | // Ionic Windows Sass 16 | // -------------------------------------------------- 17 | // Custom App variables must be declared before importing Ionic. 18 | // Ionic will use its default values when a custom variable isn't provided. 19 | @import "ionic.wp"; 20 | 21 | 22 | // App Shared Sass 23 | // -------------------------------------------------- 24 | // All Sass files that make up this app goes into the app.core.scss file. 25 | // For simpler CSS overrides, custom app CSS must come after Ionic's CSS. 26 | @import 'app.core'; 27 | 28 | 29 | // App Windows Only Sass 30 | // -------------------------------------------------- 31 | // CSS that should only apply to the Windows app 32 | -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ionic2-firebase-sample 4 | An Ionic Framework and Cordova project. 5 | Ionic Framework Team 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | gulpWatch = require('gulp-watch'), 3 | del = require('del'), 4 | argv = process.argv; 5 | 6 | /** 7 | * Ionic Gulp tasks, for more information on each see 8 | * https://github.com/driftyco/ionic-gulp-tasks 9 | */ 10 | var buildWebpack = require('ionic-gulp-webpack-build'); 11 | var buildSass = require('ionic-gulp-sass-build'); 12 | var copyHTML = require('ionic-gulp-html-copy'); 13 | var copyFonts = require('ionic-gulp-fonts-copy'); 14 | 15 | gulp.task('watch', ['sass', 'html', 'fonts'], function(){ 16 | gulpWatch('app/**/*.scss', function(){ gulp.start('sass'); }); 17 | gulpWatch('app/**/*.html', function(){ gulp.start('html'); }); 18 | return buildWebpack({ watch: true }); 19 | }); 20 | gulp.task('build', ['sass', 'html', 'fonts'], buildWebpack); 21 | gulp.task('sass', buildSass); 22 | gulp.task('html', copyHTML); 23 | gulp.task('fonts', copyFonts); 24 | gulp.task('clean', function(done){ 25 | del('www/build', done); 26 | }); 27 | 28 | /** 29 | * Ionic hooks 30 | * Add ':before' or ':after' to any Ionic project command name to run the specified 31 | * tasks before or after the command. 32 | */ 33 | gulp.task('serve:before', ['watch']); 34 | gulp.task('emulate:before', ['build']); 35 | gulp.task('deploy:before', ['build']); 36 | 37 | // we want to 'watch' when livereloading 38 | var shouldWatch = argv.indexOf('-l') > -1 || argv.indexOf('--livereload') > -1; 39 | gulp.task('run:before', [shouldWatch ? 'watch' : 'build']); -------------------------------------------------------------------------------- /hooks/README.md: -------------------------------------------------------------------------------- 1 | 21 | # Cordova Hooks 22 | 23 | Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. Hook scripts could be defined by adding them to the special predefined folder (`/hooks`) or via configuration files (`config.xml` and `plugin.xml`) and run serially in the following order: 24 | * Application hooks from `/hooks`; 25 | * Application hooks from `config.xml`; 26 | * Plugin hooks from `plugins/.../plugin.xml`. 27 | 28 | __Remember__: Make your scripts executable. 29 | 30 | __Note__: `.cordova/hooks` directory is also supported for backward compatibility, but we don't recommend using it as it is deprecated. 31 | 32 | ## Supported hook types 33 | The following hook types are supported: 34 | 35 | after_build/ 36 | after_compile/ 37 | after_docs/ 38 | after_emulate/ 39 | after_platform_add/ 40 | after_platform_rm/ 41 | after_platform_ls/ 42 | after_plugin_add/ 43 | after_plugin_ls/ 44 | after_plugin_rm/ 45 | after_plugin_search/ 46 | after_plugin_install/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being installed 47 | after_prepare/ 48 | after_run/ 49 | after_serve/ 50 | before_build/ 51 | before_compile/ 52 | before_docs/ 53 | before_emulate/ 54 | before_platform_add/ 55 | before_platform_rm/ 56 | before_platform_ls/ 57 | before_plugin_add/ 58 | before_plugin_ls/ 59 | before_plugin_rm/ 60 | before_plugin_search/ 61 | before_plugin_install/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being installed 62 | before_plugin_uninstall/ <-- Plugin hooks defined in plugin.xml are executed exclusively for a plugin being uninstalled 63 | before_prepare/ 64 | before_run/ 65 | before_serve/ 66 | pre_package/ <-- Windows 8 and Windows Phone only. 67 | 68 | ## Ways to define hooks 69 | ### Via '/hooks' directory 70 | To execute custom action when corresponding hook type is fired, use hook type as a name for a subfolder inside 'hooks' directory and place you script file here, for example: 71 | 72 | # script file will be automatically executed after each build 73 | hooks/after_build/after_build_custom_action.js 74 | 75 | 76 | ### Config.xml 77 | 78 | Hooks can be defined in project's `config.xml` using `` elements, for example: 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | ... 89 | 90 | 91 | 92 | 93 | 94 | 95 | ... 96 | 97 | 98 | ### Plugin hooks (plugin.xml) 99 | 100 | As a plugin developer you can define hook scripts using `` elements in a `plugin.xml` like that: 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | ... 109 | 110 | 111 | `before_plugin_install`, `after_plugin_install`, `before_plugin_uninstall` plugin hooks will be fired exclusively for the plugin being installed/uninstalled. 112 | 113 | ## Script Interface 114 | 115 | ### Javascript 116 | 117 | If you are writing hooks in Javascript you should use the following module definition: 118 | ```javascript 119 | module.exports = function(context) { 120 | ... 121 | } 122 | ``` 123 | 124 | You can make your scipts async using Q: 125 | ```javascript 126 | module.exports = function(context) { 127 | var Q = context.requireCordovaModule('q'); 128 | var deferral = new Q.defer(); 129 | 130 | setTimeout(function(){ 131 | console.log('hook.js>> end'); 132 | deferral.resolve(); 133 | }, 1000); 134 | 135 | return deferral.promise; 136 | } 137 | ``` 138 | 139 | `context` object contains hook type, executed script full path, hook options, command-line arguments passed to Cordova and top-level "cordova" object: 140 | ```json 141 | { 142 | "hook": "before_plugin_install", 143 | "scriptLocation": "c:\\script\\full\\path\\appBeforePluginInstall.js", 144 | "cmdLine": "The\\exact\\command\\cordova\\run\\with arguments", 145 | "opts": { 146 | "projectRoot":"C:\\path\\to\\the\\project", 147 | "cordova": { 148 | "platforms": ["wp8"], 149 | "plugins": ["com.plugin.withhooks"], 150 | "version": "0.21.7-dev" 151 | }, 152 | "plugin": { 153 | "id": "com.plugin.withhooks", 154 | "pluginInfo": { 155 | ... 156 | }, 157 | "platform": "wp8", 158 | "dir": "C:\\path\\to\\the\\project\\plugins\\com.plugin.withhooks" 159 | } 160 | }, 161 | "cordova": {...} 162 | } 163 | 164 | ``` 165 | `context.opts.plugin` object will only be passed to plugin hooks scripts. 166 | 167 | You can also require additional Cordova modules in your script using `context.requireCordovaModule` in the following way: 168 | ```javascript 169 | var Q = context.requireCordovaModule('q'); 170 | ``` 171 | 172 | __Note__: new module loader script interface is used for the `.js` files defined via `config.xml` or `plugin.xml` only. 173 | For compatibility reasons hook files specified via `/hooks` folders are run via Node child_process spawn, see 'Non-javascript' section below. 174 | 175 | ### Non-javascript 176 | 177 | Non-javascript scripts are run via Node child_process spawn from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables: 178 | 179 | * CORDOVA_VERSION - The version of the Cordova-CLI. 180 | * CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios). 181 | * CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer) 182 | * CORDOVA_HOOK - Path to the hook that is being executed. 183 | * CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate) 184 | 185 | If a script returns a non-zero exit code, then the parent cordova command will be aborted. 186 | 187 | ## Writing hooks 188 | 189 | We highly recommend writing your hooks using Node.js so that they are 190 | cross-platform. Some good examples are shown here: 191 | 192 | [http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/) 193 | 194 | Also, note that even if you are working on Windows, and in case your hook scripts aren't bat files (which is recommended, if you want your scripts to work in non-Windows operating systems) Cordova CLI will expect a shebang line as the first line for it to know the interpreter it needs to use to launch the script. The shebang line should match the following example: 195 | 196 | #!/usr/bin/env [name_of_interpreter_executable] 197 | -------------------------------------------------------------------------------- /hooks/after_prepare/010_add_platform_class.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Add Platform Class 4 | // v1.0 5 | // Automatically adds the platform class to the body tag 6 | // after the `prepare` command. By placing the platform CSS classes 7 | // directly in the HTML built for the platform, it speeds up 8 | // rendering the correct layout/style for the specific platform 9 | // instead of waiting for the JS to figure out the correct classes. 10 | 11 | var fs = require('fs'); 12 | var path = require('path'); 13 | 14 | var rootdir = process.argv[2]; 15 | 16 | function addPlatformBodyTag(indexPath, platform) { 17 | // add the platform class to the body tag 18 | try { 19 | var platformClass = 'platform-' + platform; 20 | var cordovaClass = 'platform-cordova platform-webview'; 21 | 22 | var html = fs.readFileSync(indexPath, 'utf8'); 23 | 24 | var bodyTag = findBodyTag(html); 25 | if(!bodyTag) return; // no opening body tag, something's wrong 26 | 27 | if(bodyTag.indexOf(platformClass) > -1) return; // already added 28 | 29 | var newBodyTag = bodyTag; 30 | 31 | var classAttr = findClassAttr(bodyTag); 32 | if(classAttr) { 33 | // body tag has existing class attribute, add the classname 34 | var endingQuote = classAttr.substring(classAttr.length-1); 35 | var newClassAttr = classAttr.substring(0, classAttr.length-1); 36 | newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote; 37 | newBodyTag = bodyTag.replace(classAttr, newClassAttr); 38 | 39 | } else { 40 | // add class attribute to the body tag 41 | newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">'); 42 | } 43 | 44 | html = html.replace(bodyTag, newBodyTag); 45 | 46 | fs.writeFileSync(indexPath, html, 'utf8'); 47 | 48 | process.stdout.write('add to body class: ' + platformClass + '\n'); 49 | } catch(e) { 50 | process.stdout.write(e); 51 | } 52 | } 53 | 54 | function findBodyTag(html) { 55 | // get the body tag 56 | try{ 57 | return html.match(/])(.*?)>/gi)[0]; 58 | }catch(e){} 59 | } 60 | 61 | function findClassAttr(bodyTag) { 62 | // get the body tag's class attribute 63 | try{ 64 | return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0]; 65 | }catch(e){} 66 | } 67 | 68 | if (rootdir) { 69 | 70 | // go through each of the platform directories that have been prepared 71 | var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []); 72 | 73 | for(var x=0; x 2 | /// 3 | /// 4 | /// 5 | /// 6 | -------------------------------------------------------------------------------- /typings/browser/ambient/es6-shim/es6-shim.d.ts: -------------------------------------------------------------------------------- 1 | // Compiled using typings@0.6.8 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts 3 | // Type definitions for es6-shim v0.31.2 4 | // Project: https://github.com/paulmillr/es6-shim 5 | // Definitions by: Ron Buckton 6 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 7 | 8 | declare type PropertyKey = string | number | symbol; 9 | 10 | interface IteratorResult { 11 | done: boolean; 12 | value?: T; 13 | } 14 | 15 | interface IterableShim { 16 | /** 17 | * Shim for an ES6 iterable. Not intended for direct use by user code. 18 | */ 19 | "_es6-shim iterator_"(): Iterator; 20 | } 21 | 22 | interface Iterator { 23 | next(value?: any): IteratorResult; 24 | return?(value?: any): IteratorResult; 25 | throw?(e?: any): IteratorResult; 26 | } 27 | 28 | interface IterableIteratorShim extends IterableShim, Iterator { 29 | /** 30 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code. 31 | */ 32 | "_es6-shim iterator_"(): IterableIteratorShim; 33 | } 34 | 35 | interface StringConstructor { 36 | /** 37 | * Return the String value whose elements are, in order, the elements in the List elements. 38 | * If length is 0, the empty string is returned. 39 | */ 40 | fromCodePoint(...codePoints: number[]): string; 41 | 42 | /** 43 | * String.raw is intended for use as a tag function of a Tagged Template String. When called 44 | * as such the first argument will be a well formed template call site object and the rest 45 | * parameter will contain the substitution values. 46 | * @param template A well-formed template string call site representation. 47 | * @param substitutions A set of substitution values. 48 | */ 49 | raw(template: TemplateStringsArray, ...substitutions: any[]): string; 50 | } 51 | 52 | interface String { 53 | /** 54 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point 55 | * value of the UTF-16 encoded code point starting at the string element at position pos in 56 | * the String resulting from converting this object to a String. 57 | * If there is no element at that position, the result is undefined. 58 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. 59 | */ 60 | codePointAt(pos: number): number; 61 | 62 | /** 63 | * Returns true if searchString appears as a substring of the result of converting this 64 | * object to a String, at one or more positions that are 65 | * greater than or equal to position; otherwise, returns false. 66 | * @param searchString search string 67 | * @param position If position is undefined, 0 is assumed, so as to search all of the String. 68 | */ 69 | includes(searchString: string, position?: number): boolean; 70 | 71 | /** 72 | * Returns true if the sequence of elements of searchString converted to a String is the 73 | * same as the corresponding elements of this object (converted to a String) starting at 74 | * endPosition – length(this). Otherwise returns false. 75 | */ 76 | endsWith(searchString: string, endPosition?: number): boolean; 77 | 78 | /** 79 | * Returns a String value that is made from count copies appended together. If count is 0, 80 | * T is the empty String is returned. 81 | * @param count number of copies to append 82 | */ 83 | repeat(count: number): string; 84 | 85 | /** 86 | * Returns true if the sequence of elements of searchString converted to a String is the 87 | * same as the corresponding elements of this object (converted to a String) starting at 88 | * position. Otherwise returns false. 89 | */ 90 | startsWith(searchString: string, position?: number): boolean; 91 | 92 | /** 93 | * Returns an HTML anchor element and sets the name attribute to the text value 94 | * @param name 95 | */ 96 | anchor(name: string): string; 97 | 98 | /** Returns a HTML element */ 99 | big(): string; 100 | 101 | /** Returns a HTML element */ 102 | blink(): string; 103 | 104 | /** Returns a HTML element */ 105 | bold(): string; 106 | 107 | /** Returns a HTML element */ 108 | fixed(): string 109 | 110 | /** Returns a HTML element and sets the color attribute value */ 111 | fontcolor(color: string): string 112 | 113 | /** Returns a HTML element and sets the size attribute value */ 114 | fontsize(size: number): string; 115 | 116 | /** Returns a HTML element and sets the size attribute value */ 117 | fontsize(size: string): string; 118 | 119 | /** Returns an HTML element */ 120 | italics(): string; 121 | 122 | /** Returns an HTML element and sets the href attribute value */ 123 | link(url: string): string; 124 | 125 | /** Returns a HTML element */ 126 | small(): string; 127 | 128 | /** Returns a HTML element */ 129 | strike(): string; 130 | 131 | /** Returns a HTML element */ 132 | sub(): string; 133 | 134 | /** Returns a HTML element */ 135 | sup(): string; 136 | 137 | /** 138 | * Shim for an ES6 iterable. Not intended for direct use by user code. 139 | */ 140 | "_es6-shim iterator_"(): IterableIteratorShim; 141 | } 142 | 143 | interface ArrayConstructor { 144 | /** 145 | * Creates an array from an array-like object. 146 | * @param arrayLike An array-like object to convert to an array. 147 | * @param mapfn A mapping function to call on every element of the array. 148 | * @param thisArg Value of 'this' used to invoke the mapfn. 149 | */ 150 | from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 151 | 152 | /** 153 | * Creates an array from an iterable object. 154 | * @param iterable An iterable object to convert to an array. 155 | * @param mapfn A mapping function to call on every element of the array. 156 | * @param thisArg Value of 'this' used to invoke the mapfn. 157 | */ 158 | from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 159 | 160 | /** 161 | * Creates an array from an array-like object. 162 | * @param arrayLike An array-like object to convert to an array. 163 | */ 164 | from(arrayLike: ArrayLike): Array; 165 | 166 | /** 167 | * Creates an array from an iterable object. 168 | * @param iterable An iterable object to convert to an array. 169 | */ 170 | from(iterable: IterableShim): Array; 171 | 172 | /** 173 | * Returns a new array from a set of elements. 174 | * @param items A set of elements to include in the new array object. 175 | */ 176 | of(...items: T[]): Array; 177 | } 178 | 179 | interface Array { 180 | /** 181 | * Returns the value of the first element in the array where predicate is true, and undefined 182 | * otherwise. 183 | * @param predicate find calls predicate once for each element of the array, in ascending 184 | * order, until it finds one where predicate returns true. If such an element is found, find 185 | * immediately returns that element value. Otherwise, find returns undefined. 186 | * @param thisArg If provided, it will be used as the this value for each invocation of 187 | * predicate. If it is not provided, undefined is used instead. 188 | */ 189 | find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; 190 | 191 | /** 192 | * Returns the index of the first element in the array where predicate is true, and undefined 193 | * otherwise. 194 | * @param predicate find calls predicate once for each element of the array, in ascending 195 | * order, until it finds one where predicate returns true. If such an element is found, find 196 | * immediately returns that element value. Otherwise, find returns undefined. 197 | * @param thisArg If provided, it will be used as the this value for each invocation of 198 | * predicate. If it is not provided, undefined is used instead. 199 | */ 200 | findIndex(predicate: (value: T) => boolean, thisArg?: any): number; 201 | 202 | /** 203 | * Returns the this object after filling the section identified by start and end with value 204 | * @param value value to fill array section with 205 | * @param start index to start filling the array at. If start is negative, it is treated as 206 | * length+start where length is the length of the array. 207 | * @param end index to stop filling the array at. If end is negative, it is treated as 208 | * length+end. 209 | */ 210 | fill(value: T, start?: number, end?: number): T[]; 211 | 212 | /** 213 | * Returns the this object after copying a section of the array identified by start and end 214 | * to the same array starting at position target 215 | * @param target If target is negative, it is treated as length+target where length is the 216 | * length of the array. 217 | * @param start If start is negative, it is treated as length+start. If end is negative, it 218 | * is treated as length+end. 219 | * @param end If not specified, length of the this object is used as its default value. 220 | */ 221 | copyWithin(target: number, start: number, end?: number): T[]; 222 | 223 | /** 224 | * Returns an array of key, value pairs for every entry in the array 225 | */ 226 | entries(): IterableIteratorShim<[number, T]>; 227 | 228 | /** 229 | * Returns an list of keys in the array 230 | */ 231 | keys(): IterableIteratorShim; 232 | 233 | /** 234 | * Returns an list of values in the array 235 | */ 236 | values(): IterableIteratorShim; 237 | 238 | /** 239 | * Shim for an ES6 iterable. Not intended for direct use by user code. 240 | */ 241 | "_es6-shim iterator_"(): IterableIteratorShim; 242 | } 243 | 244 | interface NumberConstructor { 245 | /** 246 | * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 247 | * that is representable as a Number value, which is approximately: 248 | * 2.2204460492503130808472633361816 x 10‍−‍16. 249 | */ 250 | EPSILON: number; 251 | 252 | /** 253 | * Returns true if passed value is finite. 254 | * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a 255 | * number. Only finite values of the type number, result in true. 256 | * @param number A numeric value. 257 | */ 258 | isFinite(number: number): boolean; 259 | 260 | /** 261 | * Returns true if the value passed is an integer, false otherwise. 262 | * @param number A numeric value. 263 | */ 264 | isInteger(number: number): boolean; 265 | 266 | /** 267 | * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a 268 | * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter 269 | * to a number. Only values of the type number, that are also NaN, result in true. 270 | * @param number A numeric value. 271 | */ 272 | isNaN(number: number): boolean; 273 | 274 | /** 275 | * Returns true if the value passed is a safe integer. 276 | * @param number A numeric value. 277 | */ 278 | isSafeInteger(number: number): boolean; 279 | 280 | /** 281 | * The value of the largest integer n such that n and n + 1 are both exactly representable as 282 | * a Number value. 283 | * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. 284 | */ 285 | MAX_SAFE_INTEGER: number; 286 | 287 | /** 288 | * The value of the smallest integer n such that n and n − 1 are both exactly representable as 289 | * a Number value. 290 | * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). 291 | */ 292 | MIN_SAFE_INTEGER: number; 293 | 294 | /** 295 | * Converts a string to a floating-point number. 296 | * @param string A string that contains a floating-point number. 297 | */ 298 | parseFloat(string: string): number; 299 | 300 | /** 301 | * Converts A string to an integer. 302 | * @param s A string to convert into a number. 303 | * @param radix A value between 2 and 36 that specifies the base of the number in numString. 304 | * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. 305 | * All other strings are considered decimal. 306 | */ 307 | parseInt(string: string, radix?: number): number; 308 | } 309 | 310 | interface ObjectConstructor { 311 | /** 312 | * Copy the values of all of the enumerable own properties from one or more source objects to a 313 | * target object. Returns the target object. 314 | * @param target The target object to copy to. 315 | * @param sources One or more source objects to copy properties from. 316 | */ 317 | assign(target: any, ...sources: any[]): any; 318 | 319 | /** 320 | * Returns true if the values are the same value, false otherwise. 321 | * @param value1 The first value. 322 | * @param value2 The second value. 323 | */ 324 | is(value1: any, value2: any): boolean; 325 | 326 | /** 327 | * Sets the prototype of a specified object o to object proto or null. Returns the object o. 328 | * @param o The object to change its prototype. 329 | * @param proto The value of the new prototype or null. 330 | * @remarks Requires `__proto__` support. 331 | */ 332 | setPrototypeOf(o: any, proto: any): any; 333 | } 334 | 335 | interface RegExp { 336 | /** 337 | * Returns a string indicating the flags of the regular expression in question. This field is read-only. 338 | * The characters in this string are sequenced and concatenated in the following order: 339 | * 340 | * - "g" for global 341 | * - "i" for ignoreCase 342 | * - "m" for multiline 343 | * - "u" for unicode 344 | * - "y" for sticky 345 | * 346 | * If no flags are set, the value is the empty string. 347 | */ 348 | flags: string; 349 | } 350 | 351 | interface Math { 352 | /** 353 | * Returns the number of leading zero bits in the 32-bit binary representation of a number. 354 | * @param x A numeric expression. 355 | */ 356 | clz32(x: number): number; 357 | 358 | /** 359 | * Returns the result of 32-bit multiplication of two numbers. 360 | * @param x First number 361 | * @param y Second number 362 | */ 363 | imul(x: number, y: number): number; 364 | 365 | /** 366 | * Returns the sign of the x, indicating whether x is positive, negative or zero. 367 | * @param x The numeric expression to test 368 | */ 369 | sign(x: number): number; 370 | 371 | /** 372 | * Returns the base 10 logarithm of a number. 373 | * @param x A numeric expression. 374 | */ 375 | log10(x: number): number; 376 | 377 | /** 378 | * Returns the base 2 logarithm of a number. 379 | * @param x A numeric expression. 380 | */ 381 | log2(x: number): number; 382 | 383 | /** 384 | * Returns the natural logarithm of 1 + x. 385 | * @param x A numeric expression. 386 | */ 387 | log1p(x: number): number; 388 | 389 | /** 390 | * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of 391 | * the natural logarithms). 392 | * @param x A numeric expression. 393 | */ 394 | expm1(x: number): number; 395 | 396 | /** 397 | * Returns the hyperbolic cosine of a number. 398 | * @param x A numeric expression that contains an angle measured in radians. 399 | */ 400 | cosh(x: number): number; 401 | 402 | /** 403 | * Returns the hyperbolic sine of a number. 404 | * @param x A numeric expression that contains an angle measured in radians. 405 | */ 406 | sinh(x: number): number; 407 | 408 | /** 409 | * Returns the hyperbolic tangent of a number. 410 | * @param x A numeric expression that contains an angle measured in radians. 411 | */ 412 | tanh(x: number): number; 413 | 414 | /** 415 | * Returns the inverse hyperbolic cosine of a number. 416 | * @param x A numeric expression that contains an angle measured in radians. 417 | */ 418 | acosh(x: number): number; 419 | 420 | /** 421 | * Returns the inverse hyperbolic sine of a number. 422 | * @param x A numeric expression that contains an angle measured in radians. 423 | */ 424 | asinh(x: number): number; 425 | 426 | /** 427 | * Returns the inverse hyperbolic tangent of a number. 428 | * @param x A numeric expression that contains an angle measured in radians. 429 | */ 430 | atanh(x: number): number; 431 | 432 | /** 433 | * Returns the square root of the sum of squares of its arguments. 434 | * @param values Values to compute the square root for. 435 | * If no arguments are passed, the result is +0. 436 | * If there is only one argument, the result is the absolute value. 437 | * If any argument is +Infinity or -Infinity, the result is +Infinity. 438 | * If any argument is NaN, the result is NaN. 439 | * If all arguments are either +0 or −0, the result is +0. 440 | */ 441 | hypot(...values: number[]): number; 442 | 443 | /** 444 | * Returns the integral part of the a numeric expression, x, removing any fractional digits. 445 | * If x is already an integer, the result is x. 446 | * @param x A numeric expression. 447 | */ 448 | trunc(x: number): number; 449 | 450 | /** 451 | * Returns the nearest single precision float representation of a number. 452 | * @param x A numeric expression. 453 | */ 454 | fround(x: number): number; 455 | 456 | /** 457 | * Returns an implementation-dependent approximation to the cube root of number. 458 | * @param x A numeric expression. 459 | */ 460 | cbrt(x: number): number; 461 | } 462 | 463 | interface PromiseLike { 464 | /** 465 | * Attaches callbacks for the resolution and/or rejection of the Promise. 466 | * @param onfulfilled The callback to execute when the Promise is resolved. 467 | * @param onrejected The callback to execute when the Promise is rejected. 468 | * @returns A Promise for the completion of which ever callback is executed. 469 | */ 470 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; 471 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; 472 | } 473 | 474 | /** 475 | * Represents the completion of an asynchronous operation 476 | */ 477 | interface Promise { 478 | /** 479 | * Attaches callbacks for the resolution and/or rejection of the Promise. 480 | * @param onfulfilled The callback to execute when the Promise is resolved. 481 | * @param onrejected The callback to execute when the Promise is rejected. 482 | * @returns A Promise for the completion of which ever callback is executed. 483 | */ 484 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 485 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 486 | 487 | /** 488 | * Attaches a callback for only the rejection of the Promise. 489 | * @param onrejected The callback to execute when the Promise is rejected. 490 | * @returns A Promise for the completion of the callback. 491 | */ 492 | catch(onrejected?: (reason: any) => T | PromiseLike): Promise; 493 | catch(onrejected?: (reason: any) => void): Promise; 494 | } 495 | 496 | interface PromiseConstructor { 497 | /** 498 | * A reference to the prototype. 499 | */ 500 | prototype: Promise; 501 | 502 | /** 503 | * Creates a new Promise. 504 | * @param executor A callback used to initialize the promise. This callback is passed two arguments: 505 | * a resolve callback used resolve the promise with a value or the result of another promise, 506 | * and a reject callback used to reject the promise with a provided reason or error. 507 | */ 508 | new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; 509 | 510 | /** 511 | * Creates a Promise that is resolved with an array of results when all of the provided Promises 512 | * resolve, or rejected when any Promise is rejected. 513 | * @param values An array of Promises. 514 | * @returns A new Promise. 515 | */ 516 | all(values: IterableShim>): Promise; 517 | 518 | /** 519 | * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 520 | * or rejected. 521 | * @param values An array of Promises. 522 | * @returns A new Promise. 523 | */ 524 | race(values: IterableShim>): Promise; 525 | 526 | /** 527 | * Creates a new rejected promise for the provided reason. 528 | * @param reason The reason the promise was rejected. 529 | * @returns A new rejected Promise. 530 | */ 531 | reject(reason: any): Promise; 532 | 533 | /** 534 | * Creates a new rejected promise for the provided reason. 535 | * @param reason The reason the promise was rejected. 536 | * @returns A new rejected Promise. 537 | */ 538 | reject(reason: any): Promise; 539 | 540 | /** 541 | * Creates a new resolved promise for the provided value. 542 | * @param value A promise. 543 | * @returns A promise whose internal state matches the provided promise. 544 | */ 545 | resolve(value: T | PromiseLike): Promise; 546 | 547 | /** 548 | * Creates a new resolved promise . 549 | * @returns A resolved promise. 550 | */ 551 | resolve(): Promise; 552 | } 553 | 554 | declare var Promise: PromiseConstructor; 555 | 556 | interface Map { 557 | clear(): void; 558 | delete(key: K): boolean; 559 | forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; 560 | get(key: K): V; 561 | has(key: K): boolean; 562 | set(key: K, value?: V): Map; 563 | size: number; 564 | entries(): IterableIteratorShim<[K, V]>; 565 | keys(): IterableIteratorShim; 566 | values(): IterableIteratorShim; 567 | } 568 | 569 | interface MapConstructor { 570 | new (): Map; 571 | new (iterable: IterableShim<[K, V]>): Map; 572 | prototype: Map; 573 | } 574 | 575 | declare var Map: MapConstructor; 576 | 577 | interface Set { 578 | add(value: T): Set; 579 | clear(): void; 580 | delete(value: T): boolean; 581 | forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; 582 | has(value: T): boolean; 583 | size: number; 584 | entries(): IterableIteratorShim<[T, T]>; 585 | keys(): IterableIteratorShim; 586 | values(): IterableIteratorShim; 587 | } 588 | 589 | interface SetConstructor { 590 | new (): Set; 591 | new (iterable: IterableShim): Set; 592 | prototype: Set; 593 | } 594 | 595 | declare var Set: SetConstructor; 596 | 597 | interface WeakMap { 598 | delete(key: K): boolean; 599 | get(key: K): V; 600 | has(key: K): boolean; 601 | set(key: K, value?: V): WeakMap; 602 | } 603 | 604 | interface WeakMapConstructor { 605 | new (): WeakMap; 606 | new (iterable: IterableShim<[K, V]>): WeakMap; 607 | prototype: WeakMap; 608 | } 609 | 610 | declare var WeakMap: WeakMapConstructor; 611 | 612 | interface WeakSet { 613 | add(value: T): WeakSet; 614 | delete(value: T): boolean; 615 | has(value: T): boolean; 616 | } 617 | 618 | interface WeakSetConstructor { 619 | new (): WeakSet; 620 | new (iterable: IterableShim): WeakSet; 621 | prototype: WeakSet; 622 | } 623 | 624 | declare var WeakSet: WeakSetConstructor; 625 | 626 | declare module Reflect { 627 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 628 | function construct(target: Function, argumentsList: ArrayLike): any; 629 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 630 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 631 | function enumerate(target: any): IterableIteratorShim; 632 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 633 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 634 | function getPrototypeOf(target: any): any; 635 | function has(target: any, propertyKey: PropertyKey): boolean; 636 | function isExtensible(target: any): boolean; 637 | function ownKeys(target: any): Array; 638 | function preventExtensions(target: any): boolean; 639 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 640 | function setPrototypeOf(target: any, proto: any): boolean; 641 | } 642 | 643 | declare module "es6-shim" { 644 | var String: StringConstructor; 645 | var Array: ArrayConstructor; 646 | var Number: NumberConstructor; 647 | var Math: Math; 648 | var Object: ObjectConstructor; 649 | var Map: MapConstructor; 650 | var Set: SetConstructor; 651 | var WeakMap: WeakMapConstructor; 652 | var WeakSet: WeakSetConstructor; 653 | var Promise: PromiseConstructor; 654 | module Reflect { 655 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 656 | function construct(target: Function, argumentsList: ArrayLike): any; 657 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 658 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 659 | function enumerate(target: any): Iterator; 660 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 661 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 662 | function getPrototypeOf(target: any): any; 663 | function has(target: any, propertyKey: PropertyKey): boolean; 664 | function isExtensible(target: any): boolean; 665 | function ownKeys(target: any): Array; 666 | function preventExtensions(target: any): boolean; 667 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 668 | function setPrototypeOf(target: any, proto: any): boolean; 669 | } 670 | } -------------------------------------------------------------------------------- /typings/browser/ambient/firebase/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/firebase/firebase.d.ts 3 | // Type definitions for Firebase API 2.4.1 4 | // Project: https://www.firebase.com/docs/javascript/firebase 5 | // Definitions by: Vincent Botone , Shin1 Kashimura , Sebastien Dubois , Szymon Stasik 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | 8 | interface FirebaseAuthResult { 9 | auth: any; 10 | expires: number; 11 | } 12 | 13 | interface FirebaseDataSnapshot { 14 | /** 15 | * Returns true if this DataSnapshot contains any data. 16 | * It is slightly more efficient than using snapshot.val() !== null. 17 | */ 18 | exists(): boolean; 19 | /** 20 | * Gets the JavaScript object representation of the DataSnapshot. 21 | */ 22 | val(): any; 23 | /** 24 | * Gets a DataSnapshot for the location at the specified relative path. 25 | */ 26 | child(childPath: string): FirebaseDataSnapshot; 27 | /** 28 | * Enumerates through the DataSnapshot’s children (in the default order). 29 | */ 30 | forEach(childAction: (childSnapshot: FirebaseDataSnapshot) => void): boolean; 31 | forEach(childAction: (childSnapshot: FirebaseDataSnapshot) => boolean): boolean; 32 | /** 33 | * Returns true if the specified child exists. 34 | */ 35 | hasChild(childPath: string): boolean; 36 | /** 37 | * Returns true if the DataSnapshot has any children. 38 | */ 39 | hasChildren(): boolean; 40 | /** 41 | * Gets the key name of the location that generated this DataSnapshot. 42 | */ 43 | key(): string; 44 | /** 45 | * @deprecated Use key() instead. 46 | * Gets the key name of the location that generated this DataSnapshot. 47 | */ 48 | name(): string; 49 | /** 50 | * Gets the number of children for this DataSnapshot. 51 | */ 52 | numChildren(): number; 53 | /** 54 | * Gets the Firebase reference for the location that generated this DataSnapshot. 55 | */ 56 | ref(): Firebase; 57 | /** 58 | * Gets the priority of the data in this DataSnapshot. 59 | * @returns {string, number, null} The priority, or null if no priority was set. 60 | */ 61 | getPriority(): any; // string or number 62 | /** 63 | * Exports the entire contents of the DataSnapshot as a JavaScript object. 64 | */ 65 | exportVal(): Object; 66 | } 67 | 68 | interface FirebaseOnDisconnect { 69 | /** 70 | * Ensures the data at this location is set to the specified value when the client is disconnected 71 | * (due to closing the browser, navigating to a new page, or network issues). 72 | */ 73 | set(value: any, onComplete: (error: any) => void): void; 74 | set(value: any): Promise; 75 | /** 76 | * Ensures the data at this location is set to the specified value and priority when the client is disconnected 77 | * (due to closing the browser, navigating to a new page, or network issues). 78 | */ 79 | setWithPriority(value: any, priority: string|number, onComplete: (error: any) => void): void; 80 | setWithPriority(value: any, priority: string|number): Promise; 81 | /** 82 | * Writes the enumerated children at this Firebase location when the client is disconnected 83 | * (due to closing the browser, navigating to a new page, or network issues). 84 | */ 85 | update(value: Object, onComplete: (error: any) => void): void; 86 | update(value: Object): Promise; 87 | /** 88 | * Ensures the data at this location is deleted when the client is disconnected 89 | * (due to closing the browser, navigating to a new page, or network issues). 90 | */ 91 | remove(onComplete: (error: any) => void): void; 92 | remove(): Promise; 93 | /** 94 | * Cancels all previously queued onDisconnect() set or update events for this location and all children. 95 | */ 96 | cancel(onComplete: (error: any) => void): void; 97 | cancel(): Promise; 98 | } 99 | 100 | interface FirebaseQuery { 101 | /** 102 | * Listens for data changes at a particular location. 103 | */ 104 | on(eventType: string, callback: (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: (error: any) => void, context?: Object): (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void; 105 | /** 106 | * Detaches a callback previously attached with on(). 107 | */ 108 | off(eventType?: string, callback?: (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void, context?: Object): void; 109 | /** 110 | * Listens for exactly one event of the specified event type, and then stops listening. 111 | */ 112 | once(eventType: string, successCallback: (dataSnapshot: FirebaseDataSnapshot) => void, context?: Object): void; 113 | once(eventType: string, successCallback: (dataSnapshot: FirebaseDataSnapshot) => void, failureCallback?: (error: any) => void, context?: Object): void; 114 | once(eventType: string): Promise 115 | /** 116 | * Generates a new Query object ordered by the specified child key. 117 | */ 118 | orderByChild(key: string): FirebaseQuery; 119 | /** 120 | * Generates a new Query object ordered by key name. 121 | */ 122 | orderByKey(): FirebaseQuery; 123 | /** 124 | * Generates a new Query object ordered by child values. 125 | */ 126 | orderByValue(): FirebaseQuery; 127 | /** 128 | * Generates a new Query object ordered by priority. 129 | */ 130 | orderByPriority(): FirebaseQuery; 131 | /** 132 | * @deprecated Use limitToFirst() and limitToLast() instead. 133 | * Generates a new Query object limited to the specified number of children. 134 | */ 135 | limit(limit: number): FirebaseQuery; 136 | /** 137 | * Creates a Query with the specified starting point. 138 | * The generated Query includes children which match the specified starting point. 139 | */ 140 | startAt(value: string, key?: string): FirebaseQuery; 141 | startAt(value: number, key?: string): FirebaseQuery; 142 | /** 143 | * Creates a Query with the specified ending point. 144 | * The generated Query includes children which match the specified ending point. 145 | */ 146 | endAt(value: string, key?: string): FirebaseQuery; 147 | endAt(value: number, key?: string): FirebaseQuery; 148 | /** 149 | * Creates a Query which includes children which match the specified value. 150 | */ 151 | equalTo(value: string|number|boolean, key?: string): FirebaseQuery; 152 | /** 153 | * Generates a new Query object limited to the first certain number of children. 154 | */ 155 | limitToFirst(limit: number): FirebaseQuery; 156 | /** 157 | * Generates a new Query object limited to the last certain number of children. 158 | */ 159 | limitToLast(limit: number): FirebaseQuery; 160 | /** 161 | * Gets a Firebase reference to the Query's location. 162 | */ 163 | ref(): Firebase; 164 | } 165 | 166 | interface Firebase extends FirebaseQuery { 167 | /** 168 | * @deprecated Use authWithCustomToken() instead. 169 | * Authenticates a Firebase client using the provided authentication token or Firebase Secret. 170 | */ 171 | auth(authToken: string, onComplete: (error: any, result: FirebaseAuthResult) => void, onCancel?:(error: any) => void): void; 172 | auth(authToken: string): Promise; 173 | /** 174 | * Authenticates a Firebase client using an authentication token or Firebase Secret. 175 | */ 176 | authWithCustomToken(autoToken: string, onComplete: (error: any, authData: FirebaseAuthData) => void, options?:Object): void; 177 | authWithCustomToken(autoToken: string, options?:Object): Promise; 178 | /** 179 | * Authenticates a Firebase client using a new, temporary guest account. 180 | */ 181 | authAnonymously(onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void; 182 | authAnonymously(options?: Object): Promise; 183 | /** 184 | * Authenticates a Firebase client using an email / password combination. 185 | */ 186 | authWithPassword(credentials: FirebaseCredentials, onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void; 187 | authWithPassword(credentials: FirebaseCredentials, options?: Object): Promise; 188 | /** 189 | * Authenticates a Firebase client using a popup-based OAuth flow. 190 | */ 191 | authWithOAuthPopup(provider: string, onComplete:(error: any, authData: FirebaseAuthData) => void, options?: Object): void; 192 | authWithOAuthPopup(provider: string, options?: Object): Promise; 193 | /** 194 | * Authenticates a Firebase client using a redirect-based OAuth flow. 195 | */ 196 | authWithOAuthRedirect(provider: string, onComplete: (error: any) => void, options?: Object): void; 197 | authWithOAuthRedirect(provider: string, options?: Object): Promise; 198 | /** 199 | * Authenticates a Firebase client using OAuth access tokens or credentials. 200 | */ 201 | authWithOAuthToken(provider: string, credentials: string|Object, onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void; 202 | authWithOAuthToken(provider: string, credentials: string|Object, options?: Object): Promise; 203 | /** 204 | * Synchronously access the current authentication state of the client. 205 | */ 206 | getAuth(): FirebaseAuthData; 207 | /** 208 | * Listen for changes to the client's authentication state. 209 | */ 210 | onAuth(onComplete: (authData: FirebaseAuthData) => void, context?: Object): void; 211 | /** 212 | * Detaches a callback previously attached with onAuth(). 213 | */ 214 | offAuth(onComplete: (authData: FirebaseAuthData) => void, context?: Object): void; 215 | /** 216 | * Unauthenticates a Firebase client. 217 | */ 218 | unauth(): void; 219 | /** 220 | * Gets a Firebase reference for the location at the specified relative path. 221 | */ 222 | child(childPath: string): Firebase; 223 | /** 224 | * Gets a Firebase reference to the parent location. 225 | */ 226 | parent(): Firebase; 227 | /** 228 | * Gets a Firebase reference to the root of the Firebase. 229 | */ 230 | root(): Firebase; 231 | /** 232 | * Returns the last token in a Firebase location. 233 | */ 234 | key(): string; 235 | /** 236 | * @deprecated Use key() instead. 237 | * Returns the last token in a Firebase location. 238 | */ 239 | name(): string; 240 | /** 241 | * Gets the absolute URL corresponding to this Firebase reference's location. 242 | */ 243 | toString(): string; 244 | /** 245 | * Writes data to this Firebase location. 246 | */ 247 | set(value: any, onComplete: (error: any) => void): void; 248 | set(value: any): Promise; 249 | /** 250 | * Writes the enumerated children to this Firebase location. 251 | */ 252 | update(value: Object, onComplete: (error: any) => void): void; 253 | update(value: Object): Promise; 254 | /** 255 | * Removes the data at this Firebase location. 256 | */ 257 | remove(onComplete: (error: any) => void): void; 258 | remove(): Promise; 259 | /** 260 | * Generates a new child location using a unique name and returns a Firebase reference to it. 261 | * @returns {Firebase} A Firebase reference for the generated location. 262 | */ 263 | push(value?: any, onComplete?: (error: any) => void): FirebaseWithPromise; 264 | /** 265 | * Writes data to this Firebase location. Like set() but also specifies the priority for that data. 266 | */ 267 | setWithPriority(value: any, priority: string|number, onComplete: (error: any) => void): void; 268 | setWithPriority(value: any, priority: string|number): Promise; 269 | /** 270 | * Sets a priority for the data at this Firebase location. 271 | */ 272 | setPriority(priority: string|number, onComplete: (error: any) => void): void; 273 | setPriority(priority: string|number): Promise; 274 | /** 275 | * Atomically modifies the data at this location. 276 | */ 277 | transaction(updateFunction: (currentData: any)=> any, onComplete?: (error: any, committed: boolean, snapshot: FirebaseDataSnapshot) => void, applyLocally?: boolean): void; 278 | /** 279 | * Creates a new user account using an email / password combination. 280 | */ 281 | createUser(credentials: FirebaseCredentials, onComplete: (error: any, userData: any) => void): void; 282 | /** 283 | * Updates the email associated with an email / password user account. 284 | */ 285 | changeEmail(credentials: FirebaseChangeEmailCredentials, onComplete: (error: any) => void): void; 286 | /** 287 | * Change the password of an existing user using an email / password combination. 288 | */ 289 | changePassword(credentials: FirebaseChangePasswordCredentials, onComplete: (error: any) => void): void; 290 | /** 291 | * Removes an existing user account using an email / password combination. 292 | */ 293 | removeUser(credentials: FirebaseCredentials, onComplete: (error: any) => void): void; 294 | /** 295 | * Sends a password-reset email to the owner of the account, containing a token that may be used to authenticate and change the user password. 296 | */ 297 | resetPassword(credentials: FirebaseResetPasswordCredentials, onComplete: (error: any) => void): void; 298 | onDisconnect(): FirebaseOnDisconnect; 299 | } 300 | 301 | interface FirebaseWithPromise extends Firebase, Promise {} 302 | 303 | interface FirebaseStatic { 304 | /** 305 | * Constructs a new Firebase reference from a full Firebase URL. 306 | */ 307 | new (firebaseURL: string): Firebase; 308 | /** 309 | * Manually disconnects the Firebase client from the server and disables automatic reconnection. 310 | */ 311 | goOffline(): void; 312 | /** 313 | * Manually reestablishes a connection to the Firebase server and enables automatic reconnection. 314 | */ 315 | goOnline(): void; 316 | 317 | ServerValue: { 318 | /** 319 | * A placeholder value for auto-populating the current timestamp 320 | * (time since the Unix epoch, in milliseconds) by the Firebase servers. 321 | */ 322 | TIMESTAMP: any; 323 | }; 324 | } 325 | declare var Firebase: FirebaseStatic; 326 | 327 | declare module 'firebase' { 328 | export = Firebase; 329 | } 330 | 331 | // Reference: https://www.firebase.com/docs/web/api/firebase/getauth.html 332 | interface FirebaseAuthData { 333 | uid: string; 334 | provider: string; 335 | token: string; 336 | expires: number; 337 | auth: Object; 338 | google?: FirebaseAuthDataGoogle; 339 | } 340 | 341 | interface FirebaseAuthDataGoogle { 342 | accessToken: string; 343 | cachedUserProfile: FirebaseAuthDataGoogleCachedUserProfile; 344 | displayName: string; 345 | email?: string; 346 | id: string; 347 | profileImageURL: string; 348 | } 349 | 350 | interface FirebaseAuthDataGoogleCachedUserProfile { 351 | "family name"?: string; 352 | gender?: string; 353 | "given name"?: string; 354 | id?: string; 355 | link?: string; 356 | locale?: string; 357 | name?: string; 358 | picture?: string; 359 | } 360 | 361 | interface FirebaseCredentials { 362 | email: string; 363 | password: string; 364 | } 365 | 366 | interface FirebaseChangePasswordCredentials { 367 | email: string; 368 | oldPassword: string; 369 | newPassword: string; 370 | } 371 | 372 | interface FirebaseChangeEmailCredentials { 373 | oldEmail: string; 374 | newEmail: string; 375 | password: string; 376 | } 377 | 378 | interface FirebaseResetPasswordCredentials { 379 | email: string; 380 | } -------------------------------------------------------------------------------- /typings/browser/ambient/peerjs/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/peerjs/peerjs.d.ts 3 | // Type definitions for PeerJS 4 | // Project: http://peerjs.com/ 5 | // Definitions by: Toshiya Nakakura 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | 8 | 9 | 10 | declare namespace PeerJs{ 11 | interface PeerJSOption{ 12 | key?: string; 13 | host?: string; 14 | port?: number; 15 | path?: string; 16 | secure?: boolean; 17 | config?: RTCPeerConnectionConfig; 18 | debug?: number; 19 | } 20 | 21 | interface PeerConnectOption{ 22 | label?: string; 23 | metadata?: any; 24 | serialization?: string; 25 | reliable?: boolean; 26 | 27 | } 28 | 29 | interface DataConnection{ 30 | send(data: any): void; 31 | close(): void; 32 | on(event: string, cb: ()=>void): void; 33 | on(event: 'data', cb: (data: any)=>void): void; 34 | on(event: 'open', cb: ()=>void): void; 35 | on(event: 'close', cb: ()=>void): void; 36 | on(event: 'error', cb: (err: any)=>void): void; 37 | off(event: string, fn: Function, once?: boolean): void; 38 | dataChannel: RTCDataChannel; 39 | label: string; 40 | metadata: any; 41 | open: boolean; 42 | peerConnection: any; 43 | peer: string; 44 | reliable: boolean; 45 | serialization: string; 46 | type: string; 47 | buffSize: number; 48 | } 49 | 50 | interface MediaConnection{ 51 | answer(stream?: any): void; 52 | close(): void; 53 | on(event: string, cb: ()=>void): void; 54 | on(event: 'stream', cb: (stream: any)=>void): void; 55 | on(event: 'close', cb: ()=>void): void; 56 | on(event: 'error', cb: (err: any)=>void): void; 57 | off(event: string, fn: Function, once?: boolean): void; 58 | open: boolean; 59 | metadata: any; 60 | peer: string; 61 | type: string; 62 | } 63 | 64 | interface utilSupportsObj { 65 | audioVideo: boolean; 66 | data: boolean; 67 | binary: boolean; 68 | reliable: boolean; 69 | } 70 | 71 | interface util{ 72 | browser: string; 73 | supports: utilSupportsObj; 74 | } 75 | 76 | export interface Peer{ 77 | /** 78 | * 79 | * @param id The brokering ID of the remote peer (their peer.id). 80 | * @param options for specifying details about Peer Connection 81 | */ 82 | connect(id: string, options?: PeerJs.PeerConnectOption): PeerJs.DataConnection; 83 | /** 84 | * Connects to the remote peer specified by id and returns a data connection. 85 | * @param id The brokering ID of the remote peer (their peer.id). 86 | * @param stream The caller's media stream 87 | * @param options Metadata associated with the connection, passed in by whoever initiated the connection. 88 | */ 89 | call(id: string, stream: any, options?: any): PeerJs.MediaConnection; 90 | /** 91 | * Calls the remote peer specified by id and returns a media connection. 92 | * @param event Event name 93 | * @param cb Callback Function 94 | */ 95 | on(event: string, cb: ()=>void): void; 96 | /** 97 | * Emitted when a connection to the PeerServer is established. 98 | * @param event Event name 99 | * @param cb id is the brokering ID of the peer 100 | */ 101 | on(event: 'open', cb: (id: string)=>void): void; 102 | /** 103 | * Emitted when a new data connection is established from a remote peer. 104 | * @param event Event name 105 | * @param cb Callback Function 106 | */ 107 | on(event: 'connection', cb: (dataConnection: PeerJs.DataConnection)=>void): void; 108 | /** 109 | * Emitted when a remote peer attempts to call you. 110 | * @param event Event name 111 | * @param cb Callback Function 112 | */ 113 | on(event: 'call', cb: (mediaConnection: PeerJs.MediaConnection)=>void): void; 114 | /** 115 | * Emitted when the peer is destroyed and can no longer accept or create any new connections. 116 | * @param event Event name 117 | * @param cb Callback Function 118 | */ 119 | on(event: 'close', cb: ()=>void): void; 120 | /** 121 | * Emitted when the peer is disconnected from the signalling server 122 | * @param event Event name 123 | * @param cb Callback Function 124 | */ 125 | on(event: 'disconnected', cb: ()=>void): void; 126 | /** 127 | * Errors on the peer are almost always fatal and will destroy the peer. 128 | * @param event Event name 129 | * @param cb Callback Function 130 | */ 131 | on(event: 'error', cb: (err: any)=>void): void; 132 | /** 133 | * Remove event listeners.(EventEmitter3) 134 | * @param {String} event The event we want to remove. 135 | * @param {Function} fn The listener that we need to find. 136 | * @param {Boolean} once Only remove once listeners. 137 | */ 138 | off(event: string, fn: Function, once?: boolean): void; 139 | /** 140 | * Close the connection to the server, leaving all existing data and media connections intact. 141 | */ 142 | disconnect(): void; 143 | /** 144 | * Attempt to reconnect to the server with the peer's old ID 145 | */ 146 | reconnect(): void; 147 | /** 148 | * Close the connection to the server and terminate all existing connections. 149 | */ 150 | destroy(): void; 151 | 152 | /** 153 | * Retrieve a data/media connection for this peer. 154 | * @param peer 155 | * @param id 156 | */ 157 | getConnection(peer: Peer, id: string): any; 158 | 159 | /** 160 | * Get a list of available peer IDs 161 | * @param callback 162 | */ 163 | listAllPeers(callback: (peerIds: Array)=>void): void; 164 | /** 165 | * The brokering ID of this peer 166 | */ 167 | id: string; 168 | /** 169 | * A hash of all connections associated with this peer, keyed by the remote peer's ID. 170 | */ 171 | connections: any; 172 | /** 173 | * false if there is an active connection to the PeerServer. 174 | */ 175 | disconnected: boolean; 176 | /** 177 | * true if this peer and all of its connections can no longer be used. 178 | */ 179 | destroyed: boolean; 180 | } 181 | } 182 | 183 | declare var Peer: { 184 | prototype: RTCIceServer; 185 | /** 186 | * A peer can connect to other peers and listen for connections. 187 | * @param id Other peers can connect to this peer using the provided ID. 188 | * If no ID is given, one will be generated by the brokering server. 189 | * @param options for specifying details about PeerServer 190 | */ 191 | new (id: string, options?: PeerJs.PeerJSOption): PeerJs.Peer; 192 | 193 | /** 194 | * A peer can connect to other peers and listen for connections. 195 | * @param options for specifying details about PeerServer 196 | */ 197 | new (options: PeerJs.PeerJSOption): PeerJs.Peer; 198 | }; -------------------------------------------------------------------------------- /typings/browser/ambient/webrtc/mediastream/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/webrtc/MediaStream.d.ts 3 | // Type definitions for WebRTC 4 | // Project: http://dev.w3.org/2011/webrtc/ 5 | // Definitions by: Ken Smith 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | 8 | // Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html 9 | // version: W3C Editor's Draft 29 June 2015 10 | 11 | interface ConstrainBooleanParameters { 12 | exact?: boolean; 13 | ideal?: boolean; 14 | } 15 | 16 | interface NumberRange { 17 | max?: number; 18 | min?: number; 19 | } 20 | 21 | interface ConstrainNumberRange extends NumberRange { 22 | exact?: number; 23 | ideal?: number; 24 | } 25 | 26 | interface ConstrainStringParameters { 27 | exact?: string | string[]; 28 | ideal?: string | string[]; 29 | } 30 | 31 | interface MediaStreamConstraints { 32 | video?: boolean | MediaTrackConstraints; 33 | audio?: boolean | MediaTrackConstraints; 34 | } 35 | 36 | declare namespace W3C { 37 | type LongRange = NumberRange; 38 | type DoubleRange = NumberRange; 39 | type ConstrainBoolean = boolean | ConstrainBooleanParameters; 40 | type ConstrainNumber = number | ConstrainNumberRange; 41 | type ConstrainLong = ConstrainNumber; 42 | type ConstrainDouble = ConstrainNumber; 43 | type ConstrainString = string | string[] | ConstrainStringParameters; 44 | } 45 | 46 | interface MediaTrackConstraints extends MediaTrackConstraintSet { 47 | advanced?: MediaTrackConstraintSet[]; 48 | } 49 | 50 | interface MediaTrackConstraintSet { 51 | width?: W3C.ConstrainLong; 52 | height?: W3C.ConstrainLong; 53 | aspectRatio?: W3C.ConstrainDouble; 54 | frameRate?: W3C.ConstrainDouble; 55 | facingMode?: W3C.ConstrainString; 56 | volume?: W3C.ConstrainDouble; 57 | sampleRate?: W3C.ConstrainLong; 58 | sampleSize?: W3C.ConstrainLong; 59 | echoCancellation?: W3C.ConstrainBoolean; 60 | latency?: W3C.ConstrainDouble; 61 | deviceId?: W3C.ConstrainString; 62 | groupId?: W3C.ConstrainString; 63 | } 64 | 65 | interface MediaTrackSupportedConstraints { 66 | width?: boolean; 67 | height?: boolean; 68 | aspectRatio?: boolean; 69 | frameRate?: boolean; 70 | facingMode?: boolean; 71 | volume?: boolean; 72 | sampleRate?: boolean; 73 | sampleSize?: boolean; 74 | echoCancellation?: boolean; 75 | latency?: boolean; 76 | deviceId?: boolean; 77 | groupId?: boolean; 78 | } 79 | 80 | interface MediaStream extends EventTarget { 81 | id: string; 82 | active: boolean; 83 | 84 | onactive: EventListener; 85 | oninactive: EventListener; 86 | onaddtrack: (event: MediaStreamTrackEvent) => any; 87 | onremovetrack: (event: MediaStreamTrackEvent) => any; 88 | 89 | clone(): MediaStream; 90 | stop(): void; 91 | 92 | getAudioTracks(): MediaStreamTrack[]; 93 | getVideoTracks(): MediaStreamTrack[]; 94 | getTracks(): MediaStreamTrack[]; 95 | 96 | getTrackById(trackId: string): MediaStreamTrack; 97 | 98 | addTrack(track: MediaStreamTrack): void; 99 | removeTrack(track: MediaStreamTrack): void; 100 | } 101 | 102 | interface MediaStreamTrackEvent extends Event { 103 | track: MediaStreamTrack; 104 | } 105 | 106 | declare enum MediaStreamTrackState { 107 | "live", 108 | "ended" 109 | } 110 | 111 | interface MediaStreamTrack extends EventTarget { 112 | id: string; 113 | kind: string; 114 | label: string; 115 | enabled: boolean; 116 | muted: boolean; 117 | remote: boolean; 118 | readyState: MediaStreamTrackState; 119 | 120 | onmute: EventListener; 121 | onunmute: EventListener; 122 | onended: EventListener; 123 | onoverconstrained: EventListener; 124 | 125 | clone(): MediaStreamTrack; 126 | 127 | stop(): void; 128 | 129 | getCapabilities(): MediaTrackCapabilities; 130 | getConstraints(): MediaTrackConstraints; 131 | getSettings(): MediaTrackSettings; 132 | applyConstraints(constraints: MediaTrackConstraints): Promise; 133 | } 134 | 135 | interface MediaTrackCapabilities { 136 | width: number | W3C.LongRange; 137 | height: number | W3C.LongRange; 138 | aspectRatio: number | W3C.DoubleRange; 139 | frameRate: number | W3C.DoubleRange; 140 | facingMode: string; 141 | volume: number | W3C.DoubleRange; 142 | sampleRate: number | W3C.LongRange; 143 | sampleSize: number | W3C.LongRange; 144 | echoCancellation: boolean[]; 145 | latency: number | W3C.DoubleRange; 146 | deviceId: string; 147 | groupId: string; 148 | } 149 | 150 | interface MediaTrackSettings { 151 | width: number; 152 | height: number; 153 | aspectRatio: number; 154 | frameRate: number; 155 | facingMode: string; 156 | volume: number; 157 | sampleRate: number; 158 | sampleSize: number; 159 | echoCancellation: boolean; 160 | latency: number; 161 | deviceId: string; 162 | groupId: string; 163 | } 164 | 165 | interface MediaStreamError { 166 | name: string; 167 | message: string; 168 | constraintName: string; 169 | } 170 | 171 | interface NavigatorGetUserMedia { 172 | (constraints: MediaStreamConstraints, 173 | successCallback: (stream: MediaStream) => void, 174 | errorCallback: (error: MediaStreamError) => void): void; 175 | } 176 | 177 | // to use with adapter.js, see: https://github.com/webrtc/adapter 178 | declare var getUserMedia: NavigatorGetUserMedia; 179 | 180 | interface Navigator { 181 | getUserMedia: NavigatorGetUserMedia; 182 | 183 | webkitGetUserMedia: NavigatorGetUserMedia; 184 | 185 | mozGetUserMedia: NavigatorGetUserMedia; 186 | 187 | msGetUserMedia: NavigatorGetUserMedia; 188 | 189 | mediaDevices: MediaDevices; 190 | } 191 | 192 | interface MediaDevices { 193 | getSupportedConstraints(): MediaTrackSupportedConstraints; 194 | 195 | getUserMedia(constraints: MediaStreamConstraints): Promise; 196 | enumerateDevices(): Promise; 197 | } 198 | 199 | interface MediaDeviceInfo { 200 | label: string; 201 | deviceId: string; 202 | kind: string; 203 | groupId: string; 204 | } -------------------------------------------------------------------------------- /typings/browser/ambient/webrtc/rtcpeerconnection/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/webrtc/RTCPeerConnection.d.ts 3 | // Type definitions for WebRTC 4 | // Project: http://dev.w3.org/2011/webrtc/ 5 | // Definitions by: Ken Smith 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | // 8 | // Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html 9 | // 10 | // For example code see: 11 | // https://code.google.com/p/webrtc/source/browse/stable/samples/js/apprtc/js/main.js 12 | // 13 | // For a generic implementation see that deals with browser differences, see: 14 | // https://code.google.com/p/webrtc/source/browse/stable/samples/js/base/adapter.js 15 | 16 | 17 | // TODO(1): Get Typescript to have string-enum types as WebRtc is full of string 18 | // enums. 19 | // https://typescript.codeplex.com/discussions/549207 20 | 21 | // TODO(2): get Typescript to have union types as WebRtc uses them. 22 | // https://typescript.codeplex.com/workitem/1364 23 | 24 | interface RTCConfiguration { 25 | iceServers: RTCIceServer[]; 26 | } 27 | declare var RTCConfiguration: { 28 | prototype: RTCConfiguration; 29 | new (): RTCConfiguration; 30 | }; 31 | 32 | interface RTCIceServer { 33 | urls: string; 34 | credential?: string; 35 | } 36 | declare var RTCIceServer: { 37 | prototype: RTCIceServer; 38 | new (): RTCIceServer; 39 | }; 40 | 41 | // moz (Firefox) specific prefixes. 42 | interface mozRTCPeerConnection extends RTCPeerConnection { 43 | } 44 | declare var mozRTCPeerConnection: { 45 | prototype: mozRTCPeerConnection; 46 | new (settings: RTCPeerConnectionConfig, 47 | constraints?:RTCMediaConstraints): mozRTCPeerConnection; 48 | }; 49 | // webkit (Chrome) specific prefixes. 50 | interface webkitRTCPeerConnection extends RTCPeerConnection { 51 | } 52 | declare var webkitRTCPeerConnection: { 53 | prototype: webkitRTCPeerConnection; 54 | new (settings: RTCPeerConnectionConfig, 55 | constraints?:RTCMediaConstraints): webkitRTCPeerConnection; 56 | }; 57 | 58 | // For Chrome, look at the code here: 59 | // https://code.google.com/p/chromium/codesearch#chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsession.cc&sq=package:chromium&dr=C&l=63 60 | interface RTCOptionalMediaConstraint { 61 | // When true, will use DTLS/SCTP data channels 62 | DtlsSrtpKeyAgreement?: boolean; 63 | // When true will use Rtp-based data channels (depreicated) 64 | RtpDataChannels?: boolean; 65 | } 66 | 67 | // ks 12/20/12 - There's more here that doesn't seem to be documented very well yet. 68 | // http://www.w3.org/TR/2013/WD-webrtc-20130910/ 69 | interface RTCMediaConstraints { 70 | mandatory?: RTCMediaOfferConstraints; 71 | optional?: RTCOptionalMediaConstraint[] 72 | } 73 | 74 | interface RTCMediaOfferConstraints { 75 | offerToReceiveAudio: boolean; 76 | offerToReceiveVideo: boolean; 77 | } 78 | 79 | interface RTCSessionDescriptionInit { 80 | type: string; // RTCSdpType; See TODO(1) 81 | sdp: string; 82 | } 83 | 84 | interface RTCSessionDescription { 85 | type?: string; // RTCSdpType; See TODO(1) 86 | sdp?: string; 87 | } 88 | declare var RTCSessionDescription: { 89 | prototype: RTCSessionDescription; 90 | new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; 91 | // TODO: Add serializer. 92 | // See: http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSdpType) 93 | }; 94 | 95 | interface webkitRTCSessionDescription extends RTCSessionDescription{ 96 | type?: string; 97 | sdp?: string; 98 | } 99 | declare var webkitRTCSessionDescription: { 100 | prototype: webkitRTCSessionDescription; 101 | new (descriptionInitDict?: RTCSessionDescriptionInit): webkitRTCSessionDescription; 102 | }; 103 | 104 | interface mozRTCSessionDescription extends RTCSessionDescription{ 105 | type?: string; 106 | sdp?: string; 107 | } 108 | declare var mozRTCSessionDescription: { 109 | prototype: mozRTCSessionDescription; 110 | new (descriptionInitDict?: RTCSessionDescriptionInit): mozRTCSessionDescription; 111 | }; 112 | 113 | 114 | 115 | interface RTCDataChannelInit { 116 | ordered ?: boolean; // messages must be sent in-order. 117 | maxPacketLifeTime ?: number; // unsigned short 118 | maxRetransmits ?: number; // unsigned short 119 | protocol ?: string; // default = '' 120 | negotiated ?: boolean; // default = false; 121 | id ?: number; // unsigned short 122 | } 123 | 124 | // TODO(1) 125 | declare enum RTCSdpType { 126 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcsdptype 127 | 'offer', 128 | 'pranswer', 129 | 'answer' 130 | } 131 | 132 | interface RTCMessageEvent { 133 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#event-datachannel-message 134 | // At present, this can be an: ArrayBuffer, a string, or a Blob. 135 | // See TODO(2) 136 | data: any; 137 | } 138 | 139 | // TODO(1) 140 | declare enum RTCDataChannelState { 141 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelState 142 | 'connecting', 143 | 'open', 144 | 'closing', 145 | 'closed' 146 | } 147 | 148 | interface RTCDataChannel extends EventTarget { 149 | label: string; 150 | reliable: boolean; 151 | readyState: string; // RTCDataChannelState; see TODO(1) 152 | bufferedAmount: number; 153 | binaryType: string; 154 | 155 | onopen: (event: Event) => void; 156 | onerror: (event: Event) => void; 157 | onclose: (event: Event) => void; 158 | onmessage: (event: RTCMessageEvent) => void; 159 | 160 | close(): void; 161 | 162 | send(data: string): void ; 163 | send(data: ArrayBuffer): void; 164 | send(data: ArrayBufferView): void; 165 | send(data: Blob): void; 166 | } 167 | declare var RTCDataChannel: { 168 | prototype: RTCDataChannel; 169 | new (): RTCDataChannel; 170 | }; 171 | 172 | interface RTCDataChannelEvent extends Event { 173 | channel: RTCDataChannel; 174 | } 175 | declare var RTCDataChannelEvent: { 176 | prototype: RTCDataChannelEvent; 177 | new (eventInitDict: RTCDataChannelEventInit): RTCDataChannelEvent; 178 | }; 179 | 180 | interface RTCIceCandidateEvent extends Event { 181 | candidate: RTCIceCandidate; 182 | } 183 | 184 | interface RTCMediaStreamEvent extends Event { 185 | stream: MediaStream; 186 | } 187 | 188 | interface EventInit { 189 | } 190 | 191 | interface RTCDataChannelEventInit extends EventInit { 192 | channel: RTCDataChannel; 193 | } 194 | 195 | interface RTCVoidCallback { 196 | (): void; 197 | } 198 | interface RTCSessionDescriptionCallback { 199 | (sdp: RTCSessionDescription): void; 200 | } 201 | interface RTCPeerConnectionErrorCallback { 202 | (errorInformation: DOMError): void; 203 | } 204 | 205 | // TODO(1) 206 | declare enum RTCIceGatheringState { 207 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcicegatheringstate-enum 208 | 'new', 209 | 'gathering', 210 | 'complete' 211 | } 212 | 213 | // TODO(1) 214 | declare enum RTCIceConnectionState { 215 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceConnectionState 216 | 'new', 217 | 'checking', 218 | 'connected', 219 | 'completed', 220 | 'failed', 221 | 'disconnected', 222 | 'closed' 223 | } 224 | 225 | // TODO(1) 226 | declare enum RTCSignalingState { 227 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSignalingState 228 | 'stable', 229 | 'have-local-offer', 230 | 'have-remote-offer', 231 | 'have-local-pranswer', 232 | 'have-remote-pranswer', 233 | 'closed' 234 | } 235 | 236 | // This is based on the current implementation of WebRtc in Chrome; the spec is 237 | // a little unclear on this. 238 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCStatsReport 239 | interface RTCStatsReport { 240 | stat(id: string): string; 241 | } 242 | 243 | interface RTCStatsCallback { 244 | (report: RTCStatsReport): void; 245 | } 246 | 247 | interface RTCPeerConnection { 248 | createOffer(successCallback: RTCSessionDescriptionCallback, 249 | failureCallback?: RTCPeerConnectionErrorCallback, 250 | constraints?: RTCMediaConstraints): void; 251 | createAnswer(successCallback: RTCSessionDescriptionCallback, 252 | failureCallback?: RTCPeerConnectionErrorCallback, 253 | constraints?: RTCMediaConstraints): void; 254 | setLocalDescription(description: RTCSessionDescription, 255 | successCallback?: RTCVoidCallback, 256 | failureCallback?: RTCPeerConnectionErrorCallback): void; 257 | localDescription: RTCSessionDescription; 258 | setRemoteDescription(description: RTCSessionDescription, 259 | successCallback?: RTCVoidCallback, 260 | failureCallback?: RTCPeerConnectionErrorCallback): void; 261 | remoteDescription: RTCSessionDescription; 262 | signalingState: string; // RTCSignalingState; see TODO(1) 263 | updateIce(configuration?: RTCConfiguration, 264 | constraints?: RTCMediaConstraints): void; 265 | addIceCandidate(candidate:RTCIceCandidate, 266 | successCallback:() => void, 267 | failureCallback:RTCPeerConnectionErrorCallback): void; 268 | iceGatheringState: string; // RTCIceGatheringState; see TODO(1) 269 | iceConnectionState: string; // RTCIceConnectionState; see TODO(1) 270 | getLocalStreams(): MediaStream[]; 271 | getRemoteStreams(): MediaStream[]; 272 | createDataChannel(label?: string, 273 | dataChannelDict?: RTCDataChannelInit): RTCDataChannel; 274 | ondatachannel: (event: Event) => void; 275 | addStream(stream: MediaStream, constraints?: RTCMediaConstraints): void; 276 | removeStream(stream: MediaStream): void; 277 | close(): void; 278 | onnegotiationneeded: (event: Event) => void; 279 | onconnecting: (event: Event) => void; 280 | onopen: (event: Event) => void; 281 | onaddstream: (event: RTCMediaStreamEvent) => void; 282 | onremovestream: (event: RTCMediaStreamEvent) => void; 283 | onstatechange: (event: Event) => void; 284 | oniceconnectionstatechange: (event: Event) => void; 285 | onicecandidate: (event: RTCIceCandidateEvent) => void; 286 | onidentityresult: (event: Event) => void; 287 | onsignalingstatechange: (event: Event) => void; 288 | getStats: (successCallback: RTCStatsCallback, 289 | failureCallback: RTCPeerConnectionErrorCallback) => void; 290 | } 291 | declare var RTCPeerConnection: { 292 | prototype: RTCPeerConnection; 293 | new (configuration: RTCConfiguration, 294 | constraints?: RTCMediaConstraints): RTCPeerConnection; 295 | }; 296 | 297 | interface RTCIceCandidate { 298 | candidate?: string; 299 | sdpMid?: string; 300 | sdpMLineIndex?: number; 301 | } 302 | declare var RTCIceCandidate: { 303 | prototype: RTCIceCandidate; 304 | new (candidateInitDict?: RTCIceCandidate): RTCIceCandidate; 305 | }; 306 | 307 | interface webkitRTCIceCandidate extends RTCIceCandidate { 308 | candidate?: string; 309 | sdpMid?: string; 310 | sdpMLineIndex?: number; 311 | } 312 | declare var webkitRTCIceCandidate: { 313 | prototype: webkitRTCIceCandidate; 314 | new (candidateInitDict?: webkitRTCIceCandidate): webkitRTCIceCandidate; 315 | }; 316 | 317 | interface mozRTCIceCandidate extends RTCIceCandidate { 318 | candidate?: string; 319 | sdpMid?: string; 320 | sdpMLineIndex?: number; 321 | } 322 | declare var mozRTCIceCandidate: { 323 | prototype: mozRTCIceCandidate; 324 | new (candidateInitDict?: mozRTCIceCandidate): mozRTCIceCandidate; 325 | }; 326 | 327 | interface RTCIceCandidateInit { 328 | candidate: string; 329 | sdpMid: string; 330 | sdpMLineIndex: number; 331 | } 332 | declare var RTCIceCandidateInit:{ 333 | prototype: RTCIceCandidateInit; 334 | new (): RTCIceCandidateInit; 335 | }; 336 | 337 | interface PeerConnectionIceEvent { 338 | peer: RTCPeerConnection; 339 | candidate: RTCIceCandidate; 340 | } 341 | declare var PeerConnectionIceEvent: { 342 | prototype: PeerConnectionIceEvent; 343 | new (): PeerConnectionIceEvent; 344 | }; 345 | 346 | interface RTCPeerConnectionConfig { 347 | iceServers: RTCIceServer[]; 348 | } 349 | declare var RTCPeerConnectionConfig: { 350 | prototype: RTCPeerConnectionConfig; 351 | new (): RTCPeerConnectionConfig; 352 | }; 353 | 354 | interface Window{ 355 | RTCPeerConnection: RTCPeerConnection; 356 | webkitRTCPeerConnection: webkitRTCPeerConnection; 357 | mozRTCPeerConnection: mozRTCPeerConnection; 358 | RTCSessionDescription: RTCSessionDescription; 359 | webkitRTCSessionDescription: webkitRTCSessionDescription; 360 | mozRTCSessionDescription: mozRTCSessionDescription; 361 | RTCIceCandidate: RTCIceCandidate; 362 | webkitRTCIceCandidate: webkitRTCIceCandidate; 363 | mozRTCIceCandidate: mozRTCIceCandidate; 364 | } -------------------------------------------------------------------------------- /typings/main.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | -------------------------------------------------------------------------------- /typings/main/ambient/es6-shim/es6-shim.d.ts: -------------------------------------------------------------------------------- 1 | // Compiled using typings@0.6.8 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/4de74cb527395c13ba20b438c3a7a419ad931f1c/es6-shim/es6-shim.d.ts 3 | // Type definitions for es6-shim v0.31.2 4 | // Project: https://github.com/paulmillr/es6-shim 5 | // Definitions by: Ron Buckton 6 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 7 | 8 | declare type PropertyKey = string | number | symbol; 9 | 10 | interface IteratorResult { 11 | done: boolean; 12 | value?: T; 13 | } 14 | 15 | interface IterableShim { 16 | /** 17 | * Shim for an ES6 iterable. Not intended for direct use by user code. 18 | */ 19 | "_es6-shim iterator_"(): Iterator; 20 | } 21 | 22 | interface Iterator { 23 | next(value?: any): IteratorResult; 24 | return?(value?: any): IteratorResult; 25 | throw?(e?: any): IteratorResult; 26 | } 27 | 28 | interface IterableIteratorShim extends IterableShim, Iterator { 29 | /** 30 | * Shim for an ES6 iterable iterator. Not intended for direct use by user code. 31 | */ 32 | "_es6-shim iterator_"(): IterableIteratorShim; 33 | } 34 | 35 | interface StringConstructor { 36 | /** 37 | * Return the String value whose elements are, in order, the elements in the List elements. 38 | * If length is 0, the empty string is returned. 39 | */ 40 | fromCodePoint(...codePoints: number[]): string; 41 | 42 | /** 43 | * String.raw is intended for use as a tag function of a Tagged Template String. When called 44 | * as such the first argument will be a well formed template call site object and the rest 45 | * parameter will contain the substitution values. 46 | * @param template A well-formed template string call site representation. 47 | * @param substitutions A set of substitution values. 48 | */ 49 | raw(template: TemplateStringsArray, ...substitutions: any[]): string; 50 | } 51 | 52 | interface String { 53 | /** 54 | * Returns a nonnegative integer Number less than 1114112 (0x110000) that is the code point 55 | * value of the UTF-16 encoded code point starting at the string element at position pos in 56 | * the String resulting from converting this object to a String. 57 | * If there is no element at that position, the result is undefined. 58 | * If a valid UTF-16 surrogate pair does not begin at pos, the result is the code unit at pos. 59 | */ 60 | codePointAt(pos: number): number; 61 | 62 | /** 63 | * Returns true if searchString appears as a substring of the result of converting this 64 | * object to a String, at one or more positions that are 65 | * greater than or equal to position; otherwise, returns false. 66 | * @param searchString search string 67 | * @param position If position is undefined, 0 is assumed, so as to search all of the String. 68 | */ 69 | includes(searchString: string, position?: number): boolean; 70 | 71 | /** 72 | * Returns true if the sequence of elements of searchString converted to a String is the 73 | * same as the corresponding elements of this object (converted to a String) starting at 74 | * endPosition – length(this). Otherwise returns false. 75 | */ 76 | endsWith(searchString: string, endPosition?: number): boolean; 77 | 78 | /** 79 | * Returns a String value that is made from count copies appended together. If count is 0, 80 | * T is the empty String is returned. 81 | * @param count number of copies to append 82 | */ 83 | repeat(count: number): string; 84 | 85 | /** 86 | * Returns true if the sequence of elements of searchString converted to a String is the 87 | * same as the corresponding elements of this object (converted to a String) starting at 88 | * position. Otherwise returns false. 89 | */ 90 | startsWith(searchString: string, position?: number): boolean; 91 | 92 | /** 93 | * Returns an HTML anchor element and sets the name attribute to the text value 94 | * @param name 95 | */ 96 | anchor(name: string): string; 97 | 98 | /** Returns a HTML element */ 99 | big(): string; 100 | 101 | /** Returns a HTML element */ 102 | blink(): string; 103 | 104 | /** Returns a HTML element */ 105 | bold(): string; 106 | 107 | /** Returns a HTML element */ 108 | fixed(): string 109 | 110 | /** Returns a HTML element and sets the color attribute value */ 111 | fontcolor(color: string): string 112 | 113 | /** Returns a HTML element and sets the size attribute value */ 114 | fontsize(size: number): string; 115 | 116 | /** Returns a HTML element and sets the size attribute value */ 117 | fontsize(size: string): string; 118 | 119 | /** Returns an HTML element */ 120 | italics(): string; 121 | 122 | /** Returns an HTML element and sets the href attribute value */ 123 | link(url: string): string; 124 | 125 | /** Returns a HTML element */ 126 | small(): string; 127 | 128 | /** Returns a HTML element */ 129 | strike(): string; 130 | 131 | /** Returns a HTML element */ 132 | sub(): string; 133 | 134 | /** Returns a HTML element */ 135 | sup(): string; 136 | 137 | /** 138 | * Shim for an ES6 iterable. Not intended for direct use by user code. 139 | */ 140 | "_es6-shim iterator_"(): IterableIteratorShim; 141 | } 142 | 143 | interface ArrayConstructor { 144 | /** 145 | * Creates an array from an array-like object. 146 | * @param arrayLike An array-like object to convert to an array. 147 | * @param mapfn A mapping function to call on every element of the array. 148 | * @param thisArg Value of 'this' used to invoke the mapfn. 149 | */ 150 | from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 151 | 152 | /** 153 | * Creates an array from an iterable object. 154 | * @param iterable An iterable object to convert to an array. 155 | * @param mapfn A mapping function to call on every element of the array. 156 | * @param thisArg Value of 'this' used to invoke the mapfn. 157 | */ 158 | from(iterable: IterableShim, mapfn: (v: T, k: number) => U, thisArg?: any): Array; 159 | 160 | /** 161 | * Creates an array from an array-like object. 162 | * @param arrayLike An array-like object to convert to an array. 163 | */ 164 | from(arrayLike: ArrayLike): Array; 165 | 166 | /** 167 | * Creates an array from an iterable object. 168 | * @param iterable An iterable object to convert to an array. 169 | */ 170 | from(iterable: IterableShim): Array; 171 | 172 | /** 173 | * Returns a new array from a set of elements. 174 | * @param items A set of elements to include in the new array object. 175 | */ 176 | of(...items: T[]): Array; 177 | } 178 | 179 | interface Array { 180 | /** 181 | * Returns the value of the first element in the array where predicate is true, and undefined 182 | * otherwise. 183 | * @param predicate find calls predicate once for each element of the array, in ascending 184 | * order, until it finds one where predicate returns true. If such an element is found, find 185 | * immediately returns that element value. Otherwise, find returns undefined. 186 | * @param thisArg If provided, it will be used as the this value for each invocation of 187 | * predicate. If it is not provided, undefined is used instead. 188 | */ 189 | find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T; 190 | 191 | /** 192 | * Returns the index of the first element in the array where predicate is true, and undefined 193 | * otherwise. 194 | * @param predicate find calls predicate once for each element of the array, in ascending 195 | * order, until it finds one where predicate returns true. If such an element is found, find 196 | * immediately returns that element value. Otherwise, find returns undefined. 197 | * @param thisArg If provided, it will be used as the this value for each invocation of 198 | * predicate. If it is not provided, undefined is used instead. 199 | */ 200 | findIndex(predicate: (value: T) => boolean, thisArg?: any): number; 201 | 202 | /** 203 | * Returns the this object after filling the section identified by start and end with value 204 | * @param value value to fill array section with 205 | * @param start index to start filling the array at. If start is negative, it is treated as 206 | * length+start where length is the length of the array. 207 | * @param end index to stop filling the array at. If end is negative, it is treated as 208 | * length+end. 209 | */ 210 | fill(value: T, start?: number, end?: number): T[]; 211 | 212 | /** 213 | * Returns the this object after copying a section of the array identified by start and end 214 | * to the same array starting at position target 215 | * @param target If target is negative, it is treated as length+target where length is the 216 | * length of the array. 217 | * @param start If start is negative, it is treated as length+start. If end is negative, it 218 | * is treated as length+end. 219 | * @param end If not specified, length of the this object is used as its default value. 220 | */ 221 | copyWithin(target: number, start: number, end?: number): T[]; 222 | 223 | /** 224 | * Returns an array of key, value pairs for every entry in the array 225 | */ 226 | entries(): IterableIteratorShim<[number, T]>; 227 | 228 | /** 229 | * Returns an list of keys in the array 230 | */ 231 | keys(): IterableIteratorShim; 232 | 233 | /** 234 | * Returns an list of values in the array 235 | */ 236 | values(): IterableIteratorShim; 237 | 238 | /** 239 | * Shim for an ES6 iterable. Not intended for direct use by user code. 240 | */ 241 | "_es6-shim iterator_"(): IterableIteratorShim; 242 | } 243 | 244 | interface NumberConstructor { 245 | /** 246 | * The value of Number.EPSILON is the difference between 1 and the smallest value greater than 1 247 | * that is representable as a Number value, which is approximately: 248 | * 2.2204460492503130808472633361816 x 10‍−‍16. 249 | */ 250 | EPSILON: number; 251 | 252 | /** 253 | * Returns true if passed value is finite. 254 | * Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a 255 | * number. Only finite values of the type number, result in true. 256 | * @param number A numeric value. 257 | */ 258 | isFinite(number: number): boolean; 259 | 260 | /** 261 | * Returns true if the value passed is an integer, false otherwise. 262 | * @param number A numeric value. 263 | */ 264 | isInteger(number: number): boolean; 265 | 266 | /** 267 | * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a 268 | * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter 269 | * to a number. Only values of the type number, that are also NaN, result in true. 270 | * @param number A numeric value. 271 | */ 272 | isNaN(number: number): boolean; 273 | 274 | /** 275 | * Returns true if the value passed is a safe integer. 276 | * @param number A numeric value. 277 | */ 278 | isSafeInteger(number: number): boolean; 279 | 280 | /** 281 | * The value of the largest integer n such that n and n + 1 are both exactly representable as 282 | * a Number value. 283 | * The value of Number.MIN_SAFE_INTEGER is 9007199254740991 2^53 − 1. 284 | */ 285 | MAX_SAFE_INTEGER: number; 286 | 287 | /** 288 | * The value of the smallest integer n such that n and n − 1 are both exactly representable as 289 | * a Number value. 290 | * The value of Number.MIN_SAFE_INTEGER is −9007199254740991 (−(2^53 − 1)). 291 | */ 292 | MIN_SAFE_INTEGER: number; 293 | 294 | /** 295 | * Converts a string to a floating-point number. 296 | * @param string A string that contains a floating-point number. 297 | */ 298 | parseFloat(string: string): number; 299 | 300 | /** 301 | * Converts A string to an integer. 302 | * @param s A string to convert into a number. 303 | * @param radix A value between 2 and 36 that specifies the base of the number in numString. 304 | * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. 305 | * All other strings are considered decimal. 306 | */ 307 | parseInt(string: string, radix?: number): number; 308 | } 309 | 310 | interface ObjectConstructor { 311 | /** 312 | * Copy the values of all of the enumerable own properties from one or more source objects to a 313 | * target object. Returns the target object. 314 | * @param target The target object to copy to. 315 | * @param sources One or more source objects to copy properties from. 316 | */ 317 | assign(target: any, ...sources: any[]): any; 318 | 319 | /** 320 | * Returns true if the values are the same value, false otherwise. 321 | * @param value1 The first value. 322 | * @param value2 The second value. 323 | */ 324 | is(value1: any, value2: any): boolean; 325 | 326 | /** 327 | * Sets the prototype of a specified object o to object proto or null. Returns the object o. 328 | * @param o The object to change its prototype. 329 | * @param proto The value of the new prototype or null. 330 | * @remarks Requires `__proto__` support. 331 | */ 332 | setPrototypeOf(o: any, proto: any): any; 333 | } 334 | 335 | interface RegExp { 336 | /** 337 | * Returns a string indicating the flags of the regular expression in question. This field is read-only. 338 | * The characters in this string are sequenced and concatenated in the following order: 339 | * 340 | * - "g" for global 341 | * - "i" for ignoreCase 342 | * - "m" for multiline 343 | * - "u" for unicode 344 | * - "y" for sticky 345 | * 346 | * If no flags are set, the value is the empty string. 347 | */ 348 | flags: string; 349 | } 350 | 351 | interface Math { 352 | /** 353 | * Returns the number of leading zero bits in the 32-bit binary representation of a number. 354 | * @param x A numeric expression. 355 | */ 356 | clz32(x: number): number; 357 | 358 | /** 359 | * Returns the result of 32-bit multiplication of two numbers. 360 | * @param x First number 361 | * @param y Second number 362 | */ 363 | imul(x: number, y: number): number; 364 | 365 | /** 366 | * Returns the sign of the x, indicating whether x is positive, negative or zero. 367 | * @param x The numeric expression to test 368 | */ 369 | sign(x: number): number; 370 | 371 | /** 372 | * Returns the base 10 logarithm of a number. 373 | * @param x A numeric expression. 374 | */ 375 | log10(x: number): number; 376 | 377 | /** 378 | * Returns the base 2 logarithm of a number. 379 | * @param x A numeric expression. 380 | */ 381 | log2(x: number): number; 382 | 383 | /** 384 | * Returns the natural logarithm of 1 + x. 385 | * @param x A numeric expression. 386 | */ 387 | log1p(x: number): number; 388 | 389 | /** 390 | * Returns the result of (e^x - 1) of x (e raised to the power of x, where e is the base of 391 | * the natural logarithms). 392 | * @param x A numeric expression. 393 | */ 394 | expm1(x: number): number; 395 | 396 | /** 397 | * Returns the hyperbolic cosine of a number. 398 | * @param x A numeric expression that contains an angle measured in radians. 399 | */ 400 | cosh(x: number): number; 401 | 402 | /** 403 | * Returns the hyperbolic sine of a number. 404 | * @param x A numeric expression that contains an angle measured in radians. 405 | */ 406 | sinh(x: number): number; 407 | 408 | /** 409 | * Returns the hyperbolic tangent of a number. 410 | * @param x A numeric expression that contains an angle measured in radians. 411 | */ 412 | tanh(x: number): number; 413 | 414 | /** 415 | * Returns the inverse hyperbolic cosine of a number. 416 | * @param x A numeric expression that contains an angle measured in radians. 417 | */ 418 | acosh(x: number): number; 419 | 420 | /** 421 | * Returns the inverse hyperbolic sine of a number. 422 | * @param x A numeric expression that contains an angle measured in radians. 423 | */ 424 | asinh(x: number): number; 425 | 426 | /** 427 | * Returns the inverse hyperbolic tangent of a number. 428 | * @param x A numeric expression that contains an angle measured in radians. 429 | */ 430 | atanh(x: number): number; 431 | 432 | /** 433 | * Returns the square root of the sum of squares of its arguments. 434 | * @param values Values to compute the square root for. 435 | * If no arguments are passed, the result is +0. 436 | * If there is only one argument, the result is the absolute value. 437 | * If any argument is +Infinity or -Infinity, the result is +Infinity. 438 | * If any argument is NaN, the result is NaN. 439 | * If all arguments are either +0 or −0, the result is +0. 440 | */ 441 | hypot(...values: number[]): number; 442 | 443 | /** 444 | * Returns the integral part of the a numeric expression, x, removing any fractional digits. 445 | * If x is already an integer, the result is x. 446 | * @param x A numeric expression. 447 | */ 448 | trunc(x: number): number; 449 | 450 | /** 451 | * Returns the nearest single precision float representation of a number. 452 | * @param x A numeric expression. 453 | */ 454 | fround(x: number): number; 455 | 456 | /** 457 | * Returns an implementation-dependent approximation to the cube root of number. 458 | * @param x A numeric expression. 459 | */ 460 | cbrt(x: number): number; 461 | } 462 | 463 | interface PromiseLike { 464 | /** 465 | * Attaches callbacks for the resolution and/or rejection of the Promise. 466 | * @param onfulfilled The callback to execute when the Promise is resolved. 467 | * @param onrejected The callback to execute when the Promise is rejected. 468 | * @returns A Promise for the completion of which ever callback is executed. 469 | */ 470 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; 471 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; 472 | } 473 | 474 | /** 475 | * Represents the completion of an asynchronous operation 476 | */ 477 | interface Promise { 478 | /** 479 | * Attaches callbacks for the resolution and/or rejection of the Promise. 480 | * @param onfulfilled The callback to execute when the Promise is resolved. 481 | * @param onrejected The callback to execute when the Promise is rejected. 482 | * @returns A Promise for the completion of which ever callback is executed. 483 | */ 484 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): Promise; 485 | then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): Promise; 486 | 487 | /** 488 | * Attaches a callback for only the rejection of the Promise. 489 | * @param onrejected The callback to execute when the Promise is rejected. 490 | * @returns A Promise for the completion of the callback. 491 | */ 492 | catch(onrejected?: (reason: any) => T | PromiseLike): Promise; 493 | catch(onrejected?: (reason: any) => void): Promise; 494 | } 495 | 496 | interface PromiseConstructor { 497 | /** 498 | * A reference to the prototype. 499 | */ 500 | prototype: Promise; 501 | 502 | /** 503 | * Creates a new Promise. 504 | * @param executor A callback used to initialize the promise. This callback is passed two arguments: 505 | * a resolve callback used resolve the promise with a value or the result of another promise, 506 | * and a reject callback used to reject the promise with a provided reason or error. 507 | */ 508 | new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; 509 | 510 | /** 511 | * Creates a Promise that is resolved with an array of results when all of the provided Promises 512 | * resolve, or rejected when any Promise is rejected. 513 | * @param values An array of Promises. 514 | * @returns A new Promise. 515 | */ 516 | all(values: IterableShim>): Promise; 517 | 518 | /** 519 | * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved 520 | * or rejected. 521 | * @param values An array of Promises. 522 | * @returns A new Promise. 523 | */ 524 | race(values: IterableShim>): Promise; 525 | 526 | /** 527 | * Creates a new rejected promise for the provided reason. 528 | * @param reason The reason the promise was rejected. 529 | * @returns A new rejected Promise. 530 | */ 531 | reject(reason: any): Promise; 532 | 533 | /** 534 | * Creates a new rejected promise for the provided reason. 535 | * @param reason The reason the promise was rejected. 536 | * @returns A new rejected Promise. 537 | */ 538 | reject(reason: any): Promise; 539 | 540 | /** 541 | * Creates a new resolved promise for the provided value. 542 | * @param value A promise. 543 | * @returns A promise whose internal state matches the provided promise. 544 | */ 545 | resolve(value: T | PromiseLike): Promise; 546 | 547 | /** 548 | * Creates a new resolved promise . 549 | * @returns A resolved promise. 550 | */ 551 | resolve(): Promise; 552 | } 553 | 554 | declare var Promise: PromiseConstructor; 555 | 556 | interface Map { 557 | clear(): void; 558 | delete(key: K): boolean; 559 | forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; 560 | get(key: K): V; 561 | has(key: K): boolean; 562 | set(key: K, value?: V): Map; 563 | size: number; 564 | entries(): IterableIteratorShim<[K, V]>; 565 | keys(): IterableIteratorShim; 566 | values(): IterableIteratorShim; 567 | } 568 | 569 | interface MapConstructor { 570 | new (): Map; 571 | new (iterable: IterableShim<[K, V]>): Map; 572 | prototype: Map; 573 | } 574 | 575 | declare var Map: MapConstructor; 576 | 577 | interface Set { 578 | add(value: T): Set; 579 | clear(): void; 580 | delete(value: T): boolean; 581 | forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; 582 | has(value: T): boolean; 583 | size: number; 584 | entries(): IterableIteratorShim<[T, T]>; 585 | keys(): IterableIteratorShim; 586 | values(): IterableIteratorShim; 587 | } 588 | 589 | interface SetConstructor { 590 | new (): Set; 591 | new (iterable: IterableShim): Set; 592 | prototype: Set; 593 | } 594 | 595 | declare var Set: SetConstructor; 596 | 597 | interface WeakMap { 598 | delete(key: K): boolean; 599 | get(key: K): V; 600 | has(key: K): boolean; 601 | set(key: K, value?: V): WeakMap; 602 | } 603 | 604 | interface WeakMapConstructor { 605 | new (): WeakMap; 606 | new (iterable: IterableShim<[K, V]>): WeakMap; 607 | prototype: WeakMap; 608 | } 609 | 610 | declare var WeakMap: WeakMapConstructor; 611 | 612 | interface WeakSet { 613 | add(value: T): WeakSet; 614 | delete(value: T): boolean; 615 | has(value: T): boolean; 616 | } 617 | 618 | interface WeakSetConstructor { 619 | new (): WeakSet; 620 | new (iterable: IterableShim): WeakSet; 621 | prototype: WeakSet; 622 | } 623 | 624 | declare var WeakSet: WeakSetConstructor; 625 | 626 | declare module Reflect { 627 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 628 | function construct(target: Function, argumentsList: ArrayLike): any; 629 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 630 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 631 | function enumerate(target: any): IterableIteratorShim; 632 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 633 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 634 | function getPrototypeOf(target: any): any; 635 | function has(target: any, propertyKey: PropertyKey): boolean; 636 | function isExtensible(target: any): boolean; 637 | function ownKeys(target: any): Array; 638 | function preventExtensions(target: any): boolean; 639 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 640 | function setPrototypeOf(target: any, proto: any): boolean; 641 | } 642 | 643 | declare module "es6-shim" { 644 | var String: StringConstructor; 645 | var Array: ArrayConstructor; 646 | var Number: NumberConstructor; 647 | var Math: Math; 648 | var Object: ObjectConstructor; 649 | var Map: MapConstructor; 650 | var Set: SetConstructor; 651 | var WeakMap: WeakMapConstructor; 652 | var WeakSet: WeakSetConstructor; 653 | var Promise: PromiseConstructor; 654 | module Reflect { 655 | function apply(target: Function, thisArgument: any, argumentsList: ArrayLike): any; 656 | function construct(target: Function, argumentsList: ArrayLike): any; 657 | function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; 658 | function deleteProperty(target: any, propertyKey: PropertyKey): boolean; 659 | function enumerate(target: any): Iterator; 660 | function get(target: any, propertyKey: PropertyKey, receiver?: any): any; 661 | function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor; 662 | function getPrototypeOf(target: any): any; 663 | function has(target: any, propertyKey: PropertyKey): boolean; 664 | function isExtensible(target: any): boolean; 665 | function ownKeys(target: any): Array; 666 | function preventExtensions(target: any): boolean; 667 | function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean; 668 | function setPrototypeOf(target: any, proto: any): boolean; 669 | } 670 | } -------------------------------------------------------------------------------- /typings/main/ambient/firebase/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/firebase/firebase.d.ts 3 | // Type definitions for Firebase API 2.4.1 4 | // Project: https://www.firebase.com/docs/javascript/firebase 5 | // Definitions by: Vincent Botone , Shin1 Kashimura , Sebastien Dubois , Szymon Stasik 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | 8 | interface FirebaseAuthResult { 9 | auth: any; 10 | expires: number; 11 | } 12 | 13 | interface FirebaseDataSnapshot { 14 | /** 15 | * Returns true if this DataSnapshot contains any data. 16 | * It is slightly more efficient than using snapshot.val() !== null. 17 | */ 18 | exists(): boolean; 19 | /** 20 | * Gets the JavaScript object representation of the DataSnapshot. 21 | */ 22 | val(): any; 23 | /** 24 | * Gets a DataSnapshot for the location at the specified relative path. 25 | */ 26 | child(childPath: string): FirebaseDataSnapshot; 27 | /** 28 | * Enumerates through the DataSnapshot’s children (in the default order). 29 | */ 30 | forEach(childAction: (childSnapshot: FirebaseDataSnapshot) => void): boolean; 31 | forEach(childAction: (childSnapshot: FirebaseDataSnapshot) => boolean): boolean; 32 | /** 33 | * Returns true if the specified child exists. 34 | */ 35 | hasChild(childPath: string): boolean; 36 | /** 37 | * Returns true if the DataSnapshot has any children. 38 | */ 39 | hasChildren(): boolean; 40 | /** 41 | * Gets the key name of the location that generated this DataSnapshot. 42 | */ 43 | key(): string; 44 | /** 45 | * @deprecated Use key() instead. 46 | * Gets the key name of the location that generated this DataSnapshot. 47 | */ 48 | name(): string; 49 | /** 50 | * Gets the number of children for this DataSnapshot. 51 | */ 52 | numChildren(): number; 53 | /** 54 | * Gets the Firebase reference for the location that generated this DataSnapshot. 55 | */ 56 | ref(): Firebase; 57 | /** 58 | * Gets the priority of the data in this DataSnapshot. 59 | * @returns {string, number, null} The priority, or null if no priority was set. 60 | */ 61 | getPriority(): any; // string or number 62 | /** 63 | * Exports the entire contents of the DataSnapshot as a JavaScript object. 64 | */ 65 | exportVal(): Object; 66 | } 67 | 68 | interface FirebaseOnDisconnect { 69 | /** 70 | * Ensures the data at this location is set to the specified value when the client is disconnected 71 | * (due to closing the browser, navigating to a new page, or network issues). 72 | */ 73 | set(value: any, onComplete: (error: any) => void): void; 74 | set(value: any): Promise; 75 | /** 76 | * Ensures the data at this location is set to the specified value and priority when the client is disconnected 77 | * (due to closing the browser, navigating to a new page, or network issues). 78 | */ 79 | setWithPriority(value: any, priority: string|number, onComplete: (error: any) => void): void; 80 | setWithPriority(value: any, priority: string|number): Promise; 81 | /** 82 | * Writes the enumerated children at this Firebase location when the client is disconnected 83 | * (due to closing the browser, navigating to a new page, or network issues). 84 | */ 85 | update(value: Object, onComplete: (error: any) => void): void; 86 | update(value: Object): Promise; 87 | /** 88 | * Ensures the data at this location is deleted when the client is disconnected 89 | * (due to closing the browser, navigating to a new page, or network issues). 90 | */ 91 | remove(onComplete: (error: any) => void): void; 92 | remove(): Promise; 93 | /** 94 | * Cancels all previously queued onDisconnect() set or update events for this location and all children. 95 | */ 96 | cancel(onComplete: (error: any) => void): void; 97 | cancel(): Promise; 98 | } 99 | 100 | interface FirebaseQuery { 101 | /** 102 | * Listens for data changes at a particular location. 103 | */ 104 | on(eventType: string, callback: (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: (error: any) => void, context?: Object): (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void; 105 | /** 106 | * Detaches a callback previously attached with on(). 107 | */ 108 | off(eventType?: string, callback?: (dataSnapshot: FirebaseDataSnapshot, prevChildName?: string) => void, context?: Object): void; 109 | /** 110 | * Listens for exactly one event of the specified event type, and then stops listening. 111 | */ 112 | once(eventType: string, successCallback: (dataSnapshot: FirebaseDataSnapshot) => void, context?: Object): void; 113 | once(eventType: string, successCallback: (dataSnapshot: FirebaseDataSnapshot) => void, failureCallback?: (error: any) => void, context?: Object): void; 114 | once(eventType: string): Promise 115 | /** 116 | * Generates a new Query object ordered by the specified child key. 117 | */ 118 | orderByChild(key: string): FirebaseQuery; 119 | /** 120 | * Generates a new Query object ordered by key name. 121 | */ 122 | orderByKey(): FirebaseQuery; 123 | /** 124 | * Generates a new Query object ordered by child values. 125 | */ 126 | orderByValue(): FirebaseQuery; 127 | /** 128 | * Generates a new Query object ordered by priority. 129 | */ 130 | orderByPriority(): FirebaseQuery; 131 | /** 132 | * @deprecated Use limitToFirst() and limitToLast() instead. 133 | * Generates a new Query object limited to the specified number of children. 134 | */ 135 | limit(limit: number): FirebaseQuery; 136 | /** 137 | * Creates a Query with the specified starting point. 138 | * The generated Query includes children which match the specified starting point. 139 | */ 140 | startAt(value: string, key?: string): FirebaseQuery; 141 | startAt(value: number, key?: string): FirebaseQuery; 142 | /** 143 | * Creates a Query with the specified ending point. 144 | * The generated Query includes children which match the specified ending point. 145 | */ 146 | endAt(value: string, key?: string): FirebaseQuery; 147 | endAt(value: number, key?: string): FirebaseQuery; 148 | /** 149 | * Creates a Query which includes children which match the specified value. 150 | */ 151 | equalTo(value: string|number|boolean, key?: string): FirebaseQuery; 152 | /** 153 | * Generates a new Query object limited to the first certain number of children. 154 | */ 155 | limitToFirst(limit: number): FirebaseQuery; 156 | /** 157 | * Generates a new Query object limited to the last certain number of children. 158 | */ 159 | limitToLast(limit: number): FirebaseQuery; 160 | /** 161 | * Gets a Firebase reference to the Query's location. 162 | */ 163 | ref(): Firebase; 164 | } 165 | 166 | interface Firebase extends FirebaseQuery { 167 | /** 168 | * @deprecated Use authWithCustomToken() instead. 169 | * Authenticates a Firebase client using the provided authentication token or Firebase Secret. 170 | */ 171 | auth(authToken: string, onComplete: (error: any, result: FirebaseAuthResult) => void, onCancel?:(error: any) => void): void; 172 | auth(authToken: string): Promise; 173 | /** 174 | * Authenticates a Firebase client using an authentication token or Firebase Secret. 175 | */ 176 | authWithCustomToken(autoToken: string, onComplete: (error: any, authData: FirebaseAuthData) => void, options?:Object): void; 177 | authWithCustomToken(autoToken: string, options?:Object): Promise; 178 | /** 179 | * Authenticates a Firebase client using a new, temporary guest account. 180 | */ 181 | authAnonymously(onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void; 182 | authAnonymously(options?: Object): Promise; 183 | /** 184 | * Authenticates a Firebase client using an email / password combination. 185 | */ 186 | authWithPassword(credentials: FirebaseCredentials, onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void; 187 | authWithPassword(credentials: FirebaseCredentials, options?: Object): Promise; 188 | /** 189 | * Authenticates a Firebase client using a popup-based OAuth flow. 190 | */ 191 | authWithOAuthPopup(provider: string, onComplete:(error: any, authData: FirebaseAuthData) => void, options?: Object): void; 192 | authWithOAuthPopup(provider: string, options?: Object): Promise; 193 | /** 194 | * Authenticates a Firebase client using a redirect-based OAuth flow. 195 | */ 196 | authWithOAuthRedirect(provider: string, onComplete: (error: any) => void, options?: Object): void; 197 | authWithOAuthRedirect(provider: string, options?: Object): Promise; 198 | /** 199 | * Authenticates a Firebase client using OAuth access tokens or credentials. 200 | */ 201 | authWithOAuthToken(provider: string, credentials: string|Object, onComplete: (error: any, authData: FirebaseAuthData) => void, options?: Object): void; 202 | authWithOAuthToken(provider: string, credentials: string|Object, options?: Object): Promise; 203 | /** 204 | * Synchronously access the current authentication state of the client. 205 | */ 206 | getAuth(): FirebaseAuthData; 207 | /** 208 | * Listen for changes to the client's authentication state. 209 | */ 210 | onAuth(onComplete: (authData: FirebaseAuthData) => void, context?: Object): void; 211 | /** 212 | * Detaches a callback previously attached with onAuth(). 213 | */ 214 | offAuth(onComplete: (authData: FirebaseAuthData) => void, context?: Object): void; 215 | /** 216 | * Unauthenticates a Firebase client. 217 | */ 218 | unauth(): void; 219 | /** 220 | * Gets a Firebase reference for the location at the specified relative path. 221 | */ 222 | child(childPath: string): Firebase; 223 | /** 224 | * Gets a Firebase reference to the parent location. 225 | */ 226 | parent(): Firebase; 227 | /** 228 | * Gets a Firebase reference to the root of the Firebase. 229 | */ 230 | root(): Firebase; 231 | /** 232 | * Returns the last token in a Firebase location. 233 | */ 234 | key(): string; 235 | /** 236 | * @deprecated Use key() instead. 237 | * Returns the last token in a Firebase location. 238 | */ 239 | name(): string; 240 | /** 241 | * Gets the absolute URL corresponding to this Firebase reference's location. 242 | */ 243 | toString(): string; 244 | /** 245 | * Writes data to this Firebase location. 246 | */ 247 | set(value: any, onComplete: (error: any) => void): void; 248 | set(value: any): Promise; 249 | /** 250 | * Writes the enumerated children to this Firebase location. 251 | */ 252 | update(value: Object, onComplete: (error: any) => void): void; 253 | update(value: Object): Promise; 254 | /** 255 | * Removes the data at this Firebase location. 256 | */ 257 | remove(onComplete: (error: any) => void): void; 258 | remove(): Promise; 259 | /** 260 | * Generates a new child location using a unique name and returns a Firebase reference to it. 261 | * @returns {Firebase} A Firebase reference for the generated location. 262 | */ 263 | push(value?: any, onComplete?: (error: any) => void): FirebaseWithPromise; 264 | /** 265 | * Writes data to this Firebase location. Like set() but also specifies the priority for that data. 266 | */ 267 | setWithPriority(value: any, priority: string|number, onComplete: (error: any) => void): void; 268 | setWithPriority(value: any, priority: string|number): Promise; 269 | /** 270 | * Sets a priority for the data at this Firebase location. 271 | */ 272 | setPriority(priority: string|number, onComplete: (error: any) => void): void; 273 | setPriority(priority: string|number): Promise; 274 | /** 275 | * Atomically modifies the data at this location. 276 | */ 277 | transaction(updateFunction: (currentData: any)=> any, onComplete?: (error: any, committed: boolean, snapshot: FirebaseDataSnapshot) => void, applyLocally?: boolean): void; 278 | /** 279 | * Creates a new user account using an email / password combination. 280 | */ 281 | createUser(credentials: FirebaseCredentials, onComplete: (error: any, userData: any) => void): void; 282 | /** 283 | * Updates the email associated with an email / password user account. 284 | */ 285 | changeEmail(credentials: FirebaseChangeEmailCredentials, onComplete: (error: any) => void): void; 286 | /** 287 | * Change the password of an existing user using an email / password combination. 288 | */ 289 | changePassword(credentials: FirebaseChangePasswordCredentials, onComplete: (error: any) => void): void; 290 | /** 291 | * Removes an existing user account using an email / password combination. 292 | */ 293 | removeUser(credentials: FirebaseCredentials, onComplete: (error: any) => void): void; 294 | /** 295 | * Sends a password-reset email to the owner of the account, containing a token that may be used to authenticate and change the user password. 296 | */ 297 | resetPassword(credentials: FirebaseResetPasswordCredentials, onComplete: (error: any) => void): void; 298 | onDisconnect(): FirebaseOnDisconnect; 299 | } 300 | 301 | interface FirebaseWithPromise extends Firebase, Promise {} 302 | 303 | interface FirebaseStatic { 304 | /** 305 | * Constructs a new Firebase reference from a full Firebase URL. 306 | */ 307 | new (firebaseURL: string): Firebase; 308 | /** 309 | * Manually disconnects the Firebase client from the server and disables automatic reconnection. 310 | */ 311 | goOffline(): void; 312 | /** 313 | * Manually reestablishes a connection to the Firebase server and enables automatic reconnection. 314 | */ 315 | goOnline(): void; 316 | 317 | ServerValue: { 318 | /** 319 | * A placeholder value for auto-populating the current timestamp 320 | * (time since the Unix epoch, in milliseconds) by the Firebase servers. 321 | */ 322 | TIMESTAMP: any; 323 | }; 324 | } 325 | declare var Firebase: FirebaseStatic; 326 | 327 | declare module 'firebase' { 328 | export = Firebase; 329 | } 330 | 331 | // Reference: https://www.firebase.com/docs/web/api/firebase/getauth.html 332 | interface FirebaseAuthData { 333 | uid: string; 334 | provider: string; 335 | token: string; 336 | expires: number; 337 | auth: Object; 338 | google?: FirebaseAuthDataGoogle; 339 | } 340 | 341 | interface FirebaseAuthDataGoogle { 342 | accessToken: string; 343 | cachedUserProfile: FirebaseAuthDataGoogleCachedUserProfile; 344 | displayName: string; 345 | email?: string; 346 | id: string; 347 | profileImageURL: string; 348 | } 349 | 350 | interface FirebaseAuthDataGoogleCachedUserProfile { 351 | "family name"?: string; 352 | gender?: string; 353 | "given name"?: string; 354 | id?: string; 355 | link?: string; 356 | locale?: string; 357 | name?: string; 358 | picture?: string; 359 | } 360 | 361 | interface FirebaseCredentials { 362 | email: string; 363 | password: string; 364 | } 365 | 366 | interface FirebaseChangePasswordCredentials { 367 | email: string; 368 | oldPassword: string; 369 | newPassword: string; 370 | } 371 | 372 | interface FirebaseChangeEmailCredentials { 373 | oldEmail: string; 374 | newEmail: string; 375 | password: string; 376 | } 377 | 378 | interface FirebaseResetPasswordCredentials { 379 | email: string; 380 | } -------------------------------------------------------------------------------- /typings/main/ambient/peerjs/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/peerjs/peerjs.d.ts 3 | // Type definitions for PeerJS 4 | // Project: http://peerjs.com/ 5 | // Definitions by: Toshiya Nakakura 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | 8 | 9 | 10 | declare namespace PeerJs{ 11 | interface PeerJSOption{ 12 | key?: string; 13 | host?: string; 14 | port?: number; 15 | path?: string; 16 | secure?: boolean; 17 | config?: RTCPeerConnectionConfig; 18 | debug?: number; 19 | } 20 | 21 | interface PeerConnectOption{ 22 | label?: string; 23 | metadata?: any; 24 | serialization?: string; 25 | reliable?: boolean; 26 | 27 | } 28 | 29 | interface DataConnection{ 30 | send(data: any): void; 31 | close(): void; 32 | on(event: string, cb: ()=>void): void; 33 | on(event: 'data', cb: (data: any)=>void): void; 34 | on(event: 'open', cb: ()=>void): void; 35 | on(event: 'close', cb: ()=>void): void; 36 | on(event: 'error', cb: (err: any)=>void): void; 37 | off(event: string, fn: Function, once?: boolean): void; 38 | dataChannel: RTCDataChannel; 39 | label: string; 40 | metadata: any; 41 | open: boolean; 42 | peerConnection: any; 43 | peer: string; 44 | reliable: boolean; 45 | serialization: string; 46 | type: string; 47 | buffSize: number; 48 | } 49 | 50 | interface MediaConnection{ 51 | answer(stream?: any): void; 52 | close(): void; 53 | on(event: string, cb: ()=>void): void; 54 | on(event: 'stream', cb: (stream: any)=>void): void; 55 | on(event: 'close', cb: ()=>void): void; 56 | on(event: 'error', cb: (err: any)=>void): void; 57 | off(event: string, fn: Function, once?: boolean): void; 58 | open: boolean; 59 | metadata: any; 60 | peer: string; 61 | type: string; 62 | } 63 | 64 | interface utilSupportsObj { 65 | audioVideo: boolean; 66 | data: boolean; 67 | binary: boolean; 68 | reliable: boolean; 69 | } 70 | 71 | interface util{ 72 | browser: string; 73 | supports: utilSupportsObj; 74 | } 75 | 76 | export interface Peer{ 77 | /** 78 | * 79 | * @param id The brokering ID of the remote peer (their peer.id). 80 | * @param options for specifying details about Peer Connection 81 | */ 82 | connect(id: string, options?: PeerJs.PeerConnectOption): PeerJs.DataConnection; 83 | /** 84 | * Connects to the remote peer specified by id and returns a data connection. 85 | * @param id The brokering ID of the remote peer (their peer.id). 86 | * @param stream The caller's media stream 87 | * @param options Metadata associated with the connection, passed in by whoever initiated the connection. 88 | */ 89 | call(id: string, stream: any, options?: any): PeerJs.MediaConnection; 90 | /** 91 | * Calls the remote peer specified by id and returns a media connection. 92 | * @param event Event name 93 | * @param cb Callback Function 94 | */ 95 | on(event: string, cb: ()=>void): void; 96 | /** 97 | * Emitted when a connection to the PeerServer is established. 98 | * @param event Event name 99 | * @param cb id is the brokering ID of the peer 100 | */ 101 | on(event: 'open', cb: (id: string)=>void): void; 102 | /** 103 | * Emitted when a new data connection is established from a remote peer. 104 | * @param event Event name 105 | * @param cb Callback Function 106 | */ 107 | on(event: 'connection', cb: (dataConnection: PeerJs.DataConnection)=>void): void; 108 | /** 109 | * Emitted when a remote peer attempts to call you. 110 | * @param event Event name 111 | * @param cb Callback Function 112 | */ 113 | on(event: 'call', cb: (mediaConnection: PeerJs.MediaConnection)=>void): void; 114 | /** 115 | * Emitted when the peer is destroyed and can no longer accept or create any new connections. 116 | * @param event Event name 117 | * @param cb Callback Function 118 | */ 119 | on(event: 'close', cb: ()=>void): void; 120 | /** 121 | * Emitted when the peer is disconnected from the signalling server 122 | * @param event Event name 123 | * @param cb Callback Function 124 | */ 125 | on(event: 'disconnected', cb: ()=>void): void; 126 | /** 127 | * Errors on the peer are almost always fatal and will destroy the peer. 128 | * @param event Event name 129 | * @param cb Callback Function 130 | */ 131 | on(event: 'error', cb: (err: any)=>void): void; 132 | /** 133 | * Remove event listeners.(EventEmitter3) 134 | * @param {String} event The event we want to remove. 135 | * @param {Function} fn The listener that we need to find. 136 | * @param {Boolean} once Only remove once listeners. 137 | */ 138 | off(event: string, fn: Function, once?: boolean): void; 139 | /** 140 | * Close the connection to the server, leaving all existing data and media connections intact. 141 | */ 142 | disconnect(): void; 143 | /** 144 | * Attempt to reconnect to the server with the peer's old ID 145 | */ 146 | reconnect(): void; 147 | /** 148 | * Close the connection to the server and terminate all existing connections. 149 | */ 150 | destroy(): void; 151 | 152 | /** 153 | * Retrieve a data/media connection for this peer. 154 | * @param peer 155 | * @param id 156 | */ 157 | getConnection(peer: Peer, id: string): any; 158 | 159 | /** 160 | * Get a list of available peer IDs 161 | * @param callback 162 | */ 163 | listAllPeers(callback: (peerIds: Array)=>void): void; 164 | /** 165 | * The brokering ID of this peer 166 | */ 167 | id: string; 168 | /** 169 | * A hash of all connections associated with this peer, keyed by the remote peer's ID. 170 | */ 171 | connections: any; 172 | /** 173 | * false if there is an active connection to the PeerServer. 174 | */ 175 | disconnected: boolean; 176 | /** 177 | * true if this peer and all of its connections can no longer be used. 178 | */ 179 | destroyed: boolean; 180 | } 181 | } 182 | 183 | declare var Peer: { 184 | prototype: RTCIceServer; 185 | /** 186 | * A peer can connect to other peers and listen for connections. 187 | * @param id Other peers can connect to this peer using the provided ID. 188 | * If no ID is given, one will be generated by the brokering server. 189 | * @param options for specifying details about PeerServer 190 | */ 191 | new (id: string, options?: PeerJs.PeerJSOption): PeerJs.Peer; 192 | 193 | /** 194 | * A peer can connect to other peers and listen for connections. 195 | * @param options for specifying details about PeerServer 196 | */ 197 | new (options: PeerJs.PeerJSOption): PeerJs.Peer; 198 | }; -------------------------------------------------------------------------------- /typings/main/ambient/webrtc/mediastream/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/webrtc/MediaStream.d.ts 3 | // Type definitions for WebRTC 4 | // Project: http://dev.w3.org/2011/webrtc/ 5 | // Definitions by: Ken Smith 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | 8 | // Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html 9 | // version: W3C Editor's Draft 29 June 2015 10 | 11 | interface ConstrainBooleanParameters { 12 | exact?: boolean; 13 | ideal?: boolean; 14 | } 15 | 16 | interface NumberRange { 17 | max?: number; 18 | min?: number; 19 | } 20 | 21 | interface ConstrainNumberRange extends NumberRange { 22 | exact?: number; 23 | ideal?: number; 24 | } 25 | 26 | interface ConstrainStringParameters { 27 | exact?: string | string[]; 28 | ideal?: string | string[]; 29 | } 30 | 31 | interface MediaStreamConstraints { 32 | video?: boolean | MediaTrackConstraints; 33 | audio?: boolean | MediaTrackConstraints; 34 | } 35 | 36 | declare namespace W3C { 37 | type LongRange = NumberRange; 38 | type DoubleRange = NumberRange; 39 | type ConstrainBoolean = boolean | ConstrainBooleanParameters; 40 | type ConstrainNumber = number | ConstrainNumberRange; 41 | type ConstrainLong = ConstrainNumber; 42 | type ConstrainDouble = ConstrainNumber; 43 | type ConstrainString = string | string[] | ConstrainStringParameters; 44 | } 45 | 46 | interface MediaTrackConstraints extends MediaTrackConstraintSet { 47 | advanced?: MediaTrackConstraintSet[]; 48 | } 49 | 50 | interface MediaTrackConstraintSet { 51 | width?: W3C.ConstrainLong; 52 | height?: W3C.ConstrainLong; 53 | aspectRatio?: W3C.ConstrainDouble; 54 | frameRate?: W3C.ConstrainDouble; 55 | facingMode?: W3C.ConstrainString; 56 | volume?: W3C.ConstrainDouble; 57 | sampleRate?: W3C.ConstrainLong; 58 | sampleSize?: W3C.ConstrainLong; 59 | echoCancellation?: W3C.ConstrainBoolean; 60 | latency?: W3C.ConstrainDouble; 61 | deviceId?: W3C.ConstrainString; 62 | groupId?: W3C.ConstrainString; 63 | } 64 | 65 | interface MediaTrackSupportedConstraints { 66 | width?: boolean; 67 | height?: boolean; 68 | aspectRatio?: boolean; 69 | frameRate?: boolean; 70 | facingMode?: boolean; 71 | volume?: boolean; 72 | sampleRate?: boolean; 73 | sampleSize?: boolean; 74 | echoCancellation?: boolean; 75 | latency?: boolean; 76 | deviceId?: boolean; 77 | groupId?: boolean; 78 | } 79 | 80 | interface MediaStream extends EventTarget { 81 | id: string; 82 | active: boolean; 83 | 84 | onactive: EventListener; 85 | oninactive: EventListener; 86 | onaddtrack: (event: MediaStreamTrackEvent) => any; 87 | onremovetrack: (event: MediaStreamTrackEvent) => any; 88 | 89 | clone(): MediaStream; 90 | stop(): void; 91 | 92 | getAudioTracks(): MediaStreamTrack[]; 93 | getVideoTracks(): MediaStreamTrack[]; 94 | getTracks(): MediaStreamTrack[]; 95 | 96 | getTrackById(trackId: string): MediaStreamTrack; 97 | 98 | addTrack(track: MediaStreamTrack): void; 99 | removeTrack(track: MediaStreamTrack): void; 100 | } 101 | 102 | interface MediaStreamTrackEvent extends Event { 103 | track: MediaStreamTrack; 104 | } 105 | 106 | declare enum MediaStreamTrackState { 107 | "live", 108 | "ended" 109 | } 110 | 111 | interface MediaStreamTrack extends EventTarget { 112 | id: string; 113 | kind: string; 114 | label: string; 115 | enabled: boolean; 116 | muted: boolean; 117 | remote: boolean; 118 | readyState: MediaStreamTrackState; 119 | 120 | onmute: EventListener; 121 | onunmute: EventListener; 122 | onended: EventListener; 123 | onoverconstrained: EventListener; 124 | 125 | clone(): MediaStreamTrack; 126 | 127 | stop(): void; 128 | 129 | getCapabilities(): MediaTrackCapabilities; 130 | getConstraints(): MediaTrackConstraints; 131 | getSettings(): MediaTrackSettings; 132 | applyConstraints(constraints: MediaTrackConstraints): Promise; 133 | } 134 | 135 | interface MediaTrackCapabilities { 136 | width: number | W3C.LongRange; 137 | height: number | W3C.LongRange; 138 | aspectRatio: number | W3C.DoubleRange; 139 | frameRate: number | W3C.DoubleRange; 140 | facingMode: string; 141 | volume: number | W3C.DoubleRange; 142 | sampleRate: number | W3C.LongRange; 143 | sampleSize: number | W3C.LongRange; 144 | echoCancellation: boolean[]; 145 | latency: number | W3C.DoubleRange; 146 | deviceId: string; 147 | groupId: string; 148 | } 149 | 150 | interface MediaTrackSettings { 151 | width: number; 152 | height: number; 153 | aspectRatio: number; 154 | frameRate: number; 155 | facingMode: string; 156 | volume: number; 157 | sampleRate: number; 158 | sampleSize: number; 159 | echoCancellation: boolean; 160 | latency: number; 161 | deviceId: string; 162 | groupId: string; 163 | } 164 | 165 | interface MediaStreamError { 166 | name: string; 167 | message: string; 168 | constraintName: string; 169 | } 170 | 171 | interface NavigatorGetUserMedia { 172 | (constraints: MediaStreamConstraints, 173 | successCallback: (stream: MediaStream) => void, 174 | errorCallback: (error: MediaStreamError) => void): void; 175 | } 176 | 177 | // to use with adapter.js, see: https://github.com/webrtc/adapter 178 | declare var getUserMedia: NavigatorGetUserMedia; 179 | 180 | interface Navigator { 181 | getUserMedia: NavigatorGetUserMedia; 182 | 183 | webkitGetUserMedia: NavigatorGetUserMedia; 184 | 185 | mozGetUserMedia: NavigatorGetUserMedia; 186 | 187 | msGetUserMedia: NavigatorGetUserMedia; 188 | 189 | mediaDevices: MediaDevices; 190 | } 191 | 192 | interface MediaDevices { 193 | getSupportedConstraints(): MediaTrackSupportedConstraints; 194 | 195 | getUserMedia(constraints: MediaStreamConstraints): Promise; 196 | enumerateDevices(): Promise; 197 | } 198 | 199 | interface MediaDeviceInfo { 200 | label: string; 201 | deviceId: string; 202 | kind: string; 203 | groupId: string; 204 | } -------------------------------------------------------------------------------- /typings/main/ambient/webrtc/rtcpeerconnection/index.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by typings 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/webrtc/RTCPeerConnection.d.ts 3 | // Type definitions for WebRTC 4 | // Project: http://dev.w3.org/2011/webrtc/ 5 | // Definitions by: Ken Smith 6 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 7 | // 8 | // Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html 9 | // 10 | // For example code see: 11 | // https://code.google.com/p/webrtc/source/browse/stable/samples/js/apprtc/js/main.js 12 | // 13 | // For a generic implementation see that deals with browser differences, see: 14 | // https://code.google.com/p/webrtc/source/browse/stable/samples/js/base/adapter.js 15 | 16 | 17 | // TODO(1): Get Typescript to have string-enum types as WebRtc is full of string 18 | // enums. 19 | // https://typescript.codeplex.com/discussions/549207 20 | 21 | // TODO(2): get Typescript to have union types as WebRtc uses them. 22 | // https://typescript.codeplex.com/workitem/1364 23 | 24 | interface RTCConfiguration { 25 | iceServers: RTCIceServer[]; 26 | } 27 | declare var RTCConfiguration: { 28 | prototype: RTCConfiguration; 29 | new (): RTCConfiguration; 30 | }; 31 | 32 | interface RTCIceServer { 33 | urls: string; 34 | credential?: string; 35 | } 36 | declare var RTCIceServer: { 37 | prototype: RTCIceServer; 38 | new (): RTCIceServer; 39 | }; 40 | 41 | // moz (Firefox) specific prefixes. 42 | interface mozRTCPeerConnection extends RTCPeerConnection { 43 | } 44 | declare var mozRTCPeerConnection: { 45 | prototype: mozRTCPeerConnection; 46 | new (settings: RTCPeerConnectionConfig, 47 | constraints?:RTCMediaConstraints): mozRTCPeerConnection; 48 | }; 49 | // webkit (Chrome) specific prefixes. 50 | interface webkitRTCPeerConnection extends RTCPeerConnection { 51 | } 52 | declare var webkitRTCPeerConnection: { 53 | prototype: webkitRTCPeerConnection; 54 | new (settings: RTCPeerConnectionConfig, 55 | constraints?:RTCMediaConstraints): webkitRTCPeerConnection; 56 | }; 57 | 58 | // For Chrome, look at the code here: 59 | // https://code.google.com/p/chromium/codesearch#chromium/src/third_party/libjingle/source/talk/app/webrtc/webrtcsession.cc&sq=package:chromium&dr=C&l=63 60 | interface RTCOptionalMediaConstraint { 61 | // When true, will use DTLS/SCTP data channels 62 | DtlsSrtpKeyAgreement?: boolean; 63 | // When true will use Rtp-based data channels (depreicated) 64 | RtpDataChannels?: boolean; 65 | } 66 | 67 | // ks 12/20/12 - There's more here that doesn't seem to be documented very well yet. 68 | // http://www.w3.org/TR/2013/WD-webrtc-20130910/ 69 | interface RTCMediaConstraints { 70 | mandatory?: RTCMediaOfferConstraints; 71 | optional?: RTCOptionalMediaConstraint[] 72 | } 73 | 74 | interface RTCMediaOfferConstraints { 75 | offerToReceiveAudio: boolean; 76 | offerToReceiveVideo: boolean; 77 | } 78 | 79 | interface RTCSessionDescriptionInit { 80 | type: string; // RTCSdpType; See TODO(1) 81 | sdp: string; 82 | } 83 | 84 | interface RTCSessionDescription { 85 | type?: string; // RTCSdpType; See TODO(1) 86 | sdp?: string; 87 | } 88 | declare var RTCSessionDescription: { 89 | prototype: RTCSessionDescription; 90 | new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; 91 | // TODO: Add serializer. 92 | // See: http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSdpType) 93 | }; 94 | 95 | interface webkitRTCSessionDescription extends RTCSessionDescription{ 96 | type?: string; 97 | sdp?: string; 98 | } 99 | declare var webkitRTCSessionDescription: { 100 | prototype: webkitRTCSessionDescription; 101 | new (descriptionInitDict?: RTCSessionDescriptionInit): webkitRTCSessionDescription; 102 | }; 103 | 104 | interface mozRTCSessionDescription extends RTCSessionDescription{ 105 | type?: string; 106 | sdp?: string; 107 | } 108 | declare var mozRTCSessionDescription: { 109 | prototype: mozRTCSessionDescription; 110 | new (descriptionInitDict?: RTCSessionDescriptionInit): mozRTCSessionDescription; 111 | }; 112 | 113 | 114 | 115 | interface RTCDataChannelInit { 116 | ordered ?: boolean; // messages must be sent in-order. 117 | maxPacketLifeTime ?: number; // unsigned short 118 | maxRetransmits ?: number; // unsigned short 119 | protocol ?: string; // default = '' 120 | negotiated ?: boolean; // default = false; 121 | id ?: number; // unsigned short 122 | } 123 | 124 | // TODO(1) 125 | declare enum RTCSdpType { 126 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcsdptype 127 | 'offer', 128 | 'pranswer', 129 | 'answer' 130 | } 131 | 132 | interface RTCMessageEvent { 133 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#event-datachannel-message 134 | // At present, this can be an: ArrayBuffer, a string, or a Blob. 135 | // See TODO(2) 136 | data: any; 137 | } 138 | 139 | // TODO(1) 140 | declare enum RTCDataChannelState { 141 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelState 142 | 'connecting', 143 | 'open', 144 | 'closing', 145 | 'closed' 146 | } 147 | 148 | interface RTCDataChannel extends EventTarget { 149 | label: string; 150 | reliable: boolean; 151 | readyState: string; // RTCDataChannelState; see TODO(1) 152 | bufferedAmount: number; 153 | binaryType: string; 154 | 155 | onopen: (event: Event) => void; 156 | onerror: (event: Event) => void; 157 | onclose: (event: Event) => void; 158 | onmessage: (event: RTCMessageEvent) => void; 159 | 160 | close(): void; 161 | 162 | send(data: string): void ; 163 | send(data: ArrayBuffer): void; 164 | send(data: ArrayBufferView): void; 165 | send(data: Blob): void; 166 | } 167 | declare var RTCDataChannel: { 168 | prototype: RTCDataChannel; 169 | new (): RTCDataChannel; 170 | }; 171 | 172 | interface RTCDataChannelEvent extends Event { 173 | channel: RTCDataChannel; 174 | } 175 | declare var RTCDataChannelEvent: { 176 | prototype: RTCDataChannelEvent; 177 | new (eventInitDict: RTCDataChannelEventInit): RTCDataChannelEvent; 178 | }; 179 | 180 | interface RTCIceCandidateEvent extends Event { 181 | candidate: RTCIceCandidate; 182 | } 183 | 184 | interface RTCMediaStreamEvent extends Event { 185 | stream: MediaStream; 186 | } 187 | 188 | interface EventInit { 189 | } 190 | 191 | interface RTCDataChannelEventInit extends EventInit { 192 | channel: RTCDataChannel; 193 | } 194 | 195 | interface RTCVoidCallback { 196 | (): void; 197 | } 198 | interface RTCSessionDescriptionCallback { 199 | (sdp: RTCSessionDescription): void; 200 | } 201 | interface RTCPeerConnectionErrorCallback { 202 | (errorInformation: DOMError): void; 203 | } 204 | 205 | // TODO(1) 206 | declare enum RTCIceGatheringState { 207 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcicegatheringstate-enum 208 | 'new', 209 | 'gathering', 210 | 'complete' 211 | } 212 | 213 | // TODO(1) 214 | declare enum RTCIceConnectionState { 215 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceConnectionState 216 | 'new', 217 | 'checking', 218 | 'connected', 219 | 'completed', 220 | 'failed', 221 | 'disconnected', 222 | 'closed' 223 | } 224 | 225 | // TODO(1) 226 | declare enum RTCSignalingState { 227 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSignalingState 228 | 'stable', 229 | 'have-local-offer', 230 | 'have-remote-offer', 231 | 'have-local-pranswer', 232 | 'have-remote-pranswer', 233 | 'closed' 234 | } 235 | 236 | // This is based on the current implementation of WebRtc in Chrome; the spec is 237 | // a little unclear on this. 238 | // http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCStatsReport 239 | interface RTCStatsReport { 240 | stat(id: string): string; 241 | } 242 | 243 | interface RTCStatsCallback { 244 | (report: RTCStatsReport): void; 245 | } 246 | 247 | interface RTCPeerConnection { 248 | createOffer(successCallback: RTCSessionDescriptionCallback, 249 | failureCallback?: RTCPeerConnectionErrorCallback, 250 | constraints?: RTCMediaConstraints): void; 251 | createAnswer(successCallback: RTCSessionDescriptionCallback, 252 | failureCallback?: RTCPeerConnectionErrorCallback, 253 | constraints?: RTCMediaConstraints): void; 254 | setLocalDescription(description: RTCSessionDescription, 255 | successCallback?: RTCVoidCallback, 256 | failureCallback?: RTCPeerConnectionErrorCallback): void; 257 | localDescription: RTCSessionDescription; 258 | setRemoteDescription(description: RTCSessionDescription, 259 | successCallback?: RTCVoidCallback, 260 | failureCallback?: RTCPeerConnectionErrorCallback): void; 261 | remoteDescription: RTCSessionDescription; 262 | signalingState: string; // RTCSignalingState; see TODO(1) 263 | updateIce(configuration?: RTCConfiguration, 264 | constraints?: RTCMediaConstraints): void; 265 | addIceCandidate(candidate:RTCIceCandidate, 266 | successCallback:() => void, 267 | failureCallback:RTCPeerConnectionErrorCallback): void; 268 | iceGatheringState: string; // RTCIceGatheringState; see TODO(1) 269 | iceConnectionState: string; // RTCIceConnectionState; see TODO(1) 270 | getLocalStreams(): MediaStream[]; 271 | getRemoteStreams(): MediaStream[]; 272 | createDataChannel(label?: string, 273 | dataChannelDict?: RTCDataChannelInit): RTCDataChannel; 274 | ondatachannel: (event: Event) => void; 275 | addStream(stream: MediaStream, constraints?: RTCMediaConstraints): void; 276 | removeStream(stream: MediaStream): void; 277 | close(): void; 278 | onnegotiationneeded: (event: Event) => void; 279 | onconnecting: (event: Event) => void; 280 | onopen: (event: Event) => void; 281 | onaddstream: (event: RTCMediaStreamEvent) => void; 282 | onremovestream: (event: RTCMediaStreamEvent) => void; 283 | onstatechange: (event: Event) => void; 284 | oniceconnectionstatechange: (event: Event) => void; 285 | onicecandidate: (event: RTCIceCandidateEvent) => void; 286 | onidentityresult: (event: Event) => void; 287 | onsignalingstatechange: (event: Event) => void; 288 | getStats: (successCallback: RTCStatsCallback, 289 | failureCallback: RTCPeerConnectionErrorCallback) => void; 290 | } 291 | declare var RTCPeerConnection: { 292 | prototype: RTCPeerConnection; 293 | new (configuration: RTCConfiguration, 294 | constraints?: RTCMediaConstraints): RTCPeerConnection; 295 | }; 296 | 297 | interface RTCIceCandidate { 298 | candidate?: string; 299 | sdpMid?: string; 300 | sdpMLineIndex?: number; 301 | } 302 | declare var RTCIceCandidate: { 303 | prototype: RTCIceCandidate; 304 | new (candidateInitDict?: RTCIceCandidate): RTCIceCandidate; 305 | }; 306 | 307 | interface webkitRTCIceCandidate extends RTCIceCandidate { 308 | candidate?: string; 309 | sdpMid?: string; 310 | sdpMLineIndex?: number; 311 | } 312 | declare var webkitRTCIceCandidate: { 313 | prototype: webkitRTCIceCandidate; 314 | new (candidateInitDict?: webkitRTCIceCandidate): webkitRTCIceCandidate; 315 | }; 316 | 317 | interface mozRTCIceCandidate extends RTCIceCandidate { 318 | candidate?: string; 319 | sdpMid?: string; 320 | sdpMLineIndex?: number; 321 | } 322 | declare var mozRTCIceCandidate: { 323 | prototype: mozRTCIceCandidate; 324 | new (candidateInitDict?: mozRTCIceCandidate): mozRTCIceCandidate; 325 | }; 326 | 327 | interface RTCIceCandidateInit { 328 | candidate: string; 329 | sdpMid: string; 330 | sdpMLineIndex: number; 331 | } 332 | declare var RTCIceCandidateInit:{ 333 | prototype: RTCIceCandidateInit; 334 | new (): RTCIceCandidateInit; 335 | }; 336 | 337 | interface PeerConnectionIceEvent { 338 | peer: RTCPeerConnection; 339 | candidate: RTCIceCandidate; 340 | } 341 | declare var PeerConnectionIceEvent: { 342 | prototype: PeerConnectionIceEvent; 343 | new (): PeerConnectionIceEvent; 344 | }; 345 | 346 | interface RTCPeerConnectionConfig { 347 | iceServers: RTCIceServer[]; 348 | } 349 | declare var RTCPeerConnectionConfig: { 350 | prototype: RTCPeerConnectionConfig; 351 | new (): RTCPeerConnectionConfig; 352 | }; 353 | 354 | interface Window{ 355 | RTCPeerConnection: RTCPeerConnection; 356 | webkitRTCPeerConnection: webkitRTCPeerConnection; 357 | mozRTCPeerConnection: mozRTCPeerConnection; 358 | RTCSessionDescription: RTCSessionDescription; 359 | webkitRTCSessionDescription: webkitRTCSessionDescription; 360 | mozRTCSessionDescription: mozRTCSessionDescription; 361 | RTCIceCandidate: RTCIceCandidate; 362 | webkitRTCIceCandidate: webkitRTCIceCandidate; 363 | mozRTCIceCandidate: mozRTCIceCandidate; 364 | } -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | 4 | module.exports = { 5 | entry: [ 6 | path.normalize('es6-shim/es6-shim.min'), 7 | 'reflect-metadata', 8 | path.normalize('zone.js/dist/zone.min'), 9 | path.resolve('app/app') 10 | ], 11 | output: { 12 | path: path.resolve('www/build/js'), 13 | filename: 'app.bundle.js', 14 | pathinfo: false // show module paths in the bundle, handy for debugging 15 | }, 16 | module: { 17 | loaders: [ 18 | { 19 | test: /\.ts$/, 20 | loader: 'awesome-typescript', 21 | query: { 22 | doTypeCheck: true, 23 | resolveGlobs: false, 24 | externals: ['typings/browser.d.ts'] 25 | }, 26 | include: path.resolve('app'), 27 | exclude: /node_modules/ 28 | }, 29 | { 30 | test: /\.js$/, 31 | include: path.resolve('node_modules/angular2'), 32 | loader: 'strip-sourcemap' 33 | } 34 | ], 35 | noParse: [ 36 | /es6-shim/, 37 | /reflect-metadata/, 38 | /zone\.js(\/|\\)dist(\/|\\)zone-microtask/ 39 | ] 40 | }, 41 | resolve: { 42 | root: ['app'], 43 | alias: { 44 | 'angular2': path.resolve('node_modules/angular2') 45 | }, 46 | extensions: ["", ".js", ".ts"] 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | --------------------------------------------------------------------------------