* components deserve to be first class props
* default back to {}
* smarter yield
* how much does caching help?
* only hit the slower path on _are_fields_known
* remove the cache thingy
* cache the inner _get_component_prop_names
* oops
* dang it darglint
* refactor things a bit
* fix events
* raise error when passing a str(var)
* make it faster
* fix typo
* fix tests
* mocker consistency
Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
* ditto
Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
---------
Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
* move overlays to _app.js
* fix unit tests
* fix dynamic imports app
* fix unit cases once again
* clear custom compoent cache between app harness tests
* fix bun path handling and add a test
* fix flags
* fix tests
* fix unit tests and mock object
* fix units test again
* revert some changes for now
* remove unused test
* remove base_state from event types
* pyi that guy
* unpack is new
* woops
* use type alias type to remove ambiguity of where types go
* use same thing with LAMBDA_OR_STATE
* do it for event type
* improve rx.Field ObjectVar typing for sqlalchemy and dataclasses
* enable parametrized objectvar tests for sqlamodel and dataclass
* improve typing for ObjectVars in ArrayVars
* ruffing
* drop duplicate objectvar import
* remove redundant overload
* allow optional hints in rx.Field annotations to resolve to the correct var type
* disable react strict mode for event loop
* oops
* pyi oui
* separate socket connection from event loop
* prettier state.js
* disable react strict mode
* didn't work sadge
* socket connect/disconnect depends on new isBackendDisabled state
* only start the event loop when the socket is set or we're not stateful
* Always drain the queue unless backend is disabled
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
* WiP
* Save the var from get_var_name
* flatten StateManagerRedis.get_state algorithm
simplify fetching of states and avoid repeatedly fetching the same state
* Get all the states in a single redis round-trip
* update docstrings in StateManagerRedis
* Move computed var dep tracking to separate module
* Fix pre-commit issues
* ComputedVar.add_dependency: explicitly dependency declaration
Allow var dependencies to be added at runtime, for example, when defining a
ComponentState that depends on vars that cannot be known statically.
Fix more pyright issues.
* Fix/ignore more pyright issues from recent merge
* handle cleaning out _potentially_dirty_states on reload
* ignore accessed attributes missing on state class
these might be added dynamically later in which case we recompute the
dependency tracking dicts... if not, they'll blow up anyway at runtime.
* fix playwright tests, which insist on running an asyncio loop
---------
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
* Handle python `range` passed to rx.Var.create
Fix the range function to use Math.ceil to handle jagged steps.
Update test cases.
* Set ToVarOperation.__qualname__ for better repr
* 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>
* 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
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