Skip to content

Commit 5891b41

Browse files
authored
Bump ReactPy to v1.1.0 (#258)
1 parent 95f8abf commit 5891b41

File tree

16 files changed

+46
-41
lines changed

16 files changed

+46
-41
lines changed

.github/workflows/publish-release-docs.yml renamed to .github/workflows/publish-latest-docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Release Docs
1+
name: Publish Latest Docs
22

33
on:
44
release:

CHANGELOG.md

+8-19
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010

1111
<!--
1212
Using the following categories, list your changes in this order:
13-
14-
### Added
15-
- for new features.
16-
17-
### Changed
18-
- for changes in existing functionality.
19-
20-
### Deprecated
21-
- for soon-to-be removed features.
22-
23-
### Removed
24-
- for removed features.
25-
26-
### Fixed
27-
- for bug fixes.
28-
29-
### Security
30-
- for vulnerability fixes.
13+
[Added, Changed, Deprecated, Removed, Fixed, Security]
3114
3215
Don't forget to remove deprecated code on each major release!
3316
-->
@@ -36,7 +19,13 @@ Don't forget to remove deprecated code on each major release!
3619

3720
## [Unreleased]
3821

39-
- Nothing (yet)!
22+
### Added
23+
24+
- `settings.py:REACTPY_ASYNC_RENDERING` to enable asynchronous rendering of components.
25+
26+
### Changed
27+
28+
- Bumped the minimum ReactPy version to `1.1.0`.
4029

4130
## [5.0.0] - 2024-10-22
4231

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
- [Customizable reconnection behavior](https://reactive-python.github.io/reactpy-django/latest/reference/settings/#stability-settings)
2929
- [Customizable disconnection behavior](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag)
3030
- [Multiple root components](https://reactive-python.github.io/reactpy-django/latest/reference/template-tag/)
31-
- [Cross-process communication/signaling (Channel Layers)](https://reactive-python.github.io/reactpy-django/latest/reference/hooks/#use-channel-layer)
31+
- [Cross-process communication/signaling](https://reactive-python.github.io/reactpy-django/latest/reference/hooks/#use-channel-layer)
3232
- [Django view to ReactPy component conversion](https://reactive-python.github.io/reactpy-django/latest/reference/components/#view-to-component)
3333
- [Django static file access](https://reactive-python.github.io/reactpy-django/latest/reference/components/#django-css)
3434
- [Django database access](https://reactive-python.github.io/reactpy-django/latest/reference/hooks/#use-query)

docs/src/reference/components.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
160160

161161
- Requires manual intervention to change HTTP methods to anything other than `GET`.
162162
- ReactPy events cannot conveniently be attached to converted view HTML.
163-
- Has no option to automatically intercept local anchor link (such as `#!html <a href='example/'></a>`) click events.
163+
- Has no option to automatically intercept click events from hyperlinks (such as `#!html <a href='example/'></a>`).
164164

165165
??? question "How do I use this for Class Based Views?"
166166

docs/src/reference/router.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ URL router that enables the ability to conditionally render other components bas
5050
| --- | --- |
5151
| `#!python VdomDict | None` | The matched component/path after it has been fully rendered. |
5252

53-
??? question "How is this different from `#!python reactpy_router.simple.router`?"
53+
??? question "How is this different from `#!python reactpy_router.browser_router`?"
5454

55-
This component utilizes `reactpy-router` under the hood, but provides a more Django-like URL routing syntax.
55+
The `django_router` component utilizes the same internals as `browser_router`, but provides a more Django-like URL routing syntax.

docs/src/reference/settings.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ This is useful to continuously update `#!python last_login` timestamps and refre
8787

8888
Multiprocessing-safe database used by ReactPy for database-backed hooks and features.
8989

90-
If configuring this value, it is mandatory to enable our database router like such:
90+
If configuring this value, it is mandatory to configure Django to use the ReactPy database router:
9191

9292
=== "settings.py"
9393

@@ -123,6 +123,18 @@ This setting is incompatible with [`daphne`](https://github.com/django/daphne).
123123

124124
---
125125

126+
### `#!python REACTPY_ASYNC_RENDERING`
127+
128+
**Default:** `#!python False`
129+
130+
**Example Value(s):** `#!python True`
131+
132+
Configures whether to use an async ReactPy rendering queue. When enabled, large renders will no longer block smaller renders from taking place. Additionally, prevents the rendering queue from being blocked on waiting for async effects to startup/shutdown (which is typically a relatively slow operation).
133+
134+
This setting is currently experimental, and currently no effort is made to de-duplicate renders. For example, if parent and child components are scheduled to render at the same time, both renders will take place even though a single render of the parent component would have been sufficient.
135+
136+
---
137+
126138
### `#!python REACTPY_DEFAULT_HOSTS`
127139

128140
**Default:** `#!python None`

requirements/pkg-deps.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
channels >=4.0.0
22
django >=4.2.0
3-
reactpy >=1.0.2, <1.1.0
3+
reactpy >=1.1.0, <1.2.0
44
reactpy-router >=1.0.0, <2.0.0
55
dill >=0.3.5
66
orjson >=3.6.0

setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from setuptools.command.develop import develop
1212
from setuptools.command.sdist import sdist
1313

14-
log = getLogger(__name__)
15-
1614
# -----------------------------------------------------------------------------
1715
# Basic Constants
1816
# -----------------------------------------------------------------------------
@@ -22,6 +20,7 @@
2220
js_dir = src_dir / "js"
2321
package_dir = src_dir / name
2422
static_dir = package_dir / "static" / name
23+
log = getLogger(__name__)
2524

2625

2726
# -----------------------------------------------------------------------------
@@ -60,7 +59,10 @@
6059
"Intended Audience :: Developers",
6160
"Intended Audience :: Science/Research",
6261
"Topic :: Multimedia :: Graphics",
62+
"Topic :: Software Development :: Widget Sets",
63+
"Topic :: Software Development :: User Interfaces",
6364
"Environment :: Web Environment",
65+
"Typing :: Typed",
6466
],
6567
}
6668

src/js/bun.lockb

1.06 KB
Binary file not shown.

src/js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"prettier": "^3.3.3"
1313
},
1414
"dependencies": {
15-
"@pyscript/core": "^0.5",
15+
"@pyscript/core": "^0.6",
1616
"@reactpy/client": "^0.3.1",
1717
"morphdom": "^2.7.4"
1818
}

src/reactpy_django/config.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from django.core.cache import DEFAULT_CACHE_ALIAS
88
from django.db import DEFAULT_DB_ALIAS
99
from django.views import View
10+
from reactpy.config import REACTPY_ASYNC_RENDERING as _REACTPY_ASYNC_RENDERING
1011
from reactpy.config import REACTPY_DEBUG_MODE as _REACTPY_DEBUG_MODE
1112
from reactpy.core.types import ComponentConstructor
1213

@@ -17,13 +18,16 @@
1718
from reactpy_django.utils import import_dotted_path
1819

1920
# Non-configurable values
20-
_REACTPY_DEBUG_MODE.set_current(getattr(settings, "DEBUG"))
2121
REACTPY_DEBUG_MODE = _REACTPY_DEBUG_MODE.current
2222
REACTPY_REGISTERED_COMPONENTS: dict[str, ComponentConstructor] = {}
2323
REACTPY_FAILED_COMPONENTS: set[str] = set()
2424
REACTPY_REGISTERED_IFRAME_VIEWS: dict[str, Callable | View] = {}
2525

2626
# Configurable through Django settings.py
27+
_REACTPY_DEBUG_MODE.set_current(getattr(settings, "DEBUG"))
28+
_REACTPY_ASYNC_RENDERING.set_current(
29+
getattr(settings, "REACTPY_ASYNC_RENDERING", _REACTPY_ASYNC_RENDERING.current)
30+
)
2731
REACTPY_URL_PREFIX: str = getattr(
2832
settings,
2933
"REACTPY_URL_PREFIX",

src/reactpy_django/decorators.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from django.contrib.auth.models import AbstractUser
1414

1515

16-
17-
1816
def user_passes_test(
1917
test_func: Callable[[AbstractUser], bool],
2018
/,
@@ -59,7 +57,5 @@ def _user_passes_test(component_constructor, fallback, test_func, *args, **kwarg
5957
# Render the component.
6058
return user_component
6159

62-
# Render the fallback component.
63-
# Returns an empty string if fallback is None, since ReactPy currently renders None as a string.
64-
# TODO: Remove this fallback when ReactPy can render None properly.
65-
return fallback(*args, **kwargs) if callable(fallback) else (fallback or "")
60+
# Render the fallback content.
61+
return fallback(*args, **kwargs) if callable(fallback) else (fallback or None)

src/reactpy_django/hooks.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ async def execute_query() -> None:
150150
try:
151151
# Run the query
152152
if asyncio.iscoroutinefunction(query):
153-
new_data = await query(**kwargs)
153+
new_data = await query(**kwargs) # type: ignore[call-arg]
154154
else:
155155
new_data = await database_sync_to_async(
156156
query, thread_sensitive=thread_sensitive
@@ -219,7 +219,7 @@ def use_mutation(
219219
) -> Mutation[FuncParams]:
220220
"""This hook is used to modify data in the background, typically to create/update/delete \
221221
data from the Django ORM.
222-
222+
223223
Mutation functions can `return False` to prevent executing your `refetch` function. All \
224224
other returns are ignored. Mutation functions can be sync or async.
225225
@@ -318,7 +318,7 @@ def use_user_data(
318318
save_default_data: bool = False,
319319
) -> UserData:
320320
"""Get or set user data stored within the REACTPY_DATABASE.
321-
321+
322322
Kwargs:
323323
default_data: A dictionary containing `{key: default_value}` pairs. \
324324
For computationally intensive defaults, your `default_value` \

src/reactpy_django/http/views.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ async def web_modules_file(request: HttpRequest, file: str) -> HttpResponse:
3737
await caches[REACTPY_CACHE].aset(
3838
cache_key, file_contents, timeout=604800, version=int(last_modified_time)
3939
)
40+
41+
# TODO: Convert this to a StreamingHttpResponse
4042
return HttpResponse(file_contents, content_type="text/javascript")
4143

4244

src/reactpy_django/pyscript/layout_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def delete_old_workspaces():
107107
if value.startswith("user_workspace_")
108108
}
109109

110-
# Delete the workspace if it exists at the moment when we check
110+
# Delete any workspaces that are not being used
111111
for uuid in python_uuids - dom_uuids:
112112
task_name = f"task_{uuid}"
113113
if task_name in globals():

src/reactpy_django/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def generate_obj_name(obj: Any) -> str:
263263
"""Makes a best effort to create a name for an object.
264264
Useful for JSON serialization of Python objects."""
265265

266-
# First attempt: Dunder methods
266+
# First attempt: Create a dotted path by inspecting dunder methods
267267
if hasattr(obj, "__module__"):
268268
if hasattr(obj, "__name__"):
269269
return f"{obj.__module__}.{obj.__name__}"

0 commit comments

Comments
 (0)