diff --git a/plugin/src/InstanceMap.lua b/plugin/src/InstanceMap.lua index 59eccc80..25a25493 100644 --- a/plugin/src/InstanceMap.lua +++ b/plugin/src/InstanceMap.lua @@ -5,6 +5,7 @@ local Log = require(script.Parent.Parent.Log) keep track of every instance we know about. TODO: Track ancestry to catch when stuff moves? + TODO: Ability to pause change tracking for preventing feedback. ]] local InstanceMap = {} InstanceMap.__index = InstanceMap diff --git a/plugin/src/PatchSet.lua b/plugin/src/PatchSet.lua new file mode 100644 index 00000000..6d18b46d --- /dev/null +++ b/plugin/src/PatchSet.lua @@ -0,0 +1,25 @@ +--[[ + Methods to operate on either a patch created by the hydrate method, or a + patch returned from the API. +]] + +local t = require(script.Parent.Parent.t) + +local Types = require(script.Parent.Types) + +local PatchSet = {} + +PatchSet.validate = t.interface({ + removed = t.array(t.union(Types.RbxId, t.Instance)), + added = t.map(Types.RbxId, Types.ApiInstance), + updated = t.array(Types.ApiInstanceUpdate), +}) + +--[[ + Invert the given PatchSet using the given instance map. +]] +function PatchSet.invert(patchSet, instanceMap) + error("not yet implemented", 2) +end + +return PatchSet \ No newline at end of file diff --git a/plugin/src/Reconciler.lua b/plugin/src/Reconciler.lua index 6050a401..ad395abf 100644 --- a/plugin/src/Reconciler.lua +++ b/plugin/src/Reconciler.lua @@ -5,24 +5,12 @@ local RbxDom = require(script.Parent.Parent.RbxDom) local t = require(script.Parent.Parent.t) -local Log = require(script.Parent.Parent.Log) local Types = require(script.Parent.Types) local invariant = require(script.Parent.invariant) local getCanonicalProperty = require(script.Parent.getCanonicalProperty) local setCanonicalProperty = require(script.Parent.setCanonicalProperty) - ---[[ - This interface represents either a patch created by the hydrate method, or a - patch returned from the API. - - This type should be a subset of Types.ApiInstanceUpdate. -]] -local IPatch = t.interface({ - removed = t.array(t.union(Types.RbxId, t.Instance)), - added = t.map(Types.RbxId, Types.ApiInstance), - updated = t.array(Types.ApiInstanceUpdate), -}) +local PatchSet = require(script.Parent.PatchSet) --[[ Attempt to safely set the parent of an instance. @@ -86,7 +74,7 @@ end editable by scripts. ]] local applyPatchSchema = Types.ifEnabled(t.tuple( - IPatch + PatchSet.validate )) function Reconciler:applyPatch(patch) assert(applyPatchSchema(patch)) @@ -287,7 +275,7 @@ local hydrateSchema = Types.ifEnabled(t.tuple( t.map(Types.RbxId, Types.VirtualInstance), Types.RbxId, t.Instance, - IPatch + PatchSet.validate )) function Reconciler:__hydrateInternal(apiInstances, id, instance, hydratePatch) assert(hydrateSchema(apiInstances, id, instance, hydratePatch)) diff --git a/plugin/src/ServeSession.lua b/plugin/src/ServeSession.lua index bf6e9194..e527cc6d 100644 --- a/plugin/src/ServeSession.lua +++ b/plugin/src/ServeSession.lua @@ -4,7 +4,6 @@ local Log = require(script.Parent.Parent.Log) local Fmt = require(script.Parent.Parent.Fmt) local t = require(script.Parent.Parent.t) -local DevSettings = require(script.Parent.DevSettings) local InstanceMap = require(script.Parent.InstanceMap) local Reconciler = require(script.Parent.Reconciler) local strict = require(script.Parent.strict) diff --git a/plugin/src/getCanonicalProperty.lua b/plugin/src/getCanonicalProperty.lua index 288d5989..f594722a 100644 --- a/plugin/src/getCanonicalProperty.lua +++ b/plugin/src/getCanonicalProperty.lua @@ -1,7 +1,7 @@ local RbxDom = require(script.Parent.Parent.RbxDom) --[[ - Attempts to set a property on the given instance. + Attempts to read a property from the given instance. ]] local function getCanonincalProperty(instance, propertyName) local descriptor = RbxDom.findCanonicalPropertyDescriptor(instance.ClassName, propertyName)