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
[submodule "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
/// 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);
if descriptor.is_some() {
// We can only use an ambiguous syntax if the property is known
// to the reflection database.
Self::Ambiguous(match variant {
Some(Self::Ambiguous(match variant {
Variant::Enum(rbx_enum) => {
if let Some(property) = descriptor {
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) {
for (variant_name, id) in &enum_descriptor.items {
if *id == rbx_enum.to_u32() {
return Self::Ambiguous(AmbiguousValue::String(
return Some(Self::Ambiguous(AmbiguousValue::String(
variant_name.to_string(),
));
)));
}
}
}
}
}
return Self::FullyQualified(variant);
return Some(Self::FullyQualified(variant));
}
Variant::Bool(bool) => AmbiguousValue::Bool(bool),
Variant::Float32(n) => AmbiguousValue::Number(n as f64),
@ -75,7 +77,7 @@ impl UnresolvedValue {
Variant::Content(ref content) => match content.value() {
ContentType::None => AmbiguousValue::String(String::new()),
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::Vector2(vector) => {
@ -87,32 +89,40 @@ impl UnresolvedValue {
Variant::Color3(color) => {
AmbiguousValue::Array3([color.r as f64, color.g as f64, color.b as f64])
}
Variant::CFrame(cf) => 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,
]),
Variant::CFrame(cf) => Self::cframe_to_array12(cf),
Variant::OptionalCFrame(maybe_cf) => match maybe_cf {
Some(cf) => Self::cframe_to_array12(cf),
None => return None,
},
Variant::Attributes(attr) => AmbiguousValue::Attributes(attr),
Variant::Font(font) => AmbiguousValue::Font(font),
Variant::MaterialColors(colors) => AmbiguousValue::MaterialColors(colors),
_ => {
return Self::FullyQualified(variant);
return Some(Self::FullyQualified(variant));
}
})
}))
} 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
/// values if they're able to be resolved in a context-free environment.
pub fn from_variant_unambiguous(variant: Variant) -> Self {

View file

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

View file

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

View file

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