mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Merge remote-tracking branch 'DefinitelyTyped/master'
This commit is contained in:
@@ -55,18 +55,23 @@ Before you share your improvement with the world, use it yourself.
|
||||
#### Test editing an exiting package
|
||||
|
||||
To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html).
|
||||
You can also directly edit the types in `node_modules/@types/foo/index.d.ts`,
|
||||
or copy them from there and paste inside of `declarations.d.ts` and follow the steps below.
|
||||
You can also directly edit the types in `node_modules/@types/foo/index.d.ts`, or copy them from there and follow the steps below.
|
||||
|
||||
|
||||
#### Test a new package
|
||||
|
||||
* Add a new file `declarations.d.ts` to your project.
|
||||
* Add it to the compilation, through `"includes"` or `"files"` in your [tsconfig](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html),
|
||||
or through a `/// <reference path="" />` declaration in your code.
|
||||
* Inside `declarations.d.ts`, write `declare module "foo" { }`, then write the module declaration inside.
|
||||
* Test that your code works.
|
||||
* *Then*, once you've tested your definitions, make a PR contributing the definition.
|
||||
Add to your `tsconfig.json`:
|
||||
|
||||
```json
|
||||
"baseUrl": "types",
|
||||
"typeRoots": ["types"],
|
||||
```
|
||||
|
||||
(You can also use `src/types`.)
|
||||
Create `types/foo/index.d.ts` containing declarations for the module "foo".
|
||||
You should now be able import from `"foo"` in your code and it will route to the new type definition.
|
||||
Then build *and* run the code to make sure your type definition actually corresponds to what happens at runtime.
|
||||
Once you've tested your definitions with real code, make a PR contributing the definition by copying `types/foo` to `DefinitelyTyped/foo` and adding a `tsconfig.json` and `foo-tests.ts`.
|
||||
|
||||
|
||||
### Make a pull request
|
||||
|
||||
Vendored
+170
@@ -0,0 +1,170 @@
|
||||
// Type definitions for math3.d.ts
|
||||
// Project: https://github.com/adragonite/math3d
|
||||
// Definitions by: Laszlo Jakab <https://github.com/laszlojakab>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "math3d" {
|
||||
export class Vector3 {
|
||||
constructor(x?: number, y?: number, z?: number);
|
||||
|
||||
public static back: Vector3;
|
||||
public static down: Vector3;
|
||||
public static forward: Vector3;
|
||||
public static left: Vector3;
|
||||
public static one: Vector3;
|
||||
public static right: Vector3;
|
||||
public static up: Vector3;
|
||||
public static zero: Vector3;
|
||||
public static dimension: number;
|
||||
public static FromVector4: (vector4: Vector4) => Vector3;
|
||||
|
||||
public homogeneous: Vector4;
|
||||
public magnitude: number;
|
||||
public values: number[];
|
||||
public vector4: Vector4;
|
||||
public x: number;
|
||||
public y: number;
|
||||
public z: number;
|
||||
|
||||
public add(vector3: Vector3): Vector3;
|
||||
public average(vector3: Vector3): Vector3;
|
||||
public cross(vector3: Vector3): Vector3;
|
||||
public distanceTo(vector3: Vector3): number;
|
||||
public dot(vector3: Vector3): number;
|
||||
public equals(vector3: Vector3): boolean;
|
||||
public mulScalar(scalar: Number): Vector3;
|
||||
public negate(): Vector3;
|
||||
public normalize(): Vector3;
|
||||
public scale(vector3: Vector3): Vector3;
|
||||
public sub(vector3: Vector3): Vector3;
|
||||
public toString(): string;
|
||||
}
|
||||
|
||||
export class Vector4 {
|
||||
constructor(x?: number, y?: number, z?: number, w?: number);
|
||||
|
||||
public static one: Vector4;
|
||||
public static zero: Vector4;
|
||||
public static dimension: number;
|
||||
|
||||
public magnitude: number;
|
||||
public values: number[];
|
||||
public x: number;
|
||||
public y: number;
|
||||
public z: number;
|
||||
public w: number;
|
||||
|
||||
public add(vector4: Vector4): Vector4;
|
||||
public distanceTo(vector4: Vector4): number;
|
||||
public dot(vector4: Vector4): number;
|
||||
public equals(vector4: Vector4): boolean;
|
||||
public mulScalar(scalar: Number): Vector4;
|
||||
public negate(): Vector4;
|
||||
public normalize(): Vector3;
|
||||
public sub(vector4: Vector4): Vector3;
|
||||
public toString(): string;
|
||||
}
|
||||
|
||||
export class Quaternion {
|
||||
constructor(x?: number, y?: number, z?: number, w?: number);
|
||||
public static Euler(x?: number, y?: number, z?: number): Quaternion;
|
||||
public static AngleAxis(axis: Vector3, angle: number): Quaternion;
|
||||
|
||||
public static identity: Quaternion;
|
||||
public static zero: Quaternion;
|
||||
|
||||
public angleAxis: { axis: Vector3, angle: number };
|
||||
public eulerAngles: { x: number, y: number, z: number };
|
||||
public x: number;
|
||||
public y: number;
|
||||
public z: number;
|
||||
public w: number;
|
||||
|
||||
public angleTo(quaternion: Quaternion): number;
|
||||
public conjugate(): Quaternion;
|
||||
public distanceTo(quaternion: Quaternion): number;
|
||||
public dot(quaternion: Quaternion): number;
|
||||
public equals(quaternion: Quaternion): boolean;
|
||||
public inverse(): Quaternion;
|
||||
public mul(quaternion: Quaternion): Quaternion;
|
||||
public mulVector3(vector3: Vector3): Vector3;
|
||||
public toString(): string;
|
||||
}
|
||||
|
||||
export class Matrix4x4 {
|
||||
constructor(data: number[]);
|
||||
|
||||
public static FlipMatrix(flipX: boolean, flipY: boolean, flipZ: boolean): Matrix4x4;
|
||||
public static ScaleMatrix(scale: number | Vector3): Matrix4x4;
|
||||
public static RotationMatrix(quaternion: Quaternion): Matrix4x4;
|
||||
public static TranslationMatrix(translation: Vector3): Matrix4x4;
|
||||
public static TRS(translation: Vector3, rotation: Quaternion, scale: number | Vector3): Matrix4x4;
|
||||
public static LocalToWorldMatrix(position: Vector3, rotation: Quaternion, scale: number | Vector3): Matrix4x4;
|
||||
public static WorldToLocalMatrix(position: Vector3, rotation: Quaternion, scale: number | Vector3): Matrix4x4;
|
||||
|
||||
public static identity: Matrix4x4;
|
||||
public static zero: Matrix4x4;
|
||||
|
||||
public columns: number[][];
|
||||
public m11: number;
|
||||
public m12: number;
|
||||
public m13: number;
|
||||
public m14: number;
|
||||
public m21: number;
|
||||
public m22: number;
|
||||
public m23: number;
|
||||
public m24: number;
|
||||
public m31: number;
|
||||
public m32: number;
|
||||
public m33: number;
|
||||
public m34: number;
|
||||
public m41: number;
|
||||
public m42: number;
|
||||
public m43: number;
|
||||
public m44: number;
|
||||
public rows: number[][];
|
||||
public size: { rows: number, columns: number };
|
||||
public values: number[];
|
||||
|
||||
public determinant(): number
|
||||
public inverse(): Matrix4x4;
|
||||
public negate(): Matrix4x4;
|
||||
public transpose(): Matrix4x4;
|
||||
public add(matrix4x4: Matrix4x4): Matrix4x4;
|
||||
public sub(matrix4x4: Matrix4x4): Matrix4x4;
|
||||
public mul(matrix4x4: Matrix4x4): Matrix4x4;
|
||||
public mulScalar(scalar: Number): Matrix4x4;
|
||||
public mulVector3(vector3: Vector3): Vector3;
|
||||
}
|
||||
|
||||
export class Transform {
|
||||
constructor(position?: Vector3, rotation?: Quaternion);
|
||||
|
||||
public forward: Vector3;
|
||||
public localPosition: Vector3;
|
||||
public localRotation: Quaternion;
|
||||
public localToWorldMatrix: Matrix4x4;
|
||||
public name: string;
|
||||
public parent: Transform;
|
||||
public position: Vector3;
|
||||
public right: Vector3;
|
||||
public root: Transform;
|
||||
public rotation: Vector3;
|
||||
public up: Vector3;
|
||||
public worldToLocalMatrix: Matrix4x4;
|
||||
|
||||
public addChild(child: Transform): void;
|
||||
public inverseTransformPosition(position: Vector3): Vector3;
|
||||
public removeChild(child: Transform): void;
|
||||
public transformPosition(position: Vector3): Vector3;
|
||||
public translate(translation: Vector3, relativeTo?: Transform.Space): Transform;
|
||||
public rotate(x: number, y: number, z: number, relativeTo?: Transform.Space): Transform;
|
||||
}
|
||||
|
||||
export module Transform {
|
||||
export enum Space {
|
||||
Self,
|
||||
World
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/// <reference path="./plugapi.d.ts" />
|
||||
|
||||
import * as PlugAPI from "plugapi";
|
||||
|
||||
new PlugAPI({
|
||||
email: "",
|
||||
password: ""
|
||||
}, function (err, bot) {
|
||||
if (!err) {
|
||||
const ROOM = "roomslug";
|
||||
bot.connect(ROOM); // The part after https://plug.dj
|
||||
|
||||
bot.on(PlugAPI.events.ROOM_JOIN, function (room) {
|
||||
console.log("Joined " + room);
|
||||
});
|
||||
|
||||
bot.on("chat", function (data) {
|
||||
if (data.type == "emote") {
|
||||
console.log(data.from + data.message);
|
||||
} else {
|
||||
console.log(data.from + "> " + data.message);
|
||||
}
|
||||
});
|
||||
|
||||
bot.on("error", function () {
|
||||
bot.connect(ROOM);
|
||||
});
|
||||
|
||||
bot.deleteAllChat = false;
|
||||
bot.multiLine = true;
|
||||
bot.multiLineLimit = 5;
|
||||
} else {
|
||||
console.log("Error initializing plugAPI: " + err);
|
||||
}
|
||||
});
|
||||
Vendored
+420
@@ -0,0 +1,420 @@
|
||||
// Type definitions for plugapi
|
||||
// Project: https://www.npmjs.com/package/plugapi
|
||||
// Definitions by: Brice Theurillat <https://github.com/BNedry/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "plugapi" {
|
||||
interface PlugLogin {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
interface Notification {
|
||||
action: string;
|
||||
id: number;
|
||||
timestamp: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
interface RawChatMessage {
|
||||
cid: string;
|
||||
message: string;
|
||||
sub: number;
|
||||
uid: number;
|
||||
un: string;
|
||||
}
|
||||
|
||||
interface Media {
|
||||
author: string;
|
||||
format: number;
|
||||
image: string;
|
||||
cid: string;
|
||||
duration: number;
|
||||
title: string;
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface Score {
|
||||
positive: number;
|
||||
listeners: number;
|
||||
grabs: number;
|
||||
negative: number;
|
||||
skipped: number;
|
||||
}
|
||||
|
||||
interface LastPlay {
|
||||
dj: User.DJ;
|
||||
media: Media;
|
||||
score: Score;
|
||||
}
|
||||
|
||||
interface FollowJoinData {
|
||||
r: number;
|
||||
un: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface LogObject {
|
||||
log: () => void;
|
||||
}
|
||||
|
||||
namespace User {
|
||||
interface Default {
|
||||
username: string;
|
||||
language: string;
|
||||
avatarID: string;
|
||||
}
|
||||
|
||||
interface Extended extends Default {
|
||||
status: number;
|
||||
fans: number;
|
||||
listenerPoints: number;
|
||||
id: string;
|
||||
curatorPoints: number;
|
||||
djPoints: number;
|
||||
}
|
||||
|
||||
interface Update extends Extended {
|
||||
dateJoined: string;
|
||||
}
|
||||
|
||||
interface Room extends Default {
|
||||
sub: number;
|
||||
level: number;
|
||||
joined: string;
|
||||
id: number;
|
||||
badge: string;
|
||||
role: number;
|
||||
gRole: number;
|
||||
slug: string;
|
||||
}
|
||||
|
||||
interface User extends Room {
|
||||
silver: boolean;
|
||||
guest: boolean;
|
||||
}
|
||||
|
||||
interface DJ extends Room {
|
||||
blurp: any;
|
||||
grab: boolean;
|
||||
status: number;
|
||||
vote: number;
|
||||
}
|
||||
|
||||
interface Audience extends DJ {
|
||||
ignores: any[];
|
||||
notifications: Notification[];
|
||||
pp: number;
|
||||
pw: number;
|
||||
xp: number;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Enum {
|
||||
interface RoomRole {
|
||||
NONE: number;
|
||||
RESIDENTDJ: number;
|
||||
BOUNCER: number;
|
||||
MANAGER: number;
|
||||
COHOST: number;
|
||||
HOST: number;
|
||||
}
|
||||
|
||||
interface GlobalRole {
|
||||
NONE: number;
|
||||
VOLUNTEER: number;
|
||||
AMBASSADOR: number;
|
||||
LEADER: number;
|
||||
ADMIN: number;
|
||||
}
|
||||
|
||||
interface Status {
|
||||
OFFLINE: number;
|
||||
ONLINE: number;
|
||||
}
|
||||
|
||||
interface Ban {
|
||||
HOUR: "h";
|
||||
DAY: "d";
|
||||
PERMA: "f";
|
||||
}
|
||||
|
||||
interface BanReason {
|
||||
SPAMMING_TROLLING: number;
|
||||
VERBAL_ABUSE: number;
|
||||
OFFENSIVE_MEDIA: number;
|
||||
INAPPROPRIATE_GENRE: number;
|
||||
NEGATIVE_ATTITUDE: number;
|
||||
}
|
||||
|
||||
interface Mute {
|
||||
SHORT: "s";
|
||||
MEDIUM: "m";
|
||||
LONG: "l";
|
||||
}
|
||||
|
||||
interface MuteReason {
|
||||
VIOLATING_COMMUNITY_RULES: number;
|
||||
VERBAL_ABUSE: number;
|
||||
SPAMMING_TROLLING: number;
|
||||
OFFENSIVE_LANGUAGE: number;
|
||||
NEGATIVE_ATTITUDE: number;
|
||||
}
|
||||
|
||||
interface Events {
|
||||
ADVANCE: "advance";
|
||||
BAN: "ban";
|
||||
BOOTH_LOCKED: "boothLocked";
|
||||
CHAT: "chat";
|
||||
CHAT_COMMAND: "command";
|
||||
CHAT_DELETE: "chatDelete";
|
||||
CHAT_LEVEL_UPDATE: "roomMinChatLevelUpdate";
|
||||
COMMAND: "command";
|
||||
DJ_LIST_CYCLE: "djListCycle";
|
||||
DJ_LIST_UPDATE: "djListUpdate";
|
||||
DJ_LIST_LOCKED: "djListLocked";
|
||||
EARN: "earn";
|
||||
FOLLOW_JOIN: "followJoin";
|
||||
FLOOD_CHAT: "floodChat";
|
||||
FRIEND_REQUEST: "friendRequest";
|
||||
GIFTED: "gifted";
|
||||
GRAB: "grab";
|
||||
KILL_SESSION: "killSession";
|
||||
MAINT_MODE: "plugMaintenance";
|
||||
MAINT_MODE_ALERT: "plugMaintenanceAlert";
|
||||
MODERATE_ADD_DJ: "modAddDJ";
|
||||
MODERATE_ADD_WAITLIST: "modAddWaitList";
|
||||
MODERATE_AMBASSADOR: "modAmbassador";
|
||||
MODERATE_BAN: "modBan";
|
||||
MODERATE_MOVE_DJ: "modMoveDJ";
|
||||
MODERATE_MUTE: "modMute";
|
||||
MODERATE_REMOVE_DJ: "modRemoveDJ";
|
||||
MODERATE_REMOVE_WAITLIST: "modRemoveWaitList";
|
||||
MODERATE_SKIP: "modSkip";
|
||||
MODERATE_STAFF: "modStaff";
|
||||
NOTIFY: "notify";
|
||||
PDJ_MESSAGE: "pdjMessage";
|
||||
PDJ_UPDATE: "pdjUpdate";
|
||||
PING: "ping";
|
||||
PLAYLIST_CYCLE: "playlistCycle";
|
||||
REQUEST_DURATION: "requestDuration";
|
||||
REQUEST_DURATION_RETRY: "requestDurationRetry";
|
||||
ROOM_CHANGE: "roomChanged";
|
||||
ROOM_DESCRIPTION_UPDATE: "roomDescriptionUpdate";
|
||||
ROOM_JOIN: "roomJoin";
|
||||
ROOM_NAME_UPDATE: "roomNameUpdate";
|
||||
ROOM_VOTE_SKIP: "roomVoteSkip";
|
||||
ROOM_WELCOME_UPDATE: "roomWelcomeUpdate";
|
||||
SESSION_CLOSE: "sessionClose";
|
||||
SKIP: "skip";
|
||||
STROBE_TOGGLE: "strobeToggle";
|
||||
USER_COUNTER_UPDATE: "userCounterUpdate";
|
||||
USER_FOLLOW: "userFollow";
|
||||
USER_JOIN: "userJoin";
|
||||
USER_LEAVE: "userLeave";
|
||||
USER_UPDATE: "userUpdate";
|
||||
VOTE: "vote";
|
||||
}
|
||||
}
|
||||
|
||||
namespace Event {
|
||||
interface BoothCycle {
|
||||
moderator: string;
|
||||
cycle: boolean;
|
||||
}
|
||||
|
||||
interface BoothLocked {
|
||||
m: string;
|
||||
c: boolean;
|
||||
ml: string;
|
||||
f: boolean;
|
||||
}
|
||||
|
||||
interface Chat {
|
||||
raw: RawChatMessage;
|
||||
id: string;
|
||||
from: User.User;
|
||||
message: string;
|
||||
mentions: Array<any>;
|
||||
muted: boolean;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface ChatDelete {
|
||||
mi: number;
|
||||
chatID: string;
|
||||
}
|
||||
|
||||
type Grab = number;
|
||||
|
||||
interface Advance {
|
||||
media: Media;
|
||||
startTime: string;
|
||||
historyID: string;
|
||||
djs: User.DJ[];
|
||||
currentDJ: User.DJ;
|
||||
playlistID: number;
|
||||
lastPlay: LastPlay;
|
||||
}
|
||||
|
||||
interface DJListUpdate {
|
||||
djs: User.DJ[];
|
||||
remove: string;
|
||||
}
|
||||
|
||||
interface Emote {
|
||||
fromID: string;
|
||||
message: string;
|
||||
from: string;
|
||||
type: string;
|
||||
chatID: string;
|
||||
}
|
||||
|
||||
interface FollowJoin {
|
||||
data: FollowJoinData;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface ModAddDJ {
|
||||
moderator: string;
|
||||
username: string;
|
||||
}
|
||||
|
||||
interface ModBan {
|
||||
moderator: string;
|
||||
username: string;
|
||||
duration: number;
|
||||
ref: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
interface ModMoveDJ {
|
||||
moderator: string;
|
||||
index: number;
|
||||
old: number;
|
||||
userID: string;
|
||||
}
|
||||
|
||||
interface ModRemoveDJ {
|
||||
moderator: string;
|
||||
username: string;
|
||||
userID: string;
|
||||
}
|
||||
|
||||
interface ModSkip {
|
||||
mi: number;
|
||||
m: string;
|
||||
}
|
||||
|
||||
interface RoomMinChatLevelUpdate {
|
||||
level: number;
|
||||
id: number;
|
||||
user: User.User;
|
||||
}
|
||||
|
||||
type RoomJoin = string;
|
||||
|
||||
type UserJoin = User.User;
|
||||
|
||||
type UserLeave = User.User;
|
||||
|
||||
interface UserUpdate {
|
||||
username: string;
|
||||
status: number;
|
||||
fans: number;
|
||||
listenerPoints: number;
|
||||
dateJoined: string;
|
||||
language: string;
|
||||
avatarID: string;
|
||||
id: string;
|
||||
curatorPoints: number;
|
||||
djPoints: number;
|
||||
}
|
||||
|
||||
interface Vote {
|
||||
i: number;
|
||||
v: number;
|
||||
}
|
||||
|
||||
interface Command extends Event.Chat {
|
||||
command: string;
|
||||
args: string[];
|
||||
respond: Function;
|
||||
respondTimeout: Function;
|
||||
havePermission: Function;
|
||||
isFrom: Function;
|
||||
}
|
||||
}
|
||||
|
||||
interface PlugAPIInstance {
|
||||
deleteAllChat: boolean;
|
||||
multiLine: boolean;
|
||||
multiLineLimit: number;
|
||||
|
||||
connect(room: string): void;
|
||||
changeDJCycle(enabled: boolean, callback?: () => void): boolean;
|
||||
changeRoom(room: string, callback?: () => void): void;
|
||||
close(): void;
|
||||
getAdmins(): User.Extended[];
|
||||
getAmbassadors(): User.Extended[];
|
||||
getAudience(): User.Audience[];
|
||||
getDJ(): User.DJ;
|
||||
getDJs(): User.DJ[];
|
||||
getHost(): User.Extended;
|
||||
getMedia(): Media;
|
||||
getRoomScore(): Score;
|
||||
getSelf(): User.Audience;
|
||||
getStaff(): User.Extended[];
|
||||
getTimeElapsed(): number;
|
||||
getTimeRemaining(): number;
|
||||
getUser(userID: number): User.DJ;
|
||||
getUsers(): User.DJ[];
|
||||
getWaitList(): User.Extended;
|
||||
getWaitListPosition(userID: number): number;
|
||||
havePermission(userID: number, permission: number, global?: boolean): boolean;
|
||||
joinBooth(callback?: () => void): boolean;
|
||||
leaveBooth(callback?: () => void): boolean;
|
||||
selfSkip(callback?: () => void): boolean;
|
||||
sendChat(msg: string, timeout?: number): void;
|
||||
setLogger(logObject: LogObject): boolean;
|
||||
|
||||
on(event: "boothCycle", callback: (data: Event.BoothCycle) => void): void;
|
||||
on(event: "boothLocked", callback: (data: Event.BoothLocked) => void): void;
|
||||
on(event: "chat", callback: (data: Event.Chat) => void): void;
|
||||
on(event: "chatDelete", callback: (data: Event.ChatDelete) => void): void;
|
||||
on(event: "grab", callback: (data: Event.Grab) => void): void;
|
||||
on(event: "advance", callback: (data: Event.Advance) => void): void;
|
||||
on(event: "djListUpdate", callback: (data: Event.DJListUpdate) => void): void;
|
||||
on(event: "emote", callback: (data: Event.Emote) => void): void;
|
||||
on(event: "followJoin", callback: (data: Event.FollowJoin) => void): void;
|
||||
on(event: "modAddDJ", callback: (data: Event.ModAddDJ) => void): void;
|
||||
on(event: "modBan", callback: (data: Event.ModBan) => void): void;
|
||||
on(event: "modMoveDJ", callback: (data: Event.ModMoveDJ) => void): void;
|
||||
on(event: "modRemoveDJ", callback: (data: Event.ModRemoveDJ) => void): void;
|
||||
on(event: "modSkip", callback: (data: Event.ModSkip) => void): void;
|
||||
on(event: "roomMinChatLevelUpdate", callback: (data: Event.RoomMinChatLevelUpdate) => void): void;
|
||||
on(event: "roomJoin", callback: (data: Event.RoomJoin) => void): void;
|
||||
on(event: "userJoin", callback: (data: Event.UserJoin) => void): void;
|
||||
on(event: "userLeave", callback: (data: Event.UserLeave) => void): void;
|
||||
on(event: "userUpdate", callback: (data: Event.UserUpdate) => void): void;
|
||||
on(event: "vote", callback: (data: Event.Vote) => void): void;
|
||||
on(event: "command", callback: (data: Event.Command) => void): void;
|
||||
on(event: string, callback: (data: any) => void): void;
|
||||
}
|
||||
|
||||
interface PlugAPIStatic {
|
||||
new (login: PlugLogin, callback?: (error: Error, bot: PlugAPIInstance) => void): PlugAPIInstance;
|
||||
new (login: PlugLogin, callback?: (bot: PlugAPIInstance) => void): PlugAPIInstance;
|
||||
ROOM_ROLE: Enum.RoomRole;
|
||||
GLOBAL_ROLES: Enum.GlobalRole;
|
||||
STATUS: Enum.Status;
|
||||
BAN: Enum.Ban;
|
||||
BAN_REASON: Enum.BanReason;
|
||||
MUTE: Enum.Mute;
|
||||
MUTE_REASON: Enum.MuteReason;
|
||||
events: Enum.Events;
|
||||
}
|
||||
|
||||
var PlugAPI: PlugAPIStatic;
|
||||
export = PlugAPI;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path="./random-seed.d.ts" />
|
||||
import { RandomSeed, create } from "random-seed";
|
||||
|
||||
// these generators produce different numbers
|
||||
let rand1: RandomSeed = create(); // method 1
|
||||
|
||||
// these generators will produce
|
||||
// the same sequence of numbers
|
||||
let seed = 'My Secret String Value';
|
||||
let rand2 = create(seed);
|
||||
|
||||
// API
|
||||
rand1.addEntropy();
|
||||
rand1.random();
|
||||
rand1.range(100);
|
||||
rand1.intBetween(0, 10);
|
||||
rand1.floatBetween(0, 1);
|
||||
rand1.seed("new seed");
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// Type definitions for random-seed 0.3.0
|
||||
// Project: https://github.com/skratchdot/random-seed/
|
||||
// Definitions by: Endel Dreyer <https://github.com/endel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "random-seed" {
|
||||
|
||||
export interface RandomSeed {
|
||||
range (range: number): number;
|
||||
random (): number;
|
||||
floatBetween (min: number, max: number): number;
|
||||
intBetween (min: number, max: number): number;
|
||||
|
||||
string (count: number): string;
|
||||
seed (seed: string): void;
|
||||
|
||||
cleanString (inStr: string): string;
|
||||
hashString (inStr: string): string;
|
||||
|
||||
addEntropy (...args: any[]): void;
|
||||
initState (): void;
|
||||
|
||||
done (): void;
|
||||
}
|
||||
|
||||
export function create (seed?: string): RandomSeed;
|
||||
|
||||
}
|
||||
@@ -1,313 +0,0 @@
|
||||
///<reference path="react-dnd.d.ts" />
|
||||
///<reference path="react-dnd-html5-backend.d.ts" />
|
||||
///<reference path="react-dnd-test-backend.d.ts" />
|
||||
"use strict";
|
||||
|
||||
// Test adapted from the ReactDnD chess game tutorial:
|
||||
// http://gaearon.github.io/react-dnd/docs-tutorial.html
|
||||
|
||||
import React = require("react");
|
||||
import ReactDnd = require("react-dnd");
|
||||
|
||||
var r = React.DOM;
|
||||
|
||||
import DragSource = ReactDnd.DragSource;
|
||||
import DropTarget = ReactDnd.DropTarget;
|
||||
import DragLayer = ReactDnd.DragLayer;
|
||||
import DragDropContext = ReactDnd.DragDropContext;
|
||||
import HTML5Backend, { getEmptyImage, NativeTypes } from "react-dnd-html5-backend";
|
||||
import TestBackend from "react-dnd-test-backend";
|
||||
|
||||
// Game Component
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace Game {
|
||||
var knightPosition = [0, 0];
|
||||
var observer: any = null;
|
||||
|
||||
function emitChange() {
|
||||
observer(knightPosition);
|
||||
}
|
||||
|
||||
export function observe(o: any) {
|
||||
if (observer) {
|
||||
throw new Error("Multiple observers not implemented.");
|
||||
}
|
||||
|
||||
observer = o;
|
||||
emitChange();
|
||||
}
|
||||
|
||||
export function moveKnight(toX: number, toY: number) {
|
||||
knightPosition = [toX, toY];
|
||||
emitChange();
|
||||
}
|
||||
|
||||
export function canMoveKnight(toX: number, toY: number) {
|
||||
const x = knightPosition[0];
|
||||
const y = knightPosition[1];
|
||||
const dx = toX - x;
|
||||
const dy = toY - y;
|
||||
|
||||
return (Math.abs(dx) === 2 && Math.abs(dy) === 1) ||
|
||||
(Math.abs(dx) === 1 && Math.abs(dy) === 2);
|
||||
}
|
||||
}
|
||||
|
||||
var ItemTypes = {
|
||||
KNIGHT: "knight"
|
||||
};
|
||||
|
||||
// Knight Component
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace Knight {
|
||||
interface KnightP extends React.Props<Knight> {
|
||||
connectDragSource: ReactDnd.ConnectDragSource;
|
||||
connectDragPreview: ReactDnd.ConnectDragPreview;
|
||||
isDragging: boolean;
|
||||
}
|
||||
|
||||
var knightSource: ReactDnd.DragSourceSpec<KnightP> = {
|
||||
beginDrag: (props) => {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
function knightCollect(connect: ReactDnd.DragSourceConnector, monitor: ReactDnd.DragSourceMonitor) {
|
||||
return {
|
||||
connectDragSource: connect.dragSource(),
|
||||
connectDragPreview: connect.dragPreview(),
|
||||
isDragging: monitor.isDragging()
|
||||
};
|
||||
}
|
||||
|
||||
@DragSource(ItemTypes.KNIGHT, knightSource, knightCollect)
|
||||
export class Knight extends React.Component<KnightP, {}> {
|
||||
static defaultProps: KnightP;
|
||||
|
||||
static create = React.createFactory(Knight);
|
||||
|
||||
componentDidMount() {
|
||||
var img = getEmptyImage();
|
||||
img.onload = () => this.props.connectDragPreview(img);
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.props.connectDragSource(
|
||||
r.div({
|
||||
style: {
|
||||
opacity: this.props.isDragging ? 0.5 : 1,
|
||||
fontSize: 25,
|
||||
fontWeight: 'bold',
|
||||
cursor: 'move'
|
||||
}
|
||||
}, "♘")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export var create = React.createFactory(Knight);
|
||||
}
|
||||
|
||||
// Square Component
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace Square {
|
||||
interface SquareP extends React.Props<Square> {
|
||||
black: boolean;
|
||||
}
|
||||
|
||||
export class Square extends React.Component<SquareP, {}> {
|
||||
render() {
|
||||
var fill = this.props.black ? 'black' : 'white';
|
||||
return r.div({
|
||||
style: {
|
||||
backgroundColor: fill
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export var create = React.createFactory(Square);
|
||||
}
|
||||
|
||||
// BoardSquare Component
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace BoardSquare {
|
||||
interface BoardSquareP extends React.Props<BoardSquare> {
|
||||
x: number;
|
||||
y: number;
|
||||
connectDropTarget?: ReactDnd.ConnectDropTarget;
|
||||
isOver?: boolean;
|
||||
canDrop?: boolean;
|
||||
}
|
||||
|
||||
var boardSquareTarget: ReactDnd.DropTargetSpec<BoardSquareP> = {
|
||||
canDrop: (props) => Game.canMoveKnight(props.x, props.y),
|
||||
drop: (props) => Game.moveKnight(props.x, props.y)
|
||||
};
|
||||
|
||||
function boardSquareCollect(connect: ReactDnd.DropTargetConnector, monitor: ReactDnd.DropTargetMonitor) {
|
||||
return {
|
||||
connectDropTarget: connect.dropTarget(),
|
||||
isOver: monitor.isOver(),
|
||||
canDrop: monitor.canDrop()
|
||||
};
|
||||
}
|
||||
|
||||
@DropTarget(ItemTypes.KNIGHT, boardSquareTarget, boardSquareCollect)
|
||||
@DropTarget(NativeTypes.FILE, boardSquareTarget, boardSquareCollect)
|
||||
export class BoardSquare extends React.Component<BoardSquareP, {}> {
|
||||
static defaultProps: BoardSquareP;
|
||||
|
||||
private _renderOverlay = (color: string) => {
|
||||
return r.div({
|
||||
style: {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
zIndex: 1,
|
||||
opacity: 0.5,
|
||||
backgroundColor: color
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
var black = (this.props.x + this.props.y) % 2 === 1;
|
||||
var isOver = this.props.isOver;
|
||||
var canDrop = this.props.canDrop;
|
||||
|
||||
return this.props.connectDropTarget(
|
||||
r.div({
|
||||
style: {
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
height: '100%'
|
||||
},
|
||||
children: [
|
||||
Square.create({
|
||||
black: black
|
||||
}),
|
||||
isOver && !canDrop ? this._renderOverlay('red') : null,
|
||||
!isOver && canDrop ? this._renderOverlay('yellow') : null,
|
||||
isOver && canDrop ? this._renderOverlay('green') : null
|
||||
]
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export var create = React.createFactory(BoardSquare);
|
||||
}
|
||||
|
||||
// Custom Drag Layer Component
|
||||
// ----------------------------------------------------------------------
|
||||
namespace CustomDragLayer {
|
||||
interface CustomDragLayerP extends React.Props<CustomDragLayer> {
|
||||
isDragging?: boolean;
|
||||
item?: Object;
|
||||
}
|
||||
|
||||
function dragLayerCollect(monitor: ReactDnd.DragLayerMonitor) {
|
||||
return {
|
||||
isDragging: monitor.isDragging(),
|
||||
item: monitor.getItem(),
|
||||
};
|
||||
}
|
||||
|
||||
@DragLayer(dragLayerCollect)
|
||||
export class CustomDragLayer extends React.Component<CustomDragLayerP, {}> {
|
||||
render() {
|
||||
return r.div(null, this.props.isDragging ? this.props.item : null);
|
||||
}
|
||||
}
|
||||
|
||||
export var create = React.createFactory(CustomDragLayer);
|
||||
}
|
||||
|
||||
// Board Component
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
namespace Board {
|
||||
interface BoardP extends React.Props<Board> {
|
||||
knightPosition: number[];
|
||||
}
|
||||
|
||||
export class Board extends React.Component<BoardP, {}> {
|
||||
private _renderPiece = (x: number, y: number) => {
|
||||
var knightX = this.props.knightPosition[0];
|
||||
var knightY = this.props.knightPosition[1];
|
||||
return x === knightX && y === knightY ?
|
||||
Knight.create() :
|
||||
null;
|
||||
};
|
||||
|
||||
private _renderSquare = (i: number) => {
|
||||
var x = i % 8;
|
||||
var y = Math.floor(i / 8);
|
||||
|
||||
return r.div({
|
||||
key: i,
|
||||
style: {
|
||||
width: '12.5%',
|
||||
height: '12.5%'
|
||||
}
|
||||
}, BoardSquare.create({
|
||||
x: x,
|
||||
y: y
|
||||
}, this._renderPiece(x, y)));
|
||||
};
|
||||
|
||||
render() {
|
||||
var squares: React.ReactHTMLElement<HTMLDivElement>[] = [];
|
||||
for (let i = 0; i < 64; i++) {
|
||||
squares.push(this._renderSquare(i));
|
||||
}
|
||||
|
||||
return r.div({
|
||||
children: [
|
||||
CustomDragLayer.create(),
|
||||
r.div({
|
||||
style: {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap'
|
||||
},
|
||||
children: squares
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@DragDropContext(HTML5Backend)
|
||||
export class BoardWithHTML5Backend extends Board {
|
||||
|
||||
}
|
||||
|
||||
@DragDropContext(TestBackend)
|
||||
export class BoardWithTestBackend extends Board {
|
||||
|
||||
}
|
||||
|
||||
export var createWithHTMLBackend = React.createFactory(BoardWithHTML5Backend);
|
||||
export var createWithTestBackend = React.createFactory(BoardWithTestBackend);
|
||||
}
|
||||
|
||||
// Render the Board Component
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Board.createWithHTMLBackend({
|
||||
knightPosition: [0, 0]
|
||||
});
|
||||
|
||||
|
||||
Board.createWithTestBackend({
|
||||
knightPosition: [0, 0]
|
||||
});
|
||||
Vendored
+6
-6
@@ -11,13 +11,13 @@ declare module __ReactDnd {
|
||||
// Decorated React Components
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
interface ContextComponent<P, S> extends React.Component<P, S> {
|
||||
class ContextComponent<P, S> extends React.Component<P, S> {
|
||||
getDecoratedComponentInstance(): React.Component<P, S>;
|
||||
// Note: getManager is not yet documented on the React DnD docs.
|
||||
getManager(): any;
|
||||
}
|
||||
|
||||
interface DndComponent<P, S> extends React.Component<P, S> {
|
||||
class DndComponent<P, S> extends React.Component<P, S> {
|
||||
getDecoratedComponentInstance(): React.Component<P, S>;
|
||||
getHandlerId(): Identifier;
|
||||
}
|
||||
@@ -40,23 +40,23 @@ declare module __ReactDnd {
|
||||
spec: DragSourceSpec<P>,
|
||||
collect: DragSourceCollector,
|
||||
options?: DndOptions<P>
|
||||
): <C extends React.ComponentClass<P> | React.StatelessComponent<P>>(componentClass: C) => C & DndComponentClass<P>;
|
||||
): (componentClass: React.ComponentClass<P> | React.StatelessComponent<P>) => DndComponentClass<P>;
|
||||
|
||||
export function DropTarget<P>(
|
||||
types: Identifier | Identifier[] | ((props: P) => Identifier | Identifier[]),
|
||||
spec: DropTargetSpec<P>,
|
||||
collect: DropTargetCollector,
|
||||
options?: DndOptions<P>
|
||||
): <C extends React.ComponentClass<P> | React.StatelessComponent<P>>(componentClass: C) => C & DndComponentClass<P>;
|
||||
): (componentClass: React.ComponentClass<P> | React.StatelessComponent<P>) => DndComponentClass<P>;
|
||||
|
||||
export function DragDropContext<P>(
|
||||
backend: Backend
|
||||
): <C extends React.ComponentClass<P> | React.StatelessComponent<P>>(componentClass: C) => C & ContextComponentClass<P>;
|
||||
): <P>(componentClass: React.ComponentClass<P> | React.StatelessComponent<P>) => ContextComponentClass<P>;
|
||||
|
||||
export function DragLayer<P>(
|
||||
collect: DragLayerCollector,
|
||||
options?: DndOptions<P>
|
||||
): <C extends React.ComponentClass<P> | React.StatelessComponent<P>>(componentClass: C) => C & DndComponentClass<P>;
|
||||
): (componentClass: React.ComponentClass<P> | React.StatelessComponent<P>) => DndComponentClass<P>;
|
||||
|
||||
type DragSourceCollector = (connect: DragSourceConnector, monitor: DragSourceMonitor) => Object;
|
||||
type DropTargetCollector = (connect: DropTargetConnector, monitor: DropTargetMonitor) => Object;
|
||||
|
||||
Vendored
+1
-1
@@ -7490,7 +7490,7 @@ declare namespace __React {
|
||||
key: string;
|
||||
}
|
||||
|
||||
export interface NavigationState extends NavigationRoute {
|
||||
export interface NavigationState {
|
||||
index: number;
|
||||
routes: NavigationRoute[];
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -261,8 +261,8 @@ declare namespace Rx {
|
||||
mergeObservable(): Observable<T>; // alias for mergeAll
|
||||
skipUntil<T2>(other: Observable<T2>): Observable<T>;
|
||||
skipUntil<T2>(other: IPromise<T2>): Observable<T>;
|
||||
switch(): Observable<T>;
|
||||
switchLatest(): Observable<T>; // alias for switch
|
||||
switch(): T;
|
||||
switchLatest(): T; // alias for switch
|
||||
takeUntil<T2>(other: Observable<T2>): Observable<T>;
|
||||
takeUntil<T2>(other: IPromise<T2>): Observable<T>;
|
||||
zip<T2>(second: Observable<T2>|IPromise<T2>): Observable<[T, T2]>;
|
||||
|
||||
Reference in New Issue
Block a user