mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
change CRLF to LF
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
/// <reference path="angular-environment.d.ts" />
|
||||
var envServiceProvider: angular.environment.ServiceProvider;
|
||||
var envService: angular.environment.Service;
|
||||
|
||||
envServiceProvider.config({
|
||||
domains: {
|
||||
development: ['localhost', 'dev.local'],
|
||||
production: ['acme.com', 'acme.net', 'acme.org']
|
||||
},
|
||||
vars: {
|
||||
development: {
|
||||
apiUrl: '//localhost/api',
|
||||
staticUrl: '//localhost/static'
|
||||
},
|
||||
production: {
|
||||
apiUrl: '//api.acme.com/v2',
|
||||
staticUrl: '//static.acme.com'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
envServiceProvider.check();
|
||||
|
||||
envService.get();
|
||||
|
||||
envService.set('production');
|
||||
|
||||
var isProd: boolean = envService.is('production');
|
||||
|
||||
var val: any = envService.read('apiUrl');
|
||||
/// <reference path="angular-environment.d.ts" />
|
||||
var envServiceProvider: angular.environment.ServiceProvider;
|
||||
var envService: angular.environment.Service;
|
||||
|
||||
envServiceProvider.config({
|
||||
domains: {
|
||||
development: ['localhost', 'dev.local'],
|
||||
production: ['acme.com', 'acme.net', 'acme.org']
|
||||
},
|
||||
vars: {
|
||||
development: {
|
||||
apiUrl: '//localhost/api',
|
||||
staticUrl: '//localhost/static'
|
||||
},
|
||||
production: {
|
||||
apiUrl: '//api.acme.com/v2',
|
||||
staticUrl: '//static.acme.com'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
envServiceProvider.check();
|
||||
|
||||
envService.get();
|
||||
|
||||
envService.set('production');
|
||||
|
||||
var isProd: boolean = envService.is('production');
|
||||
|
||||
var val: any = envService.read('apiUrl');
|
||||
|
||||
104
angular-environment/angular-environment.d.ts
vendored
104
angular-environment/angular-environment.d.ts
vendored
@@ -1,52 +1,52 @@
|
||||
// Type definitions for angular-environment v1.0.4
|
||||
// Project: https://github.com/juanpablob/angular-environment
|
||||
// Definitions by: Matt Wheatley <https://github.com/terrawheat>
|
||||
// Definitions: https://github.com/LiberisLabs
|
||||
|
||||
declare module angular.environment {
|
||||
interface ServiceProvider {
|
||||
/**
|
||||
* Sets the configuration object
|
||||
*/
|
||||
config: (config: angular.environment.Config) => void;
|
||||
/**
|
||||
* Evaluates the current domain and
|
||||
* loads the correct environment variables.
|
||||
*/
|
||||
check: () => void;
|
||||
}
|
||||
interface Service {
|
||||
/**
|
||||
* Retrieve the current environment
|
||||
*/
|
||||
get: () => string,
|
||||
|
||||
/**
|
||||
* Force sets the current environment
|
||||
*/
|
||||
set: (environment: string) => void,
|
||||
|
||||
/**
|
||||
* Evaluates current environment against
|
||||
* environment parameter.
|
||||
*/
|
||||
is: (environment: string) => boolean,
|
||||
|
||||
/**
|
||||
* Retrieves the correct version of a
|
||||
* variable for the current environment.
|
||||
*/
|
||||
read: (key: string) => any;
|
||||
}
|
||||
|
||||
interface Config {
|
||||
/**
|
||||
* Map of domains to their environments
|
||||
*/
|
||||
domains: { [environment: string]: Array<string> },
|
||||
/**
|
||||
* List of variables split by environment
|
||||
*/
|
||||
vars: { [environment: string]: { [variable: string]: any }},
|
||||
}
|
||||
}
|
||||
// Type definitions for angular-environment v1.0.4
|
||||
// Project: https://github.com/juanpablob/angular-environment
|
||||
// Definitions by: Matt Wheatley <https://github.com/terrawheat>
|
||||
// Definitions: https://github.com/LiberisLabs
|
||||
|
||||
declare module angular.environment {
|
||||
interface ServiceProvider {
|
||||
/**
|
||||
* Sets the configuration object
|
||||
*/
|
||||
config: (config: angular.environment.Config) => void;
|
||||
/**
|
||||
* Evaluates the current domain and
|
||||
* loads the correct environment variables.
|
||||
*/
|
||||
check: () => void;
|
||||
}
|
||||
interface Service {
|
||||
/**
|
||||
* Retrieve the current environment
|
||||
*/
|
||||
get: () => string,
|
||||
|
||||
/**
|
||||
* Force sets the current environment
|
||||
*/
|
||||
set: (environment: string) => void,
|
||||
|
||||
/**
|
||||
* Evaluates current environment against
|
||||
* environment parameter.
|
||||
*/
|
||||
is: (environment: string) => boolean,
|
||||
|
||||
/**
|
||||
* Retrieves the correct version of a
|
||||
* variable for the current environment.
|
||||
*/
|
||||
read: (key: string) => any;
|
||||
}
|
||||
|
||||
interface Config {
|
||||
/**
|
||||
* Map of domains to their environments
|
||||
*/
|
||||
domains: { [environment: string]: Array<string> },
|
||||
/**
|
||||
* List of variables split by environment
|
||||
*/
|
||||
vars: { [environment: string]: { [variable: string]: any }},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
/// <reference path="express.d.ts" />
|
||||
|
||||
import * as express from 'express';
|
||||
var app = express();
|
||||
|
||||
app.engine('jade', require('jade').__express);
|
||||
app.engine('html', require('ejs').renderFile);
|
||||
|
||||
express.static.mime.define({
|
||||
'application/fx': ['fx']
|
||||
});
|
||||
app.use('/static', express.static(__dirname + '/public'));
|
||||
|
||||
// simple logger
|
||||
app.use(function(req, res, next){
|
||||
console.log('%s %s', req.method, req.url);
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(function(err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
console.error(err);
|
||||
next(err);
|
||||
});
|
||||
|
||||
|
||||
app.get('/', function(req, res){
|
||||
res.send('hello world');
|
||||
});
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
|
||||
const pathStr : string = 'test';
|
||||
const pathRE : RegExp = /test/;
|
||||
const path = true? pathStr : pathRE;
|
||||
|
||||
router.get(path);
|
||||
router.put(path)
|
||||
router.post(path);
|
||||
router.delete(path);
|
||||
router.get(pathStr);
|
||||
router.put(pathStr)
|
||||
router.post(pathStr);
|
||||
router.delete(pathStr);
|
||||
router.get(pathRE);
|
||||
router.put(pathRE)
|
||||
router.post(pathRE);
|
||||
router.delete(pathRE);
|
||||
|
||||
router.use((req, res, next) => { next(); })
|
||||
router.route('/users')
|
||||
.get((req, res, next) => {
|
||||
res.send(req.query['token']);
|
||||
});
|
||||
|
||||
router.get('/user/:id', function(req, res, next) {
|
||||
if (req.params.id == 0) next('route');
|
||||
else next();
|
||||
}, function(req, res, next) {
|
||||
res.render('regular');
|
||||
});
|
||||
|
||||
app.use((req, res, next) => {
|
||||
// hacky trick, router is just a handler
|
||||
router(req, res, next);
|
||||
});
|
||||
|
||||
app.use(router);
|
||||
|
||||
app.listen(3000);
|
||||
/// <reference path="express.d.ts" />
|
||||
|
||||
import * as express from 'express';
|
||||
var app = express();
|
||||
|
||||
app.engine('jade', require('jade').__express);
|
||||
app.engine('html', require('ejs').renderFile);
|
||||
|
||||
express.static.mime.define({
|
||||
'application/fx': ['fx']
|
||||
});
|
||||
app.use('/static', express.static(__dirname + '/public'));
|
||||
|
||||
// simple logger
|
||||
app.use(function(req, res, next){
|
||||
console.log('%s %s', req.method, req.url);
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(function(err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
console.error(err);
|
||||
next(err);
|
||||
});
|
||||
|
||||
|
||||
app.get('/', function(req, res){
|
||||
res.send('hello world');
|
||||
});
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
|
||||
const pathStr : string = 'test';
|
||||
const pathRE : RegExp = /test/;
|
||||
const path = true? pathStr : pathRE;
|
||||
|
||||
router.get(path);
|
||||
router.put(path)
|
||||
router.post(path);
|
||||
router.delete(path);
|
||||
router.get(pathStr);
|
||||
router.put(pathStr)
|
||||
router.post(pathStr);
|
||||
router.delete(pathStr);
|
||||
router.get(pathRE);
|
||||
router.put(pathRE)
|
||||
router.post(pathRE);
|
||||
router.delete(pathRE);
|
||||
|
||||
router.use((req, res, next) => { next(); })
|
||||
router.route('/users')
|
||||
.get((req, res, next) => {
|
||||
res.send(req.query['token']);
|
||||
});
|
||||
|
||||
router.get('/user/:id', function(req, res, next) {
|
||||
if (req.params.id == 0) next('route');
|
||||
else next();
|
||||
}, function(req, res, next) {
|
||||
res.render('regular');
|
||||
});
|
||||
|
||||
app.use((req, res, next) => {
|
||||
// hacky trick, router is just a handler
|
||||
router(req, res, next);
|
||||
});
|
||||
|
||||
app.use(router);
|
||||
|
||||
app.listen(3000);
|
||||
|
||||
2162
express/express.d.ts
vendored
2162
express/express.d.ts
vendored
File diff suppressed because it is too large
Load Diff
182
iscroll/iscroll-5.d.ts
vendored
182
iscroll/iscroll-5.d.ts
vendored
@@ -1,91 +1,91 @@
|
||||
// Type definitions for iScroll 5
|
||||
// Project: http://cubiq.org/iscroll-5-ready-for-beta-test
|
||||
// Definitions by: Christiaan Rakowski <https://github.com/csrakowski/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface IScrollOptions {
|
||||
//hScroll?: boolean;
|
||||
//vScroll?: boolean;
|
||||
x?: number;
|
||||
y?: number;
|
||||
bounce?: boolean;
|
||||
bounceLock?: boolean;
|
||||
momentum?: boolean;
|
||||
lockDirection?: boolean;
|
||||
useTransform?: boolean;
|
||||
useTransition?: boolean;
|
||||
topOffset?: number;
|
||||
checkDOMChanges?: boolean;
|
||||
handleClick?: boolean;
|
||||
|
||||
// Scrollbar
|
||||
hScrollbar?: boolean;
|
||||
vScrollbar?: boolean;
|
||||
fixedScrollbar?: boolean;
|
||||
hideScrollbar?: boolean;
|
||||
fadeScrollbar?: boolean;
|
||||
scrollbarClass?: string;
|
||||
|
||||
// Zoom
|
||||
zoom?: boolean;
|
||||
zoomMin?: number;
|
||||
zoomMax?: number;
|
||||
doubleTapZoom?: number;
|
||||
wheelAction?: string;
|
||||
|
||||
|
||||
///String or boolean
|
||||
snap?: any;
|
||||
snapThreshold?: number;
|
||||
|
||||
//new in IScroll 5?
|
||||
|
||||
resizeIndicator?: boolean;
|
||||
mouseWheelSpeed?: number;
|
||||
startX?: number;
|
||||
startY?: number;
|
||||
scrollX?: boolean;
|
||||
scrollY?: boolean;
|
||||
directionLockThreshold?: number;
|
||||
|
||||
bounceTime?: number;
|
||||
|
||||
///String or function
|
||||
bounceEasing?: any;
|
||||
|
||||
preventDefault?: boolean;
|
||||
preventDefaultException?: boolean;
|
||||
|
||||
HWCompositing?: boolean;
|
||||
|
||||
freeScroll?: boolean;
|
||||
|
||||
resizePolling?: number;
|
||||
tap?: boolean;
|
||||
click?: boolean;
|
||||
invertWheelDirection?: boolean;
|
||||
|
||||
///Boolean or string
|
||||
eventPassthrough?: any;
|
||||
}
|
||||
|
||||
declare class IScroll {
|
||||
|
||||
constructor (element: string, options?: IScrollOptions);
|
||||
constructor (element: HTMLElement, options?: IScrollOptions);
|
||||
|
||||
destroy(): void;
|
||||
refresh(): void;
|
||||
scrollTo(x: number, y: number, time?: number, relative?: boolean): void;
|
||||
scrollToElement(element: string, time?: number): void;
|
||||
scrollToElement(element: HTMLElement, time?: number): void;
|
||||
goToPage(pageX: number, pageY: number, time?: number): void;
|
||||
disable(): void;
|
||||
enable(): void;
|
||||
stop(): void;
|
||||
zoom(x: number, y: number, scale: number, time?: number): void;
|
||||
isReady(): boolean;
|
||||
|
||||
// Events
|
||||
on: (type: string, fn: () => void) => void;
|
||||
}
|
||||
// Type definitions for iScroll 5
|
||||
// Project: http://cubiq.org/iscroll-5-ready-for-beta-test
|
||||
// Definitions by: Christiaan Rakowski <https://github.com/csrakowski/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface IScrollOptions {
|
||||
//hScroll?: boolean;
|
||||
//vScroll?: boolean;
|
||||
x?: number;
|
||||
y?: number;
|
||||
bounce?: boolean;
|
||||
bounceLock?: boolean;
|
||||
momentum?: boolean;
|
||||
lockDirection?: boolean;
|
||||
useTransform?: boolean;
|
||||
useTransition?: boolean;
|
||||
topOffset?: number;
|
||||
checkDOMChanges?: boolean;
|
||||
handleClick?: boolean;
|
||||
|
||||
// Scrollbar
|
||||
hScrollbar?: boolean;
|
||||
vScrollbar?: boolean;
|
||||
fixedScrollbar?: boolean;
|
||||
hideScrollbar?: boolean;
|
||||
fadeScrollbar?: boolean;
|
||||
scrollbarClass?: string;
|
||||
|
||||
// Zoom
|
||||
zoom?: boolean;
|
||||
zoomMin?: number;
|
||||
zoomMax?: number;
|
||||
doubleTapZoom?: number;
|
||||
wheelAction?: string;
|
||||
|
||||
|
||||
///String or boolean
|
||||
snap?: any;
|
||||
snapThreshold?: number;
|
||||
|
||||
//new in IScroll 5?
|
||||
|
||||
resizeIndicator?: boolean;
|
||||
mouseWheelSpeed?: number;
|
||||
startX?: number;
|
||||
startY?: number;
|
||||
scrollX?: boolean;
|
||||
scrollY?: boolean;
|
||||
directionLockThreshold?: number;
|
||||
|
||||
bounceTime?: number;
|
||||
|
||||
///String or function
|
||||
bounceEasing?: any;
|
||||
|
||||
preventDefault?: boolean;
|
||||
preventDefaultException?: boolean;
|
||||
|
||||
HWCompositing?: boolean;
|
||||
|
||||
freeScroll?: boolean;
|
||||
|
||||
resizePolling?: number;
|
||||
tap?: boolean;
|
||||
click?: boolean;
|
||||
invertWheelDirection?: boolean;
|
||||
|
||||
///Boolean or string
|
||||
eventPassthrough?: any;
|
||||
}
|
||||
|
||||
declare class IScroll {
|
||||
|
||||
constructor (element: string, options?: IScrollOptions);
|
||||
constructor (element: HTMLElement, options?: IScrollOptions);
|
||||
|
||||
destroy(): void;
|
||||
refresh(): void;
|
||||
scrollTo(x: number, y: number, time?: number, relative?: boolean): void;
|
||||
scrollToElement(element: string, time?: number): void;
|
||||
scrollToElement(element: HTMLElement, time?: number): void;
|
||||
goToPage(pageX: number, pageY: number, time?: number): void;
|
||||
disable(): void;
|
||||
enable(): void;
|
||||
stop(): void;
|
||||
zoom(x: number, y: number, scale: number, time?: number): void;
|
||||
isReady(): boolean;
|
||||
|
||||
// Events
|
||||
on: (type: string, fn: () => void) => void;
|
||||
}
|
||||
|
||||
992
jasmine/jasmine.d.ts
vendored
992
jasmine/jasmine.d.ts
vendored
@@ -1,496 +1,496 @@
|
||||
// Type definitions for Jasmine 2.2
|
||||
// Project: http://jasmine.github.io/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb>, David Pärsson <https://github.com/davidparsson/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
// For ddescribe / iit use : https://github.com/borisyankov/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
|
||||
|
||||
declare function describe(description: string, specDefinitions: () => void): void;
|
||||
declare function fdescribe(description: string, specDefinitions: () => void): void;
|
||||
declare function xdescribe(description: string, specDefinitions: () => void): void;
|
||||
|
||||
declare function it(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function it(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
|
||||
/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
|
||||
declare function pending(reason?: string): void;
|
||||
|
||||
declare function beforeEach(action: () => void, timeout?: number): void;
|
||||
declare function beforeEach(action: (done: () => void) => void, timeout?: number): void;
|
||||
declare function afterEach(action: () => void, timeout?: number): void;
|
||||
declare function afterEach(action: (done: () => void) => void, timeout?: number): void;
|
||||
|
||||
declare function beforeAll(action: () => void, timeout?: number): void;
|
||||
declare function beforeAll(action: (done: () => void) => void, timeout?: number): void;
|
||||
declare function afterAll(action: () => void, timeout?: number): void;
|
||||
declare function afterAll(action: (done: () => void) => void, timeout?: number): void;
|
||||
|
||||
declare function expect(spy: Function): jasmine.Matchers;
|
||||
declare function expect(actual: any): jasmine.Matchers;
|
||||
|
||||
declare function fail(e?: any): void;
|
||||
|
||||
declare function spyOn(object: any, method: string): jasmine.Spy;
|
||||
|
||||
declare function runs(asyncMethod: Function): void;
|
||||
declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
|
||||
declare function waits(timeout?: number): void;
|
||||
|
||||
declare module jasmine {
|
||||
|
||||
var clock: () => Clock;
|
||||
|
||||
function any(aclass: any): Any;
|
||||
function anything(): Any;
|
||||
function arrayContaining(sample: any[]): ArrayContaining;
|
||||
function objectContaining(sample: any): ObjectContaining;
|
||||
function createSpy(name: string, originalFn?: Function): Spy;
|
||||
function createSpyObj(baseName: string, methodNames: any[]): any;
|
||||
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
|
||||
function pp(value: any): string;
|
||||
function getEnv(): Env;
|
||||
function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
||||
function addMatchers(matchers: CustomMatcherFactories): void;
|
||||
function stringMatching(str: string): Any;
|
||||
function stringMatching(str: RegExp): Any;
|
||||
|
||||
interface Any {
|
||||
|
||||
new (expectedClass: any): any;
|
||||
|
||||
jasmineMatches(other: any): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
// taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
|
||||
interface ArrayLike<T> {
|
||||
length: number;
|
||||
[n: number]: T;
|
||||
}
|
||||
|
||||
interface ArrayContaining {
|
||||
new (sample: any[]): any;
|
||||
|
||||
asymmetricMatch(other: any): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
interface ObjectContaining {
|
||||
new (sample: any): any;
|
||||
|
||||
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
interface Block {
|
||||
|
||||
new (env: Env, func: SpecFunction, spec: Spec): any;
|
||||
|
||||
execute(onComplete: () => void): void;
|
||||
}
|
||||
|
||||
interface WaitsBlock extends Block {
|
||||
new (env: Env, timeout: number, spec: Spec): any;
|
||||
}
|
||||
|
||||
interface WaitsForBlock extends Block {
|
||||
new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
|
||||
}
|
||||
|
||||
interface Clock {
|
||||
install(): void;
|
||||
uninstall(): void;
|
||||
/** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
|
||||
tick(ms: number): void;
|
||||
mockDate(date?: Date): void;
|
||||
}
|
||||
|
||||
interface CustomEqualityTester {
|
||||
(first: any, second: any): boolean;
|
||||
}
|
||||
|
||||
interface CustomMatcher {
|
||||
compare<T>(actual: T, expected: T): CustomMatcherResult;
|
||||
compare(actual: any, expected: any): CustomMatcherResult;
|
||||
}
|
||||
|
||||
interface CustomMatcherFactory {
|
||||
(util: MatchersUtil, customEqualityTesters: Array<CustomEqualityTester>): CustomMatcher;
|
||||
}
|
||||
|
||||
interface CustomMatcherFactories {
|
||||
[index: string]: CustomMatcherFactory;
|
||||
}
|
||||
|
||||
interface CustomMatcherResult {
|
||||
pass: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
interface MatchersUtil {
|
||||
equals(a: any, b: any, customTesters?: Array<CustomEqualityTester>): boolean;
|
||||
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: Array<CustomEqualityTester>): boolean;
|
||||
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array<any>): string;
|
||||
}
|
||||
|
||||
interface Env {
|
||||
setTimeout: any;
|
||||
clearTimeout: void;
|
||||
setInterval: any;
|
||||
clearInterval: void;
|
||||
updateInterval: number;
|
||||
|
||||
currentSpec: Spec;
|
||||
|
||||
matchersClass: Matchers;
|
||||
|
||||
version(): any;
|
||||
versionString(): string;
|
||||
nextSpecId(): number;
|
||||
addReporter(reporter: Reporter): void;
|
||||
execute(): void;
|
||||
describe(description: string, specDefinitions: () => void): Suite;
|
||||
// ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
|
||||
beforeEach(beforeEachFunction: () => void): void;
|
||||
beforeAll(beforeAllFunction: () => void): void;
|
||||
currentRunner(): Runner;
|
||||
afterEach(afterEachFunction: () => void): void;
|
||||
afterAll(afterAllFunction: () => void): void;
|
||||
xdescribe(desc: string, specDefinitions: () => void): XSuite;
|
||||
it(description: string, func: () => void): Spec;
|
||||
// iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
|
||||
xit(desc: string, func: () => void): XSpec;
|
||||
compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
contains_(haystack: any, needle: any): boolean;
|
||||
addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
||||
addMatchers(matchers: CustomMatcherFactories): void;
|
||||
specFilter(spec: Spec): boolean;
|
||||
}
|
||||
|
||||
interface FakeTimer {
|
||||
|
||||
new (): any;
|
||||
|
||||
reset(): void;
|
||||
tick(millis: number): void;
|
||||
runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
|
||||
scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
|
||||
}
|
||||
|
||||
interface HtmlReporter {
|
||||
new (): any;
|
||||
}
|
||||
|
||||
interface HtmlSpecFilter {
|
||||
new (): any;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface NestedResults extends Result {
|
||||
description: string;
|
||||
|
||||
totalCount: number;
|
||||
passedCount: number;
|
||||
failedCount: number;
|
||||
|
||||
skipped: boolean;
|
||||
|
||||
rollupCounts(result: NestedResults): void;
|
||||
log(values: any): void;
|
||||
getItems(): Result[];
|
||||
addResult(result: Result): void;
|
||||
passed(): boolean;
|
||||
}
|
||||
|
||||
interface MessageResult extends Result {
|
||||
values: any;
|
||||
trace: Trace;
|
||||
}
|
||||
|
||||
interface ExpectationResult extends Result {
|
||||
matcherName: string;
|
||||
passed(): boolean;
|
||||
expected: any;
|
||||
actual: any;
|
||||
message: string;
|
||||
trace: Trace;
|
||||
}
|
||||
|
||||
interface Trace {
|
||||
name: string;
|
||||
message: string;
|
||||
stack: any;
|
||||
}
|
||||
|
||||
interface PrettyPrinter {
|
||||
|
||||
new (): any;
|
||||
|
||||
format(value: any): void;
|
||||
iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
|
||||
emitScalar(value: any): void;
|
||||
emitString(value: string): void;
|
||||
emitArray(array: any[]): void;
|
||||
emitObject(obj: any): void;
|
||||
append(value: any): void;
|
||||
}
|
||||
|
||||
interface StringPrettyPrinter extends PrettyPrinter {
|
||||
}
|
||||
|
||||
interface Queue {
|
||||
|
||||
new (env: any): any;
|
||||
|
||||
env: Env;
|
||||
ensured: boolean[];
|
||||
blocks: Block[];
|
||||
running: boolean;
|
||||
index: number;
|
||||
offset: number;
|
||||
abort: boolean;
|
||||
|
||||
addBefore(block: Block, ensure?: boolean): void;
|
||||
add(block: any, ensure?: boolean): void;
|
||||
insertNext(block: any, ensure?: boolean): void;
|
||||
start(onComplete?: () => void): void;
|
||||
isRunning(): boolean;
|
||||
next_(): void;
|
||||
results(): NestedResults;
|
||||
}
|
||||
|
||||
interface Matchers {
|
||||
|
||||
new (env: Env, actual: any, spec: Env, isNot?: boolean): any;
|
||||
|
||||
env: Env;
|
||||
actual: any;
|
||||
spec: Env;
|
||||
isNot?: boolean;
|
||||
message(): any;
|
||||
|
||||
toBe(expected: any, expectationFailOutput?: any): boolean;
|
||||
toEqual(expected: any, expectationFailOutput?: any): boolean;
|
||||
toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean;
|
||||
toBeDefined(expectationFailOutput?: any): boolean;
|
||||
toBeUndefined(expectationFailOutput?: any): boolean;
|
||||
toBeNull(expectationFailOutput?: any): boolean;
|
||||
toBeNaN(): boolean;
|
||||
toBeTruthy(expectationFailOutput?: any): boolean;
|
||||
toBeFalsy(expectationFailOutput?: any): boolean;
|
||||
toHaveBeenCalled(): boolean;
|
||||
toHaveBeenCalledWith(...params: any[]): boolean;
|
||||
toHaveBeenCalledTimes(expected: number): boolean;
|
||||
toContain(expected: any, expectationFailOutput?: any): boolean;
|
||||
toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean;
|
||||
toThrow(expected?: any): boolean;
|
||||
toThrowError(message?: string | RegExp): boolean;
|
||||
toThrowError(expected?: Error, message?: string | RegExp): boolean;
|
||||
not: Matchers;
|
||||
|
||||
Any: Any;
|
||||
}
|
||||
|
||||
interface Reporter {
|
||||
reportRunnerStarting(runner: Runner): void;
|
||||
reportRunnerResults(runner: Runner): void;
|
||||
reportSuiteResults(suite: Suite): void;
|
||||
reportSpecStarting(spec: Spec): void;
|
||||
reportSpecResults(spec: Spec): void;
|
||||
log(str: string): void;
|
||||
}
|
||||
|
||||
interface MultiReporter extends Reporter {
|
||||
addReporter(reporter: Reporter): void;
|
||||
}
|
||||
|
||||
interface Runner {
|
||||
|
||||
new (env: Env): any;
|
||||
|
||||
execute(): void;
|
||||
beforeEach(beforeEachFunction: SpecFunction): void;
|
||||
afterEach(afterEachFunction: SpecFunction): void;
|
||||
beforeAll(beforeAllFunction: SpecFunction): void;
|
||||
afterAll(afterAllFunction: SpecFunction): void;
|
||||
finishCallback(): void;
|
||||
addSuite(suite: Suite): void;
|
||||
add(block: Block): void;
|
||||
specs(): Spec[];
|
||||
suites(): Suite[];
|
||||
topLevelSuites(): Suite[];
|
||||
results(): NestedResults;
|
||||
}
|
||||
|
||||
interface SpecFunction {
|
||||
(spec?: Spec): void;
|
||||
}
|
||||
|
||||
interface SuiteOrSpec {
|
||||
id: number;
|
||||
env: Env;
|
||||
description: string;
|
||||
queue: Queue;
|
||||
}
|
||||
|
||||
interface Spec extends SuiteOrSpec {
|
||||
|
||||
new (env: Env, suite: Suite, description: string): any;
|
||||
|
||||
suite: Suite;
|
||||
|
||||
afterCallbacks: SpecFunction[];
|
||||
spies_: Spy[];
|
||||
|
||||
results_: NestedResults;
|
||||
matchersClass: Matchers;
|
||||
|
||||
getFullName(): string;
|
||||
results(): NestedResults;
|
||||
log(arguments: any): any;
|
||||
runs(func: SpecFunction): Spec;
|
||||
addToQueue(block: Block): void;
|
||||
addMatcherResult(result: Result): void;
|
||||
expect(actual: any): any;
|
||||
waits(timeout: number): Spec;
|
||||
waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
|
||||
fail(e?: any): void;
|
||||
getMatchersClass_(): Matchers;
|
||||
addMatchers(matchersPrototype: CustomMatcherFactories): void;
|
||||
finishCallback(): void;
|
||||
finish(onComplete?: () => void): void;
|
||||
after(doAfter: SpecFunction): void;
|
||||
execute(onComplete?: () => void): any;
|
||||
addBeforesAndAftersToQueue(): void;
|
||||
explodes(): void;
|
||||
spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
|
||||
removeAllSpies(): void;
|
||||
}
|
||||
|
||||
interface XSpec {
|
||||
id: number;
|
||||
runs(): void;
|
||||
}
|
||||
|
||||
interface Suite extends SuiteOrSpec {
|
||||
|
||||
new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
|
||||
|
||||
parentSuite: Suite;
|
||||
|
||||
getFullName(): string;
|
||||
finish(onComplete?: () => void): void;
|
||||
beforeEach(beforeEachFunction: SpecFunction): void;
|
||||
afterEach(afterEachFunction: SpecFunction): void;
|
||||
beforeAll(beforeAllFunction: SpecFunction): void;
|
||||
afterAll(afterAllFunction: SpecFunction): void;
|
||||
results(): NestedResults;
|
||||
add(suiteOrSpec: SuiteOrSpec): void;
|
||||
specs(): Spec[];
|
||||
suites(): Suite[];
|
||||
children(): any[];
|
||||
execute(onComplete?: () => void): void;
|
||||
}
|
||||
|
||||
interface XSuite {
|
||||
execute(): void;
|
||||
}
|
||||
|
||||
interface Spy {
|
||||
(...params: any[]): any;
|
||||
|
||||
identity: string;
|
||||
and: SpyAnd;
|
||||
calls: Calls;
|
||||
mostRecentCall: { args: any[]; };
|
||||
argsForCall: any[];
|
||||
wasCalled: boolean;
|
||||
}
|
||||
|
||||
interface SpyAnd {
|
||||
/** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
|
||||
callThrough(): Spy;
|
||||
/** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
|
||||
returnValue(val: any): Spy;
|
||||
/** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
|
||||
callFake(fn: Function): Spy;
|
||||
/** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
|
||||
throwError(msg: string): Spy;
|
||||
/** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
|
||||
stub(): Spy;
|
||||
}
|
||||
|
||||
interface Calls {
|
||||
/** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/
|
||||
any(): boolean;
|
||||
/** By chaining the spy with calls.count(), will return the number of times the spy was called **/
|
||||
count(): number;
|
||||
/** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/
|
||||
argsFor(index: number): any[];
|
||||
/** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/
|
||||
allArgs(): any[];
|
||||
/** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/
|
||||
all(): CallInfo[];
|
||||
/** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/
|
||||
mostRecent(): CallInfo;
|
||||
/** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/
|
||||
first(): CallInfo;
|
||||
/** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
interface CallInfo {
|
||||
/** The context (the this) for the call */
|
||||
object: any;
|
||||
/** All arguments passed to the call */
|
||||
args: any[];
|
||||
}
|
||||
|
||||
interface Util {
|
||||
inherit(childClass: Function, parentClass: Function): any;
|
||||
formatException(e: any): any;
|
||||
htmlEscape(str: string): string;
|
||||
argsToArray(args: any): any;
|
||||
extend(destination: any, source: any): any;
|
||||
}
|
||||
|
||||
interface JsApiReporter extends Reporter {
|
||||
|
||||
started: boolean;
|
||||
finished: boolean;
|
||||
result: any;
|
||||
messages: any;
|
||||
|
||||
new (): any;
|
||||
|
||||
suites(): Suite[];
|
||||
summarize_(suiteOrSpec: SuiteOrSpec): any;
|
||||
results(): any;
|
||||
resultsForSpec(specId: any): any;
|
||||
log(str: any): any;
|
||||
resultsForSpecs(specIds: any): any;
|
||||
summarizeResult_(result: any): any;
|
||||
}
|
||||
|
||||
interface Jasmine {
|
||||
Spec: Spec;
|
||||
clock: Clock;
|
||||
util: Util;
|
||||
}
|
||||
|
||||
export var HtmlReporter: HtmlReporter;
|
||||
export var HtmlSpecFilter: HtmlSpecFilter;
|
||||
export var DEFAULT_TIMEOUT_INTERVAL: number;
|
||||
}
|
||||
// Type definitions for Jasmine 2.2
|
||||
// Project: http://jasmine.github.io/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb>, David Pärsson <https://github.com/davidparsson/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
// For ddescribe / iit use : https://github.com/borisyankov/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
|
||||
|
||||
declare function describe(description: string, specDefinitions: () => void): void;
|
||||
declare function fdescribe(description: string, specDefinitions: () => void): void;
|
||||
declare function xdescribe(description: string, specDefinitions: () => void): void;
|
||||
|
||||
declare function it(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function it(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function fit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: () => void, timeout?: number): void;
|
||||
declare function xit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void;
|
||||
|
||||
/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
|
||||
declare function pending(reason?: string): void;
|
||||
|
||||
declare function beforeEach(action: () => void, timeout?: number): void;
|
||||
declare function beforeEach(action: (done: () => void) => void, timeout?: number): void;
|
||||
declare function afterEach(action: () => void, timeout?: number): void;
|
||||
declare function afterEach(action: (done: () => void) => void, timeout?: number): void;
|
||||
|
||||
declare function beforeAll(action: () => void, timeout?: number): void;
|
||||
declare function beforeAll(action: (done: () => void) => void, timeout?: number): void;
|
||||
declare function afterAll(action: () => void, timeout?: number): void;
|
||||
declare function afterAll(action: (done: () => void) => void, timeout?: number): void;
|
||||
|
||||
declare function expect(spy: Function): jasmine.Matchers;
|
||||
declare function expect(actual: any): jasmine.Matchers;
|
||||
|
||||
declare function fail(e?: any): void;
|
||||
|
||||
declare function spyOn(object: any, method: string): jasmine.Spy;
|
||||
|
||||
declare function runs(asyncMethod: Function): void;
|
||||
declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
|
||||
declare function waits(timeout?: number): void;
|
||||
|
||||
declare module jasmine {
|
||||
|
||||
var clock: () => Clock;
|
||||
|
||||
function any(aclass: any): Any;
|
||||
function anything(): Any;
|
||||
function arrayContaining(sample: any[]): ArrayContaining;
|
||||
function objectContaining(sample: any): ObjectContaining;
|
||||
function createSpy(name: string, originalFn?: Function): Spy;
|
||||
function createSpyObj(baseName: string, methodNames: any[]): any;
|
||||
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
|
||||
function pp(value: any): string;
|
||||
function getEnv(): Env;
|
||||
function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
||||
function addMatchers(matchers: CustomMatcherFactories): void;
|
||||
function stringMatching(str: string): Any;
|
||||
function stringMatching(str: RegExp): Any;
|
||||
|
||||
interface Any {
|
||||
|
||||
new (expectedClass: any): any;
|
||||
|
||||
jasmineMatches(other: any): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
// taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
|
||||
interface ArrayLike<T> {
|
||||
length: number;
|
||||
[n: number]: T;
|
||||
}
|
||||
|
||||
interface ArrayContaining {
|
||||
new (sample: any[]): any;
|
||||
|
||||
asymmetricMatch(other: any): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
interface ObjectContaining {
|
||||
new (sample: any): any;
|
||||
|
||||
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
interface Block {
|
||||
|
||||
new (env: Env, func: SpecFunction, spec: Spec): any;
|
||||
|
||||
execute(onComplete: () => void): void;
|
||||
}
|
||||
|
||||
interface WaitsBlock extends Block {
|
||||
new (env: Env, timeout: number, spec: Spec): any;
|
||||
}
|
||||
|
||||
interface WaitsForBlock extends Block {
|
||||
new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
|
||||
}
|
||||
|
||||
interface Clock {
|
||||
install(): void;
|
||||
uninstall(): void;
|
||||
/** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
|
||||
tick(ms: number): void;
|
||||
mockDate(date?: Date): void;
|
||||
}
|
||||
|
||||
interface CustomEqualityTester {
|
||||
(first: any, second: any): boolean;
|
||||
}
|
||||
|
||||
interface CustomMatcher {
|
||||
compare<T>(actual: T, expected: T): CustomMatcherResult;
|
||||
compare(actual: any, expected: any): CustomMatcherResult;
|
||||
}
|
||||
|
||||
interface CustomMatcherFactory {
|
||||
(util: MatchersUtil, customEqualityTesters: Array<CustomEqualityTester>): CustomMatcher;
|
||||
}
|
||||
|
||||
interface CustomMatcherFactories {
|
||||
[index: string]: CustomMatcherFactory;
|
||||
}
|
||||
|
||||
interface CustomMatcherResult {
|
||||
pass: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
interface MatchersUtil {
|
||||
equals(a: any, b: any, customTesters?: Array<CustomEqualityTester>): boolean;
|
||||
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: Array<CustomEqualityTester>): boolean;
|
||||
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array<any>): string;
|
||||
}
|
||||
|
||||
interface Env {
|
||||
setTimeout: any;
|
||||
clearTimeout: void;
|
||||
setInterval: any;
|
||||
clearInterval: void;
|
||||
updateInterval: number;
|
||||
|
||||
currentSpec: Spec;
|
||||
|
||||
matchersClass: Matchers;
|
||||
|
||||
version(): any;
|
||||
versionString(): string;
|
||||
nextSpecId(): number;
|
||||
addReporter(reporter: Reporter): void;
|
||||
execute(): void;
|
||||
describe(description: string, specDefinitions: () => void): Suite;
|
||||
// ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
|
||||
beforeEach(beforeEachFunction: () => void): void;
|
||||
beforeAll(beforeAllFunction: () => void): void;
|
||||
currentRunner(): Runner;
|
||||
afterEach(afterEachFunction: () => void): void;
|
||||
afterAll(afterAllFunction: () => void): void;
|
||||
xdescribe(desc: string, specDefinitions: () => void): XSuite;
|
||||
it(description: string, func: () => void): Spec;
|
||||
// iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
|
||||
xit(desc: string, func: () => void): XSpec;
|
||||
compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
||||
contains_(haystack: any, needle: any): boolean;
|
||||
addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
||||
addMatchers(matchers: CustomMatcherFactories): void;
|
||||
specFilter(spec: Spec): boolean;
|
||||
}
|
||||
|
||||
interface FakeTimer {
|
||||
|
||||
new (): any;
|
||||
|
||||
reset(): void;
|
||||
tick(millis: number): void;
|
||||
runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
|
||||
scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
|
||||
}
|
||||
|
||||
interface HtmlReporter {
|
||||
new (): any;
|
||||
}
|
||||
|
||||
interface HtmlSpecFilter {
|
||||
new (): any;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface NestedResults extends Result {
|
||||
description: string;
|
||||
|
||||
totalCount: number;
|
||||
passedCount: number;
|
||||
failedCount: number;
|
||||
|
||||
skipped: boolean;
|
||||
|
||||
rollupCounts(result: NestedResults): void;
|
||||
log(values: any): void;
|
||||
getItems(): Result[];
|
||||
addResult(result: Result): void;
|
||||
passed(): boolean;
|
||||
}
|
||||
|
||||
interface MessageResult extends Result {
|
||||
values: any;
|
||||
trace: Trace;
|
||||
}
|
||||
|
||||
interface ExpectationResult extends Result {
|
||||
matcherName: string;
|
||||
passed(): boolean;
|
||||
expected: any;
|
||||
actual: any;
|
||||
message: string;
|
||||
trace: Trace;
|
||||
}
|
||||
|
||||
interface Trace {
|
||||
name: string;
|
||||
message: string;
|
||||
stack: any;
|
||||
}
|
||||
|
||||
interface PrettyPrinter {
|
||||
|
||||
new (): any;
|
||||
|
||||
format(value: any): void;
|
||||
iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
|
||||
emitScalar(value: any): void;
|
||||
emitString(value: string): void;
|
||||
emitArray(array: any[]): void;
|
||||
emitObject(obj: any): void;
|
||||
append(value: any): void;
|
||||
}
|
||||
|
||||
interface StringPrettyPrinter extends PrettyPrinter {
|
||||
}
|
||||
|
||||
interface Queue {
|
||||
|
||||
new (env: any): any;
|
||||
|
||||
env: Env;
|
||||
ensured: boolean[];
|
||||
blocks: Block[];
|
||||
running: boolean;
|
||||
index: number;
|
||||
offset: number;
|
||||
abort: boolean;
|
||||
|
||||
addBefore(block: Block, ensure?: boolean): void;
|
||||
add(block: any, ensure?: boolean): void;
|
||||
insertNext(block: any, ensure?: boolean): void;
|
||||
start(onComplete?: () => void): void;
|
||||
isRunning(): boolean;
|
||||
next_(): void;
|
||||
results(): NestedResults;
|
||||
}
|
||||
|
||||
interface Matchers {
|
||||
|
||||
new (env: Env, actual: any, spec: Env, isNot?: boolean): any;
|
||||
|
||||
env: Env;
|
||||
actual: any;
|
||||
spec: Env;
|
||||
isNot?: boolean;
|
||||
message(): any;
|
||||
|
||||
toBe(expected: any, expectationFailOutput?: any): boolean;
|
||||
toEqual(expected: any, expectationFailOutput?: any): boolean;
|
||||
toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean;
|
||||
toBeDefined(expectationFailOutput?: any): boolean;
|
||||
toBeUndefined(expectationFailOutput?: any): boolean;
|
||||
toBeNull(expectationFailOutput?: any): boolean;
|
||||
toBeNaN(): boolean;
|
||||
toBeTruthy(expectationFailOutput?: any): boolean;
|
||||
toBeFalsy(expectationFailOutput?: any): boolean;
|
||||
toHaveBeenCalled(): boolean;
|
||||
toHaveBeenCalledWith(...params: any[]): boolean;
|
||||
toHaveBeenCalledTimes(expected: number): boolean;
|
||||
toContain(expected: any, expectationFailOutput?: any): boolean;
|
||||
toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean;
|
||||
toThrow(expected?: any): boolean;
|
||||
toThrowError(message?: string | RegExp): boolean;
|
||||
toThrowError(expected?: Error, message?: string | RegExp): boolean;
|
||||
not: Matchers;
|
||||
|
||||
Any: Any;
|
||||
}
|
||||
|
||||
interface Reporter {
|
||||
reportRunnerStarting(runner: Runner): void;
|
||||
reportRunnerResults(runner: Runner): void;
|
||||
reportSuiteResults(suite: Suite): void;
|
||||
reportSpecStarting(spec: Spec): void;
|
||||
reportSpecResults(spec: Spec): void;
|
||||
log(str: string): void;
|
||||
}
|
||||
|
||||
interface MultiReporter extends Reporter {
|
||||
addReporter(reporter: Reporter): void;
|
||||
}
|
||||
|
||||
interface Runner {
|
||||
|
||||
new (env: Env): any;
|
||||
|
||||
execute(): void;
|
||||
beforeEach(beforeEachFunction: SpecFunction): void;
|
||||
afterEach(afterEachFunction: SpecFunction): void;
|
||||
beforeAll(beforeAllFunction: SpecFunction): void;
|
||||
afterAll(afterAllFunction: SpecFunction): void;
|
||||
finishCallback(): void;
|
||||
addSuite(suite: Suite): void;
|
||||
add(block: Block): void;
|
||||
specs(): Spec[];
|
||||
suites(): Suite[];
|
||||
topLevelSuites(): Suite[];
|
||||
results(): NestedResults;
|
||||
}
|
||||
|
||||
interface SpecFunction {
|
||||
(spec?: Spec): void;
|
||||
}
|
||||
|
||||
interface SuiteOrSpec {
|
||||
id: number;
|
||||
env: Env;
|
||||
description: string;
|
||||
queue: Queue;
|
||||
}
|
||||
|
||||
interface Spec extends SuiteOrSpec {
|
||||
|
||||
new (env: Env, suite: Suite, description: string): any;
|
||||
|
||||
suite: Suite;
|
||||
|
||||
afterCallbacks: SpecFunction[];
|
||||
spies_: Spy[];
|
||||
|
||||
results_: NestedResults;
|
||||
matchersClass: Matchers;
|
||||
|
||||
getFullName(): string;
|
||||
results(): NestedResults;
|
||||
log(arguments: any): any;
|
||||
runs(func: SpecFunction): Spec;
|
||||
addToQueue(block: Block): void;
|
||||
addMatcherResult(result: Result): void;
|
||||
expect(actual: any): any;
|
||||
waits(timeout: number): Spec;
|
||||
waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
|
||||
fail(e?: any): void;
|
||||
getMatchersClass_(): Matchers;
|
||||
addMatchers(matchersPrototype: CustomMatcherFactories): void;
|
||||
finishCallback(): void;
|
||||
finish(onComplete?: () => void): void;
|
||||
after(doAfter: SpecFunction): void;
|
||||
execute(onComplete?: () => void): any;
|
||||
addBeforesAndAftersToQueue(): void;
|
||||
explodes(): void;
|
||||
spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
|
||||
removeAllSpies(): void;
|
||||
}
|
||||
|
||||
interface XSpec {
|
||||
id: number;
|
||||
runs(): void;
|
||||
}
|
||||
|
||||
interface Suite extends SuiteOrSpec {
|
||||
|
||||
new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
|
||||
|
||||
parentSuite: Suite;
|
||||
|
||||
getFullName(): string;
|
||||
finish(onComplete?: () => void): void;
|
||||
beforeEach(beforeEachFunction: SpecFunction): void;
|
||||
afterEach(afterEachFunction: SpecFunction): void;
|
||||
beforeAll(beforeAllFunction: SpecFunction): void;
|
||||
afterAll(afterAllFunction: SpecFunction): void;
|
||||
results(): NestedResults;
|
||||
add(suiteOrSpec: SuiteOrSpec): void;
|
||||
specs(): Spec[];
|
||||
suites(): Suite[];
|
||||
children(): any[];
|
||||
execute(onComplete?: () => void): void;
|
||||
}
|
||||
|
||||
interface XSuite {
|
||||
execute(): void;
|
||||
}
|
||||
|
||||
interface Spy {
|
||||
(...params: any[]): any;
|
||||
|
||||
identity: string;
|
||||
and: SpyAnd;
|
||||
calls: Calls;
|
||||
mostRecentCall: { args: any[]; };
|
||||
argsForCall: any[];
|
||||
wasCalled: boolean;
|
||||
}
|
||||
|
||||
interface SpyAnd {
|
||||
/** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
|
||||
callThrough(): Spy;
|
||||
/** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
|
||||
returnValue(val: any): Spy;
|
||||
/** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
|
||||
callFake(fn: Function): Spy;
|
||||
/** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
|
||||
throwError(msg: string): Spy;
|
||||
/** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
|
||||
stub(): Spy;
|
||||
}
|
||||
|
||||
interface Calls {
|
||||
/** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/
|
||||
any(): boolean;
|
||||
/** By chaining the spy with calls.count(), will return the number of times the spy was called **/
|
||||
count(): number;
|
||||
/** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/
|
||||
argsFor(index: number): any[];
|
||||
/** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/
|
||||
allArgs(): any[];
|
||||
/** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/
|
||||
all(): CallInfo[];
|
||||
/** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/
|
||||
mostRecent(): CallInfo;
|
||||
/** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/
|
||||
first(): CallInfo;
|
||||
/** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
interface CallInfo {
|
||||
/** The context (the this) for the call */
|
||||
object: any;
|
||||
/** All arguments passed to the call */
|
||||
args: any[];
|
||||
}
|
||||
|
||||
interface Util {
|
||||
inherit(childClass: Function, parentClass: Function): any;
|
||||
formatException(e: any): any;
|
||||
htmlEscape(str: string): string;
|
||||
argsToArray(args: any): any;
|
||||
extend(destination: any, source: any): any;
|
||||
}
|
||||
|
||||
interface JsApiReporter extends Reporter {
|
||||
|
||||
started: boolean;
|
||||
finished: boolean;
|
||||
result: any;
|
||||
messages: any;
|
||||
|
||||
new (): any;
|
||||
|
||||
suites(): Suite[];
|
||||
summarize_(suiteOrSpec: SuiteOrSpec): any;
|
||||
results(): any;
|
||||
resultsForSpec(specId: any): any;
|
||||
log(str: any): any;
|
||||
resultsForSpecs(specIds: any): any;
|
||||
summarizeResult_(result: any): any;
|
||||
}
|
||||
|
||||
interface Jasmine {
|
||||
Spec: Spec;
|
||||
clock: Clock;
|
||||
util: Util;
|
||||
}
|
||||
|
||||
export var HtmlReporter: HtmlReporter;
|
||||
export var HtmlSpecFilter: HtmlSpecFilter;
|
||||
export var DEFAULT_TIMEOUT_INTERVAL: number;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ mapping.fromJS(inputJSON, {
|
||||
return mapping.fromJS(options.data);
|
||||
},
|
||||
update: (options: KnockoutMappingUpdateOptions) => {
|
||||
return mapping.fromJS(options.data, options.target);
|
||||
return mapping.fromJS(options.data, options.target);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
136
knockout.mapping/knockout.mapping.d.ts
vendored
136
knockout.mapping/knockout.mapping.d.ts
vendored
@@ -1,68 +1,68 @@
|
||||
// Type definitions for Knockout.Mapping 2.0
|
||||
// Project: https://github.com/SteveSanderson/knockout.mapping
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
interface KnockoutMappingCreateOptions {
|
||||
data: any;
|
||||
parent: any;
|
||||
}
|
||||
|
||||
interface KnockoutMappingUpdateOptions {
|
||||
data: any;
|
||||
parent: any;
|
||||
target: any;
|
||||
observable?: KnockoutObservable<any>;
|
||||
}
|
||||
|
||||
interface KnockoutMappingOptions {
|
||||
ignore?: string[];
|
||||
include?: string[];
|
||||
copy?: string[];
|
||||
mappedProperties?: string[];
|
||||
deferEvaluation?: boolean;
|
||||
create?: (options: KnockoutMappingCreateOptions) => void;
|
||||
update?: (options: KnockoutMappingUpdateOptions) => void;
|
||||
key?: (data: any) => any;
|
||||
}
|
||||
|
||||
interface KnockoutMapping {
|
||||
isMapped(viewModel: any): boolean;
|
||||
fromJS(jsObject: any): any;
|
||||
fromJS(jsObject: any, targetOrOptions: any): any;
|
||||
fromJS(jsObject: any, inputOptions: any, target: any): any;
|
||||
fromJSON(jsonString: string): any;
|
||||
fromJSON(jsonString: string, targetOrOptions: any): any;
|
||||
fromJSON(jsonString: string, inputOptions: any, target: any): any;
|
||||
toJS(rootObject: any, options?: KnockoutMappingOptions): any;
|
||||
toJSON(rootObject: any, options?: KnockoutMappingOptions): any;
|
||||
defaultOptions(): KnockoutMappingOptions;
|
||||
resetDefaultOptions(): void;
|
||||
getType(x: any): any;
|
||||
visitModel(rootObject: any, callback: Function, options?: { visitedObjects?: any; parentName?: string; ignore?: string[]; copy?: string[]; include?: string[]; }): any;
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayFunctions<T> {
|
||||
mappedCreate(item: T): T;
|
||||
|
||||
mappedRemove(item: T): T[];
|
||||
mappedRemove(removeFunction: (item: T) => boolean): T[];
|
||||
mappedRemoveAll(items: T[]): T[];
|
||||
mappedRemoveAll(): T[];
|
||||
|
||||
mappedDestroy(item: T): void;
|
||||
mappedDestroy(destroyFunction: (item: T) => boolean): void;
|
||||
mappedDestroyAll(items: T[]): void;
|
||||
mappedDestroyAll(): void;
|
||||
}
|
||||
|
||||
interface KnockoutStatic {
|
||||
mapping: KnockoutMapping;
|
||||
}
|
||||
|
||||
declare module "knockout.mapping" {
|
||||
export = mapping;
|
||||
}
|
||||
declare var mapping: KnockoutMapping;
|
||||
// Type definitions for Knockout.Mapping 2.0
|
||||
// Project: https://github.com/SteveSanderson/knockout.mapping
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
interface KnockoutMappingCreateOptions {
|
||||
data: any;
|
||||
parent: any;
|
||||
}
|
||||
|
||||
interface KnockoutMappingUpdateOptions {
|
||||
data: any;
|
||||
parent: any;
|
||||
target: any;
|
||||
observable?: KnockoutObservable<any>;
|
||||
}
|
||||
|
||||
interface KnockoutMappingOptions {
|
||||
ignore?: string[];
|
||||
include?: string[];
|
||||
copy?: string[];
|
||||
mappedProperties?: string[];
|
||||
deferEvaluation?: boolean;
|
||||
create?: (options: KnockoutMappingCreateOptions) => void;
|
||||
update?: (options: KnockoutMappingUpdateOptions) => void;
|
||||
key?: (data: any) => any;
|
||||
}
|
||||
|
||||
interface KnockoutMapping {
|
||||
isMapped(viewModel: any): boolean;
|
||||
fromJS(jsObject: any): any;
|
||||
fromJS(jsObject: any, targetOrOptions: any): any;
|
||||
fromJS(jsObject: any, inputOptions: any, target: any): any;
|
||||
fromJSON(jsonString: string): any;
|
||||
fromJSON(jsonString: string, targetOrOptions: any): any;
|
||||
fromJSON(jsonString: string, inputOptions: any, target: any): any;
|
||||
toJS(rootObject: any, options?: KnockoutMappingOptions): any;
|
||||
toJSON(rootObject: any, options?: KnockoutMappingOptions): any;
|
||||
defaultOptions(): KnockoutMappingOptions;
|
||||
resetDefaultOptions(): void;
|
||||
getType(x: any): any;
|
||||
visitModel(rootObject: any, callback: Function, options?: { visitedObjects?: any; parentName?: string; ignore?: string[]; copy?: string[]; include?: string[]; }): any;
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayFunctions<T> {
|
||||
mappedCreate(item: T): T;
|
||||
|
||||
mappedRemove(item: T): T[];
|
||||
mappedRemove(removeFunction: (item: T) => boolean): T[];
|
||||
mappedRemoveAll(items: T[]): T[];
|
||||
mappedRemoveAll(): T[];
|
||||
|
||||
mappedDestroy(item: T): void;
|
||||
mappedDestroy(destroyFunction: (item: T) => boolean): void;
|
||||
mappedDestroyAll(items: T[]): void;
|
||||
mappedDestroyAll(): void;
|
||||
}
|
||||
|
||||
interface KnockoutStatic {
|
||||
mapping: KnockoutMapping;
|
||||
}
|
||||
|
||||
declare module "knockout.mapping" {
|
||||
export = mapping;
|
||||
}
|
||||
declare var mapping: KnockoutMapping;
|
||||
|
||||
8712
leaflet/leaflet.d.ts
vendored
8712
leaflet/leaflet.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
--noImplicitAny
|
||||
--noImplicitAny
|
||||
|
||||
12164
threejs/three.d.ts
vendored
12164
threejs/three.d.ts
vendored
File diff suppressed because it is too large
Load Diff
408
webrtc/MediaStream.d.ts
vendored
408
webrtc/MediaStream.d.ts
vendored
@@ -1,204 +1,204 @@
|
||||
// Type definitions for WebRTC
|
||||
// Project: http://dev.w3.org/2011/webrtc/
|
||||
// Definitions by: Ken Smith <https://github.com/smithkl42/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html
|
||||
// version: W3C Editor's Draft 29 June 2015
|
||||
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts" />
|
||||
|
||||
interface ConstrainBooleanParameters {
|
||||
exact?: boolean;
|
||||
ideal?: boolean;
|
||||
}
|
||||
|
||||
interface NumberRange {
|
||||
max?: number;
|
||||
min?: number;
|
||||
}
|
||||
|
||||
interface ConstrainNumberRange extends NumberRange {
|
||||
exact?: number;
|
||||
ideal?: number;
|
||||
}
|
||||
|
||||
interface ConstrainStringParameters {
|
||||
exact?: string | string[];
|
||||
ideal?: string | string[];
|
||||
}
|
||||
|
||||
interface MediaStreamConstraints {
|
||||
video?: boolean | MediaTrackConstraints;
|
||||
audio?: boolean | MediaTrackConstraints;
|
||||
}
|
||||
|
||||
declare module W3C {
|
||||
type LongRange = NumberRange;
|
||||
type DoubleRange = NumberRange;
|
||||
type ConstrainBoolean = boolean | ConstrainBooleanParameters;
|
||||
type ConstrainNumber = number | ConstrainNumberRange;
|
||||
type ConstrainLong = ConstrainNumber;
|
||||
type ConstrainDouble = ConstrainNumber;
|
||||
type ConstrainString = string | string[] | ConstrainStringParameters;
|
||||
}
|
||||
|
||||
interface MediaTrackConstraints extends MediaTrackConstraintSet {
|
||||
advanced?: MediaTrackConstraintSet[];
|
||||
}
|
||||
|
||||
interface MediaTrackConstraintSet {
|
||||
width?: W3C.ConstrainLong;
|
||||
height?: W3C.ConstrainLong;
|
||||
aspectRatio?: W3C.ConstrainDouble;
|
||||
frameRate?: W3C.ConstrainDouble;
|
||||
facingMode?: W3C.ConstrainString;
|
||||
volume?: W3C.ConstrainDouble;
|
||||
sampleRate?: W3C.ConstrainLong;
|
||||
sampleSize?: W3C.ConstrainLong;
|
||||
echoCancellation?: W3C.ConstrainBoolean;
|
||||
latency?: W3C.ConstrainDouble;
|
||||
deviceId?: W3C.ConstrainString;
|
||||
groupId?: W3C.ConstrainString;
|
||||
}
|
||||
|
||||
interface MediaTrackSupportedConstraints {
|
||||
width?: boolean;
|
||||
height?: boolean;
|
||||
aspectRatio?: boolean;
|
||||
frameRate?: boolean;
|
||||
facingMode?: boolean;
|
||||
volume?: boolean;
|
||||
sampleRate?: boolean;
|
||||
sampleSize?: boolean;
|
||||
echoCancellation?: boolean;
|
||||
latency?: boolean;
|
||||
deviceId?: boolean;
|
||||
groupId?: boolean;
|
||||
}
|
||||
|
||||
interface MediaStream extends EventTarget {
|
||||
id: string;
|
||||
active: boolean;
|
||||
|
||||
onactive: EventListener;
|
||||
oninactive: EventListener;
|
||||
onaddtrack: (event: MediaStreamTrackEvent) => any;
|
||||
onremovetrack: (event: MediaStreamTrackEvent) => any;
|
||||
|
||||
clone(): MediaStream;
|
||||
stop(): void;
|
||||
|
||||
getAudioTracks(): MediaStreamTrack[];
|
||||
getVideoTracks(): MediaStreamTrack[];
|
||||
getTracks(): MediaStreamTrack[];
|
||||
|
||||
getTrackById(trackId: string): MediaStreamTrack;
|
||||
|
||||
addTrack(track: MediaStreamTrack): void;
|
||||
removeTrack(track: MediaStreamTrack): void;
|
||||
}
|
||||
|
||||
interface MediaStreamTrackEvent extends Event {
|
||||
track: MediaStreamTrack;
|
||||
}
|
||||
|
||||
declare enum MediaStreamTrackState {
|
||||
"live",
|
||||
"ended"
|
||||
}
|
||||
|
||||
interface MediaStreamTrack extends EventTarget {
|
||||
id: string;
|
||||
kind: string;
|
||||
label: string;
|
||||
enabled: boolean;
|
||||
muted: boolean;
|
||||
remote: boolean;
|
||||
readyState: MediaStreamTrackState;
|
||||
|
||||
onmute: EventListener;
|
||||
onunmute: EventListener;
|
||||
onended: EventListener;
|
||||
onoverconstrained: EventListener;
|
||||
|
||||
clone(): MediaStreamTrack;
|
||||
|
||||
stop(): void;
|
||||
|
||||
getCapabilities(): MediaTrackCapabilities;
|
||||
getConstraints(): MediaTrackConstraints;
|
||||
getSettings(): MediaTrackSettings;
|
||||
applyConstraints(constraints: MediaTrackConstraints): Promise<void>;
|
||||
}
|
||||
|
||||
interface MediaTrackCapabilities {
|
||||
width: number | W3C.LongRange;
|
||||
height: number | W3C.LongRange;
|
||||
aspectRatio: number | W3C.DoubleRange;
|
||||
frameRate: number | W3C.DoubleRange;
|
||||
facingMode: string;
|
||||
volume: number | W3C.DoubleRange;
|
||||
sampleRate: number | W3C.LongRange;
|
||||
sampleSize: number | W3C.LongRange;
|
||||
echoCancellation: boolean[];
|
||||
latency: number | W3C.DoubleRange;
|
||||
deviceId: string;
|
||||
groupId: string;
|
||||
}
|
||||
|
||||
interface MediaTrackSettings {
|
||||
width: number;
|
||||
height: number;
|
||||
aspectRatio: number;
|
||||
frameRate: number;
|
||||
facingMode: string;
|
||||
volume: number;
|
||||
sampleRate: number;
|
||||
sampleSize: number;
|
||||
echoCancellation: boolean;
|
||||
latency: number;
|
||||
deviceId: string;
|
||||
groupId: string;
|
||||
}
|
||||
|
||||
interface MediaStreamError {
|
||||
name: string;
|
||||
message: string;
|
||||
constraintName: string;
|
||||
}
|
||||
|
||||
interface NavigatorGetUserMedia {
|
||||
(constraints: MediaStreamConstraints,
|
||||
successCallback: (stream: MediaStream) => void,
|
||||
errorCallback: (error: MediaStreamError) => void): void;
|
||||
}
|
||||
|
||||
// to use with adapter.js, see: https://github.com/webrtc/adapter
|
||||
declare var getUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
interface Navigator {
|
||||
getUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
webkitGetUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
mozGetUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
msGetUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
mediaDevices: MediaDevices;
|
||||
}
|
||||
|
||||
interface MediaDevices {
|
||||
getSupportedConstraints(): MediaTrackSupportedConstraints;
|
||||
|
||||
getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
|
||||
enumerateDevices(): Promise<MediaDeviceInfo[]>;
|
||||
}
|
||||
|
||||
interface MediaDeviceInfo {
|
||||
label: string;
|
||||
id: string;
|
||||
kind: string;
|
||||
facing: string;
|
||||
}
|
||||
// Type definitions for WebRTC
|
||||
// Project: http://dev.w3.org/2011/webrtc/
|
||||
// Definitions by: Ken Smith <https://github.com/smithkl42/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html
|
||||
// version: W3C Editor's Draft 29 June 2015
|
||||
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts" />
|
||||
|
||||
interface ConstrainBooleanParameters {
|
||||
exact?: boolean;
|
||||
ideal?: boolean;
|
||||
}
|
||||
|
||||
interface NumberRange {
|
||||
max?: number;
|
||||
min?: number;
|
||||
}
|
||||
|
||||
interface ConstrainNumberRange extends NumberRange {
|
||||
exact?: number;
|
||||
ideal?: number;
|
||||
}
|
||||
|
||||
interface ConstrainStringParameters {
|
||||
exact?: string | string[];
|
||||
ideal?: string | string[];
|
||||
}
|
||||
|
||||
interface MediaStreamConstraints {
|
||||
video?: boolean | MediaTrackConstraints;
|
||||
audio?: boolean | MediaTrackConstraints;
|
||||
}
|
||||
|
||||
declare module W3C {
|
||||
type LongRange = NumberRange;
|
||||
type DoubleRange = NumberRange;
|
||||
type ConstrainBoolean = boolean | ConstrainBooleanParameters;
|
||||
type ConstrainNumber = number | ConstrainNumberRange;
|
||||
type ConstrainLong = ConstrainNumber;
|
||||
type ConstrainDouble = ConstrainNumber;
|
||||
type ConstrainString = string | string[] | ConstrainStringParameters;
|
||||
}
|
||||
|
||||
interface MediaTrackConstraints extends MediaTrackConstraintSet {
|
||||
advanced?: MediaTrackConstraintSet[];
|
||||
}
|
||||
|
||||
interface MediaTrackConstraintSet {
|
||||
width?: W3C.ConstrainLong;
|
||||
height?: W3C.ConstrainLong;
|
||||
aspectRatio?: W3C.ConstrainDouble;
|
||||
frameRate?: W3C.ConstrainDouble;
|
||||
facingMode?: W3C.ConstrainString;
|
||||
volume?: W3C.ConstrainDouble;
|
||||
sampleRate?: W3C.ConstrainLong;
|
||||
sampleSize?: W3C.ConstrainLong;
|
||||
echoCancellation?: W3C.ConstrainBoolean;
|
||||
latency?: W3C.ConstrainDouble;
|
||||
deviceId?: W3C.ConstrainString;
|
||||
groupId?: W3C.ConstrainString;
|
||||
}
|
||||
|
||||
interface MediaTrackSupportedConstraints {
|
||||
width?: boolean;
|
||||
height?: boolean;
|
||||
aspectRatio?: boolean;
|
||||
frameRate?: boolean;
|
||||
facingMode?: boolean;
|
||||
volume?: boolean;
|
||||
sampleRate?: boolean;
|
||||
sampleSize?: boolean;
|
||||
echoCancellation?: boolean;
|
||||
latency?: boolean;
|
||||
deviceId?: boolean;
|
||||
groupId?: boolean;
|
||||
}
|
||||
|
||||
interface MediaStream extends EventTarget {
|
||||
id: string;
|
||||
active: boolean;
|
||||
|
||||
onactive: EventListener;
|
||||
oninactive: EventListener;
|
||||
onaddtrack: (event: MediaStreamTrackEvent) => any;
|
||||
onremovetrack: (event: MediaStreamTrackEvent) => any;
|
||||
|
||||
clone(): MediaStream;
|
||||
stop(): void;
|
||||
|
||||
getAudioTracks(): MediaStreamTrack[];
|
||||
getVideoTracks(): MediaStreamTrack[];
|
||||
getTracks(): MediaStreamTrack[];
|
||||
|
||||
getTrackById(trackId: string): MediaStreamTrack;
|
||||
|
||||
addTrack(track: MediaStreamTrack): void;
|
||||
removeTrack(track: MediaStreamTrack): void;
|
||||
}
|
||||
|
||||
interface MediaStreamTrackEvent extends Event {
|
||||
track: MediaStreamTrack;
|
||||
}
|
||||
|
||||
declare enum MediaStreamTrackState {
|
||||
"live",
|
||||
"ended"
|
||||
}
|
||||
|
||||
interface MediaStreamTrack extends EventTarget {
|
||||
id: string;
|
||||
kind: string;
|
||||
label: string;
|
||||
enabled: boolean;
|
||||
muted: boolean;
|
||||
remote: boolean;
|
||||
readyState: MediaStreamTrackState;
|
||||
|
||||
onmute: EventListener;
|
||||
onunmute: EventListener;
|
||||
onended: EventListener;
|
||||
onoverconstrained: EventListener;
|
||||
|
||||
clone(): MediaStreamTrack;
|
||||
|
||||
stop(): void;
|
||||
|
||||
getCapabilities(): MediaTrackCapabilities;
|
||||
getConstraints(): MediaTrackConstraints;
|
||||
getSettings(): MediaTrackSettings;
|
||||
applyConstraints(constraints: MediaTrackConstraints): Promise<void>;
|
||||
}
|
||||
|
||||
interface MediaTrackCapabilities {
|
||||
width: number | W3C.LongRange;
|
||||
height: number | W3C.LongRange;
|
||||
aspectRatio: number | W3C.DoubleRange;
|
||||
frameRate: number | W3C.DoubleRange;
|
||||
facingMode: string;
|
||||
volume: number | W3C.DoubleRange;
|
||||
sampleRate: number | W3C.LongRange;
|
||||
sampleSize: number | W3C.LongRange;
|
||||
echoCancellation: boolean[];
|
||||
latency: number | W3C.DoubleRange;
|
||||
deviceId: string;
|
||||
groupId: string;
|
||||
}
|
||||
|
||||
interface MediaTrackSettings {
|
||||
width: number;
|
||||
height: number;
|
||||
aspectRatio: number;
|
||||
frameRate: number;
|
||||
facingMode: string;
|
||||
volume: number;
|
||||
sampleRate: number;
|
||||
sampleSize: number;
|
||||
echoCancellation: boolean;
|
||||
latency: number;
|
||||
deviceId: string;
|
||||
groupId: string;
|
||||
}
|
||||
|
||||
interface MediaStreamError {
|
||||
name: string;
|
||||
message: string;
|
||||
constraintName: string;
|
||||
}
|
||||
|
||||
interface NavigatorGetUserMedia {
|
||||
(constraints: MediaStreamConstraints,
|
||||
successCallback: (stream: MediaStream) => void,
|
||||
errorCallback: (error: MediaStreamError) => void): void;
|
||||
}
|
||||
|
||||
// to use with adapter.js, see: https://github.com/webrtc/adapter
|
||||
declare var getUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
interface Navigator {
|
||||
getUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
webkitGetUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
mozGetUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
msGetUserMedia: NavigatorGetUserMedia;
|
||||
|
||||
mediaDevices: MediaDevices;
|
||||
}
|
||||
|
||||
interface MediaDevices {
|
||||
getSupportedConstraints(): MediaTrackSupportedConstraints;
|
||||
|
||||
getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
|
||||
enumerateDevices(): Promise<MediaDeviceInfo[]>;
|
||||
}
|
||||
|
||||
interface MediaDeviceInfo {
|
||||
label: string;
|
||||
id: string;
|
||||
kind: string;
|
||||
facing: string;
|
||||
}
|
||||
|
||||
@@ -1,90 +1,90 @@
|
||||
/// <reference path="MediaStream.d.ts" />
|
||||
/// <reference path="RTCPeerConnection.d.ts" />
|
||||
|
||||
var config: RTCConfiguration =
|
||||
{ iceServers: [{ urls: "stun.l.google.com:19302" }] };
|
||||
var constraints: RTCMediaConstraints =
|
||||
{ mandatory: { offerToReceiveAudio: true, offerToReceiveVideo: true } };
|
||||
|
||||
var peerConnection: RTCPeerConnection =
|
||||
new RTCPeerConnection(config, constraints);
|
||||
|
||||
navigator.getUserMedia({ audio: true, video: true },
|
||||
stream => {
|
||||
peerConnection.addStream(stream);
|
||||
},
|
||||
error => {
|
||||
console.log('Error message: ' + error.message);
|
||||
console.log('Error name: ' + error.name);
|
||||
});
|
||||
|
||||
peerConnection.onaddstream = ev => console.log(ev.type);
|
||||
peerConnection.ondatachannel = ev => console.log(ev.type);
|
||||
peerConnection.oniceconnectionstatechange = ev => console.log(ev.type);
|
||||
peerConnection.onnegotiationneeded = ev => console.log(ev.type);
|
||||
peerConnection.onopen = ev => console.log(ev.type);
|
||||
peerConnection.onicecandidate = ev => console.log(ev.type);
|
||||
peerConnection.onremovestream = ev => console.log(ev.type);
|
||||
peerConnection.onstatechange = ev => console.log(ev.type);
|
||||
|
||||
peerConnection.createOffer(
|
||||
offer => {
|
||||
peerConnection.setLocalDescription(offer,
|
||||
() => console.log("set local description"),
|
||||
error => console.log("Error setting local description: " + error));
|
||||
},
|
||||
error => console.log("Error creating offer: " + error));
|
||||
|
||||
var type: string = RTCSdpType[RTCSdpType.offer];
|
||||
var offer: RTCSessionDescriptionInit = { type: type, sdp: "some sdp" };
|
||||
var sessionDescription = new RTCSessionDescription(offer);
|
||||
|
||||
peerConnection.setRemoteDescription(sessionDescription, () => {
|
||||
peerConnection.createAnswer(
|
||||
answer => {
|
||||
peerConnection.setLocalDescription(answer,
|
||||
() => console.log('Set local description'),
|
||||
error => console.log(
|
||||
"Error setting local description from created answer: " + error +
|
||||
"; answer.sdp=" + answer.sdp));
|
||||
},
|
||||
error => console.log("Error creating answer: " + error));
|
||||
},
|
||||
error => console.log('Error setting remote description: ' + error +
|
||||
"; offer.sdp=" + offer.sdp));
|
||||
|
||||
var webkitSessionDescription = new webkitRTCSessionDescription(offer);
|
||||
|
||||
peerConnection.setRemoteDescription(webkitSessionDescription, () => {
|
||||
peerConnection.createAnswer(
|
||||
answer => {
|
||||
peerConnection.setLocalDescription(answer,
|
||||
() => console.log('Set local description'),
|
||||
error => console.log(
|
||||
"Error setting local description from created answer: " + error +
|
||||
"; answer.sdp=" + answer.sdp));
|
||||
},
|
||||
error => console.log("Error creating answer: " + error));
|
||||
},
|
||||
error => console.log('Error setting remote description: ' + error +
|
||||
"; offer.sdp=" + offer.sdp));
|
||||
|
||||
var mozSessionDescription = new mozRTCSessionDescription(offer);
|
||||
|
||||
peerConnection.setRemoteDescription(mozSessionDescription, () => {
|
||||
peerConnection.createAnswer(
|
||||
answer => {
|
||||
peerConnection.setLocalDescription(answer,
|
||||
() => console.log('Set local description'),
|
||||
error => console.log(
|
||||
"Error setting local description from created answer: " + error +
|
||||
"; answer.sdp=" + answer.sdp));
|
||||
},
|
||||
error => console.log("Error creating answer: " + error));
|
||||
},
|
||||
error => console.log('Error setting remote description: ' + error +
|
||||
"; offer.sdp=" + offer.sdp));
|
||||
|
||||
var wkPeerConnection: webkitRTCPeerConnection =
|
||||
new webkitRTCPeerConnection(config, constraints);
|
||||
|
||||
/// <reference path="MediaStream.d.ts" />
|
||||
/// <reference path="RTCPeerConnection.d.ts" />
|
||||
|
||||
var config: RTCConfiguration =
|
||||
{ iceServers: [{ urls: "stun.l.google.com:19302" }] };
|
||||
var constraints: RTCMediaConstraints =
|
||||
{ mandatory: { offerToReceiveAudio: true, offerToReceiveVideo: true } };
|
||||
|
||||
var peerConnection: RTCPeerConnection =
|
||||
new RTCPeerConnection(config, constraints);
|
||||
|
||||
navigator.getUserMedia({ audio: true, video: true },
|
||||
stream => {
|
||||
peerConnection.addStream(stream);
|
||||
},
|
||||
error => {
|
||||
console.log('Error message: ' + error.message);
|
||||
console.log('Error name: ' + error.name);
|
||||
});
|
||||
|
||||
peerConnection.onaddstream = ev => console.log(ev.type);
|
||||
peerConnection.ondatachannel = ev => console.log(ev.type);
|
||||
peerConnection.oniceconnectionstatechange = ev => console.log(ev.type);
|
||||
peerConnection.onnegotiationneeded = ev => console.log(ev.type);
|
||||
peerConnection.onopen = ev => console.log(ev.type);
|
||||
peerConnection.onicecandidate = ev => console.log(ev.type);
|
||||
peerConnection.onremovestream = ev => console.log(ev.type);
|
||||
peerConnection.onstatechange = ev => console.log(ev.type);
|
||||
|
||||
peerConnection.createOffer(
|
||||
offer => {
|
||||
peerConnection.setLocalDescription(offer,
|
||||
() => console.log("set local description"),
|
||||
error => console.log("Error setting local description: " + error));
|
||||
},
|
||||
error => console.log("Error creating offer: " + error));
|
||||
|
||||
var type: string = RTCSdpType[RTCSdpType.offer];
|
||||
var offer: RTCSessionDescriptionInit = { type: type, sdp: "some sdp" };
|
||||
var sessionDescription = new RTCSessionDescription(offer);
|
||||
|
||||
peerConnection.setRemoteDescription(sessionDescription, () => {
|
||||
peerConnection.createAnswer(
|
||||
answer => {
|
||||
peerConnection.setLocalDescription(answer,
|
||||
() => console.log('Set local description'),
|
||||
error => console.log(
|
||||
"Error setting local description from created answer: " + error +
|
||||
"; answer.sdp=" + answer.sdp));
|
||||
},
|
||||
error => console.log("Error creating answer: " + error));
|
||||
},
|
||||
error => console.log('Error setting remote description: ' + error +
|
||||
"; offer.sdp=" + offer.sdp));
|
||||
|
||||
var webkitSessionDescription = new webkitRTCSessionDescription(offer);
|
||||
|
||||
peerConnection.setRemoteDescription(webkitSessionDescription, () => {
|
||||
peerConnection.createAnswer(
|
||||
answer => {
|
||||
peerConnection.setLocalDescription(answer,
|
||||
() => console.log('Set local description'),
|
||||
error => console.log(
|
||||
"Error setting local description from created answer: " + error +
|
||||
"; answer.sdp=" + answer.sdp));
|
||||
},
|
||||
error => console.log("Error creating answer: " + error));
|
||||
},
|
||||
error => console.log('Error setting remote description: ' + error +
|
||||
"; offer.sdp=" + offer.sdp));
|
||||
|
||||
var mozSessionDescription = new mozRTCSessionDescription(offer);
|
||||
|
||||
peerConnection.setRemoteDescription(mozSessionDescription, () => {
|
||||
peerConnection.createAnswer(
|
||||
answer => {
|
||||
peerConnection.setLocalDescription(answer,
|
||||
() => console.log('Set local description'),
|
||||
error => console.log(
|
||||
"Error setting local description from created answer: " + error +
|
||||
"; answer.sdp=" + answer.sdp));
|
||||
},
|
||||
error => console.log("Error creating answer: " + error));
|
||||
},
|
||||
error => console.log('Error setting remote description: ' + error +
|
||||
"; offer.sdp=" + offer.sdp));
|
||||
|
||||
var wkPeerConnection: webkitRTCPeerConnection =
|
||||
new webkitRTCPeerConnection(config, constraints);
|
||||
|
||||
|
||||
726
webrtc/RTCPeerConnection.d.ts
vendored
726
webrtc/RTCPeerConnection.d.ts
vendored
@@ -1,363 +1,363 @@
|
||||
// Type definitions for WebRTC
|
||||
// Project: http://dev.w3.org/2011/webrtc/
|
||||
// Definitions by: Ken Smith <https://github.com/smithkl42/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
//
|
||||
// Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html
|
||||
//
|
||||
// For example code see:
|
||||
// https://code.google.com/p/webrtc/source/browse/stable/samples/js/apprtc/js/main.js
|
||||
//
|
||||
// For a generic implementation see that deals with browser differences, see:
|
||||
// https://code.google.com/p/webrtc/source/browse/stable/samples/js/base/adapter.js
|
||||
|
||||
/// <reference path='MediaStream.d.ts' />
|
||||
|
||||
// TODO(1): Get Typescript to have string-enum types as WebRtc is full of string
|
||||
// enums.
|
||||
// https://typescript.codeplex.com/discussions/549207
|
||||
|
||||
// TODO(2): get Typescript to have union types as WebRtc uses them.
|
||||
// https://typescript.codeplex.com/workitem/1364
|
||||
|
||||
interface RTCConfiguration {
|
||||
iceServers: RTCIceServer[];
|
||||
}
|
||||
declare var RTCConfiguration: {
|
||||
prototype: RTCConfiguration;
|
||||
new (): RTCConfiguration;
|
||||
};
|
||||
|
||||
interface RTCIceServer {
|
||||
urls: string;
|
||||
credential?: string;
|
||||
}
|
||||
declare var RTCIceServer: {
|
||||
prototype: RTCIceServer;
|
||||
new (): RTCIceServer;
|
||||
};
|
||||
|
||||
// moz (Firefox) specific prefixes.
|
||||
interface mozRTCPeerConnection extends RTCPeerConnection {
|
||||
}
|
||||
declare var mozRTCPeerConnection: {
|
||||
prototype: mozRTCPeerConnection;
|
||||
new (settings: RTCPeerConnectionConfig,
|
||||
constraints?:RTCMediaConstraints): mozRTCPeerConnection;
|
||||
};
|
||||
// webkit (Chrome) specific prefixes.
|
||||
interface webkitRTCPeerConnection extends RTCPeerConnection {
|
||||
}
|
||||
declare var webkitRTCPeerConnection: {
|
||||
prototype: webkitRTCPeerConnection;
|
||||
new (settings: RTCPeerConnectionConfig,
|
||||
constraints?:RTCMediaConstraints): webkitRTCPeerConnection;
|
||||
};
|
||||
|
||||
// For Chrome, look at the code here:
|
||||
// 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
|
||||
interface RTCOptionalMediaConstraint {
|
||||
// When true, will use DTLS/SCTP data channels
|
||||
DtlsSrtpKeyAgreement?: boolean;
|
||||
// When true will use Rtp-based data channels (depreicated)
|
||||
RtpDataChannels?: boolean;
|
||||
}
|
||||
|
||||
// ks 12/20/12 - There's more here that doesn't seem to be documented very well yet.
|
||||
// http://www.w3.org/TR/2013/WD-webrtc-20130910/
|
||||
interface RTCMediaConstraints {
|
||||
mandatory?: RTCMediaOfferConstraints;
|
||||
optional?: RTCOptionalMediaConstraint[]
|
||||
}
|
||||
|
||||
interface RTCMediaOfferConstraints {
|
||||
offerToReceiveAudio: boolean;
|
||||
offerToReceiveVideo: boolean;
|
||||
}
|
||||
|
||||
interface RTCSessionDescriptionInit {
|
||||
type: string; // RTCSdpType; See TODO(1)
|
||||
sdp: string;
|
||||
}
|
||||
|
||||
interface RTCSessionDescription {
|
||||
type?: string; // RTCSdpType; See TODO(1)
|
||||
sdp?: string;
|
||||
}
|
||||
declare var RTCSessionDescription: {
|
||||
prototype: RTCSessionDescription;
|
||||
new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription;
|
||||
// TODO: Add serializer.
|
||||
// See: http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSdpType)
|
||||
};
|
||||
|
||||
interface webkitRTCSessionDescription extends RTCSessionDescription{
|
||||
type?: string;
|
||||
sdp?: string;
|
||||
}
|
||||
declare var webkitRTCSessionDescription: {
|
||||
prototype: webkitRTCSessionDescription;
|
||||
new (descriptionInitDict?: RTCSessionDescriptionInit): webkitRTCSessionDescription;
|
||||
};
|
||||
|
||||
interface mozRTCSessionDescription extends RTCSessionDescription{
|
||||
type?: string;
|
||||
sdp?: string;
|
||||
}
|
||||
declare var mozRTCSessionDescription: {
|
||||
prototype: mozRTCSessionDescription;
|
||||
new (descriptionInitDict?: RTCSessionDescriptionInit): mozRTCSessionDescription;
|
||||
};
|
||||
|
||||
|
||||
|
||||
interface RTCDataChannelInit {
|
||||
ordered ?: boolean; // messages must be sent in-order.
|
||||
maxPacketLifeTime ?: number; // unsigned short
|
||||
maxRetransmits ?: number; // unsigned short
|
||||
protocol ?: string; // default = ''
|
||||
negotiated ?: boolean; // default = false;
|
||||
id ?: number; // unsigned short
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCSdpType {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcsdptype
|
||||
'offer',
|
||||
'pranswer',
|
||||
'answer'
|
||||
}
|
||||
|
||||
interface RTCMessageEvent {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#event-datachannel-message
|
||||
// At present, this can be an: ArrayBuffer, a string, or a Blob.
|
||||
// See TODO(2)
|
||||
data: any;
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCDataChannelState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelState
|
||||
'connecting',
|
||||
'open',
|
||||
'closing',
|
||||
'closed'
|
||||
}
|
||||
|
||||
interface RTCDataChannel extends EventTarget {
|
||||
label: string;
|
||||
reliable: boolean;
|
||||
readyState: string; // RTCDataChannelState; see TODO(1)
|
||||
bufferedAmount: number;
|
||||
binaryType: string;
|
||||
|
||||
onopen: (event: Event) => void;
|
||||
onerror: (event: Event) => void;
|
||||
onclose: (event: Event) => void;
|
||||
onmessage: (event: RTCMessageEvent) => void;
|
||||
|
||||
close(): void;
|
||||
|
||||
send(data: string): void ;
|
||||
send(data: ArrayBuffer): void;
|
||||
send(data: ArrayBufferView): void;
|
||||
send(data: Blob): void;
|
||||
}
|
||||
declare var RTCDataChannel: {
|
||||
prototype: RTCDataChannel;
|
||||
new (): RTCDataChannel;
|
||||
};
|
||||
|
||||
interface RTCDataChannelEvent extends Event {
|
||||
channel: RTCDataChannel;
|
||||
}
|
||||
declare var RTCDataChannelEvent: {
|
||||
prototype: RTCDataChannelEvent;
|
||||
new (eventInitDict: RTCDataChannelEventInit): RTCDataChannelEvent;
|
||||
};
|
||||
|
||||
interface RTCIceCandidateEvent extends Event {
|
||||
candidate: RTCIceCandidate;
|
||||
}
|
||||
|
||||
interface RTCMediaStreamEvent extends Event {
|
||||
stream: MediaStream;
|
||||
}
|
||||
|
||||
interface EventInit {
|
||||
}
|
||||
|
||||
interface RTCDataChannelEventInit extends EventInit {
|
||||
channel: RTCDataChannel;
|
||||
}
|
||||
|
||||
interface RTCVoidCallback {
|
||||
(): void;
|
||||
}
|
||||
interface RTCSessionDescriptionCallback {
|
||||
(sdp: RTCSessionDescription): void;
|
||||
}
|
||||
interface RTCPeerConnectionErrorCallback {
|
||||
(errorInformation: DOMError): void;
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCIceGatheringState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcicegatheringstate-enum
|
||||
'new',
|
||||
'gathering',
|
||||
'complete'
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCIceConnectionState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceConnectionState
|
||||
'new',
|
||||
'checking',
|
||||
'connected',
|
||||
'completed',
|
||||
'failed',
|
||||
'disconnected',
|
||||
'closed'
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCSignalingState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSignalingState
|
||||
'stable',
|
||||
'have-local-offer',
|
||||
'have-remote-offer',
|
||||
'have-local-pranswer',
|
||||
'have-remote-pranswer',
|
||||
'closed'
|
||||
}
|
||||
|
||||
// This is based on the current implementation of WebRtc in Chrome; the spec is
|
||||
// a little unclear on this.
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCStatsReport
|
||||
interface RTCStatsReport {
|
||||
stat(id: string): string;
|
||||
}
|
||||
|
||||
interface RTCStatsCallback {
|
||||
(report: RTCStatsReport): void;
|
||||
}
|
||||
|
||||
interface RTCPeerConnection {
|
||||
createOffer(successCallback: RTCSessionDescriptionCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
createAnswer(successCallback: RTCSessionDescriptionCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
setLocalDescription(description: RTCSessionDescription,
|
||||
successCallback?: RTCVoidCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback): void;
|
||||
localDescription: RTCSessionDescription;
|
||||
setRemoteDescription(description: RTCSessionDescription,
|
||||
successCallback?: RTCVoidCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback): void;
|
||||
remoteDescription: RTCSessionDescription;
|
||||
signalingState: string; // RTCSignalingState; see TODO(1)
|
||||
updateIce(configuration?: RTCConfiguration,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
addIceCandidate(candidate:RTCIceCandidate,
|
||||
successCallback:() => void,
|
||||
failureCallback:RTCPeerConnectionErrorCallback): void;
|
||||
iceGatheringState: string; // RTCIceGatheringState; see TODO(1)
|
||||
iceConnectionState: string; // RTCIceConnectionState; see TODO(1)
|
||||
getLocalStreams(): MediaStream[];
|
||||
getRemoteStreams(): MediaStream[];
|
||||
createDataChannel(label?: string,
|
||||
dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
||||
ondatachannel: (event: Event) => void;
|
||||
addStream(stream: MediaStream, constraints?: RTCMediaConstraints): void;
|
||||
removeStream(stream: MediaStream): void;
|
||||
close(): void;
|
||||
onnegotiationneeded: (event: Event) => void;
|
||||
onconnecting: (event: Event) => void;
|
||||
onopen: (event: Event) => void;
|
||||
onaddstream: (event: RTCMediaStreamEvent) => void;
|
||||
onremovestream: (event: RTCMediaStreamEvent) => void;
|
||||
onstatechange: (event: Event) => void;
|
||||
oniceconnectionstatechange: (event: Event) => void;
|
||||
onicecandidate: (event: RTCIceCandidateEvent) => void;
|
||||
onidentityresult: (event: Event) => void;
|
||||
onsignalingstatechange: (event: Event) => void;
|
||||
getStats: (successCallback: RTCStatsCallback,
|
||||
failureCallback: RTCPeerConnectionErrorCallback) => void;
|
||||
}
|
||||
declare var RTCPeerConnection: {
|
||||
prototype: RTCPeerConnection;
|
||||
new (configuration: RTCConfiguration,
|
||||
constraints?: RTCMediaConstraints): RTCPeerConnection;
|
||||
};
|
||||
|
||||
interface RTCIceCandidate {
|
||||
candidate?: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
}
|
||||
declare var RTCIceCandidate: {
|
||||
prototype: RTCIceCandidate;
|
||||
new (candidateInitDict?: RTCIceCandidate): RTCIceCandidate;
|
||||
};
|
||||
|
||||
interface webkitRTCIceCandidate extends RTCIceCandidate {
|
||||
candidate?: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
}
|
||||
declare var webkitRTCIceCandidate: {
|
||||
prototype: webkitRTCIceCandidate;
|
||||
new (candidateInitDict?: webkitRTCIceCandidate): webkitRTCIceCandidate;
|
||||
};
|
||||
|
||||
interface mozRTCIceCandidate extends RTCIceCandidate {
|
||||
candidate?: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
}
|
||||
declare var mozRTCIceCandidate: {
|
||||
prototype: mozRTCIceCandidate;
|
||||
new (candidateInitDict?: mozRTCIceCandidate): mozRTCIceCandidate;
|
||||
};
|
||||
|
||||
interface RTCIceCandidateInit {
|
||||
candidate: string;
|
||||
sdpMid: string;
|
||||
sdpMLineIndex: number;
|
||||
}
|
||||
declare var RTCIceCandidateInit:{
|
||||
prototype: RTCIceCandidateInit;
|
||||
new (): RTCIceCandidateInit;
|
||||
};
|
||||
|
||||
interface PeerConnectionIceEvent {
|
||||
peer: RTCPeerConnection;
|
||||
candidate: RTCIceCandidate;
|
||||
}
|
||||
declare var PeerConnectionIceEvent: {
|
||||
prototype: PeerConnectionIceEvent;
|
||||
new (): PeerConnectionIceEvent;
|
||||
};
|
||||
|
||||
interface RTCPeerConnectionConfig {
|
||||
iceServers: RTCIceServer[];
|
||||
}
|
||||
declare var RTCPeerConnectionConfig: {
|
||||
prototype: RTCPeerConnectionConfig;
|
||||
new (): RTCPeerConnectionConfig;
|
||||
};
|
||||
|
||||
interface Window{
|
||||
RTCPeerConnection: RTCPeerConnection;
|
||||
webkitRTCPeerConnection: webkitRTCPeerConnection;
|
||||
mozRTCPeerConnection: mozRTCPeerConnection;
|
||||
RTCSessionDescription: RTCSessionDescription;
|
||||
webkitRTCSessionDescription: webkitRTCSessionDescription;
|
||||
mozRTCSessionDescription: mozRTCSessionDescription;
|
||||
RTCIceCandidate: RTCIceCandidate;
|
||||
webkitRTCIceCandidate: webkitRTCIceCandidate;
|
||||
mozRTCIceCandidate: mozRTCIceCandidate;
|
||||
}
|
||||
// Type definitions for WebRTC
|
||||
// Project: http://dev.w3.org/2011/webrtc/
|
||||
// Definitions by: Ken Smith <https://github.com/smithkl42/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
//
|
||||
// Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html
|
||||
//
|
||||
// For example code see:
|
||||
// https://code.google.com/p/webrtc/source/browse/stable/samples/js/apprtc/js/main.js
|
||||
//
|
||||
// For a generic implementation see that deals with browser differences, see:
|
||||
// https://code.google.com/p/webrtc/source/browse/stable/samples/js/base/adapter.js
|
||||
|
||||
/// <reference path='MediaStream.d.ts' />
|
||||
|
||||
// TODO(1): Get Typescript to have string-enum types as WebRtc is full of string
|
||||
// enums.
|
||||
// https://typescript.codeplex.com/discussions/549207
|
||||
|
||||
// TODO(2): get Typescript to have union types as WebRtc uses them.
|
||||
// https://typescript.codeplex.com/workitem/1364
|
||||
|
||||
interface RTCConfiguration {
|
||||
iceServers: RTCIceServer[];
|
||||
}
|
||||
declare var RTCConfiguration: {
|
||||
prototype: RTCConfiguration;
|
||||
new (): RTCConfiguration;
|
||||
};
|
||||
|
||||
interface RTCIceServer {
|
||||
urls: string;
|
||||
credential?: string;
|
||||
}
|
||||
declare var RTCIceServer: {
|
||||
prototype: RTCIceServer;
|
||||
new (): RTCIceServer;
|
||||
};
|
||||
|
||||
// moz (Firefox) specific prefixes.
|
||||
interface mozRTCPeerConnection extends RTCPeerConnection {
|
||||
}
|
||||
declare var mozRTCPeerConnection: {
|
||||
prototype: mozRTCPeerConnection;
|
||||
new (settings: RTCPeerConnectionConfig,
|
||||
constraints?:RTCMediaConstraints): mozRTCPeerConnection;
|
||||
};
|
||||
// webkit (Chrome) specific prefixes.
|
||||
interface webkitRTCPeerConnection extends RTCPeerConnection {
|
||||
}
|
||||
declare var webkitRTCPeerConnection: {
|
||||
prototype: webkitRTCPeerConnection;
|
||||
new (settings: RTCPeerConnectionConfig,
|
||||
constraints?:RTCMediaConstraints): webkitRTCPeerConnection;
|
||||
};
|
||||
|
||||
// For Chrome, look at the code here:
|
||||
// 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
|
||||
interface RTCOptionalMediaConstraint {
|
||||
// When true, will use DTLS/SCTP data channels
|
||||
DtlsSrtpKeyAgreement?: boolean;
|
||||
// When true will use Rtp-based data channels (depreicated)
|
||||
RtpDataChannels?: boolean;
|
||||
}
|
||||
|
||||
// ks 12/20/12 - There's more here that doesn't seem to be documented very well yet.
|
||||
// http://www.w3.org/TR/2013/WD-webrtc-20130910/
|
||||
interface RTCMediaConstraints {
|
||||
mandatory?: RTCMediaOfferConstraints;
|
||||
optional?: RTCOptionalMediaConstraint[]
|
||||
}
|
||||
|
||||
interface RTCMediaOfferConstraints {
|
||||
offerToReceiveAudio: boolean;
|
||||
offerToReceiveVideo: boolean;
|
||||
}
|
||||
|
||||
interface RTCSessionDescriptionInit {
|
||||
type: string; // RTCSdpType; See TODO(1)
|
||||
sdp: string;
|
||||
}
|
||||
|
||||
interface RTCSessionDescription {
|
||||
type?: string; // RTCSdpType; See TODO(1)
|
||||
sdp?: string;
|
||||
}
|
||||
declare var RTCSessionDescription: {
|
||||
prototype: RTCSessionDescription;
|
||||
new (descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription;
|
||||
// TODO: Add serializer.
|
||||
// See: http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSdpType)
|
||||
};
|
||||
|
||||
interface webkitRTCSessionDescription extends RTCSessionDescription{
|
||||
type?: string;
|
||||
sdp?: string;
|
||||
}
|
||||
declare var webkitRTCSessionDescription: {
|
||||
prototype: webkitRTCSessionDescription;
|
||||
new (descriptionInitDict?: RTCSessionDescriptionInit): webkitRTCSessionDescription;
|
||||
};
|
||||
|
||||
interface mozRTCSessionDescription extends RTCSessionDescription{
|
||||
type?: string;
|
||||
sdp?: string;
|
||||
}
|
||||
declare var mozRTCSessionDescription: {
|
||||
prototype: mozRTCSessionDescription;
|
||||
new (descriptionInitDict?: RTCSessionDescriptionInit): mozRTCSessionDescription;
|
||||
};
|
||||
|
||||
|
||||
|
||||
interface RTCDataChannelInit {
|
||||
ordered ?: boolean; // messages must be sent in-order.
|
||||
maxPacketLifeTime ?: number; // unsigned short
|
||||
maxRetransmits ?: number; // unsigned short
|
||||
protocol ?: string; // default = ''
|
||||
negotiated ?: boolean; // default = false;
|
||||
id ?: number; // unsigned short
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCSdpType {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcsdptype
|
||||
'offer',
|
||||
'pranswer',
|
||||
'answer'
|
||||
}
|
||||
|
||||
interface RTCMessageEvent {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#event-datachannel-message
|
||||
// At present, this can be an: ArrayBuffer, a string, or a Blob.
|
||||
// See TODO(2)
|
||||
data: any;
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCDataChannelState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelState
|
||||
'connecting',
|
||||
'open',
|
||||
'closing',
|
||||
'closed'
|
||||
}
|
||||
|
||||
interface RTCDataChannel extends EventTarget {
|
||||
label: string;
|
||||
reliable: boolean;
|
||||
readyState: string; // RTCDataChannelState; see TODO(1)
|
||||
bufferedAmount: number;
|
||||
binaryType: string;
|
||||
|
||||
onopen: (event: Event) => void;
|
||||
onerror: (event: Event) => void;
|
||||
onclose: (event: Event) => void;
|
||||
onmessage: (event: RTCMessageEvent) => void;
|
||||
|
||||
close(): void;
|
||||
|
||||
send(data: string): void ;
|
||||
send(data: ArrayBuffer): void;
|
||||
send(data: ArrayBufferView): void;
|
||||
send(data: Blob): void;
|
||||
}
|
||||
declare var RTCDataChannel: {
|
||||
prototype: RTCDataChannel;
|
||||
new (): RTCDataChannel;
|
||||
};
|
||||
|
||||
interface RTCDataChannelEvent extends Event {
|
||||
channel: RTCDataChannel;
|
||||
}
|
||||
declare var RTCDataChannelEvent: {
|
||||
prototype: RTCDataChannelEvent;
|
||||
new (eventInitDict: RTCDataChannelEventInit): RTCDataChannelEvent;
|
||||
};
|
||||
|
||||
interface RTCIceCandidateEvent extends Event {
|
||||
candidate: RTCIceCandidate;
|
||||
}
|
||||
|
||||
interface RTCMediaStreamEvent extends Event {
|
||||
stream: MediaStream;
|
||||
}
|
||||
|
||||
interface EventInit {
|
||||
}
|
||||
|
||||
interface RTCDataChannelEventInit extends EventInit {
|
||||
channel: RTCDataChannel;
|
||||
}
|
||||
|
||||
interface RTCVoidCallback {
|
||||
(): void;
|
||||
}
|
||||
interface RTCSessionDescriptionCallback {
|
||||
(sdp: RTCSessionDescription): void;
|
||||
}
|
||||
interface RTCPeerConnectionErrorCallback {
|
||||
(errorInformation: DOMError): void;
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCIceGatheringState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcicegatheringstate-enum
|
||||
'new',
|
||||
'gathering',
|
||||
'complete'
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCIceConnectionState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCIceConnectionState
|
||||
'new',
|
||||
'checking',
|
||||
'connected',
|
||||
'completed',
|
||||
'failed',
|
||||
'disconnected',
|
||||
'closed'
|
||||
}
|
||||
|
||||
// TODO(1)
|
||||
declare enum RTCSignalingState {
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCSignalingState
|
||||
'stable',
|
||||
'have-local-offer',
|
||||
'have-remote-offer',
|
||||
'have-local-pranswer',
|
||||
'have-remote-pranswer',
|
||||
'closed'
|
||||
}
|
||||
|
||||
// This is based on the current implementation of WebRtc in Chrome; the spec is
|
||||
// a little unclear on this.
|
||||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCStatsReport
|
||||
interface RTCStatsReport {
|
||||
stat(id: string): string;
|
||||
}
|
||||
|
||||
interface RTCStatsCallback {
|
||||
(report: RTCStatsReport): void;
|
||||
}
|
||||
|
||||
interface RTCPeerConnection {
|
||||
createOffer(successCallback: RTCSessionDescriptionCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
createAnswer(successCallback: RTCSessionDescriptionCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
setLocalDescription(description: RTCSessionDescription,
|
||||
successCallback?: RTCVoidCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback): void;
|
||||
localDescription: RTCSessionDescription;
|
||||
setRemoteDescription(description: RTCSessionDescription,
|
||||
successCallback?: RTCVoidCallback,
|
||||
failureCallback?: RTCPeerConnectionErrorCallback): void;
|
||||
remoteDescription: RTCSessionDescription;
|
||||
signalingState: string; // RTCSignalingState; see TODO(1)
|
||||
updateIce(configuration?: RTCConfiguration,
|
||||
constraints?: RTCMediaConstraints): void;
|
||||
addIceCandidate(candidate:RTCIceCandidate,
|
||||
successCallback:() => void,
|
||||
failureCallback:RTCPeerConnectionErrorCallback): void;
|
||||
iceGatheringState: string; // RTCIceGatheringState; see TODO(1)
|
||||
iceConnectionState: string; // RTCIceConnectionState; see TODO(1)
|
||||
getLocalStreams(): MediaStream[];
|
||||
getRemoteStreams(): MediaStream[];
|
||||
createDataChannel(label?: string,
|
||||
dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
||||
ondatachannel: (event: Event) => void;
|
||||
addStream(stream: MediaStream, constraints?: RTCMediaConstraints): void;
|
||||
removeStream(stream: MediaStream): void;
|
||||
close(): void;
|
||||
onnegotiationneeded: (event: Event) => void;
|
||||
onconnecting: (event: Event) => void;
|
||||
onopen: (event: Event) => void;
|
||||
onaddstream: (event: RTCMediaStreamEvent) => void;
|
||||
onremovestream: (event: RTCMediaStreamEvent) => void;
|
||||
onstatechange: (event: Event) => void;
|
||||
oniceconnectionstatechange: (event: Event) => void;
|
||||
onicecandidate: (event: RTCIceCandidateEvent) => void;
|
||||
onidentityresult: (event: Event) => void;
|
||||
onsignalingstatechange: (event: Event) => void;
|
||||
getStats: (successCallback: RTCStatsCallback,
|
||||
failureCallback: RTCPeerConnectionErrorCallback) => void;
|
||||
}
|
||||
declare var RTCPeerConnection: {
|
||||
prototype: RTCPeerConnection;
|
||||
new (configuration: RTCConfiguration,
|
||||
constraints?: RTCMediaConstraints): RTCPeerConnection;
|
||||
};
|
||||
|
||||
interface RTCIceCandidate {
|
||||
candidate?: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
}
|
||||
declare var RTCIceCandidate: {
|
||||
prototype: RTCIceCandidate;
|
||||
new (candidateInitDict?: RTCIceCandidate): RTCIceCandidate;
|
||||
};
|
||||
|
||||
interface webkitRTCIceCandidate extends RTCIceCandidate {
|
||||
candidate?: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
}
|
||||
declare var webkitRTCIceCandidate: {
|
||||
prototype: webkitRTCIceCandidate;
|
||||
new (candidateInitDict?: webkitRTCIceCandidate): webkitRTCIceCandidate;
|
||||
};
|
||||
|
||||
interface mozRTCIceCandidate extends RTCIceCandidate {
|
||||
candidate?: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
}
|
||||
declare var mozRTCIceCandidate: {
|
||||
prototype: mozRTCIceCandidate;
|
||||
new (candidateInitDict?: mozRTCIceCandidate): mozRTCIceCandidate;
|
||||
};
|
||||
|
||||
interface RTCIceCandidateInit {
|
||||
candidate: string;
|
||||
sdpMid: string;
|
||||
sdpMLineIndex: number;
|
||||
}
|
||||
declare var RTCIceCandidateInit:{
|
||||
prototype: RTCIceCandidateInit;
|
||||
new (): RTCIceCandidateInit;
|
||||
};
|
||||
|
||||
interface PeerConnectionIceEvent {
|
||||
peer: RTCPeerConnection;
|
||||
candidate: RTCIceCandidate;
|
||||
}
|
||||
declare var PeerConnectionIceEvent: {
|
||||
prototype: PeerConnectionIceEvent;
|
||||
new (): PeerConnectionIceEvent;
|
||||
};
|
||||
|
||||
interface RTCPeerConnectionConfig {
|
||||
iceServers: RTCIceServer[];
|
||||
}
|
||||
declare var RTCPeerConnectionConfig: {
|
||||
prototype: RTCPeerConnectionConfig;
|
||||
new (): RTCPeerConnectionConfig;
|
||||
};
|
||||
|
||||
interface Window{
|
||||
RTCPeerConnection: RTCPeerConnection;
|
||||
webkitRTCPeerConnection: webkitRTCPeerConnection;
|
||||
mozRTCPeerConnection: mozRTCPeerConnection;
|
||||
RTCSessionDescription: RTCSessionDescription;
|
||||
webkitRTCSessionDescription: webkitRTCSessionDescription;
|
||||
mozRTCSessionDescription: mozRTCSessionDescription;
|
||||
RTCIceCandidate: RTCIceCandidate;
|
||||
webkitRTCIceCandidate: webkitRTCIceCandidate;
|
||||
mozRTCIceCandidate: mozRTCIceCandidate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user