diff --git a/Cargo.lock b/Cargo.lock index 5bc12bed..b44f555e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,19 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "getrandom 0.2.15", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -2229,9 +2242,9 @@ dependencies = [ [[package]] name = "rbx_binary" version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b85057e8ff75a1ce99248200c4b3c7b481a3d52f921f1053ecd67921dcc7930" +source = "git+https://github.com/rojo-rbx/rbx-dom/#28b2fae0ed3c34728d11ccca5172584f1d9c778e" dependencies = [ + "ahash", "log", "lz4", "profiling", @@ -2239,6 +2252,7 @@ dependencies = [ "rbx_reflection", "rbx_reflection_database", "thiserror", + "zstd", ] [[package]] @@ -2259,18 +2273,18 @@ dependencies = [ [[package]] name = "rbx_dom_weak" version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcd2a17d09e46af0805f8b311a926402172b97e8d9388745c9adf8f448901841" +source = "git+https://github.com/rojo-rbx/rbx-dom/#28b2fae0ed3c34728d11ccca5172584f1d9c778e" dependencies = [ + "ahash", "rbx_types", "serde", + "ustr", ] [[package]] name = "rbx_reflection" version = "4.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8118ac6021d700e8debe324af6b40ecfd2cef270a00247849dbdfeebb0802677" +source = "git+https://github.com/rojo-rbx/rbx-dom/#28b2fae0ed3c34728d11ccca5172584f1d9c778e" dependencies = [ "rbx_types", "serde", @@ -2280,8 +2294,7 @@ dependencies = [ [[package]] name = "rbx_reflection_database" version = "0.2.12+roblox-638" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e29381d675420e841f8c02db5755cbb2545ed3e13f56c539546dc58702b512a" +source = "git+https://github.com/rojo-rbx/rbx-dom/#28b2fae0ed3c34728d11ccca5172584f1d9c778e" dependencies = [ "lazy_static", "rbx_reflection", @@ -2292,8 +2305,7 @@ dependencies = [ [[package]] name = "rbx_types" version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30f49b2a3bb667e4074ba73c2dfb8ca0873f610b448ccf318a240acfdec6c73" +source = "git+https://github.com/rojo-rbx/rbx-dom/#28b2fae0ed3c34728d11ccca5172584f1d9c778e" dependencies = [ "base64 0.13.1", "bitflags 1.3.2", @@ -2307,9 +2319,9 @@ dependencies = [ [[package]] name = "rbx_xml" version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b14b3027bc9ccd82e2fc854c8bcd25ed58318e570c355bf2cf63df9cdbd5ba8" +source = "git+https://github.com/rojo-rbx/rbx-dom/#28b2fae0ed3c34728d11ccca5172584f1d9c778e" dependencies = [ + "ahash", "base64 0.13.1", "log", "rbx_dom_weak", @@ -3442,6 +3454,19 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "ustr" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18b19e258aa08450f93369cf56dd78063586adf19e92a75b338a800f799a0208" +dependencies = [ + "ahash", + "byteorder 1.5.0", + "lazy_static", + "parking_lot", + "serde", +] + [[package]] name = "utf-8" version = "0.7.6" diff --git a/crates/lune-roblox/Cargo.toml b/crates/lune-roblox/Cargo.toml index 73ca05a0..bd781f67 100644 --- a/crates/lune-roblox/Cargo.toml +++ b/crates/lune-roblox/Cargo.toml @@ -20,10 +20,10 @@ rand = "0.8" thiserror = "1.0" once_cell = "1.17" -rbx_binary = "0.7.7" -rbx_dom_weak = "2.9.0" -rbx_reflection = "4.7.0" -rbx_reflection_database = "0.2.12" -rbx_xml = "0.13.5" +rbx_binary = { version = "0.7.7", git = "https://github.com/rojo-rbx/rbx-dom/" } +rbx_dom_weak = { version = "2.9.0", git = "https://github.com/rojo-rbx/rbx-dom/" } +rbx_reflection = { version = "4.7.0", git = "https://github.com/rojo-rbx/rbx-dom/" } +rbx_reflection_database = { version = "0.2.12", git = "https://github.com/rojo-rbx/rbx-dom/" } +rbx_xml = { version = "0.13.5", git = "https://github.com/rojo-rbx/rbx-dom/" } lune-utils = { version = "0.1.3", path = "../lune-utils" } diff --git a/crates/lune-roblox/src/document/kind.rs b/crates/lune-roblox/src/document/kind.rs index eee19bad..2ef637d6 100644 --- a/crates/lune-roblox/src/document/kind.rs +++ b/crates/lune-roblox/src/document/kind.rs @@ -65,7 +65,7 @@ impl DocumentKind { for child_ref in dom.root().children() { if let Some(child_inst) = dom.get_by_ref(*child_ref) { has_top_level_child = true; - if class_is_a_service(&child_inst.class).unwrap_or(false) { + if class_is_a_service(child_inst.class).unwrap_or(false) { has_top_level_service = true; break; } diff --git a/crates/lune-roblox/src/document/postprocessing.rs b/crates/lune-roblox/src/document/postprocessing.rs index 69481f5d..64bc0bb0 100644 --- a/crates/lune-roblox/src/document/postprocessing.rs +++ b/crates/lune-roblox/src/document/postprocessing.rs @@ -18,8 +18,8 @@ pub fn postprocess_dom_for_model(dom: &mut WeakDom) { remove_matching_prop(inst, DomType::UniqueId, "HistoryId"); // Similar story with ScriptGuid - this is used // in the studio-only cloud script drafts feature - if class_is_a(&inst.class, "LuaSourceContainer").unwrap_or(false) { - inst.properties.remove("ScriptGuid"); + if class_is_a(inst.class, "LuaSourceContainer").unwrap_or(false) { + inst.properties.remove(&"ScriptGuid".into()); } }); } @@ -41,7 +41,11 @@ where } fn remove_matching_prop(inst: &mut DomInstance, ty: DomType, name: &'static str) { - if inst.properties.get(name).map_or(false, |u| u.ty() == ty) { - inst.properties.remove(name); + if inst + .properties + .get(&name.into()) + .map_or(false, |u| u.ty() == ty) + { + inst.properties.remove(&name.into()); } } diff --git a/crates/lune-roblox/src/instance/base.rs b/crates/lune-roblox/src/instance/base.rs index 58a2ae78..ad44d2af 100644 --- a/crates/lune-roblox/src/instance/base.rs +++ b/crates/lune-roblox/src/instance/base.rs @@ -71,7 +71,7 @@ pub fn add_methods<'lua, M: LuaUserDataMethods<'lua, Instance>>(m: &mut M) { "FindFirstAncestorWhichIsA", |lua, this, class_name: String| { ensure_not_destroyed(this)?; - this.find_ancestor(|child| class_is_a(&child.class, &class_name).unwrap_or(false)) + this.find_ancestor(|child| class_is_a(child.class, &class_name).unwrap_or(false)) .into_lua(lua) }, ); @@ -104,7 +104,7 @@ pub fn add_methods<'lua, M: LuaUserDataMethods<'lua, Instance>>(m: &mut M) { |lua, this, (class_name, recursive): (String, Option)| { ensure_not_destroyed(this)?; let predicate = - |child: &DomInstance| class_is_a(&child.class, &class_name).unwrap_or(false); + |child: &DomInstance| class_is_a(child.class, &class_name).unwrap_or(false); if matches!(recursive, Some(true)) { this.find_descendant(predicate).into_lua(lua) } else { diff --git a/crates/lune-roblox/src/instance/mod.rs b/crates/lune-roblox/src/instance/mod.rs index 3397e095..e6673dc8 100644 --- a/crates/lune-roblox/src/instance/mod.rs +++ b/crates/lune-roblox/src/instance/mod.rs @@ -75,7 +75,7 @@ impl Instance { Some(Self { dom_ref, - class_name: instance.class.clone(), + class_name: instance.class.to_string(), }) } else { None @@ -337,14 +337,14 @@ impl Instance { /** Gets a property for the instance, if it exists. */ - pub fn get_property(&self, name: impl AsRef) -> Option { + pub fn get_property(&self, name: &str) -> Option { INTERNAL_DOM .lock() .expect("Failed to lock document") .get_by_ref(self.dom_ref) .expect("Failed to find instance in document") .properties - .get(name.as_ref()) + .get(&name.into()) .cloned() } @@ -361,7 +361,7 @@ impl Instance { .get_by_ref_mut(self.dom_ref) .expect("Failed to find instance in document") .properties - .insert(name.as_ref().to_string(), value); + .insert(name.as_ref().into(), value); } /** @@ -377,7 +377,7 @@ impl Instance { .get_by_ref(self.dom_ref) .expect("Failed to find instance in document"); if let Some(DomValue::Attributes(attributes)) = - inst.properties.get(PROPERTY_NAME_ATTRIBUTES) + inst.properties.get(&PROPERTY_NAME_ATTRIBUTES.into()) { attributes.get(name.as_ref()).cloned() } else { @@ -398,7 +398,7 @@ impl Instance { .get_by_ref(self.dom_ref) .expect("Failed to find instance in document"); if let Some(DomValue::Attributes(attributes)) = - inst.properties.get(PROPERTY_NAME_ATTRIBUTES) + inst.properties.get(&PROPERTY_NAME_ATTRIBUTES.into()) { attributes.clone().into_iter().collect() } else { @@ -425,14 +425,14 @@ impl Instance { value => value, }; if let Some(DomValue::Attributes(attributes)) = - inst.properties.get_mut(PROPERTY_NAME_ATTRIBUTES) + inst.properties.get_mut(&PROPERTY_NAME_ATTRIBUTES.into()) { attributes.insert(name.as_ref().to_string(), value); } else { let mut attributes = DomAttributes::new(); attributes.insert(name.as_ref().to_string(), value); inst.properties.insert( - PROPERTY_NAME_ATTRIBUTES.to_string(), + PROPERTY_NAME_ATTRIBUTES.into(), DomValue::Attributes(attributes), ); } @@ -452,11 +452,11 @@ impl Instance { .get_by_ref_mut(self.dom_ref) .expect("Failed to find instance in document"); if let Some(DomValue::Attributes(attributes)) = - inst.properties.get_mut(PROPERTY_NAME_ATTRIBUTES) + inst.properties.get_mut(&PROPERTY_NAME_ATTRIBUTES.into()) { attributes.remove(name.as_ref()); if attributes.is_empty() { - inst.properties.remove(PROPERTY_NAME_ATTRIBUTES); + inst.properties.remove(&PROPERTY_NAME_ATTRIBUTES.into()); } } } @@ -473,11 +473,11 @@ impl Instance { let inst = dom .get_by_ref_mut(self.dom_ref) .expect("Failed to find instance in document"); - if let Some(DomValue::Tags(tags)) = inst.properties.get_mut(PROPERTY_NAME_TAGS) { + if let Some(DomValue::Tags(tags)) = inst.properties.get_mut(&PROPERTY_NAME_TAGS.into()) { tags.push(name.as_ref()); } else { inst.properties.insert( - PROPERTY_NAME_TAGS.to_string(), + PROPERTY_NAME_TAGS.into(), DomValue::Tags(vec![name.as_ref().to_string()].into()), ); } @@ -495,7 +495,7 @@ impl Instance { let inst = dom .get_by_ref(self.dom_ref) .expect("Failed to find instance in document"); - if let Some(DomValue::Tags(tags)) = inst.properties.get(PROPERTY_NAME_TAGS) { + if let Some(DomValue::Tags(tags)) = inst.properties.get(&PROPERTY_NAME_TAGS.into()) { tags.iter().map(ToString::to_string).collect() } else { Vec::new() @@ -514,7 +514,7 @@ impl Instance { let inst = dom .get_by_ref(self.dom_ref) .expect("Failed to find instance in document"); - if let Some(DomValue::Tags(tags)) = inst.properties.get(PROPERTY_NAME_TAGS) { + if let Some(DomValue::Tags(tags)) = inst.properties.get(&PROPERTY_NAME_TAGS.into()) { let name = name.as_ref(); tags.iter().any(|tag| tag == name) } else { @@ -534,14 +534,12 @@ impl Instance { let inst = dom .get_by_ref_mut(self.dom_ref) .expect("Failed to find instance in document"); - if let Some(DomValue::Tags(tags)) = inst.properties.get_mut(PROPERTY_NAME_TAGS) { + if let Some(DomValue::Tags(tags)) = inst.properties.get_mut(&PROPERTY_NAME_TAGS.into()) { let name = name.as_ref(); let mut new_tags = tags.iter().map(ToString::to_string).collect::>(); new_tags.retain(|tag| tag != name); - inst.properties.insert( - PROPERTY_NAME_TAGS.to_string(), - DomValue::Tags(new_tags.into()), - ); + inst.properties + .insert(PROPERTY_NAME_TAGS.into(), DomValue::Tags(new_tags.into())); } }