Skip to content

Commit ba52195

Browse files
committed
Sync with reactpy core repo
1 parent 923e309 commit ba52195

File tree

11 files changed

+24
-17
lines changed

11 files changed

+24
-17
lines changed

.github/workflows/test-python.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ jobs:
7676
python-version: 3.x
7777
- name: Install Python Dependencies
7878
run: pip install --upgrade pip hatch uv
79-
- name: Check Python formatting
79+
- name: Run Python type checker
8080
run: hatch run python:type_check

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ReactPy-Django Build Artifacts
2-
src/reactpy_django/static/reactpy_django/client.js
2+
src/reactpy_django/static/reactpy_django/index.js
3+
src/reactpy_django/static/reactpy_django/index.js.map
34
src/reactpy_django/static/reactpy_django/pyscript
45
src/reactpy_django/static/reactpy_django/morphdom
56

docs/src/about/contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ By utilizing `hatch`, the following commands are available to manage the develop
5050

5151
The `hatch test` command is a wrapper for `pytest`. Hatch "intercepts" a handful of arguments, which can be previewed by typing `hatch test --help`.
5252

53-
Any additional arguments in the `test` command are directly passed on to pytest. See the [pytest documentation](https://docs.pytest.org/en/stable/reference/reference.html#command-line-flags) for what additional arguments are available.
53+
Any additional arguments in the `test` command are provided directly to pytest. See the [pytest documentation](https://docs.pytest.org/en/stable/reference/reference.html#command-line-flags) for what additional arguments are available.
5454

5555
### Linting and Formatting
5656

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ installer = "uv"
7575
[[tool.hatch.build.hooks.build-scripts.scripts]]
7676
commands = [
7777
"bun install --cwd src/js",
78-
"bun build src/js/src/index.ts --outfile src/reactpy_django/static/reactpy_django/client.js --minify",
78+
'bun build src/js/src/index.ts --outdir="src/reactpy_django/static/reactpy_django/" --minify --sourcemap=linked',
7979
'cd src/build_scripts && python copy_dir.py "src/js/node_modules/@pyscript/core/dist" "src/reactpy_django/static/reactpy_django/pyscript"',
8080
'cd src/build_scripts && python copy_dir.py "src/js/node_modules/morphdom/dist" "src/reactpy_django/static/reactpy_django/morphdom"',
8181
]

src/js/src/client.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ export class ReactPyDjangoClient
1919
constructor(props: ReactPyDjangoClientProps) {
2020
super();
2121
this.urls = props.urls;
22+
this.mountElement = props.mountElement;
23+
this.prerenderElement = props.prerenderElement;
24+
this.offlineElement = props.offlineElement;
2225
this.socket = createReconnectingWebSocket({
23-
readyPromise: this.ready,
2426
url: this.urls.componentUrl,
25-
onMessage: async ({ data }) => this.handleIncoming(JSON.parse(data)),
27+
readyPromise: this.ready,
2628
...props.reconnectOptions,
29+
onMessage: async ({ data }) => this.handleIncoming(JSON.parse(data)),
2730
onClose: () => {
2831
// If offlineElement exists, show it and hide the mountElement/prerenderElement
2932
if (this.prerenderElement) {
@@ -43,9 +46,6 @@ export class ReactPyDjangoClient
4346
}
4447
},
4548
});
46-
this.mountElement = props.mountElement;
47-
this.prerenderElement = props.prerenderElement;
48-
this.offlineElement = props.offlineElement;
4949
}
5050

5151
sendMessage(message: any): void {

src/js/src/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export type ReconnectOptions = {
77

88
export type ReactPyUrls = {
99
componentUrl: URL;
10-
query: string;
1110
jsModules: string;
1211
};
1312

src/reactpy_django/checks.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def reactpy_warnings(app_configs, **kwargs):
6262
)
6363
)
6464

65-
# Check if reactpy_django/client.js is available
66-
if not find("reactpy_django/client.js"):
65+
# Check if reactpy_django/index.js is available
66+
if not find("reactpy_django/index.js"):
6767
warnings.append(
6868
Warning(
69-
"ReactPy client.js could not be found within Django static files!",
69+
"ReactPy index.js could not be found within Django static files!",
7070
hint="Check all static files related Django settings and INSTALLED_APPS.",
7171
id="reactpy_django.W004",
7272
)

src/reactpy_django/forms/components.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from reactpy.core.types import VdomDict
2828

2929
DjangoForm = export(
30-
module_from_file("reactpy-django", file=Path(__file__).parent.parent / "static" / "reactpy_django" / "client.js"),
30+
module_from_file("reactpy-django", file=Path(__file__).parent.parent / "static" / "reactpy_django" / "index.js"),
3131
("DjangoForm"),
3232
)
3333

src/reactpy_django/javascript_components.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
from reactpy import web
66

77
HttpRequest = web.export(
8-
web.module_from_file("reactpy-django", file=Path(__file__).parent / "static" / "reactpy_django" / "client.js"),
8+
web.module_from_file("reactpy-django", file=Path(__file__).parent / "static" / "reactpy_django" / "index.js"),
99
("HttpRequest"),
1010
)

src/reactpy_django/templates/reactpy/component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{% if reactpy_prerender_html %}<div id="{{reactpy_uuid}}-prerender">{{reactpy_prerender_html|safe}}</div>{% endif %}
1111
{% if reactpy_offline_html %}<div id="{{reactpy_uuid}}-offline" hidden>{{reactpy_offline_html|safe}}</div>{% endif %}
1212
<script type="module" crossorigin="anonymous">
13-
import { mountComponent } from "{% static 'reactpy_django/client.js' %}";
13+
import { mountComponent } from "{% static 'reactpy_django/index.js' %}";
1414
const mountElement = document.getElementById("{{reactpy_uuid}}");
1515
mountComponent(
1616
mountElement,

tests/test_app/__init__.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
assert subprocess.run(["bun", "install"], cwd=str(js_dir), check=True).returncode == 0
99
assert (
1010
subprocess.run(
11-
["bun", "build", "./src/index.ts", "--outfile", str(static_dir / "client.js"), "--minify"],
11+
[
12+
"bun",
13+
"build",
14+
"./src/index.ts",
15+
f"--outdir={static_dir}",
16+
"--minify",
17+
"--sourcemap=linked",
18+
],
1219
cwd=str(js_dir),
1320
check=True,
1421
).returncode

0 commit comments

Comments
 (0)