From c2fb7111fb0571e711a2ee432024755f003210fb Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Mon, 26 May 2025 10:48:13 -0700 Subject: [PATCH 1/5] Renamed BRP methods. --- crates/bevy_remote/src/builtin_methods.rs | 140 ++++++++++----------- crates/bevy_remote/src/lib.rs | 48 +++---- crates/bevy_remote/src/schemas/open_rpc.rs | 2 +- 3 files changed, 95 insertions(+), 95 deletions(-) diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index 18c85d3eec..4de4d27ad3 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -31,53 +31,53 @@ use crate::{ #[cfg(all(feature = "http", not(target_family = "wasm")))] use {crate::schemas::open_rpc::ServerObject, bevy_utils::default}; -/// The method path for a `bevy/get` request. -pub const BRP_GET_METHOD: &str = "bevy/get"; +/// The method path for a `bevy/world/components/get` request. +pub const BRP_GET_METHOD: &str = "bevy/world/components/get"; -/// The method path for a `bevy/query` request. -pub const BRP_QUERY_METHOD: &str = "bevy/query"; +/// The method path for a `bevy/world/query` request. +pub const BRP_QUERY_METHOD: &str = "bevy/world/query"; -/// The method path for a `bevy/spawn` request. -pub const BRP_SPAWN_METHOD: &str = "bevy/spawn"; +/// The method path for a `bevy/world/spawn` request. +pub const BRP_SPAWN_METHOD: &str = "bevy/world/spawn"; -/// The method path for a `bevy/insert` request. -pub const BRP_INSERT_METHOD: &str = "bevy/insert"; +/// The method path for a `bevy/world/components/insert` request. +pub const BRP_INSERT_METHOD: &str = "bevy/world/components/insert"; -/// The method path for a `bevy/remove` request. -pub const BRP_REMOVE_METHOD: &str = "bevy/remove"; +/// The method path for a `bevy/world/components/remove` request. +pub const BRP_REMOVE_METHOD: &str = "bevy/world/components/remove"; -/// The method path for a `bevy/destroy` request. -pub const BRP_DESTROY_METHOD: &str = "bevy/destroy"; +/// The method path for a `bevy/world/despawn` request. +pub const BRP_DESPAWN_METHOD: &str = "bevy/world/despawn"; -/// The method path for a `bevy/reparent` request. -pub const BRP_REPARENT_METHOD: &str = "bevy/reparent"; +/// The method path for a `bevy/world/reparent` request. +pub const BRP_REPARENT_METHOD: &str = "bevy/world/reparent"; -/// The method path for a `bevy/list` request. -pub const BRP_LIST_METHOD: &str = "bevy/list"; +/// The method path for a `bevy/world/components/list` request. +pub const BRP_LIST_METHOD: &str = "bevy/world/components/list"; -/// The method path for a `bevy/mutate_component` request. -pub const BRP_MUTATE_COMPONENT_METHOD: &str = "bevy/mutate_component"; +/// The method path for a `bevy/world/components/mutate` request. +pub const BRP_MUTATE_COMPONENT_METHOD: &str = "bevy/world/components/mutate"; -/// The method path for a `bevy/get+watch` request. -pub const BRP_GET_AND_WATCH_METHOD: &str = "bevy/get+watch"; +/// The method path for a `bevy/world/components/get+watch` request. +pub const BRP_GET_AND_WATCH_METHOD: &str = "bevy/world/components/get+watch"; -/// The method path for a `bevy/list+watch` request. -pub const BRP_LIST_AND_WATCH_METHOD: &str = "bevy/list+watch"; +/// The method path for a `bevy/world/components/list+watch` request. +pub const BRP_LIST_AND_WATCH_METHOD: &str = "bevy/world/components/list+watch"; -/// The method path for a `bevy/get_resource` request. -pub const BRP_GET_RESOURCE_METHOD: &str = "bevy/get_resource"; +/// The method path for a `bevy/world/resources/get` request. +pub const BRP_GET_RESOURCE_METHOD: &str = "bevy/world/resources/get"; -/// The method path for a `bevy/insert_resource` request. -pub const BRP_INSERT_RESOURCE_METHOD: &str = "bevy/insert_resource"; +/// The method path for a `bevy/world/resources/insert` request. +pub const BRP_INSERT_RESOURCE_METHOD: &str = "bevy/world/resources/insert"; -/// The method path for a `bevy/remove_resource` request. -pub const BRP_REMOVE_RESOURCE_METHOD: &str = "bevy/remove_resource"; +/// The method path for a `bevy/world/resources/remove` request. +pub const BRP_REMOVE_RESOURCE_METHOD: &str = "bevy/world/resources/remove"; -/// The method path for a `bevy/mutate_resource` request. -pub const BRP_MUTATE_RESOURCE_METHOD: &str = "bevy/mutate_resource"; +/// The method path for a `bevy/world/resources/mutate` request. +pub const BRP_MUTATE_RESOURCE_METHOD: &str = "bevy/world/resources/mutate"; -/// The method path for a `bevy/list_resources` request. -pub const BRP_LIST_RESOURCES_METHOD: &str = "bevy/list_resources"; +/// The method path for a `bevy/world/resources/list` request. +pub const BRP_LIST_RESOURCES_METHOD: &str = "bevy/world/resources/list"; /// The method path for a `bevy/registry/schema` request. pub const BRP_REGISTRY_SCHEMA_METHOD: &str = "bevy/registry/schema"; @@ -85,7 +85,7 @@ pub const BRP_REGISTRY_SCHEMA_METHOD: &str = "bevy/registry/schema"; /// The method path for a `rpc.discover` request. pub const RPC_DISCOVER_METHOD: &str = "rpc.discover"; -/// `bevy/get`: Retrieves one or more components from the entity with the given +/// `bevy/world/components/get`: Retrieves one or more components from the entity with the given /// ID. /// /// The server responds with a [`BrpGetResponse`]. @@ -110,7 +110,7 @@ pub struct BrpGetParams { pub strict: bool, } -/// `bevy/get_resource`: Retrieves the value of a given resource. +/// `bevy/world/resources/get`: Retrieves the value of a given resource. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct BrpGetResourceParams { /// The [full path] of the resource type being requested. @@ -119,7 +119,7 @@ pub struct BrpGetResourceParams { pub resource: String, } -/// `bevy/query`: Performs a query over components in the ECS, returning entities +/// `bevy/world/query`: Performs a query over components in the ECS, returning entities /// and component values that match. /// /// The server responds with a [`BrpQueryResponse`]. @@ -139,7 +139,7 @@ pub struct BrpQueryParams { pub strict: bool, } -/// `bevy/spawn`: Creates a new entity with the given components and responds +/// `bevy/world/spawn`: Creates a new entity with the given components and responds /// with its ID. /// /// The server responds with a [`BrpSpawnResponse`]. @@ -157,7 +157,7 @@ pub struct BrpSpawnParams { pub components: HashMap, } -/// `bevy/destroy`: Given an ID, despawns the entity with that ID. +/// `bevy/world/despawn`: Given an ID, despawns the entity with that ID. /// /// The server responds with an okay. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] @@ -166,7 +166,7 @@ pub struct BrpDestroyParams { pub entity: Entity, } -/// `bevy/remove`: Deletes one or more components from an entity. +/// `bevy/world/components/remove`: Deletes one or more components from an entity. /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] @@ -185,7 +185,7 @@ pub struct BrpRemoveParams { pub components: Vec, } -/// `bevy/remove_resource`: Removes the given resource from the world. +/// `bevy/world/resources/remove`: Removes the given resource from the world. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct BrpRemoveResourceParams { /// The [full path] of the resource type to remove. @@ -194,7 +194,7 @@ pub struct BrpRemoveResourceParams { pub resource: String, } -/// `bevy/insert`: Adds one or more components to an entity. +/// `bevy/world/components/insert`: Adds one or more components to an entity. /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] @@ -214,7 +214,7 @@ pub struct BrpInsertParams { pub components: HashMap, } -/// `bevy/insert_resource`: Inserts a resource into the world with a given +/// `bevy/world/resources/insert`: Inserts a resource into the world with a given /// value. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct BrpInsertResourceParams { @@ -227,7 +227,7 @@ pub struct BrpInsertResourceParams { pub value: Value, } -/// `bevy/reparent`: Assign a new parent to one or more entities. +/// `bevy/world/reparent`: Assign a new parent to one or more entities. /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] @@ -244,7 +244,7 @@ pub struct BrpReparentParams { pub parent: Option, } -/// `bevy/list`: Returns a list of all type names of registered components in the +/// `bevy/world/components/list`: Returns a list of all type names of registered components in the /// system (no params provided), or those on an entity (params provided). /// /// The server responds with a [`BrpListResponse`] @@ -254,7 +254,7 @@ pub struct BrpListParams { pub entity: Entity, } -/// `bevy/mutate_component`: +/// `bevy/world/components/mutate`: /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] @@ -276,7 +276,7 @@ pub struct BrpMutateComponentParams { pub value: Value, } -/// `bevy/mutate_resource`: +/// `bevy/world/resources/mutate`: /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] @@ -373,14 +373,14 @@ pub struct JsonSchemaTypeLimit { /// A response from the world to the client that specifies a single entity. /// -/// This is sent in response to `bevy/spawn`. +/// This is sent in response to `bevy/world/spawn`. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct BrpSpawnResponse { /// The ID of the entity in question. pub entity: Entity, } -/// The response to a `bevy/get` request. +/// The response to a `bevy/world/components/get` request. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(untagged)] pub enum BrpGetResponse { @@ -396,14 +396,14 @@ pub enum BrpGetResponse { Strict(HashMap), } -/// The response to a `bevy/get_resource` request. +/// The response to a `bevy/world/resources/get` request. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct BrpGetResourceResponse { /// The value of the requested resource. pub value: Value, } -/// A single response from a `bevy/get+watch` request. +/// A single response from a `bevy/world/components/get+watch` request. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(untagged)] pub enum BrpGetWatchingResponse { @@ -428,20 +428,20 @@ pub enum BrpGetWatchingResponse { }, } -/// The response to a `bevy/list` request. +/// The response to a `bevy/world/components/list` request. pub type BrpListResponse = Vec; -/// The response to a `bevy/list_resources` request. +/// The response to a `bevy/world/resources/list` request. pub type BrpListResourcesResponse = Vec; -/// A single response from a `bevy/list+watch` request. +/// A single response from a `bevy/world/components/list+watch` request. #[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)] pub struct BrpListWatchingResponse { added: Vec, removed: Vec, } -/// The response to a `bevy/query` request. +/// The response to a `bevy/world/query` request. pub type BrpQueryResponse = Vec; /// One query match result: a single entity paired with the requested components. @@ -479,7 +479,7 @@ fn parse_some Deserialize<'de>>(value: Option) -> Result>, world: &World) -> BrpResult { let BrpGetParams { entity, @@ -496,7 +496,7 @@ pub fn process_remote_get_request(In(params): In>, world: &World) serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/get_resource` request coming from a client. +/// Handles a `bevy/world/resources/get` request coming from a client. pub fn process_remote_get_resource_request( In(params): In>, world: &World, @@ -535,7 +535,7 @@ pub fn process_remote_get_resource_request( serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/get+watch` request coming from a client. +/// Handles a `bevy/world/components/get+watch` request coming from a client. pub fn process_remote_get_watching_request( In(params): In>, world: &World, @@ -703,7 +703,7 @@ fn reflect_component( Ok(serialized_object) } -/// Handles a `bevy/query` request coming from a client. +/// Handles a `bevy/world/query` request coming from a client. pub fn process_remote_query_request(In(params): In>, world: &mut World) -> BrpResult { let BrpQueryParams { data: BrpQuery { @@ -806,7 +806,7 @@ pub fn process_remote_query_request(In(params): In>, world: &mut W serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/spawn` request coming from a client. +/// Handles a `bevy/world/spawn` request coming from a client. pub fn process_remote_spawn_request(In(params): In>, world: &mut World) -> BrpResult { let BrpSpawnParams { components } = parse_some(params)?; @@ -863,7 +863,7 @@ pub fn process_remote_list_methods_request( serde_json::to_value(doc).map_err(BrpError::internal) } -/// Handles a `bevy/insert` request (insert components) coming from a client. +/// Handles a `bevy/world/components/insert` request (insert components) coming from a client. pub fn process_remote_insert_request( In(params): In>, world: &mut World, @@ -886,7 +886,7 @@ pub fn process_remote_insert_request( Ok(Value::Null) } -/// Handles a `bevy/insert_resource` request coming from a client. +/// Handles a `bevy/world/resources/insert` request coming from a client. pub fn process_remote_insert_resource_request( In(params): In>, world: &mut World, @@ -909,7 +909,7 @@ pub fn process_remote_insert_resource_request( Ok(Value::Null) } -/// Handles a `bevy/mutate_component` request coming from a client. +/// Handles a `bevy/world/components/mutate` request coming from a client. /// /// This method allows you to mutate a single field inside an Entity's /// component. @@ -973,7 +973,7 @@ pub fn process_remote_mutate_component_request( Ok(Value::Null) } -/// Handles a `bevy/mutate_resource` request coming from a client. +/// Handles a `bevy/world/resources/mutate` request coming from a client. pub fn process_remote_mutate_resource_request( In(params): In>, world: &mut World, @@ -1024,7 +1024,7 @@ pub fn process_remote_mutate_resource_request( Ok(Value::Null) } -/// Handles a `bevy/remove` request (remove components) coming from a client. +/// Handles a `bevy/world/components/remove` request (remove components) coming from a client. pub fn process_remote_remove_request( In(params): In>, world: &mut World, @@ -1053,7 +1053,7 @@ pub fn process_remote_remove_request( Ok(Value::Null) } -/// Handles a `bevy/remove_resource` request coming from a client. +/// Handles a `bevy/world/resources/remove` request coming from a client. pub fn process_remote_remove_resource_request( In(params): In>, world: &mut World, @@ -1072,8 +1072,8 @@ pub fn process_remote_remove_resource_request( Ok(Value::Null) } -/// Handles a `bevy/destroy` (despawn entity) request coming from a client. -pub fn process_remote_destroy_request( +/// Handles a `bevy/world/despawn` (despawn entity) request coming from a client. +pub fn process_remote_despawn_request( In(params): In>, world: &mut World, ) -> BrpResult { @@ -1084,7 +1084,7 @@ pub fn process_remote_destroy_request( Ok(Value::Null) } -/// Handles a `bevy/reparent` request coming from a client. +/// Handles a `bevy/world/reparent` request coming from a client. pub fn process_remote_reparent_request( In(params): In>, world: &mut World, @@ -1115,7 +1115,7 @@ pub fn process_remote_reparent_request( Ok(Value::Null) } -/// Handles a `bevy/list` request (list all components) coming from a client. +/// Handles a `bevy/world/components/list` request (list all components) coming from a client. pub fn process_remote_list_request(In(params): In>, world: &World) -> BrpResult { let app_type_registry = world.resource::(); let type_registry = app_type_registry.read(); @@ -1148,7 +1148,7 @@ pub fn process_remote_list_request(In(params): In>, world: &World) serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/list_resources` request coming from a client. +/// Handles a `bevy/world/resources/list` request coming from a client. pub fn process_remote_list_resources_request( In(_params): In>, world: &World, @@ -1169,7 +1169,7 @@ pub fn process_remote_list_resources_request( serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/list+watch` request coming from a client. +/// Handles a `bevy/world/components/list+watch` request coming from a client. pub fn process_remote_list_watching_request( In(params): In>, world: &World, diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index 97b2e453e7..0625ad6301 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -14,7 +14,7 @@ //! //! ```json //! { -//! "method": "bevy/get", +//! "method": "bevy/world/components/get", //! "id": 0, //! "params": { //! "entity": 4294967298, @@ -35,7 +35,7 @@ //! response. //! //! * `method` is a string that specifies one of the possible [`BrpRequest`] -//! variants: `bevy/query`, `bevy/get`, `bevy/insert`, etc. It's case-sensitive. +//! variants: `bevy/world/query`, `bevy/world/components/get`, `bevy/world/components/insert`, etc. It's case-sensitive. //! //! * `params` is parameter data specific to the request. //! @@ -102,7 +102,7 @@ //! in the ECS. Each of these methods uses the `bevy/` prefix, which is a namespace reserved for //! BRP built-in methods. //! -//! ### `bevy/get` +//! ### `bevy/world/components/get` //! //! Retrieve the values of one or more components from an entity. //! @@ -123,7 +123,7 @@ //! //! `result`: A map associating each type name to its value on the requested entity. //! -//! ### `bevy/query` +//! ### `bevy/world/query` //! //! Perform a query over components in the ECS, returning all matching entities and their associated //! component values. @@ -155,7 +155,7 @@ //! //! //! -//! ### `bevy/spawn` +//! ### `bevy/world/spawn` //! //! Create a new entity with the provided components and return the resulting entity ID. //! @@ -165,7 +165,7 @@ //! `result`: //! - `entity`: The ID of the newly spawned entity. //! -//! ### `bevy/destroy` +//! ### `bevy/world/despawn` //! //! Despawn the entity with the given ID. //! @@ -174,7 +174,7 @@ //! //! `result`: null. //! -//! ### `bevy/remove` +//! ### `bevy/world/components/remove` //! //! Delete one or more components from an entity. //! @@ -184,7 +184,7 @@ //! //! `result`: null. //! -//! ### `bevy/insert` +//! ### `bevy/world/components/insert` //! //! Insert one or more components into an entity. //! @@ -194,7 +194,7 @@ //! //! `result`: null. //! -//! ### `bevy/mutate_component` +//! ### `bevy/world/components/mutate` //! //! Mutate a field in a component. //! @@ -207,7 +207,7 @@ //! //! `result`: null. //! -//! ### `bevy/reparent` +//! ### `bevy/world/reparent` //! //! Assign a new parent to one or more entities. //! @@ -218,7 +218,7 @@ //! //! `result`: null. //! -//! ### `bevy/list` +//! ### `bevy/world/components/list` //! //! List all registered components or all components present on an entity. //! @@ -230,7 +230,7 @@ //! //! `result`: An array of fully-qualified type names of components. //! -//! ### `bevy/get+watch` +//! ### `bevy/world/components/get+watch` //! //! Watch the values of one or more components from an entity. //! @@ -258,7 +258,7 @@ //! - `removed`: An array of fully-qualified type names of components removed from the entity //! in the last tick. //! -//! ### `bevy/list+watch` +//! ### `bevy/world/components/list+watch` //! //! Watch all components present on an entity. //! @@ -274,7 +274,7 @@ //! - `removed`: An array of fully-qualified type names of components removed from the entity //! in the last tick. //! -//! ### `bevy/get_resource` +//! ### `bevy/world/resources/get` //! //! Extract the value of a given resource from the world. //! @@ -284,7 +284,7 @@ //! `result`: //! - `value`: The value of the resource in the world. //! -//! ### `bevy/insert_resource` +//! ### `bevy/world/resources/insert` //! //! Insert the given resource into the world with the given value. //! @@ -294,7 +294,7 @@ //! //! `result`: null. //! -//! ### `bevy/remove_resource` +//! ### `bevy/world/resources/remove` //! //! Remove the given resource from the world. //! @@ -303,7 +303,7 @@ //! //! `result`: null. //! -//! ### `bevy/mutate_resource` +//! ### `bevy/world/resources/mutate` //! //! Mutate a field in a resource. //! @@ -315,7 +315,7 @@ //! //! `result`: null. //! -//! ### `bevy/list_resources` +//! ### `bevy/world/resources/list` //! //! List all reflectable registered resource types. This method has no parameters. //! @@ -460,8 +460,8 @@ impl Default for RemotePlugin { builtin_methods::process_remote_remove_request, ) .with_method( - builtin_methods::BRP_DESTROY_METHOD, - builtin_methods::process_remote_destroy_request, + builtin_methods::BRP_DESPAWN_METHOD, + builtin_methods::process_remote_despawn_request, ) .with_method( builtin_methods::BRP_REPARENT_METHOD, @@ -585,7 +585,7 @@ pub enum RemoteMethodHandler { Watching(Box>, Out = BrpResult>>>), } -/// The [`SystemId`] of a function that implements a remote instant method (`bevy/get`, `bevy/query`, etc.) +/// The [`SystemId`] of a function that implements a remote instant method (`bevy/world/components/get`, `bevy/world/query`, etc.) /// /// The first parameter is the JSON value of the `params`. Typically, an /// implementation will deserialize these as the first thing they do. @@ -594,7 +594,7 @@ pub enum RemoteMethodHandler { /// automatically populate the `id` field before sending. pub type RemoteInstantMethodSystemId = SystemId>, BrpResult>; -/// The [`SystemId`] of a function that implements a remote watching method (`bevy/get+watch`, `bevy/list+watch`, etc.) +/// The [`SystemId`] of a function that implements a remote watching method (`bevy/world/components/get+watch`, `bevy/world/components/list+watch`, etc.) /// /// The first parameter is the JSON value of the `params`. Typically, an /// implementation will deserialize these as the first thing they do. @@ -659,7 +659,7 @@ pub struct RemoteWatchingRequests(Vec<(BrpMessage, RemoteWatchingMethodSystemId) /// ```json /// { /// "jsonrpc": "2.0", -/// "method": "bevy/get", +/// "method": "bevy/world/components/get", /// "id": 0, /// "params": { /// "entity": 4294967298, @@ -674,7 +674,7 @@ pub struct RemoteWatchingRequests(Vec<(BrpMessage, RemoteWatchingMethodSystemId) /// ```json /// { /// "jsonrpc": "2.0", -/// "method": "bevy/list", +/// "method": "bevy/world/components/list", /// "id": 0, /// "params": null ///} diff --git a/crates/bevy_remote/src/schemas/open_rpc.rs b/crates/bevy_remote/src/schemas/open_rpc.rs index 0ffda36bc3..27a5c35a1a 100644 --- a/crates/bevy_remote/src/schemas/open_rpc.rs +++ b/crates/bevy_remote/src/schemas/open_rpc.rs @@ -69,7 +69,7 @@ pub struct ServerObject { #[derive(Serialize, Deserialize, Debug, Default)] #[serde(rename_all = "camelCase")] pub struct MethodObject { - /// The method name (e.g., "/bevy/get") + /// The method name (e.g., "/bevy/world/components/get") pub name: String, /// An optional short summary of the method. #[serde(skip_serializing_if = "Option::is_none")] From b621db54c45e920774e1174bcb5581c5e618175e Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Mon, 26 May 2025 12:37:34 -0700 Subject: [PATCH 2/5] Added migration guide. --- .../migration-guides/renamed_BRP_methods.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 release-content/migration-guides/renamed_BRP_methods.md diff --git a/release-content/migration-guides/renamed_BRP_methods.md b/release-content/migration-guides/renamed_BRP_methods.md new file mode 100644 index 0000000000..6184a87fe3 --- /dev/null +++ b/release-content/migration-guides/renamed_BRP_methods.md @@ -0,0 +1,26 @@ +--- +title: Renamed BRP methods to be more hierarchical +pull_requests: [19377] +--- + +Most Bevy Remote Protocol methods have been renamed to be more hierarchical. +The word `destroy` has also been replaced with `despawn` to match the rest of the engine. + +| Old | New | +|------------------------|------------------------------------| +| `bevy/query` | `bevy/world/query` | +| `bevy/spawn` | `bevy/world/spawn` | +| `bevy/destroy` | `bevy/world/despawn` | +| `bevy/reparent` | `bevy/world/reparent` | +| `bevy/get` | `bevy/world/components/get` | +| `bevy/insert` | `bevy/world/components/insert` | +| `bevy/remove` | `bevy/world/components/remove` | +| `bevy/list` | `bevy/world/components/list` | +| `bevy/mutate` | `bevy/world/components/mutate` | +| `bevy/get+watch` | `bevy/world/components/get+watch` | +| `bevy/list+watch` | `bevy/world/components/list+watch` | +| `bevy/get_resource` | `bevy/world/resources/get` | +| `bevy/insert_resource` | `bevy/world/resources/insert` | +| `bevy/remove_resource` | `bevy/world/resources/remove` | +| `bevy/list_resources` | `bevy/world/resources/list` | +| `bevy/mutate_resource` | `bevy/world/resources/mutate` | From cdc5c2ce0523de437b8bbabf3633e8f200b6a8e8 Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Sat, 7 Jun 2025 10:37:53 -0700 Subject: [PATCH 3/5] Renamed to follow the `world.get_components` format. Also renamed associated types and functions. --- crates/bevy_remote/src/builtin_methods.rs | 285 +++++++++--------- crates/bevy_remote/src/lib.rs | 94 +++--- crates/bevy_remote/src/schemas/open_rpc.rs | 2 +- .../migration-guides/renamed_BRP_methods.md | 41 +-- 4 files changed, 216 insertions(+), 206 deletions(-) diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index 4de4d27ad3..8cf386e919 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -31,66 +31,66 @@ use crate::{ #[cfg(all(feature = "http", not(target_family = "wasm")))] use {crate::schemas::open_rpc::ServerObject, bevy_utils::default}; -/// The method path for a `bevy/world/components/get` request. -pub const BRP_GET_METHOD: &str = "bevy/world/components/get"; +/// The method path for a `world.get_components` request. +pub const BRP_GET_COMPONENTS_METHOD: &str = "world.get_components"; -/// The method path for a `bevy/world/query` request. -pub const BRP_QUERY_METHOD: &str = "bevy/world/query"; +/// The method path for a `world.query` request. +pub const BRP_QUERY_METHOD: &str = "world.query"; -/// The method path for a `bevy/world/spawn` request. -pub const BRP_SPAWN_METHOD: &str = "bevy/world/spawn"; +/// The method path for a `world.spawn_entity` request. +pub const BRP_SPAWN_ENTITY_METHOD: &str = "world.spawn_entity"; -/// The method path for a `bevy/world/components/insert` request. -pub const BRP_INSERT_METHOD: &str = "bevy/world/components/insert"; +/// The method path for a `world.insert_components` request. +pub const BRP_INSERT_COMPONENTS_METHOD: &str = "world.insert_components"; -/// The method path for a `bevy/world/components/remove` request. -pub const BRP_REMOVE_METHOD: &str = "bevy/world/components/remove"; +/// The method path for a `world.remove_components` request. +pub const BRP_REMOVE_COMPONENTS_METHOD: &str = "world.remove_components"; -/// The method path for a `bevy/world/despawn` request. -pub const BRP_DESPAWN_METHOD: &str = "bevy/world/despawn"; +/// The method path for a `world.despawn_entity` request. +pub const BRP_DESPAWN_COMPONENTS_METHOD: &str = "world.despawn_entity"; -/// The method path for a `bevy/world/reparent` request. -pub const BRP_REPARENT_METHOD: &str = "bevy/world/reparent"; +/// The method path for a `world.reparent_entity` request. +pub const BRP_REPARENT_ENTITY_METHOD: &str = "world.reparent_entity"; -/// The method path for a `bevy/world/components/list` request. -pub const BRP_LIST_METHOD: &str = "bevy/world/components/list"; +/// The method path for a `world.list_components` request. +pub const BRP_LIST_COMPONENTS_METHOD: &str = "world.list_components"; -/// The method path for a `bevy/world/components/mutate` request. -pub const BRP_MUTATE_COMPONENT_METHOD: &str = "bevy/world/components/mutate"; +/// The method path for a `world.mutate_components` request. +pub const BRP_MUTATE_COMPONENTS_METHOD: &str = "world.mutate_components"; -/// The method path for a `bevy/world/components/get+watch` request. -pub const BRP_GET_AND_WATCH_METHOD: &str = "bevy/world/components/get+watch"; +/// The method path for a `world.get_components+watch` request. +pub const BRP_GET_COMPONENTS_AND_WATCH_METHOD: &str = "world.get_components+watch"; -/// The method path for a `bevy/world/components/list+watch` request. -pub const BRP_LIST_AND_WATCH_METHOD: &str = "bevy/world/components/list+watch"; +/// The method path for a `world.list_components+watch` request. +pub const BRP_LIST_COMPONENTS_AND_WATCH_METHOD: &str = "world.list_components+watch"; -/// The method path for a `bevy/world/resources/get` request. -pub const BRP_GET_RESOURCE_METHOD: &str = "bevy/world/resources/get"; +/// The method path for a `world.get_resources` request. +pub const BRP_GET_RESOURCE_METHOD: &str = "world.get_resources"; -/// The method path for a `bevy/world/resources/insert` request. -pub const BRP_INSERT_RESOURCE_METHOD: &str = "bevy/world/resources/insert"; +/// The method path for a `world.insert_resources` request. +pub const BRP_INSERT_RESOURCE_METHOD: &str = "world.insert_resources"; -/// The method path for a `bevy/world/resources/remove` request. -pub const BRP_REMOVE_RESOURCE_METHOD: &str = "bevy/world/resources/remove"; +/// The method path for a `world.remove_resources` request. +pub const BRP_REMOVE_RESOURCE_METHOD: &str = "world.remove_resources"; -/// The method path for a `bevy/world/resources/mutate` request. -pub const BRP_MUTATE_RESOURCE_METHOD: &str = "bevy/world/resources/mutate"; +/// The method path for a `world.mutate_resources` request. +pub const BRP_MUTATE_RESOURCE_METHOD: &str = "world.mutate_resources"; -/// The method path for a `bevy/world/resources/list` request. -pub const BRP_LIST_RESOURCES_METHOD: &str = "bevy/world/resources/list"; +/// The method path for a `world.list_resources` request. +pub const BRP_LIST_RESOURCES_METHOD: &str = "world.list_resources"; -/// The method path for a `bevy/registry/schema` request. -pub const BRP_REGISTRY_SCHEMA_METHOD: &str = "bevy/registry/schema"; +/// The method path for a `registry.schema` request. +pub const BRP_REGISTRY_SCHEMA_METHOD: &str = "registry.schema"; /// The method path for a `rpc.discover` request. pub const RPC_DISCOVER_METHOD: &str = "rpc.discover"; -/// `bevy/world/components/get`: Retrieves one or more components from the entity with the given +/// `world.get_components`: Retrieves one or more components from the entity with the given /// ID. /// -/// The server responds with a [`BrpGetResponse`]. +/// The server responds with a [`BrpGetComponentsResponse`]. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpGetParams { +pub struct BrpGetComponentsParams { /// The ID of the entity from which components are to be requested. pub entity: Entity, @@ -110,16 +110,16 @@ pub struct BrpGetParams { pub strict: bool, } -/// `bevy/world/resources/get`: Retrieves the value of a given resource. +/// `world.get_resources`: Retrieves the value of a given resource. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpGetResourceParams { +pub struct BrpGetResourcesParams { /// The [full path] of the resource type being requested. /// /// [full path]: bevy_reflect::TypePath::type_path pub resource: String, } -/// `bevy/world/query`: Performs a query over components in the ECS, returning entities +/// `world.query`: Performs a query over components in the ECS, returning entities /// and component values that match. /// /// The server responds with a [`BrpQueryResponse`]. @@ -139,12 +139,12 @@ pub struct BrpQueryParams { pub strict: bool, } -/// `bevy/world/spawn`: Creates a new entity with the given components and responds +/// `world.spawn_entity`: Creates a new entity with the given components and responds /// with its ID. /// -/// The server responds with a [`BrpSpawnResponse`]. +/// The server responds with a [`BrpSpawnEntityResponse`]. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpSpawnParams { +pub struct BrpSpawnEntityParams { /// A map from each component's full path to its serialized value. /// /// These components will be added to the entity. @@ -157,20 +157,20 @@ pub struct BrpSpawnParams { pub components: HashMap, } -/// `bevy/world/despawn`: Given an ID, despawns the entity with that ID. +/// `world.despawn_entity`: Given an ID, despawns the entity with that ID. /// /// The server responds with an okay. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpDestroyParams { +pub struct BrpDespawnEntityParams { /// The ID of the entity to despawn. pub entity: Entity, } -/// `bevy/world/components/remove`: Deletes one or more components from an entity. +/// `world.remove_components`: Deletes one or more components from an entity. /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpRemoveParams { +pub struct BrpRemoveComponentsParams { /// The ID of the entity from which components are to be removed. pub entity: Entity, @@ -185,20 +185,20 @@ pub struct BrpRemoveParams { pub components: Vec, } -/// `bevy/world/resources/remove`: Removes the given resource from the world. +/// `world.remove_resources`: Removes the given resource from the world. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpRemoveResourceParams { +pub struct BrpRemoveResourcesParams { /// The [full path] of the resource type to remove. /// /// [full path]: bevy_reflect::TypePath::type_path pub resource: String, } -/// `bevy/world/components/insert`: Adds one or more components to an entity. +/// `world.insert_components`: Adds one or more components to an entity. /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpInsertParams { +pub struct BrpInsertComponentsParams { /// The ID of the entity that components are to be added to. pub entity: Entity, @@ -214,10 +214,10 @@ pub struct BrpInsertParams { pub components: HashMap, } -/// `bevy/world/resources/insert`: Inserts a resource into the world with a given +/// `world.insert_resources`: Inserts a resource into the world with a given /// value. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpInsertResourceParams { +pub struct BrpInsertResourcesParams { /// The [full path] of the resource type to insert. /// /// [full path]: bevy_reflect::TypePath::type_path @@ -227,11 +227,11 @@ pub struct BrpInsertResourceParams { pub value: Value, } -/// `bevy/world/reparent`: Assign a new parent to one or more entities. +/// `world.reparent_entity`: Assign a new parent to one or more entities. /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpReparentParams { +pub struct BrpReparentEntityParams { /// The IDs of the entities that are to become the new children of the /// `parent`. pub entities: Vec, @@ -244,21 +244,21 @@ pub struct BrpReparentParams { pub parent: Option, } -/// `bevy/world/components/list`: Returns a list of all type names of registered components in the +/// `world.list_components`: Returns a list of all type names of registered components in the /// system (no params provided), or those on an entity (params provided). /// -/// The server responds with a [`BrpListResponse`] +/// The server responds with a [`BrpListComponentsResponse`] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpListParams { +pub struct BrpListComponentsParams { /// The entity to query. pub entity: Entity, } -/// `bevy/world/components/mutate`: +/// `world.mutate_components`: /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpMutateComponentParams { +pub struct BrpMutateComponentsParams { /// The entity of the component to mutate. pub entity: Entity, @@ -276,11 +276,11 @@ pub struct BrpMutateComponentParams { pub value: Value, } -/// `bevy/world/resources/mutate`: +/// `world.mutate_resources`: /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpMutateResourceParams { +pub struct BrpMutateResourcesParams { /// The [full path] of the resource to mutate. /// /// [full path]: bevy_reflect::TypePath::type_path @@ -373,17 +373,17 @@ pub struct JsonSchemaTypeLimit { /// A response from the world to the client that specifies a single entity. /// -/// This is sent in response to `bevy/world/spawn`. +/// This is sent in response to `world.spawn_entity`. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpSpawnResponse { +pub struct BrpSpawnEntityResponse { /// The ID of the entity in question. pub entity: Entity, } -/// The response to a `bevy/world/components/get` request. +/// The response to a `world.get_components` request. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(untagged)] -pub enum BrpGetResponse { +pub enum BrpGetComponentsResponse { /// The non-strict response that reports errors separately without failing the entire request. Lenient { /// A map of successful components with their values. @@ -396,17 +396,17 @@ pub enum BrpGetResponse { Strict(HashMap), } -/// The response to a `bevy/world/resources/get` request. +/// The response to a `world.get_resources` request. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpGetResourceResponse { +pub struct BrpGetResourcesResponse { /// The value of the requested resource. pub value: Value, } -/// A single response from a `bevy/world/components/get+watch` request. +/// A single response from a `world.get_components+watch` request. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[serde(untagged)] -pub enum BrpGetWatchingResponse { +pub enum BrpGetComponentsWatchingResponse { /// The non-strict response that reports errors separately without failing the entire request. Lenient { /// A map of successful components with their values that were added or changes in the last @@ -428,20 +428,20 @@ pub enum BrpGetWatchingResponse { }, } -/// The response to a `bevy/world/components/list` request. -pub type BrpListResponse = Vec; +/// The response to a `world.list_components` request. +pub type BrpListComponentsResponse = Vec; -/// The response to a `bevy/world/resources/list` request. +/// The response to a `world.list_resources` request. pub type BrpListResourcesResponse = Vec; -/// A single response from a `bevy/world/components/list+watch` request. +/// A single response from a `world.list_components+watch` request. #[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpListWatchingResponse { +pub struct BrpListComponentsWatchingResponse { added: Vec, removed: Vec, } -/// The response to a `bevy/world/query` request. +/// The response to a `world.query` request. pub type BrpQueryResponse = Vec; /// One query match result: a single entity paired with the requested components. @@ -479,9 +479,12 @@ fn parse_some Deserialize<'de>>(value: Option) -> Result>, world: &World) -> BrpResult { - let BrpGetParams { +/// Handles a `world.get_components` request coming from a client. +pub fn process_remote_get_components_request( + In(params): In>, + world: &World, +) -> BrpResult { + let BrpGetComponentsParams { entity, components, strict, @@ -496,12 +499,12 @@ pub fn process_remote_get_request(In(params): In>, world: &World) serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/world/resources/get` request coming from a client. -pub fn process_remote_get_resource_request( +/// Handles a `world.get_resources` request coming from a client. +pub fn process_remote_get_resources_request( In(params): In>, world: &World, ) -> BrpResult { - let BrpGetResourceParams { + let BrpGetResourcesParams { resource: resource_path, } = parse_some(params)?; @@ -531,17 +534,17 @@ pub fn process_remote_get_resource_request( let value = serialized_object.into_values().next().ok_or_else(|| { BrpError::internal(anyhow!("Unexpected format of serialized resource value")) })?; - let response = BrpGetResourceResponse { value }; + let response = BrpGetResourcesResponse { value }; serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/world/components/get+watch` request coming from a client. -pub fn process_remote_get_watching_request( +/// Handles a `world.get_components+watch` request coming from a client. +pub fn process_remote_get_components_watching_request( In(params): In>, world: &World, mut removal_cursors: Local>>, ) -> BrpResult> { - let BrpGetParams { + let BrpGetComponentsParams { entity, components, strict, @@ -611,10 +614,10 @@ pub fn process_remote_get_watching_request( reflect_components_to_response(changed, strict, entity, entity_ref, &type_registry)?; let response = match response { - BrpGetResponse::Lenient { + BrpGetComponentsResponse::Lenient { components, errors: mut errs, - } => BrpGetWatchingResponse::Lenient { + } => BrpGetComponentsWatchingResponse::Lenient { components, removed, errors: { @@ -622,7 +625,7 @@ pub fn process_remote_get_watching_request( errs }, }, - BrpGetResponse::Strict(components) => BrpGetWatchingResponse::Strict { + BrpGetComponentsResponse::Strict(components) => BrpGetComponentsWatchingResponse::Strict { components, removed, }, @@ -633,18 +636,18 @@ pub fn process_remote_get_watching_request( )) } -/// Reflect a list of components on an entity into a [`BrpGetResponse`]. +/// Reflect a list of components on an entity into a [`BrpGetComponentsResponse`]. fn reflect_components_to_response( components: Vec, strict: bool, entity: Entity, entity_ref: EntityRef, type_registry: &TypeRegistry, -) -> BrpResult { +) -> BrpResult { let mut response = if strict { - BrpGetResponse::Strict(Default::default()) + BrpGetComponentsResponse::Strict(Default::default()) } else { - BrpGetResponse::Lenient { + BrpGetComponentsResponse::Lenient { components: Default::default(), errors: Default::default(), } @@ -653,16 +656,16 @@ fn reflect_components_to_response( for component_path in components { match reflect_component(&component_path, entity, entity_ref, type_registry) { Ok(serialized_object) => match response { - BrpGetResponse::Strict(ref mut components) - | BrpGetResponse::Lenient { + BrpGetComponentsResponse::Strict(ref mut components) + | BrpGetComponentsResponse::Lenient { ref mut components, .. } => { components.extend(serialized_object.into_iter()); } }, Err(err) => match response { - BrpGetResponse::Strict(_) => return Err(err), - BrpGetResponse::Lenient { ref mut errors, .. } => { + BrpGetComponentsResponse::Strict(_) => return Err(err), + BrpGetComponentsResponse::Lenient { ref mut errors, .. } => { let err_value = serde_json::to_value(err).map_err(BrpError::internal)?; errors.insert(component_path, err_value); } @@ -703,7 +706,7 @@ fn reflect_component( Ok(serialized_object) } -/// Handles a `bevy/world/query` request coming from a client. +/// Handles a `world.query` request coming from a client. pub fn process_remote_query_request(In(params): In>, world: &mut World) -> BrpResult { let BrpQueryParams { data: BrpQuery { @@ -806,9 +809,12 @@ pub fn process_remote_query_request(In(params): In>, world: &mut W serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/world/spawn` request coming from a client. -pub fn process_remote_spawn_request(In(params): In>, world: &mut World) -> BrpResult { - let BrpSpawnParams { components } = parse_some(params)?; +/// Handles a `world.spawn_entity` request coming from a client. +pub fn process_remote_spawn_entity_request( + In(params): In>, + world: &mut World, +) -> BrpResult { + let BrpSpawnEntityParams { components } = parse_some(params)?; let app_type_registry = world.resource::().clone(); let type_registry = app_type_registry.read(); @@ -821,7 +827,7 @@ pub fn process_remote_spawn_request(In(params): In>, world: &mut W insert_reflected_components(&type_registry, entity, reflect_components) .map_err(BrpError::component_error)?; - let response = BrpSpawnResponse { entity: entity_id }; + let response = BrpSpawnEntityResponse { entity: entity_id }; serde_json::to_value(response).map_err(BrpError::internal) } @@ -863,12 +869,12 @@ pub fn process_remote_list_methods_request( serde_json::to_value(doc).map_err(BrpError::internal) } -/// Handles a `bevy/world/components/insert` request (insert components) coming from a client. -pub fn process_remote_insert_request( +/// Handles a `world.insert_components` request (insert components) coming from a client. +pub fn process_remote_insert_components_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpInsertParams { entity, components } = parse_some(params)?; + let BrpInsertComponentsParams { entity, components } = parse_some(params)?; let app_type_registry = world.resource::().clone(); let type_registry = app_type_registry.read(); @@ -886,12 +892,12 @@ pub fn process_remote_insert_request( Ok(Value::Null) } -/// Handles a `bevy/world/resources/insert` request coming from a client. -pub fn process_remote_insert_resource_request( +/// Handles a `world.insert_resources` request coming from a client. +pub fn process_remote_insert_resources_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpInsertResourceParams { + let BrpInsertResourcesParams { resource: resource_path, value, } = parse_some(params)?; @@ -909,15 +915,15 @@ pub fn process_remote_insert_resource_request( Ok(Value::Null) } -/// Handles a `bevy/world/components/mutate` request coming from a client. +/// Handles a `world.mutate_components` request coming from a client. /// /// This method allows you to mutate a single field inside an Entity's /// component. -pub fn process_remote_mutate_component_request( +pub fn process_remote_mutate_components_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpMutateComponentParams { + let BrpMutateComponentsParams { entity, component, path, @@ -973,12 +979,12 @@ pub fn process_remote_mutate_component_request( Ok(Value::Null) } -/// Handles a `bevy/world/resources/mutate` request coming from a client. -pub fn process_remote_mutate_resource_request( +/// Handles a `world.mutate_resources` request coming from a client. +pub fn process_remote_mutate_resources_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpMutateResourceParams { + let BrpMutateResourcesParams { resource: resource_path, path: field_path, value, @@ -1024,12 +1030,12 @@ pub fn process_remote_mutate_resource_request( Ok(Value::Null) } -/// Handles a `bevy/world/components/remove` request (remove components) coming from a client. -pub fn process_remote_remove_request( +/// Handles a `world.remove_components` request (remove components) coming from a client. +pub fn process_remote_remove_components_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpRemoveParams { entity, components } = parse_some(params)?; + let BrpRemoveComponentsParams { entity, components } = parse_some(params)?; let app_type_registry = world.resource::().clone(); let type_registry = app_type_registry.read(); @@ -1053,12 +1059,12 @@ pub fn process_remote_remove_request( Ok(Value::Null) } -/// Handles a `bevy/world/resources/remove` request coming from a client. -pub fn process_remote_remove_resource_request( +/// Handles a `world.remove_resources` request coming from a client. +pub fn process_remote_remove_resources_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpRemoveResourceParams { + let BrpRemoveResourcesParams { resource: resource_path, } = parse_some(params)?; @@ -1072,24 +1078,24 @@ pub fn process_remote_remove_resource_request( Ok(Value::Null) } -/// Handles a `bevy/world/despawn` (despawn entity) request coming from a client. -pub fn process_remote_despawn_request( +/// Handles a `world.despawn_entity` (despawn entity) request coming from a client. +pub fn process_remote_despawn_entity_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpDestroyParams { entity } = parse_some(params)?; + let BrpDespawnEntityParams { entity } = parse_some(params)?; get_entity_mut(world, entity)?.despawn(); Ok(Value::Null) } -/// Handles a `bevy/world/reparent` request coming from a client. -pub fn process_remote_reparent_request( +/// Handles a `world.reparent_entity` request coming from a client. +pub fn process_remote_reparent_entity_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpReparentParams { + let BrpReparentEntityParams { entities, parent: maybe_parent, } = parse_some(params)?; @@ -1115,15 +1121,18 @@ pub fn process_remote_reparent_request( Ok(Value::Null) } -/// Handles a `bevy/world/components/list` request (list all components) coming from a client. -pub fn process_remote_list_request(In(params): In>, world: &World) -> BrpResult { +/// Handles a `world.list_components` request (list all components) coming from a client. +pub fn process_remote_list_components_request( + In(params): In>, + world: &World, +) -> BrpResult { let app_type_registry = world.resource::(); let type_registry = app_type_registry.read(); - let mut response = BrpListResponse::default(); + let mut response = BrpListComponentsResponse::default(); // If `Some`, return all components of the provided entity. - if let Some(BrpListParams { entity }) = params.map(parse).transpose()? { + if let Some(BrpListComponentsParams { entity }) = params.map(parse).transpose()? { let entity = get_entity(world, entity)?; for component_id in entity.archetype().components() { let Some(component_info) = world.components().get_info(component_id) else { @@ -1148,7 +1157,7 @@ pub fn process_remote_list_request(In(params): In>, world: &World) serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/world/resources/list` request coming from a client. +/// Handles a `world.list_resources` request coming from a client. pub fn process_remote_list_resources_request( In(_params): In>, world: &World, @@ -1169,15 +1178,15 @@ pub fn process_remote_list_resources_request( serde_json::to_value(response).map_err(BrpError::internal) } -/// Handles a `bevy/world/components/list+watch` request coming from a client. -pub fn process_remote_list_watching_request( +/// Handles a `world.list_components+watch` request coming from a client. +pub fn process_remote_list_components_watching_request( In(params): In>, world: &World, mut removal_cursors: Local>>, ) -> BrpResult> { - let BrpListParams { entity } = parse_some(params)?; + let BrpListComponentsParams { entity } = parse_some(params)?; let entity_ref = get_entity(world, entity)?; - let mut response = BrpListWatchingResponse::default(); + let mut response = BrpListComponentsWatchingResponse::default(); for component_id in entity_ref.archetype().components() { let ticks = entity_ref @@ -1215,7 +1224,7 @@ pub fn process_remote_list_watching_request( } } -/// Handles a `bevy/registry/schema` request (list all registry types in form of schema) coming from a client. +/// Handles a `registry.schema` request (list all registry types in form of schema) coming from a client. pub fn export_registry_types(In(params): In>, world: &World) -> BrpResult { let filter: BrpJsonSchemaQueryFilter = match params { None => Default::default(), @@ -1534,7 +1543,7 @@ mod tests { entity: Entity::from_raw_u32(0).unwrap(), has: Default::default(), }); - test_serialize_deserialize(BrpListWatchingResponse::default()); + test_serialize_deserialize(BrpListComponentsWatchingResponse::default()); test_serialize_deserialize(BrpQuery::default()); test_serialize_deserialize(BrpJsonSchemaQueryFilter::default()); test_serialize_deserialize(BrpJsonSchemaQueryFilter { @@ -1544,7 +1553,7 @@ mod tests { }, ..Default::default() }); - test_serialize_deserialize(BrpListParams { + test_serialize_deserialize(BrpListComponentsParams { entity: Entity::from_raw_u32(0).unwrap(), }); } diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index 0625ad6301..a502383bec 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -14,7 +14,7 @@ //! //! ```json //! { -//! "method": "bevy/world/components/get", +//! "method": world.get_components", //! "id": 0, //! "params": { //! "entity": 4294967298, @@ -35,7 +35,7 @@ //! response. //! //! * `method` is a string that specifies one of the possible [`BrpRequest`] -//! variants: `bevy/world/query`, `bevy/world/components/get`, `bevy/world/components/insert`, etc. It's case-sensitive. +//! variants: `world.query`, `world.get_components`, `world.insert_components`, etc. It's case-sensitive. //! //! * `params` is parameter data specific to the request. //! @@ -99,10 +99,10 @@ //! ## Built-in methods //! //! The Bevy Remote Protocol includes a number of built-in methods for accessing and modifying data -//! in the ECS. Each of these methods uses the `bevy/` prefix, which is a namespace reserved for +//! in the ECS. Each of these methods uses the `` prefix, which is a namespace reserved for //! BRP built-in methods. //! -//! ### `bevy/world/components/get` +//! ### `world.get_components` //! //! Retrieve the values of one or more components from an entity. //! @@ -123,7 +123,7 @@ //! //! `result`: A map associating each type name to its value on the requested entity. //! -//! ### `bevy/world/query` +//! ### `world.query` //! //! Perform a query over components in the ECS, returning all matching entities and their associated //! component values. @@ -155,7 +155,7 @@ //! //! //! -//! ### `bevy/world/spawn` +//! ### `world.spawn_entity` //! //! Create a new entity with the provided components and return the resulting entity ID. //! @@ -165,7 +165,7 @@ //! `result`: //! - `entity`: The ID of the newly spawned entity. //! -//! ### `bevy/world/despawn` +//! ### `world.despawn_entity` //! //! Despawn the entity with the given ID. //! @@ -174,7 +174,7 @@ //! //! `result`: null. //! -//! ### `bevy/world/components/remove` +//! ### `world.remove_components` //! //! Delete one or more components from an entity. //! @@ -184,7 +184,7 @@ //! //! `result`: null. //! -//! ### `bevy/world/components/insert` +//! ### `world.insert_components` //! //! Insert one or more components into an entity. //! @@ -194,7 +194,7 @@ //! //! `result`: null. //! -//! ### `bevy/world/components/mutate` +//! ### `world.mutate_components` //! //! Mutate a field in a component. //! @@ -207,7 +207,7 @@ //! //! `result`: null. //! -//! ### `bevy/world/reparent` +//! ### `world.reparent_entity` //! //! Assign a new parent to one or more entities. //! @@ -218,7 +218,7 @@ //! //! `result`: null. //! -//! ### `bevy/world/components/list` +//! ### `world.list_components` //! //! List all registered components or all components present on an entity. //! @@ -230,7 +230,7 @@ //! //! `result`: An array of fully-qualified type names of components. //! -//! ### `bevy/world/components/get+watch` +//! ### `world.get_components+watch` //! //! Watch the values of one or more components from an entity. //! @@ -258,7 +258,7 @@ //! - `removed`: An array of fully-qualified type names of components removed from the entity //! in the last tick. //! -//! ### `bevy/world/components/list+watch` +//! ### `world.list_components+watch` //! //! Watch all components present on an entity. //! @@ -274,7 +274,7 @@ //! - `removed`: An array of fully-qualified type names of components removed from the entity //! in the last tick. //! -//! ### `bevy/world/resources/get` +//! ### `world.get_resources` //! //! Extract the value of a given resource from the world. //! @@ -284,7 +284,7 @@ //! `result`: //! - `value`: The value of the resource in the world. //! -//! ### `bevy/world/resources/insert` +//! ### `world.insert_resources` //! //! Insert the given resource into the world with the given value. //! @@ -294,7 +294,7 @@ //! //! `result`: null. //! -//! ### `bevy/world/resources/remove` +//! ### `world.remove_resources` //! //! Remove the given resource from the world. //! @@ -303,7 +303,7 @@ //! //! `result`: null. //! -//! ### `bevy/world/resources/mutate` +//! ### `world.mutate_resources` //! //! Mutate a field in a resource. //! @@ -315,7 +315,7 @@ //! //! `result`: null. //! -//! ### `bevy/world/resources/list` +//! ### `world.list_resources` //! //! List all reflectable registered resource types. This method has no parameters. //! @@ -440,68 +440,68 @@ impl Default for RemotePlugin { fn default() -> Self { Self::empty() .with_method( - builtin_methods::BRP_GET_METHOD, - builtin_methods::process_remote_get_request, + builtin_methods::BRP_GET_COMPONENTS_METHOD, + builtin_methods::process_remote_get_components_request, ) .with_method( builtin_methods::BRP_QUERY_METHOD, builtin_methods::process_remote_query_request, ) .with_method( - builtin_methods::BRP_SPAWN_METHOD, - builtin_methods::process_remote_spawn_request, + builtin_methods::BRP_SPAWN_ENTITY_METHOD, + builtin_methods::process_remote_spawn_entity_request, ) .with_method( - builtin_methods::BRP_INSERT_METHOD, - builtin_methods::process_remote_insert_request, + builtin_methods::BRP_INSERT_COMPONENTS_METHOD, + builtin_methods::process_remote_insert_components_request, ) .with_method( - builtin_methods::BRP_REMOVE_METHOD, - builtin_methods::process_remote_remove_request, + builtin_methods::BRP_REMOVE_COMPONENTS_METHOD, + builtin_methods::process_remote_remove_components_request, ) .with_method( - builtin_methods::BRP_DESPAWN_METHOD, - builtin_methods::process_remote_despawn_request, + builtin_methods::BRP_DESPAWN_COMPONENTS_METHOD, + builtin_methods::process_remote_despawn_entity_request, ) .with_method( - builtin_methods::BRP_REPARENT_METHOD, - builtin_methods::process_remote_reparent_request, + builtin_methods::BRP_REPARENT_ENTITY_METHOD, + builtin_methods::process_remote_reparent_entity_request, ) .with_method( - builtin_methods::BRP_LIST_METHOD, - builtin_methods::process_remote_list_request, + builtin_methods::BRP_LIST_COMPONENTS_METHOD, + builtin_methods::process_remote_list_components_request, ) .with_method( - builtin_methods::BRP_MUTATE_COMPONENT_METHOD, - builtin_methods::process_remote_mutate_component_request, + builtin_methods::BRP_MUTATE_COMPONENTS_METHOD, + builtin_methods::process_remote_mutate_components_request, ) .with_method( builtin_methods::RPC_DISCOVER_METHOD, builtin_methods::process_remote_list_methods_request, ) .with_watching_method( - builtin_methods::BRP_GET_AND_WATCH_METHOD, - builtin_methods::process_remote_get_watching_request, + builtin_methods::BRP_GET_COMPONENTS_AND_WATCH_METHOD, + builtin_methods::process_remote_get_components_watching_request, ) .with_watching_method( - builtin_methods::BRP_LIST_AND_WATCH_METHOD, - builtin_methods::process_remote_list_watching_request, + builtin_methods::BRP_LIST_COMPONENTS_AND_WATCH_METHOD, + builtin_methods::process_remote_list_components_watching_request, ) .with_method( builtin_methods::BRP_GET_RESOURCE_METHOD, - builtin_methods::process_remote_get_resource_request, + builtin_methods::process_remote_get_resources_request, ) .with_method( builtin_methods::BRP_INSERT_RESOURCE_METHOD, - builtin_methods::process_remote_insert_resource_request, + builtin_methods::process_remote_insert_resources_request, ) .with_method( builtin_methods::BRP_REMOVE_RESOURCE_METHOD, - builtin_methods::process_remote_remove_resource_request, + builtin_methods::process_remote_remove_resources_request, ) .with_method( builtin_methods::BRP_MUTATE_RESOURCE_METHOD, - builtin_methods::process_remote_mutate_resource_request, + builtin_methods::process_remote_mutate_resources_request, ) .with_method( builtin_methods::BRP_LIST_RESOURCES_METHOD, @@ -585,7 +585,7 @@ pub enum RemoteMethodHandler { Watching(Box>, Out = BrpResult>>>), } -/// The [`SystemId`] of a function that implements a remote instant method (`bevy/world/components/get`, `bevy/world/query`, etc.) +/// The [`SystemId`] of a function that implements a remote instant method (`world.get_components`, `world.query`, etc.) /// /// The first parameter is the JSON value of the `params`. Typically, an /// implementation will deserialize these as the first thing they do. @@ -594,7 +594,7 @@ pub enum RemoteMethodHandler { /// automatically populate the `id` field before sending. pub type RemoteInstantMethodSystemId = SystemId>, BrpResult>; -/// The [`SystemId`] of a function that implements a remote watching method (`bevy/world/components/get+watch`, `bevy/world/components/list+watch`, etc.) +/// The [`SystemId`] of a function that implements a remote watching method (`world.get_components+watch`, `world.list_components+watch`, etc.) /// /// The first parameter is the JSON value of the `params`. Typically, an /// implementation will deserialize these as the first thing they do. @@ -659,7 +659,7 @@ pub struct RemoteWatchingRequests(Vec<(BrpMessage, RemoteWatchingMethodSystemId) /// ```json /// { /// "jsonrpc": "2.0", -/// "method": "bevy/world/components/get", +/// "method": "world.get_components", /// "id": 0, /// "params": { /// "entity": 4294967298, @@ -674,7 +674,7 @@ pub struct RemoteWatchingRequests(Vec<(BrpMessage, RemoteWatchingMethodSystemId) /// ```json /// { /// "jsonrpc": "2.0", -/// "method": "bevy/world/components/list", +/// "method": "world.list_components", /// "id": 0, /// "params": null ///} diff --git a/crates/bevy_remote/src/schemas/open_rpc.rs b/crates/bevy_remote/src/schemas/open_rpc.rs index 27a5c35a1a..d48291286a 100644 --- a/crates/bevy_remote/src/schemas/open_rpc.rs +++ b/crates/bevy_remote/src/schemas/open_rpc.rs @@ -69,7 +69,7 @@ pub struct ServerObject { #[derive(Serialize, Deserialize, Debug, Default)] #[serde(rename_all = "camelCase")] pub struct MethodObject { - /// The method name (e.g., "/bevy/world/components/get") + /// The method name (e.g., "world.get_components") pub name: String, /// An optional short summary of the method. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/release-content/migration-guides/renamed_BRP_methods.md b/release-content/migration-guides/renamed_BRP_methods.md index 6184a87fe3..42799160a3 100644 --- a/release-content/migration-guides/renamed_BRP_methods.md +++ b/release-content/migration-guides/renamed_BRP_methods.md @@ -1,26 +1,27 @@ --- -title: Renamed BRP methods to be more hierarchical +title: Renamed BRP methods pull_requests: [19377] --- -Most Bevy Remote Protocol methods have been renamed to be more hierarchical. +Most Bevy Remote Protocol methods have been renamed to be more explicit. The word `destroy` has also been replaced with `despawn` to match the rest of the engine. -| Old | New | -|------------------------|------------------------------------| -| `bevy/query` | `bevy/world/query` | -| `bevy/spawn` | `bevy/world/spawn` | -| `bevy/destroy` | `bevy/world/despawn` | -| `bevy/reparent` | `bevy/world/reparent` | -| `bevy/get` | `bevy/world/components/get` | -| `bevy/insert` | `bevy/world/components/insert` | -| `bevy/remove` | `bevy/world/components/remove` | -| `bevy/list` | `bevy/world/components/list` | -| `bevy/mutate` | `bevy/world/components/mutate` | -| `bevy/get+watch` | `bevy/world/components/get+watch` | -| `bevy/list+watch` | `bevy/world/components/list+watch` | -| `bevy/get_resource` | `bevy/world/resources/get` | -| `bevy/insert_resource` | `bevy/world/resources/insert` | -| `bevy/remove_resource` | `bevy/world/resources/remove` | -| `bevy/list_resources` | `bevy/world/resources/list` | -| `bevy/mutate_resource` | `bevy/world/resources/mutate` | +| Old | New | +|------------------------|-------------------------------| +| `bevy/query` | `world.query` | +| `bevy/spawn` | `world.spawn_entity` | +| `bevy/destroy` | `world.despawn_entity` | +| `bevy/reparent` | `world.reparent_entity` | +| `bevy/get` | `world.get_components` | +| `bevy/insert` | `world.insert_components` | +| `bevy/remove` | `world.remove_components` | +| `bevy/list` | `world.list_components` | +| `bevy/mutate` | `world.mutate_components` | +| `bevy/get+watch` | `world.get_components+watch` | +| `bevy/list+watch` | `world.list_components+watch` | +| `bevy/get_resource` | `world.get_resources` | +| `bevy/insert_resource` | `world.insert_resources` | +| `bevy/remove_resource` | `world.remove_resources` | +| `bevy/list_resources` | `world.list_resources` | +| `bevy/mutate_resource` | `world.mutate_resources` | +| `registry/schema` | `registry.schema` | From 43d195869f6456d717d7d86df7e6cdf4c9d7515b Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Sat, 7 Jun 2025 11:02:28 -0700 Subject: [PATCH 4/5] Fixed CI issues. --- crates/bevy_remote/src/lib.rs | 3 +-- crates/bevy_remote/src/schemas/open_rpc.rs | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index a502383bec..be38c9f185 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -99,8 +99,7 @@ //! ## Built-in methods //! //! The Bevy Remote Protocol includes a number of built-in methods for accessing and modifying data -//! in the ECS. Each of these methods uses the `` prefix, which is a namespace reserved for -//! BRP built-in methods. +//! in the ECS. //! //! ### `world.get_components` //! diff --git a/crates/bevy_remote/src/schemas/open_rpc.rs b/crates/bevy_remote/src/schemas/open_rpc.rs index d48291286a..9debc15bde 100644 --- a/crates/bevy_remote/src/schemas/open_rpc.rs +++ b/crates/bevy_remote/src/schemas/open_rpc.rs @@ -69,6 +69,10 @@ pub struct ServerObject { #[derive(Serialize, Deserialize, Debug, Default)] #[serde(rename_all = "camelCase")] pub struct MethodObject { + #[expect( + clippy::doc_markdown, + reason = "In this case, we are referring to a string, so using quotes instead of backticks makes sense." + )] /// The method name (e.g., "world.get_components") pub name: String, /// An optional short summary of the method. From 1317c8691ac2827437fe33bbfc046cf4ba4c554c Mon Sep 17 00:00:00 2001 From: AlephCubed Date: Tue, 10 Jun 2025 09:48:32 -0700 Subject: [PATCH 5/5] Rename `reparent_entity` to `reparent_entities`. --- crates/bevy_remote/src/builtin_methods.rs | 14 +++++++------- crates/bevy_remote/src/lib.rs | 6 +++--- .../migration-guides/renamed_BRP_methods.md | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index 8cf386e919..e533045a99 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -49,8 +49,8 @@ pub const BRP_REMOVE_COMPONENTS_METHOD: &str = "world.remove_components"; /// The method path for a `world.despawn_entity` request. pub const BRP_DESPAWN_COMPONENTS_METHOD: &str = "world.despawn_entity"; -/// The method path for a `world.reparent_entity` request. -pub const BRP_REPARENT_ENTITY_METHOD: &str = "world.reparent_entity"; +/// The method path for a `world.reparent_entities` request. +pub const BRP_REPARENT_ENTITIES_METHOD: &str = "world.reparent_entities"; /// The method path for a `world.list_components` request. pub const BRP_LIST_COMPONENTS_METHOD: &str = "world.list_components"; @@ -227,11 +227,11 @@ pub struct BrpInsertResourcesParams { pub value: Value, } -/// `world.reparent_entity`: Assign a new parent to one or more entities. +/// `world.reparent_entities`: Assign a new parent to one or more entities. /// /// The server responds with a null. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] -pub struct BrpReparentEntityParams { +pub struct BrpReparentEntitiesParams { /// The IDs of the entities that are to become the new children of the /// `parent`. pub entities: Vec, @@ -1090,12 +1090,12 @@ pub fn process_remote_despawn_entity_request( Ok(Value::Null) } -/// Handles a `world.reparent_entity` request coming from a client. -pub fn process_remote_reparent_entity_request( +/// Handles a `world.reparent_entities` request coming from a client. +pub fn process_remote_reparent_entities_request( In(params): In>, world: &mut World, ) -> BrpResult { - let BrpReparentEntityParams { + let BrpReparentEntitiesParams { entities, parent: maybe_parent, } = parse_some(params)?; diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index be38c9f185..7f326581a9 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -206,7 +206,7 @@ //! //! `result`: null. //! -//! ### `world.reparent_entity` +//! ### `world.reparent_entities` //! //! Assign a new parent to one or more entities. //! @@ -463,8 +463,8 @@ impl Default for RemotePlugin { builtin_methods::process_remote_despawn_entity_request, ) .with_method( - builtin_methods::BRP_REPARENT_ENTITY_METHOD, - builtin_methods::process_remote_reparent_entity_request, + builtin_methods::BRP_REPARENT_ENTITIES_METHOD, + builtin_methods::process_remote_reparent_entities_request, ) .with_method( builtin_methods::BRP_LIST_COMPONENTS_METHOD, diff --git a/release-content/migration-guides/renamed_BRP_methods.md b/release-content/migration-guides/renamed_BRP_methods.md index 42799160a3..b0c7fca1f4 100644 --- a/release-content/migration-guides/renamed_BRP_methods.md +++ b/release-content/migration-guides/renamed_BRP_methods.md @@ -11,7 +11,7 @@ The word `destroy` has also been replaced with `despawn` to match the rest of th | `bevy/query` | `world.query` | | `bevy/spawn` | `world.spawn_entity` | | `bevy/destroy` | `world.despawn_entity` | -| `bevy/reparent` | `world.reparent_entity` | +| `bevy/reparent` | `world.reparent_entities` | | `bevy/get` | `world.get_components` | | `bevy/insert` | `world.insert_components` | | `bevy/remove` | `world.remove_components` |