Merge branch 'worktree-iso-phase-4' into macros

This commit is contained in:
2026-03-07 19:08:35 +00:00
2 changed files with 48 additions and 6 deletions

View File

@@ -970,13 +970,22 @@ def sx_page_streaming_parts(ctx: dict, page_html: str, *,
return shell, tail
def sx_streaming_resolve_script(suspension_id: str, sx_source: str) -> str:
"""Build a <script> tag that resolves a streaming suspense placeholder."""
def sx_streaming_resolve_script(suspension_id: str, sx_source: str,
extra_components: str = "") -> str:
"""Build a <script> tag that resolves a streaming suspense placeholder.
If *extra_components* is non-empty, a ``<script type="text/sx">`` block
is prepended so the client loads those component defs before resolving.
"""
import json
return _SX_STREAMING_RESOLVE.format(
parts = []
if extra_components:
parts.append(f'<script type="text/sx">{extra_components}</script>')
parts.append(_SX_STREAMING_RESOLVE.format(
id=json.dumps(suspension_id),
sx=json.dumps(sx_source),
)
))
return "\n".join(parts)
_SCRIPT_HASH_CACHE: dict[str, str] = {}