Widget Primitives: extract into @wordpress/widget-primitives#79134
Conversation
parametric 0-9 glyphs with per-stroke gradients, all WPDS tokens
|
Size Change: 0 B Total Size: 8.58 MB |
|
Flaky tests detected in 21d2816. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27568263274
|
| 1. **Server (PHP).** `WP_Widget_Type_Registry` is hydrated at `init` from the | ||
| build manifest. One entry per widget folder under `widgets/`. | ||
| 2. **REST endpoint.** `/wp/v2/widget-modules` exposes the registry. Each record | ||
| returns `{ name, render_module, widget_module }`. |
There was a problem hiding this comment.
I noticed that the SVG diagram show { name, render_module, widget_module, presentation }. Should we aligning step 2 and step 4 to include presentation?
There was a problem hiding this comment.
yes, we should. Thanks!!!
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
add react-dom peer and storybook devDependencies
the REST record carries it and the hook merge prefers it
@wordpress/widget-primitives
follows the bg/fg token group rename in #79098
drop sections already covered by the architecture doc
match the convention used across react packages
What?
Moves the widget toolkit from
routes/dashboard/widget-primitives/into a standalone package,packages/widget-primitives/, published as@wordpress/widget-primitivesat0.1.0-prerelease(experimental). No behavior changes.The package is the single source of truth for the widget contract:
WidgetType,WidgetName,WidgetIcon,WidgetRenderProps,ResolveWidgetModule.useWidgetTypes()hook.<WidgetRender>host entry point.Also adds
docs/explanations/architecture/dashboard-widgets.md, explaining how the pieces of the widget system fit together (authoring convention, build pipeline, server registry, client contract, hosts).Why?
The widget contract is a public boundary: authors write against it, hosts render through it.
While it lives in
routes/dashboard/, it stays private: no external project can consume it.Moving it to a public, top-level package makes it consumable on its own.
How?
git mvof the tree intopackages/widget-primitives/src/, preserving history; the sources are unchanged.package.json(exports/typespointing at the build artifacts,wpScript: false,publishConfig.access: public, peer dep onreact) and atsconfig.jsonwith its project references.WidgetIconstays a plain SVGReactElement, with no@wordpress/uidependency: any host can define and consume its own icons.file:workspace dependency, imports pointing at@wordpress/widget-primitives, its exclude inroutes/dashboard/tsconfig.jsonremoved, and a reference in the roottsconfig.json.CHANGELOG.md;WidgetRenderstories, with an Introduction page that renders the architecture document.Testing
Widget Primitives/Introductionrenders the architecture document; underWidget Primitives/WidgetRender,Defaultshows the render contract.WithSettingsedits the widget through aDataFormmounted from the type's declarativeattributes(Field[]).WithHostChromeframes the widget in host chrome (striped) around the widget render (solid).Screen.Recording.2026-06-12.at.10.19.26.AM.mov
Manual check through the dashboard route. Enable the
gutenberg-dashboard-widgetsexperiment and load/wp-admin/:Confirm that widgets render, that the inserter lists the registered widget types, and that widget settings open.
All widget-type data now flows through
@wordpress/widget-primitives.Disable the
gutenberg-dashboard-widgetsexperiment and confirm wp-admin still works as before: the package is consumed only behind the experiment, so the default admin must be unaffected.Follow-ups
widget-dashboard) into its own package, depending on this one.@wordpress/[email protected]installs and resolves outside the monorepo.