@workadventure/iframe-api-typings 1.11.3 → 1.12.1

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.
Files changed (61) hide show
  1. package/Api/Events/AddPlayerEvent.d.ts +86 -0
  2. package/Api/Events/AskPositionEvent.d.ts +15 -0
  3. package/Api/Events/ChatEvent.d.ts +29 -0
  4. package/Api/Events/ChatVisibilityEvent.d.ts +9 -0
  5. package/Api/Events/EnablePlayersTrackingEvent.d.ts +15 -0
  6. package/Api/Events/GameStateEvent.d.ts +6 -0
  7. package/Api/Events/IframeEvent.d.ts +1123 -114
  8. package/Api/Events/JoinMucEvent.d.ts +21 -0
  9. package/Api/Events/LeaveMucEvent.d.ts +12 -0
  10. package/Api/Events/NotificationEvent.d.ts +18 -0
  11. package/Api/Events/ProximityMeeting/JoinProximityMeetingEvent.d.ts +70 -0
  12. package/Api/Events/ProximityMeeting/ParticipantProximityMeetingEvent.d.ts +70 -0
  13. package/Api/Events/SetPlayerVariableEvent.d.ts +27 -0
  14. package/Api/Events/SetSharedPlayerVariableEvent.d.ts +18 -0
  15. package/Api/Events/SetVariableEvent.d.ts +1 -9
  16. package/Api/Events/SettingsEvent.d.ts +12 -0
  17. package/Api/Events/ShowBusinessCardEvent.d.ts +12 -0
  18. package/Api/Events/{ui → Ui}/MenuItemClickedEvent.d.ts +0 -0
  19. package/Api/Events/{ui → Ui}/MenuRegisterEvent.d.ts +0 -0
  20. package/Api/Events/{ui → Ui}/TriggerActionMessageEvent.d.ts +0 -0
  21. package/Api/Events/{ui → Ui}/UIWebsite.d.ts +0 -0
  22. package/Api/Iframe/AbstractState.d.ts +14 -0
  23. package/Api/{iframe → Iframe}/Area/Area.d.ts +0 -0
  24. package/Api/{iframe → Iframe}/IframeApiContribution.d.ts +0 -0
  25. package/Api/Iframe/Player/ProximityMeeting.d.ts +85 -0
  26. package/Api/Iframe/Players/RemotePlayer.d.ts +81 -0
  27. package/Api/{iframe → Iframe}/Room/EmbeddedWebsite.d.ts +0 -0
  28. package/Api/Iframe/Sound/Sound.d.ts +43 -0
  29. package/Api/{iframe → Iframe}/Ui/ActionMessage.d.ts +0 -0
  30. package/Api/{iframe → Iframe}/Ui/ButtonDescriptor.d.ts +0 -0
  31. package/Api/{iframe → Iframe}/Ui/Menu.d.ts +0 -0
  32. package/Api/{iframe → Iframe}/Ui/Popup.d.ts +0 -0
  33. package/Api/{iframe → Iframe}/Ui/UIWebsite.d.ts +14 -1
  34. package/Api/Iframe/area.d.ts +59 -0
  35. package/Api/Iframe/camera.d.ts +46 -0
  36. package/Api/Iframe/chat.d.ts +36 -0
  37. package/Api/Iframe/controls.d.ts +56 -0
  38. package/Api/Iframe/nav.d.ts +58 -0
  39. package/Api/Iframe/player.d.ts +141 -0
  40. package/Api/Iframe/playerState.d.ts +20 -0
  41. package/Api/Iframe/players.d.ts +135 -0
  42. package/Api/{iframe → Iframe}/registeredCallbacks.d.ts +2 -2
  43. package/Api/Iframe/room.d.ts +128 -0
  44. package/Api/Iframe/sound.d.ts +21 -0
  45. package/Api/Iframe/state.d.ts +15 -0
  46. package/Api/{iframe → Iframe}/ui.d.ts +44 -15
  47. package/Api/Iframe/website.d.ts +32 -0
  48. package/iframe_api.d.ts +38 -19
  49. package/package.json +3 -2
  50. package/Api/Events/RemotePlayerClickedEvent.d.ts +0 -19
  51. package/Api/iframe/Sound/Sound.d.ts +0 -8
  52. package/Api/iframe/area.d.ts +0 -25
  53. package/Api/iframe/camera.d.ts +0 -20
  54. package/Api/iframe/chat.d.ts +0 -18
  55. package/Api/iframe/controls.d.ts +0 -10
  56. package/Api/iframe/nav.d.ts +0 -20
  57. package/Api/iframe/player.d.ts +0 -43
  58. package/Api/iframe/room.d.ts +0 -58
  59. package/Api/iframe/sound.d.ts +0 -8
  60. package/Api/iframe/state.d.ts +0 -25
  61. package/Api/iframe/website.d.ts +0 -11
@@ -0,0 +1,46 @@
1
+ import { IframeApiContribution } from "./IframeApiContribution";
2
+ import { Observable } from "rxjs";
3
+ import type { WasCameraUpdatedEvent } from "../Events/WasCameraUpdatedEvent";
4
+ export declare class WorkAdventureCameraCommands extends IframeApiContribution<WorkAdventureCameraCommands> {
5
+ callbacks: {
6
+ type: "wasCameraUpdated";
7
+ callback: (event: {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ zoom: number;
13
+ }) => void;
14
+ }[];
15
+ /**
16
+ * Set camera to follow the player.
17
+ * {@link https://workadventu.re/map-building/api-camera.md#start-following-player | Website documentation}
18
+ *
19
+ * @param smooth Smooth transition
20
+ */
21
+ followPlayer(smooth?: boolean): void;
22
+ /**
23
+ * Set camera to look at given spot. Setting width and height will adjust zoom.
24
+ * Set lock to true to lock camera in this position.
25
+ * Set smooth to true for smooth transition.
26
+ * {@link https://workadventu.re/map-building/api-camera.md#set-spot-for-camera-to-look-at | Website documentation}
27
+ *
28
+ * @param {number} x Horizontal position
29
+ * @param {number} y Vertical position
30
+ * @param {number} width Width size
31
+ * @param {number} height Height size
32
+ * @param {boolean} lock Zoom locked
33
+ * @param {boolean} smooth Smooth transition
34
+ */
35
+ set(x: number, y: number, width?: number, height?: number, lock?: boolean, smooth?: boolean): void;
36
+ /**
37
+ * Listens to updates of the camera viewport.
38
+ * It will trigger for every update of the camera's properties (position or scale for instance).
39
+ * {@link https://workadventu.re/map-building/api-camera.md#listen-to-camera-updates | Website documentation}
40
+ *
41
+ * @returns {Subject<WasCameraUpdatedEvent>} An observable firing event when the camera is updated
42
+ */
43
+ onCameraUpdate(): Observable<WasCameraUpdatedEvent>;
44
+ }
45
+ declare const _default: WorkAdventureCameraCommands;
46
+ export default _default;
@@ -0,0 +1,36 @@
1
+ import { IframeApiContribution } from "./IframeApiContribution";
2
+ export declare class WorkadventureChatCommands extends IframeApiContribution<WorkadventureChatCommands> {
3
+ callbacks: {
4
+ type: "userInputChat";
5
+ callback: (event: {
6
+ message: string;
7
+ }) => void;
8
+ }[];
9
+ /**
10
+ * Open instantly the chat window.
11
+ * {@link https://workadventu.re/map-building/api-chat.md#open-the-chat-window | Website documentation}
12
+ */
13
+ open(): void;
14
+ /**
15
+ * Close instantly the chat window.
16
+ * {@link https://workadventu.re/map-building/api-chat.md#close-the-chat-window | Website documentation}
17
+ */
18
+ close(): void;
19
+ /**
20
+ * Sends a message in the chat. The message is only visible in the browser of the current user.
21
+ * {@link https://workadventu.re/map-building/api-chat.md#sending-a-message-in-the-chat | Website documentation}
22
+ *
23
+ * @param {string} message Message to be displayed in the chat
24
+ * @param {string|undefined} author Name displayed for the author of the message. It does not have to be a real user
25
+ */
26
+ sendChatMessage(message: string, author?: string): void;
27
+ /**
28
+ * Listens to messages typed by the current user and calls the callback. Messages from other users in the chat cannot be listened to.
29
+ * {@link https://workadventu.re/map-building/api-chat.md#listening-to-messages-from-the-chat | Website documentation}
30
+ *
31
+ * @param {function(string): void} callback Function that will be called when a message is received. It contains the message typed by the user
32
+ */
33
+ onChatMessage(callback: (message: string) => void): void;
34
+ }
35
+ declare const _default: WorkadventureChatCommands;
36
+ export default _default;
@@ -0,0 +1,56 @@
1
+ import { IframeApiContribution } from "./IframeApiContribution";
2
+ export declare class WorkadventureControlsCommands extends IframeApiContribution<WorkadventureControlsCommands> {
3
+ callbacks: never[];
4
+ /**
5
+ * Disable player controls.
6
+ * {@link https://workadventu.re/map-building/api-controls.md#disabling--restoring-controls | Website documentation}
7
+ */
8
+ disablePlayerControls(): void;
9
+ /**
10
+ * Restore player controls.
11
+ * {@link https://workadventu.re/map-building/api-controls.md#disabling--restoring-controls | Website documentation}
12
+ */
13
+ restorePlayerControls(): void;
14
+ /**
15
+ * Turn off player microphone.
16
+ * {@link https://workadventu.re/map-building/api-controls.md#turn-off-webcam-or-microphone | Website documentation}
17
+ */
18
+ turnOffMicrophone(): void;
19
+ /**
20
+ * Turn off player webcam.
21
+ * {@link https://workadventu.re/map-building/api-controls.md#turn-off-webcam-or-microphone | Website documentation}
22
+ */
23
+ turnOffWebcam(): void;
24
+ /**
25
+ * Disable player microphone.
26
+ * {@link https://workadventu.re/map-building/api-controls.md#disabling--restoring-webcam-or-microphone | Website documentation}
27
+ */
28
+ disableMicrophone(): void;
29
+ /**
30
+ * Restore player microphone.
31
+ * {@link https://workadventu.re/map-building/api-controls.md#disabling--restoring-webcam-or-microphone | Website documentation}
32
+ */
33
+ restoreMicrophone(): void;
34
+ /**
35
+ * Disable player webcam.
36
+ * {@link https://workadventu.re/map-building/api-controls.md#disabling--restoring-webcam-or-microphone | Website documentation}
37
+ */
38
+ disableWebcam(): void;
39
+ /**
40
+ * Disable player webcam.
41
+ * {@link https://workadventu.re/map-building/api-controls.md#disabling--restoring-webcam-or-microphone | Website documentation}
42
+ */
43
+ restoreWebcam(): void;
44
+ /**
45
+ * Disable proximity meetings.
46
+ * {@link https://workadventu.re/map-building/api-controls.md#disabling--restoring-proximity-meeting | Website documentation}
47
+ */
48
+ disablePlayerProximityMeeting(): void;
49
+ /**
50
+ * Restore proximity meettings.
51
+ * {@link https://workadventu.re/map-building/api-controls.md#disabling--restoring-proximity-meeting | Website documentation}
52
+ */
53
+ restorePlayerProximityMeeting(): void;
54
+ }
55
+ declare const _default: WorkadventureControlsCommands;
56
+ export default _default;
@@ -0,0 +1,58 @@
1
+ import { IframeApiContribution } from "./IframeApiContribution";
2
+ export declare class CoWebsite {
3
+ private readonly id;
4
+ constructor(id: string);
5
+ close(): Promise<void>;
6
+ }
7
+ export declare class WorkadventureNavigationCommands extends IframeApiContribution<WorkadventureNavigationCommands> {
8
+ callbacks: never[];
9
+ /**
10
+ * Opens the webpage at "url" in your browser, in a new tab.
11
+ * {@link https://workadventu.re/map-building/api-nav.md#opening-a-web-page-in-a-new-tab | Website documentation}
12
+ *
13
+ * @param {string} url Url of the web page
14
+ */
15
+ openTab(url: string): void;
16
+ /**
17
+ * Opens the webpage at "url" in your browser in place of WorkAdventure. WorkAdventure will be completely unloaded.
18
+ * {@link https://workadventu.re/map-building/api-nav.md#opening-a-web-page-in-the-current-tab | Website documentation}
19
+ *
20
+ * @param {string} url Url of the web page
21
+ */
22
+ goToPage(url: string): void;
23
+ /**
24
+ * Load the map at url without unloading workadventure.
25
+ * relative urls: "../subFolder/map.json[#start-layer-name]" global urls: "/_/global/domain/path/map.json[#start-layer-name]"
26
+ * {@link https://workadventu.re/map-building/api-nav.md#going-to-a-different-map-from-the-script | Website documentation}
27
+ *
28
+ * @param {string} url Url of the web page
29
+ */
30
+ goToRoom(url: string): void;
31
+ /**
32
+ * Opens the webpage at "url" in an iFrame (on the right side of the screen) or close that iFrame.
33
+ * {@link https://workadventu.re/map-building/api-nav.md#openingclosing-web-page-in-co-websites | Website documentation}
34
+ *
35
+ * @param {string} url Url of the web page
36
+ * @param {boolean|undefined} allowApi Allows the webpage to use the "IFrame API" and execute script (it is equivalent to putting the openWebsiteAllowApi property in the map)
37
+ * @param {string|undefined} allowPolicy Grants additional access rights to the iFrame
38
+ * @param {number|undefined} widthPercent Define the width of the main cowebsite beetween the min size and the max size (70% of the viewport)
39
+ * @param {number|undefined} position Define in whitch slot the web page will be open
40
+ * @param {boolean|undefined} closable Allow to close the webpage also you need to close it by the api
41
+ * @param {boolean|undefined} lazy Add the cowebsite but don't load it
42
+ * @returns {CoWebsite} The CoWebsite created
43
+ */
44
+ openCoWebSite(url: string, allowApi?: boolean, allowPolicy?: string, widthPercent?: number, position?: number, closable?: boolean, lazy?: boolean): Promise<CoWebsite>;
45
+ /**
46
+ * Get all opened co-websites with their ids and positions.
47
+ * {@link https://workadventu.re/map-building/api-nav.md#get-all-co-websites | Website documentation}
48
+ *
49
+ * @returns {CoWebsite[]} All Cowebsites
50
+ */
51
+ getCoWebSites(): Promise<CoWebsite[]>;
52
+ /**
53
+ * @deprecated Use closeCoWebsites instead to close all co-websites
54
+ */
55
+ closeCoWebSite(): Promise<void>;
56
+ }
57
+ declare const _default: WorkadventureNavigationCommands;
58
+ export default _default;
@@ -0,0 +1,141 @@
1
+ import { IframeApiContribution } from "./IframeApiContribution";
2
+ import type { HasPlayerMovedEventCallback } from "../Events/HasPlayerMovedEvent";
3
+ import { WorkadventureProximityMeetingCommands } from "./Player/ProximityMeeting";
4
+ export declare const setPlayerName: (name: string) => void;
5
+ export declare const setPlayerLanguage: (language: string | undefined) => void;
6
+ export declare const setTags: (_tags: string[]) => void;
7
+ export declare const setUserRoomToken: (token: string | undefined) => void;
8
+ export declare const setPlayerId: (_id: number | undefined) => void;
9
+ export declare const setUuid: (_uuid: string | undefined) => void;
10
+ export declare class WorkadventurePlayerCommands extends IframeApiContribution<WorkadventurePlayerCommands> {
11
+ readonly state: import("./playerState").WorkadventurePlayerStateCommands & {
12
+ [key: string]: unknown;
13
+ };
14
+ callbacks: {
15
+ type: "hasPlayerMoved";
16
+ callback: (event: {
17
+ oldX?: number | undefined;
18
+ oldY?: number | undefined;
19
+ x: number;
20
+ y: number;
21
+ direction: "left" | "right" | "up" | "down";
22
+ moving: boolean;
23
+ }) => void;
24
+ }[];
25
+ /**
26
+ * Get the player name.
27
+ * Important: You need to wait for the end of the initialization before accessing.
28
+ * {@link https://workadventu.re/map-building/api-player.md#get-the-player-name | Website documentation}
29
+ *
30
+ * @returns {string} Player name
31
+ */
32
+ get name(): string;
33
+ /**
34
+ * Get the player UUID.
35
+ * Important: You need to wait for the end of the initialization before accessing.
36
+ * {@link https://workadventu.re/map-building/api-player.md#get-the-player-uuid | Website documentation}
37
+ * @deprecated Use WA.player.uuid instead
38
+ *
39
+ * @returns {string|undefined} Player UUID
40
+ */
41
+ get id(): string | undefined;
42
+ /**
43
+ * Get the player id.
44
+ * Important: You need to wait for the end of the initialization before accessing.
45
+ * {@link https://workadventu.re/map-building/api-player.md#get-the-player-id | Website documentation}
46
+ *
47
+ * @returns {number} Player id
48
+ */
49
+ get playerId(): number;
50
+ /**
51
+ * Get the player UUID.
52
+ * Important: You need to wait for the end of the initialization before accessing.
53
+ * {@link https://workadventu.re/map-building/api-player.md#get-the-player-uuid | Website documentation}
54
+ *
55
+ * @returns {string|undefined} Player UUID
56
+ */
57
+ get uuid(): string | undefined;
58
+ /**
59
+ * Get the player language.
60
+ * Important: You need to wait for the end of the initialization before accessing.
61
+ * {@link https://workadventu.re/map-building/api-player.md#get-the-player-language | Website documentation}
62
+ *
63
+ * @returns {string} Player language
64
+ */
65
+ get language(): string;
66
+ /**
67
+ * Get the player tags.
68
+ * Important: You need to wait for the end of the initialization before accessing.
69
+ * {@link https://workadventu.re/map-building/api-player.md#get-the-tags-of-the-player | Website documentation}
70
+ *
71
+ * @returns {string[]} Player tags
72
+ */
73
+ get tags(): string[];
74
+ /**
75
+ * Get the player position.
76
+ * Important: You need to wait for the end of the initialization before accessing.
77
+ * {@link https://workadventu.re/map-building/api-player.md#get-the-position-of-the-player | Website documentation}
78
+ *
79
+ * @returns {Position} Player position
80
+ */
81
+ getPosition(): Promise<Position>;
82
+ /**
83
+ * Listens to the movement of the current user and calls the callback.
84
+ * Sends an event when the user stops moving, changes direction and every 200ms when moving in the same direction.
85
+ * {@link https://workadventu.re/map-building/api-player.md#listen-to-player-movement | Website documentation}
86
+ *
87
+ * @param {HasPlayerMovedEventCallback} callback Function that will be called when the current player is moving. It contains the event
88
+ */
89
+ onPlayerMove(callback: HasPlayerMovedEventCallback): void;
90
+ /**
91
+ * Player will try to find shortest path to the destination point and proceed to move there.
92
+ * {@link https://workadventu.re/map-building/api-player.md#move-player-to-position | Website documentation}
93
+ *
94
+ * @param {number} x Horizontal position
95
+ * @param {number} y Vertical position
96
+ * @param {number} speed Speed
97
+ * @returns {Promise<{ x: number, y: number, cancelled: boolean }>} Promise to give an object with the position and if the move has been cancelled or not
98
+ */
99
+ moveTo(x: number, y: number, speed?: number): Promise<{
100
+ x: number;
101
+ y: number;
102
+ cancelled: boolean;
103
+ }>;
104
+ /**
105
+ * This token can be used by third party services to authenticate a player and prove that the player is in a given room.
106
+ * The token is generated by the administration panel linked to WorkAdventure.
107
+ * The token is a string and is depending on your implementation of the administration panel.
108
+ * In WorkAdventure SAAS version, the token is a JWT token that contains information such as the player's room ID and its associated membership ID.
109
+ *
110
+ * If you are using the self-hosted version of WorkAdventure and you developed your own administration panel, the token can be anything.
111
+ * By default, self-hosted versions of WorkAdventure don't come with an administration panel, so the token string will be empty.
112
+ * {@link https://workadventu.re/map-building/api-player.md#get-the-user-room-token-of-the-player | Website documentation}
113
+ *
114
+ * @returns {string|undefined} User room token
115
+ */
116
+ get userRoomToken(): string | undefined;
117
+ /**
118
+ * Display a thin line around your player's name (the "outline").
119
+ * {@link https://workadventu.re/map-building/api-player.md#set-the-outline-color-of-the-player | Website documentation}
120
+ *
121
+ * @param {number} red
122
+ * @param {number} green
123
+ * @param {number} blue
124
+ * @returns {Promise<void>} Promise to wait to known when the outiline has been displayed
125
+ */
126
+ setOutlineColor(red: number, green: number, blue: number): Promise<void>;
127
+ /**
128
+ * Remove the thin line around your player's name (the "outline").
129
+ * {@link https://workadventu.re/map-building/api-player.md#set-the-outline-color-of-the-player | Website documentation}
130
+ *
131
+ * @returns {Promise<void>} Promise to await to known when the outline has been removed
132
+ */
133
+ removeOutlineColor(): Promise<void>;
134
+ get proximityMeeting(): WorkadventureProximityMeetingCommands;
135
+ }
136
+ export declare type Position = {
137
+ x: number;
138
+ y: number;
139
+ };
140
+ declare const _default: WorkadventurePlayerCommands;
141
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import { AbstractWorkadventureStateCommands } from "./AbstractState";
2
+ export declare class WorkadventurePlayerStateCommands extends AbstractWorkadventureStateCommands {
3
+ constructor();
4
+ callbacks: {
5
+ type: "setPlayerVariable";
6
+ callback: (event: {
7
+ value?: unknown;
8
+ key: string;
9
+ }) => void;
10
+ }[];
11
+ saveVariable(key: string, value: unknown, options?: {
12
+ public?: boolean;
13
+ persist?: boolean;
14
+ ttl?: number;
15
+ scope?: "world" | "room";
16
+ }): Promise<void>;
17
+ }
18
+ export declare const playerState: WorkadventurePlayerStateCommands & {
19
+ [key: string]: unknown;
20
+ };
@@ -0,0 +1,135 @@
1
+ import { IframeApiContribution } from "./IframeApiContribution";
2
+ import { Observable } from "rxjs";
3
+ import { RemotePlayer, RemotePlayerInterface, RemotePlayerMoved } from "./Players/RemotePlayer";
4
+ export interface PlayerVariableChanged {
5
+ player: RemotePlayer;
6
+ value: unknown;
7
+ }
8
+ export declare class WorkadventurePlayersCommands extends IframeApiContribution<WorkadventurePlayersCommands> {
9
+ private trackingPlayers;
10
+ private trackingMovement;
11
+ callbacks: ({
12
+ type: "setSharedPlayerVariable";
13
+ callback: (event: {
14
+ value?: unknown;
15
+ playerId: number;
16
+ key: string;
17
+ }) => void;
18
+ } | {
19
+ type: "addRemotePlayer";
20
+ callback: (event: {
21
+ outlineColor?: number | undefined;
22
+ position: {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ name: string;
27
+ playerId: number;
28
+ variables: Map<string, unknown>;
29
+ userUuid: string;
30
+ availabilityStatus: string;
31
+ }) => void;
32
+ } | {
33
+ type: "removeRemotePlayer";
34
+ callback: (event: number) => void;
35
+ } | {
36
+ type: "remotePlayerChanged";
37
+ callback: (event: {
38
+ position?: {
39
+ x: number;
40
+ y: number;
41
+ } | undefined;
42
+ name?: string | undefined;
43
+ variables?: Map<string, unknown> | undefined;
44
+ availabilityStatus?: string | undefined;
45
+ outlineColor?: number | undefined;
46
+ playerId: number;
47
+ }) => void;
48
+ })[];
49
+ private registerRemotePlayer;
50
+ /**
51
+ * Start the tracking players. You need to call this method before being able to listen to players positions.
52
+ * {@link https://workadventu.re/map-building/api-players.md#enabling-players-tracking | Website documentation}
53
+ *
54
+ * ```ts
55
+ * await WA.players.configureTracking({
56
+ * players: true, // Required to use "onPlayerEnters", "onPlayerLeaves", "list" and "get"
57
+ * movement: true, // Required to get the player position and use "onPlayerMoves"
58
+ * })
59
+ * ```
60
+ *
61
+ * @param options
62
+ */
63
+ configureTracking(options?: {
64
+ players?: boolean;
65
+ movement?: boolean;
66
+ }): Promise<void>;
67
+ /**
68
+ * Listens to a given variable change on all available players.
69
+ * {@link https://workadventu.re/map-building/api-players.md#listen-to-a-remote-player-variable-changes | Website documentation}
70
+ *
71
+ * ```ts
72
+ * WA.players.onVariableChange("score").subscribe({ player, value } => {
73
+ * console.log("Score for player", player.name, "has been updated to", value);
74
+ * });
75
+ * ```
76
+ *
77
+ * If you are looking to listen for variable changes of only one player, look at `RemotePlayer.onVariableChange` instead.
78
+ */
79
+ onVariableChange(variableName: string): Observable<PlayerVariableChanged>;
80
+ /**
81
+ * Listens to new remote players.
82
+ * These will be triggered when a remote player is entering our "zone" (zone ~= viewport)
83
+ * This means this will NOT be triggered when a remote player enters the map, but when the remote player is
84
+ * getting visible.
85
+ * {@link https://workadventu.re/map-building/api-players.md#tracking-players-in-real-time | Website documentation}
86
+ *
87
+ * Usage:
88
+ *
89
+ * ```
90
+ * WA.players.onPlayerEnters.subscribe((remotePlayer) => { doStuff(); });
91
+ * ```
92
+ */
93
+ get onPlayerEnters(): Observable<RemotePlayerInterface>;
94
+ /**
95
+ * Listens to remote players leaving.
96
+ * These will be triggered when a remote player is leaving our "zone" (zone ~= viewport)
97
+ * This means this will be triggered when a remote player leaves the map, but ALSO when the remote player is
98
+ * walking away and is no longer visible.
99
+ * {@link https://workadventu.re/map-building/api-players.md#tracking-players-in-real-time | Website documentation}
100
+ *
101
+ * Usage:
102
+ *
103
+ * ```
104
+ * WA.players.onPlayerLeaves.subscribe((remotePlayer) => { doCleanupStuff(); });
105
+ * ```
106
+ */
107
+ get onPlayerLeaves(): Observable<RemotePlayerInterface>;
108
+ /**
109
+ * Listens to movement from all players who are in our zone (zone ~= viewport)
110
+ * This means this may NOT be triggered when a remote player moves but is far away from us.
111
+ * {@link https://workadventu.re/map-building/api-players.md#tracking-players-movement | Website documentation}
112
+ *
113
+ * Usage:
114
+ *
115
+ * ```
116
+ * WA.players.onPlayerMoves.subscribe(({ player, newPosition, oldPosition }) => { doStuff(); });
117
+ * ```
118
+ */
119
+ get onPlayerMoves(): Observable<RemotePlayerMoved>;
120
+ /**
121
+ * Returns a RemotePlayer by its id.
122
+ * {@link https://workadventu.re/map-building/api-players.md#getting-a-remote-player-by-id | Website documentation}
123
+ *
124
+ * Note: if the same user is connected twice, it will be considered as 2 different players with 2 different IDs.
125
+ */
126
+ get(id: number): RemotePlayerInterface | undefined;
127
+ /**
128
+ * Returns the list of all nearby remote players.
129
+ * The list only contains the players in the same zone as the current player (where zone ~= viewport).
130
+ * {@link https://workadventu.re/map-building/api-players.md#getting-a-list-of-players-around-me | Website documentation}
131
+ */
132
+ list(): IterableIterator<RemotePlayerInterface>;
133
+ }
134
+ declare const _default: WorkadventurePlayersCommands;
135
+ export default _default;
@@ -1,8 +1,8 @@
1
1
  import { IframeResponseEvent } from "../../Api/Events/IframeEvent";
2
2
  export declare const registeredCallbacks: {
3
- [K in IframeResponseEvent["type"]]?: (event: Extract<IframeResponseEvent, {
3
+ [K in IframeResponseEvent["type"]]?: ((event: Extract<IframeResponseEvent, {
4
4
  type: K;
5
- }>["data"]) => void;
5
+ }>["data"]) => void)[];
6
6
  };
7
7
  export declare function apiCallback<T extends IframeResponseEvent["type"]>(callbackData: {
8
8
  type: T;
@@ -0,0 +1,128 @@
1
+ import { Observable } from "rxjs";
2
+ import { IframeApiContribution } from "./IframeApiContribution";
3
+ import type { WorkadventureRoomWebsiteCommands } from "./website";
4
+ import { WorkadventureAreaCommands } from "./area";
5
+ import { ITiledMap } from "@workadventure/tiled-map-type-guard";
6
+ interface TileDescriptor {
7
+ x: number;
8
+ y: number;
9
+ tile: number | string | null;
10
+ layer: string;
11
+ }
12
+ export declare const setRoomId: (id: string) => void;
13
+ export declare const setMapURL: (url: string) => void;
14
+ export declare class WorkadventureRoomCommands extends IframeApiContribution<WorkadventureRoomCommands> {
15
+ callbacks: ({
16
+ type: "enterEvent";
17
+ callback: (event: {
18
+ name: string;
19
+ }) => void;
20
+ } | {
21
+ type: "leaveEvent";
22
+ callback: (event: {
23
+ name: string;
24
+ }) => void;
25
+ } | {
26
+ type: "enterLayerEvent";
27
+ callback: (event: {
28
+ name: string;
29
+ }) => void;
30
+ } | {
31
+ type: "leaveLayerEvent";
32
+ callback: (event: {
33
+ name: string;
34
+ }) => void;
35
+ })[];
36
+ /**
37
+ * @deprecated Use onEnterLayer instead
38
+ */
39
+ onEnterZone(name: string, callback: () => void): void;
40
+ /**
41
+ * @deprecated Use onLeaveLayer instead
42
+ */
43
+ onLeaveZone(name: string, callback: () => void): void;
44
+ /**
45
+ * Listens to the position of the current user. The event is triggered when the user enters a given layer.
46
+ * {@link https://workadventu.re/map-building/api-room.md#detecting-when-the-user-entersleaves-a-layer | Website documentation}
47
+ *
48
+ * @param {string} layerName Name of the layer who as defined in Tiled
49
+ * @returns {Subject<void>} Event subject can be listen by a subscribtion
50
+ */
51
+ onEnterLayer(layerName: string): Observable<void>;
52
+ /**
53
+ * Listens to the position of the current user. The event is triggered when the user leaves a given layer.
54
+ * {@link https://workadventu.re/map-building/api-room.md#detecting-when-the-user-entersleaves-a-layer | Website documentation}
55
+ *
56
+ * @param {string} layerName Name of the layer who as defined in Tiled
57
+ * @returns {Subject<void>} Event subject can be listen by a subscribtion
58
+ */
59
+ onLeaveLayer(layerName: string): Observable<void>;
60
+ /**
61
+ * This methods can be used to show a layer. if layerName is the name of a group layer, show all the layer in that group layer.
62
+ * {@link https://workadventu.re/map-building/api-room.md#show--hide-a-layer | Website documentation}
63
+ *
64
+ * @param {string} layerName Name of the layer/group layer who as defined in Tiled
65
+ */
66
+ showLayer(layerName: string): void;
67
+ /**
68
+ * This methods can be used to hide a layer. if layerName is the name of a group layer, hide all the layer in that group layer.
69
+ * {@link https://workadventu.re/map-building/api-room.md#show--hide-a-layer | Website documentation}
70
+ *
71
+ * @param {string} layerName Name of the layer/group layer who as defined in Tiled
72
+ */
73
+ hideLayer(layerName: string): void;
74
+ /**
75
+ * Set the value of the propertyName property of the layer layerName at propertyValue.
76
+ * If the property doesn't exist, create the property propertyName and set the value of the property at propertyValue.
77
+ * Note : To unset a property from a layer, use setProperty with propertyValue set to undefined.
78
+ * {@link https://workadventu.re/map-building/api-room.md#setcreate-properties-in-a-layer | Website documentation}
79
+ *
80
+ * @param {string} layerName Name of the layer who as defined in Tiled
81
+ * @param {string} propertyName Name of the property
82
+ * @param {string|number|boolean|undefined} propertyValue Value of the property
83
+ */
84
+ setProperty(layerName: string, propertyName: string, propertyValue: string | number | boolean | undefined): void;
85
+ /**
86
+ * Returns a promise that resolves to the JSON map file.
87
+ * Check the {@link https://doc.mapeditor.org/en/stable/reference/json-map-format/ | Tiled documentation to learn more about the format of the JSON map}.
88
+ * {@link https://workadventu.re/map-building/api-room.md#getting-map-data | Website documentation}
89
+ *
90
+ * @returns {Promise<ITiledMap>} Map in Tiled JSON format
91
+ */
92
+ getTiledMap(): Promise<ITiledMap>;
93
+ /**
94
+ * Replace the tile at the x and y coordinates in the layer named layer by the tile with the id tile.
95
+ * {@link https://workadventu.re/map-building/api-room.md#changing-tiles | Website documentation}
96
+ *
97
+ * @param {TileDescriptor[]} tiles Description of a tile
98
+ */
99
+ setTiles(tiles: TileDescriptor[]): void;
100
+ /**
101
+ * The ID of the current room is available from the WA.room.id property.
102
+ * Important: You need to wait for the end of the initialization before accessing.
103
+ * {@link https://workadventu.re/map-building/api-room.md#get-the-room-id | Website documentation}
104
+ *
105
+ * @returns {string} Id of the room
106
+ */
107
+ get id(): string;
108
+ /**
109
+ * The URL of the map is available from the WA.room.mapURL property.
110
+ * Important: You need to wait for the end of the initialization before accessing.
111
+ * {@link https://workadventu.re/map-building/api-room.md#get-the-map-url | Website documentation}
112
+ *
113
+ * @returns {string} Url of the map
114
+ */
115
+ get mapURL(): string;
116
+ /**
117
+ * Load a tileset in JSON format from an url and return the id of the first tile of the loaded tileset.
118
+ * {@link https://workadventu.re/map-building/api-room.md#loading-a-tileset | Website documentation}
119
+ *
120
+ * @param {string} url Url of the tileset
121
+ * @returns {Promise<number>} Promise to return the id of the tileset
122
+ */
123
+ loadTileset(url: string): Promise<number>;
124
+ get website(): WorkadventureRoomWebsiteCommands;
125
+ get area(): WorkadventureAreaCommands;
126
+ }
127
+ declare const _default: WorkadventureRoomCommands;
128
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { IframeApiContribution } from "./IframeApiContribution";
2
+ import { Sound } from "./Sound/Sound";
3
+ export declare class WorkadventureSoundCommands extends IframeApiContribution<WorkadventureSoundCommands> {
4
+ callbacks: never[];
5
+ /**
6
+ * Load a sound from an url.
7
+ *
8
+ * Please note that loadSound returns an object of the Sound class.
9
+ *
10
+ * The Sound class that represents a loaded sound contains two methods: play(soundConfig : SoundConfig|undefined) and stop().
11
+ *
12
+ * The parameter soundConfig is optional, if you call play without a Sound config the sound will be played with the basic configuration.
13
+ * {@link https://workadventu.re/map-building/api-sound.md#load-a-sound-from-an-url | Website documentation}
14
+ *
15
+ * @param url
16
+ * @returns
17
+ */
18
+ loadSound(url: string): Sound;
19
+ }
20
+ declare const _default: WorkadventureSoundCommands;
21
+ export default _default;