Repository navigation
refactor: move the SVG renderer out of the domain into a driven adapter - #117
Merged
emaarco merged 1 commit intoOct 28, 2026
Merged
Conversation
The renderer now lives in adapters/out/render behind a RenderDiagramPort, grouped into crop/, paint/ and compose/. The in-memory layout of a file without a diagram moves into the domain as DrawableDoc, and the image writer receives the finished drawing instead of XML. The output stays byte-identical. Closes #113
emaarco
enabled auto-merge (squash)
October 28, 2026 08:13
emaarco
deleted the
emaarco/refactor-move-the-svg-renderer-out-of-the-domain
branch
October 28, 2026 08:19
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
The SVG renderer only draws SVG, yet it lived in
src/domain/views/render/, and two file adapters (FileImageWriter,PngRenderer) called it directly. This PR makes it a browser-safe driven adapter behind an outbound port, with byte-identical output.application/port/out/RenderDiagramPortis implemented byadapters/out/render/SvgRenderer. The renderer is grouped by step:crop/(which part of the plane),paint/(shapes, connections, labels),compose/(frame, scale, badges, tiles);DocRendererandtypes.tsstay on top.SvgRenderercarries a comment on why this is custom code instead of bpmn-js.domain/views/DrawableDocparses the XML and lays out a file without a diagram (its own problems and the two notes, word for word).RenderSvgServiceandRenderDiagramServicecall it, then the port.WriteImagePort.ImageRequestcarriesdrawn: RenderResultinstead of XML and options, soout/filesno longer imports the renderer.PngRenderer.render(drawn)only rasterises; theRENDER_MAX_SIZEdefault moved torenderPnginnode.ts(the CLI always passesmaxSize).RenderOptions,RenderResult,RenderProblem,RenderTile,RenderHighlight,RENDER_MAX_SIZE,MIN_LABEL_SCALEandHALO_COLORSnow live inport/in/RenderSvgUseCase.ts. The exports ofindex.tsandnode.tskeep their names and signatures.out/renderis a registered adapter; new checks that no domain file contains<svg/<gand thatadapters/out/renderimports nonode:*. The three render constants left the list of values re-exported from the domain.CONTRIBUTING.mdlayout table, the diagram indocs/architecture.md, test paths indocs/testing.md. The render tests moved totest/adapters/out/render/.Verification:
vitest run: 2395 passed, 246 skipped.bpmn render(SVG, PNG and the--jsonreports) saved before the change and compared withcmpafter it, covering several planes,--problems,--tiles,--highlight, files without a diagram andtools/scenarios. No difference.npm run build,biome lint,knip,knip --production --exclude dependencies,jscpdandtools/iso/check.mjspass. The bench regression gate and the fuzz run ofnpm run gatewere not run locally.guide.tsneeds no update.Checklist
npm run typecheckpassesnpm run gatepassessrc/report/guide.tsand the matching page indocs/are updated (only if a command, option or output changed)Linked issue
Closes #113