1
+ import type { Component , Ref , ShallowRef } from "vue" ;
1
2
import {
2
- Component ,
3
3
computed ,
4
- createSSRApp as VueCreateSSRApp ,
4
+ createSSRApp as vueCreateSSRApp ,
5
5
defineComponent ,
6
6
h ,
7
7
onBeforeUnmount ,
8
- Ref ,
9
8
ref ,
10
- ShallowRef ,
11
9
shallowRef ,
12
10
watch ,
13
11
} from "vue" ;
14
- import { matchRoutes , Route , RouteMeta , RouteModule , Routes } from "../core/route.ts" ;
12
+ import type { Route , RouteMeta , RouteModule , RouteRecord } from "../core/route.ts" ;
13
+ import { matchRoutes } from "../core/route.ts" ;
15
14
import events from "../core/events.ts" ;
16
15
import FetchError from "../core/fetch_error.ts" ;
16
+ import { URLPatternCompat } from "../core/url_pattern.ts" ;
17
17
import type { SSRContext } from "../../server/renderer.ts" ;
18
18
import { RouterContext } from "./context.ts" ;
19
19
import { Link } from "./link.ts" ;
20
20
import { Head } from "./head.ts" ;
21
21
import { Err } from "./error.ts" ;
22
- import { URLPatternCompat } from "../core/url_pattern.ts" ;
23
22
24
23
// deno-lint-ignore no-explicit-any
25
24
const global = window as any ;
@@ -143,10 +142,10 @@ const createRouter = (props: RouterProps) => {
143
142
} ;
144
143
const dataUrl = rmod . url . pathname + rmod . url . search ;
145
144
if ( filename in routeModules ) {
146
- rmod . defaultExport = routeModules [ filename ] . defaultExport ;
145
+ Object . assign ( rmod , routeModules [ filename ] ) ;
147
146
} else {
148
- const { defaultExport } = await importModule ( meta ) ;
149
- rmod . defaultExport = defaultExport ;
147
+ const { defaultExport, withData } = await importModule ( meta ) ;
148
+ Object . assign ( rmod , { defaultExport, withData } ) ;
150
149
}
151
150
if ( ! dataCache . has ( dataUrl ) && routeModules [ filename ] ?. withData === true ) {
152
151
await prefetchData ( dataUrl ) ;
@@ -227,7 +226,7 @@ const createAppApi = (props?: RootProps) => {
227
226
const modules = shallowRef ( ssrContext ?. routeModules || loadSSRModulesFromTag ( ) ) ;
228
227
229
228
if ( modules . value . length === 0 ) {
230
- return VueCreateSSRApp ( Err , { status : 404 , message : "page not found" } ) ;
229
+ return vueCreateSSRApp ( Err , { status : 404 , message : "page not found" } ) ;
231
230
}
232
231
233
232
const url = ref ( ssrContext ?. url || new URL ( window . location ?. href ) ) ;
@@ -246,7 +245,7 @@ const createAppApi = (props?: RootProps) => {
246
245
} ,
247
246
} ) ;
248
247
249
- const app = VueCreateSSRApp ( App ) ;
248
+ const app = vueCreateSSRApp ( App ) ;
250
249
251
250
app . provide ( "modules" , modules ) ;
252
251
app . provide ( "dataCache" , dataCache ) ;
@@ -261,7 +260,7 @@ const createAppApi = (props?: RootProps) => {
261
260
return app ;
262
261
}
263
262
264
- const errApp = VueCreateSSRApp ( Err ) ;
263
+ const errApp = vueCreateSSRApp ( Err ) ;
265
264
266
265
return errApp ;
267
266
} ;
@@ -340,7 +339,7 @@ function getLoadingBar(): HTMLDivElement {
340
339
return bar ;
341
340
}
342
341
343
- function loadRoutesFromTag ( ) : Routes {
342
+ function loadRoutesFromTag ( ) : RouteRecord {
344
343
const el = window . document ?. getElementById ( "routes-manifest" ) ;
345
344
if ( el ) {
346
345
try {
0 commit comments