Commit Graph

390 Commits

Author SHA1 Message Date
Elijah Ahianyo
34bf25071a
[REF-2821]Improve Dynamic Imports (#3345)
* Improve import times

* add lazy loading to rx.el

* add lazy loading to reflex core components

* minor refactor

* Get imports working with reflex web

* get imports to work with all reflex examples

* refactor to define imports only in the root.

* lint

* deadcode remove

* update poetry deps

* unit tests fix

* app_harness fix

* app_harness fix

* pyi file generate

* pyi file generate

* sort pyi order

* fix pyi

* fix docker ci

* rework pyi-generator

* generate pyi for __init__ files

* test pyright

* test pyright ci

* partial pyright fix

* more pyright fix

* pyright fix

* fix pyi_generator

* add rx.serializer and others

* add future annotation import which fixes container CI, then also load recharts lazily

* add new pyi files

* pyright fix

* minor fixes for reflex-web and flexdown

* forward references for py38

* ruff fix

* pyi fix

* unit tests fix

* reduce coverage to 68%

* reduce coverage to 67%

* reduce coverage to 66%as a workaround to coverage's rounding issue

* reduce coverage to 66%as a workaround to coverage's rounding issue

* exclude lazy_loader dependency review checks.

* its lazy-loader

* Add docstrings and regenerate pyi files

* add link

* address Pr comments

* CI fix

* partially address PR comments.

* edit docstrings and fix integration tests

* fix typo in docstring

* pyi fix
2024-05-31 16:43:10 +00:00
Elijah Ahianyo
1a833d6b25
Recommend Running with REFLEX_USE_NPM=1 if npm run fails after installing packages with bun. (#3399) 2024-05-30 15:57:15 -07:00
Thomas Brandého
c7064b9a24
add config knob for react_strict_mode. default to True. also cleanup unused code (#3389) 2024-05-29 11:49:04 -07:00
Angelina Sheyko
0c0dde127f
Added config for number of gunicorn workers (#3351) 2024-05-22 11:31:15 -07:00
Nikhil Rao
ff985aee22
Suppress runtime warnings (#3354) 2024-05-21 12:34:25 -07:00
Nikhil Rao
ec72448b8b
Catch more errors in frontend/backend (#3346) 2024-05-20 16:55:41 -07:00
Santiago Botero
99d59104ad
Add end line in .gitignore (#3309) 2024-05-16 13:22:44 -07:00
benedikt-bartscher
48c504666e
properly replace ComputedVars (#3254)
* properly replace ComputedVars

* provide dummy override decorator for older python versions

* adjust pyi

* fix darglint

* cleanup var_data for computed vars inherited from mixin

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-05-15 15:01:14 -07:00
Masen Furer
76c8b2dfbd
Get action, cancel, on_dismiss and on_auto_close working for rx.toast (#3216)
* Get `action` and `cancel` working for rx.toast

Respect defaults set in ToastProvider toast_options when firing a toast with
it's own ToastProps set.

* Update reflex/components/sonner/toast.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Move queueEvent formatting into rx.utils.format module

Implement on_auto_close and on_dismiss callbacks inside ToastProps

* Update rx.call_script to use new format.format_queue_events

Replace duplicate logic in rx.call_script for handling the callback function.

* Move PropsBase to reflex.components.props

This base class will be exposed via rx._x.PropsBase and can be shared by other
wrapped components that need to pass a JS object full of extra props.

---------

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
2024-05-15 11:54:52 +02:00
Elijah Ahianyo
ea5a3d44e7
[REF-2814]Throw Warning for Projects Created in OneDrive on Windows (#3304)
* Throw Warning for Projects Created in OneDrive on Windows

* precommit

* remove dead code

* REFLEX_USE_NPM escape hatch to opt out of bun

In some unsupported environments, we need to just not use bun. Further
investigation needed.

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-05-14 18:47:08 -07:00
Martin Xu
aa2cf80f70
[REF-2774] Send runtime error in telemetry (#3276) 2024-05-10 18:15:03 -07:00
Martin Xu
2789f32134
[REF-2774] Add ReflexError and subclasses, send in telemetry (#3271) 2024-05-10 12:12:42 -07:00
Martin Xu
4e959694a1
enable telemetry for frontend package download subprocess (#3270) 2024-05-10 10:17:10 -07:00
Elijah Ahianyo
1d093486b9
[REF-2622] Throw warning for incompatible uvicorn version on windows (#3246) 2024-05-08 10:52:37 -07:00
Masen Furer
ea0f490030
[REF-2764] dep update 0.5.0 (#3245)
* upgrade to latest pip for in_docker_test_script.sh

* Bump gunicorn to 22.0.0 (security)

Changelog: https://docs.gunicorn.org/en/stable/news.html#id1

use utime to notify workers liveness
migrate setup to pyproject.toml
fix numerous security vulnerabilities in HTTP parser (closing some request smuggling vectors)
parsing additional requests is no longer attempted past unsupported request framing
on HTTP versions < 1.1 support for chunked transfer is refused (only used in exploits)
requests conflicting configured or passed SCRIPT_NAME now produce a verbose error
Trailer fields are no longer inspected for headers indicating secure scheme
support Python 3.12

** Breaking changes **
minimum version is Python 3.7
the limitations on valid characters in the HTTP method have been bounded to Internet Standards
requests specifying unsupported transfer coding (order) are refused by default (rare)
HTTP methods are no longer casefolded by default (IANA method registry contains none affected)
HTTP methods containing the number sign (#) are no longer accepted by default (rare)
HTTP versions < 1.0 or >= 2.0 are no longer accepted by default (rare, only HTTP/1.1 is supported)
HTTP versions consisting of multiple digits or containing a prefix/suffix are no longer accepted
HTTP header field names Gunicorn cannot safely map to variables are silently dropped, as in other software
HTTP headers with empty field name are refused by default (no legitimate use cases, used in exploits)
requests with both Transfer-Encoding and Content-Length are refused by default (such a message might indicate an attempt to perform request smuggling)
empty transfer codings are no longer permitted (reportedly seen with really old & broken proxies)

** SECURITY **
fix CVE-2024-1135

* Remove TYPE_CHECKING guard for pydantic v1 imports

Retain TYPE_CHECKING guard in v1 fallback to force pyright into pydantic.v1 namespace

* Run unit tests with pydantic v1 now that v2 is installed via poetry
2024-05-07 15:15:52 -07:00
Nikhil Rao
940afb2c92
Remove deprecations for 0.5.0 (#3222) 2024-05-07 08:55:42 -07:00
Elijah Ahianyo
0838e5ac6a
[REF-2676][REF-2751] Windows Skip ARM devices on bun install + Telemetry (#3212) 2024-05-06 09:50:05 -07:00
Elijah Ahianyo
24d15acae6
Windows Pin Version followup (Use Windows Install Link) (#3193) 2024-05-03 12:14:22 -07:00
Thomas Brandého
1817c30e22
add toast component (#3186) 2024-05-03 12:09:11 -07:00
Nikhil Rao
7903a1020d
Clean up config and app API (#3197) 2024-05-02 18:15:28 -07:00
Elijah Ahianyo
db47d39979
Windows --frontend-only fix ctrl + c (#3181) 2024-05-01 17:40:27 -07:00
Elijah Ahianyo
93c4f5024e
Windows Pin Bun version (#3192) 2024-05-01 14:47:03 -07:00
benedikt-bartscher
c2017b295e
Improved get_attribute_access_type (#3156) 2024-04-26 17:28:30 -07:00
Angelina Sheyko
cd1a30d758
Fixed app name validation (#3146) 2024-04-24 13:32:36 -07:00
Martin Xu
a5f9001cf9
send template info in init telemetry event (#3153) 2024-04-24 06:47:33 -07:00
Jirka Borovec
4d567b7ec1
ruff-format: unify Black with Ruff v0.1 (#2837)
* ruff-format: unify Black with Ruff

* ruff lint.

* v0.1.0

* run precommit

* hand fixing

* fix `not isinstance(...)`

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* rev isinstance(...) with noqa

* exclude = ["*.pyi"]

* apply precommit

* apply format

* revert pyi

* fixing

* Fix or

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Update reflex/components/datadisplay/code.pyi

* Apply suggestions from code review

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Update tests/components/core/test_colors.py

* Update reflex/app.py

* Update reflex/app.py

* Update benchmarks/test_benchmark_compile_pages.py

* Update benchmarks/test_benchmark_compile_pages.py

* Update benchmarks/test_benchmark_compile_pages.py

---------

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
2024-04-23 14:40:06 -07:00
Masen Furer
cd4f6bd056
[REF-2620] Fallback to npm (not bun) (#3138)
get_package_manager() will always resolve to npm
2024-04-22 18:17:54 -07:00
Masen Furer
041abb39c8
[REF-2619] Re-init when the template is out of date (#3121) 2024-04-22 11:32:00 -07:00
Masen Furer
6ca5f48ae7
[REF-2587] Ignore top-level theme appearance (#3119)
* pyi_generator: ignore `app.py` and single files

When running pyi_generator in pre-commit, it passes individual changed files on
the command line as targets, and these were not being properly excluded
according to the EXCLUDED_FILES list.

Add app.py to the EXCLUDED_FILES list so it does not get regenerated
automatically.

* [REF-2587] Ignore top-level theme appearance

From the Radix docs, it is not recommended to actually set `appearance`, but
instead use next-themes to set and switch the appearance dynamically.

Because Reflex already compiles the top-level theme into the next-themes
ThemeProvider, we can blank out the appearance prop after compiling contexts.js
to avoid a mismatch between the selected app appearance and the appearance in
the rx.theme when displaying overlay components.

Fix #2992
2024-04-19 14:43:45 -07:00
Elijah Ahianyo
7b61e7e4bc
Use Fallback command on all platforms (#3099)
* Use Fallback command on all platforms

* precommit fix

* obtain the loglevel cmd for fallback as well

* address PR comment
2024-04-18 20:00:41 -07:00
Masen Furer
5466d0d9a6
Use errors='replace' with subprocess (#3096) 2024-04-17 12:59:52 -07:00
Masen Furer
82279b4f1a
Simplify run_process_with_fallback logic (#3089)
* Simplify `run_process_with_fallback` logic

Include log streaming for initial command and fallback command. This is
necessary because if the command produces significant output that is not
consumed, it can fill the OS pipe and block the process from running.

* Avoid overwriting next.config.js when content has not changed

Windows cannot seem to detect when the file changes but the
content is the same and triggers a much longer hot-reload
cycle to deal with the "updated next.config.js"

* Handle case where `next.config.js` doesn't exist yet
2024-04-15 14:49:53 -07:00
Thomas Brandého
b8525261b5
add pathlib.Path serializer (#3082) 2024-04-13 01:27:10 +02:00
Masen Furer
3c8c7c3c46
[REF-1586] Use bun as a package manager on windows (#2359) 2024-04-11 16:43:01 -07:00
wassaf shahzad
4056ad613f
fix: removed .git in template URL (#3049) 2024-04-11 15:35:34 -07:00
Masen Furer
1a11941577
[REF-2392] Expose next.config.js transpilePackages key (#3006) 2024-04-11 13:50:42 -07:00
Masen Furer
d7abcd45de
Force pydantic v1 for sqlmodel compatibility (#3026) 2024-04-11 13:42:30 -07:00
wassaf shahzad
9073a2781b
added serializer for enums (#3058) 2024-04-09 21:13:43 -07:00
Nikhil Rao
dd241a1097
Add frontend flag to _init (#3054) 2024-04-09 13:15:18 -07:00
Elijah Ahianyo
fdc944e002
Literal Error Formatting (#3037) 2024-04-08 11:29:40 -07:00
Thomas Brandého
11a64e04d5
change to a nicer error message when reflex run fail (#3023) 2024-04-05 13:44:03 -07:00
Martin Xu
7d36610cae
Support reflex app creation from templates from github (#2490) 2024-04-04 15:31:34 -07:00
Nikhil Rao
44d6c997dd
Reflex run automatically inits when needed (#3011) 2024-04-04 14:34:12 -07:00
Elijah Ahianyo
619c0b0d06
Exclude .web dir when running uvicorn (#2986) 2024-04-04 09:25:03 -07:00
Thomas Brandého
bf0ebb8d09
Lendemor/improve coverage (#2988)
* add more tests

* add tests to raise coverage

* more tests, bump coverage to 73

* fix up icon_button test

* fix darglint for app.py

* fix utcnow usage warning

* set threshold to 72

* fix timestamp

* fix unit tests for linux-redis

* removed commented code and put a TODO
2024-04-04 14:31:43 +02:00
Sidharth Anil
b2c51b82a5
Windows uvicorn bug fix (#2954) 2024-04-03 14:43:28 -07:00
Thomas Brandého
0af4770180
generate pyi files when building/publishing 3rd party component (#2945)
* build pyi files when building/publishing 3rd party

* fix typo in workflow

* add future annotation

* add tests to pass coverage check

* add more unit tests

* omit pyi_generator from test coverage

* change black from dev deps to direct deps

* remake all pyi

* format pyi if black is present, return as if otherwise

* fix requested changes

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-29 09:54:21 -07:00
Malte Klemm
86526cba51
[REF-2127] Loosen requirements (#2796)
* Remove upper bounds of most dependencies.

Also adds a import try except block for pydantic.v1 and relocks.

Keep black and ruff to not mess to much with current formatting

Make pyright see the right import as long as constraint still lock pydantiv v1

Down pin pytest-asyncio again due to known issue

Fix upload handler with latest versions of fastapi

Change comment

* Add changed lockfile

* Set max versions for deps

* Revert app.pyi

---------

Co-authored-by: Malte Klemm <malte.klemm@blueyonder.com>
Co-authored-by: Nikhil Rao <nikhil@reflex.dev>
2024-03-29 09:26:53 -07:00
Masen Furer
b23859a45d
[REF-2302] When a Var points to a model, prefer access to model fields. (#2893)
* When a Var points to a model, prefer access to model fields.

When a Var points to a model, and fields of the model share the same name as
Var operations, access to the model fields is now preferred to avoid having Var
operation names shadow model fields. Since most Var operations do not actually
work against Models, this does not really block any functionality.

* Special case for ComputedVar needing to internally access fget

Since fget is a "slot" on property, normal __getattribute__ access cannot find it.

* Workaround https://github.com/python/cpython/issues/88459

In python 3.9 and 3.10, the `isinstance(list[...], type)` returns True, but
it's not a valid class for use in issubclass
2024-03-27 16:22:46 -07:00
Elijah Ahianyo
b34c97d725
Default to None if bun/fnm version is Invalid (#2940) 2024-03-27 12:38:56 -07:00
Elijah Ahianyo
61c6728006
[REF-2229]Dedupe deprecation warnings (#2871)
* Dedupe deprecation warnings

* Update reflex/utils/console.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* address PR comments

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-26 16:33:55 +00:00
wassaf shahzad
15dc7f4552
added feature to automatically change port (#2867) 2024-03-25 17:38:28 -07:00
Masen Furer
7debd3dbb9
When __REFLEX_SKIP_COMPILE == "yes" allow telemetry to fail (#2881)
* When __REFLEX_SKIP_COMPILE == "yes" allow telemetry to fail

Allow running `--backend-only` without a .web directory

* When re-initializing a pre-project_hash project, do not blow up on KeyError
2024-03-19 14:30:55 -07:00
Masen Furer
479b5182aa
[REF-2216] Warn if windows is used with py312 (#2856)
Display a warning message, recommending python 3.11 with the current release of
reflex.

We need this until running with a uvicorn version that has better support for
py3.12 on windows.
2024-03-15 11:16:20 -07:00
Emmanuel Onwuegbusi
2a8d9d1ef4
added name of Var to error message (#2827) 2024-03-13 15:39:49 -07:00
Thomas Brandého
92db402539
telemetry refactor + unit tests (#2786) 2024-03-13 12:38:54 -07:00
Masen Furer
f52ff56440
[REF-2086] Avoid "Warning: The path to the Node binary could not be found. (#2803) 2024-03-13 12:35:43 -07:00
Thomas Brandého
e5fc5f9a83
better default title for seo (also remove default description) (#2844)
* better default title for seo (also remove default description)
2024-03-13 11:18:54 -07:00
Masen Furer
eb18ce90d5
[REF-2172] Add DECORATED_PAGES before compiling in thread (#2841) 2024-03-12 10:28:37 -07:00
benedikt-bartscher
8a3c9383fb
improve event handler state references (#2818) 2024-03-11 12:18:18 -07:00
Martin Xu
bf297e2f5b
[REF-2141] Custom component command improvements (#2807)
* add custom component command improvements

* fix test

* fix regex to include both single/double quotes
2024-03-07 20:42:22 -08:00
benedikt-bartscher
f5b7eca9c7
add support for sqlalchemy AssociationProxys (#2809)
* add support for sqlalchemy AssociationProxys

* python 3.8 compatibility
2024-03-07 15:19:35 -08:00
benedikt-bartscher
19a5cdd408
Track state usage (#2441)
* rebase

* pass include_children kwarg in radix FormRoot

* respect include_children

* ruff fixes

* readd statemanager init, run pyi gen

* minor performance imporovements, fix for state changes

* fix pyi and pyright

* pass include_children for chakra

* remove old state detection

* add test for unused states in stateless app

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-03-07 14:25:55 -08:00
Masen Furer
03aa28320a
Perf improvements (part 1) (#2779)
* types: remove runtime imports from `is_generic_alias`

Reduce try/except contexts for better performance.

* _decode_var optimizations:

* compile the regex once at module scope
* fast path string scan for REFLEX_VAR_OPENING_TAG before doing more complex logic

* Avoid repeated `hasattr` check in `is_union`

`is_union` gets called a lot, and the hasattr check can be resolved at import
time for better performance.
2024-03-06 10:42:20 -08:00
Carlos Llatser
2125701c2d
Fix encoding of the .gitignore file on Windows (#2797) 2024-03-06 09:40:55 -08:00
Masen Furer
fc190c8c8f
app_module_for_backend: wait for _compile in prod mode (#2760)
* Expose reflex.utils.exec.is_prod_mode

Formalize runtime checking of the app's `--env` parameter.

* app_module_for_backend: wait for _compile in prod mode

Prod mode uses separate worker processes that fork from the main process.

If the app is not fully compiled when the fork occurs, any further changes to
the app (like mounting the _upload endpoint) will not be reflected in the
workers. This is not a performance hit because compile is skipped anyway
for backend processes and hot reload is not in the picture for prod mode.

* remove _is_dev_mode and replace it with calls to is_prod_mode()

_is_dev_mode was a private function in the compiler, but now that utils.exec
exposes is_prod_mode, we should use that throughout for consistency
2024-03-04 16:50:31 -08:00
Pablo GS
bbb9253985
Solved Nodejs prerequisite check (#2767) 2024-03-03 19:47:05 -08:00
Tom Gotsman
93fc269860
initial attempt at writing test for urls (#2689)
* initial attempt at writing test for urls

* turn it into a pytest test

* fix precommit and add wrong url to make sure test work

* fix darglint error and fix url set error

* black error

* add to test .md files in reflex as well

* update to fix masen comment

* black formatting

* Fix trailing slash in reflex/state.py

---------

Co-authored-by: Tom Gotsman <tomgotsman@Toms-MacBook-Pro.local>
Co-authored-by: Tom Gotsman <tomgotsman@toms-mbp.lan>
Co-authored-by: Masen Furer <m_github@0x26.net>
2024-02-29 13:45:57 -08:00
Elijah Ahianyo
7ec7f031a3
Only alert users of reflex upgrade once per project (#2731) 2024-02-27 17:12:21 -08:00
Masen Furer
deae662e2a
[REF-1988] API to Get instance of Arbitrary State class (#2678)
* WiP get_state

* Refactor get_state fast path

Rudimentary protection for state instance access from a background task
(StateProxy)

* retain dirty substate marking per `_mark_dirty` call to avoid test changes

* Find common ancestor by part instead of by character

Fix StateProxy for substates and parent_state attributes (have to handle in
__getattr__, not property)

Fix type annotation for `get_state`

* test_state: workflow test for `get_state` functionality

* Do not reset _always_dirty_substates when adding vars

Reset the substate tracking only when the class is instantiated.

* test_state_tree: test substate access in a larger state tree

Ensure that `get_state` returns the proper "branch" of the state tree depending
on what substate is requested.

* test_format: fixup broken tests from adding substates of TestState

* Fix flaky integration tests with more polling

* AppHarness: reset _always_dirty_substates on rx.State

* RuntimeError unless State is instantiated with _reflex_internal_init=True

Avoid user errors trying to directly instantiate State classes

* Helper functions for _substate_key and _split_substate_key

Unify the implementation of generating and decoding the token + state name
format used for redis state sharding.

* StateManagerRedis: use create_task in get_state and set_state

read and write substates concurrently (allow redis to shine)

* test_state_inheritance: use polling cuz life too short for flaky tests

kthnxbai ❤️

* Move _is_testing_env to reflex.utils.exec.is_testing_env

Reuse the code in app.py

* Break up `BaseState.get_state` and friends into separate methods

* Add test case for pre-fetching cached var dependency

* Move on_load_internal and update_vars_internal to substates

Avoid loading the entire state tree to process these common internal events. If
the state tree is very large, this allow page navigation to occur more quickly.

Pre-fetch substates that contain cached vars, as they may need to be recomputed
if certain vars change.

* Do not copy ROUTER_DATA into all substates.

This is a waste of time and memory, and can be handled via a special case in
__getattribute__

* Track whether State instance _was_touched

Avoid wasting time serializing states that have no modifications

* Do not persist states in `StateManagerRedis.get_state`

Wait until the state is actually modified, and then persist it as part of `set_state`.

Factor out common logic into helper methods for readability and to reduce
duplication of common logic.

To avoid having to recursively call `get_state`, which would require persisting
the instance and then getting it again, some of the initialization logic
regarding parent_state and substates is duplicated when creating a new
instance. This is for performance reasons.

* Remove stray print()

* context.js.jinja2: fix check for empty local storage / cookie vars

* Add comments for onLoadInternalEvent and initialEvents

* nit: typo

* split _get_was_touched into _update_was_touched

Improve clarity in cases where _get_was_touched was being called for its side
effects only.

* Remove extraneous information from incorrect State instantiation error

* Update missing redis exception message
2024-02-27 13:02:08 -08:00
Thomas Brandého
467fb794da
fix telemetry for init event (#2736) 2024-02-27 18:53:57 +01:00
benedikt-bartscher
93f402c773
Initial values for computed vars (#2670)
* initial values for computed vars draft

* add tests, add computed_var overloads

* fix darglint

* pass initial to substates when calling dict

* add tests for for child states

* format black

* allow None as initial value

* rename runtime_only to raises_at_runtime

* cleanup unused arguments of ComputedVars

* refactor cached_var to be partial of computed_var
2024-02-24 13:45:07 -08:00
Krys
278183b526
fix image serializing - REF-1889 (#2550)
* fix image serializing

* If get_format_mimetype does not work, look up format in Image.MIME

Throw a warning if the image format does not have an associated MIME type and
ultimately fallback to image/png and let the browser figure it out.

* test_media: end to end serialization of PIL images

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-02-22 08:13:19 -08:00
Martin Xu
a3be76fb75
use sync redis client to sanity check (#2679) 2024-02-21 07:01:44 -08:00
benedikt-bartscher
6c49b96d9d
Fix SQLAlchemy list types (#2668)
* fix sqlalchemy relationship list type hints

* py3.8 and py3.9 compatibility

Co-authored-by: Masen Furer <m_github@0x26.net>

* add missing import

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-02-20 15:14:33 -08:00
Nikhil Rao
4ad238c42c
Update deprecation version to 0.5.0 (#2642) 2024-02-16 11:23:15 -08:00
Masen Furer
1698e3e5e3
Fix more information link to v0.4.0 blog post (#2638) 2024-02-15 20:51:06 -08:00
Masen Furer
d979d99338
[REF-1902] [REF-1987] Chakra upgrade message (#2624)
* Show rx.chakra upgrade message _before_ overwriting the version

Ensure that the conditions for showing the rx.chakra upgrade message
are checked before overwriting the version saved in .web/reflex.json.

Check for the absense of a config file to suppress the upgrade message
when init'ing a brand new project.

Check for the existance of `reflex.json` before opening it, since it
might not exist at the point it's checked.

* Update more information link in chakra upgrade message

* Fix long line
2024-02-15 12:49:53 -08:00
invrainbow
e729a315f8
Fix fstrings being escaped improperly (#2571) 2024-02-13 14:32:44 -08:00
invrainbow
61234ae164
Fix operator precedence (#2573) 2024-02-12 19:30:25 -08:00
Masen Furer
eafe53369e
keep-chakra: whitelist is always whitelist (#2585)
Regardless of whether the same name exists in the top level rx.<x> namespace,
always convert whitelisted names to rx.chakra.<x>
2024-02-12 14:55:39 -08:00
Masen Furer
58b5e2f5bd
Merge remote-tracking branch 'origin/main' into reflex-0.4.0 2024-02-09 19:38:35 -08:00
Elijah Ahianyo
ccc9c32c95
Get rx.color working with fstrings (#2562)
* fix for rx.color working with fstrings

* Fix fstrings issues
2024-02-09 17:06:55 -08:00
Masen Furer
3619595bcc
Fixup import of ChakraComponent
It is no longer exposed in rx.components namespace
2024-02-08 12:50:07 -08:00
Elijah Ahianyo
601dd34792
rx.color to work with conditional vars (#2546) 2024-02-08 11:45:15 -08:00
Elijah Ahianyo
64a90fa6eb
Decorator to validate rx.color prop fields (#2553) 2024-02-08 11:21:46 -08:00
jackie-pc
a4ee985509
CLI script to maintain Chakra backed components in rx namespace in older apps (#2322) 2024-02-08 11:12:20 -08:00
Alek Petuskey
5589cbbfc2
Refactor rx.color (#2522)
* Refactor

* Lint

* Change name space to top level

* Update test

* Lint

* Fix pyright

* Update pyi

---------

Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
Co-authored-by: Nikhil Rao <nikhil@reflex.dev>
2024-02-04 15:39:07 -08:00
jackie-pc
80c9eb34e4
Rework telemetry to support installation_id (#2480) 2024-01-31 11:39:48 -08:00
benedikt-bartscher
be7f7969ed
improve sqlalchemy type parsing (#2474)
* improve sqlalchemy type parsing

* add support for propertys and relationships

* cleanup duplicate property check

* avoid confusion, improve readability
2024-01-30 15:57:56 -08:00
Alek Petuskey
670faf291a
[WIP] rx.color (#2443)
* Color module intial commit

* Improvments

* Update reflex/constants/colors.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* Comments+tests

* Fix import

---------

Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MacBook-Pro.local>
2024-01-28 14:06:08 -08:00
benedikt-bartscher
0d8efb9b55
parse return type annotations of sqlalchemy hybrid properties (#2422)
* parse return type annotations of sqlylchemy hybrid properties

* use get_type_hints instead of __annotations__
2024-01-23 14:00:07 -08:00
Masen Furer
9446a1e99f
[REF-1705] Do not overwrite Var attributes during format (#2421) 2024-01-19 15:17:00 -08:00
Masen Furer
6fcc4fd357
Allow app harness tests to import State subclasses (#2408) 2024-01-18 12:54:29 -08:00
jackie-pc
2c270585ab
Skip frontend packages install if previously done (#2400) 2024-01-16 17:52:28 -08:00
benedikt-bartscher
1aca1b677f
fix is_backend_variable for dunder prefixed variables (#2391) 2024-01-16 17:37:05 -08:00
Elijah Ahianyo
26a9e79a5f
Resolve correct python path on windows (#2373) 2024-01-09 09:58:06 -08:00
Masen Furer
87844c3f7d
Enable real app AppHarness tests to not specify state= (#2358) 2024-01-05 17:47:31 -08:00
Elijah Ahianyo
abfc099779
rx.match component (#2318)
* initial commit

* add more tests

* refactor match jinja template

* add docstrings

* cleanup

* possible fix for pyright

* fix conflicts

* fix conflicts again

* comments

* fixed bug from review

* fix tests

* address PR comment

* fix tests

* type error improvement

* formatting

* darglint fix

* more tests

* stringify switch condition and cases as js doesnt support complex types(lists and dicts) in switch cases.

* Update reflex/vars.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* change usages

* Precommit fix

---------

Co-authored-by: Alek Petuskey <alek@pynecone.io>
Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
2024-01-04 09:48:18 -08:00
benedikt-bartscher
58a7e5e460
support parsing type args of DeclarativeBase subclasses (#2348) 2024-01-03 11:55:07 -08:00
Jishnu N
c5c42665eb
add: reflex init app name validator (#2336) 2023-12-28 00:07:55 -08:00
Nikhil Rao
5d21f0ca60
Add high-level API for accordion (#2285) 2023-12-18 17:21:49 -08:00
jackie-pc
7388617b72
apps should no longer call "app.compile()" (#2291) 2023-12-18 16:06:21 -08:00
Martin Xu
3c07537c11
only exclude assets folder if it's in the root_dir (#2308) 2023-12-18 15:51:13 -08:00
jackie-pc
92bd3da676
capture exceptions thrown by any process in run_concurrently_context (#2296) 2023-12-14 14:41:45 -08:00
Martin Xu
9da65b9a9a
[REF-1464] Handle requirements.txt encoding (#2284) 2023-12-14 14:25:40 -08:00
Masen Furer
e245b6b6a0
support SQLModel 0.0.14 + SQLAlchemy 2 (#2283) 2023-12-12 17:52:11 -08:00
Elijah Ahianyo
9629b59617
DataFrame Serializer fix (#2281) 2023-12-12 14:03:40 -08:00
benedikt-bartscher
f90982ea06
use redis-py url syntax for redis_url (#2267)
* use redis-py url syntax for redis_url

* port is optional

* Add StateManagerRedis.close method

The close helper method always calls `close_connection_pool=True` so that all
outstanding redis operations can be stopped before changing event loops.

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2023-12-12 10:54:10 -08:00
Masen Furer
e52267477c
[REF-1417] Convert underscore-prefixed style props to pseudo selector (#2266) 2023-12-11 13:37:57 -08:00
Alek Petuskey
421be5748b
Warning if newer reflex/reflex-hosting-cli available (#2271)
* Check to see if there are new reflex version avaliable if so throw a warning

* precommit

* request -> httpx

* Fix pr comments

* Forgot import

* Generalize check_latest_package_version

---------

Co-authored-by: Alek Petuskey <alekpetuskey@aleks-mbp.lan>
Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MBP.attlocal.net>
2023-12-08 21:21:12 -08:00
Thomas Brandého
caf32605ca
add next/image and next-video in next namespace (#2223) 2023-12-07 10:38:47 -08:00
Masen Furer
60147dec65
[REF-201] Separate on_load handler from initial hydration (#1847) 2023-11-30 12:21:15 -08:00
Elijah Ahianyo
e3ee98098a
RED-1052/rx.State as Base State (#2146) 2023-11-29 09:43:33 -08:00
Martin Xu
f8395b1fd6
Separate out the hosting CLI from main repo (#2165) 2023-11-28 15:20:06 -08:00
Masen Furer
527437cf23
[REF-144] Add context in each component to prevent rerenders (#2198) 2023-11-27 16:05:59 -08:00
Thomas Brandého
8fc254041b
fix name for import var when is default and add tests (#2214) 2023-11-26 12:46:43 -08:00
Masen Furer
1603144c7d
[REF-889] useContext per substate (#2149) 2023-11-21 11:52:06 -08:00
Nikhil Rao
e9437ad941
Use singleton app provider to speed up compiles (#2172) 2023-11-20 18:11:24 -08:00
Tom Gotsman
5198daebae
keep app id (project hash) the same even after re-init (#2195) 2023-11-20 15:30:14 -08:00
Elijah Ahianyo
714edb3cde
REF-1202: Upgrade bun version if it differs from reflex set version (#2206) 2023-11-20 15:21:17 -08:00
Elijah Ahianyo
7f810ece21
To camel case fix (#2205) 2023-11-20 11:33:48 -08:00
Nikhil Rao
c3e652b8c1
Speed up reflex CLI imports (#2185) 2023-11-17 12:31:07 -08:00
Nikhil Rao
f1005e774e
Fix missing lazy imports (#2187) 2023-11-16 13:20:48 -08:00
Martin Xu
adb26787c8
Hosting CLI: remove requirements generation when init, add back timeout for deploy command, remove deploy legacy command (#2179) 2023-11-15 16:23:34 -08:00
Elijah Ahianyo
ea22452b27
Reduce Syntax highlighter footprint (#2037) 2023-11-13 12:47:55 -08:00
Thomas Brandého
39cc1b2f12
Upgrade to NextJS 14 (#2142) 2023-11-13 09:52:51 -08:00
Masen Furer
5e6520cb5d
Support Form controls via name attribute (no ID or ref) (#2012) 2023-11-10 12:58:59 -08:00
Elijah Ahianyo
7a04652a6a
Revert "Bun as runtime on Mac and Linux (#2138)" (#2153) 2023-11-09 13:01:48 -08:00
Elijah Ahianyo
4d6fa9b823
Bun as runtime on Mac and Linux (#2138) 2023-11-08 16:22:02 -08:00
Thomas Brandého
c835ad0737
fix to_snake_case and add tests (#2133) 2023-11-06 12:13:28 -08:00
Nikhil Rao
6e1bce3412
Prompt for template on reflex init (#2122) 2023-11-03 13:37:01 -07:00
Martin Xu
4c97b4c4c0
Hosting CLI: use http endpoint to return deploy milestones (#2085) 2023-11-03 12:13:46 -07:00
Martin Xu
4a526620ac
[REF-1042] Hosting CLI: check the user selected app name (#2102) 2023-11-02 14:34:10 -07:00
Nikhil Rao
6e71393ed5
Use blank template as default (#2109) 2023-11-01 15:59:34 -07:00
Masen Furer
8eb68a006e
Expose gunicorn_worker_class via Config (#2084) 2023-10-31 13:45:29 -07:00
Masen Furer
56476d0a86
Expose DOM event actions on EventHandler, EventSpec, and EventChain (stopPropagation) (#1891)
* Expose preventDefault and stopPropagation for DOM events

All EventHandler, EventSpec, and EventChain can now carry these extra
"event_actions" that will be applied inside the frontend code when an event is
triggered from the DOM.

Fix #1621
Fix REF-675

* Test cases (and fixes) for "event_actions"

* form: from __future__ import annotations

for py38, py39 compat

* Revert overzealous merge conflict resolution
2023-10-31 11:42:42 -07:00
Martin Xu
8ad9f3a96e
show all columns in list deployments, let CP control what columns user see (#2061) 2023-10-27 13:56:30 -07:00
Nikhil Rao
bb77d14fbc
Update demo command to open demo.reflex.run (#2059) 2023-10-27 13:16:02 -07:00
Martin Xu
23255d49d4
Add back build log command to CLI (#2053) 2023-10-27 11:30:04 -07:00
Masen Furer
ff4c5a5cf8
Remove .pyc and __pycache__ from template dir (#2056) 2023-10-27 11:20:46 -07:00
Nikhil Rao
8133aa10c9
Update base template (#2027) 2023-10-26 17:59:14 -07:00
Masen Furer
f66c6c3361
Support callback for rx.call_script (#2045) 2023-10-26 17:54:48 -07:00
Martin Xu
e9cf822460
CLI will not set auto/stop setting for deployment (#2040)
* do not set autostart/autostop as default on CLI

* cli feedback

* fix test

* clean up last few messages

* catch general exception for export and exit
2023-10-26 17:47:22 -07:00
Alek Petuskey
70a6b5f2d3
Autogenerating Dependencies During Deployment (#2033) 2023-10-26 17:32:58 -07:00
Thomas Brandého
9a5579e1ef
Add datagrid editor (#1941) 2023-10-26 16:17:34 -07:00
Martin Xu
fe01f0cf11
add region check upfront when user deploys interactively (#2030) 2023-10-26 10:07:49 -07:00
Masen Furer
92dd68c51f
Improve Var type handling for better rx.Model attribute access (#2010) 2023-10-25 11:55:50 -07:00
Martin Xu
f404205c3f
CLI improvements (#2026) 2023-10-24 15:35:51 -07:00
Martin Xu
81053618c9
CLI switch to prod server (#2016) 2023-10-24 09:43:20 -07:00
jackie-pc
b3499e6b7a
[reflex export] backend.zip excludes dirs that look like venv dirs (#2009) 2023-10-23 09:01:42 -07:00
Masen Furer
91bbf91c52
Resolve npm path and fnm path on Windows (#2015) 2023-10-23 08:59:48 -07:00
Thomas Brandého
d00425276d
fix fnm version check (#2014) 2023-10-23 08:45:55 -07:00
Martin Xu
07ca8fcb3b
[REF-99] Add first version of CLI for hosting service (#1810) 2023-10-21 13:09:56 -07:00
jackie-pc
c653f95435
support exporting to zip archives to a dir that is not cwd (to be used by hosting cli) (#2005) 2023-10-20 09:40:30 -07:00
Nikhil Rao
e7f0cd8e4c
Stop double compiles in dev mode (#1990) 2023-10-19 15:26:14 -07:00
Elijah Ahianyo
06bdf9ed8a
Remove 0.3.0 deprecated features (#1947) 2023-10-19 09:44:32 -07:00
Nikhil Rao
b4bb849388
Fix posthog (#1992) 2023-10-18 12:30:09 +02:00
Thomas Brandého
df09c716c6
fix serialization as a whole for list/dict/Base containing custom items to serialize (#1984) 2023-10-17 10:44:54 -07:00
Masen Furer
d1d5812602
format: event arg values use backticks (#1926) 2023-10-17 10:42:35 -07:00
Elijah Ahianyo
c6abeb31a5
Props as Literals (#1921) 2023-10-15 20:16:39 -07:00
Alek Petuskey
7d4194be34
Added base template + improve templating code (#1937) 2023-10-15 20:02:41 -07:00
Masen Furer
024cb5fa9b
Var field cleanup (#1943) 2023-10-13 14:53:55 -07:00
Nikhil Rao
85937c2369
Pin frontend package versions (#1920) 2023-10-05 12:45:21 -07:00
Elijah Ahianyo
513835cf74
Update Deprecations (#1927) 2023-10-05 12:12:42 -07:00
Elijah Ahianyo
68664a5094
Deprecate set_cookie and set_local_storage (#1917) 2023-10-04 14:15:37 -07:00
Masen Furer
0a196693a3
Add Editor component (#1851) 2023-10-02 09:41:58 -07:00
Thomas Brandého
dcb17103bb
code cleanup (split constants into a folder) (#1866) 2023-09-28 17:27:20 -07:00
Elijah Ahianyo
26885d98cf
rx.table __bool__ regression fix (#1828) 2023-09-28 09:31:01 -07:00
Nikhil Rao
41872dfdc9
Format event handlers not in importable modules (#1875) 2023-09-27 11:30:15 -07:00
Nikhil Rao
8231993e5a
Improvements to custom styles in rx.markdown (#1852) 2023-09-25 15:59:48 -07:00
Masen Furer
351611ca25
rx.background and StateManager.modify_state provides safe exclusive access to state (#1676) 2023-09-21 11:42:11 -07:00
Thomas Brandého
211dc15995
New API to define triggers (#1820) 2023-09-21 09:47:22 -07:00
Thomas Brandého
84bae0dc7d
use jinja2 to render package.json (#1849) 2023-09-21 09:46:11 -07:00
Masen Furer
0cd7242bb2
exec: print the URL, not the address the server binds to (#1846) 2023-09-20 19:31:06 -07:00
Elijah Ahianyo
d81d544b97
add option to disable Tailwind (#1842) 2023-09-20 16:47:58 -07:00
Nikhil Rao
3113aecb30
Support custom styling for code in markdown (#1844) 2023-09-20 11:40:25 -07:00
Nikhil Rao
264c44e630
Disable metrics in CI (#1822) 2023-09-15 18:15:25 -07:00
Nikhil Rao
1938a6cc58
Add serializers for different var types (#1816) 2023-09-15 17:19:26 -07:00
Elijah Ahianyo
06a110a07d
Style props with Callable Values (#1751) 2023-09-12 11:26:53 -07:00
Elijah Ahianyo
891e6a4736
Allow underscores in routes (#1713) 2023-09-08 12:18:33 -07:00
Nikhil Rao
47d789e9a6
Don't show error logs on sigint (#1781) 2023-09-07 15:54:52 -07:00
Masen Furer
43ac87f5ca
exec: don't debug print the line, processes.stream_logs already does (#1780) 2023-09-07 15:31:08 -07:00
Nikhil Rao
abc09f9074
Don't show app running message twice (#1770) 2023-09-07 01:41:26 -07:00
Elijah Ahianyo
141d1c3aab
Deprecation warning enhancement (#1738) 2023-09-06 10:46:44 -07:00
Masen Furer
38c5503f94
Client-side Routing (404 redirect) (#1695) 2023-09-05 16:22:00 -07:00
Thomas Brandého
03a92bc60e
remove frontend_package option (#1700) 2023-09-05 13:45:18 -07:00
Masen Furer
71811a600c
Var: __bool__ and __iter__ always raise a TypeError (#1750) 2023-09-05 13:44:22 -07:00
wassaf shahzad
e99d6723bc
added changes for datetime (#1745)
* added changes for datetime

* fixed formatting

* fixed darglint issue

* test_state: check for other datetime module classes

* utils/types.py: use issubclass check

fix docstring copy/paste issue

* utils/format.py: reuse types.is_datetime check

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2023-09-04 22:29:02 -07:00
Nev Delap
41e97bbc46
Issues 1633 Add frontend_path to config to support running multiple reflex apps off the same domain, and 1583 Show the correct info on where the site is being served. (#1724)
* Support setting Next.js basePath in Reflex config. (#1633)

- Tests.
- And sorted config in next.config.js template.

* Display the correct running at url with basePath if it is set. (#1583)

* Formatting, fixed by black.

* Fix indenting in test data.

* Fixed that conflict resolution shouldnt have included console.debug line.

* Rmove use of :=. Add http:// to url. Use urljoin to build url.
2023-09-02 06:38:22 -07:00
Elijah Ahianyo
829a7751b5
Refactor: Move format_prop Static Method for Improved Reusability (#1714) 2023-09-01 13:01:11 -07:00
Nikhil Rao
1d9f25be6d
Fix project hash and modernize type annotations (#1704) 2023-08-31 17:04:39 -07:00
Alek Petuskey
fed75ea7f8
Incrementally Add New Packages (#1607) 2023-08-31 14:20:44 -07:00
Masen Furer
2392c52928
Implement on_mount and on_unmount for all components. (#1636) 2023-08-30 09:50:39 -07:00
Elijah Ahianyo
689f078aa3
Fix Node Installation on ARM-based Macs with FNM (#1701) 2023-08-29 14:59:56 -07:00
Nikhil Rao
6bfce48b0c
Use stream_logs for frontend process (#1682) 2023-08-25 16:16:51 -07:00
Masen Furer
3916668461
Avoid compile step when running production backend (#1665) 2023-08-25 14:50:03 -07:00
Elijah Ahianyo
dbaa6a1e56
Fnm and node for POSIX (#1606) 2023-08-25 13:04:10 -07:00
Martin Xu
76b8af3b42
Refactor zipping in reflex export (#1668) 2023-08-23 17:18:16 -07:00
Masen Furer
81fd9d1e9c
Run backend from the main thread in dev mode (#1653) 2023-08-23 16:52:54 -07:00