Developer Integration API - #67
Conversation
|
Warning Review limit reachedNext included review available in 20 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughCimo adds a guarded asset-enqueue helper, a ChangesDeveloper integration
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Integrator
participant window.cimo.optimizeFiles
participant optimizeFileConverters
participant UploadControl
Integrator->>window.cimo.optimizeFiles: provide files before upload
window.cimo.optimizeFiles->>optimizeFileConverters: resolve converters and optimize
optimizeFileConverters-->>window.cimo.optimizeFiles: return optimized files and metadata
window.cimo.optimizeFiles-->>Integrator: return results
Integrator->>UploadControl: upload result files
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The integration API, asset loading, selector interception, optimization fallback, progress handling, and metadata sequencing are consistent with the documented behavior. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🤖 Pull request artifacts
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@DEVELOPER.md`:
- Around line 12-16: Update the documentation around the cimo_enqueue_assets
example to explicitly require registering selector filters before enqueueing
Cimo assets. Ensure the documented order places all selector filter registration
ahead of the wp_enqueue_scripts hook that calls cimo_enqueue_assets(), so
localized selectors use the custom values.
- Around line 24-28: Update the optimizeFiles example in DEVELOPER.md to wrap
the await and subsequent filesToUpload mapping in an async function, preserving
the existing behavior and making the snippet valid in a classic script.
In `@src/admin/js/public-api.js`:
- Around line 5-7: Update the comment above the public optimizeFiles assignment
to document that the API returns an array of objects shaped as {file, metadata},
with file as a File and metadata possibly null, rather than raw File objects.
Keep the window.cimo.optimizeFiles assignment unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b5658e52-1162-41c3-9c0c-12918c9f32c5
📒 Files selected for processing (9)
DEVELOPER.mdcimo.phpsrc/admin/class-script-loader.phpsrc/admin/js/index.jssrc/admin/js/media-manager/allowed-locations.jssrc/admin/js/media-manager/drop-zone.jssrc/admin/js/media-manager/select-files.jssrc/admin/js/optimize-files.jssrc/admin/js/public-api.js
Rewrite DEVELOPER.md as enqueue-first steps and point wordpress.org readme visitors to the public guide.
Bring in the Playwright e2e harness so developer API coverage can land on this branch.
Verify frontend enqueue, PHP selector interception, and window.cimo.optimizeFiles so third-party upload hooks stay intact.
fixes #65
Adds developer integration support for Cimo pre-upload optimization.
window.cimo.optimizeFiles(files, { showProgress })so plugins/themes can optimizeFile/FileListobjects before running their own upload flow.Behavior
How To Test
1. Test Frontend Enqueue
In a custom PHP plugin, enqueue Cimo assets on a frontend page:
Visit the frontend page and run this in the browser console:
Expected:
window.cimoSettingsis available.window.cimois available.window.cimo.optimizeFilesis a function.2. Test PHP Selector Filters
In the custom PHP plugin, add selector locations:
Visit the frontend page and run:
Expected:
window.cimoSettings.selectFilesAllowedLocationsincludes.my-plugin-uploader.window.cimoSettings.dropZoneAllowedLocationsincludes.my-plugin-dropzone.3. Test Automatic File Input Interception
Add this Custom HTML to the frontend page:
Select an image from the input.
Expected:
.my-plugin-uploaderwas added through the PHP filter.webp.4. Test
window.cimo.optimizeFilesRun this in the frontend browser console:
Expected:
resultsis an array of{ file, metadata }.results.map(result => result.file).Summary by CodeRabbit
New Features
Documentation