@windrun-huaiin/third-ui 7.3.0 → 7.3.2

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.
@@ -45,7 +45,7 @@ function withFingerprint(Component, config) {
45
45
  * 组件:显示用户状态和积分信息(用于调试)
46
46
  */
47
47
  function FingerprintStatus() {
48
- const { fingerprintId, anonymousUser, credits, isLoading, isInitialized, error } = useFingerprintContext();
48
+ const { fingerprintId, xUser, xCredit, xSubscription, isLoading, isInitialized, error } = useFingerprintContext();
49
49
  const [isOpen, setIsOpen] = React.useState(false);
50
50
  const handleToggle = () => {
51
51
  setIsOpen(!isOpen);
@@ -91,7 +91,7 @@ function FingerprintStatus() {
91
91
  zIndex: 9999,
92
92
  border: '1px solid #ccc',
93
93
  boxShadow: '0 4px 12px rgba(0, 0, 0, 0.2)',
94
- }, children: [jsxRuntime.jsx("h4", { style: { margin: '0 0 5px 0' }, children: "Fingerprint Debug" }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "FP_ID:" }), " ", fingerprintId || 'None'] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Loading:" }), " ", isLoading ? 'Yes' : 'No'] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Initialized:" }), " ", isInitialized ? 'Yes' : 'No'] }), error && jsxRuntime.jsxs("div", { style: { color: 'red' }, children: [jsxRuntime.jsx("strong", { children: "Error:" }), " ", error] }), anonymousUser && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "user_id:" }), " ", anonymousUser.userId, " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "clerk_user_id:" }), " ", anonymousUser.clerkUserId, " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "email:" }), " ", anonymousUser.email || 'None', " ", jsxRuntime.jsx("br", {}), " "] })), credits && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Credits:" }), " ", credits.balanceFree, " Free + ", credits.balancePaid, " Paid = ", credits.totalBalance, " Total"] }))] })] }))] }));
94
+ }, children: [jsxRuntime.jsx("h4", { style: { margin: '0 0 5px 0' }, children: "Fingerprint Debug" }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "FP_ID:" }), " ", fingerprintId || 'None'] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Loading:" }), " ", isLoading ? 'Yes' : 'No'] }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Initialized:" }), " ", isInitialized ? 'Yes' : 'No'] }), error && jsxRuntime.jsxs("div", { style: { color: 'red' }, children: [jsxRuntime.jsx("strong", { children: "Error:" }), " ", error] }), xUser && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "user_id:" }), " ", xUser.userId, " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "clerk_user_id:" }), " ", xUser.clerkUserId || 'None', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "email:" }), " ", xUser.email || 'None', " ", jsxRuntime.jsx("br", {})] })), xCredit && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "Credits:" }), " ", xCredit.balanceFree, " Free + ", xCredit.balancePaid, " Paid = ", xCredit.totalBalance, " Total"] })), xSubscription && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "user_id:" }), " ", xSubscription.userId, " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "pay_subscription_id:" }), " ", xSubscription.paySubscriptionId, " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "price_id:" }), " ", xSubscription.priceId || 'None', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "price_name:" }), " ", xSubscription.priceName || 'None', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "status:" }), " ", xSubscription.status || 'Free', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "credits_allocated:" }), " ", xSubscription.creditsAllocated || '', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "sub_period_start:" }), " ", xSubscription.subPeriodStart || '', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "sub_period_end:" }), " ", xSubscription.subPeriodEnd || '', " ", jsxRuntime.jsx("br", {})] }))] })] }))] }));
95
95
  }
96
96
 
97
97
  exports.FingerprintProvider = FingerprintProvider;
@@ -43,7 +43,7 @@ function withFingerprint(Component, config) {
43
43
  * 组件:显示用户状态和积分信息(用于调试)
44
44
  */
45
45
  function FingerprintStatus() {
46
- const { fingerprintId, anonymousUser, credits, isLoading, isInitialized, error } = useFingerprintContext();
46
+ const { fingerprintId, xUser, xCredit, xSubscription, isLoading, isInitialized, error } = useFingerprintContext();
47
47
  const [isOpen, setIsOpen] = useState(false);
48
48
  const handleToggle = () => {
49
49
  setIsOpen(!isOpen);
@@ -89,7 +89,7 @@ function FingerprintStatus() {
89
89
  zIndex: 9999,
90
90
  border: '1px solid #ccc',
91
91
  boxShadow: '0 4px 12px rgba(0, 0, 0, 0.2)',
92
- }, children: [jsx("h4", { style: { margin: '0 0 5px 0' }, children: "Fingerprint Debug" }), jsxs("div", { children: [jsx("strong", { children: "FP_ID:" }), " ", fingerprintId || 'None'] }), jsxs("div", { children: [jsx("strong", { children: "Loading:" }), " ", isLoading ? 'Yes' : 'No'] }), jsxs("div", { children: [jsx("strong", { children: "Initialized:" }), " ", isInitialized ? 'Yes' : 'No'] }), error && jsxs("div", { style: { color: 'red' }, children: [jsx("strong", { children: "Error:" }), " ", error] }), anonymousUser && (jsxs("div", { children: [jsx("strong", { children: "user_id:" }), " ", anonymousUser.userId, " ", jsx("br", {}), jsx("strong", { children: "clerk_user_id:" }), " ", anonymousUser.clerkUserId, " ", jsx("br", {}), jsx("strong", { children: "email:" }), " ", anonymousUser.email || 'None', " ", jsx("br", {}), " "] })), credits && (jsxs("div", { children: [jsx("strong", { children: "Credits:" }), " ", credits.balanceFree, " Free + ", credits.balancePaid, " Paid = ", credits.totalBalance, " Total"] }))] })] }))] }));
92
+ }, children: [jsx("h4", { style: { margin: '0 0 5px 0' }, children: "Fingerprint Debug" }), jsxs("div", { children: [jsx("strong", { children: "FP_ID:" }), " ", fingerprintId || 'None'] }), jsxs("div", { children: [jsx("strong", { children: "Loading:" }), " ", isLoading ? 'Yes' : 'No'] }), jsxs("div", { children: [jsx("strong", { children: "Initialized:" }), " ", isInitialized ? 'Yes' : 'No'] }), error && jsxs("div", { style: { color: 'red' }, children: [jsx("strong", { children: "Error:" }), " ", error] }), xUser && (jsxs("div", { children: [jsx("strong", { children: "user_id:" }), " ", xUser.userId, " ", jsx("br", {}), jsx("strong", { children: "clerk_user_id:" }), " ", xUser.clerkUserId || 'None', " ", jsx("br", {}), jsx("strong", { children: "email:" }), " ", xUser.email || 'None', " ", jsx("br", {})] })), xCredit && (jsxs("div", { children: [jsx("strong", { children: "Credits:" }), " ", xCredit.balanceFree, " Free + ", xCredit.balancePaid, " Paid = ", xCredit.totalBalance, " Total"] })), xSubscription && (jsxs("div", { children: [jsx("strong", { children: "user_id:" }), " ", xSubscription.userId, " ", jsx("br", {}), jsx("strong", { children: "pay_subscription_id:" }), " ", xSubscription.paySubscriptionId, " ", jsx("br", {}), jsx("strong", { children: "price_id:" }), " ", xSubscription.priceId || 'None', " ", jsx("br", {}), jsx("strong", { children: "price_name:" }), " ", xSubscription.priceName || 'None', " ", jsx("br", {}), jsx("strong", { children: "status:" }), " ", xSubscription.status || 'Free', " ", jsx("br", {}), jsx("strong", { children: "credits_allocated:" }), " ", xSubscription.creditsAllocated || '', " ", jsx("br", {}), jsx("strong", { children: "sub_period_start:" }), " ", xSubscription.subPeriodStart || '', " ", jsx("br", {}), jsx("strong", { children: "sub_period_end:" }), " ", xSubscription.subPeriodEnd || '', " ", jsx("br", {})] }))] })] }))] }));
93
93
  }
94
94
 
95
95
  export { FingerprintProvider, FingerprintStatus, useFingerprintContext, useFingerprintContextSafe, withFingerprint };
@@ -2,7 +2,7 @@
2
2
  * Fingerprint System Types
3
3
  * 指纹识别系统的类型定义
4
4
  */
5
- export interface AnonymousUser {
5
+ export interface XUser {
6
6
  userId: string;
7
7
  fingerprintId: string;
8
8
  clerkUserId: string;
@@ -10,11 +10,22 @@ export interface AnonymousUser {
10
10
  status: string;
11
11
  createdAt: string;
12
12
  }
13
- export interface Credits {
13
+ export interface XCredit {
14
14
  balanceFree: number;
15
15
  balancePaid: number;
16
16
  totalBalance: number;
17
17
  }
18
+ export interface XSubscription {
19
+ id: bigint;
20
+ userId: string;
21
+ paySubscriptionId: string | null;
22
+ priceId: string | null;
23
+ priceName: string | null;
24
+ status: string;
25
+ creditsAllocated: number;
26
+ subPeriodStart: string;
27
+ subPeriodEnd: string;
28
+ }
18
29
  export interface FingerprintConfig {
19
30
  /** API endpoint for anonymous user initialization */
20
31
  apiEndpoint: string;
@@ -25,8 +36,9 @@ export interface FingerprintConfig {
25
36
  }
26
37
  export interface UseFingerprintResult {
27
38
  fingerprintId: string | null;
28
- anonymousUser: AnonymousUser | null;
29
- credits: Credits | null;
39
+ xUser: XUser | null;
40
+ xCredit: XCredit | null;
41
+ xSubscription: XSubscription | null;
30
42
  isLoading: boolean;
31
43
  isInitialized: boolean;
32
44
  error: string | null;
@@ -11,8 +11,9 @@ var fingerprintClient = require('./fingerprint-client.js');
11
11
  */
12
12
  function useFingerprint(config) {
13
13
  const [fingerprintId, setFingerprintIdState] = React.useState(null);
14
- const [anonymousUser, setAnonymousUser] = React.useState(null);
15
- const [credits, setCredits] = React.useState(null);
14
+ const [xUser, setXUser] = React.useState(null);
15
+ const [xCredit, setXCredit] = React.useState(null);
16
+ const [xSubscription, setXSubscription] = React.useState(null);
16
17
  const [isLoading, setIsLoading] = React.useState(true);
17
18
  const [isInitialized, setIsInitialized] = React.useState(false);
18
19
  const [error, setError] = React.useState(null);
@@ -59,8 +60,9 @@ function useFingerprint(config) {
59
60
  }
60
61
  const data = yield response.json();
61
62
  if (data.success) {
62
- setAnonymousUser(data.user);
63
- setCredits(data.credits);
63
+ setXUser(data.xUser);
64
+ setXCredit(data.xCredit);
65
+ setXSubscription(data.xSubscription);
64
66
  setIsInitialized(true);
65
67
  // 确保fingerprint ID同步
66
68
  if (data.user.fingerprintId !== fingerprintId) {
@@ -103,8 +105,9 @@ function useFingerprint(config) {
103
105
  }
104
106
  const data = yield response.json();
105
107
  if (data.success) {
106
- setAnonymousUser(data.user);
107
- setCredits(data.credits);
108
+ setXUser(data.xUser);
109
+ setXCredit(data.xCredit);
110
+ setXSubscription(data.xSubscription);
108
111
  }
109
112
  }
110
113
  catch (err) {
@@ -127,8 +130,9 @@ function useFingerprint(config) {
127
130
  if (response.ok) {
128
131
  const data = yield response.json();
129
132
  if (data.success) {
130
- setAnonymousUser(data.user);
131
- setCredits(data.credits);
133
+ setXUser(data.xUser);
134
+ setXCredit(data.xCredit);
135
+ setXSubscription(data.xSubscription);
132
136
  setIsInitialized(true);
133
137
  }
134
138
  }
@@ -163,8 +167,9 @@ function useFingerprint(config) {
163
167
  }, [fingerprintId, isInitialized, isLoading, error, initializeAnonymousUser, config.autoInitialize]);
164
168
  return {
165
169
  fingerprintId,
166
- anonymousUser,
167
- credits,
170
+ xUser,
171
+ xCredit,
172
+ xSubscription,
168
173
  isLoading,
169
174
  isInitialized,
170
175
  error,
@@ -9,8 +9,9 @@ import { createFingerprintHeaders, setFingerprintId, getOrGenerateFingerprintId
9
9
  */
10
10
  function useFingerprint(config) {
11
11
  const [fingerprintId, setFingerprintIdState] = useState(null);
12
- const [anonymousUser, setAnonymousUser] = useState(null);
13
- const [credits, setCredits] = useState(null);
12
+ const [xUser, setXUser] = useState(null);
13
+ const [xCredit, setXCredit] = useState(null);
14
+ const [xSubscription, setXSubscription] = useState(null);
14
15
  const [isLoading, setIsLoading] = useState(true);
15
16
  const [isInitialized, setIsInitialized] = useState(false);
16
17
  const [error, setError] = useState(null);
@@ -57,8 +58,9 @@ function useFingerprint(config) {
57
58
  }
58
59
  const data = yield response.json();
59
60
  if (data.success) {
60
- setAnonymousUser(data.user);
61
- setCredits(data.credits);
61
+ setXUser(data.xUser);
62
+ setXCredit(data.xCredit);
63
+ setXSubscription(data.xSubscription);
62
64
  setIsInitialized(true);
63
65
  // 确保fingerprint ID同步
64
66
  if (data.user.fingerprintId !== fingerprintId) {
@@ -101,8 +103,9 @@ function useFingerprint(config) {
101
103
  }
102
104
  const data = yield response.json();
103
105
  if (data.success) {
104
- setAnonymousUser(data.user);
105
- setCredits(data.credits);
106
+ setXUser(data.xUser);
107
+ setXCredit(data.xCredit);
108
+ setXSubscription(data.xSubscription);
106
109
  }
107
110
  }
108
111
  catch (err) {
@@ -125,8 +128,9 @@ function useFingerprint(config) {
125
128
  if (response.ok) {
126
129
  const data = yield response.json();
127
130
  if (data.success) {
128
- setAnonymousUser(data.user);
129
- setCredits(data.credits);
131
+ setXUser(data.xUser);
132
+ setXCredit(data.xCredit);
133
+ setXSubscription(data.xSubscription);
130
134
  setIsInitialized(true);
131
135
  }
132
136
  }
@@ -161,8 +165,9 @@ function useFingerprint(config) {
161
165
  }, [fingerprintId, isInitialized, isLoading, error, initializeAnonymousUser, config.autoInitialize]);
162
166
  return {
163
167
  fingerprintId,
164
- anonymousUser,
165
- credits,
168
+ xUser,
169
+ xCredit,
170
+ xSubscription,
166
171
  isLoading,
167
172
  isInitialized,
168
173
  error,
@@ -15,10 +15,10 @@ var fingerprintProvider = require('./fingerprint/fingerprint-provider.js');
15
15
  function SignInWithFingerprint() {
16
16
  const fingerprintContext = fingerprintProvider.useFingerprintContextSafe();
17
17
  // 如果没有fingerprint context,使用默认值
18
- const { fingerprintId = null, anonymousUser = null, isInitialized = false, initializeAnonymousUser = () => tslib_es6.__awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
18
+ const { fingerprintId = null, xUser = null, isInitialized = false, initializeAnonymousUser = () => tslib_es6.__awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
19
19
  // 准备传递给Clerk的metadata,包含匿名用户信息
20
20
  const unsafeMetadata = {
21
- user_id: (anonymousUser === null || anonymousUser === void 0 ? void 0 : anonymousUser.userId) || null, // 数据库中的user_id
21
+ user_id: (xUser === null || xUser === void 0 ? void 0 : xUser.userId) || null, // 数据库中的user_id
22
22
  fingerprint_id: fingerprintId || null, // 浏览器指纹ID
23
23
  };
24
24
  // 确保匿名用户已初始化
@@ -32,17 +32,17 @@ function SignInWithFingerprint() {
32
32
  console.log('SignInWithFingerprint Debug:', {
33
33
  fingerprintProvider: fingerprintContext ? 'Available' : 'Not found',
34
34
  fingerprintId: fingerprintId || 'Not generated',
35
- anonymousUser: anonymousUser ? 'Initialized' : 'Not initialized',
35
+ xUser: xUser ? 'Initialized' : 'Not initialized',
36
36
  clerkMetadata: unsafeMetadata
37
37
  });
38
- if (anonymousUser && fingerprintId) {
38
+ if (xUser && fingerprintId) {
39
39
  console.log('User signed in with existing anonymous data:', {
40
- anonymousUserId: anonymousUser.userId,
40
+ userId: xUser.userId,
41
41
  fingerprintId,
42
42
  });
43
43
  // TODO: 实现数据合并逻辑
44
44
  }
45
- }, [anonymousUser, fingerprintId, fingerprintContext, unsafeMetadata]);
45
+ }, [xUser, fingerprintId, fingerprintContext, unsafeMetadata]);
46
46
  return jsxRuntime.jsx(nextjs.SignIn, { unsafeMetadata: unsafeMetadata });
47
47
  }
48
48
 
@@ -13,10 +13,10 @@ import { useFingerprintContextSafe } from './fingerprint/fingerprint-provider.mj
13
13
  function SignInWithFingerprint() {
14
14
  const fingerprintContext = useFingerprintContextSafe();
15
15
  // 如果没有fingerprint context,使用默认值
16
- const { fingerprintId = null, anonymousUser = null, isInitialized = false, initializeAnonymousUser = () => __awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
16
+ const { fingerprintId = null, xUser = null, isInitialized = false, initializeAnonymousUser = () => __awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
17
17
  // 准备传递给Clerk的metadata,包含匿名用户信息
18
18
  const unsafeMetadata = {
19
- user_id: (anonymousUser === null || anonymousUser === void 0 ? void 0 : anonymousUser.userId) || null, // 数据库中的user_id
19
+ user_id: (xUser === null || xUser === void 0 ? void 0 : xUser.userId) || null, // 数据库中的user_id
20
20
  fingerprint_id: fingerprintId || null, // 浏览器指纹ID
21
21
  };
22
22
  // 确保匿名用户已初始化
@@ -30,17 +30,17 @@ function SignInWithFingerprint() {
30
30
  console.log('SignInWithFingerprint Debug:', {
31
31
  fingerprintProvider: fingerprintContext ? 'Available' : 'Not found',
32
32
  fingerprintId: fingerprintId || 'Not generated',
33
- anonymousUser: anonymousUser ? 'Initialized' : 'Not initialized',
33
+ xUser: xUser ? 'Initialized' : 'Not initialized',
34
34
  clerkMetadata: unsafeMetadata
35
35
  });
36
- if (anonymousUser && fingerprintId) {
36
+ if (xUser && fingerprintId) {
37
37
  console.log('User signed in with existing anonymous data:', {
38
- anonymousUserId: anonymousUser.userId,
38
+ userId: xUser.userId,
39
39
  fingerprintId,
40
40
  });
41
41
  // TODO: 实现数据合并逻辑
42
42
  }
43
- }, [anonymousUser, fingerprintId, fingerprintContext, unsafeMetadata]);
43
+ }, [xUser, fingerprintId, fingerprintContext, unsafeMetadata]);
44
44
  return jsx(SignIn, { unsafeMetadata: unsafeMetadata });
45
45
  }
46
46
 
@@ -15,10 +15,10 @@ var fingerprintProvider = require('./fingerprint/fingerprint-provider.js');
15
15
  function SignUpWithFingerprint() {
16
16
  const fingerprintContext = fingerprintProvider.useFingerprintContextSafe();
17
17
  // 如果没有fingerprint context,使用默认值
18
- const { fingerprintId = null, anonymousUser = null, isInitialized = false, initializeAnonymousUser = () => tslib_es6.__awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
18
+ const { fingerprintId = null, xUser = null, isInitialized = false, initializeAnonymousUser = () => tslib_es6.__awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
19
19
  // 准备传递给Clerk的metadata,包含匿名用户信息
20
20
  const unsafeMetadata = {
21
- user_id: (anonymousUser === null || anonymousUser === void 0 ? void 0 : anonymousUser.userId) || null, // 数据库中的user_id
21
+ user_id: (xUser === null || xUser === void 0 ? void 0 : xUser.userId) || null, // 数据库中的user_id
22
22
  fingerprint_id: fingerprintId || null, // 浏览器指纹ID
23
23
  };
24
24
  // 确保匿名用户已初始化
@@ -32,17 +32,17 @@ function SignUpWithFingerprint() {
32
32
  console.log('SignUpWithFingerprint Debug:', {
33
33
  fingerprintProvider: fingerprintContext ? 'Available' : 'Not found',
34
34
  fingerprintId: fingerprintId || 'Not generated',
35
- anonymousUser: anonymousUser ? 'Initialized' : 'Not initialized',
35
+ xUser: xUser ? 'Initialized' : 'Not initialized',
36
36
  clerkMetadata: unsafeMetadata
37
37
  });
38
- if (anonymousUser && fingerprintId) {
38
+ if (xUser && fingerprintId) {
39
39
  console.log('User signed up with existing anonymous data:', {
40
- anonymousUserId: anonymousUser.userId,
40
+ userId: xUser.userId,
41
41
  fingerprintId,
42
42
  });
43
43
  // TODO: 实现数据迁移逻辑
44
44
  }
45
- }, [anonymousUser, fingerprintId, fingerprintContext, unsafeMetadata]);
45
+ }, [xUser, fingerprintId, fingerprintContext, unsafeMetadata]);
46
46
  return jsxRuntime.jsx(nextjs.SignUp, { unsafeMetadata: unsafeMetadata });
47
47
  }
48
48
 
@@ -13,10 +13,10 @@ import { useFingerprintContextSafe } from './fingerprint/fingerprint-provider.mj
13
13
  function SignUpWithFingerprint() {
14
14
  const fingerprintContext = useFingerprintContextSafe();
15
15
  // 如果没有fingerprint context,使用默认值
16
- const { fingerprintId = null, anonymousUser = null, isInitialized = false, initializeAnonymousUser = () => __awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
16
+ const { fingerprintId = null, xUser = null, isInitialized = false, initializeAnonymousUser = () => __awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
17
17
  // 准备传递给Clerk的metadata,包含匿名用户信息
18
18
  const unsafeMetadata = {
19
- user_id: (anonymousUser === null || anonymousUser === void 0 ? void 0 : anonymousUser.userId) || null, // 数据库中的user_id
19
+ user_id: (xUser === null || xUser === void 0 ? void 0 : xUser.userId) || null, // 数据库中的user_id
20
20
  fingerprint_id: fingerprintId || null, // 浏览器指纹ID
21
21
  };
22
22
  // 确保匿名用户已初始化
@@ -30,17 +30,17 @@ function SignUpWithFingerprint() {
30
30
  console.log('SignUpWithFingerprint Debug:', {
31
31
  fingerprintProvider: fingerprintContext ? 'Available' : 'Not found',
32
32
  fingerprintId: fingerprintId || 'Not generated',
33
- anonymousUser: anonymousUser ? 'Initialized' : 'Not initialized',
33
+ xUser: xUser ? 'Initialized' : 'Not initialized',
34
34
  clerkMetadata: unsafeMetadata
35
35
  });
36
- if (anonymousUser && fingerprintId) {
36
+ if (xUser && fingerprintId) {
37
37
  console.log('User signed up with existing anonymous data:', {
38
- anonymousUserId: anonymousUser.userId,
38
+ userId: xUser.userId,
39
39
  fingerprintId,
40
40
  });
41
41
  // TODO: 实现数据迁移逻辑
42
42
  }
43
- }, [anonymousUser, fingerprintId, fingerprintContext, unsafeMetadata]);
43
+ }, [xUser, fingerprintId, fingerprintContext, unsafeMetadata]);
44
44
  return jsx(SignUp, { unsafeMetadata: unsafeMetadata });
45
45
  }
46
46
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var coseBase$1 = require('../../../../../_virtual/cose-base.js');
3
+ var coseBase$1 = require('../../../../../_virtual/cose-base2.js');
4
4
  var layoutBase = require('../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js');
5
5
 
6
6
  var coseBase = coseBase$1.__module.exports;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var coseBase$1 = require('../../../../../_virtual/cose-base2.js');
3
+ var coseBase$1 = require('../../../../../_virtual/cose-base.js');
4
4
  var layoutBase = require('../../../layout-base@2.0.1/node_modules/layout-base/layout-base.js');
5
5
 
6
6
  var coseBase = coseBase$1.__module.exports;
@@ -1,4 +1,4 @@
1
- import { __module as layoutBase$1 } from '../../../../../_virtual/layout-base2.mjs';
1
+ import { __module as layoutBase$1 } from '../../../../../_virtual/layout-base.mjs';
2
2
 
3
3
  var layoutBase = layoutBase$1.exports;
4
4
 
@@ -1,4 +1,4 @@
1
- import { __module as layoutBase$1 } from '../../../../../_virtual/layout-base.mjs';
1
+ import { __module as layoutBase$1 } from '../../../../../_virtual/layout-base2.mjs';
2
2
 
3
3
  var layoutBase = layoutBase$1.exports;
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "7.3.0",
3
+ "version": "7.3.2",
4
4
  "description": "Third-party integrated UI components for windrun-huaiin projects",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -69,8 +69,9 @@ export function withFingerprint<P extends object>(
69
69
  export function FingerprintStatus() {
70
70
  const {
71
71
  fingerprintId,
72
- anonymousUser,
73
- credits,
72
+ xUser,
73
+ xCredit,
74
+ xSubscription,
74
75
  isLoading,
75
76
  isInitialized,
76
77
  error
@@ -145,16 +146,28 @@ export function FingerprintStatus() {
145
146
  <div><strong>Loading:</strong> {isLoading ? 'Yes' : 'No'}</div>
146
147
  <div><strong>Initialized:</strong> {isInitialized ? 'Yes' : 'No'}</div>
147
148
  {error && <div style={{ color: 'red' }}><strong>Error:</strong> {error}</div>}
148
- {anonymousUser && (
149
+ {xUser && (
149
150
  <div>
150
- <strong>user_id:</strong> {anonymousUser.userId} <br/>
151
- <strong>clerk_user_id:</strong> {anonymousUser.clerkUserId} <br/>
152
- <strong>email:</strong> {anonymousUser.email || 'None'} <br/> {/* Fixed email field */}
151
+ <strong>user_id:</strong> {xUser.userId} <br/>
152
+ <strong>clerk_user_id:</strong> {xUser.clerkUserId || 'None'} <br/>
153
+ <strong>email:</strong> {xUser.email || 'None'} <br/>
153
154
  </div>
154
155
  )}
155
- {credits && (
156
+ {xCredit && (
156
157
  <div>
157
- <strong>Credits:</strong> {credits.balanceFree} Free + {credits.balancePaid} Paid = {credits.totalBalance} Total
158
+ <strong>Credits:</strong> {xCredit.balanceFree} Free + {xCredit.balancePaid} Paid = {xCredit.totalBalance} Total
159
+ </div>
160
+ )}
161
+ {xSubscription && (
162
+ <div>
163
+ <strong>user_id:</strong> {xSubscription.userId} <br/>
164
+ <strong>pay_subscription_id:</strong> {xSubscription.paySubscriptionId} <br/>
165
+ <strong>price_id:</strong> {xSubscription.priceId || 'None'} <br/>
166
+ <strong>price_name:</strong> {xSubscription.priceName || 'None'} <br/>
167
+ <strong>status:</strong> {xSubscription.status || 'Free'} <br/>
168
+ <strong>credits_allocated:</strong> {xSubscription.creditsAllocated || ''} <br/>
169
+ <strong>sub_period_start:</strong> {xSubscription.subPeriodStart || ''} <br/>
170
+ <strong>sub_period_end:</strong> {xSubscription.subPeriodEnd || ''} <br/>
158
171
  </div>
159
172
  )}
160
173
  </div>
@@ -3,7 +3,7 @@
3
3
  * 指纹识别系统的类型定义
4
4
  */
5
5
 
6
- export interface AnonymousUser {
6
+ export interface XUser {
7
7
  userId: string;
8
8
  fingerprintId: string;
9
9
  clerkUserId: string,
@@ -12,12 +12,24 @@ export interface AnonymousUser {
12
12
  createdAt: string;
13
13
  }
14
14
 
15
- export interface Credits {
15
+ export interface XCredit {
16
16
  balanceFree: number;
17
17
  balancePaid: number;
18
18
  totalBalance: number;
19
19
  }
20
20
 
21
+ export interface XSubscription {
22
+ id: bigint
23
+ userId: string
24
+ paySubscriptionId: string | null
25
+ priceId: string | null
26
+ priceName: string | null
27
+ status: string
28
+ creditsAllocated: number
29
+ subPeriodStart: string
30
+ subPeriodEnd: string
31
+ }
32
+
21
33
  export interface FingerprintConfig {
22
34
  /** API endpoint for anonymous user initialization */
23
35
  apiEndpoint: string;
@@ -29,8 +41,9 @@ export interface FingerprintConfig {
29
41
 
30
42
  export interface UseFingerprintResult {
31
43
  fingerprintId: string | null;
32
- anonymousUser: AnonymousUser | null;
33
- credits: Credits | null;
44
+ xUser: XUser | null;
45
+ xCredit: XCredit | null;
46
+ xSubscription: XSubscription | null;
34
47
  isLoading: boolean;
35
48
  isInitialized: boolean;
36
49
  error: string | null;
@@ -7,8 +7,9 @@ import {
7
7
  createFingerprintHeaders
8
8
  } from './fingerprint-client';
9
9
  import type {
10
- AnonymousUser,
11
- Credits,
10
+ XUser,
11
+ XCredit,
12
+ XSubscription,
12
13
  UseFingerprintResult,
13
14
  FingerprintConfig
14
15
  } from './types';
@@ -19,8 +20,9 @@ import type {
19
20
  */
20
21
  export function useFingerprint(config: FingerprintConfig): UseFingerprintResult {
21
22
  const [fingerprintId, setFingerprintIdState] = useState<string | null>(null);
22
- const [anonymousUser, setAnonymousUser] = useState<AnonymousUser | null>(null);
23
- const [credits, setCredits] = useState<Credits | null>(null);
23
+ const [xUser, setXUser] = useState<XUser | null>(null);
24
+ const [xCredit, setXCredit] = useState<XCredit | null>(null);
25
+ const [xSubscription, setXSubscription] = useState<XSubscription | null>(null);
24
26
  const [isLoading, setIsLoading] = useState(true);
25
27
  const [isInitialized, setIsInitialized] = useState(false);
26
28
  const [error, setError] = useState<string | null>(null);
@@ -76,8 +78,9 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
76
78
  const data = await response.json();
77
79
 
78
80
  if (data.success) {
79
- setAnonymousUser(data.user);
80
- setCredits(data.credits);
81
+ setXUser(data.xUser);
82
+ setXCredit(data.xCredit);
83
+ setXSubscription(data.xSubscription);
81
84
  setIsInitialized(true);
82
85
 
83
86
  // 确保fingerprint ID同步
@@ -123,8 +126,9 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
123
126
  const data = await response.json();
124
127
 
125
128
  if (data.success) {
126
- setAnonymousUser(data.user);
127
- setCredits(data.credits);
129
+ setXUser(data.xUser);
130
+ setXCredit(data.xCredit);
131
+ setXSubscription(data.xSubscription);
128
132
  }
129
133
  } catch (err) {
130
134
  console.error('Failed to refresh user data:', err);
@@ -148,8 +152,9 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
148
152
  if (response.ok) {
149
153
  const data = await response.json();
150
154
  if (data.success) {
151
- setAnonymousUser(data.user);
152
- setCredits(data.credits);
155
+ setXUser(data.xUser);
156
+ setXCredit(data.xCredit);
157
+ setXSubscription(data.xSubscription);
153
158
  setIsInitialized(true);
154
159
  }
155
160
  }
@@ -187,8 +192,9 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
187
192
 
188
193
  return {
189
194
  fingerprintId,
190
- anonymousUser,
191
- credits,
195
+ xUser,
196
+ xCredit,
197
+ xSubscription,
192
198
  isLoading,
193
199
  isInitialized,
194
200
  error,
@@ -15,14 +15,14 @@ export function SignInWithFingerprint() {
15
15
  // 如果没有fingerprint context,使用默认值
16
16
  const {
17
17
  fingerprintId = null,
18
- anonymousUser = null,
18
+ xUser = null,
19
19
  isInitialized = false,
20
20
  initializeAnonymousUser = async () => {}
21
21
  } = fingerprintContext || {};
22
22
 
23
23
  // 准备传递给Clerk的metadata,包含匿名用户信息
24
24
  const unsafeMetadata = {
25
- user_id: anonymousUser?.userId || null, // 数据库中的user_id
25
+ user_id: xUser?.userId || null, // 数据库中的user_id
26
26
  fingerprint_id: fingerprintId || null, // 浏览器指纹ID
27
27
  };
28
28
 
@@ -38,18 +38,18 @@ export function SignInWithFingerprint() {
38
38
  console.log('SignInWithFingerprint Debug:', {
39
39
  fingerprintProvider: fingerprintContext ? 'Available' : 'Not found',
40
40
  fingerprintId: fingerprintId || 'Not generated',
41
- anonymousUser: anonymousUser ? 'Initialized' : 'Not initialized',
41
+ xUser: xUser ? 'Initialized' : 'Not initialized',
42
42
  clerkMetadata: unsafeMetadata
43
43
  });
44
44
 
45
- if (anonymousUser && fingerprintId) {
45
+ if (xUser && fingerprintId) {
46
46
  console.log('User signed in with existing anonymous data:', {
47
- anonymousUserId: anonymousUser.userId,
47
+ userId: xUser.userId,
48
48
  fingerprintId,
49
49
  });
50
50
  // TODO: 实现数据合并逻辑
51
51
  }
52
- }, [anonymousUser, fingerprintId, fingerprintContext, unsafeMetadata]);
52
+ }, [xUser, fingerprintId, fingerprintContext, unsafeMetadata]);
53
53
 
54
54
  return <SignIn unsafeMetadata={unsafeMetadata} />;
55
55
  }
@@ -15,14 +15,14 @@ export function SignUpWithFingerprint() {
15
15
  // 如果没有fingerprint context,使用默认值
16
16
  const {
17
17
  fingerprintId = null,
18
- anonymousUser = null,
18
+ xUser = null,
19
19
  isInitialized = false,
20
20
  initializeAnonymousUser = async () => {}
21
21
  } = fingerprintContext || {};
22
22
 
23
23
  // 准备传递给Clerk的metadata,包含匿名用户信息
24
24
  const unsafeMetadata = {
25
- user_id: anonymousUser?.userId || null, // 数据库中的user_id
25
+ user_id: xUser?.userId || null, // 数据库中的user_id
26
26
  fingerprint_id: fingerprintId || null, // 浏览器指纹ID
27
27
  };
28
28
 
@@ -38,18 +38,18 @@ export function SignUpWithFingerprint() {
38
38
  console.log('SignUpWithFingerprint Debug:', {
39
39
  fingerprintProvider: fingerprintContext ? 'Available' : 'Not found',
40
40
  fingerprintId: fingerprintId || 'Not generated',
41
- anonymousUser: anonymousUser ? 'Initialized' : 'Not initialized',
41
+ xUser: xUser ? 'Initialized' : 'Not initialized',
42
42
  clerkMetadata: unsafeMetadata
43
43
  });
44
44
 
45
- if (anonymousUser && fingerprintId) {
45
+ if (xUser && fingerprintId) {
46
46
  console.log('User signed up with existing anonymous data:', {
47
- anonymousUserId: anonymousUser.userId,
47
+ userId: xUser.userId,
48
48
  fingerprintId,
49
49
  });
50
50
  // TODO: 实现数据迁移逻辑
51
51
  }
52
- }, [anonymousUser, fingerprintId, fingerprintContext, unsafeMetadata]);
52
+ }, [xUser, fingerprintId, fingerprintContext, unsafeMetadata]);
53
53
 
54
54
  return <SignUp unsafeMetadata={unsafeMetadata} />;
55
55
  }