@b3dotfun/sdk 0.1.69-alpha.10 → 0.1.69-alpha.11

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 (38) hide show
  1. package/dist/cjs/global-account/bsmnt.d.ts +0 -1
  2. package/dist/cjs/global-account/bsmnt.js +0 -6
  3. package/dist/cjs/global-account/react/utils/index.d.ts +0 -1
  4. package/dist/cjs/global-account/react/utils/index.js +0 -1
  5. package/dist/esm/global-account/bsmnt.d.ts +0 -1
  6. package/dist/esm/global-account/bsmnt.js +0 -5
  7. package/dist/esm/global-account/react/utils/index.d.ts +0 -1
  8. package/dist/esm/global-account/react/utils/index.js +0 -1
  9. package/dist/styles/index.css +1 -1
  10. package/dist/types/global-account/bsmnt.d.ts +0 -1
  11. package/dist/types/global-account/react/utils/index.d.ts +0 -1
  12. package/package.json +1 -6
  13. package/src/global-account/bsmnt.ts +0 -6
  14. package/src/global-account/react/utils/index.ts +0 -1
  15. package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
  16. package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -54
  17. package/dist/cjs/global-account/react/components/ProfileAvatar.d.ts +0 -0
  18. package/dist/cjs/global-account/react/components/ProfileAvatar.js +0 -127
  19. package/dist/cjs/global-account/react/hooks/useRPMToken.d.ts +0 -7
  20. package/dist/cjs/global-account/react/hooks/useRPMToken.js +0 -11
  21. package/dist/cjs/global-account/react/utils/updateAvatar.d.ts +0 -4
  22. package/dist/cjs/global-account/react/utils/updateAvatar.js +0 -54
  23. package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
  24. package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -51
  25. package/dist/esm/global-account/react/components/ProfileAvatar.d.ts +0 -0
  26. package/dist/esm/global-account/react/components/ProfileAvatar.js +0 -127
  27. package/dist/esm/global-account/react/hooks/useRPMToken.d.ts +0 -7
  28. package/dist/esm/global-account/react/hooks/useRPMToken.js +0 -8
  29. package/dist/esm/global-account/react/utils/updateAvatar.d.ts +0 -4
  30. package/dist/esm/global-account/react/utils/updateAvatar.js +0 -18
  31. package/dist/types/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
  32. package/dist/types/global-account/react/components/ProfileAvatar.d.ts +0 -0
  33. package/dist/types/global-account/react/hooks/useRPMToken.d.ts +0 -7
  34. package/dist/types/global-account/react/utils/updateAvatar.d.ts +0 -4
  35. package/src/global-account/react/components/AvatarCreator/AvatarCreator.tsx +0 -90
  36. package/src/global-account/react/components/ProfileAvatar.tsx +0 -138
  37. package/src/global-account/react/hooks/useRPMToken.ts +0 -17
  38. package/src/global-account/react/utils/updateAvatar.ts +0 -21
@@ -1,90 +0,0 @@
1
- "use client";
2
-
3
- import { toast, useProfile } from "@b3dotfun/sdk/global-account/react";
4
- import { useRPMToken } from "@b3dotfun/sdk/global-account/react/hooks/useRPMToken";
5
- import { updateAvatar } from "@b3dotfun/sdk/global-account/react/utils/updateAvatar";
6
- import { cn } from "@b3dotfun/sdk/shared/utils/cn";
7
- import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
8
- import {
9
- AvatarCreatorConfig,
10
- AvatarCreator as AvatarCreatorRPM,
11
- AvatarExportedEvent,
12
- } from "@readyplayerme/react-avatar-creator";
13
- import { useState } from "react";
14
-
15
- import { useActiveAccount } from "thirdweb/react";
16
-
17
- const debug = debugB3React("AvatarCreator");
18
-
19
- const config: AvatarCreatorConfig = {
20
- clearCache: true,
21
- bodyType: "fullbody",
22
- quickStart: true,
23
- language: "en",
24
- };
25
-
26
- interface AvatarCreatorProps {
27
- onSetAvatar?: () => void;
28
- className?: string;
29
- }
30
-
31
- export function AvatarCreator({ onSetAvatar, className }: AvatarCreatorProps) {
32
- const { token, refetch: refetchRPMToken } = useRPMToken();
33
- const [loading, setIsLoading] = useState(false);
34
- const account = useActiveAccount();
35
- const { data: profile, refetch: refreshProfile } = useProfile({
36
- address: account?.address,
37
- fresh: true,
38
- });
39
-
40
- const hasAvatar = profile?.avatar;
41
-
42
- const handleOnAvatarExported = async (event: AvatarExportedEvent) => {
43
- setIsLoading(true);
44
- debug("@@AvatarExportedEvent", event);
45
- try {
46
- const avatarUpload = await updateAvatar(event.data.url);
47
- debug("@@avatarUpload", avatarUpload);
48
-
49
- await refreshProfile();
50
- toast.success(
51
- hasAvatar ? "Nice look! Your avatar has been updated!" : "Looks great! Your avatar has been saved!",
52
- );
53
- onSetAvatar?.();
54
- await refetchRPMToken(undefined);
55
- } catch (e) {
56
- debug("@@error:AvatarCreator", e);
57
- toast.error("Failed to update avatar. Please try again.");
58
- }
59
- setIsLoading(false);
60
- };
61
-
62
- if (loading) {
63
- return (
64
- <div className="flex h-[80vh] w-full flex-col items-center justify-center gap-4">
65
- <div className="border-primary h-8 w-8 animate-spin rounded-full border-4 border-t-transparent" />
66
- <p className="text-muted-foreground text-sm font-medium">Saving your avatar</p>
67
- </div>
68
- );
69
- }
70
-
71
- if (!token) {
72
- return (
73
- <div className="flex h-[80vh] w-full flex-col items-center justify-center gap-4">
74
- <div className="border-primary h-8 w-8 animate-spin rounded-full border-4 border-t-transparent" />
75
- <p className="text-muted-foreground text-sm font-medium">Loading avatar creator</p>
76
- </div>
77
- );
78
- }
79
-
80
- return (
81
- <div className={cn("h-[calc(90vh-2px)] w-full", className)}>
82
- <AvatarCreatorRPM
83
- className="h-full w-full"
84
- subdomain="b3"
85
- config={{ ...config, token }}
86
- onAvatarExported={handleOnAvatarExported}
87
- />
88
- </div>
89
- );
90
- }
@@ -1,138 +0,0 @@
1
- // "use client";
2
-
3
- // import { AnimatePresence, motion } from "motion/react";
4
- // import { useEffect, useState } from "react";
5
- // import ClientOnly from "./custom/ClientOnly";
6
-
7
- // interface ProfileAvatarProps {
8
- // avatarId: string;
9
- // timestamp?: number;
10
- // }
11
-
12
- // // this function was taken from b3-shared
13
- // function createUrlFromAvatarId(avatarId: string, extension: string = "png"): string {
14
- // if (extension === "png") {
15
- // return `https://avatars.basement.fun/${avatarId}.png`;
16
- // }
17
- // return `https://models.readyplayer.me/${avatarId}.${extension}`;
18
- // }
19
-
20
- // // Sub component for the avatar image
21
- // const ProfileAvatar = ({ avatarId, timestamp }: ProfileAvatarProps) => {
22
- // const [avatarLoading, setAvatarLoading] = useState(true);
23
- // const [avatarError, setAvatarError] = useState(false);
24
- // const [ReadyPlayerMeAvatar, setReadyPlayerMeAvatar] = useState<any>(null);
25
- // const [Vector3, setVector3] = useState<any>(null);
26
- // const [dependenciesLoaded, setDependenciesLoaded] = useState(false);
27
-
28
- // // Dynamically import dependencies only when component is used
29
- // useEffect(() => {
30
- // let isMounted = true;
31
-
32
- // const loadDependencies = async () => {
33
- // try {
34
- // const [visageModule, threeModule] = await Promise.all([
35
- // // @ts-ignore - Optional peer dependency
36
- // import("@readyplayerme/visage"),
37
- // // @ts-ignore - Optional peer dependency
38
- // import("three")
39
- // ]);
40
-
41
- // if (isMounted) {
42
- // setReadyPlayerMeAvatar(() => visageModule.Avatar);
43
- // setVector3(() => threeModule.Vector3);
44
- // setDependenciesLoaded(true);
45
- // }
46
- // } catch (error) {
47
- // console.warn("ProfileAvatar: 3D dependencies not available, falling back to 2D avatar:", error);
48
- // if (isMounted) {
49
- // setAvatarLoading(false);
50
- // setDependenciesLoaded(false);
51
- // }
52
- // }
53
- // };
54
-
55
- // loadDependencies();
56
-
57
- // return () => {
58
- // isMounted = false;
59
- // };
60
- // }, []);
61
-
62
- // if (!avatarId) {
63
- // return (
64
- // <div className="flex h-full w-full items-center justify-center">
65
- // <p className="text-white/50">No avatar available</p>
66
- // </div>
67
- // );
68
- // }
69
-
70
- // return (
71
- // <AnimatePresence mode="wait">
72
- // {(avatarLoading || !dependenciesLoaded) && !avatarError && (
73
- // <motion.img
74
- // key="avatar-image"
75
- // src={`https://models.readyplayer.me/${avatarId}.png?camera=fullbody&size=1024&expression=happy&t=${timestamp || ""}`}
76
- // alt="avatar"
77
- // className="absolute left-0 top-0 h-full w-full object-cover"
78
- // initial={{ opacity: 0 }}
79
- // animate={{ opacity: 1 }}
80
- // exit={{ opacity: 0 }}
81
- // transition={{ duration: 0.3, ease: "easeInOut" }}
82
- // onError={() => setAvatarError(true)}
83
- // />
84
- // )}
85
- // {dependenciesLoaded && (
86
- // <ClientOnly>
87
- // <motion.div
88
- // key={`avatar-3d-${timestamp}`}
89
- // className="absolute left-0 top-0 h-full w-full"
90
- // initial={{ opacity: 0 }}
91
- // animate={{ opacity: avatarLoading ? 0 : 1 }}
92
- // exit={{ opacity: 0 }}
93
- // transition={{ duration: 0.3, ease: "easeInOut" }}
94
- // >
95
- // {ReadyPlayerMeAvatar && Vector3 && (
96
- // <ReadyPlayerMeAvatar
97
- // animationSrc="https://readyplayerme-assets.s3.amazonaws.com/animations/visage/male-idle.glb"
98
- // onLoadedAnimation={{
99
- // src: "https://readyplayerme-assets.s3.amazonaws.com/animations/visage/male-spawn-animation.fbx",
100
- // loop: 4
101
- // }}
102
- // modelSrc={createUrlFromAvatarId(avatarId, "glb")}
103
- // idleRotation={true}
104
- // headMovement={true}
105
- // scale={0.9}
106
- // keyLightColor="#bca1f4"
107
- // keyLightIntensity={1}
108
- // fillLightColor="#8d4cf6"
109
- // fov={50}
110
- // emotion={{
111
- // browInnerUp: 0.3,
112
- // browOuterUpLeft: 0.37,
113
- // browOuterUpRight: 0.49,
114
- // eyeSquintLeft: 0.4,
115
- // eyeSquintRight: 0.2,
116
- // mouthShrugUpper: 0.27,
117
- // mouthSmileLeft: 0.37,
118
- // mouthSmileRight: 0.36
119
- // }}
120
- // cameraZoomTarget={new Vector3(0, 0.1, 3.2)}
121
- // cameraInitialDistance={3.2}
122
- // cameraTarget={1.55}
123
- // className="h-full w-full"
124
- // onLoaded={() => {
125
- // setAvatarLoading(false);
126
- // setAvatarError(false);
127
- // }}
128
- // shadows
129
- // />
130
- // )}
131
- // </motion.div>
132
- // </ClientOnly>
133
- // )}
134
- // </AnimatePresence>
135
- // );
136
- // };
137
-
138
- // export default ProfileAvatar;
@@ -1,17 +0,0 @@
1
- "use client";
2
-
3
- import { useQueryBSMNT } from "@b3dotfun/sdk/global-account/react/hooks/useQueryBSMNT";
4
-
5
- export function useRPMToken() {
6
- const {
7
- data,
8
- runQuery: refetch,
9
- isLoading,
10
- error: isError,
11
- } = useQueryBSMNT("profiles", "getReadyPlayerMeToken", undefined, true);
12
-
13
- const token = data?.token || "";
14
- const accountId = data?.accountId || "";
15
-
16
- return { token, accountId, refetch, isLoading, isError };
17
- }
@@ -1,21 +0,0 @@
1
- import app, { extractAvatarIdFromUrl } from "@b3dotfun/sdk/global-account/bsmnt";
2
- import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
3
-
4
- const debug = debugB3React("updateAvatar");
5
-
6
- export async function updateAvatar(avatar: string) {
7
- try {
8
- // Extract avatar ID from URL
9
- const avatarID = extractAvatarIdFromUrl(avatar);
10
-
11
- if (!avatarID) {
12
- throw new Error("Invalid avatar URL");
13
- }
14
-
15
- // Set the avatar in the profiles service
16
- return await app.service("profiles").setAvatar({ avatarUrl: String(avatar), avatarID: String(avatarID) }, {});
17
- } catch (error) {
18
- debug("Failed to update avatar:", error);
19
- throw error; // Re-throw to handle in component
20
- }
21
- }