mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Update rbx-dom (#1023)
This commit is contained in:
@@ -2,7 +2,10 @@ use std::{borrow::Cow, collections::HashMap, path::Path, str};
|
||||
|
||||
use anyhow::Context;
|
||||
use memofs::Vfs;
|
||||
use rbx_dom_weak::types::{Attributes, Ref};
|
||||
use rbx_dom_weak::{
|
||||
types::{Attributes, Ref},
|
||||
HashMapExt as _, Ustr, UstrMap,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
@@ -68,7 +71,7 @@ struct JsonModel {
|
||||
name: Option<String>,
|
||||
|
||||
#[serde(alias = "ClassName")]
|
||||
class_name: String,
|
||||
class_name: Ustr,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
@@ -82,10 +85,10 @@ struct JsonModel {
|
||||
|
||||
#[serde(
|
||||
alias = "Properties",
|
||||
default = "HashMap::new",
|
||||
default = "UstrMap::new",
|
||||
skip_serializing_if = "HashMap::is_empty"
|
||||
)]
|
||||
properties: HashMap<String, UnresolvedValue>,
|
||||
properties: UstrMap<UnresolvedValue>,
|
||||
|
||||
#[serde(default = "HashMap::new", skip_serializing_if = "HashMap::is_empty")]
|
||||
attributes: HashMap<String, UnresolvedValue>,
|
||||
@@ -93,7 +96,7 @@ struct JsonModel {
|
||||
|
||||
impl JsonModel {
|
||||
fn into_snapshot(self) -> anyhow::Result<InstanceSnapshot> {
|
||||
let name = self.name.unwrap_or_else(|| self.class_name.clone());
|
||||
let name = self.name.unwrap_or_else(|| self.class_name.to_owned());
|
||||
let class_name = self.class_name;
|
||||
|
||||
let mut children = Vec::with_capacity(self.children.len());
|
||||
@@ -101,7 +104,7 @@ impl JsonModel {
|
||||
children.push(child.into_snapshot()?);
|
||||
}
|
||||
|
||||
let mut properties = HashMap::with_capacity(self.properties.len());
|
||||
let mut properties = UstrMap::with_capacity(self.properties.len());
|
||||
for (key, unresolved) in self.properties {
|
||||
let value = unresolved.resolve(&class_name, &key)?;
|
||||
properties.insert(key, value);
|
||||
@@ -122,7 +125,7 @@ impl JsonModel {
|
||||
snapshot_id: Ref::none(),
|
||||
metadata: Default::default(),
|
||||
name: Cow::Owned(name),
|
||||
class_name: Cow::Owned(class_name),
|
||||
class_name,
|
||||
properties,
|
||||
children,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user