Update .gitmodules for rbx-dom URL and enhance UnresolvedValue handling

- Changed the rbx-dom submodule URL in .gitmodules from SSH to HTTPS for easier access.
- Introduced a new method to handle OptionalCFrame variants in UnresolvedValue, allowing for better serialization by returning `None` for `OptionalCFrame(None)`.
- Updated various files to utilize the new handling logic, ensuring properties are only inserted when resolved values are available.
This commit is contained in:
Joe 2026-01-21 16:07:24 -06:00
parent 4ccef46540
commit 69774fd546
6 changed files with 55 additions and 40 deletions

2
.gitmodules vendored
View file

@ -18,4 +18,4 @@
url = https://github.com/boatbomber/highlighter.git url = https://github.com/boatbomber/highlighter.git
[submodule "rbx-dom"] [submodule "rbx-dom"]
path = rbx-dom path = rbx-dom
url = git@github.com:UserGeneratedLLC/rbx-dom.git url = https://github.com/UserGeneratedLLC/rbx-dom.git

1
rbx-dom Submodule

@ -0,0 +1 @@
Subproject commit 7ef7d448ba6d30c4cb217b228d5c22c6f5ac07f3

View file

@ -40,12 +40,14 @@ impl UnresolvedValue {
/// Creates an `UnresolvedValue` from a variant, using a class and property /// Creates an `UnresolvedValue` from a variant, using a class and property
/// name to potentially allow for ambiguous Enum variants. /// name to potentially allow for ambiguous Enum variants.
pub fn from_variant(variant: Variant, class_name: &str, prop_name: &str) -> Self { ///
/// Returns `None` for variants that should not be serialized (e.g., `OptionalCFrame(None)`).
pub fn from_variant(variant: Variant, class_name: &str, prop_name: &str) -> Option<Self> {
let descriptor = find_descriptor(class_name, prop_name); let descriptor = find_descriptor(class_name, prop_name);
if descriptor.is_some() { if descriptor.is_some() {
// We can only use an ambiguous syntax if the property is known // We can only use an ambiguous syntax if the property is known
// to the reflection database. // to the reflection database.
Self::Ambiguous(match variant { Some(Self::Ambiguous(match variant {
Variant::Enum(rbx_enum) => { Variant::Enum(rbx_enum) => {
if let Some(property) = descriptor { if let Some(property) = descriptor {
if let DataType::Enum(enum_name) = &property.data_type { if let DataType::Enum(enum_name) = &property.data_type {
@ -53,15 +55,15 @@ impl UnresolvedValue {
if let Some(enum_descriptor) = database.enums.get(enum_name) { if let Some(enum_descriptor) = database.enums.get(enum_name) {
for (variant_name, id) in &enum_descriptor.items { for (variant_name, id) in &enum_descriptor.items {
if *id == rbx_enum.to_u32() { if *id == rbx_enum.to_u32() {
return Self::Ambiguous(AmbiguousValue::String( return Some(Self::Ambiguous(AmbiguousValue::String(
variant_name.to_string(), variant_name.to_string(),
)); )));
} }
} }
} }
} }
} }
return Self::FullyQualified(variant); return Some(Self::FullyQualified(variant));
} }
Variant::Bool(bool) => AmbiguousValue::Bool(bool), Variant::Bool(bool) => AmbiguousValue::Bool(bool),
Variant::Float32(n) => AmbiguousValue::Number(n as f64), Variant::Float32(n) => AmbiguousValue::Number(n as f64),
@ -75,7 +77,7 @@ impl UnresolvedValue {
Variant::Content(ref content) => match content.value() { Variant::Content(ref content) => match content.value() {
ContentType::None => AmbiguousValue::String(String::new()), ContentType::None => AmbiguousValue::String(String::new()),
ContentType::Uri(uri) => AmbiguousValue::String(uri.clone()), ContentType::Uri(uri) => AmbiguousValue::String(uri.clone()),
_ => return Self::FullyQualified(variant), _ => return Some(Self::FullyQualified(variant)),
}, },
Variant::ContentId(content) => AmbiguousValue::String(content.into_string()), Variant::ContentId(content) => AmbiguousValue::String(content.into_string()),
Variant::Vector2(vector) => { Variant::Vector2(vector) => {
@ -87,32 +89,40 @@ impl UnresolvedValue {
Variant::Color3(color) => { Variant::Color3(color) => {
AmbiguousValue::Array3([color.r as f64, color.g as f64, color.b as f64]) AmbiguousValue::Array3([color.r as f64, color.g as f64, color.b as f64])
} }
Variant::CFrame(cf) => AmbiguousValue::Array12([ Variant::CFrame(cf) => Self::cframe_to_array12(cf),
cf.position.x as f64, Variant::OptionalCFrame(maybe_cf) => match maybe_cf {
cf.position.y as f64, Some(cf) => Self::cframe_to_array12(cf),
cf.position.z as f64, None => return None,
cf.orientation.x.x as f64, },
cf.orientation.x.y as f64,
cf.orientation.x.z as f64,
cf.orientation.y.x as f64,
cf.orientation.y.y as f64,
cf.orientation.y.z as f64,
cf.orientation.z.x as f64,
cf.orientation.z.y as f64,
cf.orientation.z.z as f64,
]),
Variant::Attributes(attr) => AmbiguousValue::Attributes(attr), Variant::Attributes(attr) => AmbiguousValue::Attributes(attr),
Variant::Font(font) => AmbiguousValue::Font(font), Variant::Font(font) => AmbiguousValue::Font(font),
Variant::MaterialColors(colors) => AmbiguousValue::MaterialColors(colors), Variant::MaterialColors(colors) => AmbiguousValue::MaterialColors(colors),
_ => { _ => {
return Self::FullyQualified(variant); return Some(Self::FullyQualified(variant));
} }
}) }))
} else { } else {
Self::FullyQualified(variant) Some(Self::FullyQualified(variant))
} }
} }
fn cframe_to_array12(cf: CFrame) -> AmbiguousValue {
AmbiguousValue::Array12([
cf.position.x as f64,
cf.position.y as f64,
cf.position.z as f64,
cf.orientation.x.x as f64,
cf.orientation.x.y as f64,
cf.orientation.x.z as f64,
cf.orientation.y.x as f64,
cf.orientation.y.y as f64,
cf.orientation.y.z as f64,
cf.orientation.z.x as f64,
cf.orientation.z.y as f64,
cf.orientation.z.z as f64,
])
}
/// Creates an `UnresolvedValue` from a variant, only returning ambiguous /// Creates an `UnresolvedValue` from a variant, only returning ambiguous
/// values if they're able to be resolved in a context-free environment. /// values if they're able to be resolved in a context-free environment.
pub fn from_variant_unambiguous(variant: Variant) -> Self { pub fn from_variant_unambiguous(variant: Variant) -> Self {

View file

@ -123,10 +123,11 @@ fn json_model_from_pair<'sync>(
} }
} }
_ => { _ => {
properties.insert( if let Some(resolved) =
name, UnresolvedValue::from_variant(value.clone(), &new_inst.class, &name)
UnresolvedValue::from_variant(value.clone(), &new_inst.class, &name), {
); properties.insert(name, resolved);
}
} }
} }
} }

View file

@ -147,10 +147,11 @@ impl AdjacentMetadata {
} }
} }
_ => { _ => {
properties.insert( if let Some(resolved) =
name, UnresolvedValue::from_variant(value.clone(), class, &name)
UnresolvedValue::from_variant(value.clone(), class, &name), {
); properties.insert(name, resolved);
}
} }
} }
} }
@ -375,10 +376,11 @@ impl DirectoryMetadata {
} }
} }
_ => { _ => {
properties.insert( if let Some(resolved) =
name, UnresolvedValue::from_variant(value.clone(), class, &name)
UnresolvedValue::from_variant(value.clone(), class, &name), {
); properties.insert(name, resolved);
}
} }
} }
} }

View file

@ -573,10 +573,11 @@ fn project_node_property_syncback(
} }
} }
_ => { _ => {
properties.insert( if let Some(resolved) =
name, UnresolvedValue::from_variant(value.clone(), &new_inst.class, &name)
UnresolvedValue::from_variant(value.clone(), &new_inst.class, &name), {
); properties.insert(name, resolved);
}
} }
} }
} }