mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
plugin: Miscellaneous cleanup
This commit is contained in:
@@ -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
|
||||
|
||||
25
plugin/src/PatchSet.lua
Normal file
25
plugin/src/PatchSet.lua
Normal file
@@ -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
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user