1
1
import App from './features/App.vue'
2
-
3
- import Vue from 'vue'
2
+ import { App as VueApp , createApp as createVueApp } from 'vue'
4
3
import { isChrome , initEnv , SharedData , initSharedData , destroySharedData , BridgeEvents } from '@vue-devtools/shared-utils'
5
- import { createRouter } from './router'
4
+ import { createRouterInstance } from './router'
6
5
import { getBridge , setBridge } from './features/bridge'
7
6
import { setAppConnected , setAppInitializing } from './features/connection'
8
7
import { setupAppsBridgeEvents } from './features/apps'
@@ -12,37 +11,25 @@ import { setupCustomInspectorBridgeEvents } from './features/inspector/custom/co
12
11
import { setupPluginsBridgeEvents } from './features/plugin'
13
12
import { setupPlugins } from './plugins'
14
13
15
- setupPlugins ( )
16
-
17
14
// Capture and log devtool errors when running as actual extension
18
15
// so that we can debug it by inspecting the background page.
19
16
// We do want the errors to be thrown in the dev shell though.
20
- if ( isChrome ) {
21
- Vue . config . errorHandler = ( e , vm ) => {
22
- getBridge ( ) ?. send ( 'ERROR' , {
23
- message : e . message ,
24
- stack : e . stack ,
25
- component : vm . $options . name || ( vm . $options as any ) . _componentTag || 'anonymous' ,
26
- } )
27
- }
28
- }
29
-
30
- // @ts -ignore
31
- Vue . options . renderError = ( h , e ) => {
32
- return h ( 'pre' , {
33
- class : 'text-white bg-red-500 p-2 rounded text-xs overflow-auto' ,
34
- } , e . stack )
35
- }
36
-
37
17
export function createApp ( ) {
38
- const router = createRouter ( )
39
-
40
- const app = new Vue ( {
41
- router,
42
- render : h => h ( App as any ) ,
43
- } )
44
-
45
- // @TODO [Vue 3] Setup plugins
18
+ const router = createRouterInstance ( )
19
+
20
+ const app = createVueApp ( App )
21
+ app . use ( router )
22
+ setupPlugins ( app )
23
+
24
+ if ( isChrome ) {
25
+ app . config . errorHandler = ( e , vm ) => {
26
+ getBridge ( ) ?. send ( 'ERROR' , {
27
+ message : ( e as Error ) . message ,
28
+ stack : ( e as Error ) . stack ,
29
+ component : vm ?. $options . name || ( vm ?. $options as any ) . _componentTag || 'anonymous' ,
30
+ } )
31
+ }
32
+ }
46
33
47
34
return app
48
35
}
@@ -51,22 +38,22 @@ export function createApp () {
51
38
* Connect then init the app. We need to reconnect on every reload, because a
52
39
* new backend will be injected.
53
40
*/
54
- export function connectApp ( app , shell ) {
41
+ export function connectApp ( app : VueApp , shell ) {
55
42
shell . connect ( async bridge => {
56
43
setBridge ( bridge )
57
44
// @TODO remove
58
45
// @ts -ignore
59
46
window . bridge = bridge
60
47
61
- if ( Object . prototype . hasOwnProperty . call ( Vue . prototype , ' $shared' ) ) {
48
+ if ( app . config . globalProperties . $shared ) {
62
49
destroySharedData ( )
63
50
} else {
64
- Object . defineProperty ( Vue . prototype , '$shared' , {
51
+ Object . defineProperty ( app . config . globalProperties , '$shared' , {
65
52
get : ( ) => SharedData ,
66
53
} )
67
54
}
68
55
69
- initEnv ( Vue )
56
+ initEnv ( app )
70
57
71
58
bridge . on ( BridgeEvents . TO_FRONT_TITLE , ( { title } : { title : string } ) => {
72
59
document . title = `${ title } - Vue devtools`
@@ -75,7 +62,6 @@ export function connectApp (app, shell) {
75
62
await initSharedData ( {
76
63
bridge,
77
64
persist : true ,
78
- Vue,
79
65
} )
80
66
81
67
if ( SharedData . logDetected ) {
0 commit comments