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