feat(tree): close rust family shell cutover

This commit is contained in:
lix-2026
2026-04-28 16:30:51 +08:00
parent 4ab36a9386
commit 7965c6c107
75 changed files with 9721 additions and 1174 deletions
@@ -40,15 +40,40 @@ pub struct TreeShellCommandDispatcher {
#[serde(rename_all = "camelCase")]
pub struct TreeShellRuntimeArtifactBoundary {
pub contract_name: &'static str,
pub family: &'static str,
pub version: u8,
pub execution_strategy: &'static str,
pub browser_bridge: &'static str,
pub wasm_module_url: Option<&'static str>,
pub js_glue_url: Option<&'static str>,
pub input_fields: BTreeSet<&'static str>,
pub output_channels: BTreeSet<&'static str>,
pub event_kinds: BTreeSet<&'static str>,
pub runtime_api: TreeShellRuntimeApiBoundary,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TreeShellRuntimeApiBoundary {
pub request_contract: &'static str,
pub result_contract: &'static str,
pub reduce_endpoint: &'static str,
pub state_snapshots: BTreeSet<&'static str>,
pub dom_patch_kinds: BTreeSet<&'static str>,
pub host_event_kinds: BTreeSet<&'static str>,
pub command_event_kinds: BTreeSet<&'static str>,
}
impl Default for TreeShellRuntimeArtifactBoundary {
fn default() -> Self {
Self {
contract_name: "rust_tree_shell_runtime_artifact_v1",
family: "rust_family",
version: 1,
execution_strategy: "browser_bridge",
browser_bridge: "iframe_srcdoc",
wasm_module_url: Some("/api/tree-shell-runtime/mnote-tree-shell-runtime_bg.wasm"),
js_glue_url: Some("/api/tree-shell-runtime/mnote-tree-shell-runtime.js"),
input_fields: BTreeSet::from([
"rendererInput",
"projectionItems",
@@ -67,6 +92,31 @@ impl Default for TreeShellRuntimeArtifactBoundary {
"dragDrop",
"pick",
]),
runtime_api: TreeShellRuntimeApiBoundary {
request_contract: "TreeShellRuntimeRequest",
result_contract: "TreeShellRuntimeResult",
reduce_endpoint: "/api/tree/runtime/reduce",
state_snapshots: BTreeSet::from(["page", "fileTree", "picker"]),
dom_patch_kinds: BTreeSet::from(["pageState", "fileTreeState", "pickerState"]),
host_event_kinds: BTreeSet::from([
"pageOpen",
"pageContextMenu",
"fileTreeOpen",
"fileTreeContextMenu",
"fileTreeInternalDrop",
"fileTreeExternalDrop",
"pickerPickRoot",
"pickerPickDocument",
]),
command_event_kinds: BTreeSet::from([
"createNode",
"renameNode",
"moveSubtree",
"copyResource",
"moveResource",
"uploadResource",
]),
},
}
}
}
@@ -197,10 +247,12 @@ mod tests {
});
assert_eq!(filetree.mode, TreeShellRendererMode::FileTree);
assert_eq!(filetree.focused_id.as_deref(), Some("asset:a"));
assert!(filetree
.filetree_selection
.selected_row_ids
.contains("asset:a"));
assert!(
filetree
.filetree_selection
.selected_row_ids
.contains("asset:a")
);
assert!(filetree.page_focus_keyboard_reducer.is_none());
assert_eq!(
filetree
@@ -245,6 +297,18 @@ mod tests {
artifact.contract_name,
"rust_tree_shell_runtime_artifact_v1"
);
assert_eq!(artifact.family, "rust_family");
assert_eq!(artifact.version, 1);
assert_eq!(artifact.execution_strategy, "browser_bridge");
assert_eq!(artifact.browser_bridge, "iframe_srcdoc");
assert_eq!(
artifact.wasm_module_url,
Some("/api/tree-shell-runtime/mnote-tree-shell-runtime_bg.wasm")
);
assert_eq!(
artifact.js_glue_url,
Some("/api/tree-shell-runtime/mnote-tree-shell-runtime.js")
);
assert!(artifact.input_fields.contains("rendererInput"));
assert!(artifact.input_fields.contains("projectionItems"));
assert!(artifact.input_fields.contains("expandedIds"));
@@ -254,6 +318,90 @@ mod tests {
assert!(artifact.output_channels.contains("domPatch"));
assert!(artifact.output_channels.contains("intentEvent"));
assert!(artifact.output_channels.contains("commandDispatchEvent"));
assert_eq!(
artifact.runtime_api.request_contract,
"TreeShellRuntimeRequest"
);
assert_eq!(
artifact.runtime_api.result_contract,
"TreeShellRuntimeResult"
);
assert_eq!(
artifact.runtime_api.reduce_endpoint,
"/api/tree/runtime/reduce"
);
assert!(artifact.runtime_api.state_snapshots.contains("page"));
assert!(artifact.runtime_api.state_snapshots.contains("fileTree"));
assert!(artifact.runtime_api.state_snapshots.contains("picker"));
assert!(artifact.runtime_api.dom_patch_kinds.contains("pageState"));
assert!(
artifact
.runtime_api
.dom_patch_kinds
.contains("fileTreeState")
);
assert!(artifact.runtime_api.dom_patch_kinds.contains("pickerState"));
assert!(artifact.runtime_api.host_event_kinds.contains("pageOpen"));
assert!(
artifact
.runtime_api
.host_event_kinds
.contains("fileTreeOpen")
);
assert!(
artifact
.runtime_api
.host_event_kinds
.contains("fileTreeInternalDrop")
);
assert!(
artifact
.runtime_api
.host_event_kinds
.contains("fileTreeExternalDrop")
);
assert!(
artifact
.runtime_api
.host_event_kinds
.contains("pickerPickDocument")
);
assert!(
artifact
.runtime_api
.command_event_kinds
.contains("createNode")
);
assert!(
artifact
.runtime_api
.command_event_kinds
.contains("renameNode")
);
assert!(
artifact
.runtime_api
.command_event_kinds
.contains("moveSubtree")
);
assert!(
artifact
.runtime_api
.command_event_kinds
.contains("copyResource")
);
assert!(
artifact
.runtime_api
.command_event_kinds
.contains("moveResource")
);
assert!(
artifact
.runtime_api
.command_event_kinds
.contains("uploadResource")
);
assert!(artifact.event_kinds.contains("focus"));
assert!(artifact.event_kinds.contains("keyboard"));
assert!(artifact.event_kinds.contains("expandCollapse"));