22import type { ModuleInfo , RolldownModuleTransformInfo , SessionContext } from ' ~~/shared/types'
33import { useRpc } from ' #imports'
44import { computedAsync } from ' @vueuse/core'
5- import { computed , nextTick , ref , watchEffect } from ' vue'
5+ import { nextTick , ref , watchEffect } from ' vue'
66import { settings } from ' ~~/app/state/settings'
7- import { getContentByteSize } from ' ~~/app/utils/format'
87
98const props = defineProps <{
109 session: SessionContext
@@ -45,41 +44,6 @@ const info = computedAsync(async () => {
4544 } as ModuleInfo
4645})
4746
48- const durations = computed (() => {
49- const data = info .value
50- const _resolveIds = data ?.resolve_ids .reduce ((t , node ) => {
51- t += node .duration
52- return t
53- }, 0 ) ?? 0
54- const _loads = data ?.loads ?.reduce ((t , node ) => {
55- t += node .duration
56- return t
57- }, 0 ) ?? 0
58- const _transforms = data ?.transforms .reduce ((t , node ) => {
59- t += node .duration
60- return t
61- }, 0 ) ?? 0
62- const total = _resolveIds + _loads + _transforms
63- return {
64- resolveIds: _resolveIds ,
65- loads: _loads ,
66- transforms: _transforms ,
67- total ,
68- }
69- })
70-
71- const sourceCodeSize = computed (() => {
72- const data = info .value ?.transforms
73- const source = data ?.[0 ]?.content_from ?? ' '
74- return getContentByteSize (source )
75- })
76-
77- const transformedCodeSize = computed (() => {
78- const data = info .value ?.transforms ?.filter (t => t .content_to )?.reverse ()
79- const source = data ?.[0 ]?.content_to ?? ' '
80- return getContentByteSize (source )
81- })
82-
8347function selectFlowNode(v : boolean ) {
8448 flowNodeSelected .value = v
8549}
@@ -98,39 +62,7 @@ function selectFlowNode(v: boolean) {
9862 >
9963 <DisplayModuleId :id =" module" px2 pt1 :session />
10064 <div text-xs font-mono flex =" ~ items-center gap-3" ml2 >
101- <DisplayDuration
102- :duration =" durations.resolveIds" flex =" ~ gap-1 items-center"
103- :title =" `resolveId hooks cost: ${durations.resolveIds}ms`"
104- >
105- <span i-ph-magnifying-glass-duotone inline-block />
106- </DisplayDuration >
107- <DisplayDuration
108- :duration =" durations.loads" flex =" ~ gap-1 items-center"
109- :title =" `load hooks cost: ${durations.loads}ms`"
110- >
111- <span i-ph-upload-simple-duotone inline-block />
112- </DisplayDuration >
113- <DisplayDuration
114- :duration =" durations.transforms" flex =" ~ gap-1 items-center"
115- :title =" `transform hooks cost: ${durations.transforms}ms`"
116- >
117- <span i-ph-magic-wand-duotone inline-block />
118- </DisplayDuration >
119- <span op40 >|</span >
120- <DisplayDuration
121- :duration =" durations.total" flex =" ~ gap-1 items-center"
122- :title =" `Total build cost: ${durations.total}ms`"
123- >
124- <span i-ph-clock-duotone inline-block />
125- </DisplayDuration >
126- <template v-if =" sourceCodeSize && transformedCodeSize " >
127- <span op40 >|</span >
128- <div flex =" ~ gap-1 items-center" >
129- <DisplayFileSizeBadge title =" Source code size" :bytes =" sourceCodeSize" />
130- <span i-carbon-arrow-right op50 />
131- <DisplayFileSizeBadge title =" Transformed code size" :bytes =" transformedCodeSize" />
132- </div >
133- </template >
65+ <ModulesBuildMetrics v-if =" info" :metrics =" info.build_metrics" />
13466 </div >
13567 <div flex =" ~ gap-2" >
13668 <button
0 commit comments