fix: Move HandlePlatformFileDrop to window._wails internal API#4616
Conversation
Fixes #4489 ## Problem The npm package @wailsio/runtime doesn't work for drag-and-drop because Go backend calls window.wails.Window.HandlePlatformFileDrop(), but the npm package doesn't populate window.wails (by design for encapsulation). ## Root Cause PR #3295 (March 2024) intentionally removed window.wails assignment from the npm package to improve encapsulation. However, this broke platform handlers that Go backend relies on. ## Solution Move HandlePlatformFileDrop from public API (window.wails) to internal API (window._wails), following the existing pattern: - window._wails.invoke - window._wails.environment - window._wails.flags ## Changes - Register handlePlatformFileDrop in window._wails namespace - Update Go backend to call window._wails.handlePlatformFileDrop() - Use camelCase naming for consistency with other internal API methods - Rebuild bundled runtime with changes ## Benefits ✅ npm package works without window.wails pollution ✅ Maintains encapsulation of public API ✅ Platform handlers clearly separated as internal ✅ Follows existing internal API conventions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Rate limit exceeded@leaanthony has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 25 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughUpdates internal runtime exports, binds a platform file-drop handler to window._wails.handlePlatformFileDrop, and redirects the Go-side invocation to the new global. Adjusts mapped symbols for CancelError, CancellablePromise, and Window in the bundled runtime. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant OS as OS/Platform (Drop)
participant WV as WebView Window (Go)
participant JS as Frontend JS (window._wails)
participant RT as Runtime Window Handler
OS->>WV: File(s) dropped
WV->>JS: window._wails.handlePlatformFileDrop(files)
JS->>RT: Invoke bound Window.HandlePlatformFileDrop(files)
RT-->>WV: Process/dispatch to Go-side handlers
note over JS,RT: Binding established in runtime src/index.ts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
|
Updates UNRELEASED_CHANGELOG.md with the fix for #4489. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
…app#4616) * fix: Move HandlePlatformFileDrop to window._wails internal API Fixes wailsapp#4489 ## Problem The npm package @wailsio/runtime doesn't work for drag-and-drop because Go backend calls window.wails.Window.HandlePlatformFileDrop(), but the npm package doesn't populate window.wails (by design for encapsulation). ## Root Cause PR wailsapp#3295 (March 2024) intentionally removed window.wails assignment from the npm package to improve encapsulation. However, this broke platform handlers that Go backend relies on. ## Solution Move HandlePlatformFileDrop from public API (window.wails) to internal API (window._wails), following the existing pattern: - window._wails.invoke - window._wails.environment - window._wails.flags ## Changes - Register handlePlatformFileDrop in window._wails namespace - Update Go backend to call window._wails.handlePlatformFileDrop() - Use camelCase naming for consistency with other internal API methods - Rebuild bundled runtime with changes ## Benefits ✅ npm package works without window.wails pollution ✅ Maintains encapsulation of public API ✅ Platform handlers clearly separated as internal ✅ Follows existing internal API conventions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: Add changelog entry for drag-and-drop fix Updates UNRELEASED_CHANGELOG.md with the fix for wailsapp#4489. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>



Summary
Fixes #4489 - Drag-and-drop broken with npm package @wailsio/runtime
The npm package @wailsio/runtime doesn't work for drag-and-drop because the Go backend calls
window.wails.Window.HandlePlatformFileDrop(), but the npm package doesn't populatewindow.wails(by design for encapsulation).Root Cause
PR #3295 (March 2024) intentionally removed
window.wailsassignment from the npm package to improve encapsulation. However, this broke platform handlers that the Go backend relies on.Solution
Move
HandlePlatformFileDropfrom public API (window.wails) to internal API (window._wails), following the existing pattern used by other internal methods:window._wails.invokewindow._wails.environmentwindow._wails.flagsChanges
handlePlatformFileDropinwindow._wailsnamespace (index.ts:61)window._wails.handlePlatformFileDrop()(webview_window.go:1501)Benefits
✅ npm package works without
window.wailspollution✅ Maintains encapsulation of public API
✅ Platform handlers clearly separated as internal
✅ Follows existing internal API conventions
✅ Multi-window support preserved via
.bind()Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit