forked from rojo-rbx/rojo
Add Support for Plugin Scripts (#1008)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
# Rojo Changelog
|
# Rojo Changelog
|
||||||
|
|
||||||
## Unreleased Changes
|
## Unreleased Changes
|
||||||
|
* Adds support for `.plugin.lua(u)` files - this applies the `Plugin` RunContext. ([#1008])
|
||||||
* Added support for Roblox's `Content` type. This replaces the old `Content` type with `ContentId` to reflect Roblox's change.
|
* Added support for Roblox's `Content` type. This replaces the old `Content` type with `ContentId` to reflect Roblox's change.
|
||||||
If you were previously using the fully-qualified syntax for `Content` you will need to switch it to `ContentId`.
|
If you were previously using the fully-qualified syntax for `Content` you will need to switch it to `ContentId`.
|
||||||
* Added support for `Enum` attributes
|
* Added support for `Enum` attributes
|
||||||
@@ -95,6 +96,7 @@
|
|||||||
[#974]: https://github.com/rojo-rbx/rojo/pull/974
|
[#974]: https://github.com/rojo-rbx/rojo/pull/974
|
||||||
[#987]: https://github.com/rojo-rbx/rojo/pull/987
|
[#987]: https://github.com/rojo-rbx/rojo/pull/987
|
||||||
[#988]: https://github.com/rojo-rbx/rojo/pull/988
|
[#988]: https://github.com/rojo-rbx/rojo/pull/988
|
||||||
|
[#1008]: https://github.com/rojo-rbx/rojo/pull/1008
|
||||||
|
|
||||||
## [7.4.3] - August 6th, 2024
|
## [7.4.3] - August 6th, 2024
|
||||||
* Fixed issue with building binary files introduced in 7.4.2
|
* Fixed issue with building binary files introduced in 7.4.2
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ pub enum ScriptType {
|
|||||||
Server,
|
Server,
|
||||||
Client,
|
Client,
|
||||||
Module,
|
Module,
|
||||||
|
Plugin,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Core routine for turning Lua files into snapshots.
|
/// Core routine for turning Lua files into snapshots.
|
||||||
@@ -37,6 +38,7 @@ pub fn snapshot_lua(
|
|||||||
(true, ScriptType::Server) => ("Script", run_context_enums.get("Legacy")),
|
(true, ScriptType::Server) => ("Script", run_context_enums.get("Legacy")),
|
||||||
(true, ScriptType::Client) => ("LocalScript", None),
|
(true, ScriptType::Client) => ("LocalScript", None),
|
||||||
(_, ScriptType::Module) => ("ModuleScript", None),
|
(_, ScriptType::Module) => ("ModuleScript", None),
|
||||||
|
(_, ScriptType::Plugin) => ("Script", run_context_enums.get("Plugin")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let contents = vfs.read_to_string_lf_normalized(path)?;
|
let contents = vfs.read_to_string_lf_normalized(path)?;
|
||||||
@@ -164,6 +166,29 @@ mod test {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn plugin_module_from_vfs() {
|
||||||
|
let mut imfs = InMemoryFs::new();
|
||||||
|
imfs.load_snapshot("/foo.plugin.lua", VfsSnapshot::file("Hello there!"))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let vfs = Vfs::new(imfs);
|
||||||
|
|
||||||
|
let instance_snapshot = snapshot_lua(
|
||||||
|
&InstanceContext::with_emit_legacy_scripts(Some(false)),
|
||||||
|
&vfs,
|
||||||
|
Path::new("/foo.plugin.lua"),
|
||||||
|
"foo",
|
||||||
|
ScriptType::Plugin,
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
insta::with_settings!({ sort_maps => true }, {
|
||||||
|
insta::assert_yaml_snapshot!(instance_snapshot);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn class_server_from_vfs() {
|
fn class_server_from_vfs() {
|
||||||
let mut imfs = InMemoryFs::new();
|
let mut imfs = InMemoryFs::new();
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ pub enum Middleware {
|
|||||||
ServerScript,
|
ServerScript,
|
||||||
ClientScript,
|
ClientScript,
|
||||||
ModuleScript,
|
ModuleScript,
|
||||||
|
PluginScript,
|
||||||
Project,
|
Project,
|
||||||
Rbxm,
|
Rbxm,
|
||||||
Rbxmx,
|
Rbxmx,
|
||||||
@@ -227,6 +228,7 @@ impl Middleware {
|
|||||||
Self::ServerScript => snapshot_lua(context, vfs, path, name, ScriptType::Server),
|
Self::ServerScript => snapshot_lua(context, vfs, path, name, ScriptType::Server),
|
||||||
Self::ClientScript => snapshot_lua(context, vfs, path, name, ScriptType::Client),
|
Self::ClientScript => snapshot_lua(context, vfs, path, name, ScriptType::Client),
|
||||||
Self::ModuleScript => snapshot_lua(context, vfs, path, name, ScriptType::Module),
|
Self::ModuleScript => snapshot_lua(context, vfs, path, name, ScriptType::Module),
|
||||||
|
Self::PluginScript => snapshot_lua(context, vfs, path, name, ScriptType::Plugin),
|
||||||
Self::Project => snapshot_project(context, vfs, path, name),
|
Self::Project => snapshot_project(context, vfs, path, name),
|
||||||
Self::Rbxm => snapshot_rbxm(context, vfs, path, name),
|
Self::Rbxm => snapshot_rbxm(context, vfs, path, name),
|
||||||
Self::Rbxmx => snapshot_rbxmx(context, vfs, path, name),
|
Self::Rbxmx => snapshot_rbxmx(context, vfs, path, name),
|
||||||
@@ -286,6 +288,8 @@ pub fn default_sync_rules() -> &'static [SyncRule] {
|
|||||||
sync_rule!("*.server.luau", ServerScript, ".server.luau"),
|
sync_rule!("*.server.luau", ServerScript, ".server.luau"),
|
||||||
sync_rule!("*.client.lua", ClientScript, ".client.lua"),
|
sync_rule!("*.client.lua", ClientScript, ".client.lua"),
|
||||||
sync_rule!("*.client.luau", ClientScript, ".client.luau"),
|
sync_rule!("*.client.luau", ClientScript, ".client.luau"),
|
||||||
|
sync_rule!("*.plugin.lua", PluginScript, ".plugin.lua"),
|
||||||
|
sync_rule!("*.plugin.luau", PluginScript, ".plugin.luau"),
|
||||||
sync_rule!("*.{lua,luau}", ModuleScript),
|
sync_rule!("*.{lua,luau}", ModuleScript),
|
||||||
sync_rule!("*.project.json", Project, ".project.json"),
|
sync_rule!("*.project.json", Project, ".project.json"),
|
||||||
sync_rule!("*.model.json", JsonModel, ".model.json"),
|
sync_rule!("*.model.json", JsonModel, ".model.json"),
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
source: src/snapshot_middleware/lua.rs
|
||||||
|
expression: instance_snapshot
|
||||||
|
---
|
||||||
|
snapshot_id: "00000000000000000000000000000000"
|
||||||
|
metadata:
|
||||||
|
ignore_unknown_instances: false
|
||||||
|
instigating_source:
|
||||||
|
Path: /foo.plugin.lua
|
||||||
|
relevant_paths:
|
||||||
|
- /foo.plugin.lua
|
||||||
|
- /foo.meta.json
|
||||||
|
context:
|
||||||
|
emit_legacy_scripts: false
|
||||||
|
specified_id: ~
|
||||||
|
name: foo
|
||||||
|
class_name: Script
|
||||||
|
properties:
|
||||||
|
RunContext:
|
||||||
|
Enum: 3
|
||||||
|
Source:
|
||||||
|
String: Hello there!
|
||||||
|
children: []
|
||||||
Reference in New Issue
Block a user