mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 14:15:24 +00:00
Remove InstanceSnapshotContext in favor of InstanceContext (#271)
* Drop plugin context on the floor * Remove redirect from old context to new context * Pass InstanceContext via & instead of &mut reference * Re-use context value in ChangeProcessor from metadata
This commit is contained in:
committed by
GitHub
parent
12df80da56
commit
948303aac8
@@ -14,7 +14,7 @@ use crate::{
|
|||||||
snapshot::{
|
snapshot::{
|
||||||
apply_patch_set, compute_patch_set, AppliedPatchSet, InstigatingSource, PatchSet, RojoTree,
|
apply_patch_set, compute_patch_set, AppliedPatchSet, InstigatingSource, PatchSet, RojoTree,
|
||||||
},
|
},
|
||||||
snapshot_middleware::{snapshot_from_vfs, snapshot_project_node, InstanceSnapshotContext},
|
snapshot_middleware::{snapshot_from_vfs, snapshot_project_node},
|
||||||
vfs::{FsResultExt, Vfs, VfsEvent, VfsFetcher},
|
vfs::{FsResultExt, Vfs, VfsEvent, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -141,10 +141,6 @@ fn update_affected_instances<F: VfsFetcher>(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Use persisted snapshot context struct instead of recreating it
|
|
||||||
// every time.
|
|
||||||
let mut snapshot_context = InstanceSnapshotContext::default();
|
|
||||||
|
|
||||||
// How we process a file change event depends on what created this
|
// How we process a file change event depends on what created this
|
||||||
// file/folder in the first place.
|
// file/folder in the first place.
|
||||||
let applied_patch_set = match instigating_source {
|
let applied_patch_set = match instigating_source {
|
||||||
@@ -161,7 +157,7 @@ fn update_affected_instances<F: VfsFetcher>(
|
|||||||
// starting at that path and use it as the source for
|
// starting at that path and use it as the source for
|
||||||
// our patch.
|
// our patch.
|
||||||
|
|
||||||
let snapshot = snapshot_from_vfs(&mut snapshot_context, &vfs, &entry)
|
let snapshot = snapshot_from_vfs(&metadata.context, &vfs, &entry)
|
||||||
.expect("snapshot failed")
|
.expect("snapshot failed")
|
||||||
.expect("snapshot did not return an instance");
|
.expect("snapshot did not return an instance");
|
||||||
|
|
||||||
@@ -188,7 +184,7 @@ fn update_affected_instances<F: VfsFetcher>(
|
|||||||
// the project file, we snapshot the entire project node again.
|
// the project file, we snapshot the entire project node again.
|
||||||
|
|
||||||
let snapshot =
|
let snapshot =
|
||||||
snapshot_project_node(&mut snapshot_context, instance_name, project_node, &vfs)
|
snapshot_project_node(&metadata.context, instance_name, project_node, &vfs)
|
||||||
.expect("snapshot failed")
|
.expect("snapshot failed")
|
||||||
.expect("snapshot did not return an instance");
|
.expect("snapshot did not return an instance");
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
//! Initialization routines that are used by more than one Rojo command or
|
//! Initialization routines that are used by more than one Rojo command or
|
||||||
//! utility.
|
//! utility.
|
||||||
|
|
||||||
use std::{path::Path, sync::Arc};
|
use std::path::Path;
|
||||||
|
|
||||||
use rbx_dom_weak::RbxInstanceProperties;
|
use rbx_dom_weak::RbxInstanceProperties;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
project::{Project, ProjectLoadError},
|
project::{Project, ProjectLoadError},
|
||||||
snapshot::{apply_patch_set, compute_patch_set, InstancePropertiesWithMeta, RojoTree},
|
snapshot::{
|
||||||
snapshot_middleware::{snapshot_from_vfs, InstanceSnapshotContext, SnapshotPluginContext},
|
apply_patch_set, compute_patch_set, InstanceContext, InstancePropertiesWithMeta, RojoTree,
|
||||||
|
},
|
||||||
|
snapshot_middleware::snapshot_from_vfs,
|
||||||
vfs::{Vfs, VfsFetcher},
|
vfs::{Vfs, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,13 +38,12 @@ pub fn start<F: VfsFetcher>(
|
|||||||
let root_id = tree.get_root_id();
|
let root_id = tree.get_root_id();
|
||||||
|
|
||||||
log::trace!("Constructing snapshot context");
|
log::trace!("Constructing snapshot context");
|
||||||
let mut snapshot_context = InstanceSnapshotContext::default();
|
let snapshot_context = InstanceContext::default();
|
||||||
if let Some(project) = &maybe_project {
|
if let Some(project) = &maybe_project {
|
||||||
// If the project file defines no plugins, then there's no need to
|
// If the project file defines no plugins, then there's no need to
|
||||||
// initialize the snapshot plugin context.
|
// initialize the snapshot plugin context.
|
||||||
if !project.plugins.is_empty() {
|
if !project.plugins.is_empty() {
|
||||||
snapshot_context.plugin_context =
|
// TODO: Initialize plugins in instance context
|
||||||
Some(Arc::new(SnapshotPluginContext::new(&project.plugins)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ pub fn start<F: VfsFetcher>(
|
|||||||
.expect("could not get project path");
|
.expect("could not get project path");
|
||||||
|
|
||||||
log::trace!("Generating snapshot of instances from VFS");
|
log::trace!("Generating snapshot of instances from VFS");
|
||||||
let snapshot = snapshot_from_vfs(&mut snapshot_context, vfs, &entry)
|
let snapshot = snapshot_from_vfs(&snapshot_context, vfs, &entry)
|
||||||
.expect("snapshot failed")
|
.expect("snapshot failed")
|
||||||
.expect("snapshot did not return an instance");
|
.expect("snapshot did not return an instance");
|
||||||
|
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
use std::{fmt, fs, ops::Deref, path::Path, sync::Arc};
|
|
||||||
|
|
||||||
use rlua::{Lua, RegistryKey};
|
|
||||||
|
|
||||||
use super::error::SnapshotError;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct InstanceSnapshotContext {
|
|
||||||
/// Holds all the state needed to run user plugins as part of the snapshot
|
|
||||||
/// process.
|
|
||||||
///
|
|
||||||
/// If this is None, then plugins should not be evaluated at all.
|
|
||||||
pub plugin_context: Option<Arc<SnapshotPluginContext>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for InstanceSnapshotContext {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
plugin_context: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct SnapshotPluginContext {
|
|
||||||
pub state: IgnoreDebug<Lua>,
|
|
||||||
|
|
||||||
/// Registry keys pointing to the values returned by each user plugin. When
|
|
||||||
/// processing user plugins, these should be applied in order.
|
|
||||||
pub plugin_functions: Vec<RegistryKey>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SnapshotPluginContext {
|
|
||||||
pub fn new<P: AsRef<Path>>(plugin_paths: &[P]) -> Self {
|
|
||||||
let lua_state = Lua::new();
|
|
||||||
|
|
||||||
let plugin_functions = plugin_paths
|
|
||||||
.iter()
|
|
||||||
.map(|path| {
|
|
||||||
let path = path.as_ref();
|
|
||||||
|
|
||||||
let content =
|
|
||||||
fs::read_to_string(path).map_err(|err| SnapshotError::wrap(err, path))?;
|
|
||||||
|
|
||||||
lua_state.context(|lua_context| {
|
|
||||||
// Plugins are currently expected to return a function that will
|
|
||||||
// be run when a snapshot needs to be generated.
|
|
||||||
let result = lua_context
|
|
||||||
.load(&content)
|
|
||||||
.set_name(&path.display().to_string())?
|
|
||||||
.call::<_, rlua::Function>(())?;
|
|
||||||
|
|
||||||
let key = lua_context.create_registry_value(result)?;
|
|
||||||
|
|
||||||
Ok(key)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.collect::<Result<Vec<_>, SnapshotError>>()
|
|
||||||
.expect("Plugin initialization error");
|
|
||||||
|
|
||||||
Self {
|
|
||||||
state: IgnoreDebug(lua_state),
|
|
||||||
plugin_functions,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Utility type to enable having a field of a struct not implement Debug and
|
|
||||||
/// instead show a placeholder.
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct IgnoreDebug<T>(pub T);
|
|
||||||
|
|
||||||
impl<T> fmt::Debug for IgnoreDebug<T> {
|
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(formatter, "<no debug representation>")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Deref for IgnoreDebug<T> {
|
|
||||||
type Target = T;
|
|
||||||
|
|
||||||
fn deref(&self) -> &T {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct VfsSnapshotContext;
|
|
||||||
@@ -5,12 +5,11 @@ use rbx_dom_weak::RbxValue;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
|
||||||
vfs::{FsResultExt, Vfs, VfsEntry, VfsFetcher},
|
vfs::{FsResultExt, Vfs, VfsEntry, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
meta_file::AdjacentMetadata,
|
meta_file::AdjacentMetadata,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
@@ -20,7 +19,7 @@ pub struct SnapshotCsv;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotCsv {
|
impl SnapshotMiddleware for SnapshotCsv {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &mut InstanceSnapshotContext,
|
_context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -159,7 +158,7 @@ Ack,Ack!,,An exclamation of despair,¡Ay!"#,
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.csv").unwrap();
|
let entry = vfs.get("/foo.csv").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotCsv::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotCsv::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -181,7 +180,7 @@ Ack,Ack!,,An exclamation of despair,¡Ay!"#,
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.csv").unwrap();
|
let entry = vfs.get("/foo.csv").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotCsv::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotCsv::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ use std::collections::HashMap;
|
|||||||
use rbx_dom_weak::{RbxId, RbxTree};
|
use rbx_dom_weak::{RbxId, RbxTree};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
|
||||||
vfs::{DirectorySnapshot, FsResultExt, Vfs, VfsEntry, VfsFetcher, VfsSnapshot},
|
vfs::{DirectorySnapshot, FsResultExt, Vfs, VfsEntry, VfsFetcher, VfsSnapshot},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
error::SnapshotError,
|
error::SnapshotError,
|
||||||
meta_file::DirectoryMetadata,
|
meta_file::DirectoryMetadata,
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
@@ -19,7 +18,7 @@ pub struct SnapshotDir;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotDir {
|
impl SnapshotMiddleware for SnapshotDir {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
context: &mut InstanceSnapshotContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -116,7 +115,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotDir::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotDir::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -134,7 +133,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotDir::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotDir::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ use rbx_reflection::try_resolve_value;
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
snapshot::InstanceSnapshot,
|
snapshot::{InstanceContext, InstanceSnapshot},
|
||||||
vfs::{Vfs, VfsEntry, VfsFetcher},
|
vfs::{Vfs, VfsEntry, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
@@ -19,7 +18,7 @@ pub struct SnapshotJsonModel;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotJsonModel {
|
impl SnapshotMiddleware for SnapshotJsonModel {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &mut InstanceSnapshotContext,
|
_context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -164,7 +163,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.model.json").unwrap();
|
let entry = vfs.get("/foo.model.json").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotJsonModel::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotJsonModel::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ use maplit::hashmap;
|
|||||||
use rbx_dom_weak::RbxValue;
|
use rbx_dom_weak::RbxValue;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
|
||||||
vfs::{FsResultExt, Vfs, VfsEntry, VfsFetcher},
|
vfs::{FsResultExt, Vfs, VfsEntry, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
dir::SnapshotDir,
|
dir::SnapshotDir,
|
||||||
meta_file::AdjacentMetadata,
|
meta_file::AdjacentMetadata,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
@@ -20,7 +19,7 @@ pub struct SnapshotLua;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotLua {
|
impl SnapshotMiddleware for SnapshotLua {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
context: &mut InstanceSnapshotContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -108,7 +107,7 @@ fn snapshot_lua_file<F: VfsFetcher>(vfs: &Vfs<F>, entry: &VfsEntry) -> SnapshotI
|
|||||||
/// Scripts named `init.lua`, `init.server.lua`, or `init.client.lua` usurp
|
/// Scripts named `init.lua`, `init.server.lua`, or `init.client.lua` usurp
|
||||||
/// their parents, which acts similarly to `__init__.py` from the Python world.
|
/// their parents, which acts similarly to `__init__.py` from the Python world.
|
||||||
fn snapshot_init<F: VfsFetcher>(
|
fn snapshot_init<F: VfsFetcher>(
|
||||||
context: &mut InstanceSnapshotContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
folder_entry: &VfsEntry,
|
folder_entry: &VfsEntry,
|
||||||
init_name: &str,
|
init_name: &str,
|
||||||
@@ -155,7 +154,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.lua").unwrap();
|
let entry = vfs.get("/foo.lua").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotLua::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotLua::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -171,7 +170,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.server.lua").unwrap();
|
let entry = vfs.get("/foo.server.lua").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotLua::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotLua::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -187,7 +186,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.client.lua").unwrap();
|
let entry = vfs.get("/foo.client.lua").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotLua::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotLua::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -205,7 +204,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/root").unwrap();
|
let entry = vfs.get("/root").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotLua::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotLua::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -229,7 +228,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.lua").unwrap();
|
let entry = vfs.get("/foo.lua").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotLua::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotLua::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -253,7 +252,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.server.lua").unwrap();
|
let entry = vfs.get("/foo.server.lua").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotLua::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotLua::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -279,7 +278,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/bar.server.lua").unwrap();
|
let entry = vfs.get("/bar.server.lua").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotLua::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotLua::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
use rbx_dom_weak::{RbxId, RbxTree};
|
use rbx_dom_weak::{RbxId, RbxTree};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
snapshot::InstanceSnapshot,
|
snapshot::{InstanceContext, InstanceSnapshot},
|
||||||
vfs::{Vfs, VfsEntry, VfsFetcher, VfsSnapshot},
|
vfs::{Vfs, VfsEntry, VfsFetcher, VfsSnapshot},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{context::InstanceSnapshotContext, error::SnapshotError};
|
use super::error::SnapshotError;
|
||||||
|
|
||||||
pub type SnapshotInstanceResult = Result<Option<InstanceSnapshot>, SnapshotError>;
|
pub type SnapshotInstanceResult = Result<Option<InstanceSnapshot>, SnapshotError>;
|
||||||
pub type SnapshotFileResult = Option<(String, VfsSnapshot)>;
|
pub type SnapshotFileResult = Option<(String, VfsSnapshot)>;
|
||||||
|
|
||||||
pub trait SnapshotMiddleware {
|
pub trait SnapshotMiddleware {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
context: &mut InstanceSnapshotContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult;
|
) -> SnapshotInstanceResult;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
mod context;
|
|
||||||
mod csv;
|
mod csv;
|
||||||
mod dir;
|
mod dir;
|
||||||
mod error;
|
mod error;
|
||||||
@@ -19,7 +18,6 @@ mod txt;
|
|||||||
mod user_plugins;
|
mod user_plugins;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub use self::context::*;
|
|
||||||
pub use self::error::*;
|
pub use self::error::*;
|
||||||
|
|
||||||
use rbx_dom_weak::{RbxId, RbxTree};
|
use rbx_dom_weak::{RbxId, RbxTree};
|
||||||
@@ -37,7 +35,10 @@ use self::{
|
|||||||
txt::SnapshotTxt,
|
txt::SnapshotTxt,
|
||||||
user_plugins::SnapshotUserPlugins,
|
user_plugins::SnapshotUserPlugins,
|
||||||
};
|
};
|
||||||
use crate::vfs::{Vfs, VfsEntry, VfsFetcher};
|
use crate::{
|
||||||
|
snapshot::InstanceContext,
|
||||||
|
vfs::{Vfs, VfsEntry, VfsFetcher},
|
||||||
|
};
|
||||||
|
|
||||||
pub use self::project::snapshot_project_node;
|
pub use self::project::snapshot_project_node;
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ macro_rules! middlewares {
|
|||||||
( $($middleware: ident,)* ) => {
|
( $($middleware: ident,)* ) => {
|
||||||
/// Generates a snapshot of instances from the given VfsEntry.
|
/// Generates a snapshot of instances from the given VfsEntry.
|
||||||
pub fn snapshot_from_vfs<F: VfsFetcher>(
|
pub fn snapshot_from_vfs<F: VfsFetcher>(
|
||||||
context: &mut InstanceSnapshotContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ use rbx_reflection::try_resolve_value;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
project::{Project, ProjectNode},
|
project::{Project, ProjectNode},
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot, InstigatingSource},
|
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot, InstigatingSource},
|
||||||
vfs::{FsResultExt, Vfs, VfsEntry, VfsFetcher},
|
vfs::{FsResultExt, Vfs, VfsEntry, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
error::SnapshotError,
|
error::SnapshotError,
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
snapshot_from_vfs,
|
snapshot_from_vfs,
|
||||||
@@ -22,7 +21,7 @@ pub struct SnapshotProject;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotProject {
|
impl SnapshotMiddleware for SnapshotProject {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
context: &mut InstanceSnapshotContext,
|
context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -77,7 +76,7 @@ impl SnapshotMiddleware for SnapshotProject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn snapshot_project_node<F: VfsFetcher>(
|
pub fn snapshot_project_node<F: VfsFetcher>(
|
||||||
context: &mut InstanceSnapshotContext,
|
context: &InstanceContext,
|
||||||
instance_name: &str,
|
instance_name: &str,
|
||||||
node: &ProjectNode,
|
node: &ProjectNode,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
@@ -214,7 +213,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -241,7 +240,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo/hello.project.json").unwrap();
|
let entry = vfs.get("/foo/hello.project.json").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -274,7 +273,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -304,7 +303,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -335,7 +334,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -363,7 +362,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -398,7 +397,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -437,7 +436,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
@@ -481,7 +480,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo").unwrap();
|
let entry = vfs.get("/foo").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotProject::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotProject::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.expect("snapshot error")
|
.expect("snapshot error")
|
||||||
.expect("snapshot returned no instances");
|
.expect("snapshot returned no instances");
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
|
||||||
vfs::{Vfs, VfsEntry, VfsFetcher},
|
vfs::{Vfs, VfsEntry, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
@@ -13,7 +12,7 @@ pub struct SnapshotRbxlx;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxlx {
|
impl SnapshotMiddleware for SnapshotRbxlx {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &mut InstanceSnapshotContext,
|
_context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ use std::collections::HashMap;
|
|||||||
use rbx_dom_weak::{RbxInstanceProperties, RbxTree};
|
use rbx_dom_weak::{RbxInstanceProperties, RbxTree};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
|
||||||
vfs::{Vfs, VfsEntry, VfsFetcher},
|
vfs::{Vfs, VfsEntry, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
@@ -17,7 +16,7 @@ pub struct SnapshotRbxm;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxm {
|
impl SnapshotMiddleware for SnapshotRbxm {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &mut InstanceSnapshotContext,
|
_context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -74,7 +73,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.rbxm").unwrap();
|
let entry = vfs.get("/foo.rbxm").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotRbxm::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotRbxm::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
|
||||||
vfs::{Vfs, VfsEntry, VfsFetcher},
|
vfs::{Vfs, VfsEntry, VfsFetcher},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
util::match_file_name,
|
util::match_file_name,
|
||||||
};
|
};
|
||||||
@@ -13,7 +12,7 @@ pub struct SnapshotRbxmx;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotRbxmx {
|
impl SnapshotMiddleware for SnapshotRbxmx {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &mut InstanceSnapshotContext,
|
_context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -78,7 +77,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.rbxmx").unwrap();
|
let entry = vfs.get("/foo.rbxmx").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotRbxmx::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotRbxmx::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ use maplit::hashmap;
|
|||||||
use rbx_dom_weak::{RbxId, RbxTree, RbxValue};
|
use rbx_dom_weak::{RbxId, RbxTree, RbxValue};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
|
||||||
vfs::{FileSnapshot, FsResultExt, Vfs, VfsEntry, VfsFetcher, VfsSnapshot},
|
vfs::{FileSnapshot, FsResultExt, Vfs, VfsEntry, VfsFetcher, VfsSnapshot},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
error::SnapshotError,
|
error::SnapshotError,
|
||||||
meta_file::AdjacentMetadata,
|
meta_file::AdjacentMetadata,
|
||||||
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
middleware::{SnapshotFileResult, SnapshotInstanceResult, SnapshotMiddleware},
|
||||||
@@ -20,7 +19,7 @@ pub struct SnapshotTxt;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotTxt {
|
impl SnapshotMiddleware for SnapshotTxt {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
_context: &mut InstanceSnapshotContext,
|
_context: &InstanceContext,
|
||||||
vfs: &Vfs<F>,
|
vfs: &Vfs<F>,
|
||||||
entry: &VfsEntry,
|
entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
@@ -114,7 +113,7 @@ mod test {
|
|||||||
|
|
||||||
let entry = vfs.get("/foo.txt").unwrap();
|
let entry = vfs.get("/foo.txt").unwrap();
|
||||||
let instance_snapshot =
|
let instance_snapshot =
|
||||||
SnapshotTxt::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
SnapshotTxt::from_vfs(&InstanceContext::default(), &mut vfs, &entry)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use crate::vfs::{Vfs, VfsEntry, VfsFetcher};
|
use crate::{
|
||||||
|
snapshot::InstanceContext,
|
||||||
use super::{
|
vfs::{Vfs, VfsEntry, VfsFetcher},
|
||||||
context::InstanceSnapshotContext,
|
|
||||||
middleware::{SnapshotInstanceResult, SnapshotMiddleware},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::middleware::{SnapshotInstanceResult, SnapshotMiddleware};
|
||||||
|
|
||||||
/// Handles snapshotting of any file that a user plugin wants to handle.
|
/// Handles snapshotting of any file that a user plugin wants to handle.
|
||||||
///
|
///
|
||||||
/// User plugins are specified in the project file, but there are never user
|
/// User plugins are specified in the project file, but there are never user
|
||||||
@@ -15,53 +15,41 @@ pub struct SnapshotUserPlugins;
|
|||||||
|
|
||||||
impl SnapshotMiddleware for SnapshotUserPlugins {
|
impl SnapshotMiddleware for SnapshotUserPlugins {
|
||||||
fn from_vfs<F: VfsFetcher>(
|
fn from_vfs<F: VfsFetcher>(
|
||||||
context: &mut InstanceSnapshotContext,
|
_context: &InstanceContext,
|
||||||
_vfs: &Vfs<F>,
|
_vfs: &Vfs<F>,
|
||||||
_entry: &VfsEntry,
|
_entry: &VfsEntry,
|
||||||
) -> SnapshotInstanceResult {
|
) -> SnapshotInstanceResult {
|
||||||
// User plugins are only enabled if present on the snapshot context.
|
// TODO: Invoke plugin here and get result out.
|
||||||
let plugin_context = match &mut context.plugin_context {
|
|
||||||
Some(ctx) => ctx,
|
|
||||||
None => return Ok(None),
|
|
||||||
};
|
|
||||||
|
|
||||||
plugin_context.state.context(|lua_context| {
|
// The current plan for plugins here is to make them work
|
||||||
lua_context.scope(|_scope| {
|
// like Redux/Rodux middleware. A plugin will be a function
|
||||||
for _key in &plugin_context.plugin_functions {
|
// that accepts the next middleware in the chain as a
|
||||||
// TODO: Invoke plugin here and get result out.
|
// function and the snapshot subject (the VFS entry).
|
||||||
|
//
|
||||||
// The current plan for plugins here is to make them work
|
// Plugins can (but don't have to) invoke the next snapshot
|
||||||
// like Redux/Rodux middleware. A plugin will be a function
|
// function and may or may not mutate the result. The hope
|
||||||
// that accepts the next middleware in the chain as a
|
// is that this model enables the most flexibility possible
|
||||||
// function and the snapshot subject (the VFS entry).
|
// for plugins to modify existing Rojo output, as well as
|
||||||
//
|
// generate new outputs.
|
||||||
// Plugins can (but don't have to) invoke the next snapshot
|
//
|
||||||
// function and may or may not mutate the result. The hope
|
// Open questions:
|
||||||
// is that this model enables the most flexibility possible
|
// * How will middleware be ordered? Does putting user
|
||||||
// for plugins to modify existing Rojo output, as well as
|
// middleware always at the beginning or always at the end
|
||||||
// generate new outputs.
|
// of the chain reduce the scope of what that middleware
|
||||||
//
|
// can do?
|
||||||
// Open questions:
|
//
|
||||||
// * How will middleware be ordered? Does putting user
|
// * Will plugins hurt Rojo's ability to parallelize
|
||||||
// middleware always at the beginning or always at the end
|
// snapshotting in the future?
|
||||||
// of the chain reduce the scope of what that middleware
|
//
|
||||||
// can do?
|
// * Do the mutable handles to the Vfs and the snapshot
|
||||||
//
|
// context prevent plugins from invoking other plugins
|
||||||
// * Will plugins hurt Rojo's ability to parallelize
|
// indirectly?
|
||||||
// snapshotting in the future?
|
//
|
||||||
//
|
// * Will there be problems using a single Lua state because
|
||||||
// * Do the mutable handles to the Vfs and the snapshot
|
// of re-entrancy?
|
||||||
// context prevent plugins from invoking other plugins
|
//
|
||||||
// indirectly?
|
// * Can the Lua <-> Rojo bindings used for middleware be
|
||||||
//
|
// reused for or from another project like Remodel?
|
||||||
// * Will there be problems using a single Lua state because
|
|
||||||
// of re-entrancy?
|
|
||||||
//
|
|
||||||
// * Can the Lua <-> Rojo bindings used for middleware be
|
|
||||||
// reused for or from another project like Remodel?
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user