Theme: Restore public ThemeProvider export#79620
Conversation
|
Size Change: +655 B (+0.01%) Total Size: 7.52 MB 📦 View Changed
|
|
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. |
|
|
||
| export { privateApis } from './private-apis'; | ||
| export { ThemeProvider } from './theme-provider'; | ||
| export type * from './prebuilt/ts/token-types'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I think we can/should keep these. It's different from component props, which can be extracted from the component exports themselves.
aduth
left a comment
There was a problem hiding this comment.
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).
|
|
||
| /** | ||
| * @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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
| * removed in WordPress 7.3. Derive this type from `ThemeProvider`'s | ||
| * `cornerRadius` prop instead. | ||
| */ | ||
| export type CornerRadiusPreset = InternalCornerRadiusPreset; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Update: I tentatively removed CornerRadiusPreset entirely and marked it as a breaking change
There was a problem hiding this comment.
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.
|
Any chance we cherry-pick this for RC.2? |
* 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
|
I just cherry-picked this PR to the |
* 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]>
|
I just cherry-picked this PR to the |
What?
Follow up to #79594.
Restores
ThemeProvideras a public@wordpress/themeexport while keeping the existing private API bridge temporarily available.Why?
The previous stabilization in #78958 moved
ThemeProviderto 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:
ThemeProviderdirectly;@wordpress/uiconsumers can still run against older WordPress runtimes where@wordpress/themeonly exposes the private bridge;How?
ThemeProviderfrom@wordpress/theme.CornerRadiusPresettype export; consumers can derive it fromThemeProvider'scornerRadiusprop if needed.ThemeProviderand root configuration type consumers away from private/unstable root imports.no-restricted-importsto prevent newprivateApisimports from@wordpress/theme.@wordpress/uiresolver that uses the publicThemeProviderwhen available and falls back toprivateApis.ThemeProviderfor older runtimes.Testing Instructions
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.