Compare commits

..

1 Commits

Author SHA1 Message Date
Lucien Greathouse
273974b74f SmallString implementation 2022-05-27 02:54:33 -04:00
34 changed files with 281 additions and 527 deletions

View File

@@ -2,11 +2,6 @@
## Unreleased Changes
* Switched from structopt to clap for command line argument parsing.
* Significantly improved performance of building and serving. ([#548])
* Fixed `init.meta.json` when used with `init.lua` and related files. ([#549])
[#548]: https://github.com/rojo-rbx/rojo/pull/548
[#549]: https://github.com/rojo-rbx/rojo/pull/549
## [7.1.1] - May 26, 2022
* Fixed sourcemap command not stripping paths correctly ([#544])

331
Cargo.lock generated
View File

@@ -49,9 +49,9 @@ checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
[[package]]
name = "arrayvec"
version = "0.7.2"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "atty"
@@ -114,16 +114,17 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "blake3"
version = "1.3.1"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f"
checksum = "46080006c1505f12f64dd2a09264b343381ed3190fa02c8005d5d662ac571c63"
dependencies = [
"arrayref",
"arrayvec",
"cc",
"cfg-if 1.0.0",
"cfg-if 0.1.10",
"constant_time_eq",
"digest 0.10.3",
"crypto-mac",
"digest",
]
[[package]]
@@ -135,16 +136,7 @@ dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array 0.12.4",
]
[[package]]
name = "block-buffer"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324"
dependencies = [
"generic-array 0.14.5",
"generic-array",
]
[[package]]
@@ -170,9 +162,9 @@ dependencies = [
[[package]]
name = "bumpalo"
version = "3.10.0"
version = "3.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
[[package]]
name = "byte-tools"
@@ -386,13 +378,13 @@ dependencies = [
]
[[package]]
name = "crypto-common"
version = "0.1.3"
name = "crypto-mac"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8"
checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5"
dependencies = [
"generic-array 0.14.5",
"typenum",
"generic-array",
"subtle",
]
[[package]]
@@ -439,18 +431,7 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
"generic-array 0.12.4",
]
[[package]]
name = "digest"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506"
dependencies = [
"block-buffer 0.10.2",
"crypto-common",
"subtle",
"generic-array",
]
[[package]]
@@ -709,19 +690,6 @@ dependencies = [
"slab",
]
[[package]]
name = "generator"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1d9279ca822891c1a4dae06d185612cf8fc6acfe5dff37781b41297811b12ee"
dependencies = [
"cc",
"libc",
"log",
"rustversion",
"winapi 0.3.9",
]
[[package]]
name = "generic-array"
version = "0.12.4"
@@ -732,13 +700,14 @@ dependencies = [
]
[[package]]
name = "generic-array"
version = "0.14.5"
name = "getrandom"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"typenum",
"version_check",
"cfg-if 1.0.0",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]]
@@ -749,7 +718,7 @@ checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [
"cfg-if 1.0.0",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasi 0.10.0+wasi-snapshot-preview1",
]
[[package]]
@@ -865,9 +834,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "hyper"
version = "0.14.19"
version = "0.14.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f"
checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2"
dependencies = [
"bytes",
"futures-channel",
@@ -913,9 +882,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.8.2"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
dependencies = [
"autocfg",
"hashbrown",
@@ -943,9 +912,9 @@ dependencies = [
[[package]]
name = "insta"
version = "1.14.1"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc3e639bcba360d9237acabd22014c16f3df772db463b7446cd81b070714767"
checksum = "689960f187c43c01650c805fb6bc6f55ab944499d86d4ffe9474ad78991d8e94"
dependencies = [
"console",
"once_cell",
@@ -1060,19 +1029,6 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "loom"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5"
dependencies = [
"cfg-if 1.0.0",
"generator",
"scoped-tls",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "lz4"
version = "1.23.3"
@@ -1099,15 +1055,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]]
name = "matches"
version = "0.1.9"
@@ -1147,9 +1094,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "miniz_oxide"
version = "0.5.3"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc"
checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082"
dependencies = [
"adler",
]
@@ -1286,9 +1233,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.12.0"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
checksum = "7b10983b38c53aebdf33f542c6275b0f58a238129d00c4ae0e6fb59738d783ca"
[[package]]
name = "oorandom"
@@ -1346,9 +1293,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.74"
version = "0.9.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1"
checksum = "9d5fd19fb3e0a8191c1e34935718976a3e70c112ab9a24af6d7cadccd9d90bc0"
dependencies = [
"autocfg",
"cc",
@@ -1552,7 +1499,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f61dcf0b917cd75d4521d7343d1ffff3d1583054133c9b5cbea3375c703c40d"
dependencies = [
"profiling-procmacros",
"tracy-client",
"superluminal-perf",
]
[[package]]
@@ -1585,20 +1532,22 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.5"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom 0.1.16",
"libc",
"rand_chacha",
"rand_core",
"rand_hc",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
"ppv-lite86",
"rand_core",
@@ -1606,11 +1555,20 @@ dependencies = [
[[package]]
name = "rand_core"
version = "0.6.3"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom",
"getrandom 0.1.16",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
"rand_core",
]
[[package]]
@@ -1653,9 +1611,9 @@ dependencies = [
[[package]]
name = "rbx_dom_weak"
version = "2.4.0"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7cc2238fd858d706f4f5c6a0f9af3cd4a10f3f8dc8b6534e683f8543af26f33"
checksum = "6f7f524fb18f30d7065c82c4e87f747705679329810207e96169c6d4ec922d1f"
dependencies = [
"rbx_types",
"serde",
@@ -1685,11 +1643,11 @@ dependencies = [
[[package]]
name = "rbx_types"
version = "1.4.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbfc0ca9c674968170d4fbbd95dc692d0b3f9405b4830babc76107dc00a66380"
checksum = "d637383aa560cb675b7ea7a7778b945dab065ccc7c158f77b5455e27efadc6df"
dependencies = [
"base64 0.13.0",
"base64 0.11.0",
"bitflags",
"blake3",
"lazy_static",
@@ -1727,7 +1685,7 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
"getrandom 0.2.6",
"redox_syscall",
"thiserror",
]
@@ -1748,9 +1706,6 @@ name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-syntax"
@@ -1861,7 +1816,15 @@ dependencies = [
]
[[package]]
name = "rojo"
name = "rojo-insta-ext"
version = "0.1.0"
dependencies = [
"serde",
"serde_yaml",
]
[[package]]
name = "rojo-smallstring"
version = "7.1.1"
dependencies = [
"anyhow",
@@ -1900,24 +1863,16 @@ dependencies = [
"serde",
"serde_json",
"serde_yaml",
"smol_str",
"tempfile",
"termcolor",
"thiserror",
"tokio",
"tracy-client",
"uuid",
"walkdir",
"winreg 0.10.1",
]
[[package]]
name = "rojo-insta-ext"
version = "0.1.0"
dependencies = [
"serde",
"serde_yaml",
]
[[package]]
name = "rustc-demangle"
version = "0.1.21"
@@ -1933,12 +1888,6 @@ dependencies = [
"semver",
]
[[package]]
name = "rustversion"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
[[package]]
name = "ryu"
version = "1.0.10"
@@ -1964,12 +1913,6 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "scopeguard"
version = "1.1.0"
@@ -2076,21 +2019,12 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
dependencies = [
"block-buffer 0.7.3",
"digest 0.8.1",
"block-buffer",
"digest",
"fake-simd",
"opaque-debug",
]
[[package]]
name = "sharded-slab"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
dependencies = [
"lazy_static",
]
[[package]]
name = "similar"
version = "2.1.0"
@@ -2104,10 +2038,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
[[package]]
name = "smallvec"
version = "1.8.0"
name = "smol_str"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
checksum = "7475118a28b7e3a2e157ce0131ba8c5526ea96e90ee601d9f6bb2e286a35ab44"
dependencies = [
"serde",
]
[[package]]
name = "snax"
@@ -2136,15 +2073,30 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "subtle"
version = "2.4.1"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee"
[[package]]
name = "superluminal-perf"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80ed8ddf5d2a4a849fa7dc75b3e0be740adb882fe7fee87e79584402ac9b1e60"
dependencies = [
"superluminal-perf-sys",
]
[[package]]
name = "superluminal-perf-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0342a02bcc62538822a46f54294130677f026666c2e19d078fc213b7bc07ff16"
[[package]]
name = "syn"
version = "1.0.96"
version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942"
dependencies = [
"proc-macro2 1.0.39",
"quote 1.0.18",
@@ -2219,15 +2171,6 @@ dependencies = [
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
dependencies = [
"once_cell",
]
[[package]]
name = "tinytemplate"
version = "1.2.1"
@@ -2255,9 +2198,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.19.1"
version = "1.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95eec79ea28c00a365f539f1961e9278fbcaf81c0ff6aaf0e93c181352446948"
checksum = "4903bf0427cf68dddd5aa6a93220756f8be0c34fcfa9f5e6191e103e15a31395"
dependencies = [
"bytes",
"libc",
@@ -2282,9 +2225,9 @@ dependencies = [
[[package]]
name = "tokio-util"
version = "0.7.3"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45"
checksum = "f988a1a1adc2fb21f9c12aa96441da33a1728193ae0b95d2be22dbd17fcb4e5c"
dependencies = [
"bytes",
"futures-core",
@@ -2339,56 +2282,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f"
dependencies = [
"lazy_static",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596"
dependencies = [
"ansi_term",
"lazy_static",
"matchers",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
name = "tracy-client"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ebfe7a24c18b5ba86d8920c124b41b942352f863fbe0c84d3d63428fa1860f"
dependencies = [
"loom",
"once_cell",
"tracy-client-sys",
]
[[package]]
name = "tracy-client-sys"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9012b9dfeccaff16e93f5a8b02336125113a80a769902e679d334cbdd4d83f3b"
dependencies = [
"cc",
]
[[package]]
@@ -2456,20 +2349,14 @@ dependencies = [
[[package]]
name = "uuid"
version = "1.1.1"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6d5d669b51467dcf7b2f1a796ce0f955f05f01cafda6c19d6e95f730df29238"
checksum = "8cfcd319456c4d6ea10087ed423473267e1a071f3bc0aa89f80d60997843c6f0"
dependencies = [
"getrandom",
"getrandom 0.2.6",
"serde",
]
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
@@ -2525,9 +2412,15 @@ dependencies = [
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "wasi"

View File

@@ -1,5 +1,5 @@
[package]
name = "rojo"
name = "rojo-smallstring"
version = "7.1.1"
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
description = "Enables professional-grade development tools for Roblox developers"
@@ -27,8 +27,6 @@ default = []
# Enable this feature to live-reload assets from the web UI.
dev_live_assets = []
profile-with-tracy = ["profiling/profile-with-tracy", "tracy-client"]
[workspace]
members = ["crates/*"]
@@ -51,7 +49,7 @@ memofs = { version = "0.2.0", path = "crates/memofs" }
# rbx_xml = { path = "../rbx-dom/rbx_xml" }
rbx_binary = "0.6.4"
rbx_dom_weak = "2.4.0"
rbx_dom_weak = "2.3.0"
rbx_reflection = "4.2.0"
rbx_reflection_database = "0.2.2"
rbx_xml = "0.12.3"
@@ -82,8 +80,8 @@ thiserror = "1.0.30"
tokio = { version = "1.12.0", features = ["rt", "rt-multi-thread"] }
uuid = { version = "1.0.0", features = ["v4", "serde"] }
clap = { version = "3.1.18", features = ["derive"] }
profiling = "1.0.6"
tracy-client = { version = "0.13.2", optional = true }
smol_str = "0.1.23"
profiling = { version = "1.0.6", features = ["profile-with-superluminal"] }
[target.'cfg(windows)'.dependencies]
winreg = "0.10.1"

View File

@@ -1,14 +0,0 @@
---
source: tests/tests/build.rs
assertion_line: 98
expression: contents
---
<roblox version="4">
<Item class="LocalScript" referent="0">
<Properties>
<string name="Name">issue_546</string>
<bool name="Disabled">true</bool>
<string name="Source">print("Hello, world!")</string>
</Properties>
</Item>
</roblox>

View File

@@ -1,2 +0,0 @@
# Issue #546 (https://github.com/rojo-rbx/rojo/issues/546)
Regression from Rojo 6.2.0 to Rojo 7.0.0. Meta files named as init.meta.json should apply after init.client.lua and other init files.

View File

@@ -1,6 +0,0 @@
{
"name": "issue_546",
"tree": {
"$path": "hello"
}
}

View File

@@ -1 +0,0 @@
print("Hello, world!")

View File

@@ -1,5 +0,0 @@
{
"properties": {
"Disabled": true
}
}

View File

@@ -46,6 +46,7 @@ pub struct ChangeProcessor {
impl ChangeProcessor {
/// Spin up the ChangeProcessor, connecting it to the given tree, VFS, and
/// outbound message queue.
#[profiling::function]
pub fn start(
tree: Arc<Mutex<RojoTree>>,
vfs: Arc<Vfs>,
@@ -291,7 +292,7 @@ fn compute_and_apply_changes(tree: &mut RojoTree, vfs: &Vfs, id: Ref) -> Option<
}
};
let patch_set = compute_patch_set(snapshot, &tree, id);
let patch_set = compute_patch_set(snapshot.as_ref(), &tree, id);
apply_patch_set(tree, patch_set)
}
Ok(None) => {
@@ -334,7 +335,7 @@ fn compute_and_apply_changes(tree: &mut RojoTree, vfs: &Vfs, id: Ref) -> Option<
}
};
let patch_set = compute_patch_set(snapshot, &tree, id);
let patch_set = compute_patch_set(snapshot.as_ref(), &tree, id);
apply_patch_set(tree, patch_set)
}
};

View File

@@ -1,6 +1,5 @@
use std::{
io::{BufWriter, Write},
mem::forget,
path::{Path, PathBuf},
};
@@ -62,10 +61,6 @@ impl BuildCommand {
}
}
// Avoid dropping ServeSession: it's potentially VERY expensive to drop
// and we're about to exit anyways.
forget(session);
Ok(())
}
}

View File

@@ -7,7 +7,6 @@ mod init;
mod plugin;
mod serve;
mod sourcemap;
mod unpack;
mod upload;
use std::{borrow::Cow, env, path::Path, str::FromStr};
@@ -22,7 +21,6 @@ pub use self::init::{InitCommand, InitKind};
pub use self::plugin::{PluginCommand, PluginSubcommand};
pub use self::serve::ServeCommand;
pub use self::sourcemap::SourcemapCommand;
pub use self::unpack::UnpackCommand;
pub use self::upload::UploadCommand;
/// Command line options that Rojo accepts, defined using the clap crate.
@@ -48,7 +46,6 @@ impl Options {
Subcommand::FmtProject(subcommand) => subcommand.run(),
Subcommand::Doc(subcommand) => subcommand.run(),
Subcommand::Plugin(subcommand) => subcommand.run(),
Subcommand::Unpack(subcommand) => subcommand.run(),
}
}
}
@@ -122,7 +119,6 @@ pub enum Subcommand {
FmtProject(FmtProjectCommand),
Doc(DocCommand),
Plugin(PluginCommand),
Unpack(UnpackCommand),
}
pub(super) fn resolve_path(path: &Path) -> Cow<'_, Path> {

View File

@@ -1,65 +0,0 @@
use std::{io::BufReader, path::PathBuf};
use anyhow::bail;
use clap::Parser;
use fs_err::File;
use rbx_dom_weak::{Instance, WeakDom};
use crate::{Project, ProjectNode};
use super::resolve_path;
/// Unpack a Roblox place file into an existing Rojo project.
#[derive(Debug, Parser)]
pub struct UnpackCommand {
/// Path to the project to unpack. Defaults to the current directory.
#[clap(long, default_value = "")]
pub project: PathBuf,
/// Path to the place to unpack from.
pub place: PathBuf,
}
impl UnpackCommand {
pub fn run(self) -> anyhow::Result<()> {
let project_path = resolve_path(&self.project);
let project = match Project::load_fuzzy(&project_path)? {
Some(project) => project,
None => bail!("No project file was found; rojo unpack requires a project file."),
};
let place_ext = self
.place
.extension()
.and_then(|ext| ext.to_str())
.map(|ext| ext.to_lowercase());
let file = BufReader::new(File::open(&self.place)?);
let dom = match place_ext.as_deref() {
Some("rbxl") => rbx_binary::from_reader(file)?,
Some("rbxlx") => rbx_xml::from_reader_default(file)?,
Some(_) | None => bail!("Place files must end in .rbxl or .rbxlx"),
};
let context = Context { project, dom };
context.unpack();
Ok(())
}
}
struct Context {
project: Project,
dom: WeakDom,
}
impl Context {
fn unpack(&self) {
self.unpack_node(&self.project.tree, self.dom.root());
}
fn unpack_node(&self, node: &ProjectNode, instance: &Instance) {
// TODO
}
}

View File

@@ -18,6 +18,7 @@ mod project;
mod resolution;
mod serve_session;
mod session_id;
mod small_string;
mod snapshot;
mod snapshot_middleware;
mod web;

View File

@@ -6,8 +6,7 @@ use clap::Parser;
use librojo::cli::Options;
fn main() {
#[cfg(feature = "profile-with-tracy")]
tracy_client::Client::start();
profiling::register_thread!("Main Thread");
panic::set_hook(Box::new(|panic_info| {
// PanicInfo's payload is usually a &'static str or String.

View File

@@ -96,6 +96,7 @@ impl ServeSession {
/// The project file is expected to be loaded out-of-band since it's
/// currently loaded from the filesystem directly instead of through the
/// in-memory filesystem layer.
#[profiling::function]
pub fn new<P: AsRef<Path>>(vfs: Vfs, start_path: P) -> Result<Self, ServeSessionError> {
let start_path = start_path.as_ref();
let start_time = Instant::now();
@@ -130,7 +131,7 @@ impl ServeSession {
let snapshot = snapshot_from_vfs(&instance_context, &vfs, &start_path)?;
log::trace!("Computing initial patch set");
let patch_set = compute_patch_set(snapshot, &tree, root_id);
let patch_set = compute_patch_set(snapshot.as_ref(), &tree, root_id);
log::trace!("Applying initial patch set");
apply_patch_set(&mut tree, patch_set);

1
src/small_string.rs Normal file
View File

@@ -0,0 +1 @@
pub use smol_str::SmolStr as SmallString;

View File

@@ -1,13 +1,15 @@
//! Defines the structure of an instance snapshot.
use std::{borrow::Cow, collections::HashMap};
use std::collections::HashMap;
use rbx_dom_weak::{
types::{Ref, Variant},
Instance, WeakDom,
WeakDom,
};
use serde::{Deserialize, Serialize};
use crate::small_string::SmallString;
use super::InstanceMetadata;
/// A lightweight description of what an instance should look like.
@@ -25,13 +27,13 @@ pub struct InstanceSnapshot {
pub metadata: InstanceMetadata,
/// Correpsonds to the Name property of the instance.
pub name: Cow<'static, str>,
pub name: SmallString,
/// Corresponds to the ClassName property of the instance.
pub class_name: Cow<'static, str>,
pub class_name: SmallString,
/// All other properties of the instance, weakly-typed.
pub properties: HashMap<String, Variant>,
pub properties: HashMap<SmallString, Variant>,
/// The children of the instance represented as more snapshots.
///
@@ -44,37 +46,37 @@ impl InstanceSnapshot {
Self {
snapshot_id: None,
metadata: InstanceMetadata::default(),
name: Cow::Borrowed("DEFAULT"),
class_name: Cow::Borrowed("DEFAULT"),
name: "DEFAULT".into(),
class_name: "DEFAULT".into(),
properties: HashMap::new(),
children: Vec::new(),
}
}
pub fn name(self, name: impl Into<String>) -> Self {
pub fn name(self, name: impl Into<SmallString>) -> Self {
Self {
name: Cow::Owned(name.into()),
name: name.into(),
..self
}
}
pub fn class_name(self, class_name: impl Into<String>) -> Self {
pub fn class_name(self, class_name: impl Into<SmallString>) -> Self {
Self {
class_name: Cow::Owned(class_name.into()),
class_name: class_name.into(),
..self
}
}
pub fn property<K, V>(mut self, key: K, value: V) -> Self
where
K: Into<String>,
K: Into<SmallString>,
V: Into<Variant>,
{
self.properties.insert(key.into(), value.into());
self
}
pub fn properties(self, properties: impl Into<HashMap<String, Variant>>) -> Self {
pub fn properties(self, properties: impl Into<HashMap<SmallString, Variant>>) -> Self {
Self {
properties: properties.into(),
..self
@@ -102,29 +104,28 @@ impl InstanceSnapshot {
}
}
#[profiling::function]
pub fn from_tree(tree: WeakDom, id: Ref) -> Self {
let (_, mut raw_tree) = tree.into_raw();
Self::from_raw_tree(&mut raw_tree, id)
}
fn from_raw_tree(raw_tree: &mut HashMap<Ref, Instance>, id: Ref) -> Self {
let instance = raw_tree
.remove(&id)
.expect("instance did not exist in tree");
pub fn from_tree(tree: &WeakDom, id: Ref) -> Self {
let instance = tree.get_by_ref(id).expect("instance did not exist in tree");
let children = instance
.children()
.iter()
.map(|&id| Self::from_raw_tree(raw_tree, id))
.copied()
.map(|id| Self::from_tree(tree, id))
.collect();
let properties = instance
.properties
.iter()
.map(|(key, value)| (key.into(), value.clone()))
.collect();
Self {
snapshot_id: Some(id),
metadata: InstanceMetadata::default(),
name: Cow::Owned(instance.name),
class_name: Cow::Owned(instance.class),
properties: instance.properties,
name: SmallString::from(&instance.name),
class_name: SmallString::from(&instance.class),
properties,
children,
}
}

View File

@@ -5,6 +5,8 @@ use std::collections::HashMap;
use rbx_dom_weak::types::{Ref, Variant};
use serde::{Deserialize, Serialize};
use crate::small_string::SmallString;
use super::{InstanceMetadata, InstanceSnapshot};
/// A set of different kinds of patches that can be applied to an WeakDom.
@@ -40,12 +42,12 @@ pub struct PatchAdd {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PatchUpdate {
pub id: Ref,
pub changed_name: Option<String>,
pub changed_class_name: Option<String>,
pub changed_name: Option<SmallString>,
pub changed_class_name: Option<SmallString>,
/// Contains all changed properties. If a property is assigned to `None`,
/// then that property has been removed.
pub changed_properties: HashMap<String, Option<Variant>>,
pub changed_properties: HashMap<SmallString, Option<Variant>>,
/// Changed Rojo-specific metadata, if any of it changed.
pub changed_metadata: Option<InstanceMetadata>,
@@ -83,9 +85,9 @@ pub struct AppliedPatchUpdate {
pub id: Ref,
// TODO: Store previous values in order to detect application conflicts
pub changed_name: Option<String>,
pub changed_class_name: Option<String>,
pub changed_properties: HashMap<String, Option<Variant>>,
pub changed_name: Option<SmallString>,
pub changed_class_name: Option<SmallString>,
pub changed_properties: HashMap<SmallString, Option<Variant>>,
pub changed_metadata: Option<InstanceMetadata>,
}

View File

@@ -1,12 +1,11 @@
//! Defines the algorithm for applying generated patches.
use std::{
collections::{HashMap, HashSet},
mem::take,
};
use std::collections::HashMap;
use rbx_dom_weak::types::{Ref, Variant};
use crate::small_string::SmallString;
use super::{
patch::{AppliedPatchSet, AppliedPatchUpdate, PatchSet, PatchUpdate},
InstanceSnapshot, RojoTree,
@@ -19,27 +18,18 @@ use super::{
pub fn apply_patch_set(tree: &mut RojoTree, patch_set: PatchSet) -> AppliedPatchSet {
let mut context = PatchApplyContext::default();
{
profiling::scope!("removals");
for removed_id in patch_set.removed_instances {
apply_remove_instance(&mut context, tree, removed_id);
}
for removed_id in patch_set.removed_instances {
apply_remove_instance(&mut context, tree, removed_id);
}
{
profiling::scope!("additions");
for add_patch in patch_set.added_instances {
apply_add_child(&mut context, tree, add_patch.parent_id, add_patch.instance);
}
for add_patch in patch_set.added_instances {
apply_add_child(&mut context, tree, add_patch.parent_id, add_patch.instance);
}
{
profiling::scope!("updates");
// Updates need to be applied after additions, which reduces the complexity
// of updates significantly.
for update_patch in patch_set.updated_instances {
apply_update_child(&mut context, tree, update_patch);
}
// Updates need to be applied after additions, which reduces the complexity
// of updates significantly.
for update_patch in patch_set.updated_instances {
apply_update_child(&mut context, tree, update_patch);
}
finalize_patch_application(context, tree)
@@ -68,9 +58,20 @@ struct PatchApplyContext {
/// eachother.
snapshot_id_to_instance_id: HashMap<Ref, Ref>,
/// Tracks all of the instances added by this patch that have refs that need
/// to be rewritten.
has_refs_to_rewrite: HashSet<Ref>,
/// The properties of instances added by the current `PatchSet`.
///
/// Instances added to the tree can refer to eachother via Ref properties,
/// but we need to make sure they're correctly transformed from snapshot
/// space into tree space (via `snapshot_id_to_instance_id`).
///
/// It's not possible to do that transformation for refs that refer to added
/// instances until all the instances have actually been inserted into the
/// tree. For simplicity, we defer application of _all_ properties on added
/// instances instead of just Refs.
///
/// This doesn't affect updated instances, since they're always applied
/// after we've added all the instances from the patch.
added_instance_properties: HashMap<Ref, HashMap<SmallString, Variant>>,
/// The current applied patch result, describing changes made to the tree.
applied_patch_set: AppliedPatchSet,
@@ -86,22 +87,25 @@ struct PatchApplyContext {
/// The remaining Ref properties need to be handled during patch application,
/// where we build up a map of snapshot IDs to instance IDs as they're created,
/// then apply properties all at once at the end.
#[profiling::function]
fn finalize_patch_application(context: PatchApplyContext, tree: &mut RojoTree) -> AppliedPatchSet {
for id in context.has_refs_to_rewrite {
for (id, properties) in context.added_instance_properties {
// This should always succeed since instances marked as added in our
// patch should be added without fail.
let mut instance = tree
.get_instance_mut(id)
.expect("Invalid instance ID in deferred property map");
for value in instance.properties_mut().values_mut() {
if let Variant::Ref(referent) = value {
for (key, mut property_value) in properties {
if let Variant::Ref(referent) = property_value {
if let Some(&instance_referent) = context.snapshot_id_to_instance_id.get(&referent)
{
*value = Variant::Ref(instance_referent);
property_value = Variant::Ref(instance_referent);
}
}
instance
.properties_mut()
.insert(key.to_string(), property_value);
}
}
@@ -117,24 +121,24 @@ fn apply_add_child(
context: &mut PatchApplyContext,
tree: &mut RojoTree,
parent_id: Ref,
mut snapshot: InstanceSnapshot,
snapshot: InstanceSnapshot,
) {
let snapshot_id = snapshot.snapshot_id;
let children = take(&mut snapshot.children);
let properties = snapshot.properties;
let children = snapshot.children;
// If an object we're adding has a non-null referent, we'll note this
// instance down as needing to be revisited later.
let has_refs = snapshot.properties.values().any(|value| match value {
Variant::Ref(value) => value.is_some(),
_ => false,
});
// Property application is deferred until after all children
// are constructed. This helps apply referents correctly.
let remaining_snapshot = InstanceSnapshot::new()
.name(snapshot.name)
.class_name(snapshot.class_name)
.metadata(snapshot.metadata)
.snapshot_id(snapshot.snapshot_id);
let id = tree.insert_instance(parent_id, snapshot);
let id = tree.insert_instance(parent_id, remaining_snapshot);
context.applied_patch_set.added.push(id);
if has_refs {
context.has_refs_to_rewrite.insert(id);
}
context.added_instance_properties.insert(id, properties);
if let Some(snapshot_id) = snapshot_id {
context.snapshot_id_to_instance_id.insert(snapshot_id, id);
@@ -165,13 +169,13 @@ fn apply_update_child(context: &mut PatchApplyContext, tree: &mut RojoTree, patc
};
if let Some(name) = patch.changed_name {
*instance.name_mut() = name.clone();
applied_patch.changed_name = Some(name);
*instance.name_mut() = name.to_string();
applied_patch.changed_name = Some(name.into());
}
if let Some(class_name) = patch.changed_class_name {
*instance.class_name_mut() = class_name.clone();
applied_patch.changed_class_name = Some(class_name);
*instance.class_name_mut() = class_name.to_string();
applied_patch.changed_class_name = Some(class_name.into());
}
for (key, property_entry) in patch.changed_properties {
@@ -196,13 +200,15 @@ fn apply_update_child(context: &mut PatchApplyContext, tree: &mut RojoTree, patc
instance
.properties_mut()
.insert(key.clone(), Variant::Ref(new_referent));
.insert(key.to_string(), Variant::Ref(new_referent));
}
Some(ref value) => {
instance.properties_mut().insert(key.clone(), value.clone());
instance
.properties_mut()
.insert(key.to_string(), value.clone());
}
None => {
instance.properties_mut().remove(&key);
instance.properties_mut().remove(key.as_str());
}
}

View File

@@ -1,10 +1,7 @@
//! Defines the algorithm for computing a roughly-minimal patch set given an
//! existing instance tree and an instance snapshot.
use std::{
collections::{HashMap, HashSet},
mem::take,
};
use std::collections::{HashMap, HashSet};
use rbx_dom_weak::types::{Ref, Variant};
@@ -14,7 +11,11 @@ use super::{
};
#[profiling::function]
pub fn compute_patch_set(snapshot: Option<InstanceSnapshot>, tree: &RojoTree, id: Ref) -> PatchSet {
pub fn compute_patch_set(
snapshot: Option<&InstanceSnapshot>,
tree: &RojoTree,
id: Ref,
) -> PatchSet {
let mut patch_set = PatchSet::new();
if let Some(snapshot) = snapshot {
@@ -74,7 +75,7 @@ fn rewrite_refs_in_snapshot(context: &ComputePatchContext, snapshot: &mut Instan
fn compute_patch_set_internal(
context: &mut ComputePatchContext,
mut snapshot: InstanceSnapshot,
snapshot: &InstanceSnapshot,
tree: &RojoTree,
id: Ref,
patch_set: &mut PatchSet,
@@ -87,12 +88,12 @@ fn compute_patch_set_internal(
.get_instance(id)
.expect("Instance did not exist in tree");
compute_property_patches(&mut snapshot, &instance, patch_set);
compute_children_patches(context, &mut snapshot, tree, id, patch_set);
compute_property_patches(snapshot, &instance, patch_set);
compute_children_patches(context, snapshot, tree, id, patch_set);
}
fn compute_property_patches(
snapshot: &mut InstanceSnapshot,
snapshot: &InstanceSnapshot,
instance: &InstanceWithMeta,
patch_set: &mut PatchSet,
) {
@@ -102,32 +103,32 @@ fn compute_property_patches(
let changed_name = if snapshot.name == instance.name() {
None
} else {
Some(take(&mut snapshot.name).into_owned())
Some(snapshot.name.clone())
};
let changed_class_name = if snapshot.class_name == instance.class_name() {
None
} else {
Some(take(&mut snapshot.class_name).into_owned())
Some(snapshot.class_name.clone())
};
let changed_metadata = if &snapshot.metadata == instance.metadata() {
None
} else {
Some(take(&mut snapshot.metadata))
Some(snapshot.metadata.clone())
};
for (name, snapshot_value) in take(&mut snapshot.properties) {
visited_properties.insert(name.clone());
for (name, snapshot_value) in &snapshot.properties {
visited_properties.insert(name.as_str());
match instance.properties().get(&name) {
match instance.properties().get(name.as_str()) {
Some(instance_value) => {
if &snapshot_value != instance_value {
changed_properties.insert(name, Some(snapshot_value));
if snapshot_value != instance_value {
changed_properties.insert(name.clone(), Some(snapshot_value.clone()));
}
}
None => {
changed_properties.insert(name, Some(snapshot_value));
changed_properties.insert(name.clone(), Some(snapshot_value.clone()));
}
}
}
@@ -137,7 +138,7 @@ fn compute_property_patches(
continue;
}
changed_properties.insert(name.clone(), None);
changed_properties.insert(name.into(), None);
}
if changed_properties.is_empty()
@@ -159,7 +160,7 @@ fn compute_property_patches(
fn compute_children_patches(
context: &mut ComputePatchContext,
snapshot: &mut InstanceSnapshot,
snapshot: &InstanceSnapshot,
tree: &RojoTree,
id: Ref,
patch_set: &mut PatchSet,
@@ -172,7 +173,7 @@ fn compute_children_patches(
let mut paired_instances = vec![false; instance_children.len()];
for snapshot_child in take(&mut snapshot.children) {
for snapshot_child in snapshot.children.iter() {
let matching_instance =
instance_children
.iter()
@@ -209,7 +210,7 @@ fn compute_children_patches(
None => {
patch_set.added_instances.push(PatchAdd {
parent_id: id,
instance: snapshot_child,
instance: snapshot_child.clone(),
});
}
}
@@ -257,7 +258,7 @@ mod test {
children: Vec::new(),
};
let patch_set = compute_patch_set(Some(snapshot), &tree, root_id);
let patch_set = compute_patch_set(Some(&snapshot), &tree, root_id);
let expected_patch_set = PatchSet {
updated_instances: vec![PatchUpdate {
@@ -307,7 +308,7 @@ mod test {
class_name: Cow::Borrowed("foo"),
};
let patch_set = compute_patch_set(Some(snapshot), &tree, root_id);
let patch_set = compute_patch_set(Some(&snapshot), &tree, root_id);
let expected_patch_set = PatchSet {
added_instances: vec![PatchAdd {

View File

@@ -23,7 +23,7 @@ fn set_name_and_class_name() {
children: Vec::new(),
};
let patch_set = compute_patch_set(Some(snapshot), &tree, tree.get_root_id());
let patch_set = compute_patch_set(Some(&snapshot), &tree, tree.get_root_id());
let patch_value = redactions.redacted_yaml(patch_set);
assert_yaml_snapshot!(patch_value);
@@ -47,7 +47,7 @@ fn set_property() {
children: Vec::new(),
};
let patch_set = compute_patch_set(Some(snapshot), &tree, tree.get_root_id());
let patch_set = compute_patch_set(Some(&snapshot), &tree, tree.get_root_id());
let patch_value = redactions.redacted_yaml(patch_set);
assert_yaml_snapshot!(patch_value);
@@ -78,7 +78,7 @@ fn remove_property() {
children: Vec::new(),
};
let patch_set = compute_patch_set(Some(snapshot), &tree, tree.get_root_id());
let patch_set = compute_patch_set(Some(&snapshot), &tree, tree.get_root_id());
let patch_value = redactions.redacted_yaml(patch_set);
assert_yaml_snapshot!(patch_value);
@@ -107,7 +107,7 @@ fn add_child() {
}],
};
let patch_set = compute_patch_set(Some(snapshot), &tree, tree.get_root_id());
let patch_set = compute_patch_set(Some(&snapshot), &tree, tree.get_root_id());
let patch_value = redactions.redacted_yaml(patch_set);
assert_yaml_snapshot!(patch_value);
@@ -139,7 +139,7 @@ fn remove_child() {
children: Vec::new(),
};
let patch_set = compute_patch_set(Some(snapshot), &tree, tree.get_root_id());
let patch_set = compute_patch_set(Some(&snapshot), &tree, tree.get_root_id());
let patch_value = redactions.redacted_yaml(patch_set);
assert_yaml_snapshot!(patch_value);

View File

@@ -87,9 +87,8 @@ impl RojoTree {
}
pub fn insert_instance(&mut self, parent_ref: Ref, snapshot: InstanceSnapshot) -> Ref {
let builder = InstanceBuilder::empty()
.with_class(snapshot.class_name.into_owned())
.with_name(snapshot.name.into_owned())
let builder = InstanceBuilder::new(snapshot.class_name.to_owned())
.with_name(snapshot.name.to_owned())
.with_properties(snapshot.properties);
let referent = self.inner.insert(parent_ref, builder);

View File

@@ -30,7 +30,7 @@ pub fn snapshot_csv(
.name(name)
.class_name("LocalizationTable")
.properties(hashmap! {
"Contents".to_owned() => table_contents.into(),
"Contents".into() => table_contents.into(),
})
.metadata(
InstanceMetadata::new()

View File

@@ -10,40 +10,6 @@ pub fn snapshot_dir(
context: &InstanceContext,
vfs: &Vfs,
path: &Path,
) -> anyhow::Result<Option<InstanceSnapshot>> {
let mut snapshot = match snapshot_dir_no_meta(context, vfs, path)? {
Some(snapshot) => snapshot,
None => return Ok(None),
};
if let Some(mut meta) = dir_meta(vfs, path)? {
meta.apply_all(&mut snapshot)?;
}
Ok(Some(snapshot))
}
/// Retrieves the meta file that should be applied for this directory, if it
/// exists.
pub fn dir_meta(vfs: &Vfs, path: &Path) -> anyhow::Result<Option<DirectoryMetadata>> {
let meta_path = path.join("init.meta.json");
if let Some(meta_contents) = vfs.read(&meta_path).with_not_found()? {
let metadata = DirectoryMetadata::from_slice(&meta_contents, meta_path)?;
Ok(Some(metadata))
} else {
Ok(None)
}
}
/// Snapshot a directory without applying meta files; useful for if the
/// directory's ClassName will change before metadata should be applied. For
/// example, this can happen if the directory contains an `init.client.lua`
/// file.
pub fn snapshot_dir_no_meta(
context: &InstanceContext,
vfs: &Vfs,
path: &Path,
) -> anyhow::Result<Option<InstanceSnapshot>> {
let passes_filter_rules = |child: &DirEntry| {
context
@@ -86,7 +52,7 @@ pub fn snapshot_dir_no_meta(
path.join("init.client.lua"),
];
let snapshot = InstanceSnapshot::new()
let mut snapshot = InstanceSnapshot::new()
.name(instance_name)
.class_name("Folder")
.children(snapshot_children)
@@ -97,6 +63,11 @@ pub fn snapshot_dir_no_meta(
.context(context),
);
if let Some(meta_contents) = vfs.read(&meta_path).with_not_found()? {
let mut metadata = DirectoryMetadata::from_slice(&meta_contents, meta_path)?;
metadata.apply_all(&mut snapshot)?;
}
Ok(Some(snapshot))
}

View File

@@ -25,7 +25,7 @@ pub fn snapshot_json(
let as_lua = json_to_lua(value).to_string();
let properties = hashmap! {
"Source".to_owned() => as_lua.into(),
"Source".into() => as_lua.into(),
};
let meta_path = path.with_file_name(format!("{}.meta.json", name));

View File

@@ -1,4 +1,4 @@
use std::{borrow::Cow, collections::HashMap, path::Path, str};
use std::{collections::HashMap, path::Path, str};
use anyhow::Context;
use memofs::Vfs;
@@ -85,14 +85,14 @@ impl JsonModelCore {
let mut properties = HashMap::with_capacity(self.properties.len());
for (key, unresolved) in self.properties {
let value = unresolved.resolve(&class_name, &key)?;
properties.insert(key, value);
properties.insert(key.into(), value);
}
Ok(InstanceSnapshot {
snapshot_id: None,
metadata: Default::default(),
name: Cow::Owned(name),
class_name: Cow::Owned(class_name),
name: name.into(),
class_name: class_name.into(),
properties,
children,
})

View File

@@ -6,11 +6,7 @@ use memofs::{IoResultExt, Vfs};
use crate::snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot};
use super::{
dir::{dir_meta, snapshot_dir_no_meta},
meta_file::AdjacentMetadata,
util::match_trailing,
};
use super::{dir::snapshot_dir, meta_file::AdjacentMetadata, util::match_trailing};
/// Core routine for turning Lua files into snapshots.
pub fn snapshot_lua(
@@ -42,7 +38,7 @@ pub fn snapshot_lua(
.name(instance_name)
.class_name(class_name)
.properties(hashmap! {
"Source".to_owned() => contents_str.into(),
"Source".into() => contents_str.into(),
})
.metadata(
InstanceMetadata::new()
@@ -70,7 +66,7 @@ pub fn snapshot_lua_init(
init_path: &Path,
) -> anyhow::Result<Option<InstanceSnapshot>> {
let folder_path = init_path.parent().unwrap();
let dir_snapshot = snapshot_dir_no_meta(context, vfs, folder_path)?.unwrap();
let dir_snapshot = snapshot_dir(context, vfs, folder_path)?.unwrap();
if dir_snapshot.class_name != "Folder" {
anyhow::bail!(
@@ -90,10 +86,6 @@ pub fn snapshot_lua_init(
init_snapshot.children = dir_snapshot.children;
init_snapshot.metadata = dir_snapshot.metadata;
if let Some(mut meta) = dir_meta(vfs, folder_path)? {
meta.apply_all(&mut init_snapshot)?;
}
Ok(Some(init_snapshot))
}

View File

@@ -1,4 +1,4 @@
use std::{borrow::Cow, collections::HashMap, path::PathBuf};
use std::{collections::HashMap, path::PathBuf};
use anyhow::{format_err, Context};
use serde::{Deserialize, Serialize};
@@ -49,7 +49,7 @@ impl AdjacentMetadata {
.resolve(&snapshot.class_name, &key)
.with_context(|| format!("error applying meta file {}", path.display()))?;
snapshot.properties.insert(key, value);
snapshot.properties.insert(key.into(), value);
}
Ok(())
@@ -116,7 +116,7 @@ impl DirectoryMetadata {
));
}
snapshot.class_name = Cow::Owned(class_name);
snapshot.class_name = class_name.into();
}
Ok(())
@@ -136,7 +136,7 @@ impl DirectoryMetadata {
.resolve(&snapshot.class_name, &key)
.with_context(|| format!("error applying meta file {}", path.display()))?;
snapshot.properties.insert(key, value);
snapshot.properties.insert(key.into(), value);
}
Ok(())

View File

@@ -6,6 +6,7 @@ use rbx_reflection::ClassTag;
use crate::{
project::{PathNode, Project, ProjectNode},
small_string::SmallString,
snapshot::{
InstanceContext, InstanceMetadata, InstanceSnapshot, InstigatingSource, PathIgnoreRule,
},
@@ -67,13 +68,10 @@ pub fn snapshot_project_node(
) -> anyhow::Result<Option<InstanceSnapshot>> {
let project_folder = project_path.parent().unwrap();
let class_name_from_project = node
.class_name
.as_ref()
.map(|name| Cow::Owned(name.clone()));
let class_name_from_project = node.class_name.as_ref().map(|name| SmallString::from(name));
let mut class_name_from_path = None;
let name = Cow::Owned(instance_name.to_owned());
let name = SmallString::from(instance_name);
let mut properties = HashMap::new();
let mut children = Vec::new();
let mut metadata = InstanceMetadata::default();
@@ -228,7 +226,7 @@ pub fn snapshot_project_node(
_ => {}
}
properties.insert(key.clone(), value);
properties.insert(key.into(), value);
}
// If the user specified $ignoreUnknownInstances, overwrite the existing
@@ -262,7 +260,7 @@ pub fn snapshot_project_node(
}))
}
fn infer_class_name(name: &str, parent_class: Option<&str>) -> Option<Cow<'static, str>> {
fn infer_class_name(name: &str, parent_class: Option<&str>) -> Option<SmallString> {
// If className wasn't defined from another source, we may be able
// to infer one.
@@ -275,13 +273,13 @@ fn infer_class_name(name: &str, parent_class: Option<&str>) -> Option<Cow<'stati
let descriptor = rbx_reflection_database::get().classes.get(name)?;
if descriptor.tags.contains(&ClassTag::Service) {
return Some(Cow::Owned(name.to_owned()));
return Some(name.into());
}
} else if parent_class == "StarterPlayer" {
// StarterPlayer has two special members with their own classes.
if name == "StarterPlayerScripts" || name == "StarterCharacterScripts" {
return Some(Cow::Owned(name.to_owned()));
return Some(name.into());
}
}

View File

@@ -7,7 +7,6 @@ use crate::snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot};
use super::util::PathExt;
#[profiling::function]
pub fn snapshot_rbxm(
context: &InstanceContext,
vfs: &Vfs,
@@ -22,8 +21,7 @@ pub fn snapshot_rbxm(
let children = root_instance.children();
if children.len() == 1 {
let child = children[0];
let snapshot = InstanceSnapshot::from_tree(temp_tree, child)
let snapshot = InstanceSnapshot::from_tree(&temp_tree, children[0])
.name(name)
.metadata(
InstanceMetadata::new()

View File

@@ -24,8 +24,7 @@ pub fn snapshot_rbxmx(
let children = root_instance.children();
if children.len() == 1 {
let child = children[0];
let snapshot = InstanceSnapshot::from_tree(temp_tree, child)
let snapshot = InstanceSnapshot::from_tree(&temp_tree, children[0])
.name(name)
.metadata(
InstanceMetadata::new()

View File

@@ -21,7 +21,7 @@ pub fn snapshot_txt(
.to_owned();
let properties = hashmap! {
"Value".to_owned() => contents_str.into(),
"Value".into() => contents_str.into(),
};
let meta_path = path.with_file_name(format!("{}.meta.json", name));

View File

@@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize};
use crate::{
session_id::SessionId,
small_string::SmallString,
snapshot::{
AppliedPatchSet, InstanceMetadata as RojoInstanceMetadata, InstanceWithMeta, RojoTree,
},
@@ -83,13 +84,13 @@ impl<'a> SubscribeMessage<'a> {
#[serde(rename_all = "camelCase")]
pub struct InstanceUpdate {
pub id: Ref,
pub changed_name: Option<String>,
pub changed_class_name: Option<String>,
pub changed_name: Option<SmallString>,
pub changed_class_name: Option<SmallString>,
// TODO: Transform from HashMap<String, Option<_>> to something else, since
// TODO: Transform from HashMap<_, Option<_>> to something else, since
// null will get lost when decoding from JSON in some languages.
#[serde(default)]
pub changed_properties: HashMap<String, Option<Variant>>,
pub changed_properties: HashMap<SmallString, Option<Variant>>,
pub changed_metadata: Option<InstanceMetadata>,
}

View File

@@ -36,13 +36,11 @@ gen_build_tests! {
init_meta_class_name,
init_meta_properties,
init_with_children,
issue_546,
json_as_lua,
json_model_in_folder,
json_model_legacy_name,
module_in_folder,
module_init,
optional,
project_composed_default,
project_composed_file,
project_root_name,
@@ -55,6 +53,7 @@ gen_build_tests! {
txt,
txt_in_folder,
unresolved_values,
optional,
weldconstraint,
}