reflex 0.8.5a1__py3-none-any.whl → 0.8.6a0__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/{web/vite.config.js → jinja/web/vite.config.js.jinja2} +11 -0
- reflex/.templates/web/utils/state.js +5 -0
- reflex/__init__.py +1 -0
- reflex/__init__.pyi +2 -0
- reflex/app.py +65 -13
- reflex/compiler/templates.py +3 -0
- reflex/compiler/utils.py +6 -12
- reflex/components/core/auto_scroll.py +14 -13
- reflex/components/datadisplay/dataeditor.py +3 -0
- reflex/components/datadisplay/dataeditor.pyi +2 -0
- reflex/components/el/__init__.pyi +4 -0
- reflex/components/el/elements/__init__.py +1 -0
- reflex/components/el/elements/__init__.pyi +5 -0
- reflex/components/el/elements/media.py +32 -0
- reflex/components/el/elements/media.pyi +261 -0
- reflex/components/lucide/icon.py +4 -1
- reflex/components/lucide/icon.pyi +4 -1
- reflex/components/sonner/toast.py +1 -1
- reflex/config.py +15 -0
- reflex/constants/base.py +7 -58
- reflex/environment.py +0 -10
- reflex/state.py +27 -5
- reflex/testing.py +11 -0
- reflex/utils/decorator.py +1 -0
- reflex/utils/monitoring.py +180 -0
- reflex/utils/prerequisites.py +17 -0
- reflex/utils/token_manager.py +215 -0
- {reflex-0.8.5a1.dist-info → reflex-0.8.6a0.dist-info}/METADATA +5 -2
- {reflex-0.8.5a1.dist-info → reflex-0.8.6a0.dist-info}/RECORD +32 -30
- {reflex-0.8.5a1.dist-info → reflex-0.8.6a0.dist-info}/WHEEL +0 -0
- {reflex-0.8.5a1.dist-info → reflex-0.8.6a0.dist-info}/entry_points.txt +0 -0
- {reflex-0.8.5a1.dist-info → reflex-0.8.6a0.dist-info}/licenses/LICENSE +0 -0
|
@@ -6162,6 +6162,265 @@ class Path(BaseHTML):
|
|
|
6162
6162
|
The component.
|
|
6163
6163
|
"""
|
|
6164
6164
|
|
|
6165
|
+
class Marker(BaseHTML):
|
|
6166
|
+
@classmethod
|
|
6167
|
+
def create(
|
|
6168
|
+
cls,
|
|
6169
|
+
*children,
|
|
6170
|
+
marker_height: Var[float | int | str] | float | int | str | None = None,
|
|
6171
|
+
marker_width: Var[float | int | str] | float | int | str | None = None,
|
|
6172
|
+
marker_units: Var[str] | str | None = None,
|
|
6173
|
+
orient: Var[float | int | str] | float | int | str | None = None,
|
|
6174
|
+
preserve_aspect_ratio: Var[str] | str | None = None,
|
|
6175
|
+
ref_x: Var[float | int | str] | float | int | str | None = None,
|
|
6176
|
+
ref_y: Var[float | int | str] | float | int | str | None = None,
|
|
6177
|
+
view_box: Var[str] | str | None = None,
|
|
6178
|
+
access_key: Var[str] | str | None = None,
|
|
6179
|
+
auto_capitalize: Literal[
|
|
6180
|
+
"characters", "none", "off", "on", "sentences", "words"
|
|
6181
|
+
]
|
|
6182
|
+
| Var[Literal["characters", "none", "off", "on", "sentences", "words"]]
|
|
6183
|
+
| None = None,
|
|
6184
|
+
content_editable: Literal["inherit", "plaintext-only", False, True]
|
|
6185
|
+
| Var[Literal["inherit", "plaintext-only", False, True]]
|
|
6186
|
+
| None = None,
|
|
6187
|
+
context_menu: Var[str] | str | None = None,
|
|
6188
|
+
dir: Var[str] | str | None = None,
|
|
6189
|
+
draggable: Var[bool] | bool | None = None,
|
|
6190
|
+
enter_key_hint: Literal[
|
|
6191
|
+
"done", "enter", "go", "next", "previous", "search", "send"
|
|
6192
|
+
]
|
|
6193
|
+
| Var[Literal["done", "enter", "go", "next", "previous", "search", "send"]]
|
|
6194
|
+
| None = None,
|
|
6195
|
+
hidden: Var[bool] | bool | None = None,
|
|
6196
|
+
input_mode: Literal[
|
|
6197
|
+
"decimal", "email", "none", "numeric", "search", "tel", "text", "url"
|
|
6198
|
+
]
|
|
6199
|
+
| Var[
|
|
6200
|
+
Literal[
|
|
6201
|
+
"decimal", "email", "none", "numeric", "search", "tel", "text", "url"
|
|
6202
|
+
]
|
|
6203
|
+
]
|
|
6204
|
+
| None = None,
|
|
6205
|
+
item_prop: Var[str] | str | None = None,
|
|
6206
|
+
lang: Var[str] | str | None = None,
|
|
6207
|
+
role: Literal[
|
|
6208
|
+
"alert",
|
|
6209
|
+
"alertdialog",
|
|
6210
|
+
"application",
|
|
6211
|
+
"article",
|
|
6212
|
+
"banner",
|
|
6213
|
+
"button",
|
|
6214
|
+
"cell",
|
|
6215
|
+
"checkbox",
|
|
6216
|
+
"columnheader",
|
|
6217
|
+
"combobox",
|
|
6218
|
+
"complementary",
|
|
6219
|
+
"contentinfo",
|
|
6220
|
+
"definition",
|
|
6221
|
+
"dialog",
|
|
6222
|
+
"directory",
|
|
6223
|
+
"document",
|
|
6224
|
+
"feed",
|
|
6225
|
+
"figure",
|
|
6226
|
+
"form",
|
|
6227
|
+
"grid",
|
|
6228
|
+
"gridcell",
|
|
6229
|
+
"group",
|
|
6230
|
+
"heading",
|
|
6231
|
+
"img",
|
|
6232
|
+
"link",
|
|
6233
|
+
"list",
|
|
6234
|
+
"listbox",
|
|
6235
|
+
"listitem",
|
|
6236
|
+
"log",
|
|
6237
|
+
"main",
|
|
6238
|
+
"marquee",
|
|
6239
|
+
"math",
|
|
6240
|
+
"menu",
|
|
6241
|
+
"menubar",
|
|
6242
|
+
"menuitem",
|
|
6243
|
+
"menuitemcheckbox",
|
|
6244
|
+
"menuitemradio",
|
|
6245
|
+
"navigation",
|
|
6246
|
+
"none",
|
|
6247
|
+
"note",
|
|
6248
|
+
"option",
|
|
6249
|
+
"presentation",
|
|
6250
|
+
"progressbar",
|
|
6251
|
+
"radio",
|
|
6252
|
+
"radiogroup",
|
|
6253
|
+
"region",
|
|
6254
|
+
"row",
|
|
6255
|
+
"rowgroup",
|
|
6256
|
+
"rowheader",
|
|
6257
|
+
"scrollbar",
|
|
6258
|
+
"search",
|
|
6259
|
+
"searchbox",
|
|
6260
|
+
"separator",
|
|
6261
|
+
"slider",
|
|
6262
|
+
"spinbutton",
|
|
6263
|
+
"status",
|
|
6264
|
+
"switch",
|
|
6265
|
+
"tab",
|
|
6266
|
+
"table",
|
|
6267
|
+
"tablist",
|
|
6268
|
+
"tabpanel",
|
|
6269
|
+
"term",
|
|
6270
|
+
"textbox",
|
|
6271
|
+
"timer",
|
|
6272
|
+
"toolbar",
|
|
6273
|
+
"tooltip",
|
|
6274
|
+
"tree",
|
|
6275
|
+
"treegrid",
|
|
6276
|
+
"treeitem",
|
|
6277
|
+
]
|
|
6278
|
+
| Var[
|
|
6279
|
+
Literal[
|
|
6280
|
+
"alert",
|
|
6281
|
+
"alertdialog",
|
|
6282
|
+
"application",
|
|
6283
|
+
"article",
|
|
6284
|
+
"banner",
|
|
6285
|
+
"button",
|
|
6286
|
+
"cell",
|
|
6287
|
+
"checkbox",
|
|
6288
|
+
"columnheader",
|
|
6289
|
+
"combobox",
|
|
6290
|
+
"complementary",
|
|
6291
|
+
"contentinfo",
|
|
6292
|
+
"definition",
|
|
6293
|
+
"dialog",
|
|
6294
|
+
"directory",
|
|
6295
|
+
"document",
|
|
6296
|
+
"feed",
|
|
6297
|
+
"figure",
|
|
6298
|
+
"form",
|
|
6299
|
+
"grid",
|
|
6300
|
+
"gridcell",
|
|
6301
|
+
"group",
|
|
6302
|
+
"heading",
|
|
6303
|
+
"img",
|
|
6304
|
+
"link",
|
|
6305
|
+
"list",
|
|
6306
|
+
"listbox",
|
|
6307
|
+
"listitem",
|
|
6308
|
+
"log",
|
|
6309
|
+
"main",
|
|
6310
|
+
"marquee",
|
|
6311
|
+
"math",
|
|
6312
|
+
"menu",
|
|
6313
|
+
"menubar",
|
|
6314
|
+
"menuitem",
|
|
6315
|
+
"menuitemcheckbox",
|
|
6316
|
+
"menuitemradio",
|
|
6317
|
+
"navigation",
|
|
6318
|
+
"none",
|
|
6319
|
+
"note",
|
|
6320
|
+
"option",
|
|
6321
|
+
"presentation",
|
|
6322
|
+
"progressbar",
|
|
6323
|
+
"radio",
|
|
6324
|
+
"radiogroup",
|
|
6325
|
+
"region",
|
|
6326
|
+
"row",
|
|
6327
|
+
"rowgroup",
|
|
6328
|
+
"rowheader",
|
|
6329
|
+
"scrollbar",
|
|
6330
|
+
"search",
|
|
6331
|
+
"searchbox",
|
|
6332
|
+
"separator",
|
|
6333
|
+
"slider",
|
|
6334
|
+
"spinbutton",
|
|
6335
|
+
"status",
|
|
6336
|
+
"switch",
|
|
6337
|
+
"tab",
|
|
6338
|
+
"table",
|
|
6339
|
+
"tablist",
|
|
6340
|
+
"tabpanel",
|
|
6341
|
+
"term",
|
|
6342
|
+
"textbox",
|
|
6343
|
+
"timer",
|
|
6344
|
+
"toolbar",
|
|
6345
|
+
"tooltip",
|
|
6346
|
+
"tree",
|
|
6347
|
+
"treegrid",
|
|
6348
|
+
"treeitem",
|
|
6349
|
+
]
|
|
6350
|
+
]
|
|
6351
|
+
| None = None,
|
|
6352
|
+
slot: Var[str] | str | None = None,
|
|
6353
|
+
spell_check: Var[bool] | bool | None = None,
|
|
6354
|
+
tab_index: Var[int] | int | None = None,
|
|
6355
|
+
title: Var[str] | str | None = None,
|
|
6356
|
+
style: Sequence[Mapping[str, Any]]
|
|
6357
|
+
| Mapping[str, Any]
|
|
6358
|
+
| Var[Mapping[str, Any]]
|
|
6359
|
+
| Breakpoints
|
|
6360
|
+
| None = None,
|
|
6361
|
+
key: Any | None = None,
|
|
6362
|
+
id: Any | None = None,
|
|
6363
|
+
ref: Var | None = None,
|
|
6364
|
+
class_name: Any | None = None,
|
|
6365
|
+
custom_attrs: dict[str, Var | Any] | None = None,
|
|
6366
|
+
on_blur: EventType[()] | None = None,
|
|
6367
|
+
on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
|
|
6368
|
+
on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
|
|
6369
|
+
on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
|
|
6370
|
+
on_focus: EventType[()] | None = None,
|
|
6371
|
+
on_mount: EventType[()] | None = None,
|
|
6372
|
+
on_mouse_down: EventType[()] | None = None,
|
|
6373
|
+
on_mouse_enter: EventType[()] | None = None,
|
|
6374
|
+
on_mouse_leave: EventType[()] | None = None,
|
|
6375
|
+
on_mouse_move: EventType[()] | None = None,
|
|
6376
|
+
on_mouse_out: EventType[()] | None = None,
|
|
6377
|
+
on_mouse_over: EventType[()] | None = None,
|
|
6378
|
+
on_mouse_up: EventType[()] | None = None,
|
|
6379
|
+
on_scroll: EventType[()] | None = None,
|
|
6380
|
+
on_scroll_end: EventType[()] | None = None,
|
|
6381
|
+
on_unmount: EventType[()] | None = None,
|
|
6382
|
+
**props,
|
|
6383
|
+
) -> Marker:
|
|
6384
|
+
"""Create the component.
|
|
6385
|
+
|
|
6386
|
+
Args:
|
|
6387
|
+
*children: The children of the component.
|
|
6388
|
+
marker_height: The height of the marker viewport.
|
|
6389
|
+
marker_width: The width of the marker viewport.
|
|
6390
|
+
marker_units: The coordinate system for the marker attributes.
|
|
6391
|
+
orient: The orientation of the marker relative to the shape it is attached to.
|
|
6392
|
+
preserve_aspect_ratio: How the svg fragment must be deformed if it is embedded in a container with a different aspect ratio.
|
|
6393
|
+
ref_x: The x coordinate for the reference point of the marker.
|
|
6394
|
+
ref_y: The y coordinate for the reference point of the marker.
|
|
6395
|
+
view_box: The bound of the SVG viewport for the current SVG fragment.
|
|
6396
|
+
access_key: Provides a hint for generating a keyboard shortcut for the current element.
|
|
6397
|
+
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
|
|
6398
|
+
content_editable: Indicates whether the element's content is editable.
|
|
6399
|
+
context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
|
|
6400
|
+
dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
|
|
6401
|
+
draggable: Defines whether the element can be dragged.
|
|
6402
|
+
enter_key_hint: Hints what media types the media element is able to play.
|
|
6403
|
+
hidden: Defines whether the element is hidden.
|
|
6404
|
+
input_mode: Defines the type of the element.
|
|
6405
|
+
item_prop: Defines the name of the element for metadata purposes.
|
|
6406
|
+
lang: Defines the language used in the element.
|
|
6407
|
+
role: Defines the role of the element.
|
|
6408
|
+
slot: Assigns a slot in a shadow DOM shadow tree to an element.
|
|
6409
|
+
spell_check: Defines whether the element may be checked for spelling errors.
|
|
6410
|
+
tab_index: Defines the position of the current element in the tabbing order.
|
|
6411
|
+
title: Defines a tooltip for the element.
|
|
6412
|
+
style: The style of the component.
|
|
6413
|
+
key: A unique key for the component.
|
|
6414
|
+
id: The id for the component.
|
|
6415
|
+
ref: The Var to pass as the ref to the component.
|
|
6416
|
+
class_name: The class name for the component.
|
|
6417
|
+
custom_attrs: custom attribute
|
|
6418
|
+
**props: The props of the component.
|
|
6419
|
+
|
|
6420
|
+
Returns:
|
|
6421
|
+
The component.
|
|
6422
|
+
"""
|
|
6423
|
+
|
|
6165
6424
|
class G(BaseHTML):
|
|
6166
6425
|
@classmethod
|
|
6167
6426
|
def create(
|
|
@@ -6429,6 +6688,7 @@ class SVG(ComponentNamespace):
|
|
|
6429
6688
|
linear_gradient = staticmethod(LinearGradient.create)
|
|
6430
6689
|
radial_gradient = staticmethod(RadialGradient.create)
|
|
6431
6690
|
defs = staticmethod(Defs.create)
|
|
6691
|
+
marker = staticmethod(Marker.create)
|
|
6432
6692
|
g = staticmethod(G.create)
|
|
6433
6693
|
|
|
6434
6694
|
@staticmethod
|
|
@@ -6689,6 +6949,7 @@ stop = Stop.create
|
|
|
6689
6949
|
linear_gradient = LinearGradient.create
|
|
6690
6950
|
radial_gradient = RadialGradient.create
|
|
6691
6951
|
defs = Defs.create
|
|
6952
|
+
marker = Marker.create
|
|
6692
6953
|
g = G.create
|
|
6693
6954
|
area = Area.create
|
|
6694
6955
|
audio = Audio.create
|
reflex/components/lucide/icon.py
CHANGED
|
@@ -6,7 +6,7 @@ from reflex.utils.imports import ImportVar
|
|
|
6
6
|
from reflex.vars.base import LiteralVar, Var
|
|
7
7
|
from reflex.vars.sequence import LiteralStringVar, StringVar
|
|
8
8
|
|
|
9
|
-
LUCIDE_LIBRARY = "lucide-react@0.
|
|
9
|
+
LUCIDE_LIBRARY = "lucide-react@0.536.0"
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class LucideIconComponent(Component):
|
|
@@ -93,6 +93,7 @@ class DynamicIcon(LucideIconComponent):
|
|
|
93
93
|
tag = "DynamicIcon"
|
|
94
94
|
|
|
95
95
|
name: Var[str]
|
|
96
|
+
size: Var[int]
|
|
96
97
|
|
|
97
98
|
def _get_imports(self):
|
|
98
99
|
_imports = super()._get_imports()
|
|
@@ -874,6 +875,7 @@ LUCIDE_ICON_LIST = [
|
|
|
874
875
|
"hamburger",
|
|
875
876
|
"hammer",
|
|
876
877
|
"hand_coins",
|
|
878
|
+
"hand_fist",
|
|
877
879
|
"hand_heart",
|
|
878
880
|
"hand_helping",
|
|
879
881
|
"hand_metal",
|
|
@@ -1644,6 +1646,7 @@ LUCIDE_ICON_LIST = [
|
|
|
1644
1646
|
"truck_electric",
|
|
1645
1647
|
"truck",
|
|
1646
1648
|
"turkish_lira",
|
|
1649
|
+
"turntable",
|
|
1647
1650
|
"turtle",
|
|
1648
1651
|
"tv_2",
|
|
1649
1652
|
"tv_minimal_play",
|
|
@@ -11,7 +11,7 @@ from reflex.components.core.breakpoints import Breakpoints
|
|
|
11
11
|
from reflex.event import EventType, PointerEventInfo
|
|
12
12
|
from reflex.vars.base import Var
|
|
13
13
|
|
|
14
|
-
LUCIDE_LIBRARY = "lucide-react@0.
|
|
14
|
+
LUCIDE_LIBRARY = "lucide-react@0.536.0"
|
|
15
15
|
|
|
16
16
|
class LucideIconComponent(Component):
|
|
17
17
|
@classmethod
|
|
@@ -125,6 +125,7 @@ class DynamicIcon(LucideIconComponent):
|
|
|
125
125
|
cls,
|
|
126
126
|
*children,
|
|
127
127
|
name: Var[str] | str | None = None,
|
|
128
|
+
size: Var[int] | int | None = None,
|
|
128
129
|
style: Sequence[Mapping[str, Any]]
|
|
129
130
|
| Mapping[str, Any]
|
|
130
131
|
| Var[Mapping[str, Any]]
|
|
@@ -939,6 +940,7 @@ LUCIDE_ICON_LIST = [
|
|
|
939
940
|
"hamburger",
|
|
940
941
|
"hammer",
|
|
941
942
|
"hand_coins",
|
|
943
|
+
"hand_fist",
|
|
942
944
|
"hand_heart",
|
|
943
945
|
"hand_helping",
|
|
944
946
|
"hand_metal",
|
|
@@ -1709,6 +1711,7 @@ LUCIDE_ICON_LIST = [
|
|
|
1709
1711
|
"truck_electric",
|
|
1710
1712
|
"truck",
|
|
1711
1713
|
"turkish_lira",
|
|
1714
|
+
"turntable",
|
|
1712
1715
|
"turtle",
|
|
1713
1716
|
"tv_2",
|
|
1714
1717
|
"tv_minimal_play",
|
reflex/config.py
CHANGED
|
@@ -29,6 +29,9 @@ from reflex.plugins.sitemap import SitemapPlugin
|
|
|
29
29
|
from reflex.utils import console
|
|
30
30
|
from reflex.utils.exceptions import ConfigError
|
|
31
31
|
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from pyleak.base import LeakAction
|
|
34
|
+
|
|
32
35
|
|
|
33
36
|
@dataclasses.dataclass(kw_only=True)
|
|
34
37
|
class DBConfig:
|
|
@@ -186,6 +189,18 @@ class BaseConfig:
|
|
|
186
189
|
# Telemetry opt-in.
|
|
187
190
|
telemetry_enabled: bool = True
|
|
188
191
|
|
|
192
|
+
# PyLeak monitoring configuration for detecting event loop blocking and resource leaks.
|
|
193
|
+
enable_pyleak_monitoring: bool = False
|
|
194
|
+
|
|
195
|
+
# Threshold in seconds for detecting event loop blocking operations.
|
|
196
|
+
pyleak_blocking_threshold: float = 0.1
|
|
197
|
+
|
|
198
|
+
# Grace period in seconds for thread leak detection cleanup.
|
|
199
|
+
pyleak_thread_grace_period: float = 0.2
|
|
200
|
+
|
|
201
|
+
# Action to take when PyLeak detects issues
|
|
202
|
+
pyleak_action: "LeakAction | None" = None
|
|
203
|
+
|
|
189
204
|
# The bun path
|
|
190
205
|
bun_path: ExistingPath = constants.Bun.DEFAULT_PATH
|
|
191
206
|
|
reflex/constants/base.py
CHANGED
|
@@ -11,8 +11,6 @@ from typing import Literal
|
|
|
11
11
|
|
|
12
12
|
from platformdirs import PlatformDirs
|
|
13
13
|
|
|
14
|
-
from .utils import classproperty
|
|
15
|
-
|
|
16
14
|
IS_WINDOWS = platform.system() == "Windows"
|
|
17
15
|
IS_MACOS = platform.system() == "Darwin"
|
|
18
16
|
IS_LINUX = platform.system() == "Linux"
|
|
@@ -119,9 +117,6 @@ class ReflexHostingCLI(SimpleNamespace):
|
|
|
119
117
|
class Templates(SimpleNamespace):
|
|
120
118
|
"""Constants related to Templates."""
|
|
121
119
|
|
|
122
|
-
# The route on Reflex backend to query which templates are available and their URLs.
|
|
123
|
-
APP_TEMPLATES_ROUTE = "/app-templates"
|
|
124
|
-
|
|
125
120
|
# The default template
|
|
126
121
|
DEFAULT = "blank"
|
|
127
122
|
|
|
@@ -132,58 +127,12 @@ class Templates(SimpleNamespace):
|
|
|
132
127
|
CHOOSE_TEMPLATES = "choose-templates"
|
|
133
128
|
|
|
134
129
|
# The URL to find reflex templates.
|
|
135
|
-
REFLEX_TEMPLATES_URL =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
DEFAULT_TEMPLATE_URL = "https://blank-template.reflex.run"
|
|
130
|
+
REFLEX_TEMPLATES_URL = (
|
|
131
|
+
"https://reflex.dev/docs/getting-started/open-source-templates/"
|
|
132
|
+
)
|
|
139
133
|
|
|
140
134
|
# The reflex.build frontend host
|
|
141
|
-
REFLEX_BUILD_FRONTEND = "https://reflex.
|
|
142
|
-
|
|
143
|
-
# The reflex.build backend host
|
|
144
|
-
REFLEX_BUILD_BACKEND = "https://flexgen-prod-flexgen.fly.dev"
|
|
145
|
-
|
|
146
|
-
@classproperty
|
|
147
|
-
@classmethod
|
|
148
|
-
def REFLEX_BUILD_URL(cls):
|
|
149
|
-
"""The URL to redirect to reflex.build.
|
|
150
|
-
|
|
151
|
-
Returns:
|
|
152
|
-
The URL to redirect to reflex.build.
|
|
153
|
-
"""
|
|
154
|
-
from reflex.environment import environment
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
environment.REFLEX_BUILD_FRONTEND.get()
|
|
158
|
-
+ "/gen?reflex_init_token={reflex_init_token}"
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
@classproperty
|
|
162
|
-
@classmethod
|
|
163
|
-
def REFLEX_BUILD_POLL_URL(cls):
|
|
164
|
-
"""The URL to poll waiting for the user to select a generation.
|
|
165
|
-
|
|
166
|
-
Returns:
|
|
167
|
-
The URL to poll waiting for the user to select a generation.
|
|
168
|
-
"""
|
|
169
|
-
from reflex.environment import environment
|
|
170
|
-
|
|
171
|
-
return environment.REFLEX_BUILD_BACKEND.get() + "/api/init/{reflex_init_token}"
|
|
172
|
-
|
|
173
|
-
@classproperty
|
|
174
|
-
@classmethod
|
|
175
|
-
def REFLEX_BUILD_CODE_URL(cls):
|
|
176
|
-
"""The URL to fetch the generation's reflex code.
|
|
177
|
-
|
|
178
|
-
Returns:
|
|
179
|
-
The URL to fetch the generation's reflex code.
|
|
180
|
-
"""
|
|
181
|
-
from reflex.environment import environment
|
|
182
|
-
|
|
183
|
-
return (
|
|
184
|
-
environment.REFLEX_BUILD_BACKEND.get()
|
|
185
|
-
+ "/api/gen/{generation_hash}/refactored"
|
|
186
|
-
)
|
|
135
|
+
REFLEX_BUILD_FRONTEND = "https://build.reflex.dev"
|
|
187
136
|
|
|
188
137
|
class Dirs(SimpleNamespace):
|
|
189
138
|
"""Folders used by the template system of Reflex."""
|
|
@@ -204,9 +153,6 @@ class Javascript(SimpleNamespace):
|
|
|
204
153
|
# The node modules directory.
|
|
205
154
|
NODE_MODULES = "node_modules"
|
|
206
155
|
|
|
207
|
-
# The package lock file.
|
|
208
|
-
PACKAGE_LOCK = "package-lock.json"
|
|
209
|
-
|
|
210
156
|
|
|
211
157
|
class ReactRouter(Javascript):
|
|
212
158
|
"""Constants related to React Router."""
|
|
@@ -214,6 +160,9 @@ class ReactRouter(Javascript):
|
|
|
214
160
|
# The react router config file
|
|
215
161
|
CONFIG_FILE = "react-router.config.js"
|
|
216
162
|
|
|
163
|
+
# The associated Vite config file
|
|
164
|
+
VITE_CONFIG_FILE = "vite.config.js"
|
|
165
|
+
|
|
217
166
|
# Regex to check for message displayed when frontend comes up
|
|
218
167
|
DEV_FRONTEND_LISTENING_REGEX = r"Local:[\s]+"
|
|
219
168
|
|
reflex/environment.py
CHANGED
|
@@ -563,16 +563,6 @@ class EnvironmentVariables:
|
|
|
563
563
|
# Whether to skip purging the web directory in dev mode.
|
|
564
564
|
REFLEX_PERSIST_WEB_DIR: EnvVar[bool] = env_var(False)
|
|
565
565
|
|
|
566
|
-
# The reflex.build frontend host.
|
|
567
|
-
REFLEX_BUILD_FRONTEND: EnvVar[str] = env_var(
|
|
568
|
-
constants.Templates.REFLEX_BUILD_FRONTEND
|
|
569
|
-
)
|
|
570
|
-
|
|
571
|
-
# The reflex.build backend host.
|
|
572
|
-
REFLEX_BUILD_BACKEND: EnvVar[str] = env_var(
|
|
573
|
-
constants.Templates.REFLEX_BUILD_BACKEND
|
|
574
|
-
)
|
|
575
|
-
|
|
576
566
|
# This env var stores the execution mode of the app
|
|
577
567
|
REFLEX_ENV_MODE: EnvVar[constants.Env] = env_var(constants.Env.DEV)
|
|
578
568
|
|
reflex/state.py
CHANGED
|
@@ -60,6 +60,7 @@ from reflex.utils.exceptions import (
|
|
|
60
60
|
)
|
|
61
61
|
from reflex.utils.exceptions import ImmutableStateError as ImmutableStateError
|
|
62
62
|
from reflex.utils.exec import is_testing_env
|
|
63
|
+
from reflex.utils.monitoring import is_pyleak_enabled, monitor_loopblocks
|
|
63
64
|
from reflex.utils.types import _isinstance, is_union, value_inside_optional
|
|
64
65
|
from reflex.vars import Field, VarData, field
|
|
65
66
|
from reflex.vars.base import (
|
|
@@ -1784,7 +1785,11 @@ class BaseState(EvenMoreBasicBaseState):
|
|
|
1784
1785
|
from reflex.utils import telemetry
|
|
1785
1786
|
|
|
1786
1787
|
# Get the function to process the event.
|
|
1787
|
-
|
|
1788
|
+
if is_pyleak_enabled():
|
|
1789
|
+
console.debug(f"Monitoring leaks for handler: {handler.fn.__qualname__}")
|
|
1790
|
+
fn = functools.partial(monitor_loopblocks(handler.fn), state)
|
|
1791
|
+
else:
|
|
1792
|
+
fn = functools.partial(handler.fn, state)
|
|
1788
1793
|
|
|
1789
1794
|
try:
|
|
1790
1795
|
type_hints = typing.get_type_hints(handler.fn)
|
|
@@ -2463,16 +2468,30 @@ class OnLoadInternalState(State):
|
|
|
2463
2468
|
This is a separate substate to avoid deserializing the entire state tree for every page navigation.
|
|
2464
2469
|
"""
|
|
2465
2470
|
|
|
2471
|
+
# Cannot properly annotate this as `App` due to circular import issues.
|
|
2472
|
+
_app_ref: ClassVar[Any] = None
|
|
2473
|
+
|
|
2466
2474
|
def on_load_internal(self) -> list[Event | EventSpec | event.EventCallback] | None:
|
|
2467
2475
|
"""Queue on_load handlers for the current page.
|
|
2468
2476
|
|
|
2469
2477
|
Returns:
|
|
2470
2478
|
The list of events to queue for on load handling.
|
|
2479
|
+
|
|
2480
|
+
Raises:
|
|
2481
|
+
TypeError: If the app reference is not of type App.
|
|
2471
2482
|
"""
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
)
|
|
2483
|
+
from reflex.app import App
|
|
2484
|
+
|
|
2485
|
+
app = type(self)._app_ref or prerequisites.get_and_validate_app().app
|
|
2486
|
+
if not isinstance(app, App):
|
|
2487
|
+
msg = (
|
|
2488
|
+
f"Expected app to be of type {App.__name__}, got {type(app).__name__}."
|
|
2489
|
+
)
|
|
2490
|
+
raise TypeError(msg)
|
|
2491
|
+
# Cache the app reference for subsequent calls.
|
|
2492
|
+
if type(self)._app_ref is None:
|
|
2493
|
+
type(self)._app_ref = app
|
|
2494
|
+
load_events = app.get_load_events(self.router._page.path)
|
|
2476
2495
|
if not load_events:
|
|
2477
2496
|
self.is_hydrated = True
|
|
2478
2497
|
return None # Fast path for navigation with no on_load events defined.
|
|
@@ -2646,6 +2665,9 @@ def reload_state_module(
|
|
|
2646
2665
|
state: Recursive argument for the state class to reload.
|
|
2647
2666
|
|
|
2648
2667
|
"""
|
|
2668
|
+
# Reset the _app_ref of OnLoadInternalState to avoid stale references.
|
|
2669
|
+
if state is OnLoadInternalState:
|
|
2670
|
+
state._app_ref = None
|
|
2649
2671
|
# Clean out all potentially dirty states of reloaded modules.
|
|
2650
2672
|
for pd_state in tuple(state._potentially_dirty_states):
|
|
2651
2673
|
with contextlib.suppress(ValueError):
|
reflex/testing.py
CHANGED
|
@@ -376,6 +376,17 @@ class AppHarness:
|
|
|
376
376
|
msg = "Failed to reset state manager."
|
|
377
377
|
raise RuntimeError(msg)
|
|
378
378
|
|
|
379
|
+
# Also reset the TokenManager to avoid loop affinity issues
|
|
380
|
+
if (
|
|
381
|
+
hasattr(self.app_instance, "event_namespace")
|
|
382
|
+
and self.app_instance.event_namespace is not None
|
|
383
|
+
and hasattr(self.app_instance.event_namespace, "_token_manager")
|
|
384
|
+
):
|
|
385
|
+
# Import here to avoid circular imports
|
|
386
|
+
from reflex.utils.token_manager import TokenManager
|
|
387
|
+
|
|
388
|
+
self.app_instance.event_namespace._token_manager = TokenManager.create()
|
|
389
|
+
|
|
379
390
|
def _start_frontend(self):
|
|
380
391
|
# Set up the frontend.
|
|
381
392
|
with chdir(self.app_path):
|
reflex/utils/decorator.py
CHANGED
|
@@ -76,6 +76,7 @@ def debug(f: Callable[P, T]) -> Callable[P, T]:
|
|
|
76
76
|
def _write_cached_procedure_file(payload: str, cache_file: Path, value: object):
|
|
77
77
|
import pickle
|
|
78
78
|
|
|
79
|
+
cache_file.parent.mkdir(parents=True, exist_ok=True)
|
|
79
80
|
cache_file.write_bytes(pickle.dumps((payload, value)))
|
|
80
81
|
|
|
81
82
|
|