Refactoring and documentation update

This commit is contained in:
Benedicte Quimbert 2021-11-23 17:39:45 +01:00
parent 4356767739
commit 1e073d8a0e
7 changed files with 47 additions and 22 deletions

View file

@ -32,7 +32,7 @@ import { isPlayerPropertyEvent } from "./PlayerPropertyEvent";
import type { ChangeZoneEvent } from "./ChangeZoneEvent";
import { isColorEvent } from "./ColorEvent";
import { isPlayerPosition } from "./PlayerPosition";
import type { HasCameraMovedEvent } from "./HasCameraMovedEvent";
import type { WasCameraUpdatedEvent } from "./WasCameraUpdatedEvent";
export interface TypedMessageEvent<T> extends MessageEvent {
data: T;
@ -53,7 +53,7 @@ export type IframeEventMap = {
displayBubble: null;
removeBubble: null;
onPlayerMove: undefined;
onCameraMove: undefined;
onCameraUpdate: undefined;
showLayer: LayerEvent;
hideLayer: LayerEvent;
setProperty: SetPropertyEvent;
@ -86,7 +86,7 @@ export interface IframeResponseEventMap {
leaveZoneEvent: ChangeZoneEvent;
buttonClickedEvent: ButtonClickedEvent;
hasPlayerMoved: HasPlayerMovedEvent;
hasCameraMoved: HasCameraMovedEvent;
wasCameraUpdated: WasCameraUpdatedEvent;
menuItemClicked: MenuItemClickedEvent;
setVariable: SetVariableEvent;
messageTriggered: MessageReferenceEvent;

View file

@ -1,6 +1,6 @@
import * as tg from "generic-type-guard";
export const isHasCameraMovedEvent = new tg.IsInterface()
export const isWasCameraUpdatedEvent = new tg.IsInterface()
.withProperties({
x: tg.isNumber,
y: tg.isNumber,
@ -13,6 +13,6 @@ export const isHasCameraMovedEvent = new tg.IsInterface()
* A message sent from the game to the iFrame to notify a movement from the camera.
*/
export type HasCameraMovedEvent = tg.GuardedType<typeof isHasCameraMovedEvent>;
export type WasCameraUpdatedEvent = tg.GuardedType<typeof isWasCameraUpdatedEvent>;
export type HasCameraMovedEventCallback = (event: HasCameraMovedEvent) => void;
export type WasCameraUpdatedEventCallback = (event: WasCameraUpdatedEvent) => void;