Skip to content

Commit b0e2ece

Browse files
committed
chore: add entry for settings and logs
1 parent c01768d commit b0e2ece

File tree

6 files changed

+94
-38
lines changed

6 files changed

+94
-38
lines changed

packages/core/playground/vite.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ export default defineConfig({
107107
})
108108

109109
ctx.docks.register({
110-
id: 'devtools-tab',
110+
id: 'shared-state',
111111
type: 'iframe',
112112
url: '/devtools/',
113-
title: 'DevTools',
114-
icon: 'ph:gear-duotone',
113+
title: 'Shared State',
114+
icon: 'ph:database-duotone',
115115
})
116116

117117
ctx.docks.register({
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script setup lang="ts">
2+
3+
</script>
4+
5+
<template>
6+
<div>
7+
Logs
8+
// TODO:
9+
</div>
10+
</template>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script setup lang="ts">
2+
3+
</script>
4+
5+
<template>
6+
<div>
7+
Settings
8+
// TODO:
9+
</div>
10+
</template>

packages/core/src/client/webcomponents/components/ViewEntry.vue

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import type { DevToolsDockEntry } from '@vitejs/devtools-kit'
33
import type { DocksContext } from '@vitejs/devtools-kit/client'
44
import type { CSSProperties } from 'vue'
55
import type { PersistedDomViewsManager } from '../utils/PersistedDomViewsManager'
6+
import { defineAsyncComponent } from 'vue'
67
import ViewBuiltinClientAuthNotice from './ViewBuiltinClientAuthNotice.vue'
7-
import ViewBuiltinTerminals from './ViewBuiltinTerminals.vue'
8+
import ViewBuiltinSettings from './ViewBuiltinSettings.vue'
89
import ViewCustomRenderer from './ViewCustomRenderer.vue'
910
import ViewIframe from './ViewIframe.vue'
1011
import ViewLauncher from './ViewLauncher.vue'
@@ -16,48 +17,70 @@ defineProps<{
1617
iframeStyle?: CSSProperties
1718
divStyle?: CSSProperties
1819
}>()
20+
21+
// Lazy load some less frequently used builtin views
22+
const ViewBuiltinTerminals = defineAsyncComponent(() => import('./ViewBuiltinTerminals.vue'))
23+
const ViewBuiltinLogs = defineAsyncComponent(() => import('./ViewBuiltinLogs.vue'))
1924
</script>
2025

2126
<template>
22-
<template v-if="entry.type === '~builtin'">
23-
<ViewBuiltinTerminals
24-
v-if="entry.id === '~terminals'"
27+
<Suspense>
28+
<template v-if="entry.type === '~builtin'">
29+
<ViewBuiltinTerminals
30+
v-if="entry.id === '~terminals'"
31+
:context
32+
:entry
33+
/>
34+
<ViewBuiltinLogs
35+
v-else-if="entry.id === '~logs'"
36+
:context
37+
:entry
38+
/>
39+
<ViewBuiltinSettings
40+
v-else-if="entry.id === '~settings'"
41+
:context
42+
:entry
43+
/>
44+
<ViewBuiltinClientAuthNotice
45+
v-else-if="entry.id === '~client-auth-notice'"
46+
:context
47+
/>
48+
<div v-else>
49+
Unknown builtin entry: {{ entry }}
50+
</div>
51+
</template>
52+
53+
<!-- Entry for Actions -->
54+
<template v-else-if="entry.type === 'action'" />
55+
56+
<!-- User-defined entries -->
57+
<ViewIframe
58+
v-else-if="entry.type === 'iframe'"
59+
:context
60+
:entry
61+
:persisted-doms="persistedDoms"
62+
:iframe-style="iframeStyle"
63+
/>
64+
<ViewCustomRenderer
65+
v-else-if="entry.type === 'custom-render'"
2566
:context
2667
:entry
68+
:persisted-doms="persistedDoms"
69+
:div-style="divStyle"
2770
/>
28-
<ViewBuiltinClientAuthNotice
29-
v-else-if="entry.id === '~client-auth-notice'"
71+
<ViewLauncher
72+
v-else-if="entry.type === 'launcher'"
3073
:context
74+
:entry
3175
/>
3276
<div v-else>
33-
Unknown builtin entry: {{ entry }}
77+
Unknown entry: {{ entry }}
3478
</div>
35-
</template>
36-
37-
<!-- Entry for Actions -->
38-
<template v-else-if="entry.type === 'action'" />
3979

40-
<!-- User-defined entries -->
41-
<ViewIframe
42-
v-else-if="entry.type === 'iframe'"
43-
:context
44-
:entry
45-
:persisted-doms="persistedDoms"
46-
:iframe-style="iframeStyle"
47-
/>
48-
<ViewCustomRenderer
49-
v-else-if="entry.type === 'custom-render'"
50-
:context
51-
:entry
52-
:persisted-doms="persistedDoms"
53-
:div-style="divStyle"
54-
/>
55-
<ViewLauncher
56-
v-else-if="entry.type === 'launcher'"
57-
:context
58-
:entry
59-
/>
60-
<div v-else>
61-
Unknown entry: {{ entry }}
62-
</div>
80+
<template #fallback>
81+
<div>
82+
Loading...
83+
</div>
84+
</template>
85+
</Suspense>
6386
</template>

packages/core/src/node/host-docks.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ export class DevToolsDockHost implements DevToolsDockHostType {
2626
return context.terminals.sessions.size === 0
2727
},
2828
},
29+
{
30+
type: '~builtin',
31+
id: '~logs',
32+
title: 'Logs',
33+
icon: 'ph:notification-duotone',
34+
isHidden: true, // TODO: implement logs
35+
},
36+
{
37+
type: '~builtin',
38+
id: '~settings',
39+
title: 'Settings',
40+
icon: 'ph:gear-duotone',
41+
},
2942
]
3043

3144
return [

packages/kit/src/types/docks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
9696

9797
export interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
9898
type: '~builtin'
99-
id: '~terminals' | '~logs' | '~client-auth-notice'
99+
id: '~terminals' | '~logs' | '~client-auth-notice' | '~settings'
100100
}
101101

102102
export type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher

0 commit comments

Comments
 (0)