mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 23:26:19 +00:00
Update plugin to use new property format
This commit is contained in:
@@ -146,8 +146,7 @@ return function()
|
|||||||
id = "VALUE",
|
id = "VALUE",
|
||||||
changedProperties = {
|
changedProperties = {
|
||||||
Value = {
|
Value = {
|
||||||
Type = "String",
|
String = "WORLD",
|
||||||
Value = "WORLD",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -176,8 +175,7 @@ return function()
|
|||||||
changedClassName = "StringValue",
|
changedClassName = "StringValue",
|
||||||
changedProperties = {
|
changedProperties = {
|
||||||
Value = {
|
Value = {
|
||||||
Type = "String",
|
String = "I am Root",
|
||||||
Value = "I am Root",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,29 +6,31 @@
|
|||||||
local RbxDom = require(script.Parent.Parent.Parent.RbxDom)
|
local RbxDom = require(script.Parent.Parent.Parent.RbxDom)
|
||||||
local Error = require(script.Parent.Error)
|
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.
|
-- Refs are represented as IDs in the same space that Rojo's protocol uses.
|
||||||
if virtualValue.Type == "Ref" then
|
if ty == "Ref" then
|
||||||
if virtualValue.Value == nil then
|
if value == nil then
|
||||||
return true, nil
|
return true, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local instance = instanceMap.fromIds[virtualValue.Value]
|
local instance = instanceMap.fromIds[value]
|
||||||
|
|
||||||
if instance ~= nil then
|
if instance ~= nil then
|
||||||
return true, instance
|
return true, instance
|
||||||
else
|
else
|
||||||
return false, Error.new(Error.RefDidNotExist, {
|
return false, Error.new(Error.RefDidNotExist, {
|
||||||
virtualValue = virtualValue,
|
encodedValue = encodedValue,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ok, decodedValue = RbxDom.EncodedValue.decode(virtualValue)
|
local ok, decodedValue = RbxDom.EncodedValue.decode(encodedValue)
|
||||||
|
|
||||||
if not ok then
|
if not ok then
|
||||||
return false, Error.new(Error.CannotDecodeValue, {
|
return false, Error.new(Error.CannotDecodeValue, {
|
||||||
virtualValue = virtualValue,
|
encodedValue = encodedValue,
|
||||||
innerError = decodedValue,
|
innerError = decodedValue,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ return function()
|
|||||||
Name = "Value",
|
Name = "Value",
|
||||||
Properties = {
|
Properties = {
|
||||||
Value = {
|
Value = {
|
||||||
Type = "String",
|
String = "Hello, world!",
|
||||||
Value = "Hello, world!",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Children = {},
|
Children = {},
|
||||||
@@ -107,8 +106,9 @@ return function()
|
|||||||
|
|
||||||
local patchProperty = update.changedProperties["Value"]
|
local patchProperty = update.changedProperties["Value"]
|
||||||
expect(patchProperty).to.be.a("table")
|
expect(patchProperty).to.be.a("table")
|
||||||
expect(patchProperty.Type).to.equal("String")
|
local ty, value = next(patchProperty)
|
||||||
expect(patchProperty.Value).to.equal("Hello, world!")
|
expect(ty).to.equal("String")
|
||||||
|
expect(value).to.equal("Hello, world!")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("should generate an empty patch if no properties changed", function()
|
it("should generate an empty patch if no properties changed", function()
|
||||||
@@ -119,8 +119,7 @@ return function()
|
|||||||
Name = "Value",
|
Name = "Value",
|
||||||
Properties = {
|
Properties = {
|
||||||
Value = {
|
Value = {
|
||||||
Type = "String",
|
String = "Hello, world!",
|
||||||
Value = "Hello, world!",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Children = {},
|
Children = {},
|
||||||
@@ -145,8 +144,7 @@ return function()
|
|||||||
Name = "Folder",
|
Name = "Folder",
|
||||||
Properties = {
|
Properties = {
|
||||||
FAKE_PROPERTY = {
|
FAKE_PROPERTY = {
|
||||||
Type = "String",
|
String = "Hello, world!",
|
||||||
Value = "Hello, world!",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Children = {},
|
Children = {},
|
||||||
@@ -183,8 +181,7 @@ return function()
|
|||||||
-- heat_xml is a serialization-only property that is not
|
-- heat_xml is a serialization-only property that is not
|
||||||
-- exposed to Lua.
|
-- exposed to Lua.
|
||||||
heat_xml = {
|
heat_xml = {
|
||||||
Type = "Float32",
|
Float32 = 5,
|
||||||
Value = 5,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Children = {},
|
Children = {},
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ return function()
|
|||||||
Name = "Spaghetti",
|
Name = "Spaghetti",
|
||||||
Properties = {
|
Properties = {
|
||||||
Value = {
|
Value = {
|
||||||
Type = "String",
|
String = "Hello, world!",
|
||||||
Value = "Hello, world!",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Children = {},
|
Children = {},
|
||||||
|
|||||||
Reference in New Issue
Block a user