Include layout + content component deps in streaming page scan
The streaming page's component scan only covered the suspense placeholders, missing transitive deps from layout headers (e.g. ~cart-mini, ~auth-menu). Add layout.component_names to Layout class and include them plus page content_expr in the scan source. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,7 @@ from typing import Any, Callable, Awaitable
|
||||
class Layout:
|
||||
"""A named layout that generates header rows for full and OOB rendering."""
|
||||
|
||||
__slots__ = ("name", "_full_fn", "_oob_fn", "_mobile_fn")
|
||||
__slots__ = ("name", "_full_fn", "_oob_fn", "_mobile_fn", "component_names")
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -30,11 +30,13 @@ class Layout:
|
||||
full_fn: Callable[..., str | Awaitable[str]],
|
||||
oob_fn: Callable[..., str | Awaitable[str]],
|
||||
mobile_fn: Callable[..., str | Awaitable[str]] | None = None,
|
||||
component_names: list[str] | None = None,
|
||||
):
|
||||
self.name = name
|
||||
self._full_fn = full_fn
|
||||
self._oob_fn = oob_fn
|
||||
self._mobile_fn = mobile_fn
|
||||
self.component_names = component_names or []
|
||||
|
||||
async def full_headers(self, ctx: dict, **kwargs: Any) -> str:
|
||||
result = self._full_fn(ctx, **kwargs)
|
||||
@@ -109,12 +111,14 @@ def register_sx_layout(name: str, full_defcomp: str, oob_defcomp: str,
|
||||
return await _render_to_sx_with_env(oob_defcomp, env)
|
||||
|
||||
mobile_fn = None
|
||||
comp_names = [f"~{full_defcomp}", f"~{oob_defcomp}"]
|
||||
if mobile_defcomp:
|
||||
async def mobile_fn(ctx: dict, **kw: Any) -> str:
|
||||
env = {k.replace("_", "-"): v for k, v in kw.items()}
|
||||
return await _render_to_sx_with_env(mobile_defcomp, env)
|
||||
comp_names.append(f"~{mobile_defcomp}")
|
||||
|
||||
register_layout(Layout(name, full_fn, oob_fn, mobile_fn))
|
||||
register_layout(Layout(name, full_fn, oob_fn, mobile_fn, comp_names))
|
||||
|
||||
|
||||
# Register built-in layouts via .sx defcomps
|
||||
|
||||
Reference in New Issue
Block a user