reflex 0.6.8a2__py3-none-any.whl → 0.7.0a2__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/custom_components/pyproject.toml.jinja2 +1 -1
- reflex/.templates/jinja/web/pages/_app.js.jinja2 +7 -7
- reflex/.templates/jinja/web/pages/utils.js.jinja2 +3 -3
- reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +1 -4
- reflex/.templates/web/utils/state.js +65 -36
- reflex/__init__.py +4 -17
- reflex/__init__.pyi +1 -2
- reflex/app.py +249 -116
- reflex/app_mixins/lifespan.py +9 -9
- reflex/app_mixins/middleware.py +6 -6
- reflex/app_module_for_backend.py +3 -7
- reflex/base.py +7 -7
- reflex/compiler/compiler.py +8 -0
- reflex/compiler/utils.py +35 -6
- reflex/components/base/app_wrap.pyi +16 -16
- reflex/components/base/bare.py +1 -1
- reflex/components/base/body.pyi +16 -16
- reflex/components/base/document.pyi +76 -76
- reflex/components/base/error_boundary.py +2 -1
- reflex/components/base/error_boundary.pyi +19 -22
- reflex/components/base/fragment.pyi +16 -16
- reflex/components/base/head.pyi +31 -31
- reflex/components/base/link.pyi +31 -31
- reflex/components/base/meta.py +2 -2
- reflex/components/base/meta.pyi +61 -61
- reflex/components/base/script.pyi +19 -19
- reflex/components/base/strict_mode.py +10 -0
- reflex/components/base/strict_mode.pyi +57 -0
- reflex/components/component.py +38 -77
- reflex/components/core/banner.py +159 -4
- reflex/components/core/banner.pyi +162 -76
- reflex/components/core/breakpoints.py +3 -1
- reflex/components/core/client_side_routing.py +1 -1
- reflex/components/core/client_side_routing.pyi +32 -32
- reflex/components/core/clipboard.pyi +17 -20
- reflex/components/core/cond.py +9 -10
- reflex/components/core/debounce.py +1 -1
- reflex/components/core/debounce.pyi +17 -17
- reflex/components/core/foreach.py +28 -3
- reflex/components/core/html.py +1 -1
- reflex/components/core/html.pyi +16 -16
- reflex/components/core/match.py +5 -5
- reflex/components/core/sticky.py +160 -0
- reflex/components/core/sticky.pyi +449 -0
- reflex/components/core/upload.py +2 -2
- reflex/components/core/upload.pyi +80 -88
- reflex/components/datadisplay/code.py +5 -14
- reflex/components/datadisplay/code.pyi +31 -31
- reflex/components/datadisplay/dataeditor.py +7 -4
- reflex/components/datadisplay/dataeditor.pyi +40 -54
- reflex/components/datadisplay/logo.py +13 -8
- reflex/components/datadisplay/shiki_code_block.py +14 -9
- reflex/components/datadisplay/shiki_code_block.pyi +46 -46
- reflex/components/dynamic.py +22 -3
- reflex/components/el/constants/reflex.py +1 -1
- reflex/components/el/element.py +1 -1
- reflex/components/el/element.pyi +16 -16
- reflex/components/el/elements/base.pyi +16 -16
- reflex/components/el/elements/forms.py +4 -4
- reflex/components/el/elements/forms.pyi +224 -258
- reflex/components/el/elements/inline.pyi +421 -421
- reflex/components/el/elements/media.pyi +376 -376
- reflex/components/el/elements/metadata.pyi +91 -91
- reflex/components/el/elements/other.pyi +106 -106
- reflex/components/el/elements/scripts.pyi +46 -46
- reflex/components/el/elements/sectioning.pyi +226 -226
- reflex/components/el/elements/tables.pyi +151 -151
- reflex/components/el/elements/typography.pyi +226 -226
- reflex/components/gridjs/datatable.pyi +31 -31
- reflex/components/lucide/icon.py +46 -8
- reflex/components/lucide/icon.pyi +85 -31
- reflex/components/markdown/markdown.py +10 -8
- reflex/components/markdown/markdown.pyi +16 -16
- reflex/components/moment/moment.py +2 -2
- reflex/components/moment/moment.pyi +17 -19
- reflex/components/next/base.pyi +16 -16
- reflex/components/next/image.py +16 -4
- reflex/components/next/image.pyi +22 -20
- reflex/components/next/link.py +1 -1
- reflex/components/next/link.pyi +16 -16
- reflex/components/next/video.pyi +16 -16
- reflex/components/plotly/plotly.py +5 -5
- reflex/components/plotly/plotly.pyi +34 -44
- reflex/components/props.py +3 -3
- reflex/components/radix/__init__.pyi +1 -1
- reflex/components/radix/primitives/accordion.py +9 -5
- reflex/components/radix/primitives/accordion.pyi +110 -108
- reflex/components/radix/primitives/base.pyi +31 -31
- reflex/components/radix/primitives/drawer.py +5 -2
- reflex/components/radix/primitives/drawer.pyi +179 -187
- reflex/components/radix/primitives/form.pyi +160 -172
- reflex/components/radix/primitives/progress.py +1 -1
- reflex/components/radix/primitives/progress.pyi +76 -76
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/primitives/slider.pyi +78 -82
- reflex/components/radix/themes/base.pyi +121 -121
- reflex/components/radix/themes/color_mode.py +11 -9
- reflex/components/radix/themes/color_mode.pyi +47 -49
- reflex/components/radix/themes/components/alert_dialog.py +3 -0
- reflex/components/radix/themes/components/alert_dialog.pyi +110 -112
- reflex/components/radix/themes/components/aspect_ratio.pyi +16 -16
- reflex/components/radix/themes/components/avatar.pyi +16 -16
- reflex/components/radix/themes/components/badge.pyi +16 -16
- reflex/components/radix/themes/components/button.pyi +16 -16
- reflex/components/radix/themes/components/callout.pyi +76 -76
- reflex/components/radix/themes/components/card.py +1 -1
- reflex/components/radix/themes/components/card.pyi +17 -17
- reflex/components/radix/themes/components/checkbox.pyi +49 -55
- reflex/components/radix/themes/components/checkbox_cards.pyi +31 -31
- reflex/components/radix/themes/components/checkbox_group.pyi +31 -31
- reflex/components/radix/themes/components/context_menu.py +5 -0
- reflex/components/radix/themes/components/context_menu.pyi +149 -155
- reflex/components/radix/themes/components/data_list.pyi +61 -61
- reflex/components/radix/themes/components/dialog.py +3 -0
- reflex/components/radix/themes/components/dialog.pyi +113 -117
- reflex/components/radix/themes/components/dropdown_menu.py +5 -0
- reflex/components/radix/themes/components/dropdown_menu.pyi +133 -137
- reflex/components/radix/themes/components/hover_card.py +3 -0
- reflex/components/radix/themes/components/hover_card.pyi +63 -67
- reflex/components/radix/themes/components/icon_button.py +2 -2
- reflex/components/radix/themes/components/icon_button.pyi +17 -16
- reflex/components/radix/themes/components/inset.pyi +16 -16
- reflex/components/radix/themes/components/popover.py +3 -0
- reflex/components/radix/themes/components/popover.pyi +68 -70
- reflex/components/radix/themes/components/progress.pyi +16 -16
- reflex/components/radix/themes/components/radio.pyi +16 -16
- reflex/components/radix/themes/components/radio_cards.py +2 -0
- reflex/components/radix/themes/components/radio_cards.pyi +32 -34
- reflex/components/radix/themes/components/radio_group.py +1 -1
- reflex/components/radix/themes/components/radio_group.pyi +62 -64
- reflex/components/radix/themes/components/scroll_area.pyi +16 -16
- reflex/components/radix/themes/components/segmented_control.pyi +32 -35
- reflex/components/radix/themes/components/select.py +4 -0
- reflex/components/radix/themes/components/select.pyi +145 -157
- reflex/components/radix/themes/components/separator.pyi +16 -16
- reflex/components/radix/themes/components/skeleton.py +3 -0
- reflex/components/radix/themes/components/skeleton.pyi +16 -16
- reflex/components/radix/themes/components/slider.pyi +22 -28
- reflex/components/radix/themes/components/spinner.pyi +16 -16
- reflex/components/radix/themes/components/switch.pyi +17 -19
- reflex/components/radix/themes/components/table.pyi +106 -106
- reflex/components/radix/themes/components/tabs.py +3 -0
- reflex/components/radix/themes/components/tabs.pyi +78 -82
- reflex/components/radix/themes/components/text_area.py +12 -0
- reflex/components/radix/themes/components/text_area.pyi +21 -33
- reflex/components/radix/themes/components/text_field.py +1 -1
- reflex/components/radix/themes/components/text_field.pyi +52 -80
- reflex/components/radix/themes/components/tooltip.py +6 -1
- reflex/components/radix/themes/components/tooltip.pyi +20 -21
- reflex/components/radix/themes/layout/__init__.pyi +1 -1
- reflex/components/radix/themes/layout/base.pyi +16 -16
- reflex/components/radix/themes/layout/box.pyi +16 -16
- reflex/components/radix/themes/layout/center.pyi +16 -16
- reflex/components/radix/themes/layout/container.pyi +16 -16
- reflex/components/radix/themes/layout/flex.pyi +16 -16
- reflex/components/radix/themes/layout/grid.pyi +16 -16
- reflex/components/radix/themes/layout/list.py +2 -2
- reflex/components/radix/themes/layout/list.pyi +76 -76
- reflex/components/radix/themes/layout/section.pyi +16 -16
- reflex/components/radix/themes/layout/spacer.pyi +16 -16
- reflex/components/radix/themes/layout/stack.py +2 -2
- reflex/components/radix/themes/layout/stack.pyi +46 -46
- reflex/components/radix/themes/typography/blockquote.pyi +16 -16
- reflex/components/radix/themes/typography/code.pyi +16 -16
- reflex/components/radix/themes/typography/heading.pyi +16 -16
- reflex/components/radix/themes/typography/link.py +1 -1
- reflex/components/radix/themes/typography/link.pyi +16 -16
- reflex/components/radix/themes/typography/text.py +2 -2
- reflex/components/radix/themes/typography/text.pyi +106 -106
- reflex/components/react_player/audio.pyi +33 -39
- reflex/components/react_player/react_player.py +1 -1
- reflex/components/react_player/react_player.pyi +32 -38
- reflex/components/react_player/video.pyi +33 -39
- reflex/components/recharts/__init__.py +2 -0
- reflex/components/recharts/__init__.pyi +2 -0
- reflex/components/recharts/cartesian.pyi +282 -282
- reflex/components/recharts/charts.py +15 -15
- reflex/components/recharts/charts.pyi +164 -164
- reflex/components/recharts/general.py +19 -4
- reflex/components/recharts/general.pyi +132 -81
- reflex/components/recharts/polar.py +2 -2
- reflex/components/recharts/polar.pyi +55 -55
- reflex/components/recharts/recharts.py +4 -4
- reflex/components/recharts/recharts.pyi +31 -31
- reflex/components/sonner/toast.py +15 -13
- reflex/components/sonner/toast.pyi +22 -22
- reflex/components/suneditor/editor.py +6 -4
- reflex/components/suneditor/editor.pyi +26 -40
- reflex/components/tags/iter_tag.py +3 -3
- reflex/components/tags/tag.py +25 -3
- reflex/config.py +48 -15
- reflex/constants/__init__.py +1 -0
- reflex/constants/base.py +4 -1
- reflex/constants/compiler.py +5 -2
- reflex/constants/config.py +8 -1
- reflex/constants/installer.py +9 -9
- reflex/constants/style.py +1 -1
- reflex/custom_components/custom_components.py +9 -7
- reflex/event.py +215 -208
- reflex/experimental/__init__.py +19 -11
- reflex/experimental/client_state.py +53 -28
- reflex/experimental/hooks.py +5 -5
- reflex/experimental/layout.py +8 -5
- reflex/experimental/layout.pyi +79 -83
- reflex/experimental/misc.py +3 -3
- reflex/istate/wrappers.py +1 -1
- reflex/middleware/hydrate_middleware.py +2 -2
- reflex/model.py +11 -6
- reflex/page.py +5 -5
- reflex/reflex.py +90 -19
- reflex/route.py +1 -1
- reflex/state.py +358 -401
- reflex/style.py +27 -3
- reflex/testing.py +29 -23
- reflex/utils/build.py +6 -2
- reflex/utils/codespaces.py +1 -4
- reflex/utils/compat.py +6 -5
- reflex/utils/console.py +52 -16
- reflex/utils/exceptions.py +89 -26
- reflex/utils/exec.py +69 -74
- reflex/utils/export.py +6 -1
- reflex/utils/format.py +8 -40
- reflex/utils/imports.py +2 -2
- reflex/utils/lazy_loader.py +7 -1
- reflex/utils/path_ops.py +28 -14
- reflex/utils/prerequisites.py +326 -67
- reflex/utils/processes.py +45 -32
- reflex/utils/pyi_generator.py +39 -33
- reflex/utils/registry.py +4 -4
- reflex/utils/serializers.py +1 -1
- reflex/utils/telemetry.py +5 -4
- reflex/utils/types.py +42 -18
- reflex/vars/base.py +656 -333
- reflex/vars/datetime.py +6 -7
- reflex/vars/dep_tracking.py +344 -0
- reflex/vars/function.py +11 -5
- reflex/vars/number.py +31 -43
- reflex/vars/object.py +63 -62
- reflex/vars/sequence.py +79 -67
- {reflex-0.6.8a2.dist-info → reflex-0.7.0a2.dist-info}/METADATA +7 -8
- reflex-0.7.0a2.dist-info/RECORD +401 -0
- {reflex-0.6.8a2.dist-info → reflex-0.7.0a2.dist-info}/WHEEL +1 -1
- reflex/experimental/assets.py +0 -37
- reflex-0.6.8a2.dist-info/RECORD +0 -397
- {reflex-0.6.8a2.dist-info → reflex-0.7.0a2.dist-info}/LICENSE +0 -0
- {reflex-0.6.8a2.dist-info → reflex-0.7.0a2.dist-info}/entry_points.txt +0 -0
|
@@ -8,7 +8,7 @@ version = "0.0.1"
|
|
|
8
8
|
description = "Reflex custom component {{ module_name }}"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "Apache-2.0" }
|
|
11
|
-
requires-python = ">=3.
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
12
|
authors = [{ name = "", email = "YOUREMAIL@domain.com" }]
|
|
13
13
|
keywords = ["reflex","reflex-custom-components"]
|
|
14
14
|
|
|
@@ -38,13 +38,13 @@ export default function MyApp({ Component, pageProps }) {
|
|
|
38
38
|
}, []);
|
|
39
39
|
return (
|
|
40
40
|
<ThemeProvider defaultTheme={ defaultColorMode } attribute="class">
|
|
41
|
-
<
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</
|
|
47
|
-
</
|
|
41
|
+
<StateProvider>
|
|
42
|
+
<EventLoopProvider>
|
|
43
|
+
<AppWrap>
|
|
44
|
+
<Component {...pageProps} />
|
|
45
|
+
</AppWrap>
|
|
46
|
+
</EventLoopProvider>
|
|
47
|
+
</StateProvider>
|
|
48
48
|
</ThemeProvider>
|
|
49
49
|
);
|
|
50
50
|
}
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
{# Args: #}
|
|
61
61
|
{# component: component dictionary #}
|
|
62
62
|
{% macro render_iterable_tag(component) %}
|
|
63
|
-
<>{ {
|
|
63
|
+
<>{ {{ component.iterable_state }}.map(({{ component.arg_name }}, {{ component.arg_index }}) => (
|
|
64
64
|
{% for child in component.children %}
|
|
65
65
|
{{ render(child) }}
|
|
66
66
|
{% endfor %}
|
|
@@ -86,11 +86,11 @@
|
|
|
86
86
|
{% for condition in case[:-1] %}
|
|
87
87
|
case JSON.stringify({{ condition._js_expr }}):
|
|
88
88
|
{% endfor %}
|
|
89
|
-
return {{ case[-1] }};
|
|
89
|
+
return {{ render(case[-1]) }};
|
|
90
90
|
break;
|
|
91
91
|
{% endfor %}
|
|
92
92
|
default:
|
|
93
|
-
return {{ component.default }};
|
|
93
|
+
return {{ render(component.default) }};
|
|
94
94
|
break;
|
|
95
95
|
}
|
|
96
96
|
})()
|
|
@@ -16,10 +16,7 @@ export default function RadixThemesColorModeProvider({ children }) {
|
|
|
16
16
|
if (isDevMode) {
|
|
17
17
|
const lastCompiledTimeInLocalStorage =
|
|
18
18
|
localStorage.getItem("last_compiled_time");
|
|
19
|
-
if (
|
|
20
|
-
lastCompiledTimeInLocalStorage &&
|
|
21
|
-
lastCompiledTimeInLocalStorage !== lastCompiledTimeStamp
|
|
22
|
-
) {
|
|
19
|
+
if (lastCompiledTimeInLocalStorage !== lastCompiledTimeStamp) {
|
|
23
20
|
// on app startup, make sure the application color mode is persisted correctly.
|
|
24
21
|
setTheme(defaultColorMode);
|
|
25
22
|
localStorage.setItem("last_compiled_time", lastCompiledTimeStamp);
|
|
@@ -3,6 +3,7 @@ import axios from "axios";
|
|
|
3
3
|
import io from "socket.io-client";
|
|
4
4
|
import JSON5 from "json5";
|
|
5
5
|
import env from "$/env.json";
|
|
6
|
+
import reflexEnvironment from "$/reflex.json";
|
|
6
7
|
import Cookies from "universal-cookie";
|
|
7
8
|
import { useEffect, useRef, useState } from "react";
|
|
8
9
|
import Router, { useRouter } from "next/router";
|
|
@@ -105,6 +106,18 @@ export const getBackendURL = (url_str) => {
|
|
|
105
106
|
return endpoint;
|
|
106
107
|
};
|
|
107
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Check if the backend is disabled.
|
|
111
|
+
*
|
|
112
|
+
* @returns True if the backend is disabled, false otherwise.
|
|
113
|
+
*/
|
|
114
|
+
export const isBackendDisabled = () => {
|
|
115
|
+
const cookie = document.cookie
|
|
116
|
+
.split("; ")
|
|
117
|
+
.find((row) => row.startsWith("backend-enabled="));
|
|
118
|
+
return cookie !== undefined && cookie.split("=")[1] == "false";
|
|
119
|
+
};
|
|
120
|
+
|
|
108
121
|
/**
|
|
109
122
|
* Determine if any event in the event queue is stateful.
|
|
110
123
|
*
|
|
@@ -214,8 +227,8 @@ export const applyEvent = async (event, socket) => {
|
|
|
214
227
|
a.href = eval?.(
|
|
215
228
|
event.payload.url.replace(
|
|
216
229
|
"getBackendURL(env.UPLOAD)",
|
|
217
|
-
`"${getBackendURL(env.UPLOAD)}"
|
|
218
|
-
)
|
|
230
|
+
`"${getBackendURL(env.UPLOAD)}"`,
|
|
231
|
+
),
|
|
219
232
|
);
|
|
220
233
|
}
|
|
221
234
|
a.download = event.payload.filename;
|
|
@@ -300,10 +313,7 @@ export const applyEvent = async (event, socket) => {
|
|
|
300
313
|
|
|
301
314
|
// Send the event to the server.
|
|
302
315
|
if (socket) {
|
|
303
|
-
socket.emit(
|
|
304
|
-
"event",
|
|
305
|
-
event,
|
|
306
|
-
);
|
|
316
|
+
socket.emit("event", event);
|
|
307
317
|
return true;
|
|
308
318
|
}
|
|
309
319
|
|
|
@@ -331,7 +341,7 @@ export const applyRestEvent = async (event, socket) => {
|
|
|
331
341
|
event.payload.files,
|
|
332
342
|
event.payload.upload_id,
|
|
333
343
|
event.payload.on_upload_progress,
|
|
334
|
-
socket
|
|
344
|
+
socket,
|
|
335
345
|
);
|
|
336
346
|
return false;
|
|
337
347
|
}
|
|
@@ -398,7 +408,7 @@ export const connect = async (
|
|
|
398
408
|
dispatch,
|
|
399
409
|
transports,
|
|
400
410
|
setConnectErrors,
|
|
401
|
-
client_storage = {}
|
|
411
|
+
client_storage = {},
|
|
402
412
|
) => {
|
|
403
413
|
// Get backend URL object from the endpoint.
|
|
404
414
|
const endpoint = getBackendURL(EVENTURL);
|
|
@@ -407,10 +417,18 @@ export const connect = async (
|
|
|
407
417
|
socket.current = io(endpoint.href, {
|
|
408
418
|
path: endpoint["pathname"],
|
|
409
419
|
transports: transports,
|
|
420
|
+
protocols: [reflexEnvironment.version],
|
|
410
421
|
autoUnref: false,
|
|
411
422
|
});
|
|
412
423
|
// Ensure undefined fields in events are sent as null instead of removed
|
|
413
|
-
socket.current.io.encoder.replacer = (k, v) => (v === undefined ? null : v)
|
|
424
|
+
socket.current.io.encoder.replacer = (k, v) => (v === undefined ? null : v);
|
|
425
|
+
socket.current.io.decoder.tryParse = (str) => {
|
|
426
|
+
try {
|
|
427
|
+
return JSON5.parse(str);
|
|
428
|
+
} catch (e) {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
};
|
|
414
432
|
|
|
415
433
|
function checkVisibility() {
|
|
416
434
|
if (document.visibilityState === "visible") {
|
|
@@ -481,14 +499,14 @@ export const uploadFiles = async (
|
|
|
481
499
|
files,
|
|
482
500
|
upload_id,
|
|
483
501
|
on_upload_progress,
|
|
484
|
-
socket
|
|
502
|
+
socket,
|
|
485
503
|
) => {
|
|
486
504
|
// return if there's no file to upload
|
|
487
505
|
if (files === undefined || files.length === 0) {
|
|
488
506
|
return false;
|
|
489
507
|
}
|
|
490
508
|
|
|
491
|
-
const upload_ref_name = `__upload_controllers_${upload_id}
|
|
509
|
+
const upload_ref_name = `__upload_controllers_${upload_id}`;
|
|
492
510
|
|
|
493
511
|
if (refs[upload_ref_name]) {
|
|
494
512
|
console.log("Upload already in progress for ", upload_id);
|
|
@@ -586,7 +604,7 @@ export const Event = (
|
|
|
586
604
|
name,
|
|
587
605
|
payload = {},
|
|
588
606
|
event_actions = {},
|
|
589
|
-
handler = null
|
|
607
|
+
handler = null,
|
|
590
608
|
) => {
|
|
591
609
|
return { name, payload, handler, event_actions };
|
|
592
610
|
};
|
|
@@ -613,7 +631,7 @@ export const hydrateClientStorage = (client_storage) => {
|
|
|
613
631
|
for (const state_key in client_storage.local_storage) {
|
|
614
632
|
const options = client_storage.local_storage[state_key];
|
|
615
633
|
const local_storage_value = localStorage.getItem(
|
|
616
|
-
options.name || state_key
|
|
634
|
+
options.name || state_key,
|
|
617
635
|
);
|
|
618
636
|
if (local_storage_value !== null) {
|
|
619
637
|
client_storage_values[state_key] = local_storage_value;
|
|
@@ -624,7 +642,7 @@ export const hydrateClientStorage = (client_storage) => {
|
|
|
624
642
|
for (const state_key in client_storage.session_storage) {
|
|
625
643
|
const session_options = client_storage.session_storage[state_key];
|
|
626
644
|
const session_storage_value = sessionStorage.getItem(
|
|
627
|
-
session_options.name || state_key
|
|
645
|
+
session_options.name || state_key,
|
|
628
646
|
);
|
|
629
647
|
if (session_storage_value != null) {
|
|
630
648
|
client_storage_values[state_key] = session_storage_value;
|
|
@@ -649,7 +667,7 @@ export const hydrateClientStorage = (client_storage) => {
|
|
|
649
667
|
const applyClientStorageDelta = (client_storage, delta) => {
|
|
650
668
|
// find the main state and check for is_hydrated
|
|
651
669
|
const unqualified_states = Object.keys(delta).filter(
|
|
652
|
-
(key) => key.split(".").length === 1
|
|
670
|
+
(key) => key.split(".").length === 1,
|
|
653
671
|
);
|
|
654
672
|
if (unqualified_states.length === 1) {
|
|
655
673
|
const main_state = delta[unqualified_states[0]];
|
|
@@ -683,7 +701,7 @@ const applyClientStorageDelta = (client_storage, delta) => {
|
|
|
683
701
|
const session_options = client_storage.session_storage[state_key];
|
|
684
702
|
sessionStorage.setItem(
|
|
685
703
|
session_options.name || state_key,
|
|
686
|
-
delta[substate][key]
|
|
704
|
+
delta[substate][key],
|
|
687
705
|
);
|
|
688
706
|
}
|
|
689
707
|
}
|
|
@@ -703,7 +721,7 @@ const applyClientStorageDelta = (client_storage, delta) => {
|
|
|
703
721
|
export const useEventLoop = (
|
|
704
722
|
dispatch,
|
|
705
723
|
initial_events = () => [],
|
|
706
|
-
client_storage = {}
|
|
724
|
+
client_storage = {},
|
|
707
725
|
) => {
|
|
708
726
|
const socket = useRef(null);
|
|
709
727
|
const router = useRouter();
|
|
@@ -717,7 +735,7 @@ export const useEventLoop = (
|
|
|
717
735
|
|
|
718
736
|
event_actions = events.reduce(
|
|
719
737
|
(acc, e) => ({ ...acc, ...e.event_actions }),
|
|
720
|
-
event_actions ?? {}
|
|
738
|
+
event_actions ?? {},
|
|
721
739
|
);
|
|
722
740
|
|
|
723
741
|
const _e = args.filter((o) => o?.preventDefault !== undefined)[0];
|
|
@@ -745,7 +763,7 @@ export const useEventLoop = (
|
|
|
745
763
|
debounce(
|
|
746
764
|
combined_name,
|
|
747
765
|
() => queueEvents(events, socket),
|
|
748
|
-
event_actions.debounce
|
|
766
|
+
event_actions.debounce,
|
|
749
767
|
);
|
|
750
768
|
} else {
|
|
751
769
|
queueEvents(events, socket);
|
|
@@ -764,7 +782,7 @@ export const useEventLoop = (
|
|
|
764
782
|
query,
|
|
765
783
|
asPath,
|
|
766
784
|
}))(router),
|
|
767
|
-
}))
|
|
785
|
+
})),
|
|
768
786
|
);
|
|
769
787
|
sentHydrate.current = true;
|
|
770
788
|
}
|
|
@@ -799,14 +817,10 @@ export const useEventLoop = (
|
|
|
799
817
|
};
|
|
800
818
|
}, []);
|
|
801
819
|
|
|
802
|
-
//
|
|
820
|
+
// Handle socket connect/disconnect.
|
|
803
821
|
useEffect(() => {
|
|
804
|
-
//
|
|
805
|
-
if (
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
// only use websockets if state is present
|
|
809
|
-
if (Object.keys(initialState).length > 1) {
|
|
822
|
+
// only use websockets if state is present and backend is not disabled (reflex cloud).
|
|
823
|
+
if (Object.keys(initialState).length > 1 && !isBackendDisabled()) {
|
|
810
824
|
// Initialize the websocket connection.
|
|
811
825
|
if (!socket.current) {
|
|
812
826
|
connect(
|
|
@@ -814,16 +828,31 @@ export const useEventLoop = (
|
|
|
814
828
|
dispatch,
|
|
815
829
|
["websocket"],
|
|
816
830
|
setConnectErrors,
|
|
817
|
-
client_storage
|
|
831
|
+
client_storage,
|
|
818
832
|
);
|
|
819
833
|
}
|
|
820
|
-
(async () => {
|
|
821
|
-
// Process all outstanding events.
|
|
822
|
-
while (event_queue.length > 0 && !event_processing) {
|
|
823
|
-
await processEvent(socket.current);
|
|
824
|
-
}
|
|
825
|
-
})();
|
|
826
834
|
}
|
|
835
|
+
|
|
836
|
+
// Cleanup function.
|
|
837
|
+
return () => {
|
|
838
|
+
if (socket.current) {
|
|
839
|
+
socket.current.disconnect();
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
}, []);
|
|
843
|
+
|
|
844
|
+
// Main event loop.
|
|
845
|
+
useEffect(() => {
|
|
846
|
+
// Skip if the router is not ready.
|
|
847
|
+
if (!router.isReady || isBackendDisabled()) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
(async () => {
|
|
851
|
+
// Process all outstanding events.
|
|
852
|
+
while (event_queue.length > 0 && !event_processing) {
|
|
853
|
+
await processEvent(socket.current);
|
|
854
|
+
}
|
|
855
|
+
})();
|
|
827
856
|
});
|
|
828
857
|
|
|
829
858
|
// localStorage event handling
|
|
@@ -847,7 +876,7 @@ export const useEventLoop = (
|
|
|
847
876
|
vars[storage_to_state_map[e.key]] = e.newValue;
|
|
848
877
|
const event = Event(
|
|
849
878
|
`${state_name}.reflex___state____update_vars_internal_state.update_vars_internal`,
|
|
850
|
-
{ vars: vars }
|
|
879
|
+
{ vars: vars },
|
|
851
880
|
);
|
|
852
881
|
addEvents([event], e);
|
|
853
882
|
}
|
|
@@ -940,7 +969,7 @@ export const getRefValues = (refs) => {
|
|
|
940
969
|
return refs.map((ref) =>
|
|
941
970
|
ref.current
|
|
942
971
|
? ref.current.value || ref.current.getAttribute("aria-valuenow")
|
|
943
|
-
: null
|
|
972
|
+
: null,
|
|
944
973
|
);
|
|
945
974
|
};
|
|
946
975
|
|
reflex/__init__.py
CHANGED
|
@@ -84,6 +84,9 @@ In the example above, you will be able to do `rx.list`
|
|
|
84
84
|
|
|
85
85
|
from __future__ import annotations
|
|
86
86
|
|
|
87
|
+
from types import ModuleType
|
|
88
|
+
from typing import Any
|
|
89
|
+
|
|
87
90
|
from reflex.utils import (
|
|
88
91
|
compat, # for side-effects
|
|
89
92
|
lazy_loader,
|
|
@@ -303,7 +306,6 @@ _MAPPING: dict = {
|
|
|
303
306
|
"event": [
|
|
304
307
|
"EventChain",
|
|
305
308
|
"EventHandler",
|
|
306
|
-
"background",
|
|
307
309
|
"call_script",
|
|
308
310
|
"call_function",
|
|
309
311
|
"run_script",
|
|
@@ -366,20 +368,5 @@ getattr, __dir__, __all__ = lazy_loader.attach(
|
|
|
366
368
|
)
|
|
367
369
|
|
|
368
370
|
|
|
369
|
-
def __getattr__(name):
|
|
370
|
-
if name == "chakra":
|
|
371
|
-
from reflex.utils import console
|
|
372
|
-
|
|
373
|
-
console.deprecate(
|
|
374
|
-
"rx.chakra",
|
|
375
|
-
reason="and moved to a separate package. "
|
|
376
|
-
"To continue using Chakra UI components, install the `reflex-chakra` package via `pip install "
|
|
377
|
-
"reflex-chakra`.",
|
|
378
|
-
deprecation_version="0.6.0",
|
|
379
|
-
removal_version="0.7.0",
|
|
380
|
-
dedupe=True,
|
|
381
|
-
)
|
|
382
|
-
import reflex_chakra as rc
|
|
383
|
-
|
|
384
|
-
return rc
|
|
371
|
+
def __getattr__(name: ModuleType | Any):
|
|
385
372
|
return getattr(name)
|
reflex/__init__.pyi
CHANGED
|
@@ -131,7 +131,7 @@ from .components.radix.themes.layout.container import container as container
|
|
|
131
131
|
from .components.radix.themes.layout.flex import flex as flex
|
|
132
132
|
from .components.radix.themes.layout.grid import grid as grid
|
|
133
133
|
from .components.radix.themes.layout.list import list_item as list_item
|
|
134
|
-
from .components.radix.themes.layout.list import list_ns as list # noqa
|
|
134
|
+
from .components.radix.themes.layout.list import list_ns as list # noqa: F401
|
|
135
135
|
from .components.radix.themes.layout.list import ordered_list as ordered_list
|
|
136
136
|
from .components.radix.themes.layout.list import unordered_list as unordered_list
|
|
137
137
|
from .components.radix.themes.layout.section import section as section
|
|
@@ -156,7 +156,6 @@ from .constants import Env as Env
|
|
|
156
156
|
from .constants.colors import Color as Color
|
|
157
157
|
from .event import EventChain as EventChain
|
|
158
158
|
from .event import EventHandler as EventHandler
|
|
159
|
-
from .event import background as background
|
|
160
159
|
from .event import call_function as call_function
|
|
161
160
|
from .event import call_script as call_script
|
|
162
161
|
from .event import clear_local_storage as clear_local_storage
|