Files
GetiyoSimpleAIVisual/user/ts/ModuleClientApi.d.ts
2025-04-30 18:58:08 +02:00

1324 lines
35 KiB
TypeScript

//============================================================ M C A ============================================================
declare const ModuleApi: any;
interface ModuleClientApi {
//Basis info & communication
GameLib: GameLib;
/**Get the current module id. */
getModuleID: getModuleID;
/**Get the current server time. */
getTime: getTime;
/**Send a packet to the server. */
send: send;
/**Register a listener for incoming server message. */
on: on;
//Updates
/**Register a listener for a property update. */
onPropertyUpdate: onPropertyUpdate;
/**Register a listener for when when module resizes. */
onResize: onResize;
/**Register a listener for the when user details are changed. */
onUserDetailsChange: onuserdetailschange;
/**Adds a listener for the play state change. */
onPlayStateChange: onplaystatechange;
/**Adds a listener for volume change.*/
onVolumeChange: onvolumechange;
/**Adds a listener for when audable audio playback is allowed. */
onAudioAllowed: onaudioallowed;
/**Adds a listener for when the storage was restored from a snapshot.
* @deprecated For better name continuity replaced by 'onSnapshotRestore'
*/
onRuntimeStorageRestored: onruntimestoragerestored;
/**Register a listener that will be called when a snapshot is recalled and the runtime storage is restored. */
onSnapshotRestore: onsnapshotrestore;
/**Register a listener that will be called before a snapshot is taken, this makes it possible to add variable to the storage before the snapshot happens. */
onSnapshotCreate: onsnapshotcreate;
/**Get the variable storage object. */
getRuntimeStorage: getruntimestorage;
/** Get the current volume of the renderer. */
getVolume: getvolume;
/** Get the current volume of the renderer. */
getPlayState: getplaystate;
//Properties
/**Get one ore more module neighbors */
getNeighbors: getNeighbors;
/**Register a listener for incoming neighbor message. */
onNeighborMessage: onNeighborMessage;
//DOM & Renderer
/**Get the DOM container of the current element. */
dom: dom;
//User object
/**Get the current user object. */
getUser: getUser;
/**Get the resolution of the current scene. */
getResolution: getResolution;
//Conditions
/**Finish a client condition. */
finishClientCondition: finishClientCondition;
//PAGE
/**Redirect to a different webpage. */
redirect: redirect;
//Info
/**Check if the module is running in the editor. */
isInEditor: isInEditor;
/**Get the scene id. */
getSceneID: getSceneID;
/**Get the display id. */
getDisplayID: getDisplayID;
}
// -------------- Basis info & communication --------------
interface getModuleID {
/**
* Get the current module id.
* @returns {string} The current module id
*/
(): string;
}
interface getTime {
/**
* Get the current server time.
* @returns {number} Server timestamp
*/
(): number;
}
interface send {
/**
* Send a packet to the server.
* @param {string} header The header of the packet.
* @param {...any} args Additional data to add to the packet.
*/
(header: string, ...args: any): void;
}
interface on {
/**
* Register a listener for incoming server messages.
* @param {string} header The header to listen for.
* @param {Function} callback Callback will be called with the additional data as parameters when a message is received.
*/
(header: string, callback: on_callback): void;
}
interface on_callback {
/**
* Callback for when a packet is received
* @param {...any} args Additional data in the same order as when it was send.
*/
(...args: any): void;
}
// -------------- Updates --------------
interface onPropertyUpdate {
/**
* Register a listener for a property update.
* @param {string} property The key of the property to listen for.
* @param {Function} callback Callback will be called with the changed value when an update is received.
*/
(property: string, callback: onPropertyUpdate_callback): void;
}
interface onPropertyUpdate_callback {
/**
* Callback for when the property updates.
* @param {any} value The changed value of the property
*/
(value: any): void;
}
interface onResize {
/**
* Register a listener for when when module resizes.
* @param {Function} callback Callback will be called when the module resizes.
*/
(callback: onResize_callback): void;
}
interface onResize_callback {
/**
* Callback for when the module resizes.
*/
(value: any): void;
}
// -------------- Neighbors --------------
interface getNeighbors {
/**
/* Get one ore more module neighbors
* @param {moduleId?: string; moduleType?: string; moduleTypes?: string[];} filter Options to filter neighbors
*/
(filter?: {
moduleId?: string;
moduleType?: string;
moduleTypes?: string[];
}): ModuleNeighborsResults;
}
interface onNeighborMessage {
/**
* Register a listener for incoming neighbor messages.
* @param {string} header The header to listen for.
* @param {Function} callback Callback will be called with the additional data as parameters when a message is received.
*/
(header: string, callback: onNeighborMessage_callback): void;
}
interface onNeighborMessage_callback {
/**
* Callback for when a packet is received
* @param {ModuleNeighbor} neighbor The neighbor that send the message.
* @param {...any} args Additional data in the same order as when it was send.
*/
(neighbor: ModuleNeighbor, ...args: any): void;
}
interface onuserdetailschange {
/**
* Register a listener for the when user details are changed.
* @param {Function} callback Callback will be called with the user details change.
*/
(callback: onuserdetailschange_callback): void;
}
interface onuserdetailschange_callback {
/**
* Callback for the user details are changed.
*/
(value: any): void;
}
interface onplaystatechange {
/**
* Adds a listener for the play state change.
* @param {Function} callback Callback will be called with the new state.
*/
(callback: onplaystatechange_callback): void;
}
interface onplaystatechange_callback {
/**
* Callback for the play state has changed.
*/
(state: 'playing' | 'paused' | 'loading'): void;
}
interface onvolumechange {
/**
* Adds a listener for volume change.
* @param {Function} callback Callback will be called with the new volume.
*/
(callback: onvolumechange_callback): void;
}
interface onvolumechange_callback {
/**
* Callback with the new volume. Volume is a number between 0 and 1.
*/
(volume: number): void;
}
interface onaudioallowed {
/**
* Adds a listener for when audable audio playback is allowed.
* @param {Function} callback Callback will be called when audable audio playback is allowed.
*/
(callback: onaudioallowed_callback): void;
}
interface onaudioallowed_callback {
/**
* Audable audio playback is allowed.
*/
(): void;
}
interface onruntimestoragerestored {
/**
* @deprecated For better name continuity replaced by 'onSnapshotRestore'
* Adds a listener for when the storage was restored from a snapshot.
* @param {Function} callback Callback will be called when a snapshot is restored.
*/
(callback: onruntimestoragerestored_callback): void;
}
interface onruntimestoragerestored_callback {
/**
* Snapshot is restored
*/
(): void;
}
interface onsnapshotrestore {
/**
* Register a listener that will be called when a snapshot is recalled and the runtime storage is restored.
* @param {Function} callback Callback will be called when a snapshot is restored.
*/
(callback: onsnapshotrestore_callback): void;
}
interface onsnapshotrestore_callback {
/**
* Snapshot is restored
*/
(): void;
}
interface onsnapshotcreate {
/**
* Register a listener that will be called before a snapshot is taken, this makes it possible to add variable to the storage before the snapshot happens.
* @param {Function} callback Callback will be called before the snapshot is created.
*/
(callback: onsnapshotcreate_callback): void;
}
interface onsnapshotcreate_callback {
/**
* Snapshot is about to be created
*/
(): void;
}
interface getruntimestorage {
/**
/* Get the variable storage object.
* @return {ModuleRuntimeStorage} Storage object
*/
(): ModuleRuntimeStorage;
}
interface getvolume {
/**
/* Get the current volume of the renderer
* @return {number} Volume (between 0 and 1)
*/
(): number;
}
interface getplaystate {
/**
/* Get the current play state of the renderer
* @return {"playing"|"paused"|"loading"} Current play sate
*/
(): 'playing' | 'paused' | 'loading';
}
// -------------- Properties --------------
// interface getProperties {
// (callback: getProperties_callback): void;
// }
// interface getProperties_callback {
// (properties: getProperties_callback_propertylist): void;
// }
// interface getProperties_callback_propertylist {
// [property: string]: string;
// }
// interface getProperty {
// (property: getProperty_callback): void;
// }
// interface getProperty_callback {
// (value: any): any;
// }
// interface setProperty {
// (property: string, value: any): void;
// }
// -------------- DOM & Renderer --------------
interface dom {
/**
* Get the DOM container of the current element.
* @returns {HTMLDivElement} Module DOM
*/
(): HTMLDivElement;
}
interface getResolution {
/**
* Get the resolution of the current scene.
* @returns Resolution {width:number, height:number}
*/
(): getResolution_Resolution | null;
}
interface getResolution_Resolution {
/** The width of the current scene*/
width: number;
/** The height of the current scene*/
height: number;
}
// -------------- User object --------------
interface getUser {
/**
* Get the current user object.
* @returns {User} User Object
*/
(): User;
}
// -------------- Conditions --------------
interface finishClientCondition {
/**
* Finish a client condition.
* @param {string} condition The condition id. This is the same as the key for this condition in the module.json.
*/
(condition: string): void;
}
// -------------- Page --------------
interface redirect {
/**
* Check if the module is running in the editor.
* @param {string} address The address of the webpage.
* @param {string} target Optional - The address of the webpage.
*/
(address: string, target: 'self' | 'blank' | 'parent'): void;
}
// -------------- Info --------------
interface isInEditor {
/**
* Check if the module is running in the editor.
* @returns {boolean} Running is editor
*/
(): boolean;
}
interface getSceneID {
/**
* Get the scene id.
* @returns {string} The current scene id
*/
(): string | null;
}
interface getDisplayID {
/**
* Get the display id.
* @returns {string} The current display id
*/
(): string | null;
}
// ============================================================ N E I G H B O R S ============================================================
interface ModuleNeighborsResults {
/**
* Amount of neighbors in the result.
*/
length: number;
[index: number]: ModuleNeighbor;
/**
* Send a packet to all neighbors in the result result.
* @param {string} header The header of the message
* @param {...any} args Data to send
*/
sendToAll(header: string, ...args: any): void;
/**
* @description Loop trough all neighbors in this result.
* @param {(neighbor:ModuleNeighbor) => void} callback
*/
forEach(callback: (neighbor: ModuleNeighbor) => void): void;
/**
* @description Get all neighbors in this result.
* @returns {ModuleNeighbor[]} neighbors
*/
getAll(): ModuleNeighbor[];
/**
* @description Get a neighbors in this result.
* @param {number} index The index of the neighbor in this result.
* @returns {ModuleNeighbor} neighbor
*/
get(index: number): ModuleNeighbor[];
/**
* @description Get the first neighbors in this result.
* @returns {ModuleNeighbor} neighbor
*/
first(): ModuleNeighbor[];
/**
* @description Get the last neighbors in this result.
* @returns {ModuleNeighbor} neighbor
*/
last(): ModuleNeighbor[];
}
interface ModuleNeighbor {
/**
* The type of the module.
*/
moduleType: string;
/**
* The id of the module.
*/
moduleId: string;
/**
* Send a packet to this neighbor.
* @param {string} header The header of the message
* @param {...any} args Data to send
*/
send(header: string, ...args: any): void;
}
// ============================================================ U S E R ============================================================
interface User {
getID: User_getId;
getName: User_getName;
setName: User_setName;
hasName: User_hasName;
getOrganization: User_getOrganization;
hasOrganization: User_hasOrganization;
getCameraID: User_getCameraID;
hasCameraID: User_hasCameraID;
getMicrophoneID: User_getMicrophoneID;
hasMicrophoneID: User_hasMicrophoneID;
changeDetails: User_changeDetails;
onChangeDetails: User_onChangeDetails;
isMobile: User_isMobile;
isMobileOrTablet: User_isMobileOrTablet;
}
interface User_getId {
/**
* Get the user id.
* @returns {string} The current user id
*/
(): string | null;
}
interface User_getName {
/**
* Get the user name.
* @param {Function} callback Show a popup when a user has not entered their name and receive the name via the callback.
* @returns {string} Name if the user (Only if callback is undefined)
*/
(callback?: User_getName_callback): string;
}
interface User_getName_callback {
/**
* Callback with the user name.
* @param {string} name The name of the user.
*/
(name: string): void;
}
interface User_setName {
/**
* Set the user name.
* @param {string} name The new name of the user.
*/
(name: string): void;
}
interface User_hasName {
/**
* Check if the user has a name.
* @returns {boolean} User has name
*/
(): boolean;
}
interface User_getOrganization {
/**
* Get the user organization.
* @param {Function} callback Show a popup when a user has not entered their organization and receive the organization via the callback.
* @returns {string} Orgianization if the user (Only if callback is undefined)
*/
(callback?: User_getOrganization_callback): string | null;
}
interface User_getOrganization_callback {
/**
* Callback with the organizatiom name.
* @param {string} organizatiom The organizatiom of the user.
*/
(organizatiom: string): void;
}
interface User_hasOrganization {
/**
* Check if the user has a organization.
* @returns {boolean} User has organization
*/
(): boolean;
}
interface User_getCameraID {
/**
* Get the user camera ID.
* @returns {string} User camera ID
*/
(): string | null;
}
interface User_hasCameraID {
/**
* Check if the user has a camera ID configured.
* @returns {boolean} User has camera ID
*/
(): boolean;
}
interface User_getMicrophoneID {
/**
* Get the user microphone ID.
* @returns {string} User microphone ID
*/
(): string | null;
}
interface User_hasMicrophoneID {
/**
* Check if the user has a microphone ID configured.
* @returns {boolean} User has microphone ID
*/
(): boolean;
}
interface User_changeDetails {
/**
* Shows the user details change dialog the the user.
* @param {Function} callback Callback for when the user finishes editing their details.
*/
(callback: User_changeDetails_callback): void;
}
interface User_changeDetails_callback {
/**Callback for when the user finishes editing their details. */
(): void;
}
interface User_onChangeDetails {
/**
* Catch and prevent the default behavior of the change details dialog.
* @param {Function} callback Callback will be called when the the change dialog is requested.
*/
(callback: User_onChangeDetails_callback): void;
}
interface User_onChangeDetails_callback {
/**
* Callback will be called when the the change dialog is requested.
*/
(): void;
}
interface User_isMobile {
/**
* Check if the user is on mobile.
* @returns {boolean} User is mobile
*/
(): boolean;
}
interface User_isMobileOrTablet {
/**
* Check if the user is on mobile or tablet.
* @returns {boolean} User is mobile or tablet
*/
(): boolean;
}
// ============================================================ G A M E L I B ============================================================
interface GameLib {
Timing: ModuleGameTiming;
newController: GameLib_newController;
}
interface GameLib_newController {
/**
* Create a new controller.
* @param {string} roomId Id of the room.
* @param {string} controllerId Id of the controller.
*/
(roomId: string, controllerId: string): Controller;
}
// ============================================================ Game Timing ============================================================
interface ModuleGameTiming {
toTimeSpan: ModuleGameTimings_toTimeSpan;
toFrameCycle: ModuleGameTimings_toFrameCycle;
getCurrentFrameIndex: ModuleGameTimings_getCurrentFrameIndex;
getFrameIndexAtTimestamp: ModuleGameTimings_getFrameIndexAtTimestamp;
getCurrentTimeSpanRatio: ModuleGameTimings_getCurrentTimeSpanRatio;
getTimeSpanRatioAtTimestamp: ModuleGameTimings_getTimeSpanRatioAtTimestamp;
toRatio: ModuleGameTimings_toRatio;
}
interface ModuleGameTimings_toTimeSpan {
/**Creates a timespan object.
* @param {number} duration The duration of the timespan in milliseconds.
* @param {number} startTimestamp (Optional) The start timestamp of the timespan in milliseconds.
* @returns {TimeSpan} The timespan object.
*/
(duration: number, startTimestamp?: number): TimeSpan;
}
interface ModuleGameTimings_toFrameCycle {
/**Creates a frame cycle object.
* @param {number} startTimestamp The start timestamp of the frame cycle in milliseconds.
* @param {number} frameInterval The interval between frames in milliseconds.
* @param {number} totalFrames The total number of frames in the cycle.
* @param {number} startFrame (Optional) The start frame of the cycle.
* @returns {FrameCycle} The frame cycle object.
*/
(
startTimestamp: number,
frameInterval: number,
totalFrames: number,
startFrame?: number
): TimeSpan;
}
interface ModuleGameTimings_getCurrentFrameIndex {
/**Gets the current frame index of the frame cycle.
* @param {FrameCycle} cycle The frame cycle object.
* @returns {number} The current frame index.
*/
(cycle: FrameCycle): number;
}
interface ModuleGameTimings_getFrameIndexAtTimestamp {
/**Gets the frame index at the given timestamp.
* @param {FrameCycle} cycle The frame cycle object.
* @param {number} timestamp The timestamp to get the frame index at.
* @returns {number} The frame index at the given timestamp.
*/
(cycle: FrameCycle, timestamp: number): number;
}
interface ModuleGameTimings_getCurrentTimeSpanRatio {
/**Gets the ratio of the current time span.
* @param {TimeSpan} span The timespan object.
* @returns {Ratio} The ratio of the current time span.
*/
(span: TimeSpan): Ratio;
}
interface ModuleGameTimings_getTimeSpanRatioAtTimestamp {
/**Gets the ratio of the time span at the given timestamp.
* @param {TimeSpan} span The timespan object.
* @param {number} timestamp The timestamp to get the ratio at.
* @returns {Ratio} The ratio of the time span at the given timestamp.
*/
(span: TimeSpan, timestamp: number): Ratio;
}
interface ModuleGameTimings_toRatio {
/**Creates a ratio object.
* @param {number} value The value of the ratio.
* @returns {Ratio} The ratio object.
*/
(value: number): Ratio;
}
interface TimeSpan {
startTimestamp: number;
endTimestamp: number;
}
interface FrameCycle {
startTimestamp: number;
frameInterval: number;
totalFrames: number;
startFrame?: number;
}
// ============================================================ Game Timing Ratio ============================================================
interface Ratio extends Number {
easeInSine: Ratio_easeInSine;
easeInCubic: Ratio_easeInCubic;
easeInQuint: Ratio_easeInQuint;
easeInCirc: Ratio_easeInCirc;
easeInElastic: Ratio_easeInElastic;
easeOutSine: Ratio_easeOutSine;
easeOutCubic: Ratio_easeOutCubic;
easeOutQuint: Ratio_easeOutQuint;
easeOutCirc: Ratio_easeOutCirc;
easeOutElastic: Ratio_easeOutElastic;
easeInOutSine: Ratio_easeInOutSine;
easeInOutCubic: Ratio_easeInOutCubic;
easeInOutQuint: Ratio_easeInOutQuint;
easeInOutCirc: Ratio_easeInOutCirc;
easeInOutElastic: Ratio_easeInOutElastic;
easeInQuad: Ratio_easeInQuad;
easeInQuart: Ratio_easeInQuart;
easeInExpo: Ratio_easeInExpo;
easeInBack: Ratio_easeInBack;
easeInBounce: Ratio_easeInBounce;
easeOutQuad: Ratio_easeOutQuad;
easeOutQuart: Ratio_easeOutQuart;
easeOutExpo: Ratio_easeOutExpo;
easeOutBack: Ratio_easeOutBack;
easeOutBounce: Ratio_easeOutBounce;
easeInOutQuad: Ratio_easeInOutQuad;
easeInOutQuart: Ratio_easeInOutQuart;
easeInOutExpo: Ratio_easeInOutExpo;
easeInOutBack: Ratio_easeInOutBack;
easeInOutBounce: Ratio_easeInOutBounce;
bezier: Ratio_bezier;
invert: Ratio_invert;
steps: Ratio_steps;
toAbsolute: Ratio_toAbsolute;
toPercentage: Ratio_toPercentage;
}
interface Ratio_easeInSine {
/**Calculate the ratio with the ease-in-sine easing function.
* https://easings.net/#easeInSine
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInCubic {
/**Calculate the ratio with the ease-in-cubic easing function.
* https://easings.net/#easeInCubic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInQuint {
/**Calculate the ratio with the ease-in-quint easing function.
* https://easings.net/#easeInQuint
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInCirc {
/**Calculate the ratio with the ease-in-circ easing function.
* https://easings.net/#easeInCirc
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInElastic {
/**Calculate the ratio with the ease-in-elastic easing function.
* https://easings.net/#easeInElastic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutSine {
/**Calculate the ratio with the ease-out-sine easing function.
* https://easings.net/#easeOutSine
*
* To view overview of all easing functions: https://easings.net
* @param {Ratio} ratio The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutCubic {
/**Calculate the ratio with the ease-out-cubic easing function.
* https://easings.net/#easeOutCubic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutQuint {
/**Calculate the ratio with the ease-out-quint easing function.
* https://easings.net/#easeOutQuint
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutCirc {
/**Calculate the ratio with the ease-out-circ easing function.
* https://easings.net/#easeOutCirc
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutElastic {
/**Calculate the ratio with the ease-out-elastic easing function.
* https://easings.net/#easeOutElastic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutSine {
/**Calculate the ratio with the ease-in-out-sine easing function.
* https://easings.net/#easeInOutSine
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutCubic {
/**Calculate the ratio with the ease-in-out-cubic easing function.
* https://easings.net/#easeInOutCubic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutQuint {
/**Calculate the ratio with the ease-in-out-quint easing function.
* https://easings.net/#easeInOutQuint
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutCirc {
/**Calculate the ratio with the ease-in-out-circ easing function.
* https://easings.net/#easeInOutCirc
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutElastic {
/**Calculate the ratio with the ease-in-out-elastic easing function.
* https://easings.net/#easeInOutElastic
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInQuad {
/**Calculate the ratio with the ease-in-quad easing function.
* https://easings.net/#easeInQuad
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInQuart {
/**Calculate the ratio with the ease-in-quart easing function.
* https://easings.net/#easeInQuart
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInExpo {
/**Calculate the ratio with the ease-in-expo easing function.
* https://easings.net/#easeInExpo
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInBack {
/**Calculate the ratio with the ease-in-back easing function.
* https://easings.net/#easeInBack
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInBounce {
/**Calculate the ratio with the ease-in-bounce easing function.
* https://easings.net/#easeInBounce
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutQuad {
/**Calculate the ratio with the ease-out-quad easing function.
* https://easings.net/#easeOutQuad
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutQuart {
/**Calculate the ratio with the ease-out-quart easing function.
* https://easings.net/#easeOutQuart
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutExpo {
/**Calculate the ratio with the ease-out-expo easing function.
* https://easings.net/#easeOutExpo
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutBack {
/**Calculate the ratio with the ease-out-back easing function.
* https://easings.net/#easeOutBack
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeOutBounce {
/**Calculate the ratio with the ease-out-bounce easing function.
* https://easings.net/#easeOutBounce
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutQuad {
/**Calculate the ratio with the ease-in-out-quad easing function.
* https://easings.net/#easeInOutQuad
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutQuart {
/**Calculate the ratio with the ease-in-out-quart easing function.
* https://easings.net/#easeInOutQuart
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutExpo {
/**Calculate the ratio with the ease-in-out-expo easing function.
* https://easings.net/#easeInOutExpo
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutBack {
/**Calculate the ratio with the ease-in-out-back easing function.
* https://easings.net/#easeInOutBack
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_easeInOutBounce {
/**Calculate the ratio with the ease-in-out-bounce easing function.
* https://easings.net/#easeInOutBounce
*
* To view overview of all easing functions: https://easings.net
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_bezier {
/**Calculate the ratio with the bezier curve easing function.
*
* To generate a bezier curve easing visually you can use tools like: https://cubic-bezier.com
* @param {number} x1 The x coordinate of the first control point.
* @param {number} y1 The y coordinate of the first control point.
* @param {number} x2 The x coordinate of the second control point.
* @param {number} y2 The y coordinate of the second control point.
* @returns {Ratio} The new ratio.
*/
(x1: number, y1: number, x2: number, y2: number): Ratio;
}
interface Ratio_invert {
/**Invert the ratio.
* @returns {Ratio} The new ratio.
*/
(): Ratio;
}
interface Ratio_steps {
/**Calculate the ratio with the steps easing function.
* @param {number} steps The number of steps.
* @returns {Ratio} The new ratio.
*/
(steps: number): Ratio;
}
interface Ratio_toAbsolute {
/**Calculate the ratio of an absolute value.
* @returns {number} The calculated value.
*/
(total: number): number;
}
interface Ratio_toPercentage {
/**Convert the ratio to a percentage.
* @returns {number} The calculated percentage.
*/
(): number;
}
// ============================================================ C O N T R O L L E R ============================================================
interface Controller {
readonly roomId: string;
readonly controllerId: string;
call: Controller_call;
callCustom: Controller_callCustom;
joinQueue: Controller_joinQueue;
on: Controller_on;
}
interface Controller_call {
/**
* Call a button press.
* @param {Controller_call_actions} action The action to send.
* @param {string} mode The mode of the button press.
* @param {number} [intensity] The intensity of the button press (between 0 and 1).
*/
(
action: Controller_call_actions,
mode: 'on' | 'off',
intensity?: number
): void;
}
type Controller_call_actions =
| 'left'
| 'right'
| 'up'
| 'down'
| 'upleft'
| 'upright'
| 'downleft'
| 'downright'
| 'start'
| 'select'
| 'back'
| 'identify';
interface Controller_callCustom {
/**
* call a button press.
* @param {string} action The action to send.
* @param {string} mode The mode of the button press.
* @param {number} [intensity] The intensity of the button press (between 0 and 1).
*/
(action: string, mode: 'on' | 'off', intensity?: number): void;
}
interface Controller_joinQueue {
/**
* Join the room queue
*/
(): void;
}
interface Controller_on {
/**
* Register a listener for controller events.
* @param {ControllerEvents} events The events to listen for.
* @param {Function} listener The listener to call when the event is triggered.
*/
<U extends keyof ControllerEvents>(
events: U,
listener: ControllerEvents[U]
): void;
}
interface ControllerEvents {
outsideRoom: () => void;
insideGame: () => void;
insideQueue: () => void;
endScreen: (endScreen: GameRoomEndScreen) => void;
queuePositionUpdate: (position: number) => void;
activeGameChanged: (gameDetails: GameDetails) => void;
}
interface GameRoomEndScreen {
gameIcon: string;
gameName: string;
title: string;
text?: string;
stats?: { name: string; value: number | string }[];
footer?: string;
}
interface GameDetails {
name: string;
description: string;
hints: string[];
controls: GameDetails_Controls;
icon?: string;
}
type GameDetails_Controls = GameDetails_Control[];
type GameDetails_Control =
| GameDetails_ControlNormalBinary
| GameDetails_ControlCustomBinary
| GameDetails_ControlNormalAnalog
| GameDetails_ControlCustomAnalog;
interface GameDetails_ControlBase {
type: 'normal' | 'custom';
mode: 'binary' | 'analog';
}
interface GameDetails_ControlNormalBinary extends GameDetails_ControlBase {
type: 'normal';
action: Controller_call_actions;
mode: 'binary';
}
interface GameDetails_ControlCustomBinary extends GameDetails_ControlBase {
type: 'custom';
action: string;
mode: 'binary';
}
interface GameDetails_ControlNormalAnalog extends GameDetails_ControlBase {
type: 'normal';
action: Controller_call_actions;
mode: 'analog';
steps?: number;
}
interface GameDetails_ControlCustomAnalog extends GameDetails_ControlBase {
type: 'custom';
action: string;
mode: 'analog';
steps?: number;
}
// ============================================================ R U N T I M E S T O R A G E ============================================================
//-
interface ModuleRuntimeStorage {
/**
* @readonly
* Unix timestamp when the last snapshot was made.
*/
_lastSnapshot: number;
/**
* @readonly
* List of all variable keys inside the storage.
*/
_keys: string[];
/**
* @readonly
* The amount of variables inside the storage.
*/
_size: number;
/**
* Using the storage without an interface will work but is not generally advised. Please extent storage interfaca with an interface containing specific properties.
* @author Mees van der Wijk
* @deprecated
*/
[key: string]: any;
}
interface HTMLElement {
// /**Set the classList of the current element but return the current element. */
// class<T extends HTMLElement>(this: T, classList: string | string[]): T;
// /**Set the innerText of the current element but return the current element. */
// txt<T extends HTMLElement>(this: T, innerText: string): T;
// /**Set the innerHtml of the current element but return the current element. */
// html<T extends HTMLElement>(this: T, innerHtml: string): T;
// /**Set the attributes of the current element but return the current element. */
// attr<T extends HTMLElement>(
// this: T,
// attributes: { [key: string]: string }
// ): T;
// /**Set the style of the current element but return the current element. */
// style<T extends HTMLElement>(
// this: T,
// style: Partial<Record<keyof CSSStyleDeclaration, string>>
// ): T;
/**Add an element to the current element but return the current element. */
addChild<T extends HTMLElement>(this: T, child: HTMLElement): T;
/** Scale the current element to the biggest possible size without overflowing. */
scale: () => void;
}
declare const CHANNEL: string;
declare const ID: string;
declare const DISPLAY: string;
declare const Feedback: {
isOpen: boolean;
notification: (
type: 'info' | 'succes' | 'error' | 'warn',
message: string
) => void;
dialog: (
text: string,
inputType: string,
defaultValue: string,
required: boolean,
callback: () => void
) => void;
confirm: (text: string, callback: (result: boolean) => void) => void;
alert: (text: string, callback: () => void) => void;
};
declare const ce: <K extends keyof HTMLElementTagNameMap>(
tagName: K,
classList?: string | string[],
attributes?: { [key: string]: string },
innerText?: string,
innerHTML?: string,
style?: Partial<Record<keyof CSSStyleDeclaration, string>>
) => HTMLElementTagNameMap[K];
declare const loading: (zIndexLevel: number) => void;
declare const hideLoading: () => void;