This repository was archived by the owner on Jul 19, 2025. It is now read-only.
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(
1818 rootProps = null
1919 }
2020
21+ const context = createAppContext ( )
2122 let instance : ComponentInternalInstance
2223
2324 const app : App = {
2425 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+
2539 mount ( rootContainer ) : any {
2640 if ( ! instance ) {
2741 instance = createComponentInstance ( rootComponent , rootProps )
@@ -49,11 +63,41 @@ export function createVaporApp(
4963 return app
5064}
5165
66+ function createAppContext ( ) : AppContext {
67+ return {
68+ app : null as any ,
69+ config : {
70+ errorHandler : undefined ,
71+ warnHandler : undefined ,
72+ } ,
73+ }
74+ }
75+
5276export interface App {
5377 version : string
78+ config : AppConfig
79+
5480 mount (
5581 rootContainer : ParentNode | string ,
5682 isHydrate ?: boolean ,
5783 ) : ComponentInternalInstance
5884 unmount ( ) : void
5985}
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 {
100100 onErrorCaptured ,
101101 // onServerPrefetch,
102102} 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'
104109export { createIf } from './apiCreateIf'
105110export { createFor } from './apiCreateFor'
106111export { createComponent } from './apiCreateComponent'
You can’t perform that action at this time.
0 commit comments