Skip to content

Commit 57b913f

Browse files
committed
misc improvements + update docs extension
1 parent 3fead55 commit 57b913f

File tree

6 files changed

+28
-34
lines changed

6 files changed

+28
-34
lines changed

docs/source/_custom_js/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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

src/client/packages/app/index.html

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,14 @@
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>

src/client/packages/app/src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

src/client/packages/app/src/index.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/client/packages/client/src/reactpy-client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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++;

src/client/tsconfig.package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"allowJs": false,
44
"allowSyntheticDefaultImports": true,
55
"declaration": true,
6+
"declarationMap": true,
67
"esModuleInterop": false,
78
"forceConsistentCasingInFileNames": true,
89
"isolatedModules": true,

0 commit comments

Comments
 (0)