Skip to content

Commit

Permalink
Merge branch 'main' into event-target-checked-does-not-exist-for-chec…
Browse files Browse the repository at this point in the history
…kbox-inputs
  • Loading branch information
Archmonger authored Oct 29, 2024
2 parents 9983d95 + 0e4432f commit 8a4459a
Show file tree
Hide file tree
Showing 20 changed files with 132 additions and 117 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/.hatch-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ jobs:
runs-on: ${{ fromJson(inputs.runs-on-array) }}
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "14.x"
node-version: "23.x"
registry-url: ${{ inputs.node-registry-url }}
- name: Pin NPM Version
run: npm install -g [email protected]
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python Dependencies
Expand Down
44 changes: 22 additions & 22 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
name: deploy-docs

on:
push:
branches:
- "main"
tags:
- "*"
push:
branches:
- "main"
tags:
- "*"

jobs:
deploy-documentation:
runs-on: ubuntu-latest
steps:
- name: Check out src from Git
uses: actions/checkout@v2
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Login to Heroku Container Registry
run: echo ${{ secrets.HEROKU_API_KEY }} | docker login -u ${{ secrets.HEROKU_EMAIL }} --password-stdin registry.heroku.com
- name: Build Docker Image
run: docker build . --file docs/Dockerfile --tag registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
- name: Push Docker Image
run: docker push registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
- name: Deploy
run: HEROKU_API_KEY=${{ secrets.HEROKU_API_KEY }} heroku container:release web --app ${{ secrets.HEROKU_APP_NAME }}
deploy-documentation:
runs-on: ubuntu-latest
steps:
- name: Check out src from Git
uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Login to Heroku Container Registry
run: echo ${{ secrets.HEROKU_API_KEY }} | docker login -u ${{ secrets.HEROKU_EMAIL }} --password-stdin registry.heroku.com
- name: Build Docker Image
run: docker build . --file docs/Dockerfile --tag registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
- name: Push Docker Image
run: docker push registry.heroku.com/${{ secrets.HEROKU_APP_NAME }}/web
- name: Deploy
run: HEROKU_API_KEY=${{ secrets.HEROKU_API_KEY }} heroku container:release web --app ${{ secrets.HEROKU_APP_NAME }}
24 changes: 12 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
name: publish

on:
release:
types: [published]
release:
types: [published]

jobs:
publish:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "publish"
hatch-run: "publish"
node-registry-url: "https://registry.npmjs.org"
secrets:
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
pypi-username: ${{ secrets.PYPI_USERNAME }}
pypi-password: ${{ secrets.PYPI_PASSWORD }}
publish:
uses: ./.github/workflows/.hatch-run.yml
with:
job-name: "publish"
hatch-run: "publish"
node-registry-url: "https://registry.npmjs.org"
secrets:
node-auth-token: ${{ secrets.NODE_AUTH_TOKEN }}
pypi-username: ${{ secrets.PYPI_USERNAME }}
pypi-password: ${{ secrets.PYPI_PASSWORD }}
4 changes: 4 additions & 0 deletions docs/source/about/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Unreleased
- :pull:`1118` - `module_from_template` is broken with a recent release of `requests`
- :pull:`1131` - `module_from_template` did not work when using Flask backend
- :pull:`1200` - Fixed `UnicodeDecodeError` when using `reactpy.web.export`
- :pull:`1224` - Fixes needless unmounting of JavaScript components during each ReactPy render.

**Added**

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

**Deprecated**

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


v1.0.2
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ detached = true
dependencies = [
"invoke",
# lint
"black==24.1.1", # Pin lint tools we don't control to avoid breaking changes
"ruff==0.0.278", # Pin lint tools we don't control to avoid breaking changes
"black==24.1.1", # Pin lint tools we don't control to avoid breaking changes
"ruff==0.0.278", # Pin lint tools we don't control to avoid breaking changes
"toml",
"flake8==7.0.0", # Pin lint tools we don't control to avoid breaking changes
"flake8==7.0.0", # Pin lint tools we don't control to avoid breaking changes
"flake8-pyproject",
"reactpy-flake8 >=0.7",
# types
"mypy",
"types-toml",
Expand Down
4 changes: 2 additions & 2 deletions src/js/packages/@reactpy/client/src/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function useForceUpdate() {

function useImportSource(model: ReactPyVdom): MutableRefObject<any> {
const vdomImportSource = model.importSource;

const vdomImportSourceJsonString = JSON.stringify(vdomImportSource);
const mountPoint = useRef<HTMLElement>(null);
const client = React.useContext(ClientContext);
const [binding, setBinding] = useState<ImportSourceBinding | null>(null);
Expand All @@ -203,7 +203,7 @@ function useImportSource(model: ReactPyVdom): MutableRefObject<any> {
binding.unmount();
}
};
}, [client, vdomImportSource, setBinding, mountPoint.current]);
}, [client, vdomImportSourceJsonString, setBinding, mountPoint.current]);

// this effect must run every time in case the model has changed
useEffect(() => {
Expand Down
56 changes: 13 additions & 43 deletions src/py/reactpy/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ readme = "README.md"
requires-python = ">=3.9"
license = "MIT"
keywords = ["react", "javascript", "reactpy", "component"]
authors = [
{ name = "Ryan Morshead", email = "[email protected]" },
]
authors = [{ name = "Ryan Morshead", email = "[email protected]" }]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
Expand All @@ -39,33 +37,18 @@ dependencies = [
[project.optional-dependencies]
all = ["reactpy[starlette,sanic,fastapi,flask,tornado,testing]"]

starlette = [
"starlette >=0.13.6",
"uvicorn[standard] >=0.19.0",
]
starlette = ["starlette >=0.13.6", "uvicorn[standard] >=0.19.0"]
sanic = [
"sanic >=21",
"sanic-cors",
"tracerite>=1.1.1",
"setuptools",
"uvicorn[standard] >=0.19.0",
]
fastapi = [
"fastapi >=0.63.0",
"uvicorn[standard] >=0.19.0",
]
flask = [
"flask",
"markupsafe>=1.1.1,<2.1",
"flask-cors",
"flask-sock",
]
tornado = [
"tornado",
]
testing = [
"playwright",
]
fastapi = ["fastapi >=0.63.0", "uvicorn[standard] >=0.19.0"]
flask = ["flask", "markupsafe>=1.1.1,<2.1", "flask-cors", "flask-sock"]
tornado = ["tornado"]
testing = ["playwright"]

[project.urls]
Source = "https://github.com/reactive-python/reactpy"
Expand Down Expand Up @@ -101,21 +84,17 @@ cov-report = [
# "- coverage combine",
"coverage report",
]
cov = [
"test-cov {args}",
"cov-report",
]
cov = ["test-cov {args}", "cov-report"]

[tool.hatch.envs.default.env-vars]
REACTPY_DEBUG_MODE="1"
REACTPY_DEBUG_MODE = "1"

[tool.hatch.envs.lint]
features = ["all"]
dependencies = [
"mypy>=1.0.0",
"mypy==1.8",
"types-click",
"types-tornado",
"types-pkg-resources",
"types-flask",
"types-requests",
]
Expand All @@ -127,13 +106,8 @@ all = ["types"]
[[tool.hatch.build.hooks.build-scripts.scripts]]
work_dir = "../../js"
out_dir = "reactpy/_static"
commands = [
"npm ci",
"npm run build"
]
artifacts = [
"app/dist/"
]
commands = ["npm ci", "npm run build"]
artifacts = ["app/dist/"]

# --- Pytest ---------------------------------------------------------------------------

Expand All @@ -159,9 +133,7 @@ warn_unused_ignores = true
source_pkgs = ["reactpy"]
branch = false
parallel = false
omit = [
"reactpy/__init__.py",
]
omit = ["reactpy/__init__.py"]

[tool.coverage.report]
fail_under = 100
Expand All @@ -174,6 +146,4 @@ exclude_lines = [
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
omit = [
"reactpy/__main__.py",
]
omit = ["reactpy/__main__.py"]
4 changes: 3 additions & 1 deletion src/py/reactpy/reactpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from reactpy import backend, config, html, logging, sample, svg, types, web, widgets
from reactpy.backend.hooks import use_connection, use_location, use_scope
from reactpy.backend.utils import run
from reactpy.core import hooks
from reactpy.core.component import component
from reactpy.core.events import event
from reactpy.core.hooks import (
create_context,
use_callback,
use_connection,
use_context,
use_debug_value,
use_effect,
use_location,
use_memo,
use_reducer,
use_ref,
use_scope,
use_state,
)
from reactpy.core.layout import Layout
Expand Down
4 changes: 2 additions & 2 deletions src/py/reactpy/reactpy/backend/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
safe_client_build_dir_path,
safe_web_modules_dir_path,
)
from reactpy.backend.hooks import ConnectionContext
from reactpy.backend.hooks import use_connection as _use_connection
from reactpy.backend.types import Connection, Location
from reactpy.core.hooks import ConnectionContext
from reactpy.core.hooks import use_connection as _use_connection
from reactpy.core.serve import serve_layout
from reactpy.core.types import ComponentType, RootComponentConstructor
from reactpy.utils import Ref
Expand Down
41 changes: 28 additions & 13 deletions src/py/reactpy/reactpy/backend/hooks.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
from __future__ import annotations
from __future__ import annotations # nocov

from collections.abc import MutableMapping
from typing import Any
from collections.abc import MutableMapping # nocov
from typing import Any # nocov

from reactpy.backend.types import Connection, Location
from reactpy.core.hooks import create_context, use_context
from reactpy.core.types import Context
from reactpy._warnings import warn # nocov
from reactpy.backend.types import Connection, Location # nocov
from reactpy.core.hooks import ConnectionContext, use_context # nocov

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


def use_connection() -> Connection[Any]:
def use_connection() -> Connection[Any]: # nocov
"""Get the current :class:`~reactpy.backend.types.Connection`."""
warn(
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ",
"Call reactpy.use_connection instead.",
DeprecationWarning,
)

conn = use_context(ConnectionContext)
if conn is None: # nocov
if conn is None:
msg = "No backend established a connection."
raise RuntimeError(msg)
return conn


def use_scope() -> MutableMapping[str, Any]:
def use_scope() -> MutableMapping[str, Any]: # nocov
"""Get the current :class:`~reactpy.backend.types.Connection`'s scope."""
warn(
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ",
"Call reactpy.use_scope instead.",
DeprecationWarning,
)

return use_connection().scope


def use_location() -> Location:
def use_location() -> Location: # nocov
"""Get the current :class:`~reactpy.backend.types.Connection`'s location."""
warn(
"The module reactpy.backend.hooks has been deprecated and will be deleted in the future. ",
"Call reactpy.use_location instead.",
DeprecationWarning,
)

return use_connection().location
4 changes: 2 additions & 2 deletions src/py/reactpy/reactpy/backend/sanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
safe_web_modules_dir_path,
serve_with_uvicorn,
)
from reactpy.backend.hooks import ConnectionContext
from reactpy.backend.hooks import use_connection as _use_connection
from reactpy.backend.types import Connection, Location
from reactpy.core.hooks import ConnectionContext
from reactpy.core.hooks import use_connection as _use_connection
from reactpy.core.layout import Layout
from reactpy.core.serve import RecvCoroutine, SendCoroutine, Stop, serve_layout
from reactpy.core.types import RootComponentConstructor
Expand Down
4 changes: 2 additions & 2 deletions src/py/reactpy/reactpy/backend/starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
read_client_index_html,
serve_with_uvicorn,
)
from reactpy.backend.hooks import ConnectionContext
from reactpy.backend.hooks import use_connection as _use_connection
from reactpy.backend.types import Connection, Location
from reactpy.config import REACTPY_WEB_MODULES_DIR
from reactpy.core.hooks import ConnectionContext
from reactpy.core.hooks import use_connection as _use_connection
from reactpy.core.layout import Layout
from reactpy.core.serve import RecvCoroutine, SendCoroutine, serve_layout
from reactpy.core.types import RootComponentConstructor
Expand Down
4 changes: 2 additions & 2 deletions src/py/reactpy/reactpy/backend/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
CommonOptions,
read_client_index_html,
)
from reactpy.backend.hooks import ConnectionContext
from reactpy.backend.hooks import use_connection as _use_connection
from reactpy.backend.types import Connection, Location
from reactpy.config import REACTPY_WEB_MODULES_DIR
from reactpy.core.hooks import ConnectionContext
from reactpy.core.hooks import use_connection as _use_connection
from reactpy.core.layout import Layout
from reactpy.core.serve import serve_layout
from reactpy.core.types import ComponentConstructor
Expand Down
Loading

0 comments on commit 8a4459a

Please sign in to comment.