Merge branch 'master' of github.com:borisyankov/DefinitelyTyped

This commit is contained in:
James O'Cull
2015-11-05 10:18:33 -05:00
73 changed files with 101202 additions and 47302 deletions
+1
View File
@@ -297,6 +297,7 @@ declare module AngularFormly {
bound?: any;
expression?: any;
value?: any;
[key: string]: any;
};
+16
View File
@@ -0,0 +1,16 @@
/// <reference path="./assertsharp.d.ts" />
import Assert from "assertsharp";
Assert.AreEqual(0, 0, "Pass");
Assert.AreNotEqual(0, 1, "Pass");
Assert.AreNotSame(new Date(), new Date(), "Pass");
Assert.AreSequenceEqual([0], [0], (x, y) => x === y, "Pass");
Assert.Fail("Should fail");
Assert.IsFalse(false, "Pass");
Assert.IsInstanceOfType(new Date(), Date, "Pass");
Assert.IsNotInstanceOfType(true, Date, "Pass");
Assert.IsNotNull(new Date(), "Pass");
Assert.IsNull(null, "Pass");
Assert.IsTrue(true, "Pass");
Assert.Throws(() => { throw ""; }, "Pass");
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for assertsharp
// Project: https://www.npmjs.com/package/assertsharp
// Definitions by: Bruno Leonardo Michels <https://github.com/brunolm>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "assertsharp" {
export default class Assert {
static AreEqual<T>(expected: T, actual: T, message?: string): void;
static AreNotEqual<T>(notExpected: T, actual: T, message?: string): void;
static AreNotSame<T>(notExpected: T, actual: T, message?: string): void;
static AreSequenceEqual<T>(expected: T[], actual: T[], equals?: (x: any, y: any) => boolean, message?: string): void;
static Fail(message?: string): void;
static IsFalse(actual: boolean, message?: string): void;
static IsInstanceOfType(actual: any, expectedType: Function, message?: string): void;
static IsNotInstanceOfType(actual: any, wrongType: Function, message?: string): void;
static IsNotNull(actual: any, message?: string): void;
static IsNull(actual: any, message?: string): void;
static IsTrue(actual: boolean, message?: string): void;
static Throws(fn: () => void, message?: string): void;
}
}
+2
View File
@@ -367,7 +367,9 @@ declare module Backbone {
remove(): View<TModel>;
make(tagName: any, attributes?: any, content?: any): any;
delegateEvents(events?: EventsHash): any;
delegate(eventName: string, selector: string, listener: Function): View<TModel>;
undelegateEvents(): any;
undelegate(eventName: string, selector?: string, listener?: Function): View<TModel>;
_ensureElement(): void;
}
+16
View File
@@ -0,0 +1,16 @@
/// <reference path="./bytes.d.ts"/>
import bytes = require('bytes');
// 1024*1024 = 1048576
console.log(bytes(104857));
console.log(bytes(104857, { thousandsSeparator: ' ' }));
console.log(bytes.format(104857));
console.log(bytes.format(104857, { thousandsSeparator: ' ' }));
console.log(bytes('1024kb'));
console.log(bytes(1024));
console.log(bytes.parse('1024kb'));
console.log(bytes.parse(1024));
+62
View File
@@ -0,0 +1,62 @@
// Type definitions for bytes v2.1.0
// Project: https://github.com/visionmedia/bytes.js
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'bytes' {
/**
*Convert the given value in bytes into a string.
*
* @param {number} value
* @param {{
* thousandsSeparator: [string]
* }} [options] bytes options.
*
* @returns {string}
*/
function bytes(value: number, options?: { thousandsSeparator: string }): string;
/**
*Parse string to an integer in bytes.
*
* @param {string} value
* @returns {number}
*/
function bytes(value: string): number;
module bytes {
/**
* Format the given value in bytes into a string.
*
* If the value is negative, take Math.abs(). If it is a float,
* it is rounded.
*
* @param {number} value
* @param {BytesFormatOptions} [options]
*/
function format(value: number, options?: { thousandsSeparator: string }): string;
/**
* Just return the input number value.
*
* @param {number} value
* @return {number}
*/
function parse(value: number): number;
/**
* Parse the string value into an integer in bytes.
*
* If no unit is given, it is assumed the value is in bytes.
*
* @param {string} value
* @return {number}
*/
function parse(value: string): number;
}
export = bytes;
}
+54
View File
@@ -0,0 +1,54 @@
/// <reference path="./depd.d.ts"/>
import depd = require('depd');
var deprecate = depd("depd-tests");
function assert(condition: boolean, message: string): void {
if (!condition) {
throw new Error(message);
}
}
function testDepdMessage(...args: string[]): boolean {
if (arguments.length < 1) {
deprecate('testDepdMessage argument.lenth<1');
return true;
} else {
console.log('normal logic');
return false;
}
}
assert(testDepdMessage() === true, "Deprecated code must be triggered!");
assert(testDepdMessage('a') === false, "Deprecated code must be triggered!");
interface ITestObject {
p1: string;
p2: string;
}
var obj = <ITestObject>{ p1: 'deprecated property', p2: 'normal property' };
deprecate.property(obj, 'p1', 'property [p1] is deprecated!');
console.log(obj.p1);
interface ITestDeprecatedFunction {
func1?: Function;
func2?: Function;
}
var obj2 = <ITestDeprecatedFunction>{};
// message automatically derived from function name
obj2.func1 = deprecate.function(function func1() {
console.log('all calls to [func1] are deprecated ');
});
// specific message
obj2.func2 = deprecate.function(function () {
console.log('all calls to [func2] are deprecated ');
}, 'func2');
obj2.func1();
obj2.func2();
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for depd 1.1.0
// Project: https://github.com/dougwilson/nodejs-depd
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'depd' {
function depd(namespace: string): Deprecate;
interface Deprecate {
(message: string): void;
function(fn: Function, message?: string): Function;
property(obj: Object, prop: string, message: string): void;
}
export = depd;
}
+1 -1
View File
@@ -38,7 +38,7 @@ declare class Dexie {
static deepClone(obj: Object): Object;
version(versionNumber: Number): Dexie.Version
version(versionNumber: number): Dexie.Version
on: {
(eventName: string, subscriber: () => any): void;
File diff suppressed because one or more lines are too long
+8683 -3009
View File
File diff suppressed because it is too large Load Diff
+22 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for Firebase API 2.0.2
// Project: https://www.firebase.com/docs/javascript/firebase
// Definitions by: Vincent Botone <https://github.com/vbortone/>, Shin1 Kashimura <https://github.com/in-async/>
// Definitions by: Vincent Botone <https://github.com/vbortone/>, Shin1 Kashimura <https://github.com/in-async/>, Sebastien Dubois <https://github.com/dsebastien/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface FirebaseAuthResult {
@@ -317,6 +317,27 @@ interface FirebaseAuthData {
token: string;
expires: number;
auth: Object;
google?: FirebaseAuthDataGoogle;
}
interface FirebaseAuthDataGoogle {
accessToken: string;
cachedUserProfile: FirebaseAuthDataGoogleCachedUserProfile;
displayName: string;
email?: string;
id: string;
profileImageURL: string;
}
interface FirebaseAuthDataGoogleCachedUserProfile {
"family name"?: string;
gender?: string;
"given name"?: string;
id?: string;
link?: string;
locale?: string;
name?: string;
picture?: string;
}
interface FirebaseCredentials {
+2
View File
@@ -52,6 +52,7 @@ declare module "gridfs-stream" {
files: mongo.Collection;
collection(name?: string): mongo.Collection;
curCol: string;
createWriteStream(options?: GridFSStream.Options): GridFSStream.WriteStream;
createReadStream(options?: GridFSStream.Options): GridFSStream.ReadStream;
@@ -60,6 +61,7 @@ declare module "gridfs-stream" {
remove(options: GridFSStream.Options, callback: (err: Error) => void): void;
exist(options: GridFSStream.Options, callback: (err: Error, found: boolean) => void): void;
findOne(options: GridFSStream.Options, callback: (err: Error, record: any)=>void):void;
}
}
+1
View File
@@ -1715,6 +1715,7 @@ interface HighchartsCSSObject {
color?: string;
cursor?: string;
font?: string;
fontFamily?: string;
fontSize?: string;
fontWeight?: string;
left?: string;
+2
View File
@@ -37,6 +37,8 @@ declare module Html2Canvas {
/** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */
useCORS?: boolean;
/** Callback providing the rendered canvas element after rendering */
onrendered?(canvas: HTMLCanvasElement): void;
}
}
+35
View File
@@ -0,0 +1,35 @@
/// <reference path="inline-css.d.ts" />
import inlineCss = require('inline-css');
var str: string;
var bool: boolean;
var options:inlineCss.Options;
str = options.url;
str = options.extraCss;
bool = options.applyStyleTags;
bool = options.applyLinkTags;
bool = options.removeStyleTags;
bool = options.removeLinkTags;
bool = options.preserveMediaQueries;
bool = options.applyWidthAttributes;
bool = options.applyTableAttributes;
options = {
url: str,
extraCss: str,
applyStyleTags: bool,
applyLinkTags: bool,
removeStyleTags: bool,
removeLinkTags: bool,
preserveMediaQueries: bool,
applyWidthAttributes: bool,
applyTableAttributes: bool
};
inlineCss(str, options).then((value:string) => {
});
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for inline-css
// Project: https://github.com/jonkemp/inline-css
// Definitions by: Philip Spain <https://github.com/philipisapain>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../bluebird/bluebird.d.ts" />
declare module 'inline-css' {
import Promise = require('bluebird');
module InlineCss {
export interface Options {
url:string;
extraCss?:string;
applyStyleTags?:boolean;
applyLinkTags?:boolean;
removeStyleTags?:boolean;
removeLinkTags?:boolean;
preserveMediaQueries?:boolean;
applyWidthAttributes?:boolean;
applyTableAttributes?:boolean;
}
}
function InlineCss(html:string, options:InlineCss.Options):Promise<string>;
export = InlineCss;
}
+1 -1
View File
@@ -47,7 +47,7 @@ describe('displayUser', function() {
' <button id="button" />' +
'</div>';
var displayUser = require('../displayUser');
var displayUser = require.requireActual('../displayUser');
var $ = require('jquery');
var fetchCurrentUser = require('../fetchCurrentUser');
+51 -8
View File
@@ -3,21 +3,29 @@
// Definitions by: Asana <https://asana.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare function afterEach(fn: jest.EmptyFunction): void;
declare function beforeEach(fn: jest.EmptyFunction): void;
declare function describe(name: string, fn: jest.EmptyFunction): void;
declare var it: jest.It;
declare function pit(name: string, fn: jest.EmptyFunction): void;
declare var require: jest.Require;
declare function xdescribe(name: string, fn: jest.EmptyFunction): void;
declare function xit(name: string, fn: jest.EmptyFunction): void;
declare function expect(actual: any): jest.Matchers;
interface NodeRequire {
requireActual(moduleName: string): any;
}
declare module jest {
function addMatchers(matchers: CustomMatcherFactories): void;
function autoMockOff(): void;
function autoMockOn(): void;
function clearAllTimers(): void;
function currentTestPath(): string;
function dontMock(moduleName: string): void;
function genMockFromModule<T>(moduleName: string): Mock<T>;
function genMockFunction<T>(): Mock<T>;
@@ -57,14 +65,9 @@ declare module jest {
only(name: string, fn: EmptyFunction): void;
}
interface Require {
(moduleName: string): any;
requireActual(moduleName: string): any;
}
interface Mock<T> {
new(): T;
(...args:any[]): any; // TODO please fix this line! added for TypeScript 1.1.0-1 https://github.com/borisyankov/DefinitelyTyped/pull/2932
new (): T;
(...args: any[]): any; // TODO please fix this line! added for TypeScript 1.1.0-1 https://github.com/borisyankov/DefinitelyTyped/pull/2932
mock: MockContext<T>;
mockClear(): void;
mockImplementation(fn: Function): Mock<T>;
@@ -78,4 +81,44 @@ declare module jest {
calls: any[][];
instances: T[];
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomMatcherFactories {
[index: string]: CustomMatcherFactory;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomMatcherFactory {
(util: MatchersUtil, customEqualityTesters: Array<CustomEqualityTester>): CustomMatcher;
}
// taken from Jasmine since addMatchers calls into the jasmine api
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;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomEqualityTester {
(first: any, second: any): boolean;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomMatcher {
compare<T>(actual: T, expected: T): CustomMatcherResult;
compare(actual: any, expected: any): CustomMatcherResult;
}
// taken from Jasmine since addMatchers calls into the jasmine api
interface CustomMatcherResult {
pass: boolean;
message: string;
}
// taken from Jasmine which takes from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
interface ArrayLike<T> {
length: number;
[n: number]: T;
}
}
+846 -232
View File
File diff suppressed because it is too large Load Diff
+765 -222
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -8,7 +8,7 @@ function main(): void {
addColumn('description', lf.Type.STRING).
addColumn('deadline', lf.Type.DATE_TIME).
addColumn('done', lf.Type.BOOLEAN).
addPrimaryKey(['id']).
addPrimaryKey(['id'], false).
addIndex('idxDeadline', ['deadline'], false, lf.Order.DESC);
var todoDb: lf.Database = null;
+3 -1
View File
@@ -200,7 +200,9 @@ declare module lf {
name: string, columns: Array<string>|Array<IndexedColumn>,
unique?: boolean, order?: Order): TableBuilder
addNullable(columns: Array<Column>): TableBuilder
addPrimaryKey(columns: Array<string>|Array<IndexedColumn>): TableBuilder
addPrimaryKey(
columns: Array<string>|Array<IndexedColumn>,
autoInc?: boolean): TableBuilder
addUnique(name: string, columns: Array<Column>): TableBuilder
}
@@ -0,0 +1,35 @@
/// <reference path="merge-descriptors.d.ts"/>
import mixin = require('merge-descriptors');
function testAssertion(condition: boolean, errorMessage: string) {
if (!condition) {
throw new Error(errorMessage);
}
}
interface IMergedObject {
InSrc?: string;
name: string;
InTarget: string;
}
var src = {
InSrc: 'src',
get name(): string {
return 'from src name';
}
}
var target: IMergedObject = { name: 'my target name', InTarget: 'target' };
var target2 = mixin(target, src, true);
console.log(JSON.stringify(target));
testAssertion(target2 === target, "Returned object should refer to input [destination] object");
testAssertion(target.name === 'from src name', "[redfine]=true, source member will overwrite destination member");
testAssertion(target.InTarget === 'target', "overwrite do not affect members only in [destination]");
testAssertion(target['InSrc'] === 'src', "members from [source] must be copied to [destination]");
var nameProperty:PropertyDescriptor = Object.getOwnPropertyDescriptor(target, "name");
testAssertion(nameProperty.set === undefined, "member descriptor must be overwritten");
@@ -0,0 +1 @@
--noImplicitAny --module commonjs --target es5
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for merge-descriptors
// Project: https://github.com/component/merge-descriptors
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'merge-descriptors' {
function merge(destination: Object, source: Object): Object;
function merge(destination: Object, source: Object, redefine: boolean): Object;
export = merge;
}
+14
View File
@@ -0,0 +1,14 @@
/// <reference path="./ms.d.ts"/>
import ms = require('ms');
ms('2 days') // 172800000
ms('1d') // 86400000
ms(60000) // "1m"
ms(2 * 60000) // "2m"
ms(ms('10 hours')) // "10h"
ms(60000, { long: true }) // "1 minute"
ms(2 * 60000, { long: true }) // "2 minutes"
ms(ms('10 hours'), { long: true }) // "10 hours"
Vendored
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for ms v0.7.1
// Project: https://github.com/guille/ms.js
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'ms' {
/**
* Short/Long format for `value`.
*
* @param {Number} value
* @param {{long: boolean}} options
* @return {String}
*/
function ms(value: number, options?: { long: boolean }): string;
/**
* Parse the given `value` and return milliseconds.
*
* @param {String} value
* @return {Number}
*/
function ms(value: string): number;
export = ms;
}
+41
View File
@@ -0,0 +1,41 @@
/// <reference path="tsd.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.appavailability {
'use strict';
export class AppAvailabilityController {
isAvailable:boolean;
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDevice", "$cordovaAppAvailability"];
constructor($ionicPlatform:ionic.platform.IonicPlatformService,
private $cordovaDevice:ngCordova.IDeviceService,
private $cordovaAppAvailability:ngCordova.IAppAvailabilityService) {
this.isAvailable = false;
var scheme = "com.twitter.android";
if ($cordovaDevice.getPlatform() == 'iOS') {
scheme = "twitter://";
}
$ionicPlatform.ready(() => {
$cordovaAppAvailability.check(scheme).then(() => {
this.isAvailable = true;
}, (err) => {
// bad api design in plugin as well as in ngCordova !!
this.isAvailable = false;
})
});
}
}
angular.module("demo.appavailability").controller("AppAvailabilityController", AppAvailabilityController);
}
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for ngCordova AppAvailability plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ngCordova {
export interface IAppAvailabilityService {
check(urlScheme: string): ng.IPromise<any>;
}
}
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="device.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.device {
'use strict';
interface IDeviceViewModel {
available:boolean;
cordova:string;
model:string;
platform:string;
uuid:string;
version:string;
}
export class DeviceController {
public vm:IDeviceViewModel;
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDevice"];
constructor($ionicPlatform:ionic.platform.IonicPlatformService, $cordovaDevice:ngCordova.IDeviceService) {
$ionicPlatform.ready(() => {
this.vm = {
available : $cordovaDevice.getDevice().available,
cordova : $cordovaDevice.getCordova(),
model : $cordovaDevice.getModel(),
platform : $cordovaDevice.getPlatform(),
uuid : $cordovaDevice.getUUID(),
version : $cordovaDevice.getVersion()
};
});
}
}
angular.module("demo.device").controller("DeviceController", DeviceController);
}
+78
View File
@@ -0,0 +1,78 @@
// Type definitions for ngCordova device plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
declare module ngCordova {
interface IDeviceInfo {
available:boolean;
platform:string;
version:string;
uuid:string;
cordova:string;
model:string;
manufacturer:string;
isVirtual:boolean;
serial:string;
}
interface IDeviceService {
/**
* Returns the whole device object.
* @see https://github.com/apache/cordova-plugin-device
* @returns {Object} The device object.
*/
getDevice():IDeviceInfo;
/**
* Returns the Cordova version.
* @see https://github.com/apache/cordova-plugin-device#devicecordova
* @returns {String} The Cordova version.
*/
getCordova():string;
/**
* Returns the name of the device's model or product.
* @see https://github.com/apache/cordova-plugin-device#devicemodel
* @returns {String} The name of the device's model or product.
*/
getModel():string;
/**
* @deprecated device.name is deprecated as of version 2.3.0. Use device.model instead.
* @returns {String}
*/
getName():string;
/**
* Returns the device's operating system name.
* @see https://github.com/apache/cordova-plugin-device#deviceplatform
* @returns {String} The device's operating system name.
*/
getPlatform():string;
/**
* Returns the device's Universally Unique Identifier.
* @see https://github.com/apache/cordova-plugin-device#deviceuuid
* @returns {String} The device's Universally Unique Identifier
*/
getUUID():string;
/**
* Returns the operating system version.
* @see https://github.com/apache/cordova-plugin-device#deviceversion
* @returns {String}
*/
getVersion():string;
/**
* Returns the device manufacturer.
* @returns {String}
*/
getManufacturer():string;
}
}
+58
View File
@@ -0,0 +1,58 @@
/// <reference path="tsd.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.devicemotion {
'use strict';
export class DeviceMotionController {
motion:ngCordova.IDeviceMotionAcceleration;
this_watch:ngCordova.IDeviceMotionWatchPromise;
msg:string;
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDeviceMotion"];
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaDeviceMotion:ngCordova.IDeviceMotionService) {
$ionicPlatform.ready(() => {
this.getAcceleration();
});
}
getAcceleration () {
this.$cordovaDeviceMotion.getCurrentAcceleration().then( (motion) => {
this.motion = motion;
console.log(motion);
}, function (err) {
this.msg = err.message;
console.log(err);
});
}
watchAcceleration () {
var options = { frequency: 3000 }; // Update every 3 seconds
this.this_watch = this.$cordovaDeviceMotion.watchAcceleration(options);
this.this_watch.then(
() => { /* unused */
},
(err) => {
this.msg = err.message;
},
(motion) => {
this.motion = motion;
});
};
clearWatch () {
// use watchID from watchAccelaration()
this.$cordovaDeviceMotion.clearWatch(this.this_watch.watchID);
};
}
angular.module("demo.devicemotion").controller("DeviceMotionController", DeviceMotionController);
}
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for ngCordova device motion plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Michel Vidailhet <https://github.com/mvidailhet>, Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ngCordova {
export interface IDeviceMotionAcceleration {
x: number;
y: number;
z: number;
timestamp: number;
}
export interface IDeviceMotionAccelerometerOptions {
frequency: number;
}
export interface IDeviceMotionWatchPromise extends ng.IPromise<IDeviceMotionAcceleration> {
watchID: number;
cancel: () => void;
clearWatch: (watchId?: number) => void;
}
export interface IDeviceMotionService {
getCurrentAcceleration(): ng.IPromise<IDeviceMotionAcceleration>;
watchAcceleration(options: IDeviceMotionAccelerometerOptions): IDeviceMotionWatchPromise;
clearWatch(watchId: number): void;
}
}
+65
View File
@@ -0,0 +1,65 @@
/// <reference path="tsd.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.deviceorientation {
'use strict';
export class DeviceOrientationController {
msg:string;
heading:ngCordova.IDeviceOrientationHeading;
this_watch:ngCordova.IDeviceOrientationWatchPromise;
static $inject:Array<string> = ["$ionicPlatform", "$timeout", "$cordovaDeviceOrientation"];
constructor($ionicPlatform:ionic.platform.IonicPlatformService,
private $timeout:ng.ITimeoutService,
private $cordovaDeviceOrientation:ngCordova.IDeviceOrientationService) {
$ionicPlatform.ready(() => {
this.getHeading();
});
}
getHeading() {
this.$cordovaDeviceOrientation
.getCurrentHeading()
.then((position) => {
this.heading = position;
}, (err) => {
this.msg = err.message;
});
};
watchHeading () {
this.this_watch = this.$cordovaDeviceOrientation.watchHeading({frequency: 1000});
this.this_watch.then(
() => {
/* unused */
},
(err) => {
this.msg = err.message;
},
(position) => {
this.$timeout(() => {
this.heading = position;
});
}
);
};
clearWatch () {
this.$cordovaDeviceOrientation.clearWatch(this.this_watch.watchID);
};
}
angular.module("demo.deviceorientation").controller("DeviceOrientationController", DeviceOrientationController);
}
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for ngCordova device orientation plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Michel Vidailhet <https://github.com/mvidailhet>, Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ngCordova {
export interface IDeviceOrientationHeading {
magneticHeading: number;
trueHeading?: number;
headingAccuracy?: number;
timestamp?: number;
}
export interface IDeviceOrientationWatchOptions {
frequency?: number;
filter?: number;
}
export interface IDeviceOrientationWatchPromise extends ng.IPromise<IDeviceOrientationHeading> {
watchID: number;
cancel: () => void;
clearWatch: (watchId?: number) => void;
}
export interface IDeviceOrientationService {
getCurrentHeading(): ng.IPromise<IDeviceOrientationHeading>;
watchHeading(options: IDeviceOrientationWatchOptions): IDeviceOrientationWatchPromise;
clearWatch(watchID: number): void;
}
}
+47
View File
@@ -0,0 +1,47 @@
/// <reference path="tsd.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.dialog {
'use strict';
export class DialogController {
action:string;
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDialogs"];
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaDialogs:ngCordova.IDialogsService) {
this.action = "Press any button !";
}
alert() {
this.action = "Alert";
this.$cordovaDialogs.alert('Wow!');
}
confirm() {
this.action = "Confirm";
this.$cordovaDialogs.confirm('Are you sure?', "Custom title").then(function (buttonIndex) {
this.$cordovaDialogs.alert("Button index : " + buttonIndex);
});
}
prompt() {
this.action = "Prompt";
this.$cordovaDialogs.prompt('Please Login', "Custom title").then(function (result) {
this.$cordovaDialogs.alert("Input: " + result.input1 + "\n Button index : " + result.buttonIndex);
});
}
beep() {
this.action = "Beep";
this.$cordovaDialogs.beep(3);
}
}
angular.module("demo.dialog").controller("DialogController", DialogController);
}
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for ngCordova dialogs plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Michel Vidailhet <https://github.com/mvidailhet>, Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ngCordova {
export interface IDialogsPromptResult {
input1: string;
buttonIndex: number;
}
export interface IDialogsService {
alert(message: string, title?: string, buttonName?: string): ng.IPromise<void>;
confirm(message: string, title?: string, buttonArray?: Array<string>): ng.IPromise<number>;
prompt(message: string, title?: string, buttonArray?: Array<string>, defaultText?: string): ng.IPromise<IDialogsPromptResult>;
beep(repetitions: number): void;
}
}
+47
View File
@@ -0,0 +1,47 @@
/// <reference path="tsd.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.email {
'use strict';
export class EmailComposerController {
isAvailable:boolean;
status:string;
static $inject:Array<string> = ["$ionicPlatform", "$cordovaEmailComposer"];
constructor($ionicPlatform:ionic.platform.IonicPlatformService, $cordovaEmailComposer:ngCordova.IEmailComposerService) {
this.status = "";
$ionicPlatform.ready(() => {
$cordovaEmailComposer.isAvailable().then((available) => {
this.isAvailable = available;
});
let email = <ngCordova.IEmailComposerOptions>{
to: 'max@mustermann.de',
cc: 'erika@mustermann.de',
bcc: ['john@doe.com', 'jane@doe.com'],
subject: 'Cordova Icons',
body: 'How are you? Nice greetings from Leipzig',
isHtml: true
};
$cordovaEmailComposer.open(email).then(null, () => {
// user cancelled email
this.status = "User Cancelled Email";
});
});
}
}
angular.module("demo.email").controller("EmailComposerController", EmailComposerController);
}
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for ngCordova emailComposer plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ngCordova {
export interface IEmailComposerOptions {
to: string | Array<string>;
cc?: string | Array<string>;
bcc?: string | Array<string>;
attachments?: Array<any>;
subject?: string;
body?: string;
isHtml?: boolean;
}
export interface IEmailComposerService {
isAvailable(): ng.IPromise<boolean>;
open(properties: IEmailComposerOptions) : ng.IPromise<any>;
addAlias(app: string, schema: string) : void;
}
}
+39
View File
@@ -0,0 +1,39 @@
/// <reference path="tsd.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.geolocation {
'use strict';
export class GeolocationController {
erroMsg:string;
position:ngCordova.IGeoPosition;
static $inject:Array<string> = ["$ionicPlatform", "$cordovaGeolocation"];
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaGeolocation:ngCordova.IGeolocationService) {
}
getLocation = function () {
this.$cordovaGeolocation
.getCurrentPosition(<ngCordova.IGeolocationOptions>{timeout: 10000, enableHighAccuracy: false})
.then((position:ngCordova.IGeoPosition) => {
console.log("position found");
this.position = position;
// long = position.coords.longitude
// lat = position.coords.latitude
}, (err:ngCordova.IGeoPositionError) => {
console.log("unable to find location");
this.errorMsg = "Error : " + err.message;
});
};
}
angular.module("demo.geolocation").controller("GeolocationController", GeolocationController);
}
+42
View File
@@ -0,0 +1,42 @@
// Type definitions for ngCordova geolocation plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ngCordova {
export interface IGeoPositionError {
code:number;
message:string;
}
export interface IGeoCoordinates {
latitude?:number;
longitude?:number;
accuracy?:number;
altitude?:number;
heading?:number;
speed?:number;
altitudeAccuracy?:number;
}
export interface IGeoPosition {
coords:IGeoCoordinates;
timestamp:Date;
}
export interface IGeolocationOptions {
timeout?: number;
maximumAge?: number;
enableHighAccuracy?: boolean;
}
export interface IGeolocationService {
getCurrentPosition(options?: IGeolocationOptions) : ng.IPromise<IGeoPosition>;
watchPosition(options?: IGeolocationOptions) : ng.IPromise<IGeoPosition>;
clearWatch(watchID: {[key: string]: any}) : void;
}
}
+43
View File
@@ -0,0 +1,43 @@
/// <reference path="tsd.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.network {
'use strict';
export class NetworkController {
networkType:string;
connectionType:string;
errorMsg:string;
static $inject:Array<string> = ["$ionicPlatform", "$cordovaNetwork"];
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaNetwork:ngCordova.INetworkInformationService) {
$ionicPlatform.ready(() => {
this.refresh();
});
}
refresh() {
this.networkType = this.$cordovaNetwork.getNetwork();
if (this.$cordovaNetwork.isOnline()) {
this.connectionType = 'Online';
}
else if (this.$cordovaNetwork.isOffline()) {
this.connectionType = 'Offline';
}
else {
this.errorMsg = 'Error getting isOffline / isOnline methods';
}
}
}
angular.module("demo.network").controller("NetworkController", NetworkController);
}
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for ngCordova network plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ngCordova {
export interface INetworkInformationService {
getNetwork(): string;
isOnline(): boolean;
isOffline(): boolean;
clearOfflineWatch(): void;
clearOnlineWatch(): void;
}
}
+51
View File
@@ -0,0 +1,51 @@
/// <reference path="toast.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../ionic/ionic.d.ts" />
// For the full application demo please see following repo :
// https://github.com/ksachdeva/ngCordova-typescript-demo
namespace demo.toast {
'use strict';
export class ToastController {
toastMessage:string = 'enter a message';
msg:string;
static $inject:Array<string> = ["$cordovaToast"];
constructor(private $cordovaToast:ngCordova.IToastService) {
}
center() {
this.$cordovaToast.show(this.toastMessage, 'long', 'center')
.then((success) => {
console.log("center msg displayed");
}, (error) => {
this.msg = error.message;
});
}
top() {
this.$cordovaToast.showShortTop(this.toastMessage)
.then((success) => {
console.log("short top msg displayed");
}, (error) => {
this.msg = error.message;
});
}
bottom() {
this.$cordovaToast.showLongBottom(this.toastMessage)
.then((success) => {
console.log("long bottom msg displayed");
}, (error) => {
this.msg = error.message;
});
}
}
angular.module("demo.toast").controller("ToastController", ToastController);
}
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for ngCordova toast plugin
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ngCordova {
interface IToastService {
showShortTop(message:string):angular.IPromise<any>;
showShortCenter(message:string):angular.IPromise<any>;
showShortBottom(message:string):angular.IPromise<any>;
showLongTop(message:string):angular.IPromise<any>;
showLongCenter(message:string):angular.IPromise<any>;
showLongBottom(message:string):angular.IPromise<any>;
show(message:string, duration:string, position:string):angular.IPromise<any>;
}
}
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for ngCordova plugins
// Project: https://github.com/driftyco/ng-cordova
// Definitions by: Kapil Sachdeva <https://github.com/ksachdeva>
// Definitions: https://github.com/ksachdeva/DefinitelyTyped
/// <reference path="device.d.ts"/>
/// <reference path="toast.d.ts"/>
/// <reference path="network.d.ts"/>
/// <reference path="emailComposer.d.ts"/>
/// <reference path="dialogs.d.ts"/>
/// <reference path="geolocation.d.ts"/>
/// <reference path="deviceMotion.d.ts"/>
/// <reference path="deviceOrientation.d.ts"/>
/// <reference path="appAvailability.d.ts"/>
+6 -19
View File
@@ -732,21 +732,7 @@ declare module "child_process" {
declare module "url" {
export interface Url {
href: string;
protocol: string;
auth: string;
hostname: string;
port: string;
host: string;
pathname: string;
search: string;
query: any; // string | Object
slashes: boolean;
hash?: string;
path?: string;
}
export interface UrlOptions {
href?: string;
protocol?: string;
auth?: string;
hostname?: string;
@@ -754,13 +740,14 @@ declare module "url" {
host?: string;
pathname?: string;
search?: string;
query?: any;
query?: any; // string | Object
slashes?: boolean;
hash?: string;
path?: string;
}
export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url;
export function format(url: UrlOptions): string;
export function format(url: Url): string;
export function resolve(from: string, to: string): string;
}
@@ -833,10 +820,10 @@ declare module "net" {
}
export function createServer(connectionListener?: (socket: Socket) =>void ): Server;
export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server;
export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function connect(options: { port: number, host?: string, localAddress? : string, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function connect(port: number, host?: string, connectionListener?: Function): Socket;
export function connect(path: string, connectionListener?: Function): Socket;
export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function createConnection(options: { port: number, host?: string, localAddress? : string, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
export function createConnection(path: string, connectionListener?: Function): Socket;
export function isIP(input: string): number;
+6 -19
View File
@@ -651,21 +651,7 @@ declare module "child_process" {
declare module "url" {
export interface Url {
href: string;
protocol: string;
auth: string;
hostname: string;
port: string;
host: string;
pathname: string;
search: string;
query: any; // string | Object
slashes: boolean;
hash?: string;
path?: string;
}
export interface UrlOptions {
href?: string;
protocol?: string;
auth?: string;
hostname?: string;
@@ -673,13 +659,14 @@ declare module "url" {
host?: string;
pathname?: string;
search?: string;
query?: any;
query?: any; // string | Object
slashes?: boolean;
hash?: string;
path?: string;
}
export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url;
export function format(url: UrlOptions): string;
export function format(url: Url): string;
export function resolve(from: string, to: string): string;
}
@@ -749,10 +736,10 @@ declare module "net" {
}
export function createServer(connectionListener?: (socket: Socket) =>void ): Server;
export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server;
export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function connect(options: { port: number, host?: string, localAddress? : string, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function connect(port: number, host?: string, connectionListener?: Function): Socket;
export function connect(path: string, connectionListener?: Function): Socket;
export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function createConnection(options: { port: number, host?: string, localAddress? : string, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
export function createConnection(path: string, connectionListener?: Function): Socket;
export function isIP(input: string): number;
+7 -20
View File
@@ -758,7 +758,7 @@ declare module "punycode" {
export function toASCII(domain: string): string;
export var ucs2: ucs2;
interface ucs2 {
decode(string: string): string;
decode(string: string): number[];
encode(codePoints: number[]): string;
}
export var version: any;
@@ -917,21 +917,7 @@ declare module "child_process" {
declare module "url" {
export interface Url {
href: string;
protocol: string;
auth: string;
hostname: string;
port: string;
host: string;
pathname: string;
search: string;
query: any; // string | Object
slashes: boolean;
hash?: string;
path?: string;
}
export interface UrlOptions {
href?: string;
protocol?: string;
auth?: string;
hostname?: string;
@@ -939,13 +925,14 @@ declare module "url" {
host?: string;
pathname?: string;
search?: string;
query?: any;
query?: any; // string | Object
slashes?: boolean;
hash?: string;
path?: string;
}
export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url;
export function format(url: UrlOptions): string;
export function format(url: Url): string;
export function resolve(from: string, to: string): string;
}
@@ -1021,10 +1008,10 @@ declare module "net" {
}
export function createServer(connectionListener?: (socket: Socket) =>void ): Server;
export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server;
export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function connect(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function connect(port: number, host?: string, connectionListener?: Function): Socket;
export function connect(path: string, connectionListener?: Function): Socket;
export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function createConnection(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
export function createConnection(path: string, connectionListener?: Function): Socket;
export function isIP(input: string): number;
+99
View File
@@ -0,0 +1,99 @@
// Type definitions for react-intl 1.2.0
// Project: http://formatjs.io/react/
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path='../react/react.d.ts' />
declare module "react-intl" {
import * as React from 'react'
module ReactIntl {
interface IIntlMixin extends React.Mixin<any,any> {
getIntlMessage(key: string): string
}
var IntlMixin: IIntlMixin
module IntlComponent {
interface Props {
locales?: string[]
messages?: {[key: string]: any}
formats?: string[]
}
}
interface IntlComponent {
getIntlMessage(key: string): string;
}
module FormattedDate {
export interface Props extends IntlComponent.Props {
value: Date
day?: string
month?: string
year?: string
}
}
class FormattedDate extends React.Component<FormattedDate.Props,any> {}
module FormattedTime {
export interface Props extends IntlComponent.Props {
value: Date
day?: string
month?: string
year?: string
format?: string
}
}
class FormattedTime extends React.Component<FormattedTime.Props,any> {}
module FormattedRelative {
export interface Props extends IntlComponent.Props {
value: number
units?: string //"second", "minute", "hour", "day", "month" or "year"
style?: string //"best fit" (default) or "numeric"
format?: string
}
}
class FormattedRelative extends React.Component<FormattedRelative.Props,any> {}
module FormattedMessage {
export interface Props extends IntlComponent.Props {
message: string;
[prop: string]: any
}
}
class FormattedMessage extends React.Component<FormattedMessage.Props,any> {}
module FormattedHTMLMessage {
export interface Props extends IntlComponent.Props {
message: string;
[prop: string]: any
}
}
class FormattedHTMLMessage extends React.Component<FormattedHTMLMessage.Props,any> {}
module FormattedNumber {
export interface Props extends IntlComponent.Props {
value: number
style?: string
currency?: string
format?: string
}
}
class FormattedNumber extends React.Component<FormattedNumber.Props,any> {}
}
export = ReactIntl
}
+138
View File
@@ -0,0 +1,138 @@
/**
* Created by Bruno Grieder
*/
///<reference path='../react/react.d.ts' />
///<reference path='../react-mixin/react-mixin.d.ts' />
///<reference path='../react-intl/react-intl-1.2.0.d.ts' />
import * as React from 'react'
import * as reactMixin from 'react-mixin'
import {IntlMixin, IntlComponent, FormattedNumber, FormattedMessage, FormattedDate} from 'react-intl'
///////////////////////////////////////////////////////////////////////////
//
// This class does not use the mixin and react-mixin is not required
// The MESSAGES are maintained in the file
// To use it call <I18nDirect locales={['en-US']}/>
//
////////////////////////////////////////////////////////////////////////////
const MESSAGES: {[key: string] : { [lang: string]: string }} = {
Sorry: {
'en-US': 'Sorry {name}',
'fr-FR': 'Désolé {name}'
}
}
module I18nDirect {
export interface Props extends IntlComponent.Props {}
}
class I18nDirect extends React.Component<I18nDirect.Props, any> {
private _currentLocale: string
private _messages: {[key: string]: string}
constructor( props: I18nDirect.Props ) {
super( props )
}
render() {
return (
<ul>
<li>FormattedNumber:&nbsp;
<FormattedNumber value={99.95} style="currency" currency="USD"/>
</li>
<li>FormattedMessage:&nbsp;
<FormattedMessage message={this._messages['Sorry']} name='Dave'/>
</li>
<li>FormattedDate:&nbsp;
<FormattedDate value={new Date()}/>
</li>
</ul>
)
}
componentWillReceiveProps( nextProps: I18nDirect.Props ) {
this.compileMessages(nextProps)
}
componentWillMount() {
this.compileMessages(this.props)
}
private compileMessages = (props: I18nDirect.Props): void => {
let locale: string = ( props.locales && props.locales[ 0 ] ) || 'en-US'
if (this._currentLocale !== locale) {
this._messages = Object.keys( MESSAGES ).reduce(
( dic , key ) => {
dic[ key ] = MESSAGES[ key ][ locale ]
return dic
},
{} as { [key: string]: string; }
)
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// This class uses the mixin and react-mixin is
// The MESSAGES are passed from messages property of the props
// To use it call <I18nMixin {...props}/>
//
////////////////////////////////////////////////////////////////////////////
module I18nMixin {
export interface Props extends IntlComponent.Props {}
}
@reactMixin.decorate( IntlMixin )
class I18nMixin extends React.Component<I18nMixin.Props, any> implements IntlComponent {
private _currentLocale: string
constructor( props: I18nMixin.Props ) {
super( props )
}
//Expose the method provided by the Mixin
getIntlMessage: (key: string) => string = this['getIntlMessage']
render() {
return (
<ul>
<li>FormattedNumber:
<FormattedNumber value={99.95} style="currency" currency="USD"/>
</li>
<li>FormattedMessage:
<FormattedMessage message={this.getIntlMessage('Sorry')} name='Dave'/> {/* this uses the mixin */}
</li>
</ul>
)
}
}
export { I18nDirect, I18nMixin }
@@ -0,0 +1 @@
--target es5 --noImplicitAny --experimentalDecorators --jsx react --module commonjs
+152 -122
View File
@@ -1,138 +1,168 @@
/**
* Created by Bruno Grieder
* Created by Bruno Grieder and Christian Droulers
*/
///<reference path='../react/react.d.ts' />
///<reference path='../react-mixin/react-mixin.d.ts' />
///<reference path='../react-intl/react-intl.d.ts' />
import * as React from 'react'
import * as reactMixin from 'react-mixin'
import {IntlMixin, IntlComponent, FormattedNumber, FormattedMessage, FormattedDate} from 'react-intl'
///<reference path="../react/react.d.ts" />
///<reference path="../react-mixin/react-mixin.d.ts" />
///<reference path="./react-intl.d.ts" />
///////////////////////////////////////////////////////////////////////////
//
// This class does not use the mixin and react-mixin is not required
// The MESSAGES are maintained in the file
// To use it call <I18nDirect locales={['en-US']}/>
//
////////////////////////////////////////////////////////////////////////////
import * as React from "react"
import * as reactMixin from "react-mixin"
import {
IntlProvider,
InjectedIntlProps,
addLocaleData,
hasLocaleData,
injectIntl,
intlShape,
defineMessages,
FormattedRelative,
FormattedMessage,
FormattedHTMLMessage,
FormattedNumber,
FormattedPlural,
FormattedDate,
FormattedTime
} from "react-intl"
import reactIntlEn = require("react-intl/lib/locale-data/en");
const MESSAGES: {[key: string] : { [lang: string]: string }} = {
addLocaleData(reactIntlEn);
console.log(hasLocaleData("en"));
Sorry: {
'en-US': 'Sorry {name}',
'fr-FR': 'Désolé {name}'
interface SomeComponentProps extends InjectedIntlProps {
}
class SomeComponent extends React.Component<SomeComponentProps, {}> {
static propTypes: React.ValidationMap<any> = {
intl: intlShape.isRequired
};
public render(): React.ReactElement<{}> {
const formattedDate = this.props.formatDate(new Date(), { format: "short" });
const formattedTime = this.props.formatTime(new Date(), { format: "short" });
const formattedRelative = this.props.formatRelative(new Date().getTime(), { format: "short" });
const formattedNumber = this.props.formatNumber(123, { format: "short" });
const formattedPlural = this.props.formatPlural(1, { one: "hai!" });
const formattedMessage = this.props.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
const formattedHTMLMessage = this.props.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{name}</strong>!" }, { name: "Roger" });
return <div>
<FormattedRelative
value={new Date().getTime() }
units="hour"
style="numeric"
format="yyyy-MM-dd"
updateInterval={123}
initialNow={new Date() } />
<FormattedMessage
id="test"
description="Test"
defaultMessage="Hi, {name}!"
values={{ name: "bob" }}
tagName="div" />
<FormattedHTMLMessage
id="test"
description="Test"
defaultMessage="Hi, {name}!"
values={{ name: "bob" }}
tagName="div" />
<FormattedHTMLMessage
id="test"
description="Test"
defaultMessage="Hi, {name}!"
values={{ name: "bob" }}
tagName="div" />
<FormattedNumber
value={123456.78}
format="N"
localeMatcher="lookup"
style="currency"
currency="USD"
currencyDisplay="name"
useGrouping={false}
minimumIntegerDigits={1}
minimumFractionDigits={1}
minimumSignificantDigits={2}
maximumFractionDigits={3}
maximumSignificantDigits={3} />
<FormattedPlural
style="cardinal"
value={3}
other="hai?"
zero="no hai"
one="hai"
two="hai2"
few="haifew"
many="haiku" />
<FormattedDate
value={new Date() }
format="short"
localeMatcher="best fit"
formatMatcher="basic"
timeZone="EDT"
hour12={false}
weekday="short"
era="short"
year="2-digit"
month="2-digit"
day="2-digit"
hour="2-digit"
minute="2-digit"
second="2-digit"
timeZoneName="short" />
<FormattedTime
value={new Date() }
format="short"
localeMatcher="best fit"
formatMatcher="basic"
timeZone="EDT"
hour12={false}
weekday="short"
era="short"
year="2-digit"
month="2-digit"
day="2-digit"
hour="2-digit"
minute="2-digit"
second="2-digit"
timeZoneName="short" />
<FormattedNumber value={123}>
{(formattedNum: string) => (
<span className="number">{formattedNum}</span>
) }
</FormattedNumber>
</div>
}
}
class TestApp extends React.Component<{}, {}> {
public render(): React.ReactElement<{}> {
const definedMessages = defineMessages({
"sup": {
id: "sup",
defaultMessage: "Hai mom"
}
});
module I18nDirect {
export interface Props extends IntlComponent.Props {}
}
class I18nDirect extends React.Component<I18nDirect.Props, any> {
private _currentLocale: string
private _messages: {[key: string]: string}
constructor( props: I18nDirect.Props ) {
super( props )
}
render() {
return (
<ul>
<li>FormattedNumber:&nbsp;
<FormattedNumber value={99.95} style="currency" currency="USD"/>
</li>
<li>FormattedMessage:&nbsp;
<FormattedMessage message={this._messages['Sorry']} name='Dave'/>
</li>
<li>FormattedDate:&nbsp;
<FormattedDate value={new Date()}/>
</li>
</ul>
)
}
componentWillReceiveProps( nextProps: I18nDirect.Props ) {
this.compileMessages(nextProps)
}
componentWillMount() {
this.compileMessages(this.props)
}
private compileMessages = (props: I18nDirect.Props): void => {
let locale: string = ( props.locales && props.locales[ 0 ] ) || 'en-US'
if (this._currentLocale !== locale) {
this._messages = Object.keys( MESSAGES ).reduce(
( dic , key ) => {
dic[ key ] = MESSAGES[ key ][ locale ]
return dic
},
{} as { [key: string]: string; }
)
const messages = {
"hello": "Hello, {name}!"
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// This class uses the mixin and react-mixin is
// The MESSAGES are passed from messages property of the props
// To use it call <I18nMixin {...props}/>
//
////////////////////////////////////////////////////////////////////////////
module I18nMixin {
export interface Props extends IntlComponent.Props {}
}
@reactMixin.decorate( IntlMixin )
class I18nMixin extends React.Component<I18nMixin.Props, any> implements IntlComponent {
private _currentLocale: string
constructor( props: I18nMixin.Props ) {
super( props )
}
//Expose the method provided by the Mixin
getIntlMessage: (key: string) => string = this['getIntlMessage']
render() {
return (
<ul>
<li>FormattedNumber:
<FormattedNumber value={99.95} style="currency" currency="USD"/>
</li>
<li>FormattedMessage:
<FormattedMessage message={this.getIntlMessage('Sorry')} name='Dave'/> {/* this uses the mixin */}
</li>
</ul>
)
return (<IntlProvider locale="en" formats={{}} messages={messages} defaultLocale="en" defaultFormats={messages}>
<SomeComponent />
</IntlProvider>)
}
}
export { I18nDirect, I18nMixin }
export default {
TestApp,
SomeComponent: injectIntl(SomeComponent)
}
+1 -1
View File
@@ -1 +1 @@
--target es5 --noImplicitAny --experimentalDecorators --jsx react
--target es5 --noImplicitAny --experimentalDecorators --jsx react --module commonjs
+229 -89
View File
@@ -1,99 +1,239 @@
// Type definitions for react-intl 1.2.0
// Type definitions for react-intl 2.0.0-beta1
// Project: http://formatjs.io/react/
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
// Definitions by: Bruno Grieder <https://github.com/bgrieder>, Christian Droulers <https://github.com/cdroulers>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path='../react/react.d.ts' />
declare module "react-intl" {
import * as React from 'react'
module ReactIntl {
interface IIntlMixin extends React.Mixin<any,any> {
getIntlMessage(key: string): string
}
var IntlMixin: IIntlMixin
module IntlComponent {
interface Props {
locales?: string[]
messages?: {[key: string]: any}
formats?: string[]
}
}
interface IntlComponent {
getIntlMessage(key: string): string;
}
module FormattedDate {
export interface Props extends IntlComponent.Props {
value: Date
day?: string
month?: string
year?: string
}
}
class FormattedDate extends React.Component<FormattedDate.Props,any> {}
module FormattedTime {
export interface Props extends IntlComponent.Props {
value: Date
day?: string
month?: string
year?: string
format?: string
}
}
class FormattedTime extends React.Component<FormattedTime.Props,any> {}
module FormattedRelative {
export interface Props extends IntlComponent.Props {
value: number
units?: string //"second", "minute", "hour", "day", "month" or "year"
style?: string //"best fit" (default) or "numeric"
format?: string
}
}
class FormattedRelative extends React.Component<FormattedRelative.Props,any> {}
module FormattedMessage {
export interface Props extends IntlComponent.Props {
message: string;
[prop: string]: any
}
}
class FormattedMessage extends React.Component<FormattedMessage.Props,any> {}
module FormattedHTMLMessage {
export interface Props extends IntlComponent.Props {
message: string;
[prop: string]: any
}
}
class FormattedHTMLMessage extends React.Component<FormattedHTMLMessage.Props,any> {}
module FormattedNumber {
export interface Props extends IntlComponent.Props {
value: number
style?: string
currency?: string
format?: string
}
}
class FormattedNumber extends React.Component<FormattedNumber.Props,any> {}
declare module ReactIntl {
import React = __React;
interface Locale {
locale: string;
fields?: { [key: string]: string },
pluralRuleFunction?: (n: number, ord: boolean) => string;
}
export = ReactIntl
function injectIntl<T>(clazz: T): T;
function addLocaleData(data: Locale[] | Locale): void;
function hasLocaleData(localeName: string): boolean;
interface Messages {
[key: string]: FormattedMessage.MessageDescriptor
}
function defineMessages<T extends Messages>(messages: Messages): T;
interface IntlShape extends React.Requireable<any> {
}
var intlShape: IntlShape;
interface FormatConfig {
locale?: string;
formats?: any;
}
interface InjectedIntlProps {
formatDate?: (date: Date, options?: FormattedDate.PropsBase) => string;
formatTime?: (date: Date, options?: FormattedTime.PropsBase) => string;
formatRelative?: (value: number, options?: FormattedRelative.PropsBase) => string;
formatNumber?: (value: number, options?: FormattedNumber.PropsBase) => string;
formatPlural?: (value: number, options?: FormattedPlural.PropsBase) => string;
formatMessage?: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Object) => string;
formatHTMLMessage?: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Object) => string;
}
module IntlComponent {
interface DateTimeFormatProps {
/*
* one of "best fit" (default) | "lookup"
*/
localeMatcher?: string;
/*
* one of "basic" (default) | "best fit"
*/
formatMatcher?: string;
timeZone?: string,
hour12?: boolean;
/*
* one of "narrow" (default) | "short" | "long"
*/
weekday?: string;
/*
* one of "narrow" (default) | "short" | "long"
*/
era?: string;
/*
* one of "numeric" (default) | "2-digit"
*/
year?: string;
/*
* one of "numeric" (default) | "2-digit" | "narrow" | "short" | "long"
*/
month?: string;
/*
* one of "numeric" (default) | "2-digit"
*/
day?: string;
/*
* one of "numeric" (default) | "2-digit"
*/
hour?: string;
/*
* one of "numeric" (default) | "2-digit"
*/
minute?: string;
/*
* one of "numeric" (default) | "2-digit"
*/
second?: string;
/*
* one of "short" (default) | "long"
*/
timeZoneName?: string;
}
}
module FormattedDate {
export interface PropsBase extends IntlComponent.DateTimeFormatProps {
format?: string;
}
export interface Props extends PropsBase {
value: Date;
}
}
class FormattedDate extends React.Component<FormattedDate.Props, any> { }
module FormattedTime {
export interface PropsBase extends IntlComponent.DateTimeFormatProps {
format?: string;
}
export interface Props extends PropsBase {
value: Date;
}
}
class FormattedTime extends React.Component<FormattedTime.Props, any> { }
module FormattedRelative {
export interface PropsBase {
/*
* one of "second", "minute", "hour", "day", "month" or "year"
*/
units?: string;
/*
* one of "best fit" (default) | "numeric"
*/
style?: string;
format?: string;
updateInterval?: number;
initialNow?: any;
}
export interface Props extends PropsBase {
value: number;
}
}
class FormattedRelative extends React.Component<FormattedRelative.Props, any> { }
module FormattedMessage {
export interface MessageDescriptor {
id: string;
description?: string;
defaultMessage?: string;
}
export interface Props extends MessageDescriptor {
values?: Object;
tagName?: string;
}
}
class FormattedMessage extends React.Component<FormattedMessage.Props, any> { }
class FormattedHTMLMessage extends React.Component<FormattedMessage.Props, any> { }
module FormattedNumber {
export interface PropsBase {
format?: string;
/*
* one of "best fit" (default) | "lookup"
*/
localeMatcher?: string;
/*
* one of "decimal" (default) | "currency" | "percent"
*/
style?: string;
currency?: string,
/*
* one of "symbol" (default) | "code" | "name"
*/
currencyDisplay?: string;
useGrouping?: boolean;
minimumIntegerDigits?: number;
minimumFractionDigits?: number;
maximumFractionDigits?: number;
minimumSignificantDigits?: number;
maximumSignificantDigits?: number;
}
export interface Props extends PropsBase {
value: number;
}
}
class FormattedNumber extends React.Component<FormattedNumber.Props, any> { }
module FormattedPlural {
export interface PropsBase {
/*
* one of "cardinal" (default) | "ordinal"
*/
style?: string;
other?: any;
zero?: any;
one?: any;
two?: any;
few?: any;
many?: any;
}
export interface Props extends PropsBase {
value: number;
}
}
class FormattedPlural extends React.Component<FormattedPlural.Props, any> { }
module IntlProvider {
export interface Props {
locale?: string;
formats?: Object;
messages?: Object;
defaultLocale?: string;
defaultFormats?: Object;
}
}
class IntlProvider extends React.Component<IntlProvider.Props, any> { }
class LocaleData extends Array<Locale> {
}
}
declare module "react-intl" {
export = ReactIntl
}
declare module "react-intl/lib/locale-data/en" {
var data: ReactIntl.LocaleData;
export = data;
}
+4
View File
@@ -313,6 +313,8 @@ declare namespace __React {
deltaZ: number;
}
interface LoadEvent extends SyntheticEvent {}
//
// Event Handler Types
// ----------------------------------------------------------------------
@@ -330,6 +332,7 @@ declare namespace __React {
interface TouchEventHandler extends EventHandler<TouchEvent> {}
interface UIEventHandler extends EventHandler<UIEvent> {}
interface WheelEventHandler extends EventHandler<WheelEvent> {}
interface LoadEventHandler extends EventHandler<LoadEvent> {}
//
// Props / DOM Attributes
@@ -377,6 +380,7 @@ declare namespace __React {
onTouchStart?: TouchEventHandler;
onScroll?: UIEventHandler;
onWheel?: WheelEventHandler;
onLoad?: LoadEventHandler;
className?: string;
id?: string;
+449 -2
View File
@@ -1,17 +1,464 @@
/// <reference path="request-promise.d.ts" />
import rp = require('request-promise');
import nodeRequest = require('request');
rp('http://www.google.com')
.then(console.dir)
.catch(console.error);
var options: rp.Options = {
var options: nodeRequest.Options = {
uri : 'http://posttestserver.com/post.php',
method : 'POST'
method : 'POST',
json: true,
body: { some: 'payload' }
};
rp(options)
.then(console.dir)
.catch(console.error);
// --> Displays length of response from server after post
// Get full response after DELETE
options = {
method: 'DELETE',
uri: 'http://my-server/path/to/resource/1234'
};
rp(options)
.then(function (response: http.IncomingMessage) {
console.log("DELETE succeeded with status %d", response.statusCode);
})
.catch(console.error);
//The following examples from https://github.com/request/request
import fs = require('fs');
import http = require('http');
var request = rp;
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body); // Show the HTML for the Google homepage.
}
});
request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'));
fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'));
request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png'));
request
.get('http://google.com/img.png')
.on('response', function(response: any) {
console.log(response.statusCode); // 200
console.log(response.headers['content-type']); // 'image/png'
})
.pipe(request.put('http://mysite.com/img.png'));
request
.get('http://mysite.com/doodle.png')
.on('error', function(err: any) {
console.log(err);
})
.pipe(fs.createWriteStream('doodle.png'));
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
if (req.method === 'PUT') {
req.pipe(request.put('http://mysite.com/doodle.png'));
} else if (req.method === 'GET' || req.method === 'HEAD') {
request.get('http://mysite.com/doodle.png').pipe(resp);
}
}
});
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
var x = request('http://mysite.com/doodle.png');
req.pipe(x);
x.pipe(resp);
}
});
var resp: http.ServerResponse;
var req: nodeRequest.Request;
req.pipe(request('http://mysite.com/doodle.png')).pipe(resp);
var r = request;
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
r.get('http://google.com/doodle.png').pipe(resp);
}
});
request.post('http://service.com/upload', {form:{key:'value'}});
// or
request.post('http://service.com/upload').form({key:'value'});
// or
request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ });
var data = {
// Pass a simple key-value pair
my_field: 'my_value',
// Pass data via Buffers
my_buffer: new Buffer([1, 2, 3]),
// Pass data via Streams
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
// Pass multiple values /w an Array
attachments: [
fs.createReadStream(__dirname + '/attachment1.jpg'),
fs.createReadStream(__dirname + '/attachment2.jpg')
],
// Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS}
// Use case: for some types of streams, you'll need to provide "file"-related information manually.
// See the `form-data` README for more information about options: https://github.com/felixge/node-form-data
custom_file: {
value: fs.createReadStream('/dev/urandom'),
options: {
filename: 'topsecret.jpg',
contentType: 'image/jpg'
}
}
};
request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
});
var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {});
var form = requestMultipart.form();
form.append('my_field', 'my_value');
form.append('my_buffer', new Buffer([1, 2, 3]));
form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'});
request({
method: 'PUT',
preambleCRLF: true,
postambleCRLF: true,
uri: 'http://service.com/upload',
multipart: {
chunked: false,
data: [
{
'content-type': 'application/json',
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
},
{ body: 'I am an attachment' }
]
}
},
function (error, response, body) {
if (error) {
return console.error('upload failed:', error);
}
console.log('Upload successful! Server responded with:', body);
});
request({
method: 'PUT',
preambleCRLF: true,
postambleCRLF: true,
uri: 'http://service.com/upload',
multipart: [
{
'content-type': 'application/json',
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
},
{ body: 'I am an attachment' },
{ body: fs.createReadStream('image.png') }
]
},
function (error, response, body) {
if (error) {
return console.error('upload failed:', error);
}
console.log('Upload successful! Server responded with:', body);
});
request.get('http://some.server.com/').auth('username', 'password', false);
// or
request.get('http://some.server.com/', {
'auth': {
'user': 'username',
'pass': 'password',
'sendImmediately': false
}
});
// or
request.get('http://some.server.com/').auth(null, null, true, 'bearerToken');
// or
request.get('http://some.server.com/', {
'auth': {
'bearer': 'bearerToken'
}
});
var username = 'username',
password = 'password',
url = 'http://' + username + ':' + password + '@some.server.com';
request({url: url}, function (error, response, body) {
// Do more stuff with 'body' here
});
options = {
url: 'https://api.github.com/repos/request/request',
headers: {
'User-Agent': 'request'
}
};
function callback(error: any, response: http.IncomingMessage, body: string) {
if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
console.log(info.stargazers_count + " Stars");
console.log(info.forks_count + " Forks");
}
}
request(options, callback);
// OAuth1.0 - 3-legged server side flow (Twitter example)
// step 1
import qs = require('querystring');
const CONSUMER_KEY = 'key';
const CONSUMER_SECRET = 'secret';
var oauth =
{ callback: 'http://mysite.com/callback/'
, consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
}
, url = 'https://api.twitter.com/oauth/request_token'
;
request.post({url:url, oauth:oauth}, function (e, r, body) {
// Ideally, you would take the body in the response
// and construct a URL that a user clicks on (like a sign in button).
// The verifier is only available in the response after a user has
// verified with twitter that they are authorizing your app.
// step 2
var req_data = qs.parse(body);
var uri = 'https://api.twitter.com/oauth/authenticate'
+ '?' + qs.stringify({oauth_token: req_data.oauth_token});
// redirect the user to the authorize uri
// step 3
// after the user is redirected back to your server
var auth_data: any = qs.parse(body)
, oauth =
{ consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
, token: auth_data.oauth_token
, token_secret: req_data.oauth_token_secret
, verifier: auth_data.oauth_verifier
}
, url = 'https://api.twitter.com/oauth/access_token'
;
request.post({url:url, oauth:oauth}, function (e, r, body) {
// ready to make signed requests on behalf of the user
var perm_data: any = qs.parse(body);
var oauth =
{ consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
, token: perm_data.oauth_token
, token_secret: perm_data.oauth_token_secret
};
var url = 'https://api.twitter.com/1.1/users/show.json';
var query = {
screen_name: perm_data.screen_name,
user_id: perm_data.user_id
};
request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) {
console.log(user);
});
});
});
var path = require('path')
, certFile = path.resolve(__dirname, 'ssl/client.crt')
, keyFile = path.resolve(__dirname, 'ssl/client.key')
, caFile = path.resolve(__dirname, 'ssl/ca.cert.pem');
options = {
url: 'https://api.some-server.com/',
cert: fs.readFileSync(certFile),
key: fs.readFileSync(keyFile),
passphrase: 'password',
ca: fs.readFileSync(caFile)
};
request.get(options);
var path = require('path')
, certFile = path.resolve(__dirname, 'ssl/client.crt')
, keyFile = path.resolve(__dirname, 'ssl/client.key');
options = {
url: 'https://api.some-server.com/',
agentOptions: {
cert: fs.readFileSync(certFile),
key: fs.readFileSync(keyFile),
// Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format:
// pfx: fs.readFileSync(pfxFilePath),
passphrase: 'password',
securityOptions: 'SSL_OP_NO_SSLv3'
}
};
request.get(options);
request.get({
url: 'https://api.some-server.com/',
agentOptions: {
secureProtocol: 'SSLv3_method'
}
});
request.get({
url: 'https://api.some-server.com/',
agentOptions: {
ca: fs.readFileSync('ca.cert.pem')
}
});
request({
// will be ignored
method: 'GET',
uri: 'http://www.google.com',
// HTTP Archive Request Object
har: {
url: 'http://www.mockbin.com/har',
method: 'POST',
headers: [
{
name: 'content-type',
value: 'application/x-www-form-urlencoded'
}
],
postData: {
mimeType: 'application/x-www-form-urlencoded',
params: [
{
name: 'foo',
value: 'bar'
},
{
name: 'hello',
value: 'world'
}
]
}
}
});
//requests using baseRequest() will set the 'x-token' header
var baseRequest = request.defaults({
headers: {'x-token': 'my-token'}
});
//requests using specialRequest() will include the 'x-token' header set in
//baseRequest and will also include the 'special' header
var specialRequest = baseRequest.defaults({
headers: {special: 'special value'}
});
request.put(url);
request.patch(url);
request.post(url);
request.head(url);
request.del(url);
request.get(url);
request.cookie('key1=value1');
request.jar();
request.debug = true;
request.get('http://10.255.255.1', {timeout: 1500}, function(err) {
console.log(err.code === 'ETIMEDOUT');
// Set to `true` if the timeout was a connection timeout, `false` or
// `undefined` otherwise.
console.log(err.connect === true);
process.exit(0);
});
var rand = Math.floor(Math.random()*100000000).toString();
request(
{ method: 'PUT'
, uri: 'http://mikeal.iriscouch.com/testjs/' + rand
, multipart:
[ { 'content-type': 'application/json'
, body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
}
, { body: 'I am an attachment' }
]
}
, function (error, response, body) {
if(response.statusCode == 201){
console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)
} else {
console.log('error: '+ response.statusCode)
console.log(body)
}
}
);
request(
{ method: 'GET'
, uri: 'http://www.google.com'
, gzip: true
}
, function (error, response, body) {
// body is the decompressed response body
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
console.log('the decoded data is: ' + body)
}
).on('data', function(data: any) {
// decompressed data as it is received
console.log('decoded chunk: ' + data)
})
.on('response', function(response: http.IncomingMessage) {
// unmodified http.IncomingMessage object
response.on('data', function(data: any[]) {
// compressed data as it is received
console.log('received ' + data.length + ' bytes of compressed data')
})
});
var requestWithJar = request.defaults({jar: true})
requestWithJar('http://www.google.com', function () {
requestWithJar('http://images.google.com');
});
var j = request.jar()
requestWithJar = request.defaults({jar:j})
requestWithJar('http://www.google.com', function () {
requestWithJar('http://images.google.com');
});
var j = request.jar();
var cookie = request.cookie('key1=value1');
var url = 'http://www.google.com';
j.setCookie(cookie, url);
request({url: url, jar: j}, function () {
request('http://images.google.com');
});
//TODO: add definitions for tough-cookie-filestore
//var FileCookieStore = require('tough-cookie-filestore');
// NOTE - currently the 'cookies.json' file must already exist!
//var j = request.jar(new FileCookieStore('cookies.json'));
requestWithJar = request.defaults({ jar : j })
request('http://www.google.com', function() {
request('http://images.google.com');
});
var j = request.jar()
request({url: 'http://www.google.com', jar: j}, function () {
var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..."
var cookies = j.getCookies(url);
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...]
});
+16 -17
View File
@@ -1,31 +1,30 @@
// Type definitions for request-promise v0.4.2
// Project: https://www.npmjs.com/package/request-promise
// Definitions by: Christopher Glantschnig <https://github.com/cglantschnig/>
// Definitions by: Christopher Glantschnig <https://github.com/cglantschnig/>, Joe Skeen <http://github.com/joeskeen>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Change [0]: 2015/08/20 - Aya Morisawa <https://github.com/AyaMorisawa>
/// <reference path="../node/node.d.ts" />
/// <reference path="../form-data/form-data.d.ts" />
/// <reference path="../request/request.d.ts" />
/// <reference path="../bluebird/bluebird.d.ts" />
declare module 'request-promise' {
import request = require('request');
import stream = require('stream');
import http = require('http');
import FormData = require('form-data');
export = RequestPromiseAPI;
function RequestPromiseAPI(options: RequestPromiseAPI.Options): Promise<any>;
function RequestPromiseAPI(uri: string): Promise<request.Request>;
module RequestPromiseAPI {
export interface Options extends request.Options {
simple?: boolean;
transform?: (body: any, response: http.IncomingMessage) => any;
resolveWithFullResponse?: boolean;
}
interface RequestPromise extends request.Request {
then(onFulfilled: Function, onRejected?: Function): Promise<any>;
catch(onRejected: Function): Promise<any>;
finally(onFinished: Function): Promise<any>;
promise(): Promise<any>;
}
interface RequestPromiseOptions extends request.OptionalOptions {
simple?: boolean;
transform?: (body: any, response: http.IncomingMessage) => any;
resolveWithFullResponse?: boolean;
}
var requestPromise: request.RequestAPI<RequestPromise, RequestPromiseOptions>;
export = requestPromise;
}
+428 -11
View File
@@ -4,6 +4,7 @@ import request = require('request');
import http = require('http');
import stream = require('stream');
import formData = require('form-data');
import fs = require('fs');
var value: any;
var str: string;
@@ -20,7 +21,7 @@ var headers: {[key: string]: string};
var agent: http.Agent;
var write: stream.Writable;
var req: request.Request;
var form: formData.FormData;
var form1: formData.FormData;
var bodyArr: request.RequestPart[] = [{
body: value
@@ -32,7 +33,7 @@ var bodyArr: request.RequestPart[] = [{
// --- --- --- --- --- --- --- --- --- --- --- ---
str = req.toJSON();
obj = req.toJSON();
var cookieValue: request.CookieValue;
str = cookieValue.name;
@@ -125,8 +126,6 @@ req.destroy();
// --- --- --- --- --- --- --- --- --- --- --- ---
var callback: (error: any, response: any, body: any) => void;
value = request.initParams;
req = request(uri);
@@ -136,13 +135,6 @@ req = request(uri, callback);
req = request(options);
req = request(options, callback);
req = request.request(uri);
req = request.request(uri, options);
req = request.request(uri, options, callback);
req = request.request(uri, callback);
req = request.request(options);
req = request.request(options, callback);
req = request.get(uri);
req = request.get(uri, options);
req = request.get(uri, options, callback);
@@ -204,3 +196,428 @@ request
// check response
})
.pipe(request.put('http://another.com/another.png'));
//The following examples from https://github.com/request/request
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body); // Show the HTML for the Google homepage.
}
});
request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'));
fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'));
request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png'));
request
.get('http://google.com/img.png')
.on('response', function(response: any) {
console.log(response.statusCode); // 200
console.log(response.headers['content-type']); // 'image/png'
})
.pipe(request.put('http://mysite.com/img.png'));
request
.get('http://mysite.com/doodle.png')
.on('error', function(err: any) {
console.log(err);
})
.pipe(fs.createWriteStream('doodle.png'));
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
if (req.method === 'PUT') {
req.pipe(request.put('http://mysite.com/doodle.png'));
} else if (req.method === 'GET' || req.method === 'HEAD') {
request.get('http://mysite.com/doodle.png').pipe(resp);
}
}
});
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
var x = request('http://mysite.com/doodle.png');
req.pipe(x);
x.pipe(resp);
}
});
var resp: http.ServerResponse;
req.pipe(request('http://mysite.com/doodle.png')).pipe(resp);
http.createServer(function (req, resp) {
if (req.url === '/doodle.png') {
r.get('http://google.com/doodle.png').pipe(resp);
}
});
request.post('http://service.com/upload', {form:{key:'value'}});
// or
request.post('http://service.com/upload').form({key:'value'});
// or
request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ });
var data = {
// Pass a simple key-value pair
my_field: 'my_value',
// Pass data via Buffers
my_buffer: new Buffer([1, 2, 3]),
// Pass data via Streams
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
// Pass multiple values /w an Array
attachments: [
fs.createReadStream(__dirname + '/attachment1.jpg'),
fs.createReadStream(__dirname + '/attachment2.jpg')
],
// Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS}
// Use case: for some types of streams, you'll need to provide "file"-related information manually.
// See the `form-data` README for more information about options: https://github.com/felixge/node-form-data
custom_file: {
value: fs.createReadStream('/dev/urandom'),
options: {
filename: 'topsecret.jpg',
contentType: 'image/jpg'
}
}
};
request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
});
var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {});
var form = requestMultipart.form();
form.append('my_field', 'my_value');
form.append('my_buffer', new Buffer([1, 2, 3]));
form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'});
request({
method: 'PUT',
preambleCRLF: true,
postambleCRLF: true,
uri: 'http://service.com/upload',
multipart: {
chunked: false,
data: [
{
'content-type': 'application/json',
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
},
{ body: 'I am an attachment' }
]
}
},
function (error, response, body) {
if (error) {
return console.error('upload failed:', error);
}
console.log('Upload successful! Server responded with:', body);
});
request({
method: 'PUT',
preambleCRLF: true,
postambleCRLF: true,
uri: 'http://service.com/upload',
multipart: [
{
'content-type': 'application/json',
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
},
{ body: 'I am an attachment' },
{ body: fs.createReadStream('image.png') }
]
},
function (error, response, body) {
if (error) {
return console.error('upload failed:', error);
}
console.log('Upload successful! Server responded with:', body);
});
request.get('http://some.server.com/').auth('username', 'password', false);
// or
request.get('http://some.server.com/', {
'auth': {
'user': 'username',
'pass': 'password',
'sendImmediately': false
}
});
// or
request.get('http://some.server.com/').auth(null, null, true, 'bearerToken');
// or
request.get('http://some.server.com/', {
'auth': {
'bearer': 'bearerToken'
}
});
var username = 'username',
password = 'password',
url = 'http://' + username + ':' + password + '@some.server.com';
request({url: url}, function (error, response, body) {
// Do more stuff with 'body' here
});
options = {
url: 'https://api.github.com/repos/request/request',
headers: {
'User-Agent': 'request'
}
};
function callback(error: any, response: http.IncomingMessage, body: string) {
if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
console.log(info.stargazers_count + " Stars");
console.log(info.forks_count + " Forks");
}
}
request(options, callback);
// OAuth1.0 - 3-legged server side flow (Twitter example)
// step 1
import qs = require('querystring');
const CONSUMER_KEY = 'key';
const CONSUMER_SECRET = 'secret';
oauth =
{ callback: 'http://mysite.com/callback/'
, consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
}
, url = 'https://api.twitter.com/oauth/request_token'
;
request.post({url:url, oauth:oauth}, function (e, r, body) {
// Ideally, you would take the body in the response
// and construct a URL that a user clicks on (like a sign in button).
// The verifier is only available in the response after a user has
// verified with twitter that they are authorizing your app.
// step 2
var req_data = qs.parse(body);
var uri = 'https://api.twitter.com/oauth/authenticate'
+ '?' + qs.stringify({oauth_token: req_data.oauth_token});
// redirect the user to the authorize uri
// step 3
// after the user is redirected back to your server
var auth_data: any = qs.parse(body)
, oauth =
{ consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
, token: auth_data.oauth_token
, token_secret: req_data.oauth_token_secret
, verifier: auth_data.oauth_verifier
}
, url = 'https://api.twitter.com/oauth/access_token'
;
request.post({url:url, oauth:oauth}, function (e, r, body) {
// ready to make signed requests on behalf of the user
var perm_data: any = qs.parse(body);
var oauth =
{ consumer_key: CONSUMER_KEY
, consumer_secret: CONSUMER_SECRET
, token: perm_data.oauth_token
, token_secret: perm_data.oauth_token_secret
};
var url = 'https://api.twitter.com/1.1/users/show.json';
var query = {
screen_name: perm_data.screen_name,
user_id: perm_data.user_id
};
request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) {
console.log(user);
});
});
});
var path = require('path')
, certFile = path.resolve(__dirname, 'ssl/client.crt')
, keyFile = path.resolve(__dirname, 'ssl/client.key')
, caFile = path.resolve(__dirname, 'ssl/ca.cert.pem');
options = {
url: 'https://api.some-server.com/',
cert: fs.readFileSync(certFile),
key: fs.readFileSync(keyFile),
passphrase: 'password',
ca: fs.readFileSync(caFile)
};
request.get(options);
var path = require('path')
, certFile = path.resolve(__dirname, 'ssl/client.crt')
, keyFile = path.resolve(__dirname, 'ssl/client.key');
options = {
url: 'https://api.some-server.com/',
agentOptions: {
cert: fs.readFileSync(certFile),
key: fs.readFileSync(keyFile),
// Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format:
// pfx: fs.readFileSync(pfxFilePath),
passphrase: 'password',
securityOptions: 'SSL_OP_NO_SSLv3'
}
};
request.get(options);
request.get({
url: 'https://api.some-server.com/',
agentOptions: {
secureProtocol: 'SSLv3_method'
}
});
request.get({
url: 'https://api.some-server.com/',
agentOptions: {
ca: fs.readFileSync('ca.cert.pem')
}
});
request({
// will be ignored
method: 'GET',
uri: 'http://www.google.com',
// HTTP Archive Request Object
har: {
url: 'http://www.mockbin.com/har',
method: 'POST',
headers: [
{
name: 'content-type',
value: 'application/x-www-form-urlencoded'
}
],
postData: {
mimeType: 'application/x-www-form-urlencoded',
params: [
{
name: 'foo',
value: 'bar'
},
{
name: 'hello',
value: 'world'
}
]
}
}
});
//requests using baseRequest() will set the 'x-token' header
var baseRequest = request.defaults({
headers: {'x-token': 'my-token'}
});
//requests using specialRequest() will include the 'x-token' header set in
//baseRequest and will also include the 'special' header
var specialRequest = baseRequest.defaults({
headers: {special: 'special value'}
});
request.put(url);
request.patch(url);
request.post(url);
request.head(url);
request.del(url);
request.get(url);
request.cookie('key1=value1');
request.jar();
request.debug = true;
request.get('http://10.255.255.1', {timeout: 1500}, function(err) {
console.log(err.code === 'ETIMEDOUT');
// Set to `true` if the timeout was a connection timeout, `false` or
// `undefined` otherwise.
console.log(err.connect === true);
process.exit(0);
});
var rand = Math.floor(Math.random()*100000000).toString();
request(
{ method: 'PUT'
, uri: 'http://mikeal.iriscouch.com/testjs/' + rand
, multipart:
[ { 'content-type': 'application/json'
, body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
}
, { body: 'I am an attachment' }
]
}
, function (error, response, body) {
if(response.statusCode == 201){
console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)
} else {
console.log('error: '+ response.statusCode)
console.log(body)
}
}
);
request(
{ method: 'GET'
, uri: 'http://www.google.com'
, gzip: true
}
, function (error, response, body) {
// body is the decompressed response body
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
console.log('the decoded data is: ' + body)
}
).on('data', function(data: any) {
// decompressed data as it is received
console.log('decoded chunk: ' + data)
})
.on('response', function(response: http.IncomingMessage) {
// unmodified http.IncomingMessage object
response.on('data', function(data: any[]) {
// compressed data as it is received
console.log('received ' + data.length + ' bytes of compressed data')
})
});
var requestWithJar = request.defaults({jar: true})
requestWithJar('http://www.google.com', function () {
requestWithJar('http://images.google.com');
});
var j = request.jar()
requestWithJar = request.defaults({jar:j})
requestWithJar('http://www.google.com', function () {
requestWithJar('http://images.google.com');
});
var j = request.jar();
cookie = request.cookie('key1=value1');
var url = 'http://www.google.com';
j.setCookie(cookie, url);
request({url: url, jar: j}, function () {
request('http://images.google.com');
});
//TODO: add definitions for tough-cookie-filestore
//var FileCookieStore = require('tough-cookie-filestore');
// NOTE - currently the 'cookies.json' file must already exist!
//var j = request.jar(new FileCookieStore('cookies.json'));
requestWithJar = request.defaults({ jar : j })
request('http://www.google.com', function() {
request('http://images.google.com');
});
var j = request.jar()
request({url: 'http://www.google.com', jar: j}, function () {
var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..."
var cookies = j.getCookies(url);
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...]
});
+85 -43
View File
@@ -1,6 +1,6 @@
// Type definitions for request
// Project: https://github.com/mikeal/request
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>, Joe Skeen <http://github.com/joeskeen>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts
@@ -13,53 +13,56 @@ declare module 'request' {
import http = require('http');
import FormData = require('form-data');
import url = require('url');
import fs = require('fs');
export = RequestAPI;
namespace request {
export interface RequestAPI<TRequest extends Request, TOptions extends OptionalOptions> {
defaults(options: TOptions): RequestAPI<TRequest, TOptions>;
(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
(uri: string, callback?: RequestCallback): TRequest;
(options?: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
function RequestAPI(uri: string, options?: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request;
function RequestAPI(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request;
function RequestAPI(options: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request;
get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
get(uri: string, callback?: RequestCallback): TRequest;
get(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
module RequestAPI {
export function defaults(options: Options): typeof RequestAPI;
post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
post(uri: string, callback?: RequestCallback): TRequest;
post(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
export function request(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function request(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function request(options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
put(uri: string, callback?: RequestCallback): TRequest;
put(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
export function get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
head(uri: string, callback?: RequestCallback): TRequest;
head(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
export function post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
patch(uri: string, callback?: RequestCallback): TRequest;
patch(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
export function put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
del(uri: string, callback?: RequestCallback): TRequest;
del(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
export function head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
forever(agentOptions: any, optionsArg: any): TRequest;
jar(): CookieJar;
cookie(str: string): Cookie;
export function patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
initParams: any;
debug: boolean;
}
export function del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
export function del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
interface UriOptions {
uri: string;
}
export function forever(agentOptions: any, optionsArg: any): Request;
export function jar(): CookieJar;
export function cookie(str: string): Cookie;
interface UrlOptions {
url: string;
}
export var initParams: any;
export interface Options {
url?: string;
uri?: string;
interface OptionalOptions {
callback?: (error: any, response: http.IncomingMessage, body: any) => void;
jar?: any; // CookieJar
formData?: any; // Object
@@ -67,10 +70,10 @@ declare module 'request' {
auth?: AuthOptions;
oauth?: OAuthOptions;
aws?: AWSOptions;
hawk ?: HawkOptions;
hawk?: HawkOptions;
qs?: any;
json?: any;
multipart?: RequestPart[];
multipart?: RequestPart[] | Multipart;
agentOptions?: any;
agentClass?: any;
forever?: any;
@@ -79,7 +82,7 @@ declare module 'request' {
method?: string;
headers?: Headers;
body?: any;
followRedirect?: boolean|((response: http.IncomingMessage) => boolean);
followRedirect?: boolean | ((response: http.IncomingMessage) => boolean);
followAllRedirects?: boolean;
maxRedirects?: number;
encoding?: string;
@@ -88,6 +91,43 @@ declare module 'request' {
proxy?: any;
strictSSL?: boolean;
gzip?: boolean;
preambleCRLF?: boolean;
postambleCRLF?: boolean;
key?: Buffer;
cert?: Buffer;
passphrase?: string;
ca?: Buffer;
har?: HttpArchiveRequest;
}
export type RequiredOptions = UriOptions | UrlOptions;
export type Options = RequiredOptions & OptionalOptions;
export interface RequestCallback {
(error: any, response: http.IncomingMessage, body: any): void;
}
export interface HttpArchiveRequest {
url?: string;
method?: string;
headers?: NameValuePair[];
postData?: {
mimeType?: string;
params?: NameValuePair[];
}
}
export interface NameValuePair {
name: string;
value: string;
}
export interface Multipart {
chunked?: boolean;
data?: {
'content-type'?: string,
body: string
}[];
}
export interface RequestPart {
@@ -129,7 +169,7 @@ declare module 'request' {
resume(): void;
abort(): void;
destroy(): void;
toJSON(): string;
toJSON(): Object;
}
export interface Headers {
@@ -164,9 +204,9 @@ declare module 'request' {
}
export interface CookieJar {
setCookie(cookie: Cookie, uri: string|url.Url, options?: any): void
getCookieString(uri: string|url.Url): string
getCookies(uri: string|url.Url): Cookie[]
setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void
getCookieString(uri: string | url.Url): string
getCookies(uri: string | url.Url): Cookie[]
}
export interface CookieValue {
@@ -183,4 +223,6 @@ declare module 'request' {
toString(): string;
}
}
var request: request.RequestAPI<request.Request, request.OptionalOptions>;
export = request;
}
+11201 -11013
View File
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -10,7 +10,7 @@ Its prototype is simple:
string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]])
*/
declare module "sprintf-js" {
declare module sprintf_js {
/** sprintf.js is a complete open source JavaScript sprintf implementation for the browser and node.js.
Its prototype is simple:
string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]])
@@ -69,3 +69,10 @@ X - yields an integer as a hexadecimal number (upper-case)
*/
export function vsprintf(fmt: string, args: any[]): string;
}
declare module "sprintf-js" {
export =sprintf_js;
}
declare var sprintf: typeof sprintf_js.sprintf;
declare var vsprintf: typeof sprintf_js.vsprintf;
+9 -9
View File
@@ -12,9 +12,9 @@ columnDef.aggregationHideLabel = false;
columnDef.aggregationType = 1;
columnDef.aggregationType = function () { return 1; };
columnDef.cellClass = 'test';
columnDef.cellClass = (gridRow, gridCol, index) => {
//types of gridRow, gridCol, and index are flowed in correctly
return `${gridRow.entity.name}-${gridCol.field}-${index + 1}`;
columnDef.cellClass = (grid, gridRow, gridCol, rowIndex, colIndex) => {
//types of grid, gridRow, gridCol, rowIndex and colIndex are flowed in correctly
return `${grid.footerHeight}-${gridRow.entity.name}-${gridCol.field}-${rowIndex + 1}-${colIndex + 1}`;
};
columnDef.cellFilter = 'date';
columnDef.cellTemplate = '<div blah="something">hello</div>';
@@ -44,17 +44,17 @@ columnDef.filter = {
columnDef.filterCellFiltered = false;
columnDef.filterHeaderTemplate = '<div blah="test"></div>';
columnDef.filters = [columnDef.filter];
columnDef.footerCellClass = (gridRow, rowRenderIndex, gridCol, colRenderIndex) => {
//types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly
return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`;
columnDef.footerCellClass = (grid, gridRow, gridCol, rowRenderIndex, colRenderIndex) => {
//types for grid, gridRow, gridCol, rowRenderIndex, and colRenderIndex flow in properly
return `${grid.footerHeight}-${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`;
};
columnDef.footerCellClass = 'theClass';
columnDef.footerCellFilter = 'currency:$';
columnDef.footerCellTemplate = '<div class="yoshi"></div>';
columnDef.headerCellClass =
(gridRow, rowRenderIndex, gridCol, colRenderIndex) => {
//types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly
return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`;
(grid, gridRow, gridCol, rowRenderIndex, colRenderIndex) => {
//types for grid, gridRow, gridCol, rowRenderIndex, and colRenderIndex flow in properly
return `${grid.footerHeight}-${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`;
};
columnDef.headerCellClass = 'classy';
columnDef.headerCellFilter = 'currency:$';
+15 -2
View File
@@ -609,6 +609,13 @@ declare module uiGrid {
* @default false
*/
enableFiltering?: boolean;
/**
* False by default. When enabled, this adds a settings icon in the top right of the grid,
* which floats above the column header. The menu by default gives access to show/hide columns,
* but can be customized to show additional actions.
* @default false
*/
enableGridMenu?: boolean;
/**
* uiGridConstants.scrollbars.ALWAYS by default. This settings controls the horizontal scrollbar for the grid.
* Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER
@@ -819,6 +826,12 @@ declare module uiGrid {
* @default 20
*/
virtualizationThreshold?: number;
/**
* Disables client side filtering. When true, handle the filterChanged event and set data,
* defaults to false
* @default false
*/
useExternalFiltering?: boolean;
/**
* Default time in milliseconds to throttle scroll events to, defaults to 70ms
* @default 70
@@ -3767,7 +3780,7 @@ declare module uiGrid {
}
export interface ICellClassGetter<TEntity> {
(gridRow?: IGridRowOf<TEntity>, gridCol?: IGridColumnOf<TEntity>, colRenderIndex?: number): string;
(grid?: IGridInstanceOf<TEntity>, gridRow?: IGridRowOf<TEntity>, gridCol?: IGridColumnOf<TEntity>, rowRenderIndex?: number, colRenderIndex?: number): string;
}
export interface ICellTooltipGetter<TEntity> {
@@ -3777,7 +3790,7 @@ declare module uiGrid {
(gridCol: IGridColumnOf<TEntity>): string;
}
export interface IHeaderFooterCellClassGetter<TEntity> {
(gridRow: IGridRowOf<TEntity>, rowRenderIndex: number, gridCol: IGridColumnOf<TEntity>, colRenderIndex: number)
(grid: IGridInstanceOf<TEntity>, gridRow: IGridRowOf<TEntity>, gridCol: IGridColumnOf<TEntity>, rowRenderIndex: number, colRenderIndex: number)
: string;
}
export interface IMenuItem {
+4
View File
@@ -230,3 +230,7 @@ declare var URI: uri.URIStatic;
declare module 'URI' {
export = URI;
}
declare module 'urijs' {
export = URI;
}
+14 -14
View File
@@ -7,37 +7,37 @@ vox.init({
micRequired: true
});
vox.addEventListener("SDKReady", function(event: VoxImplant.Events.SDKReady) {
vox.addEventListener(VoxImplant.Events.SDKReady, function(event: VoxImplant.Events.SDKReady) {
console.log("VoxImplant SDK ver. " + event.version + " initialized");
vox.connect();
});
vox.addEventListener("ConnectionEstablished", function(event: VoxImplant.Events.ConnectionEstablished) {
vox.addEventListener(VoxImplant.Events.ConnectionEstablished, function(event: VoxImplant.Events.ConnectionEstablished) {
console.log("Connection established");
vox.login("username", "password");
});
vox.addEventListener("ConnectionClosed", function(event: VoxImplant.Events.ConnectionClosed) {
vox.addEventListener(VoxImplant.Events.ConnectionClosed, function(event: VoxImplant.Events.ConnectionClosed) {
console.log("Connection closed");
});
vox.addEventListener("ConnectionFailed", function(event: VoxImplant.Events.ConnectionFailed) {
vox.addEventListener(VoxImplant.Events.ConnectionFailed, function(event: VoxImplant.Events.ConnectionFailed) {
console.log("Connection failed. Reason: " + event.message);
});
vox.addEventListener("AuthEvent", function(event: VoxImplant.Events.AuthEvent) {
vox.addEventListener(VoxImplant.Events.AuthResult, function(event: VoxImplant.Events.AuthResult) {
if (event.result === true) {
// Authorized successfully
console.log("Logged in as " + event.displayName);
call = vox.call("some_number", false);
call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) {
call.addEventListener(VoxImplant.CallEvents.Connected, function(callevent: VoxImplant.CallEvents.Connected) {
console.log("Call connected");
});
call.addEventListener("Failed", function(callevent: VoxImplant.CallEvents.Failed) {
call.addEventListener(VoxImplant.CallEvents.Failed, function(callevent: VoxImplant.CallEvents.Failed) {
console.log("Call failed, reason: " + callevent.reason);
});
call.addEventListener("Disconnected", function(callevent: VoxImplant.CallEvents.Disconnected) {
call.addEventListener(VoxImplant.CallEvents.Disconnected, function(callevent: VoxImplant.CallEvents.Disconnected) {
console.log("Call disconnected");
});
@@ -48,13 +48,13 @@ vox.addEventListener("AuthEvent", function(event: VoxImplant.Events.AuthEvent) {
}
});
vox.addEventListener("MicAccessResult", function(event: VoxImplant.Events.MicAccessResult) {
vox.addEventListener(VoxImplant.Events.MicAccessResult, function(event: VoxImplant.Events.MicAccessResult) {
console.log("Microphone access allowed: " + event.result);
});
vox.addEventListener("IncomingCall", function(event: VoxImplant.Events.IncomingCall) {
vox.addEventListener(VoxImplant.Events.IncomingCall, function(event: VoxImplant.Events.IncomingCall) {
call = event.call;
call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) {
call.addEventListener(VoxImplant.CallEvents.Connected, function(callevent: VoxImplant.CallEvents.Connected) {
console.log("Inbound Call Connected");
setTimeout(function() {
vox.disconnect();
@@ -63,11 +63,11 @@ vox.addEventListener("IncomingCall", function(event: VoxImplant.Events.IncomingC
call.answer();
});
vox.addEventListener("MessageReceived", function(event: VoxImplant.IMEvents.MessageReceived) {
vox.addEventListener(VoxImplant.IMEvents.MessageReceived, function(event: VoxImplant.IMEvents.MessageReceived) {
console.log("Message received: " + event.content + " from " + event.id + " id " + event.message_id);
});
vox.addEventListener("SourcesInfoUpdated", function(event: VoxImplant.Events.SourcesInfoUpdated) {
vox.addEventListener(VoxImplant.Events.SourcesInfoUpdated, function(event: VoxImplant.Events.SourcesInfoUpdated) {
var audioSources: VoxImplant.AudioSourceInfo[] = vox.audioSources(),
videoSources: VoxImplant.VideoSourceInfo[] = vox.videoSources();
console.log("Received recording sources data:");
@@ -78,7 +78,7 @@ vox.addEventListener("SourcesInfoUpdated", function(event: VoxImplant.Events.Sou
vox.useVideoSource(videoSources[0].id, function() { console.log('OK'); }, function() { console.log('Failed'); });
});
vox.addEventListener("RosterReceived", function(event: VoxImplant.IMEvents.RosterReceived) {
vox.addEventListener(VoxImplant.IMEvents.RosterReceived, function(event: VoxImplant.IMEvents.RosterReceived) {
var roster: VoxImplant.RosterItem[] = event.roster;
console.log("Roster received: " + roster);
});
+53 -7
View File
@@ -5,12 +5,58 @@
declare namespace VoxImplant {
/**
* VoxImplant.Client general events
*/
enum Events {
AuthResult,
ConnectionClosed,
ConnectionEstablished,
ConnectionFailed,
IMError,
IncomingCall,
MicAccessResult,
NetStatsReceived,
PlaybackFinished,
SDKReady,
SourcesInfoUpdated
}
/**
* VoxImplant.Client Instant Messaging and Presence events
*/
enum IMEvents {
ChatStateUpdate,
MessageReceived,
MessageStatus,
PresenceUpdate,
RosterItemChange,
RosterPresenceUpdate,
RosterReceived,
SubscriptionRequest
}
/**
* VoxImplant.Call events
*/
enum CallEvents {
Connected,
Disconnected,
Failed,
InfoReceived,
MessageReceived,
ProgressToneStart,
ProgressToneStop,
TransferComplete,
TransferFailed
}
module Events {
/**
* Event dispatched after login , loginWithOneTimeKey, requestOneTimeLoginKey or loginWithCode function call
*/
interface AuthEvent {
interface AuthResult {
/**
* Auth error code, possible values are: 301 - code for 'code' auth type was sent, 302 - key for 'onetimekey' auth type received, 401 - invalid password, 404 - invalid username, 403 - user account is frozen, 500 - internal error
*/
@@ -20,7 +66,7 @@ declare namespace VoxImplant {
*/
displayName?: string;
/**
* This parameter is used to calculate hash parameter for loginWithOneTimeKey method. AuthEvent with the key dispatched after requestOneTimeLoginKey method was called
* This parameter is used to calculate hash parameter for loginWithOneTimeKey method. AuthResult with the key dispatched after requestOneTimeLoginKey method was called
*/
key?: string;
/**
@@ -420,7 +466,7 @@ declare namespace VoxImplant {
}
type VoxImplantEvent = Events.AuthEvent | Events.ConnectionClosed | Events.ConnectionEstablished |
type VoxImplantEvent = Events.AuthResult | Events.ConnectionClosed | Events.ConnectionEstablished |
Events.ConnectionFailed | Events.IMError | Events.IncomingCall | Events.MicAccessResult |
Events.NetStatsReceived | Events.PlaybackFinished | Events.SDKReady | Events.SourcesInfoUpdated;
@@ -666,7 +712,7 @@ declare namespace VoxImplant {
* @param eventName Event name
* @param eventHandler Handler function. A single parameter is passed - object with the event information
*/
addEventListener(eventName: string, eventHandler: (eventObject: VoxImplantEvent | VoxImplantIMEvent) => any): void;
addEventListener(eventName: VoxImplant.Events | VoxImplant.IMEvents, eventHandler: (eventObject: VoxImplantEvent | VoxImplantIMEvent) => any): void;
/**
* Add roster item (IM)
*
@@ -777,7 +823,7 @@ declare namespace VoxImplant {
* @param eventName Event name
* @param eventHandler Handler function
*/
removeEventListener(eventName: string, eventHandler: () => any): void;
removeEventListener(eventName: VoxImplant.Events | VoxImplant.IMEvents, eventHandler: () => any): void;
/**
* Remove roster item (IM)
*
@@ -942,7 +988,7 @@ declare namespace VoxImplant {
* @param eventName Event name
* @param eventHandler Handler function. A single parameter is passed - object with the event information
*/
addEventListener(eventName: string, eventHandler: (eventObject: VoxImplantCallEvent) => any): void;
addEventListener(eventName: VoxImplant.CallEvents, eventHandler: (eventObject: VoxImplantCallEvent) => any): void;
/**
* Answer on incoming call
*
@@ -1002,7 +1048,7 @@ declare namespace VoxImplant {
* @param eventName Event name
* @param eventHandler Handler function
*/
removeEventListener(eventName: string, eventHandler: () => any): void;
removeEventListener(eventName: VoxImplant.CallEvents, eventHandler: () => any): void;
/**
* Send Info (SIP INFO) message inside the call
*
+65
View File
@@ -13,3 +13,68 @@ let contextModule = context<SomeModule>('./someModule');
require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => {
});
// check if HMR is enabled
if(module.hot) {
// accept update of dependency
module.hot.accept("./handler.js", function() {
//...
});
}
module.exports = null;
// check if HMR is enabled
if(module.hot) {
// accept itself
module.hot.accept();
// dispose handler
module.hot.dispose(function() {
// revoke the side effect
//...
});
}
class ModuleData {
updated: boolean;
}
if (module.hot) {
module.hot.accept((err: Error) => {
//...
});
module.hot.decline("./someModule");
module.hot.dispose((data: ModuleData) => {
data.updated = true;
// ...
});
let disposeHandler: ((data: ModuleData) => void) = data => {
// ...
};
module.hot.addDisposeHandler(disposeHandler);
module.hot.removeDisposeHandler(disposeHandler);
module.hot.check(true, (err: Error, outdatedModules: (string|number)[]) => {
// ...
});
module.hot.apply({ ignoreUnaccepted: true }, (err: Error, outdatedModules: (string|number)[]) => {
// ...
});
var status: string = module.hot.status();
let statusHandler: ((status: string) => void) = status => {
// ...
};
module.hot.status(statusHandler);
module.hot.addStatusHandler(statusHandler);
module.hot.removeStatusHandler(statusHandler);
}
+129
View File
@@ -51,6 +51,133 @@ declare namespace __WebpackModuleApi {
[id: string]: any;
}
}
interface Module {
exports: any;
require(id: string): any;
id: string;
filename: string;
loaded: boolean;
parent: any;
children: any[];
hot: Hot;
}
type ModuleId = string|number;
interface Hot {
/**
* Accept code updates for the specified dependencies. The callback is called when dependencies were replaced.
* @param dependencies
* @param callback
*/
accept(dependencies: string[], callback: (updatedDependencies: ModuleId[]) => void): void;
/**
* Accept code updates for the specified dependencies. The callback is called when dependencies were replaced.
* @param dependency
* @param callback
*/
accept(dependency: string, callback: () => void): void;
/**
* Accept code updates for this module without notification of parents.
* This should only be used if the module doesnt export anything.
* The errHandler can be used to handle errors that occur while loading the updated module.
* @param errHandler
*/
accept(errHandler?: (err: Error) => void): void;
/**
* Do not accept updates for the specified dependencies. If any dependencies is updated, the code update fails with code "decline".
*/
decline(dependencies: string[]): void;
/**
* Do not accept updates for the specified dependencies. If any dependencies is updated, the code update fails with code "decline".
*/
decline(dependency: string): void;
/**
* Flag the current module as not update-able. If updated the update code would fail with code "decline".
*/
decline(): void;
/**
* Add a one time handler, which is executed when the current module code is replaced.
* Here you should destroy/remove any persistent resource you have claimed/created.
* If you want to transfer state to the new module, add it to data object.
* The data will be available at module.hot.data on the new module.
* @param callback
*/
dispose<T>(callback: (data: T) => void): void;
/**
* Add a one time handler, which is executed when the current module code is replaced.
* Here you should destroy/remove any persistent resource you have claimed/created.
* If you want to transfer state to the new module, add it to data object.
* The data will be available at module.hot.data on the new module.
* @param callback
*/
addDisposeHandler<T>(callback: (data: T) => void): void;
/**
* Remove a handler.
* This can useful to add a temporary dispose handler. You could i. e. replace code while in the middle of a multi-step async function.
* @param callback
*/
removeDisposeHandler<T>(callback: (data: T) => void): void;
/**
* Throws an exceptions if status() is not idle.
* Check all currently loaded modules for updates and apply updates if found.
* If no update was found, the callback is called with null.
* If autoApply is truthy the callback will be called with all modules that were disposed.
* apply() is automatically called with autoApply as options parameter.
* If autoApply is not set the callback will be called with all modules that will be disposed on apply().
* @param autoApply
* @param callback
*/
check(autoApply: boolean, callback: (err: Error, outdatedModules: ModuleId[]) => void): void;
/**
* Throws an exceptions if status() is not idle.
* Check all currently loaded modules for updates and apply updates if found.
* If no update was found, the callback is called with null.
* The callback will be called with all modules that will be disposed on apply().
* @param callback
*/
check(callback: (err: Error, outdatedModules: ModuleId[]) => void): void;
/**
* If status() != "ready" it throws an error.
* Continue the update process.
* @param options
* @param callback
*/
apply(options: AcceptOptions, callback: (err: Error, outdatedModules: ModuleId[]) => void): void;
/**
* If status() != "ready" it throws an error.
* Continue the update process.
* @param callback
*/
apply(callback: (err: Error, outdatedModules: ModuleId[]) => void): void;
/**
* Return one of idle, check, watch, watch-delay, prepare, ready, dispose, apply, abort or fail.
*/
status(): string;
/** Register a callback on status change. */
status(callback: (status: string) => void): void;
/** Register a callback on status change. */
addStatusHandler(callback: (status: string) => void): void;
/**
* Remove a registered status change handler.
* @param callback
*/
removeStatusHandler(callback: (status: string) => void): void;
active: boolean;
data: {};
}
interface AcceptOptions {
/**
* If true the update process continues even if some modules are not accepted (and would bubble to the entry point).
*/
ignoreUnaccepted?: boolean;
/**
* Indicates that apply() is automatically called by check function
*/
autoApply?: boolean;
}
}
declare var require: __WebpackModuleApi.RequireFunction;
@@ -101,3 +228,5 @@ declare var __non_webpack_require__: any;
* Equals the config option debug
*/
declare var DEBUG: boolean;
declare var module: __WebpackModuleApi.Module;
+4
View File
@@ -380,6 +380,10 @@ example = function () {
promise = nodefn.apply(nodeFn2, [1, '2']);
example = function() {
nodefn.apply(fs.read, arguments);
}
example = function () {
var loadPasswd = nodefn.apply(fs.readFile, ['/etc/passwd']);
+6 -6
View File
@@ -316,12 +316,12 @@ declare module "when/node" {
): when.Promise<T>;
function apply<T>(fn: _.NodeFn0<T>, args: any[]): when.Promise<T>;
function apply<T>(fn: _.NodeFn1<any, T>, args: any[]): when.Promise<T>;
function apply<T>(fn: _.NodeFn2<any, any, T>, args: any[]): when.Promise<T>;
function apply<T>(fn: _.NodeFn3<any, any, any, T>, args: any[]): when.Promise<T>;
function apply<T>(fn: _.NodeFn4<any, any, any, any, T>, args: any[]): when.Promise<T>;
function apply<T>(fn: _.NodeFn5<any, any, any, any, any, T>, args: any[]): when.Promise<T>;
function apply<T>(fn: _.NodeFn0<T>, args: any[] | IArguments): when.Promise<T>;
function apply<T>(fn: _.NodeFn1<any, T>, args: any[] | IArguments): when.Promise<T>;
function apply<T>(fn: _.NodeFn2<any, any, T>, args: any[] | IArguments): when.Promise<T>;
function apply<T>(fn: _.NodeFn3<any, any, any, T>, args: any[] | IArguments): when.Promise<T>;
function apply<T>(fn: _.NodeFn4<any, any, any, any, T>, args: any[] | IArguments): when.Promise<T>;
function apply<T>(fn: _.NodeFn5<any, any, any, any, any, T>, args: any[] | IArguments): when.Promise<T>;
function liftAll(srcApi: any, transform?: (destApi: any, liftedFunc: Function, name: string) => any, destApi?: any): any;
+5 -2
View File
@@ -50,8 +50,8 @@ declare module YT {
}
export interface PlayerOptions {
width?: number;
height?: number;
width?: string | number;
height?: string | number;
videoId?: string;
playerVars?: PlayerVars;
events?: Events;
@@ -147,6 +147,9 @@ declare module YT {
// Event Listener
addEventListener(event: string, handler: EventHandler): void;
// DOM
destroy(): void;
}
export enum PlayerState {