reflex 0.5.4a3__py3-none-any.whl → 0.5.5a1__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/demo/code/demo.py +1 -0
- reflex/.templates/apps/demo/code/pages/__init__.py +1 -0
- reflex/.templates/apps/demo/code/pages/datatable.py +1 -0
- reflex/.templates/apps/demo/code/pages/forms.py +1 -0
- reflex/.templates/apps/demo/code/pages/graphing.py +1 -0
- reflex/.templates/apps/demo/code/pages/home.py +1 -0
- reflex/.templates/apps/demo/code/styles.py +1 -0
- reflex/.templates/apps/demo/code/webui/components/loading_icon.py +1 -8
- reflex/.templates/web/components/reflex/chakra_color_mode_provider.js +27 -12
- reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +19 -5
- reflex/.templates/web/utils/state.js +73 -7
- reflex/__init__.py +3 -0
- reflex/__init__.pyi +3 -0
- reflex/admin.py +1 -0
- reflex/app.py +8 -6
- reflex/app_module_for_backend.py +2 -1
- reflex/base.py +4 -4
- reflex/compiler/compiler.py +4 -3
- reflex/compiler/templates.py +2 -0
- reflex/compiler/utils.py +58 -35
- reflex/components/__init__.py +1 -0
- reflex/components/base/__init__.py +1 -0
- reflex/components/base/app_wrap.py +1 -0
- reflex/components/base/fragment.py +1 -0
- reflex/components/base/link.py +0 -1
- reflex/components/base/script.py +11 -15
- reflex/components/base/script.pyi +1 -2
- reflex/components/chakra/base.py +15 -13
- reflex/components/chakra/base.pyi +3 -1
- reflex/components/chakra/datadisplay/code.py +1 -0
- reflex/components/chakra/datadisplay/divider.py +1 -0
- reflex/components/chakra/datadisplay/table.py +1 -0
- reflex/components/chakra/datadisplay/table.pyi +3 -0
- reflex/components/chakra/datadisplay/tag.py +1 -0
- reflex/components/chakra/disclosure/transition.py +1 -0
- reflex/components/chakra/feedback/circularprogress.py +1 -0
- reflex/components/chakra/forms/button.py +1 -0
- reflex/components/chakra/forms/checkbox.py +4 -13
- reflex/components/chakra/forms/checkbox.pyi +1 -3
- reflex/components/chakra/forms/colormodeswitch.py +1 -0
- reflex/components/chakra/forms/editable.py +13 -16
- reflex/components/chakra/forms/editable.pyi +1 -3
- reflex/components/chakra/forms/form.py +1 -0
- reflex/components/chakra/forms/input.py +22 -21
- reflex/components/chakra/forms/input.pyi +4 -4
- reflex/components/chakra/forms/multiselect.py +1 -0
- reflex/components/chakra/forms/numberinput.py +3 -12
- reflex/components/chakra/forms/numberinput.pyi +1 -3
- reflex/components/chakra/forms/pininput.py +8 -14
- reflex/components/chakra/forms/pininput.pyi +2 -3
- reflex/components/chakra/forms/radio.py +4 -13
- reflex/components/chakra/forms/radio.pyi +2 -3
- reflex/components/chakra/forms/rangeslider.py +10 -13
- reflex/components/chakra/forms/rangeslider.pyi +2 -3
- reflex/components/chakra/forms/select.py +4 -12
- reflex/components/chakra/forms/select.pyi +2 -3
- reflex/components/chakra/forms/slider.py +10 -13
- reflex/components/chakra/forms/slider.pyi +2 -3
- reflex/components/chakra/forms/switch.py +4 -13
- reflex/components/chakra/forms/switch.pyi +1 -3
- reflex/components/chakra/forms/textarea.py +16 -17
- reflex/components/chakra/forms/textarea.pyi +1 -3
- reflex/components/chakra/media/avatar.py +4 -12
- reflex/components/chakra/media/avatar.pyi +1 -2
- reflex/components/chakra/media/icon.py +1 -0
- reflex/components/chakra/media/image.py +7 -11
- reflex/components/chakra/media/image.pyi +2 -2
- reflex/components/chakra/navigation/link.py +8 -4
- reflex/components/chakra/navigation/link.pyi +2 -1
- reflex/components/chakra/overlay/alertdialog.py +12 -14
- reflex/components/chakra/overlay/alertdialog.pyi +1 -2
- reflex/components/chakra/overlay/drawer.py +12 -14
- reflex/components/chakra/overlay/drawer.pyi +1 -2
- reflex/components/chakra/overlay/menu.py +7 -11
- reflex/components/chakra/overlay/menu.pyi +2 -2
- reflex/components/chakra/overlay/modal.py +13 -13
- reflex/components/chakra/overlay/modal.pyi +2 -2
- reflex/components/chakra/overlay/popover.py +6 -12
- reflex/components/chakra/overlay/popover.pyi +1 -2
- reflex/components/chakra/overlay/tooltip.py +7 -13
- reflex/components/chakra/overlay/tooltip.pyi +1 -2
- reflex/components/chakra/typography/heading.py +0 -1
- reflex/components/chakra/typography/span.py +1 -0
- reflex/components/chakra/typography/text.py +1 -0
- reflex/components/component.py +70 -43
- reflex/components/core/__init__.py +1 -0
- reflex/components/core/banner.py +27 -24
- reflex/components/core/banner.pyi +6 -2
- reflex/components/core/client_side_routing.py +1 -0
- reflex/components/core/cond.py +19 -17
- reflex/components/core/debounce.py +4 -11
- reflex/components/core/debounce.pyi +1 -1
- reflex/components/core/foreach.py +1 -0
- reflex/components/core/html.py +1 -0
- reflex/components/core/match.py +9 -6
- reflex/components/core/upload.py +26 -25
- reflex/components/core/upload.pyi +3 -4
- reflex/components/datadisplay/__init__.py +1 -0
- reflex/components/datadisplay/code.py +27 -23
- reflex/components/datadisplay/code.pyi +4 -2
- reflex/components/datadisplay/dataeditor.py +73 -80
- reflex/components/datadisplay/dataeditor.pyi +52 -4
- reflex/components/datadisplay/logo.py +1 -0
- reflex/components/el/__init__.py +1 -0
- reflex/components/el/__init__.pyi +8 -0
- reflex/components/el/element.py +0 -1
- reflex/components/el/elements/__init__.py +5 -0
- reflex/components/el/elements/__init__.pyi +12 -1
- reflex/components/el/elements/base.py +1 -0
- reflex/components/el/elements/forms.py +44 -61
- reflex/components/el/elements/forms.pyi +4 -6
- reflex/components/el/elements/inline.py +1 -0
- reflex/components/el/elements/media.py +53 -0
- reflex/components/el/elements/media.pyi +428 -0
- reflex/components/el/elements/metadata.py +11 -0
- reflex/components/el/elements/metadata.pyi +80 -0
- reflex/components/el/elements/other.py +1 -0
- reflex/components/el/elements/scripts.py +1 -0
- reflex/components/el/elements/tables.py +1 -0
- reflex/components/el/elements/typography.py +1 -0
- reflex/components/gridjs/datatable.py +9 -6
- reflex/components/gridjs/datatable.pyi +4 -1
- reflex/components/markdown/markdown.py +36 -41
- reflex/components/markdown/markdown.pyi +4 -3
- reflex/components/media/icon.py +1 -0
- reflex/components/moment/moment.py +11 -17
- reflex/components/moment/moment.pyi +4 -3
- reflex/components/next/base.py +1 -0
- reflex/components/next/image.py +6 -11
- reflex/components/next/image.pyi +2 -2
- reflex/components/plotly/plotly.py +1 -0
- reflex/components/props.py +1 -0
- reflex/components/radix/__init__.py +1 -0
- reflex/components/radix/primitives/__init__.py +1 -0
- reflex/components/radix/primitives/accordion.py +7 -15
- reflex/components/radix/primitives/accordion.pyi +7 -4
- reflex/components/radix/primitives/base.py +1 -0
- reflex/components/radix/primitives/drawer.py +17 -27
- reflex/components/radix/primitives/drawer.pyi +2 -4
- reflex/components/radix/primitives/form.py +4 -12
- reflex/components/radix/primitives/form.pyi +2 -3
- reflex/components/radix/primitives/slider.py +6 -11
- reflex/components/radix/primitives/slider.pyi +2 -2
- reflex/components/radix/themes/__init__.py +1 -0
- reflex/components/radix/themes/base.py +3 -3
- reflex/components/radix/themes/base.pyi +3 -2
- reflex/components/radix/themes/color_mode.py +31 -2
- reflex/components/radix/themes/color_mode.pyi +10 -1
- reflex/components/radix/themes/components/__init__.py +1 -0
- reflex/components/radix/themes/components/alert_dialog.py +13 -24
- reflex/components/radix/themes/components/alert_dialog.pyi +2 -4
- reflex/components/radix/themes/components/aspect_ratio.py +1 -0
- reflex/components/radix/themes/components/card.py +1 -0
- reflex/components/radix/themes/components/checkbox.py +6 -22
- reflex/components/radix/themes/components/checkbox.pyi +2 -4
- reflex/components/radix/themes/components/checkbox_group.py +15 -3
- reflex/components/radix/themes/components/checkbox_group.pyi +10 -2
- reflex/components/radix/themes/components/context_menu.py +29 -38
- reflex/components/radix/themes/components/context_menu.pyi +2 -5
- reflex/components/radix/themes/components/dialog.py +18 -26
- reflex/components/radix/themes/components/dialog.pyi +2 -4
- reflex/components/radix/themes/components/dropdown_menu.py +32 -57
- reflex/components/radix/themes/components/dropdown_menu.pyi +2 -7
- reflex/components/radix/themes/components/hover_card.py +5 -12
- reflex/components/radix/themes/components/hover_card.pyi +2 -3
- reflex/components/radix/themes/components/icon_button.py +1 -0
- reflex/components/radix/themes/components/icon_button.pyi +1 -0
- reflex/components/radix/themes/components/inset.py +1 -0
- reflex/components/radix/themes/components/popover.py +22 -27
- reflex/components/radix/themes/components/popover.pyi +2 -4
- reflex/components/radix/themes/components/radio_group.py +25 -17
- reflex/components/radix/themes/components/radio_group.pyi +2 -3
- reflex/components/radix/themes/components/scroll_area.py +1 -0
- reflex/components/radix/themes/components/segmented_control.py +18 -5
- reflex/components/radix/themes/components/segmented_control.pyi +16 -7
- reflex/components/radix/themes/components/select.py +13 -23
- reflex/components/radix/themes/components/select.pyi +1 -4
- reflex/components/radix/themes/components/separator.py +1 -0
- reflex/components/radix/themes/components/slider.py +7 -12
- reflex/components/radix/themes/components/slider.pyi +2 -3
- reflex/components/radix/themes/components/switch.py +5 -12
- reflex/components/radix/themes/components/switch.pyi +2 -3
- reflex/components/radix/themes/components/table.py +1 -0
- reflex/components/radix/themes/components/tabs.py +4 -11
- reflex/components/radix/themes/components/tabs.pyi +2 -2
- reflex/components/radix/themes/components/text_area.py +19 -18
- reflex/components/radix/themes/components/text_area.pyi +2 -3
- reflex/components/radix/themes/components/text_field.py +19 -18
- reflex/components/radix/themes/components/text_field.pyi +3 -3
- reflex/components/radix/themes/components/tooltip.py +10 -13
- reflex/components/radix/themes/components/tooltip.pyi +2 -3
- reflex/components/radix/themes/layout/__init__.py +1 -0
- reflex/components/radix/themes/layout/box.py +1 -0
- reflex/components/radix/themes/layout/container.py +1 -0
- reflex/components/radix/themes/layout/list.py +1 -0
- reflex/components/radix/themes/layout/list.pyi +1 -0
- reflex/components/radix/themes/layout/section.py +1 -0
- reflex/components/radix/themes/typography/__init__.py +1 -0
- reflex/components/radix/themes/typography/base.py +1 -0
- reflex/components/radix/themes/typography/blockquote.py +1 -0
- reflex/components/radix/themes/typography/code.py +1 -0
- reflex/components/radix/themes/typography/heading.py +1 -0
- reflex/components/radix/themes/typography/link.py +8 -3
- reflex/components/radix/themes/typography/link.pyi +2 -1
- reflex/components/react_player/audio.py +1 -0
- reflex/components/react_player/audio.pyi +48 -0
- reflex/components/react_player/react_player.py +49 -0
- reflex/components/react_player/react_player.pyi +49 -0
- reflex/components/react_player/video.py +1 -0
- reflex/components/react_player/video.pyi +48 -0
- reflex/components/recharts/__init__.py +1 -0
- reflex/components/recharts/cartesian.py +264 -74
- reflex/components/recharts/cartesian.pyi +573 -58
- reflex/components/recharts/charts.py +68 -78
- reflex/components/recharts/charts.pyi +373 -156
- reflex/components/recharts/general.py +52 -20
- reflex/components/recharts/general.pyi +52 -6
- reflex/components/recharts/polar.py +30 -18
- reflex/components/recharts/polar.pyi +66 -5
- reflex/components/recharts/recharts.py +5 -3
- reflex/components/recharts/recharts.pyi +2 -1
- reflex/components/sonner/toast.py +2 -2
- reflex/components/sonner/toast.pyi +1 -1
- reflex/components/suneditor/editor.py +39 -26
- reflex/components/suneditor/editor.pyi +4 -4
- reflex/components/tags/iter_tag.py +1 -0
- reflex/constants/__init__.py +3 -2
- reflex/constants/base.py +20 -21
- reflex/constants/compiler.py +3 -1
- reflex/constants/config.py +1 -0
- reflex/constants/event.py +1 -0
- reflex/constants/installer.py +3 -2
- reflex/constants/style.py +2 -8
- reflex/event.py +36 -6
- reflex/experimental/assets.py +1 -0
- reflex/experimental/client_state.py +9 -3
- reflex/experimental/hooks.py +1 -0
- reflex/experimental/misc.py +12 -3
- reflex/middleware/hydrate_middleware.py +1 -0
- reflex/middleware/middleware.py +1 -0
- reflex/state.py +38 -1
- reflex/style.py +67 -20
- reflex/testing.py +6 -2
- reflex/utils/build.py +76 -72
- reflex/utils/exec.py +17 -9
- reflex/utils/export.py +13 -9
- reflex/utils/imports.py +34 -5
- reflex/utils/lazy_loader.py +1 -0
- reflex/utils/path_ops.py +39 -33
- reflex/utils/prerequisites.py +35 -27
- reflex/utils/processes.py +1 -1
- reflex/utils/serializers.py +3 -6
- reflex/utils/watch.py +3 -1
- reflex/vars.py +26 -10
- reflex/vars.pyi +3 -3
- {reflex-0.5.4a3.dist-info → reflex-0.5.5a1.dist-info}/METADATA +2 -2
- {reflex-0.5.4a3.dist-info → reflex-0.5.5a1.dist-info}/RECORD +260 -260
- {reflex-0.5.4a3.dist-info → reflex-0.5.5a1.dist-info}/LICENSE +0 -0
- {reflex-0.5.4a3.dist-info → reflex-0.5.5a1.dist-info}/WHEEL +0 -0
- {reflex-0.5.4a3.dist-info → reflex-0.5.5a1.dist-info}/entry_points.txt +0 -0
reflex/utils/prerequisites.py
CHANGED
|
@@ -58,6 +58,18 @@ class CpuInfo(Base):
|
|
|
58
58
|
address_width: Optional[int]
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
def get_web_dir() -> Path:
|
|
62
|
+
"""Get the working directory for the next.js commands.
|
|
63
|
+
|
|
64
|
+
Can be overriden with REFLEX_WEB_WORKDIR.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
The working directory.
|
|
68
|
+
"""
|
|
69
|
+
workdir = Path(os.getenv("REFLEX_WEB_WORKDIR", constants.Dirs.WEB))
|
|
70
|
+
return workdir
|
|
71
|
+
|
|
72
|
+
|
|
61
73
|
def check_latest_package_version(package_name: str):
|
|
62
74
|
"""Check if the latest version of the package is installed.
|
|
63
75
|
|
|
@@ -91,15 +103,15 @@ def get_or_set_last_reflex_version_check_datetime():
|
|
|
91
103
|
Returns:
|
|
92
104
|
The last version check datetime.
|
|
93
105
|
"""
|
|
94
|
-
|
|
106
|
+
reflex_json_file = get_web_dir() / constants.Reflex.JSON
|
|
107
|
+
if not reflex_json_file.exists():
|
|
95
108
|
return None
|
|
96
109
|
# Open and read the file
|
|
97
|
-
|
|
98
|
-
data: dict = json.load(file)
|
|
110
|
+
data = json.loads(reflex_json_file.read_text())
|
|
99
111
|
last_version_check_datetime = data.get("last_version_check_datetime")
|
|
100
112
|
if not last_version_check_datetime:
|
|
101
113
|
data.update({"last_version_check_datetime": str(datetime.now())})
|
|
102
|
-
path_ops.update_json_file(
|
|
114
|
+
path_ops.update_json_file(reflex_json_file, data)
|
|
103
115
|
return last_version_check_datetime
|
|
104
116
|
|
|
105
117
|
|
|
@@ -513,12 +525,11 @@ def get_project_hash(raise_on_fail: bool = False) -> int | None:
|
|
|
513
525
|
Returns:
|
|
514
526
|
project_hash: The app hash.
|
|
515
527
|
"""
|
|
516
|
-
|
|
528
|
+
json_file = get_web_dir() / constants.Reflex.JSON
|
|
529
|
+
if not json_file.exists() and not raise_on_fail:
|
|
517
530
|
return None
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
data = json.load(file)
|
|
521
|
-
return data.get("project_hash")
|
|
531
|
+
data = json.loads(json_file.read_text())
|
|
532
|
+
return data.get("project_hash")
|
|
522
533
|
|
|
523
534
|
|
|
524
535
|
def initialize_web_directory():
|
|
@@ -528,11 +539,11 @@ def initialize_web_directory():
|
|
|
528
539
|
# Re-use the hash if one is already created, so we don't over-write it when running reflex init
|
|
529
540
|
project_hash = get_project_hash()
|
|
530
541
|
|
|
531
|
-
path_ops.cp(constants.Templates.Dirs.WEB_TEMPLATE,
|
|
542
|
+
path_ops.cp(constants.Templates.Dirs.WEB_TEMPLATE, str(get_web_dir()))
|
|
532
543
|
|
|
533
544
|
initialize_package_json()
|
|
534
545
|
|
|
535
|
-
path_ops.mkdir(constants.Dirs.
|
|
546
|
+
path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC)
|
|
536
547
|
|
|
537
548
|
update_next_config()
|
|
538
549
|
|
|
@@ -555,10 +566,9 @@ def _compile_package_json():
|
|
|
555
566
|
|
|
556
567
|
def initialize_package_json():
|
|
557
568
|
"""Render and write in .web the package.json file."""
|
|
558
|
-
output_path = constants.PackageJson.PATH
|
|
569
|
+
output_path = get_web_dir() / constants.PackageJson.PATH
|
|
559
570
|
code = _compile_package_json()
|
|
560
|
-
|
|
561
|
-
file.write(code)
|
|
571
|
+
output_path.write_text(code)
|
|
562
572
|
|
|
563
573
|
|
|
564
574
|
def init_reflex_json(project_hash: int | None):
|
|
@@ -583,7 +593,7 @@ def init_reflex_json(project_hash: int | None):
|
|
|
583
593
|
"version": constants.Reflex.VERSION,
|
|
584
594
|
"project_hash": project_hash,
|
|
585
595
|
}
|
|
586
|
-
path_ops.update_json_file(constants.Reflex.JSON, reflex_json)
|
|
596
|
+
path_ops.update_json_file(get_web_dir() / constants.Reflex.JSON, reflex_json)
|
|
587
597
|
|
|
588
598
|
|
|
589
599
|
def update_next_config(export=False, transpile_packages: Optional[List[str]] = None):
|
|
@@ -593,7 +603,7 @@ def update_next_config(export=False, transpile_packages: Optional[List[str]] = N
|
|
|
593
603
|
export: if the method run during reflex export.
|
|
594
604
|
transpile_packages: list of packages to transpile via next.config.js.
|
|
595
605
|
"""
|
|
596
|
-
next_config_file =
|
|
606
|
+
next_config_file = get_web_dir() / constants.Next.CONFIG_FILE
|
|
597
607
|
|
|
598
608
|
next_config = _update_next_config(
|
|
599
609
|
get_config(), export=export, transpile_packages=transpile_packages
|
|
@@ -845,9 +855,7 @@ def cached_procedure(cache_file: str, payload_fn: Callable[..., str]):
|
|
|
845
855
|
|
|
846
856
|
|
|
847
857
|
@cached_procedure(
|
|
848
|
-
cache_file=
|
|
849
|
-
constants.Dirs.WEB, "reflex.install_frontend_packages.cached"
|
|
850
|
-
),
|
|
858
|
+
cache_file=str(get_web_dir() / "reflex.install_frontend_packages.cached"),
|
|
851
859
|
payload_fn=lambda p, c: f"{repr(sorted(list(p)))},{c.json()}",
|
|
852
860
|
)
|
|
853
861
|
def install_frontend_packages(packages: set[str], config: Config):
|
|
@@ -874,7 +882,7 @@ def install_frontend_packages(packages: set[str], config: Config):
|
|
|
874
882
|
fallback=fallback_command,
|
|
875
883
|
analytics_enabled=True,
|
|
876
884
|
show_status_message="Installing base frontend packages",
|
|
877
|
-
cwd=
|
|
885
|
+
cwd=get_web_dir(),
|
|
878
886
|
shell=constants.IS_WINDOWS,
|
|
879
887
|
)
|
|
880
888
|
|
|
@@ -890,7 +898,7 @@ def install_frontend_packages(packages: set[str], config: Config):
|
|
|
890
898
|
fallback=fallback_command,
|
|
891
899
|
analytics_enabled=True,
|
|
892
900
|
show_status_message="Installing tailwind",
|
|
893
|
-
cwd=
|
|
901
|
+
cwd=get_web_dir(),
|
|
894
902
|
shell=constants.IS_WINDOWS,
|
|
895
903
|
)
|
|
896
904
|
|
|
@@ -901,7 +909,7 @@ def install_frontend_packages(packages: set[str], config: Config):
|
|
|
901
909
|
fallback=fallback_command,
|
|
902
910
|
analytics_enabled=True,
|
|
903
911
|
show_status_message="Installing frontend packages from config and components",
|
|
904
|
-
cwd=
|
|
912
|
+
cwd=get_web_dir(),
|
|
905
913
|
shell=constants.IS_WINDOWS,
|
|
906
914
|
)
|
|
907
915
|
|
|
@@ -933,7 +941,7 @@ def needs_reinit(frontend: bool = True) -> bool:
|
|
|
933
941
|
return True
|
|
934
942
|
|
|
935
943
|
# Make sure the .web directory exists in frontend mode.
|
|
936
|
-
if not
|
|
944
|
+
if not get_web_dir().exists():
|
|
937
945
|
return True
|
|
938
946
|
|
|
939
947
|
# If the template is out of date, then we need to re-init
|
|
@@ -971,10 +979,10 @@ def is_latest_template() -> bool:
|
|
|
971
979
|
Returns:
|
|
972
980
|
Whether the app is using the latest template.
|
|
973
981
|
"""
|
|
974
|
-
|
|
982
|
+
json_file = get_web_dir() / constants.Reflex.JSON
|
|
983
|
+
if not json_file.exists():
|
|
975
984
|
return False
|
|
976
|
-
|
|
977
|
-
app_version = json.load(f)["version"]
|
|
985
|
+
app_version = json.load(json_file.open()).get("version")
|
|
978
986
|
return app_version == constants.Reflex.VERSION
|
|
979
987
|
|
|
980
988
|
|
|
@@ -1170,7 +1178,7 @@ def should_show_rx_chakra_migration_instructions() -> bool:
|
|
|
1170
1178
|
return False
|
|
1171
1179
|
|
|
1172
1180
|
existing_init_reflex_version = None
|
|
1173
|
-
reflex_json =
|
|
1181
|
+
reflex_json = get_web_dir() / constants.Dirs.REFLEX_JSON
|
|
1174
1182
|
if reflex_json.exists():
|
|
1175
1183
|
with reflex_json.open("r") as f:
|
|
1176
1184
|
data = json.load(f)
|
reflex/utils/processes.py
CHANGED
|
@@ -185,7 +185,7 @@ def new_process(args, run: bool = False, show_logs: bool = False, **kwargs):
|
|
|
185
185
|
|
|
186
186
|
@contextlib.contextmanager
|
|
187
187
|
def run_concurrently_context(
|
|
188
|
-
*fns: Union[Callable, Tuple]
|
|
188
|
+
*fns: Union[Callable, Tuple],
|
|
189
189
|
) -> Generator[list[futures.Future], None, None]:
|
|
190
190
|
"""Run functions concurrently in a thread pool.
|
|
191
191
|
|
reflex/utils/serializers.py
CHANGED
|
@@ -94,18 +94,15 @@ def serializer(
|
|
|
94
94
|
@overload
|
|
95
95
|
def serialize(
|
|
96
96
|
value: Any, get_type: Literal[True]
|
|
97
|
-
) -> Tuple[Optional[SerializedType], Optional[types.GenericType]]:
|
|
98
|
-
...
|
|
97
|
+
) -> Tuple[Optional[SerializedType], Optional[types.GenericType]]: ...
|
|
99
98
|
|
|
100
99
|
|
|
101
100
|
@overload
|
|
102
|
-
def serialize(value: Any, get_type: Literal[False]) -> Optional[SerializedType]:
|
|
103
|
-
...
|
|
101
|
+
def serialize(value: Any, get_type: Literal[False]) -> Optional[SerializedType]: ...
|
|
104
102
|
|
|
105
103
|
|
|
106
104
|
@overload
|
|
107
|
-
def serialize(value: Any) -> Optional[SerializedType]:
|
|
108
|
-
...
|
|
105
|
+
def serialize(value: Any) -> Optional[SerializedType]: ...
|
|
109
106
|
|
|
110
107
|
|
|
111
108
|
def serialize(
|
reflex/utils/watch.py
CHANGED
|
@@ -9,6 +9,7 @@ from watchdog.events import FileSystemEvent, FileSystemEventHandler
|
|
|
9
9
|
from watchdog.observers import Observer
|
|
10
10
|
|
|
11
11
|
from reflex.constants import Dirs
|
|
12
|
+
from reflex.utils.prerequisites import get_web_dir
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class AssetFolderWatch:
|
|
@@ -90,5 +91,6 @@ class AssetFolderHandler(FileSystemEventHandler):
|
|
|
90
91
|
The public file path.
|
|
91
92
|
"""
|
|
92
93
|
return src_path.replace(
|
|
93
|
-
str(self.root / Dirs.APP_ASSETS),
|
|
94
|
+
str(self.root / Dirs.APP_ASSETS),
|
|
95
|
+
str(self.root / get_web_dir() / Dirs.PUBLIC),
|
|
94
96
|
)
|
reflex/vars.py
CHANGED
|
@@ -39,7 +39,12 @@ from reflex.utils import console, imports, serializers, types
|
|
|
39
39
|
from reflex.utils.exceptions import VarAttributeError, VarTypeError, VarValueError
|
|
40
40
|
|
|
41
41
|
# This module used to export ImportVar itself, so we still import it for export here
|
|
42
|
-
from reflex.utils.imports import
|
|
42
|
+
from reflex.utils.imports import (
|
|
43
|
+
ImportDict,
|
|
44
|
+
ImportVar,
|
|
45
|
+
ParsedImportDict,
|
|
46
|
+
parse_imports,
|
|
47
|
+
)
|
|
43
48
|
from reflex.utils.types import override
|
|
44
49
|
|
|
45
50
|
if TYPE_CHECKING:
|
|
@@ -120,7 +125,7 @@ class VarData(Base):
|
|
|
120
125
|
state: str = ""
|
|
121
126
|
|
|
122
127
|
# Imports needed to render this var
|
|
123
|
-
imports:
|
|
128
|
+
imports: ParsedImportDict = {}
|
|
124
129
|
|
|
125
130
|
# Hooks that need to be present in the component to render this var
|
|
126
131
|
hooks: Dict[str, None] = {}
|
|
@@ -130,6 +135,19 @@ class VarData(Base):
|
|
|
130
135
|
# segments.
|
|
131
136
|
interpolations: List[Tuple[int, int]] = []
|
|
132
137
|
|
|
138
|
+
def __init__(
|
|
139
|
+
self, imports: Union[ImportDict, ParsedImportDict] | None = None, **kwargs: Any
|
|
140
|
+
):
|
|
141
|
+
"""Initialize the var data.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
imports: The imports needed to render this var.
|
|
145
|
+
**kwargs: The var data fields.
|
|
146
|
+
"""
|
|
147
|
+
if imports:
|
|
148
|
+
kwargs["imports"] = parse_imports(imports)
|
|
149
|
+
super().__init__(**kwargs)
|
|
150
|
+
|
|
133
151
|
@classmethod
|
|
134
152
|
def merge(cls, *others: VarData | None) -> VarData | None:
|
|
135
153
|
"""Merge multiple var data objects.
|
|
@@ -464,7 +482,7 @@ class Var:
|
|
|
464
482
|
self._var_name = _var_name
|
|
465
483
|
self._var_data = VarData.merge(self._var_data, _var_data)
|
|
466
484
|
|
|
467
|
-
def _replace(self, merge_var_data=None, **kwargs: Any) ->
|
|
485
|
+
def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar:
|
|
468
486
|
"""Make a copy of this Var with updated fields.
|
|
469
487
|
|
|
470
488
|
Args:
|
|
@@ -1774,18 +1792,16 @@ class Var:
|
|
|
1774
1792
|
"""
|
|
1775
1793
|
from reflex.style import Style
|
|
1776
1794
|
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
else self._var_type
|
|
1781
|
-
)
|
|
1795
|
+
generic_alias = types.is_generic_alias(self._var_type)
|
|
1796
|
+
|
|
1797
|
+
type_ = get_origin(self._var_type) if generic_alias else self._var_type
|
|
1782
1798
|
wrapped_var = str(self)
|
|
1783
1799
|
|
|
1784
1800
|
return (
|
|
1785
1801
|
wrapped_var
|
|
1786
1802
|
if not self._var_state
|
|
1787
|
-
and
|
|
1788
|
-
or types._issubclass(type_, Style)
|
|
1803
|
+
and not generic_alias
|
|
1804
|
+
and (types._issubclass(type_, dict) or types._issubclass(type_, Style))
|
|
1789
1805
|
else wrapped_var.strip("{}")
|
|
1790
1806
|
)
|
|
1791
1807
|
|
reflex/vars.pyi
CHANGED
|
@@ -10,7 +10,7 @@ from reflex.base import Base as Base
|
|
|
10
10
|
from reflex.state import State as State
|
|
11
11
|
from reflex.state import BaseState as BaseState
|
|
12
12
|
from reflex.utils import console as console, format as format, types as types
|
|
13
|
-
from reflex.utils.imports import ImportVar
|
|
13
|
+
from reflex.utils.imports import ImportVar, ImportDict, ParsedImportDict
|
|
14
14
|
from types import FunctionType
|
|
15
15
|
from typing import (
|
|
16
16
|
Any,
|
|
@@ -36,7 +36,7 @@ def _extract_var_data(value: Iterable) -> list[VarData | None]: ...
|
|
|
36
36
|
|
|
37
37
|
class VarData(Base):
|
|
38
38
|
state: str = ""
|
|
39
|
-
imports:
|
|
39
|
+
imports: Union[ImportDict, ParsedImportDict] = {}
|
|
40
40
|
hooks: Dict[str, None] = {}
|
|
41
41
|
interpolations: List[Tuple[int, int]] = []
|
|
42
42
|
@classmethod
|
|
@@ -59,7 +59,7 @@ class Var:
|
|
|
59
59
|
) -> Var: ...
|
|
60
60
|
@classmethod
|
|
61
61
|
def __class_getitem__(cls, type_: Type) -> _GenericAlias: ...
|
|
62
|
-
def _replace(self, merge_var_data=None, **kwargs: Any) ->
|
|
62
|
+
def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar: ...
|
|
63
63
|
def equals(self, other: Var) -> bool: ...
|
|
64
64
|
def to_string(self) -> Var: ...
|
|
65
65
|
def __hash__(self) -> int: ...
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: reflex
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.5a1
|
|
4
4
|
Summary: Web apps in pure Python.
|
|
5
5
|
Home-page: https://reflex.dev
|
|
6
6
|
License: Apache-2.0
|
|
@@ -21,7 +21,7 @@ Requires-Dist: build (>=1.0.3,<2.0)
|
|
|
21
21
|
Requires-Dist: charset-normalizer (>=3.3.2,<4.0)
|
|
22
22
|
Requires-Dist: dill (>=0.3.8,<0.4)
|
|
23
23
|
Requires-Dist: distro (>=1.8.0,<2.0) ; sys_platform == "linux"
|
|
24
|
-
Requires-Dist: fastapi (>=0.96.0,<
|
|
24
|
+
Requires-Dist: fastapi (>=0.96.0,<0.111.0)
|
|
25
25
|
Requires-Dist: gunicorn (>=20.1.0,<23.0)
|
|
26
26
|
Requires-Dist: httpx (>=0.25.1,<1.0)
|
|
27
27
|
Requires-Dist: jinja2 (>=3.1.2,<4.0)
|