Add generic runtime-island package producer (+ carry inline island JS)#262
Merged
Conversation
Adds RuntimeIslandPackageBuilder: a generic, product-neutral producer that projects compiled-site runtime-island metadata into an actionable carry-forward envelope (schema blocks-engine/php-transformer/runtime-island-package/v1). Per preserved island it carries a stable id, the verbatim source markup, the associated script assets (external src + scoped inline JS, resolved against the artifact), a generic enqueue handle hint, a preserve-vs-rebuild signal, and a role classification so telemetry/analytics scripts are dropped rather than carried. Wired into ArtifactCompiler::compile() alongside the existing runtime_islands report; emitted only when islands exist. Preserve-vs-rebuild (#224): runtime islands carry verbatim markup, so their JS may be carried verbatim (js_handling=preserve_verbatim). Transformed regions are not islands and never reach this package. Telemetry scripts get disposition=drop and per-script droppable=true. Upstream fix: inline <script> islands carried no JS because safeFallbackHtml() strips script bodies from source_snippet. FallbackEmitter::captureScriptFallback now preserves the bounded verbatim inline body on the script island (script_body/body_bytes/body_truncated), mirroring how template islands carry template_body, so inline script islands are no longer lossy. The package is intentionally product-neutral: it names no consumer, plugin, or host product. A downstream consumer maps it to its own materialization payload. Adds a contract fixture (tests/fixtures/contract/runtime-island-package.json) and contract-test coverage for the three representative island shapes: a verbatim-preserved first-party inline script island, a dropped telemetry external script, and a canvas island carrying both an external (materialized) and an inline script. composer test + composer parity green (128 parity fixtures). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
"Slice 2" of the runtime-island pipeline: a generic, product-neutral producer that packages transformer runtime-island output into a materialization payload a downstream consumer (e.g. SSI's companion-plugin scaffold) can turn into per-block render + scoped JS enqueue. This is the missing piece that lets the 537 script islands be carried as accepted preserved islands rather than dead fallbacks.
Changes (
php-transformer)src/ArtifactCompiler/RuntimeIslandPackageBuilder.php(new) — projects compiled-site runtime-island data into a generic envelopeblocks-engine/php-transformer/runtime-island-package/v1:{ schema, islands[], totals }. Per island: content-addressed id, kind/selector/tag, verbatim markup, preservation reason,disposition(preserve|drop),js_handling(preserve_verbatim|drop — the Feature parity: explicit preserve-vs-rebuild decision per interactive region (verbatim JS only on verbatim markup) #224 encoding), a stable enqueuehandle_hint, andscripts[](external src / inline content, role classification, telemetrydroppable). Wired intoArtifactCompiler::compile()next to the existing runtime_islands report.src/HtmlToBlocks/Diagnostics/FallbackEmitter.php—safeFallbackHtml()stripped<script>bodies fromsource_snippet, so inline script islands carried no JS at the island level.captureScriptFallback()now preserves the bounded verbatim inline body on the island (script_body/body_bytes/body_truncated), mirroring template islands. Fixed at the root rather than worked around.Boundary
Product-neutral — schema, class, fields, and comments carry no SSI/companion-plugin/Studio names. The consumer mapping (generic package → SSI
preserved_js/per-block render) stays in SSI as the next slice. (Note: a pre-existingsrc/ArtifactCompiler/CompanionPluginPayload.phpon trunk already carries product names — flagged for separate cleanup, untouched here.)Verification
composer test+composer parity→ green, 128 fixtures. New contract fixture + section covering a verbatim-preserved first-party inline island, a dropped telemetry script, and an island carrying both external+inline scripts, plus product-neutrality assertions.AI assistance