@basic-genomics/hivtrace-viz 1.1.3 → 1.1.5
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/README.md +52 -13
- package/dist/embed/hivtrace.js +1 -1
- package/dist/embed/hivtrace.js.map +1 -1
- package/dist/embed/index.html +64 -65
- package/dist/hivtrace.js +1 -1
- package/dist/hivtrace.js.map +1 -1
- package/dist/react/HivtraceViz.d.ts +1 -1
- package/dist/react/HivtraceViz.d.ts.map +1 -1
- package/dist/react/HivtraceViz.js +16 -9
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/types.d.ts +52 -2
- package/dist/react/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,19 +24,33 @@ yarn add @basic-genomics/hivtrace-viz
|
|
|
24
24
|
|
|
25
25
|
```tsx
|
|
26
26
|
import { HivtraceViz } from '@basic-genomics/hivtrace-viz/react';
|
|
27
|
+
import type { CustomContextMenuItem, ClusterInfo } from '@basic-genomics/hivtrace-viz/react';
|
|
27
28
|
|
|
28
29
|
function App() {
|
|
30
|
+
// 自定义上下文菜单项
|
|
31
|
+
const customMenuItems: CustomContextMenuItem[] = [
|
|
32
|
+
{
|
|
33
|
+
id: 'track-cluster',
|
|
34
|
+
label: '追踪此簇',
|
|
35
|
+
icon: 'fa-crosshairs',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const handleMenuClick = (itemId: string, clusterInfo: ClusterInfo) => {
|
|
40
|
+
if (itemId === 'track-cluster') {
|
|
41
|
+
console.log('追踪簇:', clusterInfo);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
29
45
|
return (
|
|
30
46
|
<HivtraceViz
|
|
31
47
|
data={analysisData}
|
|
32
48
|
options={{
|
|
33
|
-
enableClusterTracking: true,
|
|
34
49
|
threshold: 0.015,
|
|
35
50
|
expand: ['cluster_1']
|
|
36
51
|
}}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}}
|
|
52
|
+
customContextMenuItems={customMenuItems}
|
|
53
|
+
onCustomMenuItemClick={handleMenuClick}
|
|
40
54
|
onReady={() => console.log('可视化已就绪')}
|
|
41
55
|
error={fetchError?.message}
|
|
42
56
|
/>
|
|
@@ -103,19 +117,42 @@ yarn build:vite # Vite 插件
|
|
|
103
117
|
yarn build:embed # 嵌入资源
|
|
104
118
|
```
|
|
105
119
|
|
|
106
|
-
###
|
|
120
|
+
### 本地调试(与宿主应用联调)
|
|
107
121
|
|
|
108
|
-
|
|
122
|
+
使用 `npm link` 进行本地开发调试:
|
|
109
123
|
|
|
110
124
|
```bash
|
|
111
|
-
# 1. 在 hivtrace-viz
|
|
112
|
-
|
|
125
|
+
# 1. 在 hivtrace-viz 目录执行
|
|
126
|
+
npm link
|
|
113
127
|
|
|
114
|
-
# 2.
|
|
115
|
-
|
|
128
|
+
# 2. 在宿主应用目录执行
|
|
129
|
+
npm link @basic-genomics/hivtrace-viz
|
|
130
|
+
```
|
|
116
131
|
|
|
117
|
-
|
|
118
|
-
|
|
132
|
+
**开发流程:**
|
|
133
|
+
|
|
134
|
+
1. 修改 hivtrace-viz 代码后,运行相应的构建命令:
|
|
135
|
+
- 修改 `src/react/*.tsx` → `npm run build:react`
|
|
136
|
+
- 修改 `template/embed.html` → `npm run build:embed`
|
|
137
|
+
- 修改 `src/*.js` → `npm run build:core`
|
|
138
|
+
|
|
139
|
+
2. 清除宿主应用的 Vite 缓存并重启:
|
|
140
|
+
```bash
|
|
141
|
+
rm -rf node_modules/.vite
|
|
142
|
+
yarn dev
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
3. 刷新浏览器
|
|
146
|
+
|
|
147
|
+
**重要提示:**
|
|
148
|
+
- npm link 创建的是 symlink,但 Vite 会缓存模块
|
|
149
|
+
- 每次修改 hivtrace-viz 代码后需要**重新构建**对应部分
|
|
150
|
+
- 需要**删除 Vite 缓存**或**重启 dev server**才能看到更新
|
|
151
|
+
|
|
152
|
+
**验证 npm link 状态:**
|
|
153
|
+
```bash
|
|
154
|
+
ls -la node_modules/@basic-genomics/hivtrace-viz
|
|
155
|
+
# 应显示:xxx -> ../../../hivtrace-viz
|
|
119
156
|
```
|
|
120
157
|
|
|
121
158
|
## 项目结构
|
|
@@ -146,8 +183,10 @@ hivtrace-viz/
|
|
|
146
183
|
| `options` | `HivtraceVizOptions` | 配置选项 |
|
|
147
184
|
| `error` | `string` | 错误信息(API 错误时传入) |
|
|
148
185
|
| `loadingState` | `ReactNode \| null` | 自定义加载态,`null` 禁用 |
|
|
149
|
-
| `
|
|
186
|
+
| `customContextMenuItems` | `CustomContextMenuItem[]` | 自定义上下文菜单项 |
|
|
187
|
+
| `onCustomMenuItemClick` | `(itemId, clusterInfo) => void` | 自定义菜单项点击回调 |
|
|
150
188
|
| `onReady` | `() => void` | 渲染完成回调 |
|
|
189
|
+
| `onRetry` | `() => void` | 重试回调 |
|
|
151
190
|
|
|
152
191
|
## 国际化
|
|
153
192
|
|