feat: add protocol explorer with catalogs and live playground

This commit is contained in:
2026-10-19 18:21:30 +09:00
parent b82c1d0a70
commit 75a36f2298
38 changed files with 1836 additions and 83 deletions
+42 -3
View File
@@ -56,6 +56,8 @@ fn data() -> WorldspaceData {
"/2-second.md",
"/book/2-second/",
),
node("/sources", Some("/"), "/sources", "/sources/"),
node("/packages", Some("/"), "/packages", "/packages/"),
],
}
}
@@ -134,9 +136,25 @@ fn depth_boundaries_empty_children_and_order_are_protocol_observations() {
assert!(observe("/", 0).children.is_none());
let root = observe("/", 1);
let children = root.children.unwrap();
assert_eq!(children.len(), 1);
assert_eq!(children.len(), 3);
assert_eq!(children[0].object.name, "book");
assert!(children[0].children.is_none());
assert_eq!(children[1].object.name, "sources");
assert_eq!(children[2].object.name, "packages");
assert!(children.iter().all(|child| child.children.is_none()));
for path in ["/sources", "/packages"] {
assert!(observe(path, 0).children.is_none());
assert_eq!(observe(path, 1).children, Some(vec![]));
let leaf = observe(path, 1);
assert_eq!(
leaf.object.interfaces,
vec![Worldspace::document_interface()]
);
let content =
DocumentContent::decode(world.call_operation(read(path)).unwrap().result).unwrap();
assert_eq!(content.path, path);
assert_eq!(content.href, format!("{path}/"));
assert_eq!(content.html, format!("<h1>{path}</h1>"));
}
let root = observe("/", 3);
let book = &root.children.as_ref().unwrap()[0];
let chapters = book.children.as_ref().unwrap();
@@ -190,6 +208,8 @@ fn canonical_host_failures_are_not_replaced_by_direct_body_lookup() {
"/1-chapter.md",
"/draft/private.md",
"/book/draft/private.md",
"/sources/repository",
"/packages/crate",
] {
assert_eq!(
world
@@ -398,7 +418,26 @@ fn generated_real_public_documents_support_all_interactions() {
depth: MAX_DEPTH,
})
.unwrap();
assert_eq!(full.children.unwrap()[0].object.name, "book");
assert_eq!(
full.children
.unwrap()
.iter()
.map(|node| node.object.name.as_str())
.collect::<Vec<_>>(),
vec!["book", "sources", "packages", "playground"]
);
for path in ["/sources", "/packages"] {
assert_eq!(
world
.observe(ObserveRequest {
path: path.into(),
depth: 1,
})
.unwrap()
.children,
Some(vec![])
);
}
let descriptor = world
.fetch_interface(FetchInterfaceRequest {
interface: Worldspace::document_interface(),