diff --git a/docs/source/about/changelog.rst b/docs/source/about/changelog.rst index c3a612811..9f833d28f 100644 --- a/docs/source/about/changelog.rst +++ b/docs/source/about/changelog.rst @@ -18,8 +18,8 @@ Unreleased **Added** - :pull:`1113` - Added ``reactpy.ReactPy`` that can be used to run ReactPy in standalone mode. - :pull:`1113` - Added ``reactpy.ReactPyMiddleware`` that can be used to run ReactPy with any ASGI compatible framework. -- :pull:`1113` - Added ``reactpy.ReactPyMiddleware`` that can be used to run ReactPy with any ASGI compatible framework. -- :pull:`1113` - Added ``uvicorn`` and ``jinja`` installation extras (for example ``pip install reactpy[uvicorn,jinja]``). +- :pull:`1113` - Added ``reactpy.jinja.Component`` that can be used alongside ``ReactPyMiddleware`` to embed several ReactPy components into your existing application. +- :pull:`1113` - Added ``standard``, ``uvicorn``, ``jinja`` installation extras (for example ``pip install reactpy[standard]``). - :pull:`1113` - Added support for Python 3.12 and 3.13. **Changed** diff --git a/docs/source/guides/escape-hatches/distributing-javascript.rst b/docs/source/guides/escape-hatches/distributing-javascript.rst index 9eb478965..5333742ce 100644 --- a/docs/source/guides/escape-hatches/distributing-javascript.rst +++ b/docs/source/guides/escape-hatches/distributing-javascript.rst @@ -188,7 +188,7 @@ loaded with :func:`~reactpy.web.module.export`. .. note:: - When :data:`reactpy.config.REACTPY_DEBUG_MODE` is active, named exports will be validated. + When :data:`reactpy.config.REACTPY_DEBUG` is active, named exports will be validated. The remaining files that we need to create are concerned with creating a Python package. We won't cover all the details here, so refer to the Setuptools_ documentation for diff --git a/docs/source/guides/getting-started/running-reactpy.rst b/docs/source/guides/getting-started/running-reactpy.rst index 8abbd574f..90a03cbc3 100644 --- a/docs/source/guides/getting-started/running-reactpy.rst +++ b/docs/source/guides/getting-started/running-reactpy.rst @@ -103,7 +103,7 @@ Running ReactPy in Debug Mode ----------------------------- ReactPy provides a debug mode that is turned off by default. This can be enabled when you -run your application by setting the ``REACTPY_DEBUG_MODE`` environment variable. +run your application by setting the ``REACTPY_DEBUG`` environment variable. .. tab-set:: @@ -111,21 +111,21 @@ run your application by setting the ``REACTPY_DEBUG_MODE`` environment variable. .. code-block:: - export REACTPY_DEBUG_MODE=1 + export REACTPY_DEBUG=1 python my_reactpy_app.py .. tab-item:: Command Prompt .. code-block:: text - set REACTPY_DEBUG_MODE=1 + set REACTPY_DEBUG=1 python my_reactpy_app.py .. tab-item:: PowerShell .. code-block:: powershell - $env:REACTPY_DEBUG_MODE = "1" + $env:REACTPY_DEBUG = "1" python my_reactpy_app.py .. danger:: diff --git a/pyproject.toml b/pyproject.toml index e060c046e..92430e71b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,7 @@ artifacts = [] [project.optional-dependencies] all = ["reactpy[jinja,uvicorn,testing]"] +standard = ["reactpy[jinja,uvicorn]"] jinja = ["jinja2-simple-tags", "jinja2 >=3"] uvicorn = ["uvicorn[standard]"] testing = ["playwright"] diff --git a/src/js/packages/@reactpy/client/src/index.ts b/src/js/packages/@reactpy/client/src/index.ts index 9ab33297c..15192823d 100644 --- a/src/js/packages/@reactpy/client/src/index.ts +++ b/src/js/packages/@reactpy/client/src/index.ts @@ -4,3 +4,5 @@ export * from "./mount"; export * from "./types"; export * from "./vdom"; export * from "./websocket"; +export { default as React } from "preact/compat"; +export { default as ReactDOM } from "preact/compat"; diff --git a/src/reactpy/jinja.py b/src/reactpy/jinja.py index 257d9065a..77d1570f1 100644 --- a/src/reactpy/jinja.py +++ b/src/reactpy/jinja.py @@ -6,7 +6,7 @@ from reactpy.utils import render_mount_template -class ReactPyTemplateTag(StandaloneTag): # type: ignore +class Component(StandaloneTag): # type: ignore """This allows enables a `component` tag to be used in any Jinja2 rendering context, as long as this template tag is registered as a Jinja2 extension.""" diff --git a/tests/test_asgi/test_middleware.py b/tests/test_asgi/test_middleware.py index ccb3a4a9e..84dc545b8 100644 --- a/tests/test_asgi/test_middleware.py +++ b/tests/test_asgi/test_middleware.py @@ -1,6 +1,5 @@ # ruff: noqa: S701 import asyncio -import os from pathlib import Path import pytest @@ -20,7 +19,7 @@ async def display(page): templates = Jinja2Templates( env=JinjaEnvironment( loader=JinjaFileSystemLoader("tests/templates"), - extensions=["reactpy.jinja.ReactPyTemplateTag"], + extensions=["reactpy.jinja.Component"], ) ) @@ -60,7 +59,7 @@ async def test_unregistered_root_component(): templates = Jinja2Templates( env=JinjaEnvironment( loader=JinjaFileSystemLoader("tests/templates"), - extensions=["reactpy.jinja.ReactPyTemplateTag"], + extensions=["reactpy.jinja.Component"], ) )