@workadventure/iframe-api-typings 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Api/Events/ButtonClickedEvent.d.ts +9 -0
- package/Api/Events/ChatEvent.d.ts +9 -0
- package/Api/Events/ClosePopupEvent.d.ts +8 -0
- package/Api/Events/EmbeddedWebsiteEvent.d.ts +39 -0
- package/Api/Events/EnterLeaveEvent.d.ts +8 -0
- package/Api/Events/GameStateEvent.d.ts +14 -0
- package/Api/Events/GoToPageEvent.d.ts +8 -0
- package/Api/Events/HasPlayerMovedEvent.d.ts +12 -0
- package/Api/Events/IframeEvent.d.ts +207 -0
- package/Api/Events/LayerEvent.d.ts +8 -0
- package/Api/Events/LoadPageEvent.d.ts +8 -0
- package/Api/Events/LoadSoundEvent.d.ts +8 -0
- package/Api/Events/LoadTilesetEvent.d.ts +8 -0
- package/Api/Events/MapDataEvent.d.ts +8 -0
- package/Api/Events/OpenCoWebSiteEvent.d.ts +10 -0
- package/Api/Events/OpenPopupEvent.d.ts +14 -0
- package/Api/Events/OpenTabEvent.d.ts +8 -0
- package/Api/Events/PlaySoundEvent.d.ts +17 -0
- package/Api/Events/SetTilesEvent.d.ts +11 -0
- package/Api/Events/SetVariableEvent.d.ts +16 -0
- package/Api/Events/StopSoundEvent.d.ts +8 -0
- package/Api/Events/UserInputChatEvent.d.ts +8 -0
- package/Api/Events/setPropertyEvent.d.ts +10 -0
- package/Api/Events/ui/MenuItemClickedEvent.d.ts +8 -0
- package/Api/Events/ui/MenuRegisterEvent.d.ts +22 -0
- package/Api/Events/ui/TriggerActionMessageEvent.d.ts +15 -0
- package/Api/Events/ui/TriggerMessageEventHandler.d.ts +14 -0
- package/Api/IframeListener.d.ts +138 -0
- package/Api/ScriptUtils.d.ts +10 -0
- package/Api/iframe/IframeApiContribution.d.ts +25 -0
- package/Api/iframe/Room/EmbeddedWebsite.d.ts +17 -0
- package/Api/iframe/Sound/Sound.d.ts +7 -0
- package/Api/iframe/Ui/ActionMessage.d.ts +12 -0
- package/Api/iframe/Ui/ButtonDescriptor.d.ts +16 -0
- package/Api/iframe/Ui/Menu.d.ts +8 -0
- package/Api/iframe/Ui/MenuItem.d.ts +1 -0
- package/Api/iframe/Ui/Popup.d.ts +8 -0
- package/Api/iframe/chat.d.ts +11 -0
- package/Api/iframe/controls.d.ts +8 -0
- package/Api/iframe/nav.d.ts +11 -0
- package/Api/iframe/player.d.ts +14 -0
- package/Api/iframe/registeredCallbacks.d.ts +7 -0
- package/Api/iframe/room.d.ts +27 -0
- package/Api/iframe/sound.d.ts +8 -0
- package/Api/iframe/state.d.ts +14 -0
- package/Api/iframe/ui.d.ts +27 -0
- package/Api/iframe/website.d.ts +11 -0
- package/Api/types.d.ts +3 -0
- package/README.md +27 -0
- package/iframe_api.d.ts +84 -0
- package/iframe_api.js +1 -0
- package/package.json +13 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isButtonClickedEvent: tg.TypeGuard<object & {
|
|
3
|
+
popupId: number;
|
|
4
|
+
buttonId: number;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* A message sent from the game to the iFrame when a user enters or leaves a zone marked with the "zone" property.
|
|
8
|
+
*/
|
|
9
|
+
export declare type ButtonClickedEvent = tg.GuardedType<typeof isButtonClickedEvent>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isChatEvent: tg.TypeGuard<object & {
|
|
3
|
+
message: string;
|
|
4
|
+
author: string;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
8
|
+
*/
|
|
9
|
+
export declare type ChatEvent = tg.GuardedType<typeof isChatEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isClosePopupEvent: tg.TypeGuard<object & {
|
|
3
|
+
popupId: number;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
7
|
+
*/
|
|
8
|
+
export declare type ClosePopupEvent = tg.GuardedType<typeof isClosePopupEvent>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isRectangle: tg.TypeGuard<object & {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const isEmbeddedWebsiteEvent: tg.TypeGuard<object & {
|
|
9
|
+
name: string;
|
|
10
|
+
} & Partial<{
|
|
11
|
+
url: string;
|
|
12
|
+
visible: boolean;
|
|
13
|
+
allowApi: boolean;
|
|
14
|
+
allow: string;
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}>>;
|
|
20
|
+
export declare const isCreateEmbeddedWebsiteEvent: tg.TypeGuard<object & {
|
|
21
|
+
name: string;
|
|
22
|
+
url: string;
|
|
23
|
+
position: object & {
|
|
24
|
+
x: any;
|
|
25
|
+
y: any;
|
|
26
|
+
width: any;
|
|
27
|
+
height: any;
|
|
28
|
+
};
|
|
29
|
+
} & Partial<{
|
|
30
|
+
visible: boolean;
|
|
31
|
+
allowApi: boolean;
|
|
32
|
+
allow: string;
|
|
33
|
+
}>>;
|
|
34
|
+
/**
|
|
35
|
+
* A message sent from the iFrame to the game to modify an embedded website
|
|
36
|
+
*/
|
|
37
|
+
export declare type ModifyEmbeddedWebsiteEvent = tg.GuardedType<typeof isEmbeddedWebsiteEvent>;
|
|
38
|
+
export declare type CreateEmbeddedWebsiteEvent = tg.GuardedType<typeof isCreateEmbeddedWebsiteEvent>;
|
|
39
|
+
export declare type Rectangle = tg.GuardedType<typeof isRectangle>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isEnterLeaveEvent: tg.TypeGuard<object & {
|
|
3
|
+
name: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the game to the iFrame when a user enters or leaves a zone marked with the "zone" property.
|
|
7
|
+
*/
|
|
8
|
+
export declare type EnterLeaveEvent = tg.GuardedType<typeof isEnterLeaveEvent>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isGameStateEvent: tg.TypeGuard<object & {
|
|
3
|
+
roomId: string;
|
|
4
|
+
mapUrl: string;
|
|
5
|
+
nickname: string;
|
|
6
|
+
uuid: string | undefined;
|
|
7
|
+
startLayerName: string | null;
|
|
8
|
+
tags: string[];
|
|
9
|
+
variables: object;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* A message sent from the game to the iFrame when the gameState is received by the script
|
|
13
|
+
*/
|
|
14
|
+
export declare type GameStateEvent = tg.GuardedType<typeof isGameStateEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isGoToPageEvent: tg.TypeGuard<object & {
|
|
3
|
+
url: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
7
|
+
*/
|
|
8
|
+
export declare type GoToPageEvent = tg.GuardedType<typeof isGoToPageEvent>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isHasPlayerMovedEvent: tg.TypeGuard<object & {
|
|
3
|
+
direction: string;
|
|
4
|
+
moving: boolean;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* A message sent from the game to the iFrame to notify a movement from the current player.
|
|
10
|
+
*/
|
|
11
|
+
export declare type HasPlayerMovedEvent = tg.GuardedType<typeof isHasPlayerMovedEvent>;
|
|
12
|
+
export declare type HasPlayerMovedEventCallback = (event: HasPlayerMovedEvent) => void;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
import type { ButtonClickedEvent } from "./ButtonClickedEvent";
|
|
3
|
+
import type { ChatEvent } from "./ChatEvent";
|
|
4
|
+
import type { ClosePopupEvent } from "./ClosePopupEvent";
|
|
5
|
+
import type { EnterLeaveEvent } from "./EnterLeaveEvent";
|
|
6
|
+
import type { GoToPageEvent } from "./GoToPageEvent";
|
|
7
|
+
import type { LoadPageEvent } from "./LoadPageEvent";
|
|
8
|
+
import type { OpenCoWebSiteEvent } from "./OpenCoWebSiteEvent";
|
|
9
|
+
import type { OpenPopupEvent } from "./OpenPopupEvent";
|
|
10
|
+
import type { OpenTabEvent } from "./OpenTabEvent";
|
|
11
|
+
import type { UserInputChatEvent } from "./UserInputChatEvent";
|
|
12
|
+
import type { LayerEvent } from "./LayerEvent";
|
|
13
|
+
import type { SetPropertyEvent } from "./setPropertyEvent";
|
|
14
|
+
import type { LoadSoundEvent } from "./LoadSoundEvent";
|
|
15
|
+
import type { PlaySoundEvent } from "./PlaySoundEvent";
|
|
16
|
+
import type { MenuItemClickedEvent } from "./ui/MenuItemClickedEvent";
|
|
17
|
+
import type { HasPlayerMovedEvent } from "./HasPlayerMovedEvent";
|
|
18
|
+
import type { SetTilesEvent } from "./SetTilesEvent";
|
|
19
|
+
import type { SetVariableEvent } from "./SetVariableEvent";
|
|
20
|
+
import type { EmbeddedWebsite } from "../iframe/Room/EmbeddedWebsite";
|
|
21
|
+
import type { LoadTilesetEvent } from "./LoadTilesetEvent";
|
|
22
|
+
import type { MessageReferenceEvent } from "./ui/TriggerActionMessageEvent";
|
|
23
|
+
import type { MenuRegisterEvent, UnregisterMenuEvent } from "./ui/MenuRegisterEvent";
|
|
24
|
+
export interface TypedMessageEvent<T> extends MessageEvent {
|
|
25
|
+
data: T;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* List event types sent from an iFrame to WorkAdventure
|
|
29
|
+
*/
|
|
30
|
+
export declare type IframeEventMap = {
|
|
31
|
+
loadPage: LoadPageEvent;
|
|
32
|
+
chat: ChatEvent;
|
|
33
|
+
openPopup: OpenPopupEvent;
|
|
34
|
+
closePopup: ClosePopupEvent;
|
|
35
|
+
openTab: OpenTabEvent;
|
|
36
|
+
goToPage: GoToPageEvent;
|
|
37
|
+
openCoWebSite: OpenCoWebSiteEvent;
|
|
38
|
+
closeCoWebSite: null;
|
|
39
|
+
disablePlayerControls: null;
|
|
40
|
+
restorePlayerControls: null;
|
|
41
|
+
displayBubble: null;
|
|
42
|
+
removeBubble: null;
|
|
43
|
+
onPlayerMove: undefined;
|
|
44
|
+
showLayer: LayerEvent;
|
|
45
|
+
hideLayer: LayerEvent;
|
|
46
|
+
setProperty: SetPropertyEvent;
|
|
47
|
+
loadSound: LoadSoundEvent;
|
|
48
|
+
playSound: PlaySoundEvent;
|
|
49
|
+
stopSound: null;
|
|
50
|
+
getState: undefined;
|
|
51
|
+
loadTileset: LoadTilesetEvent;
|
|
52
|
+
registerMenu: MenuRegisterEvent;
|
|
53
|
+
unregisterMenu: UnregisterMenuEvent;
|
|
54
|
+
setTiles: SetTilesEvent;
|
|
55
|
+
modifyEmbeddedWebsite: Partial<EmbeddedWebsite>;
|
|
56
|
+
};
|
|
57
|
+
export interface IframeEvent<T extends keyof IframeEventMap> {
|
|
58
|
+
type: T;
|
|
59
|
+
data: IframeEventMap[T];
|
|
60
|
+
}
|
|
61
|
+
export declare const isIframeEventWrapper: (event: any) => event is IframeEvent<keyof IframeEventMap>;
|
|
62
|
+
export interface IframeResponseEventMap {
|
|
63
|
+
userInputChat: UserInputChatEvent;
|
|
64
|
+
enterEvent: EnterLeaveEvent;
|
|
65
|
+
leaveEvent: EnterLeaveEvent;
|
|
66
|
+
buttonClickedEvent: ButtonClickedEvent;
|
|
67
|
+
hasPlayerMoved: HasPlayerMovedEvent;
|
|
68
|
+
menuItemClicked: MenuItemClickedEvent;
|
|
69
|
+
setVariable: SetVariableEvent;
|
|
70
|
+
messageTriggered: MessageReferenceEvent;
|
|
71
|
+
}
|
|
72
|
+
export interface IframeResponseEvent<T extends keyof IframeResponseEventMap> {
|
|
73
|
+
type: T;
|
|
74
|
+
data: IframeResponseEventMap[T];
|
|
75
|
+
}
|
|
76
|
+
export declare const isIframeResponseEventWrapper: (event: {
|
|
77
|
+
type?: string;
|
|
78
|
+
}) => event is IframeResponseEvent<keyof IframeResponseEventMap>;
|
|
79
|
+
/**
|
|
80
|
+
* List event types sent from an iFrame to WorkAdventure that expect a unique answer from WorkAdventure along the type for the answer from WorkAdventure to the iFrame.
|
|
81
|
+
* Types are defined using Type guards that will actually bused to enforce and check types.
|
|
82
|
+
*/
|
|
83
|
+
export declare const iframeQueryMapTypeGuards: {
|
|
84
|
+
getState: {
|
|
85
|
+
query: tg.TypeGuard<undefined>;
|
|
86
|
+
answer: tg.TypeGuard<object & {
|
|
87
|
+
roomId: string;
|
|
88
|
+
mapUrl: string;
|
|
89
|
+
nickname: string;
|
|
90
|
+
uuid: string | undefined;
|
|
91
|
+
startLayerName: string | null;
|
|
92
|
+
tags: string[];
|
|
93
|
+
variables: object;
|
|
94
|
+
}>;
|
|
95
|
+
};
|
|
96
|
+
getMapData: {
|
|
97
|
+
query: tg.TypeGuard<undefined>;
|
|
98
|
+
answer: tg.TypeGuard<object & {
|
|
99
|
+
data: object;
|
|
100
|
+
}>;
|
|
101
|
+
};
|
|
102
|
+
setVariable: {
|
|
103
|
+
query: tg.TypeGuard<object & {
|
|
104
|
+
key: string;
|
|
105
|
+
value: unknown;
|
|
106
|
+
}>;
|
|
107
|
+
answer: tg.TypeGuard<undefined>;
|
|
108
|
+
};
|
|
109
|
+
loadTileset: {
|
|
110
|
+
query: tg.TypeGuard<object & {
|
|
111
|
+
url: string;
|
|
112
|
+
}>;
|
|
113
|
+
answer: tg.TypeGuard<number>;
|
|
114
|
+
};
|
|
115
|
+
triggerActionMessage: {
|
|
116
|
+
query: tg.TypeGuard<object & {
|
|
117
|
+
message: string;
|
|
118
|
+
uuid: string;
|
|
119
|
+
type: "message" | "warning";
|
|
120
|
+
}>;
|
|
121
|
+
answer: tg.TypeGuard<undefined>;
|
|
122
|
+
};
|
|
123
|
+
removeActionMessage: {
|
|
124
|
+
query: tg.TypeGuard<object & {
|
|
125
|
+
uuid: string;
|
|
126
|
+
}>;
|
|
127
|
+
answer: tg.TypeGuard<undefined>;
|
|
128
|
+
};
|
|
129
|
+
getEmbeddedWebsite: {
|
|
130
|
+
query: tg.TypeGuard<string>;
|
|
131
|
+
answer: tg.TypeGuard<object & {
|
|
132
|
+
name: string;
|
|
133
|
+
url: string;
|
|
134
|
+
position: object & {
|
|
135
|
+
x: any;
|
|
136
|
+
y: any;
|
|
137
|
+
width: any;
|
|
138
|
+
height: any;
|
|
139
|
+
};
|
|
140
|
+
} & Partial<{
|
|
141
|
+
visible: boolean;
|
|
142
|
+
allowApi: boolean;
|
|
143
|
+
allow: string;
|
|
144
|
+
}>>;
|
|
145
|
+
};
|
|
146
|
+
deleteEmbeddedWebsite: {
|
|
147
|
+
query: tg.TypeGuard<string>;
|
|
148
|
+
answer: tg.TypeGuard<undefined>;
|
|
149
|
+
};
|
|
150
|
+
createEmbeddedWebsite: {
|
|
151
|
+
query: tg.TypeGuard<object & {
|
|
152
|
+
name: string;
|
|
153
|
+
url: string;
|
|
154
|
+
position: object & {
|
|
155
|
+
x: any;
|
|
156
|
+
y: any;
|
|
157
|
+
width: any;
|
|
158
|
+
height: any;
|
|
159
|
+
};
|
|
160
|
+
} & Partial<{
|
|
161
|
+
visible: boolean;
|
|
162
|
+
allowApi: boolean;
|
|
163
|
+
allow: string;
|
|
164
|
+
}>>;
|
|
165
|
+
answer: tg.TypeGuard<undefined>;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
declare type GuardedType<T> = T extends (x: unknown) => x is infer T ? T : never;
|
|
169
|
+
declare type IframeQueryMapTypeGuardsType = typeof iframeQueryMapTypeGuards;
|
|
170
|
+
declare type UnknownToVoid<T> = undefined extends T ? void : T;
|
|
171
|
+
export declare type IframeQueryMap = {
|
|
172
|
+
[key in keyof IframeQueryMapTypeGuardsType]: {
|
|
173
|
+
query: GuardedType<IframeQueryMapTypeGuardsType[key]["query"]>;
|
|
174
|
+
answer: UnknownToVoid<GuardedType<IframeQueryMapTypeGuardsType[key]["answer"]>>;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
export interface IframeQuery<T extends keyof IframeQueryMap> {
|
|
178
|
+
type: T;
|
|
179
|
+
data: IframeQueryMap[T]["query"];
|
|
180
|
+
}
|
|
181
|
+
export interface IframeQueryWrapper<T extends keyof IframeQueryMap> {
|
|
182
|
+
id: number;
|
|
183
|
+
query: IframeQuery<T>;
|
|
184
|
+
}
|
|
185
|
+
export declare const isIframeQueryKey: (type: string) => type is "getState" | "getMapData" | "setVariable" | "loadTileset" | "triggerActionMessage" | "removeActionMessage" | "getEmbeddedWebsite" | "deleteEmbeddedWebsite" | "createEmbeddedWebsite";
|
|
186
|
+
export declare const isIframeQuery: (event: any) => event is IframeQuery<"getState" | "getMapData" | "setVariable" | "loadTileset" | "triggerActionMessage" | "removeActionMessage" | "getEmbeddedWebsite" | "deleteEmbeddedWebsite" | "createEmbeddedWebsite">;
|
|
187
|
+
export declare const isIframeQueryWrapper: (event: any) => event is IframeQueryWrapper<"getState" | "getMapData" | "setVariable" | "loadTileset" | "triggerActionMessage" | "removeActionMessage" | "getEmbeddedWebsite" | "deleteEmbeddedWebsite" | "createEmbeddedWebsite">;
|
|
188
|
+
export interface IframeAnswerEvent<T extends keyof IframeQueryMap> {
|
|
189
|
+
id: number;
|
|
190
|
+
type: T;
|
|
191
|
+
data: IframeQueryMap[T]["answer"];
|
|
192
|
+
}
|
|
193
|
+
export declare const isIframeAnswerEvent: (event: {
|
|
194
|
+
type?: string;
|
|
195
|
+
id?: number;
|
|
196
|
+
}) => event is IframeAnswerEvent<"getState" | "getMapData" | "setVariable" | "loadTileset" | "triggerActionMessage" | "removeActionMessage" | "getEmbeddedWebsite" | "deleteEmbeddedWebsite" | "createEmbeddedWebsite">;
|
|
197
|
+
export interface IframeErrorAnswerEvent {
|
|
198
|
+
id: number;
|
|
199
|
+
type: keyof IframeQueryMap;
|
|
200
|
+
error: string;
|
|
201
|
+
}
|
|
202
|
+
export declare const isIframeErrorAnswerEvent: (event: {
|
|
203
|
+
type?: string;
|
|
204
|
+
id?: number;
|
|
205
|
+
error?: string;
|
|
206
|
+
}) => event is IframeErrorAnswerEvent;
|
|
207
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isLayerEvent: tg.TypeGuard<object & {
|
|
3
|
+
name: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the iFrame to the game to show/hide a layer.
|
|
7
|
+
*/
|
|
8
|
+
export declare type LayerEvent = tg.GuardedType<typeof isLayerEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isLoadPageEvent: tg.TypeGuard<object & {
|
|
3
|
+
url: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
7
|
+
*/
|
|
8
|
+
export declare type LoadPageEvent = tg.GuardedType<typeof isLoadPageEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isLoadSoundEvent: tg.TypeGuard<object & {
|
|
3
|
+
url: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
7
|
+
*/
|
|
8
|
+
export declare type LoadSoundEvent = tg.GuardedType<typeof isLoadSoundEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isLoadTilesetEvent: tg.TypeGuard<object & {
|
|
3
|
+
url: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
7
|
+
*/
|
|
8
|
+
export declare type LoadTilesetEvent = tg.GuardedType<typeof isLoadTilesetEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isMapDataEvent: tg.TypeGuard<object & {
|
|
3
|
+
data: object;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the game to the iFrame when the data of the layers change after the iFrame send a message to the game that it want to listen to the data of the layers
|
|
7
|
+
*/
|
|
8
|
+
export declare type MapDataEvent = tg.GuardedType<typeof isMapDataEvent>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isOpenCoWebsite: tg.TypeGuard<object & {
|
|
3
|
+
url: string;
|
|
4
|
+
allowApi: boolean;
|
|
5
|
+
allowPolicy: string;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
9
|
+
*/
|
|
10
|
+
export declare type OpenCoWebSiteEvent = tg.GuardedType<typeof isOpenCoWebsite>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isOpenPopupEvent: tg.TypeGuard<object & {
|
|
3
|
+
popupId: number;
|
|
4
|
+
targetObject: string;
|
|
5
|
+
message: string;
|
|
6
|
+
buttons: (object & {
|
|
7
|
+
label: any;
|
|
8
|
+
className: any;
|
|
9
|
+
})[];
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
13
|
+
*/
|
|
14
|
+
export declare type OpenPopupEvent = tg.GuardedType<typeof isOpenPopupEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isOpenTabEvent: tg.TypeGuard<object & {
|
|
3
|
+
url: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
7
|
+
*/
|
|
8
|
+
export declare type OpenTabEvent = tg.GuardedType<typeof isOpenTabEvent>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isPlaySoundEvent: tg.TypeGuard<object & {
|
|
3
|
+
url: string;
|
|
4
|
+
config: (object & {
|
|
5
|
+
volume: any;
|
|
6
|
+
loop: any;
|
|
7
|
+
mute: any;
|
|
8
|
+
rate: any;
|
|
9
|
+
detune: any;
|
|
10
|
+
seek: any;
|
|
11
|
+
delay: any;
|
|
12
|
+
}) | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
16
|
+
*/
|
|
17
|
+
export declare type PlaySoundEvent = tg.GuardedType<typeof isPlaySoundEvent>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isSetTilesEvent: tg.TypeGuard<(object & {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
tile: string | number | null;
|
|
6
|
+
layer: string;
|
|
7
|
+
})[]>;
|
|
8
|
+
/**
|
|
9
|
+
* A message sent from the iFrame to the game to set one or many tiles.
|
|
10
|
+
*/
|
|
11
|
+
export declare type SetTilesEvent = tg.GuardedType<typeof isSetTilesEvent>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isSetVariableEvent: tg.TypeGuard<object & {
|
|
3
|
+
key: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* A message sent from the iFrame to the game to change the value of the property of the layer
|
|
8
|
+
*/
|
|
9
|
+
export declare type SetVariableEvent = tg.GuardedType<typeof isSetVariableEvent>;
|
|
10
|
+
export declare const isSetVariableIframeEvent: tg.TypeGuard<object & {
|
|
11
|
+
type: "setVariable";
|
|
12
|
+
data: object & {
|
|
13
|
+
key: any;
|
|
14
|
+
value: any;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isStopSoundEvent: tg.TypeGuard<object & {
|
|
3
|
+
url: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the iFrame to the game to add a message in the chat.
|
|
7
|
+
*/
|
|
8
|
+
export declare type StopSoundEvent = tg.GuardedType<typeof isStopSoundEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isUserInputChatEvent: tg.TypeGuard<object & {
|
|
3
|
+
message: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the game to the iFrame when a user types a message in the chat.
|
|
7
|
+
*/
|
|
8
|
+
export declare type UserInputChatEvent = tg.GuardedType<typeof isUserInputChatEvent>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isSetPropertyEvent: tg.TypeGuard<object & {
|
|
3
|
+
layerName: string;
|
|
4
|
+
propertyName: string;
|
|
5
|
+
propertyValue: string | number | boolean | undefined;
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* A message sent from the iFrame to the game to change the value of the property of the layer
|
|
9
|
+
*/
|
|
10
|
+
export declare type SetPropertyEvent = tg.GuardedType<typeof isSetPropertyEvent>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isMenuItemClickedEvent: tg.TypeGuard<object & {
|
|
3
|
+
menuItem: string;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* A message sent from the game to the iFrame when a menu item is clicked.
|
|
7
|
+
*/
|
|
8
|
+
export declare type MenuItemClickedEvent = tg.GuardedType<typeof isMenuItemClickedEvent>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
/**
|
|
3
|
+
* A message sent from a script to the game to remove a custom menu from the menu
|
|
4
|
+
*/
|
|
5
|
+
export declare const isUnregisterMenuEvent: tg.TypeGuard<object & {
|
|
6
|
+
name: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare type UnregisterMenuEvent = tg.GuardedType<typeof isUnregisterMenuEvent>;
|
|
9
|
+
export declare const isMenuRegisterOptions: tg.TypeGuard<object & {
|
|
10
|
+
allowApi: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* A message sent from a script to the game to add a custom menu from the menu
|
|
14
|
+
*/
|
|
15
|
+
export declare const isMenuRegisterEvent: tg.TypeGuard<object & {
|
|
16
|
+
name: string;
|
|
17
|
+
iframe: string | undefined;
|
|
18
|
+
options: object & {
|
|
19
|
+
allowApi: any;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
export declare type MenuRegisterEvent = tg.GuardedType<typeof isMenuRegisterEvent>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const triggerActionMessage = "triggerActionMessage";
|
|
3
|
+
export declare const removeActionMessage = "removeActionMessage";
|
|
4
|
+
export declare const isActionMessageType: tg.TypeGuard<"message" | "warning">;
|
|
5
|
+
export declare type ActionMessageType = tg.GuardedType<typeof isActionMessageType>;
|
|
6
|
+
export declare const isTriggerActionMessageEvent: tg.TypeGuard<object & {
|
|
7
|
+
message: string;
|
|
8
|
+
uuid: string;
|
|
9
|
+
type: "message" | "warning";
|
|
10
|
+
}>;
|
|
11
|
+
export declare type TriggerActionMessageEvent = tg.GuardedType<typeof isTriggerActionMessageEvent>;
|
|
12
|
+
export declare const isMessageReferenceEvent: tg.TypeGuard<object & {
|
|
13
|
+
uuid: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare type MessageReferenceEvent = tg.GuardedType<typeof isMessageReferenceEvent>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as tg from "generic-type-guard";
|
|
2
|
+
export declare const isTriggerMessageHandlerEvent: tg.PartialTypeGuard<unknown, (object & {
|
|
3
|
+
type: "triggerActionMessage";
|
|
4
|
+
data: object & {
|
|
5
|
+
message: any;
|
|
6
|
+
uuid: any;
|
|
7
|
+
type: any;
|
|
8
|
+
};
|
|
9
|
+
}) | (object & {
|
|
10
|
+
type: "removeActionMessage";
|
|
11
|
+
data: object & {
|
|
12
|
+
uuid: any;
|
|
13
|
+
};
|
|
14
|
+
})>;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { IframeQueryMap, IframeResponseEvent, IframeResponseEventMap } from "./Events/IframeEvent";
|
|
2
|
+
import type { HasPlayerMovedEvent } from "./Events/HasPlayerMovedEvent";
|
|
3
|
+
import type { SetVariableEvent } from "./Events/SetVariableEvent";
|
|
4
|
+
declare type AnswererCallback<T extends keyof IframeQueryMap> = (query: IframeQueryMap[T]["query"], source: MessageEventSource | null) => IframeQueryMap[T]["answer"] | PromiseLike<IframeQueryMap[T]["answer"]>;
|
|
5
|
+
/**
|
|
6
|
+
* Listens to messages from iframes and turn those messages into easy to use observables.
|
|
7
|
+
* Also allows to send messages to those iframes.
|
|
8
|
+
*/
|
|
9
|
+
declare class IframeListener {
|
|
10
|
+
private readonly _openPopupStream;
|
|
11
|
+
readonly openPopupStream: import("rxjs").Observable<object & {
|
|
12
|
+
popupId: number;
|
|
13
|
+
targetObject: string;
|
|
14
|
+
message: string;
|
|
15
|
+
buttons: (object & {
|
|
16
|
+
label: any;
|
|
17
|
+
className: any;
|
|
18
|
+
})[];
|
|
19
|
+
}>;
|
|
20
|
+
private readonly _openTabStream;
|
|
21
|
+
readonly openTabStream: import("rxjs").Observable<object & {
|
|
22
|
+
url: string;
|
|
23
|
+
}>;
|
|
24
|
+
private readonly _loadPageStream;
|
|
25
|
+
readonly loadPageStream: import("rxjs").Observable<string>;
|
|
26
|
+
private readonly _openCoWebSiteStream;
|
|
27
|
+
readonly openCoWebSiteStream: import("rxjs").Observable<object & {
|
|
28
|
+
url: string;
|
|
29
|
+
allowApi: boolean;
|
|
30
|
+
allowPolicy: string;
|
|
31
|
+
}>;
|
|
32
|
+
private readonly _disablePlayerControlStream;
|
|
33
|
+
readonly disablePlayerControlStream: import("rxjs").Observable<void>;
|
|
34
|
+
private readonly _enablePlayerControlStream;
|
|
35
|
+
readonly enablePlayerControlStream: import("rxjs").Observable<void>;
|
|
36
|
+
private readonly _closePopupStream;
|
|
37
|
+
readonly closePopupStream: import("rxjs").Observable<object & {
|
|
38
|
+
popupId: number;
|
|
39
|
+
}>;
|
|
40
|
+
private readonly _displayBubbleStream;
|
|
41
|
+
readonly displayBubbleStream: import("rxjs").Observable<void>;
|
|
42
|
+
private readonly _removeBubbleStream;
|
|
43
|
+
readonly removeBubbleStream: import("rxjs").Observable<void>;
|
|
44
|
+
private readonly _showLayerStream;
|
|
45
|
+
readonly showLayerStream: import("rxjs").Observable<object & {
|
|
46
|
+
name: string;
|
|
47
|
+
}>;
|
|
48
|
+
private readonly _hideLayerStream;
|
|
49
|
+
readonly hideLayerStream: import("rxjs").Observable<object & {
|
|
50
|
+
name: string;
|
|
51
|
+
}>;
|
|
52
|
+
private readonly _setPropertyStream;
|
|
53
|
+
readonly setPropertyStream: import("rxjs").Observable<object & {
|
|
54
|
+
layerName: string;
|
|
55
|
+
propertyName: string;
|
|
56
|
+
propertyValue: string | number | boolean | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
private readonly _playSoundStream;
|
|
59
|
+
readonly playSoundStream: import("rxjs").Observable<object & {
|
|
60
|
+
url: string;
|
|
61
|
+
config: (object & {
|
|
62
|
+
volume: any;
|
|
63
|
+
loop: any;
|
|
64
|
+
mute: any;
|
|
65
|
+
rate: any;
|
|
66
|
+
detune: any;
|
|
67
|
+
seek: any;
|
|
68
|
+
delay: any;
|
|
69
|
+
}) | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
private readonly _stopSoundStream;
|
|
72
|
+
readonly stopSoundStream: import("rxjs").Observable<object & {
|
|
73
|
+
url: string;
|
|
74
|
+
}>;
|
|
75
|
+
private readonly _loadSoundStream;
|
|
76
|
+
readonly loadSoundStream: import("rxjs").Observable<object & {
|
|
77
|
+
url: string;
|
|
78
|
+
}>;
|
|
79
|
+
private readonly _setTilesStream;
|
|
80
|
+
readonly setTilesStream: import("rxjs").Observable<(object & {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
tile: string | number | null;
|
|
84
|
+
layer: string;
|
|
85
|
+
})[]>;
|
|
86
|
+
private readonly _modifyEmbeddedWebsiteStream;
|
|
87
|
+
readonly modifyEmbeddedWebsiteStream: import("rxjs").Observable<object & {
|
|
88
|
+
name: string;
|
|
89
|
+
} & Partial<{
|
|
90
|
+
url: string;
|
|
91
|
+
visible: boolean;
|
|
92
|
+
allowApi: boolean;
|
|
93
|
+
allow: string;
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
width: number;
|
|
97
|
+
height: number;
|
|
98
|
+
}>>;
|
|
99
|
+
private readonly iframes;
|
|
100
|
+
private readonly iframeCloseCallbacks;
|
|
101
|
+
private readonly scripts;
|
|
102
|
+
private sendPlayerMove;
|
|
103
|
+
private answerers;
|
|
104
|
+
init(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Allows the passed iFrame to send/receive messages via the API.
|
|
107
|
+
*/
|
|
108
|
+
registerIframe(iframe: HTMLIFrameElement): void;
|
|
109
|
+
unregisterIframe(iframe: HTMLIFrameElement): void;
|
|
110
|
+
registerScript(scriptUrl: string): Promise<void>;
|
|
111
|
+
private getBaseUrl;
|
|
112
|
+
private static getIFrameId;
|
|
113
|
+
unregisterScript(scriptUrl: string): void;
|
|
114
|
+
sendUserInputChat(message: string): void;
|
|
115
|
+
sendEnterEvent(name: string): void;
|
|
116
|
+
sendLeaveEvent(name: string): void;
|
|
117
|
+
hasPlayerMoved(event: HasPlayerMovedEvent): void;
|
|
118
|
+
sendButtonClickedEvent(popupId: number, buttonId: number): void;
|
|
119
|
+
setVariable(setVariableEvent: SetVariableEvent): void;
|
|
120
|
+
sendActionMessageTriggered(uuid: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* Sends the message... to all allowed iframes.
|
|
123
|
+
*/
|
|
124
|
+
postMessage(message: IframeResponseEvent<keyof IframeResponseEventMap>): void;
|
|
125
|
+
/**
|
|
126
|
+
* Registers a callback that can be used to respond to some query (as defined in the IframeQueryMap type).
|
|
127
|
+
*
|
|
128
|
+
* Important! There can be only one "answerer" so registering a new one will unregister the old one.
|
|
129
|
+
*
|
|
130
|
+
* @param key The "type" of the query we are answering
|
|
131
|
+
* @param callback
|
|
132
|
+
*/
|
|
133
|
+
registerAnswerer<T extends keyof IframeQueryMap>(key: T, callback: AnswererCallback<T>): void;
|
|
134
|
+
unregisterAnswerer(key: keyof IframeQueryMap): void;
|
|
135
|
+
dispatchVariableToOtherIframes(key: string, value: unknown, source: MessageEventSource | null): void;
|
|
136
|
+
}
|
|
137
|
+
export declare const iframeListener: IframeListener;
|
|
138
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChatEvent } from "./Events/ChatEvent";
|
|
2
|
+
declare class ScriptUtils {
|
|
3
|
+
openTab(url: string): void;
|
|
4
|
+
goToPage(url: string): void;
|
|
5
|
+
openCoWebsite(url: string, base: string, api: boolean, policy: string): void;
|
|
6
|
+
closeCoWebSite(): void;
|
|
7
|
+
sendAnonymousChat(chatEvent: ChatEvent): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const scriptUtils: ScriptUtils;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type * as tg from "generic-type-guard";
|
|
2
|
+
import type { IframeEvent, IframeEventMap, IframeQuery, IframeQueryMap, IframeResponseEventMap } from "../Events/IframeEvent";
|
|
3
|
+
export declare function sendToWorkadventure(content: IframeEvent<keyof IframeEventMap>): void;
|
|
4
|
+
export declare const answerPromises: Map<number, {
|
|
5
|
+
resolve: (value: IframeQueryMap[keyof IframeQueryMap]["answer"] | PromiseLike<IframeQueryMap[keyof IframeQueryMap]["answer"]>) => void;
|
|
6
|
+
reject: (reason?: any) => void;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function queryWorkadventure<T extends keyof IframeQueryMap>(content: IframeQuery<T>): Promise<IframeQueryMap[T]["answer"]>;
|
|
9
|
+
export interface IframeCallback<Key extends keyof IframeResponseEventMap, T = IframeResponseEventMap[Key], Guard = tg.TypeGuard<T>> {
|
|
10
|
+
typeChecker: Guard;
|
|
11
|
+
callback: (payloadData: T) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface IframeCallbackContribution<Key extends keyof IframeResponseEventMap> extends IframeCallback<Key> {
|
|
14
|
+
type: Key;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* !! be aware that the implemented attributes (addMethodsAtRoot and subObjectIdentifier) must be readonly
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare abstract class IframeApiContribution<T extends {
|
|
22
|
+
callbacks: Array<IframeCallbackContribution<keyof IframeResponseEventMap>>;
|
|
23
|
+
}> {
|
|
24
|
+
abstract callbacks: T["callbacks"];
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CreateEmbeddedWebsiteEvent } from "../../Events/EmbeddedWebsiteEvent";
|
|
2
|
+
export declare class EmbeddedWebsite {
|
|
3
|
+
private config;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
private _url;
|
|
6
|
+
private _visible;
|
|
7
|
+
private _allow;
|
|
8
|
+
private _allowApi;
|
|
9
|
+
private _position;
|
|
10
|
+
constructor(config: CreateEmbeddedWebsiteEvent);
|
|
11
|
+
set url(url: string);
|
|
12
|
+
set visible(visible: boolean);
|
|
13
|
+
set x(x: number);
|
|
14
|
+
set y(y: number);
|
|
15
|
+
set width(width: number);
|
|
16
|
+
set height(height: number);
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ActionMessageOptions } from "../ui";
|
|
2
|
+
export declare class ActionMessage {
|
|
3
|
+
private onRemove;
|
|
4
|
+
readonly uuid: string;
|
|
5
|
+
private readonly type;
|
|
6
|
+
private readonly message;
|
|
7
|
+
private readonly callback;
|
|
8
|
+
constructor(actionMessageOptions: ActionMessageOptions, onRemove: () => void);
|
|
9
|
+
private create;
|
|
10
|
+
remove(): Promise<void>;
|
|
11
|
+
triggerCallback(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Popup } from "./Popup";
|
|
2
|
+
export declare type ButtonClickedCallback = (popup: Popup) => void;
|
|
3
|
+
export interface ButtonDescriptor {
|
|
4
|
+
/**
|
|
5
|
+
* The label of the button
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* The type of the button. Can be one of "normal", "primary", "success", "warning", "error", "disabled"
|
|
10
|
+
*/
|
|
11
|
+
className?: "normal" | "primary" | "success" | "warning" | "error" | "disabled";
|
|
12
|
+
/**
|
|
13
|
+
* Callback called if the button is pressed
|
|
14
|
+
*/
|
|
15
|
+
callback: ButtonClickedCallback;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sendMenuClickedEvent(menuItem: string): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
2
|
+
export declare class WorkadventureChatCommands extends IframeApiContribution<WorkadventureChatCommands> {
|
|
3
|
+
callbacks: import("./IframeApiContribution").IframeCallbackContribution<keyof import("../Events/IframeEvent").IframeResponseEventMap>[];
|
|
4
|
+
sendChatMessage(message: string, author: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Listen to messages sent by the local user, in the chat.
|
|
7
|
+
*/
|
|
8
|
+
onChatMessage(callback: (message: string) => void): void;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: WorkadventureChatCommands;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
2
|
+
export declare class WorkadventureControlsCommands extends IframeApiContribution<WorkadventureControlsCommands> {
|
|
3
|
+
callbacks: never[];
|
|
4
|
+
disablePlayerControls(): void;
|
|
5
|
+
restorePlayerControls(): void;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: WorkadventureControlsCommands;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
2
|
+
export declare class WorkadventureNavigationCommands extends IframeApiContribution<WorkadventureNavigationCommands> {
|
|
3
|
+
callbacks: never[];
|
|
4
|
+
openTab(url: string): void;
|
|
5
|
+
goToPage(url: string): void;
|
|
6
|
+
goToRoom(url: string): void;
|
|
7
|
+
openCoWebSite(url: string, allowApi?: boolean, allowPolicy?: string): void;
|
|
8
|
+
closeCoWebSite(): void;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: WorkadventureNavigationCommands;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
2
|
+
import type { HasPlayerMovedEventCallback } from "../Events/HasPlayerMovedEvent";
|
|
3
|
+
export declare const setPlayerName: (name: string) => void;
|
|
4
|
+
export declare const setTags: (_tags: string[]) => void;
|
|
5
|
+
export declare const setUuid: (_uuid: string | undefined) => void;
|
|
6
|
+
export declare class WorkadventurePlayerCommands extends IframeApiContribution<WorkadventurePlayerCommands> {
|
|
7
|
+
callbacks: import("./IframeApiContribution").IframeCallbackContribution<keyof import("../Events/IframeEvent").IframeResponseEventMap>[];
|
|
8
|
+
onPlayerMove(callback: HasPlayerMovedEventCallback): void;
|
|
9
|
+
get name(): string;
|
|
10
|
+
get tags(): string[];
|
|
11
|
+
get id(): string | undefined;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: WorkadventurePlayerCommands;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IframeResponseEventMap } from "../../Api/Events/IframeEvent";
|
|
2
|
+
import type { IframeCallback } from "../../Api/iframe/IframeApiContribution";
|
|
3
|
+
import type { IframeCallbackContribution } from "../../Api/iframe/IframeApiContribution";
|
|
4
|
+
export declare const registeredCallbacks: {
|
|
5
|
+
[K in keyof IframeResponseEventMap]?: IframeCallback<K>;
|
|
6
|
+
};
|
|
7
|
+
export declare function apiCallback<T extends keyof IframeResponseEventMap>(callbackData: IframeCallbackContribution<T>): IframeCallbackContribution<keyof IframeResponseEventMap>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
2
|
+
import type { ITiledMap } from "../../Phaser/Map/ITiledMap";
|
|
3
|
+
import type { WorkadventureRoomWebsiteCommands } from "./website";
|
|
4
|
+
interface TileDescriptor {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
tile: number | string | null;
|
|
8
|
+
layer: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const setRoomId: (id: string) => void;
|
|
11
|
+
export declare const setMapURL: (url: string) => void;
|
|
12
|
+
export declare class WorkadventureRoomCommands extends IframeApiContribution<WorkadventureRoomCommands> {
|
|
13
|
+
callbacks: import("./IframeApiContribution").IframeCallbackContribution<keyof import("../Events/IframeEvent").IframeResponseEventMap>[];
|
|
14
|
+
onEnterZone(name: string, callback: () => void): void;
|
|
15
|
+
onLeaveZone(name: string, callback: () => void): void;
|
|
16
|
+
showLayer(layerName: string): void;
|
|
17
|
+
hideLayer(layerName: string): void;
|
|
18
|
+
setProperty(layerName: string, propertyName: string, propertyValue: string | number | boolean | undefined): void;
|
|
19
|
+
getTiledMap(): Promise<ITiledMap>;
|
|
20
|
+
setTiles(tiles: TileDescriptor[]): void;
|
|
21
|
+
get id(): string;
|
|
22
|
+
get mapURL(): string;
|
|
23
|
+
loadTileset(url: string): Promise<number>;
|
|
24
|
+
get website(): WorkadventureRoomWebsiteCommands;
|
|
25
|
+
}
|
|
26
|
+
declare const _default: WorkadventureRoomCommands;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
2
|
+
import { Sound } from "./Sound/Sound";
|
|
3
|
+
export declare class WorkadventureSoundCommands extends IframeApiContribution<WorkadventureSoundCommands> {
|
|
4
|
+
callbacks: never[];
|
|
5
|
+
loadSound(url: string): Sound;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: WorkadventureSoundCommands;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
3
|
+
export declare const initVariables: (_variables: Map<string, unknown>) => void;
|
|
4
|
+
export declare class WorkadventureStateCommands extends IframeApiContribution<WorkadventureStateCommands> {
|
|
5
|
+
callbacks: import("./IframeApiContribution").IframeCallbackContribution<keyof import("../Events/IframeEvent").IframeResponseEventMap>[];
|
|
6
|
+
saveVariable(key: string, value: unknown): Promise<void>;
|
|
7
|
+
loadVariable(key: string): unknown;
|
|
8
|
+
hasVariable(key: string): boolean;
|
|
9
|
+
onVariableChange(key: string): Observable<unknown>;
|
|
10
|
+
}
|
|
11
|
+
declare const proxyCommand: WorkadventureStateCommands & {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
export default proxyCommand;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
2
|
+
import type { ButtonDescriptor } from "./Ui/ButtonDescriptor";
|
|
3
|
+
import { Popup } from "./Ui/Popup";
|
|
4
|
+
import { ActionMessage } from "./Ui/ActionMessage";
|
|
5
|
+
import { Menu } from "./Ui/Menu";
|
|
6
|
+
import type { RequireOnlyOne } from "../types";
|
|
7
|
+
interface MenuDescriptor {
|
|
8
|
+
callback?: (commandDescriptor: string) => void;
|
|
9
|
+
iframe?: string;
|
|
10
|
+
allowApi?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare type MenuOptions = RequireOnlyOne<MenuDescriptor, "callback" | "iframe">;
|
|
13
|
+
export interface ActionMessageOptions {
|
|
14
|
+
message: string;
|
|
15
|
+
type?: "message" | "warning";
|
|
16
|
+
callback: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventureUiCommands> {
|
|
19
|
+
callbacks: import("./IframeApiContribution").IframeCallbackContribution<keyof import("../Events/IframeEvent").IframeResponseEventMap>[];
|
|
20
|
+
openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup;
|
|
21
|
+
registerMenuCommand(commandDescriptor: string, options: MenuOptions | ((commandDescriptor: string) => void)): Menu;
|
|
22
|
+
displayBubble(): void;
|
|
23
|
+
removeBubble(): void;
|
|
24
|
+
displayActionMessage(actionMessageOptions: ActionMessageOptions): ActionMessage;
|
|
25
|
+
}
|
|
26
|
+
declare const _default: WorkAdventureUiCommands;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IframeApiContribution } from "./IframeApiContribution";
|
|
2
|
+
import { EmbeddedWebsite } from "./Room/EmbeddedWebsite";
|
|
3
|
+
import type { CreateEmbeddedWebsiteEvent } from "../Events/EmbeddedWebsiteEvent";
|
|
4
|
+
export declare class WorkadventureRoomWebsiteCommands extends IframeApiContribution<WorkadventureRoomWebsiteCommands> {
|
|
5
|
+
callbacks: never[];
|
|
6
|
+
get(objectName: string): Promise<EmbeddedWebsite>;
|
|
7
|
+
create(createEmbeddedWebsiteEvent: CreateEmbeddedWebsiteEvent): EmbeddedWebsite;
|
|
8
|
+
delete(objectName: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: WorkadventureRoomWebsiteCommands;
|
|
11
|
+
export default _default;
|
package/Api/types.d.ts
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<h1 align="center">WorkAdventure - IFrame API typings for Typescript</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">This package contains Typescript typings for <a href="https://workadventu.re/map-building/scripting">WorkAdventure's map scripting API</a></p>
|
|
4
|
+
|
|
5
|
+
<hr/>
|
|
6
|
+
|
|
7
|
+
[WorkAdventure](https://workadventu.re) comes with a scripting API. Using this API, you can add some intelligence to your map.
|
|
8
|
+
You use this API by loading an external script directly from WorkAdventure (at https://play.workadventu.re/iframe_api.js), or this script is loaded
|
|
9
|
+
for you if you are using the "script" property of a map.
|
|
10
|
+
|
|
11
|
+
This project contains Typescript typings for the `WA` object provided by this script.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
This package is only useful if you are using Typescript to script your WorkAdventure maps.
|
|
16
|
+
|
|
17
|
+
## Download & Installation
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
$ npm install @workadventure/iframe-api-typings
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
or
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
$ yarn add @workadventure/iframe-api-typings
|
|
27
|
+
```
|
package/iframe_api.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ButtonDescriptor } from "./Api/iframe/Ui/ButtonDescriptor";
|
|
2
|
+
import type { Popup } from "./Api/iframe/Ui/Popup";
|
|
3
|
+
import type { Sound } from "./Api/iframe/Sound/Sound";
|
|
4
|
+
declare const wa: {
|
|
5
|
+
ui: import("./Api/iframe/ui").WorkAdventureUiCommands;
|
|
6
|
+
nav: import("./Api/iframe/nav").WorkadventureNavigationCommands;
|
|
7
|
+
controls: import("./Api/iframe/controls").WorkadventureControlsCommands;
|
|
8
|
+
chat: import("./Api/iframe/chat").WorkadventureChatCommands;
|
|
9
|
+
sound: import("./Api/iframe/sound").WorkadventureSoundCommands;
|
|
10
|
+
room: import("./Api/iframe/room").WorkadventureRoomCommands;
|
|
11
|
+
player: import("./Api/iframe/player").WorkadventurePlayerCommands;
|
|
12
|
+
state: import("./Api/iframe/state").WorkadventureStateCommands & {
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
onInit(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use WA.chat.sendChatMessage instead
|
|
18
|
+
*/
|
|
19
|
+
sendChatMessage(message: string, author: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use WA.chat.disablePlayerControls instead
|
|
22
|
+
*/
|
|
23
|
+
disablePlayerControls(): void;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Use WA.controls.restorePlayerControls instead
|
|
26
|
+
*/
|
|
27
|
+
restorePlayerControls(): void;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use WA.ui.displayBubble instead
|
|
30
|
+
*/
|
|
31
|
+
displayBubble(): void;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use WA.ui.removeBubble instead
|
|
34
|
+
*/
|
|
35
|
+
removeBubble(): void;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use WA.nav.openTab instead
|
|
38
|
+
*/
|
|
39
|
+
openTab(url: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use WA.sound.loadSound instead
|
|
42
|
+
*/
|
|
43
|
+
loadSound(url: string): Sound;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use WA.nav.goToPage instead
|
|
46
|
+
*/
|
|
47
|
+
goToPage(url: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated Use WA.nav.goToRoom instead
|
|
50
|
+
*/
|
|
51
|
+
goToRoom(url: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Use WA.nav.openCoWebSite instead
|
|
54
|
+
*/
|
|
55
|
+
openCoWebSite(url: string, allowApi?: boolean, allowPolicy?: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use WA.nav.closeCoWebSite instead
|
|
58
|
+
*/
|
|
59
|
+
closeCoWebSite(): void;
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use WA.ui.openPopup instead
|
|
62
|
+
*/
|
|
63
|
+
openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated Use WA.chat.onChatMessage instead
|
|
66
|
+
*/
|
|
67
|
+
onChatMessage(callback: (message: string) => void): void;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Use WA.room.onEnterZone instead
|
|
70
|
+
*/
|
|
71
|
+
onEnterZone(name: string, callback: () => void): void;
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated Use WA.room.onLeaveZone instead
|
|
74
|
+
*/
|
|
75
|
+
onLeaveZone(name: string, callback: () => void): void;
|
|
76
|
+
};
|
|
77
|
+
export declare type WorkAdventureApi = typeof wa;
|
|
78
|
+
declare global {
|
|
79
|
+
interface Window {
|
|
80
|
+
WA: WorkAdventureApi;
|
|
81
|
+
}
|
|
82
|
+
let WA: WorkAdventureApi;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
package/iframe_api.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// This file is voluntarily empty.
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@workadventure/iframe-api-typings",
|
|
3
|
+
"version": "v1.5.0",
|
|
4
|
+
"description": "Typescript typings for WorkAdventure iFrame API",
|
|
5
|
+
"main": "iframe_api.js",
|
|
6
|
+
"types": "iframe_api.d.ts",
|
|
7
|
+
"repository": "https://github.com/thecodingmachine/workadventure/",
|
|
8
|
+
"author": "David Négrier <d.negrier@thecodingmachine.com>",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
}
|
|
13
|
+
}
|