|
| 1 | +<script setup lang="ts"> |
| 2 | +import type { RolldownChunkImport, RolldownChunkInfo } from '~~/shared/types/data' |
| 3 | +import { useRoute } from '#app/composables/router' |
| 4 | +import { NuxtLink } from '#components' |
| 5 | +import { computed } from 'vue' |
| 6 | +
|
| 7 | +const props = withDefaults(defineProps<{ |
| 8 | + chunk: RolldownChunkInfo | RolldownChunkImport |
| 9 | + link?: boolean |
| 10 | +}>(), { |
| 11 | + link: false, |
| 12 | +}) |
| 13 | +const route = useRoute() |
| 14 | +const normalizedImports = computed(() => Array.isArray(props.chunk.imports) ? props.chunk.imports.length : props.chunk.imports) |
| 15 | +const normalizedModules = computed(() => Array.isArray(props.chunk.modules) ? props.chunk.modules.length : props.chunk.modules) |
| 16 | +</script> |
| 17 | + |
| 18 | +<template> |
| 19 | + <component |
| 20 | + :is="link ? NuxtLink : 'div'" |
| 21 | + :to="link ? (typeof link === 'string' ? link : { path: route.path, query: { chunk: chunk.chunk_id } }) : undefined" |
| 22 | + flex="~ gap-3 items-center" |
| 23 | + > |
| 24 | + <div flex="~ gap-2 items-center" :title="`Chunk #${chunk.chunk_id}`"> |
| 25 | + <slot name="icon"> |
| 26 | + <div i-ph-shapes-duotone /> |
| 27 | + </slot> |
| 28 | + <div>{{ chunk.name || '[unnamed]' }}</div> |
| 29 | + <DisplayBadge :text="chunk.reason" /> |
| 30 | + <slot name="left-after" /> |
| 31 | + </div> |
| 32 | + |
| 33 | + <div flex-auto /> |
| 34 | + |
| 35 | + <div flex="~ items-center gap-2"> |
| 36 | + <span op50 font-mono>#{{ chunk.chunk_id }}</span> |
| 37 | + <div flex="~ gap-1 items-center" :title="`${normalizedImports} imports`"> |
| 38 | + <div i-ph-file-arrow-up-duotone /> |
| 39 | + {{ normalizedImports }} |
| 40 | + </div> |
| 41 | + <div flex="~ gap-1 items-center" :title="`${normalizedModules} modules`"> |
| 42 | + <div i-ph-package-duotone /> |
| 43 | + {{ normalizedModules }} |
| 44 | + </div> |
| 45 | + </div> |
| 46 | + <slot /> |
| 47 | + </component> |
| 48 | +</template> |
0 commit comments