mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
* fix(v3): overhaul drag-and-drop for Linux reliability and simplify Windows This commit fixes drag-and-drop reliability on Linux and simplifies the Windows implementation. ## Linux - Rewrite GTK drag handlers to properly intercept external file drops - Fix HTML5 internal drag-and-drop being broken when file drop enabled - Add hover effects during file drag operations - Fix multiple app instances interfering with each other ## Windows - Remove native IDropTarget in favor of JavaScript approach (matches v2) - File drops now handled via chrome.webview.postMessageWithAdditionalObjects ## All Platforms - Rename EnableDragAndDrop to EnableFileDrop - Rename data-wails-drop-target to data-file-drop-target - Rename wails-drop-target-active to file-drop-target-active - Add comprehensive drag-and-drop documentation ## Breaking Changes - EnableDragAndDrop -> EnableFileDrop - data-wails-dropzone -> data-file-drop-target - wails-dropzone-hover -> file-drop-target-active - DropZoneDetails -> DropTargetDetails - Remove WindowDropZoneFilesDropped event (use WindowFilesDropped) * feat(macos): optimize drag event performance with debouncing and caching - Add 50ms debouncing to limit drag events to 20/sec (was 120/sec) - Implement window implementation caching to avoid repeated lookups - Maintain existing 5-pixel threshold for immediate response - Keep zero-allocation path with pre-allocated buffers - Rename linuxDragActive to nativeDragActive for clarity - Update IMPLEMENTATION.md with optimization details and Windows guidance Performance improvements: - 83% reduction in event frequency - ~6x reduction in CPU/memory usage during drag operations - Maintains smooth visual feedback with InvokeSync for timer callbacks * fix(windows): implement proper file drop support for Windows - Remove incorrect AllowExternalDrag(false) call that was blocking file drops - Fix message prefix from 'FilesDropped' to 'file:drop:' to match JS runtime - Fix coordinate parsing for 'file:drop:x:y' format (indices 2,3 not 1,2) - Add enableFileDrop flag injection to JS runtime during navigation - Update JS runtime to check enableFileDrop flag before processing drops - Always call preventDefault() to stop browser navigation on file drags - Show 'no drop' cursor when file drops are disabled - Update example to filter file drags from HTML drop zone handlers - Add documentation for combining file drop with HTML drag-and-drop * fix(v3): block file drops on Linux when EnableFileDrop is false - Add disableDND() to intercept and reject external file drags at GTK level - Show 'no drop' cursor when files are dragged over window - Allow internal HTML5 drag-and-drop to work normally - Initialize _wails.flags object in runtime core to prevent undefined errors - Inject enableFileDrop flag on Linux and macOS (matching Windows) - Fix bare _wails reference to use window._wails - Update docs with info about blocked drops and combining with HTML DnD * fix(darwin): add missing fmt import in webview_window_darwin.go * fix(macOS): implement hover effects for file drag-and-drop with optimizations - Added draggingUpdated: handler to track mouse movement during drag operations - Implemented macosOnDragEnter/Exit/Over export functions for real-time hover state - Fixed JS function call from '_wails.handlePlatformFileDrop' to correct 'wails.Window.HandlePlatformFileDrop' - Added EnableFileDrop flag checks to prevent hover effects when file drops are disabled - Renamed linuxDragActive to nativeDragActive for cross-platform consistency Performance optimizations: - Added 50ms debounce to reduce event frequency from ~120/sec to ~20/sec - Implemented 5-pixel movement threshold for immediate response - Added window caching with sync.Map to avoid repeated lookups - Zero-allocation JavaScript calls with pre-allocated 128-byte buffer - Reduced memory usage to ~18 bytes per event (6x reduction) Build improvements: - Updated runtime Taskfile to include documentation generation - Added docs:build task to runtime build process - Fixed build order: events → docs → runtime Documentation: - Added IMPLEMENTATION.md with optimization details - Included guidance for Windows implementation * chore(v3/examples): remove html-dnd-api example The drag-n-drop example now demonstrates both external file drops and internal HTML5 drag-and-drop, making this separate example redundant. * docs(v3): move drag-and-drop implementation details to runtime-internals - Add drag-and-drop section to contributing/runtime-internals.mdx - Remove IMPLEMENTATION.md from example (content now in proper docs) - Covers platform differences, debugging tips, and key files * fix(v3): remove html-dnd-api from example build list * fix(v3): remove duplicate json import in application_darwin.go * fix(v3): address CodeRabbit review feedback - Fix docs to use app.Window.NewWithOptions() instead of deprecated API - Add mutex protection to dragOverJSBuffer to prevent race conditions - Add mutex protection to dragThrottleState fields for thread safety * docs: add coderabbit pre-push requirement to AGENTS.md * fix(v3/test): use correct CSS class name file-drop-target-active * chore(v3/test): remove dnd-test directory This was a development test file that shouldn't be in the PR. The drag-n-drop example serves as the proper test case. * docs(v3): update Windows file drop comment to reflect implemented fix Remove stale TODO - enableFileDrop flag is now injected in navigationCompleted * refactor(v3): make handleDragAndDropMessage unexported Internal method only called by application event loop, not part of public API.
369 lines
11 KiB
YAML
369 lines
11 KiB
YAML
# https://taskfile.dev
|
|
|
|
version: "3"
|
|
|
|
includes:
|
|
generator:
|
|
taskfile: ./internal/generator
|
|
dir: ./internal/generator
|
|
|
|
runtime:
|
|
taskfile: ./internal/runtime
|
|
dir: ./internal/runtime
|
|
|
|
website:
|
|
taskfile: ./website
|
|
dir: ./website
|
|
optional: true
|
|
|
|
docs:
|
|
taskfile: ../docs
|
|
dir: ../docs
|
|
optional: true
|
|
|
|
tasks:
|
|
recreate-template-dir:
|
|
dir: internal/templates
|
|
internal: true
|
|
silent: true
|
|
cmds:
|
|
- rm -rf {{.TEMPLATE_DIR}}
|
|
- mkdir -p {{.TEMPLATE_DIR}}
|
|
|
|
install:
|
|
dir: cmd/wails3
|
|
silent: true
|
|
cmds:
|
|
- go install
|
|
- echo "Installed wails CLI"
|
|
|
|
release:
|
|
summary: Release a new version of Wails. Call with `task v3:release -- <version>`
|
|
dir: tasks/release
|
|
cmds:
|
|
- go run release.go {{.CLI_ARGS}}
|
|
|
|
taskfile:upgrade:
|
|
cmds:
|
|
- go get -u github.com/go-task/task/v3
|
|
|
|
reinstall-cli:
|
|
dir: cmd/wails3
|
|
internal: true
|
|
silent: true
|
|
cmds:
|
|
- go install
|
|
- echo "Reinstalled wails CLI"
|
|
|
|
generate:events:
|
|
dir: tasks/events
|
|
cmds:
|
|
- go run generate.go
|
|
- go fmt ../../pkg/events/events.go
|
|
|
|
precommit:
|
|
cmds:
|
|
- go test ./...
|
|
- task: format
|
|
# - task: docs:update:api
|
|
|
|
test:example:darwin:
|
|
dir: 'examples/{{.DIR}}'
|
|
platforms:
|
|
- darwin
|
|
cmds:
|
|
- echo "Building example {{.DIR}} for Darwin"
|
|
- go mod tidy
|
|
- go build -o "testbuild-{{.DIR}}-darwin{{exeExt}}"
|
|
env:
|
|
CGO_LDFLAGS: -framework UniformTypeIdentifiers -mmacosx-version-min=10.13
|
|
CGO_CFLAGS: -mmacosx-version-min=10.13
|
|
|
|
test:example:windows:
|
|
dir: 'examples/{{.DIR}}'
|
|
platforms:
|
|
- windows
|
|
cmds:
|
|
- echo "Building example {{.DIR}} for Windows"
|
|
- go mod tidy
|
|
- go build -o "testbuild-{{.DIR}}-windows.exe"
|
|
env:
|
|
GOOS: windows
|
|
GOARCH: amd64
|
|
|
|
test:example:linux:
|
|
dir: 'examples/{{.DIR}}'
|
|
platforms:
|
|
- linux
|
|
cmds:
|
|
- echo "Building example {{.DIR}} for Linux"
|
|
- go mod tidy
|
|
- go build -o "testbuild-{{.DIR}}-linux"
|
|
|
|
test:example:linux:docker:arm64:
|
|
summary: Build a single example for Linux ARM64 using Docker (Ubuntu 24.04)
|
|
cmds:
|
|
- echo "Building example {{.DIR}} for Linux ARM64 using Docker"
|
|
- docker build --pull -f test/docker/Dockerfile.linux-arm64 -t wails-v3-linux-arm64 .
|
|
- docker run --rm wails-v3-linux-arm64 /build/build-linux-arm64.sh {{.DIR}}
|
|
|
|
test:example:linux:docker:x86_64:
|
|
summary: Build a single example for Linux x86_64 using Docker (Ubuntu 24.04)
|
|
cmds:
|
|
- echo "Building example {{.DIR}} for Linux x86_64 using Docker"
|
|
- docker build --pull -f test/docker/Dockerfile.linux-x86_64 -t wails-v3-linux-x86_64 .
|
|
- docker run --rm wails-v3-linux-x86_64 /build/build-linux-x86_64.sh {{.DIR}}
|
|
|
|
test:examples:linux:docker:arm64:
|
|
summary: Build all examples for Linux ARM64 using Docker (Ubuntu 24.04)
|
|
cmds:
|
|
- echo "Building Docker image for Linux ARM64 compilation..."
|
|
- docker build --pull -f test/docker/Dockerfile.linux-arm64 -t wails-v3-linux-arm64 .
|
|
- echo "Running Linux ARM64 compilation in Docker container..."
|
|
- docker run --rm wails-v3-linux-arm64
|
|
|
|
test:examples:linux:docker:x86_64:
|
|
summary: Build all examples for Linux x86_64 using Docker (Ubuntu 24.04)
|
|
cmds:
|
|
- echo "Building Docker image for Linux x86_64 compilation..."
|
|
- docker build --pull -f test/docker/Dockerfile.linux-x86_64 -t wails-v3-linux-x86_64 .
|
|
- echo "Running Linux x86_64 compilation in Docker container..."
|
|
- docker run --rm wails-v3-linux-x86_64
|
|
|
|
test:example:linux:docker:
|
|
summary: Build a single example for Linux using Docker (auto-detect architecture)
|
|
cmds:
|
|
- echo "Auto-detecting architecture for Linux Docker build..."
|
|
- |
|
|
if [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then
|
|
echo "Detected ARM64, using ARM64 Docker image"
|
|
task test:example:linux:docker:arm64 DIR={{.DIR}}
|
|
else
|
|
echo "Detected x86_64, using x86_64 Docker image"
|
|
task test:example:linux:docker:x86_64 DIR={{.DIR}}
|
|
fi
|
|
|
|
test:examples:linux:docker:
|
|
summary: Build all examples for Linux using Docker (auto-detect architecture)
|
|
cmds:
|
|
- echo "Auto-detecting architecture for Linux Docker build..."
|
|
- |
|
|
if [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then
|
|
echo "Detected ARM64, using ARM64 Docker image"
|
|
task test:examples:linux:docker:arm64
|
|
else
|
|
echo "Detected x86_64, using x86_64 Docker image"
|
|
task test:examples:linux:docker:x86_64
|
|
fi
|
|
|
|
test:examples:all:
|
|
summary: Builds all examples for all platforms (Mac + Windows + Linux via Docker)
|
|
vars:
|
|
EXAMPLEDIRS: |
|
|
badge
|
|
badge-custom
|
|
binding
|
|
build
|
|
cancel-async
|
|
cancel-chaining
|
|
clipboard
|
|
contextmenus
|
|
dev
|
|
dialogs
|
|
dialogs-basic
|
|
drag-n-drop
|
|
environment
|
|
events
|
|
events-bug
|
|
file-association
|
|
frameless
|
|
gin-example
|
|
gin-routing
|
|
gin-service
|
|
hide-window
|
|
ignore-mouse
|
|
keybindings
|
|
liquid-glass
|
|
menu
|
|
notifications
|
|
panic-handling
|
|
plain
|
|
raw-message
|
|
screen
|
|
services
|
|
show-macos-toolbar
|
|
single-instance
|
|
systray-basic
|
|
systray-custom
|
|
systray-menu
|
|
video
|
|
window
|
|
window-api
|
|
window-call
|
|
window-menu
|
|
wml
|
|
cmds:
|
|
- echo "Building all examples for all platforms..."
|
|
- echo "=== Building for Darwin ==="
|
|
- for: { var: EXAMPLEDIRS }
|
|
task: test:example:darwin
|
|
vars:
|
|
DIR: "{{.ITEM}}"
|
|
- echo "=== Building for Windows (cross-compile) ==="
|
|
- for: { var: EXAMPLEDIRS }
|
|
task: test:example:windows
|
|
vars:
|
|
DIR: "{{.ITEM}}"
|
|
- echo "=== Building for Linux (Docker) ==="
|
|
- task: test:examples:linux:docker
|
|
- echo "=== Testing CLI Code ==="
|
|
- task: test:cli
|
|
- echo "=== Cleaning Up Test Binaries ==="
|
|
- task: clean:test:binaries
|
|
|
|
test:cli:
|
|
summary: Test CLI-related code compilation
|
|
cmds:
|
|
- echo "Testing CLI appimage testfiles compilation..."
|
|
- cd internal/commands/appimage_testfiles && go mod tidy && go build
|
|
- echo "✅ CLI appimage testfiles compile successfully"
|
|
|
|
test:cli:all:
|
|
summary: Test all CLI components and critical test files
|
|
cmds:
|
|
- echo "Testing CLI appimage testfiles..."
|
|
- cd internal/commands/appimage_testfiles && go mod tidy && go build
|
|
- echo "Testing window visibility test..."
|
|
- cd tests/window-visibility-test && go mod tidy && go build
|
|
- echo "Testing service implementations..."
|
|
- cd pkg/services/badge && go build
|
|
- echo "✅ All CLI components compile successfully"
|
|
|
|
test:generator:
|
|
summary: Test code generator test cases compilation
|
|
cmds:
|
|
- echo "Testing generator test cases (sample)..."
|
|
- cd internal/generator/testcases/function_single && go mod tidy && go build
|
|
- cd internal/generator/testcases/complex_method && go mod tidy && go build
|
|
- cd internal/generator/testcases/struct_literal_single && go mod tidy && go build
|
|
- echo "✅ Generator test cases compile successfully"
|
|
|
|
test:templates:
|
|
summary: Test template generation for core templates
|
|
cmds:
|
|
- echo "Testing template generation (core templates)..."
|
|
- task: install
|
|
- echo "Testing lit template generation..."
|
|
- rm -rf ./test-template-lit && wails3 init -n test-template-lit -t lit
|
|
- mkdir -p ./test-template-lit/frontend/dist && touch ./test-template-lit/frontend/dist/.keep
|
|
- cd ./test-template-lit && go mod tidy && go build
|
|
- rm -rf ./test-template-lit
|
|
- echo "Testing react template generation..."
|
|
- rm -rf ./test-template-react && wails3 init -n test-template-react -t react
|
|
- mkdir -p ./test-template-react/frontend/dist && touch ./test-template-react/frontend/dist/.keep
|
|
- cd ./test-template-react && go mod tidy && go build
|
|
- rm -rf ./test-template-react
|
|
- echo "✅ Template generation tests completed successfully"
|
|
|
|
test:infrastructure:
|
|
summary: Test critical infrastructure components
|
|
cmds:
|
|
- echo "=== Testing CLI Components ==="
|
|
- task: test:cli:all
|
|
- echo "=== Testing Generator ==="
|
|
- task: test:generator
|
|
- echo "=== Testing Templates ==="
|
|
- task: test:templates
|
|
- echo "=== Testing pkg/application ==="
|
|
- cd pkg/application && go test -c -o /dev/null ./...
|
|
- echo "=== Cleaning Up Test Binaries ==="
|
|
- task: clean:test:binaries
|
|
- echo "✅ All infrastructure components test successfully"
|
|
|
|
test:examples:
|
|
summary: Builds the examples for current platform only
|
|
vars:
|
|
EXAMPLEDIRS: |
|
|
badge
|
|
badge-custom
|
|
binding
|
|
build
|
|
cancel-async
|
|
cancel-chaining
|
|
clipboard
|
|
contextmenus
|
|
dev
|
|
dialogs
|
|
dialogs-basic
|
|
drag-n-drop
|
|
environment
|
|
events
|
|
events-bug
|
|
file-association
|
|
frameless
|
|
gin-example
|
|
gin-routing
|
|
gin-service
|
|
hide-window
|
|
ignore-mouse
|
|
keybindings
|
|
liquid-glass
|
|
menu
|
|
notifications
|
|
panic-handling
|
|
plain
|
|
raw-message
|
|
screen
|
|
services
|
|
show-macos-toolbar
|
|
single-instance
|
|
systray-basic
|
|
systray-custom
|
|
systray-menu
|
|
video
|
|
window
|
|
window-api
|
|
window-call
|
|
window-menu
|
|
wml
|
|
cmds:
|
|
- echo "Testing examples compilation..."
|
|
- for: { var: EXAMPLEDIRS }
|
|
task: test:example:darwin
|
|
vars:
|
|
DIR: "{{.ITEM}}"
|
|
platforms: [darwin]
|
|
- for: { var: EXAMPLEDIRS }
|
|
task: test:example:linux
|
|
vars:
|
|
DIR: "{{.ITEM}}"
|
|
platforms: [linux]
|
|
- for: { var: EXAMPLEDIRS }
|
|
task: test:example:windows
|
|
vars:
|
|
DIR: "{{.ITEM}}"
|
|
platforms: [windows]
|
|
- echo "Testing CLI code..."
|
|
- task: test:cli
|
|
- echo "=== Cleaning Up Test Binaries ==="
|
|
- task: clean:test:binaries
|
|
|
|
clean:test:binaries:
|
|
summary: Clean up all test-generated binary files and directories (cross-platform)
|
|
cmds:
|
|
- echo "🧹 Cleaning up test binaries..."
|
|
- go run tasks/cleanup/cleanup.go
|
|
- echo "✅ Test binaries cleaned up"
|
|
|
|
test:all:
|
|
summary: Run all tests including examples, infrastructure, and Go unit tests
|
|
cmds:
|
|
- echo "=== Running Go Unit Tests ==="
|
|
- go test ./...
|
|
- echo "=== Testing Examples (Current Platform) ==="
|
|
- task: test:examples
|
|
- echo "=== Testing Infrastructure Components ==="
|
|
- task: test:infrastructure
|
|
- echo "=== Cleaning Up Test Binaries ==="
|
|
- task: clean:test:binaries
|
|
- echo "✅ All tests completed successfully"
|