forked from rojo-rbx/rojo
Compare commits
980 Commits
v0.2.3
...
memofs-v0.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10ba74c21e | ||
|
|
6191b6371d | ||
|
|
5be4175ac3 | ||
|
|
f61f3671a6 | ||
|
|
477e0ada32 | ||
|
|
a884f693ae | ||
|
|
3107b1b21b | ||
|
|
04529de7b3 | ||
|
|
199a39208c | ||
|
|
0187da5f24 | ||
|
|
2e1c37ffff | ||
|
|
4b0189dd55 | ||
|
|
d4a39674de | ||
|
|
07c6fd3711 | ||
|
|
cf5b72aa9a | ||
|
|
cdfbebd637 | ||
|
|
e86e3316a9 | ||
|
|
bb2dcbaea0 | ||
|
|
fefc7a69cd | ||
|
|
1b24cd36e0 | ||
|
|
6322c1f46d | ||
|
|
00a29bb6be | ||
|
|
3a029caf2b | ||
|
|
57263905e7 | ||
|
|
4f46012c11 | ||
|
|
7ea9a1e3e8 | ||
|
|
c7510e12c4 | ||
|
|
89b5d9294c | ||
|
|
339e1060b7 | ||
|
|
52e1dbd846 | ||
|
|
b4963f4ff7 | ||
|
|
838e8f6bde | ||
|
|
8f21514855 | ||
|
|
44041f33e3 | ||
|
|
5d9bc4473c | ||
|
|
a3e0d42e86 | ||
|
|
4a9c1d0d1b | ||
|
|
ff47f79c62 | ||
|
|
f46a391873 | ||
|
|
99b8ada42b | ||
|
|
f2227aa7cb | ||
|
|
a9f6c20113 | ||
|
|
e261e7a2c7 | ||
|
|
ae811aafd0 | ||
|
|
cc593b465d | ||
|
|
f81e8339e3 | ||
|
|
cdc5513726 | ||
|
|
a398338c02 | ||
|
|
26e2e81188 | ||
|
|
46d7bba87d | ||
|
|
57d5610a58 | ||
|
|
1968e1fdb7 | ||
|
|
f2584cf807 | ||
|
|
dd592d1d6d | ||
|
|
cfff08cdfd | ||
|
|
e83437c193 | ||
|
|
1d900a6a3c | ||
|
|
859c7bea8a | ||
|
|
1b9e90e786 | ||
|
|
41396367ac | ||
|
|
16c9a23d55 | ||
|
|
ce338a2a72 | ||
|
|
1f7f2b22e7 | ||
|
|
47c7f63d75 | ||
|
|
8b1e85fbb4 | ||
|
|
ff4e9fb027 | ||
|
|
d15ef40988 | ||
|
|
eadfb18f74 | ||
|
|
4b89bb087a | ||
|
|
f0a602b48b | ||
|
|
fe10da9a6c | ||
|
|
948303aac8 | ||
|
|
12df80da56 | ||
|
|
a48c238ed7 | ||
|
|
da6c7b4d7a | ||
|
|
15cbbacc2f | ||
|
|
c3f6a17bae | ||
|
|
0fbeb70865 | ||
|
|
02f98a4053 | ||
|
|
d2e2a13479 | ||
|
|
f32cb592e2 | ||
|
|
72342f3118 | ||
|
|
246fd5f6c4 | ||
|
|
715022def5 | ||
|
|
78b2bafde1 | ||
|
|
2d7ebac8e6 | ||
|
|
bcffd2eb99 | ||
|
|
459bf62fab | ||
|
|
bdaa671823 | ||
|
|
463bf9b116 | ||
|
|
0c7a94c062 | ||
|
|
af866f0665 | ||
|
|
2493c70241 | ||
|
|
3c3359999c | ||
|
|
2467004dc2 | ||
|
|
3a9f438390 | ||
|
|
3126de2c37 | ||
|
|
b7d026b98e | ||
|
|
3f8b178f88 | ||
|
|
6184f4ce4f | ||
|
|
fa736697a9 | ||
|
|
2c88c700ca | ||
|
|
0b2e9ce1ad | ||
|
|
ccafdf250e | ||
|
|
57b28faa74 | ||
|
|
d0d7c58af1 | ||
|
|
339fc979f5 | ||
|
|
47614c3102 | ||
|
|
94e1501329 | ||
|
|
dfb015acc2 | ||
|
|
f1daafbf9e | ||
|
|
432e10c205 | ||
|
|
62b626a931 | ||
|
|
9a2893c6bc | ||
|
|
3a538f98ed | ||
|
|
7c71708de7 | ||
|
|
b64d97e808 | ||
|
|
428a19789d | ||
|
|
7cc4055d94 | ||
|
|
114c93fa46 | ||
|
|
07801a0283 | ||
|
|
30c8ea583b | ||
|
|
d54a5f647e | ||
|
|
457ed05174 | ||
|
|
44c94da2d8 | ||
|
|
ec614e1912 | ||
|
|
559b509a03 | ||
|
|
e2e9209655 | ||
|
|
e55b72f73f | ||
|
|
85e30cc968 | ||
|
|
51dcfbab75 | ||
|
|
7c0aa45057 | ||
|
|
a5fdc2a9cc | ||
|
|
64fd2f9cf8 | ||
|
|
a77495c562 | ||
|
|
3880708e1d | ||
|
|
cc68d57f11 | ||
|
|
56f5a61362 | ||
|
|
40540c3637 | ||
|
|
82678235ab | ||
|
|
5123d21290 | ||
|
|
b0dcf515f0 | ||
|
|
9aafccc946 | ||
|
|
ccf98d7283 | ||
|
|
1b35c98be5 | ||
|
|
db23c3d35a | ||
|
|
1c6c1298d5 | ||
|
|
b9ebed14a5 | ||
|
|
7077f0f1f3 | ||
|
|
d1887c6cd3 | ||
|
|
9278c81611 | ||
|
|
dec9ec32df | ||
|
|
1967f738a8 | ||
|
|
1031600c63 | ||
|
|
24c697bea7 | ||
|
|
83665018d4 | ||
|
|
b093626a21 | ||
|
|
f3dc78b7cd | ||
|
|
f0cd4333c3 | ||
|
|
6d38a785ed | ||
|
|
e46f9fd94f | ||
|
|
6b620ddcef | ||
|
|
e5684ad947 | ||
|
|
dfabc07044 | ||
|
|
dca88e8272 | ||
|
|
9f947ae2c5 | ||
|
|
28156bcaf2 | ||
|
|
a14aacbcf9 | ||
|
|
321e026e43 | ||
|
|
30351f7b9d | ||
|
|
2393a1a114 | ||
|
|
479476561e | ||
|
|
a02f485040 | ||
|
|
2957e8ad73 | ||
|
|
f83abe15cb | ||
|
|
709cba45ce | ||
|
|
8a9a72fd50 | ||
|
|
13cb0a27a0 | ||
|
|
fa817e3cdd | ||
|
|
3bd8549f41 | ||
|
|
4e47655b17 | ||
|
|
18533d5944 | ||
|
|
c5839c94ca | ||
|
|
ffc146ff9b | ||
|
|
7b82e3d641 | ||
|
|
ab6cedb659 | ||
|
|
e60be94be0 | ||
|
|
f830b024d5 | ||
|
|
98519da7d9 | ||
|
|
cb3211cf46 | ||
|
|
c051153a1f | ||
|
|
956d7e0918 | ||
|
|
530a7aa834 | ||
|
|
052ca52cc3 | ||
|
|
2025b8a494 | ||
|
|
238233ca81 | ||
|
|
938c8259c3 | ||
|
|
35df5f25c7 | ||
|
|
cd84fb9fc1 | ||
|
|
8bcf12e317 | ||
|
|
10ed353e0a | ||
|
|
72d88200e4 | ||
|
|
6ef832b3a9 | ||
|
|
17d91563d5 | ||
|
|
fb65693627 | ||
|
|
079fc738ad | ||
|
|
ae0f3b0b02 | ||
|
|
b2c515f2e6 | ||
|
|
6f1469a551 | ||
|
|
1d441b86d2 | ||
|
|
b72e6e54e6 | ||
|
|
1ee679395d | ||
|
|
cf62ee5ccb | ||
|
|
995685adfe | ||
|
|
f0eb955628 | ||
|
|
923f661428 | ||
|
|
b562d11994 | ||
|
|
3554112f31 | ||
|
|
7cada2608f | ||
|
|
21d4acebc3 | ||
|
|
73bbaaf0af | ||
|
|
40105515d2 | ||
|
|
79f09deecb | ||
|
|
c4a7f8675f | ||
|
|
f9a5fee364 | ||
|
|
bdd9c58cae | ||
|
|
09368e87cf | ||
|
|
46858c45b8 | ||
|
|
fe1a96f850 | ||
|
|
581449d992 | ||
|
|
15e848d4bf | ||
|
|
0dbbf44ab2 | ||
|
|
c62a5d15ad | ||
|
|
53bd02a890 | ||
|
|
099aa26ef8 | ||
|
|
2598ea3577 | ||
|
|
7be5b36494 | ||
|
|
3dff4d1061 | ||
|
|
5b7037550d | ||
|
|
b94f21402c | ||
|
|
9f5875d4bb | ||
|
|
694b6101ca | ||
|
|
1737da9c1f | ||
|
|
bcf4fea598 | ||
|
|
90e41f3ce9 | ||
|
|
5f5fb51eae | ||
|
|
95f06d56d8 | ||
|
|
1c6788ea45 | ||
|
|
457a8a5cf8 | ||
|
|
282caf10a5 | ||
|
|
b2fc6c165b | ||
|
|
0a1fa9588f | ||
|
|
5f5bfadf2b | ||
|
|
b512e707a5 | ||
|
|
3678ddfa36 | ||
|
|
ab8aa89f2a | ||
|
|
fd22482f06 | ||
|
|
e741f7b557 | ||
|
|
a70b7ee150 | ||
|
|
87227c96ed | ||
|
|
91d12aeb4f | ||
|
|
b3f132201b | ||
|
|
24b9f552eb | ||
|
|
b4a8dec68c | ||
|
|
c140823bea | ||
|
|
f166cc93cd | ||
|
|
125c9767f1 | ||
|
|
7b7c978db6 | ||
|
|
26fc097672 | ||
|
|
0f2e2406e8 | ||
|
|
061a096600 | ||
|
|
07fe963bed | ||
|
|
7a1eda98ca | ||
|
|
e8a5e44319 | ||
|
|
486319407a | ||
|
|
4f3d917c9b | ||
|
|
e2761965d5 | ||
|
|
171ab196c8 | ||
|
|
5630cea9a0 | ||
|
|
5a4189a770 | ||
|
|
2440d9fc48 | ||
|
|
bd33aebc3d | ||
|
|
a46d467b75 | ||
|
|
8c6981da0d | ||
|
|
500a9f647f | ||
|
|
71968fca0d | ||
|
|
fc6f84897f | ||
|
|
b31ad4b1f8 | ||
|
|
aababf37a8 | ||
|
|
44a42a177a | ||
|
|
e773a92e53 | ||
|
|
196d27b959 | ||
|
|
ec8861e983 | ||
|
|
9b601eb9fe | ||
|
|
c80d9cbf01 | ||
|
|
717c15256f | ||
|
|
13dafc2091 | ||
|
|
cfc3bcfa41 | ||
|
|
2e052e97c5 | ||
|
|
5d48d05287 | ||
|
|
e34ba844c5 | ||
|
|
1d84d3e440 | ||
|
|
7a7e9087e6 | ||
|
|
8481caa67c | ||
|
|
651e63a0fb | ||
|
|
88e462c4e5 | ||
|
|
8ef797d1a4 | ||
|
|
877fd1af35 | ||
|
|
fc01eecdcb | ||
|
|
e6ba6203bb | ||
|
|
6a786f18e6 | ||
|
|
57d46287d7 | ||
|
|
bb6ab74c19 | ||
|
|
3e759b3e8e | ||
|
|
47ee8d54a8 | ||
|
|
824b984a64 | ||
|
|
618185a52d | ||
|
|
8dbc6ab7d3 | ||
|
|
5eb6754b7c | ||
|
|
a914a92cea | ||
|
|
439a1a758e | ||
|
|
9383240627 | ||
|
|
ea765eb929 | ||
|
|
d5c816f24d | ||
|
|
cf5f20bbb5 | ||
|
|
27839dfd21 | ||
|
|
27517e1aee | ||
|
|
a31bfbefa7 | ||
|
|
f1729163cf | ||
|
|
6747d97d60 | ||
|
|
2fb2342fd4 | ||
|
|
0f530b7e80 | ||
|
|
78e3cf4ffb | ||
|
|
4e512b7023 | ||
|
|
ee3fed97e0 | ||
|
|
b45d4f6401 | ||
|
|
d4c28de2c4 | ||
|
|
b7d613ace6 | ||
|
|
68dbb31272 | ||
|
|
8fe1fa48b8 | ||
|
|
e5575b782c | ||
|
|
ea112dd93d | ||
|
|
056fc5e087 | ||
|
|
cacb02b7c8 | ||
|
|
c0b6ec8ccb | ||
|
|
f4c8f0a3d8 | ||
|
|
81407ffe3c | ||
|
|
6f7dbe99fe | ||
|
|
ec9afba029 | ||
|
|
6164c5d78d | ||
|
|
94dbcd5c06 | ||
|
|
4d0dee7ee8 | ||
|
|
49e10698b1 | ||
|
|
8e1536b59b | ||
|
|
aed160994a | ||
|
|
b2b3173420 | ||
|
|
f465af964a | ||
|
|
5a7d6a673a | ||
|
|
7fb9aa2115 | ||
|
|
fea303ac8b | ||
|
|
8e8291a0bd | ||
|
|
4dc175fcd2 | ||
|
|
009a99a8eb | ||
|
|
91caa67e04 | ||
|
|
53793f7dd2 | ||
|
|
32af8783ba | ||
|
|
d6f51f8eba | ||
|
|
f40b7361e8 | ||
|
|
0231e114d5 | ||
|
|
ca61a3e83f | ||
|
|
6979f5c82d | ||
|
|
7d45b45667 | ||
|
|
7575504b80 | ||
|
|
36bcb611f1 | ||
|
|
cc34c36794 | ||
|
|
b84cb93d2c | ||
|
|
08211a7740 | ||
|
|
97985dd458 | ||
|
|
edf157215c | ||
|
|
89671c71fa | ||
|
|
eeedcc50ab | ||
|
|
de0bb069aa | ||
|
|
5d53f8bfb3 | ||
|
|
d4a7de8070 | ||
|
|
3fe15641c7 | ||
|
|
08df71a7e4 | ||
|
|
77db25b4d9 | ||
|
|
62bb5a28aa | ||
|
|
f768b200d2 | ||
|
|
a5b6db74e5 | ||
|
|
cbe4467a22 | ||
|
|
8417d18eec | ||
|
|
93ae8187cd | ||
|
|
972338d86a | ||
|
|
a4a6e3b8f6 | ||
|
|
d788dd3042 | ||
|
|
974760f020 | ||
|
|
65569c4a60 | ||
|
|
39da45f0bd | ||
|
|
dc7c27e619 | ||
|
|
90661b7743 | ||
|
|
d07571ea7e | ||
|
|
fbf29e336f | ||
|
|
09a0a803a1 | ||
|
|
dd0327ba85 | ||
|
|
d900887d97 | ||
|
|
2a0efe70a5 | ||
|
|
ce09e57315 | ||
|
|
91023c5239 | ||
|
|
714fb10fac | ||
|
|
aa3e43207f | ||
|
|
e045989d39 | ||
|
|
ad5695210d | ||
|
|
4dab6e5008 | ||
|
|
522f26cf4e | ||
|
|
3eca4bc439 | ||
|
|
b374f67b52 | ||
|
|
c68277be2c | ||
|
|
bb8a3e82e6 | ||
|
|
b511d4ba53 | ||
|
|
fd997d4bda | ||
|
|
21d04a9f85 | ||
|
|
dcb5c12197 | ||
|
|
125e8766c5 | ||
|
|
7bce1f6df4 | ||
|
|
8f66fb6fef | ||
|
|
711e009e6d | ||
|
|
212fe31cb3 | ||
|
|
a3dc4fa001 | ||
|
|
ff53113358 | ||
|
|
94cbe15b54 | ||
|
|
90516e035d | ||
|
|
c77c754f6d | ||
|
|
288c52a2cd | ||
|
|
f0fa7326dd | ||
|
|
f29b0f2f26 | ||
|
|
5dcac24f99 | ||
|
|
1eb11ac377 | ||
|
|
2e89cdcfad | ||
|
|
1b0beccd3d | ||
|
|
abb5a72fc4 | ||
|
|
bf706f7586 | ||
|
|
4459663510 | ||
|
|
68a34dc28b | ||
|
|
ba1826587c | ||
|
|
2e7a8d50b0 | ||
|
|
2a4ca21050 | ||
|
|
0ed6c57c7f | ||
|
|
983d44947e | ||
|
|
5bd88dc82f | ||
|
|
51bbab803f | ||
|
|
a587ba4558 | ||
|
|
075b6cca30 | ||
|
|
4c263bbb3e | ||
|
|
420627d892 | ||
|
|
ce3a409997 | ||
|
|
0f9f1782ae | ||
|
|
d4704a02c5 | ||
|
|
9ca2ed2c93 | ||
|
|
ae12ffdefb | ||
|
|
1e13097126 | ||
|
|
9b8a6b1168 | ||
|
|
8f6dda5cd3 | ||
|
|
91780f236e | ||
|
|
f16474815c | ||
|
|
a8ff6d7e6e | ||
|
|
8395782a2e | ||
|
|
28ea625b01 | ||
|
|
efc569f6ed | ||
|
|
d377e10771 | ||
|
|
fef85877e6 | ||
|
|
19135bfaf4 | ||
|
|
5a147fccc2 | ||
|
|
20976814ba | ||
|
|
27e2612fc9 | ||
|
|
3ea432ef2d | ||
|
|
fe6acbc1e3 | ||
|
|
379b162e64 | ||
|
|
84832955dd | ||
|
|
34b99a51c3 | ||
|
|
fb5245e2af | ||
|
|
ff0a830e0c | ||
|
|
a365f071a4 | ||
|
|
f290e7b5b2 | ||
|
|
83a0ae673c | ||
|
|
7de646c290 | ||
|
|
5d681a72ac | ||
|
|
d725970e6e | ||
|
|
54b82760cd | ||
|
|
77f79fa913 | ||
|
|
6db714a2b1 | ||
|
|
913ac7c9f5 | ||
|
|
eecbfd29e7 | ||
|
|
41025225b2 | ||
|
|
07c7b28c03 | ||
|
|
3faf3d2a56 | ||
|
|
be094d5b7c | ||
|
|
459673bd59 | ||
|
|
2968b70e6b | ||
|
|
b6989a18fc | ||
|
|
4d6a504836 | ||
|
|
6c3737df68 | ||
|
|
9f382ed9bd | ||
|
|
f9e86e58d6 | ||
|
|
469f9c927f | ||
|
|
312724189b | ||
|
|
ec0a1f1ce4 | ||
|
|
ad93631ef8 | ||
|
|
3b6238ff93 | ||
|
|
5b9facee00 | ||
|
|
376f2a554a | ||
|
|
5fd0bd3db9 | ||
|
|
2deb3bbf23 | ||
|
|
01bef0c2b8 | ||
|
|
b65a8ce680 | ||
|
|
5fc4f63238 | ||
|
|
9b0e0c175b | ||
|
|
eb97e925e6 | ||
|
|
16f8975b18 | ||
|
|
5073fce2f7 | ||
|
|
cf5036eec6 | ||
|
|
20be37dd8b | ||
|
|
93349ae2dc | ||
|
|
be81de74cd | ||
|
|
88e739090d | ||
|
|
7f324f1957 | ||
|
|
4f31c9e72f | ||
|
|
c9a663ed39 | ||
|
|
105d8aeb6b | ||
|
|
6ea1211bc5 | ||
|
|
c13291a598 | ||
|
|
aaa78c618c | ||
|
|
2890c677d4 | ||
|
|
51a010de00 | ||
|
|
ca0aabd814 | ||
|
|
91d1ba1910 | ||
|
|
c7c739dc00 | ||
|
|
7a8389bf11 | ||
|
|
5f062b8ea3 | ||
|
|
b9ee14a0f9 | ||
|
|
c3baf73455 | ||
|
|
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 | ||
|
|
fb7bfa928a | ||
|
|
100d69262c | ||
|
|
5e01658846 | ||
|
|
ccec93aee8 | ||
|
|
a089d82023 | ||
|
|
82ba583fa0 | ||
|
|
1b82044d7d | ||
|
|
0d49a2e0af | ||
|
|
1343d3a2a9 | ||
|
|
a86001b85c | ||
|
|
d6dd46c467 | ||
|
|
320974074c | ||
|
|
7b824abe52 | ||
|
|
bfd33f4b8d | ||
|
|
d5a21a0513 | ||
|
|
c894b38f06 | ||
|
|
a86347ea32 | ||
|
|
b60bfc7495 | ||
|
|
4b2f27b26d | ||
|
|
f4d7dda8e3 | ||
|
|
0d6e3e66ce | ||
|
|
7e4d451765 | ||
|
|
804bbc93b7 | ||
|
|
e7fe4ac3ec | ||
|
|
40c41b4400 | ||
|
|
0936c7c97d | ||
|
|
9ac537d38f | ||
|
|
fcfd55ff76 | ||
|
|
c2495ed57f | ||
|
|
6ad763fc01 | ||
|
|
c856a3e361 | ||
|
|
aa5f0cc335 | ||
|
|
b067335bbf | ||
|
|
7d24a14004 | ||
|
|
910be640e9 | ||
|
|
3137753afa | ||
|
|
000ff351a5 | ||
|
|
533c8ddaf7 | ||
|
|
f777d1b6c6 | ||
|
|
8b17d3b7d9 | ||
|
|
6fbe1daf8e | ||
|
|
3bd191414b | ||
|
|
fd2cb3495b | ||
|
|
e9d33bdc02 | ||
|
|
c0f4b31ab3 | ||
|
|
78de30dcf2 | ||
|
|
23c59dcae7 | ||
|
|
274ba5810b | ||
|
|
3661d0daec | ||
|
|
f215df891c | ||
|
|
ce5fe00a66 | ||
|
|
2d71e3ebea | ||
|
|
187194a615 | ||
|
|
9e956e593d | ||
|
|
c2cfcc7a2c | ||
|
|
8c482f75dd | ||
|
|
29a83cb626 | ||
|
|
a563e4c381 | ||
|
|
9cee587f22 | ||
|
|
b5cc243466 | ||
|
|
73c6b5a08c | ||
|
|
1f5a686570 | ||
|
|
6fc497f95e | ||
|
|
52eea667a7 | ||
|
|
c2f7e268ff | ||
|
|
31e5c558ab | ||
|
|
7a7ac9550d | ||
|
|
4d0fdf0dfd | ||
|
|
b448e8007e | ||
|
|
bad0e67266 | ||
|
|
3dee3dd627 | ||
|
|
4772350968 | ||
|
|
eabcc0bd1d | ||
|
|
3a3af6ab10 | ||
|
|
9723622b66 | ||
|
|
3b1d647acb | ||
|
|
6fa925a402 | ||
|
|
c8f837d726 | ||
|
|
4557396564 | ||
|
|
d3d67d47e1 | ||
|
|
42107e0715 | ||
|
|
ed183e0805 | ||
|
|
116be16392 | ||
|
|
2c188738e6 | ||
|
|
ebffba9589 | ||
|
|
ab644c3dfa | ||
|
|
c6cdd8a815 | ||
|
|
d99df59d9b | ||
|
|
c5f8247543 | ||
|
|
72557c9d23 | ||
|
|
1a1b6d923f | ||
|
|
27cf2c8740 | ||
|
|
c08a598d3f | ||
|
|
1318842c36 | ||
|
|
86d7d033d7 | ||
|
|
2df1dfa1cb | ||
|
|
78a1c658d8 | ||
|
|
f52f43fe90 | ||
|
|
58b244b7e9 | ||
|
|
d8bcbee463 | ||
|
|
f00152a9ac | ||
|
|
9720c56765 | ||
|
|
13ce04abb2 | ||
|
|
ab22b55b84 | ||
|
|
73117edbe7 | ||
|
|
d7e2a3542c | ||
|
|
fe240ed577 | ||
|
|
5e98cbe68f | ||
|
|
7a372dc50c | ||
|
|
958b6660be | ||
|
|
e731811911 | ||
|
|
66144cef2f | ||
|
|
13925f5879 | ||
|
|
68ba3fee6c | ||
|
|
95581dbaa6 | ||
|
|
aaaf3ba0b9 | ||
|
|
b885cae086 | ||
|
|
0f78eb933a | ||
|
|
6ee9a48e20 | ||
|
|
f90c51e923 | ||
|
|
6472a2cbce | ||
|
|
c75cbebbf0 | ||
|
|
2e340ff78c | ||
|
|
5a20646c57 | ||
|
|
199ebda689 | ||
|
|
ae6ca6fb23 | ||
|
|
12bfcd7b66 | ||
|
|
d365bc076e | ||
|
|
67ac6b7cec | ||
|
|
01325c8c7e | ||
|
|
21e9625c36 | ||
|
|
5bf1f11190 | ||
|
|
b4e31ea35d | ||
|
|
7c6fe38346 | ||
|
|
f89d491f29 | ||
|
|
59b2401c2c | ||
|
|
b74ba141d1 | ||
|
|
b60f06aa88 | ||
|
|
f00bcc6d7e | ||
|
|
d5b41e2bd4 | ||
|
|
c9a53debc3 | ||
|
|
edd45ca02e | ||
|
|
f88cb67210 | ||
|
|
302c6cf663 | ||
|
|
7995b6eca4 | ||
|
|
fd7e737c20 | ||
|
|
68b3d56619 | ||
|
|
059ff1777b | ||
|
|
dd16cadb4c | ||
|
|
551f75f39c | ||
|
|
23ae0bc186 | ||
|
|
713a199419 | ||
|
|
4dc705ee45 | ||
|
|
fe4678fdc5 | ||
|
|
97682108aa | ||
|
|
23d4f45ac9 | ||
|
|
9fd6799f93 | ||
|
|
5898780e8e | ||
|
|
1ad20421e9 | ||
|
|
4ff9033916 | ||
|
|
37bb0d1aa9 | ||
|
|
7042680a0a |
2
.cargo/config
Normal file
2
.cargo/config
Normal file
@@ -0,0 +1,2 @@
|
||||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-Ctarget-feature=+crt-static"]
|
||||
@@ -3,19 +3,24 @@ root = true
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
|
||||
[*.lua]
|
||||
indent_style = tab
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
insert_final_newline = false
|
||||
|
||||
[*.rs]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.json]
|
||||
[*.{json,js,css}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{rs,toml}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
insert_final_newline = true
|
||||
|
||||
[*.snap]
|
||||
insert_final_newline = true
|
||||
|
||||
[*.lua]
|
||||
indent_style = tab
|
||||
36
.github/workflows/ci.yml
vendored
Normal file
36
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
rust_version: [stable, "1.40.0"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Setup Rust toolchain
|
||||
run: rustup default ${{ matrix.rust_version }}
|
||||
|
||||
- name: Build
|
||||
run: cargo build --locked --verbose
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --locked --verbose
|
||||
|
||||
- name: Rustfmt and Clippy
|
||||
run: |
|
||||
cargo fmt -- --check
|
||||
cargo clippy
|
||||
if: matrix.rust_version == 'stable'
|
||||
|
||||
- name: Build (All Features)
|
||||
run: cargo build --locked --verbose --all-features
|
||||
|
||||
- name: Run tests (All Features)
|
||||
run: cargo test --locked --verbose --all-features
|
||||
60
.github/workflows/release.yml
vendored
Normal file
60
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["*"]
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Build release binary
|
||||
run: cargo build --verbose --locked --release
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: rojo-win64
|
||||
path: target/release/rojo.exe
|
||||
|
||||
macos:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Install Rust
|
||||
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
|
||||
- name: Build release binary
|
||||
run: |
|
||||
source $HOME/.cargo/env
|
||||
cargo build --verbose --locked --release
|
||||
env:
|
||||
OPENSSL_STATIC: 1
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: rojo-macos
|
||||
path: target/release/rojo
|
||||
|
||||
linux:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Build
|
||||
run: cargo build --locked --verbose --release
|
||||
env:
|
||||
OPENSSL_STATIC: 1
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: rojo-linux
|
||||
path: target/release/rojo
|
||||
20
.gitignore
vendored
20
.gitignore
vendored
@@ -1,2 +1,18 @@
|
||||
/target/
|
||||
**/*.rs.bk
|
||||
# Rust output directory
|
||||
/target
|
||||
|
||||
# Headers for clibrojo
|
||||
/include
|
||||
|
||||
# Roblox model and place files in the root, used for debugging
|
||||
/*.rbxm
|
||||
/*.rbxmx
|
||||
/*.rbxl
|
||||
/*.rbxlx
|
||||
|
||||
# Roblox Studio holds 'lock' files on places
|
||||
*.rbxl.lock
|
||||
*.rbxlx.lock
|
||||
|
||||
# Snapshot files from the 'insta' Rust crate
|
||||
**/*.snap.new
|
||||
27
.gitmodules
vendored
27
.gitmodules
vendored
@@ -1,12 +1,15 @@
|
||||
[submodule "modules/Roact"]
|
||||
path = modules/Roact
|
||||
url = https://github.com/Roblox/Roact.git
|
||||
[submodule "modules/Rodux"]
|
||||
path = modules/Rodux
|
||||
url = https://github.com/Roblox/Rodux.git
|
||||
[submodule "modules/RoactRodux"]
|
||||
path = modules/RoactRodux
|
||||
url = https://github.com/Roblox/RoactRodux.git
|
||||
[submodule "modules/TestEZ"]
|
||||
path = modules/TestEZ
|
||||
url = https://github.com/Roblox/TestEZ.git
|
||||
[submodule "plugin/modules/roact"]
|
||||
path = plugin/modules/roact
|
||||
url = https://github.com/Roblox/roact.git
|
||||
[submodule "plugin/modules/testez"]
|
||||
path = plugin/modules/testez
|
||||
url = https://github.com/Roblox/testez.git
|
||||
[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
|
||||
[submodule "plugin/modules/rbx-dom"]
|
||||
path = plugin/modules/rbx-dom
|
||||
url = http://github.com/rojo-rbx/rbx-dom
|
||||
@@ -9,16 +9,18 @@ stds.roblox = {
|
||||
|
||||
-- Extra functions
|
||||
"tick", "warn", "spawn",
|
||||
"wait", "settings",
|
||||
"wait", "settings", "typeof",
|
||||
|
||||
-- Types
|
||||
"Vector2", "Vector3",
|
||||
"Vector2int16", "Vector3int16",
|
||||
"Color3",
|
||||
"UDim", "UDim2",
|
||||
"Rect",
|
||||
"CFrame",
|
||||
"Enum",
|
||||
"Instance",
|
||||
"DockWidgetPluginGuiInfo",
|
||||
}
|
||||
}
|
||||
|
||||
298
CHANGELOG.md
Normal file
298
CHANGELOG.md
Normal file
@@ -0,0 +1,298 @@
|
||||
# Rojo Changelog
|
||||
|
||||
## Unreleased Changes for 0.6.x
|
||||
* Added `--watch` argument to `rojo build`. ([#284](https://github.com/rojo-rbx/rojo/pull/284))
|
||||
* Added dark theme support to plugin. ([#241](https://github.com/rojo-rbx/rojo/issues/241))
|
||||
|
||||
## [0.6.0 Alpha 2](https://github.com/rojo-rbx/rojo/releases/tag/v0.6.0-alpha.2) (March 6, 2020)
|
||||
* Fixed `rojo upload` command always uploading models.
|
||||
* Removed `--kind` parameter to `rojo upload`; Rojo now automatically uploads the correct kind of asset based on your project file.
|
||||
|
||||
## [0.5.4](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.4) (February 26, 2020)
|
||||
This is a general maintenance release for the Rojo 0.5.x release series.
|
||||
|
||||
* Updated reflection database and other dependencies.
|
||||
* First stable release with binaries for macOS and Linux.
|
||||
|
||||
## [0.6.0 Alpha 1](https://github.com/rojo-rbx/rojo/releases/tag/v0.6.0-alpha.1) (January 22, 2020)
|
||||
|
||||
### General
|
||||
* Added support for nested project files. ([#95](https://github.com/rojo-rbx/rojo/issues/95))
|
||||
* Added project file hot-reloading. ([#10](https://github.com/rojo-rbx/rojo/issues/10)])
|
||||
* Fixed Rojo dropping Ref properties ([#142](https://github.com/rojo-rbx/rojo/issues/142))
|
||||
* This means that properties like `PrimaryPart` now work!
|
||||
* Improved live sync protocol to reduce round-trips and improve syncing consistency.
|
||||
* Improved support for binary model files and places.
|
||||
|
||||
### Command Line
|
||||
* Added `--verbose`/`-v` flag, which can be specified multiple times to increase verbosity.
|
||||
* Added support for automatically finding Roblox Studio's auth cookie for `rojo upload` on Windows.
|
||||
* Added support for building, serving and uploading sources that aren't Rojo projects.
|
||||
* Improved feedback from `rojo serve`.
|
||||
* Removed support for legacy `roblox-project.json` projects, deprecated in an early Rojo 0.5.0 alpha.
|
||||
* Rojo no longer traverses directories upwards looking for project files.
|
||||
* Though undocumented, Rojo 0.5.x will search for a project file contained in any ancestor folders. This feature was removed to better support other 0.6.x features.
|
||||
|
||||
### Roblox Studio Plugin
|
||||
* Added "connecting" state to improve experience when live syncing.
|
||||
* Added "error" state to show errors in a place that isn't the output panel.
|
||||
* Improved diagnostics for when the Rojo plugin cannot create an instance.
|
||||
|
||||
## [0.5.3](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.3) (October 15, 2019)
|
||||
* Fixed an issue where Rojo would throw an error when encountering recently-added instance classes.
|
||||
|
||||
## [0.5.2](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.2) (October 14, 2019)
|
||||
* Fixed an issue where `LocalizationTable` instances would have their column order randomized. ([#173](https://github.com/rojo-rbx/rojo/issues/173))
|
||||
|
||||
## [0.5.1](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.1) (October 4, 2019)
|
||||
* Fixed an issue where Rojo would drop changes if they happened too quickly ([#252](https://github.com/rojo-rbx/rojo/issues/252))
|
||||
* Improved diagnostics for when the Rojo plugin cannot create an instance.
|
||||
* Updated dependencies
|
||||
* This brings Rojo's reflection database from client release 395 to client release 404.
|
||||
|
||||
## [0.5.0](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.0) (August 27, 2019)
|
||||
* Changed `.model.json` naming, which may require projects to migrate ambiguous cases:
|
||||
* The file name now takes precedence over the `Name` field in the model, like Rojo 0.4.x.
|
||||
* The `Name` field of the top-level instance is now optional. It's recommended that you remove it from your models.
|
||||
* Rojo will emit a warning when `Name` is specified and does not match the name from the file.
|
||||
* Fixed `Rect` values being set to `0, 0, 0, 0` when synced with the Rojo plugin. ([#201](https://github.com/rojo-rbx/rojo/issues/201))
|
||||
* Fixed live-syncing of `PhysicalProperties`, `NumberSequence`, and `ColorSequence` values
|
||||
|
||||
## [0.5.0 Alpha 13](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.0-alpha.13) (August 2, 2019)
|
||||
* Bumped minimum Rust version to 1.34.0.
|
||||
* Fixed default port documentation in `rojo serve --help` ([#219](https://github.com/rojo-rbx/rojo/issues/219))
|
||||
* Fixed BrickColor support by upgrading Roblox-related dependencies
|
||||
|
||||
## [0.5.0 Alpha 12](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.0-alpha.12) (July 2, 2019)
|
||||
* Added `.meta.json` files
|
||||
* `init.meta.json` files replace `init.model.json` files from Rojo 0.4.x ([#183](https://github.com/rojo-rbx/rojo/pull/183))
|
||||
* Other `.meta.json` files allow attaching extra data to other files ([#189](https://github.com/rojo-rbx/rojo/pull/189))
|
||||
* Added support for infinite and NaN values in types like `Vector2` when building models and places.
|
||||
* These types aren't supported for live-syncing yet due to limitations around JSON encoding.
|
||||
* Added support for using `SharedString` values when building XML models and places.
|
||||
* Added support for live-syncing `CollectionService` tags.
|
||||
* Added a warning when building binary place files, since they're still experimental and have bugs.
|
||||
* Added a warning when trying to use Rojo 0.5.x with a Rojo 0.4.x-only project.
|
||||
* Added a warning when a Rojo project contains keys that start with `$`, which are reserved names. ([#191](https://github.com/rojo-rbx/rojo/issues/191))
|
||||
* Rojo now throws an error if unknown keys are found most files.
|
||||
* Added an icon to the plugin's toolbar button
|
||||
* Changed the plugin to use a docking widget for all UI.
|
||||
* Changed the plugin to ignore unknown properties when live-syncing.
|
||||
* Rojo's approach to this problem might change later, like with a strict model mode ([#190](https://github.com/rojo-rbx/rojo/issues/190)) or another approach.
|
||||
* Upgraded to reflection database from client release 388.
|
||||
* Updated Rojo's branding to shift the color palette to make it work better on dark backgrounds
|
||||
|
||||
## [0.5.0 Alpha 11](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.0-alpha.11) (May 29, 2019)
|
||||
* Added support for implicit property values in JSON model files ([#154](https://github.com/rojo-rbx/rojo/pull/154))
|
||||
* `Content` propertyes can now be specified in projects and model files as regular string literals.
|
||||
* Added support for `BrickColor` properties.
|
||||
* Added support for properties added in client release 384, like `Lighting.Technology` being set to `"ShadowMap"`.
|
||||
* Improved performance when working with XML models and places
|
||||
* Fixed serializing empty `Content` properties as XML
|
||||
* Fixed serializing infinite and NaN floating point properties in XML
|
||||
* Improved compatibility with XML models
|
||||
* Plugin should now be able to live-sync more properties, and ignore ones it can't, like `Lighting.Technology`.
|
||||
|
||||
## 0.5.0 Alpha 10
|
||||
* This release was a dud due to [issue #176](https://github.com/rojo-rbx/rojo/issues/176) and was rolled back.
|
||||
|
||||
## [0.5.0 Alpha 9](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.0-alpha.9) (April 4, 2019)
|
||||
* Changed `rojo build` to use buffered I/O, which can make it up to 2x faster in some cases.
|
||||
* Building [*Road Not Taken*](https://github.com/rojo-rbx/roads) to an `rbxlx` file dropped from 150ms to 70ms on my machine
|
||||
* Fixed `LocalizationTable` instances being made from `csv` files incorrectly interpreting empty rows and columns. ([#149](https://github.com/rojo-rbx/rojo/pull/149))
|
||||
* Fixed CSV files with entries that parse as numbers causing Rojo to panic. ([#152](https://github.com/rojo-rbx/rojo/pull/152))
|
||||
* Improved error messages when malformed CSV files are found in a Rojo project.
|
||||
|
||||
## [0.5.0 Alpha 8](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.0-alpha.8) (March 29, 2019)
|
||||
* Added support for a bunch of new types when dealing with XML model/place files:
|
||||
* `ColorSequence`
|
||||
* `Float64`
|
||||
* `Int64`
|
||||
* `NumberRange`
|
||||
* `NumberSequence`
|
||||
* `PhysicalProperties`
|
||||
* `Ray`
|
||||
* `Rect`
|
||||
* `Ref`
|
||||
* Improved server instance ordering behavior when files are added during a live session ([#135](https://github.com/rojo-rbx/rojo/pull/135))
|
||||
* Fixed error being thrown when trying to unload the Rojo plugin.
|
||||
* Added partial fix for [issue #141](https://github.com/rojo-rbx/rojo/issues/141) for `Lighting.Technology`, which should restore live sync functionality for the default project file.
|
||||
|
||||
## [0.5.0 Alpha 6](https://github.com/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/rojo/pull/130))
|
||||
* Made error messages from invalid and missing files more user-friendly
|
||||
|
||||
## [0.5.0 Alpha 4](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.0-alpha.4) (February 8, 2019)
|
||||
* Added support for nested partitions ([#102](https://github.com/rojo-rbx/rojo/issues/102))
|
||||
* Added support for 'transmuting' partitions ([#112](https://github.com/rojo-rbx/rojo/issues/112))
|
||||
* Added support for aliasing filesystem paths ([#105](https://github.com/rojo-rbx/rojo/issues/105))
|
||||
* Changed Windows builds to statically link the CRT ([#89](https://github.com/rojo-rbx/rojo/issues/89))
|
||||
|
||||
## [0.5.0 Alpha 3](https://github.com/rojo-rbx/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/rojo-rbx/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/rojo-rbx/rojo/pull/119))
|
||||
|
||||
## [0.5.0 Alpha 2](https://github.com/rojo-rbx/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/rojo-rbx/rojo/issues/110))
|
||||
|
||||
## [0.5.0 Alpha 1](https://github.com/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/rojo/releases/tag/v0.4.12) (June 21, 2018)
|
||||
* Fixed obscure assertion failure when renaming or deleting files ([#78](https://github.com/rojo-rbx/rojo/issues/78))
|
||||
* Added a `PluginAction` for the sync in command, which should help with some automation scripts ([#80](https://github.com/rojo-rbx/rojo/pull/80))
|
||||
|
||||
## [0.4.11](https://github.com/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/rojo/pull/72))
|
||||
* JSON models are no longer as strict -- `Children` and `Properties` are now optional.
|
||||
|
||||
## [0.4.8](https://github.com/rojo-rbx/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/rojo-rbx/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/rojo-rbx/rojo/pull/70))
|
||||
* Server will now issue a warning if no partitions are specified in `rojo serve` ([#40](https://github.com/rojo-rbx/rojo/issues/40))
|
||||
|
||||
## [0.4.6](https://github.com/rojo-rbx/rojo/releases/tag/v0.4.6) (May 21, 2018)
|
||||
* Rojo handles being restarted by Roblox Studio more gracefully ([#67](https://github.com/rojo-rbx/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/rojo-rbx/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/rojo-rbx/rojo/issues/63))
|
||||
* Fixed multiple sync operations occuring at the same time. ([#61](https://github.com/rojo-rbx/rojo/issues/61))
|
||||
* Partitions targeting files directly now work as expected. ([#57](https://github.com/rojo-rbx/rojo/issues/57))
|
||||
|
||||
## [0.4.4](https://github.com/rojo-rbx/rojo/releases/tag/v0.4.4) (April 7, 2018)
|
||||
* Fix small regression introduced in 0.4.3
|
||||
|
||||
## [0.4.3](https://github.com/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/rojo/issues/46))
|
||||
|
||||
## [0.3.2](https://github.com/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/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/rojo-rbx/rojo/releases/tag/v0.2.1) (December 1, 2017)
|
||||
* Plugin only release
|
||||
* Changes default port to 8000
|
||||
|
||||
## [0.2.0](https://github.com/rojo-rbx/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/rojo-rbx/rojo/releases/tag/v0.1.0) (November 29, 2017)
|
||||
* Initial release, functionally very similar to [rbxfs](https://github.com/rojo-rbx/rbxfs)
|
||||
24
CHANGES.md
24
CHANGES.md
@@ -1,24 +0,0 @@
|
||||
# Rojo Change Log
|
||||
|
||||
## Current Master
|
||||
* *No changes*
|
||||
|
||||
## 0.2.3
|
||||
* 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
|
||||
* Plugin only release
|
||||
* Fixed broken reconciliation behavior with `init` files
|
||||
|
||||
## 0.2.1
|
||||
* Plugin only release
|
||||
* Changes default port to 8000
|
||||
|
||||
## 0.2.0
|
||||
* Support for `init.lua` like rbxfs and rbxpacker
|
||||
* More robust syncing with a new reconciler
|
||||
|
||||
## 0.1.0
|
||||
* Initial release, functionally very similar to [rbxfs](https://github.com/LPGhatguy/rbxfs)
|
||||
55
CONTRIBUTING.md
Normal file
55
CONTRIBUTING.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Contributing to the Rojo Project
|
||||
Rojo is a big project and can always use more help! This guide covers all repositories underneath the [rojo-rbx organization on GitHub](https://github.com/rojo-rbx).
|
||||
|
||||
Some of the repositories covered are:
|
||||
|
||||
* https://github.com/rojo-rbx/rojo
|
||||
* https://github.com/rojo-rbx/rbx-dom
|
||||
* https://github.com/rojo-rbx/vscode-rojo
|
||||
* https://github.com/rojo-rbx/rbxlx-to-rojo
|
||||
|
||||
## Code
|
||||
Code contributions are welcome for features and bugs that have been reported in the project's bug tracker. We want to make sure that no one wastes their time, so be sure to talk with maintainers about what changes would be accepted before doing any work!
|
||||
|
||||
You'll want these tools to work on Rojo:
|
||||
|
||||
* Latest stable Rust compiler
|
||||
* Latest stable [Rojo](https://github.com/rojo-rbx/rojo)
|
||||
* Latest stable [Remodel](https://github.com/rojo-rbx/remodel)
|
||||
* Latest stable [run-in-roblox](https://github.com/rojo-rbx/run-in-roblox)
|
||||
|
||||
## Documentation
|
||||
Documentation impacts way more people than the individual lines of code we write.
|
||||
|
||||
If you find any problems in documentation, including typos, bad grammar, misleading phrasing, or missing content, feel free to file issues and pull requests to fix them.
|
||||
|
||||
## Bug Reports and Feature Requests
|
||||
Most of the tools around Rojo try to be clear when an issue is a bug. Even if they aren't, sometimes things don't work quite right.
|
||||
|
||||
Sometimes there's something that Rojo doesn't do that it probably should.
|
||||
|
||||
Please file issues and we'll try to help figure out what the best way forward is.
|
||||
|
||||
## Pushing a Rojo Release
|
||||
The Rojo release process is pretty manual right now. If you need to do it, here's how:
|
||||
|
||||
1. Bump server version in [`server/Cargo.toml`](server/Cargo.toml)
|
||||
2. Bump plugin version in [`plugin/src/Config.lua`](plugin/src/Config.lua)
|
||||
3. Run `cargo test` to update `Cargo.lock` and double-check tests
|
||||
4. Update [`CHANGELOG.md`](CHANGELOG.md)
|
||||
5. Commit!
|
||||
* `git add . && git commit -m "Release vX.Y.Z"`
|
||||
6. Tag the commit with the version from `Cargo.toml` prepended with a v, like `v0.4.13`
|
||||
7. Build Windows release build of CLI
|
||||
* `cargo build --release`
|
||||
7. Publish the CLI
|
||||
* `cargo publish`
|
||||
8. Build and upload the plugin
|
||||
* `rojo build plugin -o Rojo.rbxm`
|
||||
* Upload `Rojo.rbxm` to Roblox.com, keep it for later
|
||||
9. Push commits and tags
|
||||
* `git push && git push --tags`
|
||||
10. Copy GitHub release content from previous release
|
||||
* Update the leading text with a summary about the release
|
||||
* Paste the changelog notes (as-is!) from [`CHANGELOG.md`](CHANGELOG.md)
|
||||
* Write a small summary of each major feature
|
||||
2968
Cargo.lock
generated
2968
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
100
Cargo.toml
100
Cargo.toml
@@ -1,20 +1,100 @@
|
||||
[package]
|
||||
name = "rojo"
|
||||
version = "0.2.0"
|
||||
version = "0.6.0-alpha.2"
|
||||
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
||||
description = "A tool to create robust Roblox projects"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/LPGhatguy/rojo"
|
||||
description = "Enables professional-grade development tools for Roblox developers"
|
||||
license = "MPL-2.0"
|
||||
homepage = "https://rojo.space"
|
||||
documentation = "https://rojo.space/docs"
|
||||
repository = "https://github.com/rojo-rbx/rojo"
|
||||
readme = "README.md"
|
||||
edition = "2018"
|
||||
|
||||
exclude = [
|
||||
"/plugin/**",
|
||||
"/test-projects/**",
|
||||
]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
# Turn on support for specifying glob ignore path rules in the project format.
|
||||
unstable_glob_ignore_paths = []
|
||||
|
||||
# Turn on the server half of Rojo's unstable two-way sync feature.
|
||||
unstable_two_way_sync = []
|
||||
|
||||
# Enable this feature to live-reload assets from the web UI.
|
||||
dev_live_assets = []
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"rojo-test",
|
||||
"rojo-insta-ext",
|
||||
"clibrojo",
|
||||
"memofs",
|
||||
]
|
||||
|
||||
default-members = [
|
||||
".",
|
||||
"rojo-test",
|
||||
"rojo-insta-ext",
|
||||
"memofs",
|
||||
]
|
||||
|
||||
[lib]
|
||||
name = "librojo"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "rojo"
|
||||
path = "src/bin.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "build"
|
||||
harness = false
|
||||
|
||||
[dependencies]
|
||||
clap = "2.27.1"
|
||||
rouille = "1.0"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
crossbeam-channel = "0.4.0"
|
||||
csv = "1.1.1"
|
||||
env_logger = "0.7.1"
|
||||
futures = "0.1.29"
|
||||
globset = "0.4.4"
|
||||
humantime = "1.3.0"
|
||||
hyper = "0.12.35"
|
||||
jod-thread = "0.1.0"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.8"
|
||||
maplit = "1.0.1"
|
||||
notify = "4.0.14"
|
||||
rbx_binary = "0.5.0"
|
||||
rbx_dom_weak = "1.10.1"
|
||||
rbx_reflection = "3.3.408"
|
||||
rbx_xml = "0.11.3"
|
||||
regex = "1.3.1"
|
||||
reqwest = "0.9.20"
|
||||
ritz = "0.1.0"
|
||||
rlua = "0.17.0"
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
serde_json = "1.0"
|
||||
notify = "4.0.0"
|
||||
rand = "0.3"
|
||||
snafu = "0.6.0"
|
||||
structopt = "0.3.5"
|
||||
termcolor = "1.0.5"
|
||||
tokio = "0.1.22"
|
||||
uuid = { version = "0.8.1", features = ["v4", "serde"] }
|
||||
memofs = { path = "memofs" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winreg = "0.6.2"
|
||||
|
||||
[dev-dependencies]
|
||||
rojo-insta-ext = { path = "rojo-insta-ext" }
|
||||
|
||||
criterion = "0.3"
|
||||
insta = { version = "0.13.1", features = ["redactions"] }
|
||||
lazy_static = "1.2"
|
||||
paste = "0.1"
|
||||
pretty_assertions = "0.6.1"
|
||||
serde_yaml = "0.8.9"
|
||||
tempfile = "3.0"
|
||||
walkdir = "2.1"
|
||||
|
||||
373
LICENSE.txt
Normal file
373
LICENSE.txt
Normal file
@@ -0,0 +1,373 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
||||
160
README.md
160
README.md
@@ -1,141 +1,55 @@
|
||||
<h1 align="center">Rojo</h1>
|
||||
<div align="center">
|
||||
<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>
|
||||
<a href="https://rojo.space">
|
||||
<img src="assets/logo-512.png" alt="Rojo" height="217" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div> </div>
|
||||
|
||||
Rojo is a flexible multi-tool designed for creating robust Roblox projects. It's in early development, but is still useful for many projects.
|
||||
<div align="center">
|
||||
<a href="https://github.com/rojo-rbx/rojo/actions">
|
||||
<img src="https://github.com/rojo-rbx/rojo/workflows/CI/badge.svg" alt="Actions status" />
|
||||
</a>
|
||||
<a href="https://crates.io/crates/rojo">
|
||||
<img src="https://img.shields.io/crates/v/rojo.svg?label=latest%20release" alt="Latest server version" />
|
||||
</a>
|
||||
<a href="https://rojo.space/docs/0.5.x">
|
||||
<img src="https://img.shields.io/badge/docs-0.5.x-brightgreen.svg" alt="Rojo 0.5.x Documentation" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
It's designed for power users who want to use the **best tools available** for building games, libraries, and plugins.
|
||||
<hr />
|
||||
|
||||
**Rojo** is a tool designed to enable Roblox developers to use professional-grade software engineering tools.
|
||||
|
||||
With Rojo, it's possible to use industry-leading tools like **Visual Studio Code** and **Git**.
|
||||
|
||||
Rojo is designed for power users who want to use the best tools available for building games, libraries, and plugins.
|
||||
|
||||
## Features
|
||||
Rojo enables:
|
||||
|
||||
Rojo has a number of desirable features *right now*:
|
||||
|
||||
* Work on scripts from the filesystem, in your favorite editor
|
||||
* Version your place, library, or plugin using Git or another VCS
|
||||
* Working on scripts and models from the filesystem, in your favorite editor
|
||||
* Versioning your game, library, or plugin using Git or another VCS
|
||||
* Streaming `rbxmx` and `rbxm` models into your game in real time
|
||||
* Packaging and deploying your project to Roblox.com from the command line
|
||||
|
||||
Soon, Rojo will be able to:
|
||||
|
||||
* Sync Roblox objects (including models) bi-directionally between the filesystem and Roblox Studio
|
||||
* Create installation scripts for libraries to be used in standalone places
|
||||
* Similar to [rbxpacker](https://github.com/LPGhatguy/rbxpacker), another one of my projects
|
||||
* Add strongly-versioned dependencies to your project
|
||||
* Automatically convert your existing game to work with Rojo
|
||||
* Sync instances from Roblox Studio to the filesystem
|
||||
* Automatically manage your assets on Roblox.com, like images and sounds
|
||||
* Import custom instances like MoonScript code
|
||||
|
||||
## Installation
|
||||
Rojo has two components:
|
||||
* The command line tool, written in Rust
|
||||
* The [Roblox Studio plugin](https://www.roblox.com/library/1211549683/Rojo-v0-0-0), written in Lua
|
||||
## [Documentation](https://rojo.space/docs)
|
||||
Documentation is hosted in the [rojo.space repository](https://github.com/rojo-rbx/rojo.space).
|
||||
|
||||
To install the command line tool, there are two options:
|
||||
* Cargo, if you have Rust installed
|
||||
* Use `cargo install rojo` -- Rojo will be available with the `rojo` command
|
||||
* Download a pre-built Windows binary from [the GitHub releases page](https://github.com/LPGhatguy/rojo/releases)
|
||||
## Contributing
|
||||
Check out our [contribution guide](CONTRIBUTING.md) for detailed instructions for helping work on Rojo!
|
||||
|
||||
## Usage
|
||||
For more help, use `rojo help`.
|
||||
Pull requests are welcome!
|
||||
|
||||
### New Project
|
||||
Just create a new folder and tell Rojo to initialize it!
|
||||
|
||||
```sh
|
||||
mkdir my-new-project
|
||||
cd my-new-project
|
||||
|
||||
rojo init
|
||||
```
|
||||
|
||||
Rojo will create an empty project in the directory.
|
||||
|
||||
The default project looks like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "my-new-project",
|
||||
"servePort": 8000,
|
||||
"partitions": {}
|
||||
}
|
||||
```
|
||||
|
||||
### Start Dev Server
|
||||
To create a server that allows the Rojo Dev Plugin to access your project, use:
|
||||
|
||||
```sh
|
||||
rojo serve
|
||||
```
|
||||
|
||||
The tool will tell you whether it found an existing project. You should then be able to connect and use the project from within Roblox Studio!
|
||||
|
||||
### Migrating an Existing Roblox Project
|
||||
**Coming soon!**
|
||||
|
||||
### Syncing into Roblox
|
||||
In order to sync code into Roblox, you'll need to add one or more "partitions" to your configuration. A partition tells Rojo how to map directories to Roblox objects.
|
||||
|
||||
Each entry in the partitions table has a unique name, a filesystem path, and the full name of the Roblox object to sync into.
|
||||
|
||||
For example, if you want to map your `src` directory to an object named `My Cool Game` in `ReplicatedStorage`, you could use this configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "rojo",
|
||||
"servePort": 8000,
|
||||
"partitions": {
|
||||
"game": {
|
||||
"path": "src",
|
||||
"target": "ReplicatedStorage.My Cool Game"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `path` parameter is relative to the project file.
|
||||
|
||||
The `target` starts at `game` and crawls down the tree. If any objects don't exist along the way, they'll be created as `Folder` instances.
|
||||
|
||||
Run `rojo serve` in the directory containing this project, then press the "Sync In" or "Toggle Polling" buttons in the Roblox Studio plugin to move code into your game.
|
||||
|
||||
### Sync Details
|
||||
The structure of files and folders on the filesystem are preserved when syncing into game.
|
||||
|
||||
Creation of Roblox instances follows a simple set of rules. The first rule that matches the file name is chosen:
|
||||
|
||||
| File Name | Instance Type | Notes |
|
||||
| -------------- | -------------- | ----------------------------------------- |
|
||||
| `*.server.lua` | `Script` | `Source` will contain the file's contents |
|
||||
| `*.client.lua` | `LocalScript` | `Source` will contain the file's contents |
|
||||
| `*.lua` | `ModuleScript` | `Source` will contain the file's contents |
|
||||
| `*` | `StringValue` | `Value` will contain the file's contents |
|
||||
|
||||
Any folders on the filesystem will turn into `Folder` objects unless they contain a file named `init.lua`, `init.server.lua`, or `init.client.lua`. Following the convention of Lua, those objects will instead be whatever the `init` file would turn into.
|
||||
|
||||
For example, this file tree:
|
||||
|
||||
* my-game
|
||||
* init.client.lua
|
||||
* foo.lua
|
||||
|
||||
Will turn into this tree in Roblox:
|
||||
|
||||
* `my-game` (`LocalScript` with source from `my-game/init.client.lua`)
|
||||
* `foo` (`ModuleScript` with source from `my-game/foo.lua`)
|
||||
|
||||
## Inspiration
|
||||
There are lots of other tools that sync scripts into Roblox, or otherwise work to improve the development flow outside of Roblox Studio.
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
Rojo supports Rust 1.40.0 and newer. The minimum supported version of Rust is based on the latest versions of the dependencies that Rojo has.
|
||||
|
||||
## License
|
||||
Rojo is available under the terms of the MIT license. See [LICENSE.md](LICENSE.md) 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/icon-32.png
Normal file
BIN
assets/icon-32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 975 B |
181
assets/index.css
Normal file
181
assets/index.css
Normal file
@@ -0,0 +1,181 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
text-decoration: inherit;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
box-sizing: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
font-family: sans-serif;
|
||||
font-size: 18px;
|
||||
text-decoration: none;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width:100%;
|
||||
max-height:100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.path-list > li {
|
||||
margin-left: 1.2em;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.root {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0.5rem auto;
|
||||
width: 100%;
|
||||
max-width: 50rem;
|
||||
background-color: #efefef;
|
||||
border: 1px solid #666;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.header {
|
||||
flex: 0 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #666;
|
||||
}
|
||||
|
||||
.main {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.main-logo {
|
||||
flex: 0 0 10rem;
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
.stats {
|
||||
flex: 0 0 20rem;
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
.stat {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.stat-name {
|
||||
display: inline;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.main-section:not(:last-of-type) {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 1.8rem;
|
||||
}
|
||||
|
||||
.button-list {
|
||||
flex: 0 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-around;
|
||||
margin: -1rem;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: inline-block;
|
||||
border: 1px solid #666;
|
||||
padding: 0.3em 1em;
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
.instance {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.instance-title {
|
||||
font-size: 1.2rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.expandable-section {
|
||||
margin: 0.25rem 0.5rem;
|
||||
}
|
||||
|
||||
.expandable-items {
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.expandable-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.expandable-label > label {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.expandable-input ~ .expandable-label .expandable-visualizer {
|
||||
font-family: monospace;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
align-content: center;
|
||||
text-align: center;
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
font-size: 2rem;
|
||||
margin: 0 0.5rem;
|
||||
transition: transform 100ms ease-in-out;
|
||||
transform-origin: 60% 60%;
|
||||
}
|
||||
|
||||
.expandable-visualizer::before {
|
||||
content: "›";
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.expandable-input:checked ~ .expandable-label {
|
||||
border-bottom: 1px solid #bbb;
|
||||
}
|
||||
|
||||
.expandable-input:checked ~ .expandable-label .expandable-visualizer {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.expandable-input:not(:checked) ~ .expandable-items {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.vfs-entry {
|
||||
}
|
||||
|
||||
.vfs-entry-name {
|
||||
position: relative;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.vfs-entry-children .vfs-entry-name::before {
|
||||
content: "";
|
||||
width: 0.6em;
|
||||
height: 1px;
|
||||
background-color: #999;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: -0.8em;
|
||||
}
|
||||
|
||||
.vfs-entry-note {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.vfs-entry-children {
|
||||
padding-left: 0.8em;
|
||||
margin-left: 0.2em;
|
||||
border-left: 1px solid #999;
|
||||
}
|
||||
BIN
assets/logo-512.png
Normal file
BIN
assets/logo-512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
66
assets/place.project.json
Normal file
66
assets/place.project.json
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "[placeholder]",
|
||||
"tree": {
|
||||
"$className": "DataModel",
|
||||
"HttpService": {
|
||||
"$className": "HttpService",
|
||||
"$properties": {
|
||||
"HttpEnabled": true
|
||||
}
|
||||
},
|
||||
"Lighting": {
|
||||
"$className": "Lighting",
|
||||
"$properties": {
|
||||
"Ambient": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"Brightness": 2,
|
||||
"GlobalShadows": true,
|
||||
"Outlines": false,
|
||||
"Technology": "Voxel"
|
||||
}
|
||||
},
|
||||
"ReplicatedStorage": {
|
||||
"$className": "ReplicatedStorage",
|
||||
"Source": {
|
||||
"$path": "src"
|
||||
}
|
||||
},
|
||||
"SoundService": {
|
||||
"$className": "SoundService",
|
||||
"$properties": {
|
||||
"RespectFilteringEnabled": true
|
||||
}
|
||||
},
|
||||
"Workspace": {
|
||||
"$className": "Workspace",
|
||||
"$properties": {
|
||||
"FilteringEnabled": true
|
||||
},
|
||||
"Baseplate": {
|
||||
"$className": "Part",
|
||||
"$properties": {
|
||||
"Anchored": true,
|
||||
"Color": [
|
||||
0.38823,
|
||||
0.37254,
|
||||
0.38823
|
||||
],
|
||||
"Locked": true,
|
||||
"Position": [
|
||||
0,
|
||||
-10,
|
||||
0
|
||||
],
|
||||
"Size": [
|
||||
512,
|
||||
20,
|
||||
512
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
assets/round-rect-4px-radius.png
Normal file
BIN
assets/round-rect-4px-radius.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 175 B |
BIN
assets/test-folder.rbxm
Normal file
BIN
assets/test-folder.rbxm
Normal file
Binary file not shown.
42
benches/build.rs
Normal file
42
benches/build.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
use std::path::Path;
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
|
||||
use tempfile::{tempdir, TempDir};
|
||||
|
||||
use librojo::cli::{build, BuildCommand};
|
||||
|
||||
pub fn benchmark_small_place(c: &mut Criterion) {
|
||||
bench_build_place(c, "Small Place", "test-projects/benchmark_small_place")
|
||||
}
|
||||
|
||||
criterion_group!(benches, benchmark_small_place);
|
||||
criterion_main!(benches);
|
||||
|
||||
fn bench_build_place(c: &mut Criterion, name: &str, path: &str) {
|
||||
let mut group = c.benchmark_group(name);
|
||||
|
||||
// 'rojo build' generally takes a fair bit of time to execute.
|
||||
group.sample_size(10);
|
||||
group.bench_function("build", |b| {
|
||||
b.iter_batched(
|
||||
|| place_setup(path),
|
||||
|(_dir, options)| build(options).unwrap(),
|
||||
BatchSize::SmallInput,
|
||||
)
|
||||
});
|
||||
|
||||
group.finish();
|
||||
}
|
||||
|
||||
fn place_setup<P: AsRef<Path>>(input_path: P) -> (TempDir, BuildCommand) {
|
||||
let dir = tempdir().unwrap();
|
||||
let input = input_path.as_ref().to_path_buf();
|
||||
let output = dir.path().join("output.rbxlx");
|
||||
|
||||
let options = BuildCommand {
|
||||
project: input,
|
||||
output,
|
||||
};
|
||||
|
||||
(dir, options)
|
||||
}
|
||||
5
bin/dev-plugin.sh
Executable file
5
bin/dev-plugin.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
watchexec -c -w plugin "sh -c './bin/install-dev-plugin.sh'"
|
||||
13
bin/install-dev-plugin.sh
Executable file
13
bin/install-dev-plugin.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
DIR="$( mktemp -d )"
|
||||
PLUGIN_FILE="$DIR/Rojo.rbxm"
|
||||
TESTEZ_FILE="$DIR/TestEZ.rbxm"
|
||||
|
||||
rojo build plugin -o "$PLUGIN_FILE"
|
||||
rojo build plugin/testez.project.json -o "$TESTEZ_FILE"
|
||||
remodel bin/mark-plugin-as-dev.lua "$PLUGIN_FILE" "$TESTEZ_FILE" 2>/dev/null
|
||||
|
||||
cp "$PLUGIN_FILE" "$LOCALAPPDATA/Roblox/Plugins/Rojo.rbxm"
|
||||
5
bin/install-release-plugin.sh
Executable file
5
bin/install-release-plugin.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
rojo build plugin -o "$LOCALAPPDATA/Roblox/Plugins/Rojo.rbxm"
|
||||
12
bin/mark-plugin-as-dev.lua
Normal file
12
bin/mark-plugin-as-dev.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local pluginPath, testezPath = ...
|
||||
|
||||
local plugin = remodel.readModelFile(pluginPath)[1]
|
||||
local testez = remodel.readModelFile(testezPath)[1]
|
||||
|
||||
local marker = Instance.new("Folder")
|
||||
marker.Name = "ROJO_DEV_BUILD"
|
||||
marker.Parent = plugin
|
||||
|
||||
testez.Parent = plugin
|
||||
|
||||
remodel.writeModelFile(plugin, pluginPath)
|
||||
8
bin/put-plugin-in-test-place.lua
Normal file
8
bin/put-plugin-in-test-place.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
local pluginPath, placePath = ...
|
||||
|
||||
local plugin = remodel.readModelFile(pluginPath)[1]
|
||||
local place = remodel.readPlaceFile(placePath)
|
||||
|
||||
plugin.Parent = place:GetService("ReplicatedStorage")
|
||||
|
||||
remodel.writePlaceFile(place, placePath)
|
||||
6
bin/run-all-tests.sh
Executable file
6
bin/run-all-tests.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
./bin/run-cli-tests.sh
|
||||
./bin/run-plugin-tests.sh
|
||||
9
bin/run-cli-tests.sh
Executable file
9
bin/run-cli-tests.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cargo test --all --locked
|
||||
cargo fmt -- --check
|
||||
|
||||
touch src/lib.rs # Nudge Rust source to make Clippy actually check things
|
||||
cargo clippy
|
||||
16
bin/run-plugin-tests.sh
Executable file
16
bin/run-plugin-tests.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
DIR="$( mktemp -d )"
|
||||
PLUGIN_FILE="$DIR/Rojo.rbxmx"
|
||||
PLACE_FILE="$DIR/RojoTestPlace.rbxlx"
|
||||
|
||||
rojo build plugin -o "$PLUGIN_FILE"
|
||||
rojo build plugin/place.project.json -o "$PLACE_FILE"
|
||||
|
||||
remodel bin/put-plugin-in-test-place.lua "$PLUGIN_FILE" "$PLACE_FILE"
|
||||
|
||||
run-in-roblox -s plugin/testBootstrap.server.lua "$PLACE_FILE"
|
||||
|
||||
luacheck plugin/src plugin/log plugin/http
|
||||
13
clibrojo/Cargo.toml
Normal file
13
clibrojo/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "clibrojo"
|
||||
version = "0.1.0"
|
||||
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rojo = { path = ".." }
|
||||
19
clibrojo/README.md
Normal file
19
clibrojo/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Rojo as a C Library
|
||||
This is an experiment to expose a C API for Rojo that would be suitable for embedding it into an existing C/C++ application.
|
||||
|
||||
I'm hoping to expand it to drop the HTTP layer and communicate through a channel, which could make it feasible to embed into an existing Roblox IDE with minimal changes or additional code.
|
||||
|
||||
## Building
|
||||
This project is currently not built by default and could break/disappear at any time.
|
||||
|
||||
```bash
|
||||
cargo build -p clibrojo
|
||||
```
|
||||
|
||||
On Windows, Cargo will generate a `clibrojo.dll` and associated `.lib` file. Link these into your project.
|
||||
|
||||
To generate the associated C header file to include in the project, use [cbindgen](https://github.com/eqrion/cbindgen):
|
||||
|
||||
```bash
|
||||
cbindgen --crate clibrojo --output include/rojo.h
|
||||
```
|
||||
14
clibrojo/src/lib.rs
Normal file
14
clibrojo/src/lib.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use std::{ffi::CStr, os::raw::c_char, path::PathBuf};
|
||||
|
||||
use librojo::commands::{serve, ServeOptions};
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn rojo_serve(path: *const c_char) {
|
||||
let path = unsafe { PathBuf::from(CStr::from_ptr(path).to_str().unwrap()) };
|
||||
|
||||
serve(&ServeOptions {
|
||||
fuzzy_project_path: path,
|
||||
port: None,
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
30
design.gv
Normal file
30
design.gv
Normal file
@@ -0,0 +1,30 @@
|
||||
digraph Rojo {
|
||||
concentrate = true;
|
||||
node [fontname = "sans-serif"];
|
||||
|
||||
plugin [label="Roblox Studio Plugin"]
|
||||
session [label="Session"]
|
||||
rbx_tree [label="Instance Tree"]
|
||||
imfs [label="In-Memory Filesystem"]
|
||||
fs_impl [label="Filesystem Implementation\n(stubbed in tests)"]
|
||||
fs [label="Real Filesystem"]
|
||||
snapshot_subsystem [label="Snapshot Subsystem\n(reconciler)"]
|
||||
snapshot_generator [label="Snapshot Generator"]
|
||||
user_middleware [label="User Middleware\n(MoonScript, etc.)"]
|
||||
builtin_middleware [label="Built-in Middleware\n(.lua, .rbxm, etc.)"]
|
||||
api [label="Web API"]
|
||||
file_watcher [label="File Watcher"]
|
||||
|
||||
session -> imfs
|
||||
session -> rbx_tree
|
||||
session -> snapshot_subsystem
|
||||
session -> snapshot_generator
|
||||
session -> file_watcher [dir="both"]
|
||||
file_watcher -> imfs
|
||||
snapshot_generator -> user_middleware
|
||||
snapshot_generator -> builtin_middleware
|
||||
plugin -> api [style="dotted"; dir="both"; minlen=2]
|
||||
api -> session
|
||||
imfs -> fs_impl
|
||||
fs_impl -> fs
|
||||
}
|
||||
15
memofs/Cargo.toml
Normal file
15
memofs/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "memofs"
|
||||
description = "Virtual filesystem with configurable backends."
|
||||
version = "0.1.0"
|
||||
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
|
||||
edition = "2018"
|
||||
readme = "README.md"
|
||||
license = "MIT"
|
||||
homepage = "https://github.com/rojo-rbx/rojo/tree/master/memofs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
notify = "4.0.15"
|
||||
crossbeam-channel = "0.4.0"
|
||||
@@ -1,9 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Lucien Greathouse
|
||||
Copyright 2020 The Rojo Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
22
memofs/README.md
Normal file
22
memofs/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# memofs
|
||||
[](https://crates.io/crates/memofs)
|
||||
|
||||
Implementation of a virtual filesystem with a configurable backend and file
|
||||
watching.
|
||||
|
||||
memofs is currently an unstable minimum viable library. Its primary consumer is
|
||||
[Rojo](https://github.com/rojo-rbx/rojo), a build system for Roblox.
|
||||
|
||||
### Current Features
|
||||
* API similar to `std::fs`
|
||||
* Configurable backends
|
||||
* `StdBackend`, which uses `std::fs` and the `notify` crate
|
||||
* `NoopBackend`, which always throws errors
|
||||
* `InMemoryFs`, a simple in-memory filesystem useful for testing
|
||||
|
||||
### Future Features
|
||||
* Hash-based hierarchical memoization keys (hence the name)
|
||||
* Configurable caching (write-through, write-around, write-back)
|
||||
|
||||
## License
|
||||
memofs is available under the terms of the MIT license. See [LICENSE.txt](LICENSE.txt) or <https://opensource.org/licenses/MIT> for more details.
|
||||
7
memofs/README.tpl
Normal file
7
memofs/README.tpl
Normal file
@@ -0,0 +1,7 @@
|
||||
# {{crate}}
|
||||
[](https://crates.io/crates/memofs)
|
||||
|
||||
{{readme}}
|
||||
|
||||
## License
|
||||
memofs is available under the terms of the MIT license. See [LICENSE.txt](LICENSE.txt) or <https://opensource.org/licenses/MIT> for more details.
|
||||
249
memofs/src/in_memory_fs.rs
Normal file
249
memofs/src/in_memory_fs.rs
Normal file
@@ -0,0 +1,249 @@
|
||||
use std::collections::{BTreeSet, HashMap, VecDeque};
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
|
||||
use crate::{DirEntry, Metadata, ReadDir, VfsBackend, VfsEvent, VfsSnapshot};
|
||||
|
||||
/// In-memory filesystem that can be used as a VFS backend.
|
||||
///
|
||||
/// Internally reference counted to enable giving a copy to
|
||||
/// [`Vfs`](struct.Vfs.html) and keeping the original to mutate the filesystem's
|
||||
/// state with.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct InMemoryFs {
|
||||
inner: Arc<Mutex<InMemoryFsInner>>,
|
||||
}
|
||||
|
||||
impl InMemoryFs {
|
||||
/// Create a new empty `InMemoryFs`.
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
inner: Arc::new(Mutex::new(InMemoryFsInner::new())),
|
||||
}
|
||||
}
|
||||
|
||||
/// Load a [`VfsSnapshot`](enum.VfsSnapshot.html) into a subtree of the
|
||||
/// in-memory filesystem.
|
||||
///
|
||||
/// This function will return an error if the operations required to apply
|
||||
/// the snapshot result in errors, like trying to create a file inside a
|
||||
/// file.
|
||||
pub fn load_snapshot<P: Into<PathBuf>>(
|
||||
&mut self,
|
||||
path: P,
|
||||
snapshot: VfsSnapshot,
|
||||
) -> io::Result<()> {
|
||||
let mut inner = self.inner.lock().unwrap();
|
||||
inner.load_snapshot(path.into(), snapshot)
|
||||
}
|
||||
|
||||
/// Raises a filesystem change event.
|
||||
///
|
||||
/// If this `InMemoryFs` is being used as the backend of a
|
||||
/// [`Vfs`](struct.Vfs.html), then any listeners be notified of this event.
|
||||
pub fn raise_event(&mut self, event: VfsEvent) {
|
||||
let inner = self.inner.lock().unwrap();
|
||||
inner.event_sender.send(event).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct InMemoryFsInner {
|
||||
entries: HashMap<PathBuf, Entry>,
|
||||
orphans: BTreeSet<PathBuf>,
|
||||
|
||||
event_receiver: Receiver<VfsEvent>,
|
||||
event_sender: Sender<VfsEvent>,
|
||||
}
|
||||
|
||||
impl InMemoryFsInner {
|
||||
fn new() -> Self {
|
||||
let (event_sender, event_receiver) = crossbeam_channel::unbounded();
|
||||
|
||||
Self {
|
||||
entries: HashMap::new(),
|
||||
orphans: BTreeSet::new(),
|
||||
event_receiver,
|
||||
event_sender,
|
||||
}
|
||||
}
|
||||
|
||||
fn load_snapshot(&mut self, path: PathBuf, snapshot: VfsSnapshot) -> io::Result<()> {
|
||||
if let Some(parent_path) = path.parent() {
|
||||
if let Some(parent_entry) = self.entries.get_mut(parent_path) {
|
||||
if let Entry::Dir { children } = parent_entry {
|
||||
children.insert(path.clone());
|
||||
} else {
|
||||
return must_be_dir(parent_path);
|
||||
}
|
||||
} else {
|
||||
self.orphans.insert(path.clone());
|
||||
}
|
||||
} else {
|
||||
self.orphans.insert(path.clone());
|
||||
}
|
||||
|
||||
match snapshot {
|
||||
VfsSnapshot::File { contents } => {
|
||||
self.entries.insert(path, Entry::File { contents });
|
||||
}
|
||||
VfsSnapshot::Dir { children } => {
|
||||
self.entries.insert(
|
||||
path.clone(),
|
||||
Entry::Dir {
|
||||
children: BTreeSet::new(),
|
||||
},
|
||||
);
|
||||
|
||||
for (child_name, child) in children {
|
||||
let full_path = path.join(child_name);
|
||||
self.load_snapshot(full_path, child)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn remove(&mut self, root_path: PathBuf) {
|
||||
self.orphans.remove(&root_path);
|
||||
|
||||
let mut to_remove = VecDeque::new();
|
||||
to_remove.push_back(root_path);
|
||||
|
||||
while let Some(path) = to_remove.pop_front() {
|
||||
if let Some(Entry::Dir { children }) = self.entries.remove(&path) {
|
||||
to_remove.extend(children);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Entry {
|
||||
File { contents: Vec<u8> },
|
||||
|
||||
Dir { children: BTreeSet<PathBuf> },
|
||||
}
|
||||
|
||||
impl VfsBackend for InMemoryFs {
|
||||
fn read(&mut self, path: &Path) -> io::Result<Vec<u8>> {
|
||||
let inner = self.inner.lock().unwrap();
|
||||
|
||||
match inner.entries.get(path) {
|
||||
Some(Entry::File { contents }) => Ok(contents.clone()),
|
||||
Some(Entry::Dir { .. }) => must_be_file(path),
|
||||
None => not_found(path),
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&mut self, path: &Path, data: &[u8]) -> io::Result<()> {
|
||||
let mut inner = self.inner.lock().unwrap();
|
||||
|
||||
inner.load_snapshot(
|
||||
path.to_path_buf(),
|
||||
VfsSnapshot::File {
|
||||
contents: data.to_owned(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn read_dir(&mut self, path: &Path) -> io::Result<ReadDir> {
|
||||
let inner = self.inner.lock().unwrap();
|
||||
|
||||
match inner.entries.get(path) {
|
||||
Some(Entry::Dir { children }) => {
|
||||
let iter = children
|
||||
.clone()
|
||||
.into_iter()
|
||||
.map(|path| Ok(DirEntry { path }));
|
||||
|
||||
Ok(ReadDir {
|
||||
inner: Box::new(iter),
|
||||
})
|
||||
}
|
||||
Some(Entry::File { .. }) => must_be_dir(path),
|
||||
None => not_found(path),
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_file(&mut self, path: &Path) -> io::Result<()> {
|
||||
let mut inner = self.inner.lock().unwrap();
|
||||
|
||||
match inner.entries.get(path) {
|
||||
Some(Entry::File { .. }) => {
|
||||
inner.remove(path.to_owned());
|
||||
Ok(())
|
||||
}
|
||||
Some(Entry::Dir { .. }) => must_be_file(path),
|
||||
None => not_found(path),
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_dir_all(&mut self, path: &Path) -> io::Result<()> {
|
||||
let mut inner = self.inner.lock().unwrap();
|
||||
|
||||
match inner.entries.get(path) {
|
||||
Some(Entry::Dir { .. }) => {
|
||||
inner.remove(path.to_owned());
|
||||
Ok(())
|
||||
}
|
||||
Some(Entry::File { .. }) => must_be_dir(path),
|
||||
None => not_found(path),
|
||||
}
|
||||
}
|
||||
|
||||
fn metadata(&mut self, path: &Path) -> io::Result<Metadata> {
|
||||
let inner = self.inner.lock().unwrap();
|
||||
|
||||
match inner.entries.get(path) {
|
||||
Some(Entry::File { .. }) => Ok(Metadata { is_file: true }),
|
||||
Some(Entry::Dir { .. }) => Ok(Metadata { is_file: false }),
|
||||
None => not_found(path),
|
||||
}
|
||||
}
|
||||
|
||||
fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent> {
|
||||
let inner = self.inner.lock().unwrap();
|
||||
|
||||
inner.event_receiver.clone()
|
||||
}
|
||||
|
||||
fn watch(&mut self, _path: &Path) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unwatch(&mut self, _path: &Path) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn must_be_file<T>(path: &Path) -> io::Result<T> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"path {} was a directory, but must be a file",
|
||||
path.display()
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
fn must_be_dir<T>(path: &Path) -> io::Result<T> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!(
|
||||
"path {} was a file, but must be a directory",
|
||||
path.display()
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
fn not_found<T>(path: &Path) -> io::Result<T> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::NotFound,
|
||||
format!("path {} not found", path.display()),
|
||||
))
|
||||
}
|
||||
404
memofs/src/lib.rs
Normal file
404
memofs/src/lib.rs
Normal file
@@ -0,0 +1,404 @@
|
||||
/*!
|
||||
Implementation of a virtual filesystem with a configurable backend and file
|
||||
watching.
|
||||
|
||||
memofs is currently an unstable minimum viable library. Its primary consumer is
|
||||
[Rojo](https://github.com/rojo-rbx/rojo), a build system for Roblox.
|
||||
|
||||
## Current Features
|
||||
* API similar to `std::fs`
|
||||
* Configurable backends
|
||||
* `StdBackend`, which uses `std::fs` and the `notify` crate
|
||||
* `NoopBackend`, which always throws errors
|
||||
* `InMemoryFs`, a simple in-memory filesystem useful for testing
|
||||
|
||||
## Future Features
|
||||
* Hash-based hierarchical memoization keys (hence the name)
|
||||
* Configurable caching (write-through, write-around, write-back)
|
||||
*/
|
||||
|
||||
mod in_memory_fs;
|
||||
mod noop_backend;
|
||||
mod snapshot;
|
||||
mod std_backend;
|
||||
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
|
||||
pub use in_memory_fs::InMemoryFs;
|
||||
pub use noop_backend::NoopBackend;
|
||||
pub use snapshot::VfsSnapshot;
|
||||
pub use std_backend::StdBackend;
|
||||
|
||||
mod sealed {
|
||||
use super::*;
|
||||
|
||||
/// Sealing trait for VfsBackend.
|
||||
pub trait Sealed {}
|
||||
|
||||
impl Sealed for NoopBackend {}
|
||||
impl Sealed for StdBackend {}
|
||||
impl Sealed for InMemoryFs {}
|
||||
}
|
||||
|
||||
/// Trait that transforms `io::Result<T>` into `io::Result<Option<T>>`.
|
||||
///
|
||||
/// `Ok(None)` takes the place of IO errors whose `io::ErrorKind` is `NotFound`.
|
||||
pub trait IoResultExt<T> {
|
||||
fn with_not_found(self) -> io::Result<Option<T>>;
|
||||
}
|
||||
|
||||
impl<T> IoResultExt<T> for io::Result<T> {
|
||||
fn with_not_found(self) -> io::Result<Option<T>> {
|
||||
match self {
|
||||
Ok(v) => Ok(Some(v)),
|
||||
Err(err) => {
|
||||
if err.kind() == io::ErrorKind::NotFound {
|
||||
Ok(None)
|
||||
} else {
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Backend that can be used to create a `Vfs`.
|
||||
///
|
||||
/// This trait is sealed and cannot not be implemented outside this crate.
|
||||
pub trait VfsBackend: sealed::Sealed + Send + 'static {
|
||||
fn read(&mut self, path: &Path) -> io::Result<Vec<u8>>;
|
||||
fn write(&mut self, path: &Path, data: &[u8]) -> io::Result<()>;
|
||||
fn read_dir(&mut self, path: &Path) -> io::Result<ReadDir>;
|
||||
fn metadata(&mut self, path: &Path) -> io::Result<Metadata>;
|
||||
fn remove_file(&mut self, path: &Path) -> io::Result<()>;
|
||||
fn remove_dir_all(&mut self, path: &Path) -> io::Result<()>;
|
||||
|
||||
fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent>;
|
||||
fn watch(&mut self, path: &Path) -> io::Result<()>;
|
||||
fn unwatch(&mut self, path: &Path) -> io::Result<()>;
|
||||
}
|
||||
|
||||
/// Vfs equivalent to [`std::fs::DirEntry`][std::fs::DirEntry].
|
||||
///
|
||||
/// [std::fs::DirEntry]: https://doc.rust-lang.org/stable/std/fs/struct.DirEntry.html
|
||||
pub struct DirEntry {
|
||||
pub(crate) path: PathBuf,
|
||||
}
|
||||
|
||||
impl DirEntry {
|
||||
pub fn path(&self) -> &Path {
|
||||
&self.path
|
||||
}
|
||||
}
|
||||
|
||||
/// Vfs equivalent to [`std::fs::ReadDir`][std::fs::ReadDir].
|
||||
///
|
||||
/// [std::fs::ReadDir]: https://doc.rust-lang.org/stable/std/fs/struct.ReadDir.html
|
||||
pub struct ReadDir {
|
||||
pub(crate) inner: Box<dyn Iterator<Item = io::Result<DirEntry>>>,
|
||||
}
|
||||
|
||||
impl Iterator for ReadDir {
|
||||
type Item = io::Result<DirEntry>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.inner.next()
|
||||
}
|
||||
}
|
||||
|
||||
/// Vfs equivalent to [`std::fs::Metadata`][std::fs::Metadata].
|
||||
///
|
||||
/// [std::fs::Metadata]: https://doc.rust-lang.org/stable/std/fs/struct.Metadata.html
|
||||
#[derive(Debug)]
|
||||
pub struct Metadata {
|
||||
pub(crate) is_file: bool,
|
||||
}
|
||||
|
||||
impl Metadata {
|
||||
pub fn is_file(&self) -> bool {
|
||||
self.is_file
|
||||
}
|
||||
|
||||
pub fn is_dir(&self) -> bool {
|
||||
!self.is_file
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents an event that a filesystem can raise that might need to be
|
||||
/// handled.
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
pub enum VfsEvent {
|
||||
Create(PathBuf),
|
||||
Write(PathBuf),
|
||||
Remove(PathBuf),
|
||||
}
|
||||
|
||||
/// Contains implementation details of the Vfs, wrapped by `Vfs` and `VfsLock`,
|
||||
/// the public interfaces to this type.
|
||||
struct VfsInner {
|
||||
backend: Box<dyn VfsBackend>,
|
||||
}
|
||||
|
||||
impl VfsInner {
|
||||
fn read<P: AsRef<Path>>(&mut self, path: P) -> io::Result<Arc<Vec<u8>>> {
|
||||
let path = path.as_ref();
|
||||
let contents = self.backend.read(path)?;
|
||||
self.backend.watch(path)?;
|
||||
Ok(Arc::new(contents))
|
||||
}
|
||||
|
||||
fn write<P: AsRef<Path>, C: AsRef<[u8]>>(&mut self, path: P, contents: C) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
let contents = contents.as_ref();
|
||||
self.backend.write(path, contents)
|
||||
}
|
||||
|
||||
fn read_dir<P: AsRef<Path>>(&mut self, path: P) -> io::Result<ReadDir> {
|
||||
let path = path.as_ref();
|
||||
let dir = self.backend.read_dir(path)?;
|
||||
self.backend.watch(path)?;
|
||||
Ok(dir)
|
||||
}
|
||||
|
||||
fn remove_file<P: AsRef<Path>>(&mut self, path: P) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
let _ = self.backend.unwatch(path);
|
||||
self.backend.remove_file(path)
|
||||
}
|
||||
|
||||
fn remove_dir_all<P: AsRef<Path>>(&mut self, path: P) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
let _ = self.backend.unwatch(path);
|
||||
self.backend.remove_dir_all(path)
|
||||
}
|
||||
|
||||
fn metadata<P: AsRef<Path>>(&mut self, path: P) -> io::Result<Metadata> {
|
||||
let path = path.as_ref();
|
||||
self.backend.metadata(path)
|
||||
}
|
||||
|
||||
fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent> {
|
||||
self.backend.event_receiver()
|
||||
}
|
||||
|
||||
fn commit_event(&mut self, event: &VfsEvent) -> io::Result<()> {
|
||||
match event {
|
||||
VfsEvent::Remove(path) => {
|
||||
let _ = self.backend.unwatch(&path);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// A virtual filesystem with a configurable backend.
|
||||
///
|
||||
/// All operations on the Vfs take a lock on an internal backend. For performing
|
||||
/// large batches of operations, it might be more performant to call `lock()`
|
||||
/// and use [`VfsLock`](struct.VfsLock.html) instead.
|
||||
pub struct Vfs {
|
||||
inner: Mutex<VfsInner>,
|
||||
}
|
||||
|
||||
impl Vfs {
|
||||
/// Creates a new `Vfs` with the default backend, `StdBackend`.
|
||||
pub fn new_default() -> Self {
|
||||
Self::new(StdBackend::new())
|
||||
}
|
||||
|
||||
/// Creates a new `Vfs` with the given backend.
|
||||
pub fn new<B: VfsBackend>(backend: B) -> Self {
|
||||
let lock = VfsInner {
|
||||
backend: Box::new(backend),
|
||||
};
|
||||
|
||||
Self {
|
||||
inner: Mutex::new(lock),
|
||||
}
|
||||
}
|
||||
|
||||
/// Manually lock the Vfs, useful for large batches of operations.
|
||||
pub fn lock(&self) -> VfsLock<'_> {
|
||||
VfsLock {
|
||||
inner: self.inner.lock().unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Read a file from the VFS, or the underlying backend if it isn't
|
||||
/// resident.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::read`][std::fs::read].
|
||||
///
|
||||
/// [std::fs::read]: https://doc.rust-lang.org/stable/std/fs/fn.read.html
|
||||
#[inline]
|
||||
pub fn read<P: AsRef<Path>>(&self, path: P) -> io::Result<Arc<Vec<u8>>> {
|
||||
let path = path.as_ref();
|
||||
self.inner.lock().unwrap().read(path)
|
||||
}
|
||||
|
||||
/// Write a file to the VFS and the underlying backend.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::write`][std::fs::write].
|
||||
///
|
||||
/// [std::fs::write]: https://doc.rust-lang.org/stable/std/fs/fn.write.html
|
||||
#[inline]
|
||||
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(&self, path: P, contents: C) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
let contents = contents.as_ref();
|
||||
self.inner.lock().unwrap().write(path, contents)
|
||||
}
|
||||
|
||||
/// Read all of the children of a directory.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::read_dir`][std::fs::read_dir].
|
||||
///
|
||||
/// [std::fs::read_dir]: https://doc.rust-lang.org/stable/std/fs/fn.read_dir.html
|
||||
#[inline]
|
||||
pub fn read_dir<P: AsRef<Path>>(&self, path: P) -> io::Result<ReadDir> {
|
||||
let path = path.as_ref();
|
||||
self.inner.lock().unwrap().read_dir(path)
|
||||
}
|
||||
|
||||
/// Remove a file.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::remove_file`][std::fs::remove_file].
|
||||
///
|
||||
/// [std::fs::remove_file]: https://doc.rust-lang.org/stable/std/fs/fn.remove_file.html
|
||||
#[inline]
|
||||
pub fn remove_file<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
self.inner.lock().unwrap().remove_file(path)
|
||||
}
|
||||
|
||||
/// Remove a directory and all of its descendants.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::remove_dir_all`][std::fs::remove_dir_all].
|
||||
///
|
||||
/// [std::fs::remove_dir_all]: https://doc.rust-lang.org/stable/std/fs/fn.remove_dir_all.html
|
||||
#[inline]
|
||||
pub fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
self.inner.lock().unwrap().remove_dir_all(path)
|
||||
}
|
||||
|
||||
/// Query metadata about the given path.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::metadata`][std::fs::metadata].
|
||||
///
|
||||
/// [std::fs::metadata]: https://doc.rust-lang.org/stable/std/fs/fn.metadata.html
|
||||
#[inline]
|
||||
pub fn metadata<P: AsRef<Path>>(&self, path: P) -> io::Result<Metadata> {
|
||||
let path = path.as_ref();
|
||||
self.inner.lock().unwrap().metadata(path)
|
||||
}
|
||||
|
||||
/// Retrieve a handle to the event receiver for this `Vfs`.
|
||||
#[inline]
|
||||
pub fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent> {
|
||||
self.inner.lock().unwrap().event_receiver()
|
||||
}
|
||||
|
||||
/// Commit an event to this `Vfs`.
|
||||
#[inline]
|
||||
pub fn commit_event(&self, event: &VfsEvent) -> io::Result<()> {
|
||||
self.inner.lock().unwrap().commit_event(event)
|
||||
}
|
||||
}
|
||||
|
||||
/// A locked handle to a [`Vfs`](struct.Vfs.html), created by `Vfs::lock`.
|
||||
///
|
||||
/// Implements roughly the same API as [`Vfs`](struct.Vfs.html).
|
||||
pub struct VfsLock<'a> {
|
||||
inner: MutexGuard<'a, VfsInner>,
|
||||
}
|
||||
|
||||
impl VfsLock<'_> {
|
||||
/// Read a file from the VFS, or the underlying backend if it isn't
|
||||
/// resident.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::read`][std::fs::read].
|
||||
///
|
||||
/// [std::fs::read]: https://doc.rust-lang.org/stable/std/fs/fn.read.html
|
||||
#[inline]
|
||||
pub fn read<P: AsRef<Path>>(&mut self, path: P) -> io::Result<Arc<Vec<u8>>> {
|
||||
let path = path.as_ref();
|
||||
self.inner.read(path)
|
||||
}
|
||||
|
||||
/// Write a file to the VFS and the underlying backend.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::write`][std::fs::write].
|
||||
///
|
||||
/// [std::fs::write]: https://doc.rust-lang.org/stable/std/fs/fn.write.html
|
||||
#[inline]
|
||||
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(
|
||||
&mut self,
|
||||
path: P,
|
||||
contents: C,
|
||||
) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
let contents = contents.as_ref();
|
||||
self.inner.write(path, contents)
|
||||
}
|
||||
|
||||
/// Read all of the children of a directory.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::read_dir`][std::fs::read_dir].
|
||||
///
|
||||
/// [std::fs::read_dir]: https://doc.rust-lang.org/stable/std/fs/fn.read_dir.html
|
||||
#[inline]
|
||||
pub fn read_dir<P: AsRef<Path>>(&mut self, path: P) -> io::Result<ReadDir> {
|
||||
let path = path.as_ref();
|
||||
self.inner.read_dir(path)
|
||||
}
|
||||
|
||||
/// Remove a file.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::remove_file`][std::fs::remove_file].
|
||||
///
|
||||
/// [std::fs::remove_file]: https://doc.rust-lang.org/stable/std/fs/fn.remove_file.html
|
||||
#[inline]
|
||||
pub fn remove_file<P: AsRef<Path>>(&mut self, path: P) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
self.inner.remove_file(path)
|
||||
}
|
||||
|
||||
/// Remove a directory and all of its descendants.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::remove_dir_all`][std::fs::remove_dir_all].
|
||||
///
|
||||
/// [std::fs::remove_dir_all]: https://doc.rust-lang.org/stable/std/fs/fn.remove_dir_all.html
|
||||
#[inline]
|
||||
pub fn remove_dir_all<P: AsRef<Path>>(&mut self, path: P) -> io::Result<()> {
|
||||
let path = path.as_ref();
|
||||
self.inner.remove_dir_all(path)
|
||||
}
|
||||
|
||||
/// Query metadata about the given path.
|
||||
///
|
||||
/// Roughly equivalent to [`std::fs::metadata`][std::fs::metadata].
|
||||
///
|
||||
/// [std::fs::metadata]: https://doc.rust-lang.org/stable/std/fs/fn.metadata.html
|
||||
#[inline]
|
||||
pub fn metadata<P: AsRef<Path>>(&mut self, path: P) -> io::Result<Metadata> {
|
||||
let path = path.as_ref();
|
||||
self.inner.metadata(path)
|
||||
}
|
||||
|
||||
/// Retrieve a handle to the event receiver for this `Vfs`.
|
||||
#[inline]
|
||||
pub fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent> {
|
||||
self.inner.event_receiver()
|
||||
}
|
||||
|
||||
/// Commit an event to this `Vfs`.
|
||||
#[inline]
|
||||
pub fn commit_event(&mut self, event: &VfsEvent) -> io::Result<()> {
|
||||
self.inner.commit_event(event)
|
||||
}
|
||||
}
|
||||
76
memofs/src/noop_backend.rs
Normal file
76
memofs/src/noop_backend.rs
Normal file
@@ -0,0 +1,76 @@
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{Metadata, ReadDir, VfsBackend, VfsEvent};
|
||||
|
||||
/// `VfsBackend` that returns an error on every operation.
|
||||
#[non_exhaustive]
|
||||
pub struct NoopBackend;
|
||||
|
||||
impl NoopBackend {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl VfsBackend for NoopBackend {
|
||||
fn read(&mut self, _path: &Path) -> io::Result<Vec<u8>> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"NoopBackend doesn't do anything",
|
||||
))
|
||||
}
|
||||
|
||||
fn write(&mut self, _path: &Path, _data: &[u8]) -> io::Result<()> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"NoopBackend doesn't do anything",
|
||||
))
|
||||
}
|
||||
|
||||
fn read_dir(&mut self, _path: &Path) -> io::Result<ReadDir> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"NoopBackend doesn't do anything",
|
||||
))
|
||||
}
|
||||
|
||||
fn remove_file(&mut self, _path: &Path) -> io::Result<()> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"NoopBackend doesn't do anything",
|
||||
))
|
||||
}
|
||||
|
||||
fn remove_dir_all(&mut self, _path: &Path) -> io::Result<()> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"NoopBackend doesn't do anything",
|
||||
))
|
||||
}
|
||||
|
||||
fn metadata(&mut self, _path: &Path) -> io::Result<Metadata> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"NoopBackend doesn't do anything",
|
||||
))
|
||||
}
|
||||
|
||||
fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent> {
|
||||
crossbeam_channel::never()
|
||||
}
|
||||
|
||||
fn watch(&mut self, _path: &Path) -> io::Result<()> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"NoopBackend doesn't do anything",
|
||||
))
|
||||
}
|
||||
|
||||
fn unwatch(&mut self, _path: &Path) -> io::Result<()> {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"NoopBackend doesn't do anything",
|
||||
))
|
||||
}
|
||||
}
|
||||
44
memofs/src/snapshot.rs
Normal file
44
memofs/src/snapshot.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// A slice of a tree of files. Can be loaded into an
|
||||
/// [`InMemoryFs`](struct.InMemoryFs.html).
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
pub enum VfsSnapshot {
|
||||
File {
|
||||
contents: Vec<u8>,
|
||||
},
|
||||
|
||||
Dir {
|
||||
children: BTreeMap<String, VfsSnapshot>,
|
||||
},
|
||||
}
|
||||
|
||||
impl VfsSnapshot {
|
||||
pub fn file<C: Into<Vec<u8>>>(contents: C) -> Self {
|
||||
Self::File {
|
||||
contents: contents.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dir<K: Into<String>, I: IntoIterator<Item = (K, VfsSnapshot)>>(children: I) -> Self {
|
||||
Self::Dir {
|
||||
children: children
|
||||
.into_iter()
|
||||
.map(|(key, value)| (key.into(), value))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn empty_file() -> Self {
|
||||
Self::File {
|
||||
contents: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn empty_dir() -> Self {
|
||||
Self::Dir {
|
||||
children: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
111
memofs/src/std_backend.rs
Normal file
111
memofs/src/std_backend.rs
Normal file
@@ -0,0 +1,111 @@
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::sync::mpsc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use crossbeam_channel::Receiver;
|
||||
use notify::{watcher, DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
|
||||
|
||||
use crate::{DirEntry, Metadata, ReadDir, VfsBackend, VfsEvent};
|
||||
|
||||
/// `VfsBackend` that uses `std::fs` and the `notify` crate.
|
||||
pub struct StdBackend {
|
||||
watcher: RecommendedWatcher,
|
||||
watcher_receiver: Receiver<VfsEvent>,
|
||||
}
|
||||
|
||||
impl StdBackend {
|
||||
pub fn new() -> StdBackend {
|
||||
let (notify_tx, notify_rx) = mpsc::channel();
|
||||
let watcher = watcher(notify_tx, Duration::from_millis(50)).unwrap();
|
||||
|
||||
let (tx, rx) = crossbeam_channel::unbounded();
|
||||
|
||||
thread::spawn(move || {
|
||||
for event in notify_rx {
|
||||
match event {
|
||||
DebouncedEvent::Create(path) => {
|
||||
tx.send(VfsEvent::Create(path))?;
|
||||
}
|
||||
DebouncedEvent::Write(path) => {
|
||||
tx.send(VfsEvent::Write(path))?;
|
||||
}
|
||||
DebouncedEvent::Remove(path) => {
|
||||
tx.send(VfsEvent::Remove(path))?;
|
||||
}
|
||||
DebouncedEvent::Rename(from, to) => {
|
||||
tx.send(VfsEvent::Remove(from))?;
|
||||
tx.send(VfsEvent::Create(to))?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Result::<(), crossbeam_channel::SendError<VfsEvent>>::Ok(())
|
||||
});
|
||||
|
||||
Self {
|
||||
watcher,
|
||||
watcher_receiver: rx,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VfsBackend for StdBackend {
|
||||
fn read(&mut self, path: &Path) -> io::Result<Vec<u8>> {
|
||||
fs::read(path)
|
||||
}
|
||||
|
||||
fn write(&mut self, path: &Path, data: &[u8]) -> io::Result<()> {
|
||||
fs::write(path, data)
|
||||
}
|
||||
|
||||
fn read_dir(&mut self, path: &Path) -> io::Result<ReadDir> {
|
||||
let entries: Result<Vec<_>, _> = fs::read_dir(path)?.collect();
|
||||
let mut entries = entries?;
|
||||
|
||||
entries.sort_by_cached_key(|entry| entry.file_name());
|
||||
|
||||
let inner = entries
|
||||
.into_iter()
|
||||
.map(|entry| Ok(DirEntry { path: entry.path() }));
|
||||
|
||||
Ok(ReadDir {
|
||||
inner: Box::new(inner),
|
||||
})
|
||||
}
|
||||
|
||||
fn remove_file(&mut self, path: &Path) -> io::Result<()> {
|
||||
fs::remove_file(path)
|
||||
}
|
||||
|
||||
fn remove_dir_all(&mut self, path: &Path) -> io::Result<()> {
|
||||
fs::remove_dir_all(path)
|
||||
}
|
||||
|
||||
fn metadata(&mut self, path: &Path) -> io::Result<Metadata> {
|
||||
let inner = fs::metadata(path)?;
|
||||
|
||||
Ok(Metadata {
|
||||
is_file: inner.is_file(),
|
||||
})
|
||||
}
|
||||
|
||||
fn event_receiver(&self) -> crossbeam_channel::Receiver<VfsEvent> {
|
||||
self.watcher_receiver.clone()
|
||||
}
|
||||
|
||||
fn watch(&mut self, path: &Path) -> io::Result<()> {
|
||||
self.watcher
|
||||
.watch(path, RecursiveMode::NonRecursive)
|
||||
.map_err(|inner| io::Error::new(io::ErrorKind::Other, inner))
|
||||
}
|
||||
|
||||
fn unwatch(&mut self, path: &Path) -> io::Result<()> {
|
||||
self.watcher
|
||||
.unwatch(path)
|
||||
.map_err(|inner| io::Error::new(io::ErrorKind::Other, inner))
|
||||
}
|
||||
}
|
||||
Submodule modules/Roact deleted from 7cce62b130
Submodule modules/RoactRodux deleted from 43c4f347fe
Submodule modules/Rodux deleted from 6c573259ab
Submodule modules/TestEZ deleted from 9945f562e5
30
plugin/default.project.json
Normal file
30
plugin/default.project.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "Rojo",
|
||||
"tree": {
|
||||
"$className": "Folder",
|
||||
"Plugin": {
|
||||
"$path": "src"
|
||||
},
|
||||
"Log": {
|
||||
"$path": "log"
|
||||
},
|
||||
"Http": {
|
||||
"$path": "http"
|
||||
},
|
||||
"Fmt": {
|
||||
"$path": "fmt"
|
||||
},
|
||||
"Roact": {
|
||||
"$path": "modules/roact/src"
|
||||
},
|
||||
"Promise": {
|
||||
"$path": "modules/promise/lib"
|
||||
},
|
||||
"t": {
|
||||
"$path": "modules/t/lib"
|
||||
},
|
||||
"RbxDom": {
|
||||
"$path": "modules/rbx-dom/rbx_dom_lua/src"
|
||||
}
|
||||
}
|
||||
}
|
||||
245
plugin/fmt/init.lua
Normal file
245
plugin/fmt/init.lua
Normal file
@@ -0,0 +1,245 @@
|
||||
--[[
|
||||
This library describes a formatting mechanism akin to Rust's std::fmt.
|
||||
|
||||
It has a couple building blocks:
|
||||
|
||||
* A new syntax for formatting strings, taken verbatim from Rust. It'd also
|
||||
be possible to use printf-style formatting specifiers to integrate with
|
||||
the existing string.format utility.
|
||||
|
||||
* An equivalent to Rust's `Display` trait. We're mapping the semantics of
|
||||
tostring and the __tostring metamethod onto this trait. A lot of types
|
||||
should already have __tostring implementations, too!
|
||||
|
||||
* An equivalent to Rust's `Debug` trait. This library Lua-ifies that idea by
|
||||
inventing a new metamethod, `__fmtDebug`. We pass along the "extended
|
||||
form" attribute which is the equivalent of the "alternate mode" in Rust's
|
||||
Debug trait since it's the author's opinion that treating it as a
|
||||
verbosity flag is semantically accurate.
|
||||
]]
|
||||
|
||||
--[[
|
||||
The default implementation of __fmtDebug for tables when the extended option
|
||||
is not set.
|
||||
]]
|
||||
local function defaultTableDebug(buffer, input)
|
||||
buffer:writeRaw("{")
|
||||
|
||||
for key, value in pairs(input) do
|
||||
buffer:write("[{:?}] = {:?}", key, value)
|
||||
|
||||
if next(input, key) ~= nil then
|
||||
buffer:writeRaw(", ")
|
||||
end
|
||||
end
|
||||
|
||||
buffer:writeRaw("}")
|
||||
end
|
||||
|
||||
--[[
|
||||
The default implementation of __fmtDebug for tables with the extended option
|
||||
set.
|
||||
]]
|
||||
local function defaultTableDebugExtended(buffer, input)
|
||||
-- Special case for empty tables.
|
||||
if next(input) == nil then
|
||||
buffer:writeRaw("{}")
|
||||
return
|
||||
end
|
||||
|
||||
buffer:writeLineRaw("{")
|
||||
buffer:indent()
|
||||
|
||||
for key, value in pairs(input) do
|
||||
buffer:writeLine("[{:?}] = {:#?},", key, value)
|
||||
end
|
||||
|
||||
buffer:unindent()
|
||||
buffer:writeRaw("}")
|
||||
end
|
||||
|
||||
--[[
|
||||
The default debug representation for all types.
|
||||
]]
|
||||
local function debugImpl(buffer, value, extendedForm)
|
||||
local valueType = typeof(value)
|
||||
|
||||
if valueType == "string" then
|
||||
local formatted = string.format("%q", value)
|
||||
buffer:writeRaw(formatted)
|
||||
elseif valueType == "table" then
|
||||
local valueMeta = getmetatable(value)
|
||||
|
||||
if valueMeta ~= nil and valueMeta.__fmtDebug ~= nil then
|
||||
-- This type implement's the metamethod we made up to line up with
|
||||
-- Rust's 'Debug' trait.
|
||||
|
||||
valueMeta.__fmtDebug(value, buffer, extendedForm)
|
||||
else
|
||||
if extendedForm then
|
||||
defaultTableDebugExtended(buffer, value)
|
||||
else
|
||||
defaultTableDebug(buffer, value)
|
||||
end
|
||||
end
|
||||
elseif valueType == "Instance" then
|
||||
buffer:writeRaw(value:GetFullName())
|
||||
else
|
||||
buffer:writeRaw(tostring(value))
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Defines and implements the library's template syntax.
|
||||
]]
|
||||
local function writeFmt(buffer, template, ...)
|
||||
local currentArg = 0
|
||||
local i = 1
|
||||
local len = #template
|
||||
|
||||
while i <= len do
|
||||
local openBrace = template:find("{", i)
|
||||
|
||||
if openBrace == nil then
|
||||
-- There are no remaining open braces in this string, so we can
|
||||
-- write the rest of the string to the buffer.
|
||||
|
||||
buffer:writeRaw(template:sub(i))
|
||||
break
|
||||
else
|
||||
-- We found an open brace! This could be:
|
||||
-- - A literal '{', written as '{{'
|
||||
-- - The beginning of an interpolation, like '{}'
|
||||
-- - An error, if there's no matching '}'
|
||||
|
||||
local charAfterBrace = template:sub(openBrace + 1, openBrace + 1)
|
||||
if charAfterBrace == "{" then
|
||||
-- This is a literal brace, so we'll write everything up to this
|
||||
-- point (including the first brace), and then skip over the
|
||||
-- second brace.
|
||||
|
||||
buffer:writeRaw(template:sub(i, openBrace))
|
||||
i = openBrace + 2
|
||||
else
|
||||
-- This SHOULD be an interpolation. We'll find our matching
|
||||
-- brace and treat the contents as the formatting specifier.
|
||||
|
||||
-- If there were any unwritten characters before this
|
||||
-- interpolation, write them to the buffer.
|
||||
if openBrace - i > 0 then
|
||||
buffer:writeRaw(template:sub(i, openBrace - 1))
|
||||
end
|
||||
|
||||
local closeBrace = template:find("}", openBrace + 1)
|
||||
assert(closeBrace ~= nil, "Unclosed formatting specifier. Use '{{' to write an open brace.")
|
||||
|
||||
local formatSpecifier = template:sub(openBrace + 1, closeBrace - 1)
|
||||
currentArg = currentArg + 1
|
||||
local arg = select(currentArg, ...)
|
||||
|
||||
if formatSpecifier == "" then
|
||||
-- This should use the equivalent of Rust's 'Display', ie
|
||||
-- tostring and the __tostring metamethod.
|
||||
|
||||
buffer:writeRaw(tostring(arg))
|
||||
elseif formatSpecifier == ":?" then
|
||||
-- This should use the equivalent of Rust's 'Debug',
|
||||
-- invented for this library as __fmtDebug.
|
||||
|
||||
debugImpl(buffer, arg, false)
|
||||
elseif formatSpecifier == ":#?" then
|
||||
-- This should use the equivlant of Rust's 'Debug' with the
|
||||
-- 'alternate' (ie expanded) flag set.
|
||||
|
||||
debugImpl(buffer, arg, true)
|
||||
else
|
||||
error("unsupported format specifier " .. formatSpecifier, 2)
|
||||
end
|
||||
|
||||
i = closeBrace + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function debugOutputBuffer()
|
||||
local buffer = {}
|
||||
local startOfLine = true
|
||||
local indentLevel = 0
|
||||
local indentation = ""
|
||||
|
||||
function buffer:writeLine(template, ...)
|
||||
writeFmt(self, template, ...)
|
||||
self:nextLine()
|
||||
end
|
||||
|
||||
function buffer:writeLineRaw(value)
|
||||
self:writeRaw(value)
|
||||
self:nextLine()
|
||||
end
|
||||
|
||||
function buffer:write(template, ...)
|
||||
return writeFmt(self, template, ...)
|
||||
end
|
||||
|
||||
function buffer:writeRaw(value)
|
||||
if #value > 0 then
|
||||
if startOfLine and #indentation > 0 then
|
||||
startOfLine = false
|
||||
table.insert(self, indentation)
|
||||
end
|
||||
|
||||
table.insert(self, value)
|
||||
startOfLine = false
|
||||
end
|
||||
end
|
||||
|
||||
function buffer:nextLine()
|
||||
table.insert(self, "\n")
|
||||
startOfLine = true
|
||||
end
|
||||
|
||||
function buffer:indent()
|
||||
indentLevel = indentLevel + 1
|
||||
indentation = string.rep(" ", indentLevel)
|
||||
end
|
||||
|
||||
function buffer:unindent()
|
||||
indentLevel = math.max(0, indentLevel - 1)
|
||||
indentation = string.rep(" ", indentLevel)
|
||||
end
|
||||
|
||||
function buffer:finish()
|
||||
return table.concat(self, "")
|
||||
end
|
||||
|
||||
return buffer
|
||||
end
|
||||
|
||||
local function fmt(template, ...)
|
||||
local buffer = debugOutputBuffer()
|
||||
writeFmt(buffer, template, ...)
|
||||
return buffer:finish()
|
||||
end
|
||||
|
||||
--[[
|
||||
Wrap the given object in a type that implements the given function as its
|
||||
Debug implementation, and forwards __tostring to the type's underlying
|
||||
tostring implementation.
|
||||
]]
|
||||
local function debugify(object, fmtFunc)
|
||||
return setmetatable({}, {
|
||||
__fmtDebug = function(_, ...)
|
||||
return fmtFunc(object, ...)
|
||||
end,
|
||||
__tostring = function()
|
||||
return tostring(object)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
debugOutputBuffer = debugOutputBuffer,
|
||||
fmt = fmt,
|
||||
debugify = debugify,
|
||||
}
|
||||
66
plugin/http/Error.lua
Normal file
66
plugin/http/Error.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
local Error = {}
|
||||
Error.__index = Error
|
||||
|
||||
Error.Kind = {
|
||||
HttpNotEnabled = {
|
||||
message = "Rojo requires HTTP access, which is not enabled.\n" ..
|
||||
"Check your game settings, located in the 'Home' tab of Studio.",
|
||||
},
|
||||
ConnectFailed = {
|
||||
message = "Couldn't connect to the Rojo server.\n" ..
|
||||
"Make sure the server is running -- use 'rojo serve' to run it!",
|
||||
},
|
||||
Timeout = {
|
||||
message = "HTTP request timed out.",
|
||||
},
|
||||
Unknown = {
|
||||
message = "Unknown HTTP error: {{message}}",
|
||||
},
|
||||
}
|
||||
|
||||
setmetatable(Error.Kind, {
|
||||
__index = function(_, key)
|
||||
error(("%q is not a valid member of Http.Error.Kind"):format(tostring(key)), 2)
|
||||
end,
|
||||
})
|
||||
|
||||
function Error.new(type, extraMessage)
|
||||
extraMessage = extraMessage or ""
|
||||
local message = type.message:gsub("{{message}}", extraMessage)
|
||||
|
||||
local err = {
|
||||
type = type,
|
||||
message = message,
|
||||
}
|
||||
|
||||
setmetatable(err, Error)
|
||||
|
||||
return err
|
||||
end
|
||||
|
||||
function Error:__tostring()
|
||||
return self.message
|
||||
end
|
||||
|
||||
--[[
|
||||
This method shouldn't have to exist. Ugh.
|
||||
]]
|
||||
function Error.fromRobloxErrorString(message)
|
||||
local lower = message:lower()
|
||||
|
||||
if lower:find("^http requests are not enabled") then
|
||||
return Error.new(Error.Kind.HttpNotEnabled)
|
||||
end
|
||||
|
||||
if lower:find("^httperror: timedout") then
|
||||
return Error.new(Error.Kind.Timeout)
|
||||
end
|
||||
|
||||
if lower:find("^httperror: connectfail") then
|
||||
return Error.new(Error.Kind.ConnectFailed)
|
||||
end
|
||||
|
||||
return Error.new(Error.Kind.Unknown, message)
|
||||
end
|
||||
|
||||
return Error
|
||||
34
plugin/http/Response.lua
Normal file
34
plugin/http/Response.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local stringTemplate = [[
|
||||
Http.Response {
|
||||
code: %d
|
||||
body: %s
|
||||
}]]
|
||||
|
||||
local Response = {}
|
||||
Response.__index = Response
|
||||
|
||||
function Response:__tostring()
|
||||
return stringTemplate:format(self.code, self.body)
|
||||
end
|
||||
|
||||
function Response.fromRobloxResponse(response)
|
||||
local self = {
|
||||
body = response.Body,
|
||||
code = response.StatusCode,
|
||||
headers = response.Headers,
|
||||
}
|
||||
|
||||
return setmetatable(self, Response)
|
||||
end
|
||||
|
||||
function Response:isSuccess()
|
||||
return self.code >= 200 and self.code < 300
|
||||
end
|
||||
|
||||
function Response:json()
|
||||
return HttpService:JSONDecode(self.body)
|
||||
end
|
||||
|
||||
return Response
|
||||
66
plugin/http/init.lua
Normal file
66
plugin/http/init.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local Promise = require(script.Parent.Promise)
|
||||
local Log = require(script.Parent.Log)
|
||||
|
||||
local HttpError = require(script.Error)
|
||||
local HttpResponse = require(script.Response)
|
||||
|
||||
local lastRequestId = 0
|
||||
|
||||
local Http = {}
|
||||
|
||||
Http.Error = HttpError
|
||||
Http.Response = HttpResponse
|
||||
|
||||
local function performRequest(requestParams)
|
||||
local requestId = lastRequestId + 1
|
||||
lastRequestId = requestId
|
||||
|
||||
Log.trace("HTTP {}({}) {}", requestParams.Method, requestId, requestParams.Url)
|
||||
|
||||
if requestParams.Body ~= nil then
|
||||
Log.trace("{}", requestParams.Body)
|
||||
end
|
||||
|
||||
return Promise.new(function(resolve, reject)
|
||||
coroutine.wrap(function()
|
||||
local success, response = pcall(function()
|
||||
return HttpService:RequestAsync(requestParams)
|
||||
end)
|
||||
|
||||
if success then
|
||||
Log.trace("Request {} success, status code {}", requestId, response.StatusCode)
|
||||
resolve(HttpResponse.fromRobloxResponse(response))
|
||||
else
|
||||
Log.trace("Request {} failure: {:?}", requestId, response)
|
||||
reject(HttpError.fromRobloxErrorString(response))
|
||||
end
|
||||
end)()
|
||||
end)
|
||||
end
|
||||
|
||||
function Http.get(url)
|
||||
return performRequest({
|
||||
Url = url,
|
||||
Method = "GET",
|
||||
})
|
||||
end
|
||||
|
||||
function Http.post(url, body)
|
||||
return performRequest({
|
||||
Url = url,
|
||||
Method = "POST",
|
||||
Body = body,
|
||||
})
|
||||
end
|
||||
|
||||
function Http.jsonEncode(object)
|
||||
return HttpService:JSONEncode(object)
|
||||
end
|
||||
|
||||
function Http.jsonDecode(source)
|
||||
return HttpService:JSONDecode(source)
|
||||
end
|
||||
|
||||
return Http
|
||||
5
plugin/http/init.spec.lua
Normal file
5
plugin/http/init.spec.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
return function()
|
||||
it("should load", function()
|
||||
require(script.Parent)
|
||||
end)
|
||||
end
|
||||
56
plugin/log/init.lua
Normal file
56
plugin/log/init.lua
Normal file
@@ -0,0 +1,56 @@
|
||||
local Fmt = require(script.Parent.Fmt)
|
||||
|
||||
local Level = {
|
||||
Error = 0,
|
||||
Warning = 1,
|
||||
Info = 2,
|
||||
Debug = 3,
|
||||
Trace = 4,
|
||||
}
|
||||
|
||||
local function getLogLevel()
|
||||
return Level.Info
|
||||
end
|
||||
|
||||
local function addTags(tag, message)
|
||||
return tag .. message:gsub("\n", "\n" .. tag)
|
||||
end
|
||||
|
||||
local TRACE_TAG = (" "):rep(15) .. "[Rojo-Trace] "
|
||||
local INFO_TAG = (" "):rep(15) .. "[Rojo-Info] "
|
||||
local DEBUG_TAG = (" "):rep(15) .. "[Rojo-Debug] "
|
||||
local WARN_TAG = "[Rojo-Warn] "
|
||||
|
||||
local Log = {}
|
||||
|
||||
Log.Level = Level
|
||||
|
||||
function Log.setLogLevelThunk(thunk)
|
||||
getLogLevel = thunk
|
||||
end
|
||||
|
||||
function Log.trace(template, ...)
|
||||
if getLogLevel() >= Level.Trace then
|
||||
print(addTags(TRACE_TAG, Fmt.fmt(template, ...)))
|
||||
end
|
||||
end
|
||||
|
||||
function Log.info(template, ...)
|
||||
if getLogLevel() >= Level.Info then
|
||||
print(addTags(INFO_TAG, Fmt.fmt(template, ...)))
|
||||
end
|
||||
end
|
||||
|
||||
function Log.debug(template, ...)
|
||||
if getLogLevel() >= Level.Debug then
|
||||
print(addTags(DEBUG_TAG, Fmt.fmt(template, ...)))
|
||||
end
|
||||
end
|
||||
|
||||
function Log.warn(template, ...)
|
||||
if getLogLevel() >= Level.Warning then
|
||||
warn(addTags(WARN_TAG, Fmt.fmt(template, ...)))
|
||||
end
|
||||
end
|
||||
|
||||
return Log
|
||||
5
plugin/log/init.spec.lua
Normal file
5
plugin/log/init.spec.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
return function()
|
||||
it("should load", function()
|
||||
require(script.Parent)
|
||||
end)
|
||||
end
|
||||
1
plugin/modules/promise
Submodule
1
plugin/modules/promise
Submodule
Submodule plugin/modules/promise added at 7fb09d103f
1
plugin/modules/rbx-dom
Submodule
1
plugin/modules/rbx-dom
Submodule
Submodule plugin/modules/rbx-dom added at 5bca08fec3
1
plugin/modules/roact
Submodule
1
plugin/modules/roact
Submodule
Submodule plugin/modules/roact added at f7d2f1ce1d
1
plugin/modules/t
Submodule
1
plugin/modules/t
Submodule
Submodule plugin/modules/t added at f643b50682
1
plugin/modules/testez
Submodule
1
plugin/modules/testez
Submodule
Submodule plugin/modules/testez added at 6e9157db3c
236
plugin/src/ApiContext.lua
Normal file
236
plugin/src/ApiContext.lua
Normal file
@@ -0,0 +1,236 @@
|
||||
local Http = require(script.Parent.Parent.Http)
|
||||
local Log = require(script.Parent.Parent.Log)
|
||||
local Promise = require(script.Parent.Parent.Promise)
|
||||
|
||||
local Config = require(script.Parent.Config)
|
||||
local Types = require(script.Parent.Types)
|
||||
local Version = require(script.Parent.Version)
|
||||
|
||||
local validateApiInfo = Types.ifEnabled(Types.ApiInfoResponse)
|
||||
local validateApiRead = Types.ifEnabled(Types.ApiReadResponse)
|
||||
local validateApiSubscribe = Types.ifEnabled(Types.ApiSubscribeResponse)
|
||||
|
||||
--[[
|
||||
Returns a promise that will never resolve nor reject.
|
||||
]]
|
||||
local function hangingPromise()
|
||||
return Promise.new(function() end)
|
||||
end
|
||||
|
||||
local function rejectFailedRequests(response)
|
||||
if response.code >= 400 then
|
||||
local message = string.format("HTTP %s:\n%s", tostring(response.code), response.body)
|
||||
|
||||
return Promise.reject(message)
|
||||
end
|
||||
|
||||
return response
|
||||
end
|
||||
|
||||
local function rejectWrongProtocolVersion(infoResponseBody)
|
||||
if infoResponseBody.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/rojo-rbx/rojo for more details."
|
||||
):format(
|
||||
Version.display(Config.version), Config.protocolVersion,
|
||||
Config.expectedServerVersionString,
|
||||
infoResponseBody.serverVersion, infoResponseBody.protocolVersion
|
||||
)
|
||||
|
||||
return Promise.reject(message)
|
||||
end
|
||||
|
||||
return Promise.resolve(infoResponseBody)
|
||||
end
|
||||
|
||||
local function rejectWrongPlaceId(infoResponseBody)
|
||||
if infoResponseBody.expectedPlaceIds ~= nil then
|
||||
local foundId = false
|
||||
|
||||
for _, id in ipairs(infoResponseBody.expectedPlaceIds) do
|
||||
if id == game.PlaceId then
|
||||
foundId = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not foundId then
|
||||
local idList = {}
|
||||
for _, id in ipairs(infoResponseBody.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 your .project.json file."
|
||||
):format(
|
||||
tostring(game.PlaceId),
|
||||
table.concat(idList, "\n")
|
||||
)
|
||||
|
||||
return Promise.reject(message)
|
||||
end
|
||||
end
|
||||
|
||||
return Promise.resolve(infoResponseBody)
|
||||
end
|
||||
|
||||
local ApiContext = {}
|
||||
ApiContext.__index = ApiContext
|
||||
|
||||
function ApiContext.new(baseUrl)
|
||||
assert(type(baseUrl) == "string")
|
||||
|
||||
local self = {
|
||||
__baseUrl = baseUrl,
|
||||
__sessionId = nil,
|
||||
__messageCursor = -1,
|
||||
__connected = true,
|
||||
}
|
||||
|
||||
return setmetatable(self, ApiContext)
|
||||
end
|
||||
|
||||
function ApiContext:__fmtDebug(output)
|
||||
output:writeLine("ApiContext {{")
|
||||
output:indent()
|
||||
|
||||
output:writeLine("Connected: {}", self.__connected)
|
||||
output:writeLine("Base URL: {}", self.__baseUrl)
|
||||
output:writeLine("Session ID: {}", self.__sessionId)
|
||||
output:writeLine("Message Cursor: {}", self.__messageCursor)
|
||||
|
||||
output:unindent()
|
||||
output:write("}")
|
||||
end
|
||||
|
||||
function ApiContext:disconnect()
|
||||
self.__connected = false
|
||||
end
|
||||
|
||||
function ApiContext:setMessageCursor(index)
|
||||
self.__messageCursor = index
|
||||
end
|
||||
|
||||
function ApiContext:connect()
|
||||
local url = ("%s/api/rojo"):format(self.__baseUrl)
|
||||
|
||||
return Http.get(url)
|
||||
:andThen(rejectFailedRequests)
|
||||
:andThen(Http.Response.json)
|
||||
:andThen(rejectWrongProtocolVersion)
|
||||
:andThen(function(body)
|
||||
assert(validateApiInfo(body))
|
||||
|
||||
return body
|
||||
end)
|
||||
:andThen(rejectWrongPlaceId)
|
||||
:andThen(function(body)
|
||||
self.__sessionId = body.sessionId
|
||||
|
||||
return body
|
||||
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(Http.Response.json)
|
||||
:andThen(function(body)
|
||||
if body.sessionId ~= self.__sessionId then
|
||||
return Promise.reject("Server changed ID")
|
||||
end
|
||||
|
||||
assert(validateApiRead(body))
|
||||
|
||||
return body
|
||||
end)
|
||||
end
|
||||
|
||||
function ApiContext:write(patch)
|
||||
local url = ("%s/api/write"):format(self.__baseUrl)
|
||||
|
||||
local updated = {}
|
||||
for _, update in ipairs(patch.updated) do
|
||||
local fixedUpdate = {
|
||||
id = update.id,
|
||||
changedName = update.changedName,
|
||||
}
|
||||
|
||||
if next(update.changedProperties) ~= nil then
|
||||
fixedUpdate.changedProperties = update.changedProperties
|
||||
end
|
||||
|
||||
table.insert(updated, fixedUpdate)
|
||||
end
|
||||
|
||||
-- Only add the 'added' field if the table is non-empty, or else Roblox's
|
||||
-- JSON implementation will turn the table into an array instead of an
|
||||
-- object, causing API validation to fail.
|
||||
local added
|
||||
if next(patch.added) ~= nil then
|
||||
added = patch.added
|
||||
end
|
||||
|
||||
local body = {
|
||||
sessionId = self.__sessionId,
|
||||
removed = patch.removed,
|
||||
updated = updated,
|
||||
added = added,
|
||||
}
|
||||
|
||||
body = Http.jsonEncode(body)
|
||||
|
||||
return Http.post(url, body)
|
||||
:andThen(rejectFailedRequests)
|
||||
:andThen(Http.Response.json)
|
||||
:andThen(function(body)
|
||||
Log.info("Write response: {:?}", body)
|
||||
|
||||
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 == Http.Error.Kind.Timeout then
|
||||
if self.__connected then
|
||||
return sendRequest()
|
||||
else
|
||||
return hangingPromise()
|
||||
end
|
||||
end
|
||||
|
||||
return Promise.reject(err)
|
||||
end)
|
||||
end
|
||||
|
||||
return sendRequest()
|
||||
:andThen(rejectFailedRequests)
|
||||
:andThen(Http.Response.json)
|
||||
:andThen(function(body)
|
||||
if body.sessionId ~= self.__sessionId then
|
||||
return Promise.reject("Server changed ID")
|
||||
end
|
||||
|
||||
assert(validateApiSubscribe(body))
|
||||
|
||||
self:setMessageCursor(body.messageCursor)
|
||||
|
||||
return body.messages
|
||||
end)
|
||||
end
|
||||
|
||||
return ApiContext
|
||||
34
plugin/src/Assets.lua
Normal file
34
plugin/src/Assets.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
local strict = require(script.Parent.strict)
|
||||
|
||||
local Assets = {
|
||||
Sprites = {},
|
||||
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://3405346157",
|
||||
Icon = "rbxassetid://3405341609",
|
||||
},
|
||||
StartSession = "",
|
||||
SessionActive = "",
|
||||
Configure = "",
|
||||
}
|
||||
|
||||
local function guardForTypos(name, map)
|
||||
strict(name, map)
|
||||
|
||||
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
|
||||
228
plugin/src/Components/App.lua
Normal file
228
plugin/src/Components/App.lua
Normal file
@@ -0,0 +1,228 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
local Plugin = Rojo.Plugin
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
local Log = require(Rojo.Log)
|
||||
|
||||
local ApiContext = require(Plugin.ApiContext)
|
||||
local Assets = require(Plugin.Assets)
|
||||
local Config = require(Plugin.Config)
|
||||
local DevSettings = require(Plugin.DevSettings)
|
||||
local ServeSession = require(Plugin.ServeSession)
|
||||
local Version = require(Plugin.Version)
|
||||
local preloadAssets = require(Plugin.preloadAssets)
|
||||
local strict = require(Plugin.strict)
|
||||
|
||||
local Theme = require(Plugin.Components.Theme)
|
||||
local ConnectPanel = require(Plugin.Components.ConnectPanel)
|
||||
local ConnectingPanel = require(Plugin.Components.ConnectingPanel)
|
||||
local ConnectionActivePanel = require(Plugin.Components.ConnectionActivePanel)
|
||||
local ErrorPanel = require(Plugin.Components.ErrorPanel)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
Log.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 AppStatus = strict("AppStatus", {
|
||||
NotStarted = "NotStarted",
|
||||
Connecting = "Connecting",
|
||||
Connected = "Connected",
|
||||
Error = "Error",
|
||||
})
|
||||
|
||||
local App = Roact.Component:extend("App")
|
||||
|
||||
function App:init()
|
||||
self:setState({
|
||||
appStatus = AppStatus.NotStarted,
|
||||
errorMessage = nil,
|
||||
})
|
||||
|
||||
self.signals = {}
|
||||
self.serveSession = nil
|
||||
|
||||
self.displayedVersion = DevSettings:isEnabled()
|
||||
and Config.codename
|
||||
or Version.display(Config.version)
|
||||
|
||||
local toolbar = self.props.plugin:CreateToolbar("Rojo " .. self.displayedVersion)
|
||||
|
||||
self.toggleButton = toolbar:CreateButton(
|
||||
"Rojo",
|
||||
"Show or hide the Rojo panel",
|
||||
Assets.Images.Icon)
|
||||
self.toggleButton.ClickableWhenViewportHidden = true
|
||||
self.toggleButton.Click:Connect(function()
|
||||
self.dockWidget.Enabled = not self.dockWidget.Enabled
|
||||
end)
|
||||
|
||||
local widgetInfo = DockWidgetPluginGuiInfo.new(
|
||||
Enum.InitialDockState.Right,
|
||||
false, -- Initially enabled state
|
||||
false, -- Whether to override the widget's previous state
|
||||
360, 190, -- Floating size
|
||||
360, 190 -- Minimum size
|
||||
)
|
||||
|
||||
self.dockWidget = self.props.plugin:CreateDockWidgetPluginGui("Rojo-" .. self.displayedVersion, widgetInfo)
|
||||
self.dockWidget.Name = "Rojo " .. self.displayedVersion
|
||||
self.dockWidget.Title = "Rojo " .. self.displayedVersion
|
||||
self.dockWidget.AutoLocalize = false
|
||||
self.dockWidget.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
||||
|
||||
self.signals.dockWidgetEnabled = self.dockWidget:GetPropertyChangedSignal("Enabled"):Connect(function()
|
||||
self.toggleButton:SetActive(self.dockWidget.Enabled)
|
||||
end)
|
||||
end
|
||||
|
||||
function App:startSession(address, port)
|
||||
Log.trace("Starting new session")
|
||||
|
||||
local baseUrl = ("http://%s:%s"):format(address, port)
|
||||
self.serveSession = ServeSession.new({
|
||||
apiContext = ApiContext.new(baseUrl),
|
||||
})
|
||||
|
||||
self.serveSession:onStatusChanged(function(status, details)
|
||||
if status == ServeSession.Status.Connecting then
|
||||
self:setState({
|
||||
appStatus = AppStatus.Connecting,
|
||||
})
|
||||
elseif status == ServeSession.Status.Connected then
|
||||
self:setState({
|
||||
appStatus = AppStatus.Connected,
|
||||
})
|
||||
elseif status == ServeSession.Status.Disconnected then
|
||||
self.serveSession = nil
|
||||
|
||||
-- Details being present indicates that this
|
||||
-- disconnection was from an error.
|
||||
if details ~= nil then
|
||||
Log.warn("Disconnected from an error: {}", details)
|
||||
|
||||
self:setState({
|
||||
appStatus = AppStatus.Error,
|
||||
errorMessage = tostring(details),
|
||||
})
|
||||
else
|
||||
self:setState({
|
||||
appStatus = AppStatus.NotStarted,
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
self.serveSession:start()
|
||||
end
|
||||
|
||||
function App:render()
|
||||
local children
|
||||
|
||||
if self.state.appStatus == AppStatus.NotStarted then
|
||||
children = {
|
||||
ConnectPanel = e(ConnectPanel, {
|
||||
startSession = function(address, port)
|
||||
self:startSession(address, port)
|
||||
end,
|
||||
cancel = function()
|
||||
Log.trace("Canceling session configuration")
|
||||
|
||||
self:setState({
|
||||
appStatus = AppStatus.NotStarted,
|
||||
})
|
||||
end,
|
||||
}),
|
||||
}
|
||||
elseif self.state.appStatus == AppStatus.Connecting then
|
||||
children = {
|
||||
ConnectingPanel = Roact.createElement(ConnectingPanel),
|
||||
}
|
||||
elseif self.state.appStatus == AppStatus.Connected then
|
||||
children = {
|
||||
ConnectionActivePanel = e(ConnectionActivePanel, {
|
||||
stopSession = function()
|
||||
Log.trace("Disconnecting session")
|
||||
|
||||
self.serveSession:stop()
|
||||
self.serveSession = nil
|
||||
self:setState({
|
||||
appStatus = AppStatus.NotStarted,
|
||||
})
|
||||
|
||||
Log.trace("Session terminated by user")
|
||||
end,
|
||||
}),
|
||||
}
|
||||
elseif self.state.appStatus == AppStatus.Error then
|
||||
children = {
|
||||
ErrorPanel = Roact.createElement(ErrorPanel, {
|
||||
errorMessage = self.state.errorMessage,
|
||||
onDismiss = function()
|
||||
self:setState({
|
||||
appStatus = AppStatus.NotStarted,
|
||||
})
|
||||
end,
|
||||
}),
|
||||
}
|
||||
end
|
||||
|
||||
return Roact.createElement(Theme.StudioProvider, nil, {
|
||||
UI = Roact.createElement(Roact.Portal, {
|
||||
target = self.dockWidget,
|
||||
}, children),
|
||||
})
|
||||
end
|
||||
|
||||
function App:didMount()
|
||||
Log.trace("Rojo {} initializing", self.displayedVersion)
|
||||
|
||||
checkUpgrade(self.props.plugin)
|
||||
preloadAssets()
|
||||
end
|
||||
|
||||
function App:willUnmount()
|
||||
if self.serveSession ~= nil then
|
||||
self.serveSession:stop()
|
||||
self.serveSession = nil
|
||||
end
|
||||
|
||||
for _, signal in pairs(self.signals) do
|
||||
signal:Disconnect()
|
||||
end
|
||||
end
|
||||
|
||||
return App
|
||||
163
plugin/src/Components/ConnectPanel.lua
Normal file
163
plugin/src/Components/ConnectPanel.lua
Normal file
@@ -0,0 +1,163 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
local Plugin = Rojo.Plugin
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
|
||||
local Config = require(Plugin.Config)
|
||||
|
||||
local Theme = require(Plugin.Components.Theme)
|
||||
local Panel = require(Plugin.Components.Panel)
|
||||
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 e = Roact.createElement
|
||||
|
||||
local ConnectPanel = Roact.Component:extend("ConnectPanel")
|
||||
|
||||
function ConnectPanel:init()
|
||||
self:setState({
|
||||
address = "",
|
||||
port = "",
|
||||
})
|
||||
end
|
||||
|
||||
function ConnectPanel:render()
|
||||
local startSession = self.props.startSession
|
||||
|
||||
return Theme.with(function(theme)
|
||||
return e(Panel, nil, {
|
||||
Layout = e("UIListLayout", {
|
||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||
VerticalAlignment = Enum.VerticalAlignment.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.Text1,
|
||||
}),
|
||||
|
||||
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.Text1,
|
||||
}),
|
||||
|
||||
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 = 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,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
return ConnectPanel
|
||||
35
plugin/src/Components/ConnectingPanel.lua
Normal file
35
plugin/src/Components/ConnectingPanel.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Plugin = script:FindFirstAncestor("Plugin")
|
||||
|
||||
local Theme = require(Plugin.Components.Theme)
|
||||
local Panel = require(Plugin.Components.Panel)
|
||||
local FitText = require(Plugin.Components.FitText)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local ConnectingPanel = Roact.Component:extend("ConnectingPanel")
|
||||
|
||||
function ConnectingPanel:render()
|
||||
return Theme.with(function(theme)
|
||||
return e(Panel, nil, {
|
||||
Layout = Roact.createElement("UIListLayout", {
|
||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||
VerticalAlignment = Enum.VerticalAlignment.Center,
|
||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||
Padding = UDim.new(0, 8),
|
||||
}),
|
||||
|
||||
Text = e(FitText, {
|
||||
Padding = Vector2.new(12, 6),
|
||||
Font = theme.ButtonFont,
|
||||
TextSize = 18,
|
||||
Text = "Connecting...",
|
||||
TextColor3 = theme.Text1,
|
||||
BackgroundTransparency = 1,
|
||||
}),
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
return ConnectingPanel
|
||||
47
plugin/src/Components/ConnectionActivePanel.lua
Normal file
47
plugin/src/Components/ConnectionActivePanel.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Plugin = script:FindFirstAncestor("Plugin")
|
||||
|
||||
local Theme = require(Plugin.Components.Theme)
|
||||
local Panel = require(Plugin.Components.Panel)
|
||||
local FitText = require(Plugin.Components.FitText)
|
||||
local FormButton = require(Plugin.Components.FormButton)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local ConnectionActivePanel = Roact.Component:extend("ConnectionActivePanel")
|
||||
|
||||
function ConnectionActivePanel:render()
|
||||
local stopSession = self.props.stopSession
|
||||
|
||||
return Theme.with(function(theme)
|
||||
return e(Panel, nil, {
|
||||
Layout = Roact.createElement("UIListLayout", {
|
||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||
VerticalAlignment = Enum.VerticalAlignment.Center,
|
||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||
Padding = UDim.new(0, 8),
|
||||
}),
|
||||
|
||||
Text = e(FitText, {
|
||||
Padding = Vector2.new(12, 6),
|
||||
Font = theme.ButtonFont,
|
||||
TextSize = 18,
|
||||
Text = "Connected to Live-Sync Server",
|
||||
TextColor3 = theme.Text1,
|
||||
BackgroundTransparency = 1,
|
||||
}),
|
||||
|
||||
DisconnectButton = e(FormButton, {
|
||||
layoutOrder = 2,
|
||||
text = "Disconnect",
|
||||
secondary = true,
|
||||
onClick = function()
|
||||
stopSession()
|
||||
end,
|
||||
}),
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
return ConnectionActivePanel
|
||||
70
plugin/src/Components/ErrorPanel.lua
Normal file
70
plugin/src/Components/ErrorPanel.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Plugin = script:FindFirstAncestor("Plugin")
|
||||
|
||||
local Theme = require(Plugin.Components.Theme)
|
||||
local Panel = require(Plugin.Components.Panel)
|
||||
local FitText = require(Plugin.Components.FitText)
|
||||
local FitScrollingFrame = require(Plugin.Components.FitScrollingFrame)
|
||||
local FormButton = require(Plugin.Components.FormButton)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local BUTTON_HEIGHT = 60
|
||||
local HOR_PADDING = 8
|
||||
|
||||
local ErrorPanel = Roact.Component:extend("ErrorPanel")
|
||||
|
||||
function ErrorPanel:render()
|
||||
local errorMessage = self.props.errorMessage
|
||||
local onDismiss = self.props.onDismiss
|
||||
|
||||
return Theme.with(function(theme)
|
||||
return e(Panel, nil, {
|
||||
Layout = Roact.createElement("UIListLayout", {
|
||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||
VerticalAlignment = Enum.VerticalAlignment.Center,
|
||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||
Padding = UDim.new(0, 8),
|
||||
}),
|
||||
|
||||
ErrorContainer = e(FitScrollingFrame, {
|
||||
containerProps = {
|
||||
BackgroundTransparency = 1,
|
||||
BorderSizePixel = 0,
|
||||
Size = UDim2.new(1, -HOR_PADDING * 2, 1, -BUTTON_HEIGHT),
|
||||
Position = UDim2.new(0, HOR_PADDING, 0, 0),
|
||||
ScrollBarImageColor3 = theme.Text1,
|
||||
VerticalScrollBarInset = Enum.ScrollBarInset.ScrollBar,
|
||||
ScrollingDirection = Enum.ScrollingDirection.Y,
|
||||
},
|
||||
}, {
|
||||
Text = e(FitText, {
|
||||
Size = UDim2.new(1, 0, 0, 0),
|
||||
|
||||
LayoutOrder = 1,
|
||||
TextXAlignment = Enum.TextXAlignment.Left,
|
||||
TextYAlignment = Enum.TextYAlignment.Top,
|
||||
FitAxis = "Y",
|
||||
Font = theme.ButtonFont,
|
||||
TextSize = 18,
|
||||
Text = errorMessage,
|
||||
TextWrap = true,
|
||||
TextColor3 = theme.Text1,
|
||||
BackgroundTransparency = 1,
|
||||
}),
|
||||
}),
|
||||
|
||||
DismissButton = e(FormButton, {
|
||||
layoutOrder = 2,
|
||||
text = "Dismiss",
|
||||
secondary = true,
|
||||
onClick = function()
|
||||
onDismiss()
|
||||
end,
|
||||
}),
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
return ErrorPanel
|
||||
63
plugin/src/Components/FitList.lua
Normal file
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
|
||||
33
plugin/src/Components/FitScrollingFrame.lua
Normal file
33
plugin/src/Components/FitScrollingFrame.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Dictionary = require(script.Parent.Parent.Dictionary)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local FitScrollingFrame = Roact.Component:extend("FitScrollingFrame")
|
||||
|
||||
function FitScrollingFrame:init()
|
||||
self.sizeBinding, self.setSize = Roact.createBinding(UDim2.new())
|
||||
end
|
||||
|
||||
function FitScrollingFrame:render()
|
||||
local containerProps = self.props.containerProps
|
||||
local layoutProps = self.props.layoutProps
|
||||
|
||||
local children = Dictionary.merge(self.props[Roact.Children], {
|
||||
["$Layout"] = e("UIListLayout", Dictionary.merge({
|
||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||
[Roact.Change.AbsoluteContentSize] = function(instance)
|
||||
self.setSize(UDim2.new(0, 0, 0, instance.AbsoluteContentSize.Y))
|
||||
end,
|
||||
}, layoutProps)),
|
||||
})
|
||||
|
||||
local fullContainerProps = Dictionary.merge(containerProps, {
|
||||
CanvasSize = self.sizeBinding,
|
||||
})
|
||||
|
||||
return e("ScrollingFrame", fullContainerProps, children)
|
||||
end
|
||||
|
||||
return FitScrollingFrame
|
||||
88
plugin/src/Components/FitText.lua
Normal file
88
plugin/src/Components/FitText.lua
Normal file
@@ -0,0 +1,88 @@
|
||||
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.ref = Roact.createRef()
|
||||
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, {
|
||||
FitAxis = Dictionary.None,
|
||||
Kind = Dictionary.None,
|
||||
Padding = Dictionary.None,
|
||||
MinSize = Dictionary.None,
|
||||
Size = self.sizeBinding,
|
||||
[Roact.Ref] = self.ref,
|
||||
[Roact.Change.AbsoluteSize] = function()
|
||||
self:updateTextMeasurements()
|
||||
end
|
||||
})
|
||||
|
||||
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 fitAxis = self.props.FitAxis or "XY"
|
||||
local baseSize = self.props.Size
|
||||
|
||||
local text = self.props.Text or ""
|
||||
local font = self.props.Font or Enum.Font.Legacy
|
||||
local textSize = self.props.TextSize or 12
|
||||
|
||||
local containerSize = self.ref.current.AbsoluteSize
|
||||
|
||||
local textBounds
|
||||
|
||||
if fitAxis == "XY" then
|
||||
textBounds = Vector2.new(9e6, 9e6)
|
||||
elseif fitAxis == "X" then
|
||||
textBounds = Vector2.new(9e6, containerSize.Y - padding.Y * 2)
|
||||
elseif fitAxis == "Y" then
|
||||
textBounds = Vector2.new(containerSize.X - padding.X * 2, 9e6)
|
||||
end
|
||||
|
||||
local measuredText = TextService:GetTextSize(text, textSize, font, textBounds)
|
||||
|
||||
local computedX = math.max(minSize.X, padding.X * 2 + measuredText.X)
|
||||
local computedY = math.max(minSize.Y, padding.Y * 2 + measuredText.Y)
|
||||
|
||||
local totalSize
|
||||
|
||||
if fitAxis == "XY" then
|
||||
totalSize = UDim2.new(
|
||||
0, computedX,
|
||||
0, computedY)
|
||||
elseif fitAxis == "X" then
|
||||
totalSize = UDim2.new(
|
||||
0, computedX,
|
||||
baseSize.Y.Scale, baseSize.Y.Offset)
|
||||
elseif fitAxis == "Y" then
|
||||
totalSize = UDim2.new(
|
||||
baseSize.X.Scale, baseSize.X.Offset,
|
||||
0, computedY)
|
||||
end
|
||||
|
||||
self.setSize(totalSize)
|
||||
end
|
||||
|
||||
return FitText
|
||||
64
plugin/src/Components/FormButton.lua
Normal file
64
plugin/src/Components/FormButton.lua
Normal file
@@ -0,0 +1,64 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
local Plugin = Rojo.Plugin
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
|
||||
local Assets = require(Plugin.Assets)
|
||||
local Theme = require(Plugin.Components.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
|
||||
|
||||
return Theme.with(function(theme)
|
||||
if props.secondary then
|
||||
textColor = theme.Brand1
|
||||
backgroundColor = theme.Background2
|
||||
else
|
||||
textColor = theme.TextOnAccent
|
||||
backgroundColor = theme.Brand1
|
||||
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)
|
||||
end
|
||||
|
||||
return FormButton
|
||||
82
plugin/src/Components/FormTextInput.lua
Normal file
82
plugin/src/Components/FormTextInput.lua
Normal file
@@ -0,0 +1,82 @@
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
local Plugin = Rojo.Plugin
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
|
||||
local Assets = require(Plugin.Assets)
|
||||
local Theme = require(Plugin.Components.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 Theme.with(function(theme)
|
||||
return e("ImageLabel", {
|
||||
LayoutOrder = layoutOrder,
|
||||
Image = RoundBox.asset,
|
||||
ImageRectOffset = RoundBox.offset,
|
||||
ImageRectSize = RoundBox.size,
|
||||
ScaleType = Enum.ScaleType.Slice,
|
||||
SliceCenter = RoundBox.center,
|
||||
ImageColor3 = theme.Background2,
|
||||
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.Text2,
|
||||
TextColor3 = theme.Text1,
|
||||
|
||||
[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)
|
||||
end
|
||||
|
||||
return FormTextInput
|
||||
38
plugin/src/Components/Panel.lua
Normal file
38
plugin/src/Components/Panel.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
|
||||
|
||||
local Plugin = script:FindFirstAncestor("Plugin")
|
||||
|
||||
local RojoFooter = require(Plugin.Components.RojoFooter)
|
||||
local Theme = require(Plugin.Components.Theme)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local Panel = Roact.Component:extend("Panel")
|
||||
|
||||
function Panel:init()
|
||||
self.footerSize, self.setFooterSize = Roact.createBinding(Vector2.new())
|
||||
end
|
||||
|
||||
function Panel:render()
|
||||
return Theme.with(function(theme)
|
||||
return e("Frame", {
|
||||
Size = UDim2.new(1, 0, 1, 0),
|
||||
BackgroundTransparency = 1,
|
||||
}, {
|
||||
Layout = Roact.createElement("UIListLayout", {
|
||||
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
||||
SortOrder = Enum.SortOrder.LayoutOrder,
|
||||
}),
|
||||
|
||||
Body = e("Frame", {
|
||||
Size = UDim2.new(0, 360, 1, -32),
|
||||
BackgroundColor3 = theme.Background1,
|
||||
BorderSizePixel = 0,
|
||||
}, self.props[Roact.Children]),
|
||||
|
||||
Footer = e(RojoFooter),
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
return Panel
|
||||
70
plugin/src/Components/RojoFooter.lua
Normal file
70
plugin/src/Components/RojoFooter.lua
Normal file
@@ -0,0 +1,70 @@
|
||||
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.Components.Theme)
|
||||
|
||||
local e = Roact.createElement
|
||||
|
||||
local RojoFooter = Roact.Component:extend("RojoFooter")
|
||||
|
||||
function RojoFooter:init()
|
||||
self.footerSize, self.setFooterSize = Roact.createBinding(Vector2.new())
|
||||
self.footerVersionSize, self.setFooterVersionSize = Roact.createBinding(Vector2.new())
|
||||
end
|
||||
|
||||
function RojoFooter:render()
|
||||
return Theme.with(function(theme)
|
||||
return e("Frame", {
|
||||
LayoutOrder = 3,
|
||||
Size = UDim2.new(1, 0, 0, 32),
|
||||
BackgroundColor3 = theme.Background2,
|
||||
BorderSizePixel = 0,
|
||||
ZIndex = 2,
|
||||
}, {
|
||||
Padding = e("UIPadding", {
|
||||
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 = UDim2.new(0, 0, 0, 32),
|
||||
}, {
|
||||
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("TextLabel", {
|
||||
Position = UDim2.new(1, 0, 0, 0),
|
||||
Size = UDim2.new(0, 0, 1, 0),
|
||||
AnchorPoint = Vector2.new(1, 0),
|
||||
Font = theme.TitleFont,
|
||||
TextSize = 18,
|
||||
Text = Version.display(Config.version),
|
||||
TextXAlignment = Enum.TextXAlignment.Right,
|
||||
TextColor3 = theme.Text2,
|
||||
BackgroundTransparency = 1,
|
||||
|
||||
[Roact.Change.AbsoluteSize] = function(rbx)
|
||||
self.setFooterVersionSize(rbx.AbsoluteSize)
|
||||
end,
|
||||
}),
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
return RojoFooter
|
||||
104
plugin/src/Components/Theme.lua
Normal file
104
plugin/src/Components/Theme.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
--[[
|
||||
Theming system taking advantage of Roact's new context API.
|
||||
|
||||
Doesn't use colors provided by Studio and instead just branches on theme
|
||||
name. This isn't exactly best practice.
|
||||
]]
|
||||
|
||||
local Studio = settings():GetService("Studio")
|
||||
|
||||
local Rojo = script:FindFirstAncestor("Rojo")
|
||||
|
||||
local Roact = require(Rojo.Roact)
|
||||
local Log = require(Rojo.Log)
|
||||
|
||||
local strict = require(script.Parent.Parent.strict)
|
||||
|
||||
local lightTheme = strict("Theme", {
|
||||
ButtonFont = Enum.Font.GothamSemibold,
|
||||
InputFont = Enum.Font.Code,
|
||||
TitleFont = Enum.Font.GothamBold,
|
||||
MainFont = Enum.Font.Gotham,
|
||||
|
||||
Brand1 = Color3.fromRGB(225, 56, 53),
|
||||
|
||||
Text1 = Color3.fromRGB(64, 64, 64),
|
||||
Text2 = Color3.fromRGB(160, 160, 160),
|
||||
TextOnAccent = Color3.fromRGB(235, 235, 235),
|
||||
|
||||
Background1 = Color3.fromRGB(255, 255, 255),
|
||||
Background2 = Color3.fromRGB(235, 235, 235),
|
||||
})
|
||||
|
||||
local darkTheme = strict("Theme", {
|
||||
ButtonFont = Enum.Font.GothamSemibold,
|
||||
InputFont = Enum.Font.Code,
|
||||
TitleFont = Enum.Font.GothamBold,
|
||||
MainFont = Enum.Font.Gotham,
|
||||
|
||||
Brand1 = Color3.fromRGB(225, 56, 53),
|
||||
|
||||
Text1 = Color3.fromRGB(235, 235, 235),
|
||||
Text2 = Color3.fromRGB(200, 200, 200),
|
||||
TextOnAccent = Color3.fromRGB(235, 235, 235),
|
||||
|
||||
Background1 = Color3.fromRGB(48, 48, 48),
|
||||
Background2 = Color3.fromRGB(64, 64, 64),
|
||||
})
|
||||
|
||||
local Context = Roact.createContext(lightTheme)
|
||||
|
||||
local StudioProvider = Roact.Component:extend("StudioProvider")
|
||||
|
||||
-- Pull the current theme from Roblox Studio and update state with it.
|
||||
function StudioProvider:updateTheme()
|
||||
local studioTheme = Studio.Theme
|
||||
|
||||
if studioTheme.Name == "Light" then
|
||||
self:setState({
|
||||
theme = lightTheme,
|
||||
})
|
||||
elseif studioTheme.Name == "Dark" then
|
||||
self:setState({
|
||||
theme = darkTheme,
|
||||
})
|
||||
else
|
||||
Log.warn("Unexpected theme '{}'' -- falling back to light theme!", studioTheme.Name)
|
||||
|
||||
self:setState({
|
||||
theme = lightTheme,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function StudioProvider:init()
|
||||
self:updateTheme()
|
||||
end
|
||||
|
||||
function StudioProvider:render()
|
||||
return Roact.createElement(Context.Provider, {
|
||||
value = self.state.theme,
|
||||
}, self.props[Roact.Children])
|
||||
end
|
||||
|
||||
function StudioProvider:didMount()
|
||||
self.connection = Studio.ThemeChanged:Connect(function()
|
||||
self:updateTheme()
|
||||
end)
|
||||
end
|
||||
|
||||
function StudioProvider:willUnmount()
|
||||
self.connection:Disconnect()
|
||||
end
|
||||
|
||||
local function with(callback)
|
||||
return Roact.createElement(Context.Consumer, {
|
||||
render = callback,
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
StudioProvider = StudioProvider,
|
||||
Consumer = Context.Consumer,
|
||||
with = with,
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
return {
|
||||
pollingRate = 0.3,
|
||||
version = "v0.2.3",
|
||||
dev = false,
|
||||
}
|
||||
local strict = require(script.Parent.strict)
|
||||
|
||||
local isDevBuild = script.Parent.Parent:FindFirstChild("ROJO_DEV_BUILD") ~= nil
|
||||
|
||||
return strict("Config", {
|
||||
isDevBuild = isDevBuild,
|
||||
codename = "Epiphany",
|
||||
version = {0, 6, 0, "-alpha.2"},
|
||||
expectedServerVersionString = "0.6.0 or newer",
|
||||
protocolVersion = 3,
|
||||
defaultHost = "localhost",
|
||||
defaultPort = 34872,
|
||||
})
|
||||
151
plugin/src/DevSettings.lua
Normal file
151
plugin/src/DevSettings.lua
Normal file
@@ -0,0 +1,151 @@
|
||||
local Config = require(script.Parent.Config)
|
||||
|
||||
local Environment = {
|
||||
User = "User",
|
||||
Dev = "Dev",
|
||||
Test = "Test",
|
||||
}
|
||||
|
||||
local DEFAULT_ENVIRONMENT = Config.isDevBuild and Environment.Dev or Environment.User
|
||||
|
||||
local VALUES = {
|
||||
LogLevel = {
|
||||
type = "IntValue",
|
||||
values = {
|
||||
[Environment.User] = 2,
|
||||
[Environment.Dev] = 4,
|
||||
[Environment.Test] = 4,
|
||||
},
|
||||
},
|
||||
TypecheckingEnabled = {
|
||||
type = "BoolValue",
|
||||
values = {
|
||||
[Environment.User] = false,
|
||||
[Environment.Dev] = true,
|
||||
[Environment.Test] = true,
|
||||
},
|
||||
},
|
||||
UnstableTwoWaySync = {
|
||||
type = "BoolValue",
|
||||
values = {
|
||||
[Environment.User] = false,
|
||||
[Environment.Dev] = false,
|
||||
[Environment.Test] = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local CONTAINER_NAME = "RojoDevSettings" .. Config.codename
|
||||
|
||||
local function getValueContainer()
|
||||
return game:FindFirstChild(CONTAINER_NAME)
|
||||
end
|
||||
|
||||
local valueContainer = getValueContainer()
|
||||
|
||||
game.ChildAdded:Connect(function(child)
|
||||
local success, name = pcall(function()
|
||||
return child.Name
|
||||
end)
|
||||
|
||||
if success and name == CONTAINER_NAME then
|
||||
valueContainer = child
|
||||
end
|
||||
end)
|
||||
|
||||
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[DEFAULT_ENVIRONMENT]
|
||||
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 DevSettings:twoWaySyncEnabled()
|
||||
return getValue("UnstableTwoWaySync")
|
||||
end
|
||||
|
||||
function _G.ROJO_DEV_CREATE()
|
||||
DevSettings:createDevSettings()
|
||||
end
|
||||
|
||||
return DevSettings
|
||||
33
plugin/src/Dictionary.lua
Normal file
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,67 +0,0 @@
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local HTTP_DEBUG = false
|
||||
|
||||
local Promise = require(script.Parent.Promise)
|
||||
local HttpError = require(script.Parent.HttpError)
|
||||
local HttpResponse = require(script.Parent.HttpResponse)
|
||||
|
||||
local function dprint(...)
|
||||
if HTTP_DEBUG then
|
||||
print(...)
|
||||
end
|
||||
end
|
||||
|
||||
local Http = {}
|
||||
Http.__index = Http
|
||||
|
||||
function Http.new(baseUrl)
|
||||
assert(type(baseUrl) == "string", "Http.new needs a baseUrl!")
|
||||
|
||||
local http = {
|
||||
baseUrl = baseUrl
|
||||
}
|
||||
|
||||
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)
|
||||
end)
|
||||
|
||||
if ok then
|
||||
dprint("\t", result, "\n")
|
||||
resolve(HttpResponse.new(result))
|
||||
else
|
||||
reject(HttpError.fromErrorString(result))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function Http:post(endpoint, body)
|
||||
dprint("\nPOST", endpoint)
|
||||
dprint(body)
|
||||
return Promise.new(function(resolve, reject)
|
||||
spawn(function()
|
||||
local ok, result = pcall(function()
|
||||
return HttpService:PostAsync(self.baseUrl .. endpoint, body)
|
||||
end)
|
||||
|
||||
if ok then
|
||||
dprint("\t", result, "\n")
|
||||
resolve(HttpResponse.new(result))
|
||||
else
|
||||
reject(HttpError.fromErrorString(result))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
return Http
|
||||
@@ -1,57 +0,0 @@
|
||||
local HttpError = {}
|
||||
HttpError.__index = HttpError
|
||||
|
||||
HttpError.Error = {
|
||||
HttpNotEnabled = {
|
||||
message = "Rojo requires HTTP access, which is not enabled.\n" ..
|
||||
"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!",
|
||||
},
|
||||
Unknown = {
|
||||
message = "Rojo encountered an unknown error: {{message}}",
|
||||
},
|
||||
}
|
||||
|
||||
function HttpError.new(type, extraMessage)
|
||||
extraMessage = extraMessage or ""
|
||||
local message = type.message:gsub("{{message}}", extraMessage)
|
||||
|
||||
local err = {
|
||||
type = type,
|
||||
message = message,
|
||||
}
|
||||
|
||||
setmetatable(err, HttpError)
|
||||
|
||||
return err
|
||||
end
|
||||
|
||||
function HttpError:__tostring()
|
||||
return self.message
|
||||
end
|
||||
|
||||
--[[
|
||||
This method shouldn't have to exist. Ugh.
|
||||
]]
|
||||
function HttpError.fromErrorString(err)
|
||||
err = err:lower()
|
||||
|
||||
if err:find("^http requests are not enabled") then
|
||||
return HttpError.new(HttpError.Error.HttpNotEnabled)
|
||||
end
|
||||
|
||||
if err:find("^curl error") then
|
||||
return HttpError.new(HttpError.Error.ConnectFailed)
|
||||
end
|
||||
|
||||
return HttpError.new(HttpError.Error.Unknown, err)
|
||||
end
|
||||
|
||||
function HttpError:report()
|
||||
warn(self.message)
|
||||
end
|
||||
|
||||
return HttpError
|
||||
@@ -1,20 +0,0 @@
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local HttpResponse = {}
|
||||
HttpResponse.__index = HttpResponse
|
||||
|
||||
function HttpResponse.new(body)
|
||||
local response = {
|
||||
body = body,
|
||||
}
|
||||
|
||||
setmetatable(response, HttpResponse)
|
||||
|
||||
return response
|
||||
end
|
||||
|
||||
function HttpResponse:json()
|
||||
return HttpService:JSONDecode(self.body)
|
||||
end
|
||||
|
||||
return HttpResponse
|
||||
177
plugin/src/InstanceMap.lua
Normal file
177
plugin/src/InstanceMap.lua
Normal file
@@ -0,0 +1,177 @@
|
||||
local Log = require(script.Parent.Parent.Log)
|
||||
|
||||
--[[
|
||||
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(onInstanceChanged)
|
||||
local self = {
|
||||
fromIds = {},
|
||||
fromInstances = {},
|
||||
instancesToSignal = {},
|
||||
onInstanceChanged = onInstanceChanged,
|
||||
}
|
||||
|
||||
return setmetatable(self, InstanceMap)
|
||||
end
|
||||
|
||||
--[[
|
||||
Disconnect all connections and release all instance references.
|
||||
]]
|
||||
function InstanceMap:stop()
|
||||
-- I think this is safe.
|
||||
for instance in pairs(self.fromInstances) do
|
||||
self:removeInstance(instance)
|
||||
end
|
||||
end
|
||||
|
||||
function InstanceMap:__fmtDebug(output)
|
||||
output:writeLine("InstanceMap {{")
|
||||
output:indent()
|
||||
|
||||
-- Collect all of the entries in the InstanceMap and sort them by their
|
||||
-- label, which helps make our output deterministic.
|
||||
local entries = {}
|
||||
for id, instance in pairs(self.fromIds) do
|
||||
local label = string.format("%s (%s)", instance:GetFullName(), instance.ClassName)
|
||||
|
||||
table.insert(entries, {id, label})
|
||||
end
|
||||
|
||||
table.sort(entries, function(a, b)
|
||||
return a[2] < b[2]
|
||||
end)
|
||||
|
||||
for _, entry in ipairs(entries) do
|
||||
output:writeLine("{}: {}", entry[1], entry[2])
|
||||
end
|
||||
|
||||
output:unindent()
|
||||
output:write("}")
|
||||
end
|
||||
|
||||
function InstanceMap:insert(id, instance)
|
||||
self.fromIds[id] = instance
|
||||
self.fromInstances[instance] = id
|
||||
self:__connectSignals(instance)
|
||||
end
|
||||
|
||||
function InstanceMap:removeId(id)
|
||||
local instance = self.fromIds[id]
|
||||
|
||||
if instance ~= nil then
|
||||
self:__disconnectSignals(instance)
|
||||
self.fromIds[id] = nil
|
||||
self.fromInstances[instance] = nil
|
||||
else
|
||||
Log.warn("Attempted to remove nonexistant ID {}", id)
|
||||
end
|
||||
end
|
||||
|
||||
function InstanceMap:removeInstance(instance)
|
||||
local id = self.fromInstances[instance]
|
||||
self:__disconnectSignals(instance)
|
||||
|
||||
if id ~= nil then
|
||||
self.fromInstances[instance] = nil
|
||||
self.fromIds[id] = nil
|
||||
else
|
||||
Log.warn("Attempted to remove nonexistant instance {}", instance)
|
||||
end
|
||||
end
|
||||
|
||||
function InstanceMap:destroyInstance(instance)
|
||||
local id = self.fromInstances[instance]
|
||||
|
||||
if id ~= nil then
|
||||
self:destroyId(id)
|
||||
else
|
||||
Log.warn("Attempted to destroy untracked instance {}", 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
|
||||
Log.warn("Attempted to destroy nonexistant ID {}", id)
|
||||
end
|
||||
end
|
||||
|
||||
function InstanceMap:__connectSignals(instance)
|
||||
-- ValueBase instances have an overriden version of the Changed signal that
|
||||
-- only detects changes to their Value property.
|
||||
--
|
||||
-- We can instead connect listener to each individual property that we care
|
||||
-- about on those objects (Name and Value) to emulate the same idea.
|
||||
if instance:IsA("ValueBase") then
|
||||
local signals = {
|
||||
instance:GetPropertyChangedSignal("Name"):Connect(function()
|
||||
self:__maybeFireInstanceChanged(instance, "Name")
|
||||
end),
|
||||
|
||||
instance:GetPropertyChangedSignal("Value"):Connect(function()
|
||||
self:__maybeFireInstanceChanged(instance, "Value")
|
||||
end),
|
||||
|
||||
instance:GetPropertyChangedSignal("Parent"):Connect(function()
|
||||
self:__maybeFireInstanceChanged(instance, "Parent")
|
||||
end),
|
||||
}
|
||||
|
||||
self.instancesToSignal[instance] = signals
|
||||
else
|
||||
self.instancesToSignal[instance] = instance.Changed:Connect(function(propertyName)
|
||||
self:__maybeFireInstanceChanged(instance, propertyName)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function InstanceMap:__maybeFireInstanceChanged(instance, propertyName)
|
||||
Log.trace("{}.{} changed", instance:GetFullName(), propertyName)
|
||||
|
||||
if self.onInstanceChanged ~= nil then
|
||||
self.onInstanceChanged(instance, propertyName)
|
||||
end
|
||||
end
|
||||
|
||||
function InstanceMap:__disconnectSignals(instance)
|
||||
local signals = self.instancesToSignal[instance]
|
||||
|
||||
if signals ~= nil then
|
||||
-- In most cases, we only have a single signal, so we avoid keeping
|
||||
-- around the extra table. ValueBase objects force us to use multiple
|
||||
-- signals to emulate the Instance.Changed event, however.
|
||||
if typeof(signals) == "table" then
|
||||
for _, signal in ipairs(signals) do
|
||||
signal:Disconnect()
|
||||
end
|
||||
else
|
||||
signals:Disconnect()
|
||||
end
|
||||
|
||||
self.instancesToSignal[instance] = nil
|
||||
end
|
||||
end
|
||||
|
||||
return InstanceMap
|
||||
@@ -1,42 +0,0 @@
|
||||
if not plugin then
|
||||
return
|
||||
end
|
||||
|
||||
local Plugin = require(script.Parent.Plugin)
|
||||
local Config = require(script.Parent.Config)
|
||||
|
||||
local function main()
|
||||
local pluginInstance = Plugin.new()
|
||||
|
||||
local displayedVersion = Config.dev and "DEV" or Config.version
|
||||
|
||||
local toolbar = plugin:CreateToolbar("Rojo Plugin " .. displayedVersion)
|
||||
|
||||
toolbar:CreateButton("Test Connection", "Connect to Rojo Server", "")
|
||||
.Click:Connect(function()
|
||||
pluginInstance:connect()
|
||||
:catch(function(err)
|
||||
warn(err)
|
||||
end)
|
||||
end)
|
||||
|
||||
toolbar:CreateButton("Sync In", "Sync into Roblox Studio", "")
|
||||
.Click:Connect(function()
|
||||
pluginInstance:syncIn()
|
||||
:catch(function(err)
|
||||
warn(err)
|
||||
end)
|
||||
end)
|
||||
|
||||
toolbar:CreateButton("Toggle Polling", "Poll server for changes", "")
|
||||
.Click:Connect(function()
|
||||
spawn(function()
|
||||
pluginInstance:togglePolling()
|
||||
:catch(function(err)
|
||||
warn(err)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
main()
|
||||
@@ -1,178 +0,0 @@
|
||||
local Config = require(script.Parent.Config)
|
||||
local Http = require(script.Parent.Http)
|
||||
local Server = require(script.Parent.Server)
|
||||
local Promise = require(script.Parent.Promise)
|
||||
local Reconciler = require(script.Parent.Reconciler)
|
||||
|
||||
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 foop = {
|
||||
_http = Http.new(remote),
|
||||
_server = nil,
|
||||
_polling = false,
|
||||
}
|
||||
|
||||
setmetatable(foop, Plugin)
|
||||
|
||||
do
|
||||
local screenGui = Instance.new("ScreenGui")
|
||||
screenGui.Name = "Rojo UI"
|
||||
screenGui.Parent = game.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
|
||||
|
||||
foop._label = screenGui
|
||||
end
|
||||
|
||||
return foop
|
||||
end
|
||||
|
||||
function Plugin:server()
|
||||
if not self._server then
|
||||
self._server = Server.connect(self._http)
|
||||
:catch(function(err)
|
||||
self._server = nil
|
||||
return Promise.reject(err)
|
||||
end)
|
||||
end
|
||||
|
||||
return self._server
|
||||
end
|
||||
|
||||
function Plugin:connect()
|
||||
print("Testing connection...")
|
||||
|
||||
return self:server()
|
||||
:andThen(function(server)
|
||||
return server:getInfo()
|
||||
end)
|
||||
:andThen(function(result)
|
||||
print("Server found!")
|
||||
print("Protocol version:", result.protocolVersion)
|
||||
print("Server version:", result.serverVersion)
|
||||
end)
|
||||
end
|
||||
|
||||
function Plugin:togglePolling()
|
||||
if self._polling then
|
||||
self:stopPolling()
|
||||
|
||||
return Promise.resolve(nil)
|
||||
else
|
||||
return self:startPolling()
|
||||
end
|
||||
end
|
||||
|
||||
function Plugin:stopPolling()
|
||||
if not self._polling then
|
||||
return
|
||||
end
|
||||
|
||||
print("Stopped polling.")
|
||||
|
||||
self._polling = false
|
||||
self._label.Enabled = false
|
||||
end
|
||||
|
||||
function Plugin:_pull(server, project, routes)
|
||||
local items = server:read(routes):await()
|
||||
|
||||
for index = 1, #routes do
|
||||
local route = routes[index]
|
||||
local partitionName = route[1]
|
||||
local partition = project.partitions[partitionName]
|
||||
local item = items[index]
|
||||
|
||||
local fullRoute = collectMatch(partition.target, "[^.]+")
|
||||
for i = 2, #route do
|
||||
table.insert(fullRoute, routes[index][i])
|
||||
end
|
||||
|
||||
Reconciler.reconcileRoute(fullRoute, item)
|
||||
end
|
||||
end
|
||||
|
||||
function Plugin:startPolling()
|
||||
if self._polling then
|
||||
return
|
||||
end
|
||||
|
||||
print("Starting to poll...")
|
||||
|
||||
self._polling = true
|
||||
self._label.Enabled = true
|
||||
|
||||
return self:server()
|
||||
:andThen(function(server)
|
||||
self:syncIn():await()
|
||||
|
||||
local project = server:getInfo():await().project
|
||||
|
||||
while self._polling do
|
||||
local changes = server:getChanges():await()
|
||||
|
||||
local routes = {}
|
||||
|
||||
for _, change in ipairs(changes) do
|
||||
table.insert(routes, change.route)
|
||||
end
|
||||
|
||||
self:_pull(server, project, routes)
|
||||
|
||||
wait(Config.pollingRate)
|
||||
end
|
||||
end)
|
||||
:catch(function()
|
||||
self:stopPolling()
|
||||
end)
|
||||
end
|
||||
|
||||
function Plugin:syncIn()
|
||||
print("Syncing from server...")
|
||||
|
||||
return self:server()
|
||||
:andThen(function(server)
|
||||
local project = server:getInfo():await().project
|
||||
|
||||
local routes = {}
|
||||
|
||||
for name in pairs(project.partitions) do
|
||||
table.insert(routes, {name})
|
||||
end
|
||||
|
||||
self:_pull(server, project, routes)
|
||||
|
||||
print("Sync successful!")
|
||||
end)
|
||||
end
|
||||
|
||||
return Plugin
|
||||
@@ -1,308 +0,0 @@
|
||||
--[[
|
||||
An implementation of Promises similar to Promise/A+.
|
||||
]]
|
||||
|
||||
local PROMISE_DEBUG = false
|
||||
|
||||
-- If promise debugging is on, use a version of pcall that warns on failure.
|
||||
-- This is useful for finding errors that happen within Promise itself.
|
||||
local wpcall
|
||||
if PROMISE_DEBUG then
|
||||
wpcall = function(f, ...)
|
||||
local result = { pcall(f, ...) }
|
||||
|
||||
if not result[1] then
|
||||
warn(result[2])
|
||||
end
|
||||
|
||||
return unpack(result)
|
||||
end
|
||||
else
|
||||
wpcall = pcall
|
||||
end
|
||||
|
||||
--[[
|
||||
Creates a function that invokes a callback with correct error handling and
|
||||
resolution mechanisms.
|
||||
]]
|
||||
local function createAdvancer(callback, resolve, reject)
|
||||
return function(...)
|
||||
local result = { wpcall(callback, ...) }
|
||||
local ok = table.remove(result, 1)
|
||||
|
||||
if ok then
|
||||
resolve(unpack(result))
|
||||
else
|
||||
reject(unpack(result))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function isEmpty(t)
|
||||
return next(t) == nil
|
||||
end
|
||||
|
||||
local Promise = {}
|
||||
Promise.__index = Promise
|
||||
|
||||
Promise.Status = {
|
||||
Started = "Started",
|
||||
Resolved = "Resolved",
|
||||
Rejected = "Rejected",
|
||||
}
|
||||
|
||||
--[[
|
||||
Constructs a new Promise with the given initializing callback.
|
||||
|
||||
This is generally only called when directly wrapping a non-promise API into
|
||||
a promise-based version.
|
||||
|
||||
The callback will receive 'resolve' and 'reject' methods, used to start
|
||||
invoking the promise chain.
|
||||
|
||||
For example:
|
||||
|
||||
local function get(url)
|
||||
return Promise.new(function(resolve, reject)
|
||||
spawn(function()
|
||||
resolve(HttpService:GetAsync(url))
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
get("https://google.com")
|
||||
:andThen(function(stuff)
|
||||
print("Got some stuff!", stuff)
|
||||
end)
|
||||
]]
|
||||
function Promise.new(callback)
|
||||
local promise = {
|
||||
-- Used to locate where a promise was created
|
||||
_source = debug.traceback(),
|
||||
|
||||
-- A tag to identify us as a promise
|
||||
_type = "Promise",
|
||||
|
||||
_status = Promise.Status.Started,
|
||||
|
||||
-- A table containing a list of all results, whether success or failure.
|
||||
-- Only valid if _status is set to something besides Started
|
||||
_value = nil,
|
||||
|
||||
-- If an error occurs with no observers, this will be set.
|
||||
_unhandledRejection = false,
|
||||
|
||||
-- Queues representing functions we should invoke when we update!
|
||||
_queuedResolve = {},
|
||||
_queuedReject = {},
|
||||
}
|
||||
|
||||
setmetatable(promise, Promise)
|
||||
|
||||
local function resolve(...)
|
||||
promise:_resolve(...)
|
||||
end
|
||||
|
||||
local function reject(...)
|
||||
promise:_reject(...)
|
||||
end
|
||||
|
||||
local ok, err = wpcall(callback, resolve, reject)
|
||||
|
||||
if not ok and promise._status == Promise.Status.Started then
|
||||
reject(err)
|
||||
end
|
||||
|
||||
return promise
|
||||
end
|
||||
|
||||
--[[
|
||||
Create a promise that represents the immediately resolved value.
|
||||
]]
|
||||
function Promise.resolve(value)
|
||||
return Promise.new(function(resolve)
|
||||
resolve(value)
|
||||
end)
|
||||
end
|
||||
|
||||
--[[
|
||||
Create a promise that represents the immediately rejected value.
|
||||
]]
|
||||
function Promise.reject(value)
|
||||
return Promise.new(function(_, reject)
|
||||
reject(value)
|
||||
end)
|
||||
end
|
||||
|
||||
--[[
|
||||
Returns a new promise that:
|
||||
* is resolved when all input promises resolve
|
||||
* is rejected if ANY input promises reject
|
||||
]]
|
||||
function Promise.all(...)
|
||||
error("unimplemented", 2)
|
||||
end
|
||||
|
||||
--[[
|
||||
Is the given object a Promise instance?
|
||||
]]
|
||||
function Promise.is(object)
|
||||
if type(object) ~= "table" then
|
||||
return false
|
||||
end
|
||||
|
||||
return object._type == "Promise"
|
||||
end
|
||||
|
||||
--[[
|
||||
Creates a new promise that receives the result of this promise.
|
||||
|
||||
The given callbacks are invoked depending on that result.
|
||||
]]
|
||||
function Promise:andThen(successHandler, failureHandler)
|
||||
self._unhandledRejection = false
|
||||
|
||||
-- Create a new promise to follow this part of the chain
|
||||
return Promise.new(function(resolve, reject)
|
||||
-- Our default callbacks just pass values onto the next promise.
|
||||
-- This lets success and failure cascade correctly!
|
||||
|
||||
local successCallback = resolve
|
||||
if successHandler then
|
||||
successCallback = createAdvancer(successHandler, resolve, reject)
|
||||
end
|
||||
|
||||
local failureCallback = reject
|
||||
if failureHandler then
|
||||
failureCallback = createAdvancer(failureHandler, resolve, reject)
|
||||
end
|
||||
|
||||
if self._status == Promise.Status.Started then
|
||||
-- If we haven't resolved yet, put ourselves into the queue
|
||||
table.insert(self._queuedResolve, successCallback)
|
||||
table.insert(self._queuedReject, failureCallback)
|
||||
elseif self._status == Promise.Status.Resolved then
|
||||
-- This promise has already resolved! Trigger success immediately.
|
||||
successCallback(unpack(self._value))
|
||||
elseif self._status == Promise.Status.Rejected then
|
||||
-- This promise died a terrible death! Trigger failure immediately.
|
||||
failureCallback(unpack(self._value))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
--[[
|
||||
Used to catch any errors that may have occurred in the promise.
|
||||
]]
|
||||
function Promise:catch(failureCallback)
|
||||
return self:andThen(nil, failureCallback)
|
||||
end
|
||||
|
||||
--[[
|
||||
Yield until the promise is completed.
|
||||
|
||||
This matches the execution model of normal Roblox functions.
|
||||
]]
|
||||
function Promise:await()
|
||||
self._unhandledRejection = false
|
||||
|
||||
if self._status == Promise.Status.Started then
|
||||
local result
|
||||
local bindable = Instance.new("BindableEvent")
|
||||
|
||||
self:andThen(function(...)
|
||||
result = {...}
|
||||
bindable:Fire(true)
|
||||
end, function(...)
|
||||
result = {...}
|
||||
bindable:Fire(false)
|
||||
end)
|
||||
|
||||
local ok = bindable.Event:Wait()
|
||||
bindable:Destroy()
|
||||
|
||||
if not ok then
|
||||
error(tostring(result[1]), 2)
|
||||
end
|
||||
|
||||
return unpack(result)
|
||||
elseif self._status == Promise.Status.Resolved then
|
||||
return unpack(self._value)
|
||||
elseif self._status == Promise.Status.Rejected then
|
||||
error(tostring(self._value[1]), 2)
|
||||
end
|
||||
end
|
||||
|
||||
function Promise:_resolve(...)
|
||||
if self._status ~= Promise.Status.Started then
|
||||
return
|
||||
end
|
||||
|
||||
-- If the resolved value was a Promise, we chain onto it!
|
||||
if Promise.is((...)) then
|
||||
-- Without this warning, arguments sometimes mysteriously disappear
|
||||
if select("#", ...) > 1 then
|
||||
local message = ("When returning a Promise from andThen, extra arguments are discarded! See:\n\n%s"):format(
|
||||
self._source
|
||||
)
|
||||
warn(message)
|
||||
end
|
||||
|
||||
(...):andThen(function(...)
|
||||
self:_resolve(...)
|
||||
end, function(...)
|
||||
self:_reject(...)
|
||||
end)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
self._status = Promise.Status.Resolved
|
||||
self._value = {...}
|
||||
|
||||
-- We assume that these callbacks will not throw errors.
|
||||
for _, callback in ipairs(self._queuedResolve) do
|
||||
callback(...)
|
||||
end
|
||||
end
|
||||
|
||||
function Promise:_reject(...)
|
||||
if self._status ~= Promise.Status.Started then
|
||||
return
|
||||
end
|
||||
|
||||
self._status = Promise.Status.Rejected
|
||||
self._value = {...}
|
||||
|
||||
-- If there are any rejection handlers, call those!
|
||||
if not isEmpty(self._queuedReject) then
|
||||
-- We assume that these callbacks will not throw errors.
|
||||
for _, callback in ipairs(self._queuedReject) do
|
||||
callback(...)
|
||||
end
|
||||
else
|
||||
-- At this point, no one was able to observe the error.
|
||||
-- An error handler might still be attached if the error occurred
|
||||
-- synchronously. We'll wait one tick, and if there are still no
|
||||
-- observers, then we should put a message in the console.
|
||||
|
||||
self._unhandledRejection = true
|
||||
local err = tostring((...))
|
||||
|
||||
spawn(function()
|
||||
-- Someone observed the error, hooray!
|
||||
if not self._unhandledRejection then
|
||||
return
|
||||
end
|
||||
|
||||
-- Build a reasonable message
|
||||
local message = ("Unhandled promise rejection:\n\n%s\n\n%s"):format(
|
||||
err,
|
||||
self._source
|
||||
)
|
||||
warn(message)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
return Promise
|
||||
@@ -1,70 +0,0 @@
|
||||
return function()
|
||||
local Promise = require(script.Parent.Promise)
|
||||
|
||||
describe("Promise.new", function()
|
||||
it("should instantiate with a callback", function()
|
||||
local promise = Promise.new(function() end)
|
||||
|
||||
expect(promise).to.be.ok()
|
||||
end)
|
||||
|
||||
it("should invoke the given callback with resolve and reject", function()
|
||||
local callCount = 0
|
||||
local resolveArg
|
||||
local rejectArg
|
||||
|
||||
local promise = Promise.new(function(resolve, reject)
|
||||
callCount = callCount + 1
|
||||
resolveArg = resolve
|
||||
rejectArg = reject
|
||||
end)
|
||||
|
||||
expect(promise).to.be.ok()
|
||||
|
||||
expect(callCount).to.equal(1)
|
||||
expect(resolveArg).to.be.a("function")
|
||||
expect(rejectArg).to.be.a("function")
|
||||
expect(promise._status).to.equal(Promise.Status.Started)
|
||||
end)
|
||||
|
||||
it("should resolve promises on resolve()", function()
|
||||
local callCount = 0
|
||||
|
||||
local promise = Promise.new(function(resolve)
|
||||
callCount = callCount + 1
|
||||
resolve()
|
||||
end)
|
||||
|
||||
expect(promise).to.be.ok()
|
||||
expect(callCount).to.equal(1)
|
||||
expect(promise._status).to.equal(Promise.Status.Resolved)
|
||||
end)
|
||||
|
||||
it("should reject promises on reject()", function()
|
||||
local callCount = 0
|
||||
|
||||
local promise = Promise.new(function(resolve, reject)
|
||||
callCount = callCount + 1
|
||||
reject()
|
||||
end)
|
||||
|
||||
expect(promise).to.be.ok()
|
||||
expect(callCount).to.equal(1)
|
||||
expect(promise._status).to.equal(Promise.Status.Rejected)
|
||||
end)
|
||||
|
||||
it("should reject on error in callback", function()
|
||||
local callCount = 0
|
||||
|
||||
local promise = Promise.new(function()
|
||||
callCount = callCount + 1
|
||||
error("hahah")
|
||||
end)
|
||||
|
||||
expect(promise).to.be.ok()
|
||||
expect(callCount).to.equal(1)
|
||||
expect(promise._status).to.equal(Promise.Status.Rejected)
|
||||
expect(promise._value[1]:find("hahah")).to.be.ok()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
@@ -1,264 +1,401 @@
|
||||
--[[
|
||||
This module defines the meat of the Rojo plugin and how it manages tracking
|
||||
and mutating the Roblox DOM.
|
||||
]]
|
||||
|
||||
local RbxDom = require(script.Parent.Parent.RbxDom)
|
||||
local t = require(script.Parent.Parent.t)
|
||||
local Log = require(script.Parent.Parent.Log)
|
||||
|
||||
local Types = require(script.Parent.Types)
|
||||
local invariant = require(script.Parent.invariant)
|
||||
local getCanonicalProperty = require(script.Parent.getCanonicalProperty)
|
||||
local setCanonicalProperty = require(script.Parent.setCanonicalProperty)
|
||||
|
||||
--[[
|
||||
This interface represents either a patch created by the hydrate method, or a
|
||||
patch returned from the API.
|
||||
|
||||
This type should be a subset of Types.ApiInstanceUpdate.
|
||||
]]
|
||||
local IPatch = t.interface({
|
||||
removed = t.array(t.union(Types.RbxId, t.Instance)),
|
||||
added = t.map(Types.RbxId, Types.ApiInstance),
|
||||
updated = t.array(Types.ApiInstanceUpdate),
|
||||
})
|
||||
|
||||
--[[
|
||||
Attempt to safely set the parent of an instance.
|
||||
|
||||
This function will always succeed, even if the actual set failed. This is
|
||||
important for some types like services that will throw even if their current
|
||||
parent is already set to the requested parent.
|
||||
|
||||
TODO: See if we can eliminate this by being more nuanced with property
|
||||
assignment?
|
||||
]]
|
||||
local function safeSetParent(instance, newParent)
|
||||
pcall(function()
|
||||
instance.Parent = newParent
|
||||
end)
|
||||
end
|
||||
|
||||
--[[
|
||||
Similar to setting Parent, some instances really don't like being renamed.
|
||||
|
||||
TODO: Should we be throwing away these results or can we be more careful?
|
||||
]]
|
||||
local function safeSetName(instance, name)
|
||||
pcall(function()
|
||||
instance.Name = name
|
||||
end)
|
||||
end
|
||||
|
||||
local Reconciler = {}
|
||||
Reconciler.__index = Reconciler
|
||||
|
||||
--[[
|
||||
The set of file names that should pass as init files
|
||||
These files usurp their parents.
|
||||
]]
|
||||
local initNames = {
|
||||
["init.lua"] = true,
|
||||
["init.server.lua"] = true,
|
||||
["init.client.lua"] = true,
|
||||
}
|
||||
function Reconciler.new(instanceMap)
|
||||
local self = {
|
||||
-- Tracks all of the instances known by the reconciler by ID.
|
||||
__instanceMap = instanceMap,
|
||||
}
|
||||
|
||||
local function isInit(item, itemFileName)
|
||||
if item and item.type == "dir" then
|
||||
return
|
||||
end
|
||||
|
||||
return initNames[itemFileName] or false
|
||||
return setmetatable(self, Reconciler)
|
||||
end
|
||||
|
||||
--[[
|
||||
Determines if the given VFS item has an init file. Yields information about
|
||||
the file.
|
||||
See Reconciler:__hydrateInternal().
|
||||
]]
|
||||
local function findInit(item)
|
||||
if item.type ~= "dir" then
|
||||
return nil, nil
|
||||
end
|
||||
function Reconciler:hydrate(apiInstances, id, instance)
|
||||
local hydratePatch = {
|
||||
removed = {},
|
||||
added = {},
|
||||
updated = {},
|
||||
}
|
||||
|
||||
for childFileName, childItem in pairs(item.children) do
|
||||
if isInit(childItem, childFileName) then
|
||||
return childItem, childFileName
|
||||
end
|
||||
end
|
||||
self:__hydrateInternal(apiInstances, id, instance, hydratePatch)
|
||||
|
||||
return nil, nil
|
||||
return hydratePatch
|
||||
end
|
||||
|
||||
--[[
|
||||
Given a VFS item, returns a Name and ClassName for a corresponding Roblox
|
||||
instance.
|
||||
Applies a patch to the Roblox DOM using the reconciler's internal state.
|
||||
|
||||
Doesn't take into account init files.
|
||||
TODO: This function might only apply some of the patch in the future and
|
||||
require content negotiation with the Rojo server to handle types that aren't
|
||||
editable by scripts.
|
||||
]]
|
||||
local function itemToName(item, fileName)
|
||||
if item and item.type == "dir" then
|
||||
return fileName, "Folder"
|
||||
elseif item and item.type == "file" or not item then
|
||||
if fileName:find("%.server%.lua$") then
|
||||
return fileName:match("^(.-)%.server%.lua$"), "Script"
|
||||
elseif fileName:find("%.client%.lua$") then
|
||||
return fileName:match("^(.-)%.client%.lua$"), "LocalScript"
|
||||
elseif fileName:find("%.lua") then
|
||||
return fileName:match("^(.-)%.lua$"), "ModuleScript"
|
||||
else
|
||||
return fileName, "StringValue"
|
||||
local applyPatchSchema = Types.ifEnabled(t.tuple(
|
||||
IPatch
|
||||
))
|
||||
function Reconciler:applyPatch(patch)
|
||||
assert(applyPatchSchema(patch))
|
||||
|
||||
for _, removedIdOrInstance in ipairs(patch.removed) do
|
||||
local removedInstance
|
||||
|
||||
if Types.RbxId(removedIdOrInstance) then
|
||||
-- If this value is an ID, it's assumed to be an instance that the
|
||||
-- Rojo server knows about.
|
||||
removedInstance = self.__instanceMap.fromIds[removedIdOrInstance]
|
||||
self.__instanceMap:removeId(removedIdOrInstance)
|
||||
end
|
||||
|
||||
-- If this entry was an ID that we didn't know about, removedInstance
|
||||
-- will be nil, which we guard against in case of minor tree desync.
|
||||
if removedInstance ~= nil then
|
||||
-- Ensure that if any descendants are tracked by Rojo, that we
|
||||
-- properly un-track them.
|
||||
for _, descendantInstance in ipairs(removedInstance:GetDescendants()) do
|
||||
self.__instanceMap:removeInstance(descendantInstance)
|
||||
end
|
||||
|
||||
removedInstance:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: This loop assumes that apiInstance.ParentId is never nil. The Rojo
|
||||
-- plugin can't create a new top-level DataModel anyways, so this should
|
||||
-- only be violated in cases that are already erroneous.
|
||||
for id, apiInstance in pairs(patch.added) do
|
||||
if self.__instanceMap.fromIds[id] == nil then
|
||||
-- Find the first ancestor of this instance that is marked for an
|
||||
-- addition.
|
||||
--
|
||||
-- This helps us make sure we only reify each instance once, and we
|
||||
-- start from the top.
|
||||
while patch.added[apiInstance.Parent] ~= nil do
|
||||
id = apiInstance.Parent
|
||||
apiInstance = patch.added[id]
|
||||
end
|
||||
|
||||
local parentInstance = self.__instanceMap.fromIds[apiInstance.Parent]
|
||||
|
||||
if parentInstance == nil then
|
||||
invariant(
|
||||
"Cannot add an instance from a patch that has no parent.\nInstance {} with parent {}.\nState: {:#?}",
|
||||
id,
|
||||
apiInstance.Parent,
|
||||
self.__instanceMap
|
||||
)
|
||||
end
|
||||
|
||||
self:__reifyInstance(patch.added, id, parentInstance)
|
||||
end
|
||||
end
|
||||
|
||||
for _, update in ipairs(patch.updated) do
|
||||
local instance = self.__instanceMap.fromIds[update.id]
|
||||
|
||||
if instance == nil then
|
||||
invariant(
|
||||
"Cannot update an instance that does not exist in the reconciler's state.\nInstance {}\nState: {:#?}",
|
||||
update.id,
|
||||
self.__instanceMap
|
||||
)
|
||||
end
|
||||
|
||||
if update.changedClassName ~= nil then
|
||||
error("TODO: Support changing class name by destroying + recreating instance.")
|
||||
end
|
||||
|
||||
if update.changedName ~= nil then
|
||||
instance.Name = update.changedName
|
||||
end
|
||||
|
||||
if update.changedMetadata ~= nil then
|
||||
print("TODO: Support changing metadata, if necessary.")
|
||||
end
|
||||
|
||||
if update.changedProperties ~= nil then
|
||||
for propertyName, propertyValue in pairs(update.changedProperties) do
|
||||
-- TODO: Gracefully handle this error instead?
|
||||
assert(setCanonicalProperty(instance, propertyName, self:__decodeApiValue(propertyValue)))
|
||||
end
|
||||
end
|
||||
else
|
||||
error("unknown item type " .. tostring(item.type))
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
Given a VFS item, assigns all relevant values (except Name!) to a Roblox
|
||||
instance.
|
||||
Transforms a value into one that can be sent over the network back to the
|
||||
Rojo server.
|
||||
|
||||
This operation can fail, and so it returns bool, value.
|
||||
]]
|
||||
local function setValues(rbx, item, fileName)
|
||||
local _, className = itemToName(item, fileName)
|
||||
|
||||
if className:find("Script") then
|
||||
rbx.Source = item.contents
|
||||
else
|
||||
rbx.Value = item.contents
|
||||
function Reconciler:encodeApiValue(value)
|
||||
if typeof(value) == "string" then
|
||||
return true, {
|
||||
Type = "String",
|
||||
Value = value,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Reconciler._reifyShallow(item, fileName)
|
||||
if item.type == "dir" then
|
||||
local initItem, initFileName = findInit(item)
|
||||
|
||||
if initItem then
|
||||
local rbx = Reconciler._reify(initItem, initFileName)
|
||||
rbx.Name = fileName
|
||||
|
||||
return rbx
|
||||
else
|
||||
local rbx = Instance.new("Folder")
|
||||
rbx.Name = fileName
|
||||
|
||||
return rbx
|
||||
end
|
||||
elseif item.type == "file" then
|
||||
local objectName, className = itemToName(item, fileName)
|
||||
|
||||
local rbx = Instance.new(className)
|
||||
rbx.Name = objectName
|
||||
|
||||
setValues(rbx, item, fileName)
|
||||
|
||||
return rbx
|
||||
else
|
||||
error("unknown item type " .. tostring(item.type))
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--[[
|
||||
Construct a new Roblox instance tree that corresponds to the given VFS item.
|
||||
Transforms a value encoded by rbx_dom_weak on the server side into a value
|
||||
usable by Rojo's reconciler, potentially using RbxDom.
|
||||
]]
|
||||
function Reconciler._reify(item, fileName, parent)
|
||||
local rbx = Reconciler._reifyShallow(item, fileName)
|
||||
function Reconciler:__decodeApiValue(apiValue)
|
||||
assert(Types.ApiValue(apiValue))
|
||||
|
||||
if item.type == "dir" then
|
||||
for childFileName, childItem in pairs(item.children) do
|
||||
if not isInit(childItem, childFileName) then
|
||||
local childRbx = Reconciler._reify(childItem, childFileName)
|
||||
childRbx.Parent = rbx
|
||||
end
|
||||
end
|
||||
-- Refs are represented as IDs in the same space that Rojo's protocol uses.
|
||||
if apiValue.Type == "Ref" then
|
||||
-- TODO: This ref could be pointing at an instance we haven't created
|
||||
-- yet!
|
||||
|
||||
return self.__instanceMap.fromIds[apiValue.Value]
|
||||
end
|
||||
|
||||
rbx.Parent = parent
|
||||
local success, decodedValue = RbxDom.EncodedValue.decode(apiValue)
|
||||
|
||||
return rbx
|
||||
if not success then
|
||||
error(decodedValue, 2)
|
||||
end
|
||||
|
||||
return decodedValue
|
||||
end
|
||||
|
||||
function Reconciler.reconcile(rbx, item, fileName, parent)
|
||||
-- Item was deleted!
|
||||
if not item then
|
||||
if isInit(item, fileName) then
|
||||
if not parent then
|
||||
return
|
||||
end
|
||||
--[[
|
||||
Constructs an instance from an ApiInstance without any of its children.
|
||||
]]
|
||||
local reifySingleInstanceSchema = Types.ifEnabled(t.tuple(
|
||||
Types.ApiInstance
|
||||
))
|
||||
function Reconciler:__reifySingleInstance(apiInstance)
|
||||
assert(reifySingleInstanceSchema(apiInstance))
|
||||
|
||||
-- Un-usurp parent!
|
||||
local newParent = Instance.new("Folder")
|
||||
newParent.Name = parent.Name
|
||||
-- Instance.new can fail if we're passing in something that can't be
|
||||
-- created, like a service, something enabled with a feature flag, or
|
||||
-- something that requires higher security than we have.
|
||||
local ok, instance = pcall(Instance.new, apiInstance.ClassName)
|
||||
if not ok then
|
||||
return false, instance
|
||||
end
|
||||
|
||||
for _, child in ipairs(parent:GetChildren()) do
|
||||
child.Parent = newParent
|
||||
end
|
||||
-- TODO: When can setting Name fail here?
|
||||
safeSetName(instance, apiInstance.Name)
|
||||
|
||||
newParent.Parent = parent.Parent
|
||||
parent:Destroy()
|
||||
for key, value in pairs(apiInstance.Properties) do
|
||||
setCanonicalProperty(instance, key, self:__decodeApiValue(value))
|
||||
end
|
||||
|
||||
return
|
||||
else
|
||||
if rbx then
|
||||
rbx:Destroy()
|
||||
end
|
||||
return true, instance
|
||||
end
|
||||
|
||||
return
|
||||
--[[
|
||||
Construct an instance and all of its descendants, parent it to the given
|
||||
instance, and insert it into the reconciler's internal state.
|
||||
]]
|
||||
local reifyInstanceSchema = Types.ifEnabled(t.tuple(
|
||||
t.map(Types.RbxId, Types.VirtualInstance),
|
||||
Types.RbxId,
|
||||
t.Instance
|
||||
))
|
||||
function Reconciler:__reifyInstance(apiInstances, id, parentInstance)
|
||||
assert(reifyInstanceSchema(apiInstances, id, parentInstance))
|
||||
|
||||
local apiInstance = apiInstances[id]
|
||||
local ok, instance = self:__reifySingleInstance(apiInstance)
|
||||
|
||||
-- TODO: Propagate this error upward to handle it elsewhere?
|
||||
if not ok then
|
||||
error(("Couldn't create an instance of type %q, a child of %s"):format(
|
||||
apiInstance.ClassName,
|
||||
parentInstance:GetFullName()
|
||||
))
|
||||
end
|
||||
|
||||
self.__instanceMap:insert(id, instance)
|
||||
|
||||
for _, childId in ipairs(apiInstance.Children) do
|
||||
self:__reifyInstance(apiInstances, childId, instance)
|
||||
end
|
||||
|
||||
safeSetParent(instance, parentInstance)
|
||||
|
||||
return instance
|
||||
end
|
||||
|
||||
--[[
|
||||
Populates the reconciler's internal state, maps IDs to instances that the
|
||||
Rojo plugin knows about, and generates a patch that would update the Roblox
|
||||
tree to match Rojo's view of the tree.
|
||||
]]
|
||||
local hydrateSchema = Types.ifEnabled(t.tuple(
|
||||
t.map(Types.RbxId, Types.VirtualInstance),
|
||||
Types.RbxId,
|
||||
t.Instance,
|
||||
IPatch
|
||||
))
|
||||
function Reconciler:__hydrateInternal(apiInstances, id, instance, hydratePatch)
|
||||
assert(hydrateSchema(apiInstances, id, instance, hydratePatch))
|
||||
|
||||
self.__instanceMap:insert(id, instance)
|
||||
|
||||
local apiInstance = apiInstances[id]
|
||||
|
||||
local function markIdAdded(id)
|
||||
local apiInstance = apiInstances[id]
|
||||
hydratePatch.added[id] = apiInstance
|
||||
|
||||
for _, childId in ipairs(apiInstance.Children) do
|
||||
markIdAdded(childId)
|
||||
end
|
||||
end
|
||||
|
||||
if item.type == "dir" then
|
||||
-- Folder was created!
|
||||
if not rbx then
|
||||
return Reconciler._reify(item, fileName, parent)
|
||||
end
|
||||
local changedName = nil
|
||||
local changedProperties = {}
|
||||
|
||||
local initItem, initFileName = findInit(item)
|
||||
if apiInstance.Name ~= instance.Name then
|
||||
changedName = apiInstance.Name
|
||||
end
|
||||
|
||||
if initItem then
|
||||
local _, initClassName = itemToName(initItem, initFileName)
|
||||
for propertyName, virtualValue in pairs(apiInstance.Properties) do
|
||||
local success, existingValue = getCanonicalProperty(instance, propertyName)
|
||||
|
||||
if rbx.ClassName == initClassName then
|
||||
setValues(rbx, initItem, initFileName)
|
||||
else
|
||||
rbx:Destroy()
|
||||
return Reconciler._reify(item, fileName, parent)
|
||||
end
|
||||
else
|
||||
if rbx.ClassName ~= "Folder" then
|
||||
rbx:Destroy()
|
||||
return Reconciler._reify(item, fileName, parent)
|
||||
if success then
|
||||
local decodedValue = self:__decodeApiValue(virtualValue)
|
||||
|
||||
if existingValue ~= decodedValue then
|
||||
changedProperties[propertyName] = virtualValue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local visitedChildren = {}
|
||||
-- If any properties differed from the virtual instance we read, add it to
|
||||
-- the hydrate patch so that we can catch up.
|
||||
if changedName ~= nil or next(changedProperties) ~= nil then
|
||||
table.insert(hydratePatch.updated, {
|
||||
id = id,
|
||||
changedName = changedName,
|
||||
changedClassName = nil,
|
||||
changedProperties = changedProperties,
|
||||
changedMetadata = nil,
|
||||
})
|
||||
end
|
||||
|
||||
for childFileName, childItem in pairs(item.children) do
|
||||
if not isInit(childItem, childFileName) then
|
||||
local childName = itemToName(childItem, childFileName)
|
||||
local existingChildren = instance:GetChildren()
|
||||
|
||||
visitedChildren[childName] = true
|
||||
-- For each existing child, we'll track whether it's been paired with an
|
||||
-- instance that the Rojo server knows about.
|
||||
local isExistingChildVisited = {}
|
||||
for i = 1, #existingChildren do
|
||||
isExistingChildVisited[i] = false
|
||||
end
|
||||
|
||||
Reconciler.reconcile(rbx:FindFirstChild(childName), childItem, childFileName, rbx)
|
||||
end
|
||||
end
|
||||
for _, childId in ipairs(apiInstance.Children) do
|
||||
local apiChild = apiInstances[childId]
|
||||
|
||||
for _, childRbx in ipairs(rbx:GetChildren()) do
|
||||
-- Child was deleted!
|
||||
if not visitedChildren[childRbx.Name] then
|
||||
childRbx:Destroy()
|
||||
end
|
||||
end
|
||||
local childInstance
|
||||
|
||||
return rbx
|
||||
elseif item.type == "file" then
|
||||
if isInit(item, fileName) then
|
||||
-- Usurp our container!
|
||||
local _, className = itemToName(item, fileName)
|
||||
for childIndex, instance in ipairs(existingChildren) do
|
||||
if not isExistingChildVisited[childIndex] then
|
||||
-- We guard accessing Name and ClassName in order to avoid
|
||||
-- tripping over children of DataModel that Rojo won't have
|
||||
-- permissions to access at all.
|
||||
local ok, name, className = pcall(function()
|
||||
return instance.Name, instance.ClassName
|
||||
end)
|
||||
|
||||
if parent.ClassName == className then
|
||||
rbx = parent
|
||||
else
|
||||
rbx = Reconciler._reify(item, fileName, parent.Parent)
|
||||
rbx.Name = parent.Name
|
||||
|
||||
for _, child in ipairs(parent:GetChildren()) do
|
||||
child.Parent = rbx
|
||||
-- This rule is very conservative and could be loosened in the
|
||||
-- future, or more heuristics could be introduced.
|
||||
if ok and name == apiChild.Name and className == apiChild.ClassName then
|
||||
childInstance = instance
|
||||
isExistingChildVisited[childIndex] = true
|
||||
break
|
||||
end
|
||||
|
||||
parent:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
setValues(rbx, item, fileName)
|
||||
|
||||
return rbx
|
||||
if childInstance ~= nil then
|
||||
-- We found an instance that matches the instance from the API, yay!
|
||||
self:__hydrateInternal(apiInstances, childId, childInstance, hydratePatch)
|
||||
else
|
||||
if not rbx then
|
||||
return Reconciler._reify(item, fileName, parent)
|
||||
end
|
||||
|
||||
local _, className = itemToName(item, fileName)
|
||||
|
||||
if rbx.ClassName ~= className then
|
||||
rbx:Destroy()
|
||||
return Reconciler._reify(item, fileName, parent)
|
||||
end
|
||||
|
||||
setValues(rbx, item, fileName)
|
||||
|
||||
return rbx
|
||||
markIdAdded(childId)
|
||||
end
|
||||
end
|
||||
|
||||
-- Any unvisited children at this point aren't known by Rojo and we can
|
||||
-- destroy them unless the user has explicitly asked us to preserve children
|
||||
-- of this instance.
|
||||
local shouldClearUnknown = self:__shouldClearUnknownChildren(apiInstance)
|
||||
if shouldClearUnknown then
|
||||
for childIndex, visited in ipairs(isExistingChildVisited) do
|
||||
if not visited then
|
||||
table.insert(hydratePatch.removed, existingChildren[childIndex])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Reconciler:__shouldClearUnknownChildren(apiInstance)
|
||||
if apiInstance.Metadata ~= nil then
|
||||
return not apiInstance.Metadata.ignoreUnknownInstances
|
||||
else
|
||||
error("unknown item type " .. tostring(item.type))
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function Reconciler.reconcileRoute(route, item)
|
||||
local location = game
|
||||
|
||||
for i = 1, #route - 1 do
|
||||
local piece = route[i]
|
||||
local newLocation = location:FindFirstChild(piece)
|
||||
|
||||
if not newLocation then
|
||||
newLocation = Instance.new("Folder")
|
||||
newLocation.Name = piece
|
||||
newLocation.Parent = location
|
||||
end
|
||||
|
||||
location = newLocation
|
||||
end
|
||||
|
||||
local fileName = route[#route]
|
||||
|
||||
local name = itemToName(item, fileName)
|
||||
local rbx = location:FindFirstChild(name)
|
||||
Reconciler.reconcile(rbx, item, fileName, location)
|
||||
end
|
||||
|
||||
return Reconciler
|
||||
return Reconciler
|
||||
213
plugin/src/ServeSession.lua
Normal file
213
plugin/src/ServeSession.lua
Normal file
@@ -0,0 +1,213 @@
|
||||
local Log = require(script.Parent.Parent.Log)
|
||||
local Fmt = require(script.Parent.Parent.Fmt)
|
||||
local t = require(script.Parent.Parent.t)
|
||||
|
||||
local DevSettings = require(script.Parent.DevSettings)
|
||||
local InstanceMap = require(script.Parent.InstanceMap)
|
||||
local Reconciler = require(script.Parent.Reconciler)
|
||||
local strict = require(script.Parent.strict)
|
||||
|
||||
local Status = strict("Session.Status", {
|
||||
NotStarted = "NotStarted",
|
||||
Connecting = "Connecting",
|
||||
Connected = "Connected",
|
||||
Disconnected = "Disconnected",
|
||||
})
|
||||
|
||||
local function debugPatch(patch)
|
||||
return Fmt.debugify(patch, function(patch, output)
|
||||
output:writeLine("Patch {{")
|
||||
output:indent()
|
||||
|
||||
for removed in ipairs(patch.removed) do
|
||||
output:writeLine("Remove ID {}", removed)
|
||||
end
|
||||
|
||||
for id, added in pairs(patch.added) do
|
||||
output:writeLine("Add ID {} {:#?}", id, added)
|
||||
end
|
||||
|
||||
for _, updated in ipairs(patch.updated) do
|
||||
output:writeLine("Update ID {} {:#?}", updated.id, updated)
|
||||
end
|
||||
|
||||
output:unindent()
|
||||
output:write("}")
|
||||
end)
|
||||
end
|
||||
|
||||
local ServeSession = {}
|
||||
ServeSession.__index = ServeSession
|
||||
|
||||
ServeSession.Status = Status
|
||||
|
||||
local validateServeOptions = t.strictInterface({
|
||||
apiContext = t.table,
|
||||
})
|
||||
|
||||
function ServeSession.new(options)
|
||||
assert(validateServeOptions(options))
|
||||
|
||||
-- Declare self ahead of time to capture it in a closure
|
||||
local self
|
||||
local function onInstanceChanged(instance, propertyName)
|
||||
self:__onInstanceChanged(instance, propertyName)
|
||||
end
|
||||
|
||||
local instanceMap = InstanceMap.new(onInstanceChanged)
|
||||
local reconciler = Reconciler.new(instanceMap)
|
||||
|
||||
self = {
|
||||
__status = Status.NotStarted,
|
||||
__apiContext = options.apiContext,
|
||||
__reconciler = reconciler,
|
||||
__instanceMap = instanceMap,
|
||||
__statusChangedCallback = nil,
|
||||
}
|
||||
|
||||
setmetatable(self, ServeSession)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function ServeSession:__fmtDebug(output)
|
||||
output:writeLine("ServeSession {{")
|
||||
output:indent()
|
||||
|
||||
output:writeLine("API Context: {:#?}", self.__apiContext)
|
||||
output:writeLine("Instances: {:#?}", self.__instanceMap)
|
||||
|
||||
output:unindent()
|
||||
output:write("}")
|
||||
end
|
||||
|
||||
function ServeSession:onStatusChanged(callback)
|
||||
self.__statusChangedCallback = callback
|
||||
end
|
||||
|
||||
function ServeSession:start()
|
||||
self:__setStatus(Status.Connecting)
|
||||
|
||||
self.__apiContext:connect()
|
||||
:andThen(function(serverInfo)
|
||||
self:__setStatus(Status.Connected)
|
||||
|
||||
local rootInstanceId = serverInfo.rootInstanceId
|
||||
|
||||
return self:__initialSync(rootInstanceId)
|
||||
:andThen(function()
|
||||
return self:__mainSyncLoop()
|
||||
end)
|
||||
end)
|
||||
:catch(function(err)
|
||||
self:__stopInternal(err)
|
||||
end)
|
||||
end
|
||||
|
||||
function ServeSession:stop()
|
||||
self:__stopInternal()
|
||||
end
|
||||
|
||||
function ServeSession:__onInstanceChanged(instance, propertyName)
|
||||
if not DevSettings:twoWaySyncEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local instanceId = self.__instanceMap.fromInstances[instance]
|
||||
|
||||
if instanceId == nil then
|
||||
Log.warn("Ignoring change for instance {:?} as it is unknown to Rojo", instance)
|
||||
return
|
||||
end
|
||||
|
||||
local remove = nil
|
||||
|
||||
local update = {
|
||||
id = instanceId,
|
||||
changedProperties = {},
|
||||
}
|
||||
|
||||
if propertyName == "Name" then
|
||||
update.changedName = instance.Name
|
||||
elseif propertyName == "Parent" then
|
||||
if instance.Parent == nil then
|
||||
update = nil
|
||||
remove = instanceId
|
||||
else
|
||||
Log.warn("Cannot sync non-nil Parent property changes yet")
|
||||
return
|
||||
end
|
||||
else
|
||||
local success, encoded = self.__reconciler:encodeApiValue(instance[propertyName])
|
||||
|
||||
if not success then
|
||||
Log.warn("Could not sync back property {:?}.{}", instance, propertyName)
|
||||
return
|
||||
end
|
||||
|
||||
update.changedProperties[propertyName] = encoded
|
||||
end
|
||||
|
||||
local patch = {
|
||||
removed = {remove},
|
||||
added = {},
|
||||
updated = {update},
|
||||
}
|
||||
|
||||
self.__apiContext:write(patch)
|
||||
end
|
||||
|
||||
function ServeSession:__initialSync(rootInstanceId)
|
||||
return self.__apiContext:read({ rootInstanceId })
|
||||
:andThen(function(readResponseBody)
|
||||
-- Tell the API Context that we're up-to-date with the version of
|
||||
-- the tree defined in this response.
|
||||
self.__apiContext:setMessageCursor(readResponseBody.messageCursor)
|
||||
|
||||
Log.trace("Computing changes that plugin needs to make to catch up to server...")
|
||||
|
||||
-- Calculate the initial patch to apply to the DataModel to catch us
|
||||
-- up to what Rojo thinks the place should look like.
|
||||
local hydratePatch = self.__reconciler:hydrate(
|
||||
readResponseBody.instances,
|
||||
rootInstanceId,
|
||||
game
|
||||
)
|
||||
|
||||
Log.trace("Computed hydration patch: {:#?}", debugPatch(hydratePatch))
|
||||
|
||||
-- TODO: Prompt user to notify them of this patch, since it's
|
||||
-- effectively a conflict between the Rojo server and the client.
|
||||
|
||||
self.__reconciler:applyPatch(hydratePatch)
|
||||
end)
|
||||
end
|
||||
|
||||
function ServeSession:__mainSyncLoop()
|
||||
return self.__apiContext:retrieveMessages()
|
||||
:andThen(function(messages)
|
||||
for _, message in ipairs(messages) do
|
||||
self.__reconciler:applyPatch(message)
|
||||
end
|
||||
|
||||
if self.__status ~= Status.Disconnected then
|
||||
return self:__mainSyncLoop()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ServeSession:__stopInternal(err)
|
||||
self:__setStatus(Status.Disconnected, err)
|
||||
self.__apiContext:disconnect()
|
||||
self.__instanceMap:stop()
|
||||
end
|
||||
|
||||
function ServeSession:__setStatus(status, detail)
|
||||
self.__status = status
|
||||
|
||||
if self.__statusChangedCallback ~= nil then
|
||||
self.__statusChangedCallback(status, detail)
|
||||
end
|
||||
end
|
||||
|
||||
return ServeSession
|
||||
@@ -1,69 +0,0 @@
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local Server = {}
|
||||
Server.__index = Server
|
||||
|
||||
--[[
|
||||
Create a new Server using the given HTTP implementation and replacer.
|
||||
|
||||
If the context becomes invalid, `replacer` will be invoked with a new
|
||||
context that should be suitable to replace this one.
|
||||
|
||||
Attempting to invoke methods on an invalid conext will throw errors!
|
||||
]]
|
||||
function Server.connect(http)
|
||||
local context = {
|
||||
http = http,
|
||||
serverId = nil,
|
||||
currentTime = 0,
|
||||
}
|
||||
|
||||
setmetatable(context, Server)
|
||||
|
||||
return context:_start()
|
||||
end
|
||||
|
||||
function Server:_start()
|
||||
return self:getInfo()
|
||||
:andThen(function(response)
|
||||
self.serverId = response.serverId
|
||||
self.currentTime = response.currentTime
|
||||
|
||||
return self
|
||||
end)
|
||||
end
|
||||
|
||||
function Server:getInfo()
|
||||
return self.http:get("/")
|
||||
:andThen(function(response)
|
||||
response = response:json()
|
||||
|
||||
return response
|
||||
end)
|
||||
end
|
||||
|
||||
function Server:read(paths)
|
||||
local body = HttpService:JSONEncode(paths)
|
||||
|
||||
return self.http:post("/read", body)
|
||||
:andThen(function(response)
|
||||
response = response:json()
|
||||
|
||||
return response.items
|
||||
end)
|
||||
end
|
||||
|
||||
function Server:getChanges()
|
||||
local url = ("/changes/%f"):format(self.currentTime)
|
||||
|
||||
return self.http:get(url)
|
||||
:andThen(function(response)
|
||||
response = response:json()
|
||||
|
||||
self.currentTime = response.currentTime
|
||||
|
||||
return response.changes
|
||||
end)
|
||||
end
|
||||
|
||||
return Server
|
||||
99
plugin/src/Types.lua
Normal file
99
plugin/src/Types.lua
Normal file
@@ -0,0 +1,99 @@
|
||||
local t = require(script.Parent.Parent.t)
|
||||
|
||||
local DevSettings = require(script.Parent.DevSettings)
|
||||
local strict = require(script.Parent.strict)
|
||||
|
||||
local RbxId = t.string
|
||||
|
||||
local ApiValue = t.interface({
|
||||
Type = t.string,
|
||||
Value = t.optional(t.any),
|
||||
})
|
||||
|
||||
local ApiInstanceMetadata = t.interface({
|
||||
ignoreUnknownInstances = t.optional(t.boolean),
|
||||
})
|
||||
|
||||
local ApiInstance = t.interface({
|
||||
Id = RbxId,
|
||||
Parent = t.optional(RbxId),
|
||||
Name = t.string,
|
||||
ClassName = t.string,
|
||||
Properties = t.map(t.string, ApiValue),
|
||||
Metadata = t.optional(ApiInstanceMetadata),
|
||||
Children = t.array(RbxId),
|
||||
})
|
||||
|
||||
local ApiInstanceUpdate = t.interface({
|
||||
id = RbxId,
|
||||
changedName = t.optional(t.string),
|
||||
changedClassName = t.optional(t.string),
|
||||
changedProperties = t.map(t.string, ApiValue),
|
||||
changedMetadata = t.optional(ApiInstanceMetadata),
|
||||
})
|
||||
|
||||
local ApiSubscribeMessage = t.interface({
|
||||
removed = t.array(RbxId),
|
||||
added = t.map(RbxId, ApiInstance),
|
||||
updated = t.array(ApiInstanceUpdate),
|
||||
})
|
||||
|
||||
local ApiInfoResponse = t.interface({
|
||||
sessionId = t.string,
|
||||
serverVersion = t.string,
|
||||
protocolVersion = t.number,
|
||||
expectedPlaceIds = t.optional(t.array(t.number)),
|
||||
rootInstanceId = RbxId,
|
||||
})
|
||||
|
||||
local ApiReadResponse = t.interface({
|
||||
sessionId = t.string,
|
||||
messageCursor = t.number,
|
||||
instances = t.map(RbxId, ApiInstance),
|
||||
})
|
||||
|
||||
local ApiSubscribeResponse = t.interface({
|
||||
sessionId = t.string,
|
||||
messageCursor = t.number,
|
||||
messages = t.array(ApiSubscribeMessage),
|
||||
})
|
||||
|
||||
local ApiError = t.interface({
|
||||
kind = t.union(
|
||||
t.literal("NotFound"),
|
||||
t.literal("BadRequest"),
|
||||
t.literal("InternalError")
|
||||
),
|
||||
details = t.string,
|
||||
})
|
||||
|
||||
local function ifEnabled(innerCheck)
|
||||
return function(...)
|
||||
if DevSettings:shouldTypecheck() then
|
||||
return innerCheck(...)
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return strict("Types", {
|
||||
ifEnabled = ifEnabled,
|
||||
|
||||
ApiInfoResponse = ApiInfoResponse,
|
||||
ApiReadResponse = ApiReadResponse,
|
||||
ApiSubscribeResponse = ApiSubscribeResponse,
|
||||
ApiError = ApiError,
|
||||
|
||||
ApiInstance = ApiInstance,
|
||||
ApiInstanceUpdate = ApiInstanceUpdate,
|
||||
ApiInstanceMetadata = ApiInstanceMetadata,
|
||||
ApiSubscribeMessage = ApiSubscribeMessage,
|
||||
ApiValue = ApiValue,
|
||||
RbxId = RbxId,
|
||||
|
||||
-- Deprecated aliases during transition
|
||||
VirtualInstance = ApiInstance,
|
||||
VirtualMetadata = ApiInstanceMetadata,
|
||||
VirtualValue = ApiValue,
|
||||
})
|
||||
46
plugin/src/Version.lua
Normal file
46
plugin/src/Version.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
local function compare(a, b)
|
||||
if a > b then
|
||||
return 1
|
||||
elseif a < b then
|
||||
return -1
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
local Version = {}
|
||||
|
||||
--[[
|
||||
Compares two versions of the form {major, minor, revision}.
|
||||
|
||||
If a is newer than b, 1.
|
||||
If a is older than b, -1.
|
||||
If a and b are the same, 0.
|
||||
]]
|
||||
function Version.compare(a, b)
|
||||
local major = compare(a[1], b[1])
|
||||
local minor = compare(a[2] or 0, b[2] or 0)
|
||||
local revision = compare(a[3] or 0, b[3] or 0)
|
||||
|
||||
if major ~= 0 then
|
||||
return major
|
||||
end
|
||||
|
||||
if minor ~= 0 then
|
||||
return minor
|
||||
end
|
||||
|
||||
return revision
|
||||
end
|
||||
|
||||
function Version.display(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
|
||||
28
plugin/src/Version.spec.lua
Normal file
28
plugin/src/Version.spec.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
return function()
|
||||
local Version = require(script.Parent.Version)
|
||||
|
||||
it("should compare equal versions", function()
|
||||
expect(Version.compare({1, 2, 3}, {1, 2, 3})).to.equal(0)
|
||||
expect(Version.compare({0, 4, 0}, {0, 4})).to.equal(0)
|
||||
expect(Version.compare({0, 0, 123}, {0, 0, 123})).to.equal(0)
|
||||
expect(Version.compare({26}, {26})).to.equal(0)
|
||||
expect(Version.compare({26, 42}, {26, 42})).to.equal(0)
|
||||
expect(Version.compare({1, 0, 0}, {1})).to.equal(0)
|
||||
end)
|
||||
|
||||
it("should compare newer, older versions", function()
|
||||
expect(Version.compare({1}, {0})).to.equal(1)
|
||||
expect(Version.compare({1, 1}, {1, 0})).to.equal(1)
|
||||
end)
|
||||
|
||||
it("should compare different major versions", function()
|
||||
expect(Version.compare({1, 3, 2}, {2, 2, 1})).to.equal(-1)
|
||||
expect(Version.compare({1, 2}, {2, 1})).to.equal(-1)
|
||||
expect(Version.compare({1}, {2})).to.equal(-1)
|
||||
end)
|
||||
|
||||
it("should compare different minor versions", function()
|
||||
expect(Version.compare({1, 2, 3}, {1, 3, 2})).to.equal(-1)
|
||||
expect(Version.compare({50, 1}, {50, 2})).to.equal(-1)
|
||||
end)
|
||||
end
|
||||
39
plugin/src/getCanonicalProperty.lua
Normal file
39
plugin/src/getCanonicalProperty.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
local RbxDom = require(script.Parent.Parent.RbxDom)
|
||||
|
||||
--[[
|
||||
Attempts to set a property on the given instance.
|
||||
]]
|
||||
local function getCanonincalProperty(instance, propertyName)
|
||||
local descriptor = RbxDom.findCanonicalPropertyDescriptor(instance.ClassName, propertyName)
|
||||
|
||||
-- We can skip unknown properties; they're not likely reflected to Lua.
|
||||
--
|
||||
-- A good example of a property like this is `Model.ModelInPrimary`, which
|
||||
-- is serialized but not reflected to Lua.
|
||||
if descriptor == nil then
|
||||
return false, "unknown property"
|
||||
end
|
||||
|
||||
if descriptor.scriptability == "None" or descriptor.scriptability == "Write" then
|
||||
return false, "unreadable property"
|
||||
end
|
||||
|
||||
local success, valueOrErr = descriptor:read(instance)
|
||||
|
||||
if not success then
|
||||
local err = valueOrErr
|
||||
|
||||
-- If we don't have permission to read a property, we can chalk that up
|
||||
-- to our database being out of date and the engine being right.
|
||||
if err.kind == RbxDom.Error.Kind.Roblox and err.extra:find("lacking permission") then
|
||||
return false, "permission error"
|
||||
end
|
||||
|
||||
local message = ("Invalid property %s.%s: %s"):format(descriptor.className, descriptor.name, tostring(err))
|
||||
error(message, 2)
|
||||
end
|
||||
|
||||
return true, valueOrErr
|
||||
end
|
||||
|
||||
return getCanonincalProperty
|
||||
32
plugin/src/init.server.lua
Normal file
32
plugin/src/init.server.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
if not plugin then
|
||||
return
|
||||
end
|
||||
|
||||
local Log = require(script.Parent.Log)
|
||||
|
||||
local DevSettings = require(script.DevSettings)
|
||||
|
||||
Log.setLogLevelThunk(function()
|
||||
return DevSettings:getLogLevel()
|
||||
end)
|
||||
|
||||
local Roact = require(script.Parent.Roact)
|
||||
|
||||
local Config = require(script.Config)
|
||||
local App = require(script.Components.App)
|
||||
|
||||
local app = Roact.createElement(App, {
|
||||
plugin = plugin,
|
||||
})
|
||||
|
||||
local tree = Roact.mount(app, nil, "Rojo UI")
|
||||
|
||||
plugin.Unloading:Connect(function()
|
||||
Roact.unmount(tree)
|
||||
end)
|
||||
|
||||
if Config.isDevBuild then
|
||||
local TestEZ = require(script.Parent.TestEZ)
|
||||
|
||||
require(script.runTests)(TestEZ)
|
||||
end
|
||||
15
plugin/src/init.spec.lua
Normal file
15
plugin/src/init.spec.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
return function()
|
||||
it("should load all submodules", function()
|
||||
local function loadRecursive(container)
|
||||
if container:IsA("ModuleScript") and not container.Name:find("%.spec$") then
|
||||
require(container)
|
||||
end
|
||||
|
||||
for _, child in ipairs(container:GetChildren()) do
|
||||
loadRecursive(child)
|
||||
end
|
||||
end
|
||||
|
||||
loadRecursive(script.Parent)
|
||||
end)
|
||||
end
|
||||
29
plugin/src/invariant.lua
Normal file
29
plugin/src/invariant.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
local Fmt = require(script.Parent.Parent.Fmt)
|
||||
|
||||
local Config = require(script.Parent.Config)
|
||||
|
||||
local invariant
|
||||
|
||||
if Config.isDevBuild then
|
||||
function invariant(message, ...)
|
||||
message = Fmt.fmt(message, ...)
|
||||
|
||||
error("Invariant violation: " .. message, 2)
|
||||
end
|
||||
else
|
||||
function invariant(message, ...)
|
||||
message = Fmt.fmt(message, ...)
|
||||
|
||||
local fullMessage = string.format(
|
||||
"Rojo detected an invariant violation within itself:\n" ..
|
||||
"%s\n\n" ..
|
||||
"This is a bug in Rojo. Please file an issue:\n" ..
|
||||
"https://github.com/rojo-rbx/rojo/issues",
|
||||
message
|
||||
)
|
||||
|
||||
error(fullMessage, 2)
|
||||
end
|
||||
end
|
||||
|
||||
return invariant
|
||||
29
plugin/src/preloadAssets.lua
Normal file
29
plugin/src/preloadAssets.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
local ContentProvider = game:GetService("ContentProvider")
|
||||
|
||||
local Log = require(script.Parent.Parent.Log)
|
||||
|
||||
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
|
||||
|
||||
Log.trace("Preloading assets: {:?}", contentUrls)
|
||||
|
||||
coroutine.wrap(function()
|
||||
ContentProvider:PreloadAsync(contentUrls)
|
||||
end)()
|
||||
end
|
||||
|
||||
return preloadAssets
|
||||
@@ -1,4 +1,5 @@
|
||||
return function()
|
||||
local TestEZ = require(script.Parent.Parent.TestEZ)
|
||||
TestEZ.TestBootstrap:run(script.Parent)
|
||||
end
|
||||
return function(TestEZ)
|
||||
local Rojo = script.Parent.Parent
|
||||
|
||||
TestEZ.TestBootstrap:run({ Rojo.Plugin, Rojo.Http, Rojo.Log })
|
||||
end
|
||||
37
plugin/src/setCanonicalProperty.lua
Normal file
37
plugin/src/setCanonicalProperty.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
local RbxDom = require(script.Parent.Parent.RbxDom)
|
||||
|
||||
--[[
|
||||
Attempts to set a property on the given instance.
|
||||
]]
|
||||
local function setCanonicalProperty(instance, propertyName, value)
|
||||
local descriptor = RbxDom.findCanonicalPropertyDescriptor(instance.ClassName, propertyName)
|
||||
|
||||
-- We can skip unknown properties; they're not likely reflected to Lua.
|
||||
--
|
||||
-- A good example of a property like this is `Model.ModelInPrimary`, which
|
||||
-- is serialized but not reflected to Lua.
|
||||
if descriptor == nil then
|
||||
return false, "unknown property"
|
||||
end
|
||||
|
||||
if descriptor.scriptability == "None" or descriptor.scriptability == "Read" then
|
||||
return false, "unwritable property"
|
||||
end
|
||||
|
||||
local success, err = descriptor:write(instance, value)
|
||||
|
||||
if not success then
|
||||
-- If we don't have permission to write a property, we just silently
|
||||
-- ignore it.
|
||||
if err.kind == RbxDom.Error.Kind.Roblox and err.extra:find("lacking permission") then
|
||||
return false, "permission error"
|
||||
end
|
||||
|
||||
local message = ("Invalid property %s.%s: %s"):format(descriptor.className, descriptor.name, tostring(err))
|
||||
error(message, 2)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return setCanonicalProperty
|
||||
24
plugin/src/strict.lua
Normal file
24
plugin/src/strict.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
local function strictInner(name, target)
|
||||
assert(type(name) == "string", "Argument #1 to `strict` must be a string or the table to modify")
|
||||
assert(type(target) == "table", "Argument #2 to `strict` must be nil or the table to modify")
|
||||
|
||||
setmetatable(target, {
|
||||
__index = function(_, key)
|
||||
error(("%q is not a valid member of strict table %q"):format(tostring(key), name), 2)
|
||||
end,
|
||||
|
||||
__newindex = function()
|
||||
error(("Strict table %q is read-only"):format(name), 2)
|
||||
end,
|
||||
})
|
||||
|
||||
return target
|
||||
end
|
||||
|
||||
return function(nameOrTarget, target)
|
||||
if type(nameOrTarget) == "string" then
|
||||
return strictInner(nameOrTarget, target)
|
||||
else
|
||||
return strictInner("<unnamed table>", target)
|
||||
end
|
||||
end
|
||||
19
plugin/testBootstrap.server.lua
Normal file
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
|
||||
|
||||
require(Rojo.Plugin.runTests)(TestEZ)
|
||||
|
||||
if setDevSettings then
|
||||
DevSettings:resetValues()
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user