@@ -13,7 +13,7 @@ import { isFunction, NO, isObject } from '@vue/shared'
13
13
import { warn } from './warning'
14
14
import { createVNode , cloneVNode , VNode } from './vnode'
15
15
import { RootHydrateFunction } from './hydration'
16
- import { initApp , appUnmounted } from './devtools'
16
+ import { devtoolsInitApp , devtoolsUnmountApp } from './devtools'
17
17
import { version } from '.'
18
18
19
19
export interface App < HostElement = any > {
@@ -32,7 +32,7 @@ export interface App<HostElement = any> {
32
32
unmount ( rootContainer : HostElement | string ) : void
33
33
provide < T > ( key : InjectionKey < T > | string , value : T ) : this
34
34
35
- // internal. We need to expose these for the server-renderer and devtools
35
+ // internal, but we need to expose these for the server-renderer and devtools
36
36
_component : Component
37
37
_props : Data | null
38
38
_container : HostElement | null
@@ -50,7 +50,6 @@ export interface AppConfig {
50
50
// @private
51
51
readonly isNativeTag ?: ( tag : string ) => boolean
52
52
53
- devtools : boolean
54
53
performance : boolean
55
54
optionMergeStrategies : Record < string , OptionMergeFunction >
56
55
globalProperties : Record < string , any >
@@ -68,15 +67,13 @@ export interface AppConfig {
68
67
}
69
68
70
69
export interface AppContext {
70
+ app : App // for devtools
71
71
config : AppConfig
72
72
mixins : ComponentOptions [ ]
73
73
components : Record < string , PublicAPIComponent >
74
74
directives : Record < string , Directive >
75
75
provides : Record < string | symbol , any >
76
76
reload ?: ( ) => void // HMR only
77
-
78
- // internal for devtools
79
- __app ?: App
80
77
}
81
78
82
79
type PluginInstallFunction = ( app : App , ...options : any [ ] ) => any
@@ -89,9 +86,9 @@ export type Plugin =
89
86
90
87
export function createAppContext ( ) : AppContext {
91
88
return {
89
+ app : null as any ,
92
90
config : {
93
91
isNativeTag : NO ,
94
- devtools : true ,
95
92
performance : false ,
96
93
globalProperties : { } ,
97
94
optionMergeStrategies : { } ,
@@ -126,7 +123,7 @@ export function createAppAPI<HostElement>(
126
123
127
124
let isMounted = false
128
125
129
- const app : App = {
126
+ const app : App = ( context . app = {
130
127
_component : rootComponent as Component ,
131
128
_props : rootProps ,
132
129
_container : null ,
@@ -165,7 +162,7 @@ export function createAppAPI<HostElement>(
165
162
} ,
166
163
167
164
mixin ( mixin : ComponentOptions ) {
168
- if ( __FEATURE_OPTIONS__ ) {
165
+ if ( __FEATURE_OPTIONS_API__ ) {
169
166
if ( ! context . mixins . includes ( mixin ) ) {
170
167
context . mixins . push ( mixin )
171
168
} else if ( __DEV__ ) {
@@ -230,8 +227,12 @@ export function createAppAPI<HostElement>(
230
227
}
231
228
isMounted = true
232
229
app . _container = rootContainer
230
+ // for devtools and telemetry
231
+ ; ( rootContainer as any ) . __vue_app__ = app
233
232
234
- __DEV__ && initApp ( app , version )
233
+ if ( __DEV__ || __FEATURE_PROD_DEVTOOLS__ ) {
234
+ devtoolsInitApp ( app , version )
235
+ }
235
236
236
237
return vnode . component ! . proxy
237
238
} else if ( __DEV__ ) {
@@ -247,8 +248,7 @@ export function createAppAPI<HostElement>(
247
248
unmount ( ) {
248
249
if ( isMounted ) {
249
250
render ( null , app . _container )
250
-
251
- __DEV__ && appUnmounted ( app )
251
+ devtoolsUnmountApp ( app )
252
252
} else if ( __DEV__ ) {
253
253
warn ( `Cannot unmount an app that is not mounted.` )
254
254
}
@@ -267,9 +267,7 @@ export function createAppAPI<HostElement>(
267
267
268
268
return app
269
269
}
270
- }
271
-
272
- context . __app = app
270
+ } )
273
271
274
272
return app
275
273
}
0 commit comments