fix: Move HandlePlatformFileDrop to window._wails internal API (#4616)

* fix: Move HandlePlatformFileDrop to window._wails internal API

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>

* chore: Add changelog entry for drag-and-drop fix

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>

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Lea Anthony 2025-10-02 12:01:53 +10:00 committed by GitHub
commit 6665a3a4b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 11 additions and 4 deletions

View file

@ -23,7 +23,7 @@ After processing, the content will be moved to the main changelog and this file
## Fixed
<!-- Bug fixes -->
- Fix the white window appearing on Windows when creating a hidden window by @leaanthony in [#4612](https://github.com/wailsapp/wails/pull/4612)
- Fix drag-and-drop not working when using npm package @wailsio/runtime (#4489) by @leaanthony in #4616
## Deprecated
<!-- Soon-to-be removed features -->

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -54,4 +54,10 @@ export * from "./cancellable.js";
// Notify backend
window._wails.invoke = System.invoke;
// Register platform handlers (internal API)
// Note: Window is the thisWindow instance (default export from window.ts)
// Binding ensures 'this' correctly refers to the current window instance
window._wails.handlePlatformFileDrop = Window.HandlePlatformFileDrop.bind(Window);
System.invoke("wails:runtime:ready");

View file

@ -1498,7 +1498,7 @@ func (w *WebviewWindow) InitiateFrontendDropProcessing(filenames []string, x int
}
jsCall := fmt.Sprintf(
"window.wails.Window.HandlePlatformFileDrop(%s, %d, %d);",
"window._wails.handlePlatformFileDrop(%s, %d, %d);",
string(filenamesJSON),
x,
y,