Explicit state and event id minification#6100
Explicit state and event id minification#6100benedikt-bartscher wants to merge 77 commits intoreflex-dev:mainfrom
Conversation
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
| has_substates = len(substates) > 0 | ||
|
|
||
| if handlers: | ||
| console.log(f"{child_prefix}|-- Event Handlers:") |
There was a problem hiding this comment.
Very tiny optical nit, cause sometimes EventHandlers is the last sub item.
It might work like this, didn't test it.
| console.log(f"{child_prefix}|-- Event Handlers:") | |
| console.log(f"{child_prefix}{'|' if has_substates else '`'}-- Event Handlers:") |
|
TODO: best-effort-mode
a similar thing can be implemented for event handler id's edit: not that easy, as state names are baked into to many things (events, vars etc). we would need to defer init_subclass and possibly parts of @rx.var and @rx.event edit2: i have found a better approach with a minify.json which makes this obsolete |
|
Open for discussion: Should reflex reserve the first 5/10 state id's for internal states? Current reflex uses 0-3, but that might change in the future. edit: with sibling uniqueness we would just need to reserve the state id's on the first rx.State subclass level. edit2: i have found a better approach with a minify.json which makes this obsolete |
|
TODO: think about sibling uniqueness for states. currently using global uniqueness edit: adjusted in 6b4c5fa |
35ad1c6 to
1647c1e
Compare
|
Idea: store ids in a minify.json file
|
When a parent and child state have the same minified name, substate resolution can fail because the leading segment is stripped incorrectly. This change adds a flag to skip stripping only on the initial recursive call, ensuring correct resolution even in name collision scenarios.
* 0828dev * does 15 fix this * ok it seems there are css issues * is it autoprefixer?? * idk * wtf is wrong with this * idk even * is it granian? * ok * vite * fix types * bump granian
Certain build environments, such as docker bind mounts, can create symlinks that exist, but cannot be overwritten for whatever reason. So we unlink those for Simon 🎁
…x-dev#6147) * feat: add vite_allowed_hosts config option for Vite dev server Add a configurable `vite_allowed_hosts` field to `rx.Config` that controls whether `allowedHosts: true` is set in the Vite dev server configuration. This allows users running Reflex in Docker, Codespaces, or behind a reverse proxy to opt-in to allowing all hosts, preventing 403 Forbidden errors from Vite's host header validation. Default is `False` (original behavior, Vite only allows localhost). Users can enable it in rxconfig.py: config = rx.Config(app_name="myapp", vite_allowed_hosts=True) Or via environment variable: REFLEX_VITE_ALLOWED_HOSTS=true reflex run * refactor: support bool | list[str] for vite_allowed_hosts * feat: support union types in interpret_env_var_value Instead of raising an error for union types, try each type in the union in order and return the first successful interpretation. Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Masen Furer <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
…fallback (reflex-dev#6154) * fix: include frontend_path in sirv prod command for correct 404.html fallback When frontend_path is set, the build moves all static files (including 404.html) into a subdirectory, but the sirv --single flag was hardcoded to look for 404.html at the root. This broke dynamic routes in prod. Closes reflex-dev#5812 Co-Authored-By: Claude Opus 4.6 <[email protected]> * Update reflex/constants/installer.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…lex-dev#6155) * fix: make disable_plugins accept Plugin types instead of strings Change `disable_plugins` from `list[str]` to `list[type[Plugin]]` so both `plugins` and `disable_plugins` use consistent Plugin-based types (reflex-dev#6150). Strings and instances are still accepted at runtime with a deprecation warning, and normalized to the Plugin class. Environment variable support via REFLEX_DISABLE_PLUGINS continues to work through a new `interpret_plugin_class_env` interpreter, which `interpret_plugin_env` now reuses for class resolution. Co-Authored-By: Claude Opus 4.6 <[email protected]> * Update reflex/config.py --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
…event-id-minification
…date sync_minify_config and validate_minify_config grouped siblings by string-splitting state paths, which fails when children of the same parent class are defined in different Python modules. This caused colliding minified IDs (e.g. both getting 'a'). Now uses get_parent_state() class objects for grouping, consistent with generate_minify_config which was already correct. Also resolves merge conflicts in _get_event_handler to keep the minified event name reverse lookup.
Summary
Add state and event name minification with CLI management tools.
minify.jsonconfig file to map state/event names to short IDs (e.g.,myapp.state.AppState→"a")reflex minifyCLI command group for managing minificationCLI Commands
based on #6098