Skip to content

Commit 0a53ae5

Browse files
committed
Merge remote-tracking branch 'origin/main' into hybrid-properties
2 parents cf67b87 + 3c11451 commit 0a53ae5

40 files changed

Lines changed: 1225 additions & 943 deletions

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm",
2+
"image": "mcr.microsoft.com/devcontainers/python:3.14-trixie",
33
"postCreateCommand": "/bin/bash -c 'python -m pip install uv && python -m uv sync & git clone https://github.com/reflex-dev/reflex-examples; wait'",
44
"forwardPorts": [3000, 8000],
55
"portsAttributes": {

pyi_hashes.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"reflex/components/core/window_events.pyi": "af33ccec866b9540ee7fbec6dbfbd151",
2424
"reflex/components/datadisplay/__init__.pyi": "52755871369acbfd3a96b46b9a11d32e",
2525
"reflex/components/datadisplay/code.pyi": "b86769987ef4d1cbdddb461be88539fd",
26-
"reflex/components/datadisplay/dataeditor.pyi": "fb26f3e702fcb885539d1cf82a854be3",
26+
"reflex/components/datadisplay/dataeditor.pyi": "f8c1e816c9f22f4a7429f812214407f2",
2727
"reflex/components/datadisplay/shiki_code_block.pyi": "1d53e75b6be0d3385a342e7b3011babd",
2828
"reflex/components/el/__init__.pyi": "0adfd001a926a2a40aee94f6fa725ecc",
2929
"reflex/components/el/element.pyi": "c5974a92fbc310e42d0f6cfdd13472f4",
@@ -39,7 +39,7 @@
3939
"reflex/components/el/elements/tables.pyi": "686eb70ea7d8c4dafb0cc5c284e76184",
4040
"reflex/components/el/elements/typography.pyi": "684e83dde887dba12badd0fb75c87c04",
4141
"reflex/components/gridjs/datatable.pyi": "98a7e1b3f3b60cafcdfcd8879750ee42",
42-
"reflex/components/lucide/icon.pyi": "9cdd1107295f5c4b6d5d6516f487f237",
42+
"reflex/components/lucide/icon.pyi": "dcb8773ef162f3ec5759efe11374cf5e",
4343
"reflex/components/markdown/markdown.pyi": "dd74e8e9665b2a813ff799a7aa190b44",
4444
"reflex/components/moment/moment.pyi": "e1952f1c2c82cef85d91e970d1be64ab",
4545
"reflex/components/plotly/plotly.pyi": "4311a0aae2abcc9226abb6a273f96372",
@@ -113,10 +113,10 @@
113113
"reflex/components/react_player/video.pyi": "998671c06103d797c554d9278eb3b2a0",
114114
"reflex/components/react_router/dom.pyi": "3042fa630b7e26a7378fe045d7fbf4af",
115115
"reflex/components/recharts/__init__.pyi": "6ee7f1ca2c0912f389ba6f3251a74d99",
116-
"reflex/components/recharts/cartesian.pyi": "cfca4f880239ffaecdf9fb4c7c8caed5",
116+
"reflex/components/recharts/cartesian.pyi": "d138261ab8259d5208c2f028b9f708bd",
117117
"reflex/components/recharts/charts.pyi": "013036b9c00ad85a570efdb813c1bc40",
118118
"reflex/components/recharts/general.pyi": "d87ff9b85b2a204be01753690df4fb11",
119-
"reflex/components/recharts/polar.pyi": "ad24bd37c6acc0bc9bd4ac01af3ffe49",
120-
"reflex/components/recharts/recharts.pyi": "c41d19ab67972246c574098929bea7ea",
119+
"reflex/components/recharts/polar.pyi": "b8b1a3e996e066facdf4f8c9eb363137",
120+
"reflex/components/recharts/recharts.pyi": "d5c9fc57a03b419748f0408c23319eee",
121121
"reflex/components/sonner/toast.pyi": "3c27bad1aaeb5183eaa6a41e77e8d7f0"
122122
}

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "reflex"
3-
version = "0.8.27dev1"
3+
version = "0.8.28dev1"
44
description = "Web apps in pure Python."
55
license.text = "Apache-2.0"
66
authors = [
@@ -244,7 +244,7 @@ fail_fast = true
244244

245245
[[tool.pre-commit.repos]]
246246
repo = "https://github.com/astral-sh/ruff-pre-commit"
247-
rev = "v0.14.13"
247+
rev = "v0.15.1"
248248
hooks = [
249249
{ id = "ruff-format", args = [
250250
"reflex",

reflex/.templates/web/utils/state.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,16 @@ export const applyRestEvent = async (event, socket, navigate, params) => {
446446
return eventSent;
447447
};
448448

449+
/**
450+
* Resolve a socket reference to the actual socket object.
451+
* Handles both ref objects ({ current: Socket }) and raw sockets.
452+
* @param socket Either a ref object or raw socket.
453+
* @returns The actual socket object.
454+
*/
455+
const resolveSocket = (socket) => {
456+
return socket?.current ?? socket;
457+
};
458+
449459
/**
450460
* Queue events to be processed and trigger processing of queue.
451461
* @param events Array of events to queue.
@@ -471,7 +481,7 @@ export const queueEvents = async (
471481
];
472482
}
473483
event_queue.push(...events.filter((e) => e !== undefined && e !== null));
474-
await processEvent(socket.current, navigate, params);
484+
await processEvent(resolveSocket(socket), navigate, params);
475485
};
476486

477487
/**

reflex/app.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@
7777
from reflex.event import (
7878
_EVENT_FIELDS,
7979
Event,
80-
EventHandler,
8180
EventSpec,
8281
EventType,
8382
IndividualEventType,
8483
get_hydrate_event,
8584
noop,
8685
)
86+
from reflex.istate.proxy import StateProxy
8787
from reflex.page import DECORATED_PAGES
8888
from reflex.route import (
8989
get_route_args,
@@ -1619,6 +1619,8 @@ def _process_background(
16191619
if not handler.is_background:
16201620
return None
16211621

1622+
substate = StateProxy(substate)
1623+
16221624
async def _coro():
16231625
"""Coroutine to process the event and emit updates inside an asyncio.Task.
16241626
@@ -1934,21 +1936,14 @@ async def upload_file(request: Request):
19341936
substate_token = _substate_key(token, handler.rpartition(".")[0])
19351937
state = await app.state_manager.get_state(substate_token)
19361938

1937-
# get the current session ID
1938-
# get the current state(parent state/substate)
1939-
path = handler.split(".")[:-1]
1940-
current_state = state.get_substate(path)
19411939
handler_upload_param = ()
19421940

1943-
# get handler function
1944-
func = getattr(type(current_state), handler.split(".")[-1])
1941+
_current_state, event_handler = state._get_event_handler(handler)
19451942

1946-
# check if there exists any handler args with annotation, list[UploadFile]
1947-
if isinstance(func, EventHandler):
1948-
if func.is_background:
1949-
msg = f"@rx.event(background=True) is not supported for upload handler `{handler}`."
1950-
raise UploadTypeError(msg)
1951-
func = func.fn
1943+
if event_handler.is_background:
1944+
msg = f"@rx.event(background=True) is not supported for upload handler `{handler}`."
1945+
raise UploadTypeError(msg)
1946+
func = event_handler.fn
19521947
if isinstance(func, functools.partial):
19531948
func = func.func
19541949
for k, v in get_type_hints(func).items():

reflex/assets.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ def asset(
9292
if not dst_file.exists() and (
9393
not dst_file.is_symlink() or dst_file.resolve() != src_file_shared.resolve()
9494
):
95-
dst_file.symlink_to(src_file_shared)
95+
try:
96+
dst_file.symlink_to(src_file_shared)
97+
except FileExistsError:
98+
# This happens when Simon builds the app on a bind mount in a docker container.
99+
dst_file.unlink()
100+
dst_file.symlink_to(src_file_shared)
96101

97102
return f"/{external}/{subfolder}/{path}"

reflex/compiler/templates.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ def vite_config_template(
502502
force_full_reload: bool,
503503
experimental_hmr: bool,
504504
sourcemap: bool | Literal["inline", "hidden"],
505+
allowed_hosts: bool | list[str] = False,
505506
):
506507
"""Template for vite.config.js.
507508
@@ -511,10 +512,17 @@ def vite_config_template(
511512
force_full_reload: Whether to force a full reload on changes.
512513
experimental_hmr: Whether to enable experimental HMR features.
513514
sourcemap: The sourcemap configuration.
515+
allowed_hosts: Allow all hosts (True), specific hosts (list of strings), or only localhost (False).
514516
515517
Returns:
516518
Rendered vite.config.js content as string.
517519
"""
520+
if allowed_hosts is True:
521+
allowed_hosts_line = "\n allowedHosts: true,"
522+
elif isinstance(allowed_hosts, list) and allowed_hosts:
523+
allowed_hosts_line = f"\n allowedHosts: {json.dumps(allowed_hosts)},"
524+
else:
525+
allowed_hosts_line = ""
518526
return rf"""import {{ fileURLToPath, URL }} from "url";
519527
import {{ reactRouter }} from "@react-router/dev/vite";
520528
import {{ defineConfig }} from "vite";
@@ -586,7 +594,7 @@ def vite_config_template(
586594
hmr: {"true" if experimental_hmr else "false"},
587595
}},
588596
server: {{
589-
port: process.env.PORT,
597+
port: process.env.PORT,{allowed_hosts_line}
590598
hmr: {"true" if hmr else "false"},
591599
watch: {{
592600
ignored: [

reflex/components/base/error_boundary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def on_error_spec(
3636
class ErrorBoundary(Component):
3737
"""A React Error Boundary component that catches unhandled frontend exceptions."""
3838

39-
library = "react-error-boundary@6.1.0"
39+
library = "react-error-boundary@6.1.1"
4040
tag = "ErrorBoundary"
4141

4242
# Fired when the boundary catches an error.

reflex/components/core/debounce.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def create(cls, *children: Component, **props: Any) -> Component:
111111
child_ref = child.get_ref()
112112
if props.get("input_ref") is None and child_ref:
113113
props["input_ref"] = Var(_js_expr=child_ref, _var_type=str)
114+
if child.id is not None:
114115
props["id"] = child.id
115116

116117
# Set the child element to wrap, including any imports/hooks from the child.

reflex/components/core/upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class GhostUpload(Fragment):
221221
class Upload(MemoizationLeaf):
222222
"""A file upload component."""
223223

224-
library = "react-dropzone@14.3.8"
224+
library = "react-dropzone@15.0.0"
225225

226226
tag = ""
227227

0 commit comments

Comments
 (0)