@tanstack/devtools-utils 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -2
- package/src/vue/index.ts +2 -0
- package/src/vue/panel.ts +71 -0
- package/src/vue/plugin.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/devtools-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "TanStack Devtools utilities for creating your own devtools.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@types/react": ">=19.0.0",
|
|
55
55
|
"react": ">=19.0.0",
|
|
56
|
-
"solid-js": ">=1.9.7"
|
|
56
|
+
"solid-js": ">=1.9.7",
|
|
57
|
+
"vue": ">=3.2.0"
|
|
57
58
|
},
|
|
58
59
|
"peerDependenciesMeta": {
|
|
59
60
|
"react": {
|
|
@@ -64,6 +65,9 @@
|
|
|
64
65
|
},
|
|
65
66
|
"solid-js": {
|
|
66
67
|
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"vue": {
|
|
70
|
+
"optional": true
|
|
67
71
|
}
|
|
68
72
|
},
|
|
69
73
|
"files": [
|
package/src/vue/index.ts
ADDED
package/src/vue/panel.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defineComponent, h, onMounted, onUnmounted, ref } from 'vue'
|
|
2
|
+
import type { DefineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
export interface DevtoolsPanelProps {
|
|
5
|
+
theme?: 'dark' | 'light' | 'system'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createVuePanel<
|
|
9
|
+
TComponentProps extends DevtoolsPanelProps,
|
|
10
|
+
TCoreDevtoolsClass extends {
|
|
11
|
+
mount: (el: HTMLElement, theme?: DevtoolsPanelProps['theme']) => void
|
|
12
|
+
unmount: () => void
|
|
13
|
+
},
|
|
14
|
+
>(CoreClass: new (props: TComponentProps) => TCoreDevtoolsClass) {
|
|
15
|
+
const props = {
|
|
16
|
+
theme: {
|
|
17
|
+
type: String as () => DevtoolsPanelProps['theme'],
|
|
18
|
+
},
|
|
19
|
+
devtoolsProps: {
|
|
20
|
+
type: Object as () => TComponentProps,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Panel = defineComponent({
|
|
25
|
+
props,
|
|
26
|
+
setup(config) {
|
|
27
|
+
const devToolRef = ref<HTMLElement | null>(null)
|
|
28
|
+
const devtools = ref<TCoreDevtoolsClass | null>(null)
|
|
29
|
+
|
|
30
|
+
onMounted(() => {
|
|
31
|
+
const instance = new CoreClass(config.devtoolsProps as TComponentProps)
|
|
32
|
+
devtools.value = instance
|
|
33
|
+
|
|
34
|
+
if (devToolRef.value) {
|
|
35
|
+
instance.mount(devToolRef.value, config.theme)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
onUnmounted(() => {
|
|
40
|
+
if (devToolRef.value && devtools.value) {
|
|
41
|
+
devtools.value.unmount()
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
return () => {
|
|
46
|
+
return h('div', {
|
|
47
|
+
style: { height: '100%' },
|
|
48
|
+
ref: devToolRef,
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const NoOpPanel = defineComponent({
|
|
55
|
+
props,
|
|
56
|
+
setup() {
|
|
57
|
+
return () => null
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
return [Panel, NoOpPanel] as unknown as [
|
|
62
|
+
DefineComponent<{
|
|
63
|
+
theme?: DevtoolsPanelProps['theme']
|
|
64
|
+
devtoolsProps: TComponentProps
|
|
65
|
+
}>,
|
|
66
|
+
DefineComponent<{
|
|
67
|
+
theme?: DevtoolsPanelProps['theme']
|
|
68
|
+
devtoolsProps: TComponentProps
|
|
69
|
+
}>,
|
|
70
|
+
]
|
|
71
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Fragment } from 'vue'
|
|
2
|
+
import type { DefineComponent } from 'vue'
|
|
3
|
+
|
|
4
|
+
export function createVuePlugin<TComponentProps extends Record<string, any>>(
|
|
5
|
+
name: string,
|
|
6
|
+
component: DefineComponent<TComponentProps, {}, unknown>,
|
|
7
|
+
) {
|
|
8
|
+
function Plugin(props: TComponentProps) {
|
|
9
|
+
return {
|
|
10
|
+
name,
|
|
11
|
+
component,
|
|
12
|
+
props,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function NoOpPlugin(props: TComponentProps) {
|
|
16
|
+
return {
|
|
17
|
+
name,
|
|
18
|
+
component: Fragment,
|
|
19
|
+
props,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return [Plugin, NoOpPlugin] as const
|
|
23
|
+
}
|