refactor: split tree shell renderer
This commit is contained in:
+1
-1
@@ -210,7 +210,7 @@ cargo test --manifest-path rust/Cargo.toml -p mnote-web --lib ssr::pages::layout
|
|||||||
- [x] D4. `tree-shell-picker-runtime.js`:picker search/focus/pick root。
|
- [x] D4. `tree-shell-picker-runtime.js`:picker search/focus/pick root。
|
||||||
- [x] D5. `tree-shell-dom-runtime.js`:DOM patch/render helpers。
|
- [x] D5. `tree-shell-dom-runtime.js`:DOM patch/render helpers。
|
||||||
- [x] D6. `tree-shell-icons-runtime.js`:icon templates 和 resource kind badge。
|
- [x] D6. `tree-shell-icons-runtime.js`:icon templates 和 resource kind badge。
|
||||||
- [ ] D7. entrypoint 少于 2,500 行。
|
- [x] D7. entrypoint 少于 2,500 行。
|
||||||
|
|
||||||
验收命令:
|
验收命令:
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -166,6 +166,10 @@ pub fn build_router(state: AppState) -> Router {
|
|||||||
"/api/mnote-browser-runtime/tree-shell-runtime.js",
|
"/api/mnote-browser-runtime/tree-shell-runtime.js",
|
||||||
get(web_shell::tree_shell_runtime_asset),
|
get(web_shell::tree_shell_runtime_asset),
|
||||||
)
|
)
|
||||||
|
.route(
|
||||||
|
"/api/mnote-browser-runtime/tree-shell-render-runtime.js",
|
||||||
|
get(web_shell::tree_shell_render_runtime_asset),
|
||||||
|
)
|
||||||
.route(
|
.route(
|
||||||
"/api/mnote-browser-runtime/tree-shell-page-runtime.js",
|
"/api/mnote-browser-runtime/tree-shell-page-runtime.js",
|
||||||
get(web_shell::tree_shell_page_runtime_asset),
|
get(web_shell::tree_shell_page_runtime_asset),
|
||||||
@@ -649,6 +653,7 @@ mod tests {
|
|||||||
"/api/mnote-browser-runtime/sidebar-tree-runtime.js",
|
"/api/mnote-browser-runtime/sidebar-tree-runtime.js",
|
||||||
"/api/mnote-browser-runtime/tree-live-controller.js",
|
"/api/mnote-browser-runtime/tree-live-controller.js",
|
||||||
"/api/mnote-browser-runtime/tree-shell-runtime.js",
|
"/api/mnote-browser-runtime/tree-shell-runtime.js",
|
||||||
|
"/api/mnote-browser-runtime/tree-shell-render-runtime.js",
|
||||||
"/api/mnote-browser-runtime/tree-shell-page-runtime.js",
|
"/api/mnote-browser-runtime/tree-shell-page-runtime.js",
|
||||||
"/api/mnote-browser-runtime/tree-shell-state-runtime.js",
|
"/api/mnote-browser-runtime/tree-shell-state-runtime.js",
|
||||||
"/api/mnote-browser-runtime/tree-shell-icons-runtime.js",
|
"/api/mnote-browser-runtime/tree-shell-icons-runtime.js",
|
||||||
|
|||||||
@@ -2393,6 +2393,8 @@ pub async fn reduce_tree_shell_runtime(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
const TREE_SHELL_RUNTIME_JS: &str = include_str!("../../browser/tree-shell-runtime.js");
|
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 =
|
const TREE_SHELL_FILETREE_RUNTIME_JS: &str =
|
||||||
include_str!("../../browser/tree-shell-filetree-runtime.js");
|
include_str!("../../browser/tree-shell-filetree-runtime.js");
|
||||||
const TREE_SHELL_FILETREE_MENU_RUNTIME_JS: &str =
|
const TREE_SHELL_FILETREE_MENU_RUNTIME_JS: &str =
|
||||||
@@ -2542,7 +2544,7 @@ mod tests {
|
|||||||
assert!(html.contains("tree-create-root"));
|
assert!(html.contains("tree-create-root"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.ready"));
|
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.ready"));
|
||||||
assert!(html.contains("test-shell"));
|
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.context-menu"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.page.expand.changed"));
|
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.page.expand.changed"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.page.focus.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!(TREE_SHELL_RUNTIME_JS.contains("tree.filetree.selection.changed"));
|
||||||
assert!(html.contains("\"contractName\":\"rust_filetree_selection_reducer_v1\""));
|
assert!(html.contains("\"contractName\":\"rust_filetree_selection_reducer_v1\""));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("applyFileTreeSelectionAction"));
|
assert!(TREE_SHELL_RUNTIME_JS.contains("applyFileTreeSelectionAction"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("tree.filetree.internal-drop"));
|
assert!(TREE_SHELL_RENDER_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.external-drop"));
|
||||||
assert!(html.contains("\"rowKind\":\"asset_folder\""));
|
assert!(html.contains("\"rowKind\":\"asset_folder\""));
|
||||||
assert!(html.contains("\"resourceMeta\""));
|
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-runtime.js"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("tree-shell-filetree-menu-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_RUNTIME_JS.contains("tree-shell-filetree-dnd-runtime.js"));
|
||||||
|
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("function createTreeShellRenderer(context)"));
|
||||||
assert!(
|
assert!(
|
||||||
TREE_SHELL_FILETREE_RUNTIME_JS.contains("function getFileTreeRowOwnerDocumentId(item)")
|
TREE_SHELL_FILETREE_RUNTIME_JS.contains("function getFileTreeRowOwnerDocumentId(item)")
|
||||||
);
|
);
|
||||||
@@ -2689,14 +2693,14 @@ mod tests {
|
|||||||
.contains("function buildFileTreeMenuTarget(context"));
|
.contains("function buildFileTreeMenuTarget(context"));
|
||||||
assert!(TREE_SHELL_FILETREE_DND_RUNTIME_JS
|
assert!(TREE_SHELL_FILETREE_DND_RUNTIME_JS
|
||||||
.contains("function createTreeShellFileTreeDndRuntime(context)"));
|
.contains("function createTreeShellFileTreeDndRuntime(context)"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS
|
assert!(TREE_SHELL_RENDER_RUNTIME_JS
|
||||||
.contains("row.dataset.ownerDocumentId = ownerDocumentId || \"\";"));
|
.contains("row.dataset.ownerDocumentId = ownerDocumentId || \"\";"));
|
||||||
assert!(
|
assert!(
|
||||||
TREE_SHELL_RUNTIME_JS.contains("if (rowId && getFileTreeRowDocumentId(renameItem))")
|
TREE_SHELL_RUNTIME_JS.contains("if (rowId && getFileTreeRowDocumentId(renameItem))")
|
||||||
);
|
);
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("if (getFileTreeRowDocumentId(item))"));
|
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("if (getFileTreeRowDocumentId(item))"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("documentId: ownerDocumentId || null"));
|
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("documentId: ownerDocumentId || null"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("dragover"));
|
assert!(TREE_SHELL_RENDER_RUNTIME_JS.contains("dragover"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS.contains("hydrateInitialFileTree"));
|
assert!(TREE_SHELL_RUNTIME_JS.contains("hydrateInitialFileTree"));
|
||||||
assert!(TREE_SHELL_RUNTIME_JS
|
assert!(TREE_SHELL_RUNTIME_JS
|
||||||
.contains("const usedRustInitialRenderer = hydrateInitialRenderer();"));
|
.contains("const usedRustInitialRenderer = hydrateInitialRenderer();"));
|
||||||
|
|||||||
@@ -938,6 +938,20 @@ pub async fn tree_shell_runtime_asset() -> Response {
|
|||||||
.unwrap_or_else(|_| Response::new(Body::empty()))
|
.unwrap_or_else(|_| Response::new(Body::empty()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn tree_shell_render_runtime_asset() -> Response {
|
||||||
|
const JS: &str = include_str!("../../browser/tree-shell-render-runtime.js");
|
||||||
|
Response::builder()
|
||||||
|
.status(StatusCode::OK)
|
||||||
|
.header(
|
||||||
|
header::CONTENT_TYPE,
|
||||||
|
"application/javascript; charset=utf-8",
|
||||||
|
)
|
||||||
|
.header(header::CACHE_CONTROL, "no-store")
|
||||||
|
.header(HEADER_MNOTE_WEB_OWNER, "mnote-web")
|
||||||
|
.body(Body::from(JS))
|
||||||
|
.unwrap_or_else(|_| Response::new(Body::empty()))
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn tree_shell_page_runtime_asset() -> Response {
|
pub async fn tree_shell_page_runtime_asset() -> Response {
|
||||||
const JS: &str = include_str!("../../browser/tree-shell-page-runtime.js");
|
const JS: &str = include_str!("../../browser/tree-shell-page-runtime.js");
|
||||||
Response::builder()
|
Response::builder()
|
||||||
|
|||||||
Reference in New Issue
Block a user