mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a86001b85c | ||
|
|
d6dd46c467 | ||
|
|
320974074c | ||
|
|
7b824abe52 | ||
|
|
bfd33f4b8d | ||
|
|
d5a21a0513 | ||
|
|
c894b38f06 | ||
|
|
a86347ea32 | ||
|
|
b60bfc7495 | ||
|
|
4b2f27b26d | ||
|
|
f4d7dda8e3 | ||
|
|
0d6e3e66ce | ||
|
|
7e4d451765 | ||
|
|
804bbc93b7 | ||
|
|
e7fe4ac3ec | ||
|
|
40c41b4400 | ||
|
|
0936c7c97d | ||
|
|
9ac537d38f | ||
|
|
fcfd55ff76 | ||
|
|
c2495ed57f | ||
|
|
6ad763fc01 | ||
|
|
c856a3e361 | ||
|
|
aa5f0cc335 | ||
|
|
b067335bbf | ||
|
|
7d24a14004 |
31
CHANGES.md
31
CHANGES.md
@@ -1,7 +1,20 @@
|
|||||||
# Rojo Change Log
|
# Rojo Change Log
|
||||||
|
|
||||||
## Current master
|
## Current master
|
||||||
* *No changes*
|
* Added support for `init.model.json` files, which enable versioning `Tool` instances (among other things) with Rojo. ([#66](https://github.com/LPGhatguy/rojo/issues/66))
|
||||||
|
* Fixed obscure error when syncing into an invalid service.
|
||||||
|
* Fixed multiple sync processes occurring when a server ID mismatch is detected.
|
||||||
|
|
||||||
|
## 0.4.9 (May 26, 2018)
|
||||||
|
* Fixed warning when renaming or removing files that would sometimes corrupt the instance cache ([#72](https://github.com/LPGhatguy/rojo/pull/72))
|
||||||
|
* JSON models are no longer as strict -- `Children` and `Properties` are now optional.
|
||||||
|
|
||||||
|
## 0.4.8 (May 26, 2018)
|
||||||
|
* Hotfix to prevent errors from being thrown when objects managed by Rojo are deleted
|
||||||
|
|
||||||
|
## 0.4.7 (May 25, 2018)
|
||||||
|
* Added icons to the Rojo plugin, made by [@Vorlias](https://github.com/Vorlias)! ([#70](https://github.com/LPGhatguy/rojo/pull/70))
|
||||||
|
* Server will now issue a warning if no partitions are specified in `rojo serve` ([#40](https://github.com/LPGhatguy/rojo/issues/40))
|
||||||
|
|
||||||
## 0.4.6 (May 21, 2018)
|
## 0.4.6 (May 21, 2018)
|
||||||
* Rojo handles being restarted by Roblox Studio more gracefully ([#67](https://github.com/LPGhatguy/rojo/issues/67))
|
* Rojo handles being restarted by Roblox Studio more gracefully ([#67](https://github.com/LPGhatguy/rojo/issues/67))
|
||||||
@@ -25,11 +38,11 @@
|
|||||||
## 0.4.3 (April 7, 2018)
|
## 0.4.3 (April 7, 2018)
|
||||||
* Plugin now automatically selects `HttpService` if it determines that HTTP isn't enabled ([#58](https://github.com/LPGhatguy/rojo/pull/58))
|
* Plugin now automatically selects `HttpService` if it determines that HTTP isn't enabled ([#58](https://github.com/LPGhatguy/rojo/pull/58))
|
||||||
* Plugin now has much more robust handling and will wipe all state when the server changes.
|
* Plugin now has much more robust handling and will wipe all state when the server changes.
|
||||||
* This should fix issues that would otherwise be solved by restarting Roblox Studio.
|
* This should fix issues that would otherwise be solved by restarting Roblox Studio.
|
||||||
|
|
||||||
## 0.4.2 (April 4, 2018)
|
## 0.4.2 (April 4, 2018)
|
||||||
* Fixed final case of duplicated instance insertion, caused by reconciled instances not being inserted into `RouteMap`.
|
* Fixed final case of duplicated instance insertion, caused by reconciled instances not being inserted into `RouteMap`.
|
||||||
* The reconciler is still not a perfect solution, especially if script instances get moved around without being destroyed. I don't think this can be fixed before a big refactor.
|
* The reconciler is still not a perfect solution, especially if script instances get moved around without being destroyed. I don't think this can be fixed before a big refactor.
|
||||||
|
|
||||||
## 0.4.1 (April 1, 2018)
|
## 0.4.1 (April 1, 2018)
|
||||||
* Merged plugin repository into main Rojo repository for easier tracking.
|
* Merged plugin repository into main Rojo repository for easier tracking.
|
||||||
@@ -37,9 +50,9 @@
|
|||||||
|
|
||||||
## 0.4.0 (March 27, 2018)
|
## 0.4.0 (March 27, 2018)
|
||||||
* Protocol version 1, which shifts more responsibility onto the server
|
* Protocol version 1, which shifts more responsibility onto the server
|
||||||
* This is a **major breaking** change!
|
* This is a **major breaking** change!
|
||||||
* The server now has a content of 'filter plugins', which transform data at various stages in the pipeline
|
* The server now has a content of 'filter plugins', which transform data at various stages in the pipeline
|
||||||
* The server now exposes Roblox instance objects instead of file contents, which lines up with how `rojo pack` will work, and paves the way for more robust syncing.
|
* The server now exposes Roblox instance objects instead of file contents, which lines up with how `rojo pack` will work, and paves the way for more robust syncing.
|
||||||
* Added `*.model.json` files, which let you embed small Roblox objects into your Rojo tree.
|
* Added `*.model.json` files, which let you embed small Roblox objects into your Rojo tree.
|
||||||
* Improved error messages in some cases ([#46](https://github.com/LPGhatguy/rojo/issues/46))
|
* Improved error messages in some cases ([#46](https://github.com/LPGhatguy/rojo/issues/46))
|
||||||
|
|
||||||
@@ -49,18 +62,18 @@
|
|||||||
|
|
||||||
## 0.3.1 (December 14, 2017)
|
## 0.3.1 (December 14, 2017)
|
||||||
* Improved error reporting when invalid JSON is found in a `rojo.json` project
|
* Improved error reporting when invalid JSON is found in a `rojo.json` project
|
||||||
* These messages are passed on from Serde
|
* These messages are passed on from Serde
|
||||||
|
|
||||||
## 0.3.0 (December 12, 2017)
|
## 0.3.0 (December 12, 2017)
|
||||||
* Factored out the plugin into a separate repository
|
* Factored out the plugin into a separate repository
|
||||||
* Fixed server when using a file as a partition
|
* Fixed server when using a file as a partition
|
||||||
* Previously, trailing slashes were put on the end of a partition even if the read request was an empty string. This broke file reading on Windows when a partition pointed to a file instead of a directory!
|
* Previously, trailing slashes were put on the end of a partition even if the read request was an empty string. This broke file reading on Windows when a partition pointed to a file instead of a directory!
|
||||||
* Started running automatic tests on Travis CI (#9)
|
* Started running automatic tests on Travis CI (#9)
|
||||||
|
|
||||||
## 0.2.3 (December 4, 2017)
|
## 0.2.3 (December 4, 2017)
|
||||||
* Plugin only release
|
* Plugin only release
|
||||||
* Tightened `init` file rules to only match script files
|
* Tightened `init` file rules to only match script files
|
||||||
* Previously, Rojo would sometimes pick up the wrong file when syncing
|
* Previously, Rojo would sometimes pick up the wrong file when syncing
|
||||||
|
|
||||||
## 0.2.2 (December 1, 2017)
|
## 0.2.2 (December 1, 2017)
|
||||||
* Plugin only release
|
* Plugin only release
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<a href="https://travis-ci.org/LPGhatguy/rojo">
|
<a href="https://travis-ci.org/LPGhatguy/rojo">
|
||||||
<img src="https://api.travis-ci.org/LPGhatguy/rojo.svg?branch=master" alt="Travis-CI Build Status" />
|
<img src="https://api.travis-ci.org/LPGhatguy/rojo.svg?branch=master" alt="Travis-CI Build Status" />
|
||||||
</a>
|
</a>
|
||||||
<img src="https://img.shields.io/badge/latest_version-0.4.6-brightgreen.svg" alt="Current server version" />
|
<img src="https://img.shields.io/badge/latest_version-0.4.9-brightgreen.svg" alt="Current server version" />
|
||||||
<a href="https://lpghatguy.github.io/rojo">
|
<a href="https://lpghatguy.github.io/rojo">
|
||||||
<img src="https://img.shields.io/badge/documentation-website-brightgreen.svg" alt="Rojo Documentation" />
|
<img src="https://img.shields.io/badge/documentation-website-brightgreen.svg" alt="Rojo Documentation" />
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
BIN
assets/rojo-polling-icon.png
Normal file
BIN
assets/rojo-polling-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 375 B |
BIN
assets/rojo-sync-in.png
Normal file
BIN
assets/rojo-sync-in.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 382 B |
BIN
assets/rojo-test-icon.png
Normal file
BIN
assets/rojo-test-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 430 B |
@@ -26,13 +26,21 @@ Will turn into these instances in Roblox:
|
|||||||

|

|
||||||
|
|
||||||
## Models
|
## Models
|
||||||
Rojo supports a JSON model format for representing simple models. It's designed for instance types like `BindableEvent` or `*Value` objects, and is not suitable for larger models.
|
Rojo supports a JSON model format for representing simple models. It's designed for instance types like `BindableEvent` or `Value` objects, and is not suitable for larger models.
|
||||||
|
|
||||||
|
Rojo JSON models are stored in `.model.json` files.
|
||||||
|
|
||||||
|
Starting in Rojo version **0.4.10**, model files named `init.model.json` that are located in folders will replace that folder, much like Rojo's `init.lua` support. This can be useful to version instances like `Tool` that tend to contain several instances as well as one or more scripts.
|
||||||
|
|
||||||
!!! info
|
!!! info
|
||||||
In the future, Rojo will support `.rbxmx` models. See [issue #7](https://github.com/LPGhatguy/rojo/issues/7) for more details and updates on this feature.
|
In the future, Rojo will support `.rbxmx` models. See [issue #7](https://github.com/LPGhatguy/rojo/issues/7) for more details and updates on this feature.
|
||||||
|
|
||||||
JSON model files are strict, with every property being required. They look like this:
|
!!! warning
|
||||||
|
Prior to Rojo version **0.4.9**, the `Properties` and `Children` properties are required on all instances in JSON models!
|
||||||
|
|
||||||
|
JSON model files are fairly strict; any syntax errors will cause the model to fail to sync! They look like this:
|
||||||
|
|
||||||
|
`hello.model.json`
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"Name": "hello",
|
"Name": "hello",
|
||||||
@@ -40,14 +48,11 @@ JSON model files are strict, with every property being required. They look like
|
|||||||
"Children": [
|
"Children": [
|
||||||
{
|
{
|
||||||
"Name": "Some Part",
|
"Name": "Some Part",
|
||||||
"ClassName": "Part",
|
"ClassName": "Part"
|
||||||
"Children": [],
|
|
||||||
"Properties": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Some StringValue",
|
"Name": "Some StringValue",
|
||||||
"ClassName": "StringValue",
|
"ClassName": "StringValue",
|
||||||
"Children": [],
|
|
||||||
"Properties": {
|
"Properties": {
|
||||||
"Value": {
|
"Value": {
|
||||||
"Type": "String",
|
"Type": "String",
|
||||||
@@ -55,7 +60,6 @@ JSON model files are strict, with every property being required. They look like
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"Properties": {}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -39,10 +39,6 @@ stds.testez = {
|
|||||||
|
|
||||||
ignore = {
|
ignore = {
|
||||||
"212", -- unused arguments
|
"212", -- unused arguments
|
||||||
"421", -- shadowing local variable
|
|
||||||
"422", -- shadowing argument
|
|
||||||
"431", -- shadowing upvalue
|
|
||||||
"432", -- shadowing upvalue argument
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std = "lua51+roblox"
|
std = "lua51+roblox"
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ function Api.connect(http)
|
|||||||
setmetatable(context, Api)
|
setmetatable(context, Api)
|
||||||
|
|
||||||
return context:_start()
|
return context:_start()
|
||||||
|
:andThen(function()
|
||||||
|
return context
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Api:_start()
|
function Api:_start()
|
||||||
@@ -60,8 +63,6 @@ function Api:_start()
|
|||||||
|
|
||||||
self.serverId = response.serverId
|
self.serverId = response.serverId
|
||||||
self.currentTime = response.currentTime
|
self.currentTime = response.currentTime
|
||||||
|
|
||||||
return self
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
return {
|
return {
|
||||||
pollingRate = 0.2,
|
pollingRate = 0.2,
|
||||||
version = {0, 4, 6},
|
version = {0, 4, 9},
|
||||||
expectedServerVersionString = "0.4.x",
|
expectedServerVersionString = "0.4.x",
|
||||||
protocolVersion = 1,
|
protocolVersion = 1,
|
||||||
|
icons = {
|
||||||
|
syncIn = "rbxassetid://1820320573",
|
||||||
|
togglePolling = "rbxassetid://1820320064",
|
||||||
|
testConnection = "rbxassetid://1820320989",
|
||||||
|
},
|
||||||
dev = false,
|
dev = false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ local function main()
|
|||||||
|
|
||||||
local toolbar = plugin:CreateToolbar("Rojo Plugin " .. displayedVersion)
|
local toolbar = plugin:CreateToolbar("Rojo Plugin " .. displayedVersion)
|
||||||
|
|
||||||
toolbar:CreateButton("Test Connection", "Connect to Rojo Server", "")
|
toolbar:CreateButton("Test Connection", "Connect to Rojo Server", Config.icons.testConnection)
|
||||||
.Click:Connect(function()
|
.Click:Connect(function()
|
||||||
checkUpgrade()
|
checkUpgrade()
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ local function main()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
toolbar:CreateButton("Sync In", "Sync into Roblox Studio", "")
|
toolbar:CreateButton("Sync In", "Sync into Roblox Studio", Config.icons.syncIn)
|
||||||
.Click:Connect(function()
|
.Click:Connect(function()
|
||||||
checkUpgrade()
|
checkUpgrade()
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ local function main()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
toolbar:CreateButton("Toggle Polling", "Poll server for changes", "")
|
toolbar:CreateButton("Toggle Polling", "Poll server for changes", Config.icons.togglePolling)
|
||||||
.Click:Connect(function()
|
.Click:Connect(function()
|
||||||
checkUpgrade()
|
checkUpgrade()
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ local Api = require(script.Parent.Api)
|
|||||||
local Reconciler = require(script.Parent.Reconciler)
|
local Reconciler = require(script.Parent.Reconciler)
|
||||||
local Version = require(script.Parent.Version)
|
local Version = require(script.Parent.Version)
|
||||||
|
|
||||||
|
local MESSAGE_SERVER_CHANGED = "Rojo: The server has changed since the last request, reloading plugin..."
|
||||||
|
local MESSAGE_PLUGIN_CHANGED = "Rojo: Another instance of Rojo came online, unloading..."
|
||||||
|
|
||||||
local function collectMatch(source, pattern)
|
local function collectMatch(source, pattern)
|
||||||
local result = {}
|
local result = {}
|
||||||
|
|
||||||
@@ -80,6 +83,7 @@ function Plugin.new()
|
|||||||
-- object.
|
-- object.
|
||||||
screenGui.AncestryChanged:Connect(function(_, parent)
|
screenGui.AncestryChanged:Connect(function(_, parent)
|
||||||
if parent == nil then
|
if parent == nil then
|
||||||
|
warn(MESSAGE_PLUGIN_CHANGED)
|
||||||
self:restart()
|
self:restart()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -93,8 +97,6 @@ end
|
|||||||
restarted.
|
restarted.
|
||||||
]]
|
]]
|
||||||
function Plugin:restart()
|
function Plugin:restart()
|
||||||
warn("Rojo: The server has changed since the last request, reloading plugin...")
|
|
||||||
|
|
||||||
self:stopPolling()
|
self:stopPolling()
|
||||||
|
|
||||||
self._reconciler:destruct()
|
self._reconciler:destruct()
|
||||||
@@ -105,22 +107,25 @@ function Plugin:restart()
|
|||||||
self._syncInProgress = false
|
self._syncInProgress = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function Plugin:api()
|
function Plugin:getApi()
|
||||||
if not self._api then
|
if self._api == nil then
|
||||||
self._api = Api.connect(self._http)
|
return Api.connect(self._http)
|
||||||
:catch(function(err)
|
:andThen(function(api)
|
||||||
self._api = nil
|
self._api = api
|
||||||
|
|
||||||
|
return api
|
||||||
|
end, function(err)
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self._api
|
return Promise.resolve(self._api)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Plugin:connect()
|
function Plugin:connect()
|
||||||
print("Rojo: Testing connection...")
|
print("Rojo: Testing connection...")
|
||||||
|
|
||||||
return self:api()
|
return self:getApi()
|
||||||
:andThen(function(api)
|
:andThen(function(api)
|
||||||
local ok, info = api:getInfo():await()
|
local ok, info = api:getInfo():await()
|
||||||
|
|
||||||
@@ -134,6 +139,7 @@ function Plugin:connect()
|
|||||||
end)
|
end)
|
||||||
:catch(function(err)
|
:catch(function(err)
|
||||||
if err == Api.Error.ServerIdMismatch then
|
if err == Api.Error.ServerIdMismatch then
|
||||||
|
warn(MESSAGE_SERVER_CHANGED)
|
||||||
self:restart()
|
self:restart()
|
||||||
return self:connect()
|
return self:connect()
|
||||||
else
|
else
|
||||||
@@ -204,25 +210,25 @@ function Plugin:startPolling()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
print("Rojo: Polling server for changes...")
|
print("Rojo: Starting to poll server for changes...")
|
||||||
|
|
||||||
self._polling = true
|
self._polling = true
|
||||||
self._label.Enabled = true
|
self._label.Enabled = true
|
||||||
|
|
||||||
return self:api()
|
return self:getApi()
|
||||||
:andThen(function(api)
|
:andThen(function(api)
|
||||||
local syncOk, result = self:syncIn():await()
|
|
||||||
|
|
||||||
if not syncOk then
|
|
||||||
return Promise.reject(result)
|
|
||||||
end
|
|
||||||
|
|
||||||
local infoOk, info = api:getInfo():await()
|
local infoOk, info = api:getInfo():await()
|
||||||
|
|
||||||
if not infoOk then
|
if not infoOk then
|
||||||
return Promise.reject(info)
|
return Promise.reject(info)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local syncOk, result = self:syncIn():await()
|
||||||
|
|
||||||
|
if not syncOk then
|
||||||
|
return Promise.reject(result)
|
||||||
|
end
|
||||||
|
|
||||||
while self._polling do
|
while self._polling do
|
||||||
local changesOk, changes = api:getChanges():await()
|
local changesOk, changes = api:getChanges():await()
|
||||||
|
|
||||||
@@ -248,12 +254,12 @@ function Plugin:startPolling()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
:catch(function(err)
|
:catch(function(err)
|
||||||
self:stopPolling()
|
|
||||||
|
|
||||||
if err == Api.Error.ServerIdMismatch then
|
if err == Api.Error.ServerIdMismatch then
|
||||||
|
warn(MESSAGE_SERVER_CHANGED)
|
||||||
self:restart()
|
self:restart()
|
||||||
return self:startPolling()
|
return self:startPolling()
|
||||||
else
|
else
|
||||||
|
self:stopPolling()
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -269,7 +275,7 @@ function Plugin:syncIn()
|
|||||||
self._syncInProgress = true
|
self._syncInProgress = true
|
||||||
print("Rojo: Syncing from server...")
|
print("Rojo: Syncing from server...")
|
||||||
|
|
||||||
return self:api()
|
return self:getApi()
|
||||||
:andThen(function(api)
|
:andThen(function(api)
|
||||||
local ok, info = api:getInfo():await()
|
local ok, info = api:getInfo():await()
|
||||||
|
|
||||||
@@ -292,6 +298,7 @@ function Plugin:syncIn()
|
|||||||
self._syncInProgress = false
|
self._syncInProgress = false
|
||||||
|
|
||||||
if err == Api.Error.ServerIdMismatch then
|
if err == Api.Error.ServerIdMismatch then
|
||||||
|
warn(MESSAGE_SERVER_CHANGED)
|
||||||
self:restart()
|
self:restart()
|
||||||
return self:syncIn()
|
return self:syncIn()
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
local RouteMap = require(script.Parent.RouteMap)
|
local RouteMap = require(script.Parent.RouteMap)
|
||||||
|
|
||||||
local function classEqual(a, b)
|
local function classEqual(a, b)
|
||||||
|
assert(typeof(a) == "string")
|
||||||
|
assert(typeof(b) == "string")
|
||||||
|
|
||||||
if a == "*" or b == "*" then
|
if a == "*" or b == "*" then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -9,6 +12,9 @@ local function classEqual(a, b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function applyProperties(target, properties)
|
local function applyProperties(target, properties)
|
||||||
|
assert(typeof(target) == "Instance")
|
||||||
|
assert(typeof(properties) == "table")
|
||||||
|
|
||||||
for key, property in pairs(properties) do
|
for key, property in pairs(properties) do
|
||||||
-- TODO: Transform property value based on property.Type
|
-- TODO: Transform property value based on property.Type
|
||||||
-- Right now, we assume that 'value' is primitive!
|
-- Right now, we assume that 'value' is primitive!
|
||||||
@@ -22,18 +28,19 @@ end
|
|||||||
* Changing parent threw an error
|
* Changing parent threw an error
|
||||||
]]
|
]]
|
||||||
local function reparent(rbx, parent)
|
local function reparent(rbx, parent)
|
||||||
if rbx then
|
assert(typeof(rbx) == "Instance")
|
||||||
if rbx.Parent == parent then
|
assert(typeof(parent) == "Instance")
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- It's possible that 'rbx' is a service or some other object that we
|
if rbx.Parent == parent then
|
||||||
-- can't change the parent of. That's the only reason why Parent would
|
return
|
||||||
-- fail except for rbx being previously destroyed!
|
|
||||||
pcall(function()
|
|
||||||
rbx.Parent = parent
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Setting `Parent` can fail if:
|
||||||
|
-- * The object has been destroyed
|
||||||
|
-- * The object is a service and cannot be reparented
|
||||||
|
pcall(function()
|
||||||
|
rbx.Parent = parent
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@@ -94,22 +101,30 @@ function Reconciler:_reconcileChildren(rbx, item)
|
|||||||
while true do
|
while true do
|
||||||
local itemChild, rbxChild = findNextChildPair(item.Children, rbxChildren, visited)
|
local itemChild, rbxChild = findNextChildPair(item.Children, rbxChildren, visited)
|
||||||
|
|
||||||
if not itemChild then
|
if itemChild == nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
reparent(self:reconcile(rbxChild, itemChild), rbx)
|
local newRbxChild = self:reconcile(rbxChild, itemChild)
|
||||||
|
|
||||||
|
if newRbxChild ~= nil then
|
||||||
|
newRbxChild.Parent = rbx
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Reconcile any children that were deleted
|
-- Reconcile any children that were deleted
|
||||||
while true do
|
while true do
|
||||||
local rbxChild, itemChild = findNextChildPair(rbxChildren, item.Children, visited)
|
local rbxChild, itemChild = findNextChildPair(rbxChildren, item.Children, visited)
|
||||||
|
|
||||||
if not rbxChild then
|
if rbxChild == nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
reparent(self:reconcile(rbxChild, itemChild), rbx)
|
local newRbxChild = self:reconcile(rbxChild, itemChild)
|
||||||
|
|
||||||
|
if newRbxChild ~= nil then
|
||||||
|
newRbxChild.Parent = rbx
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -133,7 +148,7 @@ function Reconciler:_reify(item)
|
|||||||
reparent(self:_reify(child), rbx)
|
reparent(self:_reify(child), rbx)
|
||||||
end
|
end
|
||||||
|
|
||||||
if item.Route then
|
if item.Route ~= nil then
|
||||||
self._routeMap:insert(item.Route, rbx)
|
self._routeMap:insert(item.Route, rbx)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -153,8 +168,8 @@ end
|
|||||||
]]
|
]]
|
||||||
function Reconciler:reconcile(rbx, item)
|
function Reconciler:reconcile(rbx, item)
|
||||||
-- Item was deleted
|
-- Item was deleted
|
||||||
if not item then
|
if item == nil then
|
||||||
if rbx then
|
if rbx ~= nil then
|
||||||
self._routeMap:removeByRbx(rbx)
|
self._routeMap:removeByRbx(rbx)
|
||||||
rbx:Destroy()
|
rbx:Destroy()
|
||||||
end
|
end
|
||||||
@@ -163,7 +178,7 @@ function Reconciler:reconcile(rbx, item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Item was created!
|
-- Item was created!
|
||||||
if not rbx then
|
if rbx == nil then
|
||||||
return self:_reify(item)
|
return self:_reify(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -191,13 +206,18 @@ function Reconciler:reconcileRoute(route, item, itemRoute)
|
|||||||
local child = rbx:FindFirstChild(piece)
|
local child = rbx:FindFirstChild(piece)
|
||||||
|
|
||||||
-- We should get services instead of making folders here.
|
-- We should get services instead of making folders here.
|
||||||
if rbx == game and not child then
|
if rbx == game and child == nil then
|
||||||
local _
|
local success
|
||||||
_, child = pcall(game.GetService, game, piece)
|
success, child = pcall(game.GetService, game, piece)
|
||||||
|
|
||||||
|
-- That isn't a valid service!
|
||||||
|
if not success then
|
||||||
|
child = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- We don't want to create a folder if we're reaching our target item!
|
-- We don't want to create a folder if we're reaching our target item!
|
||||||
if not child and i ~= #route then
|
if child == nil and i ~= #route then
|
||||||
child = Instance.new("Folder")
|
child = Instance.new("Folder")
|
||||||
child.Parent = rbx
|
child.Parent = rbx
|
||||||
child.Name = piece
|
child.Name = piece
|
||||||
@@ -208,7 +228,7 @@ function Reconciler:reconcileRoute(route, item, itemRoute)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Let's check the route map!
|
-- Let's check the route map!
|
||||||
if not rbx then
|
if rbx == nil then
|
||||||
rbx = self._routeMap:get(itemRoute)
|
rbx = self._routeMap:get(itemRoute)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ function RouteMap:removeByRoute(route)
|
|||||||
local rbx = self._map[hashedRoute]
|
local rbx = self._map[hashedRoute]
|
||||||
|
|
||||||
if rbx ~= nil then
|
if rbx ~= nil then
|
||||||
self:_removeInternal(hashedRoute, rbx)
|
self:_removeInternal(rbx, hashedRoute)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ function RouteMap:removeByRbx(rbx)
|
|||||||
local hashedRoute = self._reverseMap[rbx]
|
local hashedRoute = self._reverseMap[rbx]
|
||||||
|
|
||||||
if hashedRoute ~= nil then
|
if hashedRoute ~= nil then
|
||||||
self:_removeInternal(hashedRoute, rbx)
|
self:_removeInternal(rbx, hashedRoute)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ function RouteMap:_removeInternal(rbx, hashedRoute)
|
|||||||
self._connectionsByRbx[rbx]:Disconnect()
|
self._connectionsByRbx[rbx]:Disconnect()
|
||||||
self._connectionsByRbx[rbx] = nil
|
self._connectionsByRbx[rbx] = nil
|
||||||
|
|
||||||
self:removeRbxDescendants(rbx)
|
self:_removeRbxDescendants(rbx)
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|||||||
2
server/Cargo.lock
generated
2
server/Cargo.lock
generated
@@ -636,7 +636,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rojo"
|
name = "rojo"
|
||||||
version = "0.4.6"
|
version = "0.4.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rojo"
|
name = "rojo"
|
||||||
version = "0.4.6"
|
version = "0.4.10"
|
||||||
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"
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if project.partitions.len() == 0 {
|
||||||
|
println!("");
|
||||||
|
println!("This project has no partitions and will not do anything when served!");
|
||||||
|
println!("This is usually a mistake -- edit rojo.json!");
|
||||||
|
println!("");
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref PLUGIN_CHAIN: PluginChain = PluginChain::new(vec![
|
static ref PLUGIN_CHAIN: PluginChain = PluginChain::new(vec![
|
||||||
Box::new(ScriptPlugin::new()),
|
Box::new(ScriptPlugin::new()),
|
||||||
|
|||||||
@@ -9,13 +9,6 @@ pub enum TransformFileResult {
|
|||||||
// TODO: Error case
|
// TODO: Error case
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum RbxChangeResult {
|
|
||||||
Write(Option<VfsItem>),
|
|
||||||
Pass,
|
|
||||||
|
|
||||||
// TODO: Error case
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum FileChangeResult {
|
pub enum FileChangeResult {
|
||||||
MarkChanged(Option<Vec<Route>>),
|
MarkChanged(Option<Vec<Route>>),
|
||||||
Pass,
|
Pass,
|
||||||
@@ -26,10 +19,6 @@ pub trait Plugin {
|
|||||||
/// into a Roblox instance.
|
/// into a Roblox instance.
|
||||||
fn transform_file(&self, plugins: &PluginChain, vfs_item: &VfsItem) -> TransformFileResult;
|
fn transform_file(&self, plugins: &PluginChain, vfs_item: &VfsItem) -> TransformFileResult;
|
||||||
|
|
||||||
/// Invoked when a Roblox Instance change is reported by the Roblox Studio
|
|
||||||
/// plugin and needs to be turned into a file to save.
|
|
||||||
fn handle_rbx_change(&self, route: &Route, rbx_item: &RbxInstance) -> RbxChangeResult;
|
|
||||||
|
|
||||||
/// Invoked when a file changes on the filesystem. The result defines what
|
/// Invoked when a file changes on the filesystem. The result defines what
|
||||||
/// routes are marked as needing to be refreshed.
|
/// routes are marked as needing to be refreshed.
|
||||||
fn handle_file_change(&self, route: &Route) -> FileChangeResult;
|
fn handle_file_change(&self, route: &Route) -> FileChangeResult;
|
||||||
@@ -58,17 +47,6 @@ impl PluginChain {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_rbx_change(&self, route: &Route, rbx_item: &RbxInstance) -> Option<VfsItem> {
|
|
||||||
for plugin in &self.plugins {
|
|
||||||
match plugin.handle_rbx_change(route, rbx_item) {
|
|
||||||
RbxChangeResult::Write(vfs_item) => return vfs_item,
|
|
||||||
RbxChangeResult::Pass => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn handle_file_change(&self, route: &Route) -> Option<Vec<Route>> {
|
pub fn handle_file_change(&self, route: &Route) -> Option<Vec<Route>> {
|
||||||
for plugin in &self.plugins {
|
for plugin in &self.plugins {
|
||||||
match plugin.handle_file_change(route) {
|
match plugin.handle_file_change(route) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use core::Route;
|
use core::Route;
|
||||||
use plugin::{Plugin, PluginChain, TransformFileResult, RbxChangeResult, FileChangeResult};
|
use plugin::{Plugin, PluginChain, TransformFileResult, FileChangeResult};
|
||||||
use rbx::{RbxInstance, RbxValue};
|
use rbx::{RbxInstance, RbxValue};
|
||||||
use vfs::VfsItem;
|
use vfs::VfsItem;
|
||||||
|
|
||||||
@@ -60,8 +60,4 @@ impl Plugin for DefaultPlugin {
|
|||||||
fn handle_file_change(&self, route: &Route) -> FileChangeResult {
|
fn handle_file_change(&self, route: &Route) -> FileChangeResult {
|
||||||
FileChangeResult::MarkChanged(Some(vec![route.clone()]))
|
FileChangeResult::MarkChanged(Some(vec![route.clone()]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_rbx_change(&self, _route: &Route, _rbx_item: &RbxInstance) -> RbxChangeResult {
|
|
||||||
RbxChangeResult::Pass
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use regex::Regex;
|
|||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
use core::Route;
|
use core::Route;
|
||||||
use plugin::{Plugin, PluginChain, TransformFileResult, RbxChangeResult, FileChangeResult};
|
use plugin::{Plugin, PluginChain, TransformFileResult, FileChangeResult};
|
||||||
use rbx::RbxInstance;
|
use rbx::RbxInstance;
|
||||||
use vfs::VfsItem;
|
use vfs::VfsItem;
|
||||||
|
|
||||||
@@ -10,6 +10,8 @@ lazy_static! {
|
|||||||
static ref JSON_MODEL_PATTERN: Regex = Regex::new(r"^(.*?)\.model\.json$").unwrap();
|
static ref JSON_MODEL_PATTERN: Regex = Regex::new(r"^(.*?)\.model\.json$").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static JSON_MODEL_INIT: &'static str = "init.model.json";
|
||||||
|
|
||||||
pub struct JsonModelPlugin;
|
pub struct JsonModelPlugin;
|
||||||
|
|
||||||
impl JsonModelPlugin {
|
impl JsonModelPlugin {
|
||||||
@@ -19,7 +21,7 @@ impl JsonModelPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Plugin for JsonModelPlugin {
|
impl Plugin for JsonModelPlugin {
|
||||||
fn transform_file(&self, _plugins: &PluginChain, vfs_item: &VfsItem) -> TransformFileResult {
|
fn transform_file(&self, plugins: &PluginChain, vfs_item: &VfsItem) -> TransformFileResult {
|
||||||
match vfs_item {
|
match vfs_item {
|
||||||
&VfsItem::File { ref contents, .. } => {
|
&VfsItem::File { ref contents, .. } => {
|
||||||
let rbx_name = match JSON_MODEL_PATTERN.captures(vfs_item.name()) {
|
let rbx_name = match JSON_MODEL_PATTERN.captures(vfs_item.name()) {
|
||||||
@@ -41,15 +43,56 @@ impl Plugin for JsonModelPlugin {
|
|||||||
|
|
||||||
TransformFileResult::Value(Some(rbx_item))
|
TransformFileResult::Value(Some(rbx_item))
|
||||||
},
|
},
|
||||||
&VfsItem::Dir { .. } => TransformFileResult::Pass,
|
&VfsItem::Dir { ref children, .. } => {
|
||||||
|
let init_item = match children.get(JSON_MODEL_INIT) {
|
||||||
|
Some(v) => v,
|
||||||
|
None => return TransformFileResult::Pass,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut rbx_item = match self.transform_file(plugins, init_item) {
|
||||||
|
TransformFileResult::Value(Some(item)) => item,
|
||||||
|
TransformFileResult::Value(None) | TransformFileResult::Pass => {
|
||||||
|
eprintln!("Inconsistency detected in JsonModelPlugin!");
|
||||||
|
return TransformFileResult::Pass;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
rbx_item.name.clear();
|
||||||
|
rbx_item.name.push_str(vfs_item.name());
|
||||||
|
|
||||||
|
for (child_name, child_item) in children {
|
||||||
|
if child_name == init_item.name() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
match plugins.transform_file(child_item) {
|
||||||
|
Some(child_rbx_item) => {
|
||||||
|
rbx_item.children.push(child_rbx_item);
|
||||||
|
},
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TransformFileResult::Value(Some(rbx_item))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_file_change(&self, _route: &Route) -> FileChangeResult {
|
fn handle_file_change(&self, route: &Route) -> FileChangeResult {
|
||||||
FileChangeResult::Pass
|
let leaf = match route.last() {
|
||||||
}
|
Some(v) => v,
|
||||||
|
None => return FileChangeResult::Pass,
|
||||||
|
};
|
||||||
|
|
||||||
fn handle_rbx_change(&self, _route: &Route, _rbx_item: &RbxInstance) -> RbxChangeResult {
|
let is_init = leaf == JSON_MODEL_INIT;
|
||||||
RbxChangeResult::Pass
|
|
||||||
|
if is_init {
|
||||||
|
let mut changed = route.clone();
|
||||||
|
changed.pop();
|
||||||
|
|
||||||
|
FileChangeResult::MarkChanged(Some(vec![changed]))
|
||||||
|
} else {
|
||||||
|
FileChangeResult::Pass
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
|||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use core::Route;
|
use core::Route;
|
||||||
use plugin::{Plugin, PluginChain, TransformFileResult, RbxChangeResult, FileChangeResult};
|
use plugin::{Plugin, PluginChain, TransformFileResult, FileChangeResult};
|
||||||
use rbx::{RbxInstance, RbxValue};
|
use rbx::{RbxInstance, RbxValue};
|
||||||
use vfs::VfsItem;
|
use vfs::VfsItem;
|
||||||
|
|
||||||
@@ -117,8 +117,4 @@ impl Plugin for ScriptPlugin {
|
|||||||
FileChangeResult::Pass
|
FileChangeResult::Pass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_rbx_change(&self, _route: &Route, _rbx_item: &RbxInstance) -> RbxChangeResult {
|
|
||||||
RbxChangeResult::Pass
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ use std::collections::HashMap;
|
|||||||
pub struct RbxInstance {
|
pub struct RbxInstance {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub class_name: String,
|
pub class_name: String,
|
||||||
|
|
||||||
|
#[serde(default = "Vec::new")]
|
||||||
pub children: Vec<RbxInstance>,
|
pub children: Vec<RbxInstance>,
|
||||||
|
|
||||||
|
#[serde(default = "HashMap::new")]
|
||||||
pub properties: HashMap<String, RbxValue>,
|
pub properties: HashMap<String, RbxValue>,
|
||||||
|
|
||||||
/// The route that this instance was generated from, if there was one.
|
/// The route that this instance was generated from, if there was one.
|
||||||
|
|||||||
1
test-project/src/SomeTool/SomeTool.client.lua
Normal file
1
test-project/src/SomeTool/SomeTool.client.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
print("Hello, world, from my tool!")
|
||||||
4
test-project/src/SomeTool/init.model.json
Normal file
4
test-project/src/SomeTool/init.model.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Name": "SomeTool",
|
||||||
|
"ClassName": "Tool"
|
||||||
|
}
|
||||||
@@ -4,14 +4,11 @@
|
|||||||
"Children": [
|
"Children": [
|
||||||
{
|
{
|
||||||
"Name": "Some Part",
|
"Name": "Some Part",
|
||||||
"ClassName": "Part",
|
"ClassName": "Part"
|
||||||
"Children": [],
|
|
||||||
"Properties": {}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Some StringValue",
|
"Name": "Some StringValue",
|
||||||
"ClassName": "StringValue",
|
"ClassName": "StringValue",
|
||||||
"Children": [],
|
|
||||||
"Properties": {
|
"Properties": {
|
||||||
"Value": {
|
"Value": {
|
||||||
"Type": "String",
|
"Type": "String",
|
||||||
@@ -19,6 +16,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"Properties": {}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user