File tree Expand file tree Collapse file tree 6 files changed +28
-34
lines changed
docs/source/_custom_js/src Expand file tree Collapse file tree 6 files changed +28
-34
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ export function mountWidgetExample(
1616 reactpyPort = window . location . port ;
1717 }
1818
19- const client = SimpleReactPyServer ( {
19+ const client = new SimpleReactPyClient ( {
2020 serverLocation : {
2121 url : `${ window . location . protocol } //${ reactpyHost } :${ reactpyPort } ` ,
22- route : "" ,
23- query : `view_id=${ viewID } ` ,
22+ route : "/ " ,
23+ query : `? view_id=${ viewID } ` ,
2424 } ,
2525 } ) ;
2626
Original file line number Diff line number Diff line change 22< html lang ="en ">
33 < head >
44 < meta charset ="utf-8 " />
5+ < script type ="module ">
6+ import { app } from "./src/index" ;
7+ app ( document . getElementById ( "app" ) ) ;
8+ </ script >
59 <!-- we replace this with user-provided head elements -->
610 {__head__}
711 </ head >
812 < body >
913 < 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 >
2314 </ body >
2415</ 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 {
7070 }
7171
7272 start ( ) : void {
73- logger . log ( "Starting ReactPy client..." ) ;
73+ logger . log ( "Starting client..." ) ;
7474 this . resolveShouldOpen ( undefined ) ;
7575 }
7676
7777 stop ( ) : void {
78- logger . log ( "Stopping ReactPy client..." ) ;
78+ logger . log ( "stopping client..." ) ;
7979 this . resolveShouldClose ( undefined ) ;
8080 }
8181
@@ -173,15 +173,17 @@ function startReconnectingWebSocket(
173173 return ;
174174 }
175175
176- logger . log ( "disconnected" ) ;
176+ logger . log ( "client disconnected" ) ;
177177 props . onClose ( ) ;
178178
179179 if ( retries >= maxRetries ) {
180180 return ;
181181 }
182182
183183 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+ ) ;
185187 setTimeout ( connect , thisInterval ) ;
186188 interval = nextInterval ( interval , backoffRate , maxInterval ) ;
187189 retries ++ ;
Original file line number Diff line number Diff line change 33 "allowJs" : false ,
44 "allowSyntheticDefaultImports" : true ,
55 "declaration" : true ,
6+ "declarationMap" : true ,
67 "esModuleInterop" : false ,
78 "forceConsistentCasingInFileNames" : true ,
89 "isolatedModules" : true ,
You can’t perform that action at this time.
0 commit comments