1
1
import type { ReactNode } from 'react' ;
2
- import { defineEntries } from 'waku/server' ;
3
- import { Slot } from 'waku/client' ;
2
+ import { new_defineEntries } from 'waku/minimal /server' ;
3
+ import { Slot } from 'waku/minimal/ client' ;
4
4
5
5
import App from './components/App' ;
6
6
import InnerApp from './components/InnerApp' ;
7
7
import AppWithoutSsr from './components/AppWithoutSsr' ;
8
8
9
- export default defineEntries (
10
- // renderEntries
11
- async ( rscPath ) => {
12
- const params = new URLSearchParams ( rscPath || 'App=Waku&InnerApp=0' ) ;
13
- const result : Record < string , ReactNode > = { } ;
14
- if ( params . has ( 'App' ) ) {
15
- result . App = < App name = { params . get ( 'App' ) ! } /> ;
9
+ export default new_defineEntries ( {
10
+ unstable_handleRequest : async ( input , { renderRsc, renderHtml } ) => {
11
+ if ( input . type === 'component' ) {
12
+ const params = new URLSearchParams (
13
+ input . rscPath || 'App=Waku&InnerApp=0' ,
14
+ ) ;
15
+ const result : Record < string , ReactNode > = { } ;
16
+ if ( params . has ( 'App' ) ) {
17
+ result . App = < App name = { params . get ( 'App' ) ! } /> ;
18
+ }
19
+ if ( params . has ( 'InnerApp' ) ) {
20
+ result . InnerApp = < InnerApp count = { Number ( params . get ( 'InnerApp' ) ) } /> ;
21
+ }
22
+ if ( params . has ( 'AppWithoutSsr' ) ) {
23
+ result . AppWithoutSsr = < AppWithoutSsr /> ;
24
+ }
25
+ return renderRsc ( result ) ;
16
26
}
17
- if ( params . has ( 'InnerApp' ) ) {
18
- result . InnerApp = < InnerApp count = { Number ( params . get ( 'InnerApp' ) ) } /> ;
27
+ if ( input . type === 'custom' && input . pathname === '/' ) {
28
+ return renderHtml (
29
+ { App : < App name = "Waku" /> , InnerApp : < InnerApp count = { 0 } /> } ,
30
+ < Slot id = "App" /> ,
31
+ '' ,
32
+ ) ;
19
33
}
20
- if ( params . has ( 'AppWithoutSsr' ) ) {
21
- result . AppWithoutSsr = < AppWithoutSsr /> ;
22
- }
23
- return result ;
24
34
} ,
25
- // getBuildConfig
26
- async ( ) => [
35
+ unstable_getBuildConfig : async ( ) => [
27
36
{
28
- pathname : '/' ,
37
+ pathSpec : [ ] ,
29
38
entries : [
30
39
{ rscPath : '' } ,
31
40
{ rscPath : 'InnerApp=1' , skipPrefetch : true } ,
@@ -36,23 +45,9 @@ export default defineEntries(
36
45
] ,
37
46
} ,
38
47
{
39
- pathname : ' /no-ssr',
48
+ pathSpec : [ { type : 'literal' , name : ' /no-ssr' } ] ,
40
49
entries : [ { rscPath : 'AppWithoutSsr' } ] ,
41
50
isStatic : true ,
42
51
} ,
43
52
] ,
44
- // getSsrConfig
45
- async ( pathname ) => {
46
- switch ( pathname ) {
47
- case '/' :
48
- return {
49
- rscPath : '' ,
50
- html : < Slot id = "App" /> ,
51
- } ;
52
- case '/no-ssr' :
53
- return null ;
54
- default :
55
- return null ;
56
- }
57
- } ,
58
- ) ;
53
+ } ) ;
0 commit comments