Skip to content

Commit a39fcf7

Browse files
committed
feat: navigation on resolveId
1 parent f96858e commit a39fcf7

File tree

5 files changed

+72
-49
lines changed

5 files changed

+72
-49
lines changed
Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script setup lang="ts">
2+
import type { SessionContext } from '../../types/data'
3+
import { NuxtLink } from '#components'
24
import { Tooltip } from 'floating-vue'
35
import { relative } from 'pathe'
46
import { computed } from 'vue'
@@ -8,6 +10,8 @@ const props = withDefaults(
810
id?: string
911
badges?: boolean
1012
icon?: boolean
13+
link?: boolean
14+
session?: SessionContext
1115
}>(),
1216
{
1317
icon: true,
@@ -37,32 +41,37 @@ const containerClass = computed(() => {
3741
</script>
3842

3943
<template>
40-
<Tooltip
41-
my-auto text-sm font-mono block w-full
42-
:triggers="['hover']"
43-
:delay="1200"
44-
:disabled="(props.id?.length || 0) < 30"
45-
placement="bottom-start"
44+
<component
45+
:is="link ? NuxtLink : 'div'"
46+
:to="link ? { path: `/session/${session?.id}/flow`, query: { module: id } } : undefined"
4647
>
47-
<div
48-
v-if="id"
49-
:class="containerClass"
48+
<Tooltip
49+
my-auto text-sm font-mono block w-full
50+
:triggers="['hover']"
51+
:delay="1200"
52+
:disabled="(props.id?.length || 0) < 30"
53+
placement="bottom-start"
5054
>
51-
<DisplayFileIcon v-if="icon" :filename="id" mr1.5 />
52-
<span>
53-
<DisplayHighlightedPath :path="relativePath" />
54-
</span>
55-
<slot />
56-
<!-- <DisplayBadge
57-
v-if="isVirtual"
58-
class="ml1"
59-
text="virtual"
60-
/> -->
61-
</div>
62-
<template #popper>
63-
<span font-mono text-sm>
64-
{{ props.id }}
65-
</span>
66-
</template>
67-
</Tooltip>
55+
<div
56+
v-if="id"
57+
:class="containerClass"
58+
>
59+
<DisplayFileIcon v-if="icon" :filename="id" mr1.5 />
60+
<span>
61+
<DisplayHighlightedPath :path="relativePath" />
62+
</span>
63+
<slot />
64+
<!-- <DisplayBadge
65+
v-if="isVirtual"
66+
class="ml1"
67+
text="virtual"
68+
/> -->
69+
</div>
70+
<template #popper>
71+
<span font-mono text-sm>
72+
{{ props.id }}
73+
</span>
74+
</template>
75+
</Tooltip>
76+
</component>
6877
</template>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ const codeDisplay = computed(() => {
134134
v-for="(item, index) of resolveIds"
135135
:key="item.id"
136136
:item="item"
137+
:session="session"
137138
:active="isSelectedAncestor(item)"
138139
:class="index > 0 ? 'pt-2' : ''"
139140
@select="select"
@@ -160,6 +161,7 @@ const codeDisplay = computed(() => {
160161
v-for="(item, index) of loads"
161162
:key="item.id"
162163
:item="item"
164+
:session="session"
163165
:active="isSelectedAncestor(item)"
164166
:class="index > 0 ? 'pt-2' : ''"
165167
@select="select"
@@ -185,6 +187,7 @@ const codeDisplay = computed(() => {
185187
v-for="(item, index) of transforms"
186188
:key="item.id"
187189
:item="item"
190+
:session="session"
188191
:active="isSelectedAncestor(item)"
189192
:class="index > 0 ? 'pt-2' : ''"
190193
@select="select"

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<script setup lang="ts">
2+
import type { SessionContext } from '@/types/data'
23
import type { RolldownModuleFlowNode } from '../../../node/rpc/functions/rolldown-get-module-info'
34
import { computed } from 'vue'
45
import { isFlowmapSwapping } from '../../state/flowmap'
56
67
const props = defineProps<{
78
item: RolldownModuleFlowNode
9+
session: SessionContext
810
active?: boolean
911
}>()
1012
@@ -33,6 +35,13 @@ function down() {
3335
emit('select', props.item)
3436
isFlowmapSwapping.value = true
3537
}
38+
39+
const importterModule = computed(() => {
40+
if (props.item.type !== 'resolve')
41+
return undefined
42+
const id = props.item.importer
43+
return props.session.modulesList.find(m => m.id === id)
44+
})
3645
</script>
3746

3847
<template>
@@ -100,16 +109,20 @@ function down() {
100109
#after
101110
>
102111
<div
103-
p3 ml4 border="l" flex="~ col gap-2"
112+
p3 ml4 border="l" flex="~ col gap-1"
104113
:class="active ? 'border-flow-line-active' : 'border-flow-line'"
105114
>
106-
<DisplayModuleId :id="item.importer" />
107-
<div flex="~ gap-1 items-center" pl1>
108-
<div i-ph-arrow-bend-down-right text-sm op50 />
109-
<DisplayModuleId :id="item.module_request" />
115+
<div flex="~ gap-2 items-center">
116+
<div i-ph-arrow-elbow-left-down text-base op50 flex-none ml0.8 />
117+
<DisplayModuleId
118+
:id="item.importer"
119+
:session="session"
120+
:link="importterModule ? true : false"
121+
:class="importterModule ? 'hover:bg-active' : ''"
122+
px2 py1 rounded
123+
/>
110124
</div>
111-
<div i-ph-arrow-down ml6 text-sm op50 />
112-
<DisplayModuleId :id="item.resolved_id" ml6 />
125+
<DisplayModuleId :id="item.module_request" />
113126
</div>
114127
</template>
115128
</FlowmapNode>

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
<script setup lang="ts">
22
import type { SessionContext } from '../../../types/data'
33
import { useRoute } from '#app/composables/router'
4-
import { useAsyncState } from '@vueuse/core'
4+
import { computedAsync } from '@vueuse/core'
55
import { backend } from '../../../state/backend'
66
77
const props = defineProps<{
88
session: SessionContext
99
}>()
1010
11-
const query = useRoute().query
11+
const route = useRoute()
1212
13-
const { state: info } = useAsyncState(
14-
async () => {
15-
return await backend.value!.functions['vite:rolldown:get-module-info']?.({
16-
session: props.session.id,
17-
module: query.module as string,
18-
})
19-
},
20-
null,
21-
)
13+
const info = computedAsync(async () => {
14+
const arg = {
15+
session: props.session.id,
16+
module: route.query.module as string,
17+
}
18+
return await backend.value!.functions['vite:rolldown:get-module-info']?.(arg)
19+
})
2220
</script>
2321

2422
<template>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ const filtered = computed(() => {
4141
>
4242
</div>
4343
<template v-for="mod of filtered" :key="mod">
44-
<NuxtLink
45-
:to="{ path: `/session/${session.id}/flow`, query: { module: mod.id } }"
44+
<DisplayModuleId
45+
:id="mod.id"
46+
:session
4647
hover="bg-active" block px2 p1
4748
border="~ base rounded"
48-
>
49-
<DisplayModuleId :id="mod.id" />
50-
</NuxtLink>
49+
:link="true"
50+
/>
5151
</template>
5252
<div text-center text-xs op50 m4>
5353
{{ filtered.length }} of {{ session.modulesList.length }}

0 commit comments

Comments
 (0)