1- import { NO , isFunction , isObject } from '@vue/shared'
1+ import { NO , getGlobalThis , isFunction , isObject } from '@vue/shared'
22import {
33 type Component ,
44 type ComponentInternalInstance ,
@@ -16,7 +16,9 @@ import {
1616import type { InjectionKey } from './apiInject'
1717import type { RawProps } from './componentProps'
1818import { validateDirectiveName } from './directives'
19+ import { devtoolsInitApp , setDevtoolsHook } from './devtools'
1920
21+ let uid = 0
2022export function createVaporApp (
2123 rootComponent : Component ,
2224 rootProps : RawProps | null = null ,
@@ -27,14 +29,24 @@ export function createVaporApp(
2729 rootProps = null
2830 }
2931
32+ const target = getGlobalThis ( )
33+ target . __VUE__ = true
34+ if ( __DEV__ || __FEATURE_PROD_DEVTOOLS__ ) {
35+ setDevtoolsHook ( target . __VUE_DEVTOOLS_GLOBAL_HOOK__ , target )
36+ }
37+
3038 const context = createAppContext ( )
3139 const installedPlugins = new WeakSet ( )
3240
3341 let instance : ComponentInternalInstance
3442
35- const app : App = {
36- _context : context ,
43+ const app : App = ( context . app = {
44+ _uid : uid ++ ,
45+ _component : rootComponent ,
46+ _props : rootProps ,
3747 _container : null ,
48+ _context : context ,
49+ _instance : null ,
3850
3951 version,
4052
@@ -122,6 +134,11 @@ export function createVaporApp(
122134 // for devtools and telemetry
123135 ; ( rootContainer as any ) . __vue_app__ = app
124136
137+ if ( __DEV__ || __FEATURE_PROD_DEVTOOLS__ ) {
138+ app . _instance = instance
139+ devtoolsInitApp ( app , version )
140+ }
141+
125142 return instance
126143 } else if ( __DEV__ ) {
127144 warn (
@@ -161,14 +178,15 @@ export function createVaporApp(
161178 currentApp = lastApp
162179 }
163180 } ,
164- }
181+ } )
165182
166183 return app
167184}
168185
169186export function createAppContext ( ) : AppContext {
170187 return {
171188 app : null as any ,
189+ mixins : [ ] ,
172190 config : {
173191 isNativeTag : NO ,
174192 performance : false ,
@@ -219,8 +237,13 @@ export interface App {
219237 provide < T > ( key : string | InjectionKey < T > , value : T ) : App
220238 runWithContext < T > ( fn : ( ) => T ) : T
221239
222- _context : AppContext
240+ // internal, but we need to expose these for the server-renderer and devtools
241+ _uid : number
242+ _component : Component
243+ _props : RawProps | null
223244 _container : ParentNode | null
245+ _context : AppContext
246+ _instance : ComponentInternalInstance | null
224247}
225248
226249export interface AppConfig {
@@ -244,6 +267,7 @@ export interface AppConfig {
244267export interface AppContext {
245268 app : App // for devtools
246269 config : AppConfig
270+ mixins : never [ ] // for devtools, but no longer supported
247271 provides : Record < string | symbol , any >
248272
249273 /**
0 commit comments