Merge branch 'main' into datetime-rfc2822-support

This commit is contained in:
Ryan 2025-03-25 22:00:44 -04:00 committed by GitHub
commit 9637c4b731
Signed by: DevComp
GPG key ID: B5690EEEBB952194
22 changed files with 318 additions and 65 deletions

108
Cargo.lock generated
View file

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 4
[[package]] [[package]]
name = "addr2line" name = "addr2line"
@ -23,7 +23,7 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"cipher", "cipher",
"cpufeatures", "cpufeatures",
] ]
@ -206,7 +206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8"
dependencies = [ dependencies = [
"async-lock", "async-lock",
"cfg-if", "cfg-if 1.0.0",
"concurrent-queue", "concurrent-queue",
"futures-io", "futures-io",
"futures-lite", "futures-lite",
@ -254,7 +254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
"object", "object",
@ -318,7 +318,7 @@ dependencies = [
"arrayref", "arrayref",
"arrayvec 0.7.6", "arrayvec 0.7.6",
"cc", "cc",
"cfg-if", "cfg-if 1.0.0",
"constant_time_eq 0.3.1", "constant_time_eq 0.3.1",
"digest", "digest",
] ]
@ -433,6 +433,12 @@ dependencies = [
"shlex", "shlex",
] ]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@ -650,7 +656,7 @@ version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -744,7 +750,7 @@ version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35"
dependencies = [ dependencies = [
"dirs-sys", "dirs-sys 0.4.1",
] ]
[[package]] [[package]]
@ -758,6 +764,27 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "dirs"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
dependencies = [
"cfg-if 0.1.10",
"dirs-sys 0.3.7",
]
[[package]]
name = "dirs-sys"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"redox_users 0.4.6",
"winapi",
]
[[package]] [[package]]
name = "dirs-sys" name = "dirs-sys"
version = "0.4.1" version = "0.4.1"
@ -805,7 +832,7 @@ version = "0.8.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
] ]
[[package]] [[package]]
@ -890,7 +917,7 @@ version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"rustix", "rustix",
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
@ -999,7 +1026,7 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb949699c3e4df3a183b1d2142cb24277057055ed23c68ed58894f76c517223" checksum = "dbb949699c3e4df3a183b1d2142cb24277057055ed23c68ed58894f76c517223"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"log", "log",
"rustversion", "rustversion",
@ -1022,7 +1049,7 @@ version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"wasi 0.9.0+wasi-snapshot-preview1", "wasi 0.9.0+wasi-snapshot-preview1",
] ]
@ -1033,7 +1060,7 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"wasi 0.11.0+wasi-snapshot-preview1", "wasi 0.11.0+wasi-snapshot-preview1",
] ]
@ -1432,7 +1459,7 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
@ -1490,7 +1517,7 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"generator", "generator",
"scoped-tls", "scoped-tls",
"tracing", "tracing",
@ -1660,6 +1687,7 @@ dependencies = [
"mlua-luau-scheduler", "mlua-luau-scheduler",
"once_cell", "once_cell",
"rbx_cookie", "rbx_cookie",
"roblox_install",
] ]
[[package]] [[package]]
@ -1714,8 +1742,10 @@ dependencies = [
"dunce", "dunce",
"mlua", "mlua",
"once_cell", "once_cell",
"parking_lot",
"path-clean", "path-clean",
"pathdiff", "pathdiff",
"semver 1.0.23",
"tokio", "tokio",
] ]
@ -1763,7 +1793,7 @@ version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"digest", "digest",
] ]
@ -1844,7 +1874,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebe026d6bd1583a9cf9080e189030ddaea7e6f5f0deb366a8e26f8a26c4135b8" checksum = "ebe026d6bd1583a9cf9080e189030ddaea7e6f5f0deb366a8e26f8a26c4135b8"
dependencies = [ dependencies = [
"cc", "cc",
"cfg-if", "cfg-if 1.0.0",
"luau0-src", "luau0-src",
"pkg-config", "pkg-config",
] ]
@ -1865,7 +1895,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"cfg-if", "cfg-if 1.0.0",
"cfg_aliases", "cfg_aliases",
"libc", "libc",
] ]
@ -1992,7 +2022,7 @@ version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"libc", "libc",
"redox_syscall 0.5.7", "redox_syscall 0.5.7",
"smallvec", "smallvec",
@ -2101,7 +2131,7 @@ version = "3.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"concurrent-queue", "concurrent-queue",
"hermit-abi 0.4.0", "hermit-abi 0.4.0",
"pin-project-lite", "pin-project-lite",
@ -2249,7 +2279,7 @@ checksum = "d8a61b073240f4c13b1e780a8999a113dfa28bc93f2cf9fc41c6f36e7aceb5bf"
dependencies = [ dependencies = [
"byteorder 0.5.3", "byteorder 0.5.3",
"cookie", "cookie",
"dirs", "dirs 1.0.5",
"log", "log",
"plist", "plist",
"winapi", "winapi",
@ -2447,7 +2477,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
dependencies = [ dependencies = [
"cc", "cc",
"cfg-if", "cfg-if 1.0.0",
"getrandom 0.2.15", "getrandom 0.2.15",
"libc", "libc",
"spin", "spin",
@ -2477,6 +2507,17 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "roblox_install"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "743bb8c693a387f1ae8d2026d82d8b0c175cc4777b97c1f7b12fdb3be595bb13"
dependencies = [
"dirs 2.0.2",
"thiserror",
"winreg 0.6.2",
]
[[package]] [[package]]
name = "rust-argon2" name = "rust-argon2"
version = "0.8.3" version = "0.8.3"
@ -2613,7 +2654,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63" checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"cfg-if", "cfg-if 1.0.0",
"clipboard-win", "clipboard-win",
"fd-lock", "fd-lock",
"home", "home",
@ -2784,7 +2825,7 @@ version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"cpufeatures", "cpufeatures",
"digest", "digest",
] ]
@ -2801,7 +2842,7 @@ version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"cpufeatures", "cpufeatures",
"digest", "digest",
] ]
@ -3008,7 +3049,7 @@ version = "3.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"fastrand", "fastrand",
"once_cell", "once_cell",
"rustix", "rustix",
@ -3041,7 +3082,7 @@ version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"once_cell", "once_cell",
] ]
@ -3503,7 +3544,7 @@ version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"once_cell", "once_cell",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]
@ -3529,7 +3570,7 @@ version = "0.4.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -3850,6 +3891,15 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "winreg"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winreg" name = "winreg"
version = "0.10.1" version = "0.10.1"
@ -3865,7 +3915,7 @@ version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 1.0.0",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]

View file

@ -41,7 +41,7 @@ where
} }
fn remove_matching_prop(inst: &mut DomInstance, ty: DomType, name: &'static str) { fn remove_matching_prop(inst: &mut DomInstance, ty: DomType, name: &'static str) {
if inst.properties.get(name).map_or(false, |u| u.ty() == ty) { if inst.properties.get(name).is_some_and(|u| u.ty() == ty) {
inst.properties.remove(name); inst.properties.remove(name);
} }
} }

View file

@ -23,7 +23,7 @@ pub fn make_list_writer() -> Box<ListWriter> {
}) })
} }
/** /*
Userdata metamethod implementations Userdata metamethod implementations
Note that many of these return [`LuaResult`] even though they don't Note that many of these return [`LuaResult`] even though they don't

View file

@ -60,7 +60,7 @@ where
} }
} }
/** /*
Conversion methods between `DateTimeValues` and plain lua tables Conversion methods between `DateTimeValues` and plain lua tables
Note that the `IntoLua` implementation here uses a read-only table, Note that the `IntoLua` implementation here uses a read-only table,
@ -117,7 +117,7 @@ impl IntoLua<'_> for DateTimeValues {
} }
} }
/** /*
Conversion methods between chrono's timezone-aware `DateTime` to Conversion methods between chrono's timezone-aware `DateTime` to
and from our non-timezone-aware `DateTimeValues` values struct and from our non-timezone-aware `DateTimeValues` values struct
*/ */

View file

@ -2,7 +2,7 @@
use mlua::prelude::*; use mlua::prelude::*;
use lune_utils::TableBuilder; use lune_utils::{jit::JitStatus, TableBuilder};
mod options; mod options;
@ -78,7 +78,13 @@ fn load_source<'lua>(
// changed, otherwise disable JIT since it'll fall back anyways // changed, otherwise disable JIT since it'll fall back anyways
lua.enable_jit(options.codegen_enabled && !env_changed); lua.enable_jit(options.codegen_enabled && !env_changed);
let function = chunk.into_function()?; let function = chunk.into_function()?;
lua.enable_jit(true); lua.enable_jit(
lua.app_data_ref::<JitStatus>()
.ok_or(LuaError::runtime(
"Failed to get current JitStatus ref from AppData",
))?
.enabled(),
);
Ok(function) Ok(function)
} }

View file

@ -33,7 +33,7 @@ where
} }
} }
impl<'a, W> AsyncWrite for AsyncTeeWriter<'a, W> impl<W> AsyncWrite for AsyncTeeWriter<'_, W>
where where
W: AsyncWrite + Unpin, W: AsyncWrite + Unpin,
{ {

View file

@ -18,6 +18,7 @@ mlua-luau-scheduler = { version = "0.0.2", path = "../mlua-luau-scheduler" }
once_cell = "1.17" once_cell = "1.17"
rbx_cookie = { version = "0.1.4", default-features = false } rbx_cookie = { version = "0.1.4", default-features = false }
roblox_install = "1.0.0"
lune-utils = { version = "0.1.3", path = "../lune-utils" } lune-utils = { version = "0.1.3", path = "../lune-utils" }
lune-roblox = { version = "0.1.4", path = "../lune-roblox" } lune-roblox = { version = "0.1.4", path = "../lune-roblox" }

View file

@ -13,6 +13,7 @@ use lune_roblox::{
static REFLECTION_DATABASE: OnceCell<ReflectionDatabase> = OnceCell::new(); static REFLECTION_DATABASE: OnceCell<ReflectionDatabase> = OnceCell::new();
use lune_utils::TableBuilder; use lune_utils::TableBuilder;
use roblox_install::RobloxStudio;
/** /**
Creates the `roblox` standard library module. Creates the `roblox` standard library module.
@ -39,6 +40,10 @@ pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
.with_function("getReflectionDatabase", get_reflection_database)? .with_function("getReflectionDatabase", get_reflection_database)?
.with_function("implementProperty", implement_property)? .with_function("implementProperty", implement_property)?
.with_function("implementMethod", implement_method)? .with_function("implementMethod", implement_method)?
.with_function("studioApplicationPath", studio_application_path)?
.with_function("studioContentPath", studio_content_path)?
.with_function("studioPluginPath", studio_plugin_path)?
.with_function("studioBuiltinPluginPath", studio_builtin_plugin_path)?
.build_readonly() .build_readonly()
} }
@ -147,3 +152,27 @@ fn implement_method(
InstanceRegistry::insert_method(lua, &class_name, &method_name, method).into_lua_err()?; InstanceRegistry::insert_method(lua, &class_name, &method_name, method).into_lua_err()?;
Ok(()) Ok(())
} }
fn studio_application_path(_: &Lua, _: ()) -> LuaResult<String> {
RobloxStudio::locate()
.map(|rs| rs.application_path().display().to_string())
.map_err(LuaError::external)
}
fn studio_content_path(_: &Lua, _: ()) -> LuaResult<String> {
RobloxStudio::locate()
.map(|rs| rs.content_path().display().to_string())
.map_err(LuaError::external)
}
fn studio_plugin_path(_: &Lua, _: ()) -> LuaResult<String> {
RobloxStudio::locate()
.map(|rs| rs.plugins_path().display().to_string())
.map_err(LuaError::external)
}
fn studio_builtin_plugin_path(_: &Lua, _: ()) -> LuaResult<String> {
RobloxStudio::locate()
.map(|rs| rs.built_in_plugins_path().display().to_string())
.map_err(LuaError::external)
}

View file

@ -117,7 +117,7 @@ impl<'lua> FromLua<'lua> for CompressDecompressFormat {
Errors when the compression fails. Errors when the compression fails.
*/ */
pub async fn compress<'lua>( pub async fn compress(
source: impl AsRef<[u8]>, source: impl AsRef<[u8]>,
format: CompressDecompressFormat, format: CompressDecompressFormat,
level: Option<i32>, level: Option<i32>,
@ -163,7 +163,7 @@ pub async fn compress<'lua>(
Errors when the decompression fails. Errors when the decompression fails.
*/ */
pub async fn decompress<'lua>( pub async fn decompress(
source: impl AsRef<[u8]>, source: impl AsRef<[u8]>,
format: CompressDecompressFormat, format: CompressDecompressFormat,
) -> LuaResult<Vec<u8>> { ) -> LuaResult<Vec<u8>> {

View file

@ -150,9 +150,9 @@ impl RequireContext {
self.get_from_cache(lua, abs_path.as_ref()) self.get_from_cache(lua, abs_path.as_ref())
} }
async fn load<'lua>( async fn load(
&self, &self,
lua: &'lua Lua, lua: &Lua,
abs_path: impl AsRef<Path>, abs_path: impl AsRef<Path>,
rel_path: impl AsRef<Path>, rel_path: impl AsRef<Path>,
) -> LuaResult<LuaRegistryKey> { ) -> LuaResult<LuaRegistryKey> {

View file

@ -22,3 +22,5 @@ dunce = "1.0"
once_cell = "1.17" once_cell = "1.17"
path-clean = "1.0" path-clean = "1.0"
pathdiff = "0.2" pathdiff = "0.2"
parking_lot = "0.12.3"
semver = "1.0"

View file

@ -1,11 +1,9 @@
use std::{ use std::{collections::HashSet, sync::Arc};
collections::HashSet,
sync::{Arc, Mutex},
};
use console::{colors_enabled as get_colors_enabled, set_colors_enabled}; use console::{colors_enabled as get_colors_enabled, set_colors_enabled};
use mlua::prelude::*; use mlua::prelude::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use parking_lot::ReentrantMutex;
mod basic; mod basic;
mod config; mod config;
@ -20,7 +18,7 @@ pub use self::config::ValueFormatConfig;
// NOTE: Since the setting for colors being enabled is global, // NOTE: Since the setting for colors being enabled is global,
// and these functions may be called in parallel, we use this global // and these functions may be called in parallel, we use this global
// lock to make sure that we don't mess up the colors for other threads. // lock to make sure that we don't mess up the colors for other threads.
static COLORS_LOCK: Lazy<Arc<Mutex<()>>> = Lazy::new(|| Arc::new(Mutex::new(()))); static COLORS_LOCK: Lazy<Arc<ReentrantMutex<()>>> = Lazy::new(|| Arc::new(ReentrantMutex::new(())));
/** /**
Formats a Lua value into a pretty string using the given config. Formats a Lua value into a pretty string using the given config.
@ -28,7 +26,7 @@ static COLORS_LOCK: Lazy<Arc<Mutex<()>>> = Lazy::new(|| Arc::new(Mutex::new(()))
#[must_use] #[must_use]
#[allow(clippy::missing_panics_doc)] #[allow(clippy::missing_panics_doc)]
pub fn pretty_format_value(value: &LuaValue, config: &ValueFormatConfig) -> String { pub fn pretty_format_value(value: &LuaValue, config: &ValueFormatConfig) -> String {
let _guard = COLORS_LOCK.lock().unwrap(); let _guard = COLORS_LOCK.lock();
let were_colors_enabled = get_colors_enabled(); let were_colors_enabled = get_colors_enabled();
set_colors_enabled(were_colors_enabled && config.colors_enabled); set_colors_enabled(were_colors_enabled && config.colors_enabled);
@ -48,7 +46,7 @@ pub fn pretty_format_value(value: &LuaValue, config: &ValueFormatConfig) -> Stri
#[must_use] #[must_use]
#[allow(clippy::missing_panics_doc)] #[allow(clippy::missing_panics_doc)]
pub fn pretty_format_multi_value(values: &LuaMultiValue, config: &ValueFormatConfig) -> String { pub fn pretty_format_multi_value(values: &LuaMultiValue, config: &ValueFormatConfig) -> String {
let _guard = COLORS_LOCK.lock().unwrap(); let _guard = COLORS_LOCK.lock();
let were_colors_enabled = get_colors_enabled(); let were_colors_enabled = get_colors_enabled();
set_colors_enabled(were_colors_enabled && config.colors_enabled); set_colors_enabled(were_colors_enabled && config.colors_enabled);

View file

@ -0,0 +1,30 @@
#[derive(Debug, Clone, Copy, Default)]
pub struct JitStatus(bool);
impl JitStatus {
#[must_use]
pub fn new(enabled: bool) -> Self {
Self(enabled)
}
pub fn set_status(&mut self, enabled: bool) {
self.0 = enabled;
}
#[must_use]
pub fn enabled(self) -> bool {
self.0
}
}
impl From<JitStatus> for bool {
fn from(val: JitStatus) -> Self {
val.enabled()
}
}
impl From<bool> for JitStatus {
fn from(val: bool) -> Self {
Self::new(val)
}
}

View file

@ -4,6 +4,7 @@ mod table_builder;
mod version_string; mod version_string;
pub mod fmt; pub mod fmt;
pub mod jit;
pub mod path; pub mod path;
pub use self::table_builder::TableBuilder; pub use self::table_builder::TableBuilder;

View file

@ -2,6 +2,7 @@ use std::sync::Arc;
use mlua::prelude::*; use mlua::prelude::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use semver::Version;
static LUAU_VERSION: Lazy<Arc<String>> = Lazy::new(create_luau_version_string); static LUAU_VERSION: Lazy<Arc<String>> = Lazy::new(create_luau_version_string);
@ -20,12 +21,10 @@ pub fn get_version_string(lune_version: impl AsRef<str>) -> String {
let lune_version = lune_version.as_ref(); let lune_version = lune_version.as_ref();
assert!(!lune_version.is_empty(), "Lune version string is empty"); assert!(!lune_version.is_empty(), "Lune version string is empty");
assert!( match Version::parse(lune_version) {
lune_version.chars().all(is_valid_version_char), Ok(semver) => format!("Lune {semver}+{}", *LUAU_VERSION),
"Lune version string contains invalid characters" Err(e) => panic!("Lune version string is not valid semver: {e}"),
); }
format!("Lune {lune_version}+{}", *LUAU_VERSION)
} }
fn create_luau_version_string() -> Arc<String> { fn create_luau_version_string() -> Arc<String> {

View file

@ -1,4 +1,4 @@
use std::process::ExitCode; use std::{env, process::ExitCode};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use clap::Parser; use clap::Parser;
@ -41,7 +41,15 @@ impl RunCommand {
}; };
// Create a new lune runtime with all globals & run the script // Create a new lune runtime with all globals & run the script
let mut rt = Runtime::new().with_args(self.script_args); let mut rt = Runtime::new()
.with_args(self.script_args)
// Enable JIT compilation unless it was requested to be disabled
.with_jit(
!matches!(
env::var("LUNE_LUAU_JIT").ok(),
Some(jit_enabled) if jit_enabled == "0" || jit_enabled == "false" || jit_enabled == "off"
)
);
let result = rt let result = rt
.run(&script_display_name, strip_shebang(script_contents)) .run(&script_display_name, strip_shebang(script_contents))

View file

@ -64,8 +64,8 @@ pub fn discover_script_path(path: impl AsRef<str>, in_home_dir: bool) -> Result<
// NOTE: We use metadata directly here to try to // NOTE: We use metadata directly here to try to
// avoid accessing the file path more than once // avoid accessing the file path more than once
let file_meta = file_path.metadata(); let file_meta = file_path.metadata();
let is_file = file_meta.as_ref().map_or(false, Metadata::is_file); let is_file = file_meta.as_ref().is_ok_and(Metadata::is_file);
let is_dir = file_meta.as_ref().map_or(false, Metadata::is_dir); let is_dir = file_meta.as_ref().is_ok_and(Metadata::is_dir);
let is_abs = file_path.is_absolute(); let is_abs = file_path.is_absolute();
let ext = file_path.extension(); let ext = file_path.extension();
if is_file { if is_file {

View file

@ -8,6 +8,7 @@ use std::{
}, },
}; };
use lune_utils::jit::JitStatus;
use mlua::prelude::*; use mlua::prelude::*;
use mlua_luau_scheduler::{Functions, Scheduler}; use mlua_luau_scheduler::{Functions, Scheduler};
use self_cell::self_cell; use self_cell::self_cell;
@ -100,6 +101,7 @@ impl RuntimeInner {
*/ */
pub struct Runtime { pub struct Runtime {
inner: RuntimeInner, inner: RuntimeInner,
jit_status: JitStatus,
} }
impl Runtime { impl Runtime {
@ -113,6 +115,7 @@ impl Runtime {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
inner: RuntimeInner::create().expect("Failed to create runtime"), inner: RuntimeInner::create().expect("Failed to create runtime"),
jit_status: JitStatus::default(),
} }
} }
@ -130,6 +133,15 @@ impl Runtime {
self self
} }
/**
Enables or disables JIT compilation.
*/
#[must_use]
pub fn with_jit(mut self, jit_status: impl Into<JitStatus>) -> Self {
self.jit_status = jit_status.into();
self
}
/** /**
Runs a Lune script inside of the current runtime. Runs a Lune script inside of the current runtime.
@ -155,6 +167,10 @@ impl Runtime {
eprintln!("{}", RuntimeError::from(e)); eprintln!("{}", RuntimeError::from(e));
}); });
// Enable / disable the JIT as requested and store the current status as AppData
lua.set_app_data(self.jit_status);
lua.enable_jit(self.jit_status.enabled());
// Load our "main" thread // Load our "main" thread
let main = lua let main = lua
.load(script_contents.as_ref()) .load(script_contents.as_ref())

View file

@ -31,7 +31,9 @@ macro_rules! create_tests {
// The rest of the test logic can continue as normal // The rest of the test logic can continue as normal
let full_name = format!("{}/tests/{}.luau", workspace_dir.display(), $value); let full_name = format!("{}/tests/{}.luau", workspace_dir.display(), $value);
let script = read_to_string(&full_name).await?; let script = read_to_string(&full_name).await?;
let mut lune = Runtime::new().with_args( let mut lune = Runtime::new()
.with_jit(true)
.with_args(
ARGS ARGS
.clone() .clone()
.iter() .iter()

View file

@ -334,7 +334,7 @@ impl<'lua> LuaSchedulerExt<'lua> for Lua {
} }
} }
impl<'lua> LuaSpawnExt<'lua> for Lua { impl LuaSpawnExt<'_> for Lua {
fn spawn<F, T>(&self, fut: F) -> Task<T> fn spawn<F, T>(&self, fut: F) -> Task<T>
where where
F: Future<Output = T> + Send + 'static, F: Future<Output = T> + Send + 'static,

View file

@ -122,3 +122,23 @@ stdio.ewrite(typeof(errorMessage))
assertContains("Should format errors similarly to userdata", stdio.format(errorMessage), "<LuaErr") assertContains("Should format errors similarly to userdata", stdio.format(errorMessage), "<LuaErr")
assertContains("Should format errors with stack begins", stdio.format(errorMessage), "Stack Begin") assertContains("Should format errors with stack begins", stdio.format(errorMessage), "Stack Begin")
assertContains("Should format errors with stack ends", stdio.format(errorMessage), "Stack End") assertContains("Should format errors with stack ends", stdio.format(errorMessage), "Stack End")
-- Check that calling stdio.format in a __tostring metamethod by print doesn't cause a deadlock
local inner = {}
setmetatable(inner, {
__tostring = function()
return stdio.format(5)
end,
})
print(inner)
local outer = {}
setmetatable(outer, {
__tostring = function()
return stdio.format(inner)
end,
})
print(outer)

View file

@ -504,4 +504,95 @@ roblox.Instance = (nil :: any) :: {
new: ((className: "DataModel") -> DataModel) & ((className: string) -> Instance), new: ((className: "DataModel") -> DataModel) & ((className: string) -> Instance),
} }
--[=[
@within Roblox
@tag must_use
Returns the path to the system's Roblox Studio executable.
There is no guarantee that this will exist, but if Studio is installed this
is where it will be.
### Example usage
```lua
local roblox = require("@lune/roblox")
local pathToStudio = roblox.studioApplicationPath()
print("Studio is located at:", pathToStudio)
```
]=]
function roblox.studioApplicationPath(): string
return nil :: any
end
--[=[
@within Roblox
@tag must_use
Returns the path to the `Content` folder of the system's current Studio
install.
This folder will always exist if Studio is installed.
### Example usage
```lua
local roblox = require("@lune/roblox")
local pathToContent = roblox.studioContentPath()
print("Studio's content folder is located at:", pathToContent)
```
]=]
function roblox.studioContentPath(): string
return nil :: any
end
--[=[
@within Roblox
@tag must_use
Returns the path to the `plugin` folder of the system's current Studio
install. This is the path where local plugins are installed.
This folder may not exist if the user has never installed a local plugin.
It will also not necessarily take into account custom plugin directories
set from Studio.
### Example usage
```lua
local roblox = require("@lune/roblox")
local pathToPluginFolder = roblox.studioPluginPath()
print("Studio's plugin folder is located at:", pathToPluginFolder)
```
]=]
function roblox.studioPluginPath(): string
return nil :: any
end
--[=[
@within Roblox
@tag must_use
Returns the path to the `BuiltInPlugin` folder of the system's current
Studio install. This is the path where built-in plugins like the ToolBox
are installed.
This folder will always exist if Studio is installed.
### Example usage
```lua
local roblox = require("@lune/roblox")
local pathToPluginFolder = roblox.studioBuiltinPluginPath()
print("Studio's built-in plugin folder is located at:", pathToPluginFolder)
```
]=]
function roblox.studioBuiltinPluginPath(): string
return nil :: any
end
return roblox return roblox