Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from mixer/init-1
Browse files Browse the repository at this point in the history
Initial thoughts
  • Loading branch information
connor4312 authored Aug 14, 2017
2 parents 7332c0f + 8fb1326 commit 28d0665
Show file tree
Hide file tree
Showing 11 changed files with 935 additions and 83 deletions.
2 changes: 2 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
237 changes: 235 additions & 2 deletions mixer.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,240 @@
declare module 'mixer' {
import { EventEmitter } from 'eventemitter3';

/**
* IControl is some kind of control on the protocol. The controlID is
* unique in the scene.
*
* This is a minimal interface: control types may extend this interface
* and define their own properties.
*/
export interface IControl {
readonly controlID: string;
readonly kind: string;
}

/**
* IScene is a scene on the protocol. It can contain many controls. The
* sceneID is globally unique.
*
* This is a minimal interface: scenes may extend this interface
* and define their own properties.
*/
export interface IScene {
readonly sceneID: string;
readonly controls: IControl[];
}

/**
* IGroup is a groups of participants on the protocol. Groups are assigned
* to a single scene.
*
* This is a minimal interface: integrations may extend this interface
* and define their own properties.
*/
export interface IGroup {
readonly sceneID: string;
readonly groupID: string;
}

/**
* ISceneCreate is an event triggered when a new scene is created.
*/
export interface ISceneCreate {
readonly scenes: IScene[];
}

/**
* ISceneUpdate is an event triggered when a an existing scene is updated.
*/
export interface ISceneUpdate {
readonly scenes: IScene[];
}

/**
* ISceneDelete is an event triggered when a scene is deleted.
*/
export interface ISceneDelete {
readonly sceneID: string;
readonly reassignSceneID: string;
}

/**
* IControlChange is fired when new controls are created, updated, or
* deleted in the scene.
*/
export interface IControlChange {
readonly sceneID: string;
readonly controls: IControl[];
}

/**
* IGroupDelete is an event triggered when a group is deleted.
*/
export interface IGroupDelete {
readonly groupID: string;
readonly reassignGroupID: string;
}

/**
* IGroupCreate is fired when new groups are created.
*/
export interface IGroupCreate {
readonly groups: IGroup[];
}

/**
* IGroupUpdate is fired when groups are updated.
*/
export interface IGroupUpdate {
readonly groups: IGroup[];
}

/**
* IParticipant represents a user in Interactive. As far as controls are
* concerned, this means only the current user.
*
* This is a minimal interface: integrations may extend this interface
* and define their own properties.
*/
export interface IParticipant {
readonly sessionID: string;
readonly userID: number;
readonly username: string;
readonly level: number;
readonly lastInputAt: number; // milliseconds timestamp
readonly connectedAt: number; // milliseconds timestamp
readonly disabled: boolean;
readonly groupID: string;
}

/**
* IParticipantUpdate is fired when the participant's data is updated,
* and once when first connecting.
*/
export interface IParticipantUpdate {
readonly participants: [IParticipant];
}

/**
* IInput is an input event fired on a control. This is a minimal
* interface; custom properties may be added and they will be passed
* through to the game client.
*/
export interface IInput {
controlID: string;
event: string;
}

/**
* IReady is sent when when the integration indicates that it has set up
* and is ready to accept input.
*/
export interface IReady {
readonly isReady: boolean;
}

/**
* Attaches a handler function that will be triggered when the call comes in.
*/
export function on(call: string, data: any): void;
}
export interface Socket extends EventEmitter {
on(event: 'onParticipantJoin', handler: (ev: IParticipantUpdate) => void): this;
on(event: 'onParticipantUpdate', handler: (ev: IParticipantUpdate) => void): this;
on(event: 'onGroupCreate', handler: (ev: IGroupCreate) => void): this;
on(event: 'onGroupDelete', handler: (ev: IGroupDelete) => void): this;
on(event: 'onGroupUpdate', handler: (ev: IGroupUpdate) => void): this;
on(event: 'onSceneCreate', handler: (ev: ISceneCreate) => void): this;
on(event: 'onSceneDelete', handler: (ev: ISceneDelete) => void): this;
on(event: 'onSceneUpdate', handler: (ev: ISceneUpdate) => void): this;
on(event: 'onControlCreate', handler: (ev: IControlChange) => void): this;
on(event: 'onControlDelete', handler: (ev: IControlChange) => void): this;
on(event: 'onControlUpdate', handler: (ev: IControlChange) => void): this;
on(event: 'onReady', handler: (ev: IReady) => void): this;

call(method: 'giveInput', options: IInput): void;
call(method: string, options: object): Promise<object>;
call(method: string, options: object, waitForReply: true): Promise<object>;
call(method: string, options: object, waitForReply: false): void;
}

/**
* IVideoPositionOptions are passed into display.moveVideo() to change
* where the video is shown on the screen.
*/
export interface IVideoPositionOptions {
/**
* Position of the video on screen as a percent (0 - 100) of the screen width.
* If omitted, it's not modified.
*/
x?: number;

/**
* Position of the video on screen as a percent (0 - 100) of the screen height.
* If omitted, it's not modified.
*/
y?: number;

/**
* Width of the video on screen as a percent (0 - 100) of the screen.
* If omitted, it's not modified.
*/
width?: number;

/**
* Height of the video on screen as a percent (0 - 100) of the screen.
* If omitted, it's not modified.
*/
height?: number;

/**
* Duration of the movement easing in milliseconds. Defaults to 0.
*/
duration?: number;

/**
* CSS easing function. Defaults to 'linear'.
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function
*/
easing?: string;
}

/**
* Display modified the display of interactive controls.
*/
export interface Display {
/**
* Hides the controls and displays a loading spinner, optionally
* with a custom message. This is useful for transitioning. If called
* while the controls are already minimized, it will update the message.
*/
minimize(message?: string): void;

/**
* Restores previously minimize()'d controls.
*/
maximize(): void;

/**
* Moves the position of the video on the screen.
*/
moveVideo(options: IVideoPositionOptions): void;
}

/**
* Returns the fully qualified URL to a static project asset, from the
* `src/static` folder.
*/
export function asset(...path: string[]): string;

/**
* IPackageConfig describes the configuration you write in the "interactive"
* section of your package.json. It's injected automatically when your
* controls boot.
*/
export interface IPackageConfig {

}

export const socket: Socket;
export const display: Display;
}
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --content-base build/"
},
"interactive": {
"display": {
"mode": "legacy-grid"
}
},
"author": "Connor Peet <[email protected]>",
"license": "MIT",
"dependencies": {
"decko": "^1.2.0",
"eventemitter3": "^2.0.3",
"preact": "^8.2.1"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 28d0665

Please sign in to comment.