-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Description
Now that the usage of private selectors, actions, components, functions, and other exports can be restricted to the Gutenberg plugin, it's time to also make it possible for block.json and theme.json APIs.
This issue is a part of Developer Experience: There's ~280 __experimental APIs. Let's stabilize them!.
Block.json
At the moment, the private block.json APIs can be restricted to core blocks by manually checking the block type. For example, here's how that would look like for supports.__experimentalMetadata:
export function hasBlockMetadataSupport( blockType, feature = '' ) {
+ if ( ! blockType.startsWith('core/') ) {
+ return false;
+ }
const support = getBlockSupport( blockType, '__experimentalMetadata' );
return !! ( true === support || support?.[ feature ] );
}It would be convenient to automate this process and apply it to all __experimental block.json entries. Here's an idea: preprocess all the block.json metadata and remove the __experimental keys from all non-core blocks. This wouldn't apply to the __experimental entries that have already become a public API. Technically speaking, I'm thinking of recursive filtering based on the block type prefix and an allowlist of public experimental APIs.
Theme.json
I don't understand the meaning of restricting the experimental theme.json API to the Gutenberg plugin. Would it be based on a list of core themes? Theme.json files have a hierarchy – what if a third-party theme inherits experimental settings from a theme.json file related to WordPress core? CC @scruffian @mtias @draganescu @youknowriad
CC @gziolo @dmsnell @jsnajdr @ciampo @noisysocks @talldan @ntsekouras @andrewserong