From 8a33d5322850ef83ba0c68fb3a9e34cb95d52277 Mon Sep 17 00:00:00 2001 From: Mattijs Kneppers Date: Mon, 18 Jul 2016 17:17:27 +0200 Subject: [PATCH 01/47] Add stronger typed version of gl-matrix definitions. Also contains all methods of gl-matrix available on 18 july 2016. No tests yet. --- gl-matrix/gl-matrix-typed.d.ts | 3063 ++++++++++++++++++++++++++++++++ 1 file changed, 3063 insertions(+) create mode 100644 gl-matrix/gl-matrix-typed.d.ts diff --git a/gl-matrix/gl-matrix-typed.d.ts b/gl-matrix/gl-matrix-typed.d.ts new file mode 100644 index 0000000000..f64225c6f7 --- /dev/null +++ b/gl-matrix/gl-matrix-typed.d.ts @@ -0,0 +1,3063 @@ +// Type definitions for gl-matrix 2.2.2 +// Project: https://github.com/toji/gl-matrix +// Definitions by: Tat +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Common +declare namespace glMatrix { + /** + * Convert Degree To Radian + * + * @param a Angle in Degrees + */ + export function toRadian(a: number): number; +} + +// vec2 +export class vec2 extends Float32Array { + private typeVec2:number; + + /** + * Creates a new, empty vec2 + * + * @returns a new 2D vector + */ + public static create(): vec2; + + /** + * Creates a new vec2 initialized with values from an existing vector + * + * @param a a vector to clone + * @returns a new 2D vector + */ + public static clone(a: vec2): vec2; + + /** + * Creates a new vec2 initialized with the given values + * + * @param x X component + * @param y Y component + * @returns a new 2D vector + */ + public static fromValues(x: number, y: number): vec2; + + /** + * Copy the values from one vec2 to another + * + * @param out the receiving vector + * @param a the source vector + * @returns out + */ + public static copy(out: vec2, a: vec2): vec2; + + /** + * Set the components of a vec2 to the given values + * + * @param out the receiving vector + * @param x X component + * @param y Y component + * @returns out + */ + public static set(out: vec2, x: number, y: number): vec2; + + /** + * Adds two vec2's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static add(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Subtracts vector b from vector a + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static subtract(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Subtracts vector b from vector a + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static sub(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Multiplies two vec2's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static multiply(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Multiplies two vec2's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static mul(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Divides two vec2's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static divide(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Divides two vec2's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static div(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Math.ceil the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to ceil + * @returns {vec2} out + */ + public static ceil(out:vec2, a:vec2):vec2; + + /** + * Math.floor the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to floor + * @returns {vec2} out + */ + public static floor (out:vec2, a:vec2):vec2; + + /** + * Returns the minimum of two vec2's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static min(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Returns the maximum of two vec2's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static max(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Math.round the components of a vec2 + * + * @param {vec2} out the receiving vector + * @param {vec2} a vector to round + * @returns {vec2} out + */ + public static round(out:vec2, a:vec2):vec2; + + + /** + * Scales a vec2 by a scalar number + * + * @param out the receiving vector + * @param a the vector to scale + * @param b amount to scale the vector by + * @returns out + */ + public static scale(out: vec2, a: vec2, b: number): vec2; + + /** + * Adds two vec2's after scaling the second operand by a scalar value + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @param scale the amount to scale b by before adding + * @returns out + */ + public static scaleAndAdd(out: vec2, a: vec2, b: vec2, scale: number): vec2; + + /** + * Calculates the euclidian distance between two vec2's + * + * @param a the first operand + * @param b the second operand + * @returns distance between a and b + */ + public static distance(a: vec2, b: vec2): number; + + /** + * Calculates the euclidian distance between two vec2's + * + * @param a the first operand + * @param b the second operand + * @returns distance between a and b + */ + public static dist(a: vec2, b: vec2): number; + + /** + * Calculates the squared euclidian distance between two vec2's + * + * @param a the first operand + * @param b the second operand + * @returns squared distance between a and b + */ + public static squaredDistance(a: vec2, b: vec2): number; + + /** + * Calculates the squared euclidian distance between two vec2's + * + * @param a the first operand + * @param b the second operand + * @returns squared distance between a and b + */ + public static sqrDist(a: vec2, b: vec2): number; + + /** + * Calculates the length of a vec2 + * + * @param a vector to calculate length of + * @returns length of a + */ + public static length(a: vec2): number; + + /** + * Calculates the length of a vec2 + * + * @param a vector to calculate length of + * @returns length of a + */ + public static len(a: vec2): number; + + /** + * Calculates the squared length of a vec2 + * + * @param a vector to calculate squared length of + * @returns squared length of a + */ + public static squaredLength(a: vec2): number; + + /** + * Calculates the squared length of a vec2 + * + * @param a vector to calculate squared length of + * @returns squared length of a + */ + public static sqrLen(a: vec2): number; + + /** + * Negates the components of a vec2 + * + * @param out the receiving vector + * @param a vector to negate + * @returns out + */ + public static negate(out: vec2, a: vec2): vec2; + + /** + * Returns the inverse of the components of a vec2 + * + * @param out the receiving vector + * @param a vector to invert + * @returns out + */ + public static inverse(out: vec2, a: vec2): vec2; + + /** + * Normalize a vec2 + * + * @param out the receiving vector + * @param a vector to normalize + * @returns out + */ + public static normalize(out: vec2, a: vec2): vec2; + + /** + * Calculates the dot product of two vec2's + * + * @param a the first operand + * @param b the second operand + * @returns dot product of a and b + */ + public static dot(a: vec2, b: vec2): number; + + /** + * Computes the cross product of two vec2's + * Note that the cross product must by definition produce a 3D vector + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static cross(out: vec2, a: vec2, b: vec2): vec2; + + /** + * Performs a linear interpolation between two vec2's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @param t interpolation amount between the two inputs + * @returns out + */ + public static lerp(out: vec2, a: vec2, b: vec2, t: number): vec2; + + /** + * Generates a random unit vector + * + * @param out the receiving vector + * @returns out + */ + public static random(out: vec2): vec2; + + /** + * Generates a random vector with the given scale + * + * @param out the receiving vector + * @param scale Length of the resulting vector. If ommitted, a unit vector will be returned + * @returns out + */ + public static random(out: vec2, scale: number): vec2; + + /** + * Transforms the vec2 with a mat2 + * + * @param out the receiving vector + * @param a the vector to transform + * @param m matrix to transform with + * @returns out + */ + public static transformMat2(out: vec2, a: vec2, m: mat2): vec2; + + /** + * Transforms the vec2 with a mat2d + * + * @param out the receiving vector + * @param a the vector to transform + * @param m matrix to transform with + * @returns out + */ + public static transformMat2d(out: vec2, a: vec2, m: mat2d): vec2; + + /** + * Transforms the vec2 with a mat3 + * 3rd vector component is implicitly '1' + * + * @param out the receiving vector + * @param a the vector to transform + * @param m matrix to transform with + * @returns out + */ + public static transformMat3(out: vec2, a: vec2, m: mat3): vec2; + + /** + * Transforms the vec2 with a mat4 + * 3rd vector component is implicitly '0' + * 4th vector component is implicitly '1' + * + * @param out the receiving vector + * @param a the vector to transform + * @param m matrix to transform with + * @returns out + */ + public static transformMat4(out: vec2, a: vec2, m: mat4): vec2; + + /** + * Perform some operation over an array of vec2s. + * + * @param a the array of vectors to iterate over + * @param stride Number of elements between the start of each vec2. If 0 assumes tightly packed + * @param offset Number of elements to skip at the beginning of the array + * @param count Number of vec2s to iterate over. If 0 iterates over entire array + * @param fn Function to call for each vector in the array + * @param arg additional argument to pass to fn + * @returns a + */ + public static forEach(a: vec2, stride: number, offset: number, count: number, + fn: (a: vec2, b: vec2, arg: any) => void, arg: any): vec2; + + /** + * Perform some operation over an array of vec2s. + * + * @param a the array of vectors to iterate over + * @param stride Number of elements between the start of each vec2. If 0 assumes tightly packed + * @param offset Number of elements to skip at the beginning of the array + * @param count Number of vec2s to iterate over. If 0 iterates over entire array + * @param fn Function to call for each vector in the array + * @returns a + */ + public static forEach(a: vec2, stride: number, offset: number, count: number, + fn: (a: vec2, b: vec2) => void): vec2; + + /** + * Returns a string representation of a vector + * + * @param a vector to represent as a string + * @returns string representation of the vector + */ + public static str(a: vec2): string; + + /** + * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) + * + * @param {vec2} a The first vector. + * @param {vec2} b The second vector. + * @returns {boolean} True if the vectors are equal, false otherwise. + */ + public static exactEquals (a:vec2, b:vec2): boolean; + + /** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {vec2} a The first vector. + * @param {vec2} b The second vector. + * @returns {boolean} True if the vectors are equal, false otherwise. + */ + public static equals (a:vec2, b:vec2) : boolean; +} + +// vec3 +export class vec3 extends Float32Array { + private typeVec3:number; + + /** + * Creates a new, empty vec3 + * + * @returns a new 3D vector + */ + public static create(): vec3; + + /** + * Creates a new vec3 initialized with values from an existing vector + * + * @param a vector to clone + * @returns a new 3D vector + */ + public static clone(a: vec3): vec3; + + /** + * Creates a new vec3 initialized with the given values + * + * @param x X component + * @param y Y component + * @param z Z component + * @returns a new 3D vector + */ + public static fromValues(x: number, y: number, z: number): vec3; + + /** + * Copy the values from one vec3 to another + * + * @param out the receiving vector + * @param a the source vector + * @returns out + */ + public static copy(out: vec3, a: vec3): vec3; + + /** + * Set the components of a vec3 to the given values + * + * @param out the receiving vector + * @param x X component + * @param y Y component + * @param z Z component + * @returns out + */ + public static set(out: vec3, x: number, y: number, z: number): vec3; + + /** + * Adds two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static add(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Subtracts vector b from vector a + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static subtract(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Subtracts vector b from vector a + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static sub(out: vec3, a: vec3, b: vec3): vec3 + + /** + * Multiplies two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static multiply(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Multiplies two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static mul(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Divides two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static divide(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Divides two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static div(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Math.ceil the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to ceil + * @returns {vec3} out + */ + public static ceil (out:vec3, a:vec3) : vec3; + + /** + * Math.floor the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to floor + * @returns {vec3} out + */ + public static floor (out:vec3, a:vec3) :vec3; + + /** + * Returns the minimum of two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static min(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Returns the maximum of two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static max(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Math.round the components of a vec3 + * + * @param {vec3} out the receiving vector + * @param {vec3} a vector to round + * @returns {vec3} out + */ + public static round (out:vec3, a:vec3) : vec3 + + /** + * Scales a vec3 by a scalar number + * + * @param out the receiving vector + * @param a the vector to scale + * @param b amount to scale the vector by + * @returns out + */ + public static scale(out: vec3, a: vec3, b: number): vec3; + + /** + * Adds two vec3's after scaling the second operand by a scalar value + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @param scale the amount to scale b by before adding + * @returns out + */ + public static scaleAndAdd(out: vec3, a: vec3, b: vec3, scale: number): vec3; + + /** + * Calculates the euclidian distance between two vec3's + * + * @param a the first operand + * @param b the second operand + * @returns distance between a and b + */ + public static distance(a: vec3, b: vec3): number; + + /** + * Calculates the euclidian distance between two vec3's + * + * @param a the first operand + * @param b the second operand + * @returns distance between a and b + */ + public static dist(a: vec3, b: vec3): number; + + /** + * Calculates the squared euclidian distance between two vec3's + * + * @param a the first operand + * @param b the second operand + * @returns squared distance between a and b + */ + public static squaredDistance(a: vec3, b: vec3): number; + + /** + * Calculates the squared euclidian distance between two vec3's + * + * @param a the first operand + * @param b the second operand + * @returns squared distance between a and b + */ + public static sqrDist(a: vec3, b: vec3): number; + + /** + * Calculates the length of a vec3 + * + * @param a vector to calculate length of + * @returns length of a + */ + public static length(a: vec3): number; + + /** + * Calculates the length of a vec3 + * + * @param a vector to calculate length of + * @returns length of a + */ + public static len(a: vec3): number; + + /** + * Calculates the squared length of a vec3 + * + * @param a vector to calculate squared length of + * @returns squared length of a + */ + public static squaredLength(a: vec3): number; + + /** + * Calculates the squared length of a vec3 + * + * @param a vector to calculate squared length of + * @returns squared length of a + */ + public static sqrLen(a: vec3): number; + + /** + * Negates the components of a vec3 + * + * @param out the receiving vector + * @param a vector to negate + * @returns out + */ + public static negate(out: vec3, a: vec3): vec3; + + /** + * Returns the inverse of the components of a vec3 + * + * @param out the receiving vector + * @param a vector to invert + * @returns out + */ + public static inverse(out: vec3, a: vec3): vec3; + + /** + * Normalize a vec3 + * + * @param out the receiving vector + * @param a vector to normalize + * @returns out + */ + public static normalize(out: vec3, a: vec3): vec3; + + /** + * Calculates the dot product of two vec3's + * + * @param a the first operand + * @param b the second operand + * @returns dot product of a and b + */ + public static dot(a: vec3, b: vec3): number; + + /** + * Computes the cross product of two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static cross(out: vec3, a: vec3, b: vec3): vec3; + + /** + * Performs a linear interpolation between two vec3's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @param t interpolation amount between the two inputs + * @returns out + */ + public static lerp(out: vec3, a: vec3, b: vec3, t: number): vec3; + + /** + * Performs a hermite interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {vec3} c the third operand + * @param {vec3} d the fourth operand + * @param {number} t interpolation amount between the two inputs + * @returns {vec3} out + */ + public static hermite (out:vec3, a:vec3, b:vec3, c:vec3, d:vec3, t:number) : vec3; + + /** + * Performs a bezier interpolation with two control points + * + * @param {vec3} out the receiving vector + * @param {vec3} a the first operand + * @param {vec3} b the second operand + * @param {vec3} c the third operand + * @param {vec3} d the fourth operand + * @param {number} t interpolation amount between the two inputs + * @returns {vec3} out + */ + public static bezier (out:vec3, a:vec3, b:vec3, c:vec3, d:vec3, t:number) :vec3; + + /** + * Generates a random unit vector + * + * @param out the receiving vector + * @returns out + */ + public static random(out: vec3): vec3; + + /** + * Generates a random vector with the given scale + * + * @param out the receiving vector + * @param [scale] Length of the resulting vector. If omitted, a unit vector will be returned + * @returns out + */ + public static random(out: vec3, scale: number): vec3; + + /** + * Transforms the vec3 with a mat3. + * + * @param out the receiving vector + * @param a the vector to transform + * @param m the 3x3 matrix to transform with + * @returns out + */ + public static transformMat3(out: vec3, a: vec3, m: mat3): vec3; + + /** + * Transforms the vec3 with a mat4. + * 4th vector component is implicitly '1' + * + * @param out the receiving vector + * @param a the vector to transform + * @param m matrix to transform with + * @returns out + */ + public static transformMat4(out: vec3, a: vec3, m: mat4): vec3; + + /** + * Transforms the vec3 with a quat + * + * @param out the receiving vector + * @param a the vector to transform + * @param q quaternion to transform with + * @returns out + */ + public static transformQuat(out: vec3, a: vec3, q: quat): vec3; + + + /** + * Rotate a 3D vector around the x-axis + * @param out The receiving vec3 + * @param a The vec3 point to rotate + * @param b The origin of the rotation + * @param c The angle of rotation + * @returns out + */ + public static rotateX(out: vec3, a: vec3, b: vec3, c: number): vec3; + + /** + * Rotate a 3D vector around the y-axis + * @param out The receiving vec3 + * @param a The vec3 point to rotate + * @param b The origin of the rotation + * @param c The angle of rotation + * @returns out + */ + public static rotateY(out: vec3, a: vec3, b: vec3, c: number): vec3; + + /** + * Rotate a 3D vector around the z-axis + * @param out The receiving vec3 + * @param a The vec3 point to rotate + * @param b The origin of the rotation + * @param c The angle of rotation + * @returns out + */ + public static rotateZ(out: vec3, a: vec3, b: vec3, c: number): vec3; + + /** + * Perform some operation over an array of vec3s. + * + * @param a the array of vectors to iterate over + * @param stride Number of elements between the start of each vec3. If 0 assumes tightly packed + * @param offset Number of elements to skip at the beginning of the array + * @param count Number of vec3s to iterate over. If 0 iterates over entire array + * @param fn Function to call for each vector in the array + * @param arg additional argument to pass to fn + * @returns a + * @function + */ + public static forEach(a: vec3, stride: number, offset: number, count: number, + fn: (a: vec3, b: vec3, arg: any) => void, arg: any): vec3; + + /** + * Perform some operation over an array of vec3s. + * + * @param a the array of vectors to iterate over + * @param stride Number of elements between the start of each vec3. If 0 assumes tightly packed + * @param offset Number of elements to skip at the beginning of the array + * @param count Number of vec3s to iterate over. If 0 iterates over entire array + * @param fn Function to call for each vector in the array + * @returns a + * @function + */ + public static forEach(a: vec3, stride: number, offset: number, count: number, + fn: (a: vec3, b: vec3) => void): vec3; + + /** + * Get the angle between two 3D vectors + * @param a The first operand + * @param b The second operand + * @returns The angle in radians + */ + public static angle(a: vec3, b: vec3): number; + + /** + * Returns a string representation of a vector + * + * @param a vector to represent as a string + * @returns string representation of the vector + */ + public static str(a: vec3): string; + + /** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {vec3} a The first vector. + * @param {vec3} b The second vector. + * @returns {boolean} True if the vectors are equal, false otherwise. + */ + public static exactEquals (a, b): boolean + + /** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {vec3} a The first vector. + * @param {vec3} b The second vector. + * @returns {boolean} True if the vectors are equal, false otherwise. + */ + public static equals (a, b) : boolean +} + +// vec4 +export class vec4 extends Float32Array { + private typeVec3:number; + + /** + * Creates a new, empty vec4 + * + * @returns a new 4D vector + */ + public static create(): vec4; + + /** + * Creates a new vec4 initialized with values from an existing vector + * + * @param a vector to clone + * @returns a new 4D vector + */ + public static clone(a: vec4): vec4; + + /** + * Creates a new vec4 initialized with the given values + * + * @param x X component + * @param y Y component + * @param z Z component + * @param w W component + * @returns a new 4D vector + */ + public static fromValues(x: number, y: number, z: number, w: number): vec4; + + /** + * Copy the values from one vec4 to another + * + * @param out the receiving vector + * @param a the source vector + * @returns out + */ + public static copy(out: vec4, a: vec4): vec4; + + /** + * Set the components of a vec4 to the given values + * + * @param out the receiving vector + * @param x X component + * @param y Y component + * @param z Z component + * @param w W component + * @returns out + */ + public static set(out: vec4, x: number, y: number, z: number, w: number): vec4; + + /** + * Adds two vec4's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static add(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Subtracts vector b from vector a + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static subtract(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Subtracts vector b from vector a + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static sub(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Multiplies two vec4's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static multiply(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Multiplies two vec4's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static mul(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Divides two vec4's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static divide(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Divides two vec4's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static div(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Math.ceil the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to ceil + * @returns {vec4} out + */ + public static ceil (out:vec4, a:vec4) : vec4; + + /** + * Math.floor the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to floor + * @returns {vec4} out + */ + public static floor (out:vec4, a:vec4) : vec4; + + /** + * Returns the minimum of two vec4's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static min(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Returns the maximum of two vec4's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static max(out: vec4, a: vec4, b: vec4): vec4; + + /** + * Math.round the components of a vec4 + * + * @param {vec4} out the receiving vector + * @param {vec4} a vector to round + * @returns {vec4} out + */ + public static round (out:vec4, a:vec4): vec4; + + /** + * Scales a vec4 by a scalar number + * + * @param out the receiving vector + * @param a the vector to scale + * @param b amount to scale the vector by + * @returns out + */ + public static scale(out: vec4, a: vec4, b: number): vec4; + + /** + * Adds two vec4's after scaling the second operand by a scalar value + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @param scale the amount to scale b by before adding + * @returns out + */ + public static scaleAndAdd(out: vec4, a: vec4, b: vec4, scale: number): vec4; + + /** + * Calculates the euclidian distance between two vec4's + * + * @param a the first operand + * @param b the second operand + * @returns distance between a and b + */ + public static distance(a: vec4, b: vec4): number; + + /** + * Calculates the euclidian distance between two vec4's + * + * @param a the first operand + * @param b the second operand + * @returns distance between a and b + */ + public static dist(a: vec4, b: vec4): number; + + /** + * Calculates the squared euclidian distance between two vec4's + * + * @param a the first operand + * @param b the second operand + * @returns squared distance between a and b + */ + public static squaredDistance(a: vec4, b: vec4): number; + + /** + * Calculates the squared euclidian distance between two vec4's + * + * @param a the first operand + * @param b the second operand + * @returns squared distance between a and b + */ + public static sqrDist(a: vec4, b: vec4): number; + + /** + * Calculates the length of a vec4 + * + * @param a vector to calculate length of + * @returns length of a + */ + public static length(a: vec4): number; + + /** + * Calculates the length of a vec4 + * + * @param a vector to calculate length of + * @returns length of a + */ + public static len(a: vec4): number; + + /** + * Calculates the squared length of a vec4 + * + * @param a vector to calculate squared length of + * @returns squared length of a + */ + public static squaredLength(a: vec4): number; + + /** + * Calculates the squared length of a vec4 + * + * @param a vector to calculate squared length of + * @returns squared length of a + */ + public static sqrLen(a: vec4): number; + + /** + * Negates the components of a vec4 + * + * @param out the receiving vector + * @param a vector to negate + * @returns out + */ + public static negate(out: vec4, a: vec4): vec4; + + /** + * Returns the inverse of the components of a vec4 + * + * @param out the receiving vector + * @param a vector to invert + * @returns out + */ + public static inverse(out: vec4, a: vec4): vec4; + + /** + * Normalize a vec4 + * + * @param out the receiving vector + * @param a vector to normalize + * @returns out + */ + public static normalize(out: vec4, a: vec4): vec4; + + /** + * Calculates the dot product of two vec4's + * + * @param a the first operand + * @param b the second operand + * @returns dot product of a and b + */ + public static dot(a: vec4, b: vec4): number; + + /** + * Performs a linear interpolation between two vec4's + * + * @param out the receiving vector + * @param a the first operand + * @param b the second operand + * @param t interpolation amount between the two inputs + * @returns out + */ + public static lerp(out: vec4, a: vec4, b: vec4, t: number): vec4; + + /** + * Generates a random unit vector + * + * @param out the receiving vector + * @returns out + */ + public static random(out: vec4): vec4; + + /** + * Generates a random vector with the given scale + * + * @param out the receiving vector + * @param scale length of the resulting vector. If ommitted, a unit vector will be returned + * @returns out + */ + public static random(out: vec4, scale: number): vec4; + + /** + * Transforms the vec4 with a mat4. + * + * @param out the receiving vector + * @param a the vector to transform + * @param m matrix to transform with + * @returns out + */ + public static transformMat4(out: vec4, a: vec4, m: mat4): vec4; + + /** + * Transforms the vec4 with a quat + * + * @param out the receiving vector + * @param a the vector to transform + * @param q quaternion to transform with + * @returns out + */ + + public static transformQuat(out: vec4, a: vec4, q: quat): vec4; + + /** + * Perform some operation over an array of vec4s. + * + * @param a the array of vectors to iterate over + * @param stride Number of elements between the start of each vec4. If 0 assumes tightly packed + * @param offset Number of elements to skip at the beginning of the array + * @param count Number of vec4s to iterate over. If 0 iterates over entire array + * @param fn Function to call for each vector in the array + * @param arg additional argument to pass to fn + * @returns a + * @function + */ + public static forEach(a: vec4, stride: number, offset: number, count: number, + fn: (a: vec4, b: vec4, arg: any) => void, arg: any): vec4; + + /** + * Perform some operation over an array of vec4s. + * + * @param a the array of vectors to iterate over + * @param stride Number of elements between the start of each vec4. If 0 assumes tightly packed + * @param offset Number of elements to skip at the beginning of the array + * @param count Number of vec4s to iterate over. If 0 iterates over entire array + * @param fn Function to call for each vector in the array + * @returns a + * @function + */ + public static forEach(a: vec4, stride: number, offset: number, count: number, + fn: (a: vec4, b: vec4) => void): vec4; + + /** + * Returns a string representation of a vector + * + * @param a vector to represent as a string + * @returns string representation of the vector + */ + public static str(a: vec4): string; + + /** + * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) + * + * @param {vec4} a The first vector. + * @param {vec4} b The second vector. + * @returns {boolean} True if the vectors are equal, false otherwise. + */ + public static exactEquals (a:vec4, b:vec4) : boolean; + + /** + * Returns whether or not the vectors have approximately the same elements in the same position. + * + * @param {vec4} a The first vector. + * @param {vec4} b The second vector. + * @returns {boolean} True if the vectors are equal, false otherwise. + */ + public static equals (a:vec4, b:vec4) : boolean; +} + +// mat2 +export class mat2 extends Float32Array { + private typeMat2:number; + + /** + * Creates a new identity mat2 + * + * @returns a new 2x2 matrix + */ + public static create():mat2; + + /** + * Creates a new mat2 initialized with values from an existing matrix + * + * @param a matrix to clone + * @returns a new 2x2 matrix + */ + public static clone(a:mat2):mat2; + + /** + * Copy the values from one mat2 to another + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static copy(out:mat2, a:mat2):mat2; + + /** + * Set a mat2 to the identity matrix + * + * @param out the receiving matrix + * @returns out + */ + public static identity(out:mat2):mat2; + + /** + * Create a new mat2 with the given values + * + * @param {number} m00 Component in column 0, row 0 position (index 0) + * @param {number} m01 Component in column 0, row 1 position (index 1) + * @param {number} m10 Component in column 1, row 0 position (index 2) + * @param {number} m11 Component in column 1, row 1 position (index 3) + * @returns {mat2} out A new 2x2 matrix + */ + public static fromValues(m00:number, m01:number, m10:number, m11:number):mat2; + + /** + * Set the components of a mat2 to the given values + * + * @param {mat2} out the receiving matrix + * @param {number} m00 Component in column 0, row 0 position (index 0) + * @param {number} m01 Component in column 0, row 1 position (index 1) + * @param {number} m10 Component in column 1, row 0 position (index 2) + * @param {number} m11 Component in column 1, row 1 position (index 3) + * @returns {mat2} out + */ + public static set(out:mat2, m00:number, m01:number, m10:number, m11:number):mat2; + + /** + * Transpose the values of a mat2 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static transpose(out:mat2, a:mat2):mat2; + + /** + * Inverts a mat2 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static invert(out:mat2, a:mat2):mat2; + + /** + * Calculates the adjugate of a mat2 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static adjoint(out:mat2, a:mat2):mat2; + + /** + * Calculates the determinant of a mat2 + * + * @param a the source matrix + * @returns determinant of a + */ + public static determinant(a:mat2):number; + + /** + * Multiplies two mat2's + * + * @param out the receiving matrix + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static multiply(out:mat2, a:mat2, b:mat2):mat2; + + /** + * Multiplies two mat2's + * + * @param out the receiving matrix + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static mul(out:mat2, a:mat2, b:mat2):mat2; + + /** + * Rotates a mat2 by the given angle + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param rad the angle to rotate the matrix by + * @returns out + */ + public static rotate(out:mat2, a:mat2, rad:number):mat2; + + /** + * Scales the mat2 by the dimensions in the given vec2 + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param v the vec2 to scale the matrix by + * @returns out + **/ + public static scale(out:mat2, a:mat2, v:vec2):mat2; + + /** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.rotate(dest, dest, rad); + * + * @param {mat2} out mat2 receiving operation result + * @param {number} rad the angle to rotate the matrix by + * @returns {mat2} out + */ + public static fromRotation(out:mat2, rad:number):mat2; + + /** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2.identity(dest); + * mat2.scale(dest, dest, vec); + * + * @param {mat2} out mat2 receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat2} out + */ + public static fromScaling(out:mat2, v:vec2); + + /** + * Returns a string representation of a mat2 + * + * @param a matrix to represent as a string + * @returns string representation of the matrix + */ + public static str(a:mat2):string; + + /** + * Returns Frobenius norm of a mat2 + * + * @param a the matrix to calculate Frobenius norm of + * @returns Frobenius norm + */ + public static frob(a:mat2):number; + + /** + * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix + * @param L the lower triangular matrix + * @param D the diagonal matrix + * @param U the upper triangular matrix + * @param a the input matrix to factorize + */ + public static LDU(L:mat2, D:mat2, U:mat2, a:mat2):mat2; + + /** + * Adds two mat2's + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ + public static add(out:mat2, a:mat2, b:mat2):mat2; + + /** + * Subtracts matrix b from matrix a + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ + public static subtract (out:mat2, a:mat2, b:mat2):mat2; + + /** + * Subtracts matrix b from matrix a + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @returns {mat2} out + */ + public static sub (out:mat2, a:mat2, b:mat2):mat2; + + /** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat2} a The first matrix. + * @param {mat2} b The second matrix. + * @returns {boolean} True if the matrices are equal, false otherwise. + */ + public static exactEquals (a:mat2, b:mat2):boolean; + + /** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat2} a The first matrix. + * @param {mat2} b The second matrix. + * @returns {boolean} True if the matrices are equal, false otherwise. + */ + public static equals (a:mat2, b:mat2) :boolean; + + /** + * Multiply each element of the matrix by a scalar. + * + * @param {mat2} out the receiving matrix + * @param {mat2} a the matrix to scale + * @param {number} b amount to scale the matrix's elements by + * @returns {mat2} out + */ + public static multiplyScalar (out:mat2, a:mat2, b:number) :mat2 + + /** + * Adds two mat2's after multiplying each element of the second operand by a scalar value. + * + * @param {mat2} out the receiving vector + * @param {mat2} a the first operand + * @param {mat2} b the second operand + * @param {number} scale the amount to scale b's elements by before adding + * @returns {mat2} out + */ + public static multiplyScalarAndAdd (out:mat2, a:mat2, b:mat2, scale:number): mat2 + + + +} + +// mat2d +export class mat2d extends Float32Array { + private typeMat2d:number; + + /** + * Creates a new identity mat2d + * + * @returns a new 2x3 matrix + */ + public static create(): mat2d; + + /** + * Creates a new mat2d initialized with values from an existing matrix + * + * @param a matrix to clone + * @returns a new 2x3 matrix + */ + public static clone(a: mat2d): mat2d; + + /** + * Copy the values from one mat2d to another + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static copy(out: mat2d, a: mat2d): mat2d; + + /** + * Set a mat2d to the identity matrix + * + * @param out the receiving matrix + * @returns out + */ + public static identity(out: mat2d): mat2d; + + /** + * Create a new mat2d with the given values + * + * @param {number} a Component A (index 0) + * @param {number} b Component B (index 1) + * @param {number} c Component C (index 2) + * @param {number} d Component D (index 3) + * @param {number} tx Component TX (index 4) + * @param {number} ty Component TY (index 5) + * @returns {mat2d} A new mat2d + */ + public static fromValues (a:number, b:number, c:number, d:number, tx:number, ty:number) : mat2d + + + /** + * Set the components of a mat2d to the given values + * + * @param {mat2d} out the receiving matrix + * @param {number} a Component A (index 0) + * @param {number} b Component B (index 1) + * @param {number} c Component C (index 2) + * @param {number} d Component D (index 3) + * @param {number} tx Component TX (index 4) + * @param {number} ty Component TY (index 5) + * @returns {mat2d} out + */ + public static set (out:mat2d, a:number, b:number, c:number, d:number, tx:number, ty:number) :mat2d + + /** + * Inverts a mat2d + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static invert(out: mat2d, a: mat2d): mat2d; + + /** + * Calculates the determinant of a mat2d + * + * @param a the source matrix + * @returns determinant of a + */ + public static determinant(a: mat2d): number; + + /** + * Multiplies two mat2d's + * + * @param out the receiving matrix + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static multiply(out: mat2d, a: mat2d, b: mat2d): mat2d; + + /** + * Multiplies two mat2d's + * + * @param out the receiving matrix + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static mul(out: mat2d, a: mat2d, b: mat2d): mat2d; + + /** + * Rotates a mat2d by the given angle + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param rad the angle to rotate the matrix by + * @returns out + */ + public static rotate(out: mat2d, a: mat2d, rad: number): mat2d; + + /** + * Scales the mat2d by the dimensions in the given vec2 + * + * @param out the receiving matrix + * @param a the matrix to translate + * @param v the vec2 to scale the matrix by + * @returns out + **/ + public static scale(out: mat2d, a: mat2d, v: vec2): mat2d; + + /** + * Translates the mat2d by the dimensions in the given vec2 + * + * @param out the receiving matrix + * @param a the matrix to translate + * @param v the vec2 to translate the matrix by + * @returns out + **/ + public static translate(out: mat2d, a: mat2d, v: vec2): mat2d; + + /** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.rotate(dest, dest, rad); + * + * @param {mat2d} out mat2d receiving operation result + * @param {number} rad the angle to rotate the matrix by + * @returns {mat2d} out + */ + public static fromRotation (out:mat2d, rad:number): mat2d; + + /** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.scale(dest, dest, vec); + * + * @param {mat2d} out mat2d receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat2d} out + */ + public static fromScaling (out:mat2d, v:vec2):mat2d; + + /** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat2d.identity(dest); + * mat2d.translate(dest, dest, vec); + * + * @param {mat2d} out mat2d receiving operation result + * @param {vec2} v Translation vector + * @returns {mat2d} out + */ + public static fromTranslation (out:mat2d, v:vec2):mat2d + + /** + * Returns a string representation of a mat2d + * + * @param a matrix to represent as a string + * @returns string representation of the matrix + */ + public static str(a: mat2d): string; + + /** + * Returns Frobenius norm of a mat2d + * + * @param a the matrix to calculate Frobenius norm of + * @returns Frobenius norm + */ + public static frob(a: mat2d): number; + + /** + * Adds two mat2d's + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ + public static add (out: mat2d, a: mat2d, b: mat2d): mat2d + + /** + * Subtracts matrix b from matrix a + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ + public static subtract(out: mat2d, a: mat2d, b: mat2d): mat2d + + /** + * Subtracts matrix b from matrix a + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @returns {mat2d} out + */ + public static sub(out: mat2d, a: mat2d, b: mat2d): mat2d + + /** + * Multiply each element of the matrix by a scalar. + * + * @param {mat2d} out the receiving matrix + * @param {mat2d} a the matrix to scale + * @param {number} b amount to scale the matrix's elements by + * @returns {mat2d} out + */ + public static multiplyScalar (out: mat2d, a: mat2d, b: mat2d): mat2d; + + /** + * Adds two mat2d's after multiplying each element of the second operand by a scalar value. + * + * @param {mat2d} out the receiving vector + * @param {mat2d} a the first operand + * @param {mat2d} b the second operand + * @param {number} scale the amount to scale b's elements by before adding + * @returns {mat2d} out + */ + public static multiplyScalarAndAdd (out: mat2d, a: mat2d, b: mat2d, scale:number) : mat2d + + /** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat2d} a The first matrix. + * @param {mat2d} b The second matrix. + * @returns {boolean} True if the matrices are equal, false otherwise. + */ + public static exactEquals (a: mat2d, b: mat2d): boolean; + + /** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat2d} a The first matrix. + * @param {mat2d} b The second matrix. + * @returns {boolean} True if the matrices are equal, false otherwise. + */ + public static equals (a: mat2d, b: mat2d): boolean +} + +// mat3 +export class mat3 extends Float32Array { + private typeMat3:number; + + /** + * Creates a new identity mat3 + * + * @returns a new 3x3 matrix + */ + public static create():mat3; + + /** + * Copies the upper-left 3x3 values into the given mat3. + * + * @param {mat3} out the receiving 3x3 matrix + * @param {mat4} a the source 4x4 matrix + * @returns {mat3} out + */ + public static fromMat4(out:mat3, a:mat4):mat3 + + /** + * Creates a new mat3 initialized with values from an existing matrix + * + * @param a matrix to clone + * @returns a new 3x3 matrix + */ + public static clone(a:mat3):mat3; + + /** + * Copy the values from one mat3 to another + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static copy(out:mat3, a:mat3):mat3; + + /** + * Create a new mat3 with the given values + * + * @param {number} m00 Component in column 0, row 0 position (index 0) + * @param {number} m01 Component in column 0, row 1 position (index 1) + * @param {number} m02 Component in column 0, row 2 position (index 2) + * @param {number} m10 Component in column 1, row 0 position (index 3) + * @param {number} m11 Component in column 1, row 1 position (index 4) + * @param {number} m12 Component in column 1, row 2 position (index 5) + * @param {number} m20 Component in column 2, row 0 position (index 6) + * @param {number} m21 Component in column 2, row 1 position (index 7) + * @param {number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} A new mat3 + */ + public static fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22):mat3; + + + /** + * Set the components of a mat3 to the given values + * + * @param {mat3} out the receiving matrix + * @param {number} m00 Component in column 0, row 0 position (index 0) + * @param {number} m01 Component in column 0, row 1 position (index 1) + * @param {number} m02 Component in column 0, row 2 position (index 2) + * @param {number} m10 Component in column 1, row 0 position (index 3) + * @param {number} m11 Component in column 1, row 1 position (index 4) + * @param {number} m12 Component in column 1, row 2 position (index 5) + * @param {number} m20 Component in column 2, row 0 position (index 6) + * @param {number} m21 Component in column 2, row 1 position (index 7) + * @param {number} m22 Component in column 2, row 2 position (index 8) + * @returns {mat3} out + */ + public static set(out:mat3, m00:number, m01:number, m02:number, m10:number, m11:number, m12:number, m20:number, m21:number, m22:number):mat3 + + /** + * Set a mat3 to the identity matrix + * + * @param out the receiving matrix + * @returns out + */ + public static identity(out:mat3):mat3; + + /** + * Transpose the values of a mat3 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static transpose(out:mat3, a:mat3):mat3; + + /** + * Inverts a mat3 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static invert(out:mat3, a:mat3):mat3; + + /** + * Calculates the adjugate of a mat3 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static adjoint(out:mat3, a:mat3):mat3; + + /** + * Calculates the determinant of a mat3 + * + * @param a the source matrix + * @returns determinant of a + */ + public static determinant(a:mat3):number; + + /** + * Multiplies two mat3's + * + * @param out the receiving matrix + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static multiply(out:mat3, a:mat3, b:mat3):mat3; + + /** + * Multiplies two mat3's + * + * @param out the receiving matrix + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static mul(out:mat3, a:mat3, b:mat3):mat3; + + + /** + * Translate a mat3 by the given vector + * + * @param out the receiving matrix + * @param a the matrix to translate + * @param v vector to translate by + * @returns out + */ + public static translate(out:mat3, a:mat3, v:vec3):mat3; + + /** + * Rotates a mat3 by the given angle + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param rad the angle to rotate the matrix by + * @returns out + */ + public static rotate(out:mat3, a:mat3, rad:number):mat3; + + /** + * Scales the mat3 by the dimensions in the given vec2 + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param v the vec2 to scale the matrix by + * @returns out + **/ + public static scale(out:mat3, a:mat3, v:vec2):mat3; + + /** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.translate(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {vec2} v Translation vector + * @returns {mat3} out + */ + public static fromTranslation(out:mat3, v:vec2):mat3 + + /** + * Creates a matrix from a given angle + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.rotate(dest, dest, rad); + * + * @param {mat3} out mat3 receiving operation result + * @param {number} rad the angle to rotate the matrix by + * @returns {mat3} out + */ + public static fromRotation(out:mat3, rad:number):mat3 + + /** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat3.identity(dest); + * mat3.scale(dest, dest, vec); + * + * @param {mat3} out mat3 receiving operation result + * @param {vec2} v Scaling vector + * @returns {mat3} out + */ + public static fromScaling(out:mat3, v:vec2):mat3 + + /** + * Copies the values from a mat2d into a mat3 + * + * @param out the receiving matrix + * @param {mat2d} a the matrix to copy + * @returns out + **/ + public static fromMat2d(out:mat3, a:mat2d):mat3; + + /** + * Copies the upper-left 3x3 values into the given mat3. + * + * @param out the receiving 3x3 matrix + * @param a the source 4x4 matrix + * @returns out + */ + public static fromMat4(out:mat3, a:mat4):mat3; + + /** + * Calculates a 3x3 matrix from the given quaternion + * + * @param out mat3 receiving operation result + * @param q Quaternion to create matrix from + * + * @returns out + */ + public static fromQuat(out:mat3, q:quat):mat3; + + /** + * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix + * + * @param out mat3 receiving operation result + * @param a Mat4 to derive the normal matrix from + * + * @returns out + */ + public static normalFromMat4(out:mat3, a:mat3):mat3; + + /** + * Returns a string representation of a mat3 + * + * @param mat matrix to represent as a string + * @returns string representation of the matrix + */ + public static str(mat:mat3):string; + + /** + * Returns Frobenius norm of a mat3 + * + * @param a the matrix to calculate Frobenius norm of + * @returns Frobenius norm + */ + public static frob(a:mat3):number; + + /** + * Adds two mat3's + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out + */ + public static add(out:mat3, a:mat3, b:mat3):mat3 + + /** + * Subtracts matrix b from matrix a + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out + */ + public static subtract(out:mat3, a:mat3, b:mat3):mat3 + + /** + * Subtracts matrix b from matrix a + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @returns {mat3} out + */ + public static sub(out:mat3, a:mat3, b:mat3):mat3 + + /** + * Multiply each element of the matrix by a scalar. + * + * @param {mat3} out the receiving matrix + * @param {mat3} a the matrix to scale + * @param {number} b amount to scale the matrix's elements by + * @returns {mat3} out + */ + public static multiplyScalar(out:mat3, a:mat3, b:number):mat3 + + /** + * Adds two mat3's after multiplying each element of the second operand by a scalar value. + * + * @param {mat3} out the receiving vector + * @param {mat3} a the first operand + * @param {mat3} b the second operand + * @param {number} scale the amount to scale b's elements by before adding + * @returns {mat3} out + */ + public static multiplyScalarAndAdd(out:mat3, a:mat3, b:mat3, scale:number):mat3 + + /** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat3} a The first matrix. + * @param {mat3} b The second matrix. + * @returns {boolean} True if the matrices are equal, false otherwise. + */ + public static exactEquals(a:mat3, b:mat3):boolean; + + /** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat3} a The first matrix. + * @param {mat3} b The second matrix. + * @returns {boolean} True if the matrices are equal, false otherwise. + */ + public static equals(a:mat3, b:mat3):boolean +} + +// mat4 +export class mat4 extends Float32Array { + private typeMat4:number; + + /** + * Creates a new identity mat4 + * + * @returns a new 4x4 matrix + */ + public static create():mat4; + + /** + * Creates a new mat4 initialized with values from an existing matrix + * + * @param a matrix to clone + * @returns a new 4x4 matrix + */ + public static clone(a:mat4):mat4; + + /** + * Copy the values from one mat4 to another + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static copy(out:mat4, a:mat4):mat4; + + + /** + * Create a new mat4 with the given values + * + * @param {number} m00 Component in column 0, row 0 position (index 0) + * @param {number} m01 Component in column 0, row 1 position (index 1) + * @param {number} m02 Component in column 0, row 2 position (index 2) + * @param {number} m03 Component in column 0, row 3 position (index 3) + * @param {number} m10 Component in column 1, row 0 position (index 4) + * @param {number} m11 Component in column 1, row 1 position (index 5) + * @param {number} m12 Component in column 1, row 2 position (index 6) + * @param {number} m13 Component in column 1, row 3 position (index 7) + * @param {number} m20 Component in column 2, row 0 position (index 8) + * @param {number} m21 Component in column 2, row 1 position (index 9) + * @param {number} m22 Component in column 2, row 2 position (index 10) + * @param {number} m23 Component in column 2, row 3 position (index 11) + * @param {number} m30 Component in column 3, row 0 position (index 12) + * @param {number} m31 Component in column 3, row 1 position (index 13) + * @param {number} m32 Component in column 3, row 2 position (index 14) + * @param {number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} A new mat4 + */ + public static fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33):mat4; + + /** + * Set the components of a mat4 to the given values + * + * @param {mat4} out the receiving matrix + * @param {number} m00 Component in column 0, row 0 position (index 0) + * @param {number} m01 Component in column 0, row 1 position (index 1) + * @param {number} m02 Component in column 0, row 2 position (index 2) + * @param {number} m03 Component in column 0, row 3 position (index 3) + * @param {number} m10 Component in column 1, row 0 position (index 4) + * @param {number} m11 Component in column 1, row 1 position (index 5) + * @param {number} m12 Component in column 1, row 2 position (index 6) + * @param {number} m13 Component in column 1, row 3 position (index 7) + * @param {number} m20 Component in column 2, row 0 position (index 8) + * @param {number} m21 Component in column 2, row 1 position (index 9) + * @param {number} m22 Component in column 2, row 2 position (index 10) + * @param {number} m23 Component in column 2, row 3 position (index 11) + * @param {number} m30 Component in column 3, row 0 position (index 12) + * @param {number} m31 Component in column 3, row 1 position (index 13) + * @param {number} m32 Component in column 3, row 2 position (index 14) + * @param {number} m33 Component in column 3, row 3 position (index 15) + * @returns {mat4} out + */ + public static set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33):mat4; + + /** + * Set a mat4 to the identity matrix + * + * @param out the receiving matrix + * @returns out + */ + public static identity(out:mat4):mat4; + + /** + * Transpose the values of a mat4 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static transpose(out:mat4, a:mat4):mat4; + + /** + * Inverts a mat4 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static invert(out:mat4, a:mat4):mat4; + + /** + * Calculates the adjugate of a mat4 + * + * @param out the receiving matrix + * @param a the source matrix + * @returns out + */ + public static adjoint(out:mat4, a:mat4):mat4; + + /** + * Calculates the determinant of a mat4 + * + * @param a the source matrix + * @returns determinant of a + */ + public static determinant(a:mat4):number; + + /** + * Multiplies two mat4's + * + * @param out the receiving matrix + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static multiply(out:mat4, a:mat4, b:mat4):mat4; + + /** + * Multiplies two mat4's + * + * @param out the receiving matrix + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static mul(out:mat4, a:mat4, b:mat4):mat4; + + /** + * Translate a mat4 by the given vector + * + * @param out the receiving matrix + * @param a the matrix to translate + * @param v vector to translate by + * @returns out + */ + public static translate(out:mat4, a:mat4, v:vec3):mat4; + + /** + * Scales the mat4 by the dimensions in the given vec3 + * + * @param out the receiving matrix + * @param a the matrix to scale + * @param v the vec3 to scale the matrix by + * @returns out + **/ + public static scale(out:mat4, a:mat4, v:vec3):mat4; + + /** + * Rotates a mat4 by the given angle + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param rad the angle to rotate the matrix by + * @param axis the axis to rotate around + * @returns out + */ + public static rotate(out:mat4, a:mat4, rad:number, axis:vec3):mat4; + + /** + * Rotates a matrix by the given angle around the X axis + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param rad the angle to rotate the matrix by + * @returns out + */ + public static rotateX(out:mat4, a:mat4, rad:number):mat4; + + /** + * Rotates a matrix by the given angle around the Y axis + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param rad the angle to rotate the matrix by + * @returns out + */ + public static rotateY(out:mat4, a:mat4, rad:number):mat4; + + /** + * Rotates a matrix by the given angle around the Z axis + * + * @param out the receiving matrix + * @param a the matrix to rotate + * @param rad the angle to rotate the matrix by + * @returns out + */ + public static rotateZ(out:mat4, a:mat4, rad:number):mat4; + + /** + * Creates a matrix from a vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, dest, vec); + * + * @param {mat4} out mat4 receiving operation result + * @param {vec3} v Translation vector + * @returns {mat4} out + */ + public static fromTranslation(out:mat4, v:vec3):mat4 + + /** + * Creates a matrix from a vector scaling + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.scale(dest, dest, vec); + * + * @param {mat4} out mat4 receiving operation result + * @param {vec3} v Scaling vector + * @returns {mat4} out + */ + public static fromScaling(out:mat4, v:vec3):mat4 + + /** + * Creates a matrix from a given angle around a given axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotate(dest, dest, rad, axis); + * + * @param {mat4} out mat4 receiving operation result + * @param {number} rad the angle to rotate the matrix by + * @param {vec3} axis the axis to rotate around + * @returns {mat4} out + */ + public static fromRotation(out:mat4, rad:number, axis:vec3):mat4 + + /** + * Creates a matrix from the given angle around the X axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateX(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + public static fromXRotation(out:mat4, rad:number):mat4 + + /** + * Creates a matrix from the given angle around the Y axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateY(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + public static fromYRotation(out:mat4, rad:number):mat4 + + + /** + * Creates a matrix from the given angle around the Z axis + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.rotateZ(dest, dest, rad); + * + * @param {mat4} out mat4 receiving operation result + * @param {number} rad the angle to rotate the matrix by + * @returns {mat4} out + */ + public static fromZRotation(out:mat4, rad:number):mat4 + + /** + * Creates a matrix from a quaternion rotation and vector translation + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * var quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * + * @param out mat4 receiving operation result + * @param q Rotation quaternion + * @param v Translation vector + * @returns out + */ + public static fromRotationTranslation(out:mat4, q:quat, v:vec3):mat4; + + /** + * Returns the translation vector component of a transformation + * matrix. If a matrix is built with fromRotationTranslation, + * the returned vector will be the same as the translation vector + * originally supplied. + * @param {vec3} out Vector to receive translation component + * @param {mat4} mat Matrix to be decomposed (input) + * @return {vec3} out + */ + public static getTranslation(out:vec3, mat:mat4):vec3; + + /** + * Returns a quaternion representing the rotational component + * of a transformation matrix. If a matrix is built with + * fromRotationTranslation, the returned quaternion will be the + * same as the quaternion originally supplied. + * @param {quat} out Quaternion to receive the rotation component + * @param {mat4} mat Matrix to be decomposed (input) + * @return {quat} out + */ + public static getRotation(out:quat, mat:mat4):quat; + + /** + * Creates a matrix from a quaternion rotation, vector translation and vector scale + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * var quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * + * @param out mat4 receiving operation result + * @param q Rotation quaternion + * @param v Translation vector + * @param s Scaling vector + * @returns out + */ + public static fromRotationTranslationScale(out:mat4, q:quat, v:vec3, s:vec3):mat4; + + /** + * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin + * This is equivalent to (but much faster than): + * + * mat4.identity(dest); + * mat4.translate(dest, vec); + * mat4.translate(dest, origin); + * var quatMat = mat4.create(); + * quat4.toMat4(quat, quatMat); + * mat4.multiply(dest, quatMat); + * mat4.scale(dest, scale) + * mat4.translate(dest, negativeOrigin); + * + * @param {mat4} out mat4 receiving operation result + * @param {quat} q Rotation quaternion + * @param {vec3} v Translation vector + * @param {vec3} s Scaling vector + * @param {vec3} o The origin vector around which to scale and rotate + * @returns {mat4} out + */ + public static fromRotationTranslationScaleOrigin(out:mat4, q:quat, v:vec3, s:vec3, o:vec3):mat4 + + /** + * Calculates a 4x4 matrix from the given quaternion + * + * @param {mat4} out mat4 receiving operation result + * @param {quat} q Quaternion to create matrix from + * + * @returns {mat4} out + */ + public static fromQuat(out:mat4, q:quat):mat4 + + /** + * Generates a frustum matrix with the given bounds + * + * @param out mat4 frustum matrix will be written into + * @param left Left bound of the frustum + * @param right Right bound of the frustum + * @param bottom Bottom bound of the frustum + * @param top Top bound of the frustum + * @param near Near bound of the frustum + * @param far Far bound of the frustum + * @returns out + */ + public static frustum(out:mat4, left:number, right:number, + bottom:number, top:number, near:number, far:number):mat4; + + /** + * Generates a perspective projection matrix with the given bounds + * + * @param out mat4 frustum matrix will be written into + * @param fovy Vertical field of view in radians + * @param aspect Aspect ratio. typically viewport width/height + * @param near Near bound of the frustum + * @param far Far bound of the frustum + * @returns out + */ + public static perspective(out:mat4, fovy:number, aspect:number, + near:number, far:number):mat4; + + /** + * Generates a perspective projection matrix with the given field of view. + * This is primarily useful for generating projection matrices to be used + * with the still experimental WebVR API. + * + * @param {mat4} out mat4 frustum matrix will be written into + * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees + * @param {number} near Near bound of the frustum + * @param {number} far Far bound of the frustum + * @returns {mat4} out + */ + public static perspectiveFromFieldOfView(out:mat4, + fov:{upDegrees:number, downDegrees:number, leftDegrees:number, rightDegrees:number}, + near, far):mat4 + + /** + * Generates a orthogonal projection matrix with the given bounds + * + * @param out mat4 frustum matrix will be written into + * @param left Left bound of the frustum + * @param right Right bound of the frustum + * @param bottom Bottom bound of the frustum + * @param top Top bound of the frustum + * @param near Near bound of the frustum + * @param far Far bound of the frustum + * @returns out + */ + public static ortho(out:mat4, left:number, right:number, + bottom:number, top:number, near:number, far:number):mat4; + + /** + * Generates a look-at matrix with the given eye position, focal point, and up axis + * + * @param out mat4 frustum matrix will be written into + * @param eye Position of the viewer + * @param center Point the viewer is looking at + * @param up vec3 pointing up + * @returns out + */ + public static lookAt(out:mat4, eye:vec3, center:vec3, up:vec3):mat4; + + /** + * Returns a string representation of a mat4 + * + * @param mat matrix to represent as a string + * @returns string representation of the matrix + */ + public static str(mat:mat4):string; + + /** + * Returns Frobenius norm of a mat4 + * + * @param a the matrix to calculate Frobenius norm of + * @returns Frobenius norm + */ + public static frob(a:mat4):number; + + /** + * Adds two mat4's + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out + */ + public static add(out:mat4, a:mat4, b:mat4):mat4 + + /** + * Subtracts matrix b from matrix a + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out + */ + public static subtract(out:mat4, a:mat4, b:mat4):mat4 + + /** + * Subtracts matrix b from matrix a + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @returns {mat4} out + */ + public static sub(out:mat4, a:mat4, b:mat4):mat4 + + /** + * Multiply each element of the matrix by a scalar. + * + * @param {mat4} out the receiving matrix + * @param {mat4} a the matrix to scale + * @param {number} b amount to scale the matrix's elements by + * @returns {mat4} out + */ + public static multiplyScalar(out:mat4, a:mat4, b:mat4):mat4 + + /** + * Adds two mat4's after multiplying each element of the second operand by a scalar value. + * + * @param {mat4} out the receiving vector + * @param {mat4} a the first operand + * @param {mat4} b the second operand + * @param {number} scale the amount to scale b's elements by before adding + * @returns {mat4} out + */ + public static multiplyScalarAndAdd (out:mat4, a:mat4, b:mat4, scale:number):mat4 + + /** + * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) + * + * @param {mat4} a The first matrix. + * @param {mat4} b The second matrix. + * @returns {boolean} True if the matrices are equal, false otherwise. + */ + public static exactEquals (a:mat4, b:mat4) :boolean + + /** + * Returns whether or not the matrices have approximately the same elements in the same position. + * + * @param {mat4} a The first matrix. + * @param {mat4} b The second matrix. + * @returns {boolean} True if the matrices are equal, false otherwise. + */ + public static equals (a:mat4, b:mat4): boolean + +} + +// quat +export class quat extends Float32Array { + private typeQuat:number; + + /** + * Creates a new identity quat + * + * @returns a new quaternion + */ + public static create(): quat; + + /** + * Creates a new quat initialized with values from an existing quaternion + * + * @param a quaternion to clone + * @returns a new quaternion + * @function + */ + public static clone(a: quat): quat; + + /** + * Creates a new quat initialized with the given values + * + * @param x X component + * @param y Y component + * @param z Z component + * @param w W component + * @returns a new quaternion + * @function + */ + public static fromValues(x: number, y: number, z: number, w: number): quat; + + /** + * Copy the values from one quat to another + * + * @param out the receiving quaternion + * @param a the source quaternion + * @returns out + * @function + */ + public static copy(out: quat, a: quat): quat; + + /** + * Set the components of a quat to the given values + * + * @param out the receiving quaternion + * @param x X component + * @param y Y component + * @param z Z component + * @param w W component + * @returns out + * @function + */ + public static set(out: quat, x: number, y: number, z: number, w: number): quat; + + /** + * Set a quat to the identity quaternion + * + * @param out the receiving quaternion + * @returns out + */ + public static identity(out: quat): quat; + + /** + * Sets a quaternion to represent the shortest rotation from one + * vector to another. + * + * Both vectors are assumed to be unit length. + * + * @param {quat} out the receiving quaternion. + * @param {vec3} a the initial vector + * @param {vec3} b the destination vector + * @returns {quat} out + */ + public static rotationTo (out:quat, a:vec3, b:vec3): quat; + + /** + * Sets the specified quaternion with values corresponding to the given + * axes. Each axis is a vec3 and is expected to be unit length and + * perpendicular to all other specified axes. + * + * @param {vec3} view the vector representing the viewing direction + * @param {vec3} right the vector representing the local "right" direction + * @param {vec3} up the vector representing the local "up" direction + * @returns {quat} out + */ + public static setAxes (out:quat, view:vec3, right:vec3, up:vec3):quat + + + + /** + * Sets a quat from the given angle and rotation axis, + * then returns it. + * + * @param out the receiving quaternion + * @param axis the axis around which to rotate + * @param rad the angle in radians + * @returns out + **/ + public static setAxisAngle(out: quat, axis: vec3, rad: number): quat; + + /** + * Gets the rotation axis and angle for a given + * quaternion. If a quaternion is created with + * setAxisAngle, this method will return the same + * values as providied in the original parameter list + * OR functionally equivalent values. + * Example: The quaternion formed by axis [0, 0, 1] and + * angle -90 is the same as the quaternion formed by + * [0, 0, 1] and 270. This method favors the latter. + * @param {vec3} out_axis Vector receiving the axis of rotation + * @param {quat} q Quaternion to be decomposed + * @return {number} Angle, in radians, of the rotation + */ + public static getAxisAngle (out_axis:vec3, q:quat) :number + + /** + * Adds two quat's + * + * @param out the receiving quaternion + * @param a the first operand + * @param b the second operand + * @returns out + * @function + */ + public static add(out: quat, a: quat, b: quat): quat; + + /** + * Multiplies two quat's + * + * @param out the receiving quaternion + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static multiply(out: quat, a: quat, b: quat): quat; + + /** + * Multiplies two quat's + * + * @param out the receiving quaternion + * @param a the first operand + * @param b the second operand + * @returns out + */ + public static mul(out: quat, a: quat, b: quat): quat; + + /** + * Scales a quat by a scalar number + * + * @param out the receiving vector + * @param a the vector to scale + * @param b amount to scale the vector by + * @returns out + * @function + */ + public static scale(out: quat, a: quat, b: number): quat; + + /** + * Calculates the length of a quat + * + * @param a vector to calculate length of + * @returns length of a + * @function + */ + public static length(a: quat): number; + + /** + * Calculates the length of a quat + * + * @param a vector to calculate length of + * @returns length of a + * @function + */ + public static len(a: quat): number; + + /** + * Calculates the squared length of a quat + * + * @param a vector to calculate squared length of + * @returns squared length of a + * @function + */ + public static squaredLength(a: quat): number; + + /** + * Calculates the squared length of a quat + * + * @param a vector to calculate squared length of + * @returns squared length of a + * @function + */ + public static sqrLen(a: quat): number; + + /** + * Normalize a quat + * + * @param out the receiving quaternion + * @param a quaternion to normalize + * @returns out + * @function + */ + public static normalize(out: quat, a: quat): quat; + + /** + * Calculates the dot product of two quat's + * + * @param a the first operand + * @param b the second operand + * @returns dot product of a and b + * @function + */ + public static dot(a: quat, b: quat): number; + + /** + * Performs a linear interpolation between two quat's + * + * @param out the receiving quaternion + * @param a the first operand + * @param b the second operand + * @param t interpolation amount between the two inputs + * @returns out + * @function + */ + public static lerp(out: quat, a: quat, b: quat, t: number): quat; + + /** + * Performs a spherical linear interpolation between two quat + * + * @param out the receiving quaternion + * @param a the first operand + * @param b the second operand + * @param t interpolation amount between the two inputs + * @returns out + */ + public static slerp(out:quat, a:quat, b:quat, t:number): quat; + + /** + * Performs a spherical linear interpolation with two control points + * + * @param {quat} out the receiving quaternion + * @param {quat} a the first operand + * @param {quat} b the second operand + * @param {quat} c the third operand + * @param {quat} d the fourth operand + * @param {number} t interpolation amount + * @returns {quat} out + */ + public static sqlerp(out: quat, a: quat, b: quat, c: quat, d: quat, t: number): quat; + + /** + * Calculates the inverse of a quat + * + * @param out the receiving quaternion + * @param a quat to calculate inverse of + * @returns out + */ + public static invert(out: quat, a: quat): quat; + + /** + * Calculates the conjugate of a quat + * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result. + * + * @param out the receiving quaternion + * @param a quat to calculate conjugate of + * @returns out + */ + public static conjugate(out: quat, a: quat): quat; + + /** + * Returns a string representation of a quaternion + * + * @param a quat to represent as a string + * @returns string representation of the quat + */ + public static str(a: quat): string; + + /** + * Rotates a quaternion by the given angle about the X axis + * + * @param out quat receiving operation result + * @param a quat to rotate + * @param rad angle (in radians) to rotate + * @returns out + */ + public static rotateX(out: quat, a: quat, rad: number): quat; + + /** + * Rotates a quaternion by the given angle about the Y axis + * + * @param out quat receiving operation result + * @param a quat to rotate + * @param rad angle (in radians) to rotate + * @returns out + */ + public static rotateY(out: quat, a: quat, rad: number): quat; + + /** + * Rotates a quaternion by the given angle about the Z axis + * + * @param out quat receiving operation result + * @param a quat to rotate + * @param rad angle (in radians) to rotate + * @returns out + */ + public static rotateZ(out: quat, a: quat, rad: number): quat; + + /** + * Creates a quaternion from the given 3x3 rotation matrix. + * + * NOTE: The resultant quaternion is not normalized, so you should be sure + * to renormalize the quaternion yourself where necessary. + * + * @param out the receiving quaternion + * @param m rotation matrix + * @returns out + * @function + */ + public static fromMat3(out: quat, m: mat3): quat; + + /** + * Sets the specified quaternion with values corresponding to the given + * axes. Each axis is a vec3 and is expected to be unit length and + * perpendicular to all other specified axes. + * + * @param out the receiving quat + * @param view the vector representing the viewing direction + * @param right the vector representing the local "right" direction + * @param up the vector representing the local "up" direction + * @returns out + */ + public static setAxes(out: quat, view: vec3, right: vec3, up: vec3): quat; + + /** + * Sets a quaternion to represent the shortest rotation from one + * vector to another. + * + * Both vectors are assumed to be unit length. + * + * @param out the receiving quaternion. + * @param a the initial vector + * @param b the destination vector + * @returns out + */ + public static rotationTo(out: quat, a: vec3, b: vec3): quat; + + /** + * Calculates the W component of a quat from the X, Y, and Z components. + * Assumes that quaternion is 1 unit in length. + * Any existing W component will be ignored. + * + * @param out the receiving quaternion + * @param a quat to calculate W component of + * @returns out + */ + public static calculateW(out: quat, a: quat): quat; + + /** + * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===) + * + * @param {quat} a The first vector. + * @param {quat} b The second vector. + * @returns {boolean} True if the quaternions are equal, false otherwise. + */ + public static exactEquals (a:quat, b:quat) : boolean; + + /** + * Returns whether or not the quaternions have approximately the same elements in the same position. + * + * @param {quat} a The first vector. + * @param {quat} b The second vector. + * @returns {boolean} True if the quaternions are equal, false otherwise. + */ + public static equals (a:quat, b:quat) : boolean; +} From 9d33ed7f26cd37bf99bae074b6ddca5c4b0b8aef Mon Sep 17 00:00:00 2001 From: Mattijs Kneppers Date: Mon, 18 Jul 2016 19:29:05 +0200 Subject: [PATCH 02/47] Add gl-matrix-typed tests and fix gl-matrix-typed --- gl-matrix/gl-matrix-typed-tests.ts | 346 +++++++++++++++++++++++++++++ gl-matrix/gl-matrix-typed.d.ts | 71 +++--- 2 files changed, 377 insertions(+), 40 deletions(-) create mode 100644 gl-matrix/gl-matrix-typed-tests.ts diff --git a/gl-matrix/gl-matrix-typed-tests.ts b/gl-matrix/gl-matrix-typed-tests.ts new file mode 100644 index 0000000000..7364ec0a83 --- /dev/null +++ b/gl-matrix/gl-matrix-typed-tests.ts @@ -0,0 +1,346 @@ +/// + +// common +import {vec2, mat2, mat3, mat4, vec3, vec4, glMatrix, mat2d, quat} from "./gl-matrix-typed"; +var result: number = glMatrix.toRadian(180); + +var outVal: number; +var outBool: boolean; +var outStr: string; + +let vecArray = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); + +let vec2A = vec2.fromValues(1, 2); +let vec2B = vec2.fromValues(3, 4); +let vec3A = vec3.fromValues(1, 2, 3); +let vec3B = vec3.fromValues(3, 4, 5); +let vec4A = vec4.fromValues(1, 2, 3, 4); +let vec4B = vec4.fromValues(3, 4, 5, 6); +let mat2A = mat2.fromValues(1, 2, 3, 4); +let mat2B = mat2.fromValues(1, 2, 3, 4); +let mat2dA = mat2d.fromValues(1, 2, 3, 4, 5, 6); +let mat2dB = mat2d.fromValues(1, 2, 3, 4, 5, 6); +let mat3A = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9); +let mat3B = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9); +let mat4A = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); +let mat4B = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); +let quatA = quat.fromValues(1, 2, 3, 4); +let quatB = quat.fromValues(5, 6, 7, 8); + +let outVec2 = vec2.create(); +let outVec3 = vec3.create(); +let outVec4 = vec4.create(); +let outMat2 = mat2.create(); +let outMat2d = mat2d.create(); +let outMat3 = mat3.create(); +let outMat4 = mat4.create(); +let outQuat = quat.create(); + +// vec2 +outVec2 = vec2.create(); +outVec2 = vec2.clone(vec2A); +outVec2 = vec2.fromValues(1, 2); +outVec2 = vec2.copy(outVec2, vec2A); +outVec2 = vec2.set(outVec2, 1, 2); +outVec2 = vec2.add(outVec2, vec2A, vec2B); +outVec2 = vec2.subtract(outVec2, vec2A, vec2B); +outVec2 = vec2.sub(outVec2, vec2A, vec2B); +outVec2 = vec2.multiply(outVec2, vec2A, vec2B); +outVec2 = vec2.mul(outVec2, vec2A, vec2B); +outVec2 = vec2.divide(outVec2, vec2A, vec2B); +outVec2 = vec2.div(outVec2, vec2A, vec2B); +outVec2 = vec2.ceil(outVec2, vec2A); +outVec2 = vec2.floor(outVec2, vec2A); +outVec2 = vec2.min(outVec2, vec2A, vec2B); +outVec2 = vec2.max(outVec2, vec2A, vec2B); +outVec2 = vec2.round(outVec2, vec2A); +outVec2 = vec2.scale(outVec2, vec2A, 2); +outVec2 = vec2.scaleAndAdd(outVec2, vec2A, vec2B, 0.5); +outVal = vec2.distance(vec2A, vec2B); +outVal = vec2.dist(vec2A, vec2B); +outVal = vec2.squaredDistance(vec2A, vec2B); +outVal = vec2.sqrDist(vec2A, vec2B); +outVal = vec2.length(vec2A); +outVal = vec2.len(vec2A); +outVal = vec2.squaredLength(vec2A); +outVal = vec2.sqrLen(vec2A); +outVec2 = vec2.negate(outVec2, vec2A); +outVec2 = vec2.inverse(outVec2, vec2A); +outVec2 = vec2.normalize(outVec2, vec2A); +outVal = vec2.dot(vec2A, vec2B); +outVec2 = vec2.cross(outVec2, vec2A, vec2B); +outVec2 = vec2.lerp(outVec2, vec2A, vec2B, 0.5); +outVec2 = vec2.random(outVec2); +outVec2 = vec2.random(outVec2, 5.0); +outVec2 = vec2.transformMat2(outVec2, vec2A, mat2A); +outVec2 = vec2.transformMat2d(outVec2, vec2A, mat2dA); +outVec2 = vec2.transformMat3(outVec2, vec2A, mat3A); +outVec2 = vec2.transformMat4(outVec2, vec2A, mat4A); +vecArray = vec2.forEach(vecArray, 0, 0, 0, vec2.normalize); +outStr = vec2.str(vec2A); +outBool = vec2.exactEquals(vec2A, vec2B); +outBool = vec2.equals(vec2A, vec2B); + +// vec3 +outVec3 = vec3.create(); +outVec3 = vec3.clone(vec3A); +outVec3 = vec3.fromValues(1, 2, 3); +outVec3 = vec3.copy(outVec3, vec3A); +outVec3 = vec3.set(outVec3, 1, 2, 3); +outVec3 = vec3.add(outVec3, vec3A, vec3B); +outVec3 = vec3.subtract(outVec3, vec3A, vec3B); +outVec3 = vec3.sub(outVec3, vec3A, vec3B); +outVec3 = vec3.multiply(outVec3, vec3A, vec3B); +outVec3 = vec3.mul(outVec3, vec3A, vec3B); +outVec3 = vec3.divide(outVec3, vec3A, vec3B); +outVec3 = vec3.div(outVec3, vec3A, vec3B); +outVec3 = vec3.ceil(outVec3, vec3A); +outVec3 = vec3.floor(outVec3, vec3A); +outVec3 = vec3.min(outVec3, vec3A, vec3B); +outVec3 = vec3.max(outVec3, vec3A, vec3B); +outVec3 = vec3.round(outVec3, vec3A); +outVec3 = vec3.scale(outVec3, vec3A, 2); +outVec3 = vec3.scaleAndAdd(outVec3, vec3A, vec3B, 0.5); +outVal = vec3.distance(vec3A, vec3B); +outVal = vec3.dist(vec3A, vec3B); +outVal = vec3.squaredDistance(vec3A, vec3B); +outVal = vec3.sqrDist(vec3A, vec3B); +outVal = vec3.length(vec3A); +outVal = vec3.len(vec3A); +outVal = vec3.squaredLength(vec3A); +outVal = vec3.sqrLen(vec3A); +outVec3 = vec3.negate(outVec3, vec3A); +outVec3 = vec3.inverse(outVec3, vec3A); +outVec3 = vec3.normalize(outVec3, vec3A); +outVal = vec3.dot(vec3A, vec3B); +outVec3 = vec3.cross(outVec3, vec3A, vec3B); +outVec3 = vec3.lerp(outVec3, vec3A, vec3B, 0.5); +outVec3 = vec3.hermite(outVec3, vec3A, vec3B, vec3A, vec3B, 0.5); +outVec3 = vec3.bezier(outVec3, vec3A, vec3B, vec3A, vec3B, 0.5); +outVec3 = vec3.random(outVec3); +outVec3 = vec3.random(outVec3, 5.0); +outVec3 = vec3.transformMat3(outVec3, vec3A, mat3A); +outVec3 = vec3.transformMat4(outVec3, vec3A, mat4A); +outVec3 = vec3.transformQuat(outVec3, vec3A, quatA); +outVec3 = vec3.rotateX(outVec3, vec3A, vec3B, Math.PI); +outVec3 = vec3.rotateY(outVec3, vec3A, vec3B, Math.PI); +outVec3 = vec3.rotateZ(outVec3, vec3A, vec3B, Math.PI); +vecArray = vec3.forEach(vecArray, 0, 0, 0, vec3.normalize); +outVal = vec3.angle(vec3A, vec3B); +outStr = vec3.str(vec3A); +outBool = vec3.exactEquals(vec3A, vec3B); +outBool = vec3.equals(vec3A, vec3B); + +// vec4 +outVec4 = vec4.create(); +outVec4 = vec4.clone(vec4A); +outVec4 = vec4.fromValues(1, 2, 3, 4); +outVec4 = vec4.copy(outVec4, vec4A); +outVec4 = vec4.set(outVec4, 1, 2, 3, 4); +outVec4 = vec4.add(outVec4, vec4A, vec4B); +outVec4 = vec4.subtract(outVec4, vec4A, vec4B); +outVec4 = vec4.sub(outVec4, vec4A, vec4B); +outVec4 = vec4.multiply(outVec4, vec4A, vec4B); +outVec4 = vec4.mul(outVec4, vec4A, vec4B); +outVec4 = vec4.divide(outVec4, vec4A, vec4B); +outVec4 = vec4.div(outVec4, vec4A, vec4B); +outVec4 = vec4.ceil(outVec4, vec4A); +outVec4 = vec4.floor(outVec4, vec4A); +outVec4 = vec4.min(outVec4, vec4A, vec4B); +outVec4 = vec4.max(outVec4, vec4A, vec4B); +outVec4 = vec4.scale(outVec4, vec4A, 2); +outVec4 = vec4.scaleAndAdd(outVec4, vec4A, vec4B, 0.5); +outVal = vec4.distance(vec4A, vec4B); +outVal = vec4.dist(vec4A, vec4B); +outVal = vec4.squaredDistance(vec4A, vec4B); +outVal = vec4.sqrDist(vec4A, vec4B); +outVal = vec4.length(vec4A); +outVal = vec4.len(vec4A); +outVal = vec4.squaredLength(vec4A); +outVal = vec4.sqrLen(vec4A); +outVec4 = vec4.negate(outVec4, vec4A); +outVec4 = vec4.inverse(outVec4, vec4A); +outVec4 = vec4.normalize(outVec4, vec4A); +outVal = vec4.dot(vec4A, vec4B); +outVec4 = vec4.lerp(outVec4, vec4A, vec4B, 0.5); +outVec4 = vec4.random(outVec4); +outVec4 = vec4.random(outVec4, 5.0); +outVec4 = vec4.transformMat4(outVec4, vec4A, mat4A); +outVec4 = vec4.transformQuat(outVec4, vec4A, quatA); +vecArray = vec4.forEach(vecArray, 0, 0, 0, vec4.normalize); +outStr = vec4.str(vec4A); +outBool = vec4.exactEquals(vec4A, vec4B); +outBool = vec4.equals(vec4A, vec4B); + +// mat2 +outMat2 = mat2.create(); +outMat2 = mat2.clone(mat2A); +outMat2 = mat2.copy(outMat2, mat2A); +outMat2 = mat2.identity(outMat2); +outMat2 = mat2.fromValues(1, 2, 3, 4); +outMat2 = mat2.set(outMat2, 1, 2, 3, 4); +outMat2 = mat2.transpose(outMat2, mat2A); +outMat2 = mat2.invert(outMat2, mat2A); +outMat2 = mat2.adjoint(outMat2, mat2A); +outVal = mat2.determinant(mat2A); +outMat2 = mat2.multiply(outMat2, mat2A, mat2B); +outMat2 = mat2.mul(outMat2, mat2A, mat2B); +outMat2 = mat2.rotate(outMat2, mat2A, Math.PI * 0.5); +outMat2 = mat2.scale(outMat2, mat2A, vec2A); +outMat2 = mat2.fromRotation(outMat2, 0.5); +outMat2 = mat2.fromScaling(outMat2, vec2A); +outStr = mat2.str(mat2A); +outVal = mat2.frob(mat2A); +var L = mat2.create(); +var D = mat2.create(); +var U = mat2.create(); +outMat2 = mat2.LDU(L, D, U, mat2A); +outMat2 = mat2.add(outMat2, mat2A, mat2B); +outMat2 = mat2.subtract(outMat2, mat2A, mat2B); +outMat2 = mat2.sub(outMat2, mat2A, mat2B); +outBool = mat2.exactEquals(mat2A, mat2B); +outBool = mat2.equals(mat2A, mat2B); +outMat2 = mat2.multiplyScalar (outMat2, mat2A, 2); +outMat2 = mat2.multiplyScalarAndAdd (outMat2, mat2A, mat2B, 2); + +// mat2d +outMat2d = mat2d.create(); +outMat2d = mat2d.clone(mat2dA); +outMat2d = mat2d.copy(outMat2d, mat2dA); +outMat2d = mat2d.identity(outMat2d); +outMat2d = mat2d.fromValues(1, 2, 3, 4, 5, 6); +outMat2d = mat2d.set(outMat2d, 1, 2, 3, 4, 5, 6); +outMat2d = mat2d.invert(outMat2d, mat2dA); +outVal = mat2d.determinant(mat2dA); +outMat2d = mat2d.multiply(outMat2d, mat2dA, mat2dB); +outMat2d = mat2d.mul(outMat2d, mat2dA, mat2dB); +outMat2d = mat2d.rotate(outMat2d, mat2dA, Math.PI * 0.5); +outMat2d = mat2d.scale(outMat2d, mat2dA, vec2A); +outMat2d = mat2d.translate(outMat2d, mat2dA, vec2A); +outMat2d = mat2d.fromRotation(outMat2d, 0.5); +outMat2d = mat2d.fromScaling(outMat2d, vec2A); +outMat2d = mat2d.fromTranslation(outMat2d, vec2A); +outStr = mat2d.str(mat2dA); +outVal = mat2d.frob(mat2dA); +outMat2d = mat2d.add(outMat2d, mat2dA, mat2dB); +outMat2d = mat2d.subtract(outMat2d, mat2dA, mat2dB); +outMat2d = mat2d.sub(outMat2d, mat2dA, mat2dB); +outMat2d = mat2d.multiplyScalar (outMat2d, mat2dA, 2); +outMat2d = mat2d.multiplyScalarAndAdd (outMat2d, mat2dA, mat2dB, 2); +outBool = mat2d.exactEquals(mat2dA, mat2dB); +outBool = mat2d.equals(mat2dA, mat2dB); + + +// mat3 +outMat3 = mat3.create(); +outMat3 = mat3.fromMat4(outMat3, mat4A); +outMat3 = mat3.clone(mat3A); +outMat3 = mat3.copy(outMat3, mat3A); +outMat3 = mat3.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9); +outMat3 = mat3.set(outMat3, 1, 2, 3, 4, 5, 6, 7, 8, 9); +outMat3 = mat3.identity(outMat3); +outMat3 = mat3.transpose(outMat3, mat3A); +outMat3 = mat3.invert(outMat3, mat3A); +outMat3 = mat3.adjoint(outMat3, mat3A); +outVal = mat3.determinant(mat3A); +outMat3 = mat3.multiply(outMat3, mat3A, mat3B); +outMat3 = mat3.mul(outMat3, mat3A, mat3B); +outMat3 = mat3.translate(outMat3, mat3A, vec3A); +outMat3 = mat3.rotate(outMat3, mat3A, Math.PI/2); +outMat3 = mat3.scale(outMat3, mat3A, vec2A); +outMat3 = mat3.fromTranslation(outMat3, vec2A); +outMat3 = mat3.fromRotation(outMat3, Math.PI); +outMat3 = mat3.fromScaling(outMat3, vec2A); +outMat3 = mat3.fromMat2d(outMat3, mat2dA); +outMat3 = mat3.fromQuat(outMat3, quatA); +outMat3 = mat3.normalFromMat4(outMat3, mat4A); +outStr = mat3.str(mat3A); +outVal = mat3.frob(mat3A); +outMat3 = mat3.add(outMat3, mat3A, mat3B); +outMat3 = mat3.subtract(outMat3, mat3A, mat3B); +outMat3 = mat3.sub(outMat3, mat3A, mat3B); +outMat3 = mat3.multiplyScalar (outMat3, mat3A, 2); +outMat3 = mat3.multiplyScalarAndAdd (outMat3, mat3A, mat3B, 2); +outBool = mat3.exactEquals(mat3A, mat3B); +outBool = mat3.equals(mat3A, mat3B); + +//mat4 +outMat4 = mat4.create(); +outMat4 = mat4.clone(mat4A); +outMat4 = mat4.copy(outMat4, mat4A); +outMat4 = mat4.fromValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); +outMat4 = mat4.set(outMat4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); +outMat4 = mat4.identity(outMat4); +outMat4 = mat4.transpose(outMat4, mat4A); +outMat4 = mat4.invert(outMat4, mat4A); +outMat4 = mat4.adjoint(outMat4, mat4A); +outVal = mat4.determinant(mat4A); +outMat4 = mat4.multiply(outMat4, mat4A, mat4B); +outMat4 = mat4.mul(outMat4, mat4A, mat4B); +outMat4 = mat4.translate(outMat4, mat4A, vec3A); +outMat4 = mat4.scale(outMat4, mat4A, vec3A); +outMat4 = mat4.rotate(outMat4, mat4A, Math.PI, vec3A); +outMat4 = mat4.rotateX(outMat4, mat4A, Math.PI); +outMat4 = mat4.rotateY(outMat4, mat4A, Math.PI); +outMat4 = mat4.rotateZ(outMat4, mat4A, Math.PI); +outMat4 = mat4.fromTranslation(outMat4, vec3A); +outMat4 = mat4.fromRotation(outMat4, Math.PI, vec3A); +outMat4 = mat4.fromScaling(outMat4, vec3A); +outMat4 = mat4.fromXRotation(outMat4, Math.PI); +outMat4 = mat4.fromYRotation(outMat4, Math.PI); +outMat4 = mat4.fromZRotation(outMat4, Math.PI); +outMat4 = mat4.fromRotationTranslation(outMat4, quatA, vec3A); +outVec3 = mat4.getTranslation(outVec3, mat4A) +outQuat = mat4.getRotation(outQuat, mat4A) +outMat4 = mat4.fromRotationTranslationScale(outMat4, quatA, vec3A, vec3B); +outMat4 = mat4.fromRotationTranslationScaleOrigin(outMat4, quatA, vec3A, vec3B, vec3A); +outMat4 = mat4.fromQuat(outMat4, quatB); +outMat4 = mat4.frustum(outMat4, -1, 1, -1, 1, -1, 1); +outMat4 = mat4.perspective(outMat4, Math.PI, 1, 0, 1); +outMat4 = mat4.perspectiveFromFieldOfView(outMat4, {upDegrees:Math.PI, downDegrees:-Math.PI, leftDegrees:-Math.PI, rightDegrees:Math.PI}, 1, 0); +outMat4 = mat4.ortho(outMat4, -1, 1, -1, 1, -1, 1); +outMat4 = mat4.lookAt(outMat4, vec3A, vec3B, vec3A); +outStr = mat4.str(mat4A); +outVal = mat4.frob(mat4A); +outMat4 = mat4.add(outMat4, mat4A, mat4B); +outMat4 = mat4.subtract(outMat4, mat4A, mat4B); +outMat4 = mat4.sub(outMat4, mat4A, mat4B); +outMat4 = mat4.multiplyScalar (outMat4, mat4A, 2); +outMat4 = mat4.multiplyScalarAndAdd (outMat4, mat4A, mat4B, 2); +outBool = mat4.exactEquals(mat4A, mat4B); +outBool = mat4.equals(mat4A, mat4B); + +// quat +var deg90 = Math.PI / 2; +outQuat = quat.create(); +outQuat = quat.clone(quatA); +outQuat = quat.fromValues(1, 2, 3, 4); +outQuat = quat.copy(outQuat, quatA); +outQuat = quat.set(outQuat, 1, 2, 3, 4); +outQuat = quat.identity(outQuat); +outQuat = quat.rotationTo(outQuat, vec3A, vec3B); +outQuat = quat.setAxes(outQuat, vec3A, vec3B, vec3A); +outQuat = quat.setAxisAngle(outQuat, vec3A, Math.PI * 0.5); +outVal = quat.getAxisAngle (outVec3, quatA); +outQuat = quat.add(outQuat, quatA, quatB); +outQuat = quat.multiply(outQuat, quatA, quatB); +outQuat = quat.mul(outQuat, quatA, quatB); +outQuat = quat.scale(outQuat, quatA, 2); +outVal = quat.length(quatA); +outVal = quat.len(quatA); +outVal = quat.squaredLength(quatA); +outVal = quat.sqrLen(quatA); +outQuat = quat.normalize(outQuat, quatA); +outVal = quat.dot(quatA, quatB); +outQuat = quat.lerp(outQuat, quatA, quatB, 0.5); +outQuat = quat.slerp(outQuat, quatA, quatB, 0.5); +outQuat = quat.invert(outQuat, quatA); +outQuat = quat.conjugate(outQuat, quatA); +outStr = quat.str(quatA); +outQuat = quat.rotateX(outQuat, quatA, deg90); +outQuat = quat.rotateY(outQuat, quatA, deg90); +outQuat = quat.rotateZ(outQuat, quatA, deg90); +outQuat = quat.fromMat3(outQuat, mat3A); +outQuat = quat.calculateW(outQuat, quatA); +outBool = quat.exactEquals(quatA, quatB); +outBool = quat.equals(quatA, quatB); \ No newline at end of file diff --git a/gl-matrix/gl-matrix-typed.d.ts b/gl-matrix/gl-matrix-typed.d.ts index f64225c6f7..e172074fec 100644 --- a/gl-matrix/gl-matrix-typed.d.ts +++ b/gl-matrix/gl-matrix-typed.d.ts @@ -1,16 +1,16 @@ // Type definitions for gl-matrix 2.2.2 // Project: https://github.com/toji/gl-matrix -// Definitions by: Tat +// Definitions by: Mattijs Kneppers , based on definitions by Tat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Common -declare namespace glMatrix { +export class glMatrix { /** - * Convert Degree To Radian - * - * @param a Angle in Degrees - */ - export function toRadian(a: number): number; + * Convert Degree To Radian + * + * @param a Angle in Degrees + */ + public static toRadian(a: number): number; } // vec2 @@ -396,8 +396,8 @@ export class vec2 extends Float32Array { * @param arg additional argument to pass to fn * @returns a */ - public static forEach(a: vec2, stride: number, offset: number, count: number, - fn: (a: vec2, b: vec2, arg: any) => void, arg: any): vec2; + public static forEach(a: Float32Array, stride: number, offset: number, count: number, + fn: (a: vec2, b: vec2, arg: any) => void, arg: any): Float32Array; /** * Perform some operation over an array of vec2s. @@ -409,8 +409,8 @@ export class vec2 extends Float32Array { * @param fn Function to call for each vector in the array * @returns a */ - public static forEach(a: vec2, stride: number, offset: number, count: number, - fn: (a: vec2, b: vec2) => void): vec2; + public static forEach(a: Float32Array, stride: number, offset: number, count: number, + fn: (a: vec2, b: vec2) => void): Float32Array; /** * Returns a string representation of a vector @@ -868,8 +868,8 @@ export class vec3 extends Float32Array { * @returns a * @function */ - public static forEach(a: vec3, stride: number, offset: number, count: number, - fn: (a: vec3, b: vec3, arg: any) => void, arg: any): vec3; + public static forEach(a: Float32Array, stride: number, offset: number, count: number, + fn: (a: vec3, b: vec3, arg: any) => void, arg: any): Float32Array; /** * Perform some operation over an array of vec3s. @@ -882,8 +882,8 @@ export class vec3 extends Float32Array { * @returns a * @function */ - public static forEach(a: vec3, stride: number, offset: number, count: number, - fn: (a: vec3, b: vec3) => void): vec3; + public static forEach(a: Float32Array, stride: number, offset: number, count: number, + fn: (a: vec3, b: vec3) => void): Float32Array; /** * Get the angle between two 3D vectors @@ -908,7 +908,7 @@ export class vec3 extends Float32Array { * @param {vec3} b The second vector. * @returns {boolean} True if the vectors are equal, false otherwise. */ - public static exactEquals (a, b): boolean + public static exactEquals (a:vec3, b:vec3): boolean /** * Returns whether or not the vectors have approximately the same elements in the same position. @@ -917,7 +917,7 @@ export class vec3 extends Float32Array { * @param {vec3} b The second vector. * @returns {boolean} True if the vectors are equal, false otherwise. */ - public static equals (a, b) : boolean + public static equals (a:vec3, b:vec3) : boolean } // vec4 @@ -1274,8 +1274,8 @@ export class vec4 extends Float32Array { * @returns a * @function */ - public static forEach(a: vec4, stride: number, offset: number, count: number, - fn: (a: vec4, b: vec4, arg: any) => void, arg: any): vec4; + public static forEach(a: Float32Array, stride: number, offset: number, count: number, + fn: (a: vec4, b: vec4, arg: any) => void, arg: any): Float32Array; /** * Perform some operation over an array of vec4s. @@ -1288,8 +1288,8 @@ export class vec4 extends Float32Array { * @returns a * @function */ - public static forEach(a: vec4, stride: number, offset: number, count: number, - fn: (a: vec4, b: vec4) => void): vec4; + public static forEach(a: Float32Array, stride: number, offset: number, count: number, + fn: (a: vec4, b: vec4) => void): Float32Array; /** * Returns a string representation of a vector @@ -1476,7 +1476,7 @@ export class mat2 extends Float32Array { * @param {vec2} v Scaling vector * @returns {mat2} out */ - public static fromScaling(out:mat2, v:vec2); + public static fromScaling(out:mat2, v:vec2):mat2; /** * Returns a string representation of a mat2 @@ -1623,7 +1623,7 @@ export class mat2d extends Float32Array { * @param {number} ty Component TY (index 5) * @returns {mat2d} A new mat2d */ - public static fromValues (a:number, b:number, c:number, d:number, tx:number, ty:number) : mat2d + public static fromValues (a:number, b:number, c:number, d:number, tx:number, ty:number) : mat2d /** @@ -1800,7 +1800,7 @@ export class mat2d extends Float32Array { * @param {number} b amount to scale the matrix's elements by * @returns {mat2d} out */ - public static multiplyScalar (out: mat2d, a: mat2d, b: mat2d): mat2d; + public static multiplyScalar (out: mat2d, a: mat2d, b: number): mat2d; /** * Adds two mat2d's after multiplying each element of the second operand by a scalar value. @@ -1883,7 +1883,7 @@ export class mat3 extends Float32Array { * @param {number} m22 Component in column 2, row 2 position (index 8) * @returns {mat3} A new mat3 */ - public static fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22):mat3; + public static fromValues(m00:number, m01:number, m02:number, m10:number, m11:number, m12:number, m20:number, m21:number, m22:number):mat3; /** @@ -2045,15 +2045,6 @@ export class mat3 extends Float32Array { **/ public static fromMat2d(out:mat3, a:mat2d):mat3; - /** - * Copies the upper-left 3x3 values into the given mat3. - * - * @param out the receiving 3x3 matrix - * @param a the source 4x4 matrix - * @returns out - */ - public static fromMat4(out:mat3, a:mat4):mat3; - /** * Calculates a 3x3 matrix from the given quaternion * @@ -2072,7 +2063,7 @@ export class mat3 extends Float32Array { * * @returns out */ - public static normalFromMat4(out:mat3, a:mat3):mat3; + public static normalFromMat4(out:mat3, a:mat4):mat3; /** * Returns a string representation of a mat3 @@ -2210,7 +2201,7 @@ export class mat4 extends Float32Array { * @param {number} m33 Component in column 3, row 3 position (index 15) * @returns {mat4} A new mat4 */ - public static fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33):mat4; + public static fromValues(m00:number, m01:number, m02:number, m03:number, m10:number, m11:number, m12:number, m13:number, m20:number, m21:number, m22:number, m23:number, m30:number, m31:number, m32:number, m33:number):mat4; /** * Set the components of a mat4 to the given values @@ -2234,7 +2225,7 @@ export class mat4 extends Float32Array { * @param {number} m33 Component in column 3, row 3 position (index 15) * @returns {mat4} out */ - public static set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33):mat4; + public static set(out:mat4, m00:number, m01:number, m02:number, m03:number, m10:number, m11:number, m12:number, m13:number, m20:number, m21:number, m22:number, m23:number, m30:number, m31:number, m32:number, m33:number):mat4; /** * Set a mat4 to the identity matrix @@ -2571,7 +2562,7 @@ export class mat4 extends Float32Array { */ public static perspectiveFromFieldOfView(out:mat4, fov:{upDegrees:number, downDegrees:number, leftDegrees:number, rightDegrees:number}, - near, far):mat4 + near:number, far:number):mat4 /** * Generates a orthogonal projection matrix with the given bounds @@ -2653,7 +2644,7 @@ export class mat4 extends Float32Array { * @param {number} b amount to scale the matrix's elements by * @returns {mat4} out */ - public static multiplyScalar(out:mat4, a:mat4, b:mat4):mat4 + public static multiplyScalar(out:mat4, a:mat4, b:number):mat4 /** * Adds two mat4's after multiplying each element of the second operand by a scalar value. @@ -3059,5 +3050,5 @@ export class quat extends Float32Array { * @param {quat} b The second vector. * @returns {boolean} True if the quaternions are equal, false otherwise. */ - public static equals (a:quat, b:quat) : boolean; + public static equals (a:quat, b:quat) : boolean; } From 25e18b592470e3dddccc826fde2bb8e7610ef863 Mon Sep 17 00:00:00 2001 From: Aluan Haddad Date: Mon, 25 Jul 2016 12:37:59 -0400 Subject: [PATCH 03/47] Improve precision of Object.assign signature Modified the signature of `Object.assign`, adding three overloads, and adjusting the documentation of the fourth. Please note that these have been copied verbatim from the _lib.es2015.core.d.ts_ file shipped with typescript@2.1.0-dev.20160725. --- core-js/core-js.d.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/core-js/core-js.d.ts b/core-js/core-js.d.ts index e9be316364..c633dc4ef6 100644 --- a/core-js/core-js.d.ts +++ b/core-js/core-js.d.ts @@ -31,7 +31,34 @@ interface ObjectConstructor { * Copy the values of all of the enumerable own properties from one or more source objects to a * target object. Returns the target object. * @param target The target object to copy to. - * @param sources One or more source objects to copy properties from. + * @param source The source object from which to copy properties. + */ + assign(target: T, source: U): T & U; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V): T & U & V; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param source1 The first source object from which to copy properties. + * @param source2 The second source object from which to copy properties. + * @param source3 The third source object from which to copy properties. + */ + assign(target: T, source1: U, source2: V, source3: W): T & U & V & W; + + /** + * Copy the values of all of the enumerable own properties from one or more source objects to a + * target object. Returns the target object. + * @param target The target object to copy to. + * @param sources One or more source objects from which to copy properties */ assign(target: any, ...sources: any[]): any; From 8438fa6a582ffb50832fdeecbf2230c3b7dc4183 Mon Sep 17 00:00:00 2001 From: darklektor Date: Tue, 26 Jul 2016 21:19:47 +0300 Subject: [PATCH 04/47] Added FeedDialogParams to fbsdk typings --- fbsdk/fbsdk.d.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/fbsdk/fbsdk.d.ts b/fbsdk/fbsdk.d.ts index 36078fddea..23e49a3683 100644 --- a/fbsdk/fbsdk.d.ts +++ b/fbsdk/fbsdk.d.ts @@ -67,11 +67,28 @@ interface PayDialogParams { test_currency?: string; } +interface FeedDialogParams { + method: string; // "feed" + app_id: string; + redirect_uri?: string; + display?: string; + from?: string; + to?: string; + link?: string; + picture?: string; + source?: string; + name: string; + caption?: string; + description?: string; + ref?: any; +} + declare type FBUIParams = ShareDialogParams | PageTabDialogParams | RequestsDialogParams | SendDialogParams - | PayDialogParams; + | PayDialogParams + | FeedDialogParams; interface FBLoginOptions{ auth_type?: string; From 056aa8301cd56072f083e772dbe83b538490e007 Mon Sep 17 00:00:00 2001 From: osechet Date: Thu, 28 Jul 2016 12:18:45 +0200 Subject: [PATCH 05/47] Add the options argument to openlayers custom control --- openlayers/openlayers-3.14.2.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/openlayers/openlayers-3.14.2.d.ts b/openlayers/openlayers-3.14.2.d.ts index f8ca153820..5046e1fa8f 100644 --- a/openlayers/openlayers-3.14.2.d.ts +++ b/openlayers/openlayers-3.14.2.d.ts @@ -1070,6 +1070,25 @@ declare namespace olx { rightHanded?: boolean; } } + + namespace control { + interface ControlOptions { + /** + * The element is the control's container element. This only needs to be specified if you're developing a custom control. + */ + element?: Element; + + /** + * Function called when the control should be re-rendered. This is called in a requestAnimationFrame callback. + */ + render?: any; + + /** + * Specify a target if you want the control to be rendered outside of the map's viewport. + */ + target?: Element | string; + } + } } /** @@ -2388,6 +2407,7 @@ declare namespace ol { } class Control { + constructor(options: olx.control.ControlOptions); } class FullScreen { From d6fa7eb79f413fb318cc2f648c4219642fbe51d3 Mon Sep 17 00:00:00 2001 From: Manish Lakhara Date: Sat, 30 Jul 2016 03:11:17 +0530 Subject: [PATCH 06/47] Added Thenable interface for Async Methods. According to HelloJs doc, async methods return Promise A+ compliant thenable. So added interface for thenable and changed return type of login, logout and api methods. --- hellojs/hellojs.d.ts | 53 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index 686d5c1adf..64e7372a08 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -35,10 +35,49 @@ interface HelloJSEventArgument { authResponse?: any; } +interface HelloJSImmediateSuccessCB { + (value: T): TP; +} + +interface HelloJSImmediateErrorCB { + (err: any): TP; +} + +interface HelloJSDeferredSuccessCB { + (value: T): HelloJSThenable; +} + +interface HelloJSDeferredErrorCB { + (error: any): HelloJSThenable; +} + +interface HelloJSThenable { + then( + successCB?: HelloJSDeferredSuccessCB, + errorCB?: HelloJSDeferredErrorCB + ): HelloJSThenable; + + then( + successCB?: HelloJSDeferredSuccessCB, + errorCB?: HelloJSImmediateErrorCB + ): HelloJSThenable; + + then( + successCB?: HelloJSImmediateSuccessCB, + errorCB?: HelloJSDeferredErrorCB + ): HelloJSThenable; + + then( + successCB?: HelloJSImmediateSuccessCB, + errorCB?: HelloJSImmediateErrorCB + ): HelloJSThenable; +} + + interface HelloJSStatic extends HelloJSEvent { init(serviceAppIds: { [id: string]: string; }, options?: HelloJSLoginOptions): void; - login(network: string, options?: HelloJSLoginOptions, callback?: () => void): void; - logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): void; + login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; + logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; getAuthResponse(network: string): any; service(network: string): HelloJSServiceDef; settings: HelloJSLoginOptions; @@ -46,11 +85,15 @@ interface HelloJSStatic extends HelloJSEvent { init(servicesDef: { [id: string]: HelloJSServiceDef; }): void; } + + + + interface HelloJSStaticNamed { - login(option?: HelloJSLoginOptions, callback?: () => void): void; - logout(callback?: () => void): void; + login(option?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; + logout(callback?: () => void): HelloJSThenable; getAuthResponse(): any; - api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSStatic; + api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSThenable; } interface HelloJSOAuthDef { From 3e722697c85ac46a9b262447806b91247185c6a1 Mon Sep 17 00:00:00 2001 From: Manish Lakhara Date: Sat, 30 Jul 2016 03:27:03 +0530 Subject: [PATCH 07/47] Fix: HelloJSThenable required a type parameter. --- hellojs/hellojs.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index 64e7372a08..7dabae4054 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -76,8 +76,8 @@ interface HelloJSThenable { interface HelloJSStatic extends HelloJSEvent { init(serviceAppIds: { [id: string]: string; }, options?: HelloJSLoginOptions): void; - login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; - logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; + login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; + logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; getAuthResponse(network: string): any; service(network: string): HelloJSServiceDef; settings: HelloJSLoginOptions; @@ -90,10 +90,10 @@ interface HelloJSStatic extends HelloJSEvent { interface HelloJSStaticNamed { - login(option?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; - logout(callback?: () => void): HelloJSThenable; + login(option?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; + logout(callback?: () => void): HelloJSThenable; getAuthResponse(): any; - api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSThenable; + api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSThenable; } interface HelloJSOAuthDef { From 406a22a9c1ed920e23f0b4ad6069810962479885 Mon Sep 17 00:00:00 2001 From: Manish Lakhara Date: Sat, 30 Jul 2016 03:49:59 +0530 Subject: [PATCH 08/47] Implemented a simpler then interface as generic typings was not needed --- hellojs/hellojs.d.ts | 59 +++++++++----------------------------------- 1 file changed, 11 insertions(+), 48 deletions(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index 7dabae4054..d54bca2905 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -27,57 +27,24 @@ interface HelloJSEvent { success(callback: (json?: any) => void): HelloJSStatic; error(callback: (json?: any) => void): HelloJSStatic; complete(callback: (json?: any) => void): HelloJSStatic; + then(successCallback: (json?: any) => void, errorCallback: (json?: any) => void): HelloJSStatic; } +interface HelloJSThenable { + then(successCallback: (json?: any) => void, errorCallback: (json?: any) => void): HelloJSStatic; +} + + interface HelloJSEventArgument { network: string; authResponse?: any; } -interface HelloJSImmediateSuccessCB { - (value: T): TP; -} - -interface HelloJSImmediateErrorCB { - (err: any): TP; -} - -interface HelloJSDeferredSuccessCB { - (value: T): HelloJSThenable; -} - -interface HelloJSDeferredErrorCB { - (error: any): HelloJSThenable; -} - -interface HelloJSThenable { - then( - successCB?: HelloJSDeferredSuccessCB, - errorCB?: HelloJSDeferredErrorCB - ): HelloJSThenable; - - then( - successCB?: HelloJSDeferredSuccessCB, - errorCB?: HelloJSImmediateErrorCB - ): HelloJSThenable; - - then( - successCB?: HelloJSImmediateSuccessCB, - errorCB?: HelloJSDeferredErrorCB - ): HelloJSThenable; - - then( - successCB?: HelloJSImmediateSuccessCB, - errorCB?: HelloJSImmediateErrorCB - ): HelloJSThenable; -} - - interface HelloJSStatic extends HelloJSEvent { init(serviceAppIds: { [id: string]: string; }, options?: HelloJSLoginOptions): void; - login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; - logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; + login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; + logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; getAuthResponse(network: string): any; service(network: string): HelloJSServiceDef; settings: HelloJSLoginOptions; @@ -85,15 +52,11 @@ interface HelloJSStatic extends HelloJSEvent { init(servicesDef: { [id: string]: HelloJSServiceDef; }): void; } - - - - interface HelloJSStaticNamed { - login(option?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; - logout(callback?: () => void): HelloJSThenable; + login(option?: HelloJSLoginOptions, callback?: () => void): void; + logout(callback?: () => void): void; getAuthResponse(): any; - api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSThenable; + api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSStatic; } interface HelloJSOAuthDef { From fe2f0deec12c47b636e0a9817ec4fb36d6a2c024 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Tue, 2 Aug 2016 13:27:16 +0200 Subject: [PATCH 09/47] fix: Enable the use of the parse() method for superagent --- superagent/superagent-tests.ts | 18 ++++++++++++++++++ superagent/superagent.d.ts | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/superagent/superagent-tests.ts b/superagent/superagent-tests.ts index 58b6840440..cc270a8ca4 100644 --- a/superagent/superagent-tests.ts +++ b/superagent/superagent-tests.ts @@ -193,6 +193,24 @@ request('/search') var charset: string = res.charset; }); +// Custom parsers +request + .post('/search') + .parse((res, callback) => { + res.setEncoding("binary"); + let data = ""; + res.on("data", (chunk: string) => { + data += chunk; + }); + + res.on("end", () => { + callback(null, new Buffer(data, "base64")); + }); + }) + .end((res: request.Response) => { + res.body.toString("hex"); + }); + var req = request.get('/hoge'); // Aborting requests req.abort(); diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index d16b13584f..9d9f3a8f15 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -50,7 +50,7 @@ declare module "superagent" { search(url: string, callback?: CallbackHandler): Req; connect(url: string, callback?: CallbackHandler): Req; - parse(fn: Function): Req; + parse(fn: (res: Response, callback: (err: Error, body: any) => void) => void): this; saveCookies(res: Response): void; attachCookies(req: Req): void; } @@ -107,6 +107,7 @@ declare module "superagent" { withCredentials(): this; write(data: string, encoding?: string): this; write(data: Buffer, encoding?: string): this; + parse(fn: (res: Response, callback: (err: Error, body: any) => void) => void): this; } } From b91b67fc09fc34ae8f7e34b0d2a905421de101c5 Mon Sep 17 00:00:00 2001 From: Alexander Hefner Date: Tue, 2 Aug 2016 15:32:54 +0200 Subject: [PATCH 10/47] jasmine-ajax stubRequest data can be a RegExp as well #10315 --- jasmine-ajax/jasmine-ajax.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jasmine-ajax/jasmine-ajax.d.ts b/jasmine-ajax/jasmine-ajax.d.ts index 143b3b1a5c..0eb873e048 100644 --- a/jasmine-ajax/jasmine-ajax.d.ts +++ b/jasmine-ajax/jasmine-ajax.d.ts @@ -73,6 +73,9 @@ declare class MockAjax { stubRequest(url: RegExp, data?: string, method?: string): JasmineAjaxRequestStub; stubRequest(url: string, data?: string, method?: string): JasmineAjaxRequestStub; + + stubRequest(url: RegExp, data?: RegExp, method?: string): JasmineAjaxRequestStub; + stubRequest(url: string, data?: RegExp, method?: string): JasmineAjaxRequestStub; requests: JasmineAjaxRequestTracker; stubs: JasmineAjaxStubTracker; From b5d87c636a43d2d4a411116a5493db2a2d623d80 Mon Sep 17 00:00:00 2001 From: anwalkers Date: Tue, 2 Aug 2016 08:58:08 -0700 Subject: [PATCH 11/47] Added event listeners --- i18next/i18next.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 5e2f8dcd20..07517c1e2c 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -119,6 +119,8 @@ declare namespace I18next { createInstance(options?:Options, callback?:(err:any, t:TranslationFunction) => void):I18n; cloneInstance(options?:Options, callback?:(err:any, t:TranslationFunction) => void):I18n; + + on(event: string, listener: (options: I18next.Options) => void ): void; } } From 007a7ec5bf2ac268676845c552b4b47ac7eb5ec1 Mon Sep 17 00:00:00 2001 From: anwalkers Date: Tue, 2 Aug 2016 15:38:29 -0700 Subject: [PATCH 12/47] added other events and emitter.off --- i18next/i18next.d.ts | 80 ++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 07517c1e2c..6e561a98bd 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -39,15 +39,15 @@ declare namespace I18next { count?: number; context?: any; replace?: any; - lng?:string; - lngs?:string[]; - fallbackLng?:string; - ns?:string|string[]; - keySeparator?:string; - nsSeparator?:string; - returnObjects?:boolean; - joinArrays?:string; - postProcess?:string|any[]; + lng?: string; + lngs?: string[]; + fallbackLng?: string; + ns?: string | string[]; + keySeparator?: string; + nsSeparator?: string; + returnObjects?: boolean; + joinArrays?: string; + postProcess?: string | any[]; interpolation?: InterpolationOptions; } @@ -56,10 +56,10 @@ declare namespace I18next { resources?: ResourceStore; lng?: string; fallbackLng?: string; - ns?: string|string[]; + ns?: string | string[]; defaultNS?: string; - fallbackNS?: string|string[]; - whitelist?:string[]; + fallbackNS?: string | string[]; + whitelist?: string[]; lowerCaseLng?: boolean; load?: string preload?: string[]; @@ -69,63 +69,71 @@ declare namespace I18next { contextSeparator?: string; saveMissing?: boolean; saveMissingTo?: string; - missingKeyHandler?: (lng:string, ns:string, key:string, fallbackValue:string) => void; - parseMissingKeyHandler?: (key:string) => void; + missingKeyHandler?: (lng: string, ns: string, key: string, fallbackValue: string) => void; + parseMissingKeyHandler?: (key: string) => void; appendNamespaceToMissingKey?: boolean; - postProcess?: string|any[]; + postProcess?: string | any[]; returnNull?: boolean; returnEmptyString?: boolean; returnObjects?: boolean; - returnedObjectHandler?: (key:string, value:string, options:any) => void; + returnedObjectHandler?: (key: string, value: string, options: any) => void; joinArrays?: string; - overloadTranslationOptionHandler?: (args:any[]) => TranslationOptions; + overloadTranslationOptionHandler?: (args: any[]) => TranslationOptions; interpolation?: InterpolationOptions; detection?: any; backend?: any; cache?: any; } - type TranslationFunction = (key:string, options?:TranslationOptions) => string; + type TranslationFunction = (key: string, options?: TranslationOptions) => string; class I18n { - constructor(options?:Options, callback?:(err:any, t:TranslationFunction) => void); + constructor(options?: Options, callback?: (err: any, t: TranslationFunction) => void); - init(options?:Options, callback?:(err:any, t:TranslationFunction) => void):I18n; + init(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; - loadResources(callback?:(err:any) => void):void; + loadResources(callback?: (err: any) => void): void; - language:string; + language: string; - languages:string[]; + languages: string[]; - use(module:any):I18n; + use(module: any): I18n; - changeLanguage(lng:string, callback?:(err:any, t:TranslationFunction) => void):void; + changeLanguage(lng: string, callback?: (err: any, t: TranslationFunction) => void): void; - getFixedT(lng?:string, ns?:string|string[]):TranslationFunction; + getFixedT(lng?: string, ns?: string | string[]): TranslationFunction; - t(key:string, options?:TranslationOptions):string|any|Array; + t(key: string, options?: TranslationOptions): string | any | Array; - exists():boolean; + exists(): boolean; - setDefaultNamespace(ns:string):void; + setDefaultNamespace(ns: string): void; - loadNamespaces(ns:string[], callback?:() => void):void; + loadNamespaces(ns: string[], callback?: () => void): void; - loadLanguages(lngs:string[], callback?:()=>void):void; + loadLanguages(lngs: string[], callback?: () => void): void; - dir(lng?:string):string; + dir(lng?: string): string; - createInstance(options?:Options, callback?:(err:any, t:TranslationFunction) => void):I18n; + createInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; - cloneInstance(options?:Options, callback?:(err:any, t:TranslationFunction) => void):I18n; + cloneInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; - on(event: string, listener: (options: I18next.Options) => void ): void; + on(initialized: string, listener: (options: I18next.Options) => void): void; + on(loaded: string, listener: (loaded: any) => void): void; + on(failedLoading: string, listener: (lng: string, ns: string, msg: string) => void): void; + on(missingKey: string, listener: (lngs: any, namespace: string, key: string, res) => void): void; + on(added: string, listener: (lng: string, ns: string) => void): void; + on(removed: string, listener: (lng: string, ns: string) => void): void; + on(languageChanged: string, listener: (lng: string) => void): void; + + off(event: string, listener: () => void): void; } } declare module 'i18next' { - var i18n:I18next.I18n; + var i18n: I18next.I18n; export = i18n; } From 71a58acf25285d2197e7c78b0876cbfd6bb9b17c Mon Sep 17 00:00:00 2001 From: anwalkers Date: Tue, 2 Aug 2016 15:40:55 -0700 Subject: [PATCH 13/47] fixed implicit any --- i18next/i18next.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 6e561a98bd..18230db023 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -123,7 +123,7 @@ declare namespace I18next { on(initialized: string, listener: (options: I18next.Options) => void): void; on(loaded: string, listener: (loaded: any) => void): void; on(failedLoading: string, listener: (lng: string, ns: string, msg: string) => void): void; - on(missingKey: string, listener: (lngs: any, namespace: string, key: string, res) => void): void; + on(missingKey: string, listener: (lngs: any, namespace: string, key: string, res: any) => void): void; on(added: string, listener: (lng: string, ns: string) => void): void; on(removed: string, listener: (lng: string, ns: string) => void): void; on(languageChanged: string, listener: (lng: string) => void): void; From e35437bad2149015f50d08691923406d577e3fc7 Mon Sep 17 00:00:00 2001 From: Brooke Smith Date: Wed, 3 Aug 2016 12:46:18 +1000 Subject: [PATCH 14/47] Fix service_worker_api bug * Some Requests should be Responses * Fixed other testing bugs * Due to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/5015 I removed es6-promises inclusion --- service_worker_api/service_worker_api-test.ts | 18 ++++++++++-------- service_worker_api/service_worker_api.d.ts | 11 ++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/service_worker_api/service_worker_api-test.ts b/service_worker_api/service_worker_api-test.ts index e144880ba1..0d39cc509b 100644 --- a/service_worker_api/service_worker_api-test.ts +++ b/service_worker_api/service_worker_api-test.ts @@ -19,13 +19,11 @@ self.addEventListener('fetch', function(event: FetchEvent) { }); self.caches.open('v1').then(function(cache: Cache) { - cache.matchAll('/images/').then(function(response: Array) { + cache.matchAll('/images/').then(function(response: Array) { response.forEach(function(element, index, array) { - cache.delete(element); - + cache.delete(element.url); }); }); - }); self.addEventListener('install', function(event: InstallEvent) { @@ -56,7 +54,11 @@ self.addEventListener('install', function(event: InstallEvent) { }); self.addEventListener('fetch', function(event: FetchEvent) { - var cachedResponse = self.caches.match(event.request).catch(function() { + var cachedResponse = self.caches.match(event.request).then(function(response: Response) { + if (response) { + return response; + } + }).catch(function() { return self.fetch(event.request).then(function(response: Response) { return self.caches.open('v1').then(function(cache) { cache.put(event.request, response.clone()); @@ -71,8 +73,8 @@ self.addEventListener('fetch', function(event: FetchEvent) { }); self.caches.open('v1').then(function(cache) { - cache.match('/images/image.png').then(function(response) { - cache.delete(response); + cache.match('/images/image.png').then(function(response: Response) { + cache.delete(response.url); }); }); @@ -185,4 +187,4 @@ self.addEventListener('notificationclick', function(event: NotificationEvent) { if (self.clients.openWindow) return self.clients.openWindow('/'); })); -}); \ No newline at end of file +}); diff --git a/service_worker_api/service_worker_api.d.ts b/service_worker_api/service_worker_api.d.ts index 77c80b6706..6084efc4a0 100644 --- a/service_worker_api/service_worker_api.d.ts +++ b/service_worker_api/service_worker_api.d.ts @@ -3,7 +3,8 @@ // Definitions by: Tristan Caron // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +// // REMOVED third "/" so this doesn't fire. Problem with duplicate Promises +// between es6 and typescript - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/5015 /** * Provides methods relating to the body of the response/request, allowing you @@ -279,16 +280,16 @@ interface Cache { * @param request The Request you are attempting to find in the Cache. * @param {CacheOptions} options */ - match(request: Request | string, options?: CacheOptions): Promise; + match(request: Request | string, options?: CacheOptions): Promise; /** - * Returns a Promise that resolves to an array of all matching requests in + * Returns a Promise that resolves to an array of all matching responses in * the Cache object. * * @param request The Request you are attempting to find in the Cache. * @param {CacheOptions} options */ - matchAll(request: Request | string, options?: CacheOptions): Promise>; + matchAll(request: Request | string, options?: CacheOptions): Promise>; /** * Returns a Promise that resolves to a new Cache entry whose key @@ -893,4 +894,4 @@ interface Window extends ServiceWorkerGlobalScope { interface NotificationEvent extends Event, ExtendableEvent { notification: any; -} \ No newline at end of file +} From 5d58ff759b11dfd18446b2f5e30ea78fd025c6e7 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Wed, 3 Aug 2016 14:13:26 +0200 Subject: [PATCH 15/47] Update to Electron 1.3.2 --- github-electron/github-electron-main-tests.ts | 39 +++++++ github-electron/github-electron.d.ts | 105 +++++++++++++++++- 2 files changed, 139 insertions(+), 5 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index 4453967cc4..0392702e6a 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -577,6 +577,42 @@ var template = [ focusedWindow.webContents.toggleDevTools(); } } + }, + { + type: 'separator' + }, + { + label: 'Actual Size', + accelerator: 'CmdOrCtrl+0', + click: (item, focusedWindow) => { + if (focusedWindow) { + focusedWindow.webContents.setZoomLevel(0) + } + } + }, + { + label: 'Zoom In', + accelerator: 'CmdOrCtrl+Plus', + click: (item, focusedWindow) => { + if (focusedWindow) { + const { webContents } = focusedWindow; + webContents.getZoomLevel((zoomLevel) => { + webContents.setZoomLevel(zoomLevel + 0.5) + }); + } + } + }, + { + label: 'Zoom Out', + accelerator: 'CmdOrCtrl+-', + click: (item, focusedWindow) => { + if (focusedWindow) { + const { webContents } = focusedWindow; + webContents.getZoomLevel((zoomLevel) => { + webContents.setZoomLevel(zoomLevel - 0.5) + }); + } + } } ] }, @@ -827,6 +863,8 @@ shell.openExternal('https://github.com', { shell.beep(); +shell.writeShortcutLink('/home/user/Desktop/shortcut.lnk', 'update', shell.readShortcutLink('/home/user/Desktop/shortcut.lnk')); + // session // https://github.com/atom/electron/blob/master/docs/api/session.md @@ -860,6 +898,7 @@ session.defaultSession.cookies.set(cookie, (error) => { session.defaultSession.on('will-download', (event, item, webContents) => { // Set the save path, making Electron not to prompt a save dialog. item.setSavePath('/tmp/save.pdf'); + console.log(item.getSavePath()); console.log(item.getMimeType()); console.log(item.getFilename()); console.log(item.getTotalBytes()); diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 98cf047493..0961eb03cf 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron v1.3.1 +// Type definitions for Electron v1.3.2 // Project: http://electron.atom.io/ // Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -490,6 +490,13 @@ declare namespace Electron { * Note: This API is only available on macOS. */ show(): void; + /** + * @returns Whether the dock icon is visible. + * The app.dock.show() call is asynchronous so this method might not return true immediately after that call. + * + * Note: This API is only available on macOS. + */ + isVisible(): boolean; /** * Sets the application dock menu. * @@ -2049,6 +2056,11 @@ declare namespace Electron { * routine to determine the save path (Usually prompts a save dialog). */ setSavePath(path: string): void; + /** + * @returns The save path of the download item. + * This will be either the path set via downloadItem.setSavePath(path) or the path selected from the shown save dialog. + */ + getSavePath(): string; /** * Pauses the download. */ @@ -2438,13 +2450,17 @@ declare namespace Electron { */ static createFromDataURL(dataURL: string): NativeImage; /** - * @returns Buffer Contains the image's PNG encoded data. + * @returns Buffer that contains the image's PNG encoded data. */ toPNG(): Buffer; /** - * @returns Buffer Contains the image's JPEG encoded data. + * @returns Buffer that contains the image's JPEG encoded data. */ toJPEG(quality: number): Buffer; + /** + * @returns Buffer that contains the image's raw pixel data. + */ + toBitmap(): Buffer; /** * @returns string The data URL of the image. */ @@ -3250,6 +3266,62 @@ declare namespace Electron { * Play the beep sound. */ beep(): void; + /** + * Creates or updates a shortcut link at shortcutPath. + * + * Note: This API is available only on Windows. + */ + writeShortcutLink(shortcutPath: string, options: ShortcutLinkOptions): boolean; + /** + * Creates or updates a shortcut link at shortcutPath. + * + * Note: This API is available only on Windows. + */ + writeShortcutLink(shortcutPath: string, operation: 'create' | 'update' | 'replace', options: ShortcutLinkOptions): boolean; + /** + * Resolves the shortcut link at shortcutPath. + * An exception will be thrown when any error happens. + * + * Note: This API is available only on Windows. + */ + readShortcutLink(shortcutPath: string): ShortcutLinkOptions; + } + + interface ShortcutLinkOptions { + /** + * The target to launch from this shortcut. + */ + target: string; + /** + * The working directory. + * Default: empty. + */ + cwd?: string; + /** + * The arguments to be applied to target when launching from this shortcut. + * Default: empty. + */ + args?: string; + /** + * The description of the shortcut. + * Default: empty. + */ + description?: string; + /** + * The path to the icon, can be a DLL or EXE. icon and iconIndex have to be set together. + * Default: empty, which uses the target's icon. + */ + icon?: string; + /** + * The resource ID of icon when icon is a DLL or EXE. + * Default: 0. + */ + iconIndex?: number; + /** + * The Application User Model ID. + * Default: empty. + */ + appUserModelId?: string; } // https://github.com/electron/electron/blob/master/docs/api/system-preferences.md @@ -3634,9 +3706,9 @@ declare namespace Electron { /** * Emitted when the cursor’s type changes. * If the type parameter is custom, the image parameter will hold the custom cursor image - * in a NativeImage, and the scale will hold scaling information for the image. + * in a NativeImage, and scale, size and hotspot will hold additional information about the custom cursor. */ - on(event: 'cursor-changed', listener: (event: Event, type: CursorType, image?: NativeImage, scale?: number) => void): this; + on(event: 'cursor-changed', listener: (event: Event, type: CursorType, image?: NativeImage, scale?: number, size?: Size, hotspot?: Point) => void): this; /** * Emitted when there is a new context menu that needs to be handled. */ @@ -3762,6 +3834,29 @@ declare namespace Electron { * @returns Whether this page has been muted. */ isAudioMuted(): boolean; + /** + * Changes the zoom factor to the specified factor. + * Zoom factor is zoom percent divided by 100, so 300% = 3.0. + */ + setZoomFactor(factor: number): void; + /** + * Sends a request to get current zoom factor. + */ + getZoomFactor(callback: (zoomFactor: number) => void): void; + /** + * Changes the zoom level to the specified level. + * The original size is 0 and each increment above or below represents + * zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively. + */ + setZoomLevel(level: number): void; + /** + * Sends a request to get current zoom level. + */ + getZoomLevel(callback: (zoomLevel: number) => void): void; + /** + * Sets the maximum and minimum zoom level. + */ + setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void; /** * Executes the editing command undo in web page. */ From ff3fe1639015362b1dc0dfb2de1423cddf770ce7 Mon Sep 17 00:00:00 2001 From: anwalkers Date: Wed, 3 Aug 2016 09:07:22 -0700 Subject: [PATCH 16/47] attempt String Literal Type. tslint doesn't like them --- i18next/i18next.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 18230db023..ccecb67216 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -120,13 +120,13 @@ declare namespace I18next { cloneInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; - on(initialized: string, listener: (options: I18next.Options) => void): void; - on(loaded: string, listener: (loaded: any) => void): void; - on(failedLoading: string, listener: (lng: string, ns: string, msg: string) => void): void; - on(missingKey: string, listener: (lngs: any, namespace: string, key: string, res: any) => void): void; - on(added: string, listener: (lng: string, ns: string) => void): void; - on(removed: string, listener: (lng: string, ns: string) => void): void; - on(languageChanged: string, listener: (lng: string) => void): void; + on(initialized: 'initialized', listener: (options: I18next.Options) => void): void; + on(loaded: 'loaded', listener: (loaded: any) => void): void; + on(failedLoading: 'failedLoading', listener: (lng: string, ns: string, msg: string) => void): void; + on(missingKey: 'missingKey', listener: (lngs: any, namespace: string, key: string, res: any) => void): void; + on(added: 'added', listener: (lng: string, ns: string) => void): void; + on(removed: 'removed', listener: (lng: string, ns: string) => void): void; + on(languageChanged: 'languageChanged', listener: (lng: string) => void): void; off(event: string, listener: () => void): void; } From d083424a0e104d3258926cedd7f892b0ea6aa03f Mon Sep 17 00:00:00 2001 From: anwalkers Date: Wed, 3 Aug 2016 09:11:18 -0700 Subject: [PATCH 17/47] rollback to non string literal type --- i18next/i18next.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index ccecb67216..18230db023 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -120,13 +120,13 @@ declare namespace I18next { cloneInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; - on(initialized: 'initialized', listener: (options: I18next.Options) => void): void; - on(loaded: 'loaded', listener: (loaded: any) => void): void; - on(failedLoading: 'failedLoading', listener: (lng: string, ns: string, msg: string) => void): void; - on(missingKey: 'missingKey', listener: (lngs: any, namespace: string, key: string, res: any) => void): void; - on(added: 'added', listener: (lng: string, ns: string) => void): void; - on(removed: 'removed', listener: (lng: string, ns: string) => void): void; - on(languageChanged: 'languageChanged', listener: (lng: string) => void): void; + on(initialized: string, listener: (options: I18next.Options) => void): void; + on(loaded: string, listener: (loaded: any) => void): void; + on(failedLoading: string, listener: (lng: string, ns: string, msg: string) => void): void; + on(missingKey: string, listener: (lngs: any, namespace: string, key: string, res: any) => void): void; + on(added: string, listener: (lng: string, ns: string) => void): void; + on(removed: string, listener: (lng: string, ns: string) => void): void; + on(languageChanged: string, listener: (lng: string) => void): void; off(event: string, listener: () => void): void; } From 1fb90278ce678b668e0bed069095b1920dc658ec Mon Sep 17 00:00:00 2001 From: anwalkers Date: Wed, 3 Aug 2016 10:52:12 -0700 Subject: [PATCH 18/47] @mxl suggested for getting string literals working --- i18next/i18next.d.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 18230db023..5ced8aecdb 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -119,14 +119,15 @@ declare namespace I18next { createInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; cloneInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; - - on(initialized: string, listener: (options: I18next.Options) => void): void; - on(loaded: string, listener: (loaded: any) => void): void; - on(failedLoading: string, listener: (lng: string, ns: string, msg: string) => void): void; - on(missingKey: string, listener: (lngs: any, namespace: string, key: string, res: any) => void): void; - on(added: string, listener: (lng: string, ns: string) => void): void; - on(removed: string, listener: (lng: string, ns: string) => void): void; - on(languageChanged: string, listener: (lng: string) => void): void; + + on(event: string, listener: () => void): void; + on(initialized: 'initialized', listener: (options: I18next.Options) => void): void; + on(loaded: 'loaded', listener: (loaded: any) => void): void; + on(failedLoading: 'failedLoading', listener: (lng: string, ns: string, msg: string) => void): void; + on(missingKey: 'missingKey', listener: (lngs: any, namespace: string, key: string, res: any) => void): void; + on(added: 'added', listener: (lng: string, ns: string) => void): void; + on(removed: 'removed', listener: (lng: string, ns: string) => void): void; + on(languageChanged: 'languageChanged', listener: (lng: string) => void): void; off(event: string, listener: () => void): void; } From 5a771fdfce1ce227d2f673f2d68910a9299746e8 Mon Sep 17 00:00:00 2001 From: Jonas Brekle Date: Wed, 3 Aug 2016 10:51:23 +0200 Subject: [PATCH 19/47] extend ckeditor typings with: 'env' property, 'commands' property, tools.enableHtml5Elements function, fix buttonDefinition for addButton, addMenuItem(s) with typed definition argument --- ckeditor/ckeditor.d.ts | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts index 9d8728338f..60b6491407 100644 --- a/ckeditor/ckeditor.d.ts +++ b/ckeditor/ckeditor.d.ts @@ -57,6 +57,7 @@ declare namespace CKEDITOR { var basePath: string; var currentInstance: editor; var document: dom.document; + var env: environmentConfig; var instances: editor[]; var loadFullCoreTimeout: number; var revision: string; @@ -1029,6 +1030,12 @@ declare namespace CKEDITOR { } + interface IMenuItemDefinition { + label:string, + command:string, + group:string, + order:number + } class editor extends event { activeEnterMode: number; @@ -1066,13 +1073,14 @@ declare namespace CKEDITOR { addCommand(commandName: string, commandDefinition: commandDefinition): void; addFeature(feature: feature): boolean; addMenuGroup(name: string, order?: number): void; - addMenuItem(name: string, definition?: any): void; - addMenuItems(definitions: any[]): void; + addMenuItem(name: string, definition?: IMenuItemDefinition): void; + addMenuItems(definitions: {[id:string]:IMenuItemDefinition}): void; addMode(mode: string, exec: () => void): void; addRemoveFormatFilter(func: Function): void; applyStyle(style: style): void; attachStyleStateChange(style: style, callback: Function): void; checkDirty(): boolean; + commands:any; createFakeElement(realElement: Object, className: Object, realElementType: Object, isResizable: Object): void; createFakeParserElement(realElement: Object, className: Object, realElementType: Object, isResizable: Object): void; createRange(): dom.range; @@ -1235,6 +1243,11 @@ declare namespace CKEDITOR { } + interface buttonDefinition { + label : string; + command : string; + toolbar : string; + } interface template { @@ -1284,10 +1297,31 @@ declare namespace CKEDITOR { class ui extends event { constructor(editor: editor); add(name: string, type: Object, definition: Object): void; - addButton(name: string, definition: dialog.definition.button): void; + addButton(name: string, definition: buttonDefinition): void; addHandler(type: Object, handler: Object): void; } + class environmentConfig { + air : boolean; + chrome : boolean; + cssClass : string; + edge : boolean; + gecko : boolean; + hc : boolean; + hidpi : boolean; + iOS : boolean; + ie : boolean; + isCompatible : boolean; + mac : boolean; + needsBrFiller : boolean; + needsNbspFiller : boolean; + quirks : boolean; + safari : boolean; + version : number; + webkit : boolean; + secure( ) : boolean; + } + namespace ui { namespace dialog { class uiElement { @@ -1761,6 +1795,7 @@ declare namespace CKEDITOR { namespace tools { var callFunction: Function; + function enableHtml5Elements(doc: Object, withAppend? : Boolean) : void; } @@ -1772,3 +1807,4 @@ declare namespace CKEDITOR { function detect(defaultLanguage: string, probeLanguage: string): string; } } + From 4ad073419e93b469d48f5287c93b67b4381d14c4 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 5 Aug 2016 09:39:51 +0200 Subject: [PATCH 20/47] Using typeof and export instead of duplicating declaration in Ember. --- ember/ember.d.ts | 423 +---------------------------------------------- 1 file changed, 2 insertions(+), 421 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index b50fdc536e..a151cbfea2 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -2562,431 +2562,12 @@ declare namespace Ember { function wrap(func: Function, superFunc: Function): Function; } -// ReSharper disable DuplicatingLocalDeclaration -declare namespace Em { - /** - Alias for jQuery. - **/ - var $: typeof Ember.$; - var A: typeof Ember.A; - class ActionHandlerMixin extends Ember.ActionHandlerMixin { } - class Application extends Ember.Application { } - class Array extends Ember.Array { } - class ArrayProxy extends Ember.ArrayProxy { } - var BOOTED: typeof Ember.BOOTED; - class Binding extends Ember.Binding { } - class Button extends Ember.Button { } - class Checkbox extends Ember.Checkbox { } - class Comparable extends Ember.Comparable { } - class Component extends Ember.Component { } - class ComputedProperty extends Ember.ComputedProperty { } - class Container extends Ember.Container { } - class Controller extends Ember.Controller { } - class ControllerMixin extends Ember.ControllerMixin { } - class Copyable extends Ember.Copyable { } - class CoreObject extends Ember.CoreObject { } - class DAG extends Ember.DAG { } - var DEFAULT_GETTER_FUNCTION: typeof Ember.DEFAULT_GETTER_FUNCTION; - class DefaultResolver extends Ember.DefaultResolver { } - class Descriptor extends Ember.Descriptor { } - var EMPTY_META: typeof Ember.EMPTY_META; - var ENV: typeof Ember.ENV; - var EXTEND_PROTOTYPES: typeof Ember.EXTEND_PROTOTYPES; - class EachProxy extends Ember.EachProxy { } - class Enumerable extends Ember.Enumerable { } - var Error: typeof Ember.Error; - class EventDispatcher extends Ember.EventDispatcher { } - class Evented extends Ember.Evented { } - var FROZEN_ERROR: typeof Ember.FROZEN_ERROR; - class Freezable extends Ember.Freezable { } - var GUID_KEY: typeof Ember.GUID_KEY; - namespace Handlebars { - var compile: typeof Ember.Handlebars.compile; - var precompile: typeof Ember.Handlebars.precompile; - class Compiler extends Ember.Handlebars.Compiler { } - class JavaScriptCompiler extends Ember.Handlebars.JavaScriptCompiler { } - var registerPartial: typeof Ember.Handlebars.registerPartial; - var K: typeof Ember.Handlebars.K; - var createFrame: typeof Ember.Handlebars.createFrame; - var Exception: typeof Ember.Handlebars.Exception; - class SafeString extends Ember.Handlebars.SafeString { } - var parse: typeof Ember.Handlebars.parse; - var print: typeof Ember.Handlebars.print; - var logger: typeof Ember.Handlebars.logger; - var log: typeof Ember.Handlebars.log; - } - class HashLocation extends Ember.HashLocation { } - class HistoryLocation extends Ember.HistoryLocation { } - var IS_BINDING: typeof Ember.IS_BINDING; - class Instrumentation extends Ember.Instrumentation { } - var K: typeof Ember.K; - var LOG_BINDINGS: typeof Ember.LOG_BINDINGS; - var LOG_STACKTRACE_ON_DEPRECATION: typeof Ember.LOG_STACKTRACE_ON_DEPRECATION; - var LOG_VERSION: typeof Ember.LOG_VERSION; - class Location extends Ember.Location { } - var Logger: typeof Ember.Logger; - var MANDATORY_SETTER_FUNCTION: typeof Ember.MANDATORY_SETTER_FUNCTION; - var META_KEY: typeof Ember.META_KEY; - class Map extends Ember.Map { } - class MapWithDefault extends Ember.MapWithDefault { } - class Mixin extends Ember.Mixin { } - class MutableArray extends Ember.MutableArray { } - class MutableEnumerable extends Ember.MutableEnumberable { } - var NAME_KEY: typeof Ember.NAME_KEY; - class Namespace extends Ember.Namespace { } - class NativeArray extends Ember.NativeArray { } - class NoneLocation extends Ember.NoneLocation { } - var ORDER_DEFINITION: typeof Ember.ORDER_DEFINITION; - class Object extends Ember.Object { } - class ObjectProxy extends Ember.ObjectProxy { } - class Observable extends Ember.Observable { } - class OrderedSet extends Ember.OrderedSet { } - namespace RSVP { - interface PromiseResolve extends Ember.RSVP.PromiseResolve { } - interface PromiseReject extends Ember.RSVP.PromiseReject { } - interface PromiseResolverFunction extends Ember.RSVP.PromiseResolverFunction { } - class Promise extends Ember.RSVP.Promise { } - } - class Route extends Ember.Route { } - class Router extends Ember.Router { } - class RouterDSL extends Ember.RouterDSL { } - var SHIM_ES5: typeof Ember.SHIM_ES5; - var STRINGS: typeof Ember.STRINGS; - class SelectOption extends Ember.SelectOption { } - class State extends Ember.State { } - class StateManager extends Ember.StateManager { } - namespace String { - var camelize: typeof Ember.String.camelize; - var capitalize: typeof Ember.String.capitalize; - var classify: typeof Ember.String.classify; - var dasherize: typeof Ember.String.dasherize; - var decamelize: typeof Ember.String.decamelize; - var fmt: typeof Ember.String.fmt; - var htmlSafe: typeof Ember.String.htmlSafe; - var loc: typeof Ember.String.loc; - var underscore: typeof Ember.String.underscore; - var w: typeof Ember.String.w; - } - var TEMPLATES: typeof Ember.TEMPLATES; - class TargetActionSupport extends Ember.TargetActionSupport { } - class Test extends Ember.Test { } - class TextArea extends Ember.TextArea { } - class TextField extends Ember.TextField { } - class TextSupport extends Ember.TextSupport { } - var VERSION: typeof Ember.VERSION; - class ViewTargetActionSupport extends Ember.ViewTargetActionSupport { } - var ViewUtils: typeof Ember.ViewUtils; - var addListener: typeof Ember.addListener; - var addObserver: typeof Ember.addObserver; - var alias: typeof Ember.alias; - var aliasMethod: typeof Ember.aliasMethod; - var anyUnprocessedMixins: typeof Ember.anyUnprocessedMixins; - var assert: typeof Ember.assert; - var beginPropertyChanges: typeof Ember.beginPropertyChanges; - var bind: typeof Ember.bind; - var cacheFor: typeof Ember.cacheFor; - var canInvoke: typeof Ember.canInvoke; - var changeProperties: typeof Ember.changeProperties; - var compare: typeof Ember.compare; - var computed: typeof Ember.computed; - var config: typeof Ember.config; - var controllerFor: typeof Ember.controllerFor; - var copy: typeof Ember.copy; - var create: typeof Ember.create; - var debug: typeof Ember.debug; - var defineProperty: typeof Ember.defineProperty; - var deprecate: typeof Ember.deprecate; - var deprecateFunc: typeof Ember.deprecateFunc; - var destroy: typeof Ember.destroy; - var empty: typeof deprecateFunc; - var endPropertyChanges: typeof Ember.endPropertyChanges; - var exports: typeof Ember.exports; - var finishChains: typeof Ember.finishChains; - var flushPendingChains: typeof Ember.flushPendingChains; - var generateController: typeof Ember.generateController; - var generateGuid: typeof Ember.generateGuid; - var get: typeof Ember.get; - var getPath: typeof Ember.getPath; - var getWithDefault: typeof Ember.getWithDefault; - var guidFor: typeof Ember.guidFor; - var handleErrors: typeof Ember.handleErrors; - var hasListeners: typeof Ember.hasListeners; - var hasOwnProperty: typeof Ember.hasOwnProperty; - var immediateObserver: typeof Ember.immediateObserver; - var imports: typeof Ember.imports; - var inspect: typeof Ember.inspect; - var instrument: typeof Ember.instrument; - var isArray: typeof Ember.isArray; - var isEmpty: typeof Ember.isEmpty; - var isEqual: typeof Ember.isEqual; - var isGlobalPath: typeof Ember.isGlobalPath; - var isNamespace: typeof Ember.isNamespace; - var isNone: typeof Ember.isNone; - var isPrototypeOf: typeof Ember.isPrototypeOf; - var isWatching: typeof Ember.isWatching; - var keys: typeof Ember.keys; - var listenersDiff: typeof Ember.listenersDiff; - var listenersFor: typeof Ember.listenersFor; - var listenersUnion: typeof Ember.listenersUnion; - var lookup: typeof Ember.lookup; - var makeArray: typeof Ember.makeArray; - var merge: typeof Ember.merge; - var meta: typeof Ember.meta; - var mixin: typeof Ember.mixin; - var none: typeof Ember.none; - var normalizeTuple: typeof Ember.normalizeTuple; - var observer: typeof Ember.observer; - var observersFor: typeof Ember.observersFor; - var onLoad: typeof Ember.onLoad; - var onError: typeof Ember.onError; - var overrideChains: typeof Ember.overrideChains; - var platform: typeof Ember.platform; - var propertyDidChange: typeof Ember.propertyDidChange; - var propertyIsEnumerable: typeof Ember.propertyIsEnumerable; - var propertyWillChange: typeof Ember.propertyWillChange; - var removeChainWatcher: typeof Ember.removeChainWatcher; - var removeListener: typeof Ember.removeListener; - var removeObserver: typeof Ember.removeObserver; - var required: typeof Ember.required; - var rewatch: typeof Ember.rewatch; - var run: typeof Ember.run; - var runLoadHooks: typeof Ember.runLoadHooks; - var sendEvent: typeof Ember.sendEvent; - var set: typeof Ember.set; - var setPath: typeof Ember.setPath; - var setProperties: typeof Ember.setProperties; - var subscribe: typeof Ember.subscribe; - var toLocaleString: typeof Ember.toLocaleString; - var toString: typeof Ember.toString; - var tryCatchFinally: typeof Ember.tryCatchFinally; - var tryInvoke: typeof Ember.tryInvoke; - var trySet: typeof Ember.trySet; - var trySetPath: typeof Ember.trySetPath; - var typeOf: typeof Ember.typeOf; - var unwatch: typeof Ember.unwatch; - var unwatchKey: typeof Ember.unwatchKey; - var unwatchPath: typeof Ember.unwatchPath; - var uuid: typeof Ember.uuid; - var valueOf: typeof Ember.valueOf; - var warn: typeof Ember.warn; - var watch: typeof Ember.watch; - var watchKey: typeof Ember.watchKey; - var watchPath: typeof Ember.watchPath; - var watchedEvents: typeof Ember.watchedEvents; - var wrap: typeof Ember.wrap; -} +declare var Em : typeof Ember; /** * External ambient module - to allow "import Ember = require('Ember');" to work correctly */ declare module "Ember" { - - var $: typeof Ember.$; - var A: typeof Ember.A; - class ActionHandlerMixin extends Ember.ActionHandlerMixin { } - class Application extends Ember.Application { } - class Array extends Ember.Array { } - class ArrayProxy extends Ember.ArrayProxy { } - var BOOTED: typeof Ember.BOOTED; - class Binding extends Ember.Binding { } - class Button extends Ember.Button { } - class Checkbox extends Ember.Checkbox { } - class Comparable extends Ember.Comparable { } - class Component extends Ember.Component { } - class ComputedProperty extends Ember.ComputedProperty { } - class Container extends Ember.Container { } - class Controller extends Ember.Controller { } - class ControllerMixin extends Ember.ControllerMixin { } - class Copyable extends Ember.Copyable { } - class CoreObject extends Ember.CoreObject { } - class DAG extends Ember.DAG { } - var DEFAULT_GETTER_FUNCTION: typeof Ember.DEFAULT_GETTER_FUNCTION; - class DefaultResolver extends Ember.DefaultResolver { } - class Descriptor extends Ember.Descriptor { } - var EMPTY_META: typeof Ember.EMPTY_META; - var ENV: typeof Ember.ENV; - var EXTEND_PROTOTYPES: typeof Ember.EXTEND_PROTOTYPES; - class EachProxy extends Ember.EachProxy { } - class Enumerable extends Ember.Enumerable { } - var Error: typeof Ember.Error; - class EventDispatcher extends Ember.EventDispatcher { } - class Evented extends Ember.Evented { } - var FROZEN_ERROR: typeof Ember.FROZEN_ERROR; - class Freezable extends Ember.Freezable { } - var GUID_KEY: typeof Ember.GUID_KEY; - namespace Handlebars { - var compile: typeof Ember.Handlebars.compile; - var precompile: typeof Ember.Handlebars.precompile; - class Compiler extends Ember.Handlebars.Compiler { } - class JavaScriptCompiler extends Ember.Handlebars.JavaScriptCompiler { } - var registerPartial: typeof Ember.Handlebars.registerPartial; - var K: typeof Ember.Handlebars.K; - var createFrame: typeof Ember.Handlebars.createFrame; - var Exception: typeof Ember.Handlebars.Exception; - class SafeString extends Ember.Handlebars.SafeString { } - var parse: typeof Ember.Handlebars.parse; - var print: typeof Ember.Handlebars.print; - var logger: typeof Ember.Handlebars.logger; - var log: typeof Ember.Handlebars.log; - } - class HashLocation extends Ember.HashLocation { } - class HistoryLocation extends Ember.HistoryLocation { } - var IS_BINDING: typeof Ember.IS_BINDING; - class Instrumentation extends Ember.Instrumentation { } - var K: typeof Ember.K; - var LOG_BINDINGS: typeof Ember.LOG_BINDINGS; - var LOG_STACKTRACE_ON_DEPRECATION: typeof Ember.LOG_STACKTRACE_ON_DEPRECATION; - var LOG_VERSION: typeof Ember.LOG_VERSION; - class Location extends Ember.Location { } - var Logger: typeof Ember.Logger; - var MANDATORY_SETTER_FUNCTION: typeof Ember.MANDATORY_SETTER_FUNCTION; - var META_KEY: typeof Ember.META_KEY; - class Map extends Ember.Map { } - class MapWithDefault extends Ember.MapWithDefault { } - class Mixin extends Ember.Mixin { } - class MutableArray extends Ember.MutableArray { } - class MutableEnumerable extends Ember.MutableEnumberable { } - var NAME_KEY: typeof Ember.NAME_KEY; - class Namespace extends Ember.Namespace { } - class NativeArray extends Ember.NativeArray { } - class NoneLocation extends Ember.NoneLocation { } - var ORDER_DEFINITION: typeof Ember.ORDER_DEFINITION; - class Object extends Ember.Object { } - class ObjectProxy extends Ember.ObjectProxy { } - class Observable extends Ember.Observable { } - class OrderedSet extends Ember.OrderedSet { } - namespace RSVP { - interface PromiseResolve extends Ember.RSVP.PromiseResolve { } - interface PromiseReject extends Ember.RSVP.PromiseReject { } - interface PromiseResolverFunction extends Ember.RSVP.PromiseResolverFunction { } - class Promise extends Ember.RSVP.Promise { } - } - class Route extends Ember.Route { } - class Router extends Ember.Router { } - class RouterDSL extends Ember.RouterDSL { } - var SHIM_ES5: typeof Ember.SHIM_ES5; - var STRINGS: typeof Ember.STRINGS; - class SelectOption extends Ember.SelectOption { } - class State extends Ember.State { } - class StateManager extends Ember.StateManager { } - namespace String { - var camelize: typeof Ember.String.camelize; - var capitalize: typeof Ember.String.capitalize; - var classify: typeof Ember.String.classify; - var dasherize: typeof Ember.String.dasherize; - var decamelize: typeof Ember.String.decamelize; - var fmt: typeof Ember.String.fmt; - var htmlSafe: typeof Ember.String.htmlSafe; - var loc: typeof Ember.String.loc; - var underscore: typeof Ember.String.underscore; - var w: typeof Ember.String.w; - } - var TEMPLATES: typeof Ember.TEMPLATES; - class TargetActionSupport extends Ember.TargetActionSupport { } - class Test extends Ember.Test { } - class TextArea extends Ember.TextArea { } - class TextField extends Ember.TextField { } - class TextSupport extends Ember.TextSupport { } - var VERSION: typeof Ember.VERSION; - class ViewTargetActionSupport extends Ember.ViewTargetActionSupport { } - var ViewUtils: typeof Ember.ViewUtils; - var addListener: typeof Ember.addListener; - var addObserver: typeof Ember.addObserver; - var alias: typeof Ember.alias; - var aliasMethod: typeof Ember.aliasMethod; - var anyUnprocessedMixins: typeof Ember.anyUnprocessedMixins; - var assert: typeof Ember.assert; - var beginPropertyChanges: typeof Ember.beginPropertyChanges; - var bind: typeof Ember.bind; - var cacheFor: typeof Ember.cacheFor; - var canInvoke: typeof Ember.canInvoke; - var changeProperties: typeof Ember.changeProperties; - var compare: typeof Ember.compare; - var computed: typeof Ember.computed; - var config: typeof Ember.config; - var controllerFor: typeof Ember.controllerFor; - var copy: typeof Ember.copy; - var create: typeof Ember.create; - var debug: typeof Ember.debug; - var defineProperty: typeof Ember.defineProperty; - var deprecate: typeof Ember.deprecate; - var deprecateFunc: typeof Ember.deprecateFunc; - var destroy: typeof Ember.destroy; - var empty: typeof Ember.deprecateFunc; - var endPropertyChanges: typeof Ember.endPropertyChanges; - var exports: typeof Ember.exports; - var finishChains: typeof Ember.finishChains; - var flushPendingChains: typeof Ember.flushPendingChains; - var generateController: typeof Ember.generateController; - var generateGuid: typeof Ember.generateGuid; - var get: typeof Ember.get; - var getPath: typeof Ember.getPath; - var getWithDefault: typeof Ember.getWithDefault; - var guidFor: typeof Ember.guidFor; - var handleErrors: typeof Ember.handleErrors; - var hasListeners: typeof Ember.hasListeners; - var hasOwnProperty: typeof Ember.hasOwnProperty; - var immediateObserver: typeof Ember.immediateObserver; - var imports: typeof Ember.imports; - var inspect: typeof Ember.inspect; - var instrument: typeof Ember.instrument; - var isArray: typeof Ember.isArray; - var isEmpty: typeof Ember.isEmpty; - var isEqual: typeof Ember.isEqual; - var isGlobalPath: typeof Ember.isGlobalPath; - var isNamespace: typeof Ember.isNamespace; - var isNone: typeof Ember.isNone; - var isPrototypeOf: typeof Ember.isPrototypeOf; - var isWatching: typeof Ember.isWatching; - var keys: typeof Ember.keys; - var listenersDiff: typeof Ember.listenersDiff; - var listenersFor: typeof Ember.listenersFor; - var listenersUnion: typeof Ember.listenersUnion; - var lookup: typeof Ember.lookup; - var makeArray: typeof Ember.makeArray; - var merge: typeof Ember.merge; - var meta: typeof Ember.meta; - var mixin: typeof Ember.mixin; - var none: typeof Ember.none; - var normalizeTuple: typeof Ember.normalizeTuple; - var observer: typeof Ember.observer; - var observersFor: typeof Ember.observersFor; - var onLoad: typeof Ember.onLoad; - var onError: typeof Ember.onError; - var overrideChains: typeof Ember.overrideChains; - var platform: typeof Ember.platform; - var propertyDidChange: typeof Ember.propertyDidChange; - var propertyIsEnumerable: typeof Ember.propertyIsEnumerable; - var propertyWillChange: typeof Ember.propertyWillChange; - var removeChainWatcher: typeof Ember.removeChainWatcher; - var removeListener: typeof Ember.removeListener; - var removeObserver: typeof Ember.removeObserver; - var required: typeof Ember.required; - var rewatch: typeof Ember.rewatch; - var run: typeof Ember.run; - var runLoadHooks: typeof Ember.runLoadHooks; - var sendEvent: typeof Ember.sendEvent; - var set: typeof Ember.set; - var setPath: typeof Ember.setPath; - var setProperties: typeof Ember.setProperties; - var subscribe: typeof Ember.subscribe; - var toLocaleString: typeof Ember.toLocaleString; - var toString: typeof Ember.toString; - var tryCatchFinally: typeof Ember.tryCatchFinally; - var tryInvoke: typeof Ember.tryInvoke; - var trySet: typeof Ember.trySet; - var trySetPath: typeof Ember.trySetPath; - var typeOf: typeof Ember.typeOf; - var unwatch: typeof Ember.unwatch; - var unwatchKey: typeof Ember.unwatchKey; - var unwatchPath: typeof Ember.unwatchPath; - var uuid: typeof Ember.uuid; - var valueOf: typeof Ember.valueOf; - var warn: typeof Ember.warn; - var watch: typeof Ember.watch; - var watchKey: typeof Ember.watchKey; - var watchPath: typeof Ember.watchPath; - var watchedEvents: typeof Ember.watchedEvents; - var wrap: typeof Ember.wrap; + export = Ember; } From 30132424e290683c61d47282872867a7c7e61724 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 5 Aug 2016 09:46:39 +0200 Subject: [PATCH 21/47] Filled in ENV variable in Ember --- ember/ember.d.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index a151cbfea2..e232742610 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -1015,8 +1015,19 @@ declare namespace Ember { **/ class Descriptor { } var EMPTY_META: {}; // TODO: define interface - var ENV: {}; - var EXTEND_PROTOTYPES: boolean; + namespace ENV { + export var EXTEND_PROTOTYPES: typeof Ember.EXTEND_PROTOTYPES; + export var LOG_BINDINGS: boolean; + export var LOG_STACKTRACE_ON_DEPRECATION: boolean; + export var LOG_VERSION: boolean; + export var MODEL_FACTORY_INJECTIONS: boolean; + export var RAISE_ON_DEPRECATION: boolean; + } + namespace EXTEND_PROTOTYPES { + export var Array: boolean; + export var Function: boolean; + export var String: boolean; + } /** This is the object instance returned when you get the @each property on an array. It uses the unknownProperty handler to automatically create EachArray instances for property names. From 9ab8c2ce8ccdc51e2d4524f1ff7be661ff553aaa Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 5 Aug 2016 11:22:56 +0200 Subject: [PATCH 22/47] When wring types in Ember, you now have to use the full "Ember" name instead of the shorthand "Em". --- ember/ember-tests.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ember/ember-tests.ts b/ember/ember-tests.ts index 5452bbf901..63acb0fbba 100644 --- a/ember/ember-tests.ts +++ b/ember/ember-tests.ts @@ -4,7 +4,7 @@ var App : any; -App = Em.Application.create(); +App = Em.Application.create(); App.president = Em.Object.create({ name: 'Barack Obama' @@ -44,7 +44,7 @@ var tom = Person1.create({ tom.helloWorld(); Person1.reopen({ isPerson: true }); -Person1.create().get('isPerson'); +Person1.create().get('isPerson'); Person1.reopenClass({ createMan: () => { @@ -55,7 +55,7 @@ Person1.reopenClass({ declare var Person1: typeof MyPerson; Person1.createMan().get('isMan'); -var person = Person1.create({ +var person = Person1.create({ firstName: 'Yehuda', lastName: 'Katz' }); @@ -140,10 +140,10 @@ var people2 = [ Person3.create({ name: 'Yehuda', isHappy: true }), Person3.create({ name: 'Majd', isHappy: false }) ]; -people2.every((person: Em.Object) => { +people2.every((person: Ember.Object) => { return !!person.get('isHappy'); }); -people2.some((person: Em.Object) => { +people2.some((person: Ember.Object) => { return !!person.get('isHappy'); }); people2.everyProperty('isHappy', true); From 85059621e52afcc4293e85b2f552242bba4045b2 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 5 Aug 2016 11:29:32 +0200 Subject: [PATCH 23/47] A lot of updating ember to version 2.7 --- ember/ember.d.ts | 49 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index e232742610..71a578c186 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Ember.js 2.0 +// Type definitions for Ember.js 2.7 // Project: http://emberjs.com/ // Definitions by: Jed Mao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -448,7 +448,6 @@ declare namespace Ember { static metaForProperty(key: string): {}; static isClass: boolean; static isMethod: boolean; - static initializer(args?: ApplicationInitializerArguments): void; /** Call advanceReadiness after any asynchronous setup logic has completed. Each call to deferReadiness must be matched by a call to advanceReadiness @@ -697,7 +696,7 @@ declare namespace Ember { constructor(toPath: string, fromPath: string); connect(obj: any): Binding; copy(): Binding; - disconnect(obj: any): Binding; + disconnect(): Binding; from(path: string): Binding; to(path: string): Binding; to(pathTuple: any[]): Binding; @@ -790,6 +789,8 @@ declare namespace Ember { constructor(parent: Container); parent: Container; children: any[]; + owner: any; + ownerInjection(): any; resolver: Function; registry: {}; cache: {}; @@ -805,7 +806,7 @@ declare namespace Ember { describe(fullName: string): string; makeToString(factory: any, fullName: string): Function; lookup(fullName: string, options?: {}): any; - lookupFactory(fullName: string): any; + lookupFactory(fullName: string, options?: {}): any; destroy(): void; reset(): void; } @@ -1014,7 +1015,6 @@ declare namespace Ember { You generally won't need to create or subclass this directly. **/ class Descriptor { } - var EMPTY_META: {}; // TODO: define interface namespace ENV { export var EXTEND_PROTOTYPES: typeof Ember.EXTEND_PROTOTYPES; export var LOG_BINDINGS: boolean; @@ -1148,7 +1148,7 @@ declare namespace Ember { var GUID_KEY: string; namespace Handlebars { function compile(string: string): Function; - function precompile(string: string): void; + function precompile(string: string, options: any): void; class Compiler { } class JavaScriptCompiler { } function registerPartial(name: string, str: any): void; @@ -2204,25 +2204,11 @@ declare namespace Ember { resource(name: string, options?: {}, callback?: Function): void; resource(name: string, callback: Function): void; route(name: string, options?: {}): void; + explicitIndex: boolean; + router: Router; + options: any; } - var SHIM_ES5: boolean; var STRINGS: boolean; - class SelectOption extends Component { - static detect(obj: any): boolean; - static detectInstance(obj: any): boolean; - /** - Iterate over each computed property for the class, passing its name and any - associated metadata (see metaForProperty) to the callback. - **/ - static eachComputedProperty(callback: Function, binding: {}): void; - /** - Returns the original hash that was passed to meta(). - @param key property name - **/ - static metaForProperty(key: string): {}; - static isClass: boolean; - static isMethod: boolean; - } class State extends Object implements Evented { static detect(obj: any): boolean; static detectInstance(obj: any): boolean; @@ -2401,7 +2387,6 @@ declare namespace Ember { **/ var alias: typeof deprecateFunc; function aliasMethod(methodName: string): Descriptor; - var anyUnprocessedMixins: boolean; function assert(desc: string, test: boolean): void; function beginPropertyChanges(): void; function bind(obj: any, to: string, from: string): Binding; @@ -2431,8 +2416,6 @@ declare namespace Ember { oneWay(dependentKey: string): ComputedProperty; or(...args: string[]): ComputedProperty; }; - // ReSharper disable DuplicatingLocalDeclaration - var config: {}; // ReSharper restore DuplicatingLocalDeclaration function controllerFor(container: Container, controllerName: string, lookupOptions?: {}): Controller; function copy(obj: any, deep: boolean): any; @@ -2452,10 +2435,7 @@ declare namespace Ember { // ReSharper disable once DuplicatingLocalDeclaration var empty: typeof deprecateFunc; function endPropertyChanges(): void; - // ReSharper disable once DuplicatingLocalDeclaration - var exports: {}; function finishChains(obj: any): void; - function flushPendingChains(): void; function generateController(container: Container, controllerName: string, context: any): Controller; function generateGuid(obj: any, prefix?: string): string; function get(obj: any, keyName: string): any; @@ -2469,7 +2449,6 @@ declare namespace Ember { function hasListeners(context: any, name: string): boolean; function hasOwnProperty(prop: string): boolean; function immediateObserver(func: Function, ...propertyNames: any[]): Function; - var imports: {}; function inspect(obj: any): string; function instrument(name: string, payload: any, callback: Function, binding: any): void; function isArray(obj: any): boolean; @@ -2488,13 +2467,12 @@ declare namespace Ember { var lookup: {}; // TODO: define interface function makeArray(obj: any): any[]; function merge(original: any, updates: any): any; - function meta(obj: any, writable?: boolean): {}; + function meta(obj: any): {}; function mixin(obj: any, ...args: any[]): any; /** Ember.none is deprecated. Please use Ember.isNone instead. **/ var none: typeof deprecateFunc; - function normalizeTuple(target: any, path: string): any[]; function observer(...args: any[]): Function; function observersFor(obj: any, path: string): any[]; function onLoad(name: string, callback: Function): void; @@ -2571,6 +2549,13 @@ declare namespace Ember { function watchPath(obj: any, keyPath: string): void; function watchedEvents(obj: {}): any[]; function wrap(func: Function, superFunc: Function): Function; + var _ContainerProxyMixin : Mixin; + var _RegistryProxyMixin: Mixin; + function getOwner(object: any): any; + function setOwner(object: any, owner: any): void; + var testing : boolean; + var MODEL_FACTORY_INJECTIONS : boolean; + function assign(original: any, ...sources: any[]): any; } declare var Em : typeof Ember; From 6b5a500c0b788a61344c604ddceaa60ec8a1007e Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 5 Aug 2016 11:44:38 +0200 Subject: [PATCH 24/47] The entire Test object was documented wrong. It is not a class, it is a plain object/module/namespace with functions and properties. --- ember/ember.d.ts | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 71a578c186..0e43ed7787 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -2291,23 +2291,28 @@ declare namespace Ember { class TargetActionSupport { triggerAction(opts: {}): boolean; } - class Test { - click(selector: string): RSVP.Promise; - fillin(selector: string, text: string): RSVP.Promise; - find(selector: string): JQuery; - findWithAssert(selector: string): JQuery; - injectTestHelpers(): void; - keyEvent(selector: string, type: string, keyCode: number): RSVP.Promise; - static oninjectHelpers(callback: Function): void; - static promise(resolver: Function): RSVP.Promise; - static registerHelper(name: string, helperMethod: Function): void; - removeTestHelpers(): void; - setupForTesting(): void; - static unregisterHelper(name: string): void; - visit(url: string): RSVP.Promise; - wait(value: any): RSVP.Promise; - static adapter: Object; - testHelpers: {}; + namespace Test { + class Adapter extends Ember.Object { + constructor (); + } + class Promise extends Ember.RSVP.Promise { + constructor (); + } + function oninjectHelpers(callback: Function): void; + function promise(resolver: Function, label: string): Ember.Test.Promise; + function unregisterHelper(name: string): void; + function registerHelper(name: string, helperMethod: Function): void; + function registerAsyncHelper(name: string, helperMethod: Function): void; + + var adapter: Object; + var QUnitAdapter: Object; + + function registerWaiter(callback: Function): void; + function registerWaiter(context: any, callback: Function): void; + function unregisterWaiter(callback: Function): void; + function unregisterWaiter(context: any, callback: Function): void; + + function resolve(result: any): Ember.Test.Promise; } class TextArea extends Component implements TextSupport { static detect(obj: any): boolean; From 74b01565183f4c35c82a9148b10de8f68e9823f8 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 5 Aug 2016 12:27:29 +0200 Subject: [PATCH 25/47] Added the Registry class to ember. (since it is a private class, and the API is unstable, no documentation was added for the inner workings): --- ember/ember.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 0e43ed7787..7aa4a2671c 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -529,6 +529,7 @@ declare namespace Ember { Application's router. **/ Router: Router; + registry: Registry; } /** This module implements Observer-friendly Array-like behavior. This mixin is picked up by the @@ -792,7 +793,7 @@ declare namespace Ember { owner: any; ownerInjection(): any; resolver: Function; - registry: {}; + registry: Registry; cache: {}; typeInjections: {}; injections: {}; @@ -1592,6 +1593,10 @@ declare namespace Ember { isEmpty(): boolean; toArray(): any[]; } + class Registry { + constructor (options: any); + static set: typeof Ember.set; + } // FYI - RSVP source comes from https://github.com/tildeio/rsvp.js/blob/master/lib/rsvp/promise.js namespace RSVP { From a1a716dca3180b94b7e0972737dad61593872d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kov=C3=A1cs=20Q?= Date: Fri, 5 Aug 2016 17:04:49 +0200 Subject: [PATCH 26/47] [Drop] Fix issue where createContext did not return constructable type --- drop/drop-tests.ts | 8 ++++++++ drop/drop.d.ts | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drop/drop-tests.ts b/drop/drop-tests.ts index cc19621fbd..0da04e9445 100644 --- a/drop/drop-tests.ts +++ b/drop/drop-tests.ts @@ -36,3 +36,11 @@ var e = new Drop({ content: () => greenBox }); +var Tooltip = Drop.createContext({ + classPrefix: 'tooltip' +}); + +var t = new Tooltip({ + target: yellowBox, + content: () => greenBox +}); diff --git a/drop/drop.d.ts b/drop/drop.d.ts index 63f9c8621e..51b05b8c1a 100644 --- a/drop/drop.d.ts +++ b/drop/drop.d.ts @@ -27,7 +27,7 @@ declare class Drop { public once(event: string, handler: Function, context?: any): void; public off(event: string, handler?: Function): void; - public static createContext(options: Drop.IDropContextOptions): Drop; + public static createContext(options: Drop.IDropContextOptions): Drop.IDropConstructor; } declare namespace Drop { @@ -54,6 +54,10 @@ declare namespace Drop { hoverCloseDelay?: number; tetherOptions?: Tether.ITetherOptions; } + + interface IDropConstructor { + new (options: Drop.IDropOptions): Drop; + } } declare module "drop" { From 3df433e5dc1a79e06b29958c5c3aa43f3d1d1c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kov=C3=A1cs=20Q?= Date: Fri, 5 Aug 2016 17:17:58 +0200 Subject: [PATCH 27/47] [Drop] Remove unnecessary whitespace --- drop/drop.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/drop/drop.d.ts b/drop/drop.d.ts index 51b05b8c1a..7794977b08 100644 --- a/drop/drop.d.ts +++ b/drop/drop.d.ts @@ -63,4 +63,3 @@ declare namespace Drop { declare module "drop" { export = Drop; } - From 41a2fd266b4fd5a0404d3f1debd209a6f1df7360 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Sat, 6 Aug 2016 17:45:21 +0200 Subject: [PATCH 28/47] Re-introduced the redundant Em declaration. --- ember/ember-tests.ts | 14 +-- ember/ember.d.ts | 211 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 217 insertions(+), 8 deletions(-) diff --git a/ember/ember-tests.ts b/ember/ember-tests.ts index 63acb0fbba..5924dbd0ae 100644 --- a/ember/ember-tests.ts +++ b/ember/ember-tests.ts @@ -4,7 +4,7 @@ var App : any; -App = Em.Application.create(); +App = Em.Application.create(); App.president = Em.Object.create({ name: 'Barack Obama' @@ -44,7 +44,7 @@ var tom = Person1.create({ tom.helloWorld(); Person1.reopen({ isPerson: true }); -Person1.create().get('isPerson'); +Person1.create().get('isPerson'); Person1.reopenClass({ createMan: () => { @@ -55,7 +55,7 @@ Person1.reopenClass({ declare var Person1: typeof MyPerson; Person1.createMan().get('isMan'); -var person = Person1.create({ +var person = Person1.create({ firstName: 'Yehuda', lastName: 'Katz' }); @@ -140,17 +140,17 @@ var people2 = [ Person3.create({ name: 'Yehuda', isHappy: true }), Person3.create({ name: 'Majd', isHappy: false }) ]; -people2.every((person: Ember.Object) => { +people2.every((person: Em.Object) => { return !!person.get('isHappy'); }); -people2.some((person: Ember.Object) => { +people2.some((person: Em.Object) => { return !!person.get('isHappy'); }); people2.everyProperty('isHappy', true); people2.someProperty('isHappy', true); -// Examples taken from http://emberjs.com/api/classes/Ember.RSVP.Promise.html -var promise = new Ember.RSVP.Promise(function(resolve: Function, reject: Function) { +// Examples taken from http://emberjs.com/api/classes/Em.RSVP.Promise.html +var promise = new Em.RSVP.Promise(function(resolve: Function, reject: Function) { // on success resolve('ok!'); diff --git a/ember/ember.d.ts b/ember/ember.d.ts index 7aa4a2671c..20328feef8 100644 --- a/ember/ember.d.ts +++ b/ember/ember.d.ts @@ -2568,7 +2568,216 @@ declare namespace Ember { function assign(original: any, ...sources: any[]): any; } -declare var Em : typeof Ember; +declare namespace Em { + var $: typeof Ember.$; + var A: typeof Ember.A; + class ActionHandlerMixin extends Ember.ActionHandlerMixin { } + class Application extends Ember.Application { } + class Array extends Ember.Array { } + class ArrayProxy extends Ember.ArrayProxy { } + var BOOTED: typeof Ember.BOOTED; + class Binding extends Ember.Binding { } + class Button extends Ember.Button { } + class Checkbox extends Ember.Checkbox { } + class Comparable extends Ember.Comparable { } + class Component extends Ember.Component { } + class ComputedProperty extends Ember.ComputedProperty { } + class Container extends Ember.Container { } + class Controller extends Ember.Controller { } + class ControllerMixin extends Ember.ControllerMixin { } + class Copyable extends Ember.Copyable {} + class CoreObject extends Ember.CoreObject { } + class DAG extends Ember.DAG {} + var DEFAULT_GETTER_FUNCTION : typeof Ember.DEFAULT_GETTER_FUNCTION; + class DefaultResolver extends Ember.DefaultResolver { } + class Descriptor extends Ember.Descriptor { } + var ENV: typeof Ember.ENV; + var EXTEND_PROTOTYPES: typeof Ember.EXTEND_PROTOTYPES; + class EachProxy extends Ember.EachProxy { } + class Enumerable extends Ember.Enumerable { } + var Error: typeof Ember.Error; + class EventDispatcher extends Ember.EventDispatcher { } + class Evented extends Ember.Evented { } + var FROZEN_ERROR: typeof Ember.FROZEN_ERROR; + class Freezable extends Ember.Freezable { } + var GUID_KEY: typeof Ember.GUID_KEY; + namespace Handlebars { + var compile: typeof Ember.Handlebars.compile; + var precompile: typeof Ember.Handlebars.precompile; + class Compiler extends Ember.Handlebars.Compiler { } + class JavaScriptCompiler extends Ember.Handlebars.JavaScriptCompiler{ } + var registerPartial: typeof Ember.Handlebars.registerPartial; + var K: typeof Ember.Handlebars.K; + var createFrame: typeof Ember.Handlebars.createFrame; + var Exception: typeof Ember.Handlebars.Exception; + class SafeString extends Ember.Handlebars.SafeString { } + var parse: typeof Ember.Handlebars.parse; + var print: typeof Ember.Handlebars.print; + var logger: typeof Ember.Handlebars.logger; + var log: typeof Ember.Handlebars.log; + } + class HashLocation extends Ember.HashLocation { } + class HistoryLocation extends Ember.HistoryLocation { } + var IS_BINDING: typeof Ember.IS_BINDING; + class Instrumentation extends Ember.Instrumentation { } + var K: typeof Ember.K; + var LOG_BINDINGS: typeof Ember.LOG_BINDINGS; + var LOG_STACKTRACE_ON_DEPRECATION: typeof Ember.LOG_STACKTRACE_ON_DEPRECATION; + var LOG_VERSION: typeof Ember.LOG_VERSION; + class Location extends Ember.Location {} + var Logger: typeof Ember.Logger; + var MANDATORY_SETTER_FUNCTION: typeof Ember.MANDATORY_SETTER_FUNCTION; + var META_KEY: typeof Ember.META_KEY; + class Map extends Ember.Map { } + class MapWithDefault extends Ember.MapWithDefault { } + class Mixin extends Ember.Mixin { } + class MutableArray extends Ember.MutableArray { } + class MutableEnumberable extends Ember.MutableEnumberable { } + var NAME_KEY: typeof Ember.NAME_KEY; + class Namespace extends Ember.Namespace { } + class NativeArray extends Ember.NativeArray { } + class NoneLocation extends Ember.NoneLocation { } + var ORDER_DEFINITION: typeof Ember.ORDER_DEFINITION; + class Object extends Ember.Object { } + class ObjectProxy extends Ember.ObjectProxy { } + class Observable extends Ember.Observable { } + class OrderedSet extends Ember.OrderedSet { } + class Registry extends Ember.Registry { } + namespace RSVP { + interface PromiseResolve extends Ember.RSVP.PromiseResolve { } + interface PromiseReject extends Ember.RSVP.PromiseReject { } + interface PromiseResolverFunction extends Ember.RSVP.PromiseResolverFunction { } + class Promise extends Ember.RSVP.Promise { } + } + class Route extends Ember.Route {} + class Router extends Ember.Router { } + class RouterDSL extends Ember.RouterDSL { } + var STRINGS: typeof Ember.STRINGS; + class State extends Ember.State { } + class StateManager extends Ember.StateManager { } + var String : typeof Ember.String; + var TEMPLATES: typeof Ember.TEMPLATES; + class TargetActionSupport extends Ember.TargetActionSupport {} + namespace Test { + class Adapter extends Ember.Test.Adapter { } + class Promise extends Ember.Test.Promise { } + var oninjectHelpers: typeof Ember.Test.oninjectHelpers; + var promise: typeof Ember.Test.promise; + var unregisterHelper: typeof Ember.Test.unregisterHelper; + var registerHelper: typeof Ember.Test.registerHelper; + var registerAsyncHelper: typeof Ember.Test.registerAsyncHelper; + var adapter: typeof Ember.Test.adapter; + var QUnitAdapter: typeof Ember.Test.QUnitAdapter; + var registerWaiter: typeof Ember.Test.registerWaiter; + var unregisterWaiter: typeof Ember.Test.unregisterWaiter + var resolve: typeof Ember.Test.resolve; + } + class TextArea extends Ember.TextArea { } + class TextField extends Ember.TextField { } + class TextSupport extends Ember.TextSupport { } + var VERSION: typeof Ember.VERSION; + class ViewTargetActionSupport extends Ember.ViewTargetActionSupport { } + var ViewUtils: typeof Ember.ViewUtils; + var addListener: typeof Ember.addListener; + var addObserver: typeof Ember.addObserver; + var alias: typeof Ember.alias; + var aliasMethod: typeof Ember.aliasMethod; + var assert: typeof Ember.assert; + var beginPropertyChanges: typeof Ember.beginPropertyChanges; + var bind: typeof Ember.bind; + var cacheFor: typeof Ember.cacheFor; + var canInvoke: typeof Ember.canInvoke; + var changeProperties: typeof Ember.changeProperties; + var compare: typeof Ember.compare; + var computed: typeof Ember.computed; + var controllerFor: typeof Ember.controllerFor; + var copy: typeof Ember.copy; + var create: typeof Ember.create; + var debug: typeof Ember.debug; + var defineProperty: typeof Ember.defineProperty; + var deprecate: typeof Ember.deprecate; + var deprecateFunc: typeof Ember.deprecateFunc + var destroy: typeof Ember.destroy; + var empty: typeof Ember.empty; + var endPropertyChanges: typeof Ember.endPropertyChanges; + var finishChains: typeof Ember.finishChains; + var generateController: typeof Ember.generateController; + var generateGuid: typeof Ember.generateGuid; + var get: typeof Ember.get; + var getPath: typeof Ember.getPath; + var getWithDefault: typeof Ember.getWithDefault; + var guidFor: typeof Ember.guidFor; + var handleErrors: typeof Ember.handleErrors; + var hasListeners: typeof Ember.hasListeners; + var hasOwnProperty: typeof Ember.hasOwnProperty; + var immediateObserver: typeof Ember.immediateObserver; + var inspect: typeof Ember.inspect; + var instrument: typeof Ember.instrument; + var isArray: typeof Ember.isArray; + var isEmpty: typeof Ember.isEmpty; + var isEqual: typeof Ember.isEqual; + var isGlobalPath: typeof Ember.isGlobalPath; + var isNamespace: typeof Ember.isNamespace; + var isNone: typeof Ember.isNone; + var isPrototypeOf: typeof Ember.isPrototypeOf; + var isWatching: typeof Ember.isWatching; + var keys: typeof Ember.keys; + var listenersDiff: typeof Ember.listenersDiff; + var listenersFor: typeof Ember.listenersFor; + var listenersUnion: typeof Ember.listenersUnion; + var lookup: typeof Ember.lookup; + var makeArray: typeof Ember.makeArray; + var merge: typeof Ember.merge; + var meta: typeof Ember.meta; + var mixin: typeof Ember.mixin; + var none: typeof Ember.none; + var observer: typeof Ember.observer; + var observersFor: typeof Ember.observersFor; + var onLoad: typeof Ember.onLoad; + var onError: typeof Ember.onError; + var overrideChains: typeof Ember.overrideChains; + var platform: typeof Ember.platform; + var propertyDidChange: typeof Ember.propertyDidChange; + var propertyIsEnumerable: typeof Ember.propertyIsEnumerable; + var propertyWillChange: typeof Ember.propertyWillChange; + var removeChainWatcher: typeof Ember.removeChainWatcher; + var removeListener: typeof Ember.removeListener; + var removeObserver: typeof Ember.removeObserver; + var required: typeof Ember.required; + var rewatch: typeof Ember.rewatch; + var run: typeof Ember.run; + var runLoadHooks: typeof Ember.runLoadHooks; + var sendEvent: typeof Ember.sendEvent; + var set: typeof Ember.set; + var setPath: typeof Ember.setPath; + var setProperties: typeof Ember.setProperties; + var subscribe: typeof Ember.subscribe; + var toLocaleString: typeof Ember.toLocaleString; + var toString: typeof Ember.toString; + var tryCatchFinally: typeof Ember.tryCatchFinally; + var tryInvoke: typeof Ember.tryInvoke; + var trySet: typeof Ember.trySet; + var trySetPath: typeof Ember.trySetPath; + var typeOf: typeof Ember.typeOf; + var unwatch: typeof Ember.unwatch; + var unwatchKey: typeof Ember.unwatchKey; + var unwatchPath: typeof Ember.unwatchPath; + var uuid: typeof Ember.uuid; + var valueOf: typeof Ember.valueOf; + var warn: typeof Ember.warn; + var watch: typeof Ember.watch; + var watchKey: typeof Ember.watchKey; + var watchPath: typeof Ember.watchPath; + var watchedEvents: typeof Ember.watchedEvents; + var wrap: typeof Ember.wrap; + var _ContainerProxyMixin : typeof Ember._ContainerProxyMixin; + var _RegistryProxyMixin: typeof Ember._RegistryProxyMixin; + var getOwner: typeof Ember.getOwner; + var setOwner: typeof Ember.setOwner; + var testing: typeof Ember.testing; + var MODEL_FACTORY_INJECTIONS: typeof Ember.MODEL_FACTORY_INJECTIONS; + var assign: typeof Ember.assign; +} /** * External ambient module - to allow "import Ember = require('Ember');" to work correctly From 951b738dc935be4b5f31bcb92f7dfc3f863fa3d5 Mon Sep 17 00:00:00 2001 From: Manish Lakhara Date: Sat, 6 Aug 2016 21:15:34 +0530 Subject: [PATCH 29/47] Added Promise/A+ compliant thenable. Extending HelloJSEvent from HelloJSThenable. --- hellojs/hellojs.d.ts | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index 7dabae4054..d831a3d836 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -18,23 +18,6 @@ interface HelloJSLogoutOptions { force?: boolean; } -interface HelloJSEvent { - on(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic; - off(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic; - findEvents(event: string, callback: (name: string, index: number) => void): void; - emit(event: string, data: any): HelloJSStatic; - emitAfter(): HelloJSStatic; - success(callback: (json?: any) => void): HelloJSStatic; - error(callback: (json?: any) => void): HelloJSStatic; - complete(callback: (json?: any) => void): HelloJSStatic; -} - - -interface HelloJSEventArgument { - network: string; - authResponse?: any; -} - interface HelloJSImmediateSuccessCB { (value: T): TP; } @@ -73,11 +56,28 @@ interface HelloJSThenable { ): HelloJSThenable; } +interface HelloJSEvent extends HelloJSThenable { + on(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic; + off(event: string, callback: (auth: HelloJSEventArgument) => void): HelloJSStatic; + findEvents(event: string, callback: (name: string, index: number) => void): void; + emit(event: string, data: any): HelloJSStatic; + emitAfter(): HelloJSStatic; + success(callback: (json?: any) => void): HelloJSStatic; + error(callback: (json?: any) => void): HelloJSStatic; + complete(callback: (json?: any) => void): HelloJSStatic; +} + + +interface HelloJSEventArgument { + network: string; + authResponse?: any; +} + interface HelloJSStatic extends HelloJSEvent { init(serviceAppIds: { [id: string]: string; }, options?: HelloJSLoginOptions): void; - login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; - logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSThenable; + login(network: string, options?: HelloJSLoginOptions, callback?: () => void): HelloJSStatic; + logout(network: string, options?: HelloJSLogoutOptions, callback?: () => void): HelloJSStatic; getAuthResponse(network: string): any; service(network: string): HelloJSServiceDef; settings: HelloJSLoginOptions; @@ -93,7 +93,7 @@ interface HelloJSStaticNamed { login(option?: HelloJSLoginOptions, callback?: () => void): HelloJSThenable; logout(callback?: () => void): HelloJSThenable; getAuthResponse(): any; - api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSThenable; + api(path?: string, method?: string, data?: any, callback?: (json?: any) => void): HelloJSStatic; } interface HelloJSOAuthDef { From 4b8091b4129bdad21aad9477fbe70e5384b5fb6e Mon Sep 17 00:00:00 2001 From: york yao Date: Sun, 7 Aug 2016 10:24:54 +0800 Subject: [PATCH 30/47] add definitions of ajv --- ajv/ajv-tests.ts | 74 +++++++++++++++++++++++++++++++ ajv/ajv.d.ts | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 ajv/ajv-tests.ts create mode 100644 ajv/ajv.d.ts diff --git a/ajv/ajv-tests.ts b/ajv/ajv-tests.ts new file mode 100644 index 0000000000..e6413fd824 --- /dev/null +++ b/ajv/ajv-tests.ts @@ -0,0 +1,74 @@ +/// + +import * as Ajv from 'ajv'; +var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true} +var validate = ajv.compile({}); +var valid = validate({}); +if (!valid) console.log(validate.errors); + +var valid = ajv.validate({}, {}); +if (!valid) console.log(ajv.errors); + +ajv.addSchema({}, 'mySchema'); +var valid = ajv.validate('mySchema', {}); +if (!valid) console.log(ajv.errorsText()); + +ajv.addKeyword('range', { + type: 'number', compile: function (sch, parentSchema) { + var min: any = sch[0]; + var max: any = sch[1]; + + return parentSchema.exclusiveRange === true + ? function (data) { return data > min && data < max; } + : function (data) { return data >= min && data <= max; } + } +}); + +var schema = { "range": [2, 4], "exclusiveRange": true }; +var validate = ajv.compile(schema); +console.log(validate(2.01)); // true +console.log(validate(3.99)); // true +console.log(validate(2)); // false +console.log(validate(4)); // false + +declare var request: any; +function loadSchema(uri: any, callback: any) { + request.json(uri, function (err: any, res: any, body: any) { + if (err || res.statusCode >= 400) + callback(err || new Error('Loading error: ' + res.statusCode)); + else + callback(null, body); + }); +} +var ajv = new Ajv({ loadSchema: loadSchema }); + +ajv.compileAsync(schema, function (err, validate) { + if (err) return; + var valid = validate({}); +}); + +declare var knex: any; +function checkIdExists(schema: any, data: any) { + return knex(schema.table) + .select('id') + .where('id', data) + .then(function (rows: any) { + return true; + }); +} + +var validate = ajv.compile(schema); + +(validate({ userId: 1, postId: 19 }) as PromiseLike) + .then(function (valid) { + // "valid" is always true here + console.log('Data is valid'); + }, function (err) { + if (!(err instanceof Ajv.ValidationError)) throw err; + // data is invalid + console.log('Validation errors:', err.errors); + }); + +var ajv = new Ajv({ /* async: 'es7', */ transpile: 'nodent' }); +var validate = ajv.compile(schema); // transpiled es7 async function +(validate({}) as PromiseLike).then(() => { }, () => { }); diff --git a/ajv/ajv.d.ts b/ajv/ajv.d.ts new file mode 100644 index 0000000000..d8bfd56ef3 --- /dev/null +++ b/ajv/ajv.d.ts @@ -0,0 +1,112 @@ +// Type definitions for ajv +// Project: https://github.com/epoberezkin/ajv +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "ajv" { + class Ajv { + /** + * Create Ajv instance. + */ + constructor(options?: Ajv.AjvOptions); + /** + * Generate validating function and cache the compiled schema for future use. + */ + compile(schema: any): Ajv.AjvValidate; + /** + * Asyncronous version of compile method that loads missing remote schemas using asynchronous function in options.loadSchema. + */ + compileAsync(schema: any, callback: (error: Error, validate: Ajv.AjvValidate) => void): void; + /** + * Validate data using passed schema (it will be compiled and cached). + */ + validate(schema: any, data: any): boolean | PromiseLike; + errors: Ajv.ValidationError[]; + /** + * Add schema(s) to validator instance. + */ + addSchema(schema: any, key: string): void; + /** + * Adds meta schema(s) that can be used to validate other schemas. + * That function should be used instead of addSchema because there may be instance options that would compile a meta schema incorrectly (at the moment it is removeAdditional option). + */ + addMetaSchema(schema: any, key: string): void; + /** + * Validates schema. + * This method should be used to validate schemas rather than validate due to the inconsistency of uri format in JSON-Schema standard. + */ + validateSchema(schema: any): Boolean; + /** + * Retrieve compiled schema previously added with addSchema by the key passed to addSchema or by its full reference (id). + * Returned validating function has schema property with the reference to the original schema. + */ + getSchema(key: string): Ajv.AjvValidate; + /** + * Remove added/cached schema. + * Even if schema is referenced by other schemas it can be safely removed as dependent schemas have local references. + */ + removeSchema(schema: any): void; + /** + * Add custom format to validate strings. It can also be used to replace pre-defined formats for Ajv instance. + */ + addFormat(name: string, format: any): void; + /** + * Add custom validation keyword to Ajv instance. + */ + addKeyword(keyword: string, definition: Ajv.AjxKeywordDefinition): void; + errorsText(): any; + static ValidationError: Function; + } + namespace Ajv { + type AjvOptions = { + v5?: boolean; + allErrors?: boolean; + verbose?: boolean; + jsonPointers?: boolean; + uniqueItems?: boolean; + unicode?: boolean; + format?: string; + formats?: any; + schemas?: any; + missingRefs?: boolean; + loadSchema?(uri: string, callback: (error: Error, body: any) => void): void; + removeAdditional?: boolean; + useDefaults?: boolean; + coerceTypes?: boolean; + async?: any; + transpile?: string; + meta?: boolean; + validateSchema?: boolean; + addUsedSchema?: boolean; + inlineRefs?: boolean; + passContext?: boolean; + loopRequired?: number; + ownProperties?: boolean; + multipleOfPrecision?: boolean; + errorDataPath?: string, + messages?: boolean; + beautify?: boolean; + cache?: any; + } + type AjvValidate = ((data: any) => boolean | PromiseLike) & { + errors: ValidationError[]; + } + type AjxKeywordDefinition = { + async?: boolean; + type: string; + compile?: (schema: any, parentsSchema: any) => ((data: any) => boolean | PromiseLike); + validate?: (schema: any, data: any) => boolean; + } + type ValidationError = { + keyword: string; + dataPath: string; + schemaPath: string; + params: any; + message: string; + schema: any; + parentSchema: any; + data: any; + } + } + export = Ajv; +} From 0da790884ece889a38f7c655d3351c91b4b80848 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 7 Aug 2016 08:08:05 -0400 Subject: [PATCH 31/47] commented out array.sort() which may create errors depending on the version of lib.d.ts --- mongoose/mongoose.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts index 9d8eb390b0..421129320f 100644 --- a/mongoose/mongoose.d.ts +++ b/mongoose/mongoose.d.ts @@ -1122,7 +1122,9 @@ declare module "mongoose" { * potentially overwritting any changes that happen between when you retrieved the object * and when you save it. */ - sort(compareFn?: (a: T, b: T) => number): T[]; + // some lib.d.ts have return type "this" and others have return type "T[]" + // which causes errors. Let the inherited array provide the sort() method. + //sort(compareFn?: (a: T, b: T) => number): T[]; /** * Wraps Array#splice with proper change tracking and casting. From f1fe2148037bbd924235f49065ae5286b33a4ae4 Mon Sep 17 00:00:00 2001 From: wallverb Date: Sun, 7 Aug 2016 10:53:50 -0400 Subject: [PATCH 32/47] Add cb to SNICallback NodeJS doc: SNICallback(servername, cb) A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: servername and cb. SNICallback should invoke cb(null, ctx), where ctx is a SecureContext instance. (tls.createSecureContext(...) can be used to get a proper SecureContext.) If SNICallback wasn't provided the default callback with high-level API will be used (see below). --- node/node.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index 6ccd2caf89..6770d84632 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -903,7 +903,7 @@ declare module "https" { requestCert?: boolean; rejectUnauthorized?: boolean; NPNProtocols?: any; - SNICallback?: (servername: string) => any; + SNICallback?: (servername: string, cb:(err:Error,ctx:tls.SecureContext)=>any) => any; } export interface RequestOptions extends http.RequestOptions { @@ -1995,7 +1995,7 @@ declare module "tls" { requestCert?: boolean; rejectUnauthorized?: boolean; NPNProtocols?: any; //array or Buffer; - SNICallback?: (servername: string) => any; + SNICallback?: (servername: string, cb:(err:Error,ctx:SecureContext)=>any) => any; } export interface ConnectionOptions { From d765fdbf2517c151c69b9cb5afd86eff149cbce6 Mon Sep 17 00:00:00 2001 From: Ekin Koc Date: Sun, 7 Aug 2016 22:56:32 +0300 Subject: [PATCH 33/47] Fix error TS2497 on import * as X from 'koa-static --- koa-static/koa-static.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koa-static/koa-static.d.ts b/koa-static/koa-static.d.ts index 4b95eca3be..feba76fb8d 100644 --- a/koa-static/koa-static.d.ts +++ b/koa-static/koa-static.d.ts @@ -46,6 +46,6 @@ declare module "koa-static" { */ gzip?: boolean; }): { (ctx: Koa.Context, next?: () => any): any }; - + namespace serve{} export = serve; } From 5dcd99320d6e14900b5687fcdc682c675676409b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Kov=C3=A1cs=20Q?= Date: Mon, 8 Aug 2016 10:41:19 +0200 Subject: [PATCH 34/47] [Drop] Change return type of createContext to use typeof --- drop/drop.d.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drop/drop.d.ts b/drop/drop.d.ts index 7794977b08..87ae4425b9 100644 --- a/drop/drop.d.ts +++ b/drop/drop.d.ts @@ -27,7 +27,7 @@ declare class Drop { public once(event: string, handler: Function, context?: any): void; public off(event: string, handler?: Function): void; - public static createContext(options: Drop.IDropContextOptions): Drop.IDropConstructor; + public static createContext(options: Drop.IDropContextOptions): typeof Drop; } declare namespace Drop { @@ -54,10 +54,6 @@ declare namespace Drop { hoverCloseDelay?: number; tetherOptions?: Tether.ITetherOptions; } - - interface IDropConstructor { - new (options: Drop.IDropOptions): Drop; - } } declare module "drop" { From f01bad82e6d997dda493ce626f62141ab5676d08 Mon Sep 17 00:00:00 2001 From: Vlado Tesanovic Date: Mon, 8 Aug 2016 14:08:07 +0200 Subject: [PATCH 35/47] Update express-brute.d.ts --- express-brute/express-brute.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/express-brute/express-brute.d.ts b/express-brute/express-brute.d.ts index 37df68af64..c194f5b69a 100644 --- a/express-brute/express-brute.d.ts +++ b/express-brute/express-brute.d.ts @@ -49,15 +49,15 @@ declare module "express-brute" { * @interface */ interface ExpressBruteOptions { - freeRetries: number; - proxyDepth: number; - attachResetToRequest: boolean; - refreshTimeoutOnRequest: boolean; - minWait: number; - maxWait: number; - lifetime: number; - failCallback: (req: express.Request, res: express.Response, next: Function, nextValidRequestDate: any) => void; - handleStoreError: any; + freeRetries?: number; + proxyDepth?: number; + attachResetToRequest?: boolean; + refreshTimeoutOnRequest?: boolean; + minWait?: number; + maxWait?: number; + lifetime?: number; + failCallback?: (req: express.Request, res: express.Response, next: Function, nextValidRequestDate: any) => void; + handleStoreError?: any; } /** @@ -70,7 +70,7 @@ class ExpressBrute { * @constructor * @param {any} store The store. */ - constructor(store: any); + constructor(store: any, options?: ExpressBruteOptions); /** * @summary Generates middleware that will bounce requests with the same key and IP address that happen faster than the current wait time by calling failCallback. From a54edba69170195685dac5cf438036356ee04b29 Mon Sep 17 00:00:00 2001 From: jan-molak Date: Mon, 8 Aug 2016 13:18:41 +0100 Subject: [PATCH 36/47] Updated to match the command signature as of 4.8.1 --- yargs/yargs-tests.ts | 6 ++++++ yargs/yargs.d.ts | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 14509d2072..06f7dd0b5b 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -321,3 +321,9 @@ function Argv$reset() { ya.showHelp(); } } + +function Argv$commandDir() { + var ya = yargs + .commandDir('.') + .argv +} diff --git a/yargs/yargs.d.ts b/yargs/yargs.d.ts index 7dc1ef2319..a26396ed37 100644 --- a/yargs/yargs.d.ts +++ b/yargs/yargs.d.ts @@ -70,6 +70,8 @@ declare module "yargs" { command(command: string, description: string, builder: { [optionName: string]: Options }, handler: (args: Argv) => void): Argv; command(command: string, description: string, builder: (args: Argv) => Options, handler: (args: Argv) => void): Argv; + commandDir(dir: string, opts?: RequireDirectoryOptions): Argv; + completion(cmd: string, fn?: SyncCompletionFunction): Argv; completion(cmd: string, description?: string, fn?: SyncCompletionFunction): Argv; completion(cmd: string, fn?: AsyncCompletionFunction): Argv; @@ -95,7 +97,7 @@ declare module "yargs" { strict(): Argv; - help(): string; + help(): Argv; help(option: string, description?: string): Argv; env(prefix?: string): Argv; @@ -136,6 +138,14 @@ declare module "yargs" { fail(func: (msg: string) => any): void; } + interface RequireDirectoryOptions { + recurse?: boolean; + extensions?: string[]; + visit?: (any) => any; + include?: RegExp | ((string)=>boolean); + exclude?: RegExp | ((string)=>boolean); + } + interface Options { type?: string; group?: string; From 18d922366a44c5c8b277a87a656510a10d56e895 Mon Sep 17 00:00:00 2001 From: jan-molak Date: Mon, 8 Aug 2016 13:51:42 +0100 Subject: [PATCH 37/47] Updated to match the command signature as of 4.8.1 and updated the tests --- yargs/yargs-tests.ts | 3 ++- yargs/yargs.d.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 06f7dd0b5b..20e663f9b1 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -238,7 +238,8 @@ function completion_async() { function Argv$help() { var yargs1 = yargs .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); - var s: string = yargs1.help(); + + yargs1.help().argv; } function Argv$showHelpOnFail() { diff --git a/yargs/yargs.d.ts b/yargs/yargs.d.ts index a26396ed37..e2f329e3c0 100644 --- a/yargs/yargs.d.ts +++ b/yargs/yargs.d.ts @@ -141,9 +141,9 @@ declare module "yargs" { interface RequireDirectoryOptions { recurse?: boolean; extensions?: string[]; - visit?: (any) => any; - include?: RegExp | ((string)=>boolean); - exclude?: RegExp | ((string)=>boolean); + visit?: (commandObject: any, pathToFile?: string, filename?: string) => any; + include?: RegExp | ((pathToFile: string)=>boolean); + exclude?: RegExp | ((pathToFile: string)=>boolean); } interface Options { From d145c87f5219e8e9fa5abc42f0a7da537988001a Mon Sep 17 00:00:00 2001 From: Michael Skarum Date: Mon, 8 Aug 2016 15:18:34 +0200 Subject: [PATCH 38/47] Added AWS Lambda --- aws-lambda/aws-lambda-tests.ts | 49 ++++++++++++++++++++++++++++++++++ aws-lambda/aws-lambda.d.ts | 43 +++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 aws-lambda/aws-lambda-tests.ts create mode 100644 aws-lambda/aws-lambda.d.ts diff --git a/aws-lambda/aws-lambda-tests.ts b/aws-lambda/aws-lambda-tests.ts new file mode 100644 index 0000000000..fd289dcb7f --- /dev/null +++ b/aws-lambda/aws-lambda-tests.ts @@ -0,0 +1,49 @@ +/// + +import lambda = require('aws-lambda'); + +var str: string; +var date: Date; +var sns: lambda.SNS; +var kinesis: lambda.Kinesis; +var recordsList: lambda.Record[]; +var anyObj: any; +var num: number; + +/* Records */ +var records: lambda.Records; + +recordsList = records.Records; + +/* Record */ +var record: lambda.Record; + +str = record.EventVersion; +str = record.EventSubscriptionArn; +str = record.EnventSource; +sns = record.Sns; +kinesis = record.kinesis; + +/* SNS */ +str = sns.Type; +str = sns.MessageId; +str = sns.TopicArn; +str = sns.Subject; +str = sns.Message; +date = sns.Timestamp; + +/* Kinesis */ +var kinesis: lambda.Kinesis; + +str = kinesis.data; + +/* Context */ +var context: lambda.Context; + +context.log(str, anyObj); +context.fail(str); +context.succeed(str); +context.succeed(anyObj); +context.succeed(str, anyObj); +str = context.awsRequestId; +num = context.getRemainingTimeInMillis(); \ No newline at end of file diff --git a/aws-lambda/aws-lambda.d.ts b/aws-lambda/aws-lambda.d.ts new file mode 100644 index 0000000000..80ff3ce4a3 --- /dev/null +++ b/aws-lambda/aws-lambda.d.ts @@ -0,0 +1,43 @@ +// Type definitions for AWS Lambda +// Project: http://docs.aws.amazon.com/lambda +// Definitions by: Michael Skarum +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "aws-lambda" { + + export interface Records { + Records: Record[]; + } + interface Record { + EventVersion: string; + EventSubscriptionArn: string; + EnventSource: string; + Sns: SNS; + kinesis: Kinesis; + } + interface SNS { + Type: string; + MessageId: string; + TopicArn: string; + Subject: string; + Message: string; + Timestamp: Date; + } + + interface Kinesis { + data: string; + } + + export interface Context { + log(message: string, object: any): void; + fail(message: string): void; + succeed(message: string): void; + succeed(object: any): void; + succeed(message: string, object: any): void; + awsRequestId: string; + getRemainingTimeInMillis(): number; + } + + + export function Callback(error?: any, message?: string): void; +} \ No newline at end of file From ab312fac955d0245337bfe2bedff83bf721b3638 Mon Sep 17 00:00:00 2001 From: microshine Date: Mon, 8 Aug 2016 20:36:36 +0300 Subject: [PATCH 39/47] Update Handle type --- pkcs11js/pkcs11js.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkcs11js/pkcs11js.d.ts b/pkcs11js/pkcs11js.d.ts index 8ed0fd78bc..c340ca2112 100644 --- a/pkcs11js/pkcs11js.d.ts +++ b/pkcs11js/pkcs11js.d.ts @@ -1,4 +1,4 @@ -// Type definitions for pkcs11js v1.0.0 +// Type definitions for pkcs11js v1.0.3 // Project: https://github.com/PeculiarVentures/pkcs11js // Definitions by: Stepan Miroshin // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -7,12 +7,12 @@ /** * A Node.js implementation of the PKCS#11 2.3 interface - * v1.0.0 + * v1.0.3 */ declare module "pkcs11js" { - type Handle = number; + type Handle = Buffer; interface Version { From 79aec36f24b35329da809f36d5d164efeeab41ed Mon Sep 17 00:00:00 2001 From: jan-molak Date: Mon, 8 Aug 2016 20:10:57 +0100 Subject: [PATCH 40/47] Corrected the indentation and added a test to cover the optional configuration object that can be passed to `commandDir` --- yargs/yargs-tests.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 20e663f9b1..c964e1b724 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -236,10 +236,10 @@ function completion_async() { } function Argv$help() { - var yargs1 = yargs - .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); - - yargs1.help().argv; + var argv = yargs + .usage("$0 -operand1 number -operand2 number -operation [add|subtract]") + .help() + .argv; } function Argv$showHelpOnFail() { @@ -323,8 +323,23 @@ function Argv$reset() { } } +// http://yargs.js.org/docs/#methods-commanddirdirectory-opts function Argv$commandDir() { var ya = yargs .commandDir('.') .argv } + + +// http://yargs.js.org/docs/#methods-commanddirdirectory-opts +function Argv$commandDirWithOptions() { + var ya = yargs + .commandDir('.', { + recurse: false, + extensions: ['js'], + visit: (commandObject: any, pathToFile: string, filename: string) => { }, + include: /.*\.js$/, + exclude: /.*\.spec.js$/, + }) + .argv +} From f27002e2901cbb643cac55e81b77c73fa9dbf14a Mon Sep 17 00:00:00 2001 From: Ruslan Arkhipau Date: Mon, 8 Aug 2016 14:06:19 -0700 Subject: [PATCH 41/47] [grecaptcha] Added a missing `size` parameter; Added value constraints to `theme`, `type`, and `size` parameters --- grecaptcha/grecaptcha-tests.ts | 3 ++- grecaptcha/grecaptcha.d.ts | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/grecaptcha/grecaptcha-tests.ts b/grecaptcha/grecaptcha-tests.ts index cfc86e71b6..b252efb04d 100644 --- a/grecaptcha/grecaptcha-tests.ts +++ b/grecaptcha/grecaptcha-tests.ts @@ -2,8 +2,9 @@ var params: ReCaptchaV2.Parameters = { "sitekey": "mySuperSecretKey", - "theme": "black", // no type-checking here. + "theme": "light", "type": "image", + "size": "normal", "tabindex": 5, "callback": (response: string) => { }, "expired-callback": () => { }, diff --git a/grecaptcha/grecaptcha.d.ts b/grecaptcha/grecaptcha.d.ts index 8e3b744d53..c8f165a8f8 100644 --- a/grecaptcha/grecaptcha.d.ts +++ b/grecaptcha/grecaptcha.d.ts @@ -29,6 +29,10 @@ declare namespace ReCaptchaV2 getResponse(opt_widget_id?: number): string; } + type Theme = "light" | "dark"; + type Type = "image" | "audio"; + type Size = "normal" | "compact"; + interface Parameters { /** @@ -39,14 +43,23 @@ declare namespace ReCaptchaV2 * Optional. The color theme of the widget. * Accepted values: "light", "dark" * @default "light" + * @type {Theme} **/ - theme?: string; + theme?: Theme; /** * Optional. The type of CAPTCHA to serve. - * Accepted values: "audio ", "image" + * Accepted values: "audio", "image" * @default "image" + * @type {Type} **/ - type?: string; + type?: Type; + /** + * Optional. The size of the widget. + * Accepted values: "compact", "normal" + * @default "compact" + * @type {Size} + */ + size?: Size; /** * Optional. The tabindex of the widget and challenge. * If other elements in your page use tabindex, it should be set to make user navigation easier. From 59beaf066765d009675802c34f939d48710b3a01 Mon Sep 17 00:00:00 2001 From: Michael Skarum Date: Tue, 9 Aug 2016 07:20:40 +0200 Subject: [PATCH 42/47] Changes based on review --- aws-lambda/aws-lambda.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws-lambda/aws-lambda.d.ts b/aws-lambda/aws-lambda.d.ts index 80ff3ce4a3..cdd8e2f506 100644 --- a/aws-lambda/aws-lambda.d.ts +++ b/aws-lambda/aws-lambda.d.ts @@ -39,5 +39,5 @@ declare module "aws-lambda" { } - export function Callback(error?: any, message?: string): void; + export type Callback = (error?: Error, message?: string) => void; } \ No newline at end of file From f7763de15ee8b5f3425cd165feebd0ae9ccf05f7 Mon Sep 17 00:00:00 2001 From: Garth Kidd Date: Tue, 26 Jul 2016 12:54:31 +1000 Subject: [PATCH 43/47] Fix error TS2497 on import * as X from 'statsd-client': Per Microsoft/TypeScript#5073, closed as `By Design` by @mhegazy, we need to export a namespace for `import *` to work, else `TS2497`. That clashes with the `export = ClassName` pattern unless you also merge in a namespace, e.g. with `namespace ClassName {}`. --- statsd-client/statsd-client-import-asterisk-tests.ts | 3 +++ statsd-client/statsd-client.d.ts | 1 + 2 files changed, 4 insertions(+) create mode 100644 statsd-client/statsd-client-import-asterisk-tests.ts diff --git a/statsd-client/statsd-client-import-asterisk-tests.ts b/statsd-client/statsd-client-import-asterisk-tests.ts new file mode 100644 index 0000000000..b01d523042 --- /dev/null +++ b/statsd-client/statsd-client-import-asterisk-tests.ts @@ -0,0 +1,3 @@ +/// +import * as StatsdClient from 'statsd-client'; +const statsd = new StatsdClient({ debug: true }); diff --git a/statsd-client/statsd-client.d.ts b/statsd-client/statsd-client.d.ts index 2fabcfb83f..b5c8bba2ef 100644 --- a/statsd-client/statsd-client.d.ts +++ b/statsd-client/statsd-client.d.ts @@ -99,5 +99,6 @@ declare module "statsd-client" { getChildClient(name: string): StatsdClient; } + namespace StatsdClient {} export = StatsdClient; } From 8aa4200da22464f6fccdc629e786abbdcdee71ca Mon Sep 17 00:00:00 2001 From: Eric Brody Date: Mon, 8 Aug 2016 10:09:19 -0400 Subject: [PATCH 44/47] Update serialport for 4.0 changes to the way it is exported --- serialport/serialport-tests.ts | 22 ++++----- serialport/serialport.d.ts | 86 +++++++++++++++++----------------- 2 files changed, 55 insertions(+), 53 deletions(-) diff --git a/serialport/serialport-tests.ts b/serialport/serialport-tests.ts index b820fa7a8d..79f85423eb 100644 --- a/serialport/serialport-tests.ts +++ b/serialport/serialport-tests.ts @@ -1,38 +1,38 @@ // Tests for serialport.d.ts -// Project: https://github.com/EmergingTechnologyAdvisors/node-serialport +// Project: https://github.com/EmergingTechnologyAdvisors/node-serialport // Definitions by: Jeremy Foster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Tests taken from documentation samples. /// -import * as serialport from 'serialport'; +import * as SerialPort from 'serialport'; function test_basic_connect() { - let port = new serialport.SerialPort(""); + let port = new SerialPort(""); } function test_connect_config() { - let port = new serialport.SerialPort("", { + let port = new SerialPort("", { baudrate: 0, disconnectedCallback: function () { }, - parser: serialport.parsers.readline("\n") + parser: SerialPort.parsers.readline("\n") }); } function test_write() { - let port = new serialport.SerialPort(""); - port.write('main screen turn on', (err, bytesWritten) => { + let port = new SerialPort(""); + port.write("main screen turn on", (err, bytesWritten) => { }); } function test_events() { - let port = new serialport.SerialPort(""); - port.on('open', function () { }); + let port = new SerialPort(""); + port.on("open", function () { }); } function test_list_ports() { - serialport.list( (err:string, ports:serialport.portConfig[]) => { + SerialPort.list( (err: string, ports: SerialPort.portConfig[]) => { }); -} \ No newline at end of file +} diff --git a/serialport/serialport.d.ts b/serialport/serialport.d.ts index d8bbc03f6f..53d8a4e92e 100644 --- a/serialport/serialport.d.ts +++ b/serialport/serialport.d.ts @@ -1,51 +1,53 @@ -// Type definitions for serialport -// Project: https://github.com/EmergingTechnologyAdvisors/node-serialport +// Type definitions for serialport 4.0.1 +// Project: https://github.com/EmergingTechnologyAdvisors/node-serialport // Definitions by: Jeremy Foster -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'serialport' { - module parsers { - function readline(delimiter: string):void; - function raw(emitter:any, buffer:string):void - } - - export class SerialPort { - constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err:string) => void) + class SerialPort { + constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err: string) => void) isOpen: boolean; - on(event: string, callback?: (data?:any) => void):void; - open(callback?: () => void):void; - write(buffer: any, callback?: (err:string, bytesWritten:number) => void):void - pause():void; - resume():void; - disconnected(err: Error):void; - close(callback?: () => void):void; - flush(callback?: () => void):void; - set(options: setOptions, callback: () => void):void; - drain(callback?: () => void):void; - update(options: updateOptions, callback?: () => void):void; + on(event: string, callback?: (data?: any) => void): void; + open(callback?: () => void): void; + write(buffer: any, callback?: (err: string, bytesWritten: number) => void): void + pause(): void; + resume(): void; + disconnected(err: Error): void; + close(callback?: () => void): void; + flush(callback?: () => void): void; + set(options: SerialPort.setOptions, callback: () => void): void; + drain(callback?: () => void): void; + update(options: SerialPort.updateOptions, callback?: () => void): void; + static list(callback: (err: string, ports: SerialPort.portConfig[]) => void): void; + static parsers: { + readline: (delimiter: string) => void, + raw: (emitter: any, buffer: string) => void + }; } - export function list(callback: (err: string, ports:portConfig[]) => void): void; + namespace SerialPort { + interface portConfig { + comName: string; + manufacturer: string; + serialNumber: string; + pnpId: string; + locationId: string; + vendorId: string; + productId: string; + } - interface portConfig { - comName: string, - manufacturer: string, - serialNumber: string, - pnpId: string, - locationId: string, - vendorId: string, - productId: string + interface setOptions { + brk?: boolean; + cts?: boolean; + dsr?: boolean; + dtr?: boolean; + rts?: boolean; + } + + interface updateOptions { + baudRate?: number; + } } - interface setOptions { - brk?: boolean; - cts?: boolean; - dsr?: boolean; - dtr?: boolean; - rts?: boolean; - } - - interface updateOptions { - baudRate?: number - } -} \ No newline at end of file + export = SerialPort +} From a4af2e4e31b8ab2e2bc4f3075434898ca0a092e3 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 10 Aug 2016 07:13:51 -0700 Subject: [PATCH 45/47] Fix i18next merge --- i18next/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/i18next/index.d.ts b/i18next/index.d.ts index b02aa16bbe..39e0f2a1a2 100644 --- a/i18next/index.d.ts +++ b/i18next/index.d.ts @@ -87,8 +87,8 @@ declare namespace i18n { type TranslationFunction = (key: string, options?: TranslationOptions) => string; - class I18n { - constructor(options?: Options, callback?: (err: any, t: TranslationFunction) => void); + interface I18n { + //constructor(options?: Options, callback?: (err: any, t: TranslationFunction) => void); init(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; @@ -121,7 +121,7 @@ declare namespace i18n { cloneInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; on(event: string, listener: () => void): void; - on(initialized: 'initialized', listener: (options: I18next.Options) => void): void; + on(initialized: 'initialized', listener: (options: i18n.Options) => void): void; on(loaded: 'loaded', listener: (loaded: any) => void): void; on(failedLoading: 'failedLoading', listener: (lng: string, ns: string, msg: string) => void): void; on(missingKey: 'missingKey', listener: (lngs: any, namespace: string, key: string, res: any) => void): void; From 9b7a29a8b59dd11b6b150af3a4f430b4239bcdf0 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 10 Aug 2016 10:07:13 -0700 Subject: [PATCH 46/47] Make test subclass structurally different from superclass --- lodash/lodash-tests.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 18786f28d0..4819d9ff68 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -6840,7 +6840,9 @@ namespace TestIsError { } { - class CustomError extends Error {} + class CustomError extends Error { + custom: string + } let value: number|CustomError; From f290918b0ecfdadd66025bb59c134d0b2111569e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 10 Aug 2016 13:09:24 -0700 Subject: [PATCH 47/47] Remove trailing . from doctrine header --- doctrine/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doctrine/index.d.ts b/doctrine/index.d.ts index 92e05e4f3d..6ccab4269a 100644 --- a/doctrine/index.d.ts +++ b/doctrine/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for doctrine the JSDoc parser. +// Type definitions for doctrine the JSDoc parser // Project: https://github.com/eslint/doctrine // Definitions by: rictic // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped