@windrun-huaiin/third-ui 7.3.0 → 7.3.1
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/clerk/fingerprint/fingerprint-provider.js +2 -2
- package/dist/clerk/fingerprint/fingerprint-provider.mjs +2 -2
- package/dist/clerk/fingerprint/types.d.ts +12 -0
- package/dist/clerk/fingerprint/use-fingerprint.js +5 -0
- package/dist/clerk/fingerprint/use-fingerprint.mjs +5 -0
- package/dist/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.mjs +1 -1
- package/dist/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.mjs +1 -1
- package/dist/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/package.json +1 -1
- package/src/clerk/fingerprint/fingerprint-provider.tsx +15 -2
- package/src/clerk/fingerprint/types.ts +13 -0
- package/src/clerk/fingerprint/use-fingerprint.ts +6 -0
|
@@ -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, anonymousUser, credits, subscription, 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", {})
|
|
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 || 'None', " ", 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"] })), subscription && (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("strong", { children: "user_id:" }), " ", subscription.userId, " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "pay_subscription_id:" }), " ", subscription.paySubscriptionId, " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "price_id:" }), " ", subscription.priceId || 'None', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "price_name:" }), " ", subscription.priceName || 'None', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "status:" }), " ", subscription.status || 'Free', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "credits_allocated:" }), " ", subscription.creditsAllocated || '', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "sub_period_start:" }), " ", subscription.subPeriodStart || '', " ", jsxRuntime.jsx("br", {}), jsxRuntime.jsx("strong", { children: "sub_period_end:" }), " ", subscription.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, anonymousUser, credits, subscription, 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", {})
|
|
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 || 'None', " ", 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"] })), subscription && (jsxs("div", { children: [jsx("strong", { children: "user_id:" }), " ", subscription.userId, " ", jsx("br", {}), jsx("strong", { children: "pay_subscription_id:" }), " ", subscription.paySubscriptionId, " ", jsx("br", {}), jsx("strong", { children: "price_id:" }), " ", subscription.priceId || 'None', " ", jsx("br", {}), jsx("strong", { children: "price_name:" }), " ", subscription.priceName || 'None', " ", jsx("br", {}), jsx("strong", { children: "status:" }), " ", subscription.status || 'Free', " ", jsx("br", {}), jsx("strong", { children: "credits_allocated:" }), " ", subscription.creditsAllocated || '', " ", jsx("br", {}), jsx("strong", { children: "sub_period_start:" }), " ", subscription.subPeriodStart || '', " ", jsx("br", {}), jsx("strong", { children: "sub_period_end:" }), " ", subscription.subPeriodEnd || '', " ", jsx("br", {})] }))] })] }))] }));
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export { FingerprintProvider, FingerprintStatus, useFingerprintContext, useFingerprintContextSafe, withFingerprint };
|
|
@@ -15,6 +15,17 @@ export interface Credits {
|
|
|
15
15
|
balancePaid: number;
|
|
16
16
|
totalBalance: number;
|
|
17
17
|
}
|
|
18
|
+
export interface Subscription {
|
|
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;
|
|
@@ -27,6 +38,7 @@ export interface UseFingerprintResult {
|
|
|
27
38
|
fingerprintId: string | null;
|
|
28
39
|
anonymousUser: AnonymousUser | null;
|
|
29
40
|
credits: Credits | null;
|
|
41
|
+
subscription: Subscription | null;
|
|
30
42
|
isLoading: boolean;
|
|
31
43
|
isInitialized: boolean;
|
|
32
44
|
error: string | null;
|
|
@@ -13,6 +13,7 @@ function useFingerprint(config) {
|
|
|
13
13
|
const [fingerprintId, setFingerprintIdState] = React.useState(null);
|
|
14
14
|
const [anonymousUser, setAnonymousUser] = React.useState(null);
|
|
15
15
|
const [credits, setCredits] = React.useState(null);
|
|
16
|
+
const [subscription, setSubscription] = 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);
|
|
@@ -61,6 +62,7 @@ function useFingerprint(config) {
|
|
|
61
62
|
if (data.success) {
|
|
62
63
|
setAnonymousUser(data.user);
|
|
63
64
|
setCredits(data.credits);
|
|
65
|
+
setSubscription(data.subscription);
|
|
64
66
|
setIsInitialized(true);
|
|
65
67
|
// 确保fingerprint ID同步
|
|
66
68
|
if (data.user.fingerprintId !== fingerprintId) {
|
|
@@ -105,6 +107,7 @@ function useFingerprint(config) {
|
|
|
105
107
|
if (data.success) {
|
|
106
108
|
setAnonymousUser(data.user);
|
|
107
109
|
setCredits(data.credits);
|
|
110
|
+
setSubscription(data.subscription);
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
catch (err) {
|
|
@@ -129,6 +132,7 @@ function useFingerprint(config) {
|
|
|
129
132
|
if (data.success) {
|
|
130
133
|
setAnonymousUser(data.user);
|
|
131
134
|
setCredits(data.credits);
|
|
135
|
+
setSubscription(data.subscription);
|
|
132
136
|
setIsInitialized(true);
|
|
133
137
|
}
|
|
134
138
|
}
|
|
@@ -165,6 +169,7 @@ function useFingerprint(config) {
|
|
|
165
169
|
fingerprintId,
|
|
166
170
|
anonymousUser,
|
|
167
171
|
credits,
|
|
172
|
+
subscription,
|
|
168
173
|
isLoading,
|
|
169
174
|
isInitialized,
|
|
170
175
|
error,
|
|
@@ -11,6 +11,7 @@ function useFingerprint(config) {
|
|
|
11
11
|
const [fingerprintId, setFingerprintIdState] = useState(null);
|
|
12
12
|
const [anonymousUser, setAnonymousUser] = useState(null);
|
|
13
13
|
const [credits, setCredits] = useState(null);
|
|
14
|
+
const [subscription, setSubscription] = useState(null);
|
|
14
15
|
const [isLoading, setIsLoading] = useState(true);
|
|
15
16
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
16
17
|
const [error, setError] = useState(null);
|
|
@@ -59,6 +60,7 @@ function useFingerprint(config) {
|
|
|
59
60
|
if (data.success) {
|
|
60
61
|
setAnonymousUser(data.user);
|
|
61
62
|
setCredits(data.credits);
|
|
63
|
+
setSubscription(data.subscription);
|
|
62
64
|
setIsInitialized(true);
|
|
63
65
|
// 确保fingerprint ID同步
|
|
64
66
|
if (data.user.fingerprintId !== fingerprintId) {
|
|
@@ -103,6 +105,7 @@ function useFingerprint(config) {
|
|
|
103
105
|
if (data.success) {
|
|
104
106
|
setAnonymousUser(data.user);
|
|
105
107
|
setCredits(data.credits);
|
|
108
|
+
setSubscription(data.subscription);
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
catch (err) {
|
|
@@ -127,6 +130,7 @@ function useFingerprint(config) {
|
|
|
127
130
|
if (data.success) {
|
|
128
131
|
setAnonymousUser(data.user);
|
|
129
132
|
setCredits(data.credits);
|
|
133
|
+
setSubscription(data.subscription);
|
|
130
134
|
setIsInitialized(true);
|
|
131
135
|
}
|
|
132
136
|
}
|
|
@@ -163,6 +167,7 @@ function useFingerprint(config) {
|
|
|
163
167
|
fingerprintId,
|
|
164
168
|
anonymousUser,
|
|
165
169
|
credits,
|
|
170
|
+
subscription,
|
|
166
171
|
isLoading,
|
|
167
172
|
isInitialized,
|
|
168
173
|
error,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as coseBase$1 } from '../../../../../_virtual/cose-
|
|
1
|
+
import { __module as coseBase$1 } from '../../../../../_virtual/cose-base2.mjs';
|
|
2
2
|
import { __require as requireLayoutBase } from '../../../layout-base@1.0.2/node_modules/layout-base/layout-base.mjs';
|
|
3
3
|
|
|
4
4
|
var coseBase = coseBase$1.exports;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as coseBase$1 } from '../../../../../_virtual/cose-
|
|
1
|
+
import { __module as coseBase$1 } from '../../../../../_virtual/cose-base.mjs';
|
|
2
2
|
import { __require as requireLayoutBase } from '../../../layout-base@2.0.1/node_modules/layout-base/layout-base.mjs';
|
|
3
3
|
|
|
4
4
|
var coseBase = coseBase$1.exports;
|
package/package.json
CHANGED
|
@@ -71,6 +71,7 @@ export function FingerprintStatus() {
|
|
|
71
71
|
fingerprintId,
|
|
72
72
|
anonymousUser,
|
|
73
73
|
credits,
|
|
74
|
+
subscription,
|
|
74
75
|
isLoading,
|
|
75
76
|
isInitialized,
|
|
76
77
|
error
|
|
@@ -148,8 +149,8 @@ export function FingerprintStatus() {
|
|
|
148
149
|
{anonymousUser && (
|
|
149
150
|
<div>
|
|
150
151
|
<strong>user_id:</strong> {anonymousUser.userId} <br/>
|
|
151
|
-
<strong>clerk_user_id:</strong> {anonymousUser.clerkUserId} <br/>
|
|
152
|
-
<strong>email:</strong> {anonymousUser.email || 'None'} <br/>
|
|
152
|
+
<strong>clerk_user_id:</strong> {anonymousUser.clerkUserId || 'None'} <br/>
|
|
153
|
+
<strong>email:</strong> {anonymousUser.email || 'None'} <br/>
|
|
153
154
|
</div>
|
|
154
155
|
)}
|
|
155
156
|
{credits && (
|
|
@@ -157,6 +158,18 @@ export function FingerprintStatus() {
|
|
|
157
158
|
<strong>Credits:</strong> {credits.balanceFree} Free + {credits.balancePaid} Paid = {credits.totalBalance} Total
|
|
158
159
|
</div>
|
|
159
160
|
)}
|
|
161
|
+
{subscription && (
|
|
162
|
+
<div>
|
|
163
|
+
<strong>user_id:</strong> {subscription.userId} <br/>
|
|
164
|
+
<strong>pay_subscription_id:</strong> {subscription.paySubscriptionId} <br/>
|
|
165
|
+
<strong>price_id:</strong> {subscription.priceId || 'None'} <br/>
|
|
166
|
+
<strong>price_name:</strong> {subscription.priceName || 'None'} <br/>
|
|
167
|
+
<strong>status:</strong> {subscription.status || 'Free'} <br/>
|
|
168
|
+
<strong>credits_allocated:</strong> {subscription.creditsAllocated || ''} <br/>
|
|
169
|
+
<strong>sub_period_start:</strong> {subscription.subPeriodStart || ''} <br/>
|
|
170
|
+
<strong>sub_period_end:</strong> {subscription.subPeriodEnd || ''} <br/>
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
160
173
|
</div>
|
|
161
174
|
</>
|
|
162
175
|
)}
|
|
@@ -18,6 +18,18 @@ export interface Credits {
|
|
|
18
18
|
totalBalance: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export interface Subscription {
|
|
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;
|
|
@@ -31,6 +43,7 @@ export interface UseFingerprintResult {
|
|
|
31
43
|
fingerprintId: string | null;
|
|
32
44
|
anonymousUser: AnonymousUser | null;
|
|
33
45
|
credits: Credits | null;
|
|
46
|
+
subscription: Subscription | null;
|
|
34
47
|
isLoading: boolean;
|
|
35
48
|
isInitialized: boolean;
|
|
36
49
|
error: string | null;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import type {
|
|
10
10
|
AnonymousUser,
|
|
11
11
|
Credits,
|
|
12
|
+
Subscription,
|
|
12
13
|
UseFingerprintResult,
|
|
13
14
|
FingerprintConfig
|
|
14
15
|
} from './types';
|
|
@@ -21,6 +22,7 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
|
|
|
21
22
|
const [fingerprintId, setFingerprintIdState] = useState<string | null>(null);
|
|
22
23
|
const [anonymousUser, setAnonymousUser] = useState<AnonymousUser | null>(null);
|
|
23
24
|
const [credits, setCredits] = useState<Credits | null>(null);
|
|
25
|
+
const [subscription, setSubscription] = useState<Subscription | 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);
|
|
@@ -78,6 +80,7 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
|
|
|
78
80
|
if (data.success) {
|
|
79
81
|
setAnonymousUser(data.user);
|
|
80
82
|
setCredits(data.credits);
|
|
83
|
+
setSubscription(data.subscription);
|
|
81
84
|
setIsInitialized(true);
|
|
82
85
|
|
|
83
86
|
// 确保fingerprint ID同步
|
|
@@ -125,6 +128,7 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
|
|
|
125
128
|
if (data.success) {
|
|
126
129
|
setAnonymousUser(data.user);
|
|
127
130
|
setCredits(data.credits);
|
|
131
|
+
setSubscription(data.subscription);
|
|
128
132
|
}
|
|
129
133
|
} catch (err) {
|
|
130
134
|
console.error('Failed to refresh user data:', err);
|
|
@@ -150,6 +154,7 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
|
|
|
150
154
|
if (data.success) {
|
|
151
155
|
setAnonymousUser(data.user);
|
|
152
156
|
setCredits(data.credits);
|
|
157
|
+
setSubscription(data.subscription);
|
|
153
158
|
setIsInitialized(true);
|
|
154
159
|
}
|
|
155
160
|
}
|
|
@@ -189,6 +194,7 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
|
|
|
189
194
|
fingerprintId,
|
|
190
195
|
anonymousUser,
|
|
191
196
|
credits,
|
|
197
|
+
subscription,
|
|
192
198
|
isLoading,
|
|
193
199
|
isInitialized,
|
|
194
200
|
error,
|