@taskon/widget-react 0.0.1-beta.6 → 0.0.1-beta.7
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/README.md +48 -43
- package/dist/EligibilityInfo.css +2 -33
- package/dist/TaskOnProvider.css +287 -0
- package/dist/ThemeProvider.css +227 -0
- package/dist/UserCenterWidget2.css +32 -290
- package/dist/WidgetShell.css +0 -227
- package/dist/chunks/{CommunityTaskList-Hde2OKHH.js → CommunityTaskList-D0uVD8wD.js} +37 -58
- package/dist/chunks/{EligibilityInfo-BV0Z2TgY.js → EligibilityInfo-Cf6hx9-a.js} +17 -209
- package/dist/chunks/{LeaderboardWidget-BNGRD5Bu.js → LeaderboardWidget-DyoiiNS6.js} +10 -9
- package/dist/chunks/{PageBuilder-C5DSHiW9.js → PageBuilder-DoAFPm6-.js} +5 -5
- package/dist/chunks/{Quest-DG9zfXJo.js → Quest-ySZlYd4u.js} +6 -11
- package/dist/chunks/TaskOnProvider-CxtFIs3n.js +2072 -0
- package/dist/chunks/{WidgetShell-D7yC894Y.js → ThemeProvider-CulHkqqY.js} +1354 -617
- package/dist/chunks/UserCenterWidget-BJsc_GSZ.js +3246 -0
- package/dist/chunks/{UserCenterWidget-D5ttw4hO.js → UserCenterWidget-STq8kpV4.js} +162 -365
- package/dist/chunks/WidgetShell-8xn-Jivw.js +659 -0
- package/dist/chunks/useIsMobile-D6Ybur-6.js +30 -0
- package/dist/chunks/useToast-BGJhd3BX.js +93 -0
- package/dist/community-task.js +1 -1
- package/dist/core.d.ts +9 -15
- package/dist/core.js +3 -3
- package/dist/index.d.ts +64 -15
- package/dist/index.js +15 -10
- package/dist/leaderboard.js +1 -1
- package/dist/page-builder.js +1 -1
- package/dist/quest.js +1 -1
- package/dist/user-center.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/TaskOnProvider-BhamHIyY.js +0 -1260
- package/dist/chunks/ThemeProvider-mXLdLSkq.js +0 -1397
- package/dist/chunks/UserCenterWidget-jDO5zTN1.js +0 -3297
- package/dist/chunks/useToast-CaRkylKe.js +0 -304
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useContext, createContext, useMemo, useState, useCallback } from "react";
|
|
2
|
+
const defaultWalletContext = {
|
|
3
|
+
// EVM state
|
|
4
|
+
evmAdapter: null,
|
|
5
|
+
evmAddress: null,
|
|
6
|
+
evmChainId: null,
|
|
7
|
+
isEvmConnected: false,
|
|
8
|
+
// Detection status
|
|
9
|
+
isDetecting: true,
|
|
10
|
+
// Actions (no-op by default)
|
|
11
|
+
connectEvm: async () => null,
|
|
12
|
+
disconnectEvm: async () => {
|
|
13
|
+
},
|
|
14
|
+
signEvmMessage: async () => null
|
|
15
|
+
};
|
|
16
|
+
const WalletContext = createContext(defaultWalletContext);
|
|
17
|
+
function useWallet() {
|
|
18
|
+
const context = useContext(WalletContext);
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
21
|
+
function useEvmWallet() {
|
|
22
|
+
const context = useWallet();
|
|
23
|
+
return useMemo(
|
|
24
|
+
() => ({
|
|
25
|
+
adapter: context.evmAdapter,
|
|
26
|
+
address: context.evmAddress,
|
|
27
|
+
chainId: context.evmChainId,
|
|
28
|
+
isConnected: context.isEvmConnected,
|
|
29
|
+
connect: context.connectEvm,
|
|
30
|
+
disconnect: context.disconnectEvm,
|
|
31
|
+
signMessage: context.signEvmMessage
|
|
32
|
+
}),
|
|
33
|
+
[
|
|
34
|
+
context.evmAdapter,
|
|
35
|
+
context.evmAddress,
|
|
36
|
+
context.evmChainId,
|
|
37
|
+
context.isEvmConnected,
|
|
38
|
+
context.connectEvm,
|
|
39
|
+
context.disconnectEvm,
|
|
40
|
+
context.signEvmMessage
|
|
41
|
+
]
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const ToastContext = createContext(null);
|
|
45
|
+
function useToast() {
|
|
46
|
+
const context = useContext(ToastContext);
|
|
47
|
+
if (!context) {
|
|
48
|
+
throw new Error("useToast must be used within TaskOnProvider");
|
|
49
|
+
}
|
|
50
|
+
return context;
|
|
51
|
+
}
|
|
52
|
+
let toastId = 0;
|
|
53
|
+
function generateId() {
|
|
54
|
+
return `toast-${++toastId}-${Date.now()}`;
|
|
55
|
+
}
|
|
56
|
+
function useToastState() {
|
|
57
|
+
const [toasts, setToasts] = useState([]);
|
|
58
|
+
const showToast = useCallback(
|
|
59
|
+
(message, type = "info", duration) => {
|
|
60
|
+
const newToast = {
|
|
61
|
+
id: generateId(),
|
|
62
|
+
message,
|
|
63
|
+
type,
|
|
64
|
+
duration
|
|
65
|
+
};
|
|
66
|
+
setToasts((prev) => [...prev, newToast]);
|
|
67
|
+
},
|
|
68
|
+
[]
|
|
69
|
+
);
|
|
70
|
+
const removeToast = useCallback((id) => {
|
|
71
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
72
|
+
}, []);
|
|
73
|
+
const toast = {
|
|
74
|
+
success: (message, duration) => showToast(message, "success", duration),
|
|
75
|
+
error: (message, duration) => showToast(message, "error", duration),
|
|
76
|
+
warning: (message, duration) => showToast(message, "warning", duration),
|
|
77
|
+
info: (message, duration) => showToast(message, "info", duration)
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
toasts,
|
|
81
|
+
showToast,
|
|
82
|
+
removeToast,
|
|
83
|
+
toast
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
ToastContext as T,
|
|
88
|
+
WalletContext as W,
|
|
89
|
+
useEvmWallet as a,
|
|
90
|
+
useToastState as b,
|
|
91
|
+
useToast as c,
|
|
92
|
+
useWallet as u
|
|
93
|
+
};
|
package/dist/community-task.js
CHANGED
package/dist/core.d.ts
CHANGED
|
@@ -352,7 +352,7 @@ export declare interface TaskOnContextValue {
|
|
|
352
352
|
*/
|
|
353
353
|
chains: ChainInfo[];
|
|
354
354
|
/**
|
|
355
|
-
* Community info (auto-loaded on init based on
|
|
355
|
+
* Community info (auto-loaded on init based on clientId)
|
|
356
356
|
* Used for displaying community logo and name in reward cards
|
|
357
357
|
*/
|
|
358
358
|
communityInfo: CommunityInfo | null;
|
|
@@ -365,7 +365,7 @@ export declare interface TaskOnContextValue {
|
|
|
365
365
|
* - TaskOn client management (based on @taskon/core)
|
|
366
366
|
* - User authentication (login/logout)
|
|
367
367
|
* - Locale configuration
|
|
368
|
-
* - Wallet management (
|
|
368
|
+
* - Wallet management (host adapter or built-in wallet picker)
|
|
369
369
|
* - Widget locale preloading (optional)
|
|
370
370
|
* - Toast notifications (internal, user-transparent)
|
|
371
371
|
*/
|
|
@@ -376,10 +376,10 @@ export declare function TaskOnProvider({ config, children, preloadLocales, }: Ta
|
|
|
376
376
|
*/
|
|
377
377
|
export declare interface TaskOnProviderConfig {
|
|
378
378
|
/**
|
|
379
|
-
*
|
|
380
|
-
* Note:
|
|
379
|
+
* Client ID for authentication (X-API-Key header)
|
|
380
|
+
* Note: clientId already contains community info, no need to configure communityId/communityKey separately
|
|
381
381
|
*/
|
|
382
|
-
|
|
382
|
+
clientId: string;
|
|
383
383
|
/**
|
|
384
384
|
* API base URL (optional)
|
|
385
385
|
* @default https://white-label-api.taskon.xyz
|
|
@@ -393,8 +393,8 @@ export declare interface TaskOnProviderConfig {
|
|
|
393
393
|
/**
|
|
394
394
|
* Wallet configuration for blockchain interactions
|
|
395
395
|
*
|
|
396
|
-
* When not provided, TaskOn will use built-in
|
|
397
|
-
* for EVM wallet connections
|
|
396
|
+
* When not provided, TaskOn will use SDK built-in wallet picker adapter
|
|
397
|
+
* for EVM wallet connections.
|
|
398
398
|
*/
|
|
399
399
|
walletConfig?: WalletConfig;
|
|
400
400
|
/**
|
|
@@ -407,7 +407,7 @@ export declare interface TaskOnProviderConfig {
|
|
|
407
407
|
* ```tsx
|
|
408
408
|
* <TaskOnProvider
|
|
409
409
|
* config={{
|
|
410
|
-
*
|
|
410
|
+
* clientId: 'your-client-id',
|
|
411
411
|
* onRequestLogin: () => {
|
|
412
412
|
* setShowLoginModal(true);
|
|
413
413
|
* },
|
|
@@ -837,15 +837,9 @@ export declare interface WalletAdapter {
|
|
|
837
837
|
export declare interface WalletConfig {
|
|
838
838
|
/**
|
|
839
839
|
* Custom EVM wallet adapter
|
|
840
|
-
* If not provided, uses built-in
|
|
840
|
+
* If not provided, uses SDK built-in wallet picker adapter
|
|
841
841
|
*/
|
|
842
842
|
evmAdapter?: WalletAdapter;
|
|
843
|
-
/**
|
|
844
|
-
* Disable auto-detection of wallet providers
|
|
845
|
-
* When true, only uses adapter explicitly provided above
|
|
846
|
-
* @default false
|
|
847
|
-
*/
|
|
848
|
-
disableAutoDetect?: boolean;
|
|
849
843
|
}
|
|
850
844
|
|
|
851
845
|
/**
|
package/dist/core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { T, d, e, f, i, g, u, a, c, b } from "./chunks/ThemeProvider-
|
|
1
|
+
import { T, d, e, f, i, g, u, a, c, b } from "./chunks/ThemeProvider-CulHkqqY.js";
|
|
2
2
|
import { RewardType } from "@taskon/core";
|
|
3
|
-
import { T as T2, u as u2 } from "./chunks/TaskOnProvider-
|
|
4
|
-
import { a as a2, u as u3 } from "./chunks/useToast-
|
|
3
|
+
import { T as T2, u as u2 } from "./chunks/TaskOnProvider-CxtFIs3n.js";
|
|
4
|
+
import { a as a2, u as u3 } from "./chunks/useToast-BGJhd3BX.js";
|
|
5
5
|
export {
|
|
6
6
|
RewardType,
|
|
7
7
|
T2 as TaskOnProvider,
|
package/dist/index.d.ts
CHANGED
|
@@ -213,6 +213,30 @@ export declare function createLocaleLoader<T>(defaultMessages: T, imports: Local
|
|
|
213
213
|
*/
|
|
214
214
|
export declare function createT<T extends Record<string, string>>(messages: T): <K extends keyof T>(key: K, params?: InterpolationParams) => string;
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Ethereum Provider Interface (EIP-1193)
|
|
218
|
+
*
|
|
219
|
+
* Exported for scenarios where caller already owns a specific provider
|
|
220
|
+
* instance (e.g. wallet selection dialog) and needs to build an adapter
|
|
221
|
+
* around it.
|
|
222
|
+
*/
|
|
223
|
+
declare interface EthereumProvider {
|
|
224
|
+
request: (args: {
|
|
225
|
+
method: string;
|
|
226
|
+
params?: unknown[];
|
|
227
|
+
}) => Promise<unknown>;
|
|
228
|
+
on?: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
229
|
+
removeListener?: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export declare class EvmWalletSelectionCanceledError extends Error {
|
|
233
|
+
constructor(message?: string);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export declare class EvmWalletSelectionInProgressError extends Error {
|
|
237
|
+
constructor(message?: string);
|
|
238
|
+
}
|
|
239
|
+
|
|
216
240
|
/**
|
|
217
241
|
* Interpolate a string with parameters
|
|
218
242
|
*
|
|
@@ -581,6 +605,19 @@ export declare interface SeedToken {
|
|
|
581
605
|
spacingChangeUnit?: number;
|
|
582
606
|
}
|
|
583
607
|
|
|
608
|
+
export declare function selectEvmWallet(options?: SelectEvmWalletOptions): Promise<SelectEvmWalletResult>;
|
|
609
|
+
|
|
610
|
+
export declare interface SelectEvmWalletOptions {
|
|
611
|
+
signal?: AbortSignal;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export declare interface SelectEvmWalletResult {
|
|
615
|
+
walletId: string;
|
|
616
|
+
walletName: string;
|
|
617
|
+
address: string;
|
|
618
|
+
provider: EthereumProvider;
|
|
619
|
+
}
|
|
620
|
+
|
|
584
621
|
/**
|
|
585
622
|
* Locales recognized by the widget i18n runtime.
|
|
586
623
|
*
|
|
@@ -662,7 +699,7 @@ export declare interface TaskOnContextValue {
|
|
|
662
699
|
*/
|
|
663
700
|
chains: ChainInfo[];
|
|
664
701
|
/**
|
|
665
|
-
* Community info (auto-loaded on init based on
|
|
702
|
+
* Community info (auto-loaded on init based on clientId)
|
|
666
703
|
* Used for displaying community logo and name in reward cards
|
|
667
704
|
*/
|
|
668
705
|
communityInfo: CommunityInfo | null;
|
|
@@ -675,7 +712,7 @@ export declare interface TaskOnContextValue {
|
|
|
675
712
|
* - TaskOn client management (based on @taskon/core)
|
|
676
713
|
* - User authentication (login/logout)
|
|
677
714
|
* - Locale configuration
|
|
678
|
-
* - Wallet management (
|
|
715
|
+
* - Wallet management (host adapter or built-in wallet picker)
|
|
679
716
|
* - Widget locale preloading (optional)
|
|
680
717
|
* - Toast notifications (internal, user-transparent)
|
|
681
718
|
*/
|
|
@@ -686,10 +723,10 @@ export declare function TaskOnProvider({ config, children, preloadLocales, }: Ta
|
|
|
686
723
|
*/
|
|
687
724
|
export declare interface TaskOnProviderConfig {
|
|
688
725
|
/**
|
|
689
|
-
*
|
|
690
|
-
* Note:
|
|
726
|
+
* Client ID for authentication (X-API-Key header)
|
|
727
|
+
* Note: clientId already contains community info, no need to configure communityId/communityKey separately
|
|
691
728
|
*/
|
|
692
|
-
|
|
729
|
+
clientId: string;
|
|
693
730
|
/**
|
|
694
731
|
* API base URL (optional)
|
|
695
732
|
* @default https://white-label-api.taskon.xyz
|
|
@@ -703,8 +740,8 @@ export declare interface TaskOnProviderConfig {
|
|
|
703
740
|
/**
|
|
704
741
|
* Wallet configuration for blockchain interactions
|
|
705
742
|
*
|
|
706
|
-
* When not provided, TaskOn will use built-in
|
|
707
|
-
* for EVM wallet connections
|
|
743
|
+
* When not provided, TaskOn will use SDK built-in wallet picker adapter
|
|
744
|
+
* for EVM wallet connections.
|
|
708
745
|
*/
|
|
709
746
|
walletConfig?: WalletConfig;
|
|
710
747
|
/**
|
|
@@ -717,7 +754,7 @@ export declare interface TaskOnProviderConfig {
|
|
|
717
754
|
* ```tsx
|
|
718
755
|
* <TaskOnProvider
|
|
719
756
|
* config={{
|
|
720
|
-
*
|
|
757
|
+
* clientId: 'your-client-id',
|
|
721
758
|
* onRequestLogin: () => {
|
|
722
759
|
* setShowLoginModal(true);
|
|
723
760
|
* },
|
|
@@ -1197,15 +1234,9 @@ export declare interface WalletAdapter {
|
|
|
1197
1234
|
export declare interface WalletConfig {
|
|
1198
1235
|
/**
|
|
1199
1236
|
* Custom EVM wallet adapter
|
|
1200
|
-
* If not provided, uses built-in
|
|
1237
|
+
* If not provided, uses SDK built-in wallet picker adapter
|
|
1201
1238
|
*/
|
|
1202
1239
|
evmAdapter?: WalletAdapter;
|
|
1203
|
-
/**
|
|
1204
|
-
* Disable auto-detection of wallet providers
|
|
1205
|
-
* When true, only uses adapter explicitly provided above
|
|
1206
|
-
* @default false
|
|
1207
|
-
*/
|
|
1208
|
-
disableAutoDetect?: boolean;
|
|
1209
1240
|
}
|
|
1210
1241
|
|
|
1211
1242
|
/**
|
|
@@ -1217,6 +1248,24 @@ declare interface WalletContextValue extends WalletState {
|
|
|
1217
1248
|
signEvmMessage: (message: string) => Promise<string | null>;
|
|
1218
1249
|
}
|
|
1219
1250
|
|
|
1251
|
+
export declare function WalletPickerDialog({ open, onOpenChange, onSelect, onError, }: WalletPickerDialogProps): default_2.ReactElement;
|
|
1252
|
+
|
|
1253
|
+
export declare function WalletPickerDialogHost(): default_2.ReactElement;
|
|
1254
|
+
|
|
1255
|
+
export declare interface WalletPickerDialogProps {
|
|
1256
|
+
open: boolean;
|
|
1257
|
+
onOpenChange: (open: boolean) => void;
|
|
1258
|
+
onSelect?: (selection: WalletPickerSelection) => Promise<void>;
|
|
1259
|
+
onError?: (error: string) => void;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
export declare interface WalletPickerSelection {
|
|
1263
|
+
walletId: string;
|
|
1264
|
+
walletName: string;
|
|
1265
|
+
address: string;
|
|
1266
|
+
provider: any;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1220
1269
|
/**
|
|
1221
1270
|
* Wallet state exposed through context
|
|
1222
1271
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { c } from "./chunks/WidgetShell-
|
|
2
|
-
import { T, d, e, f, i, g, u, a, c as c2, b } from "./chunks/ThemeProvider-
|
|
1
|
+
import { c } from "./chunks/WidgetShell-8xn-Jivw.js";
|
|
2
|
+
import { T, d, e, f, i, g, u, a, c as c2, b } from "./chunks/ThemeProvider-CulHkqqY.js";
|
|
3
3
|
import { RewardType } from "@taskon/core";
|
|
4
|
-
import { T as T2, u as u2 } from "./chunks/TaskOnProvider-
|
|
5
|
-
import { a as
|
|
6
|
-
import { C } from "./chunks/CommunityTaskList-
|
|
7
|
-
import { L } from "./chunks/LeaderboardWidget-
|
|
8
|
-
import { Q, Q as Q2 } from "./chunks/Quest-
|
|
9
|
-
import { U } from "./chunks/UserCenterWidget-
|
|
10
|
-
import { P } from "./chunks/PageBuilder-
|
|
4
|
+
import { E, b as b2, T as T2, W, a as a2, s, u as u2 } from "./chunks/TaskOnProvider-CxtFIs3n.js";
|
|
5
|
+
import { a as a3, u as u3 } from "./chunks/useToast-BGJhd3BX.js";
|
|
6
|
+
import { C } from "./chunks/CommunityTaskList-D0uVD8wD.js";
|
|
7
|
+
import { L } from "./chunks/LeaderboardWidget-DyoiiNS6.js";
|
|
8
|
+
import { Q, Q as Q2 } from "./chunks/Quest-ySZlYd4u.js";
|
|
9
|
+
import { U } from "./chunks/UserCenterWidget-BJsc_GSZ.js";
|
|
10
|
+
import { P } from "./chunks/PageBuilder-DoAFPm6-.js";
|
|
11
11
|
export {
|
|
12
12
|
C as CommunityTaskList,
|
|
13
|
+
E as EvmWalletSelectionCanceledError,
|
|
14
|
+
b2 as EvmWalletSelectionInProgressError,
|
|
13
15
|
L as LeaderboardWidget,
|
|
14
16
|
P as PageBuilder,
|
|
15
17
|
Q as Quest,
|
|
@@ -18,14 +20,17 @@ export {
|
|
|
18
20
|
T2 as TaskOnProvider,
|
|
19
21
|
T as ThemeProvider,
|
|
20
22
|
U as UserCenterWidget,
|
|
23
|
+
W as WalletPickerDialog,
|
|
24
|
+
a2 as WalletPickerDialogHost,
|
|
21
25
|
d as clearLocaleCache,
|
|
22
26
|
c as cloudThemeToReactTheme,
|
|
23
27
|
e as createLocaleLoader,
|
|
24
28
|
f as createT,
|
|
25
29
|
i as interpolate,
|
|
26
30
|
g as isSupportedLocale,
|
|
31
|
+
s as selectEvmWallet,
|
|
27
32
|
u2 as useCommonLocale,
|
|
28
|
-
|
|
33
|
+
a3 as useEvmWallet,
|
|
29
34
|
u as useTaskOnAuth,
|
|
30
35
|
a as useTaskOnTheme,
|
|
31
36
|
c2 as useTranslation,
|
package/dist/leaderboard.js
CHANGED
package/dist/page-builder.js
CHANGED
package/dist/quest.js
CHANGED
package/dist/user-center.js
CHANGED