1
1
<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'
4
4
import { computed , ref , watch } from ' vue'
5
- import { editInspectorState } from ' @vue/devtools-core'
5
+ import { rpc } from ' @vue/devtools-core'
6
6
import { isArray , isObject , sortByKey } from ' @vue/devtools-shared'
7
7
import { VueButton , VueIcon , vTooltip } from ' @vue/devtools-ui'
8
8
import ChildStateViewer from ' ./ChildStateViewer.vue'
@@ -15,7 +15,7 @@ import type { EditorAddNewPropType } from '~/composables/state-editor'
15
15
import { useHover } from ' ~/composables/hover'
16
16
17
17
const props = defineProps <{
18
- data: InspectorState
18
+ data: CustomInspectorState
19
19
depth: number
20
20
index: string
21
21
}>()
@@ -57,7 +57,7 @@ const normalizedDisplayedKey = computed(() => normalizedPath.value[normalizedPat
57
57
const normalizedDisplayedValue = computed (() => {
58
58
const directlyDisplayedValueMap = [' Reactive' ]
59
59
const extraDisplayedValue = (props .data as InspectorCustomState )?._custom ?.stateTypeName || props .data ?.stateTypeName
60
- if (directlyDisplayedValueMap .includes (extraDisplayedValue ! )) {
60
+ if (directlyDisplayedValueMap .includes (extraDisplayedValue as string )) {
61
61
return extraDisplayedValue
62
62
}
63
63
@@ -95,7 +95,7 @@ const normalizedDisplayedChildren = computed(() => {
95
95
... inherit ,
96
96
editable: props .data .editable && ! isUneditableType ,
97
97
creating: false ,
98
- })) as unknown as InspectorState []
98
+ })) as unknown as CustomInspectorState []
99
99
}
100
100
else if (isObject (value )) {
101
101
displayedChildren = Object .keys (value ).slice (0 , limit .value ).map (key => ({
@@ -110,7 +110,7 @@ const normalizedDisplayedChildren = computed(() => {
110
110
displayedChildren = sortByKey (displayedChildren )
111
111
}
112
112
113
- return (displayedChildren === props .data .value ? [] : displayedChildren ) as InspectorState []
113
+ return (displayedChildren === props .data .value ? [] : displayedChildren ) as CustomInspectorState []
114
114
})
115
115
116
116
// has children
@@ -137,7 +137,7 @@ watch(() => editing.value, (v) => {
137
137
138
138
function submit() {
139
139
const data = props .data
140
- editInspectorState ({
140
+ rpc . value . editInspectorState ({
141
141
path: normalizedPath .value ,
142
142
inspectorId: state .value .inspectorId ,
143
143
type: data .stateType ! ,
@@ -147,7 +147,7 @@ function submit() {
147
147
type: editingType .value ,
148
148
value: toSubmit (editingText .value , raw .value .customType ),
149
149
},
150
- } satisfies InspectorStateEditorPayload )
150
+ } as unknown as DevToolsV6PluginAPIHookPayloads [ DevToolsV6PluginAPIHookKeys . EDIT_COMPONENT_STATE ] )
151
151
toggleEditing ()
152
152
}
153
153
@@ -164,7 +164,7 @@ function addNewProp(type: EditorAddNewPropType) {
164
164
165
165
function submitDrafting() {
166
166
const data = props .data
167
- editInspectorState ({
167
+ rpc . value . editInspectorState ({
168
168
path: [... normalizedPath .value , draftingNewProp .value .key ],
169
169
inspectorId: state .value .inspectorId ,
170
170
type: data .stateType ! ,
@@ -174,7 +174,7 @@ function submitDrafting() {
174
174
type: typeof toSubmit (draftingNewProp .value .value ),
175
175
value: toSubmit (draftingNewProp .value .value ),
176
176
},
177
- } satisfies InspectorStateEditorPayload )
177
+ } as unknown as DevToolsV6PluginAPIHookPayloads [ DevToolsV6PluginAPIHookKeys . EDIT_COMPONENT_STATE ] )
178
178
resetDrafting ()
179
179
}
180
180
0 commit comments