1
- import { NO , isFunction , isObject } from '@vue/shared'
1
+ import { NO , getGlobalThis , isFunction , isObject } from '@vue/shared'
2
2
import {
3
3
type Component ,
4
4
type ComponentInternalInstance ,
@@ -16,7 +16,9 @@ import {
16
16
import type { InjectionKey } from './apiInject'
17
17
import type { RawProps } from './componentProps'
18
18
import { validateDirectiveName } from './directives'
19
+ import { devtoolsInitApp , setDevtoolsHook } from './devtools'
19
20
21
+ let uid = 0
20
22
export function createVaporApp (
21
23
rootComponent : Component ,
22
24
rootProps : RawProps | null = null ,
@@ -27,14 +29,24 @@ export function createVaporApp(
27
29
rootProps = null
28
30
}
29
31
32
+ const target = getGlobalThis ( )
33
+ target . __VUE__ = true
34
+ if ( __DEV__ || __FEATURE_PROD_DEVTOOLS__ ) {
35
+ setDevtoolsHook ( target . __VUE_DEVTOOLS_GLOBAL_HOOK__ , target )
36
+ }
37
+
30
38
const context = createAppContext ( )
31
39
const installedPlugins = new WeakSet ( )
32
40
33
41
let instance : ComponentInternalInstance
34
42
35
- const app : App = {
36
- _context : context ,
43
+ const app : App = ( context . app = {
44
+ _uid : uid ++ ,
45
+ _component : rootComponent ,
46
+ _props : rootProps ,
37
47
_container : null ,
48
+ _context : context ,
49
+ _instance : null ,
38
50
39
51
version,
40
52
@@ -122,6 +134,11 @@ export function createVaporApp(
122
134
// for devtools and telemetry
123
135
; ( rootContainer as any ) . __vue_app__ = app
124
136
137
+ if ( __DEV__ || __FEATURE_PROD_DEVTOOLS__ ) {
138
+ app . _instance = instance
139
+ devtoolsInitApp ( app , version )
140
+ }
141
+
125
142
return instance
126
143
} else if ( __DEV__ ) {
127
144
warn (
@@ -161,14 +178,15 @@ export function createVaporApp(
161
178
currentApp = lastApp
162
179
}
163
180
} ,
164
- }
181
+ } )
165
182
166
183
return app
167
184
}
168
185
169
186
export function createAppContext ( ) : AppContext {
170
187
return {
171
188
app : null as any ,
189
+ mixins : [ ] ,
172
190
config : {
173
191
isNativeTag : NO ,
174
192
performance : false ,
@@ -219,8 +237,13 @@ export interface App {
219
237
provide < T > ( key : string | InjectionKey < T > , value : T ) : App
220
238
runWithContext < T > ( fn : ( ) => T ) : T
221
239
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
223
244
_container : ParentNode | null
245
+ _context : AppContext
246
+ _instance : ComponentInternalInstance | null
224
247
}
225
248
226
249
export interface AppConfig {
@@ -244,6 +267,7 @@ export interface AppConfig {
244
267
export interface AppContext {
245
268
app : App // for devtools
246
269
config : AppConfig
270
+ mixins : never [ ] // for devtools, but no longer supported
247
271
provides : Record < string | symbol , any >
248
272
249
273
/**
0 commit comments