mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-30 02:01:46 +00:00
Merge remote-tracking branch 'refs/remotes/DefinitelyTyped/master'
This commit is contained in:
@@ -101,4 +101,10 @@ function TestGlobalApiAndChannels() {
|
||||
|
||||
Backbone.Radio.reply('auth', 'authenticate', onStart);
|
||||
Backbone.Radio.request('auth', 'authenticate', 'pelle', 42);
|
||||
}
|
||||
}
|
||||
|
||||
import Radio = require('backbone.radio');
|
||||
function TestImport() {
|
||||
var channel: Backbone.Radio.Channel = Radio.channel('channel-name');
|
||||
channel.command('show:view');
|
||||
}
|
||||
|
||||
Vendored
+6
@@ -90,3 +90,9 @@ declare namespace Backbone {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'backbone.radio' {
|
||||
import Backbone = require('backbone');
|
||||
|
||||
export = Backbone.Radio;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/// <reference path="./bezier-js.d.ts" />
|
||||
|
||||
function test() {
|
||||
|
||||
var bezierjs: typeof BezierJs;
|
||||
|
||||
var bezier = new bezierjs.Bezier([1,2,3,4]);
|
||||
var cap = new bezierjs.BezierCap([]);
|
||||
var point: BezierJs.Point = { x: 0, y: 0 };
|
||||
var utils = bezier.getUtils();
|
||||
var line: BezierJs.Line = { p1: { x:0, y: 0}, p2: {x:1, y: 1}};
|
||||
var abc: BezierJs.ABC = { A: null, B: null, C: null };
|
||||
var arc: BezierJs.Arc = { e: 0, s: 0, x: 0, y: 0, r: 1 };
|
||||
var bbox: BezierJs.BBox = bezier.bbox();
|
||||
var closest: BezierJs.Closest = { mdist: 1, mpos: 0 };
|
||||
var inflection: BezierJs.Inflection = { values: null, x: [0], y: [0], z:[0] };
|
||||
var minmax: BezierJs.MinMax = { min: 0, max: 0 };
|
||||
var offset: BezierJs.Offset = { x: 0, y: 0, c: point, n: point };
|
||||
var pair: BezierJs.Pair = { left: bezier, right: bezier };
|
||||
var poly: BezierJs.PolyBezier = bezier.outline(1);
|
||||
var projection: BezierJs.Projection = { x: 0, y: 0, t: 9, d: 4 };
|
||||
var shape: BezierJs.Shape = { startcap: cap, endcap: cap, forward: bezier, back: bezier, bbox: bbox };
|
||||
var split: BezierJs.Split = { left: bezier, right: bezier, span: [point] };
|
||||
|
||||
bezier.arcs();
|
||||
bezier.clockwise;
|
||||
bezier.compute(.5);
|
||||
bezier.computedirection();
|
||||
bezier.curveintersects([bezier], [bezier]);
|
||||
bezier.derivative(0);
|
||||
bezier.get(1);
|
||||
bezier.getLUT()[0].x;
|
||||
bezier.hull(0);
|
||||
bezier.inflections().values;
|
||||
bezier.intersects(bezier);
|
||||
bezier.length();
|
||||
bezier.lineIntersects(line);
|
||||
bezier.normal(0);
|
||||
bezier.offset(1,2);
|
||||
bezier.on(point, 0);
|
||||
bezier.order = 5;
|
||||
bezier.outlineshapes(1,3);
|
||||
bezier.overlaps(bezier);
|
||||
bezier.point(9);
|
||||
bezier.project(point);
|
||||
bezier.raise();
|
||||
bezier.reduce();
|
||||
bezier.scale(4);
|
||||
bezier.selfintersects();
|
||||
bezier.simple();
|
||||
bezier.split(0, 1);
|
||||
bezier.toSVG();
|
||||
bezier.update();
|
||||
|
||||
cap.virtual = true;
|
||||
|
||||
poly.addCurve(bezier);
|
||||
poly.bbox();
|
||||
poly.curve(7);
|
||||
poly.curves[0]._3d;
|
||||
poly.length();
|
||||
poly.offset(9).points[0].y;
|
||||
poly.points[0];
|
||||
|
||||
utils.abcratio(0, 1);
|
||||
utils.align([point], line);
|
||||
utils.angle(point, point, point);
|
||||
utils.approximately(5, 7, .001);
|
||||
utils.arcfn(1, function(){});
|
||||
utils.bboxoverlap(bbox, bbox);
|
||||
utils.between(0, 0, 1);
|
||||
utils.closest([point], point);
|
||||
utils.copy({});
|
||||
utils.dist(point, point);
|
||||
utils.droots([9]);
|
||||
utils.expandbox(bbox, bbox);
|
||||
utils.findbbox([bezier]);
|
||||
utils.getccenter(point, point, point);
|
||||
utils.getminmax(bezier, 'x', [0]);
|
||||
utils.length(function(){});
|
||||
utils.lerp(1, point, point);
|
||||
utils.lli(offset, offset);
|
||||
utils.lli4(point, point, point, point);
|
||||
utils.lli8(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
utils.makeline(point, point);
|
||||
utils.makeshape(bezier, bezier);
|
||||
utils.map(0, 0, 0, 0, 0);
|
||||
utils.pairiteration(bezier, bezier);
|
||||
utils.pointsToString([point]);
|
||||
utils.projectionratio(0, 0);
|
||||
utils.roots([point], line);
|
||||
utils.round(.999, .001);
|
||||
utils.shapeintersections(shape, bbox, shape, bbox);
|
||||
|
||||
}
|
||||
Vendored
+197
@@ -0,0 +1,197 @@
|
||||
// Type definitions for Bezier.js
|
||||
// Project: https://github.com/Pomax/bezierjs
|
||||
// Definitions by: Dan Marshall <https://github.com/danmarshall>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
declare module BezierJs {
|
||||
interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
z?: number;
|
||||
}
|
||||
interface Projection extends Point {
|
||||
t?: number;
|
||||
d?: number;
|
||||
}
|
||||
interface Inflection {
|
||||
x: number[];
|
||||
y: number[];
|
||||
z?: number[];
|
||||
values: number[];
|
||||
}
|
||||
interface Offset extends Point {
|
||||
c: Point;
|
||||
n: Point;
|
||||
}
|
||||
interface Pair {
|
||||
left: Bezier;
|
||||
right: Bezier;
|
||||
}
|
||||
interface Split extends Pair {
|
||||
span: Point[];
|
||||
_t1?: number;
|
||||
_t2?: number;
|
||||
}
|
||||
interface MinMax {
|
||||
min: number;
|
||||
mid?: number;
|
||||
max: number;
|
||||
size?: number;
|
||||
}
|
||||
interface BBox {
|
||||
x: MinMax;
|
||||
y: MinMax;
|
||||
z?: MinMax;
|
||||
}
|
||||
interface Line {
|
||||
p1: Point;
|
||||
p2: Point;
|
||||
}
|
||||
interface Arc extends Point {
|
||||
e: number;
|
||||
r: number;
|
||||
s: number;
|
||||
}
|
||||
interface Shape {
|
||||
startcap: BezierCap;
|
||||
forward: Bezier;
|
||||
back: Bezier;
|
||||
endcap: BezierCap;
|
||||
bbox: BBox;
|
||||
}
|
||||
interface ABC {
|
||||
A: Point;
|
||||
B: Point;
|
||||
C: Point;
|
||||
}
|
||||
interface Closest {
|
||||
mdist: number;
|
||||
mpos: number;
|
||||
}
|
||||
/**
|
||||
* Bezier curve constructor. The constructor argument can be one of three things:
|
||||
*
|
||||
* 1. array/4 of {x:..., y:..., z:...}, z optional
|
||||
* 2. numerical array/8 ordered x1,y1,x2,y2,x3,y3,x4,y4
|
||||
* 3. numerical array/12 ordered x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4
|
||||
*
|
||||
*/
|
||||
class Bezier {
|
||||
clockwise: boolean;
|
||||
private _linear;
|
||||
_3d: boolean;
|
||||
_t1: number;
|
||||
_t2: number;
|
||||
_lut: Point[];
|
||||
dpoints: Point[][];
|
||||
order: number;
|
||||
points: Point[];
|
||||
dims: string[];
|
||||
dimlen: number;
|
||||
constructor(points: Point[]);
|
||||
constructor(coords: number[]);
|
||||
constructor(n1: number, n2: number, n3: number, n4: number, n5: number, n6: number, n7: number, n8: number);
|
||||
constructor(p1: Point, p2: Point, p3: Point, p4?: Point);
|
||||
static fromSVG(svgString: string): Bezier;
|
||||
static getABC(n: number, S: Point, B: Point, E: Point, t: number): ABC;
|
||||
static quadraticFromPoints(p1: Point, p2: Point, p3: Point, t: number): Bezier;
|
||||
static cubicFromPoints(S: Point, B: Point, E: Point, t: number, d1: number): Bezier;
|
||||
static getUtils(): typeof utils;
|
||||
getUtils(): typeof utils;
|
||||
valueOf(): string;
|
||||
toString(): string;
|
||||
toSVG(): string;
|
||||
update(): void;
|
||||
computedirection(): void;
|
||||
length(): number;
|
||||
getLUT(steps?: number): Point[];
|
||||
on(point: Point, error: number): number;
|
||||
project(point: Point): Projection;
|
||||
get(t: number): Point;
|
||||
point(idx: number): Point;
|
||||
compute(t: number): Point;
|
||||
raise(): Bezier;
|
||||
derivative(t: number): Point;
|
||||
inflections(): number[];
|
||||
normal(t: number): Point;
|
||||
private __normal2(t);
|
||||
private __normal3(t);
|
||||
private __normal(t);
|
||||
hull(t: number): Point[];
|
||||
split(t1: number, t2?: number): Bezier | Split;
|
||||
extrema(): Inflection;
|
||||
bbox(): BBox;
|
||||
overlaps(curve: Bezier): boolean;
|
||||
offset(t: number, d?: number): Offset | Bezier[];
|
||||
simple(): boolean;
|
||||
reduce(): any[];
|
||||
scale(d: Function): Bezier;
|
||||
scale(d: number): Bezier;
|
||||
outline(d1: number, d2?: number, d3?: number, d4?: number): PolyBezier;
|
||||
outlineshapes(d1: number, d2: number): Shape[];
|
||||
intersects(curve: Bezier): string[] | number[];
|
||||
intersects(curve: Line): string[] | number[];
|
||||
lineIntersects(line: Line): number[];
|
||||
selfintersects(): string[];
|
||||
curveintersects(c1: Bezier[], c2: Bezier[]): string[];
|
||||
arcs(errorThreshold?: number): Arc[];
|
||||
private _error(pc, np1, s, e);
|
||||
private _iterate(errorThreshold, circles);
|
||||
}
|
||||
class BezierCap extends Bezier {
|
||||
virtual: boolean;
|
||||
}
|
||||
}
|
||||
declare module BezierJs.utils {
|
||||
var Tvalues: number[];
|
||||
var Cvalues: number[];
|
||||
function arcfn(t: number, derivativeFn: Function): number;
|
||||
function between(v: number, m: number, M: number): boolean;
|
||||
function approximately(a: number, b: number, precision?: number): boolean;
|
||||
function length(derivativeFn: Function): number;
|
||||
function map(v: number, ds: number, de: number, ts: number, te: number): number;
|
||||
function lerp(r: number, v1: Point, v2: Point): Point;
|
||||
function pointToString(p: Point): string;
|
||||
function pointsToString(points: Point[]): string;
|
||||
function copy(obj: Object): any;
|
||||
function angle(o: Point, v1: Point, v2: Point): number;
|
||||
function round(v: number, d: number): number;
|
||||
function dist(p1: Point, p2: Point): number;
|
||||
function closest(LUT: Point[], point: Point): Closest;
|
||||
function abcratio(t: number, n: number): number;
|
||||
function projectionratio(t: number, n: number): number;
|
||||
function lli8(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): Point;
|
||||
function lli4(p1: Point, p2: Point, p3: Point, p4: Point): Point;
|
||||
function lli(v1: Offset, v2: Offset): Point;
|
||||
function makeline(p1: Point, p2: Point): Bezier;
|
||||
function findbbox(sections: Bezier[]): BBox;
|
||||
function shapeintersections(s1: Shape, bbox1: BBox, s2: Shape, bbox2: BBox): string[][] | number[][];
|
||||
function makeshape(forward: Bezier, back: Bezier): Shape;
|
||||
function getminmax(curve: Bezier, d: string, list: number[]): MinMax;
|
||||
function align(points: Point[], line: Line): Point[];
|
||||
function roots(points: Point[], line: Line): number[];
|
||||
function droots(p: number[]): number[];
|
||||
function inflections(points: Point[]): number[];
|
||||
function bboxoverlap(b1: BBox, b2: BBox): boolean;
|
||||
function expandbox(bbox: BBox, _bbox: BBox): void;
|
||||
function pairiteration(c1: Bezier, c2: Bezier): string[];
|
||||
function getccenter(p1: Point, p2: Point, p3: Point): Arc;
|
||||
}
|
||||
declare module BezierJs {
|
||||
/**
|
||||
* Poly Bezier
|
||||
* @param {[type]} curves [description]
|
||||
*/
|
||||
class PolyBezier {
|
||||
curves: Bezier[];
|
||||
private _3d;
|
||||
points: Point[];
|
||||
constructor(curves: Bezier[]);
|
||||
valueOf(): string;
|
||||
toString(): string;
|
||||
addCurve(curve: Bezier): void;
|
||||
length(): number;
|
||||
curve(idx: number): Bezier;
|
||||
bbox(): BBox;
|
||||
offset(d: number): PolyBezier;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="./browser-sync.d.ts"/>
|
||||
import browserSync = require("browser-sync");
|
||||
import * as browserSync from "browser-sync";
|
||||
|
||||
(() => {
|
||||
//make sure that the interfaces are correctly exposed
|
||||
|
||||
Vendored
+19
-8
@@ -8,10 +8,10 @@
|
||||
/// <reference path="../micromatch/micromatch.d.ts" />
|
||||
|
||||
declare module "browser-sync" {
|
||||
import chokidar = require("chokidar");
|
||||
import fs = require("fs");
|
||||
import http = require("http");
|
||||
import mm = require("micromatch");
|
||||
import * as chokidar from "chokidar";
|
||||
import * as fs from "fs";
|
||||
import * as http from "http";
|
||||
import * as mm from "micromatch";
|
||||
|
||||
namespace browserSync {
|
||||
interface Options {
|
||||
@@ -23,14 +23,14 @@ declare module "browser-sync" {
|
||||
* weinre.port - Default: 8080
|
||||
* Note: requires at least version 2.0.0
|
||||
*/
|
||||
ui?: UIOptions;
|
||||
ui?: UIOptions | boolean;
|
||||
/**
|
||||
* Browsersync can watch your files as you work. Changes you make will either be injected into the page (CSS
|
||||
* & images) or will cause all browsers to do a full-page refresh. See anymatch for more information on glob
|
||||
* patterns.
|
||||
* Default: false
|
||||
*/
|
||||
files?: string | string[];
|
||||
files?: string | (string | FileCallback)[];
|
||||
/**
|
||||
* File watching options that get passed along to Chokidar. Check their docs for available options
|
||||
* Default: undefined
|
||||
@@ -245,7 +245,7 @@ declare module "browser-sync" {
|
||||
* Note: requires at least version 1.6.2
|
||||
*/
|
||||
socket?: SocketOptions;
|
||||
middleware?: MiddlewareHandler | MiddlewareHandler[];
|
||||
middleware?: MiddlewareHandler | PerRouteMiddleware | (MiddlewareHandler | PerRouteMiddleware)[];
|
||||
}
|
||||
|
||||
interface Hash<T> {
|
||||
@@ -261,6 +261,12 @@ declare module "browser-sync" {
|
||||
};
|
||||
}
|
||||
|
||||
interface FileCallback {
|
||||
match?: string | string[];
|
||||
fn: (event: string, file: string) => any;
|
||||
options?: chokidar.WatchOptions;
|
||||
}
|
||||
|
||||
interface ServerOptions {
|
||||
/** set base directory */
|
||||
baseDir?: string | string[];
|
||||
@@ -274,7 +280,7 @@ declare module "browser-sync" {
|
||||
*/
|
||||
routes?: Hash<string>;
|
||||
/** configure custom middleware */
|
||||
middleware?: MiddlewareHandler[];
|
||||
middleware?: (MiddlewareHandler | PerRouteMiddleware)[];
|
||||
}
|
||||
|
||||
interface ProxyOptions {
|
||||
@@ -289,6 +295,11 @@ declare module "browser-sync" {
|
||||
(req: http.ServerRequest, res: http.ServerResponse, next: Function): any;
|
||||
}
|
||||
|
||||
interface PerRouteMiddleware {
|
||||
route: string;
|
||||
handle: MiddlewareHandler;
|
||||
}
|
||||
|
||||
interface GhostOptions {
|
||||
clicks?: boolean;
|
||||
scroll?: boolean;
|
||||
|
||||
@@ -500,3 +500,5 @@ s = s.unescapeHTML();
|
||||
// #############################################################################################
|
||||
|
||||
promiseOfVoid = delay(i);
|
||||
|
||||
console.log('core-js version number:', core.version);
|
||||
|
||||
Vendored
+2
@@ -1266,6 +1266,8 @@ interface String {
|
||||
declare function delay(msec: number): Promise<void>;
|
||||
|
||||
declare namespace core {
|
||||
var version: string;
|
||||
|
||||
namespace Reflect {
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>): any;
|
||||
|
||||
@@ -0,0 +1,605 @@
|
||||
/// <reference path="enzyme-1.2.0.d.ts" />
|
||||
/// <reference path="../react/react.d.ts"/>
|
||||
|
||||
import { shallow, mount, render, describeWithDOM, spyLifecycle } from "enzyme";
|
||||
import * as React from "react";
|
||||
import {Component, ReactElement, HTMLAttributes} from "react";
|
||||
import {ShallowWrapper, ReactWrapper, CheerioWrapper} from "enzyme";
|
||||
|
||||
|
||||
// Help classes/interfaces
|
||||
interface MyComponentProps {
|
||||
propsProperty: any;
|
||||
numberProp?: number;
|
||||
}
|
||||
|
||||
interface StatelessProps {
|
||||
stateless: any;
|
||||
}
|
||||
|
||||
interface MyComponentState {
|
||||
stateProperty: any;
|
||||
}
|
||||
|
||||
class MyComponent extends Component<MyComponentProps, MyComponentState> {
|
||||
setState(...args: any[]) {
|
||||
}
|
||||
}
|
||||
|
||||
const MyStatelessComponent = (props: StatelessProps) => <span />;
|
||||
|
||||
// API
|
||||
namespace SpyLifecycleTest {
|
||||
spyLifecycle(MyComponent);
|
||||
}
|
||||
|
||||
// ShallowWrapper
|
||||
namespace ShallowWrapperTest {
|
||||
var shallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState> =
|
||||
shallow<MyComponentProps, MyComponentState>(<MyComponent propsProperty="value"/>);
|
||||
|
||||
var reactElement: ReactElement<any>,
|
||||
objectVal: Object,
|
||||
boolVal: Boolean,
|
||||
stringVal: String,
|
||||
elementWrapper: ShallowWrapper<HTMLAttributes, {}>
|
||||
|
||||
function test_find() {
|
||||
elementWrapper = shallowWrapper.find('.selector');
|
||||
shallowWrapper = shallowWrapper.find(MyComponent);
|
||||
shallowWrapper.find(MyStatelessComponent).props().stateless;
|
||||
shallowWrapper.find(MyStatelessComponent).shallow();
|
||||
}
|
||||
|
||||
function test_findWhere() {
|
||||
shallowWrapper =
|
||||
shallowWrapper.findWhere((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
|
||||
function test_filter() {
|
||||
elementWrapper = shallowWrapper.filter('.selector');
|
||||
shallowWrapper = shallowWrapper.filter(MyComponent).shallow();
|
||||
}
|
||||
|
||||
function test_filterWhere() {
|
||||
shallowWrapper =
|
||||
shallowWrapper.filterWhere(wrapper => {
|
||||
wrapper.props().propsProperty;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function test_contains() {
|
||||
boolVal = shallowWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_hasClass() {
|
||||
boolVal = shallowWrapper.find('.my-button').hasClass('disabled');
|
||||
}
|
||||
|
||||
function test_is() {
|
||||
boolVal = shallowWrapper.is('.some-class');
|
||||
}
|
||||
|
||||
function test_not() {
|
||||
elementWrapper = shallowWrapper.find('.foo').not('.bar');
|
||||
}
|
||||
|
||||
function test_children() {
|
||||
shallowWrapper = shallowWrapper.children();
|
||||
shallowWrapper.children(MyStatelessComponent).props().stateless;
|
||||
}
|
||||
|
||||
function test_parents() {
|
||||
shallowWrapper = shallowWrapper.parents();
|
||||
}
|
||||
|
||||
function test_parent() {
|
||||
shallowWrapper = shallowWrapper.parent();
|
||||
}
|
||||
|
||||
function test_closest() {
|
||||
elementWrapper = shallowWrapper.closest('.selector');
|
||||
shallowWrapper = shallowWrapper.closest(MyComponent);
|
||||
}
|
||||
|
||||
function test_shallow() {
|
||||
shallowWrapper = shallowWrapper.shallow();
|
||||
}
|
||||
|
||||
function test_unmount() {
|
||||
shallowWrapper = shallowWrapper.unmount();
|
||||
}
|
||||
|
||||
function test_render() {
|
||||
var cheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState> = shallowWrapper.render();
|
||||
}
|
||||
|
||||
function test_text() {
|
||||
stringVal = shallowWrapper.text();
|
||||
}
|
||||
|
||||
|
||||
function test_html() {
|
||||
stringVal = shallowWrapper.html();
|
||||
}
|
||||
|
||||
function test_get() {
|
||||
reactElement = shallowWrapper.get(1);
|
||||
}
|
||||
|
||||
function test_at() {
|
||||
shallowWrapper = shallowWrapper.at(1);
|
||||
}
|
||||
|
||||
function test_first() {
|
||||
shallowWrapper = shallowWrapper.first();
|
||||
}
|
||||
|
||||
function test_last() {
|
||||
shallowWrapper = shallowWrapper.last();
|
||||
}
|
||||
|
||||
function test_state() {
|
||||
shallowWrapper.state();
|
||||
shallowWrapper.state('key');
|
||||
}
|
||||
|
||||
function test_props() {
|
||||
objectVal = shallowWrapper.props();
|
||||
}
|
||||
|
||||
function test_prop() {
|
||||
shallowWrapper.prop('key');
|
||||
}
|
||||
|
||||
|
||||
function test_simulate(...args: any[]) {
|
||||
shallowWrapper.simulate('click');
|
||||
shallowWrapper.simulate('click', args);
|
||||
}
|
||||
|
||||
function test_setState() {
|
||||
shallowWrapper = shallowWrapper.setState({stateProperty: 'state'});
|
||||
}
|
||||
|
||||
function test_setProps() {
|
||||
shallowWrapper = shallowWrapper.setProps({propsProperty: 'foo'});
|
||||
}
|
||||
|
||||
function test_setContext() {
|
||||
shallowWrapper = shallowWrapper.setContext({name: 'baz'});
|
||||
}
|
||||
|
||||
function test_instance() {
|
||||
var myComponent: MyComponent = shallowWrapper.instance();
|
||||
}
|
||||
|
||||
function test_update() {
|
||||
shallowWrapper = shallowWrapper.update();
|
||||
}
|
||||
|
||||
function test_debug() {
|
||||
stringVal = shallowWrapper.debug();
|
||||
}
|
||||
|
||||
function test_type() {
|
||||
var stringOrFunction: String|Function = shallowWrapper.type();
|
||||
}
|
||||
|
||||
function test_forEach() {
|
||||
shallowWrapper =
|
||||
shallowWrapper.forEach(wrapper => wrapper.shallow().props().propsProperty);
|
||||
}
|
||||
|
||||
function test_map() {
|
||||
var arrayNumbers: Array<Number> =
|
||||
shallowWrapper.map(wrapper => wrapper.props().numberProp);
|
||||
}
|
||||
|
||||
function test_reduce() {
|
||||
const total: number[] =
|
||||
shallowWrapper.reduce(
|
||||
(amount: number, n: ShallowWrapper<MyComponentProps, MyComponentState>) => amount + n.props().numberProp
|
||||
);
|
||||
}
|
||||
|
||||
function test_reduceRight() {
|
||||
const total: number[] =
|
||||
shallowWrapper.reduceRight<number>(
|
||||
(amount: number, n: ShallowWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
|
||||
);
|
||||
}
|
||||
|
||||
function test_some() {
|
||||
boolVal = shallowWrapper.some('.selector');
|
||||
boolVal = shallowWrapper.some(MyComponent);
|
||||
}
|
||||
|
||||
function test_someWhere() {
|
||||
boolVal = shallowWrapper.someWhere((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
|
||||
function test_every() {
|
||||
boolVal = shallowWrapper.every('.selector');
|
||||
boolVal = shallowWrapper.every(MyComponent);
|
||||
}
|
||||
|
||||
function test_everyWhere() {
|
||||
boolVal = shallowWrapper.everyWhere((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ReactWrapper
|
||||
namespace ReactWrapperTest {
|
||||
var reactWrapper: ReactWrapper<MyComponentProps, MyComponentState> =
|
||||
mount<MyComponentProps, MyComponentState>(<MyComponent propsProperty="value"/>);
|
||||
|
||||
var reactElement: ReactElement<any>,
|
||||
objectVal: Object,
|
||||
boolVal: Boolean,
|
||||
stringVal: String,
|
||||
elementWrapper: ReactWrapper<HTMLAttributes, {}>
|
||||
|
||||
function test_unmount() {
|
||||
reactWrapper = reactWrapper.unmount();
|
||||
}
|
||||
|
||||
function test_mount() {
|
||||
reactWrapper = reactWrapper.mount();
|
||||
}
|
||||
|
||||
function test_find() {
|
||||
elementWrapper = reactWrapper.find('.selector');
|
||||
reactWrapper = reactWrapper.find(MyComponent);
|
||||
reactWrapper.find(MyStatelessComponent).props().stateless;
|
||||
}
|
||||
|
||||
function test_findWhere() {
|
||||
reactWrapper =
|
||||
reactWrapper.findWhere((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
|
||||
function test_filter() {
|
||||
elementWrapper = reactWrapper.filter('.selector');
|
||||
reactWrapper = reactWrapper.filter(MyComponent);
|
||||
}
|
||||
|
||||
function test_filterWhere() {
|
||||
reactWrapper =
|
||||
reactWrapper.filterWhere(wrapper => {
|
||||
wrapper.props().propsProperty;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function test_contains() {
|
||||
boolVal = reactWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_hasClass() {
|
||||
boolVal = reactWrapper.find('.my-button').hasClass('disabled');
|
||||
}
|
||||
|
||||
function test_is() {
|
||||
boolVal = reactWrapper.is('.some-class');
|
||||
}
|
||||
|
||||
function test_not() {
|
||||
elementWrapper = reactWrapper.find('.foo').not('.bar');
|
||||
}
|
||||
|
||||
function test_children() {
|
||||
reactWrapper = reactWrapper.children();
|
||||
}
|
||||
|
||||
function test_parents() {
|
||||
reactWrapper = reactWrapper.parents();
|
||||
}
|
||||
|
||||
function test_parent() {
|
||||
reactWrapper = reactWrapper.parent();
|
||||
}
|
||||
|
||||
function test_closest() {
|
||||
elementWrapper = reactWrapper.closest('.selector');
|
||||
reactWrapper = reactWrapper.closest(MyComponent);
|
||||
}
|
||||
|
||||
function test_text() {
|
||||
stringVal = reactWrapper.text();
|
||||
}
|
||||
|
||||
function test_html() {
|
||||
stringVal = reactWrapper.html();
|
||||
}
|
||||
|
||||
function test_get() {
|
||||
reactElement = reactWrapper.get(1);
|
||||
}
|
||||
|
||||
function test_at() {
|
||||
reactWrapper = reactWrapper.at(1);
|
||||
}
|
||||
|
||||
function test_first() {
|
||||
reactWrapper = reactWrapper.first();
|
||||
}
|
||||
|
||||
function test_last() {
|
||||
reactWrapper = reactWrapper.last();
|
||||
}
|
||||
|
||||
function test_state() {
|
||||
reactWrapper.state();
|
||||
reactWrapper.state('key');
|
||||
}
|
||||
|
||||
function test_props() {
|
||||
objectVal = reactWrapper.props();
|
||||
}
|
||||
|
||||
function test_prop() {
|
||||
reactWrapper.prop('key');
|
||||
}
|
||||
|
||||
|
||||
function test_simulate(...args: any[]) {
|
||||
reactWrapper.simulate('click');
|
||||
reactWrapper.simulate('click', args);
|
||||
}
|
||||
|
||||
function test_setState() {
|
||||
reactWrapper = reactWrapper.setState({stateProperty: 'state'});
|
||||
}
|
||||
|
||||
function test_setProps() {
|
||||
reactWrapper = reactWrapper.setProps({propsProperty: 'foo'});
|
||||
}
|
||||
|
||||
function test_setContext() {
|
||||
reactWrapper = reactWrapper.setContext({name: 'baz'});
|
||||
}
|
||||
|
||||
function test_instance() {
|
||||
var myComponent: MyComponent = reactWrapper.instance();
|
||||
}
|
||||
|
||||
function test_update() {
|
||||
reactWrapper = reactWrapper.update();
|
||||
}
|
||||
|
||||
function test_debug() {
|
||||
stringVal = reactWrapper.debug();
|
||||
}
|
||||
|
||||
function test_type() {
|
||||
var stringOrFunction: String|Function = reactWrapper.type();
|
||||
}
|
||||
|
||||
function test_forEach() {
|
||||
reactWrapper =
|
||||
reactWrapper.forEach(wrapper => wrapper.props().propsProperty);
|
||||
}
|
||||
|
||||
function test_map() {
|
||||
var arrayNumbers: Array<Number> =
|
||||
reactWrapper.map(wrapper => wrapper.props().numberProp);
|
||||
}
|
||||
|
||||
function test_reduce() {
|
||||
const total: number[] =
|
||||
reactWrapper.reduce<number>(
|
||||
(amount: number, n: ReactWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
|
||||
);
|
||||
}
|
||||
|
||||
function test_reduceRight() {
|
||||
const total: number[] =
|
||||
reactWrapper.reduceRight<number>(
|
||||
(amount: number, n: ReactWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
|
||||
);
|
||||
}
|
||||
|
||||
function test_some() {
|
||||
boolVal = reactWrapper.some('.selector');
|
||||
boolVal = reactWrapper.some(MyComponent);
|
||||
}
|
||||
|
||||
function test_someWhere() {
|
||||
boolVal = reactWrapper.someWhere((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
|
||||
function test_every() {
|
||||
boolVal = reactWrapper.every('.selector');
|
||||
boolVal = reactWrapper.every(MyComponent);
|
||||
}
|
||||
|
||||
function test_everyWhere() {
|
||||
boolVal = reactWrapper.everyWhere((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
}
|
||||
|
||||
// CheerioWrapper
|
||||
namespace CheerioWrapperTest {
|
||||
var cheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState> =
|
||||
render<MyComponentProps, MyComponentState>(<MyComponent propsProperty="value"/>);
|
||||
|
||||
var reactElement: ReactElement<any>,
|
||||
objectVal: Object,
|
||||
boolVal: Boolean,
|
||||
stringVal: String,
|
||||
elementWrapper: CheerioWrapper<HTMLAttributes, {}>
|
||||
|
||||
function test_find() {
|
||||
elementWrapper = cheerioWrapper.find('.selector');
|
||||
cheerioWrapper = cheerioWrapper.find(MyComponent);
|
||||
cheerioWrapper.find(MyStatelessComponent).props().stateless;
|
||||
}
|
||||
|
||||
function test_findWhere() {
|
||||
cheerioWrapper =
|
||||
cheerioWrapper.findWhere((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
|
||||
function test_filter() {
|
||||
elementWrapper = cheerioWrapper.filter('.selector');
|
||||
cheerioWrapper = cheerioWrapper.filter(MyComponent);
|
||||
}
|
||||
|
||||
function test_filterWhere() {
|
||||
cheerioWrapper =
|
||||
cheerioWrapper.filterWhere(wrapper => {
|
||||
wrapper.props().propsProperty;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function test_contains() {
|
||||
boolVal = cheerioWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_hasClass() {
|
||||
boolVal = cheerioWrapper.find('.my-button').hasClass('disabled');
|
||||
}
|
||||
|
||||
function test_is() {
|
||||
boolVal = cheerioWrapper.is('.some-class');
|
||||
}
|
||||
|
||||
function test_not() {
|
||||
elementWrapper = cheerioWrapper.find('.foo').not('.bar');
|
||||
}
|
||||
|
||||
function test_children() {
|
||||
cheerioWrapper = cheerioWrapper.children();
|
||||
}
|
||||
|
||||
function test_parents() {
|
||||
cheerioWrapper = cheerioWrapper.parents();
|
||||
}
|
||||
|
||||
function test_parent() {
|
||||
cheerioWrapper = cheerioWrapper.parent();
|
||||
}
|
||||
|
||||
function test_closest() {
|
||||
elementWrapper = cheerioWrapper.closest('.selector');
|
||||
cheerioWrapper = cheerioWrapper.closest(MyComponent);
|
||||
}
|
||||
|
||||
function test_text() {
|
||||
stringVal = cheerioWrapper.text();
|
||||
}
|
||||
|
||||
function test_html() {
|
||||
stringVal = cheerioWrapper.html();
|
||||
}
|
||||
|
||||
function test_get() {
|
||||
reactElement = cheerioWrapper.get(1);
|
||||
}
|
||||
|
||||
function test_at() {
|
||||
cheerioWrapper = cheerioWrapper.at(1);
|
||||
}
|
||||
|
||||
function test_first() {
|
||||
cheerioWrapper = cheerioWrapper.first();
|
||||
}
|
||||
|
||||
function test_last() {
|
||||
cheerioWrapper = cheerioWrapper.last();
|
||||
}
|
||||
|
||||
function test_state() {
|
||||
cheerioWrapper.state();
|
||||
cheerioWrapper.state('key');
|
||||
}
|
||||
|
||||
function test_props() {
|
||||
objectVal = cheerioWrapper.props();
|
||||
}
|
||||
|
||||
function test_prop() {
|
||||
cheerioWrapper.prop('key');
|
||||
}
|
||||
|
||||
|
||||
function test_simulate(...args: any[]) {
|
||||
cheerioWrapper.simulate('click');
|
||||
cheerioWrapper.simulate('click', args);
|
||||
}
|
||||
|
||||
function test_setState() {
|
||||
cheerioWrapper = cheerioWrapper.setState({stateProperty: 'state'});
|
||||
}
|
||||
|
||||
function test_setProps() {
|
||||
cheerioWrapper = cheerioWrapper.setProps({propsProperty: 'foo'});
|
||||
}
|
||||
|
||||
function test_setContext() {
|
||||
cheerioWrapper = cheerioWrapper.setContext({name: 'baz'});
|
||||
}
|
||||
|
||||
function test_instance() {
|
||||
var myComponent: MyComponent = cheerioWrapper.instance();
|
||||
}
|
||||
|
||||
function test_update() {
|
||||
cheerioWrapper = cheerioWrapper.update();
|
||||
}
|
||||
|
||||
function test_debug() {
|
||||
stringVal = cheerioWrapper.debug();
|
||||
}
|
||||
|
||||
function test_type() {
|
||||
var stringOrFunction: String|Function = cheerioWrapper.type();
|
||||
}
|
||||
|
||||
function test_forEach() {
|
||||
cheerioWrapper =
|
||||
cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>)=> {
|
||||
});
|
||||
}
|
||||
|
||||
function test_map() {
|
||||
var arrayNumbers: Array<Number> =
|
||||
cheerioWrapper.map(wrapper => wrapper.props().numberProp);
|
||||
}
|
||||
|
||||
function test_reduce() {
|
||||
const total: number[] =
|
||||
cheerioWrapper.reduce<number>(
|
||||
(amount: number, n: CheerioWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
|
||||
);
|
||||
}
|
||||
|
||||
function test_reduceRight() {
|
||||
const total: number[] =
|
||||
cheerioWrapper.reduceRight<number>(
|
||||
(amount: number, n: CheerioWrapper<MyComponentProps, MyComponentState>) => amount + n.prop('amount')
|
||||
);
|
||||
}
|
||||
|
||||
function test_some() {
|
||||
boolVal = cheerioWrapper.some('.selector');
|
||||
boolVal = cheerioWrapper.some(MyComponent);
|
||||
}
|
||||
|
||||
function test_someWhere() {
|
||||
boolVal = cheerioWrapper.someWhere((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
|
||||
function test_every() {
|
||||
boolVal = cheerioWrapper.every('.selector');
|
||||
boolVal = cheerioWrapper.every(MyComponent);
|
||||
}
|
||||
|
||||
function test_everyWhere() {
|
||||
boolVal = cheerioWrapper.everyWhere((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => true);
|
||||
}
|
||||
}
|
||||
Vendored
+473
@@ -0,0 +1,473 @@
|
||||
// Type definitions for Enzyme v1.2.0
|
||||
// Project: https://github.com/airbnb/enzyme
|
||||
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="../react/react.d.ts" />
|
||||
|
||||
declare module "enzyme" {
|
||||
|
||||
import {ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes} from "react";
|
||||
|
||||
export class ElementClass extends Component<any, any> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Many methods in Enzyme's API accept a selector as an argument. Selectors in Enzyme can fall into one of the
|
||||
* following three categories:
|
||||
*
|
||||
* 1. A Valid CSS Selector
|
||||
* 2. A React Component Constructor
|
||||
* 3. A React Component's displayName
|
||||
*/
|
||||
export type EnzymeSelector = String | typeof ElementClass;
|
||||
|
||||
interface CommonWrapper<P, S> {
|
||||
/**
|
||||
* Find every node in the render tree that matches the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
find<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
|
||||
find<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
|
||||
find(selector: string): CommonWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Finds every node in the render tree that returns true for the provided predicate function.
|
||||
* @param predicate
|
||||
*/
|
||||
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => Boolean): CommonWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Removes nodes in the current wrapper that do not match the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
filter<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
|
||||
filter<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
|
||||
filter(selector: string): CommonWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with only the nodes of the current wrapper that, when passed into the provided predicate function, return true.
|
||||
* @param predicate
|
||||
*/
|
||||
filterWhere(predicate: (wrapper: this) => Boolean): this;
|
||||
|
||||
/**
|
||||
* Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in.
|
||||
* @param node
|
||||
*/
|
||||
contains(node: ReactElement<any>): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not the current node has a className prop including the passed in class name.
|
||||
* @param className
|
||||
*/
|
||||
hasClass(className: String): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not the current node matches a provided selector.
|
||||
* @param selector
|
||||
*/
|
||||
is(selector: EnzymeSelector): Boolean;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with only the nodes of the current wrapper that don't match the provided selector.
|
||||
* This method is effectively the negation or inverse of filter.
|
||||
* @param selector
|
||||
*/
|
||||
not(selector: EnzymeSelector): this;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
|
||||
* can be provided and it will filter the children by this selector.
|
||||
* @param [selector]
|
||||
*/
|
||||
children<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
|
||||
children<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
|
||||
children(selector: string): CommonWrapper<HTMLAttributes, any>;
|
||||
children(): CommonWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
|
||||
* current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
* @param [selector]
|
||||
*/
|
||||
parents<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
|
||||
parents<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
|
||||
parents(selector: string): CommonWrapper<HTMLAttributes, any>;
|
||||
parents(): CommonWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper with the direct parent of the node in the current wrapper.
|
||||
*/
|
||||
parent(): CommonWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper of the first element that matches the selector by traversing up through the current node's
|
||||
* ancestors in the tree, starting with itself.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
* @param selector
|
||||
*/
|
||||
closest<P2>(component: ComponentClass<P2>): CommonWrapper<P2, any>;
|
||||
closest<P2>(statelessComponent: StatelessComponent<P2>): CommonWrapper<P2, {}>;
|
||||
closest(selector: string): CommonWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Returns a string of the rendered text of the current render tree. This function should be looked at with
|
||||
* skepticism if being used to test what the actual HTML output of the component will be. If that is what you
|
||||
* would like to test, use enzyme's render function instead.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
text(): String;
|
||||
|
||||
/**
|
||||
* Returns a string of the rendered HTML markup of the current render tree.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
html(): String;
|
||||
|
||||
/**
|
||||
* Returns the node at a given index of the current wrapper.
|
||||
* @param index
|
||||
*/
|
||||
get(index: number): ReactElement<any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper around the node at a given index of the current wrapper.
|
||||
* @param index
|
||||
*/
|
||||
at(index: number): this;
|
||||
|
||||
/**
|
||||
* Reduce the set of matched nodes to the first in the set.
|
||||
*/
|
||||
first(): this;
|
||||
|
||||
/**
|
||||
* Reduce the set of matched nodes to the last in the set.
|
||||
*/
|
||||
last(): this;
|
||||
|
||||
/**
|
||||
* Returns the state hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value.
|
||||
* @param [key]
|
||||
*/
|
||||
state(key?: String): any;
|
||||
|
||||
/**
|
||||
* Returns the props hash for the current node of the wrapper.
|
||||
*
|
||||
* NOTE: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
props(): P;
|
||||
|
||||
/**
|
||||
* Returns the prop value for the node of the current wrapper with the provided key.
|
||||
*
|
||||
* NOTE: can only be called on a wrapper of a single node.
|
||||
* @param key
|
||||
*/
|
||||
prop(key: String): any;
|
||||
|
||||
/**
|
||||
* Simulate events.
|
||||
* Returns itself.
|
||||
* @param event
|
||||
* @param args?
|
||||
*/
|
||||
simulate(event: string, ...args: any[]): this;
|
||||
|
||||
/**
|
||||
* A method to invoke setState() on the root component instance similar to how you might in the definition of
|
||||
* the component, and re-renders. This method is useful for testing your component in hard to achieve states,
|
||||
* however should be used sparingly. If possible, you should utilize your component's external API in order to
|
||||
* get it into whatever state you want to test, in order to be as accurate of a test as possible. This is not
|
||||
* always practical, however.
|
||||
* Returns itself.
|
||||
*
|
||||
* NOTE: can only be called on a wrapper instance that is also the root instance.
|
||||
* @param state
|
||||
*/
|
||||
setState(state: S): this;
|
||||
|
||||
/**
|
||||
* A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test
|
||||
* how the component behaves over time with changing props. Calling this, for instance, will call the
|
||||
* componentWillReceiveProps lifecycle method.
|
||||
*
|
||||
* Similar to setState, this method accepts a props object and will merge it in with the already existing props.
|
||||
* Returns itself.
|
||||
*
|
||||
* NOTE: can only be called on a wrapper instance that is also the root instance.
|
||||
* @param state
|
||||
*/
|
||||
setProps(props: P): this;
|
||||
|
||||
/**
|
||||
* A method that sets the context of the root component, and re-renders. Useful for when you are wanting to
|
||||
* test how the component behaves over time with changing contexts.
|
||||
* Returns itself.
|
||||
*
|
||||
* NOTE: can only be called on a wrapper instance that is also the root instance.
|
||||
* @param state
|
||||
*/
|
||||
setContext(context: Object): this;
|
||||
|
||||
/**
|
||||
* Gets the instance of the component being rendered as the root node passed into shallow().
|
||||
*
|
||||
* NOTE: can only be called on a wrapper instance that is also the root instance.
|
||||
*/
|
||||
instance(): Component<P, S>;
|
||||
|
||||
/**
|
||||
* Forces a re-render. Useful to run before checking the render output if something external may be updating
|
||||
* the state of the component somewhere.
|
||||
* Returns itself.
|
||||
*
|
||||
* NOTE: can only be called on a wrapper instance that is also the root instance.
|
||||
*/
|
||||
update(): this;
|
||||
|
||||
/**
|
||||
* Returns an html-like string of the wrapper for debugging purposes. Useful to print out to the console when
|
||||
* tests are not passing when you expect them to.
|
||||
*/
|
||||
debug(): String;
|
||||
|
||||
/**
|
||||
* Returns the type of the current node of this wrapper. If it's a composite component, this will be the
|
||||
* component constructor. If it's native DOM node, it will be a string of the tag name.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
type(): String | Function;
|
||||
|
||||
/**
|
||||
* Iterates through each node of the current wrapper and executes the provided function with a wrapper around
|
||||
* the corresponding node passed in as the first argument.
|
||||
*
|
||||
* Returns itself.
|
||||
* @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first
|
||||
* argument, and will be run with a context of the original instance.
|
||||
*/
|
||||
forEach(fn: (wrapper: this) => any): this;
|
||||
|
||||
/**
|
||||
* Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map
|
||||
* function.
|
||||
* Returns an array of the returned values from the mapping function..
|
||||
* @param fn A mapping function to be run for every node in the collection, the results of which will be mapped
|
||||
* to the returned array. Should expect a ShallowWrapper as the first argument, and will be run
|
||||
* with a context of the original instance.
|
||||
*/
|
||||
map<V>(fn: (wrapper: this) => V): V[];
|
||||
|
||||
/**
|
||||
* Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node
|
||||
* is passed in as a ShallowWrapper, and is processed from left to right.
|
||||
* @param fn
|
||||
* @param initialValue
|
||||
*/
|
||||
reduce<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[];
|
||||
|
||||
/**
|
||||
* Applies the provided reducing function to every node in the wrapper to reduce to a single value.
|
||||
* Each node is passed in as a ShallowWrapper, and is processed from right to left.
|
||||
* @param fn
|
||||
* @param initialValue
|
||||
*/
|
||||
reduceRight<R>(fn: (prevVal: R, wrapper: this, index: number) => R, initialValue?: R): R[];
|
||||
|
||||
/**
|
||||
* Returns whether or not any of the nodes in the wrapper match the provided selector.
|
||||
* @param selector
|
||||
*/
|
||||
some(selector: EnzymeSelector): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not any of the nodes in the wrapper pass the provided predicate function.
|
||||
* @param fn
|
||||
*/
|
||||
someWhere(fn: (wrapper: this) => Boolean): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not all of the nodes in the wrapper match the provided selector.
|
||||
* @param selector
|
||||
*/
|
||||
every(selector: EnzymeSelector): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not any of the nodes in the wrapper pass the provided predicate function.
|
||||
* @param fn
|
||||
*/
|
||||
everyWhere(fn: (wrapper: this) => Boolean): Boolean;
|
||||
|
||||
length: number;
|
||||
}
|
||||
|
||||
export interface ShallowWrapper<P, S> extends CommonWrapper<P, S> {
|
||||
shallow(): ShallowWrapper<P, S>;
|
||||
render(): CheerioWrapper<P, S>;
|
||||
unmount(): ShallowWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Find every node in the render tree that matches the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
find<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
find<P2>(statelessComponent: (props: P2) => JSX.Element): ShallowWrapper<P2, {}>;
|
||||
find(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Removes nodes in the current wrapper that do not match the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
filter<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
filter<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
|
||||
filter(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Finds every node in the render tree that returns true for the provided predicate function.
|
||||
* @param predicate
|
||||
*/
|
||||
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => Boolean): ShallowWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
|
||||
* can be provided and it will filter the children by this selector.
|
||||
* @param [selector]
|
||||
*/
|
||||
children<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
children<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
|
||||
children(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
children(): ShallowWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
|
||||
* current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
* @param [selector]
|
||||
*/
|
||||
parents<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
parents<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
|
||||
parents(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
parents(): ShallowWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper of the first element that matches the selector by traversing up through the current node's
|
||||
* ancestors in the tree, starting with itself.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
* @param selector
|
||||
*/
|
||||
closest<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
closest<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, {}>;
|
||||
closest(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper with the direct parent of the node in the current wrapper.
|
||||
*/
|
||||
parent(): ShallowWrapper<any, any>;
|
||||
}
|
||||
|
||||
export interface ReactWrapper<P, S> extends CommonWrapper<P, S> {
|
||||
unmount(): ReactWrapper<any, any>;
|
||||
mount(): ReactWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Find every node in the render tree that matches the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
find<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
find<P2>(statelessComponent: (props: P2) => JSX.Element): ReactWrapper<P2, {}>;
|
||||
find(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Finds every node in the render tree that returns true for the provided predicate function.
|
||||
* @param predicate
|
||||
*/
|
||||
findWhere(predicate: (wrapper: CommonWrapper<any, any>) => Boolean): ReactWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Removes nodes in the current wrapper that do not match the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
filter<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
filter<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
|
||||
filter(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
|
||||
* can be provided and it will filter the children by this selector.
|
||||
* @param [selector]
|
||||
*/
|
||||
children<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
children<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
|
||||
children(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
children(): ReactWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
|
||||
* current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
* @param [selector]
|
||||
*/
|
||||
parents<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
parents<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
|
||||
parents(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
parents(): ReactWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper of the first element that matches the selector by traversing up through the current node's
|
||||
* ancestors in the tree, starting with itself.
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
* @param selector
|
||||
*/
|
||||
closest<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
closest<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, {}>;
|
||||
closest(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper with the direct parent of the node in the current wrapper.
|
||||
*/
|
||||
parent(): ReactWrapper<any, any>;
|
||||
}
|
||||
|
||||
export interface CheerioWrapper<P, S> extends CommonWrapper<P, S> {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Shallow rendering is useful to constrain yourself to testing a component as a unit, and to ensure that
|
||||
* your tests aren't indirectly asserting on behavior of child components.
|
||||
* @param node
|
||||
* @param [options]
|
||||
*/
|
||||
export function shallow<P, S>(node: ReactElement<P>, options?: any): ShallowWrapper<P, S>;
|
||||
|
||||
/**
|
||||
* Mounts and renders a react component into the document and provides a testing wrapper around it.
|
||||
* @param node
|
||||
* @param [options]
|
||||
*/
|
||||
export function mount<P, S>(node: ReactElement<P>, options?: any): ReactWrapper<P, S>;
|
||||
|
||||
/**
|
||||
* Render react components to static HTML and analyze the resulting HTML structure.
|
||||
* @param node
|
||||
* @param [options]
|
||||
*/
|
||||
export function render<P, S>(node: ReactElement<P>, options?: any): CheerioWrapper<P, S>;
|
||||
|
||||
export function describeWithDOM(description: String, fn: Function): void;
|
||||
|
||||
export function spyLifecycle(component: typeof Component): void;
|
||||
}
|
||||
+178
-13
@@ -73,6 +73,26 @@ namespace ShallowWrapperTest {
|
||||
boolVal = shallowWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_containsMatchingElement() {
|
||||
boolVal = shallowWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_containsAllMatchingElements() {
|
||||
boolVal = shallowWrapper.containsAllMatchingElements([<div className="foo bar"/>]);
|
||||
}
|
||||
|
||||
function test_containsAnyMatchingElement() {
|
||||
boolVal = shallowWrapper.containsAnyMatchingElements([<div className="foo bar"/>]);
|
||||
}
|
||||
|
||||
function test_equals() {
|
||||
boolVal = shallowWrapper.equals(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_matchesElement() {
|
||||
boolVal = shallowWrapper.matchesElement(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_hasClass() {
|
||||
boolVal = shallowWrapper.find('.my-button').hasClass('disabled');
|
||||
}
|
||||
@@ -90,6 +110,20 @@ namespace ShallowWrapperTest {
|
||||
shallowWrapper.children(MyStatelessComponent).props().stateless;
|
||||
}
|
||||
|
||||
function test_childAt() {
|
||||
const childWrapper: ShallowWrapper<any, any> = shallowWrapper.childAt(0);
|
||||
|
||||
interface TmpType1 {
|
||||
foo: any
|
||||
}
|
||||
|
||||
interface TmpType2 {
|
||||
bar: any
|
||||
}
|
||||
|
||||
const childWrapper2: ShallowWrapper<TmpType1, TmpType2> = shallowWrapper.childAt<TmpType1, TmpType2>(0);
|
||||
}
|
||||
|
||||
function test_parents() {
|
||||
shallowWrapper = shallowWrapper.parents();
|
||||
}
|
||||
@@ -143,6 +177,13 @@ namespace ShallowWrapperTest {
|
||||
function test_state() {
|
||||
shallowWrapper.state();
|
||||
shallowWrapper.state('key');
|
||||
const tmp: String = shallowWrapper.state<String>('key');
|
||||
}
|
||||
|
||||
function test_context() {
|
||||
shallowWrapper.context();
|
||||
shallowWrapper.context('key');
|
||||
const tmp: String = shallowWrapper.context<String>('key');
|
||||
}
|
||||
|
||||
function test_props() {
|
||||
@@ -151,8 +192,12 @@ namespace ShallowWrapperTest {
|
||||
|
||||
function test_prop() {
|
||||
shallowWrapper.prop('key');
|
||||
const tmp: String = shallowWrapper.prop<String>('key');
|
||||
}
|
||||
|
||||
function test_key() {
|
||||
stringVal = shallowWrapper.key();
|
||||
}
|
||||
|
||||
function test_simulate(...args: any[]) {
|
||||
shallowWrapper.simulate('click');
|
||||
@@ -160,15 +205,15 @@ namespace ShallowWrapperTest {
|
||||
}
|
||||
|
||||
function test_setState() {
|
||||
shallowWrapper = shallowWrapper.setState({stateProperty: 'state'});
|
||||
shallowWrapper = shallowWrapper.setState({ stateProperty: 'state' });
|
||||
}
|
||||
|
||||
function test_setProps() {
|
||||
shallowWrapper = shallowWrapper.setProps({propsProperty: 'foo'});
|
||||
shallowWrapper = shallowWrapper.setProps({ propsProperty: 'foo' });
|
||||
}
|
||||
|
||||
function test_setContext() {
|
||||
shallowWrapper = shallowWrapper.setContext({name: 'baz'});
|
||||
shallowWrapper = shallowWrapper.setContext({ name: 'baz' });
|
||||
}
|
||||
|
||||
function test_instance() {
|
||||
@@ -184,7 +229,11 @@ namespace ShallowWrapperTest {
|
||||
}
|
||||
|
||||
function test_type() {
|
||||
var stringOrFunction: String|Function = shallowWrapper.type();
|
||||
var stringOrFunction: String | Function = shallowWrapper.type();
|
||||
}
|
||||
|
||||
function test_name() {
|
||||
var str: String = shallowWrapper.name();
|
||||
}
|
||||
|
||||
function test_forEach() {
|
||||
@@ -250,6 +299,24 @@ namespace ReactWrapperTest {
|
||||
reactWrapper = reactWrapper.mount();
|
||||
}
|
||||
|
||||
function test_ref() {
|
||||
reactWrapper = reactWrapper.ref('refName');
|
||||
|
||||
interface TmpType1 {
|
||||
foo: string
|
||||
}
|
||||
|
||||
interface TmpType2 {
|
||||
bar: string
|
||||
}
|
||||
|
||||
const tmp: ReactWrapper<TmpType1, TmpType2> = reactWrapper.ref<TmpType1, TmpType2>('refName');
|
||||
}
|
||||
|
||||
function test_detach() {
|
||||
reactWrapper.detach();
|
||||
}
|
||||
|
||||
function test_find() {
|
||||
elementWrapper = reactWrapper.find('.selector');
|
||||
reactWrapper = reactWrapper.find(MyComponent);
|
||||
@@ -278,6 +345,26 @@ namespace ReactWrapperTest {
|
||||
boolVal = reactWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_containsMatchingElement() {
|
||||
boolVal = reactWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_containsAllMatchingElements() {
|
||||
boolVal = reactWrapper.containsAllMatchingElements([<div className="foo bar"/>]);
|
||||
}
|
||||
|
||||
function test_containsAnyMatchingElement() {
|
||||
boolVal = reactWrapper.containsAnyMatchingElements([<div className="foo bar"/>]);
|
||||
}
|
||||
|
||||
function test_equals() {
|
||||
boolVal = reactWrapper.equals(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_matchesElement() {
|
||||
boolVal = reactWrapper.matchesElement(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_hasClass() {
|
||||
boolVal = reactWrapper.find('.my-button').hasClass('disabled');
|
||||
}
|
||||
@@ -294,6 +381,20 @@ namespace ReactWrapperTest {
|
||||
reactWrapper = reactWrapper.children();
|
||||
}
|
||||
|
||||
function test_childAt() {
|
||||
const childWrapper: ReactWrapper<any, any> = reactWrapper.childAt(0);
|
||||
|
||||
interface TmpType1 {
|
||||
foo: any
|
||||
}
|
||||
|
||||
interface TmpType2 {
|
||||
bar: any
|
||||
}
|
||||
|
||||
const childWrapper2: ReactWrapper<TmpType1, TmpType2> = reactWrapper.childAt<TmpType1, TmpType2>(0);
|
||||
}
|
||||
|
||||
function test_parents() {
|
||||
reactWrapper = reactWrapper.parents();
|
||||
}
|
||||
@@ -334,6 +435,13 @@ namespace ReactWrapperTest {
|
||||
function test_state() {
|
||||
reactWrapper.state();
|
||||
reactWrapper.state('key');
|
||||
const tmp: String = reactWrapper.state<String>('key');
|
||||
}
|
||||
|
||||
function test_context() {
|
||||
reactWrapper.context();
|
||||
reactWrapper.context('key');
|
||||
const tmp: String = reactWrapper.context<String>('key');
|
||||
}
|
||||
|
||||
function test_props() {
|
||||
@@ -342,8 +450,12 @@ namespace ReactWrapperTest {
|
||||
|
||||
function test_prop() {
|
||||
reactWrapper.prop('key');
|
||||
const tmp: String = reactWrapper.prop<String>('key');
|
||||
}
|
||||
|
||||
function test_key() {
|
||||
stringVal = reactWrapper.key();
|
||||
}
|
||||
|
||||
function test_simulate(...args: any[]) {
|
||||
reactWrapper.simulate('click');
|
||||
@@ -351,15 +463,15 @@ namespace ReactWrapperTest {
|
||||
}
|
||||
|
||||
function test_setState() {
|
||||
reactWrapper = reactWrapper.setState({stateProperty: 'state'});
|
||||
reactWrapper = reactWrapper.setState({ stateProperty: 'state' });
|
||||
}
|
||||
|
||||
function test_setProps() {
|
||||
reactWrapper = reactWrapper.setProps({propsProperty: 'foo'});
|
||||
reactWrapper = reactWrapper.setProps({ propsProperty: 'foo' });
|
||||
}
|
||||
|
||||
function test_setContext() {
|
||||
reactWrapper = reactWrapper.setContext({name: 'baz'});
|
||||
reactWrapper = reactWrapper.setContext({ name: 'baz' });
|
||||
}
|
||||
|
||||
function test_instance() {
|
||||
@@ -375,7 +487,11 @@ namespace ReactWrapperTest {
|
||||
}
|
||||
|
||||
function test_type() {
|
||||
var stringOrFunction: String|Function = reactWrapper.type();
|
||||
var stringOrFunction: String | Function = reactWrapper.type();
|
||||
}
|
||||
|
||||
function test_name() {
|
||||
var str: String = reactWrapper.name();
|
||||
}
|
||||
|
||||
function test_forEach() {
|
||||
@@ -460,6 +576,26 @@ namespace CheerioWrapperTest {
|
||||
boolVal = cheerioWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_containsMatchingElement() {
|
||||
boolVal = cheerioWrapper.contains(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_containsAllMatchingElements() {
|
||||
boolVal = cheerioWrapper.containsAllMatchingElements([<div className="foo bar"/>]);
|
||||
}
|
||||
|
||||
function test_containsAnyMatchingElement() {
|
||||
boolVal = cheerioWrapper.containsAnyMatchingElements([<div className="foo bar"/>]);
|
||||
}
|
||||
|
||||
function test_equals() {
|
||||
boolVal = cheerioWrapper.equals(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_matchesElement() {
|
||||
boolVal = cheerioWrapper.matchesElement(<div className="foo bar"/>);
|
||||
}
|
||||
|
||||
function test_hasClass() {
|
||||
boolVal = cheerioWrapper.find('.my-button').hasClass('disabled');
|
||||
}
|
||||
@@ -476,6 +612,20 @@ namespace CheerioWrapperTest {
|
||||
cheerioWrapper = cheerioWrapper.children();
|
||||
}
|
||||
|
||||
function test_childAt() {
|
||||
const childWrapper: CheerioWrapper<any, any> = cheerioWrapper.childAt(0);
|
||||
|
||||
interface TmpType1 {
|
||||
foo: any
|
||||
}
|
||||
|
||||
interface TmpType2 {
|
||||
bar: any
|
||||
}
|
||||
|
||||
const childWrapper2: CheerioWrapper<TmpType1, TmpType2> = cheerioWrapper.childAt<TmpType1, TmpType2>(0);
|
||||
}
|
||||
|
||||
function test_parents() {
|
||||
cheerioWrapper = cheerioWrapper.parents();
|
||||
}
|
||||
@@ -516,6 +666,13 @@ namespace CheerioWrapperTest {
|
||||
function test_state() {
|
||||
cheerioWrapper.state();
|
||||
cheerioWrapper.state('key');
|
||||
const tmp: String = cheerioWrapper.state<String>('key');
|
||||
}
|
||||
|
||||
function test_context() {
|
||||
cheerioWrapper.context();
|
||||
cheerioWrapper.context('key');
|
||||
const tmp: String = cheerioWrapper.context<String>('key');
|
||||
}
|
||||
|
||||
function test_props() {
|
||||
@@ -524,8 +681,12 @@ namespace CheerioWrapperTest {
|
||||
|
||||
function test_prop() {
|
||||
cheerioWrapper.prop('key');
|
||||
const tmp: String = cheerioWrapper.prop<String>('key');
|
||||
}
|
||||
|
||||
function test_key() {
|
||||
stringVal = cheerioWrapper.key();
|
||||
}
|
||||
|
||||
function test_simulate(...args: any[]) {
|
||||
cheerioWrapper.simulate('click');
|
||||
@@ -533,15 +694,15 @@ namespace CheerioWrapperTest {
|
||||
}
|
||||
|
||||
function test_setState() {
|
||||
cheerioWrapper = cheerioWrapper.setState({stateProperty: 'state'});
|
||||
cheerioWrapper = cheerioWrapper.setState({ stateProperty: 'state' });
|
||||
}
|
||||
|
||||
function test_setProps() {
|
||||
cheerioWrapper = cheerioWrapper.setProps({propsProperty: 'foo'});
|
||||
cheerioWrapper = cheerioWrapper.setProps({ propsProperty: 'foo' });
|
||||
}
|
||||
|
||||
function test_setContext() {
|
||||
cheerioWrapper = cheerioWrapper.setContext({name: 'baz'});
|
||||
cheerioWrapper = cheerioWrapper.setContext({ name: 'baz' });
|
||||
}
|
||||
|
||||
function test_instance() {
|
||||
@@ -557,12 +718,16 @@ namespace CheerioWrapperTest {
|
||||
}
|
||||
|
||||
function test_type() {
|
||||
var stringOrFunction: String|Function = cheerioWrapper.type();
|
||||
var stringOrFunction: String | Function = cheerioWrapper.type();
|
||||
}
|
||||
|
||||
function test_name() {
|
||||
var str: String = cheerioWrapper.name();
|
||||
}
|
||||
|
||||
function test_forEach() {
|
||||
cheerioWrapper =
|
||||
cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>)=> {
|
||||
cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Vendored
+88
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Enzyme v1.2.0
|
||||
// Type definitions for Enzyme v2.3.0
|
||||
// Project: https://github.com/airbnb/enzyme
|
||||
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -57,6 +57,34 @@ declare module "enzyme" {
|
||||
*/
|
||||
contains(node: ReactElement<any>): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not a given react element exists in the shallow render tree.
|
||||
* @param node
|
||||
*/
|
||||
containsMatchingElement(node: ReactElement<any>): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not all the given react elements exists in the shallow render tree
|
||||
* @param nodes
|
||||
*/
|
||||
containsAllMatchingElements(nodes: ReactElement<any>[]): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not one of the given react elements exists in the shallow render tree.
|
||||
* @param nodes
|
||||
*/
|
||||
containsAnyMatchingElements(nodes: ReactElement<any>[]): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not the current render tree is equal to the given node, based on the expected value.
|
||||
*/
|
||||
equals(node: ReactElement<any>): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not a given react element matches the shallow render tree.
|
||||
*/
|
||||
matchesElement(node: ReactElement<any>): Boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not the current node has a className prop including the passed in class name.
|
||||
* @param className
|
||||
@@ -86,6 +114,13 @@ declare module "enzyme" {
|
||||
children(selector: string): CommonWrapper<HTMLAttributes, any>;
|
||||
children(): CommonWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with child at the specified index.
|
||||
* @param index
|
||||
*/
|
||||
childAt(index: Number): CommonWrapper<any, any>;
|
||||
childAt<P2, S2>(index: Number): CommonWrapper<P2, S2>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
|
||||
* current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
|
||||
@@ -157,6 +192,13 @@ declare module "enzyme" {
|
||||
* @param [key]
|
||||
*/
|
||||
state(key?: String): any;
|
||||
state<T>(key?: String): T;
|
||||
|
||||
/**
|
||||
* Returns the context hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value.
|
||||
*/
|
||||
context(key?: String): any;
|
||||
context<T>(key?: String): T;
|
||||
|
||||
/**
|
||||
* Returns the props hash for the current node of the wrapper.
|
||||
@@ -172,6 +214,13 @@ declare module "enzyme" {
|
||||
* @param key
|
||||
*/
|
||||
prop(key: String): any;
|
||||
prop<T>(key: String): T;
|
||||
|
||||
/**
|
||||
* Returns the key value for the node of the current wrapper.
|
||||
* NOTE: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
key(): String;
|
||||
|
||||
/**
|
||||
* Simulate events.
|
||||
@@ -247,6 +296,11 @@ declare module "enzyme" {
|
||||
*/
|
||||
type(): String | Function;
|
||||
|
||||
/**
|
||||
* Returns the name of the current node of the wrapper.
|
||||
*/
|
||||
name(): String;
|
||||
|
||||
/**
|
||||
* Iterates through each node of the current wrapper and executes the provided function with a wrapper around
|
||||
* the corresponding node passed in as the first argument.
|
||||
@@ -347,6 +401,13 @@ declare module "enzyme" {
|
||||
children(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
children(): ShallowWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with child at the specified index.
|
||||
* @param index
|
||||
*/
|
||||
childAt(index: Number): ShallowWrapper<any, any>;
|
||||
childAt<P2, S2>(index: Number): ShallowWrapper<P2, S2>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
|
||||
* current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
|
||||
@@ -380,6 +441,25 @@ declare module "enzyme" {
|
||||
unmount(): ReactWrapper<any, any>;
|
||||
mount(): ReactWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper of the node that matches the provided reference name.
|
||||
*
|
||||
* NOTE: can only be called on a wrapper instance that is also the root instance.
|
||||
*/
|
||||
ref(refName: String): ReactWrapper<any, any>;
|
||||
ref<P2, S2>(refName: String): ReactWrapper<P2, S2>;
|
||||
|
||||
/**
|
||||
* Detaches the react tree from the DOM. Runs ReactDOM.unmountComponentAtNode() under the hood.
|
||||
*
|
||||
* This method will most commonly be used as a "cleanup" method if you decide to use the attachTo option in mount(node, options).
|
||||
*
|
||||
* The method is intentionally not "fluent" (in that it doesn't return this) because you should not be doing anything with this wrapper after this method is called.
|
||||
*
|
||||
* Using the attachTo is not generally recommended unless it is absolutely necessary to test something. It is your responsibility to clean up after yourself at the end of the test if you do decide to use it, though.
|
||||
*/
|
||||
detach() : void;
|
||||
|
||||
/**
|
||||
* Find every node in the render tree that matches the provided selector.
|
||||
* @param selector The selector to match.
|
||||
@@ -412,6 +492,13 @@ declare module "enzyme" {
|
||||
children(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
children(): ReactWrapper<any, any>;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with child at the specified index.
|
||||
* @param index
|
||||
*/
|
||||
childAt(index: Number): ReactWrapper<any, any>;
|
||||
childAt<P2, S2>(index: Number): ReactWrapper<P2, S2>;
|
||||
|
||||
/**
|
||||
* Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the
|
||||
* current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector.
|
||||
|
||||
@@ -49,6 +49,8 @@ let generateOptions: escodegen.GenerateOptions = {
|
||||
verbatim: " "
|
||||
};
|
||||
|
||||
let precedence: escodegen.Precedence = escodegen.Precedence.Primary;
|
||||
|
||||
let myCode: string = escodegen.generate({}, generateOptions);
|
||||
|
||||
let ast: any = escodegen.attachComments({}, {}, {});
|
||||
|
||||
Vendored
+29
@@ -135,6 +135,35 @@ declare module 'escodegen' {
|
||||
*/
|
||||
verbatim?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://github.com/estools/escodegen/commit/adf113333cd4888cf59bfc4f957df98bf7db82b6
|
||||
*/
|
||||
export enum Precedence {
|
||||
Sequence,
|
||||
Yield,
|
||||
Await,
|
||||
Assignment,
|
||||
Conditional,
|
||||
ArrowFunction,
|
||||
LogicalOR,
|
||||
LogicalAND,
|
||||
BitwiseOR,
|
||||
BitwiseXOR,
|
||||
BitwiseAND,
|
||||
Equality,
|
||||
Relational,
|
||||
BitwiseSHIFT,
|
||||
Additive,
|
||||
Multiplicative,
|
||||
Unary,
|
||||
Postfix,
|
||||
Call,
|
||||
New,
|
||||
TaggedTemplate,
|
||||
Member,
|
||||
Primary
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces given Abstract Syntax Tree as javascript code
|
||||
|
||||
Vendored
+22
-16
@@ -1,6 +1,6 @@
|
||||
// Type definitions for html2canvas.js v0.4.1
|
||||
// Type definitions for html2canvas.js v0.5.0-bata.4
|
||||
// Project: https://github.com/niklasvh/html2canvas
|
||||
// Definitions by: Richard Hepburn <https://github.com/rwhepburn/>
|
||||
// Definitions by: Richard Hepburn <https://github.com/rwhepburn/>, Pei-Tang Huang <https://github.com/tan9/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
@@ -36,26 +36,14 @@ declare namespace Html2Canvas {
|
||||
|
||||
/** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */
|
||||
useCORS?: boolean;
|
||||
|
||||
|
||||
/** Use svg powered rendering where available (FF11+). */
|
||||
svgRendering?: boolean;
|
||||
|
||||
/** Callback providing the rendered canvas element after rendering */
|
||||
onrendered?(canvas: HTMLCanvasElement): void;
|
||||
}
|
||||
}
|
||||
|
||||
interface Html2CanvasStatic {
|
||||
|
||||
/**
|
||||
* Renders an HTML element to a canvas so that a screenshot can be generated.
|
||||
*
|
||||
* The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot,
|
||||
* but builds the screenshot based on the information available on the page.
|
||||
*
|
||||
* @param {HTMLElement} element The HTML element which will be rendered to the canvas. Use the root element to render the entire window.
|
||||
*/
|
||||
(element: HTMLElement): void;
|
||||
/**
|
||||
* Renders an HTML element to a canvas so that a screenshot can be generated.
|
||||
*
|
||||
@@ -65,7 +53,25 @@ interface Html2CanvasStatic {
|
||||
* @param {HTMLElement} element The HTML element which will be rendered to the canvas. Use the root element to render the entire window.
|
||||
* @param {Html2CanvasOptions} options The options object that controls how the element will be rendered.
|
||||
*/
|
||||
(element: HTMLElement, options: Html2Canvas.Html2CanvasOptions): void;
|
||||
(element: HTMLElement, options?: Html2Canvas.Html2CanvasOptions): Html2CanvasPromise<HTMLCanvasElement>;
|
||||
}
|
||||
|
||||
// FIXME:
|
||||
// Find out a way to dependent on real Promise interface.
|
||||
// And remove following custome Promise interface.
|
||||
interface Html2CanvasThenable<R> {
|
||||
then<U>(onFulfilled?: (value: R) => U | Html2CanvasThenable<U>, onRejected?: (error: any) => U | Html2CanvasThenable<U>): Html2CanvasThenable<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U | Html2CanvasThenable<U>, onRejected?: (error: any) => void): Html2CanvasThenable<U>;
|
||||
}
|
||||
|
||||
interface Html2CanvasPromise<R> extends Html2CanvasThenable<R> {
|
||||
then<U>(onFulfilled?: (value: R) => U | Html2CanvasThenable<U>, onRejected?: (error: any) => U | Html2CanvasThenable<U>): Html2CanvasPromise<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U | Html2CanvasThenable<U>, onRejected?: (error: any) => void): Html2CanvasPromise<U>;
|
||||
catch<U>(onRejected?: (error: any) => U | Html2CanvasThenable<U>): Html2CanvasPromise<U>;
|
||||
}
|
||||
|
||||
declare module 'html2canvas' {
|
||||
export = html2canvas;
|
||||
}
|
||||
|
||||
declare var html2canvas: Html2CanvasStatic;
|
||||
|
||||
+7
-7
@@ -4,23 +4,23 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare enum RequestContext {
|
||||
"audio", "beacon", "cspreport", "download", "embed", "eventsource",
|
||||
"favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe",
|
||||
"image", "imageset", "import", "internal", "location", "manifest",
|
||||
"object", "ping", "plugin", "prefetch", "script", "serviceworker",
|
||||
"audio", "beacon", "cspreport", "download", "embed", "eventsource",
|
||||
"favicon", "fetch", "font", "form", "frame", "hyperlink", "iframe",
|
||||
"image", "imageset", "import", "internal", "location", "manifest",
|
||||
"object", "ping", "plugin", "prefetch", "script", "serviceworker",
|
||||
"sharedworker", "subresource", "style", "track", "video", "worker",
|
||||
"xmlhttprequest", "xslt"
|
||||
}
|
||||
declare enum RequestMode { "same-origin", "no-cors", "cors" }
|
||||
declare enum RequestCredentials { "omit", "same-origin", "include" }
|
||||
declare enum RequestCache {
|
||||
"default", "no-store", "reload", "no-cache", "force-cache",
|
||||
declare enum RequestCache {
|
||||
"default", "no-store", "reload", "no-cache", "force-cache",
|
||||
"only-if-cached"
|
||||
}
|
||||
declare enum ResponseType { "basic", "cors", "default", "error", "opaque" }
|
||||
|
||||
declare type HeaderInit = Headers | Array<string>;
|
||||
declare type BodyInit = Blob | FormData | string;
|
||||
declare type BodyInit = ArrayBuffer | ArrayBufferView | Blob | FormData | string;
|
||||
declare type RequestInfo = Request | string;
|
||||
|
||||
interface RequestInit {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/// <reference path="jquery.tooltipster.d.ts" />
|
||||
|
||||
// Type definition tests for jQuery Tooltipster 3.0.5
|
||||
// Type definition tests for jQuery Tooltipster 3.3.0
|
||||
// Project: https://github.com/iamceege/tooltipster
|
||||
// Definitions by: Patrick Magee <https://github.com/pjmagee/>
|
||||
// Definitions by: Patrick Magee <https://github.com/pjmagee/>, Dmitry Pesterev <https://github.com/VorobeY1326/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// Tests taken from the getting started section of the Tooltipster website
|
||||
|
||||
@@ -13,6 +13,10 @@ $(document).ready(function () {
|
||||
$('#my-tooltip').tooltipster({
|
||||
content: $('<span><img src="my-image.png" /> <strong>This text is in bold case !</strong></span>')
|
||||
});
|
||||
|
||||
$('#my-tooltip').tooltipster({
|
||||
content: 'string test'
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -191,4 +195,4 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
|
||||
$('#my-special-tooltip').tooltipster('content', 'My new content');
|
||||
$('#my-special-tooltip').tooltipster('content', 'My new content');
|
||||
|
||||
+30
-11
@@ -1,6 +1,6 @@
|
||||
// Type definitions for jQuery Tooltipster 3.0.5
|
||||
// Type definitions for jQuery Tooltipster 3.3.0
|
||||
// Project: https://github.com/iamceege/tooltipster
|
||||
// Definitions by: Patrick Magee <https://github.com/pjmagee/>
|
||||
// Definitions by: Patrick Magee <https://github.com/pjmagee/>, Dmitry Pesterev <https://github.com/VorobeY1326/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
@@ -21,14 +21,13 @@ interface JQueryTooltipsterOptions {
|
||||
*/
|
||||
arrowColor?: any;
|
||||
/**
|
||||
* If autoClose is set to false, the tooltip will never close unless you call the 'close' method yourself. Default: true
|
||||
* If autoClose is set to false, the tooltip will never close unless you call the 'hide' method yourself. Default: true
|
||||
*/
|
||||
autoClose?: boolean;
|
||||
/**
|
||||
* If set, this will override the content of the tooltip. Default: null
|
||||
* @type string, jQuery object
|
||||
*/
|
||||
content?: any;
|
||||
content?: string | JQuery;
|
||||
/**
|
||||
* If the content of the tooltip is provided as a string, it is displayed as plain text by default. If this content should actually be interpreted as HTML, set this option to true. Default: false
|
||||
*/
|
||||
@@ -38,15 +37,19 @@ interface JQueryTooltipsterOptions {
|
||||
*/
|
||||
contentCloning?: boolean;
|
||||
/**
|
||||
* Tooltipster logs notices into the console when you're doing something you ideally shouldn't be doing. Set to false to disable logging. Default: true
|
||||
*/
|
||||
debug?: boolean;
|
||||
/**
|
||||
* Delay how long it takes (in milliseconds) for the tooltip to start animating in. Default: 200
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
* Set a fixed width for the tooltip. The tooltip will always be a consistent width - no matter your content size. Default: 0 (auto width)
|
||||
* Set a minimum width for the tooltip. Default: 0 (auto width)
|
||||
*/
|
||||
fixedWidth?: number;
|
||||
minWidth?: number;
|
||||
/**
|
||||
* Set a max width for the tooltip. If the tooltip ends up being smaller than the set max width, the tooltip's width will be set automatically. Default: 0 (no max width)
|
||||
* Set a maximum width for the tooltip. Default: null (no max width)
|
||||
*/
|
||||
maxWidth?: number;
|
||||
/**
|
||||
@@ -66,10 +69,13 @@ interface JQueryTooltipsterOptions {
|
||||
*/
|
||||
functionAfter?: (origin) => void;
|
||||
/**
|
||||
* If using the iconDesktop or iconTouch options, this sets the content for your icon. Default: '(?)'
|
||||
* @type string, jQuery object
|
||||
* If true, the tooltip will close if its origin is clicked. This option only applies when 'trigger' is 'hover' and 'autoClose' is false. Default: false
|
||||
*/
|
||||
icon?: any;
|
||||
hideOnClick?: boolean;
|
||||
/**
|
||||
* If using the iconDesktop or iconTouch options, this sets the content for your icon. Default: '(?)'
|
||||
*/
|
||||
icon?: string | JQuery;
|
||||
/**
|
||||
* If you provide a jQuery object to the 'icon' option, this sets if it is a clone of this object that should actually be used. Default: true
|
||||
*/
|
||||
@@ -95,6 +101,10 @@ interface JQueryTooltipsterOptions {
|
||||
*/
|
||||
interactiveTolerance?: number;
|
||||
/**
|
||||
* Allows you to put multiple tooltips on a single element. Read further instructions down this page. Default: false
|
||||
*/
|
||||
multiple?: boolean;
|
||||
/**
|
||||
* Offsets the tooltip (in pixels) farther left/right from the origin. Default: 0
|
||||
*/
|
||||
offsetX?: number;
|
||||
@@ -116,6 +126,15 @@ interface JQueryTooltipsterOptions {
|
||||
*/
|
||||
positionTracker?: boolean;
|
||||
/**
|
||||
* Called after the tooltip has been repositioned by the position tracker (if enabled). Default: A function that will close the tooltip if the trigger is 'hover' and autoClose is false.
|
||||
*/
|
||||
positionTrackerCallback?: (origin) => void;
|
||||
/**
|
||||
* Specify if a TITLE attribute should be restored on the HTML element after a call to the 'destroy' method. This attribute may be omitted, or be restored with the value that existed before Tooltipster was initialized, or be restored with the stringified value of the current content. Note: in case of multiple tooltips on a single element, only the last destroyed tooltip may trigger a restoration. Default: 'current'
|
||||
* 'none', 'previous' or 'current'
|
||||
*/
|
||||
restoration?: string;
|
||||
/**
|
||||
* Set the speed of the animation. Default: 350
|
||||
*/
|
||||
speed?: number;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/// <reference path="js-quantities.d.ts" />
|
||||
|
||||
var Val1 = Qty('1 m')
|
||||
|
||||
var Val2 = Qty(1);
|
||||
|
||||
var Val3 = Qty(1, 'm');
|
||||
|
||||
var Val4 = Qty(Val1);
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
// Type definitions for JS-quantities
|
||||
// Project: http://gentooboontoo.github.io/js-quantities/
|
||||
// Definitions by: William Comartin <https://github.com/wcomartin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var Qty: QtyModule.QtyStatic;
|
||||
|
||||
declare namespace QtyModule {
|
||||
interface QtyStatic {
|
||||
(value: string): Qty;
|
||||
(value: number): Qty;
|
||||
(value: number, unit: string): Qty;
|
||||
(value: Qty): Qty;
|
||||
}
|
||||
|
||||
interface Qty {
|
||||
version: string;
|
||||
|
||||
scalar: number;
|
||||
baseScalar: number;
|
||||
|
||||
parse(value: string): Qty;
|
||||
|
||||
swiftConverter(srcUnits:string, dstUnits:string): (value:number) => number;
|
||||
|
||||
getkinds(): string[];
|
||||
|
||||
getUnits(kind:string): string[];
|
||||
|
||||
getAliases(unitName:string): string[];
|
||||
|
||||
formatter(scalar:number, units:string):string;
|
||||
|
||||
toFloat(): number;
|
||||
|
||||
isUnitless(): boolean;
|
||||
|
||||
isCompatible(other:string|Qty): boolean;
|
||||
|
||||
isInverse(other:string|Qty): boolean
|
||||
|
||||
kind(): string;
|
||||
|
||||
isBase(): boolean;
|
||||
|
||||
toBase(): Qty;
|
||||
|
||||
units(): string;
|
||||
|
||||
eq(other:Qty): boolean;
|
||||
lt(other:Qty): boolean;
|
||||
lte(other:Qty): boolean;
|
||||
gt(other:Qty): boolean;
|
||||
gte(other:Qty): boolean;
|
||||
|
||||
toPrec(precQuantity: Qty|string|number): Qty;
|
||||
|
||||
toString(targetUnitsOrMaxDecimalsOrPrec?:number|string|Qty, maxDecimals?: number): string;
|
||||
|
||||
format(targetUnits?:string, formatter?:(scalar:number, units:string) => string): string;
|
||||
|
||||
compareTo(other:Qty|string): number;
|
||||
|
||||
same(other: Qty): boolean;
|
||||
|
||||
inverse(): Qty;
|
||||
|
||||
isDegrees(): boolean;
|
||||
|
||||
isTemperature(): boolean;
|
||||
|
||||
to(other:string|Qty): Qty;
|
||||
|
||||
add(other:string|Qty): Qty;
|
||||
sub(other:string|Qty): Qty;
|
||||
mul(other:number|string|Qty): Qty;
|
||||
div(other:number|string|Qty): Qty;
|
||||
}
|
||||
}
|
||||
Vendored
+37
-3
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Kii Cloud SDK v2.4.3
|
||||
// Type definitions for Kii Cloud SDK v2.4.4
|
||||
// Project: http://en.kii.com/
|
||||
// Definitions by: Kii Consortium <http://jp.kii.com/consortium/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -6059,6 +6059,18 @@ declare namespace KiiCloud {
|
||||
*/
|
||||
getEmailAddress(): string;
|
||||
|
||||
/**
|
||||
* Get the email of this user that has not been verified.
|
||||
* When the user's email has been changed and email verification is required in you app configuration,
|
||||
* New email is stored as pending email.
|
||||
* After the new email has been verified, the address can be obtained by {@link KiiUser.getEmailAddress}
|
||||
*
|
||||
* @return User's new email address has not been verified.
|
||||
* null if no pending email field is included in refresh
|
||||
* response or undefined when no refresh operation has been done before.
|
||||
*/
|
||||
getPendingEmailAddress(): string;
|
||||
|
||||
/**
|
||||
* Get the phone number associated with this user
|
||||
*
|
||||
@@ -6066,6 +6078,18 @@ declare namespace KiiCloud {
|
||||
*/
|
||||
getPhoneNumber(): string;
|
||||
|
||||
/**
|
||||
* Get the phone of this user that has not been verified.
|
||||
* When the user's phone has been changed and phone verification is required in you app configuration,
|
||||
* New phone is stored as pending phone.
|
||||
* After the new phone has been verified, the address can be obtained by {@link KiiUser.getPhoneNumber}
|
||||
*
|
||||
* @return User's new phone number has not been verified.
|
||||
* null if no pending phone field is included in refresh
|
||||
* response or undefined when no refresh operation has been done before.
|
||||
*/
|
||||
getPendingPhoneNumber(): string;
|
||||
|
||||
/**
|
||||
* Get the country code associated with this user
|
||||
*
|
||||
@@ -7126,7 +7150,12 @@ declare namespace KiiCloud {
|
||||
ownerOfGroups(callbacks?: { success(theUser: KiiUser, groupList: KiiGroup[]): any; failure(theUser: KiiUser, anErrorString: string): any; }): Promise<[KiiUser, KiiGroup[]]>;
|
||||
|
||||
/**
|
||||
* Updates the user's phone number on the server
|
||||
* Change phone number of logged in user.
|
||||
* If the phone number verification is required by your app configuration,
|
||||
* User's phone number would not changed to new one until the new phone number verification has been done.
|
||||
* In this case, new phone can be obtained by {@link KiiUser#getPendingPhoneNumber()}.
|
||||
* This API does not refresh the KiiUser automatically.
|
||||
* Please execute {@link KiiUser#refresh()} before checking the value of {@link KiiUser#getPhoneNumber()} or {@link KiiUser#getPendingPhoneNumber()}.
|
||||
*
|
||||
* @param newPhoneNumber The new phone number to change to
|
||||
* @param callbacks An object with callback methods defined
|
||||
@@ -7169,7 +7198,12 @@ declare namespace KiiCloud {
|
||||
changePhone(newPhoneNumber: string, callbacks?: { success(theUser: KiiUser): any; failure(theUser: KiiUser, anErrorString: string): any; }): Promise<KiiUser>;
|
||||
|
||||
/**
|
||||
* Updates the user's email address on the server
|
||||
* Change email of logged in user.
|
||||
* If the email address verification is required by your app configuration,
|
||||
* User's email would not changed to new one until the new email verification has been done.
|
||||
* In this case, new mail address can be obtained by {@link KiiUser#getPendingEmailAddress()}.
|
||||
* This API does not refresh the KiiUser automatically.
|
||||
* Please execute {@link KiiUser#refresh()} before checking the value of {@link KiiUser#getEmailAddress()} or {@link KiiUser#getPendingEmailAddress()}
|
||||
*
|
||||
* @param newEmail The new email address to change to
|
||||
* @param callbacks An object with callback methods defined
|
||||
|
||||
+405
-290
File diff suppressed because it is too large
Load Diff
Vendored
+418
-295
File diff suppressed because it is too large
Load Diff
@@ -25,11 +25,11 @@ function test() {
|
||||
}
|
||||
|
||||
function testAngle() {
|
||||
makerjs.angle.areEqual(12, 13);
|
||||
makerjs.angle.mirror(45, true, false);
|
||||
makerjs.angle.noRevolutions(90);
|
||||
makerjs.angle.ofArcEnd(paths.arc);
|
||||
makerjs.angle.ofArcMiddle(paths.arc);
|
||||
makerjs.angle.ofArcSpan(paths.arc);
|
||||
makerjs.angle.ofLineInDegrees(paths.line);
|
||||
makerjs.angle.ofPointInDegrees([0,0], [1,1]);
|
||||
makerjs.angle.ofPointInRadians([0,0], [1,1]);
|
||||
@@ -67,7 +67,9 @@ function test() {
|
||||
}
|
||||
|
||||
function testMeasure() {
|
||||
makerjs.measure.arcAngle(paths.arc);
|
||||
makerjs.measure.isPointEqual(p1, p2);
|
||||
makerjs.measure.isPathEqual(paths.line, paths.circle, 4);
|
||||
makerjs.measure.isAngleEqual(12, 13);
|
||||
makerjs.measure.isArcConcaveTowardsPoint(paths.arc, [0,0]);
|
||||
makerjs.measure.isBetween(7, 8, 9, false);
|
||||
makerjs.measure.isBetweenArcAngles(7, paths.arc, false);
|
||||
@@ -119,7 +121,6 @@ function test() {
|
||||
}
|
||||
|
||||
function testPath() {
|
||||
makerjs.path.areEqual(paths.line, paths.circle, 4);
|
||||
makerjs.path.breakAtPoint(paths.arc, [0,0]).type;
|
||||
makerjs.path.dogbone(paths.line, paths.line, 7);
|
||||
makerjs.path.fillet(paths.arc, paths.line, 4);
|
||||
@@ -129,7 +130,6 @@ function test() {
|
||||
makerjs.path.moveRelative(paths.circle, [0,0]);
|
||||
makerjs.path.rotate(paths.line, 5, [0,0]);
|
||||
makerjs.path.scale(paths.arc, 8);
|
||||
makerjs.path.slopeIntersectionPoint(paths.line, paths.line);
|
||||
}
|
||||
|
||||
function testPaths() {
|
||||
@@ -156,8 +156,6 @@ function test() {
|
||||
|
||||
function testPoint() {
|
||||
makerjs.point.add(p1, p2);
|
||||
makerjs.point.areEqual(p1, p2);
|
||||
makerjs.point.areEqualRounded(p1, p2);
|
||||
makerjs.point.average(p1, p2);
|
||||
makerjs.point.clone(p1);
|
||||
makerjs.point.closest([0,0], [p1, p2]);
|
||||
@@ -170,7 +168,6 @@ function test() {
|
||||
makerjs.point.rotate(p1, 5, p2);
|
||||
makerjs.point.rounded(p1);
|
||||
makerjs.point.scale(p2, 8);
|
||||
makerjs.point.serialize(p1);
|
||||
makerjs.point.subtract(p2, p1);
|
||||
makerjs.point.zero();
|
||||
}
|
||||
|
||||
Vendored
+553
-108
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/Microsoft/maker.js
|
||||
// Definitions by: Dan Marshall <https://github.com/danmarshall>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/// <reference path="../pdfkit/pdfkit.d.ts" />
|
||||
/**
|
||||
* Root module for Maker.js.
|
||||
*
|
||||
@@ -37,6 +38,13 @@ declare namespace MakerJs {
|
||||
* @param accuracy Optional exemplar of number of decimal places.
|
||||
*/
|
||||
function round(n: number, accuracy?: number): number;
|
||||
/**
|
||||
* Create a string representation of a route array.
|
||||
*
|
||||
* @param route Array of strings which are segments of a route.
|
||||
* @returns String of the flattened array.
|
||||
*/
|
||||
function createRouteKey(route: string[]): string;
|
||||
/**
|
||||
* Clone an object.
|
||||
*
|
||||
@@ -89,6 +97,12 @@ declare namespace MakerJs {
|
||||
*/
|
||||
high: IPoint;
|
||||
}
|
||||
/**
|
||||
* A map of measurements.
|
||||
*/
|
||||
interface IMeasureMap {
|
||||
[key: string]: IMeasure;
|
||||
}
|
||||
/**
|
||||
* A line, curved line or other simple two dimensional shape.
|
||||
*/
|
||||
@@ -181,7 +195,6 @@ declare namespace MakerJs {
|
||||
function isPathArc(item: any): boolean;
|
||||
/**
|
||||
* A map of functions which accept a path as a parameter.
|
||||
* @private
|
||||
*/
|
||||
interface IPathFunctionMap {
|
||||
/**
|
||||
@@ -191,7 +204,6 @@ declare namespace MakerJs {
|
||||
}
|
||||
/**
|
||||
* A map of functions which accept a path and an origin point as parameters.
|
||||
* @private
|
||||
*/
|
||||
interface IPathOriginFunctionMap {
|
||||
/**
|
||||
@@ -213,10 +225,31 @@ declare namespace MakerJs {
|
||||
Circle: string;
|
||||
Arc: string;
|
||||
};
|
||||
/**
|
||||
* Slope and y-intercept of a line.
|
||||
*/
|
||||
interface ISlope {
|
||||
/**
|
||||
* Boolean to see if line has slope or is vertical.
|
||||
*/
|
||||
hasSlope: boolean;
|
||||
/**
|
||||
* Optional value of non-vertical slope.
|
||||
*/
|
||||
slope?: number;
|
||||
/**
|
||||
* Line used to calculate this slope.
|
||||
*/
|
||||
line: IPathLine;
|
||||
/**
|
||||
* Optional value of y when x = 0.
|
||||
*/
|
||||
yIntercept?: number;
|
||||
}
|
||||
/**
|
||||
* Options to pass to path.intersection()
|
||||
*/
|
||||
interface IPathIntersectionOptions {
|
||||
interface IPathIntersectionBaseOptions {
|
||||
/**
|
||||
* Optional boolean to only return deep intersections, i.e. not on an end point or tangent.
|
||||
*/
|
||||
@@ -226,6 +259,19 @@ declare namespace MakerJs {
|
||||
*/
|
||||
out_AreOverlapped?: boolean;
|
||||
}
|
||||
/**
|
||||
* Options to pass to path.intersection()
|
||||
*/
|
||||
interface IPathIntersectionOptions extends IPathIntersectionBaseOptions {
|
||||
/**
|
||||
* Optional boolean to only return deep intersections, i.e. not on an end point or tangent.
|
||||
*/
|
||||
path1Offset?: IPoint;
|
||||
/**
|
||||
* Optional output variable which will be set to true if the paths are overlapped.
|
||||
*/
|
||||
path2Offset?: IPoint;
|
||||
}
|
||||
/**
|
||||
* An intersection of two paths.
|
||||
*/
|
||||
@@ -268,6 +314,14 @@ declare namespace MakerJs {
|
||||
* Point which is known to be outside of the model.
|
||||
*/
|
||||
farPoint?: IPoint;
|
||||
/**
|
||||
* Cached measurements for model A.
|
||||
*/
|
||||
measureA?: measure.Atlas;
|
||||
/**
|
||||
* Cached measurements for model B.
|
||||
*/
|
||||
measureB?: measure.Atlas;
|
||||
}
|
||||
/**
|
||||
* Options to pass to model.findLoops.
|
||||
@@ -278,6 +332,19 @@ declare namespace MakerJs {
|
||||
*/
|
||||
removeFromOriginal?: boolean;
|
||||
}
|
||||
/**
|
||||
* Options to pass to model.simplify()
|
||||
*/
|
||||
interface ISimplifyOptions {
|
||||
/**
|
||||
* Optional
|
||||
*/
|
||||
pointMatchingDistance?: number;
|
||||
/**
|
||||
* Optional
|
||||
*/
|
||||
scalarMatchingDistance?: number;
|
||||
}
|
||||
/**
|
||||
* A path that may be indicated to "flow" in either direction between its endpoints.
|
||||
*/
|
||||
@@ -370,11 +437,104 @@ declare namespace MakerJs {
|
||||
pathId: string;
|
||||
}
|
||||
/**
|
||||
* Path and its reference id within a model
|
||||
* A route to either a path or a model, and the absolute offset of it.
|
||||
*/
|
||||
interface IRefPathInModel extends IRefPathIdInModel {
|
||||
interface IRouteOffset {
|
||||
layer: string;
|
||||
offset: IPoint;
|
||||
route: string[];
|
||||
routeKey: string;
|
||||
}
|
||||
/**
|
||||
* A path reference in a walk.
|
||||
*/
|
||||
interface IWalkPath extends IRefPathIdInModel, IRouteOffset {
|
||||
pathContext: IPath;
|
||||
}
|
||||
/**
|
||||
* Callback signature for path in model.walk().
|
||||
*/
|
||||
interface IWalkPathCallback {
|
||||
(context: IWalkPath): void;
|
||||
}
|
||||
/**
|
||||
* A link in a chain, with direction of flow.
|
||||
*/
|
||||
interface IChainLink {
|
||||
/**
|
||||
* Reference to the path.
|
||||
*/
|
||||
walkedPath: IWalkPath;
|
||||
/**
|
||||
* Path flows forwards or reverse.
|
||||
*/
|
||||
reversed: boolean;
|
||||
/**
|
||||
* The endpoints of the path, in absolute coords.
|
||||
*/
|
||||
endPoints: IPoint[];
|
||||
}
|
||||
/**
|
||||
* A chain of paths which connect end to end.
|
||||
*/
|
||||
interface IChain {
|
||||
/**
|
||||
* The links in this chain.
|
||||
*/
|
||||
links: IChainLink[];
|
||||
/**
|
||||
* Flag if this chain forms a loop end to end.
|
||||
*/
|
||||
endless?: boolean;
|
||||
}
|
||||
/**
|
||||
* Callback to model.findChains() with resulting array of chains and unchained paths.
|
||||
*/
|
||||
interface IChainCallback {
|
||||
(chains: IChain[], loose: IWalkPath[], layer: string): void;
|
||||
}
|
||||
/**
|
||||
* Options to pass to model.findLoops.
|
||||
*/
|
||||
interface IFindChainsOptions extends IPointMatchOptions {
|
||||
/**
|
||||
* Flag to separate chains by layers.
|
||||
*/
|
||||
byLayers?: boolean;
|
||||
}
|
||||
/**
|
||||
* Reference to a model within a model.
|
||||
*/
|
||||
interface IRefModelInModel {
|
||||
parentModel: IModel;
|
||||
childId: string;
|
||||
childModel: IModel;
|
||||
}
|
||||
/**
|
||||
* A model reference in a walk.
|
||||
*/
|
||||
interface IWalkModel extends IRefModelInModel, IRouteOffset {
|
||||
}
|
||||
/**
|
||||
* Callback signature for model.walk().
|
||||
*/
|
||||
interface IWalkModelCallback {
|
||||
(context: IWalkModel): void;
|
||||
}
|
||||
/**
|
||||
* Callback signature for model.walk(), which may return false to halt any further walking.
|
||||
*/
|
||||
interface IWalkModelCancellableCallback {
|
||||
(context: IWalkModel): boolean;
|
||||
}
|
||||
/**
|
||||
* Options to pass to model.walk().
|
||||
*/
|
||||
interface IWalkOptions {
|
||||
onPath?: IWalkPathCallback;
|
||||
beforeChildWalk?: IWalkModelCancellableCallback;
|
||||
afterChildWalk?: IWalkModelCallback;
|
||||
}
|
||||
/**
|
||||
* Describes a parameter and its limits.
|
||||
*/
|
||||
@@ -425,14 +585,6 @@ declare namespace MakerJs {
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.angle {
|
||||
/**
|
||||
* Find out if two angles are equal.
|
||||
*
|
||||
* @param a First angle.
|
||||
* @param b Second angle.
|
||||
* @returns true if angles are the same, false if they are not
|
||||
*/
|
||||
function areEqual(angle1: number, angle2: number, accuracy?: number): boolean;
|
||||
/**
|
||||
* Ensures an angle is not greater than 360
|
||||
*
|
||||
@@ -469,6 +621,13 @@ declare namespace MakerJs.angle {
|
||||
* @returns Middle angle of arc.
|
||||
*/
|
||||
function ofArcMiddle(arc: IPathArc, ratio?: number): number;
|
||||
/**
|
||||
* Total angle of an arc between its start and end angles.
|
||||
*
|
||||
* @param arc The arc to measure.
|
||||
* @returns Angle of arc.
|
||||
*/
|
||||
function ofArcSpan(arc: IPathArc): number;
|
||||
/**
|
||||
* Angle of a line path.
|
||||
*
|
||||
@@ -512,23 +671,6 @@ declare namespace MakerJs.point {
|
||||
* @returns A new point object.
|
||||
*/
|
||||
function add(a: IPoint, b: IPoint, subtract?: boolean): IPoint;
|
||||
/**
|
||||
* Find out if two points are equal.
|
||||
*
|
||||
* @param a First point.
|
||||
* @param b Second point.
|
||||
* @returns true if points are the same, false if they are not
|
||||
*/
|
||||
function areEqual(a: IPoint, b: IPoint, withinDistance?: number): boolean;
|
||||
/**
|
||||
* Find out if two points are equal after rounding.
|
||||
*
|
||||
* @param a First point.
|
||||
* @param b Second point.
|
||||
* @param accuracy Optional exemplar of number of decimal places.
|
||||
* @returns true if points are the same, false if they are not
|
||||
*/
|
||||
function areEqualRounded(a: IPoint, b: IPoint, accuracy?: number): boolean;
|
||||
/**
|
||||
* Get the average of two points.
|
||||
*
|
||||
@@ -580,7 +722,16 @@ declare namespace MakerJs.point {
|
||||
* @param pathContext The path object.
|
||||
* @returns Array with 2 elements: [0] is the point object corresponding to the origin, [1] is the point object corresponding to the end.
|
||||
*/
|
||||
function fromPathEnds(pathContext: IPath): IPoint[];
|
||||
function fromPathEnds(pathContext: IPath, pathOffset?: IPoint): IPoint[];
|
||||
/**
|
||||
* Calculates the intersection of slopes of two lines.
|
||||
*
|
||||
* @param lineA First line to use for slope.
|
||||
* @param lineB Second line to use for slope.
|
||||
* @param options Optional IPathIntersectionOptions.
|
||||
* @returns point of intersection of the two slopes, or null if the slopes did not intersect.
|
||||
*/
|
||||
function fromSlopeIntersection(lineA: IPathLine, lineB: IPathLine, options?: IPathIntersectionBaseOptions): IPoint;
|
||||
/**
|
||||
* Get the middle point of a path.
|
||||
*
|
||||
@@ -623,14 +774,6 @@ declare namespace MakerJs.point {
|
||||
* @returns A new point.
|
||||
*/
|
||||
function scale(pointToScale: IPoint, scaleValue: number): IPoint;
|
||||
/**
|
||||
* Get a string representation of a point.
|
||||
*
|
||||
* @param pointContext The point to serialize.
|
||||
* @param accuracy Optional exemplar of number of decimal places.
|
||||
* @returns String representing the point.
|
||||
*/
|
||||
function serialize(pointContext: IPoint, accuracy?: number): string;
|
||||
/**
|
||||
* Subtract a point from another point, and return the result as a new point. Shortcut to Add(a, b, subtract = true).
|
||||
*
|
||||
@@ -649,13 +792,12 @@ declare namespace MakerJs.point {
|
||||
}
|
||||
declare namespace MakerJs.path {
|
||||
/**
|
||||
* Find out if two paths are equal.
|
||||
* Create a clone of a path. This is faster than cloneObject.
|
||||
*
|
||||
* @param a First path.
|
||||
* @param b Second path.
|
||||
* @returns true if paths are the same, false if they are not
|
||||
* @param pathToClone The path to clone.
|
||||
* @returns Cloned path.
|
||||
*/
|
||||
function areEqual(path1: IPath, path2: IPath, withinPointDistance?: number): boolean;
|
||||
function clone(pathToClone: IPath): IPath;
|
||||
/**
|
||||
* Create a clone of a path, mirrored on either or both x and y axes.
|
||||
*
|
||||
@@ -679,9 +821,18 @@ declare namespace MakerJs.path {
|
||||
*
|
||||
* @param pathToMove The path to move.
|
||||
* @param delta The x & y adjustments as a point object.
|
||||
* @param subtract Optional boolean to subtract instead of add.
|
||||
* @returns The original path (for chaining).
|
||||
*/
|
||||
function moveRelative(pathToMove: IPath, delta: IPoint): IPath;
|
||||
function moveRelative(pathToMove: IPath, delta: IPoint, subtract?: boolean): IPath;
|
||||
/**
|
||||
* Move some paths relatively during a task execution, then unmove them.
|
||||
*
|
||||
* @param pathsToMove The paths to move.
|
||||
* @param deltas The x & y adjustments as a point object array.
|
||||
* @param task The function to call while the paths are temporarily moved.
|
||||
*/
|
||||
function moveTemporary(pathsToMove: IPath[], deltas: IPoint[], task: Function): void;
|
||||
/**
|
||||
* Rotate a path.
|
||||
*
|
||||
@@ -715,11 +866,6 @@ declare namespace MakerJs.path {
|
||||
declare namespace MakerJs.paths {
|
||||
/**
|
||||
* Class for arc path.
|
||||
*
|
||||
* @param origin The center point of the arc.
|
||||
* @param radius The radius of the arc.
|
||||
* @param startAngle The start angle of the arc.
|
||||
* @param endAngle The end angle of the arc.
|
||||
*/
|
||||
class Arc implements IPathArc {
|
||||
origin: IPoint;
|
||||
@@ -727,19 +873,71 @@ declare namespace MakerJs.paths {
|
||||
startAngle: number;
|
||||
endAngle: number;
|
||||
type: string;
|
||||
/**
|
||||
* Class for arc path, created from origin point, radius, start angle, and end angle.
|
||||
*
|
||||
* @param origin The center point of the arc.
|
||||
* @param radius The radius of the arc.
|
||||
* @param startAngle The start angle of the arc.
|
||||
* @param endAngle The end angle of the arc.
|
||||
*/
|
||||
constructor(origin: IPoint, radius: number, startAngle: number, endAngle: number);
|
||||
/**
|
||||
* Class for arc path, created from 2 points, radius, large Arc flag, and clockwise flag.
|
||||
*
|
||||
* @param pointA First end point of the arc.
|
||||
* @param pointB Second end point of the arc.
|
||||
* @param radius The radius of the arc.
|
||||
* @param largeArc Boolean flag to indicate clockwise direction.
|
||||
* @param clockwise Boolean flag to indicate clockwise direction.
|
||||
*/
|
||||
constructor(pointA: IPoint, pointB: IPoint, radius: number, largeArc: boolean, clockwise: boolean);
|
||||
/**
|
||||
* Class for arc path, created from 2 points and optional boolean flag indicating clockwise.
|
||||
*
|
||||
* @param pointA First end point of the arc.
|
||||
* @param pointB Second end point of the arc.
|
||||
* @param clockwise Boolean flag to indicate clockwise direction.
|
||||
*/
|
||||
constructor(pointA: IPoint, pointB: IPoint, clockwise?: boolean);
|
||||
/**
|
||||
* Class for arc path, created from 3 points.
|
||||
*
|
||||
* @param pointA First end point of the arc.
|
||||
* @param pointB Middle point on the arc.
|
||||
* @param pointC Second end point of the arc.
|
||||
*/
|
||||
constructor(pointA: IPoint, pointB: IPoint, pointC: IPoint);
|
||||
}
|
||||
/**
|
||||
* Class for circle path.
|
||||
*
|
||||
* @param origin The center point of the circle.
|
||||
* @param radius The radius of the circle.
|
||||
*/
|
||||
class Circle implements IPathCircle {
|
||||
type: string;
|
||||
origin: IPoint;
|
||||
radius: number;
|
||||
type: string;
|
||||
/**
|
||||
* Class for circle path, created from origin point and radius.
|
||||
*
|
||||
* @param origin The center point of the circle.
|
||||
* @param radius The radius of the circle.
|
||||
*/
|
||||
constructor(origin: IPoint, radius: number);
|
||||
/**
|
||||
* Class for circle path, created from 2 points.
|
||||
*
|
||||
* @param pointA First point on the circle.
|
||||
* @param pointB Second point on the circle.
|
||||
*/
|
||||
constructor(pointA: IPoint, pointB: IPoint);
|
||||
/**
|
||||
* Class for circle path, created from 3 points.
|
||||
*
|
||||
* @param pointA First point on the circle.
|
||||
* @param pointB Second point on the circle.
|
||||
* @param pointC Third point on the circle.
|
||||
*/
|
||||
constructor(pointA: IPoint, pointB: IPoint, pointC: IPoint);
|
||||
}
|
||||
/**
|
||||
* Class for line path.
|
||||
@@ -832,6 +1030,14 @@ declare namespace MakerJs.model {
|
||||
* @returns The original model (for chaining).
|
||||
*/
|
||||
function moveRelative(modelToMove: IModel, delta: IPoint): IModel;
|
||||
/**
|
||||
* Prefix the ids of paths in a model.
|
||||
*
|
||||
* @param modelToPrefix The model to prefix.
|
||||
* @param prefix The prefix to prepend on paths ids.
|
||||
* @returns The original model (for chaining).
|
||||
*/
|
||||
function prefixPathIds(modelToPrefix: IModel, prefix: string): IModel;
|
||||
/**
|
||||
* Rotate a model.
|
||||
*
|
||||
@@ -865,6 +1071,15 @@ declare namespace MakerJs.model {
|
||||
* @param callback Callback for each path.
|
||||
*/
|
||||
function walkPaths(modelContext: IModel, callback: IModelPathCallback): void;
|
||||
/**
|
||||
* Recursively walk through all paths for a given model.
|
||||
*
|
||||
* @param modelContext The model to walk.
|
||||
* @param pathCallback Callback for each path.
|
||||
* @param modelCallbackBeforeWalk Callback for each model prior to recursion, which can cancel the recursion if it returns false.
|
||||
* @param modelCallbackAfterWalk Callback for each model after recursion.
|
||||
*/
|
||||
function walk(modelContext: IModel, options: IWalkOptions): void;
|
||||
}
|
||||
declare namespace MakerJs.model {
|
||||
/**
|
||||
@@ -875,7 +1090,7 @@ declare namespace MakerJs.model {
|
||||
* @param farPoint Optional point of reference which is outside the bounds of the modelContext.
|
||||
* @returns Boolean true if the path is inside of the modelContext.
|
||||
*/
|
||||
function isPathInsideModel(pathContext: IPath, modelContext: IModel, farPoint?: IPoint): boolean;
|
||||
function isPathInsideModel(pathContext: IPath, modelContext: IModel, pathOffset?: IPoint, farPoint?: IPoint, measureAtlas?: measure.Atlas): boolean;
|
||||
/**
|
||||
* Break a model's paths everywhere they intersect with another path.
|
||||
*
|
||||
@@ -884,7 +1099,7 @@ declare namespace MakerJs.model {
|
||||
*/
|
||||
function breakPathsAtIntersections(modelToBreak: IModel, modelToIntersect?: IModel): void;
|
||||
/**
|
||||
* Combine 2 models. The models should be originated, and every path within each model should be part of a loop.
|
||||
* Combine 2 models.
|
||||
*
|
||||
* @param modelA First model to combine.
|
||||
* @param modelB Second model to combine.
|
||||
@@ -896,6 +1111,106 @@ declare namespace MakerJs.model {
|
||||
* @param farPoint Optional point of reference which is outside the bounds of both models.
|
||||
*/
|
||||
function combine(modelA: IModel, modelB: IModel, includeAInsideB?: boolean, includeAOutsideB?: boolean, includeBInsideA?: boolean, includeBOutsideA?: boolean, options?: ICombineOptions): void;
|
||||
/**
|
||||
* Combine 2 models, resulting in a intersection.
|
||||
*
|
||||
* @param modelA First model to combine.
|
||||
* @param modelB Second model to combine.
|
||||
*/
|
||||
function combineIntersection(modelA: IModel, modelB: IModel): void;
|
||||
/**
|
||||
* Combine 2 models, resulting in a subtraction of B from A.
|
||||
*
|
||||
* @param modelA First model to combine.
|
||||
* @param modelB Second model to combine.
|
||||
*/
|
||||
function combineSubtraction(modelA: IModel, modelB: IModel): void;
|
||||
/**
|
||||
* Combine 2 models, resulting in a union.
|
||||
*
|
||||
* @param modelA First model to combine.
|
||||
* @param modelB Second model to combine.
|
||||
*/
|
||||
function combineUnion(modelA: IModel, modelB: IModel): void;
|
||||
}
|
||||
declare namespace MakerJs {
|
||||
/**
|
||||
* Compare keys to see if they are equal.
|
||||
*/
|
||||
interface ICollectionKeyComparer<K> {
|
||||
(a: K, b: K): boolean;
|
||||
}
|
||||
/**
|
||||
* A collection for items that share a common key.
|
||||
*/
|
||||
interface ICollection<K, T> {
|
||||
key: K;
|
||||
items: T[];
|
||||
}
|
||||
/**
|
||||
* Collects items that share a common key.
|
||||
*/
|
||||
class Collector<K, T> {
|
||||
private comparer;
|
||||
collections: ICollection<K, T>[];
|
||||
constructor(comparer?: ICollectionKeyComparer<K>);
|
||||
addItemToCollection(key: K, item: T): void;
|
||||
findCollection(key: K, action?: (index: number) => void): T[];
|
||||
removeCollection(key: K): boolean;
|
||||
removeItemFromCollection(key: K, item: T): boolean;
|
||||
getCollectionsOfMultiple(cb: (key: K, items: T[]) => void): void;
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.model {
|
||||
/**
|
||||
* Simplify a model's paths by reducing redundancy: combine multiple overlapping paths into a single path. The model must be originated.
|
||||
*
|
||||
* @param modelContext The originated model to search for similar paths.
|
||||
* @param options Optional options object.
|
||||
* @returns The simplified model (for chaining).
|
||||
*/
|
||||
function simplify(modelToSimplify: IModel, options?: ISimplifyOptions): IModel;
|
||||
}
|
||||
declare namespace MakerJs.path {
|
||||
/**
|
||||
* Expand path by creating a model which surrounds it.
|
||||
*
|
||||
* @param pathToExpand Path to expand.
|
||||
* @param expansion Distance to expand.
|
||||
* @param isolateCaps Optional flag to put the end caps into a separate model named "caps".
|
||||
* @returns Model which surrounds the path.
|
||||
*/
|
||||
function expand(pathToExpand: IPath, expansion: number, isolateCaps?: boolean): IModel;
|
||||
/**
|
||||
* Represent an arc using straight lines.
|
||||
*
|
||||
* @param arc Arc to straighten.
|
||||
* @param bevel Optional flag to bevel the angle to prevent it from being too sharp.
|
||||
* @param prefix Optional prefix to apply to path ids.
|
||||
* @returns Model of straight lines with same endpoints as the arc.
|
||||
*/
|
||||
function straighten(arc: IPathArc, bevel?: boolean, prefix?: string): IModel;
|
||||
}
|
||||
declare namespace MakerJs.model {
|
||||
/**
|
||||
* Expand all paths in a model, then combine the resulting expansions.
|
||||
*
|
||||
* @param modelToExpand Model to expand.
|
||||
* @param distance Distance to expand.
|
||||
* @param joints Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.
|
||||
* @returns Model which surrounds the paths of the original model.
|
||||
*/
|
||||
function expandPaths(modelToExpand: IModel, distance: number, joints?: number, combineOptions?: ICombineOptions): IModel;
|
||||
/**
|
||||
* Outline a model by a specified distance. Useful for accommodating for kerf.
|
||||
*
|
||||
* @param modelToOutline Model to outline.
|
||||
* @param distance Distance to outline.
|
||||
* @param joints Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.
|
||||
* @param inside Optional boolean to draw lines inside the model instead of outside.
|
||||
* @returns Model which surrounds the paths outside of the original model.
|
||||
*/
|
||||
function outline(modelToOutline: IModel, distance: number, joints?: number, inside?: boolean): IModel;
|
||||
}
|
||||
declare namespace MakerJs.units {
|
||||
/**
|
||||
@@ -909,12 +1224,48 @@ declare namespace MakerJs.units {
|
||||
}
|
||||
declare namespace MakerJs.measure {
|
||||
/**
|
||||
* Total angle of an arc between its start and end angles.
|
||||
* Find out if two angles are equal.
|
||||
*
|
||||
* @param arc The arc to measure.
|
||||
* @returns Angle of arc.
|
||||
* @param angleA First angle.
|
||||
* @param angleB Second angle.
|
||||
* @returns true if angles are the same, false if they are not
|
||||
*/
|
||||
function arcAngle(arc: IPathArc): number;
|
||||
function isAngleEqual(angleA: number, angleB: number, accuracy?: number): boolean;
|
||||
/**
|
||||
* Find out if two paths are equal.
|
||||
*
|
||||
* @param pathA First path.
|
||||
* @param pathB Second path.
|
||||
* @returns true if paths are the same, false if they are not
|
||||
*/
|
||||
function isPathEqual(pathA: IPath, pathB: IPath, withinPointDistance?: number, pathAOffset?: IPoint, pathBOffset?: IPoint): boolean;
|
||||
/**
|
||||
* Find out if two points are equal.
|
||||
*
|
||||
* @param a First point.
|
||||
* @param b Second point.
|
||||
* @returns true if points are the same, false if they are not
|
||||
*/
|
||||
function isPointEqual(a: IPoint, b: IPoint, withinDistance?: number): boolean;
|
||||
/**
|
||||
* Check for slope equality.
|
||||
*
|
||||
* @param slopeA The ISlope to test.
|
||||
* @param slopeB The ISlope to check for equality.
|
||||
* @returns Boolean true if slopes are equal.
|
||||
*/
|
||||
function isSlopeEqual(slopeA: ISlope, slopeB: ISlope): boolean;
|
||||
}
|
||||
declare namespace MakerJs.measure {
|
||||
/**
|
||||
* Increase a measurement by an additional measurement.
|
||||
*
|
||||
* @param baseMeasure The measurement to increase.
|
||||
* @param addMeasure The additional measurement.
|
||||
* @param addOffset Optional offset point of the additional measurement.
|
||||
* @returns The increased original measurement (for chaining).
|
||||
*/
|
||||
function increase(baseMeasure: IMeasure, addMeasure: IMeasure): IMeasure;
|
||||
/**
|
||||
* Check for arc being concave or convex towards a given point.
|
||||
*
|
||||
@@ -923,16 +1274,25 @@ declare namespace MakerJs.measure {
|
||||
* @returns Boolean true if arc is concave towards point.
|
||||
*/
|
||||
function isArcConcaveTowardsPoint(arc: IPathArc, towardsPoint: IPoint): boolean;
|
||||
/**
|
||||
* Check for arc overlapping another arc.
|
||||
*
|
||||
* @param arcA The arc to test.
|
||||
* @param arcB The arc to check for overlap.
|
||||
* @param excludeTangents Boolean to exclude exact endpoints and only look for deep overlaps.
|
||||
* @returns Boolean true if arc1 is overlapped with arcB.
|
||||
*/
|
||||
function isArcOverlapping(arcA: IPathArc, arcB: IPathArc, excludeTangents: boolean): boolean;
|
||||
/**
|
||||
* Check if a given number is between two given limits.
|
||||
*
|
||||
* @param valueInQuestion The number to test.
|
||||
* @param limit1 First limit.
|
||||
* @param limit2 Second limit.
|
||||
* @param limitA First limit.
|
||||
* @param limitB Second limit.
|
||||
* @param exclusive Flag to exclude equaling the limits.
|
||||
* @returns Boolean true if value is between (or equal to) the limits.
|
||||
*/
|
||||
function isBetween(valueInQuestion: number, limit1: number, limit2: number, exclusive: boolean): boolean;
|
||||
function isBetween(valueInQuestion: number, limitA: number, limitB: number, exclusive: boolean): boolean;
|
||||
/**
|
||||
* Check if a given angle is between an arc's start and end angles.
|
||||
*
|
||||
@@ -951,6 +1311,27 @@ declare namespace MakerJs.measure {
|
||||
* @returns Boolean true if point is between (or equal to) the line's origin and end points.
|
||||
*/
|
||||
function isBetweenPoints(pointInQuestion: IPoint, line: IPathLine, exclusive: boolean): boolean;
|
||||
/**
|
||||
* Check for line overlapping another line.
|
||||
*
|
||||
* @param lineA The line to test.
|
||||
* @param lineB The line to check for overlap.
|
||||
* @param excludeTangents Boolean to exclude exact endpoints and only look for deep overlaps.
|
||||
* @returns Boolean true if line1 is overlapped with lineB.
|
||||
*/
|
||||
function isLineOverlapping(lineA: IPathLine, lineB: IPathLine, excludeTangents: boolean): boolean;
|
||||
/**
|
||||
* Check for measurement overlapping another measurement.
|
||||
*
|
||||
* @param measureA The measurement to test.
|
||||
* @param measureB The measurement to check for overlap.
|
||||
* @returns Boolean true if measure1 is overlapped with measureB.
|
||||
*/
|
||||
function isMeasurementOverlapping(measureA: IMeasure, measureB: IMeasure): boolean;
|
||||
/**
|
||||
* Gets the slope of a line.
|
||||
*/
|
||||
function lineSlope(line: IPathLine): ISlope;
|
||||
/**
|
||||
* Calculates the distance between two points.
|
||||
*
|
||||
@@ -965,7 +1346,7 @@ declare namespace MakerJs.measure {
|
||||
* @param pathToMeasure The path to measure.
|
||||
* @returns object with low and high points.
|
||||
*/
|
||||
function pathExtents(pathToMeasure: IPath): IMeasure;
|
||||
function pathExtents(pathToMeasure: IPath, addOffset?: IPoint): IMeasure;
|
||||
/**
|
||||
* Measures the length of a path.
|
||||
*
|
||||
@@ -977,9 +1358,38 @@ declare namespace MakerJs.measure {
|
||||
* Measures the smallest rectangle which contains a model.
|
||||
*
|
||||
* @param modelToMeasure The model to measure.
|
||||
* @param atlas Optional atlas to save measurements.
|
||||
* @returns object with low and high points.
|
||||
*/
|
||||
function modelExtents(modelToMeasure: IModel): IMeasure;
|
||||
function modelExtents(modelToMeasure: IModel, atlas?: measure.Atlas): IMeasure;
|
||||
/**
|
||||
* A list of maps of measurements.
|
||||
*
|
||||
* @param modelToMeasure The model to measure.
|
||||
* @param atlas Optional atlas to save measurements.
|
||||
* @returns object with low and high points.
|
||||
*/
|
||||
class Atlas {
|
||||
modelContext: IModel;
|
||||
/**
|
||||
* Flag that models have been measured.
|
||||
*/
|
||||
modelsMeasured: boolean;
|
||||
/**
|
||||
* Map of model measurements, mapped by routeKey.
|
||||
*/
|
||||
modelMap: IMeasureMap;
|
||||
/**
|
||||
* Map of path measurements, mapped by routeKey.
|
||||
*/
|
||||
pathMap: IMeasureMap;
|
||||
/**
|
||||
* Constructor.
|
||||
* @param modelContext The model to measure.
|
||||
*/
|
||||
constructor(modelContext: IModel);
|
||||
measureModels(): void;
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.exporter {
|
||||
/**
|
||||
@@ -1050,12 +1460,12 @@ declare namespace MakerJs.solvers {
|
||||
/**
|
||||
* Solves for the angle of a triangle when you know lengths of 3 sides.
|
||||
*
|
||||
* @param length1 Length of side of triangle, opposite of the angle you are trying to find.
|
||||
* @param length2 Length of any other side of the triangle.
|
||||
* @param length3 Length of the remaining side of the triangle.
|
||||
* @param lengthA Length of side of triangle, opposite of the angle you are trying to find.
|
||||
* @param lengthB Length of any other side of the triangle.
|
||||
* @param lengthC Length of the remaining side of the triangle.
|
||||
* @returns Angle opposite of the side represented by the first parameter.
|
||||
*/
|
||||
function solveTriangleSSS(length1: number, length2: number, length3: number): number;
|
||||
function solveTriangleSSS(lengthA: number, lengthB: number, lengthC: number): number;
|
||||
/**
|
||||
* Solves for the length of a side of a triangle when you know length of one side and 2 angles.
|
||||
*
|
||||
@@ -1076,33 +1486,24 @@ declare namespace MakerJs.path {
|
||||
* @returns IPathIntersection object, with points(s) of intersection (and angles, when a path is an arc or circle); or null if the paths did not intersect.
|
||||
*/
|
||||
function intersection(path1: IPath, path2: IPath, options?: IPathIntersectionOptions): IPathIntersection;
|
||||
/**
|
||||
* Calculates the intersection of slopes of two lines.
|
||||
*
|
||||
* @param line1 First line to use for slope.
|
||||
* @param line2 Second line to use for slope.
|
||||
* @param options Optional IPathIntersectionOptions.
|
||||
* @returns point of intersection of the two slopes, or null if the slopes did not intersect.
|
||||
*/
|
||||
function slopeIntersectionPoint(line1: IPathLine, line2: IPathLine, options?: IPathIntersectionOptions): IPoint;
|
||||
}
|
||||
declare namespace MakerJs.path {
|
||||
/**
|
||||
* Adds a round corner to the outside angle between 2 lines. The lines must meet at one point.
|
||||
*
|
||||
* @param line1 First line to fillet, which will be modified to fit the fillet.
|
||||
* @param line2 Second line to fillet, which will be modified to fit the fillet.
|
||||
* @param lineA First line to fillet, which will be modified to fit the fillet.
|
||||
* @param lineB Second line to fillet, which will be modified to fit the fillet.
|
||||
* @returns Arc path object of the new fillet.
|
||||
*/
|
||||
function dogbone(line1: IPathLine, line2: IPathLine, filletRadius: number, options?: IPointMatchOptions): IPathArc;
|
||||
function dogbone(lineA: IPathLine, lineB: IPathLine, filletRadius: number, options?: IPointMatchOptions): IPathArc;
|
||||
/**
|
||||
* Adds a round corner to the inside angle between 2 paths. The paths must meet at one point.
|
||||
*
|
||||
* @param path1 First path to fillet, which will be modified to fit the fillet.
|
||||
* @param path2 Second path to fillet, which will be modified to fit the fillet.
|
||||
* @param pathA First path to fillet, which will be modified to fit the fillet.
|
||||
* @param pathB Second path to fillet, which will be modified to fit the fillet.
|
||||
* @returns Arc path object of the new fillet.
|
||||
*/
|
||||
function fillet(path1: IPath, path2: IPath, filletRadius: number, options?: IPointMatchOptions): IPathArc;
|
||||
function fillet(pathA: IPath, pathB: IPath, filletRadius: number, options?: IPointMatchOptions): IPathArc;
|
||||
}
|
||||
declare namespace MakerJs.kit {
|
||||
/**
|
||||
@@ -1123,22 +1524,15 @@ declare namespace MakerJs.kit {
|
||||
}
|
||||
declare namespace MakerJs.model {
|
||||
/**
|
||||
* @private
|
||||
* Find paths that have common endpoints and form chains.
|
||||
*
|
||||
* @param modelContext The model to search for chains.
|
||||
* @param options Optional options object.
|
||||
* @returns A list of chains.
|
||||
*/
|
||||
interface IPointMappedItem<T> {
|
||||
averagePoint: IPoint;
|
||||
item: T;
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
class PointMap<T> {
|
||||
matchingDistance: number;
|
||||
list: IPointMappedItem<T>[];
|
||||
constructor(matchingDistance?: number);
|
||||
add(pointToAdd: IPoint, item: T): void;
|
||||
find(pointToFind: IPoint, saveAverage: boolean): T;
|
||||
}
|
||||
function findChains(modelContext: IModel, callback: IChainCallback, options?: IFindChainsOptions): void;
|
||||
}
|
||||
declare namespace MakerJs.model {
|
||||
/**
|
||||
* Find paths that have common endpoints and form loops.
|
||||
*
|
||||
@@ -1153,7 +1547,14 @@ declare namespace MakerJs.model {
|
||||
* @param loopToDetach The model to search for loops.
|
||||
*/
|
||||
function detachLoop(loopToDetach: IModel): void;
|
||||
function removeDeadEnds(modelContext: IModel, pointMatchingDistance?: number): void;
|
||||
/**
|
||||
* Remove paths from a model which have endpoints that do not connect to other paths.
|
||||
*
|
||||
* @param modelContext The model to search for dead ends.
|
||||
* @param options Optional options object.
|
||||
* @returns The input model (for chaining).
|
||||
*/
|
||||
function removeDeadEnds(modelContext: IModel, pointMatchingDistance?: number): IModel;
|
||||
}
|
||||
declare namespace MakerJs.exporter {
|
||||
/**
|
||||
@@ -1249,6 +1650,37 @@ declare namespace MakerJs.exporter {
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.exporter {
|
||||
/**
|
||||
* Injects drawing into a PDFKit document.
|
||||
*
|
||||
* @param modelToExport Model object to export.
|
||||
* @param options Export options object.
|
||||
* @returns String of PDF file contents.
|
||||
*/
|
||||
function toPDF(doc: PDFKit.PDFDocument, modelToExport: IModel, options?: IPDFRenderOptions): void;
|
||||
/**
|
||||
* PDF rendering options.
|
||||
*/
|
||||
interface IPDFRenderOptions extends IExportOptions {
|
||||
/**
|
||||
* Rendered reference origin.
|
||||
*/
|
||||
origin?: IPoint;
|
||||
/**
|
||||
* SVG color of the rendered paths.
|
||||
*/
|
||||
stroke?: string;
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.exporter {
|
||||
/**
|
||||
* Convert a chain to SVG path data.
|
||||
*/
|
||||
function chainToSVGPathData(chain: IChain, offset: IPoint): string;
|
||||
/**
|
||||
* Convert a path to SVG path data.
|
||||
*/
|
||||
function pathToSVGPathData(pathToExport: IPath, offset: IPoint, offset2: IPoint): string;
|
||||
function toSVG(modelToExport: IModel, options?: ISVGRenderOptions): string;
|
||||
function toSVG(pathsToExport: IPath[], options?: ISVGRenderOptions): string;
|
||||
function toSVG(pathToExport: IPath, options?: ISVGRenderOptions): string;
|
||||
@@ -1273,6 +1705,10 @@ declare namespace MakerJs.exporter {
|
||||
* Optional attributes to add to the root svg tag.
|
||||
*/
|
||||
svgAttrs?: IXmlTagAttrs;
|
||||
/**
|
||||
* SVG fill color.
|
||||
*/
|
||||
fill?: string;
|
||||
/**
|
||||
* SVG font size and font size units.
|
||||
*/
|
||||
@@ -1314,9 +1750,11 @@ declare namespace MakerJs.models {
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.models {
|
||||
class Polygon extends ConnectTheDots {
|
||||
constructor(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number);
|
||||
static getPoints(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number): IPoint[];
|
||||
class Polygon implements IModel {
|
||||
paths: IPathMap;
|
||||
constructor(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number, circumscribed?: boolean);
|
||||
static circumscribedRadius(radius: number, angleInRadians: number): number;
|
||||
static getPoints(numberOfSides: number, radius: number, firstCornerAngleInDegrees?: number, circumscribed?: boolean): IPoint[];
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.models {
|
||||
@@ -1344,19 +1782,24 @@ declare namespace MakerJs.models {
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.models {
|
||||
class Oval extends RoundRectangle {
|
||||
class Oval implements IModel {
|
||||
paths: IPathMap;
|
||||
constructor(width: number, height: number);
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.models {
|
||||
class OvalArc implements IModel {
|
||||
paths: IPathMap;
|
||||
constructor(startAngle: number, endAngle: number, sweepRadius: number, slotRadius: number, selfIntersect?: boolean);
|
||||
models: IModelMap;
|
||||
constructor(startAngle: number, endAngle: number, sweepRadius: number, slotRadius: number, selfIntersect?: boolean, isolateCaps?: boolean);
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.models {
|
||||
class Rectangle extends ConnectTheDots {
|
||||
class Rectangle implements IModel {
|
||||
paths: IPathMap;
|
||||
origin: IPoint;
|
||||
constructor(width: number, height: number);
|
||||
constructor(measurement: IMeasure);
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.models {
|
||||
@@ -1375,11 +1818,13 @@ declare namespace MakerJs.models {
|
||||
class Slot implements IModel {
|
||||
paths: IPathMap;
|
||||
origin: IPoint;
|
||||
constructor(origin: IPoint, endPoint: IPoint, radius: number);
|
||||
models: IModelMap;
|
||||
constructor(origin: IPoint, endPoint: IPoint, radius: number, isolateCaps?: boolean);
|
||||
}
|
||||
}
|
||||
declare namespace MakerJs.models {
|
||||
class Square extends Rectangle {
|
||||
class Square implements IModel {
|
||||
paths: IPathMap;
|
||||
constructor(side: number);
|
||||
}
|
||||
}
|
||||
|
||||
+55
-2
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import morgan = require('morgan');
|
||||
import express = require('express');
|
||||
|
||||
// a pre-defined name
|
||||
morgan('combined')
|
||||
@@ -15,8 +16,8 @@ morgan('tiny')
|
||||
morgan(':remote-addr :method :url')
|
||||
|
||||
// a custom function
|
||||
morgan(function (req, res) {
|
||||
return req.method + ' ' + req.url
|
||||
morgan(function (tokens, req, res) {
|
||||
return req.method + ' ' + req.url + ' ' + tokens['date'](req, res, 'iso'); // use predefined :date[iso] token with format argument
|
||||
})
|
||||
|
||||
morgan('combined', {
|
||||
@@ -29,3 +30,55 @@ morgan('combined', {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// test interface definition for morgan
|
||||
var morgan2 : morgan.Morgan = morgan;
|
||||
|
||||
// a named custom format defined as string (example: extend 'tiny' format with user-agent token)
|
||||
morgan.format('tiny-extended', ':method :url :status :res[content-length] - :response-time ms :user-agent');
|
||||
|
||||
|
||||
// a named custom format defined using the Function signature (example: extend 'dev' format with user-agent token)
|
||||
|
||||
// extend morgan.FormatFn interface with memoizer property to avoid unnecessary re-compiling
|
||||
// of status-code range driven colorized format functions
|
||||
interface IFormatFnIndexer {
|
||||
[memoizerName: string]: morgan.FormatFn;
|
||||
}
|
||||
|
||||
interface IExtendedFormatFn extends morgan.FormatFn {
|
||||
memoizer?: IFormatFnIndexer;
|
||||
}
|
||||
|
||||
|
||||
var developmentExtendedFormatLine : IExtendedFormatFn = function(tokens, req, res):string {
|
||||
|
||||
// get the status code if response written
|
||||
var status = res.statusCode
|
||||
? res.statusCode
|
||||
: undefined;
|
||||
|
||||
// get status color
|
||||
var color = status >= 500 ? 31 // red
|
||||
: status >= 400 ? 33 // yellow
|
||||
: status >= 300 ? 36 // cyan
|
||||
: status >= 200 ? 32 // green
|
||||
: 0; // no color
|
||||
|
||||
// get colored format function, if previously memoized, otherwise undefined
|
||||
var fn: morgan.FormatFn = developmentExtendedFormatLine.memoizer[color];
|
||||
|
||||
if (!fn) {
|
||||
// compile
|
||||
fn = developmentExtendedFormatLine.memoizer[color] = morgan.compile('\x1b[0m:method :url \x1b['
|
||||
+ color + 'm:status \x1b[0m:response-time ms - :res[content-length]\x1b[0m :user-agent');
|
||||
}
|
||||
|
||||
return fn(tokens, req, res);
|
||||
};
|
||||
|
||||
developmentExtendedFormatLine.memoizer = {};
|
||||
|
||||
|
||||
morgan.format('dev-extended', developmentExtendedFormatLine);
|
||||
|
||||
Vendored
+118
-4
@@ -1,4 +1,4 @@
|
||||
// Type definitions for morgan 1.2.2
|
||||
// Type definitions for morgan 1.7.0
|
||||
// Project: https://github.com/expressjs/morgan
|
||||
// Definitions by: James Roland Cabresos <https://github.com/staticfunction>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -10,7 +10,114 @@ declare module "morgan" {
|
||||
|
||||
namespace morgan {
|
||||
|
||||
export function token<T>(name: string, callback: (req: express.Request, res: express.Response) => T): express.RequestHandler;
|
||||
export interface FormatFn extends Function {
|
||||
(tokens: TokenIndexer, req: express.Request, res: express.Response): string;
|
||||
}
|
||||
|
||||
export interface TokenCallbackFn extends Function {
|
||||
(req: express.Request, res: express.Response, arg?: string | number | boolean): string;
|
||||
}
|
||||
|
||||
export interface TokenIndexer {
|
||||
[tokenName: string]: TokenCallbackFn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public interface of morgan logger
|
||||
*/
|
||||
export interface Morgan {
|
||||
/***
|
||||
* Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names),
|
||||
* or a string of a format string containing defined tokens.
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
(format: string, options?: Options): express.RequestHandler;
|
||||
/***
|
||||
* Standard Apache combined log output.
|
||||
* :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent"
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
(format: 'combined', options?: Options): express.RequestHandler;
|
||||
/***
|
||||
* Standard Apache common log output.
|
||||
* :remote-addr - :remote-user [:date] ":method :url HTTP/:http-version" :status :res[content-length]
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
(format: 'common', options?: Options): express.RequestHandler;
|
||||
/**
|
||||
* Concise output colored by response status for development use. The :status token will be colored red for server error codes, yellow for client error codes, cyan for redirection codes, and uncolored for all other codes.
|
||||
* :method :url :status :response-time ms - :res[content-length]
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
(format: 'dev', options?: Options): express.RequestHandler;
|
||||
|
||||
/***
|
||||
* Shorter than default, also including response time.
|
||||
* :remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
(format: 'short', options?: Options): express.RequestHandler;
|
||||
|
||||
/***
|
||||
* The minimal output.
|
||||
* :method :url :status :res[content-length] - :response-time ms
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
(format: 'tiny', options?: Options): express.RequestHandler;
|
||||
|
||||
/***
|
||||
* Create a new morgan logger middleware function using the given format and options. The format argument may be a
|
||||
* custom format function which adheres to the signature.
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
(format: FormatFn, options?: Options): express.RequestHandler;
|
||||
|
||||
/**
|
||||
* Define a custom token which can be used in custom morgan logging formats.
|
||||
*/
|
||||
token(name: string, callback: TokenCallbackFn): Morgan;
|
||||
/**
|
||||
* Define a named custom format by specifying a format string in token notation
|
||||
*/
|
||||
format(name: string, fmt: string): Morgan;
|
||||
|
||||
/**
|
||||
* Define a named custom format by specifying a format function
|
||||
*/
|
||||
format(name: string, fmt: FormatFn): Morgan;
|
||||
|
||||
/**
|
||||
* Compile a format string in token notation into a format function
|
||||
*/
|
||||
compile(format: string): FormatFn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a custom token which can be used in custom morgan logging formats.
|
||||
*/
|
||||
export function token(name: string, callback: TokenCallbackFn): Morgan;
|
||||
|
||||
/**
|
||||
* Define a named custom format by specifying a format string in token notation
|
||||
*/
|
||||
export function format(name: string, fmt: string): Morgan;
|
||||
|
||||
/**
|
||||
* Define a named custom format by specifying a format function
|
||||
*/
|
||||
export function format(name: string, fmt: FormatFn): Morgan;
|
||||
|
||||
/**
|
||||
* Compile a format string in token notation into a format function
|
||||
*/
|
||||
export function compile(format: string): FormatFn;
|
||||
|
||||
export interface StreamOptions {
|
||||
/**
|
||||
@@ -48,7 +155,8 @@ declare module "morgan" {
|
||||
}
|
||||
|
||||
/***
|
||||
* Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names), a string of a format string, or a function that will produce a log entry.
|
||||
* Create a new morgan logger middleware function using the given format and options. The format argument may be a string of a predefined name (see below for the names),
|
||||
* or a string of a format string containing defined tokens.
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
@@ -94,7 +202,13 @@ declare module "morgan" {
|
||||
*/
|
||||
function morgan(format: 'tiny', options?: morgan.Options): express.RequestHandler;
|
||||
|
||||
function morgan(custom: (req: express.Request, res: express.Response) => string): express.RequestHandler
|
||||
/***
|
||||
* Create a new morgan logger middleware function using the given format and options. The format argument may be a
|
||||
* custom format function which adheres to the signature.
|
||||
* @param format
|
||||
* @param options
|
||||
*/
|
||||
function morgan(format: morgan.FormatFn, options?: morgan.Options): express.RequestHandler
|
||||
|
||||
export = morgan;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ assert.notStrictEqual(2, "2", "uses === comparator");
|
||||
assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT");
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
if (false) { throw "a hammer at your face"; }
|
||||
const b = false;
|
||||
if (b) { throw "a hammer at your face"; }
|
||||
}, undefined, "What the...*crunch*");
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
@@ -26,7 +26,8 @@ assert.notStrictEqual(2, "2", "uses === comparator");
|
||||
assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT");
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
if (false) { throw "a hammer at your face"; }
|
||||
const b = false;
|
||||
if (b) { throw "a hammer at your face"; }
|
||||
}, undefined, "What the...*crunch*");
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Vendored
+1
-1
@@ -465,7 +465,7 @@ interface NodeBuffer extends Uint8Array {
|
||||
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
fill(value: any, offset?: number, end?: number): Buffer;
|
||||
fill(value: any, offset?: number, end?: number): this;
|
||||
// TODO: encoding param
|
||||
indexOf(value: string | number | Buffer, byteOffset?: number): number;
|
||||
// TODO: entries
|
||||
|
||||
Vendored
+1
-1
@@ -465,7 +465,7 @@ interface NodeBuffer extends Uint8Array {
|
||||
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
fill(value: any, offset?: number, end?: number): Buffer;
|
||||
fill(value: any, offset?: number, end?: number): this;
|
||||
// TODO: encoding param
|
||||
indexOf(value: string | number | Buffer, byteOffset?: number): number;
|
||||
// TODO: entries
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/// <reference path="react-ga.d.ts" />
|
||||
/// <reference path="../jasmine/jasmine.d.ts" />
|
||||
|
||||
describe("Testing react-ga initialize object", () => {
|
||||
it("Able to initialize react-ga object", () => {
|
||||
let ga = __reactGA;
|
||||
ga.initialize("UA-65432-1");
|
||||
});
|
||||
it("Able to initailize react-ga object", () => {
|
||||
let ga = __reactGA;
|
||||
|
||||
let options: __reactGA.InitializeOptions = {
|
||||
debug: true,
|
||||
}
|
||||
|
||||
ga.initialize("UA-65432-1", options);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Testing react-ga pageview calls", () => {
|
||||
it("Able to make pageview calls", () => {
|
||||
let ga = __reactGA;
|
||||
ga.initialize("UA-65432-1");
|
||||
|
||||
ga.pageview("http://telshin.com");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Testing react-ga modal calls", () => {
|
||||
it("Able to make modal calls", () => {
|
||||
let ga = __reactGA;
|
||||
ga.initialize("UA-65432-1");
|
||||
|
||||
ga.modalview("Test modal");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Testing react-ga event calls", () => {
|
||||
it("Able to make event calls", () => {
|
||||
let ga = __reactGA;
|
||||
ga.initialize("UA-65432-1");
|
||||
|
||||
let options: __reactGA.EventArgs = {
|
||||
category: "Test",
|
||||
action: "CI",
|
||||
label: "Running Jasmine tests for react-ga typscript library",
|
||||
value: 4,
|
||||
nonInteraction: true,
|
||||
}
|
||||
|
||||
ga.event(options);
|
||||
});
|
||||
});
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for react-fa v1.4.1
|
||||
// Project: https://github.com/react-ga/react-ga
|
||||
// Definitions by: Tim Aldridge <https://github.com/telshin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace __reactGA {
|
||||
export interface EventArgs {
|
||||
category: string;
|
||||
action: string;
|
||||
label?: string;
|
||||
value?: number;
|
||||
nonInteraction?: boolean;
|
||||
}
|
||||
|
||||
export interface InitializeOptions {
|
||||
debug?: boolean;
|
||||
}
|
||||
|
||||
export function initialize(trackingCode: string, options?: InitializeOptions): void;
|
||||
export function pageview(path: string): void;
|
||||
export function modalview(name: string): void;
|
||||
export function event(args: EventArgs): void;
|
||||
}
|
||||
|
||||
declare module 'react-ga' {
|
||||
export = __reactGA;
|
||||
}
|
||||
Vendored
+2
-2
@@ -9,7 +9,7 @@
|
||||
|
||||
declare module "redux-bootstrap" {
|
||||
|
||||
interface BoostrapOptions {
|
||||
interface BootstrapOptions {
|
||||
routes: JSX.Element;
|
||||
reducers: ReducersOption;
|
||||
middlewares?: Redux.Middleware[];
|
||||
@@ -27,5 +27,5 @@ declare module "redux-bootstrap" {
|
||||
[index: string]: Redux.Reducer;
|
||||
}
|
||||
|
||||
export default function bootstrap(options: BoostrapOptions): BootstrapResult;
|
||||
export default function bootstrap(options: BootstrapOptions): BootstrapResult;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -110,7 +110,7 @@ declare module 'request' {
|
||||
key?: Buffer;
|
||||
cert?: Buffer;
|
||||
passphrase?: string;
|
||||
ca?: Buffer;
|
||||
ca?: string | Buffer | string[] | Buffer[];
|
||||
har?: HttpArchiveRequest;
|
||||
useQuerystring?: boolean;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -82,7 +82,7 @@ interface ResponseInit {
|
||||
}
|
||||
|
||||
declare type HeaderInit = Headers|Array<string>;
|
||||
declare type BodyInit = Blob|FormData|string;
|
||||
declare type BodyInit = ArrayBuffer|ArrayBufferView|Blob|FormData|string;
|
||||
declare type RequestInfo = Request|string;
|
||||
|
||||
interface Window {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
///<reference path="wolfy87-eventemitter.d.ts"/>
|
||||
/// <reference path="./wolfy87-eventemitter.d.ts" />
|
||||
|
||||
import EventEmitter = require("wolfy87-eventemitter");
|
||||
import * as EventEmitter from 'wolfy87-eventemitter';
|
||||
|
||||
var emitter = new EventEmitter();
|
||||
|
||||
@@ -108,4 +108,3 @@ function testNoConflict() {
|
||||
var NoConflictEventEmitter = EventEmitter.noConflict();
|
||||
var e: Wolfy87EventEmitter.EventEmitter = new NoConflictEventEmitter();
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -9,7 +9,7 @@ declare namespace Wolfy87EventEmitter {
|
||||
* Hash Object for manipulating multiple events.
|
||||
*/
|
||||
interface MultipleEvents {
|
||||
[event:string]: any //Function | Function[]
|
||||
[event: string]: any //Function | Function[]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,6 +506,7 @@ declare namespace Wolfy87EventEmitter {
|
||||
|
||||
declare module "wolfy87-eventemitter" {
|
||||
class EventEmitter extends Wolfy87EventEmitter.EventEmitter {}
|
||||
namespace EventEmitter {}
|
||||
export = EventEmitter;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user