File tree 6 files changed +28
-34
lines changed
docs/source/_custom_js/src 6 files changed +28
-34
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ export function mountWidgetExample(
16
16
reactpyPort = window . location . port ;
17
17
}
18
18
19
- const client = SimpleReactPyServer ( {
19
+ const client = new SimpleReactPyClient ( {
20
20
serverLocation : {
21
21
url : `${ window . location . protocol } //${ reactpyHost } :${ reactpyPort } ` ,
22
- route : "" ,
23
- query : `view_id=${ viewID } ` ,
22
+ route : "/ " ,
23
+ query : `? view_id=${ viewID } ` ,
24
24
} ,
25
25
} ) ;
26
26
Original file line number Diff line number Diff line change 2
2
< html lang ="en ">
3
3
< head >
4
4
< meta charset ="utf-8 " />
5
+ < script type ="module ">
6
+ import { app } from "./src/index" ;
7
+ app ( document . getElementById ( "app" ) ) ;
8
+ </ script >
5
9
<!-- we replace this with user-provided head elements -->
6
10
{__head__}
7
11
</ head >
8
12
< body >
9
13
< div id ="app "> </ div >
10
- < script type ="module ">
11
- import { mount } from "@reactpy/client" ;
12
- mount (
13
- document . getElementById ( "app" ) ,
14
- new SimpleReactPyClient ( {
15
- serverLocation : {
16
- url : document . location . origin ,
17
- route : document . location . pathname ,
18
- query : document . location . search ,
19
- } ,
20
- } ) ,
21
- ) ;
22
- </ script >
23
14
</ body >
24
15
</ html >
Original file line number Diff line number Diff line change
1
+ import { mount , SimpleReactPyClient } from "@reactpy/client" ;
2
+
3
+ export function app ( element : HTMLElement ) {
4
+ mount (
5
+ element ,
6
+ new SimpleReactPyClient ( {
7
+ serverLocation : {
8
+ url : document . location . host ,
9
+ route : document . location . pathname ,
10
+ query : document . location . search ,
11
+ } ,
12
+ } ) ,
13
+ ) ;
14
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -70,12 +70,12 @@ export class SimpleReactPyClient implements ReactPyClient {
70
70
}
71
71
72
72
start ( ) : void {
73
- logger . log ( "Starting ReactPy client..." ) ;
73
+ logger . log ( "Starting client..." ) ;
74
74
this . resolveShouldOpen ( undefined ) ;
75
75
}
76
76
77
77
stop ( ) : void {
78
- logger . log ( "Stopping ReactPy client..." ) ;
78
+ logger . log ( "stopping client..." ) ;
79
79
this . resolveShouldClose ( undefined ) ;
80
80
}
81
81
@@ -173,15 +173,17 @@ function startReconnectingWebSocket(
173
173
return ;
174
174
}
175
175
176
- logger . log ( "disconnected" ) ;
176
+ logger . log ( "client disconnected" ) ;
177
177
props . onClose ( ) ;
178
178
179
179
if ( retries >= maxRetries ) {
180
180
return ;
181
181
}
182
182
183
183
const thisInterval = addJitter ( interval , intervalJitter ) ;
184
- logger . log ( `reconnecting in ${ thisInterval / 1000 } seconds...` ) ;
184
+ logger . log (
185
+ `reconnecting in ${ ( thisInterval / 1000 ) . toPrecision ( 4 ) } seconds...` ,
186
+ ) ;
185
187
setTimeout ( connect , thisInterval ) ;
186
188
interval = nextInterval ( interval , backoffRate , maxInterval ) ;
187
189
retries ++ ;
Original file line number Diff line number Diff line change 3
3
"allowJs" : false ,
4
4
"allowSyntheticDefaultImports" : true ,
5
5
"declaration" : true ,
6
+ "declarationMap" : true ,
6
7
"esModuleInterop" : false ,
7
8
"forceConsistentCasingInFileNames" : true ,
8
9
"isolatedModules" : true ,
You can’t perform that action at this time.
0 commit comments