reflex 0.7.13a1__py3-none-any.whl → 0.7.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of reflex might be problematic. Click here for more details.
- reflex/.templates/apps/blank/code/blank.py +0 -2
- reflex/app.py +100 -92
- reflex/app_mixins/lifespan.py +2 -3
- reflex/app_mixins/middleware.py +1 -0
- reflex/app_mixins/mixin.py +0 -1
- reflex/assets.py +7 -4
- reflex/base.py +3 -2
- reflex/compiler/compiler.py +79 -65
- reflex/compiler/utils.py +8 -6
- reflex/components/base/app_wrap.pyi +0 -1
- reflex/components/base/bare.py +22 -12
- reflex/components/base/body.pyi +0 -1
- reflex/components/base/document.pyi +0 -5
- reflex/components/base/error_boundary.pyi +0 -1
- reflex/components/base/fragment.pyi +0 -1
- reflex/components/base/head.pyi +0 -2
- reflex/components/base/link.pyi +0 -2
- reflex/components/base/meta.py +2 -1
- reflex/components/base/meta.pyi +0 -4
- reflex/components/base/script.py +2 -1
- reflex/components/base/script.pyi +0 -1
- reflex/components/base/strict_mode.pyi +0 -1
- reflex/components/component.py +85 -45
- reflex/components/core/auto_scroll.pyi +0 -1
- reflex/components/core/banner.py +1 -1
- reflex/components/core/banner.pyi +0 -6
- reflex/components/core/breakpoints.py +9 -11
- reflex/components/core/client_side_routing.pyi +0 -2
- reflex/components/core/clipboard.pyi +0 -1
- reflex/components/core/colors.py +10 -7
- reflex/components/core/cond.py +4 -2
- reflex/components/core/debounce.py +5 -3
- reflex/components/core/debounce.pyi +0 -1
- reflex/components/core/foreach.py +8 -6
- reflex/components/core/html.py +3 -3
- reflex/components/core/html.pyi +0 -1
- reflex/components/core/match.py +19 -17
- reflex/components/core/sticky.pyi +0 -4
- reflex/components/core/upload.py +1 -1
- reflex/components/core/upload.pyi +0 -5
- reflex/components/datadisplay/code.py +1 -2
- reflex/components/datadisplay/code.pyi +0 -2
- reflex/components/datadisplay/dataeditor.py +7 -10
- reflex/components/datadisplay/dataeditor.pyi +0 -1
- reflex/components/datadisplay/logo.py +3 -4
- reflex/components/datadisplay/shiki_code_block.py +8 -11
- reflex/components/datadisplay/shiki_code_block.pyi +0 -3
- reflex/components/dynamic.py +2 -3
- reflex/components/el/__init__.pyi +2 -0
- reflex/components/el/element.pyi +0 -1
- reflex/components/el/elements/__init__.py +1 -0
- reflex/components/el/elements/__init__.pyi +3 -0
- reflex/components/el/elements/base.pyi +0 -1
- reflex/components/el/elements/forms.py +14 -15
- reflex/components/el/elements/forms.pyi +15 -32
- reflex/components/el/elements/inline.pyi +0 -28
- reflex/components/el/elements/media.py +26 -0
- reflex/components/el/elements/media.pyi +259 -25
- reflex/components/el/elements/metadata.py +0 -1
- reflex/components/el/elements/metadata.pyi +0 -6
- reflex/components/el/elements/other.pyi +0 -7
- reflex/components/el/elements/scripts.pyi +0 -3
- reflex/components/el/elements/sectioning.pyi +0 -15
- reflex/components/el/elements/tables.pyi +0 -10
- reflex/components/el/elements/typography.pyi +0 -15
- reflex/components/gridjs/datatable.py +10 -13
- reflex/components/gridjs/datatable.pyi +0 -2
- reflex/components/lucide/icon.py +10 -9
- reflex/components/lucide/icon.pyi +0 -3
- reflex/components/markdown/markdown.py +6 -8
- reflex/components/markdown/markdown.pyi +0 -1
- reflex/components/moment/moment.pyi +0 -1
- reflex/components/next/base.py +0 -2
- reflex/components/next/base.pyi +0 -3
- reflex/components/next/image.pyi +0 -1
- reflex/components/next/link.pyi +0 -1
- reflex/components/next/video.pyi +0 -1
- reflex/components/plotly/plotly.pyi +0 -9
- reflex/components/props.py +4 -3
- reflex/components/radix/primitives/accordion.py +1 -1
- reflex/components/radix/primitives/accordion.pyi +0 -7
- reflex/components/radix/primitives/base.py +1 -3
- reflex/components/radix/primitives/base.pyi +0 -2
- reflex/components/radix/primitives/drawer.py +1 -1
- reflex/components/radix/primitives/drawer.pyi +0 -11
- reflex/components/radix/primitives/form.py +5 -9
- reflex/components/radix/primitives/form.pyi +0 -12
- reflex/components/radix/primitives/progress.py +1 -1
- reflex/components/radix/primitives/progress.pyi +0 -5
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/primitives/slider.pyi +0 -5
- reflex/components/radix/themes/base.pyi +0 -8
- reflex/components/radix/themes/color_mode.pyi +0 -3
- reflex/components/radix/themes/components/alert_dialog.py +4 -2
- reflex/components/radix/themes/components/alert_dialog.pyi +4 -9
- reflex/components/radix/themes/components/aspect_ratio.py +1 -2
- reflex/components/radix/themes/components/aspect_ratio.pyi +1 -3
- reflex/components/radix/themes/components/avatar.py +5 -2
- reflex/components/radix/themes/components/avatar.pyi +1 -3
- reflex/components/radix/themes/components/badge.py +5 -2
- reflex/components/radix/themes/components/badge.pyi +1 -3
- reflex/components/radix/themes/components/button.py +2 -3
- reflex/components/radix/themes/components/button.pyi +1 -3
- reflex/components/radix/themes/components/callout.py +1 -2
- reflex/components/radix/themes/components/callout.pyi +1 -7
- reflex/components/radix/themes/components/card.py +1 -2
- reflex/components/radix/themes/components/card.pyi +1 -3
- reflex/components/radix/themes/components/checkbox.py +7 -4
- reflex/components/radix/themes/components/checkbox.pyi +1 -5
- reflex/components/radix/themes/components/checkbox_cards.py +1 -2
- reflex/components/radix/themes/components/checkbox_cards.pyi +1 -4
- reflex/components/radix/themes/components/checkbox_group.py +1 -2
- reflex/components/radix/themes/components/checkbox_group.pyi +1 -4
- reflex/components/radix/themes/components/context_menu.py +1 -1
- reflex/components/radix/themes/components/context_menu.pyi +1 -14
- reflex/components/radix/themes/components/data_list.py +1 -2
- reflex/components/radix/themes/components/data_list.pyi +1 -6
- reflex/components/radix/themes/components/dialog.py +4 -2
- reflex/components/radix/themes/components/dialog.pyi +4 -9
- reflex/components/radix/themes/components/dropdown_menu.py +5 -2
- reflex/components/radix/themes/components/dropdown_menu.pyi +4 -10
- reflex/components/radix/themes/components/hover_card.py +4 -2
- reflex/components/radix/themes/components/hover_card.pyi +4 -6
- reflex/components/radix/themes/components/icon_button.py +7 -8
- reflex/components/radix/themes/components/icon_button.pyi +1 -3
- reflex/components/radix/themes/components/inset.py +1 -2
- reflex/components/radix/themes/components/inset.pyi +1 -3
- reflex/components/radix/themes/components/popover.py +4 -2
- reflex/components/radix/themes/components/popover.pyi +4 -6
- reflex/components/radix/themes/components/progress.py +1 -2
- reflex/components/radix/themes/components/progress.pyi +1 -3
- reflex/components/radix/themes/components/radio.py +1 -2
- reflex/components/radix/themes/components/radio.pyi +1 -3
- reflex/components/radix/themes/components/radio_cards.py +1 -2
- reflex/components/radix/themes/components/radio_cards.pyi +1 -4
- reflex/components/radix/themes/components/radio_group.py +7 -5
- reflex/components/radix/themes/components/radio_group.pyi +1 -6
- reflex/components/radix/themes/components/scroll_area.py +1 -2
- reflex/components/radix/themes/components/scroll_area.pyi +1 -3
- reflex/components/radix/themes/components/segmented_control.py +1 -2
- reflex/components/radix/themes/components/segmented_control.pyi +1 -4
- reflex/components/radix/themes/components/select.py +5 -2
- reflex/components/radix/themes/components/select.pyi +1 -11
- reflex/components/radix/themes/components/separator.py +1 -2
- reflex/components/radix/themes/components/separator.pyi +1 -3
- reflex/components/radix/themes/components/skeleton.py +1 -2
- reflex/components/radix/themes/components/skeleton.pyi +1 -3
- reflex/components/radix/themes/components/slider.py +1 -2
- reflex/components/radix/themes/components/slider.pyi +1 -3
- reflex/components/radix/themes/components/spinner.py +1 -2
- reflex/components/radix/themes/components/spinner.pyi +1 -3
- reflex/components/radix/themes/components/switch.py +1 -2
- reflex/components/radix/themes/components/switch.pyi +1 -3
- reflex/components/radix/themes/components/table.py +1 -2
- reflex/components/radix/themes/components/table.pyi +1 -9
- reflex/components/radix/themes/components/tabs.py +1 -2
- reflex/components/radix/themes/components/tabs.pyi +1 -7
- reflex/components/radix/themes/components/text_area.py +5 -2
- reflex/components/radix/themes/components/text_area.pyi +2 -4
- reflex/components/radix/themes/components/text_field.py +5 -2
- reflex/components/radix/themes/components/text_field.pyi +1 -5
- reflex/components/radix/themes/components/tooltip.py +1 -2
- reflex/components/radix/themes/components/tooltip.pyi +1 -3
- reflex/components/radix/themes/layout/base.py +5 -2
- reflex/components/radix/themes/layout/base.pyi +5 -3
- reflex/components/radix/themes/layout/box.py +1 -2
- reflex/components/radix/themes/layout/box.pyi +1 -3
- reflex/components/radix/themes/layout/center.pyi +0 -1
- reflex/components/radix/themes/layout/container.py +1 -2
- reflex/components/radix/themes/layout/container.pyi +1 -3
- reflex/components/radix/themes/layout/flex.py +6 -2
- reflex/components/radix/themes/layout/flex.pyi +1 -3
- reflex/components/radix/themes/layout/grid.py +6 -2
- reflex/components/radix/themes/layout/grid.pyi +1 -3
- reflex/components/radix/themes/layout/list.py +2 -1
- reflex/components/radix/themes/layout/list.pyi +0 -5
- reflex/components/radix/themes/layout/section.py +1 -2
- reflex/components/radix/themes/layout/section.pyi +1 -3
- reflex/components/radix/themes/layout/spacer.pyi +0 -1
- reflex/components/radix/themes/layout/stack.py +1 -1
- reflex/components/radix/themes/layout/stack.pyi +0 -3
- reflex/components/radix/themes/typography/blockquote.py +1 -1
- reflex/components/radix/themes/typography/blockquote.pyi +1 -3
- reflex/components/radix/themes/typography/code.py +5 -1
- reflex/components/radix/themes/typography/code.pyi +1 -3
- reflex/components/radix/themes/typography/heading.py +1 -1
- reflex/components/radix/themes/typography/heading.pyi +1 -3
- reflex/components/radix/themes/typography/link.py +3 -2
- reflex/components/radix/themes/typography/link.pyi +1 -3
- reflex/components/radix/themes/typography/text.py +1 -1
- reflex/components/radix/themes/typography/text.pyi +1 -9
- reflex/components/react_player/audio.py +0 -2
- reflex/components/react_player/audio.pyi +0 -3
- reflex/components/react_player/react_player.pyi +0 -1
- reflex/components/react_player/video.py +0 -2
- reflex/components/react_player/video.pyi +0 -3
- reflex/components/recharts/__init__.py +1 -1
- reflex/components/recharts/__init__.pyi +1 -1
- reflex/components/recharts/cartesian.py +20 -25
- reflex/components/recharts/cartesian.pyi +20 -37
- reflex/components/recharts/charts.py +2 -1
- reflex/components/recharts/charts.pyi +0 -12
- reflex/components/recharts/general.pyi +0 -6
- reflex/components/recharts/polar.py +5 -4
- reflex/components/recharts/polar.pyi +4 -10
- reflex/components/recharts/recharts.py +12 -10
- reflex/components/recharts/recharts.pyi +10 -11
- reflex/components/sonner/toast.py +2 -2
- reflex/components/sonner/toast.pyi +0 -2
- reflex/components/suneditor/editor.py +2 -1
- reflex/components/suneditor/editor.pyi +0 -1
- reflex/components/tags/iter_tag.py +4 -2
- reflex/config.py +41 -615
- reflex/constants/base.py +6 -6
- reflex/constants/compiler.py +8 -6
- reflex/constants/installer.py +25 -16
- reflex/custom_components/custom_components.py +1 -2
- reflex/environment.py +606 -0
- reflex/event.py +58 -60
- reflex/experimental/__init__.py +2 -2
- reflex/experimental/client_state.py +9 -4
- reflex/experimental/layout.pyi +0 -5
- reflex/istate/manager.py +17 -20
- reflex/istate/proxy.py +19 -12
- reflex/model.py +8 -5
- reflex/plugins/base.py +8 -0
- reflex/plugins/tailwind_v3.py +8 -0
- reflex/plugins/tailwind_v4.py +9 -0
- reflex/reflex.py +11 -12
- reflex/route.py +7 -9
- reflex/state.py +67 -71
- reflex/style.py +3 -1
- reflex/testing.py +49 -30
- reflex/utils/build.py +2 -1
- reflex/utils/console.py +70 -17
- reflex/utils/exec.py +113 -39
- reflex/utils/export.py +2 -1
- reflex/utils/format.py +21 -24
- reflex/utils/imports.py +4 -3
- reflex/utils/lazy_loader.py +3 -3
- reflex/utils/misc.py +2 -1
- reflex/utils/net.py +2 -2
- reflex/utils/path_ops.py +4 -2
- reflex/utils/prerequisites.py +69 -39
- reflex/utils/processes.py +5 -7
- reflex/utils/pyi_generator.py +46 -41
- reflex/utils/redir.py +1 -1
- reflex/utils/registry.py +1 -1
- reflex/utils/serializers.py +4 -4
- reflex/utils/telemetry.py +36 -3
- reflex/utils/types.py +16 -13
- reflex/vars/base.py +96 -109
- reflex/vars/datetime.py +2 -1
- reflex/vars/dep_tracking.py +19 -28
- reflex/vars/number.py +6 -7
- reflex/vars/object.py +5 -6
- reflex/vars/sequence.py +11 -11
- {reflex-0.7.13a1.dist-info → reflex-0.7.14.dist-info}/METADATA +1 -1
- reflex-0.7.14.dist-info/RECORD +408 -0
- reflex-0.7.13a1.dist-info/RECORD +0 -407
- {reflex-0.7.13a1.dist-info → reflex-0.7.14.dist-info}/WHEEL +0 -0
- {reflex-0.7.13a1.dist-info → reflex-0.7.14.dist-info}/entry_points.txt +0 -0
- {reflex-0.7.13a1.dist-info → reflex-0.7.14.dist-info}/licenses/LICENSE +0 -0
reflex/compiler/compiler.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import sys
|
|
5
6
|
from collections.abc import Iterable, Sequence
|
|
6
7
|
from datetime import datetime
|
|
7
8
|
from inspect import getmodule
|
|
@@ -18,8 +19,9 @@ from reflex.components.component import (
|
|
|
18
19
|
CustomComponent,
|
|
19
20
|
StatefulComponent,
|
|
20
21
|
)
|
|
21
|
-
from reflex.config import
|
|
22
|
+
from reflex.config import get_config
|
|
22
23
|
from reflex.constants.compiler import PageNames
|
|
24
|
+
from reflex.environment import environment
|
|
23
25
|
from reflex.state import BaseState
|
|
24
26
|
from reflex.style import SYSTEM_COLOR_MODE
|
|
25
27
|
from reflex.utils import console, path_ops
|
|
@@ -200,15 +202,14 @@ def _validate_stylesheet(stylesheet_full_path: Path, assets_app_path: Path) -> N
|
|
|
200
202
|
"""
|
|
201
203
|
suffix = stylesheet_full_path.suffix[1:] if stylesheet_full_path.suffix else ""
|
|
202
204
|
if suffix not in constants.Reflex.STYLESHEETS_SUPPORTED:
|
|
203
|
-
|
|
205
|
+
msg = f"Stylesheet file {stylesheet_full_path} is not supported."
|
|
206
|
+
raise ValueError(msg)
|
|
204
207
|
if not stylesheet_full_path.absolute().is_relative_to(assets_app_path.absolute()):
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
)
|
|
208
|
+
msg = f"Cannot include stylesheets from outside the assets directory: {stylesheet_full_path}"
|
|
209
|
+
raise FileNotFoundError(msg)
|
|
208
210
|
if not stylesheet_full_path.name:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
)
|
|
211
|
+
msg = f"Stylesheet file name cannot be empty: {stylesheet_full_path}"
|
|
212
|
+
raise ValueError(msg)
|
|
212
213
|
if (
|
|
213
214
|
len(
|
|
214
215
|
stylesheet_full_path.absolute()
|
|
@@ -218,9 +219,8 @@ def _validate_stylesheet(stylesheet_full_path: Path, assets_app_path: Path) -> N
|
|
|
218
219
|
== 1
|
|
219
220
|
and stylesheet_full_path.stem == PageNames.STYLESHEET_ROOT
|
|
220
221
|
):
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
)
|
|
222
|
+
msg = f"Stylesheet file name cannot be '{PageNames.STYLESHEET_ROOT}': {stylesheet_full_path}"
|
|
223
|
+
raise ValueError(msg)
|
|
224
224
|
|
|
225
225
|
|
|
226
226
|
RADIX_THEMES_STYLESHEET = "@radix-ui/themes/styles.css"
|
|
@@ -257,9 +257,8 @@ def _compile_root_stylesheet(stylesheets: list[str]) -> str:
|
|
|
257
257
|
stylesheet_full_path = assets_app_path / stylesheet.strip("/")
|
|
258
258
|
|
|
259
259
|
if not stylesheet_full_path.exists():
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
)
|
|
260
|
+
msg = f"The stylesheet file {stylesheet_full_path} does not exist."
|
|
261
|
+
raise FileNotFoundError(msg)
|
|
263
262
|
|
|
264
263
|
if stylesheet_full_path.is_dir():
|
|
265
264
|
all_files = (
|
|
@@ -685,12 +684,12 @@ def into_component(component: Component | ComponentCallable) -> Component:
|
|
|
685
684
|
"""
|
|
686
685
|
if (converted := _into_component_once(component)) is not None:
|
|
687
686
|
return converted
|
|
687
|
+
if not callable(component):
|
|
688
|
+
msg = f"Expected a Component or callable, got {component!r} of type {type(component)}"
|
|
689
|
+
raise TypeError(msg)
|
|
690
|
+
|
|
688
691
|
try:
|
|
689
|
-
|
|
690
|
-
callable(component)
|
|
691
|
-
and (converted := _into_component_once(component())) is not None
|
|
692
|
-
):
|
|
693
|
-
return converted
|
|
692
|
+
component_called = component()
|
|
694
693
|
except KeyError as e:
|
|
695
694
|
if isinstance(e, ReflexError):
|
|
696
695
|
raise
|
|
@@ -714,9 +713,10 @@ def into_component(component: Component | ComponentCallable) -> Component:
|
|
|
714
713
|
"Cannot pass a Var to a built-in function. Consider using .length() for accessing the length of an iterable Var."
|
|
715
714
|
).with_traceback(e.__traceback__) from None
|
|
716
715
|
if message.endswith(
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
716
|
+
(
|
|
717
|
+
"indices must be integers or slices, not NumberCastedVar",
|
|
718
|
+
"indices must be integers or slices, not BooleanCastedVar",
|
|
719
|
+
)
|
|
720
720
|
):
|
|
721
721
|
raise TypeError(
|
|
722
722
|
"Cannot index into a primitive sequence with a Var. Consider calling rx.Var.create() on the sequence."
|
|
@@ -727,7 +727,11 @@ def into_component(component: Component | ComponentCallable) -> Component:
|
|
|
727
727
|
).with_traceback(e.__traceback__) from None
|
|
728
728
|
raise
|
|
729
729
|
|
|
730
|
-
|
|
730
|
+
if (converted := _into_component_once(component_called)) is not None:
|
|
731
|
+
return converted
|
|
732
|
+
|
|
733
|
+
msg = f"Expected a Component, got {component_called!r} of type {type(component_called)}"
|
|
734
|
+
raise TypeError(msg)
|
|
731
735
|
|
|
732
736
|
|
|
733
737
|
def compile_unevaluated_page(
|
|
@@ -748,52 +752,61 @@ def compile_unevaluated_page(
|
|
|
748
752
|
|
|
749
753
|
Returns:
|
|
750
754
|
The compiled component and whether state should be enabled.
|
|
755
|
+
|
|
756
|
+
Raises:
|
|
757
|
+
Exception: If an error occurs while evaluating the page.
|
|
751
758
|
"""
|
|
752
|
-
|
|
753
|
-
|
|
759
|
+
try:
|
|
760
|
+
# Generate the component if it is a callable.
|
|
761
|
+
component = into_component(page.component)
|
|
754
762
|
|
|
755
|
-
|
|
763
|
+
component._add_style_recursive(style or {}, theme)
|
|
756
764
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
enable_state = True
|
|
762
|
-
else:
|
|
763
|
-
for var in component._get_vars(include_children=True):
|
|
764
|
-
var_data = var._get_all_var_data()
|
|
765
|
-
if not var_data:
|
|
766
|
-
continue
|
|
767
|
-
if not var_data.state:
|
|
768
|
-
continue
|
|
765
|
+
enable_state = False
|
|
766
|
+
# Ensure state is enabled if this page uses state.
|
|
767
|
+
if state is None:
|
|
768
|
+
if page.on_load or component._has_stateful_event_triggers():
|
|
769
769
|
enable_state = True
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
770
|
+
else:
|
|
771
|
+
for var in component._get_vars(include_children=True):
|
|
772
|
+
var_data = var._get_all_var_data()
|
|
773
|
+
if not var_data:
|
|
774
|
+
continue
|
|
775
|
+
if not var_data.state:
|
|
776
|
+
continue
|
|
777
|
+
enable_state = True
|
|
778
|
+
break
|
|
779
|
+
|
|
780
|
+
from reflex.app import OverlayFragment
|
|
781
|
+
from reflex.utils.format import make_default_page_title
|
|
782
|
+
|
|
783
|
+
component = OverlayFragment.create(component)
|
|
784
|
+
|
|
785
|
+
meta_args = {
|
|
786
|
+
"title": (
|
|
787
|
+
page.title
|
|
788
|
+
if page.title is not None
|
|
789
|
+
else make_default_page_title(get_config().app_name, route)
|
|
790
|
+
),
|
|
791
|
+
"image": page.image,
|
|
792
|
+
"meta": page.meta,
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if page.description is not None:
|
|
796
|
+
meta_args["description"] = page.description
|
|
797
|
+
|
|
798
|
+
# Add meta information to the component.
|
|
799
|
+
utils.add_meta(
|
|
800
|
+
component,
|
|
801
|
+
**meta_args,
|
|
802
|
+
)
|
|
795
803
|
|
|
796
|
-
|
|
804
|
+
except Exception as e:
|
|
805
|
+
if sys.version_info >= (3, 11):
|
|
806
|
+
e.add_note(f"Happened while evaluating page {route!r}")
|
|
807
|
+
raise
|
|
808
|
+
else:
|
|
809
|
+
return component, enable_state
|
|
797
810
|
|
|
798
811
|
|
|
799
812
|
class ExecutorSafeFunctions:
|
|
@@ -873,5 +886,6 @@ class ExecutorSafeFunctions:
|
|
|
873
886
|
ValueError: If the style is not set.
|
|
874
887
|
"""
|
|
875
888
|
if style is None:
|
|
876
|
-
|
|
889
|
+
msg = "STYLE should be set"
|
|
890
|
+
raise ValueError(msg)
|
|
877
891
|
return compile_theme(style)
|
reflex/compiler/utils.py
CHANGED
|
@@ -60,7 +60,8 @@ def compile_import_statement(fields: list[ImportVar]) -> tuple[str, list[str]]:
|
|
|
60
60
|
# Check for default imports.
|
|
61
61
|
defaults = {field for field in fields_set if field.is_default}
|
|
62
62
|
if len(defaults) >= 2:
|
|
63
|
-
|
|
63
|
+
msg = "Only one default import is allowed."
|
|
64
|
+
raise ValueError(msg)
|
|
64
65
|
|
|
65
66
|
# Get the default import, and the specific imports.
|
|
66
67
|
default = next(iter({field.name for field in defaults}), "")
|
|
@@ -91,9 +92,8 @@ def validate_imports(import_dict: ParsedImportDict):
|
|
|
91
92
|
):
|
|
92
93
|
used_tags[import_name] = lib if lib[0] == "$" else already_imported
|
|
93
94
|
continue
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
95
|
+
msg = f"Can not compile, the tag {import_name} is used multiple time from {lib} and {used_tags[import_name]}"
|
|
96
|
+
raise ValueError(msg)
|
|
97
97
|
if import_name is not None:
|
|
98
98
|
used_tags[import_name] = lib
|
|
99
99
|
|
|
@@ -130,9 +130,11 @@ def compile_imports(import_dict: ParsedImportDict) -> list[dict]:
|
|
|
130
130
|
for path, (default, rest) in compiled.items():
|
|
131
131
|
if not lib:
|
|
132
132
|
if default:
|
|
133
|
-
|
|
133
|
+
msg = "No default field allowed for empty library."
|
|
134
|
+
raise ValueError(msg)
|
|
134
135
|
if rest is None or len(rest) == 0:
|
|
135
|
-
|
|
136
|
+
msg = "No fields to import."
|
|
137
|
+
raise ValueError(msg)
|
|
136
138
|
import_dicts.extend(get_import_dict(module) for module in sorted(rest))
|
|
137
139
|
continue
|
|
138
140
|
|
reflex/components/base/bare.py
CHANGED
|
@@ -8,7 +8,7 @@ from typing import Any
|
|
|
8
8
|
from reflex.components.component import BaseComponent, Component, ComponentStyle
|
|
9
9
|
from reflex.components.tags import Tag
|
|
10
10
|
from reflex.components.tags.tagless import Tagless
|
|
11
|
-
from reflex.
|
|
11
|
+
from reflex.environment import PerformanceMode, environment
|
|
12
12
|
from reflex.utils import console
|
|
13
13
|
from reflex.utils.decorator import once
|
|
14
14
|
from reflex.utils.imports import ParsedImportDict
|
|
@@ -43,9 +43,8 @@ def validate_str(value: str):
|
|
|
43
43
|
f"Output includes {value!s} which will be displayed as a string. If you are calling `str` on a Var, consider using .to_string() instead."
|
|
44
44
|
)
|
|
45
45
|
elif perf_mode == PerformanceMode.RAISE:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
)
|
|
46
|
+
msg = f"Output includes {value!s} which will be displayed as a string. If you are calling `str` on a Var, consider using .to_string() instead."
|
|
47
|
+
raise ValueError(msg)
|
|
49
48
|
|
|
50
49
|
|
|
51
50
|
def _components_from_var(var: Var) -> Sequence[BaseComponent]:
|
|
@@ -72,10 +71,9 @@ class Bare(Component):
|
|
|
72
71
|
if isinstance(contents, LiteralStringVar):
|
|
73
72
|
validate_str(contents._var_value)
|
|
74
73
|
return cls._unsafe_create(children=[], contents=contents)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
contents = Var.create(contents if contents is not None else "")
|
|
74
|
+
if isinstance(contents, str):
|
|
75
|
+
validate_str(contents)
|
|
76
|
+
contents = Var.create(contents if contents is not None else "")
|
|
79
77
|
|
|
80
78
|
return cls._unsafe_create(children=[], contents=contents)
|
|
81
79
|
|
|
@@ -143,17 +141,29 @@ class Bare(Component):
|
|
|
143
141
|
custom_code |= component._get_all_custom_code()
|
|
144
142
|
return custom_code
|
|
145
143
|
|
|
146
|
-
def _get_all_app_wrap_components(
|
|
144
|
+
def _get_all_app_wrap_components(
|
|
145
|
+
self, *, ignore_ids: set[int] | None = None
|
|
146
|
+
) -> dict[tuple[int, str], Component]:
|
|
147
147
|
"""Get the components that should be wrapped in the app.
|
|
148
148
|
|
|
149
|
+
Args:
|
|
150
|
+
ignore_ids: The ids to ignore when collecting components.
|
|
151
|
+
|
|
149
152
|
Returns:
|
|
150
153
|
The components that should be wrapped in the app.
|
|
151
154
|
"""
|
|
152
|
-
|
|
155
|
+
ignore_ids = ignore_ids or set()
|
|
156
|
+
app_wrap_components = super()._get_all_app_wrap_components(
|
|
157
|
+
ignore_ids=ignore_ids
|
|
158
|
+
)
|
|
153
159
|
if isinstance(self.contents, Var):
|
|
154
160
|
for component in _components_from_var(self.contents):
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
component_id = id(component)
|
|
162
|
+
if isinstance(component, Component) and component_id not in ignore_ids:
|
|
163
|
+
ignore_ids.add(component_id)
|
|
164
|
+
app_wrap_components |= component._get_all_app_wrap_components(
|
|
165
|
+
ignore_ids=ignore_ids
|
|
166
|
+
)
|
|
157
167
|
return app_wrap_components
|
|
158
168
|
|
|
159
169
|
def _get_all_refs(self) -> set[str]:
|
reflex/components/base/body.pyi
CHANGED
|
@@ -61,7 +61,6 @@ class NextDocumentLib(Component):
|
|
|
61
61
|
Returns:
|
|
62
62
|
The component.
|
|
63
63
|
"""
|
|
64
|
-
...
|
|
65
64
|
|
|
66
65
|
class Html(NextDocumentLib):
|
|
67
66
|
@overload
|
|
@@ -114,7 +113,6 @@ class Html(NextDocumentLib):
|
|
|
114
113
|
Returns:
|
|
115
114
|
The component.
|
|
116
115
|
"""
|
|
117
|
-
...
|
|
118
116
|
|
|
119
117
|
class DocumentHead(NextDocumentLib):
|
|
120
118
|
@overload
|
|
@@ -166,7 +164,6 @@ class DocumentHead(NextDocumentLib):
|
|
|
166
164
|
Returns:
|
|
167
165
|
The component.
|
|
168
166
|
"""
|
|
169
|
-
...
|
|
170
167
|
|
|
171
168
|
class Main(NextDocumentLib):
|
|
172
169
|
@overload
|
|
@@ -218,7 +215,6 @@ class Main(NextDocumentLib):
|
|
|
218
215
|
Returns:
|
|
219
216
|
The component.
|
|
220
217
|
"""
|
|
221
|
-
...
|
|
222
218
|
|
|
223
219
|
class NextScript(NextDocumentLib):
|
|
224
220
|
@overload
|
|
@@ -270,4 +266,3 @@ class NextScript(NextDocumentLib):
|
|
|
270
266
|
Returns:
|
|
271
267
|
The component.
|
|
272
268
|
"""
|
|
273
|
-
...
|
reflex/components/base/head.pyi
CHANGED
|
@@ -61,7 +61,6 @@ class NextHeadLib(Component):
|
|
|
61
61
|
Returns:
|
|
62
62
|
The component.
|
|
63
63
|
"""
|
|
64
|
-
...
|
|
65
64
|
|
|
66
65
|
class Head(NextHeadLib, MemoizationLeaf):
|
|
67
66
|
@overload
|
|
@@ -113,6 +112,5 @@ class Head(NextHeadLib, MemoizationLeaf):
|
|
|
113
112
|
Returns:
|
|
114
113
|
The memoization leaf
|
|
115
114
|
"""
|
|
116
|
-
...
|
|
117
115
|
|
|
118
116
|
head = Head.create
|
reflex/components/base/link.pyi
CHANGED
reflex/components/base/meta.py
CHANGED
|
@@ -20,7 +20,8 @@ class Title(elements.Title):
|
|
|
20
20
|
"""
|
|
21
21
|
# Make sure the title is a single string.
|
|
22
22
|
if len(self.children) != 1 or not isinstance(self.children[0], Bare):
|
|
23
|
-
|
|
23
|
+
msg = "Title must be a single string."
|
|
24
|
+
raise ValueError(msg)
|
|
24
25
|
return super().render()
|
|
25
26
|
|
|
26
27
|
|
reflex/components/base/meta.pyi
CHANGED
|
@@ -62,7 +62,6 @@ class Title(elements.Title):
|
|
|
62
62
|
Returns:
|
|
63
63
|
The component.
|
|
64
64
|
"""
|
|
65
|
-
...
|
|
66
65
|
|
|
67
66
|
class Meta(elements.Meta):
|
|
68
67
|
@overload
|
|
@@ -318,7 +317,6 @@ class Meta(elements.Meta):
|
|
|
318
317
|
Returns:
|
|
319
318
|
The component.
|
|
320
319
|
"""
|
|
321
|
-
...
|
|
322
320
|
|
|
323
321
|
class Description(elements.Meta):
|
|
324
322
|
@overload
|
|
@@ -572,7 +570,6 @@ class Description(elements.Meta):
|
|
|
572
570
|
Returns:
|
|
573
571
|
The component.
|
|
574
572
|
"""
|
|
575
|
-
...
|
|
576
573
|
|
|
577
574
|
class Image(elements.Meta):
|
|
578
575
|
@overload
|
|
@@ -828,4 +825,3 @@ class Image(elements.Meta):
|
|
|
828
825
|
Returns:
|
|
829
826
|
The component.
|
|
830
827
|
"""
|
|
831
|
-
...
|
reflex/components/base/script.py
CHANGED
|
@@ -68,7 +68,8 @@ class Script(Component):
|
|
|
68
68
|
ValueError: when neither children nor `src` are specified.
|
|
69
69
|
"""
|
|
70
70
|
if not children and not props.get("src"):
|
|
71
|
-
|
|
71
|
+
msg = "Must provide inline script or `src` prop."
|
|
72
|
+
raise ValueError(msg)
|
|
72
73
|
return super().create(*children, **props)
|
|
73
74
|
|
|
74
75
|
|