mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 12:45:05 +00:00
config_map -> instance_metadata_map
This commit is contained in:
@@ -28,7 +28,7 @@ function ApiContext.new(baseUrl)
|
||||
onMessageCallback = nil,
|
||||
serverId = nil,
|
||||
rootInstanceId = nil,
|
||||
configMap = nil,
|
||||
instanceMetadataMap = nil,
|
||||
connected = false,
|
||||
messageCursor = -1,
|
||||
partitionRoutes = nil,
|
||||
@@ -70,7 +70,7 @@ function ApiContext:connect()
|
||||
self.connected = true
|
||||
self.partitionRoutes = body.partitions
|
||||
self.rootInstanceId = body.rootInstanceId
|
||||
self.configMap = body.configMap
|
||||
self.instanceMetadataMap = body.instanceMetadataMap
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -46,15 +46,15 @@ local function setProperty(instance, key, value)
|
||||
end
|
||||
end
|
||||
|
||||
local function shouldClearUnknown(id, configMap)
|
||||
if configMap[id] then
|
||||
return not configMap[id].ignoreUnknown
|
||||
local function shouldClearUnknown(id, instanceMetadataMap)
|
||||
if instanceMetadataMap[id] then
|
||||
return not instanceMetadataMap[id].ignoreUnknown
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local function reify(instanceData, instanceMap, configMap, id, parent)
|
||||
local function reify(instanceData, instanceMap, instanceMetadataMap, id, parent)
|
||||
local data = instanceData[id]
|
||||
|
||||
local instance = Instance.new(data.ClassName)
|
||||
@@ -67,7 +67,7 @@ local function reify(instanceData, instanceMap, configMap, id, parent)
|
||||
instance.Name = data.Name
|
||||
|
||||
for _, childId in ipairs(data.Children) do
|
||||
reify(instanceData, instanceMap, configMap, childId, instance)
|
||||
reify(instanceData, instanceMap, instanceMetadataMap, childId, instance)
|
||||
end
|
||||
|
||||
setProperty(instance, "Parent", parent)
|
||||
@@ -76,7 +76,7 @@ local function reify(instanceData, instanceMap, configMap, id, parent)
|
||||
return instance
|
||||
end
|
||||
|
||||
local function reconcile(instanceData, instanceMap, configMap, id, existingInstance)
|
||||
local function reconcile(instanceData, instanceMap, instanceMetadataMap, id, existingInstance)
|
||||
local data = instanceData[id]
|
||||
|
||||
assert(data.ClassName == existingInstance.ClassName)
|
||||
@@ -111,13 +111,13 @@ local function reconcile(instanceData, instanceMap, configMap, id, existingInsta
|
||||
|
||||
if existingChildInstance ~= nil then
|
||||
unvisitedExistingChildren[existingChildInstance] = nil
|
||||
reconcile(instanceData, instanceMap, configMap, childId, existingChildInstance)
|
||||
reconcile(instanceData, instanceMap, instanceMetadataMap, childId, existingChildInstance)
|
||||
else
|
||||
reify(instanceData, instanceMap, configMap, childId, existingInstance)
|
||||
reify(instanceData, instanceMap, instanceMetadataMap, childId, existingInstance)
|
||||
end
|
||||
end
|
||||
|
||||
if shouldClearUnknown(id, configMap) then
|
||||
if shouldClearUnknown(id, instanceMetadataMap) then
|
||||
for existingChildInstance in pairs(unvisitedExistingChildren) do
|
||||
instanceMap:removeInstance(existingChildInstance)
|
||||
existingChildInstance:Destroy()
|
||||
@@ -168,7 +168,7 @@ function Session.new()
|
||||
end
|
||||
else
|
||||
if instance ~= nil then
|
||||
reconcile(response.instances, instanceMap, api.configMap, id, instance)
|
||||
reconcile(response.instances, instanceMap, api.instanceMetadataMap, id, instance)
|
||||
else
|
||||
error("TODO: Crawl up to nearest parent, use that?")
|
||||
end
|
||||
@@ -182,8 +182,8 @@ function Session.new()
|
||||
return api:read({api.rootInstanceId})
|
||||
end)
|
||||
:andThen(function(response)
|
||||
reconcile(response.instances, instanceMap, api.configMap, api.rootInstanceId, game)
|
||||
-- reify(response.instances, instanceMap, configMap, api.rootInstanceId, game.ReplicatedStorage)
|
||||
reconcile(response.instances, instanceMap, api.instanceMetadataMap, api.rootInstanceId, game)
|
||||
-- reify(response.instances, instanceMap, instanceMetadataMap, api.rootInstanceId, game.ReplicatedStorage)
|
||||
return api:retrieveMessages()
|
||||
end)
|
||||
:catch(function(message)
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::{
|
||||
pub struct RbxSession {
|
||||
tree: RbxTree,
|
||||
path_map: PathMap<RbxId>,
|
||||
config_map: HashMap<RbxId, InstanceProjectNodeConfig>,
|
||||
instance_metadata_map: HashMap<RbxId, InstanceProjectNodeConfig>,
|
||||
message_queue: Arc<MessageQueue<InstanceChanges>>,
|
||||
imfs: Arc<Mutex<Imfs>>,
|
||||
project: Arc<Project>,
|
||||
@@ -32,17 +32,17 @@ impl RbxSession {
|
||||
message_queue: Arc<MessageQueue<InstanceChanges>>,
|
||||
) -> RbxSession {
|
||||
let mut path_map = PathMap::new();
|
||||
let mut config_map = HashMap::new();
|
||||
let mut instance_metadata_map = HashMap::new();
|
||||
|
||||
let tree = {
|
||||
let temp_imfs = imfs.lock().unwrap();
|
||||
construct_initial_tree(&project, &temp_imfs, &mut path_map, &mut config_map)
|
||||
construct_initial_tree(&project, &temp_imfs, &mut path_map, &mut instance_metadata_map)
|
||||
};
|
||||
|
||||
RbxSession {
|
||||
tree,
|
||||
path_map,
|
||||
config_map,
|
||||
instance_metadata_map,
|
||||
message_queue,
|
||||
imfs,
|
||||
project,
|
||||
@@ -63,7 +63,7 @@ impl RbxSession {
|
||||
let snapshot = snapshot_instances_from_imfs(&imfs, &closest_path)
|
||||
.expect("Could not generate instance snapshot");
|
||||
|
||||
reconcile_subtree(&mut self.tree, instance_id, &snapshot, &mut self.path_map, &mut self.config_map, &mut changes);
|
||||
reconcile_subtree(&mut self.tree, instance_id, &snapshot, &mut self.path_map, &mut self.instance_metadata_map, &mut changes);
|
||||
}
|
||||
|
||||
if !changes.is_empty() {
|
||||
@@ -128,22 +128,22 @@ impl RbxSession {
|
||||
&self.tree
|
||||
}
|
||||
|
||||
pub fn get_config_map(&self) -> &HashMap<RbxId, InstanceProjectNodeConfig> {
|
||||
&self.config_map
|
||||
pub fn get_instance_metadata_map(&self) -> &HashMap<RbxId, InstanceProjectNodeConfig> {
|
||||
&self.instance_metadata_map
|
||||
}
|
||||
}
|
||||
|
||||
pub fn construct_oneoff_tree(project: &Project, imfs: &Imfs) -> RbxTree {
|
||||
let mut path_map = PathMap::new();
|
||||
let mut config_map = HashMap::new();
|
||||
construct_initial_tree(project, imfs, &mut path_map, &mut config_map)
|
||||
let mut instance_metadata_map = HashMap::new();
|
||||
construct_initial_tree(project, imfs, &mut path_map, &mut instance_metadata_map)
|
||||
}
|
||||
|
||||
fn construct_initial_tree(
|
||||
project: &Project,
|
||||
imfs: &Imfs,
|
||||
path_map: &mut PathMap<RbxId>,
|
||||
config_map: &mut HashMap<RbxId, InstanceProjectNodeConfig>,
|
||||
instance_metadata_map: &mut HashMap<RbxId, InstanceProjectNodeConfig>,
|
||||
) -> RbxTree {
|
||||
let snapshot = construct_project_node(
|
||||
imfs,
|
||||
@@ -152,7 +152,7 @@ fn construct_initial_tree(
|
||||
);
|
||||
|
||||
let mut changes = InstanceChanges::default();
|
||||
let tree = reify_root(&snapshot, path_map, config_map, &mut changes);
|
||||
let tree = reify_root(&snapshot, path_map, instance_metadata_map, &mut changes);
|
||||
|
||||
tree
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ pub struct ServerInfoResponse<'a> {
|
||||
pub server_version: &'a str,
|
||||
pub protocol_version: u64,
|
||||
pub root_instance_id: RbxId,
|
||||
pub config_map: Cow<'a, HashMap<RbxId, InstanceProjectNodeConfig>>,
|
||||
pub instance_metadata_map: Cow<'a, HashMap<RbxId, InstanceProjectNodeConfig>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@@ -78,7 +78,7 @@ impl Server {
|
||||
protocol_version: 2,
|
||||
session_id: self.session.session_id,
|
||||
root_instance_id: tree.get_root_id(),
|
||||
config_map: Cow::Borrowed(rbx_session.get_config_map()),
|
||||
instance_metadata_map: Cow::Borrowed(rbx_session.get_instance_metadata_map()),
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user