Compare commits
321 Commits
v0.4.11
...
v0.5.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
4a597e0ba7 | ||
|
|
d5f3e25bea | ||
|
|
5e4c1a8359 | ||
|
|
d86e655ad2 | ||
|
|
80154bbf9f | ||
|
|
be853ba2a7 | ||
|
|
4d3036d030 | ||
|
|
ecb9b5e28f | ||
|
|
38e3c198f2 | ||
|
|
2f64501556 | ||
|
|
2c2554d73d | ||
|
|
69d1accf3f | ||
|
|
785bdb8ecb | ||
|
|
78a1947cec | ||
|
|
0ff59ecb4e | ||
|
|
b58fed16b4 | ||
|
|
6719be02c3 | ||
|
|
8757834e07 | ||
|
|
aa243d1b8a | ||
|
|
aeb18eb124 | ||
|
|
6c3e118ee3 | ||
|
|
3c0fe4d684 | ||
|
|
12fd9aa1ef | ||
|
|
821122a33d | ||
|
|
0d9406d991 | ||
|
|
350eec3bc7 | ||
|
|
e700b3105a | ||
|
|
dd2a730b4a | ||
|
|
c6766bbe77 | ||
|
|
e5d3204b6c | ||
|
|
4767cbd12b | ||
|
|
deb4118c5d | ||
|
|
4516df5aac | ||
|
|
663df7bdc2 | ||
|
|
e81f0a4a95 | ||
|
|
38cd13dc0c | ||
|
|
14fd470363 | ||
|
|
fc8d9dc1fe | ||
|
|
1659adb419 | ||
|
|
6490b77d4c | ||
|
|
23463b620e | ||
|
|
6bc331be75 | ||
|
|
87f6410877 | ||
|
|
b1ddfc3a49 | ||
|
|
d01e757d2f | ||
|
|
e593ce0420 | ||
|
|
578abfabb3 | ||
|
|
aa7b7e43ff | ||
|
|
af4d4e0246 | ||
|
|
fecb11cba4 | ||
|
|
614f886008 | ||
|
|
6fcb895d70 | ||
|
|
5a98ede45e | ||
|
|
779d462932 | ||
|
|
e301116e87 | ||
|
|
bd3a4a719d | ||
|
|
4cfdc72c00 | ||
|
|
3620a9d256 | ||
|
|
f254a51d59 | ||
|
|
99bbe58255 | ||
|
|
a400abff4c | ||
|
|
585806837e | ||
|
|
249aa999a3 | ||
|
|
aae1d8b34f | ||
|
|
9d3638fa46 | ||
|
|
5b2a830d2d | ||
|
|
b87943e39d | ||
|
|
c421fd0b25 | ||
|
|
a1395a382a | ||
|
|
a54364642a | ||
|
|
14ab85adbd | ||
|
|
c284b7de40 | ||
|
|
e23056ac2f | ||
|
|
8ce2e605a2 | ||
|
|
9408247708 | ||
|
|
3e1c467b65 | ||
|
|
811db2e668 | ||
|
|
f833642733 | ||
|
|
30ce927621 | ||
|
|
f21f01be1a | ||
|
|
d81eaa6c13 | ||
|
|
5ad830a6d7 | ||
|
|
14e1829164 | ||
|
|
0a2810a98b | ||
|
|
7b84fce737 | ||
|
|
1e1b409f8b | ||
|
|
5f91a8fdfe | ||
|
|
5bb70c2675 | ||
|
|
ed6d8415bd | ||
|
|
d53ffd8da2 | ||
|
|
d52ecaa050 | ||
|
|
9ac001bd3e | ||
|
|
4b81166782 | ||
|
|
95866d0f2e | ||
|
|
54b8a1aea5 | ||
|
|
0822aa9240 | ||
|
|
c883850142 | ||
|
|
54da826447 | ||
|
|
ce5ea92076 | ||
|
|
98f8c5c0f2 | ||
|
|
6ced8f32b1 | ||
|
|
f870107c66 | ||
|
|
4e7aa5d0a9 | ||
|
|
779bcaeccb | ||
|
|
f2849357f8 | ||
|
|
998fca721a | ||
|
|
a83c68f2fc | ||
|
|
665809e11a | ||
|
|
a306fa26e0 | ||
|
|
9574f8ebd7 | ||
|
|
b62d946f83 | ||
|
|
b26b36da5d | ||
|
|
8d640ab467 | ||
|
|
eff4301027 | ||
|
|
0be4e6921d | ||
|
|
049875e8fc | ||
|
|
b9f7d3d889 | ||
|
|
70ba101fe1 | ||
|
|
b2753cb268 | ||
|
|
11f398b553 | ||
|
|
24a4099d82 | ||
|
|
99ea374fc5 | ||
|
|
1992ce1cfb | ||
|
|
2724534156 | ||
|
|
c57989a790 | ||
|
|
1888c83b6e | ||
|
|
837fd22254 | ||
|
|
02a3da111a | ||
|
|
5c2bf65eaa | ||
|
|
b5ae6a5785 | ||
|
|
699e07a0f7 | ||
|
|
b8025452bf | ||
|
|
1138c05dff | ||
|
|
ae36688bf2 | ||
|
|
64e2ef3d3b | ||
|
|
9cfeee0577 | ||
|
|
86e0f3fabe | ||
|
|
edcb3d8638 | ||
|
|
1582d8f504 | ||
|
|
5816bb64dc | ||
|
|
b7a28aa511 | ||
|
|
37ed80055b | ||
|
|
e6c2f1c15d | ||
|
|
a74c11aef5 | ||
|
|
ad3999066d | ||
|
|
77c10d14c9 | ||
|
|
8c2e430a56 | ||
|
|
0aaefe9a66 | ||
|
|
14db86e4b7 | ||
|
|
9949a6c9ee | ||
|
|
9bf5bd11e2 | ||
|
|
a3cc39cd92 | ||
|
|
45af35cccd | ||
|
|
20e9688268 | ||
|
|
3be5988083 | ||
|
|
474d877290 | ||
|
|
b6a2b7dded | ||
|
|
2e42c28485 | ||
|
|
4453211c0d | ||
|
|
01dd603bd5 | ||
|
|
fff71e1de0 | ||
|
|
c0ffbd360e | ||
|
|
2f1aadd497 | ||
|
|
645ab0ae98 | ||
|
|
9ac7ebc335 | ||
|
|
d807d22350 | ||
|
|
05594ecca0 | ||
|
|
a511a5b259 | ||
|
|
9125f96302 | ||
|
|
1b9ab43b6d | ||
|
|
1176c9bbf1 | ||
|
|
65e551c5cf | ||
|
|
8fadafcd24 | ||
|
|
57442a4848 | ||
|
|
7154f2c328 | ||
|
|
e3e4809446 | ||
|
|
5707b8c7e8 | ||
|
|
f125814847 | ||
|
|
893587040d | ||
|
|
308369b14f | ||
|
|
9516a1aeea | ||
|
|
f43dc99f7a | ||
|
|
3feb8c3344 | ||
|
|
4d0a2b806c | ||
|
|
a89fff1a22 | ||
|
|
52f01da400 | ||
|
|
b732c43274 | ||
|
|
ee0a5cada3 | ||
|
|
dbd499701f | ||
|
|
fc3f750efb | ||
|
|
457f3c8f54 | ||
|
|
e4d3c3b045 | ||
|
|
e4379e29af | ||
|
|
4542febaaf | ||
|
|
f691d8a6a5 | ||
|
|
503d7400f3 | ||
|
|
061ea0e7a3 | ||
|
|
dd4d542d7e | ||
|
|
75359e2b83 | ||
|
|
db7f8ffb1b | ||
|
|
f59a9040fc | ||
|
|
5114d12daf | ||
|
|
13a7c1ba81 | ||
|
|
26a7bb9746 | ||
|
|
d427f01224 | ||
|
|
25c73ed917 | ||
|
|
ce6a9dc448 | ||
|
|
c50922e90c | ||
|
|
bcd5fab33c | ||
|
|
49a2bc8ace | ||
|
|
f1c5268670 | ||
|
|
29fe7492cc | ||
|
|
2340a07408 | ||
|
|
797c39347f | ||
|
|
5a9d3959e2 | ||
|
|
1e0a7dea73 | ||
|
|
c61d6a5804 | ||
|
|
8aee5c769f | ||
|
|
7c585fcbce | ||
|
|
f7689f3154 | ||
|
|
6617b8b6c4 | ||
|
|
9db31c9191 | ||
|
|
767a59a481 | ||
|
|
f632444a0e | ||
|
|
16c3c1f498 | ||
|
|
c8bb9bf2e9 | ||
|
|
729ab25581 | ||
|
|
38e0f82812 | ||
|
|
b4fd2e31b3 | ||
|
|
e09d23d6c2 | ||
|
|
9ad0eabb85 | ||
|
|
fb950cb007 | ||
|
|
60c5c2d344 | ||
|
|
a29c4f2b65 | ||
|
|
5a99281e23 | ||
|
|
31e1f61548 | ||
|
|
dbad0a16c4 | ||
|
|
a69cbf45df | ||
|
|
284f423220 | ||
|
|
81a18e88ad | ||
|
|
72bc77f1d5 | ||
|
|
80b9b7594b | ||
|
|
7e671ee76a | ||
|
|
5d608cb498 | ||
|
|
c6982f70b4 | ||
|
|
ef0d1e7cec | ||
|
|
1db06194c7 | ||
|
|
f3e7e54675 | ||
|
|
2bd64db8d9 | ||
|
|
ae8098b80a | ||
|
|
bfe8dcd224 | ||
|
|
8a26994084 | ||
|
|
77d0865d58 | ||
|
|
bece337d79 | ||
|
|
5a5da3240f | ||
|
|
4138bb7ee1 | ||
|
|
4088bb47f0 | ||
|
|
d10b6d324e | ||
|
|
43b27831eb | ||
|
|
20c9c89b27 | ||
|
|
e1c420d37d | ||
|
|
be58598a3e | ||
|
|
5e08093609 | ||
|
|
f5599b95b3 | ||
|
|
ba930ea584 | ||
|
|
ba3fa24f9a | ||
|
|
ff0f5cd49c | ||
|
|
284f5cfb71 | ||
|
|
871796f172 | ||
|
|
9733f059c2 | ||
|
|
db71bdfde7 | ||
|
|
9aa27f4c11 | ||
|
|
8893d0ddde | ||
|
|
0b46860cdd | ||
|
|
ec1f9bd706 | ||
|
|
e30545c132 | ||
|
|
7d7f671920 |
2
.cargo/config
Normal file
@@ -0,0 +1,2 @@
|
||||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-Ctarget-feature=+crt-static"]
|
||||
@@ -3,13 +3,16 @@ root = true
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
|
||||
[*.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
[*.{json,js,css}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.{md,rs}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.lua]
|
||||
indent_style = tab
|
||||
4
.gitignore
vendored
@@ -1 +1,5 @@
|
||||
/site
|
||||
/target
|
||||
/scratch-project
|
||||
**/*.rs.bk
|
||||
/server/failed-snapshots/
|
||||
9
.gitmodules
vendored
@@ -1,12 +1,6 @@
|
||||
[submodule "plugin/modules/roact"]
|
||||
path = plugin/modules/roact
|
||||
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"]
|
||||
path = plugin/modules/testez
|
||||
url = https://github.com/Roblox/testez.git
|
||||
@@ -16,3 +10,6 @@
|
||||
[submodule "plugin/modules/promise"]
|
||||
path = plugin/modules/promise
|
||||
url = https://github.com/LPGhatguy/roblox-lua-promise.git
|
||||
[submodule "plugin/modules/t"]
|
||||
path = plugin/modules/t
|
||||
url = https://github.com/osyrisrblx/t.git
|
||||
59
.travis.yml
@@ -1,39 +1,54 @@
|
||||
matrix:
|
||||
include:
|
||||
- language: python
|
||||
env:
|
||||
- LUA="lua=5.1"
|
||||
# Lua tests are currently disabled because of holes in Lemur that are pretty
|
||||
# tedious to fix. It should be fixed by either adding missing features to
|
||||
# Lemur or by migrating to a CI system based on real Roblox instead.
|
||||
|
||||
before_install:
|
||||
- pip install hererocks
|
||||
- hererocks lua_install -r^ --$LUA
|
||||
- export PATH=$PATH:$PWD/lua_install/bin
|
||||
# - language: python
|
||||
# env:
|
||||
# - LUA="lua=5.1"
|
||||
|
||||
install:
|
||||
- luarocks install luafilesystem
|
||||
- luarocks install busted
|
||||
- luarocks install luacov
|
||||
- luarocks install luacov-coveralls
|
||||
- luarocks install luacheck
|
||||
# before_install:
|
||||
# - pip install hererocks
|
||||
# - hererocks lua_install -r^ --$LUA
|
||||
# - export PATH=$PATH:$PWD/lua_install/bin
|
||||
|
||||
# install:
|
||||
# - luarocks install luafilesystem
|
||||
# - luarocks install busted
|
||||
# - luarocks install luacov
|
||||
# - luarocks install luacov-coveralls
|
||||
# - luarocks install luacheck
|
||||
|
||||
# script:
|
||||
# - cd plugin
|
||||
# - luacheck src
|
||||
# - lua -lluacov spec.lua
|
||||
|
||||
# after_success:
|
||||
# - cd plugin
|
||||
# - luacov-coveralls -e $TRAVIS_BUILD_DIR/lua_install
|
||||
|
||||
- language: rust
|
||||
rust: 1.32.0
|
||||
cache: cargo
|
||||
|
||||
script:
|
||||
- cd plugin
|
||||
- luacheck src
|
||||
- lua -lluacov spec.lua
|
||||
|
||||
after_success:
|
||||
- cd plugin
|
||||
- luacov-coveralls -e $TRAVIS_BUILD_DIR/lua_install
|
||||
- cargo test --verbose
|
||||
- cargo test --verbose --all-features
|
||||
|
||||
- language: rust
|
||||
rust: stable
|
||||
cache: cargo
|
||||
|
||||
script:
|
||||
- cd server
|
||||
- cargo test --verbose
|
||||
- cargo test --verbose --all-features
|
||||
|
||||
- language: rust
|
||||
rust: beta
|
||||
cache: cargo
|
||||
|
||||
script:
|
||||
- cd server
|
||||
- cargo test --verbose
|
||||
- cargo test --verbose --all-features
|
||||
182
CHANGELOG.md
Normal file
@@ -0,0 +1,182 @@
|
||||
# Rojo Changelog
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [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)
|
||||
* 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 aliasing filesystem paths ([#105](https://github.com/LPGhatguy/rojo/issues/105))
|
||||
* Changed Windows builds to statically link the CRT ([#89](https://github.com/LPGhatguy/rojo/issues/89))
|
||||
|
||||
## [0.5.0 Alpha 3](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.3) (February 1, 2019)
|
||||
* Changed default project file name from `roblox-project.json` to `default.project.json` ([#120](https://github.com/LPGhatguy/rojo/pull/120))
|
||||
* The old file name will still be supported until 0.5.0 is fully released.
|
||||
* Added warning when loading project files that don't end in `.project.json`
|
||||
* This new extension enables Rojo to distinguish project files from random JSON files, which is necessary to support nested projects.
|
||||
* Added new (empty) diagnostic page served from the server
|
||||
* Added better error messages for when a file is missing that's referenced by a Rojo project
|
||||
* Added support for visualization endpoints returning GraphViz source when Dot is not available
|
||||
* Fixed an in-memory filesystem regression introduced recently ([#119](https://github.com/LPGhatguy/rojo/pull/119))
|
||||
|
||||
## [0.5.0 Alpha 2](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.2) (January 28, 2019)
|
||||
* Added support for `.model.json` files, compatible with 0.4.x
|
||||
* Fixed in-memory filesystem not handling out-of-order filesystem change events
|
||||
* Fixed long-polling error caused by a promise mixup ([#110](https://github.com/LPGhatguy/rojo/issues/110))
|
||||
|
||||
## [0.5.0 Alpha 1](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.1) (January 25, 2019)
|
||||
* Changed plugin UI to be way prettier
|
||||
* Thanks to [Reselim](https://github.com/Reselim) for the design!
|
||||
* Changed plugin error messages to be a little more useful
|
||||
* Removed unused 'Config' button in plugin UI
|
||||
* Fixed bug where bad server responses could cause the plugin to be in a bad state
|
||||
* Upgraded to rbx\_tree, rbx\_xml, and rbx\_binary 0.2.0, which dramatically expands the kinds of properties that Rojo can handle, especially in XML.
|
||||
|
||||
## [0.5.0 Alpha 0](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.0) (January 14, 2019)
|
||||
* "Epiphany" rewrite, in progress since the beginning of time
|
||||
* New live sync protocol
|
||||
* Uses HTTP long polling to reduce request count and improve responsiveness
|
||||
* New project format
|
||||
* Hierarchical, preventing overlapping partitions
|
||||
* Added `rojo build` command
|
||||
* Generates `rbxm`, `rbxmx`, `rbxl`, or `rbxlx` files out of your project
|
||||
* Usage: `rojo build <PROJECT> --output <OUTPUT>.rbxm`
|
||||
* Added `rojo upload` command
|
||||
* Generates and uploads a place or model to roblox.com out of your project
|
||||
* Usage: `rojo upload <PROJECT> --cookie "<ROBLOSECURITY>" --asset_id <PLACE_ID>`
|
||||
* New plugin
|
||||
* Only one button now, "Connect"
|
||||
* New UI to pick server address and port
|
||||
* Better error reporting
|
||||
* Added support for `.csv` files turning into `LocalizationTable` instances
|
||||
* Added support for `.txt` files turning into `StringValue` instances
|
||||
* Added debug visualization code to diagnose problems
|
||||
* `/visualize/rbx` and `/visualize/imfs` show instance and file state respectively; they require GraphViz to be installed on your machine.
|
||||
* Added optional place ID restrictions to project files
|
||||
* This helps prevent syncing in content to the wrong place
|
||||
* Multiple places can be specified, like when building a multi-place game
|
||||
* Added support for specifying properties on services in project files
|
||||
|
||||
## [0.4.13](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.13) (November 12, 2018)
|
||||
* When `rojo.json` points to a file or directory that does not exist, Rojo now issues a warning instead of throwing an error and exiting
|
||||
|
||||
## [0.4.12](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.12) (June 21, 2018)
|
||||
* Fixed obscure assertion failure when renaming or deleting files ([#78](https://github.com/LPGhatguy/rojo/issues/78))
|
||||
* Added a `PluginAction` for the sync in command, which should help with some automation scripts ([#80](https://github.com/LPGhatguy/rojo/pull/80))
|
||||
|
||||
## [0.4.11](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.11) (June 10, 2018)
|
||||
* Defensively insert existing instances into RouteMap; should fix most duplication cases when syncing into existing trees.
|
||||
* Fixed incorrect synchronization from `Plugin:_pull` that would cause polling to create issues
|
||||
* Fixed incorrect file routes being assigned to `init.lua` and `init.model.json` files
|
||||
* Untangled route handling-internals slightly
|
||||
|
||||
## [0.4.10](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.10) (June 2, 2018)
|
||||
* 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](https://github.com/LPGhatguy/rojo/releases/tag/v0.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](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.8) (May 26, 2018)
|
||||
* Hotfix to prevent errors from being thrown when objects managed by Rojo are deleted
|
||||
|
||||
## [0.4.7](https://github.com/LPGhatguy/rojo/releases/tag/v0.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](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.6) (May 21, 2018)
|
||||
* Rojo handles being restarted by Roblox Studio more gracefully ([#67](https://github.com/LPGhatguy/rojo/issues/67))
|
||||
* Folders should no longer get collapsed when syncing occurs.
|
||||
* **Significant** robustness improvements with regards to caching.
|
||||
* **This should catch all existing script duplication bugs.**
|
||||
* If there are any bugs with script duplication or caching in the future, restarting the Rojo server process will fix them for that session.
|
||||
* Fixed message in plugin not being prefixed with `Rojo: `.
|
||||
|
||||
## [0.4.5](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.5) (May 1, 2018)
|
||||
* Rojo messages are now prefixed with `Rojo: ` to make them stand out in the output more.
|
||||
* Fixed server to notice file changes *much* more quickly. (200ms vs 1000ms)
|
||||
* Server now lists name of project when starting up.
|
||||
* Rojo now throws an error if no project file is found. ([#63](https://github.com/LPGhatguy/rojo/issues/63))
|
||||
* Fixed multiple sync operations occuring at the same time. ([#61](https://github.com/LPGhatguy/rojo/issues/61))
|
||||
* Partitions targeting files directly now work as expected. ([#57](https://github.com/LPGhatguy/rojo/issues/57))
|
||||
|
||||
## [0.4.4](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.4) (April 7, 2018)
|
||||
* Fix small regression introduced in 0.4.3
|
||||
|
||||
## [0.4.3](https://github.com/LPGhatguy/rojo/releases/tag/v0.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 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.
|
||||
|
||||
## [0.4.2](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.2) (April 4, 2018)
|
||||
* 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.
|
||||
|
||||
## [0.4.1](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.1) (April 1, 2018)
|
||||
* Merged plugin repository into main Rojo repository for easier tracking.
|
||||
* Improved `RouteMap` object tracking; this should fix some cases of duplicated instances being synced into the tree.
|
||||
|
||||
## [0.4.0](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.0) (March 27, 2018)
|
||||
* Protocol version 1, which shifts more responsibility onto the server
|
||||
* 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 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.
|
||||
* Improved error messages in some cases ([#46](https://github.com/LPGhatguy/rojo/issues/46))
|
||||
|
||||
## [0.3.2](https://github.com/LPGhatguy/rojo/releases/tag/v0.3.2) (December 20, 2017)
|
||||
* Fixed `rojo serve` failing to correctly construct an absolute root path when passed as an argument
|
||||
* Fixed intense CPU usage when running `rojo serve`
|
||||
|
||||
## [0.3.1](https://github.com/LPGhatguy/rojo/releases/tag/v0.3.1) (December 14, 2017)
|
||||
* Improved error reporting when invalid JSON is found in a `rojo.json` project
|
||||
* These messages are passed on from Serde
|
||||
|
||||
## [0.3.0](https://github.com/LPGhatguy/rojo/releases/tag/v0.3.0) (December 12, 2017)
|
||||
* Factored out the plugin into a separate repository
|
||||
* 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!
|
||||
* Started running automatic tests on Travis CI (#9)
|
||||
|
||||
## [0.2.3](https://github.com/LPGhatguy/rojo/releases/tag/v0.2.3) (December 4, 2017)
|
||||
* Plugin only release
|
||||
* Tightened `init` file rules to only match script files
|
||||
* Previously, Rojo would sometimes pick up the wrong file when syncing
|
||||
|
||||
## [0.2.2](https://github.com/LPGhatguy/rojo/releases/tag/v0.2.2) (December 1, 2017)
|
||||
* Plugin only release
|
||||
* Fixed broken reconciliation behavior with `init` files
|
||||
|
||||
## [0.2.1](https://github.com/LPGhatguy/rojo/releases/tag/v0.2.1) (December 1, 2017)
|
||||
* Plugin only release
|
||||
* Changes default port to 8000
|
||||
|
||||
## [0.2.0](https://github.com/LPGhatguy/rojo/releases/tag/v0.2.0) (December 1, 2017)
|
||||
* Support for `init.lua` like rbxfs and rbxpacker
|
||||
* More robust syncing with a new reconciler
|
||||
|
||||
## [0.1.0](https://github.com/LPGhatguy/rojo/releases/tag/v0.1.0) (November 29, 2017)
|
||||
* Initial release, functionally very similar to [rbxfs](https://github.com/LPGhatguy/rbxfs)
|
||||
100
CHANGES.md
@@ -1,100 +0,0 @@
|
||||
# Rojo Change Log
|
||||
|
||||
## Current master
|
||||
* *No changes*
|
||||
|
||||
## 0.4.11 (June 10, 2018)
|
||||
* Defensively insert existing instances into RouteMap; should fix most duplication cases when syncing into existing trees.
|
||||
* Fixed incorrect synchronization from `Plugin:_pull` that would cause polling to create issues
|
||||
* Fixed incorrect file routes being assigned to `init.lua` and `init.model.json` files
|
||||
* Untangled route handling-internals slightly
|
||||
|
||||
## 0.4.10 (June 2, 2018)
|
||||
* 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)
|
||||
* Rojo handles being restarted by Roblox Studio more gracefully ([#67](https://github.com/LPGhatguy/rojo/issues/67))
|
||||
* Folders should no longer get collapsed when syncing occurs.
|
||||
* **Significant** robustness improvements with regards to caching.
|
||||
* **This should catch all existing script duplication bugs.**
|
||||
* If there are any bugs with script duplication or caching in the future, restarting the Rojo server process will fix them for that session.
|
||||
* Fixed message in plugin not being prefixed with `Rojo: `.
|
||||
|
||||
## 0.4.5 (May 1, 2018)
|
||||
* Rojo messages are now prefixed with `Rojo: ` to make them stand out in the output more.
|
||||
* Fixed server to notice file changes *much* more quickly. (200ms vs 1000ms)
|
||||
* Server now lists name of project when starting up.
|
||||
* Rojo now throws an error if no project file is found. ([#63](https://github.com/LPGhatguy/rojo/issues/63))
|
||||
* Fixed multiple sync operations occuring at the same time. ([#61](https://github.com/LPGhatguy/rojo/issues/61))
|
||||
* Partitions targeting files directly now work as expected. ([#57](https://github.com/LPGhatguy/rojo/issues/57))
|
||||
|
||||
## 0.4.4 (April 7, 2018)
|
||||
* Fix small regression introduced in 0.4.3
|
||||
|
||||
## 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 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.
|
||||
|
||||
## 0.4.2 (April 4, 2018)
|
||||
* 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.
|
||||
|
||||
## 0.4.1 (April 1, 2018)
|
||||
* Merged plugin repository into main Rojo repository for easier tracking.
|
||||
* Improved `RouteMap` object tracking; this should fix some cases of duplicated instances being synced into the tree.
|
||||
|
||||
## 0.4.0 (March 27, 2018)
|
||||
* Protocol version 1, which shifts more responsibility onto the server
|
||||
* 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 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.
|
||||
* Improved error messages in some cases ([#46](https://github.com/LPGhatguy/rojo/issues/46))
|
||||
|
||||
## 0.3.2 (December 20, 2017)
|
||||
* Fixed `rojo serve` failing to correctly construct an absolute root path when passed as an argument
|
||||
* Fixed intense CPU usage when running `rojo serve`
|
||||
|
||||
## 0.3.1 (December 14, 2017)
|
||||
* Improved error reporting when invalid JSON is found in a `rojo.json` project
|
||||
* These messages are passed on from Serde
|
||||
|
||||
## 0.3.0 (December 12, 2017)
|
||||
* Factored out the plugin into a separate repository
|
||||
* 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!
|
||||
* Started running automatic tests on Travis CI (#9)
|
||||
|
||||
## 0.2.3 (December 4, 2017)
|
||||
* Plugin only release
|
||||
* Tightened `init` file rules to only match script files
|
||||
* Previously, Rojo would sometimes pick up the wrong file when syncing
|
||||
|
||||
## 0.2.2 (December 1, 2017)
|
||||
* Plugin only release
|
||||
* Fixed broken reconciliation behavior with `init` files
|
||||
|
||||
## 0.2.1 (December 1, 2017)
|
||||
* Plugin only release
|
||||
* Changes default port to 8000
|
||||
|
||||
## 0.2.0 (December 1, 2017)
|
||||
* Support for `init.lua` like rbxfs and rbxpacker
|
||||
* More robust syncing with a new reconciler
|
||||
|
||||
## 0.1.0 (November 29, 2017)
|
||||
* Initial release, functionally very similar to [rbxfs](https://github.com/LPGhatguy/rbxfs)
|
||||
1954
Cargo.lock
generated
Normal file
5
Cargo.toml
Normal file
@@ -0,0 +1,5 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"server",
|
||||
"rojo-e2e",
|
||||
]
|
||||
49
DESIGN.md
@@ -1,49 +0,0 @@
|
||||
# Rojo Design - Protocol Version 1
|
||||
This is a super rough draft that I'm trying to use to lay out some of my thoughts.
|
||||
|
||||
## API
|
||||
|
||||
### POST `/read`
|
||||
Accepts a `Vec<Route>` of items to read.
|
||||
|
||||
Returns `Vec<Option<RbxInstance>>`, in the same order as the request.
|
||||
|
||||
### POST `/write`
|
||||
Accepts a `Vec<{ Route, RbxInstance }>` of items to write.
|
||||
|
||||
I imagine that the `Name` attribute of the top-level `RbxInstance` would be ignored in favor of the route name?
|
||||
|
||||
## CLI
|
||||
The `rojo serve` command uses three major components:
|
||||
* A Virtual Filesystem (VFS), which exposes the filesystem as `VfsItem` objects
|
||||
* A VFS watcher, which tracks changes to the filesystem and logs them
|
||||
* An HTTP API, which exposes an interface to the Roblox Studio plugin
|
||||
|
||||
### Transform Plugins
|
||||
Transform plugins (or filter plugins?) can interject in three places:
|
||||
* Transform a `VfsItem` that's being read into an `RbxInstance` in the VFS
|
||||
* Transform an `RbxInstance` that's being written into a `VfsItem` in the VFS
|
||||
* Transform a file change into paths that need to be updated in the VFS watcher
|
||||
|
||||
The plan is to have several built-in plugins that can be rearranged/configured in project settings:
|
||||
|
||||
* Base plugin
|
||||
* Transforms all unhandled files to/from StringValue objects
|
||||
* Script plugin
|
||||
* Transforms `*.lua` files to their appropriate file types
|
||||
* JSON/rbxmx/rbxlx model plugin
|
||||
* External binary plugin
|
||||
* User passes a binary name (like `moonc`) that modifies file contents
|
||||
|
||||
## Roblox Studio Plugin
|
||||
With the protocol version 1 change, the Roblox Studio plugin got a lot simpler. Notably, the plugin doesn't need to be aware of anything about the filesystem's semantics, which is super handy.
|
||||
|
||||
## Bi-directional syncing
|
||||
Quenty laid out a good way to handle bi-directional syncing.
|
||||
|
||||
When receiving a change from the plugin:
|
||||
1. Hash the new contents of the file, store it in a map from routes to hashes
|
||||
2. Write the new file contents to the filesystem
|
||||
3. Later down the line, receive a change event from the filesystem watcher
|
||||
4. When receiving a change, if the item is in the hash map, read it and hash those contents
|
||||
5. If the hash matches the last noted hash, discard the change, else continue as normal
|
||||
52
README.md
@@ -8,9 +8,14 @@
|
||||
<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" />
|
||||
</a>
|
||||
<img src="https://img.shields.io/badge/latest_version-0.4.11-brightgreen.svg" alt="Current server version" />
|
||||
<a href="https://lpghatguy.github.io/rojo">
|
||||
<img src="https://img.shields.io/badge/documentation-website-brightgreen.svg" alt="Rojo Documentation" />
|
||||
<a href="https://crates.io/crates/rojo">
|
||||
<img src="https://img.shields.io/crates/v/rojo.svg?label=version" alt="Latest server version" />
|
||||
</a>
|
||||
<a href="https://lpghatguy.github.io/rojo/0.4.x">
|
||||
<img src="https://img.shields.io/badge/docs-0.4.x-brightgreen.svg" alt="Rojo Documentation" />
|
||||
</a>
|
||||
<a href="https://lpghatguy.github.io/rojo/0.5.x">
|
||||
<img src="https://img.shields.io/badge/docs-0.5.x-brightgreen.svg" alt="Rojo Documentation" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -18,43 +23,46 @@
|
||||
|
||||
**Rojo** is a flexible multi-tool designed for creating robust Roblox projects.
|
||||
|
||||
It's designed for power users who want to use the **best tools available** for building games, libraries, and plugins.
|
||||
It lets Roblox developers use industry-leading tools like Git and VS Code, and crucial utilities like Luacheck.
|
||||
|
||||
Rojo is designed for **power users** who want to use the **best tools available** for building games, libraries, and plugins.
|
||||
|
||||
## Features
|
||||
Rojo lets you:
|
||||
|
||||
* Work on scripts from the filesystem, in your favorite editor
|
||||
* Version your place, library, or plugin using Git or another VCS
|
||||
* Sync JSON-format models from the filesystem into your game
|
||||
* Version your place, model, or plugin using Git or another VCS
|
||||
* Sync `rbxmx` and `rbxm` models into your game in real time
|
||||
* Package and deploy your project to Roblox.com from the command line
|
||||
|
||||
Later this year, Rojo will be able to:
|
||||
Soon, Rojo will be able to:
|
||||
|
||||
* Sync `rbxmx` models between the filesystem and Roblox Studio
|
||||
* Package projects into `rbxmx` files from the command line
|
||||
* Sync instances from Roblox Studio to the filesystem
|
||||
* Compile MoonScript and other custom things for your project
|
||||
|
||||
## [Documentation Website](https://lpghatguy.github.io/rojo)
|
||||
You can also view the documentation by browsing the [docs folder of the repository](https://github.com/LPGhatguy/rojo/tree/master/docs), but because it uses a number of Markdown extensions, it may not be very readable.
|
||||
## [Documentation](https://lpghatguy.github.io/rojo)
|
||||
You can also view the documentation by browsing the [docs](https://github.com/LPGhatguy/rojo/tree/master/docs) folder of the repository, but because it uses a number of Markdown extensions, it may not be very readable.
|
||||
|
||||
## Inspiration
|
||||
## Inspiration and Alternatives
|
||||
There are lots of other tools that sync scripts into Roblox or provide other tools for working with Roblox places.
|
||||
|
||||
Here are a few, if you're looking for alternatives or supplements to Rojo:
|
||||
|
||||
* [Studio Bridge by Vocksel](https://github.com/vocksel/studio-bridge)
|
||||
* [RbxRefresh by Osyris](https://github.com/osyrisrblx/RbxRefresh)
|
||||
* [RbxSync by evaera](https://github.com/evaera/RbxSync)
|
||||
* [CodeSync](https://github.com/MemoryPenguin/CodeSync) and [rbx-exteditor](https://github.com/MemoryPenguin/rbx-exteditor) by [MemoryPenguin](https://github.com/MemoryPenguin)
|
||||
* [rbxmk by Anaminus](https://github.com/anaminus/rbxmk)
|
||||
* [Rofresh by Osyris](https://github.com/osyrisrblx/rofresh)
|
||||
* [RbxRefresh by Osyris](https://github.com/osyrisrblx/RbxRefresh)
|
||||
* [Studio Bridge by Vocksel](https://github.com/vocksel/studio-bridge)
|
||||
* [Elixir by Vocksel](https://github.com/vocksel/elixir)
|
||||
* [RbxSync by evaera](https://github.com/evaera/RbxSync)
|
||||
* [CodeSync by MemoryPenguin](https://github.com/MemoryPenguin/CodeSync)
|
||||
* [rbx-exteditor by MemoryPenguin](https://github.com/MemoryPenguin/rbx-exteditor)
|
||||
|
||||
I also have a couple tools that Rojo intends to replace:
|
||||
|
||||
* [rbxfs](https://github.com/LPGhatguy/rbxfs), which has been deprecated by Rojo
|
||||
* [rbxpacker](https://github.com/LPGhatguy/rbxpacker), which is still useful
|
||||
If you use a plugin that _isn't_ Rojo for syncing code, open an issue and let me know why! I'd like Rojo to be the end-all tool so that people stop reinventing solutions to this problem.
|
||||
|
||||
## Contributing
|
||||
Pull requests are welcome!
|
||||
|
||||
All pull requests are run against a test suite on Travis CI. That test suite should always pass!
|
||||
Rojo supports Rust 1.32 and newer. Any changes to the minimum required compiler version require a _minor_ version bump.
|
||||
|
||||
## License
|
||||
Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE](LICENSE) for details.
|
||||
Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details.
|
||||
BIN
assets/kenney-ui-gray-sheet.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
41
assets/kenney-ui-gray-sheet.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<TextureAtlas imagePath="sheet.png">
|
||||
<SubTexture name="grey_arrowDownGrey.png" x="78" y="498" width="15" height="10"/>
|
||||
<SubTexture name="grey_arrowDownWhite.png" x="123" y="496" width="15" height="10"/>
|
||||
<SubTexture name="grey_arrowUpGrey.png" x="108" y="498" width="15" height="10"/>
|
||||
<SubTexture name="grey_arrowUpWhite.png" x="93" y="498" width="15" height="10"/>
|
||||
<SubTexture name="grey_box.png" x="147" y="433" width="38" height="36"/>
|
||||
<SubTexture name="grey_boxCheckmark.png" x="147" y="469" width="38" height="36"/>
|
||||
<SubTexture name="grey_boxCross.png" x="185" y="433" width="38" height="36"/>
|
||||
<SubTexture name="grey_boxTick.png" x="190" y="198" width="36" height="36"/>
|
||||
<SubTexture name="grey_button00.png" x="0" y="143" width="190" height="45"/>
|
||||
<SubTexture name="grey_button01.png" x="0" y="188" width="190" height="49"/>
|
||||
<SubTexture name="grey_button02.png" x="0" y="98" width="190" height="45"/>
|
||||
<SubTexture name="grey_button03.png" x="0" y="331" width="190" height="49"/>
|
||||
<SubTexture name="grey_button04.png" x="0" y="286" width="190" height="45"/>
|
||||
<SubTexture name="grey_button05.png" x="0" y="0" width="195" height="49"/>
|
||||
<SubTexture name="grey_button06.png" x="0" y="49" width="191" height="49"/>
|
||||
<SubTexture name="grey_button07.png" x="195" y="0" width="49" height="49"/>
|
||||
<SubTexture name="grey_button08.png" x="240" y="49" width="49" height="49"/>
|
||||
<SubTexture name="grey_button09.png" x="98" y="433" width="49" height="45"/>
|
||||
<SubTexture name="grey_button10.png" x="191" y="49" width="49" height="49"/>
|
||||
<SubTexture name="grey_button11.png" x="0" y="433" width="49" height="45"/>
|
||||
<SubTexture name="grey_button12.png" x="244" y="0" width="49" height="49"/>
|
||||
<SubTexture name="grey_button13.png" x="49" y="433" width="49" height="45"/>
|
||||
<SubTexture name="grey_button14.png" x="0" y="384" width="190" height="49"/>
|
||||
<SubTexture name="grey_button15.png" x="0" y="237" width="190" height="49"/>
|
||||
<SubTexture name="grey_checkmarkGrey.png" x="99" y="478" width="21" height="20"/>
|
||||
<SubTexture name="grey_checkmarkWhite.png" x="78" y="478" width="21" height="20"/>
|
||||
<SubTexture name="grey_circle.png" x="185" y="469" width="36" height="36"/>
|
||||
<SubTexture name="grey_crossGrey.png" x="120" y="478" width="18" height="18"/>
|
||||
<SubTexture name="grey_crossWhite.png" x="190" y="318" width="18" height="18"/>
|
||||
<SubTexture name="grey_panel.png" x="190" y="98" width="100" height="100"/>
|
||||
<SubTexture name="grey_sliderDown.png" x="190" y="234" width="28" height="42"/>
|
||||
<SubTexture name="grey_sliderEnd.png" x="138" y="478" width="8" height="10"/>
|
||||
<SubTexture name="grey_sliderHorizontal.png" x="0" y="380" width="190" height="4"/>
|
||||
<SubTexture name="grey_sliderLeft.png" x="0" y="478" width="39" height="31"/>
|
||||
<SubTexture name="grey_sliderRight.png" x="39" y="478" width="39" height="31"/>
|
||||
<SubTexture name="grey_sliderUp.png" x="190" y="276" width="28" height="42"/>
|
||||
<SubTexture name="grey_sliderVertical.png" x="208" y="318" width="4" height="100"/>
|
||||
<SubTexture name="grey_tickGrey.png" x="190" y="336" width="17" height="17"/>
|
||||
<SubTexture name="grey_tickWhite.png" x="190" y="353" width="17" height="17"/>
|
||||
</TextureAtlas>
|
||||
BIN
assets/round-rect-4px-radius.png
Normal file
|
After Width: | Height: | Size: 175 B |
39
design.gv
Normal file
@@ -0,0 +1,39 @@
|
||||
digraph G {
|
||||
graph [
|
||||
ranksep = "0.7",
|
||||
nodesep = "1.0",
|
||||
];
|
||||
node [
|
||||
fontname = "Hack",
|
||||
shape = "record",
|
||||
];
|
||||
|
||||
roblox_studio -> plugin [dir = "both"];
|
||||
plugin -> web_server [style = "dashed", dir = "both"];
|
||||
|
||||
web_server -> session;
|
||||
|
||||
session -> rbx_session;
|
||||
session -> fs_watcher;
|
||||
session -> message_queue;
|
||||
|
||||
fs_watcher -> imfs [weight = "10"];
|
||||
fs_watcher -> rbx_session [constraint = "false"];
|
||||
|
||||
imfs -> fs;
|
||||
|
||||
rbx_session -> imfs;
|
||||
rbx_session -> middlewares [weight = "10"];
|
||||
rbx_session -> message_queue [constraint = "false"];
|
||||
|
||||
plugin [label = "Studio Plugin"];
|
||||
roblox_studio [label = "Roblox Studio"];
|
||||
fs [label = "Filesystem"];
|
||||
fs_watcher [label = "Filesystem Watcher"];
|
||||
session [label = "Session"];
|
||||
web_server [label = "Web API"];
|
||||
imfs [label = "In-Memory Filesystem"];
|
||||
rbx_session [label = "RbxSession"];
|
||||
message_queue [label = "MessageQueue"];
|
||||
middlewares [label = "Middlewares"];
|
||||
}
|
||||
68
docs/creating-a-place.md
Normal file
@@ -0,0 +1,68 @@
|
||||
[TOC]
|
||||
|
||||
## Creating the Rojo Project
|
||||
|
||||
To use Rojo to build a place, you'll need to create a new project file, which tells Rojo how your project is structured on-disk and in Roblox.
|
||||
|
||||
Create a new folder, then run `rojo init` inside that folder to initialize an empty project.
|
||||
|
||||
```sh
|
||||
mkdir my-new-project
|
||||
cd my-new-project
|
||||
|
||||
rojo init
|
||||
```
|
||||
|
||||
Rojo will make a small project file in your directory, named `default.project.json`. It'll make sure that any code in the directory `src` will get put into `ReplicatedStorage.Source`.
|
||||
|
||||
Speaking of, let's make sure we create a directory named `src`, and maybe a Lua file inside of it:
|
||||
|
||||
```sh
|
||||
mkdir src
|
||||
echo 'print("Hello, world!")' > src/hello.lua
|
||||
```
|
||||
|
||||
## Building Your Place
|
||||
Now that we have a project, one thing we can do is build a Roblox place file for our project. This is a great way to get started with a project quickly with no fuss.
|
||||
|
||||
All we have to do is call `rojo build`:
|
||||
|
||||
```sh
|
||||
rojo build -o MyNewProject.rbxl
|
||||
```
|
||||
|
||||
If you open `MyNewProject.rbxl` in Roblox Studio now, you should see a `Folder` containing a `ModuleScript` under `ReplicatedStorage`!
|
||||
|
||||
!!! info
|
||||
To generate an XML place file instead, like if you're checking the place file into version control, just use `rbxlx` as the extension on the output file instead.
|
||||
|
||||
## Live-Syncing into Studio
|
||||
Building a place file is great for the initial build, but for actively working on your place, you'll want something quicker.
|
||||
|
||||
In Roblox Studio, make sure the Rojo plugin is installed. If you need it, check out [the installation guide](installation) to learn how to install it.
|
||||
|
||||
To expose your project to the plugin, you'll need to _serve_ it from the command line:
|
||||
|
||||
```sh
|
||||
rojo serve
|
||||
```
|
||||
|
||||
This will start up a web server that tells Roblox Studio what instances are in your project and sends notifications if any of them change.
|
||||
|
||||
Note the port number, then switch into Roblox Studio and press the Rojo **Connect** button in the plugins tab. Type in the port number, if necessary, and press **Start**.
|
||||
|
||||
If everything went well, you should now be able to change files in the `src` directory and watch them sync into Roblox Studio in real time!
|
||||
|
||||
## Uploading Your Place
|
||||
Aimed at teams that want serious levels of automation, Rojo can upload places to Roblox.com automatically.
|
||||
|
||||
You'll need an existing place on Roblox.com as well as the `.ROBLOSECURITY` cookie of an account that has write access to that place.
|
||||
|
||||
!!! warning
|
||||
It's recommended that you set up a Roblox account dedicated to deploying your place instead of your personal account in case your security cookie is compromised.
|
||||
|
||||
Generating and uploading your place file is as simple as:
|
||||
|
||||
```sh
|
||||
rojo upload --asset_id [PLACE ID] --cookie "[SECURITY COOKIE]"
|
||||
```
|
||||
3
docs/extra.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.md-typeset__table {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
# Creating a Project
|
||||
To use Rojo, you'll need to create a new project file, which tells Rojo what your project is, and how to load it into Roblox Studio.
|
||||
|
||||
## New Project
|
||||
Create a new folder, then run `rojo init` inside that folder to initialize an empty project.
|
||||
|
||||
```sh
|
||||
mkdir my-new-project
|
||||
cd my-new-project
|
||||
|
||||
rojo init
|
||||
```
|
||||
|
||||
Rojo will create an empty project file named `rojo.json` in the directory.
|
||||
|
||||
The default configuration doesn't do anything. We need to tell Rojo where our code is on the filesystem, and where we want to put it in the Roblox tree.
|
||||
|
||||
To do that, open up `rojo.json` and add an entry to the `partitions` table:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "your-project-name-here",
|
||||
"servePort": 8000,
|
||||
"partitions": {
|
||||
"src": {
|
||||
"path": "src",
|
||||
"target": "ReplicatedStorage.Project"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
!!! warning
|
||||
Make sure that the `src` directory exists in your project, or Rojo will throw an error!
|
||||
|
||||
!!! warning
|
||||
Any objects contained in the `target` of a partition will be destroyed by Rojo if not found on the filesystem!
|
||||
|
||||
A Rojo project has one or more *partitions*. Partitions define how code should be transferred between the filesystem and Roblox by mapping directories and files to Roblox objects.
|
||||
|
||||
Each partition has:
|
||||
|
||||
* A name (the key in the `partitions` object), which is used for debugging
|
||||
* `path`, the location on the filesystem relative to `rojo.json`
|
||||
* `target`, the location in Roblox relative to `game`
|
||||
|
||||
## Syncing into Studio
|
||||
|
||||
Once you've added your partition to the project file, you can start the Rojo dev server by running a command in your project's directory:
|
||||
|
||||
```sh
|
||||
rojo serve
|
||||
```
|
||||
|
||||
If your project is in the right place, Rojo will let you know that it was found and start an HTTP server that the plugin can connect to.
|
||||
|
||||
In Roblox Studio, open the plugins tab and find Rojo's buttons.
|
||||
|
||||

|
||||
{: align="center" }
|
||||
|
||||
Press **Test Connection** to verify that the plugin can communicate with the dev server. Watch the Output panel for the results.
|
||||
|
||||
!!! info
|
||||
If you see an error message, return to the previous steps and make sure that the Rojo dev server is running.
|
||||
|
||||

|
||||
{: align="center" }
|
||||
|
||||
After your connection was successful, press **Sync In** to move code from the filesystem into Studio, or use **Toggle Polling** to have Rojo automatically sync in changes as they happen.
|
||||
|
||||
## Importing an Existing Project
|
||||
Rojo will eventually support importing an existing Roblox project onto the filesystem for use with Rojo.
|
||||
|
||||
Rojo doesn't currently support converting an existing project or syncing files from Roblox Studio onto the filesystem. In the mean time, you can manually copy your files into the structure that Rojo expects.
|
||||
|
||||
Up-to-date information will be available on [issue #5](https://github.com/LPGhatguy/rojo/issues/5) as this is worked on.
|
||||
@@ -1,26 +0,0 @@
|
||||
# Installation
|
||||
Rojo has two components:
|
||||
|
||||
* The server, a binary written in Rust
|
||||
* The plugin, a Roblox Studio plugin written in Lua
|
||||
|
||||
It's important that the plugin and server are compatible. The plugin will show errors in the Roblox Studio Output window if there is a version mismatch.
|
||||
|
||||
## Installing the Server
|
||||
To install the server, either:
|
||||
|
||||
* If you have Rust installed, use `cargo install rojo`
|
||||
* Or, download a pre-built Windows binary from [the GitHub releases page](https://github.com/LPGhatguy/rojo/releases)
|
||||
|
||||
**The Rojo binary must be run from the command line, like Terminal on MacOS or `cmd.exe` on Windows. It's recommended that you put the Rojo binary on your `PATH` to make this easier.**
|
||||
|
||||
## Installing the Plugin
|
||||
To install the plugin, either:
|
||||
|
||||
* Install the plugin from the [Roblox plugin page](https://www.roblox.com/library/1211549683/Rojo).
|
||||
* This gives you less control over what version you install -- you will always have the latest version.
|
||||
* Or, download the latest release from [the GitHub releases section](https://github.com/LPGhatguy/rojo/releases) and install it into your Roblox plugins folder
|
||||
* You can open this folder by clicking the "Plugins Folder" button from the Plugins toolbar in Roblox Studio
|
||||
|
||||
## Visual Studio Code Extension
|
||||
If you use Visual Studio Code on Windows, you can install [Evaera's unofficial Rojo extension](https://marketplace.visualstudio.com/items?itemName=evaera.vscode-rojo), which will install both halves of Rojo for you. It even has a nifty UI to add partitions and start/stop the Rojo server!
|
||||
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 17 KiB |
BIN
docs/images/plugins-folder-in-studio.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
17
docs/images/sync-example-files.gv
Normal file
@@ -0,0 +1,17 @@
|
||||
digraph "Sync Files" {
|
||||
graph [
|
||||
ranksep = "0.7",
|
||||
nodesep = "0.5",
|
||||
];
|
||||
node [
|
||||
fontname = "monospace",
|
||||
shape = "record",
|
||||
];
|
||||
|
||||
my_model [label = "MyModel"]
|
||||
init_server [label = "init.server.lua"]
|
||||
foo [label = "foo.lua"]
|
||||
|
||||
my_model -> init_server
|
||||
my_model -> foo
|
||||
}
|
||||
38
docs/images/sync-example-files.svg
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
|
||||
-->
|
||||
<!-- Title: Sync Files Pages: 1 -->
|
||||
<svg width="258pt" height="132pt"
|
||||
viewBox="0.00 0.00 258.00 132.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 128)">
|
||||
<title>Sync Files</title>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-128 254,-128 254,4 -4,4"/>
|
||||
<!-- my_model -->
|
||||
<g id="node1" class="node"><title>my_model</title>
|
||||
<polygon fill="none" stroke="black" points="104,-87.5 104,-123.5 178,-123.5 178,-87.5 104,-87.5"/>
|
||||
<text text-anchor="middle" x="141" y="-101.8" font-family="monospace" font-size="14.00">MyModel</text>
|
||||
</g>
|
||||
<!-- init_server -->
|
||||
<g id="node2" class="node"><title>init_server</title>
|
||||
<polygon fill="none" stroke="black" points="0,-0.5 0,-36.5 140,-36.5 140,-0.5 0,-0.5"/>
|
||||
<text text-anchor="middle" x="70" y="-14.8" font-family="monospace" font-size="14.00">init.server.lua</text>
|
||||
</g>
|
||||
<!-- my_model->init_server -->
|
||||
<g id="edge1" class="edge"><title>my_model->init_server</title>
|
||||
<path fill="none" stroke="black" d="M126.632,-87.299C116.335,-74.9713 102.308,-58.1787 90.7907,-44.3902"/>
|
||||
<polygon fill="black" stroke="black" points="93.4435,-42.1065 84.3465,-36.6754 88.0711,-46.594 93.4435,-42.1065"/>
|
||||
</g>
|
||||
<!-- foo -->
|
||||
<g id="node3" class="node"><title>foo</title>
|
||||
<polygon fill="none" stroke="black" points="176,-0.5 176,-36.5 250,-36.5 250,-0.5 176,-0.5"/>
|
||||
<text text-anchor="middle" x="213" y="-14.8" font-family="monospace" font-size="14.00">foo.lua</text>
|
||||
</g>
|
||||
<!-- my_model->foo -->
|
||||
<g id="edge2" class="edge"><title>my_model->foo</title>
|
||||
<path fill="none" stroke="black" d="M155.57,-87.299C166.013,-74.9713 180.237,-58.1787 191.917,-44.3902"/>
|
||||
<polygon fill="black" stroke="black" points="194.659,-46.5681 198.451,-36.6754 189.317,-42.0437 194.659,-46.5681"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
15
docs/images/sync-example-instances.gv
Normal file
@@ -0,0 +1,15 @@
|
||||
digraph "Sync Files" {
|
||||
graph [
|
||||
ranksep = "0.7",
|
||||
nodesep = "0.5",
|
||||
];
|
||||
node [
|
||||
fontname = "monospace",
|
||||
shape = "record",
|
||||
];
|
||||
|
||||
my_model [label = "MyModel (Script)"]
|
||||
foo [label = "foo (ModuleScript)"]
|
||||
|
||||
my_model -> foo
|
||||
}
|
||||
28
docs/images/sync-example-instances.svg
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
|
||||
-->
|
||||
<!-- Title: Sync Files Pages: 1 -->
|
||||
<svg width="173pt" height="132pt"
|
||||
viewBox="0.00 0.00 173.00 132.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 128)">
|
||||
<title>Sync Files</title>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-128 169,-128 169,4 -4,4"/>
|
||||
<!-- my_model -->
|
||||
<g id="node1" class="node"><title>my_model</title>
|
||||
<polygon fill="none" stroke="black" points="8,-87.5 8,-123.5 157,-123.5 157,-87.5 8,-87.5"/>
|
||||
<text text-anchor="middle" x="82.5" y="-101.8" font-family="monospace" font-size="14.00">MyModel (Script)</text>
|
||||
</g>
|
||||
<!-- foo -->
|
||||
<g id="node2" class="node"><title>foo</title>
|
||||
<polygon fill="none" stroke="black" points="0,-0.5 0,-36.5 165,-36.5 165,-0.5 0,-0.5"/>
|
||||
<text text-anchor="middle" x="82.5" y="-14.8" font-family="monospace" font-size="14.00">foo (ModuleScript)</text>
|
||||
</g>
|
||||
<!-- my_model->foo -->
|
||||
<g id="edge1" class="edge"><title>my_model->foo</title>
|
||||
<path fill="none" stroke="black" d="M82.5,-87.299C82.5,-75.6626 82.5,-60.0479 82.5,-46.7368"/>
|
||||
<polygon fill="black" stroke="black" points="86.0001,-46.6754 82.5,-36.6754 79.0001,-46.6755 86.0001,-46.6754"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
17
docs/images/sync-example-json-model.gv
Normal file
@@ -0,0 +1,17 @@
|
||||
digraph "Sync Files" {
|
||||
graph [
|
||||
ranksep = "0.7",
|
||||
nodesep = "0.5",
|
||||
];
|
||||
node [
|
||||
fontname = "monospace",
|
||||
shape = "record",
|
||||
];
|
||||
|
||||
model [label = "My Cool Model (Folder)"]
|
||||
root_part [label = "RootPart (Part)"]
|
||||
send_money [label = "SendMoney (RemoteEvent)"]
|
||||
|
||||
model -> root_part
|
||||
model -> send_money
|
||||
}
|
||||
38
docs/images/sync-example-json-model.svg
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
|
||||
-->
|
||||
<!-- Title: Sync Files Pages: 1 -->
|
||||
<svg width="390pt" height="132pt"
|
||||
viewBox="0.00 0.00 390.00 132.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 128)">
|
||||
<title>Sync Files</title>
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-128 386,-128 386,4 -4,4"/>
|
||||
<!-- model -->
|
||||
<g id="node1" class="node"><title>model</title>
|
||||
<polygon fill="none" stroke="black" points="75,-87.5 75,-123.5 273,-123.5 273,-87.5 75,-87.5"/>
|
||||
<text text-anchor="middle" x="174" y="-101.8" font-family="monospace" font-size="14.00">My Cool Model (Folder)</text>
|
||||
</g>
|
||||
<!-- root_part -->
|
||||
<g id="node2" class="node"><title>root_part</title>
|
||||
<polygon fill="none" stroke="black" points="0,-0.5 0,-36.5 140,-36.5 140,-0.5 0,-0.5"/>
|
||||
<text text-anchor="middle" x="70" y="-14.8" font-family="monospace" font-size="14.00">RootPart (Part)</text>
|
||||
</g>
|
||||
<!-- model->root_part -->
|
||||
<g id="edge1" class="edge"><title>model->root_part</title>
|
||||
<path fill="none" stroke="black" d="M152.954,-87.299C137.448,-74.6257 116.168,-57.2335 99.0438,-43.2377"/>
|
||||
<polygon fill="black" stroke="black" points="100.972,-40.2938 91.0147,-36.6754 96.5426,-45.7138 100.972,-40.2938"/>
|
||||
</g>
|
||||
<!-- send_money -->
|
||||
<g id="node3" class="node"><title>send_money</title>
|
||||
<polygon fill="none" stroke="black" points="176,-0.5 176,-36.5 382,-36.5 382,-0.5 176,-0.5"/>
|
||||
<text text-anchor="middle" x="279" y="-14.8" font-family="monospace" font-size="14.00">SendMoney (RemoteEvent)</text>
|
||||
</g>
|
||||
<!-- model->send_money -->
|
||||
<g id="edge2" class="edge"><title>model->send_money</title>
|
||||
<path fill="none" stroke="black" d="M195.248,-87.299C210.904,-74.6257 232.388,-57.2335 249.677,-43.2377"/>
|
||||
<polygon fill="black" stroke="black" points="252.213,-45.6878 257.783,-36.6754 247.809,-40.2471 252.213,-45.6878"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
@@ -1,6 +1,11 @@
|
||||
# Home
|
||||
This is the documentation home for Rojo.
|
||||
This is the documentation home for Rojo 0.5.x.
|
||||
|
||||
Available versions of these docs:
|
||||
|
||||
* [Latest version (currently 0.5.x)](https://lpghatguy.github.io/rojo)
|
||||
* [0.5.x](https://lpghatguy.github.io/rojo/0.5.x)
|
||||
* [0.4.x](https://lpghatguy.github.io/rojo/0.4.x)
|
||||
|
||||
**Rojo** is a flexible multi-tool designed for creating robust Roblox projects.
|
||||
|
||||
This documentation is a work in progress, and is incomplete.
|
||||
This documentation is a continual work in progress. If you find any issues, please file an issue on [Rojo's issue tracker](https://github.com/LPGhatguy/rojo/issues)!
|
||||
45
docs/installation.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[TOC]
|
||||
|
||||
## Overview
|
||||
|
||||
Rojo has two components:
|
||||
|
||||
* The command line interface (CLI)
|
||||
* The Roblox Studio plugin
|
||||
|
||||
!!! info
|
||||
It's important that your installed version of the plugin and CLI are compatible.
|
||||
|
||||
The plugin will show errors in the Roblox Studio output window if there is a version mismatch.
|
||||
|
||||
## Installing the CLI
|
||||
|
||||
### Installing from GitHub
|
||||
If you're on Windows, there are pre-built binaries available from Rojo's [GitHub Releases page](https://github.com/LPGhatguy/rojo/releases).
|
||||
|
||||
The Rojo CLI must be run from the command line, like Terminal.app on MacOS or `cmd.exe` on Windows. It's recommended that you put the Rojo CLI executable on your `PATH` to make this easier.
|
||||
|
||||
### Installing from Cargo
|
||||
If you have Rust installed, the easiest way to get Rojo is with Cargo!
|
||||
|
||||
To install the latest 0.5.0 alpha, use:
|
||||
|
||||
```sh
|
||||
cargo install rojo --version 0.5.0-alpha.6
|
||||
```
|
||||
|
||||
## Installing the Plugin
|
||||
|
||||
### Installing from GitHub
|
||||
The Rojo Roblox Studio plugin is available available from Rojo's [GitHub Releases page](https://github.com/LPGhatguy/rojo/releases).
|
||||
|
||||
Download the attached `rbxm` file and put it into your Roblox Studio plugins folder. You can find that folder by pressing **Plugins Folder** from your Plugins toolbar in Roblox Studio:
|
||||
|
||||

|
||||
{: align="center" }
|
||||
|
||||
### Installing from Roblox.com
|
||||
Visit [Rojo's Roblox.com Plugin page](https://www.roblox.com/library/1997686364/Rojo-0-5-0-alpha-3) in Roblox Studio and press **Install**.
|
||||
|
||||
## Visual Studio Code Extension
|
||||
If you use Visual Studio Code on Windows, you can install [Evaera's unofficial Rojo extension](https://marketplace.visualstudio.com/items?itemName=evaera.vscode-rojo), which will install both halves of Rojo for you. It even has a nifty UI to add partitions and start/stop the Rojo server!
|
||||
45
docs/internals/overview.md
Normal file
@@ -0,0 +1,45 @@
|
||||
This document aims to give a general overview of how Rojo works. It's intended for people who want to contribute to the project as well as anyone who's just curious how the tool works!
|
||||
|
||||
[TOC]
|
||||
|
||||
## CLI
|
||||
|
||||
### RbxTree
|
||||
Rojo uses a library named [`rbx_tree`](https://github.com/LPGhatguy/rbx-tree) as its implementation of the Roblox DOM. It serves as a common format for serialization to all the formats Rojo supports!
|
||||
|
||||
Rojo uses two related libraries to deserialize instances from Roblox's file formats, `rbx_xml` and `rbx_binary`.
|
||||
|
||||
### In-Memory Filesystem (IMFS)
|
||||
Relevant source files:
|
||||
|
||||
* [`server/src/imfs.rs`](https://github.com/LPGhatguy/rojo/blob/master/server/src/imfs.rs)
|
||||
* [`server/src/fs_watcher.rs`](https://github.com/LPGhatguy/rojo/blob/master/server/src/fs_watcher.rs)
|
||||
|
||||
Rojo keeps an in-memory copy of all files that it needs reasons about. This enables taking fast, stateless, tear-tree snapshots of files to turn them into instances.
|
||||
|
||||
Keeping an in-memory copy of file contents will also enable Rojo to debounce changes that are caused by Rojo itself. This'll happen when two-way sync finally happens.
|
||||
|
||||
### Snapshot Reconciler
|
||||
Relevant source files:
|
||||
|
||||
* [`server/src/snapshot_reconciler.rs`](https://github.com/LPGhatguy/rojo/blob/master/server/src/snapshot_reconciler.rs)
|
||||
* [`server/src/rbx_snapshot.rs`](https://github.com/LPGhatguy/rojo/blob/master/server/src/rbx_snapshot.rs)
|
||||
* [`server/src/rbx_session.rs`](https://github.com/LPGhatguy/rojo/blob/master/server/src/rbx_session.rs)
|
||||
|
||||
To simplify incremental updates of instances, Rojo generates lightweight snapshots describing how files map to instances. This means that Rojo can treat file change events similarly to damage painting as opposed to trying to surgically update the correct instances.
|
||||
|
||||
This approach reduces the number of desynchronization bugs, reduces the complexity of important pieces of the codebase, and makes writing plugins a lot easier.
|
||||
|
||||
### HTTP API
|
||||
Relevant source files:
|
||||
|
||||
* [`server/src/web.rs`](https://github.com/LPGhatguy/rojo/blob/master/server/src/web.rs)
|
||||
|
||||
The Rojo live-sync server and Roblox Studio plugin communicate via HTTP.
|
||||
|
||||
Requests sent from the plugin to the server are regular HTTP requests.
|
||||
|
||||
Messages sent from the server to the plugin are delivered via HTTP long-polling. This is an approach that uses long-lived HTTP requests that restart on timeout. It's largely been replaced by WebSockets, but Roblox doesn't have support for them.
|
||||
|
||||
## Roblox Studio Plugin
|
||||
TODO
|
||||
58
docs/migrating-to-epiphany.md
Normal file
@@ -0,0 +1,58 @@
|
||||
Rojo underwent a large refactor during most of 2018 to enable a bunch of new features and lay groundwork for lots more in 2019. As such, Rojo **0.5.x** projects are not compatible with Rojo **0.4.x** projects.
|
||||
|
||||
[TOC]
|
||||
|
||||
## Supporting Both 0.4.x and 0.5.x
|
||||
Rojo 0.5.x uses a different name for its project format. While 0.4.x used `rojo.json`, 0.5.x uses `default.project.json`, which allows them to coexist.
|
||||
|
||||
If you aren't sure about upgrading or want to upgrade gradually, it's possible to keep both files in the same project without causing problems.
|
||||
|
||||
## Upgrading Your Project File
|
||||
Project files in 0.5.x are more explicit and flexible than they were in 0.4.x. Project files can now describe models and plugins in addition to places.
|
||||
|
||||
This new project file format also guards against two of the biggest pitfalls when writing a config file:
|
||||
|
||||
* Using a service as a partition target directly, which often wiped away extra instances
|
||||
* Defining two partitions that overlapped, which made Rojo act unpredictably
|
||||
|
||||
The biggest change is that the `partitions` field has been replaced with a new field, `tree`, that describes the entire hierarchy of your project from the top-down.
|
||||
|
||||
A project for 0.4.x that syncs from the `src` directory into `ReplicatedStorage.Source` would look like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Rojo 0.4.x Example",
|
||||
"partitions": {
|
||||
"path": "src",
|
||||
"target": "ReplicatedStorage.Source"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In 0.5.x, the project format is more explicit:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Rojo 0.5.x Example",
|
||||
"tree": {
|
||||
"$className": "DataModel",
|
||||
"ReplicatedStorage": {
|
||||
"$className": "ReplicatedStorage",
|
||||
"Source": {
|
||||
"$path": "src"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For each object in the tree, we define *metadata* and *children*.
|
||||
|
||||
Metadata begins with a dollar sign (`$`), like `$className`. This is so that children and metadata can coexist without creating too many nested layers.
|
||||
|
||||
All other values are considered children, where the key is the instance's name, and the value is an object, repeating the process.
|
||||
|
||||
## Migrating Unknown Files
|
||||
If you used Rojo to sync in files as `StringValue` objects, you'll need to make sure those files end with the `txt` extension to preserve this in Rojo 0.5.x.
|
||||
|
||||
Unknown files are now ignored in Rojo instead of being converted to `StringValue` objects.
|
||||
100
docs/project-format.md
Normal file
@@ -0,0 +1,100 @@
|
||||
[TOC]
|
||||
|
||||
## Project File
|
||||
|
||||
Rojo projects are JSON files that have the `.project.json` extension. They have these fields:
|
||||
|
||||
* `name`: A string indicating the name of the project.
|
||||
* This is only used for diagnostics.
|
||||
* `tree`: An [Instance Description](#instance-description) describing the root instance of the project.
|
||||
|
||||
## Instance Description
|
||||
Instance Descriptions correspond one-to-one with the actual Roblox Instances in the project. They can be specified directly in the project file or be pulled from the filesystem.
|
||||
|
||||
* `$className`: The ClassName of the Instance being described.
|
||||
* Optional if `$path` is specified.
|
||||
* `$path`: The path on the filesystem to pull files from into the project.
|
||||
* Optional if `$className` is specified.
|
||||
* Paths are relative to the folder containing the project file.
|
||||
* `$properties`: Properties to apply to the instance. Values should be [Instance Property Values](#instance-property-value).
|
||||
* Optional
|
||||
* `$ignoreUnknownInstances`: Whether instances that Rojo doesn't know about should be deleted.
|
||||
* Optional
|
||||
* Default is `false` if `$path` is specified, otherwise `true`.
|
||||
|
||||
All other fields in an Instance Description are turned into instances whose name is the key. These values should also be Instance Descriptions!
|
||||
|
||||
Instance Descriptions are fairly verbose and strict. In the future, it'll be possible for Rojo to infer class names for known services like `Workspace`.
|
||||
|
||||
## Instance Property Value
|
||||
The shape of Instance Property Values is defined by the [rbx_tree](https://github.com/LPGhatguy/rbx-tree) library, so it uses slightly different conventions than the rest of Rojo.
|
||||
|
||||
Each value should be an object with the following required fields:
|
||||
|
||||
* `Type`: The type of property to represent.
|
||||
* [Supported types can be found here](https://github.com/LPGhatguy/rbx-tree#property-type-coverage).
|
||||
* `Value`: The value of the property.
|
||||
* The shape of this field depends on which property type is being used. `Vector3` and `Color3` values are both represented as a list of numbers, for example.
|
||||
|
||||
Instance Property Values are intentionally very strict. Rojo will eventually be able to infer types for you!
|
||||
|
||||
## Example Projects
|
||||
This project bundles up everything in the `src` directory. It'd be suitable for making a plugin or model:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "AwesomeLibrary",
|
||||
"tree": {
|
||||
"$path": "src"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This project describes the layout you might use if you were making the next hit simulator game, *Sisyphus Simulator*:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Sisyphus Simulator",
|
||||
"tree": {
|
||||
"$className": "DataModel",
|
||||
|
||||
"HttpService": {
|
||||
"$className": "HttpService",
|
||||
"$properties": {
|
||||
"HttpEnabled": {
|
||||
"Type": "Bool",
|
||||
"Value": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"ReplicatedStorage": {
|
||||
"$className": "ReplicatedStorage",
|
||||
"$path": "src/ReplicatedStorage"
|
||||
},
|
||||
|
||||
"StarterPlayer": {
|
||||
"$className": "StarterPlayer",
|
||||
|
||||
"StarterPlayerScripts": {
|
||||
"$className": "StarterPlayerScripts",
|
||||
"$path": "src/StarterPlayerScripts"
|
||||
}
|
||||
},
|
||||
|
||||
"Workspace": {
|
||||
"$className": "Workspace",
|
||||
"$properties": {
|
||||
"Gravity": {
|
||||
"Type": "Float32",
|
||||
"Value": 67.3
|
||||
}
|
||||
},
|
||||
|
||||
"Terrain": {
|
||||
"$path": "Terrain.rbxm"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,65 +1,91 @@
|
||||
# Sync Details
|
||||
This page aims to describe how Rojo turns files on the filesystem into Roblox objects.
|
||||
|
||||
[TOC]
|
||||
|
||||
## Overview
|
||||
| File Name | Instance Type |
|
||||
| -------------- | ------------------- |
|
||||
| any directory | `Folder` |
|
||||
| `*.server.lua` | `Script` |
|
||||
| `*.client.lua` | `LocalScript` |
|
||||
| `*.lua` | `ModuleScript` |
|
||||
| `*.csv` | `LocalizationTable` |
|
||||
| `*.txt` | `StringValue` |
|
||||
| `*.model.json` | Any |
|
||||
| `*.rbxm` | Any |
|
||||
| `*.rbxmx` | Any |
|
||||
|
||||
## Limitations
|
||||
Not all property types can be synced by Rojo in real-time due to limitations of the Roblox Studio plugin API. In these cases, you can usually generate a place file and open it when you start working on a project.
|
||||
|
||||
Some common cases you might hit are:
|
||||
|
||||
* Binary data (Terrain, CSG, CollectionService tags)
|
||||
* `MeshPart.MeshId`
|
||||
* `HttpService.HttpEnabled`
|
||||
|
||||
For a list of all property types that Rojo can reason about, both when live-syncing and when building place files, look at [rbx_tree's type coverage chart](https://github.com/LPGhatguy/rbx-tree#property-type-coverage).
|
||||
|
||||
## Folders
|
||||
Any directory on the filesystem will turn into a `Folder` instance in Roblox, unless that folder matches the name of a service or other existing instance. In those cases, that instance will be preserved.
|
||||
Any directory on the filesystem will turn into a `Folder` instance unless it contains an 'init' script, described below.
|
||||
|
||||
## Scripts
|
||||
Rojo can represent `ModuleScript`, `Script`, and `LocalScript` objects. The default script type is `ModuleScript`, since most scripts in well-structued Roblox projects will be modules.
|
||||
The default script type in Rojo projects is `ModuleScript`, since most scripts in well-structued Roblox projects will be modules.
|
||||
|
||||
| File Name | Instance Type |
|
||||
| -------------- | -------------- |
|
||||
| `*.server.lua` | `Script` |
|
||||
| `*.client.lua` | `LocalScript` |
|
||||
| `*.lua` | `ModuleScript` |
|
||||
If a directory contains a file named `init.server.lua`, `init.client.lua`, or `init.lua`, that folder will be transformed into a `*Script` instance with the contents of the 'init' file. This can be used to create scripts inside of scripts.
|
||||
|
||||
If a directory contains a file named `init.server.lua`, `init.client.lua`, or `init.lua`, that folder will be transformed into a `*Script` instance with the conents of the `init` file. This can be used to create scripts inside of scripts.
|
||||
For example, these files:
|
||||
|
||||
For example, this file tree:
|
||||
|
||||
* my-game
|
||||
* init.client.lua
|
||||
* foo.lua
|
||||

|
||||
{: align="center" }
|
||||
|
||||
Will turn into these instances in Roblox:
|
||||
|
||||

|
||||

|
||||
{: align="center" }
|
||||
|
||||
## 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.
|
||||
## Localization Tables
|
||||
Any CSV files are transformed into `LocalizationTable` instances. Rojo expects these files to follow the same format that Roblox does when importing and exporting localization information.
|
||||
|
||||
Rojo JSON models are stored in `.model.json` files.
|
||||
## Plain Text Files
|
||||
Plain text files (`.txt`) files are transformed into `StringValue` instances. This is useful for bringing in text data that can be read by scripts at runtime.
|
||||
|
||||
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.
|
||||
## JSON Models
|
||||
Files ending in `.model.json` can be used to describe simple models. They're designed to be hand-written and are useful for instances like `RemoteEvent`.
|
||||
|
||||
!!! 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.
|
||||
A JSON model describing a folder containing a `Part` and a `RemoteEvent` could be described as:
|
||||
|
||||
!!! 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
|
||||
{
|
||||
"Name": "hello",
|
||||
"ClassName": "Model",
|
||||
"Name": "My Cool Model",
|
||||
"ClassName": "Folder",
|
||||
"Children": [
|
||||
{
|
||||
"Name": "Some Part",
|
||||
"ClassName": "Part"
|
||||
},
|
||||
{
|
||||
"Name": "Some StringValue",
|
||||
"ClassName": "StringValue",
|
||||
"Name": "RootPart",
|
||||
"ClassName": "Part",
|
||||
"Properties": {
|
||||
"Value": {
|
||||
"Type": "String",
|
||||
"Value": "Hello, world!"
|
||||
"Size": {
|
||||
"Type": "Vector3",
|
||||
"Value": [4, 4, 4]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Name": "SendMoney",
|
||||
"ClassName": "RemoteEvent"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
It would turn into instances in this shape:
|
||||
|
||||

|
||||
{: align="center" }
|
||||
|
||||
## Binary and XML Models
|
||||
Rojo supports both binary (`.rbxm`) and XML (`.rbxmx`) models generated by Roblox Studio or another tool.
|
||||
|
||||
Not all property types are supported for all formats!
|
||||
|
||||
For a rundown of supported types, check out [rbx_tree's type coverage chart](https://github.com/LPGhatguy/rbx-tree#property-type-coverage).
|
||||
@@ -1,17 +1,19 @@
|
||||
# Why Rojo?
|
||||
There are a number of existing plugins for Roblox that move code from the filesystem into Roblox.
|
||||
|
||||
Besides Rojo, there is:
|
||||
Besides Rojo, you might consider:
|
||||
|
||||
* [Studio Bridge](https://github.com/vocksel/studio-bridge) by [Vocksel](https://github.com/vocksel)
|
||||
* [RbxRefresh](https://github.com/osyrisrblx/RbxRefresh) by [Osyris](https://github.com/osyrisrblx)
|
||||
* [RbxSync](https://github.com/evaera/RbxSync) by [evaera](https://github.com/evaera)
|
||||
* [CodeSync](https://github.com/MemoryPenguin/CodeSync) and [rbx-exteditor](https://github.com/MemoryPenguin/rbx-exteditor) by [MemoryPenguin](https://github.com/MemoryPenguin)
|
||||
* [rbxmk](https://github.com/anaminus/rbxmk) by [Anaminus](https://github.com/anaminus)
|
||||
* [rbxmk by Anaminus](https://github.com/anaminus/rbxmk)
|
||||
* [Rofresh by Osyris](https://github.com/osyrisrblx/rofresh)
|
||||
* [RbxRefresh by Osyris](https://github.com/osyrisrblx/RbxRefresh)
|
||||
* [Studio Bridge by Vocksel](https://github.com/vocksel/studio-bridge)
|
||||
* [Elixir by Vocksel](https://github.com/vocksel/elixir)
|
||||
* [RbxSync by evaera](https://github.com/evaera/RbxSync)
|
||||
* [CodeSync by MemoryPenguin](https://github.com/MemoryPenguin/CodeSync)
|
||||
* [rbx-exteditor by MemoryPenguin](https://github.com/MemoryPenguin/rbx-exteditor)
|
||||
|
||||
So why did I build Rojo?
|
||||
|
||||
Each of these tools solves what is essentially the same problem from a few different angles. The goal of Rojo is to take all of the lessons and ideas learned from these projects and build a tool that can solve the problem for good.
|
||||
Each of these tools solves what is essentially the same problem from a few different angles. The goal of Rojo is to take all of the lessons and ideas learned from these projects and build a tool that can solve this problem for good.
|
||||
|
||||
Additionally:
|
||||
|
||||
|
||||
35
generate-docs
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Kludged documentation generator to support multiple versions.
|
||||
# Make sure the `site` folder is a checkout of this repository's `gh-pages`
|
||||
# branch.
|
||||
|
||||
set -e
|
||||
|
||||
REMOTE=$(git remote get-url origin)
|
||||
CHECKOUT="$(mktemp -d)"
|
||||
OUTPUT="$(pwd)/site"
|
||||
|
||||
if [ -d site ]
|
||||
then
|
||||
cd site
|
||||
git pull
|
||||
else
|
||||
git clone "$REMOTE" site
|
||||
cd site
|
||||
git checkout gh-pages
|
||||
fi
|
||||
|
||||
git clone "$REMOTE" "$CHECKOUT"
|
||||
cd "$CHECKOUT"
|
||||
|
||||
echo "Building master"
|
||||
git checkout master
|
||||
mkdocs build --site-dir "$OUTPUT"
|
||||
|
||||
echo "Building 0.5.x"
|
||||
mkdocs build --site-dir "$OUTPUT/0.5.x"
|
||||
|
||||
echo "Building 0.4.x"
|
||||
git checkout v0.4.x
|
||||
mkdocs build --site-dir "$OUTPUT/0.4.x"
|
||||
15
mkdocs.yml
@@ -1,5 +1,4 @@
|
||||
site_name: Rojo Documentation
|
||||
site_url: https://lpghatguy.github.io/rojo/
|
||||
repo_name: LPGhatguy/rojo
|
||||
repo_url: https://github.com/LPGhatguy/rojo
|
||||
|
||||
@@ -9,13 +8,19 @@ theme:
|
||||
primary: 'Red'
|
||||
accent: 'Red'
|
||||
|
||||
pages:
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Why Rojo?: why-rojo.md
|
||||
- Getting Started:
|
||||
- Installation: getting-started/installation.md
|
||||
- Creating a Project: getting-started/creating-a-project.md
|
||||
- Installation: installation.md
|
||||
- Creating a Place with Rojo: creating-a-place.md
|
||||
- Migrating from 0.4.x to 0.5.x: migrating-to-epiphany.md
|
||||
- Project Format: project-format.md
|
||||
- Sync Details: sync-details.md
|
||||
- Rojo Internals:
|
||||
- Internals Overview: internals/overview.md
|
||||
|
||||
extra_css:
|
||||
- extra.css
|
||||
|
||||
markdown_extensions:
|
||||
- attr_list
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[*.lua]
|
||||
indent_style = tab
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
@@ -13,6 +13,7 @@ stds.roblox = {
|
||||
|
||||
-- Types
|
||||
"Vector2", "Vector3",
|
||||
"Vector2int16", "Vector3int16",
|
||||
"Color3",
|
||||
"UDim", "UDim2",
|
||||
"Rect",
|
||||
@@ -39,6 +40,10 @@ stds.testez = {
|
||||
|
||||
ignore = {
|
||||
"212", -- unused arguments
|
||||
"421", -- shadowing local variable
|
||||
"422", -- shadowing argument
|
||||
"431", -- shadowing upvalue
|
||||
"432", -- shadowing upvalue argument
|
||||
}
|
||||
|
||||
std = "lua51+roblox"
|
||||
|
||||
5
plugin/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Rojo Plugin
|
||||
|
||||
This is the source to the Rojo Roblox Studio plugin.
|
||||
|
||||
Documentation is WIP.
|
||||
18
plugin/default.project.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "Rojo",
|
||||
"tree": {
|
||||
"$className": "Folder",
|
||||
"Plugin": {
|
||||
"$path": "src"
|
||||
},
|
||||
"Roact": {
|
||||
"$path": "modules/roact/lib"
|
||||
},
|
||||
"Promise": {
|
||||
"$path": "modules/promise/lib"
|
||||
},
|
||||
"t": {
|
||||
"$path": "modules/t/lib/t.lua"
|
||||
}
|
||||
}
|
||||
}
|
||||
37
plugin/loadEnvironment.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
--[[
|
||||
Loads the Rojo plugin and all of its dependencies.
|
||||
]]
|
||||
|
||||
local function loadEnvironment()
|
||||
-- If you add any dependencies, add them to this table so they'll be loaded!
|
||||
local LOAD_MODULES = {
|
||||
{"src", "Rojo"},
|
||||
{"modules/promise/lib", "Promise"},
|
||||
{"modules/testez/lib", "TestEZ"},
|
||||
}
|
||||
|
||||
-- This makes sure we can load Lemur and other libraries that depend on init.lua
|
||||
package.path = package.path .. ";?/init.lua"
|
||||
|
||||
-- If this fails, make sure you've run `lua bin/install-dependencies.lua` first!
|
||||
local lemur = require("modules.lemur")
|
||||
|
||||
-- Create a virtual Roblox tree
|
||||
local habitat = lemur.Habitat.new()
|
||||
|
||||
-- We'll put all of our library code and dependencies here
|
||||
local modules = lemur.Instance.new("Folder")
|
||||
modules.Name = "Modules"
|
||||
modules.Parent = habitat.game:GetService("ReplicatedStorage")
|
||||
|
||||
-- Load all of the modules specified above
|
||||
for _, module in ipairs(LOAD_MODULES) do
|
||||
local container = habitat:loadFromFs(module[1])
|
||||
container.Name = module[2]
|
||||
container.Parent = modules
|
||||
end
|
||||
|
||||
return habitat, modules
|
||||
end
|
||||
|
||||
return loadEnvironment
|
||||
1
plugin/modules/t
Submodule
48
plugin/place.project.json
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "rojo",
|
||||
"tree": {
|
||||
"$className": "DataModel",
|
||||
|
||||
"ReplicatedStorage": {
|
||||
"$className": "ReplicatedStorage",
|
||||
|
||||
"Rojo": {
|
||||
"$className": "Folder",
|
||||
|
||||
"Plugin": {
|
||||
"$path": "src"
|
||||
},
|
||||
"Roact": {
|
||||
"$path": "modules/roact/lib"
|
||||
},
|
||||
"Promise": {
|
||||
"$path": "modules/promise/lib"
|
||||
},
|
||||
"t": {
|
||||
"$path": "modules/t/lib/t.lua"
|
||||
}
|
||||
},
|
||||
"TestEZ": {
|
||||
"$path": "modules/testez/lib"
|
||||
}
|
||||
},
|
||||
|
||||
"HttpService": {
|
||||
"$className": "HttpService",
|
||||
"$properties": {
|
||||
"HttpEnabled": {
|
||||
"Type": "Bool",
|
||||
"Value": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"ServerScriptService": {
|
||||
"$className": "ServerScriptService",
|
||||
|
||||
"TestBootstrap": {
|
||||
"$path": "testBootstrap.server.lua"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,31 +4,31 @@
|
||||
"partitions": {
|
||||
"plugin": {
|
||||
"path": "src",
|
||||
"target": "ReplicatedStorage.Rojo.plugin"
|
||||
"target": "ReplicatedStorage.Rojo.Plugin"
|
||||
},
|
||||
"modules/roact": {
|
||||
"path": "modules/roact/lib",
|
||||
"target": "ReplicatedStorage.Rojo.modules.Roact"
|
||||
"target": "ReplicatedStorage.Rojo.Roact"
|
||||
},
|
||||
"modules/rodux": {
|
||||
"path": "modules/rodux/lib",
|
||||
"target": "ReplicatedStorage.Rojo.modules.Rodux"
|
||||
"target": "ReplicatedStorage.Rojo.Rodux"
|
||||
},
|
||||
"modules/roact-rodux": {
|
||||
"path": "modules/roact-rodux/lib",
|
||||
"target": "ReplicatedStorage.Rojo.modules.RoactRodux"
|
||||
"target": "ReplicatedStorage.Rojo.RoactRodux"
|
||||
},
|
||||
"modules/promise": {
|
||||
"path": "modules/promise/lib",
|
||||
"target": "ReplicatedStorage.Rojo.modules.Promise"
|
||||
"target": "ReplicatedStorage.Rojo.Promise"
|
||||
},
|
||||
"modules/testez": {
|
||||
"path": "modules/testez/lib",
|
||||
"target": "ReplicatedStorage.TestEZ"
|
||||
},
|
||||
"tests": {
|
||||
"path": "tests",
|
||||
"target": "TestService"
|
||||
"path": "testBootstrap.server.lua",
|
||||
"target": "TestService.testBootstrap"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
plugin/runTest.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
local loadEnvironment = require("loadEnvironment")
|
||||
|
||||
local testPath = assert((...), "Please specify a path to a test file.")
|
||||
|
||||
local habitat = loadEnvironment()
|
||||
|
||||
local testModule = habitat:loadFromFs(testPath)
|
||||
|
||||
if testModule == nil then
|
||||
error("Couldn't find test file at " .. testPath)
|
||||
end
|
||||
|
||||
print("Starting test module.")
|
||||
|
||||
habitat:require(testModule)
|
||||
@@ -2,68 +2,16 @@
|
||||
Loads our library and all of its dependencies, then runs tests using TestEZ.
|
||||
]]
|
||||
|
||||
-- If you add any dependencies, add them to this table so they'll be loaded!
|
||||
local LOAD_MODULES = {
|
||||
{"src", "Plugin"},
|
||||
{"modules/testez/lib", "TestEZ"},
|
||||
}
|
||||
local loadEnvironment = require("loadEnvironment")
|
||||
|
||||
-- This makes sure we can load Lemur and other libraries that depend on init.lua
|
||||
package.path = package.path .. ";?/init.lua"
|
||||
|
||||
-- If this fails, make sure you've run `lua bin/install-dependencies.lua` first!
|
||||
local lemur = require("modules.lemur")
|
||||
|
||||
--[[
|
||||
Collapses ModuleScripts named 'init' into their parent folders.
|
||||
|
||||
This is the same result as the collapsing mechanism from Rojo.
|
||||
]]
|
||||
local function collapse(root)
|
||||
local init = root:FindFirstChild("init")
|
||||
if init then
|
||||
init.Name = root.Name
|
||||
init.Parent = root.Parent
|
||||
|
||||
for _, child in ipairs(root:GetChildren()) do
|
||||
child.Parent = init
|
||||
end
|
||||
|
||||
root:Destroy()
|
||||
root = init
|
||||
end
|
||||
|
||||
for _, child in ipairs(root:GetChildren()) do
|
||||
if child:IsA("Folder") then
|
||||
collapse(child)
|
||||
end
|
||||
end
|
||||
|
||||
return root
|
||||
end
|
||||
|
||||
-- Create a virtual Roblox tree
|
||||
local habitat = lemur.Habitat.new()
|
||||
|
||||
-- We'll put all of our library code and dependencies here
|
||||
local Root = lemur.Instance.new("Folder")
|
||||
Root.Name = "Root"
|
||||
|
||||
-- Load all of the modules specified above
|
||||
for _, module in ipairs(LOAD_MODULES) do
|
||||
local container = lemur.Instance.new("Folder", Root)
|
||||
container.Name = module[2]
|
||||
habitat:loadFromFs(module[1], container)
|
||||
end
|
||||
|
||||
collapse(Root)
|
||||
local habitat, modules = loadEnvironment()
|
||||
|
||||
-- Load TestEZ and run our tests
|
||||
local TestEZ = habitat:require(Root.TestEZ)
|
||||
local TestEZ = habitat:require(modules.TestEZ)
|
||||
|
||||
local results = TestEZ.TestBootstrap:run(Root.Plugin, TestEZ.Reporters.TextReporter)
|
||||
local results = TestEZ.TestBootstrap:run({modules.Rojo}, TestEZ.Reporters.TextReporter)
|
||||
|
||||
-- Did something go wrong?
|
||||
if results.failureCount > 0 then
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
@@ -1,114 +0,0 @@
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local Promise = require(script.Parent.Parent.modules.Promise)
|
||||
|
||||
local Config = require(script.Parent.Config)
|
||||
local Version = require(script.Parent.Version)
|
||||
|
||||
local Api = {}
|
||||
Api.__index = Api
|
||||
|
||||
Api.Error = {
|
||||
ServerIdMismatch = "ServerIdMismatch",
|
||||
}
|
||||
|
||||
setmetatable(Api.Error, {
|
||||
__index = function(_, key)
|
||||
error("Invalid API.Error name " .. key, 2)
|
||||
end
|
||||
})
|
||||
|
||||
--[[
|
||||
Api.connect(Http) -> Promise<Api>
|
||||
|
||||
Create a new Api using the given HTTP implementation.
|
||||
|
||||
Attempting to invoke methods on an invalid conext will throw errors!
|
||||
]]
|
||||
function Api.connect(http)
|
||||
local context = {
|
||||
http = http,
|
||||
serverId = nil,
|
||||
currentTime = 0,
|
||||
}
|
||||
|
||||
setmetatable(context, Api)
|
||||
|
||||
return context:_start()
|
||||
:andThen(function()
|
||||
return context
|
||||
end)
|
||||
end
|
||||
|
||||
function Api:_start()
|
||||
return self.http:get("/")
|
||||
:andThen(function(response)
|
||||
response = response:json()
|
||||
|
||||
if response.protocolVersion ~= Config.protocolVersion then
|
||||
local message = (
|
||||
"Found a Rojo dev server, but it's using a different protocol version, and is incompatible." ..
|
||||
"\nMake sure you have matching versions of both the Rojo plugin and server!" ..
|
||||
"\n\nYour client is version %s, with protocol version %s. It expects server version %s." ..
|
||||
"\nYour server is version %s, with protocol version %s." ..
|
||||
"\n\nGo to https://github.com/LPGhatguy/rojo for more details."
|
||||
):format(
|
||||
Version.display(Config.version), Config.protocolVersion,
|
||||
Config.expectedApiVersionString,
|
||||
response.serverVersion, response.protocolVersion
|
||||
)
|
||||
|
||||
return Promise.reject(message)
|
||||
end
|
||||
|
||||
self.serverId = response.serverId
|
||||
self.currentTime = response.currentTime
|
||||
end)
|
||||
end
|
||||
|
||||
function Api:getInfo()
|
||||
return self.http:get("/")
|
||||
:andThen(function(response)
|
||||
response = response:json()
|
||||
|
||||
if response.serverId ~= self.serverId then
|
||||
return Promise.reject(Api.Error.ServerIdMismatch)
|
||||
end
|
||||
|
||||
return response
|
||||
end)
|
||||
end
|
||||
|
||||
function Api:read(paths)
|
||||
local body = HttpService:JSONEncode(paths)
|
||||
|
||||
return self.http:post("/read", body)
|
||||
:andThen(function(response)
|
||||
response = response:json()
|
||||
|
||||
if response.serverId ~= self.serverId then
|
||||
return Promise.reject(Api.Error.ServerIdMismatch)
|
||||
end
|
||||
|
||||
return response.items
|
||||
end)
|
||||
end
|
||||
|
||||
function Api:getChanges()
|
||||
local url = ("/changes/%f"):format(self.currentTime)
|
||||
|
||||
return self.http:get(url)
|
||||
:andThen(function(response)
|
||||
response = response:json()
|
||||
|
||||
if response.serverId ~= self.serverId then
|
||||
return Promise.reject(Api.Error.ServerIdMismatch)
|
||||
end
|
||||
|
||||
self.currentTime = response.currentTime
|
||||
|
||||
return response.changes
|
||||
end)
|
||||
end
|
||||
|
||||
return Api
|
||||
169
plugin/src/ApiContext.lua
Normal file
@@ -0,0 +1,169 @@
|
||||
local Promise = require(script.Parent.Parent.Promise)
|
||||
|
||||
local Config = require(script.Parent.Config)
|
||||
local Version = require(script.Parent.Version)
|
||||
local Http = require(script.Parent.Http)
|
||||
local HttpError = require(script.Parent.HttpError)
|
||||
|
||||
local ApiContext = {}
|
||||
ApiContext.__index = ApiContext
|
||||
|
||||
-- TODO: Audit cases of errors and create enum values for each of them.
|
||||
ApiContext.Error = {
|
||||
ServerIdMismatch = "ServerIdMismatch",
|
||||
|
||||
-- The server gave an unexpected 400-category error, which may be the
|
||||
-- client's fault.
|
||||
ClientError = "ClientError",
|
||||
|
||||
-- The server gave an unexpected 500-category error, which may be the
|
||||
-- server's fault.
|
||||
ServerError = "ServerError",
|
||||
}
|
||||
|
||||
setmetatable(ApiContext.Error, {
|
||||
__index = function(_, key)
|
||||
error("Invalid ApiContext.Error name " .. key, 2)
|
||||
end
|
||||
})
|
||||
|
||||
local function rejectFailedRequests(response)
|
||||
if response.code >= 400 then
|
||||
if response.code < 500 then
|
||||
return Promise.reject(ApiContext.Error.ClientError)
|
||||
else
|
||||
return Promise.reject(ApiContext.Error.ServerError)
|
||||
end
|
||||
end
|
||||
|
||||
return response
|
||||
end
|
||||
|
||||
function ApiContext.new(baseUrl)
|
||||
assert(type(baseUrl) == "string")
|
||||
|
||||
local self = {
|
||||
baseUrl = baseUrl,
|
||||
serverId = nil,
|
||||
rootInstanceId = nil,
|
||||
messageCursor = -1,
|
||||
partitionRoutes = nil,
|
||||
}
|
||||
|
||||
setmetatable(self, ApiContext)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function ApiContext:onMessage(callback)
|
||||
self.onMessageCallback = callback
|
||||
end
|
||||
|
||||
function ApiContext:connect()
|
||||
local url = ("%s/api/rojo"):format(self.baseUrl)
|
||||
|
||||
return Http.get(url)
|
||||
:andThen(rejectFailedRequests)
|
||||
:andThen(function(response)
|
||||
local body = response:json()
|
||||
|
||||
if body.protocolVersion ~= Config.protocolVersion then
|
||||
local message = (
|
||||
"Found a Rojo dev server, but it's using a different protocol version, and is incompatible." ..
|
||||
"\nMake sure you have matching versions of both the Rojo plugin and server!" ..
|
||||
"\n\nYour client is version %s, with protocol version %s. It expects server version %s." ..
|
||||
"\nYour server is version %s, with protocol version %s." ..
|
||||
"\n\nGo to https://github.com/LPGhatguy/rojo for more details."
|
||||
):format(
|
||||
Version.display(Config.version), Config.protocolVersion,
|
||||
Config.expectedApiContextVersionString,
|
||||
body.serverVersion, body.protocolVersion
|
||||
)
|
||||
|
||||
return Promise.reject(message)
|
||||
end
|
||||
|
||||
if body.expectedPlaceIds ~= nil then
|
||||
local foundId = false
|
||||
|
||||
for _, id in ipairs(body.expectedPlaceIds) do
|
||||
if id == game.PlaceId then
|
||||
foundId = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not foundId then
|
||||
local idList = {}
|
||||
for _, id in ipairs(body.expectedPlaceIds) do
|
||||
table.insert(idList, "- " .. tostring(id))
|
||||
end
|
||||
|
||||
local message = (
|
||||
"Found a Rojo server, but its project is set to only be used with a specific list of places." ..
|
||||
"\nYour place ID is %s, but needs to be one of these:" ..
|
||||
"\n%s" ..
|
||||
"\n\nTo change this list, edit 'servePlaceIds' in roblox-project.json"
|
||||
):format(
|
||||
tostring(game.PlaceId),
|
||||
table.concat(idList, "\n")
|
||||
)
|
||||
|
||||
return Promise.reject(message)
|
||||
end
|
||||
end
|
||||
|
||||
self.serverId = body.serverId
|
||||
self.partitionRoutes = body.partitions
|
||||
self.rootInstanceId = body.rootInstanceId
|
||||
end)
|
||||
end
|
||||
|
||||
function ApiContext:read(ids)
|
||||
local url = ("%s/api/read/%s"):format(self.baseUrl, table.concat(ids, ","))
|
||||
|
||||
return Http.get(url)
|
||||
:andThen(rejectFailedRequests)
|
||||
:andThen(function(response)
|
||||
local body = response:json()
|
||||
|
||||
if body.serverId ~= self.serverId then
|
||||
return Promise.reject("Server changed ID")
|
||||
end
|
||||
|
||||
self.messageCursor = body.messageCursor
|
||||
|
||||
return body
|
||||
end)
|
||||
end
|
||||
|
||||
function ApiContext:retrieveMessages()
|
||||
local url = ("%s/api/subscribe/%s"):format(self.baseUrl, self.messageCursor)
|
||||
|
||||
local function sendRequest()
|
||||
return Http.get(url)
|
||||
:catch(function(err)
|
||||
if err.type == HttpError.Error.Timeout then
|
||||
return sendRequest()
|
||||
end
|
||||
|
||||
return Promise.reject(err)
|
||||
end)
|
||||
end
|
||||
|
||||
return sendRequest()
|
||||
:andThen(rejectFailedRequests)
|
||||
:andThen(function(response)
|
||||
local body = response:json()
|
||||
|
||||
if body.serverId ~= self.serverId then
|
||||
return Promise.reject("Server changed ID")
|
||||
end
|
||||
|
||||
self.messageCursor = body.messageCursor
|
||||
|
||||
return body.messages
|
||||
end)
|
||||
end
|
||||
|
||||
return ApiContext
|
||||
41
plugin/src/Assets.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
local Assets = {
|
||||
Sprites = {
|
||||
WhiteCross = {
|
||||
asset = "rbxassetid://2738712459",
|
||||
offset = Vector2.new(190, 318),
|
||||
size = Vector2.new(18, 18),
|
||||
},
|
||||
},
|
||||
Slices = {
|
||||
RoundBox = {
|
||||
asset = "rbxassetid://2773204550",
|
||||
offset = Vector2.new(0, 0),
|
||||
size = Vector2.new(32, 32),
|
||||
center = Rect.new(4, 4, 4, 4),
|
||||
},
|
||||
},
|
||||
Images = {
|
||||
Logo = "rbxassetid://2773210620",
|
||||
},
|
||||
StartSession = "",
|
||||
SessionActive = "",
|
||||
Configure = "",
|
||||
}
|
||||
|
||||
local function guardForTypos(name, map)
|
||||
setmetatable(map, {
|
||||
__index = function(_, key)
|
||||
error(("%q is not a valid member of %s"):format(tostring(key), name), 2)
|
||||
end
|
||||
})
|
||||
|
||||
for key, child in pairs(map) do
|
||||
if type(child) == "table" then
|
||||
guardForTypos(("%s.%s"):format(name, key), child)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
guardForTypos("Assets", Assets)
|
||||
|
||||
return Assets
|
||||
205
plugin/src/Components/App.lua
Normal file
@@ -0,0 +1,205 @@
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Plugin = script:FindFirstAncestor("Plugin")
|
||||
|
||||
local Assets = require(Plugin.Assets)
|
||||
local Session = require(Plugin.Session)
|
||||
local Config = require(Plugin.Config)
|
||||
local Version = require(Plugin.Version)
|
||||
local Logging = require(Plugin.Logging)
|
||||
local DevSettings = require(Plugin.DevSettings)
|
||||
local preloadAssets = require(Plugin.preloadAssets)
|
||||
|
||||
local ConnectPanel = require(Plugin.Components.ConnectPanel)
|
||||
local ConnectionActivePanel = require(Plugin.Components.ConnectionActivePanel)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local function showUpgradeMessage(lastVersion)
|
||||
local message = (
|
||||
"Rojo detected an upgrade from version %s to version %s." ..
|
||||
"\nMake sure you have also upgraded your server!" ..
|
||||
"\n\nRojo plugin version %s is intended for use with server version %s."
|
||||
):format(
|
||||
Version.display(lastVersion), Version.display(Config.version),
|
||||
Version.display(Config.version), Config.expectedServerVersionString
|
||||
)
|
||||
|
||||
Logging.info(message)
|
||||
end
|
||||
|
||||
--[[
|
||||
Check if the user is using a newer version of Rojo than last time. If they
|
||||
are, show them a reminder to make sure they check their server version.
|
||||
]]
|
||||
local function checkUpgrade(plugin)
|
||||
-- When developing Rojo, there's no use in doing version checks
|
||||
if DevSettings:isEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local lastVersion = plugin:GetSetting("LastRojoVersion")
|
||||
|
||||
if lastVersion then
|
||||
local wasUpgraded = Version.compare(Config.version, lastVersion) == 1
|
||||
|
||||
if wasUpgraded then
|
||||
showUpgradeMessage(lastVersion)
|
||||
end
|
||||
end
|
||||
|
||||
plugin:SetSetting("LastRojoVersion", Config.version)
|
||||
end
|
||||
|
||||
local SessionStatus = {
|
||||
Disconnected = "Disconnected",
|
||||
Connected = "Connected",
|
||||
ConfiguringSession = "ConfiguringSession",
|
||||
-- TODO: Error?
|
||||
}
|
||||
|
||||
setmetatable(SessionStatus, {
|
||||
__index = function(_, key)
|
||||
error(("%q is not a valid member of SessionStatus"):format(tostring(key)), 2)
|
||||
end,
|
||||
})
|
||||
|
||||
local App = Roact.Component:extend("App")
|
||||
|
||||
function App:init()
|
||||
self:setState({
|
||||
sessionStatus = SessionStatus.Disconnected,
|
||||
})
|
||||
|
||||
self.connectButton = nil
|
||||
self.currentSession = nil
|
||||
|
||||
self.displayedVersion = DevSettings:isEnabled()
|
||||
and Config.codename
|
||||
or Version.display(Config.version)
|
||||
end
|
||||
|
||||
function App:render()
|
||||
local children
|
||||
|
||||
if self.state.sessionStatus == SessionStatus.Connected then
|
||||
children = {
|
||||
ConnectionActivePanel = e(ConnectionActivePanel, {
|
||||
stopSession = function()
|
||||
Logging.trace("Disconnecting session")
|
||||
|
||||
self.currentSession:disconnect()
|
||||
self.currentSession = nil
|
||||
self:setState({
|
||||
sessionStatus = SessionStatus.Disconnected,
|
||||
})
|
||||
|
||||
Logging.trace("Session terminated by user")
|
||||
end,
|
||||
}),
|
||||
}
|
||||
elseif self.state.sessionStatus == SessionStatus.ConfiguringSession then
|
||||
children = {
|
||||
ConnectPanel = e(ConnectPanel, {
|
||||
startSession = function(address, port)
|
||||
Logging.trace("Starting new session")
|
||||
|
||||
local success, session = Session.new({
|
||||
address = address,
|
||||
port = port,
|
||||
onError = function(message)
|
||||
Logging.warn("Rojo session terminated because of an error:\n%s", tostring(message))
|
||||
self.currentSession = nil
|
||||
|
||||
self:setState({
|
||||
sessionStatus = SessionStatus.Disconnected,
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
if success then
|
||||
self.currentSession = session
|
||||
self:setState({
|
||||
sessionStatus = SessionStatus.Connected,
|
||||
})
|
||||
end
|
||||
end,
|
||||
cancel = function()
|
||||
Logging.trace("Canceling session configuration")
|
||||
|
||||
self:setState({
|
||||
sessionStatus = SessionStatus.Disconnected,
|
||||
})
|
||||
end,
|
||||
}),
|
||||
}
|
||||
end
|
||||
|
||||
return e("ScreenGui", {
|
||||
AutoLocalize = false,
|
||||
ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
|
||||
}, children)
|
||||
end
|
||||
|
||||
function App:didMount()
|
||||
Logging.trace("Rojo %s initializing", self.displayedVersion)
|
||||
|
||||
local toolbar = self.props.plugin:CreateToolbar("Rojo " .. self.displayedVersion)
|
||||
|
||||
self.connectButton = toolbar:CreateButton(
|
||||
"Connect",
|
||||
"Connect to a running Rojo session",
|
||||
Assets.StartSession)
|
||||
self.connectButton.ClickableWhenViewportHidden = false
|
||||
self.connectButton.Click:Connect(function()
|
||||
checkUpgrade(self.props.plugin)
|
||||
|
||||
if self.state.sessionStatus == SessionStatus.Connected then
|
||||
Logging.trace("Disconnecting session")
|
||||
|
||||
self.currentSession:disconnect()
|
||||
self.currentSession = nil
|
||||
self:setState({
|
||||
sessionStatus = SessionStatus.Disconnected,
|
||||
})
|
||||
|
||||
Logging.trace("Session terminated by user")
|
||||
elseif self.state.sessionStatus == SessionStatus.Disconnected then
|
||||
Logging.trace("Starting session configuration")
|
||||
|
||||
self:setState({
|
||||
sessionStatus = SessionStatus.ConfiguringSession,
|
||||
})
|
||||
elseif self.state.sessionStatus == SessionStatus.ConfiguringSession then
|
||||
Logging.trace("Canceling session configuration")
|
||||
|
||||
self:setState({
|
||||
sessionStatus = SessionStatus.Disconnected,
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
preloadAssets()
|
||||
end
|
||||
|
||||
function App:willUnmount()
|
||||
if self.currentSession ~= nil then
|
||||
self.currentSession:disconnect()
|
||||
self.currentSession = nil
|
||||
end
|
||||
end
|
||||
|
||||
function App:didUpdate()
|
||||
local connectActive = self.state.sessionStatus == SessionStatus.ConfiguringSession
|
||||
or self.state.sessionStatus == SessionStatus.Connected
|
||||
|
||||
self.connectButton:SetActive(connectActive)
|
||||
|
||||
if self.state.sessionStatus == SessionStatus.Connected then
|
||||
self.connectButton.Icon = Assets.SessionActive
|
||||
else
|
||||
self.connectButton.Icon = Assets.StartSession
|
||||
end
|
||||
end
|
||||
|
||||
return App
|
||||
261
plugin/src/Components/ConnectPanel.lua
Normal file
@@ -0,0 +1,261 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
local Plugin = Rojo.Plugin
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
|
||||
local Config = require(Plugin.Config)
|
||||
local Version = require(Plugin.Version)
|
||||
local Assets = require(Plugin.Assets)
|
||||
local Theme = require(Plugin.Theme)
|
||||
local joinBindings = require(Plugin.joinBindings)
|
||||
|
||||
local FitList = require(Plugin.Components.FitList)
|
||||
local FitText = require(Plugin.Components.FitText)
|
||||
local FormButton = require(Plugin.Components.FormButton)
|
||||
local FormTextInput = require(Plugin.Components.FormTextInput)
|
||||
|
||||
local RoundBox = Assets.Slices.RoundBox
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local ConnectPanel = Roact.Component:extend("ConnectPanel")
|
||||
|
||||
function ConnectPanel:init()
|
||||
self.footerSize, self.setFooterSize = Roact.createBinding(Vector2.new())
|
||||
self.footerVersionSize, self.setFooterVersionSize = Roact.createBinding(Vector2.new())
|
||||
|
||||
-- This is constructed in init because 'joinBindings' is a hack and we'd
|
||||
-- leak memory constructing it every render. When this kind of feature lands
|
||||
-- in Roact properly, we can do this inline in render without fear.
|
||||
self.footerRestSize = joinBindings(
|
||||
{
|
||||
self.footerSize,
|
||||
self.footerVersionSize,
|
||||
},
|
||||
function(container, other)
|
||||
return UDim2.new(0, container.X - other.X - 16, 0, 32)
|
||||
end
|
||||
)
|
||||
|
||||
self:setState({
|
||||
address = "",
|
||||
port = "",
|
||||
})
|
||||
end
|
||||
|
||||
function ConnectPanel:render()
|
||||
local startSession = self.props.startSession
|
||||
local cancel = self.props.cancel
|
||||
|
||||
return e(FitList, {
|
||||
containerKind = "ImageLabel",
|
||||
containerProps = {
|
||||
Image = RoundBox.asset,
|
||||
ImageRectOffset = RoundBox.offset,
|
||||
ImageRectSize = RoundBox.size,
|
||||
SliceCenter = RoundBox.center,
|
||||
ScaleType = Enum.ScaleType.Slice,
|
||||
BackgroundTransparency = 1,
|
||||
Position = UDim2.new(0.5, 0, 0.5, 0),
|
||||
AnchorPoint = Vector2.new(0.5, 0.5),
|
||||
},
|
||||
layoutProps = {
|
||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||
},
|
||||
}, {
|
||||
Inputs = e(FitList, {
|
||||
containerProps = {
|
||||
BackgroundTransparency = 1,
|
||||
LayoutOrder = 1,
|
||||
},
|
||||
layoutProps = {
|
||||
FillDirection = Enum.FillDirection.Horizontal,
|
||||
Padding = UDim.new(0, 8),
|
||||
},
|
||||
paddingProps = {
|
||||
PaddingTop = UDim.new(0, 20),
|
||||
PaddingBottom = UDim.new(0, 10),
|
||||
PaddingLeft = UDim.new(0, 24),
|
||||
PaddingRight = UDim.new(0, 24),
|
||||
},
|
||||
}, {
|
||||
Address = e(FitList, {
|
||||
containerProps = {
|
||||
LayoutOrder = 1,
|
||||
BackgroundTransparency = 1,
|
||||
},
|
||||
layoutProps = {
|
||||
Padding = UDim.new(0, 4),
|
||||
},
|
||||
}, {
|
||||
Label = e(FitText, {
|
||||
Kind = "TextLabel",
|
||||
LayoutOrder = 1,
|
||||
BackgroundTransparency = 1,
|
||||
TextXAlignment = Enum.TextXAlignment.Left,
|
||||
Font = Theme.TitleFont,
|
||||
TextSize = 20,
|
||||
Text = "Address",
|
||||
TextColor3 = Theme.AccentColor,
|
||||
}),
|
||||
|
||||
Input = e(FormTextInput, {
|
||||
layoutOrder = 2,
|
||||
width = UDim.new(0, 220),
|
||||
value = self.state.address,
|
||||
placeholderValue = Config.defaultHost,
|
||||
onValueChange = function(newValue)
|
||||
self:setState({
|
||||
address = newValue,
|
||||
})
|
||||
end,
|
||||
}),
|
||||
}),
|
||||
|
||||
Port = e(FitList, {
|
||||
containerProps = {
|
||||
LayoutOrder = 2,
|
||||
BackgroundTransparency = 1,
|
||||
},
|
||||
layoutProps = {
|
||||
Padding = UDim.new(0, 4),
|
||||
},
|
||||
}, {
|
||||
Label = e(FitText, {
|
||||
Kind = "TextLabel",
|
||||
LayoutOrder = 1,
|
||||
BackgroundTransparency = 1,
|
||||
TextXAlignment = Enum.TextXAlignment.Left,
|
||||
Font = Theme.TitleFont,
|
||||
TextSize = 20,
|
||||
Text = "Port",
|
||||
TextColor3 = Theme.AccentColor,
|
||||
}),
|
||||
|
||||
Input = e(FormTextInput, {
|
||||
layoutOrder = 2,
|
||||
width = UDim.new(0, 80),
|
||||
value = self.state.port,
|
||||
placeholderValue = Config.defaultPort,
|
||||
onValueChange = function(newValue)
|
||||
self:setState({
|
||||
port = newValue,
|
||||
})
|
||||
end,
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
|
||||
Buttons = e(FitList, {
|
||||
fitAxes = "Y",
|
||||
containerProps = {
|
||||
BackgroundTransparency = 1,
|
||||
LayoutOrder = 2,
|
||||
Size = UDim2.new(1, 0, 0, 0),
|
||||
},
|
||||
layoutProps = {
|
||||
FillDirection = Enum.FillDirection.Horizontal,
|
||||
HorizontalAlignment = Enum.HorizontalAlignment.Right,
|
||||
Padding = UDim.new(0, 8),
|
||||
},
|
||||
paddingProps = {
|
||||
PaddingTop = UDim.new(0, 0),
|
||||
PaddingBottom = UDim.new(0, 20),
|
||||
PaddingLeft = UDim.new(0, 24),
|
||||
PaddingRight = UDim.new(0, 24),
|
||||
},
|
||||
}, {
|
||||
e(FormButton, {
|
||||
layoutOrder = 1,
|
||||
text = "Cancel",
|
||||
onClick = function()
|
||||
if cancel ~= nil then
|
||||
cancel()
|
||||
end
|
||||
end,
|
||||
secondary = true,
|
||||
}),
|
||||
|
||||
e(FormButton, {
|
||||
layoutOrder = 2,
|
||||
text = "Connect",
|
||||
onClick = function()
|
||||
if startSession ~= nil then
|
||||
local address = self.state.address
|
||||
if address:len() == 0 then
|
||||
address = Config.defaultHost
|
||||
end
|
||||
|
||||
local port = self.state.port
|
||||
if port:len() == 0 then
|
||||
port = Config.defaultPort
|
||||
end
|
||||
|
||||
startSession(address, port)
|
||||
end
|
||||
end,
|
||||
}),
|
||||
}),
|
||||
|
||||
Footer = e(FitList, {
|
||||
fitAxes = "Y",
|
||||
containerKind = "ImageLabel",
|
||||
containerProps = {
|
||||
Image = RoundBox.asset,
|
||||
ImageRectOffset = RoundBox.offset + Vector2.new(0, RoundBox.size.Y / 2),
|
||||
ImageRectSize = RoundBox.size * Vector2.new(1, 0.5),
|
||||
SliceCenter = RoundBox.center,
|
||||
ScaleType = Enum.ScaleType.Slice,
|
||||
ImageColor3 = Theme.SecondaryColor,
|
||||
Size = UDim2.new(1, 0, 0, 0),
|
||||
LayoutOrder = 3,
|
||||
BackgroundTransparency = 1,
|
||||
|
||||
[Roact.Change.AbsoluteSize] = function(rbx)
|
||||
self.setFooterSize(rbx.AbsoluteSize)
|
||||
end,
|
||||
},
|
||||
layoutProps = {
|
||||
FillDirection = Enum.FillDirection.Horizontal,
|
||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||
VerticalAlignment = Enum.VerticalAlignment.Center,
|
||||
},
|
||||
paddingProps = {
|
||||
PaddingTop = UDim.new(0, 4),
|
||||
PaddingBottom = UDim.new(0, 4),
|
||||
PaddingLeft = UDim.new(0, 8),
|
||||
PaddingRight = UDim.new(0, 8),
|
||||
},
|
||||
}, {
|
||||
LogoContainer = e("Frame", {
|
||||
BackgroundTransparency = 1,
|
||||
|
||||
Size = self.footerRestSize,
|
||||
}, {
|
||||
Logo = e("ImageLabel", {
|
||||
Image = Assets.Images.Logo,
|
||||
Size = UDim2.new(0, 80, 0, 40),
|
||||
ScaleType = Enum.ScaleType.Fit,
|
||||
BackgroundTransparency = 1,
|
||||
Position = UDim2.new(0, 0, 1, -10),
|
||||
AnchorPoint = Vector2.new(0, 1),
|
||||
}),
|
||||
}),
|
||||
|
||||
Version = e(FitText, {
|
||||
Font = Theme.TitleFont,
|
||||
TextSize = 18,
|
||||
Text = Version.display(Config.version),
|
||||
TextXAlignment = Enum.TextXAlignment.Right,
|
||||
TextColor3 = Theme.LightTextColor,
|
||||
BackgroundTransparency = 1,
|
||||
|
||||
[Roact.Change.AbsoluteSize] = function(rbx)
|
||||
self.setFooterVersionSize(rbx.AbsoluteSize)
|
||||
end,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
end
|
||||
|
||||
return ConnectPanel
|
||||
67
plugin/src/Components/ConnectionActivePanel.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Plugin = script:FindFirstAncestor("Plugin")
|
||||
|
||||
local Theme = require(Plugin.Theme)
|
||||
local Assets = require(Plugin.Assets)
|
||||
|
||||
local FitList = require(Plugin.Components.FitList)
|
||||
local FitText = require(Plugin.Components.FitText)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local RoundBox = Assets.Slices.RoundBox
|
||||
local WhiteCross = Assets.Sprites.WhiteCross
|
||||
|
||||
local function ConnectionActivePanel(props)
|
||||
local stopSession = props.stopSession
|
||||
|
||||
return e(FitList, {
|
||||
containerKind = "ImageLabel",
|
||||
containerProps = {
|
||||
Image = RoundBox.asset,
|
||||
ImageRectOffset = RoundBox.offset + Vector2.new(0, RoundBox.size.Y / 2),
|
||||
ImageRectSize = RoundBox.size * Vector2.new(1, 0.5),
|
||||
SliceCenter = Rect.new(4, 4, 4, 4),
|
||||
ScaleType = Enum.ScaleType.Slice,
|
||||
BackgroundTransparency = 1,
|
||||
Position = UDim2.new(0.5, 0, 0, 0),
|
||||
AnchorPoint = Vector2.new(0.5, 0),
|
||||
},
|
||||
layoutProps = {
|
||||
FillDirection = Enum.FillDirection.Horizontal,
|
||||
VerticalAlignment = Enum.VerticalAlignment.Center,
|
||||
},
|
||||
}, {
|
||||
Text = e(FitText, {
|
||||
Padding = Vector2.new(12, 6),
|
||||
Font = Theme.ButtonFont,
|
||||
TextSize = 18,
|
||||
Text = "Rojo Connected",
|
||||
TextColor3 = Theme.PrimaryColor,
|
||||
BackgroundTransparency = 1,
|
||||
}),
|
||||
|
||||
CloseContainer = e("ImageButton", {
|
||||
Size = UDim2.new(0, 30, 0, 30),
|
||||
BackgroundTransparency = 1,
|
||||
|
||||
[Roact.Event.Activated] = function()
|
||||
stopSession()
|
||||
end,
|
||||
}, {
|
||||
CloseImage = e("ImageLabel", {
|
||||
Size = UDim2.new(0, 16, 0, 16),
|
||||
Position = UDim2.new(0.5, 0, 0.5, 0),
|
||||
AnchorPoint = Vector2.new(0.5, 0.5),
|
||||
Image = WhiteCross.asset,
|
||||
ImageRectOffset = WhiteCross.offset,
|
||||
ImageRectSize = WhiteCross.size,
|
||||
ImageColor3 = Theme.PrimaryColor,
|
||||
BackgroundTransparency = 1,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
end
|
||||
|
||||
return ConnectionActivePanel
|
||||
63
plugin/src/Components/FitList.lua
Normal file
@@ -0,0 +1,63 @@
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Dictionary = require(script.Parent.Parent.Dictionary)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local FitList = Roact.Component:extend("FitList")
|
||||
|
||||
function FitList:init()
|
||||
self.sizeBinding, self.setSize = Roact.createBinding(UDim2.new())
|
||||
end
|
||||
|
||||
function FitList:render()
|
||||
local containerKind = self.props.containerKind or "Frame"
|
||||
local fitAxes = self.props.fitAxes or "XY"
|
||||
local containerProps = self.props.containerProps
|
||||
local layoutProps = self.props.layoutProps
|
||||
local paddingProps = self.props.paddingProps
|
||||
|
||||
local padding
|
||||
if paddingProps ~= nil then
|
||||
padding = e("UIPadding", paddingProps)
|
||||
end
|
||||
|
||||
local children = Dictionary.merge(self.props[Roact.Children], {
|
||||
["$Layout"] = e("UIListLayout", Dictionary.merge({
|
||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||
[Roact.Change.AbsoluteContentSize] = function(instance)
|
||||
local contentSize = instance.AbsoluteContentSize
|
||||
|
||||
if paddingProps ~= nil then
|
||||
contentSize = contentSize + Vector2.new(
|
||||
paddingProps.PaddingLeft.Offset + paddingProps.PaddingRight.Offset,
|
||||
paddingProps.PaddingTop.Offset + paddingProps.PaddingBottom.Offset)
|
||||
end
|
||||
|
||||
local combinedSize
|
||||
|
||||
if fitAxes == "X" then
|
||||
combinedSize = UDim2.new(0, contentSize.X, containerProps.Size.Y.Scale, containerProps.Size.Y.Offset)
|
||||
elseif fitAxes == "Y" then
|
||||
combinedSize = UDim2.new(containerProps.Size.X.Scale, containerProps.Size.X.Offset, 0, contentSize.Y)
|
||||
elseif fitAxes == "XY" then
|
||||
combinedSize = UDim2.new(0, contentSize.X, 0, contentSize.Y)
|
||||
else
|
||||
error("Invalid fitAxes value")
|
||||
end
|
||||
|
||||
self.setSize(combinedSize)
|
||||
end,
|
||||
}, layoutProps)),
|
||||
|
||||
["$Padding"] = padding,
|
||||
})
|
||||
|
||||
local fullContainerProps = Dictionary.merge(containerProps, {
|
||||
Size = self.sizeBinding,
|
||||
})
|
||||
|
||||
return e(containerKind, fullContainerProps, children)
|
||||
end
|
||||
|
||||
return FitList
|
||||
52
plugin/src/Components/FitText.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
local TextService = game:GetService("TextService")
|
||||
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Dictionary = require(script.Parent.Parent.Dictionary)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local FitText = Roact.Component:extend("FitText")
|
||||
|
||||
function FitText:init()
|
||||
self.sizeBinding, self.setSize = Roact.createBinding(UDim2.new())
|
||||
end
|
||||
|
||||
function FitText:render()
|
||||
local kind = self.props.Kind or "TextLabel"
|
||||
|
||||
local containerProps = Dictionary.merge(self.props, {
|
||||
Kind = Dictionary.None,
|
||||
Padding = Dictionary.None,
|
||||
MinSize = Dictionary.None,
|
||||
Size = self.sizeBinding
|
||||
})
|
||||
|
||||
return e(kind, containerProps)
|
||||
end
|
||||
|
||||
function FitText:didMount()
|
||||
self:updateTextMeasurements()
|
||||
end
|
||||
|
||||
function FitText:didUpdate()
|
||||
self:updateTextMeasurements()
|
||||
end
|
||||
|
||||
function FitText:updateTextMeasurements()
|
||||
local minSize = self.props.MinSize or Vector2.new(0, 0)
|
||||
local padding = self.props.Padding or Vector2.new(0, 0)
|
||||
|
||||
local text = self.props.Text or ""
|
||||
local font = self.props.Font or Enum.Font.Legacy
|
||||
local textSize = self.props.TextSize or 12
|
||||
|
||||
local measuredText = TextService:GetTextSize(text, textSize, font, Vector2.new(9e6, 9e6))
|
||||
local totalSize = UDim2.new(
|
||||
0, math.max(minSize.X, padding.X * 2 + measuredText.X),
|
||||
0, math.max(minSize.Y, padding.Y * 2 + measuredText.Y))
|
||||
|
||||
self.setSize(totalSize)
|
||||
end
|
||||
|
||||
return FitText
|
||||
62
plugin/src/Components/FormButton.lua
Normal file
@@ -0,0 +1,62 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
local Plugin = Rojo.Plugin
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
|
||||
local Assets = require(Plugin.Assets)
|
||||
local Theme = require(Plugin.Theme)
|
||||
local FitList = require(Plugin.Components.FitList)
|
||||
local FitText = require(Plugin.Components.FitText)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local RoundBox = Assets.Slices.RoundBox
|
||||
|
||||
local function FormButton(props)
|
||||
local text = props.text
|
||||
local layoutOrder = props.layoutOrder
|
||||
local onClick = props.onClick
|
||||
|
||||
local textColor
|
||||
local backgroundColor
|
||||
|
||||
if props.secondary then
|
||||
textColor = Theme.AccentColor
|
||||
backgroundColor = Theme.SecondaryColor
|
||||
else
|
||||
textColor = Theme.SecondaryColor
|
||||
backgroundColor = Theme.AccentColor
|
||||
end
|
||||
|
||||
return e(FitList, {
|
||||
containerKind = "ImageButton",
|
||||
containerProps = {
|
||||
LayoutOrder = layoutOrder,
|
||||
BackgroundTransparency = 1,
|
||||
Image = RoundBox.asset,
|
||||
ImageRectOffset = RoundBox.offset,
|
||||
ImageRectSize = RoundBox.size,
|
||||
SliceCenter = RoundBox.center,
|
||||
ScaleType = Enum.ScaleType.Slice,
|
||||
ImageColor3 = backgroundColor,
|
||||
|
||||
[Roact.Event.Activated] = function()
|
||||
if onClick ~= nil then
|
||||
onClick()
|
||||
end
|
||||
end,
|
||||
},
|
||||
}, {
|
||||
Text = e(FitText, {
|
||||
Kind = "TextLabel",
|
||||
Text = text,
|
||||
TextSize = 18,
|
||||
TextColor3 = textColor,
|
||||
Font = Theme.ButtonFont,
|
||||
Padding = Vector2.new(16, 8),
|
||||
BackgroundTransparency = 1,
|
||||
}),
|
||||
})
|
||||
end
|
||||
|
||||
return FormButton
|
||||
80
plugin/src/Components/FormTextInput.lua
Normal file
@@ -0,0 +1,80 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
local Plugin = Rojo.Plugin
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
|
||||
local Assets = require(Plugin.Assets)
|
||||
local Theme = require(Plugin.Theme)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local RoundBox = Assets.Slices.RoundBox
|
||||
|
||||
local TEXT_SIZE = 22
|
||||
local PADDING = 8
|
||||
|
||||
local FormTextInput = Roact.Component:extend("FormTextInput")
|
||||
|
||||
function FormTextInput:init()
|
||||
self:setState({
|
||||
focused = false,
|
||||
})
|
||||
end
|
||||
|
||||
function FormTextInput:render()
|
||||
local value = self.props.value
|
||||
local placeholderValue = self.props.placeholderValue
|
||||
local onValueChange = self.props.onValueChange
|
||||
local layoutOrder = self.props.layoutOrder
|
||||
local width = self.props.width
|
||||
|
||||
local shownPlaceholder
|
||||
if self.state.focused then
|
||||
shownPlaceholder = ""
|
||||
else
|
||||
shownPlaceholder = placeholderValue
|
||||
end
|
||||
|
||||
return e("ImageLabel", {
|
||||
LayoutOrder = layoutOrder,
|
||||
Image = RoundBox.asset,
|
||||
ImageRectOffset = RoundBox.offset,
|
||||
ImageRectSize = RoundBox.size,
|
||||
ScaleType = Enum.ScaleType.Slice,
|
||||
SliceCenter = RoundBox.center,
|
||||
ImageColor3 = Theme.SecondaryColor,
|
||||
Size = UDim2.new(width.Scale, width.Offset, 0, TEXT_SIZE + PADDING * 2),
|
||||
BackgroundTransparency = 1,
|
||||
}, {
|
||||
InputInner = e("TextBox", {
|
||||
BackgroundTransparency = 1,
|
||||
Size = UDim2.new(1, -PADDING * 2, 1, -PADDING * 2),
|
||||
Position = UDim2.new(0.5, 0, 0.5, 0),
|
||||
AnchorPoint = Vector2.new(0.5, 0.5),
|
||||
Font = Theme.InputFont,
|
||||
ClearTextOnFocus = false,
|
||||
TextXAlignment = Enum.TextXAlignment.Center,
|
||||
TextSize = TEXT_SIZE,
|
||||
Text = value,
|
||||
PlaceholderText = shownPlaceholder,
|
||||
PlaceholderColor3 = Theme.AccentLightColor,
|
||||
TextColor3 = Theme.AccentColor,
|
||||
|
||||
[Roact.Change.Text] = function(rbx)
|
||||
onValueChange(rbx.Text)
|
||||
end,
|
||||
[Roact.Event.Focused] = function()
|
||||
self:setState({
|
||||
focused = true,
|
||||
})
|
||||
end,
|
||||
[Roact.Event.FocusLost] = function()
|
||||
self:setState({
|
||||
focused = false,
|
||||
})
|
||||
end,
|
||||
}),
|
||||
})
|
||||
end
|
||||
|
||||
return FormTextInput
|
||||
@@ -1,12 +1,8 @@
|
||||
return {
|
||||
pollingRate = 0.2,
|
||||
version = {0, 4, 11},
|
||||
expectedServerVersionString = "0.4.x",
|
||||
protocolVersion = 1,
|
||||
icons = {
|
||||
syncIn = "rbxassetid://1820320573",
|
||||
togglePolling = "rbxassetid://1820320064",
|
||||
testConnection = "rbxassetid://1820320989",
|
||||
},
|
||||
dev = false,
|
||||
}
|
||||
codename = "Epiphany",
|
||||
version = {0, 5, 0, "-alpha.6"},
|
||||
expectedServerVersionString = "0.5.0 or newer",
|
||||
protocolVersion = 2,
|
||||
defaultHost = "localhost",
|
||||
defaultPort = 34872,
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
return function()
|
||||
local Config = require(script.Parent.Config)
|
||||
|
||||
it("should have 'dev' disabled", function()
|
||||
expect(Config.dev).to.equal(false)
|
||||
end)
|
||||
end
|
||||
127
plugin/src/DevSettings.lua
Normal file
@@ -0,0 +1,127 @@
|
||||
local Config = require(script.Parent.Config)
|
||||
|
||||
local Environment = {
|
||||
User = "User",
|
||||
Dev = "Dev",
|
||||
Test = "Test",
|
||||
}
|
||||
|
||||
local VALUES = {
|
||||
LogLevel = {
|
||||
type = "IntValue",
|
||||
values = {
|
||||
[Environment.User] = 2,
|
||||
[Environment.Dev] = 3,
|
||||
[Environment.Test] = 3,
|
||||
},
|
||||
},
|
||||
TypecheckingEnabled = {
|
||||
type = "BoolValue",
|
||||
values = {
|
||||
[Environment.User] = false,
|
||||
[Environment.Dev] = true,
|
||||
[Environment.Test] = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local CONTAINER_NAME = "RojoDevSettings" .. Config.codename
|
||||
|
||||
local function getValueContainer()
|
||||
return game:FindFirstChild(CONTAINER_NAME)
|
||||
end
|
||||
|
||||
local valueContainer = getValueContainer()
|
||||
|
||||
local function getStoredValue(name)
|
||||
if valueContainer == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
local valueObject = valueContainer:FindFirstChild(name)
|
||||
|
||||
if valueObject == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
return valueObject.Value
|
||||
end
|
||||
|
||||
local function setStoredValue(name, kind, value)
|
||||
local object = valueContainer:FindFirstChild(name)
|
||||
|
||||
if object == nil then
|
||||
object = Instance.new(kind)
|
||||
object.Name = name
|
||||
object.Parent = valueContainer
|
||||
end
|
||||
|
||||
object.Value = value
|
||||
end
|
||||
|
||||
local function createAllValues(environment)
|
||||
assert(Environment[environment] ~= nil, "Invalid environment")
|
||||
|
||||
valueContainer = getValueContainer()
|
||||
|
||||
if valueContainer == nil then
|
||||
valueContainer = Instance.new("Folder")
|
||||
valueContainer.Name = CONTAINER_NAME
|
||||
valueContainer.Parent = game
|
||||
end
|
||||
|
||||
for name, value in pairs(VALUES) do
|
||||
setStoredValue(name, value.type, value.values[environment])
|
||||
end
|
||||
end
|
||||
|
||||
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 = {}
|
||||
|
||||
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()
|
||||
return valueContainer ~= nil
|
||||
end
|
||||
|
||||
function DevSettings:getLogLevel()
|
||||
return getValue("LogLevel")
|
||||
end
|
||||
|
||||
function DevSettings:shouldTypecheck()
|
||||
return getValue("TypecheckingEnabled")
|
||||
end
|
||||
|
||||
function _G.ROJO_DEV_CREATE()
|
||||
DevSettings:createDevSettings()
|
||||
end
|
||||
|
||||
return DevSettings
|
||||
33
plugin/src/Dictionary.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
--[[
|
||||
This is a placeholder module waiting for Cryo to become available.
|
||||
]]
|
||||
|
||||
local None = newproxy(true)
|
||||
getmetatable(None).__tostring = function()
|
||||
return "None"
|
||||
end
|
||||
|
||||
local function merge(...)
|
||||
local output = {}
|
||||
|
||||
for i = 1, select("#", ...) do
|
||||
local source = select(i, ...)
|
||||
|
||||
if source ~= nil then
|
||||
for key, value in pairs(source) do
|
||||
if value == None then
|
||||
output[key] = nil
|
||||
else
|
||||
output[key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return output
|
||||
end
|
||||
|
||||
return {
|
||||
None = None,
|
||||
merge = merge,
|
||||
}
|
||||
@@ -1,68 +1,75 @@
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local HTTP_DEBUG = false
|
||||
|
||||
local Promise = require(script.Parent.Parent.modules.Promise)
|
||||
local Promise = require(script.Parent.Parent.Promise)
|
||||
|
||||
local Logging = require(script.Parent.Logging)
|
||||
local HttpError = require(script.Parent.HttpError)
|
||||
local HttpResponse = require(script.Parent.HttpResponse)
|
||||
|
||||
local function dprint(...)
|
||||
if HTTP_DEBUG then
|
||||
print(...)
|
||||
end
|
||||
end
|
||||
local lastRequestId = 0
|
||||
|
||||
-- TODO: Factor out into separate library, especially error handling
|
||||
local Http = {}
|
||||
Http.__index = Http
|
||||
|
||||
function Http.new(baseUrl)
|
||||
assert(type(baseUrl) == "string", "Http.new needs a baseUrl!")
|
||||
function Http.get(url)
|
||||
local requestId = lastRequestId + 1
|
||||
lastRequestId = requestId
|
||||
|
||||
local http = {
|
||||
baseUrl = baseUrl
|
||||
}
|
||||
Logging.trace("GET(%d) %s", requestId, url)
|
||||
|
||||
setmetatable(http, Http)
|
||||
|
||||
return http
|
||||
end
|
||||
|
||||
function Http:get(endpoint)
|
||||
dprint("\nGET", endpoint)
|
||||
return Promise.new(function(resolve, reject)
|
||||
spawn(function()
|
||||
local ok, result = pcall(function()
|
||||
return HttpService:GetAsync(self.baseUrl .. endpoint, true)
|
||||
coroutine.wrap(function()
|
||||
local success, response = pcall(function()
|
||||
return HttpService:RequestAsync({
|
||||
Url = url,
|
||||
Method = "GET",
|
||||
})
|
||||
end)
|
||||
|
||||
if ok then
|
||||
dprint("\t", result, "\n")
|
||||
resolve(HttpResponse.new(result))
|
||||
if success then
|
||||
Logging.trace("Request %d success: status code %s", requestId, response.StatusCode)
|
||||
resolve(HttpResponse.fromRobloxResponse(response))
|
||||
else
|
||||
reject(HttpError.fromErrorString(result))
|
||||
Logging.trace("Request %d failure: %s", requestId, response)
|
||||
reject(HttpError.fromErrorString(response))
|
||||
end
|
||||
end)
|
||||
end)()
|
||||
end)
|
||||
end
|
||||
|
||||
function Http:post(endpoint, body)
|
||||
dprint("\nPOST", endpoint)
|
||||
dprint(body)
|
||||
function Http.post(url, body)
|
||||
local requestId = lastRequestId + 1
|
||||
lastRequestId = requestId
|
||||
|
||||
Logging.trace("POST(%d) %s\n%s", requestId, url, body)
|
||||
|
||||
return Promise.new(function(resolve, reject)
|
||||
spawn(function()
|
||||
local ok, result = pcall(function()
|
||||
return HttpService:PostAsync(self.baseUrl .. endpoint, body)
|
||||
coroutine.wrap(function()
|
||||
local success, response = pcall(function()
|
||||
return HttpService:RequestAsync({
|
||||
Url = url,
|
||||
Method = "POST",
|
||||
Body = body,
|
||||
})
|
||||
end)
|
||||
|
||||
if ok then
|
||||
dprint("\t", result, "\n")
|
||||
resolve(HttpResponse.new(result))
|
||||
if success then
|
||||
Logging.trace("Request %d success: status code %s", requestId, response.StatusCode)
|
||||
resolve(HttpResponse.fromRobloxResponse(response))
|
||||
else
|
||||
reject(HttpError.fromErrorString(result))
|
||||
Logging.trace("Request %d failure: %s", requestId, response)
|
||||
reject(HttpError.fromErrorString(response))
|
||||
end
|
||||
end)
|
||||
end)()
|
||||
end)
|
||||
end
|
||||
|
||||
return Http
|
||||
function Http.jsonEncode(object)
|
||||
return HttpService:JSONEncode(object)
|
||||
end
|
||||
|
||||
function Http.jsonDecode(source)
|
||||
return HttpService:JSONDecode(source)
|
||||
end
|
||||
|
||||
return Http
|
||||
@@ -1,3 +1,5 @@
|
||||
local Logging = require(script.Parent.Logging)
|
||||
|
||||
local HttpError = {}
|
||||
HttpError.__index = HttpError
|
||||
|
||||
@@ -7,14 +9,23 @@ HttpError.Error = {
|
||||
"Check your game settings, located in the 'Home' tab of Studio.",
|
||||
},
|
||||
ConnectFailed = {
|
||||
message = "Rojo plugin couldn't connect to the Rojo server.\n" ..
|
||||
"Make sure the server is running -- use 'Rojo serve' to run it!",
|
||||
message = "Couldn't connect to the Rojo server.\n" ..
|
||||
"Make sure the server is running -- use 'rojo serve' to run it!",
|
||||
},
|
||||
Timeout = {
|
||||
message = "Request timed out.",
|
||||
},
|
||||
Unknown = {
|
||||
message = "Rojo encountered an unknown error: {{message}}",
|
||||
message = "Unknown error: {{message}}",
|
||||
},
|
||||
}
|
||||
|
||||
setmetatable(HttpError.Error, {
|
||||
__index = function(_, key)
|
||||
error(("%q is not a valid member of HttpError.Error"):format(tostring(key)), 2)
|
||||
end,
|
||||
})
|
||||
|
||||
function HttpError.new(type, extraMessage)
|
||||
extraMessage = extraMessage or ""
|
||||
local message = type.message:gsub("{{message}}", extraMessage)
|
||||
@@ -36,25 +47,26 @@ end
|
||||
--[[
|
||||
This method shouldn't have to exist. Ugh.
|
||||
]]
|
||||
function HttpError.fromErrorString(err)
|
||||
err = err:lower()
|
||||
function HttpError.fromErrorString(message)
|
||||
local lower = message:lower()
|
||||
|
||||
if err:find("^http requests are not enabled") then
|
||||
if lower:find("^http requests are not enabled") then
|
||||
return HttpError.new(HttpError.Error.HttpNotEnabled)
|
||||
end
|
||||
|
||||
if err:find("^curl error") then
|
||||
if lower:find("^httperror: timedout") then
|
||||
return HttpError.new(HttpError.Error.Timeout)
|
||||
end
|
||||
|
||||
if lower:find("^httperror: connectfail") then
|
||||
return HttpError.new(HttpError.Error.ConnectFailed)
|
||||
end
|
||||
|
||||
return HttpError.new(HttpError.Error.Unknown, err)
|
||||
return HttpError.new(HttpError.Error.Unknown, message)
|
||||
end
|
||||
|
||||
function HttpError:report()
|
||||
warn(self.message)
|
||||
if self.type == HttpError.Error.HttpNotEnabled then
|
||||
game:GetService("Selection"):Set{game:GetService("HttpService")}
|
||||
end
|
||||
Logging.warn(self.message)
|
||||
end
|
||||
|
||||
return HttpError
|
||||
return HttpError
|
||||
@@ -1,20 +1,34 @@
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local stringTemplate = [[
|
||||
HttpResponse {
|
||||
code: %d
|
||||
body: %s
|
||||
}]]
|
||||
|
||||
local HttpResponse = {}
|
||||
HttpResponse.__index = HttpResponse
|
||||
|
||||
function HttpResponse.new(body)
|
||||
local response = {
|
||||
body = body,
|
||||
function HttpResponse:__tostring()
|
||||
return stringTemplate:format(self.code, self.body)
|
||||
end
|
||||
|
||||
function HttpResponse.fromRobloxResponse(response)
|
||||
local self = {
|
||||
body = response.Body,
|
||||
code = response.StatusCode,
|
||||
headers = response.Headers,
|
||||
}
|
||||
|
||||
setmetatable(response, HttpResponse)
|
||||
return setmetatable(self, HttpResponse)
|
||||
end
|
||||
|
||||
return response
|
||||
function HttpResponse:isSuccess()
|
||||
return self.code >= 200 and self.code < 300
|
||||
end
|
||||
|
||||
function HttpResponse:json()
|
||||
return HttpService:JSONDecode(self.body)
|
||||
end
|
||||
|
||||
return HttpResponse
|
||||
return HttpResponse
|
||||
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
|
||||
50
plugin/src/Logging.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
local DevSettings = require(script.Parent.DevSettings)
|
||||
|
||||
local Level = {
|
||||
Error = 0,
|
||||
Warning = 1,
|
||||
Info = 2,
|
||||
Trace = 3,
|
||||
}
|
||||
|
||||
local testLogLevel = nil
|
||||
|
||||
local function getLogLevel()
|
||||
if testLogLevel ~= nil then
|
||||
return testLogLevel
|
||||
end
|
||||
|
||||
return DevSettings:getLogLevel()
|
||||
end
|
||||
|
||||
local function addTags(tag, message)
|
||||
return tag .. message:gsub("\n", "\n" .. tag)
|
||||
end
|
||||
|
||||
local INFO_TAG = (" "):rep(15) .. "[Rojo-Info] "
|
||||
local TRACE_TAG = (" "):rep(15) .. "[Rojo-Trace] "
|
||||
local WARN_TAG = "[Rojo-Warn] "
|
||||
|
||||
local Log = {}
|
||||
|
||||
Log.Level = Level
|
||||
|
||||
function Log.trace(template, ...)
|
||||
if getLogLevel() >= Level.Trace then
|
||||
print(addTags(TRACE_TAG, string.format(template, ...)))
|
||||
end
|
||||
end
|
||||
|
||||
function Log.info(template, ...)
|
||||
if getLogLevel() >= Level.Info then
|
||||
print(addTags(INFO_TAG, string.format(template, ...)))
|
||||
end
|
||||
end
|
||||
|
||||
function Log.warn(template, ...)
|
||||
if getLogLevel() >= Level.Warning then
|
||||
warn(addTags(WARN_TAG, string.format(template, ...)))
|
||||
end
|
||||
end
|
||||
|
||||
return Log
|
||||
@@ -1,79 +0,0 @@
|
||||
if not plugin then
|
||||
return
|
||||
end
|
||||
|
||||
local Plugin = require(script.Parent.Plugin)
|
||||
local Config = require(script.Parent.Config)
|
||||
local Version = require(script.Parent.Version)
|
||||
|
||||
--[[
|
||||
Check if the user is using a newer version of Rojo than last time. If they
|
||||
are, show them a reminder to make sure they check their server version.
|
||||
]]
|
||||
local function checkUpgrade()
|
||||
-- When developing Rojo, there's no use in doing version checks
|
||||
if Config.dev then
|
||||
return
|
||||
end
|
||||
|
||||
local lastVersion = plugin:GetSetting("LastRojoVersion")
|
||||
|
||||
if lastVersion then
|
||||
local wasUpgraded = Version.compare(Config.version, lastVersion) == 1
|
||||
|
||||
if wasUpgraded then
|
||||
local message = (
|
||||
"\nRojo detected an upgrade from version %s to version %s." ..
|
||||
"\nMake sure you have also upgraded your server!" ..
|
||||
"\n\nRojo version %s is intended for use with server version %s.\n"
|
||||
):format(
|
||||
Version.display(lastVersion), Version.display(Config.version),
|
||||
Version.display(Config.version), Config.expectedServerVersionString
|
||||
)
|
||||
|
||||
print(message)
|
||||
end
|
||||
end
|
||||
|
||||
plugin:SetSetting("LastRojoVersion", Config.version)
|
||||
end
|
||||
|
||||
local function main()
|
||||
local pluginInstance = Plugin.new()
|
||||
|
||||
local displayedVersion = Config.dev and "DEV" or Version.display(Config.version)
|
||||
|
||||
local toolbar = plugin:CreateToolbar("Rojo Plugin " .. displayedVersion)
|
||||
|
||||
toolbar:CreateButton("Test Connection", "Connect to Rojo Server", Config.icons.testConnection)
|
||||
.Click:Connect(function()
|
||||
checkUpgrade()
|
||||
|
||||
pluginInstance:connect()
|
||||
:catch(function(err)
|
||||
warn(err)
|
||||
end)
|
||||
end)
|
||||
|
||||
toolbar:CreateButton("Sync In", "Sync into Roblox Studio", Config.icons.syncIn)
|
||||
.Click:Connect(function()
|
||||
checkUpgrade()
|
||||
|
||||
pluginInstance:syncIn()
|
||||
:catch(function(err)
|
||||
warn(err)
|
||||
end)
|
||||
end)
|
||||
|
||||
toolbar:CreateButton("Toggle Polling", "Poll server for changes", Config.icons.togglePolling)
|
||||
.Click:Connect(function()
|
||||
checkUpgrade()
|
||||
|
||||
pluginInstance:togglePolling()
|
||||
:catch(function(err)
|
||||
warn(err)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
main()
|
||||
@@ -1,311 +0,0 @@
|
||||
local CoreGui = game:GetService("CoreGui")
|
||||
|
||||
local Promise = require(script.Parent.Parent.modules.Promise)
|
||||
|
||||
local Config = require(script.Parent.Config)
|
||||
local Http = require(script.Parent.Http)
|
||||
local Api = require(script.Parent.Api)
|
||||
local Reconciler = require(script.Parent.Reconciler)
|
||||
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 result = {}
|
||||
|
||||
for match in source:gmatch(pattern) do
|
||||
table.insert(result, match)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
local Plugin = {}
|
||||
Plugin.__index = Plugin
|
||||
|
||||
function Plugin.new()
|
||||
local address = "localhost"
|
||||
local port = Config.dev and 8001 or 8000
|
||||
|
||||
local remote = ("http://%s:%d"):format(address, port)
|
||||
|
||||
local self = {
|
||||
_http = Http.new(remote),
|
||||
_reconciler = Reconciler.new(),
|
||||
_api = nil,
|
||||
_polling = false,
|
||||
_syncInProgress = false,
|
||||
}
|
||||
|
||||
setmetatable(self, Plugin)
|
||||
|
||||
do
|
||||
local uiName = ("Rojo %s UI"):format(Version.display(Config.version))
|
||||
|
||||
if Config.dev then
|
||||
uiName = "Rojo Dev UI"
|
||||
end
|
||||
|
||||
-- If there's an existing Rojo UI, like from a Roblox plugin upgrade
|
||||
-- that wasn't Rojo, make sure we clean it up.
|
||||
local existingUi = CoreGui:FindFirstChild(uiName)
|
||||
|
||||
if existingUi ~= nil then
|
||||
existingUi:Destroy()
|
||||
end
|
||||
|
||||
local screenGui = Instance.new("ScreenGui")
|
||||
screenGui.Name = uiName
|
||||
screenGui.Parent = CoreGui
|
||||
screenGui.DisplayOrder = -1
|
||||
screenGui.Enabled = false
|
||||
|
||||
local label = Instance.new("TextLabel")
|
||||
label.Font = Enum.Font.SourceSans
|
||||
label.TextSize = 20
|
||||
label.Text = "Rojo polling..."
|
||||
label.BackgroundColor3 = Color3.fromRGB(31, 31, 31)
|
||||
label.BackgroundTransparency = 0.5
|
||||
label.BorderSizePixel = 0
|
||||
label.TextColor3 = Color3.new(1, 1, 1)
|
||||
label.Size = UDim2.new(0, 120, 0, 28)
|
||||
label.Position = UDim2.new(0, 0, 0, 0)
|
||||
label.Parent = screenGui
|
||||
|
||||
self._label = screenGui
|
||||
|
||||
-- If our UI was destroyed, we assume it was from another instance of
|
||||
-- the Rojo plugin coming online.
|
||||
--
|
||||
-- Roblox doesn't notify plugins when they get unloaded, so this is the
|
||||
-- best trigger we have right now unless we create a dedicated event
|
||||
-- object.
|
||||
screenGui.AncestryChanged:Connect(function(_, parent)
|
||||
if parent == nil then
|
||||
warn(MESSAGE_PLUGIN_CHANGED)
|
||||
self:restart()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--[[
|
||||
Clears all state and issues a notice to the user that the plugin has
|
||||
restarted.
|
||||
]]
|
||||
function Plugin:restart()
|
||||
self:stopPolling()
|
||||
|
||||
self._reconciler:destruct()
|
||||
self._reconciler = Reconciler.new()
|
||||
|
||||
self._api = nil
|
||||
self._polling = false
|
||||
self._syncInProgress = false
|
||||
end
|
||||
|
||||
function Plugin:getApi()
|
||||
if self._api == nil then
|
||||
return Api.connect(self._http)
|
||||
:andThen(function(api)
|
||||
self._api = api
|
||||
|
||||
return api
|
||||
end, function(err)
|
||||
return Promise.reject(err)
|
||||
end)
|
||||
end
|
||||
|
||||
return Promise.resolve(self._api)
|
||||
end
|
||||
|
||||
function Plugin:connect()
|
||||
print("Rojo: Testing connection...")
|
||||
|
||||
return self:getApi()
|
||||
:andThen(function(api)
|
||||
local ok, info = api:getInfo():await()
|
||||
|
||||
if not ok then
|
||||
return Promise.reject(info)
|
||||
end
|
||||
|
||||
print("Rojo: Server found!")
|
||||
print("Rojo: Protocol version:", info.protocolVersion)
|
||||
print("Rojo: Server version:", info.serverVersion)
|
||||
end)
|
||||
:catch(function(err)
|
||||
if err == Api.Error.ServerIdMismatch then
|
||||
warn(MESSAGE_SERVER_CHANGED)
|
||||
self:restart()
|
||||
return self:connect()
|
||||
else
|
||||
return Promise.reject(err)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Plugin:togglePolling()
|
||||
if self._polling then
|
||||
return self:stopPolling()
|
||||
else
|
||||
return self:startPolling()
|
||||
end
|
||||
end
|
||||
|
||||
function Plugin:stopPolling()
|
||||
if not self._polling then
|
||||
return Promise.resolve(false)
|
||||
end
|
||||
|
||||
print("Rojo: Stopped polling server for changes.")
|
||||
|
||||
self._polling = false
|
||||
self._label.Enabled = false
|
||||
|
||||
return Promise.resolve(true)
|
||||
end
|
||||
|
||||
function Plugin:_pull(api, project, fileRoutes)
|
||||
return api:read(fileRoutes)
|
||||
:andThen(function(items)
|
||||
for index = 1, #fileRoutes do
|
||||
local fileRoute = fileRoutes[index]
|
||||
local partitionName = fileRoute[1]
|
||||
local partition = project.partitions[partitionName]
|
||||
local item = items[index]
|
||||
|
||||
local partitionTargetRbxRoute = collectMatch(partition.target, "[^.]+")
|
||||
|
||||
-- If the item route's length was 1, we need to rename the instance to
|
||||
-- line up with the partition's root object name.
|
||||
if item ~= nil and #fileRoute == 1 then
|
||||
local objectName = partition.target:match("[^.]+$")
|
||||
item.Name = objectName
|
||||
end
|
||||
|
||||
local itemRbxRoute = {}
|
||||
for _, piece in ipairs(partitionTargetRbxRoute) do
|
||||
table.insert(itemRbxRoute, piece)
|
||||
end
|
||||
|
||||
for i = 2, #fileRoute do
|
||||
table.insert(itemRbxRoute, fileRoute[i])
|
||||
end
|
||||
|
||||
self._reconciler:reconcileRoute(itemRbxRoute, item, fileRoute)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Plugin:startPolling()
|
||||
if self._polling then
|
||||
return
|
||||
end
|
||||
|
||||
print("Rojo: Starting to poll server for changes...")
|
||||
|
||||
self._polling = true
|
||||
self._label.Enabled = true
|
||||
|
||||
return self:getApi()
|
||||
:andThen(function(api)
|
||||
local infoOk, info = api:getInfo():await()
|
||||
|
||||
if not infoOk then
|
||||
return Promise.reject(info)
|
||||
end
|
||||
|
||||
local syncOk, result = self:syncIn():await()
|
||||
|
||||
if not syncOk then
|
||||
return Promise.reject(result)
|
||||
end
|
||||
|
||||
while self._polling do
|
||||
local changesOk, changes = api:getChanges():await()
|
||||
|
||||
if not changesOk then
|
||||
return Promise.reject(changes)
|
||||
end
|
||||
|
||||
if #changes > 0 then
|
||||
local routes = {}
|
||||
|
||||
for _, change in ipairs(changes) do
|
||||
table.insert(routes, change.route)
|
||||
end
|
||||
|
||||
local pullOk, pullResult = self:_pull(api, info.project, routes):await()
|
||||
|
||||
if not pullOk then
|
||||
return Promise.reject(pullResult)
|
||||
end
|
||||
end
|
||||
|
||||
wait(Config.pollingRate)
|
||||
end
|
||||
end)
|
||||
:catch(function(err)
|
||||
if err == Api.Error.ServerIdMismatch then
|
||||
warn(MESSAGE_SERVER_CHANGED)
|
||||
self:restart()
|
||||
return self:startPolling()
|
||||
else
|
||||
self:stopPolling()
|
||||
return Promise.reject(err)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function Plugin:syncIn()
|
||||
if self._syncInProgress then
|
||||
warn("Rojo: Can't sync right now, because a sync is already in progress.")
|
||||
|
||||
return Promise.resolve()
|
||||
end
|
||||
|
||||
self._syncInProgress = true
|
||||
print("Rojo: Syncing from server...")
|
||||
|
||||
return self:getApi()
|
||||
:andThen(function(api)
|
||||
local ok, info = api:getInfo():await()
|
||||
|
||||
if not ok then
|
||||
return Promise.reject(info)
|
||||
end
|
||||
|
||||
local fileRoutes = {}
|
||||
|
||||
for name in pairs(info.project.partitions) do
|
||||
table.insert(fileRoutes, {name})
|
||||
end
|
||||
|
||||
local pullSuccess, pullResult = self:_pull(api, info.project, fileRoutes):await()
|
||||
|
||||
self._syncInProgress = false
|
||||
|
||||
if not pullSuccess then
|
||||
return Promise.reject(pullResult)
|
||||
end
|
||||
|
||||
print("Rojo: Sync successful!")
|
||||
end)
|
||||
:catch(function(err)
|
||||
self._syncInProgress = false
|
||||
|
||||
if err == Api.Error.ServerIdMismatch then
|
||||
warn(MESSAGE_SERVER_CHANGED)
|
||||
self:restart()
|
||||
return self:syncIn()
|
||||
else
|
||||
return Promise.reject(err)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return Plugin
|
||||
@@ -1,246 +1,216 @@
|
||||
local RouteMap = require(script.Parent.RouteMap)
|
||||
local t = require(script.Parent.Parent.t)
|
||||
|
||||
local function classEqual(a, b)
|
||||
assert(typeof(a) == "string")
|
||||
assert(typeof(b) == "string")
|
||||
|
||||
if a == "*" or b == "*" then
|
||||
return true
|
||||
end
|
||||
|
||||
return a == b
|
||||
end
|
||||
|
||||
local function applyProperties(target, properties)
|
||||
assert(typeof(target) == "Instance")
|
||||
assert(typeof(properties) == "table")
|
||||
|
||||
for key, property in pairs(properties) do
|
||||
-- TODO: Transform property value based on property.Type
|
||||
-- Right now, we assume that 'value' is primitive!
|
||||
target[key] = property.Value
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Attempt to parent `rbx` to `parent`, doing nothing if:
|
||||
* parent is already `parent`
|
||||
* Changing parent threw an error
|
||||
]]
|
||||
local function reparent(rbx, parent)
|
||||
assert(typeof(rbx) == "Instance")
|
||||
assert(typeof(parent) == "Instance")
|
||||
|
||||
if rbx.Parent == parent then
|
||||
return
|
||||
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
|
||||
|
||||
--[[
|
||||
Attempts to match up Roblox instances and object specifiers for
|
||||
reconciliation.
|
||||
|
||||
An object is considered a match if they have the same Name and ClassName.
|
||||
|
||||
primaryChildren and secondaryChildren can each be either a list of Roblox
|
||||
instances or object specifiers. Since they share a common shape, switching
|
||||
the two around isn't problematic!
|
||||
|
||||
visited is expected to be an empty table initially. It will be filled with
|
||||
the set of children that have been visited so far.
|
||||
]]
|
||||
local function findNextChildPair(primaryChildren, secondaryChildren, visited)
|
||||
for _, primaryChild in ipairs(primaryChildren) do
|
||||
if not visited[primaryChild] then
|
||||
visited[primaryChild] = true
|
||||
|
||||
for _, secondaryChild in ipairs(secondaryChildren) do
|
||||
if classEqual(primaryChild.ClassName, secondaryChild.ClassName) and primaryChild.Name == secondaryChild.Name then
|
||||
visited[secondaryChild] = true
|
||||
|
||||
return primaryChild, secondaryChild
|
||||
end
|
||||
end
|
||||
|
||||
return primaryChild, nil
|
||||
end
|
||||
end
|
||||
|
||||
return nil, nil
|
||||
end
|
||||
local InstanceMap = require(script.Parent.InstanceMap)
|
||||
local Logging = require(script.Parent.Logging)
|
||||
local setCanonicalProperty = require(script.Parent.setCanonicalProperty)
|
||||
local rojoValueToRobloxValue = require(script.Parent.rojoValueToRobloxValue)
|
||||
local Types = require(script.Parent.Types)
|
||||
|
||||
local Reconciler = {}
|
||||
Reconciler.__index = Reconciler
|
||||
|
||||
function Reconciler.new()
|
||||
local reconciler = {
|
||||
_routeMap = RouteMap.new(),
|
||||
local self = {
|
||||
instanceMap = InstanceMap.new(),
|
||||
}
|
||||
|
||||
setmetatable(reconciler, Reconciler)
|
||||
|
||||
return reconciler
|
||||
return setmetatable(self, Reconciler)
|
||||
end
|
||||
|
||||
function Reconciler:applyUpdate(requestedIds, virtualInstancesById)
|
||||
-- This function may eventually be asynchronous; it will require calls to
|
||||
-- the server to resolve instances that don't exist yet.
|
||||
local visitedIds = {}
|
||||
|
||||
for _, id in ipairs(requestedIds) do
|
||||
self:__applyUpdatePiece(id, visitedIds, virtualInstancesById)
|
||||
end
|
||||
end
|
||||
|
||||
local reconcileSchema = Types.ifEnabled(t.tuple(
|
||||
t.map(t.string, Types.VirtualInstance),
|
||||
t.string,
|
||||
t.Instance
|
||||
))
|
||||
--[[
|
||||
A semi-smart algorithm that attempts to apply the given item's children to
|
||||
an existing Roblox object.
|
||||
Update an existing instance, including its properties and children, to match
|
||||
the given information.
|
||||
]]
|
||||
function Reconciler:_reconcileChildren(rbx, item)
|
||||
local visited = {}
|
||||
local rbxChildren = rbx:GetChildren()
|
||||
function Reconciler:reconcile(virtualInstancesById, id, instance)
|
||||
assert(reconcileSchema(virtualInstancesById, id, instance))
|
||||
|
||||
-- Reconcile any children that were added or updated
|
||||
while true do
|
||||
local itemChild, rbxChild = findNextChildPair(item.Children, rbxChildren, visited)
|
||||
local virtualInstance = virtualInstancesById[id]
|
||||
|
||||
if itemChild == nil then
|
||||
break
|
||||
end
|
||||
|
||||
local newRbxChild = self:reconcile(rbxChild, itemChild)
|
||||
|
||||
if newRbxChild ~= nil then
|
||||
newRbxChild.Parent = rbx
|
||||
end
|
||||
-- If an instance changes ClassName, we assume it's very different. That's
|
||||
-- not always the case!
|
||||
if virtualInstance.ClassName ~= instance.ClassName then
|
||||
-- TODO: Preserve existing children instead?
|
||||
local parent = instance.Parent
|
||||
self.instanceMap:destroyId(id)
|
||||
return self:__reify(virtualInstancesById, id, parent)
|
||||
end
|
||||
|
||||
-- Reconcile any children that were deleted
|
||||
while true do
|
||||
local rbxChild, itemChild = findNextChildPair(rbxChildren, item.Children, visited)
|
||||
self.instanceMap:insert(id, instance)
|
||||
|
||||
if rbxChild == nil then
|
||||
break
|
||||
end
|
||||
-- Some instances don't like being named, even if their name already matches
|
||||
setCanonicalProperty(instance, "Name", virtualInstance.Name)
|
||||
|
||||
local newRbxChild = self:reconcile(rbxChild, itemChild)
|
||||
|
||||
if newRbxChild ~= nil then
|
||||
newRbxChild.Parent = rbx
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Construct a new Roblox object from the given item.
|
||||
]]
|
||||
function Reconciler:_reify(item)
|
||||
local className = item.ClassName
|
||||
|
||||
-- "*" represents a match of any class. It reifies as a folder!
|
||||
if className == "*" then
|
||||
className = "Folder"
|
||||
for key, value in pairs(virtualInstance.Properties) do
|
||||
setCanonicalProperty(instance, key, rojoValueToRobloxValue(value))
|
||||
end
|
||||
|
||||
local rbx = Instance.new(className)
|
||||
rbx.Name = item.Name
|
||||
local existingChildren = instance:GetChildren()
|
||||
|
||||
applyProperties(rbx, item.Properties)
|
||||
|
||||
for _, child in ipairs(item.Children) do
|
||||
reparent(self:_reify(child), rbx)
|
||||
local unvisitedExistingChildren = {}
|
||||
for _, child in ipairs(existingChildren) do
|
||||
unvisitedExistingChildren[child] = true
|
||||
end
|
||||
|
||||
if item.Route ~= nil then
|
||||
self._routeMap:insert(item.Route, rbx)
|
||||
end
|
||||
for _, childId in ipairs(virtualInstance.Children) do
|
||||
local childData = virtualInstancesById[childId]
|
||||
|
||||
return rbx
|
||||
end
|
||||
local existingChildInstance
|
||||
for instance in pairs(unvisitedExistingChildren) do
|
||||
local ok, name, className = pcall(function()
|
||||
return instance.Name, instance.ClassName
|
||||
end)
|
||||
|
||||
--[[
|
||||
Clears any state that the Reconciler has, stopping it completely.
|
||||
]]
|
||||
function Reconciler:destruct()
|
||||
self._routeMap:destruct()
|
||||
end
|
||||
|
||||
--[[
|
||||
Apply the changes represented by the given item to a Roblox object that's a
|
||||
child of the given instance.
|
||||
]]
|
||||
function Reconciler:reconcile(rbx, item)
|
||||
-- Item was deleted
|
||||
if item == nil then
|
||||
if rbx ~= nil then
|
||||
self._routeMap:removeByRbx(rbx)
|
||||
rbx:Destroy()
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Item was created!
|
||||
if rbx == nil then
|
||||
return self:_reify(item)
|
||||
end
|
||||
|
||||
-- Item changed type!
|
||||
if not classEqual(rbx.ClassName, item.ClassName) then
|
||||
self._routeMap:removeByRbx(rbx)
|
||||
rbx:Destroy()
|
||||
|
||||
return self:_reify(item)
|
||||
end
|
||||
|
||||
-- It's possible that the instance we're associating with this item hasn't
|
||||
-- been inserted into the RouteMap yet.
|
||||
if item.Route ~= nil then
|
||||
self._routeMap:insert(item.Route, rbx)
|
||||
end
|
||||
|
||||
applyProperties(rbx, item.Properties)
|
||||
self:_reconcileChildren(rbx, item)
|
||||
|
||||
return rbx
|
||||
end
|
||||
|
||||
function Reconciler:reconcileRoute(rbxRoute, item, fileRoute)
|
||||
local parent
|
||||
local rbx = game
|
||||
|
||||
for i = 1, #rbxRoute do
|
||||
local piece = rbxRoute[i]
|
||||
|
||||
local child = rbx:FindFirstChild(piece)
|
||||
|
||||
-- We should get services instead of making folders here.
|
||||
if rbx == game and child == nil then
|
||||
local success
|
||||
success, child = pcall(game.GetService, game, piece)
|
||||
|
||||
-- That isn't a valid service!
|
||||
if not success then
|
||||
child = nil
|
||||
if ok then
|
||||
if name == childData.Name and className == childData.ClassName then
|
||||
existingChildInstance = instance
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- We don't want to create a folder if we're reaching our target item!
|
||||
if child == nil and i ~= #rbxRoute then
|
||||
child = Instance.new("Folder")
|
||||
child.Parent = rbx
|
||||
child.Name = piece
|
||||
if existingChildInstance ~= nil then
|
||||
unvisitedExistingChildren[existingChildInstance] = nil
|
||||
self:reconcile(virtualInstancesById, childId, existingChildInstance)
|
||||
else
|
||||
self:__reify(virtualInstancesById, childId, instance)
|
||||
end
|
||||
end
|
||||
|
||||
local shouldClearUnknown = self:__shouldClearUnknownChildren(virtualInstance)
|
||||
|
||||
for existingChildInstance in pairs(unvisitedExistingChildren) do
|
||||
local childId = self.instanceMap.fromInstances[existingChildInstance]
|
||||
|
||||
if childId == nil then
|
||||
if shouldClearUnknown then
|
||||
existingChildInstance:Destroy()
|
||||
end
|
||||
else
|
||||
self.instanceMap:destroyInstance(existingChildInstance)
|
||||
end
|
||||
end
|
||||
|
||||
-- The root instance of a project won't have a parent, like the DataModel,
|
||||
-- so we need to be careful here.
|
||||
if virtualInstance.Parent ~= nil then
|
||||
local parent = self.instanceMap.fromIds[virtualInstance.Parent]
|
||||
|
||||
if parent == nil then
|
||||
Logging.info("Instance %s wanted parent of %s", tostring(id), tostring(virtualInstance.Parent))
|
||||
error("Rojo bug: During reconciliation, an instance referred to an instance ID as parent that does not exist.")
|
||||
end
|
||||
|
||||
parent = rbx
|
||||
rbx = child
|
||||
-- Some instances, like services, don't like having their Parent
|
||||
-- property poked, even if we're setting it to the same value.
|
||||
setCanonicalProperty(instance, "Parent", parent)
|
||||
end
|
||||
|
||||
-- Let's check the route map!
|
||||
if rbx == nil then
|
||||
rbx = self._routeMap:get(fileRoute)
|
||||
end
|
||||
|
||||
rbx = self:reconcile(rbx, item)
|
||||
|
||||
reparent(rbx, parent)
|
||||
return instance
|
||||
end
|
||||
|
||||
return Reconciler
|
||||
function Reconciler:__shouldClearUnknownChildren(virtualInstance)
|
||||
if virtualInstance.Metadata ~= nil then
|
||||
return not virtualInstance.Metadata.ignoreUnknownInstances
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local reifySchema = Types.ifEnabled(t.tuple(
|
||||
t.map(t.string, Types.VirtualInstance),
|
||||
t.string,
|
||||
t.Instance
|
||||
))
|
||||
|
||||
function Reconciler:__reify(virtualInstancesById, id, parent)
|
||||
assert(reifySchema(virtualInstancesById, id, parent))
|
||||
|
||||
local virtualInstance = virtualInstancesById[id]
|
||||
|
||||
local instance = Instance.new(virtualInstance.ClassName)
|
||||
|
||||
for key, value in pairs(virtualInstance.Properties) do
|
||||
setCanonicalProperty(instance, key, rojoValueToRobloxValue(value))
|
||||
end
|
||||
|
||||
setCanonicalProperty(instance, "Name", virtualInstance.Name)
|
||||
|
||||
for _, childId in ipairs(virtualInstance.Children) do
|
||||
self:__reify(virtualInstancesById, childId, instance)
|
||||
end
|
||||
|
||||
setCanonicalProperty(instance, "Parent", parent)
|
||||
self.instanceMap:insert(id, instance)
|
||||
|
||||
return instance
|
||||
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)
|
||||
assert(applyUpdatePieceSchema(id, visitedIds, virtualInstancesById))
|
||||
|
||||
if visitedIds[id] then
|
||||
return
|
||||
end
|
||||
|
||||
visitedIds[id] = true
|
||||
|
||||
local virtualInstance = virtualInstancesById[id]
|
||||
local instance = self.instanceMap.fromIds[id]
|
||||
|
||||
-- The instance was deleted in this update
|
||||
if virtualInstance == nil then
|
||||
self.instanceMap:destroyId(id)
|
||||
return
|
||||
end
|
||||
|
||||
-- An instance we know about was updated
|
||||
if instance ~= nil then
|
||||
self:reconcile(virtualInstancesById, id, instance)
|
||||
return instance
|
||||
end
|
||||
|
||||
-- If the instance's parent already exists, we can stick it there
|
||||
local parentInstance = self.instanceMap.fromIds[virtualInstance.Parent]
|
||||
if parentInstance ~= nil then
|
||||
self:__reify(virtualInstancesById, id, parentInstance)
|
||||
return
|
||||
end
|
||||
|
||||
-- Otherwise, we can check if this response payload contained the parent and
|
||||
-- work from there instead.
|
||||
local parentData = virtualInstancesById[virtualInstance.Parent]
|
||||
if parentData ~= nil then
|
||||
if visitedIds[virtualInstance.Parent] then
|
||||
error("Rojo bug: An instance was present and marked as visited but its instance was missing")
|
||||
end
|
||||
|
||||
self:__applyUpdatePiece(virtualInstance.Parent, visitedIds, virtualInstancesById)
|
||||
return
|
||||
end
|
||||
|
||||
Logging.trace("Instance ID %s, parent ID %s", tostring(id), tostring(virtualInstance.Parent))
|
||||
error("Rojo NYI: Instances with parents that weren't mentioned in an update payload")
|
||||
end
|
||||
|
||||
return Reconciler
|
||||
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
|
||||
@@ -1,123 +0,0 @@
|
||||
--[[
|
||||
A map from Route objects (given by the server) to Roblox instances (created
|
||||
by the plugin).
|
||||
]]
|
||||
|
||||
local function hashRoute(route)
|
||||
return table.concat(route, "/")
|
||||
end
|
||||
|
||||
local RouteMap = {}
|
||||
RouteMap.__index = RouteMap
|
||||
|
||||
function RouteMap.new()
|
||||
local self = {
|
||||
_map = {},
|
||||
_reverseMap = {},
|
||||
_connectionsByRbx = {},
|
||||
}
|
||||
|
||||
setmetatable(self, RouteMap)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function RouteMap:insert(route, rbx)
|
||||
local hashed = hashRoute(route)
|
||||
|
||||
-- Make sure that each route and instance are only present in RouteMap once.
|
||||
self:removeByRoute(route)
|
||||
self:removeByRbx(rbx)
|
||||
|
||||
self._map[hashed] = rbx
|
||||
self._reverseMap[rbx] = hashed
|
||||
self._connectionsByRbx[rbx] = rbx.AncestryChanged:Connect(function(_, parent)
|
||||
if parent == nil then
|
||||
self:removeByRbx(rbx)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function RouteMap:get(route)
|
||||
return self._map[hashRoute(route)]
|
||||
end
|
||||
|
||||
function RouteMap:removeByRoute(route)
|
||||
local hashedRoute = hashRoute(route)
|
||||
local rbx = self._map[hashedRoute]
|
||||
|
||||
if rbx ~= nil then
|
||||
self:_removeInternal(rbx, hashedRoute)
|
||||
end
|
||||
end
|
||||
|
||||
function RouteMap:removeByRbx(rbx)
|
||||
local hashedRoute = self._reverseMap[rbx]
|
||||
|
||||
if hashedRoute ~= nil then
|
||||
self:_removeInternal(rbx, hashedRoute)
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Correcly removes the given Roblox Instance/Route pair from the RouteMap.
|
||||
]]
|
||||
function RouteMap:_removeInternal(rbx, hashedRoute)
|
||||
self._map[hashedRoute] = nil
|
||||
self._reverseMap[rbx] = nil
|
||||
self._connectionsByRbx[rbx]:Disconnect()
|
||||
self._connectionsByRbx[rbx] = nil
|
||||
|
||||
self:_removeRbxDescendants(rbx)
|
||||
end
|
||||
|
||||
--[[
|
||||
Ensure that there are no descendants of the given Roblox Instance still
|
||||
present in the map, guaranteeing that it has been cleaned out.
|
||||
]]
|
||||
function RouteMap:_removeRbxDescendants(parentRbx)
|
||||
for rbx in pairs(self._reverseMap) do
|
||||
if rbx:IsDescendantOf(parentRbx) then
|
||||
self:removeByRbx(rbx)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Remove all items from the map and disconnect all connections, cleaning up
|
||||
the RouteMap.
|
||||
]]
|
||||
function RouteMap:destruct()
|
||||
self._map = {}
|
||||
self._reverseMap = {}
|
||||
|
||||
for _, connection in pairs(self._connectionsByRbx) do
|
||||
connection:Disconnect()
|
||||
end
|
||||
|
||||
self._connectionsByRbx = {}
|
||||
end
|
||||
|
||||
function RouteMap:visualize()
|
||||
-- Log all of our keys so that the visualization has a stable order.
|
||||
local keys = {}
|
||||
|
||||
for key in pairs(self._map) do
|
||||
table.insert(keys, key)
|
||||
end
|
||||
|
||||
table.sort(keys)
|
||||
|
||||
local buffer = {}
|
||||
for _, key in ipairs(keys) do
|
||||
local visualized = ("- %s: %s"):format(
|
||||
key,
|
||||
self._map[key]:GetFullName()
|
||||
)
|
||||
table.insert(buffer, visualized)
|
||||
end
|
||||
|
||||
return table.concat(buffer, "\n")
|
||||
end
|
||||
|
||||
return RouteMap
|
||||
97
plugin/src/Session.lua
Normal file
@@ -0,0 +1,97 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
|
||||
local Promise = require(Rojo.Promise)
|
||||
|
||||
local ApiContext = require(script.Parent.ApiContext)
|
||||
local Reconciler = require(script.Parent.Reconciler)
|
||||
|
||||
local Session = {}
|
||||
Session.__index = Session
|
||||
|
||||
function Session.new(config)
|
||||
local remoteUrl = ("http://%s:%s"):format(config.address, config.port)
|
||||
local api = ApiContext.new(remoteUrl)
|
||||
|
||||
local self = {
|
||||
onError = config.onError,
|
||||
disconnected = false,
|
||||
reconciler = Reconciler.new(),
|
||||
api = api,
|
||||
}
|
||||
|
||||
api:connect()
|
||||
:andThen(function()
|
||||
if self.disconnected then
|
||||
return
|
||||
end
|
||||
|
||||
return api:read({api.rootInstanceId})
|
||||
end)
|
||||
:andThen(function(response)
|
||||
if self.disconnected then
|
||||
return
|
||||
end
|
||||
|
||||
self.reconciler:reconcile(response.instances, api.rootInstanceId, game)
|
||||
return self:__processMessages()
|
||||
end)
|
||||
:catch(function(message)
|
||||
self.disconnected = true
|
||||
self.onError(message)
|
||||
end)
|
||||
|
||||
return not self.disconnected, setmetatable(self, Session)
|
||||
end
|
||||
|
||||
function Session:__processMessages()
|
||||
if self.disconnected then
|
||||
return Promise.resolve()
|
||||
end
|
||||
|
||||
return self.api:retrieveMessages()
|
||||
:andThen(function(messages)
|
||||
local promise = Promise.resolve(nil)
|
||||
|
||||
for _, message in ipairs(messages) do
|
||||
promise = promise:andThen(function()
|
||||
return self:__onMessage(message)
|
||||
end)
|
||||
end
|
||||
|
||||
return promise
|
||||
end)
|
||||
:andThen(function()
|
||||
return self:__processMessages()
|
||||
end)
|
||||
end
|
||||
|
||||
function Session:__onMessage(message)
|
||||
if self.disconnected then
|
||||
return Promise.resolve()
|
||||
end
|
||||
|
||||
local requestedIds = {}
|
||||
|
||||
for _, id in ipairs(message.added) do
|
||||
table.insert(requestedIds, id)
|
||||
end
|
||||
|
||||
for _, id in ipairs(message.updated) do
|
||||
table.insert(requestedIds, id)
|
||||
end
|
||||
|
||||
for _, id in ipairs(message.removed) do
|
||||
table.insert(requestedIds, id)
|
||||
end
|
||||
|
||||
return self.api:read(requestedIds)
|
||||
:andThen(function(response)
|
||||
return self.reconciler:applyUpdate(requestedIds, response.instances)
|
||||
end)
|
||||
end
|
||||
|
||||
function Session:disconnect()
|
||||
self.disconnected = true
|
||||
end
|
||||
|
||||
return Session
|
||||
20
plugin/src/Theme.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
local Theme = {
|
||||
ButtonFont = Enum.Font.GothamSemibold,
|
||||
InputFont = Enum.Font.Code,
|
||||
TitleFont = Enum.Font.GothamBold,
|
||||
MainFont = Enum.Font.Gotham,
|
||||
|
||||
AccentColor = Color3.fromRGB(136, 0, 27),
|
||||
AccentLightColor = Color3.fromRGB(210, 145, 157),
|
||||
PrimaryColor = Color3.fromRGB(20, 20, 20),
|
||||
SecondaryColor = Color3.fromRGB(235, 235, 235),
|
||||
LightTextColor = Color3.fromRGB(140, 140, 140),
|
||||
}
|
||||
|
||||
setmetatable(Theme, {
|
||||
__index = function(_, key)
|
||||
error(("%s is not a valid member of Theme"):format(key), 2)
|
||||
end
|
||||
})
|
||||
|
||||
return Theme
|
||||
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,
|
||||
}
|
||||
@@ -34,7 +34,13 @@ function Version.compare(a, b)
|
||||
end
|
||||
|
||||
function Version.display(version)
|
||||
return table.concat(version, ".")
|
||||
local output = ("%d.%d.%d"):format(version[1], version[2], version[3])
|
||||
|
||||
if version[4] ~= nil then
|
||||
output = output .. version[4]
|
||||
end
|
||||
|
||||
return output
|
||||
end
|
||||
|
||||
return Version
|
||||
return Version
|
||||
17
plugin/src/init.server.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
if not plugin then
|
||||
return
|
||||
end
|
||||
|
||||
local Roact = require(script.Parent.Roact)
|
||||
|
||||
local App = require(script.Components.App)
|
||||
|
||||
local app = Roact.createElement(App, {
|
||||
plugin = plugin,
|
||||
})
|
||||
|
||||
Roact.mount(app, game:GetService("CoreGui"), "Rojo UI")
|
||||
|
||||
plugin.Unloading:Connect(function()
|
||||
Roact.unmount(app)
|
||||
end)
|
||||
34
plugin/src/joinBindings.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
--[[
|
||||
joinBindings is a crazy hack that allows combining multiple Roact bindings
|
||||
in the same spirit as `map`.
|
||||
|
||||
It's implemented in terms of Roact internals that will probably break at
|
||||
some point; please don't do that or use this module in your own code!
|
||||
]]
|
||||
|
||||
local Binding = require(script:FindFirstAncestor("Rojo").Roact.Binding)
|
||||
|
||||
local function evaluate(fun, bindings)
|
||||
local input = {}
|
||||
|
||||
for index, binding in ipairs(bindings) do
|
||||
input[index] = binding:getValue()
|
||||
end
|
||||
|
||||
return fun(unpack(input, 1, #bindings))
|
||||
end
|
||||
|
||||
local function joinBindings(bindings, joinFunction)
|
||||
local initialValue = evaluate(joinFunction, bindings)
|
||||
local binding, setValue = Binding.create(initialValue)
|
||||
|
||||
for _, binding in ipairs(bindings) do
|
||||
Binding.subscribe(binding, function()
|
||||
setValue(evaluate(joinFunction, bindings))
|
||||
end)
|
||||
end
|
||||
|
||||
return binding
|
||||
end
|
||||
|
||||
return joinBindings
|
||||
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
@@ -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
@@ -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
|
||||
52
plugin/src/setCanonicalProperty.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
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
|
||||
|
||||
-- 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
|
||||
19
plugin/testBootstrap.server.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
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
|
||||
5
plugin/tests/empty.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local Session = require(ReplicatedStorage.Modules.Rojo.Session)
|
||||
|
||||
Session.new()
|
||||
@@ -1,2 +0,0 @@
|
||||
local TestEZ = require(game.ReplicatedStorage.TestEZ)
|
||||
TestEZ.TestBootstrap:run(game.ReplicatedStorage.Rojo.plugin)
|
||||
6
rojo-e2e/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "rojo-e2e"
|
||||
version = "0.1.0"
|
||||
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
||||
|
||||
[dependencies]
|
||||
2
rojo-e2e/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# Rojo End-to-End
|
||||
This is a WIP test runner designed for Rojo. It will eventually start up the Rojo server and plugin and test functionality end-to-end.
|
||||
32
rojo-e2e/src/lib.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use std::{
|
||||
path::Path,
|
||||
process::Command,
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let plugin_path = Path::new("../plugin");
|
||||
let server_path = Path::new("../server");
|
||||
let tests_path = Path::new("../tests");
|
||||
|
||||
let server = Command::new("cargo")
|
||||
.args(&["run", "--", "serve", "../test-projects/empty"])
|
||||
.current_dir(server_path)
|
||||
.spawn();
|
||||
|
||||
thread::sleep(Duration::from_millis(1000));
|
||||
|
||||
// TODO: Wait for server to start responding on the right port
|
||||
|
||||
let test_client = Command::new("lua")
|
||||
.args(&["runTest.lua", "tests/empty.lua"])
|
||||
.current_dir(plugin_path)
|
||||
.spawn();
|
||||
|
||||
thread::sleep(Duration::from_millis(300));
|
||||
|
||||
// TODO: Collect output from the client for success/failure?
|
||||
|
||||
println!("Dying!");
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
[*.rs]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
2
server/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
/target/
|
||||
**/*.rs.bk
|
||||
1104
server/Cargo.lock
generated
@@ -1,22 +1,50 @@
|
||||
[package]
|
||||
name = "rojo"
|
||||
version = "0.4.11"
|
||||
version = "0.5.0-alpha.6"
|
||||
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
||||
description = "A tool to create robust Roblox projects"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/LPGhatguy/rojo"
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
server-plugins = []
|
||||
|
||||
[lib]
|
||||
name = "librojo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "rojo"
|
||||
path = "src/bin.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = "2.27.1"
|
||||
rouille = "2.1.0"
|
||||
clap = "2.27"
|
||||
csv = "1.0"
|
||||
env_logger = "0.6"
|
||||
failure = "0.1.3"
|
||||
futures = "0.1"
|
||||
hyper = "0.12"
|
||||
log = "0.4"
|
||||
maplit = "1.0.1"
|
||||
notify = "4.0"
|
||||
rbx_binary = "0.4.0"
|
||||
rbx_dom_weak = "1.2.0"
|
||||
rbx_xml = "0.5.0"
|
||||
rbx_reflection = "2.0.374"
|
||||
regex = "1.0"
|
||||
reqwest = "0.9.5"
|
||||
rlua = "0.16"
|
||||
ritz = "0.1.0"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
notify = "4.0.0"
|
||||
rand = "0.3"
|
||||
regex = "0.2"
|
||||
lazy_static = "1.0"
|
||||
uuid = { version = "0.7", features = ["v4", "serde"] }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.0"
|
||||
walkdir = "2.1"
|
||||
lazy_static = "1.2"
|
||||
pretty_assertions = "0.6.1"
|
||||
paste = "0.1"
|
||||
4
server/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Rojo Server
|
||||
This is the source to the Rojo server.
|
||||
|
||||
Documentation is WIP.
|
||||
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;
|
||||
}
|
||||