Add legacy and runContext script sync rule middlewares (#909)

This commit is contained in:
Micah
2025-04-02 12:47:27 -07:00
committed by GitHub
parent 73ed5ae697
commit 4c4b2dbe17
3 changed files with 53 additions and 8 deletions

View File

@@ -16,6 +16,10 @@ pub enum ScriptType {
Client,
Module,
Plugin,
LegacyServer,
LegacyClient,
RunContextServer,
RunContextClient,
}
/// Core routine for turning Lua files into snapshots.
@@ -32,13 +36,27 @@ pub fn snapshot_lua(
.expect("Unable to get RunContext enums!")
.items;
let (class_name, run_context) = match (context.emit_legacy_scripts, script_type) {
(false, ScriptType::Server) => ("Script", run_context_enums.get("Server")),
(false, ScriptType::Client) => ("Script", run_context_enums.get("Client")),
(true, ScriptType::Server) => ("Script", run_context_enums.get("Legacy")),
(true, ScriptType::Client) => ("LocalScript", None),
(_, ScriptType::Module) => ("ModuleScript", None),
(_, ScriptType::Plugin) => ("Script", run_context_enums.get("Plugin")),
let (class_name, run_context) = match script_type {
ScriptType::Server => {
if context.emit_legacy_scripts {
("Script", run_context_enums.get("Legacy"))
} else {
("Script", run_context_enums.get("Server"))
}
}
ScriptType::Client => {
if context.emit_legacy_scripts {
("LocalScript", None)
} else {
("Script", run_context_enums.get("Client"))
}
}
ScriptType::Module => ("ModuleScript", None),
ScriptType::Plugin => ("Script", run_context_enums.get("Plugin")),
ScriptType::LegacyServer => ("Script", run_context_enums.get("Legacy")),
ScriptType::LegacyClient => ("LocalScript", None),
ScriptType::RunContextServer => ("Script", run_context_enums.get("Server")),
ScriptType::RunContextClient => ("Script", run_context_enums.get("Client")),
};
let contents = vfs.read_to_string_lf_normalized(path)?;

View File

@@ -203,6 +203,10 @@ pub enum Middleware {
ClientScript,
ModuleScript,
PluginScript,
LegacyClientScript,
LegacyServerScript,
RunContextServerScript,
RunContextClientScript,
Project,
Rbxm,
Rbxmx,
@@ -229,6 +233,18 @@ impl Middleware {
Self::ClientScript => snapshot_lua(context, vfs, path, name, ScriptType::Client),
Self::ModuleScript => snapshot_lua(context, vfs, path, name, ScriptType::Module),
Self::PluginScript => snapshot_lua(context, vfs, path, name, ScriptType::Plugin),
Self::LegacyClientScript => {
snapshot_lua(context, vfs, path, name, ScriptType::LegacyClient)
}
Self::LegacyServerScript => {
snapshot_lua(context, vfs, path, name, ScriptType::LegacyServer)
}
Self::RunContextClientScript => {
snapshot_lua(context, vfs, path, name, ScriptType::RunContextClient)
}
Self::RunContextServerScript => {
snapshot_lua(context, vfs, path, name, ScriptType::RunContextServer)
}
Self::Project => snapshot_project(context, vfs, path, name),
Self::Rbxm => snapshot_rbxm(context, vfs, path, name),
Self::Rbxmx => snapshot_rbxmx(context, vfs, path, name),