mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Add default properties caching and update matching logic
- Implemented a caching mechanism for default properties per class in `rbx_dom_lua/init.lua`, allowing for efficient retrieval of encoded default values, including inherited defaults. - Updated the matching logic in `Reconciler/matching.lua` to account for properties present only on the Studio side, ensuring accurate comparisons against default values during reconciliation. - Added new test cases to validate the handling of default-omitted properties, enhancing the robustness of the reconciliation process. These changes improve the efficiency and accuracy of property matching, addressing issues related to default values in the reconciliation workflow.
This commit is contained in:
parent
e54f5ef4e3
commit
9c6966acff
30 changed files with 1648 additions and 0 deletions
|
|
@ -330,6 +330,48 @@ function Matching._countOwnDiffs(vInst: any, studioInstance: Instance): number
|
|||
end
|
||||
end
|
||||
|
||||
-- Properties present only on the Studio side (not in virtual).
|
||||
-- Syncback strips default-valued properties from model files, so virtual
|
||||
-- instances may omit properties that Studio has at non-default values.
|
||||
-- Without this check, a virtual instance missing e.g. Face scores equally
|
||||
-- against all Studio instances in the group, causing wrong pairings.
|
||||
local defaults = RbxDom.findDefaultProperties(vInst.ClassName)
|
||||
if defaults then
|
||||
for propName, encodedDefault in defaults do
|
||||
if propName == "Tags" or propName == "Attributes" then
|
||||
continue
|
||||
end
|
||||
|
||||
-- Skip properties already compared from the virtual side
|
||||
if vProps and vProps[propName] ~= nil then
|
||||
continue
|
||||
end
|
||||
|
||||
-- Skip Ref/UniqueId types (not comparable during hydration)
|
||||
local ty = next(encodedDefault)
|
||||
if ty == "Ref" or ty == "UniqueId" then
|
||||
continue
|
||||
end
|
||||
|
||||
-- pcall guards against unsupported types (e.g. SharedString)
|
||||
local pcallOk, decodeOk, defaultValue = pcall(RbxDom.EncodedValue.decode, encodedDefault)
|
||||
if not pcallOk or not decodeOk then
|
||||
continue
|
||||
end
|
||||
|
||||
local readOk, studioValue = pcall(function()
|
||||
return (studioInstance :: any)[propName]
|
||||
end)
|
||||
if not readOk then
|
||||
continue
|
||||
end
|
||||
|
||||
if not trueEquals(defaultValue, studioValue) then
|
||||
cost += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Tags: count individual adds/removes
|
||||
local vTags = vInst.Properties and vInst.Properties.Tags
|
||||
if vTags then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue