Skip to content
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

[experiments] Add README.md and CHANGELOG.md #44457

Merged
merged 8 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/experiments/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. -->

## Unreleased

– Package created.
49 changes: 49 additions & 0 deletions packages/experiments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Experiments

Private `__experimental` APIs that are not [exposed publicly plugin authors](https://make.wordpress.org/core/2022/08/10/proposal-stop-merging-experimental-apis-from-gutenberg-to-wordpress-core/#respond).

This package acts as a "dealer" that only allows WordPress packages to use the experimental APIs.

Each package needs to start by registering itself:

```js
const { register } =
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
'<CONSENT STRING>', // See index.js
adamziel marked this conversation as resolved.
Show resolved Hide resolved
'@wordpress/blocks'
);
```

The function name communicates that plugins are not supposed to use it. To make double and triple sure, the first argument must be that exact consent string, and the second argument must be a known `@wordpress` package that hasn't opted in yet – otherwise an error is thrown.

Expose a new `__experimental` API as follows:

```js
export const __experiments = register( { __unstableGetInnerBlocksProps } )
```

Consume the registered `__experimental` APIs as follows:

```js
// In the @wordpress/block-editor package:
import { __experiments as blocksExperiments } from '@wordpress/blocks';
const { unlock } =
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
'<CONSENT STRING>', // See index.js
'@wordpress/block-editor'
);

const { __unstableGetInnerBlocksProps } = unlock( blocksExperiments );
```

All new experimental APIs should be shipped as **private** using this method.

The **public** experimental APIs that have already been shipped in a stable WordPress version should
remain accessible via `window.wp`. Please do not create new ones.
adamziel marked this conversation as resolved.
Show resolved Hide resolved

A determined developer who would want to use the private experimental APIs at all costs would have to:

* Realize a private importing system exists
* Read the code where the risks would be spelled out in capital letters
* Explicitly type out he or she is aware of the consequences
* Pretend to register a `@wordpress` package (and trigger an error as soon as the real package is loaded)
adamziel marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion packages/experiments/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@wordpress/dependency-injection",
"name": "@wordpress/experiments",
adamziel marked this conversation as resolved.
Show resolved Hide resolved
"version": "0.0.1",
"description": "Dependency Injection container for WordPress.",
adamziel marked this conversation as resolved.
Show resolved Hide resolved
"author": "The WordPress Contributors",
Expand Down