Skip to content

Commit f6dc53b

Browse files
committed
feat: plugins page
1 parent 53affa0 commit f6dc53b

26 files changed

Lines changed: 2181 additions & 52 deletions

packages/vite/src/app/app.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ useSideNav(() => {
2727
icon: 'i-ph-graph-duotone',
2828
to: '/graph',
2929
},
30+
{
31+
title: 'Plugins',
32+
icon: 'i-ph-plugs-duotone',
33+
to: '/plugins',
34+
},
3035
]
3136
})
3237
</script>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script setup lang="ts" generic="T extends { id: string; text?: string; parent?: T }">
2+
import type { GraphBaseOptions } from 'nanovis'
3+
import { computed } from 'vue'
4+
5+
const props = defineProps<{
6+
selected?: T
7+
options: GraphBaseOptions<any>
8+
}>()
9+
10+
const emit = defineEmits<{
11+
(e: 'select', node: T | null): void
12+
}>()
13+
14+
const parentStack = computed(() => {
15+
const stack: T[] = []
16+
let current = props.selected
17+
while (current) {
18+
stack.unshift(current)
19+
current = current.parent
20+
}
21+
return stack
22+
})
23+
</script>
24+
25+
<template>
26+
<div flex="~ gap-1 items-center wrap">
27+
<template v-for="node, idx of parentStack" :key="node.id">
28+
<div v-if="idx > 0" i-ph-arrow-right-bold text-sm op-fade />
29+
<button
30+
hover="bg-active" rounded px1
31+
@click="emit('select', node)"
32+
>
33+
<span>{{ node.text || node.id }}</span>
34+
</button>
35+
</template>
36+
</div>
37+
</template>

packages/vite/src/app/components/data/ModuleDetailsLoader.vue

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<script setup lang="ts">
22
import type { DevToolsRpcServerFunctions } from '@vitejs/devtools-kit'
3+
import type { InspectModuleUpdatedPayload } from '~/composables/rpc'
34
import type { ViteModuleListItem } from '~/types/modules'
45
import DisplayCloseButton from '@vitejs/devtools-ui/components/DisplayCloseButton.vue'
5-
import { computed, nextTick, ref, watchEffect } from 'vue'
6+
import { useDebounceFn } from '@vueuse/core'
7+
import { computed, ref, watch } from 'vue'
68
import { useRpc } from '#imports'
9+
import { onInspectModuleUpdated } from '~/composables/rpc'
710
import { settings } from '~/state/settings'
811
912
type InspectQuery = Parameters<DevToolsRpcServerFunctions['vite:inspect:get-module-transform-info']>[0]
@@ -27,14 +30,40 @@ const flowNodeSelected = ref(false)
2730
2831
const info = computed(() => props.modules.find(item => item.id === props.module))
2932
30-
watchEffect(async () => {
33+
let transformRequestVersion = 0
34+
35+
async function loadTransformInfo() {
3136
const query = props.query
3237
const moduleId = props.module
33-
nextTick(async () => {
34-
transformsLoading.value = true
35-
transformInfo.value = await rpc.value.call('vite:inspect:get-module-transform-info', query, moduleId)
36-
transformsLoading.value = false
37-
})
38+
39+
const requestVersion = ++transformRequestVersion
40+
transformsLoading.value = true
41+
try {
42+
const result = await rpc.value.call('vite:inspect:get-module-transform-info', query, moduleId)
43+
if (requestVersion === transformRequestVersion)
44+
transformInfo.value = result
45+
}
46+
finally {
47+
if (requestVersion === transformRequestVersion)
48+
transformsLoading.value = false
49+
}
50+
}
51+
52+
const reloadTransformInfo = useDebounceFn((payload: InspectModuleUpdatedPayload = {}) => {
53+
if (!payload.ids || payload.ids.includes(props.module))
54+
loadTransformInfo()
55+
}, 100)
56+
57+
watch(
58+
() => [props.query.vite, props.query.env, props.module],
59+
() => {
60+
loadTransformInfo()
61+
},
62+
{ immediate: true },
63+
)
64+
65+
onInspectModuleUpdated((payload) => {
66+
reloadTransformInfo(payload)
3867
})
3968
4069
function selectFlowNode(v: boolean) {

0 commit comments

Comments
 (0)