Repository navigation
Theme: Restore public ThemeProvider export #79620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
9fe7e18
Theme: Restore public ThemeProvider export
ciampo 9368815
Theme: Add ThemeProvider public export changelog
ciampo 3427a2d
Theme: Use warning package for ThemeProvider deprecation
ciampo a73e43e
Theme: Use restricted import for private APIs
ciampo c02f94b
Theme: Deprecate unstable root type exports
ciampo 9ee3bce
Storybook: Derive ThemeProvider corner radius type
ciampo 57715bd
Theme: Keep token type exports unrestricted
ciampo ab8e694
Theme: Warn for all private API access
ciampo 5e1c566
Theme: Simplify private API warning message
ciampo 4866d05
Theme: Clarify private API warning source
ciampo 27733eb
Theme: Clarify private API changelog entry
ciampo a70f380
Theme: Simplify private API warning tests
ciampo 6d56aac
UI: Remove internal ThemeProvider changelog entry
ciampo 5d2a903
Theme: Remove redundant SCRIPT_DEBUG test setup
ciampo 07a6f24
Theme: Use deprecated package for private API warnings
ciampo 2c18621
Theme: Align deprecation timeline wording
ciampo 86c2fc0
Theme: Retarget private API removal to WordPress 7.3
ciampo 5e3a1ba
UI: Add ThemeProvider compatibility fallback
ciampo acc5316
Storybook: Tighten corner radius preset types
ciampo 4b2dcb5
Storybook: Clarify optional corner radius type
ciampo 9b0675e
Build: Add missing TypeScript project references
ciampo cf72026
Theme: Reclassify private API changelog entry
ciampo 54eb383
UI: Reuse lock-unlock helper
ciampo 1367e9d
Theme: Clarify private hook deprecation message
ciampo 2d11ce6
Theme: Add CornerRadiusPreset changelog deprecation
ciampo 13cf1c4
Theme: Remove root CornerRadiusPreset export
ciampo 0fbd30d
Theme: Add CornerRadiusPreset breaking change
ciampo 0ef91a0
Theme: Clean up compatibility metadata
ciampo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| export { privateApis } from './private-apis'; | ||
| export { ThemeProvider } from './theme-provider'; | ||
| export type * from './prebuilt/ts/token-types'; | ||
| export { type ThemeProvider } from './theme-provider'; | ||
| export type { CornerRadiusPreset } from './types'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,37 @@ | ||
| import deprecated from '@wordpress/deprecated'; | ||
| import { lock } from './lock-unlock'; | ||
| import { ThemeProvider } from './theme-provider'; | ||
| import { useThemeProviderStyles } from './use-theme-provider-styles'; | ||
|
|
||
| function warnPrivateApi( | ||
| apiName: string, | ||
| options: { alternative?: string; hint?: string } = {} | ||
| ) { | ||
| deprecated( `\`privateApis.${ apiName }\` from \`@wordpress/theme\``, { | ||
| since: '7.1', | ||
| version: '7.3', | ||
| ...options, | ||
| } ); | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated Private `@wordpress/theme` APIs will be removed in WordPress 7.3. | ||
| * Use public `@wordpress/theme` APIs for supported theming use cases. | ||
| */ | ||
| export const privateApis = {}; | ||
| lock( privateApis, { | ||
| ThemeProvider, | ||
| useThemeProviderStyles, | ||
| get ThemeProvider() { | ||
| warnPrivateApi( 'ThemeProvider', { | ||
| alternative: '`ThemeProvider` from `@wordpress/theme`', | ||
| } ); | ||
| return ThemeProvider; | ||
| }, | ||
| get useThemeProviderStyles() { | ||
| warnPrivateApi( 'useThemeProviderStyles', { | ||
| alternative: | ||
| '`ThemeProvider` from `@wordpress/theme` for supported theming use cases', | ||
| hint: '`useThemeProviderStyles` has no public replacement.', | ||
| } ); | ||
| return useThemeProviderStyles; | ||
| }, | ||
| } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { unlock } from '../lock-unlock'; | ||
| import { privateApis } from '../private-apis'; | ||
| import { ThemeProvider } from '../theme-provider'; | ||
| import { useThemeProviderStyles } from '../use-theme-provider-styles'; | ||
|
|
||
| describe( 'privateApis', () => { | ||
| it( 'warns when accessing useThemeProviderStyles through private APIs', () => { | ||
| const warn = jest | ||
| .spyOn( console, 'warn' ) | ||
| .mockImplementation( () => {} ); | ||
|
|
||
| const unlockedPrivateApis = unlock< { | ||
| useThemeProviderStyles: typeof useThemeProviderStyles; | ||
| } >( privateApis ); | ||
|
|
||
| expect( unlockedPrivateApis.useThemeProviderStyles ).toBe( | ||
| useThemeProviderStyles | ||
| ); | ||
|
|
||
| expect( warn ).toHaveBeenCalledWith( | ||
| '`privateApis.useThemeProviderStyles` from `@wordpress/theme` is deprecated since version 7.1 and will be removed in version 7.3. Please use `ThemeProvider` from `@wordpress/theme` for supported theming use cases instead. Note: `useThemeProviderStyles` has no public replacement.' | ||
| ); | ||
|
|
||
| warn.mockRestore(); | ||
| } ); | ||
|
|
||
| it( 'warns when accessing ThemeProvider through private APIs', () => { | ||
| const warn = jest | ||
| .spyOn( console, 'warn' ) | ||
| .mockImplementation( () => {} ); | ||
|
|
||
| const unlockedPrivateApis = unlock< { | ||
| ThemeProvider: typeof ThemeProvider; | ||
| } >( privateApis ); | ||
|
|
||
| expect( unlockedPrivateApis.ThemeProvider ).toBe( ThemeProvider ); | ||
|
|
||
| expect( warn ).toHaveBeenCalledWith( | ||
| '`privateApis.ThemeProvider` from `@wordpress/theme` is deprecated since version 7.1 and will be removed in version 7.3. Please use `ThemeProvider` from `@wordpress/theme` instead.' | ||
| ); | ||
|
|
||
| warn.mockRestore(); | ||
| } ); | ||
| } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.