* rename private fields with leading underscore in App
* fix constants API
* fix public API for some attributes of App()
* fix conflicts properly 🙈
* remove extra private
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
* Fix setting default color mode in dev mode
Without this, the last_compiled_timestamp local storage never gets set because
it's always `null` until it gets set.
* test_client_storage: also pop `theme` key from next-themes
* remove deprecated features and support for py3.9
* remove other deprecated stuff
* update lock file
* fix units tests
* relock poetry
* fix _replace for computed_var
* fix some merge typo
* fix typing of deploy args
* fix benchmarks.yml versions
* console.error instead of raising Exception
* fix tests
* ignore lambdas when resolving annotations
* simplify redirect logic in event.py
* more fixes
* fix unit tests again
* give back default annotations for lambdas
* fix signature check for on_submit
* remove useless stuff
* update pyi
* readd the getattr
* raise if log_level is wrong type
* silly goose, loglevel is a subclass of str
* i don't believe this code
* add guard
---------
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
* make object var handle all mapping instead of just dict
* unbreak ci
* get it right pyright
* create generic variable for field
* add support for typeddict (to some degree)
* import from extensions
* [ENG-4351] Add mapping for lucide icons
For icon names that don't auto-translate to the correct lucide tag name,
provide manual override.
Fix#4621
* account for new mapping in unit tests
* unbreak link _hover
* add a test to catch the error
* change tmp path for harness
* add () to fixture
* add spacer to avoid initial hover
* only install chromium browser for faster ci
---------
Co-authored-by: Lendemor <thomas.brandeho@gmail.com>
* [ENG-2157] [Refix] Allow `rx.download` to resolve `rx.get_upload_url`
Update the special case in a way that works with the new Var system and its
unstoppable determination to concatenate strings instead of using template
string
This has been broken since 0.6.0, so a regression test was added to avoid
future inadvertant breakage.
Fix#2812 (again)
* use safer indirect eval
* Proxy backend requests on '/' to the frontend
If the optional extra `proxy` is installed, then the backend can handle all
requests by proxy unrecognized routes to the frontend nextjs server.
* Update lock file
* pre-commit fu
* AppHarness: set config frontend_port and backend_port
* integration: frontend port and backend port should return the same content
with proxying enabled by default in dev mode, both frontend and backend ports
on / should return the same content.
* Retry up to 100 times when proxying to frontend
* Reduce retry attempts to 25
Fix log level passing to subprocess
* scripts/wait_for_listening_port: primarily check HTTP responses
if the port is up or not, we don't really care... the HTTP request needs to
work and not return errors
* aiohttp is an optional dep
* adapt integration.sh for --backend-only (counter integration test)
* woops
* windows WTF?
* scratching my head 🎄
* double WTF windows
* Fix remaining integration tests
The default behavior for EventSpec is to treat the spec as a partial, wherein
if additional unfilled arguments are available, and the event trigger wants to
pass additional arguments, they will be applied positionally.
However, it never makes sense to fill in `callback` with an event trigger arg.
Therefore, if the callback is not provided initially, set it to None explicitly
so that some invalid value cannot be added later.
* BaseState.get_var_value helper to get a value from a Var
When given a state Var or a LiteralVar, retrieve the actual value associated
with the Var.
For state Vars, the returned value is directly tied to the associated state and
can be modified.
Modifying LiteralVar values or ComputedVar values will have no useful effect.
* Use Var[VAR_TYPE] annotation to take advantage of generics
This requires rx.Field to pass typing where used.
* Add case where get_var_value gets something that's not a var
* [ENG-4083] Track internal changes in dataclass instances
Create a dynamic subclass of MutableProxy with `__dataclass_fields__` set
according to the dataclass being wrapped.
* support dataclasses.asdict on MutableProxy instances
* add datetime var operations
* add future annotations
* add LiteralDatetimeVar
* remove methods that don't apply
* fix serialization
* add unit and integrations test
* oops, forgot to commit that important change
* Throw warnings when Redis lock is held for more than the allowed threshold
* initial tests
* fix tests and address comments
* fix tests fr, and use pydantic validators
* darglint fix
* increase lock expiration in tests to 2500
* remove print statement
---------
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
* [ENG-4165] Consider default and default_factory for state vars
When determining whether a state var should be marked as optional, check that
it is missing both default and default_factory and is not required.
Fix#4471
* add test for default factory with rx.foreach (#4515)
---------
Co-authored-by: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com>
* Avoid double JSON encode/decode for socket.io
socket.io (python and js) already has a built in mechanism for JSON encoding
and decoding messages over the websocket. To use it, we pass a custom `json`
namespace which uses `format.json_dumps` (leveraging reflex serializers) to encode the
messages. This avoids sending a JSON-encoded string of JSON over the wire, and
reduces the number of serialization/deserialization passes over the message
data.
The side benefit is that debugging websocket messages in browser tools displays
the parsed JSON hierarchy and is much easier to work with.
* JSON5.parse in on_upload_progress handler responses
* add eradicate rules for commented out code
* remove output change
* fix pyi messed up indent
* fix pyi again
* fix layout docstring
* fix pyi_generator to remove commented out props from docs
* fix pyi_generator and regenerate some pyi
* fix double strip
* update all pyi
* try to fix stuff in pyi_gen
* whatever
* remove that maybe? i don't know
* fix that shit?
* fix more shit, idk
* better not see you ever again, extra line
* fix: handle default_factory in get_attribute_access_type, add tests for sqla dataclasses
* only test classes which have default_factory + add test for no default
* add test for color mode (initial and toggle)
* add css check
* add page reload in the tests
* update test to catch the appearance regression
* don't render the appearance prop of rx.theme
* rx.upload must include _var_data from props
str-casting the dropzone arguments removed any VarData they depended on, like
the state context.
update test_upload to include passing a prop from a state var
* Handle large payload delta from upload event handler
Fix update chunk chaining logic; try/catch wasn't catching errors from the
async inner function.
* Unit test updates
* test_client_storage: simulate backend state expiry
* [HOS-333] Send a "reload" message to the frontend after state expiry
1. a state instance expires on the backing store
2. frontend attempts to process an event against the expired token and gets a
fresh instance of the state without router_data set
3. backend sends a "reload" message on the websocket containing the event and
immediately stops processing
4. in response to the "reload" message, frontend sends
[hydrate, update client storage, on_load, <previous_event>]
This allows the frontend and backend to re-syncronize on the state of the app
before continuing to process regular events.
If the event in (2) is a special hydrate event, then it is processed normally
by the middleware and the "reload" logic is skipped since this indicates an
initial load or a browser refresh.
* unit tests working with redis
On py3.9 and py3.10, `dict[str, str]` and other typing forms are kinda
considered classes, but they still fail when doing `issubclass`, so
specifically exclude generic aliases before calling issubclass.
Fix#4424
Bonus fix: support upcasting of pydantic v1 and v2 models
* wip rx._x.asset improvements
* only add symlink if it doesn't already exist
* minor improvements, add more tests
* use deprecated Generator for python3.8 support
* improve docstring
* only allow explicit shared, only validate local assets if not backend_only
* fix darglint
* allow setting backend only env to false.
* use new is_backend_only in assets
* ruffing
* Move to `rx.asset`, retain old API in `rx._x.asset`
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
* [ENG-3953] Support pydantic BaseModel (v1 and v2) as state var
Provide serializers and mutable proxy tracking for pydantic models directly.
* conditionally define v2 serializer
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
* Add `MutableProxy._is_mutable_value` to avoid duplicate logic
* Conditionally import BaseModel to handle older pydantic v1 versions
* pre-commit fu
---------
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>