reflex 0.6.3.post1__py3-none-any.whl → 0.6.4a1__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.

Files changed (96) hide show
  1. reflex/.templates/jinja/web/pages/_app.js.jinja2 +2 -2
  2. reflex/.templates/jinja/web/utils/context.js.jinja2 +3 -1
  3. reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +3 -3
  4. reflex/.templates/web/components/shiki/code.js +29 -0
  5. reflex/.templates/web/jsconfig.json +2 -1
  6. reflex/.templates/web/utils/state.js +6 -4
  7. reflex/__init__.py +6 -3
  8. reflex/__init__.pyi +4 -3
  9. reflex/app.py +6 -5
  10. reflex/compiler/compiler.py +6 -7
  11. reflex/compiler/utils.py +8 -1
  12. reflex/components/base/error_boundary.py +37 -24
  13. reflex/components/base/error_boundary.pyi +8 -7
  14. reflex/components/component.py +8 -3
  15. reflex/components/core/banner.py +2 -2
  16. reflex/components/core/client_side_routing.py +1 -1
  17. reflex/components/core/clipboard.py +1 -1
  18. reflex/components/core/clipboard.pyi +1 -1
  19. reflex/components/core/cond.py +1 -1
  20. reflex/components/core/debounce.py +5 -1
  21. reflex/components/core/upload.py +7 -9
  22. reflex/components/core/upload.pyi +2 -2
  23. reflex/components/datadisplay/code.py +1 -1
  24. reflex/components/datadisplay/dataeditor.py +83 -18
  25. reflex/components/datadisplay/dataeditor.pyi +67 -15
  26. reflex/components/datadisplay/shiki_code_block.py +813 -0
  27. reflex/components/datadisplay/shiki_code_block.pyi +2211 -0
  28. reflex/components/dynamic.py +3 -3
  29. reflex/components/el/elements/forms.py +37 -23
  30. reflex/components/el/elements/forms.pyi +7 -4
  31. reflex/components/markdown/markdown.py +12 -1
  32. reflex/components/moment/moment.pyi +1 -1
  33. reflex/components/radix/primitives/drawer.pyi +2 -2
  34. reflex/components/radix/themes/base.py +2 -2
  35. reflex/components/radix/themes/color_mode.pyi +1 -1
  36. reflex/components/radix/themes/components/alert_dialog.pyi +1 -1
  37. reflex/components/radix/themes/components/checkbox.pyi +3 -3
  38. reflex/components/radix/themes/components/context_menu.pyi +1 -1
  39. reflex/components/radix/themes/components/dialog.pyi +2 -2
  40. reflex/components/radix/themes/components/dropdown_menu.pyi +2 -2
  41. reflex/components/radix/themes/components/hover_card.pyi +2 -2
  42. reflex/components/radix/themes/components/popover.pyi +1 -1
  43. reflex/components/radix/themes/components/radio_cards.pyi +1 -1
  44. reflex/components/radix/themes/components/radio_group.pyi +1 -1
  45. reflex/components/radix/themes/components/select.pyi +6 -6
  46. reflex/components/radix/themes/components/switch.pyi +1 -1
  47. reflex/components/radix/themes/components/tabs.pyi +2 -2
  48. reflex/components/radix/themes/components/tooltip.pyi +4 -2
  49. reflex/components/react_player/__init__.py +1 -0
  50. reflex/components/react_player/audio.pyi +6 -3
  51. reflex/components/react_player/react_player.py +12 -1
  52. reflex/components/react_player/react_player.pyi +11 -3
  53. reflex/components/react_player/video.pyi +6 -3
  54. reflex/components/recharts/recharts.py +2 -2
  55. reflex/components/sonner/toast.py +1 -1
  56. reflex/components/suneditor/editor.py +40 -16
  57. reflex/components/suneditor/editor.pyi +15 -11
  58. reflex/config.py +236 -20
  59. reflex/constants/__init__.py +2 -0
  60. reflex/constants/base.py +53 -31
  61. reflex/constants/compiler.py +2 -12
  62. reflex/constants/config.py +1 -2
  63. reflex/constants/installer.py +88 -32
  64. reflex/constants/style.py +1 -1
  65. reflex/constants/utils.py +32 -0
  66. reflex/custom_components/custom_components.py +3 -3
  67. reflex/event.py +147 -84
  68. reflex/experimental/__init__.py +2 -0
  69. reflex/experimental/client_state.py +1 -1
  70. reflex/experimental/layout.pyi +1 -1
  71. reflex/istate/storage.py +144 -0
  72. reflex/model.py +8 -11
  73. reflex/reflex.py +18 -17
  74. reflex/state.py +83 -149
  75. reflex/style.py +1 -1
  76. reflex/testing.py +2 -1
  77. reflex/utils/build.py +0 -12
  78. reflex/utils/exceptions.py +8 -0
  79. reflex/utils/exec.py +22 -4
  80. reflex/utils/imports.py +6 -0
  81. reflex/utils/net.py +2 -4
  82. reflex/utils/path_ops.py +7 -21
  83. reflex/utils/prerequisites.py +11 -17
  84. reflex/utils/pyi_generator.py +91 -3
  85. reflex/utils/registry.py +2 -6
  86. reflex/utils/types.py +14 -0
  87. reflex/vars/base.py +453 -424
  88. reflex/vars/function.py +6 -16
  89. reflex/vars/number.py +46 -67
  90. reflex/vars/object.py +1 -31
  91. reflex/vars/sequence.py +177 -47
  92. {reflex-0.6.3.post1.dist-info → reflex-0.6.4a1.dist-info}/METADATA +1 -1
  93. {reflex-0.6.3.post1.dist-info → reflex-0.6.4a1.dist-info}/RECORD +96 -91
  94. {reflex-0.6.3.post1.dist-info → reflex-0.6.4a1.dist-info}/LICENSE +0 -0
  95. {reflex-0.6.3.post1.dist-info → reflex-0.6.4a1.dist-info}/WHEEL +0 -0
  96. {reflex-0.6.3.post1.dist-info → reflex-0.6.4a1.dist-info}/entry_points.txt +0 -0
@@ -1,11 +1,11 @@
1
1
  {% extends "web/pages/base_page.js.jinja2" %}
2
2
 
3
3
  {% block early_imports %}
4
- import '/styles/styles.css'
4
+ import '$/styles/styles.css'
5
5
  {% endblock %}
6
6
 
7
7
  {% block declaration %}
8
- import { EventLoopProvider, StateProvider, defaultColorMode } from "/utils/context.js";
8
+ import { EventLoopProvider, StateProvider, defaultColorMode } from "$/utils/context.js";
9
9
  import { ThemeProvider } from 'next-themes'
10
10
  {% for library_alias, library_path in window_libraries %}
11
11
  import * as {{library_alias}} from "{{library_path}}";
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext, useMemo, useReducer, useState } from "react"
2
- import { applyDelta, Event, hydrateClientStorage, useEventLoop, refs } from "/utils/state.js"
2
+ import { applyDelta, Event, hydrateClientStorage, useEventLoop, refs } from "$/utils/state.js"
3
3
 
4
4
  {% if initial_state %}
5
5
  export const initialState = {{ initial_state|json_dumps }}
@@ -59,6 +59,8 @@ export const initialEvents = () => [
59
59
  {% else %}
60
60
  export const state_name = undefined
61
61
 
62
+ export const exception_state_name = undefined
63
+
62
64
  export const onLoadInternalEvent = () => []
63
65
 
64
66
  export const initialEvents = () => []
@@ -4,8 +4,8 @@ import {
4
4
  ColorModeContext,
5
5
  defaultColorMode,
6
6
  isDevMode,
7
- lastCompiledTimeStamp
8
- } from "/utils/context.js";
7
+ lastCompiledTimeStamp,
8
+ } from "$/utils/context.js";
9
9
 
10
10
  export default function RadixThemesColorModeProvider({ children }) {
11
11
  const { theme, resolvedTheme, setTheme } = useTheme();
@@ -37,7 +37,7 @@ export default function RadixThemesColorModeProvider({ children }) {
37
37
  const allowedModes = ["light", "dark", "system"];
38
38
  if (!allowedModes.includes(mode)) {
39
39
  console.error(
40
- `Invalid color mode "${mode}". Defaulting to "${defaultColorMode}".`,
40
+ `Invalid color mode "${mode}". Defaulting to "${defaultColorMode}".`
41
41
  );
42
42
  mode = defaultColorMode;
43
43
  }
@@ -0,0 +1,29 @@
1
+ import { useEffect, useState } from "react"
2
+ import { codeToHtml} from "shiki"
3
+
4
+ export function Code ({code, theme, language, transformers, ...divProps}) {
5
+ const [codeResult, setCodeResult] = useState("")
6
+ useEffect(() => {
7
+ async function fetchCode() {
8
+ let final_code;
9
+
10
+ if (Array.isArray(code)) {
11
+ final_code = code[0];
12
+ } else {
13
+ final_code = code;
14
+ }
15
+ const result = await codeToHtml(final_code, {
16
+ lang: language,
17
+ theme,
18
+ transformers
19
+ });
20
+ setCodeResult(result);
21
+ }
22
+ fetchCode();
23
+ }, [code, language, theme, transformers]
24
+
25
+ )
26
+ return (
27
+ <div dangerouslySetInnerHTML={{__html: codeResult}} {...divProps} ></div>
28
+ )
29
+ }
@@ -2,7 +2,8 @@
2
2
  "compilerOptions": {
3
3
  "baseUrl": ".",
4
4
  "paths": {
5
+ "$/*": ["*"],
5
6
  "@/*": ["public/*"]
6
7
  }
7
8
  }
8
- }
9
+ }
@@ -2,7 +2,7 @@
2
2
  import axios from "axios";
3
3
  import io from "socket.io-client";
4
4
  import JSON5 from "json5";
5
- import env from "/env.json";
5
+ import env from "$/env.json";
6
6
  import Cookies from "universal-cookie";
7
7
  import { useEffect, useRef, useState } from "react";
8
8
  import Router, { useRouter } from "next/router";
@@ -12,9 +12,9 @@ import {
12
12
  onLoadInternalEvent,
13
13
  state_name,
14
14
  exception_state_name,
15
- } from "utils/context.js";
16
- import debounce from "/utils/helpers/debounce";
17
- import throttle from "/utils/helpers/throttle";
15
+ } from "$/utils/context.js";
16
+ import debounce from "$/utils/helpers/debounce";
17
+ import throttle from "$/utils/helpers/throttle";
18
18
  import * as Babel from "@babel/standalone";
19
19
 
20
20
  // Endpoint URLs.
@@ -743,6 +743,7 @@ export const useEventLoop = (
743
743
  addEvents([
744
744
  Event(`${exception_state_name}.handle_frontend_exception`, {
745
745
  stack: error.stack,
746
+ component_stack: "",
746
747
  }),
747
748
  ]);
748
749
  return false;
@@ -754,6 +755,7 @@ export const useEventLoop = (
754
755
  addEvents([
755
756
  Event(`${exception_state_name}.handle_frontend_exception`, {
756
757
  stack: event.reason.stack,
758
+ component_stack: "",
757
759
  }),
758
760
  ]);
759
761
  return false;
reflex/__init__.py CHANGED
@@ -320,15 +320,18 @@ _MAPPING: dict = {
320
320
  "upload_files",
321
321
  "window_alert",
322
322
  ],
323
+ "istate.storage": [
324
+ "Cookie",
325
+ "LocalStorage",
326
+ "SessionStorage",
327
+ ],
323
328
  "middleware": ["middleware", "Middleware"],
324
329
  "model": ["session", "Model"],
325
330
  "state": [
326
331
  "var",
327
- "Cookie",
328
- "LocalStorage",
329
- "SessionStorage",
330
332
  "ComponentState",
331
333
  "State",
334
+ "dynamic",
332
335
  ],
333
336
  "style": ["Style", "toggle_color_mode"],
334
337
  "utils.imports": ["ImportVar"],
reflex/__init__.pyi CHANGED
@@ -174,16 +174,17 @@ from .event import stop_propagation as stop_propagation
174
174
  from .event import upload_files as upload_files
175
175
  from .event import window_alert as window_alert
176
176
  from .experimental import _x as _x
177
+ from .istate.storage import Cookie as Cookie
178
+ from .istate.storage import LocalStorage as LocalStorage
179
+ from .istate.storage import SessionStorage as SessionStorage
177
180
  from .middleware import Middleware as Middleware
178
181
  from .middleware import middleware as middleware
179
182
  from .model import Model as Model
180
183
  from .model import session as session
181
184
  from .page import page as page
182
185
  from .state import ComponentState as ComponentState
183
- from .state import Cookie as Cookie
184
- from .state import LocalStorage as LocalStorage
185
- from .state import SessionStorage as SessionStorage
186
186
  from .state import State as State
187
+ from .state import dynamic as dynamic
187
188
  from .state import var as var
188
189
  from .style import Style as Style
189
190
  from .style import toggle_color_mode as toggle_color_mode
reflex/app.py CHANGED
@@ -64,7 +64,7 @@ from reflex.components.core.client_side_routing import (
64
64
  )
65
65
  from reflex.components.core.upload import Upload, get_upload_dir
66
66
  from reflex.components.radix import themes
67
- from reflex.config import get_config
67
+ from reflex.config import environment, get_config
68
68
  from reflex.event import Event, EventHandler, EventSpec, window_alert
69
69
  from reflex.model import Model, get_db_status
70
70
  from reflex.page import (
@@ -679,7 +679,7 @@ class App(MiddlewareMixin, LifespanMixin, Base):
679
679
  for i, tags in imports.items()
680
680
  if i not in constants.PackageJson.DEPENDENCIES
681
681
  and i not in constants.PackageJson.DEV_DEPENDENCIES
682
- and not any(i.startswith(prefix) for prefix in ["/", ".", "next/"])
682
+ and not any(i.startswith(prefix) for prefix in ["/", "$/", ".", "next/"])
683
683
  and i != ""
684
684
  and any(tag.install for tag in tags)
685
685
  }
@@ -957,15 +957,16 @@ class App(MiddlewareMixin, LifespanMixin, Base):
957
957
  executor = None
958
958
  if (
959
959
  platform.system() in ("Linux", "Darwin")
960
- and os.environ.get("REFLEX_COMPILE_PROCESSES") is not None
960
+ and (number_of_processes := environment.REFLEX_COMPILE_PROCESSES)
961
+ is not None
961
962
  ):
962
963
  executor = concurrent.futures.ProcessPoolExecutor(
963
- max_workers=int(os.environ.get("REFLEX_COMPILE_PROCESSES", 0)) or None,
964
+ max_workers=number_of_processes,
964
965
  mp_context=multiprocessing.get_context("fork"),
965
966
  )
966
967
  else:
967
968
  executor = concurrent.futures.ThreadPoolExecutor(
968
- max_workers=int(os.environ.get("REFLEX_COMPILE_THREADS", 0)) or None,
969
+ max_workers=environment.REFLEX_COMPILE_THREADS
969
970
  )
970
971
 
971
972
  with executor:
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import os
6
5
  from datetime import datetime
7
6
  from pathlib import Path
8
7
  from typing import Dict, Iterable, Optional, Type, Union
@@ -16,7 +15,7 @@ from reflex.components.component import (
16
15
  CustomComponent,
17
16
  StatefulComponent,
18
17
  )
19
- from reflex.config import get_config
18
+ from reflex.config import environment, get_config
20
19
  from reflex.state import BaseState
21
20
  from reflex.style import SYSTEM_COLOR_MODE
22
21
  from reflex.utils.exec import is_prod_mode
@@ -68,8 +67,8 @@ def _compile_app(app_root: Component) -> str:
68
67
  window_libraries = [
69
68
  (_normalize_library_name(name), name) for name in bundled_libraries
70
69
  ] + [
71
- ("utils_context", f"/{constants.Dirs.UTILS}/context"),
72
- ("utils_state", f"/{constants.Dirs.UTILS}/state"),
70
+ ("utils_context", f"$/{constants.Dirs.UTILS}/context"),
71
+ ("utils_state", f"$/{constants.Dirs.UTILS}/state"),
73
72
  ]
74
73
 
75
74
  return templates.APP_ROOT.render(
@@ -229,7 +228,7 @@ def _compile_components(
229
228
  """
230
229
  imports = {
231
230
  "react": [ImportVar(tag="memo")],
232
- f"/{constants.Dirs.STATE_PATH}": [ImportVar(tag="E"), ImportVar(tag="isTrue")],
231
+ f"$/{constants.Dirs.STATE_PATH}": [ImportVar(tag="E"), ImportVar(tag="isTrue")],
233
232
  }
234
233
  component_renders = []
235
234
 
@@ -316,7 +315,7 @@ def _compile_stateful_components(
316
315
  # Don't import from the file that we're about to create.
317
316
  all_imports = utils.merge_imports(*all_import_dicts)
318
317
  all_imports.pop(
319
- f"/{constants.Dirs.UTILS}/{constants.PageNames.STATEFUL_COMPONENTS}", None
318
+ f"$/{constants.Dirs.UTILS}/{constants.PageNames.STATEFUL_COMPONENTS}", None
320
319
  )
321
320
 
322
321
  return templates.STATEFUL_COMPONENTS.render(
@@ -527,7 +526,7 @@ def remove_tailwind_from_postcss() -> tuple[str, str]:
527
526
 
528
527
  def purge_web_pages_dir():
529
528
  """Empty out .web/pages directory."""
530
- if not is_prod_mode() and os.environ.get("REFLEX_PERSIST_WEB_DIR"):
529
+ if not is_prod_mode() and environment.REFLEX_PERSIST_WEB_DIR:
531
530
  # Skip purging the web directory in dev mode if REFLEX_PERSIST_WEB_DIR is set.
532
531
  return
533
532
 
reflex/compiler/utils.py CHANGED
@@ -28,7 +28,8 @@ from reflex.components.base import (
28
28
  Title,
29
29
  )
30
30
  from reflex.components.component import Component, ComponentStyle, CustomComponent
31
- from reflex.state import BaseState, Cookie, LocalStorage, SessionStorage
31
+ from reflex.istate.storage import Cookie, LocalStorage, SessionStorage
32
+ from reflex.state import BaseState
32
33
  from reflex.style import Style
33
34
  from reflex.utils import console, format, imports, path_ops
34
35
  from reflex.utils.imports import ImportVar, ParsedImportDict
@@ -82,6 +83,12 @@ def validate_imports(import_dict: ParsedImportDict):
82
83
  f"{_import.tag}/{_import.alias}" if _import.alias else _import.tag
83
84
  )
84
85
  if import_name in used_tags:
86
+ already_imported = used_tags[import_name]
87
+ if (already_imported[0] == "$" and already_imported[1:] == lib) or (
88
+ lib[0] == "$" and lib[1:] == already_imported
89
+ ):
90
+ used_tags[import_name] = lib if lib[0] == "$" else already_imported
91
+ continue
85
92
  raise ValueError(
86
93
  f"Can not compile, the tag {import_name} is used multiple time from {lib} and {used_tags[import_name]}"
87
94
  )
@@ -2,16 +2,32 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List
5
+ from typing import Dict, List, Tuple
6
6
 
7
7
  from reflex.compiler.compiler import _compile_component
8
8
  from reflex.components.component import Component
9
9
  from reflex.components.el import div, p
10
- from reflex.constants import Hooks, Imports
11
- from reflex.event import EventChain, EventHandler
12
- from reflex.utils.imports import ImportVar
10
+ from reflex.event import EventHandler
11
+ from reflex.state import FrontendEventExceptionState
13
12
  from reflex.vars.base import Var
14
- from reflex.vars.function import FunctionVar
13
+
14
+
15
+ def on_error_spec(
16
+ error: Var[Dict[str, str]], info: Var[Dict[str, str]]
17
+ ) -> Tuple[Var[str], Var[str]]:
18
+ """The spec for the on_error event handler.
19
+
20
+ Args:
21
+ error: The error message.
22
+ info: Additional information about the error.
23
+
24
+ Returns:
25
+ The arguments for the event handler.
26
+ """
27
+ return (
28
+ error.stack,
29
+ info.componentStack,
30
+ )
15
31
 
16
32
 
17
33
  class ErrorBoundary(Component):
@@ -21,31 +37,13 @@ class ErrorBoundary(Component):
21
37
  tag = "ErrorBoundary"
22
38
 
23
39
  # Fired when the boundary catches an error.
24
- on_error: EventHandler[lambda error, info: [error, info]] = Var( # type: ignore
25
- "logFrontendError"
26
- ).to(FunctionVar, EventChain)
40
+ on_error: EventHandler[on_error_spec]
27
41
 
28
42
  # Rendered instead of the children when an error is caught.
29
43
  Fallback_component: Var[Component] = Var(_js_expr="Fallback")._replace(
30
44
  _var_type=Component
31
45
  )
32
46
 
33
- def add_imports(self) -> dict[str, list[ImportVar]]:
34
- """Add imports for the component.
35
-
36
- Returns:
37
- The imports to add.
38
- """
39
- return Imports.EVENTS
40
-
41
- def add_hooks(self) -> List[str | Var]:
42
- """Add hooks for the component.
43
-
44
- Returns:
45
- The hooks to add.
46
- """
47
- return [Hooks.EVENTS, Hooks.FRONTEND_ERRORS]
48
-
49
47
  def add_custom_code(self) -> List[str]:
50
48
  """Add custom Javascript code into the page that contains this component.
51
49
 
@@ -75,5 +73,20 @@ class ErrorBoundary(Component):
75
73
  """
76
74
  ]
77
75
 
76
+ @classmethod
77
+ def create(cls, *children, **props):
78
+ """Create an ErrorBoundary component.
79
+
80
+ Args:
81
+ *children: The children of the component.
82
+ **props: The props of the component.
83
+
84
+ Returns:
85
+ The ErrorBoundary component.
86
+ """
87
+ if "on_error" not in props:
88
+ props["on_error"] = FrontendEventExceptionState.handle_frontend_exception
89
+ return super().create(*children, **props)
90
+
78
91
 
79
92
  error_boundary = ErrorBoundary.create
@@ -3,17 +3,18 @@
3
3
  # ------------------- DO NOT EDIT ----------------------
4
4
  # This file was generated by `reflex/utils/pyi_generator.py`!
5
5
  # ------------------------------------------------------
6
- from typing import Any, Dict, List, Optional, Union, overload
6
+ from typing import Any, Dict, List, Optional, Tuple, Union, overload
7
7
 
8
8
  from reflex.components.component import Component
9
9
  from reflex.event import EventType
10
10
  from reflex.style import Style
11
- from reflex.utils.imports import ImportVar
12
11
  from reflex.vars.base import Var
13
12
 
13
+ def on_error_spec(
14
+ error: Var[Dict[str, str]], info: Var[Dict[str, str]]
15
+ ) -> Tuple[Var[str], Var[str]]: ...
16
+
14
17
  class ErrorBoundary(Component):
15
- def add_imports(self) -> dict[str, list[ImportVar]]: ...
16
- def add_hooks(self) -> List[str | Var]: ...
17
18
  def add_custom_code(self) -> List[str]: ...
18
19
  @overload
19
20
  @classmethod
@@ -31,7 +32,7 @@ class ErrorBoundary(Component):
31
32
  on_click: Optional[EventType[[]]] = None,
32
33
  on_context_menu: Optional[EventType[[]]] = None,
33
34
  on_double_click: Optional[EventType[[]]] = None,
34
- on_error: Optional[EventType] = None,
35
+ on_error: Optional[EventType[str, str]] = None,
35
36
  on_focus: Optional[EventType[[]]] = None,
36
37
  on_mount: Optional[EventType[[]]] = None,
37
38
  on_mouse_down: Optional[EventType[[]]] = None,
@@ -45,7 +46,7 @@ class ErrorBoundary(Component):
45
46
  on_unmount: Optional[EventType[[]]] = None,
46
47
  **props,
47
48
  ) -> "ErrorBoundary":
48
- """Create the component.
49
+ """Create an ErrorBoundary component.
49
50
 
50
51
  Args:
51
52
  *children: The children of the component.
@@ -59,7 +60,7 @@ class ErrorBoundary(Component):
59
60
  **props: The props of the component.
60
61
 
61
62
  Returns:
62
- The component.
63
+ The ErrorBoundary component.
63
64
  """
64
65
  ...
65
66
 
@@ -38,6 +38,7 @@ from reflex.constants import (
38
38
  )
39
39
  from reflex.constants.compiler import SpecialAttributes
40
40
  from reflex.event import (
41
+ EventCallback,
41
42
  EventChain,
42
43
  EventChainVar,
43
44
  EventHandler,
@@ -1126,6 +1127,8 @@ class Component(BaseComponent, ABC):
1126
1127
  for trigger in self.event_triggers.values():
1127
1128
  if isinstance(trigger, EventChain):
1128
1129
  for event in trigger.events:
1130
+ if isinstance(event, EventCallback):
1131
+ continue
1129
1132
  if isinstance(event, EventSpec):
1130
1133
  if event.handler.state_full_name:
1131
1134
  return True
@@ -1305,7 +1308,9 @@ class Component(BaseComponent, ABC):
1305
1308
  if self._get_ref_hook():
1306
1309
  # Handle hooks needed for attaching react refs to DOM nodes.
1307
1310
  _imports.setdefault("react", set()).add(ImportVar(tag="useRef"))
1308
- _imports.setdefault(f"/{Dirs.STATE_PATH}", set()).add(ImportVar(tag="refs"))
1311
+ _imports.setdefault(f"$/{Dirs.STATE_PATH}", set()).add(
1312
+ ImportVar(tag="refs")
1313
+ )
1309
1314
 
1310
1315
  if self._get_mount_lifecycle_hook():
1311
1316
  # Handle hooks for `on_mount` / `on_unmount`.
@@ -1662,7 +1667,7 @@ class CustomComponent(Component):
1662
1667
  """A custom user-defined component."""
1663
1668
 
1664
1669
  # Use the components library.
1665
- library = f"/{Dirs.COMPONENTS_PATH}"
1670
+ library = f"$/{Dirs.COMPONENTS_PATH}"
1666
1671
 
1667
1672
  # The function that creates the component.
1668
1673
  component_fn: Callable[..., Component] = Component.create
@@ -2230,7 +2235,7 @@ class StatefulComponent(BaseComponent):
2230
2235
  """
2231
2236
  if self.rendered_as_shared:
2232
2237
  return {
2233
- f"/{Dirs.UTILS}/{PageNames.STATEFUL_COMPONENTS}": [
2238
+ f"$/{Dirs.UTILS}/{PageNames.STATEFUL_COMPONENTS}": [
2234
2239
  ImportVar(tag=self.tag)
2235
2240
  ]
2236
2241
  }
@@ -66,8 +66,8 @@ class WebsocketTargetURL(Var):
66
66
  _js_expr="getBackendURL(env.EVENT).href",
67
67
  _var_data=VarData(
68
68
  imports={
69
- "/env.json": [ImportVar(tag="env", is_default=True)],
70
- f"/{Dirs.STATE_PATH}": [ImportVar(tag="getBackendURL")],
69
+ "$/env.json": [ImportVar(tag="env", is_default=True)],
70
+ f"$/{Dirs.STATE_PATH}": [ImportVar(tag="getBackendURL")],
71
71
  },
72
72
  ),
73
73
  _var_type=WebsocketTargetURL,
@@ -21,7 +21,7 @@ route_not_found: Var = Var(_js_expr=constants.ROUTE_NOT_FOUND)
21
21
  class ClientSideRouting(Component):
22
22
  """The client-side routing component."""
23
23
 
24
- library = "/utils/client_side_routing"
24
+ library = "$/utils/client_side_routing"
25
25
  tag = "useClientSideRouting"
26
26
 
27
27
  def add_hooks(self) -> list[str]:
@@ -67,7 +67,7 @@ class Clipboard(Fragment):
67
67
  The import dict for the component.
68
68
  """
69
69
  return {
70
- "/utils/helpers/paste.js": ImportVar(
70
+ "$/utils/helpers/paste.js": ImportVar(
71
71
  tag="usePasteHandler", is_default=True
72
72
  ),
73
73
  }
@@ -40,7 +40,7 @@ class Clipboard(Fragment):
40
40
  on_mouse_out: Optional[EventType[[]]] = None,
41
41
  on_mouse_over: Optional[EventType[[]]] = None,
42
42
  on_mouse_up: Optional[EventType[[]]] = None,
43
- on_paste: Optional[EventType] = None,
43
+ on_paste: Optional[EventType[list[tuple[str, str]]]] = None,
44
44
  on_scroll: Optional[EventType[[]]] = None,
45
45
  on_unmount: Optional[EventType[[]]] = None,
46
46
  **props,
@@ -15,7 +15,7 @@ from reflex.vars.base import LiteralVar, Var
15
15
  from reflex.vars.number import ternary_operation
16
16
 
17
17
  _IS_TRUE_IMPORT: ImportDict = {
18
- f"/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")],
18
+ f"$/{Dirs.STATE_PATH}": [ImportVar(tag="isTrue")],
19
19
  }
20
20
 
21
21
 
@@ -118,7 +118,7 @@ class DebounceInput(Component):
118
118
  _var_type=Type[Component],
119
119
  _var_data=VarData(
120
120
  imports=child._get_imports(),
121
- hooks=child._get_hooks_internal(),
121
+ hooks=child._get_all_hooks(),
122
122
  ),
123
123
  ),
124
124
  )
@@ -128,6 +128,10 @@ class DebounceInput(Component):
128
128
  component.event_triggers.update(child.event_triggers)
129
129
  component.children = child.children
130
130
  component._rename_props = child._rename_props
131
+ outer_get_all_custom_code = component._get_all_custom_code
132
+ component._get_all_custom_code = lambda: outer_get_all_custom_code().union(
133
+ child._get_all_custom_code()
134
+ )
131
135
  return component
132
136
 
133
137
  def _render(self):
@@ -2,13 +2,13 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import os
6
5
  from pathlib import Path
7
6
  from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple
8
7
 
9
8
  from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
10
9
  from reflex.components.el.elements.forms import Input
11
10
  from reflex.components.radix.themes.layout.box import Box
11
+ from reflex.config import environment
12
12
  from reflex.constants import Dirs
13
13
  from reflex.event import (
14
14
  CallableEventSpec,
@@ -29,7 +29,7 @@ DEFAULT_UPLOAD_ID: str = "default"
29
29
  upload_files_context_var_data: VarData = VarData(
30
30
  imports={
31
31
  "react": "useContext",
32
- f"/{Dirs.CONTEXTS_PATH}": "UploadFilesContext",
32
+ f"$/{Dirs.CONTEXTS_PATH}": "UploadFilesContext",
33
33
  },
34
34
  hooks={
35
35
  "const [filesById, setFilesById] = useContext(UploadFilesContext);": None,
@@ -125,9 +125,7 @@ def get_upload_dir() -> Path:
125
125
  """
126
126
  Upload.is_used = True
127
127
 
128
- uploaded_files_dir = Path(
129
- os.environ.get("REFLEX_UPLOADED_FILES_DIR", "./uploaded_files")
130
- )
128
+ uploaded_files_dir = environment.REFLEX_UPLOADED_FILES_DIR
131
129
  uploaded_files_dir.mkdir(parents=True, exist_ok=True)
132
130
  return uploaded_files_dir
133
131
 
@@ -136,8 +134,8 @@ uploaded_files_url_prefix = Var(
136
134
  _js_expr="getBackendURL(env.UPLOAD)",
137
135
  _var_data=VarData(
138
136
  imports={
139
- f"/{Dirs.STATE_PATH}": "getBackendURL",
140
- "/env.json": ImportVar(tag="env", is_default=True),
137
+ f"$/{Dirs.STATE_PATH}": "getBackendURL",
138
+ "$/env.json": ImportVar(tag="env", is_default=True),
141
139
  }
142
140
  ),
143
141
  ).to(str)
@@ -172,14 +170,14 @@ def _on_drop_spec(files: Var) -> Tuple[Var[Any]]:
172
170
  class UploadFilesProvider(Component):
173
171
  """AppWrap component that provides a dict of selected files by ID via useContext."""
174
172
 
175
- library = f"/{Dirs.CONTEXTS_PATH}"
173
+ library = f"$/{Dirs.CONTEXTS_PATH}"
176
174
  tag = "UploadFilesProvider"
177
175
 
178
176
 
179
177
  class Upload(MemoizationLeaf):
180
178
  """A file upload component."""
181
179
 
182
- library = "react-dropzone@14.2.9"
180
+ library = "react-dropzone@14.2.10"
183
181
 
184
182
  tag = "ReactDropzone"
185
183
 
@@ -34,8 +34,8 @@ uploaded_files_url_prefix = Var(
34
34
  _js_expr="getBackendURL(env.UPLOAD)",
35
35
  _var_data=VarData(
36
36
  imports={
37
- f"/{Dirs.STATE_PATH}": "getBackendURL",
38
- "/env.json": ImportVar(tag="env", is_default=True),
37
+ f"$/{Dirs.STATE_PATH}": "getBackendURL",
38
+ "$/env.json": ImportVar(tag="env", is_default=True),
39
39
  }
40
40
  ),
41
41
  ).to(str)
@@ -381,7 +381,7 @@ for theme_name in dir(Theme):
381
381
  class CodeBlock(Component):
382
382
  """A code block."""
383
383
 
384
- library = "react-syntax-highlighter@15.5.0"
384
+ library = "react-syntax-highlighter@15.6.1"
385
385
 
386
386
  tag = "PrismAsyncLight"
387
387