File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
packages/runtime-vapor/src Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,24 @@ export function createVaporApp(
18
18
rootProps = null
19
19
}
20
20
21
+ const context = createAppContext ( )
21
22
let instance : ComponentInternalInstance
22
23
23
24
const app : App = {
24
25
version,
26
+
27
+ get config ( ) {
28
+ return context . config
29
+ } ,
30
+
31
+ set config ( v ) {
32
+ if ( __DEV__ ) {
33
+ warn (
34
+ `app.config cannot be replaced. Modify individual options instead.` ,
35
+ )
36
+ }
37
+ } ,
38
+
25
39
mount ( rootContainer ) : any {
26
40
if ( ! instance ) {
27
41
instance = createComponentInstance ( rootComponent , rootProps )
@@ -49,11 +63,41 @@ export function createVaporApp(
49
63
return app
50
64
}
51
65
66
+ function createAppContext ( ) : AppContext {
67
+ return {
68
+ app : null as any ,
69
+ config : {
70
+ errorHandler : undefined ,
71
+ warnHandler : undefined ,
72
+ } ,
73
+ }
74
+ }
75
+
52
76
export interface App {
53
77
version : string
78
+ config : AppConfig
79
+
54
80
mount (
55
81
rootContainer : ParentNode | string ,
56
82
isHydrate ?: boolean ,
57
83
) : ComponentInternalInstance
58
84
unmount ( ) : void
59
85
}
86
+
87
+ export interface AppConfig {
88
+ errorHandler ?: (
89
+ err : unknown ,
90
+ instance : ComponentInternalInstance | null ,
91
+ info : string ,
92
+ ) => void
93
+ warnHandler ?: (
94
+ msg : string ,
95
+ instance : ComponentInternalInstance | null ,
96
+ trace : string ,
97
+ ) => void
98
+ }
99
+
100
+ export interface AppContext {
101
+ app : App // for devtools
102
+ config : AppConfig
103
+ }
Original file line number Diff line number Diff line change @@ -100,7 +100,12 @@ export {
100
100
onErrorCaptured ,
101
101
// onServerPrefetch,
102
102
} from './apiLifecycle'
103
- export { createVaporApp , type App } from './apiCreateApp'
103
+ export {
104
+ createVaporApp ,
105
+ type App ,
106
+ type AppConfig ,
107
+ type AppContext ,
108
+ } from './apiCreateVaporApp'
104
109
export { createIf } from './apiCreateIf'
105
110
export { createFor } from './apiCreateFor'
106
111
export { createComponent } from './apiCreateComponent'
You can’t perform that action at this time.
0 commit comments