-
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathNodeModuleInfo.vue
More file actions
157 lines (150 loc) · 4.56 KB
/
Copy pathNodeModuleInfo.vue
File metadata and controls
157 lines (150 loc) · 4.56 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<script setup lang="ts">
import type { RolldownModuleFlowNode, SessionContext } from '~~/shared/types'
import { computed } from 'vue'
import { isFlowmapSwapping } from '~/state/flowmap'
const props = defineProps<{
item: RolldownModuleFlowNode
session: SessionContext
active?: boolean
}>()
const emit = defineEmits<{
(e: 'select', item: RolldownModuleFlowNode): void
(e: 'toggleShowAll', item: RolldownModuleFlowNode): void
}>()
const isDashed = computed(() => {
switch (props.item.type) {
case 'transform':
return props.item.content_from === props.item.content_to
case 'load':
return props.item.content == null
default:
return false
}
})
function enter() {
if (isFlowmapSwapping.value)
emit('select', props.item)
}
function down() {
emit('select', props.item)
isFlowmapSwapping.value = true
}
const importterModule = computed(() => {
if (props.item.type !== 'resolve')
return undefined
const id = props.item.importer
return props.session.modulesList.find(m => m.id === id)
})
</script>
<template>
<div v-if="item.type === 'no_changes_collapsed'" pl10>
<div
flex="~ gap-2 items-center" text-sm border="l" py1
:class="active ? 'border-flow-line-active' : 'border-flow-line'"
>
<div
w-2 h-2 border="4" rounded-full ml--1 translate-x--0.5px
:class="active ? 'border-flow-line-active' : 'border-flow-line'"
/>
<span op50>{{ item.count }} plugins did not change the content but cost</span>
<DisplayDuration :duration="item.duration" :color="true" :factor="5" text-xs />
<span op50 flex-shrink-0>in total</span>
<button
border="~ base rounded-full" px2 py-px op50 hover="op100"
@click="emit('toggleShowAll', item)"
>
Expand
</button>
</div>
</div>
<div v-else-if="item.type === 'no_changes_hide'" pl10>
<div
flex="~ gap-2 items-center" text-sm border="l" py1
:class="active ? 'border-flow-line-active' : 'border-flow-line'"
>
<div
w-2 h-2 border="4" rounded-full ml--1 translate-x--0.5px
:class="active ? 'border-flow-line-active' : 'border-flow-line'"
/>
<span op50>{{ item.count }} plugins did not change the content but cost</span>
<DisplayDuration :duration="item.duration" :color="true" :factor="5" text-xs />
<span op50 flex-shrink-0>in total</span>
<button
border="~ base rounded-full" px2 py-px op50 hover="op100"
@click="emit('toggleShowAll', item)"
>
Hide
</button>
</div>
</div>
<FlowmapNode
v-else
:lines="{ top: true }"
:class-node-outer="isDashed ? 'border-dashed' : ''"
:active="active"
class-node-inline="gap-2 items-center"
pl6
@pointerenter="enter"
>
<template #inner>
<button
px3 py1 hover="bg-active" flex="~ inline gap-2 items-center"
@click="emit('select', item)"
@pointerdown="down"
>
<slot name="button">
<DisplayPluginName
v-if="'plugin_name' in item"
:class="isDashed ? 'op50' : ''"
:name="item.plugin_name"
class="font-mono text-sm ws-nowrap"
/>
</slot>
</button>
</template>
<template #inline-after>
<DisplayDuration
v-if="'duration' in item"
:duration="item.duration"
:color="true"
:factor="5"
text-xs flex-shrink-0
/>
<template v-if="item.type === 'transform'">
<div v-if="item.content_from === item.content_to" text-xs op25>
no changes
</div>
<div v-else>
<div font-mono text-xs flex="~ gap-1 items-center">
<span text-green>+{{ item.diff_added }}</span>
<span text-red>-{{ item.diff_removed }}</span>
</div>
</div>
</template>
</template>
<template
v-if="item.type === 'resolve' && item.resolved_id && item.importer"
#after
>
<div
p3 ml4 border="l" flex="~ col gap-1"
:class="active ? 'border-flow-line-active' : 'border-flow-line'"
>
<div flex="~ gap-2 items-center">
<div i-ph-arrow-elbow-left-down text-base op50 flex-none ml0.8 />
<DisplayModuleId
:id="item.importer"
:session="session"
:link="importterModule ? true : false"
:class="importterModule ? 'hover:bg-active' : ''"
px2 py1 rounded
/>
</div>
<DisplayModuleId
:id="item.module_request"
:session="session"
/>
</div>
</template>
</FlowmapNode>
</template>