File tree Expand file tree Collapse file tree 17 files changed +217
-88
lines changed Expand file tree Collapse file tree 17 files changed +217
-88
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,27 @@ export default defineConfig({
9494 action : ctx . utils . createSimpleClientScript ( ( ) => { } ) ,
9595 } )
9696
97+ ctx . docks . register ( {
98+ id : 'launcher' ,
99+ type : 'launcher' ,
100+ icon : 'ph:rocket-launch-duotone' ,
101+ title : 'Launcher' ,
102+ launcher : {
103+ title : 'Launcher My Cool App' ,
104+ onLaunch : async ( ) => {
105+ await new Promise ( resolve => setTimeout ( resolve , 1000 ) )
106+
107+ ctx . docks . update ( {
108+ id : 'launcher' ,
109+ icon : 'ph:rocket-launch-fill' ,
110+ type : 'iframe' ,
111+ title : 'My Cool App is Ready' ,
112+ url : 'https://antfu.me' ,
113+ } )
114+ } ,
115+ } ,
116+ } )
117+
97118 let count = 1
98119 // eslint-disable-next-line unimport/auto-insert
99120 setInterval ( ( ) => {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const context: DocksContext = await createDocksContext(
2323 rpcReturn ,
2424)
2525
26- context .docks .selected || = context .docks .entries [0 ] || null
26+ context .docks .selectedId || = context .docks .entries [0 ]?. id ?? null
2727
2828const { selectDockEntry } = useStateHandlers (context )
2929 </script >
@@ -43,7 +43,7 @@ const { selectDockEntry } = useStateHandlers(context)
4343 />
4444 </div >
4545 <div >
46- <div id =" vite-devtools-views-container" ref =" viewsContainer" />
46+ <div id =" vite-devtools-views-container" ref =" viewsContainer" class = " pointer-events-auto " />
4747 <ViewEntry
4848 v-if =" context.docks.selected && viewsContainer"
4949 :key =" context.docks.selected.id"
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -245,6 +245,12 @@ onMounted(() => {
245245 id =" vite-devtools-glowing"
246246 :class =" context.panel.isDragging ? 'op60!' : ''"
247247 />
248+ <slot
249+ :context =" context"
250+ :dock-el =" dockEl"
251+ :selected =" context.docks.selected"
252+ :panel-margins =" panelMargins"
253+ />
248254 <div
249255 id =" vite-devtools-dock-container"
250256 ref =" dockEl"
@@ -275,11 +281,5 @@ onMounted(() => {
275281 />
276282 </div >
277283 </div >
278- <slot
279- :context =" context"
280- :dock-el =" dockEl"
281- :selected =" context.docks.selected"
282- :panel-margins =" panelMargins"
283- />
284284 </div >
285285</template >
Original file line number Diff line number Diff line change @@ -102,7 +102,6 @@ const panelStyle = computed(() => {
102102
103103 const style: CSSProperties = {
104104 position: ' fixed' ,
105- zIndex: - 1 ,
106105 pointerEvents: (panel .isDragging || panel .isResizing ) ? ' none' : ' auto' ,
107106 width: ` min(${store .width }vw, calc(100vw - ${marginHorizontal }px)) ` ,
108107 height: ` min(${store .height }vh, calc(100vh - ${marginVertical }px)) ` ,
@@ -178,12 +177,11 @@ onMounted(() => {
178177 border: '1px solid #8883',
179178 borderRadius: '0.5rem',
180179 }"
181- rounded
182180 />
183181 <div
184182 id =" vite-devtools-views-container"
185183 ref =" viewsContainer"
186- class =" absolute inset-0"
184+ class =" absolute inset-0 pointer-events-none "
187185 />
188186 </div >
189187</template >
Original file line number Diff line number Diff line change 8282 <div
8383 id =" vite-devtools-resize-container"
8484 ref =" container"
85- class =" w-full h-full absolute left-0 right-0 bottom-0 top-0 antialiased"
85+ class =" w-full h-full absolute left-0 right-0 bottom-0 top-0 antialiased pointer-events-auto "
8686 >
8787 <!-- Handlers -->
8888 <div
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import type { CSSProperties } from 'vue'
55import type { PresistedDomViewsManager } from ' ../utils/PresistedDomViewsManager'
66import ViewCustomRenderer from ' ./ViewCustomRenderer.vue'
77import ViewIframe from ' ./ViewIframe.vue'
8+ import ViewLauncher from ' ./ViewLauncher.vue'
89
910defineProps <{
1011 context: DocksContext
@@ -31,6 +32,11 @@ defineProps<{
3132 :presisted-doms =" presistedDoms"
3233 :div-style =" divStyle"
3334 />
35+ <ViewLauncher
36+ v-else-if =" entry.type === 'launcher'"
37+ :context
38+ :entry
39+ />
3440 <div v-else >
3541 Unknown entry: {{ entry }}
3642 </div >
Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ import type { DevToolsViewLauncher } from ' @vitejs/devtools-kit'
3+ import type { DocksContext } from ' @vitejs/devtools-kit/client'
4+ import DockIcon from ' ./DockIcon.vue'
5+
6+ const props = defineProps <{
7+ context: DocksContext
8+ entry: DevToolsViewLauncher
9+ }>()
10+
11+ function onLaunch() {
12+ props .context .rpc .$call (' vite:core:on-dock-launch' , props .entry .id )
13+ }
14+ </script >
15+
16+ <template >
17+ <div class =" flex flex-col gap-4 items-center justify-center h-full relative" >
18+ <DockIcon :icon =" entry.icon" class =" w-10 h-10" />
19+ <h1 class =" text-2xl font-bold" >
20+ {{ entry.launcher.title }}
21+ </h1 >
22+ <p >{{ entry.launcher.description }}</p >
23+ <button class =" bg-lime6 px4 py1 rounded hover:bg-lime7 transition-all duration-300" @click =" onLaunch" >
24+ Launch
25+ </button >
26+ <p >{{ entry.launcher.status }}</p >
27+ </div >
28+ </template >
Original file line number Diff line number Diff line change @@ -82,8 +82,9 @@ export async function createDocksContext(
8282 return _docksContext
8383 }
8484
85- const selected = ref < DevToolsDockEntry | null > ( null )
85+ const selectedId = ref < string | null > ( null )
8686 const dockEntries = await useDocksEntries ( rpcReturn )
87+ const selected = computed ( ( ) => dockEntries . value . find ( entry => entry . id === selectedId . value ) ?? null )
8788
8889 const dockEntryStateMap : Map < string , DockEntryState > = reactive ( new Map ( ) )
8990 watchEffect ( ( ) => {
@@ -109,19 +110,20 @@ export async function createDocksContext(
109110 isVertical : computed ( ( ) => panelStore . value . position === 'left' || panelStore . value . position === 'right' ) ,
110111 } ,
111112 docks : {
113+ selectedId,
112114 selected,
113115 entries : dockEntries ,
114116 entryToStateMap : markRaw ( dockEntryStateMap ) ,
115117 getStateById : ( id : string ) => dockEntryStateMap . get ( id ) ,
116118 switchEntry : async ( id : string | null ) => {
117119 if ( id === null ) {
118- selected . value = null
120+ selectedId . value = null
119121 return true
120122 }
121123 const entry = dockEntries . value . find ( e => e . id === id )
122124 if ( ! entry )
123125 return false
124- selected . value = entry
126+ selectedId . value = entry . id
125127 // TODO: run action
126128 return true
127129 } ,
Original file line number Diff line number Diff line change @@ -39,10 +39,10 @@ export function useStateHandlers(
3939 async function selectDockEntry ( entry ?: DevToolsDockEntry ) {
4040 if ( ! entry ) {
4141 context . panel . store . open = false
42- context . docks . selected = null
42+ context . docks . selectedId = null
4343 return
4444 }
45- if ( context . docks . selected ?. id === entry . id ) {
45+ if ( context . docks . selectedId === entry . id ) {
4646 return
4747 }
4848
@@ -62,7 +62,7 @@ export function useStateHandlers(
6262 await setupScript ( entry , scriptContext )
6363 }
6464
65- context . docks . selected = entry
65+ context . docks . selectedId = entry . id
6666 context . panel . store . open = true
6767 }
6868
You can’t perform that action at this time.
0 commit comments