mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 14:15:24 +00:00
Compare commits
52 Commits
v0.5.0-alp
...
v0.5.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77f79fa913 | ||
|
|
6db714a2b1 | ||
|
|
913ac7c9f5 | ||
|
|
eecbfd29e7 | ||
|
|
41025225b2 | ||
|
|
07c7b28c03 | ||
|
|
3faf3d2a56 | ||
|
|
be094d5b7c | ||
|
|
459673bd59 | ||
|
|
2968b70e6b | ||
|
|
b6989a18fc | ||
|
|
4d6a504836 | ||
|
|
6c3737df68 | ||
|
|
9f382ed9bd | ||
|
|
f9e86e58d6 | ||
|
|
469f9c927f | ||
|
|
312724189b | ||
|
|
ec0a1f1ce4 | ||
|
|
ad93631ef8 | ||
|
|
3b6238ff93 | ||
|
|
5b9facee00 | ||
|
|
376f2a554a | ||
|
|
5fd0bd3db9 | ||
|
|
2deb3bbf23 | ||
|
|
01bef0c2b8 | ||
|
|
b65a8ce680 | ||
|
|
5fc4f63238 | ||
|
|
9b0e0c175b | ||
|
|
eb97e925e6 | ||
|
|
16f8975b18 | ||
|
|
5073fce2f7 | ||
|
|
cf5036eec6 | ||
|
|
20be37dd8b | ||
|
|
93349ae2dc | ||
|
|
be81de74cd | ||
|
|
88e739090d | ||
|
|
7f324f1957 | ||
|
|
4f31c9e72f | ||
|
|
c9a663ed39 | ||
|
|
105d8aeb6b | ||
|
|
6ea1211bc5 | ||
|
|
c13291a598 | ||
|
|
aaa78c618c | ||
|
|
2890c677d4 | ||
|
|
51a010de00 | ||
|
|
ca0aabd814 | ||
|
|
91d1ba1910 | ||
|
|
c7c739dc00 | ||
|
|
7a8389bf11 | ||
|
|
5f062b8ea3 | ||
|
|
b9ee14a0f9 | ||
|
|
c3baf73455 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,4 +2,4 @@
|
|||||||
/target
|
/target
|
||||||
/scratch-project
|
/scratch-project
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
/generate-docs.run
|
/server/failed-snapshots/
|
||||||
9
.gitmodules
vendored
9
.gitmodules
vendored
@@ -1,12 +1,6 @@
|
|||||||
[submodule "plugin/modules/roact"]
|
[submodule "plugin/modules/roact"]
|
||||||
path = plugin/modules/roact
|
path = plugin/modules/roact
|
||||||
url = https://github.com/Roblox/roact.git
|
url = https://github.com/Roblox/roact.git
|
||||||
[submodule "plugin/modules/rodux"]
|
|
||||||
path = plugin/modules/rodux
|
|
||||||
url = https://github.com/Roblox/rodux.git
|
|
||||||
[submodule "plugin/modules/roact-rodux"]
|
|
||||||
path = plugin/modules/roact-rodux
|
|
||||||
url = https://github.com/Roblox/roact-rodux.git
|
|
||||||
[submodule "plugin/modules/testez"]
|
[submodule "plugin/modules/testez"]
|
||||||
path = plugin/modules/testez
|
path = plugin/modules/testez
|
||||||
url = https://github.com/Roblox/testez.git
|
url = https://github.com/Roblox/testez.git
|
||||||
@@ -16,3 +10,6 @@
|
|||||||
[submodule "plugin/modules/promise"]
|
[submodule "plugin/modules/promise"]
|
||||||
path = plugin/modules/promise
|
path = plugin/modules/promise
|
||||||
url = https://github.com/LPGhatguy/roblox-lua-promise.git
|
url = https://github.com/LPGhatguy/roblox-lua-promise.git
|
||||||
|
[submodule "plugin/modules/t"]
|
||||||
|
path = plugin/modules/t
|
||||||
|
url = https://github.com/osyrisrblx/t.git
|
||||||
49
.travis.yml
49
.travis.yml
@@ -1,36 +1,41 @@
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- language: python
|
# Lua tests are currently disabled because of holes in Lemur that are pretty
|
||||||
env:
|
# tedious to fix. It should be fixed by either adding missing features to
|
||||||
- LUA="lua=5.1"
|
# Lemur or by migrating to a CI system based on real Roblox instead.
|
||||||
|
|
||||||
before_install:
|
# - language: python
|
||||||
- pip install hererocks
|
# env:
|
||||||
- hererocks lua_install -r^ --$LUA
|
# - LUA="lua=5.1"
|
||||||
- export PATH=$PATH:$PWD/lua_install/bin
|
|
||||||
|
|
||||||
install:
|
# before_install:
|
||||||
- luarocks install luafilesystem
|
# - pip install hererocks
|
||||||
- luarocks install busted
|
# - hererocks lua_install -r^ --$LUA
|
||||||
- luarocks install luacov
|
# - export PATH=$PATH:$PWD/lua_install/bin
|
||||||
- luarocks install luacov-coveralls
|
|
||||||
- luarocks install luacheck
|
|
||||||
|
|
||||||
script:
|
# install:
|
||||||
- cd plugin
|
# - luarocks install luafilesystem
|
||||||
- luacheck src
|
# - luarocks install busted
|
||||||
- lua -lluacov spec.lua
|
# - luarocks install luacov
|
||||||
|
# - luarocks install luacov-coveralls
|
||||||
|
# - luarocks install luacheck
|
||||||
|
|
||||||
after_success:
|
# script:
|
||||||
- cd plugin
|
# - cd plugin
|
||||||
- luacov-coveralls -e $TRAVIS_BUILD_DIR/lua_install
|
# - luacheck src
|
||||||
|
# - lua -lluacov spec.lua
|
||||||
|
|
||||||
|
# after_success:
|
||||||
|
# - cd plugin
|
||||||
|
# - luacov-coveralls -e $TRAVIS_BUILD_DIR/lua_install
|
||||||
|
|
||||||
- language: rust
|
- language: rust
|
||||||
rust: 1.31.1
|
rust: 1.32.0
|
||||||
cache: cargo
|
cache: cargo
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo test --verbose
|
- cargo test --verbose
|
||||||
|
- cargo test --verbose --all-features
|
||||||
|
|
||||||
- language: rust
|
- language: rust
|
||||||
rust: stable
|
rust: stable
|
||||||
@@ -38,6 +43,7 @@ matrix:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo test --verbose
|
- cargo test --verbose
|
||||||
|
- cargo test --verbose --all-features
|
||||||
|
|
||||||
- language: rust
|
- language: rust
|
||||||
rust: beta
|
rust: beta
|
||||||
@@ -45,3 +51,4 @@ matrix:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo test --verbose
|
- cargo test --verbose
|
||||||
|
- cargo test --verbose --all-features
|
||||||
37
CHANGELOG.md
37
CHANGELOG.md
@@ -2,6 +2,43 @@
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.5.0 Alpha 8](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.8) (March 29, 2019)
|
||||||
|
* Added support for a bunch of new types when dealing with XML model/place files:
|
||||||
|
* `ColorSequence`
|
||||||
|
* `Float64`
|
||||||
|
* `Int64`
|
||||||
|
* `NumberRange`
|
||||||
|
* `NumberSequence`
|
||||||
|
* `PhysicalProperties`
|
||||||
|
* `Ray`
|
||||||
|
* `Rect`
|
||||||
|
* `Ref`
|
||||||
|
* Improved server instance ordering behavior when files are added during a live session ([#135](https://github.com/LPGhatguy/rojo/pull/135))
|
||||||
|
* Fixed error being thrown when trying to unload the Rojo plugin.
|
||||||
|
* Added partial fix for [issue #141](https://github.com/LPGhatguy/rojo/issues/141) for `Lighting.Technology`, which should restore live sync functionality for the default project file.
|
||||||
|
|
||||||
|
## [0.5.0 Alpha 6](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.6) (March 19, 2019)
|
||||||
|
* Fixed `rojo init` giving unexpected results by upgrading to `rbx_dom_weak` 1.1.0
|
||||||
|
* Fixed live server not responding when the Rojo plugin is connected ([#133](https://github.com/LPGhatguy/rojo/issues/133))
|
||||||
|
* Updated default place file:
|
||||||
|
* Improved default properties to be closer to Studio's built-in 'Baseplate' template
|
||||||
|
* Added a baseplate to the project file (Thanks, [@AmaranthineCodices](https://github.com/AmaranthineCodices/)!)
|
||||||
|
* Added more type support to Rojo plugin
|
||||||
|
* Fixed some cases where the Rojo plugin would leave around objects that it knows should be deleted
|
||||||
|
* Updated plugin to correctly listen to `Plugin.Unloading` when installing or uninstalling new plugins
|
||||||
|
|
||||||
|
## [0.5.0 Alpha 5](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.5) (March 1, 2019)
|
||||||
|
* Upgraded core dependencies, which improves compatibility for lots of instance types
|
||||||
|
* Upgraded from `rbx_tree` 0.2.0 to `rbx_dom_weak` 1.0.0
|
||||||
|
* Upgraded from `rbx_xml` 0.2.0 to `rbx_xml` 0.4.0
|
||||||
|
* Upgraded from `rbx_binary` 0.2.0 to `rbx_binary` 0.4.0
|
||||||
|
* Added support for non-primitive types in the Rojo plugin.
|
||||||
|
* Types like `Color3` and `CFrame` can now be updated live!
|
||||||
|
* Fixed plugin assets flashing in on first load ([#121](https://github.com/LPGhatguy/rojo/issues/121))
|
||||||
|
* Changed Rojo's HTTP server from Rouille to Hyper, which reduced the release size by around a megabyte.
|
||||||
|
* Added property type inference to projects, which makes specifying services a lot easier ([#130](https://github.com/LPGhatguy/rojo/pull/130))
|
||||||
|
* Made error messages from invalid and missing files more user-friendly
|
||||||
|
|
||||||
## [0.5.0 Alpha 4](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.4) (February 8, 2019)
|
## [0.5.0 Alpha 4](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.4) (February 8, 2019)
|
||||||
* Added support for nested partitions ([#102](https://github.com/LPGhatguy/rojo/issues/102))
|
* Added support for nested partitions ([#102](https://github.com/LPGhatguy/rojo/issues/102))
|
||||||
* Added support for 'transmuting' partitions ([#112](https://github.com/LPGhatguy/rojo/issues/112))
|
* Added support for 'transmuting' partitions ([#112](https://github.com/LPGhatguy/rojo/issues/112))
|
||||||
|
|||||||
1083
Cargo.lock
generated
1083
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -62,7 +62,7 @@ If you use a plugin that _isn't_ Rojo for syncing code, open an issue and let me
|
|||||||
## Contributing
|
## Contributing
|
||||||
Pull requests are welcome!
|
Pull requests are welcome!
|
||||||
|
|
||||||
Rojo supports Rust 1.31.1 and newer. Any changes to the minimum required compiler version require a _minor_ version bump.
|
Rojo supports Rust 1.32 and newer. Any changes to the minimum required compiler version require a _minor_ version bump.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details.
|
Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details.
|
||||||
@@ -25,7 +25,7 @@ If you have Rust installed, the easiest way to get Rojo is with Cargo!
|
|||||||
To install the latest 0.5.0 alpha, use:
|
To install the latest 0.5.0 alpha, use:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo install rojo --version 0.5.0-alpha.3
|
cargo install rojo --version 0.5.0-alpha.8
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installing the Plugin
|
## Installing the Plugin
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ stds.roblox = {
|
|||||||
|
|
||||||
-- Types
|
-- Types
|
||||||
"Vector2", "Vector3",
|
"Vector2", "Vector3",
|
||||||
|
"Vector2int16", "Vector3int16",
|
||||||
"Color3",
|
"Color3",
|
||||||
"UDim", "UDim2",
|
"UDim", "UDim2",
|
||||||
"Rect",
|
"Rect",
|
||||||
|
|||||||
@@ -8,14 +8,11 @@
|
|||||||
"Roact": {
|
"Roact": {
|
||||||
"$path": "modules/roact/lib"
|
"$path": "modules/roact/lib"
|
||||||
},
|
},
|
||||||
"Rodux": {
|
|
||||||
"$path": "modules/rodux/lib"
|
|
||||||
},
|
|
||||||
"RoactRodux": {
|
|
||||||
"$path": "modules/roact-rodux/lib"
|
|
||||||
},
|
|
||||||
"Promise": {
|
"Promise": {
|
||||||
"$path": "modules/promise/lib"
|
"$path": "modules/promise/lib"
|
||||||
|
},
|
||||||
|
"t": {
|
||||||
|
"$path": "modules/t/lib/t.lua"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Submodule plugin/modules/roact-rodux deleted from 5d2e6885fc
Submodule plugin/modules/rodux deleted from 862f1c769a
1
plugin/modules/t
Submodule
1
plugin/modules/t
Submodule
Submodule plugin/modules/t added at a3a80ebf0a
@@ -15,14 +15,11 @@
|
|||||||
"Roact": {
|
"Roact": {
|
||||||
"$path": "modules/roact/lib"
|
"$path": "modules/roact/lib"
|
||||||
},
|
},
|
||||||
"Rodux": {
|
|
||||||
"$path": "modules/rodux/lib"
|
|
||||||
},
|
|
||||||
"RoactRodux": {
|
|
||||||
"$path": "modules/roact-rodux/lib"
|
|
||||||
},
|
|
||||||
"Promise": {
|
"Promise": {
|
||||||
"$path": "modules/promise/lib"
|
"$path": "modules/promise/lib"
|
||||||
|
},
|
||||||
|
"t": {
|
||||||
|
"$path": "modules/t/lib/t.lua"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"TestEZ": {
|
"TestEZ": {
|
||||||
@@ -40,8 +37,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"TestService": {
|
"ServerScriptService": {
|
||||||
"$className": "TestService",
|
"$className": "ServerScriptService",
|
||||||
|
|
||||||
"TestBootstrap": {
|
"TestBootstrap": {
|
||||||
"$path": "testBootstrap.server.lua"
|
"$path": "testBootstrap.server.lua"
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
local sheetAsset = "rbxassetid://2738712459"
|
|
||||||
|
|
||||||
local Assets = {
|
local Assets = {
|
||||||
Sprites = {
|
Sprites = {
|
||||||
WhiteCross = {
|
WhiteCross = {
|
||||||
asset = sheetAsset,
|
asset = "rbxassetid://2738712459",
|
||||||
offset = Vector2.new(190, 318),
|
offset = Vector2.new(190, 318),
|
||||||
size = Vector2.new(18, 18),
|
size = Vector2.new(18, 18),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local Config = require(Plugin.Config)
|
|||||||
local Version = require(Plugin.Version)
|
local Version = require(Plugin.Version)
|
||||||
local Logging = require(Plugin.Logging)
|
local Logging = require(Plugin.Logging)
|
||||||
local DevSettings = require(Plugin.DevSettings)
|
local DevSettings = require(Plugin.DevSettings)
|
||||||
|
local preloadAssets = require(Plugin.preloadAssets)
|
||||||
|
|
||||||
local ConnectPanel = require(Plugin.Components.ConnectPanel)
|
local ConnectPanel = require(Plugin.Components.ConnectPanel)
|
||||||
local ConnectionActivePanel = require(Plugin.Components.ConnectionActivePanel)
|
local ConnectionActivePanel = require(Plugin.Components.ConnectionActivePanel)
|
||||||
@@ -177,6 +178,15 @@ function App:didMount()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
preloadAssets()
|
||||||
|
end
|
||||||
|
|
||||||
|
function App:willUnmount()
|
||||||
|
if self.currentSession ~= nil then
|
||||||
|
self.currentSession:disconnect()
|
||||||
|
self.currentSession = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function App:didUpdate()
|
function App:didUpdate()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
codename = "Epiphany",
|
codename = "Epiphany",
|
||||||
version = {0, 5, 0, "-alpha.4"},
|
version = {0, 5, 0, "-alpha.8"},
|
||||||
expectedServerVersionString = "0.5.0 or newer",
|
expectedServerVersionString = "0.5.0 or newer",
|
||||||
protocolVersion = 2,
|
protocolVersion = 2,
|
||||||
defaultHost = "localhost",
|
defaultHost = "localhost",
|
||||||
|
|||||||
@@ -1,10 +1,27 @@
|
|||||||
local Config = require(script.Parent.Config)
|
local Config = require(script.Parent.Config)
|
||||||
|
|
||||||
|
local Environment = {
|
||||||
|
User = "User",
|
||||||
|
Dev = "Dev",
|
||||||
|
Test = "Test",
|
||||||
|
}
|
||||||
|
|
||||||
local VALUES = {
|
local VALUES = {
|
||||||
LogLevel = {
|
LogLevel = {
|
||||||
type = "IntValue",
|
type = "IntValue",
|
||||||
defaultUserValue = 2,
|
values = {
|
||||||
defaultDevValue = 3,
|
[Environment.User] = 2,
|
||||||
|
[Environment.Dev] = 3,
|
||||||
|
[Environment.Test] = 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TypecheckingEnabled = {
|
||||||
|
type = "BoolValue",
|
||||||
|
values = {
|
||||||
|
[Environment.User] = false,
|
||||||
|
[Environment.Dev] = true,
|
||||||
|
[Environment.Test] = true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +59,9 @@ local function setStoredValue(name, kind, value)
|
|||||||
object.Value = value
|
object.Value = value
|
||||||
end
|
end
|
||||||
|
|
||||||
local function createAllValues()
|
local function createAllValues(environment)
|
||||||
|
assert(Environment[environment] ~= nil, "Invalid environment")
|
||||||
|
|
||||||
valueContainer = getValueContainer()
|
valueContainer = getValueContainer()
|
||||||
|
|
||||||
if valueContainer == nil then
|
if valueContainer == nil then
|
||||||
@@ -52,20 +71,57 @@ local function createAllValues()
|
|||||||
end
|
end
|
||||||
|
|
||||||
for name, value in pairs(VALUES) do
|
for name, value in pairs(VALUES) do
|
||||||
setStoredValue(name, value.type, value.defaultDevValue)
|
setStoredValue(name, value.type, value.values[environment])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_G[("ROJO_%s_DEV_CREATE"):format(Config.codename:upper())] = createAllValues
|
local function getValue(name)
|
||||||
|
assert(VALUES[name] ~= nil, "Invalid DevSettings name")
|
||||||
|
|
||||||
|
local stored = getStoredValue(name)
|
||||||
|
|
||||||
|
if stored ~= nil then
|
||||||
|
return stored
|
||||||
|
end
|
||||||
|
|
||||||
|
return VALUES[name].values[Environment.User]
|
||||||
|
end
|
||||||
|
|
||||||
local DevSettings = {}
|
local DevSettings = {}
|
||||||
|
|
||||||
|
function DevSettings:createDevSettings()
|
||||||
|
createAllValues(Environment.Dev)
|
||||||
|
end
|
||||||
|
|
||||||
|
function DevSettings:createTestSettings()
|
||||||
|
createAllValues(Environment.Test)
|
||||||
|
end
|
||||||
|
|
||||||
|
function DevSettings:hasChangedValues()
|
||||||
|
return valueContainer ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function DevSettings:resetValues()
|
||||||
|
if valueContainer then
|
||||||
|
valueContainer:Destroy()
|
||||||
|
valueContainer = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function DevSettings:isEnabled()
|
function DevSettings:isEnabled()
|
||||||
return valueContainer ~= nil
|
return valueContainer ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function DevSettings:getLogLevel()
|
function DevSettings:getLogLevel()
|
||||||
return getStoredValue("LogLevel") or VALUES.LogLevel.defaultUserValue
|
return getValue("LogLevel")
|
||||||
|
end
|
||||||
|
|
||||||
|
function DevSettings:shouldTypecheck()
|
||||||
|
return getValue("TypecheckingEnabled")
|
||||||
|
end
|
||||||
|
|
||||||
|
function _G.ROJO_DEV_CREATE()
|
||||||
|
DevSettings:createDevSettings()
|
||||||
end
|
end
|
||||||
|
|
||||||
return DevSettings
|
return DevSettings
|
||||||
81
plugin/src/InstanceMap.lua
Normal file
81
plugin/src/InstanceMap.lua
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
local Logging = require(script.Parent.Logging)
|
||||||
|
|
||||||
|
--[[
|
||||||
|
A bidirectional map between instance IDs and Roblox instances. It lets us
|
||||||
|
keep track of every instance we know about.
|
||||||
|
|
||||||
|
TODO: Track ancestry to catch when stuff moves?
|
||||||
|
]]
|
||||||
|
local InstanceMap = {}
|
||||||
|
InstanceMap.__index = InstanceMap
|
||||||
|
|
||||||
|
function InstanceMap.new()
|
||||||
|
local self = {
|
||||||
|
fromIds = {},
|
||||||
|
fromInstances = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
return setmetatable(self, InstanceMap)
|
||||||
|
end
|
||||||
|
|
||||||
|
function InstanceMap:insert(id, instance)
|
||||||
|
self.fromIds[id] = instance
|
||||||
|
self.fromInstances[instance] = id
|
||||||
|
end
|
||||||
|
|
||||||
|
function InstanceMap:removeId(id)
|
||||||
|
local instance = self.fromIds[id]
|
||||||
|
|
||||||
|
if instance ~= nil then
|
||||||
|
self.fromIds[id] = nil
|
||||||
|
self.fromInstances[instance] = nil
|
||||||
|
else
|
||||||
|
Logging.warn("Attempted to remove nonexistant ID %s", tostring(id))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function InstanceMap:removeInstance(instance)
|
||||||
|
local id = self.fromInstances[instance]
|
||||||
|
|
||||||
|
if id ~= nil then
|
||||||
|
self.fromInstances[instance] = nil
|
||||||
|
self.fromIds[id] = nil
|
||||||
|
else
|
||||||
|
Logging.warn("Attempted to remove nonexistant instance %s", tostring(instance))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function InstanceMap:destroyInstance(instance)
|
||||||
|
local id = self.fromInstances[instance]
|
||||||
|
|
||||||
|
if id ~= nil then
|
||||||
|
self:destroyId(id)
|
||||||
|
else
|
||||||
|
Logging.warn("Attempted to destroy untracked instance %s", tostring(instance))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function InstanceMap:destroyId(id)
|
||||||
|
local instance = self.fromIds[id]
|
||||||
|
self:removeId(id)
|
||||||
|
|
||||||
|
if instance ~= nil then
|
||||||
|
local descendantsToDestroy = {}
|
||||||
|
|
||||||
|
for otherInstance in pairs(self.fromInstances) do
|
||||||
|
if otherInstance:IsDescendantOf(instance) then
|
||||||
|
table.insert(descendantsToDestroy, otherInstance)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, otherInstance in ipairs(descendantsToDestroy) do
|
||||||
|
self:removeInstance(otherInstance)
|
||||||
|
end
|
||||||
|
|
||||||
|
instance:Destroy()
|
||||||
|
else
|
||||||
|
Logging.warn("Attempted to destroy nonexistant ID %s", tostring(id))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return InstanceMap
|
||||||
@@ -1,108 +1,17 @@
|
|||||||
|
local t = require(script.Parent.Parent.t)
|
||||||
|
|
||||||
|
local InstanceMap = require(script.Parent.InstanceMap)
|
||||||
local Logging = require(script.Parent.Logging)
|
local Logging = require(script.Parent.Logging)
|
||||||
|
local setCanonicalProperty = require(script.Parent.setCanonicalProperty)
|
||||||
local function makeInstanceMap()
|
local rojoValueToRobloxValue = require(script.Parent.rojoValueToRobloxValue)
|
||||||
local self = {
|
local Types = require(script.Parent.Types)
|
||||||
fromIds = {},
|
|
||||||
fromInstances = {},
|
|
||||||
}
|
|
||||||
|
|
||||||
function self:insert(id, instance)
|
|
||||||
self.fromIds[id] = instance
|
|
||||||
self.fromInstances[instance] = id
|
|
||||||
end
|
|
||||||
|
|
||||||
function self:removeId(id)
|
|
||||||
local instance = self.fromIds[id]
|
|
||||||
|
|
||||||
if instance ~= nil then
|
|
||||||
self.fromIds[id] = nil
|
|
||||||
self.fromInstances[instance] = nil
|
|
||||||
else
|
|
||||||
Logging.warn("Attempted to remove nonexistant ID %s", tostring(id))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function self:removeInstance(instance)
|
|
||||||
local id = self.fromInstances[instance]
|
|
||||||
|
|
||||||
if id ~= nil then
|
|
||||||
self.fromInstances[instance] = nil
|
|
||||||
self.fromIds[id] = nil
|
|
||||||
else
|
|
||||||
Logging.warn("Attempted to remove nonexistant instance %s", tostring(instance))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function self:destroyId(id)
|
|
||||||
local instance = self.fromIds[id]
|
|
||||||
self:removeId(id)
|
|
||||||
|
|
||||||
if instance ~= nil then
|
|
||||||
local descendantsToDestroy = {}
|
|
||||||
|
|
||||||
for otherInstance in pairs(self.fromInstances) do
|
|
||||||
if otherInstance:IsDescendantOf(instance) then
|
|
||||||
table.insert(descendantsToDestroy, otherInstance)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, otherInstance in ipairs(descendantsToDestroy) do
|
|
||||||
self:removeInstance(otherInstance)
|
|
||||||
end
|
|
||||||
|
|
||||||
instance:Destroy()
|
|
||||||
else
|
|
||||||
Logging.warn("Attempted to destroy nonexistant ID %s", tostring(id))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
local function setProperty(instance, key, value)
|
|
||||||
-- The 'Contents' property of LocalizationTable isn't directly exposed, but
|
|
||||||
-- has corresponding (deprecated) getters and setters.
|
|
||||||
if key == "Contents" and instance.ClassName == "LocalizationTable" then
|
|
||||||
instance:SetContents(value)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If we don't have permissions to access this value at all, we can skip it.
|
|
||||||
local readSuccess, existingValue = pcall(function()
|
|
||||||
return instance[key]
|
|
||||||
end)
|
|
||||||
|
|
||||||
if not readSuccess then
|
|
||||||
-- An error will be thrown if there was a permission issue or if the
|
|
||||||
-- property doesn't exist. In the latter case, we should tell the user
|
|
||||||
-- because it's probably their fault.
|
|
||||||
if existingValue:find("lacking permission") then
|
|
||||||
Logging.trace("Permission error reading property %s on class %s", tostring(key), instance.ClassName)
|
|
||||||
return
|
|
||||||
else
|
|
||||||
error(("Invalid property %s on class %s: %s"):format(tostring(key), instance.ClassName, existingValue), 2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local writeSuccess, err = pcall(function()
|
|
||||||
if existingValue ~= value then
|
|
||||||
instance[key] = value
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
if not writeSuccess then
|
|
||||||
error(("Cannot set property %s on class %s: %s"):format(tostring(key), instance.ClassName, err), 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
local Reconciler = {}
|
local Reconciler = {}
|
||||||
Reconciler.__index = Reconciler
|
Reconciler.__index = Reconciler
|
||||||
|
|
||||||
function Reconciler.new()
|
function Reconciler.new()
|
||||||
local self = {
|
local self = {
|
||||||
instanceMap = makeInstanceMap(),
|
instanceMap = InstanceMap.new(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(self, Reconciler)
|
return setmetatable(self, Reconciler)
|
||||||
@@ -118,11 +27,18 @@ function Reconciler:applyUpdate(requestedIds, virtualInstancesById)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local reconcileSchema = Types.ifEnabled(t.tuple(
|
||||||
|
t.map(t.string, Types.VirtualInstance),
|
||||||
|
t.string,
|
||||||
|
t.Instance
|
||||||
|
))
|
||||||
--[[
|
--[[
|
||||||
Update an existing instance, including its properties and children, to match
|
Update an existing instance, including its properties and children, to match
|
||||||
the given information.
|
the given information.
|
||||||
]]
|
]]
|
||||||
function Reconciler:reconcile(virtualInstancesById, id, instance)
|
function Reconciler:reconcile(virtualInstancesById, id, instance)
|
||||||
|
assert(reconcileSchema(virtualInstancesById, id, instance))
|
||||||
|
|
||||||
local virtualInstance = virtualInstancesById[id]
|
local virtualInstance = virtualInstancesById[id]
|
||||||
|
|
||||||
-- If an instance changes ClassName, we assume it's very different. That's
|
-- If an instance changes ClassName, we assume it's very different. That's
|
||||||
@@ -137,10 +53,10 @@ function Reconciler:reconcile(virtualInstancesById, id, instance)
|
|||||||
self.instanceMap:insert(id, instance)
|
self.instanceMap:insert(id, instance)
|
||||||
|
|
||||||
-- Some instances don't like being named, even if their name already matches
|
-- Some instances don't like being named, even if their name already matches
|
||||||
setProperty(instance, "Name", virtualInstance.Name)
|
setCanonicalProperty(instance, "Name", virtualInstance.Name)
|
||||||
|
|
||||||
for key, value in pairs(virtualInstance.Properties) do
|
for key, value in pairs(virtualInstance.Properties) do
|
||||||
setProperty(instance, key, value.Value)
|
setCanonicalProperty(instance, key, rojoValueToRobloxValue(value))
|
||||||
end
|
end
|
||||||
|
|
||||||
local existingChildren = instance:GetChildren()
|
local existingChildren = instance:GetChildren()
|
||||||
@@ -175,10 +91,17 @@ function Reconciler:reconcile(virtualInstancesById, id, instance)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self:__shouldClearUnknownInstances(virtualInstance) then
|
local shouldClearUnknown = self:__shouldClearUnknownChildren(virtualInstance)
|
||||||
for existingChildInstance in pairs(unvisitedExistingChildren) do
|
|
||||||
self.instanceMap:removeInstance(existingChildInstance)
|
for existingChildInstance in pairs(unvisitedExistingChildren) do
|
||||||
existingChildInstance:Destroy()
|
local childId = self.instanceMap.fromInstances[existingChildInstance]
|
||||||
|
|
||||||
|
if childId == nil then
|
||||||
|
if shouldClearUnknown then
|
||||||
|
existingChildInstance:Destroy()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.instanceMap:destroyInstance(existingChildInstance)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -194,16 +117,13 @@ function Reconciler:reconcile(virtualInstancesById, id, instance)
|
|||||||
|
|
||||||
-- Some instances, like services, don't like having their Parent
|
-- Some instances, like services, don't like having their Parent
|
||||||
-- property poked, even if we're setting it to the same value.
|
-- property poked, even if we're setting it to the same value.
|
||||||
setProperty(instance, "Parent", parent)
|
setCanonicalProperty(instance, "Parent", parent)
|
||||||
if instance.Parent ~= parent then
|
|
||||||
instance.Parent = parent
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
function Reconciler:__shouldClearUnknownInstances(virtualInstance)
|
function Reconciler:__shouldClearUnknownChildren(virtualInstance)
|
||||||
if virtualInstance.Metadata ~= nil then
|
if virtualInstance.Metadata ~= nil then
|
||||||
return not virtualInstance.Metadata.ignoreUnknownInstances
|
return not virtualInstance.Metadata.ignoreUnknownInstances
|
||||||
else
|
else
|
||||||
@@ -211,29 +131,44 @@ function Reconciler:__shouldClearUnknownInstances(virtualInstance)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local reifySchema = Types.ifEnabled(t.tuple(
|
||||||
|
t.map(t.string, Types.VirtualInstance),
|
||||||
|
t.string,
|
||||||
|
t.Instance
|
||||||
|
))
|
||||||
|
|
||||||
function Reconciler:__reify(virtualInstancesById, id, parent)
|
function Reconciler:__reify(virtualInstancesById, id, parent)
|
||||||
|
assert(reifySchema(virtualInstancesById, id, parent))
|
||||||
|
|
||||||
local virtualInstance = virtualInstancesById[id]
|
local virtualInstance = virtualInstancesById[id]
|
||||||
|
|
||||||
local instance = Instance.new(virtualInstance.ClassName)
|
local instance = Instance.new(virtualInstance.ClassName)
|
||||||
|
|
||||||
for key, value in pairs(virtualInstance.Properties) do
|
for key, value in pairs(virtualInstance.Properties) do
|
||||||
-- TODO: Branch on value.Type
|
setCanonicalProperty(instance, key, rojoValueToRobloxValue(value))
|
||||||
setProperty(instance, key, value.Value)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
instance.Name = virtualInstance.Name
|
setCanonicalProperty(instance, "Name", virtualInstance.Name)
|
||||||
|
|
||||||
for _, childId in ipairs(virtualInstance.Children) do
|
for _, childId in ipairs(virtualInstance.Children) do
|
||||||
self:__reify(virtualInstancesById, childId, instance)
|
self:__reify(virtualInstancesById, childId, instance)
|
||||||
end
|
end
|
||||||
|
|
||||||
setProperty(instance, "Parent", parent)
|
setCanonicalProperty(instance, "Parent", parent)
|
||||||
self.instanceMap:insert(id, instance)
|
self.instanceMap:insert(id, instance)
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local applyUpdatePieceSchema = Types.ifEnabled(t.tuple(
|
||||||
|
t.string,
|
||||||
|
t.map(t.string, t.boolean),
|
||||||
|
t.map(t.string, Types.VirtualInstance)
|
||||||
|
))
|
||||||
|
|
||||||
function Reconciler:__applyUpdatePiece(id, visitedIds, virtualInstancesById)
|
function Reconciler:__applyUpdatePiece(id, visitedIds, virtualInstancesById)
|
||||||
|
assert(applyUpdatePieceSchema(id, visitedIds, virtualInstancesById))
|
||||||
|
|
||||||
if visitedIds[id] then
|
if visitedIds[id] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
218
plugin/src/Reconciler.spec.lua
Normal file
218
plugin/src/Reconciler.spec.lua
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
local Reconciler = require(script.Parent.Reconciler)
|
||||||
|
|
||||||
|
return function()
|
||||||
|
it("should leave instances alone if there's nothing specified", function()
|
||||||
|
local instance = Instance.new("Folder")
|
||||||
|
instance.Name = "TestFolder"
|
||||||
|
|
||||||
|
local instanceId = "test-id"
|
||||||
|
local virtualInstancesById = {
|
||||||
|
[instanceId] = {
|
||||||
|
Name = "TestFolder",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {},
|
||||||
|
Properties = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local reconciler = Reconciler.new()
|
||||||
|
reconciler:reconcile(virtualInstancesById, instanceId, instance)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should assign names from virtual instances", function()
|
||||||
|
local instance = Instance.new("Folder")
|
||||||
|
instance.Name = "InitialName"
|
||||||
|
|
||||||
|
local instanceId = "test-id"
|
||||||
|
local virtualInstancesById = {
|
||||||
|
[instanceId] = {
|
||||||
|
Name = "NewName",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {},
|
||||||
|
Properties = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local reconciler = Reconciler.new()
|
||||||
|
reconciler:reconcile(virtualInstancesById, instanceId, instance)
|
||||||
|
|
||||||
|
expect(instance.Name).to.equal("NewName")
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should assign properties from virtual instances", function()
|
||||||
|
local instance = Instance.new("IntValue")
|
||||||
|
instance.Name = "TestValue"
|
||||||
|
instance.Value = 5
|
||||||
|
|
||||||
|
local instanceId = "test-id"
|
||||||
|
local virtualInstancesById = {
|
||||||
|
[instanceId] = {
|
||||||
|
Name = "TestValue",
|
||||||
|
ClassName = "IntValue",
|
||||||
|
Children = {},
|
||||||
|
Properties = {
|
||||||
|
Value = {
|
||||||
|
Type = "Int32",
|
||||||
|
Value = 9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local reconciler = Reconciler.new()
|
||||||
|
reconciler:reconcile(virtualInstancesById, instanceId, instance)
|
||||||
|
|
||||||
|
expect(instance.Value).to.equal(9)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should wipe unknown children by default", function()
|
||||||
|
local parent = Instance.new("Folder")
|
||||||
|
parent.Name = "Parent"
|
||||||
|
|
||||||
|
local child = Instance.new("Folder")
|
||||||
|
child.Name = "Child"
|
||||||
|
|
||||||
|
local parentId = "test-id"
|
||||||
|
local virtualInstancesById = {
|
||||||
|
[parentId] = {
|
||||||
|
Name = "Parent",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {},
|
||||||
|
Properties = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local reconciler = Reconciler.new()
|
||||||
|
reconciler:reconcile(virtualInstancesById, parentId, parent)
|
||||||
|
|
||||||
|
expect(#parent:GetChildren()).to.equal(0)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should preserve unknown children if ignoreUnknownInstances is set", function()
|
||||||
|
local parent = Instance.new("Folder")
|
||||||
|
parent.Name = "Parent"
|
||||||
|
|
||||||
|
local child = Instance.new("Folder")
|
||||||
|
child.Parent = parent
|
||||||
|
child.Name = "Child"
|
||||||
|
|
||||||
|
local parentId = "test-id"
|
||||||
|
local virtualInstancesById = {
|
||||||
|
[parentId] = {
|
||||||
|
Name = "Parent",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {},
|
||||||
|
Properties = {},
|
||||||
|
Metadata = {
|
||||||
|
ignoreUnknownInstances = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local reconciler = Reconciler.new()
|
||||||
|
reconciler:reconcile(virtualInstancesById, parentId, parent)
|
||||||
|
|
||||||
|
expect(child.Parent).to.equal(parent)
|
||||||
|
expect(#parent:GetChildren()).to.equal(1)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should remove known removed children", function()
|
||||||
|
local parent = Instance.new("Folder")
|
||||||
|
parent.Name = "Parent"
|
||||||
|
|
||||||
|
local child = Instance.new("Folder")
|
||||||
|
child.Parent = parent
|
||||||
|
child.Name = "Child"
|
||||||
|
|
||||||
|
local parentId = "parent-id"
|
||||||
|
local childId = "child-id"
|
||||||
|
|
||||||
|
local reconciler = Reconciler.new()
|
||||||
|
|
||||||
|
local virtualInstancesById = {
|
||||||
|
[parentId] = {
|
||||||
|
Name = "Parent",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {childId},
|
||||||
|
Properties = {},
|
||||||
|
},
|
||||||
|
[childId] = {
|
||||||
|
Name = "Child",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {},
|
||||||
|
Properties = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
reconciler:reconcile(virtualInstancesById, parentId, parent)
|
||||||
|
|
||||||
|
expect(child.Parent).to.equal(parent)
|
||||||
|
expect(#parent:GetChildren()).to.equal(1)
|
||||||
|
|
||||||
|
local newVirtualInstances = {
|
||||||
|
[parentId] = {
|
||||||
|
Name = "Parent",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {},
|
||||||
|
Properties = {},
|
||||||
|
},
|
||||||
|
[childId] = nil,
|
||||||
|
}
|
||||||
|
reconciler:reconcile(newVirtualInstances, parentId, parent)
|
||||||
|
|
||||||
|
expect(child.Parent).to.equal(nil)
|
||||||
|
expect(#parent:GetChildren()).to.equal(0)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should remove known removed children if ignoreUnknownInstances is set", function()
|
||||||
|
local parent = Instance.new("Folder")
|
||||||
|
parent.Name = "Parent"
|
||||||
|
|
||||||
|
local child = Instance.new("Folder")
|
||||||
|
child.Parent = parent
|
||||||
|
child.Name = "Child"
|
||||||
|
|
||||||
|
local parentId = "parent-id"
|
||||||
|
local childId = "child-id"
|
||||||
|
|
||||||
|
local reconciler = Reconciler.new()
|
||||||
|
|
||||||
|
local virtualInstancesById = {
|
||||||
|
[parentId] = {
|
||||||
|
Name = "Parent",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {childId},
|
||||||
|
Properties = {},
|
||||||
|
Metadata = {
|
||||||
|
ignoreUnknownInstances = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[childId] = {
|
||||||
|
Name = "Child",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {},
|
||||||
|
Properties = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
reconciler:reconcile(virtualInstancesById, parentId, parent)
|
||||||
|
|
||||||
|
expect(child.Parent).to.equal(parent)
|
||||||
|
expect(#parent:GetChildren()).to.equal(1)
|
||||||
|
|
||||||
|
local newVirtualInstances = {
|
||||||
|
[parentId] = {
|
||||||
|
Name = "Parent",
|
||||||
|
ClassName = "Folder",
|
||||||
|
Children = {},
|
||||||
|
Properties = {},
|
||||||
|
Metadata = {
|
||||||
|
ignoreUnknownInstances = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
[childId] = nil,
|
||||||
|
}
|
||||||
|
reconciler:reconcile(newVirtualInstances, parentId, parent)
|
||||||
|
|
||||||
|
expect(child.Parent).to.equal(nil)
|
||||||
|
expect(#parent:GetChildren()).to.equal(0)
|
||||||
|
end)
|
||||||
|
end
|
||||||
36
plugin/src/Types.lua
Normal file
36
plugin/src/Types.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
local t = require(script.Parent.Parent.t)
|
||||||
|
|
||||||
|
local DevSettings = require(script.Parent.DevSettings)
|
||||||
|
|
||||||
|
local VirtualValue = t.interface({
|
||||||
|
Type = t.string,
|
||||||
|
Value = t.optional(t.any),
|
||||||
|
})
|
||||||
|
|
||||||
|
local VirtualMetadata = t.interface({
|
||||||
|
ignoreUnknownInstances = t.optional(t.boolean),
|
||||||
|
})
|
||||||
|
|
||||||
|
local VirtualInstance = t.interface({
|
||||||
|
Name = t.string,
|
||||||
|
ClassName = t.string,
|
||||||
|
Properties = t.map(t.string, VirtualValue),
|
||||||
|
Metadata = t.optional(VirtualMetadata)
|
||||||
|
})
|
||||||
|
|
||||||
|
local function ifEnabled(innerCheck)
|
||||||
|
return function(...)
|
||||||
|
if DevSettings:shouldTypecheck() then
|
||||||
|
return innerCheck(...)
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
ifEnabled = ifEnabled,
|
||||||
|
VirtualInstance = VirtualInstance,
|
||||||
|
VirtualMetadata = VirtualMetadata,
|
||||||
|
VirtualValue = VirtualValue,
|
||||||
|
}
|
||||||
@@ -4,16 +4,14 @@ end
|
|||||||
|
|
||||||
local Roact = require(script.Parent.Roact)
|
local Roact = require(script.Parent.Roact)
|
||||||
|
|
||||||
Roact.setGlobalConfig({
|
|
||||||
elementTracing = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
local App = require(script.Components.App)
|
local App = require(script.Components.App)
|
||||||
|
|
||||||
local app = Roact.createElement(App, {
|
local app = Roact.createElement(App, {
|
||||||
plugin = plugin,
|
plugin = plugin,
|
||||||
})
|
})
|
||||||
|
|
||||||
Roact.mount(app, game:GetService("CoreGui"), "Rojo UI")
|
local tree = Roact.mount(app, game:GetService("CoreGui"), "Rojo UI")
|
||||||
|
|
||||||
-- TODO: Detect another instance of Rojo coming online and shut down this one.
|
plugin.Unloading:Connect(function()
|
||||||
|
Roact.unmount(tree)
|
||||||
|
end)
|
||||||
28
plugin/src/preloadAssets.lua
Normal file
28
plugin/src/preloadAssets.lua
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
local ContentProvider = game:GetService("ContentProvider")
|
||||||
|
|
||||||
|
local Logging = require(script.Parent.Logging)
|
||||||
|
local Assets = require(script.Parent.Assets)
|
||||||
|
|
||||||
|
local function preloadAssets()
|
||||||
|
local contentUrls = {}
|
||||||
|
|
||||||
|
for _, sprite in pairs(Assets.Sprites) do
|
||||||
|
table.insert(contentUrls, sprite.asset)
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, slice in pairs(Assets.Slices) do
|
||||||
|
table.insert(contentUrls, slice.asset)
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, url in pairs(Assets.Images) do
|
||||||
|
table.insert(contentUrls, url)
|
||||||
|
end
|
||||||
|
|
||||||
|
Logging.trace("Preloading assets: %s", table.concat(contentUrls, ", "))
|
||||||
|
|
||||||
|
coroutine.wrap(function()
|
||||||
|
ContentProvider:PreloadAsync(contentUrls)
|
||||||
|
end)()
|
||||||
|
end
|
||||||
|
|
||||||
|
return preloadAssets
|
||||||
38
plugin/src/rojoValueToRobloxValue.lua
Normal file
38
plugin/src/rojoValueToRobloxValue.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
local primitiveTypes = {
|
||||||
|
Bool = true,
|
||||||
|
Enum = true,
|
||||||
|
Float32 = true,
|
||||||
|
Float64 = true,
|
||||||
|
Int32 = true,
|
||||||
|
Int64 = true,
|
||||||
|
String = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
local directConstructors = {
|
||||||
|
CFrame = CFrame.new,
|
||||||
|
Color3 = Color3.new,
|
||||||
|
Color3uint8 = Color3.fromRGB,
|
||||||
|
Rect = Rect.new,
|
||||||
|
UDim = UDim.new,
|
||||||
|
UDim2 = UDim2.new,
|
||||||
|
Vector2 = Vector2.new,
|
||||||
|
Vector2int16 = Vector2int16.new,
|
||||||
|
Vector3 = Vector3.new,
|
||||||
|
Vector3int16 = Vector3int16.new,
|
||||||
|
}
|
||||||
|
|
||||||
|
local function rojoValueToRobloxValue(value)
|
||||||
|
if primitiveTypes[value.Type] then
|
||||||
|
return value.Value
|
||||||
|
end
|
||||||
|
|
||||||
|
local constructor = directConstructors[value.Type]
|
||||||
|
if constructor ~= nil then
|
||||||
|
return constructor(unpack(value.Value))
|
||||||
|
end
|
||||||
|
|
||||||
|
local errorMessage = ("The Rojo plugin doesn't know how to handle values of type %q yet!"):format(tostring(value.Type))
|
||||||
|
error(errorMessage)
|
||||||
|
end
|
||||||
|
|
||||||
|
return rojoValueToRobloxValue
|
||||||
40
plugin/src/rojoValueToRobloxValue.spec.lua
Normal file
40
plugin/src/rojoValueToRobloxValue.spec.lua
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
local rojoValueToRobloxValue = require(script.Parent.rojoValueToRobloxValue)
|
||||||
|
|
||||||
|
return function()
|
||||||
|
it("should convert primitives", function()
|
||||||
|
local inputString = {
|
||||||
|
Type = "String",
|
||||||
|
Value = "Hello, world!",
|
||||||
|
}
|
||||||
|
|
||||||
|
local inputFloat32 = {
|
||||||
|
Type = "Float32",
|
||||||
|
Value = 12341.512,
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(rojoValueToRobloxValue(inputString)).to.equal(inputString.Value)
|
||||||
|
expect(rojoValueToRobloxValue(inputFloat32)).to.equal(inputFloat32.Value)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should convert properties with direct constructors", function()
|
||||||
|
local inputColor3 = {
|
||||||
|
Type = "Color3",
|
||||||
|
Value = {0, 1, 0.5},
|
||||||
|
}
|
||||||
|
local outputColor3 = Color3.new(0, 1, 0.5)
|
||||||
|
|
||||||
|
local inputCFrame = {
|
||||||
|
Type = "CFrame",
|
||||||
|
Value = {
|
||||||
|
1, 2, 3,
|
||||||
|
4, 5, 6,
|
||||||
|
7, 8, 9,
|
||||||
|
10, 11, 12,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
local outputCFrame = CFrame.new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
|
||||||
|
|
||||||
|
expect(rojoValueToRobloxValue(inputColor3)).to.equal(outputColor3)
|
||||||
|
expect(rojoValueToRobloxValue(inputCFrame)).to.equal(outputCFrame)
|
||||||
|
end)
|
||||||
|
end
|
||||||
57
plugin/src/setCanonicalProperty.lua
Normal file
57
plugin/src/setCanonicalProperty.lua
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
local Logging = require(script.Parent.Logging)
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Attempts to set a property on the given instance.
|
||||||
|
|
||||||
|
This method deals in terms of what Rojo calls 'canonical properties', which
|
||||||
|
don't necessarily exist either in serialization or in Lua-reflected APIs,
|
||||||
|
but may be present in the API dump.
|
||||||
|
|
||||||
|
Ideally, canonical properties map 1:1 with properties we can assign, but in
|
||||||
|
some cases like LocalizationTable contents and CollectionService tags, we
|
||||||
|
have to read/write properties a little differently.
|
||||||
|
]]
|
||||||
|
local function setCanonicalProperty(instance, key, value)
|
||||||
|
-- The 'Contents' property of LocalizationTable isn't directly exposed, but
|
||||||
|
-- has corresponding (deprecated) getters and setters.
|
||||||
|
if instance.ClassName == "LocalizationTable" and key == "Contents" then
|
||||||
|
instance:SetContents(value)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Temporary workaround for fixing issue #141 in this specific case.
|
||||||
|
if instance.ClassName == "Lighting" and key == "Technology" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If we don't have permissions to access this value at all, we can skip it.
|
||||||
|
local readSuccess, existingValue = pcall(function()
|
||||||
|
return instance[key]
|
||||||
|
end)
|
||||||
|
|
||||||
|
if not readSuccess then
|
||||||
|
-- An error will be thrown if there was a permission issue or if the
|
||||||
|
-- property doesn't exist. In the latter case, we should tell the user
|
||||||
|
-- because it's probably their fault.
|
||||||
|
if existingValue:find("lacking permission") then
|
||||||
|
Logging.trace("Permission error reading property %s on class %s", tostring(key), instance.ClassName)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
error(("Invalid property %s on class %s: %s"):format(tostring(key), instance.ClassName, existingValue), 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local writeSuccess, err = pcall(function()
|
||||||
|
if existingValue ~= value then
|
||||||
|
instance[key] = value
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if not writeSuccess then
|
||||||
|
error(("Cannot set property %s on class %s: %s"):format(tostring(key), instance.ClassName, err), 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return setCanonicalProperty
|
||||||
@@ -1,2 +1,19 @@
|
|||||||
local TestEZ = require(game.ReplicatedStorage.TestEZ)
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
TestEZ.TestBootstrap:run(game.ReplicatedStorage.Rojo.plugin)
|
|
||||||
|
local TestEZ = require(ReplicatedStorage.TestEZ)
|
||||||
|
|
||||||
|
local Rojo = ReplicatedStorage.Rojo
|
||||||
|
|
||||||
|
local DevSettings = require(Rojo.Plugin.DevSettings)
|
||||||
|
|
||||||
|
local setDevSettings = not DevSettings:hasChangedValues()
|
||||||
|
|
||||||
|
if setDevSettings then
|
||||||
|
DevSettings:createTestSettings()
|
||||||
|
end
|
||||||
|
|
||||||
|
TestEZ.TestBootstrap:run({Rojo.Plugin})
|
||||||
|
|
||||||
|
if setDevSettings then
|
||||||
|
DevSettings:resetValues()
|
||||||
|
end
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rojo"
|
name = "rojo"
|
||||||
version = "0.5.0-alpha.4"
|
version = "0.5.0-alpha.8"
|
||||||
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
||||||
description = "A tool to create robust Roblox projects"
|
description = "A tool to create robust Roblox projects"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/LPGhatguy/rojo"
|
repository = "https://github.com/LPGhatguy/rojo"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
server-plugins = []
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "librojo"
|
name = "librojo"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
@@ -15,25 +19,24 @@ path = "src/lib.rs"
|
|||||||
name = "rojo"
|
name = "rojo"
|
||||||
path = "src/bin.rs"
|
path = "src/bin.rs"
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
bundle-plugin = []
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.27"
|
clap = "2.27"
|
||||||
csv = "1.0"
|
csv = "1.0"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
failure = "0.1.3"
|
failure = "0.1.3"
|
||||||
|
futures = "0.1"
|
||||||
|
hyper = "0.12"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
maplit = "1.0.1"
|
maplit = "1.0.1"
|
||||||
notify = "4.0"
|
notify = "4.0"
|
||||||
rand = "0.4"
|
rbx_binary = "0.4.0"
|
||||||
rbx_binary = "0.2.0"
|
rbx_dom_weak = "1.3.0"
|
||||||
rbx_tree = "0.2.0"
|
rbx_xml = "0.6.0"
|
||||||
rbx_xml = "0.2.0"
|
rbx_reflection = "2.0.374"
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
reqwest = "0.9.5"
|
reqwest = "0.9.5"
|
||||||
rouille = "2.1"
|
rlua = "0.16"
|
||||||
|
ritz = "0.1.0"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
@@ -43,5 +46,5 @@ uuid = { version = "0.7", features = ["v4", "serde"] }
|
|||||||
tempfile = "3.0"
|
tempfile = "3.0"
|
||||||
walkdir = "2.1"
|
walkdir = "2.1"
|
||||||
lazy_static = "1.2"
|
lazy_static = "1.2"
|
||||||
pretty_assertions = "0.5.1"
|
pretty_assertions = "0.6.1"
|
||||||
paste = "0.1"
|
paste = "0.1"
|
||||||
43
server/assets/index.css
Normal file
43
server/assets/index.css
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
font-family: sans-serif;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
padding: 1rem;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 60rem;
|
||||||
|
background-color: #efefef;
|
||||||
|
border: 1px solid #666;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 2rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.docs {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Rojo</title>
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
font-family: sans-serif;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main {
|
|
||||||
padding: 1rem;
|
|
||||||
text-align: center;
|
|
||||||
margin: 0 auto;
|
|
||||||
width: 100%;
|
|
||||||
max-width: 60rem;
|
|
||||||
background-color: #efefef;
|
|
||||||
border: 1px solid #666;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: 2rem;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.docs {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="main">
|
|
||||||
<h1 class="title">Rojo Live Sync is up and running!</h1>
|
|
||||||
<a class="docs" href="https://lpghatguy.github.io/rojo">Rojo Documentation</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
66
server/assets/place.project.json
Normal file
66
server/assets/place.project.json
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"name": "[placeholder]",
|
||||||
|
"tree": {
|
||||||
|
"$className": "DataModel",
|
||||||
|
"HttpService": {
|
||||||
|
"$className": "HttpService",
|
||||||
|
"$properties": {
|
||||||
|
"HttpEnabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Lighting": {
|
||||||
|
"$className": "Lighting",
|
||||||
|
"$properties": {
|
||||||
|
"Ambient": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"Brightness": 2,
|
||||||
|
"GlobalShadows": true,
|
||||||
|
"Outlines": false,
|
||||||
|
"Technology": "Voxel"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ReplicatedStorage": {
|
||||||
|
"$className": "ReplicatedStorage",
|
||||||
|
"Source": {
|
||||||
|
"$path": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"SoundService": {
|
||||||
|
"$className": "SoundService",
|
||||||
|
"$properties": {
|
||||||
|
"RespectFilteringEnabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Workspace": {
|
||||||
|
"$className": "Workspace",
|
||||||
|
"$properties": {
|
||||||
|
"FilteringEnabled": true
|
||||||
|
},
|
||||||
|
"Baseplate": {
|
||||||
|
"$className": "Part",
|
||||||
|
"$properties": {
|
||||||
|
"Anchored": true,
|
||||||
|
"Color": [
|
||||||
|
0.38823,
|
||||||
|
0.37254,
|
||||||
|
0.38823
|
||||||
|
],
|
||||||
|
"Locked": true,
|
||||||
|
"Position": [
|
||||||
|
0,
|
||||||
|
-10,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"Size": [
|
||||||
|
512,
|
||||||
|
20,
|
||||||
|
512
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,9 +8,10 @@ use log::info;
|
|||||||
use failure::Fail;
|
use failure::Fail;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
rbx_session::construct_oneoff_tree,
|
|
||||||
project::{Project, ProjectLoadFuzzyError},
|
|
||||||
imfs::{Imfs, FsError},
|
imfs::{Imfs, FsError},
|
||||||
|
project::{Project, ProjectLoadFuzzyError},
|
||||||
|
rbx_session::construct_oneoff_tree,
|
||||||
|
rbx_snapshot::SnapshotError,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
@@ -59,6 +60,9 @@ pub enum BuildError {
|
|||||||
|
|
||||||
#[fail(display = "{}", _0)]
|
#[fail(display = "{}", _0)]
|
||||||
FsError(#[fail(cause)] FsError),
|
FsError(#[fail(cause)] FsError),
|
||||||
|
|
||||||
|
#[fail(display = "{}", _0)]
|
||||||
|
SnapshotError(#[fail(cause)] SnapshotError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_from!(BuildError {
|
impl_from!(BuildError {
|
||||||
@@ -67,6 +71,7 @@ impl_from!(BuildError {
|
|||||||
rbx_xml::EncodeError => XmlModelEncodeError,
|
rbx_xml::EncodeError => XmlModelEncodeError,
|
||||||
rbx_binary::EncodeError => BinaryModelEncodeError,
|
rbx_binary::EncodeError => BinaryModelEncodeError,
|
||||||
FsError => FsError,
|
FsError => FsError,
|
||||||
|
SnapshotError => SnapshotError,
|
||||||
});
|
});
|
||||||
|
|
||||||
pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
|
pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
|
||||||
@@ -86,7 +91,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
|
|||||||
|
|
||||||
let mut imfs = Imfs::new();
|
let mut imfs = Imfs::new();
|
||||||
imfs.add_roots_from_project(&project)?;
|
imfs.add_roots_from_project(&project)?;
|
||||||
let tree = construct_oneoff_tree(&project, &imfs);
|
let tree = construct_oneoff_tree(&project, &imfs)?;
|
||||||
let mut file = File::create(&options.output_file)?;
|
let mut file = File::create(&options.output_file)?;
|
||||||
|
|
||||||
match output_kind {
|
match output_kind {
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ use failure::Fail;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
project::{Project, ProjectLoadFuzzyError},
|
project::{Project, ProjectLoadFuzzyError},
|
||||||
web::Server,
|
web::LiveServer,
|
||||||
imfs::FsError,
|
imfs::FsError,
|
||||||
live_session::LiveSession,
|
live_session::{LiveSession, LiveSessionError},
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_PORT: u16 = 34872;
|
const DEFAULT_PORT: u16 = 34872;
|
||||||
@@ -28,11 +28,15 @@ pub enum ServeError {
|
|||||||
|
|
||||||
#[fail(display = "{}", _0)]
|
#[fail(display = "{}", _0)]
|
||||||
FsError(#[fail(cause)] FsError),
|
FsError(#[fail(cause)] FsError),
|
||||||
|
|
||||||
|
#[fail(display = "{}", _0)]
|
||||||
|
LiveSessionError(#[fail(cause)] LiveSessionError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_from!(ServeError {
|
impl_from!(ServeError {
|
||||||
ProjectLoadFuzzyError => ProjectLoadError,
|
ProjectLoadFuzzyError => ProjectLoadError,
|
||||||
FsError => FsError,
|
FsError => FsError,
|
||||||
|
LiveSessionError => LiveSessionError,
|
||||||
});
|
});
|
||||||
|
|
||||||
pub fn serve(options: &ServeOptions) -> Result<(), ServeError> {
|
pub fn serve(options: &ServeOptions) -> Result<(), ServeError> {
|
||||||
@@ -45,7 +49,7 @@ pub fn serve(options: &ServeOptions) -> Result<(), ServeError> {
|
|||||||
info!("Using project {:#?}", project);
|
info!("Using project {:#?}", project);
|
||||||
|
|
||||||
let live_session = Arc::new(LiveSession::new(Arc::clone(&project))?);
|
let live_session = Arc::new(LiveSession::new(Arc::clone(&project))?);
|
||||||
let server = Server::new(Arc::clone(&live_session));
|
let server = LiveServer::new(live_session);
|
||||||
|
|
||||||
let port = options.port
|
let port = options.port
|
||||||
.or(project.serve_port)
|
.or(project.serve_port)
|
||||||
@@ -53,7 +57,7 @@ pub fn serve(options: &ServeOptions) -> Result<(), ServeError> {
|
|||||||
|
|
||||||
println!("Rojo server listening on port {}", port);
|
println!("Rojo server listening on port {}", port);
|
||||||
|
|
||||||
server.listen(port);
|
server.start(port);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -9,9 +9,10 @@ use failure::Fail;
|
|||||||
use reqwest::header::{ACCEPT, USER_AGENT, CONTENT_TYPE, COOKIE};
|
use reqwest::header::{ACCEPT, USER_AGENT, CONTENT_TYPE, COOKIE};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
rbx_session::construct_oneoff_tree,
|
|
||||||
project::{Project, ProjectLoadFuzzyError},
|
|
||||||
imfs::{Imfs, FsError},
|
imfs::{Imfs, FsError},
|
||||||
|
project::{Project, ProjectLoadFuzzyError},
|
||||||
|
rbx_session::construct_oneoff_tree,
|
||||||
|
rbx_snapshot::SnapshotError,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
@@ -36,6 +37,9 @@ pub enum UploadError {
|
|||||||
|
|
||||||
#[fail(display = "{}", _0)]
|
#[fail(display = "{}", _0)]
|
||||||
FsError(#[fail(cause)] FsError),
|
FsError(#[fail(cause)] FsError),
|
||||||
|
|
||||||
|
#[fail(display = "{}", _0)]
|
||||||
|
SnapshotError(#[fail(cause)] SnapshotError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_from!(UploadError {
|
impl_from!(UploadError {
|
||||||
@@ -44,6 +48,7 @@ impl_from!(UploadError {
|
|||||||
reqwest::Error => HttpError,
|
reqwest::Error => HttpError,
|
||||||
rbx_xml::EncodeError => XmlModelEncodeError,
|
rbx_xml::EncodeError => XmlModelEncodeError,
|
||||||
FsError => FsError,
|
FsError => FsError,
|
||||||
|
SnapshotError => SnapshotError,
|
||||||
});
|
});
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -67,7 +72,7 @@ pub fn upload(options: &UploadOptions) -> Result<(), UploadError> {
|
|||||||
|
|
||||||
let mut imfs = Imfs::new();
|
let mut imfs = Imfs::new();
|
||||||
imfs.add_roots_from_project(&project)?;
|
imfs.add_roots_from_project(&project)?;
|
||||||
let tree = construct_oneoff_tree(&project, &imfs);
|
let tree = construct_oneoff_tree(&project, &imfs)?;
|
||||||
|
|
||||||
let root_id = tree.get_root_id();
|
let root_id = tree.get_root_id();
|
||||||
let mut contents = Vec::new();
|
let mut contents = Vec::new();
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
cmp::Ordering,
|
||||||
path::{self, Path, PathBuf},
|
collections::{HashMap, HashSet, BTreeSet},
|
||||||
fmt,
|
fmt,
|
||||||
fs,
|
fs,
|
||||||
io,
|
io,
|
||||||
|
path::{self, Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use failure::Fail;
|
use failure::Fail;
|
||||||
@@ -237,7 +238,7 @@ impl Imfs {
|
|||||||
} else if metadata.is_dir() {
|
} else if metadata.is_dir() {
|
||||||
let item = ImfsItem::Directory(ImfsDirectory {
|
let item = ImfsItem::Directory(ImfsDirectory {
|
||||||
path: path.to_path_buf(),
|
path: path.to_path_buf(),
|
||||||
children: HashSet::new(),
|
children: BTreeSet::new(),
|
||||||
});
|
});
|
||||||
|
|
||||||
self.items.insert(path.to_path_buf(), item);
|
self.items.insert(path.to_path_buf(), item);
|
||||||
@@ -285,19 +286,43 @@ impl Imfs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct ImfsFile {
|
pub struct ImfsFile {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
pub contents: Vec<u8>,
|
pub contents: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
impl PartialOrd for ImfsFile {
|
||||||
pub struct ImfsDirectory {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
pub path: PathBuf,
|
Some(self.cmp(other))
|
||||||
pub children: HashSet<PathBuf>,
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
impl Ord for ImfsFile {
|
||||||
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
|
self.path.cmp(&other.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
pub struct ImfsDirectory {
|
||||||
|
pub path: PathBuf,
|
||||||
|
pub children: BTreeSet<PathBuf>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for ImfsDirectory {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
|
Some(self.cmp(other))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for ImfsDirectory {
|
||||||
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
|
self.path.cmp(&other.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
pub enum ImfsItem {
|
pub enum ImfsItem {
|
||||||
File(ImfsFile),
|
File(ImfsFile),
|
||||||
Directory(ImfsDirectory),
|
Directory(ImfsDirectory),
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![recursion_limit="128"]
|
||||||
|
|
||||||
// Macros
|
// Macros
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod impl_from;
|
pub mod impl_from;
|
||||||
@@ -17,4 +19,3 @@ pub mod session_id;
|
|||||||
pub mod snapshot_reconciler;
|
pub mod snapshot_reconciler;
|
||||||
pub mod visualize;
|
pub mod visualize;
|
||||||
pub mod web;
|
pub mod web;
|
||||||
pub mod web_util;
|
|
||||||
@@ -1,21 +1,40 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
collections::HashSet,
|
||||||
|
mem,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use failure::Fail;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
fs_watcher::FsWatcher,
|
fs_watcher::FsWatcher,
|
||||||
imfs::{Imfs, FsError},
|
imfs::{Imfs, FsError},
|
||||||
message_queue::MessageQueue,
|
message_queue::MessageQueue,
|
||||||
project::Project,
|
project::Project,
|
||||||
rbx_session::RbxSession,
|
rbx_session::RbxSession,
|
||||||
|
rbx_snapshot::SnapshotError,
|
||||||
session_id::SessionId,
|
session_id::SessionId,
|
||||||
snapshot_reconciler::InstanceChanges,
|
snapshot_reconciler::InstanceChanges,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Fail)]
|
||||||
|
pub enum LiveSessionError {
|
||||||
|
#[fail(display = "{}", _0)]
|
||||||
|
Fs(#[fail(cause)] FsError),
|
||||||
|
|
||||||
|
#[fail(display = "{}", _0)]
|
||||||
|
Snapshot(#[fail(cause)] SnapshotError),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_from!(LiveSessionError {
|
||||||
|
FsError => Fs,
|
||||||
|
SnapshotError => Snapshot,
|
||||||
|
});
|
||||||
|
|
||||||
/// Contains all of the state for a Rojo live-sync session.
|
/// Contains all of the state for a Rojo live-sync session.
|
||||||
pub struct LiveSession {
|
pub struct LiveSession {
|
||||||
pub project: Arc<Project>,
|
project: Arc<Project>,
|
||||||
pub session_id: SessionId,
|
session_id: SessionId,
|
||||||
pub message_queue: Arc<MessageQueue<InstanceChanges>>,
|
pub message_queue: Arc<MessageQueue<InstanceChanges>>,
|
||||||
pub rbx_session: Arc<Mutex<RbxSession>>,
|
pub rbx_session: Arc<Mutex<RbxSession>>,
|
||||||
pub imfs: Arc<Mutex<Imfs>>,
|
pub imfs: Arc<Mutex<Imfs>>,
|
||||||
@@ -23,7 +42,7 @@ pub struct LiveSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl LiveSession {
|
impl LiveSession {
|
||||||
pub fn new(project: Arc<Project>) -> Result<LiveSession, FsError> {
|
pub fn new(project: Arc<Project>) -> Result<LiveSession, LiveSessionError> {
|
||||||
let imfs = {
|
let imfs = {
|
||||||
let mut imfs = Imfs::new();
|
let mut imfs = Imfs::new();
|
||||||
imfs.add_roots_from_project(&project)?;
|
imfs.add_roots_from_project(&project)?;
|
||||||
@@ -36,7 +55,7 @@ impl LiveSession {
|
|||||||
Arc::clone(&project),
|
Arc::clone(&project),
|
||||||
Arc::clone(&imfs),
|
Arc::clone(&imfs),
|
||||||
Arc::clone(&message_queue),
|
Arc::clone(&message_queue),
|
||||||
)));
|
)?));
|
||||||
|
|
||||||
let fs_watcher = FsWatcher::start(
|
let fs_watcher = FsWatcher::start(
|
||||||
Arc::clone(&imfs),
|
Arc::clone(&imfs),
|
||||||
@@ -46,8 +65,8 @@ impl LiveSession {
|
|||||||
let session_id = SessionId::new();
|
let session_id = SessionId::new();
|
||||||
|
|
||||||
Ok(LiveSession {
|
Ok(LiveSession {
|
||||||
project,
|
|
||||||
session_id,
|
session_id,
|
||||||
|
project,
|
||||||
message_queue,
|
message_queue,
|
||||||
rbx_session,
|
rbx_session,
|
||||||
imfs,
|
imfs,
|
||||||
@@ -55,7 +74,26 @@ impl LiveSession {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_project(&self) -> &Project {
|
/// Restarts the live session using the given project while preserving the
|
||||||
|
/// internal session ID.
|
||||||
|
pub fn restart_with_new_project(&mut self, project: Arc<Project>) -> Result<(), LiveSessionError> {
|
||||||
|
let mut new_session = LiveSession::new(project)?;
|
||||||
|
new_session.session_id = self.session_id;
|
||||||
|
|
||||||
|
mem::replace(self, new_session);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn root_project(&self) -> &Project {
|
||||||
&self.project
|
&self.project
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn session_id(&self) -> SessionId {
|
||||||
|
self.session_id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn serve_place_ids(&self) -> &Option<HashSet<u64>> {
|
||||||
|
&self.project.serve_place_ids
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,67 +1,83 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
mem,
|
||||||
sync::{
|
sync::{
|
||||||
mpsc,
|
|
||||||
atomic::{AtomicUsize, Ordering},
|
|
||||||
RwLock,
|
RwLock,
|
||||||
Mutex,
|
Mutex,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A unique identifier, not guaranteed to be generated in any order.
|
use futures::sync::oneshot;
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ListenerId(usize);
|
|
||||||
|
|
||||||
/// Generate a new ID, which has no defined ordering.
|
struct Listener<T> {
|
||||||
pub fn get_listener_id() -> ListenerId {
|
sender: oneshot::Sender<(u32, Vec<T>)>,
|
||||||
static LAST_ID: AtomicUsize = AtomicUsize::new(0);
|
cursor: u32,
|
||||||
|
}
|
||||||
|
|
||||||
ListenerId(LAST_ID.fetch_add(1, Ordering::SeqCst))
|
fn fire_listener_if_ready<T: Clone>(messages: &[T], listener: Listener<T>) -> Result<(), Listener<T>> {
|
||||||
|
let current_cursor = messages.len() as u32;
|
||||||
|
|
||||||
|
if listener.cursor < current_cursor {
|
||||||
|
let new_messages = messages[(listener.cursor as usize)..].to_vec();
|
||||||
|
let _ = listener.sender.send((current_cursor, new_messages));
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(listener)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A message queue with persistent history that can be subscribed to.
|
/// A message queue with persistent history that can be subscribed to.
|
||||||
///
|
///
|
||||||
/// Definitely non-optimal, but a simple design that works well for the
|
/// Definitely non-optimal. This would ideally be a lockless mpmc queue.
|
||||||
/// synchronous web server Rojo uses, Rouille.
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct MessageQueue<T> {
|
pub struct MessageQueue<T> {
|
||||||
messages: RwLock<Vec<T>>,
|
messages: RwLock<Vec<T>>,
|
||||||
message_listeners: Mutex<HashMap<ListenerId, mpsc::Sender<()>>>,
|
message_listeners: Mutex<Vec<Listener<T>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Clone> MessageQueue<T> {
|
impl<T: Clone> MessageQueue<T> {
|
||||||
pub fn new() -> MessageQueue<T> {
|
pub fn new() -> MessageQueue<T> {
|
||||||
MessageQueue {
|
MessageQueue {
|
||||||
messages: RwLock::new(Vec::new()),
|
messages: RwLock::new(Vec::new()),
|
||||||
message_listeners: Mutex::new(HashMap::new()),
|
message_listeners: Mutex::new(Vec::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_messages(&self, new_messages: &[T]) {
|
pub fn push_messages(&self, new_messages: &[T]) {
|
||||||
let message_listeners = self.message_listeners.lock().unwrap();
|
let mut message_listeners = self.message_listeners.lock().unwrap();
|
||||||
|
let mut messages = self.messages.write().unwrap();
|
||||||
|
messages.extend_from_slice(new_messages);
|
||||||
|
|
||||||
{
|
let mut remaining_listeners = Vec::new();
|
||||||
let mut messages = self.messages.write().unwrap();
|
|
||||||
messages.extend_from_slice(new_messages);
|
for listener in message_listeners.drain(..) {
|
||||||
|
match fire_listener_if_ready(&messages, listener) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(listener) => remaining_listeners.push(listener)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for listener in message_listeners.values() {
|
// Without this annotation, Rust gets confused since the first argument
|
||||||
listener.send(()).unwrap();
|
// is a MutexGuard, but the second is a Vec.
|
||||||
}
|
mem::replace::<Vec<_>>(&mut message_listeners, remaining_listeners);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subscribe(&self, sender: mpsc::Sender<()>) -> ListenerId {
|
pub fn subscribe(&self, cursor: u32, sender: oneshot::Sender<(u32, Vec<T>)>) {
|
||||||
let id = get_listener_id();
|
let listener = {
|
||||||
|
let listener = Listener {
|
||||||
|
sender,
|
||||||
|
cursor,
|
||||||
|
};
|
||||||
|
|
||||||
|
let messages = self.messages.read().unwrap();
|
||||||
|
|
||||||
|
match fire_listener_if_ready(&messages, listener) {
|
||||||
|
Ok(_) => return,
|
||||||
|
Err(listener) => listener
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let mut message_listeners = self.message_listeners.lock().unwrap();
|
let mut message_listeners = self.message_listeners.lock().unwrap();
|
||||||
message_listeners.insert(id, sender);
|
message_listeners.push(listener);
|
||||||
|
|
||||||
id
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unsubscribe(&self, id: ListenerId) {
|
|
||||||
let mut message_listeners = self.message_listeners.lock().unwrap();
|
|
||||||
message_listeners.remove(&id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_message_cursor(&self) -> u32 {
|
pub fn get_message_cursor(&self) -> u32 {
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ pub struct PathMap<T> {
|
|||||||
nodes: HashMap<PathBuf, PathMapNode<T>>,
|
nodes: HashMap<PathBuf, PathMapNode<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Default for PathMap<T> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> PathMap<T> {
|
impl<T> PathMap<T> {
|
||||||
pub fn new() -> PathMap<T> {
|
pub fn new() -> PathMap<T> {
|
||||||
PathMap {
|
PathMap {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet, BTreeMap},
|
||||||
fmt,
|
fmt,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io,
|
io,
|
||||||
@@ -8,9 +8,11 @@ use std::{
|
|||||||
|
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use failure::Fail;
|
use failure::Fail;
|
||||||
use maplit::hashmap;
|
use rbx_dom_weak::{UnresolvedRbxValue, RbxValue};
|
||||||
use rbx_tree::RbxValue;
|
|
||||||
use serde_derive::{Serialize, Deserialize};
|
use serde_derive::{Serialize, Deserialize};
|
||||||
|
use serde::{Serialize, Serializer};
|
||||||
|
|
||||||
|
static DEFAULT_PLACE: &'static str = include_str!("../assets/place.project.json");
|
||||||
|
|
||||||
pub static PROJECT_FILENAME: &'static str = "default.project.json";
|
pub static PROJECT_FILENAME: &'static str = "default.project.json";
|
||||||
pub static COMPAT_PROJECT_FILENAME: &'static str = "roblox-project.json";
|
pub static COMPAT_PROJECT_FILENAME: &'static str = "roblox-project.json";
|
||||||
@@ -24,6 +26,10 @@ struct SourceProject {
|
|||||||
name: String,
|
name: String,
|
||||||
tree: SourceProjectNode,
|
tree: SourceProjectNode,
|
||||||
|
|
||||||
|
#[cfg_attr(not(feature = "plugins-enabled"), serde(skip_deserializing))]
|
||||||
|
#[serde(default = "Vec::new", skip_serializing_if = "Vec::is_empty")]
|
||||||
|
plugins: Vec<SourcePlugin>,
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
serve_port: Option<u16>,
|
serve_port: Option<u16>,
|
||||||
|
|
||||||
@@ -33,12 +39,17 @@ struct SourceProject {
|
|||||||
|
|
||||||
impl SourceProject {
|
impl SourceProject {
|
||||||
/// Consumes the SourceProject and yields a Project, ready for prime-time.
|
/// Consumes the SourceProject and yields a Project, ready for prime-time.
|
||||||
pub fn into_project(self, project_file_location: &Path) -> Project {
|
pub fn into_project(mut self, project_file_location: &Path) -> Project {
|
||||||
let tree = self.tree.into_project_node(project_file_location);
|
let tree = self.tree.into_project_node(project_file_location);
|
||||||
|
let plugins = self.plugins
|
||||||
|
.drain(..)
|
||||||
|
.map(|source_plugin| source_plugin.into_plugin(project_file_location))
|
||||||
|
.collect();
|
||||||
|
|
||||||
Project {
|
Project {
|
||||||
name: self.name,
|
name: self.name,
|
||||||
tree,
|
tree,
|
||||||
|
plugins,
|
||||||
serve_port: self.serve_port,
|
serve_port: self.serve_port,
|
||||||
serve_place_ids: self.serve_place_ids,
|
serve_place_ids: self.serve_place_ids,
|
||||||
file_location: PathBuf::from(project_file_location),
|
file_location: PathBuf::from(project_file_location),
|
||||||
@@ -46,16 +57,89 @@ impl SourceProject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An alternative serializer for `UnresolvedRbxValue` that uses the minimum
|
||||||
|
/// representation of the value.
|
||||||
|
///
|
||||||
|
/// For example, the default Serialize impl might give you:
|
||||||
|
///
|
||||||
|
/// ```json
|
||||||
|
/// {
|
||||||
|
/// "Type": "Bool",
|
||||||
|
/// "Value": true
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// But in reality, users are expected to write just:
|
||||||
|
///
|
||||||
|
/// ```json
|
||||||
|
/// true
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// This holds true for other values that might be ambiguous or just have more
|
||||||
|
/// complicated representations like enums.
|
||||||
|
fn serialize_unresolved_minimal<S>(unresolved: &UnresolvedRbxValue, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where S: Serializer
|
||||||
|
{
|
||||||
|
match unresolved {
|
||||||
|
UnresolvedRbxValue::Ambiguous(_) => unresolved.serialize(serializer),
|
||||||
|
UnresolvedRbxValue::Concrete(concrete) => {
|
||||||
|
match concrete {
|
||||||
|
RbxValue::Bool { value } => value.serialize(serializer),
|
||||||
|
RbxValue::CFrame { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Color3 { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Color3uint8 { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Content { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Enum { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Float32 { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Int32 { value } => value.serialize(serializer),
|
||||||
|
RbxValue::String { value } => value.serialize(serializer),
|
||||||
|
RbxValue::UDim { value } => value.serialize(serializer),
|
||||||
|
RbxValue::UDim2 { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Vector2 { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Vector2int16 { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Vector3 { value } => value.serialize(serializer),
|
||||||
|
RbxValue::Vector3int16 { value } => value.serialize(serializer),
|
||||||
|
_ => concrete.serialize(serializer),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A wrapper around serialize_unresolved_minimal that handles the HashMap case.
|
||||||
|
fn serialize_unresolved_map<S>(value: &HashMap<String, UnresolvedRbxValue>, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where S: Serializer
|
||||||
|
{
|
||||||
|
use serde::ser::SerializeMap;
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct Minimal<'a>(
|
||||||
|
#[serde(serialize_with = "serialize_unresolved_minimal")]
|
||||||
|
&'a UnresolvedRbxValue
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut map = serializer.serialize_map(Some(value.len()))?;
|
||||||
|
for (k, v) in value {
|
||||||
|
map.serialize_key(k)?;
|
||||||
|
map.serialize_value(&Minimal(v))?;
|
||||||
|
}
|
||||||
|
map.end()
|
||||||
|
}
|
||||||
|
|
||||||
/// Similar to SourceProject, the structure of nodes in the project tree is
|
/// Similar to SourceProject, the structure of nodes in the project tree is
|
||||||
/// slightly different on-disk than how we want to handle them in the rest of
|
/// slightly different on-disk than how we want to handle them in the rest of
|
||||||
/// Rojo.
|
/// Rojo.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
struct SourceProjectNode {
|
struct SourceProjectNode {
|
||||||
#[serde(rename = "$className", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "$className", skip_serializing_if = "Option::is_none")]
|
||||||
class_name: Option<String>,
|
class_name: Option<String>,
|
||||||
|
|
||||||
#[serde(rename = "$properties", default = "HashMap::new", skip_serializing_if = "HashMap::is_empty")]
|
#[serde(
|
||||||
properties: HashMap<String, RbxValue>,
|
rename = "$properties",
|
||||||
|
default = "HashMap::new",
|
||||||
|
skip_serializing_if = "HashMap::is_empty",
|
||||||
|
serialize_with = "serialize_unresolved_map",
|
||||||
|
)]
|
||||||
|
properties: HashMap<String, UnresolvedRbxValue>,
|
||||||
|
|
||||||
#[serde(rename = "$ignoreUnknownInstances", skip_serializing_if = "Option::is_none")]
|
#[serde(rename = "$ignoreUnknownInstances", skip_serializing_if = "Option::is_none")]
|
||||||
ignore_unknown_instances: Option<bool>,
|
ignore_unknown_instances: Option<bool>,
|
||||||
@@ -64,14 +148,14 @@ struct SourceProjectNode {
|
|||||||
path: Option<String>,
|
path: Option<String>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
children: HashMap<String, SourceProjectNode>,
|
children: BTreeMap<String, SourceProjectNode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SourceProjectNode {
|
impl SourceProjectNode {
|
||||||
/// Consumes the SourceProjectNode and turns it into a ProjectNode.
|
/// Consumes the SourceProjectNode and turns it into a ProjectNode.
|
||||||
pub fn into_project_node(mut self, project_file_location: &Path) -> ProjectNode {
|
pub fn into_project_node(self, project_file_location: &Path) -> ProjectNode {
|
||||||
let children = self.children.drain()
|
let children = self.children.iter()
|
||||||
.map(|(key, value)| (key, value.into_project_node(project_file_location)))
|
.map(|(key, value)| (key.clone(), value.clone().into_project_node(project_file_location)))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Make sure that paths are absolute, transforming them by adding the
|
// Make sure that paths are absolute, transforming them by adding the
|
||||||
@@ -95,6 +179,26 @@ impl SourceProjectNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
struct SourcePlugin {
|
||||||
|
path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SourcePlugin {
|
||||||
|
pub fn into_plugin(self, project_file_location: &Path) -> Plugin {
|
||||||
|
let path = if Path::new(&self.path).is_absolute() {
|
||||||
|
PathBuf::from(self.path)
|
||||||
|
} else {
|
||||||
|
let project_folder_location = project_file_location.parent().unwrap();
|
||||||
|
project_folder_location.join(self.path)
|
||||||
|
};
|
||||||
|
|
||||||
|
Plugin {
|
||||||
|
path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Error returned by Project::load_exact
|
/// Error returned by Project::load_exact
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum ProjectLoadExactError {
|
pub enum ProjectLoadExactError {
|
||||||
@@ -133,6 +237,7 @@ pub enum ProjectInitError {
|
|||||||
AlreadyExists(PathBuf),
|
AlreadyExists(PathBuf),
|
||||||
IoError(#[fail(cause)] io::Error),
|
IoError(#[fail(cause)] io::Error),
|
||||||
SaveError(#[fail(cause)] ProjectSaveError),
|
SaveError(#[fail(cause)] ProjectSaveError),
|
||||||
|
JsonError(#[fail(cause)] serde_json::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ProjectInitError {
|
impl fmt::Display for ProjectInitError {
|
||||||
@@ -141,6 +246,7 @@ impl fmt::Display for ProjectInitError {
|
|||||||
ProjectInitError::AlreadyExists(path) => write!(output, "Path {} already exists", path.display()),
|
ProjectInitError::AlreadyExists(path) => write!(output, "Path {} already exists", path.display()),
|
||||||
ProjectInitError::IoError(inner) => write!(output, "IO error: {}", inner),
|
ProjectInitError::IoError(inner) => write!(output, "IO error: {}", inner),
|
||||||
ProjectInitError::SaveError(inner) => write!(output, "{}", inner),
|
ProjectInitError::SaveError(inner) => write!(output, "{}", inner),
|
||||||
|
ProjectInitError::JsonError(inner) => write!(output, "{}", inner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,8 +264,8 @@ pub enum ProjectSaveError {
|
|||||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
|
||||||
pub struct ProjectNode {
|
pub struct ProjectNode {
|
||||||
pub class_name: Option<String>,
|
pub class_name: Option<String>,
|
||||||
pub children: HashMap<String, ProjectNode>,
|
pub children: BTreeMap<String, ProjectNode>,
|
||||||
pub properties: HashMap<String, RbxValue>,
|
pub properties: HashMap<String, UnresolvedRbxValue>,
|
||||||
pub ignore_unknown_instances: Option<bool>,
|
pub ignore_unknown_instances: Option<bool>,
|
||||||
|
|
||||||
#[serde(serialize_with = "crate::path_serializer::serialize_option")]
|
#[serde(serialize_with = "crate::path_serializer::serialize_option")]
|
||||||
@@ -198,10 +304,30 @@ impl ProjectNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct Plugin {
|
||||||
|
pub path: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Plugin {
|
||||||
|
fn to_source_plugin(&self, project_file_location: &Path) -> SourcePlugin {
|
||||||
|
let project_folder_location = project_file_location.parent().unwrap();
|
||||||
|
let path = match self.path.strip_prefix(project_folder_location) {
|
||||||
|
Ok(stripped) => stripped.to_str().unwrap().replace("\\", "/"),
|
||||||
|
Err(_) => format!("{}", self.path.display()),
|
||||||
|
};
|
||||||
|
|
||||||
|
SourcePlugin {
|
||||||
|
path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Project {
|
pub struct Project {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub tree: ProjectNode,
|
pub tree: ProjectNode,
|
||||||
|
pub plugins: Vec<Plugin>,
|
||||||
pub serve_port: Option<u16>,
|
pub serve_port: Option<u16>,
|
||||||
pub serve_place_ids: Option<HashSet<u64>>,
|
pub serve_place_ids: Option<HashSet<u64>>,
|
||||||
pub file_location: PathBuf,
|
pub file_location: PathBuf,
|
||||||
@@ -210,46 +336,16 @@ pub struct Project {
|
|||||||
impl Project {
|
impl Project {
|
||||||
pub fn init_place(project_fuzzy_path: &Path) -> Result<PathBuf, ProjectInitError> {
|
pub fn init_place(project_fuzzy_path: &Path) -> Result<PathBuf, ProjectInitError> {
|
||||||
let project_path = Project::init_pick_path(project_fuzzy_path)?;
|
let project_path = Project::init_pick_path(project_fuzzy_path)?;
|
||||||
let project_folder_path = project_path.parent().unwrap();
|
|
||||||
let project_name = if project_fuzzy_path == project_path {
|
let project_name = if project_fuzzy_path == project_path {
|
||||||
project_fuzzy_path.parent().unwrap().file_name().unwrap().to_str().unwrap()
|
project_fuzzy_path.parent().unwrap().file_name().unwrap().to_str().unwrap()
|
||||||
} else {
|
} else {
|
||||||
project_fuzzy_path.file_name().unwrap().to_str().unwrap()
|
project_fuzzy_path.file_name().unwrap().to_str().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let tree = ProjectNode {
|
let mut project = Project::load_from_str(DEFAULT_PLACE, &project_path)
|
||||||
class_name: Some(String::from("DataModel")),
|
.map_err(ProjectInitError::JsonError)?;
|
||||||
children: hashmap! {
|
|
||||||
String::from("ReplicatedStorage") => ProjectNode {
|
|
||||||
class_name: Some(String::from("ReplicatedStorage")),
|
|
||||||
children: hashmap! {
|
|
||||||
String::from("Source") => ProjectNode {
|
|
||||||
path: Some(project_folder_path.join("src")),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
},
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
String::from("HttpService") => ProjectNode {
|
|
||||||
class_name: Some(String::from("HttpService")),
|
|
||||||
properties: hashmap! {
|
|
||||||
String::from("HttpEnabled") => RbxValue::Bool {
|
|
||||||
value: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
},
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let project = Project {
|
project.name = project_name.to_owned();
|
||||||
name: project_name.to_string(),
|
|
||||||
tree,
|
|
||||||
serve_port: None,
|
|
||||||
serve_place_ids: None,
|
|
||||||
file_location: project_path.clone(),
|
|
||||||
};
|
|
||||||
|
|
||||||
project.save()
|
project.save()
|
||||||
.map_err(ProjectInitError::SaveError)?;
|
.map_err(ProjectInitError::SaveError)?;
|
||||||
@@ -274,6 +370,7 @@ impl Project {
|
|||||||
let project = Project {
|
let project = Project {
|
||||||
name: project_name.to_string(),
|
name: project_name.to_string(),
|
||||||
tree,
|
tree,
|
||||||
|
plugins: Vec::new(),
|
||||||
serve_port: None,
|
serve_port: None,
|
||||||
serve_place_ids: None,
|
serve_place_ids: None,
|
||||||
file_location: project_path.clone(),
|
file_location: project_path.clone(),
|
||||||
@@ -336,6 +433,12 @@ impl Project {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_from_str(contents: &str, project_file_location: &Path) -> Result<Project, serde_json::Error> {
|
||||||
|
let parsed: SourceProject = serde_json::from_str(&contents)?;
|
||||||
|
|
||||||
|
Ok(parsed.into_project(project_file_location))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn load_fuzzy(fuzzy_project_location: &Path) -> Result<Project, ProjectLoadFuzzyError> {
|
pub fn load_fuzzy(fuzzy_project_location: &Path) -> Result<Project, ProjectLoadFuzzyError> {
|
||||||
let project_path = Self::locate(fuzzy_project_location)
|
let project_path = Self::locate(fuzzy_project_location)
|
||||||
.ok_or(ProjectLoadFuzzyError::NotFound)?;
|
.ok_or(ProjectLoadFuzzyError::NotFound)?;
|
||||||
@@ -383,10 +486,20 @@ impl Project {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn folder_location(&self) -> &Path {
|
||||||
|
self.file_location.parent().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
fn to_source_project(&self) -> SourceProject {
|
fn to_source_project(&self) -> SourceProject {
|
||||||
|
let plugins = self.plugins
|
||||||
|
.iter()
|
||||||
|
.map(|plugin| plugin.to_source_plugin(&self.file_location))
|
||||||
|
.collect();
|
||||||
|
|
||||||
SourceProject {
|
SourceProject {
|
||||||
name: self.name.clone(),
|
name: self.name.clone(),
|
||||||
tree: self.tree.to_source_node(&self.file_location),
|
tree: self.tree.to_source_node(&self.file_location),
|
||||||
|
plugins,
|
||||||
serve_port: self.serve_port,
|
serve_port: self.serve_port,
|
||||||
serve_place_ids: self.serve_place_ids.clone(),
|
serve_place_ids: self.serve_place_ids.clone(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,16 +6,25 @@ use std::{
|
|||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use rlua::Lua;
|
||||||
use serde_derive::{Serialize, Deserialize};
|
use serde_derive::{Serialize, Deserialize};
|
||||||
use log::{info, trace};
|
use log::{info, trace, error};
|
||||||
use rbx_tree::{RbxTree, RbxId};
|
use rbx_dom_weak::{RbxTree, RbxId};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
project::{Project, ProjectNode},
|
project::{Project, ProjectNode},
|
||||||
message_queue::MessageQueue,
|
message_queue::MessageQueue,
|
||||||
imfs::{Imfs, ImfsItem},
|
imfs::{Imfs, ImfsItem},
|
||||||
path_map::PathMap,
|
path_map::PathMap,
|
||||||
rbx_snapshot::{snapshot_project_tree, snapshot_project_node, snapshot_imfs_path},
|
rbx_snapshot::{
|
||||||
|
SnapshotError,
|
||||||
|
SnapshotContext,
|
||||||
|
SnapshotPluginContext,
|
||||||
|
SnapshotPluginEntry,
|
||||||
|
snapshot_project_tree,
|
||||||
|
snapshot_project_node,
|
||||||
|
snapshot_imfs_path,
|
||||||
|
},
|
||||||
snapshot_reconciler::{InstanceChanges, reify_root, reconcile_subtree},
|
snapshot_reconciler::{InstanceChanges, reify_root, reconcile_subtree},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,22 +67,60 @@ impl RbxSession {
|
|||||||
project: Arc<Project>,
|
project: Arc<Project>,
|
||||||
imfs: Arc<Mutex<Imfs>>,
|
imfs: Arc<Mutex<Imfs>>,
|
||||||
message_queue: Arc<MessageQueue<InstanceChanges>>,
|
message_queue: Arc<MessageQueue<InstanceChanges>>,
|
||||||
) -> RbxSession {
|
) -> Result<RbxSession, SnapshotError> {
|
||||||
let mut instances_per_path = PathMap::new();
|
let mut instances_per_path = PathMap::new();
|
||||||
let mut metadata_per_instance = HashMap::new();
|
let mut metadata_per_instance = HashMap::new();
|
||||||
|
|
||||||
let tree = {
|
let plugin_context = if cfg!(feature = "server-plugins") {
|
||||||
let temp_imfs = imfs.lock().unwrap();
|
let lua = Lua::new();
|
||||||
reify_initial_tree(&project, &temp_imfs, &mut instances_per_path, &mut metadata_per_instance)
|
let mut callback_key = None;
|
||||||
|
|
||||||
|
lua.context(|context| {
|
||||||
|
let callback = context.load(r#"
|
||||||
|
return function(snapshot)
|
||||||
|
print("got my snapshot:", snapshot)
|
||||||
|
print("name:", snapshot.name, "class name:", snapshot.className)
|
||||||
|
end"#)
|
||||||
|
.set_name("a cool plugin").unwrap()
|
||||||
|
.call::<(), rlua::Function>(()).unwrap();
|
||||||
|
|
||||||
|
callback_key = Some(context.create_registry_value(callback).unwrap());
|
||||||
|
});
|
||||||
|
|
||||||
|
let plugins = vec![
|
||||||
|
SnapshotPluginEntry {
|
||||||
|
file_name_filter: String::new(),
|
||||||
|
callback: callback_key.unwrap(),
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
Some(SnapshotPluginContext { lua, plugins })
|
||||||
|
} else {
|
||||||
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
RbxSession {
|
let context = SnapshotContext {
|
||||||
|
plugin_context,
|
||||||
|
};
|
||||||
|
|
||||||
|
let tree = {
|
||||||
|
let temp_imfs = imfs.lock().unwrap();
|
||||||
|
reify_initial_tree(
|
||||||
|
&project,
|
||||||
|
&context,
|
||||||
|
&temp_imfs,
|
||||||
|
&mut instances_per_path,
|
||||||
|
&mut metadata_per_instance,
|
||||||
|
)?
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(RbxSession {
|
||||||
tree,
|
tree,
|
||||||
instances_per_path,
|
instances_per_path,
|
||||||
metadata_per_instance,
|
metadata_per_instance,
|
||||||
message_queue,
|
message_queue,
|
||||||
imfs,
|
imfs,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_created_or_updated(&mut self, path: &Path) {
|
fn path_created_or_updated(&mut self, path: &Path) {
|
||||||
@@ -104,27 +151,37 @@ impl RbxSession {
|
|||||||
.expect("Metadata did not exist for path")
|
.expect("Metadata did not exist for path")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
|
let context = SnapshotContext {
|
||||||
|
plugin_context: None,
|
||||||
|
};
|
||||||
|
|
||||||
for instance_id in &instances_at_path {
|
for instance_id in &instances_at_path {
|
||||||
let instance_metadata = self.metadata_per_instance.get(&instance_id)
|
let instance_metadata = self.metadata_per_instance.get(&instance_id)
|
||||||
.expect("Metadata for instance ID did not exist");
|
.expect("Metadata for instance ID did not exist");
|
||||||
|
|
||||||
let maybe_snapshot = match &instance_metadata.project_definition {
|
let maybe_snapshot = match &instance_metadata.project_definition {
|
||||||
Some((instance_name, project_node)) => {
|
Some((instance_name, project_node)) => {
|
||||||
snapshot_project_node(&imfs, &project_node, Cow::Owned(instance_name.clone()))
|
snapshot_project_node(&context, &imfs, &project_node, Cow::Owned(instance_name.clone()))
|
||||||
.unwrap_or_else(|_| panic!("Could not generate instance snapshot for path {}", path_to_snapshot.display()))
|
// .unwrap_or_else(|_| panic!("Could not generate instance snapshot for path {}", path_to_snapshot.display()))
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
snapshot_imfs_path(&imfs, &path_to_snapshot, None)
|
snapshot_imfs_path(&context, &imfs, &path_to_snapshot, None)
|
||||||
.unwrap_or_else(|_| panic!("Could not generate instance snapshot for path {}", path_to_snapshot.display()))
|
// .unwrap_or_else(|_| panic!("Could not generate instance snapshot for path {}", path_to_snapshot.display()))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let snapshot = match maybe_snapshot {
|
let snapshot = match maybe_snapshot {
|
||||||
Some(snapshot) => snapshot,
|
Ok(Some(snapshot)) => snapshot,
|
||||||
None => {
|
Ok(None) => {
|
||||||
trace!("Path resulted in no snapshot being generated.");
|
trace!("Path resulted in no snapshot being generated.");
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
Err(err) => {
|
||||||
|
error!("Rojo couldn't turn one of the project's files into Roblox instances.");
|
||||||
|
error!("Any changes to the file have been ignored.");
|
||||||
|
error!("{}", err);
|
||||||
|
return;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
trace!("Snapshot: {:#?}", snapshot);
|
trace!("Snapshot: {:#?}", snapshot);
|
||||||
@@ -194,29 +251,39 @@ impl RbxSession {
|
|||||||
&self.tree
|
&self.tree
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_all_instance_metadata(&self) -> &HashMap<RbxId, MetadataPerInstance> {
|
||||||
|
&self.metadata_per_instance
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_instance_metadata(&self, id: RbxId) -> Option<&MetadataPerInstance> {
|
pub fn get_instance_metadata(&self, id: RbxId) -> Option<&MetadataPerInstance> {
|
||||||
self.metadata_per_instance.get(&id)
|
self.metadata_per_instance.get(&id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn construct_oneoff_tree(project: &Project, imfs: &Imfs) -> RbxTree {
|
pub fn construct_oneoff_tree(project: &Project, imfs: &Imfs) -> Result<RbxTree, SnapshotError> {
|
||||||
let mut instances_per_path = PathMap::new();
|
let mut instances_per_path = PathMap::new();
|
||||||
let mut metadata_per_instance = HashMap::new();
|
let mut metadata_per_instance = HashMap::new();
|
||||||
reify_initial_tree(project, imfs, &mut instances_per_path, &mut metadata_per_instance)
|
let context = SnapshotContext {
|
||||||
|
plugin_context: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
reify_initial_tree(project, &context, imfs, &mut instances_per_path, &mut metadata_per_instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reify_initial_tree(
|
fn reify_initial_tree(
|
||||||
project: &Project,
|
project: &Project,
|
||||||
|
context: &SnapshotContext,
|
||||||
imfs: &Imfs,
|
imfs: &Imfs,
|
||||||
instances_per_path: &mut PathMap<HashSet<RbxId>>,
|
instances_per_path: &mut PathMap<HashSet<RbxId>>,
|
||||||
metadata_per_instance: &mut HashMap<RbxId, MetadataPerInstance>,
|
metadata_per_instance: &mut HashMap<RbxId, MetadataPerInstance>,
|
||||||
) -> RbxTree {
|
) -> Result<RbxTree, SnapshotError> {
|
||||||
let snapshot = snapshot_project_tree(imfs, project)
|
let snapshot = match snapshot_project_tree(&context, imfs, project)? {
|
||||||
.expect("Could not snapshot project tree")
|
Some(snapshot) => snapshot,
|
||||||
.expect("Project did not produce any instances");
|
None => panic!("Project did not produce any instances"),
|
||||||
|
};
|
||||||
|
|
||||||
let mut changes = InstanceChanges::default();
|
let mut changes = InstanceChanges::default();
|
||||||
let tree = reify_root(&snapshot, instances_per_path, metadata_per_instance, &mut changes);
|
let tree = reify_root(&snapshot, instances_per_path, metadata_per_instance, &mut changes);
|
||||||
|
|
||||||
tree
|
Ok(tree)
|
||||||
}
|
}
|
||||||
@@ -9,11 +9,13 @@ use std::{
|
|||||||
str,
|
str,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use rlua::Lua;
|
||||||
use failure::Fail;
|
use failure::Fail;
|
||||||
use log::info;
|
use log::info;
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
use rbx_tree::{RbxTree, RbxValue, RbxInstanceProperties};
|
use rbx_dom_weak::{RbxTree, RbxValue, RbxInstanceProperties};
|
||||||
use serde_derive::{Serialize, Deserialize};
|
use serde_derive::{Serialize, Deserialize};
|
||||||
|
use rbx_reflection::{try_resolve_value, ValueResolveError};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{
|
imfs::{
|
||||||
@@ -38,6 +40,53 @@ const INIT_MODULE_NAME: &str = "init.lua";
|
|||||||
const INIT_SERVER_NAME: &str = "init.server.lua";
|
const INIT_SERVER_NAME: &str = "init.server.lua";
|
||||||
const INIT_CLIENT_NAME: &str = "init.client.lua";
|
const INIT_CLIENT_NAME: &str = "init.client.lua";
|
||||||
|
|
||||||
|
pub struct SnapshotContext {
|
||||||
|
pub plugin_context: Option<SnapshotPluginContext>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Context that's only relevant to generating snapshots if there are plugins
|
||||||
|
/// associated with the project.
|
||||||
|
///
|
||||||
|
/// It's possible that this needs some sort of extra nesting/filtering to
|
||||||
|
/// support nested projects, since their plugins should only apply to
|
||||||
|
/// themselves.
|
||||||
|
pub struct SnapshotPluginContext {
|
||||||
|
pub lua: Lua,
|
||||||
|
pub plugins: Vec<SnapshotPluginEntry>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SnapshotPluginEntry {
|
||||||
|
/// Simple file name suffix filter to avoid running plugins on every file
|
||||||
|
/// change.
|
||||||
|
pub file_name_filter: String,
|
||||||
|
|
||||||
|
/// A key into the Lua registry created by [`create_registry_value`] that
|
||||||
|
/// refers to a function that can be called to transform a file/instance
|
||||||
|
/// pair according to how the plugin needs to operate.
|
||||||
|
///
|
||||||
|
/// [`create_registry_value`]: https://docs.rs/rlua/0.16.2/rlua/struct.Context.html#method.create_registry_value
|
||||||
|
pub callback: rlua::RegistryKey,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
struct LuaRbxSnapshot(RbxSnapshotInstance<'static>);
|
||||||
|
|
||||||
|
impl rlua::UserData for LuaRbxSnapshot {
|
||||||
|
fn add_methods<'lua, M: rlua::UserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
|
methods.add_meta_method(rlua::MetaMethod::Index, |_context, this, key: String| {
|
||||||
|
match key.as_str() {
|
||||||
|
"name" => Ok(this.0.name.clone().into_owned()),
|
||||||
|
"className" => Ok(this.0.class_name.clone().into_owned()),
|
||||||
|
_ => Err(rlua::Error::RuntimeError(format!("{} is not a valid member of RbxSnapshotInstance", &key))),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
methods.add_meta_method(rlua::MetaMethod::ToString, |_context, _this, _args: ()| {
|
||||||
|
Ok("RbxSnapshotInstance")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type SnapshotResult<'a> = Result<Option<RbxSnapshotInstance<'a>>, SnapshotError>;
|
pub type SnapshotResult<'a> = Result<Option<RbxSnapshotInstance<'a>>, SnapshotError>;
|
||||||
|
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
@@ -71,6 +120,19 @@ pub enum SnapshotError {
|
|||||||
ProjectNodeInvalidTransmute {
|
ProjectNodeInvalidTransmute {
|
||||||
partition_path: PathBuf,
|
partition_path: PathBuf,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
PropertyResolveError {
|
||||||
|
#[fail(cause)]
|
||||||
|
inner: ValueResolveError,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ValueResolveError> for SnapshotError {
|
||||||
|
fn from(inner: ValueResolveError) -> SnapshotError {
|
||||||
|
SnapshotError::PropertyResolveError {
|
||||||
|
inner,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for SnapshotError {
|
impl fmt::Display for SnapshotError {
|
||||||
@@ -99,24 +161,27 @@ impl fmt::Display for SnapshotError {
|
|||||||
writeln!(output, "")?;
|
writeln!(output, "")?;
|
||||||
writeln!(output, "Partition target ($path): {}", partition_path.display())
|
writeln!(output, "Partition target ($path): {}", partition_path.display())
|
||||||
},
|
},
|
||||||
|
SnapshotError::PropertyResolveError { inner } => write!(output, "{}", inner),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn snapshot_project_tree<'source>(
|
pub fn snapshot_project_tree<'source>(
|
||||||
|
context: &SnapshotContext,
|
||||||
imfs: &'source Imfs,
|
imfs: &'source Imfs,
|
||||||
project: &'source Project,
|
project: &'source Project,
|
||||||
) -> SnapshotResult<'source> {
|
) -> SnapshotResult<'source> {
|
||||||
snapshot_project_node(imfs, &project.tree, Cow::Borrowed(&project.name))
|
snapshot_project_node(context, imfs, &project.tree, Cow::Borrowed(&project.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn snapshot_project_node<'source>(
|
pub fn snapshot_project_node<'source>(
|
||||||
|
context: &SnapshotContext,
|
||||||
imfs: &'source Imfs,
|
imfs: &'source Imfs,
|
||||||
node: &ProjectNode,
|
node: &ProjectNode,
|
||||||
instance_name: Cow<'source, str>,
|
instance_name: Cow<'source, str>,
|
||||||
) -> SnapshotResult<'source> {
|
) -> SnapshotResult<'source> {
|
||||||
let maybe_snapshot = match &node.path {
|
let maybe_snapshot = match &node.path {
|
||||||
Some(path) => snapshot_imfs_path(imfs, &path, Some(instance_name.clone()))?,
|
Some(path) => snapshot_imfs_path(context, imfs, &path, Some(instance_name.clone()))?,
|
||||||
None => match &node.class_name {
|
None => match &node.class_name {
|
||||||
Some(_class_name) => Some(RbxSnapshotInstance {
|
Some(_class_name) => Some(RbxSnapshotInstance {
|
||||||
name: instance_name.clone(),
|
name: instance_name.clone(),
|
||||||
@@ -170,13 +235,14 @@ pub fn snapshot_project_node<'source>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (child_name, child_project_node) in &node.children {
|
for (child_name, child_project_node) in &node.children {
|
||||||
if let Some(child) = snapshot_project_node(imfs, child_project_node, Cow::Owned(child_name.clone()))? {
|
if let Some(child) = snapshot_project_node(context, imfs, child_project_node, Cow::Owned(child_name.clone()))? {
|
||||||
snapshot.children.push(child);
|
snapshot.children.push(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (key, value) in &node.properties {
|
for (key, value) in &node.properties {
|
||||||
snapshot.properties.insert(key.clone(), value.clone());
|
let resolved_value = try_resolve_value(&snapshot.class_name, key, value)?;
|
||||||
|
snapshot.properties.insert(key.clone(), resolved_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ignore_unknown_instances) = node.ignore_unknown_instances {
|
if let Some(ignore_unknown_instances) = node.ignore_unknown_instances {
|
||||||
@@ -189,6 +255,7 @@ pub fn snapshot_project_node<'source>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn snapshot_imfs_path<'source>(
|
pub fn snapshot_imfs_path<'source>(
|
||||||
|
context: &SnapshotContext,
|
||||||
imfs: &'source Imfs,
|
imfs: &'source Imfs,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
instance_name: Option<Cow<'source, str>>,
|
instance_name: Option<Cow<'source, str>>,
|
||||||
@@ -196,23 +263,25 @@ pub fn snapshot_imfs_path<'source>(
|
|||||||
// If the given path doesn't exist in the in-memory filesystem, we consider
|
// If the given path doesn't exist in the in-memory filesystem, we consider
|
||||||
// that an error.
|
// that an error.
|
||||||
match imfs.get(path) {
|
match imfs.get(path) {
|
||||||
Some(imfs_item) => snapshot_imfs_item(imfs, imfs_item, instance_name),
|
Some(imfs_item) => snapshot_imfs_item(context, imfs, imfs_item, instance_name),
|
||||||
None => return Err(SnapshotError::DidNotExist(path.to_owned())),
|
None => return Err(SnapshotError::DidNotExist(path.to_owned())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_imfs_item<'source>(
|
fn snapshot_imfs_item<'source>(
|
||||||
|
context: &SnapshotContext,
|
||||||
imfs: &'source Imfs,
|
imfs: &'source Imfs,
|
||||||
item: &'source ImfsItem,
|
item: &'source ImfsItem,
|
||||||
instance_name: Option<Cow<'source, str>>,
|
instance_name: Option<Cow<'source, str>>,
|
||||||
) -> SnapshotResult<'source> {
|
) -> SnapshotResult<'source> {
|
||||||
match item {
|
match item {
|
||||||
ImfsItem::File(file) => snapshot_imfs_file(file, instance_name),
|
ImfsItem::File(file) => snapshot_imfs_file(context, file, instance_name),
|
||||||
ImfsItem::Directory(directory) => snapshot_imfs_directory(imfs, directory, instance_name),
|
ImfsItem::Directory(directory) => snapshot_imfs_directory(context, imfs, directory, instance_name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_imfs_directory<'source>(
|
fn snapshot_imfs_directory<'source>(
|
||||||
|
context: &SnapshotContext,
|
||||||
imfs: &'source Imfs,
|
imfs: &'source Imfs,
|
||||||
directory: &'source ImfsDirectory,
|
directory: &'source ImfsDirectory,
|
||||||
instance_name: Option<Cow<'source, str>>,
|
instance_name: Option<Cow<'source, str>>,
|
||||||
@@ -229,11 +298,11 @@ fn snapshot_imfs_directory<'source>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let mut snapshot = if directory.children.contains(&init_path) {
|
let mut snapshot = if directory.children.contains(&init_path) {
|
||||||
snapshot_imfs_path(imfs, &init_path, Some(snapshot_name))?.unwrap()
|
snapshot_imfs_path(context, imfs, &init_path, Some(snapshot_name))?.unwrap()
|
||||||
} else if directory.children.contains(&init_server_path) {
|
} else if directory.children.contains(&init_server_path) {
|
||||||
snapshot_imfs_path(imfs, &init_server_path, Some(snapshot_name))?.unwrap()
|
snapshot_imfs_path(context, imfs, &init_server_path, Some(snapshot_name))?.unwrap()
|
||||||
} else if directory.children.contains(&init_client_path) {
|
} else if directory.children.contains(&init_client_path) {
|
||||||
snapshot_imfs_path(imfs, &init_client_path, Some(snapshot_name))?.unwrap()
|
snapshot_imfs_path(context, imfs, &init_client_path, Some(snapshot_name))?.unwrap()
|
||||||
} else {
|
} else {
|
||||||
RbxSnapshotInstance {
|
RbxSnapshotInstance {
|
||||||
class_name: Cow::Borrowed("Folder"),
|
class_name: Cow::Borrowed("Folder"),
|
||||||
@@ -262,7 +331,7 @@ fn snapshot_imfs_directory<'source>(
|
|||||||
// them here.
|
// them here.
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
if let Some(child) = snapshot_imfs_path(imfs, child_path, None)? {
|
if let Some(child) = snapshot_imfs_path(context, imfs, child_path, None)? {
|
||||||
snapshot.children.push(child);
|
snapshot.children.push(child);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -273,6 +342,7 @@ fn snapshot_imfs_directory<'source>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_imfs_file<'source>(
|
fn snapshot_imfs_file<'source>(
|
||||||
|
context: &SnapshotContext,
|
||||||
file: &'source ImfsFile,
|
file: &'source ImfsFile,
|
||||||
instance_name: Option<Cow<'source, str>>,
|
instance_name: Option<Cow<'source, str>>,
|
||||||
) -> SnapshotResult<'source> {
|
) -> SnapshotResult<'source> {
|
||||||
@@ -308,6 +378,20 @@ fn snapshot_imfs_file<'source>(
|
|||||||
info!("File generated no snapshot: {}", file.path.display());
|
info!("File generated no snapshot: {}", file.path.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(snapshot) = maybe_snapshot.as_ref() {
|
||||||
|
if let Some(plugin_context) = &context.plugin_context {
|
||||||
|
for plugin in &plugin_context.plugins {
|
||||||
|
let owned_snapshot = snapshot.get_owned();
|
||||||
|
let registry_key = &plugin.callback;
|
||||||
|
|
||||||
|
plugin_context.lua.context(move |context| {
|
||||||
|
let callback: rlua::Function = context.registry_value(registry_key).unwrap();
|
||||||
|
callback.call::<_, ()>(LuaRbxSnapshot(owned_snapshot)).unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(maybe_snapshot)
|
Ok(maybe_snapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use std::{
|
|||||||
str,
|
str,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rbx_tree::{RbxTree, RbxId, RbxInstanceProperties, RbxValue};
|
use rbx_dom_weak::{RbxTree, RbxId, RbxInstanceProperties, RbxValue};
|
||||||
use serde_derive::{Serialize, Deserialize};
|
use serde_derive::{Serialize, Deserialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -64,7 +64,7 @@ impl InstanceChanges {
|
|||||||
|
|
||||||
/// A lightweight, hierarchical representation of an instance that can be
|
/// A lightweight, hierarchical representation of an instance that can be
|
||||||
/// applied to the tree.
|
/// applied to the tree.
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct RbxSnapshotInstance<'a> {
|
pub struct RbxSnapshotInstance<'a> {
|
||||||
pub name: Cow<'a, str>,
|
pub name: Cow<'a, str>,
|
||||||
pub class_name: Cow<'a, str>,
|
pub class_name: Cow<'a, str>,
|
||||||
@@ -73,6 +73,22 @@ pub struct RbxSnapshotInstance<'a> {
|
|||||||
pub metadata: MetadataPerInstance,
|
pub metadata: MetadataPerInstance,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> RbxSnapshotInstance<'a> {
|
||||||
|
pub fn get_owned(&'a self) -> RbxSnapshotInstance<'static> {
|
||||||
|
let children: Vec<RbxSnapshotInstance<'static>> = self.children.iter()
|
||||||
|
.map(RbxSnapshotInstance::get_owned)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
RbxSnapshotInstance {
|
||||||
|
name: Cow::Owned(self.name.clone().into_owned()),
|
||||||
|
class_name: Cow::Owned(self.class_name.clone().into_owned()),
|
||||||
|
properties: self.properties.clone(),
|
||||||
|
children,
|
||||||
|
metadata: self.metadata.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> PartialOrd for RbxSnapshotInstance<'a> {
|
impl<'a> PartialOrd for RbxSnapshotInstance<'a> {
|
||||||
fn partial_cmp(&self, other: &RbxSnapshotInstance) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &RbxSnapshotInstance) -> Option<Ordering> {
|
||||||
Some(self.name.cmp(&other.name)
|
Some(self.name.cmp(&other.name)
|
||||||
@@ -137,7 +153,7 @@ pub fn reify_subtree(
|
|||||||
instance_per_path: &mut PathMap<HashSet<RbxId>>,
|
instance_per_path: &mut PathMap<HashSet<RbxId>>,
|
||||||
metadata_per_instance: &mut HashMap<RbxId, MetadataPerInstance>,
|
metadata_per_instance: &mut HashMap<RbxId, MetadataPerInstance>,
|
||||||
changes: &mut InstanceChanges,
|
changes: &mut InstanceChanges,
|
||||||
) {
|
) -> RbxId {
|
||||||
let instance = reify_core(snapshot);
|
let instance = reify_core(snapshot);
|
||||||
let id = tree.insert_instance(instance, parent_id);
|
let id = tree.insert_instance(instance, parent_id);
|
||||||
|
|
||||||
@@ -148,6 +164,8 @@ pub fn reify_subtree(
|
|||||||
for child in &snapshot.children {
|
for child in &snapshot.children {
|
||||||
reify_subtree(child, tree, id, instance_per_path, metadata_per_instance, changes);
|
reify_subtree(child, tree, id, instance_per_path, metadata_per_instance, changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reify_metadata(
|
fn reify_metadata(
|
||||||
@@ -206,6 +224,9 @@ fn reify_core(snapshot: &RbxSnapshotInstance) -> RbxInstanceProperties {
|
|||||||
instance
|
instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Updates the given instance to match the properties defined on the snapshot.
|
||||||
|
///
|
||||||
|
/// Returns whether any changes were applied.
|
||||||
fn reconcile_instance_properties(instance: &mut RbxInstanceProperties, snapshot: &RbxSnapshotInstance) -> bool {
|
fn reconcile_instance_properties(instance: &mut RbxInstanceProperties, snapshot: &RbxSnapshotInstance) -> bool {
|
||||||
let mut has_diffs = false;
|
let mut has_diffs = false;
|
||||||
|
|
||||||
@@ -263,6 +284,8 @@ fn reconcile_instance_properties(instance: &mut RbxInstanceProperties, snapshot:
|
|||||||
has_diffs
|
has_diffs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Updates the children of the instance in the `RbxTree` to match the children
|
||||||
|
/// of the `RbxSnapshotInstance`. Order will be updated to match.
|
||||||
fn reconcile_instance_children(
|
fn reconcile_instance_children(
|
||||||
tree: &mut RbxTree,
|
tree: &mut RbxTree,
|
||||||
id: RbxId,
|
id: RbxId,
|
||||||
@@ -271,12 +294,21 @@ fn reconcile_instance_children(
|
|||||||
metadata_per_instance: &mut HashMap<RbxId, MetadataPerInstance>,
|
metadata_per_instance: &mut HashMap<RbxId, MetadataPerInstance>,
|
||||||
changes: &mut InstanceChanges,
|
changes: &mut InstanceChanges,
|
||||||
) {
|
) {
|
||||||
let mut visited_snapshot_indices = HashSet::new();
|
// These lists are kept so that we can apply all the changes we figure out
|
||||||
|
let mut children_to_maybe_update: Vec<(RbxId, &RbxSnapshotInstance)> = Vec::new();
|
||||||
let mut children_to_update: Vec<(RbxId, &RbxSnapshotInstance)> = Vec::new();
|
let mut children_to_add: Vec<(usize, &RbxSnapshotInstance)> = Vec::new();
|
||||||
let mut children_to_add: Vec<&RbxSnapshotInstance> = Vec::new();
|
|
||||||
let mut children_to_remove: Vec<RbxId> = Vec::new();
|
let mut children_to_remove: Vec<RbxId> = Vec::new();
|
||||||
|
|
||||||
|
// This map is used once we're done mutating children to sort them according
|
||||||
|
// to the order specified in the snapshot. Without it, a snapshot with a new
|
||||||
|
// child prepended will cause the RbxTree instance to have out-of-order
|
||||||
|
// children and would make Rojo non-deterministic.
|
||||||
|
let mut ids_to_snapshot_indices = HashMap::new();
|
||||||
|
|
||||||
|
// Since we have to enumerate the children of both the RbxTree instance and
|
||||||
|
// our snapshot, we keep a set of the snapshot children we've seen.
|
||||||
|
let mut visited_snapshot_indices = vec![false; snapshot.children.len()];
|
||||||
|
|
||||||
let children_ids = tree.get_instance(id).unwrap().get_children_ids();
|
let children_ids = tree.get_instance(id).unwrap().get_children_ids();
|
||||||
|
|
||||||
// Find all instances that were removed or updated, which we derive by
|
// Find all instances that were removed or updated, which we derive by
|
||||||
@@ -287,7 +319,7 @@ fn reconcile_instance_children(
|
|||||||
// Locate a matching snapshot for this instance
|
// Locate a matching snapshot for this instance
|
||||||
let mut matching_snapshot = None;
|
let mut matching_snapshot = None;
|
||||||
for (snapshot_index, child_snapshot) in snapshot.children.iter().enumerate() {
|
for (snapshot_index, child_snapshot) in snapshot.children.iter().enumerate() {
|
||||||
if visited_snapshot_indices.contains(&snapshot_index) {
|
if visited_snapshot_indices[snapshot_index] {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +327,8 @@ fn reconcile_instance_children(
|
|||||||
// similar. This heuristic is similar to React's reconciliation
|
// similar. This heuristic is similar to React's reconciliation
|
||||||
// strategy.
|
// strategy.
|
||||||
if child_snapshot.name == child_instance.name {
|
if child_snapshot.name == child_instance.name {
|
||||||
visited_snapshot_indices.insert(snapshot_index);
|
ids_to_snapshot_indices.insert(child_id, snapshot_index);
|
||||||
|
visited_snapshot_indices[snapshot_index] = true;
|
||||||
matching_snapshot = Some(child_snapshot);
|
matching_snapshot = Some(child_snapshot);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -303,26 +336,23 @@ fn reconcile_instance_children(
|
|||||||
|
|
||||||
match matching_snapshot {
|
match matching_snapshot {
|
||||||
Some(child_snapshot) => {
|
Some(child_snapshot) => {
|
||||||
children_to_update.push((child_instance.get_id(), child_snapshot));
|
children_to_maybe_update.push((child_instance.get_id(), child_snapshot));
|
||||||
},
|
}
|
||||||
None => {
|
None => {
|
||||||
children_to_remove.push(child_instance.get_id());
|
children_to_remove.push(child_instance.get_id());
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find all instancs that were added, which is just the snapshots we didn't
|
// Find all instancs that were added, which is just the snapshots we didn't
|
||||||
// match up to existing instances above.
|
// match up to existing instances above.
|
||||||
for (snapshot_index, child_snapshot) in snapshot.children.iter().enumerate() {
|
for (snapshot_index, child_snapshot) in snapshot.children.iter().enumerate() {
|
||||||
if !visited_snapshot_indices.contains(&snapshot_index) {
|
if !visited_snapshot_indices[snapshot_index] {
|
||||||
children_to_add.push(child_snapshot);
|
children_to_add.push((snapshot_index, child_snapshot));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for child_snapshot in &children_to_add {
|
// Apply all of our removals we gathered from our diff
|
||||||
reify_subtree(child_snapshot, tree, id, instance_per_path, metadata_per_instance, changes);
|
|
||||||
}
|
|
||||||
|
|
||||||
for child_id in &children_to_remove {
|
for child_id in &children_to_remove {
|
||||||
if let Some(subtree) = tree.remove_instance(*child_id) {
|
if let Some(subtree) = tree.remove_instance(*child_id) {
|
||||||
for id in subtree.iter_all_ids() {
|
for id in subtree.iter_all_ids() {
|
||||||
@@ -332,7 +362,18 @@ fn reconcile_instance_children(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (child_id, child_snapshot) in &children_to_update {
|
// Apply all of our children additions
|
||||||
|
for (snapshot_index, child_snapshot) in &children_to_add {
|
||||||
|
let id = reify_subtree(child_snapshot, tree, id, instance_per_path, metadata_per_instance, changes);
|
||||||
|
ids_to_snapshot_indices.insert(id, *snapshot_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply any updates that might have updates
|
||||||
|
for (child_id, child_snapshot) in &children_to_maybe_update {
|
||||||
reconcile_subtree(tree, *child_id, child_snapshot, instance_per_path, metadata_per_instance, changes);
|
reconcile_subtree(tree, *child_id, child_snapshot, instance_per_path, metadata_per_instance, changes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply the sort mapping defined by ids_to_snapshot_indices above
|
||||||
|
let instance = tree.get_instance_mut(id).unwrap();
|
||||||
|
instance.sort_children_unstable_by_key(|id| ids_to_snapshot_indices.get(&id).unwrap());
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
collections::HashMap,
|
||||||
fmt,
|
fmt,
|
||||||
io::Write,
|
io::Write,
|
||||||
path::Path,
|
path::Path,
|
||||||
@@ -6,12 +7,13 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use rbx_tree::RbxId;
|
use rbx_dom_weak::{RbxTree, RbxId};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
imfs::{Imfs, ImfsItem},
|
imfs::{Imfs, ImfsItem},
|
||||||
rbx_session::RbxSession,
|
rbx_session::RbxSession,
|
||||||
web::PublicInstanceMetadata,
|
web::api::PublicInstanceMetadata,
|
||||||
|
rbx_session::MetadataPerInstance,
|
||||||
};
|
};
|
||||||
|
|
||||||
static GRAPHVIZ_HEADER: &str = r#"
|
static GRAPHVIZ_HEADER: &str = r#"
|
||||||
@@ -53,42 +55,59 @@ pub fn graphviz_to_svg(source: &str) -> Option<String> {
|
|||||||
Some(String::from_utf8(output.stdout).expect("Failed to parse stdout as UTF-8"))
|
Some(String::from_utf8(output.stdout).expect("Failed to parse stdout as UTF-8"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct VisualizeRbxTree<'a, 'b> {
|
||||||
|
pub tree: &'a RbxTree,
|
||||||
|
pub metadata: &'b HashMap<RbxId, MetadataPerInstance>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, 'b> fmt::Display for VisualizeRbxTree<'a, 'b> {
|
||||||
|
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
writeln!(output, "{}", GRAPHVIZ_HEADER)?;
|
||||||
|
|
||||||
|
visualize_instance(&self.tree, self.tree.get_root_id(), &self.metadata, output)?;
|
||||||
|
|
||||||
|
writeln!(output, "}}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A Display wrapper struct to visualize an RbxSession as SVG.
|
/// A Display wrapper struct to visualize an RbxSession as SVG.
|
||||||
pub struct VisualizeRbxSession<'a>(pub &'a RbxSession);
|
pub struct VisualizeRbxSession<'a>(pub &'a RbxSession);
|
||||||
|
|
||||||
impl<'a> fmt::Display for VisualizeRbxSession<'a> {
|
impl<'a> fmt::Display for VisualizeRbxSession<'a> {
|
||||||
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
||||||
writeln!(output, "{}", GRAPHVIZ_HEADER)?;
|
writeln!(output, "{}", VisualizeRbxTree {
|
||||||
|
tree: self.0.get_tree(),
|
||||||
visualize_rbx_node(self.0, self.0.get_tree().get_root_id(), output)?;
|
metadata: self.0.get_all_instance_metadata(),
|
||||||
|
})
|
||||||
writeln!(output, "}}")?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visualize_rbx_node(session: &RbxSession, id: RbxId, output: &mut fmt::Formatter) -> fmt::Result {
|
fn visualize_instance(
|
||||||
let node = session.get_tree().get_instance(id).unwrap();
|
tree: &RbxTree,
|
||||||
|
id: RbxId,
|
||||||
|
metadata: &HashMap<RbxId, MetadataPerInstance>,
|
||||||
|
output: &mut fmt::Formatter,
|
||||||
|
) -> fmt::Result {
|
||||||
|
let instance = tree.get_instance(id).unwrap();
|
||||||
|
|
||||||
let mut node_label = format!("{}|{}|{}", node.name, node.class_name, id);
|
let mut instance_label = format!("{}|{}|{}", instance.name, instance.class_name, id);
|
||||||
|
|
||||||
if let Some(session_metadata) = session.get_instance_metadata(id) {
|
if let Some(session_metadata) = metadata.get(&id) {
|
||||||
let metadata = PublicInstanceMetadata::from_session_metadata(session_metadata);
|
let metadata = PublicInstanceMetadata::from_session_metadata(session_metadata);
|
||||||
node_label.push('|');
|
instance_label.push('|');
|
||||||
node_label.push_str(&serde_json::to_string(&metadata).unwrap());
|
instance_label.push_str(&serde_json::to_string(&metadata).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
node_label = node_label
|
instance_label = instance_label
|
||||||
.replace("\"", """)
|
.replace("\"", """)
|
||||||
.replace("{", "\\{")
|
.replace("{", "\\{")
|
||||||
.replace("}", "\\}");
|
.replace("}", "\\}");
|
||||||
|
|
||||||
writeln!(output, " \"{}\" [label=\"{}\"]", id, node_label)?;
|
writeln!(output, " \"{}\" [label=\"{}\"]", id, instance_label)?;
|
||||||
|
|
||||||
for &child_id in node.get_children_ids() {
|
for &child_id in instance.get_children_ids() {
|
||||||
writeln!(output, " \"{}\" -> \"{}\"", id, child_id)?;
|
writeln!(output, " \"{}\" -> \"{}\"", id, child_id)?;
|
||||||
visualize_rbx_node(session, child_id, output)?;
|
visualize_instance(tree, child_id, metadata, output)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,32 +1,36 @@
|
|||||||
//! Defines Rojo's web interface that all clients use to communicate with a
|
//! Defines Rojo's HTTP API, all under /api. These endpoints generally return
|
||||||
//! running live-sync session.
|
//! JSON.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
sync::{mpsc, Arc},
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serde_derive::{Serialize, Deserialize};
|
use futures::{
|
||||||
use log::trace;
|
future::{self, IntoFuture},
|
||||||
use rouille::{
|
Future,
|
||||||
self,
|
sync::oneshot,
|
||||||
router,
|
};
|
||||||
|
use hyper::{
|
||||||
|
service::Service,
|
||||||
|
header,
|
||||||
|
StatusCode,
|
||||||
|
Method,
|
||||||
|
Body,
|
||||||
Request,
|
Request,
|
||||||
Response,
|
Response,
|
||||||
};
|
};
|
||||||
use rbx_tree::{RbxId, RbxInstance};
|
use serde_derive::{Serialize, Deserialize};
|
||||||
|
use rbx_dom_weak::{RbxId, RbxInstance};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
live_session::LiveSession,
|
live_session::LiveSession,
|
||||||
session_id::SessionId,
|
session_id::SessionId,
|
||||||
snapshot_reconciler::InstanceChanges,
|
snapshot_reconciler::InstanceChanges,
|
||||||
visualize::{VisualizeRbxSession, VisualizeImfs, graphviz_to_svg},
|
|
||||||
rbx_session::{MetadataPerInstance},
|
rbx_session::{MetadataPerInstance},
|
||||||
};
|
};
|
||||||
|
|
||||||
static HOME_CONTENT: &str = include_str!("../assets/index.html");
|
|
||||||
|
|
||||||
/// Contains the instance metadata relevant to Rojo clients.
|
/// Contains the instance metadata relevant to Rojo clients.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
@@ -43,7 +47,7 @@ impl PublicInstanceMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Used to attach metadata specific to Rojo to instances, which come from the
|
/// Used to attach metadata specific to Rojo to instances, which come from the
|
||||||
/// rbx_tree crate.
|
/// rbx_dom_weak crate.
|
||||||
///
|
///
|
||||||
/// Both fields are wrapped in Cow in order to make owned-vs-borrowed simpler
|
/// Both fields are wrapped in Cow in order to make owned-vs-borrowed simpler
|
||||||
/// for tests.
|
/// for tests.
|
||||||
@@ -82,121 +86,133 @@ pub struct SubscribeResponse<'a> {
|
|||||||
pub messages: Cow<'a, [InstanceChanges]>,
|
pub messages: Cow<'a, [InstanceChanges]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Server {
|
fn response_json<T: serde::Serialize>(value: T) -> Response<Body> {
|
||||||
|
let serialized = match serde_json::to_string(&value) {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(err) => {
|
||||||
|
return Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.header(header::CONTENT_TYPE, "text/plain")
|
||||||
|
.body(Body::from(err.to_string()))
|
||||||
|
.unwrap();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Response::builder()
|
||||||
|
.header(header::CONTENT_TYPE, "application/json")
|
||||||
|
.body(Body::from(serialized))
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ApiService {
|
||||||
live_session: Arc<LiveSession>,
|
live_session: Arc<LiveSession>,
|
||||||
server_version: &'static str,
|
server_version: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Server {
|
impl Service for ApiService {
|
||||||
pub fn new(live_session: Arc<LiveSession>) -> Server {
|
type ReqBody = Body;
|
||||||
Server {
|
type ResBody = Body;
|
||||||
|
type Error = hyper::Error;
|
||||||
|
type Future = Box<dyn Future<Item = hyper::Response<Self::ReqBody>, Error = Self::Error> + Send>;
|
||||||
|
|
||||||
|
fn call(&mut self, request: hyper::Request<Self::ReqBody>) -> Self::Future {
|
||||||
|
let response = match (request.method(), request.uri().path()) {
|
||||||
|
(&Method::GET, "/api/rojo") => self.handle_api_rojo(),
|
||||||
|
(&Method::GET, path) if path.starts_with("/api/read/") => self.handle_api_read(request),
|
||||||
|
(&Method::GET, path) if path.starts_with("/api/subscribe/") => {
|
||||||
|
return self.handle_api_subscribe(request);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
Response::builder()
|
||||||
|
.status(StatusCode::NOT_FOUND)
|
||||||
|
.body(Body::empty())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Box::new(future::ok(response))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ApiService {
|
||||||
|
pub fn new(live_session: Arc<LiveSession>) -> ApiService {
|
||||||
|
ApiService {
|
||||||
live_session,
|
live_session,
|
||||||
server_version: env!("CARGO_PKG_VERSION"),
|
server_version: env!("CARGO_PKG_VERSION"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unreachable_code)]
|
|
||||||
pub fn handle_request(&self, request: &Request) -> Response {
|
|
||||||
trace!("Request {} {}", request.method(), request.url());
|
|
||||||
|
|
||||||
router!(request,
|
|
||||||
(GET) (/) => {
|
|
||||||
self.handle_home()
|
|
||||||
},
|
|
||||||
(GET) (/api/rojo) => {
|
|
||||||
self.handle_api_rojo()
|
|
||||||
},
|
|
||||||
(GET) (/api/subscribe/{ cursor: u32 }) => {
|
|
||||||
self.handle_api_subscribe(cursor)
|
|
||||||
},
|
|
||||||
(GET) (/api/read/{ id_list: String }) => {
|
|
||||||
let requested_ids: Option<Vec<RbxId>> = id_list
|
|
||||||
.split(',')
|
|
||||||
.map(RbxId::parse_str)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
self.handle_api_read(requested_ids)
|
|
||||||
},
|
|
||||||
(GET) (/visualize/rbx) => {
|
|
||||||
self.handle_visualize_rbx()
|
|
||||||
},
|
|
||||||
(GET) (/visualize/imfs) => {
|
|
||||||
self.handle_visualize_imfs()
|
|
||||||
},
|
|
||||||
_ => Response::empty_404()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn listen(self, port: u16) {
|
|
||||||
let address = format!("0.0.0.0:{}", port);
|
|
||||||
|
|
||||||
rouille::start_server(address, move |request| self.handle_request(request));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_home(&self) -> Response {
|
|
||||||
Response::html(HOME_CONTENT)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a summary of information about the server
|
/// Get a summary of information about the server
|
||||||
fn handle_api_rojo(&self) -> Response {
|
fn handle_api_rojo(&self) -> Response<Body> {
|
||||||
let rbx_session = self.live_session.rbx_session.lock().unwrap();
|
let rbx_session = self.live_session.rbx_session.lock().unwrap();
|
||||||
let tree = rbx_session.get_tree();
|
let tree = rbx_session.get_tree();
|
||||||
|
|
||||||
Response::json(&ServerInfoResponse {
|
response_json(&ServerInfoResponse {
|
||||||
server_version: self.server_version,
|
server_version: self.server_version,
|
||||||
protocol_version: 2,
|
protocol_version: 2,
|
||||||
session_id: self.live_session.session_id,
|
session_id: self.live_session.session_id(),
|
||||||
expected_place_ids: self.live_session.project.serve_place_ids.clone(),
|
expected_place_ids: self.live_session.serve_place_ids().clone(),
|
||||||
root_instance_id: tree.get_root_id(),
|
root_instance_id: tree.get_root_id(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve any messages past the given cursor index, and if
|
/// Retrieve any messages past the given cursor index, and if
|
||||||
/// there weren't any, subscribe to receive any new messages.
|
/// there weren't any, subscribe to receive any new messages.
|
||||||
fn handle_api_subscribe(&self, cursor: u32) -> Response {
|
fn handle_api_subscribe(&self, request: Request<Body>) -> <ApiService as Service>::Future {
|
||||||
|
let argument = &request.uri().path()["/api/subscribe/".len()..];
|
||||||
|
let cursor: u32 = match argument.parse() {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(err) => {
|
||||||
|
return Box::new(future::ok(Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.header(header::CONTENT_TYPE, "text/plain")
|
||||||
|
.body(Body::from(err.to_string()))
|
||||||
|
.unwrap()));
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
let message_queue = Arc::clone(&self.live_session.message_queue);
|
let message_queue = Arc::clone(&self.live_session.message_queue);
|
||||||
|
let session_id = self.live_session.session_id();
|
||||||
|
|
||||||
// Did the client miss any messages since the last subscribe?
|
let (tx, rx) = oneshot::channel();
|
||||||
{
|
message_queue.subscribe(cursor, tx);
|
||||||
let (new_cursor, new_messages) = message_queue.get_messages_since(cursor);
|
|
||||||
|
|
||||||
if !new_messages.is_empty() {
|
let result = rx.into_future()
|
||||||
return Response::json(&SubscribeResponse {
|
.and_then(move |(new_cursor, new_messages)| {
|
||||||
session_id: self.live_session.session_id,
|
Box::new(future::ok(response_json(SubscribeResponse {
|
||||||
messages: Cow::Borrowed(&new_messages),
|
session_id: session_id,
|
||||||
|
messages: Cow::Owned(new_messages),
|
||||||
message_cursor: new_cursor,
|
message_cursor: new_cursor,
|
||||||
})
|
})))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let (tx, rx) = mpsc::channel();
|
|
||||||
|
|
||||||
let sender_id = message_queue.subscribe(tx);
|
|
||||||
|
|
||||||
match rx.recv() {
|
|
||||||
Ok(_) => (),
|
|
||||||
Err(_) => return Response::text("error!").with_status_code(500),
|
|
||||||
}
|
|
||||||
|
|
||||||
message_queue.unsubscribe(sender_id);
|
|
||||||
|
|
||||||
{
|
|
||||||
let (new_cursor, new_messages) = message_queue.get_messages_since(cursor);
|
|
||||||
|
|
||||||
return Response::json(&SubscribeResponse {
|
|
||||||
session_id: self.live_session.session_id,
|
|
||||||
messages: Cow::Owned(new_messages),
|
|
||||||
message_cursor: new_cursor,
|
|
||||||
})
|
})
|
||||||
}
|
.or_else(|e| {
|
||||||
|
Box::new(future::ok(Response::builder()
|
||||||
|
.status(500)
|
||||||
|
.body(Body::from(format!("Internal Error: {:?}", e)))
|
||||||
|
.unwrap()))
|
||||||
|
});
|
||||||
|
|
||||||
|
Box::new(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_api_read(&self, requested_ids: Option<Vec<RbxId>>) -> Response {
|
fn handle_api_read(&self, request: Request<Body>) -> Response<Body> {
|
||||||
|
let argument = &request.uri().path()["/api/read/".len()..];
|
||||||
|
let requested_ids: Option<Vec<RbxId>> = argument
|
||||||
|
.split(',')
|
||||||
|
.map(RbxId::parse_str)
|
||||||
|
.collect();
|
||||||
|
|
||||||
let message_queue = Arc::clone(&self.live_session.message_queue);
|
let message_queue = Arc::clone(&self.live_session.message_queue);
|
||||||
|
|
||||||
let requested_ids = match requested_ids {
|
let requested_ids = match requested_ids {
|
||||||
Some(id) => id,
|
Some(id) => id,
|
||||||
None => return rouille::Response::text("Malformed ID list").with_status_code(400),
|
None => {
|
||||||
|
return Response::builder()
|
||||||
|
.status(StatusCode::BAD_REQUEST)
|
||||||
|
.header(header::CONTENT_TYPE, "text/plain")
|
||||||
|
.body(Body::from("Malformed ID list"))
|
||||||
|
.unwrap();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let rbx_session = self.live_session.rbx_session.lock().unwrap();
|
let rbx_session = self.live_session.rbx_session.lock().unwrap();
|
||||||
@@ -228,30 +244,10 @@ impl Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Response::json(&ReadResponse {
|
response_json(&ReadResponse {
|
||||||
session_id: self.live_session.session_id,
|
session_id: self.live_session.session_id(),
|
||||||
message_cursor,
|
message_cursor,
|
||||||
instances,
|
instances,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_visualize_rbx(&self) -> Response {
|
|
||||||
let rbx_session = self.live_session.rbx_session.lock().unwrap();
|
|
||||||
let dot_source = format!("{}", VisualizeRbxSession(&rbx_session));
|
|
||||||
|
|
||||||
match graphviz_to_svg(&dot_source) {
|
|
||||||
Some(svg) => Response::svg(svg),
|
|
||||||
None => Response::text(dot_source),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_visualize_imfs(&self) -> Response {
|
|
||||||
let imfs = self.live_session.imfs.lock().unwrap();
|
|
||||||
let dot_source = format!("{}", VisualizeImfs(&imfs));
|
|
||||||
|
|
||||||
match graphviz_to_svg(&dot_source) {
|
|
||||||
Some(svg) => Response::svg(svg),
|
|
||||||
None => Response::text(dot_source),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
121
server/src/web/interface.rs
Normal file
121
server/src/web/interface.rs
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
//! Defines the HTTP-based UI. These endpoints generally return HTML and SVG.
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use futures::{future, Future};
|
||||||
|
use hyper::{
|
||||||
|
service::Service,
|
||||||
|
header,
|
||||||
|
Body,
|
||||||
|
Method,
|
||||||
|
StatusCode,
|
||||||
|
Request,
|
||||||
|
Response,
|
||||||
|
};
|
||||||
|
use ritz::html;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
live_session::LiveSession,
|
||||||
|
visualize::{VisualizeRbxSession, VisualizeImfs, graphviz_to_svg},
|
||||||
|
};
|
||||||
|
|
||||||
|
static HOME_CSS: &str = include_str!("../../assets/index.css");
|
||||||
|
|
||||||
|
pub struct InterfaceService {
|
||||||
|
live_session: Arc<LiveSession>,
|
||||||
|
server_version: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service for InterfaceService {
|
||||||
|
type ReqBody = Body;
|
||||||
|
type ResBody = Body;
|
||||||
|
type Error = hyper::Error;
|
||||||
|
type Future = Box<dyn Future<Item = Response<Self::ReqBody>, Error = Self::Error> + Send>;
|
||||||
|
|
||||||
|
fn call(&mut self, request: Request<Self::ReqBody>) -> Self::Future {
|
||||||
|
let response = match (request.method(), request.uri().path()) {
|
||||||
|
(&Method::GET, "/") => self.handle_home(),
|
||||||
|
(&Method::GET, "/visualize/rbx") => self.handle_visualize_rbx(),
|
||||||
|
(&Method::GET, "/visualize/imfs") => self.handle_visualize_imfs(),
|
||||||
|
_ => Response::builder()
|
||||||
|
.status(StatusCode::NOT_FOUND)
|
||||||
|
.body(Body::empty())
|
||||||
|
.unwrap(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Box::new(future::ok(response))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InterfaceService {
|
||||||
|
pub fn new(live_session: Arc<LiveSession>) -> InterfaceService {
|
||||||
|
InterfaceService {
|
||||||
|
live_session,
|
||||||
|
server_version: env!("CARGO_PKG_VERSION"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_home(&self) -> Response<Body> {
|
||||||
|
let page = html! {
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>"Rojo"</title>
|
||||||
|
<style>
|
||||||
|
{ ritz::UnescapedText::new(HOME_CSS) }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="main">
|
||||||
|
<h1 class="title">
|
||||||
|
"Rojo Live Sync is up and running!"
|
||||||
|
</h1>
|
||||||
|
<h2 class="subtitle">
|
||||||
|
"Version " { self.server_version }
|
||||||
|
</h2>
|
||||||
|
<a class="docs" href="https://lpghatguy.github.io/rojo">
|
||||||
|
"Rojo Documentation"
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
};
|
||||||
|
|
||||||
|
Response::builder()
|
||||||
|
.header(header::CONTENT_TYPE, "text/html")
|
||||||
|
.body(Body::from(format!("<!DOCTYPE html>{}", page)))
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_visualize_rbx(&self) -> Response<Body> {
|
||||||
|
let rbx_session = self.live_session.rbx_session.lock().unwrap();
|
||||||
|
let dot_source = format!("{}", VisualizeRbxSession(&rbx_session));
|
||||||
|
|
||||||
|
match graphviz_to_svg(&dot_source) {
|
||||||
|
Some(svg) => Response::builder()
|
||||||
|
.header(header::CONTENT_TYPE, "image/svg+xml")
|
||||||
|
.body(Body::from(svg))
|
||||||
|
.unwrap(),
|
||||||
|
None => Response::builder()
|
||||||
|
.header(header::CONTENT_TYPE, "text/plain")
|
||||||
|
.body(Body::from(dot_source))
|
||||||
|
.unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_visualize_imfs(&self) -> Response<Body> {
|
||||||
|
let imfs = self.live_session.imfs.lock().unwrap();
|
||||||
|
let dot_source = format!("{}", VisualizeImfs(&imfs));
|
||||||
|
|
||||||
|
match graphviz_to_svg(&dot_source) {
|
||||||
|
Some(svg) => Response::builder()
|
||||||
|
.header(header::CONTENT_TYPE, "image/svg+xml")
|
||||||
|
.body(Body::from(svg))
|
||||||
|
.unwrap(),
|
||||||
|
None => Response::builder()
|
||||||
|
.header(header::CONTENT_TYPE, "text/plain")
|
||||||
|
.body(Body::from(dot_source))
|
||||||
|
.unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
85
server/src/web/mod.rs
Normal file
85
server/src/web/mod.rs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
// TODO: This module needs to be public for visualize, we should move
|
||||||
|
// PublicInstanceMetadata and switch this private!
|
||||||
|
pub mod api;
|
||||||
|
mod interface;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use log::trace;
|
||||||
|
use futures::{
|
||||||
|
future::{self, FutureResult},
|
||||||
|
Future,
|
||||||
|
};
|
||||||
|
use hyper::{
|
||||||
|
service::Service,
|
||||||
|
Body,
|
||||||
|
Request,
|
||||||
|
Response,
|
||||||
|
Server,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
live_session::LiveSession,
|
||||||
|
};
|
||||||
|
|
||||||
|
use self::{
|
||||||
|
api::ApiService,
|
||||||
|
interface::InterfaceService,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct RootService {
|
||||||
|
api: api::ApiService,
|
||||||
|
interface: interface::InterfaceService,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Service for RootService {
|
||||||
|
type ReqBody = Body;
|
||||||
|
type ResBody = Body;
|
||||||
|
type Error = hyper::Error;
|
||||||
|
type Future = Box<dyn Future<Item = Response<Self::ReqBody>, Error = Self::Error> + Send>;
|
||||||
|
|
||||||
|
fn call(&mut self, request: Request<Self::ReqBody>) -> Self::Future {
|
||||||
|
trace!("{} {}", request.method(), request.uri().path());
|
||||||
|
|
||||||
|
if request.uri().path().starts_with("/api") {
|
||||||
|
self.api.call(request)
|
||||||
|
} else {
|
||||||
|
self.interface.call(request)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RootService {
|
||||||
|
pub fn new(live_session: Arc<LiveSession>) -> RootService {
|
||||||
|
RootService {
|
||||||
|
api: ApiService::new(Arc::clone(&live_session)),
|
||||||
|
interface: InterfaceService::new(Arc::clone(&live_session)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct LiveServer {
|
||||||
|
live_session: Arc<LiveSession>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LiveServer {
|
||||||
|
pub fn new(live_session: Arc<LiveSession>) -> LiveServer {
|
||||||
|
LiveServer {
|
||||||
|
live_session,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start(self, port: u16) {
|
||||||
|
let address = ([127, 0, 0, 1], port).into();
|
||||||
|
|
||||||
|
let server = Server::bind(&address)
|
||||||
|
.serve(move || {
|
||||||
|
let service: FutureResult<_, hyper::Error> =
|
||||||
|
future::ok(RootService::new(Arc::clone(&self.live_session)));
|
||||||
|
service
|
||||||
|
})
|
||||||
|
.map_err(|e| eprintln!("Server error: {}", e));
|
||||||
|
|
||||||
|
hyper::rt::run(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
use std::io::Read;
|
|
||||||
|
|
||||||
use rouille;
|
|
||||||
use serde;
|
|
||||||
use serde_json;
|
|
||||||
|
|
||||||
static MAX_BODY_SIZE: usize = 100 * 1024 * 1024; // 100 MiB
|
|
||||||
|
|
||||||
/// Pulls text that may be JSON out of a Rouille Request object.
|
|
||||||
///
|
|
||||||
/// Doesn't do any actual parsing -- all this method does is verify the content
|
|
||||||
/// type of the request and read the request's body.
|
|
||||||
fn read_json_text(request: &rouille::Request) -> Option<String> {
|
|
||||||
// Bail out if the request body isn't marked as JSON
|
|
||||||
let content_type = request.header("Content-Type")?;
|
|
||||||
|
|
||||||
if !content_type.starts_with("application/json") {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
let body = request.data()?;
|
|
||||||
|
|
||||||
// Allocate a buffer and read up to MAX_BODY_SIZE+1 bytes into it.
|
|
||||||
let mut out = Vec::new();
|
|
||||||
body.take(MAX_BODY_SIZE.saturating_add(1) as u64).read_to_end(&mut out).ok()?;
|
|
||||||
|
|
||||||
// If the body was too big (MAX_BODY_SIZE+1), we abort instead of trying to
|
|
||||||
// process it.
|
|
||||||
if out.len() > MAX_BODY_SIZE {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
String::from_utf8(out).ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reads the body out of a Rouille Request and attempts to turn it into JSON.
|
|
||||||
pub fn read_json<T>(request: &rouille::Request) -> Option<T>
|
|
||||||
where
|
|
||||||
T: serde::de::DeserializeOwned,
|
|
||||||
{
|
|
||||||
let body = read_json_text(&request)?;
|
|
||||||
serde_json::from_str(&body).ok()?
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet, BTreeSet},
|
||||||
fs,
|
fs,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
};
|
};
|
||||||
@@ -80,7 +80,7 @@ fn base_tree() -> Result<(TempDir, Imfs, ExpectedImfs, TestResources), Error> {
|
|||||||
expected_roots.insert(root.path().to_path_buf());
|
expected_roots.insert(root.path().to_path_buf());
|
||||||
|
|
||||||
let root_item = {
|
let root_item = {
|
||||||
let mut children = HashSet::new();
|
let mut children = BTreeSet::new();
|
||||||
children.insert(foo_path.clone());
|
children.insert(foo_path.clone());
|
||||||
children.insert(bar_path.clone());
|
children.insert(bar_path.clone());
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ fn base_tree() -> Result<(TempDir, Imfs, ExpectedImfs, TestResources), Error> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let foo_item = {
|
let foo_item = {
|
||||||
let mut children = HashSet::new();
|
let mut children = BTreeSet::new();
|
||||||
children.insert(baz_path.clone());
|
children.insert(baz_path.clone());
|
||||||
|
|
||||||
ImfsItem::Directory(ImfsDirectory {
|
ImfsItem::Directory(ImfsDirectory {
|
||||||
@@ -199,7 +199,7 @@ fn adding_folder() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let folder_item = {
|
let folder_item = {
|
||||||
let mut children = HashSet::new();
|
let mut children = BTreeSet::new();
|
||||||
children.insert(file1_path.clone());
|
children.insert(file1_path.clone());
|
||||||
children.insert(file2_path.clone());
|
children.insert(file2_path.clone());
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{HashMap, BTreeMap},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rbx_tree::RbxValue;
|
use rbx_dom_weak::RbxValue;
|
||||||
|
|
||||||
use librojo::{
|
use librojo::{
|
||||||
project::{Project, ProjectNode},
|
project::{Project, ProjectNode},
|
||||||
@@ -53,7 +53,7 @@ fn single_partition_game() {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut replicated_storage_children = HashMap::new();
|
let mut replicated_storage_children = BTreeMap::new();
|
||||||
replicated_storage_children.insert("Foo".to_string(), foo);
|
replicated_storage_children.insert("Foo".to_string(), foo);
|
||||||
|
|
||||||
let replicated_storage = ProjectNode {
|
let replicated_storage = ProjectNode {
|
||||||
@@ -65,7 +65,7 @@ fn single_partition_game() {
|
|||||||
let mut http_service_properties = HashMap::new();
|
let mut http_service_properties = HashMap::new();
|
||||||
http_service_properties.insert("HttpEnabled".to_string(), RbxValue::Bool {
|
http_service_properties.insert("HttpEnabled".to_string(), RbxValue::Bool {
|
||||||
value: true,
|
value: true,
|
||||||
});
|
}.into());
|
||||||
|
|
||||||
let http_service = ProjectNode {
|
let http_service = ProjectNode {
|
||||||
class_name: Some(String::from("HttpService")),
|
class_name: Some(String::from("HttpService")),
|
||||||
@@ -73,7 +73,7 @@ fn single_partition_game() {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut root_children = HashMap::new();
|
let mut root_children = BTreeMap::new();
|
||||||
root_children.insert("ReplicatedStorage".to_string(), replicated_storage);
|
root_children.insert("ReplicatedStorage".to_string(), replicated_storage);
|
||||||
root_children.insert("HttpService".to_string(), http_service);
|
root_children.insert("HttpService".to_string(), http_service);
|
||||||
|
|
||||||
@@ -86,6 +86,7 @@ fn single_partition_game() {
|
|||||||
Project {
|
Project {
|
||||||
name: "single-sync-point".to_string(),
|
name: "single-sync-point".to_string(),
|
||||||
tree: root_node,
|
tree: root_node,
|
||||||
|
plugins: Vec::new(),
|
||||||
serve_port: None,
|
serve_port: None,
|
||||||
serve_place_ids: None,
|
serve_place_ids: None,
|
||||||
file_location: project_location.join("default.project.json"),
|
file_location: project_location.join("default.project.json"),
|
||||||
|
|||||||
112
server/tests/snapshot_reconciler.rs
Normal file
112
server/tests/snapshot_reconciler.rs
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
mod test_util;
|
||||||
|
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
use rbx_dom_weak::{RbxTree, RbxInstanceProperties};
|
||||||
|
|
||||||
|
use librojo::{
|
||||||
|
snapshot_reconciler::{RbxSnapshotInstance, reconcile_subtree},
|
||||||
|
};
|
||||||
|
|
||||||
|
use test_util::tree::trees_equal;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn patch_communicativity() {
|
||||||
|
let base_tree = RbxTree::new(RbxInstanceProperties {
|
||||||
|
name: "DataModel".into(),
|
||||||
|
class_name: "DataModel".into(),
|
||||||
|
properties: HashMap::new(),
|
||||||
|
});
|
||||||
|
|
||||||
|
let patch_a = RbxSnapshotInstance {
|
||||||
|
name: "DataModel".into(),
|
||||||
|
class_name: "DataModel".into(),
|
||||||
|
children: vec![
|
||||||
|
RbxSnapshotInstance {
|
||||||
|
name: "Child-A".into(),
|
||||||
|
class_name: "Folder".into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let patch_b = RbxSnapshotInstance {
|
||||||
|
name: "DataModel".into(),
|
||||||
|
class_name: "DataModel".into(),
|
||||||
|
children: vec![
|
||||||
|
RbxSnapshotInstance {
|
||||||
|
name: "Child-B".into(),
|
||||||
|
class_name: "Folder".into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let patch_combined = RbxSnapshotInstance {
|
||||||
|
name: "DataModel".into(),
|
||||||
|
class_name: "DataModel".into(),
|
||||||
|
children: vec![
|
||||||
|
RbxSnapshotInstance {
|
||||||
|
name: "Child-A".into(),
|
||||||
|
class_name: "Folder".into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
RbxSnapshotInstance {
|
||||||
|
name: "Child-B".into(),
|
||||||
|
class_name: "Folder".into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
],
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let root_id = base_tree.get_root_id();
|
||||||
|
|
||||||
|
let mut tree_a = base_tree.clone();
|
||||||
|
|
||||||
|
reconcile_subtree(
|
||||||
|
&mut tree_a,
|
||||||
|
root_id,
|
||||||
|
&patch_a,
|
||||||
|
&mut Default::default(),
|
||||||
|
&mut Default::default(),
|
||||||
|
&mut Default::default(),
|
||||||
|
);
|
||||||
|
|
||||||
|
reconcile_subtree(
|
||||||
|
&mut tree_a,
|
||||||
|
root_id,
|
||||||
|
&patch_combined,
|
||||||
|
&mut Default::default(),
|
||||||
|
&mut Default::default(),
|
||||||
|
&mut Default::default(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut tree_b = base_tree.clone();
|
||||||
|
|
||||||
|
reconcile_subtree(
|
||||||
|
&mut tree_b,
|
||||||
|
root_id,
|
||||||
|
&patch_b,
|
||||||
|
&mut Default::default(),
|
||||||
|
&mut Default::default(),
|
||||||
|
&mut Default::default(),
|
||||||
|
);
|
||||||
|
|
||||||
|
reconcile_subtree(
|
||||||
|
&mut tree_b,
|
||||||
|
root_id,
|
||||||
|
&patch_combined,
|
||||||
|
&mut Default::default(),
|
||||||
|
&mut Default::default(),
|
||||||
|
&mut Default::default(),
|
||||||
|
);
|
||||||
|
|
||||||
|
match trees_equal(&tree_a, &tree_b) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(e) => panic!("{}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
68
server/tests/snapshot_snapshots.rs
Normal file
68
server/tests/snapshot_snapshots.rs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
mod test_util;
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
|
use librojo::{
|
||||||
|
imfs::Imfs,
|
||||||
|
project::Project,
|
||||||
|
rbx_snapshot::{SnapshotContext, snapshot_project_tree},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::test_util::{
|
||||||
|
snapshot::*,
|
||||||
|
};
|
||||||
|
|
||||||
|
macro_rules! generate_snapshot_tests {
|
||||||
|
($($name: ident),*) => {
|
||||||
|
$(
|
||||||
|
paste::item! {
|
||||||
|
#[test]
|
||||||
|
fn [<snapshot_ $name>]() {
|
||||||
|
let _ = env_logger::try_init();
|
||||||
|
|
||||||
|
let tests_folder = Path::new(env!("CARGO_MANIFEST_DIR")).join("../test-projects");
|
||||||
|
let project_folder = tests_folder.join(stringify!($name));
|
||||||
|
run_snapshot_test(&project_folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_snapshot_tests!(
|
||||||
|
empty,
|
||||||
|
multi_partition_game,
|
||||||
|
nested_partitions,
|
||||||
|
single_partition_game,
|
||||||
|
single_partition_model,
|
||||||
|
transmute_partition
|
||||||
|
);
|
||||||
|
|
||||||
|
fn run_snapshot_test(path: &Path) {
|
||||||
|
println!("Running snapshot from project: {}", path.display());
|
||||||
|
|
||||||
|
let project = Project::load_fuzzy(path)
|
||||||
|
.expect("Couldn't load project file for snapshot test");
|
||||||
|
|
||||||
|
let mut imfs = Imfs::new();
|
||||||
|
imfs.add_roots_from_project(&project)
|
||||||
|
.expect("Could not add IMFS roots to snapshot project");
|
||||||
|
|
||||||
|
let context = SnapshotContext {
|
||||||
|
plugin_context: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut snapshot = snapshot_project_tree(&context, &imfs, &project)
|
||||||
|
.expect("Could not generate snapshot for snapshot test");
|
||||||
|
|
||||||
|
if let Some(snapshot) = snapshot.as_mut() {
|
||||||
|
anonymize_snapshot(path, snapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
match read_expected_snapshot(path) {
|
||||||
|
Some(expected_snapshot) => assert_eq!(snapshot, expected_snapshot),
|
||||||
|
None => write_expected_snapshot(path, &snapshot),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
use std::{
|
|
||||||
fs::{self, File},
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
|
||||||
|
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
|
|
||||||
use librojo::{
|
|
||||||
imfs::Imfs,
|
|
||||||
project::{Project, ProjectNode},
|
|
||||||
rbx_snapshot::snapshot_project_tree,
|
|
||||||
snapshot_reconciler::{RbxSnapshotInstance},
|
|
||||||
};
|
|
||||||
|
|
||||||
macro_rules! generate_snapshot_tests {
|
|
||||||
($($name: ident),*) => {
|
|
||||||
$(
|
|
||||||
paste::item! {
|
|
||||||
#[test]
|
|
||||||
fn [<snapshot_ $name>]() {
|
|
||||||
let tests_folder = Path::new(env!("CARGO_MANIFEST_DIR")).join("../test-projects");
|
|
||||||
let project_folder = tests_folder.join(stringify!($name));
|
|
||||||
run_snapshot_test(&project_folder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
generate_snapshot_tests!(
|
|
||||||
empty,
|
|
||||||
nested_partitions,
|
|
||||||
single_partition_game,
|
|
||||||
single_partition_model,
|
|
||||||
transmute_partition
|
|
||||||
);
|
|
||||||
|
|
||||||
const SNAPSHOT_EXPECTED_NAME: &str = "expected-snapshot.json";
|
|
||||||
|
|
||||||
fn run_snapshot_test(path: &Path) {
|
|
||||||
println!("Running snapshot from project: {}", path.display());
|
|
||||||
|
|
||||||
let project = Project::load_fuzzy(path)
|
|
||||||
.expect("Couldn't load project file for snapshot test");
|
|
||||||
|
|
||||||
let mut imfs = Imfs::new();
|
|
||||||
imfs.add_roots_from_project(&project)
|
|
||||||
.expect("Could not add IMFS roots to snapshot project");
|
|
||||||
|
|
||||||
let mut snapshot = snapshot_project_tree(&imfs, &project)
|
|
||||||
.expect("Could not generate snapshot for snapshot test");
|
|
||||||
|
|
||||||
if let Some(snapshot) = snapshot.as_mut() {
|
|
||||||
anonymize_snapshot(path, snapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
match read_expected_snapshot(path) {
|
|
||||||
Some(expected_snapshot) => assert_eq!(snapshot, expected_snapshot),
|
|
||||||
None => write_expected_snapshot(path, &snapshot),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Snapshots contain absolute paths, which simplifies much of Rojo.
|
|
||||||
///
|
|
||||||
/// For saving snapshots to the disk, we should strip off the project folder
|
|
||||||
/// path to make them machine-independent. This doesn't work for paths that fall
|
|
||||||
/// outside of the project folder, but that's okay here.
|
|
||||||
///
|
|
||||||
/// We also need to sort children, since Rojo tends to enumerate the filesystem
|
|
||||||
/// in an unpredictable order.
|
|
||||||
fn anonymize_snapshot(project_folder_path: &Path, snapshot: &mut RbxSnapshotInstance) {
|
|
||||||
match snapshot.metadata.source_path.as_mut() {
|
|
||||||
Some(path) => *path = anonymize_path(project_folder_path, path),
|
|
||||||
None => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
match snapshot.metadata.project_definition.as_mut() {
|
|
||||||
Some((_, project_node)) => anonymize_project_node(project_folder_path, project_node),
|
|
||||||
None => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
snapshot.children.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
|
||||||
|
|
||||||
for child in snapshot.children.iter_mut() {
|
|
||||||
anonymize_snapshot(project_folder_path, child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn anonymize_project_node(project_folder_path: &Path, project_node: &mut ProjectNode) {
|
|
||||||
match project_node.path.as_mut() {
|
|
||||||
Some(path) => *path = anonymize_path(project_folder_path, path),
|
|
||||||
None => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
for child_node in project_node.children.values_mut() {
|
|
||||||
anonymize_project_node(project_folder_path, child_node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn anonymize_path(project_folder_path: &Path, path: &Path) -> PathBuf {
|
|
||||||
if path.is_absolute() {
|
|
||||||
path.strip_prefix(project_folder_path)
|
|
||||||
.expect("Could not anonymize absolute path")
|
|
||||||
.to_path_buf()
|
|
||||||
} else {
|
|
||||||
path.to_path_buf()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_expected_snapshot(path: &Path) -> Option<Option<RbxSnapshotInstance<'static>>> {
|
|
||||||
let contents = fs::read(path.join(SNAPSHOT_EXPECTED_NAME)).ok()?;
|
|
||||||
let snapshot: Option<RbxSnapshotInstance<'static>> = serde_json::from_slice(&contents)
|
|
||||||
.expect("Could not deserialize snapshot");
|
|
||||||
|
|
||||||
Some(snapshot)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_expected_snapshot(path: &Path, snapshot: &Option<RbxSnapshotInstance>) {
|
|
||||||
let mut file = File::create(path.join(SNAPSHOT_EXPECTED_NAME))
|
|
||||||
.expect("Could not open file to write snapshot");
|
|
||||||
|
|
||||||
serde_json::to_writer_pretty(&mut file, snapshot)
|
|
||||||
.expect("Could not serialize snapshot to file");
|
|
||||||
}
|
|
||||||
@@ -1,31 +1,13 @@
|
|||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::fs::{create_dir, copy};
|
use std::fs::{create_dir, copy};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use rouille::Request;
|
|
||||||
|
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use librojo::web::Server;
|
pub mod snapshot;
|
||||||
|
pub mod tree;
|
||||||
pub trait HttpTestUtil {
|
|
||||||
fn get_string(&self, url: &str) -> String;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HttpTestUtil for Server {
|
|
||||||
fn get_string(&self, url: &str) -> String {
|
|
||||||
let info_request = Request::fake_http("GET", url, vec![], vec![]);
|
|
||||||
let response = self.handle_request(&info_request);
|
|
||||||
|
|
||||||
assert_eq!(response.status_code, 200);
|
|
||||||
|
|
||||||
let (mut reader, _) = response.data.into_reader_and_size();
|
|
||||||
let mut body = String::new();
|
|
||||||
reader.read_to_string(&mut body).unwrap();
|
|
||||||
|
|
||||||
body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn copy_recursive(from: &Path, to: &Path) -> io::Result<()> {
|
pub fn copy_recursive(from: &Path, to: &Path) -> io::Result<()> {
|
||||||
for entry in WalkDir::new(from) {
|
for entry in WalkDir::new(from) {
|
||||||
|
|||||||
79
server/tests/test_util/snapshot.rs
Normal file
79
server/tests/test_util/snapshot.rs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
|
use librojo::{
|
||||||
|
project::ProjectNode,
|
||||||
|
snapshot_reconciler::RbxSnapshotInstance,
|
||||||
|
rbx_session::MetadataPerInstance,
|
||||||
|
};
|
||||||
|
|
||||||
|
const SNAPSHOT_EXPECTED_NAME: &str = "expected-snapshot.json";
|
||||||
|
|
||||||
|
/// Snapshots contain absolute paths, which simplifies much of Rojo.
|
||||||
|
///
|
||||||
|
/// For saving snapshots to the disk, we should strip off the project folder
|
||||||
|
/// path to make them machine-independent. This doesn't work for paths that fall
|
||||||
|
/// outside of the project folder, but that's okay here.
|
||||||
|
///
|
||||||
|
/// We also need to sort children, since Rojo tends to enumerate the filesystem
|
||||||
|
/// in an unpredictable order.
|
||||||
|
pub fn anonymize_snapshot(project_folder_path: &Path, snapshot: &mut RbxSnapshotInstance) {
|
||||||
|
anonymize_metadata(project_folder_path, &mut snapshot.metadata);
|
||||||
|
|
||||||
|
snapshot.children.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
||||||
|
|
||||||
|
for child in snapshot.children.iter_mut() {
|
||||||
|
anonymize_snapshot(project_folder_path, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn anonymize_metadata(project_folder_path: &Path, metadata: &mut MetadataPerInstance) {
|
||||||
|
match metadata.source_path.as_mut() {
|
||||||
|
Some(path) => *path = anonymize_path(project_folder_path, path),
|
||||||
|
None => {},
|
||||||
|
}
|
||||||
|
|
||||||
|
match metadata.project_definition.as_mut() {
|
||||||
|
Some((_, project_node)) => anonymize_project_node(project_folder_path, project_node),
|
||||||
|
None => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn anonymize_project_node(project_folder_path: &Path, project_node: &mut ProjectNode) {
|
||||||
|
match project_node.path.as_mut() {
|
||||||
|
Some(path) => *path = anonymize_path(project_folder_path, path),
|
||||||
|
None => {},
|
||||||
|
}
|
||||||
|
|
||||||
|
for child_node in project_node.children.values_mut() {
|
||||||
|
anonymize_project_node(project_folder_path, child_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn anonymize_path(project_folder_path: &Path, path: &Path) -> PathBuf {
|
||||||
|
if path.is_absolute() {
|
||||||
|
path.strip_prefix(project_folder_path)
|
||||||
|
.expect("Could not anonymize absolute path")
|
||||||
|
.to_path_buf()
|
||||||
|
} else {
|
||||||
|
path.to_path_buf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn read_expected_snapshot(path: &Path) -> Option<Option<RbxSnapshotInstance<'static>>> {
|
||||||
|
let contents = fs::read(path.join(SNAPSHOT_EXPECTED_NAME)).ok()?;
|
||||||
|
let snapshot: Option<RbxSnapshotInstance<'static>> = serde_json::from_slice(&contents)
|
||||||
|
.expect("Could not deserialize snapshot");
|
||||||
|
|
||||||
|
Some(snapshot)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write_expected_snapshot(path: &Path, snapshot: &Option<RbxSnapshotInstance>) {
|
||||||
|
let mut file = File::create(path.join(SNAPSHOT_EXPECTED_NAME))
|
||||||
|
.expect("Could not open file to write snapshot");
|
||||||
|
|
||||||
|
serde_json::to_writer_pretty(&mut file, snapshot)
|
||||||
|
.expect("Could not serialize snapshot to file");
|
||||||
|
}
|
||||||
351
server/tests/test_util/tree.rs
Normal file
351
server/tests/test_util/tree.rs
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
//! Defines a mechanism to compare two RbxTree objects and generate a useful
|
||||||
|
//! diff if they aren't the same. These methods ignore IDs, which are randomly
|
||||||
|
//! generated whenever a tree is constructed anyways. This makes matching up
|
||||||
|
//! pairs of instances that should be the same potentially difficult.
|
||||||
|
//!
|
||||||
|
//! It relies on a couple different ideas:
|
||||||
|
//! - Instances with the same name and class name are matched as the same
|
||||||
|
//! instance. See basic_equal for this logic
|
||||||
|
//! - A path of period-delimited names (like Roblox's GetFullName) should be
|
||||||
|
//! enough to debug most issues. If it isn't, we can do something fun like
|
||||||
|
//! generate GraphViz graphs.
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
fmt,
|
||||||
|
fs::{self, File},
|
||||||
|
hash::Hash,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
|
use log::error;
|
||||||
|
use serde_derive::{Serialize, Deserialize};
|
||||||
|
use rbx_dom_weak::{RbxId, RbxTree};
|
||||||
|
|
||||||
|
use librojo::{
|
||||||
|
rbx_session::MetadataPerInstance,
|
||||||
|
live_session::LiveSession,
|
||||||
|
visualize::{VisualizeRbxTree, graphviz_to_svg},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::snapshot::anonymize_metadata;
|
||||||
|
|
||||||
|
/// Marks a 'step' in the test, which will snapshot the session's current
|
||||||
|
/// RbxTree object and compare it against the saved snapshot if it exists.
|
||||||
|
pub fn tree_step(step: &str, live_session: &LiveSession, source_path: &Path) {
|
||||||
|
let rbx_session = live_session.rbx_session.lock().unwrap();
|
||||||
|
let tree = rbx_session.get_tree();
|
||||||
|
|
||||||
|
let project_folder = live_session.root_project().folder_location();
|
||||||
|
let metadata = rbx_session.get_all_instance_metadata()
|
||||||
|
.iter()
|
||||||
|
.map(|(key, meta)| {
|
||||||
|
let mut meta = meta.clone();
|
||||||
|
anonymize_metadata(project_folder, &mut meta);
|
||||||
|
(*key, meta)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let tree_with_metadata = TreeWithMetadata {
|
||||||
|
tree: Cow::Borrowed(&tree),
|
||||||
|
metadata: Cow::Owned(metadata),
|
||||||
|
};
|
||||||
|
|
||||||
|
match read_tree_by_name(source_path, step) {
|
||||||
|
Some(expected) => match trees_and_metadata_equal(&expected, &tree_with_metadata) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(e) => {
|
||||||
|
error!("Trees at step '{}' were not equal.\n{}", step, e);
|
||||||
|
|
||||||
|
let expected_gv = format!("{}", VisualizeRbxTree {
|
||||||
|
tree: &expected.tree,
|
||||||
|
metadata: &expected.metadata,
|
||||||
|
});
|
||||||
|
|
||||||
|
let actual_gv = format!("{}", VisualizeRbxTree {
|
||||||
|
tree: &tree_with_metadata.tree,
|
||||||
|
metadata: &tree_with_metadata.metadata,
|
||||||
|
});
|
||||||
|
|
||||||
|
let output_dir = PathBuf::from("failed-snapshots");
|
||||||
|
fs::create_dir_all(&output_dir)
|
||||||
|
.expect("Could not create failed-snapshots directory");
|
||||||
|
|
||||||
|
let expected_basename = format!("{}-{}-expected", live_session.root_project().name, step);
|
||||||
|
let actual_basename = format!("{}-{}-actual", live_session.root_project().name, step);
|
||||||
|
|
||||||
|
let mut expected_out = output_dir.join(expected_basename);
|
||||||
|
let mut actual_out = output_dir.join(actual_basename);
|
||||||
|
|
||||||
|
match (graphviz_to_svg(&expected_gv), graphviz_to_svg(&actual_gv)) {
|
||||||
|
(Some(expected_svg), Some(actual_svg)) => {
|
||||||
|
expected_out.set_extension("svg");
|
||||||
|
actual_out.set_extension("svg");
|
||||||
|
|
||||||
|
fs::write(&expected_out, expected_svg)
|
||||||
|
.expect("Couldn't write expected SVG");
|
||||||
|
|
||||||
|
fs::write(&actual_out, actual_svg)
|
||||||
|
.expect("Couldn't write actual SVG");
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
expected_out.set_extension("gv");
|
||||||
|
actual_out.set_extension("gv");
|
||||||
|
|
||||||
|
fs::write(&expected_out, expected_gv)
|
||||||
|
.expect("Couldn't write expected GV");
|
||||||
|
|
||||||
|
fs::write(&actual_out, actual_gv)
|
||||||
|
.expect("Couldn't write actual GV");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error!("Output at {} and {}", expected_out.display(), actual_out.display());
|
||||||
|
|
||||||
|
panic!("Tree mismatch at step '{}'", step);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
write_tree_by_name(source_path, step, &tree_with_metadata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_cow_map<K: Clone + Eq + Hash, V: Clone>() -> Cow<'static, HashMap<K, V>> {
|
||||||
|
Cow::Owned(HashMap::new())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
struct TreeWithMetadata<'a> {
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub tree: Cow<'a, RbxTree>,
|
||||||
|
|
||||||
|
#[serde(default = "new_cow_map")]
|
||||||
|
pub metadata: Cow<'a, HashMap<RbxId, MetadataPerInstance>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_tree_by_name(path: &Path, identifier: &str) -> Option<TreeWithMetadata<'static>> {
|
||||||
|
let mut file_path = path.join(identifier);
|
||||||
|
file_path.set_extension("tree.json");
|
||||||
|
|
||||||
|
let contents = fs::read(&file_path).ok()?;
|
||||||
|
let tree: TreeWithMetadata = serde_json::from_slice(&contents)
|
||||||
|
.expect("Could not deserialize tree");
|
||||||
|
|
||||||
|
Some(tree)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_tree_by_name(path: &Path, identifier: &str, tree: &TreeWithMetadata) {
|
||||||
|
let mut file_path = path.join(identifier);
|
||||||
|
file_path.set_extension("tree.json");
|
||||||
|
|
||||||
|
let mut file = File::create(file_path)
|
||||||
|
.expect("Could not open file to write tree");
|
||||||
|
|
||||||
|
serde_json::to_writer_pretty(&mut file, tree)
|
||||||
|
.expect("Could not serialize tree to file");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct TreeMismatch {
|
||||||
|
pub path: Cow<'static, str>,
|
||||||
|
pub detail: Cow<'static, str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TreeMismatch {
|
||||||
|
pub fn new<'a, A: Into<Cow<'a, str>>, B: Into<Cow<'a, str>>>(path: A, detail: B) -> TreeMismatch {
|
||||||
|
TreeMismatch {
|
||||||
|
path: Cow::Owned(path.into().into_owned()),
|
||||||
|
detail: Cow::Owned(detail.into().into_owned()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_parent(mut self, name: &str) -> TreeMismatch {
|
||||||
|
self.path.to_mut().insert(0, '.');
|
||||||
|
self.path.to_mut().insert_str(0, name);
|
||||||
|
|
||||||
|
TreeMismatch {
|
||||||
|
path: self.path,
|
||||||
|
detail: self.detail,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for TreeMismatch {
|
||||||
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
writeln!(formatter, "Tree mismatch at path {}", self.path)?;
|
||||||
|
writeln!(formatter, "{}", self.detail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn trees_equal(
|
||||||
|
left_tree: &RbxTree,
|
||||||
|
right_tree: &RbxTree,
|
||||||
|
) -> Result<(), TreeMismatch> {
|
||||||
|
let left = TreeWithMetadata {
|
||||||
|
tree: Cow::Borrowed(left_tree),
|
||||||
|
metadata: Cow::Owned(HashMap::new()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let right = TreeWithMetadata {
|
||||||
|
tree: Cow::Borrowed(right_tree),
|
||||||
|
metadata: Cow::Owned(HashMap::new()),
|
||||||
|
};
|
||||||
|
|
||||||
|
trees_and_metadata_equal(&left, &right)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn trees_and_metadata_equal(
|
||||||
|
left_tree: &TreeWithMetadata,
|
||||||
|
right_tree: &TreeWithMetadata,
|
||||||
|
) -> Result<(), TreeMismatch> {
|
||||||
|
let left_id = left_tree.tree.get_root_id();
|
||||||
|
let right_id = right_tree.tree.get_root_id();
|
||||||
|
|
||||||
|
instances_equal(left_tree, left_id, right_tree, right_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn instances_equal(
|
||||||
|
left_tree: &TreeWithMetadata,
|
||||||
|
left_id: RbxId,
|
||||||
|
right_tree: &TreeWithMetadata,
|
||||||
|
right_id: RbxId,
|
||||||
|
) -> Result<(), TreeMismatch> {
|
||||||
|
basic_equal(left_tree, left_id, right_tree, right_id)?;
|
||||||
|
properties_equal(left_tree, left_id, right_tree, right_id)?;
|
||||||
|
children_equal(left_tree, left_id, right_tree, right_id)?;
|
||||||
|
metadata_equal(left_tree, left_id, right_tree, right_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn basic_equal(
|
||||||
|
left_tree: &TreeWithMetadata,
|
||||||
|
left_id: RbxId,
|
||||||
|
right_tree: &TreeWithMetadata,
|
||||||
|
right_id: RbxId,
|
||||||
|
) -> Result<(), TreeMismatch> {
|
||||||
|
let left_instance = left_tree.tree.get_instance(left_id)
|
||||||
|
.expect("ID did not exist in left tree");
|
||||||
|
|
||||||
|
let right_instance = right_tree.tree.get_instance(right_id)
|
||||||
|
.expect("ID did not exist in right tree");
|
||||||
|
|
||||||
|
if left_instance.name != right_instance.name {
|
||||||
|
let message = format!("Name did not match ('{}' vs '{}')", left_instance.name, right_instance.name);
|
||||||
|
|
||||||
|
return Err(TreeMismatch::new(&left_instance.name, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
if left_instance.class_name != right_instance.class_name {
|
||||||
|
let message = format!("Class name did not match ('{}' vs '{}')", left_instance.class_name, right_instance.class_name);
|
||||||
|
|
||||||
|
return Err(TreeMismatch::new(&left_instance.name, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn properties_equal(
|
||||||
|
left_tree: &TreeWithMetadata,
|
||||||
|
left_id: RbxId,
|
||||||
|
right_tree: &TreeWithMetadata,
|
||||||
|
right_id: RbxId,
|
||||||
|
) -> Result<(), TreeMismatch> {
|
||||||
|
let left_instance = left_tree.tree.get_instance(left_id)
|
||||||
|
.expect("ID did not exist in left tree");
|
||||||
|
|
||||||
|
let right_instance = right_tree.tree.get_instance(right_id)
|
||||||
|
.expect("ID did not exist in right tree");
|
||||||
|
|
||||||
|
let mut visited = HashSet::new();
|
||||||
|
|
||||||
|
for (key, left_value) in &left_instance.properties {
|
||||||
|
visited.insert(key);
|
||||||
|
|
||||||
|
let right_value = right_instance.properties.get(key);
|
||||||
|
|
||||||
|
if Some(left_value) != right_value {
|
||||||
|
let message = format!(
|
||||||
|
"Property {}:\n\tLeft: {:?}\n\tRight: {:?}",
|
||||||
|
key,
|
||||||
|
Some(left_value),
|
||||||
|
right_value,
|
||||||
|
);
|
||||||
|
|
||||||
|
return Err(TreeMismatch::new(&left_instance.name, message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (key, right_value) in &right_instance.properties {
|
||||||
|
if visited.contains(key) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let left_value = left_instance.properties.get(key);
|
||||||
|
|
||||||
|
if left_value != Some(right_value) {
|
||||||
|
let message = format!(
|
||||||
|
"Property {}:\n\tLeft: {:?}\n\tRight: {:?}",
|
||||||
|
key,
|
||||||
|
left_value,
|
||||||
|
Some(right_value),
|
||||||
|
);
|
||||||
|
|
||||||
|
return Err(TreeMismatch::new(&left_instance.name, message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn children_equal(
|
||||||
|
left_tree: &TreeWithMetadata,
|
||||||
|
left_id: RbxId,
|
||||||
|
right_tree: &TreeWithMetadata,
|
||||||
|
right_id: RbxId,
|
||||||
|
) -> Result<(), TreeMismatch> {
|
||||||
|
let left_instance = left_tree.tree.get_instance(left_id)
|
||||||
|
.expect("ID did not exist in left tree");
|
||||||
|
|
||||||
|
let right_instance = right_tree.tree.get_instance(right_id)
|
||||||
|
.expect("ID did not exist in right tree");
|
||||||
|
|
||||||
|
let left_children = left_instance.get_children_ids();
|
||||||
|
let right_children = right_instance.get_children_ids();
|
||||||
|
|
||||||
|
if left_children.len() != right_children.len() {
|
||||||
|
return Err(TreeMismatch::new(&left_instance.name, "Instances had different numbers of children"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (left_child_id, right_child_id) in left_children.iter().zip(right_children) {
|
||||||
|
instances_equal(left_tree, *left_child_id, right_tree, *right_child_id)
|
||||||
|
.map_err(|e| e.add_parent(&left_instance.name))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn metadata_equal(
|
||||||
|
left_tree: &TreeWithMetadata,
|
||||||
|
left_id: RbxId,
|
||||||
|
right_tree: &TreeWithMetadata,
|
||||||
|
right_id: RbxId,
|
||||||
|
) -> Result<(), TreeMismatch> {
|
||||||
|
let left_meta = left_tree.metadata.get(&left_id);
|
||||||
|
let right_meta = right_tree.metadata.get(&right_id);
|
||||||
|
|
||||||
|
if left_meta != right_meta {
|
||||||
|
let left_instance = left_tree.tree.get_instance(left_id)
|
||||||
|
.expect("Left instance didn't exist in tree");
|
||||||
|
|
||||||
|
let message = format!(
|
||||||
|
"Metadata mismatch:\n\tLeft: {:?}\n\tRight: {:?}",
|
||||||
|
left_meta,
|
||||||
|
right_meta,
|
||||||
|
);
|
||||||
|
|
||||||
|
return Err(TreeMismatch::new(&left_instance.name, message));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
68
server/tests/tree_snapshots.rs
Normal file
68
server/tests/tree_snapshots.rs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
mod test_util;
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
fs,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
sync::Arc,
|
||||||
|
thread,
|
||||||
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
|
use tempfile::{tempdir, TempDir};
|
||||||
|
|
||||||
|
use librojo::{
|
||||||
|
live_session::LiveSession,
|
||||||
|
project::Project,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::test_util::{
|
||||||
|
copy_recursive,
|
||||||
|
tree::tree_step,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn multi_partition_game() {
|
||||||
|
let _ = env_logger::try_init();
|
||||||
|
let source_path = project_path("multi_partition_game");
|
||||||
|
|
||||||
|
let (dir, live_session) = start_session(&source_path);
|
||||||
|
tree_step("initial", &live_session, &source_path);
|
||||||
|
|
||||||
|
let added_path = dir.path().join("a/added");
|
||||||
|
fs::create_dir_all(&added_path)
|
||||||
|
.expect("Couldn't create directory");
|
||||||
|
thread::sleep(Duration::from_millis(250));
|
||||||
|
|
||||||
|
tree_step("with_dir", &live_session, &source_path);
|
||||||
|
|
||||||
|
let moved_path = dir.path().join("b/added");
|
||||||
|
fs::rename(&added_path, &moved_path)
|
||||||
|
.expect("Couldn't rename directory");
|
||||||
|
thread::sleep(Duration::from_millis(250));
|
||||||
|
|
||||||
|
tree_step("with_moved_dir", &live_session, &source_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Find the path to the given test project relative to the manifest.
|
||||||
|
fn project_path(name: &str) -> PathBuf {
|
||||||
|
let mut path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../test-projects");
|
||||||
|
path.push(name);
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Starts a new LiveSession for the project located at the given file path.
|
||||||
|
fn start_session(source_path: &Path) -> (TempDir, LiveSession) {
|
||||||
|
let dir = tempdir()
|
||||||
|
.expect("Couldn't create temporary directory");
|
||||||
|
|
||||||
|
copy_recursive(&source_path, dir.path())
|
||||||
|
.expect("Couldn't copy project to temporary directory");
|
||||||
|
|
||||||
|
let project = Arc::new(Project::load_fuzzy(dir.path())
|
||||||
|
.expect("Couldn't load project from temp directory"));
|
||||||
|
|
||||||
|
let live_session = LiveSession::new(Arc::clone(&project))
|
||||||
|
.expect("Couldn't start live session");
|
||||||
|
|
||||||
|
(dir, live_session)
|
||||||
|
}
|
||||||
6
test-projects/malformed-stuff/default.project.json
Normal file
6
test-projects/malformed-stuff/default.project.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "malformed-stuff",
|
||||||
|
"tree": {
|
||||||
|
"$path": "src"
|
||||||
|
}
|
||||||
|
}
|
||||||
2
test-projects/malformed-stuff/src/bad-model.model.json
Normal file
2
test-projects/malformed-stuff/src/bad-model.model.json
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
ahhh this isn't a JSON model
|
||||||
|
bamboozled again
|
||||||
1
test-projects/multi_partition_game/a/foo.txt
Normal file
1
test-projects/multi_partition_game/a/foo.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Hello world, from a/foo.txt
|
||||||
1
test-projects/multi_partition_game/a/main.lua
Normal file
1
test-projects/multi_partition_game/a/main.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-- hello, from a/main.lua
|
||||||
1
test-projects/multi_partition_game/b/something.lua
Normal file
1
test-projects/multi_partition_game/b/something.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-- b/something.lua
|
||||||
21
test-projects/multi_partition_game/default.project.json
Normal file
21
test-projects/multi_partition_game/default.project.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "multi_partition_game",
|
||||||
|
"tree": {
|
||||||
|
"$className": "DataModel",
|
||||||
|
"ReplicatedStorage": {
|
||||||
|
"$className": "ReplicatedStorage",
|
||||||
|
"Ack": {
|
||||||
|
"$path": "a"
|
||||||
|
},
|
||||||
|
"Bar": {
|
||||||
|
"$path": "b"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"HttpService": {
|
||||||
|
"$className": "HttpService",
|
||||||
|
"$properties": {
|
||||||
|
"HttpEnabled": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
212
test-projects/multi_partition_game/expected-snapshot.json
Normal file
212
test-projects/multi_partition_game/expected-snapshot.json
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
{
|
||||||
|
"name": "multi_partition_game",
|
||||||
|
"class_name": "DataModel",
|
||||||
|
"properties": {},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "HttpService",
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"children": [],
|
||||||
|
"metadata": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"HttpService",
|
||||||
|
{
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"children": {},
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ReplicatedStorage",
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"properties": {},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "Ack",
|
||||||
|
"class_name": "Folder",
|
||||||
|
"properties": {},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "foo",
|
||||||
|
"class_name": "StringValue",
|
||||||
|
"properties": {
|
||||||
|
"Value": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "Hello world, from a/foo.txt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"children": [],
|
||||||
|
"metadata": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/foo.txt",
|
||||||
|
"project_definition": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "main",
|
||||||
|
"class_name": "ModuleScript",
|
||||||
|
"properties": {
|
||||||
|
"Source": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "-- hello, from a/main.lua"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"children": [],
|
||||||
|
"metadata": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/main.lua",
|
||||||
|
"project_definition": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a",
|
||||||
|
"project_definition": [
|
||||||
|
"Ack",
|
||||||
|
{
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Bar",
|
||||||
|
"class_name": "Folder",
|
||||||
|
"properties": {},
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "something",
|
||||||
|
"class_name": "ModuleScript",
|
||||||
|
"properties": {
|
||||||
|
"Source": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "-- b/something.lua"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"children": [],
|
||||||
|
"metadata": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b/something.lua",
|
||||||
|
"project_definition": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b",
|
||||||
|
"project_definition": [
|
||||||
|
"Bar",
|
||||||
|
{
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"ReplicatedStorage",
|
||||||
|
{
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"children": {
|
||||||
|
"Bar": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
},
|
||||||
|
"Ack": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"multi_partition_game",
|
||||||
|
{
|
||||||
|
"class_name": "DataModel",
|
||||||
|
"children": {
|
||||||
|
"ReplicatedStorage": {
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"children": {
|
||||||
|
"Bar": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
},
|
||||||
|
"Ack": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
},
|
||||||
|
"HttpService": {
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"children": {},
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
242
test-projects/multi_partition_game/initial.tree.json
Normal file
242
test-projects/multi_partition_game/initial.tree.json
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
{
|
||||||
|
"instances": {
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd": {
|
||||||
|
"Name": "main",
|
||||||
|
"ClassName": "ModuleScript",
|
||||||
|
"Properties": {
|
||||||
|
"Source": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "-- hello, from a/main.lua"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "00f207b1-fc18-4088-a45e-caf8cd98f5dd",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "14fed1a3-ba97-46a6-ae93-ac26bd9471df"
|
||||||
|
},
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df": {
|
||||||
|
"Name": "Ack",
|
||||||
|
"ClassName": "Folder",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "14fed1a3-ba97-46a6-ae93-ac26bd9471df",
|
||||||
|
"Children": [
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9",
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd"
|
||||||
|
],
|
||||||
|
"Parent": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
},
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c": {
|
||||||
|
"Name": "Bar",
|
||||||
|
"ClassName": "Folder",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "c910510c-37a8-4fd8-ae41-01169ccb739c",
|
||||||
|
"Children": [
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4"
|
||||||
|
],
|
||||||
|
"Parent": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
},
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9": {
|
||||||
|
"Name": "foo",
|
||||||
|
"ClassName": "StringValue",
|
||||||
|
"Properties": {
|
||||||
|
"Value": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "Hello world, from a/foo.txt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "c55fd55c-258e-4a93-a63a-ea243038c9b9",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "14fed1a3-ba97-46a6-ae93-ac26bd9471df"
|
||||||
|
},
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4": {
|
||||||
|
"Name": "something",
|
||||||
|
"ClassName": "ModuleScript",
|
||||||
|
"Properties": {
|
||||||
|
"Source": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "-- b/something.lua"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "71a95983-c856-4cf2-aee6-bd8a523e80e4",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "c910510c-37a8-4fd8-ae41-01169ccb739c"
|
||||||
|
},
|
||||||
|
"3b5af13f-c997-4009-915c-0810b0e83032": {
|
||||||
|
"Name": "multi_partition_game",
|
||||||
|
"ClassName": "DataModel",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "3b5af13f-c997-4009-915c-0810b0e83032",
|
||||||
|
"Children": [
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c",
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
],
|
||||||
|
"Parent": null
|
||||||
|
},
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c": {
|
||||||
|
"Name": "HttpService",
|
||||||
|
"ClassName": "HttpService",
|
||||||
|
"Properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "bf8e2d4f-33a0-42a0-8168-1b62d6ac050c",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "3b5af13f-c997-4009-915c-0810b0e83032"
|
||||||
|
},
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b": {
|
||||||
|
"Name": "ReplicatedStorage",
|
||||||
|
"ClassName": "ReplicatedStorage",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b",
|
||||||
|
"Children": [
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df",
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c"
|
||||||
|
],
|
||||||
|
"Parent": "3b5af13f-c997-4009-915c-0810b0e83032"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root_id": "3b5af13f-c997-4009-915c-0810b0e83032",
|
||||||
|
"metadata": {
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/main.lua",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"HttpService",
|
||||||
|
{
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"children": {},
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a",
|
||||||
|
"project_definition": [
|
||||||
|
"Ack",
|
||||||
|
{
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/foo.txt",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b/something.lua",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b",
|
||||||
|
"project_definition": [
|
||||||
|
"Bar",
|
||||||
|
{
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"ReplicatedStorage",
|
||||||
|
{
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"children": {
|
||||||
|
"Ack": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
},
|
||||||
|
"Bar": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"3b5af13f-c997-4009-915c-0810b0e83032": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"multi_partition_game",
|
||||||
|
{
|
||||||
|
"class_name": "DataModel",
|
||||||
|
"children": {
|
||||||
|
"HttpService": {
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"children": {},
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
},
|
||||||
|
"ReplicatedStorage": {
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"children": {
|
||||||
|
"Ack": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
},
|
||||||
|
"Bar": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
256
test-projects/multi_partition_game/with_dir.tree.json
Normal file
256
test-projects/multi_partition_game/with_dir.tree.json
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
{
|
||||||
|
"instances": {
|
||||||
|
"b48b369f-5706-4029-9fa6-90651a4910ea": {
|
||||||
|
"Name": "added",
|
||||||
|
"ClassName": "Folder",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "b48b369f-5706-4029-9fa6-90651a4910ea",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "14fed1a3-ba97-46a6-ae93-ac26bd9471df"
|
||||||
|
},
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd": {
|
||||||
|
"Name": "main",
|
||||||
|
"ClassName": "ModuleScript",
|
||||||
|
"Properties": {
|
||||||
|
"Source": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "-- hello, from a/main.lua"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "00f207b1-fc18-4088-a45e-caf8cd98f5dd",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "14fed1a3-ba97-46a6-ae93-ac26bd9471df"
|
||||||
|
},
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df": {
|
||||||
|
"Name": "Ack",
|
||||||
|
"ClassName": "Folder",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "14fed1a3-ba97-46a6-ae93-ac26bd9471df",
|
||||||
|
"Children": [
|
||||||
|
"b48b369f-5706-4029-9fa6-90651a4910ea",
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9",
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd"
|
||||||
|
],
|
||||||
|
"Parent": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
},
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c": {
|
||||||
|
"Name": "Bar",
|
||||||
|
"ClassName": "Folder",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "c910510c-37a8-4fd8-ae41-01169ccb739c",
|
||||||
|
"Children": [
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4"
|
||||||
|
],
|
||||||
|
"Parent": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
},
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9": {
|
||||||
|
"Name": "foo",
|
||||||
|
"ClassName": "StringValue",
|
||||||
|
"Properties": {
|
||||||
|
"Value": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "Hello world, from a/foo.txt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "c55fd55c-258e-4a93-a63a-ea243038c9b9",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "14fed1a3-ba97-46a6-ae93-ac26bd9471df"
|
||||||
|
},
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4": {
|
||||||
|
"Name": "something",
|
||||||
|
"ClassName": "ModuleScript",
|
||||||
|
"Properties": {
|
||||||
|
"Source": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "-- b/something.lua"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "71a95983-c856-4cf2-aee6-bd8a523e80e4",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "c910510c-37a8-4fd8-ae41-01169ccb739c"
|
||||||
|
},
|
||||||
|
"3b5af13f-c997-4009-915c-0810b0e83032": {
|
||||||
|
"Name": "multi_partition_game",
|
||||||
|
"ClassName": "DataModel",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "3b5af13f-c997-4009-915c-0810b0e83032",
|
||||||
|
"Children": [
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c",
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
],
|
||||||
|
"Parent": null
|
||||||
|
},
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c": {
|
||||||
|
"Name": "HttpService",
|
||||||
|
"ClassName": "HttpService",
|
||||||
|
"Properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "bf8e2d4f-33a0-42a0-8168-1b62d6ac050c",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "3b5af13f-c997-4009-915c-0810b0e83032"
|
||||||
|
},
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b": {
|
||||||
|
"Name": "ReplicatedStorage",
|
||||||
|
"ClassName": "ReplicatedStorage",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b",
|
||||||
|
"Children": [
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df",
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c"
|
||||||
|
],
|
||||||
|
"Parent": "3b5af13f-c997-4009-915c-0810b0e83032"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root_id": "3b5af13f-c997-4009-915c-0810b0e83032",
|
||||||
|
"metadata": {
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/foo.txt",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"ReplicatedStorage",
|
||||||
|
{
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"children": {
|
||||||
|
"Ack": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
},
|
||||||
|
"Bar": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b/something.lua",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/main.lua",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"HttpService",
|
||||||
|
{
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"children": {},
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"b48b369f-5706-4029-9fa6-90651a4910ea": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/added",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"3b5af13f-c997-4009-915c-0810b0e83032": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"multi_partition_game",
|
||||||
|
{
|
||||||
|
"class_name": "DataModel",
|
||||||
|
"children": {
|
||||||
|
"HttpService": {
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"children": {},
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
},
|
||||||
|
"ReplicatedStorage": {
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"children": {
|
||||||
|
"Ack": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
},
|
||||||
|
"Bar": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b",
|
||||||
|
"project_definition": [
|
||||||
|
"Bar",
|
||||||
|
{
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a",
|
||||||
|
"project_definition": [
|
||||||
|
"Ack",
|
||||||
|
{
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
256
test-projects/multi_partition_game/with_moved_dir.tree.json
Normal file
256
test-projects/multi_partition_game/with_moved_dir.tree.json
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
{
|
||||||
|
"instances": {
|
||||||
|
"866071d6-465a-4b88-8c63-07489d950916": {
|
||||||
|
"Name": "added",
|
||||||
|
"ClassName": "Folder",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "866071d6-465a-4b88-8c63-07489d950916",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "c910510c-37a8-4fd8-ae41-01169ccb739c"
|
||||||
|
},
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd": {
|
||||||
|
"Name": "main",
|
||||||
|
"ClassName": "ModuleScript",
|
||||||
|
"Properties": {
|
||||||
|
"Source": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "-- hello, from a/main.lua"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "00f207b1-fc18-4088-a45e-caf8cd98f5dd",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "14fed1a3-ba97-46a6-ae93-ac26bd9471df"
|
||||||
|
},
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df": {
|
||||||
|
"Name": "Ack",
|
||||||
|
"ClassName": "Folder",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "14fed1a3-ba97-46a6-ae93-ac26bd9471df",
|
||||||
|
"Children": [
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9",
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd"
|
||||||
|
],
|
||||||
|
"Parent": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
},
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c": {
|
||||||
|
"Name": "Bar",
|
||||||
|
"ClassName": "Folder",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "c910510c-37a8-4fd8-ae41-01169ccb739c",
|
||||||
|
"Children": [
|
||||||
|
"866071d6-465a-4b88-8c63-07489d950916",
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4"
|
||||||
|
],
|
||||||
|
"Parent": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
},
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9": {
|
||||||
|
"Name": "foo",
|
||||||
|
"ClassName": "StringValue",
|
||||||
|
"Properties": {
|
||||||
|
"Value": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "Hello world, from a/foo.txt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "c55fd55c-258e-4a93-a63a-ea243038c9b9",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "14fed1a3-ba97-46a6-ae93-ac26bd9471df"
|
||||||
|
},
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4": {
|
||||||
|
"Name": "something",
|
||||||
|
"ClassName": "ModuleScript",
|
||||||
|
"Properties": {
|
||||||
|
"Source": {
|
||||||
|
"Type": "String",
|
||||||
|
"Value": "-- b/something.lua"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "71a95983-c856-4cf2-aee6-bd8a523e80e4",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "c910510c-37a8-4fd8-ae41-01169ccb739c"
|
||||||
|
},
|
||||||
|
"3b5af13f-c997-4009-915c-0810b0e83032": {
|
||||||
|
"Name": "multi_partition_game",
|
||||||
|
"ClassName": "DataModel",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "3b5af13f-c997-4009-915c-0810b0e83032",
|
||||||
|
"Children": [
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c",
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b"
|
||||||
|
],
|
||||||
|
"Parent": null
|
||||||
|
},
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c": {
|
||||||
|
"Name": "HttpService",
|
||||||
|
"ClassName": "HttpService",
|
||||||
|
"Properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Id": "bf8e2d4f-33a0-42a0-8168-1b62d6ac050c",
|
||||||
|
"Children": [],
|
||||||
|
"Parent": "3b5af13f-c997-4009-915c-0810b0e83032"
|
||||||
|
},
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b": {
|
||||||
|
"Name": "ReplicatedStorage",
|
||||||
|
"ClassName": "ReplicatedStorage",
|
||||||
|
"Properties": {},
|
||||||
|
"Id": "99eefe5f-ef74-49e6-8a8b-c833e00ca56b",
|
||||||
|
"Children": [
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df",
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c"
|
||||||
|
],
|
||||||
|
"Parent": "3b5af13f-c997-4009-915c-0810b0e83032"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root_id": "3b5af13f-c997-4009-915c-0810b0e83032",
|
||||||
|
"metadata": {
|
||||||
|
"bf8e2d4f-33a0-42a0-8168-1b62d6ac050c": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"HttpService",
|
||||||
|
{
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"children": {},
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"c910510c-37a8-4fd8-ae41-01169ccb739c": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b",
|
||||||
|
"project_definition": [
|
||||||
|
"Bar",
|
||||||
|
{
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"866071d6-465a-4b88-8c63-07489d950916": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b/added",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"14fed1a3-ba97-46a6-ae93-ac26bd9471df": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a",
|
||||||
|
"project_definition": [
|
||||||
|
"Ack",
|
||||||
|
{
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"00f207b1-fc18-4088-a45e-caf8cd98f5dd": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/main.lua",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"99eefe5f-ef74-49e6-8a8b-c833e00ca56b": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"ReplicatedStorage",
|
||||||
|
{
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"children": {
|
||||||
|
"Ack": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
},
|
||||||
|
"Bar": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"71a95983-c856-4cf2-aee6-bd8a523e80e4": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "b/something.lua",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"c55fd55c-258e-4a93-a63a-ea243038c9b9": {
|
||||||
|
"ignore_unknown_instances": false,
|
||||||
|
"source_path": "a/foo.txt",
|
||||||
|
"project_definition": null
|
||||||
|
},
|
||||||
|
"3b5af13f-c997-4009-915c-0810b0e83032": {
|
||||||
|
"ignore_unknown_instances": true,
|
||||||
|
"source_path": null,
|
||||||
|
"project_definition": [
|
||||||
|
"multi_partition_game",
|
||||||
|
{
|
||||||
|
"class_name": "DataModel",
|
||||||
|
"children": {
|
||||||
|
"HttpService": {
|
||||||
|
"class_name": "HttpService",
|
||||||
|
"children": {},
|
||||||
|
"properties": {
|
||||||
|
"HttpEnabled": {
|
||||||
|
"Type": "Bool",
|
||||||
|
"Value": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
},
|
||||||
|
"ReplicatedStorage": {
|
||||||
|
"class_name": "ReplicatedStorage",
|
||||||
|
"children": {
|
||||||
|
"Ack": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "a"
|
||||||
|
},
|
||||||
|
"Bar": {
|
||||||
|
"class_name": null,
|
||||||
|
"children": {},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": "b"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {},
|
||||||
|
"ignore_unknown_instances": null,
|
||||||
|
"path": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,10 +11,7 @@
|
|||||||
"HttpService": {
|
"HttpService": {
|
||||||
"$className": "HttpService",
|
"$className": "HttpService",
|
||||||
"$properties": {
|
"$properties": {
|
||||||
"HttpEnabled": {
|
"HttpEnabled": true
|
||||||
"Type": "Bool",
|
|
||||||
"Value": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user