Repository navigation
Conversation
Packages that are allowed to use private APIs could not use the cropper, its state hook or the crop helpers, because the private API object only carried the store, the editor and its modal. This adds the cropper component, `useCropperController`, `getSourceRegion`, `getSourceRegionPercent` and `buildModifiers` to that object. The public exports do not change, and a small test pins them. The image editor README and the comment at the top of its barrel file still called the module internal or a public contract, so both now describe the private API.
The comment listed three of the four things the private API takes from the image editor and left out how `buildModifiers` reaches it. It now says only that a small part of the module is available outside the package, and points at `private-apis.ts` for the list.
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. 📦 Bundle sizeSize Change: +355 B (0%) Total Size: 8.58 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in
|
The README and the comment at the top of the image editor's main file used "barrel", a word many readers will not know. Both now say what the file is. Only wording changes.
|
Closing this. I don't think it's a good idea to expose a private API from media-editor only to change the package source later with it's public. For the record we want a separate package as media-editor comes with a lot of baggage, e.g., dataviews etc |
What?
See #86145. Stacked on #86147: until that PR merges, this PR is based on its branch so the diff shows only this change.
Makes the image editor's cropper available to other packages through the media editor's private API: the
Croppercomponent,useCropperController,getSourceRegion,getSourceRegionPercentandbuildModifiers.Why?
This is the second small step of #86145: export the cropper privately first, so real use can shape the API before it becomes a public promise. Today the private API object only carries the store, the editor and its modal, so a package that wants only the cropper, such as the media library or the site icon screen, cannot use it.
How?
The five items are added to the object that
private-apis.tsalready locks. Nothing is added to the public exports, and a small test pins them. The image editor README now says the module is private and shows how a package that is allowed to use private APIs can unlock the new items. The README and the comment at the top of the image editor's main file no longer describe the module as internal or public.There is no changelog entry, since this only touches the private API and does not change the public interface. Say if reviewers want one.
Testing Instructions
npm run test:unit -- packages/media-editor. It should pass, including the new check on the public exports.Checked with the unit tests, lint, the docs lint and the typecheck. Not yet tried in a browser, and the README example was written against the code but not run.