feat(Headless): #3591861 Use the new Canvas content API endpoint in the headless SDK
- Switches the headless SDK's draft-aware
fetchPage()client from/ce-api/{path}to/canvas/content-api. - Adopts the Canvas endpoint's content, document-head, route, and redirect response contract.
- Removes the now obsolete Lupus endpoint dependencies and the
/ce-apiauto-save controller override.
SDK response handling
fetchPage(requestUri) now returns:
Page, containing Canvas-rendered content when available, document-head data, and normalized route information.route.managedByCanvasindicates whether Canvas manages the route's complete component tree.route.managedByCanvasis used to distinguish an empty Canvas-managed page from a route Canvas does not render, because both returncontent: null.
PageRedirect, containing the redirect URL, status code, and external-URL flag.nullwhen Drupal returns a non-success response.
isPageRedirect() distinguishes redirect results before page fields are read. Live draft requests continue to carry the preview bearer token. Empty draft content receives an editor-only structural root so the frontend can render an editable content-region placeholder.
Component-tree bindings now consume one structured root or null instead of the former structured-or-markup response.
Lupus removal
The SDK no longer calls /ce-api, so this MR removes:
- The
drupal/lupus_decoupleddevelopment dependency. - The
lupus_ce_rendererandlupus_decoupled_ce_apimodule dependencies. - The Lupus-specific auto-save preview controller, controller subscriber, services, and kernel test.
Testing
- build ui and packages and enable canvas_headless
npm run buildnpm run packages:buildddev drush crnpm link -wsddev drush en canvas_headless
- create a headless app:
npx @drupal-canvas/create@latest --experimental-headless --template nextjs - start headless app
npm link @drupal-canvas/headless @drupal-canvas/headless-next @drupal-canvas/headless-react(if using a template other than the nextjs, link@drupal-canvas/headlessand framework adapter matching the template)npm run dev
- configure frontend in canvas
- verify that headless preview in canvas works and uses auto-save data
- verify that the headless app can display published canvas pages outside preview context
AI-Generated: Yes (Used AI coding agent to work on implementation).
Edited by wotnak