Skip to content

Refactor renderers into pluggable extensions while preserving backward compatibility - #133

Open
yuriyapostol wants to merge 9 commits into
kazuhikoarase:masterfrom
yuriyapostol:feature/pluggable-renderers
Open

Refactor renderers into pluggable extensions while preserving backward compatibility#133
yuriyapostol wants to merge 9 commits into
kazuhikoarase:masterfrom
yuriyapostol:feature/pluggable-renderers

Conversation

@yuriyapostol

Copy link
Copy Markdown

This PR refactors the rendering layer to make format renderers modular and extensible, while keeping the existing public API backward compatible.

What changed

  • moved non-core renderers out of the main implementation into separate renderer modules
  • rewrote and expanded the SVG renderer
  • added configurable renderer options instead of keeping rendering behavior fixed
  • made it possible to add new renderers or replace existing ones without changing the core QR generation logic
  • preserved backward compatibility for existing consumers
  • added optional renderers for:
    • SVG
    • table
    • ASCII
    • GIF / DataURL
  • updated demo and tests accordingly

Motivation

The previous structure made rendering formats tightly coupled to the main module.

This change introduces a more modular renderer architecture:

  • the core QR code generation logic stays focused on QR construction
  • renderers become independent and easier to evolve
  • new output formats can be added with less impact on the core code
  • existing renderers can be improved or replaced more safely

This also allowed me to substantially rework SVG rendering and extend renderer configuration without breaking existing usage patterns.

Backward compatibility

Compatibility was an explicit goal of this change.

Existing usage is preserved, including:

  • the main entry point
  • existing rendering methods

So projects using the current API should continue to work, while gaining access to the more modular renderer structure.

@yuriyapostol

Copy link
Copy Markdown
Author

This PR also includes two follow-up commits beyond the original renderer extraction work:

  • Add crispEdges option for SVG output in JavaScript
    Adds a new crispEdges option for SVG rendering in JavaScript. The option supports true, false, and 'auto' (default). In auto mode, shape-rendering="crispEdges" is applied only for whole-number cell sizes, which preserves sharp rendering without introducing geometry distortion for fractional sizes.

  • Refactor experiment/vt renderers into pluggable modules
    Applies the same renderer modularization to the TypeScript-based js/experiment/vt sources. The SVG, table, ASCII, and GIF renderers are moved out of the core module into separate renderer modules, compatibility wrappers are preserved in the main QRCode API, and the TypeScript build/tests are updated accordingly.

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