@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.
Files changed (54) hide show
  1. package/dist/_virtual/cytoscape-cose-bilkent.js +1 -1
  2. package/dist/_virtual/cytoscape-cose-bilkent.mjs +1 -1
  3. package/dist/_virtual/cytoscape-fcose.js +1 -1
  4. package/dist/_virtual/cytoscape-fcose.mjs +1 -1
  5. package/dist/lib/clerk-intl.d.ts +3 -4566
  6. package/dist/main/faq.js +0 -1
  7. package/dist/main/faq.mjs +0 -1
  8. package/dist/main/gallery.js +0 -1
  9. package/dist/main/gallery.mjs +0 -1
  10. package/dist/main/money-price/money-price-button.js +36 -15
  11. package/dist/main/money-price/money-price-button.mjs +36 -15
  12. package/dist/main/money-price/money-price-interactive.js +15 -9
  13. package/dist/main/money-price/money-price-interactive.mjs +16 -10
  14. package/dist/main/money-price/money-price.js +1 -14
  15. package/dist/main/money-price/money-price.mjs +1 -14
  16. package/dist/main/price-plan.js +0 -1
  17. package/dist/main/price-plan.mjs +0 -1
  18. package/dist/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  19. package/dist/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  20. package/dist/node_modules/.pnpm/{cytoscape@3.33.0 → cytoscape@3.33.1}/node_modules/cytoscape/dist/cytoscape.esm.js +19 -2
  21. package/dist/node_modules/.pnpm/{cytoscape@3.33.0 → cytoscape@3.33.1}/node_modules/cytoscape/dist/cytoscape.esm.mjs +19 -2
  22. package/dist/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  23. package/dist/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  24. package/dist/node_modules/.pnpm/mermaid@11.9.0/node_modules/mermaid/dist/chunks/mermaid.core/architectureDiagram-SUXI7LT5.js +1 -1
  25. package/dist/node_modules/.pnpm/mermaid@11.9.0/node_modules/mermaid/dist/chunks/mermaid.core/architectureDiagram-SUXI7LT5.mjs +1 -1
  26. package/dist/node_modules/.pnpm/mermaid@11.9.0/node_modules/mermaid/dist/chunks/mermaid.core/mindmap-definition-6CBA2TL7.js +1 -1
  27. package/dist/node_modules/.pnpm/mermaid@11.9.0/node_modules/mermaid/dist/chunks/mermaid.core/mindmap-definition-6CBA2TL7.mjs +1 -1
  28. package/package.json +1 -1
  29. package/src/main/money-price/money-price-button.tsx +48 -24
  30. package/src/main/money-price/money-price-interactive.tsx +38 -21
  31. package/src/main/money-price/money-price.tsx +6 -8
  32. package/dist/clerk/client-page-generator.d.ts +0 -10
  33. package/dist/clerk/client-page-generator.js +0 -28
  34. package/dist/clerk/client-page-generator.mjs +0 -25
  35. package/dist/clerk/context/FingerprintProvider.d.ts +0 -25
  36. package/dist/clerk/context/FingerprintProvider.js +0 -71
  37. package/dist/clerk/context/FingerprintProvider.mjs +0 -65
  38. package/dist/clerk/fingerprint/fingerprint.d.ts +0 -55
  39. package/dist/clerk/fingerprint/fingerprint.js +0 -17
  40. package/dist/clerk/fingerprint/fingerprint.mjs +0 -15
  41. package/dist/clerk/fingerprint.d.ts +0 -55
  42. package/dist/clerk/fingerprint.js +0 -237
  43. package/dist/clerk/fingerprint.mjs +0 -225
  44. package/dist/clerk/hooks/useFingerprint.d.ts +0 -6
  45. package/dist/clerk/hooks/useFingerprint.js +0 -182
  46. package/dist/clerk/hooks/useFingerprint.mjs +0 -180
  47. package/dist/clerk/types.d.ts +0 -42
  48. package/dist/main/money-price/money-price-config.d.ts +0 -8
  49. package/dist/main/money-price/money-price-config.js +0 -223
  50. package/dist/main/money-price/money-price-config.mjs +0 -219
  51. /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
  52. /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
  53. /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
  54. /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,55 +0,0 @@
1
- /**
2
- * Fingerprint Core Utilities
3
- * 基于浏览器特征生成唯一的设备指纹ID,用于匿名用户识别
4
- * Core fingerprint generation logic - completely generic
5
- *
6
- * NOTE: This module should only be used on the client-side
7
- */
8
- /**
9
- * 生成基于真实浏览器特征的fingerprint ID
10
- * 使用FingerprintJS收集浏览器特征并生成唯一标识
11
- */
12
- export declare function generateFingerprintId(): Promise<string>;
13
- /**
14
- * 获取当前的fingerprint ID
15
- */
16
- export declare function getFingerprintId(): string | null;
17
- /**
18
- * 设置fingerprint ID到存储
19
- */
20
- export declare function setFingerprintId(fingerprintId: string): void;
21
- /**
22
- * 清除fingerprint ID
23
- */
24
- export declare function clearFingerprintId(): void;
25
- /**
26
- * 获取或生成fingerprint ID
27
- * 如果不存在则自动生成新的
28
- */
29
- export declare function getOrGenerateFingerprintId(): Promise<string>;
30
- /**
31
- * 验证fingerprint ID格式
32
- */
33
- export declare function isValidFingerprintId(fingerprintId: string): boolean;
34
- /**
35
- * 创建包含fingerprint ID的fetch headers
36
- */
37
- export declare function createFingerprintHeaders(): Promise<Record<string, string>>;
38
- /**
39
- * Hook for generating fingerprint headers
40
- */
41
- export declare function useFingerprintHeaders(): () => Promise<Record<string, string>>;
42
- /**
43
- * Create a fetch wrapper that automatically includes fingerprint headers
44
- */
45
- export declare function createFingerprintFetch(): (url: string | URL | Request, init?: RequestInit) => Promise<Response>;
46
- /**
47
- * 从请求中提取fingerprint ID
48
- * 优先级:header > cookie > query参数
49
- */
50
- export declare function extractFingerprintId(headers: Headers | Record<string, string>, cookies?: Record<string, string>, query?: Record<string, string | undefined>): string | null;
51
- export declare const FINGERPRINT_CONSTANTS: {
52
- readonly STORAGE_KEY: "diaomao_fingerprint_id";
53
- readonly HEADER_NAME: "x-fingerprint-id";
54
- readonly COOKIE_NAME: "fingerprint_id";
55
- };
@@ -1,237 +0,0 @@
1
- 'use strict';
2
-
3
- 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');
4
-
5
- /**
6
- * Fingerprint Core Utilities
7
- * 基于浏览器特征生成唯一的设备指纹ID,用于匿名用户识别
8
- * Core fingerprint generation logic - completely generic
9
- *
10
- * NOTE: This module should only be used on the client-side
11
- */
12
- // Dynamic import to avoid SSR issues
13
- let FingerprintJS = null;
14
- // Only import in browser environment
15
- if (typeof window !== 'undefined') {
16
- Promise.resolve().then(function () { return require('../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.js'); }).then((module) => {
17
- FingerprintJS = module.default;
18
- });
19
- }
20
- // Fingerprint ID的存储键
21
- const FINGERPRINT_STORAGE_KEY = 'diaomao_fingerprint_id';
22
- const FINGERPRINT_HEADER_NAME = 'x-fingerprint-id';
23
- const FINGERPRINT_COOKIE_NAME = 'fingerprint_id';
24
- /**
25
- * 生成基于真实浏览器特征的fingerprint ID
26
- * 使用FingerprintJS收集浏览器特征并生成唯一标识
27
- */
28
- function generateFingerprintId() {
29
- return tslib_es6.__awaiter(this, void 0, void 0, function* () {
30
- // 如果在浏览器环境中,尝试使用现有的fingerprint ID
31
- if (typeof window !== 'undefined') {
32
- // 首先检查localStorage
33
- const existingId = localStorage.getItem(FINGERPRINT_STORAGE_KEY);
34
- if (existingId && isValidFingerprintId(existingId)) {
35
- return existingId;
36
- }
37
- // 检查cookie
38
- const cookieId = getCookieValue(FINGERPRINT_COOKIE_NAME);
39
- if (cookieId && isValidFingerprintId(cookieId)) {
40
- // 同步到localStorage
41
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, cookieId);
42
- return cookieId;
43
- }
44
- try {
45
- // 等待FingerprintJS加载完成
46
- if (!FingerprintJS) {
47
- const module = yield Promise.resolve().then(function () { return require('../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.js'); });
48
- FingerprintJS = module.default;
49
- }
50
- // 使用FingerprintJS生成基于浏览器特征的指纹
51
- const fp = yield FingerprintJS.load();
52
- const result = yield fp.get();
53
- const fingerprintId = `fp_${result.visitorId}`;
54
- // 存储到localStorage和cookie
55
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, fingerprintId);
56
- setCookie(FINGERPRINT_COOKIE_NAME, fingerprintId, 365); // 365天过期
57
- return fingerprintId;
58
- }
59
- catch (error) {
60
- console.warn('Failed to generate fingerprint with FingerprintJS:', error);
61
- // 降级方案:生成时间戳+随机数,但只在没有任何现有ID时使用
62
- const fallbackId = `fp_fallback_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
63
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, fallbackId);
64
- setCookie(FINGERPRINT_COOKIE_NAME, fallbackId, 365);
65
- return fallbackId;
66
- }
67
- }
68
- // 服务端环境降级方案
69
- return `fp_server_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
70
- });
71
- }
72
- /**
73
- * 获取当前的fingerprint ID
74
- */
75
- function getFingerprintId() {
76
- if (typeof window === 'undefined') {
77
- return null;
78
- }
79
- // 首先检查localStorage
80
- const localStorageId = localStorage.getItem(FINGERPRINT_STORAGE_KEY);
81
- if (localStorageId) {
82
- return localStorageId;
83
- }
84
- // 检查cookie
85
- const cookieId = getCookieValue(FINGERPRINT_COOKIE_NAME);
86
- if (cookieId) {
87
- // 同步到localStorage
88
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, cookieId);
89
- return cookieId;
90
- }
91
- return null;
92
- }
93
- /**
94
- * 设置fingerprint ID到存储
95
- */
96
- function setFingerprintId(fingerprintId) {
97
- if (typeof window === 'undefined') {
98
- return;
99
- }
100
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, fingerprintId);
101
- setCookie(FINGERPRINT_COOKIE_NAME, fingerprintId, 365);
102
- }
103
- /**
104
- * 清除fingerprint ID
105
- */
106
- function clearFingerprintId() {
107
- if (typeof window === 'undefined') {
108
- return;
109
- }
110
- localStorage.removeItem(FINGERPRINT_STORAGE_KEY);
111
- deleteCookie(FINGERPRINT_COOKIE_NAME);
112
- }
113
- /**
114
- * 获取或生成fingerprint ID
115
- * 如果不存在则自动生成新的
116
- */
117
- function getOrGenerateFingerprintId() {
118
- return tslib_es6.__awaiter(this, void 0, void 0, function* () {
119
- const existingId = getFingerprintId();
120
- if (existingId) {
121
- return existingId;
122
- }
123
- return yield generateFingerprintId();
124
- });
125
- }
126
- /**
127
- * 验证fingerprint ID格式
128
- */
129
- function isValidFingerprintId(fingerprintId) {
130
- if (!fingerprintId)
131
- return false;
132
- // 支持多种格式:
133
- // - fp_ + FingerprintJS visitorId (变长字符串)
134
- // - fp_fallback_ + 时间戳_随机字符串 (客户端降级方案)
135
- // - fp_server_ + 时间戳_随机字符串 (服务端降级)
136
- return /^fp(_fallback|_server)?_[a-zA-Z0-9_]+$/.test(fingerprintId);
137
- }
138
- /**
139
- * 创建包含fingerprint ID的fetch headers
140
- */
141
- function createFingerprintHeaders() {
142
- return tslib_es6.__awaiter(this, void 0, void 0, function* () {
143
- const fingerprintId = yield getOrGenerateFingerprintId();
144
- return {
145
- [FINGERPRINT_HEADER_NAME]: fingerprintId,
146
- };
147
- });
148
- }
149
- /**
150
- * Hook for generating fingerprint headers
151
- */
152
- function useFingerprintHeaders() {
153
- return createFingerprintHeaders;
154
- }
155
- /**
156
- * Create a fetch wrapper that automatically includes fingerprint headers
157
- */
158
- function createFingerprintFetch() {
159
- return (url, init) => tslib_es6.__awaiter(this, void 0, void 0, function* () {
160
- const fingerprintHeaders = yield createFingerprintHeaders();
161
- const headers = Object.assign(Object.assign({}, fingerprintHeaders), ((init === null || init === void 0 ? void 0 : init.headers) || {}));
162
- return fetch(url, Object.assign(Object.assign({}, init), { headers }));
163
- });
164
- }
165
- /**
166
- * 从请求中提取fingerprint ID
167
- * 优先级:header > cookie > query参数
168
- */
169
- function extractFingerprintId(headers, cookies, query) {
170
- // 1. 从header中获取
171
- const headerValue = headers instanceof Headers
172
- ? headers.get(FINGERPRINT_HEADER_NAME)
173
- : headers[FINGERPRINT_HEADER_NAME];
174
- if (headerValue && isValidFingerprintId(headerValue)) {
175
- return headerValue;
176
- }
177
- // 2. 从cookie中获取
178
- if (cookies) {
179
- const cookieValue = cookies[FINGERPRINT_COOKIE_NAME];
180
- if (cookieValue && isValidFingerprintId(cookieValue)) {
181
- return cookieValue;
182
- }
183
- }
184
- // 3. 从query参数中获取
185
- if (query) {
186
- const queryValue = query.fingerprint_id || query.fp_id;
187
- if (queryValue && isValidFingerprintId(queryValue)) {
188
- return queryValue;
189
- }
190
- }
191
- return null;
192
- }
193
- // Cookie 辅助函数
194
- function getCookieValue(name) {
195
- var _a;
196
- if (typeof document === 'undefined') {
197
- return null;
198
- }
199
- const value = `; ${document.cookie}`;
200
- const parts = value.split(`; ${name}=`);
201
- if (parts.length === 2) {
202
- return ((_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(';').shift()) || null;
203
- }
204
- return null;
205
- }
206
- function setCookie(name, value, days) {
207
- if (typeof document === 'undefined') {
208
- return;
209
- }
210
- const expires = new Date();
211
- expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
212
- document.cookie = `${name}=${value};expires=${expires.toUTCString()};path=/;SameSite=Lax`;
213
- }
214
- function deleteCookie(name) {
215
- if (typeof document === 'undefined') {
216
- return;
217
- }
218
- document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
219
- }
220
- // 常量导出
221
- const FINGERPRINT_CONSTANTS = {
222
- STORAGE_KEY: FINGERPRINT_STORAGE_KEY,
223
- HEADER_NAME: FINGERPRINT_HEADER_NAME,
224
- COOKIE_NAME: FINGERPRINT_COOKIE_NAME,
225
- };
226
-
227
- exports.FINGERPRINT_CONSTANTS = FINGERPRINT_CONSTANTS;
228
- exports.clearFingerprintId = clearFingerprintId;
229
- exports.createFingerprintFetch = createFingerprintFetch;
230
- exports.createFingerprintHeaders = createFingerprintHeaders;
231
- exports.extractFingerprintId = extractFingerprintId;
232
- exports.generateFingerprintId = generateFingerprintId;
233
- exports.getFingerprintId = getFingerprintId;
234
- exports.getOrGenerateFingerprintId = getOrGenerateFingerprintId;
235
- exports.isValidFingerprintId = isValidFingerprintId;
236
- exports.setFingerprintId = setFingerprintId;
237
- exports.useFingerprintHeaders = useFingerprintHeaders;
@@ -1,225 +0,0 @@
1
- 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';
2
-
3
- /**
4
- * Fingerprint Core Utilities
5
- * 基于浏览器特征生成唯一的设备指纹ID,用于匿名用户识别
6
- * Core fingerprint generation logic - completely generic
7
- *
8
- * NOTE: This module should only be used on the client-side
9
- */
10
- // Dynamic import to avoid SSR issues
11
- let FingerprintJS = null;
12
- // Only import in browser environment
13
- if (typeof window !== 'undefined') {
14
- import('../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.mjs').then((module) => {
15
- FingerprintJS = module.default;
16
- });
17
- }
18
- // Fingerprint ID的存储键
19
- const FINGERPRINT_STORAGE_KEY = 'diaomao_fingerprint_id';
20
- const FINGERPRINT_HEADER_NAME = 'x-fingerprint-id';
21
- const FINGERPRINT_COOKIE_NAME = 'fingerprint_id';
22
- /**
23
- * 生成基于真实浏览器特征的fingerprint ID
24
- * 使用FingerprintJS收集浏览器特征并生成唯一标识
25
- */
26
- function generateFingerprintId() {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- // 如果在浏览器环境中,尝试使用现有的fingerprint ID
29
- if (typeof window !== 'undefined') {
30
- // 首先检查localStorage
31
- const existingId = localStorage.getItem(FINGERPRINT_STORAGE_KEY);
32
- if (existingId && isValidFingerprintId(existingId)) {
33
- return existingId;
34
- }
35
- // 检查cookie
36
- const cookieId = getCookieValue(FINGERPRINT_COOKIE_NAME);
37
- if (cookieId && isValidFingerprintId(cookieId)) {
38
- // 同步到localStorage
39
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, cookieId);
40
- return cookieId;
41
- }
42
- try {
43
- // 等待FingerprintJS加载完成
44
- if (!FingerprintJS) {
45
- const module = yield import('../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.mjs');
46
- FingerprintJS = module.default;
47
- }
48
- // 使用FingerprintJS生成基于浏览器特征的指纹
49
- const fp = yield FingerprintJS.load();
50
- const result = yield fp.get();
51
- const fingerprintId = `fp_${result.visitorId}`;
52
- // 存储到localStorage和cookie
53
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, fingerprintId);
54
- setCookie(FINGERPRINT_COOKIE_NAME, fingerprintId, 365); // 365天过期
55
- return fingerprintId;
56
- }
57
- catch (error) {
58
- console.warn('Failed to generate fingerprint with FingerprintJS:', error);
59
- // 降级方案:生成时间戳+随机数,但只在没有任何现有ID时使用
60
- const fallbackId = `fp_fallback_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
61
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, fallbackId);
62
- setCookie(FINGERPRINT_COOKIE_NAME, fallbackId, 365);
63
- return fallbackId;
64
- }
65
- }
66
- // 服务端环境降级方案
67
- return `fp_server_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;
68
- });
69
- }
70
- /**
71
- * 获取当前的fingerprint ID
72
- */
73
- function getFingerprintId() {
74
- if (typeof window === 'undefined') {
75
- return null;
76
- }
77
- // 首先检查localStorage
78
- const localStorageId = localStorage.getItem(FINGERPRINT_STORAGE_KEY);
79
- if (localStorageId) {
80
- return localStorageId;
81
- }
82
- // 检查cookie
83
- const cookieId = getCookieValue(FINGERPRINT_COOKIE_NAME);
84
- if (cookieId) {
85
- // 同步到localStorage
86
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, cookieId);
87
- return cookieId;
88
- }
89
- return null;
90
- }
91
- /**
92
- * 设置fingerprint ID到存储
93
- */
94
- function setFingerprintId(fingerprintId) {
95
- if (typeof window === 'undefined') {
96
- return;
97
- }
98
- localStorage.setItem(FINGERPRINT_STORAGE_KEY, fingerprintId);
99
- setCookie(FINGERPRINT_COOKIE_NAME, fingerprintId, 365);
100
- }
101
- /**
102
- * 清除fingerprint ID
103
- */
104
- function clearFingerprintId() {
105
- if (typeof window === 'undefined') {
106
- return;
107
- }
108
- localStorage.removeItem(FINGERPRINT_STORAGE_KEY);
109
- deleteCookie(FINGERPRINT_COOKIE_NAME);
110
- }
111
- /**
112
- * 获取或生成fingerprint ID
113
- * 如果不存在则自动生成新的
114
- */
115
- function getOrGenerateFingerprintId() {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- const existingId = getFingerprintId();
118
- if (existingId) {
119
- return existingId;
120
- }
121
- return yield generateFingerprintId();
122
- });
123
- }
124
- /**
125
- * 验证fingerprint ID格式
126
- */
127
- function isValidFingerprintId(fingerprintId) {
128
- if (!fingerprintId)
129
- return false;
130
- // 支持多种格式:
131
- // - fp_ + FingerprintJS visitorId (变长字符串)
132
- // - fp_fallback_ + 时间戳_随机字符串 (客户端降级方案)
133
- // - fp_server_ + 时间戳_随机字符串 (服务端降级)
134
- return /^fp(_fallback|_server)?_[a-zA-Z0-9_]+$/.test(fingerprintId);
135
- }
136
- /**
137
- * 创建包含fingerprint ID的fetch headers
138
- */
139
- function createFingerprintHeaders() {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- const fingerprintId = yield getOrGenerateFingerprintId();
142
- return {
143
- [FINGERPRINT_HEADER_NAME]: fingerprintId,
144
- };
145
- });
146
- }
147
- /**
148
- * Hook for generating fingerprint headers
149
- */
150
- function useFingerprintHeaders() {
151
- return createFingerprintHeaders;
152
- }
153
- /**
154
- * Create a fetch wrapper that automatically includes fingerprint headers
155
- */
156
- function createFingerprintFetch() {
157
- return (url, init) => __awaiter(this, void 0, void 0, function* () {
158
- const fingerprintHeaders = yield createFingerprintHeaders();
159
- const headers = Object.assign(Object.assign({}, fingerprintHeaders), ((init === null || init === void 0 ? void 0 : init.headers) || {}));
160
- return fetch(url, Object.assign(Object.assign({}, init), { headers }));
161
- });
162
- }
163
- /**
164
- * 从请求中提取fingerprint ID
165
- * 优先级:header > cookie > query参数
166
- */
167
- function extractFingerprintId(headers, cookies, query) {
168
- // 1. 从header中获取
169
- const headerValue = headers instanceof Headers
170
- ? headers.get(FINGERPRINT_HEADER_NAME)
171
- : headers[FINGERPRINT_HEADER_NAME];
172
- if (headerValue && isValidFingerprintId(headerValue)) {
173
- return headerValue;
174
- }
175
- // 2. 从cookie中获取
176
- if (cookies) {
177
- const cookieValue = cookies[FINGERPRINT_COOKIE_NAME];
178
- if (cookieValue && isValidFingerprintId(cookieValue)) {
179
- return cookieValue;
180
- }
181
- }
182
- // 3. 从query参数中获取
183
- if (query) {
184
- const queryValue = query.fingerprint_id || query.fp_id;
185
- if (queryValue && isValidFingerprintId(queryValue)) {
186
- return queryValue;
187
- }
188
- }
189
- return null;
190
- }
191
- // Cookie 辅助函数
192
- function getCookieValue(name) {
193
- var _a;
194
- if (typeof document === 'undefined') {
195
- return null;
196
- }
197
- const value = `; ${document.cookie}`;
198
- const parts = value.split(`; ${name}=`);
199
- if (parts.length === 2) {
200
- return ((_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.split(';').shift()) || null;
201
- }
202
- return null;
203
- }
204
- function setCookie(name, value, days) {
205
- if (typeof document === 'undefined') {
206
- return;
207
- }
208
- const expires = new Date();
209
- expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
210
- document.cookie = `${name}=${value};expires=${expires.toUTCString()};path=/;SameSite=Lax`;
211
- }
212
- function deleteCookie(name) {
213
- if (typeof document === 'undefined') {
214
- return;
215
- }
216
- document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
217
- }
218
- // 常量导出
219
- const FINGERPRINT_CONSTANTS = {
220
- STORAGE_KEY: FINGERPRINT_STORAGE_KEY,
221
- HEADER_NAME: FINGERPRINT_HEADER_NAME,
222
- COOKIE_NAME: FINGERPRINT_COOKIE_NAME,
223
- };
224
-
225
- export { FINGERPRINT_CONSTANTS, clearFingerprintId, createFingerprintFetch, createFingerprintHeaders, extractFingerprintId, generateFingerprintId, getFingerprintId, getOrGenerateFingerprintId, isValidFingerprintId, setFingerprintId, useFingerprintHeaders };
@@ -1,6 +0,0 @@
1
- import type { UseFingerprintResult, FingerprintConfig } from '../types';
2
- /**
3
- * Hook for managing fingerprint ID and anonymous user data
4
- * Accepts configuration to customize API endpoint and behavior
5
- */
6
- export declare function useFingerprint(config: FingerprintConfig): UseFingerprintResult;