Skip to content

Commit 5b4c3d0

Browse files
committed
feat: adjust ui
1 parent 0acd58b commit 5b4c3d0

File tree

5 files changed

+142
-70
lines changed

5 files changed

+142
-70
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<script setup lang="ts">
2+
import type { ModuleInfo, RolldownModuleTransformInfo, SessionContext } from '~~/shared/types'
3+
import { useRpc } from '#imports'
4+
import { computedAsync } from '@vueuse/core'
5+
import { nextTick, ref, watchEffect } from 'vue'
6+
7+
const props = defineProps<{
8+
session: SessionContext
9+
module: string
10+
}>()
11+
12+
const emit = defineEmits<{
13+
(e: 'close'): void
14+
}>()
15+
16+
const rpc = useRpc()
17+
const transforms = ref<RolldownModuleTransformInfo[]>([])
18+
const transformsLoading = ref(false)
19+
const flowNodeSelected = ref(false)
20+
const view = ref<'flow' | 'charts' | 'imports'>('flow')
21+
22+
watchEffect(async () => {
23+
const arg = {
24+
session: props.session.id,
25+
module: props.module,
26+
}
27+
// fetch transforms in the next tick to avoid race conditions with module info
28+
nextTick(async () => {
29+
transforms.value = []
30+
transformsLoading.value = true
31+
transforms.value = await rpc.value!['vite:rolldown:get-module-transforms']?.(arg)
32+
transformsLoading.value = false
33+
})
34+
})
35+
36+
const info = computedAsync(async () => {
37+
const arg = {
38+
session: props.session.id,
39+
module: props.module,
40+
}
41+
return {
42+
transforms: transforms.value,
43+
...(await rpc.value!['vite:rolldown:get-module-info']?.(arg)),
44+
} as ModuleInfo
45+
})
46+
47+
function selectFlowNode(v: boolean) {
48+
flowNodeSelected.value = v
49+
}
50+
</script>
51+
52+
<template>
53+
<div v-if="info" relative h-full w-full>
54+
<DisplayCloseButton
55+
absolute right-2 top-1.5
56+
@click="emit('close')"
57+
/>
58+
<div
59+
bg-glass absolute left-2 top-2 z-panel-content p2
60+
border="~ base rounded-lg"
61+
flex="~ col gap-2"
62+
>
63+
<DisplayModuleId :id="module" px2 py1 :session />
64+
<div flex="~ gap-2">
65+
<button
66+
:class="view === 'flow' ? 'text-primary' : ''"
67+
flex="~ gap-2 items-center justify-center"
68+
px2 py1 w-40
69+
border="~ base rounded-lg"
70+
hover="bg-active"
71+
@click="view = 'flow'"
72+
>
73+
<div i-ph-git-branch-duotone rotate-180 />
74+
Build Flow
75+
</button>
76+
<button
77+
:class="view === 'charts' ? 'text-primary' : ''"
78+
flex="~ gap-2 items-center justify-center"
79+
px2 py1 w-40
80+
border="~ base rounded-lg"
81+
hover="bg-active"
82+
@click="view = 'charts'"
83+
>
84+
<div i-ph-chart-donut-duotone />
85+
Charts
86+
</button>
87+
<button
88+
:class="view === 'imports' ? 'text-primary' : ''"
89+
flex="~ gap-2 items-center justify-center"
90+
px2 py1 w-40
91+
border="~ base rounded-lg"
92+
hover="bg-active"
93+
@click="view = 'imports'"
94+
>
95+
<div i-ph-graph-duotone />
96+
Imports
97+
</button>
98+
</div>
99+
</div>
100+
<div h-30 w-100 />
101+
<FlowmapModuleFlow
102+
v-if="view === 'flow'"
103+
p4
104+
:info
105+
:session
106+
:transforms-loading
107+
@select="selectFlowNode"
108+
/>
109+
<ChartModuleFlamegraph
110+
v-if="view === 'charts'"
111+
:info
112+
:session="session"
113+
:flow-node-selected="flowNodeSelected"
114+
/>
115+
<DataModuleImportRelationships
116+
v-if="view === 'imports'"
117+
:module="info"
118+
:session="session"
119+
/>
120+
</div>
121+
<VisualLoading v-else />
122+
</template>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script setup lang="ts">
2+
import type { ModuleInfo, SessionContext } from '~~/shared/types'
3+
4+
defineProps<{
5+
module: ModuleInfo
6+
session: SessionContext
7+
}>()
8+
</script>
9+
10+
<template>
11+
<div>
12+
Module Imports Relationships (TODO)
13+
</div>
14+
</template>

packages/devtools/src/app/components/flowmap/ModuleFlow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const codeDisplay = computed(() => {
140140
</script>
141141

142142
<template>
143-
<div pt4>
143+
<div pt4 ws-nowrap>
144144
<div v-if="info.importers?.length" text-sm>
145145
<div flex>
146146
<VMenu>

packages/devtools/src/app/components/flowmap/ModuleFlowLoader.vue

Lines changed: 0 additions & 61 deletions
This file was deleted.

packages/devtools/src/app/pages/session/[session].vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,14 @@ onMounted(async () => {
8585
<div
8686
:key="(route.query.module as string)"
8787
v-on-click-outside="closeFlowPanel"
88-
fixed right-0 bottom-0 top-20 z-panel-content
89-
of-scroll bg-glass border="l t base rounded-tl-xl"
90-
max-w-90vw min-w-250
88+
fixed right-0 bottom-0 top-20 left-20 z-panel-content
89+
bg-glass border="l t base rounded-tl-xl"
90+
of-auto
9191
>
92-
<FlowmapModuleFlowLoader
92+
<DataModuleDetailsLoader
9393
:module="(route.query.module as string)"
9494
:session="session"
95-
/>
96-
<DisplayCloseButton
97-
absolute right-2 top-2
98-
@click="closeFlowPanel"
95+
@close="closeFlowPanel"
9996
/>
10097
</div>
10198
</div>

0 commit comments

Comments
 (0)