@windrun-huaiin/third-ui 7.2.0 → 7.2.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.
@@ -2,14 +2,13 @@
2
2
 
3
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
4
  var fingerprintShared = require('./fingerprint-shared.js');
5
+ var fp_esm = require('../../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.js');
5
6
 
6
7
  /**
7
8
  * Fingerprint Client Utilities
8
9
  * 客户端专用的指纹生成和管理逻辑
9
10
  * 只能在浏览器环境中使用
10
11
  */
11
- // Dynamic import to avoid SSR issues
12
- let FingerprintJS = null;
13
12
  /**
14
13
  * 生成基于真实浏览器特征的fingerprint ID
15
14
  * 使用FingerprintJS收集浏览器特征并生成唯一标识
@@ -33,13 +32,8 @@ function generateFingerprintId() {
33
32
  return cookieId;
34
33
  }
35
34
  try {
36
- // 等待FingerprintJS加载完成
37
- if (!FingerprintJS) {
38
- 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'); });
39
- FingerprintJS = module.default;
40
- }
41
35
  // 使用FingerprintJS生成基于浏览器特征的指纹
42
- const fp = yield FingerprintJS.load();
36
+ const fp = yield fp_esm.default.load();
43
37
  const result = yield fp.get();
44
38
  const fingerprintId = `fp_${result.visitorId}`;
45
39
  // 存储到localStorage和cookie
@@ -123,7 +117,7 @@ function createFingerprintHeaders() {
123
117
  return tslib_es6.__awaiter(this, void 0, void 0, function* () {
124
118
  const fingerprintId = yield getOrGenerateFingerprintId();
125
119
  return {
126
- 'x-fingerprint-id': fingerprintId,
120
+ FINGERPRINT_HEADER_NAME: fingerprintId,
127
121
  };
128
122
  });
129
123
  }
@@ -1,13 +1,12 @@
1
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
2
  import { FINGERPRINT_STORAGE_KEY, isValidFingerprintId, FINGERPRINT_COOKIE_NAME } from './fingerprint-shared.mjs';
3
+ import index from '../../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.mjs';
3
4
 
4
5
  /**
5
6
  * Fingerprint Client Utilities
6
7
  * 客户端专用的指纹生成和管理逻辑
7
8
  * 只能在浏览器环境中使用
8
9
  */
9
- // Dynamic import to avoid SSR issues
10
- let FingerprintJS = null;
11
10
  /**
12
11
  * 生成基于真实浏览器特征的fingerprint ID
13
12
  * 使用FingerprintJS收集浏览器特征并生成唯一标识
@@ -31,13 +30,8 @@ function generateFingerprintId() {
31
30
  return cookieId;
32
31
  }
33
32
  try {
34
- // 等待FingerprintJS加载完成
35
- if (!FingerprintJS) {
36
- const module = yield import('../../node_modules/.pnpm/@fingerprintjs_fingerprintjs@4.6.2/node_modules/@fingerprintjs/fingerprintjs/dist/fp.esm.mjs');
37
- FingerprintJS = module.default;
38
- }
39
33
  // 使用FingerprintJS生成基于浏览器特征的指纹
40
- const fp = yield FingerprintJS.load();
34
+ const fp = yield index.load();
41
35
  const result = yield fp.get();
42
36
  const fingerprintId = `fp_${result.visitorId}`;
43
37
  // 存储到localStorage和cookie
@@ -121,7 +115,7 @@ function createFingerprintHeaders() {
121
115
  return __awaiter(this, void 0, void 0, function* () {
122
116
  const fingerprintId = yield getOrGenerateFingerprintId();
123
117
  return {
124
- 'x-fingerprint-id': fingerprintId,
118
+ FINGERPRINT_HEADER_NAME: fingerprintId,
125
119
  };
126
120
  });
127
121
  }
@@ -2,7 +2,7 @@
2
2
  * Fingerprint Shared Utilities
3
3
  * 客户端和服务端共享的常量、类型和验证逻辑
4
4
  */
5
- export declare const FINGERPRINT_STORAGE_KEY = "diaomao_fingerprint_id";
5
+ export declare const FINGERPRINT_STORAGE_KEY = "x_fingerprint_id";
6
6
  export declare const FINGERPRINT_HEADER_NAME = "x-fingerprint-id";
7
7
  export declare const FINGERPRINT_COOKIE_NAME = "fingerprint_id";
8
8
  /**
@@ -11,7 +11,7 @@ export declare const FINGERPRINT_COOKIE_NAME = "fingerprint_id";
11
11
  */
12
12
  export declare function isValidFingerprintId(fingerprintId: string): boolean;
13
13
  export declare const FINGERPRINT_CONSTANTS: {
14
- readonly STORAGE_KEY: "diaomao_fingerprint_id";
14
+ readonly STORAGE_KEY: "x_fingerprint_id";
15
15
  readonly HEADER_NAME: "x-fingerprint-id";
16
16
  readonly COOKIE_NAME: "fingerprint_id";
17
17
  };
@@ -5,7 +5,7 @@
5
5
  * 客户端和服务端共享的常量、类型和验证逻辑
6
6
  */
7
7
  // Fingerprint ID的存储键和header名
8
- const FINGERPRINT_STORAGE_KEY = 'diaomao_fingerprint_id';
8
+ const FINGERPRINT_STORAGE_KEY = 'x_fingerprint_id';
9
9
  const FINGERPRINT_HEADER_NAME = 'x-fingerprint-id';
10
10
  const FINGERPRINT_COOKIE_NAME = 'fingerprint_id';
11
11
  /**
@@ -3,7 +3,7 @@
3
3
  * 客户端和服务端共享的常量、类型和验证逻辑
4
4
  */
5
5
  // Fingerprint ID的存储键和header名
6
- const FINGERPRINT_STORAGE_KEY = 'diaomao_fingerprint_id';
6
+ const FINGERPRINT_STORAGE_KEY = 'x_fingerprint_id';
7
7
  const FINGERPRINT_HEADER_NAME = 'x-fingerprint-id';
8
8
  const FINGERPRINT_COOKIE_NAME = 'fingerprint_id';
9
9
  /**
@@ -5,6 +5,8 @@
5
5
  export interface AnonymousUser {
6
6
  userId: string;
7
7
  fingerprintId: string;
8
+ clerkUserId: string;
9
+ email: string;
8
10
  status: string;
9
11
  createdAt: string;
10
12
  }
@@ -23,13 +23,7 @@ function useFingerprint(config) {
23
23
  if (typeof window === 'undefined')
24
24
  return null;
25
25
  try {
26
- // 优先检查现有ID
27
- const existingId = fingerprintClient.getFingerprintId();
28
- if (existingId) {
29
- setFingerprintIdState(existingId);
30
- return existingId;
31
- }
32
- // 生成新的fingerprint ID
26
+ // 优先检查现有ID, 没有就生成新的fingerprint ID
33
27
  const currentFingerprintId = yield fingerprintClient.getOrGenerateFingerprintId();
34
28
  setFingerprintIdState(currentFingerprintId);
35
29
  return currentFingerprintId;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
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
3
  import { useState, useCallback, useEffect } from 'react';
4
- import { createFingerprintHeaders, setFingerprintId, getFingerprintId, getOrGenerateFingerprintId } from './fingerprint-client.mjs';
4
+ import { createFingerprintHeaders, setFingerprintId, getOrGenerateFingerprintId } from './fingerprint-client.mjs';
5
5
 
6
6
  /**
7
7
  * Hook for managing fingerprint ID and anonymous user data
@@ -21,13 +21,7 @@ function useFingerprint(config) {
21
21
  if (typeof window === 'undefined')
22
22
  return null;
23
23
  try {
24
- // 优先检查现有ID
25
- const existingId = getFingerprintId();
26
- if (existingId) {
27
- setFingerprintIdState(existingId);
28
- return existingId;
29
- }
30
- // 生成新的fingerprint ID
24
+ // 优先检查现有ID, 没有就生成新的fingerprint ID
31
25
  const currentFingerprintId = yield getOrGenerateFingerprintId();
32
26
  setFingerprintIdState(currentFingerprintId);
33
27
  return currentFingerprintId;
@@ -613,34 +613,6 @@ function loadSources(sources, sourceOptions, excludeSources, loopReleaseInterval
613
613
  });
614
614
  };
615
615
  }
616
- /**
617
- * Modifies an entropy source by transforming its returned value with the given function.
618
- * Keeps the source properties: sync/async, 1/2 stages.
619
- *
620
- * Warning for package users:
621
- * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
622
- */
623
- function transformSource(source, transformValue) {
624
- var transformLoadResult = function (loadResult) {
625
- if (isFinalResultLoaded(loadResult)) {
626
- return transformValue(loadResult);
627
- }
628
- return function () {
629
- var getResult = loadResult();
630
- if (isPromise(getResult)) {
631
- return getResult.then(transformValue);
632
- }
633
- return transformValue(getResult);
634
- };
635
- };
636
- return function (options) {
637
- var loadResult = source(options);
638
- if (isPromise(loadResult)) {
639
- return loadResult.then(transformLoadResult);
640
- }
641
- return transformLoadResult(loadResult);
642
- };
643
- }
644
616
 
645
617
  /*
646
618
  * Functions to help with features that vary through browsers
@@ -3215,9 +3187,6 @@ function load(options) {
3215
3187
  // The default export is a syntax sugar (`import * as FP from '...' → import FP from '...'`).
3216
3188
  // It should contain all the public exported values.
3217
3189
  var index = { load: load, hashComponents: hashComponents, componentsToDebugString: componentsToDebugString };
3218
- // The exports below are for private usage. They may change unexpectedly. Use them at your own risk.
3219
- /** Not documented, out of Semantic Versioning, usage is at your own risk */
3220
- var murmurX64Hash128 = x64hash128;
3221
3190
 
3222
3191
  exports.componentsToDebugString = componentsToDebugString;
3223
3192
  exports.default = index;
@@ -3238,8 +3207,6 @@ exports.isTrident = isTrident;
3238
3207
  exports.isWebKit = isWebKit;
3239
3208
  exports.load = load;
3240
3209
  exports.loadSources = loadSources;
3241
- exports.murmurX64Hash128 = murmurX64Hash128;
3242
3210
  exports.prepareForSources = prepareForSources;
3243
3211
  exports.sources = sources;
3244
- exports.transformSource = transformSource;
3245
3212
  exports.withIframe = withIframe;
@@ -609,34 +609,6 @@ function loadSources(sources, sourceOptions, excludeSources, loopReleaseInterval
609
609
  });
610
610
  };
611
611
  }
612
- /**
613
- * Modifies an entropy source by transforming its returned value with the given function.
614
- * Keeps the source properties: sync/async, 1/2 stages.
615
- *
616
- * Warning for package users:
617
- * This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
618
- */
619
- function transformSource(source, transformValue) {
620
- var transformLoadResult = function (loadResult) {
621
- if (isFinalResultLoaded(loadResult)) {
622
- return transformValue(loadResult);
623
- }
624
- return function () {
625
- var getResult = loadResult();
626
- if (isPromise(getResult)) {
627
- return getResult.then(transformValue);
628
- }
629
- return transformValue(getResult);
630
- };
631
- };
632
- return function (options) {
633
- var loadResult = source(options);
634
- if (isPromise(loadResult)) {
635
- return loadResult.then(transformLoadResult);
636
- }
637
- return transformLoadResult(loadResult);
638
- };
639
- }
640
612
 
641
613
  /*
642
614
  * Functions to help with features that vary through browsers
@@ -3211,8 +3183,5 @@ function load(options) {
3211
3183
  // The default export is a syntax sugar (`import * as FP from '...' → import FP from '...'`).
3212
3184
  // It should contain all the public exported values.
3213
3185
  var index = { load: load, hashComponents: hashComponents, componentsToDebugString: componentsToDebugString };
3214
- // The exports below are for private usage. They may change unexpectedly. Use them at your own risk.
3215
- /** Not documented, out of Semantic Versioning, usage is at your own risk */
3216
- var murmurX64Hash128 = x64hash128;
3217
3186
 
3218
- export { componentsToDebugString, index as default, getFullscreenElement, getUnstableAudioFingerprint, getUnstableCanvasFingerprint, getUnstableScreenFrame, getUnstableScreenResolution, getWebGLContext, hashComponents, isAndroid, isChromium, isDesktopWebKit, isEdgeHTML, isGecko, isSamsungInternet, isTrident, isWebKit, load, loadSources, murmurX64Hash128, prepareForSources, sources, transformSource, withIframe };
3187
+ export { componentsToDebugString, index as default, getFullscreenElement, getUnstableAudioFingerprint, getUnstableCanvasFingerprint, getUnstableScreenFrame, getUnstableScreenResolution, getWebGLContext, hashComponents, isAndroid, isChromium, isDesktopWebKit, isEdgeHTML, isGecko, isSamsungInternet, isTrident, isWebKit, load, loadSources, prepareForSources, sources, withIframe };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "7.2.0",
3
+ "version": "7.2.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",
@@ -75,8 +75,8 @@
75
75
  "mermaid": "^11.6.0",
76
76
  "react-medium-image-zoom": "^5.2.14",
77
77
  "zod": "^3.22.4",
78
- "@windrun-huaiin/base-ui": "^8.1.1",
79
- "@windrun-huaiin/lib": "^7.1.1"
78
+ "@windrun-huaiin/lib": "^7.1.1",
79
+ "@windrun-huaiin/base-ui": "^8.1.1"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "react": "19.1.0",
@@ -9,9 +9,7 @@ import {
9
9
  FINGERPRINT_COOKIE_NAME,
10
10
  isValidFingerprintId
11
11
  } from './fingerprint-shared';
12
-
13
- // Dynamic import to avoid SSR issues
14
- let FingerprintJS: any = null;
12
+ import FingerprintJS from '@fingerprintjs/fingerprintjs';
15
13
 
16
14
  /**
17
15
  * 生成基于真实浏览器特征的fingerprint ID
@@ -38,12 +36,6 @@ export async function generateFingerprintId(): Promise<string> {
38
36
  }
39
37
 
40
38
  try {
41
- // 等待FingerprintJS加载完成
42
- if (!FingerprintJS) {
43
- const module = await import('@fingerprintjs/fingerprintjs');
44
- FingerprintJS = module.default;
45
- }
46
-
47
39
  // 使用FingerprintJS生成基于浏览器特征的指纹
48
40
  const fp = await FingerprintJS.load();
49
41
  const result = await fp.get();
@@ -138,7 +130,7 @@ export async function getOrGenerateFingerprintId(): Promise<string> {
138
130
  export async function createFingerprintHeaders(): Promise<Record<string, string>> {
139
131
  const fingerprintId = await getOrGenerateFingerprintId();
140
132
  return {
141
- 'x-fingerprint-id': fingerprintId,
133
+ FINGERPRINT_HEADER_NAME : fingerprintId,
142
134
  };
143
135
  }
144
136
 
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import React, { createContext, useContext } from 'react';
3
+ import React, { createContext, useContext, useState } from 'react';
4
4
  import { useFingerprint } from './use-fingerprint';
5
5
  import type {
6
6
  FingerprintContextType,
@@ -66,7 +66,7 @@ export function withFingerprint<P extends object>(
66
66
  /**
67
67
  * 组件:显示用户状态和积分信息(用于调试)
68
68
  */
69
- export function FingerprintDebugInfo() {
69
+ export function FingerprintStatus() {
70
70
  const {
71
71
  fingerprintId,
72
72
  anonymousUser,
@@ -76,39 +76,90 @@ export function FingerprintDebugInfo() {
76
76
  error
77
77
  } = useFingerprintContext();
78
78
 
79
- if (!process.env.NODE_ENV || process.env.NODE_ENV === 'production') {
80
- return null;
81
- }
79
+ const [isOpen, setIsOpen] = useState(false);
80
+
81
+ const handleToggle = () => {
82
+ setIsOpen(!isOpen);
83
+ };
82
84
 
83
85
  return (
84
- <div style={{
85
- position: 'fixed',
86
- bottom: '10px',
87
- right: '10px',
88
- background: '#f0f0f0',
89
- padding: '10px',
90
- borderRadius: '5px',
91
- fontSize: '12px',
92
- fontFamily: 'monospace',
93
- maxWidth: '300px',
94
- zIndex: 9999,
95
- border: '1px solid #ccc'
96
- }}>
97
- <h4 style={{ margin: '0 0 5px 0' }}>Fingerprint Debug</h4>
98
- <div><strong>FP ID:</strong> {fingerprintId || 'None'}</div>
99
- <div><strong>Loading:</strong> {isLoading ? 'Yes' : 'No'}</div>
100
- <div><strong>Initialized:</strong> {isInitialized ? 'Yes' : 'No'}</div>
101
- {error && <div style={{ color: 'red' }}><strong>Error:</strong> {error}</div>}
102
- {anonymousUser && (
103
- <div>
104
- <strong>User ID:</strong> {anonymousUser.userId.slice(0, 8)}...
105
- </div>
106
- )}
107
- {credits && (
108
- <div>
109
- <strong>Credits:</strong> {credits.balanceFree}F + {credits.balancePaid}P = {credits.totalBalance}
110
- </div>
86
+ <>
87
+ <button
88
+ onClick={handleToggle}
89
+ style={{
90
+ position: 'fixed',
91
+ top: '10px',
92
+ left: '10px',
93
+ width: '50px',
94
+ height: '50px',
95
+ background: 'linear-gradient(135deg, #9b59b6, #e74c3c)',
96
+ borderRadius: '50%',
97
+ border: 'none',
98
+ cursor: 'pointer',
99
+ zIndex: 10000,
100
+ display: 'flex',
101
+ alignItems: 'center',
102
+ justifyContent: 'center',
103
+ boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)',
104
+ }}
105
+ >
106
+ <span style={{
107
+ fontSize: '24px',
108
+ color: 'white',
109
+ transform: isOpen ? 'rotate(180deg)' : 'rotate(0deg)',
110
+ transition: 'transform 0.3s ease',
111
+ }}>▼</span>
112
+ </button>
113
+
114
+ {isOpen && (
115
+ <>
116
+ <div
117
+ style={{
118
+ position: 'fixed',
119
+ top: 0,
120
+ left: 0,
121
+ width: '100%',
122
+ height: '100%',
123
+ background: 'rgba(0, 0, 0, 0.5)',
124
+ zIndex: 9998,
125
+ }}
126
+ />
127
+ <div
128
+ style={{
129
+ position: 'fixed',
130
+ top: '70px',
131
+ left: '10px',
132
+ background: '#f0f0f0',
133
+ padding: '15px',
134
+ borderRadius: '5px',
135
+ fontSize: '12px',
136
+ fontFamily: 'monospace',
137
+ maxWidth: '300px',
138
+ zIndex: 9999,
139
+ border: '1px solid #ccc',
140
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.2)',
141
+ }}
142
+ >
143
+ <h4 style={{ margin: '0 0 5px 0' }}>Fingerprint Debug</h4>
144
+ <div><strong>FP_ID:</strong> {fingerprintId || 'None'}</div>
145
+ <div><strong>Loading:</strong> {isLoading ? 'Yes' : 'No'}</div>
146
+ <div><strong>Initialized:</strong> {isInitialized ? 'Yes' : 'No'}</div>
147
+ {error && <div style={{ color: 'red' }}><strong>Error:</strong> {error}</div>}
148
+ {anonymousUser && (
149
+ <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 */}
153
+ </div>
154
+ )}
155
+ {credits && (
156
+ <div>
157
+ <strong>Credits:</strong> {credits.balanceFree} Free + {credits.balancePaid} Paid = {credits.totalBalance} Total
158
+ </div>
159
+ )}
160
+ </div>
161
+ </>
111
162
  )}
112
- </div>
163
+ </>
113
164
  );
114
165
  }
@@ -4,9 +4,9 @@
4
4
  */
5
5
 
6
6
  // Fingerprint ID的存储键和header名
7
- export const FINGERPRINT_STORAGE_KEY = 'diaomao_fingerprint_id';
8
- export const FINGERPRINT_HEADER_NAME = 'x-fingerprint-id';
9
- export const FINGERPRINT_COOKIE_NAME = 'fingerprint_id';
7
+ export const FINGERPRINT_STORAGE_KEY = '__x_fingerprint_id';
8
+ export const FINGERPRINT_HEADER_NAME = 'x-fingerprint-id-v8';
9
+ export const FINGERPRINT_COOKIE_NAME = '__x_fingerprint_id';
10
10
 
11
11
  /**
12
12
  * 验证fingerprint ID格式
@@ -6,6 +6,8 @@
6
6
  export interface AnonymousUser {
7
7
  userId: string;
8
8
  fingerprintId: string;
9
+ clerkUserId: string,
10
+ email: string,
9
11
  status: string;
10
12
  createdAt: string;
11
13
  }
@@ -3,7 +3,6 @@
3
3
  import { useState, useEffect, useCallback } from 'react';
4
4
  import {
5
5
  getOrGenerateFingerprintId,
6
- getFingerprintId,
7
6
  setFingerprintId,
8
7
  createFingerprintHeaders
9
8
  } from './fingerprint-client';
@@ -33,14 +32,7 @@ export function useFingerprint(config: FingerprintConfig): UseFingerprintResult
33
32
  if (typeof window === 'undefined') return null;
34
33
 
35
34
  try {
36
- // 优先检查现有ID
37
- const existingId = getFingerprintId();
38
- if (existingId) {
39
- setFingerprintIdState(existingId);
40
- return existingId;
41
- }
42
-
43
- // 生成新的fingerprint ID
35
+ // 优先检查现有ID, 没有就生成新的fingerprint ID
44
36
  const currentFingerprintId = await getOrGenerateFingerprintId();
45
37
  setFingerprintIdState(currentFingerprintId);
46
38
  return currentFingerprintId;