11<script setup lang="ts">
22import type { TreeNodeInput } from ' nanovis'
3- import type { RolldownPluginBuildMetrics , SessionContext } from ' ~~/shared/types'
3+ import type { PluginBuildInfo , RolldownPluginBuildMetrics , SessionContext } from ' ~~/shared/types'
44import { Flamegraph , normalizeTreeNode } from ' nanovis'
55import { computed , onMounted , onUnmounted , ref , shallowRef , useTemplateRef , watch } from ' vue'
66import { parseReadablePath } from ' ~/utils/filepath'
7+ import { normalizeTimestamp } from ' ~/utils/format'
78import { getFileTypeFromModuleId , ModuleTypeRules } from ' ~/utils/icon'
89
910const props = defineProps <{
@@ -24,7 +25,7 @@ const parsedPaths = computed(() => props.session.modulesList.map((mod) => {
2425// filter current module list existed module type
2526const existedModuleTypes = computed (() => ModuleTypeRules .filter (rule => parsedPaths .value .some (mod => rule .match .test (mod .mod .id ))))
2627
27- const n = (node : TreeNodeInput <any >) => normalizeTreeNode (node , undefined , false )
28+ const n = (node : TreeNodeInput <PluginBuildInfo >) => normalizeTreeNode (node , undefined , false )
2829
2930const tree = computed (() => {
3031 // build children: module group by module type
@@ -37,6 +38,7 @@ const tree = computed(() => {
3738 id: ` resolveId-${idx } ` ,
3839 text: id .module ,
3940 size: id .duration ,
41+ meta: id ,
4042 })),
4143 }))
4244
@@ -49,6 +51,7 @@ const tree = computed(() => {
4951 id: ` resolveId-${idx } ` ,
5052 text: id .module ,
5153 size: id .duration ,
54+ meta: id ,
5255 })),
5356 }))
5457
@@ -61,6 +64,7 @@ const tree = computed(() => {
6164 id: ` resolveId-${idx } ` ,
6265 text: id .module ,
6366 size: id .duration ,
67+ meta: id ,
6468 })),
6569 }))
6670
@@ -93,11 +97,12 @@ const tree = computed(() => {
9397const hoverNode = ref <{
9498 plugin_name: string
9599 duration: number
100+ meta: PluginBuildInfo | undefined
96101} | null >(null )
97102const hoverX = ref <number >(0 )
98103const hoverY = ref <number >(0 )
99104const el = useTemplateRef <HTMLDivElement >(' el' )
100- const flamegraph = shallowRef <Flamegraph | null >(null )
105+ const flamegraph = shallowRef <Flamegraph < PluginBuildInfo > | null >(null )
101106
102107function buildFlamegraph() {
103108 flamegraph .value = new Flamegraph (tree .value , {
@@ -124,6 +129,7 @@ function buildFlamegraph() {
124129 hoverNode .value = {
125130 plugin_name: node .text ! ,
126131 duration: node .size ,
132+ meta: node .meta ,
127133 }
128134 },
129135 })
@@ -159,10 +165,24 @@ watch(tree, async () => {
159165 z-panel-content bg-glass pointer-events-none text-sm
160166 :style =" { left: `${hoverX}px`, top: `${hoverY}px` }"
161167 >
162- <div font-bold font-mono >
168+ <div flex =" ~" font-bold font-mono >
169+ <DisplayFileIcon v-if =" hoverNode.meta" :filename =" hoverNode.meta.module" mr1.5 />
163170 {{ hoverNode.plugin_name }}
164171 </div >
165- <DisplayDuration :duration =" hoverNode.duration" />
172+ <div v-if =" hoverNode.meta" >
173+ <div >
174+ <label >Start Time: </label >
175+ <time :datetime =" new Date(hoverNode.meta.timestamp_start).toISOString()" >{{ normalizeTimestamp(hoverNode.meta.timestamp_start) }}</time >
176+ </div >
177+ <div >
178+ <label >End Time: </label >
179+ <time :datetime =" new Date(hoverNode.meta.timestamp_end).toISOString()" >{{ normalizeTimestamp(hoverNode.meta.timestamp_end) }}</time >
180+ </div >
181+ </div >
182+ <div flex =" ~ gap-1" >
183+ <label >Duration: </label >
184+ <DisplayDuration :duration =" hoverNode.duration" />
185+ </div >
166186 </div >
167187 </Teleport >
168188 <div ref =" el" min-h-30 />
0 commit comments