Skip to content

Commit 3feec46

Browse files
webfansplzalexzhang1030autofix-ci[bot]
authored
feat: compatible with v6 plugin API, refactor messaging system (#421)
Co-authored-by: Alex <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 3e882aa commit 3feec46

File tree

225 files changed

+4129
-4694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+4129
-4694
lines changed

.vscode/settings.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@
3131
"yaml"
3232
],
3333
"scss.lint.unknownAtRules": "ignore",
34-
"typescript.tsdk": "node_modules/typescript/lib"
34+
"typescript.tsdk": "node_modules/typescript/lib",
35+
"cSpell.words": [
36+
"Mergeable"
37+
]
3538
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<script setup lang="ts">
2+
</script>
3+
4+
<template>
5+
<div class="h-screen w-screen $ui-fcc flex-col">
6+
<div class="outer">
7+
<div class="inner">
8+
<i class="i-logos-vue inline-block h8! w8!" alt="Vue logo" />
9+
</div>
10+
</div>
11+
<slot />
12+
</div>
13+
</template>
14+
15+
<style scoped>
16+
@keyframes connecting {
17+
0% {
18+
--at-apply: opacity-60 scale-60;
19+
}
20+
50% {
21+
--at-apply: opacity-80 scale-80;
22+
}
23+
100% {
24+
--at-apply: opacity-100 scale-100;
25+
}
26+
}
27+
28+
.outer,
29+
.inner {
30+
--at-apply: transform rounded-[50%] bg-primary-500 bg-opacity-10;
31+
}
32+
.outer {
33+
--at-apply: p-6;
34+
animation: connecting 1.2s linear infinite;
35+
}
36+
37+
.inner {
38+
--at-apply: pt-6 pr-5 pb-4 pl-5;
39+
animation: connecting 1.2s 0.1s backwards linear infinite;
40+
}
41+
</style>

packages/applet/src/components/basic/DevToolsHeader.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { defineProps } from 'vue'
33
import { useVirtualRouter } from '~/composables/virtual-router'
44
55
defineProps<{
6-
githubRepoLink: string
6+
githubRepoLink?: string
77
docLink: string
88
}>()
99
const router = useVirtualRouter()
@@ -20,7 +20,7 @@ const router = useVirtualRouter()
2020
<a class="pr2" :href="docLink" target="_blank">
2121
<i class="i-clarity:document-line cursor-pointer op70 text-base hover:op100" />
2222
</a>
23-
<a :href="githubRepoLink" target="_blank">
23+
<a v-if="githubRepoLink" :href="githubRepoLink" target="_blank">
2424
<i class="i-mdi:github cursor-pointer op70 text-base hover:op100" />
2525
</a>
2626
</div>

packages/applet/src/components/basic/SelectiveList.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
22
import { defineModel } from 'vue'
3-
import type { InspectorNodeTag } from '@vue/devtools-kit'
3+
import type { CustomInspectorNode } from '@vue/devtools-kit'
44
import NodeTag from '~/components/basic/NodeTag.vue'
55
6-
defineProps<{ data: { id: string, label: string, tags: InspectorNodeTag[] }[] }>()
6+
defineProps<{ data: CustomInspectorNode[] }>()
77
88
const selected = defineModel()
99

packages/applet/src/components/state/ChildStateViewer.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
2-
import type { InspectorState } from '@vue/devtools-kit'
2+
import type { CustomInspectorState } from '@vue/devtools-kit'
33
import StateFieldViewer from './StateFieldViewer.vue'
44
55
withDefaults(defineProps<{
6-
data: InspectorState[]
6+
data: CustomInspectorState[]
77
depth: number
88
index: string
99
}>(), {

packages/applet/src/components/state/RootStateViewer.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script setup lang="ts">
22
import { watchEffect } from 'vue'
3-
import type { InspectorState } from '@vue/devtools-kit'
3+
import type { CustomInspectorState } from '@vue/devtools-kit'
44
import ChildStateViewer from './ChildStateViewer.vue'
55
import ToggleExpanded from '~/components/basic/ToggleExpanded.vue'
66
import { useToggleExpanded } from '~/composables/toggle-expanded'
77
import { createStateEditorContext } from '~/composables/state-editor'
88
99
const props = withDefaults(defineProps<{
10-
data: Record<string, InspectorState[]>
10+
data: Record<string, CustomInspectorState[]>
1111
nodeId: string
1212
inspectorId: string
1313
disableEdit?: boolean

packages/applet/src/components/state/StateFieldEditor.vue

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<script setup lang="ts">
22
import { computed, ref, toRaw } from 'vue'
33
import { VueButton, VueDropdown, VueDropdownButton, VueIcon, vTooltip } from '@vue/devtools-ui'
4-
import { getRaw } from '@vue/devtools-kit'
5-
import type { InspectorState, InspectorStateEditorPayload } from '@vue/devtools-kit'
4+
import { DevToolsV6PluginAPIHookKeys, getRaw } from '@vue/devtools-kit'
5+
import type { CustomInspectorState, DevToolsV6PluginAPIHookPayloads } from '@vue/devtools-kit'
66
import type { ButtonProps } from '@vue/devtools-ui/dist/types/src/components/Button'
7-
import { editInspectorState } from '@vue/devtools-core'
7+
import { rpc } from '@vue/devtools-core'
88
import { useClipboard } from '@vueuse/core'
99
import { useStateEditorContext } from '~/composables/state-editor'
1010
import type { EditorAddNewPropType, EditorInputValidType } from '~/composables/state-editor'
1111
1212
const props = withDefaults(defineProps<{
13-
data: InspectorState
13+
data: CustomInspectorState & { key?: string }
1414
hovering: boolean
1515
depth: number
1616
showAddIfNeeded?: boolean
@@ -45,7 +45,7 @@ const buttonClass = computed(() => ({
4545
}))
4646
4747
function quickEdit(v: unknown, remove: boolean = false) {
48-
editInspectorState({
48+
rpc.value.editInspectorState({
4949
path: props.data.path || [props.data.key],
5050
inspectorId: state.value.inspectorId,
5151
type: props.data.stateType!,
@@ -56,7 +56,7 @@ function quickEdit(v: unknown, remove: boolean = false) {
5656
type: dataType.value,
5757
remove,
5858
},
59-
} satisfies InspectorStateEditorPayload)
59+
} as unknown as DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.EDIT_COMPONENT_STATE])
6060
}
6161
6262
function quickEditNum(v: number | string, offset: 1 | -1) {
@@ -147,7 +147,7 @@ function quickEditNum(v: number | string, offset: 1 | -1) {
147147
</VueDropdownButton>
148148
<VueDropdownButton
149149
@click="() => {
150-
copy(data.key)
150+
copy(data.key!)
151151
}"
152152
>
153153
<template #icon>

packages/applet/src/components/state/StateFieldViewer.vue

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
2-
import type { InspectorCustomState, InspectorState, InspectorStateEditorPayload } from '@vue/devtools-kit'
3-
import { formatInspectorStateValue, getInspectorStateValueType, getRaw, toEdit, toSubmit } from '@vue/devtools-kit'
2+
import type { CustomInspectorState, InspectorCustomState } from '@vue/devtools-kit'
3+
import { DevToolsV6PluginAPIHookKeys, DevToolsV6PluginAPIHookPayloads, formatInspectorStateValue, getInspectorStateValueType, getRaw, toEdit, toSubmit } from '@vue/devtools-kit'
44
import { computed, ref, watch } from 'vue'
5-
import { editInspectorState } from '@vue/devtools-core'
5+
import { rpc } from '@vue/devtools-core'
66
import { isArray, isObject, sortByKey } from '@vue/devtools-shared'
77
import { VueButton, VueIcon, vTooltip } from '@vue/devtools-ui'
88
import ChildStateViewer from './ChildStateViewer.vue'
@@ -15,7 +15,7 @@ import type { EditorAddNewPropType } from '~/composables/state-editor'
1515
import { useHover } from '~/composables/hover'
1616
1717
const props = defineProps<{
18-
data: InspectorState
18+
data: CustomInspectorState
1919
depth: number
2020
index: string
2121
}>()
@@ -57,7 +57,7 @@ const normalizedDisplayedKey = computed(() => normalizedPath.value[normalizedPat
5757
const normalizedDisplayedValue = computed(() => {
5858
const directlyDisplayedValueMap = ['Reactive']
5959
const extraDisplayedValue = (props.data as InspectorCustomState)?._custom?.stateTypeName || props.data?.stateTypeName
60-
if (directlyDisplayedValueMap.includes(extraDisplayedValue!)) {
60+
if (directlyDisplayedValueMap.includes(extraDisplayedValue as string)) {
6161
return extraDisplayedValue
6262
}
6363
@@ -95,7 +95,7 @@ const normalizedDisplayedChildren = computed(() => {
9595
...inherit,
9696
editable: props.data.editable && !isUneditableType,
9797
creating: false,
98-
})) as unknown as InspectorState[]
98+
})) as unknown as CustomInspectorState[]
9999
}
100100
else if (isObject(value)) {
101101
displayedChildren = Object.keys(value).slice(0, limit.value).map(key => ({
@@ -110,7 +110,7 @@ const normalizedDisplayedChildren = computed(() => {
110110
displayedChildren = sortByKey(displayedChildren)
111111
}
112112
113-
return (displayedChildren === props.data.value ? [] : displayedChildren) as InspectorState[]
113+
return (displayedChildren === props.data.value ? [] : displayedChildren) as CustomInspectorState[]
114114
})
115115
116116
// has children
@@ -137,7 +137,7 @@ watch(() => editing.value, (v) => {
137137
138138
function submit() {
139139
const data = props.data
140-
editInspectorState({
140+
rpc.value.editInspectorState({
141141
path: normalizedPath.value,
142142
inspectorId: state.value.inspectorId,
143143
type: data.stateType!,
@@ -147,7 +147,7 @@ function submit() {
147147
type: editingType.value,
148148
value: toSubmit(editingText.value, raw.value.customType),
149149
},
150-
} satisfies InspectorStateEditorPayload)
150+
} as unknown as DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.EDIT_COMPONENT_STATE])
151151
toggleEditing()
152152
}
153153
@@ -164,7 +164,7 @@ function addNewProp(type: EditorAddNewPropType) {
164164
165165
function submitDrafting() {
166166
const data = props.data
167-
editInspectorState({
167+
rpc.value.editInspectorState({
168168
path: [...normalizedPath.value, draftingNewProp.value.key],
169169
inspectorId: state.value.inspectorId,
170170
type: data.stateType!,
@@ -174,7 +174,7 @@ function submitDrafting() {
174174
type: typeof toSubmit(draftingNewProp.value.value),
175175
value: toSubmit(draftingNewProp.value.value),
176176
},
177-
} satisfies InspectorStateEditorPayload)
177+
} as unknown as DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.EDIT_COMPONENT_STATE])
178178
resetDrafting()
179179
}
180180

packages/applet/src/components/timeline/EventList.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang="ts">
2-
import type { TimelineEvent } from '@vue/devtools-kit'
2+
import type { TimelineEventOptions } from '@vue/devtools-kit'
33
import { computed } from 'vue'
44
import { RecycleScroller } from 'vue-virtual-scroller'
55
import { formatTime } from '~/utils'
66
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
77
88
const props = defineProps<{
9-
data: Array<TimelineEvent['event'] & { color?: string, id?: number }>
9+
data: Array<TimelineEventOptions['event'] & { color?: string, id?: number }>
1010
}>()
1111
1212
const selected = defineModel()
@@ -19,7 +19,7 @@ const normalizedData = computed(() => {
1919
if (item.groupId !== currentGroupId || currentColorIndex === -1)
2020
currentColorIndex = (currentColorIndex + 1) % colors.length
2121
22-
currentGroupId = item.groupId ?? currentGroupId
22+
currentGroupId = item.groupId as number ?? currentGroupId
2323
2424
item.id = index
2525
item.color = colors[currentColorIndex]

packages/applet/src/components/timeline/index.vue

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
22
import { Pane, Splitpanes } from 'splitpanes'
3-
import { onAddTimelineEvent } from '@vue/devtools-core'
4-
import { computed, ref } from 'vue'
3+
import { DevToolsMessagingEvents, rpc } from '@vue/devtools-core'
4+
import { computed, onUnmounted, ref } from 'vue'
55
6-
import type { InspectorState, TimelineEvent } from '@vue/devtools-kit'
6+
import type { CustomInspectorState, TimelineEventOptions } from '@vue/devtools-kit'
77
import EventList from './EventList.vue'
88
import Navbar from '~/components/basic/Navbar.vue'
99
import Empty from '~/components/basic/Empty.vue'
@@ -14,28 +14,28 @@ import DevToolsHeader from '~/components/basic/DevToolsHeader.vue'
1414
const props = defineProps<{
1515
layerIds: string[]
1616
docLink: string
17-
githubRepoLink: string
17+
githubRepoLink?: string
1818
}>()
1919
2020
const { expanded: expandedStateNodes } = createExpandedContext('timeline-state')
2121
2222
// event info + group info = [0, 1]
2323
expandedStateNodes.value = ['0', '1']
2424
25-
const eventList = ref<TimelineEvent['event'][]>([])
26-
const groupList = ref<Map<number, TimelineEvent['event'][]>>(new Map())
25+
const eventList = ref<TimelineEventOptions['event'][]>([])
26+
const groupList = ref<Map<string | number | undefined, TimelineEventOptions['event'][]>>(new Map())
2727
const selectedEventIndex = ref(0)
2828
const selectedEventInfo = computed(() => eventList.value[selectedEventIndex.value] ?? null)
2929
// event info
3030
const normalizedEventInfo = computed(() => {
31-
const info: InspectorState[] = []
31+
const info: CustomInspectorState[] = []
3232
for (const key in selectedEventInfo.value?.data) {
3333
info.push({
3434
key,
3535
type: key,
3636
editable: false,
3737
value: selectedEventInfo.value.data[key]!,
38-
})
38+
} as unknown as CustomInspectorState)
3939
}
4040
return info
4141
})
@@ -62,18 +62,18 @@ const normalizedGroupInfo = computed(() => {
6262
6363
// normalize display info
6464
const displayedInfo = computed(() => {
65-
return { 'Event Info': normalizedEventInfo.value, ...(normalizedGroupInfo.value && { 'Group Info': normalizedGroupInfo.value }) } as unknown as Record<string, InspectorState[]>
65+
return { 'Event Info': normalizedEventInfo.value, ...(normalizedGroupInfo.value && { 'Group Info': normalizedGroupInfo.value }) } as unknown as Record<string, CustomInspectorState[]>
6666
})
6767
68-
function normalizeGroupList(event: TimelineEvent['event']) {
68+
function normalizeGroupList(event: TimelineEventOptions['event']) {
6969
const groupId = event.groupId
7070
if (groupId !== undefined) {
7171
groupList.value.set(groupId, groupList.value.get(groupId) ?? [])
7272
groupList.value.get(groupId)?.push(event)
7373
}
7474
}
7575
76-
onAddTimelineEvent((payload) => {
76+
function onTimelineEventUpdated(payload) {
7777
if (!payload)
7878
return
7979
@@ -83,6 +83,12 @@ onAddTimelineEvent((payload) => {
8383
8484
eventList.value.push(event)
8585
normalizeGroupList(event)
86+
}
87+
88+
rpc.functions.on(DevToolsMessagingEvents.TIMELINE_EVENT_UPDATED, onTimelineEventUpdated)
89+
90+
onUnmounted(() => {
91+
rpc.functions.off(DevToolsMessagingEvents.TIMELINE_EVENT_UPDATED, onTimelineEventUpdated)
8692
})
8793
</script>
8894

packages/applet/src/composables/connect-state.ts

-47
This file was deleted.

0 commit comments

Comments
 (0)