@domino-sdk/relay 0.27.0 → 0.29.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/dist/authoring.d.ts +11 -3
- package/dist/authoring.js +5 -3
- package/dist/browser.d.ts +320 -190
- package/dist/browser.js +12 -6
- package/dist/{chunk-D6AIUNSM.js → chunk-5LLU7UUV.js} +42 -10
- package/dist/{chunk-IXLY3A7B.js → chunk-BE5V6RFD.js} +8 -0
- package/dist/{chunk-M3R5V5WC.js → chunk-LAKQCIHX.js} +6 -1
- package/dist/{chunk-D6BX627V.js → chunk-MRKFRCCI.js} +43 -50
- package/dist/{chunk-RVGO2CRA.js → chunk-MVCKCDNR.js} +175 -2
- package/dist/{chunk-AKB266O5.js → chunk-YKS6P4IP.js} +13 -2
- package/dist/index.d.ts +557 -494
- package/dist/index.js +20 -8
- package/dist/portal-proxy.js +3 -3
- package/dist/react/index.d.ts +243 -58
- package/dist/react/index.js +278 -90
- package/dist/schema.d.ts +27 -1
- package/dist/schema.js +3 -1
- package/dist/{submission-input-CYyH_25w.d.ts → submission-input-C0cOmO4Q.d.ts} +15 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
|
+
cosmosChainList,
|
|
3
|
+
cosmosChainsError,
|
|
2
4
|
createBrowserRelayClient,
|
|
3
5
|
discoverCosmosWallets,
|
|
4
6
|
discoverEvmWallets,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
discoverSignInWallets,
|
|
8
|
+
discoverSolanaWallets,
|
|
9
|
+
readSignInMethods,
|
|
10
|
+
signInOptionsFrom
|
|
11
|
+
} from "../chunk-MVCKCDNR.js";
|
|
7
12
|
import {
|
|
8
13
|
RelayError,
|
|
9
14
|
avatarSrc,
|
|
10
15
|
defaultAvatar,
|
|
11
16
|
walletAvatarSeed
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
+
} from "../chunk-5LLU7UUV.js";
|
|
18
|
+
import "../chunk-YKS6P4IP.js";
|
|
19
|
+
import "../chunk-LAKQCIHX.js";
|
|
20
|
+
import "../chunk-MRKFRCCI.js";
|
|
21
|
+
import "../chunk-BE5V6RFD.js";
|
|
17
22
|
|
|
18
23
|
// src/react/provider.tsx
|
|
19
24
|
import { useState as useState3 } from "react";
|
|
@@ -538,7 +543,7 @@ function useQuest(observed) {
|
|
|
538
543
|
}
|
|
539
544
|
|
|
540
545
|
// src/react/auth.ts
|
|
541
|
-
import { useEffect as useEffect5, useState as useState6 } from "react";
|
|
546
|
+
import { useCallback as useCallback3, useEffect as useEffect5, useMemo as useMemo2, useRef as useRef2, useState as useState6 } from "react";
|
|
542
547
|
|
|
543
548
|
// src/react/wallets.ts
|
|
544
549
|
import { useCallback as useCallback2, useEffect as useEffect4, useState as useState5 } from "react";
|
|
@@ -605,16 +610,13 @@ function useWallets() {
|
|
|
605
610
|
}, "Couldn't unlink this wallet. Try again.")
|
|
606
611
|
};
|
|
607
612
|
}
|
|
608
|
-
function chainList(chains) {
|
|
609
|
-
return chains === void 0 ? [] : Array.isArray(chains) ? chains : [chains];
|
|
610
|
-
}
|
|
611
613
|
function discoverChains(key) {
|
|
612
614
|
return JSON.parse(key).flatMap(
|
|
613
615
|
(chain) => discoverCosmosWallets(chain)
|
|
614
616
|
);
|
|
615
617
|
}
|
|
616
618
|
function useWalletDiscovery(options = {}) {
|
|
617
|
-
const chains = JSON.stringify(
|
|
619
|
+
const chains = JSON.stringify(cosmosChainList(options.cosmos));
|
|
618
620
|
const [found, setFound] = useState5({ evm: [], solana: [], cosmos: [] });
|
|
619
621
|
useEffect4(() => {
|
|
620
622
|
let active = true;
|
|
@@ -633,7 +635,9 @@ function useWalletDiscovery(options = {}) {
|
|
|
633
635
|
return found;
|
|
634
636
|
}
|
|
635
637
|
function useSignInWallets(networks, options = {}) {
|
|
636
|
-
const chains = JSON.stringify(
|
|
638
|
+
const chains = JSON.stringify(
|
|
639
|
+
cosmosChainsError(options.cosmos) ? [] : cosmosChainList(options.cosmos)
|
|
640
|
+
);
|
|
637
641
|
const key = networks ? `${networks.join(" ")}
|
|
638
642
|
${chains}` : null;
|
|
639
643
|
const [found, setFound] = useState5(null);
|
|
@@ -643,16 +647,12 @@ ${chains}` : null;
|
|
|
643
647
|
}
|
|
644
648
|
let active = true;
|
|
645
649
|
const [families = "", cosmos = "[]"] = key.split("\n");
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
...enabled.includes("cosmos") ? tagged("cosmos", discoverChains(cosmos)) : []
|
|
651
|
-
];
|
|
652
|
-
const evm = enabled.includes("eip155") ? discoverEvmWallets() : Promise.resolve([]);
|
|
653
|
-
void evm.then((wallets) => {
|
|
650
|
+
void discoverSignInWallets(
|
|
651
|
+
families.split(" ").filter(Boolean),
|
|
652
|
+
JSON.parse(cosmos)
|
|
653
|
+
).catch(() => []).then((wallets) => {
|
|
654
654
|
if (active) {
|
|
655
|
-
setFound({ key, wallets
|
|
655
|
+
setFound({ key, wallets });
|
|
656
656
|
}
|
|
657
657
|
});
|
|
658
658
|
return () => {
|
|
@@ -668,18 +668,11 @@ function useSignInMethods() {
|
|
|
668
668
|
const [methods, setMethods] = useState6(null);
|
|
669
669
|
useEffect5(() => {
|
|
670
670
|
let active = true;
|
|
671
|
-
relay
|
|
672
|
-
if (
|
|
673
|
-
|
|
671
|
+
void readSignInMethods(relay).then((result) => {
|
|
672
|
+
if (active) {
|
|
673
|
+
setMethods(result);
|
|
674
674
|
}
|
|
675
|
-
|
|
676
|
-
providers: result.providers.filter((p) => p.configured).map((p) => p.provider),
|
|
677
|
-
email: result.email,
|
|
678
|
-
wallets: result.wallets
|
|
679
|
-
});
|
|
680
|
-
}).catch(
|
|
681
|
-
() => active && setMethods({ providers: [], email: true, wallets: [] })
|
|
682
|
-
);
|
|
675
|
+
});
|
|
683
676
|
return () => {
|
|
684
677
|
active = false;
|
|
685
678
|
};
|
|
@@ -696,62 +689,86 @@ function useMe() {
|
|
|
696
689
|
return;
|
|
697
690
|
}
|
|
698
691
|
let active = true;
|
|
699
|
-
|
|
700
|
-
read();
|
|
701
|
-
window.addEventListener(WALLETS_CHANGED, read);
|
|
692
|
+
void relay.me.get().then((value) => active && setMe(value)).catch(() => active && setMe(null));
|
|
702
693
|
return () => {
|
|
703
694
|
active = false;
|
|
704
|
-
window.removeEventListener(WALLETS_CHANGED, read);
|
|
705
695
|
};
|
|
706
696
|
}, [relay, member]);
|
|
707
697
|
return me;
|
|
708
698
|
}
|
|
709
699
|
function useSignIn() {
|
|
710
700
|
const relay = useRelay();
|
|
711
|
-
const [challenge,
|
|
701
|
+
const [challenge, setChallengeState] = useState6(null);
|
|
702
|
+
const latest = useRef2(null);
|
|
712
703
|
const [busy, setBusy] = useState6(false);
|
|
713
704
|
const [error, setError] = useState6(null);
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
705
|
+
const setChallenge = useCallback3((value) => {
|
|
706
|
+
latest.current = value;
|
|
707
|
+
setChallengeState(value);
|
|
708
|
+
}, []);
|
|
709
|
+
const run = useCallback3(
|
|
710
|
+
async (task, fallback) => {
|
|
711
|
+
setBusy(true);
|
|
712
|
+
setError(null);
|
|
713
|
+
try {
|
|
714
|
+
await task();
|
|
715
|
+
} catch (cause) {
|
|
716
|
+
setError(
|
|
717
|
+
cause instanceof Error && cause.message ? cause.message : fallback
|
|
718
|
+
);
|
|
719
|
+
} finally {
|
|
720
|
+
setBusy(false);
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
[]
|
|
724
|
+
);
|
|
725
|
+
const sendCode = useCallback3(
|
|
726
|
+
(email) => run(async () => {
|
|
727
|
+
setChallenge(null);
|
|
733
728
|
setChallenge((await relay.auth.emailStart(email)).challenge);
|
|
734
729
|
}, "Couldn't send a code. Check the address and try again."),
|
|
735
|
-
|
|
736
|
-
|
|
730
|
+
[relay, run, setChallenge]
|
|
731
|
+
);
|
|
732
|
+
const verifyCode = useCallback3(
|
|
733
|
+
(code) => run(async () => {
|
|
734
|
+
const sent = latest.current;
|
|
735
|
+
if (!sent) {
|
|
737
736
|
throw new Error("Request a new code first.");
|
|
738
737
|
}
|
|
739
|
-
await relay.auth.emailVerify(
|
|
738
|
+
await relay.auth.emailVerify(sent, code.trim());
|
|
740
739
|
setChallenge(null);
|
|
741
740
|
}, "That code didn't work. Check it, or request a new one."),
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
741
|
+
[relay, run, setChallenge]
|
|
742
|
+
);
|
|
743
|
+
const startOver = useCallback3(() => {
|
|
744
|
+
setChallenge(null);
|
|
745
|
+
setError(null);
|
|
746
|
+
}, [setChallenge]);
|
|
747
|
+
const withProvider = useCallback3(
|
|
748
|
+
(provider) => run(async () => {
|
|
747
749
|
const { url } = await relay.auth.start(provider, "sign-in");
|
|
748
750
|
window.location.assign(url);
|
|
749
751
|
}, "Couldn't start sign-in. Try again."),
|
|
750
|
-
|
|
751
|
-
|
|
752
|
+
[relay, run]
|
|
753
|
+
);
|
|
754
|
+
const withWallet = useCallback3(
|
|
755
|
+
(signer) => run(async () => {
|
|
752
756
|
await relay.auth.wallet.signIn(signer);
|
|
753
757
|
setChallenge(null);
|
|
754
|
-
}, "Couldn't sign in with this wallet. Try again.")
|
|
758
|
+
}, "Couldn't sign in with this wallet. Try again."),
|
|
759
|
+
[relay, run, setChallenge]
|
|
760
|
+
);
|
|
761
|
+
return {
|
|
762
|
+
busy,
|
|
763
|
+
error,
|
|
764
|
+
/** True once a code was sent and the form should ask for it. */
|
|
765
|
+
codeSent: challenge !== null,
|
|
766
|
+
sendCode,
|
|
767
|
+
verifyCode,
|
|
768
|
+
startOver,
|
|
769
|
+
withProvider,
|
|
770
|
+
/** Signs in, or signs up, with a wallet; the wallet asks the participant to sign a message. */
|
|
771
|
+
withWallet
|
|
755
772
|
};
|
|
756
773
|
}
|
|
757
774
|
function useSignOut() {
|
|
@@ -769,9 +786,55 @@ function useSignOut() {
|
|
|
769
786
|
}
|
|
770
787
|
};
|
|
771
788
|
}
|
|
789
|
+
function useSignInOptions(input = {}) {
|
|
790
|
+
const chains = JSON.stringify(cosmosChainList(input.cosmos));
|
|
791
|
+
const cosmos = useMemo2(
|
|
792
|
+
() => JSON.parse(chains),
|
|
793
|
+
[chains]
|
|
794
|
+
);
|
|
795
|
+
const methods = useSignInMethods();
|
|
796
|
+
const wallets = useSignInWallets(methods?.wallets, { cosmos });
|
|
797
|
+
const {
|
|
798
|
+
busy,
|
|
799
|
+
error,
|
|
800
|
+
codeSent,
|
|
801
|
+
startOver,
|
|
802
|
+
sendCode,
|
|
803
|
+
verifyCode,
|
|
804
|
+
withProvider,
|
|
805
|
+
withWallet
|
|
806
|
+
} = useSignIn();
|
|
807
|
+
const built = useMemo2(() => {
|
|
808
|
+
if (!methods) {
|
|
809
|
+
return null;
|
|
810
|
+
}
|
|
811
|
+
if (!wallets && methods.providers.length === 0 && !methods.email) {
|
|
812
|
+
return null;
|
|
813
|
+
}
|
|
814
|
+
return signInOptionsFrom(methods, wallets ?? [], {
|
|
815
|
+
cosmos,
|
|
816
|
+
walletsPending: !wallets,
|
|
817
|
+
actions: {
|
|
818
|
+
oauth: withProvider,
|
|
819
|
+
sendCode,
|
|
820
|
+
verifyCode,
|
|
821
|
+
wallet: withWallet
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
}, [methods, wallets, cosmos, withProvider, sendCode, verifyCode, withWallet]);
|
|
825
|
+
return {
|
|
826
|
+
options: built?.options ?? null,
|
|
827
|
+
unavailable: built?.unavailable ?? [],
|
|
828
|
+
methodsError: methods?.error ?? null,
|
|
829
|
+
busy,
|
|
830
|
+
error,
|
|
831
|
+
codeSent,
|
|
832
|
+
startOver
|
|
833
|
+
};
|
|
834
|
+
}
|
|
772
835
|
|
|
773
836
|
// src/react/accounts.ts
|
|
774
|
-
import { useCallback as
|
|
837
|
+
import { useCallback as useCallback4, useEffect as useEffect6, useState as useState7 } from "react";
|
|
775
838
|
var CHANGED = "relay-accounts-changed";
|
|
776
839
|
function isConnected(accounts, provider) {
|
|
777
840
|
return Boolean(
|
|
@@ -786,7 +849,7 @@ function useAccounts() {
|
|
|
786
849
|
const [accounts, setAccounts] = useState7(null);
|
|
787
850
|
const [error, setError] = useState7(null);
|
|
788
851
|
const [busy, setBusy] = useState7(false);
|
|
789
|
-
const refresh =
|
|
852
|
+
const refresh = useCallback4(async () => {
|
|
790
853
|
try {
|
|
791
854
|
setAccounts(await relay.auth.accounts());
|
|
792
855
|
setError(null);
|
|
@@ -842,7 +905,7 @@ function useAccounts() {
|
|
|
842
905
|
}
|
|
843
906
|
|
|
844
907
|
// src/react/profiles.ts
|
|
845
|
-
import { useCallback as
|
|
908
|
+
import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef3, useState as useState8 } from "react";
|
|
846
909
|
var PROFILE_CHANGED = "relay-profile-changed";
|
|
847
910
|
function useMyProfile() {
|
|
848
911
|
const relay = useRelay();
|
|
@@ -850,8 +913,8 @@ function useMyProfile() {
|
|
|
850
913
|
const [profile, setProfile] = useState8(null);
|
|
851
914
|
const [error, setError] = useState8(null);
|
|
852
915
|
const [busy, setBusy] = useState8(false);
|
|
853
|
-
const session =
|
|
854
|
-
const refresh =
|
|
916
|
+
const session = useRef3(null);
|
|
917
|
+
const refresh = useCallback5(async () => {
|
|
855
918
|
try {
|
|
856
919
|
const [current, value] = await Promise.all([
|
|
857
920
|
relay.auth.session(),
|
|
@@ -919,26 +982,26 @@ function useMyProfile() {
|
|
|
919
982
|
)
|
|
920
983
|
};
|
|
921
984
|
}
|
|
922
|
-
function
|
|
923
|
-
const relay = useRelay();
|
|
985
|
+
function useProfileRead(read, intervalMs, fallback) {
|
|
924
986
|
const { member } = useExperience();
|
|
925
|
-
const
|
|
926
|
-
|
|
927
|
-
|
|
987
|
+
const [state, setState] = useState8({
|
|
988
|
+
status: "loading"
|
|
989
|
+
});
|
|
990
|
+
const refresh = useCallback5(async () => {
|
|
928
991
|
try {
|
|
929
|
-
const
|
|
930
|
-
setState({ status: "ready",
|
|
992
|
+
const value = await read();
|
|
993
|
+
setState({ status: "ready", value, stale: null });
|
|
931
994
|
} catch (cause) {
|
|
932
995
|
if (cause instanceof RelayError && cause.status === 404) {
|
|
933
996
|
setState({ status: "missing" });
|
|
934
997
|
return;
|
|
935
998
|
}
|
|
936
|
-
const message = cause instanceof Error && cause.message ? cause.message :
|
|
999
|
+
const message = cause instanceof Error && cause.message ? cause.message : fallback;
|
|
937
1000
|
setState(
|
|
938
1001
|
(previous) => previous.status === "ready" ? { ...previous, stale: message } : { status: "error", message }
|
|
939
1002
|
);
|
|
940
1003
|
}
|
|
941
|
-
}, [
|
|
1004
|
+
}, [read, fallback]);
|
|
942
1005
|
useEffect7(() => {
|
|
943
1006
|
setState({ status: "loading" });
|
|
944
1007
|
void refresh();
|
|
@@ -954,11 +1017,132 @@ function useProfile(id, options = {}) {
|
|
|
954
1017
|
window.removeEventListener(PROFILE_CHANGED, changed);
|
|
955
1018
|
};
|
|
956
1019
|
}, [refresh, member, intervalMs]);
|
|
1020
|
+
return { state, refresh };
|
|
1021
|
+
}
|
|
1022
|
+
function useProfile(id, options = {}) {
|
|
1023
|
+
const relay = useRelay();
|
|
1024
|
+
const read = useCallback5(() => relay.profiles.get(id), [relay, id]);
|
|
1025
|
+
const { state, refresh } = useProfileRead(
|
|
1026
|
+
read,
|
|
1027
|
+
options.intervalMs ?? 6e4,
|
|
1028
|
+
"Could not load the profile."
|
|
1029
|
+
);
|
|
1030
|
+
const value = state.status === "ready" ? { status: "ready", profile: state.value, stale: state.stale } : state;
|
|
1031
|
+
return { ...value, refresh };
|
|
1032
|
+
}
|
|
1033
|
+
function useLeaderboardPlacement(board, profile, options = {}) {
|
|
1034
|
+
const relay = useRelay();
|
|
1035
|
+
const read = useCallback5(
|
|
1036
|
+
() => relay.leaderboards.placement(board, profile),
|
|
1037
|
+
[relay, board, profile]
|
|
1038
|
+
);
|
|
1039
|
+
const { state, refresh } = useProfileRead(
|
|
1040
|
+
read,
|
|
1041
|
+
options.intervalMs ?? 3e4,
|
|
1042
|
+
"Could not load the leaderboard placement."
|
|
1043
|
+
);
|
|
957
1044
|
return { ...state, refresh };
|
|
958
1045
|
}
|
|
1046
|
+
function useProfileReferral(profile, program, options = {}) {
|
|
1047
|
+
const relay = useRelay();
|
|
1048
|
+
const read = useCallback5(
|
|
1049
|
+
() => relay.profiles.referral(profile, program),
|
|
1050
|
+
[relay, profile, program]
|
|
1051
|
+
);
|
|
1052
|
+
const { state, refresh } = useProfileRead(
|
|
1053
|
+
read,
|
|
1054
|
+
options.intervalMs ?? 6e4,
|
|
1055
|
+
"Could not load referral progress."
|
|
1056
|
+
);
|
|
1057
|
+
return { ...state, refresh };
|
|
1058
|
+
}
|
|
1059
|
+
function useProfileCompletions(profile, options = {}) {
|
|
1060
|
+
const relay = useRelay();
|
|
1061
|
+
const { member } = useExperience();
|
|
1062
|
+
const { limit = 20 } = options;
|
|
1063
|
+
const [state, setState] = useState8({
|
|
1064
|
+
status: "loading"
|
|
1065
|
+
});
|
|
1066
|
+
const cursor = useRef3(null);
|
|
1067
|
+
const generation = useRef3(0);
|
|
1068
|
+
const paging = useRef3({ ready: false, busy: false });
|
|
1069
|
+
const load = useCallback5(
|
|
1070
|
+
async (first) => {
|
|
1071
|
+
if (first) {
|
|
1072
|
+
generation.current++;
|
|
1073
|
+
paging.current = { ready: false, busy: false };
|
|
1074
|
+
} else {
|
|
1075
|
+
if (!paging.current.ready || paging.current.busy || cursor.current === null) {
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
paging.current.busy = true;
|
|
1079
|
+
setState(
|
|
1080
|
+
(previous) => previous.status === "ready" ? { ...previous, loading: true, error: null } : previous
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
const current = generation.current;
|
|
1084
|
+
const own = paging.current;
|
|
1085
|
+
try {
|
|
1086
|
+
const page = await relay.profiles.completions(profile, {
|
|
1087
|
+
limit,
|
|
1088
|
+
...!first && cursor.current ? { cursor: cursor.current } : {}
|
|
1089
|
+
});
|
|
1090
|
+
if (current !== generation.current) {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
cursor.current = page.nextCursor;
|
|
1094
|
+
own.ready = true;
|
|
1095
|
+
setState((previous) => ({
|
|
1096
|
+
status: "ready",
|
|
1097
|
+
items: !first && previous.status === "ready" ? [...previous.items, ...page.items] : page.items,
|
|
1098
|
+
more: page.nextCursor !== null,
|
|
1099
|
+
loading: false,
|
|
1100
|
+
error: null
|
|
1101
|
+
}));
|
|
1102
|
+
} catch (cause) {
|
|
1103
|
+
if (current !== generation.current) {
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
if (first && cause instanceof RelayError && cause.status === 404) {
|
|
1107
|
+
setState({ status: "missing" });
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
const message = cause instanceof Error && cause.message ? cause.message : "Could not load completed quests.";
|
|
1111
|
+
setState(
|
|
1112
|
+
(previous) => !first && previous.status === "ready" ? { ...previous, loading: false, error: message } : { status: "error", message }
|
|
1113
|
+
);
|
|
1114
|
+
} finally {
|
|
1115
|
+
if (!first) {
|
|
1116
|
+
own.busy = false;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
},
|
|
1120
|
+
[relay, profile, limit]
|
|
1121
|
+
);
|
|
1122
|
+
useEffect7(() => {
|
|
1123
|
+
setState({ status: "loading" });
|
|
1124
|
+
cursor.current = null;
|
|
1125
|
+
void load(true);
|
|
1126
|
+
const changed = () => void load(true);
|
|
1127
|
+
window.addEventListener(PROFILE_CHANGED, changed);
|
|
1128
|
+
return () => {
|
|
1129
|
+
generation.current++;
|
|
1130
|
+
window.removeEventListener(PROFILE_CHANGED, changed);
|
|
1131
|
+
};
|
|
1132
|
+
}, [load, member]);
|
|
1133
|
+
return {
|
|
1134
|
+
...state,
|
|
1135
|
+
refresh: () => load(true),
|
|
1136
|
+
/**
|
|
1137
|
+
* Appends the next page; does nothing while one loads, while the first page reloads, or when
|
|
1138
|
+
* there is none.
|
|
1139
|
+
*/
|
|
1140
|
+
loadMore: () => load(false)
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
959
1143
|
|
|
960
1144
|
// src/react/referrals.ts
|
|
961
|
-
import { useCallback as
|
|
1145
|
+
import { useCallback as useCallback6, useEffect as useEffect8, useRef as useRef4, useState as useState9 } from "react";
|
|
962
1146
|
var PENDING = "domino:pending-referral";
|
|
963
1147
|
var CODE = /^[a-zA-Z0-9_-]{1,100}$/;
|
|
964
1148
|
function captureReferralCode(param = "ref") {
|
|
@@ -988,8 +1172,8 @@ function useInvitation(param = "ref") {
|
|
|
988
1172
|
const code = captureReferralCode(param);
|
|
989
1173
|
return code ? { status: "pending", code } : { status: "none" };
|
|
990
1174
|
});
|
|
991
|
-
const started =
|
|
992
|
-
const accept =
|
|
1175
|
+
const started = useRef4(null);
|
|
1176
|
+
const accept = useCallback6(
|
|
993
1177
|
async (code) => {
|
|
994
1178
|
setState({ status: "accepting", code });
|
|
995
1179
|
try {
|
|
@@ -1023,7 +1207,7 @@ function useReferralSummary(options = {}) {
|
|
|
1023
1207
|
const { member } = useExperience();
|
|
1024
1208
|
const [summary, setSummary] = useState9(null);
|
|
1025
1209
|
const [error, setError] = useState9(null);
|
|
1026
|
-
const refresh =
|
|
1210
|
+
const refresh = useCallback6(async () => {
|
|
1027
1211
|
try {
|
|
1028
1212
|
setSummary(await relay.referrals.summary());
|
|
1029
1213
|
setError(null);
|
|
@@ -1049,13 +1233,13 @@ function useReferralSummary(options = {}) {
|
|
|
1049
1233
|
}
|
|
1050
1234
|
|
|
1051
1235
|
// src/react/leaderboards.ts
|
|
1052
|
-
import { useCallback as
|
|
1236
|
+
import { useCallback as useCallback7, useEffect as useEffect9, useState as useState10 } from "react";
|
|
1053
1237
|
function useLeaderboard(board, options = {}) {
|
|
1054
1238
|
const relay = useRelay();
|
|
1055
1239
|
const { member } = useExperience();
|
|
1056
1240
|
const { limit = 25, intervalMs = 3e4 } = options;
|
|
1057
1241
|
const [state, setState] = useState10({ status: "loading" });
|
|
1058
|
-
const refresh =
|
|
1242
|
+
const refresh = useCallback7(async () => {
|
|
1059
1243
|
try {
|
|
1060
1244
|
const page = await relay.leaderboards.standings(board, { limit });
|
|
1061
1245
|
setState({ status: "ready", page, stale: null });
|
|
@@ -1079,11 +1263,11 @@ function useLeaderboard(board, options = {}) {
|
|
|
1079
1263
|
}
|
|
1080
1264
|
|
|
1081
1265
|
// src/react/references.ts
|
|
1082
|
-
import { useCallback as
|
|
1266
|
+
import { useCallback as useCallback8, useEffect as useEffect10, useState as useState11 } from "react";
|
|
1083
1267
|
function useReferences(read, failure) {
|
|
1084
1268
|
const relay = useRelay();
|
|
1085
1269
|
const [state, setState] = useState11({ status: "loading" });
|
|
1086
|
-
const refresh =
|
|
1270
|
+
const refresh = useCallback8(async () => {
|
|
1087
1271
|
try {
|
|
1088
1272
|
setState({ status: "ready", items: await read(relay) });
|
|
1089
1273
|
} catch (cause) {
|
|
@@ -1132,15 +1316,19 @@ export {
|
|
|
1132
1316
|
useExperience,
|
|
1133
1317
|
useInvitation,
|
|
1134
1318
|
useLeaderboard,
|
|
1319
|
+
useLeaderboardPlacement,
|
|
1135
1320
|
useMe,
|
|
1136
1321
|
useMyProfile,
|
|
1137
1322
|
usePointLedgers,
|
|
1138
1323
|
useProfile,
|
|
1324
|
+
useProfileCompletions,
|
|
1325
|
+
useProfileReferral,
|
|
1139
1326
|
useQuest,
|
|
1140
1327
|
useReferralSummary,
|
|
1141
1328
|
useRelay,
|
|
1142
1329
|
useSignIn,
|
|
1143
1330
|
useSignInMethods,
|
|
1331
|
+
useSignInOptions,
|
|
1144
1332
|
useSignInWallets,
|
|
1145
1333
|
useSignOut,
|
|
1146
1334
|
useTieredRewards,
|
package/dist/schema.d.ts
CHANGED
|
@@ -310,6 +310,14 @@ declare const questPresentationSchema: z.ZodObject<{
|
|
|
310
310
|
}, z.core.$strict>>;
|
|
311
311
|
}, z.core.$strict>;
|
|
312
312
|
type QuestPresentation = z.infer<typeof questPresentationSchema>;
|
|
313
|
+
/**
|
|
314
|
+
* How a quest appears on participant profiles. Hidden by default: a completion can reveal what a
|
|
315
|
+
* member holds or did, so each quest opts in.
|
|
316
|
+
*/
|
|
317
|
+
declare const questProfileSchema: z.ZodObject<{
|
|
318
|
+
visible: z.ZodBoolean;
|
|
319
|
+
}, z.core.$strict>;
|
|
320
|
+
type QuestProfile = z.infer<typeof questProfileSchema>;
|
|
313
321
|
declare const questDescriptionSchema: z.ZodObject<{
|
|
314
322
|
quest: z.ZodString;
|
|
315
323
|
runtimeVersion: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>>;
|
|
@@ -544,6 +552,9 @@ declare const questDescriptionSchema: z.ZodObject<{
|
|
|
544
552
|
visible: "visible";
|
|
545
553
|
hidden: "hidden";
|
|
546
554
|
}>>;
|
|
555
|
+
profile: z.ZodOptional<z.ZodObject<{
|
|
556
|
+
visible: z.ZodBoolean;
|
|
557
|
+
}, z.core.$strict>>;
|
|
547
558
|
budgets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
548
559
|
id: z.ZodString;
|
|
549
560
|
scope: z.ZodEnum<{
|
|
@@ -851,6 +862,9 @@ declare const publishedReleaseSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
851
862
|
visible: "visible";
|
|
852
863
|
hidden: "hidden";
|
|
853
864
|
}>>;
|
|
865
|
+
profile: z.ZodOptional<z.ZodObject<{
|
|
866
|
+
visible: z.ZodBoolean;
|
|
867
|
+
}, z.core.$strict>>;
|
|
854
868
|
budgets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
855
869
|
id: z.ZodString;
|
|
856
870
|
scope: z.ZodEnum<{
|
|
@@ -1155,6 +1169,9 @@ declare const publishedReleaseSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1155
1169
|
metrics: ("likes" | "replies" | "reposts" | "quotes" | "views" | "bookmarks")[];
|
|
1156
1170
|
maxAgeMs: number;
|
|
1157
1171
|
} | undefined;
|
|
1172
|
+
profile?: {
|
|
1173
|
+
visible: boolean;
|
|
1174
|
+
} | undefined;
|
|
1158
1175
|
key?: string | undefined;
|
|
1159
1176
|
origin?: {
|
|
1160
1177
|
typeVersion: string;
|
|
@@ -1454,6 +1471,9 @@ declare const templateSchema: z.ZodObject<{
|
|
|
1454
1471
|
visible: "visible";
|
|
1455
1472
|
hidden: "hidden";
|
|
1456
1473
|
}>>;
|
|
1474
|
+
profile: z.ZodOptional<z.ZodObject<{
|
|
1475
|
+
visible: z.ZodBoolean;
|
|
1476
|
+
}, z.core.$strict>>;
|
|
1457
1477
|
budgets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1458
1478
|
id: z.ZodString;
|
|
1459
1479
|
scope: z.ZodEnum<{
|
|
@@ -2363,6 +2383,9 @@ declare const snapshotSchema: z.ZodObject<{
|
|
|
2363
2383
|
visible: "visible";
|
|
2364
2384
|
hidden: "hidden";
|
|
2365
2385
|
}>>;
|
|
2386
|
+
profile: z.ZodOptional<z.ZodObject<{
|
|
2387
|
+
visible: z.ZodBoolean;
|
|
2388
|
+
}, z.core.$strict>>;
|
|
2366
2389
|
budgets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
2367
2390
|
id: z.ZodString;
|
|
2368
2391
|
scope: z.ZodEnum<{
|
|
@@ -2667,6 +2690,9 @@ declare const snapshotSchema: z.ZodObject<{
|
|
|
2667
2690
|
metrics: ("likes" | "replies" | "reposts" | "quotes" | "views" | "bookmarks")[];
|
|
2668
2691
|
maxAgeMs: number;
|
|
2669
2692
|
} | undefined;
|
|
2693
|
+
profile?: {
|
|
2694
|
+
visible: boolean;
|
|
2695
|
+
} | undefined;
|
|
2670
2696
|
key?: string | undefined;
|
|
2671
2697
|
origin?: {
|
|
2672
2698
|
typeVersion: string;
|
|
@@ -3212,4 +3238,4 @@ declare const contentPerformancePageSchema: z.ZodObject<{
|
|
|
3212
3238
|
next: z.ZodNullable<z.ZodNumber>;
|
|
3213
3239
|
}, z.core.$strict>;
|
|
3214
3240
|
|
|
3215
|
-
export { type Attempt, type ContentPerformanceSnapshot, type Decision, type Entitlement, type MemberPage, type MemberProgress, type PhotoResult, type PickupAvailability, type PublishedRelease, type QuestAvailability, type QuestDescription, type QuestPresentation, type QuestSettingsInput, type QuizEvidence, type ReleaseInput, type ReviewPage, type Reward, type Snapshot, type SubmissionEvidence, type SubmitInput, type TextResult, type TextReviewInput, type TieredRewardDefinition, type TieredRewardReference, artifactSchema, attemptSchema, batchReleaseSchema, beginHandoverSchema, completionRecordSchema, configurePickupSchema, confirmHandoverSchema, contentPerformancePageSchema, contentPerformanceQuerySchema, contentPerformanceSnapshotSchema, createStockItemSchema, decisionSchema, entitlementSchema, errorSchema, eventSchema, evidenceSchema, identifier, integrationRewardSchema, mediaUrlSchema, memberListSchema, memberPageSchema, memberProgressSchema, photoResultSchema, pickupAllocationSchema, pickupAvailabilitySchema, pickupCatalogSchema, pickupPolicySchema, pickupSelectionSchema, pointsRewardSchema, prerequisiteSchema, publishedReleaseSchema, questAvailabilitySchema, questDescriptionSchema, questPresentationSchema, questSettingsInputSchema, quizAnswersSchema, quizEvidenceSchema, releaseSchema, reservationSchema, reviewItemSchema, reviewListSchema, reviewModeSchema, reviewPageSchema, rewardBundleSchema, rewardKey, rewardSchema, snapshotSchema, staffDecisionSchema, stockItemSchema, stockSchema, storedReviewModeSchema, submissionEvidenceSchema, submitSchema, templateSchema, textResultSchema, textReviewInputSchema, tierRewardSchema, tieredRewardDefinitionSchema, tieredRewardReferenceSchema, triggerSchema };
|
|
3241
|
+
export { type Attempt, type ContentPerformanceSnapshot, type Decision, type Entitlement, type MemberPage, type MemberProgress, type PhotoResult, type PickupAvailability, type PublishedRelease, type QuestAvailability, type QuestDescription, type QuestPresentation, type QuestProfile, type QuestSettingsInput, type QuizEvidence, type ReleaseInput, type ReviewPage, type Reward, type Snapshot, type SubmissionEvidence, type SubmitInput, type TextResult, type TextReviewInput, type TieredRewardDefinition, type TieredRewardReference, artifactSchema, attemptSchema, batchReleaseSchema, beginHandoverSchema, completionRecordSchema, configurePickupSchema, confirmHandoverSchema, contentPerformancePageSchema, contentPerformanceQuerySchema, contentPerformanceSnapshotSchema, createStockItemSchema, decisionSchema, entitlementSchema, errorSchema, eventSchema, evidenceSchema, identifier, integrationRewardSchema, mediaUrlSchema, memberListSchema, memberPageSchema, memberProgressSchema, photoResultSchema, pickupAllocationSchema, pickupAvailabilitySchema, pickupCatalogSchema, pickupPolicySchema, pickupSelectionSchema, pointsRewardSchema, prerequisiteSchema, publishedReleaseSchema, questAvailabilitySchema, questDescriptionSchema, questPresentationSchema, questProfileSchema, questSettingsInputSchema, quizAnswersSchema, quizEvidenceSchema, releaseSchema, reservationSchema, reviewItemSchema, reviewListSchema, reviewModeSchema, reviewPageSchema, rewardBundleSchema, rewardKey, rewardSchema, snapshotSchema, staffDecisionSchema, stockItemSchema, stockSchema, storedReviewModeSchema, submissionEvidenceSchema, submitSchema, templateSchema, textResultSchema, textReviewInputSchema, tierRewardSchema, tieredRewardDefinitionSchema, tieredRewardReferenceSchema, triggerSchema };
|
package/dist/schema.js
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
questAvailabilitySchema,
|
|
34
34
|
questDescriptionSchema,
|
|
35
35
|
questPresentationSchema,
|
|
36
|
+
questProfileSchema,
|
|
36
37
|
questSettingsInputSchema,
|
|
37
38
|
quizAnswersSchema,
|
|
38
39
|
quizEvidenceSchema,
|
|
@@ -59,7 +60,7 @@ import {
|
|
|
59
60
|
tieredRewardDefinitionSchema,
|
|
60
61
|
tieredRewardReferenceSchema,
|
|
61
62
|
triggerSchema
|
|
62
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-BE5V6RFD.js";
|
|
63
64
|
export {
|
|
64
65
|
artifactSchema,
|
|
65
66
|
attemptSchema,
|
|
@@ -95,6 +96,7 @@ export {
|
|
|
95
96
|
questAvailabilitySchema,
|
|
96
97
|
questDescriptionSchema,
|
|
97
98
|
questPresentationSchema,
|
|
99
|
+
questProfileSchema,
|
|
98
100
|
questSettingsInputSchema,
|
|
99
101
|
quizAnswersSchema,
|
|
100
102
|
quizEvidenceSchema,
|