mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 05:06:29 +00:00
Add legacy and runContext script sync rule middlewares (#909)
This commit is contained in:
@@ -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)?;
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user