Add support for external references in RojoTree and syncback process

- Introduced REF_EXTERNAL_ATTRIBUTE_PREFIX for attributes pointing to external instances.
- Enhanced PatchApplyContext to track external references and apply them during patch application.
- Implemented get_instance_by_path method in RojoTree for resolving paths to external instances.
- Updated collect_referents function to handle external references and preserve their paths during syncback.
- Refactored link_referents to include external reference handling in the linking process.
This commit is contained in:
Joe 2026-01-20 21:05:28 -06:00
parent 9e270bd847
commit a1e270949d
5 changed files with 217 additions and 27 deletions

View file

@ -14,7 +14,7 @@ use rbx_dom_weak::{
};
use serde::{Deserialize, Serialize};
use std::{
collections::{HashMap, HashSet, VecDeque},
collections::{HashMap, VecDeque},
env,
path::Path,
sync::OnceLock,
@ -24,7 +24,7 @@ use crate::{
glob::Glob,
snapshot::{InstanceWithMeta, RojoTree},
snapshot_middleware::Middleware,
syncback::ref_properties::{collect_referents, link_referents},
syncback::ref_properties::{collect_all_paths, collect_referents, link_referents},
Project,
};
@ -65,6 +65,11 @@ pub fn syncback_loop(
.map(|rules| rules.compile_tree_globs())
.transpose()?;
// Collect all instance paths BEFORE pruning so we can track external references
// (references to instances that will be pruned, like SoundGroups in SoundService).
log::debug!("Collecting instance paths before pruning...");
let pre_prune_paths = collect_all_paths(&new_tree);
// TODO: Add a better way to tell if the root of a project is a directory
let skip_pruning = if let Some(path) = &project.tree.path {
let middleware =
@ -87,7 +92,7 @@ pub fn syncback_loop(
}
log::debug!("Collecting referents for new DOM...");
let deferred_referents = collect_referents(&new_tree);
let deferred_referents = collect_referents(&new_tree, &pre_prune_paths);
// Remove any properties that are manually blocked from syncback via the
// project file.