mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 13:15:50 +00:00
Upgrade to rbx_dom_weak 2.0 (#377)
* Mostly mechanical port bits * Almost there * It builds again! * Turn on all the code again * Tests compiling but not passing * Stub work for value resolution * Implement resolution minus enums and derived properties * Implement property descriptor resolution * Update referent snapshots * Update unions test project Using a place file instead of a model yields better error messages in Roblox Studio. * Add easy shortcut to testing with local rbx-dom * Update rbx-dom * Add enum resolution * Update init.meta.json to use UnresolvedValue * Expand value resolution support, add test * Filter SharedString values from web API * Add 'property' builder method to InstanceSnapshot * Change InstanceSnapshot/InstanceBuilder boundary * Fix remove_file crash * rustfmt * Update to latest rbx_dom_lua * Update dependencies, including rbx_dom_weak * Update to latest rbx-dom * Update dependencies * Update rbx-dom, fixing more bugs * Remove experimental warning on binary place builds * Remove unused imports
This commit is contained in:
committed by
GitHub
parent
b84aab0960
commit
59ef5f05ea
@@ -5,7 +5,7 @@ use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
};
|
||||
|
||||
use rbx_dom_weak::{RbxId, RbxValue};
|
||||
use rbx_dom_weak::types::{Ref, Variant};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
@@ -23,22 +23,22 @@ pub const PROTOCOL_VERSION: u64 = 3;
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SubscribeMessage<'a> {
|
||||
pub removed: Vec<RbxId>,
|
||||
pub added: HashMap<RbxId, Instance<'a>>,
|
||||
pub removed: Vec<Ref>,
|
||||
pub added: HashMap<Ref, Instance<'a>>,
|
||||
pub updated: Vec<InstanceUpdate>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct InstanceUpdate {
|
||||
pub id: RbxId,
|
||||
pub id: Ref,
|
||||
pub changed_name: Option<String>,
|
||||
pub changed_class_name: Option<String>,
|
||||
|
||||
// TODO: Transform from HashMap<String, Option<_>> to something else, since
|
||||
// null will get lost when decoding from JSON in some languages.
|
||||
#[serde(default)]
|
||||
pub changed_properties: HashMap<String, Option<RbxValue>>,
|
||||
pub changed_properties: HashMap<String, Option<Variant>>,
|
||||
pub changed_metadata: Option<InstanceMetadata>,
|
||||
}
|
||||
|
||||
@@ -59,23 +59,36 @@ impl InstanceMetadata {
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct Instance<'a> {
|
||||
pub id: RbxId,
|
||||
pub parent: Option<RbxId>,
|
||||
pub id: Ref,
|
||||
pub parent: Ref,
|
||||
pub name: Cow<'a, str>,
|
||||
pub class_name: Cow<'a, str>,
|
||||
pub properties: Cow<'a, HashMap<String, RbxValue>>,
|
||||
pub children: Cow<'a, [RbxId]>,
|
||||
pub properties: HashMap<String, Cow<'a, Variant>>,
|
||||
pub children: Cow<'a, [Ref]>,
|
||||
pub metadata: Option<InstanceMetadata>,
|
||||
}
|
||||
|
||||
impl<'a> Instance<'a> {
|
||||
pub(crate) fn from_rojo_instance(source: InstanceWithMeta<'_>) -> Instance<'_> {
|
||||
let properties = source
|
||||
.properties()
|
||||
.iter()
|
||||
.filter_map(|(key, value)| {
|
||||
// SharedString values can't be serialized via Serde
|
||||
if matches!(value, Variant::SharedString(_)) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some((key.clone(), Cow::Borrowed(value)))
|
||||
})
|
||||
.collect();
|
||||
|
||||
Instance {
|
||||
id: source.id(),
|
||||
parent: source.parent(),
|
||||
name: Cow::Borrowed(source.name()),
|
||||
class_name: Cow::Borrowed(source.class_name()),
|
||||
properties: Cow::Borrowed(source.properties()),
|
||||
properties,
|
||||
children: Cow::Borrowed(source.children()),
|
||||
metadata: Some(InstanceMetadata::from_rojo_metadata(source.metadata())),
|
||||
}
|
||||
@@ -91,7 +104,7 @@ pub struct ServerInfoResponse {
|
||||
pub protocol_version: u64,
|
||||
pub project_name: String,
|
||||
pub expected_place_ids: Option<HashSet<u64>>,
|
||||
pub root_instance_id: RbxId,
|
||||
pub root_instance_id: Ref,
|
||||
}
|
||||
|
||||
/// Response body from /api/read/{id}
|
||||
@@ -100,17 +113,17 @@ pub struct ServerInfoResponse {
|
||||
pub struct ReadResponse<'a> {
|
||||
pub session_id: SessionId,
|
||||
pub message_cursor: u32,
|
||||
pub instances: HashMap<RbxId, Instance<'a>>,
|
||||
pub instances: HashMap<Ref, Instance<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WriteRequest {
|
||||
pub session_id: SessionId,
|
||||
pub removed: Vec<RbxId>,
|
||||
pub removed: Vec<Ref>,
|
||||
|
||||
#[serde(default)]
|
||||
pub added: HashMap<RbxId, ()>,
|
||||
pub added: HashMap<Ref, ()>,
|
||||
pub updated: Vec<InstanceUpdate>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user