From 58e16ecbc393c3611359e90a3432f52a3a4bfeda Mon Sep 17 00:00:00 2001 From: James Trinklein Date: Mon, 25 Apr 2016 07:10:54 -0700 Subject: [PATCH 01/67] Update restify types add route spec (#9082) * restify: fix compile errors in test file did not compile without error when compiling with: `tsc --noImplicitAny restify/restify-tests.ts` * restify: add RouteSpec interface --- restify/restify-tests.ts | 34 ++++++++++++++++++++-------------- restify/restify.d.ts | 9 ++++++++- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/restify/restify-tests.ts b/restify/restify-tests.ts index ca3c5000ef..c6905878b4 100644 --- a/restify/restify-tests.ts +++ b/restify/restify-tests.ts @@ -4,7 +4,7 @@ import restify = require("restify"); var server = restify.createServer({ formatters: { - 'application/foo': function formatFoo(req, res, body) { + 'application/foo': function formatFoo(req: restify.Request, res: restify.Response, body: any) { if (body instanceof Error) return body.stack; @@ -37,7 +37,7 @@ server.use((req, res, next)=>{}); server.use([(req, res, next)=>{}]); server.use((req, res, next)=>{}, (req, res, next)=>{}); -function send(req, res, next) { +function send(req: restify.Request, res: restify.Response, next: restify.Next) { req.header('key', 'val'); req.header('key') === 'val'; @@ -77,7 +77,7 @@ function send(req, res, next) { res.code === 50; res.contentLength === 50; - res.charSet === 'test'; + res.charSet('test'); res.contentType === 'test'; res.headers; res.id === 'test'; @@ -249,7 +249,15 @@ server.on('after', restify.auditLogger({ log: ()=>{} })); -restify.defaultResponseHeaders = function(data) { +server.on('after', (req: restify.Request, res: restify.Response, route: restify.Route, err: any) => { + route.spec.method === 'GET'; + route.spec.name === 'routeName'; + route.spec.path === '/some/path'; + route.spec.versions === ['v1']; + restify.auditLogger({ log: ()=>{} })(req, res, route, err); +}); + +restify.defaultResponseHeaders = function(data: any) { this.header('Server', 'helloworld'); }; @@ -276,18 +284,16 @@ client = restify.createStringClient({ version: "" }); -client.get("test", send); -client.head('test', send); -client.post('path', {}, send); -client.put('path', {}, send); -client.del('path', send); +client.head('test', function(err: any, req: restify.Request, res: restify.Response) { }); +client.put('path', {}, function(err: any, req: restify.Request, res: restify.Response, obj: any) { }); +client.del('path', function(err: any, req: restify.Request, res: restify.Response) { }); -client.post('/foo', { hello: 'world' }, function(err, req, res, obj) { +client.post('/foo', { hello: 'world' }, function(err: any, req: restify.Request, res: restify.Response, obj: any) { console.log('%d -> %j', res.statusCode, res.headers); console.log('%j', obj); }); -client.get('/foo/bar', function(err, req, res, data) { +client.get('/foo/bar', function(err: any, req: restify.Request, res: restify.Response, data: string) { console.log('%s', data); }); @@ -295,13 +301,13 @@ var client2 = restify.createClient({ url: 'http://127.0.0.1' }); -client2.get('/str/mcavage', function(err, req) { +client2.get('/str/mcavage', function(err: any, req: any) { - req.on('result', function(err, res) { + req.on('result', function(err: any, res: any) { res.body = ''; res.setEncoding('utf8'); - res.on('data', function(chunk) { + res.on('data', function(chunk: string) { res.body += chunk; }); diff --git a/restify/restify.d.ts b/restify/restify.d.ts index ec6fd26b6e..f68ea0b2cc 100644 --- a/restify/restify.d.ts +++ b/restify/restify.d.ts @@ -73,11 +73,18 @@ declare module "restify" { id: string; } + interface RouteSpec { + method: string; + name: string; + path: string; + versions: string[]; + } + interface Route { name: string; method: string; path: RoutePathRegex; - spec: Object; + spec: RouteSpec; types: string[]; versions: string[]; } From ed7feb8223518d5af92381813b1fd79a934aa683 Mon Sep 17 00:00:00 2001 From: pafflique Date: Mon, 25 Apr 2016 17:11:05 +0300 Subject: [PATCH 02/67] jest.mock should accept optional factory (#9079) https://facebook.github.io/jest/docs/api.html#jest-mock-modulename-factory --- jest/jest.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest/jest.d.ts b/jest/jest.d.ts index 033dd23faa..451b9abc88 100644 --- a/jest/jest.d.ts +++ b/jest/jest.d.ts @@ -29,7 +29,7 @@ declare namespace jest { function fn(implementation?: Function): Mock; function dontMock(moduleName: string): void; function genMockFromModule(moduleName: string): Mock; - function mock(moduleName: string): void; + function mock(moduleName: string, factory?: Function): void; function runAllTicks(): void; function runAllTimers(): void; function runOnlyPendingTimers(): void; From 2989fcf3d39f30bc9a8f6c25b59c47969aad48af Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 25 Apr 2016 16:23:46 +0200 Subject: [PATCH 03/67] Update to Electron 0.37.7 (#9086) * Update to Electron 0.37.7 * Add Electron specific process API --- github-electron/github-electron-main-tests.ts | 29 +++++- .../github-electron-renderer-tests.ts | 10 ++ github-electron/github-electron.d.ts | 92 +++++++++++++++++-- 3 files changed, 122 insertions(+), 9 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index 1366a82022..27d6599596 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -65,7 +65,7 @@ app.on('ready', () => { mainWindow.webContents.openDevTools(); mainWindow.webContents.toggleDevTools(); - mainWindow.webContents.openDevTools({detach: true}); + mainWindow.webContents.openDevTools({mode: 'detach'}); mainWindow.webContents.closeDevTools(); mainWindow.webContents.addWorkSpace('/path/to/workspace'); mainWindow.webContents.removeWorkSpace('/path/to/workspace'); @@ -337,6 +337,9 @@ win.on('closed', () => { win.loadURL('https://github.com'); win.show(); +var toolbarRect = document.getElementById('toolbar').getBoundingClientRect(); +win.setSheetOffset(toolbarRect.height); + // content-tracing // https://github.com/atom/electron/blob/master/docs/api/content-tracing.md @@ -517,12 +520,20 @@ var template = [ { label: 'Reload', accelerator: 'Command+R', - click: () => { BrowserWindow.getFocusedWindow().webContents.reloadIgnoringCache(); } + click: (item, focusedWindow) => { + if (focusedWindow) { + focusedWindow.webContents.reloadIgnoringCache(); + } + } }, { label: 'Toggle DevTools', accelerator: 'Alt+Command+I', - click: () => { BrowserWindow.getFocusedWindow().webContents.toggleDevTools(); } + click: (item, focusedWindow) => { + if (focusedWindow) { + focusedWindow.webContents.toggleDevTools(); + } + } } ] }, @@ -703,6 +714,18 @@ var image = clipboard.readImage(); var appIcon3 = new Tray(image); var appIcon4 = new Tray('/Users/somebody/images/icon.png'); +// process +// https://github.com/electron/electron/blob/master/docs/api/process.md + +console.log(process.type); +console.log(process.resourcesPath); +console.log(process.mas); +console.log(process.windowsStore); +process.noAsar = true; +process.crash(); +process.hang(); +process.setFdLimit(8192); + // screen // https://github.com/atom/electron/blob/master/docs/api/screen.md diff --git a/github-electron/github-electron-renderer-tests.ts b/github-electron/github-electron-renderer-tests.ts index 37faae9dbb..42d034c5c7 100644 --- a/github-electron/github-electron-renderer-tests.ts +++ b/github-electron/github-electron-renderer-tests.ts @@ -171,6 +171,16 @@ var image = clipboard.readImage(); var appIcon3 = new Tray(image); var appIcon4 = new Tray('/Users/somebody/images/icon.png'); +// https://github.com/electron/electron/blob/master/docs/api/process.md + +// preload.js +var _setImmediate = setImmediate; +var _clearImmediate = clearImmediate; +process.once('loaded', function() { + global.setImmediate = _setImmediate; + global.clearImmediate = _clearImmediate; +}); + // screen // https://github.com/atom/electron/blob/master/docs/api/screen.md diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index ec53909d50..3d4bd89835 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron v0.37.6 +// Type definitions for Electron v0.37.7 // Project: http://electron.atom.io/ // Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -297,6 +297,14 @@ declare namespace Electron { * Note: This is only implemented on OS X. */ isDarkMode(): boolean; + /** + * Imports the certificate in pkcs12 format into the platform certificate store. + * @param callback Called with the result of import operation, a value of 0 indicates success + * while any other value indicates failure according to chromium net_error_list. + * + * Note: This API is only available on Linux. + */ + importCertificate(options: ImportCertificateOptions, callback: (result: number) => void): void; commandLine: CommandLine; /** * Note: This API is only available on Mac. @@ -306,6 +314,17 @@ declare namespace Electron { type AppPathName = 'home'|'appData'|'userData'|'temp'|'exe'|'module'|'desktop'|'documents'|'downloads'|'music'|'pictures'|'videos'; + interface ImportCertificateOptions { + /** + * Path for the pkcs12 file. + */ + certificate: string; + /** + * Passphrase for the certificate. + */ + password: string; + } + interface CommandLine { /** * Append a switch [with optional value] to Chromium's command line. @@ -814,6 +833,11 @@ declare namespace Electron { * @returns The title of the native window. */ getTitle(): string; + /** + * Changes the attachment point for sheets on Mac OS X. + * Note: This API is available only on OS X. + */ + setSheetOffset(offset: number): void; /** * Starts or stops flashing the window to attract user's attention. */ @@ -2419,7 +2443,7 @@ declare namespace Electron { /** * The screen module retrieves information about screen size, displays, cursor position, etc. - * You should not use this module until the ready event of the app module is emitted. + * You can not use this module until the ready event of the app module is emitted. */ interface Screen extends NodeJS.EventEmitter { /** @@ -2547,7 +2571,7 @@ declare namespace Electron { webRequest: WebRequest; } - type Permission = 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen'; + type Permission = 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal'; interface ClearStorageDataOptions { /** @@ -3253,6 +3277,10 @@ declare namespace Electron { * @returns Whether web page is still loading resources. */ isLoading(): boolean; + /** + * @returns Whether the main frame (and not just iframes or frames within it) is still loading. + */ + isLoadingMainFrame(): boolean; /** * @returns Whether web page is waiting for a first-response for the main * resource of the page. @@ -3420,9 +3448,9 @@ declare namespace Electron { */ openDevTools(options?: { /** - * Opens devtools in a new window. + * Opens the devtools with specified dock state. Defaults to last used dock state. */ - detach?: boolean; + mode?: 'right' | 'bottom' | 'undocked' | 'detach' }): void; /** * Closes the developer tools. @@ -4234,7 +4262,7 @@ declare namespace Electron { * Emitted when a page's theme color changes. This is usually due to encountering a meta tag: * */ - addEventListener(type: 'did-change-theme-color', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + addEventListener(type: 'did-change-theme-color', listener: (event: WebViewElement.DidChangeThemeColorEvent) => void, useCapture?: boolean): void; /** * Emitted when DevTools is opened. */ @@ -4330,6 +4358,10 @@ declare namespace Electron { name: string; version: string; } + + interface DidChangeThemeColorEvent extends Event { + themeColor: string; + } } /** @@ -4424,6 +4456,54 @@ interface File { path: string; } +// https://github.com/electron/electron/blob/master/docs/api/process.md + +declare namespace NodeJS { + interface Process { + /** + * Process's type + */ + type: 'browser' | 'renderer'; + /** + * Path to JavaScript source code. + */ + resourcesPath: string; + /** + * For Mac App Store build, this value is true, for other builds it is undefined. + */ + mas?: boolean; + /** + * If the app is running as a Windows Store app (appx), this value is true, for other builds it is undefined. + */ + windowsStore?: boolean; + /** + * Emitted when Electron has loaded its internal initialization script + * and is beginning to load the web page or the main script. + */ + on(event: 'loaded', listener: Function): this; + on(event: string, listener: Function): this; + /** + * Setting this to true can disable the support for asar archives in Node's built-in modules. + */ + noAsar?: boolean; + /** + * Causes the main thread of the current process crash; + */ + crash(): void; + /** + * Causes the main thread of the current process hang. + */ + hang(): void; + /** + * Sets the file descriptor soft limit to maxDescriptors or the OS hard limit, + * whichever is lower for the current process. + * + * Note: This API is only available on Mac and Linux. + */ + setFdLimit(maxDescriptors: number): void; + } +} + declare module 'electron' { var electron: Electron.ElectronMainAndRenderer; export = electron; From 53a84ee8571160502b3456172d58ca84e296cbdc Mon Sep 17 00:00:00 2001 From: Marcus David Bronstein Date: Mon, 25 Apr 2016 11:28:27 -0300 Subject: [PATCH 04/67] adding microgears definitions (#9084) From 129f08fb205936f67997c98cbd16fed92e3c38a1 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Tue, 26 Apr 2016 00:34:26 +1000 Subject: [PATCH 05/67] `i18next.t("foo", {returnObjects: true})` returns an Object (#9077) * `t("foo", {returnObjects: true})` returns an Object * `t("foo", {returnObjects: true})` returns an Object * () will return Object you will have to cast it to any to access properties --- i18next/i18next.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index d8627c4462..9f976fd751 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -100,7 +100,7 @@ declare namespace I18next { getFixedT(lng?:string, ns?:string|string[]):TranslationFunction; - t(key:string, options?:TranslationOptions):string; + t(key:string, options?:TranslationOptions):string|any|Array; exists():boolean; From f9c44651705f574f6d4258fe5e1c335462bdcc19 Mon Sep 17 00:00:00 2001 From: Pavel Martynov Date: Mon, 25 Apr 2016 07:34:59 -0700 Subject: [PATCH 06/67] angular-protractor.d.ts - fix for waitForAngular (#9088) Even citing to heredoc: * @return {!webdriver.promise.Promise} A promise that will resolve to the * scripts return value. */ and this is not Promise. This is Promise. --- angular-protractor/angular-protractor.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts index fa2928c136..d33eeddace 100644 --- a/angular-protractor/angular-protractor.d.ts +++ b/angular-protractor/angular-protractor.d.ts @@ -1683,7 +1683,7 @@ declare namespace protractor { * @return {!webdriver.promise.Promise} A promise that will resolve to the * scripts return value. */ - waitForAngular(): webdriver.promise.Promise; + waitForAngular(): webdriver.promise.Promise; /** * Add a module to load before Angular whenever Protractor.get is called. From 3e3e5ac859992208dbe30f0abdbb2d86ccb454b3 Mon Sep 17 00:00:00 2001 From: basvis Date: Mon, 25 Apr 2016 16:44:02 +0200 Subject: [PATCH 07/67] Added isReady and onReady definitions to ITranslateService (#9037) --- angular-translate/angular-translate-tests.ts | 6 +++++- angular-translate/angular-translate.d.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/angular-translate/angular-translate-tests.ts b/angular-translate/angular-translate-tests.ts index 8ef1ab2e39..4aac8b4b34 100644 --- a/angular-translate/angular-translate-tests.ts +++ b/angular-translate/angular-translate-tests.ts @@ -35,7 +35,11 @@ interface Scope extends ng.IScope { app.controller('Ctrl', ($scope: Scope, $translate: angular.translate.ITranslateService) => { $scope['changeLanguage'] = function (key: any) { - $translate.use(key); + $translate.onReady().then(() => { + if($translate.isReady()) { + $translate.use(key); + } + }); }; }).run(($filter: ng.IFilterService) => { var x: string; diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts index 9d9eeb98a1..c4eca39a95 100644 --- a/angular-translate/angular-translate.d.ts +++ b/angular-translate/angular-translate.d.ts @@ -66,6 +66,8 @@ declare namespace angular.translate { useFallbackLanguage(langKey?: string): void; versionInfo(): string; loaderCache(): any; + isReady(): boolean; + onReady(): angular.IPromise; } interface ITranslateProvider extends angular.IServiceProvider { From b97c0d5a222094e965a484606ed03a7e5e844c46 Mon Sep 17 00:00:00 2001 From: Dave Templin Date: Mon, 25 Apr 2016 07:44:19 -0700 Subject: [PATCH 08/67] mongodb.d.ts fixes to enable Promise and async-await (#9064) * mongodb.d.ts fixes to enable Promise and async-await * Update mongodb.d.ts --- mongodb/mongodb.d.ts | 161 +++++++++++++++++++++++++++++++------------ 1 file changed, 116 insertions(+), 45 deletions(-) diff --git a/mongodb/mongodb.d.ts b/mongodb/mongodb.d.ts index 6c9f8efe7f..a08251b8ba 100644 --- a/mongodb/mongodb.d.ts +++ b/mongodb/mongodb.d.ts @@ -164,8 +164,8 @@ declare module "mongodb" { // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser addUser(username: string, password: string, callback: MongoCallback): void; - addUser(username: string, password: string, options?: { w?: number | string, wtimeout?: number, j?: boolean, customData?: Object, roles?: Object[] }): Promise; - addUser(username: string, password: string, options: { w?: number | string, wtimeout?: number, j?: boolean, customData?: Object, roles?: Object[] }, callback: MongoCallback): void; + addUser(username: string, password: string, options?: DbAddUserOptions): Promise; + addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin admin(): Admin; // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate @@ -184,7 +184,7 @@ declare module "mongodb" { collections(): Promise; collections(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command - command(command: Object, callback?: MongoCallback): void; + command(command: Object, callback: MongoCallback): void; command(command: Object, options?: { readPreference: ReadPreference | string }): Promise; command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection @@ -199,8 +199,8 @@ declare module "mongodb" { db(dbName: string): Db; db(dbName: string, options: { noListener?: boolean, returnNonCachedInstance?: boolean }): Db; //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection - dropCollection(name: string): Promise; - dropCollection(name: string, callback: MongoCallback): void; + dropCollection(name: string): Promise; + dropCollection(name: string, callback: MongoCallback): void; // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase dropDatabase(): Promise; dropDatabase(callback: MongoCallback): void; @@ -219,7 +219,7 @@ declare module "mongodb" { indexInformation(name: string, options?: { full?: boolean, readPreference?: ReadPreference | string }): Promise; indexInformation(name: string, options: { full?: boolean, readPreference?: ReadPreference | string }, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#listCollections - listCollections(filter: Object, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; + listCollections(filter: { name?: string }, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout logout(callback: MongoCallback): void; logout(options?: { dbName?: string }): Promise; @@ -231,7 +231,7 @@ declare module "mongodb" { removeUser(username: string, callback: MongoCallback): void; removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise; removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback): void; renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise; renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback): void; @@ -241,6 +241,8 @@ declare module "mongodb" { stats(options: { scale?: number }, callback: MongoCallback): void; } + + // Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html export class Server extends EventEmitter { constructor(host: string, port: number, options?: ServerOptions); @@ -254,13 +256,22 @@ declare module "mongodb" { connections(): Array; } - + // Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html export class Mongos extends EventEmitter { constructor(servers: Array, options?: MongosOptions); connections(): Array; } + + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser + export interface DbAddUserOptions { + w?: string | number; + wtimeout?: number; + j?: boolean; + customData?: Object; + roles?: Object[]; + } //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection export interface CollectionCreateOptions { @@ -333,42 +344,42 @@ declare module "mongodb" { authenticate(username: string, password: string, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo buildInfo(): Promise; - buildInfo(callback: MongoCallback): void + buildInfo(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command command(command: Object, callback: MongoCallback): void; command(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; command(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases listDatabases(): Promise; - listDatabases(callback: MongoCallback): void + listDatabases(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout logout(): Promise; - logout(callback: MongoCallback): void + logout(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping ping(): Promise; - ping(callback: MongoCallback): void + ping(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo profilingInfo(): Promise; - profilingInfo(callback: MongoCallback): void + profilingInfo(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel profilingLevel(): Promise; - profilingLevel(callback: MongoCallback): void + profilingLevel(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser removeUser(username: string, callback: MongoCallback): void; removeUser(username: string, options?: FSyncOptions): Promise; removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus replSetGetStatus(): Promise; - replSetGetStatus(callback: MongoCallback): void + replSetGetStatus(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo serverInfo(): Promise; - serverInfo(callback: MongoCallback): void + serverInfo(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus serverStatus(): Promise; - serverStatus(callback: MongoCallback): void + serverStatus(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel setProfilingLevel(level: string): Promise; - setProfilingLevel(level: string, callback: MongoCallback): void + setProfilingLevel(level: string, callback: MongoCallback): void; // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection validateCollection(collectionNme: string, callback: MongoCallback): void; validateCollection(collectionNme: string, options?: Object): Promise; @@ -564,12 +575,12 @@ declare module "mongodb" { // Get current index hint for collection. hint: any; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate - aggregate(pipeline: Object[], callback: MongoCallback): void | AggregationCursor; - aggregate(pipeline: Object[], options: CollectionAggrigationOptions, callback: MongoCallback): void | AggregationCursor; + aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor; + aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite - bulkWrite(operations: Object[], callback: MongoCallback): void - bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise - bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void + bulkWrite(operations: Object[], callback: MongoCallback): void; + bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise; + bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count count(query: Object, callback: MongoCallback): void; count(query: Object, options?: MongoCountPreferences): Promise; @@ -590,9 +601,9 @@ declare module "mongodb" { deleteOne(filter: Object, options?: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }): Promise; deleteOne(filter: Object, options: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct - distinct(key: string, query: Object, callback: MongoCallback): void + distinct(key: string, query: Object, callback: MongoCallback): void; distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string }): Promise; - distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void + distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop drop(): Promise; drop(callback: MongoCallback): void; @@ -604,7 +615,16 @@ declare module "mongodb" { dropIndexes(): Promise; dropIndexes(callback?: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find - find(query: Object): Cursor; + find(query?: Object): Cursor; + /** @deprecated */ + find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne + /** @deprecated use find().limit(1).next(function(err, doc){}) */ + findOne(filter: Object, callback: MongoCallback): void; + /** @deprecated use find().limit(1).next(function(err, doc){}) */ + findOne(filter: Object, options?: FindOneOptions): Promise; + /** @deprecated use find().limit(1).next(function(err, doc){}) */ + findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete findOneAndDelete(filter: Object, callback: MongoCallback): void; findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise; @@ -640,17 +660,24 @@ declare module "mongodb" { indexInformation(options?: { full: boolean }): Promise; indexInformation(options: { full: boolean }, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp - initializeOrderedBulkOp(options: CollectionOptions): OrderedBulkOperation; + initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp - initializeUnorderedBulkOp(options: CollectionOptions): UnorderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany - insertMany(docs: Object[], callback: MongoCallback): void - insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise; - insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void + initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne - insertOne(docs: Object, callback: MongoCallback): void + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, callback: MongoCallback): void; + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, options?: CollectionInsertOneOptions): Promise; + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany + insertMany(docs: Object[], callback: MongoCallback): void; + insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise; + insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne + insertOne(docs: Object, callback: MongoCallback): void; insertOne(docs: Object, options?: CollectionInsertOneOptions): Promise; - insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void + insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped isCapped(): Promise; isCapped(callback: MongoCallback): void; @@ -678,10 +705,22 @@ declare module "mongodb" { replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise; replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save + /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ + save(doc: Object, callback: MongoCallback): void; + save(doc: Object, options?: CollectionOptions): Promise; + save(doc: Object, options: CollectionOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats stats(callback: MongoCallback): void; stats(options?: { scale: number }): Promise; stats(options: { scale: number }, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#update + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, callback: MongoCallback): void; + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany updateMany(filter: Object, update: Object, callback: MongoCallback): void; updateMany(filter: Object, update: Object, options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }): Promise; @@ -693,6 +732,7 @@ declare module "mongodb" { } // Documentation: http://docs.mongodb.org/manual/reference/command/collStats/ + //TODO complete this export interface CollStats { // Namespace. ns: string; @@ -724,10 +764,11 @@ declare module "mongodb" { maxSize: boolean; wiredTiger: any; indexDetails: any; + ok: number; } //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate - export interface CollectionAggrigationOptions { + export interface CollectionAggregationOptions { readPreference?: ReadPreference | string; // Return the query as cursor, on 2.6 > it returns as a real cursor // on pre 2.6 it returns as an emulated cursor. @@ -875,7 +916,7 @@ declare module "mongodb" { length: number; //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute execute(callback: MongoCallback): void; - execute(options: FSyncOptions): Promise; + execute(options?: FSyncOptions): Promise; execute(options: FSyncOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#find find(selector: Object): FindOperatorsOrdered; @@ -885,7 +926,7 @@ declare module "mongodb" { //http://mongodb.github.io/node-mongodb-native/2.1/api/BulkWriteResult.html export interface BulkWriteResult { - ok: boolean; + ok: number; nInserted: number; nUpdated: number; nUpserted: number; @@ -936,7 +977,7 @@ declare module "mongodb" { export interface UnorderedBulkOperation { //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#execute execute(callback: MongoCallback): void; - execute(options: FSyncOptions): Promise; + execute(options?: FSyncOptions): Promise; execute(options: FSyncOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#find find(selector: Object): FindOperatorsUnordered; @@ -955,6 +996,30 @@ declare module "mongodb" { upsert(): FindOperatorsUnordered; } + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne + export interface FindOneOptions { + limit?: number, + sort?: Array | Object, + fields?: Object, + skip?: number, + hint?: Object, + explain?: boolean, + snapshot?: boolean, + timeout?: boolean, + tailable?: boolean, + batchSize?: number, + returnKey?: boolean, + maxScan?: number, + min?: number, + max?: number, + showDiskLoc?: boolean, + comment?: string, + raw?: boolean, + readPreference?: ReadPreference | string, + partial?: boolean, + maxTimeMs?: number + } + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertWriteOpResult export interface InsertWriteOpResult { insertedCount: number; @@ -1031,7 +1096,13 @@ declare module "mongodb" { bypassDocumentValidation?: boolean } - + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~WriteOpResult + export interface WriteOpResult { + ops: Array; + connection: any; + result: any; + } + //http://mongodb.github.io/node-mongodb-native/2.1/api/external-Readable.html export interface Readable { pause(): void; @@ -1177,7 +1248,7 @@ declare module "mongodb" { close(): Promise; close(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#each - each(callback: MongoCallback): void + each(callback: MongoCallback): void; // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#explain explain(): Promise; explain(callback: MongoCallback): void; @@ -1219,8 +1290,8 @@ declare module "mongodb" { // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#sort sort(document: Object): AggregationCursor; // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; + toArray(): Promise; + toArray(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unpipe unpipe(destination?: Writable): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unshift @@ -1241,7 +1312,7 @@ declare module "mongodb" { close(): Promise; close(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#each - each(callback: MongoCallback): void + each(callback: MongoCallback): void; // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#isClosed isClosed(): boolean; // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#maxTimeMS @@ -1264,8 +1335,8 @@ declare module "mongodb" { // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setReadPreference setReadPreference(readPreference: string | ReadPreference): CommandCursor; // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#toArray - toArray(): Promise; - toArray(callback: MongoCallback): void; + toArray(): Promise; + toArray(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unpipe unpipe(destination?: Writable): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift From d4c9dc3197a82bd731db8d2dd969af1534c0dc6b Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Mon, 25 Apr 2016 16:47:15 +0200 Subject: [PATCH 09/67] Add type definitions for wrap-ansi (https://www.npmjs.com/package/wrap-ansi) (#9090) --- wrap-ansi/wrap-ansi-tests.ts | 8 ++++++++ wrap-ansi/wrap-ansi.d.ts | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 wrap-ansi/wrap-ansi-tests.ts create mode 100644 wrap-ansi/wrap-ansi.d.ts diff --git a/wrap-ansi/wrap-ansi-tests.ts b/wrap-ansi/wrap-ansi-tests.ts new file mode 100644 index 0000000000..8fb08dfd8b --- /dev/null +++ b/wrap-ansi/wrap-ansi-tests.ts @@ -0,0 +1,8 @@ +/// + +import wrapAnsi = require("wrap-ansi"); + +wrapAnsi("input", 80) === "output"; +wrapAnsi("input", 80, {}) === "output"; +wrapAnsi("input", 80, { hard: true }) === "output"; +wrapAnsi("input", 80, { hard: false }) === "output"; diff --git a/wrap-ansi/wrap-ansi.d.ts b/wrap-ansi/wrap-ansi.d.ts new file mode 100644 index 0000000000..79a63abc78 --- /dev/null +++ b/wrap-ansi/wrap-ansi.d.ts @@ -0,0 +1,20 @@ +// Type definitions for wrap-ansi v2.0.0 +// Project: https://www.npmjs.com/package/wrap-ansi +// Definitions by: Klaus Reimer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "wrap-ansi" { + /** + * Wrap words to the specified column width. + * + * @param input String with ANSI escape codes. Like one styled by chalk. + * @param columns Number of columns to wrap the text to. + * @param options By default the wrap is soft, meaning long words may extend past the column width. Setting + * this to true will make it hard wrap at the column width. + */ + function wrapAnsi(input: string, columns: number, options?: { hard?: boolean }): string; + + namespace wrapAnsi {} + + export = wrapAnsi; +} From 66a568104ade0a2359e47f139f387c9fa2cb0870 Mon Sep 17 00:00:00 2001 From: Voislav Date: Mon, 25 Apr 2016 16:48:14 +0200 Subject: [PATCH 10/67] update declarations to latest 2.3.6 version. keep 2.3.1 versions files (#9039) * update declarations to latest 2.3.6 version. keep 2.3.1 versions files * rename 2.3.1 tests file to use propper naming convention --- .../angular-permission-2.3.1-tests.ts | 92 ++++++++++ .../angular-permission-2.3.1.d.ts | 165 ++++++++++++++++++ .../angular-permission-tests.ts | 6 +- angular-permission/angular-permission.d.ts | 20 ++- 4 files changed, 275 insertions(+), 8 deletions(-) create mode 100644 angular-permission/angular-permission-2.3.1-tests.ts create mode 100644 angular-permission/angular-permission-2.3.1.d.ts diff --git a/angular-permission/angular-permission-2.3.1-tests.ts b/angular-permission/angular-permission-2.3.1-tests.ts new file mode 100644 index 0000000000..3753ba9d51 --- /dev/null +++ b/angular-permission/angular-permission-2.3.1-tests.ts @@ -0,0 +1,92 @@ +/// + +import permission = angular.permission; + +angular + .module('fooModule', ['permission', 'user']) + .run(function (PermissionStore: permission.PermissionStore, User: any) { + // Define anonymous permission + PermissionStore + .definePermission('anonymous', function (stateParams) { + // If the returned value is *truthy* then the user has the permission, otherwise they don't + if (!User) { + return true; // Is anonymous + } + return false; + }); + }); + + interface BackendUserService { + checkSession(): angular.IPromise; + getAccessLevel(): angular.IPromise<{accessLevel: string}>; + hasPermissionDefinition(permission: string) : angular.IPromise; + } + + angular.module('barModule', ['permission', 'user']) + .run(function (PermissionStore: permission.PermissionStore, User: BackendUserService, $q: angular.IQService) { + PermissionStore + // Define user permission calling back-end + .definePermission('user', function (stateParams) { + // This time we will return a promise + // If the promise *resolves* then the user has the permission, if it *rejects* (you guessed it) + + // Let's assume this returns a promise that resolves or rejects if session is active + return User.checkSession(); + }); + + PermissionStore + // A different example for admin + .definePermission('admin', function (stateParams) { + var deferred = $q.defer(); + + User.getAccessLevel() + .then(function (data) { + if (data.accessLevel === 'admin') { + deferred.resolve(); + } else { + deferred.reject(); + } + }) + .catch(function () { + // Error with request + deferred.reject(); + }); + + return deferred.promise; + }); + + let arrayOfPermissionNames = ['p1', 'p2']; + PermissionStore.defineManyPermissions(arrayOfPermissionNames, function (stateParams: angular.ui.IStateParamsService, permissionName: string) { + return User.hasPermissionDefinition(permissionName); + }); + + PermissionStore.clearStore(); + + PermissionStore.removePermissionDefinition('user'); + + let permissions: Array = PermissionStore.getStore(); + + + }); + +angular + .module('fooModule', ['permission', 'user']) + .run(function (RoleStore: permission.RoleStore, User: any) { + RoleStore + // Permission array validated role + // Library will internally validate if 'user' and 'editor' permissions are valid when checking if role is valid + .defineRole('admin', ['user', 'editor']); + + RoleStore + // Server side validated role + .defineRole('accountant', [], function (stateParams) { + // Let's assume that we are making a request to server here and return response as promise + return User.hasRole('accountant'); + }); + + RoleStore.clearStore(); + + RoleStore.removeRoleDefinition('user'); + + let roles: Array = RoleStore.getStore(); + }); diff --git a/angular-permission/angular-permission-2.3.1.d.ts b/angular-permission/angular-permission-2.3.1.d.ts new file mode 100644 index 0000000000..afe32ce875 --- /dev/null +++ b/angular-permission/angular-permission-2.3.1.d.ts @@ -0,0 +1,165 @@ +// Type definitions for angular-permission 2.3.1 +// Project: https://github.com/Narzerus/angular-permission +// Definitions by: Voislav Mishevski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare namespace angular.permission { + + export interface PermissionStore { + /** + * Allows to define permission on application configuration + * @method + * + * @param permissionName {String} Name of defined permission + * @param validationFunction {Function} Function used to validate if permission is valid + */ + definePermission( + name: string, + validationFunction: (stateParams?: angular.ui.IStateParamsService, permission?: string) => boolean | angular.IPromise + ): void; + + /** + * Allows to define set of permissionNames with shared validation function on application configuration + * @method + * @throws {TypeError} + * + * @param permissionNames {Array} Set of permission names + * @param validationFunction {Function} Function used to validate if permission is valid + */ + defineManyPermissions( + permissions: string[], + validationFunction: (stateParams?: angular.ui.IStateParamsService, permission?: string) => boolean | angular.IPromise + ): void; + + clearStore(): void; + + /** + * Deletes permission + * @method + * + * @param permissionName {String} Name of defined permission + */ + removePermissionDefinition(permission: string): void; + + /** + * Checks if permission exists + * @method + * + * @param permissionName {String} Name of defined permission + * @returns {Boolean} + */ + hasPermissionDefinition(permissionName: string): boolean; + + /** + * Returns all permissions + * @method + * + * @returns {Object} Permissions collection + */ + getStore(): Permission[]; + } + + export interface RoleStore { + /** + * Allows to define role + * @method + * + * @param roleName {String} Name of defined role + * @param permissions {Array} Set of permission names + * @param [validationFunction] {Function} Function used to validate if permissions in role are valid + */ + defineRole( + role: string, + permissions: Array, + validationFunction: RoleValidationFunction + ): void; + + /** + * Allows to define role + * @method + * + * @param roleName {String} Name of defined role + * @param permissions {Array} Set of permission names + */ + defineRole(role: string, permissions: Array): void; + + /** + * Checks if role is defined in store + * @method + * + * @param roleName {String} Name of role + * @returns {Boolean} + */ + hasRoleDefinition(role: string): boolean; + + /** + * Returns role definition object by it's name + * @method + * + * @returns {permission.Role} Role definition object + */ + getRoleDefinition(roleName: string): Role; + + /** + * Removes all role definitions + * @method + */ + clearStore(): void; + + /** + * Deletes role from store + * @method + * + * @param roleName {String} Name of defined permission + */ + removeRoleDefinition(roleName: string): void; + + /** + * Returns all role definitions + * @method + * + * @returns {Object} Defined roles collection + */ + getStore(): Role[]; + } + + export interface Role { + roleName: string; + permissionNames: string[]; + validationFunction?: RoleValidationFunction; + } + + export interface Permission { + permissionName: string; + validationFunction?: PermissionValidationFunction; + } + + interface RoleValidationFunction { + (stateParams?: angular.ui.IStateParamsService, permission?: string): boolean | angular.IPromise; + } + + interface PermissionValidationFunction { + (stateParams?: angular.ui.IStateParamsService, permission?: string): boolean | angular.IPromise; + } + + export interface IPermissionState extends angular.ui.IState { + data?: any | DataWithPermissions; + } + + export interface DataWithPermissions { + permissions?: { + only?: (() => void) | Array | angular.IPromise; + except?: (() => void) | Array | angular.IPromise; + redirectTo: string | (() => string) | (() => PermissionRedirectConfigation) | {[index: string]: PermissionRedirectConfigation} + }; + } + + export interface PermissionRedirectConfigation { + state: string; + params?: {}; + options?: angular.ui.IStateOptions; + } +} diff --git a/angular-permission/angular-permission-tests.ts b/angular-permission/angular-permission-tests.ts index 206850ad70..cc9cd7c367 100644 --- a/angular-permission/angular-permission-tests.ts +++ b/angular-permission/angular-permission-tests.ts @@ -36,7 +36,7 @@ angular PermissionStore // A different example for admin - .definePermission('admin', function (stateParams) { + .definePermission('admin', function (permission: string, stateParams: angular.permission.TransitionProperties) { var deferred = $q.defer(); User.getAccessLevel() @@ -56,7 +56,7 @@ angular }); let arrayOfPermissionNames = ['p1', 'p2']; - PermissionStore.defineManyPermissions(arrayOfPermissionNames, function (stateParams: angular.ui.IStateParamsService, permissionName: string) { + PermissionStore.defineManyPermissions(arrayOfPermissionNames, function (permissionName: string, stateParams: angular.permission.TransitionProperties) { return User.hasPermissionDefinition(permissionName); }); @@ -79,7 +79,7 @@ angular RoleStore // Server side validated role - .defineRole('accountant', [], function (stateParams) { + .defineRole('accountant', [], function (permission, stateParams) { // Let's assume that we are making a request to server here and return response as promise return User.hasRole('accountant'); }); diff --git a/angular-permission/angular-permission.d.ts b/angular-permission/angular-permission.d.ts index afe32ce875..fecbafb29b 100644 --- a/angular-permission/angular-permission.d.ts +++ b/angular-permission/angular-permission.d.ts @@ -1,4 +1,4 @@ -// Type definitions for angular-permission 2.3.1 +// Type definitions for angular-permission 2.3.6 // Project: https://github.com/Narzerus/angular-permission // Definitions by: Voislav Mishevski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,6 +7,16 @@ /// declare namespace angular.permission { + /** + * Used as optional parameter provided on definitions of permissions and roles + */ + export interface TransitionProperties { + fromState?: angular.ui.IState; + fromParams?: angular.ui.IStateParamsService; + toState?: angular.ui.IState; + toParams?: angular.ui.IStateParamsService; + options?: angular.ui.IStateOptions; + } export interface PermissionStore { /** @@ -18,7 +28,7 @@ declare namespace angular.permission { */ definePermission( name: string, - validationFunction: (stateParams?: angular.ui.IStateParamsService, permission?: string) => boolean | angular.IPromise + validationFunction: (permission?: string, transitionProperties?: TransitionProperties) => boolean | angular.IPromise ): void; /** @@ -31,7 +41,7 @@ declare namespace angular.permission { */ defineManyPermissions( permissions: string[], - validationFunction: (stateParams?: angular.ui.IStateParamsService, permission?: string) => boolean | angular.IPromise + validationFunction: (permission?: string, transitionProperties?: TransitionProperties) => boolean | angular.IPromise ): void; clearStore(): void; @@ -138,11 +148,11 @@ declare namespace angular.permission { } interface RoleValidationFunction { - (stateParams?: angular.ui.IStateParamsService, permission?: string): boolean | angular.IPromise; + (permission?: string, transitionProperties?: TransitionProperties): boolean | angular.IPromise; } interface PermissionValidationFunction { - (stateParams?: angular.ui.IStateParamsService, permission?: string): boolean | angular.IPromise; + (permission?: string, transitionProperties?: TransitionProperties): boolean | angular.IPromise; } export interface IPermissionState extends angular.ui.IState { From 1dc239e241cf7f3ceba0c83ded52c11f9d792b32 Mon Sep 17 00:00:00 2001 From: Gergely Sipos Date: Mon, 25 Apr 2016 16:48:47 +0200 Subject: [PATCH 11/67] Highland: fix for HighlandStatic generics (#9091) _(Promise) should return Highland.Stream and _(Promise --- highland/highland-tests.ts | 4 +++- highland/highland.d.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/highland/highland-tests.ts b/highland/highland-tests.ts index c7e213aa17..7a67670edd 100644 --- a/highland/highland-tests.ts +++ b/highland/highland-tests.ts @@ -137,7 +137,9 @@ fooStream = _(readable); fooStream = _(emitter); fooStream = _(fooStreamThen); -fooStream = _(fooArrThen); +fooStream = _(fooThen); + +fooArrStream = _(fooArrThen); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/highland/highland.d.ts b/highland/highland.d.ts index 8becaf2762..f3617ccd14 100644 --- a/highland/highland.d.ts +++ b/highland/highland.d.ts @@ -67,7 +67,7 @@ interface HighlandStatic { // moar (promise for everything?) (xs: Highland.Thenable>): Highland.Stream; - (xs: Highland.Thenable): Highland.Stream; + (xs: Highland.Thenable): Highland.Stream; /** * The end of stream marker. This is sent along the data channel of a Stream From 42e2274e9b5dc51598e2a7371c25a46bc31620b9 Mon Sep 17 00:00:00 2001 From: Howard Yeh Date: Mon, 25 Apr 2016 07:50:02 -0700 Subject: [PATCH 12/67] react-native specialized Component class (#9060) * react-native specialized Component class * react-native native component methods * react-native move global static outwards * react-native fix typedef bugs --- react-native/react-native-tests.tsx | 10 +- react-native/react-native.d.ts | 138 +++++++++++++++++++++++----- 2 files changed, 124 insertions(+), 24 deletions(-) diff --git a/react-native/react-native-tests.tsx b/react-native/react-native-tests.tsx index 8bed3c8be3..00f4be76d8 100644 --- a/react-native/react-native-tests.tsx +++ b/react-native/react-native-tests.tsx @@ -72,11 +72,19 @@ var styles = StyleSheet.create( class Welcome extends React.Component { + testNativeMethods() { + this.setNativeProps({}); + + const { rootView } = this.refs; + + rootView.measure((x, y, width, height) => { + }); + } render() { return ( - + Welcome to React Native diff --git a/react-native/react-native.d.ts b/react-native/react-native.d.ts index a6cab25ff0..824fad6f77 100644 --- a/react-native/react-native.d.ts +++ b/react-native/react-native.d.ts @@ -22,7 +22,7 @@ import React = __React; //react-native "extends" react -declare namespace __React { +declare module "react-native" { /** @@ -121,6 +121,109 @@ declare namespace __React { // @see lib.es6.d.ts export var Promise: PromiseConstructor; + module NativeMethodsMixin { + type MeasureOnSuccessCallback = ( + x: number, + y: number, + width: number, + height: number, + pageX: number, + pageY: number + ) => void + + type MeasureInWindowOnSuccessCallback = ( + x: number, + y: number, + width: number, + height: number + ) => void + + type MeasureLayoutOnSuccessCallback = ( + left: number, + top: number, + width: number, + height: number + ) => void + } + + /** + * @see https://github.com/facebook/react-native/blob/master/Libraries/ReactIOS/NativeMethodsMixin.js + */ + export class Component extends React.Component { + /** + * Determines the location on screen, width, and height of the given view and + * returns the values via an async callback. If successful, the callback will + * be called with the following arguments: + * + * - x + * - y + * - width + * - height + * - pageX + * - pageY + * + * Note that these measurements are not available until after the rendering + * has been completed in native. If you need the measurements as soon as + * possible, consider using the [`onLayout` + * prop](docs/view.html#onlayout) instead. + */ + measure(callback: NativeMethodsMixin.MeasureOnSuccessCallback): void; + + /** + * Determines the location of the given view in the window and returns the + * values via an async callback. If the React root view is embedded in + * another native view, this will give you the absolute coordinates. If + * successful, the callback will be called with the following + * arguments: + * + * - x + * - y + * - width + * - height + * + * Note that these measurements are not available until after the rendering + * has been completed in native. + */ + measureInWindow(callback: NativeMethodsMixin.MeasureInWindowOnSuccessCallback): void; + + /** + * Like [`measure()`](#measure), but measures the view relative an ancestor, + * specified as `relativeToNativeNode`. This means that the returned x, y + * are relative to the origin x, y of the ancestor view. + * + * As always, to obtain a native node handle for a component, you can use + * `React.findNodeHandle(component)`. + */ + measureLayout( + relativeToNativeNode: number, + onSuccess: NativeMethodsMixin.MeasureLayoutOnSuccessCallback, + onFail: () => void /* currently unused */ + ): void; + + /** + * This function sends props straight to native. They will not participate in + * future diff process - this means that if you do not include them in the + * next render, they will remain active (see [Direct + * Manipulation](docs/direct-manipulation.html)). + */ + setNativeProps(nativeProps: Object): void; + + /** + * Requests focus for the given input or view. The exact behavior triggered + * will depend on the platform and type of view. + */ + focus(): void; + + /** + * Removes focus from an input or view. This is the opposite of `focus()`. + */ + blur(): void; + + refs: { + [key: string]: Component + }; + } + //TODO: BGR: Replace with ComponentClass ? // node_modules/react-tools/src/classic/class/ReactClass.js export interface ReactClass { @@ -219,7 +322,6 @@ declare namespace __React { * //FIXME: need to find documentation on which compoenent is a native (i.e. non composite component) */ export interface NativeComponent { - setNativeProps: ( props: Object ) => void } /** @@ -2080,7 +2182,7 @@ declare namespace __React { } export interface Route { - component?: ComponentClass + component?: React.ComponentClass id?: string title?: string passProps?: Object; @@ -3489,19 +3591,6 @@ declare namespace __React { export function __spread( target: any, ...sources: any[] ): any; - - export interface GlobalStatic { - - /** - * Accepts a function as its only argument and calls that function before the next repaint. - * It is an essential building block for animations that underlies all of the JavaScript-based animation APIs. - * In general, you shouldn't need to call this yourself - the animation API's will manage frame updates for you. - * @see https://facebook.github.io/react-native/docs/animations.html#requestanimationframe - */ - requestAnimationFrame( fn: () => void ) : void; - - } - // // Add-Ons // @@ -3518,16 +3607,19 @@ declare namespace __React { export var TestModule: TestModuleStatic export type TestModule = TestModuleStatic } - - } -declare module "react-native" { - - import ReactNative = __React - export = ReactNative +declare interface ReactNativeGlobalStatic { + /** + * Accepts a function as its only argument and calls that function before the next repaint. + * It is an essential building block for animations that underlies all of the JavaScript-based animation APIs. + * In general, you shouldn't need to call this yourself - the animation API's will manage frame updates for you. + * @see https://facebook.github.io/react-native/docs/animations.html#requestanimationframe + */ + requestAnimationFrame( fn: () => void ) : void; } -declare var global: __React.GlobalStatic + +declare var global: ReactNativeGlobalStatic; declare function require( name: string ): any \ No newline at end of file From 55b227930cdb7a362b9022082e00954f57bd787d Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 25 Apr 2016 18:54:06 +0400 Subject: [PATCH 13/67] Master (#9078) * Create dts for surveyjs surveyjs is origionally written on TypeScript * Fix The Travis CI build * Fix The Travis CI build * Fix The Travis CI build * Rename survey.d.ts to survey-knockout.d.ts --- survey-knockout/survey-knockout-tests.ts | 22 + survey-knockout/survey-knockout.d.ts | 1087 ++++++++++++++++++++++ 2 files changed, 1109 insertions(+) create mode 100644 survey-knockout/survey-knockout-tests.ts create mode 100644 survey-knockout/survey-knockout.d.ts diff --git a/survey-knockout/survey-knockout-tests.ts b/survey-knockout/survey-knockout-tests.ts new file mode 100644 index 0000000000..4d45d371c7 --- /dev/null +++ b/survey-knockout/survey-knockout-tests.ts @@ -0,0 +1,22 @@ +/// + +function createFromCodeTests() { + var survey = new Survey.SurveyModel(); + var page = survey.addNewPage("Page 1"); + page.addNewQuestion("text", "question1"); + page.addNewQuestion("comment", "question2"); + page = survey.addNewPage("Page 2"); + page.addNewQuestion("matrix", "question3"); + page.addNewQuestion("matrixdropdown", "question4"); + return survey; +} +function createFromJSONTests() { + var survey = new Survey.SurveyModel({ + pages: [{ + "name": "page1", + "questions": [{ "type": "text", "name": "textQuestion", "isRequired": "true" }, { "type": "checkbox", "name": "checkboxQuestion", "isRequired": "true", "choices": ["red", "white"] }] + }] + }); + survey.setValue("textQuestion", "newValue"); + return survey; +} diff --git a/survey-knockout/survey-knockout.d.ts b/survey-knockout/survey-knockout.d.ts new file mode 100644 index 0000000000..e5e26e23b8 --- /dev/null +++ b/survey-knockout/survey-knockout.d.ts @@ -0,0 +1,1087 @@ +// Type definitions for Survey JavaScript library v0.9.3 +// Project: http://surveyjs.org/ +// Definitions by: Andrew Telnov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module Survey { + interface HashTable { + [key: string]: T; + } + interface ISurvey { + getValue(name: string): any; + setValue(name: string, newValue: any): any; + getComment(name: string): string; + setComment(name: string, newValue: string): any; + pageVisibilityChanged(page: IPage, newValue: boolean): any; + questionVisibilityChanged(question: IQuestion, newValue: boolean): any; + questionAdded(question: IQuestion, index: number): any; + questionRemoved(question: IQuestion): any; + validateQuestion(name: string): SurveyError; + isDesignMode: boolean; + } + interface IQuestion { + name: string; + visible: boolean; + hasTitle: boolean; + setVisibleIndex(value: number): any; + onSurveyValueChanged(newValue: any): any; + } + interface IPage { + visible: boolean; + } + class ItemValue { + static Separator: string; + static setData(items: Array, values: Array): void; + static getData(items: Array): any; + private itemValue; + private itemText; + constructor(value: any, text?: string); + getType(): string; + value: any; + hasText: boolean; + text: string; + } + class Base { + getType(): string; + } + class SurveyError { + getText(): string; + } + class Event { + private callbacks; + isEmpty: boolean; + fire(sender: any, options: Options): void; + add(func: T): void; + remove(func: T): void; + } +} + +declare module Survey { + class dxSurveyService { + static serviceUrl: string; + constructor(); + loadSurvey(surveyId: string, onLoad: (success: boolean, result: string, response: any) => void): void; + sendResult(postId: string, result: JSON, onSendResult: (success: boolean, response: any) => void, clientId?: string, isPartialCompleted?: boolean): void; + getResult(resultId: string, name: string, onGetResult: (success: boolean, data: any, dataList: Array, response: any) => void): void; + isCompleted(resultId: string, clientId: string, onIsCompleted: (success: boolean, result: string, response: any) => void): void; + } +} + +declare module Survey { + var surveyLocalization: { + currentLocale: string; + locales: {}; + getString: (strName: string) => any; + getLocales: () => string[]; + }; + var surveyStrings: { + pagePrevText: string; + pageNextText: string; + completeText: string; + otherItemText: string; + progressText: string; + optionsCaption: string; + requiredError: string; + numericError: string; + textMinLength: string; + minSelectError: string; + maxSelectError: string; + numericMinMax: string; + numericMin: string; + numericMax: string; + invalidEmail: string; + }; +} + +/// +/// +declare module Survey { + class AnswerRequiredError extends SurveyError { + constructor(); + getText(): string; + } + class RequreNumericError extends SurveyError { + constructor(); + getText(): string; + } + class CustomError extends SurveyError { + private text; + constructor(text: string); + getText(): string; + } +} + +/// +declare module Survey { + class JsonObjectProperty { + name: string; + private typeValue; + private choicesValue; + private choicesfunc; + className: string; + classNamePart: string; + baseClassName: string; + defaultValue: any; + onGetValue: (obj: any) => any; + onSetValue: (obj: any, value: any, jsonConv: JsonObject) => any; + constructor(name: string); + type: string; + hasToUseGetValue: (obj: any) => any; + isDefaultValue(value: any): boolean; + getValue(obj: any): any; + hasToUseSetValue: (obj: any, value: any, jsonConv: JsonObject) => any; + setValue(obj: any, value: any, jsonConv: JsonObject): void; + getObjType(objType: string): string; + getClassName(className: string): string; + choices: Array; + setChoices(value: Array, valueFunc: () => Array): void; + } + class JsonMetadataClass { + name: string; + creator: () => any; + parentName: string; + static requiredSymbol: string; + static typeSymbol: string; + properties: Array; + requiredProperties: Array; + constructor(name: string, propertiesNames: Array, creator?: () => any, parentName?: string); + find(name: string): JsonObjectProperty; + private getPropertyName(propertyName); + } + class JsonMetadata { + private classes; + private childrenClasses; + private classProperties; + private classRequiredProperties; + addClass(name: string, propertiesNames: Array, creator?: () => any, parentName?: string): JsonMetadataClass; + overrideClassCreatore(name: string, creator: () => any): void; + setPropertyValues(name: string, propertyName: string, propertyClassName: string, defaultValue?: any, onGetValue?: (obj: any) => any, onSetValue?: (obj: any, value: any, jsonConv: JsonObject) => any): void; + setPropertyChoices(name: string, propertyName: string, choices: Array, choicesFunc?: () => Array): void; + setPropertyClassInfo(name: string, propertyName: string, baseClassName: string, classNamePart?: string): void; + getProperties(name: string): Array; + createClass(name: string): any; + getChildrenClasses(name: string, canBeCreated?: boolean): Array; + getRequiredProperties(name: string): Array; + private fillChildrenClasses(name, canBeCreated, result); + private findClass(name); + private findProperty(name, propertyName); + private fillProperties(name, list); + private addProperty(property, list, endIndex); + private fillRequiredProperties(name, list); + } + class JsonError { + type: string; + message: string; + description: string; + at: Number; + constructor(type: string, message: string); + getFullDescription(): string; + } + class JsonUnknownPropertyError extends JsonError { + propertyName: string; + className: string; + constructor(propertyName: string, className: string); + } + class JsonMissingTypeErrorBase extends JsonError { + baseClassName: string; + type: string; + message: string; + constructor(baseClassName: string, type: string, message: string); + } + class JsonMissingTypeError extends JsonMissingTypeErrorBase { + propertyName: string; + baseClassName: string; + constructor(propertyName: string, baseClassName: string); + } + class JsonIncorrectTypeError extends JsonMissingTypeErrorBase { + propertyName: string; + baseClassName: string; + constructor(propertyName: string, baseClassName: string); + } + class JsonRequiredPropertyError extends JsonError { + propertyName: string; + className: string; + constructor(propertyName: string, className: string); + } + class JsonObject { + private static typePropertyName; + private static positionPropertyName; + private static metaDataValue; + static metaData: JsonMetadata; + errors: JsonError[]; + toJsonObject(obj: any): any; + toObject(jsonObj: any, obj: any): void; + protected toJsonObjectCore(obj: any, property: JsonObjectProperty): any; + protected valueToJson(obj: any, result: any, property: JsonObjectProperty): void; + protected valueToObj(value: any, obj: any, key: any, property: JsonObjectProperty): void; + private isValueArray(value); + private createNewObj(value, property); + private checkNewObjectOnErrors(newObj, value, property, className); + private addNewError(error, jsonObj); + private valueToArray(value, obj, key, property); + private findProperty(properties, key); + } +} + +/// +/// +declare module Survey { + class QuestionBase extends Base implements IQuestion { + name: string; + protected data: ISurvey; + private visibleValue; + private visibleIndexValue; + width: string; + visibilityChangedCallback: () => void; + visibleIndexChangedCallback: () => void; + constructor(name: string); + visible: boolean; + visibleIndex: number; + hasErrors(): boolean; + hasTitle: boolean; + hasComment: boolean; + setData(newValue: ISurvey): void; + protected fireCallback(callback: () => void): void; + protected onSetData(): void; + protected onCreating(): void; + onSurveyValueChanged(newValue: any): void; + setVisibleIndex(value: number): void; + } +} + +/// +/// +declare module Survey { + class QuestionFactory { + static Instance: QuestionFactory; + static DefaultChoices: (string | { + value: number; + text: string; + })[]; + private creatorHash; + registerQuestion(questionType: string, questionCreator: (name: string) => QuestionBase): void; + getAllTypes(): Array; + createQuestion(questionType: string, name: string): QuestionBase; + } +} + +/// +/// +/// +declare module Survey { + class PageModel extends Base implements IPage { + name: string; + questions: Array; + data: ISurvey; + title: string; + visibleIndex: number; + private numValue; + private visibleValue; + constructor(name?: string); + num: number; + visible: boolean; + getType(): string; + isVisible: boolean; + addQuestion(question: QuestionBase, index?: number): void; + addNewQuestion(questionType: string, name: string): QuestionBase; + removeQuestion(question: QuestionBase): void; + hasErrors(): boolean; + addQuestionsToList(list: Array, visibleOnly?: boolean): void; + protected onNumChanged(value: number): void; + } +} + +/// +/// +/// +declare module Survey { + class ValidatorResult { + value: any; + error: SurveyError; + constructor(value: any, error?: SurveyError); + } + class SurveyValidator extends Base { + text: string; + constructor(); + protected getErrorText(name: string): string; + protected getDefaultErrorText(name: string): string; + validate(value: any, name?: string): ValidatorResult; + } + interface IValidatorOwner { + validators: Array; + value: any; + getValidatorTitle(): string; + } + class ValidatorRunner { + run(owner: IValidatorOwner): SurveyError; + } + class NumericValidator extends SurveyValidator { + minValue: number; + maxValue: number; + constructor(minValue?: number, maxValue?: number); + getType(): string; + validate(value: any, name?: string): ValidatorResult; + protected getDefaultErrorText(name: string): any; + private isNumber(value); + } + class TextValidator extends SurveyValidator { + minLength: number; + constructor(minLength?: number); + getType(): string; + validate(value: any, name?: string): ValidatorResult; + protected getDefaultErrorText(name: string): any; + } + class AnswerCountValidator extends SurveyValidator { + minCount: number; + maxCount: number; + constructor(minCount?: number, maxCount?: number); + getType(): string; + validate(value: any, name?: string): ValidatorResult; + protected getDefaultErrorText(name: string): string; + } + class RegexValidator extends SurveyValidator { + regex: string; + constructor(regex?: string); + getType(): string; + validate(value: any, name?: string): ValidatorResult; + } + class EmailValidator extends SurveyValidator { + private re; + constructor(); + getType(): string; + validate(value: any, name?: string): ValidatorResult; + protected getDefaultErrorText(name: string): any; + } +} + +/// +/// +/// +/// +/// +declare module Survey { + class Question extends QuestionBase implements IValidatorOwner { + name: string; + private titleValue; + private questionValue; + private isRequiredValue; + private hasCommentValue; + private hasOtherValue; + errors: Array; + validators: Array; + valueChangedCallback: () => void; + commentChangedCallback: () => void; + errorsChangedCallback: () => void; + constructor(name: string); + hasTitle: boolean; + title: string; + supportComment(): boolean; + supportOther(): boolean; + isRequired: boolean; + hasComment: boolean; + hasOther: boolean; + protected onSetData(): void; + value: any; + comment: string; + isEmpty(): boolean; + hasErrors(): boolean; + private checkForErrors(); + protected onCheckForErrors(errors: Array): void; + protected runValidators(): SurveyError; + private isValueChangedInSurvey; + protected setNewValue(newValue: any): void; + protected onValueChanged(): void; + private setNewComment(newValue); + onSurveyValueChanged(newValue: any): void; + getValidatorTitle(): string; + } +} + +/// +/// +declare module Survey { + class QuestionSelectBase extends Question { + otherItem: ItemValue; + choicesValues: Array; + otherErrorText: string; + choicesOrderValue: string; + constructor(name: string); + isOtherSelected: boolean; + choices: Array; + choicesOrder: string; + otherText: string; + visibleChoices: Array; + supportComment(): boolean; + supportOther(): boolean; + protected onCheckForErrors(errors: Array): void; + sortVisibleChoices(array: Array): Array; + sortArray(array: Array, mult: number): Array; + randomizeArray(array: Array): Array; + } + class QuestionCheckboxBase extends QuestionSelectBase { + name: string; + private colCountValue; + colCountChangedCallback: () => void; + constructor(name: string); + colCount: number; + } +} + +/// +/// +declare module Survey { + class QuestionCheckboxModel extends QuestionCheckboxBase { + name: string; + constructor(name: string); + isOtherSelected: boolean; + getType(): string; + } +} + +/// +/// +declare module Survey { + class QuestionCommentModel extends Question { + name: string; + rows: number; + cols: number; + constructor(name: string); + getType(): string; + isEmpty(): boolean; + } +} + +/// +/// +declare module Survey { + class QuestionDropdownModel extends QuestionSelectBase { + name: string; + private optionsCaptionValue; + constructor(name: string); + optionsCaption: string; + getType(): string; + } +} + +/// +/// +declare module Survey { + class QuestionHtmlModel extends QuestionBase { + name: string; + private htmlValue; + constructor(name: string); + getType(): string; + html: string; + } +} + +/// +/// +declare module Survey { + interface IMatrixData { + onMatrixRowChanged(row: MatrixRowModel): any; + } + class MatrixRowModel extends Base { + name: any; + text: string; + fullName: string; + private data; + protected rowValue: any; + constructor(name: any, text: string, fullName: string, data: IMatrixData, value: any); + value: any; + protected onValueChanged(): void; + } + class QuestionMatrixModel extends Question implements IMatrixData { + name: string; + private columnsValue; + private rowsValue; + private isRowChanging; + private generatedVisibleRows; + constructor(name: string); + getType(): string; + hasRows: boolean; + columns: Array; + rows: Array; + visibleRows: Array; + protected createMatrixRow(name: any, text: string, fullName: string, value: any): MatrixRowModel; + protected onValueChanged(): void; + onMatrixRowChanged(row: MatrixRowModel): void; + } +} + +/// +/// +declare module Survey { + interface IMatrixDropdownData { + onCellChanged(cell: MatrixDropdownCellModel): any; + columns: Array; + choices: Array; + optionsCaption: string; + } + class MatrixDropdownColumn extends Base { + name: string; + private choicesValue; + private titleValue; + optionsCaption: string; + constructor(name: string, title?: string); + getType(): string; + title: string; + choices: Array; + } + class MatrixDropdownCellModel { + column: MatrixDropdownColumn; + row: MatrixDropdownRowModel; + private data; + private cellValue; + constructor(column: MatrixDropdownColumn, row: MatrixDropdownRowModel, data: IMatrixDropdownData, value: any); + choices: Array; + optionsCaption: string; + value: any; + protected onValueChanged(): void; + } + class MatrixDropdownRowModel { + name: any; + text: string; + protected data: IMatrixDropdownData; + protected rowValue: any; + cells: Array; + constructor(name: any, text: string, data: IMatrixDropdownData, value: any); + value: any; + private buildCells(); + protected createCell(column: MatrixDropdownColumn, value: any): MatrixDropdownCellModel; + protected getCellValue(column: MatrixDropdownColumn): any; + } + class QuestionMatrixDropdownModel extends Question implements IMatrixDropdownData { + name: string; + private columnsValue; + private rowsValue; + private choicesValue; + private optionsCaptionValue; + private isRowChanging; + private generatedVisibleRows; + constructor(name: string); + getType(): string; + columns: Array; + rows: Array; + choices: Array; + optionsCaption: string; + addColumn(name: string, title?: string): MatrixDropdownColumn; + visibleRows: Array; + protected createMatrixRow(name: any, text: string, value: any): MatrixDropdownRowModel; + protected onValueChanged(): void; + onCellChanged(cell: MatrixDropdownCellModel): void; + } +} + +/// +/// +declare module Survey { + interface IMultipleTextData { + getMultipleTextValue(name: string): any; + setMultipleTextValue(name: string, value: any): any; + } + class MultipleTextItemModel extends Base implements IValidatorOwner { + name: any; + private data; + private titleValue; + validators: Array; + constructor(name?: any, title?: string); + getType(): string; + setData(data: IMultipleTextData): void; + title: string; + value: any; + onValueChanged(newValue: any): void; + getValidatorTitle(): string; + } + class QuestionMultipleTextModel extends Question implements IMultipleTextData { + name: string; + itemSize: number; + items: Array; + constructor(name: string); + getType(): string; + AddItem(name: string, title?: string): MultipleTextItemModel; + private isMultipleItemValueChanging; + protected onValueChanged(): void; + protected createTextItem(name: string, title: string): MultipleTextItemModel; + protected onItemValueChanged(): void; + protected runValidators(): SurveyError; + getMultipleTextValue(name: string): any; + setMultipleTextValue(name: string, value: any): void; + } +} + +/// +/// +declare module Survey { + class QuestionRadiogroupModel extends QuestionCheckboxBase { + name: string; + constructor(name: string); + getType(): string; + } +} + +/// +/// +declare module Survey { + class QuestionRatingModel extends Question { + name: string; + static defaultRateValues: ItemValue[]; + private rates; + mininumRateDescription: string; + maximumRateDescription: string; + rateValuesChangedCallback: () => void; + constructor(name: string); + rateValues: Array; + visibleRateValues: ItemValue[]; + getType(): string; + supportComment(): boolean; + supportOther(): boolean; + } +} + +/// +/// +declare module Survey { + class QuestionTextModel extends Question { + name: string; + size: number; + constructor(name: string); + getType(): string; + isEmpty(): boolean; + } +} + +/// +/// +declare module Survey { + class Trigger extends Base { + static operatorsValue: HashTable; + static operators: HashTable; + private opValue; + value: any; + constructor(); + operator: string; + check(value: any): void; + protected onSuccess(): void; + protected onFailure(): void; + } + interface ISurveyTriggerOwner { + getObjects(pages: string[], questions: string[]): any[]; + } + class SurveyTrigger extends Trigger { + name: string; + pages: string[]; + questions: string[]; + private owner; + constructor(); + setOwner(owner: ISurveyTriggerOwner): void; + protected onSuccess(): void; + protected onFailure(): void; + onTrigger(func: Function): void; + protected onItemSuccess(item: any): void; + protected onItemFailure(item: any): void; + } + class SurveyTriggerVisible extends SurveyTrigger { + constructor(); + getType(): string; + protected onItemSuccess(item: any): void; + protected onItemFailure(item: any): void; + } +} + +/// +/// +/// +/// +/// +declare module Survey { + class SurveyModel extends Base implements ISurvey, ISurveyTriggerOwner { + surveyId: string; + surveyPostId: string; + clientId: string; + sendResultOnPageNext: boolean; + commentPrefix: string; + title: string; + showNavigationButtons: boolean; + showTitle: boolean; + showPageTitles: boolean; + requiredText: string; + showProgressBar: string; + pages: Array; + triggers: Array; + private currentPageValue; + private valuesHash; + private pagePrevTextValue; + private pageNextTextValue; + private completeTextValue; + private showPageNumbersValue; + private showQuestionNumbersValue; + private localeValue; + onComplete: Event<(sender: SurveyModel) => any, any>; + onCurrentPageChanged: Event<(sender: SurveyModel, options: any) => any, any>; + onValueChanged: Event<(sender: SurveyModel, options: any) => any, any>; + onVisibleChanged: Event<(sender: SurveyModel, options: any) => any, any>; + onPageVisibleChanged: Event<(sender: SurveyModel, options: any) => any, any>; + onQuestionAdded: Event<(sender: SurveyModel, options: any) => any, any>; + onQuestionRemoved: Event<(sender: SurveyModel, options: any) => any, any>; + onValidateQuestion: Event<(sender: SurveyModel, options: any) => any, any>; + onSendResult: Event<(sender: SurveyModel, options: any) => any, any>; + onGetResult: Event<(sender: SurveyModel, options: any) => any, any>; + jsonErrors: Array; + mode: string; + constructor(jsonObj?: any, renderedElement?: any); + getType(): string; + locale: string; + pagePrevText: string; + pageNextText: string; + completeText: string; + showPageNumbers: boolean; + showQuestionNumbers: string; + data: any; + comments: any; + visiblePages: Array; + isEmpty: boolean; + PageCount: number; + visiblePageCount: number; + currentPage: PageModel; + protected currentPageChanged(newValue: PageModel, oldValue: PageModel): void; + isDesignMode: boolean; + nextPage(): boolean; + isCurrentPageHasErrors: boolean; + prevPage(): boolean; + completeLastPage(): boolean; + isFirstPage: boolean; + isLastPage: boolean; + progressText: string; + getPage(index: number): PageModel; + addPage(page: PageModel): void; + addNewPage(name: string): PageModel; + removePage(page: PageModel): void; + getQuestionByName(name: string): IQuestion; + getQuestionsByNames(names: string[]): IQuestion[]; + getPageByQuestion(question: IQuestion): PageModel; + getPageByName(name: string): PageModel; + getPagesByNames(names: string[]): PageModel[]; + getAllQuestions(visibleOnly?: boolean): Array; + protected createNewPage(name: string): PageModel; + private notifyQuestionOnValueChanged(name, newValue); + private notifyAllQuestionsOnValueChanged(); + private checkTriggers(name, newValue); + sendResult(postId?: string, clientId?: string, isPartialCompleted?: boolean): void; + getResult(resultId: string, name: string): void; + loadSurveyFromService(surveyId?: string, element?: any): void; + protected onLoadSurveyFromService(element: any): void; + private updateVisibleIndexes(); + private updatePageVisibleIndexes(showIndex); + private updateQuestionVisibleIndexes(questions, showIndex); + private setJsonObject(jsonObj); + protected onBeforeCreating(): void; + protected onCreating(): void; + getValue(name: string): any; + setValue(name: string, newValue: any): void; + getComment(name: string): string; + setComment(name: string, newValue: string): void; + questionVisibilityChanged(question: IQuestion, newValue: boolean): void; + pageVisibilityChanged(page: IPage, newValue: boolean): void; + questionAdded(question: IQuestion, index: number): void; + questionRemoved(question: IQuestion): void; + validateQuestion(name: string): SurveyError; + getObjects(pages: string[], questions: string[]): any[]; + } +} + +declare module Survey { + class SurveyWindowModel extends Base { + static surveyElementName: string; + surveyValue: SurveyModel; + windowElement: HTMLDivElement; + isShowingValue: boolean; + isExpandedValue: boolean; + titleValue: string; + templateValue: string; + constructor(jsonObj: any); + getType(): string; + survey: SurveyModel; + isShowing: boolean; + isExpanded: boolean; + title: string; + expand(): void; + collapse(): void; + protected createSurvey(jsonObj: any): SurveyModel; + protected expandcollapse(value: boolean): void; + } +} + +/// +declare module Survey { +} + +/// +declare module Survey { +} + +/// +declare module Survey { + class Page extends PageModel { + koNo: any; + constructor(name?: string); + protected onCreating(): void; + protected onNumChanged(value: number): void; + } +} + +/// +declare module Survey { + class QuestionImplementorBase { + question: QuestionBase; + koVisible: any; + koNo: any; + koErrors: any; + constructor(question: QuestionBase); + protected onVisibilityChanged(): void; + protected onVisibleIndexChanged(): void; + protected getNo(): string; + } +} + +/// +/// +declare module Survey { + class QuestionImplementor extends QuestionImplementorBase { + question: Question; + private isUpdating; + koValue: any; + koComment: any; + constructor(question: Question); + protected onValueChanged(): void; + protected onCommentChanged(): void; + protected onVisibilityChanged(): void; + protected onVisibleIndexChanged(): void; + protected onErrorsChanged(): void; + protected createkoValue(): any; + protected setkoValue(newValue: any): void; + protected updateValue(newValue: any): void; + protected updateComment(newValue: any): void; + protected getNo(): string; + } +} + +/// +declare module Survey { + class QuestionSelectBaseImplementor extends QuestionImplementor { + koOtherVisible: any; + constructor(question: Question); + protected isOtherSelected: boolean; + } + class QuestionCheckboxBaseImplementor extends QuestionSelectBaseImplementor { + koWidth: any; + constructor(question: Question); + protected onColCountChanged(): void; + protected colWidth: string; + private koAfterRender(el, con); + } +} + +/// +/// +declare module Survey { + class QuestionCheckbox extends QuestionCheckboxModel { + name: string; + constructor(name: string); + } +} + +/// +declare module Survey { + class QuestionComment extends QuestionCommentModel { + name: string; + constructor(name: string); + } +} + +/// +declare module Survey { + class QuestionDropdown extends QuestionDropdownModel { + name: string; + constructor(name: string); + } +} + +/// +/// +declare module Survey { + class QuestionHtml extends QuestionHtmlModel { + name: string; + constructor(name: string); + } +} + +/// +declare module Survey { + class MatrixRow extends MatrixRowModel { + name: any; + text: string; + fullName: string; + private isValueUpdating; + koValue: any; + constructor(name: any, text: string, fullName: string, data: IMatrixData, value: any); + protected onValueChanged(): void; + } + class QuestionMatrix extends QuestionMatrixModel { + name: string; + constructor(name: string); + protected createMatrixRow(name: any, text: string, fullName: string, value: any): MatrixRowModel; + } +} + +/// +declare module Survey { + class MatrixDropdownCell extends MatrixDropdownCellModel { + column: MatrixDropdownColumn; + row: MatrixDropdownRowModel; + private isValueUpdating; + koValue: any; + constructor(column: MatrixDropdownColumn, row: MatrixDropdownRowModel, data: IMatrixDropdownData, value: any); + protected onValueChanged(): void; + } + class MatrixDropdownRow extends MatrixDropdownRowModel { + name: any; + text: string; + constructor(name: any, text: string, data: IMatrixDropdownData, value: any); + protected createCell(column: MatrixDropdownColumn, value: any): MatrixDropdownCellModel; + } + class QuestionMatrixDropdown extends QuestionMatrixDropdownModel { + name: string; + constructor(name: string); + protected createMatrixRow(name: any, text: string, value: any): MatrixDropdownRowModel; + } +} + +/// +declare module Survey { + class MultipleTextItem extends MultipleTextItemModel { + name: any; + private isKOValueUpdating; + koValue: any; + constructor(name?: any, title?: string); + onValueChanged(newValue: any): void; + } + class QuestionMultipleText extends QuestionMultipleTextModel { + name: string; + constructor(name: string); + protected createTextItem(name: string, title: string): MultipleTextItemModel; + } +} + +/// +declare module Survey { + class QuestionRadiogroup extends QuestionRadiogroupModel { + name: string; + constructor(name: string); + } +} + +/// +declare module Survey { + class QuestionRating extends QuestionRatingModel { + name: string; + constructor(name: string); + } +} + +/// +declare module Survey { + class QuestionText extends QuestionTextModel { + name: string; + constructor(name: string); + } +} + +/// +declare module Survey { + class SurveyBase extends SurveyModel { + private renderedElement; + onRendered: Event<(sender: SurveyModel) => any, any>; + koCurrentPage: any; + koIsFirstPage: any; + koIsLastPage: any; + dummyObservable: any; + koProgress: any; + koProgressText: any; + constructor(jsonObj?: any, renderedElement?: any); + render(element?: any): void; + protected createNewPage(name: string): Page; + protected getTemplate(): string; + protected onBeforeCreating(): void; + protected currentPageChanged(newValue: PageModel, oldValue: PageModel): void; + protected onLoadSurveyFromService(element: any): void; + private applyBinding(); + private updateKoCurrentPage(); + private getProgress(); + } +} + +/// +/// +declare module Survey { + class SurveyWindowBase extends SurveyWindowModel { + koExpanded: any; + doExpand: any; + constructor(jsonObj: any); + protected createSurvey(jsonObj: any): SurveyModel; + protected expandcollapse(value: boolean): void; + protected template: string; + show(): void; + protected getDefaultTemplate(): string; + hide(): void; + private changeExpanded(); + private onComplete(); + } +} + +declare module Survey { + class SurveyTemplateTextBase { + constructor(); + replaceText(replaceText: string, id: string, questionType?: string): void; + protected getId(id: string, questionType: string): string; + protected text: string; + } +} + +declare module template.ko { + var html: string; +} + +/// +/// +declare module Survey { + class Survey extends SurveyBase { + constructor(jsonObj?: any, renderedElement?: any); + protected getTemplate(): string; + } +} + +/// +/// +declare module Survey { + class SurveyWindow extends SurveyWindowBase { + koExpanded: any; + doExpand: any; + constructor(jsonObj: any); + protected createSurvey(jsonObj: any): SurveyModel; + protected getDefaultTemplate(): string; + } +} + +declare module template.window.ko { + var html: string; +} + +/// +/// +declare module Survey { + class SurveyTemplateText extends SurveyTemplateTextBase { + protected text: string; + } +} + From 6d1c71e4802e9e33c739a7aff7fccf5597eae3f3 Mon Sep 17 00:00:00 2001 From: Randall Koutnik Date: Mon, 25 Apr 2016 08:33:22 -0700 Subject: [PATCH 14/67] Add definition for hidden function in colors (#9097) This is the secret style referenced at the end of colors' readme. --- colors/colors.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/colors/colors.d.ts b/colors/colors.d.ts index cc6b307c03..07c4c19e06 100644 --- a/colors/colors.d.ts +++ b/colors/colors.d.ts @@ -41,6 +41,7 @@ declare module "colors" { america: Color; trap: Color; random: Color; + zalgo: Color; } namespace e { From 6adcd02b062c7ad6302a1b69baa56d6194718795 Mon Sep 17 00:00:00 2001 From: Jakob Gillich Date: Mon, 25 Apr 2016 17:36:30 +0200 Subject: [PATCH 15/67] pouch: add callback-less constructor (#8868) --- pouchDB/pouch.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pouchDB/pouch.d.ts b/pouchDB/pouch.d.ts index d3097a4099..0360e02b65 100644 --- a/pouchDB/pouch.d.ts +++ b/pouchDB/pouch.d.ts @@ -207,11 +207,13 @@ interface PouchApi { interface PouchOptions { name?: string; adapter?: string; + skip_setup?: boolean; } interface PouchDB extends PouchApi { new (name: string, opts: PouchOptions, callback: (err: PouchError, res: PouchDB) => void): PouchDB; new (name: string, callback: (err: PouchError, res: PouchDB) => void): PouchDB; + new (name: string, opts: PouchOptions): PouchDB; new (name: string): PouchDB; destroy(name: string, callback: (err: PouchError) => void): void; } From 1f17720f56a341e2a290ee2182054b7317222a22 Mon Sep 17 00:00:00 2001 From: Derrick Liu Date: Mon, 25 Apr 2016 07:40:19 -0800 Subject: [PATCH 16/67] react-select: use export default to match library (#9100) * Update react-select to export Select by default * Update react-select tests to match --- react-select/react-select-tests.tsx | 2 +- react-select/react-select.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/react-select/react-select-tests.tsx b/react-select/react-select-tests.tsx index b5258d85ca..8e573e1444 100644 --- a/react-select/react-select-tests.tsx +++ b/react-select/react-select-tests.tsx @@ -5,7 +5,7 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; -import * as Select from "react-select"; +import Select from "react-select"; class SelectTest extends React.Component, {}> { diff --git a/react-select/react-select.d.ts b/react-select/react-select.d.ts index 5ad97ba2ff..72cc5d43e8 100644 --- a/react-select/react-select.d.ts +++ b/react-select/react-select.d.ts @@ -302,5 +302,5 @@ declare namespace ReactSelect { declare module "react-select" { const select: ReactSelect.ReactSelectClass; - export = select; + export default select; } From 869bd9c489a21cc6ed7fe56978b2cfced295c4a7 Mon Sep 17 00:00:00 2001 From: Robin Joseph Date: Mon, 25 Apr 2016 08:41:51 -0700 Subject: [PATCH 17/67] Update bookshelf.d.ts (#9101) --- bookshelf/bookshelf-tests.ts | 3 +++ bookshelf/bookshelf.d.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bookshelf/bookshelf-tests.ts b/bookshelf/bookshelf-tests.ts index 42faf0909e..92758e143a 100644 --- a/bookshelf/bookshelf-tests.ts +++ b/bookshelf/bookshelf-tests.ts @@ -15,6 +15,9 @@ var knex = Knex({ var bookshelf = Bookshelf(knex); +bookshelf.plugin('registry'); +bookshelf.plugin(['virtuals']); + class User extends bookshelf.Model { get tableName() { return 'users'; } messages() : Bookshelf.Collection { diff --git a/bookshelf/bookshelf.d.ts b/bookshelf/bookshelf.d.ts index 74f5e83d4a..cf70220840 100644 --- a/bookshelf/bookshelf.d.ts +++ b/bookshelf/bookshelf.d.ts @@ -18,7 +18,7 @@ declare module 'bookshelf' { Model : typeof Bookshelf.Model; Collection : typeof Bookshelf.Collection; - plugin(name: string) : Bookshelf; + plugin(name: string | string[] | Function, options?: any) : Bookshelf; transaction(callback : (transaction : knex.Transaction) => T) : Promise; } From 925fedb376b733608663d213aa908407a4bfd6b6 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 26 Apr 2016 01:15:01 +0930 Subject: [PATCH 18/67] adding react-mdl (#9102) * added material-design-lite definition and tests * adding react-mdl * fixed es6 compilation by chanigng import i don't know why git is saying that every line changed... * fixed es6 compilation --- react-mdl/react-mdl-tests.tsx | 1044 +++++++++++++++++++++++++++++++++ react-mdl/react-mdl.d.ts | 606 +++++++++++++++++++ 2 files changed, 1650 insertions(+) create mode 100644 react-mdl/react-mdl-tests.tsx create mode 100644 react-mdl/react-mdl.d.ts diff --git a/react-mdl/react-mdl-tests.tsx b/react-mdl/react-mdl-tests.tsx new file mode 100644 index 0000000000..1e7fd19b0c --- /dev/null +++ b/react-mdl/react-mdl-tests.tsx @@ -0,0 +1,1044 @@ +// Test file for react-mdl Definition file +/// + +import * as React from 'react'; +import {Badge, + FABButton, Button, IconButton, + Card, CardActions, CardTitle, CardText, CardMenu, CardMedia, + Checkbox, + DataTable, TableHeader, Table, + Dialog, DialogTitle, DialogContent, DialogActions, + Grid, Cell, + Icon, IconToggle, + Layout, Header, Navigation, Drawer, Content, HeaderRow, HeaderTabs, Footer, FooterDropDownSection, FooterLinkList, FooterSection, + List, ListItem, ListItemContent, ListItemAction, + Menu, MenuItem, + ProgressBar, + RadioGroup, Radio, + Slider, + Snackbar, + Spinner, + Switch, + Tabs, Tab, + Textfield, + Tooltip} from 'react-mdl'; + +// all tests are from the examples provided here: https://tleunen.github.io/react-mdl/ + +// Badge tests +React.createClass({ + render: function() { + return ( +
+ {/* Number badge on icon */} + + + + + {/* Icon badge on icon */} + + + + + {/* Number badge on text */} + Inbox + + {/* Icon badge without background on text */} + Mood +
+ ); + } +}); + +// Button tests +React.createClass({ + render: function() { + return ( +
+ {/* Colored FAB button */} + + + + + {/* Colored FAB button with ripple */} + + + + + {/* FAB button */} + + + + + {/* FAB button with ripple */} + + + + + {/* Disabled FAB button */} + + + + + {/* Mini FAB button */} + + + + + {/* Colored Mini FAB button */} + + + + + {/* Raised button */} + + + {/* Raised button with ripple */} + + + {/* Disabled Raised button */} + + + {/* Colored Raised button */} + + + {/* Accent-colored button without ripple */} + + + {/* Accent-colored button with ripple */} + + + {/* Flat button */} + + + {/* Flat button with ripple */} + + + {/* Disabled flat button */} + + + {/* Primary colored flat button */} + + + {/* Accent-colored flat button */} + + + {/* Icon button */} + + + {/* Colored Icon button */} + +
+ ); + } +}) + +// Card tests +React.createClass({ + render: function() { + return ( +
+ + Welcome + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Mauris sagittis pellentesque lacus eleifend lacinia... + + + + + + + + + + + Update + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Aenan convallis. + + + + + + + + + + + Image.jpg + + + + + + +

+ Featured event:
+ May 24, 2016
+ 7-11pm +

+
+ + +
+ +
+
+
+ ); + } +}); + +// Checkbox tests +React.createClass({ + render: function() { + return ( +
+ + + +
+ ); + } +}); + +// DataTable tests +React.createClass({ + render: function() { + return ( +
+ + Material + Quantity + `\$${price.toFixed(2)}`} tooltip="Price pet unit">Price + + + + Material + Quantity + `\$${price.toFixed(2)}`} tooltip="Price pet unit">Price + + + + (isAsc ? a : b).match(/\((.*)\)/)[1].localeCompare((isAsc ? b : a).match(/\((.*)\)/)[1])} + tooltip="The amazing material name" + > + Material + + + Quantity + + `\$${price.toFixed(2)}`} + tooltip="Price pet unit" + > + Price + +
+
+ ); + } +}); + +// Dialog tests +React.createClass({ + render: function() { + return ( +
+
+ + + Allow data collection? + +

Allowing us to collect data will let us get you the information you want faster.

+
+ + + + +
+
+ +
+ + + Allow this site to collect usage data to improve your experience? + +

Allowing us to collect data will let us get you the information you want faster.

+
+ + + + +
+
+ +
+ + + Allow data collection? + +

Allowing us to collect data will let us get you the information you want faster.

+
+ + + + +
+
+
+ ); + } +}); + +// Grid tests +React.createClass({ + render: function() { + return ( +
+
+ + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + + 4 + 4 + 4 + + + 6 + 4 + 2 + + + 6 (8 tablet) + 4 (6 tablet) + 2 (4 phone) + +
+
+ ); + } +}); + +// IconToggle tests +React.createClass({ + render: function() { + return ( +
+ + + +
+ ); + } +}); + +// Layout tests +React.createClass({ + render: function() { + return ( +
+ {/* Uses a transparent header that draws on top of the layout's background */} +
+ +
+ + Link + Link + Link + Link + +
+ + + Link + Link + Link + Link + + + +
+
+ + {/* No header, and the drawer stays open on larger screens (fixed drawer). */} +
+ + + + Link + Link + Link + Link + + + + +
+ + {/* Always shows a header, even in smaller screens. */} +
+ +
Area / The Title}> + + Link + Link + Link + Link + +
+ + + Link + Link + Link + Link + + + +
+
+ + {/* The drawer is always open in large screens. The header is always shown, even in small screens. */} +
+ +
+ {}} + label="Search" + expandable + expandableIcon="search" + /> +
+ + + Link + Link + Link + Link + + + +
+
+ + {/* Uses a header that scrolls with the text, rather than staying locked at the top */} +
+ +
+ + Link + Link + Link + Link + +
+ + + Link + Link + Link + Link + + + +
+ + +
+ + {/* Uses a header that contracts as the page scrolls down. */} +
+ +
+ + {}} + label="Search" + expandable + expandableIcon="search" + /> + + + + Link + Link + Link + Link + + +
+ + + Link + Link + Link + Link + + + +
+ + +
+ + {/* Hide the top part of the header when scrolling down */} +
+ +
+ + {}} + label="Search" + expandable + expandableIcon="search" + /> + + + + Link + Link + Link + Link + + +
+ + + Link + Link + Link + Link + + + +
+ + +
+ +
+ +
+ + this.setState({ activeTab: tabId })}> + Tab1 + Tab2 + Tab3 + Tab4 + Tab5 + Tab6 + +
+ + +
Content for the tab: {this.state.activeTab}
+
+
+
+ + {/* Simple header with fixed tabs. */} +
+ +
+ + {}}> + Tab1 + Tab2 + Tab3 + +
+ + +
You can add logic to update the content of this container based on the "activeTab" receive in the `onChange` callback.
+
+
+
+ + + + +
+ ); + } +}); + +// List tests +React.createClass({ + render: function() { + return ( +
+ + Bryan Cranston + Aaron Paul + Bob Odenkirk + + + + + Bryan Cranston + + + Aaron Paul + + + Bob Odenkirk + + + + + + Bryan Cranston + + + + + + Aaron Paul + + + + + + Bob Odenkirk + + + + + + + + + Bryan Cranston + + + + + + Aaron Paul + + + + + + Bob Odenkirk + + + + + + + + + Bryan Cranston + + + + + + Aaron Paul + + + + + + Bob Odenkirk + + + + + + + + + Bryan Cranston + + + + + + Aaron Paul + + + + + + Bob Odenkirk + + + + + +
+ ); + } +}); + +// Menu tests +React.createClass({ + render: function() { + return ( +
+ {/* Lower left */} +
+ + + Some Action + Another Action + Disabled Action + Yet Another Action + +
+ + {/* Lower right */} +
+ + + Some Action + Another Action + Disabled Action + Yet Another Action + +
+ + {/* Top left */} +
+ + + Some Action + Another Action + Disabled Action + Yet Another Action + +
+ + {/* Top right */} +
+ + + Some Action + Another Action + Disabled Action + Yet Another Action + +
+
+ ); + } +}); + +// ProgressBar tests +React.createClass({ + render: function() { + return ( +
+ {/* Simple Progress Bar */} + + + {/* Progress Bar with Indeterminate Progress */} + + + {/* Progress Bar with Buffering */} + +
+ ); + } +}); + +// Radio tests +React.createClass({ + render: function() { + return ( +
+ + Ripple option + Other option + + + + Ripple option + Other option + +
+ ); + } +}); + +// Slider tests +React.createClass({ + render: function() { + return ( +
+ {/* Default slider */} + + + {/* Slider with initial value */} + +
+ ); + } +}); + +// Snackbar tests +React.createClass({ + render: function() { + return ( +
+
+ + Button color changed. +
+ +
+ + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius luctus quam. Fusce quis blandit libero. Donec accumsan nunc lectus, vel blandit diam bibendum ac. Integer faucibus, lorem et convallis fermentum, diam dolor imperdiet mi, nec iaculis risus mauris id elit. Vivamus vel eros dapibus, molestie ante ut, vestibulum sem. + +
+
+ ); + } +}); + +// Spinner tests +React.createClass({ + render: function() { + return ( +
+ {/* Simple spinner */} + + + {/* Single color spinner */} + +
+ ); + } +}); + +// Switch tests +React.createClass({ + render: function() { + return ( +
+ Ripple switch + + Switch +
+ ); + } +}); + +// Tab tests +React.createClass({ + render: function() { + return ( +
+
+ this.setState({ activeTab: tabId })} ripple> + Starks + Lannisters + Targaryens + +
+
Content for the tab: {this.state.activeTab}
+
+
+
+ ); + } +}); + +// Textfield tests +React.createClass({ + render: function() { + return ( +
+ {/* Simple textfield */} + {}} + label="Text..." + style={{width: '200px'}} + /> + + {/* Numeric textfield */} + {}} + pattern="-?[0-9]*(\.[0-9]+)?" + error="Input is not a number!" + label="Number..." + style={{width: '200px'}} + /> + + {/* Textfield with floating label */} + {}} + label="Text..." + floatingLabel + style={{width: '200px'}} + /> + + {/* Numeric Textfield with floating label */} + {}} + pattern="-?[0-9]*(\.[0-9]+)?" + error="Input is not a number!" + label="Number..." + floatingLabel + /> +
+ ); + } +}); + +// Tooltip tests +React.createClass({ + render: function() { + return ( +
+ {/* Simple tooltip */} + + + + + {/* Large Tooltip */} + + + + + {/* Rich Tooltip */} + Upload file.zip}> + + + + {/* Multiline Tooltip */} + Share your content
via social media}> + +
+ + {/* Right Tooltip */} + + + + + {/* Left Tooltip */} + + + + + {/* Top Tooltip */} + + + + + {/* Bottom Tooltip */} + + + +
+ ); + } +}); diff --git a/react-mdl/react-mdl.d.ts b/react-mdl/react-mdl.d.ts new file mode 100644 index 0000000000..56d688c7f4 --- /dev/null +++ b/react-mdl/react-mdl.d.ts @@ -0,0 +1,606 @@ +// Type definitions for react-mdl 1.5.3 +// Project: https://github.com/tleunen/react-mdl +// Definitions by: Brad Zacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace __ReactMDL { + import React = __React; + + type __MDLClassProps = React.ClassAttributes; + type __MDLOtherProps = React.HTMLProps; + class __MDLComponent

extends React.Component {} + class __MDLBasicComponent extends __MDLComponent<__MDLOtherProps> {} + + interface ShadowedComponent { + shadow ?: number; + } + interface RippleComponent { + ripple ?: boolean; + } + interface CustomRenderedComponent { + component ?: string | JSX.Element | Function; + } + + + // HTMLAttributes (minus the 'data', 'icon', 'label', 'name', 'rows', 'size', 'title', 'value' attributes) + interface MDLHTMLAttributes { + // React-specific Attributes + defaultChecked?: boolean; + defaultValue?: string | string[]; + + // Standard HTML Attributes + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: string; + autoFocus?: boolean; + autoPlay?: boolean; + capture?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + challenge?: string; + checked?: boolean; + classID?: string; + className?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: boolean; + coords?: string; + crossOrigin?: string; + dateTime?: string; + default?: boolean; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + hidden?: boolean; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + id?: string; + inputMode?: string; + integrity?: string; + is?: string; + keyParams?: string; + keyType?: string; + kind?: string; + lang?: string; + list?: string; + loop?: boolean; + low?: number; + manifest?: string; + marginHeight?: number; + marginWidth?: number; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + minLength?: number; + multiple?: boolean; + muted?: boolean; + nonce?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + reversed?: boolean; + role?: string; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcLang?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: React.CSSProperties; + summary?: string; + tabIndex?: number; + target?: string; + type?: string; + useMap?: string; + width?: number | string; + wmode?: string; + wrap?: string; + + // RDFa Attributes + about?: string; + datatype?: string; + inlist?: any; + prefix?: string; + property?: string; + resource?: string; + typeof?: string; + vocab?: string; + + // Non-standard Attributes + autoCapitalize?: string; + autoCorrect?: string; + autoSave?: string; + color?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + itemID?: string; + itemRef?: string; + results?: number; + security?: string; + unselectable?: boolean; + + // Allows aria- and data- Attributes + [key: string]: any; + } + // DOMAttributes (minus 'onClick', 'onChange') + interface MDLDOMAttributes { + // DOMAttributes (minus onClick) + children?: React.ReactNode; + dangerouslySetInnerHTML?: { + __html: string; + }; + + // Clipboard Events + onCopy?: React.ClipboardEventHandler; + onCut?: React.ClipboardEventHandler; + onPaste?: React.ClipboardEventHandler; + + // Composition Events + onCompositionEnd?: React.CompositionEventHandler; + onCompositionStart?: React.CompositionEventHandler; + onCompositionUpdate?: React.CompositionEventHandler; + + // Focus Events + onFocus?: React.FocusEventHandler; + onBlur?: React.FocusEventHandler; + + // Form Events + onInput?: React.FormEventHandler; + onSubmit?: React.FormEventHandler; + + // Image Events + onLoad?: React.ReactEventHandler; + onError?: React.ReactEventHandler; // also a Media Event + + // Keyboard Events + onKeyDown?: React.KeyboardEventHandler; + onKeyPress?: React.KeyboardEventHandler; + onKeyUp?: React.KeyboardEventHandler; + + // Media Events + onAbort?: React.ReactEventHandler; + onCanPlay?: React.ReactEventHandler; + onCanPlayThrough?: React.ReactEventHandler; + onDurationChange?: React.ReactEventHandler; + onEmptied?: React.ReactEventHandler; + onEncrypted?: React.ReactEventHandler; + onEnded?: React.ReactEventHandler; + onLoadedData?: React.ReactEventHandler; + onLoadedMetadata?: React.ReactEventHandler; + onLoadStart?: React.ReactEventHandler; + onPause?: React.ReactEventHandler; + onPlay?: React.ReactEventHandler; + onPlaying?: React.ReactEventHandler; + onProgress?: React.ReactEventHandler; + onRateChange?: React.ReactEventHandler; + onSeeked?: React.ReactEventHandler; + onSeeking?: React.ReactEventHandler; + onStalled?: React.ReactEventHandler; + onSuspend?: React.ReactEventHandler; + onTimeUpdate?: React.ReactEventHandler; + onVolumeChange?: React.ReactEventHandler; + onWaiting?: React.ReactEventHandler; + + // MouseEvents + onContextMenu?: React.MouseEventHandler; + onDoubleClick?: React.MouseEventHandler; + onDrag?: React.DragEventHandler; + onDragEnd?: React.DragEventHandler; + onDragEnter?: React.DragEventHandler; + onDragExit?: React.DragEventHandler; + onDragLeave?: React.DragEventHandler; + onDragOver?: React.DragEventHandler; + onDragStart?: React.DragEventHandler; + onDrop?: React.DragEventHandler; + onMouseDown?: React.MouseEventHandler; + onMouseEnter?: React.MouseEventHandler; + onMouseLeave?: React.MouseEventHandler; + onMouseMove?: React.MouseEventHandler; + onMouseOut?: React.MouseEventHandler; + onMouseOver?: React.MouseEventHandler; + onMouseUp?: React.MouseEventHandler; + + // Selection Events + onSelect?: React.ReactEventHandler; + + // Touch Events + onTouchCancel?: React.TouchEventHandler; + onTouchEnd?: React.TouchEventHandler; + onTouchMove?: React.TouchEventHandler; + onTouchStart?: React.TouchEventHandler; + + // UI Events + onScroll?: React.UIEventHandler; + + // Wheel Events + onWheel?: React.WheelEventHandler; + } + + + + interface BadgeProps extends __MDLClassProps { + text: string | number; + className ?: string; + noBackground ?: boolean; + overlap ?: boolean; + } + class Badge extends __MDLComponent {} + + + interface ButtonProps extends __MDLOtherProps, RippleComponent, CustomRenderedComponent { + accent ?: boolean; + colored ?: boolean; + primary ?: boolean; + } + interface StandardButtonProps extends ButtonProps { + raised ?: boolean; + } + interface FABButtonProps extends ButtonProps { + mini ?: boolean; + } + interface IconButtonProps extends ButtonProps { + name ?: string; + raised ?: boolean; + } + class Button extends __MDLComponent {} + class FABButton extends __MDLComponent {} + class IconButton extends __MDLComponent {} + + + interface CardProps extends __MDLOtherProps, ShadowedComponent {} + interface CardActionProps extends __MDLOtherProps { + border ?: boolean; + } + interface CardTitleProps extends __MDLOtherProps { + expand ?: boolean; + } + class Card extends __MDLComponent {} + class CardActions extends __MDLComponent {} + class CardTitle extends __MDLComponent {} + class CardText extends __MDLBasicComponent {} + class CardMenu extends __MDLBasicComponent {} + class CardMedia extends __MDLBasicComponent {} + + + interface CheckboxProps extends __MDLOtherProps, RippleComponent { + checked ?: boolean; + disabled ?: boolean; + label ?: string; + } + class Checkbox extends __MDLComponent {} + + interface UndecoratedTableProps extends __MDLClassProps, MDLHTMLAttributes, React.DOMAttributes, ShadowedComponent { + rows: Array; + rowKeyColumn ?: string; + + name ?: string; + title ?: string; + } + interface TableProps extends UndecoratedTableProps { + sortable ?: boolean; + selectable ?: boolean; + onSelectionChanged ?: (row : any) => any; + } + interface TableHeaderProps extends __MDLClassProps, MDLHTMLAttributes, MDLDOMAttributes { + name : string; + title ?: string; + cellFormatter ?: (value : any, row : any, index : number) => React.ReactNode; + numeric ?: boolean; + nosort ?: boolean; + onClick ?: (e : React.MouseEvent, name : string) => any; + sortFn ?: (a : any, b : any, isAsc : boolean) => number; + tooltip ?: React.ReactNode; + } + class Table extends __MDLComponent {} + class TableHeader extends __MDLComponent {} + class UndecoratedTable extends __MDLComponent {} + class DataTable extends Table {} + + + interface DialogProps extends __MDLOtherProps { + open ?: boolean; + } + interface DialogActionsProps extends __MDLOtherProps { + fullWidth ?: boolean; + } + interface DialogTitleProps extends __MDLOtherProps, CustomRenderedComponent {} + class Dialog extends __MDLComponent {} + class DialogActions extends __MDLComponent {} + class DialogTitle extends __MDLComponent {} + class DialogContent extends __MDLBasicComponent {} + + + interface GridProps extends __MDLOtherProps, CustomRenderedComponent, ShadowedComponent { + noSpacing ?: boolean; + } + interface CellProps extends __MDLOtherProps, CustomRenderedComponent, ShadowedComponent { + col : number; + align ?: string; + phone ?: number; + tablet ?: number; + hideDesktop ?: boolean; + hidePhone ?: boolean; + hideTablet ?: boolean; + } + class Grid extends __MDLComponent {} + class Cell extends __MDLComponent {} + + + interface IconProps extends __MDLOtherProps { + name : string; + } + class Icon extends __MDLComponent {} + + + interface IconToggleProps extends __MDLOtherProps, RippleComponent { + name : string; + checked ?: boolean; + disabled ?: boolean; + } + class IconToggle extends __MDLComponent {} + + + interface ContentProps extends __MDLOtherProps, CustomRenderedComponent {} + interface DrawerProps extends __MDLOtherProps { + title ?: string; + } + interface HeaderProps extends __MDLOtherProps { + title ?: string; + scroll ?: boolean; + seamed ?: boolean; + transparent ?: boolean; + waterfall ?: boolean; + hideTop ?: boolean; + } + interface HeaderRowProps extends __MDLOtherProps { + title ?: string; + } + interface HeaderTabsProps extends __MDLOtherProps, RippleComponent { + activeTab ?: number; + onChange ?: React.FormEventHandler; + } + interface LayoutProps extends __MDLOtherProps { + fixedDrawer ?: boolean; + fixedHeader ?: boolean; + fixedTabse ?: boolean; + } + interface NavigationProps extends __MDLOtherProps {} + class Content extends __MDLComponent {} + class Drawer extends __MDLComponent {} + class Header extends __MDLComponent {} + class HeaderRow extends __MDLComponent {} + class HeaderTabs extends __MDLComponent {} + class Layout extends __MDLComponent {} + class Navigation extends __MDLComponent {} + class Spacer extends __MDLBasicComponent {} + + interface FooterProps extends MDLHTMLAttributes, React.DOMAttributes { + size ?: string; + + title ?: string; + } + interface FooterDropDownSectionProps extends MDLHTMLAttributes, React.DOMAttributes { + size ?: string; + title : React.ReactNode; + } + interface FooterLinkListProps extends MDLHTMLAttributes, React.DOMAttributes { + size ?: string; + + title ?: string; + } + interface FooterSectionProps extends MDLHTMLAttributes, React.DOMAttributes { + size ?: string; + type ?: string; + logo ?: React.ReactNode; + + title ?: string; + } + class Footer extends __MDLComponent {} + class FooterDropDownSection extends __MDLComponent {} + class FooterLinkList extends __MDLComponent {} + class FooterSection extends __MDLComponent {} + + interface ListItemProps extends __MDLOtherProps { + twoLine ?: boolean; + threeLine ?: boolean; + } + interface ListItemActionProps extends __MDLOtherProps { + info ?: string; + } + interface ListItemContentProps extends MDLHTMLAttributes, React.DOMAttributes { + avatar ?: string | JSX.Element; + icon ?: string | JSX.Element; + subtitle ?: React.ReactNode; + useBodyClass ?: boolean; + } + class List extends __MDLBasicComponent {} + class ListItem extends __MDLComponent {} + class ListItemAction extends __MDLComponent {} + class ListItemContent extends __MDLComponent {} + + + interface MenuProps extends __MDLOtherProps, RippleComponent { + target : string; + align ?: string; + valign ?: string; + } + class Menu extends __MDLComponent {} + class MenuItem extends __MDLBasicComponent {} + + + interface ProgressBarProps extends __MDLOtherProps { + buffer ?: number; + indeterminate ?: boolean; + progress ?: number; + } + class ProgressBar extends __MDLComponent {} + + + interface RadioProps extends MDLHTMLAttributes, React.DOMAttributes, RippleComponent { + value : string | number; + checked ?: boolean; + disabled ?: boolean; + name ?: string; + onChange ?: React.FormEventHandler; + label ?: string; + } + interface RadioGroupProps extends MDLHTMLAttributes, React.DOMAttributes { + name : string; + value : string | number; + childContainer ?: string; + container ?: string; + onChange ?: React.FormEventHandler; + label ?: string; + } + class Radio extends __MDLComponent {} + class RadioGroup extends __MDLComponent {} + + + interface SliderProps extends MDLHTMLAttributes, React.DOMAttributes { + max : number; + min : number; + onChange ?: React.FormEventHandler; + value ?: number; + } + class Slider extends __MDLComponent {} + + + interface SnackbarProps extends __MDLOtherProps { + active : boolean; + onTimeout : () => any; + action ?: string; + onActionClick ?: React.MouseEventHandler; + timeout ?: number; + } + class Snackbar extends __MDLComponent {} + + + interface SpinnerProps extends __MDLOtherProps { + singleColor ?: boolean; + } + class Spinner extends __MDLComponent {} + + + interface SwitchProps extends __MDLOtherProps, RippleComponent { + checked ?: boolean; + disabled ?: boolean; + onChange ?: React.FormEventHandler; + } + class Switch extends __MDLComponent {} + + + interface TabProps extends __MDLOtherProps, CustomRenderedComponent { + active ?: boolean; + cssPrefix ?: string; + onTabClick ?: (tabId : number) => any; + tabId ?: number; + } + interface TabBarProps extends MDLHTMLAttributes, MDLDOMAttributes { + cssPrefix : string; + activeTab ?: number; + onChange ?: (tabId : number) => any; + + name ?: string; + title ?: string; + onClick ?: React.MouseEventHandler; + } + interface TabsProps extends MDLHTMLAttributes, MDLDOMAttributes { + activeTab ?: number; + onChange ?: (tabId : number) => any; + tabBarProps ?: TabBarProps; + + name ?: string; + title ?: string; + onClick ?: React.MouseEventHandler; + } + class Tab extends __MDLComponent {} + class TabBar extends __MDLComponent {} + class Tabs extends __MDLComponent {} + + + interface TextfieldProps extends MDLHTMLAttributes, React.DOMAttributes { + label : string; + disabled ?: boolean; + error ?: React.ReactNode; + expandable ?: boolean; + expandableIcon ?: string; + floatingLabel ?: boolean; + id ?: string; + inputClassName ?: string; + maxRows ?: number; + onChange ?: React.FormEventHandler; + pattern ?: string; + required ?: boolean; + rows ?: number; + value ?: string | number; + + name ?: string; + title ?: string; + } + class Textfield extends __MDLComponent {} + + + interface TooltipProps extends MDLHTMLAttributes, React.DOMAttributes { + label : React.ReactNode; + large ?: boolean; + position ?: string; + + name ?: string; + title ?: string; + } + class Tooltip extends __MDLComponent {} +} + +declare module 'react-mdl' { + export = __ReactMDL; +} \ No newline at end of file From c2c611de3da3dadcaf911490d32f58653c541e67 Mon Sep 17 00:00:00 2001 From: mmmichl Date: Mon, 25 Apr 2016 17:45:14 +0200 Subject: [PATCH 19/67] Make JWT token payloads optional (#9093) This is suggested by the spec https://jwt.io/introduction/#payload --- angular-jwt/angular-jwt-tests.ts | 4 ++-- angular-jwt/angular-jwt.d.ts | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/angular-jwt/angular-jwt-tests.ts b/angular-jwt/angular-jwt-tests.ts index 7f66f26114..3a6b7d6bf1 100644 --- a/angular-jwt/angular-jwt-tests.ts +++ b/angular-jwt/angular-jwt-tests.ts @@ -3,14 +3,14 @@ var app = angular.module("angular-jwt-tests", ["angular-jwt"]); -var $jwtHelper: angular.jwt.IJwtHelper; +var $jwtHelper: ng.jwt.IJwtHelper; var expToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tLyIsInN1YiI6ImZhY2Vib29rfDEwMTU0Mjg3MDI3NTEwMzAyIiwiYXVkIjoiQlVJSlNXOXg2MHNJSEJ3OEtkOUVtQ2JqOGVESUZ4REMiLCJleHAiOjE0MTIyMzQ3MzAsImlhdCI6MTQxMjE5ODczMH0.7M5sAV50fF1-_h9qVbdSgqAnXVF7mz3I6RjS6JiH0H8'; var tokenPayload = $jwtHelper.decodeToken(expToken); var date = $jwtHelper.getTokenExpirationDate(expToken); var bool = $jwtHelper.isTokenExpired(expToken); -var $jwtInterceptor: angular.jwt.IJwtInterceptor; +var $jwtInterceptor: ng.jwt.IJwtInterceptor; $jwtInterceptor.tokenGetter = () => { return expToken; diff --git a/angular-jwt/angular-jwt.d.ts b/angular-jwt/angular-jwt.d.ts index d8c719e2ef..eb02cf24df 100644 --- a/angular-jwt/angular-jwt.d.ts +++ b/angular-jwt/angular-jwt.d.ts @@ -8,14 +8,14 @@ declare namespace angular.jwt { interface JwtToken { - iss: string; - sub: string; - aud: string; - exp: number; - nbf: number; - iat: number; - jti: string; - unique_name: string; + iss?: string; + sub?: string; + aud?: string; + exp?: number; + nbf?: number; + iat?: number; + jti?: string; + unique_name?: string; } interface IJwtHelper { From d0fb1d757135f5a0236467b3cf87f52b0b87ad01 Mon Sep 17 00:00:00 2001 From: georgeedwards Date: Mon, 25 Apr 2016 16:45:46 +0100 Subject: [PATCH 20/67] Made module name comply with the Azure docs (#9104) --- azure-mobile-services-client/AzureMobileServicesClient.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-mobile-services-client/AzureMobileServicesClient.d.ts b/azure-mobile-services-client/AzureMobileServicesClient.d.ts index f93ca868c7..b9749002c9 100644 --- a/azure-mobile-services-client/AzureMobileServicesClient.d.ts +++ b/azure-mobile-services-client/AzureMobileServicesClient.d.ts @@ -100,7 +100,7 @@ declare namespace Microsoft.WindowsAzure { } } -declare module "WindowsAzure" { +declare module "azure-mobile-apps-client" { export = WindowsAzure; } From 5b7257019ae959533341a715b339d2562bbf9b85 Mon Sep 17 00:00:00 2001 From: Alex Staroselsky Date: Mon, 25 Apr 2016 10:50:16 -0500 Subject: [PATCH 21/67] Exposed angular.mock.module.sharedInjector method for jasmine and mocha testing to take advantage of jasmine's beforeAll() and mocha's before() methods. (#9106) --- angularjs/angular-mocks-tests.ts | 1 + angularjs/angular-mocks.d.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/angularjs/angular-mocks-tests.ts b/angularjs/angular-mocks-tests.ts index 294bcf8982..8790e68cf3 100644 --- a/angularjs/angular-mocks-tests.ts +++ b/angularjs/angular-mocks-tests.ts @@ -36,6 +36,7 @@ mock.module( function () { return 2; } ); mock.module({ module1: function () { return 1; } }); +mock.module.sharedInjector(); date = mock.TzDate(-7, '2013-1-1T15:00:00Z'); date = mock.TzDate(-8, 12345678); diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts index c97471e5bf..9031cc56d1 100644 --- a/angularjs/angular-mocks.d.ts +++ b/angularjs/angular-mocks.d.ts @@ -47,7 +47,10 @@ declare namespace angular { inject: IInjectStatic // see https://docs.angularjs.org/api/ngMock/function/angular.mock.module - module(...modules: any[]): any; + module: { + (...modules: any[]): any; + sharedInjector(): void; + } // see https://docs.angularjs.org/api/ngMock/type/angular.mock.TzDate TzDate(offset: number, timestamp: number): Date; From 9b795ab947fd030e65e611326a41e0169709e43a Mon Sep 17 00:00:00 2001 From: Flavien R Date: Mon, 25 Apr 2016 17:51:20 +0200 Subject: [PATCH 22/67] Pikaday: added showDaysInNextAndPreviousMonths property. (#8849) * added missing property to Pikaday. * cleanup. * test --- pikaday/pikaday-tests.ts | 11 +++++++++++ pikaday/pikaday.d.ts | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/pikaday/pikaday-tests.ts b/pikaday/pikaday-tests.ts index f98d4afcee..48cd8d3226 100644 --- a/pikaday/pikaday-tests.ts +++ b/pikaday/pikaday-tests.ts @@ -71,3 +71,14 @@ new Pikaday({field: $('#datepicker')[0]}); yearRange: [2000, 2020] }); })(); + +(() => { + new Pikaday( + { + field: document.getElementById('datepicker'), + firstDay: 1, + minDate: new Date('2000-01-01'), + maxDate: new Date('2020-12-31'), + showDaysInNextAndPreviousMonths: true + }); +})(); diff --git a/pikaday/pikaday.d.ts b/pikaday/pikaday.d.ts index 0025561f54..3e4f80df9a 100644 --- a/pikaday/pikaday.d.ts +++ b/pikaday/pikaday.d.ts @@ -241,6 +241,11 @@ declare namespace Pikaday { * Render the month after the year in the title. Default: false. */ showMonthAfterYear?: boolean; + + /** + * Render days of the calendar grid that fall in the next or previous months to the current month instead of rendering an empty table cell. Default: false. + */ + showDaysInNextAndPreviousMonths?: boolean; /** * Number of visible calendars. From 7ae49d7dac88d557c33ab6621b8168f882c6ed5d Mon Sep 17 00:00:00 2001 From: Luca Cavallaro Date: Mon, 25 Apr 2016 17:51:34 +0200 Subject: [PATCH 23/67] Update vexflow.d.ts (#9095) * Update vexflow.d.ts Backends renderer enum starts with 1, according to http://www.vexflow.com/docs/renderer.html * Update vexflow.d.ts fix all enums * Update vexflow.d.ts fix StaveConnector 'type' enum. "SINGLE_LEFT and SINGLE are the same value for compatibility with older versions of vexflow" --- vexflow/vexflow.d.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/vexflow/vexflow.d.ts b/vexflow/vexflow.d.ts index 8fec777460..a651c850d4 100644 --- a/vexflow/vexflow.d.ts +++ b/vexflow/vexflow.d.ts @@ -167,8 +167,8 @@ declare namespace Vex { } namespace Annotation { - const enum Justify {LEFT, CENTER, RIGHT, CENTER_STEM} - const enum VerticalJustify {TOP, CENTER, BOTTOM, CENTER_STEM} + const enum Justify {LEFT = 1, CENTER, RIGHT, CENTER_STEM} + const enum VerticalJustify {TOP = 1, CENTER, BOTTOM, CENTER_STEM} const CATEGORY : string; } @@ -194,7 +194,7 @@ declare namespace Vex { } namespace Barline { - const enum type {SINGLE, DOUBLE, END, REPEAT_BEGIN, REPEAT_END, REPEAT_BOTH, NONE} + const enum type {SINGLE = 1, DOUBLE, END, REPEAT_BEGIN, REPEAT_END, REPEAT_BOTH, NONE} } class Barline extends StaveModifier { @@ -365,7 +365,7 @@ declare namespace Vex { } namespace Curve { - const enum Position {NEAR_HEAD, NEAR_TOP} + const enum Position {NEAR_HEAD = 1, NEAR_TOP} } class Dot extends Modifier { @@ -553,7 +553,7 @@ declare namespace Vex { } namespace Modifier { - const enum Position {LEFT, RIGHT, ABOVE, BELOW} + const enum Position {LEFT = 1, RIGHT, ABOVE, BELOW} const CATEGORY : string } @@ -717,7 +717,7 @@ declare namespace Vex { } namespace PedalMarking { - const enum Styles {TEXT, BRACKET, MIXED} + const enum Styles {TEXT = 1, BRACKET, MIXED} const GLYPHS : {[name : string] : {code : string, x_shift : number, y_shift : number}}; } @@ -774,8 +774,8 @@ declare namespace Vex { } namespace Renderer { - const enum Backends {CANVAS, RAPHAEL, SVG, VML} - const enum LineEndType {NONE, UP, DOWN} + const enum Backends {CANVAS = 1, RAPHAEL, SVG, VML} + const enum LineEndType {NONE = 1, UP, DOWN} } class Repetition extends StaveModifier { @@ -790,7 +790,7 @@ declare namespace Vex { } namespace Repetition { - const enum type { NONE, CODA_LEFT, CODA_RIGHT, SEGNO_LEFT, SEGNO_RIGHT, DC, DC_AL_CODA, DC_AL_FINE, DS, DS_AL_CODA, DS_AL_FINE, FINE } + const enum type { NONE = 1, CODA_LEFT, CODA_RIGHT, SEGNO_LEFT, SEGNO_RIGHT, DC, DC_AL_CODA, DC_AL_FINE, DS, DS_AL_CODA, DS_AL_FINE, FINE } } class Stave { @@ -859,7 +859,7 @@ declare namespace Vex { } namespace StaveConnector { - const enum type { SINGLE_RIGHT, SINGLE_LEFT, SINGLE, DOUBLE, BRACE, BRACKET, BOLD_DOUBLE_LEFT, BOLD_DOUBLE_RIGHT, THIN_DOUBLE } + const enum type { SINGLE_RIGHT = 0, SINGLE_LEFT = 1, SINGLE = 1, DOUBLE = 2, BRACE = 3, BRACKET = 4, BOLD_DOUBLE_LEFT = 5, BOLD_DOUBLE_RIGHT = 6, THIN_DOUBLE = 7 } } class StaveHairpin { @@ -874,7 +874,7 @@ declare namespace Vex { } namespace StaveHairpin { - const enum type { CRESC, DECRESC } + const enum type { CRESC = 1, DECRESC } } class StaveLine { @@ -892,8 +892,8 @@ declare namespace Vex { } namespace StaveLine { - const enum TextVerticalPosition { TOP, BOTTOM } - const enum TextJustification { LEFT, CENTER, RIGHT } + const enum TextVerticalPosition { TOP = 1, BOTTOM } + const enum TextJustification { LEFT = 1, CENTER, RIGHT } } class StaveModifier { @@ -1105,7 +1105,7 @@ declare namespace Vex { } namespace Stroke { - const enum Type {BRUSH_DOWN, BRUSH_UP, ROLL_DOWN, ROLL_UP, RASQUEDO_DOWN, RASQUEDO_UP} + const enum Type {BRUSH_DOWN = 1, BRUSH_UP, ROLL_DOWN, ROLL_UP, RASQUEDO_DOWN, RASQUEDO_UP} const CATEGORY : string; } @@ -1212,7 +1212,7 @@ declare namespace Vex { } namespace TextBracket { - const enum Positions {TOP, BOTTOM} + const enum Positions {TOP = 1, BOTTOM = -1} } class TextDynamics extends Note { @@ -1232,7 +1232,7 @@ declare namespace Vex { } namespace TextNote { - const enum Justification {LEFT, CENTER, RIGHT} + const enum Justification {LEFT = 1, CENTER, RIGHT} const GLYPHS : {[name : string] : {code : string, point : number, x_shift : number, y_shift : number}} } @@ -1390,7 +1390,7 @@ declare namespace Vex { } namespace Voice { - const enum Mode {STRICT, SOFT, FULL} + const enum Mode {STRICT = 1, SOFT, FULL} } class VoiceGroup { @@ -1407,7 +1407,7 @@ declare namespace Vex { } namespace Volta { - const enum type {NONE, BEGIN, MID, END, BEGIN_END} + const enum type {NONE = 1, BEGIN, MID, END, BEGIN_END} } } } From bde199ae38af4220608c9afe4959275ec5230fe4 Mon Sep 17 00:00:00 2001 From: Vaggelis Mparmpas Date: Mon, 25 Apr 2016 17:58:29 +0200 Subject: [PATCH 24/67] Removed: ISourceArg, IDestinationArg, linkChannels (#9107) Changed: wiretaps to wireTaps --- postal/postal.d.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/postal/postal.d.ts b/postal/postal.d.ts index d476c3710a..62caad6c1d 100644 --- a/postal/postal.d.ts +++ b/postal/postal.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Postal v1.0.6 +// Type definitions for Postal v1.0.8 // Project: https://github.com/postaljs/postal.js // Definitions by: Lokesh Peta , Paul Jolly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -61,19 +61,9 @@ interface IChannelDefinition { channel: string; } -interface ISourceArg { - topic: string; - channel?: string; -} - -interface IDestinationArg { - topic: string | ((topic: string) => string); - channel?: string; -} - interface IPostal { subscriptions: {}; - wiretaps: ICallback[]; + wireTaps: ICallback[]; addWireTap(callback: ICallback): () => void; @@ -83,8 +73,6 @@ interface IPostal { getSubscribersFor(options: {channel?: string, topic?: string, context?: any}): ISubscriptionDefinition[]; getSubscribersFor(predicateFn: (sub: ISubscriptionDefinition) => boolean): ISubscriptionDefinition[]; - linkChannels(source: ISourceArg | ISourceArg[], destination: IDestinationArg | IDestinationArg[]): void; - publish(envelope: IEnvelope): void; reset(): void; From 735fe1063ed8b32595296d41295847c2ecd75357 Mon Sep 17 00:00:00 2001 From: Piotr Laszczkowski Date: Mon, 25 Apr 2016 18:00:02 +0200 Subject: [PATCH 25/67] Update definitions for Handsontable (#8970) * Add type definitions for Handsontable * Update definitions for Handsontable --- handsontable/handsontable-tests.ts | 14 ++++++++++++++ handsontable/handsontable.d.ts | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/handsontable/handsontable-tests.ts b/handsontable/handsontable-tests.ts index 88cbe587af..25ec4dee0f 100644 --- a/handsontable/handsontable-tests.ts +++ b/handsontable/handsontable-tests.ts @@ -14,14 +14,17 @@ function test_HandsontableInit() { autoRowSize: true, autoWrapCol: true, autoWrapRow: true, + bindRowsWithHeaders: 'foo', cell: [], cells: function() {}, checkedTemplate: true, className: [], colHeaders: true, + collapsibleColumns: true, columnHeaderHeight: 123, columns: [], columnSorting: {}, + columnSummary: {}, colWidths: 123, commentedCellClassName: 'foo', comments: [], @@ -41,15 +44,24 @@ function test_HandsontableInit() { debug: true, defaultDate: 'foo', disableVisualSelection: true, + dropdownMenu: [], editor: true, enterBeginsEditing: true, enterMoves: {}, fillHandle: true, + filter: true, + filteringCaseSensitive: true, + filters: false, fixedColumnsLeft: 123, + fixedRowsBottom: 123, fixedRowsTop: 123, format: 'foo', fragmentSelection: true, + ganttChart: {}, + headerTooltips: true, height: 123, + hiddenColumns: true, + hiddenRows: {}, invalidCellClassName: 'foo', label: {}, language: 'foo', @@ -66,6 +78,7 @@ function test_HandsontableInit() { minSpareCols: 123, minSpareRows: 123, multiSelect: true, + nestedHeaders: [], noWordWrapClassName: 'foo', observeChanges: true, observeDOMVisibility: true, @@ -85,6 +98,7 @@ function test_HandsontableInit() { search: true, selectOptions: [], skipColumnOnPaste: true, + sortByRelevance: true, sortFunction: function() {}, sortIndicator: true, source: [], diff --git a/handsontable/handsontable.d.ts b/handsontable/handsontable.d.ts index 1af41e0125..9c7f87aaa3 100644 --- a/handsontable/handsontable.d.ts +++ b/handsontable/handsontable.d.ts @@ -16,14 +16,17 @@ declare namespace ht { autoRowSize?: Object|boolean; autoWrapCol?: boolean; autoWrapRow?: boolean; + bindRowsWithHeaders?: boolean|string; cell?: any[]; cells?: Function; checkedTemplate?: boolean|string; className?: string|any[]; colHeaders?: boolean|any[]|Function; + collapsibleColumns?: boolean|any[]; columnHeaderHeight?: number|any[]; columns?: any[]; columnSorting?: boolean|Object; + columnSummary?: Object; colWidths?: any[]|Function|number|string; commentedCellClassName?: string; comments?: boolean|any[]; @@ -43,15 +46,24 @@ declare namespace ht { debug?: boolean; defaultDate?: string; disableVisualSelection?: boolean|string|any[]; + dropdownMenu?: boolean|Object|any[]; editor?: string|Function|boolean; enterBeginsEditing?: boolean; enterMoves?: Object|Function; fillHandle?: boolean|string|Object; + filter?: boolean; + filteringCaseSensitive?: boolean; + filters?: boolean; fixedColumnsLeft?: number; + fixedRowsBottom?: number; fixedRowsTop?: number; format?: string; fragmentSelection?: boolean|string; + ganttChart?: Object; + headerTooltips?: boolean|Object; height?: number|Function; + hiddenColumns?: boolean|Object; + hiddenRows?: boolean|Object; invalidCellClassName?: string; label?: Object; language?: string; @@ -68,6 +80,7 @@ declare namespace ht { minSpareCols?: number; minSpareRows?: number; multiSelect?: boolean; + nestedHeaders?: any[]; noWordWrapClassName?: string; observeChanges?: boolean; observeDOMVisibility?: boolean; @@ -87,6 +100,7 @@ declare namespace ht { search?: boolean; selectOptions?: any[]; skipColumnOnPaste?: boolean; + sortByRelevance?: boolean; sortFunction?: Function; sortIndicator?: boolean; source?: any[]|Function; From 91d28b86d71068abe2e8cb223fcc8151e3683b31 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 25 Apr 2016 18:02:56 +0200 Subject: [PATCH 26/67] fixed-data-table: Added missing 'extends React.Props' to ColumnGroupProps (#9092) --- fixed-data-table/fixed-data-table.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixed-data-table/fixed-data-table.d.ts b/fixed-data-table/fixed-data-table.d.ts index e4bc79ff51..dcc188e5ba 100644 --- a/fixed-data-table/fixed-data-table.d.ts +++ b/fixed-data-table/fixed-data-table.d.ts @@ -398,7 +398,7 @@ declare namespace FixedDataTable { /** * Component that defines the attributes of a table column group. */ - export interface ColumnGroupProps { + export interface ColumnGroupProps extends __React.Props { /** * The horizontal alignment of the table cell content. * 'left', 'center', 'right' From 310c247694d7f31bd2e3198f71c55221f7c3a3c7 Mon Sep 17 00:00:00 2001 From: Howard Yeh Date: Mon, 25 Apr 2016 09:03:05 -0700 Subject: [PATCH 27/67] React native animated (#9057) * Type Animated.Value * react-native Animated.spring * react-native AnimatedValueXY type * react-native Animated.parallel * react-native Animated.event * react-native Animated components * react-native tweak Animated types * react-native add Animated.timing * react-native rewrite animation config as interface * react-native remove semi-colons * react-native refine the type AnimatedValue * react-native refine the type AnimatedValue * react-native animated no implicit any * react-native animated API tests * react-native more Animated API type coverage * react-native add Animated.Base as alias of commone base type * react-native fix typedef bug --- react-native/react-native-animated-tests.tsx | 95 ++++++ react-native/react-native.d.ts | 298 +++++++++++++++++++ 2 files changed, 393 insertions(+) create mode 100644 react-native/react-native-animated-tests.tsx diff --git a/react-native/react-native-animated-tests.tsx b/react-native/react-native-animated-tests.tsx new file mode 100644 index 0000000000..6fafd9f32f --- /dev/null +++ b/react-native/react-native-animated-tests.tsx @@ -0,0 +1,95 @@ +/// + +import * as React from 'react-native' + +import { + Animated, + View, +} from 'react-native'; + +function TestAnimatedAPI() { + // Value + const v1 = new Animated.Value(0); + const v2 = new Animated.Value(0); + + v1.setValue(0.1); + + v1.addListener(e => { + let n: number = e.value; + }); + + const v200 = v1.interpolate({ + inputRange: [0, 1], + outputRange: [0, 200], + }); + + // ValueXY + const position = new Animated.ValueXY({ x: 0, y: 0 }); + + // Animation functions + const spring1 = Animated.spring(v1, { + toValue: 0.5, + tension: 10, + }); + + const springXY = Animated.spring(position, { + toValue: { + x: 1, + y: 2, + } + }); + + spring1.start(); + spring1.stop(); + + Animated.parallel([ + Animated.spring(v1, { toValue: 1 }), + Animated.spring(v2, { toValue: 1 }), + ], { + stopTogether: true, + }); + + Animated.decay(v1, { + velocity: 2, + }); + + Animated.timing(v1, { + toValue: 1, + duration: 100, + delay: 100, + easing: v => v, + }); + + Animated.add(v1, v2); + Animated.multiply(v1, v2); + Animated.modulo(v1, 2); + + Animated.delay(100); + + Animated.sequence([ + spring1, + springXY, + ]); + + Animated.stagger(100, [ + spring1, + springXY, + ]); + + return ( + + + + + + + + ); +} \ No newline at end of file diff --git a/react-native/react-native.d.ts b/react-native/react-native.d.ts index 824fad6f77..8b2ab35f82 100644 --- a/react-native/react-native.d.ts +++ b/react-native/react-native.d.ts @@ -3453,6 +3453,304 @@ declare module "react-native" { vibrate(): void } + export module Animated { + // Most (all?) functions where AnimatedValue is used any subclass of Animated can be used as well. + type AnimatedValue = Animated; + type AnimatedValueXY = ValueXY; + + type Base = Animated; + + class Animated { + // Internal class, no public API. + } + + class AnimatedWithChildren extends Animated { + // Internal class, no public API. + } + + class AnimatedInterpolation extends AnimatedWithChildren { + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + type ExtrapolateType = 'extend' | 'identity' | 'clamp'; + + type InterpolationConfigType = { + inputRange: number[]; + outputRange: (number[] | string[]); + easing?: ((input: number) => number); + extrapolate?: ExtrapolateType; + extrapolateLeft?: ExtrapolateType; + extrapolateRight?: ExtrapolateType; + }; + + type ValueListenerCallback = (state: {value: number}) => void; + + /** + * Standard value for driving animations. One `Animated.Value` can drive + * multiple properties in a synchronized fashion, but can only be driven by one + * mechanism at a time. Using a new mechanism (e.g. starting a new animation, + * or calling `setValue`) will stop any previous ones. + */ + export class Value extends AnimatedWithChildren { + constructor(value: number); + + setValue(value: number): void; + + /** + * Sets an offset that is applied on top of whatever value is set, whether via + * `setValue`, an animation, or `Animated.event`. Useful for compensating + * things like the start of a pan gesture. + */ + setOffset(offset: number): void; + + /** + * Merges the offset value into the base value and resets the offset to zero. + * The final output of the value is unchanged. + */ + flattenOffset(): void; + + /** + * Adds an asynchronous listener to the value so you can observe updates from + * animations. This is useful because there is no way to + * synchronously read the value because it might be driven natively. + */ + addListener(callback: ValueListenerCallback): string; + + removeListener(id: string): void; + + removeAllListeners(): void; + + /** + * Stops any running animation or tracking. `callback` is invoked with the + * final value after stopping the animation, which is useful for updating + * state to match the animation position with layout. + */ + stopAnimation(callback?: (value: number) => void): void; + + /** + * Interpolates the value before updating the property, e.g. mapping 0-1 to + * 0-10. + */ + interpolate(config: InterpolationConfigType): AnimatedInterpolation; + } + + type ValueXYListenerCallback = (value: {x: number; y: number}) => void; + + /** + * 2D Value for driving 2D animations, such as pan gestures. Almost identical + * API to normal `Animated.Value`, but multiplexed. Contains two regular + * `Animated.Value`s under the hood. + */ + export class ValueXY extends AnimatedWithChildren { + x: AnimatedValue; + y: AnimatedValue; + + constructor(valueIn?: {x: number | AnimatedValue; y: number | AnimatedValue}); + + setValue(value: {x: number; y: number}): void; + + setOffset(offset: {x: number; y: number}): void; + + flattenOffset(): void + + stopAnimation(callback?: () => number): void; + + addListener(callback: ValueXYListenerCallback): string; + + removeListener(id: string): void; + + /** + * Converts `{x, y}` into `{left, top}` for use in style, e.g. + * + *```javascript + * style={this.state.anim.getLayout()} + *``` + */ + getLayout(): { left: AnimatedValue, top: AnimatedValue }; + + /** + * Converts `{x, y}` into a useable translation transform, e.g. + * + *```javascript + * style={{ + * transform: this.state.anim.getTranslateTransform() + * }} + *``` + */ + getTranslateTransform(): {[key: string]: AnimatedValue}[]; + + } + + type EndResult = {finished: boolean}; + type EndCallback = (result: EndResult) => void; + + interface CompositeAnimation { + start: (callback?: EndCallback) => void; + stop: () => void; + } + + interface AnimationConfig { + isInteraction?: boolean; + useNativeDriver?: boolean; + } + + /** + * Animates a value from an initial velocity to zero based on a decay + * coefficient. + */ + export function decay( + value: AnimatedValue | AnimatedValueXY, + config: DecayAnimationConfig + ): CompositeAnimation; + + interface DecayAnimationConfig extends AnimationConfig { + velocity: number | {x: number, y: number}; + deceleration?: number; + } + + /** + * Animates a value along a timed easing curve. The `Easing` module has tons + * of pre-defined curves, or you can use your own function. + */ + export var timing: ( + value: AnimatedValue | AnimatedValueXY, + config: TimingAnimationConfig + ) => CompositeAnimation; + + interface TimingAnimationConfig extends AnimationConfig { + toValue: number | AnimatedValue | {x: number, y: number} | AnimatedValueXY; + easing?: (value: number) => number; + duration?: number; + delay?: number; + } + + interface SpringAnimationConfig extends AnimationConfig { + toValue: number | AnimatedValue | {x: number, y: number} | AnimatedValueXY; + overshootClamping?: boolean; + restDisplacementThreshold?: number; + restSpeedThreshold?: number; + velocity?: number | {x: number, y: number}; + bounciness?: number; + speed?: number; + tension?: number; + friction?: number; + } + + /** + * Creates a new Animated value composed from two Animated values added + * together. + */ + export function add( + a: Animated, + b: Animated + ): AnimatedAddition; + + class AnimatedAddition extends AnimatedInterpolation {} + + /** + * Creates a new Animated value composed from two Animated values multiplied + * together. + */ + export function multiply( + a: Animated, + b: Animated + ): AnimatedMultiplication; + + class AnimatedMultiplication extends AnimatedInterpolation {} + + /** + * Creates a new Animated value that is the (non-negative) modulo of the + * provided Animated value + */ + export function modulo( + a: Animated, + modulus: number + ): AnimatedModulo; + + class AnimatedModulo extends AnimatedInterpolation {} + + /** + * Starts an animation after the given delay. + */ + export function delay(time: number): CompositeAnimation; + + /** + * Starts an array of animations in order, waiting for each to complete + * before starting the next. If the current running animation is stopped, no + * following animations will be started. + */ + export function sequence( + animations: Array + ): CompositeAnimation; + + /** + * Array of animations may run in parallel (overlap), but are started in + * sequence with successive delays. Nice for doing trailing effects. + */ + + export function stagger( + time: number, + animations: Array + ): CompositeAnimation + + /** + * Spring animation based on Rebound and Origami. Tracks velocity state to + * create fluid motions as the `toValue` updates, and can be chained together. + */ + export var spring: ( + value: AnimatedValue | AnimatedValueXY, + config: SpringAnimationConfig + ) => CompositeAnimation; + + type ParallelConfig = { + stopTogether?: boolean; // If one is stopped, stop all. default: true + } + + /** + * Starts an array of animations all at the same time. By default, if one + * of the animations is stopped, they will all be stopped. You can override + * this with the `stopTogether` flag. + */ + var parallel: ( + animations: Array, + config?: ParallelConfig + ) => CompositeAnimation; + + type Mapping = {[key: string]: Mapping} | AnimatedValue; + interface EventConfig { + listener?: Function + } + + /** + * Takes an array of mappings and extracts values from each arg accordingly, + * then calls `setValue` on the mapped outputs. e.g. + * + *```javascript + * onScroll={Animated.event( + * [{nativeEvent: {contentOffset: {x: this._scrollX}}}] + * {listener}, // Optional async listener + * ) + * ... + * onPanResponderMove: Animated.event([ + * null, // raw event arg ignored + * {dx: this._panX}, // gestureState arg + * ]), + *``` + */ + var event: ( + argMapping: Mapping[], + config?: EventConfig + ) => (...args: any[]) => void; + + /** + * Animated variants of the basic native views. Accepts Animated.Value for + * props and style. + */ + export var View: any; + export var Image: any; + export var Text: any; + } + ////////////////////////////////////////////////////////////////////////// // // R E - E X P O R T S From 768a3952704566c0665550700bcb131eee7b91a1 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 26 Apr 2016 19:11:47 -0500 Subject: [PATCH 28/67] When only a single column is returned, it is of type Column, not SortColumn (#8659) --- slickgrid/SlickGrid.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/slickgrid/SlickGrid.d.ts b/slickgrid/SlickGrid.d.ts index 9dbdd0e75c..96f91eaaf1 100644 --- a/slickgrid/SlickGrid.d.ts +++ b/slickgrid/SlickGrid.d.ts @@ -1395,9 +1395,13 @@ declare namespace Slick { export interface OnSortEventArgs extends GridEventArgs { multiColumnSort: boolean; - sortCol?: SortColumn; - sortCols?: SortColumn[]; + + // Single column returned + sortCol?: Column; sortAsc: boolean; + + // Multiple columns returned + sortCols?: SortColumn[]; } export interface OnScrollEventArgs extends GridEventArgs { From 08ed4e9f1869e37e29514d862e0158b40e550232 Mon Sep 17 00:00:00 2001 From: Nicholas Lydon Date: Wed, 27 Apr 2016 04:56:38 +0100 Subject: [PATCH 29/67] React TestUtils SyntheticEventData extends browser Event (#9000) * SyntheticEventData extends browser Event From https://facebook.github.io/react/docs/events.html Your event handlers will be passed instances of SyntheticEvent, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including stopPropagation() and preventDefault(), except the events work identically across all browsers. * make react synthetic event properties optional --- react/react-addons-test-utils.d.ts | 20 +++++++++++++++++--- react/react-global-tests.ts | 3 ++- react/react-tests.ts | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/react/react-addons-test-utils.d.ts b/react/react-addons-test-utils.d.ts index 8bf50366e9..9807300ff4 100644 --- a/react/react-addons-test-utils.d.ts +++ b/react/react-addons-test-utils.d.ts @@ -6,7 +6,22 @@ /// declare namespace __React { - interface SyntheticEventData { + interface OptionalEventProperties { + bubbles?: boolean; + cancelable?: boolean; + currentTarget?: EventTarget; + defaultPrevented?: boolean; + eventPhase?: number; + isTrusted?: boolean; + nativeEvent?: Event; + preventDefault?(): void; + stopPropagation?(): void; + target?: EventTarget; + timeStamp?: Date; + type?: string; + } + + interface SyntheticEventData extends OptionalEventProperties { altKey?: boolean; button?: number; buttons?: number; @@ -41,8 +56,7 @@ declare namespace __React { } interface EventSimulator { - (element: Element, eventData?: SyntheticEventData): void; - (component: Component, eventData?: SyntheticEventData): void; + (element: Element | Component, eventData?: SyntheticEventData): void; } interface MockedComponentClass { diff --git a/react/react-global-tests.ts b/react/react-global-tests.ts index 3aaf4b2c1f..1ed7f8484e 100644 --- a/react/react-global-tests.ts +++ b/react/react-global-tests.ts @@ -418,9 +418,10 @@ React.createClass({ // TestUtils addon // -------------------------------------------------------------------------- var node: Element; + React.addons.TestUtils.Simulate.click(node); React.addons.TestUtils.Simulate.change(node); -React.addons.TestUtils.Simulate.keyDown(node, { key: "Enter" }); +React.addons.TestUtils.Simulate.keyDown(node, { key: "Enter", cancelable: false }); var renderer: React.ShallowRenderer = React.addons.TestUtils.createRenderer(); diff --git a/react/react-tests.ts b/react/react-tests.ts index dc0a409dcf..5976fb23bd 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -553,7 +553,7 @@ var node: Element = TestUtils.renderIntoDocument(React.DOM.div()); TestUtils.Simulate.click(node); TestUtils.Simulate.change(node); -TestUtils.Simulate.keyDown(node, { key: "Enter" }); +TestUtils.Simulate.keyDown(node, { key: "Enter", cancelable: false }); var renderer: React.ShallowRenderer = TestUtils.createRenderer(); From 864787b1648711682c97db5b003f07b79cd6d32b Mon Sep 17 00:00:00 2001 From: Matt Brooks Date: Thu, 28 Apr 2016 17:28:40 +0100 Subject: [PATCH 30/67] Add support for `ko.tasks` API in Knockout.js v3.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for Knockout’s microtask queue. Knockout’s microtask queue supports scheduling tasks to run as soon as possible while still being asynchronous, striving to schedule them to occur before yielding for I/O, reflow, or redrawing. --- knockout/knockout.d.ts | 23 ++++++++++++++++++++--- knockout/tests/knockout-tests.ts | 29 +++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 962a776333..6e53ac2e25 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Knockout v3.2.0 +// Type definitions for Knockout v3.4.0 // Project: http://knockoutjs.com -// Definitions by: Boris Yankov , Igor Oleinikov , Clément Bourgeois +// Definitions by: Boris Yankov , Igor Oleinikov , Clément Bourgeois , Matt Brooks // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -387,6 +387,17 @@ interface KnockoutTemplateEngine extends KnockoutNativeTemplateEngine { rewriteTemplate(template: any, rewriterCallback: Function, templateDocument: Document): void; } +////////////////////////////////// +// tasks.js +////////////////////////////////// + +interface KnockoutTasks { + scheduler: (callback: Function) => any; + schedule(task: Function): number; + cancel(handle: number): void; + runEarly(): void; +} + ///////////////////////////////// interface KnockoutStatic { @@ -544,7 +555,13 @@ interface KnockoutStatic { deferUpdates: boolean, useOnlyNativeEvents: boolean - } + }; + + ///////////////////////////////// + // tasks.js + ///////////////////////////////// + + tasks: KnockoutTasks; } interface KnockoutBindingProvider { diff --git a/knockout/tests/knockout-tests.ts b/knockout/tests/knockout-tests.ts index e9334a7534..8da6c12950 100644 --- a/knockout/tests/knockout-tests.ts +++ b/knockout/tests/knockout-tests.ts @@ -570,8 +570,8 @@ function test_misc() { $(element).datepicker("destroy"); }); - this.observableFactory = function(): KnockoutObservable{ - if (true) { + this.observableFactory = function(flag = true): KnockoutObservable{ + if (flag) { return ko.computed({ read:function(){ return 3; @@ -655,3 +655,28 @@ function testUnwrapUnion() { var num = ko.unwrap(possibleObs); } + +function test_tasks() { + // Schedule an empty task + ko.tasks.schedule(function() { + }); + + // Schedule a task with arguments and return type + let logSomethingTask = (message: string) => { + console.log("Log message"); + return true; + }; + + let taskHandle = ko.tasks.schedule(logSomethingTask); + + // Cancel a task + ko.tasks.cancel(taskHandle); + + // Process the current microtask queue on demand + ko.tasks.runEarly(); + + // Redefine or augment how Knockout schedules the event to process and flush the queue + ko.tasks.scheduler = function (callback) { + setTimeout(callback, 0); + }; +} From 0c33358b1e58d84653e81e7605a951285b1a2c72 Mon Sep 17 00:00:00 2001 From: Derrick Liu Date: Sun, 1 May 2016 04:55:08 -0800 Subject: [PATCH 31/67] react-select: Export the Option interface (#9110) * Add an export for Option so we can use it directly * Update tests to import the newly exported Option --- react-select/react-select-tests.tsx | 8 ++++---- react-select/react-select.d.ts | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/react-select/react-select-tests.tsx b/react-select/react-select-tests.tsx index 8e573e1444..8e4571f472 100644 --- a/react-select/react-select-tests.tsx +++ b/react-select/react-select-tests.tsx @@ -5,16 +5,16 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; -import Select from "react-select"; +import Select, { Option } from "react-select"; class SelectTest extends React.Component, {}> { render() { - const options: ReactSelect.Option[] = [{ label: "Foo", value: "bar" }]; + const options: Option[] = [{ label: "Foo", value: "bar" }]; const onChange = (value: any) => console.log(value); const onOpen = () => { return; }; const onClose = () => { return; }; - const optionRenderer = (option: ReactSelect.Option) => {option.label} + const optionRenderer = (option: Option) => {option.label} return

tag + * when your property is invalid + */ decorateInputElement?: boolean; + /** + * If defined, the CSS class assigned to both and validation message elements + */ errorClass?: string; + /** + * The CSS class assigned to validation error elements, must have decorateInputElement set to true + */ errorElementClass?: string; + /** + * The CSS class assigned to validation error messages + */ errorMessageClass?: string; + /** + * Shows tooltips using input 'title' attribute. False hides them + */ + errorsAsTitle?: boolean; + /** + * Shows the error when hovering the input field (decorateElement must be true) + */ + errorsAsTitleOnModified?: boolean; grouping?: KnockoutValidationGroupingOptions; + /** + * If true validation will insert either a element or the template + * specified by messageTemplate after any element (e.g. ) + * that uses a KO value binding with a validated field + */ + insertMessages?: boolean; + /** + * Indicates whether validation messages are triggered only + * when properties are modified or at all times + */ + messagesOnModified?: boolean; + /** + * The id of the + * that you want to use for all your validation messages + */ + messageTemplate?: string; + /** + * Indicates whether to assign validation rules to your ViewModel + * using HTML5 validation attributes + */ + parseInputAttributes?: boolean; + /** + * Register custom validation rules defined via ko.validation.rules + */ + registerExtenders?: boolean; + validate?: KnockoutValidationValidateOptions; + /** + * Add HTML5 input validation attributes to form elements + * that ko observable's are bound to + */ + writeInputAttributes?: boolean; } interface KnockoutValidationUtils { @@ -154,7 +227,7 @@ interface KnockoutSubscribableFunctions { } declare module "knockout.validation" { - export = validation; + export = validation; } -declare var validation: KnockoutValidationStatic +declare var validation: KnockoutValidationStatic From 3a0f632200048227e6544bc8891f06bfbcc4ef1b Mon Sep 17 00:00:00 2001 From: AmirSaber Sharifi Date: Sun, 1 May 2016 11:44:30 -0400 Subject: [PATCH 51/67] fix bluebird refrence and add dropForeign function (#9105) --- knex/knex.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 52740662c8..5aa1a46d18 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -3,11 +3,11 @@ // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// +/// /// declare module "knex" { - // import Promise = require("bluebird"); + import Promise = require("bluebird"); import * as events from "events"; type Callback = Function; @@ -299,8 +299,8 @@ declare module "knex" { // Schema builder // - interface SchemaBuilder { - createTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): Promise; + interface SchemaBuilder extends Promise { + createTable(tableName: string, callback: (tableBuilder: CreateTableBuilder) => any): SchemaBuilder; renameTable(oldTableName: string, newTableName: string): Promise; dropTable(tableName: string): Promise; hasTable(tableName: string): Promise; @@ -339,6 +339,7 @@ declare module "knex" { unique(columnNames: string[], indexName?: string) : TableBuilder; foreign(column: string): ForeignConstraintBuilder; foreign(columns: string[]): MultikeyForeignConstraintBuilder; + dropForeign(columnNames: string[], foreignKeyName?: string): TableBuilder; } interface CreateTableBuilder extends TableBuilder { From 7b7b8af73b5c268392d0c06096fc67ca83ae7766 Mon Sep 17 00:00:00 2001 From: Valentin Robert Date: Sun, 1 May 2016 08:44:42 -0700 Subject: [PATCH 52/67] added onComplete to W2UI.W2Event (#9148) --- w2ui/w2ui.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/w2ui/w2ui.d.ts b/w2ui/w2ui.d.ts index d75777b8f0..f30c9f77b0 100644 --- a/w2ui/w2ui.d.ts +++ b/w2ui/w2ui.d.ts @@ -21,6 +21,7 @@ declare var w2ui: W2UI.W2UI declare namespace W2UI { interface W2Event { + onComplete: () => void; target: string; } From 3063f61d0e2177d804ef0157309e10c35bd99e4c Mon Sep 17 00:00:00 2001 From: Sam Verschueren Date: Sun, 1 May 2016 17:52:48 +0200 Subject: [PATCH 53/67] Add array-find-index (#9151) --- array-find-index/array-find-index-tests.ts | 10 ++++++++++ array-find-index/array-find-index.d.ts | 13 +++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 array-find-index/array-find-index-tests.ts create mode 100644 array-find-index/array-find-index.d.ts diff --git a/array-find-index/array-find-index-tests.ts b/array-find-index/array-find-index-tests.ts new file mode 100644 index 0000000000..8c69a531e2 --- /dev/null +++ b/array-find-index/array-find-index-tests.ts @@ -0,0 +1,10 @@ +/// + +import * as arrayFindIndex from 'array-find-index'; + +arrayFindIndex(['rainbow', 'unicorn', 'pony'], x => x === 'unicorn'); + +const ctx = {foo: 'rainbow'}; +arrayFindIndex(['rainbow', 'unicorn', 'pony'], function (x) { + return x === this.foo; +}, ctx); diff --git a/array-find-index/array-find-index.d.ts b/array-find-index/array-find-index.d.ts new file mode 100644 index 0000000000..650cac2a16 --- /dev/null +++ b/array-find-index/array-find-index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for array-find-index +// Project: https://github.com/sindresorhus/array-find-index +// Definitions by: Sam Verschueren +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "array-find-index" { + type Predicate = (element: any, index: number, array: any[]) => boolean; + + function arrayFindIndex(arr: any[], predicate: Predicate): number; + function arrayFindIndex(arr: any[], predicate: Predicate, ctx: any): number; + namespace arrayFindIndex {} + export = arrayFindIndex; +} From 28cd028ab871a770027b35e0e14bd8c7005eca21 Mon Sep 17 00:00:00 2001 From: kwiateusz Date: Sun, 1 May 2016 17:53:03 +0200 Subject: [PATCH 54/67] Ionic update (#9152) * update of ionic typings * ionic test update * update according suggestion of optional param --- ionic/ionic-tests.ts | 2 ++ ionic/ionic.d.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/ionic/ionic-tests.ts b/ionic/ionic-tests.ts index 1790e542f1..d8c98ae25f 100644 --- a/ionic/ionic-tests.ts +++ b/ionic/ionic-tests.ts @@ -9,6 +9,8 @@ testIonic.config(['$ionicConfigProvider', ($ionicConfigProvider: ionic.utility.I $ionicConfigProvider.views.maxCache(10); var forwardCache: boolean = $ionicConfigProvider.views.forwardCache(); $ionicConfigProvider.views.forwardCache(true); + var swipeBackEnabled: boolean = $ionicConfigProvider.views.swipeBackEnabled(); + $ionicConfigProvider.views.swipeBackEnabled(true); var jsScrolling: boolean = $ionicConfigProvider.scrolling.jsScrolling(); $ionicConfigProvider.scrolling.jsScrolling(true); diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts index e2cbc195b7..fae9cdbf63 100644 --- a/ionic/ionic.d.ts +++ b/ionic/ionic.d.ts @@ -358,6 +358,7 @@ declare namespace ionic { transition(transition?: string): string; maxCache(maxNumber?: number): number; forwardCache(value?: boolean): boolean; + swipeBackEnabled(value?: boolean): boolean; }; scrolling: { jsScrolling(value?: boolean): boolean; From 8d4f60d532f8b6523db29eb78a7fac0a828e4ee3 Mon Sep 17 00:00:00 2001 From: cedric lombardot Date: Sun, 1 May 2016 17:53:22 +0200 Subject: [PATCH 55/67] [Async] Update filter signature (#9123) Filter signature do not correspond to documentation https://github.com/caolan/async#filter --- async/async.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/async/async.d.ts b/async/async.d.ts index 066685e3c7..5add0db63c 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -85,15 +85,15 @@ interface Async { map(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): any; mapSeries(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): any; mapLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): any; - filter(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; - select(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; - filterSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; - selectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; - filterLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; - selectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; - reject(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; - rejectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; - rejectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any; + filter(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; + select(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; + filterSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; + selectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; + filterLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; + selectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; + reject(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; + rejectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; + rejectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): any; reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any; inject(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any; foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any; From 649cae32796337785199168f93cb6b7ece5c0802 Mon Sep 17 00:00:00 2001 From: cedric lombardot Date: Sun, 1 May 2016 17:53:44 +0200 Subject: [PATCH 56/67] [Async] Detect signatures callback (#9116) Fix signatures of detect callbacks to follow doc https://github.com/caolan/async#detect --- async/async.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/async/async.d.ts b/async/async.d.ts index 5add0db63c..c3d218fabc 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -15,7 +15,7 @@ interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncForEachOfIterator { (item: T, key: number, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; } -interface AsyncBooleanIterator { (item: T, callback: (truthValue: boolean) => void): void; } +interface AsyncBooleanIterator { (item: T, callback: (err: string, truthValue: boolean) => void): void; } interface AsyncWorker { (task: T, callback: ErrorCallback): void; } interface AsyncVoidFunction { (callback: ErrorCallback): void; } @@ -99,9 +99,9 @@ interface Async { foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any; reduceRight(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any; foldr(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any; - detect(arr: T[], iterator: AsyncBooleanIterator, callback?: (result: T) => void): any; - detectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (result: T) => void): any; - detectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (result: T) => void): any; + detect(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): any; + detectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): any; + detectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): any; sortBy(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): any; some(arr: T[], iterator: AsyncBooleanIterator, callback?: (result: boolean) => void): any; someLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (result: boolean) => void): any; From 152fb904dffd145582da89a0c776822b26ff0e8d Mon Sep 17 00:00:00 2001 From: ascoders Date: Sun, 1 May 2016 23:55:36 +0800 Subject: [PATCH 57/67] update react-router.d.ts (#9066) add basename to MatchArgs --- react-router/react-router.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 07acd52b9e..80d2e4ee6d 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -250,6 +250,7 @@ declare namespace ReactRouter { location?: H.Location | string parseQueryString?: ParseQueryString stringifyQuery?: StringifyQuery + basename?: string } interface MatchState extends RouterState { history: History From 8cc14d55978d9eca2c374adf1c70d5b9c0abef70 Mon Sep 17 00:00:00 2001 From: Yoshiki Shibukawa Date: Mon, 2 May 2016 00:56:57 +0900 Subject: [PATCH 58/67] update Mithril.js definition from 0.1.x to 0.2.4 (#4523) --- mithril/mithril-tests.ts | 2 +- mithril/mithril.d.ts | 879 ++++++++++++++++++++++++++++++++++----- 2 files changed, 783 insertions(+), 98 deletions(-) diff --git a/mithril/mithril-tests.ts b/mithril/mithril-tests.ts index be5832a40d..a7d065f144 100644 --- a/mithril/mithril-tests.ts +++ b/mithril/mithril-tests.ts @@ -52,4 +52,4 @@ var todo = { }; //initialize the application -m.module(document, todo); +m.mount(document, todo); diff --git a/mithril/mithril.d.ts b/mithril/mithril.d.ts index b4e9dd5a54..d1c2ba78a6 100644 --- a/mithril/mithril.d.ts +++ b/mithril/mithril.d.ts @@ -3,175 +3,860 @@ // Definitions by: Leo Horie , Chris Bowdon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -//Mithril type definitions for Typescript +// Mithril type definitions for Typescript -declare module _mithril { - interface MithrilStatic { +/** +* This is the module containing all the types/declarations/etc. for Mithril +*/ +declare namespace Mithril { + interface ChildArray extends Array {} + type Children = Child | ChildArray; + type Child = string | VirtualElement | Component; - (selector: string, attributes: MithrilAttributes, ...children: Array>): MithrilVirtualElement; - (selector: string, ...children: Array>): MithrilVirtualElement; + interface Static { + /** + * Creates a virtual element for use with m.render, m.mount, etc. + * + * @param selector A simple CSS selector. May include SVG tags. Nested + * selectors are not supported. + * @param attributes Attributes to add. Any DOM attribute may be used + * as an attribute, although innerHTML and the like may be overwritten + * silently. + * @param children Child elements, components, and text to add. + * @return A virtual element. + * + * @see m.render + * @see m.mount + * @see m.component + */ + ( + selector: string, + ...children: Children[] + ): VirtualElement; - prop(promise: MithrilPromise) : MithrilPromiseProperty; - prop(value: T): MithrilProperty; - prop(): MithrilProperty; // might be that this should be Property + /** + * Creates a virtual element for use with m.render, m.mount, etc. + * + * @param selector A simple CSS selector. May include SVG tags. Nested + * selectors are not supported. + * @param attributes Attributes to add. Any DOM attribute may be used + * as an attribute, although innerHTML and the like may be overwritten + * silently. + * @param children Child elements, components, and text to add. + * @return A virtual element. + * + * @see m.render + * @see m.mount + * @see m.component + */ + ( + selector: string, + attributes: Attributes, + ...children: Children[] + ): VirtualElement; - withAttr(property: string, callback: (value: any) => void): (e: MithrilEvent) => any; + /** + * Initializes a component for use with m.render, m.mount, etc. + * + * @param component A component. + * @param args Arguments to optionally pass to the component. + * @return A component. + * + * @see m.render + * @see m.mount + * @see m + */ + ( + component: Component, + ...args: any[] + ): Component; - module(rootElement: Node, component: MithrilComponent): T; - module(rootElement: Node): T; - mount(rootElement: Node, component: MithrilComponent): T; - mount(rootElement: Node): T; + /** + * Creates a getter-setter function that wraps a Mithril promise. Useful + * for uniform data access, m.withAttr, etc. + * + * @param promise A thennable to initialize the property with. It may + * optionally be a Mithril promise. + * @return A getter-setter function wrapping the promise. + * + * @see m.withAttr + */ + prop(promise: Thennable) : Promise; - component(component: MithrilComponent, ...args: Array): MithrilComponent - - trust(html: string): string; + /** + * Creates a getter-setter function that wraps a simple value. Useful + * for uniform data access, m.withAttr, etc. + * + * @param value A value to initialize the property with + * @return A getter-setter function wrapping the value. + * + * @see m.withAttr + */ + prop(value: T): BasicProperty; - render(rootElement: Element|HTMLDocument): void; - render(rootElement: Element|HTMLDocument, children: MithrilVirtualElement, forceRecreation?: boolean): void; - render(rootElement: Element|HTMLDocument, children: MithrilVirtualElement[], forceRecreation?: boolean): void; + /** + * Creates a getter-setter function that wraps a simple value. Useful + * for uniform data access, m.withAttr, etc. + * + * @return A getter-setter function wrapping the value. + * + * @see m.withAttr + */ + prop(): BasicProperty; + + /** + * Returns a event handler that can be bound to an element, firing with + * the specified property. + * + * @param property The property to get from the event. + * @param callback The handler to use the value from the event. + * @return A function suitable for listening to an event. + */ + withAttr( + property: string, + callback: (value: any) => any, + callbackThis?: any + ): (e: Event) => void; + + /** + * @deprecated Use m.mount instead + */ + module( + rootElement: Node, + component: Component + ): T; + + /** + * Mounts a component to a base DOM node. + * + * @param rootElement The base node. + * @param component The component to mount. + * @return An instance of the top-level component's controller + */ + mount( + rootElement: Node, + component: Component + ): T; + + /** + * Initializes a component for use with m.render, m.mount, etc. + * + * @param selector A component. + * @param args Arguments to optionally pass to the component. + * @return A component. + * + * @see m.render + * @see m.mount + * @see m + */ + component( + component: Component, + ...args: any[] + ): Component; + + /** + * Trust this string of HTML. + * + * @param html The HTML to trust + * @return A String object instance with an added internal flag to mark + * it as trusted. + */ + trust(html: string): TrustedString; + + /** + * Render a virtual DOM tree. + * + * @param rootElement The base element/node to render the tree from. + * @param children One or more child nodes to add to the tree. + * @param forceRecreation If true, overwrite the entire tree without + * diffing against it. + */ + render( + rootElement: Element, + children: VirtualElement|VirtualElement[], + forceRecreation?: boolean + ): void; redraw: { + /** + * Force a redraw the active component. It redraws asynchronously by + * default to allow for simultaneous events to run before redrawing, + * such as the event combination keypress + input frequently used for + * input. + * + * @param force If true, redraw synchronously. + */ (force?: boolean): void; - strategy: MithrilProperty; + + /** + * Gets/sets the current redraw strategy, which returns one of the + * following: + * + * "all" - recreates the DOM tree from scratch + * "diff" - recreates the DOM tree from scratch + * "none" - leaves the DOM tree intact + * + * This is useful for event handlers, which may want to cancel + * the next redraw if the event doesn't update the UI. + * + * @return The current strategy + */ + strategy: BasicProperty<"all" | "diff" | "none">; } route: { - (rootElement: HTMLDocument, defaultRoute: string, routes: MithrilRoutes): void; - (rootElement: Element, defaultRoute: string, routes: MithrilRoutes): void; + /** + * Enable routing, mounting a controller based on the route. It + * automatically mounts the components for you, starting with the one + * specified by the default route. + * + * @param rootElement The element to mount the active controller to. + * @param defaultRoute The route to start with. + * @param routes A key-value mapping of pathname to controller. + */ + ( + rootElement: Element, + defaultRoute: string, + routes: Routes + ): void; - (element: Element, isInitialized: boolean, context: Object, vdom: Object): void; + /** + * This allows m.route to be used as the `config` attribute for a + * virtual element, particularly useful for cases like this: + * + * ```ts + * // Note that the '#' is not required in `href`, thanks to the + * `config` setting. + * m("a[href='/dashboard/alicesmith']", {config: m.route}); + * ``` + */ + ( + element: Element, + isInitialized: boolean, + context?: Context, + vdom?: VirtualElement + ): void; + + /** + * Programmatically redirect to another route. + * + * @param path The route to go to. + * @param params Parameters to pass as a query string. + * @param shouldReplaceHistory Whether to replace the current history + * instead of adding a new one. + */ (path: string, params?: any, shouldReplaceHistory?: boolean): void; + + /** + * Gets the current route. + * + * @return The current route. + */ (): string; + /** + * Gets a route parameter. + * + * @param key The key to get. + * @return The value associated with the parameter key. + */ param(key: string): string; - mode: string; - buildQueryString(data: Object): String - parseQueryString(data: String): Object + + /** + * The current routing mode. This may be changed before calling + * m.route to change the part of the URL used to perform the routing. + * + * The value can be set to one of the following, defaulting to + * "hash": + * + * "search" - Uses the query string. This allows for named anchors to + * work on the page, but changes cause IE8 and lower to refresh the + * page. + * + * "hash" - Uses the hash. This is the only routing mode that does + * not cause page refreshes on any browser, but it does not support + * named anchors. + * + * "pathname" - Uses the URL pathname. This requires server-side + * setup to support bookmarking and page refreshes. It always causes + * page refreshes on IE8 and lower. Note that this requires that the + * application to be run from the root of the URL. + */ + mode: "search" | "hash" | "pathname"; + + /** + * Serialize an object into a query string. + * + * @param data The data to serialize. + * @return The serialized string. + */ + buildQueryString(data: Object): string; + + /** + * Parse a query string into an object. + * + * @param data The data to parse. + * @return The parsed object data. + */ + parseQueryString(data: string): Object; } - request(options: MithrilXHROptions): MithrilPromise; + /** + * Send an XHR request to a server. Note that the `url` option is + * required. + * + * @param options The options to use for the request. + * @return A promise to the returned data, or void if not applicable. + * + * @see XHROptions for the available options. + */ + request(options: XHROptions): Promise + + /** + * Send a JSONP request to a server. Note that the `url` option is + * required. + * + * @param options The options to use + * @return A promise to the returned data. + * + * @see JSONPOptions for the available options. + */ + request(options: JSONPOptions): Promise; deferred: { + /** + * Create a Mithril deferred object. It behaves synchronously if + * possible, an intentional deviation from Promises/A+. Note that + * deferreds are completely separate from the redrawing system, and + * never trigger a redraw on their own. + * + * @return A new Mithril deferred instance. + * + * @see m.deferred.onerror for the error callback called for Error + * subclasses + */ + (): Deferred; + + /** + * A callback for all uncaught native Error subclasses in deferreds. + * This defaults to synchronously rethrowing all errors, a deviation + * from Promises/A+, but the behavior is configurable. To restore + * Promises/A+-compatible behavior. simply set this to a no-op. + */ onerror(e: Error): void; - (): MithrilDeferred; } - sync(promises: MithrilPromise[]): MithrilPromise; + /** + * Takes a list of promises or thennables and returns a Mithril promise + * that resolves once all in the list are resolved, or rejects if any of + * them reject. + * + * @param promises A list of promises to try to resolve. + * @return A promise that resolves to all the promises if all resolve, or + * rejects with the error contained in the first rejection. + */ + sync(promises: Thennable[]): Promise; + /** + * Use this and endComputation if your views aren't redrawing after + * calls to third-party libraries. For integrating asynchronous code, + * this should be called before any asynchronous work is done. For + * synchronous code, this should be called at the beginning of the + * problematic segment. Note that these calls must be balanced, much like + * braces and parentheses. This is mostly used internally. Prefer + * m.redraw where possible, especially when making repeated calls. + * + * @see endComputation + * @see m.render + */ startComputation(): void; + + /** + * Use startComputation and this if your views aren't redrawing after + * calls to third-party libraries. For integrating asynchronous code, + * this should be called after all asynchronous work completes. For + * synchronous code, this should be called at the end of the problematic + * segment. Note that these calls must be balanced, much like braces and + * parentheses. This is mostly used internally. Prefer m.redraw where + * possible, especially when making repeated calls. + * + * @see startComputation + * @see m.render + */ endComputation(): void; - // For test suite - deps: { - (mockWindow: Window): Window; - factory: Object; - } - + /** + * This overwrites the internal version of window used by Mithril. + * It's mostly useful for testing, and is also used internally by + * Mithril to test itself. By default Mithril uses `window` for the + * dependency. + * + * @param mockWindow The mock to use for the window. + * @return The mock that was passed in. + */ + deps(mockWindow: Window): Window; } - export interface MithrilVirtualElement { - key?: number; - tag?: string; - attrs?: MithrilAttributes; - children?: any[]; + interface TrustedString extends String { + /** @private Implementation detail. Don't depend on it. */ + $trusted: boolean; } - // Configuration function for an element - interface MithrilElementConfig { - (element: Element, isInitialized: boolean, context?: any, vdom?: MithrilVirtualElement): void; + /** + * The interface for a virtual element. It's best to consider this immutable + * for most use cases. + * + * @see m + */ + interface VirtualElement { + /** + * The tag name of this element. + */ + tag: string; + + /** + * The attributes of this element. + */ + attrs: Attributes; + + /** + * The children of this element. + */ + children: Children[]; } - // Attributes on a virtual element - interface MithrilAttributes { - title?: string; + /** + * An event passed by Mithril to unload event handlers. + */ + interface Event { + /** + * Prevent the default behavior of scrolling the page and updating the + * URL on next route change. + */ + preventDefault(): void; + } + + /** + * A context object for configuration functions. + * + * @see ElementConfig + */ + interface Context { + /** + * A function to call when the node is unloaded. Useful for cleanup. + */ + onunload?(): any; + + /** + * Set true if the backing DOM node needs to be retained between route + * changes if possible. Set false if this node needs to be recreated + * every single time, regardless of how "different" it is. + */ + retain?: boolean; + } + + /** + * This represents a callback function for a virtual element's config + * attribute. It's a low-level function useful for extra cleanup after + * removal from the tree, storing instances of third-party classes that + * need to be associated with the DOM, etc. + * + * @see Attributes + * @see Context + */ + interface ElementConfig { + /** + * A callback function for a virtual element's config attribute. + * + * @param element The associated DOM element. + * @param isInitialized Whether this is the first call for the virtual + * element or not. + * @param context The associated context for this element. + * @param vdom The associated virtual element. + */ + ( + element: Element, + isInitialized: boolean, + context: Context, + vdom: VirtualElement + ): void; + } + + /** + * This represents the attributes available for configuring virtual elements, + * beyond the applicable DOM attributes. + * + * @see m + */ + interface Attributes { + /** + * The class name(s) for this virtual element, as a space-separated list. + */ className?: string; + + /** + * The class name(s) for this virtual element, as a space-separated list. + */ class?: string; - config?: MithrilElementConfig; + + /** + * A custom, low-level configuration in case this element needs special + * cleanup after removal from the tree. + * + * @see ElementConfig + */ + config?: ElementConfig; + + /** + * A key to optionally associate with this element. + */ + key?: string | number; + + /** + * Any other virtual element properties, including attributes and event + * handlers. + */ + [property: string]: any; } - // Defines the subset of Event that Mithril needs - interface MithrilEvent { - currentTarget: Element; - } - - interface MithrilController { + /** + * The basis of a Mithril controller instance. + */ + interface Controller { + /** + * An optional handler to call when the associated virtual element is + * destroyed. + * + * @param evt An associated event. + */ onunload?(evt: Event): any; } - interface MithrilControllerFunction extends MithrilController { - (): any; + /** + * This represents a controller function. + * + * @see ControllerConstructor + */ + interface ControllerFunction { + (...args: any[]): T; } - interface MithrilView { - (ctrl: T): string|MithrilVirtualElement; + /** + * This represents a controller constructor. + * + * @see ControllerFunction + */ + interface ControllerConstructor { + new (...args: any[]): T; } - interface MithrilComponent { - controller: MithrilControllerFunction|{ new(): T }; - view: MithrilView; + /** + * This represents a Mithril component. + * + * @see m + * @see m.component + */ + interface Component { + /** + * The component's controller. + * + * @see m.component + */ + controller: ControllerFunction | ControllerConstructor; + + /** + * Creates a view out of virtual elements. + * + * @see m.component + */ + view(ctrl?: T, ...args: any[]): VirtualElement; } - interface MithrilProperty { + /** + * This is the base interface for property getter-setters + * + * @see m.prop + */ + interface Property { + /** + * Gets the contained value. + * + * @return The contained value. + */ (): T; + + /** + * Sets the contained value. + * + * @param value The new value to set. + * @return The newly set value. + */ (value: T): T; + } + + /** + * This represents a non-promise getter-setter functions. + * + * @see m.prop which returns objects that implement this interface. + */ + interface BasicProperty extends Property { + /** + * Makes this serializable to JSON. + */ toJSON(): T; } - interface MithrilPromiseProperty extends MithrilPromise { - (): T; - (value: T): T; - toJSON(): T; + /** + * This represents a key-value mapping linking routes to components. + */ + interface Routes { + /** + * The key represents the route. The value represents the corresponding + * component. + */ + [key: string]: Component; } - interface MithrilRoutes { - [key: string]: MithrilComponent; - } - - - interface MithrilDeferred { + /** + * This represents a Mithril deferred object. + */ + interface Deferred { + /** + * Resolve this deferred's promise with a value. + * + * @param value The value to resolve the promise with. + */ resolve(value?: T): void; - reject(value?: any): void; - promise: MithrilPromise; + + /** + * Reject this deferred with an error. + * + * @param value The reason for rejecting the promise. + */ + reject(reason?: any): void; + + /** + * The backing promise. + * + * @see Promise + */ + promise: Promise; } - interface MithrilSuccessCallback { - (value: T): U; - (value: T): MithrilPromise; + /** + * This represents a thennable success callback. + */ + interface SuccessCallback { + (value: T): U | Thennable; } - interface MithrilErrorCallback { - (value: Error): U; - (value: string): U; + /** + * This represents a thennable error callback. + */ + interface ErrorCallback { + (value: Error): T | Thennable; } - interface MithrilPromise { - (): T; - (value: T): T; - then(success: (value: T) => U): MithrilPromise; - then(success: (value: T) => MithrilPromise): MithrilPromise; - then(success: (value: T) => U, error: (value: Error) => V): MithrilPromise|MithrilPromise; - then(success: (value: T) => MithrilPromise, error: (value: Error) => V): MithrilPromise|MithrilPromise; + /** + * This represents a thennable. + */ + interface Thennable { + then(success: SuccessCallback): Thennable; + then(success: SuccessCallback, error: ErrorCallback): Thennable; + catch?(error: ErrorCallback): Thennable; + catch?(error: ErrorCallback): Thennable; } - interface MithrilXHROptions { - method?: string; - url: string; - user?: string; - password?: string; + + /** + * This represents a Mithril promise object. + */ + interface Promise extends Thennable, Property> { + /** + * Chain this promise with a simple success callback, propogating + * rejections. + * + * @param success The callback to call when the promise is resolved. + * @return The chained promise. + */ + then(success: SuccessCallback): Promise; + + /** + * Chain this promise with a success callback and error callback, without + * propogating rejections. + * + * @param success The callback to call when the promise is resolved. + * @param error The callback to call when the promise is rejected. + * @return The chained promise. + */ + then(success: SuccessCallback, error: ErrorCallback): Promise; + + /** + * Chain this promise with a single error callback, without propogating + * rejections. + * + * @param error The callback to call when the promise is rejected. + * @return The chained promise. + */ + catch(error: ErrorCallback): Promise; + } + + /** + * These are the common options shared across normal and JSONP requests. + * + * @see m.request + */ + interface RequestOptions { + /** + * The data to be sent. It's automatically serialized in the right format + * depending on the method (with exception of HTML5 FormData), and put in + * the appropriate section of the request. + */ data?: any; + + /** + * Whether to run it in the background, i.e. true if it doesn't affect + * template rendering. + */ background?: boolean; + + /** + * Set an initial value while the request is working, to populate the + * promise getter-setter. + */ + initialValue?: any; + + /** + * An optional preprocessor function to unwrap a successful response, in + * case the response contains metadata wrapping the data. + * + * @param data The data to unwrap. + * @return The unwrapped result. + */ unwrapSuccess?(data: any): any; + + /** + * An optional preprocessor function to unwrap an unsuccessful response, + * in case the response contains metadata wrapping the data. + * + * @param data The data to unwrap. + * @return The unwrapped result. + */ unwrapError?(data: any): any; + + /** + * An optional function to serialize the data. This defaults to + * `JSON.stringify`. + * + * @param dataToSerialize The data to serialize. + * @return The serialized form as a string. + */ serialize?(dataToSerialize: any): string; + + /** + * An optional function to deserialize the data. This defaults to + * `JSON.parse`. + * + * @param dataToSerialize The data to parse. + * @return The parsed form. + */ deserialize?(dataToDeserialize: string): any; - extract?(xhr: XMLHttpRequest, options: MithrilXHROptions): string; - type?(data: Object): void; - config?(xhr: XMLHttpRequest, options: MithrilXHROptions): XMLHttpRequest; - dataType?: string; + + /** + * An optional function to extract the data from a raw XMLHttpRequest, + * useful if the relevant data is in a response header or the status + * field. + * + * @param xhr The associated XMLHttpRequest. + * @param options The options passed to this request. + * @return string The serialized format. + */ + extract?(xhr: XMLHttpRequest, options: this): string; + + /** + * The parsed data, or its children if it's an array, will be passed to + * this class constructor if it's given, to parse it into classes. + * + * @param data The data to parse. + * @return The new instance for the list. + */ + type?: new (data: any) => any; + + /** + * The URL to send the request to. + */ + url: string; + } + + /** + * This represents the available options for configuring m.request for JSONP + * requests. + * + * @see m.request + */ + interface JSONPOptions extends RequestOptions { + /** + * For JSONP requests, this must be the string "jsonp". Otherwise, it's + * ignored. + */ + dataType: "jsonp"; + + /** + * The querystring key for the JSONP request callback. This is useful for + * APIs that don't use common conventions, such as + * `www.example.com/?jsonpCallback=doSomething`. It defaults to + * `callback`. + */ + callbackKey?: string; + + /** + * The data to send with the request. This is automatically serialized + * to a querystring. + */ + data?: Object; + } + + /** + * This represents the available options for configuring m.request for + * standard AJAX requests. + * + * @see m.request + */ + interface XHROptions extends RequestOptions { + /** + * This represents the HTTP method used, defaulting to "GET". + */ + method: "GET" | "POST" | "PUT" | "DELETE" | "HEAD" | "OPTIONS"; + + /** + * The username for HTTP authentication. + */ + user?: string; + + /** + * The password for HTTP authentication. + */ + password?: string; + + /** + * An optional function to run between `open` and `send`, useful for + * adding request headers or using XHR2 features such as the `upload` + * property. It is even possible to override the XHR altogether with a + * similar object, such as an XDomainRequest instance. + * + * @param xhr The associated XMLHttpRequest. + * @param options The options passed to this request. + * @return The new XMLHttpRequest, or nothing if the same one is kept. + */ + config?(xhr: XMLHttpRequest, options: this): any; + + /** + * The data to send with the request. + */ + data?: Object; } } -declare var Mithril: _mithril.MithrilStatic; -declare var m: _mithril.MithrilStatic; +declare const m: Mithril.Static; declare module "mithril" { export = m; From 15d1bacc2b3f1dffcea83ce95e92d676c8c39132 Mon Sep 17 00:00:00 2001 From: Scott Rippee Date: Sun, 1 May 2016 09:09:35 -0700 Subject: [PATCH 59/67] =?UTF-8?q?Adding=20type=20definition=20for=20slacki?= =?UTF-8?q?fy-html=20(https://github.com/mrq-cz/s=E2=80=A6=20(#9145)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adding type definition for slackify-html (https://github.com/mrq-cz/slackify-html) * Fixed name of test file --- slackify-html/slackify-html-tests.ts | 5 +++++ slackify-html/slackify-html.d.ts | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 slackify-html/slackify-html-tests.ts create mode 100644 slackify-html/slackify-html.d.ts diff --git a/slackify-html/slackify-html-tests.ts b/slackify-html/slackify-html-tests.ts new file mode 100644 index 0000000000..075ccff3b7 --- /dev/null +++ b/slackify-html/slackify-html-tests.ts @@ -0,0 +1,5 @@ +/// + +import slackify = require("slackify-html"); + +var text = slackify('this link is important'); diff --git a/slackify-html/slackify-html.d.ts b/slackify-html/slackify-html.d.ts new file mode 100644 index 0000000000..66c0b917c3 --- /dev/null +++ b/slackify-html/slackify-html.d.ts @@ -0,0 +1,9 @@ +// Type definitions for slackify-html v1.0.1 +// Project: https://github.com/mrq-cz/slackify-html +// Definitions by: Scott Rippee +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "slackify-html" { + function slackify(html : string) : string; + export = slackify; +} From 53c91ff9a7aca751cf75cf940fc3c163e1713b99 Mon Sep 17 00:00:00 2001 From: Roger Chen Date: Sun, 1 May 2016 09:09:52 -0700 Subject: [PATCH 60/67] Add typings for react-split-pane (#9160) --- react-split-pane/react-split-pane-tests.tsx | 24 ++++++++++++ react-split-pane/react-split-pane.d.ts | 41 +++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 react-split-pane/react-split-pane-tests.tsx create mode 100644 react-split-pane/react-split-pane.d.ts diff --git a/react-split-pane/react-split-pane-tests.tsx b/react-split-pane/react-split-pane-tests.tsx new file mode 100644 index 0000000000..7aa6c006e6 --- /dev/null +++ b/react-split-pane/react-split-pane-tests.tsx @@ -0,0 +1,24 @@ +/// +/// + +import * as React from "react"; +import * as SplitPane from "react-split-pane"; + +class SplitPaneTest extends React.Component, {}> { + + render() { + return ( + +
+
+ + ); + } +} diff --git a/react-split-pane/react-split-pane.d.ts b/react-split-pane/react-split-pane.d.ts new file mode 100644 index 0000000000..e3d7f959de --- /dev/null +++ b/react-split-pane/react-split-pane.d.ts @@ -0,0 +1,41 @@ +// Type definitions for react-split-pane v0.1.38 +// Project: https://github.com/tomkp/react-split-pane +// Definitions by: Roger Chen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace ReactSplitPane { + interface ReactSplitPaneProps { + allowResize?: boolean; + className?: string; + /** + * Either a number (in pixels) or string (percentage) + */ + defaultSize?: number | string; + /** + * Either a number (in pixels) or string (percentage) + */ + maxSize?: number | string; + /** + * Either a number (in pixels) or string (percentage) + */ + minSize?: number | string; + onChange?: Function; + onDragFinished?: Function; + onDragStarted?: Function; + primary?: string; + /** + * Either a number (in pixels) or string (percentage) + */ + size?: number | string; + split?: string; + } + + interface ReactSplitPaneClass extends __React.ComponentClass { } +} + +declare module "react-split-pane" { + var split: ReactSplitPane.ReactSplitPaneClass; + export = split; +} From 925bf8b076867d714a75b9e9d86118287e030db2 Mon Sep 17 00:00:00 2001 From: Sergey Rubanov Date: Sun, 1 May 2016 20:16:58 +0400 Subject: [PATCH 61/67] add title property to TabChangeInfo (#9163) --- chrome/chrome.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 9cdf8c3a5d..cdb48b2767 100644 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -6211,6 +6211,11 @@ declare namespace chrome.tabs { * @since Chrome 27. */ faviconUrl?: string; + /** + * The tab's new title. + * @since Chrome 48. + */ + title?: string; } interface TabMoveInfo { From 1b14446e5d6235b529c61e0554efeb9f30cf88c2 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 1 May 2016 18:17:09 +0200 Subject: [PATCH 62/67] Update to Electron 0.37.8 (#9161) * Update to Electron 0.37.8 * Fix exchanged interceptBufferProtocol / interceptStringProtocol + add handler types to avoid duplicates --- github-electron/github-electron-main-tests.ts | 12 ++- github-electron/github-electron.d.ts | 97 +++++++++++++------ 2 files changed, 74 insertions(+), 35 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index 27d6599596..a2c40c1d68 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -19,6 +19,7 @@ import { screen, shell, session, + systemPreferences, hideInternalModules } from 'electron'; @@ -260,8 +261,8 @@ app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1'); app.commandLine.appendSwitch('v', -1); app.commandLine.appendSwitch('vmodule', 'console=0'); -// app -// https://github.com/atom/electron/blob/master/docs/api/app.md +// systemPreferences +// https://github.com/electron/electron/blob/master/docs/api/system-preferences.md var browserOptions = { width: 1000, @@ -271,7 +272,7 @@ var browserOptions = { }; // Make the window transparent only if the platform supports it. -if (process.platform !== 'win32' || app.isAeroGlassEnabled()) { +if (process.platform !== 'win32' || systemPreferences.isAeroGlassEnabled()) { browserOptions.transparent = true; browserOptions.frame = false; } @@ -288,9 +289,12 @@ if (browserOptions.transparent) { } app.on('platform-theme-changed', () => { - console.log(app.isDarkMode()); + console.log(systemPreferences.isDarkMode()); }); +// app +// https://github.com/atom/electron/blob/master/docs/api/app.md + app.on('certificate-error', function(event, webContents, url, error, certificate, callback) { if (url == "https://github.com") { // Verification logic. diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 3d4bd89835..131a0a425a 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -149,11 +149,6 @@ declare namespace Electron { * Emitted when the gpu process crashes. */ on(event: 'gpu-process-crashed', listener: Function): this; - /** - * Emitted when the system’s Dark Mode theme is toggled. - * Note: This is only implemented on OS X. - */ - on(event: 'platform-theme-changed', listener: Function): this; on(event: string, listener: Function): this; /** * Try to close all windows. The before-quit event will first be emitted. @@ -256,10 +251,16 @@ declare namespace Electron { /** * Removes the current executable as the default handler for a protocol (aka URI scheme). * - * Note: This API is only available on Windows. + * Note: This is only implemented on Windows. * On OS X, removing the app will automatically remove the app as the default protocol handler. */ removeAsDefaultProtocolClient(protocol: string): void; + /** + * @returns Whether the current executable is the default handler for a protocol (aka URI scheme). + * + * Note: This is only implemented on OS X and Windows. + */ + isDefaultProtocolClient(protocol: string): boolean; /** * Adds tasks to the Tasks category of JumpList on Windows. * @@ -284,19 +285,6 @@ declare namespace Electron { * Changes the Application User Model ID to id. */ setAppUserModelId(id: string): void; - /** - * This method returns true if DWM composition (Aero Glass) is enabled, - * and false otherwise. You can use it to determine if you should create - * a transparent window or not (transparent windows won’t work correctly when DWM composition is disabled). - * - * Note: This is only implemented on Windows. - */ - isAeroGlassEnabled(): boolean; - /** - * @returns If the system is in Dark Mode. - * Note: This is only implemented on OS X. - */ - isDarkMode(): boolean; /** * Imports the certificate in pkcs12 format into the platform certificate store. * @param callback Called with the result of import operation, a value of 0 indicates success @@ -2268,19 +2256,19 @@ declare namespace Electron { /** * Registers a protocol of scheme that will send the file as a response. */ - registerFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: FileProtocolCallback) => void, completion?: (error: Error) => void): void; + registerFileProtocol(scheme: string, handler: FileProtocolHandler, completion?: (error: Error) => void): void; /** * Registers a protocol of scheme that will send a Buffer as a response. */ - registerBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: BufferProtocolCallback) => void, completion?: (error: Error) => void): void; + registerBufferProtocol(scheme: string, handler: BufferProtocolHandler, completion?: (error: Error) => void): void; /** * Registers a protocol of scheme that will send a String as a response. */ - registerStringProtocol(scheme: string, handler: (request: ProtocolRequest, callback: StringProtocolCallback) => void, completion?: (error: Error) => void): void; + registerStringProtocol(scheme: string, handler: StringProtocolHandler, completion?: (error: Error) => void): void; /** * Registers a protocol of scheme that will send an HTTP request as a response. */ - registerHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: HttpProtocolCallback) => void, completion?: (error: Error) => void): void; + registerHttpProtocol(scheme: string, handler: HttpProtocolHandler, completion?: (error: Error) => void): void; /** * Unregisters the custom protocol of scheme. */ @@ -2292,25 +2280,30 @@ declare namespace Electron { /** * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a file as a response. */ - interceptFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: FileProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a String as a response. - */ - interceptStringProtocol(scheme: string, handler: (request: ProtocolRequest, callback: BufferProtocolCallback) => void, completion?: (error: Error) => void): void; + interceptFileProtocol(scheme: string, handler: FileProtocolHandler, completion?: (error: Error) => void): void; /** * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a Buffer as a response. */ - interceptBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: StringProtocolCallback) => void, completion?: (error: Error) => void): void; + interceptBufferProtocol(scheme: string, handler: BufferProtocolHandler, completion?: (error: Error) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a String as a response. + */ + interceptStringProtocol(scheme: string, handler: StringProtocolHandler, completion?: (error: Error) => void): void; /** * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a new HTTP request as a response. */ - interceptHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: HttpProtocolCallback) => void, completion?: (error: Error) => void): void; + interceptHttpProtocol(scheme: string, handler: HttpProtocolHandler, completion?: (error: Error) => void): void; /** * Remove the interceptor installed for scheme and restore its original handler. */ uninterceptProtocol(scheme: string, completion?: (error: Error) => void): void; } + type FileProtocolHandler = (request: ProtocolRequest, callback: FileProtocolCallback) => void; + type BufferProtocolHandler = (request: ProtocolRequest, callback: BufferProtocolCallback) => void; + type StringProtocolHandler = (request: ProtocolRequest, callback: StringProtocolCallback) => void; + type HttpProtocolHandler = (request: ProtocolRequest, callback: HttpProtocolCallback) => void; + interface ProtocolRequest { url: string; referrer: string; @@ -2416,7 +2409,7 @@ declare namespace Electron { */ scaleFactor: number; /** - * Can be 0, 1, 2, 3, each represents screen rotation in clock-wise degrees of 0, 90, 180, 270. + * Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees. */ rotation: number; touchSupport: 'available' | 'unavailable' | 'unknown'; @@ -2950,6 +2943,47 @@ declare namespace Electron { beep(): void; } + // https://github.com/electron/electron/blob/master/docs/api/system-preferences.md + + /** + * Get system preferences. + */ + interface SystemPreferences { + /** + * @returns If the system is in Dark Mode. + * + * Note: This is only implemented on OS X. + */ + isDarkMode(): boolean; + /** + * Subscribes to native notifications of OS X, callback will be called when the corresponding event happens. + * The id of the subscriber is returned, which can be used to unsubscribe the event. + * + * Note: This is only implemented on OS X. + */ + subscribeNotification(event: string, callback: Function): number; + /** + * Removes the subscriber with id. + * + * Note: This is only implemented on OS X. + */ + unsubscribeNotification(id: number): void; + /** + * Get the value of key in system preferences. + * + * Note: This is only implemented on OS X. + */ + getUserDefault(key: string, type: 'string' | 'boolean' | 'integer' | 'float' | 'double' | 'url'): any; + /** + * This method returns true if DWM composition (Aero Glass) is enabled, + * and false otherwise. You can use it to determine if you should create + * a transparent window or not (transparent windows won’t work correctly when DWM composition is disabled). + * + * Note: This is only implemented on Windows. + */ + isAeroGlassEnabled(): boolean; + } + // https://github.com/electron/electron/blob/master/docs/api/tray.md /** @@ -4418,6 +4452,7 @@ declare namespace Electron { protocol: Electron.Protocol; screen: Electron.Screen; session: typeof Electron.Session; + systemPreferences: Electron.SystemPreferences; Tray: Electron.Tray; hideInternalModules(): void; } From 80327be2772c9478d2cb52d24b441055e75eb075 Mon Sep 17 00:00:00 2001 From: Joel Day Date: Sun, 1 May 2016 09:19:20 -0700 Subject: [PATCH 63/67] Declarations for Kik browser API library. (#9164) * Definitions for the Kik browser integration library. * Add module declaration. * Minor fixes + tests. --- kik-browser/kik-browser-tests.ts | 310 +++++++++++++++++++++++++++++++ kik-browser/kik-browser.d.ts | 135 ++++++++++++++ 2 files changed, 445 insertions(+) create mode 100644 kik-browser/kik-browser-tests.ts create mode 100644 kik-browser/kik-browser.d.ts diff --git a/kik-browser/kik-browser-tests.ts b/kik-browser/kik-browser-tests.ts new file mode 100644 index 0000000000..ebd7bed113 --- /dev/null +++ b/kik-browser/kik-browser-tests.ts @@ -0,0 +1,310 @@ +/// + +if (kik.enabled) { + // running in kik +} + +if (kik.send) { + // can send messages +} + +kik.getUser(function (user) { + if (!user) { + // user denied access to their information + } else { + typeof user.username; // "string" + typeof user.fullName; // "string" + typeof user.firstName; // "string" + typeof user.lastName; // "string" + typeof user.pic; // "string" + typeof user.thumbnail; // "string" + } +}); + +if (kik.hasPermission()) { + // your webpage has permission +} + +kik.getAnonymousUser(function (token) { + typeof token; // "string" +}); + +kik.sign("my data", function (signedData, username, host) { + if (!signedData) { + // failed to sign + // perhaps user denied permissions + } else { + // successfully signed + typeof signedData; // "string", signed data + typeof username; // "string", user who signed + typeof host; // "string", host of your webpage + // all of these fields must be passed to the + // verification service to be successful + } +}); + +kik.anonymousSign("my data", function (signedData, anonToken, host) { + if (!signedData) { + // failed to sign + } else { + // successfully signed + typeof signedData; // "string", signed data + typeof anonToken; // "string", anonymous user who signed + typeof host; // "string", host of your webpage + } +}); + +kik.send({ + title : "Message title" , + text : "Message body" , + pic : "http://mysite.com/pic" , // optional + big : true , // optional + noForward : true , // optional + data : { some : "json" } // optional +}); + +kik.send("myFriend", { + title : "Message title" , + text : "Message body" , +}); + +if (kik.message) { + // your webpage was launched from a message + // kik.message is exactly what was provided in kik.send + // in this case: { some "json" } +} + +kik.openConversation("kikteam"); + +kik.metrics.enableGoogleAnalytics("id", "mydomain.com"); +kik.metrics.enableGoogleAnalytics(); +kik.showProfile("kikteam"); + +kik.pickUsers(function (users) { + if (!users) { + // action was cancelled by user + } else { + users.forEach(function (user) { + typeof user.username; // "string" + typeof user.fullName; // "string" + typeof user.firstName; // "string" + typeof user.lastName; // "string" + typeof user.pic; // "string" + typeof user.thumbnail; // "string" + }); + } +}); + +kik.pickUsers({ + minResults : 2 , // number >= 0 + maxResults : 4 // number > 0 +}, function (users) { + // do something with data +}); + +kik.pickUsers({ + preselected : [ + { username : "foo" /*, etc */ }, + // any user object obtained from previous call to pickUsers + ] +}, function (users) { + // do something with data +}); + +kik.pickUsers({ + filterSelf: false +}, function (users) { + // do something with data +}); + +kik.photo.get(function (photos) { + if (!photos) { + // action cancelled by user + } else { + // photos is a list of data URLs + } +}); + +kik.photo.get({ + quality : 0.7 , // number between 0-1 + minResults : 2 , // number between 1-25 + maxResults : 25 , // number between 1-25 + maxHeight : 1280 , // number in pixels between 0-1280 + maxWidth : 1280 , // number in pixels between 0-1280 +}, function (photos) { + // do something with the photos +}); + +kik.photo.getFromCamera({ + onSelect : function (numPhotos) { + // called immediately after the user has selected photos + // "numPhotos" is the number of photos selected by the user + // that many "onPhoto" events will be fired after this + // "onComplete" will fire after all "onPhoto" events are done + }, + onPhoto : function (photo, index) { + // "photo" is a data URL representing a single image + // "photo" may be null if there was an error in processing + // this will be called once for each image when it is ready + // "index" is an integer relating to the order of selection + // event may not come in order so use index if you care + }, + onComplete : function (photos) { + // "photos" is list of all photos from all photo events + // this event is identical to normal callback + }, + onCancel : function () { + // the action was cancelled by the user + // no other events will be called + } +}); + +kik.photo.get({ + quality : 0.7 , // number between 0-1 + minResults : 2 , // number between 1-25 + maxResults : 25 , // number between 1-25 + maxHeight : 1280 , // number in pixels between 0-1280 + maxWidth : 1280 , // number in pixels between 0-1280 +}, function (photos) { + // do something with the photos +}); + +kik.photo.getFromCamera({ + onSelect : function (numPhotos) { + // called immediately after the user has selected photos + // 'numPhotos' is the number of photos selected by the user + // that many 'onPhoto' events will be fired after this + // 'onComplete' will fire after all 'onPhoto' events are done + }, + onPhoto : function (photo, index) { + // 'photo' is a data URL representing a single image + // 'photo' may be null if there was an error in processing + // this will be called once for each image when it is ready + // 'index' is an integer relating to the order of selection + // event may not come in order so use index if you care + }, + onComplete : function (photos) { + // 'photos' is list of all photos from all photo events + // this event is identical to normal callback + }, + onCancel : function () { + // the action was cancelled by the user + // no other events will be called + } +}); + +kik.photo.getFromGallery(function (photos) { + // do something with the photos +}); + +kik.photo.saveToGallery("url", function (status) { + if (status) { + // save succeeded + } else { + // save failed + } +}); + +kik.picker( + "http://othersite.com/", + { arbitrary : "request data" }, + function (response) { + // do something with the picked data! + } +); + +if (kik.picker.reply) { + // webpage was launched in "picker mode" + // kik.picker.url === the url of the calling webpage + // kik.picker.data === { arbitrary : "request data" } + kik.picker.reply({ arbitrary : "response data" }); +} + +kik.ready(function () { + // expensive task that should not block loading +}); + +function handleBackButton () { + // called when back button is pressed + return false; // optionally cancel default behavior +} + +kik.browser.back(handleBackButton); // handle back button +kik.browser.unbindBack(handleBackButton); // unbind from handling back button + +kik.open("http://www.google.com/"); +kik.open("https://pop.kik.com/"); +kik.open("twitter://post"); + +kik.open("http://mysite.com/", true); // opens in popup mode + +kik.open("https://thirdparty.com/auth/page/path", true); + +kik.open("http://mysite.com/#response-data"); + +kik.linkData; // "response-data" + +kik.on("linkData", function () { + kik.linkData; // "response-data" +}); + +if (kik.browser.background) { + // the webpage is in the background +} + +kik.browser.on("background", function () { + // the webpage is now in the background +}); +kik.browser.on("foreground", function () { + // the webpage has returned to the foreground +}); + +// lock the orientation in landscape mode +kik.browser.setOrientationLock("landscape"); + +// unlock the orientation +kik.browser.setOrientationLock("free"); + +kik.browser.statusBar(false); // hide status bar +kik.browser.statusBar(true); // show status bar + +kik.formHelpers.show(); // show helpers +kik.formHelpers.hide(); // hide helpers +kik.formHelpers.isEnabled(); // check if enabled + +// backlight will not turn off as long +// as your webpage is visible to the user +kik.browser.backlightTimeout(false); + +// backlight will timeout as per OS rules +kik.browser.backlightTimeout(true); + +function eventHandler () { + // do something when event occurs +} + +// bind to event +kik.on("message", eventHandler); + +// unbind from event +kik.off("message", eventHandler); + +// bind to an event once (ignoring subsequent occurrences) +kik.once("message", eventHandler); + +kik.trigger("message", { + title : "Fake message" , + // object will be passed to all event listeners +}); + +let os = kik.utils.platform.os; +typeof os.name === "string"; // "ios", "android", "osx", "windows", etc +typeof os.version === "number"; // numeric version number + +let browser = kik.utils.platform.browser; +typeof browser.name === "string"; // "chrome", "safari", "opera", etc +typeof browser.version === "number"; // numeric version number + +let version = kik.utils.platform.version; +typeof browser.name === "string"; +typeof browser.version === "number"; // numeric version number \ No newline at end of file diff --git a/kik-browser/kik-browser.d.ts b/kik-browser/kik-browser.d.ts new file mode 100644 index 0000000000..3e183b0e21 --- /dev/null +++ b/kik-browser/kik-browser.d.ts @@ -0,0 +1,135 @@ +// Type definitions for Kik Cards v2.3.6 +// Project: https://dev.kik.com +// Definitions by: Joel Day +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Kik { + enabled: boolean; + message: KikMessage; + + send(user: string, message: KikMessage): void; + send(message: KikMessage): void; + ready(callback: () => void): void; + hasPermission(): boolean; + open(url: string, popupMode?: boolean): void; + on(property: string, eventHandler: () => void): void; + off(property: string, eventHandler: () => void): void; + once(property: string, eventHandler: () => void): void; + trigger(property: string, data?: any): void; + linkData: string; + getUser(callback: (user: KikUser) => void): void; + getAnonymousUser(callback: (token: string) => void): void; + sign(data: string, callback: (signedData: string, username: string, host: string) => void): void; + anonymousSign(data: string, callback: (signedData: string, anonToken: string, host: string) => void): void; + openConversation(username: string): void; + showProfile(username: string): void; + pickUsers(options: KikPickUsersOptions, callback: (users: KikUser[]) => void): void; + pickUsers(callback: (users: KikUser[]) => void): void; + + formHelpers: { + show(): void; + hide(): void; + isEnabled(): boolean; + }; + + metrics: { + enableGoogleAnalytics(): void; + enableGoogleAnalytics(trackingId: string, domain: string, oldApi?: boolean): void; + }; + + photo: { + get(options: KikGetOptions, callback: (photos: string[]) => void): void; + getFromCamera(callbacks: KikGetFromCameraCallbacks): void; + getFromCamera(options: KikGetFromCameraOptions, callbacks: KikGetFromCameraCallbacks): void; + getFromGallery(callback: (photos: string[]) => void): void; + getFromGallery(options: KikGetOptions, callback: (photos: string[]) => void): void; + saveToGallery(url: string, callback: (status: boolean) => void): void; + get(callback: (photos: string[]) => void): void; + }; + + picker: { + (url: string, data: any, callback: (response: any) => void): void; + reply: (data: any) => void; + }; + + browser: { + background: boolean; + back(callback: () => boolean | void): void; + unbindBack(callback: () => boolean | void): void; + on(property: string, callback: () => void): void; + off(property: string, callback: () => void): void; + once(property: string, callback: () => void): void; + trigger(property: string, data?: any): void; + getOrientationLock(): string; + setOrientationLock(lock: "free" | "landscape" | "portrait"): void; + setOrientationLock(lock: string): void; + statusBar(show: boolean): void; + backlightTimeout(timeout: boolean): void; + }; + + utils: { + platform: { + os: { + name: string; + version: string; + }; + browser: { + name: string; + version: string; + }; + version: { + name: string; + version: string; + }; + }; + }; +} + +interface KikUser { + username: string; + fullName: string; + firstName: string; + lastName: string; + pic: string; + thumbnail: string; +} + +interface KikMessage { + title: string; + text: string; + pic?: string; + big?: boolean; + noForward?: boolean; + data?: any; +} + +interface KikPickUsersOptions { + minResults?: number; + maxResults?: number; + preselected?: { username: string }[]; + filtered?: string[]; + filterSelf?: boolean; +} + +interface KikGetOptions { + quality?: number; + minResults?: number; + maxResults?: number; + maxHeight?: number; + maxWidth?: number; +} + +interface KikGetFromCameraOptions { + quality?: number; + maxHeight?: number; + maxWidth?: number; +} + +interface KikGetFromCameraCallbacks { + onSelect: (numPhotos: number) => void; + onPhoto: (photo: string, index: number) => void; + onComplete: (photos: string[]) => void; + onCancel: () => void; +} + +declare const kik: Kik; \ No newline at end of file From 0dcacf4517fde4c465b0455492f47c85c2289741 Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Sun, 1 May 2016 09:19:36 -0700 Subject: [PATCH 64/67] Update Helmet definitions for Helmet 2.0.0 (#9162) --- helmet/helmet-tests.ts | 230 ++++++++++++++++++++++++----------------- helmet/helmet.d.ts | 125 +++++++++++++--------- 2 files changed, 214 insertions(+), 141 deletions(-) diff --git a/helmet/helmet-tests.ts b/helmet/helmet-tests.ts index 0223244cc0..5d8a7515cd 100644 --- a/helmet/helmet-tests.ts +++ b/helmet/helmet-tests.ts @@ -10,22 +10,19 @@ var app = express(); */ function helmetTest() { app.use(helmet()); + app.use(helmet({})); + app.use(helmet({ frameguard: false })); + app.use(helmet({ frameguard: true })); + app.use(helmet({ + frameguard: { + action: 'deny' + } + })); } /** - * @summary Test for {@see helmet#xssFilter} function. + * @summary Test for {@see helmet#contentSecurityPolicy} function. */ -function xssFilterTest() { - app.use(helmet.xssFilter()); - app.use(helmet.xssFilter({})); - app.use(helmet.xssFilter({ setOnOldIE: false })); - app.use(helmet.xssFilter({ setOnOldIE: true })); -} - -/** - * @summary Test for {@see helmet#csp} function. - */ - function contentSecurityPolicyTest() { const emptyArray: string[] = []; const config = { @@ -63,86 +60,6 @@ function contentSecurityPolicyTest() { }, setAllHeaders: true })); - - app.use(helmet.csp()); - app.use(helmet.csp({})); - app.use(helmet.csp(config)); - app.use(helmet.csp({ - directives: { - defaultSrc: ["'self'"] - }, - setAllHeaders: true - })); -} - -/** - * @summary Test for {@see helmet#frameguard} function. - */ -function frameguardTest() { - app.use(helmet.frameguard()); - app.use(helmet.frameguard("sameorigin")); -} - -/** - * @summary Test for {@see helmet#hsts} function. - */ -function hstsTest() { - app.use(helmet.hsts()); - app.use(helmet.hsts({ maxAge: 7776000000 })); -} - -/** - * @summary Test for {@see helmet#ieNoOpen} function. - */ -function ieNoOpenTest() { - app.use(helmet.ieNoOpen()); -} - -/** - * @summary Test for {@see helmet#noSniff} function. - */ -function noSniffTest() { - app.use(helmet.noSniff()); -} - -/** - * @summary Test for {@see helmet#publicKeyPins} function. - */ -function publicKeyPinsTest() { - app.use(helmet.publicKeyPins({ - maxAge: 7776000000, - sha256s: ["AbCdEf123=", "ZyXwVu456="], - })); - - app.use(helmet.publicKeyPins({ - maxAge: 7776000000, - sha256s: ["AbCdEf123=", "ZyXwVu456="], - includeSubdomains: false - })); - - app.use(helmet.publicKeyPins({ - maxAge: 7776000000, - sha256s: ["AbCdEf123=", "ZyXwVu456="], - includeSubdomains: true - })); - - app.use(helmet.publicKeyPins({ - maxAge: 7776000000, - sha256s: ["AbCdEf123=", "ZyXwVu456="], - reportUri: "http://example.com" - })); - - app.use(helmet.publicKeyPins({ - maxAge: 7776000000, - sha256s: ["AbCdEf123=", "ZyXwVu456="], - reportOnly: true - })); - - app.use(helmet.publicKeyPins({ - maxAge: 7776000000, - sha256s: ["AbCdEf123=", "ZyXwVu456="], - setIf: function (req, res) { return true; } - })); } /** @@ -153,3 +70,132 @@ function dnsPrefetchControlTest() { app.use(helmet.dnsPrefetchControl({ allow: false })); app.use(helmet.dnsPrefetchControl({ allow: true })); } + +/** + * @summary Test for {@see helmet#frameguard} function. + */ +function frameguardTest() { + app.use(helmet.frameguard()); + app.use(helmet.frameguard({})); + app.use(helmet.frameguard({ action: 'deny' })); + app.use(helmet.frameguard({ action: 'sameorigin' })); + app.use(helmet.frameguard({ + action: 'allow-from', + domain: 'http://example.com' + })); +} + +/** + * @summary Test for {@see helmet#hidePoweredBy} function. + */ +function hidePoweredBy() { + app.use(helmet.hidePoweredBy()); + app.use(helmet.hidePoweredBy({})); + app.use(helmet.hidePoweredBy({ setTo: 'PHP 4.2.0' })); +} + +/** + * @summary Test for {@see helmet#hpkp} function. + */ +function hpkpTest() { + app.use(helmet.hpkp({ + maxAge: 7776000000, + sha256s: ['AbCdEf123=', 'ZyXwVu456='], + })); + + app.use(helmet.hpkp({ + maxAge: 7776000000, + sha256s: ['AbCdEf123=', 'ZyXwVu456='], + includeSubdomains: false + })); + + app.use(helmet.hpkp({ + maxAge: 7776000000, + sha256s: ['AbCdEf123=', 'ZyXwVu456='], + includeSubdomains: true + })); + + app.use(helmet.hpkp({ + maxAge: 7776000000, + sha256s: ['AbCdEf123=', 'ZyXwVu456='], + reportUri: 'http://example.com' + })); + + app.use(helmet.hpkp({ + maxAge: 7776000000, + sha256s: ['AbCdEf123=', 'ZyXwVu456='], + reportOnly: true + })); + + app.use(helmet.hpkp({ + maxAge: 7776000000, + sha256s: ['AbCdEf123=', 'ZyXwVu456='], + setIf: function (req, res) { return true; } + })); +} + +/** + * @summary Test for {@see helmet#hsts} function. + */ +function hstsTest() { + app.use(helmet.hsts()); + + app.use(helmet.hsts({ maxAge: 7776000000 })); + + app.use(helmet.hsts({ + maxAge: 7776000000, + })); + + app.use(helmet.hsts({ + maxAge: 7776000000, + includeSubdomains: true + })); + + app.use(helmet.hsts({ + maxAge: 7776000000, + preload: true + })); + + app.use(helmet.hsts({ + maxAge: 7776000000, + force: true + })); + + app.use(helmet.hsts({ + maxAge: 7776000000, + setIf: function (req, res) { return true; } + })); +} + +/** + * @summary Test for {@see helmet#ieNoOpen} function. + */ +function ieNoOpenTest() { + app.use(helmet.ieNoOpen()); +} + +/** + * @summary Test for {@see helmet#noCache} function. + */ +function noCacheTest() { + app.use(helmet.noCache()); + app.use(helmet.noCache({})); + app.use(helmet.noCache({ noEtag: true })); +} + +/** + * @summary Test for {@see helmet#noSniff} function. + */ +function noSniffTest() { + app.use(helmet.noSniff()); +} + +/** + * @summary Test for {@see helmet#xssFilter} function. + */ +function xssFilterTest() { + app.use(helmet.xssFilter()); + app.use(helmet.xssFilter({})); + app.use(helmet.xssFilter({ setOnOldIE: false })); + app.use(helmet.xssFilter({ setOnOldIE: true })); +} diff --git a/helmet/helmet.d.ts b/helmet/helmet.d.ts index f32ba0a2d9..7154d0b739 100644 --- a/helmet/helmet.d.ts +++ b/helmet/helmet.d.ts @@ -5,15 +5,28 @@ /// -declare module "helmet" { - import express = require("express"); - - interface IHelmetCspDirectiveFunction { +declare module 'helmet' { + import express = require('express'); + + interface IHelmetConfiguration { + contentSecurityPolicy? : boolean | IHelmetContentSecurityPolicyConfiguration, + dnsPrefetchControl?: boolean | IHelmetDnsPrefetchControlConfiguration, + frameguard?: boolean | IHelmetFrameguardConfiguration, + hidePoweredBy?: boolean | IHelmetHidePoweredByConfiguration, + hpkp?: boolean | IHelmetHpkpConfiguration, + hsts?: boolean | IHelmetHstsConfiguration, + ieNoOpen?: boolean, + noCache?: boolean, + noSniff?: boolean, + xssFilter?: boolean | IHelmetXssFilterConfiguration + } + + interface IHelmetContentSecurityPolicyDirectiveFunction { (req: express.Request, res: express.Response): string; } - type HelmetCspDirectiveValue = string | IHelmetCspDirectiveFunction; + type HelmetCspDirectiveValue = string | IHelmetContentSecurityPolicyDirectiveFunction; - interface IHelmetCspDirectives { + interface IHelmetContentSecurityPolicyDirectives { baseUri? : HelmetCspDirectiveValue[], childSrc? : HelmetCspDirectiveValue[], connectSrc? : HelmetCspDirectiveValue[], @@ -31,36 +44,53 @@ declare module "helmet" { scriptSrc? : HelmetCspDirectiveValue[], styleSrc? : HelmetCspDirectiveValue[] } - - interface IHelmetCspConfiguration { + + interface IHelmetContentSecurityPolicyConfiguration { reportOnly? : boolean; setAllHeaders? : boolean; disableAndroid? : boolean; browserSniff?: boolean; - directives? : IHelmetCspDirectives + directives? : IHelmetContentSecurityPolicyDirectives } - interface IHelmetPublicKeyPinsSetIfFunction { + interface IHelmetDnsPrefetchControlConfiguration { + allow? : boolean; + } + + interface IHelmetFrameguardConfiguration { + action? : string, + domain? : string + } + + interface IHelmetHidePoweredByConfiguration { + setTo? : string + } + + interface IHelmetSetIfFunction { (req: express.Request, res: express.Response): boolean; } - interface IHelmetPublicKeyPinsConfiguration { + interface IHelmetHpkpConfiguration { maxAge : number; sha256s : string[]; includeSubdomains? : boolean; reportUri? : string; reportOnly? : boolean; - setIf?: IHelmetPublicKeyPinsSetIfFunction + setIf?: IHelmetSetIfFunction + } + + interface IHelmetHstsConfiguration { + maxAge: number; + includeSubdomains? : boolean; + preload? : boolean; + setIf? : IHelmetSetIfFunction, + force? : boolean; } interface IHelmetXssFilterConfiguration { setOnOldIE? : boolean; } - interface IHelmetDnsPrefetchControlConfiguration { - allow? : boolean; - } - /** * @summary Interface for helmet class. * @interface @@ -70,77 +100,74 @@ declare module "helmet" { * @summary Constructor. * @return {RequestHandler} The Request handler. */ - ():express.RequestHandler; + (options ?: IHelmetConfiguration): express.RequestHandler; + + /** + * @summary Set policy around third-party content via headers + * @param {IHelmetContentSecurityPolicyConfiguration} options The options + * @return {RequestHandler} The Request handler + */ + contentSecurityPolicy(options ?: IHelmetContentSecurityPolicyConfiguration): express.RequestHandler; /** * @summary Stop browsers from doing DNS prefetching. + * @param {IHelmetDnsPrefetchControlConfiguration} options The options + * @return {RequestHandler} The Request handler */ - dnsPrefetchControl(options ?: IHelmetDnsPrefetchControlConfiguration):express.RequestHandler; + dnsPrefetchControl(options ?: IHelmetDnsPrefetchControlConfiguration): express.RequestHandler; /** * @summary Prevent clickjacking. - * @param {string} header The header. - * @return {RequestHandler} The Request handler. + * @param {IHelmetFrameguardConfiguration} options The options + * @return {RequestHandler} The Request handler */ - frameguard(header ?: string):express.RequestHandler; + frameguard(options ?: IHelmetFrameguardConfiguration): express.RequestHandler; /** * @summary Hide "X-Powered-By" header. - * @param {Object} options The options. + * @param {IHelmetHidePoweredByConfiguration} options The options * @return {RequestHandler} The Request handler. */ - hidePoweredBy(options ?: Object):express.RequestHandler; + hidePoweredBy(options ?: IHelmetHidePoweredByConfiguration): express.RequestHandler; + + /** + * @summary Adds the "Public-Key-Pins" header. + * @param {IHelmetHpkpConfiguration} options The options + * @return {RequestHandler} The Request handler. + */ + hpkp(options ?: IHelmetHpkpConfiguration): express.RequestHandler; /** * @summary Adds the "Strict-Transport-Security" header. - * @param {Object} options The options. + * @param {IHelmetHstsConfiguration} options The options * @return {RequestHandler} The Request handler. */ - hsts(options ?: Object):express.RequestHandler; + hsts(options ?: IHelmetHstsConfiguration): express.RequestHandler; /** * @summary Add the "X-Download-Options" header. * @return {RequestHandler} The Request handler. */ - ieNoOpen():express.RequestHandler; + ieNoOpen(): express.RequestHandler; /** * @summary Add the "Cache-Control" and "Pragma" headers to stop caching. * @return {RequestHandler} The Request handler. */ - noCache(options ?: Object):express.RequestHandler; + noCache(options ?: Object): express.RequestHandler; /** * @summary Adds the "X-Content-Type-Options" header. * @return {RequestHandler} The Request handler. */ - noSniff():express.RequestHandler; - - /** - * @summary Adds the "Public-Key-Pins" header. - * @return {RequestHandler} The Request handler. - */ - publicKeyPins(options ?: IHelmetPublicKeyPinsConfiguration):express.RequestHandler; + noSniff(): express.RequestHandler; /** * @summary Mitigate cross-site scripting attacks with the "X-XSS-Protection" header. + * @param {IHelmetXssFilterConfiguration} options The options * @return {RequestHandler} The Request handler. - * @param {Object} options The options. */ - xssFilter(options ?: IHelmetXssFilterConfiguration):express.RequestHandler; - - /** - * @summary Set policy around third-party content via headers - * @return {RequestHandler} The Request handler - * @param {Object} options The options - */ - csp(options ?: IHelmetCspConfiguration): express.RequestHandler; - - /** - * @see csp - */ - contentSecurityPolicy(options ?: IHelmetCspConfiguration): express.RequestHandler; - + xssFilter(options ?: IHelmetXssFilterConfiguration): express.RequestHandler; } var helmet: Helmet; From e05e1f6f83c6ac84e9d7ff8284e8089d53a788a6 Mon Sep 17 00:00:00 2001 From: Abd ar-Rahman Hamidi Date: Sun, 1 May 2016 21:20:03 +0500 Subject: [PATCH 65/67] Add additional option of compression at compression.d.ts (#9165) --- compression/compression.d.ts | 44 +++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/compression/compression.d.ts b/compression/compression.d.ts index 6a444e3f49..84fa211bd0 100644 --- a/compression/compression.d.ts +++ b/compression/compression.d.ts @@ -10,8 +10,50 @@ declare module "compression" { namespace e { interface CompressionOptions { - threshold?: number; + /** + * See https://github.com/expressjs/compression#chunksize regarding the usage. + */ + chunkSize?: number; + + /** + * See https://github.com/expressjs/compression#level regarding the usage. + */ + level?: number; + + /** + * See https://github.com/expressjs/compression#memlevel regarding the usage. + */ + memLevel?: number; + + /** + * See https://github.com/expressjs/compression#strategy regarding the usage. + */ + strategy?: number; + + /** + * See https://github.com/expressjs/compression#threshold regarding the usage. + */ + threshold?: number|string; + + /** + * See https://github.com/expressjs/compression#windowbits regarding the usage. + */ + windowBits?: number; + + /** + * See https://github.com/expressjs/compression#filter regarding the usage. + */ filter?: Function; + + /** + * See https://nodejs.org/api/zlib.html#zlib_class_options regarding the usage. + */ + flush?: number; + + /** + * See https://nodejs.org/api/zlib.html#zlib_class_options regarding the usage. + */ + finishFlush?: number; } } From 1faa6f7a7e485664d3edecbf2fc294748d9b5e9f Mon Sep 17 00:00:00 2001 From: Matt Brooks Date: Tue, 3 May 2016 13:44:49 +0100 Subject: [PATCH 66/67] Remove `knockout.deferred.updates` plugin Acting on advice to remove the plugin, which is obsolete as of Knockout.js v3.4.0. In v3.4.0, Knockout.js includes native support for the functionality previously provided by this plugin. The plugin's API now conflicts with the official API. --- .../knockout.deferred.updates-tests.ts | 252 ------------------ ...ockout.deferred.updates-tests.ts.tscparams | 1 - .../knockout.deferred.updates.d.ts | 46 ---- .../knockout.deferred.updates.d.ts.tscparams | 1 - 4 files changed, 300 deletions(-) delete mode 100644 knockout.deferred.updates/knockout.deferred.updates-tests.ts delete mode 100644 knockout.deferred.updates/knockout.deferred.updates-tests.ts.tscparams delete mode 100644 knockout.deferred.updates/knockout.deferred.updates.d.ts delete mode 100644 knockout.deferred.updates/knockout.deferred.updates.d.ts.tscparams diff --git a/knockout.deferred.updates/knockout.deferred.updates-tests.ts b/knockout.deferred.updates/knockout.deferred.updates-tests.ts deleted file mode 100644 index 060ff3984a..0000000000 --- a/knockout.deferred.updates/knockout.deferred.updates-tests.ts +++ /dev/null @@ -1,252 +0,0 @@ -/// - -// Turn *off* deferred updates for computed observables and subscriptions -ko.computed.deferUpdates = false; - -var myComputed = ko.computed(() => { /* ... */ }); -// Turn *on* deferred updates for this computed observable -myComputed.deferUpdates = true; - -var myObservable = ko.observable(); -var mySubscription = myObservable.subscribe((value) => { /* ... */ }); -// Turn *on* deferred updates for this subscription -mySubscription.deferUpdates = true; - -// Turn *off* deferred updates for this computed observable -myComputed.extend({ deferred: false }); - - -// -// Examples -// - -function nestedComputedNoPlugin() { - var vm: any = { - a: ko.observable(0), - b: ko.observable(0), - c: ko.observable(0), - d: ko.observable(0), - e: ko.observable(0), - f: ko.observable(0) - }; - - var startTime = new Date().getTime(); - var updateArray = []; - - function firstUpdate() { - var updateList = document.getElementById('updates'); - while (updateList.firstChild) updateList.removeChild(updateList.firstChild); - } - - function pushUpdate(name, value, color) { - var li = document.createElement('li'); - li.appendChild(document.createTextNode(name + ' ' + value + '; ' + (new Date().getTime() - startTime) + ' ms')); - li.style.color = color; - document.getElementById('updates').appendChild(li); - } - - function lastUpdate() { - } - - var updateCounter = 0, plusminus = 1; - - vm.doUpdate = function () { - var u = updateCounter += plusminus; - startTime = new Date().getTime(); - vm.a(u); - vm.b(u); - vm.c(u); - vm.d(u); - vm.e(u); - vm.f(u); - plusminus = !u ? 1 : (u == 9) ? -1 : plusminus; - }; - - vm.setThrottle = function (value) { - vm.A.throttleEvaluation = value; - vm._B.throttleEvaluation = value; - vm.C.throttleEvaluation = value; - vm.D.throttleEvaluation = value; - vm.E.throttleEvaluation = value; - vm.F.throttleEvaluation = value; - }; - - vm.runNormal = function () { - ko.computed.deferUpdates = false; - vm.setThrottle(undefined); - vm.doUpdate(); - }; - - vm.runThrottle = function () { - ko.computed.deferUpdates = false; - vm.setThrottle(1); - vm.doUpdate(); - }; - - vm.A = ko.computed(function () { - var result = '' + vm.a(); - firstUpdate(); - pushUpdate('A', result, 'green'); - return result; - }, null, { deferEvaluation: true }); - - vm._B = ko.computed(function () { - var result = '' + vm.A() + vm.b(); - pushUpdate('B', result, 'darkturquoise'); - return result; - }, null, { deferEvaluation: true }); - - vm.C = ko.computed(function () { - var result = '' + vm._B() + vm.c(); - pushUpdate('C', result, 'royalblue'); - return result; - }, null, { deferEvaluation: true }); - - vm.D = ko.computed(function () { - var result = '' + vm.C() + vm.d(); - pushUpdate('D', result, 'indigo'); - return result; - }, null, { deferEvaluation: true }); - - vm.E = ko.computed(function () { - var result = '' + vm.D() + vm.e(); - pushUpdate('E', result, 'firebrick'); - return result; - }, null, { deferEvaluation: true }); - - vm.F = ko.computed(function () { - var f = vm.f(), result = '' + vm.E() + f; - pushUpdate('F', result, 'orangered'); - if (result === '' + f + f + f + f + f + f) lastUpdate(); - return result; - }, null, { deferEvaluation: true }); - - vm.A(); - vm._B(); - vm.C(); - vm.D(); - vm.E(); - vm.F(); - - ko.applyBindings(vm); -}; - -function nestedComputedPlugin() { - var vm: any = { - a: ko.observable(0), - b: ko.observable(0), - c: ko.observable(0), - d: ko.observable(0), - e: ko.observable(0), - f: ko.observable(0) - }; - - var startTime = new Date().getTime(); - var updateArray = []; - - function firstUpdate() { - var updateList = document.getElementById('updates'); - while (updateList.firstChild) - updateList.removeChild(updateList.firstChild); - } - - function pushUpdate(name, value, color) { - var li = document.createElement('li'); - li.appendChild(document.createTextNode(name + ' ' + value + '; ' + (new Date().getTime() - startTime) + ' ms')); - li.style.color = color; - document.getElementById('updates').appendChild(li); - } - - function lastUpdate() { - } - - var updateCounter = 0, plusminus = 1; - - vm.doUpdate = function () { - var u = updateCounter += plusminus; - startTime = new Date().getTime(); - vm.a(u); - vm.b(u); - vm.c(u); - vm.d(u); - vm.e(u); - vm.f(u); - plusminus = !u ? 1 : (u == 9) ? -1 : plusminus; - }; - - vm.setThrottle = function (value) { - vm.A.throttleEvaluation = value; - vm._B.throttleEvaluation = value; - vm.C.throttleEvaluation = value; - vm.D.throttleEvaluation = value; - vm.E.throttleEvaluation = value; - vm.F.throttleEvaluation = value; - }; - - vm.runNormal = function () { - ko.computed.deferUpdates = false; - vm.setThrottle(undefined); - vm.doUpdate(); - }; - - vm.runThrottle = function () { - ko.computed.deferUpdates = false; - vm.setThrottle(1); - vm.doUpdate(); - }; - - vm.runDefer = function () { - ko.computed.deferUpdates = true; - vm.setThrottle(undefined); - vm.doUpdate(); - }; - - vm.runWrappedDefer = ko.tasks.makeProcessedCallback(vm.runDefer); - - vm.A = ko.computed(function () { - var result = '' + vm.a(); - firstUpdate(); - pushUpdate('A', result, 'green'); - return result; - }, null, { deferEvaluation: true }); - - vm._B = ko.computed(function () { - var result = '' + vm.A() + vm.b(); - pushUpdate('B', result, 'darkturquoise'); - return result; - }, null, { deferEvaluation: true }); - - vm.C = ko.computed(function () { - var result = '' + vm._B() + vm.c(); - pushUpdate('C', result, 'royalblue'); - return result; - }, null, { deferEvaluation: true }); - - vm.D = ko.computed(function () { - var result = '' + vm.C() + vm.d(); - pushUpdate('D', result, 'indigo'); - return result; - }, null, { deferEvaluation: true }); - - vm.E = ko.computed(function () { - var result = '' + vm.D() + vm.e(); - pushUpdate('E', result, 'firebrick'); - return result; - }, null, { deferEvaluation: true }); - - vm.F = ko.computed(function () { - var f = vm.f(), result = '' + vm.E() + f; - pushUpdate('F', result, 'orangered'); - if (result === '' + f + f + f + f + f + f) lastUpdate(); - return result; - }, null, { deferEvaluation: true }); - - vm.A(); - vm._B(); - vm.C(); - vm.D(); - vm.E(); - vm.F(); - - ko.applyBindings(vm); -} diff --git a/knockout.deferred.updates/knockout.deferred.updates-tests.ts.tscparams b/knockout.deferred.updates/knockout.deferred.updates-tests.ts.tscparams deleted file mode 100644 index 8b13789179..0000000000 --- a/knockout.deferred.updates/knockout.deferred.updates-tests.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ - diff --git a/knockout.deferred.updates/knockout.deferred.updates.d.ts b/knockout.deferred.updates/knockout.deferred.updates.d.ts deleted file mode 100644 index d3c5d7b40d..0000000000 --- a/knockout.deferred.updates/knockout.deferred.updates.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Type definitions for Knockout Deferred Updates -// Project: https://github.com/mbest/knockout-deferred-updates -// Definitions by: Sebastián Galiano -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -interface KnockoutDeferredTasks { - processImmediate(evaluator: Function, object?: any, args?: any[]): any; - processDelayed(evaluator: Function, distinct?: boolean, options?: any[]): boolean; - makeProcessedCallback(evaluator: Function): void; -} - -// Knockout global -interface KnockoutStatic { - tasks: KnockoutDeferredTasks; - processAllDeferredBindingUpdates(): void; - processAllDeferredUpdates(): void; - evaluateAsynchronously(evaluator: Function, timeout?: any): number; - ignoreDependencies(callback: Function, callbackTarget: any, callbackArgs?: any[]); -} - -// Observables -interface KnockoutSubscribableFunctions { - deferUpdates: boolean; -} - -// Computed -interface KnockoutComputedStatic { - deferUpdates: boolean; -} - -interface KnockoutSubscription { - deferUpdates: boolean; -} - -// Utils -interface KnockoutUtils { - objectForEach(obj: any, action: Function): void; - objectMap(source: any, mapping: Function): any; -} - -// Deferred extender -interface KnockoutExtenders { - deferred(target: any, value: boolean): any; -} \ No newline at end of file diff --git a/knockout.deferred.updates/knockout.deferred.updates.d.ts.tscparams b/knockout.deferred.updates/knockout.deferred.updates.d.ts.tscparams deleted file mode 100644 index 8b13789179..0000000000 --- a/knockout.deferred.updates/knockout.deferred.updates.d.ts.tscparams +++ /dev/null @@ -1 +0,0 @@ - From 74c909751b2aa6741b9a8e54d11e9b5e6204e2cc Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Tue, 3 May 2016 17:24:40 +0200 Subject: [PATCH 67/67] Add torrent-stream definitions (#9111) * Add torrent-stream definitions * Fix * Update torrent-stream.d.ts * Update torrent-stream-tests.ts * Options needs to be optional * Fix --- torrent-stream/torrent-stream-tests.ts | 6 +++ torrent-stream/torrent-stream.d.ts | 62 ++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 torrent-stream/torrent-stream-tests.ts create mode 100644 torrent-stream/torrent-stream.d.ts diff --git a/torrent-stream/torrent-stream-tests.ts b/torrent-stream/torrent-stream-tests.ts new file mode 100644 index 0000000000..f69b7f968f --- /dev/null +++ b/torrent-stream/torrent-stream-tests.ts @@ -0,0 +1,6 @@ +/// + +import * as torrentStream from "torrent-stream"; + +let engine: TorrentStream.TorrentEngine = torrentStream("magnet"); +console.log(engine.swarm.downloaded) diff --git a/torrent-stream/torrent-stream.d.ts b/torrent-stream/torrent-stream.d.ts new file mode 100644 index 0000000000..ccb81613bf --- /dev/null +++ b/torrent-stream/torrent-stream.d.ts @@ -0,0 +1,62 @@ +// Type definitions for torrent-stream +// Project: https://npmjs.com/package/torrent-stream +// Definitions by: Xavier Stouder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace TorrentStream { + interface TorrentEngine { + files: TorrentFile[]; + destroy(callback: () => void): void; + connect(peer: string): void; + disconnect(peer: string): void; + block(peer: string): void; + remove(keepPieces: boolean, callback: () => void): void; + listen(port: number, callback: () => void): void; + swarm: Swarm; + + // Events + on(event: "ready" | "torrent" | "idle", callback: Function): void; + on(event: "download", callback: (pieceIndex: number) => void): void; + on(event: "upload", callback: (pieceIndex: number, offset: number, length: number) => void): void; + on(event: string,callback: Function): void; + } + interface TorrentEngineOptions { + connections?: number; // Max amount of peers to be connected to. + uploads?: number; // Number of upload slots. + tmp?: string; // Root folder for the files storage. Default folder under /tmp/torrent-stream/{infoHash}. + path?: string; // Path where to save the files. Overrides 'tmp'. + verify?: boolean; // Verify previously stored data before starting. + dht?: boolean; // Whether or not to use DHT to initialize the swarm. + tracker?: boolean; // Whether or not to use trackers from torrent file or magnet link. + trackers?: string[]; // Allows to declare additional custom trackers to use. + storage?: any; // Use a custom storage backend rather than the default disk-backed one. + } + interface Swarm { + downloaded: number; + } + interface TorrentFile { + name: string; + path: string; + length: number; + + select(): void; + deselect(): void; + createReadStream(options?: ReadStreamOptions): any; + } + interface ReadStreamOptions { + start: number; + end: number; + } +} + +declare module "torrent-stream" { + function s(magnet: string | Buffer, options?: TorrentStream.TorrentEngineOptions): TorrentStream.TorrentEngine; + + namespace s { + // Here + } + + export = s; +}