-
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathApp.vue
More file actions
81 lines (73 loc) · 2.7 KB
/
App.vue
File metadata and controls
81 lines (73 loc) · 2.7 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
<script setup lang="ts">
import type { DocksContext } from '@vitejs/devtools-kit/client'
import { getDevToolsRpcClient } from '@vitejs/devtools-kit/client'
import { markRaw, ref, useTemplateRef, watch } from 'vue'
import DockEntriesWithCategories from '../webcomponents/components/DockEntriesWithCategories.vue'
import FloatingElements from '../webcomponents/components/FloatingElements.vue'
import VitePlus from '../webcomponents/components/icons/VitePlus.vue'
import ViewBuiltinClientAuthNotice from '../webcomponents/components/ViewBuiltinClientAuthNotice.vue'
import ViewEntry from '../webcomponents/components/ViewEntry.vue'
import { createDocksContext } from '../webcomponents/state/context'
import { PersistedDomViewsManager } from '../webcomponents/utils/PersistedDomViewsManager'
const rpc = await getDevToolsRpcClient()
// eslint-disable-next-line no-console
console.log('[VITE DEVTOOLS] RPC', rpc)
const viewsContainer = useTemplateRef<HTMLElement>('viewsContainer')
const persistedDoms = markRaw(new PersistedDomViewsManager(viewsContainer))
const context: DocksContext = await createDocksContext(
'standalone',
rpc,
)
const isRpcTrusted = ref(context.rpc.isTrusted)
context.rpc.events.on('rpc:is-trusted:updated', (isTrusted) => {
isRpcTrusted.value = isTrusted
})
watch(
() => context.docks.entries,
() => {
context.docks.selectedId ||= context.docks.entries[0]?.id ?? null
},
{ immediate: true },
)
function switchEntry(id: string) {
if (id) {
context.docks.switchEntry(id)
}
}
</script>
<template>
<div v-if="!isRpcTrusted" class="h-screen w-screen of-hidden">
<ViewBuiltinClientAuthNotice :context="context" />
</div>
<div v-else class="h-screen w-screen of-hidden grid cols-[max-content_1fr]">
<div class="border-r border-base flex flex-col">
<div class="p2 border-b border-base flex">
<VitePlus class="w-7 h-7 ma" />
</div>
<div class="transition duration-200 p2">
<DockEntriesWithCategories
:context="context"
:groups="context.docks.groupedEntries"
:is-vertical="false"
:selected="context.docks.selected"
@select="(e) => switchEntry(e?.id)"
>
<template #separator>
<div class="border-base border-b w-full my-2" />
</template>
</DockEntriesWithCategories>
</div>
</div>
<div>
<div id="vite-devtools-views-container" ref="viewsContainer" class="pointer-events-auto" />
<ViewEntry
v-if="context.docks.selected && viewsContainer"
:key="context.docks.selected.id"
:entry="context.docks.selected"
:context
:persisted-doms="persistedDoms"
/>
</div>
</div>
<FloatingElements />
</template>