1
1
<script setup lang="ts">
2
- import type { ModuleInfo , RolldownModuleFlowNode , RolldownModuleLoadNoChanges , RolldownModuleTransformInfo , RolldownModuleTransformNoChanges , SessionContext } from ' ~~/shared/types'
2
+ import type { ModuleInfo , RolldownModuleFlowNode , RolldownModuleNoChanges , RolldownModuleNoChangesHide , RolldownModuleTransformInfo , SessionContext } from ' ~~/shared/types'
3
3
import { Menu as VMenu } from ' floating-vue'
4
- import { computed , ref , shallowRef , toRefs , watch } from ' vue'
4
+ import { computed , shallowRef , toRefs , watch } from ' vue'
5
+ import { settingsRefs } from ' ~/state/settings'
5
6
import PluginName from ' ../display/PluginName.vue'
6
7
7
8
const props = defineProps <{
@@ -13,51 +14,85 @@ const emit = defineEmits<{
13
14
(e : ' select' , v : boolean ): void
14
15
}>()
15
16
const { info } = toRefs (props )
16
- const expandNoChangesTransform = ref (false )
17
- const expandNoChangesLoad = ref (false )
17
+
18
+ const {
19
+ flowShowAllTransforms,
20
+ flowShowAllLoads,
21
+ flowExpandTransforms,
22
+ flowExpandLoads,
23
+ flowExpandResolveId,
24
+ } = settingsRefs
25
+
18
26
const selected = shallowRef <RolldownModuleFlowNode | null >(null )
19
27
20
28
const resolveIds = computed (() => info ?.value ?.resolve_ids ?? [])
21
29
22
- const transforms = computed ((): (RolldownModuleTransformNoChanges | RolldownModuleTransformInfo )[] => {
23
- if (expandNoChangesTransform .value )
24
- return info ?.value ?.transforms ?? []
25
-
30
+ const transforms = computed ((): (RolldownModuleNoChanges | RolldownModuleNoChangesHide | RolldownModuleTransformInfo )[] => {
26
31
const unchanged = info ?.value ?.transforms ?.filter (t => t .content_from === t .content_to )
27
32
const changed = info ?.value ?.transforms ?.filter (t => t .content_from !== t .content_to )
28
33
34
+ if (flowShowAllTransforms .value && ! unchanged ?.length )
35
+ return info ?.value ?.transforms ?? []
36
+
37
+ if (flowShowAllTransforms .value && unchanged ?.length ) {
38
+ return [
39
+ ... (info .value .transforms ?? []),
40
+ ({
41
+ type: ' no_changes_hide' ,
42
+ id: ' no_changes_hide' ,
43
+ count: unchanged ?.length ?? 0 ,
44
+ duration: unchanged ?.reduce ((acc , t ) => acc + t .duration , 0 ) ?? 0 ,
45
+ } satisfies RolldownModuleNoChangesHide ),
46
+ ]
47
+ }
48
+
29
49
if (! unchanged ?.length )
30
50
return changed ?? []
51
+
31
52
return [
32
53
({
33
- type: ' transform_no_changes ' ,
34
- id: ' transform_no_changes ' ,
54
+ type: ' no_changes_collapsed ' ,
55
+ id: ' no_changes_collapsed ' ,
35
56
count: unchanged ?.length ?? 0 ,
36
57
duration: unchanged ?.reduce ((acc , t ) => acc + t .duration , 0 ) ?? 0 ,
37
- } satisfies RolldownModuleTransformNoChanges ),
58
+ } satisfies RolldownModuleNoChanges ),
38
59
... (changed ?? []),
39
60
]
40
61
})
41
62
42
63
const loads = computed (() => {
43
- if (expandNoChangesLoad .value )
44
- return info ?.value ?.loads ?? []
45
-
46
64
const unchanged = info ?.value ?.loads ?.filter (l => ! l .content )
47
65
const changed = info ?.value ?.loads ?.filter (l => l .content )
48
66
67
+ if (flowShowAllLoads .value && ! unchanged ?.length )
68
+ return info ?.value ?.loads ?? []
69
+
70
+ if (flowShowAllLoads .value && unchanged ?.length ) {
71
+ return [
72
+ ... (info .value .loads ?? []),
73
+ ({
74
+ type: ' no_changes_hide' ,
75
+ id: ' no_changes_hide' ,
76
+ count: unchanged ?.length ?? 0 ,
77
+ duration: unchanged ?.reduce ((acc , t ) => acc + t .duration , 0 ) ?? 0 ,
78
+ } satisfies RolldownModuleNoChangesHide ),
79
+ ]
80
+ }
81
+
49
82
if (! unchanged ?.length )
50
83
return changed ?? []
84
+
51
85
return [
52
86
({
53
- type: ' load_no_changes ' ,
54
- id: ' load_no_changes ' ,
87
+ type: ' no_changes_collapsed ' ,
88
+ id: ' no_changes_collapsed ' ,
55
89
count: unchanged ?.length ?? 0 ,
56
90
duration: unchanged ?.reduce ((acc , t ) => acc + t .duration , 0 ) ?? 0 ,
57
- } satisfies RolldownModuleLoadNoChanges ),
91
+ } satisfies RolldownModuleNoChanges ),
58
92
... (changed ?? []),
59
93
]
60
94
})
95
+
61
96
const nodes = computed (() => [
62
97
... resolveIds .value ,
63
98
... loads .value ,
@@ -82,13 +117,6 @@ watch(selected, (v) => {
82
117
emit (' select' , !! v )
83
118
})
84
119
85
- function activate(node : RolldownModuleFlowNode ) {
86
- if (node .type === ' transform_no_changes' )
87
- expandNoChangesTransform .value = ! expandNoChangesTransform .value
88
- else if (node .type === ' load_no_changes' )
89
- expandNoChangesLoad .value = ! expandNoChangesLoad .value
90
- }
91
-
92
120
const codeDisplay = computed (() => {
93
121
if (! selected .value )
94
122
return null
@@ -189,9 +217,10 @@ const codeDisplay = computed(() => {
189
217
</VMenu >
190
218
</template >
191
219
</div >
192
- <div flex =" ~ gap-10" >
220
+ <div flex =" ~ gap-10" min-w-300 >
193
221
<div select-none w-max >
194
222
<FlowmapExpandable
223
+ v-model:expanded =" flowExpandResolveId"
195
224
:expandable =" resolveIds.length > 0"
196
225
:class-root-node =" resolveIds.length === 0 ? 'border-dashed' : ''"
197
226
:active-start =" isSelectedAncestor(resolveIds[0] || loads[0])"
@@ -211,13 +240,13 @@ const codeDisplay = computed(() => {
211
240
:active =" isSelectedAncestor(item)"
212
241
:class =" index > 0 ? 'pt-2' : ''"
213
242
@select =" select"
214
- @activate =" activate"
215
243
/>
216
244
</div >
217
245
</template >
218
246
</FlowmapExpandable >
219
247
220
248
<FlowmapExpandable
249
+ v-model:expanded =" flowExpandLoads"
221
250
:expandable =" loads.length > 0"
222
251
:class-root-node =" loads.length === 0 ? 'border-dashed' : ''"
223
252
:active-start =" isSelectedAncestor(loads[0])"
@@ -237,13 +266,14 @@ const codeDisplay = computed(() => {
237
266
:active =" isSelectedAncestor(item)"
238
267
:class =" index > 0 ? 'pt-2' : ''"
239
268
@select =" select"
240
- @activate = " activate "
269
+ @toggle-show-all = " flowShowAllLoads = !flowShowAllLoads "
241
270
/>
242
271
</div >
243
272
</template >
244
273
</FlowmapExpandable >
245
274
246
275
<FlowmapExpandable
276
+ v-model:expanded =" flowExpandTransforms"
247
277
:expandable =" transforms.length > 0"
248
278
:class-root-node =" transforms.length === 0 ? 'border-dashed' : ''"
249
279
:active-start =" isSelectedAncestor(transforms[0])"
@@ -264,7 +294,7 @@ const codeDisplay = computed(() => {
264
294
:active =" isSelectedAncestor(item)"
265
295
:class =" index > 0 ? 'pt-2' : ''"
266
296
@select =" select"
267
- @activate = " activate "
297
+ @toggle-show-all = " flowShowAllTransforms = !flowShowAllTransforms "
268
298
/>
269
299
</div >
270
300
</template >
0 commit comments