@@ -13,7 +13,7 @@ import { isFunction, NO, isObject } from '@vue/shared'
1313import { warn } from './warning'
1414import { createVNode , cloneVNode , VNode } from './vnode'
1515import { RootHydrateFunction } from './hydration'
16- import { initApp , appUnmounted } from './devtools'
16+ import { devtoolsInitApp , devtoolsUnmountApp } from './devtools'
1717import { version } from '.'
1818
1919export interface App < HostElement = any > {
@@ -32,7 +32,7 @@ export interface App<HostElement = any> {
3232 unmount ( rootContainer : HostElement | string ) : void
3333 provide < T > ( key : InjectionKey < T > | string , value : T ) : this
3434
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
3636 _component : Component
3737 _props : Data | null
3838 _container : HostElement | null
@@ -50,7 +50,6 @@ export interface AppConfig {
5050 // @private
5151 readonly isNativeTag ?: ( tag : string ) => boolean
5252
53- devtools : boolean
5453 performance : boolean
5554 optionMergeStrategies : Record < string , OptionMergeFunction >
5655 globalProperties : Record < string , any >
@@ -68,15 +67,13 @@ export interface AppConfig {
6867}
6968
7069export interface AppContext {
70+ app : App // for devtools
7171 config : AppConfig
7272 mixins : ComponentOptions [ ]
7373 components : Record < string , PublicAPIComponent >
7474 directives : Record < string , Directive >
7575 provides : Record < string | symbol , any >
7676 reload ?: ( ) => void // HMR only
77-
78- // internal for devtools
79- __app ?: App
8077}
8178
8279type PluginInstallFunction = ( app : App , ...options : any [ ] ) => any
@@ -89,9 +86,9 @@ export type Plugin =
8986
9087export function createAppContext ( ) : AppContext {
9188 return {
89+ app : null as any ,
9290 config : {
9391 isNativeTag : NO ,
94- devtools : true ,
9592 performance : false ,
9693 globalProperties : { } ,
9794 optionMergeStrategies : { } ,
@@ -126,7 +123,7 @@ export function createAppAPI<HostElement>(
126123
127124 let isMounted = false
128125
129- const app : App = {
126+ const app : App = ( context . app = {
130127 _component : rootComponent as Component ,
131128 _props : rootProps ,
132129 _container : null ,
@@ -165,7 +162,7 @@ export function createAppAPI<HostElement>(
165162 } ,
166163
167164 mixin ( mixin : ComponentOptions ) {
168- if ( __FEATURE_OPTIONS__ ) {
165+ if ( __FEATURE_OPTIONS_API__ ) {
169166 if ( ! context . mixins . includes ( mixin ) ) {
170167 context . mixins . push ( mixin )
171168 } else if ( __DEV__ ) {
@@ -230,8 +227,12 @@ export function createAppAPI<HostElement>(
230227 }
231228 isMounted = true
232229 app . _container = rootContainer
230+ // for devtools and telemetry
231+ ; ( rootContainer as any ) . __vue_app__ = app
233232
234- __DEV__ && initApp ( app , version )
233+ if ( __DEV__ || __FEATURE_PROD_DEVTOOLS__ ) {
234+ devtoolsInitApp ( app , version )
235+ }
235236
236237 return vnode . component ! . proxy
237238 } else if ( __DEV__ ) {
@@ -247,8 +248,7 @@ export function createAppAPI<HostElement>(
247248 unmount ( ) {
248249 if ( isMounted ) {
249250 render ( null , app . _container )
250-
251- __DEV__ && appUnmounted ( app )
251+ devtoolsUnmountApp ( app )
252252 } else if ( __DEV__ ) {
253253 warn ( `Cannot unmount an app that is not mounted.` )
254254 }
@@ -267,9 +267,7 @@ export function createAppAPI<HostElement>(
267267
268268 return app
269269 }
270- }
271-
272- context . __app = app
270+ } )
273271
274272 return app
275273 }
0 commit comments