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