Skip to content

Commit

Permalink
Rename the "experiments" export to "privateApis" (#47975)
Browse files Browse the repository at this point in the history
* Rename the "experiments" export to "privateApis"

* Fix a typo

* minor missing renames

---------

Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
adamziel and ntsekouras authored Feb 11, 2023
1 parent ca90b31 commit 7fbf73d
Show file tree
Hide file tree
Showing 47 changed files with 189 additions and 193 deletions.
7 changes: 3 additions & 4 deletions docs/contributors/code/coding-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ You can attach private selectors and actions to a public store:

```js
// In packages/package1/store.js:
import { experiments as dataExperiments } from '@wordpress/data';
import { __experimentalHasContentRoleAttribute, ...selectors } from './selectors';
import { __experimentalToggleFeature, ...actions } from './selectors';
// The `lock` function is exported from the internal experiments.js file where
Expand Down Expand Up @@ -340,9 +339,9 @@ function MyComponent() {
// In packages/package1/index.js:
import { lock } from './private-apis';

export const experiments = {};
export const privateApis = {};
/* Attach private data to the exported object */
lock( experiments, {
lock( privateApis, {
__experimentalCallback: function () {},
__experimentalReactComponent: function ExperimentalComponent() {
return <div />;
Expand All @@ -352,7 +351,7 @@ lock( experiments, {
} );

// In packages/package2/index.js:
import { experiments } from '@wordpress/package1';
import { privateApis } from '@wordpress/package1';
import { unlock } from './private-apis';

const {
Expand Down
8 changes: 4 additions & 4 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,6 @@ _Returns_

Undocumented declaration.

### experiments

Experimental @wordpress/block-editor APIs.

### FontSizePicker

_Related_
Expand Down Expand Up @@ -639,6 +635,10 @@ _Related_

- <https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md>

### privateApis

Private @wordpress/block-editor APIs.

### RichText

_Related_
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/url-popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useState } from '@wordpress/element';
import {
Button,
Popover,
experiments as componentsExperiments,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { chevronDown } from '@wordpress/icons';
import deprecated from '@wordpress/deprecated';
Expand All @@ -19,7 +19,7 @@ import LinkEditor from './link-editor';
import { unlock } from '../../lock-unlock';

const { __experimentalPopoverLegacyPositionToPlacement } = unlock(
componentsExperiments
componentsPrivateApis
);

const DEFAULT_PLACEMENT = 'bottom';
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/hooks/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { __, sprintf } from '@wordpress/i18n';
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
import {
BaseControl,
experiments as componentsExperiments,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
Expand All @@ -32,7 +32,7 @@ import { cleanEmptyObject } from './utils';
import { unlock } from '../lock-unlock';
import { store as blockEditorStore } from '../store';

const { CustomSelectControl } = unlock( componentsExperiments );
const { CustomSelectControl } = unlock( componentsPrivateApis );

const POSITION_SUPPORT_KEY = 'position';

Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export * from './elements';
export * from './utils';
export { storeConfig, store } from './store';
export { SETTINGS_DEFAULTS } from './store/defaults';
export { experiments } from './private-apis';
export { privateApis } from './private-apis';
6 changes: 3 additions & 3 deletions packages/block-editor/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import OffCanvasEditor from './components/off-canvas-editor';
import LeafMoreMenu from './components/off-canvas-editor/leaf-more-menu';

/**
* Experimental @wordpress/block-editor APIs.
* Private @wordpress/block-editor APIs.
*/
export const experiments = {};
lock( experiments, {
export const privateApis = {};
lock( privateApis, {
...globalStyles,
ExperimentalBlockEditorProvider,
LeafMoreMenu,
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/private-apis.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { ExperimentalBlockEditorProvider } from './components/provider';
import { lock } from './lock-unlock';

/**
* Experimental @wordpress/block-editor APIs.
* Private @wordpress/block-editor APIs.
*/
export const experiments = {};
lock( experiments, {
export const privateApis = {};
lock( privateApis, {
...globalStyles,
ExperimentalBlockEditorProvider,
} );
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import {
experiments as blockEditorExperiments,
privateApis as blockEditorPrivateApis,
InspectorControls,
store as blockEditorStore,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -33,7 +33,7 @@ const MainContent = ( {
isNavigationMenuMissing,
onCreateNew,
} ) => {
const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorExperiments );
const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
// Provide a hierarchy of clientIds for the given Navigation block (clientId).
// This is required else the list view will display the entire block tree.
const clientIdsTree = useSelect(
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,5 @@ export {
export { default as withNotices } from './higher-order/with-notices';
export { default as withSpokenMessages } from './higher-order/with-spoken-messages';

// Experiments.
export { experiments } from './private-apis';
// Private APIs.
export { privateApis } from './private-apis';
4 changes: 2 additions & 2 deletions packages/components/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const { lock, unlock } =
'@wordpress/components'
);

export const experiments = {};
lock( experiments, {
export const privateApis = {};
lock( privateApis, {
CustomSelectControl,
__experimentalPopoverLegacyPositionToPlacement,
} );
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

/**
* Internal dependencies
Expand All @@ -11,7 +11,7 @@ import useBlocksFocusControl from '../focus-control/use-blocks-focus-control';

import { unlock } from '../../private-apis';

const { ExperimentalBlockEditorProvider } = unlock( blockEditorExperiments );
const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );

export default function SidebarEditorProvider( {
sidebar,
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-post/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ErrorBoundary,
PostLockedModal,
store as editorStore,
experiments as editorExperiments,
privateApis as editorPrivateApis,
} from '@wordpress/editor';
import { useMemo } from '@wordpress/element';
import { SlotFillProvider } from '@wordpress/components';
Expand All @@ -23,7 +23,7 @@ import EditorInitialization from './components/editor-initialization';
import { store as editPostStore } from './store';
import { unlock } from './private-apis';

const { ExperimentalEditorProvider } = unlock( editorExperiments );
const { ExperimentalEditorProvider } = unlock( editorPrivateApis );

function Editor( { postId, postType, settings, initialEdits, ...props } ) {
const {
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/block-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
__unstableUseTypingObserver as useTypingObserver,
BlockEditorKeyboardShortcuts,
store as blockEditorStore,
experiments as blockEditorExperiments,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import {
useMergeRefs,
Expand All @@ -39,7 +39,7 @@ import EditorCanvas from './editor-canvas';
import StyleBook from '../style-book';
import { unlock } from '../../private-apis';

const { ExperimentalBlockEditorProvider } = unlock( blockEditorExperiments );
const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );

const LAYOUT = {
type: 'default',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*/
import { useEffect } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import { store as editSiteStore } from '../../store';
import { unlock } from '../../private-apis';

const { useGlobalStylesOutput } = unlock( blockEditorExperiments );
const { useGlobalStylesOutput } = unlock( blockEditorPrivateApis );

function useGlobalStylesRenderer() {
const [ styles, settings, svgFilters ] = useGlobalStylesOutput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import {
__experimentalBorderRadiusControl as BorderRadiusControl,
experiments as blockEditorExperiments,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import {
__experimentalBorderBoxControl as BorderBoxControl,
Expand All @@ -21,7 +21,7 @@ import { __ } from '@wordpress/i18n';
import { useSupportedStyles, useColorsPerOrigin } from './hooks';
import { unlock } from '../../private-apis';

const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorExperiments );
const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );

export function useHasBorderPanel( name ) {
const controls = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
__experimentalVStack as VStack,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import { unlock } from '../../private-apis';

const { useGlobalSetting } = unlock( blockEditorExperiments );
const { useGlobalSetting } = unlock( blockEditorPrivateApis );

export default function ColorPalettePanel( { name } ) {
const [ themeColors, setThemeColors ] = useGlobalSetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import { isRTL, __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

/**
* Internal dependencies
Expand All @@ -37,7 +37,7 @@ import { useHasShadowControl } from './shadow-panel';
import { unlock } from '../../private-apis';

const { useHasTypographyPanel, useGlobalSetting } = unlock(
blockEditorExperiments
blockEditorPrivateApis
);

function ContextMenu( { name, parentMenu = '' } ) {
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/global-styles/custom-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import {
experiments as blockEditorExperiments,
privateApis as blockEditorPrivateApis,
transformStyles,
} from '@wordpress/block-editor';
import { info } from '@wordpress/icons';
Expand All @@ -23,7 +23,7 @@ import { info } from '@wordpress/icons';
import { unlock } from '../../private-apis';
import Subtitle from './subtitle';

const { useGlobalStyle } = unlock( blockEditorExperiments );
const { useGlobalStyle } = unlock( blockEditorPrivateApis );
function CustomCSSControl( { blockName } ) {
// If blockName is defined, we are customizing CSS at the block level:
// styles.blocks.blockName.css
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
__experimentalUseCustomSides as useCustomSides,
HeightControl,
__experimentalSpacingSizesControl as SpacingSizesControl,
experiments as blockEditorExperiments,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import { Icon, positionCenter, stretchWide } from '@wordpress/icons';

Expand All @@ -30,7 +30,7 @@ import { Icon, positionCenter, stretchWide } from '@wordpress/icons';
import { useSupportedStyles } from './hooks';
import { unlock } from '../../private-apis';

const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorExperiments );
const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );

const AXIAL_SIDES = [ 'horizontal', 'vertical' ];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { mergeWith, isEmpty, mapValues } from 'lodash';
import { useMemo, useCallback } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import CanvasSpinner from '../canvas-spinner';
import { unlock } from '../../private-apis';

const { GlobalStylesContext } = unlock( blockEditorExperiments );
const { GlobalStylesContext } = unlock( blockEditorPrivateApis );

function mergeTreesCustomizer( _, srcValue ) {
// We only pass as arrays the presets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {
DuotonePicker,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import Subtitle from './subtitle';
import { unlock } from '../../private-apis';

const { useGlobalSetting } = unlock( blockEditorExperiments );
const { useGlobalSetting } = unlock( blockEditorPrivateApis );

const noop = () => {};

Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import a11yPlugin from 'colord/plugins/a11y';
import { _x } from '@wordpress/i18n';
import { useMemo } from '@wordpress/element';
import { store as blocksStore } from '@wordpress/blocks';
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import { unlock } from '../../private-apis';
import { useSelect } from '@wordpress/data';

const { useGlobalSetting } = unlock( blockEditorExperiments );
const { useGlobalSetting } = unlock( blockEditorPrivateApis );

// Enable colord's a11y plugin.
extend( [ a11yPlugin ] );
Expand Down
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/global-styles/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { __, _n, sprintf } from '@wordpress/i18n';
import { shuffle } from '@wordpress/icons';
import { useMemo } from '@wordpress/element';
import { experiments as blockEditorExperiments } from '@wordpress/block-editor';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

/**
* Internal dependencies
Expand All @@ -24,7 +24,7 @@ import { useColorRandomizer } from './hooks';
import ColorIndicatorWrapper from './color-indicator-wrapper';
import { unlock } from '../../private-apis';

const { useGlobalSetting } = unlock( blockEditorExperiments );
const { useGlobalSetting } = unlock( blockEditorPrivateApis );

const EMPTY_COLORS = [];

Expand Down
Loading

0 comments on commit 7fbf73d

Please sign in to comment.