@wvdsh/sdk-js 1.3.15 → 1.3.16
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/dist/index.d.ts +32 -0
- package/dist/index.js +55 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -91,6 +91,8 @@ type UpsertedLeaderboardEntry = FunctionReturnType<typeof api.sdk.leaderboards.u
|
|
|
91
91
|
userId: GenericId<"users">;
|
|
92
92
|
username: string;
|
|
93
93
|
userAvatarUrl?: string;
|
|
94
|
+
submittedScore: number;
|
|
95
|
+
submittedRank: number;
|
|
94
96
|
};
|
|
95
97
|
type WavedashEvent = (typeof WavedashEvents)[keyof typeof WavedashEvents];
|
|
96
98
|
interface WavedashConfig {
|
|
@@ -767,6 +769,20 @@ declare class AudioManager extends WavedashManager {
|
|
|
767
769
|
private mutationObserver;
|
|
768
770
|
constructor(sdk: WavedashSDK);
|
|
769
771
|
isMuted(): boolean;
|
|
772
|
+
/**
|
|
773
|
+
* Ask the host to mute (true) or unmute (false). Resolves to `true` if the
|
|
774
|
+
* host applied the change, `false` otherwise — notably, the host rejects an
|
|
775
|
+
* unmute when the user muted the game from the Wavedash UI, so games can't
|
|
776
|
+
* override an explicit user mute. The resulting state arrives via the usual
|
|
777
|
+
* MUTE_CHANGED broadcast, so `isMuted()` updates independently of this result.
|
|
778
|
+
*/
|
|
779
|
+
requestMute(muted: boolean): Promise<boolean>;
|
|
780
|
+
/**
|
|
781
|
+
* Toggle mute. Like `requestMute`, the host may reject the unmute half of a
|
|
782
|
+
* toggle if the user muted from the Wavedash UI. Resolves to `true` if the
|
|
783
|
+
* host applied the change.
|
|
784
|
+
*/
|
|
785
|
+
toggleMute(): Promise<boolean>;
|
|
770
786
|
private handleMute;
|
|
771
787
|
/**
|
|
772
788
|
* Track a media element and (if SDK is currently muted) silence it.
|
|
@@ -1021,6 +1037,22 @@ declare class WavedashSDK extends EventTarget {
|
|
|
1021
1037
|
* a user gesture handler when entering fullscreen.
|
|
1022
1038
|
*/
|
|
1023
1039
|
toggleFullscreen(): Promise<boolean>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Whether the game is currently muted. Mirrored from the Wavedash host page,
|
|
1042
|
+
* which owns the mute control so its UI button and the game stay in sync.
|
|
1043
|
+
*/
|
|
1044
|
+
isMuted(): boolean;
|
|
1045
|
+
/**
|
|
1046
|
+
* Ask the host to mute (true) or unmute (false). Resolves to `true` if the
|
|
1047
|
+
* change was applied, `false` if it was rejected — the host won't let the
|
|
1048
|
+
* game unmute when the user has muted from the Wavedash UI.
|
|
1049
|
+
*/
|
|
1050
|
+
requestMute(muted: boolean): Promise<boolean>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Toggle mute. Resolves to `true` if the change was applied, `false` if it
|
|
1053
|
+
* was rejected (e.g. trying to unmute over an explicit user mute).
|
|
1054
|
+
*/
|
|
1055
|
+
toggleMute(): Promise<boolean>;
|
|
1024
1056
|
getUser(): SDKUser;
|
|
1025
1057
|
/**
|
|
1026
1058
|
* Get a username. Returns the logged in user's username if no ID is passed.
|
package/dist/index.js
CHANGED
|
@@ -1172,7 +1172,12 @@ var LeaderboardManager = class extends WavedashManager {
|
|
|
1172
1172
|
this.updateCachedTotalEntries(leaderboardId, result.totalEntries);
|
|
1173
1173
|
}
|
|
1174
1174
|
return {
|
|
1175
|
+
// Where your current leaderboard standing ranks
|
|
1175
1176
|
...result.entry,
|
|
1177
|
+
// Where the submission itself ranks
|
|
1178
|
+
submittedScore: result.submission.score,
|
|
1179
|
+
submittedRank: result.submission.globalRank,
|
|
1180
|
+
// User info
|
|
1176
1181
|
userId: this.sdk.wavedashUser.id,
|
|
1177
1182
|
username: this.sdk.wavedashUser.username,
|
|
1178
1183
|
userAvatarUrl: this.sdk.wavedashUser.avatarUrl
|
|
@@ -3196,6 +3201,31 @@ var AudioManager = class extends WavedashManager {
|
|
|
3196
3201
|
isMuted() {
|
|
3197
3202
|
return this._isMuted;
|
|
3198
3203
|
}
|
|
3204
|
+
/**
|
|
3205
|
+
* Ask the host to mute (true) or unmute (false). Resolves to `true` if the
|
|
3206
|
+
* host applied the change, `false` otherwise — notably, the host rejects an
|
|
3207
|
+
* unmute when the user muted the game from the Wavedash UI, so games can't
|
|
3208
|
+
* override an explicit user mute. The resulting state arrives via the usual
|
|
3209
|
+
* MUTE_CHANGED broadcast, so `isMuted()` updates independently of this result.
|
|
3210
|
+
*/
|
|
3211
|
+
async requestMute(muted) {
|
|
3212
|
+
const response = await this.sdk.iframeMessenger.requestFromParent(
|
|
3213
|
+
IFRAME_MESSAGE_TYPE5.SET_MUTE,
|
|
3214
|
+
{ muted }
|
|
3215
|
+
);
|
|
3216
|
+
return response.success;
|
|
3217
|
+
}
|
|
3218
|
+
/**
|
|
3219
|
+
* Toggle mute. Like `requestMute`, the host may reject the unmute half of a
|
|
3220
|
+
* toggle if the user muted from the Wavedash UI. Resolves to `true` if the
|
|
3221
|
+
* host applied the change.
|
|
3222
|
+
*/
|
|
3223
|
+
async toggleMute() {
|
|
3224
|
+
const response = await this.sdk.iframeMessenger.requestFromParent(
|
|
3225
|
+
IFRAME_MESSAGE_TYPE5.TOGGLE_MUTE
|
|
3226
|
+
);
|
|
3227
|
+
return response.success;
|
|
3228
|
+
}
|
|
3199
3229
|
/**
|
|
3200
3230
|
* Track a media element and (if SDK is currently muted) silence it.
|
|
3201
3231
|
* Idempotent — safe to call multiple times for the same element.
|
|
@@ -3976,6 +4006,31 @@ var WavedashSDK = class extends EventTarget {
|
|
|
3976
4006
|
async toggleFullscreen() {
|
|
3977
4007
|
return this.fullscreenManager.toggleFullscreen();
|
|
3978
4008
|
}
|
|
4009
|
+
// =====
|
|
4010
|
+
// Audio
|
|
4011
|
+
// =====
|
|
4012
|
+
/**
|
|
4013
|
+
* Whether the game is currently muted. Mirrored from the Wavedash host page,
|
|
4014
|
+
* which owns the mute control so its UI button and the game stay in sync.
|
|
4015
|
+
*/
|
|
4016
|
+
isMuted() {
|
|
4017
|
+
return this.audioManager.isMuted();
|
|
4018
|
+
}
|
|
4019
|
+
/**
|
|
4020
|
+
* Ask the host to mute (true) or unmute (false). Resolves to `true` if the
|
|
4021
|
+
* change was applied, `false` if it was rejected — the host won't let the
|
|
4022
|
+
* game unmute when the user has muted from the Wavedash UI.
|
|
4023
|
+
*/
|
|
4024
|
+
async requestMute(muted) {
|
|
4025
|
+
return this.audioManager.requestMute(muted);
|
|
4026
|
+
}
|
|
4027
|
+
/**
|
|
4028
|
+
* Toggle mute. Resolves to `true` if the change was applied, `false` if it
|
|
4029
|
+
* was rejected (e.g. trying to unmute over an explicit user mute).
|
|
4030
|
+
*/
|
|
4031
|
+
async toggleMute() {
|
|
4032
|
+
return this.audioManager.toggleMute();
|
|
4033
|
+
}
|
|
3979
4034
|
// ============
|
|
3980
4035
|
// User methods
|
|
3981
4036
|
// ============
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wvdsh/sdk-js",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Wavedash JavaScript SDK",
|
|
6
6
|
"main": "./dist/client.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"typescript-eslint": "^8.52.0"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@wvdsh/api": "^0.1.
|
|
52
|
+
"@wvdsh/api": "^0.1.32",
|
|
53
53
|
"convex": "^1.39.1",
|
|
54
54
|
"lodash.throttle": "^4.1.1"
|
|
55
55
|
}
|