reflex 0.7.12__py3-none-any.whl → 0.7.13a1__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/jinja/app/rxconfig.py.jinja2 +1 -0
- reflex/.templates/web/postcss.config.js +0 -1
- reflex/.templates/web/utils/state.js +1 -1
- reflex/__init__.py +1 -0
- reflex/__init__.pyi +1 -0
- reflex/app.py +87 -27
- reflex/compiler/compiler.py +11 -62
- reflex/compiler/templates.py +12 -3
- reflex/compiler/utils.py +20 -4
- reflex/components/component.py +366 -88
- reflex/components/datadisplay/code.py +1 -1
- reflex/components/datadisplay/shiki_code_block.py +97 -86
- reflex/components/datadisplay/shiki_code_block.pyi +4 -2
- reflex/components/el/elements/forms.py +1 -1
- reflex/components/lucide/icon.py +2 -1
- reflex/components/lucide/icon.pyi +1 -0
- reflex/components/plotly/plotly.py +2 -2
- reflex/components/plotly/plotly.pyi +2 -3
- reflex/components/radix/themes/base.py +4 -11
- reflex/components/radix/themes/components/icon_button.py +2 -2
- reflex/components/radix/themes/components/text_field.py +3 -0
- reflex/components/radix/themes/components/text_field.pyi +2 -0
- reflex/components/radix/themes/layout/list.py +1 -1
- reflex/components/tags/iter_tag.py +3 -5
- reflex/config.py +54 -7
- reflex/constants/__init__.py +0 -2
- reflex/event.py +154 -93
- reflex/plugins/__init__.py +7 -0
- reflex/plugins/base.py +101 -0
- reflex/plugins/tailwind_v3.py +255 -0
- reflex/plugins/tailwind_v4.py +257 -0
- reflex/state.py +24 -3
- reflex/utils/build.py +1 -1
- reflex/utils/console.py +1 -1
- reflex/utils/exec.py +18 -0
- reflex/utils/path_ops.py +26 -6
- reflex/utils/prerequisites.py +21 -90
- reflex/utils/pyi_generator.py +12 -2
- reflex/utils/types.py +15 -1
- reflex/vars/base.py +59 -4
- reflex/vars/object.py +8 -0
- {reflex-0.7.12.dist-info → reflex-0.7.13a1.dist-info}/METADATA +2 -2
- {reflex-0.7.12.dist-info → reflex-0.7.13a1.dist-info}/RECORD +47 -46
- scripts/hatch_build.py +17 -0
- reflex/.templates/jinja/web/tailwind.config.js.jinja2 +0 -66
- reflex/.templates/web/styles/tailwind.css +0 -6
- reflex/constants/style.py +0 -16
- {reflex-0.7.12.dist-info → reflex-0.7.13a1.dist-info}/WHEEL +0 -0
- {reflex-0.7.12.dist-info → reflex-0.7.13a1.dist-info}/entry_points.txt +0 -0
- {reflex-0.7.12.dist-info → reflex-0.7.13a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import dataclasses
|
|
5
6
|
import re
|
|
6
7
|
from collections import defaultdict
|
|
8
|
+
from dataclasses import dataclass
|
|
7
9
|
from typing import Any, Literal
|
|
8
10
|
|
|
9
|
-
from reflex.base import Base
|
|
10
11
|
from reflex.components.component import Component, ComponentNamespace
|
|
11
12
|
from reflex.components.core.colors import color
|
|
12
13
|
from reflex.components.core.cond import color_mode_cond
|
|
@@ -410,99 +411,109 @@ class ShikiDecorations(NoExtrasAllowedProps):
|
|
|
410
411
|
always_wrap: bool = False
|
|
411
412
|
|
|
412
413
|
|
|
413
|
-
|
|
414
|
+
@dataclass(kw_only=True)
|
|
415
|
+
class ShikiBaseTransformers:
|
|
414
416
|
"""Base for creating transformers."""
|
|
415
417
|
|
|
416
|
-
library: str
|
|
417
|
-
fns: list[FunctionStringVar]
|
|
418
|
-
style: Style | None
|
|
418
|
+
library: str = ""
|
|
419
|
+
fns: list[FunctionStringVar] = dataclasses.field(default_factory=list)
|
|
420
|
+
style: Style | None = dataclasses.field(default=None)
|
|
419
421
|
|
|
420
422
|
|
|
423
|
+
@dataclass(kw_only=True)
|
|
421
424
|
class ShikiJsTransformer(ShikiBaseTransformers):
|
|
422
425
|
"""A Wrapped shikijs transformer."""
|
|
423
426
|
|
|
424
427
|
library: str = "@shikijs/transformers@3.3.0"
|
|
425
|
-
fns: list[FunctionStringVar] =
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
"
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
"
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
"
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
"
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
"
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
"
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
"
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
428
|
+
fns: list[FunctionStringVar] = dataclasses.field(
|
|
429
|
+
default_factory=lambda: [
|
|
430
|
+
FunctionStringVar.create(fn) for fn in SHIKIJS_TRANSFORMER_FNS
|
|
431
|
+
]
|
|
432
|
+
)
|
|
433
|
+
style: Style | None = dataclasses.field(
|
|
434
|
+
default_factory=lambda: Style(
|
|
435
|
+
{
|
|
436
|
+
"code": {
|
|
437
|
+
"line-height": "1.7",
|
|
438
|
+
"font-size": "0.875em",
|
|
439
|
+
"display": "grid",
|
|
440
|
+
},
|
|
441
|
+
# Diffs
|
|
442
|
+
".diff": {
|
|
443
|
+
"margin": "0 -24px",
|
|
444
|
+
"padding": "0 24px",
|
|
445
|
+
"width": "calc(100% + 48px)",
|
|
446
|
+
"display": "inline-block",
|
|
447
|
+
},
|
|
448
|
+
".diff.add": {
|
|
449
|
+
"background-color": "rgba(16, 185, 129, .14)",
|
|
450
|
+
"position": "relative",
|
|
451
|
+
},
|
|
452
|
+
".diff.remove": {
|
|
453
|
+
"background-color": "rgba(244, 63, 94, .14)",
|
|
454
|
+
"opacity": "0.7",
|
|
455
|
+
"position": "relative",
|
|
456
|
+
},
|
|
457
|
+
".diff.remove:after": {
|
|
458
|
+
"position": "absolute",
|
|
459
|
+
"left": "10px",
|
|
460
|
+
"content": "'-'",
|
|
461
|
+
"color": "#b34e52",
|
|
462
|
+
},
|
|
463
|
+
".diff.add:after": {
|
|
464
|
+
"position": "absolute",
|
|
465
|
+
"left": "10px",
|
|
466
|
+
"content": "'+'",
|
|
467
|
+
"color": "#18794e",
|
|
468
|
+
},
|
|
469
|
+
# Highlight
|
|
470
|
+
".highlighted": {
|
|
471
|
+
"background-color": "rgba(142, 150, 170, .14)",
|
|
472
|
+
"margin": "0 -24px",
|
|
473
|
+
"padding": "0 24px",
|
|
474
|
+
"width": "calc(100% + 48px)",
|
|
475
|
+
"display": "inline-block",
|
|
476
|
+
},
|
|
477
|
+
".highlighted.error": {
|
|
478
|
+
"background-color": "rgba(244, 63, 94, .14)",
|
|
479
|
+
},
|
|
480
|
+
".highlighted.warning": {
|
|
481
|
+
"background-color": "rgba(234, 179, 8, .14)",
|
|
482
|
+
},
|
|
483
|
+
# Highlighted Word
|
|
484
|
+
".highlighted-word": {
|
|
485
|
+
"background-color": color("gray", 2),
|
|
486
|
+
"border": f"1px solid {color('gray', 5)}",
|
|
487
|
+
"padding": "1px 3px",
|
|
488
|
+
"margin": "-1px -3px",
|
|
489
|
+
"border-radius": "4px",
|
|
490
|
+
},
|
|
491
|
+
# Focused Lines
|
|
492
|
+
".has-focused .line:not(.focused)": {
|
|
493
|
+
"opacity": "0.7",
|
|
494
|
+
"filter": "blur(0.095rem)",
|
|
495
|
+
"transition": "filter .35s, opacity .35s",
|
|
496
|
+
},
|
|
497
|
+
".has-focused:hover .line:not(.focused)": {
|
|
498
|
+
"opacity": "1",
|
|
499
|
+
"filter": "none",
|
|
500
|
+
},
|
|
501
|
+
# White Space
|
|
502
|
+
# ".tab, .space": {
|
|
503
|
+
# "position": "relative", # noqa: ERA001
|
|
504
|
+
# },
|
|
505
|
+
# ".tab::before": {
|
|
506
|
+
# "content": "'⇥'", # noqa: ERA001
|
|
507
|
+
# "position": "absolute", # noqa: ERA001
|
|
508
|
+
# "opacity": "0.3",# noqa: ERA001
|
|
509
|
+
# },
|
|
510
|
+
# ".space::before": {
|
|
511
|
+
# "content": "'·'", # noqa: ERA001
|
|
512
|
+
# "position": "absolute", # noqa: ERA001
|
|
513
|
+
# "opacity": "0.3", # noqa: ERA001
|
|
514
|
+
# },
|
|
515
|
+
}
|
|
516
|
+
)
|
|
506
517
|
)
|
|
507
518
|
|
|
508
519
|
def __init__(self, **kwargs):
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
|
5
5
|
# ------------------------------------------------------
|
|
6
6
|
from collections.abc import Mapping, Sequence
|
|
7
|
+
from dataclasses import dataclass
|
|
7
8
|
from typing import Any, Literal, overload
|
|
8
9
|
|
|
9
|
-
from reflex.base import Base
|
|
10
10
|
from reflex.components.component import Component, ComponentNamespace
|
|
11
11
|
from reflex.components.core.breakpoints import Breakpoints
|
|
12
12
|
from reflex.components.markdown.markdown import MarkdownComponentMap
|
|
@@ -343,11 +343,13 @@ class ShikiDecorations(NoExtrasAllowedProps):
|
|
|
343
343
|
properties: dict[str, Any]
|
|
344
344
|
always_wrap: bool
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
@dataclass(kw_only=True)
|
|
347
|
+
class ShikiBaseTransformers:
|
|
347
348
|
library: str
|
|
348
349
|
fns: list[FunctionStringVar]
|
|
349
350
|
style: Style | None
|
|
350
351
|
|
|
352
|
+
@dataclass(kw_only=True)
|
|
351
353
|
class ShikiJsTransformer(ShikiBaseTransformers):
|
|
352
354
|
library: str
|
|
353
355
|
fns: list[FunctionStringVar]
|
|
@@ -189,7 +189,7 @@ class Form(BaseHTML):
|
|
|
189
189
|
# Render the form hooks and use the hash of the resulting code to create a unique name.
|
|
190
190
|
props["handle_submit_unique_name"] = ""
|
|
191
191
|
form = super().create(*children, **props)
|
|
192
|
-
form.handle_submit_unique_name = md5(
|
|
192
|
+
form.handle_submit_unique_name = md5( # pyright: ignore[reportAttributeAccessIssue]
|
|
193
193
|
str(form._get_all_hooks()).encode("utf-8")
|
|
194
194
|
).hexdigest()
|
|
195
195
|
return form
|
reflex/components/lucide/icon.py
CHANGED
|
@@ -10,7 +10,7 @@ from reflex.vars.sequence import LiteralStringVar, StringVar
|
|
|
10
10
|
class LucideIconComponent(Component):
|
|
11
11
|
"""Lucide Icon Component."""
|
|
12
12
|
|
|
13
|
-
library = "lucide-react@0.
|
|
13
|
+
library = "lucide-react@0.511.0"
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class Icon(LucideIconComponent):
|
|
@@ -1463,6 +1463,7 @@ LUCIDE_ICON_LIST = [
|
|
|
1463
1463
|
"square_dashed_bottom_code",
|
|
1464
1464
|
"square_dashed_kanban",
|
|
1465
1465
|
"square_dashed_mouse_pointer",
|
|
1466
|
+
"square_dashed_top_solid",
|
|
1466
1467
|
"square_divide",
|
|
1467
1468
|
"square_dot",
|
|
1468
1469
|
"square_equal",
|
|
@@ -12,9 +12,9 @@ from reflex.utils.imports import ImportDict, ImportVar
|
|
|
12
12
|
from reflex.vars.base import LiteralVar, Var
|
|
13
13
|
|
|
14
14
|
try:
|
|
15
|
-
from plotly.
|
|
15
|
+
from plotly.graph_objs import Figure
|
|
16
|
+
from plotly.graph_objs.layout import Template
|
|
16
17
|
|
|
17
|
-
Template = layout.Template
|
|
18
18
|
except ImportError:
|
|
19
19
|
console.warn("Plotly is not installed. Please run `pip install plotly`.")
|
|
20
20
|
Figure = Any
|
|
@@ -14,9 +14,8 @@ from reflex.utils.imports import ImportDict
|
|
|
14
14
|
from reflex.vars.base import Var
|
|
15
15
|
|
|
16
16
|
try:
|
|
17
|
-
from plotly.
|
|
18
|
-
|
|
19
|
-
Template = layout.Template
|
|
17
|
+
from plotly.graph_objs import Figure
|
|
18
|
+
from plotly.graph_objs.layout import Template
|
|
20
19
|
except ImportError:
|
|
21
20
|
console.warn("Plotly is not installed. Please run `pip install plotly`.")
|
|
22
21
|
Figure = Any
|
|
@@ -7,7 +7,6 @@ from typing import Any, ClassVar, Literal
|
|
|
7
7
|
from reflex.components import Component
|
|
8
8
|
from reflex.components.core.breakpoints import Responsive
|
|
9
9
|
from reflex.components.tags import Tag
|
|
10
|
-
from reflex.config import get_config
|
|
11
10
|
from reflex.utils.imports import ImportDict, ImportVar
|
|
12
11
|
from reflex.vars.base import Var
|
|
13
12
|
|
|
@@ -135,7 +134,9 @@ class RadixThemesComponent(Component):
|
|
|
135
134
|
"""
|
|
136
135
|
component = super().create(*children, **props)
|
|
137
136
|
if component.library is None:
|
|
138
|
-
component.library = RadixThemesComponent.
|
|
137
|
+
component.library = RadixThemesComponent.get_fields()[
|
|
138
|
+
"library"
|
|
139
|
+
].default_value()
|
|
139
140
|
component.alias = "RadixThemes" + (component.tag or type(component).__name__)
|
|
140
141
|
return component
|
|
141
142
|
|
|
@@ -239,17 +240,9 @@ class Theme(RadixThemesComponent):
|
|
|
239
240
|
Returns:
|
|
240
241
|
The import dict.
|
|
241
242
|
"""
|
|
242
|
-
|
|
243
|
+
return {
|
|
243
244
|
"$/utils/theme.js": [ImportVar(tag="theme", is_default=True)],
|
|
244
245
|
}
|
|
245
|
-
if get_config().tailwind is None:
|
|
246
|
-
# When tailwind is disabled, import the radix-ui styles directly because they will
|
|
247
|
-
# not be included in the tailwind.css file.
|
|
248
|
-
_imports[""] = ImportVar(
|
|
249
|
-
tag="@radix-ui/themes/styles.css",
|
|
250
|
-
install=False,
|
|
251
|
-
)
|
|
252
|
-
return _imports
|
|
253
246
|
|
|
254
247
|
def _render(self, props: dict[str, Any] | None = None) -> Tag:
|
|
255
248
|
tag = super()._render(props)
|
|
@@ -75,7 +75,7 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent):
|
|
|
75
75
|
)
|
|
76
76
|
if "size" in props:
|
|
77
77
|
if isinstance(props["size"], str):
|
|
78
|
-
children[0].size = RADIX_TO_LUCIDE_SIZE[props["size"]]
|
|
78
|
+
children[0].size = RADIX_TO_LUCIDE_SIZE[props["size"]] # pyright: ignore[reportAttributeAccessIssue]
|
|
79
79
|
else:
|
|
80
80
|
size_map_var = Match.create(
|
|
81
81
|
props["size"],
|
|
@@ -84,7 +84,7 @@ class IconButton(elements.Button, RadixLoadingProp, RadixThemesComponent):
|
|
|
84
84
|
)
|
|
85
85
|
if not isinstance(size_map_var, Var):
|
|
86
86
|
raise ValueError(f"Match did not return a Var: {size_map_var}")
|
|
87
|
-
children[0].size = size_map_var
|
|
87
|
+
children[0].size = size_map_var # pyright: ignore[reportAttributeAccessIssue]
|
|
88
88
|
return super().create(*children, **props)
|
|
89
89
|
|
|
90
90
|
def add_style(self):
|
|
@@ -127,6 +127,9 @@ class TextFieldSlot(RadixThemesComponent):
|
|
|
127
127
|
# Override theme color for text field slot
|
|
128
128
|
color_scheme: Var[LiteralAccentColor]
|
|
129
129
|
|
|
130
|
+
# Which side of the input the slot should be placed on
|
|
131
|
+
side: Var[Literal["left", "right"]]
|
|
132
|
+
|
|
130
133
|
|
|
131
134
|
class TextField(ComponentNamespace):
|
|
132
135
|
"""TextField components namespace."""
|
|
@@ -471,6 +471,7 @@ class TextFieldSlot(RadixThemesComponent):
|
|
|
471
471
|
]
|
|
472
472
|
]
|
|
473
473
|
| None = None,
|
|
474
|
+
side: Literal["left", "right"] | Var[Literal["left", "right"]] | None = None,
|
|
474
475
|
style: Sequence[Mapping[str, Any]]
|
|
475
476
|
| Mapping[str, Any]
|
|
476
477
|
| Var[Mapping[str, Any]]
|
|
@@ -507,6 +508,7 @@ class TextFieldSlot(RadixThemesComponent):
|
|
|
507
508
|
Args:
|
|
508
509
|
*children: Child components.
|
|
509
510
|
color_scheme: Override theme color for text field slot
|
|
511
|
+
side: Which side of the input the slot should be placed on
|
|
510
512
|
style: The style of the component.
|
|
511
513
|
key: A unique key for the component.
|
|
512
514
|
id: The id for the component.
|
|
@@ -170,7 +170,7 @@ class ListItem(Li, MarkdownComponentMap):
|
|
|
170
170
|
"""
|
|
171
171
|
for child in children:
|
|
172
172
|
if isinstance(child, Text):
|
|
173
|
-
child.as_ = "span"
|
|
173
|
+
child.as_ = "span" # pyright: ignore[reportAttributeAccessIssue]
|
|
174
174
|
elif isinstance(child, Icon) and "display" not in child.style:
|
|
175
175
|
child.style["display"] = "inline"
|
|
176
176
|
return super().create(*children, **props)
|
|
@@ -105,8 +105,8 @@ class IterTag(Tag):
|
|
|
105
105
|
The rendered component.
|
|
106
106
|
"""
|
|
107
107
|
# Import here to avoid circular imports.
|
|
108
|
+
from reflex.compiler.compiler import _into_component_once
|
|
108
109
|
from reflex.components.base.fragment import Fragment
|
|
109
|
-
from reflex.components.component import Component
|
|
110
110
|
from reflex.components.core.cond import Cond
|
|
111
111
|
from reflex.components.core.foreach import Foreach
|
|
112
112
|
|
|
@@ -128,11 +128,9 @@ class IterTag(Tag):
|
|
|
128
128
|
if isinstance(component, (Foreach, Cond)):
|
|
129
129
|
component = Fragment.create(component)
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
if isinstance(component, tuple):
|
|
133
|
-
component = Fragment.create(*component)
|
|
131
|
+
component = _into_component_once(component)
|
|
134
132
|
|
|
135
|
-
if
|
|
133
|
+
if component is None:
|
|
136
134
|
raise ValueError("The render function must return a component.")
|
|
137
135
|
|
|
138
136
|
# Set the component key.
|
reflex/config.py
CHANGED
|
@@ -22,6 +22,7 @@ from typing import (
|
|
|
22
22
|
TYPE_CHECKING,
|
|
23
23
|
Annotated,
|
|
24
24
|
Any,
|
|
25
|
+
ClassVar,
|
|
25
26
|
Generic,
|
|
26
27
|
TypeVar,
|
|
27
28
|
get_args,
|
|
@@ -34,6 +35,7 @@ import pydantic.v1 as pydantic
|
|
|
34
35
|
from reflex import constants
|
|
35
36
|
from reflex.base import Base
|
|
36
37
|
from reflex.constants.base import LogLevel
|
|
38
|
+
from reflex.plugins import Plugin, TailwindV3Plugin, TailwindV4Plugin
|
|
37
39
|
from reflex.utils import console
|
|
38
40
|
from reflex.utils.exceptions import ConfigError, EnvironmentVarValueError
|
|
39
41
|
from reflex.utils.types import (
|
|
@@ -894,6 +896,11 @@ class Config(Base):
|
|
|
894
896
|
# Extra overlay function to run after the app is built. Formatted such that `from path_0.path_1... import path[-1]`, and calling it with no arguments would work. For example, "reflex.components.moment.moment".
|
|
895
897
|
extra_overlay_function: str | None = None
|
|
896
898
|
|
|
899
|
+
# List of plugins to use in the app.
|
|
900
|
+
plugins: list[Plugin] = []
|
|
901
|
+
|
|
902
|
+
_prefixes: ClassVar[list[str]] = ["REFLEX_"]
|
|
903
|
+
|
|
897
904
|
def __init__(self, *args, **kwargs):
|
|
898
905
|
"""Initialize the config values.
|
|
899
906
|
|
|
@@ -906,29 +913,59 @@ class Config(Base):
|
|
|
906
913
|
"""
|
|
907
914
|
super().__init__(*args, **kwargs)
|
|
908
915
|
|
|
909
|
-
#
|
|
910
|
-
|
|
916
|
+
# Clean up this code when we remove plain envvar in 0.8.0
|
|
917
|
+
show_deprecation = False
|
|
918
|
+
env_loglevel = os.environ.get("REFLEX_LOGLEVEL")
|
|
919
|
+
if not env_loglevel:
|
|
920
|
+
env_loglevel = os.environ.get("LOGLEVEL")
|
|
921
|
+
if env_loglevel:
|
|
922
|
+
show_deprecation = True
|
|
911
923
|
if env_loglevel is not None:
|
|
912
924
|
env_loglevel = LogLevel(env_loglevel.lower())
|
|
913
925
|
if env_loglevel or self.loglevel != LogLevel.DEFAULT:
|
|
914
926
|
console.set_log_level(env_loglevel or self.loglevel)
|
|
915
927
|
|
|
928
|
+
if show_deprecation:
|
|
929
|
+
console.deprecate(
|
|
930
|
+
"Usage of deprecated LOGLEVEL env var detected.",
|
|
931
|
+
reason="Prefer `REFLEX_` prefix when setting env vars.",
|
|
932
|
+
deprecation_version="0.7.13",
|
|
933
|
+
removal_version="0.8.0",
|
|
934
|
+
)
|
|
935
|
+
|
|
916
936
|
# Update the config from environment variables.
|
|
917
937
|
env_kwargs = self.update_from_env()
|
|
918
938
|
for key, env_value in env_kwargs.items():
|
|
919
939
|
setattr(self, key, env_value)
|
|
920
940
|
|
|
921
|
-
#
|
|
941
|
+
# Update default URLs if ports were set
|
|
922
942
|
kwargs.update(env_kwargs)
|
|
923
943
|
self._non_default_attributes.update(kwargs)
|
|
924
944
|
self._replace_defaults(**kwargs)
|
|
925
945
|
|
|
946
|
+
if self.tailwind is not None and not any(
|
|
947
|
+
isinstance(plugin, (TailwindV3Plugin, TailwindV4Plugin))
|
|
948
|
+
for plugin in self.plugins
|
|
949
|
+
):
|
|
950
|
+
console.deprecate(
|
|
951
|
+
"Inferring tailwind usage",
|
|
952
|
+
reason="""
|
|
953
|
+
|
|
954
|
+
If you are using tailwind, add `rx.plugins.TailwindV3Plugin()` to the `plugins=[]` in rxconfig.py.
|
|
955
|
+
|
|
956
|
+
If you are not using tailwind, set `tailwind` to `None` in rxconfig.py.""",
|
|
957
|
+
deprecation_version="0.7.13",
|
|
958
|
+
removal_version="0.8.0",
|
|
959
|
+
dedupe=True,
|
|
960
|
+
)
|
|
961
|
+
self.plugins.append(TailwindV3Plugin())
|
|
962
|
+
|
|
926
963
|
if (
|
|
927
964
|
self.state_manager_mode == constants.StateManagerMode.REDIS
|
|
928
965
|
and not self.redis_url
|
|
929
966
|
):
|
|
930
967
|
raise ConfigError(
|
|
931
|
-
"REDIS_URL is required when using the redis state manager."
|
|
968
|
+
f"{self._prefixes[0]}REDIS_URL is required when using the redis state manager."
|
|
932
969
|
)
|
|
933
970
|
|
|
934
971
|
@property
|
|
@@ -969,7 +1006,18 @@ class Config(Base):
|
|
|
969
1006
|
# Iterate over the fields.
|
|
970
1007
|
for key, field in self.__fields__.items():
|
|
971
1008
|
# The env var name is the key in uppercase.
|
|
972
|
-
|
|
1009
|
+
for prefix in self._prefixes:
|
|
1010
|
+
if env_var := os.environ.get(f"{prefix}{key.upper()}"):
|
|
1011
|
+
break
|
|
1012
|
+
else:
|
|
1013
|
+
# Default to non-prefixed env var if other are not found.
|
|
1014
|
+
if env_var := os.environ.get(key.upper()):
|
|
1015
|
+
console.deprecate(
|
|
1016
|
+
f"Usage of deprecated {key.upper()} env var detected.",
|
|
1017
|
+
reason=f"Prefer `{self._prefixes[0]}` prefix when setting env vars.",
|
|
1018
|
+
deprecation_version="0.7.13",
|
|
1019
|
+
removal_version="0.8.0",
|
|
1020
|
+
)
|
|
973
1021
|
|
|
974
1022
|
# If the env var is set, override the config value.
|
|
975
1023
|
if env_var and env_var.strip():
|
|
@@ -989,7 +1037,6 @@ class Config(Base):
|
|
|
989
1037
|
f"Overriding config value {key} with env var {key.upper()}={env_var}",
|
|
990
1038
|
dedupe=True,
|
|
991
1039
|
)
|
|
992
|
-
|
|
993
1040
|
return updated_values
|
|
994
1041
|
|
|
995
1042
|
def get_event_namespace(self) -> str:
|
|
@@ -1041,7 +1088,7 @@ class Config(Base):
|
|
|
1041
1088
|
"""
|
|
1042
1089
|
for key, value in kwargs.items():
|
|
1043
1090
|
if value is not None:
|
|
1044
|
-
os.environ[key.upper()] = str(value)
|
|
1091
|
+
os.environ[self._prefixes[0] + key.upper()] = str(value)
|
|
1045
1092
|
setattr(self, key, value)
|
|
1046
1093
|
self._non_default_attributes.update(kwargs)
|
|
1047
1094
|
self._replace_defaults(**kwargs)
|
reflex/constants/__init__.py
CHANGED
|
@@ -59,7 +59,6 @@ from .route import (
|
|
|
59
59
|
RouteVar,
|
|
60
60
|
)
|
|
61
61
|
from .state import StateManagerMode
|
|
62
|
-
from .style import Tailwind
|
|
63
62
|
|
|
64
63
|
__all__ = [
|
|
65
64
|
"ALEMBIC_CONFIG",
|
|
@@ -115,6 +114,5 @@ __all__ = [
|
|
|
115
114
|
"RouteVar",
|
|
116
115
|
"SocketEvent",
|
|
117
116
|
"StateManagerMode",
|
|
118
|
-
"Tailwind",
|
|
119
117
|
"Templates",
|
|
120
118
|
]
|