feat: #3580092 Add support for json-render output format

#3580092

Adds json-render as a third Custom Elements JSON serialization format alongside the existing explicit and legacy formats.

Caveat

Currently, json-render does not support named slots in its specifications (only a single default children slot is supported). Drupal Canvas (CLI, Workbench) uses the slots structure proposed in json-render PR #105.

That PR is currently based on an older version of json-render, from when React was its only supported adapter. I'll work on bringing it up to date and extending named-slot support to the additional framework adapters that json-render now supports.

Changes

  • Refactor CustomElementNormalizer into a facade backed by tagged, format-specific normalizers:
    • JsonFormatNormalizer preserves the existing explicit and legacy formats.
    • JsonRenderFormatNormalizer produces a flat {root, elements} json-render spec.
      • For multi-root trees, renderless-container is used as the single synthetic root.
      • For empty render trees, empty json-render spec is returned { "root": "", "elements": {} }.
      • Named slots use the format proposed in the json-render PR #105.
  • Add json-render to the Custom Elements configuration form and allow callers to select it explicitly through the json_format normalization context.

I used an AI coding agent to assist in implementing this.

Edited by wotnak

Merge request reports

Loading