Skip to content

Commit 60a21f9

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/src/js/vite-3.2.10
2 parents dc66dd1 + 0e4432f commit 60a21f9

File tree

20 files changed

+132
-117
lines changed

20 files changed

+132
-117
lines changed

.github/workflows/.hatch-run.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ jobs:
3838
runs-on: ${{ fromJson(inputs.runs-on-array) }}
3939
runs-on: ${{ matrix.runs-on }}
4040
steps:
41-
- uses: actions/checkout@v2
42-
- uses: actions/setup-node@v2
41+
- uses: actions/checkout@v4
42+
- uses: actions/setup-node@v4
4343
with:
44-
node-version: "14.x"
44+
node-version: "23.x"
4545
registry-url: ${{ inputs.node-registry-url }}
4646
- name: Pin NPM Version
4747
run: npm install -g [email protected]
4848
- name: Use Python ${{ matrix.python-version }}
49-
uses: actions/setup-python@v2
49+
uses: actions/setup-python@v5
5050
with:
5151
python-version: ${{ matrix.python-version }}
5252
- name: Install Python Dependencies

.github/workflows/deploy-docs.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
name: deploy-docs
55

66
on:
7-
push:
8-
branches:
9-
- "main"
10-
tags:
11-
- "*"
7+
push:
8+
branches:
9+
- "main"
10+
tags:
11+
- "*"
1212

1313
jobs:
14-
deploy-documentation:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: Check out src from Git
18-
uses: actions/checkout@v2
19-
- name: Get history and tags for SCM versioning to work
20-
run: |
21-
git fetch --prune --unshallow
22-
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
23-
- name: Login to Heroku Container Registry
24-
run: echo ${{ secrets.HEROKU_API_KEY }} | docker login -u ${{ secrets.HEROKU_EMAIL }} --password-stdin registry.heroku.com
25-
- name: Build Docker Image
26-
run: docker build . --file docs/Dockerfile --tag registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
27-
- name: Push Docker Image
28-
run: docker push registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
29-
- name: Deploy
30-
run: HEROKU_API_KEY=${{ secrets.HEROKU_API_KEY }} heroku container:release web --app ${{ secrets.HEROKU_APP_NAME }}
14+
deploy-documentation:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out src from Git
18+
uses: actions/checkout@v4
19+
- name: Get history and tags for SCM versioning to work
20+
run: |
21+
git fetch --prune --unshallow
22+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
23+
- name: Login to Heroku Container Registry
24+
run: echo ${{ secrets.HEROKU_API_KEY }} | docker login -u ${{ secrets.HEROKU_EMAIL }} --password-stdin registry.heroku.com
25+
- name: Build Docker Image
26+
run: docker build . --file docs/Dockerfile --tag registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
27+
- name: Push Docker Image
28+
run: docker push registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
29+
- name: Deploy
30+
run: HEROKU_API_KEY=${{ secrets.HEROKU_API_KEY }} heroku container:release web --app ${{ secrets.HEROKU_APP_NAME }}

.github/workflows/publish.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
name: publish
55

66
on:
7-
release:
8-
types: [published]
7+
release:
8+
types: [published]
99

1010
jobs:
11-
publish:
12-
uses: ./.github/workflows/.hatch-run.yml
13-
with:
14-
job-name: "publish"
15-
hatch-run: "publish"
16-
node-registry-url: "https://registry.npmjs.org"
17-
secrets:
18-
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
19-
pypi-username: ${{ secrets.PYPI_USERNAME }}
20-
pypi-password: ${{ secrets.PYPI_PASSWORD }}
11+
publish:
12+
uses: ./.github/workflows/.hatch-run.yml
13+
with:
14+
job-name: "publish"
15+
hatch-run: "publish"
16+
node-registry-url: "https://registry.npmjs.org"
17+
secrets:
18+
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
19+
pypi-username: ${{ secrets.PYPI_USERNAME }}
20+
pypi-password: ${{ secrets.PYPI_PASSWORD }}

docs/source/about/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Unreleased
2323
- :pull:`1118` - `module_from_template` is broken with a recent release of `requests`
2424
- :pull:`1131` - `module_from_template` did not work when using Flask backend
2525
- :pull:`1200` - Fixed `UnicodeDecodeError` when using `reactpy.web.export`
26+
- :pull:`1224` - Fixes needless unmounting of JavaScript components during each ReactPy render.
2627

2728
**Added**
2829

@@ -40,12 +41,15 @@ Unreleased
4041
fragment to conditionally render an element by writing
4142
``something if condition else html._()``. Now you can simply write
4243
``something if condition else None``.
44+
- :pull:`1210` - Move hooks from ``reactpy.backend.hooks`` into ``reactpy.core.hooks``.
4345

4446
**Deprecated**
4547

4648
- :pull:`1171` - The ``Stop`` exception. Recent releases of ``anyio`` have made this
4749
exception difficult to use since it now raises an ``ExceptionGroup``. This exception
4850
was primarily used for internal testing purposes and so is now deprecated.
51+
- :pull:`1210` - Deprecate ``reactpy.backend.hooks`` since the hooks have been moved into
52+
``reactpy.core.hooks``.
4953

5054

5155
v1.0.2

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ detached = true
1212
dependencies = [
1313
"invoke",
1414
# lint
15-
"black==24.1.1", # Pin lint tools we don't control to avoid breaking changes
16-
"ruff==0.0.278", # Pin lint tools we don't control to avoid breaking changes
15+
"black==24.1.1", # Pin lint tools we don't control to avoid breaking changes
16+
"ruff==0.0.278", # Pin lint tools we don't control to avoid breaking changes
1717
"toml",
18-
"flake8==7.0.0", # Pin lint tools we don't control to avoid breaking changes
18+
"flake8==7.0.0", # Pin lint tools we don't control to avoid breaking changes
1919
"flake8-pyproject",
20-
"reactpy-flake8 >=0.7",
2120
# types
2221
"mypy",
2322
"types-toml",

src/js/packages/@reactpy/client/src/components.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function useForceUpdate() {
177177

178178
function useImportSource(model: ReactPyVdom): MutableRefObject<any> {
179179
const vdomImportSource = model.importSource;
180-
180+
const vdomImportSourceJsonString = JSON.stringify(vdomImportSource);
181181
const mountPoint = useRef<HTMLElement>(null);
182182
const client = React.useContext(ClientContext);
183183
const [binding, setBinding] = useState<ImportSourceBinding | null>(null);
@@ -203,7 +203,7 @@ function useImportSource(model: ReactPyVdom): MutableRefObject<any> {
203203
binding.unmount();
204204
}
205205
};
206-
}, [client, vdomImportSource, setBinding, mountPoint.current]);
206+
}, [client, vdomImportSourceJsonString, setBinding, mountPoint.current]);
207207

208208
// this effect must run every time in case the model has changed
209209
useEffect(() => {

src/py/reactpy/pyproject.toml

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ readme = "README.md"
1212
requires-python = ">=3.9"
1313
license = "MIT"
1414
keywords = ["react", "javascript", "reactpy", "component"]
15-
authors = [
16-
{ name = "Ryan Morshead", email = "[email protected]" },
17-
]
15+
authors = [{ name = "Ryan Morshead", email = "[email protected]" }]
1816
classifiers = [
1917
"Development Status :: 4 - Beta",
2018
"Programming Language :: Python",
@@ -39,33 +37,18 @@ dependencies = [
3937
[project.optional-dependencies]
4038
all = ["reactpy[starlette,sanic,fastapi,flask,tornado,testing]"]
4139

42-
starlette = [
43-
"starlette >=0.13.6",
44-
"uvicorn[standard] >=0.19.0",
45-
]
40+
starlette = ["starlette >=0.13.6", "uvicorn[standard] >=0.19.0"]
4641
sanic = [
4742
"sanic >=21",
4843
"sanic-cors",
4944
"tracerite>=1.1.1",
5045
"setuptools",
5146
"uvicorn[standard] >=0.19.0",
5247
]
53-
fastapi = [
54-
"fastapi >=0.63.0",
55-
"uvicorn[standard] >=0.19.0",
56-
]
57-
flask = [
58-
"flask",
59-
"markupsafe>=1.1.1,<2.1",
60-
"flask-cors",
61-
"flask-sock",
62-
]
63-
tornado = [
64-
"tornado",
65-
]
66-
testing = [
67-
"playwright",
68-
]
48+
fastapi = ["fastapi >=0.63.0", "uvicorn[standard] >=0.19.0"]
49+
flask = ["flask", "markupsafe>=1.1.1,<2.1", "flask-cors", "flask-sock"]
50+
tornado = ["tornado"]
51+
testing = ["playwright"]
6952

7053
[project.urls]
7154
Source = "https://github.com/reactive-python/reactpy"
@@ -101,21 +84,17 @@ cov-report = [
10184
# "- coverage combine",
10285
"coverage report",
10386
]
104-
cov = [
105-
"test-cov {args}",
106-
"cov-report",
107-
]
87+
cov = ["test-cov {args}", "cov-report"]
10888

10989
[tool.hatch.envs.default.env-vars]
110-
REACTPY_DEBUG_MODE="1"
90+
REACTPY_DEBUG_MODE = "1"
11191

11292
[tool.hatch.envs.lint]
11393
features = ["all"]
11494
dependencies = [
115-
"mypy>=1.0.0",
95+
"mypy==1.8",
11696
"types-click",
11797
"types-tornado",
118-
"types-pkg-resources",
11998
"types-flask",
12099
"types-requests",
121100
]
@@ -127,13 +106,8 @@ all = ["types"]
127106
[[tool.hatch.build.hooks.build-scripts.scripts]]
128107
work_dir = "../../js"
129108
out_dir = "reactpy/_static"
130-
commands = [
131-
"npm ci",
132-
"npm run build"
133-
]
134-
artifacts = [
135-
"app/dist/"
136-
]
109+
commands = ["npm ci", "npm run build"]
110+
artifacts = ["app/dist/"]
137111

138112
# --- Pytest ---------------------------------------------------------------------------
139113

@@ -159,9 +133,7 @@ warn_unused_ignores = true
159133
source_pkgs = ["reactpy"]
160134
branch = false
161135
parallel = false
162-
omit = [
163-
"reactpy/__init__.py",
164-
]
136+
omit = ["reactpy/__init__.py"]
165137

166138
[tool.coverage.report]
167139
fail_under = 100
@@ -174,6 +146,4 @@ exclude_lines = [
174146
"if __name__ == .__main__.:",
175147
"if TYPE_CHECKING:",
176148
]
177-
omit = [
178-
"reactpy/__main__.py",
179-
]
149+
omit = ["reactpy/__main__.py"]

src/py/reactpy/reactpy/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
from reactpy import backend, config, html, logging, sample, svg, types, web, widgets
2-
from reactpy.backend.hooks import use_connection, use_location, use_scope
32
from reactpy.backend.utils import run
43
from reactpy.core import hooks
54
from reactpy.core.component import component
65
from reactpy.core.events import event
76
from reactpy.core.hooks import (
87
create_context,
98
use_callback,
9+
use_connection,
1010
use_context,
1111
use_debug_value,
1212
use_effect,
13+
use_location,
1314
use_memo,
1415
use_reducer,
1516
use_ref,
17+
use_scope,
1618
use_state,
1719
)
1820
from reactpy.core.layout import Layout

src/py/reactpy/reactpy/backend/flask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
safe_client_build_dir_path,
3636
safe_web_modules_dir_path,
3737
)
38-
from reactpy.backend.hooks import ConnectionContext
39-
from reactpy.backend.hooks import use_connection as _use_connection
4038
from reactpy.backend.types import Connection, Location
39+
from reactpy.core.hooks import ConnectionContext
40+
from reactpy.core.hooks import use_connection as _use_connection
4141
from reactpy.core.serve import serve_layout
4242
from reactpy.core.types import ComponentType, RootComponentConstructor
4343
from reactpy.utils import Ref
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
1-
from __future__ import annotations
1+
from __future__ import annotations # nocov
22

3-
from collections.abc import MutableMapping
4-
from typing import Any
3+
from collections.abc import MutableMapping # nocov
4+
from typing import Any # nocov
55

6-
from reactpy.backend.types import Connection, Location
7-
from reactpy.core.hooks import create_context, use_context
8-
from reactpy.core.types import Context
6+
from reactpy._warnings import warn # nocov
7+
from reactpy.backend.types import Connection, Location # nocov
8+
from reactpy.core.hooks import ConnectionContext, use_context # nocov
99

10-
# backend implementations should establish this context at the root of an app
11-
ConnectionContext: Context[Connection[Any] | None] = create_context(None)
1210

13-
14-
def use_connection() -> Connection[Any]:
11+
def use_connection() -> Connection[Any]: # nocov
1512
"""Get the current :class:`~reactpy.backend.types.Connection`."""
13+
warn(
14+
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ",
15+
"Call reactpy.use_connection instead.",
16+
DeprecationWarning,
17+
)
18+
1619
conn = use_context(ConnectionContext)
17-
if conn is None: # nocov
20+
if conn is None:
1821
msg = "No backend established a connection."
1922
raise RuntimeError(msg)
2023
return conn
2124

2225

23-
def use_scope() -> MutableMapping[str, Any]:
26+
def use_scope() -> MutableMapping[str, Any]: # nocov
2427
"""Get the current :class:`~reactpy.backend.types.Connection`'s scope."""
28+
warn(
29+
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ",
30+
"Call reactpy.use_scope instead.",
31+
DeprecationWarning,
32+
)
33+
2534
return use_connection().scope
2635

2736

28-
def use_location() -> Location:
37+
def use_location() -> Location: # nocov
2938
"""Get the current :class:`~reactpy.backend.types.Connection`'s location."""
39+
warn(
40+
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ",
41+
"Call reactpy.use_location instead.",
42+
DeprecationWarning,
43+
)
44+
3045
return use_connection().location

src/py/reactpy/reactpy/backend/sanic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
safe_web_modules_dir_path,
2525
serve_with_uvicorn,
2626
)
27-
from reactpy.backend.hooks import ConnectionContext
28-
from reactpy.backend.hooks import use_connection as _use_connection
2927
from reactpy.backend.types import Connection, Location
28+
from reactpy.core.hooks import ConnectionContext
29+
from reactpy.core.hooks import use_connection as _use_connection
3030
from reactpy.core.layout import Layout
3131
from reactpy.core.serve import RecvCoroutine, SendCoroutine, Stop, serve_layout
3232
from reactpy.core.types import RootComponentConstructor

src/py/reactpy/reactpy/backend/starlette.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
read_client_index_html,
2525
serve_with_uvicorn,
2626
)
27-
from reactpy.backend.hooks import ConnectionContext
28-
from reactpy.backend.hooks import use_connection as _use_connection
2927
from reactpy.backend.types import Connection, Location
3028
from reactpy.config import REACTPY_WEB_MODULES_DIR
29+
from reactpy.core.hooks import ConnectionContext
30+
from reactpy.core.hooks import use_connection as _use_connection
3131
from reactpy.core.layout import Layout
3232
from reactpy.core.serve import RecvCoroutine, SendCoroutine, serve_layout
3333
from reactpy.core.types import RootComponentConstructor

src/py/reactpy/reactpy/backend/tornado.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
CommonOptions,
2525
read_client_index_html,
2626
)
27-
from reactpy.backend.hooks import ConnectionContext
28-
from reactpy.backend.hooks import use_connection as _use_connection
2927
from reactpy.backend.types import Connection, Location
3028
from reactpy.config import REACTPY_WEB_MODULES_DIR
29+
from reactpy.core.hooks import ConnectionContext
30+
from reactpy.core.hooks import use_connection as _use_connection
3131
from reactpy.core.layout import Layout
3232
from reactpy.core.serve import serve_layout
3333
from reactpy.core.types import ComponentConstructor

0 commit comments

Comments
 (0)