add cannon,rsvp,wonder-commonlib,wonder-frp dts file

This commit is contained in:
yyc
2017-01-21 21:14:25 +08:00
parent d568404f00
commit a8f925e787
8 changed files with 2364 additions and 0 deletions
+989
View File
@@ -0,0 +1,989 @@
declare module CANNON {
export interface IAABBOptions {
upperBound?: Vec3;
lowerBound?: Vec3;
}
export class AABB {
lowerBound: Vec3;
upperBound: Vec3;
constructor(options?: IAABBOptions);
setFromPoints(points: Vec3[], position?: Vec3, quaternion?: Quaternion, skinSize?: number): void;
copy(aabb: AABB): void;
extend(aabb: AABB): void;
overlaps(aabb: AABB): boolean;
}
export class ArrayCollisionMatrix {
matrix: Mat3[];
get(i: number, j: number): number;
set(i: number, j: number, value?: number): void;
reset(): void;
setNumObjects(n: number): void;
}
export class BroadPhase {
world: World;
useBoundingBoxes: boolean;
dirty: boolean;
collisionPairs(world: World, p1: Body[], p2: Body[]): void;
needBroadphaseCollision(bodyA: Body, bodyB: Body): boolean;
intersectionTest(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void;
doBoundingSphereBroadphase(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void;
doBoundingBoxBroadphase(bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void;
makePairsUnique(pairs1: Body[], pairs2: Body[]): void;
setWorld(world: World): void;
boundingSphereCheck(bodyA: Body, bodyB: Body): boolean;
aabbQuery(world: World, aabb: AABB, result: Body[]): Body[];
}
export class GridBroadphase extends BroadPhase {
nx: number;
ny: number;
nz: number;
aabbMin: Vec3;
aabbMax: Vec3;
bins: any[];
constructor(aabbMin?: Vec3, aabbMax?: Vec3, nx?: number, ny?: number, nz?: number);
}
export class NaiveBroadphase extends BroadPhase {
}
export class ObjectCollisionMatrix {
matrix: number[];
get(i: number, j: number): number;
set(i: number, j: number, value: number): void;
reset(): void;
setNumObjects(n: number): void;
}
export class Ray {
from: Vec3;
to: Vec3;
precision: number;
checkCollisionResponse: boolean;
constructor(from?: Vec3, to?: Vec3);
getAABB(result: RaycastResult): void;
}
export class RaycastResult {
rayFromWorld: Vec3;
rayToWorld: Vec3;
hitNormalWorld: Vec3;
hitPointWorld: Vec3;
hasHit: boolean;
shape: Shape;
body: Body;
distance: number;
reset(): void;
set(rayFromWorld: Vec3, rayToWorld: Vec3, hitNormalWorld: Vec3, hitPointWorld: Vec3, shape: Shape, body: Body, distance: number): void;
}
export class SAPBroadphase extends BroadPhase {
static insertionSortX(a: any[]): any[];
static insertionSortY(a: any[]): any[];
static insertionSortZ(a: any[]): any[];
static checkBounds(bi: Body, bj: Body, axisIndex?: number): boolean;
axisList: any[];
world: World;
axisIndex: number;
constructor(world?: World);
autoDetectAxis(): void;
aabbQuery(world: World, aabb: AABB, result?: Body[]): Body[];
}
export interface IConstraintOptions {
collideConnected?: boolean;
wakeUpBodies?: boolean;
}
export class Constraint {
equations: any[];
bodyA: Body;
bodyB: Body;
id: number;
collideConnected: boolean;
constructor(bodyA: Body, bodyB: Body, options?: IConstraintOptions);
update(): void;
}
export class DistanceConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, distance: number, maxForce?: number);
}
export interface IHingeConstraintOptions {
pivotA?: Vec3;
axisA?: Vec3;
pivotB?: Vec3;
axisB?: Vec3;
maxForce?: number;
}
export class HingeConstraint extends Constraint {
motorEnabled: boolean;
motorTargetVelocity: number;
motorMinForce: number;
motorMaxForce: number;
motorEquation: RotationalMotorEquation;
constructor(bodyA: Body, bodyB: Body, options?: IHingeConstraintOptions);
enableMotor(): void;
disableMotor(): void;
}
export class PointToPointConstraint extends Constraint {
constructor(bodyA: Body, pivotA: Vec3, bodyB: Body, pivotB: Vec3, maxForce?: number);
}
export class LockConstraint extends Constraint {
constructor(bodyA: Body, bodyB: Body, options?:any);
}
export class Equation {
id: number;
minForce: number;
maxForce: number;
bi: Body;
bj: Body;
a: number;
b: number;
eps: number;
jacobianElementA: JacobianElement;
jacobianElementB: JacobianElement;
enabled: boolean;
constructor(bi: Body, bj: Body, minForce?: number, maxForce?: number);
setSpookParams(stiffness: number, relaxation: number, timeStep: number): void;
computeB(a: number, b: number, h: number): number;
computeGq(): number;
computeGW(): number;
computeGWlamda(): number;
computeGiMf(): number;
computeGiMGt(): number;
addToWlamda(deltalambda: number): number;
computeC(): number;
}
export class FrictionEquation extends Equation {
constructor(bi: Body, bj: Body, slipForce: number);
}
export class RotationalEquation extends Equation {
ni: Vec3;
nj: Vec3;
nixnj: Vec3;
njxni: Vec3;
invIi: Mat3;
invIj: Mat3;
relVel: Vec3;
relForce: Vec3;
constructor(bodyA: Body, bodyB: Body);
}
export class RotationalMotorEquation extends Equation {
axisA: Vec3;
axisB: Vec3;
invLi: Mat3;
invIj: Mat3;
targetVelocity: number;
constructor(bodyA: Body, bodyB: Body, maxForce?: number);
}
export class ContactEquation extends Equation {
restitution: number;
ri: Vec3;
rj: Vec3;
penetrationVec: Vec3;
ni: Vec3;
rixn: Vec3;
rjxn: Vec3;
invIi: Mat3;
invIj: Mat3;
biInvInertiaTimesRixn: Vec3;
bjInvInertiaTimesRjxn: Vec3;
constructor(bi: Body, bj: Body);
}
export interface IContactMaterialOptions {
friction?: number;
restitution?: number;
contactEquationStiffness?: number;
contactEquationRelaxation?: number;
frictionEquationStiffness?: number;
frictionEquationRelaxation?: number;
}
export class ContactMaterial {
id: number;
materials: Material[];
friction: number;
restitution: number;
contactEquationStiffness: number;
contactEquationRelaxation: number;
frictionEquationStiffness: number;
frictionEquationRelaxation: number;
constructor(m1: Material, m2: Material, options?: IContactMaterialOptions);
}
export class Material {
name: string;
id: number;
friction:number;
restitution:number;
constructor(name: string);
}
export class JacobianElement {
spatial: Vec3;
rotational: Vec3;
multiplyElement(element: JacobianElement): number;
multiplyVectors(spacial: Vec3, rotational: Vec3): number;
}
export class Mat3 {
constructor(elements?: number[]);
identity(): void;
setZero(): void;
setTrace(vec3: Vec3): void;
getTrace(target: Vec3): void;
vmult(v: Vec3, target?: Vec3): Vec3;
smult(s: number): void;
mmult(m: Mat3): Mat3;
scale(v: Vec3, target?: Mat3): Mat3;
solve(b: Vec3, target?: Vec3): Vec3;
e(row: number, column: number, value?: number): number;
copy(source: Mat3): Mat3;
toString(): string;
reverse(target?: Mat3): Mat3;
setRotationFromQuaternion(q: Quaternion): Mat3;
transpose(target?: Mat3): Mat3;
}
export class Quaternion {
x: number;
y: number;
z: number;
w: number;
constructor(x?: number, y?: number, z?: number, w?: number);
set(x: number, y: number, z: number, w: number): void;
toString(): string;
toArray(): number[];
setFromAxisAngle(axis: Vec3, angle: number): void;
toAxisAngle(targetAxis?: Vec3): any[];
setFromVectors(u: Vec3, v: Vec3): void;
mult(q: Quaternion, target?: Quaternion): Quaternion;
inverse(target?: Quaternion): Quaternion;
conjugate(target?: Quaternion): Quaternion;
normalize(): void;
normalizeFast(): void;
vmult(v: Vec3, target?: Vec3): Vec3;
copy(source: Quaternion): Quaternion;
toEuler(target: Vec3, order?: string): void;
setFromEuler(x: number, y: number, z: number, order?: string): Quaternion;
clone(): Quaternion;
}
export class Transform {
static pointToLocalFrame(position: Vec3, quaternion: Quaternion, worldPoint: Vec3, result?: Vec3): Vec3;
static pointToWorldFrame(position: Vec3, quaternion: Quaternion, localPoint: Vec3, result?: Vec3): Vec3;
position: Vec3;
quaternion: Quaternion;
vectorToWorldFrame(localVector: Vec3, result?: Vec3): Vec3;
vectorToLocalFrame(position: Vec3, quaternion: Quaternion, worldVector: Vec3, result?: Vec3): Vec3;
}
export class Vec3 {
static ZERO: Vec3;
x: number;
y: number;
z: number;
constructor(x?: number, y?: number, z?: number);
cross(v: Vec3, target?: Vec3): Vec3;
set(x: number, y: number, z: number): Vec3;
setZero(): void;
vadd(v: Vec3, target?: Vec3): Vec3;
vsub(v: Vec3, target?: Vec3): Vec3;
crossmat(): Mat3;
normalize(): number;
unit(target?: Vec3): Vec3;
norm(): number;
norm2(): number;
distanceTo(p: Vec3): number;
mult(scalar: number, target?: Vec3): Vec3;
scale(scalar: number, target?: Vec3): Vec3;
dot(v: Vec3): number;
isZero(): boolean;
negate(target?: Vec3): Vec3;
tangents(t1: Vec3, t2: Vec3): void;
toString(): string;
toArray(): number[];
copy(source: Vec3): Vec3;
lerp(v: Vec3, t: number, target?: Vec3): void;
almostEquals(v: Vec3, precision?: number): boolean;
almostZero(precision?: number): boolean;
isAntiparallelTo(v: Vec3, prescision?: number): boolean;
clone(): Vec3;
}
export interface IBodyOptions {
position?: Vec3;
velocity?: Vec3;
angularVelocity?: Vec3;
quaternion?: Quaternion;
mass?: number;
material?: number;
type?: number;
linearDamping?: number;
angularDamping?: number;
}
export class Body extends EventTarget {
static DYNAMIC: number;
static STATIC: number;
static KINEMATIC: number;
static AWAKE: number;
static SLEEPY: number;
static SLEEPING: number;
static sleepyEvent: IEvent;
static sleepEvent: IEvent;
id: number;
world: World;
preStep: Function;
postStep: Function;
vlambda: Vec3;
collisionFilterGroup: number;
collisionFilterMask: number;
collisionResponse: boolean;
position: Vec3;
previousPosition: Vec3;
initPosition: Vec3;
velocity: Vec3;
initVelocity: Vec3;
force: Vec3;
mass: number;
invMass: number;
material: Material;
linearDamping: number;
type: number;
allowSleep: boolean;
sleepState: number;
sleepSpeedLimit: number;
sleepTimeLimit: number;
timeLastSleepy: number;
torque: Vec3;
quaternion: Quaternion;
initQuaternion: Quaternion;
angularVelocity: Vec3;
initAngularVelocity: Vec3;
interpolatedPosition: Vec3;
interpolatedQuaternion: Quaternion;
shapes: Shape[];
shapeOffsets: any[];
shapeOrentiations: any[];
inertia: Vec3;
invInertia: Vec3;
invInertiaWorld: Mat3;
invMassSolve: number;
invInertiaSolve: Vec3;
invInteriaWorldSolve: Mat3;
fixedRotation: boolean;
angularDamping: number;
aabb: AABB;
aabbNeedsUpdate: boolean;
wlambda: Vec3;
constructor(options?: IBodyOptions);
wakeUp(): void;
sleep(): void;
sleepTick(time: number): void;
updateSolveMassProperties(): void;
pointToLocalFrame(worldPoint: Vec3, result?: Vec3): Vec3;
pointToWorldFrame(localPoint: Vec3, result?: Vec3): Vec3;
vectorToWorldFrame(localVector: Vec3, result?: Vec3): Vec3;
addShape(shape: Shape, offset?: Vec3, orientation?: Quaternion): void;
updateBoundingRadius(): void;
computeAABB(): void;
updateInertiaWorld(force: Vec3): void;
applyForce(force: Vec3, worldPoint: Vec3): void;
applyImpulse(impulse: Vec3, worldPoint: Vec3): void;
updateMassProperties(): void;
getVelocityAtWorldPoint(worldPoint: Vec3, result: Vec3): Vec3;
}
export interface IRaycastVehicleOptions {
chassisBody?: Body;
indexRightAxis?: number;
indexLeftAxis?: number;
indexUpAxis?: number;
}
export interface IWheelInfoOptions {
chassisConnectionPointLocal?: Vec3;
chassisConnectionPointWorld?: Vec3;
directionLocal?: Vec3;
directionWorld?: Vec3;
axleLocal?: Vec3;
axleWorld?: Vec3;
suspensionRestLength?: number;
suspensionMaxLength?: number;
radius?: number;
suspensionStiffness?: number;
dampingCompression?: number;
dampingRelaxation?: number;
frictionSlip?: number;
steering?: number;
rotation?: number;
deltaRotation?: number;
rollInfluence?: number;
maxSuspensionForce?: number;
isFronmtWheel?: boolean;
clippedInvContactDotSuspension?: number;
suspensionRelativeVelocity?: number;
suspensionForce?: number;
skidInfo?: number;
suspensionLength?: number;
maxSuspensionTravel?: number;
useCustomSlidingRotationalSpeed?: boolean;
customSlidingRotationalSpeed?: number;
position?: Vec3;
direction?: Vec3;
axis?: Vec3;
body?: Body;
}
export class WheelInfo {
maxSuspensionTravbel: number;
customSlidingRotationalSpeed: number;
useCustomSlidingRotationalSpeed: boolean;
sliding: boolean;
chassisConnectionPointLocal: Vec3;
chassisConnectionPointWorld: Vec3;
directionLocal: Vec3;
directionWorld: Vec3;
axleLocal: Vec3;
axleWorld: Vec3;
suspensionRestLength: number;
suspensionMaxLength: number;
radius: number;
suspensionStiffness: number;
dampingCompression: number;
dampingRelaxation: number;
frictionSlip: number;
steering: number;
rotation: number;
deltaRotation: number;
rollInfluence: number;
maxSuspensionForce: number;
engineForce: number;
brake: number;
isFrontWheel: boolean;
clippedInvContactDotSuspension: number;
suspensionRelativeVelocity: number;
suspensionForce: number;
skidInfo: number;
suspensionLength: number;
sideImpulse: number;
forwardImpulse: number;
raycastResult: RaycastResult;
worldTransform: Transform;
isInContact: boolean;
constructor(options?: IWheelInfoOptions);
}
export class RaycastVehicle {
chassisBody: Body;
wheelInfos: IWheelInfoOptions[];
sliding: boolean;
world: World;
iindexRightAxis: number;
indexForwardAxis: number;
indexUpAxis: number;
constructor(options?: IRaycastVehicleOptions);
addWheel(options?: IWheelInfoOptions): void;
setSteeringValue(value: number, wheelIndex: number): void;
applyEngineForce(value: number, wheelIndex: number): void;
setBrake(brake: number, wheelIndex: number): void;
addToWorld(world: World): void;
getVehicleAxisWorld(axisIndex: number, result: Vec3): Vec3;
updateVehicle(timeStep: number): void;
updateSuspension(deltaTime: number): void;
removeFromWorld(world: World): void;
getWheelTransformWorld(wheelIndex: number): Transform;
}
export interface IRigidVehicleOptions {
chassisBody: Body;
}
export class RigidVehicle {
wheelBodies: Body[];
coordinateSystem: Vec3;
chassisBody: Body;
constraints: Constraint[];
wheelAxes: Vec3[];
wheelForces: Vec3[];
constructor(options?: IRigidVehicleOptions);
addWheel(options?: IWheelInfoOptions): Body;
setSteeringValue(value: number, wheelIndex: number): void;
setMotorSpeed(value: number, wheelIndex: number): void;
disableMotor(wheelIndex: number): void;
setWheelForce(value: number, wheelIndex: number): void;
applyWheelForce(value: number, wheelIndex: number): void;
addToWorld(world: World): void;
removeFromWorld(world: World): void;
getWheelSpeed(wheelIndex: number): number;
}
export class SPHSystem {
particles: Particle[];
density: number;
smoothingRadius: number;
speedOfSound: number;
viscosity: number;
eps: number;
pressures: number[];
densities: number[];
neighbors: number[];
add(particle: Particle): void;
remove(particle: Particle): void;
getNeighbors(particle: Particle, neighbors: Particle[]): void;
update(): void;
w(r: number): number;
gradw(rVec: Vec3, resultVec: Vec3): void;
nablaw(r: number): number;
}
export interface ISpringOptions {
restLength?: number;
stiffness?: number;
damping?: number;
worldAnchorA?: Vec3;
worldAnchorB?: Vec3;
localAnchorA?: Vec3;
localAnchorB?: Vec3;
}
export class Spring {
restLength: number;
stffness: number;
damping: number;
bodyA: Body;
bodyB: Body;
localAnchorA: Vec3;
localAnchorB: Vec3;
constructor(options?: ISpringOptions);
setWorldAnchorA(worldAnchorA: Vec3): void;
setWorldAnchorB(worldAnchorB: Vec3): void;
getWorldAnchorA(result: Vec3): void;
getWorldAnchorB(result: Vec3): void;
applyForce(): void;
}
export class Box extends Shape {
static calculateIntertia(halfExtents: Vec3, mass: number, target: Vec3): void;
boundingSphereRadius: number;
collisionResponse: boolean;
halfExtents: Vec3;
convexPolyhedronRepresentation: ConvexPolyhedron;
constructor(halfExtents: Vec3);
updateConvexPolyhedronRepresentation(): void;
calculateLocalInertia(mass: number, target?: Vec3): Vec3;
getSideNormals(sixTargetVectors: boolean, quat?: Quaternion): Vec3[];
updateBoundingSphereRadius(): number;
volume(): number;
forEachWorldCorner(pos: Vec3, quat: Quaternion, callback: Function): void;
}
export class ConvexPolyhedron extends Shape {
static computeNormal(va: Vec3, vb: Vec3, vc: Vec3, target: Vec3): void;
static project(hull: ConvexPolyhedron, axis: Vec3, pos: Vec3, quat: Quaternion, result: number[]): void;
vertices: Vec3[];
worldVertices: Vec3[];
worldVerticesNeedsUpdate: boolean;
faces: number[];
faceNormals: Vec3[];
uniqueEdges: Vec3[];
constructor(points?: Vec3[], faces?: number[]);
computeEdges(): void;
computeNormals(): void;
getFaceNormal(i: number, target: Vec3): Vec3;
clipAgainstHull(posA: Vec3, quatA: Quaternion, hullB: Vec3, quatB: Quaternion, separatingNormal: Vec3, minDist: number, maxDist: number, result: any[]): void;
findSaparatingAxis(hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion, target: Vec3, faceListA: any[], faceListB: any[]): boolean;
testSepAxis(axis: Vec3, hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion): number;
getPlaneConstantOfFace(face_i: number): number;
clipFaceAgainstHull(separatingNormal: Vec3, posA: Vec3, quatA: Quaternion, worldVertsB1: Vec3[], minDist: number, maxDist: number, result: any[]): void;
clipFaceAgainstPlane(inVertices: Vec3[], outVertices: Vec3[], planeNormal: Vec3, planeConstant: number): Vec3;
computeWorldVertices(position: Vec3, quat: Quaternion): void;
computeLocalAABB(aabbmin: Vec3, aabbmax: Vec3): void;
computeWorldFaceNormals(quat: Quaternion): void;
calculateWorldAABB(pos: Vec3, quat: Quaternion, min: Vec3, max: Vec3): void;
getAveragePointLocal(target: Vec3): Vec3;
transformAllPoints(offset: Vec3, quat: Quaternion): void;
pointIsInside(p: Vec3): boolean;
}
export class Cylinder extends Shape {
constructor(radiusTop: number, radiusBottom: number, height: number, numSegments: number);
}
export interface IHightfield {
minValue?: number;
maxValue?: number;
elementSize: number;
}
export class Heightfield extends Shape {
data: number[];
maxValue: number;
minValue: number;
elementSize: number;
cacheEnabled: boolean;
pillarConvex: ConvexPolyhedron;
pillarOffset: Vec3;
type: number;
constructor(data: number[], options?: IHightfield);
update(): void;
updateMinValue(): void;
updateMaxValue(): void;
setHeightValueAtIndex(xi: number, yi: number, value: number): void;
getRectMinMax(iMinX: number, iMinY: number, iMaxX: number, iMaxY: number, result: any[]): void;
getIndexOfPosition(x: number, y: number, result: any[], clamp: boolean): boolean;
getConvexTrianglePillar(xi: number, yi: number, getUpperTriangle: boolean): void;
}
export class Particle extends Shape {
}
export class Plane extends Shape {
worldNormal: Vec3;
worldNormalNeedsUpdate: boolean;
boundingSphereRadius: number;
computeWorldNormal(quat: Quaternion): void;
calculateWorldAABB(pos: Vec3, quat: Quaternion, min: number, max: number): void;
}
export class Shape {
static types: {
SPHERE: number;
PLANE: number;
BOX: number;
COMPOUND: number;
CONVEXPOLYHEDRON: number;
HEIGHTFIELD: number;
PARTICLE: number;
CYLINDER: number;
}
type: number;
boundingSphereRadius: number;
collisionResponse: boolean;
updateBoundingSphereRadius(): number;
volume(): number;
calculateLocalInertia(mass: number, target: Vec3): Vec3;
}
export class Sphere extends Shape {
radius: number;
constructor(radius: number);
}
export class GSSolver extends Solver {
iterations: number;
tolerance: number;
solve(dy: number, world: World): number;
}
export class Solver {
iterations: number;
equations: Equation[];
solve(dy: number, world: World): number;
addEquation(eq: Equation): void;
removeEquation(eq: Equation): void;
removeAllEquations(): void;
}
export class SplitSolver extends Solver {
subsolver: Solver;
constructor(subsolver: Solver);
solve(dy: number, world: World): number;
}
export class EventTarget {
addEventListener(type: string, listener: Function): EventTarget;
hasEventListener(type: string, listener: Function): boolean;
removeEventListener(type: string, listener: Function): EventTarget;
dispatchEvent(event: IEvent): IEvent;
}
export class Pool {
objects: any[];
type: any[];
release(): any;
get(): any;
constructObject(): any;
}
export class TupleDictionary {
data: {
keys: any[];
};
get(i: number, j: number): number;
set(i: number, j: number, value: number): void;
reset(): void;
}
export class Utils {
static defaults(options?: any, defaults?: any): any;
}
export class Vec3Pool extends Pool {
type: any;
constructObject(): Vec3;
}
export class NarrowPhase {
contactPointPool: Pool[];
v3pool: Vec3Pool;
}
export class World extends EventTarget {
dt: number;
allowSleep: boolean;
contacts: ContactEquation[];
frictionEquations: FrictionEquation[];
quatNormalizeSkip: number;
quatNormalizeFast: boolean;
time: number;
stepnumber: number;
default_dt: number;
nextId: number;
gravity: Vec3;
broadphase: NaiveBroadphase;
bodies: Body[];
solver: Solver;
constraints: Constraint[];
narrowPhase: NarrowPhase;
collisionMatrix: ArrayCollisionMatrix;
collisionMatrixPrevious: ArrayCollisionMatrix;
materials: Material[];
contactmaterials: ContactMaterial[];
contactMaterialTable: TupleDictionary;
defaultMaterial: Material;
defaultContactMaterial: ContactMaterial;
doProfiling: boolean;
profile: {
solve: number;
makeContactConstraints: number;
broadphaser: number;
integrate: number;
narrowphase: number;
};
subsystems: any[];
addBodyEvent: IBodyEvent;
removeBodyEvent: IBodyEvent;
getContactMaterial(m1: Material, m2: Material): ContactMaterial;
numObjects(): number;
collisionMatrixTick(): void;
addBody(body: Body): void;
addConstraint(c: Constraint): void;
removeConstraint(c: Constraint): void;
rayTest(from: Vec3, to: Vec3, result: RaycastResult): void;
remove(body: Body): void;
addMaterial(m: Material): void;
addContactMaterial(cmat: ContactMaterial): void;
step(dy: number, timeSinceLastCalled?: number, maxSubSteps?: number): void;
}
export interface IEvent {
type: string;
}
export interface IBodyEvent extends IEvent {
body: Body;
}
}
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
]
}
+315
View File
@@ -0,0 +1,315 @@
// Type definitions for RSVP 3.0.9
// Project: github.com/tildeio/rsvp.js 3.0.9
// Definitions by: Taylor Brown <https://github.com/Taytay>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Some of this file was taken from the type definitions for es6-promise https://github.com/borisyankov/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts
// Credit for that file goes to: François de Campredon <https://github.com/fdecampredon/>
// Some of this file was taken from the type definitions for Q : https://github.com/borisyankov/DefinitelyTyped/blob/master/q/Q.d.ts
// Credit for that file goes to: Barrie Nemetchek <https://github.com/bnemetchek>, Andrew Gaspar <https://github.com/AndrewGaspar/>, John Reilly <https://github.com/johnnyreilly>
declare module RSVP {
interface Thenable<R> {
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => U): Thenable<U>;
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => void): Thenable<U>;
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => U): Thenable<U>;
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => void): Thenable<U>;
}
interface Deferred<T> {
promise: Promise<T>;
resolve(value: T): void;
reject(reason: any): void;
}
class Promise<R> implements Thenable<R> {
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise is fulfilled with result object passed to resolve.
* If you call reject your promise is rejected with the object passed to resolve.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback:(resolve:(result?:R) => void, reject:(error:any) => void) => void, label? : string);
/**
* If you call resolve in the body of the callback passed to the constructor,
* your promise will be fulfilled/rejected with the outcome of thenable passed to resolve.
* If you call reject your promise is rejected with the object passed to resolve.
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
* Any errors thrown in the constructor callback will be implicitly passed to reject().
*/
constructor(callback:(resolve:(thenable?:Thenable<R>) => void, reject:(error:any) => void) => void, label? : string);
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => Thenable<U>):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => U):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => Thenable<U>, onRejected?:(error:any) => void):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => Thenable<U>):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => U):Promise<U>;
/**
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
* If an error is thrown in the callback, the returned promise rejects with that error.
*
* @param onFulfilled called when/if "promise" resolves
* @param onRejected called when/if "promise" rejects
*/
then<U>(onFulfilled?:(value:R) => U, onRejected?:(error:any) => void):Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?:(error:any) => Thenable<U>):Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?:(error:any) => U):Promise<U>;
/**
* Sugar for promise.then(undefined, onRejected)
*
* @param onRejected called when/if "promise" rejects
*/
catch<U>(onRejected?:(error:any) => void):Promise<U>;
finally(finallyCallback: () => any): Promise<R>;
static all<T>(promises: Thenable<T>[]): Promise<T[]>;
static all<T>(promises: any[]): Promise<T[]>;
static race<R>(promises:Promise<R>[]):Promise<R>;
/**
@method resolve
@param {Any} value value that the returned promise will be resolved with
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise that will become fulfilled with the given
`value`
*/
static resolve<T>(object: Thenable<T>): Promise<T>;
static resolve<T>(object: T): Promise<T>;
/**
@method cast (Deprecated in favor of resolve
@param {Any} value value that the returned promise will be resolved with
@param {String} label optional string for identifying the returned promise.
Useful for tooling.
@return {Promise} a promise that will become fulfilled with the given
`value`
*/
static cast<T>(object: Thenable<T>, label? : string): Promise<T>;
static cast<T>(object: T, label? : string): Promise<T>;
/**
`RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
*/
static reject(reason?: any): Promise<any>;
}
interface PromiseState<T> {
state: string /* "fulfilled", "rejected", "pending" */;
value?: T;
reason?: any;
}
interface InstrumentEvent{
guid:string; // guid of promise. Must be globally unique, not just within the implementation
childGuid:string; // child of child promise (for chained via `then`)
eventName:string; // one of ['created', 'chained', 'fulfilled', 'rejected']
detail:any; // fulfillment value or rejection reason, if applicable
label:string; // label passed to promise's constructor
timeStamp:number; // milliseconds elapsed since 1 January 1970 00:00:00 UTC up until now
}
export function on(eventName : string, callback: (value:any)=>void) : void;
export function on(eventName : "error", errorHandler: (reason:any)=>void): void;
export function on(eventName : "created", listener: (event:InstrumentEvent)=>void): void;
export function on(eventName : "chained", listener: (event:InstrumentEvent)=>void): void;
export function on(eventName : "fulfilled", listener: (event:InstrumentEvent)=>void): void;
export function on(eventName : "rejected", listener: (event:InstrumentEvent)=>void): void;
export function configure(configName : string, value : any): void;
export function configure(configName : "instrument", shouldInstrument : boolean): void;
/**
* configure('onerror', handler) is deprecated in favor of on('error', handler)
* @param configName
* @param errorHandler
*/
export function configure(configName : "onerror", errorHandler : (reason:any)=>void): void;
/**
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
* the array passed to all can be a mixture of promise-like objects and other objects.
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
*/
export function all<T>(promises: Thenable<T>[]): Promise<T[]>;
export function all<T>(promises: any[]): Promise<T[]>;
/**
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
* the array passed to all can be a mixture of promise-like objects and other objects.
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
* The key difference to the all() function is that both the fulfillment value and the argument to the hash() function
* are object literals. This allows you to simply reference the results directly off the returned object without
* having to remember the initial order like you would with all().
*
*/
export function hash<T>(promises: Thenable<T>[]): Promise<T[]>;
export function hash<T>(promises: any[]): Promise<T[]>;
/**
`RSVP.map` is similar to JavaScript's native `map` method, except that it
waits for all promises to become fulfilled before running the `mapFn` on
each item in given to `promises`. `RSVP.map` returns a promise that will
become fulfilled with the result of running `mapFn` on the values the promises
become fulfilled with.
*/
export function map<T>(promises: Thenable<T>[], mapFn : (item:any)=>any, label? : string): Promise<T[]>;
export function map<T>(promises: any[], mapFn : (item:any)=>any, label? : string): Promise<T[]>;
/**
* `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing
* a fail-fast method, it waits until all the promises have returned and
* shows you all the results. This is useful if you want to handle multiple
* promises' failure states together as a set.
*/
export function allSettled<T>(promises: Thenable<T>[]): Promise<PromiseState<T>[]>;
export function allSettled<T>(promises: any[]): Promise<PromiseState<T>[]>;
/**
* `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object
* instead of an array for its `promises` argument.
*
* Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method,
* but like `RSVP.allSettled`, `hashSettled` waits until all the
* constituent promises have returned and then shows you all the results
* with their states and values/reasons. This is useful if you want to
* handle multiple promises' failure states together as a set.
*/
export function hashSettled<T>(promises: Thenable<T>[]): Promise<PromiseState<T>[]>;
export function hashSettled<T>(promises: any[]): Promise<PromiseState<T>[]>;
/**
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
*/
function race<R>(promises:Promise<R>[]):Promise<R>;
/**
* `RSVP.denodeify` takes a "node-style" function and returns a function that
* will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the
* browser when you'd prefer to use promises over using callbacks. For example,
* `denodeify` transforms the following:
*/
export function denodeify<T>(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise<T>;
/**
* Favor the Promise Constructor instead (if possible)
*
*/
export function defer<T>(): Deferred<T>;
/**
`RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
*/
export function reject(reason?: any): Promise<any>;
/**
`RSVP.Promise.resolve` returns a promise that will become resolved with the
passed `value`.
*/
export function resolve<T>(object: Thenable<T>): Promise<T>;
export function resolve<T>(object: T): Promise<T>;
/**
* `RSVP.filter` is similar to JavaScript's native `filter` method, except that it
* waits for all promises to become fulfilled before running the `filterFn` on
* each item in given to `promises`. `RSVP.filter` returns a promise that will
* become fulfilled with the result of running `filterFn` on the values the
* promises become fulfilled with.
*/
export function filter<T>(promises: Thenable<T>[], filterFn:(value:any)=>any): Promise<T[]>;
/**
`RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event
loop in order to aid debugging.
Promises A+ specifies that any exceptions that occur with a promise must be
caught by the promises implementation and bubbled to the last handler. For
this reason, it is recommended that you always specify a second rejection
handler function to `then`. However, `RSVP.rethrow` will throw the exception
outside of the promise, so it bubbles up to your console if in the browser,
or domain/cause uncaught exception in Node. `rethrow` will also throw the
error again so the error can be handled by the promise per the spec.
*/
export function rethrow(reason : any):void;
}
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
]
}
+258
View File
@@ -0,0 +1,258 @@
declare module wdCb {
class JudgeUtils {
static isArray(arr: any): boolean;
static isArrayExactly(arr: any): boolean;
static isNumber(num: any): boolean;
static isNumberExactly(num: any): boolean;
static isString(str: any): boolean;
static isStringExactly(str: any): boolean;
static isBoolean(bool: any): boolean;
static isDom(obj: any): boolean;
static isObject(obj: any): boolean;
static isDirectObject(obj: any): boolean;
static isHostMethod(object: any, property: any): boolean;
static isNodeJs(): boolean;
static isFunction(func: any): boolean;
}
}
declare var global: any, window: Window;
declare module wdCb {
var root: any;
}
declare module wdCb {
}
declare module wdCb {
const $BREAK: {
break: boolean;
};
const $REMOVE: any;
}
declare module wdCb {
class Log {
static info: {
INVALID_PARAM: string;
helperFunc: (...args: any[]) => string;
assertion: (...args: any[]) => any;
FUNC_INVALID: (...args: any[]) => any;
FUNC_MUST: (...args: any[]) => any;
FUNC_MUST_BE: (...args: any[]) => any;
FUNC_MUST_NOT_BE: (...args: any[]) => any;
FUNC_SHOULD: (...args: any[]) => any;
FUNC_SHOULD_NOT: (...args: any[]) => any;
FUNC_SUPPORT: (...args: any[]) => any;
FUNC_NOT_SUPPORT: (...args: any[]) => any;
FUNC_MUST_DEFINE: (...args: any[]) => any;
FUNC_MUST_NOT_DEFINE: (...args: any[]) => any;
FUNC_UNKNOW: (...args: any[]) => any;
FUNC_EXPECT: (...args: any[]) => any;
FUNC_UNEXPECT: (...args: any[]) => any;
FUNC_EXIST: (...args: any[]) => any;
FUNC_NOT_EXIST: (...args: any[]) => any;
FUNC_ONLY: (...args: any[]) => any;
FUNC_CAN_NOT: (...args: any[]) => any;
};
static log(...messages: any[]): void;
static assert(cond: any, ...messages: any[]): void;
static error(cond: any, ...message: any[]): any;
static warn(...message: any[]): void;
private static _exec(consoleMethod, args, sliceBegin?);
}
}
declare module wdCb {
class List<T> {
protected children: Array<T>;
getCount(): number;
hasChild(child: any): boolean;
hasChildWithFunc(func: Function): boolean;
getChildren(): T[];
getChild(index: number): T;
addChild(child: T): this;
addChildren(arg: Array<T> | List<T> | any): this;
setChildren(children: Array<T>): this;
unShiftChild(child: T): void;
removeAllChildren(): this;
forEach(func: Function, context?: any): this;
toArray(): T[];
protected copyChildren(): T[];
protected removeChildHelper(arg: any): Array<T>;
private _forEach(arr, func, context?);
private _removeChild(arr, func);
}
}
declare module wdCb {
class Collection<T> extends List<T> {
static create<T>(children?: any[]): Collection<T>;
constructor(children?: Array<T>);
clone(): any;
clone(isDeep: boolean): any;
clone(target: Collection<T>): any;
clone(target: Collection<T>, isDeep: boolean): any;
filter(func: (value: T, index: number) => boolean): Collection<T>;
findOne(func: (value: T, index: number) => boolean): T;
reverse(): Collection<T>;
removeChild(arg: any): Collection<T>;
sort(func: (a: T, b: T) => any, isSortSelf?: boolean): Collection<T>;
map(func: (value: T, index: number) => any): Collection<any>;
removeRepeatItems(): Collection<T>;
hasRepeatItems(): false;
}
}
declare module wdCb {
class Hash<T> {
static create<T>(children?: {}): Hash<T>;
constructor(children?: {
[s: string]: T;
});
private _children;
getChildren(): {
[s: string]: T;
};
getCount(): number;
getKeys(): Collection<string>;
getValues(): Collection<T>;
getChild(key: string): T;
setValue(key: string, value: any): this;
addChild(key: string, value: any): this;
addChildren(arg: {} | Hash<T>): this;
appendChild(key: string, value: any): this;
setChildren(children: {
[s: string]: T;
}): void;
removeChild(arg: any): Collection<T>;
removeAllChildren(): void;
hasChild(key: string): boolean;
hasChildWithFunc(func: Function): boolean;
forEach(func: Function, context?: any): this;
filter(func: Function): Hash<T>;
findOne(func: Function): any[];
map(func: Function): Hash<T>;
toCollection(): Collection<any>;
toArray(): Array<T>;
clone(): any;
clone(isDeep: boolean): any;
clone(target: Hash<T>): any;
clone(target: Hash<T>, isDeep: boolean): any;
}
}
declare module wdCb {
class Queue<T> extends List<T> {
static create<T>(children?: any[]): Queue<T>;
constructor(children?: Array<T>);
readonly front: T;
readonly rear: T;
push(element: T): void;
pop(): T;
clear(): void;
}
}
declare module wdCb {
class Stack<T> extends List<T> {
static create<T>(children?: any[]): Stack<T>;
constructor(children?: Array<T>);
readonly top: T;
push(element: T): void;
pop(): T;
clear(): void;
clone(): any;
clone(isDeep: boolean): any;
clone(target: Stack<T>): any;
clone(target: Stack<T>, isDeep: boolean): any;
filter(func: (value: T, index: number) => boolean): Collection<T>;
findOne(func: (value: T, index: number) => boolean): T;
reverse(): Collection<T>;
removeChild(arg: any): Collection<T>;
sort(func: (a: T, b: T) => any, isSortSelf?: boolean): Collection<T>;
map(func: (value: T, index: number) => any): Collection<any>;
removeRepeatItems(): Collection<T>;
hasRepeatItems(): false;
}
}
declare module wdCb {
class AjaxUtils {
static ajax(conf: any): void;
private static _createAjax(error);
private static _isLocalFile(status);
private static _isSoundFile(dataType);
}
}
declare module wdCb {
class ArrayUtils {
static removeRepeatItems(arr: Array<any>, isEqual?: (a: any, b: any) => boolean): any[];
static contain(arr: Array<any>, ele: any): boolean;
}
}
declare module wdCb {
class ConvertUtils {
static toString(obj: any): string;
private static _convertCodeToString(fn);
}
}
declare module wdCb {
class EventUtils {
static bindEvent(context: any, func: any): (event: any) => any;
static addEvent(dom: any, eventName: any, handler: any): void;
static removeEvent(dom: any, eventName: any, handler: any): void;
}
}
declare module wdCb {
class ExtendUtils {
static extendDeep(parent: any, child?: any, filter?: (val: any, i: any) => boolean): any;
static extend(destination: any, source: any): any;
static copyPublicAttri(source: any): {};
}
}
declare module wdCb {
class PathUtils {
static basename(path: string, ext?: string): string;
static changeExtname(pathStr: string, extname: string): string;
static changeBasename(pathStr: string, basename: string, isSameExt?: boolean): string;
static extname(path: string): string;
static dirname(path: string): string;
private static _splitPath(fileName);
}
}
declare module wdCb {
class FunctionUtils {
static bind(object: any, func: Function): () => any;
}
}
declare module wdCb {
class DomQuery {
static create(eleStr: string): any;
static create(dom: HTMLElement): any;
private _doms;
constructor(eleStr: string);
constructor(dom: HTMLElement);
get(index: any): HTMLElement;
prepend(eleStr: string): any;
prepend(dom: HTMLElement): any;
prependTo(eleStr: string): this;
remove(): this;
css(property: string, value: string): void;
attr(name: string): any;
attr(name: string, value: string): any;
text(str?: string): string;
private _isDomEleStr(eleStr);
private _buildDom(eleStr);
private _buildDom(dom);
private _createElement(eleStr);
}
}
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
]
}
+718
View File
@@ -0,0 +1,718 @@
declare module wdFrp {
class JudgeUtils extends wdCb.JudgeUtils {
static isPromise(obj: any): boolean;
static isEqual(ob1: Entity, ob2: Entity): boolean;
static isIObserver(i: IObserver): () => any;
}
}
declare module wdFrp {
var fromNodeCallback: (func: Function, context?: any) => (...funcArgs: any[]) => AnonymousStream;
var fromStream: (stream: any, finishEventName?: string) => AnonymousStream;
var fromReadableStream: (stream: any) => AnonymousStream;
var fromWritableStream: (stream: any) => AnonymousStream;
var fromTransformStream: (stream: any) => AnonymousStream;
}
declare module wdFrp {
abstract class Entity {
static UID: number;
private _uid;
uid: string;
constructor(uidPre: string);
}
}
declare module wdFrp {
class Main {
static isTest: boolean;
}
}
declare module wdFrp {
function assert(cond: boolean, message?: string): void;
function require(InFunc: any): (target: any, name: any, descriptor: any) => any;
function ensure(OutFunc: any): (target: any, name: any, descriptor: any) => any;
function requireGetter(InFunc: any): (target: any, name: any, descriptor: any) => any;
function requireSetter(InFunc: any): (target: any, name: any, descriptor: any) => any;
function ensureGetter(OutFunc: any): (target: any, name: any, descriptor: any) => any;
function ensureSetter(OutFunc: any): (target: any, name: any, descriptor: any) => any;
function invariant(func: any): (target: any) => void;
}
declare module wdFrp {
interface IDisposable {
dispose(): void;
}
}
declare module wdFrp {
class SingleDisposable extends Entity implements IDisposable {
static create(disposeHandler?: Function): SingleDisposable;
private _disposeHandler;
private _isDisposed;
constructor(disposeHandler: Function);
setDisposeHandler(handler: Function): void;
dispose(): void;
}
}
declare module wdFrp {
class GroupDisposable extends Entity implements IDisposable {
static create(disposable?: IDisposable): GroupDisposable;
private _group;
private _isDisposed;
constructor(disposable?: IDisposable);
add(disposable: IDisposable): this;
remove(disposable: IDisposable): this;
dispose(): void;
}
}
declare module wdFrp {
interface IObserver extends IDisposable {
next(value: any): any;
error(error: any): any;
completed(): any;
}
}
declare module wdFrp {
class InnerSubscription implements IDisposable {
static create(subject: Subject | GeneratorSubject, observer: Observer): InnerSubscription;
private _subject;
private _observer;
constructor(subject: Subject | GeneratorSubject, observer: Observer);
dispose(): void;
}
}
declare module wdFrp {
class InnerSubscriptionGroup implements IDisposable {
static create(): InnerSubscriptionGroup;
private _container;
addChild(child: IDisposable): void;
dispose(): void;
}
}
declare var global: any, window: Window;
declare module wdFrp {
var root: any;
}
declare module wdFrp {
}
declare module wdFrp {
}
declare module wdFrp {
}
declare module wdFrp {
abstract class Stream extends Entity {
scheduler: Scheduler;
subscribeFunc: (observer: IObserver) => Function | void;
constructor(subscribeFunc: any);
abstract subscribe(arg1: Function | Observer | Subject, onError?: Function, onCompleted?: Function): IDisposable;
buildStream(observer: IObserver): IDisposable;
do(onNext?: Function, onError?: Function, onCompleted?: Function): DoStream;
map(selector: Function): MapStream;
flatMap(selector: Function): MergeAllStream;
concatMap(selector: Function): any;
mergeAll(): MergeAllStream;
concatAll(): any;
skipUntil(otherStream: Stream): SkipUntilStream;
takeUntil(otherStream: Stream): TakeUntilStream;
take(count?: number): AnonymousStream;
takeLast(count?: number): AnonymousStream;
takeWhile(predicate: (value: any, index: number, source: Stream) => boolean, thisArg?: this): AnonymousStream;
lastOrDefault(defaultValue?: any): AnonymousStream;
filter(predicate: (value: any) => boolean, thisArg?: this): any;
filterWithState(predicate: (value: any) => boolean, thisArg?: this): any;
concat(streamArr: Array<Stream>): any;
concat(...otherStream: any[]): any;
merge(maxConcurrent: number): any;
merge(streamArr: Array<Stream>): any;
merge(...otherStreams: any[]): any;
repeat(count?: number): RepeatStream;
ignoreElements(): IgnoreElementsStream;
protected handleSubject(subject: any): boolean;
private _isSubject(subject);
private _setSubject(subject);
}
}
declare module wdFrp {
class Scheduler {
static create(...args: any[]): Scheduler;
private _requestLoopId;
requestLoopId: any;
publishRecursive(observer: IObserver, initial: any, action: Function): void;
publishInterval(observer: IObserver, initial: any, interval: number, action: Function): number;
publishIntervalRequest(observer: IObserver, action: Function): void;
publishTimeout(observer: IObserver, time: number, action: Function): number;
}
}
declare module wdFrp {
abstract class Observer extends Entity implements IObserver {
private _isDisposed;
isDisposed: boolean;
protected onUserNext: Function;
protected onUserError: Function;
protected onUserCompleted: Function;
private _isStop;
private _disposable;
constructor(observer: IObserver);
constructor(onNext: Function, onError: Function, onCompleted: Function);
next(value: any): any;
error(error: any): void;
completed(): void;
dispose(): void;
setDisposable(disposable: IDisposable): void;
protected abstract onNext(value: any): any;
protected abstract onError(error: any): any;
protected abstract onCompleted(): any;
}
}
declare module wdFrp {
class Subject implements IObserver {
static create(): Subject;
private _source;
source: Stream;
private _observer;
subscribe(arg1?: Function | Observer, onError?: Function, onCompleted?: Function): IDisposable;
next(value: any): void;
error(error: any): void;
completed(): void;
start(): void;
remove(observer: Observer): void;
dispose(): void;
}
}
declare module wdFrp {
class GeneratorSubject extends Entity implements IObserver {
static create(): GeneratorSubject;
private _isStart;
isStart: boolean;
constructor();
observer: any;
onBeforeNext(value: any): void;
onAfterNext(value: any): void;
onIsCompleted(value: any): boolean;
onBeforeError(error: any): void;
onAfterError(error: any): void;
onBeforeCompleted(): void;
onAfterCompleted(): void;
subscribe(arg1?: Function | Observer, onError?: Function, onCompleted?: Function): IDisposable;
next(value: any): void;
error(error: any): void;
completed(): void;
toStream(): any;
start(): void;
stop(): void;
remove(observer: Observer): void;
dispose(): void;
}
}
declare module wdFrp {
class AnonymousObserver extends Observer {
static create(onNext: Function, onError: Function, onCompleted: Function): AnonymousObserver;
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class AutoDetachObserver extends Observer {
static create(observer: IObserver): any;
static create(onNext: Function, onError: Function, onCompleted: Function): any;
dispose(): void;
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class MapObserver extends Observer {
static create(currentObserver: IObserver, selector: Function): MapObserver;
private _currentObserver;
private _selector;
constructor(currentObserver: IObserver, selector: Function);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class DoObserver extends Observer {
static create(currentObserver: IObserver, prevObserver: IObserver): DoObserver;
private _currentObserver;
private _prevObserver;
constructor(currentObserver: IObserver, prevObserver: IObserver);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class MergeAllObserver extends Observer {
static create(currentObserver: IObserver, streamGroup: wdCb.Collection<Stream>, groupDisposable: GroupDisposable): MergeAllObserver;
constructor(currentObserver: IObserver, streamGroup: wdCb.Collection<Stream>, groupDisposable: GroupDisposable);
done: boolean;
currentObserver: IObserver;
private _streamGroup;
private _groupDisposable;
protected onNext(innerSource: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class MergeObserver extends Observer {
static create(currentObserver: IObserver, maxConcurrent: number, streamGroup: wdCb.Collection<Stream>, groupDisposable: GroupDisposable): MergeObserver;
constructor(currentObserver: IObserver, maxConcurrent: number, streamGroup: wdCb.Collection<Stream>, groupDisposable: GroupDisposable);
done: boolean;
currentObserver: IObserver;
activeCount: number;
q: Array<Stream>;
private _maxConcurrent;
private _groupDisposable;
private _streamGroup;
handleSubscribe(innerSource: any): void;
protected onNext(innerSource: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
private _isReachMaxConcurrent();
}
}
declare module wdFrp {
class TakeUntilObserver extends Observer {
static create(prevObserver: IObserver): TakeUntilObserver;
private _prevObserver;
constructor(prevObserver: IObserver);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class SkipUntilSourceObserver extends Observer {
static create(prevObserver: IObserver, skipUntilStream: SkipUntilStream): SkipUntilSourceObserver;
private _prevObserver;
private _skipUntilStream;
constructor(prevObserver: IObserver, skipUntilStream: SkipUntilStream);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class SkipUntilOtherObserver extends Observer {
static create(prevObserver: IObserver, skipUntilStream: SkipUntilStream): SkipUntilOtherObserver;
otherDisposable: IDisposable;
private _prevObserver;
private _skipUntilStream;
constructor(prevObserver: IObserver, skipUntilStream: SkipUntilStream);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class ConcatObserver extends Observer {
static create(currentObserver: IObserver, startNextStream: Function): ConcatObserver;
protected currentObserver: any;
private _startNextStream;
constructor(currentObserver: IObserver, startNextStream: Function);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
interface ISubjectObserver {
addChild(observer: Observer): any;
removeChild(observer: Observer): any;
}
}
declare module wdFrp {
class SubjectObserver implements IObserver {
observers: wdCb.Collection<IObserver>;
private _disposable;
isEmpty(): boolean;
next(value: any): void;
error(error: any): void;
completed(): void;
addChild(observer: Observer): void;
removeChild(observer: Observer): void;
dispose(): void;
setDisposable(disposable: IDisposable): void;
}
}
declare module wdFrp {
class IgnoreElementsObserver extends Observer {
static create(currentObserver: IObserver): IgnoreElementsObserver;
private _currentObserver;
constructor(currentObserver: IObserver);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class FilterObserver extends Observer {
static create(prevObserver: IObserver, predicate: (value: any, index?: number, source?: Stream) => boolean, source: Stream): FilterObserver;
constructor(prevObserver: IObserver, predicate: (value: any) => boolean, source: Stream);
protected prevObserver: IObserver;
protected source: Stream;
protected i: number;
protected predicate: (value: any, index?: number, source?: Stream) => boolean;
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
}
}
declare module wdFrp {
class FilterWithStateObserver extends FilterObserver {
static create(prevObserver: IObserver, predicate: (value: any, index?: number, source?: Stream) => boolean, source: Stream): FilterWithStateObserver;
private _isTrigger;
protected onNext(value: any): void;
}
}
declare module wdFrp {
abstract class BaseStream extends Stream {
abstract subscribeCore(observer: IObserver): IDisposable;
subscribe(arg1: Function | Observer | Subject, onError?: any, onCompleted?: any): IDisposable;
buildStream(observer: IObserver): IDisposable;
}
}
declare module wdFrp {
class DoStream extends BaseStream {
static create(source: Stream, onNext?: Function, onError?: Function, onCompleted?: Function): DoStream;
private _source;
private _observer;
constructor(source: Stream, onNext: Function, onError: Function, onCompleted: Function);
subscribeCore(observer: IObserver): IDisposable;
}
}
declare module wdFrp {
class MapStream extends BaseStream {
static create(source: Stream, selector: Function): MapStream;
private _source;
private _selector;
constructor(source: Stream, selector: Function);
subscribeCore(observer: IObserver): IDisposable;
}
}
declare module wdFrp {
class FromArrayStream extends BaseStream {
static create(array: Array<any>, scheduler: Scheduler): FromArrayStream;
private _array;
constructor(array: Array<any>, scheduler: Scheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class FromPromiseStream extends BaseStream {
static create(promise: any, scheduler: Scheduler): FromPromiseStream;
private _promise;
constructor(promise: any, scheduler: Scheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class FromEventPatternStream extends BaseStream {
static create(addHandler: Function, removeHandler: Function): FromEventPatternStream;
private _addHandler;
private _removeHandler;
constructor(addHandler: Function, removeHandler: Function);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class AnonymousStream extends Stream {
static create(subscribeFunc: Function): AnonymousStream;
constructor(subscribeFunc: Function);
subscribe(subject: Subject): IDisposable;
subscribe(observer: IObserver): IDisposable;
subscribe(onNext: (value: any) => void): IDisposable;
subscribe(onNext: (value: any) => void, onError: (e: any) => void): IDisposable;
subscribe(onNext: (value: any) => void, onError: (e: any) => void, onComplete: () => void): IDisposable;
}
}
declare module wdFrp {
class IntervalStream extends BaseStream {
static create(interval: number, scheduler: Scheduler): IntervalStream;
private _interval;
constructor(interval: number, scheduler: Scheduler);
initWhenCreate(): void;
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class IntervalRequestStream extends BaseStream {
static create(scheduler: Scheduler): IntervalRequestStream;
private _isEnd;
constructor(scheduler: Scheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class TimeoutStream extends BaseStream {
static create(time: number, scheduler: Scheduler): TimeoutStream;
private _time;
constructor(time: number, scheduler: Scheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
declare module wdFrp {
class MergeAllStream extends BaseStream {
static create(source: Stream): MergeAllStream;
constructor(source: Stream);
private _source;
private _observer;
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class MergeStream extends BaseStream {
static create(source: Stream, maxConcurrent: number): MergeStream;
constructor(source: Stream, maxConcurrent: number);
private _source;
private _maxConcurrent;
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class TakeUntilStream extends BaseStream {
static create(source: Stream, otherSteam: Stream): TakeUntilStream;
private _source;
private _otherStream;
constructor(source: Stream, otherStream: Stream);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class SkipUntilStream extends BaseStream {
static create(source: Stream, otherSteam: Stream): SkipUntilStream;
isOpen: boolean;
private _source;
private _otherStream;
constructor(source: Stream, otherStream: Stream);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class ConcatStream extends BaseStream {
static create(sources: Array<Stream>): ConcatStream;
private _sources;
constructor(sources: Array<Stream>);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class RepeatStream extends BaseStream {
static create(source: Stream, count: number): RepeatStream;
private _source;
private _count;
constructor(source: Stream, count: number);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class IgnoreElementsStream extends BaseStream {
static create(source: Stream): IgnoreElementsStream;
private _source;
constructor(source: Stream);
subscribeCore(observer: IObserver): IDisposable;
}
}
declare module wdFrp {
class DeferStream extends BaseStream {
static create(buildStreamFunc: Function): DeferStream;
private _buildStreamFunc;
constructor(buildStreamFunc: Function);
subscribeCore(observer: IObserver): GroupDisposable;
}
}
declare module wdFrp {
class FilterStream extends BaseStream {
static create(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): FilterStream;
constructor(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any);
predicate: (value: any, index?: number, source?: Stream) => boolean;
private _source;
subscribeCore(observer: IObserver): IDisposable;
internalFilter(predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): Stream;
protected createObserver(observer: IObserver): Observer;
protected createStreamForInternalFilter(source: Stream, innerPredicate: any, thisArg: any): Stream;
private _innerPredicate(predicate, self);
}
}
declare module wdFrp {
class FilterWithStateStream extends FilterStream {
static create(source: Stream, predicate: (value: any, index?: number, source?: Stream) => boolean, thisArg: any): FilterWithStateStream;
protected createObserver(observer: IObserver): FilterWithStateObserver;
protected createStreamForInternalFilter(source: Stream, innerPredicate: any, thisArg: any): Stream;
}
}
declare module wdFrp {
var createStream: (subscribeFunc: any) => AnonymousStream;
var fromArray: (array: any[], scheduler?: Scheduler) => FromArrayStream;
var fromPromise: (promise: any, scheduler?: Scheduler) => FromPromiseStream;
var fromEventPattern: (addHandler: Function, removeHandler: Function) => FromEventPatternStream;
var interval: (interval: any, scheduler?: Scheduler) => IntervalStream;
var intervalRequest: (scheduler?: Scheduler) => IntervalRequestStream;
var timeout: (time: any, scheduler?: Scheduler) => TimeoutStream;
var empty: () => AnonymousStream;
var callFunc: (func: Function, context?: any) => AnonymousStream;
var judge: (condition: Function, thenSource: Function, elseSource: Function) => any;
var defer: (buildStreamFunc: Function) => DeferStream;
var just: (returnValue: any) => AnonymousStream;
}
declare module wdFrp {
enum FilterState {
TRIGGER = 0,
ENTER = 1,
LEAVE = 2,
}
}
declare module wdFrp {
class Record {
static create(time: number, value: any, actionType?: ActionType, comparer?: Function): Record;
private _time;
time: number;
private _value;
value: number;
private _actionType;
actionType: ActionType;
private _comparer;
constructor(time: any, value: any, actionType: ActionType, comparer: Function);
equals(other: any): any;
}
}
declare module wdFrp {
class MockObserver extends Observer {
static create(scheduler: TestScheduler): MockObserver;
private _messages;
messages: [Record];
private _scheduler;
constructor(scheduler: TestScheduler);
protected onNext(value: any): void;
protected onError(error: any): void;
protected onCompleted(): void;
dispose(): void;
clone(): MockObserver;
}
}
declare module wdFrp {
class MockPromise {
static create(scheduler: TestScheduler, messages: [Record]): MockPromise;
private _messages;
private _scheduler;
constructor(scheduler: TestScheduler, messages: [Record]);
then(successCb: Function, errorCb: Function, observer: IObserver): void;
}
}
declare module wdFrp {
class TestScheduler extends Scheduler {
static next(tick: any, value: any): Record;
static error(tick: any, error: any): Record;
static completed(tick: any): Record;
static create(isReset?: boolean): TestScheduler;
constructor(isReset: boolean);
private _clock;
clock: number;
private _isReset;
private _isDisposed;
private _timerMap;
private _streamMap;
private _subscribedTime;
private _disposedTime;
private _observer;
setStreamMap(observer: IObserver, messages: [Record]): void;
remove(observer: Observer): void;
publishRecursive(observer: MockObserver, initial: any, recursiveFunc: Function): void;
publishInterval(observer: IObserver, initial: any, interval: number, action: Function): number;
publishIntervalRequest(observer: IObserver, action: Function): number;
publishTimeout(observer: IObserver, time: number, action: Function): number;
private _setClock();
startWithTime(create: Function, subscribedTime: number, disposedTime: number): MockObserver;
startWithSubscribe(create: any, subscribedTime?: number): MockObserver;
startWithDispose(create: any, disposedTime?: number): MockObserver;
publicAbsolute(time: any, handler: any): void;
start(): void;
createStream(args: any): TestStream;
createObserver(): MockObserver;
createResolvedPromise(time: number, value: any): MockPromise;
createRejectPromise(time: number, error: any): MockPromise;
private _getMinAndMaxTime();
private _exec(time, map);
private _runStream(time);
private _runAt(time, callback);
private _tick(time);
}
}
declare module wdFrp {
enum ActionType {
NEXT = 0,
ERROR = 1,
COMPLETED = 2,
}
}
declare module wdFrp {
class TestStream extends BaseStream {
static create(messages: [Record], scheduler: TestScheduler): TestStream;
scheduler: TestScheduler;
private _messages;
constructor(messages: [Record], scheduler: TestScheduler);
subscribeCore(observer: IObserver): SingleDisposable;
}
}
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
]
}