diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ca7b58..7517d5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added support for `CFrame` and `Font` types in attributes when using the `roblox` builtin. + ### Fixed -- Fixed `roblox.serializeModel` still keeping some unique ids +- Fixed `roblox.serializeModel` still keeping some unique ids. ## `0.7.3` - July 5th, 2023 diff --git a/Cargo.lock b/Cargo.lock index 7998320..ed5d36d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1535,7 +1535,7 @@ dependencies = [ [[package]] name = "rbx_binary" version = "0.7.0" -source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e" +source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de" dependencies = [ "log", "lz4", @@ -1566,7 +1566,7 @@ dependencies = [ [[package]] name = "rbx_dom_weak" version = "2.4.0" -source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e" +source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de" dependencies = [ "rbx_types", "serde", @@ -1575,7 +1575,7 @@ dependencies = [ [[package]] name = "rbx_reflection" version = "4.2.0" -source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e" +source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de" dependencies = [ "rbx_types", "serde", @@ -1585,7 +1585,7 @@ dependencies = [ [[package]] name = "rbx_reflection_database" version = "0.2.6+roblox-572" -source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e" +source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de" dependencies = [ "lazy_static", "rbx_reflection", @@ -1596,7 +1596,7 @@ dependencies = [ [[package]] name = "rbx_types" version = "1.5.0" -source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e" +source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de" dependencies = [ "base64 0.13.1", "bitflags 1.3.2", @@ -1610,7 +1610,7 @@ dependencies = [ [[package]] name = "rbx_xml" version = "0.13.0" -source = "git+https://github.com/rojo-rbx/rbx-dom?rev=2e78feb05e033cbca8db1d9e490f8334c096d13e#2e78feb05e033cbca8db1d9e490f8334c096d13e" +source = "git+https://github.com/rojo-rbx/rbx-dom?rev=b6d255e0b5d96155f694ca224676b251059cf2de#b6d255e0b5d96155f694ca224676b251059cf2de" dependencies = [ "base64 0.13.1", "log", diff --git a/packages/lib-roblox/Cargo.toml b/packages/lib-roblox/Cargo.toml index 9c3cdf5..d221c66 100644 --- a/packages/lib-roblox/Cargo.toml +++ b/packages/lib-roblox/Cargo.toml @@ -22,11 +22,11 @@ thiserror.workspace = true glam = "0.24" rand = "0.8" -rbx_binary = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" } -rbx_dom_weak = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" } -rbx_reflection = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" } -rbx_reflection_database = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" } -rbx_xml = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "2e78feb05e033cbca8db1d9e490f8334c096d13e" } +rbx_binary = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" } +rbx_dom_weak = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" } +rbx_reflection = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" } +rbx_reflection_database = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" } +rbx_xml = { git = "https://github.com/rojo-rbx/rbx-dom", rev = "b6d255e0b5d96155f694ca224676b251059cf2de" } [dev-dependencies] anyhow = "1.0" diff --git a/packages/lib-roblox/src/datatypes/attributes.rs b/packages/lib-roblox/src/datatypes/attributes.rs index a23d155..d827801 100644 --- a/packages/lib-roblox/src/datatypes/attributes.rs +++ b/packages/lib-roblox/src/datatypes/attributes.rs @@ -24,16 +24,16 @@ pub fn ensure_valid_attribute_name(name: impl AsRef) -> LuaResult<()> { } pub fn ensure_valid_attribute_value(value: &DomValue) -> LuaResult<()> { - // TODO: Uncomment supported types when they are also supported in rbx-dom serialization let is_valid = matches!( value.ty(), DomType::Bool | DomType::BrickColor - // | DomType::CFrame + | DomType::CFrame | DomType::Color3 | DomType::ColorSequence | DomType::Float32 | DomType::Float64 + | DomType::Font | DomType::Int32 | DomType::Int64 | DomType::NumberRange @@ -43,7 +43,7 @@ pub fn ensure_valid_attribute_value(value: &DomValue) -> LuaResult<()> { | DomType::UDim | DomType::UDim2 | DomType::Vector2 - | DomType::Vector3 // | DomType::Font + | DomType::Vector3 ); if is_valid { Ok(()) diff --git a/tests/roblox/instance/attributes.luau b/tests/roblox/instance/attributes.luau index 716e1ae..a75ac87 100644 --- a/tests/roblox/instance/attributes.luau +++ b/tests/roblox/instance/attributes.luau @@ -2,9 +2,11 @@ local fs = require("@lune/fs") local roblox = require("@lune/roblox") :: any local BrickColor = roblox.BrickColor +local CFrame = roblox.CFrame local Color3 = roblox.Color3 local ColorSequence = roblox.ColorSequence local ColorSequenceKeypoint = roblox.ColorSequenceKeypoint +local Font = roblox.Font local NumberRange = roblox.NumberRange local NumberSequence = roblox.NumberSequence local NumberSequenceKeypoint = roblox.NumberSequenceKeypoint @@ -19,6 +21,8 @@ local modelFile = fs.readFile("tests/roblox/rbx-test-files/models/attributes/bin local model = roblox.deserializeModel(modelFile)[1] model:SetAttribute("Foo", "Bar") +model:SetAttribute("CFrame", CFrame.identity) +model:SetAttribute("Font", Font.new("Arial")) local ATTRS_ACTUAL = model:GetAttributes() local ATTRS_EXPECTED: { [string]: any } = { @@ -48,6 +52,8 @@ local ATTRS_EXPECTED: { [string]: any } = { NaN = 0 / 0, -- Extras we set Foo = "Bar", + CFrame = CFrame.identity, + Font = Font.new("Arial"), } for name, value in ATTRS_EXPECTED do