{"id":15439404,"url":"https://github.com/synphonyte/leptos-bevy-canvas","last_synced_at":"2025-04-06T06:06:39.511Z","repository":{"id":256822778,"uuid":"856537286","full_name":"Synphonyte/leptos-bevy-canvas","owner":"Synphonyte","description":"Embed an idiomatic Bevy app inside your Leptos app with ease.","archived":false,"fork":false,"pushed_at":"2025-03-19T18:30:22.000Z","size":159,"stargazers_count":72,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-05T04:27:02.568Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Synphonyte.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Synphonyte"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-09-12T18:38:33.000Z","updated_at":"2025-04-03T06:12:52.000Z","dependencies_parsed_at":"2025-01-17T07:05:04.337Z","dependency_job_id":"5fd3a450-2d5b-4753-b6df-cbc06890abda","html_url":"https://github.com/Synphonyte/leptos-bevy-canvas","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":"0.12903225806451613","last_synced_commit":"744f1a26253e7255ff60020446e2c68b2ae94eb7"},"previous_names":["synphonyte/leptos-bevy-canvas"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Synphonyte%2Fleptos-bevy-canvas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Synphonyte%2Fleptos-bevy-canvas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Synphonyte%2Fleptos-bevy-canvas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Synphonyte%2Fleptos-bevy-canvas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Synphonyte","download_url":"https://codeload.github.com/Synphonyte/leptos-bevy-canvas/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441042,"owners_count":20939239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T19:05:47.414Z","updated_at":"2025-04-06T06:06:39.486Z","avatar_url":"https://github.com/Synphonyte.png","language":"Rust","funding_links":["https://github.com/sponsors/Synphonyte"],"categories":[],"sub_categories":[],"readme":"# Leptos Bevy Canvas\n\n[![Crates.io](https://img.shields.io/crates/v/leptos-bevy-canvas.svg)](https://crates.io/crates/leptos-bevy-canvas)\n[![Docs](https://docs.rs/leptos-bevy-canvas/badge.svg)](https://docs.rs/leptos-bevy-canvas/)\n[![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/synphonyte/leptos-bevy-canvas#license)\n[![Build Status](https://github.com/synphonyte/leptos-bevy-canvas/actions/workflows/ci.yml/badge.svg)](https://github.com/synphonyte/leptos-bevy-canvas/actions/workflows/ci.yml)\n[![built with Codeium](https://codeium.com/badges/main)](https://codeium.com)\n\n\u003c!-- cargo-rdme start --\u003e\n\nEmbed an idiomatic Bevy app inside your Leptos app.\n\n[Send and Receive Events ![Events Demo](https://media.githubusercontent.com/media/Synphonyte/leptos-bevy-canvas/refs/heads/main/docs/unidir_events.webp)](https://github.com/Synphonyte/leptos-bevy-canvas/tree/main/examples/unidir_events)\n\n[Sync Bevy Queries ![Query Sync Demo](https://media.githubusercontent.com/media/Synphonyte/leptos-bevy-canvas/refs/heads/main/docs/synced_bevy_query.webp)](https://github.com/Synphonyte/leptos-bevy-canvas/tree/main/examples/synced_bevy_query)\n\n## Features\n\n- **Easy to use** - Simply embed your Bevy app inside your Leptos app with the\n  [`BevyCanvas`](fn@crate::prelude::BevyCanvas) component.\n- **Idiomatic** - This crate doesn't want you to do anything differently in the way you write\n  your Bevy app or your Leptos app. It just gives you the tools for them to communicate.\n- **Events** - Send events in either or both directions between your Bevy app and your Leptos app.\n- **Resource signals** - Synchronize Bevy `Resource`s with `RwSignal`s in your Leptos app.\n\n## Example\n\n```rust\nuse bevy::prelude::*;\nuse leptos::prelude::*;\nuse leptos_bevy_canvas::prelude::*;\n\n#[derive(Event)]\npub struct TextEvent {\n    pub text: String,\n}\n\n#[component]\npub fn App() -\u003e impl IntoView {\n    // This initializes a sender for the Leptos app and\n    // a receiver for the Bevy app\n    let (text_event_sender, bevy_text_receiver) = event_l2b::\u003cTextEvent\u003e();\n\n    let on_input = move |evt| {\n        // send the event over to Bevy\n        text_event_sender\n            .send(TextEvent { text: event_target_value(\u0026evt) })\n            .ok();\n    };\n\n    view! {\n        \u003cinput type=\"text\" on:input=on_input /\u003e\n\n        \u003cBevyCanvas\n            init=move || {\n                // Pass the receiver into the Bevy app initialization\n                init_bevy_app(bevy_text_receiver)\n            }\n\n            {..}\n            width=\"300\"\n            height=\"500\"\n        /\u003e\n    }\n}\n\n// In Bevy it ends up just as a normal event\npub fn set_text(\n    mut event_reader: EventReader\u003cTextEvent\u003e,\n) {\n    for event in event_reader.read() {\n        // do something with the event\n    }\n}\n\n// This initializes a normal Bevy app\nfn init_bevy_app( text_receiver: BevyEventReceiver\u003cTextEvent\u003e) -\u003e App {\n    let mut app = App::new();\n    app\n        .add_plugins(\n            DefaultPlugins.set(WindowPlugin {\n                primary_window: Some(Window {\n                    // \"#bevy_canvas\" is the default and can be\n                    // changed in the \u003cBevyCanvas\u003e component\n                    canvas: Some(\"#bevy_canvas\".into()),\n                    ..default()\n                }),\n                ..default()\n            }),\n        )\n        // import the event here into Bevy\n        .import_event_from_leptos(text_receiver)\n        .add_systems(Update, set_text);\n\n    app\n}\n```\n\nPlease check the examples to see how to synchronize a `Resource` or a `Query`.\n\n## Compatibility\n\n| Crate version | Compatible Leptos version | Compatible Bevy version |\n|---------------|---------------------------|-------------------------|\n| 0.1, 0.2      | 0.7                       | 0.15                    |\n\n\u003c!-- cargo-rdme end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynphonyte%2Fleptos-bevy-canvas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynphonyte%2Fleptos-bevy-canvas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynphonyte%2Fleptos-bevy-canvas/lists"}