blocks-engine 0.2.2: add opt-in structuredStrategy for no-CSS-carry blocks reconstruction#382
Merged
Merged
Conversation
…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).
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.
Summary
Adds
structuredStrategy, a selectable reconstruction strategy exported from@automattic/blocks-engine/theme. It interprets theSectionSpecinto clean, theme-styled canonical blocks first (nativeDecision→renderCover/renderCardGrid/renderMediaText/ …), falling back to a verbatimcore/htmlisland 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).structuredStrategyrestores that pre-preserve-DOM fidelity.Safety
Strictly additive and opt-in via
SectionRenderOptions.strategy. The default remainsdefaultReconstructStrategy(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 newstructuredStrategyseam tests and the unchanged default-path byte-identity test.wp:coverhero + gallery columns at ~source height (vs. unstyled stack under the default).