mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge remote-tracking branch 'refs/remotes/DefinitelyTyped/master'
This commit is contained in:
Vendored
+10
@@ -319,6 +319,11 @@ declare module "agenda" {
|
||||
* The date/time the job last failed.
|
||||
*/
|
||||
failedAt: Date;
|
||||
|
||||
/**
|
||||
* Job's state
|
||||
*/
|
||||
disabled: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,6 +414,11 @@ declare module "agenda" {
|
||||
* @param cb Called after the job has been saved to the database.
|
||||
*/
|
||||
touch(cb?: Callback): void;
|
||||
|
||||
/**
|
||||
* Calculates next time the job should run
|
||||
*/
|
||||
computeNextRunAt(): Job;
|
||||
}
|
||||
|
||||
interface JobOptions {
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ declare module "angular-translate" {
|
||||
declare namespace angular.translate {
|
||||
|
||||
interface ITranslationTable {
|
||||
[key: string]: any;
|
||||
[key: string]: string | ITranslationTable;
|
||||
}
|
||||
|
||||
interface ILanguageKeyAlias {
|
||||
@@ -96,7 +96,7 @@ declare namespace angular.translate {
|
||||
storageKey(): string;
|
||||
storageKey(key: string): void; // JeroMiya - the library should probably return ITranslateProvider but it doesn't here
|
||||
useUrlLoader(url: string): ITranslateProvider;
|
||||
useStaticFilesLoader(options: IStaticFilesLoaderOptions): ITranslateProvider;
|
||||
useStaticFilesLoader(options: IStaticFilesLoaderOptions | { files: IStaticFilesLoaderOptions[] }): ITranslateProvider;
|
||||
useLoader(loaderFactory: string, options?: any): ITranslateProvider;
|
||||
useLocalStorage(): ITranslateProvider;
|
||||
useCookieStorage(): ITranslateProvider;
|
||||
|
||||
@@ -1098,6 +1098,12 @@ function parseTyping() {
|
||||
}
|
||||
}
|
||||
|
||||
function parseWithParams() {
|
||||
var $parse: angular.IParseService;
|
||||
var compiledExp = $parse('a.b.c', () => null);
|
||||
var compiledExp = $parse('a.b.c', null, false);
|
||||
}
|
||||
|
||||
function doBootstrap(element: Element | JQuery, mode: string): ng.auto.IInjectorService {
|
||||
if (mode === 'debug') {
|
||||
return angular.bootstrap(element, ['main', function($provide: ng.auto.IProvideService) {
|
||||
|
||||
Vendored
+5
-2
@@ -873,7 +873,7 @@ declare namespace angular {
|
||||
// see http://docs.angularjs.org/api/ng.$parseProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IParseService {
|
||||
(expression: string): ICompiledExpression;
|
||||
(expression: string, interceptorFn?: (value: any, scope: IScope, locals: any) => any, expensiveChecks?: boolean): ICompiledExpression;
|
||||
}
|
||||
|
||||
interface IParseProvider {
|
||||
@@ -985,7 +985,10 @@ declare namespace angular {
|
||||
// DocumentService
|
||||
// see http://docs.angularjs.org/api/ng.$document
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IDocumentService extends JQuery {}
|
||||
interface IDocumentService extends JQuery {
|
||||
// Must return intersection type for index signature compatibility with JQuery
|
||||
[index: number]: HTMLElement & Document;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ExceptionHandlerService
|
||||
|
||||
Vendored
+1
-1
@@ -886,7 +886,7 @@ declare namespace angular {
|
||||
// see http://docs.angularjs.org/api/ng.$parseProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IParseService {
|
||||
(expression: string): ICompiledExpression;
|
||||
(expression: string, interceptorFn?: (value: any, scope: IScope, locals: any) => any, expensiveChecks?: boolean): ICompiledExpression;
|
||||
}
|
||||
|
||||
interface IParseProvider {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="./aphrodite.d.ts" />
|
||||
|
||||
import * as React from "react";
|
||||
import { StyleSheet, css, StyleSheetServer, StyleSheetTestUtils } from "aphrodite";
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
red: {
|
||||
backgroundColor: 'red'
|
||||
},
|
||||
blue: {
|
||||
backgroundColor: 'blue'
|
||||
},
|
||||
hover: {
|
||||
':hover': {
|
||||
backgroundColor: 'red'
|
||||
}
|
||||
},
|
||||
small: {
|
||||
'@media (max-width: 600px)': {
|
||||
backgroundColor: 'red',
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const coolFont = {
|
||||
fontFamily: "CoolFont",
|
||||
fontStyle: "normal",
|
||||
fontWeight: "normal",
|
||||
src: "url('coolfont.woff2') format('woff2')"
|
||||
};
|
||||
|
||||
const withFont = StyleSheet.create({
|
||||
headingText: {
|
||||
fontFamily: coolFont,
|
||||
fontSize: 20
|
||||
},
|
||||
bodyText: {
|
||||
fontFamily: [coolFont, "sans-serif"],
|
||||
fontSize: 12
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
class App extends React.Component<{}, {}> {
|
||||
render() {
|
||||
return <div>
|
||||
<span className={css(styles.red)}>
|
||||
This is red.
|
||||
</span>
|
||||
<span className={css(styles.hover)}>
|
||||
This turns red on hover.
|
||||
</span>
|
||||
<span className={css(styles.small)}>
|
||||
This turns red when the browser is less than 600px width.
|
||||
</span>
|
||||
<span className={css(styles.red, styles.blue)}>
|
||||
This is blue.
|
||||
</span>
|
||||
<span className={css(styles.blue, styles.small)}>
|
||||
This is blue and turns red when the browser is less than
|
||||
600px width.
|
||||
</span>
|
||||
<span className={css(withFont.bodyText)}>
|
||||
With font
|
||||
</span>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
const output = StyleSheetServer.renderStatic(() => {
|
||||
return "test";
|
||||
});
|
||||
|
||||
output.css.content;
|
||||
output.css.renderedClassNames;
|
||||
output.html;
|
||||
|
||||
StyleSheet.rehydrate(output.css.renderedClassNames);
|
||||
|
||||
StyleSheetTestUtils.suppressStyleInjection();
|
||||
StyleSheetTestUtils.clearBufferAndResumeStyleInjection();
|
||||
Vendored
+76
@@ -0,0 +1,76 @@
|
||||
// Type definitions for Aphrodite 0.5.0
|
||||
// Project: https://github.com/Khan/aphrodite
|
||||
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "aphrodite" {
|
||||
import * as React from "react";
|
||||
|
||||
/**
|
||||
* Aphrodite style declaration
|
||||
*/
|
||||
export interface StyleDeclaration {
|
||||
[key: string]: React.CSSProperties;
|
||||
}
|
||||
|
||||
interface StyleSheetStatic {
|
||||
/**
|
||||
* Create style sheet
|
||||
*/
|
||||
create<T extends StyleDeclaration>(styles: T): T;
|
||||
/**
|
||||
* Rehydrate class names from server renderer
|
||||
*/
|
||||
rehydrate(renderedClassNames: string[]): void;
|
||||
}
|
||||
|
||||
export var StyleSheet: StyleSheetStatic;
|
||||
/**
|
||||
* Get class names from passed styles
|
||||
*/
|
||||
export function css(...styles: any[]): string;
|
||||
|
||||
interface StaticRendererResult {
|
||||
html: string;
|
||||
css: {
|
||||
content: string;
|
||||
renderedClassNames: string[];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utilities for using Aphrodite server-side.
|
||||
*/
|
||||
interface StyleSheetServerStatic {
|
||||
renderStatic(renderFunc: () => string): StaticRendererResult;
|
||||
}
|
||||
|
||||
export var StyleSheetServer: StyleSheetServerStatic;
|
||||
|
||||
interface StyleSheetTestUtilsStatic {
|
||||
/**
|
||||
* Prevent styles from being injected into the DOM.
|
||||
*
|
||||
* This is useful in situations where you'd like to test rendering UI
|
||||
* components which use Aphrodite without any of the side-effects of
|
||||
* Aphrodite happening. Particularly useful for testing the output of
|
||||
* components when you have no DOM, e.g. testing in Node without a fake DOM.
|
||||
*
|
||||
* Should be paired with a subsequent call to
|
||||
* clearBufferAndResumeStyleInjection.
|
||||
*/
|
||||
suppressStyleInjection(): void;
|
||||
/**
|
||||
* Opposite method of preventStyleInject.
|
||||
*/
|
||||
clearBufferAndResumeStyleInjection(): void;
|
||||
}
|
||||
|
||||
export var StyleSheetTestUtils: StyleSheetTestUtilsStatic;
|
||||
}
|
||||
|
||||
declare module "aphrodite/no-important" {
|
||||
export * from "aphrodite";
|
||||
}
|
||||
Vendored
+1
-1
@@ -397,7 +397,7 @@ declare module "aws-sdk" {
|
||||
}
|
||||
|
||||
export interface SendMessageParams {
|
||||
QueueUrl: string;
|
||||
QueueUrl?: string;
|
||||
MessageBody: string;
|
||||
DelaySeconds?: number;
|
||||
MessageAttributes?: { [name:string]: MessageAttribute; }
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path="bazinga-translator.d.ts" />
|
||||
|
||||
Translator.fallback = 'en';
|
||||
Translator.defaultDomain = 'messages';
|
||||
|
||||
Translator.add("test", "it work", "frontend", "en");
|
||||
|
||||
Translator.trans('key', {}, 'frontend');
|
||||
Translator.trans('key', {"foo": "bar"}, 'DOMAIN_NAME');
|
||||
|
||||
Translator.transChoice('key', 1, {}, 'frontend');
|
||||
Translator.transChoice('key', 123, {"foo": "bar"}, 'DOMAIN_NAME');
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
// Type definitions for Translator
|
||||
// Project: https://github.com/willdurand/BazingaJsTranslationBundle
|
||||
// Definitions by: Alex <https://github.com/alexndlm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface BazingaTranslator {
|
||||
/**
|
||||
* The current locale.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
locale: string;
|
||||
|
||||
/**
|
||||
* Fallback locale.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
fallback: string;
|
||||
|
||||
/**
|
||||
* Placeholder prefix.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
placeHolderPrefix: string;
|
||||
|
||||
/**
|
||||
* Placeholder suffix.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
placeHolderSuffix: string;
|
||||
|
||||
/**
|
||||
* Default domain.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
defaultDomain: string;
|
||||
|
||||
/**
|
||||
* Plural separator.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
pluralSeparator: string;
|
||||
|
||||
/**
|
||||
* Adds a translation entry.
|
||||
*
|
||||
* @param {String} id The message id
|
||||
* @param {String} message The message to register for the given id
|
||||
* @param {String} [domain] The domain for the message or null to use the default
|
||||
* @param {String} [locale] The locale or null to use the default
|
||||
*
|
||||
* @return {Object} Translator
|
||||
*/
|
||||
add(id: string, message: string, domain: string, locale: string): BazingaTranslator;
|
||||
|
||||
|
||||
/**
|
||||
* Translates the given message.
|
||||
*
|
||||
* @param {String} id The message id
|
||||
* @param {Object} [parameters] An array of parameters for the message
|
||||
* @param {String} [domain] The domain for the message or null to guess it
|
||||
* @param {String} [locale] The locale or null to use the default
|
||||
*
|
||||
* @return {String} The translated string
|
||||
*/
|
||||
trans(id: string, parameters: any, domain: string, locale?: string): string;
|
||||
|
||||
/**
|
||||
* Translates the given choice message by choosing a translation according to a number.
|
||||
*
|
||||
* @param {String} id The message id
|
||||
* @param {Number} number The number to use to find the indice of the message
|
||||
* @param {Object} [parameters] An array of parameters for the message
|
||||
* @param {String} [domain] The domain for the message or null to guess it
|
||||
* @param {String} [locale] The locale or null to use the default
|
||||
*
|
||||
* @return {String} The translated string
|
||||
*/
|
||||
transChoice(id: string, number: number, parameters: any, domain: string, locale?: string): string,
|
||||
|
||||
/**
|
||||
* Loads translations from JSON.
|
||||
*
|
||||
* @param {String} data A JSON string or object literal
|
||||
*
|
||||
* @return {Object} Translator
|
||||
*/
|
||||
fromJSON(data: string): BazingaTranslator;
|
||||
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
declare var Translator: BazingaTranslator;
|
||||
Vendored
+5
-2
@@ -44,14 +44,17 @@ declare namespace Boom {
|
||||
export function rangeNotSatisfiable(message?: string, data?: any): BoomError;
|
||||
export function expectationFailed(message?: string, data?: any): BoomError;
|
||||
export function badData(message?: string, data?: any): BoomError;
|
||||
export function locked(message?: string, data?: any): BoomError;
|
||||
export function preconditionRequired(message?: string, data?: any): BoomError;
|
||||
export function tooManyRequests(message?: string, data?: any): BoomError;
|
||||
export function illegal(message?: string, data?: any): BoomError;
|
||||
|
||||
// 5xx
|
||||
export function badImplementation(message?: string, data?: any): BoomError;
|
||||
export function notImplemented(message?: string, data?: any): BoomError;
|
||||
export function badGateway(message?: string, data?: any): BoomError;
|
||||
export function serverTimeout(message?: string, data?: any): BoomError;
|
||||
export function serverUnavailable(message?: string, data?: any): BoomError;
|
||||
export function gatewayTimeout(message?: string, data?: any): BoomError;
|
||||
export function badImplementation(message?: string, data?: any): BoomError;
|
||||
}
|
||||
|
||||
declare module "boom" {
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ interface SliderOptions {
|
||||
* Default: 'horizontal'
|
||||
* set the orientation. Accepts 'vertical' or 'horizontal'
|
||||
*/
|
||||
orientation?: number;
|
||||
orientation?: string;
|
||||
/**
|
||||
* Default: 5
|
||||
* initial value. Use array to have a range slider.
|
||||
|
||||
Vendored
+1
-1
@@ -17,7 +17,7 @@ declare namespace Chai {
|
||||
html(html: string): Assertion;
|
||||
text(text: string): Assertion;
|
||||
value(text: string): Assertion;
|
||||
(selector: string): Assertion;
|
||||
descendants(selector: string): Assertion;
|
||||
visible: Assertion;
|
||||
hidden: Assertion;
|
||||
selected: Assertion;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/// <reference path="chroma-js-0.5.6.d.ts" />
|
||||
|
||||
function test_chroma() {
|
||||
chroma("red");
|
||||
chroma("#ff0000");
|
||||
chroma("#f00");
|
||||
chroma("FF0000");
|
||||
chroma(255, 0, 0);
|
||||
chroma([255, 0, 0]);
|
||||
chroma(0, 1, 0.5, 'hsl');
|
||||
chroma([0, 1, 0.5], 'hsl');
|
||||
chroma(0, 1, 1, 'hsv');
|
||||
chroma("rgb(255,0,0)");
|
||||
chroma("rgb(100%,0%,0%)");
|
||||
chroma("hsl(0,100%,50%)");
|
||||
chroma(53.24, 80.09, 67.20, 'lab');
|
||||
chroma(53.24, 104.55, 40, 'lch');
|
||||
chroma(1, 0, 0, 'gl');
|
||||
|
||||
chroma.hex("#ff0000");
|
||||
chroma.hex("red");
|
||||
chroma.hex("rgb(255, 0, 0)");
|
||||
|
||||
chroma.rgb(255, 0, 0);
|
||||
chroma.hsl(0, 1, 0.5);
|
||||
chroma.hsv(120, 0.5, 0.5);
|
||||
chroma.lab(53.24, 80.09, 67.20);
|
||||
chroma.lch(53.24, 104.55, 40);
|
||||
chroma.gl(1, 0, 0);
|
||||
|
||||
chroma.interpolate('white', 'black', 0) // #ffffff
|
||||
chroma.interpolate('white', 'black', 1) // #000000
|
||||
chroma.interpolate('white', 'black', 0.5) // #7f7f7f
|
||||
chroma.interpolate('white', 'black', 0.5, 'hsv') // #808080
|
||||
chroma.interpolate('white', 'black', 0.5, 'lab') // #777777
|
||||
|
||||
chroma.interpolate('rgba(0,0,0,0)', 'rgba(255,0,0,1)', 0.5).css() //"rgba(127.5,0,0,0.5)"
|
||||
|
||||
var bezInterpolator = chroma.interpolate.bezier(['white', 'yellow', 'red', 'black']);
|
||||
bezInterpolator(0).hex() // #ffffff
|
||||
bezInterpolator(0.33).hex() // #ffcc67
|
||||
bezInterpolator(0.66).hex() // #b65f1a
|
||||
bezInterpolator(1).hex() // #000000
|
||||
|
||||
chroma.luminance('black') // 0
|
||||
chroma.luminance('white') // 1
|
||||
chroma.luminance('#ff0000') // 0.2126
|
||||
|
||||
chroma.contrast('white', 'navy') // 16.00 – ok
|
||||
chroma.contrast('white', 'yellow') // 1.07 – not ok!
|
||||
}
|
||||
|
||||
function test_color() {
|
||||
chroma('red').hex() // "#FF0000""
|
||||
chroma('red').rgb() // [255, 0, 0]
|
||||
chroma('red').hsv() // [0, 1, 1]
|
||||
chroma('red').hsl() // [0, 1, 0.5]
|
||||
chroma('red').lab() // [53.2407, 80.0924, 67.2031]
|
||||
chroma('red').lch() // [53.2407, 104.5517, 39.9990]
|
||||
chroma('red').rgba() // [255, 0, 0, 1]
|
||||
chroma('red').css() // "rgb(255,0,0)"
|
||||
chroma('red').alpha(0.7).css() // "rgba(255,0,0,0.7)"
|
||||
chroma('red').css('hsl') // "hsl(0,100%,50%)"
|
||||
chroma('red').alpha(0.7).css('hsl') // "hsla(0,100%,50%,0.7)"
|
||||
chroma('blue').css('hsla') // "hsla(240,100%,50%,1)"
|
||||
|
||||
var red = chroma('red');
|
||||
red.alpha(0.5);
|
||||
red.css(); // rgba(255,0,0,0.5);
|
||||
|
||||
chroma('red').darken().hex() // #BC0000
|
||||
chroma('red').brighten().hex() // #FF603B
|
||||
chroma('#eecc99').saturate().hex() // #fcc973
|
||||
chroma('red').desaturate().hex() // #ec3d23
|
||||
|
||||
chroma('black').luminance() // 0
|
||||
chroma('white').luminance() // 1
|
||||
chroma('red').luminance() // 0.2126
|
||||
}
|
||||
|
||||
function test_scale() {
|
||||
var scale = chroma.scale(['lightyellow', 'navy']);
|
||||
scale(0.5); // #7F7FB0
|
||||
|
||||
chroma.scale('RdYlBu');
|
||||
|
||||
var col = scale(0.5);
|
||||
col.hex(); // #7F7FB0
|
||||
col.rgb(); // [127.5, 127.5, 176]
|
||||
|
||||
scale = chroma.scale(['lightyellow', 'navy']).out('hex');
|
||||
scale(0.5); // "#7F7FB0"
|
||||
|
||||
var scale = chroma.scale(['lightyellow', 'navy']);
|
||||
scale.mode('hsv')(0.5); // #54C08A
|
||||
scale.mode('hsl')(0.5); // #31FF98
|
||||
scale.mode('lab')(0.5); // #967CB2
|
||||
scale.mode('lch')(0.5); // #D26662
|
||||
|
||||
var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 400]);
|
||||
scale(200); // #7F7FB0
|
||||
|
||||
var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 100, 200, 300, 400]);
|
||||
scale(98); // #7F7FB0
|
||||
scale(99); // #7F7FB0
|
||||
scale(100); // #AAAAC0
|
||||
scale(101); // #AAAAC0
|
||||
|
||||
chroma.scale(['#eee', '#900']).domain([0, 400], 7);
|
||||
chroma.scale(['#eee', '#900']).domain([1, 1000000], 7, 'log');
|
||||
chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'quantiles');
|
||||
chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'k-means');
|
||||
chroma.scale(['white', 'red']).domain([0, 100], 4).domain() // [0, 25, 50, 75, 100]
|
||||
|
||||
chroma.scale().range(['lightyellow', 'navy']);
|
||||
|
||||
chroma.scale(['lightyellow', 'navy']).correctLightness(true);
|
||||
|
||||
chroma.scale('RdYlGn').domain([0,1], 5).colors()
|
||||
}
|
||||
Vendored
+317
@@ -0,0 +1,317 @@
|
||||
// Type definitions for Chroma.js v0.5.6
|
||||
// Project: https://github.com/gka/chroma.js
|
||||
// Definitions by: Sebastian Brückner <https://github.com/invliD>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Chroma.js is a tiny library for all kinds of color conversions and color scales.
|
||||
*/
|
||||
declare namespace Chroma {
|
||||
|
||||
export interface ChromaStatic {
|
||||
/**
|
||||
* Creates a color from a string representation (as supported in CSS).
|
||||
*
|
||||
* @param color The string to convert to a color.
|
||||
* @return the color object.
|
||||
*/
|
||||
(color: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using a, b and c as values.
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @param c
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
* @return the color object.
|
||||
*/
|
||||
(a: number, b: number, c: number, colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using values.
|
||||
*
|
||||
* @param values An array of values (e.g. [r, g, b, a?]).
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
* @return the color object.
|
||||
*/
|
||||
(values: number[], colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using a, b and c as values.
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @param c
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
* @return the color object.
|
||||
*/
|
||||
color(a: number, b: number, c: number, colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Calculate the contrast ratio of two colors.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(color1: Color, color2: Color): number;
|
||||
/**
|
||||
* Calculate the contrast ratio of two colors.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(color1: Color, color2: string): number;
|
||||
/**
|
||||
* Calculate the contrast ratio of two colors.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(color1: string, color2: Color): number;
|
||||
/**
|
||||
* Calculate the contrast ratio of two colors.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(color1: string, color2: string): number;
|
||||
|
||||
/**
|
||||
* Create a color from a hex or string representation (as supported in CSS).
|
||||
*
|
||||
* This is an alias of chroma.hex().
|
||||
*
|
||||
* @param color The string to convert to a color.
|
||||
* @return the color object.
|
||||
*/
|
||||
css(color: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color from a hex or string representation (as supported in CSS).
|
||||
*
|
||||
* This is an alias of chroma.css().
|
||||
*
|
||||
* @param color The string to convert to a color.
|
||||
* @return the color object.
|
||||
*/
|
||||
hex(color: string): Color;
|
||||
|
||||
rgb(red: number, green: number, blue: number, alpha?: number): Color;
|
||||
hsl(hue: number, saturation: number, lightness: number, alpha?: number): Color;
|
||||
hsv(hue: number, saturation: number, value: number, alpha?: number): Color;
|
||||
lab(lightness: number, a: number, b: number, alpha?: number): Color;
|
||||
lch(lightness: number, chroma: number, hue: number, alpha?: number): Color;
|
||||
gl(red: number, green: number, blue: number, alpha?: number): Color;
|
||||
|
||||
interpolate: InterpolateFunction;
|
||||
mix: InterpolateFunction;
|
||||
|
||||
luminance(color: Color): number;
|
||||
luminance(color: string): number;
|
||||
|
||||
/**
|
||||
* Creates a color scale using a pre-defined color scale.
|
||||
*
|
||||
* @param name The name of the color scale.
|
||||
* @return the resulting color scale.
|
||||
*/
|
||||
scale(name: string): Scale;
|
||||
|
||||
/**
|
||||
* Creates a color scale function from the given set of colors.
|
||||
*
|
||||
* @param colors An Array of at least two color names or hex values.
|
||||
* @return the resulting color scale.
|
||||
*/
|
||||
scale(colors?: string[]): Scale;
|
||||
|
||||
scales: PredefinedScales;
|
||||
}
|
||||
|
||||
interface InterpolateFunction {
|
||||
(color1: Color, color2: Color, f: number, mode?: string): Color;
|
||||
(color1: Color, color2: string, f: number, mode?: string): Color;
|
||||
(color1: string, color2: Color, f: number, mode?: string): Color;
|
||||
(color1: string, color2: string, f: number, mode?: string): Color;
|
||||
|
||||
bezier(colors: any[]): (t: number) => Color;
|
||||
}
|
||||
|
||||
interface PredefinedScales {
|
||||
[key: string]: Scale;
|
||||
|
||||
cool: Scale;
|
||||
hot: Scale;
|
||||
}
|
||||
|
||||
export interface Color {
|
||||
/**
|
||||
* Creates a color from a string representation (as supported in CSS).
|
||||
*
|
||||
* @param color The string to convert to a color.
|
||||
*/
|
||||
new(color: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using a, b and c as values.
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @param c
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
*/
|
||||
new(a: number, b: number, c: number, colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using a, b and c as color values and alpha as the alpha value.
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @param c
|
||||
* @param alpha The alpha value of the color.
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
*/
|
||||
new(a: number, b: number, c: number, alpha: number, colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using values.
|
||||
*
|
||||
* @param values An array of values (e.g. [r, g, b, a?]).
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
*/
|
||||
new(values: number[], colorSpace: string): Color;
|
||||
|
||||
/**
|
||||
* Convert this color to CSS hex representation.
|
||||
*
|
||||
* @return this color's hex representation.
|
||||
*/
|
||||
hex(): string;
|
||||
|
||||
/**
|
||||
* @return the relative luminance of the color, which is a value between 0 (black) and 1 (white).
|
||||
*/
|
||||
luminance(): number;
|
||||
|
||||
/**
|
||||
* @return the X11 name of this color or its hex value if it does not have a name.
|
||||
*/
|
||||
name(): string;
|
||||
|
||||
/**
|
||||
* @return the alpha value of the color.
|
||||
*/
|
||||
alpha(): number;
|
||||
|
||||
/**
|
||||
* Set the alpha value.
|
||||
*
|
||||
* @param alpha The alpha value.
|
||||
* @return this
|
||||
*/
|
||||
alpha(alpha: number): Color;
|
||||
|
||||
css(mode?: string): string;
|
||||
|
||||
interpolate(color: Color, f: number, mode?: string): Color;
|
||||
interpolate(color: string, f: number, mode?: string): Color;
|
||||
|
||||
premultiply(): Color;
|
||||
|
||||
rgb(): number[];
|
||||
rgba(): number[];
|
||||
hsl(): number[];
|
||||
hsv(): number[];
|
||||
lab(): number[];
|
||||
lch(): number[];
|
||||
hsi(): number[];
|
||||
gl(): number[];
|
||||
|
||||
darken(amount?: number): Color;
|
||||
darker(amount: number): Color;
|
||||
brighten(amount?: number): Color;
|
||||
brighter(amount: number): Color;
|
||||
saturate(amount?: number): Color;
|
||||
desaturate(amount?: number): Color;
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export interface Scale {
|
||||
/**
|
||||
* Interpolate a color using the currently set range and domain.
|
||||
*
|
||||
* @param value The value to use for interpolation.
|
||||
* @return the interpolated hex color OR a Color object (depending on the mode set on this Scale).
|
||||
*/
|
||||
(value: number): any;
|
||||
|
||||
/**
|
||||
* Retreive all possible colors generated by this scale if it has distinct classes.
|
||||
*
|
||||
* @param mode The output mode to use. Must be one of Color's getters. Defaults to "hex".
|
||||
* @return an array of colors in the type specified by mode.
|
||||
*/
|
||||
colors(mode?: string): any[];
|
||||
|
||||
correctLightness(): boolean;
|
||||
|
||||
/**
|
||||
* Enable or disable automatic lightness correction of this scale.
|
||||
*
|
||||
* @param Whether to enable or disable automatic lightness correction.
|
||||
* @return this
|
||||
*/
|
||||
correctLightness(enable: boolean): Scale;
|
||||
|
||||
/**
|
||||
* Get the current domain.
|
||||
*
|
||||
* @return The current domain.
|
||||
*/
|
||||
domain(): number[];
|
||||
|
||||
/**
|
||||
* Set the domain.
|
||||
*
|
||||
* @param domain An Array of at least two numbers (min and max).
|
||||
* @param classes The number of fixed classes to create between min and max.
|
||||
* @param mode The scale to use. Examples: log, quantiles, k-means.
|
||||
* @return this
|
||||
*/
|
||||
domain(domain: number[], classes?: number, mode?: string): Scale;
|
||||
|
||||
/**
|
||||
* Specify in which color space the colors should be interpolated. Defaults to "rgb".
|
||||
* You can use any of the following spaces: rgb, hsv, hsl, lab, lch
|
||||
*
|
||||
* @param colorSpace The color space to use for interpolation.
|
||||
* @return this
|
||||
*/
|
||||
mode(colorSpace: string): Scale;
|
||||
|
||||
/**
|
||||
* Set the output mode of this Scale.
|
||||
*
|
||||
* @param mode The output mode to use. Must be one of Color's getters.
|
||||
* @return this
|
||||
*/
|
||||
out(mode: string): Scale;
|
||||
|
||||
/**
|
||||
* Set the color range after initialization.
|
||||
*
|
||||
* @param colors An Array of at least two color names or hex values.
|
||||
* @return this
|
||||
*/
|
||||
range(colors: string[]): Scale;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare var chroma: Chroma.ChromaStatic;
|
||||
+153
-107
@@ -1,120 +1,166 @@
|
||||
/// <reference path="chroma-js.d.ts" />
|
||||
|
||||
function test_chroma() {
|
||||
chroma("red");
|
||||
chroma("#ff0000");
|
||||
chroma("#f00");
|
||||
chroma("FF0000");
|
||||
chroma(255, 0, 0);
|
||||
chroma([255, 0, 0]);
|
||||
chroma(0, 1, 0.5, 'hsl');
|
||||
chroma([0, 1, 0.5], 'hsl');
|
||||
chroma(0, 1, 1, 'hsv');
|
||||
chroma("rgb(255,0,0)");
|
||||
chroma("rgb(100%,0%,0%)");
|
||||
chroma("hsl(0,100%,50%)");
|
||||
chroma(53.24, 80.09, 67.20, 'lab');
|
||||
chroma(53.24, 104.55, 40, 'lch');
|
||||
chroma(1, 0, 0, 'gl');
|
||||
|
||||
chroma.hex("#ff0000");
|
||||
chroma.hex("red");
|
||||
chroma.hex("rgb(255, 0, 0)");
|
||||
|
||||
chroma.rgb(255, 0, 0);
|
||||
chroma.hsl(0, 1, 0.5);
|
||||
chroma.hsv(120, 0.5, 0.5);
|
||||
chroma.lab(53.24, 80.09, 67.20);
|
||||
chroma.lch(53.24, 104.55, 40);
|
||||
chroma.gl(1, 0, 0);
|
||||
|
||||
chroma.interpolate('white', 'black', 0) // #ffffff
|
||||
chroma.interpolate('white', 'black', 1) // #000000
|
||||
chroma.interpolate('white', 'black', 0.5) // #7f7f7f
|
||||
chroma.interpolate('white', 'black', 0.5, 'hsv') // #808080
|
||||
chroma.interpolate('white', 'black', 0.5, 'lab') // #777777
|
||||
|
||||
chroma.interpolate('rgba(0,0,0,0)', 'rgba(255,0,0,1)', 0.5).css() //"rgba(127.5,0,0,0.5)"
|
||||
|
||||
var bezInterpolator = chroma.interpolate.bezier(['white', 'yellow', 'red', 'black']);
|
||||
bezInterpolator(0).hex() // #ffffff
|
||||
bezInterpolator(0.33).hex() // #ffcc67
|
||||
bezInterpolator(0.66).hex() // #b65f1a
|
||||
bezInterpolator(1).hex() // #000000
|
||||
|
||||
chroma.luminance('black') // 0
|
||||
chroma.luminance('white') // 1
|
||||
chroma.luminance('#ff0000') // 0.2126
|
||||
|
||||
chroma.contrast('white', 'navy') // 16.00 – ok
|
||||
chroma.contrast('white', 'yellow') // 1.07 – not ok!
|
||||
chroma('hotpink');
|
||||
chroma('#ff3399');
|
||||
chroma('F39');
|
||||
chroma.hex("#fff");
|
||||
|
||||
chroma(0xff3399);
|
||||
chroma(0xff, 0x33, 0x99);
|
||||
chroma(255, 51, 153);
|
||||
chroma([255, 51, 153]);
|
||||
chroma(330, 1, 0.6, 'hsl');
|
||||
chroma.hsl(330, 1, 0.6);
|
||||
chroma.lch(80, 40, 130);
|
||||
chroma(80, 40, 130, 'lch');
|
||||
chroma.cmyk(0.2, 0.8, 0, 0);
|
||||
chroma(0.2, 0.8, 0, 0, 'cmyk');
|
||||
chroma.gl(0.6, 0, 0.8);
|
||||
chroma.gl(0.6, 0, 0.8, 0.5);
|
||||
chroma(0.6, 0, 0.8, 'gl');
|
||||
chroma.temperature(2000);
|
||||
chroma.temperature(3500);
|
||||
chroma.temperature(6000);
|
||||
chroma.mix('red', 'blue');
|
||||
chroma.mix('red', 'blue', 0.25);
|
||||
chroma.mix('red', 'blue', 0.5, 'rgb');
|
||||
chroma.mix('red', 'blue', 0.5, 'hsl');
|
||||
chroma.mix('red', 'blue', 0.5, 'lab');
|
||||
chroma.mix('red', 'blue', 0.5, 'lch');
|
||||
chroma.blend('4CBBFC', 'EEEE22', 'multiply');
|
||||
chroma.blend('4CBBFC', 'EEEE22', 'darken');
|
||||
chroma.blend('4CBBFC', 'EEEE22', 'lighten');
|
||||
chroma.random();
|
||||
chroma.contrast('pink', 'hotpink');
|
||||
chroma.contrast('pink', 'purple');
|
||||
chroma.brewer.OrRd;
|
||||
var data = [3.0, 3.5, 3.6, 3.8, 3.8, 4.1, 4.3, 4.4,
|
||||
4.6, 4.9, 5.2, 5.3, 5.4, 5.7, 5.8, 5.9,
|
||||
6.2, 6.5, 6.8, 7.2, 9];
|
||||
chroma.limits(data, 'e', 5);
|
||||
chroma.limits(data, 'q', 5);
|
||||
chroma.limits(data, 'k', 5);
|
||||
}
|
||||
|
||||
function test_color() {
|
||||
chroma('red').hex() // "#FF0000""
|
||||
chroma('red').rgb() // [255, 0, 0]
|
||||
chroma('red').hsv() // [0, 1, 1]
|
||||
chroma('red').hsl() // [0, 1, 0.5]
|
||||
chroma('red').lab() // [53.2407, 80.0924, 67.2031]
|
||||
chroma('red').lch() // [53.2407, 104.5517, 39.9990]
|
||||
chroma('red').rgba() // [255, 0, 0, 1]
|
||||
chroma('red').css() // "rgb(255,0,0)"
|
||||
chroma('red').alpha(0.7).css() // "rgba(255,0,0,0.7)"
|
||||
chroma('red').css('hsl') // "hsl(0,100%,50%)"
|
||||
chroma('red').alpha(0.7).css('hsl') // "hsla(0,100%,50%,0.7)"
|
||||
chroma('blue').css('hsla') // "hsla(240,100%,50%,1)"
|
||||
|
||||
var red = chroma('red');
|
||||
red.alpha(0.5);
|
||||
red.css(); // rgba(255,0,0,0.5);
|
||||
|
||||
chroma('red').darken().hex() // #BC0000
|
||||
chroma('red').brighten().hex() // #FF603B
|
||||
chroma('#eecc99').saturate().hex() // #fcc973
|
||||
chroma('red').desaturate().hex() // #ec3d23
|
||||
|
||||
chroma('black').luminance() // 0
|
||||
chroma('white').luminance() // 1
|
||||
chroma('red').luminance() // 0.2126
|
||||
chroma('red').alpha(0.5);
|
||||
chroma('rgba(255,0,0,0.35)').alpha();
|
||||
chroma('hotpink').darken();
|
||||
chroma('hotpink').darken(2);
|
||||
chroma('hotpink').brighten();
|
||||
chroma('slategray').saturate();
|
||||
chroma('slategray').saturate(2);
|
||||
chroma('hotpink').desaturate();
|
||||
chroma('hotpink').desaturate(2);
|
||||
chroma('hotpink').desaturate(3);
|
||||
// change hue to 0 deg (=red)
|
||||
chroma('skyblue').set('hsl.h', 0);
|
||||
// set chromacity to 30
|
||||
chroma('hotpink').set('lch.c', 30);
|
||||
// half Lab lightness
|
||||
chroma('orangered').set('lab.l', '*0.5');
|
||||
// double Lch saturation
|
||||
chroma('darkseagreen').set('lch.c', '*2');
|
||||
chroma('orangered').get('lab.l');
|
||||
chroma('orangered').get('hsl.l');
|
||||
chroma('orangered').get('rgb.g');
|
||||
chroma('white').luminance();
|
||||
chroma('aquamarine').luminance();
|
||||
chroma('hotpink').luminance();
|
||||
chroma('darkslateblue').luminance();
|
||||
chroma('black').luminance();
|
||||
chroma('white').luminance(0.5);
|
||||
chroma('aquamarine').luminance(0.5);
|
||||
chroma('hotpink').luminance(0.5);
|
||||
chroma('darkslateblue').luminance(0.5);
|
||||
chroma('aquamarine').luminance(0.5);
|
||||
chroma('aquamarine').luminance(0.5, 'lab');
|
||||
chroma('aquamarine').luminance(0.5, 'hsl');
|
||||
chroma('orange').hex();
|
||||
chroma('#ffa500').name();
|
||||
chroma('#ffa505').name();
|
||||
chroma('teal').css();
|
||||
chroma('teal').alpha(0.5).css();
|
||||
chroma('teal').css('hsl');
|
||||
chroma('orange').rgb();
|
||||
chroma('orange').hsl();
|
||||
chroma('white').hsl();
|
||||
chroma('orange').hsv();
|
||||
chroma('white').hsv();
|
||||
chroma('orange').hsi();
|
||||
chroma('white').hsi();
|
||||
chroma('orange').lab();
|
||||
chroma('skyblue').lch();
|
||||
chroma('skyblue').hcl();
|
||||
chroma('#ff3300').temperature();
|
||||
chroma('#ff8a13').temperature();
|
||||
chroma('#ffe3cd').temperature();
|
||||
chroma('#cbdbff').temperature();
|
||||
chroma('#b3ccff').temperature();
|
||||
chroma('33cc00').gl();
|
||||
}
|
||||
|
||||
function test_scale() {
|
||||
var scale = chroma.scale(['lightyellow', 'navy']);
|
||||
scale(0.5); // #7F7FB0
|
||||
var f = chroma.scale();
|
||||
f(0.25);
|
||||
f(0.5);
|
||||
f(0.75);
|
||||
chroma.scale(['yellow', '008ae5']);
|
||||
chroma.scale(['yellow', 'red', 'black']);
|
||||
// default domain is [0,1]
|
||||
chroma.scale(['yellow', '008ae5']);
|
||||
// set domain to [0,100]
|
||||
chroma.scale(['yellow', '008ae5']).domain([0, 100]);
|
||||
// default domain is [0,1]
|
||||
chroma.scale(['yellow', 'lightgreen', '008ae5'])
|
||||
.domain([0, 0.25, 1]);
|
||||
chroma.scale(['yellow', '008ae5']);
|
||||
chroma.scale(['yellow', 'navy']);
|
||||
chroma.scale(['yellow', 'navy']).mode('lab');
|
||||
chroma.scale(['yellow', 'navy']).mode('lab');
|
||||
chroma.scale(['yellow', 'navy']).mode('hsl');
|
||||
chroma.scale(['yellow', 'navy']).mode('lch');
|
||||
chroma.scale('YlGnBu');
|
||||
chroma.scale('Spectral');
|
||||
chroma.scale('Spectral').domain([1, 0]);
|
||||
chroma.brewer.OrRd;
|
||||
chroma.scale(['yellow', '008ae5']).mode('lch');
|
||||
|
||||
chroma.scale(['yellow', '008ae5'])
|
||||
.mode('lch')
|
||||
.correctLightness();
|
||||
// linear interpolation
|
||||
chroma.scale(['yellow', 'red', 'black']);
|
||||
// bezier interpolation
|
||||
chroma.bezier(['yellow', 'red', 'black']);
|
||||
// convert bezier interpolator into chroma.scale
|
||||
chroma.bezier(['yellow', 'red', 'black'])
|
||||
.scale().colors(5);
|
||||
// use the default helix...
|
||||
chroma.cubehelix();
|
||||
// or customize it
|
||||
chroma.cubehelix()
|
||||
.start(200)
|
||||
.rotations(-0.5)
|
||||
.gamma(0.8)
|
||||
.lightness([0.3, 0.8]);
|
||||
|
||||
chroma.cubehelix()
|
||||
.start(200)
|
||||
.rotations(-0.35)
|
||||
.gamma(0.7)
|
||||
.lightness([0.3, 0.8])
|
||||
.scale() // convert to chroma.scale
|
||||
.correctLightness()
|
||||
.colors(5);
|
||||
|
||||
chroma.scale('RdYlBu');
|
||||
chroma.scale('RdYlBu').padding(0.15);
|
||||
|
||||
var col = scale(0.5);
|
||||
col.hex(); // #7F7FB0
|
||||
col.rgb(); // [127.5, 127.5, 176]
|
||||
chroma.scale('OrRd');
|
||||
chroma.scale('OrRd').padding([0.2, 0]);
|
||||
|
||||
scale = chroma.scale(['lightyellow', 'navy']).out('hex');
|
||||
scale(0.5); // "#7F7FB0"
|
||||
|
||||
var scale = chroma.scale(['lightyellow', 'navy']);
|
||||
scale.mode('hsv')(0.5); // #54C08A
|
||||
scale.mode('hsl')(0.5); // #31FF98
|
||||
scale.mode('lab')(0.5); // #967CB2
|
||||
scale.mode('lch')(0.5); // #D26662
|
||||
|
||||
var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 400]);
|
||||
scale(200); // #7F7FB0
|
||||
|
||||
var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 100, 200, 300, 400]);
|
||||
scale(98); // #7F7FB0
|
||||
scale(99); // #7F7FB0
|
||||
scale(100); // #AAAAC0
|
||||
scale(101); // #AAAAC0
|
||||
|
||||
chroma.scale(['#eee', '#900']).domain([0, 400], 7);
|
||||
chroma.scale(['#eee', '#900']).domain([1, 1000000], 7, 'log');
|
||||
chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'quantiles');
|
||||
chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'k-means');
|
||||
chroma.scale(['white', 'red']).domain([0, 100], 4).domain() // [0, 25, 50, 75, 100]
|
||||
|
||||
chroma.scale().range(['lightyellow', 'navy']);
|
||||
|
||||
chroma.scale(['lightyellow', 'navy']).correctLightness(true);
|
||||
|
||||
chroma.scale('RdYlGn').domain([0,1], 5).colors()
|
||||
}
|
||||
chroma.scale('OrRd').classes(5);
|
||||
chroma.scale('OrRd').classes(8);
|
||||
}
|
||||
Vendored
+174
-226
@@ -1,14 +1,14 @@
|
||||
// Type definitions for Chroma.js v0.5.6
|
||||
// Type definitions for Chroma.js v1.1.1
|
||||
// Project: https://github.com/gka/chroma.js
|
||||
// Definitions by: Sebastian Brückner <https://github.com/invliD>
|
||||
// Definitions by: Sebastian Brückner <https://github.com/invliD>, Marcin Pacholec <https://github.com/mpacholec>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Chroma.js is a tiny library for all kinds of color conversions and color scales.
|
||||
*/
|
||||
declare namespace Chroma {
|
||||
|
||||
export interface ChromaStatic {
|
||||
|
||||
/**
|
||||
* Creates a color from a string representation (as supported in CSS).
|
||||
*
|
||||
@@ -17,6 +17,14 @@ declare namespace Chroma {
|
||||
*/
|
||||
(color: string): Color;
|
||||
|
||||
/**
|
||||
* Creates a color from a number representation [0; 16777215]
|
||||
*
|
||||
* @param color The number to convert to a color.
|
||||
* @return the color object.
|
||||
*/
|
||||
(number: number): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using a, b and c as values.
|
||||
*
|
||||
@@ -25,72 +33,20 @@ declare namespace Chroma {
|
||||
* @param c
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
* @return the color object.
|
||||
*/
|
||||
*/
|
||||
(a: number, b: number, c: number, colorSpace?: string): Color;
|
||||
|
||||
(a: number, b: number, c: number, d: number, colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using values.
|
||||
*
|
||||
* @param values An array of values (e.g. [r, g, b, a?]).
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
* @return the color object.
|
||||
*/
|
||||
* Create a color in the specified color space using values.
|
||||
*
|
||||
* @param values An array of values (e.g. [r, g, b, a?]).
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
* @return the color object.
|
||||
*/
|
||||
(values: number[], colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using a, b and c as values.
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @param c
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
* @return the color object.
|
||||
*/
|
||||
color(a: number, b: number, c: number, colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Calculate the contrast ratio of two colors.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(color1: Color, color2: Color): number;
|
||||
/**
|
||||
* Calculate the contrast ratio of two colors.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(color1: Color, color2: string): number;
|
||||
/**
|
||||
* Calculate the contrast ratio of two colors.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(color1: string, color2: Color): number;
|
||||
/**
|
||||
* Calculate the contrast ratio of two colors.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(color1: string, color2: string): number;
|
||||
|
||||
/**
|
||||
* Create a color from a hex or string representation (as supported in CSS).
|
||||
*
|
||||
* This is an alias of chroma.hex().
|
||||
*
|
||||
* @param color The string to convert to a color.
|
||||
* @return the color object.
|
||||
*/
|
||||
css(color: string): Color;
|
||||
|
||||
/**
|
||||
* Create a color from a hex or string representation (as supported in CSS).
|
||||
*
|
||||
@@ -101,217 +57,209 @@ declare namespace Chroma {
|
||||
*/
|
||||
hex(color: string): Color;
|
||||
|
||||
rgb(red: number, green: number, blue: number, alpha?: number): Color;
|
||||
hsl(hue: number, saturation: number, lightness: number, alpha?: number): Color;
|
||||
hsv(hue: number, saturation: number, value: number, alpha?: number): Color;
|
||||
hsl(h: number, s: number, l: number): Color;
|
||||
|
||||
hsv(h: number, s: number, v: number): Color;
|
||||
|
||||
lab(lightness: number, a: number, b: number, alpha?: number): Color;
|
||||
lch(lightness: number, chroma: number, hue: number, alpha?: number): Color;
|
||||
|
||||
lch(l: number, c: number, h: number): Color;
|
||||
|
||||
rgb(r: number, g: number, b: number): Color;
|
||||
|
||||
/**
|
||||
* GL is a variant of RGB(A), with the only difference that the components are normalized to the range of 0..1.
|
||||
*/
|
||||
gl(red: number, green: number, blue: number, alpha?: number): Color;
|
||||
|
||||
interpolate: InterpolateFunction;
|
||||
mix: InterpolateFunction;
|
||||
/**
|
||||
* light 2000K, bright sunlight 6000K. Based on Neil Bartlett's implementation.
|
||||
* https://github.com/neilbartlett/color-temperature
|
||||
*/
|
||||
temperature(t: number): Color;
|
||||
|
||||
luminance(color: Color): number;
|
||||
luminance(color: string): number;
|
||||
mix(col1: string | Color, col2: string | Color, f?: number, colorSpace?: string): Color;
|
||||
|
||||
interpolate(col1: string | Color, col2: string | Color, f?: number, colorSpace?: string): Color;
|
||||
|
||||
/**
|
||||
* Creates a color scale using a pre-defined color scale.
|
||||
*
|
||||
* @param name The name of the color scale.
|
||||
* @return the resulting color scale.
|
||||
* Blends two colors using RGB channel-wise blend functions. Valid blend modes are multiply, darken, lighten, screen, overlay, burn, and dogde.
|
||||
*/
|
||||
blend(col1: string, col2: string, blendMode: string): Color;
|
||||
|
||||
/**
|
||||
* Returns a random color.
|
||||
*/
|
||||
random(): Color;
|
||||
|
||||
/**
|
||||
* Computes the WCAG contrast ratio between two colors.
|
||||
* A minimum contrast of 4.5:1 is recommended to ensure that text is still readable against a background color.
|
||||
*
|
||||
* @param color1 The first color.
|
||||
* @param color2 The second color.
|
||||
* @return the contrast ratio.
|
||||
*/
|
||||
contrast(col1: string | Color, col2: string | Color): number;
|
||||
|
||||
bezier(colors: string[]): Scale;
|
||||
|
||||
/**
|
||||
* chroma.brewer is an map of ColorBrewer scales that are included in chroma.js for convenience.
|
||||
* chroma.scale uses the colors to construct.
|
||||
*/
|
||||
brewer: {
|
||||
OrRd: string[];
|
||||
PuBu: string[];
|
||||
BuPu: string[];
|
||||
Oranges: string[];
|
||||
BuGn: string[];
|
||||
YlOrBr: string[];
|
||||
YlGn: string[];
|
||||
Reds: string[];
|
||||
RdPu: string[];
|
||||
Greens: string[];
|
||||
YlGnBu: string[];
|
||||
Purples: string[];
|
||||
GnBu: string[];
|
||||
Greys: string[];
|
||||
YlOrRd: string[];
|
||||
PuRd: string[];
|
||||
Blues: string[];
|
||||
PuBuGn: string[];
|
||||
Spectral: string[];
|
||||
RdYlGn: string[];
|
||||
RdBu: string[];
|
||||
PiYG: string[];
|
||||
PRGn: string[];
|
||||
RdYlBu: string[];
|
||||
BrBG: string[];
|
||||
RdGy: string[];
|
||||
PuOr: string[];
|
||||
Set2: string[];
|
||||
Accent: string[];
|
||||
Set1: string[];
|
||||
Set3: string[];
|
||||
Dark2: string[];
|
||||
Paired: string[];
|
||||
Pastel2: string[];
|
||||
Pastel1: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function that computes class breaks for you, based on actual data.
|
||||
* Supports three different modes: equidistant breaks, quantiles breaks and breaks based on k-means clusting.
|
||||
*/
|
||||
limits(data: number[], mode: string, c: number): number[];
|
||||
|
||||
scale(name: string): Scale;
|
||||
|
||||
/**
|
||||
* Creates a color scale function from the given set of colors.
|
||||
*
|
||||
* @param colors An Array of at least two color names or hex values.
|
||||
* @return the resulting color scale.
|
||||
*/
|
||||
scale(colors?: string[]): Scale;
|
||||
|
||||
scales: PredefinedScales;
|
||||
}
|
||||
cubehelix(): Cubehelix;
|
||||
|
||||
interface InterpolateFunction {
|
||||
(color1: Color, color2: Color, f: number, mode?: string): Color;
|
||||
(color1: Color, color2: string, f: number, mode?: string): Color;
|
||||
(color1: string, color2: Color, f: number, mode?: string): Color;
|
||||
(color1: string, color2: string, f: number, mode?: string): Color;
|
||||
|
||||
bezier(colors: any[]): (t: number) => Color;
|
||||
}
|
||||
|
||||
interface PredefinedScales {
|
||||
[key: string]: Scale;
|
||||
|
||||
cool: Scale;
|
||||
hot: Scale;
|
||||
cmyk(c: number, m: number, y: number, k: number): Color;
|
||||
|
||||
/**
|
||||
* Create a color from a hex or string representation (as supported in CSS).
|
||||
*
|
||||
* This is an alias of chroma.hex().
|
||||
*
|
||||
* @param color The string to convert to a color.
|
||||
* @return the color object.
|
||||
*/
|
||||
css(col: string, mode?: string): string;
|
||||
}
|
||||
|
||||
export interface Color {
|
||||
/**
|
||||
* Creates a color from a string representation (as supported in CSS).
|
||||
*
|
||||
* @param color The string to convert to a color.
|
||||
*/
|
||||
new(color: string): Color;
|
||||
alpha(a?: number): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using a, b and c as values.
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @param c
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
*/
|
||||
new(a: number, b: number, c: number, colorSpace?: string): Color;
|
||||
darken(f?: number): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using a, b and c as color values and alpha as the alpha value.
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @param c
|
||||
* @param alpha The alpha value of the color.
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
*/
|
||||
new(a: number, b: number, c: number, alpha: number, colorSpace?: string): Color;
|
||||
brighten(f?: number): Color;
|
||||
|
||||
/**
|
||||
* Create a color in the specified color space using values.
|
||||
*
|
||||
* @param values An array of values (e.g. [r, g, b, a?]).
|
||||
* @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
|
||||
*/
|
||||
new(values: number[], colorSpace: string): Color;
|
||||
saturate(s?: number): Color;
|
||||
|
||||
/**
|
||||
* Convert this color to CSS hex representation.
|
||||
*
|
||||
* @return this color's hex representation.
|
||||
*/
|
||||
hex(): string;
|
||||
desaturate(s?: number): Color;
|
||||
|
||||
set(modechan: string, v: number | string): Color;
|
||||
|
||||
get(modechan: string): number;
|
||||
|
||||
/**
|
||||
* @return the relative luminance of the color, which is a value between 0 (black) and 1 (white).
|
||||
*/
|
||||
luminance(): number;
|
||||
|
||||
/**
|
||||
* @return the X11 name of this color or its hex value if it does not have a name.
|
||||
*/
|
||||
luminance(l: number, mode?: string): Color;
|
||||
|
||||
hex(): string;
|
||||
|
||||
name(): string;
|
||||
|
||||
/**
|
||||
* @return the alpha value of the color.
|
||||
*/
|
||||
alpha(): number;
|
||||
|
||||
/**
|
||||
* Set the alpha value.
|
||||
* Create a color from a hex or string representation (as supported in CSS).
|
||||
*
|
||||
* @param alpha The alpha value.
|
||||
* @return this
|
||||
* This is an alias of chroma.hex().
|
||||
*
|
||||
* @param color The string to convert to a color.
|
||||
* @return the color object.
|
||||
*/
|
||||
alpha(alpha: number): Color;
|
||||
|
||||
css(mode?: string): string;
|
||||
|
||||
interpolate(color: Color, f: number, mode?: string): Color;
|
||||
interpolate(color: string, f: number, mode?: string): Color;
|
||||
|
||||
premultiply(): Color;
|
||||
|
||||
rgb(): number[];
|
||||
|
||||
rgba(): number[];
|
||||
|
||||
hsl(): number[];
|
||||
|
||||
hsv(): number[];
|
||||
lab(): number[];
|
||||
lch(): number[];
|
||||
|
||||
hsi(): number[];
|
||||
|
||||
lab(): number[];
|
||||
|
||||
lch(): number[];
|
||||
|
||||
hcl(): number[];
|
||||
|
||||
temperature(): number;
|
||||
|
||||
gl(): number[];
|
||||
|
||||
darken(amount?: number): Color;
|
||||
darker(amount: number): Color;
|
||||
brighten(amount?: number): Color;
|
||||
brighter(amount: number): Color;
|
||||
saturate(amount?: number): Color;
|
||||
desaturate(amount?: number): Color;
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
export interface Scale {
|
||||
/**
|
||||
* Interpolate a color using the currently set range and domain.
|
||||
*
|
||||
* @param value The value to use for interpolation.
|
||||
* @return the interpolated hex color OR a Color object (depending on the mode set on this Scale).
|
||||
*/
|
||||
(c: string[]): Scale;
|
||||
|
||||
(value: number): any;
|
||||
|
||||
/**
|
||||
* Retreive all possible colors generated by this scale if it has distinct classes.
|
||||
*
|
||||
* @param mode The output mode to use. Must be one of Color's getters. Defaults to "hex".
|
||||
* @return an array of colors in the type specified by mode.
|
||||
*/
|
||||
colors(mode?: string): any[];
|
||||
domain(d?: number[], n?: number, mode?: string): Scale;
|
||||
|
||||
correctLightness(): boolean;
|
||||
mode(mode: string): Scale;
|
||||
|
||||
/**
|
||||
* Enable or disable automatic lightness correction of this scale.
|
||||
*
|
||||
* @param Whether to enable or disable automatic lightness correction.
|
||||
* @return this
|
||||
*/
|
||||
correctLightness(enable: boolean): Scale;
|
||||
correctLightness(enable?: boolean): Scale;
|
||||
|
||||
/**
|
||||
* Get the current domain.
|
||||
*
|
||||
* @return The current domain.
|
||||
*/
|
||||
domain(): number[];
|
||||
bezier(colors: string[]): Scale;
|
||||
|
||||
/**
|
||||
* Set the domain.
|
||||
*
|
||||
* @param domain An Array of at least two numbers (min and max).
|
||||
* @param classes The number of fixed classes to create between min and max.
|
||||
* @param mode The scale to use. Examples: log, quantiles, k-means.
|
||||
* @return this
|
||||
*/
|
||||
domain(domain: number[], classes?: number, mode?: string): Scale;
|
||||
padding(p: number | number[]): Scale;
|
||||
|
||||
/**
|
||||
* Specify in which color space the colors should be interpolated. Defaults to "rgb".
|
||||
* You can use any of the following spaces: rgb, hsv, hsl, lab, lch
|
||||
*
|
||||
* @param colorSpace The color space to use for interpolation.
|
||||
* @return this
|
||||
*/
|
||||
mode(colorSpace: string): Scale;
|
||||
colors(c?: number): string[];
|
||||
|
||||
classes(c: number | number[]): (t: number) => Color;
|
||||
|
||||
range(arg: string[]): Scale;
|
||||
|
||||
scale(): Scale;
|
||||
|
||||
/**
|
||||
* Set the output mode of this Scale.
|
||||
*
|
||||
* @param mode The output mode to use. Must be one of Color's getters.
|
||||
* @return this
|
||||
*/
|
||||
out(mode: string): Scale;
|
||||
|
||||
/**
|
||||
* Set the color range after initialization.
|
||||
*
|
||||
* @param colors An Array of at least two color names or hex values.
|
||||
* @return this
|
||||
*/
|
||||
range(colors: string[]): Scale;
|
||||
}
|
||||
|
||||
export interface Cubehelix extends Scale {
|
||||
start(s: number): Cubehelix;
|
||||
|
||||
rotations(r: number): Cubehelix;
|
||||
|
||||
gamma(g: number): Cubehelix;
|
||||
|
||||
lightness(l: number[]): Cubehelix;
|
||||
}
|
||||
}
|
||||
|
||||
declare var chroma: Chroma.ChromaStatic;
|
||||
|
||||
Vendored
+6
-4
@@ -7219,7 +7219,7 @@ declare namespace chrome.webRequest {
|
||||
* Optional.
|
||||
* If the request method is POST and the body is a sequence of key-value pairs encoded in UTF8, encoded as either multipart/form-data, or application/x-www-form-urlencoded, this dictionary is present and for each key contains the list of all values for that key. If the data is of another media type, or if it is malformed, the dictionary is not present. An example value of this dictionary is {'key': ['value1', 'value2']}.
|
||||
*/
|
||||
formData?: Object;
|
||||
formData?: { [key: string]: string[] };
|
||||
/**
|
||||
* Optional.
|
||||
* If the request method is PUT or POST, and the body is not already parsed in formData, then the unparsed request body elements are contained in this array.
|
||||
@@ -7233,6 +7233,7 @@ declare namespace chrome.webRequest {
|
||||
}
|
||||
|
||||
interface ResourceRequest {
|
||||
url: string;
|
||||
/** The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request. */
|
||||
requestId: string;
|
||||
/** The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (type is main_frame or sub_frame), frameId indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab. */
|
||||
@@ -7251,7 +7252,6 @@ declare namespace chrome.webRequest {
|
||||
}
|
||||
|
||||
interface WebRequestDetails extends ResourceRequest {
|
||||
url: string;
|
||||
/** Standard HTTP method. */
|
||||
method: string;
|
||||
}
|
||||
@@ -7304,7 +7304,7 @@ declare namespace chrome.webRequest {
|
||||
|
||||
interface WebAuthenticationChallengeDetails extends WebResponseHeadersDetails {
|
||||
/** The authentication scheme, e.g. Basic or Digest. */
|
||||
schema: string;
|
||||
scheme: string;
|
||||
/** The authentication realm provided by the server, if there is one. */
|
||||
realm?: string;
|
||||
/** The server requesting authentication. */
|
||||
@@ -7336,7 +7336,9 @@ declare namespace chrome.webRequest {
|
||||
|
||||
interface WebRedirectionResponseEvent extends _WebResponseHeadersEvent<WebRedirectionResponseDetails> {}
|
||||
|
||||
interface WebAuthenticationChallengeEvent extends chrome.events.Event<(details: WebAuthenticationChallengeDetails, callback?: (response: BlockingResponse) => void) => void> {}
|
||||
interface WebAuthenticationChallengeEvent extends chrome.events.Event<(details: WebAuthenticationChallengeDetails, callback?: (response: BlockingResponse) => void) => void> {
|
||||
addListener(callback: (details: WebAuthenticationChallengeDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
interface WebResponseErrorEvent extends _WebResponseHeadersEvent<WebResponseErrorDetails> {}
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/// <reference path="countdown.d.ts" />
|
||||
|
||||
import { countdown, Timespan, CountdownStatic, Format } from 'countdown';
|
||||
|
||||
let ts: Timespan;
|
||||
let interval: number;
|
||||
|
||||
ts = <Timespan>countdown(new Date());
|
||||
ts = <Timespan>countdown(150);
|
||||
|
||||
interval = <number>countdown(new Date(),
|
||||
function (ts: Timespan) {
|
||||
document.getElementById('pageTimer').innerHTML = ts.toHTML('strong');
|
||||
},
|
||||
countdown.HOURS | countdown.MINUTES | countdown.SECONDS,
|
||||
2,
|
||||
2
|
||||
);
|
||||
|
||||
clearInterval(interval);
|
||||
|
||||
ts.toString('foo');
|
||||
ts.toHTML('em', 'foo');
|
||||
|
||||
countdown.resetFormat();
|
||||
countdown.setLabels('a', 'b', 'c', 'd', 'e');
|
||||
|
||||
countdown.setLabels('a', 'b', 'c', 'd', 'e', function (value: number): string {
|
||||
return 'ok';
|
||||
}, function (value: number, unit: number): string {
|
||||
return 'ok';
|
||||
});
|
||||
|
||||
countdown.setLabels(null, null, null, null, 'Now.');
|
||||
|
||||
countdown.setLabels(
|
||||
' millisecond| second| minute| hour| day| week| month| year| decade| century| millennium',
|
||||
' milliseconds| seconds| minutes| hours| days| weeks| months| years| decades| centuries| millennia',
|
||||
' and ',
|
||||
', ',
|
||||
'',
|
||||
n => n.toString());
|
||||
Vendored
+69
@@ -0,0 +1,69 @@
|
||||
// Type definitions for countdown.js
|
||||
// Project: http://countdownjs.org/
|
||||
// Definitions by: Gabriel Juchault <https://github.com/gjuchault>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'countdown' {
|
||||
export type DateFunction = (timespan: Timespan) => void;
|
||||
export type DateTime = number | Date | DateFunction;
|
||||
|
||||
export interface Timespan {
|
||||
start?: Date;
|
||||
end?: Date;
|
||||
units?: number;
|
||||
value?: number;
|
||||
millennia?: number;
|
||||
centuries?: number;
|
||||
decades?: number;
|
||||
years?: number;
|
||||
months?: number;
|
||||
days?: number;
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
milliseconds?: number;
|
||||
toString(label?: string): string;
|
||||
toHTML(tagName?: string, label?: string): string;
|
||||
}
|
||||
|
||||
export interface Format {
|
||||
singular?: string | Array<string>;
|
||||
plural?: string | Array<string>;
|
||||
last?: string;
|
||||
delim?: string;
|
||||
empty?: string;
|
||||
formatNumber?(value: number): string;
|
||||
formatter?(value: number, unit: number): string;
|
||||
}
|
||||
|
||||
export interface CountdownStatic {
|
||||
(start: DateTime, end?: DateTime, units?: number, max?: number, digits?: number): Timespan | number;
|
||||
MILLENNIA: number;
|
||||
CENTURIES: number;
|
||||
DECADES: number;
|
||||
YEARS: number;
|
||||
MONTHS: number;
|
||||
WEEKS: number;
|
||||
DAYS: number;
|
||||
HOURS: number;
|
||||
MINUTES: number;
|
||||
SECONDS: number;
|
||||
MILLISECONDS: number;
|
||||
ALL: number;
|
||||
DEFAULTS: number;
|
||||
resetLabels(): void;
|
||||
setLabels(
|
||||
singular?: string,
|
||||
plural?: string,
|
||||
last?: string,
|
||||
delim?: string,
|
||||
empty?: string,
|
||||
formatNumber?: (value: number) => string,
|
||||
formatter?: (value: number, unit: number) => string
|
||||
): void;
|
||||
resetFormat(): void;
|
||||
setFormat(format: Format): void;
|
||||
}
|
||||
|
||||
export let countdown: CountdownStatic;
|
||||
}
|
||||
@@ -1,2 +1,16 @@
|
||||
/// <reference path="./cropperjs.d.ts"/>
|
||||
import * as Cropper from 'cropperjs';
|
||||
|
||||
var image = <HTMLImageElement>document.getElementById('image');
|
||||
var cropper = new Cropper(image, {
|
||||
aspectRatio: 16 / 9,
|
||||
crop: function(e) {
|
||||
console.log(e.detail.x);
|
||||
console.log(e.detail.y);
|
||||
console.log(e.detail.width);
|
||||
console.log(e.detail.height);
|
||||
console.log(e.detail.rotate);
|
||||
console.log(e.detail.scaleX);
|
||||
console.log(e.detail.scaleY);
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+19
@@ -11,7 +11,26 @@ declare module cropperjs {
|
||||
CanvasShouldNotBeWithInTheContainer = 2,
|
||||
ContainerSshouldBeWithInTheCanvas = 3
|
||||
}
|
||||
export interface CropperCustomEvent extends CustomEvent {
|
||||
detail: Data;
|
||||
}
|
||||
export interface CropperOptions {
|
||||
/**
|
||||
* Function called when crop box is moved or resized
|
||||
*/
|
||||
crop?: (event: CropperCustomEvent) => void;
|
||||
/**
|
||||
* Function called at start of crop box being moved or resized
|
||||
*/
|
||||
cropstart?: (event: CropperCustomEvent) => void;
|
||||
/**
|
||||
* Function called when crop box is moved
|
||||
*/
|
||||
cropmove?: (event: CropperCustomEvent) => void;
|
||||
/**
|
||||
* Function called when crop box is finished being moved or resized
|
||||
*/
|
||||
cropend?: (event: CropperCustomEvent) => void;
|
||||
/**
|
||||
* Define the view mode of the cropper.
|
||||
* @default 0
|
||||
|
||||
Vendored
+1
-1
@@ -1606,7 +1606,7 @@ declare module dijit {
|
||||
* already removed/destroyed manually.
|
||||
*
|
||||
*/
|
||||
own(): any;
|
||||
own(...args: any[]): any[];
|
||||
/**
|
||||
* Place this widget somewhere in the DOM based
|
||||
* on standard domConstruct.place() conventions.
|
||||
|
||||
Vendored
+1
-1
@@ -5686,7 +5686,7 @@ declare namespace dojo {
|
||||
* @param dest The object to which to copy/add all properties contained in source. If dest is falsy, thena new object is manufactured before copying/adding properties begins.
|
||||
* @param sources One of more objects from which to draw all properties to copy into dest. sources are processedleft-to-right and if more than one of these objects contain the same property name, the right-mostvalue "wins".
|
||||
*/
|
||||
mixin(dest: Object, sources: Object[]): Object;
|
||||
mixin(dest: Object, source: Object, sources?: Object[]): Object;
|
||||
/**
|
||||
* similar to hitch() except that the scope object is left to be
|
||||
* whatever the execution context eventually becomes.
|
||||
|
||||
@@ -18,17 +18,15 @@ fetchMock.mock(/test/, {
|
||||
}
|
||||
});
|
||||
|
||||
fetchMock.reMock();
|
||||
|
||||
fetchMock.restore().reset();
|
||||
|
||||
fetchMock.calls().matched[0][1].body;
|
||||
(fetchMock.calls().matched[0][1] as RequestInit).body;
|
||||
fetchMock.calls().unmatched[0][0].toUpperCase();
|
||||
fetchMock.calls("http://test.com")[0][0].toUpperCase();
|
||||
fetchMock.calls("http://test.com")[0][1].body;
|
||||
(fetchMock.calls("http://test.com")[0][1] as RequestInit).body;
|
||||
|
||||
fetchMock.called("http://test.com");
|
||||
|
||||
fetchMock.lastCall()[1].body;
|
||||
(fetchMock.lastCall()[1] as RequestInit).body;
|
||||
fetchMock.lastUrl();
|
||||
fetchMock.lastOptions();
|
||||
|
||||
Vendored
+126
-63
@@ -1,40 +1,32 @@
|
||||
// Type definitions for fetch-mock 4.6.0
|
||||
// Type definitions for fetch-mock 5.0.0
|
||||
// Project: https://github.com/wheresrhys/fetch-mock
|
||||
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>, Tamir Duberstein <https://github.com/tamird>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/// <reference path="../whatwg-fetch/whatwg-fetch.d.ts" />
|
||||
|
||||
|
||||
declare module "fetch-mock" {
|
||||
type MockRequest = Request | RequestInit;
|
||||
|
||||
/**
|
||||
* Mock matcher function
|
||||
* @param url
|
||||
* @param opts
|
||||
*/
|
||||
type MockMatcherFunction = (url: string, opts: any) => boolean;
|
||||
type MockMatcherFunction = (url: string, opts: MockRequest) => boolean
|
||||
/**
|
||||
* Mock matcher. Can be one of following:
|
||||
* string: Either an exact url to match e.g. 'http://www.site.com/page.html' or, if the string begins with a ^, the string following the ^ must begin the url
|
||||
* e.g. '^http://www.site.com' would match 'http://www.site.com' or 'http://www.site.com/page.html'
|
||||
* string: Either
|
||||
* an exact url to match e.g. 'http://www.site.com/page.html'
|
||||
* if the string begins with a `^`, the string following the `^` must
|
||||
begin the url e.g. '^http://www.site.com' would match
|
||||
'http://www.site.com' or 'http://www.site.com/page.html'
|
||||
* '*' to match any url
|
||||
* RegExp: A regular expression to test the url against
|
||||
* Function(url, opts): A function (returning a Boolean) that is passed the url and opts fetch() is called with (or, if fetch() was called with one, the Request instance)
|
||||
* Function(url, opts): A function (returning a Boolean) that is passed the
|
||||
url and opts fetch() is called with (or, if fetch() was called with one,
|
||||
the Request instance)
|
||||
*/
|
||||
type MockMatcher = string | RegExp | Function | MockMatcherFunction;
|
||||
|
||||
/**
|
||||
* Mock response function
|
||||
* @param url
|
||||
* @param opts
|
||||
*/
|
||||
type MockResponseFunction = (url: string, opts: any) => MockResponse;
|
||||
/**
|
||||
* number: Creates a response with this status
|
||||
* string: Creates a 200 response with the string as the response body
|
||||
* object: As long as the object does not contain any of the properties below it is converted into a json string and returned as the body of a 200 response.
|
||||
* If MockResponseObject was given then it's used to configure response
|
||||
*/
|
||||
type MockResponse = number | string | MockResponseObject | {};
|
||||
|
||||
type MockMatcher = string | RegExp | MockMatcherFunction;
|
||||
|
||||
/**
|
||||
* Mock response object
|
||||
@@ -52,93 +44,164 @@ declare module "fetch-mock" {
|
||||
/**
|
||||
* Set the response headers.
|
||||
*/
|
||||
headers?: { [key: string]: any };
|
||||
headers?: { [key: string]: string };
|
||||
/**
|
||||
* If this property is present then a Promise rejected with the value of throws is returned
|
||||
* If this property is present then a Promise rejected with the value
|
||||
of throws is returned
|
||||
*/
|
||||
throws?: boolean;
|
||||
/**
|
||||
* This property determines whether or not the request body should be JSON.stringified before being sent
|
||||
* This property determines whether or not the request body should be
|
||||
JSON.stringified before being sent
|
||||
* @default true
|
||||
*/
|
||||
sendAsJson?: boolean;
|
||||
}
|
||||
/**
|
||||
* Response: A Response instance - will be used unaltered
|
||||
* number: Creates a response with this status
|
||||
* string: Creates a 200 response with the string as the response body
|
||||
* object: As long as the object is not a MockResponseObject it is
|
||||
converted into a json string and returned as the body of a 200 response
|
||||
* If MockResponseObject was given then it's used to configure response
|
||||
* Function(url, opts): A function that is passed the url and opts fetch()
|
||||
is called with and that returns any of the responses listed above
|
||||
*/
|
||||
type MockResponse = Response | Promise<Response>
|
||||
| number | Promise<number>
|
||||
| string | Promise<string>
|
||||
| Object | Promise<Object>
|
||||
| MockResponseObject | Promise<MockResponseObject>;
|
||||
/**
|
||||
* Mock response function
|
||||
* @param url
|
||||
* @param opts
|
||||
*/
|
||||
type MockResponseFunction = (url: string, opts: MockRequest) => MockResponse;
|
||||
|
||||
interface MockCallOptions {
|
||||
[key: string]: any;
|
||||
/**
|
||||
* Mock options object
|
||||
*/
|
||||
interface MockOptions {
|
||||
/**
|
||||
* A unique string naming the route. Used to subsequently retrieve
|
||||
references to the calls, grouped by name.
|
||||
* @default matcher.toString()
|
||||
*
|
||||
* Note: If a non-unique name is provided no error will be thrown
|
||||
(because names are optional, auto-generated ones may legitimately
|
||||
clash)
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* http method to match
|
||||
*/
|
||||
method?: string;
|
||||
/**
|
||||
* as specified above
|
||||
*/
|
||||
matcher?: MockMatcher;
|
||||
/**
|
||||
* as specified above
|
||||
*/
|
||||
response?: MockResponse | MockResponseFunction;
|
||||
}
|
||||
|
||||
type MockCall = [string, RequestInit];
|
||||
type MockCall = [string, MockRequest];
|
||||
|
||||
interface MatchedRoutes {
|
||||
matched: MockCall[];
|
||||
unmatched: MockCall[];
|
||||
matched: Array<MockCall>;
|
||||
unmatched: Array<MockCall>;
|
||||
}
|
||||
|
||||
interface FetchMockStatic {
|
||||
/**
|
||||
* When using isomorphic-fetch or node-fetch ideally fetch should be added as a global.
|
||||
* If not possible to do so you can still use fetch-mock in combination with mockery or similar in nodejs.
|
||||
* To use fetch-mock with with mockery you may use this function to prevent fetch-mock trying to mock the function globally.
|
||||
* @deprecated
|
||||
*/
|
||||
useNonGlobalFetch(func?: any): void;
|
||||
/**
|
||||
* Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked
|
||||
* Response object or passes the call through to fetch(). Calls to .mock() can be chained.
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
route, and optionally returns a mocked Response object or passes the
|
||||
call through to fetch(). Calls to .mock() can be chained.
|
||||
* @param matcher Condition for selecting which requests to mock
|
||||
* @param response Configures the http response returned by the mock
|
||||
*/
|
||||
mock(matcher: MockMatcher, response?: MockResponse | MockResponseFunction): this;
|
||||
mock(matcher: MockMatcher, response: MockResponse | MockResponseFunction): this;
|
||||
/**
|
||||
* Replaces fetch() with a stub which records its calls, grouped by route, and optionally returns a mocked
|
||||
* Response object or passes the call through to fetch(). Calls to .mock() can be chained.
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
route, and optionally returns a mocked Response object or passes the
|
||||
call through to fetch(). Calls to .mock() can be chained.
|
||||
* @param matcher Condition for selecting which requests to mock
|
||||
* @param method Only matches requests using this http method
|
||||
* @param response Configures the http response returned by the mock
|
||||
* @param options Additional properties defining the route to mock
|
||||
*/
|
||||
mock(matcher: MockMatcher, method?: string, response?: MockResponse | MockMatcherFunction): this;
|
||||
mock(matcher: MockMatcher, response: MockResponse | MockResponseFunction, options: MockOptions): this;
|
||||
/**
|
||||
* Restores fetch() to its unstubbed state and clears all data recorded for its calls
|
||||
* Replaces fetch() with a stub which records its calls, grouped by
|
||||
route, and optionally returns a mocked Response object or passes the
|
||||
call through to fetch(). Calls to .mock() can be chained.
|
||||
* @param options The route to mock
|
||||
*/
|
||||
mock(options: MockOptions): this;
|
||||
/**
|
||||
* Chainable method that restores fetch() to its unstubbed state and
|
||||
clears all data recorded for its calls.
|
||||
*/
|
||||
restore(): this;
|
||||
/**
|
||||
* Clears all data recorded for fetch()'s calls
|
||||
* Chainable method that clears all data recorded for fetch()'s calls
|
||||
*/
|
||||
reset(): this;
|
||||
/**
|
||||
* Calls restore() internally then calls mock(). This allows you to put some generic calls to mock() in a
|
||||
* beforeEach() while retaining the flexibility to vary the responses for some tests. reMock() can be chained.
|
||||
* Returns all calls to fetch, grouped by whether fetch-mock matched
|
||||
them or not.
|
||||
*/
|
||||
reMock(matcher?: MockMatcher, response?: MockResponse | MockResponseFunction): this;
|
||||
reMock(matcher?: MockMatcher, method?: string, response?: MockResponse | MockMatcherFunction): this;
|
||||
|
||||
/**
|
||||
* Returns an object {matched: [], unmatched: []} containing arrays of all calls to fetch, grouped by whether fetch-mock matched them or not.
|
||||
* If matcherName is specified then only calls to fetch matching that route are returned.
|
||||
*/
|
||||
calls(matcher: string): MockCall[];
|
||||
calls(): MatchedRoutes;
|
||||
/**
|
||||
* Returns a Boolean indicating whether fetch was called and a route was matched. If matcherName is specified it only returns true if that particular route was matched.
|
||||
* Returns all calls to fetch matching matcherName.
|
||||
*/
|
||||
called(matcher?: string): boolean;
|
||||
calls(matcherName?: string): Array<MockCall>;
|
||||
/**
|
||||
* Returns a Boolean indicating whether fetch was called and a route
|
||||
was matched.
|
||||
*/
|
||||
called(): boolean;
|
||||
/**
|
||||
* Returns a Boolean indicating whether fetch was called and a route
|
||||
named matcherName was matched.
|
||||
*/
|
||||
called(matcherName?: string): boolean;
|
||||
/**
|
||||
* Returns the arguments for the last matched call to fetch
|
||||
*/
|
||||
lastCall(matcher?: string): MockCall;
|
||||
lastCall(): MockCall;
|
||||
/**
|
||||
* Returns the arguments for the last call to fetch matching
|
||||
matcherName
|
||||
*/
|
||||
lastCall(matcherName?: string): MockCall;
|
||||
/**
|
||||
* Returns the url for the last matched call to fetch
|
||||
*/
|
||||
lastUrl(matcher?: string): string;
|
||||
lastUrl(): string;
|
||||
/**
|
||||
* Returns the url for the last call to fetch matching matcherName
|
||||
*/
|
||||
lastUrl(matcherName?: string): string;
|
||||
/**
|
||||
* Returns the options for the last matched call to fetch
|
||||
*/
|
||||
lastOptions(matcher?: string): MockCallOptions;
|
||||
|
||||
lastOptions(): MockRequest;
|
||||
/**
|
||||
* Returns the options for the last call to fetch matching matcherName
|
||||
*/
|
||||
lastOptions(matcherName?: string): MockRequest;
|
||||
/**
|
||||
* Set some global config options, which include
|
||||
* sendAsJson [default `true`] - by default fetchMock will
|
||||
convert objects to JSON before sending. This is overrideable
|
||||
for each call but for some scenarios, e.g. when dealing with a
|
||||
lot of array buffers, it can be useful to default to `false`
|
||||
*/
|
||||
configure(opts: Object): void;
|
||||
}
|
||||
|
||||
var fetchMock: FetchMockStatic;
|
||||
export = fetchMock;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,135 @@
|
||||
/// <reference path="form-data.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../request/request.d.ts" />
|
||||
/// <reference path="../isomorphic-fetch/isomorphic-fetch.d.ts" />
|
||||
import FormData = require('form-data');
|
||||
import fs = require('fs');
|
||||
import http = require('http');
|
||||
import request = require('request');
|
||||
|
||||
import formData = require('form-data');
|
||||
import * as ImportUsingES6Syntax from 'form-data';
|
||||
|
||||
var value: any;
|
||||
var fd = new formData.FormData();
|
||||
var obj: Object = fd.getHeaders();
|
||||
value = fd.pipe(value);
|
||||
() => {
|
||||
var form = new FormData();
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
||||
}
|
||||
|
||||
() => {
|
||||
var form = new FormData();
|
||||
|
||||
http.request('http://nodejs.org/images/logo.png', function (response) {
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_logo', response);
|
||||
});
|
||||
}
|
||||
|
||||
() => {
|
||||
var form = new FormData();
|
||||
|
||||
form.append('my_field', 'my value');
|
||||
form.append('my_buffer', new Buffer(10));
|
||||
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
|
||||
}
|
||||
|
||||
() => {
|
||||
var form = new FormData();
|
||||
form.submit('http://example.org/', function (err, res) {
|
||||
// res – response object (http.IncomingMessage) //
|
||||
res.resume();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
() => {
|
||||
var form = new FormData();
|
||||
var request = http.request({
|
||||
method: 'post',
|
||||
host: 'example.org',
|
||||
path: '/upload',
|
||||
headers: form.getHeaders()
|
||||
});
|
||||
|
||||
form.pipe(request);
|
||||
|
||||
request.on('response', function (res: any) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
() => {
|
||||
var form = new FormData();
|
||||
form.submit('example.org/upload', function (err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
}
|
||||
|
||||
() => {
|
||||
var CRLF = '\r\n';
|
||||
var form = new FormData();
|
||||
var buffer = new Buffer('');
|
||||
|
||||
var options = {
|
||||
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
|
||||
knownLength: 1
|
||||
};
|
||||
|
||||
form.append('my_buffer', buffer, options);
|
||||
|
||||
form.submit('http://example.com/', function (err, res) {
|
||||
if (err) throw err;
|
||||
console.log('Done');
|
||||
});
|
||||
}
|
||||
|
||||
() => {
|
||||
var form = new FormData();
|
||||
form.submit({
|
||||
host: 'example.com',
|
||||
path: '/probably.php?extra=params',
|
||||
auth: 'username:password'
|
||||
}, function (err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
}
|
||||
|
||||
() => {
|
||||
var form = new FormData();
|
||||
form.submit({
|
||||
host: 'example.com',
|
||||
path: '/surelynot.php',
|
||||
headers: { 'x-test-header': 'test-header-value' }
|
||||
}, function (err, res) {
|
||||
console.log(res.statusCode);
|
||||
});
|
||||
}
|
||||
|
||||
() => {
|
||||
var formData = {
|
||||
my_field: 'my_value',
|
||||
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
||||
};
|
||||
|
||||
request.post({ url: 'http://service.com/upload', formData: formData }, function (err, httpResponse, body) {
|
||||
if (err) {
|
||||
return console.error('upload failed:', err);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
}
|
||||
|
||||
() => {
|
||||
var form = new FormData();
|
||||
|
||||
form.append('a', 1);
|
||||
|
||||
fetch('http://example.com', { method: 'POST', body: form })
|
||||
.then(function (res) {
|
||||
return res.json();
|
||||
}).then(function (json) {
|
||||
console.log(json);
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+18
-9
@@ -1,16 +1,25 @@
|
||||
// Type definitions for form-data
|
||||
// Project: https://github.com/felixge/node-form-data
|
||||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
|
||||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, Leon Yu <https://github.com/leonyu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts
|
||||
|
||||
declare module "form-data" {
|
||||
export class FormData {
|
||||
append(key: string, value: any, options?: any): FormData;
|
||||
getHeaders(): Object;
|
||||
// TODO expand pipe
|
||||
pipe(to: any): any;
|
||||
submit(params: string|Object, callback: (error: any, response: any) => void): any;
|
||||
}
|
||||
}
|
||||
class FormData {
|
||||
append(key: string, value: any, options?: any): void;
|
||||
getHeaders(): FormData.Dictionary<string>;
|
||||
// TODO expand pipe
|
||||
pipe(to: any): any;
|
||||
submit(params: string | Object, callback: (error: any, response: any) => void): any;
|
||||
getBoundary(): string;
|
||||
}
|
||||
|
||||
namespace FormData {
|
||||
interface Dictionary<T> {
|
||||
[key: string]: T;
|
||||
}
|
||||
}
|
||||
|
||||
export = FormData;
|
||||
}
|
||||
@@ -96,6 +96,7 @@ app.on('ready', () => {
|
||||
mainWindow.webContents.executeJavaScript('return true;', true);
|
||||
mainWindow.webContents.executeJavaScript('return true;', true, (result: boolean) => console.log(result));
|
||||
mainWindow.webContents.insertText('blah, blah, blah');
|
||||
mainWindow.webContents.startDrag({file: '/path/to/img.png', icon: nativeImage.createFromPath('/path/to/icon.png')});
|
||||
mainWindow.webContents.findInPage('blah');
|
||||
mainWindow.webContents.findInPage('blah', {
|
||||
forward: true,
|
||||
@@ -133,6 +134,12 @@ app.on('ready', () => {
|
||||
});
|
||||
|
||||
mainWindow.webContents.debugger.sendCommand("Network.enable");
|
||||
mainWindow.webContents.capturePage(image => {
|
||||
console.log(image.toDataURL());
|
||||
});
|
||||
mainWindow.webContents.capturePage({width: 100, height: 200}, image => {
|
||||
console.log(image.toPNG());
|
||||
});
|
||||
});
|
||||
|
||||
app.commandLine.appendSwitch('enable-web-bluetooth');
|
||||
@@ -220,6 +227,7 @@ app.dock.setBadge('foo');
|
||||
var id = app.dock.bounce('informational');
|
||||
app.dock.cancelBounce(id);
|
||||
app.dock.setIcon('/path/to/icon.png');
|
||||
app.dock.setBadgeCount(app.dock.getBadgeCount() + 1);
|
||||
|
||||
app.setUserTasks([
|
||||
<Electron.Task>{
|
||||
@@ -232,6 +240,12 @@ app.setUserTasks([
|
||||
}
|
||||
]);
|
||||
app.setUserTasks([]);
|
||||
if (app.isUnityRunning()) {
|
||||
}
|
||||
if (app.isAccessibilitySupportEnabled()) {
|
||||
}
|
||||
app.setLoginItemSettings({openAtLogin: true, openAsHidden: false});
|
||||
console.log(app.getLoginItemSettings().wasOpenedAtLogin);
|
||||
|
||||
var window = new BrowserWindow();
|
||||
window.setProgressBar(0.5);
|
||||
@@ -247,6 +261,7 @@ app.on('ready', () => {
|
||||
onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false });
|
||||
onlineStatusWindow.loadURL(`file://${__dirname}/online-status.html`);
|
||||
});
|
||||
app.on('accessibility-support-changed', (_, enabled) => console.log('accessibility: ' + enabled));
|
||||
|
||||
ipcMain.on('online-status-changed', (event: any, status: any) => {
|
||||
console.log(status);
|
||||
@@ -429,6 +444,14 @@ ipcMain.on('synchronous-message', (event: Electron.IpcMainEvent, arg: any) => {
|
||||
event.returnValue = 'pong';
|
||||
});
|
||||
|
||||
var winWindows = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
show: false,
|
||||
thickFrame: false,
|
||||
type: 'toolbar',
|
||||
});
|
||||
|
||||
// menu-item
|
||||
// https://github.com/atom/electron/blob/master/docs/api/menu-item.md
|
||||
|
||||
@@ -700,8 +723,11 @@ app.on('ready', () => {
|
||||
|
||||
clipboard.writeText('Example String');
|
||||
clipboard.writeText('Example String', 'selection');
|
||||
clipboard.writeBookmark('foo', 'http://example.com');
|
||||
clipboard.writeBookmark('foo', 'http://example.com', 'selection');
|
||||
console.log(clipboard.readText('selection'));
|
||||
console.log(clipboard.availableFormats());
|
||||
console.log(clipboard.readBookmark().title);
|
||||
clipboard.clear();
|
||||
|
||||
clipboard.write({
|
||||
|
||||
@@ -250,6 +250,7 @@ webview.addEventListener('ipc-message', function(event) {
|
||||
console.log(event.channel); // Prints "pong"
|
||||
});
|
||||
webview.send('ping');
|
||||
webview.capturePage((image) => { console.log(image); });
|
||||
|
||||
// In guest page.
|
||||
ipcRenderer.on('ping', function() {
|
||||
|
||||
Vendored
+178
-31
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Electron v1.2.5
|
||||
// Type definitions for Electron v1.2.7
|
||||
// Project: http://electron.atom.io/
|
||||
// Definitions by: jedmao <https://github.com/jedmao/>, rhysd <https://rhysd.github.io>, Milan Burda <https://github.com/miniak/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -160,6 +160,12 @@ declare namespace Electron {
|
||||
* Emitted when the gpu process crashes.
|
||||
*/
|
||||
on(event: 'gpu-process-crashed', listener: Function): this;
|
||||
/**
|
||||
* Emitted when Chrome's accessibility support changes.
|
||||
*
|
||||
* Note: This API is only available on macOS and Windows.
|
||||
*/
|
||||
on(event: 'accessibility-support-changed', listener: (event: Event, accessibilitySupportEnabled: boolean) => void): this;
|
||||
on(event: string, listener: Function): this;
|
||||
/**
|
||||
* Try to close all windows. The before-quit event will first be emitted.
|
||||
@@ -341,6 +347,33 @@ declare namespace Electron {
|
||||
* This method can only be called before app is ready.
|
||||
*/
|
||||
disableHardwareAcceleration(): void;
|
||||
/**
|
||||
* @returns whether current desktop environment is Unity launcher. (Linux)
|
||||
*
|
||||
* Note: This API is only available on Linux.
|
||||
*/
|
||||
isUnityRunning(): boolean;
|
||||
/**
|
||||
* Returns a Boolean, true if Chrome's accessibility support is enabled, false otherwise.
|
||||
* This API will return true if the use of assistive technologies, such as screen readers,
|
||||
* has been detected.
|
||||
* See https://www.chromium.org/developers/design-documents/accessibility for more details.
|
||||
*
|
||||
* Note: This API is only available on macOS and Windows.
|
||||
*/
|
||||
isAccessibilitySupportEnabled(): boolean;
|
||||
/**
|
||||
* @returns an Object with the login item settings of the app.
|
||||
*
|
||||
* Note: This API is only available on macOS and Windows.
|
||||
*/
|
||||
getLoginItemSettings(): LoginItemSettings;
|
||||
/**
|
||||
* Set the app's login item settings.
|
||||
*
|
||||
* Note: This API is only available on macOS and Windows.
|
||||
*/
|
||||
setLoginItemSettings(settings: LoginItemSettings): void;
|
||||
commandLine: CommandLine;
|
||||
/**
|
||||
* Note: This API is only available on macOS.
|
||||
@@ -414,6 +447,20 @@ declare namespace Electron {
|
||||
* Note: This API is only available on macOS.
|
||||
*/
|
||||
getBadge(): string;
|
||||
/**
|
||||
* Sets the counter badge for current app. Setting the count to 0 will hide the badge.
|
||||
*
|
||||
* @returns True when the call succeeded, otherwise returns false.
|
||||
*
|
||||
* Note: This API is only available on macOS and Linux.
|
||||
*/
|
||||
setBadgeCount(count: number): boolean;
|
||||
/**
|
||||
* @returns The current value displayed in the counter badge.
|
||||
*
|
||||
* Note: This API is only available on macOS and Linux.
|
||||
*/
|
||||
getBadgeCount(): number;
|
||||
/**
|
||||
* Hides the dock icon.
|
||||
*
|
||||
@@ -472,6 +519,32 @@ declare namespace Electron {
|
||||
iconIndex?: number;
|
||||
}
|
||||
|
||||
interface LoginItemSettings {
|
||||
/**
|
||||
* True if the app is set to open at login.
|
||||
*/
|
||||
openAtLogin: boolean;
|
||||
/**
|
||||
* True if the app is set to open as hidden at login. This setting is only supported on macOS.
|
||||
*/
|
||||
openAsHidden: boolean;
|
||||
/**
|
||||
* True if the app was opened at login automatically. This setting is only supported on macOS.
|
||||
*/
|
||||
wasOpenedAtLogin?: boolean;
|
||||
/**
|
||||
* True if the app was opened as a hidden login item. This indicates that the app should not
|
||||
* open any windows at startup. This setting is only supported on macOS.
|
||||
*/
|
||||
wasOpenedAsHidden?: boolean;
|
||||
/**
|
||||
* True if the app was opened as a login item that should restore the state from the previous session.
|
||||
* This indicates that the app should restore the windows that were open the last time the app was closed.
|
||||
* This setting is only supported on macOS.
|
||||
*/
|
||||
restoreState?: boolean;
|
||||
}
|
||||
|
||||
// https://github.com/electron/electron/blob/master/docs/api/auto-updater.md
|
||||
|
||||
/**
|
||||
@@ -968,6 +1041,13 @@ declare namespace Electron {
|
||||
* @param callback Supplies the image that stores data of the snapshot.
|
||||
*/
|
||||
capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
|
||||
/**
|
||||
* Captures the snapshot of page within rect, upon completion the callback
|
||||
* will be called. Omitting the rect would capture the whole visible page.
|
||||
* Note: Be sure to read documents on remote buffer in remote if you are going
|
||||
* to use this API in renderer process.
|
||||
* @param callback Supplies the image that stores data of the snapshot.
|
||||
*/
|
||||
capturePage(callback: (image: NativeImage) => void): void;
|
||||
/**
|
||||
* Same as webContents.loadURL(url).
|
||||
@@ -1458,15 +1538,20 @@ declare namespace Electron {
|
||||
* The style of window title bar.
|
||||
*/
|
||||
titleBarStyle?: 'default' | 'hidden' | 'hidden-inset';
|
||||
/**
|
||||
* Use WS_THICKFRAME style for frameless windows on Windows
|
||||
*/
|
||||
thickFrame?: boolean;
|
||||
/**
|
||||
* Settings of web page’s features.
|
||||
*/
|
||||
webPreferences?: WebPreferences;
|
||||
}
|
||||
|
||||
type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac;
|
||||
type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac | BrowserWindowTypeWindows;
|
||||
type BrowserWindowTypeLinux = 'desktop' | 'dock' | 'toolbar' | 'splash' | 'notification';
|
||||
type BrowserWindowTypeMac = 'desktop' | 'textured';
|
||||
type BrowserWindowTypeWindows = 'toolbar';
|
||||
|
||||
interface Rectangle {
|
||||
x?: number;
|
||||
@@ -1541,10 +1626,27 @@ declare namespace Electron {
|
||||
html?: string;
|
||||
image?: NativeImage;
|
||||
}, type?: ClipboardType): void;
|
||||
/**
|
||||
* @returns An Object containing title and url keys representing the bookmark in the clipboard.
|
||||
*
|
||||
* Note: This API is available on macOS and Windows.
|
||||
*/
|
||||
readBookmark(): Bookmark;
|
||||
/**
|
||||
* Writes the title and url into the clipboard as a bookmark.
|
||||
*
|
||||
* Note: This API is available on macOS and Windows.
|
||||
*/
|
||||
writeBookmark(title: string, url: string, type?: ClipboardType): void;
|
||||
}
|
||||
|
||||
type ClipboardType = '' | 'selection';
|
||||
|
||||
interface Bookmark {
|
||||
title: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
// https://github.com/electron/electron/blob/master/docs/api/content-tracing.md
|
||||
|
||||
/**
|
||||
@@ -1836,7 +1938,7 @@ declare namespace Electron {
|
||||
/**
|
||||
* Contains which features the dialog should use.
|
||||
*/
|
||||
properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory')[];
|
||||
properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory' | 'showHiddenFiles')[];
|
||||
}
|
||||
|
||||
interface SaveDialogOptions {
|
||||
@@ -3292,6 +3394,17 @@ declare namespace Electron {
|
||||
metaKey: boolean;
|
||||
}
|
||||
|
||||
interface DragItem {
|
||||
/**
|
||||
* The absolute path of the file to be dragged
|
||||
*/
|
||||
file: string;
|
||||
/**
|
||||
* The image showing under the cursor when dragging.
|
||||
*/
|
||||
icon: NativeImage;
|
||||
}
|
||||
|
||||
// https://github.com/electron/electron/blob/master/docs/api/web-contents.md
|
||||
|
||||
/**
|
||||
@@ -3739,16 +3852,12 @@ declare namespace Electron {
|
||||
* Begin subscribing for presentation events and captured frames,
|
||||
* The callback will be called when there is a presentation event.
|
||||
*/
|
||||
beginFrameSubscription(callback: (
|
||||
/**
|
||||
* The frameBuffer is a Buffer that contains raw pixel data.
|
||||
* On most machines, the pixel data is effectively stored in 32bit BGRA format,
|
||||
* but the actual representation depends on the endianness of the processor
|
||||
* (most modern processors are little-endian, on machines with big-endian
|
||||
* processors the data is in 32bit ARGB format).
|
||||
*/
|
||||
frameBuffer: Buffer
|
||||
) => void): void;
|
||||
beginFrameSubscription(onlyDirty: boolean, callback: BeginFrameSubscriptionCallback): void;
|
||||
/**
|
||||
* Begin subscribing for presentation events and captured frames,
|
||||
* The callback will be called when there is a presentation event.
|
||||
*/
|
||||
beginFrameSubscription(callback: BeginFrameSubscriptionCallback): void;
|
||||
/**
|
||||
* End subscribing for frame presentation events.
|
||||
*/
|
||||
@@ -3762,6 +3871,18 @@ declare namespace Electron {
|
||||
* Note: This API is available only on macOS.
|
||||
*/
|
||||
showDefinitionForSelection(): void;
|
||||
/**
|
||||
* Sets the item as dragging item for current drag-drop operation.
|
||||
*/
|
||||
startDrag(item: DragItem): void;
|
||||
/**
|
||||
* Captures a snapshot of the page within rect.
|
||||
*/
|
||||
capturePage(callback: (image: NativeImage) => void): void;
|
||||
/**
|
||||
* Captures a snapshot of the page within rect.
|
||||
*/
|
||||
capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
|
||||
/**
|
||||
* @returns The unique ID of this WebContents.
|
||||
*/
|
||||
@@ -3786,6 +3907,24 @@ declare namespace Electron {
|
||||
debugger: Debugger;
|
||||
}
|
||||
|
||||
interface BeginFrameSubscriptionCallback {
|
||||
(
|
||||
/**
|
||||
* The frameBuffer is a Buffer that contains raw pixel data.
|
||||
* On most machines, the pixel data is effectively stored in 32bit BGRA format,
|
||||
* but the actual representation depends on the endianness of the processor
|
||||
* (most modern processors are little-endian, on machines with big-endian
|
||||
* processors the data is in 32bit ARGB format).
|
||||
*/
|
||||
frameBuffer: Buffer,
|
||||
/**
|
||||
* The dirtyRect is an object with x, y, width, height properties that describes which part of the page was repainted.
|
||||
* If onlyDirty is set to true, frameBuffer will only contain the repainted area. onlyDirty defaults to false.
|
||||
*/
|
||||
dirtyRect?: Bounds
|
||||
): void
|
||||
}
|
||||
|
||||
interface ContextMenuParams {
|
||||
/**
|
||||
* x coordinate
|
||||
@@ -3825,76 +3964,76 @@ declare namespace Electron {
|
||||
*/
|
||||
mediaFlags: {
|
||||
/**
|
||||
* Wether the media element has crashed.
|
||||
* Whether the media element has crashed.
|
||||
*/
|
||||
inError: boolean;
|
||||
/**
|
||||
* Wether the media element is paused.
|
||||
* Whether the media element is paused.
|
||||
*/
|
||||
isPaused: boolean;
|
||||
/**
|
||||
* Wether the media element is muted.
|
||||
* Whether the media element is muted.
|
||||
*/
|
||||
isMuted: boolean;
|
||||
/**
|
||||
* Wether the media element has audio.
|
||||
* Whether the media element has audio.
|
||||
*/
|
||||
hasAudio: boolean;
|
||||
/**
|
||||
* Wether the media element is looping.
|
||||
* Whether the media element is looping.
|
||||
*/
|
||||
isLooping: boolean;
|
||||
/**
|
||||
* Wether the media element's controls are visible.
|
||||
* Whether the media element's controls are visible.
|
||||
*/
|
||||
isControlsVisible: boolean;
|
||||
/**
|
||||
* Wether the media element's controls are toggleable.
|
||||
* Whether the media element's controls are toggleable.
|
||||
*/
|
||||
canToggleControls: boolean;
|
||||
/**
|
||||
* Wether the media element can be rotated.
|
||||
* Whether the media element can be rotated.
|
||||
*/
|
||||
canRotate: boolean;
|
||||
}
|
||||
/**
|
||||
* Wether the context menu was invoked on an image which has non-empty contents.
|
||||
* Whether the context menu was invoked on an image which has non-empty contents.
|
||||
*/
|
||||
hasImageContents: boolean;
|
||||
/**
|
||||
* Wether the context is editable.
|
||||
* Whether the context is editable.
|
||||
*/
|
||||
isEditable: boolean;
|
||||
/**
|
||||
* These flags indicate wether the renderer believes it is able to perform the corresponding action.
|
||||
* These flags indicate whether the renderer believes it is able to perform the corresponding action.
|
||||
*/
|
||||
editFlags: {
|
||||
/**
|
||||
* Wether the renderer believes it can undo.
|
||||
* Whether the renderer believes it can undo.
|
||||
*/
|
||||
canUndo: boolean;
|
||||
/**
|
||||
* Wether the renderer believes it can redo.
|
||||
* Whether the renderer believes it can redo.
|
||||
*/
|
||||
canRedo: boolean;
|
||||
/**
|
||||
* Wether the renderer believes it can cut.
|
||||
* Whether the renderer believes it can cut.
|
||||
*/
|
||||
canCut: boolean;
|
||||
/**
|
||||
* Wether the renderer believes it can copy
|
||||
* Whether the renderer believes it can copy
|
||||
*/
|
||||
canCopy: boolean;
|
||||
/**
|
||||
* Wether the renderer believes it can paste.
|
||||
* Whether the renderer believes it can paste.
|
||||
*/
|
||||
canPaste: boolean;
|
||||
/**
|
||||
* Wether the renderer believes it can delete.
|
||||
* Whether the renderer believes it can delete.
|
||||
*/
|
||||
canDelete: boolean;
|
||||
/**
|
||||
* Wether the renderer believes it can select all.
|
||||
* Whether the renderer believes it can select all.
|
||||
*/
|
||||
canSelectAll: boolean;
|
||||
}
|
||||
@@ -4556,6 +4695,14 @@ declare namespace Electron {
|
||||
* @returns The WebContents associated with this webview.
|
||||
*/
|
||||
getWebContents(): WebContents;
|
||||
/**
|
||||
* Captures a snapshot of the webview's page. Same as webContents.capturePage([rect, ]callback).
|
||||
*/
|
||||
capturePage(callback: (image: NativeImage) => void): void;
|
||||
/**
|
||||
* Captures a snapshot of the webview's page. Same as webContents.capturePage([rect, ]callback).
|
||||
*/
|
||||
capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
|
||||
/**
|
||||
* Fired when a load has committed. This includes navigation within the current document
|
||||
* as well as subframe document-level loads, but does not include asynchronous resource loads.
|
||||
|
||||
Vendored
+5
@@ -149,6 +149,11 @@ declare module "gulp" {
|
||||
* Note that an explicit dot in a portion of the pattern will always match dot files.
|
||||
*/
|
||||
dot?: boolean;
|
||||
|
||||
/**
|
||||
* Set to match only fles, not directories. Set this flag to prevent copying empty directories
|
||||
*/
|
||||
nodir?: boolean;
|
||||
|
||||
/**
|
||||
* By default, a pattern starting with a forward-slash will be "mounted" onto the root setting, so that a valid
|
||||
|
||||
Vendored
+52
-21
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Hammer.js 2.0.4
|
||||
// Type definitions for Hammer.js 2.0.8
|
||||
// Project: http://hammerjs.github.io/
|
||||
// Definitions by: Philip Bulley <https://github.com/milkisevil/>, Han Lin Yap <https://github.com/codler>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -11,7 +11,7 @@ declare module "hammerjs" {
|
||||
|
||||
interface HammerStatic
|
||||
{
|
||||
new( element:HTMLElement | SVGElement, options?:any ): HammerManager;
|
||||
new( element:HTMLElement | SVGElement, options?:HammerOptions ): HammerManager;
|
||||
|
||||
defaults:HammerDefaults;
|
||||
|
||||
@@ -68,16 +68,22 @@ interface HammerStatic
|
||||
prefixed( obj:any, property:string ):string;
|
||||
}
|
||||
|
||||
interface HammerDefaults
|
||||
type RecognizerTuple =
|
||||
[RecognizerStatic]
|
||||
| [RecognizerStatic, RecognizerOptions]
|
||||
| [RecognizerStatic, RecognizerOptions, string | string[]]
|
||||
| [RecognizerStatic, RecognizerOptions, string | string[], (string | Recognizer) | (string | Recognizer)[]];
|
||||
|
||||
interface HammerDefaults extends HammerOptions
|
||||
{
|
||||
domEvents:boolean;
|
||||
enable:boolean;
|
||||
preset:any[];
|
||||
preset:RecognizerTuple[];
|
||||
touchAction:string;
|
||||
cssProps:CssProps;
|
||||
|
||||
inputClass():void;
|
||||
inputTarget():void;
|
||||
inputClass:() => void;
|
||||
inputTarget:EventTarget;
|
||||
}
|
||||
|
||||
interface CssProps
|
||||
@@ -90,13 +96,25 @@ interface CssProps
|
||||
userSelect:string;
|
||||
}
|
||||
|
||||
interface HammerOptions extends HammerDefaults
|
||||
interface HammerOptions
|
||||
{
|
||||
cssProps?:CssProps;
|
||||
domEvents?:boolean;
|
||||
enable?:boolean | ((manager: HammerManager) => boolean);
|
||||
preset?:RecognizerTuple[];
|
||||
touchAction?:string;
|
||||
recognizers?:RecognizerTuple[];
|
||||
|
||||
inputClass?:() => void;
|
||||
inputTarget?:EventTarget;
|
||||
}
|
||||
|
||||
interface HammerManagerConstructor {
|
||||
new( element:HTMLElement, options?:any ):HammerManager;
|
||||
new( element:EventTarget, options?:HammerOptions ):HammerManager;
|
||||
}
|
||||
|
||||
interface HammerListener {
|
||||
(event:HammerInput): void
|
||||
}
|
||||
|
||||
interface HammerManager
|
||||
@@ -109,8 +127,8 @@ interface HammerManager
|
||||
emit( event:string, data:any ):void;
|
||||
get( recogniser:Recognizer ):Recognizer;
|
||||
get( recogniser:string ):Recognizer;
|
||||
off( events:string, handler?:( event:HammerInput ) => void ):void;
|
||||
on( events:string, handler:( event:HammerInput ) => void ):void;
|
||||
off( events:string, handler?:HammerListener ):void;
|
||||
on( events:string, handler:HammerListener ):void;
|
||||
recognize( inputData:any ):void;
|
||||
remove( recogniser:Recognizer ):HammerManager;
|
||||
remove( recogniser:string ):HammerManager;
|
||||
@@ -157,7 +175,7 @@ declare class HammerInput
|
||||
direction:number;
|
||||
|
||||
/** Direction moved from it's starting point. Matches the DIRECTION constants. */
|
||||
offsetDirection:string;
|
||||
offsetDirection:number;
|
||||
|
||||
/** Scaling that has been done when multi-touch. 1 on a single touch. */
|
||||
scale:number;
|
||||
@@ -178,7 +196,7 @@ declare class HammerInput
|
||||
pointerType:string;
|
||||
|
||||
/** Event type, matches the INPUT constants. */
|
||||
eventType:string;
|
||||
eventType:number;
|
||||
|
||||
/** true when the first input. */
|
||||
isFirst:boolean;
|
||||
@@ -221,9 +239,22 @@ declare class TouchMouseInput extends HammerInput
|
||||
constructor( manager:HammerManager, callback:Function );
|
||||
}
|
||||
|
||||
interface RecognizerOptions {
|
||||
direction?: number;
|
||||
enable?: boolean | ((recognizer: Recognizer, inputData: HammerInput) => boolean);
|
||||
event?: string;
|
||||
interval?: number;
|
||||
pointers?: number;
|
||||
posThreshold?: number;
|
||||
taps?: number
|
||||
threshold?: number;
|
||||
time?: number;
|
||||
velocity?: number;
|
||||
}
|
||||
|
||||
interface RecognizerStatic
|
||||
{
|
||||
new( options?:any ):Recognizer;
|
||||
new( options?:RecognizerOptions ):Recognizer;
|
||||
}
|
||||
|
||||
interface Recognizer
|
||||
@@ -246,7 +277,7 @@ interface Recognizer
|
||||
requireFailure( otherRecognizer:Recognizer ):Recognizer;
|
||||
requireFailure( otherRecognizer:string ):Recognizer;
|
||||
reset():void;
|
||||
set( options?:any ):Recognizer;
|
||||
set( options?:RecognizerOptions ):Recognizer;
|
||||
tryEmit( input:HammerInput ):void;
|
||||
}
|
||||
|
||||
@@ -258,12 +289,12 @@ interface AttrRecognizerStatic
|
||||
|
||||
interface AttrRecognizer extends Recognizer
|
||||
{
|
||||
new( options?:any ):AttrRecognizer;
|
||||
new( options?:RecognizerOptions ):AttrRecognizer;
|
||||
}
|
||||
|
||||
interface PanRecognizerStatic
|
||||
{
|
||||
new( options?:any ):PanRecognizer;
|
||||
new( options?:RecognizerOptions ):PanRecognizer;
|
||||
}
|
||||
|
||||
interface PanRecognizer extends AttrRecognizer
|
||||
@@ -272,7 +303,7 @@ interface PanRecognizer extends AttrRecognizer
|
||||
|
||||
interface PinchRecognizerStatic
|
||||
{
|
||||
new( options?:any ):PinchRecognizer;
|
||||
new( options?:RecognizerOptions ):PinchRecognizer;
|
||||
}
|
||||
|
||||
interface PinchRecognizer extends AttrRecognizer
|
||||
@@ -281,7 +312,7 @@ interface PinchRecognizer extends AttrRecognizer
|
||||
|
||||
interface PressRecognizerStatic
|
||||
{
|
||||
new( options?:any ):PressRecognizer;
|
||||
new( options?:RecognizerOptions ):PressRecognizer;
|
||||
}
|
||||
|
||||
interface PressRecognizer extends AttrRecognizer
|
||||
@@ -290,7 +321,7 @@ interface PressRecognizer extends AttrRecognizer
|
||||
|
||||
interface RotateRecognizerStatic
|
||||
{
|
||||
new( options?:any ):RotateRecognizer;
|
||||
new( options?:RecognizerOptions ):RotateRecognizer;
|
||||
}
|
||||
|
||||
interface RotateRecognizer extends AttrRecognizer
|
||||
@@ -299,7 +330,7 @@ interface RotateRecognizer extends AttrRecognizer
|
||||
|
||||
interface SwipeRecognizerStatic
|
||||
{
|
||||
new( options?:any ):SwipeRecognizer;
|
||||
new( options?:RecognizerOptions ):SwipeRecognizer;
|
||||
}
|
||||
|
||||
interface SwipeRecognizer extends AttrRecognizer
|
||||
@@ -308,7 +339,7 @@ interface SwipeRecognizer extends AttrRecognizer
|
||||
|
||||
interface TapRecognizerStatic
|
||||
{
|
||||
new( options?:any ):TapRecognizer;
|
||||
new( options?:RecognizerOptions ):TapRecognizer;
|
||||
}
|
||||
|
||||
interface TapRecognizer extends AttrRecognizer
|
||||
|
||||
Vendored
+10
-10
@@ -52,20 +52,20 @@ interface Howl {
|
||||
onpause: Function;
|
||||
onplay: Function;
|
||||
load(): Howl;
|
||||
play(sprite?: string, callback?: (soundId: number) => void): Howl;
|
||||
play(callback?: (soundId: number) => void): Howl;
|
||||
pause(soundId?: number): Howl;
|
||||
stop(soundId?: number): Howl;
|
||||
mute(soundId?: number): Howl;
|
||||
unmute(soundId?: number): Howl;
|
||||
fade(from: number, to: number, duration: number, callback?: Function, soundId?: number): Howl;
|
||||
play(sprite?: string, callback?: (soundId: string) => void): Howl;
|
||||
play(callback?: (soundId: string) => void): Howl;
|
||||
pause(soundId?: string): Howl;
|
||||
stop(soundId?: string): Howl;
|
||||
mute(soundId?: string): Howl;
|
||||
unmute(soundId?: string): Howl;
|
||||
fade(from: number, to: number, duration: number, callback?: Function, soundId?: string): Howl;
|
||||
loop(): boolean;
|
||||
loop(loop: boolean): Howl;
|
||||
pos(position?: number, soundId?: number): number;
|
||||
pos3d(x: number, y: number, z: number, soundId?: number): any;
|
||||
pos(position?: number, soundId?: string): number;
|
||||
pos3d(x: number, y: number, z: number, soundId?: string): any;
|
||||
sprite(definition?: IHowlSoundSpriteDefinition): IHowlSoundSpriteDefinition;
|
||||
volume(): number;
|
||||
volume(volume?: number, soundId?: number): Howl;
|
||||
volume(volume?: number, soundId?: string): Howl;
|
||||
urls(): string[];
|
||||
urls(urls: string[]): Howl;
|
||||
on(event: string, listener?: Function): Howl;
|
||||
|
||||
Vendored
+3
-1
@@ -41,7 +41,8 @@ declare module IORedis {
|
||||
}
|
||||
|
||||
interface Redis extends NodeJS.EventEmitter, Commander {
|
||||
connect(callback: Function): Promise<any>;
|
||||
status: string;
|
||||
connect(callback?: Function): Promise<any>;
|
||||
disconnect(): void;
|
||||
duplicate(): Redis;
|
||||
monitor(calback: (error: Error, monitor: NodeJS.EventEmitter) => void): Promise<NodeJS.EventEmitter>;
|
||||
@@ -59,6 +60,7 @@ declare module IORedis {
|
||||
subscribe(channel: string): any;
|
||||
get(args: any[], callback?: ResCallbackT<string>): any;
|
||||
get(...args: any[]): any;
|
||||
getBuffer(key: string, callback?: ResCallbackT<Buffer>): any;
|
||||
set(args: any[], callback?: ResCallbackT<string>): any;
|
||||
set(...args: any[]): any;
|
||||
setnx(args: any[], callback?: ResCallbackT<any>): any;
|
||||
|
||||
+4
-4
@@ -17,13 +17,13 @@ interface JQueryFileInputOptions {
|
||||
* The drop target element(s), by the default the complete document.
|
||||
* Set to null to disable drag & drop support:
|
||||
*/
|
||||
dropZone?: HTMLElement;
|
||||
dropZone?: Element | Element[] | JQuery | string;
|
||||
|
||||
/**
|
||||
* The paste target element(s), by the default the complete document.
|
||||
* Set to null to disable paste support:
|
||||
*/
|
||||
pasteZone?: HTMLElement;
|
||||
pasteZone?: Element | Element[] | JQuery | string;
|
||||
|
||||
/**
|
||||
* The file input field(s), that are listened to for change events.
|
||||
@@ -31,7 +31,7 @@ interface JQueryFileInputOptions {
|
||||
* of the widget element on plugin initialization.
|
||||
* Set to null to disable the change listener.
|
||||
*/
|
||||
fileInput?: HTMLElement;
|
||||
fileInput?: Element | Element[] | JQuery | string;
|
||||
|
||||
/**
|
||||
* By default, the file input field is replaced with a clone after
|
||||
@@ -286,4 +286,4 @@ interface JQueryFileUploadProgressObject extends JQueryFileInputOptions, JQueryF
|
||||
}
|
||||
|
||||
interface JQueryFileUploadDone extends JQueryFileInputOptions, JQueryFileUploadXhr {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/// <reference path="jquery.payment.d.ts" />
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
$.payment.cards.push({
|
||||
// Card type, as returned by $.payment.cardType.
|
||||
type: 'mastercard',
|
||||
// Array of prefixes used to identify the card type.
|
||||
patterns: [
|
||||
51, 52, 53, 54, 55,
|
||||
22, 23, 24, 25, 26, 27
|
||||
],
|
||||
// Array of valid card number lengths.
|
||||
length: [16],
|
||||
// Array of valid card CVC lengths.
|
||||
cvcLength: [3],
|
||||
// Boolean indicating whether a valid card number should satisfy the Luhn check.
|
||||
luhn: true,
|
||||
// Regex used to format the card number. Each match is joined with a space.
|
||||
format: /(\d{1,4})/g
|
||||
})
|
||||
|
||||
$('[data-numeric]').payment('restrictNumeric');
|
||||
|
||||
$.payment.validateCardNumber('4242 4242 4242 4242') === true; //=> true
|
||||
|
||||
$.payment.validateCardExpiry('05', '20') === true; //=> true
|
||||
$.payment.validateCardExpiry('05', '2015') === true; //=> true
|
||||
$.payment.validateCardExpiry('05', '05') === true; //=> false
|
||||
|
||||
$.payment.validateCardCVC('123') === true; //=> true
|
||||
$.payment.validateCardCVC('123', 'amex') === true; //=> true
|
||||
$.payment.validateCardCVC('1234', 'amex') === true; //=> true
|
||||
$.payment.validateCardCVC('12344') === false; //=> false
|
||||
|
||||
$.payment.cardType('4242 4242 4242 4242') === 'visa'; //=> 'visa'
|
||||
|
||||
$.payment.cardExpiryVal('03 / 2025') === {month: 3, year: 2025}; //=> {month: 3, year: 2025}
|
||||
$.payment.cardExpiryVal('05 / 04') === {month: 3, year: 2025}; //=> {month: 5, year: 2004}
|
||||
$('input.cc-exp').payment('cardExpiryVal') //=> {month: 4, year: 2020}
|
||||
|
||||
var valid = $.payment.validateCardNumber($('input.cc-num').val());
|
||||
|
||||
if (!valid) {
|
||||
alert('Your card is not valid!');
|
||||
}
|
||||
Vendored
+12
-7
@@ -77,33 +77,38 @@ declare namespace JQueryPayment {
|
||||
/**
|
||||
* Card type
|
||||
*/
|
||||
type: string;
|
||||
type?: string;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Regex used to identify the card type. For the best experience, this should be
|
||||
* the shortest pattern that can guarantee the card is of a particular type.
|
||||
*/
|
||||
pattern: RegExp;
|
||||
pattern?: RegExp;
|
||||
|
||||
/**
|
||||
* Array of prefixes used to identify the card type.
|
||||
*/
|
||||
patterns?: number[];
|
||||
|
||||
/**
|
||||
* Array of valid card number lengths.
|
||||
*/
|
||||
length: number[];
|
||||
length?: number[];
|
||||
|
||||
/**
|
||||
* Array of valid card CVC lengths.
|
||||
*/
|
||||
cvcLength: number[];
|
||||
cvcLength?: number[];
|
||||
|
||||
/**
|
||||
* Boolean indicating whether a valid card number should satisfy the Luhn check.
|
||||
*/
|
||||
luhn: boolean;
|
||||
luhn?: boolean;
|
||||
|
||||
/**
|
||||
* Regex used to format the card number. Each match is joined with a space.
|
||||
*/
|
||||
format: RegExp;
|
||||
format?: RegExp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+6
-1
@@ -28,4 +28,9 @@ interface JQueryTimer {
|
||||
|
||||
interface JQuery {
|
||||
timer: JQueryTimer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface JQueryStatic {
|
||||
timer: JQueryTimer;
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -1,4 +1,4 @@
|
||||
// Type definitions for jQueryUI 1.9
|
||||
// Type definitions for jQueryUI 1.11
|
||||
// Project: http://jqueryui.com/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, John Reilly <https://github.com/johnnyreilly>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -625,9 +625,9 @@ declare namespace JQueryUI {
|
||||
|
||||
interface Selectable extends Widget, SelectableOptions {
|
||||
}
|
||||
|
||||
|
||||
// SelectMenu //////////////////////////////////////////////////
|
||||
|
||||
|
||||
interface SelectMenuOptions extends SelectMenuEvents {
|
||||
appendTo?: string;
|
||||
disabled?: boolean;
|
||||
@@ -1705,7 +1705,7 @@ interface JQuery {
|
||||
selectable(optionLiteral: string, optionName: string): any;
|
||||
selectable(optionLiteral: string, options: JQueryUI.SelectableOptions): any;
|
||||
selectable(optionLiteral: string, optionName: string, optionValue: any): JQuery;
|
||||
|
||||
|
||||
selectmenu(): JQuery;
|
||||
selectmenu(methodName: 'close'): JQuery;
|
||||
selectmenu(methodName: 'destroy'): JQuery;
|
||||
|
||||
@@ -109,3 +109,8 @@ var tree = $('a').jstree();
|
||||
tree.move_node('a', 'b', 0, (node: any, new_par: any, pos: any) => { }, true, true);
|
||||
tree.copy_node('a', 'b', 0, (node: any, new_par: any, pos: any) => { }, true, true);
|
||||
|
||||
// #10271 jstree - get_path params not marked to be optional
|
||||
tree.get_path('nodeId');
|
||||
tree.get_path('nodeId', '/');
|
||||
tree.get_path('nodeId', '/', true);
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -830,7 +830,7 @@ interface JSTree extends JQuery {
|
||||
* @param {Boolean} ids if set to true build the path using ID, otherwise node text is used
|
||||
* @return {mixed}
|
||||
*/
|
||||
get_path: (obj: any, glue: string, ids: boolean) => any;
|
||||
get_path: (obj: any, glue?: string, ids?: boolean) => any;
|
||||
|
||||
/**
|
||||
* get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
|
||||
|
||||
Vendored
+1
-1
@@ -28,7 +28,7 @@ declare module 'kafka-node' {
|
||||
}
|
||||
|
||||
export class Consumer {
|
||||
constructor(client: Client, fetchRequests: Array<Topic>, options: ConsumerOptions);
|
||||
constructor(client: Client, fetchRequests: Array<OffsetFetchRequest>, options: ConsumerOptions);
|
||||
on(eventName: string, cb: (message: string) => any): void;
|
||||
on(eventName: string, cb: (error: any) => any): void;
|
||||
addTopics(topics: Array<string>, cb: (error: any, added: boolean) => any): void;
|
||||
|
||||
Vendored
+1
@@ -4411,6 +4411,7 @@ declare namespace kendo.ui {
|
||||
name?: string;
|
||||
text?: GridColumnCommandItemText;
|
||||
className?: string;
|
||||
template?: string;
|
||||
imageClass?: string;
|
||||
click?: Function;
|
||||
}
|
||||
|
||||
@@ -156,6 +156,10 @@ knex('users')
|
||||
.join('contacts', 'users.id', 'contacts.user_id')
|
||||
.select('users.id', 'contacts.phone');
|
||||
|
||||
knex('users')
|
||||
.join(knex('contacts').select('user_id', 'phone').as('contacts'), 'users.id', 'contacts.user_id')
|
||||
.select('users.id', 'contacts.phone');
|
||||
|
||||
knex.select('*').from('users').join('accounts', function() {
|
||||
this.on('accounts.id', '=', 'users.account_id').orOn('accounts.owner_id', '=', 'users.id')
|
||||
});
|
||||
|
||||
Vendored
+7
-6
@@ -14,6 +14,7 @@ declare module "knex" {
|
||||
type Client = Function;
|
||||
type Value = string|number|boolean|Date|Array<string>|Array<number>|Array<Date>|Array<boolean>;
|
||||
type ColumnName = string|Knex.Raw|Knex.QueryBuilder;
|
||||
type TableName = string|Knex.Raw|Knex.QueryBuilder;
|
||||
|
||||
interface Knex extends Knex.QueryInterface {
|
||||
(tableName?: string): Knex.QueryBuilder;
|
||||
@@ -164,12 +165,12 @@ declare module "knex" {
|
||||
|
||||
interface Join {
|
||||
(raw: Raw): QueryBuilder;
|
||||
(tableName: string, callback: (joinClause: JoinClause) => any): QueryBuilder;
|
||||
(tableName: string, columns: {[key: string]: string|Raw}): QueryBuilder;
|
||||
(tableName: string, raw: Raw): QueryBuilder;
|
||||
(tableName: string, column1: string, column2: string): QueryBuilder;
|
||||
(tableName: string, column1: string, raw: Raw): QueryBuilder;
|
||||
(tableName: string, column1: string, operator: string, column2: string): QueryBuilder;
|
||||
(tableName: TableName, callback: (joinClause: JoinClause) => any): QueryBuilder;
|
||||
(tableName: TableName, columns: {[key: string]: string|Raw}): QueryBuilder;
|
||||
(tableName: TableName, raw: Raw): QueryBuilder;
|
||||
(tableName: TableName, column1: string, column2: string): QueryBuilder;
|
||||
(tableName: TableName, column1: string, raw: Raw): QueryBuilder;
|
||||
(tableName: TableName, column1: string, operator: string, column2: string): QueryBuilder;
|
||||
}
|
||||
|
||||
interface JoinClause {
|
||||
|
||||
Vendored
+158
-117
@@ -13,129 +13,170 @@
|
||||
}
|
||||
|
||||
=============================================== */
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../cookies/cookies.d.ts"/>
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
|
||||
declare module "koa" {
|
||||
import { EventEmitter } from "events";
|
||||
import * as http from "http";
|
||||
import * as net from "net";
|
||||
import { EventEmitter } from "events";
|
||||
import * as cookies from "cookies";
|
||||
import * as http from "http";
|
||||
import * as net from "net";
|
||||
|
||||
namespace Koa {
|
||||
export interface Context extends Request, Response {
|
||||
body?: any;
|
||||
request?: Request;
|
||||
response?: Response;
|
||||
originalUrl?: string;
|
||||
state?: any;
|
||||
name?: string;
|
||||
cookies?: any;
|
||||
writable?: Boolean;
|
||||
respond?: Boolean;
|
||||
app?: Koa;
|
||||
req?: http.IncomingMessage;
|
||||
res?: http.ServerResponse;
|
||||
namespace Koa {
|
||||
export interface Context extends Request, Response {
|
||||
app: Koa;
|
||||
req: http.IncomingMessage;
|
||||
res: http.ServerResponse;
|
||||
request: Request;
|
||||
response: Response;
|
||||
|
||||
cookies: cookies.ICookies;
|
||||
originalUrl: string;
|
||||
state: any;
|
||||
|
||||
name?: string;
|
||||
respond?: boolean;
|
||||
|
||||
assert(test: any, ...args: any[]): void;
|
||||
onerror(err?: any): void;
|
||||
throw(...args: any[]): void;
|
||||
|
||||
toJSON(): any;
|
||||
inspect(): any;
|
||||
}
|
||||
|
||||
export interface Request {
|
||||
app: Koa;
|
||||
req: http.IncomingMessage;
|
||||
res: http.ServerResponse;
|
||||
ctx: Context;
|
||||
response: Response;
|
||||
|
||||
fresh: boolean;
|
||||
header: any;
|
||||
headers: any;
|
||||
host: string;
|
||||
hostname: string;
|
||||
href: string;
|
||||
idempotent: boolean;
|
||||
ip: string;
|
||||
ips: string[];
|
||||
method: string;
|
||||
origin: string;
|
||||
originalUrl: string;
|
||||
path: string;
|
||||
protocol: string;
|
||||
query: any;
|
||||
querystring: string;
|
||||
search: string;
|
||||
secure: boolean;
|
||||
socket: net.Socket;
|
||||
stale: boolean;
|
||||
subdomains: string[];
|
||||
type: string;
|
||||
url: string;
|
||||
|
||||
charset?: string;
|
||||
length?: number;
|
||||
|
||||
accepts(): string[];
|
||||
accepts(arg: string): void | string;
|
||||
accepts(arg: string[]): void | string;
|
||||
accepts(...args: string[]): void | string;
|
||||
acceptsCharsets(): string[];
|
||||
acceptsCharsets(arg: string): void | string;
|
||||
acceptsCharsets(arg: string[]): void | string;
|
||||
acceptsCharsets(...args: string[]): void | string;
|
||||
acceptsEncodings(): string[];
|
||||
acceptsEncodings(arg: string): void | string;
|
||||
acceptsEncodings(arg: string[]): void | string;
|
||||
acceptsEncodings(...args: string[]): void | string;
|
||||
acceptsLanguages(): string[];
|
||||
acceptsLanguages(arg: string): void | string;
|
||||
acceptsLanguages(arg: string[]): void | string;
|
||||
acceptsLanguages(...args: string[]): void | string;
|
||||
get(field: string): string;
|
||||
is(): string[];
|
||||
is(arg: string): void | string;
|
||||
is(arg: string[]): void | string;
|
||||
is(...args: string[]): void | string;
|
||||
|
||||
toJSON(): any;
|
||||
inspect(): any;
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
app: Koa;
|
||||
req: http.IncomingMessage;
|
||||
res: http.ServerResponse;
|
||||
ctx: Context;
|
||||
request: Request;
|
||||
|
||||
body: any;
|
||||
etag: string;
|
||||
header: any;
|
||||
headers: any;
|
||||
headerSent: boolean;
|
||||
lastModified: Date;
|
||||
message: string;
|
||||
socket: net.Socket;
|
||||
status: number;
|
||||
type: string;
|
||||
writable: boolean;
|
||||
|
||||
charset?: string;
|
||||
length?: number;
|
||||
|
||||
append(field: string, val: string | string[]): void;
|
||||
attachment(filename?: string): void;
|
||||
get(field: string): string;
|
||||
is(): string[];
|
||||
is(arg: string): void | string;
|
||||
is(arg: string[]): void | string;
|
||||
is(...args: string[]): void | string;
|
||||
redirect(url: string, alt?: string): void;
|
||||
remove(field: string): void;
|
||||
set(field: string, val: string | string[]): void;
|
||||
set(field: any): void;
|
||||
vary(field: string): void;
|
||||
|
||||
toJSON(): any;
|
||||
inspect(): any;
|
||||
}
|
||||
}
|
||||
|
||||
class Koa extends EventEmitter {
|
||||
context: Koa.Context;
|
||||
env: string;
|
||||
keys: string[];
|
||||
proxy: boolean;
|
||||
request: Koa.Request;
|
||||
response: Koa.Response;
|
||||
server: http.Server;
|
||||
silent: boolean;
|
||||
subdomainOffset: number;
|
||||
|
||||
constructor();
|
||||
|
||||
// From node.d.ts
|
||||
listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): http.Server;
|
||||
listen(port: number, hostname?: string, listeningListener?: Function): http.Server;
|
||||
listen(port: number, backlog?: number, listeningListener?: Function): http.Server;
|
||||
listen(port: number, listeningListener?: Function): http.Server;
|
||||
listen(path: string, backlog?: number, listeningListener?: Function): http.Server;
|
||||
listen(path: string, listeningListener?: Function): http.Server;
|
||||
listen(handle: any, backlog?: number, listeningListener?: Function): http.Server;
|
||||
listen(handle: any, listeningListener?: Function): http.Server;
|
||||
listen(options: net.ListenOptions, listeningListener?: Function): http.Server;
|
||||
|
||||
callback(): (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
||||
onerror(err: any): void;
|
||||
use(middleware: (ctx: Koa.Context, next: () => Promise<any>) => any): Koa;
|
||||
|
||||
toJSON(): any;
|
||||
inspect(): any;
|
||||
throw(code?: any, message?: any): void;
|
||||
assert(test: any, status: number, message: string): void;
|
||||
}
|
||||
|
||||
export interface Request {
|
||||
_querycache?: string;
|
||||
app?: Koa;
|
||||
req?: http.IncomingMessage;
|
||||
res?: http.ServerResponse;
|
||||
response?: Response;
|
||||
ctx?: Context;
|
||||
headers?: any;
|
||||
header?: any;
|
||||
method?: string;
|
||||
length?: any;
|
||||
url?: string;
|
||||
origin?: string;
|
||||
originalUrl?: string;
|
||||
href?: string;
|
||||
path?: string;
|
||||
querystring?: string;
|
||||
query?: any;
|
||||
search?: string;
|
||||
idempotent?: Boolean;
|
||||
socket?: net.Socket;
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
fresh?: Boolean;
|
||||
stale?: Boolean;
|
||||
charset?: string;
|
||||
secure?: Boolean;
|
||||
ips?: Array<string>;
|
||||
ip?: string;
|
||||
subdomains?: Array<string>;
|
||||
accept?: any;
|
||||
type?: string;
|
||||
accepts?: () => any;
|
||||
acceptsEncodings?: () => any;
|
||||
acceptsCharsets?: () => any;
|
||||
acceptsLanguages?: () => any;
|
||||
is?: (types: any) => any;
|
||||
toJSON?: () => any;
|
||||
inspect?: () => any;
|
||||
get?: (field: string) => string;
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
_body?: any;
|
||||
_explicitStatus?: Boolean;
|
||||
app?: Koa;
|
||||
res?: http.ServerResponse;
|
||||
req?: http.IncomingMessage;
|
||||
ctx?: Context;
|
||||
request?: Request;
|
||||
socket?: net.Socket;
|
||||
header?: any;
|
||||
headers?: any;
|
||||
status?: number;
|
||||
message?: string;
|
||||
type?: string;
|
||||
body?: any;
|
||||
length?: any;
|
||||
headerSent?: Boolean;
|
||||
lastModified?: Date;
|
||||
etag?: string;
|
||||
writable?: Boolean;
|
||||
is?: (types: any) => any;
|
||||
redirect?: (url: string, alt: string) => void;
|
||||
attachment?: (filename?: string) => void;
|
||||
vary?: (field: string) => void;
|
||||
get?: (field: string) => string;
|
||||
set?: (field: any, val: any) => void;
|
||||
remove?: (field: string) => void;
|
||||
append?: (field: string, val: any) => void;
|
||||
toJSON?: () => any;
|
||||
inspect?: () => any;
|
||||
}
|
||||
}
|
||||
|
||||
class Koa extends EventEmitter {
|
||||
keys: Array<string>;
|
||||
subdomainOffset: number;
|
||||
proxy: Boolean;
|
||||
server: http.Server;
|
||||
env: string;
|
||||
context: Koa.Context;
|
||||
request: Koa.Request;
|
||||
response: Koa.Response;
|
||||
silent: Boolean;
|
||||
constructor();
|
||||
use(middleware: (ctx: Koa.Context, next: Function) => any): Koa;
|
||||
callback(): (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
||||
listen(port: number, callback?: Function): http.Server;
|
||||
toJSON(): any;
|
||||
inspect(): any;
|
||||
onerror(err: any): void;
|
||||
}
|
||||
|
||||
namespace Koa {}
|
||||
export = Koa;
|
||||
namespace Koa {}
|
||||
export = Koa;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -157,7 +157,7 @@ declare module linqjs {
|
||||
groupBy<TKey>(keySelector: (element: T) => TKey): IEnumerable<IGrouping<TKey, any>>;
|
||||
groupBy<TKey, TElement>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement): IEnumerable<IGrouping<TKey, TElement>>;
|
||||
groupBy<TKey, TElement, TResult>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, element: IEnumerable<TElement>) => TResult): IEnumerable<TResult>;
|
||||
groupBy<TKey, TElement, TResult, TCompare>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, element: IEnumerable<TElement>) => TResult, compareSelector: (element: T) => TCompare): IEnumerable<TResult>;
|
||||
groupBy<TKey, TElement, TResult, TCompare>(keySelector: (element: T) => TKey, elementSelector: (element: T) => TElement, resultSelector: (key: TKey, element: IEnumerable<TElement>) => TResult, compareSelector: (element: TKey) => TCompare): IEnumerable<TResult>;
|
||||
// :IEnumerable<IGrouping<TKey, T>>
|
||||
partitionBy<TKey>(keySelector: (element: T) => TKey): IEnumerable<IGrouping<TKey, any>>;
|
||||
// :IEnumerable<IGrouping<TKey, TElement>>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="load-json-file.d.ts" />
|
||||
import * as loadJsonFile from 'load-json-file';
|
||||
|
||||
function assert(actual: string, expected: string): void {
|
||||
if (actual !== expected) {
|
||||
throw new Error(`${JSON.stringify(actual)} !== ${JSON.stringify(expected)}`);
|
||||
}
|
||||
}
|
||||
|
||||
loadJsonFile('../package.json').then(pkg => {
|
||||
assert(pkg.name, 'definitely-typed');
|
||||
});
|
||||
|
||||
const pkg = loadJsonFile.sync('../package.json');
|
||||
assert(pkg.name, 'definitely-typed');
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for load-json-file v2.0.0
|
||||
// Project: https://github.com/sindresorhus/load-json-file
|
||||
// Definitions by: Sam Verschueren <https://github.com/SamVerschueren>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "load-json-file" {
|
||||
|
||||
interface LoadJsonFile {
|
||||
/**
|
||||
* Returns a promise for the parsed JSON.
|
||||
*
|
||||
* @param filepath
|
||||
*/
|
||||
(filepath: string): Promise<any>;
|
||||
/**
|
||||
* Returns the parsed JSON.
|
||||
*
|
||||
* @param filepath
|
||||
*/
|
||||
sync(filepath: string): any;
|
||||
}
|
||||
|
||||
const loadJsonFile: LoadJsonFile;
|
||||
|
||||
export = loadJsonFile;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/// <reference path="./meteor-accounts-phone.d.ts" />
|
||||
|
||||
let booleanResult: boolean;
|
||||
const options = {};
|
||||
function noop() {}
|
||||
|
||||
SMS.twilio = {
|
||||
FROM: 'me',
|
||||
ACCOUNT_SID: 'my-account-sid',
|
||||
AUTH_TOKEN: 'my-auth-token'
|
||||
};
|
||||
|
||||
SMS.phoneTemplate = {
|
||||
from: 'me',
|
||||
text: noop
|
||||
};
|
||||
|
||||
SMS.send(options);
|
||||
SMS.send(options, noop);
|
||||
|
||||
Meteor.loginWithPhoneAndPassword(options, 'password');
|
||||
Meteor.loginWithPhoneAndPassword('options', 'password');
|
||||
Meteor.loginWithPhoneAndPassword(options, 'password', noop);
|
||||
Meteor.loginWithPhoneAndPassword('options', 'password', noop);
|
||||
|
||||
Accounts._options = {
|
||||
verificationCodeLength: 4,
|
||||
verificationMaxRetries: 10,
|
||||
verificationRetriesWaitTime: 60 * 1000,
|
||||
verificationWaitTime: 10 * 1000,
|
||||
sendPhoneVerificationCodeOnCreation: true,
|
||||
forbidClientAccountCreation: true,
|
||||
phoneVerificationMasterCode: ['1234'],
|
||||
adminPhoneNumbers: ['+972546999999']
|
||||
};
|
||||
|
||||
Accounts.createUserWithPhone(options);
|
||||
Accounts.createUserWithPhone(options, noop);
|
||||
|
||||
Accounts.requestPhoneVerification('+972546999999');
|
||||
Accounts.requestPhoneVerification('+972546999999', noop);
|
||||
|
||||
Accounts.verifyPhone('+972546999999', '1234');
|
||||
Accounts.verifyPhone('+972546999999', '1234', noop);
|
||||
Accounts.verifyPhone('+972546999999', '1234', '123456');
|
||||
Accounts.verifyPhone('+972546999999', '1234', '123456', noop);
|
||||
|
||||
booleanResult = Accounts.isPhoneVerified();
|
||||
|
||||
Accounts.onPhoneVerification(noop);
|
||||
@@ -0,0 +1,69 @@
|
||||
// Type definitions for accounts-phone 0.0.21
|
||||
// Project: https://github.com/okland/accounts-phone
|
||||
// Definitions by: Eytan Manor <https://github.com/DAB0mB>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace SMS {
|
||||
var twilio: {
|
||||
FROM?: string;
|
||||
ACCOUNT_SID?: string;
|
||||
AUTH_TOKEN?: string;
|
||||
};
|
||||
|
||||
var phoneTemplate: {
|
||||
from: string;
|
||||
text: Function;
|
||||
};
|
||||
|
||||
function send(options: Object, callback?: Function): void;
|
||||
}
|
||||
|
||||
declare namespace Meteor {
|
||||
function loginWithPhoneAndPassword(selector: Object | String, password: String, callback?: Function): void;
|
||||
}
|
||||
|
||||
declare module 'meteor/meteor' {
|
||||
namespace Meteor {
|
||||
function loginWithPhoneAndPassword(selector: Object | String, password: String, callback?: Function): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace Accounts {
|
||||
var _options: {
|
||||
verificationCodeLength?: number,
|
||||
verificationMaxRetries?: number,
|
||||
verificationRetriesWaitTime?: number,
|
||||
verificationWaitTime?: number,
|
||||
sendPhoneVerificationCodeOnCreation?: boolean,
|
||||
forbidClientAccountCreation?: boolean,
|
||||
phoneVerificationMasterCode?: Array<string>,
|
||||
adminPhoneNumbers?: Array<string>
|
||||
};
|
||||
|
||||
function createUserWithPhone(options: Object, callback?: Function): void;
|
||||
function requestPhoneVerification(phone: string, callback?: Function): void;
|
||||
function verifyPhone(phone: string, code: string, newPassword?: string | Function, callback?: Function): void;
|
||||
function isPhoneVerified(): boolean;
|
||||
function onPhoneVerification(func: Function): void;
|
||||
}
|
||||
|
||||
declare module 'meteor/accounts-base' {
|
||||
namespace Accounts {
|
||||
var _options: {
|
||||
verificationCodeLength?: number,
|
||||
verificationMaxRetries?: number,
|
||||
verificationRetriesWaitTime?: number,
|
||||
verificationWaitTime?: number,
|
||||
sendPhoneVerificationCodeOnCreation?: boolean,
|
||||
forbidClientAccountCreation?: boolean,
|
||||
phoneVerificationMasterCode?: Array<string>,
|
||||
adminPhoneNumbers?: Array<string>
|
||||
};
|
||||
|
||||
function createUserWithPhone(options: Object, callback?: Function): void;
|
||||
function requestPhoneVerification(phone: string, callback?: Function): void;
|
||||
function verifyPhone(phone: string, code: string, newPassword?: string | Function, callback?: Function): void;
|
||||
function isPhoneVerified(): boolean;
|
||||
function onPhoneVerification(func: Function): void;
|
||||
}
|
||||
}
|
||||
@@ -63,3 +63,18 @@ declare namespace Meteor {
|
||||
PublishCompositeConfig<any>|PublishCompositeConfig<any>[]
|
||||
) : void;
|
||||
}
|
||||
|
||||
declare module 'meteor/meteor' {
|
||||
namespace Meteor {
|
||||
function publishComposite(
|
||||
name : string,
|
||||
config : PublishCompositeConfig<any>|PublishCompositeConfig<any>[]
|
||||
) : void;
|
||||
|
||||
function publishComposite(
|
||||
name : string,
|
||||
configFunc : (...args : any[]) =>
|
||||
PublishCompositeConfig<any>|PublishCompositeConfig<any>[]
|
||||
) : void;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ declare module "nconf" {
|
||||
export var sources: any[];
|
||||
|
||||
export function clear(key: string, callback?: ICallbackFunction): any;
|
||||
export function get (key: string, callback?: ICallbackFunction): any;
|
||||
export function get (key?: string, callback?: ICallbackFunction): any;
|
||||
export function merge(key: string, value: any, callback?: ICallbackFunction): any;
|
||||
export function set (key: string, value: any, callback?: ICallbackFunction): any;
|
||||
export function reset(callback?: ICallbackFunction): any;
|
||||
|
||||
Vendored
+10
-1
@@ -46,7 +46,16 @@ declare module "nodemailer" {
|
||||
* @param pluginFunc is a function that takes two arguments: the mail object and a callback function
|
||||
*/
|
||||
use(step: string, plugin: Plugin): void;
|
||||
|
||||
|
||||
/**
|
||||
* Verifies connection with server
|
||||
*/
|
||||
verify(callback: (error: Error, success?: boolean) => void): void;
|
||||
|
||||
/**
|
||||
* Verifies connection with server
|
||||
*/
|
||||
verify(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Close all connections
|
||||
|
||||
Vendored
+4
@@ -3349,3 +3349,7 @@ id(value: number|string): this;
|
||||
}
|
||||
}
|
||||
declare var nv : nv.Nvd3Static;
|
||||
|
||||
declare module "nvd3" {
|
||||
export = nv;
|
||||
}
|
||||
|
||||
Vendored
+70
-34
@@ -25,6 +25,10 @@ declare namespace Parse {
|
||||
|
||||
interface SuccessFailureOptions extends SuccessOption, ErrorOption {
|
||||
}
|
||||
|
||||
interface SessionTokenOption {
|
||||
sessionToken?: string;
|
||||
}
|
||||
|
||||
interface WaitOption {
|
||||
/**
|
||||
@@ -67,29 +71,30 @@ declare namespace Parse {
|
||||
|
||||
interface IPromise<T> {
|
||||
|
||||
then<U>(resolvedCallback: (value: T) => IPromise<U>, rejectedCallback?: (reason: any) => IPromise<U>): IPromise<T>;
|
||||
then<U>(resolvedCallback: (value: T) => U, rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (value: T) => U, rejectedCallback?: (reason: any) => U): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => IPromise<U>, rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U, rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U, rejectedCallback?: (reason: any) => U): IPromise<U>;
|
||||
}
|
||||
|
||||
class Promise<T> {
|
||||
class Promise<T> implements IPromise<T> {
|
||||
|
||||
static as<U>(resolvedValue: U): Promise<U>;
|
||||
static error<U>(error: U): Promise<U>;
|
||||
static error<U, V>(error: U): Promise<V>;
|
||||
static is(possiblePromise: any): Boolean;
|
||||
static when(promises: Promise<any>[]): Promise<any>;
|
||||
static when(promises: IPromise<any>[]): Promise<any>;
|
||||
static when(...promises: IPromise<any>[]): Promise<any>;
|
||||
|
||||
always(callback: Function): Promise<T>;
|
||||
done(callback: Function): Promise<T>;
|
||||
fail(callback: Function): Promise<T>;
|
||||
reject(error: any): void;
|
||||
resolve(result: any): void;
|
||||
then<U>(resolvedCallback: (value: T) => Promise<U>,
|
||||
rejectedCallback?: (reason: any) => Promise<U>): IPromise<T>;
|
||||
then<U>(resolvedCallback: (value: T) => U,
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<T>;
|
||||
then<U>(resolvedCallback: (value: T) => U,
|
||||
rejectedCallback?: (reason: any) => U): IPromise<T>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => IPromise<U>,
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U,
|
||||
rejectedCallback?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(resolvedCallback: (...values: T[]) => U,
|
||||
rejectedCallback?: (reason: any) => U): IPromise<U>;
|
||||
}
|
||||
|
||||
interface IBaseObject {
|
||||
@@ -306,7 +311,9 @@ declare namespace Parse {
|
||||
*/
|
||||
class Object extends BaseObject {
|
||||
|
||||
id: any;
|
||||
id: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
attributes: any;
|
||||
cid: string;
|
||||
changed: boolean;
|
||||
@@ -319,7 +326,9 @@ declare namespace Parse {
|
||||
static fetchAll<T>(list: Object[], options: SuccessFailureOptions): Promise<T>;
|
||||
static fetchAllIfNeeded<T>(list: Object[], options: SuccessFailureOptions): Promise<T>;
|
||||
static destroyAll<T>(list: Object[], options?: Object.DestroyAllOptions): Promise<T>;
|
||||
static saveAll<T>(list: Object[], options?: Object.SaveAllOptions): Promise<T>;
|
||||
static saveAll<T extends Object>(list: T[], options?: Object.SaveAllOptions): Promise<T[]>;
|
||||
|
||||
static registerSubclass<T extends Object>(className: string, clazz: new (options?: any) => T): void;
|
||||
|
||||
initialize(): void;
|
||||
add(attr: string, item: any): Object;
|
||||
@@ -333,7 +342,7 @@ declare namespace Parse {
|
||||
dirtyKeys(): string[];
|
||||
escape(attr: string): string;
|
||||
existed(): boolean;
|
||||
fetch<T>(options?: Object.FetchOptions): Promise<T>;
|
||||
fetch<T extends Object>(options?: Object.FetchOptions): Promise<T>;
|
||||
get(attr: string): any;
|
||||
getACL(): ACL;
|
||||
has(attr: string): boolean;
|
||||
@@ -345,7 +354,8 @@ declare namespace Parse {
|
||||
previousAttributes(): any;
|
||||
relation(attr: string): Relation;
|
||||
remove(attr: string, item: any): any;
|
||||
save<T>(options?: Object.SaveOptions, arg2?: any, arg3?: any): Promise<T>;
|
||||
save<T extends Object>(attrs?: { [key: string]: any }, options?: Object.SaveOptions): Promise<T>;
|
||||
save<T extends Object>(key: string, value: any, options?: Object.SaveOptions): Promise<T>;
|
||||
set(key: string, value: any, options?: Object.SetOptions): boolean;
|
||||
setACL(acl: ACL, options?: SuccessFailureOptions): boolean;
|
||||
unset(attr: string, options?: any): any;
|
||||
@@ -583,11 +593,11 @@ declare namespace Parse {
|
||||
doesNotExist(key: string): Query;
|
||||
doesNotMatchKeyInQuery(key: string, queryKey: string, query: Query): Query;
|
||||
doesNotMatchQuery(key: string, query: Query): Query;
|
||||
each<T>(callback: Function, options?: SuccessFailureOptions): Promise<T>;
|
||||
each<T>(callback: Function, options?: Query.EachOptions): Promise<T>;
|
||||
endsWith(key: string, suffix: string): Query;
|
||||
equalTo(key: string, value: any): Query;
|
||||
exists(key: string): Query;
|
||||
find<T>(options?: Query.FindOptions): Promise<T>;
|
||||
find<T extends Object>(options?: Query.FindOptions): Promise<T[]>;
|
||||
first<T>(options?: Query.FirstOptions): Promise<T>;
|
||||
get(objectId: string, options?: Query.GetOptions): Promise<any>;
|
||||
greaterThan(key: string, value: any): Query;
|
||||
@@ -613,6 +623,7 @@ declare namespace Parse {
|
||||
}
|
||||
|
||||
namespace Query {
|
||||
interface EachOptions extends SuccessFailureOptions, UseMasterKeyOption { }
|
||||
interface CountOptions extends SuccessFailureOptions, UseMasterKeyOption { }
|
||||
interface FindOptions extends SuccessFailureOptions, UseMasterKeyOption { }
|
||||
interface FirstOptions extends SuccessFailureOptions, UseMasterKeyOption { }
|
||||
@@ -642,6 +653,21 @@ declare namespace Parse {
|
||||
setName(name: string, options?: SuccessFailureOptions): any;
|
||||
}
|
||||
|
||||
class Config extends Object {
|
||||
static get(options?: SuccessFailureOptions): Promise<Config>;
|
||||
static current(): Config;
|
||||
|
||||
get(attr: string): any;
|
||||
escape(attr: string): any;
|
||||
}
|
||||
|
||||
class Session extends Object {
|
||||
static current(): Promise<Session>;
|
||||
|
||||
getSessionToken(): string;
|
||||
isCurrentSessionRevocable(): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routers map faux-URLs to actions, and fire events when routes are
|
||||
* matched. Creating a new one sets its `routes` hash, if not set statically.
|
||||
@@ -698,11 +724,10 @@ declare namespace Parse {
|
||||
static allowCustomUserClass(isAllowed: boolean): void;
|
||||
static become<T>(sessionToken: string, options?: SuccessFailureOptions): Promise<T>;
|
||||
static requestPasswordReset<T>(email: string, options?: SuccessFailureOptions): Promise<T>;
|
||||
static extend(protoProps?: any, classProps?: any): any;
|
||||
|
||||
signUp<T>(attrs: any, options?: SuccessFailureOptions): Promise<T>;
|
||||
logIn<T>(options?: SuccessFailureOptions): Promise<T>;
|
||||
fetch<T>(options?: SuccessFailureOptions): Promise<T>;
|
||||
save<T>(arg1: any, arg2: any, arg3: any): Promise<T>;
|
||||
authenticated(): boolean;
|
||||
isCurrent(): boolean;
|
||||
|
||||
@@ -822,9 +847,9 @@ declare namespace Parse {
|
||||
}
|
||||
|
||||
interface JobStatus {
|
||||
error?: Function;
|
||||
message?: Function;
|
||||
success?: Function;
|
||||
error?: (response: any) => void;
|
||||
message?: (response: any) => void;
|
||||
success?: (response: any) => void;
|
||||
}
|
||||
|
||||
interface FunctionRequest {
|
||||
@@ -835,8 +860,8 @@ declare namespace Parse {
|
||||
}
|
||||
|
||||
interface FunctionResponse {
|
||||
success?: (response: HttpResponse) => void;
|
||||
error?: (response: HttpResponse) => void;
|
||||
success?: (response: any) => void;
|
||||
error?: (response: any) => void;
|
||||
}
|
||||
|
||||
interface Cookie {
|
||||
@@ -845,12 +870,18 @@ declare namespace Parse {
|
||||
value?: string;
|
||||
}
|
||||
|
||||
interface AfterSaveRequest extends FunctionRequest {}
|
||||
interface SaveRequest extends FunctionRequest {
|
||||
object: Object;
|
||||
}
|
||||
|
||||
interface AfterSaveRequest extends SaveRequest {}
|
||||
interface AfterDeleteRequest extends FunctionRequest {}
|
||||
interface BeforeDeleteRequest extends FunctionRequest {}
|
||||
interface BeforeDeleteResponse extends FunctionResponse {}
|
||||
interface BeforeSaveRequest extends FunctionRequest {}
|
||||
interface BeforeSaveResponse extends FunctionResponse {}
|
||||
interface BeforeSaveRequest extends SaveRequest {}
|
||||
interface BeforeSaveResponse extends FunctionResponse {
|
||||
success?: () => void;
|
||||
}
|
||||
|
||||
function afterDelete(arg1: any, func?: (request: AfterDeleteRequest) => void): void;
|
||||
function afterSave(arg1: any, func?: (request: AfterSaveRequest) => void): void;
|
||||
@@ -859,9 +890,11 @@ declare namespace Parse {
|
||||
function define(name: string, func?: (request: FunctionRequest, response: FunctionResponse) => void): void;
|
||||
function httpRequest(options: HTTPOptions): Promise<HttpResponse>;
|
||||
function job(name: string, func?: (request: JobRequest, status: JobStatus) => void): HttpResponse;
|
||||
function run<T>(name: string, data?: any, options?: SuccessFailureOptions): Promise<T>;
|
||||
function run<T>(name: string, data?: any, options?: RunOptions): Promise<T>;
|
||||
function useMasterKey(): void;
|
||||
|
||||
interface RunOptions extends SuccessFailureOptions, UseMasterKeyOption, SessionTokenOption { }
|
||||
|
||||
/**
|
||||
* To use this Cloud Module in Cloud Code, you must require 'buffer' in your JavaScript file.
|
||||
*
|
||||
@@ -911,7 +944,10 @@ declare namespace Parse {
|
||||
|
||||
}
|
||||
|
||||
enum ErrorCode {
|
||||
/*
|
||||
* We need to inline the codes in order to make compilation work without this type definition as dependency.
|
||||
*/
|
||||
const enum ErrorCode {
|
||||
|
||||
OTHER_CAUSE = -1,
|
||||
INTERNAL_SERVER_ERROR = 1,
|
||||
@@ -1043,18 +1079,18 @@ declare namespace Parse {
|
||||
* Call this method first to set up your authentication tokens for Parse.
|
||||
* You can get your keys from the Data Browser on parse.com.
|
||||
* @param {String} applicationId Your Parse Application ID.
|
||||
* @param {String} javaScriptKey Your Parse JavaScript Key.
|
||||
* @param {String} javaScriptKey (optional) Your Parse JavaScript Key (Not needed for parse-server)
|
||||
* @param {String} masterKey (optional) Your Parse Master Key. (Node.js only!)
|
||||
*/
|
||||
function initialize(applicationId: string, javaScriptKey: string, masterKey?: string): void;
|
||||
function initialize(applicationId: string, javaScriptKey?: string, masterKey?: string): void;
|
||||
|
||||
}
|
||||
|
||||
declare module "parse/node" {
|
||||
export = { Parse };
|
||||
export = Parse;
|
||||
}
|
||||
|
||||
declare module "parse" {
|
||||
import parse = require("parse/node");
|
||||
import * as parse from "parse/node";
|
||||
export = parse
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -29,7 +29,7 @@ interface PlotlyConfig {
|
||||
}
|
||||
|
||||
interface PlotlyStatic {
|
||||
newPlot(divid:string, data:any[], layout?:any, config?:PlotlyConfig):void;
|
||||
newPlot(divid:string | HTMLElement, data:any[], layout?:any, config?:PlotlyConfig):void;
|
||||
}
|
||||
|
||||
declare module "plotly.js" {
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/// <reference path="pouch.d.ts" />
|
||||
|
||||
window.alert = function (thing?: string) {
|
||||
var div = document.createElement('div');
|
||||
div.appendChild(document.createTextNode(thing));
|
||||
document.getElementsByTagName('body')[0].appendChild(div);
|
||||
}
|
||||
|
||||
var pouch: PouchDB;
|
||||
|
||||
function pouchTests() {
|
||||
new PouchDB('testdb', function (err: PouchError, res: PouchDB) {
|
||||
if (err) {
|
||||
alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason);
|
||||
}
|
||||
else {
|
||||
pouch = res;
|
||||
alert("database opened");
|
||||
runTests();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var tests = [
|
||||
setupTests,
|
||||
testId,
|
||||
testAllDocs,
|
||||
testGet,
|
||||
testUpdate,
|
||||
testDelete,
|
||||
deleteDb
|
||||
];
|
||||
|
||||
var testIndex;
|
||||
|
||||
var revs: any = {};
|
||||
|
||||
function runTests() {
|
||||
testIndex = 0;
|
||||
tests[testIndex++]();
|
||||
}
|
||||
|
||||
// each test function except the last one needs to call nextTest when it is finished doing its thing.
|
||||
function nextTest() {
|
||||
alert("starting test " + testIndex);
|
||||
tests[testIndex++]();
|
||||
}
|
||||
|
||||
function setupTests() {
|
||||
alert('setupTests');
|
||||
pouch.bulkDocs({
|
||||
docs: [{ _id: '1', name: 'record 1' },
|
||||
{ _id: '2', name: 'record 2' },
|
||||
{ _id: '3', name: 'record 3' }
|
||||
]
|
||||
}, function (err: PouchError, res: PouchUpdateResponse[]) {
|
||||
if (err) {
|
||||
alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason);
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < res.length; i++) {
|
||||
if (res[i].ok) {
|
||||
revs[res[i].id] = res[i].rev;
|
||||
}
|
||||
}
|
||||
alert("test records loaded");
|
||||
}
|
||||
nextTest();
|
||||
});
|
||||
}
|
||||
|
||||
function testId() {
|
||||
alert('testId');
|
||||
var id = pouch.id();
|
||||
alert('Database Id = ' + id);
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function testGet() {
|
||||
alert('testGet');
|
||||
pouch.get('1', function (err: PouchError, res: PouchGetResponse) {
|
||||
if (err) {
|
||||
alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason);
|
||||
}
|
||||
else {
|
||||
alert('Retrieved record with id=1, name=[' + res['name'] + ']');
|
||||
}
|
||||
nextTest();
|
||||
});
|
||||
}
|
||||
|
||||
function testAllDocs() {
|
||||
alert('testAllDocs');
|
||||
pouch.allDocs(function (err: PouchError, res: PouchAllDocsResponse) {
|
||||
alert('allDocs resulted in ' + res.total_rows + ' results');
|
||||
for (var i = 0; i < res.total_rows; i++) {
|
||||
alert('Retrieved record with id=' + res.rows[i].id + ', rev=[' + res.rows[i].value.rev + ']');
|
||||
}
|
||||
nextTest();
|
||||
});
|
||||
}
|
||||
|
||||
function testUpdate() {
|
||||
alert('testUpdate');
|
||||
pouch.put({ _id: '2', _rev: revs['2'], name: 'record 2 updated' }, function (err: PouchError, res: PouchUpdateResponse) {
|
||||
if (err) {
|
||||
alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason);
|
||||
}
|
||||
else {
|
||||
alert('record updated id=' + res.id + ', rev=[' + res.rev + ']');
|
||||
}
|
||||
testAllDocs(); // spit out the db contents and then go on
|
||||
});
|
||||
}
|
||||
|
||||
function testDelete() {
|
||||
alert('testDelete');
|
||||
pouch.remove({ _id: '3', _rev: revs['3'] }, function (err: PouchError, res: PouchUpdateResponse) {
|
||||
if (err) {
|
||||
alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason);
|
||||
}
|
||||
else {
|
||||
alert('record deleted id=' + res.id + ', rev=[' + res.rev + ']');
|
||||
}
|
||||
testAllDocs(); // spit out the db contents and then go on
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDb() {
|
||||
alert('deleteDb');
|
||||
if (pouch) {
|
||||
pouch = null;
|
||||
PouchDB.destroy('testdb', function (err: PouchError) {
|
||||
if (err) {
|
||||
alert('Error ' + err.status + ' occurred ' + err.error + ' - ' + err.reason);
|
||||
}
|
||||
else {
|
||||
alert("database destroyed");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
Vendored
-232
@@ -1,232 +0,0 @@
|
||||
// Type definitions for Pouch 0.1
|
||||
// Project: http://pouchdb.com
|
||||
// Definitions by: Bill Sears <https://github.com/MrBigDog2U/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface PouchError {
|
||||
status: number;
|
||||
error: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
interface PouchApi {
|
||||
type(): string;
|
||||
id(): string;
|
||||
close(callback: () => void): void;
|
||||
}
|
||||
|
||||
interface PouchInfoResponse {
|
||||
db_name: string;
|
||||
doc_count: number;
|
||||
update_seq: string;
|
||||
}
|
||||
|
||||
interface PouchApi {
|
||||
info(callback: (err: PouchError, res: PouchInfoResponse) => void): void;
|
||||
}
|
||||
|
||||
interface PouchGetOptions {
|
||||
rev?: string;
|
||||
revs?: boolean;
|
||||
revs_info?: boolean;
|
||||
conflicts?: boolean;
|
||||
attachments?: boolean;
|
||||
}
|
||||
|
||||
interface PouchGetResponse {
|
||||
_id: string;
|
||||
_rev: string;
|
||||
_attachments: any;
|
||||
}
|
||||
|
||||
interface PouchAllDocsOptions {
|
||||
startkey?: string;
|
||||
endKey?: string;
|
||||
descending?: boolean;
|
||||
include_docs?: boolean;
|
||||
conflicts?: boolean;
|
||||
}
|
||||
|
||||
interface PouchAllDocsItem {
|
||||
id: string;
|
||||
key: string;
|
||||
value: any;
|
||||
doc: any;
|
||||
}
|
||||
|
||||
interface PouchAllDocsResponse {
|
||||
total_rows: number;
|
||||
rows: PouchAllDocsItem[];
|
||||
}
|
||||
|
||||
interface PouchApi {
|
||||
//
|
||||
// get == select by id
|
||||
//
|
||||
get(id: string, opts: PouchGetOptions, callback: (err: PouchError, res: PouchGetResponse) => void): void;
|
||||
get(id: string, callback: (err: PouchError, res: PouchGetResponse) => void): void;
|
||||
allDocs(opts: PouchAllDocsOptions, callback: (err: PouchError, res: PouchAllDocsResponse) => void): void;
|
||||
allDocs(callback: (err: PouchError, res: PouchAllDocsResponse) => void): void;
|
||||
}
|
||||
|
||||
interface PouchBulkDocsRequest {
|
||||
docs: any[];
|
||||
}
|
||||
|
||||
interface PouchUpdateOptions {
|
||||
new_edits?: boolean;
|
||||
}
|
||||
|
||||
interface PouchUpdateResponse {
|
||||
ok: boolean;
|
||||
id: string;
|
||||
rev: string;
|
||||
}
|
||||
|
||||
interface PouchApi {
|
||||
bulkDocs(req: PouchBulkDocsRequest, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void;
|
||||
bulkDocs(req: PouchBulkDocsRequest, callback: (err: PouchError, res: PouchUpdateResponse[]) => void): void;
|
||||
//
|
||||
// post == insert (doc does not contain an _id)
|
||||
//
|
||||
post(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
|
||||
post(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
|
||||
//
|
||||
// put == update (doc DOES contain an _id)
|
||||
//
|
||||
put(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
|
||||
put(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
|
||||
//
|
||||
// remove == delete
|
||||
//
|
||||
remove(doc: any, opts: PouchUpdateOptions, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
|
||||
remove(doc: any, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
|
||||
}
|
||||
|
||||
interface PouchFilter {
|
||||
map: (doc: any) => void;
|
||||
reduce?: (key: string, value: any) => any;
|
||||
}
|
||||
|
||||
interface PouchQueryOptions {
|
||||
complete?: any;
|
||||
include_docs?: boolean;
|
||||
error?: (err: PouchError) => void;
|
||||
descending?: boolean;
|
||||
reduce?: boolean;
|
||||
}
|
||||
|
||||
interface PouchQueryResponse {
|
||||
rows: any[];
|
||||
}
|
||||
|
||||
interface PouchApi {
|
||||
//
|
||||
// query == select by other criteria
|
||||
//
|
||||
query(fun: string, opts: PouchQueryOptions, callback: (err: PouchError, res: PouchQueryResponse) => void): void;
|
||||
query(fun: string, callback: (err: PouchError, res: PouchQueryResponse) => void): void;
|
||||
query(fun: PouchFilter, opts: PouchQueryOptions, callback: (err: PouchError, res: PouchQueryResponse) => void): void;
|
||||
query(fun: PouchFilter, callback: (err: PouchError, res: PouchQueryResponse) => void): void;
|
||||
}
|
||||
|
||||
interface PouchAttachmentOptions {
|
||||
decode?: boolean;
|
||||
}
|
||||
|
||||
interface PouchApi {
|
||||
getAttachment(id: string, opts: PouchAttachmentOptions, callback: (err: PouchError, res: any) => void): void;
|
||||
getAttachment(id: string, callback: (err: PouchError, res: any) => void): void;
|
||||
putAttachment(id: string, rev: string, doc: any, type: string, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
|
||||
removeAttachment(id: string, rev: string, callback: (err: PouchError, res: PouchUpdateResponse) => void): void;
|
||||
}
|
||||
|
||||
interface PouchCancellable {
|
||||
cancel: () => void;
|
||||
}
|
||||
|
||||
interface PouchChangesOptions {
|
||||
onChange: (change: PouchChange) => void;
|
||||
complete?: (err: PouchError, res: PouchChanges) => void;
|
||||
seq?: number;
|
||||
since?: number;
|
||||
descending?: boolean;
|
||||
filter?: PouchFilter;
|
||||
continuous?: boolean;
|
||||
include_docs?: boolean;
|
||||
conflicts?: boolean;
|
||||
}
|
||||
|
||||
interface PouchChange {
|
||||
changes: any;
|
||||
doc: PouchGetResponse;
|
||||
id: string;
|
||||
seq: number;
|
||||
}
|
||||
|
||||
interface PouchChanges {
|
||||
results: PouchChange[];
|
||||
}
|
||||
|
||||
interface PouchApi {
|
||||
changes(opts: PouchChangesOptions, callback: (err: PouchError, res: PouchChanges) => void): PouchCancellable;
|
||||
changes(callback: (err: PouchError, res: PouchChanges) => void): PouchCancellable;
|
||||
}
|
||||
|
||||
interface PouchRevsDiffOptions {
|
||||
}
|
||||
|
||||
interface PouchReplicateOptions {
|
||||
continuous?: boolean;
|
||||
onChange?: (e: any) => void;
|
||||
filter?: any; // Can be either string or PouchFilter
|
||||
complete?: (err: PouchError, res: PouchChanges) => void;
|
||||
}
|
||||
|
||||
interface PouchReplicateResponse {
|
||||
ok: boolean;
|
||||
start_time: Date;
|
||||
end_time: Date;
|
||||
docs_read: number;
|
||||
docs_written: number;
|
||||
}
|
||||
|
||||
interface PouchReplicate {
|
||||
from(url: string, opts: PouchReplicateOptions, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable;
|
||||
from(url: string, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable;
|
||||
to(dbName: string, opts: PouchReplicateOptions, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable;
|
||||
to(dbName: string, callback: (err: PouchError, res: PouchReplicateResponse) => void): PouchCancellable;
|
||||
}
|
||||
|
||||
interface PouchApi {
|
||||
revsDiff(req: any, opts: PouchRevsDiffOptions, callback: (missing: any) => void): void;
|
||||
revsDiff(req: any, callback: (missing: any) => void): void;
|
||||
replicate: PouchReplicate;
|
||||
}
|
||||
|
||||
interface PouchOptions {
|
||||
name?: string;
|
||||
adapter?: string;
|
||||
skip_setup?: boolean;
|
||||
}
|
||||
|
||||
interface PouchDB extends PouchApi {
|
||||
new (name: string, opts: PouchOptions, callback: (err: PouchError, res: PouchDB) => void): PouchDB;
|
||||
new (name: string, callback: (err: PouchError, res: PouchDB) => void): PouchDB;
|
||||
new (name: string, opts: PouchOptions): PouchDB;
|
||||
new (name: string): PouchDB;
|
||||
destroy(name: string, callback: (err: PouchError) => void): void;
|
||||
}
|
||||
|
||||
declare var PouchDB: PouchDB;
|
||||
|
||||
// Support AMD require
|
||||
declare module 'pouchdb' {
|
||||
export = PouchDB;
|
||||
}
|
||||
|
||||
//
|
||||
// emit is the function that the PouchFilter.map function should call in order to add a particular item to
|
||||
// a filter view.
|
||||
//
|
||||
declare function emit(key: any, value: any): void;
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-adapter-fruitdown.d.ts" />
|
||||
|
||||
namespace PouchDBAdapterFruitdownTests {
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
let model: PouchDB.Core.Document<MyModel>;
|
||||
|
||||
let db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'fruitdown',
|
||||
});
|
||||
db.get('model').then((result) => model);
|
||||
db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'fruitdown',
|
||||
});
|
||||
db.get('model').then((result) => model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Type definitions for pouchdb-adapter-fruitdown v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace FruitDOWNAdapter {
|
||||
interface FruitDOWNAdapterConfiguration
|
||||
extends Configuration.LocalDatabaseConfiguration {
|
||||
adapter: 'fruitdown';
|
||||
}
|
||||
}
|
||||
|
||||
interface Static {
|
||||
new<Content extends Core.Encodable>(name: string | void,
|
||||
options: FruitDOWNAdapter.FruitDOWNAdapterConfiguration
|
||||
): Database<Content>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-adapter-fruitdown' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-adapter-http.d.ts" />
|
||||
|
||||
function testHttpDbCreation() {
|
||||
const basicDB = new PouchDB('basic', {
|
||||
adapter: 'http'
|
||||
});
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for pouchdb-http v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace HttpAdapter {
|
||||
interface HttpAdapterConfiguration
|
||||
extends Configuration.RemoteDatabaseConfiguration {
|
||||
adapter: 'http';
|
||||
}
|
||||
}
|
||||
|
||||
interface Static {
|
||||
new<Content extends Core.Encodable>(name: string | void,
|
||||
options: HttpAdapter.HttpAdapterConfiguration
|
||||
): Database<Content>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-adapter-http' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-adapter-idb.d.ts" />
|
||||
|
||||
function testIdbDbCreation() {
|
||||
const basicDB = new PouchDB('basic', {
|
||||
adapter: 'idb'
|
||||
});
|
||||
const persistentDb = new PouchDB('persistent', {
|
||||
adapter: 'idb',
|
||||
storage: 'persistent'
|
||||
});
|
||||
const temporaryDb = new PouchDB('temporary', {
|
||||
adapter: 'idb',
|
||||
storage: 'temporary'
|
||||
});
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// Type definitions for pouchdb-adapter-idb v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace Core {
|
||||
interface DatabaseInfo {
|
||||
idb_attachment_format?: 'base64' | 'binary';
|
||||
}
|
||||
}
|
||||
|
||||
namespace IdbAdapter {
|
||||
interface IdbAdapterConfiguration
|
||||
extends Configuration.LocalDatabaseConfiguration {
|
||||
/**
|
||||
* Configures storage persistence.
|
||||
*
|
||||
* Only works in Firefox 26+.
|
||||
*/
|
||||
storage?: 'persistent' | 'temporary';
|
||||
adapter: 'idb';
|
||||
}
|
||||
}
|
||||
|
||||
interface Static {
|
||||
new<Content extends Core.Encodable>(name: string | void,
|
||||
options: IdbAdapter.IdbAdapterConfiguration
|
||||
): Database<Content>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-adapter-idb' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-adapter-leveldb.d.ts" />
|
||||
|
||||
namespace PouchDBAdapterLevelDBTests {
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
|
||||
let db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'leveldb',
|
||||
});
|
||||
db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'leveldb',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Type definitions for pouchdb-adapter-leveldb v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace LevelDbAdapter {
|
||||
interface LevelDbAdapterConfiguration extends Configuration.LocalDatabaseConfiguration {
|
||||
adapter: 'leveldb';
|
||||
}
|
||||
}
|
||||
|
||||
interface Static {
|
||||
new<Content extends Core.Encodable>(name: string | void,
|
||||
options: LevelDbAdapter.LevelDbAdapterConfiguration
|
||||
): Database<Content>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-adapter-leveldb' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-adapter-localstorage.d.ts" />
|
||||
|
||||
namespace PouchDBAdapterLocalStorageyTests {
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
|
||||
let db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'localstorage',
|
||||
});
|
||||
db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'localstorage',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Type definitions for pouchdb-adapter-localstorage v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace LocalStorageAdapter {
|
||||
interface LocalStorageAdapterConfiguration
|
||||
extends Configuration.LocalDatabaseConfiguration {
|
||||
adapter: 'localstorage';
|
||||
}
|
||||
}
|
||||
|
||||
interface Static {
|
||||
new<Content extends Core.Encodable>(name: string | void,
|
||||
options: LocalStorageAdapter.LocalStorageAdapterConfiguration
|
||||
): Database<Content>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-adapter-localstorage' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-adapter-memory.d.ts" />
|
||||
|
||||
namespace PouchDBAdapterMemoryTests {
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
|
||||
let db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'memory',
|
||||
});
|
||||
db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'memory',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Type definitions for pouchdb-adapter-memory v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace MemoryAdapter {
|
||||
interface MemoryAdapterConfiguration
|
||||
extends Configuration.LocalDatabaseConfiguration {
|
||||
adapter: 'memory';
|
||||
}
|
||||
}
|
||||
|
||||
interface Static {
|
||||
new<Content extends Core.Encodable>(name: string | void,
|
||||
options: MemoryAdapter.MemoryAdapterConfiguration
|
||||
): Database<Content>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-adapter-memory' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-adapter-node-websql.d.ts" />
|
||||
|
||||
namespace PouchDBAdapterNodeWebSQLTests {
|
||||
function isBoolean(someBoolean: boolean) {
|
||||
}
|
||||
function isNumber(someNumber: number) {
|
||||
}
|
||||
function isString(someString: string) {
|
||||
}
|
||||
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
|
||||
let db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'websql',
|
||||
size: 5,
|
||||
});
|
||||
db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'websql',
|
||||
});
|
||||
|
||||
db.info().then((info) => {
|
||||
isBoolean(info.sqlite_plugin);
|
||||
isString(info.websql_encoding);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Type definitions for pouchdb-adapter-node-websql v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="../pouchdb-adapter-websql/pouchdb-adapter-websql.d.ts" />
|
||||
|
||||
declare module 'pouchdb-adapter-node-websql' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-adapter-websql.d.ts" />
|
||||
|
||||
namespace PouchDBAdapterWebSQLTests {
|
||||
function isBoolean(someBoolean: boolean) {
|
||||
}
|
||||
function isNumber(someNumber: number) {
|
||||
}
|
||||
function isString(someString: string) {
|
||||
}
|
||||
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
|
||||
let db = new PouchDB('basic');
|
||||
db = new PouchDB(null, {
|
||||
adapter: 'websql'
|
||||
});
|
||||
db = new PouchDB('sized', {
|
||||
adapter: 'websql',
|
||||
size: 10
|
||||
});
|
||||
|
||||
db.info().then((info) => {
|
||||
isBoolean(info.sqlite_plugin);
|
||||
isString(info.websql_encoding);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Type definitions for pouchdb-adapter-websql v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace Core {
|
||||
interface DatabaseInfo {
|
||||
sqlite_plugin?: boolean;
|
||||
websql_encoding?: 'UTF-8' | 'UTF-16';
|
||||
}
|
||||
}
|
||||
|
||||
namespace AdapterWebSql {
|
||||
interface Configuration
|
||||
extends Configuration.LocalDatabaseConfiguration {
|
||||
/**
|
||||
* Amount in MB to request for storage.
|
||||
*/
|
||||
size?: number;
|
||||
adapter: 'websql';
|
||||
}
|
||||
}
|
||||
|
||||
interface Static {
|
||||
new<Content extends Core.Encodable>(name: string | void,
|
||||
options: AdapterWebSql.Configuration): Database<Content>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-adapter-websql' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-browser.d.ts" />
|
||||
|
||||
namespace PouchDBBrowserTests {
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
let model: PouchDB.Core.Document<MyModel>;
|
||||
|
||||
let db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'idb',
|
||||
});
|
||||
db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'http',
|
||||
});
|
||||
db.get('model').then((result) => model);
|
||||
db.viewCleanup().catch((error) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for pouchdb-browser v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="../pouchdb-adapter-idb/pouchdb-adapter-idb.d.ts" />
|
||||
/// <reference path="../pouchdb-adapter-http/pouchdb-adapter-http.d.ts" />
|
||||
/// <reference path="../pouchdb-mapreduce/pouchdb-mapreduce.d.ts" />
|
||||
/// <reference path="../pouchdb-replication/pouchdb-replication.d.ts" />
|
||||
|
||||
declare module 'pouchdb-browser' {
|
||||
const PouchDb: PouchDB.Static;
|
||||
export = PouchDb;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/// <reference path="./pouchdb-core.d.ts" />
|
||||
|
||||
namespace PouchDBCoreTests {
|
||||
function isString(someString: string) {
|
||||
}
|
||||
function isNumber(someNumber: number) {
|
||||
}
|
||||
|
||||
function testAllDocs() {
|
||||
const db = new PouchDB<{ foo: number }>();
|
||||
|
||||
db.allDocs().then(({ offset, total_rows, rows }) => {
|
||||
isNumber(offset);
|
||||
isNumber(total_rows);
|
||||
|
||||
rows.forEach(({ id, key, value, doc }) => {
|
||||
isString(id);
|
||||
isString(key);
|
||||
isString(value.rev);
|
||||
|
||||
// check document property
|
||||
isNumber(doc.foo);
|
||||
})
|
||||
});
|
||||
|
||||
db.allDocs({ startkey: "a", endkey: "b" });
|
||||
db.allDocs({ startkey: "a", endkey: "b", inclusive_end: true });
|
||||
db.allDocs({ keys: ["a", "b", "c" ]});
|
||||
db.allDocs({ key: "a" });
|
||||
db.allDocs({
|
||||
attachments: true,
|
||||
binary: true,
|
||||
conflicts: true,
|
||||
descending: true,
|
||||
include_docs: true,
|
||||
limit: 5,
|
||||
skip: 1
|
||||
});
|
||||
}
|
||||
|
||||
function testDestroy() {
|
||||
const db = new PouchDB<{}>();
|
||||
|
||||
db.destroy({}, (error) => {
|
||||
});
|
||||
db.destroy().then(() => {
|
||||
}).catch((error) => {
|
||||
});
|
||||
}
|
||||
|
||||
function testBasics() {
|
||||
type MyModel = { property: 'someProperty '};
|
||||
let model: PouchDB.Core.Document<MyModel>;
|
||||
const id = 'model';
|
||||
|
||||
const db = new PouchDB<MyModel>();
|
||||
|
||||
db.post(model).then((result) => {
|
||||
isString(result.id);
|
||||
});
|
||||
db.post(model, null, (error, response) => {
|
||||
});
|
||||
|
||||
db.get(id).then((result) => model = result);
|
||||
db.get(id, null, (error, result) => {
|
||||
});
|
||||
|
||||
db.put(model).then((error) => {
|
||||
});
|
||||
db.put(model, null, null, null, (error) => {
|
||||
});
|
||||
|
||||
db.info().then((info) => {
|
||||
});
|
||||
db.info({ ajax: { cache: true }}, (error, result) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
Vendored
+334
@@ -0,0 +1,334 @@
|
||||
// Type definitions for pouchdb-core v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace Core {
|
||||
interface Error {
|
||||
}
|
||||
interface Callback<E, R> {
|
||||
(error: E | void, result: R | void): void;
|
||||
}
|
||||
type AnyCallback = Callback<any, any>;
|
||||
type DocumentId = string;
|
||||
type DocumentKey = string;
|
||||
type RevisionId = string;
|
||||
type Availability = 'available' | 'compacted' | 'not compacted' | 'missing';
|
||||
type Attachment = string | ArrayBuffer;
|
||||
type Encodable = { [propertyName: string]: any };
|
||||
|
||||
interface Options {
|
||||
ajax?: Configuration.RemoteRequesterConfiguration;
|
||||
}
|
||||
|
||||
interface BasicResponse {
|
||||
/** `true` if the operation was successful; `false` otherwise */
|
||||
ok: boolean;
|
||||
}
|
||||
interface Response extends BasicResponse {
|
||||
/** id of the targeted document */
|
||||
id: DocumentId;
|
||||
/** resulting revision of the targeted document */
|
||||
rev: RevisionId;
|
||||
}
|
||||
|
||||
interface DatabaseInfo {
|
||||
}
|
||||
|
||||
interface Revision<Content> {
|
||||
ok: Document<Content> & RevisionIdMeta;
|
||||
}
|
||||
interface RevisionInfo {
|
||||
rev: RevisionId;
|
||||
status: Availability;
|
||||
}
|
||||
|
||||
interface IdMeta {
|
||||
_id: DocumentId;
|
||||
}
|
||||
interface RevisionIdMeta {
|
||||
_rev: RevisionId;
|
||||
}
|
||||
interface GetMeta {
|
||||
/** Conflicting leaf revisions.
|
||||
*
|
||||
* Only present if `GetOptions.conflicts` is `true`
|
||||
*/
|
||||
_conflicts?: RevisionId[];
|
||||
_rev?: RevisionId;
|
||||
/** Only present if `GetOptions.revs` is `true` */
|
||||
_revs_info?: RevisionInfo[];
|
||||
/** Only present if `GetOptions.revs_info` is `true` */
|
||||
_revisions?: {
|
||||
ids: RevisionId[];
|
||||
start: number;
|
||||
}
|
||||
}
|
||||
type NewDocument<Content extends Encodable> = Content;
|
||||
type Document<Content extends Encodable> = Content & IdMeta;
|
||||
type ExistingDocument<Content extends Encodable> =
|
||||
Document<Content> & RevisionIdMeta;
|
||||
|
||||
interface AllDocsOptions extends Options {
|
||||
/** Include attachment data for each document.
|
||||
*
|
||||
* Requires `include_docs` to be `true`.
|
||||
*
|
||||
* By default, attachments are Base64-encoded.
|
||||
* @see binary
|
||||
*/
|
||||
attachments?: boolean;
|
||||
/** Return attachments as Buffers.
|
||||
*
|
||||
* Requires `include_docs` to be `true`.
|
||||
* Requires `attachments` to be `true`. */
|
||||
binary?: boolean;
|
||||
/** Include conflict information for each document.
|
||||
*
|
||||
* Requires `include_docs` to be `true`. */
|
||||
conflicts?: boolean;
|
||||
/** Reverse ordering of results. */
|
||||
descending?: boolean;
|
||||
/** Include contents for each document. */
|
||||
include_docs?: boolean;
|
||||
/** Maximum number of documents to return. */
|
||||
limit?: number;
|
||||
/** Number of documents to skip before returning.
|
||||
*
|
||||
* Causes poor performance on IndexedDB and LevelDB. */
|
||||
skip?: number;
|
||||
}
|
||||
interface AllDocsWithKeyOptions extends AllDocsOptions {
|
||||
/** Constrain results to documents matching this key. */
|
||||
key: DocumentKey;
|
||||
}
|
||||
interface AllDocsWithKeysOptions extends AllDocsOptions {
|
||||
/** Constrains results to documents matching any of these keys. */
|
||||
keys: DocumentId[];
|
||||
}
|
||||
interface AllDocsWithinRangeOptions extends AllDocsOptions {
|
||||
/** Low end of range, or high end if `descending` is `true`. */
|
||||
startkey: DocumentKey;
|
||||
/** High end of range, or low end if `descending` is `true`. */
|
||||
endkey: DocumentKey;
|
||||
/** Include any documents identified by `endkey`.
|
||||
*
|
||||
* Defaults to `true`. */
|
||||
inclusive_end?: boolean;
|
||||
}
|
||||
interface AllDocsMeta {
|
||||
_attachments?: {
|
||||
[attachmentId: string]: Attachment;
|
||||
};
|
||||
}
|
||||
interface AllDocsResponse<Content extends Core.Encodable> {
|
||||
/** The `skip` if provided, or in CouchDB the actual offset */
|
||||
offset: number;
|
||||
total_rows: number;
|
||||
rows: {
|
||||
/** Only present if `include_docs` was `true`. */
|
||||
doc?: Document<Content & AllDocsMeta>;
|
||||
id: DocumentId;
|
||||
key: DocumentKey;
|
||||
value: {
|
||||
rev: RevisionId;
|
||||
}
|
||||
}[];
|
||||
}
|
||||
|
||||
interface DestroyOptions extends Options {
|
||||
}
|
||||
|
||||
interface GetOptions extends Options {
|
||||
/** Include list of conflicting leaf revisions. */
|
||||
conflicts?: boolean;
|
||||
/** Specific revision to fetch */
|
||||
rev?: RevisionId;
|
||||
/** Include revision history of the document. */
|
||||
revs?: boolean;
|
||||
/** Include a list of revisions of the document, and their
|
||||
* availability. */
|
||||
revs_info?: boolean;
|
||||
}
|
||||
interface GetOpenRevisions extends Options {
|
||||
/** Fetch all leaf revisions if open_revs="all" or fetch all leaf
|
||||
* revisions specified in open_revs array. Leaves will be returned
|
||||
* in the same order as specified in input array. */
|
||||
open_revs: 'all' | Core.RevisionId[];
|
||||
}
|
||||
|
||||
/** @todo does this have any other properties? */
|
||||
interface PutOptions extends Options {
|
||||
}
|
||||
interface PostOptions extends PutOptions {
|
||||
}
|
||||
|
||||
interface InfoOptions extends Options {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass this to `PouchDB.plugin()`.
|
||||
*/
|
||||
export type Plugin = 'This should be passed to PouchDB.plugin()';
|
||||
|
||||
namespace Configuration {
|
||||
interface CommonDatabaseConfiguration {
|
||||
/**
|
||||
* Database name.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* Database adapter to use.
|
||||
*
|
||||
* If unspecified, PouchDB will infer this automatically, preferring
|
||||
* IndexedDB to WebSQL in browsers that support both (i.e. Chrome,
|
||||
* Opera and Android 4.4+).
|
||||
*/
|
||||
adapter?: string;
|
||||
}
|
||||
|
||||
interface LocalDatabaseConfiguration extends CommonDatabaseConfiguration {
|
||||
/**
|
||||
* Enables auto compaction, which means compact() is called after
|
||||
* every change to the database.
|
||||
*
|
||||
* Defaults to false.
|
||||
*/
|
||||
auto_compaction?: boolean;
|
||||
/**
|
||||
* How many old revisions we keep track (not a copy) of.
|
||||
*/
|
||||
revs_limit?: number;
|
||||
}
|
||||
|
||||
interface RemoteRequesterConfiguration {
|
||||
/**
|
||||
* Time before HTTP requests time out (in ms).
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* Appends a random string to the end of all HTTP GET requests to avoid
|
||||
* them being cached on IE. Set this to true to prevent this happening.
|
||||
*/
|
||||
cache?: boolean;
|
||||
/**
|
||||
* HTTP headers to add to requests.
|
||||
*/
|
||||
headers?: {
|
||||
[name: string]: string;
|
||||
}
|
||||
username?: string;
|
||||
password?: string;
|
||||
/**
|
||||
* Enables transferring cookies and HTTP Authorization information.
|
||||
*
|
||||
* Defaults to true.
|
||||
*/
|
||||
withCredentials?: boolean;
|
||||
/**
|
||||
* Disables automatic creation of databases.
|
||||
*/
|
||||
skip_setup?: boolean;
|
||||
}
|
||||
|
||||
interface RemoteDatabaseConfiguration extends CommonDatabaseConfiguration {
|
||||
ajax?: RemoteRequesterConfiguration;
|
||||
}
|
||||
|
||||
type DatabaseConfiguration = LocalDatabaseConfiguration |
|
||||
RemoteDatabaseConfiguration;
|
||||
}
|
||||
|
||||
|
||||
|
||||
interface Static {
|
||||
plugin(plugin: Plugin): Static;
|
||||
|
||||
new<Content extends Core.Encodable>(name?: string,
|
||||
options?: Configuration.DatabaseConfiguration): Database<Content>;
|
||||
}
|
||||
|
||||
interface Database<Content extends Core.Encodable> {
|
||||
/** Fetch all documents matching the given key. */
|
||||
allDocs(options: Core.AllDocsWithKeyOptions):
|
||||
Promise<Core.AllDocsResponse<Content>>;
|
||||
/** Fetch all documents matching any of the given keys. */
|
||||
allDocs(options: Core.AllDocsWithKeysOptions):
|
||||
Promise<Core.AllDocsResponse<Content>>;
|
||||
/** Fetch all documents matching the given key range. */
|
||||
allDocs(options: Core.AllDocsWithinRangeOptions):
|
||||
Promise<Core.AllDocsResponse<Content>>;
|
||||
/** Fetch all documents. */
|
||||
allDocs(options?: Core.AllDocsOptions):
|
||||
Promise<Core.AllDocsResponse<Content>>;
|
||||
|
||||
/** Destroy the database */
|
||||
destroy(options: Core.DestroyOptions | void,
|
||||
callback: Core.AnyCallback): void;
|
||||
destroy(options?: Core.DestroyOptions | void): Promise<void>;
|
||||
|
||||
/** Fetch a document */
|
||||
get(docId: Core.DocumentId,
|
||||
options: Core.GetOpenRevisions): Promise<Core.Revision<Content>[]>;
|
||||
get(docId: Core.DocumentId,
|
||||
options: Core.GetOpenRevisions,
|
||||
callback: Core.Callback<any,
|
||||
Core.Revision<Content>[]>): void;
|
||||
get(docId: Core.DocumentId,
|
||||
options: Core.GetOptions
|
||||
): Promise<Core.Document<Content> & Core.GetMeta>;
|
||||
get(docId: Core.DocumentId,
|
||||
options: Core.GetOptions,
|
||||
callback: Core.Callback<any, Core.Document<Content> & Core.GetMeta>
|
||||
): void;
|
||||
get(docId: Core.DocumentId,
|
||||
options: void,
|
||||
callback: Core.Callback<any, Core.Document<Content>>): void;
|
||||
get(docId: Core.DocumentId): Promise<Core.Document<Content>>;
|
||||
|
||||
/** Create a new document without providing an id.
|
||||
*
|
||||
* You should prefer put() to post(), because when you post(), you are
|
||||
* missing an opportunity to use allDocs() to sort documents by _id
|
||||
* (because your _ids are random).
|
||||
*
|
||||
* @see {@link https://pouchdb.com/2014/06/17/12-pro-tips-for-better-code-with-pouchdb.html|PouchDB Pro Tips}
|
||||
* */
|
||||
post(doc: Core.NewDocument<Content>,
|
||||
options: Core.PostOptions | void,
|
||||
callback: Core.Callback<Core.Error, Core.Response>): void;
|
||||
post(doc: Core.NewDocument<Content>,
|
||||
options?: Core.PostOptions): Promise<Core.Response>;
|
||||
|
||||
/** Create a new document or update an existing document.
|
||||
*
|
||||
* If the document already exists, you must specify its revision _rev,
|
||||
* otherwise a conflict will occur.
|
||||
* There are some restrictions on valid property names of the documents.
|
||||
* If you try to store non-JSON data (for instance Date objects) you may
|
||||
* see inconsistent results. */
|
||||
put(doc: Core.Document<Content>,
|
||||
id: Core.DocumentId | void,
|
||||
revision: Core.RevisionId | void,
|
||||
options: Core.PutOptions | void,
|
||||
callback: Core.Callback<Core.Error, Core.Response>): void;
|
||||
put(doc: Core.Document<Content>,
|
||||
id?: Core.DocumentId,
|
||||
revision?: Core.RevisionId,
|
||||
options?: Core.PutOptions): Promise<Core.Response>;
|
||||
|
||||
/** Get database information */
|
||||
info(options: Core.InfoOptions | void,
|
||||
callback: Core.Callback<any, Core.DatabaseInfo>): void;
|
||||
info(options?: Core.InfoOptions): Promise<Core.DatabaseInfo>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-core' {
|
||||
const PouchDb: PouchDB.Static;
|
||||
export = PouchDb;
|
||||
}
|
||||
|
||||
declare var PouchDB: PouchDB.Static;
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-http.d.ts" />
|
||||
|
||||
namespace PouchDBHttpTests {
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
let model: PouchDB.Core.Document<MyModel>;
|
||||
|
||||
let db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'http',
|
||||
});
|
||||
db.get('model').then((result) => model);
|
||||
}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for pouchdb-http v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="../pouchdb-adapter-http/pouchdb-adapter-http.d.ts" />
|
||||
|
||||
declare module 'pouchdb-http' {
|
||||
const PouchDb: PouchDB.Static;
|
||||
export = PouchDb;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path="../pouchdb-mapreduce/pouchdb-mapreduce.d.ts" />
|
||||
|
||||
namespace PouchDBBrowserTests {
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
let model: PouchDB.Core.Document<MyModel>;
|
||||
|
||||
let db = new PouchDB<MyModel>('mydb');
|
||||
db.viewCleanup().catch((error) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for pouchdb-mapreduce v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
export interface Database<Content extends Core.Encodable> {
|
||||
/**
|
||||
* Cleans up any stale map/reduce indexes.
|
||||
*
|
||||
* As design docs are deleted or modified, their associated index
|
||||
* files(in CouchDB) or companion databases (in local PouchDBs) continue
|
||||
* to take up space on disk. viewCleanup() removes these unnecessary
|
||||
* index files.
|
||||
*/
|
||||
viewCleanup(callback: PouchDB.Core.Callback<any,void>): void;
|
||||
viewCleanup(): Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-adapter-mapreduce' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="./pouchdb-node.d.ts" />
|
||||
|
||||
namespace PouchDBBrowserTests {
|
||||
function testConstructor() {
|
||||
type MyModel = { numericProperty: number };
|
||||
let model: PouchDB.Core.Document<MyModel>;
|
||||
|
||||
let db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'http',
|
||||
});
|
||||
db = new PouchDB<MyModel>('myDb', {
|
||||
adapter: 'leveldb',
|
||||
});
|
||||
db.get('model').then((result) => model);
|
||||
db.viewCleanup().catch((error) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for pouchdb-node v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
/// <reference path="../pouchdb-adapter-leveldb/pouchdb-adapter-leveldb.d.ts" />
|
||||
/// <reference path="../pouchdb-adapter-http/pouchdb-adapter-http.d.ts" />
|
||||
/// <reference path="../pouchdb-mapreduce/pouchdb-mapreduce.d.ts" />
|
||||
/// <reference path="../pouchdb-replication/pouchdb-replication.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace Core {
|
||||
interface DatabaseInfo {
|
||||
/** The backend *DOWN adapter being used (MemDOWN, RiakDOWN, …). */
|
||||
backend_adapter?: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-node' {
|
||||
const PouchDb: PouchDB.Static;
|
||||
export = PouchDb;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
/// <reference path="./pouchdb-replication.d.ts" />
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// Type definitions for pouchdb-replication v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../pouchdb-core/pouchdb-core.d.ts" />
|
||||
|
||||
declare namespace PouchDB {
|
||||
namespace Replication {
|
||||
/** @todo When is this present? */
|
||||
interface ReplicationMeta {
|
||||
_replication_id: string;
|
||||
_replication_state: string;
|
||||
_replication_state_time: number;
|
||||
_replication_stats: {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'pouchdb-replication' {
|
||||
const plugin: PouchDB.Plugin;
|
||||
export = plugin;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/// <reference path="./pouchdb.d.ts" />
|
||||
|
||||
namespace PouchDBTests {
|
||||
function isString(someString: string) {
|
||||
}
|
||||
function isNumber(someNumber: number) {
|
||||
}
|
||||
|
||||
function testAllDocs() {
|
||||
const db = new PouchDB<{ foo: number }>();
|
||||
|
||||
db.allDocs().then(({ offset, total_rows, rows }) => {
|
||||
isNumber(offset);
|
||||
isNumber(total_rows);
|
||||
|
||||
rows.forEach(({ id, key, value, doc }) => {
|
||||
isString(id);
|
||||
isString(key);
|
||||
isString(value.rev);
|
||||
|
||||
// check document property
|
||||
isNumber(doc.foo);
|
||||
})
|
||||
});
|
||||
|
||||
db.allDocs({ startkey: "a", endkey: "b" });
|
||||
db.allDocs({ startkey: "a", endkey: "b", inclusive_end: true });
|
||||
db.allDocs({ keys: ["a", "b", "c" ]});
|
||||
db.allDocs({ key: "a" });
|
||||
db.allDocs({
|
||||
attachments: true,
|
||||
binary: true,
|
||||
conflicts: true,
|
||||
descending: true,
|
||||
include_docs: true,
|
||||
limit: 5,
|
||||
skip: 1
|
||||
});
|
||||
}
|
||||
|
||||
function testDestroy() {
|
||||
const db = new PouchDB<{}>();
|
||||
|
||||
db.destroy({}, (error) => {
|
||||
});
|
||||
db.destroy().then(() => {
|
||||
}).catch((error) => {
|
||||
});
|
||||
}
|
||||
|
||||
function testBasics() {
|
||||
type MyModel = { property: 'someProperty '};
|
||||
let model: PouchDB.Core.Document<MyModel>;
|
||||
const id = 'model';
|
||||
|
||||
let db = new PouchDB<MyModel>();
|
||||
db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'fruitdown'
|
||||
});
|
||||
db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'http'
|
||||
});
|
||||
db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'idb'
|
||||
});
|
||||
db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'leveldb'
|
||||
});
|
||||
db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'localstorage'
|
||||
});
|
||||
db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'memory'
|
||||
});
|
||||
db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'websql'
|
||||
});
|
||||
db = new PouchDB<MyModel>(null, {
|
||||
adapter: 'websql',
|
||||
size: 100
|
||||
});
|
||||
|
||||
db.post(model).then((result) => {
|
||||
isString(result.id);
|
||||
});
|
||||
db.post(model, null, (error, response) => {
|
||||
});
|
||||
|
||||
db.get(id).then((result) => model = result);
|
||||
db.get(id, null, (error, result) => {
|
||||
});
|
||||
|
||||
db.put(model).then((error) => {
|
||||
});
|
||||
db.put(model, null, null, null, (error) => {
|
||||
});
|
||||
|
||||
db.info().then((info) => {
|
||||
});
|
||||
db.info({ ajax: { cache: true }}, (error, result) => {
|
||||
});
|
||||
|
||||
db.viewCleanup().catch((error) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// Type definitions for pouchdb v5.4.4
|
||||
// Project: https://pouchdb.com/
|
||||
// Definitions by: Andy Brown <https://github.com/AGBrown>, Brian Geppert <https://github.com/geppy>, Frederico Galvão <https://github.com/fredgalvao>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path='../pouchdb-adapter-fruitdown/pouchdb-adapter-fruitdown.d.ts' />
|
||||
/// <reference path='../pouchdb-adapter-http/pouchdb-adapter-http.d.ts' />
|
||||
/// <reference path='../pouchdb-adapter-idb/pouchdb-adapter-idb.d.ts' />
|
||||
/// <reference path='../pouchdb-adapter-leveldb/pouchdb-adapter-leveldb.d.ts' />
|
||||
/// <reference path='../pouchdb-adapter-localstorage/pouchdb-adapter-localstorage.d.ts' />
|
||||
/// <reference path='../pouchdb-adapter-memory/pouchdb-adapter-memory.d.ts' />
|
||||
/// <reference path='../pouchdb-adapter-node-websql/pouchdb-adapter-node-websql.d.ts' />
|
||||
/// <reference path='../pouchdb-adapter-websql/pouchdb-adapter-websql.d.ts' />
|
||||
/// <reference path='../pouchdb-browser/pouchdb-browser.d.ts' />
|
||||
/// <reference path='../pouchdb-core/pouchdb-core.d.ts' />
|
||||
/// <reference path='../pouchdb-http/pouchdb-http.d.ts' />
|
||||
/// <reference path='../pouchdb-mapreduce/pouchdb-mapreduce.d.ts' />
|
||||
/// <reference path='../pouchdb-node/pouchdb-node.d.ts' />
|
||||
/// <reference path='../pouchdb-replication/pouchdb-replication.d.ts' />
|
||||
|
||||
declare module 'pouchdb' {
|
||||
const plugin: PouchDB.Static;
|
||||
export = plugin;
|
||||
}
|
||||
+10
-11
@@ -22,19 +22,18 @@ declare module 'promisify-supertest' {
|
||||
interface SuperTest extends superagent.SuperAgent<Test> {
|
||||
}
|
||||
|
||||
interface Test extends superagent.Request<Test> {
|
||||
interface Test extends superagent.Request {
|
||||
url: string;
|
||||
serverAddress(app: any, path: string): string;
|
||||
expect(status: number, callback?: CallbackHandler): Test;
|
||||
expect(status: number, body: string, callback?: CallbackHandler): Test;
|
||||
expect(body: string, callback?: CallbackHandler): Test;
|
||||
expect(body: RegExp, callback?: CallbackHandler): Test;
|
||||
expect(body: Object, callback?: CallbackHandler): Test;
|
||||
expect(field: string, val: string, callback?: CallbackHandler): Test;
|
||||
expect(field: string, val: RegExp, callback?: CallbackHandler): Test;
|
||||
expect(checker: (res: Response) => any): Test;
|
||||
end(callback: CallbackHandler): Test;
|
||||
end(): Promise<Response>;
|
||||
expect(status: number, callback?: CallbackHandler): this;
|
||||
expect(status: number, body: string, callback?: CallbackHandler): this;
|
||||
expect(body: string, callback?: CallbackHandler): this;
|
||||
expect(body: RegExp, callback?: CallbackHandler): this;
|
||||
expect(body: Object, callback?: CallbackHandler): this;
|
||||
expect(field: string, val: string, callback?: CallbackHandler): this;
|
||||
expect(field: string, val: RegExp, callback?: CallbackHandler): this;
|
||||
expect(checker: (res: Response) => any): this;
|
||||
end(callback?: CallbackHandler): this & Promise<Response>;
|
||||
}
|
||||
|
||||
interface Response extends superagent.Response {
|
||||
|
||||
@@ -23,7 +23,7 @@ function priceFormatter(cell: any, row: any) {
|
||||
render(
|
||||
<BootstrapTable data={products} striped={true} hover={true}>
|
||||
<TableHeaderColumn dataField="id" isKey={true} dataAlign="center" dataSort={true}>Product ID</TableHeaderColumn>
|
||||
<TableHeaderColumn dataField="name" dataSort={true}>Product Name</TableHeaderColumn>
|
||||
<TableHeaderColumn dataField="name" dataSort={true} editable={{ type: 'textarea', rows: 10 }}>Product Name</TableHeaderColumn>
|
||||
<TableHeaderColumn dataField="price" dataFormat={priceFormatter}>Product Price</TableHeaderColumn>
|
||||
</BootstrapTable>,
|
||||
document.getElementById("app")
|
||||
|
||||
+7
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for react-bootstrap-table v2.3.0
|
||||
// Project: https://github.com/AllenFang/react-bootstrap-table
|
||||
// Definitions by: Frank Laub <https://github.com/flaub>, Michael Scharf <https://github.com/scharf>
|
||||
// Definitions by: Frank Laub <https://github.com/flaub>, Michael Scharf <https://github.com/scharf>, Ian Ker-Seymer <https://github.com/ianks>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
@@ -556,6 +556,12 @@ declare module "react-bootstrap-table" {
|
||||
|
||||
*/
|
||||
options?: any;
|
||||
|
||||
/**
|
||||
Configuration for the textarea editable type
|
||||
*/
|
||||
cols?: number;
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export type FilterType = 'TextFilter' | 'RegexFilter' | 'SelectFilter' | 'NumberFilter' | 'DateFilter' | 'CustomFilter';
|
||||
|
||||
+4
-3
@@ -1,4 +1,4 @@
|
||||
// Type definitions for react-datepicker v0.27.0
|
||||
// Type definitions for react-datepicker v0.28.1
|
||||
// Project: https://github.com/Hacker0x01/react-datepicker
|
||||
// Definitions by: Rajab Shakirov <https://github.com/radziksh>, Andrey Balokha <https://github.com/andrewBalekha>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -38,8 +38,9 @@ declare module "react-datepicker" {
|
||||
tabIndex?: number;
|
||||
tetherConstraints?: any[];
|
||||
title?: string;
|
||||
todayButton?: string;
|
||||
todayButton?: string;
|
||||
fixedHeight?: boolean;
|
||||
}
|
||||
let ReactDatePicker: __React.ClassicComponentClass<ReactDatePicker>;
|
||||
export = ReactDatePicker;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ import DropTarget = ReactDnd.DropTarget;
|
||||
import DragLayer = ReactDnd.DragLayer;
|
||||
import DragDropContext = ReactDnd.DragDropContext;
|
||||
import HTML5Backend, { getEmptyImage } from 'react-dnd-html5-backend';
|
||||
import TestBackend = require('react-dnd/modules/backends/Test');
|
||||
|
||||
// Game Component
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -285,7 +283,6 @@ namespace Board {
|
||||
}
|
||||
|
||||
export var createWithHTMLBackend = React.createFactory(DragDropContext(HTML5Backend)(Board));
|
||||
export var createWithTestBackend = React.createFactory(DragDropContext(TestBackend)(Board));
|
||||
}
|
||||
|
||||
// Render the Board Component
|
||||
@@ -294,8 +291,3 @@ namespace Board {
|
||||
Board.createWithHTMLBackend({
|
||||
knightPosition: [0, 0]
|
||||
});
|
||||
|
||||
|
||||
Board.createWithTestBackend({
|
||||
knightPosition: [0, 0]
|
||||
});
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// Type definitions for React DnD HTML 5 Backend v2.0.0
|
||||
// Project: https://github.com/gaearon/react-dnd
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path='./react-dnd.d.ts' />
|
||||
|
||||
declare module "react-dnd-html5-backend" {
|
||||
export namespace NativeTypes {
|
||||
export const FILE: string;
|
||||
export const URL: string;
|
||||
export const TEXT: string;
|
||||
}
|
||||
export function getEmptyImage(): any; // Image
|
||||
export default class HTML5Backend implements __ReactDnd.Backend { }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for React DnD HTML 5 Backend v2.0.0
|
||||
// Project: https://github.com/gaearon/react-dnd
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path='./react-dnd.d.ts' />
|
||||
|
||||
declare module "react-dnd-test-backend" {
|
||||
class TestBackend {
|
||||
setup(): void;
|
||||
teardown(): void;
|
||||
connectDragSource(): void;
|
||||
connectDropTarget(): void;
|
||||
simulateBeginDrag(sourceIds: __ReactDnd.Identifier[], options?: {}): void;
|
||||
simulatePublishDragSource(): void;
|
||||
simulateHover(targetIds: __ReactDnd.Identifier[], options?: {}): void;
|
||||
simulateDrop(): void;
|
||||
simulateEndDrag(): void;
|
||||
}
|
||||
|
||||
export { TestBackend as default };
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
///<reference path="react-dnd.d.ts" />
|
||||
///<reference path="react-dnd-html5-backend.d.ts" />
|
||||
///<reference path="react-dnd-test-backend.d.ts" />
|
||||
"use strict";
|
||||
|
||||
// Test adapted from the ReactDnD chess game tutorial:
|
||||
@@ -13,8 +15,8 @@ import DragSource = ReactDnd.DragSource;
|
||||
import DropTarget = ReactDnd.DropTarget;
|
||||
import DragLayer = ReactDnd.DragLayer;
|
||||
import DragDropContext = ReactDnd.DragDropContext;
|
||||
import HTML5Backend, { getEmptyImage } from 'react-dnd/modules/backends/HTML5';
|
||||
import TestBackend = require('react-dnd/modules/backends/Test');
|
||||
import HTML5Backend, { getEmptyImage, NativeTypes } from "react-dnd-html5-backend";
|
||||
import TestBackend from "react-dnd-test-backend";
|
||||
|
||||
// Game Component
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -199,6 +201,7 @@ namespace BoardSquare {
|
||||
}
|
||||
|
||||
export var DndBoardSquare = DropTarget(ItemTypes.KNIGHT, boardSquareTarget, boardSquareCollect)(BoardSquare);
|
||||
export var fileDropTarget = DropTarget(NativeTypes.FILE, boardSquareTarget, boardSquareCollect)(BoardSquare);
|
||||
export var create = React.createFactory(DndBoardSquare);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user