Skip to content

Theme: Restore public ThemeProvider export#79620

Merged
ciampo merged 28 commits into
trunkfrom
codex/theme-provider-public-bridge
Jun 29, 2026
Merged

Theme: Restore public ThemeProvider export#79620
ciampo merged 28 commits into
trunkfrom
codex/theme-provider-public-bridge

Conversation

@ciampo

@ciampo ciampo commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What?

Follow up to #79594.

Restores ThemeProvider as a public @wordpress/theme export while keeping the existing private API bridge temporarily available.

Why?

The previous stabilization in #78958 moved ThemeProvider to the public API but also removed the private export. That broke bundled/package consumers that still depended on the private API path, so #79594 temporarily restored the private-only state.

This PR lands the safer transition:

  • public API consumers can import ThemeProvider directly;
  • existing private API consumers keep working during a grace period;
  • newer @wordpress/ui consumers can still run against older WordPress runtimes where @wordpress/theme only exposes the private bridge;
  • private API access now warns through deprecations before removal in WordPress 7.3.

How?

  • Exports the runtime ThemeProvider from @wordpress/theme.
  • Keeps private API compatibility, but marks access as deprecated and points consumers to supported public theming APIs.
  • Removes the root CornerRadiusPreset type export; consumers can derive it from ThemeProvider's cornerRadius prop if needed.
  • Migrates Gutenberg-owned ThemeProvider and root configuration type consumers away from private/unstable root imports.
  • Uses no-restricted-imports to prevent new privateApis imports from @wordpress/theme.
  • Adds a temporary @wordpress/ui resolver that uses the public ThemeProvider when available and falls back to privateApis.ThemeProvider for older runtimes.

Testing Instructions

  • All unit tests pass.
  • All lint checks pass.
  • Build succeeds.

Testing Instructions for Keyboard

Not applicable; this changes package API wiring and lint coverage without changing UI behavior.

Screenshots or screencast

Not applicable.

Use of AI Tools

Created with assistance from OpenAI Codex. The diff and verification output were reviewed before opening this PR.

@github-actions github-actions Bot added [Package] Edit Site /packages/edit-site [Package] Theme /packages/theme [Package] UI /packages/ui labels Jun 29, 2026
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

Size Change: +655 B (+0.01%)

Total Size: 7.52 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 51.1 kB +45 B (+0.09%)
build/modules/content-types/index.min.js 160 kB +46 B (+0.03%)
build/scripts/block-directory/index.min.js 44.1 kB +56 B (+0.13%)
build/scripts/block-editor/index.min.js 383 kB +65 B (+0.02%)
build/scripts/edit-post/index.min.js 52.3 kB +72 B (+0.14%)
build/scripts/edit-site/index.min.js 298 kB +54 B (+0.02%)
build/scripts/editor/index.min.js 487 kB +35 B (+0.01%)
build/scripts/media-utils/index.min.js 115 kB +76 B (+0.07%)
build/scripts/theme/index.min.js 22.6 kB +206 B (+0.92%)

compressed-size-action

@ciampo ciampo self-assigned this Jun 29, 2026
@ciampo ciampo added [Type] Code Quality Issues or PRs that relate to code quality Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) labels Jun 29, 2026
@ciampo ciampo marked this pull request as ready for review June 29, 2026 09:52
@ciampo ciampo requested review from a team and manzoorwanijk as code owners June 29, 2026 09:52
@ciampo ciampo requested a review from tyxla June 29, 2026 09:52
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: aduth <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


export { privateApis } from './private-apis';
export { ThemeProvider } from './theme-provider';
export type * from './prebuilt/ts/token-types';

@ciampo ciampo Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether we should keep these types around. On one hand, they are the TS reflection of the CSS tokens and they are consumed by @wordpress/ui. On the other hand, we usually don't export types from DS packages.

In any case, changes such as adding a deprecation + lint errors can be handled in a separate PR.

cc @mirka @aduth

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, given that they are consumed by @wordpress/ui, we won't be able to simply delete them like done for the corner radius type.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can/should keep these. It's different from component props, which can be extracted from the component exports themselves.

Comment thread packages/theme/src/test/private-apis.test.ts Outdated
Comment thread packages/theme/src/private-apis.ts Outdated
Comment thread storybook/decorators/with-design-system-theme.tsx Outdated
Comment thread packages/theme/CHANGELOG.md Outdated

@aduth aduth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested that this works successfully both in Gutenberg-native screens using ThemeProvider stable API (Site Editor, no deprecation warning), as well as the AI plugin settings screen which bundles an older version of @wordpress/ui (logs deprecation warning).

Comment thread packages/theme/src/index.ts Outdated
Comment on lines +6 to +12

/**
* @deprecated This type is not part of the intended public API and will be
* removed in WordPress 7.3. Derive this type from `ThemeProvider`'s
* `cornerRadius` prop instead.
*/
export type CornerRadiusPreset = InternalCornerRadiusPreset;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we discussed this recently in #78958 (comment), but I'm less clear about needing to keep around the TypeScript types. It'd help to understand the failure scenario.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I just wrote a separate, related comment here.

I personally would like to remove it, but I intially adopted a more conversative approach.

The failure scenario here would be a build errors at TS compilation time, since the export would be missing?

Comment thread packages/theme/tsconfig.src.json Outdated
Comment thread packages/theme/src/index.ts Outdated
* removed in WordPress 7.3. Derive this type from `ThemeProvider`'s
* `cornerRadius` prop instead.
*/
export type CornerRadiusPreset = InternalCornerRadiusPreset;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a partially separate conversation to have. In short, we should not have a CornerRadiusPreset type export, since it can be derived (if needed) via React.ComponentProps< typeof ThemeProvider >[ 'cornerRadius' ].

Given that this export was added recently (#78816) and didn't make it to a WP release yet, I wonder if we can be more aggressive and just remove it from the package directly, especially given that its only usages in the repo were "internal" (storybook/decorators/with-design-system-theme.tsx and storybook/stories/design-system/theme-example-application.story.tsx). The potential to cause build errors here is much lower.

cc @WordPress/gutenberg-components and @tyxla

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I tentatively removed CornerRadiusPreset entirely and marked it as a breaking change

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to remove it too. Particularly since the rationale you suggested in #78958 (comment) for why TypeScript types would need to be sensitive to backwards-compatibility has to do with plugins supporting multiple versions of WordPress. If this has never landed in a WordPress release, combined with the fact that TypeScript types don't ever get exposed on window.wp.theme, it seems fine to remove.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed 👍

@ciampo ciampo enabled auto-merge (squash) June 29, 2026 14:27
@ciampo ciampo merged commit 9f77aaa into trunk Jun 29, 2026
54 of 62 checks passed
@ciampo ciampo deleted the codex/theme-provider-public-bridge branch June 29, 2026 14:27
@github-actions github-actions Bot added this to the Gutenberg 23.6 milestone Jun 29, 2026
@CGastrell

Copy link
Copy Markdown
Contributor

Any chance we cherry-pick this for RC.2?

tyxla added a commit that referenced this pull request Jun 30, 2026
* Theme: Restore public ThemeProvider export

* Theme: Add ThemeProvider public export changelog

* Theme: Use warning package for ThemeProvider deprecation

* Theme: Use restricted import for private APIs

* Theme: Deprecate unstable root type exports

* Storybook: Derive ThemeProvider corner radius type

* Theme: Keep token type exports unrestricted

* Theme: Warn for all private API access

* Theme: Simplify private API warning message

* Theme: Clarify private API warning source

* Theme: Clarify private API changelog entry

* Theme: Simplify private API warning tests

* UI: Remove internal ThemeProvider changelog entry

* Theme: Remove redundant SCRIPT_DEBUG test setup

* Theme: Use deprecated package for private API warnings

* Theme: Align deprecation timeline wording

* Theme: Retarget private API removal to WordPress 7.3

* UI: Add ThemeProvider compatibility fallback

* Storybook: Tighten corner radius preset types

* Storybook: Clarify optional corner radius type

* Build: Add missing TypeScript project references

* Theme: Reclassify private API changelog entry

* UI: Reuse lock-unlock helper

* Theme: Clarify private hook deprecation message

* Theme: Add CornerRadiusPreset changelog deprecation

* Theme: Remove root CornerRadiusPreset export

* Theme: Add CornerRadiusPreset breaking change

* Theme: Clean up compatibility metadata

---

Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: aduth <[email protected]>
# Conflicts:
#	packages/theme/CHANGELOG.md
#	packages/ui/CHANGELOG.md
@tyxla

tyxla commented Jun 30, 2026

Copy link
Copy Markdown
Member

I just cherry-picked this PR to the release/23.5 branch to get it included in the next release: 9fccd4f

@tyxla tyxla removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jun 30, 2026
ciampo added a commit that referenced this pull request Jun 30, 2026
* Theme: Restore public ThemeProvider export

* Theme: Add ThemeProvider public export changelog

* Theme: Use warning package for ThemeProvider deprecation

* Theme: Use restricted import for private APIs

* Theme: Deprecate unstable root type exports

* Storybook: Derive ThemeProvider corner radius type

* Theme: Keep token type exports unrestricted

* Theme: Warn for all private API access

* Theme: Simplify private API warning message

* Theme: Clarify private API warning source

* Theme: Clarify private API changelog entry

* Theme: Simplify private API warning tests

* UI: Remove internal ThemeProvider changelog entry

* Theme: Remove redundant SCRIPT_DEBUG test setup

* Theme: Use deprecated package for private API warnings

* Theme: Align deprecation timeline wording

* Theme: Retarget private API removal to WordPress 7.3

* UI: Add ThemeProvider compatibility fallback

* Storybook: Tighten corner radius preset types

* Storybook: Clarify optional corner radius type

* Build: Add missing TypeScript project references

* Theme: Reclassify private API changelog entry

* UI: Reuse lock-unlock helper

* Theme: Clarify private hook deprecation message

* Theme: Add CornerRadiusPreset changelog deprecation

* Theme: Remove root CornerRadiusPreset export

* Theme: Add CornerRadiusPreset breaking change

* Theme: Clean up compatibility metadata

---

Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: aduth <[email protected]>
@ciampo

ciampo commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I just cherry-picked this PR to the wp/latest branch (92529df) to get it included in the latest npm package releases (@wordpress/[email protected], @wordpress/[email protected])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Edit Site /packages/edit-site [Package] Theme /packages/theme [Package] UI /packages/ui [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants