Repository: actuate-rs/actuate Branch: main Commit: 3375218576da Files: 38 Total size: 177.4 KB Directory structure: gitextract_uddujspb/ ├── .gitattributes ├── .github/ │ ├── FUNDING.yml │ └── workflows/ │ └── ci.yml ├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── examples/ │ ├── README.md │ ├── counter.rs │ ├── http.rs │ ├── radio_button.rs │ └── timer.rs ├── macros/ │ ├── CHANGELOG.md │ ├── Cargo.toml │ └── src/ │ └── lib.rs ├── src/ │ ├── animation.rs │ ├── compose/ │ │ ├── catch.rs │ │ ├── dyn_compose.rs │ │ ├── from_fn.rs │ │ ├── from_iter.rs │ │ ├── memo.rs │ │ └── mod.rs │ ├── composer.rs │ ├── data.rs │ ├── ecs/ │ │ ├── mod.rs │ │ └── spawn.rs │ ├── executor.rs │ ├── lib.rs │ └── ui/ │ ├── material/ │ │ ├── button.rs │ │ ├── container.rs │ │ ├── mod.rs │ │ ├── radio.rs │ │ ├── text.rs │ │ └── ui.rs │ └── mod.rs └── tests/ └── composer.rs ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ * text=auto *.rs text eol=lf *.toml text eol=lf *.wgsl text eol=lf *.txt text eol=lf *.png binary *.ttf binary ================================================ FILE: .github/FUNDING.yml ================================================ github: actuate-rs open_collective: actuateui ================================================ FILE: .github/workflows/ci.yml ================================================ name: CI on: push: branches: ["main"] pull_request: branches: ["main"] env: CARGO_TERM_COLOR: always jobs: # Build core features core: name: Build core runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout sources uses: actions/checkout@v4 - name: Cache uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable - name: Run cargo build run: cargo build --verbose # Run cargo fmt --all -- --check format: name: Format runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout sources uses: actions/checkout@v4 - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable with: components: rustfmt - name: Run cargo fmt run: cargo fmt --all -- --check # Run cargo clippy clippy: name: Clippy runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout sources uses: actions/checkout@v4 - name: Cache uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }} - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable with: components: clippy - name: Install Dependencies run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - name: Run clippy run: cargo clippy -- -D warnings # Run cargo test test: name: Tests runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout sources uses: actions/checkout@v4 - name: Cache uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable - name: Install Dependencies run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - name: Run cargo test run: cargo test --features full --verbose # Run cargo test miri: name: Miri runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout sources uses: actions/checkout@v4 - name: Cache uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} - name: Install stable toolchain uses: dtolnay/rust-toolchain@stable - name: Install Dependencies run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - name: Install Miri run: | rustup toolchain install nightly --component miri rustup override set nightly cargo miri setup - name: Test with Miri run: cargo miri test --workspace --features full --verbose ================================================ FILE: .gitignore ================================================ /target dist/ ================================================ FILE: CHANGELOG.md ================================================ # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.21.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.20.1...actuate-v0.21.0) - 2025-12-18 ## Breaking changes - Update to Bevy v0.17.3 ## [0.20.1](https://github.com/actuate-rs/actuate/compare/actuate-v0.20.0...actuate-v0.20.1) - 2024-12-13 ## Documentation - Fix formatting in crate example ## [0.20.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.19.1...actuate-v0.20.0) - 2024-12-13 ## Breaking changes - Fix `Data` impl for `&T` (63d89ed) - Remove Data from root exports (677b160) - Replace `Memoize` trait with more specific `Generational` trait (febe238) ## Features - Impl `Data` for Rc and derive `Clone` for `Catch` composable (e038307) - Impl `Clone` for `from_fn`, `from_iter`, and `memo` composables (21c016f) - Add `material_ui` composable (5dad9a3) ## Fixes - Replace `std` deps with `core` (68d44a2) - Simplify styling in `scroll_view` composable and update `http` example (f90e4c4) - Check for removed entities in Spawn composable (c23e158) ## Documentation - Add docs to `use_local_task` (63d89ed) - Add docs to `use_task` (7ddbe84) - Update counter example (3b79bb1) - Update borrowing docs (efcdfe3) ## [0.19.1](https://github.com/actuate-rs/actuate/compare/actuate-v0.19.0...actuate-v0.19.1) - 2024-12-09 ## Features - Add `use_effect` hook (5ae0a51) - `fn use_effect(cx: ScopeState<'_>, dependency: D, effect: impl FnOnce(&D))` ## Fixes - Remove `AnyItemState` in `from_iter` composable to pass stacked borrows check in miri (2360814) ## Documentation - Add docs for `from_fn` and `from_iter` composables (5c379e1) ## [0.19.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.18.1...actuate-v0.19.0) - 2024-12-08 ## Breaking changes - Require `'static` items in `from_iter` composable - This prevents edge cases where an item may have been removed from a collection, but references still exist down the tree. ## Documentation - Add logo to rustdocs (702b1e0) - Update material docs (3084286) - Update link to `core::error::Error` in `Catch` composable (b664206) ## [0.18.1](https://github.com/actuate-rs/actuate/compare/actuate-v0.18.0...actuate-v0.18.1) - 2024-12-07 ## Fixes - Specify `winit` backend for `docs.rs` (62bec2d) ## [0.18.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.17.2...actuate-v0.18.0) - 2024-12-07 ## Breaking changes - Create `ScrollView` composable and new `ui` module (28628f4, ebb17b0) - The `material` is now located under `ui` ## Features - Add support for reactive Bevy desktop apps (7c65ba9, 6918000) - Add more picking handler methods to `Modify` (64404b3) - More advanced typography with new Text composable (825e007) - Derive `Clone` for `Spawn` and refactor (6c4e457) - Add methods to modify all Node fields ## [0.17.2](https://github.com/actuate-rs/actuate/compare/actuate-v0.17.1...actuate-v0.17.2) - 2024-12-07 ## Fixes - Update pending composable ordering and track child index in `Spawn` composable (fdf89ed) - Reverse node IDs and refactor internals (42e1971) ## Documentation - Add docs to `spawn` constructor and split up ecs module (9c06bfe) - Move examples for `catch` and `dyn_compose` to rustdocs (9502a4b) - Move traits example to data module and add docs, reorganize examples (67ec922) - Update Data docs (829c6d9) ## [0.17.1](https://github.com/actuate-rs/actuate/compare/actuate-v0.17.0...actuate-v0.17.1) - 2024-12-06 ## Features - Create `FromFn` composable - You can now create a composable without input using `from_fn` (433ab1d) - ```rs fn from_fn(f: F) -> FromFn where F: Fn(ScopeState) -> C, C: Compose ``` - Derive `Clone` and `Debug` for `Button`, `Container`, and `RadioButton` (4f337ed) ## Documentation - Update docs for feature flags (869aa89) ## [0.17.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.16.1...actuate-v0.17.0) - 2024-12-06 ## Breaking changes - Move `Modifier` and `Modify` to ecs module (behind new picking feature) (35b10ea) - These items can be useful for other design systems than Material 3 - Call `on_insert` on every insertion of a spawned bundle (this now requires `Fn` instead of `FnOnce`) (533da07) ## Fixes - Revert from breadth-first traversal of the composition to depth-first (8b3acd2) - Update styling for `Container` (9cca3a7) ## [0.16.1](https://github.com/actuate-rs/actuate/compare/actuate-v0.16.0...actuate-v0.16.1) - 2024-12-05 ## Features - Material UI components - `Button` - `Container` - `RadioButton` - `text` - `label` - `heading` - New scheduling algorithm based on `BTreeSet` (2a457a9) ## [0.16.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.15.0...actuate-v0.16.0) - 2024-12-05 ### Breaking changes - Major internal rewrite! (9ef73eb) The new internals allow for more dynamic control over the composition , enabling features like pause and resume of a composition. `Composer::try_compose` will now also skip directly to changed composables, rather than setting change flags. - Removes exported methods for `ScopeData` - The `Runtime` struct is now private to ensure safety ## Features - `Composer` is now an iterator! This allows for stepping through each composable in the composition. - `Composer` also implements `fmt::Debug`: ```rs use actuate::prelude::*; use actuate::composer::Composer; #[derive(Data)] struct A; impl Compose for A { fn compose(cx: Scope) -> impl Compose { (B, C) } } #[derive(Data)] struct B; impl Compose for B { fn compose(cx: Scope) -> impl Compose {} } #[derive(Data)] struct C; impl Compose for C { fn compose(cx: Scope) -> impl Compose {} } let mut composer = Composer::new(A); composer.try_compose().unwrap(); assert_eq!(format!("{:?}", composer), "Composer(A(B, C))") ``` ## [0.15.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.14.2...actuate-v0.15.0) - 2024-12-03 ### Breaking changes - Add `#[actuate(path = "..")]` attribute to `Data` macro and use fully-qualified path to Actuate by default (b159478). - This allows for use of the `Data` macro without importing the full `prelude`. - Replace `DynCompose::new` with `dyn_compose` constructor fn (9d65ec8). - Return `Rc` from use_context - `fn use_context(cx: ScopeState<'_>) -> Result<&Rc, ContextError> { .. }` - This allows for cloning context into `'static` environments. ### Refactors - Use explicit imports internally to speed up compile times and exclude hidden `Data` traits from prelude (07bfd96). ## [0.14.2](https://github.com/actuate-rs/actuate/compare/actuate-v0.14.1...actuate-v0.14.2) - 2024-12-03 ### Features - Optimize empty composables by skipping creation of ScopeData ### Fixes - Enable Tokio dependency with animation and ecs features (5263fe4) ## [0.14.1](https://github.com/actuate-rs/actuate/compare/actuate-v0.14.0...actuate-v0.14.1) - 2024-12-03 ### Fixes - Remove unused tokio read lock guard (0ad962f) ## [0.14.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.13.0...actuate-v0.14.0) - 2024-12-03 ### Breaking Changes - Remove unsound `Compose` impl for `Map` and create `MapUnchecked` struct - The original `Compose` impl for `Map` would cause undefined behavior if multiple references to the same composable were used. The new unsafe `MapUnchecked` keeps this functionality for low-level components, where the documented safety contract can be checked. However, for most composables I now see `Compose + Clone` being a typical pattern (which I think is fine given some composables only copy references when cloned, and references to composables can still be passed around). ### Fixes - Impl re-composition when the type has changed in `DynCompose` (7d41100) ### Documentation - Update docs for `Spawn` composable (205b88a) - Add example to showcase `DynCompose` (7d41100) ## [0.13.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.12.0...actuate-v0.13.0) - 2024-12-02 ### Breaking Changes - Use `PartialEq` in `use_memo` instead of the `Memoize` trait (6539c95) - This is to memoize tuples and other groups of data. To use pointer equality, you can still use `Signal::generation` or `Memoize::memoize` to get the current generation. - Remove unused UseWorld struct (81615cd) ### Documentation - Add more documentation to the `Catch` composable - Adds a quick explanation of using `Result` + `Catch`, and links to the `catch` constructor function for more info. - Add explanation to `compose::from_iter` (dc6715d) ### Other - Change release procedure and update CI (dd4be8d, fe23aad, 723fe6c) ## [0.12.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.11.0...actuate-v0.12.0) - 2024-12-02 ### Other - `#![no_std]` support ([#100](https://github.com/actuate-rs/actuate/pull/100)) - Clean up and add internal docs - Remove Sized bound in Compose trait - Create `Catch` composable and impl `Compose` for `Result` ([#99](https://github.com/actuate-rs/actuate/pull/99)) - Add getter and setter methods to ScopeData - Update docs - Remove is_empty from ScopeState in favor of checking for empty types - Create README.md ## [0.11.0](https://github.com/actuate-rs/actuate/compare/actuate-v0.10.2...actuate-v0.11.0) - 2024-11-29 ### Other - Update to Bevy 0.15.0 - Disable observers after drop - Add support for standard references in RefMap and Cow - Fix formatting in README ## [0.10.2](https://github.com/actuate-rs/actuate/compare/actuate-v0.10.1...actuate-v0.10.2) - 2024-11-28 ### Other - Add specialized impl of SystemParamFunction for Triggers - Export animation channel - Impl Data for UseAnimated - Impl Data for Pin - Impl Data for Box> - Allow return values for Data fns - Create `use_animated` hook ([#88](https://github.com/actuate-rs/actuate/pull/88)) - Fix tasks not running on the ecs ## [0.10.1](https://github.com/actuate-rs/actuate/compare/actuate-v0.10.0...actuate-v0.10.1) - 2024-11-26 ### Other - Apply system params in use_world_once - Apply deferred system param updates - Add SignalMut::set_if_neq and generation methods ================================================ FILE: Cargo.toml ================================================ [package] name = "actuate" version = "0.21.0" edition = "2021" license = "MIT OR Apache-2.0" description = "A reactive user-interface framework" repository = "https://github.com/actuate-rs/actuate" [features] animation = ["ecs", "dep:bevy_math", "dep:bevy_time", "dep:tokio"] ecs = ["std", "dep:bevy_app", "dep:bevy_ecs", "dep:bevy_utils", "dep:bevy_winit"] executor = ["std", "dep:tokio"] material = ["ecs", "ui", "picking", "dep:bevy_color", "dep:bevy_input", "dep:bevy_text"] picking = ["dep:bevy_picking"] rt = ["executor", "tokio/rt-multi-thread"] std = [] tracing = ["dep:tracing"] ui = ["dep:bevy_ui"] full = ["animation", "ecs", "material", "rt", "tracing"] default = ["std"] [workspace] members = [ ".", "macros" ] [dependencies] actuate-macros = { version = "0.2.0", path = "macros" } ahash = { version = "0.8.11", default-features = false } bevy_app = { version = "0.17.3", optional = true } bevy_color = { version = "0.17.3", optional = true } bevy_ecs = { version = "0.17.3", optional = true } bevy_input = { version = "0.17.3", optional = true } bevy_math = { version = "0.17.3", optional = true } bevy_picking = { version = "0.17.3", optional = true } bevy_text = { version = "0.17.3", optional = true } bevy_time = { version = "0.17.3", optional = true } bevy_ui = { version = "0.17.3", optional = true } bevy_utils = { version = "0.17.3", optional = true } bevy_winit = { version = "0.17.3", optional = true } crossbeam-queue = { version = "0.3.11", default-features = false, features = ["alloc"] } futures = "0.3.31" hashbrown = "0.15.2" slotmap = "1.0.7" thiserror = "2.0.3" tracing = { version = "0.1.40", optional = true } tokio = { version = "1.41.1", features = ["sync"], optional = true } typeid = "1.0.2" [dev-dependencies] bevy = { version = "0.17.3" } reqwest = { version = "0.12.9", features = ["json"] } serde = { version = "1.0.215", features = ["derive"] } tracing-subscriber = "0.3.18" [package.metadata.docs.rs] all-features = true features = ["bevy_winit/x11"] rustdoc-args = ["--cfg", "docsrs"] [[example]] name = "counter" required-features = ["material"] [[example]] name = "http" required-features = ["material", "rt"] [[example]] name = "radio_button" required-features = ["material"] [[example]] name = "timer" required-features = ["ecs"] ================================================ FILE: LICENSE-APACHE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: LICENSE-MIT ================================================ MIT License Copyright (c) 2023 Matthew Hunzinger Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================

Actuate

Crates.io version docs.rs docs CI status

A high-performance and borrow-checker friendly framework for declarative programming in Rust. This crate provides a generic library that lets you define reactive components (also known as composables). ## Features - Declarative scenes and UI for [Bevy](https://github.com/bevyengine/bevy) - Efficient and borrow-checker friendly state management: Manage state with components and hooks, all using zero-cost smart pointers - Generic core for custom backends ```rust use actuate::prelude::*; #[derive(Data)] struct Counter { start: i32, } impl Compose for Counter { fn compose(cx: Scope) -> impl Compose { let count = use_mut(&cx, || cx.me().start); material_ui(( text::headline(format!("High five count: {}", count)), button(text::label("Up high")).on_click(move || SignalMut::update(count, |x| *x += 1)), button(text::label("Down low")).on_click(move || SignalMut::update(count, |x| *x -= 1)), if *count == 0 { Some(text::label("Gimme five!")) } else { None }, )) .align_items(AlignItems::Center) .justify_content(JustifyContent::Center) } } ``` ## Borrowing Composables can borrow from their ancestors, as well as state. ```rs use actuate::prelude::*; #[derive(Data)] struct User<'a> { // `actuate::Cow` allows for either a borrowed or owned value. name: Cow<'a, String>, } impl Compose for User<'_> { fn compose(cx: Scope) -> impl Compose { text::headline(cx.me().name.to_string()) } } #[derive(Data)] struct App { name: String } impl Compose for App { fn compose(cx: Scope) -> impl Compose { // Get a mapped reference to the app's `name` field. let name = Signal::map(cx.me(), |me| &me.name).into(); User { name } } } ``` ## Installation To add this crate to your project: ``` cargo add actuate --features full ``` For more feature flags, see the crate documentation for [features](https://docs.rs/actuate/latest/actuate/#features). ## Inspiration This crate is inspired by [Xilem](https://github.com/linebender/xilem) and uses a similar approach to type-safe reactivity. The main difference with this crate is the concept of scopes, components store their state in their own scope and updates to that scope re-render the component. State management is inspired by React and [Dioxus](https://github.com/DioxusLabs/dioxus). Previous implementations were in [Concoct](https://github.com/concoct-rs/concoct) but were never very compatible with lifetimes. ================================================ FILE: examples/README.md ================================================ ## Examples Examples combining Actuate and [Bevy](https://github.com/bevyengine/bevy) You can run these examples with: ``` cargo run --features full --example {EXAMPLE} ``` ================================================ FILE: examples/counter.rs ================================================ // Counter UI example. use actuate::prelude::*; use bevy::{prelude::*, winit::WinitSettings}; // Counter composable. #[derive(Data)] struct Counter { start: i32, } impl Compose for Counter { fn compose(cx: Scope) -> impl Compose { let count = use_mut(&cx, || cx.me().start); material_ui(( text::headline(format!("High five count: {}", count)), button(text::label("Up high")).on_click(move || SignalMut::update(count, |x| *x += 1)), button(text::label("Down low")).on_click(move || SignalMut::update(count, |x| *x -= 1)), if *count == 0 { Some(text::label("Gimme five!")) } else { None }, )) .align_items(AlignItems::Center) .justify_content(JustifyContent::Center) } } fn setup(mut commands: Commands) { commands.spawn(Camera2d::default()); // Spawn a composition with a `Counter`, adding it to the Actuate runtime. commands.spawn(( Node { width: Val::Percent(100.), height: Val::Percent(100.), ..default() }, Composition::new(Counter { start: 0 }), )); } fn main() { App::new() .add_plugins((DefaultPlugins, ActuatePlugin)) .insert_resource(WinitSettings::desktop_app()) .add_systems(Startup, setup) .run(); } ================================================ FILE: examples/http.rs ================================================ // HTTP UI example use actuate::{executor::ExecutorContext, prelude::*}; use bevy::{prelude::*, winit::WinitSettings}; use serde::Deserialize; use std::collections::HashMap; // Dog breed composable. #[derive(Data)] struct Breed { name: String, families: Vec, } impl Compose for Breed { fn compose(cx: Scope) -> impl Compose { container(( text::headline(cx.me().name.to_owned()), compose::from_iter(cx.me().families.clone(), |family| { text::label(family.to_string()) }), )) } } #[derive(Deserialize)] struct Response { message: HashMap>, } // Dog breed list composable. #[derive(Data)] struct BreedList; impl Compose for BreedList { fn compose(cx: Scope) -> impl Compose { let breeds = use_mut(&cx, HashMap::new); // Spawn a task that loads dog breeds from an HTTP API. use_task(&cx, move || async move { let json: Response = reqwest::get("https://dog.ceo/api/breeds/list/all") .await .unwrap() .json() .await .unwrap(); SignalMut::set(breeds, json.message); }); material_ui( // Render the currently loaded breeds. scroll_view(compose::from_iter((*breeds).clone(), |breed| Breed { name: breed.0.clone(), families: breed.1.clone(), })) .max_width(Val::Px(400.)) .flex_gap(Val::Px(30.)), ) .align_items(AlignItems::Center) } } #[derive(Data)] struct Example; impl Compose for Example { fn compose(cx: Scope) -> impl Compose { // Setup the Tokio executor. use_provider(&cx, ExecutorContext::default); BreedList } } fn main() { App::new() .add_plugins((DefaultPlugins, ActuatePlugin)) .insert_resource(WinitSettings::desktop_app()) .add_systems(Startup, setup) .run(); } fn setup(mut commands: Commands) { commands.spawn(Camera2d::default()); // Spawn a composition with a `BreedList`, adding it to the Actuate runtime. commands.spawn(( Node { width: Val::Percent(100.), height: Val::Percent(100.), ..default() }, Composition::new(Example), )); } ================================================ FILE: examples/radio_button.rs ================================================ // Counter UI example. use actuate::prelude::*; use bevy::prelude::*; // Counter composable. #[derive(Data)] struct Example; impl Compose for Example { fn compose(cx: Scope) -> impl Compose { let is_shown = use_mut(&cx, || true); radio_button() .is_enabled(*is_shown) .on_click(move || SignalMut::update(is_shown, |x| *x = !*x)) } } fn setup(mut commands: Commands) { commands.spawn(Camera2d::default()); // Spawn a composition with a `Counter`, adding it to the Actuate runtime. commands.spawn(( Node { flex_direction: FlexDirection::Column, align_items: AlignItems::Center, row_gap: Val::Px(10.), ..default() }, Composition::new(Example), )); } fn main() { App::new() .add_plugins((DefaultPlugins, ActuatePlugin)) .add_systems(Startup, setup) .run(); } ================================================ FILE: examples/timer.rs ================================================ // Timer UI example. use actuate::prelude::*; use bevy::prelude::*; // Timer composable. #[derive(Data)] struct Timer; impl Compose for Timer { fn compose(cx: Scope) -> impl Compose { let current_time = use_mut(&cx, Time::default); // Use the `Time` resource from the ECS world, updating the `current_time`. use_world(&cx, move |time: Res