@windrun-huaiin/third-ui 7.3.11 → 7.3.13
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/_virtual/cytoscape-cose-bilkent.js +1 -1
- package/dist/_virtual/cytoscape-cose-bilkent.mjs +1 -1
- package/dist/_virtual/cytoscape-fcose.js +1 -1
- package/dist/_virtual/cytoscape-fcose.mjs +1 -1
- package/dist/lib/clerk-intl.d.ts +3 -4566
- package/dist/main/faq.js +0 -1
- package/dist/main/faq.mjs +0 -1
- package/dist/main/gallery.js +0 -1
- package/dist/main/gallery.mjs +0 -1
- package/dist/main/money-price/money-price-button.js +36 -15
- package/dist/main/money-price/money-price-button.mjs +36 -15
- package/dist/main/money-price/money-price-interactive.js +15 -9
- package/dist/main/money-price/money-price-interactive.mjs +16 -10
- package/dist/main/money-price/money-price.js +1 -14
- package/dist/main/money-price/money-price.mjs +1 -14
- package/dist/main/price-plan.js +0 -1
- package/dist/main/price-plan.mjs +0 -1
- package/dist/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/node_modules/.pnpm/{cytoscape@3.33.0 → cytoscape@3.33.1}/node_modules/cytoscape/dist/cytoscape.esm.js +19 -2
- package/dist/node_modules/.pnpm/{cytoscape@3.33.0 → cytoscape@3.33.1}/node_modules/cytoscape/dist/cytoscape.esm.mjs +19 -2
- 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/dist/node_modules/.pnpm/mermaid@11.9.0/node_modules/mermaid/dist/chunks/mermaid.core/architectureDiagram-SUXI7LT5.js +1 -1
- package/dist/node_modules/.pnpm/mermaid@11.9.0/node_modules/mermaid/dist/chunks/mermaid.core/architectureDiagram-SUXI7LT5.mjs +1 -1
- package/dist/node_modules/.pnpm/mermaid@11.9.0/node_modules/mermaid/dist/chunks/mermaid.core/mindmap-definition-6CBA2TL7.js +1 -1
- package/dist/node_modules/.pnpm/mermaid@11.9.0/node_modules/mermaid/dist/chunks/mermaid.core/mindmap-definition-6CBA2TL7.mjs +1 -1
- package/package.json +1 -1
- package/src/main/money-price/money-price-button.tsx +48 -24
- package/src/main/money-price/money-price-interactive.tsx +38 -21
- package/src/main/money-price/money-price.tsx +6 -8
- package/dist/clerk/client-page-generator.d.ts +0 -10
- package/dist/clerk/client-page-generator.js +0 -28
- package/dist/clerk/client-page-generator.mjs +0 -25
- package/dist/clerk/context/FingerprintProvider.d.ts +0 -25
- package/dist/clerk/context/FingerprintProvider.js +0 -71
- package/dist/clerk/context/FingerprintProvider.mjs +0 -65
- package/dist/clerk/fingerprint/fingerprint.d.ts +0 -55
- package/dist/clerk/fingerprint/fingerprint.js +0 -17
- package/dist/clerk/fingerprint/fingerprint.mjs +0 -15
- package/dist/clerk/fingerprint.d.ts +0 -55
- package/dist/clerk/fingerprint.js +0 -237
- package/dist/clerk/fingerprint.mjs +0 -225
- package/dist/clerk/hooks/useFingerprint.d.ts +0 -6
- package/dist/clerk/hooks/useFingerprint.js +0 -182
- package/dist/clerk/hooks/useFingerprint.mjs +0 -180
- package/dist/clerk/types.d.ts +0 -42
- package/dist/main/money-price/money-price-config.d.ts +0 -8
- package/dist/main/money-price/money-price-config.js +0 -223
- package/dist/main/money-price/money-price-config.mjs +0 -219
- /package/dist/node_modules/.pnpm/{cytoscape-cose-bilkent@4.1.0_cytoscape@3.33.0 → cytoscape-cose-bilkent@4.1.0_cytoscape@3.33.1}/node_modules/cytoscape-cose-bilkent/cytoscape-cose-bilkent.js +0 -0
- /package/dist/node_modules/.pnpm/{cytoscape-cose-bilkent@4.1.0_cytoscape@3.33.0 → cytoscape-cose-bilkent@4.1.0_cytoscape@3.33.1}/node_modules/cytoscape-cose-bilkent/cytoscape-cose-bilkent.mjs +0 -0
- /package/dist/node_modules/.pnpm/{cytoscape-fcose@2.2.0_cytoscape@3.33.0 → cytoscape-fcose@2.2.0_cytoscape@3.33.1}/node_modules/cytoscape-fcose/cytoscape-fcose.js +0 -0
- /package/dist/node_modules/.pnpm/{cytoscape-fcose@2.2.0_cytoscape@3.33.0 → cytoscape-fcose@2.2.0_cytoscape@3.33.1}/node_modules/cytoscape-fcose/cytoscape-fcose.mjs +0 -0
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var tslib_es6 = require('../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.js');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var fingerprint = require('../fingerprint.js');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Hook for managing fingerprint ID and anonymous user data
|
|
10
|
-
* Accepts configuration to customize API endpoint and behavior
|
|
11
|
-
*/
|
|
12
|
-
function useFingerprint(config) {
|
|
13
|
-
const [fingerprintId, setFingerprintIdState] = React.useState(null);
|
|
14
|
-
const [anonymousUser, setAnonymousUser] = React.useState(null);
|
|
15
|
-
const [credits, setCredits] = React.useState(null);
|
|
16
|
-
const [isLoading, setIsLoading] = React.useState(true);
|
|
17
|
-
const [isInitialized, setIsInitialized] = React.useState(false);
|
|
18
|
-
const [error, setError] = React.useState(null);
|
|
19
|
-
/**
|
|
20
|
-
* 第一阶段:初始化fingerprint ID
|
|
21
|
-
*/
|
|
22
|
-
const initializeFingerprintId = React.useCallback(() => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
if (typeof window === 'undefined')
|
|
24
|
-
return null;
|
|
25
|
-
try {
|
|
26
|
-
// 优先检查现有ID
|
|
27
|
-
const existingId = fingerprint.getFingerprintId();
|
|
28
|
-
if (existingId) {
|
|
29
|
-
setFingerprintIdState(existingId);
|
|
30
|
-
return existingId;
|
|
31
|
-
}
|
|
32
|
-
// 生成新的fingerprint ID
|
|
33
|
-
const currentFingerprintId = yield fingerprint.getOrGenerateFingerprintId();
|
|
34
|
-
setFingerprintIdState(currentFingerprintId);
|
|
35
|
-
return currentFingerprintId;
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.error('Failed to initialize fingerprint ID:', error);
|
|
39
|
-
setError('Failed to generate fingerprint ID');
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}), []);
|
|
43
|
-
/**
|
|
44
|
-
* 第二阶段:初始化匿名用户
|
|
45
|
-
*/
|
|
46
|
-
const initializeAnonymousUser = React.useCallback(() => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (!fingerprintId) {
|
|
48
|
-
console.warn('Cannot initialize user without fingerprint ID');
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
setIsLoading(true);
|
|
53
|
-
setError(null);
|
|
54
|
-
const fingerprintHeaders = yield fingerprint.createFingerprintHeaders();
|
|
55
|
-
const response = yield fetch(config.apiEndpoint, {
|
|
56
|
-
method: 'POST',
|
|
57
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, fingerprintHeaders),
|
|
58
|
-
body: JSON.stringify({
|
|
59
|
-
fingerprintId: fingerprintId,
|
|
60
|
-
}),
|
|
61
|
-
});
|
|
62
|
-
if (!response.ok) {
|
|
63
|
-
const errorData = yield response.json().catch(() => ({}));
|
|
64
|
-
throw new Error(errorData.error || 'Failed to initialize anonymous user');
|
|
65
|
-
}
|
|
66
|
-
const data = yield response.json();
|
|
67
|
-
if (data.success) {
|
|
68
|
-
setAnonymousUser(data.user);
|
|
69
|
-
setCredits(data.credits);
|
|
70
|
-
setIsInitialized(true);
|
|
71
|
-
// 确保fingerprint ID同步
|
|
72
|
-
if (data.user.fingerprintId !== fingerprintId) {
|
|
73
|
-
fingerprint.setFingerprintId(data.user.fingerprintId);
|
|
74
|
-
setFingerprintIdState(data.user.fingerprintId);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
throw new Error(data.error || 'Unknown error occurred');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
console.error('Failed to initialize anonymous user:', err);
|
|
83
|
-
setError(err instanceof Error ? err.message : 'Unknown error');
|
|
84
|
-
}
|
|
85
|
-
finally {
|
|
86
|
-
setIsLoading(false);
|
|
87
|
-
}
|
|
88
|
-
}), [fingerprintId]);
|
|
89
|
-
/**
|
|
90
|
-
* 刷新用户数据
|
|
91
|
-
*/
|
|
92
|
-
const refreshUserData = React.useCallback(() => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
if (!fingerprintId)
|
|
94
|
-
return;
|
|
95
|
-
try {
|
|
96
|
-
setError(null);
|
|
97
|
-
const fingerprintHeaders = yield fingerprint.createFingerprintHeaders();
|
|
98
|
-
const response = yield fetch(`${config.apiEndpoint}?fingerprintId=${fingerprintId}`, {
|
|
99
|
-
method: 'GET',
|
|
100
|
-
headers: fingerprintHeaders,
|
|
101
|
-
});
|
|
102
|
-
if (!response.ok) {
|
|
103
|
-
if (response.status === 404) {
|
|
104
|
-
// 用户不存在,需要重新初始化
|
|
105
|
-
yield initializeAnonymousUser();
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
throw new Error('Failed to fetch user data');
|
|
109
|
-
}
|
|
110
|
-
const data = yield response.json();
|
|
111
|
-
if (data.success) {
|
|
112
|
-
setAnonymousUser(data.user);
|
|
113
|
-
setCredits(data.credits);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
console.error('Failed to refresh user data:', err);
|
|
118
|
-
setError(err instanceof Error ? err.message : 'Unknown error');
|
|
119
|
-
}
|
|
120
|
-
}), [fingerprintId, initializeAnonymousUser, config.apiEndpoint]);
|
|
121
|
-
/**
|
|
122
|
-
* 检查现有用户数据(仅在有fingerprint ID时执行)
|
|
123
|
-
*/
|
|
124
|
-
const checkExistingUser = React.useCallback(() => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
if (!fingerprintId)
|
|
126
|
-
return;
|
|
127
|
-
try {
|
|
128
|
-
const fingerprintHeaders = yield fingerprint.createFingerprintHeaders();
|
|
129
|
-
const response = yield fetch(`${config.apiEndpoint}?fingerprintId=${fingerprintId}`, {
|
|
130
|
-
method: 'GET',
|
|
131
|
-
headers: fingerprintHeaders,
|
|
132
|
-
});
|
|
133
|
-
if (response.ok) {
|
|
134
|
-
const data = yield response.json();
|
|
135
|
-
if (data.success) {
|
|
136
|
-
setAnonymousUser(data.user);
|
|
137
|
-
setCredits(data.credits);
|
|
138
|
-
setIsInitialized(true);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
catch (err) {
|
|
143
|
-
console.error('Failed to check existing user:', err);
|
|
144
|
-
}
|
|
145
|
-
}), [fingerprintId, config.apiEndpoint]);
|
|
146
|
-
// 第一阶段:页面加载完成后生成指纹ID
|
|
147
|
-
React.useEffect(() => {
|
|
148
|
-
if (typeof window === 'undefined')
|
|
149
|
-
return;
|
|
150
|
-
const initFingerprint = () => tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
yield initializeFingerprintId();
|
|
152
|
-
setIsLoading(false); // 第一阶段完成,结束加载状态
|
|
153
|
-
});
|
|
154
|
-
initFingerprint();
|
|
155
|
-
}, [initializeFingerprintId]);
|
|
156
|
-
// 第二阶段:有指纹ID后检查现有用户
|
|
157
|
-
React.useEffect(() => {
|
|
158
|
-
if (!fingerprintId || isInitialized)
|
|
159
|
-
return;
|
|
160
|
-
checkExistingUser();
|
|
161
|
-
}, [fingerprintId, isInitialized, checkExistingUser]);
|
|
162
|
-
// 第三阶段:如果没有现有用户且自动初始化开启,则创建新用户
|
|
163
|
-
React.useEffect(() => {
|
|
164
|
-
if (!fingerprintId || isInitialized || isLoading || error)
|
|
165
|
-
return;
|
|
166
|
-
if (config.autoInitialize === false)
|
|
167
|
-
return;
|
|
168
|
-
initializeAnonymousUser();
|
|
169
|
-
}, [fingerprintId, isInitialized, isLoading, error, initializeAnonymousUser, config.autoInitialize]);
|
|
170
|
-
return {
|
|
171
|
-
fingerprintId,
|
|
172
|
-
anonymousUser,
|
|
173
|
-
credits,
|
|
174
|
-
isLoading,
|
|
175
|
-
isInitialized,
|
|
176
|
-
error,
|
|
177
|
-
initializeAnonymousUser,
|
|
178
|
-
refreshUserData,
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
exports.useFingerprint = useFingerprint;
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { __awaiter } from '../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.2/node_modules/tslib/tslib.es6.mjs';
|
|
3
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
4
|
-
import { getFingerprintId, getOrGenerateFingerprintId, createFingerprintHeaders, setFingerprintId } from '../fingerprint.mjs';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Hook for managing fingerprint ID and anonymous user data
|
|
8
|
-
* Accepts configuration to customize API endpoint and behavior
|
|
9
|
-
*/
|
|
10
|
-
function useFingerprint(config) {
|
|
11
|
-
const [fingerprintId, setFingerprintIdState] = useState(null);
|
|
12
|
-
const [anonymousUser, setAnonymousUser] = useState(null);
|
|
13
|
-
const [credits, setCredits] = useState(null);
|
|
14
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
15
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
16
|
-
const [error, setError] = useState(null);
|
|
17
|
-
/**
|
|
18
|
-
* 第一阶段:初始化fingerprint ID
|
|
19
|
-
*/
|
|
20
|
-
const initializeFingerprintId = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
if (typeof window === 'undefined')
|
|
22
|
-
return null;
|
|
23
|
-
try {
|
|
24
|
-
// 优先检查现有ID
|
|
25
|
-
const existingId = getFingerprintId();
|
|
26
|
-
if (existingId) {
|
|
27
|
-
setFingerprintIdState(existingId);
|
|
28
|
-
return existingId;
|
|
29
|
-
}
|
|
30
|
-
// 生成新的fingerprint ID
|
|
31
|
-
const currentFingerprintId = yield getOrGenerateFingerprintId();
|
|
32
|
-
setFingerprintIdState(currentFingerprintId);
|
|
33
|
-
return currentFingerprintId;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
console.error('Failed to initialize fingerprint ID:', error);
|
|
37
|
-
setError('Failed to generate fingerprint ID');
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}), []);
|
|
41
|
-
/**
|
|
42
|
-
* 第二阶段:初始化匿名用户
|
|
43
|
-
*/
|
|
44
|
-
const initializeAnonymousUser = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (!fingerprintId) {
|
|
46
|
-
console.warn('Cannot initialize user without fingerprint ID');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
setIsLoading(true);
|
|
51
|
-
setError(null);
|
|
52
|
-
const fingerprintHeaders = yield createFingerprintHeaders();
|
|
53
|
-
const response = yield fetch(config.apiEndpoint, {
|
|
54
|
-
method: 'POST',
|
|
55
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, fingerprintHeaders),
|
|
56
|
-
body: JSON.stringify({
|
|
57
|
-
fingerprintId: fingerprintId,
|
|
58
|
-
}),
|
|
59
|
-
});
|
|
60
|
-
if (!response.ok) {
|
|
61
|
-
const errorData = yield response.json().catch(() => ({}));
|
|
62
|
-
throw new Error(errorData.error || 'Failed to initialize anonymous user');
|
|
63
|
-
}
|
|
64
|
-
const data = yield response.json();
|
|
65
|
-
if (data.success) {
|
|
66
|
-
setAnonymousUser(data.user);
|
|
67
|
-
setCredits(data.credits);
|
|
68
|
-
setIsInitialized(true);
|
|
69
|
-
// 确保fingerprint ID同步
|
|
70
|
-
if (data.user.fingerprintId !== fingerprintId) {
|
|
71
|
-
setFingerprintId(data.user.fingerprintId);
|
|
72
|
-
setFingerprintIdState(data.user.fingerprintId);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
throw new Error(data.error || 'Unknown error occurred');
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
console.error('Failed to initialize anonymous user:', err);
|
|
81
|
-
setError(err instanceof Error ? err.message : 'Unknown error');
|
|
82
|
-
}
|
|
83
|
-
finally {
|
|
84
|
-
setIsLoading(false);
|
|
85
|
-
}
|
|
86
|
-
}), [fingerprintId]);
|
|
87
|
-
/**
|
|
88
|
-
* 刷新用户数据
|
|
89
|
-
*/
|
|
90
|
-
const refreshUserData = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
if (!fingerprintId)
|
|
92
|
-
return;
|
|
93
|
-
try {
|
|
94
|
-
setError(null);
|
|
95
|
-
const fingerprintHeaders = yield createFingerprintHeaders();
|
|
96
|
-
const response = yield fetch(`${config.apiEndpoint}?fingerprintId=${fingerprintId}`, {
|
|
97
|
-
method: 'GET',
|
|
98
|
-
headers: fingerprintHeaders,
|
|
99
|
-
});
|
|
100
|
-
if (!response.ok) {
|
|
101
|
-
if (response.status === 404) {
|
|
102
|
-
// 用户不存在,需要重新初始化
|
|
103
|
-
yield initializeAnonymousUser();
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
throw new Error('Failed to fetch user data');
|
|
107
|
-
}
|
|
108
|
-
const data = yield response.json();
|
|
109
|
-
if (data.success) {
|
|
110
|
-
setAnonymousUser(data.user);
|
|
111
|
-
setCredits(data.credits);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
console.error('Failed to refresh user data:', err);
|
|
116
|
-
setError(err instanceof Error ? err.message : 'Unknown error');
|
|
117
|
-
}
|
|
118
|
-
}), [fingerprintId, initializeAnonymousUser, config.apiEndpoint]);
|
|
119
|
-
/**
|
|
120
|
-
* 检查现有用户数据(仅在有fingerprint ID时执行)
|
|
121
|
-
*/
|
|
122
|
-
const checkExistingUser = useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
if (!fingerprintId)
|
|
124
|
-
return;
|
|
125
|
-
try {
|
|
126
|
-
const fingerprintHeaders = yield createFingerprintHeaders();
|
|
127
|
-
const response = yield fetch(`${config.apiEndpoint}?fingerprintId=${fingerprintId}`, {
|
|
128
|
-
method: 'GET',
|
|
129
|
-
headers: fingerprintHeaders,
|
|
130
|
-
});
|
|
131
|
-
if (response.ok) {
|
|
132
|
-
const data = yield response.json();
|
|
133
|
-
if (data.success) {
|
|
134
|
-
setAnonymousUser(data.user);
|
|
135
|
-
setCredits(data.credits);
|
|
136
|
-
setIsInitialized(true);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
catch (err) {
|
|
141
|
-
console.error('Failed to check existing user:', err);
|
|
142
|
-
}
|
|
143
|
-
}), [fingerprintId, config.apiEndpoint]);
|
|
144
|
-
// 第一阶段:页面加载完成后生成指纹ID
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
if (typeof window === 'undefined')
|
|
147
|
-
return;
|
|
148
|
-
const initFingerprint = () => __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
yield initializeFingerprintId();
|
|
150
|
-
setIsLoading(false); // 第一阶段完成,结束加载状态
|
|
151
|
-
});
|
|
152
|
-
initFingerprint();
|
|
153
|
-
}, [initializeFingerprintId]);
|
|
154
|
-
// 第二阶段:有指纹ID后检查现有用户
|
|
155
|
-
useEffect(() => {
|
|
156
|
-
if (!fingerprintId || isInitialized)
|
|
157
|
-
return;
|
|
158
|
-
checkExistingUser();
|
|
159
|
-
}, [fingerprintId, isInitialized, checkExistingUser]);
|
|
160
|
-
// 第三阶段:如果没有现有用户且自动初始化开启,则创建新用户
|
|
161
|
-
useEffect(() => {
|
|
162
|
-
if (!fingerprintId || isInitialized || isLoading || error)
|
|
163
|
-
return;
|
|
164
|
-
if (config.autoInitialize === false)
|
|
165
|
-
return;
|
|
166
|
-
initializeAnonymousUser();
|
|
167
|
-
}, [fingerprintId, isInitialized, isLoading, error, initializeAnonymousUser, config.autoInitialize]);
|
|
168
|
-
return {
|
|
169
|
-
fingerprintId,
|
|
170
|
-
anonymousUser,
|
|
171
|
-
credits,
|
|
172
|
-
isLoading,
|
|
173
|
-
isInitialized,
|
|
174
|
-
error,
|
|
175
|
-
initializeAnonymousUser,
|
|
176
|
-
refreshUserData,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export { useFingerprint };
|
package/dist/clerk/types.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fingerprint System Types
|
|
3
|
-
* 指纹识别系统的类型定义
|
|
4
|
-
*/
|
|
5
|
-
export interface AnonymousUser {
|
|
6
|
-
userId: string;
|
|
7
|
-
fingerprintId: string;
|
|
8
|
-
status: string;
|
|
9
|
-
createdAt: string;
|
|
10
|
-
}
|
|
11
|
-
export interface Credits {
|
|
12
|
-
balanceFree: number;
|
|
13
|
-
balancePaid: number;
|
|
14
|
-
totalBalance: number;
|
|
15
|
-
}
|
|
16
|
-
export interface FingerprintConfig {
|
|
17
|
-
/** API endpoint for anonymous user initialization */
|
|
18
|
-
apiEndpoint: string;
|
|
19
|
-
/** Whether to automatically initialize the user on load */
|
|
20
|
-
autoInitialize?: boolean;
|
|
21
|
-
/** Initial credits for new users */
|
|
22
|
-
initialCredits?: number;
|
|
23
|
-
}
|
|
24
|
-
export interface UseFingerprintResult {
|
|
25
|
-
fingerprintId: string | null;
|
|
26
|
-
anonymousUser: AnonymousUser | null;
|
|
27
|
-
credits: Credits | null;
|
|
28
|
-
isLoading: boolean;
|
|
29
|
-
isInitialized: boolean;
|
|
30
|
-
error: string | null;
|
|
31
|
-
initializeAnonymousUser: () => Promise<void>;
|
|
32
|
-
refreshUserData: () => Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
export interface FingerprintContextType extends UseFingerprintResult {
|
|
35
|
-
}
|
|
36
|
-
export interface FingerprintProviderProps {
|
|
37
|
-
children: React.ReactNode;
|
|
38
|
-
config: FingerprintConfig;
|
|
39
|
-
}
|
|
40
|
-
export interface FingerprintFetch {
|
|
41
|
-
(url: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
42
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Money Price Configuration
|
|
3
|
-
* 价格组件配置文件
|
|
4
|
-
*/
|
|
5
|
-
import type { MoneyPriceConfig, PaymentProviderConfig, EnhancePricePlan } from './money-price-types';
|
|
6
|
-
export declare const moneyPriceConfig: MoneyPriceConfig;
|
|
7
|
-
export declare function getActiveProviderConfig(config: MoneyPriceConfig): PaymentProviderConfig;
|
|
8
|
-
export declare function getProductPricing(productKey: 'free' | 'pro' | 'ultra', billingType: 'monthly' | 'yearly', provider: string, config: MoneyPriceConfig): EnhancePricePlan;
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Money Price Configuration
|
|
5
|
-
* 价格组件配置文件
|
|
6
|
-
*/
|
|
7
|
-
// 示例配置
|
|
8
|
-
const moneyPriceConfig = {
|
|
9
|
-
paymentProviders: {
|
|
10
|
-
stripe: {
|
|
11
|
-
provider: 'stripe',
|
|
12
|
-
enabled: true,
|
|
13
|
-
products: {
|
|
14
|
-
free: {
|
|
15
|
-
key: 'free',
|
|
16
|
-
name: 'free', // Just a key, actual display name comes from translation
|
|
17
|
-
plans: {
|
|
18
|
-
monthly: {
|
|
19
|
-
priceId: 'free',
|
|
20
|
-
amount: 0,
|
|
21
|
-
currency: 'usd',
|
|
22
|
-
credits: 0
|
|
23
|
-
},
|
|
24
|
-
yearly: {
|
|
25
|
-
priceId: 'free',
|
|
26
|
-
amount: 0,
|
|
27
|
-
currency: 'usd',
|
|
28
|
-
credits: 0
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
pro: {
|
|
33
|
-
key: 'pro',
|
|
34
|
-
name: 'pro', // Just a key, actual display name comes from translation
|
|
35
|
-
plans: {
|
|
36
|
-
monthly: {
|
|
37
|
-
priceId: process.env.NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PRICE_ID || 'price_pro_monthly',
|
|
38
|
-
amount: Number(process.env.NEXT_PUBLIC_STRIPE_PRO_MONTHLY_AMOUNT) || 10,
|
|
39
|
-
currency: process.env.NEXT_PUBLIC_STRIPE_PRO_MONTHLY_CURRENCY || 'usd',
|
|
40
|
-
credits: Number(process.env.NEXT_PUBLIC_STRIPE_PRO_MONTHLY_CREDITS) || 100
|
|
41
|
-
},
|
|
42
|
-
yearly: {
|
|
43
|
-
priceId: process.env.NEXT_PUBLIC_STRIPE_PRO_YEARLY_PRICE_ID || 'price_pro_yearly',
|
|
44
|
-
amount: Number(process.env.NEXT_PUBLIC_STRIPE_PRO_YEARLY_AMOUNT) || 96,
|
|
45
|
-
originalAmount: 120,
|
|
46
|
-
discountPercent: 20,
|
|
47
|
-
currency: process.env.NEXT_PUBLIC_STRIPE_PRO_YEARLY_CURRENCY || 'usd',
|
|
48
|
-
credits: Number(process.env.NEXT_PUBLIC_STRIPE_PRO_YEARLY_CREDITS) || 1200
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
ultra: {
|
|
53
|
-
key: 'ultra',
|
|
54
|
-
name: 'ultra', // Just a key, actual display name comes from translation
|
|
55
|
-
plans: {
|
|
56
|
-
monthly: {
|
|
57
|
-
priceId: process.env.NEXT_PUBLIC_STRIPE_ULTRA_MONTHLY_PRICE_ID || 'price_ultra_monthly',
|
|
58
|
-
amount: Number(process.env.NEXT_PUBLIC_STRIPE_ULTRA_MONTHLY_AMOUNT) || 20,
|
|
59
|
-
currency: process.env.NEXT_PUBLIC_STRIPE_ULTRA_MONTHLY_CURRENCY || 'usd',
|
|
60
|
-
credits: Number(process.env.NEXT_PUBLIC_STRIPE_ULTRA_MONTHLY_CREDITS) || 250
|
|
61
|
-
},
|
|
62
|
-
yearly: {
|
|
63
|
-
priceId: process.env.NEXT_PUBLIC_STRIPE_ULTRA_YEARLY_PRICE_ID || 'price_ultra_yearly',
|
|
64
|
-
amount: Number(process.env.NEXT_PUBLIC_STRIPE_ULTRA_YEARLY_AMOUNT) || 192,
|
|
65
|
-
originalAmount: 240,
|
|
66
|
-
discountPercent: 20,
|
|
67
|
-
currency: process.env.NEXT_PUBLIC_STRIPE_ULTRA_YEARLY_CURRENCY || 'usd',
|
|
68
|
-
credits: Number(process.env.NEXT_PUBLIC_STRIPE_ULTRA_YEARLY_CREDITS) || 3000
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
alipay: {
|
|
75
|
-
provider: 'alipay',
|
|
76
|
-
enabled: false,
|
|
77
|
-
products: {
|
|
78
|
-
free: {
|
|
79
|
-
key: 'free',
|
|
80
|
-
name: 'free',
|
|
81
|
-
plans: {
|
|
82
|
-
monthly: {
|
|
83
|
-
priceId: 'free',
|
|
84
|
-
amount: 0,
|
|
85
|
-
currency: 'cny',
|
|
86
|
-
credits: 0
|
|
87
|
-
},
|
|
88
|
-
yearly: {
|
|
89
|
-
priceId: 'free',
|
|
90
|
-
amount: 0,
|
|
91
|
-
currency: 'cny',
|
|
92
|
-
credits: 0
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
pro: {
|
|
97
|
-
key: 'pro',
|
|
98
|
-
name: 'pro',
|
|
99
|
-
plans: {
|
|
100
|
-
monthly: {
|
|
101
|
-
priceId: 'alipay_pro_monthly',
|
|
102
|
-
amount: 70,
|
|
103
|
-
currency: 'cny',
|
|
104
|
-
credits: 100
|
|
105
|
-
},
|
|
106
|
-
yearly: {
|
|
107
|
-
priceId: 'alipay_pro_yearly',
|
|
108
|
-
amount: 672,
|
|
109
|
-
originalAmount: 840,
|
|
110
|
-
discountPercent: 20,
|
|
111
|
-
currency: 'cny',
|
|
112
|
-
credits: 1200
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
ultra: {
|
|
117
|
-
key: 'ultra',
|
|
118
|
-
name: 'ultra',
|
|
119
|
-
plans: {
|
|
120
|
-
monthly: {
|
|
121
|
-
priceId: 'alipay_ultra_monthly',
|
|
122
|
-
amount: 140,
|
|
123
|
-
currency: 'cny',
|
|
124
|
-
credits: 250
|
|
125
|
-
},
|
|
126
|
-
yearly: {
|
|
127
|
-
priceId: 'alipay_ultra_yearly',
|
|
128
|
-
amount: 1344,
|
|
129
|
-
originalAmount: 1680,
|
|
130
|
-
discountPercent: 20,
|
|
131
|
-
currency: 'cny',
|
|
132
|
-
credits: 3000
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
wechat: {
|
|
139
|
-
provider: 'wechat',
|
|
140
|
-
enabled: false,
|
|
141
|
-
products: {
|
|
142
|
-
free: {
|
|
143
|
-
key: 'free',
|
|
144
|
-
name: 'free',
|
|
145
|
-
plans: {
|
|
146
|
-
monthly: {
|
|
147
|
-
priceId: 'free',
|
|
148
|
-
amount: 0,
|
|
149
|
-
currency: 'cny',
|
|
150
|
-
credits: 0
|
|
151
|
-
},
|
|
152
|
-
yearly: {
|
|
153
|
-
priceId: 'free',
|
|
154
|
-
amount: 0,
|
|
155
|
-
currency: 'cny',
|
|
156
|
-
credits: 0
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
pro: {
|
|
161
|
-
key: 'pro',
|
|
162
|
-
name: 'pro',
|
|
163
|
-
plans: {
|
|
164
|
-
monthly: {
|
|
165
|
-
priceId: 'wechat_pro_monthly',
|
|
166
|
-
amount: 70,
|
|
167
|
-
currency: 'cny',
|
|
168
|
-
credits: 100
|
|
169
|
-
},
|
|
170
|
-
yearly: {
|
|
171
|
-
priceId: 'wechat_pro_yearly',
|
|
172
|
-
amount: 672,
|
|
173
|
-
originalAmount: 840,
|
|
174
|
-
discountPercent: 20,
|
|
175
|
-
currency: 'cny',
|
|
176
|
-
credits: 1200
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
ultra: {
|
|
181
|
-
key: 'ultra',
|
|
182
|
-
name: 'ultra',
|
|
183
|
-
plans: {
|
|
184
|
-
monthly: {
|
|
185
|
-
priceId: 'wechat_ultra_monthly',
|
|
186
|
-
amount: 140,
|
|
187
|
-
currency: 'cny',
|
|
188
|
-
credits: 250
|
|
189
|
-
},
|
|
190
|
-
yearly: {
|
|
191
|
-
priceId: 'wechat_ultra_yearly',
|
|
192
|
-
amount: 1344,
|
|
193
|
-
originalAmount: 1680,
|
|
194
|
-
discountPercent: 20,
|
|
195
|
-
currency: 'cny',
|
|
196
|
-
credits: 3000
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
activeProvider: process.env.NEXT_PUBLIC_ACTIVE_PAYMENT_PROVIDER || 'stripe',
|
|
204
|
-
display: {
|
|
205
|
-
currency: '$',
|
|
206
|
-
locale: 'en',
|
|
207
|
-
minFeaturesCount: 4
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
// 辅助函数:获取当前激活的支付供应商配置
|
|
211
|
-
function getActiveProviderConfig(config) {
|
|
212
|
-
const provider = config.activeProvider;
|
|
213
|
-
return config.paymentProviders[provider];
|
|
214
|
-
}
|
|
215
|
-
// 辅助函数:获取特定产品的价格信息
|
|
216
|
-
function getProductPricing(productKey, billingType, provider, config) {
|
|
217
|
-
const providerConfig = config.paymentProviders[provider];
|
|
218
|
-
return providerConfig.products[productKey].plans[billingType];
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
exports.getActiveProviderConfig = getActiveProviderConfig;
|
|
222
|
-
exports.getProductPricing = getProductPricing;
|
|
223
|
-
exports.moneyPriceConfig = moneyPriceConfig;
|