Skip to content

[2/3] refactor(painter): collapse legacy API surface (SD-2836)#3117

Open
tupizz wants to merge 4 commits intotadeu/sd-2836-1-consume-resolved-layoutfrom
tadeu/sd-2836-2-collapse-legacy-api
Open

[2/3] refactor(painter): collapse legacy API surface (SD-2836)#3117
tupizz wants to merge 4 commits intotadeu/sd-2836-1-consume-resolved-layoutfrom
tadeu/sd-2836-2-collapse-legacy-api

Conversation

@tupizz
Copy link
Copy Markdown
Contributor

@tupizz tupizz commented May 4, 2026

Stack

# PR Branch Status
1 #3116 tadeu/sd-2836-1-consume-resolved-layout open
2 this PR tadeu/sd-2836-2-collapse-legacy-api open
3 #3118 tadeu/sd-2836-3-lock-boundary open

Review in order. PR2 depends on PR1; merge PR1 first. PR3 depends on PR2.

What changed

Builds on PR1 (which made DomPainter consume ResolvedLayout internally) by collapsing the legacy public surface so that ResolvedLayout is the only painter input.

Painter (packages/layout-engine/painters/dom)

  • index.ts collapsed to a thin pass-through. Deleted: buildLegacyPaintInput, normalizeDomPainterInput, isDomPainterInput, wrapProvider, resolveDecorationItems, normalizeOptionalBlockMeasurePair, assertRequiredBlockMeasurePair, createEmptyResolvedLayout.
  • paint() now accepts { resolvedLayout, mount, mapping? } only. The legacy (layout, mount) shape is gone.
  • _test-utils.ts (new) hosts a createTestPainter helper that wraps a painter for tests still expressing inputs in the legacy shape, chaining the user's onPaintSnapshot after the internal one.

Tests

  • pm-adapter integration tests migrated to ResolvedLayout.
  • layout-bridge perf benchmark migrated to resolveLayout() + paint({ resolvedLayout }).
  • super-editor PresentationEditor.test.ts mock for resolveLayout synthesizes a ResolvedPage per source Layout page so rebuildRegions(resolvedLayout) populates regions correctly.

Why this split

PR1 keeps the internal migration reviewable on its own. This PR removes the legacy entry points and forces every consumer onto ResolvedLayout. PR3 then locks the boundary (test guard + drops @superdoc/layout-resolved from runtime deps).

Verification

  • All package tests pass: painter-dom, pm-adapter, layout-bridge, layout-engine, super-editor.
  • HEAD-vs-origin/main corpus snapshot diff: 0 changed / 407 unchanged (rendering-neutral).

Test plan

  • CI green
  • Reviewer confirms no remaining references to deleted helpers
  • PR3 boundary guard catches any future regressions

@tupizz tupizz requested a review from a team as a code owner May 4, 2026 16:51
@linear
Copy link
Copy Markdown

linear Bot commented May 4, 2026

@tupizz tupizz force-pushed the tadeu/sd-2836-1-consume-resolved-layout branch from 33e0471 to c5d0b09 Compare May 4, 2026 17:10
@tupizz tupizz force-pushed the tadeu/sd-2836-2-collapse-legacy-api branch 2 times, most recently from befe9c0 to 8f18041 Compare May 4, 2026 17:48
tupizz added 4 commits May 4, 2026 15:04
Make ResolvedLayout the only painter input contract:

* DomPainterInput collapses to `{ resolvedLayout: ResolvedLayout }`.
  sourceLayout, blocks/measures, headerBlocks/Measures,
  footerBlocks/Measures all removed.
* DomPainterOptions: drop blocks/measures.
* DomPainterHandle: drop setData, setResolvedLayout. paint takes only
  DomPainterInput. Drops the `paint(Layout)` overload across painter,
  PresentationPainterAdapter, and (transitively) PresentationEditor's
  paintInput.
* createDomPainter shrinks to a thin pass-through. Removes
  buildLegacyPaintInput, normalizeDomPainterInput, isDomPainterInput,
  wrapProvider, resolveDecorationItems, normalizeOptionalBlockMeasurePair,
  assertRequiredBlockMeasurePair, createEmptyResolvedLayout,
  LegacyDomPainterState, OptionalBlockMeasurePair.
* PageDecorationPayload.items becomes required (the synthesis path
  is gone).

Tests:
* New `_test-utils.ts` exposes a legacy-shaped `createTestPainter`
  that test files import in place of `createDomPainter`. The helper
  builds a real DomPainterInput internally and synthesizes decoration
  items so existing test bodies don't have to be rewritten.
* All 17 painter test files migrated to the helper.
* Two source-anchor tests still failing under investigation;
  remaining work is bounded and tracked.
createTestPainter was overwriting the user-supplied onPaintSnapshot callback with its own, so tests that relied on the callback (source-anchor tests) saw an undefined snapshot. Chain the user callback after the internal one.
The three integration tests in pm-adapter were calling painter.paint(layout, mount) with raw Layout. They now resolveLayout() first and call painter.paint({ resolvedLayout }, mount). All 1794 pm-adapter tests pass.
The layout-bridge incremental-pipeline performance benchmark called painter.paint(layout, mount) and painter.setData(...). Both are removed by the API collapse. Migrate to resolveLayout() + DomPainterInput so the benchmark continues to exercise the painter under the new contract.
@tupizz tupizz force-pushed the tadeu/sd-2836-2-collapse-legacy-api branch from 8f18041 to 1c869c1 Compare May 4, 2026 18:05
@tupizz tupizz self-assigned this May 4, 2026
Copy link
Copy Markdown
Contributor

@luccas-harbour luccas-harbour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @tupizz!
I started reviewing this one and ran into an issue running tests, both packages/layout-engine/layout-bridge/test/performance.test.ts and packages/layout-engine/pm-adapter/src/integration.test.ts failed for me. It looks like you need to add @superdoc/layout-resolved as a test dependency to both @superdoc/pm-adapter and @superdoc/layout-bridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants