refactor: split tree shell renderer

This commit is contained in:
lix-2026
2026-05-26 03:51:06 +08:00
parent 0f0e37ed54
commit c65135f7ed
6 changed files with 1126 additions and 916 deletions
+11 -7
View File
@@ -2393,6 +2393,8 @@ pub async fn reduce_tree_shell_runtime(
#[cfg(test)]
mod tests {
const TREE_SHELL_RUNTIME_JS: &str = include_str!("../../browser/tree-shell-runtime.js");
const TREE_SHELL_RENDER_RUNTIME_JS: &str =
include_str!("../../browser/tree-shell-render-runtime.js");
const TREE_SHELL_FILETREE_RUNTIME_JS: &str =
include_str!("../../browser/tree-shell-filetree-runtime.js");
const TREE_SHELL_FILETREE_MENU_RUNTIME_JS: &str =
@@ -2542,7 +2544,7 @@ mod tests {
assert!(html.contains("tree-create-root"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.ready"));
assert!(html.contains("test-shell"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree-action-menu"));
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("tree-action-menu"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.page.context-menu"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.page.expand.changed"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.page.focus.changed"));
@@ -2675,13 +2677,15 @@ mod tests {
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.filetree.selection.changed"));
assert!(html.contains("\"contractName\":\"rust_filetree_selection_reducer_v1\""));
assert!(TREE_SHELL_RUNTIME_JS.contains("applyFileTreeSelectionAction"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.filetree.internal-drop"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.filetree.external-drop"));
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("tree.filetree.internal-drop"));
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("tree.filetree.external-drop"));
assert!(html.contains("\"rowKind\":\"asset_folder\""));
assert!(html.contains("\"resourceMeta\""));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree-shell-render-runtime.js"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree-shell-filetree-runtime.js"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree-shell-filetree-menu-runtime.js"));
assert!(TREE_SHELL_RUNTIME_JS.contains("tree-shell-filetree-dnd-runtime.js"));
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("function createTreeShellRenderer(context)"));
assert!(
TREE_SHELL_FILETREE_RUNTIME_JS.contains("function getFileTreeRowOwnerDocumentId(item)")
);
@@ -2689,14 +2693,14 @@ mod tests {
.contains("function buildFileTreeMenuTarget(context"));
assert!(TREE_SHELL_FILETREE_DND_RUNTIME_JS
.contains("function createTreeShellFileTreeDndRuntime(context)"));
assert!(TREE_SHELL_RUNTIME_JS
assert!(TREE_SHELL_RENDER_RUNTIME_JS
.contains("row.dataset.ownerDocumentId = ownerDocumentId || \"\";"));
assert!(
TREE_SHELL_RUNTIME_JS.contains("if (rowId && getFileTreeRowDocumentId(renameItem))")
);
assert!(TREE_SHELL_RUNTIME_JS.contains("if (getFileTreeRowDocumentId(item))"));
assert!(TREE_SHELL_RUNTIME_JS.contains("documentId: ownerDocumentId || null"));
assert!(TREE_SHELL_RUNTIME_JS.contains("dragover"));
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("if (getFileTreeRowDocumentId(item))"));
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("documentId: ownerDocumentId || null"));
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("dragover"));
assert!(TREE_SHELL_RUNTIME_JS.contains("hydrateInitialFileTree"));
assert!(TREE_SHELL_RUNTIME_JS
.contains("const usedRustInitialRenderer = hydrateInitialRenderer();"));