From d955342e64c0cd19cbd7ff52cd7c27097d334bee Mon Sep 17 00:00:00 2001 From: Stuart Harris Date: Tue, 9 Jun 2026 09:13:20 +0100 Subject: [PATCH] chore!: remove crux_platform --- Cargo.lock | 9 -- Cargo.toml | 1 - Justfile | 2 +- README.md | 2 - crux_core/README.md | 2 - crux_macros/README.md | 1 - crux_macros/src/export.rs | 14 -- crux_platform/CHANGELOG.md | 191 --------------------------- crux_platform/Cargo.toml | 16 --- crux_platform/README.md | 48 ------- crux_platform/src/command.rs | 5 - crux_platform/src/lib.rs | 39 ------ crux_platform/src/protocol.rs | 24 ---- crux_platform/tests/platform_test.rs | 116 ---------------- renovate.json | 1 - 15 files changed, 1 insertion(+), 470 deletions(-) delete mode 100644 crux_platform/CHANGELOG.md delete mode 100644 crux_platform/Cargo.toml delete mode 100644 crux_platform/README.md delete mode 100644 crux_platform/src/command.rs delete mode 100644 crux_platform/src/lib.rs delete mode 100644 crux_platform/src/protocol.rs delete mode 100644 crux_platform/tests/platform_test.rs diff --git a/Cargo.lock b/Cargo.lock index 6eaadc4fb..55526b35a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -526,15 +526,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "crux_platform" -version = "0.10.0" -dependencies = [ - "crux_core", - "facet 0.44.5", - "serde", -] - [[package]] name = "crux_time" version = "0.17.0" diff --git a/Cargo.toml b/Cargo.toml index d59753fec..34cd91ca2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ members = [ "crux_http", "crux_kv", "crux_macros", - "crux_platform", "crux_time", "doctest_support", "examples_support/api_server", diff --git a/Justfile b/Justfile index 59bcabf58..3fe9069c8 100644 --- a/Justfile +++ b/Justfile @@ -1,5 +1,5 @@ # Crates published in order (dependencies before dependents) -publish_packages := "crux_macros crux_core crux_http crux_kv crux_platform crux_time" +publish_packages := "crux_macros crux_core crux_http crux_kv crux_time" default: ci diff --git a/README.md b/README.md index a967b1d02..83543a878 100644 --- a/README.md +++ b/README.md @@ -145,8 +145,6 @@ you want to: 1. `Time` (get current time, notify after duration, notify at instant) — [source](./crux_time), [crate](https://crates.io/crates/crux_time), request/response -1. `Platform` (get the current platform) — [source](./crux_platform), - [crate](https://crates.io/crates/crux_platform), request/response (**deprecated** — copy the types into your own project instead) ### Example custom capabilities diff --git a/crux_core/README.md b/crux_core/README.md index 23bbb1952..180f5c1bb 100644 --- a/crux_core/README.md +++ b/crux_core/README.md @@ -144,8 +144,6 @@ you want to: 1. `Time` (get current time, notify after duration, notify at instant) — [source](https://github.com/redbadger/crux/tree/master/crux_time), [crate](https://crates.io/crates/crux_time), request/response -1. `Platform` (get the current platform) — [source](https://github.com/redbadger/crux/tree/master/crux_platform), - [crate](https://crates.io/crates/crux_platform), request/response (**deprecated** — copy the types into your own project instead) ### Example custom capabilities diff --git a/crux_macros/README.md b/crux_macros/README.md index 6449f78f5..24d47a8be 100644 --- a/crux_macros/README.md +++ b/crux_macros/README.md @@ -90,7 +90,6 @@ Full usage might look something like this: pub struct CatFactCapabilities { pub http: Http, pub key_value: KeyValue, - pub platform: Platform, pub render: Render, pub time: Time, } diff --git a/crux_macros/src/export.rs b/crux_macros/src/export.rs index ec5f87f5d..3340f5e83 100644 --- a/crux_macros/src/export.rs +++ b/crux_macros/src/export.rs @@ -203,7 +203,6 @@ mod tests { pub struct MyCapabilities { pub http: crux_http::Http, pub key_value: KeyValue, - pub platform: Platform, pub render: Render, #[effect(skip)] pub time: Time, @@ -227,9 +226,6 @@ mod tests { as Capability>::Operation::register_types(generator)?; - as Capability>::Operation::register_types(generator)?; as Capability>::Operation::register_types(generator)?; generator.register_type::()?; generator.register_type::<::crux_core::bridge::Request>()?; @@ -249,9 +245,6 @@ mod tests { as Capability>::Operation::register_types_facet(generator)?; - as Capability>::Operation::register_types_facet(generator)?; as Capability>::Operation::register_types_facet(generator)?; @@ -271,7 +264,6 @@ mod tests { pub struct MyCapabilities { pub http: crux_http::Http, pub key_value: KeyValue, - pub platform: Platform, pub render: Render, pub time: Time, } @@ -294,9 +286,6 @@ mod tests { as Capability>::Operation::register_types(generator)?; - as Capability>::Operation::register_types(generator)?; as Capability>::Operation::register_types(generator)?; as Capability>::Operation::register_types(generator)?; generator.register_type::()?; @@ -317,9 +306,6 @@ mod tests { as Capability>::Operation::register_types_facet(generator)?; - as Capability>::Operation::register_types_facet(generator)?; as Capability>::Operation::register_types_facet(generator)?; diff --git a/crux_platform/CHANGELOG.md b/crux_platform/CHANGELOG.md deleted file mode 100644 index d89960f56..000000000 --- a/crux_platform/CHANGELOG.md +++ /dev/null @@ -1,191 +0,0 @@ -# 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). - -## [Unreleased] - -## [0.10.0](https://github.com/redbadger/crux/compare/crux_platform-v0.9.0...crux_platform-v0.10.0) - 2026-05-31 - -### ⚠️ Deprecated - -- **This crate is deprecated and will no longer be maintained.** - The `Platform` capability never did much, and it is straightforward to copy the - small amount of code into your own project as a custom capability. See the README - for a drop-in migration snippet. -- All public items (`Platform`, `PlatformRequest`, `PlatformResponse`) are now - marked `#[deprecated]` so you will receive compiler warnings when using this crate. - -### ⚙️ Miscellaneous Tasks - -- Align with `crux_core` 0.19.0. - -## [0.9.0](https://github.com/redbadger/crux/compare/crux_platform-v0.8.0...crux_platform-v0.9.0) - 2026-05-07 - -### ⚙️ Miscellaneous Tasks - -- Align with `crux_core` 0.18.0. No public API changes. - -## [0.8.0](https://github.com/redbadger/crux/compare/crux_platform-v0.7.0...crux_platform-v0.8.0) - 2026-03-20 - -### 🚀 Features - -**This is a breaking release.** - -- **Command API Support**: Updated to work with the new Command API, removing dependency on the deprecated Capability trait. -- **Enhanced Testing**: Improved testing support with new command-based test helpers. - -### ⚙️ Miscellaneous Tasks - -- Update to `facet_generate` 0.15, `facet` 0.31, and other Rust dependencies. -- Migrate internal implementation from Capability to Command API. -- Update documentation and examples for Command-based usage. -- Update Rust dependencies and align with `crux_core` 0.17.0. - -## [0.7.0](https://github.com/redbadger/crux/compare/crux_platform-v0.6.0...crux_platform-v0.7.0) - 2025-07-03 - -### ⚙️ Miscellaneous Tasks - -- *(crux)* Format fixes - -## [0.6.0](https://github.com/redbadger/crux/compare/crux_platform-v0.5.0...crux_platform-v0.6.0) - 2025-05-27 - -This is a minor bump because of breaking changes in `crux_core` - -### Other - -- clippy pedantic - -## [0.5.0](https://github.com/redbadger/crux/compare/crux_platform-v0.4.0...crux_platform-v0.5.0) - 2025-04-09 - -### Other - -- updated the following local packages: crux_core - -## [0.4.0](https://github.com/redbadger/crux/compare/crux_platform-v0.3.6...crux_platform-v0.4.0) - 2025-04-09 -Replaces yanked 0.3.6 as that broke typegen on older versions of crux_core. - -## [0.3.6](https://github.com/redbadger/crux/compare/crux_platform-v0.3.5...crux_platform-v0.3.6) - 2025-04-08 - -Updated to use version 0.13 of [`crux_core`](https://crates.io/crates/crux_core). - -## [0.3.5](https://github.com/redbadger/crux/compare/crux_platform-v0.3.4...crux_platform-v0.3.5) - 2025-03-21 - -### Other - -- updated the following local packages: crux_core - -## [0.3.4](https://github.com/redbadger/crux/compare/crux_platform-v0.3.3...crux_platform-v0.3.4) - 2025-03-17 - -This is a maintenance release (minor non-breaking changes and dependency updates). - -### Other - -- update Cargo.toml dependencies - -## [0.3.3](https://github.com/redbadger/crux/compare/crux_platform-v0.3.2...crux_platform-v0.3.3) - 2025-02-18 - -### Other - -- Updates internal tests for error handling when resolving requests - -## [0.3.2](https://github.com/redbadger/crux/compare/crux_platform-v0.3.1...crux_platform-v0.3.2) - 2025-02-03 - -### Other - -- update platform capability to have command support - -## [0.3.1](https://github.com/redbadger/crux/compare/crux_platform-v0.3.0...crux_platform-v0.3.1) - 2025-01-22 - -### Other - -- update Cargo.toml dependencies - -## [0.3.0](https://github.com/redbadger/crux/compare/crux_platform-v0.2.3...crux_platform-v0.3.0) - 2025-01-21 - -### Other - -- Integrate Commands into the Core so apps can mix and match -- Update App trait to support Command, fix all tests - -## [0.2.3](https://github.com/redbadger/crux/compare/crux_platform-v0.2.2...crux_platform-v0.2.3) - 2025-01-07 - -### Other - -- update Cargo.lock dependencies - -## [0.2.2](https://github.com/redbadger/crux/compare/crux_platform-v0.2.1...crux_platform-v0.2.2) - 2024-10-23 - -### Other - -- update tests - -## [0.2.1](https://github.com/redbadger/crux/compare/crux_platform-v0.2.0...crux_platform-v0.2.1) - 2024-20-21 - -- no changes, just updated dependencies - -## [0.2.0](https://github.com/redbadger/crux/compare/crux_platform-v0.1.12...crux_platform-v0.2.0) - 2024-08-12 - -### Other -- updated the following local packages: crux_core - -## [0.1.12](https://github.com/redbadger/crux/compare/crux_platform-v0.1.11...crux_platform-v0.1.12) - 2024-05-21 - -### Other - -- Release crux_core v0.8.0 - -## [0.1.11](https://github.com/redbadger/crux/compare/crux_platform-v0.1.10...crux_platform-v0.1.11) - 2024-05-15 - -### Other - -- remove unused deps - -## [0.1.10](https://github.com/redbadger/crux/compare/crux_platform-v0.1.9...crux_platform-v0.1.10) - 2024-05-14 - -### Other - -- relax vaious func traits from Fn to FnOnce - -## [0.1.9](https://github.com/redbadger/crux/compare/crux_platform-v0.1.8...crux_platform-v0.1.9) - 2024-03-24 - -### Other - -- update Cargo.toml dependencies - -## [0.1.8](https://github.com/redbadger/crux/compare/crux_platform-v0.1.7...crux_platform-v0.1.8) - 2024-02-02 - -### Fixed - -- fix doc test deps - -### Other - -- Export crux_macros from crux_core and change docs - -## [0.1.7](https://github.com/redbadger/crux/compare/crux_platform-v0.1.6...crux_platform-v0.1.7) - 2024-01-11 - -### Other - -- update Cargo.toml dependencies - -## [0.1.6](https://github.com/redbadger/crux/compare/crux_platform-v0.1.5...crux_platform-v0.1.6) - 2023-12-03 - -### Other - -- updated the following local packages: crux_core - -## [0.1.5](https://github.com/redbadger/crux/compare/crux_platform-v0.1.4...crux_platform-v0.1.5) - 2023-11-29 - -### Other - -- update dependencies - -## [0.1.4](https://github.com/redbadger/crux/compare/crux_platform-v0.1.3...crux_platform-v0.1.4) - 2023-10-25 - -### Other - -- versions for compatibility with semver checks -- implement derive macro for Capability trait diff --git a/crux_platform/Cargo.toml b/crux_platform/Cargo.toml deleted file mode 100644 index fb7fbc90a..000000000 --- a/crux_platform/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "crux_platform" -description = "Platform capability for use with crux_core" -version = "0.10.0" -readme = "README.md" -authors.workspace = true -repository.workspace = true -edition.workspace = true -license.workspace = true -keywords.workspace = true -rust-version.workspace = true - -[dependencies] -crux_core = { version = "0.19.0", path = "../crux_core" } -facet.workspace = true -serde = { workspace = true, features = ["derive"] } diff --git a/crux_platform/README.md b/crux_platform/README.md deleted file mode 100644 index d7aea32c6..000000000 --- a/crux_platform/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# crux_platform (deprecated) - -> **⚠️ This crate is deprecated and will no longer be maintained.** - -The `crux_platform` capability was provided as a convenience for querying the current platform -(iOS, Android, Web, etc.) from the shell. In practice it never did much, and with the -[Command API](https://docs.rs/crux_core/latest/crux_core/command/index.html) it is -straightforward to create your own platform capability tailored to your app's needs. - -## Migration - -Copy the handful of types below into your own project and adjust them however you like. -The shell-side implementation (responding to `PlatformRequest` with a `PlatformResponse`) -remains exactly the same. - -```rust -use crux_core::{Command, Request, command::RequestBuilder, capability::Operation}; -use facet::Facet; -use serde::{Deserialize, Serialize}; -use std::marker::PhantomData; - -#[derive(Facet, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub struct PlatformRequest; - -#[derive(Facet, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct PlatformResponse(pub String); - -impl Operation for PlatformRequest { - type Output = PlatformResponse; -} - -pub struct Platform { - _marker: PhantomData<(Effect, Event)>, -} - -impl Platform -where - Effect: From> + Send + 'static, - Event: Send + 'static, -{ - pub fn get() -> RequestBuilder> { - Command::request_from_shell(PlatformRequest) - } -} -``` - -For more information on building custom capabilities, see -[Managed Effects](https://redbadger.github.io/crux/guide/effects.html) in the Crux book. diff --git a/crux_platform/src/command.rs b/crux_platform/src/command.rs deleted file mode 100644 index dad2b6f44..000000000 --- a/crux_platform/src/command.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![allow(deprecated)] - -// For backwards compatibility -#[deprecated(since = "0.17.9", note = "Import directly from crate root")] -pub use crate::Platform; diff --git a/crux_platform/src/lib.rs b/crux_platform/src/lib.rs deleted file mode 100644 index 8324cd21a..000000000 --- a/crux_platform/src/lib.rs +++ /dev/null @@ -1,39 +0,0 @@ -#![allow(clippy::unsafe_derive_deserialize)] -//! # Deprecated -//! -//! This crate is deprecated and will no longer be maintained. -//! -//! The `Platform` capability was originally provided as a convenience for querying the current -//! platform from the shell. Create a custom capability in your own project instead — -//! see the [README](https://crates.io/crates/crux_platform) for a drop-in migration snippet. - -pub mod command; -pub mod protocol; - -use std::marker::PhantomData; - -use crux_core::{Command, Request, command::RequestBuilder}; - -pub use protocol::*; - -#[deprecated( - since = "0.10.0", - note = "The `crux_platform` crate is deprecated. Copy the types into your own project instead. See the README for migration guidance: https://crates.io/crates/crux_platform" -)] -pub struct Platform { - effect: PhantomData, - event: PhantomData, -} - -#[allow(deprecated)] -impl Platform -where - Effect: From> + Send + 'static, - Event: Send + 'static, -{ - /// Get the platform of the shell - #[must_use] - pub fn get() -> RequestBuilder> { - Command::request_from_shell(PlatformRequest) - } -} diff --git a/crux_platform/src/protocol.rs b/crux_platform/src/protocol.rs deleted file mode 100644 index 3c0a37316..000000000 --- a/crux_platform/src/protocol.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![allow(deprecated)] - -use crux_core::capability::Operation; -use facet::Facet; -use serde::{Deserialize, Serialize}; - -#[deprecated( - since = "0.10.0", - note = "The `crux_platform` crate is deprecated. Copy the types into your own project instead. See the README for migration guidance: https://crates.io/crates/crux_platform" -)] -#[derive(Facet, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub struct PlatformRequest; - -#[deprecated( - since = "0.10.0", - note = "The `crux_platform` crate is deprecated. Copy the types into your own project instead. See the README for migration guidance: https://crates.io/crates/crux_platform" -)] -#[derive(Facet, Debug, PartialEq, Eq, Serialize, Deserialize)] -pub struct PlatformResponse(pub String); - -#[allow(deprecated)] -impl Operation for PlatformRequest { - type Output = PlatformResponse; -} diff --git a/crux_platform/tests/platform_test.rs b/crux_platform/tests/platform_test.rs deleted file mode 100644 index 0d4f0e455..000000000 --- a/crux_platform/tests/platform_test.rs +++ /dev/null @@ -1,116 +0,0 @@ -#![allow(deprecated)] - -mod shared { - use crux_core::macros::effect; - use crux_core::render::RenderOperation; - use crux_core::{Command, render::render}; - use crux_platform::{Platform, PlatformRequest, PlatformResponse}; - use serde::{Deserialize, Serialize}; - - #[derive(Default)] - pub struct App; - - #[derive(Serialize, Deserialize)] - pub enum Event { - PlatformGet, - PlatformSet(PlatformResponse), - } - - #[derive(Default, Serialize, Deserialize)] - pub struct Model { - pub platform: String, - } - - #[derive(Serialize, Deserialize, Default)] - pub struct ViewModel { - pub platform: String, - } - - impl crux_core::App for App { - type Event = Event; - type Model = Model; - type ViewModel = ViewModel; - type Effect = Effect; - - fn update(&self, event: Event, model: &mut Model) -> Command { - match event { - Event::PlatformGet => Platform::get().then_send(Event::PlatformSet), - Event::PlatformSet(platform) => { - model.platform = platform.0; - - render() - } - } - } - - fn view(&self, model: &Self::Model) -> Self::ViewModel { - ViewModel { - platform: model.platform.clone(), - } - } - } - - #[effect] - pub enum Effect { - Platform(PlatformRequest), - Render(RenderOperation), - } -} - -mod shell { - use super::shared::{App, Effect, Event}; - use crux_core::{Core, Request}; - use crux_platform::{PlatformRequest, PlatformResponse}; - use std::collections::VecDeque; - - pub enum Outcome { - Platform(Request, PlatformResponse), - } - - enum CoreMessage { - Event(Event), - Response(Outcome), - } - - pub fn run(core: &Core) { - let mut queue: VecDeque = VecDeque::new(); - - queue.push_back(CoreMessage::Event(Event::PlatformGet)); - - while !queue.is_empty() { - let msg = queue.pop_front(); - - let effs = match msg { - Some(CoreMessage::Event(m)) => core.process_event(m), - Some(CoreMessage::Response(Outcome::Platform(mut request, outcome))) => core - .resolve(&mut request, outcome) - .expect("effect should resolve"), - - _ => vec![], - }; - - for effect in effs { - if let Effect::Platform(request) = effect { - queue.push_back(CoreMessage::Response(Outcome::Platform( - request, - PlatformResponse("test shell".to_string()), - ))); - } - } - } - } -} - -mod tests { - use crate::{shared::App, shell::run}; - use crux_core::Core; - - #[test] - pub fn test_platform() { - let core: Core = Core::default(); - - run(&core); - - assert_eq!(core.view().platform, "test shell"); - } -} diff --git a/renovate.json b/renovate.json index d8a9f3e89..bbdef0126 100644 --- a/renovate.json +++ b/renovate.json @@ -30,7 +30,6 @@ "crux_http/**", "crux_kv/**", "crux_macros/**", - "crux_platform/**", "crux_time/**" ], "matchManagers": ["cargo"],