File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { renderToStream , type RenderToStreamOptions } from '@builder.io/qwik/server' ;
2
2
import Root from './root' ;
3
3
4
+ // You can pass these as query parameters, as well as `preloadDebug`
5
+ const preloaderSettings = [
6
+ 'maxPreloads' ,
7
+ 'minProbability' ,
8
+ 'maxSimultaneousPreloads' ,
9
+ 'minPreloadProbability' ,
10
+ ] as const ;
11
+
4
12
export default function ( opts : RenderToStreamOptions ) {
13
+ const { serverData } = opts ;
14
+ const urlStr = serverData ?. url ;
15
+ if ( urlStr ) {
16
+ const { searchParams } = new URL ( urlStr ) ;
17
+ if ( searchParams . size ) {
18
+ opts = {
19
+ ...opts ,
20
+ prefetchStrategy : {
21
+ ...opts . prefetchStrategy ,
22
+ implementation : { ...opts . prefetchStrategy ?. implementation } ,
23
+ } ,
24
+ } ;
25
+ if ( searchParams . has ( 'preloadDebug' ) ) {
26
+ opts . prefetchStrategy ! . implementation ! . debug = true ;
27
+ }
28
+ for ( const type of preloaderSettings ) {
29
+ if ( searchParams . has ( type ) ) {
30
+ opts . prefetchStrategy ! . implementation ! [ type ] = Number ( searchParams . get ( type ) ) ;
31
+ }
32
+ }
33
+ }
34
+ }
5
35
return renderToStream ( < Root /> , {
6
36
qwikLoader : {
7
37
// The docs can be long so make sure to intercept events before the end of the document.
You can’t perform that action at this time.
0 commit comments