@taskon/widget-react 0.0.1-beta.2 → 0.0.1-beta.3
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 +55 -16
- package/dist/CommunityTaskList.css +432 -628
- package/dist/EligibilityInfo.css +944 -431
- package/dist/PageBuilder.css +0 -2
- package/dist/Quest.css +460 -505
- package/dist/TaskOnProvider.css +15 -15
- package/dist/UserCenterWidget.css +0 -174
- package/dist/UserCenterWidget2.css +870 -102
- package/dist/chunks/{CommunityTaskList-BlH1Wdd5.js → CommunityTaskList-C9mPl_31.js} +913 -826
- package/dist/chunks/{EligibilityInfo-C7GZ2G5u.js → EligibilityInfo-DGBffKN8.js} +1137 -449
- package/dist/chunks/{LeaderboardWidget-CmYfDeHV.js → LeaderboardWidget-DPOQVXkT.js} +15 -10
- package/dist/chunks/{PageBuilder-Bw0zSkFh.js → PageBuilder-WCZvxL2j.js} +5 -5
- package/dist/chunks/{Quest-DKFZ-pPU.js → Quest-DjGH_8bx.js} +464 -314
- package/dist/chunks/{TaskOnProvider-BD6Vp2x8.js → TaskOnProvider-iannERG1.js} +2 -207
- package/dist/chunks/{ThemeProvider-wnSXrNQb.js → ThemeProvider-DNJqI2lD.js} +246 -54
- package/dist/chunks/UserCenterWidget-B0O-f_xl.js +8344 -0
- package/dist/chunks/{UserCenterWidget-Cw6h_5hT.js → UserCenterWidget-CAhgp46j.js} +204 -1001
- package/dist/chunks/{WidgetShell-D_5OjvNZ.js → dynamic-import-helper-B2j_dZ4V.js} +607 -40
- package/dist/chunks/useToast-CaRkylKe.js +304 -0
- package/dist/chunks/{usercenter-ja-uu-XfVF9.js → usercenter-ja-B2465c1O.js} +4 -10
- package/dist/chunks/{usercenter-ko-DYgUOVzd.js → usercenter-ko-xAEYxqLg.js} +4 -10
- package/dist/community-task.d.ts +34 -3
- package/dist/community-task.js +1 -1
- package/dist/core.d.ts +40 -3
- package/dist/core.js +9 -10
- package/dist/dynamic-import-helper.css +186 -0
- package/dist/index.d.ts +207 -10
- package/dist/index.js +21 -19
- package/dist/leaderboard.d.ts +8 -1
- package/dist/leaderboard.js +2 -2
- package/dist/page-builder.js +1 -1
- package/dist/quest.d.ts +8 -2
- package/dist/quest.js +1 -1
- package/dist/user-center.d.ts +20 -136
- package/dist/user-center.js +19 -236
- package/package.json +7 -2
- package/dist/TipPopover.css +0 -210
- package/dist/WidgetShell.css +0 -182
- package/dist/chunks/TipPopover-BrW8jo71.js +0 -2926
- package/dist/chunks/UserCenterWidget-BE329iS7.js +0 -3546
- package/dist/chunks/dynamic-import-helper-DxEFwm31.js +0 -537
- package/dist/chunks/useToast-B-wyO5zL.js +0 -93
- package/dist/chunks/useWidgetLocale-JDelxtt8.js +0 -74
|
@@ -0,0 +1,304 @@
|
|
|
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
|
+
let ethersModule = null;
|
|
45
|
+
const interfaceCache = /* @__PURE__ */ new Map();
|
|
46
|
+
async function loadEthers() {
|
|
47
|
+
if (ethersModule) {
|
|
48
|
+
return ethersModule;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
ethersModule = await import("ethers");
|
|
52
|
+
return ethersModule;
|
|
53
|
+
} catch {
|
|
54
|
+
throw new Error(
|
|
55
|
+
"ethers.js is required for contract invocation. Please install ethers@^6.0.0"
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function getInterface(abi) {
|
|
60
|
+
const { ethers } = await loadEthers();
|
|
61
|
+
const cacheKey = JSON.stringify(abi);
|
|
62
|
+
let iface = interfaceCache.get(cacheKey);
|
|
63
|
+
if (!iface) {
|
|
64
|
+
iface = new ethers.Interface(abi);
|
|
65
|
+
interfaceCache.set(cacheKey, iface);
|
|
66
|
+
}
|
|
67
|
+
return iface;
|
|
68
|
+
}
|
|
69
|
+
function getEthereumProvider() {
|
|
70
|
+
if (typeof window === "undefined") return null;
|
|
71
|
+
return window.ethereum ?? null;
|
|
72
|
+
}
|
|
73
|
+
function buildEthereumAdapter(provider, initialAddress = null, initialChainId = null) {
|
|
74
|
+
let currentAddress = initialAddress;
|
|
75
|
+
let currentChainId = initialChainId;
|
|
76
|
+
const adapter = {
|
|
77
|
+
/**
|
|
78
|
+
* Connect wallet
|
|
79
|
+
*/
|
|
80
|
+
connect: async () => {
|
|
81
|
+
const accounts = await provider.request({
|
|
82
|
+
method: "eth_requestAccounts"
|
|
83
|
+
});
|
|
84
|
+
if (!accounts || accounts.length === 0) {
|
|
85
|
+
throw new Error("No accounts found");
|
|
86
|
+
}
|
|
87
|
+
const address = accounts[0];
|
|
88
|
+
if (!address) {
|
|
89
|
+
throw new Error("No accounts found");
|
|
90
|
+
}
|
|
91
|
+
currentAddress = address;
|
|
92
|
+
const chainIdHex = await provider.request({
|
|
93
|
+
method: "eth_chainId"
|
|
94
|
+
});
|
|
95
|
+
currentChainId = parseInt(chainIdHex, 16);
|
|
96
|
+
return address;
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* Disconnect from wallet
|
|
100
|
+
* Note: Most wallets don't support programmatic disconnect, can only clear local state
|
|
101
|
+
*/
|
|
102
|
+
disconnect: async () => {
|
|
103
|
+
currentAddress = null;
|
|
104
|
+
currentChainId = null;
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* Sign message (personal_sign)
|
|
108
|
+
*/
|
|
109
|
+
signMessage: async (message) => {
|
|
110
|
+
if (!currentAddress) {
|
|
111
|
+
throw new Error("Wallet not connected");
|
|
112
|
+
}
|
|
113
|
+
const signature = await provider.request({
|
|
114
|
+
method: "personal_sign",
|
|
115
|
+
params: [message, currentAddress]
|
|
116
|
+
});
|
|
117
|
+
return signature;
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
* Get current address
|
|
121
|
+
*/
|
|
122
|
+
getAddress: () => currentAddress,
|
|
123
|
+
/**
|
|
124
|
+
* Get current chain ID
|
|
125
|
+
*/
|
|
126
|
+
getChainId: () => currentChainId,
|
|
127
|
+
/**
|
|
128
|
+
* Switch network
|
|
129
|
+
*/
|
|
130
|
+
switchNetwork: async (chainId) => {
|
|
131
|
+
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
132
|
+
try {
|
|
133
|
+
await provider.request({
|
|
134
|
+
method: "wallet_switchEthereumChain",
|
|
135
|
+
params: [{ chainId: chainIdHex }]
|
|
136
|
+
});
|
|
137
|
+
currentChainId = chainId;
|
|
138
|
+
} catch (error) {
|
|
139
|
+
const err = error;
|
|
140
|
+
if (err.code === 4902) {
|
|
141
|
+
throw new Error("Chain not found in wallet. Please add the network manually.");
|
|
142
|
+
}
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Get wallet's native token balance (for gas estimation)
|
|
148
|
+
* @returns Balance in ETH (string, formatted)
|
|
149
|
+
*/
|
|
150
|
+
getBalance: async () => {
|
|
151
|
+
if (!currentAddress) {
|
|
152
|
+
throw new Error("Wallet not connected");
|
|
153
|
+
}
|
|
154
|
+
const balanceHex = await provider.request({
|
|
155
|
+
method: "eth_getBalance",
|
|
156
|
+
params: [currentAddress, "latest"]
|
|
157
|
+
});
|
|
158
|
+
const balanceWei = BigInt(balanceHex);
|
|
159
|
+
const balanceEth = Number(balanceWei) / 1e18;
|
|
160
|
+
return balanceEth.toString();
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* Invoke a smart contract method
|
|
164
|
+
*
|
|
165
|
+
* 使用 ethers.js 编码合约调用,支持缓存优化:
|
|
166
|
+
* - ethers 模块只加载一次
|
|
167
|
+
* - 相同 ABI 的 Interface 实例会被缓存复用
|
|
168
|
+
*
|
|
169
|
+
* @param params - Contract invocation parameters
|
|
170
|
+
* @returns Transaction hash
|
|
171
|
+
*/
|
|
172
|
+
invokeContract: async (params) => {
|
|
173
|
+
var _a;
|
|
174
|
+
if (!currentAddress) {
|
|
175
|
+
throw new Error("Wallet not connected");
|
|
176
|
+
}
|
|
177
|
+
const { contract, abi, method, params: methodParams, chainId, value } = params;
|
|
178
|
+
if (chainId && currentChainId !== chainId) {
|
|
179
|
+
await ((_a = adapter.switchNetwork) == null ? void 0 : _a.call(adapter, chainId));
|
|
180
|
+
}
|
|
181
|
+
let encodedData;
|
|
182
|
+
try {
|
|
183
|
+
const iface = await getInterface(abi);
|
|
184
|
+
encodedData = iface.encodeFunctionData(method, methodParams);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (error instanceof Error && error.message.includes("ethers.js is required")) {
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Failed to encode contract call "${method}": ${error instanceof Error ? error.message : String(error)}`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
const txParams = {
|
|
194
|
+
from: currentAddress,
|
|
195
|
+
to: contract,
|
|
196
|
+
data: encodedData
|
|
197
|
+
};
|
|
198
|
+
if (value) {
|
|
199
|
+
txParams.value = `0x${BigInt(value).toString(16)}`;
|
|
200
|
+
}
|
|
201
|
+
const txHash = await provider.request({
|
|
202
|
+
method: "eth_sendTransaction",
|
|
203
|
+
params: [txParams]
|
|
204
|
+
});
|
|
205
|
+
return txHash;
|
|
206
|
+
},
|
|
207
|
+
/**
|
|
208
|
+
* Listen to account changes
|
|
209
|
+
*/
|
|
210
|
+
onAccountChange: (callback) => {
|
|
211
|
+
var _a;
|
|
212
|
+
const handler = (accounts) => {
|
|
213
|
+
const accountList = accounts;
|
|
214
|
+
currentAddress = accountList[0] ?? null;
|
|
215
|
+
callback(currentAddress);
|
|
216
|
+
};
|
|
217
|
+
(_a = provider.on) == null ? void 0 : _a.call(provider, "accountsChanged", handler);
|
|
218
|
+
return () => {
|
|
219
|
+
var _a2;
|
|
220
|
+
return (_a2 = provider.removeListener) == null ? void 0 : _a2.call(provider, "accountsChanged", handler);
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
/**
|
|
224
|
+
* Listen to chain changes
|
|
225
|
+
*/
|
|
226
|
+
onChainChange: (callback) => {
|
|
227
|
+
var _a;
|
|
228
|
+
const handler = (chainIdHex) => {
|
|
229
|
+
currentChainId = parseInt(chainIdHex, 16);
|
|
230
|
+
callback(currentChainId);
|
|
231
|
+
};
|
|
232
|
+
(_a = provider.on) == null ? void 0 : _a.call(provider, "chainChanged", handler);
|
|
233
|
+
return () => {
|
|
234
|
+
var _a2;
|
|
235
|
+
return (_a2 = provider.removeListener) == null ? void 0 : _a2.call(provider, "chainChanged", handler);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
return adapter;
|
|
240
|
+
}
|
|
241
|
+
function createEthereumAdapter() {
|
|
242
|
+
const provider = getEthereumProvider();
|
|
243
|
+
if (!provider) return null;
|
|
244
|
+
return buildEthereumAdapter(provider);
|
|
245
|
+
}
|
|
246
|
+
function createEthereumAdapterFromProvider(provider, options = {}) {
|
|
247
|
+
return buildEthereumAdapter(
|
|
248
|
+
provider,
|
|
249
|
+
options.address ?? null,
|
|
250
|
+
options.chainId ?? null
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
const ToastContext = createContext(null);
|
|
254
|
+
function useToast() {
|
|
255
|
+
const context = useContext(ToastContext);
|
|
256
|
+
if (!context) {
|
|
257
|
+
throw new Error("useToast must be used within TaskOnProvider");
|
|
258
|
+
}
|
|
259
|
+
return context;
|
|
260
|
+
}
|
|
261
|
+
let toastId = 0;
|
|
262
|
+
function generateId() {
|
|
263
|
+
return `toast-${++toastId}-${Date.now()}`;
|
|
264
|
+
}
|
|
265
|
+
function useToastState() {
|
|
266
|
+
const [toasts, setToasts] = useState([]);
|
|
267
|
+
const showToast = useCallback(
|
|
268
|
+
(message, type = "info", duration) => {
|
|
269
|
+
const newToast = {
|
|
270
|
+
id: generateId(),
|
|
271
|
+
message,
|
|
272
|
+
type,
|
|
273
|
+
duration
|
|
274
|
+
};
|
|
275
|
+
setToasts((prev) => [...prev, newToast]);
|
|
276
|
+
},
|
|
277
|
+
[]
|
|
278
|
+
);
|
|
279
|
+
const removeToast = useCallback((id) => {
|
|
280
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
281
|
+
}, []);
|
|
282
|
+
const toast = {
|
|
283
|
+
success: (message, duration) => showToast(message, "success", duration),
|
|
284
|
+
error: (message, duration) => showToast(message, "error", duration),
|
|
285
|
+
warning: (message, duration) => showToast(message, "warning", duration),
|
|
286
|
+
info: (message, duration) => showToast(message, "info", duration)
|
|
287
|
+
};
|
|
288
|
+
return {
|
|
289
|
+
toasts,
|
|
290
|
+
showToast,
|
|
291
|
+
removeToast,
|
|
292
|
+
toast
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
export {
|
|
296
|
+
ToastContext as T,
|
|
297
|
+
WalletContext as W,
|
|
298
|
+
useEvmWallet as a,
|
|
299
|
+
useToastState as b,
|
|
300
|
+
createEthereumAdapter as c,
|
|
301
|
+
useToast as d,
|
|
302
|
+
createEthereumAdapterFromProvider as e,
|
|
303
|
+
useWallet as u
|
|
304
|
+
};
|
|
@@ -24,9 +24,6 @@ const withdrawing = "引き出し処理中...";
|
|
|
24
24
|
const confirm = "確認";
|
|
25
25
|
const cancel = "キャンセル";
|
|
26
26
|
const close = "閉じる";
|
|
27
|
-
const gasFreeWithdraw = "無料引き出し";
|
|
28
|
-
const gasFreeRemaining = "残り{count}回の無料引き出し";
|
|
29
|
-
const pollingStatus = "ガスステーションで処理中...";
|
|
30
27
|
const columnDetail = "詳細";
|
|
31
28
|
const columnDuration = "期間";
|
|
32
29
|
const activityName = "アクティビティ名";
|
|
@@ -107,6 +104,7 @@ const columnDiscordRole = "Discord ロール";
|
|
|
107
104
|
const columnTime = "時間";
|
|
108
105
|
const columnStatus = "ステータス";
|
|
109
106
|
const columnAmount = "数量";
|
|
107
|
+
const walletNotBind = "引き出す前にウォレットを連携してください";
|
|
110
108
|
const ja = {
|
|
111
109
|
tabMyRewards,
|
|
112
110
|
tabIdentity,
|
|
@@ -134,9 +132,6 @@ const ja = {
|
|
|
134
132
|
confirm,
|
|
135
133
|
cancel,
|
|
136
134
|
close,
|
|
137
|
-
gasFreeWithdraw,
|
|
138
|
-
gasFreeRemaining,
|
|
139
|
-
pollingStatus,
|
|
140
135
|
columnDetail,
|
|
141
136
|
columnDuration,
|
|
142
137
|
activityName,
|
|
@@ -216,7 +211,8 @@ const ja = {
|
|
|
216
211
|
columnDiscordRole,
|
|
217
212
|
columnTime,
|
|
218
213
|
columnStatus,
|
|
219
|
-
columnAmount
|
|
214
|
+
columnAmount,
|
|
215
|
+
walletNotBind
|
|
220
216
|
};
|
|
221
217
|
export {
|
|
222
218
|
activityName,
|
|
@@ -266,8 +262,6 @@ export {
|
|
|
266
262
|
frozenTypeReferral,
|
|
267
263
|
frozenTypeTgMiniApp,
|
|
268
264
|
frozenTypeWithdraw,
|
|
269
|
-
gasFreeRemaining,
|
|
270
|
-
gasFreeWithdraw,
|
|
271
265
|
gasNotEnough,
|
|
272
266
|
kycWarning,
|
|
273
267
|
lastLoginMethod,
|
|
@@ -289,7 +283,6 @@ export {
|
|
|
289
283
|
pleaseEnterValidCode,
|
|
290
284
|
pleaseEnterValidEmail,
|
|
291
285
|
pointsHistory,
|
|
292
|
-
pollingStatus,
|
|
293
286
|
previous,
|
|
294
287
|
resend,
|
|
295
288
|
resendCode,
|
|
@@ -320,6 +313,7 @@ export {
|
|
|
320
313
|
unbinding,
|
|
321
314
|
verificationCode,
|
|
322
315
|
walletAddresses,
|
|
316
|
+
walletNotBind,
|
|
323
317
|
withdraw,
|
|
324
318
|
withdrawCanceled,
|
|
325
319
|
withdrawCanceledMessage,
|
|
@@ -24,9 +24,6 @@ const withdrawing = "출금 처리 중...";
|
|
|
24
24
|
const confirm = "확인";
|
|
25
25
|
const cancel = "취소";
|
|
26
26
|
const close = "닫기";
|
|
27
|
-
const gasFreeWithdraw = "무료 출금";
|
|
28
|
-
const gasFreeRemaining = "무료 출금 {count}회 남음";
|
|
29
|
-
const pollingStatus = "가스 스테이션 처리 중...";
|
|
30
27
|
const columnDetail = "상세";
|
|
31
28
|
const columnDuration = "기간";
|
|
32
29
|
const activityName = "활동명";
|
|
@@ -107,6 +104,7 @@ const columnDiscordRole = "Discord 역할";
|
|
|
107
104
|
const columnTime = "시간";
|
|
108
105
|
const columnStatus = "상태";
|
|
109
106
|
const columnAmount = "수량";
|
|
107
|
+
const walletNotBind = "출금 전 지갑을 먼저 연결해 주세요";
|
|
110
108
|
const ko = {
|
|
111
109
|
tabMyRewards,
|
|
112
110
|
tabIdentity,
|
|
@@ -134,9 +132,6 @@ const ko = {
|
|
|
134
132
|
confirm,
|
|
135
133
|
cancel,
|
|
136
134
|
close,
|
|
137
|
-
gasFreeWithdraw,
|
|
138
|
-
gasFreeRemaining,
|
|
139
|
-
pollingStatus,
|
|
140
135
|
columnDetail,
|
|
141
136
|
columnDuration,
|
|
142
137
|
activityName,
|
|
@@ -216,7 +211,8 @@ const ko = {
|
|
|
216
211
|
columnDiscordRole,
|
|
217
212
|
columnTime,
|
|
218
213
|
columnStatus,
|
|
219
|
-
columnAmount
|
|
214
|
+
columnAmount,
|
|
215
|
+
walletNotBind
|
|
220
216
|
};
|
|
221
217
|
export {
|
|
222
218
|
activityName,
|
|
@@ -266,8 +262,6 @@ export {
|
|
|
266
262
|
frozenTypeReferral,
|
|
267
263
|
frozenTypeTgMiniApp,
|
|
268
264
|
frozenTypeWithdraw,
|
|
269
|
-
gasFreeRemaining,
|
|
270
|
-
gasFreeWithdraw,
|
|
271
265
|
gasNotEnough,
|
|
272
266
|
kycWarning,
|
|
273
267
|
lastLoginMethod,
|
|
@@ -289,7 +283,6 @@ export {
|
|
|
289
283
|
pleaseEnterValidCode,
|
|
290
284
|
pleaseEnterValidEmail,
|
|
291
285
|
pointsHistory,
|
|
292
|
-
pollingStatus,
|
|
293
286
|
previous,
|
|
294
287
|
resend,
|
|
295
288
|
resendCode,
|
|
@@ -320,6 +313,7 @@ export {
|
|
|
320
313
|
unbinding,
|
|
321
314
|
verificationCode,
|
|
322
315
|
walletAddresses,
|
|
316
|
+
walletNotBind,
|
|
323
317
|
withdraw,
|
|
324
318
|
withdrawCanceled,
|
|
325
319
|
withdrawCanceledMessage,
|
package/dist/community-task.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ChainType } from '@taskon/core';
|
|
|
2
2
|
import { CommunityTaskInfo } from '@taskon/core';
|
|
3
3
|
import { default as default_2 } from 'react';
|
|
4
4
|
import { RecurrenceType } from '@taskon/core';
|
|
5
|
+
import { RewardDisplayMode } from '@taskon/core';
|
|
5
6
|
import { SnsType } from '@taskon/core';
|
|
6
7
|
import { TaskReviewResult } from '@taskon/core';
|
|
7
8
|
|
|
@@ -210,6 +211,11 @@ declare interface BaseTaskProps {
|
|
|
210
211
|
coolDown?: number;
|
|
211
212
|
/** 冷却结束回调(用于重置 coolDown 状态) */
|
|
212
213
|
onCoolDownComplete?: () => void;
|
|
214
|
+
/**
|
|
215
|
+
* 周期任务倒计时结束回调
|
|
216
|
+
* 用于在 next_time 到期后刷新单个任务卡片状态
|
|
217
|
+
*/
|
|
218
|
+
onDoneCountdownComplete?: (taskId: number) => void | Promise<void>;
|
|
213
219
|
/** 是否禁用交互 */
|
|
214
220
|
disabled?: boolean;
|
|
215
221
|
/**
|
|
@@ -260,6 +266,11 @@ export declare interface CommunityTaskListProps {
|
|
|
260
266
|
* Cloud config includes display options, sector filtering, etc.
|
|
261
267
|
*/
|
|
262
268
|
widgetId?: number;
|
|
269
|
+
/**
|
|
270
|
+
* Manual theme mode override (highest priority when provided).
|
|
271
|
+
* Recommended with dual + toggle cloud strategy.
|
|
272
|
+
*/
|
|
273
|
+
themeMode?: "light" | "dark" | "auto";
|
|
263
274
|
/** Whether in preview mode */
|
|
264
275
|
isPreview?: boolean;
|
|
265
276
|
/** 社区信息(用于前置任务链接跳转) */
|
|
@@ -278,8 +289,9 @@ export declare interface CommunityTaskListProps {
|
|
|
278
289
|
*/
|
|
279
290
|
initialTaskId?: number;
|
|
280
291
|
/**
|
|
281
|
-
* Callback when dialog opens (host can use to update URL params)
|
|
282
|
-
*
|
|
292
|
+
* Callback when dialog opens or switches task (host can use to update URL params).
|
|
293
|
+
* Fires whenever active task changes, including eligibility-driven task switches.
|
|
294
|
+
* @param taskId Currently active task ID
|
|
283
295
|
* @example
|
|
284
296
|
* ```tsx
|
|
285
297
|
* onTaskOpen={(taskId) => router.replace(`?task=${taskId}`)}
|
|
@@ -287,13 +299,28 @@ export declare interface CommunityTaskListProps {
|
|
|
287
299
|
*/
|
|
288
300
|
onTaskOpen?: (taskId: number) => void;
|
|
289
301
|
/**
|
|
290
|
-
* Callback when dialog closes (host can use to clear URL params)
|
|
302
|
+
* Callback when dialog closes (host can use to clear URL params).
|
|
303
|
+
* Fires only when dialog is actually closed; in-place task switches do not emit close first.
|
|
291
304
|
* @example
|
|
292
305
|
* ```tsx
|
|
293
306
|
* onTaskClose={() => router.replace(pathname)}
|
|
294
307
|
* ```
|
|
295
308
|
*/
|
|
296
309
|
onTaskClose?: () => void;
|
|
310
|
+
/**
|
|
311
|
+
* Initial TaskChain campaign ID from URL (passed by host after parsing URL)
|
|
312
|
+
* Used to auto-open TaskChain dialog on page refresh or shared links
|
|
313
|
+
*/
|
|
314
|
+
initialTaskChainId?: number;
|
|
315
|
+
/**
|
|
316
|
+
* Callback when TaskChain dialog opens (host can use to update URL params)
|
|
317
|
+
* @param taskChainId Currently opened TaskChain campaign ID
|
|
318
|
+
*/
|
|
319
|
+
onTaskChainOpen?: (taskChainId: number) => void;
|
|
320
|
+
/**
|
|
321
|
+
* Callback when TaskChain dialog closes (host can use to clear URL params)
|
|
322
|
+
*/
|
|
323
|
+
onTaskChainClose?: () => void;
|
|
297
324
|
/** Sector IDs to display; undefined means show all */
|
|
298
325
|
sectorIds?: number[];
|
|
299
326
|
/** Whether to show sector tab selector (default: true) */
|
|
@@ -304,6 +331,10 @@ export declare interface CommunityTaskListProps {
|
|
|
304
331
|
showSectorDescription?: boolean;
|
|
305
332
|
/** Whether to show sector reward (default: true) */
|
|
306
333
|
showSectorReward?: boolean;
|
|
334
|
+
/** How reward details are displayed in TaskChain claimed NFT cards */
|
|
335
|
+
rewardDisplayMode?: RewardDisplayMode;
|
|
336
|
+
/** Redirect URL for reward details when mode is redirect */
|
|
337
|
+
rewardRedirectUrl?: string;
|
|
307
338
|
}
|
|
308
339
|
|
|
309
340
|
/** 奖励信息(统一格式) */
|
package/dist/community-task.js
CHANGED
package/dist/core.d.ts
CHANGED
|
@@ -178,13 +178,32 @@ export declare interface MapToken {
|
|
|
178
178
|
colorSuccess?: string;
|
|
179
179
|
colorWarning?: string;
|
|
180
180
|
colorError?: string;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
/** Page/canvas base background */
|
|
182
|
+
colorBgCanvas?: string;
|
|
183
|
+
/** Main surface background (cards, panels) */
|
|
184
|
+
colorBgSurface?: string;
|
|
185
|
+
/** Subtle surface background (low-contrast cards) */
|
|
186
|
+
colorBgSurfaceSubtle?: string;
|
|
187
|
+
/** Strong surface background (section headers, tracks) */
|
|
188
|
+
colorBgSurfaceStrong?: string;
|
|
189
|
+
/** Floating layer background (tooltip, dropdown, popover) */
|
|
190
|
+
colorBgFloating?: string;
|
|
191
|
+
/** Overlay mask background */
|
|
192
|
+
colorBgMask?: string;
|
|
193
|
+
/** Inset background (inner slots/containers) */
|
|
194
|
+
colorBgInset?: string;
|
|
195
|
+
colorSuccessBg?: string;
|
|
196
|
+
colorWarningBg?: string;
|
|
197
|
+
colorErrorBg?: string;
|
|
198
|
+
colorSecondaryBg?: string;
|
|
184
199
|
colorText?: string;
|
|
185
200
|
colorTextSecondary?: string;
|
|
186
201
|
colorTextTertiary?: string;
|
|
187
202
|
colorTextDisabled?: string;
|
|
203
|
+
/** Link color */
|
|
204
|
+
colorLink?: string;
|
|
205
|
+
/** Text color on primary background elements (e.g. primary button text) */
|
|
206
|
+
colorTextOnPrimary?: string;
|
|
188
207
|
colorBorder?: string;
|
|
189
208
|
colorBorderSecondary?: string;
|
|
190
209
|
borderRadius?: number;
|
|
@@ -225,10 +244,22 @@ export declare interface SeedToken {
|
|
|
225
244
|
colorWarning?: string;
|
|
226
245
|
/** Error color */
|
|
227
246
|
colorError?: string;
|
|
247
|
+
/** Link color */
|
|
248
|
+
colorLink?: string;
|
|
249
|
+
/** Base text color */
|
|
250
|
+
colorText?: string;
|
|
251
|
+
/** Text color on primary buttons */
|
|
252
|
+
colorTextOnPrimary?: string;
|
|
253
|
+
/** Base page background color (used to derive background layers) */
|
|
254
|
+
colorBgBase?: string;
|
|
228
255
|
/** Base border radius */
|
|
229
256
|
borderRadius?: number;
|
|
230
257
|
/** Base font size */
|
|
231
258
|
fontSize?: number;
|
|
259
|
+
/** Spacing base step from cloud config */
|
|
260
|
+
spacingBaseStep?: number;
|
|
261
|
+
/** Spacing change unit from cloud config */
|
|
262
|
+
spacingChangeUnit?: number;
|
|
232
263
|
}
|
|
233
264
|
|
|
234
265
|
/**
|
|
@@ -416,6 +447,12 @@ export declare interface TaskOnTheme {
|
|
|
416
447
|
export declare interface TaskOnThemeConfig {
|
|
417
448
|
/** Theme mode */
|
|
418
449
|
mode?: ThemeMode;
|
|
450
|
+
/**
|
|
451
|
+
* Theme mode strategy.
|
|
452
|
+
* - auto: mode selection follows standard mode behavior
|
|
453
|
+
* - toggle: SDK/host controls mode manually (typically used with dual+toggle from cloud config)
|
|
454
|
+
*/
|
|
455
|
+
modeStrategy?: "auto" | "toggle";
|
|
419
456
|
/** Compact mode */
|
|
420
457
|
compact?: boolean;
|
|
421
458
|
/** Seed tokens */
|
package/dist/core.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { T, u, a } from "./chunks/ThemeProvider-
|
|
1
|
+
import { T, c, i, u, a, b } from "./chunks/ThemeProvider-DNJqI2lD.js";
|
|
2
2
|
import { RewardType } from "@taskon/core";
|
|
3
|
-
import { T as T2, c, b, i, a as a2, u as u2 } from "./chunks/TaskOnProvider-
|
|
4
|
-
import { a as a3, u as u3 } from "./chunks/useToast-
|
|
5
|
-
import { c as c2, i as i2, u as u4 } from "./chunks/useWidgetLocale-JDelxtt8.js";
|
|
3
|
+
import { T as T2, c as c2, b as b2, i as i2, a as a2, u as u2 } from "./chunks/TaskOnProvider-iannERG1.js";
|
|
4
|
+
import { a as a3, u as u3 } from "./chunks/useToast-CaRkylKe.js";
|
|
6
5
|
export {
|
|
7
6
|
RewardType,
|
|
8
7
|
T2 as TaskOnProvider,
|
|
9
8
|
T as ThemeProvider,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
c as clearLocaleCache,
|
|
10
|
+
c2 as createLocaleLoader,
|
|
11
|
+
b2 as createT,
|
|
12
|
+
i2 as interpolate,
|
|
13
|
+
i as isSupportedLocale,
|
|
15
14
|
a2 as useCommonLocale,
|
|
16
15
|
a3 as useEvmWallet,
|
|
17
16
|
u as useTaskOnAuth,
|
|
18
17
|
a as useTaskOnTheme,
|
|
19
18
|
u2 as useTranslation,
|
|
20
19
|
u3 as useWallet,
|
|
21
|
-
|
|
20
|
+
b as useWidgetLocale
|
|
22
21
|
};
|