Skip to content

blocks-engine 0.2.2: add opt-in structuredStrategy for no-CSS-carry blocks reconstruction#382

Merged
borkweb merged 1 commit into
trunkfrom
fix/reconstruct-strategy
Jun 30, 2026
Merged

blocks-engine 0.2.2: add opt-in structuredStrategy for no-CSS-carry blocks reconstruction#382
borkweb merged 1 commit into
trunkfrom
fix/reconstruct-strategy

Conversation

@borkweb

@borkweb borkweb commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Adds structuredStrategy, a selectable reconstruction strategy exported from @automattic/blocks-engine/theme. It interprets the SectionSpec into clean, theme-styled canonical blocks first (nativeDecisionrenderCover / renderCardGrid / renderMediaText / …), falling back to a verbatim core/html island only on coverage loss. Unlike the preserve-DOM default it does not preserve source classes or whole-section islands, so its output is self-contained and renders from the theme alone — no dependency on carried source CSS.

Bumps the package to 0.2.2 with a CHANGELOG entry and a strategy-seam test.

Why

The interpretive structured renderers still exist in the engine, but both shipped strategies (defaultReconstructStrategy, classifySemanticStrategy) route through preserve-DOM / verbatim islands first — keeping source classes and therefore requiring carried source CSS to render. A no-CSS-carry blocks pipeline (data-liberation's blocks reconstruct path) had no way to select the structured renderers, so its output rendered unstyled (class-preserving blocks with no backing CSS, e.g. a Wix homepage stacking to ~20× the source height). structuredStrategy restores that pre-preserve-DOM fidelity.

Safety

Strictly additive and opt-in via SectionRenderOptions.strategy. The default remains defaultReconstructStrategy (preserve-DOM), so the carried-CSS paths (local-convert, theme-carry) are byte-identical — verified by the existing strategy-seam byte-identity test and the full suite (441 tests green).

Test plan

  • vitest run — full suite green (441), including the new structuredStrategy seam tests and the unchanged default-path byte-identity test.
  • Dogfood (data-liberation blocks path, Wix source): structured output is gate-passing with 0 preserved source classes / 0 islands / 0 remote URLs; renders theme-styled chrome + wp:cover hero + gallery columns at ~source height (vs. unstyled stack under the default).

…locks reconstruction

## Summary
Adds `structuredStrategy`, a selectable reconstruction strategy exported from
`@automattic/blocks-engine/theme`. It interprets the `SectionSpec` into clean,
theme-styled canonical blocks first (`nativeDecision` -> `renderCover` /
`renderCardGrid` / `renderMediaText` / ...), falling back to a verbatim
`core/html` island only on coverage loss. Unlike the preserve-DOM default it
does not preserve source classes or whole-section islands, so its output is
self-contained and renders from the theme alone, with no dependency on carried
source CSS. Bumps the package to 0.2.2 with a CHANGELOG entry and a strategy-seam
test.

## Why
The interpretive structured renderers still exist in the engine, but both shipped
strategies (`defaultReconstructStrategy`, `classifySemanticStrategy`) route through
preserve-DOM / verbatim islands first, which keep source classes and therefore
require carried source CSS to render. A no-CSS-carry blocks pipeline (data-liberation's
blocks reconstruct path) had no way to select the structured renderers, so its output
rendered unstyled (class-preserving blocks with no backing CSS). `structuredStrategy`
restores that pre-preserve-DOM fidelity.

## Safety
Strictly additive and opt-in via `SectionRenderOptions.strategy`. The default remains
`defaultReconstructStrategy` (preserve-DOM), so the carried-CSS paths (local-convert,
theme-carry) are byte-identical — verified by the existing strategy-seam byte-identity
test and the full suite (441 tests green).
@borkweb borkweb merged commit 770865e into trunk Jun 30, 2026
2 checks passed
@borkweb borkweb deleted the fix/reconstruct-strategy branch June 30, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant