@wvdsh/sdk-js 1.3.7 → 1.3.9
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 +48 -34
- package/dist/index.js +304 -177
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -702,18 +702,8 @@ declare class OverlayManager extends WavedashManager {
|
|
|
702
702
|
|
|
703
703
|
declare class FriendsManager extends WavedashManager {
|
|
704
704
|
private userCache;
|
|
705
|
+
private leaderboardPageUserCache;
|
|
705
706
|
constructor(sdk: WavedashSDK);
|
|
706
|
-
/**
|
|
707
|
-
* Cache users from any source (friends, lobby users)
|
|
708
|
-
* Accepts both Friend format (avatarUrl) and LobbyUser format (userAvatarUrl)
|
|
709
|
-
* @param users - Array of users with userId, username, and optional avatar r2Key
|
|
710
|
-
*/
|
|
711
|
-
cacheUsers(users: Array<{
|
|
712
|
-
userId: GenericId<"users">;
|
|
713
|
-
username: string;
|
|
714
|
-
avatarUrl?: string;
|
|
715
|
-
userAvatarUrl?: string;
|
|
716
|
-
}>): void;
|
|
717
707
|
/**
|
|
718
708
|
* Returns CDN URL with size transformation for a cached user's avatar.
|
|
719
709
|
* @param userId - The user ID to get the avatar URL for
|
|
@@ -728,31 +718,18 @@ declare class FriendsManager extends WavedashManager {
|
|
|
728
718
|
* @returns The username, or null if user not cached
|
|
729
719
|
*/
|
|
730
720
|
getUsername(userId: GenericId<"users">): string | null;
|
|
721
|
+
/**
|
|
722
|
+
* List all friends for the logged in user
|
|
723
|
+
* @returns Array<{
|
|
724
|
+
* avatarUrl?: string;
|
|
725
|
+
* isOnline: boolean;
|
|
726
|
+
* userId: Id<"users">;
|
|
727
|
+
* username: string;
|
|
728
|
+
* }>
|
|
729
|
+
*/
|
|
731
730
|
listFriends(): Promise<Friend[]>;
|
|
732
731
|
}
|
|
733
732
|
|
|
734
|
-
/**
|
|
735
|
-
* Logger interface and implementation
|
|
736
|
-
* Simply logs to the console with customizable log level
|
|
737
|
-
*
|
|
738
|
-
* In the future we could extend this to write .log files to IndexedDB or cache storage
|
|
739
|
-
*/
|
|
740
|
-
interface Logger {
|
|
741
|
-
debug(message: string, ...args: unknown[]): void;
|
|
742
|
-
info(message: string, ...args: unknown[]): void;
|
|
743
|
-
warn(message: string, ...args: unknown[]): void;
|
|
744
|
-
error(message: string, ...args: unknown[]): void;
|
|
745
|
-
}
|
|
746
|
-
declare class WavedashLogger implements Logger {
|
|
747
|
-
private logLevel;
|
|
748
|
-
constructor(logLevel?: number);
|
|
749
|
-
setLogLevel(level: number): void;
|
|
750
|
-
debug(message: string, ...args: unknown[]): void;
|
|
751
|
-
info(message: string, ...args: unknown[]): void;
|
|
752
|
-
warn(message: string, ...args: unknown[]): void;
|
|
753
|
-
error(message: string, ...args: unknown[]): void;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
733
|
/**
|
|
757
734
|
* Utilities for handling iframe messaging between the iframe'd Wavedash SDK and the parent window.
|
|
758
735
|
* Assumes window is defined and this is only ever running inside an iframe.
|
|
@@ -779,6 +756,36 @@ declare class IFrameMessenger {
|
|
|
779
756
|
requestFromParent<T extends keyof IFrameEventPayloadMap>(requestType: T, data?: Record<string, unknown>): Promise<IFrameEventPayloadMap[T]>;
|
|
780
757
|
}
|
|
781
758
|
|
|
759
|
+
/**
|
|
760
|
+
* Utilities for messaging between the SDK and the service worker
|
|
761
|
+
* that proxies API requests on its behalf.
|
|
762
|
+
*/
|
|
763
|
+
type SwMessage<T = unknown> = {
|
|
764
|
+
type: string;
|
|
765
|
+
payload?: T;
|
|
766
|
+
};
|
|
767
|
+
type SwReply = (message: SwMessage) => void;
|
|
768
|
+
type SwListener = (payload: unknown, reply: SwReply) => void;
|
|
769
|
+
declare class SwMessenger {
|
|
770
|
+
private listeners;
|
|
771
|
+
constructor();
|
|
772
|
+
/**
|
|
773
|
+
* Register a handler for an incoming message type from the SW. The handler
|
|
774
|
+
* receives the message payload and a `reply` function that routes the
|
|
775
|
+
* response back via the transferred MessagePort when present, falling back
|
|
776
|
+
* to a controller postMessage otherwise.
|
|
777
|
+
*/
|
|
778
|
+
addEventListener(type: string, listener: SwListener): void;
|
|
779
|
+
removeEventListener(type: string, listener: SwListener): void;
|
|
780
|
+
/**
|
|
781
|
+
* Fire-and-forget message to the active service worker controller. No-op
|
|
782
|
+
* when no SW is controlling the page (first load before activation, or
|
|
783
|
+
* environments without SW support).
|
|
784
|
+
*/
|
|
785
|
+
postToServiceWorker(message: SwMessage): boolean;
|
|
786
|
+
private handleMessage;
|
|
787
|
+
}
|
|
788
|
+
|
|
782
789
|
declare class WavedashSDK extends EventTarget {
|
|
783
790
|
private _initialized;
|
|
784
791
|
get initialized(): boolean;
|
|
@@ -868,8 +875,8 @@ declare class WavedashSDK extends EventTarget {
|
|
|
868
875
|
convexClient: ConvexClient;
|
|
869
876
|
engineCallbackReceiver: string;
|
|
870
877
|
engineInstance: EngineInstance | null;
|
|
871
|
-
logger: WavedashLogger;
|
|
872
878
|
iframeMessenger: IFrameMessenger;
|
|
879
|
+
swMessenger: SwMessenger;
|
|
873
880
|
p2pManager: P2PManager;
|
|
874
881
|
fullscreenManager: FullscreenManager;
|
|
875
882
|
overlayManager: OverlayManager;
|
|
@@ -1168,6 +1175,13 @@ declare class WavedashSDK extends EventTarget {
|
|
|
1168
1175
|
*/
|
|
1169
1176
|
private destroy;
|
|
1170
1177
|
private setupSessionEndListeners;
|
|
1178
|
+
/**
|
|
1179
|
+
* Respond to the service worker's `embed.creds-request` with the SDK's
|
|
1180
|
+
* current gameplay JWT. The SW asks when it wakes from termination with no
|
|
1181
|
+
* in-memory or IDB credentials (e.g. Safari ITP storage decay) — we're the
|
|
1182
|
+
* fastest live source. JWT only; sessionToken is owned by the SW + cookies.
|
|
1183
|
+
*/
|
|
1184
|
+
private setupSwCredsListener;
|
|
1171
1185
|
}
|
|
1172
1186
|
declare global {
|
|
1173
1187
|
interface Window {
|