Update plugin to use new property format

This commit is contained in:
Lucien Greathouse
2021-07-02 16:12:12 -04:00
parent 2377f41036
commit 92e6f862ad
4 changed files with 19 additions and 23 deletions

View File

@@ -146,8 +146,7 @@ return function()
id = "VALUE",
changedProperties = {
Value = {
Type = "String",
Value = "WORLD",
String = "WORLD",
},
},
})
@@ -176,8 +175,7 @@ return function()
changedClassName = "StringValue",
changedProperties = {
Value = {
Type = "String",
Value = "I am Root",
String = "I am Root",
},
},
})

View File

@@ -6,29 +6,31 @@
local RbxDom = require(script.Parent.Parent.Parent.RbxDom)
local Error = require(script.Parent.Error)
local function decodeValue(virtualValue, instanceMap)
local function decodeValue(encodedValue, instanceMap)
local ty, value = next(encodedValue)
-- Refs are represented as IDs in the same space that Rojo's protocol uses.
if virtualValue.Type == "Ref" then
if virtualValue.Value == nil then
if ty == "Ref" then
if value == nil then
return true, nil
end
local instance = instanceMap.fromIds[virtualValue.Value]
local instance = instanceMap.fromIds[value]
if instance ~= nil then
return true, instance
else
return false, Error.new(Error.RefDidNotExist, {
virtualValue = virtualValue,
encodedValue = encodedValue,
})
end
end
local ok, decodedValue = RbxDom.EncodedValue.decode(virtualValue)
local ok, decodedValue = RbxDom.EncodedValue.decode(encodedValue)
if not ok then
return false, Error.new(Error.CannotDecodeValue, {
virtualValue = virtualValue,
encodedValue = encodedValue,
innerError = decodedValue,
})
end

View File

@@ -80,8 +80,7 @@ return function()
Name = "Value",
Properties = {
Value = {
Type = "String",
Value = "Hello, world!",
String = "Hello, world!",
},
},
Children = {},
@@ -107,8 +106,9 @@ return function()
local patchProperty = update.changedProperties["Value"]
expect(patchProperty).to.be.a("table")
expect(patchProperty.Type).to.equal("String")
expect(patchProperty.Value).to.equal("Hello, world!")
local ty, value = next(patchProperty)
expect(ty).to.equal("String")
expect(value).to.equal("Hello, world!")
end)
it("should generate an empty patch if no properties changed", function()
@@ -119,8 +119,7 @@ return function()
Name = "Value",
Properties = {
Value = {
Type = "String",
Value = "Hello, world!",
String = "Hello, world!",
},
},
Children = {},
@@ -145,8 +144,7 @@ return function()
Name = "Folder",
Properties = {
FAKE_PROPERTY = {
Type = "String",
Value = "Hello, world!",
String = "Hello, world!",
},
},
Children = {},
@@ -183,8 +181,7 @@ return function()
-- heat_xml is a serialization-only property that is not
-- exposed to Lua.
heat_xml = {
Type = "Float32",
Value = 5,
Float32 = 5,
},
},
Children = {},

View File

@@ -54,8 +54,7 @@ return function()
Name = "Spaghetti",
Properties = {
Value = {
Type = "String",
Value = "Hello, world!",
String = "Hello, world!",
},
},
Children = {},