Merge branch 'types-2.0' into mixedCase

This commit is contained in:
Paul van Brenk
2016-08-19 16:38:20 -07:00
193 changed files with 5280 additions and 1526 deletions
+23
View File
@@ -0,0 +1,23 @@
/// <reference types="auth0-js" />
var auth0 = new Auth0({
domain: 'mine.auth0.com',
clientID: 'dsa7d77dsa7d7',
callbackURL: 'http://my-app.com/callback',
callbackOnLocationHash: true
});
auth0.login({
connection: 'google-oauth2',
popup: true,
popupOptions: {
width: 450,
height: 800
}
}, (err, profile, idToken, accessToken, state) => {
if (err) {
alert("something went wrong: " + err.message);
return;
}
alert('hello ' + profile.name);
});
+132
View File
@@ -0,0 +1,132 @@
// Type definitions for Auth0.js
// Project: https://github.com/auth0/auth0.js
// Definitions by: Robert McLaws <https://github.com/advancedrei>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/** Extensions to the browser Window object. */
interface Window {
/** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
token: string;
}
/** This is the interface for the main Auth0 client. */
interface Auth0Static {
new(options: Auth0ClientOptions): Auth0Static;
changePassword(options: any, callback?: Function): void;
decodeJwt(jwt: string): any;
login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
logout(query: string): void;
getConnections(callback?: Function): void;
refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
getProfile(id_token: string, callback?: Function): Auth0UserProfile;
getSSOData(withActiveDirectories: any, callback?: Function): void;
parseHash(hash: string): Auth0DecodedHash;
signup(options: Auth0SignupOptions, callback: Function): void;
validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
}
/** Represents constructor options for the Auth0 client. */
interface Auth0ClientOptions {
clientID: string;
callbackURL: string;
callbackOnLocationHash?: boolean;
domain: string;
forceJSONP?: boolean;
}
/** Represents a normalized UserProfile. */
interface Auth0UserProfile {
email: string;
family_name: string;
gender: string;
given_name: string;
locale: string;
name: string;
nickname: string;
picture: string;
user_id: string;
/** Represents one or more Identities that may be associated with the User. */
identities: Auth0Identity[];
user_metadata?: any;
app_metadata?: any;
}
/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
interface MicrosoftUserProfile extends Auth0UserProfile {
emails: string[];
}
/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
interface Office365UserProfile extends Auth0UserProfile {
tenantid: string;
upn: string;
}
/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
interface AdfsUserProfile extends Auth0UserProfile {
issuer: string;
}
/** Represents multiple identities assigned to a user. */
interface Auth0Identity {
access_token: string;
connection: string;
isSocial: boolean;
provider: string;
user_id: string;
}
interface Auth0DecodedHash {
access_token: string;
id_token: string;
profile: Auth0UserProfile;
state: any;
}
interface Auth0PopupOptions {
width: number;
height: number;
}
interface Auth0LoginOptions {
auto_login?: boolean;
connection?: string;
email?: string;
username?: string;
password?: string;
popup?: boolean;
popupOptions?: Auth0PopupOptions;
}
interface Auth0SignupOptions extends Auth0LoginOptions {
auto_login: boolean;
}
interface Auth0Error {
code: any;
details: any;
name: string;
message: string;
status: any;
}
/** Represents the response from an API Token Delegation request. */
interface Auth0DelegationToken {
/** The length of time in seconds the token is valid for. */
expires_in: string;
/** The JWT for delegated access. */
id_token: string;
/** The type of token being returned. Possible values: "Bearer" */
token_type: string;
}
declare const Auth0: Auth0Static;
declare module "auth0" {
export = Auth0
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"auth0-js-tests.ts"
]
}
+1 -1
View File
@@ -1,4 +1,4 @@
/// <reference types="auth0" />
/// <reference types="auth0-js" />
const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID";
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Brian Caruso <https://github.com/carusology>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="auth0" />
/// <reference types="auth0-js" />
interface Auth0LockAdditionalSignUpFieldOption {
value: string;
+1 -1
View File
@@ -1,4 +1,4 @@
/// <reference types="auth0" />
/// <reference types="auth0-js" />
var widget: Auth0WidgetStatic = new Auth0Widget({
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Robert McLaws <https://github.com/advancedrei>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="auth0" />
/// <reference types="auth0-js" />
interface Auth0WidgetStatic {
+47 -19
View File
@@ -1,23 +1,51 @@
/// <reference types="auth0" />
var auth0 = new Auth0({
domain: 'mine.auth0.com',
clientID: 'dsa7d77dsa7d7',
callbackURL: 'http://my-app.com/callback',
callbackOnLocationHash: true
import * as auth0 from 'auth0';
const management = new auth0.ManagementClient({
token: '{YOUR_API_V2_TOKEN}',
domain: '{YOUR_ACCOUNT}.auth0.com'
});
auth0.login({
connection: 'google-oauth2',
popup: true,
popupOptions: {
width: 450,
height: 800
}
}, (err, profile, idToken, accessToken, state) => {
if (err) {
alert("something went wrong: " + err.message);
return;
}
alert('hello ' + profile.name);
});
const auth = new auth0.AuthenticationClient({
domain: '{YOUR_ACCOUNT}.auth0.com',
clientId: '{OPTIONAL_CLIENT_ID}'
});
// Using a callback.
management.getUsers((err: Error, users: auth0.User[]) => {
if (err) {
// Handle error.
}
console.log(users);
});
// Using a Promise.
management
.getUsers()
.then((users) => {
console.log(users);
})
.catch((err) => {
// Handle the error.
});
management
.createUser({
connection: 'My-Connection',
email: 'hi@me.co',
}).then((user) => {
console.log(user);
}).catch((err) => {
// Handle the error.
});
auth
.requestChangePasswordEmail({
connection: 'My-Connection',
email: 'hi@me.co',
}).then((response) => {
console.log(response);
}).catch((err) => {
// Handle the error.
});
+70 -113
View File
@@ -1,132 +1,89 @@
// Type definitions for Auth0.js
// Project: http://auth0.com
// Definitions by: Robert McLaws <https://github.com/advancedrei>
// Type definitions for auth0 v2.3.1
// Project: https://github.com/auth0/node-auth0
// Definitions by: Seth Westphal <https://github.com/westy92>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/** Extensions to the browser Window object. */
interface Window {
/** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
token: string;
import * as Promise from 'bluebird';
export interface ManagementClientOptions {
token: string;
domain?: string;
}
/** This is the interface for the main Auth0 client. */
interface Auth0Static {
new(options: Auth0ClientOptions): Auth0Static;
changePassword(options: any, callback?: Function): void;
decodeJwt(jwt: string): any;
login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
logout(query: string): void;
getConnections(callback?: Function): void;
refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
getProfile(id_token: string, callback?: Function): Auth0UserProfile;
getSSOData(withActiveDirectories: any, callback?: Function): void;
parseHash(hash: string): Auth0DecodedHash;
signup(options: Auth0SignupOptions, callback: Function): void;
validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
export interface UserData {
connection: string;
email?: string;
username?: string;
password?: string;
phone_number?: string;
user_metadata?: {};
email_verified?: boolean;
app_metadata?: {};
}
/** Represents constructor options for the Auth0 client. */
interface Auth0ClientOptions {
clientID: string;
callbackURL: string;
callbackOnLocationHash?: boolean;
domain: string;
forceJSONP?: boolean;
export interface GetUsersData {
per_page?: number;
page?: number;
include_totals?: boolean;
sort?: string;
connection?: string;
fields?: string;
include_fields?: boolean;
q?: string;
search_engine?: string;
}
/** Represents a normalized UserProfile. */
interface Auth0UserProfile {
email: string;
family_name: string;
gender: string;
given_name: string;
locale: string;
name: string;
nickname: string;
picture: string;
user_id: string;
/** Represents one or more Identities that may be associated with the User. */
identities: Auth0Identity[];
user_metadata?: any;
app_metadata?: any;
export interface User {
email?: string;
email_verified?: boolean;
username?: string;
phone_number?: string;
phone_verified?: boolean;
user_id?: string;
created_at?: string;
updated_at?: string;
identities?: Identity[];
app_metadata?: {};
user_metadata?: {};
picture?: string;
name?: string;
nickname?: string;
multifactor?: string[];
last_ip?: string;
last_login?: string;
logins_count?: number;
blocked?: boolean;
}
/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
interface MicrosoftUserProfile extends Auth0UserProfile {
emails: string[];
export interface Identity {
connection: string;
user_id: string;
provider: string;
isSocial: boolean;
}
/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
interface Office365UserProfile extends Auth0UserProfile {
tenantid: string;
upn: string;
export class ManagementClient {
constructor(options: ManagementClientOptions);
getUsers(params?: GetUsersData): Promise<User[]>;
getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void;
createUser(data: UserData): Promise<User>;
createUser(data: UserData, cb: (err: Error, data: User) => void): void;
}
/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
interface AdfsUserProfile extends Auth0UserProfile {
issuer: string;
export interface AuthenticationClientOptions {
clientId?: string;
domain: string;
}
/** Represents multiple identities assigned to a user. */
interface Auth0Identity {
access_token: string;
connection: string;
isSocial: boolean;
provider: string;
user_id: string;
export interface RequestChangePasswordEmailData {
connection: string;
email: string;
}
interface Auth0DecodedHash {
access_token: string;
id_token: string;
profile: Auth0UserProfile;
state: any;
}
export class AuthenticationClient {
constructor(options: AuthenticationClientOptions);
interface Auth0PopupOptions {
width: number;
height: number;
}
interface Auth0LoginOptions {
auto_login?: boolean;
connection?: string;
email?: string;
username?: string;
password?: string;
popup?: boolean;
popupOptions?: Auth0PopupOptions;
}
interface Auth0SignupOptions extends Auth0LoginOptions {
auto_login: boolean;
}
interface Auth0Error {
code: any;
details: any;
name: string;
message: string;
status: any;
}
/** Represents the response from an API Token Delegation request. */
interface Auth0DelegationToken {
/** The length of time in seconds the token is valid for. */
expires_in: string;
/** The JWT for delegated access. */
id_token: string;
/** The type of token being returned. Possible values: "Bearer" */
token_type: string;
}
declare var Auth0: Auth0Static;
declare module "auth0" {
export = Auth0
}
requestChangePasswordEmail(data: RequestChangePasswordEmailData): Promise<string>;
requestChangePasswordEmail(data: RequestChangePasswordEmailData, cb: (err: Error, message: string) => void): void;
}
@@ -0,0 +1,7 @@
/// <reference path="index.d.ts"/>
window.addEventListener('batterystatus',
(ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
window.addEventListener('batterycritical',
() => { alert('Battery is critical low!'); });
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova BatteryStatus plugin.
// Type definitions for Apache Cordova BatteryStatus plugin
// Project: https://github.com/apache/cordova-plugin-battery-status
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Window {
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-battery-status-tests.ts"
]
}
@@ -0,0 +1,13 @@
/// <reference path="index.d.ts"/>
navigator.camera.getPicture(
(data: string) => { alert('Got photo!'); },
(message: string)=> { alert('Failed!: ' + message); },
{
allowEdit: true,
cameraDirection: Camera.Direction.BACK,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
quality: 80
});
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova Camera plugin.
// Type definitions for Apache Cordova Camera plugin
// Project: https://github.com/apache/cordova-plugin-camera
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Navigator {
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-camera-tests.ts"
]
}
@@ -0,0 +1,18 @@
/// <reference path="index.d.ts"/>
var contact: Contact = navigator.contacts.create({
nickname: 'John Smith',
displayName: 'John Smith',
phoneNumbers: [{ pref: true, type: "work", value: "+185642556856" }]
});
navigator.contacts.find(["phoneNumbers"],
(contacts: Contact[])=> { alert('Find ' + contacts.length + ' contacts'); },
(error: ContactError) => { alert('Error: ' + error.message); },
new ContactFindOptions("+1", true)
);
navigator.contacts.pickContact(
(contact: Contact)=> { console.log(contact); },
(err: ContactError)=> { console.log(err.message); }
);
@@ -1,10 +1,10 @@
// Type definitions for Apache Cordova Contacts plugin.
// Type definitions for Apache Cordova Contacts plugin
// Project: https://github.com/apache/cordova-plugin-contacts
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license
interface Navigator {
/** Provides access to the device contacts database. */
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-contacts-tests.ts"
]
}
@@ -0,0 +1,12 @@
/// <reference path="index.d.ts"/>
navigator.accelerometer.getCurrentAcceleration(
(acc: Acceleration) => { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
() => { alert('Error!'); });
var acchandle: WatchHandle = navigator.accelerometer.watchAcceleration(
(acc: Acceleration)=> { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
() => { alert('Error!'); },
{ frequency: 10 });
navigator.accelerometer.clearWatch(acchandle);
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova Device Motion plugin.
// Type definitions for Apache Cordova Device Motion plugin
// Project: https://github.com/apache/cordova-plugin-device-motion
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Navigator {
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-device-motion-tests.ts"
]
}
@@ -0,0 +1,13 @@
/// <reference path="index.d.ts"/>
navigator.compass.getCurrentHeading(
(heading: CompassHeading)=> { console.log('Got heading to ' + heading.magneticHeading); },
(error: CompassError)=> { alert('Error! ' + error.code); },
{ frequency: 10 });
var accelhandle = navigator.compass.watchHeading(
(heading: CompassHeading) => { console.log('Got heading to ' + heading.magneticHeading); },
(error: CompassError) => { alert('Error! ' + error.code); },
{ frequency: 10 });
navigator.compass.clearWatch(accelhandle);
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova Device Orientation plugin.
// Type definitions for Apache Cordova Device Orientation plugin
// Project: https://github.com/apache/cordova-plugin-device-orientation
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Navigator {
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-device-orientation-tests.ts"
]
}
@@ -0,0 +1,3 @@
/// <reference path="index.d.ts"/>
console.log(JSON.stringify(device));
@@ -1,10 +1,10 @@
// Type definitions for Apache Cordova Device plugin.
// Type definitions for Apache Cordova Device plugin
// Project: https://github.com/apache/cordova-plugin-device
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license
/**
* This plugin defines a global device object, which describes the device's hardware and software.
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-device-tests.ts"
]
}
@@ -0,0 +1,4 @@
/// <reference path="index.d.ts"/>
navigator.notification.alert('Alert!', () => { alert('You\'re alerted'); }, 'Alert', 'Ok');
navigator.notification.confirm('Are you ok?', (choice: number) => { alert('Your choice is ' + choice); });
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova Dialogs plugin.
// Type definitions for Apache Cordova Dialogs plugin
// Project: https://github.com/apache/cordova-plugin-dialogs
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Navigator {
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-dialogs-tests.ts"
]
}
@@ -0,0 +1,39 @@
/// <reference path="index.d.ts"/>
var file = new FileTransfer();
file.onprogress = (ev: ProgressEvent) => {
if (ev.lengthComputable) {
console.log(ev.loaded + '/' + ev.total);
}
};
file.download('http://some.server.com/download.php',
'cdvfile://localhost/persistent/path/to/downloads/',
(file: FileEntry)=> { console.log('File Downloaded to ' + file.fullPath); },
(err: FileTransferError) => {
console.error('Error ' + err.code);
if (err.exception) {
console.error('Failed with exception ' + err.exception);
}
},
true,
{
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
});
file.upload('cdvfile://localhost/persistent/path/to/downloads/',
'http://some.server.com/download.php',
(result: FileUploadResult)=> { console.log('File uploaded. Bytes uploaded: ' + result.bytesSent); },
(err: FileTransferError) => {
console.error('Error ' + err.code);
if (err.exception) {
console.error('Failed with exception ' + err.exception);
}
},
{ headers: {"X-Email": "user@mail.com", 'X-Token': "asdf3w234"}, httpMethod: "PUT" },
true);
file.abort();
@@ -1,12 +1,12 @@
// Type definitions for Apache Cordova FileTransfer plugin.
// Type definitions for Apache Cordova FileTransfer plugin
// Project: https://github.com/apache/cordova-plugin-file-transfer
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc. <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license
/// <reference path="FileSystem.d.ts"/>
/// <reference path="../cordova-plugin-file/index.d.ts" />
/**
* The FileTransfer object provides a way to upload files using an HTTP multi-part POST request,
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-file-transfer-tests.ts"
]
}
@@ -0,0 +1,40 @@
/// <reference path="../cordova/index.d.ts"/>
/// <reference path="index.d.ts"/>
function fsaccessor(fs: FileSystem) {
console.log('FS root is: ' + fs.root.name);
var fsreader: DirectoryReader = fs.root.createReader();
fsreader.readEntries(
(entries: Entry[]) => { console.log(fs.root.name + ' has ' + entries.length + ' child elements'); },
(err: FileError)=> { alert('Error: ' + err.code); });
}
window.requestFileSystem(
window.TEMPORARY,
1024 * 1024 * 5,
fsaccessor,
(err: FileError) => { alert('Error: ' + err.code); }
);
window.resolveLocalFileSystemURI(cordova.file.applicationDirectory,
(entry: Entry)=> {
if (entry.isDirectory) {
console.log('successfully resolved ' + entry.fullPath + 'directory');
console.log(entry.toURL());
console.log(entry.toInternalURL());
} else {
var fentry = <FileEntry>entry;
fentry.file((f: File) => { console.log(f.slice(f.size - 10, f.size)); });
fentry.createWriter((writer: FileWriter)=> {
if (writer.readyState == FileWriter.INIT) {
console.log('Init FileWriter');
writer.write(new Blob(['sdfdsfsdf']));
writer.onprogress = function(ev: ProgressEvent) {
console.log('Writing ' + ev.target);
};
}
});
}
},
(error: FileError) => { console.log(error.code); }
);
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova File System plugin.
// Type definitions for Apache Cordova File System plugin
// Project: https://github.com/apache/cordova-plugin-file
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Window {
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-file-tests.ts"
]
}
@@ -0,0 +1,13 @@
/// <reference path="index.d.ts"/>
navigator.globalization.dateToString(new Date(),
(date) => { console.log(JSON.stringify(date)); },
(error) => { alert(error.message); },
{ formatLength: "short", selector: "date" });
navigator.globalization.getDateNames(
(names) => {
names.value.forEach((name) => { console.log(name); });
},
(error) => { alert(error.message); },
{ item: "months", type: "wide" });
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova Globalization plugin.
// Type definitions for Apache Cordova Globalization plugin
// Project: https://github.com/apache/cordova-plugin-globalization
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Navigator {
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-globalization-tests.ts"
]
}
@@ -0,0 +1,15 @@
/// <reference path="index.d.ts"/>
// InAppBrowser plugin
//----------------------------------------------------------------------
// signature of window.open() added by InAppBrowser plugin
// is similar to native window.open signature, so the compiler can's
// select proper overload, but we cast result to InAppBrowser manually.
var iab = <InAppBrowser>window.open('google.com', '_self');
iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); });
iab.show();
iab.executeScript(
{ code: "console.log('Injected script in action')" },
()=> { console.log('Script is executed'); }
);
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova InAppBrowser plugin.
// Type definitions for Apache Cordova InAppBrowser plugin
// Project: https://github.com/apache/cordova-plugin-inappbrowser
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Window {
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-inappbrowser-tests.ts"
]
}
@@ -0,0 +1,25 @@
/// <reference path="index.d.ts"/>
Keyboard.shrinkView(true);
Keyboard.shrinkView(false);
Keyboard.hideFormAccessoryBar(true);
Keyboard.hideFormAccessoryBar(false);
Keyboard.disableScrollingInShrinkView(true);
Keyboard.disableScrollingInShrinkView(false);
if (Keyboard.isVisible) {
console.log('Keyboard is visible');
}
Keyboard.automaticScrollToTopOnHiding = true;
Keyboard.onshow = function () {
console.log('onshow');
};
Keyboard.onhide = function () {
console.log('onhide');
};
Keyboard.onshowing = function () {
console.log('onshowing');
};
Keyboard.onhiding= function () {
console.log('onhiding');
};
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-keyboard-tests.ts"
]
}
@@ -0,0 +1,13 @@
/// <reference path="index.d.ts" />
console.log('Supported audio modes are: ' + JSON.stringify(navigator.device.capture.supportedAudioModes));
navigator.device.capture.captureAudio(
(captures: MediaFile[]) => { console.log(captures.length + ' captured'); },
(err: CaptureError) => { alert('Error ' + err.message); },
{
limit: 3,
duration: 10
}
);
@@ -1,10 +1,10 @@
// Type definitions for Apache Cordova MediaCapture plugin.
// Type definitions for Apache Cordova MediaCapture plugin
// Project: https://github.com/apache/cordova-plugin-media-capture
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license
interface Navigator {
device: Device;
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-media-capture-tests.ts"
]
}
@@ -0,0 +1,11 @@
/// <reference path="index.d.ts"/>
// Media and Media Capture
//----------------------------------------------------------------------
var media = new Media('',
() => { console.log('Media opened'); },
(err: MediaError) => { alert('Error: ' + err.code); });
media.play();
media.setVolume(10);
@@ -1,10 +1,10 @@
// Type definitions for Apache Cordova Media plugin.
// Type definitions for Apache Cordova Media plugin
// Project: https://github.com/apache/cordova-plugin-media
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license
declare var Media: {
new (
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-media-tests.ts"
]
}
@@ -0,0 +1,8 @@
/// <reference path="index.d.ts" />
var connType = navigator.connection.type;
if (connType == Connection.WIFI) {
console.log('Congratulations, you\'re with fast Internet!');
}
document.addEventListener('offline', () => { alert('You\'re offline!'); });
@@ -1,10 +1,10 @@
// Type definitions for Apache Cordova Network Information plugin.
// Type definitions for Apache Cordova Network Information plugin
// Project: https://github.com/apache/cordova-plugin-network-information
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license
interface Navigator {
/**
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-network-information-tests.ts"
]
}
@@ -0,0 +1,4 @@
/// <reference path="index.d.ts"/>
navigator.splashscreen.show();
navigator.splashscreen.hide();
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova Splashscreen plugin.
// Type definitions for Apache Cordova Splashscreen plugin
// Project: https://github.com/apache/cordova-plugin-splashscreen
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Navigator {
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-splashscreen-tests.ts"
]
}
@@ -1,5 +1,4 @@
// Licensed under the MIT license.
/// <reference path="index.d.ts"/>
var statusBar: StatusBar = window.StatusBar;
@@ -1,4 +1,4 @@
// Type definitions for Apache Cordova StatusBar plugin.
// Type definitions for Apache Cordova StatusBar plugin
// Project: https://github.com/apache/cordova-plugin-statusbar
// Definitions by: Xinkai Chen <https://github.com/Xinkai>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-statusbar-tests.ts"
]
}
@@ -0,0 +1,8 @@
/// <reference path="index.d.ts" />
var notification: Notification;
notification.vibrate(100);
notification.vibrateWithPattern([100, 200, 200, 150, 50], 3);
setTimeout(notification.cancelVibration, 1000);
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova Vibration plugin.
// Type definitions for Apache Cordova Vibration plugin
// Project: https://github.com/apache/cordova-plugin-vibration
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>, Louis Lagrange <https://github.com/Minishlink/>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>, Louis Lagrange <https://github.com/Minishlink/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Navigator {
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-vibration-tests.ts"
]
}
@@ -0,0 +1,16 @@
/// <reference path="index.d.ts" />
var db = window.openDatabase('Test', '0.1', 'test', 1024 * 1024 * 5);
db.transaction(
(tx: SqlTransaction) => {
tx.executeSql('CREATE TABLE Sample IF NOT EXIST...');
tx.executeSql('INSERT INTO Sample VALUES...');
},
(err: SqlError) => {
if (err.code = SqlError.SYNTAX_ERR) {
alert('Error ' + err.message);
}
},
() => { console.log('Transaction completed successfully'); }
);
@@ -1,9 +1,9 @@
// Type definitions for Apache Cordova WebSQL plugin.
// Type definitions for Apache Cordova WebSQL plugin
// Project: https://github.com/MSOpenTech/cordova-plugin-websql
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
interface Window {
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noEmit": true
},
"files": [
"index.d.ts",
"cordova-plugin-websql-tests.ts"
]
}
@@ -1,6 +1,5 @@
/// <reference types="cordova" />
window.plugins.socialsharing.iPadPopupCoordinates = function () {
return "100,100,200,300";
};
+4
View File
@@ -3,6 +3,10 @@
// Definitions by: Markus Wagner <https://github.com/Ritzlgrmft/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Window {
plugins: Plugins;
}
interface Plugins {
socialsharing: SocialSharingPlugin.SocialSharing;
}
+3 -295
View File
@@ -4,6 +4,9 @@
// Apache Cordova core
//----------------------------------------------------------------------
/// <reference path="../cordova-plugin-vibration/index.d.ts"/>
/// <reference path="../cordova-plugin-websql/index.d.ts"/>
console.log('cordova.version: ' + cordova.version + ', cordova.platformId: ' + cordova.platformId);
console.log(typeof window.cordova);
@@ -30,301 +33,6 @@ declare var app: Application;
document.addEventListener('deviceready', () => { app.start(); });
document.addEventListener('pause', ()=> { app.pause(); });
// Battery status plugin
//----------------------------------------------------------------------
window.addEventListener('batterystatus',
(ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
window.addEventListener('batterycritical',
() => { alert('Battery is critical low!'); });
// Camera plugin
//----------------------------------------------------------------------
navigator.camera.getPicture(
(data: string) => { alert('Got photo!'); },
(message: string)=> { alert('Failed!: ' + message); },
{
allowEdit: true,
cameraDirection: Camera.Direction.BACK,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
quality: 80
});
// Contacts plugin
//----------------------------------------------------------------------
var contact: Contact = navigator.contacts.create({
nickname: 'John Smith',
displayName: 'John Smith',
phoneNumbers: [{ pref: true, type: "work", value: "+185642556856" }]
});
navigator.contacts.find(["phoneNumbers"],
(contacts: Contact[])=> { alert('Find ' + contacts.length + ' contacts'); },
(error: ContactError) => { alert('Error: ' + error.message); },
new ContactFindOptions("+1", true)
);
navigator.contacts.pickContact(
(contact: Contact)=> { console.log(contact); },
(err: ContactError)=> { console.log(err.message); }
);
// Device API
//----------------------------------------------------------------------
console.log(JSON.stringify(device));
// DeviceMotion plugin
//----------------------------------------------------------------------
navigator.accelerometer.getCurrentAcceleration(
(acc: Acceleration) => { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
() => { alert('Error!'); });
var acchandle: WatchHandle = navigator.accelerometer.watchAcceleration(
(acc: Acceleration)=> { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
() => { alert('Error!'); },
{ frequency: 10 });
navigator.accelerometer.clearWatch(acchandle);
// DeviceOrientation plugin
//----------------------------------------------------------------------
navigator.compass.getCurrentHeading(
(heading: CompassHeading)=> { console.log('Got heading to ' + heading.magneticHeading); },
(error: CompassError)=> { alert('Error! ' + error.code); },
{ frequency: 10 });
var accelhandle = navigator.compass.watchHeading(
(heading: CompassHeading) => { console.log('Got heading to ' + heading.magneticHeading); },
(error: CompassError) => { alert('Error! ' + error.code); },
{ frequency: 10 });
navigator.compass.clearWatch(accelhandle);
// Dialogs plugin
//----------------------------------------------------------------------
navigator.notification.alert('Alert!', () => { alert('You\'re alerted'); }, 'Alert', 'Ok');
navigator.notification.confirm('Are you ok?', (choice: number) => { alert('Your choice is ' + choice); });
// FileSystem plugin
//----------------------------------------------------------------------
function fsaccessor(fs: FileSystem) {
console.log('FS root is: ' + fs.root.name);
var fsreader: DirectoryReader = fs.root.createReader();
fsreader.readEntries(
(entries: Entry[]) => { console.log(fs.root.name + ' has ' + entries.length + ' child elements'); },
(err: FileError)=> { alert('Error: ' + err.code); });
}
window.requestFileSystem(
window.TEMPORARY,
1024 * 1024 * 5,
fsaccessor,
(err: FileError) => { alert('Error: ' + err.code); }
);
window.resolveLocalFileSystemURI(cordova.file.applicationDirectory,
(entry: Entry)=> {
if (entry.isDirectory) {
console.log('successfully resolved ' + entry.fullPath + 'directory');
console.log(entry.toURL());
console.log(entry.toInternalURL());
} else {
var fentry = <FileEntry>entry;
fentry.file((f: File) => { console.log(f.slice(f.size - 10, f.size)); });
fentry.createWriter((writer: FileWriter)=> {
if (writer.readyState == FileWriter.INIT) {
console.log('Init FileWriter');
writer.write(new Blob(['sdfdsfsdf']));
writer.onprogress = function(ev: ProgressEvent) {
console.log('Writing ' + ev.target);
};
}
});
}
},
(error: FileError) => { console.log(error.code); }
);
// FileTransfer plugin
//----------------------------------------------------------------------
var file = new FileTransfer();
file.onprogress = (ev: ProgressEvent) => {
if (ev.lengthComputable) {
console.log(ev.loaded + '/' + ev.total);
}
};
file.download('http://some.server.com/download.php',
'cdvfile://localhost/persistent/path/to/downloads/',
(file: FileEntry)=> { console.log('File Downloaded to ' + file.fullPath); },
(err: FileTransferError) => {
console.error('Error ' + err.code);
if (err.exception) {
console.error('Failed with exception ' + err.exception);
}
},
true,
{
headers: {
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
}
});
file.upload('cdvfile://localhost/persistent/path/to/downloads/',
'http://some.server.com/download.php',
(result: FileUploadResult)=> { console.log('File uploaded. Bytes uploaded: ' + result.bytesSent); },
(err: FileTransferError) => {
console.error('Error ' + err.code);
if (err.exception) {
console.error('Failed with exception ' + err.exception);
}
},
{ headers: {"X-Email": "user@mail.com", 'X-Token': "asdf3w234"}, httpMethod: "PUT" },
true);
file.abort();
file.abort();
// InAppBrowser plugin
//----------------------------------------------------------------------
// signature of window.open() added by InAppBrowser plugin
// is similar to native window.open signature, so the compiler can's
// select proper overload, but we cast result to InAppBrowser manually.
var iab = <InAppBrowser>window.open('google.com', '_self');
iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); });
iab.show();
iab.executeScript(
{ code: "console.log('Injected script in action')" },
()=> { console.log('Script is executed'); }
);
// Globalization plugin
//----------------------------------------------------------------------
navigator.globalization.dateToString(new Date(),
(date) => { console.log(JSON.stringify(date)); },
(error) => { alert(error.message); },
{ formatLength: "short", selector: "date" });
navigator.globalization.getDateNames(
(names) => {
names.value.forEach((name) => { console.log(name); });
},
(error) => { alert(error.message); },
{ item: "months", type: "wide" });
// Media and Media Capture
//----------------------------------------------------------------------
var media = new Media('',
() => { console.log('Media opened'); },
(err: MediaError) => { alert('Error: ' + err.code); });
media.play();
media.setVolume(10);
console.log('Supported audio modes are: ' + JSON.stringify(navigator.device.capture.supportedAudioModes));
navigator.device.capture.captureAudio(
(captures: MediaFile[])=> { console.log(captures.length + ' captured'); },
(err: CaptureError)=> { alert('Error ' + err.message); },
{
limit: 3,
duration: 10
});
// Push Notifications
//----------------------------------------------------------------------
var pushNotification = window.plugins.pushNotification;
pushNotification.register(
(regId: string) => { console.log('Successfully registered'); },
(err: any) => { alert('Error!'); },
{
channelName: "your_channel_name",
ecb: "onNotification"
});
function onNotification(e: any) {
navigator.notification.alert(e.text2, () => { }, e.text1);
}
window.plugins.pushNotification.unregister(() => { }, () => { });
// Network Plugin
//----------------------------------------------------------------------
var connType = navigator.connection.type;
if (connType == Connection.WIFI) {
console.log('Congratulations, you\'re with fast Internet!');
}
document.addEventListener('offline', () => { alert('You\'re offline!'); });
// SplashScreen plugin
//----------------------------------------------------------------------
navigator.splashscreen.show();
navigator.splashscreen.hide();
// WebSQL plugin
//----------------------------------------------------------------------
var db = window.openDatabase('Test', '0.1', 'test', 1024 * 1024 * 5);
db.transaction(
(tx: SqlTransaction) => {
tx.executeSql('CREATE TABLE Sample IF NOT EXIST...');
tx.executeSql('INSERT INTO Sample VALUES...');
},
(err: SqlError) => {
if (err.code = SqlError.SYNTAX_ERR) {
alert('Error ' + err.message);
}
},
() => { console.log('Transaction completed successfully'); }
);
// Vibration plugin
//----------------------------------------------------------------------
navigator.notification.vibrate(100);
navigator.notification.vibrateWithPattern([100, 200, 200, 150, 50], 3);
setTimeout(navigator.notification.cancelVibration, 1000);
// Keyboard plugin
//----------------------------------------------------------------------
Keyboard.shrinkView(true);
Keyboard.shrinkView(false);
Keyboard.hideFormAccessoryBar(true);
Keyboard.hideFormAccessoryBar(false);
Keyboard.disableScrollingInShrinkView(true);
Keyboard.disableScrollingInShrinkView(false);
if (Keyboard.isVisible) {
console.log('Keyboard is visible');
}
Keyboard.automaticScrollToTopOnHiding = true;
Keyboard.onshow = function () {
console.log('onshow');
};
Keyboard.onhide = function () {
console.log('onhide');
};
Keyboard.onshowing = function () {
console.log('onshowing');
};
Keyboard.onhiding= function () {
console.log('onhiding');
};
+3 -22
View File
@@ -1,31 +1,12 @@
// Type definitions for Apache Cordova
// Project: http://cordova.apache.org
// Definitions by: Microsoft Open Technologies Inc. <http://msopentech.com>
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
/// <reference path="plugins/BatteryStatus.d.ts"/>
/// <reference path="plugins/Camera.d.ts"/>
/// <reference path="plugins/Contacts.d.ts"/>
/// <reference path="plugins/Device.d.ts"/>
/// <reference path="plugins/DeviceMotion.d.ts"/>
/// <reference path="plugins/DeviceOrientation.d.ts"/>
/// <reference path="plugins/Dialogs.d.ts"/>
/// <reference path="plugins/FileSystem.d.ts"/>
/// <reference path="plugins/FileTransfer.d.ts"/>
/// <reference path="plugins/Globalization.d.ts"/>
/// <reference path="plugins/InAppBrowser.d.ts"/>
/// <reference path="plugins/Media.d.ts"/>
/// <reference path="plugins/MediaCapture.d.ts"/>
/// <reference path="plugins/NetworkInformation.d.ts"/>
/// <reference path="plugins/Push.d.ts"/>
/// <reference path="plugins/Splashscreen.d.ts"/>
/// <reference path="plugins/StatusBar.d.ts"/>
/// <reference path="plugins/Vibration.d.ts"/>
/// <reference path="plugins/WebSQL.d.ts"/>
/// <reference path="plugins/Keyboard.d.ts"/>
interface Cordova {
/** Invokes native functionality by specifying corresponding service name, action and optional parameters.
-70
View File
@@ -1,70 +0,0 @@
// Type definitions for Apache Cordova Push plugin.
// Project: https://github.com/phonegap-build/PushPlugin
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Window {
plugins: Plugins
}
interface Plugins {
/**
* This plugin allows to receive push notifications. The Android implementation uses
* Google's GCM (Google Cloud Messaging) service,
* whereas the iOS version is based on Apple APNS Notifications
*/
pushNotification: PushNotification
}
/**
* This plugin allows to receive push notifications. The Android implementation uses
* Google's GCM (Google Cloud Messaging) service,
* whereas the iOS version is based on Apple APNS Notifications
*/
interface PushNotification {
/**
* Registers as push notification receiver.
* @param successCallback Called when a plugin method returns without error.
* @param errorCallback Called when the plugin returns an error.
* @param registrationOptions Options for registration process.
*/
register(
successCallback: (registrationId: string) => void,
errorCallback: (error: any) => void,
registrationOptions: RegistrationOptions): void;
/**
* Unregisters as push notification receiver.
* @param successCallback Called when a plugin method returns without error.
* @param errorCallback Called when the plugin returns an error.
*/
unregister(
successCallback: (result: any) => void,
errorCallback: (error: any) => void): void;
/**
* Sets the badge count visible when the app is not running. iOS only.
* @param successCallback Called when a plugin method returns without error.
* @param errorCallback Called when the plugin returns an error.
* @param badgeCount An integer indicating what number should show up in the badge. Passing 0 will clear the badge.
*/
setApplicationIconBadgeNumber(
successCallback: (result: any) => void,
errorCallback: (error: any) => void,
badgeCount: number): void;
}
/** Options for registration process. */
interface RegistrationOptions {
/** This is the Google project ID you need to obtain by registering your application for GCM. Android only */
senderID?: string;
/** WP8 only */
channelName?: string;
/** Callback, that is fired when notification arrived */
ecb?: string;
badge?: boolean;
sound?: boolean;
alert?: boolean
}
+2 -8
View File
@@ -2,15 +2,9 @@
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"noImplicitAny": false,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
"noEmit": true
},
"files": [
"index.d.ts",
+104 -104
View File
@@ -6,7 +6,7 @@
* are not intended as functional tests.
*/
import * as d3 from 'd3-array';
import * as d3Array from 'd3-array';
import { scaleTime } from 'd3-scale';
import { timeYear } from 'd3-time';
@@ -47,8 +47,8 @@ let date: Date;
let extentNum: [number, number];
let extentStr: [string, string];
let extentNumeric: [NumCoercible, NumCoercible];
let extentDateMixed: [d3.Primitive, d3.Primitive];
let extentMixed: [d3.Primitive | NumCoercible, d3.Primitive | NumCoercible];
let extentDateMixed: [d3Array.Primitive, d3Array.Primitive];
let extentMixed: [d3Array.Primitive | NumCoercible, d3Array.Primitive | NumCoercible];
let extentDate: [Date, Date];
let numbersArray = [10, 20, 30, 40, 50];
@@ -72,35 +72,35 @@ let mixedObjectArray = [
// without accessors
num = d3.max(numbersArray);
str = d3.max(stringyNumbersArray);
numeric = d3.max(numericArray);
date = d3.max(dateArray);
num = d3Array.max(numbersArray);
str = d3Array.max(stringyNumbersArray);
numeric = d3Array.max(numericArray);
date = d3Array.max(dateArray);
// with accessors
num = d3.max(mixedObjectArray, function (datum, index, array) {
num = d3Array.max(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.num;
});
str = d3.max(mixedObjectArray, function (datum, index, array) {
str = d3Array.max(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.str;
});
numeric = d3.max(mixedObjectArray, function (datum, index, array) {
numeric = d3Array.max(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.numeric;
});
date = d3.max(mixedObjectArray, function (datum, index, array) {
date = d3Array.max(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -111,35 +111,35 @@ date = d3.max(mixedObjectArray, function (datum, index, array) {
// without accessors
num = d3.min(numbersArray);
str = d3.min(stringyNumbersArray);
numeric = d3.min(numericArray);
date = d3.min(dateArray);
num = d3Array.min(numbersArray);
str = d3Array.min(stringyNumbersArray);
numeric = d3Array.min(numericArray);
date = d3Array.min(dateArray);
// with accessors
num = d3.min(mixedObjectArray, function (datum, index, array) {
num = d3Array.min(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.num;
});
str = d3.min(mixedObjectArray, function (datum, index, array) {
str = d3Array.min(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.str;
});
numeric = d3.min(mixedObjectArray, function (datum, index, array) {
numeric = d3Array.min(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.numeric;
});
date = d3.min(mixedObjectArray, function (datum, index, array) {
date = d3Array.min(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -150,36 +150,36 @@ date = d3.min(mixedObjectArray, function (datum, index, array) {
// without accessors
extentNum = d3.extent(numbersArray);
extentStr = d3.extent(stringyNumbersArray);
extentNumeric = d3.extent(numericArray);
extentDate = d3.extent(dateArray);
extentMixed = d3.extent([new NumCoercible(10), 13, '12', true]);
extentNum = d3Array.extent(numbersArray);
extentStr = d3Array.extent(stringyNumbersArray);
extentNumeric = d3Array.extent(numericArray);
extentDate = d3Array.extent(dateArray);
extentMixed = d3Array.extent([new NumCoercible(10), 13, '12', true]);
// with accessors
extentNum = d3.extent(mixedObjectArray, function (datum, index, array) {
extentNum = d3Array.extent(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.num;
});
extentStr = d3.extent(mixedObjectArray, function (datum, index, array) {
extentStr = d3Array.extent(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.str;
});
extentMixed = d3.extent(mixedObjectArray, function (datum, index, array) {
extentMixed = d3Array.extent(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.numeric;
});
extentDateMixed = d3.extent(mixedObjectArray, function (datum, index, array) {
extentDateMixed = d3Array.extent(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -188,9 +188,9 @@ extentDateMixed = d3.extent(mixedObjectArray, function (datum, index, array) {
// mean() ----------------------------------------------------------------------
num = d3.mean(numbersArray);
num = d3Array.mean(numbersArray);
num = d3.mean(mixedObjectArray, function (datum, index, array) {
num = d3Array.mean(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -199,9 +199,9 @@ num = d3.mean(mixedObjectArray, function (datum, index, array) {
// median() --------------------------------------------------------------------
num = d3.median(numbersArray);
num = d3Array.median(numbersArray);
num = d3.median(mixedObjectArray, function (datum, index, array) {
num = d3Array.median(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -210,9 +210,9 @@ num = d3.median(mixedObjectArray, function (datum, index, array) {
// quantile() ------------------------------------------------------------------
num = d3.quantile(numbersArray, 0.5);
num = d3Array.quantile(numbersArray, 0.5);
num = d3.quantile(mixedObjectArray, 0.5, function (datum, index, array) {
num = d3Array.quantile(mixedObjectArray, 0.5, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -222,9 +222,9 @@ num = d3.quantile(mixedObjectArray, 0.5, function (datum, index, array) {
// sum() -----------------------------------------------------------------------
num = d3.sum(numbersArray);
num = d3Array.sum(numbersArray);
num = d3.sum(mixedObjectArray, function (datum, index, array) {
num = d3Array.sum(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -233,9 +233,9 @@ num = d3.sum(mixedObjectArray, function (datum, index, array) {
// deviation() -----------------------------------------------------------------
num = d3.deviation(numbersArray);
num = d3Array.deviation(numbersArray);
num = d3.deviation(mixedObjectArray, function (datum, index, array) {
num = d3Array.deviation(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -244,9 +244,9 @@ num = d3.deviation(mixedObjectArray, function (datum, index, array) {
// variance() ------------------------------------------------------------------
num = d3.variance(numbersArray);
num = d3Array.variance(numbersArray);
num = d3.variance(mixedObjectArray, function (datum, index, array) {
num = d3Array.variance(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
@@ -259,65 +259,65 @@ num = d3.variance(mixedObjectArray, function (datum, index, array) {
// scan() ----------------------------------------------------------------------
num = d3.scan(mixedObjectArray, function (a, b) {
num = d3Array.scan(mixedObjectArray, function (a, b) {
return a.num - b.num; // a and b are of type MixedObject
});
// bisectLeft() ----------------------------------------------------------------
num = d3.bisectLeft([0, 2, 3, 4, 7, 8], 4);
num = d3.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1);
num = d3.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4);
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1);
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3.bisectLeft(['0', '2', '3', '4', '7', '8'], '21');
num = d3.bisectLeft(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3.bisectLeft(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21');
num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
// bisectRight() ---------------------------------------------------------------
num = d3.bisectRight([0, 2, 3, 4, 7, 8], 4);
num = d3.bisectRight([0, 2, 3, 4, 7, 8], 4, 1);
num = d3.bisectRight([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4);
num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4, 1);
num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3.bisectRight(['0', '2', '3', '4', '7', '8'], '21');
num = d3.bisectRight(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3.bisectRight(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21');
num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
// bisect() --------------------------------------------------------------------
num = d3.bisect([0, 2, 3, 4, 7, 8], 4);
num = d3.bisect([0, 2, 3, 4, 7, 8], 4, 1);
num = d3.bisect([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4);
num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4, 1);
num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3.bisect(['0', '2', '3', '4', '7', '8'], '21');
num = d3.bisect(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3.bisect(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21');
num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
// bisector() ------------------------------------------------------------------
mixedObjectArray.sort(function (a, b) { return a.date.valueOf() - b.date.valueOf(); });
let mixedObjectDateBisectorObject: d3.Bisector<MixedObject, Date>;
let mixedObjectDateBisectorObject: d3Array.Bisector<MixedObject, Date>;
// define using accessor
mixedObjectDateBisectorObject = d3.bisector<MixedObject, Date>(function (el) {
mixedObjectDateBisectorObject = d3Array.bisector<MixedObject, Date>(function (el) {
return el.date;
});
// define using comparator
mixedObjectDateBisectorObject = d3.bisector<MixedObject, Date>(function (el, x) {
mixedObjectDateBisectorObject = d3Array.bisector<MixedObject, Date>(function (el, x) {
return el.date.valueOf() - x.valueOf();
});
@@ -334,15 +334,15 @@ num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14
// ascending() -----------------------------------------------------------------
num = d3.ascending(10, 20);
num = d3.ascending('10', '20');
num = d3.ascending(new Date(2016, 6, 13), new Date(2016, 6, 14));
num = d3Array.ascending(10, 20);
num = d3Array.ascending('10', '20');
num = d3Array.ascending(new Date(2016, 6, 13), new Date(2016, 6, 14));
// descending() ----------------------------------------------------------------
num = d3.descending(10, 20);
num = d3.descending('10', '20');
num = d3.descending(new Date(2016, 6, 13), new Date(2016, 6, 14));
num = d3Array.descending(10, 20);
num = d3Array.descending('10', '20');
num = d3Array.descending(new Date(2016, 6, 13), new Date(2016, 6, 14));
// -----------------------------------------------------------------------------
// Test Transforming Arrays
@@ -367,20 +367,20 @@ let testArrays: MixedObject[][] = [
let mergedArray: MixedObject[];
mergedArray = d3.merge(testArrays); // inferred type
mergedArray = d3.merge<MixedObject>(testArrays); // explicit type
mergedArray = d3Array.merge(testArrays); // inferred type
mergedArray = d3Array.merge<MixedObject>(testArrays); // explicit type
// mergedArray = d3.merge<MixedObject>([[10, 40, 30], [15, 30]]); // fails, type mismatch
// pairs() ---------------------------------------------------------------------
let pairs: Array<[MixedObject, MixedObject]>;
pairs = d3.pairs(mergedArray);
pairs = d3Array.pairs(mergedArray);
// permute() -------------------------------------------------------------------
// getting a permutation of array elements
mergedArray = d3.permute(mergedArray, [1, 0, 2, 5, 3, 4, 6]);
mergedArray = d3Array.permute(mergedArray, [1, 0, 2, 5, 3, 4, 6]);
// Getting an ordered array with object properties
@@ -391,35 +391,35 @@ let testObject = {
more: [10, 30, 40]
};
let x: Array<number | string | Date | number[]> = d3.permute(testObject, ['name', 'val', 'when', 'more']);
let x: Array<number | string | Date | number[]> = d3Array.permute(testObject, ['name', 'val', 'when', 'more']);
// range() ---------------------------------------------------------------------
numbersArray = d3.range(10);
numbersArray = d3.range(1, 10);
numbersArray = d3.range(1, 10, 0.5);
numbersArray = d3Array.range(10);
numbersArray = d3Array.range(1, 10);
numbersArray = d3Array.range(1, 10, 0.5);
// shuffle() -------------------------------------------------------------------
mergedArray = d3.shuffle(mergedArray);
mergedArray = d3Array.shuffle(mergedArray);
mergedArray = d3.shuffle(mergedArray, 1);
mergedArray = d3Array.shuffle(mergedArray, 1);
mergedArray = d3.shuffle(mergedArray, 1, 3);
mergedArray = d3Array.shuffle(mergedArray, 1, 3);
// ticks() ---------------------------------------------------------------------
numbersArray = d3.ticks(1, 10, 5);
numbersArray = d3Array.ticks(1, 10, 5);
// tickStep() ------------------------------------------------------------------
numbersArray = d3.tickStep(1, 10, 5);
numbersArray = d3Array.tickStep(1, 10, 5);
// transpose() -----------------------------------------------------------------
testArrays = d3.transpose([
testArrays = d3Array.transpose([
[
new MixedObject(10, new Date(2016, 6, 1)),
new MixedObject(50, new Date(2017, 4, 15))
@@ -432,7 +432,7 @@ testArrays = d3.transpose([
// zip() -----------------------------------------------------------------------
testArrays = d3.zip(
testArrays = d3Array.zip(
[
new MixedObject(10, new Date(2016, 6, 1)),
new MixedObject(20, new Date(2016, 7, 30)),
@@ -454,11 +454,11 @@ let tScale = scaleTime();
// Create histogram generator ==================================================
let defaultHistogram: d3.HistogramGenerator<number, number>;
defaultHistogram = d3.histogram();
let defaultHistogram: d3Array.HistogramGenerator<number, number>;
defaultHistogram = d3Array.histogram();
let testHistogram: d3.HistogramGenerator<MixedObject, Date>;
testHistogram = d3.histogram<MixedObject, Date>();
let testHistogram: d3Array.HistogramGenerator<MixedObject, Date>;
testHistogram = d3Array.histogram<MixedObject, Date>();
// Configure histogram generator ===============================================
@@ -501,7 +501,7 @@ domainAccessorFn = testHistogram.domain();
defaultHistogram = defaultHistogram.thresholds(3);
// with threshold count generator
defaultHistogram = defaultHistogram.thresholds(d3.thresholdScott);
defaultHistogram = defaultHistogram.thresholds(d3Array.thresholdScott);
// with thresholds value array
@@ -518,10 +518,10 @@ testHistogram = testHistogram.thresholds(tScale.ticks(timeYear));
// Use histogram generator =====================================================
let defaultBins: Array<d3.Bin<number, number>>;
let defaultBins: Array<d3Array.Bin<number, number>>;
defaultBins = defaultHistogram([-1, 0, 1, 1, 3, 20, 234]);
let defaultBin: d3.Bin<number, number>;
let defaultBin: d3Array.Bin<number, number>;
defaultBin = defaultBins[0];
num = defaultBin.length; // defaultBin is array
@@ -529,10 +529,10 @@ num = defaultBin[0]; // with element type number
num = defaultBin.x0; // bin lower bound is number
num = defaultBin.x1; // bin upper bound is number
let testBins: Array<d3.Bin<MixedObject, Date>>;
let testBins: Array<d3Array.Bin<MixedObject, Date>>;
testBins = testHistogram(mixedObjectArray);
let testBin: d3.Bin<MixedObject, Date>;
let testBin: d3Array.Bin<MixedObject, Date>;
testBin = testBins[0];
num = testBin.length; // defaultBin is array
@@ -544,8 +544,8 @@ date = testBin.x1; // bin upper bound is Date
// Histogram Tresholds =========================================================
num = d3.thresholdFreedmanDiaconis([-1, 0, 1, 1, 3, 20, 234], -1, 234);
num = d3Array.thresholdFreedmanDiaconis([-1, 0, 1, 1, 3, 20, 234], -1, 234);
num = d3.thresholdScott([-1, 0, 1, 1, 3, 20, 234], -1, 234);
num = d3Array.thresholdScott([-1, 0, 1, 1, 3, 20, 234], -1, 234);
num = d3.thresholdSturges([-1, 0, 1, 1, 3, 20, 234]);
num = d3Array.thresholdSturges([-1, 0, 1, 1, 3, 20, 234]);
+10 -11
View File
@@ -157,7 +157,7 @@ export function sum<T>(array: T[], accessor: (datum: T, index: number, array: T[
export function deviation(array: number[]): number | undefined;
/**
* Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array,
* Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array,
* using the given accessor to convert values to numbers.
*/
export function deviation<T>(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined;
@@ -255,7 +255,7 @@ export function range(start: number, stop: number, step?: number): number[];
export function shuffle<T>(array: T[], lo?: number, hi?: number): T[];
/**
* Generate an array of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive).
* Generate an array of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive).
*/
export function ticks(start: number, stop: number, count: number): number[];
@@ -274,7 +274,7 @@ export function transpose<T>(matrix: T[][]): T[][];
/**
* Returns an array of arrays, where the ith array contains the ith element from each of the argument arrays.
* The returned array is truncated in length to the shortest array in arrays. If arrays contains only a single array, the returned array
* The returned array is truncated in length to the shortest array in arrays. If arrays contains only a single array, the returned array
* contains one-element arrays. With no arguments, the returned array is empty.
*/
export function zip<T>(...arrays: T[][]): T[][];
@@ -311,7 +311,7 @@ export interface HistogramGenerator<Datum, Value extends number | Date> {
/**
* Divide the domain uniformly into approximately count bins. IMPORTANT: This threshold
* setting approach only works, when the materialized values are numbers!
*
*
* @param count The desired number of uniform bins.
*/
thresholds(count: number): this;
@@ -319,10 +319,10 @@ export interface HistogramGenerator<Datum, Value extends number | Date> {
* Set a threshold accessor function, which returns the desired number of bins.
* Divides the domain uniformly into approximately count bins. IMPORTANT: This threshold
* setting approach only works, when the materialized values are numbers!
*
*
* @param count A function which accepts as arguments the array of materialized values, and
* optionally the domain minimum and maximum. The function calcutates and returns the suggested
* number of bins.
* number of bins.
*/
thresholds(count: ThresholdCountGenerator): this;
/**
@@ -332,12 +332,12 @@ export interface HistogramGenerator<Datum, Value extends number | Date> {
*/
thresholds(thresholds: Value[]): this;
/**
* Set a threshold accessor function, which returns the array of values to be used as
* Set a threshold accessor function, which returns the array of values to be used as
* thresholds in determining the bins.
*
*
* @param thresholds A function which accepts as arguments the array of materialized values, and
* optionally the domain minimum and maximum. The function calcutates and returns the array of values to be used as
* thresholds in determining the bins.
* optionally the domain minimum and maximum. The function calcutates and returns the array of values to be used as
* thresholds in determining the bins.
*/
thresholds(thresholds: ThresholdArrayGenerator<Value>): this;
}
@@ -354,4 +354,3 @@ export function thresholdFreedmanDiaconis(values: number[], min: number, max: nu
export function thresholdScott(values: number[], min: number, max: number): number; // of type ThresholdCountGenerator
export function thresholdSturges(values: number[]): number; // of type ThresholdCountGenerator
+8 -1
View File
@@ -13,6 +13,7 @@ import {
scaleOrdinal,
ScaleOrdinal,
scalePow,
ScalePower,
scaleTime,
ScaleTime,
} from 'd3-scale';
@@ -70,11 +71,17 @@ let leftAxis: d3Axis.Axis<number | { valueOf(): number }> = d3Axis.axisLeft(scal
// scale(...) ----------------------------------------------------------------
leftAxis = leftAxis.scale(scalePow());
let powerScale: ScalePower<number, number> = leftAxis.scale<ScalePower<number, number>>();
// powerScale = leftAxis.scale(); // fails, without casting as AxisScale is purposely generic
bottomAxis = bottomAxis.scale(scaleOrdinal<number>());
// bottomAxis = bottomAxis.scale(scalePow()) // fails, domain of scale incompatible with domain of axis
let axisScale: d3Axis.AxisScale<string> = bottomAxis.scale();
// let ordinalScale: ScaleOrdinal<string, number> = bottomAxis.scale(); // fails, without casting as AxisScale is purposely generic
let ordinalScale: ScaleOrdinal<string, number> = bottomAxis.scale<ScaleOrdinal<string, number>>();
// ordinalScale = bottomAxis.scale(); // fails, without casting as AxisScale is purposely generic
// ticks(...) ----------------------------------------------------------------
+19 -20
View File
@@ -1,11 +1,10 @@
// Type definitions for D3JS d3-axis module 1.0.0
// Project: https://github.com/d3/d3-axis/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Selection, TransitionLike } from 'd3-selection';
// --------------------------------------------------------------------------
// Shared Types and Interfaces
// --------------------------------------------------------------------------
@@ -67,14 +66,14 @@ export interface Axis<Domain> {
/**
* Gets the current scale underlying the axis.
*/
scale(): AxisScale<Domain>;
scale<A extends AxisScale<Domain>>(): A;
/**
* Sets the scale and returns the axis.
*
* @param scale The scale to be used for axis generation
*/
scale(scale: AxisScale<Domain>): Axis<Domain>;
scale(scale: AxisScale<Domain>): this;
/**
* Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.
@@ -82,7 +81,7 @@ export interface Axis<Domain> {
* @param count Number of ticks that should be rendered
* @param specifier An optional format specifier to customize how the tick values are formatted.
*/
ticks(count: number, specifier?: string): Axis<Domain>;
ticks(count: number, specifier?: string): this;
/**
* Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.
@@ -92,12 +91,12 @@ export interface Axis<Domain> {
* in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15).
* @param specifier An optional format specifier to customize how the tick values are formatted.
*/
ticks(interval: AxisTimeInterval, specifier?: string): Axis<Domain>;
ticks(interval: AxisTimeInterval, specifier?: string): this;
/**
* Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.
*/
ticks(arg0: any, ...args: any[]): Axis<Domain>;
ticks(arg0: any, ...args: any[]): this;
/**
* Get an array containing the currently set arguments to be passed into scale.ticks and scale.tickFormat.
@@ -109,7 +108,7 @@ export interface Axis<Domain> {
*
* @param args An array containing a single element representing the count, i.e. number of ticks to be rendered.
*/
tickArguments(args: [number]): Axis<Domain>;
tickArguments(args: [number]): this;
/**
* Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.
@@ -117,7 +116,7 @@ export interface Axis<Domain> {
* @param args An array containing two elements. The first element represents the count, i.e. number of ticks to be rendered. The second
* element is a string representing the format specifier to customize how the tick values are formatted.
*/
tickArguments(args: [number, string]): Axis<Domain>;
tickArguments(args: [number, string]): this;
/**
* Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.
@@ -126,7 +125,7 @@ export interface Axis<Domain> {
* @param args An array containing a single element representing a time interval used to generate date-based ticks.
* This is typically a TimeInterval/CountableTimeInterval as defined in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15).
*/
tickArguments(args: [AxisTimeInterval]): Axis<Domain>;
tickArguments(args: [AxisTimeInterval]): this;
/**
* Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.
@@ -136,14 +135,14 @@ export interface Axis<Domain> {
* This is typically a TimeInterval/CountableTimeInterval as defined in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15).
* The second element is a string representing the format specifier to customize how the tick values are formatted.
*/
tickArguments(args: [AxisTimeInterval, string]): Axis<Domain>;
tickArguments(args: [AxisTimeInterval, string]): this;
/**
* Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator.
*
* @param args An array with arguments suitable for the scale to be used for tick generation
*/
tickArguments(args: any[]): Axis<Domain>;
tickArguments(args: any[]): this;
/**
* Returns the current tick values, which defaults to null.
@@ -158,14 +157,14 @@ export interface Axis<Domain> {
*
* @param values An array with values from the Domain of the scale underlying the axis.
*/
tickValues(values: Domain[]): Axis<Domain>;
tickValues(values: Domain[]): this;
/**
* Clears any previously-set explicit tick values and reverts back to the scales tick generator.
*
* @param values null
*/
tickValues(values: null): Axis<Domain>;
tickValues(values: null): this;
/**
@@ -179,7 +178,7 @@ export interface Axis<Domain> {
* @param format A function mapping a value from the axis Domain to a formatted string
* for display purposes.
*/
tickFormat(format: (domainValue: Domain) => string): Axis<Domain>;
tickFormat(format: (domainValue: Domain) => string): this;
/**
* Reset the tick format function. A null format indicates that the scales
@@ -189,7 +188,7 @@ export interface Axis<Domain> {
*
* @param format null
*/
tickFormat(format: null): Axis<Domain>;
tickFormat(format: null): this;
/**
* Get the current inner tick size, which defaults to 6.
@@ -200,7 +199,7 @@ export interface Axis<Domain> {
*
* @param size Tick size in pixels (Default is 6).
*/
tickSize(size: number): Axis<Domain>;
tickSize(size: number): this;
/**
* Get the current inner tick size, which defaults to 6.
@@ -216,7 +215,7 @@ export interface Axis<Domain> {
*
* @param size Tick size in pixels (Default is 6).
*/
tickSizeInner(size: number): Axis<Domain>;
tickSizeInner(size: number): this;
/**
* Get the current outer tick size, which defaults to 6.
@@ -240,7 +239,7 @@ export interface Axis<Domain> {
*
* @param size Tick size in pixels (Default is 6).
*/
tickSizeOuter(size: number): Axis<Domain>;
tickSizeOuter(size: number): this;
/**
* Get the current padding, which defaults to 3.
@@ -252,7 +251,7 @@ export interface Axis<Domain> {
*
* @param padding Padding in pixels (Default is 3).
*/
tickPadding(padding: number): Axis<Domain>;
tickPadding(padding: number): this;
}
+15 -15
View File
@@ -1,9 +1,9 @@
// Type definitions for D3JS d3-brush module 1.0.1
// Project: https://github.com/d3/d3-brush/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ArrayLike, Selection, TransitionLike } from 'd3-selection';
import { ArrayLike, Selection, TransitionLike, ValueFn } from 'd3-selection';
/**
* Type alias for a BrushSelection. For a two-dimensional brush, it must be defined as [[x0, y0], [x1, y1]],
@@ -15,20 +15,20 @@ export type BrushSelection = [[number, number], [number, number]] | [number, num
export interface BrushBehavior<Datum> {
(group: Selection<SVGGElement, Datum, any, any>, ...args: any[]): void;
move(group: Selection<SVGGElement, Datum, any, any>, selection: BrushSelection): BrushBehavior<Datum>;
move(group: Selection<SVGGElement, Datum, any, any>, selection: (this: SVGGElement, d?: Datum, i?: number, group?: Array<SVGGElement> | ArrayLike<SVGGElement>) => BrushSelection): BrushBehavior<Datum>;
move(group: TransitionLike<SVGGElement, Datum>, selection: BrushSelection): BrushBehavior<Datum>;
move(group: TransitionLike<SVGGElement, Datum>, selection: (this: SVGGElement, d?: Datum, i?: number, group?: Array<SVGGElement> | ArrayLike<SVGGElement>) => BrushSelection): BrushBehavior<Datum>;
extent(): (this: SVGGElement, d: Datum, i: number, group: Array<SVGGElement> | ArrayLike<SVGGElement>) => [[number, number], [number, number]];
extent(extent: [[number, number], [number, number]]): BrushBehavior<Datum>;
extent(extent: (this: SVGGElement, d: Datum, i: number, group: Array<SVGGElement> | ArrayLike<SVGGElement>) => [[number, number], [number, number]]): BrushBehavior<Datum>;
filter(): (this: SVGGElement, datum: Datum, index: number, group: Array<SVGGElement> | ArrayLike<SVGGElement>) => boolean;
filter(filterFn: (this: SVGGElement, datum: Datum, index: number, group: Array<SVGGElement> | ArrayLike<SVGGElement>) => boolean): BrushBehavior<Datum>;
move(group: Selection<SVGGElement, Datum, any, any>, selection: BrushSelection): void;
move(group: Selection<SVGGElement, Datum, any, any>, selection: ValueFn<SVGGElement, Datum, BrushSelection>): void;
move(group: TransitionLike<SVGGElement, Datum>, selection: BrushSelection): void;
move(group: TransitionLike<SVGGElement, Datum>, selection: ValueFn<SVGGElement, Datum, BrushSelection>): void;
extent(): ValueFn<SVGGElement, Datum, [[number, number], [number, number]]>;
extent(extent: [[number, number], [number, number]]): this;
extent(extent: ValueFn<SVGGElement, Datum, [[number, number], [number, number]]>): this;
filter(): ValueFn<SVGGElement, Datum, boolean>;
filter(filterFn: ValueFn<SVGGElement, Datum, boolean>): this;
handleSize(): number;
handleSize(size: number): BrushBehavior<Datum>;
on(typenames: string): (this: SVGGElement, datum: Datum, index: number, group: Array<SVGGElement> | ArrayLike<SVGGElement>) => void;
on(typenames: string, callback: null): BrushBehavior<Datum>;
on(typenames: string, callback: (this: SVGGElement, datum: Datum, index: number, group: Array<SVGGElement> | ArrayLike<SVGGElement>) => void): BrushBehavior<Datum>;
handleSize(size: number): this;
on(typenames: string): ValueFn<SVGGElement, Datum, void>;
on(typenames: string, callback: null): this;
on(typenames: string, callback: ValueFn<SVGGElement, Datum, void>): this;
}
+18 -18
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-chord module 1.0.0
// Project: https://github.com/d3/d3-chord/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// ---------------------------------------------------------------------
@@ -34,16 +34,16 @@ export interface Chords extends Array<Chord> {
export interface ChordLayout {
(matrix: number[][]): Chords;
padAngle(): number;
padAngle(angle: number): ChordLayout;
padAngle(angle: number): this;
sortGroups(): ((a: number, b: number) => number) | null;
sortGroups(compare: null): ChordLayout;
sortGroups(compare: (a: number, b: number) => number): ChordLayout;
sortGroups(compare: null): this;
sortGroups(compare: (a: number, b: number) => number): this;
sortSubgroups(): ((a: number, b: number) => number) | null;
sortSubgroups(compare: null): ChordLayout;
sortSubgroups(compare: (a: number, b: number) => number): ChordLayout;
sortSubgroups(compare: null): this;
sortSubgroups(compare: (a: number, b: number) => number): this;
sortChords(): ((a: number, b: number) => number) | null;
sortChords(compare: null): ChordLayout;
sortChords(compare: (a: number, b: number) => number): ChordLayout;
sortChords(compare: null): this;
sortChords(compare: (a: number, b: number) => number): this;
}
export function chord(): ChordLayout;
@@ -56,21 +56,21 @@ export function chord(): ChordLayout;
export interface RibbonGenerator<This, ChordDatum, ChordSubgroupDatum> {
(this: This, d: ChordDatum, ...args: any[]): string | undefined;
source(): (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum;
source(source: (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
source(source: (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum): this;
target(): (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum;
target(target: (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
target(target: (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum): this;
radius(): (this: This, d: ChordSubgroupDatum, ...args: any[]) => number;
radius(radius: number): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
radius(radius: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
radius(radius: number): this;
radius(radius: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): this;
startAngle(): (this: This, d: ChordSubgroupDatum, ...args: any[]) => number;
startAngle(angle: number): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
startAngle(angle: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
startAngle(angle: number): this;
startAngle(angle: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): this;
endAngle(): (this: This, d: ChordSubgroupDatum, ...args: any[]) => number;
endAngle(angle: number): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
endAngle(angle: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
endAngle(angle: number): this;
endAngle(angle: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): this;
context(): CanvasRenderingContext2D | null;
context(context: CanvasRenderingContext2D): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
context(context: null): RibbonGenerator<This, ChordDatum, ChordSubgroupDatum>;
context(context: CanvasRenderingContext2D): this;
context(context: null): this;
}
export function ribbon(): RibbonGenerator<any, Chord, ChordSubgroup>;
+5 -5
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-collection module 1.0.0
// Project: https://github.com/d3/d3-collection/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
@@ -104,10 +104,10 @@ export interface NestedObject<Datum, RollupType> {
}
interface Nest<Datum, RollupType> {
key(func: (datum: Datum) => string): Nest<Datum, RollupType>;
sortKeys(comparator: (a: string, b: string) => number): Nest<Datum, RollupType>;
sortValues(comparator: (a: Datum, b: Datum) => number): Nest<Datum, RollupType>;
rollup(func: (values: Datum[]) => RollupType): Nest<Datum, RollupType>;
key(func: (datum: Datum) => string): this;
sortKeys(comparator: (a: string, b: string) => number): this;
sortValues(comparator: (a: Datum, b: Datum) => number): this;
rollup(func: (values: Datum[]) => RollupType): this;
map(array: Datum[]): Map<any>; // more specifically it returns NestedMap<Datum, RollupType>
object(array: Datum[]): { [key: string]: any }; // more specifically it returns NestedObject<Datum, RollupType>
entries(array: Datum[]): Array<{ key: string; values: any; value: RollupType | undefined }>; // more specifically it returns NestedArray<Datum, RollupType>
+28 -18
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-color module 1.0.0
// Project: https://github.com/d3/d3-color/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// ---------------------------------------------------------------------------
@@ -12,6 +12,17 @@
*/
export type ColorSpaceObject = RGBColor | HSLColor | LabColor | HCLColor | CubehelixColor;
/**
* A helper interface of methods common to color objects (including colors defined outside the d3-color standard module,
* e.g. in d3-hsv). This interface
*/
export interface ColorCommonInstance {
displayable(): boolean;
toString(): string;
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
}
export interface Color {
displayable(): boolean; // Note: While this method is used in prototyping for colors of specific colorspaces, it should not be called directly, as 'this.rgb' would not be implemented on Color
@@ -20,7 +31,7 @@ export interface Color {
export interface ColorFactory extends Function {
(cssColorSpecifier: string): RGBColor | HSLColor;
(color: ColorSpaceObject): RGBColor | HSLColor;
(color: ColorSpaceObject | ColorCommonInstance): RGBColor | HSLColor;
// prototype: Color;
}
@@ -29,8 +40,8 @@ export interface RGBColor extends Color {
g: number;
b: number;
opacity: number;
brighter(k?: number): RGBColor;
darker(k?: number): RGBColor;
brighter(k?: number): this;
darker(k?: number): this;
displayable(): boolean;
rgb(): RGBColor;
toString(): string;
@@ -39,7 +50,7 @@ export interface RGBColor extends Color {
export interface RGBColorFactory extends Function {
(r: number, g: number, b: number, opacity?: number): RGBColor;
(cssColorSpecifier: string): RGBColor;
(color: ColorSpaceObject): RGBColor;
(color: ColorSpaceObject | ColorCommonInstance): RGBColor;
// prototype: RGBColor;
}
@@ -48,8 +59,8 @@ export interface HSLColor extends Color {
s: number;
l: number;
opacity: number;
brighter(k?: number): HSLColor;
darker(k?: number): HSLColor;
brighter(k?: number): this;
darker(k?: number): this;
displayable(): boolean;
rgb(): RGBColor;
}
@@ -57,7 +68,7 @@ export interface HSLColor extends Color {
export interface HSLColorFactory extends Function {
(h: number, s: number, l: number, opacity?: number): HSLColor;
(cssColorSpecifier: string): HSLColor;
(color: ColorSpaceObject): HSLColor;
(color: ColorSpaceObject | ColorCommonInstance): HSLColor;
// prototype: HSLColor;
}
@@ -66,15 +77,15 @@ export interface LabColor extends Color {
a: number;
b: number;
opacity: number;
brighter(k?: number): LabColor;
darker(k?: number): LabColor;
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
}
export interface LabColorFactory extends Function {
(l: number, a: number, b: number, opacity?: number): LabColor;
(cssColorSpecifier: string): LabColor;
(color: ColorSpaceObject): LabColor;
(color: ColorSpaceObject | ColorCommonInstance): LabColor;
// prototype: LabColor;
}
@@ -83,15 +94,15 @@ export interface HCLColor extends Color {
c: number;
l: number;
opacity: number;
brighter(k?: number): HCLColor;
darker(k?: number): HCLColor;
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
}
export interface HCLColorFactory extends Function {
(h: number, l: number, c: number, opacity?: number): HCLColor;
(cssColorSpecifier: string): HCLColor;
(color: ColorSpaceObject): HCLColor;
(color: ColorSpaceObject | ColorCommonInstance): HCLColor;
// prototype: HCLColor;
}
@@ -100,15 +111,15 @@ export interface CubehelixColor extends Color {
s: number;
l: number;
opacity: number;
brighter(k?: number): CubehelixColor;
darker(k?: number): CubehelixColor;
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
}
export interface CubehelixColorFactory extends Function {
(h: number, s: number, l: number, opacity?: number): CubehelixColor;
(cssColorSpecifier: string): CubehelixColor;
(color: ColorSpaceObject): CubehelixColor;
(color: ColorSpaceObject | ColorCommonInstance): CubehelixColor;
// prototype: CubehelixColor;
}
@@ -127,4 +138,3 @@ export var lab: LabColorFactory;
export var hcl: HCLColorFactory;
export var cubehelix: CubehelixColorFactory;
+3 -3
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-dispatch module 1.0.0
// Project: https://github.com/d3/d3-dispatch/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface Dispatch<T extends EventTarget> {
@@ -9,8 +9,8 @@ export interface Dispatch<T extends EventTarget> {
copy(): Dispatch<T>;
on(typenames: string): (this: T, ...args: any[]) => void;
on(typenames: string, callback: null): Dispatch<T>;
on(typenames: string, callback: (this: T, ...args: any[]) => void): Dispatch<T>;
on(typenames: string, callback: null): this;
on(typenames: string, callback: (this: T, ...args: any[]) => void): this;
}
export function dispatch<T extends EventTarget>(...types: string[]): Dispatch<T>;
+15 -15
View File
@@ -1,9 +1,9 @@
// Type definitions for D3JS d3-drag module 1.0.0
// Project: https://github.com/d3/d3-drag/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ArrayLike, Selection } from 'd3-selection';
import { ArrayLike, Selection, ValueFn } from 'd3-selection';
// --------------------------------------------------------------------------
@@ -35,16 +35,16 @@ export interface SubjectPosition {
export interface DragBehavior<GElement extends DraggedElementBaseType, Datum, Subject> extends Function {
(selection: Selection<GElement, Datum, any, any>, ...args: any[]): void;
container(): (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => DragContainerElement;
container(accessor: (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => DragContainerElement): DragBehavior<GElement, Datum, Subject>;
container(container: DragContainerElement): DragBehavior<GElement, Datum, Subject>;
filter(): (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => boolean;
filter(filterFn: (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => boolean): DragBehavior<GElement, Datum, Subject>;
subject(): (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => Subject;
subject(accessor: (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => Subject): DragBehavior<GElement, Datum, Subject>;
on(typenames: string): (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => any;
on(typenames: string, callback: null): DragBehavior<GElement, Datum, Subject>;
on(typenames: string, callback: (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => any): DragBehavior<GElement, Datum, Subject>;
container(): ValueFn<GElement, Datum, DragContainerElement>;
container(accessor: ValueFn<GElement, Datum, DragContainerElement>): this;
container(container: DragContainerElement): this;
filter(): ValueFn<GElement, Datum, boolean>;
filter(filterFn: ValueFn<GElement, Datum, boolean>): this;
subject(): ValueFn<GElement, Datum, Subject>;
subject(accessor: ValueFn<GElement, Datum, Subject>): this;
on(typenames: string): ValueFn<GElement, Datum, void>;
on(typenames: string, callback: null): this;
on(typenames: string, callback: ValueFn<GElement, Datum, void>): this;
}
export function drag<GElement extends DraggedElementBaseType, Datum>(): DragBehavior<GElement, Datum, Datum | SubjectPosition>;
@@ -62,9 +62,9 @@ export interface D3DragEvent<GElement extends DraggedElementBaseType, Datum, Sub
identifier: 'mouse' | number;
active: number;
sourceEvent: any;
on(typenames: string): (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => void;
on(typenames: string, callback: null): D3DragEvent<GElement, Datum, Subject>;
on(typenames: string, callback: (this: GElement, datum?: Datum, index?: number, group?: Array<GElement> | ArrayLike<GElement>) => void): D3DragEvent<GElement, Datum, Subject>;
on(typenames: string): ValueFn<GElement, Datum, void>;
on(typenames: string, callback: null): this;
on(typenames: string, callback: ValueFn<GElement, Datum, void>): this;
}
export function dragDisable(window: Window): void;
+38 -38
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-ease module 1.0.0
// Project: https://github.com/d3/d3-ease/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// --------------------------------------------------------------------------
@@ -8,49 +8,49 @@
// --------------------------------------------------------------------------
export function easeLinear(normalizedTime: number): number;
export function easeLinear(normalizedTime: number): number;
export function easeQuad(normalizedTime: number): number;
export function easeQuadIn(normalizedTime: number): number;
export function easeQuadOut(normalizedTime: number): number;
export function easeQuadInOut(normalizedTime: number): number;
export function easeQuad(normalizedTime: number): number;
export function easeQuadIn(normalizedTime: number): number;
export function easeQuadOut(normalizedTime: number): number;
export function easeQuadInOut(normalizedTime: number): number;
export function easeCubic(normalizedTime: number): number;
export function easeCubicIn(normalizedTime: number): number;
export function easeCubicOut(normalizedTime: number): number;
export function easeCubicInOut(normalizedTime: number): number;
export function easeCubic(normalizedTime: number): number;
export function easeCubicIn(normalizedTime: number): number;
export function easeCubicOut(normalizedTime: number): number;
export function easeCubicInOut(normalizedTime: number): number;
export function easePoly(normalizedTime: number): number;
export function easePolyIn(normalizedTime: number): number;
export function easePolyOut(normalizedTime: number): number;
export function easePolyInOut(normalizedTime: number): number;
export function easePoly(normalizedTime: number): number;
export function easePolyIn(normalizedTime: number): number;
export function easePolyOut(normalizedTime: number): number;
export function easePolyInOut(normalizedTime: number): number;
export function easeSin(normalizedTime: number): number;
export function easeSinIn(normalizedTime: number): number;
export function easeSinOut(normalizedTime: number): number;
export function easeSinInOut(normalizedTime: number): number;
export function easeSin(normalizedTime: number): number;
export function easeSinIn(normalizedTime: number): number;
export function easeSinOut(normalizedTime: number): number;
export function easeSinInOut(normalizedTime: number): number;
export function easeExp(normalizedTime: number): number;
export function easeExpIn(normalizedTime: number): number;
export function easeExpOut(normalizedTime: number): number;
export function easeExpInOut(normalizedTime: number): number;
export function easeExp(normalizedTime: number): number;
export function easeExpIn(normalizedTime: number): number;
export function easeExpOut(normalizedTime: number): number;
export function easeExpInOut(normalizedTime: number): number;
export function easeCircle(normalizedTime: number): number;
export function easeCircleIn(normalizedTime: number): number;
export function easeCircleOut(normalizedTime: number): number;
export function easeCircleInOut(normalizedTime: number): number;
export function easeCircle(normalizedTime: number): number;
export function easeCircleIn(normalizedTime: number): number;
export function easeCircleOut(normalizedTime: number): number;
export function easeCircleInOut(normalizedTime: number): number;
export function easeBounce(normalizedTime: number): number;
export function easeBounceIn(normalizedTime: number): number;
export function easeBounceOut(normalizedTime: number): number;
export function easeBounceInOut(normalizedTime: number): number;
export function easeBounce(normalizedTime: number): number;
export function easeBounceIn(normalizedTime: number): number;
export function easeBounceOut(normalizedTime: number): number;
export function easeBounceInOut(normalizedTime: number): number;
export function easeBack(normalizedTime: number): number;
export function easeBackIn(normalizedTime: number): number;
export function easeBackOut(normalizedTime: number): number;
export function easeBackInOut(normalizedTime: number): number;
export function easeBack(normalizedTime: number): number;
export function easeBackIn(normalizedTime: number): number;
export function easeBackOut(normalizedTime: number): number;
export function easeBackInOut(normalizedTime: number): number;
export function easeElastic(normalizedTime: number): number;
export function easeElasticIn(normalizedTime: number): number;
export function easeElasticOut(normalizedTime: number): number;
export function easeElasticInOut(normalizedTime: number): number;
export function easeElastic(normalizedTime: number): number;
export function easeElasticIn(normalizedTime: number): number;
export function easeElasticOut(normalizedTime: number): number;
export function easeElasticInOut(normalizedTime: number): number;
+11 -7
View File
@@ -452,22 +452,26 @@ nodeLinkSimulation
let f: d3Force.Force<SimNode, SimLink>;
// getter with generic force returned
f = nodeLinkSimulation.force('charge');
f = nodeLinkSimulation.force('link');
// getter with force type cast to improve return type specificity
let fLink: d3Force.ForceLink<SimNode, SimLink>;
// fLink = nodeLinkSimulation.force('link'); // fails, as ForceLink specific properties are missing from 'generic' force
// Need explicit, careful type casting to a specific force type
fLink = <d3Force.ForceLink<SimNode, SimLink>>nodeLinkSimulation.force('link');
fLink = nodeLinkSimulation.force<d3Force.ForceLink<SimNode, SimLink>>('link');
// This is mainly an issue for ForceLinks, if once wants to get the links from an initialized force
// or re-set new links for an initialized force, e.g.:
simLinks = (<d3Force.ForceLink<SimNode, SimLink>>nodeLinkSimulation.force('link')).links();
simLinks = nodeLinkSimulation.force<d3Force.ForceLink<SimNode, SimLink>>('link').links();
// fLink = nodeLinkSimulation.force('link'); // fails, as ForceLink specific properties are missing from 'generic' force
// The same could be followed for custom forces.
// on() --------------------------------------------------------------------------------
@@ -511,11 +515,11 @@ nodeSimulation = nodeSimulation.on('tick', null);
// restart() --------------------------------------------------------------------------
nodeLinkSimulation.restart();
nodeLinkSimulation = nodeLinkSimulation.restart();
// stop() -----------------------------------------------------------------------------
nodeLinkSimulation.stop();
nodeLinkSimulation = nodeLinkSimulation.stop();
// tick() -----------------------------------------------------------------------------
+42 -42
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-force module 1.0.0
// Project: https://github.com/d3/d3-force/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -31,28 +31,28 @@ export interface SimulationLinkDatum<NodeDatum extends SimulationNodeDatum> {
}
export interface Simulation<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>> {
restart(): Simulation<NodeDatum, LinkDatum>;
stop(): Simulation<NodeDatum, LinkDatum>;
tick(): Simulation<NodeDatum, LinkDatum>;
restart(): this;
stop(): this;
tick(): void;
nodes(): Array<NodeDatum>;
nodes(nodesData: Array<NodeDatum>): Simulation<NodeDatum, LinkDatum>;
nodes(nodesData: Array<NodeDatum>): this;
alpha(): number;
alpha(alpha: number): Simulation<NodeDatum, LinkDatum>;
alpha(alpha: number): this;
alphaMin(): number;
alphaMin(min: number): Simulation<NodeDatum, LinkDatum>;
alphaMin(min: number): this;
alphaDecay(): number;
alphaDecay(decay: number): Simulation<NodeDatum, LinkDatum>;
alphaDecay(decay: number): this;
alphaTarget(): number;
alphaTarget(target: number): Simulation<NodeDatum, LinkDatum>;
alphaTarget(target: number): this;
velocityDecay(): number;
velocityDecay(decay: number): Simulation<NodeDatum, LinkDatum>;
force(name: string): Force<NodeDatum, LinkDatum>; // force names are arbitrary, so return type inference is not possible
force(name: string, force: null): Simulation<NodeDatum, LinkDatum>;
force(name: string, force: Force<NodeDatum, LinkDatum>): Simulation<NodeDatum, LinkDatum>;
velocityDecay(decay: number): this;
force<F extends Force<NodeDatum, LinkDatum>>(name: string): F; // force names are arbitrary, so return type inference is not possible
force(name: string, force: null): this;
force(name: string, force: Force<NodeDatum, LinkDatum>): this;
find(x: number, y: number, radius?: number): NodeDatum | undefined;
on(typenames: 'tick' | 'end' | string): (this: Simulation<NodeDatum, LinkDatum>) => void;
on(typenames: 'tick' | 'end' | string, listener: null): Simulation<NodeDatum, LinkDatum>;
on(typenames: 'tick' | 'end' | string, listener: (this: this) => void): Simulation<NodeDatum, LinkDatum>;
on(typenames: 'tick' | 'end' | string, listener: null): this;
on(typenames: 'tick' | 'end' | string, listener: (this: this) => void): this;
}
export function forceSimulation<NodeDatum extends SimulationNodeDatum>(nodesData?: Array<NodeDatum>): Simulation<NodeDatum, undefined>;
@@ -65,7 +65,7 @@ export function forceSimulation<NodeDatum extends SimulationNodeDatum, LinkDatum
export interface Force<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>> {
(alpha: number): void;
initialize(nodes: Array<NodeDatum>): void;
initialize?(nodes: Array<NodeDatum>): void;
}
@@ -73,9 +73,9 @@ export interface Force<NodeDatum extends SimulationNodeDatum, LinkDatum extends
export interface ForceCenter<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
x(): number;
x(x: number): ForceCenter<NodeDatum>;
x(x: number): this;
y(): number;
y(y: number): ForceCenter<NodeDatum>;
y(y: number): this;
}
export function forceCenter<NodeDatum extends SimulationNodeDatum>(x?: number, y?: number): ForceCenter<NodeDatum>;
@@ -84,12 +84,12 @@ export function forceCenter<NodeDatum extends SimulationNodeDatum>(x?: number, y
export interface ForceCollide<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
radius(): (node: NodeDatum, i: number, nodes: Array<NodeDatum>) => number;
radius(radius: number): ForceCollide<NodeDatum>;
radius(radius: (node: NodeDatum, i: number, nodes: Array<NodeDatum>) => number): ForceCollide<NodeDatum>;
radius(radius: number): this;
radius(radius: (node: NodeDatum, i: number, nodes: Array<NodeDatum>) => number): this;
strength(): number;
strength(strength: number): ForceCollide<NodeDatum>;
strength(strength: number): this;
iterations(): number;
iterations(iterations: number): ForceCollide<NodeDatum>;
iterations(iterations: number): this;
}
export function forceCollide<NodeDatum extends SimulationNodeDatum>(): ForceCollide<NodeDatum>;
@@ -100,17 +100,17 @@ export function forceCollide<NodeDatum extends SimulationNodeDatum>(radius: (nod
export interface ForceLink<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>> extends Force<NodeDatum, LinkDatum> {
links(): Array<LinkDatum>;
links(links: Array<LinkDatum>): ForceLink<NodeDatum, LinkDatum>;
links(links: Array<LinkDatum>): this;
id(): (node: NodeDatum, i: number, nodesData: Array<NodeDatum>) => (string | number);
id(id: (node: NodeDatum, i: number, nodesData: Array<NodeDatum>) => string): ForceLink<NodeDatum, LinkDatum>;
id(id: (node: NodeDatum, i: number, nodesData: Array<NodeDatum>) => string): this;
distance(): (link: LinkDatum, i: number, links: Array<LinkDatum>) => number;
distance(distance: number): ForceLink<NodeDatum, LinkDatum>;
distance(distance: (link: LinkDatum, i: number, links: Array<LinkDatum>) => number): ForceLink<NodeDatum, LinkDatum>;
distance(distance: number): this;
distance(distance: (link: LinkDatum, i: number, links: Array<LinkDatum>) => number): this;
strength(): (link: LinkDatum, i: number, links: Array<LinkDatum>) => number;
strength(strength: number): ForceLink<NodeDatum, LinkDatum>;
strength(strength: (link: LinkDatum, i: number, links: Array<LinkDatum>) => number): ForceLink<NodeDatum, LinkDatum>;
strength(strength: number): this;
strength(strength: (link: LinkDatum, i: number, links: Array<LinkDatum>) => number): this;
iterations(): number;
iterations(iterations: number): ForceLink<NodeDatum, LinkDatum>;
iterations(iterations: number): this;
}
export function forceLink<NodeDatum extends SimulationNodeDatum, LinksDatum extends SimulationLinkDatum<NodeDatum>>(): ForceLink<NodeDatum, LinksDatum>;
@@ -120,14 +120,14 @@ export function forceLink<NodeDatum extends SimulationNodeDatum, LinksDatum exte
export interface ForceManyBody<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
strength(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
strength(strength: number): ForceManyBody<NodeDatum>;
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForceManyBody<NodeDatum>;
strength(strength: number): this;
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): this;
theta(): number;
theta(theta: number): ForceManyBody<NodeDatum>;
theta(theta: number): this;
distanceMin(): number;
distanceMin(distance: number): ForceManyBody<NodeDatum>;
distanceMin(distance: number): this;
distanceMax(): number;
distanceMax(distance: number): ForceManyBody<NodeDatum>;
distanceMax(distance: number): this;
}
export function forceManyBody<NodeDatum extends SimulationNodeDatum>(): ForceManyBody<NodeDatum>;
@@ -136,11 +136,11 @@ export function forceManyBody<NodeDatum extends SimulationNodeDatum>(): ForceMan
export interface ForceX<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
strength(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
strength(strength: number): ForceX<NodeDatum>;
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForceX<NodeDatum>;
strength(strength: number): this;
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): this;
x(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
x(x: number): ForceX<NodeDatum>;
x(x: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForceX<NodeDatum>;
x(x: number): this;
x(x: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): this;
}
export function forceX<NodeDatum extends SimulationNodeDatum>(): ForceX<NodeDatum>;
@@ -149,11 +149,11 @@ export function forceX<NodeDatum extends SimulationNodeDatum>(x: (d: NodeDatum,
export interface ForceY<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
strength(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
strength(strength: number): ForceY<NodeDatum>;
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForceY<NodeDatum>;
strength(strength: number): this;
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): this;
y(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
y(y: number): ForceY<NodeDatum>;
y(y: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForceY<NodeDatum>;
y(y: number): this;
y(y: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): this;
}
export function forceY<NodeDatum extends SimulationNodeDatum>(): ForceY<NodeDatum>;
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-format module 1.0.0
// Project: https://github.com/d3/d3-format/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
+625
View File
@@ -0,0 +1,625 @@
/**
* Typescript definition tests for d3/d3-geo module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Geo from 'd3-geo';
import { Selection } from 'd3-selection';
// ----------------------------------------------------------------------
// Tests setup
// ----------------------------------------------------------------------
interface SampleProperties1 {
name: string;
}
interface SampleProperties2 {
name: string;
value: number;
}
const samplePolygon: GeoJSON.Polygon = {
type: 'Polygon',
coordinates: [
[[0, 0], [0, 90], [90, 0], [0, 0]]
]
};
const sampleSphere: d3Geo.GeoSphere = {
type: 'Sphere'
};
const sampleGeometryCollection: GeoJSON.GeometryCollection = {
type: 'GeometryCollection',
geometries: [
samplePolygon,
samplePolygon
]
};
const sampleExtendedGeometryCollection: d3Geo.ExtendedGeometryCollection<GeoJSON.Polygon | d3Geo.GeoSphere> = {
type: 'GeometryCollection',
geometries: [
samplePolygon,
sampleSphere
]
};
const sampleFeature: GeoJSON.Feature<GeoJSON.Polygon> = {
type: 'Feature',
geometry: samplePolygon,
properties: {
name: 'Alabama'
}
};
const sampleExtendedFeature1: d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1> = {
type: 'Feature',
geometry: samplePolygon,
properties: {
name: 'Alabama'
}
};
const sampleExtendedFeature2: d3Geo.ExtendedFeature<d3Geo.GeoSphere, SampleProperties2> = {
type: 'Feature',
geometry: sampleSphere,
properties: {
name: 'earth',
value: 42
}
};
const sampleFeatureCollection: GeoJSON.FeatureCollection<GeoJSON.Polygon> = {
type: 'FeatureCollection',
features: [
sampleFeature,
sampleFeature
]
};
const sampleExtendedFeatureCollection: d3Geo.ExtendedFeatureCollection<d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1> | d3Geo.ExtendedFeature<d3Geo.GeoSphere, SampleProperties2>> = {
type: 'FeatureCollection',
features: [
sampleExtendedFeature1,
sampleExtendedFeature2
]
};
// ----------------------------------------------------------------------
// Spherical Math
// ----------------------------------------------------------------------
// geoArea(...) =========================================================
let area: number = d3Geo.geoArea(samplePolygon);
area = d3Geo.geoArea(sampleSphere);
area = d3Geo.geoArea(sampleGeometryCollection);
area = d3Geo.geoArea(sampleExtendedGeometryCollection);
area = d3Geo.geoArea(sampleFeature);
area = d3Geo.geoArea(sampleExtendedFeature1);
area = d3Geo.geoArea(sampleExtendedFeature2);
area = d3Geo.geoArea(sampleFeatureCollection);
area = d3Geo.geoArea(sampleExtendedFeatureCollection);
// geoBounds(...) =========================================================
let bounds: [[number, number], [number, number]] = d3Geo.geoBounds(samplePolygon);
bounds = d3Geo.geoBounds(sampleSphere);
bounds = d3Geo.geoBounds(sampleGeometryCollection);
bounds = d3Geo.geoBounds(sampleExtendedGeometryCollection);
bounds = d3Geo.geoBounds(sampleFeature);
bounds = d3Geo.geoBounds(sampleExtendedFeature1);
bounds = d3Geo.geoBounds(sampleExtendedFeature2);
bounds = d3Geo.geoBounds(sampleFeatureCollection);
bounds = d3Geo.geoBounds(sampleExtendedFeatureCollection);
// geoCentroid(...) =======================================================
let centroid: [number, number] = d3Geo.geoCentroid(samplePolygon);
centroid = d3Geo.geoCentroid(sampleSphere);
centroid = d3Geo.geoCentroid(sampleGeometryCollection);
centroid = d3Geo.geoCentroid(sampleExtendedGeometryCollection);
centroid = d3Geo.geoCentroid(sampleFeature);
centroid = d3Geo.geoCentroid(sampleExtendedFeature1);
centroid = d3Geo.geoCentroid(sampleExtendedFeature2);
centroid = d3Geo.geoCentroid(sampleFeatureCollection);
centroid = d3Geo.geoCentroid(sampleExtendedFeatureCollection);
// geoDistance(...) =======================================================
let distance: number = d3Geo.geoDistance([54, 2], [53, 1]);
// geoLength(...) =========================================================
let length: number = d3Geo.geoLength(samplePolygon);
length = d3Geo.geoLength(sampleSphere);
length = d3Geo.geoLength(sampleGeometryCollection);
length = d3Geo.geoLength(sampleExtendedGeometryCollection);
length = d3Geo.geoLength(sampleFeature);
length = d3Geo.geoLength(sampleExtendedFeature1);
length = d3Geo.geoLength(sampleExtendedFeature2);
length = d3Geo.geoLength(sampleFeatureCollection);
length = d3Geo.geoLength(sampleExtendedFeatureCollection);
// geoInterpolate(...) ====================================================
let interpolateFct: (t: number) => [number, number] = d3Geo.geoInterpolate([54, 2], [53, 1]);
// geoRotation(...) =======================================================
// create rotation -----------------------------------------------------
let rotation: d3Geo.GeoRotation = d3Geo.geoRotation([90, 45]);
let rotation2: d3Geo.GeoRotation = d3Geo.geoRotation([90, 45, 27.5]);
// use rotation --------------------------------------------------------
let point: [number, number] = rotation([54, 2]);
let inverted: [number, number] = rotation.invert([54, 2]);
// ----------------------------------------------------------------------
// Spherical Shapes - geoCircle
// ----------------------------------------------------------------------
// Create GeoCircleGenerator ============================================
// simple use case
let circleGeneratorSimple: d3Geo.GeoCircleGenerator<any, any> = d3Geo.geoCircle();
// complex use as part of object
class Circulator {
constructor(radius: number, precision: number) {
this.r = radius;
this.p = precision;
this.circleGenerator = d3Geo.geoCircle<Circulator, [number, number] | undefined>()
.radius(function (datum) {
let t: Circulator = this;
let d: [number, number] | undefined = datum;
return this.r;
})
.precision(function (datum) {
let t: Circulator = this;
let d: [number, number] | undefined = datum;
return this.p;
})
.center(function (datum) {
let t: Circulator = this;
let d: [number, number] | undefined = datum;
return d ? d : [0, 0];
});
}
private r: number;
private p: number;
private circleGenerator: d3Geo.GeoCircleGenerator<Circulator, [number, number] | undefined>;
public getCirclePolygon(center?: [number, number]): GeoJSON.Polygon {
if (center && center.length === 2 && typeof center[0] === 'number' && typeof center[1] === 'number') {
return this.circleGenerator(center);
} else {
return this.circleGenerator();
}
}
}
let circulator = new Circulator(50, 2);
// Configure CircleGenerator ============================================
// center(...) ----------------------------------------------------------
let centerFctSimple: ((this: any, d: any, ...args: any[]) => [number, number]) = circleGeneratorSimple.center();
let c: [number, number] = [54, 2];
circleGeneratorSimple = circleGeneratorSimple.center(() => c);
circleGeneratorSimple = circleGeneratorSimple.center(c);
// radius(...) -----------------------------------------------------------
let radius: ((...args: any[]) => number) = circleGeneratorSimple.radius();
circleGeneratorSimple = circleGeneratorSimple.radius(() => 5);
circleGeneratorSimple = circleGeneratorSimple.radius(2);
// precision(...) --------------------------------------------------------
let precision: ((...args: any[]) => number) = circleGeneratorSimple.precision();
circleGeneratorSimple = circleGeneratorSimple.precision(() => 5);
circleGeneratorSimple = circleGeneratorSimple.precision(2);
// Use CircleGenerator ====================================================
// use simple geoCircleGenerator
let circlePolygon: GeoJSON.Polygon = circleGeneratorSimple();
// use encapsulated geoCircleGenerator
circlePolygon = circulator.getCirclePolygon([5, 5]);
circlePolygon = circulator.getCirclePolygon();
// ----------------------------------------------------------------------
// Spherical Shapes - geoGraticule
// ----------------------------------------------------------------------
// Create GeoGraticuleGenerator =========================================
let graticuleGenerator: d3Geo.GeoGraticuleGenerator = d3Geo.geoGraticule();
// Configure GeoGraticuleGenerator =======================================
// extent(...) -----------------------------------------------------------
let extent: [[number, number], [number, number]] = graticuleGenerator.extent();
graticuleGenerator = graticuleGenerator.extent([[-180, -80], [180, 80]]);
// extentMajor(...) ---------------------------------------------------------
let extentMajor: [[number, number], [number, number]] = graticuleGenerator.extentMajor();
graticuleGenerator = graticuleGenerator.extentMajor([[-180, -80], [180, 80]]);
// extentMinor(...) ---------------------------------------------------------
let extentMinor: [[number, number], [number, number]] = graticuleGenerator.extentMinor();
graticuleGenerator = graticuleGenerator.extentMinor([[-180, -80], [180, 80]]);
// step(...) ----------------------------------------------------------------
let step: [number, number] = graticuleGenerator.step();
graticuleGenerator = graticuleGenerator.step([10, 10]);
// stepMajor(...) -----------------------------------------------------------
let stepMajor: [number, number] = graticuleGenerator.stepMajor();
graticuleGenerator = graticuleGenerator.stepMajor([10, 10]);
// stepMinor(...) ------------------------------------------------------------
let stepMinor: [number, number] = graticuleGenerator.stepMinor();
graticuleGenerator = graticuleGenerator.stepMinor([10, 10]);
// precision(...) -------------------------------------------------------------
let precision1: number = graticuleGenerator.precision();
graticuleGenerator = graticuleGenerator.precision(5);
// Use GeoGraticuleGenerator ============================================
let multiString: GeoJSON.MultiLineString = graticuleGenerator();
let lines: GeoJSON.LineString[] = graticuleGenerator.lines();
let polygon2: GeoJSON.Polygon = graticuleGenerator.outline();
// ----------------------------------------------------------------------
// Raw Projections
// ----------------------------------------------------------------------
// Pre-Defined Raw Projection Factories =================================
let azimuthalEqualAreaRaw: d3Geo.GeoRawProjection = d3Geo.geoAzimuthalEqualAreaRaw();
let azimuthalEquidistantRaw: d3Geo.GeoRawProjection = d3Geo.geoAzimuthalEquidistantRaw();
let conicConformalRaw: d3Geo.GeoRawProjection = d3Geo.geoConicConformalRaw(0, 0);
let conicEqualAreaRaw: d3Geo.GeoRawProjection = d3Geo.geoConicEqualAreaRaw(0, 0);
let conicEquidistantRaw: d3Geo.GeoRawProjection = d3Geo.geoConicEquidistantRaw(0, 0);
let equirectangularRaw: d3Geo.GeoRawProjection = d3Geo.geoEquirectangularRaw();
let gnomonicRaw: d3Geo.GeoRawProjection = d3Geo.geoGnomonicRaw();
let mercatorRaw: d3Geo.GeoRawProjection = d3Geo.geoMercatorRaw();
let orthographicRaw: d3Geo.GeoRawProjection = d3Geo.geoOrthographicRaw();
let stereographicRaw: d3Geo.GeoRawProjection = d3Geo.geoStereographicRaw();
let transverseMercatorRaw: d3Geo.GeoRawProjection = d3Geo.geoTransverseMercatorRaw();
// Use Raw Projection =====================================================
let rawProjectionPoint: [number, number] = azimuthalEqualAreaRaw(54, 2);
let rawProjectionInvertedPoint: [number, number] = azimuthalEqualAreaRaw.invert(180, 6);
// ----------------------------------------------------------------------
// Pre-Defined Projections
// ----------------------------------------------------------------------
// Create predefined Projection from factory =============================
let albers: d3Geo.GeoConicProjection = d3Geo.geoAlbers();
let albersUsa: d3Geo.GeoProjection = d3Geo.geoAlbersUsa();
let azimuthalEqualArea: d3Geo.GeoProjection = d3Geo.geoAzimuthalEqualArea();
let azimuthalEquidistant: d3Geo.GeoProjection = d3Geo.geoAzimuthalEquidistant();
let conicConformal: d3Geo.GeoConicProjection = d3Geo.geoConicConformal();
let conicEqualArea: d3Geo.GeoConicProjection = d3Geo.geoConicEqualArea();
let conicEquidistant: d3Geo.GeoConicProjection = d3Geo.geoConicEquidistant();
let cquirectangular: d3Geo.GeoProjection = d3Geo.geoEquirectangular();
let gnomonic: d3Geo.GeoProjection = d3Geo.geoGnomonic();
let mercator: d3Geo.GeoProjection = d3Geo.geoMercator();
let orthographic: d3Geo.GeoProjection = d3Geo.geoOrthographic();
let stereographic: d3Geo.GeoProjection = d3Geo.geoStereographic();
let transverseMercator: d3Geo.GeoProjection = d3Geo.geoTransverseMercator();
// ----------------------------------------------------------------------
// Create New Projections
// ----------------------------------------------------------------------
let geoProjection: d3Geo.GeoProjection = d3Geo.geoProjection(azimuthalEqualAreaRaw);
let mutate: () => d3Geo.GeoProjection = d3Geo.geoProjectionMutator(() => azimuthalEqualAreaRaw);
let constructedProjection: d3Geo.GeoProjection = mutate();
// Use Projection ==========================================================
let projected: [number, number] = constructedProjection([54, 2]);
let inverted2: [number, number] = constructedProjection.invert([54, 2]);
// TODO ?????
// let stream: d3Geo.Stream = constructedProjection.stream([54, 2]);
let clipAngle: number = constructedProjection.clipAngle();
constructedProjection = constructedProjection.clipAngle(null);
constructedProjection = constructedProjection.clipAngle(45);
let clipExtent: [[number, number], [number, number]] = constructedProjection.clipExtent();
constructedProjection = constructedProjection.clipExtent(null);
constructedProjection = constructedProjection.clipExtent([[0, 0], [1, 1]]);
let scale: number = constructedProjection.scale();
constructedProjection = constructedProjection.scale(45);
let translate: [number, number] = constructedProjection.translate();
constructedProjection = constructedProjection.translate([480, 250]);
let center: [number, number] = constructedProjection.center();
constructedProjection = constructedProjection.center([0, 0]);
let rotate: [number, number, number] = constructedProjection.rotate();
constructedProjection = constructedProjection.rotate([0, 0]);
constructedProjection = constructedProjection.rotate([0, 0, 0]);
let precision2: number = constructedProjection.precision();
constructedProjection = constructedProjection.precision(0.707);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], samplePolygon);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], sampleSphere);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], sampleGeometryCollection);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], sampleExtendedGeometryCollection);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], sampleFeature);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], sampleExtendedFeature1);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], sampleExtendedFeature2);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], sampleFeatureCollection);
constructedProjection = constructedProjection.fitExtent([[0, 0], [960, 500]], sampleExtendedFeatureCollection);
constructedProjection = constructedProjection.fitSize([960, 500], samplePolygon);
constructedProjection = constructedProjection.fitSize([960, 500], sampleSphere);
constructedProjection = constructedProjection.fitSize([960, 500], sampleGeometryCollection);
constructedProjection = constructedProjection.fitSize([960, 500], sampleExtendedGeometryCollection);
constructedProjection = constructedProjection.fitSize([960, 500], sampleFeature);
constructedProjection = constructedProjection.fitSize([960, 500], sampleExtendedFeature1);
constructedProjection = constructedProjection.fitSize([960, 500], sampleExtendedFeature2);
constructedProjection = constructedProjection.fitSize([960, 500], sampleFeatureCollection);
constructedProjection = constructedProjection.fitSize([960, 500], sampleExtendedFeatureCollection);
// ----------------------------------------------------------------------
// GeoConicProjection interface
// ----------------------------------------------------------------------
// parallels(...) ------------------------------------------------------
let parallels: [number, number] = conicConformal.parallels();
conicConformal = conicConformal.parallels([20, 20]);
// test method inheritance from GeoProjection ---------------------------
conicConformal = conicConformal.fitSize([960, 500], samplePolygon); // inherited
// ----------------------------------------------------------------------
// GeoPath Generator
// ----------------------------------------------------------------------
// Create geoPath Generator =============================================
let geoPathCanvas: d3Geo.GeoPath<any, d3Geo.GeoPermissibleObjects>;
geoPathCanvas = d3Geo.geoPath();
let geoPathSVG: d3Geo.GeoPath<SVGPathElement, d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1>>;
geoPathSVG = d3Geo.geoPath<SVGPathElement, d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1>>();
// Configure geoPath Generator ==========================================
// projection(...) ------------------------------------------------------
geoPathCanvas = geoPathCanvas.projection(azimuthalEqualArea);
let geoPathProjectionMinimal: d3Geo.GeoStreamWrapper = geoPathCanvas.projection();
let geoPathProjectionUnion: d3Geo.GeoProjection | d3Geo.GeoConicProjection | d3Geo.GeoStreamWrapper = geoPathCanvas.projection();
let geoPathProjection: d3Geo.GeoProjection = geoPathCanvas.projection<d3Geo.GeoProjection>();
geoPathSVG = geoPathSVG.projection(conicConformal);
let geoPathConicProjection: d3Geo.GeoConicProjection = geoPathSVG.projection<d3Geo.GeoConicProjection>();
// geoPathConicProjection = geoPathSVG.projection(); // fails without casting to GeoConicProjection, or alternatively custom typeguard
// geoPathConicProjection = geoPathSVG.projection<SampleProperties1>(); // fails as SampleProperties does not extend minimal interface
// context(...) ------------------------------------------------------
// minimal context interface
geoPathCanvas = geoPathCanvas.context({
beginPath: () => { return; },
moveTo: (x: number, y: number) => { return; },
lineTo: (x: number, y: number) => { return; },
arc: (x, y, radius, startAngle, endAngle) => { return; },
closePath: () => { return; }
});
let geoPathContext: d3Geo.GeoContext = geoPathCanvas.context();
// reset
geoPathCanvas = geoPathCanvas.context(null);
// With canvas 2D rendering context
let canvasContext: CanvasRenderingContext2D;
geoPathCanvas = geoPathCanvas.context(canvasContext);
canvasContext = geoPathCanvas.context<CanvasRenderingContext2D>();
// canvasContext = geoPathSimple.context(); // fails without casting to CanvasRenderingContext2D
// canvasContext = geoPathSimple.context<SampleProperties1>(); // fails as SampleProperties does not extend GeoCanvas
// pointRadius(...) ------------------------------------------------------
geoPathCanvas = geoPathCanvas.pointRadius(5);
let geoPathCanvasPointRadiusAccessor: (this: any, d: d3Geo.GeoPermissibleObjects, ...args: any[]) => number = geoPathCanvas.pointRadius();
geoPathSVG = geoPathSVG.pointRadius(function (datum) {
let that: SVGPathElement = this;
let d: d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1> = datum;
return datum.properties.name === 'Alabama' ? 10 : 15;
});
let geoPathSVGPointRadiusAccessor: (this: SVGPathElement, d: d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1>, ...args: any[]) => number = geoPathSVG.pointRadius();
// let geoPathSVGPointRadiusAccessorWrong1: (this: SVGCircleElement, d: d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1>, ...args: any[]) => number = geoPathSVG.pointRadius(); // fails, mismatch in this context
// let geoPathSVGPointRadiusAccessorWrong2: (this: SVGPathElement, d: d3Geo.GeoGeometryObjects, ...args: any[]) => number = geoPathSVG.pointRadius(); // fails, mismatch in object datum type
// Use geoPath Generator ================================================
// area(...) ------------------------------------------------------
let geoPathArea: number = geoPathCanvas.area(samplePolygon);
geoPathArea = geoPathCanvas.area(sampleSphere);
geoPathArea = geoPathCanvas.area(sampleGeometryCollection);
geoPathArea = geoPathCanvas.area(sampleExtendedGeometryCollection);
geoPathArea = geoPathCanvas.area(sampleFeature);
geoPathArea = geoPathCanvas.area(sampleExtendedFeature1);
geoPathArea = geoPathCanvas.area(sampleExtendedFeature2);
geoPathArea = geoPathCanvas.area(sampleFeatureCollection);
geoPathArea = geoPathCanvas.area(sampleExtendedFeatureCollection);
// geoPathArea = geoPathSVG.area(sampleExtendedFeatureCollection); // fails, wrong data object type
// bounds(...) ------------------------------------------------------
let geoPathBounds: [[number, number], [number, number]] = geoPathCanvas.bounds(samplePolygon);
geoPathBounds = geoPathCanvas.bounds(sampleSphere);
geoPathBounds = geoPathCanvas.bounds(sampleGeometryCollection);
geoPathBounds = geoPathCanvas.bounds(sampleExtendedGeometryCollection);
geoPathBounds = geoPathCanvas.bounds(sampleFeature);
geoPathBounds = geoPathCanvas.bounds(sampleExtendedFeature1);
geoPathBounds = geoPathCanvas.bounds(sampleExtendedFeature2);
geoPathBounds = geoPathCanvas.bounds(sampleFeatureCollection);
geoPathBounds = geoPathCanvas.bounds(sampleExtendedFeatureCollection);
// geoPathBounds = geoPathSVG.bounds(sampleExtendedFeatureCollection); // fails, wrong data object type
// centroid(...) ------------------------------------------------------
let geoPathCentroid: [number, number] = geoPathCanvas.centroid(samplePolygon);
geoPathCentroid = geoPathCanvas.centroid(sampleSphere);
geoPathCentroid = geoPathCanvas.centroid(sampleGeometryCollection);
geoPathCentroid = geoPathCanvas.centroid(sampleExtendedGeometryCollection);
geoPathCentroid = geoPathCanvas.centroid(sampleFeature);
geoPathCentroid = geoPathCanvas.centroid(sampleExtendedFeature1);
geoPathCentroid = geoPathCanvas.centroid(sampleExtendedFeature2);
geoPathCentroid = geoPathCanvas.centroid(sampleFeatureCollection);
geoPathCentroid = geoPathCanvas.centroid(sampleExtendedFeatureCollection);
// geoPathCentroid = geoPathSVG.centroid(sampleExtendedFeatureCollection); // fails, wrong data object type
// render path to context of get path string----------------------------
// render to GeoContext/Canvas
geoPathCanvas(samplePolygon);
geoPathCanvas(sampleSphere);
geoPathCanvas(sampleGeometryCollection);
geoPathCanvas(sampleExtendedGeometryCollection);
geoPathCanvas(sampleFeature);
geoPathCanvas(sampleExtendedFeature1);
geoPathCanvas(sampleExtendedFeature2);
geoPathCanvas(sampleFeatureCollection);
geoPathCanvas(sampleExtendedFeatureCollection);
// Use path string generator for SVGPathElement
let svgPath: Selection<SVGPathElement, d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1>, any, any>;
svgPath.attr('d', geoPathSVG);
let svgCircleWrong: Selection<SVGCircleElement, d3Geo.ExtendedFeature<GeoJSON.Polygon, SampleProperties1>, any, any>;
// svgCircleWrong.attr('d', geoPathSVG); // fails, mismatch in `this` context
let svgPathWrong: Selection<SVGPathElement, GeoJSON.Polygon, any, any>;
// svgPathWrong.attr('d', geoPathSVG); // fails, mismatch in datum type
// ----------------------------------------------------------------------
// geoClipExtent
// ----------------------------------------------------------------------
let geoClipExtent: d3Geo.GeoExtent = d3Geo.geoClipExtent();
// extent(...) ----------------------------------------------------------
let extent2: [[number, number], [number, number]] = geoClipExtent.extent();
geoClipExtent = geoClipExtent.extent([[0, 0], [960, 500]]);
// stream(...) ----------------------------------------------------------
let stream: d3Geo.GeoStream;
stream = geoClipExtent.stream(stream);
// ----------------------------------------------------------------------
// Stream interface
// ----------------------------------------------------------------------
stream.point(0, 0);
stream.point(0, 0, 0);
stream.lineStart();
stream.lineEnd();
stream.polygonStart();
stream.polygonEnd();
stream.sphere();
// ----------------------------------------------------------------------
// Context interface
// ----------------------------------------------------------------------
let context: d3Geo.GeoContext = {
beginPath: () => { return; },
moveTo: (x: number, y: number) => { return; },
lineTo: (x: number, y: number) => { return; },
arc: (x, y, radius, startAngle, endAngle) => { return; },
closePath: () => { return; }
};
// ----------------------------------------------------------------------
// Projection Streams
// ----------------------------------------------------------------------
// geoTransform(...) ====================================================
let transformFunction: { stream: (s: d3Geo.GeoStream) => {} } = d3Geo.geoTransform({});
interface CustomTranformProto extends d3Geo.GeoTransformPrototype {
a: number;
}
let customTransformProto: CustomTranformProto;
customTransformProto = {
point: function (x, y) {
return this.stream.point(x + this.a, -y);
},
a: 10
};
let t: { stream: (s: d3Geo.GeoStream) => (CustomTranformProto & d3Geo.GeoStream) } = d3Geo.geoTransform(customTransformProto);
// geoStream(...) ========================================================
d3Geo.geoStream(samplePolygon, stream);
d3Geo.geoStream(sampleSphere, stream);
d3Geo.geoStream(sampleGeometryCollection, stream);
d3Geo.geoStream(sampleExtendedGeometryCollection, stream);
d3Geo.geoStream(sampleFeature, stream);
d3Geo.geoStream(sampleExtendedFeature1, stream);
d3Geo.geoStream(sampleExtendedFeature2, stream);
d3Geo.geoStream(sampleFeatureCollection, stream);
d3Geo.geoStream(sampleExtendedFeatureCollection, stream);
+358
View File
@@ -0,0 +1,358 @@
// Type definitions for D3JS d3-geo module 1.2.0
// Project: https://github.com/d3/d3-geo/
// Definitions by: Hugues Stefanski <https://github.com/Ledragon>, Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="geojson" />
// ----------------------------------------------------------------------
// Shared Interfaces and Types
// ----------------------------------------------------------------------
/**
* A basic geometry for a sphere, which is supported by d3-geo
* beyond the GeoJSON geometries.
*/
export interface GeoSphere {
type: 'Sphere';
}
/**
* Type Alias for GeoJSON Geometry Object and GeoSphere additional
* geometry supported by d3-geo
*/
export type GeoGeometryObjects = GeoJSON.GeometryObject | GeoSphere;
/**
* A GeoJSON-style GeometryCollection which supports GeoJSON geometry objects
* and additionally GeoSphere
*/
export interface ExtendedGeometryCollection<GeometryType extends GeoGeometryObjects> {
type: string;
bbox?: number[];
crs?: GeoJSON.CoordinateReferenceSystem;
geometries: GeometryType[];
}
/**
* A GeoJSON-style Feature which support features built on GeoJSON GeometryObjects
* or GeoSphere
*/
export interface ExtendedFeature<GeometryType extends GeoGeometryObjects, Properties> extends GeoJSON.GeoJsonObject {
geometry: GeometryType;
properties: Properties;
id?: string;
}
/**
* A GeoJSON-style FeatureCollection which supports GeoJSON features
* and features built on GeoSphere
*/
export interface ExtendedFeatureCollection<FeatureType extends ExtendedFeature<GeoGeometryObjects, any>> extends GeoJSON.GeoJsonObject {
features: FeatureType[];
}
/**
* Type Alias for permissible objects which can be used with d3-geo
* methods
*/
export type GeoPermissibleObjects = GeoGeometryObjects | ExtendedGeometryCollection<GeoGeometryObjects> | ExtendedFeature<GeoGeometryObjects, any> | ExtendedFeatureCollection<ExtendedFeature<GeoGeometryObjects, any>>;
// ----------------------------------------------------------------------
// Spherical Math
// ----------------------------------------------------------------------
/**Returns the spherical area of the specified GeoJSON feature in steradians. */
export function geoArea(feature: ExtendedFeature<GeoGeometryObjects, any>): number;
export function geoArea(feature: ExtendedFeatureCollection<ExtendedFeature<GeoGeometryObjects, any>>): number;
export function geoArea(feature: GeoGeometryObjects): number;
export function geoArea(feature: ExtendedGeometryCollection<GeoGeometryObjects>): number;
/**Returns the spherical bounding box for the specified GeoJSON feature. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude. All coordinates are given in degrees. */
export function geoBounds(feature: ExtendedFeature<GeoGeometryObjects, any>): [[number, number], [number, number]];
export function geoBounds(feature: ExtendedFeatureCollection<ExtendedFeature<GeoGeometryObjects, any>>): [[number, number], [number, number]];
export function geoBounds(feature: GeoGeometryObjects): [[number, number], [number, number]];
export function geoBounds(feature: ExtendedGeometryCollection<GeoGeometryObjects>): [[number, number], [number, number]];
/**Returns the spherical centroid of the specified GeoJSON feature. See also path.centroid, which computes the projected planar centroid.*/
export function geoCentroid(feature: ExtendedFeature<GeoGeometryObjects, any>): [number, number];
export function geoCentroid(feature: ExtendedFeatureCollection<ExtendedFeature<GeoGeometryObjects, any>>): [number, number];
export function geoCentroid(feature: GeoGeometryObjects): [number, number];
export function geoCentroid(feature: ExtendedGeometryCollection<GeoGeometryObjects>): [number, number];
/**Returns the great-arc distance in radians between the two points a and b. Each point must be specified as a two-element array [longitude, latitude] in degrees. */
export function geoDistance(a: [number, number], b: [number, number]): number;
/**Returns the great-arc length of the specified GeoJSON feature in radians.*/
export function geoLength(feature: ExtendedFeature<GeoGeometryObjects, any>): number;
export function geoLength(feature: ExtendedFeatureCollection<ExtendedFeature<GeoGeometryObjects, any>>): number;
export function geoLength(feature: GeoGeometryObjects): number;
export function geoLength(feature: ExtendedGeometryCollection<GeoGeometryObjects>): number;
/**Returns an interpolator function given two points a and b. Each point must be specified as a two-element array [longitude, latitude] in degrees. */
export function geoInterpolate(a: [number, number], b: [number, number]): (t: number) => [number, number];
export interface GeoRotation {
(point: [number, number]): [number, number];
invert(point: [number, number]): [number, number];
}
/**Returns a rotation function for the given angles, which must be a two- or three-element array of numbers [lambda, phi, gamma] specifying the rotation angles in degrees about each spherical axis. */
export function geoRotation(angles: [number, number] | [number, number, number]): GeoRotation;
// ----------------------------------------------------------------------
// Spherical Shapes
// ----------------------------------------------------------------------
// geoCircle ============================================================
export interface GeoCircleGenerator<This, Datum> {
/**Returns a new GeoJSON geometry object of type “Polygon” approximating a circle on the surface of a sphere, with the current center, radius and precision. */
(this: This, d?: Datum, ...args: any[]): GeoJSON.Polygon;
center(): ((this: This, d: Datum, ...args: any[]) => [number, number]);
center(center: [number, number]): this;
center(center: ((this: This, d: Datum, ...args: any[]) => [number, number])): this;
radius(): ((this: This, d: Datum, ...args: any[]) => number);
radius(radius: number): this;
radius(radius: ((this: This, d: Datum, ...args: any[]) => number)): this;
precision(): ((this: This, d: Datum, ...args: any[]) => number);
precision(precision: number): this;
precision(precision: (this: This, d: Datum, ...args: any[]) => number): this;
}
export function geoCircle(): GeoCircleGenerator<any, any>;
export function geoCircle<Datum>(): GeoCircleGenerator<any, Datum>;
export function geoCircle<This, Datum>(): GeoCircleGenerator<This, Datum>;
// geoGraticule ============================================================
export interface GeoGraticuleGenerator {
/**Returns a GeoJSON MultiLineString geometry object representing all meridians and parallels for this graticule. */
(): GeoJSON.MultiLineString;
lines(): GeoJSON.LineString[];
outline(): GeoJSON.Polygon;
extent(): [[number, number], [number, number]];
extent(extent: [[number, number], [number, number]]): this;
extentMajor(): [[number, number], [number, number]];
extentMajor(extent: [[number, number], [number, number]]): this;
extentMinor(): [[number, number], [number, number]];
extentMinor(extent: [[number, number], [number, number]]): this;
step(): [number, number];
step(step: [number, number]): this;
stepMajor(): [number, number];
stepMajor(step: [number, number]): this;
stepMinor(): [number, number];
stepMinor(step: [number, number]): this;
precision(): number;
precision(angle: number): this;
}
export function geoGraticule(): GeoGraticuleGenerator;
// ----------------------------------------------------------------------
// Projections
// ----------------------------------------------------------------------
export interface GeoStream {
lineEnd(): void;
lineStart(): void;
point(x: number, y: number, z?: number): void;
polygonEnd(): void;
polygonStart(): void;
sphere?(): void;
}
export interface GeoStreamWrapper {
stream(stream: GeoStream): GeoStream;
}
export interface GeoRawProjection {
(longitude: number, latitude: number): [number, number];
invert?(x: number, y: number): [number, number];
}
export interface GeoProjection extends GeoStreamWrapper {
/**Returns a new array x, y representing the projected point of the given point. The point must be specified as a two-element array [longitude, latitude] in degrees. */
(point: [number, number]): [number, number] | null;
center(): [number, number];
center(point: [number, number]): this;
clipAngle(): number | null;
clipAngle(angle: null): this;
clipAngle(angle: number): this;
clipExtent(): [[number, number], [number, number]] | null;
clipExtent(extent: null): this;
clipExtent(extent: [[number, number], [number, number]]): this;
/**Sets the projections scale and translate to fit the specified GeoJSON object in the center of the given extent. */
fitExtent(extent: [[number, number], [number, number]], object: ExtendedFeature<GeoGeometryObjects, any>): this;
fitExtent(extent: [[number, number], [number, number]], object: ExtendedFeatureCollection<ExtendedFeature<GeoGeometryObjects, any>>): this;
fitExtent(extent: [[number, number], [number, number]], object: GeoGeometryObjects): this;
fitExtent(extent: [[number, number], [number, number]], object: ExtendedGeometryCollection<GeoGeometryObjects>): this;
/**A convenience method for projection.fitExtent where the top-left corner of the extent is [0,0]. */
fitSize(size: [number, number], object: ExtendedFeature<GeoGeometryObjects, any>): this;
fitSize(size: [number, number], object: ExtendedFeatureCollection<ExtendedFeature<GeoGeometryObjects, any>>): this;
fitSize(size: [number, number], object: GeoGeometryObjects): this;
fitSize(size: [number, number], object: ExtendedGeometryCollection<GeoGeometryObjects>): this;
/**Returns a new array [longitude, latitude] in degrees representing the unprojected point of the given projected point. */
invert?(point: [number, number]): [number, number] | null;
precision(): number;
precision(precision: number): this;
rotate(): [number, number, number];
rotate(angles: [number, number] | [number, number, number]): this;
scale(): number;
scale(scale: number): this;
translate(): [number, number];
translate(point: [number, number]): this;
}
export interface GeoConicProjection extends GeoProjection {
parallels(value: [number, number]): this;
parallels(): [number, number];
}
// geoPath ==============================================================
export interface GeoContext {
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void;
beginPath(): void;
closePath(): void;
lineTo(x: number, y: number): void;
moveTo(x: number, y: number): void;
}
export interface GeoPath<This, DatumObject extends GeoPermissibleObjects> {
(this: This, object: DatumObject, ...args: any[]): string;
area(object: DatumObject): number;
bounds(object: DatumObject): [[number, number], [number, number]];
centroid(object: DatumObject): [number, number];
context<C extends GeoContext>(): C | null;
context(context: GeoContext | null): this;
/**
* Get the current projection. The generic parameter can be used to cast the result to the
* correct, known type of the projection, e.g. GeoProjection or GeoConicProjection. Otherwise,
* the return type defaults to the minimum type requirement for a projection which
* can be passed into a GeoPath.
*/
projection<P extends GeoConicProjection | GeoProjection | GeoStreamWrapper>(): P | null;
/**
* Set the projection to the identity projection
*/
projection(projection: null): this;
/**
* Set the projection to be used with the geo path generator.
*/
projection(projection: GeoProjection): this;
/**
* Set the projection to be used with the geo path generator to a custom projection.
* Custom projections must minimally contain a stream method.
*/
projection(projection: GeoStreamWrapper): this;
pointRadius(): (this: This, object: DatumObject, ...args: any[]) => number;
pointRadius(value: number): this;
pointRadius(value: (this: This, object: DatumObject, ...args: any[]) => number): this;
}
export function geoPath(): GeoPath<any, GeoPermissibleObjects>;
export function geoPath<DatumObject extends GeoPermissibleObjects>(): GeoPath<any, DatumObject>;
export function geoPath<This, DatumObject extends GeoPermissibleObjects>(): GeoPath<This, DatumObject>;
// Raw Projections ========================================================
export function geoAzimuthalEqualAreaRaw(): GeoRawProjection;
export function geoAzimuthalEquidistantRaw(): GeoRawProjection;
export function geoConicConformalRaw(phi0: number, phi1: number): GeoRawProjection;
export function geoConicEqualAreaRaw(phi0: number, phi1: number): GeoRawProjection;
export function geoConicEquidistantRaw(phi0: number, phi1: number): GeoRawProjection;
export function geoEquirectangularRaw(): GeoRawProjection;
export function geoGnomonicRaw(): GeoRawProjection;
export function geoMercatorRaw(): GeoRawProjection;
export function geoOrthographicRaw(): GeoRawProjection;
export function geoStereographicRaw(): GeoRawProjection;
export function geoTransverseMercatorRaw(): GeoRawProjection;
// geoProjection ==========================================================
export function geoProjection(project: GeoRawProjection): GeoProjection;
// geoProjectionMutator ====================================================
export function geoProjectionMutator(factory: (...args: any[]) => GeoRawProjection): () => GeoProjection;
// Pre-Defined Projections =================================================
export function geoAlbers(): GeoConicProjection;
export function geoAlbersUsa(): GeoProjection;
export function geoAzimuthalEqualArea(): GeoProjection;
export function geoAzimuthalEquidistant(): GeoProjection;
export function geoConicConformal(): GeoConicProjection;
export function geoConicEqualArea(): GeoConicProjection;
export function geoConicEquidistant(): GeoConicProjection;
export function geoEquirectangular(): GeoProjection;
export function geoGnomonic(): GeoProjection;
export function geoMercator(): GeoProjection;
export function geoOrthographic(): GeoProjection;
export function geoStereographic(): GeoProjection;
export function geoTransverseMercator(): GeoProjection;
// geoClipExtent =============================================================
export interface GeoExtent {
extent(): [[number, number], [number, number]];
extent(extent: [[number, number], [number, number]]): this;
stream(stream: GeoStream): GeoStream;
}
export function geoClipExtent(): GeoExtent;
// ----------------------------------------------------------------------
// Projection Streams
// ----------------------------------------------------------------------
// geoTransform(...) ====================================================
export interface GeoTransformPrototype {
lineEnd?(this: this & { stream: GeoStream }): void;
lineStart?(this: this & { stream: GeoStream }): void;
point?(this: this & { stream: GeoStream }, x: number, y: number, z?: number): void;
polygonEnd?(this: this & { stream: GeoStream }): void;
polygonStart?(this: this & { stream: GeoStream }): void;
sphere?(this: this & { stream: GeoStream }): void;
}
// TODO: Review whether GeoStreamWrapper should be included into return value union type, i.e. ({ stream: (s: GeoStream) => (T & GeoStream & GeoStreamWrapper)})?
// It probably should be omitted for purposes of this API. The stream method added to (T & GeoStream) is more of a private member used internally to
// implement the Transform factory
export function geoTransform<T extends GeoTransformPrototype>(prototype: T): { stream: (s: GeoStream) => (T & GeoStream) };
// geoStream(...) =======================================================
export function geoStream(object: ExtendedFeature<GeoGeometryObjects, any>, stream: GeoStream): void;
export function geoStream(object: ExtendedFeatureCollection<ExtendedFeature<GeoGeometryObjects, any>>, stream: GeoStream): void;
export function geoStream(object: GeoGeometryObjects, stream: GeoStream): void;
export function geoStream(object: ExtendedGeometryCollection<GeoGeometryObjects>, stream: GeoStream): void;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"d3-geo-tests.ts"
]
}
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-hierarchy module 1.0.0
// Project: https://github.com/d3/d3-hierarchy/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// -----------------------------------------------------------------------
+45
View File
@@ -0,0 +1,45 @@
/**
* Typescript definition tests for d3/d3-hsv module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import {hsv, HSVColor} from 'd3-hsv';
import {rgb, RGBColor} from 'd3-color';
let c: RGBColor,
cHSV: HSVColor,
displayable: boolean,
cString: string;
// hsv signature
cHSV = hsv(120, 0.4, 0.5);
cHSV = hsv(120, 0.4, 0.5, 0.5);
// specifier signature
cHSV = hsv('rgb(255, 255, 255)');
cHSV = hsv('rgb(10%, 20%, 30%)');
cHSV = hsv('rgba(255, 255, 255, 0.4)');
cHSV = hsv('rgba(10%, 20%, 30%, 0.4)');
cHSV = hsv('hsl(120, 50%, 20%)');
cHSV = hsv('hsla(120, 50%, 20%, 0.4)');
cHSV = hsv('#ffeeaa');
cHSV = hsv('#fea');
cHSV = hsv('steelblue');
// color signature
c = rgb('steelblue');
cHSV = hsv(c);
cHSV = hsv(cHSV);
// method signatures
cHSV = cHSV.brighter();
cHSV = cHSV.brighter(0.2);
cHSV = cHSV.darker();
cHSV = cHSV.darker(0.2);
displayable = cHSV.displayable();
cString = cHSV.toString();
console.log('Channels = (h : %d, s: %d, v: %d)', cHSV.h, cHSV.s, cHSV.v);
console.log('Opacity = %d', cHSV.opacity);
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for D3JS d3-hsv module 0.0.3
// Project: https://github.com/d3/d3-hsv/
// Definitions by: Yuri Feldman <https://github.com/arrayjam>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import {Color, RGBColor, ColorSpaceObject, ColorCommonInstance} from 'd3-color';
type ColorSpaceObjectWithHSV = ColorSpaceObject | HSVColor;
export interface HSVColorFactory extends Function {
(h: number, s: number, v: number, opacity?: number): HSVColor;
(cssColorSpecifier: string): HSVColor;
(color: HSVColor | ColorSpaceObject | ColorCommonInstance): HSVColor;
}
export interface HSVColor extends Color {
h: number;
s: number;
v: number;
opacity: number;
brighter(k?: number): this;
darker(k?: number): this;
rgb(): RGBColor;
}
export var hsv: HSVColorFactory;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"d3-hsv-tests.ts"
]
}
+14 -2
View File
@@ -6,8 +6,9 @@
* are not intended as functional tests.
*/
import * as d3Interpolate from 'd3-interpolate';
import * as d3Color from 'd3-color';
import * as d3Interpolate from 'd3-interpolate';
import * as d3Hsv from 'd3-hsv';
// Preparatory steps -------------------------------------------------------------------
@@ -56,6 +57,7 @@ let num: number,
arrStr: string[],
objKeyVal: { [key: string]: any },
objRGBColor: d3Color.RGBColor,
objHSVColor: d3Hsv.HSVColor,
zoom: [number, number, number];
// test interpolate(a, b) signature ----------------------------------------------------
@@ -65,6 +67,7 @@ iNum = d3Interpolate.interpolate('1', 5);
// color interpolator returning a color string
iString = d3Interpolate.interpolate('seagreen', d3Color.rgb(100, 100, 100));
iString = d3Interpolate.interpolate('seagreen', d3Hsv.hsv(60, 1, 0.2, 0.4));
iString = d3Interpolate.interpolate('seagreen', 'steelblue'); // as used with valid color name string
// date interpolator
@@ -168,6 +171,7 @@ arrStr = d3Interpolate.quantize<string>(d3Interpolate.interpolateString('-1', '2
// without gamma correction
iString = d3Interpolate.interpolateRgb('seagreen', 'steelblue');
iString = d3Interpolate.interpolateRgb(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateRgb(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
str = iString(0.5);
// with gamma correction
@@ -176,34 +180,41 @@ iString = d3Interpolate.interpolateRgb.gamma(2.2)('purple', 'orange');
// test interpolateRgbBasis(color) and interpolateRgbBasisClosed(color) signatures -------------------------
iString = d3Interpolate.interpolateRgbBasis(['seagreen', d3Color.rgb('steelblue'), 'rgb(100, 100, 100)']);
iString = d3Interpolate.interpolateRgbBasisClosed(['seagreen', d3Color.rgb('steelblue'), 'rgb(100, 100, 100)']);
iString = d3Interpolate.interpolateRgbBasis(['seagreen', d3Hsv.hsv('steelblue'), 'rgb(100, 100, 100)']);
iString = d3Interpolate.interpolateRgbBasisClosed(['seagreen', d3Hsv.hsv('steelblue'), 'rgb(100, 100, 100)']);
// test interpolateHsl(a, b) and interpolateHslLong(a, b)----------------------------------------------------------------
iString = d3Interpolate.interpolateHsl('seagreen', 'steelblue');
iString = d3Interpolate.interpolateHsl(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateHsl(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
iString = d3Interpolate.interpolateHslLong('seagreen', 'steelblue');
iString = d3Interpolate.interpolateHslLong(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateHslLong(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
// test interpolateLab(a, b) --------------------------------------------------------------------------------------------
iString = d3Interpolate.interpolateLab('seagreen', 'steelblue');
iString = d3Interpolate.interpolateLab(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateLab(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
// test interpolateHcl(a, b) and interpolateHclLong(a, b) ----------------------------------------------------------------
iString = d3Interpolate.interpolateHcl('seagreen', 'steelblue');
iString = d3Interpolate.interpolateHcl(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateHcl(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
iString = d3Interpolate.interpolateHclLong('seagreen', 'steelblue');
iString = d3Interpolate.interpolateHclLong(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateHclLong(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
// test interpolateCubehelix(a, b) and interpolateCubehelixLong(a, b) ---------------------------------------------------
// without gamma correction
iString = d3Interpolate.interpolateCubehelix('seagreen', 'steelblue');
iString = d3Interpolate.interpolateCubehelix(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateCubehelix(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
str = iString(0.5);
// with gamma correction
@@ -212,6 +223,7 @@ iString = d3Interpolate.interpolateCubehelix.gamma(2.2)('purple', 'orange');
// without gamma correction
iString = d3Interpolate.interpolateCubehelixLong('seagreen', 'steelblue');
iString = d3Interpolate.interpolateCubehelixLong(d3Color.rgb('seagreen'), d3Color.hcl('steelblue'));
iString = d3Interpolate.interpolateCubehelixLong(d3Color.rgb('seagreen'), d3Hsv.hsv('steelblue'));
str = iString(0.5);
// with gamma correction
+11 -11
View File
@@ -1,9 +1,9 @@
// Type definitions for D3JS d3-interpolate module 1.1.0
// Project: https://github.com/d3/d3-interpolate/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ColorSpaceObject } from 'd3-color';
import { ColorCommonInstance } from 'd3-color';
// --------------------------------------------------------------------------
@@ -20,7 +20,7 @@ export interface ZoomInterpolator extends Function {
}
export interface ColorGammaInterpolationFactory extends Function {
(a: string | ColorSpaceObject, b: string | ColorSpaceObject): ((t: number) => string);
(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string);
gamma(g: number): ColorGammaInterpolationFactory;
}
@@ -39,7 +39,7 @@ export type ZoomView = [number, number, number];
export function interpolate(a: any, b: null): ((t: number) => null);
export function interpolate(a: number | { valueOf(): number }, b: number): ((t: number) => number);
export function interpolate(a: any, b: ColorSpaceObject): ((t: number) => string);
export function interpolate(a: any, b: ColorCommonInstance): ((t: number) => string);
export function interpolate(a: Date, b: Date): ((t: number) => Date);
export function interpolate(a: string | { toString(): string }, b: string): ((t: number) => string);
export function interpolate<U extends Array<any>>(a: Array<any>, b: U): ((t: number) => U);
@@ -78,14 +78,14 @@ export function quantize<T>(interpolator: ((t: number) => T), n: number): Array<
export var interpolateRgb: ColorGammaInterpolationFactory;
export function interpolateRgbBasis(colors: Array<string | ColorSpaceObject>): ((t: number) => string);
export function interpolateRgbBasisClosed(colors: Array<string | ColorSpaceObject>): ((t: number) => string);
export function interpolateRgbBasis(colors: Array<string | ColorCommonInstance>): ((t: number) => string);
export function interpolateRgbBasisClosed(colors: Array<string | ColorCommonInstance>): ((t: number) => string);
export function interpolateHsl(a: string | ColorSpaceObject, b: string | ColorSpaceObject): ((t: number) => string);
export function interpolateHslLong(a: string | ColorSpaceObject, b: string | ColorSpaceObject): ((t: number) => string);
export function interpolateLab(a: string | ColorSpaceObject, b: string | ColorSpaceObject): ((t: number) => string);
export function interpolateHcl(a: string | ColorSpaceObject, b: string | ColorSpaceObject): ((t: number) => string);
export function interpolateHclLong(a: string | ColorSpaceObject, b: string | ColorSpaceObject): ((t: number) => string);
export function interpolateHsl(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string);
export function interpolateHslLong(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string);
export function interpolateLab(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string);
export function interpolateHcl(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string);
export function interpolateHclLong(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string);
export var interpolateCubehelix: ColorGammaInterpolationFactory;
export var interpolateCubehelixLong: ColorGammaInterpolationFactory;
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-path module 1.0.0
// Project: https://github.com/d3/d3-path/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface Path {
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-polygon module 1.0.0
// Project: https://github.com/d3/d3-polygon/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
+12 -12
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-quadtree module 1.0.0
// Project: https://github.com/d3/d3-quadtree/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
@@ -20,27 +20,27 @@ export interface QuadtreeLeaf<T> {
*
* A child quadrant may be undefined if it is empty.
*/
export interface QuadtreeInternalNode<T> extends Array<QuadtreeInternalNode<T> | QuadtreeLeaf<T> | undefined> {}
export interface QuadtreeInternalNode<T> extends Array<QuadtreeInternalNode<T> | QuadtreeLeaf<T> | undefined> { }
export interface Quadtree<T> {
x(): (d: T) => number;
x(x: (d: T) => number): Quadtree<T>;
x(x: (d: T) => number): this;
y(): (d: T) => number;
y(y: (d: T) => number): Quadtree<T>;
y(y: (d: T) => number): this;
extent(): [[number, number], [number, number]] | undefined;
extent(extend: [[number, number], [number, number]]): Quadtree<T>;
cover(x: number, y: number): Quadtree<T>;
add(datum: T): Quadtree<T>;
addAll(data: Array<T>): Quadtree<T>;
remove(datum: T): Quadtree<T>;
removeAll(data: Array<T>): Quadtree<T>;
extent(extend: [[number, number], [number, number]]): this;
cover(x: number, y: number): this;
add(datum: T): this;
addAll(data: Array<T>): this;
remove(datum: T): this;
removeAll(data: Array<T>): this;
copy(): Quadtree<T>;
root(): QuadtreeInternalNode<T> | QuadtreeLeaf<T>;
data(): Array<T>;
size(): number;
find(x: number, y: number, radius?: number): T | undefined;
visit(callback: (node: QuadtreeInternalNode<T> | QuadtreeLeaf<T>, x0: number, y0: number, x1: number, y1: number) => (void | boolean)): Quadtree<T>;
visitAfter(callback: (node: QuadtreeInternalNode<T> | QuadtreeLeaf<T>, x0: number, y0: number, x1: number, y1: number) => void): Quadtree<T>;
visit(callback: (node: QuadtreeInternalNode<T> | QuadtreeLeaf<T>, x0: number, y0: number, x1: number, y1: number) => (void | boolean)): this;
visitAfter(callback: (node: QuadtreeInternalNode<T> | QuadtreeLeaf<T>, x0: number, y0: number, x1: number, y1: number) => void): this;
}
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-queue module 3.0.1
// Project: https://github.com/d3/d3-queue/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for D3JS d3-random module 1.0.0
// Project: https://github.com/d3/d3-random/
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**

Some files were not shown because too many files have changed in this diff Show More