diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 84b7cb6dc..9faf71704 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -70,7 +70,7 @@ body: validations: required: false - type: textarea - id: systemetails + id: systemdetails attributes: label: System Details description: Please add the output of `wails doctor`. diff --git a/.github/workflows/build-cross-image.yml b/.github/workflows/build-cross-image.yml new file mode 100644 index 000000000..83b40f2be --- /dev/null +++ b/.github/workflows/build-cross-image.yml @@ -0,0 +1,423 @@ +name: Build Cross-Compiler Image + +on: + workflow_dispatch: + inputs: + branch: + description: 'Branch containing Dockerfile' + required: true + default: 'v3-alpha' + sdk_version: + description: 'macOS SDK version' + required: true + default: '14.5' + zig_version: + description: 'Zig version' + required: true + default: '0.14.0' + image_version: + description: 'Image version tag' + required: true + default: 'latest' + skip_tests: + description: 'Skip cross-compilation tests' + required: false + default: 'false' + type: boolean + push: + branches: + - v3-alpha + paths: + - 'v3/internal/commands/build_assets/docker/Dockerfile.cross' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: wailsapp/wails-cross + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + outputs: + image_tag: ${{ steps.vars.outputs.image_version }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch || github.ref }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set build variables + id: vars + run: | + echo "sdk_version=${{ inputs.sdk_version || '14.5' }}" >> $GITHUB_OUTPUT + echo "zig_version=${{ inputs.zig_version || '0.14.0' }}" >> $GITHUB_OUTPUT + echo "image_version=${{ inputs.image_version || 'latest' }}" >> $GITHUB_OUTPUT + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest + type=raw,value=${{ steps.vars.outputs.image_version }} + type=raw,value=sdk-${{ steps.vars.outputs.sdk_version }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: v3/internal/commands/build_assets/docker + file: v3/internal/commands/build_assets/docker/Dockerfile.cross + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: | + ${{ steps.meta.outputs.labels }} + io.wails.zig.version=${{ steps.vars.outputs.zig_version }} + io.wails.sdk.version=${{ steps.vars.outputs.sdk_version }} + build-args: | + ZIG_VERSION=${{ steps.vars.outputs.zig_version }} + MACOS_SDK_VERSION=${{ steps.vars.outputs.sdk_version }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Test cross-compilation for all platforms + test-cross-compile: + needs: build + if: ${{ inputs.skip_tests != 'true' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + # Darwin targets (Zig + macOS SDK) - no platform emulation needed + - os: darwin + arch: arm64 + platform: "" + expected_file: "Mach-O 64-bit.*arm64" + - os: darwin + arch: amd64 + platform: "" + expected_file: "Mach-O 64-bit.*x86_64" + # Linux targets (GCC) - need platform to match architecture + - os: linux + arch: amd64 + platform: "linux/amd64" + expected_file: "ELF 64-bit LSB.*x86-64" + - os: linux + arch: arm64 + platform: "linux/arm64" + expected_file: "ELF 64-bit LSB.*ARM aarch64" + # Windows targets (Zig + mingw) - no platform emulation needed + - os: windows + arch: amd64 + platform: "" + expected_file: "PE32\\+ executable.*x86-64" + - os: windows + arch: arm64 + platform: "" + expected_file: "PE32\\+ executable.*Aarch64" + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch || github.ref }} + + - name: Set up QEMU + if: matrix.platform != '' + uses: docker/setup-qemu-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create test CGO project + run: | + mkdir -p test-project + cd test-project + + # Create a minimal CGO test program + cat > main.go << 'EOF' + package main + + /* + #include + + int add(int a, int b) { + return a + b; + } + */ + import "C" + import "fmt" + + func main() { + result := C.add(1, 2) + fmt.Printf("CGO test: 1 + 2 = %d\n", result) + } + EOF + + cat > go.mod << 'EOF' + module test-cgo + + go 1.21 + EOF + + - name: Build ${{ matrix.os }}/${{ matrix.arch }} (CGO) + run: | + cd test-project + PLATFORM_FLAG="" + if [ -n "${{ matrix.platform }}" ]; then + PLATFORM_FLAG="--platform ${{ matrix.platform }}" + fi + + docker run --rm $PLATFORM_FLAG \ + -v "$(pwd):/app" \ + -e APP_NAME="test-cgo" \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.image_tag || 'latest' }} \ + ${{ matrix.os }} ${{ matrix.arch }} + + - name: Verify binary format + run: | + cd test-project/bin + ls -la + + # Find the built binary + if [ "${{ matrix.os }}" = "windows" ]; then + BINARY=$(ls test-cgo-${{ matrix.os }}-${{ matrix.arch }}.exe 2>/dev/null || ls *.exe | head -1) + else + BINARY=$(ls test-cgo-${{ matrix.os }}-${{ matrix.arch }} 2>/dev/null || ls test-cgo* | grep -v '.exe' | head -1) + fi + + echo "Binary: $BINARY" + FILE_OUTPUT=$(file "$BINARY") + echo "File output: $FILE_OUTPUT" + + # Verify the binary format matches expected + if echo "$FILE_OUTPUT" | grep -qE "${{ matrix.expected_file }}"; then + echo "✅ Binary format verified: ${{ matrix.os }}/${{ matrix.arch }}" + else + echo "❌ Binary format mismatch!" + echo "Expected pattern: ${{ matrix.expected_file }}" + echo "Got: $FILE_OUTPUT" + exit 1 + fi + + - name: Check library dependencies (Linux only) + if: matrix.os == 'linux' + run: | + cd test-project/bin + BINARY=$(ls test-cgo-${{ matrix.os }}-${{ matrix.arch }} 2>/dev/null || ls test-cgo* | grep -v '.exe' | head -1) + + echo "## Library Dependencies for $BINARY" + echo "" + + # Use readelf to show dynamic dependencies + echo "### NEEDED libraries:" + readelf -d "$BINARY" | grep NEEDED || echo "No dynamic dependencies (statically linked)" + + # Verify expected libraries are linked + echo "" + echo "### Verifying required libraries..." + NEEDED=$(readelf -d "$BINARY" | grep NEEDED) + + MISSING="" + for lib in libwebkit2gtk-4.1.so libgtk-3.so libglib-2.0.so libc.so; do + if echo "$NEEDED" | grep -q "$lib"; then + echo "✅ $lib" + else + echo "❌ $lib MISSING" + MISSING="$MISSING $lib" + fi + done + + if [ -n "$MISSING" ]; then + echo "" + echo "ERROR: Missing required libraries:$MISSING" + exit 1 + fi + + # Test non-CGO builds (pure Go cross-compilation) + test-non-cgo: + needs: build + if: ${{ inputs.skip_tests != 'true' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - os: darwin + arch: arm64 + expected_file: "Mach-O 64-bit.*arm64" + - os: darwin + arch: amd64 + expected_file: "Mach-O 64-bit.*x86_64" + - os: linux + arch: amd64 + expected_file: "ELF 64-bit LSB" + - os: linux + arch: arm64 + expected_file: "ELF 64-bit LSB.*ARM aarch64" + - os: windows + arch: amd64 + expected_file: "PE32\\+ executable.*x86-64" + - os: windows + arch: arm64 + expected_file: "PE32\\+ executable.*Aarch64" + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch || github.ref }} + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create test non-CGO project + run: | + mkdir -p test-project + cd test-project + + # Create a pure Go test program (no CGO) + cat > main.go << 'EOF' + package main + + import "fmt" + + func main() { + fmt.Println("Pure Go cross-compilation test") + } + EOF + + cat > go.mod << 'EOF' + module test-pure-go + + go 1.21 + EOF + + - name: Build ${{ matrix.os }}/${{ matrix.arch }} (non-CGO) + run: | + cd test-project + + # For non-CGO, we can use any platform since Go handles cross-compilation + # We set CGO_ENABLED=0 to ensure pure Go build + docker run --rm \ + -v "$(pwd):/app" \ + -e APP_NAME="test-pure-go" \ + -e CGO_ENABLED=0 \ + --entrypoint /bin/sh \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.image_tag || 'latest' }} \ + -c "GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o bin/test-pure-go-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.os == 'windows' && '.exe' || '' }} ." + + - name: Verify binary format + run: | + cd test-project/bin + ls -la + + # Find the built binary + if [ "${{ matrix.os }}" = "windows" ]; then + BINARY="test-pure-go-${{ matrix.os }}-${{ matrix.arch }}.exe" + else + BINARY="test-pure-go-${{ matrix.os }}-${{ matrix.arch }}" + fi + + echo "Binary: $BINARY" + FILE_OUTPUT=$(file "$BINARY") + echo "File output: $FILE_OUTPUT" + + # Verify the binary format matches expected + if echo "$FILE_OUTPUT" | grep -qE "${{ matrix.expected_file }}"; then + echo "✅ Binary format verified: ${{ matrix.os }}/${{ matrix.arch }} (non-CGO)" + else + echo "❌ Binary format mismatch!" + echo "Expected pattern: ${{ matrix.expected_file }}" + echo "Got: $FILE_OUTPUT" + exit 1 + fi + + - name: Check library dependencies (Linux only) + if: matrix.os == 'linux' + run: | + cd test-project/bin + BINARY="test-pure-go-${{ matrix.os }}-${{ matrix.arch }}" + + echo "## Library Dependencies for $BINARY (non-CGO)" + echo "" + + # Non-CGO builds should have minimal dependencies (just libc or statically linked) + echo "### NEEDED libraries:" + readelf -d "$BINARY" | grep NEEDED || echo "No dynamic dependencies (statically linked)" + + # Verify NO GTK/WebKit libraries (since CGO is disabled) + NEEDED=$(readelf -d "$BINARY" | grep NEEDED || true) + if echo "$NEEDED" | grep -q "libwebkit\|libgtk"; then + echo "❌ ERROR: Non-CGO binary should not link to GTK/WebKit!" + exit 1 + else + echo "✅ Confirmed: No GTK/WebKit dependencies (expected for non-CGO)" + fi + + # Summary job + test-summary: + needs: [build, test-cross-compile, test-non-cgo] + if: always() && inputs.skip_tests != 'true' + runs-on: ubuntu-latest + steps: + - name: Check test results + run: | + echo "## Cross-Compilation Test Results" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + if [ "${{ needs.test-cross-compile.result }}" = "success" ]; then + echo "✅ **CGO Tests**: All passed" >> $GITHUB_STEP_SUMMARY + else + echo "❌ **CGO Tests**: Failed" >> $GITHUB_STEP_SUMMARY + fi + + if [ "${{ needs.test-non-cgo.result }}" = "success" ]; then + echo "✅ **Non-CGO Tests**: All passed" >> $GITHUB_STEP_SUMMARY + else + echo "❌ **Non-CGO Tests**: Failed" >> $GITHUB_STEP_SUMMARY + fi + + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Tested Platforms" >> $GITHUB_STEP_SUMMARY + echo "| Platform | Architecture | CGO | Non-CGO |" >> $GITHUB_STEP_SUMMARY + echo "|----------|-------------|-----|---------|" >> $GITHUB_STEP_SUMMARY + echo "| Darwin | arm64 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| Darwin | amd64 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| Linux | arm64 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| Linux | amd64 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| Windows | arm64 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY + echo "| Windows | amd64 | ✅ | ✅ |" >> $GITHUB_STEP_SUMMARY + + # Fail if any test failed + if [ "${{ needs.test-cross-compile.result }}" != "success" ] || [ "${{ needs.test-non-cgo.result }}" != "success" ]; then + echo "" + echo "❌ Some tests failed. Check the individual job logs for details." + exit 1 + fi diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml new file mode 100644 index 000000000..b5e8cfd4d --- /dev/null +++ b/.github/workflows/claude-code-review.yml @@ -0,0 +1,44 @@ +name: Claude Code Review + +on: + pull_request: + types: [opened, synchronize, ready_for_review, reopened] + # Optional: Only run on specific file changes + # paths: + # - "src/**/*.ts" + # - "src/**/*.tsx" + # - "src/**/*.js" + # - "src/**/*.jsx" + +jobs: + claude-review: + # Optional: Filter by PR author + # if: | + # github.event.pull_request.user.login == 'external-contributor' || + # github.event.pull_request.user.login == 'new-developer' || + # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' + + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code Review + id: claude-review + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + plugin_marketplaces: 'https://github.com/anthropics/claude-code.git' + plugins: 'code-review@claude-code-plugins' + prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}' + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://code.claude.com/docs/en/cli-reference for available options + diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 000000000..d300267f1 --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,50 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] + +jobs: + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + issues: read + id-token: write + actions: read # Required for Claude to read CI results on PRs + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Run Claude Code + id: claude + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + + # This is an optional setting that allows Claude to read CI results on PRs + additional_permissions: | + actions: read + + # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. + # prompt: 'Update the pull request description to include a summary of changes.' + + # Optional: Add claude_args to customize behavior and configuration + # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md + # or https://code.claude.com/docs/en/cli-reference for available options + # claude_args: '--allowed-tools Bash(gh pr:*)' + diff --git a/.github/workflows/nightly-release-v3.yml b/.github/workflows/nightly-release-v3.yml index 2a7530917..ae56ba7bc 100644 --- a/.github/workflows/nightly-release-v3.yml +++ b/.github/workflows/nightly-release-v3.yml @@ -1,4 +1,3 @@ - name: Nightly Release v3-alpha on: @@ -35,9 +34,10 @@ jobs: token: ${{ secrets.WAILS_REPO_TOKEN || github.token }} - name: Setup Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v4 with: - go-version: '1.23' + go-version: '1.24' + cache: true cache-dependency-path: 'v3/go.sum' - name: Install Task @@ -46,20 +46,6 @@ jobs: version: 3.x repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Verify Go and Task installation - run: | - echo "Go version:" - go version - echo "" - echo "Task version:" - task --version - echo "" - echo "Working directory:" - pwd - echo "" - echo "v3 directory contents:" - ls -la v3/ - - name: Setup Git run: | git config --global user.name "github-actions[bot]" @@ -84,24 +70,16 @@ jobs: run: | echo "🔍 Checking UNRELEASED_CHANGELOG.md for content..." - # Check if the file exists and has content - if [ -f "v3/UNRELEASED_CHANGELOG.md" ]; then - echo "Found v3/UNRELEASED_CHANGELOG.md" - - # Run the release script in check mode to see if there's content - cd v3/tasks/release - - # Use the release script itself to check for content - if go run release.go --check-only 2>/dev/null; then - echo "has_unreleased_content=true" >> $GITHUB_OUTPUT - echo "✅ Found unreleased changelog content" - else - echo "has_unreleased_content=false" >> $GITHUB_OUTPUT - echo "ℹ️ No unreleased changelog content found" - fi + # Run the release script in check mode to see if there's content + cd v3/tasks/release + + # Use the release script itself to check for content + if go run release.go --check-only 2>/dev/null; then + echo "has_unreleased_content=true" >> $GITHUB_OUTPUT + echo "✅ Found unreleased changelog content" else - echo "⚠️ v3/UNRELEASED_CHANGELOG.md not found" echo "has_unreleased_content=false" >> $GITHUB_OUTPUT + echo "ℹ️ No unreleased changelog content found" fi - name: Quick change detection and early exit @@ -185,579 +163,48 @@ jobs: echo "🔨 FORCE RELEASE: Overriding change detection" fi - - name: Extract changelog content before release - id: extract_changelog - if: | - steps.quick_check.outputs.should_continue == 'true' || - github.event.inputs.force_release == 'true' - run: | - cd v3 - - echo "📝 Extracting changelog content before release..." - - # Use the new --create-release-notes flag - cd tasks/release - if go run release.go --create-release-notes ../../release_notes.md; then - echo "✅ Successfully created release notes" - echo "has_content=true" >> $GITHUB_OUTPUT - - # Show content preview - echo "Release notes preview:" - head -10 ../../release_notes.md - else - echo "⚠️ Failed to create release notes or no content found" - echo "No changelog updates in this release." > ../../release_notes.md - echo "has_content=false" >> $GITHUB_OUTPUT - fi - cd ../.. - - name: Run release script id: release if: | steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true' + env: + WAILS_REPO_TOKEN: ${{ secrets.WAILS_REPO_TOKEN || github.token }} + GITHUB_TOKEN: ${{ secrets.WAILS_REPO_TOKEN || github.token }} run: | - cd v3 - - echo "🚀 Running release task..." - echo "=======================================================" - - # Initialize error tracking - RELEASE_ERRORS="" - RELEASE_SUCCESS=true - - # Store the original version for comparison - ORIGINAL_VERSION=$(cat internal/version/version.txt 2>/dev/null || echo "unknown") - echo "📌 Current version: $ORIGINAL_VERSION" - - # Run the release task and capture output with error handling + cd v3/tasks/release + ARGS=() if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then - echo "🧪 DRY RUN MODE: Simulating release task execution" - # In dry run, we'll simulate the task without making actual changes - OUTPUT=$(task release 2>&1 || true) - RELEASE_EXIT_CODE=0 # Always succeed in dry run - echo "$OUTPUT" - else - echo "🚀 LIVE MODE: Executing release task" - OUTPUT=$(task release 2>&1) - RELEASE_EXIT_CODE=$? - echo "$OUTPUT" - - if [ $RELEASE_EXIT_CODE -ne 0 ]; then - echo "❌ Release task failed with exit code $RELEASE_EXIT_CODE" - RELEASE_ERRORS="$RELEASE_ERRORS\n- Release task execution failed: $OUTPUT" - RELEASE_SUCCESS=false - else - echo "✅ Release task completed successfully" - fi - fi - - # Verify version file exists and is readable - if [ ! -f "internal/version/version.txt" ]; then - echo "❌ Version file not found: internal/version/version.txt" - RELEASE_ERRORS="$RELEASE_ERRORS\n- Version file not found after release task execution" - RELEASE_SUCCESS=false - RELEASE_VERSION="unknown" - else - RELEASE_VERSION=$(cat internal/version/version.txt 2>/dev/null || echo "unknown") - if [ "$RELEASE_VERSION" == "unknown" ]; then - echo "❌ Failed to read version from file" - RELEASE_ERRORS="$RELEASE_ERRORS\n- Failed to read version from version.txt" - RELEASE_SUCCESS=false - else - echo "✅ Successfully read version: $RELEASE_VERSION" - fi - fi - - # Check if version changed - VERSION_CHANGED="false" - if [ "$ORIGINAL_VERSION" != "$RELEASE_VERSION" ] && [ "$RELEASE_VERSION" != "unknown" ]; then - echo "✅ Version changed from $ORIGINAL_VERSION to $RELEASE_VERSION" - VERSION_CHANGED="true" - else - echo "ℹ️ Version unchanged: $RELEASE_VERSION" - fi - - RELEASE_TAG="${RELEASE_VERSION}" - RELEASE_TITLE="Wails ${RELEASE_VERSION}" - - # Set outputs for next steps - echo "version=$RELEASE_VERSION" >> $GITHUB_OUTPUT - echo "tag=$RELEASE_TAG" >> $GITHUB_OUTPUT - echo "title=$RELEASE_TITLE" >> $GITHUB_OUTPUT - echo "is_prerelease=true" >> $GITHUB_OUTPUT - echo "is_latest=false" >> $GITHUB_OUTPUT - echo "has_changes=${{ steps.changelog_check.outputs.has_unreleased_content }}" >> $GITHUB_OUTPUT - echo "success=$RELEASE_SUCCESS" >> $GITHUB_OUTPUT - echo "version_changed=$VERSION_CHANGED" >> $GITHUB_OUTPUT - - # Copy pre-extracted release notes - if [ "$RELEASE_SUCCESS" == "true" ]; then - echo "📝 Using pre-extracted release notes..." - - # Use the release_notes.md file created earlier - if [ -f "release_notes.md" ]; then - cp release_notes.md release-notes.txt - echo "✅ Successfully copied release notes" - echo "release_notes_file=release-notes.txt" >> $GITHUB_OUTPUT - else - echo "ℹ️ No pre-extracted release notes found" - echo "No detailed changelog available for this release." > release-notes.txt - echo "release_notes_file=release-notes.txt" >> $GITHUB_OUTPUT - fi - else - echo "release_notes_file=" >> $GITHUB_OUTPUT - echo "⚠️ Skipping release notes generation due to release task failure" - fi - - # Set error output for later steps - if [ -n "$RELEASE_ERRORS" ]; then - echo "release_errors<> $GITHUB_OUTPUT - echo -e "$RELEASE_ERRORS" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - echo "has_release_errors=true" >> $GITHUB_OUTPUT - else - echo "has_release_errors=false" >> $GITHUB_OUTPUT - fi - - - name: Create and push git tag - id: git_tag - if: | - (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && - steps.check_tag.outputs.has_tag == 'false' && - github.event.inputs.dry_run != 'true' && - steps.release.outputs.success == 'true' && - steps.release.outputs.version_changed == 'true' - env: - GITHUB_TOKEN: ${{ secrets.WAILS_REPO_TOKEN || github.token }} - run: | - echo "🏷️ Creating and pushing git tag: ${{ steps.release.outputs.tag }}" - - # Initialize error tracking - GIT_ERRORS="" - GIT_SUCCESS=true - - # Create git tag with error handling - if git tag -a "${{ steps.release.outputs.tag }}" -m "Release ${{ steps.release.outputs.version }}" 2>&1; then - echo "✅ Successfully created git tag: ${{ steps.release.outputs.tag }}" - else - echo "❌ Failed to create git tag" - GIT_ERRORS="$GIT_ERRORS\n- Failed to create git tag: ${{ steps.release.outputs.tag }}" - GIT_SUCCESS=false - fi - - # Push tag with retry logic and error handling - if [ "$GIT_SUCCESS" == "true" ]; then - RETRY_COUNT=0 - MAX_RETRIES=3 - PUSH_SUCCESS=false - - while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ "$PUSH_SUCCESS" == "false" ]; do - RETRY_COUNT=$((RETRY_COUNT + 1)) - echo "🔄 Attempting to push tag (attempt $RETRY_COUNT/$MAX_RETRIES)..." - - if git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" "${{ steps.release.outputs.tag }}" 2>&1; then - echo "✅ Successfully pushed git tag to origin" - PUSH_SUCCESS=true - else - echo "❌ Failed to push git tag (attempt $RETRY_COUNT/$MAX_RETRIES)" - if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then - echo "⏳ Waiting 5 seconds before retry..." - sleep 5 - fi - fi - done - - if [ "$PUSH_SUCCESS" == "false" ]; then - echo "❌ Failed to push git tag after $MAX_RETRIES attempts" - GIT_ERRORS="$GIT_ERRORS\n- Failed to push git tag after $MAX_RETRIES attempts" - GIT_SUCCESS=false - fi - fi - - # Set outputs for later steps - echo "success=$GIT_SUCCESS" >> $GITHUB_OUTPUT - - if [ -n "$GIT_ERRORS" ]; then - echo "git_tag_errors<> $GITHUB_OUTPUT - echo -e "$GIT_ERRORS" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - echo "has_git_errors=true" >> $GITHUB_OUTPUT - else - echo "has_git_errors=false" >> $GITHUB_OUTPUT - fi - - - name: Commit and push changes - id: git_commit - if: | - (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && - github.event.inputs.dry_run != 'true' && - steps.release.outputs.success == 'true' && - steps.release.outputs.version_changed == 'true' - env: - GITHUB_TOKEN: ${{ secrets.WAILS_REPO_TOKEN || github.token }} - run: | - echo "📝 Committing and pushing changes..." - - # Initialize error tracking - COMMIT_ERRORS="" - COMMIT_SUCCESS=true - - # Add any changes made by the release script with error handling - if git add . 2>&1; then - echo "✅ Successfully staged changes" - else - echo "❌ Failed to stage changes" - COMMIT_ERRORS="$COMMIT_ERRORS\n- Failed to stage changes with git add" - COMMIT_SUCCESS=false - fi - - # Check if there are changes to commit - if [ "$COMMIT_SUCCESS" == "true" ]; then - if ! git diff --cached --quiet; then - echo "📝 Changes detected, creating commit..." - - # Create commit with error handling - if git commit -m "${{ steps.release.outputs.version }}" 2>&1; then - echo "✅ Successfully created commit" - - # Push changes with retry logic - RETRY_COUNT=0 - MAX_RETRIES=3 - PUSH_SUCCESS=false - - while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ "$PUSH_SUCCESS" == "false" ]; do - RETRY_COUNT=$((RETRY_COUNT + 1)) - echo "🔄 Attempting to push changes (attempt $RETRY_COUNT/$MAX_RETRIES)..." - - if git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" v3-alpha 2>&1; then - echo "✅ Successfully pushed changes to v3-alpha branch" - PUSH_SUCCESS=true - else - echo "❌ Failed to push changes (attempt $RETRY_COUNT/$MAX_RETRIES)" - if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then - echo "⏳ Waiting 5 seconds before retry..." - sleep 5 - fi - fi - done - - if [ "$PUSH_SUCCESS" == "false" ]; then - echo "❌ Failed to push changes after $MAX_RETRIES attempts" - COMMIT_ERRORS="$COMMIT_ERRORS\n- Failed to push changes after $MAX_RETRIES attempts" - COMMIT_SUCCESS=false - fi - else - echo "❌ Failed to create commit" - COMMIT_ERRORS="$COMMIT_ERRORS\n- Failed to create git commit" - COMMIT_SUCCESS=false - fi - else - echo "ℹ️ No changes to commit" - fi - fi - - # Set outputs for later steps - echo "success=$COMMIT_SUCCESS" >> $GITHUB_OUTPUT - - if [ -n "$COMMIT_ERRORS" ]; then - echo "commit_errors<> $GITHUB_OUTPUT - echo -e "$COMMIT_ERRORS" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - echo "has_commit_errors=true" >> $GITHUB_OUTPUT - else - echo "has_commit_errors=false" >> $GITHUB_OUTPUT - fi - - - name: Read release notes - id: read_notes - if: | - (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && - steps.release.outputs.release_notes_file != '' && - steps.release.outputs.version_changed == 'true' - run: | - cd v3 - if [ -f "release-notes.txt" ]; then - # Read the release notes and add header - echo "### Changes in this release:" > formatted-release-notes.txt - echo "" >> formatted-release-notes.txt - cat release-notes.txt >> formatted-release-notes.txt - - # Read the formatted notes for output - RELEASE_NOTES=$(cat formatted-release-notes.txt) - echo "release_notes<> $GITHUB_OUTPUT - echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - else - echo "release_notes=No release notes available" >> $GITHUB_OUTPUT - fi - - - name: Test GitHub Release Creation (DRY RUN) - if: | - (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && - github.event.inputs.dry_run == 'true' && - steps.release.outputs.version_changed == 'true' - run: | - echo "🧪 DRY RUN: Would create GitHub release with the following parameters:" - echo "=======================================================================" - echo "Tag Name: ${{ steps.release.outputs.tag }}" - echo "Release Name: ${{ steps.release.outputs.title }}" - echo "Is Prerelease: ${{ steps.release.outputs.is_prerelease }}" - echo "Is Latest: ${{ steps.release.outputs.is_latest }}" - echo "Has Changes: ${{ steps.release.outputs.has_changes }}" - echo "" - echo "Release Body Preview:" - echo "## Wails v3 Alpha Release - ${{ steps.release.outputs.version }}" - echo "" - cat << 'RELEASE_NOTES_EOF' - ${{ steps.read_notes.outputs.release_notes }} - RELEASE_NOTES_EOF - echo "" - echo "" - echo "" - echo "---" - echo "" - echo "🤖 This is an automated nightly release generated from the latest changes in the v3-alpha branch." - echo "" - echo "**Installation:**" - echo "\`\`\`bash" - echo "go install github.com/wailsapp/wails/v3/cmd/wails@${{ steps.release.outputs.tag }}" - echo "\`\`\`" - echo "" - echo "**⚠️ Alpha Warning:** This is pre-release software and may contain bugs or incomplete features." - echo "" - echo "✅ DRY RUN: GitHub release creation test completed successfully!" - - - name: Create GitHub Release (LIVE) - id: github_release - if: | - (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && - github.event.inputs.dry_run != 'true' && - steps.release.outputs.success == 'true' && - steps.release.outputs.version_changed == 'true' - continue-on-error: true - run: | - echo "🚀 Creating GitHub release using gh CLI..." - - # Create release notes in a temporary file - cat > release_notes.md << 'EOF' - ## Wails v3 Alpha Release - ${{ steps.release.outputs.version }} - - ${{ steps.read_notes.outputs.release_notes }} - - - - --- - - 🤖 This is an automated nightly release generated from the latest changes in the v3-alpha branch. - - **Installation:** - ```bash - go install github.com/wailsapp/wails/v3/cmd/wails@${{ steps.release.outputs.tag }} - ``` - - **⚠️ Alpha Warning:** This is pre-release software and may contain bugs or incomplete features. - EOF - - # Create the release - if gh release create "${{ steps.release.outputs.tag }}" \ - --title "${{ steps.release.outputs.title }}" \ - --notes-file release_notes.md \ - --target v3-alpha \ - --prerelease; then - echo "✅ Successfully created GitHub release" - echo "outcome=success" >> $GITHUB_OUTPUT - else - echo "❌ Failed to create GitHub release" - echo "outcome=failure" >> $GITHUB_OUTPUT - fi - env: - GITHUB_TOKEN: ${{ secrets.WAILS_REPO_TOKEN || github.token }} - - - name: Handle GitHub Release Creation Result - id: release_result - if: | - (steps.quick_check.outputs.should_continue == 'true' || github.event.inputs.force_release == 'true') && - github.event.inputs.dry_run != 'true' && - steps.release.outputs.success == 'true' && - steps.release.outputs.version_changed == 'true' - run: | - echo "📋 Checking GitHub release creation result..." - - # Initialize error tracking - GITHUB_ERRORS="" - GITHUB_SUCCESS=true - - # Check if GitHub release creation succeeded - if [ "${{ steps.github_release.outcome }}" == "success" ]; then - echo "✅ GitHub release created successfully" - echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ steps.release.outputs.tag }}" - else - echo "❌ GitHub release creation failed" - GITHUB_ERRORS="$GITHUB_ERRORS\n- GitHub release creation failed with outcome: ${{ steps.github_release.outcome }}" - GITHUB_SUCCESS=false - fi - - # Set outputs for summary - echo "success=$GITHUB_SUCCESS" >> $GITHUB_OUTPUT - - if [ -n "$GITHUB_ERRORS" ]; then - echo "github_errors<> $GITHUB_OUTPUT - echo -e "$GITHUB_ERRORS" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - echo "has_github_errors=true" >> $GITHUB_OUTPUT - else - echo "has_github_errors=false" >> $GITHUB_OUTPUT - fi - - - name: Error Summary and Reporting - id: error_summary - if: always() - run: | - echo "📊 Generating comprehensive error summary..." - - # Initialize error tracking - TOTAL_ERRORS=0 - ERROR_SUMMARY="" - OVERALL_SUCCESS=true - - # Check for changelog errors - if [ "${{ steps.changelog_check.outputs.has_errors }}" == "true" ]; then - echo "❌ Changelog processing errors detected" - ERROR_SUMMARY="$ERROR_SUMMARY\n### 📄 Changelog Processing Errors\n${{ steps.changelog_check.outputs.changelog_errors }}\n" - TOTAL_ERRORS=$((TOTAL_ERRORS + 1)) - OVERALL_SUCCESS=false - fi - - # Check for release script errors - if [ "${{ steps.release.outputs.has_release_errors }}" == "true" ]; then - echo "❌ Release script errors detected" - ERROR_SUMMARY="$ERROR_SUMMARY\n### 🚀 Release Script Errors\n${{ steps.release.outputs.release_errors }}\n" - TOTAL_ERRORS=$((TOTAL_ERRORS + 1)) - OVERALL_SUCCESS=false - fi - - # Check for git tag errors - if [ "${{ steps.git_tag.outputs.has_git_errors }}" == "true" ]; then - echo "❌ Git tag errors detected" - ERROR_SUMMARY="$ERROR_SUMMARY\n### 🏷️ Git Tag Errors\n${{ steps.git_tag.outputs.git_tag_errors }}\n" - TOTAL_ERRORS=$((TOTAL_ERRORS + 1)) - OVERALL_SUCCESS=false - fi - - # Check for git commit errors - if [ "${{ steps.git_commit.outputs.has_commit_errors }}" == "true" ]; then - echo "❌ Git commit errors detected" - ERROR_SUMMARY="$ERROR_SUMMARY\n### 📝 Git Commit Errors\n${{ steps.git_commit.outputs.commit_errors }}\n" - TOTAL_ERRORS=$((TOTAL_ERRORS + 1)) - OVERALL_SUCCESS=false - fi - - # Check for GitHub release errors - if [ "${{ steps.release_result.outputs.has_github_errors }}" == "true" ]; then - echo "❌ GitHub release errors detected" - ERROR_SUMMARY="$ERROR_SUMMARY\n### 🐙 GitHub Release Errors\n${{ steps.release_result.outputs.github_errors }}\n" - TOTAL_ERRORS=$((TOTAL_ERRORS + 1)) - OVERALL_SUCCESS=false - fi - - # Set outputs for final summary - echo "total_errors=$TOTAL_ERRORS" >> $GITHUB_OUTPUT - echo "overall_success=$OVERALL_SUCCESS" >> $GITHUB_OUTPUT - - if [ -n "$ERROR_SUMMARY" ]; then - echo "error_summary<> $GITHUB_OUTPUT - echo -e "$ERROR_SUMMARY" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi - - # Log summary - if [ "$OVERALL_SUCCESS" == "true" ]; then - echo "✅ Workflow completed successfully with no errors" - else - echo "⚠️ Workflow completed with $TOTAL_ERRORS error categories" + ARGS+=(--dry-run) fi + go run release.go "${ARGS[@]}" - name: Summary if: always() run: | if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then - echo "## 🧪 DRY RUN Release Test Summary" >> $GITHUB_STEP_SUMMARY + echo "## 🧪 DRY RUN Release Summary" >> $GITHUB_STEP_SUMMARY else echo "## 🚀 Nightly Release Summary" >> $GITHUB_STEP_SUMMARY fi echo "================================" >> $GITHUB_STEP_SUMMARY - echo "- **Version:** ${{ steps.release.outputs.version }}" >> $GITHUB_STEP_SUMMARY - echo "- **Tag:** ${{ steps.release.outputs.tag }}" >> $GITHUB_STEP_SUMMARY - echo "- **Version Changed:** ${{ steps.release.outputs.version_changed }}" >> $GITHUB_STEP_SUMMARY - echo "- **Has existing tag:** ${{ steps.check_tag.outputs.has_tag }}" >> $GITHUB_STEP_SUMMARY - echo "- **Has unreleased changelog content:** ${{ steps.changelog_check.outputs.has_unreleased_content }}" >> $GITHUB_STEP_SUMMARY - echo "- **Has changes:** ${{ steps.release.outputs.has_changes }}" >> $GITHUB_STEP_SUMMARY - echo "- **Is prerelease:** ${{ steps.release.outputs.is_prerelease }}" >> $GITHUB_STEP_SUMMARY - echo "- **Is latest:** ${{ steps.release.outputs.is_latest }}" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - - # Overall status - if [ "${{ steps.error_summary.outputs.overall_success }}" == "true" ]; then - if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then - echo "- **Mode:** 🧪 DRY RUN (no actual release created)" >> $GITHUB_STEP_SUMMARY - echo "- **Status:** ✅ Test completed successfully" >> $GITHUB_STEP_SUMMARY + + if [ -n "${{ steps.release.outputs.release_version }}" ]; then + echo "- **Version:** ${{ steps.release.outputs.release_version }}" >> $GITHUB_STEP_SUMMARY + echo "- **Tag:** ${{ steps.release.outputs.release_tag }}" >> $GITHUB_STEP_SUMMARY + echo "- **Status:** ${{ steps.release.outcome == 'success' && '✅ Success' || '⚠️ Failed' }}" >> $GITHUB_STEP_SUMMARY + echo "- **Mode:** ${{ steps.release.outputs.release_dry_run == 'true' && '🧪 Dry Run' || '🚀 Live release' }}" >> $GITHUB_STEP_SUMMARY + if [ -n "${{ steps.release.outputs.release_url }}" ]; then + echo "- **Release URL:** ${{ steps.release.outputs.release_url }}" >> $GITHUB_STEP_SUMMARY + fi + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Changelog" >> $GITHUB_STEP_SUMMARY + if [ "${{ steps.changelog_check.outputs.has_unreleased_content }}" == "true" ]; then + echo "✅ Unreleased changelog processed and reset." >> $GITHUB_STEP_SUMMARY else - echo "- **Mode:** 🚀 Live release" >> $GITHUB_STEP_SUMMARY - echo "- **Status:** ✅ Release created successfully" >> $GITHUB_STEP_SUMMARY + echo "ℹ️ No unreleased changelog content detected." >> $GITHUB_STEP_SUMMARY fi else - echo "- **Mode:** ${{ github.event.inputs.dry_run == 'true' && '🧪 DRY RUN' || '🚀 Live release' }}" >> $GITHUB_STEP_SUMMARY - echo "- **Status:** ⚠️ Completed with ${{ steps.error_summary.outputs.total_errors }} error(s)" >> $GITHUB_STEP_SUMMARY + echo "- Release script did not run (skipped or failed before execution)." >> $GITHUB_STEP_SUMMARY fi - - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Release Processing" >> $GITHUB_STEP_SUMMARY - if [ "${{ steps.release.outputs.version_changed }}" == "true" ]; then - echo "✅ **Version was incremented** and release created" >> $GITHUB_STEP_SUMMARY - else - echo "ℹ️ **Version was not changed** - no release created" >> $GITHUB_STEP_SUMMARY - fi - - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Changelog Processing" >> $GITHUB_STEP_SUMMARY - if [ "${{ steps.changelog_check.outputs.has_unreleased_content }}" == "true" ]; then - echo "✅ **UNRELEASED_CHANGELOG.md** had content and was processed" >> $GITHUB_STEP_SUMMARY - echo "- Content moved to main changelog" >> $GITHUB_STEP_SUMMARY - echo "- UNRELEASED_CHANGELOG.md reset with template" >> $GITHUB_STEP_SUMMARY - else - echo "ℹ️ **UNRELEASED_CHANGELOG.md** had no content to process" >> $GITHUB_STEP_SUMMARY - fi - - # Error reporting section - if [ "${{ steps.error_summary.outputs.total_errors }}" -gt 0 ]; then - echo "" >> $GITHUB_STEP_SUMMARY - echo "## ⚠️ Error Report" >> $GITHUB_STEP_SUMMARY - echo "**Total Error Categories:** ${{ steps.error_summary.outputs.total_errors }}" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "${{ steps.error_summary.outputs.error_summary }}" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### 🔧 Troubleshooting Tips" >> $GITHUB_STEP_SUMMARY - echo "- Check the individual step logs above for detailed error messages" >> $GITHUB_STEP_SUMMARY - echo "- Verify GitHub token permissions (contents: write, pull-requests: read)" >> $GITHUB_STEP_SUMMARY - echo "- Ensure UNRELEASED_CHANGELOG.md follows the expected format" >> $GITHUB_STEP_SUMMARY - echo "- Check for network connectivity issues if git/GitHub operations failed" >> $GITHUB_STEP_SUMMARY - echo "- Re-run the workflow with 'force_release=true' if needed" >> $GITHUB_STEP_SUMMARY - fi - - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Release Notes Preview" >> $GITHUB_STEP_SUMMARY - if [ -n "${{ steps.read_notes.outputs.release_notes }}" ]; then - echo "${{ steps.read_notes.outputs.release_notes }}" >> $GITHUB_STEP_SUMMARY - else - echo "No specific release notes generated" >> $GITHUB_STEP_SUMMARY - fi - echo "" >> $GITHUB_STEP_SUMMARY - echo "---" >> $GITHUB_STEP_SUMMARY - echo "*Generated by automated nightly release workflow with enhanced error handling and changelog integration*" >> $GITHUB_STEP_SUMMARY - - # Set final workflow status - if [ "${{ steps.error_summary.outputs.overall_success }}" != "true" ]; then - echo "⚠️ Workflow completed with errors. Check the summary above for details." - exit 1 - fi \ No newline at end of file + diff --git a/.github/workflows/pr-master.yml b/.github/workflows/pr-master.yml index 00c0f9103..c961b4434 100644 --- a/.github/workflows/pr-master.yml +++ b/.github/workflows/pr-master.yml @@ -1,17 +1,26 @@ -name: PR Checks (master) - +# Updated to ensure "Run Go Tests" runs for pull requests as expected. +# Key fix: the test_go job previously required github.event.review.state == 'approved' +# which only exists on pull_request_review events. That prevented the job from +# running for regular pull_request events (opened / synchronize / reopened). +# New logic: run tests for pull_request events, and also allow running when a +# pull_request_review is submitted with state == 'approved'. on: pull_request: + types: [opened, synchronize, reopened] branches: - master pull_request_review: types: [submitted] branches: - master + workflow_dispatch: {} + +name: PR Checks (master) + jobs: check_docs: name: Check Docs - if: ${{github.repository == 'wailsapp/wails' && github.base_ref == 'master'}} + if: ${{ github.repository == 'wailsapp/wails' && github.base_ref == 'master' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -23,7 +32,6 @@ jobs: files: | website/**/*.mdx website/**/*.md - - name: Run step only when files change. if: steps.verify-changed-files.outputs.files_changed != 'true' run: | @@ -32,11 +40,18 @@ jobs: test_go: name: Run Go Tests runs-on: ${{ matrix.os }} + # Run when: + # - the event is a pull_request (opened/synchronize/reopened) OR + # - the event is a pull_request_review AND the review state is 'approved' + # plus other existing filters (not the update-sponsors branch, repo and base_ref) if: > + github.repository == 'wailsapp/wails' && + github.base_ref == 'master' && github.event.pull_request.head.ref != 'update-sponsors' && - github.event.review.state == 'approved' && - github.repository == 'wailsapp/wails' && - github.base_ref == 'master' + ( + github.event_name == 'pull_request' || + (github.event_name == 'pull_request_review' && github.event.review.state == 'approved') + ) strategy: matrix: os: [ubuntu-22.04, windows-latest, macos-latest, ubuntu-24.04] diff --git a/.github/workflows/unreleased-changelog-trigger.yml b/.github/workflows/unreleased-changelog-trigger.yml new file mode 100644 index 000000000..8cfe85de0 --- /dev/null +++ b/.github/workflows/unreleased-changelog-trigger.yml @@ -0,0 +1,129 @@ +name: Auto Release on Changelog Update + +on: + push: + branches: + - v3-alpha + paths: + - 'v3/UNRELEASED_CHANGELOG.md' + workflow_dispatch: + inputs: + dry_run: + description: 'Run in dry-run mode (no actual release)' + required: false + default: false + type: boolean + +jobs: + check-permissions: + name: Check Release Permissions + runs-on: ubuntu-latest + outputs: + authorized: ${{ steps.check.outputs.authorized }} + steps: + - name: Check if user is authorized for releases + id: check + run: | + # Only allow specific users to trigger releases + AUTHORIZED_USERS="leaanthony" + + if [[ "$AUTHORIZED_USERS" == *"${{ github.actor }}"* ]]; then + echo "✅ User ${{ github.actor }} is authorized for releases" + echo "authorized=true" >> $GITHUB_OUTPUT + else + echo "❌ User ${{ github.actor }} is not authorized for releases" + echo "authorized=false" >> $GITHUB_OUTPUT + fi + + trigger-release: + name: Trigger v3-alpha Release + permissions: + contents: read + actions: write + runs-on: ubuntu-latest + needs: check-permissions + if: needs.check-permissions.outputs.authorized == 'true' + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: v3-alpha + fetch-depth: 0 + token: ${{ secrets.WAILS_REPO_TOKEN || github.token }} + + - name: Check for unreleased changelog content + id: changelog_check + run: | + echo "🔍 Checking UNRELEASED_CHANGELOG.md for content..." + + cd v3 + # Check if UNRELEASED_CHANGELOG.md has actual content beyond the template + if [ -f "UNRELEASED_CHANGELOG.md" ]; then + # Use a simple check for actual content (bullet points starting with -) + CONTENT_LINES=$(grep -E "^\s*-\s+[^[:space:]]" UNRELEASED_CHANGELOG.md | wc -l) + if [ "$CONTENT_LINES" -gt 0 ]; then + echo "✅ Found $CONTENT_LINES content lines in UNRELEASED_CHANGELOG.md" + echo "has_content=true" >> $GITHUB_OUTPUT + else + echo "ℹ️ No actual content found in UNRELEASED_CHANGELOG.md" + echo "has_content=false" >> $GITHUB_OUTPUT + fi + else + echo "❌ UNRELEASED_CHANGELOG.md not found" + echo "has_content=false" >> $GITHUB_OUTPUT + fi + + - name: Trigger nightly release workflow + if: steps.changelog_check.outputs.has_content == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.WAILS_REPO_TOKEN || github.token }} + script: | + const response = await github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'nightly-release-v3.yml', + ref: 'v3-alpha', + inputs: { + force_release: 'true', + dry_run: '${{ github.event.inputs.dry_run || "false" }}' + } + }); + + console.log('🚀 Successfully triggered nightly release workflow'); + console.log(`Workflow dispatch response status: ${response.status}`); + + // Create a summary + core.summary + .addHeading('🚀 Auto Release Triggered') + .addRaw('The v3-alpha release workflow has been automatically triggered due to changes in UNRELEASED_CHANGELOG.md') + .addTable([ + [{data: 'Trigger', header: true}, {data: 'Value', header: true}], + ['Repository', context.repo.repo], + ['Branch', 'v3-alpha'], + ['Actor', context.actor], + ['Dry Run', '${{ github.event.inputs.dry_run || "false" }}'], + ['Force Release', 'true'] + ]) + .addRaw('\n---\n*This release was automatically triggered by the unreleased-changelog-trigger workflow*') + .write(); + + - name: No content found + if: steps.changelog_check.outputs.has_content == 'false' + run: | + echo "ℹ️ No content found in UNRELEASED_CHANGELOG.md, skipping release trigger" + echo "## ℹ️ No Release Triggered" >> $GITHUB_STEP_SUMMARY + echo "**Reason:** UNRELEASED_CHANGELOG.md does not contain actual changelog content" >> $GITHUB_STEP_SUMMARY + echo "**Action:** No release workflow was triggered" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "To trigger a release, add actual changelog entries to the UNRELEASED_CHANGELOG.md file." >> $GITHUB_STEP_SUMMARY + + - name: Unauthorized user + if: needs.check-permissions.outputs.authorized == 'false' + run: | + echo "❌ User ${{ github.actor }} is not authorized to trigger releases" + echo "## ❌ Unauthorized Release Attempt" >> $GITHUB_STEP_SUMMARY + echo "**User:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY + echo "**Action:** Release trigger was blocked due to insufficient permissions" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Only authorized users can trigger automatic releases via changelog updates." >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/README.de.md b/README.de.md index b1616d2f9..5df35de5b 100644 --- a/README.de.md +++ b/README.de.md @@ -25,7 +25,7 @@ Erschaffe Desktop Anwendungen mit Go & Web Technologien. Awesome - Discord + Discord
diff --git a/README.es.md b/README.es.md index 59cbcf132..277d1c1fd 100644 --- a/README.es.md +++ b/README.es.md @@ -25,7 +25,7 @@ Awesome - Discord + Discord
diff --git a/README.fr.md b/README.fr.md index 2f405b46a..61230f353 100644 --- a/README.fr.md +++ b/README.fr.md @@ -25,7 +25,7 @@ Awesome - Discord + Discord
diff --git a/README.ja.md b/README.ja.md index d4edb662c..ffd9f8103 100644 --- a/README.ja.md +++ b/README.ja.md @@ -27,7 +27,7 @@ Awesome - Discord + Discord
diff --git a/README.ko.md b/README.ko.md index fc27dfbe1..075e04229 100644 --- a/README.ko.md +++ b/README.ko.md @@ -27,7 +27,7 @@ Awesome - Discord + Discord
diff --git a/README.md b/README.md index 12ff1d6dc..5ab9309b4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Awesome - Discord + Discord
@@ -98,9 +98,9 @@ The installation instructions are on the [official website](https://wails.io/doc This project is supported by these kind people / companies: -

- -

+## Powered By + +[![JetBrains logo.](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)](https://jb.gg/OpenSource) ## FAQ diff --git a/README.pt-br.md b/README.pt-br.md index 8129ac853..0e3883352 100644 --- a/README.pt-br.md +++ b/README.pt-br.md @@ -25,7 +25,7 @@ Awesome
- Discord + Discord
diff --git a/README.ru.md b/README.ru.md index 4a24b9bcb..76fa59d07 100644 --- a/README.ru.md +++ b/README.ru.md @@ -25,7 +25,7 @@ Awesome - Discord + Discord
diff --git a/README.tr.md b/README.tr.md index b9e88c0b9..e9b16ca76 100644 --- a/README.tr.md +++ b/README.tr.md @@ -25,7 +25,7 @@ Awesome - Discord + Discord
diff --git a/README.uz.md b/README.uz.md index 88744e94e..807262405 100644 --- a/README.uz.md +++ b/README.uz.md @@ -25,7 +25,7 @@ Awesome - Discord + Discord
diff --git a/README.zh-Hans.md b/README.zh-Hans.md index baeeb420e..4c09d0c45 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -27,7 +27,7 @@ Awesome - Discord + Discord
diff --git a/v2/cmd/wails/doctor.go b/v2/cmd/wails/doctor.go index eac5048b3..7f453133d 100644 --- a/v2/cmd/wails/doctor.go +++ b/v2/cmd/wails/doctor.go @@ -255,7 +255,6 @@ func diagnoseEnvironment(f *flags.Doctor) error { if len(dependenciesMissing) != 0 { pterm.Println("Fatal:") pterm.Println("Required dependencies missing: " + strings.Join(dependenciesMissing, " ")) - pterm.Println("Please read this article on how to resolve this: https://wails.io/guides/resolving-missing-packages") } pterm.Println() // Spacer for sponsor message diff --git a/v2/cmd/wails/internal/version.txt b/v2/cmd/wails/internal/version.txt index 2df320e9d..805579f30 100644 --- a/v2/cmd/wails/internal/version.txt +++ b/v2/cmd/wails/internal/version.txt @@ -1 +1 @@ -v2.10.2 \ No newline at end of file +v2.11.0 \ No newline at end of file diff --git a/v2/examples/customlayout/go.mod b/v2/examples/customlayout/go.mod index c7ead2202..e1a17304e 100644 --- a/v2/examples/customlayout/go.mod +++ b/v2/examples/customlayout/go.mod @@ -27,7 +27,7 @@ require ( github.com/tkrajina/go-reflector v0.5.8 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - github.com/wailsapp/go-webview2 v1.0.19 // indirect + github.com/wailsapp/go-webview2 v1.0.22 // indirect github.com/wailsapp/mimetype v1.4.1 // indirect golang.org/x/crypto v0.33.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect diff --git a/v2/examples/customlayout/go.sum b/v2/examples/customlayout/go.sum index d5caf9fef..f1995affb 100644 --- a/v2/examples/customlayout/go.sum +++ b/v2/examples/customlayout/go.sum @@ -72,6 +72,7 @@ github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+ github.com/wailsapp/go-webview2 v1.0.10 h1:PP5Hug6pnQEAhfRzLCoOh2jJaPdrqeRgJKZhyYyDV/w= github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo= github.com/wailsapp/go-webview2 v1.0.19/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc= +github.com/wailsapp/go-webview2 v1.0.22/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc= github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= diff --git a/v2/examples/dragdrop-test/.gitignore b/v2/examples/dragdrop-test/.gitignore new file mode 100644 index 000000000..a11bbf414 --- /dev/null +++ b/v2/examples/dragdrop-test/.gitignore @@ -0,0 +1,4 @@ +build/bin +node_modules +frontend/dist +frontend/wailsjs diff --git a/v2/examples/dragdrop-test/README.md b/v2/examples/dragdrop-test/README.md new file mode 100644 index 000000000..397b08b92 --- /dev/null +++ b/v2/examples/dragdrop-test/README.md @@ -0,0 +1,19 @@ +# README + +## About + +This is the official Wails Vanilla template. + +You can configure the project by editing `wails.json`. More information about the project settings can be found +here: https://wails.io/docs/reference/project-config + +## Live Development + +To run in live development mode, run `wails dev` in the project directory. This will run a Vite development +server that will provide very fast hot reload of your frontend changes. If you want to develop in a browser +and have access to your Go methods, there is also a dev server that runs on http://localhost:34115. Connect +to this in your browser, and you can call your Go code from devtools. + +## Building + +To build a redistributable, production mode package, use `wails build`. diff --git a/v2/examples/dragdrop-test/app.go b/v2/examples/dragdrop-test/app.go new file mode 100644 index 000000000..af53038a1 --- /dev/null +++ b/v2/examples/dragdrop-test/app.go @@ -0,0 +1,27 @@ +package main + +import ( + "context" + "fmt" +) + +// App struct +type App struct { + ctx context.Context +} + +// NewApp creates a new App application struct +func NewApp() *App { + return &App{} +} + +// startup is called when the app starts. The context is saved +// so we can call the runtime methods +func (a *App) startup(ctx context.Context) { + a.ctx = ctx +} + +// Greet returns a greeting for the given name +func (a *App) Greet(name string) string { + return fmt.Sprintf("Hello %s, It's show time!", name) +} diff --git a/v2/examples/dragdrop-test/build/README.md b/v2/examples/dragdrop-test/build/README.md new file mode 100644 index 000000000..1ae2f677f --- /dev/null +++ b/v2/examples/dragdrop-test/build/README.md @@ -0,0 +1,35 @@ +# Build Directory + +The build directory is used to house all the build files and assets for your application. + +The structure is: + +* bin - Output directory +* darwin - macOS specific files +* windows - Windows specific files + +## Mac + +The `darwin` directory holds files specific to Mac builds. +These may be customised and used as part of the build. To return these files to the default state, simply delete them +and +build with `wails build`. + +The directory contains the following files: + +- `Info.plist` - the main plist file used for Mac builds. It is used when building using `wails build`. +- `Info.dev.plist` - same as the main plist file but used when building using `wails dev`. + +## Windows + +The `windows` directory contains the manifest and rc files used when building with `wails build`. +These may be customised for your application. To return these files to the default state, simply delete them and +build with `wails build`. + +- `icon.ico` - The icon used for the application. This is used when building using `wails build`. If you wish to + use a different icon, simply replace this file with your own. If it is missing, a new `icon.ico` file + will be created using the `appicon.png` file in the build directory. +- `installer/*` - The files used to create the Windows installer. These are used when building using `wails build`. +- `info.json` - Application details used for Windows builds. The data here will be used by the Windows installer, + as well as the application itself (right click the exe -> properties -> details) +- `wails.exe.manifest` - The main application manifest file. \ No newline at end of file diff --git a/v2/examples/dragdrop-test/build/appicon.png b/v2/examples/dragdrop-test/build/appicon.png new file mode 100644 index 000000000..63617fe4f Binary files /dev/null and b/v2/examples/dragdrop-test/build/appicon.png differ diff --git a/v2/examples/dragdrop-test/build/darwin/Info.dev.plist b/v2/examples/dragdrop-test/build/darwin/Info.dev.plist new file mode 100644 index 000000000..14121ef7c --- /dev/null +++ b/v2/examples/dragdrop-test/build/darwin/Info.dev.plist @@ -0,0 +1,68 @@ + + + + CFBundlePackageType + APPL + CFBundleName + {{.Info.ProductName}} + CFBundleExecutable + {{.OutputFilename}} + CFBundleIdentifier + com.wails.{{.Name}} + CFBundleVersion + {{.Info.ProductVersion}} + CFBundleGetInfoString + {{.Info.Comments}} + CFBundleShortVersionString + {{.Info.ProductVersion}} + CFBundleIconFile + iconfile + LSMinimumSystemVersion + 10.13.0 + NSHighResolutionCapable + true + NSHumanReadableCopyright + {{.Info.Copyright}} + {{if .Info.FileAssociations}} + CFBundleDocumentTypes + + {{range .Info.FileAssociations}} + + CFBundleTypeExtensions + + {{.Ext}} + + CFBundleTypeName + {{.Name}} + CFBundleTypeRole + {{.Role}} + CFBundleTypeIconFile + {{.IconName}} + + {{end}} + + {{end}} + {{if .Info.Protocols}} + CFBundleURLTypes + + {{range .Info.Protocols}} + + CFBundleURLName + com.wails.{{.Scheme}} + CFBundleURLSchemes + + {{.Scheme}} + + CFBundleTypeRole + {{.Role}} + + {{end}} + + {{end}} + NSAppTransportSecurity + + NSAllowsLocalNetworking + + + + diff --git a/v2/examples/dragdrop-test/build/darwin/Info.plist b/v2/examples/dragdrop-test/build/darwin/Info.plist new file mode 100644 index 000000000..d17a7475c --- /dev/null +++ b/v2/examples/dragdrop-test/build/darwin/Info.plist @@ -0,0 +1,63 @@ + + + + CFBundlePackageType + APPL + CFBundleName + {{.Info.ProductName}} + CFBundleExecutable + {{.OutputFilename}} + CFBundleIdentifier + com.wails.{{.Name}} + CFBundleVersion + {{.Info.ProductVersion}} + CFBundleGetInfoString + {{.Info.Comments}} + CFBundleShortVersionString + {{.Info.ProductVersion}} + CFBundleIconFile + iconfile + LSMinimumSystemVersion + 10.13.0 + NSHighResolutionCapable + true + NSHumanReadableCopyright + {{.Info.Copyright}} + {{if .Info.FileAssociations}} + CFBundleDocumentTypes + + {{range .Info.FileAssociations}} + + CFBundleTypeExtensions + + {{.Ext}} + + CFBundleTypeName + {{.Name}} + CFBundleTypeRole + {{.Role}} + CFBundleTypeIconFile + {{.IconName}} + + {{end}} + + {{end}} + {{if .Info.Protocols}} + CFBundleURLTypes + + {{range .Info.Protocols}} + + CFBundleURLName + com.wails.{{.Scheme}} + CFBundleURLSchemes + + {{.Scheme}} + + CFBundleTypeRole + {{.Role}} + + {{end}} + + {{end}} + + diff --git a/v2/examples/dragdrop-test/build/windows/icon.ico b/v2/examples/dragdrop-test/build/windows/icon.ico new file mode 100644 index 000000000..f33479841 Binary files /dev/null and b/v2/examples/dragdrop-test/build/windows/icon.ico differ diff --git a/v2/examples/dragdrop-test/build/windows/info.json b/v2/examples/dragdrop-test/build/windows/info.json new file mode 100644 index 000000000..9727946b7 --- /dev/null +++ b/v2/examples/dragdrop-test/build/windows/info.json @@ -0,0 +1,15 @@ +{ + "fixed": { + "file_version": "{{.Info.ProductVersion}}" + }, + "info": { + "0000": { + "ProductVersion": "{{.Info.ProductVersion}}", + "CompanyName": "{{.Info.CompanyName}}", + "FileDescription": "{{.Info.ProductName}}", + "LegalCopyright": "{{.Info.Copyright}}", + "ProductName": "{{.Info.ProductName}}", + "Comments": "{{.Info.Comments}}" + } + } +} \ No newline at end of file diff --git a/v2/examples/dragdrop-test/build/windows/installer/project.nsi b/v2/examples/dragdrop-test/build/windows/installer/project.nsi new file mode 100644 index 000000000..654ae2e49 --- /dev/null +++ b/v2/examples/dragdrop-test/build/windows/installer/project.nsi @@ -0,0 +1,114 @@ +Unicode true + +#### +## Please note: Template replacements don't work in this file. They are provided with default defines like +## mentioned underneath. +## If the keyword is not defined, "wails_tools.nsh" will populate them with the values from ProjectInfo. +## If they are defined here, "wails_tools.nsh" will not touch them. This allows to use this project.nsi manually +## from outside of Wails for debugging and development of the installer. +## +## For development first make a wails nsis build to populate the "wails_tools.nsh": +## > wails build --target windows/amd64 --nsis +## Then you can call makensis on this file with specifying the path to your binary: +## For a AMD64 only installer: +## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app.exe +## For a ARM64 only installer: +## > makensis -DARG_WAILS_ARM64_BINARY=..\..\bin\app.exe +## For a installer with both architectures: +## > makensis -DARG_WAILS_AMD64_BINARY=..\..\bin\app-amd64.exe -DARG_WAILS_ARM64_BINARY=..\..\bin\app-arm64.exe +#### +## The following information is taken from the ProjectInfo file, but they can be overwritten here. +#### +## !define INFO_PROJECTNAME "MyProject" # Default "{{.Name}}" +## !define INFO_COMPANYNAME "MyCompany" # Default "{{.Info.CompanyName}}" +## !define INFO_PRODUCTNAME "MyProduct" # Default "{{.Info.ProductName}}" +## !define INFO_PRODUCTVERSION "1.0.0" # Default "{{.Info.ProductVersion}}" +## !define INFO_COPYRIGHT "Copyright" # Default "{{.Info.Copyright}}" +### +## !define PRODUCT_EXECUTABLE "Application.exe" # Default "${INFO_PROJECTNAME}.exe" +## !define UNINST_KEY_NAME "UninstKeyInRegistry" # Default "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}" +#### +## !define REQUEST_EXECUTION_LEVEL "admin" # Default "admin" see also https://nsis.sourceforge.io/Docs/Chapter4.html +#### +## Include the wails tools +#### +!include "wails_tools.nsh" + +# The version information for this two must consist of 4 parts +VIProductVersion "${INFO_PRODUCTVERSION}.0" +VIFileVersion "${INFO_PRODUCTVERSION}.0" + +VIAddVersionKey "CompanyName" "${INFO_COMPANYNAME}" +VIAddVersionKey "FileDescription" "${INFO_PRODUCTNAME} Installer" +VIAddVersionKey "ProductVersion" "${INFO_PRODUCTVERSION}" +VIAddVersionKey "FileVersion" "${INFO_PRODUCTVERSION}" +VIAddVersionKey "LegalCopyright" "${INFO_COPYRIGHT}" +VIAddVersionKey "ProductName" "${INFO_PRODUCTNAME}" + +# Enable HiDPI support. https://nsis.sourceforge.io/Reference/ManifestDPIAware +ManifestDPIAware true + +!include "MUI.nsh" + +!define MUI_ICON "..\icon.ico" +!define MUI_UNICON "..\icon.ico" +# !define MUI_WELCOMEFINISHPAGE_BITMAP "resources\leftimage.bmp" #Include this to add a bitmap on the left side of the Welcome Page. Must be a size of 164x314 +!define MUI_FINISHPAGE_NOAUTOCLOSE # Wait on the INSTFILES page so the user can take a look into the details of the installation steps +!define MUI_ABORTWARNING # This will warn the user if they exit from the installer. + +!insertmacro MUI_PAGE_WELCOME # Welcome to the installer page. +# !insertmacro MUI_PAGE_LICENSE "resources\eula.txt" # Adds a EULA page to the installer +!insertmacro MUI_PAGE_DIRECTORY # In which folder install page. +!insertmacro MUI_PAGE_INSTFILES # Installing page. +!insertmacro MUI_PAGE_FINISH # Finished installation page. + +!insertmacro MUI_UNPAGE_INSTFILES # Uinstalling page + +!insertmacro MUI_LANGUAGE "English" # Set the Language of the installer + +## The following two statements can be used to sign the installer and the uninstaller. The path to the binaries are provided in %1 +#!uninstfinalize 'signtool --file "%1"' +#!finalize 'signtool --file "%1"' + +Name "${INFO_PRODUCTNAME}" +OutFile "..\..\bin\${INFO_PROJECTNAME}-${ARCH}-installer.exe" # Name of the installer's file. +InstallDir "$PROGRAMFILES64\${INFO_COMPANYNAME}\${INFO_PRODUCTNAME}" # Default installing folder ($PROGRAMFILES is Program Files folder). +ShowInstDetails show # This will always show the installation details. + +Function .onInit + !insertmacro wails.checkArchitecture +FunctionEnd + +Section + !insertmacro wails.setShellContext + + !insertmacro wails.webview2runtime + + SetOutPath $INSTDIR + + !insertmacro wails.files + + CreateShortcut "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}" + CreateShortCut "$DESKTOP\${INFO_PRODUCTNAME}.lnk" "$INSTDIR\${PRODUCT_EXECUTABLE}" + + !insertmacro wails.associateFiles + !insertmacro wails.associateCustomProtocols + + !insertmacro wails.writeUninstaller +SectionEnd + +Section "uninstall" + !insertmacro wails.setShellContext + + RMDir /r "$AppData\${PRODUCT_EXECUTABLE}" # Remove the WebView2 DataPath + + RMDir /r $INSTDIR + + Delete "$SMPROGRAMS\${INFO_PRODUCTNAME}.lnk" + Delete "$DESKTOP\${INFO_PRODUCTNAME}.lnk" + + !insertmacro wails.unassociateFiles + !insertmacro wails.unassociateCustomProtocols + + !insertmacro wails.deleteUninstaller +SectionEnd diff --git a/v2/examples/dragdrop-test/build/windows/installer/wails_tools.nsh b/v2/examples/dragdrop-test/build/windows/installer/wails_tools.nsh new file mode 100644 index 000000000..f9c0f8852 --- /dev/null +++ b/v2/examples/dragdrop-test/build/windows/installer/wails_tools.nsh @@ -0,0 +1,249 @@ +# DO NOT EDIT - Generated automatically by `wails build` + +!include "x64.nsh" +!include "WinVer.nsh" +!include "FileFunc.nsh" + +!ifndef INFO_PROJECTNAME + !define INFO_PROJECTNAME "{{.Name}}" +!endif +!ifndef INFO_COMPANYNAME + !define INFO_COMPANYNAME "{{.Info.CompanyName}}" +!endif +!ifndef INFO_PRODUCTNAME + !define INFO_PRODUCTNAME "{{.Info.ProductName}}" +!endif +!ifndef INFO_PRODUCTVERSION + !define INFO_PRODUCTVERSION "{{.Info.ProductVersion}}" +!endif +!ifndef INFO_COPYRIGHT + !define INFO_COPYRIGHT "{{.Info.Copyright}}" +!endif +!ifndef PRODUCT_EXECUTABLE + !define PRODUCT_EXECUTABLE "${INFO_PROJECTNAME}.exe" +!endif +!ifndef UNINST_KEY_NAME + !define UNINST_KEY_NAME "${INFO_COMPANYNAME}${INFO_PRODUCTNAME}" +!endif +!define UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINST_KEY_NAME}" + +!ifndef REQUEST_EXECUTION_LEVEL + !define REQUEST_EXECUTION_LEVEL "admin" +!endif + +RequestExecutionLevel "${REQUEST_EXECUTION_LEVEL}" + +!ifdef ARG_WAILS_AMD64_BINARY + !define SUPPORTS_AMD64 +!endif + +!ifdef ARG_WAILS_ARM64_BINARY + !define SUPPORTS_ARM64 +!endif + +!ifdef SUPPORTS_AMD64 + !ifdef SUPPORTS_ARM64 + !define ARCH "amd64_arm64" + !else + !define ARCH "amd64" + !endif +!else + !ifdef SUPPORTS_ARM64 + !define ARCH "arm64" + !else + !error "Wails: Undefined ARCH, please provide at least one of ARG_WAILS_AMD64_BINARY or ARG_WAILS_ARM64_BINARY" + !endif +!endif + +!macro wails.checkArchitecture + !ifndef WAILS_WIN10_REQUIRED + !define WAILS_WIN10_REQUIRED "This product is only supported on Windows 10 (Server 2016) and later." + !endif + + !ifndef WAILS_ARCHITECTURE_NOT_SUPPORTED + !define WAILS_ARCHITECTURE_NOT_SUPPORTED "This product can't be installed on the current Windows architecture. Supports: ${ARCH}" + !endif + + ${If} ${AtLeastWin10} + !ifdef SUPPORTS_AMD64 + ${if} ${IsNativeAMD64} + Goto ok + ${EndIf} + !endif + + !ifdef SUPPORTS_ARM64 + ${if} ${IsNativeARM64} + Goto ok + ${EndIf} + !endif + + IfSilent silentArch notSilentArch + silentArch: + SetErrorLevel 65 + Abort + notSilentArch: + MessageBox MB_OK "${WAILS_ARCHITECTURE_NOT_SUPPORTED}" + Quit + ${else} + IfSilent silentWin notSilentWin + silentWin: + SetErrorLevel 64 + Abort + notSilentWin: + MessageBox MB_OK "${WAILS_WIN10_REQUIRED}" + Quit + ${EndIf} + + ok: +!macroend + +!macro wails.files + !ifdef SUPPORTS_AMD64 + ${if} ${IsNativeAMD64} + File "/oname=${PRODUCT_EXECUTABLE}" "${ARG_WAILS_AMD64_BINARY}" + ${EndIf} + !endif + + !ifdef SUPPORTS_ARM64 + ${if} ${IsNativeARM64} + File "/oname=${PRODUCT_EXECUTABLE}" "${ARG_WAILS_ARM64_BINARY}" + ${EndIf} + !endif +!macroend + +!macro wails.writeUninstaller + WriteUninstaller "$INSTDIR\uninstall.exe" + + SetRegView 64 + WriteRegStr HKLM "${UNINST_KEY}" "Publisher" "${INFO_COMPANYNAME}" + WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "${INFO_PRODUCTNAME}" + WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${INFO_PRODUCTVERSION}" + WriteRegStr HKLM "${UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXECUTABLE}" + WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" + WriteRegStr HKLM "${UNINST_KEY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" + + ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 + IntFmt $0 "0x%08X" $0 + WriteRegDWORD HKLM "${UNINST_KEY}" "EstimatedSize" "$0" +!macroend + +!macro wails.deleteUninstaller + Delete "$INSTDIR\uninstall.exe" + + SetRegView 64 + DeleteRegKey HKLM "${UNINST_KEY}" +!macroend + +!macro wails.setShellContext + ${If} ${REQUEST_EXECUTION_LEVEL} == "admin" + SetShellVarContext all + ${else} + SetShellVarContext current + ${EndIf} +!macroend + +# Install webview2 by launching the bootstrapper +# See https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#online-only-deployment +!macro wails.webview2runtime + !ifndef WAILS_INSTALL_WEBVIEW_DETAILPRINT + !define WAILS_INSTALL_WEBVIEW_DETAILPRINT "Installing: WebView2 Runtime" + !endif + + SetRegView 64 + # If the admin key exists and is not empty then webview2 is already installed + ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv" + ${If} $0 != "" + Goto ok + ${EndIf} + + ${If} ${REQUEST_EXECUTION_LEVEL} == "user" + # If the installer is run in user level, check the user specific key exists and is not empty then webview2 is already installed + ReadRegStr $0 HKCU "Software\Microsoft\EdgeUpdate\Clients{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv" + ${If} $0 != "" + Goto ok + ${EndIf} + ${EndIf} + + SetDetailsPrint both + DetailPrint "${WAILS_INSTALL_WEBVIEW_DETAILPRINT}" + SetDetailsPrint listonly + + InitPluginsDir + CreateDirectory "$pluginsdir\webview2bootstrapper" + SetOutPath "$pluginsdir\webview2bootstrapper" + File "tmp\MicrosoftEdgeWebview2Setup.exe" + ExecWait '"$pluginsdir\webview2bootstrapper\MicrosoftEdgeWebview2Setup.exe" /silent /install' + + SetDetailsPrint both + ok: +!macroend + +# Copy of APP_ASSOCIATE and APP_UNASSOCIATE macros from here https://gist.github.com/nikku/281d0ef126dbc215dd58bfd5b3a5cd5b +!macro APP_ASSOCIATE EXT FILECLASS DESCRIPTION ICON COMMANDTEXT COMMAND + ; Backup the previously associated file class + ReadRegStr $R0 SHELL_CONTEXT "Software\Classes\.${EXT}" "" + WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "${FILECLASS}_backup" "$R0" + + WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "" "${FILECLASS}" + + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}" "" `${DESCRIPTION}` + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\DefaultIcon" "" `${ICON}` + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell" "" "open" + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell\open" "" `${COMMANDTEXT}` + WriteRegStr SHELL_CONTEXT "Software\Classes\${FILECLASS}\shell\open\command" "" `${COMMAND}` +!macroend + +!macro APP_UNASSOCIATE EXT FILECLASS + ; Backup the previously associated file class + ReadRegStr $R0 SHELL_CONTEXT "Software\Classes\.${EXT}" `${FILECLASS}_backup` + WriteRegStr SHELL_CONTEXT "Software\Classes\.${EXT}" "" "$R0" + + DeleteRegKey SHELL_CONTEXT `Software\Classes\${FILECLASS}` +!macroend + +!macro wails.associateFiles + ; Create file associations + {{range .Info.FileAssociations}} + !insertmacro APP_ASSOCIATE "{{.Ext}}" "{{.Name}}" "{{.Description}}" "$INSTDIR\{{.IconName}}.ico" "Open with ${INFO_PRODUCTNAME}" "$INSTDIR\${PRODUCT_EXECUTABLE} $\"%1$\"" + + File "..\{{.IconName}}.ico" + {{end}} +!macroend + +!macro wails.unassociateFiles + ; Delete app associations + {{range .Info.FileAssociations}} + !insertmacro APP_UNASSOCIATE "{{.Ext}}" "{{.Name}}" + + Delete "$INSTDIR\{{.IconName}}.ico" + {{end}} +!macroend + +!macro CUSTOM_PROTOCOL_ASSOCIATE PROTOCOL DESCRIPTION ICON COMMAND + DeleteRegKey SHELL_CONTEXT "Software\Classes\${PROTOCOL}" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}" "" "${DESCRIPTION}" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}" "URL Protocol" "" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\DefaultIcon" "" "${ICON}" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell" "" "" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell\open" "" "" + WriteRegStr SHELL_CONTEXT "Software\Classes\${PROTOCOL}\shell\open\command" "" "${COMMAND}" +!macroend + +!macro CUSTOM_PROTOCOL_UNASSOCIATE PROTOCOL + DeleteRegKey SHELL_CONTEXT "Software\Classes\${PROTOCOL}" +!macroend + +!macro wails.associateCustomProtocols + ; Create custom protocols associations + {{range .Info.Protocols}} + !insertmacro CUSTOM_PROTOCOL_ASSOCIATE "{{.Scheme}}" "{{.Description}}" "$INSTDIR\${PRODUCT_EXECUTABLE},0" "$INSTDIR\${PRODUCT_EXECUTABLE} $\"%1$\"" + + {{end}} +!macroend + +!macro wails.unassociateCustomProtocols + ; Delete app custom protocol associations + {{range .Info.Protocols}} + !insertmacro CUSTOM_PROTOCOL_UNASSOCIATE "{{.Scheme}}" + {{end}} +!macroend diff --git a/v2/examples/dragdrop-test/build/windows/wails.exe.manifest b/v2/examples/dragdrop-test/build/windows/wails.exe.manifest new file mode 100644 index 000000000..17e1a2387 --- /dev/null +++ b/v2/examples/dragdrop-test/build/windows/wails.exe.manifest @@ -0,0 +1,15 @@ + + + + + + + + + + + true/pm + permonitorv2,permonitor + + + \ No newline at end of file diff --git a/v2/examples/dragdrop-test/frontend/index.html b/v2/examples/dragdrop-test/frontend/index.html new file mode 100644 index 000000000..4010f1be6 --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/index.html @@ -0,0 +1,12 @@ + + + + + + dragdrop-test + + +
+ + + diff --git a/v2/examples/dragdrop-test/frontend/package-lock.json b/v2/examples/dragdrop-test/frontend/package-lock.json new file mode 100644 index 000000000..8eed5313c --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/package-lock.json @@ -0,0 +1,653 @@ +{ + "name": "frontend", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "frontend", + "version": "0.0.0", + "devDependencies": { + "vite": "^3.0.7" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.18.tgz", + "integrity": "sha512-5GT+kcs2WVGjVs7+boataCkO5Fg0y4kCjzkB5bAip7H4jfnOS3dA6KPiww9W1OEKTKeAcUVhdZGvgI65OXmUnw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.18.tgz", + "integrity": "sha512-L4jVKS82XVhw2nvzLg/19ClLWg0y27ulRwuP7lcyL6AbUWB5aPglXY3M21mauDQMDfRLs8cQmeT03r/+X3cZYQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.18.tgz", + "integrity": "sha512-x/R72SmW3sSFRm5zrrIjAhCeQSAWoni3CmHEqfQrZIQTM3lVCdehdwuIqaOtfC2slvpdlLa62GYoN8SxT23m6Q==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.15.18", + "@esbuild/linux-loong64": "0.15.18", + "esbuild-android-64": "0.15.18", + "esbuild-android-arm64": "0.15.18", + "esbuild-darwin-64": "0.15.18", + "esbuild-darwin-arm64": "0.15.18", + "esbuild-freebsd-64": "0.15.18", + "esbuild-freebsd-arm64": "0.15.18", + "esbuild-linux-32": "0.15.18", + "esbuild-linux-64": "0.15.18", + "esbuild-linux-arm": "0.15.18", + "esbuild-linux-arm64": "0.15.18", + "esbuild-linux-mips64le": "0.15.18", + "esbuild-linux-ppc64le": "0.15.18", + "esbuild-linux-riscv64": "0.15.18", + "esbuild-linux-s390x": "0.15.18", + "esbuild-netbsd-64": "0.15.18", + "esbuild-openbsd-64": "0.15.18", + "esbuild-sunos-64": "0.15.18", + "esbuild-windows-32": "0.15.18", + "esbuild-windows-64": "0.15.18", + "esbuild-windows-arm64": "0.15.18" + } + }, + "node_modules/esbuild-android-64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.18.tgz", + "integrity": "sha512-wnpt3OXRhcjfIDSZu9bnzT4/TNTDsOUvip0foZOUBG7QbSt//w3QV4FInVJxNhKc/ErhUxc5z4QjHtMi7/TbgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-android-arm64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.18.tgz", + "integrity": "sha512-G4xu89B8FCzav9XU8EjsXacCKSG2FT7wW9J6hOc18soEHJdtWu03L3TQDGf0geNxfLTtxENKBzMSq9LlbjS8OQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-darwin-64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.18.tgz", + "integrity": "sha512-2WAvs95uPnVJPuYKP0Eqx+Dl/jaYseZEUUT1sjg97TJa4oBtbAKnPnl3b5M9l51/nbx7+QAEtuummJZW0sBEmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-darwin-arm64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.18.tgz", + "integrity": "sha512-tKPSxcTJ5OmNb1btVikATJ8NftlyNlc8BVNtyT/UAr62JFOhwHlnoPrhYWz09akBLHI9nElFVfWSTSRsrZiDUA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-freebsd-64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.18.tgz", + "integrity": "sha512-TT3uBUxkteAjR1QbsmvSsjpKjOX6UkCstr8nMr+q7zi3NuZ1oIpa8U41Y8I8dJH2fJgdC3Dj3CXO5biLQpfdZA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-freebsd-arm64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.18.tgz", + "integrity": "sha512-R/oVr+X3Tkh+S0+tL41wRMbdWtpWB8hEAMsOXDumSSa6qJR89U0S/PpLXrGF7Wk/JykfpWNokERUpCeHDl47wA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-32": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.18.tgz", + "integrity": "sha512-lphF3HiCSYtaa9p1DtXndiQEeQDKPl9eN/XNoBf2amEghugNuqXNZA/ZovthNE2aa4EN43WroO0B85xVSjYkbg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.18.tgz", + "integrity": "sha512-hNSeP97IviD7oxLKFuii5sDPJ+QHeiFTFLoLm7NZQligur8poNOWGIgpQ7Qf8Balb69hptMZzyOBIPtY09GZYw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-arm": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.18.tgz", + "integrity": "sha512-UH779gstRblS4aoS2qpMl3wjg7U0j+ygu3GjIeTonCcN79ZvpPee12Qun3vcdxX+37O5LFxz39XeW2I9bybMVA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-arm64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.18.tgz", + "integrity": "sha512-54qr8kg/6ilcxd+0V3h9rjT4qmjc0CccMVWrjOEM/pEcUzt8X62HfBSeZfT2ECpM7104mk4yfQXkosY8Quptug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-mips64le": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.18.tgz", + "integrity": "sha512-Mk6Ppwzzz3YbMl/ZZL2P0q1tnYqh/trYZ1VfNP47C31yT0K8t9s7Z077QrDA/guU60tGNp2GOwCQnp+DYv7bxQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-ppc64le": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.18.tgz", + "integrity": "sha512-b0XkN4pL9WUulPTa/VKHx2wLCgvIAbgwABGnKMY19WhKZPT+8BxhZdqz6EgkqCLld7X5qiCY2F/bfpUUlnFZ9w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-riscv64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.18.tgz", + "integrity": "sha512-ba2COaoF5wL6VLZWn04k+ACZjZ6NYniMSQStodFKH/Pu6RxzQqzsmjR1t9QC89VYJxBeyVPTaHuBMCejl3O/xg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-s390x": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.18.tgz", + "integrity": "sha512-VbpGuXEl5FCs1wDVp93O8UIzl3ZrglgnSQ+Hu79g7hZu6te6/YHgVJxCM2SqfIila0J3k0csfnf8VD2W7u2kzQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-netbsd-64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.18.tgz", + "integrity": "sha512-98ukeCdvdX7wr1vUYQzKo4kQ0N2p27H7I11maINv73fVEXt2kyh4K4m9f35U1K43Xc2QGXlzAw0K9yoU7JUjOg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-openbsd-64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.18.tgz", + "integrity": "sha512-yK5NCcH31Uae076AyQAXeJzt/vxIo9+omZRKj1pauhk3ITuADzuOx5N2fdHrAKPxN+zH3w96uFKlY7yIn490xQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-sunos-64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.18.tgz", + "integrity": "sha512-On22LLFlBeLNj/YF3FT+cXcyKPEI263nflYlAhz5crxtp3yRG1Ugfr7ITyxmCmjm4vbN/dGrb/B7w7U8yJR9yw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-32": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.18.tgz", + "integrity": "sha512-o+eyLu2MjVny/nt+E0uPnBxYuJHBvho8vWsC2lV61A7wwTWC3jkN2w36jtA+yv1UgYkHRihPuQsL23hsCYGcOQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.18.tgz", + "integrity": "sha512-qinug1iTTaIIrCorAUjR0fcBk24fjzEedFYhhispP8Oc7SFvs+XeW3YpAKiKp8dRpizl4YYAhxMjlftAMJiaUw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-arm64": { + "version": "0.15.18", + "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.18.tgz", + "integrity": "sha512-q9bsYzegpZcLziq0zgUi5KqGVtfhjxGbnksaBFYmWLxeV/S1fK4OLdq2DFYnXcLMjlZw2L0jLsk1eGoB522WXQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/resolve": { + "version": "1.22.11", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz", + "integrity": "sha512-RfqAvLnMl313r7c9oclB1HhUEAezcpLjz95wFH4LVuhk9JF/r22qmVP9AMmOU4vMX7Q8pN8jwNg/CSpdFnMjTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/rollup": { + "version": "2.79.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz", + "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", + "dev": true, + "license": "MIT", + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/vite": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/vite/-/vite-3.2.11.tgz", + "integrity": "sha512-K/jGKL/PgbIgKCiJo5QbASQhFiV02X9Jh+Qq0AKCRCRKZtOTVi4t6wh75FDpGf2N9rYOnzH87OEFQNaFy6pdxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.15.9", + "postcss": "^8.4.18", + "resolve": "^1.22.1", + "rollup": "^2.79.1" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + } + } +} diff --git a/v2/examples/dragdrop-test/frontend/package.json b/v2/examples/dragdrop-test/frontend/package.json new file mode 100644 index 000000000..a1b6f8e1a --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/package.json @@ -0,0 +1,13 @@ +{ + "name": "frontend", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "devDependencies": { + "vite": "^3.0.7" + } +} \ No newline at end of file diff --git a/v2/examples/dragdrop-test/frontend/src/app.css b/v2/examples/dragdrop-test/frontend/src/app.css new file mode 100644 index 000000000..1d3b595bc --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/src/app.css @@ -0,0 +1,229 @@ +/* #app styles are in style.css to avoid conflicts */ + +.compact-container { + display: flex; + gap: 15px; + margin: 15px 0; + justify-content: center; + align-items: flex-start; +} + +.drag-source { + background: white; + border: 2px solid #5c6bc0; + padding: 12px; + min-width: 140px; + border-radius: 6px; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); +} + +.drag-source h4 { + color: #3949ab; + margin: 0 0 8px 0; + font-size: 14px; +} + +.draggable { + background: #f5f5f5; + color: #1a1a1a; + padding: 8px; + margin: 6px 0; + border-radius: 4px; + cursor: move; + text-align: center; + transition: all 0.3s ease; + font-weight: 600; + font-size: 14px; + border: 2px solid #c5cae9; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); +} + +.draggable:hover { + transform: translateY(-2px); + box-shadow: 0 4px 12px rgba(0,0,0,0.15); + background: #e8eaf6; + border-color: #7986cb; +} + +.draggable.dragging { + opacity: 0.5; + transform: scale(0.95); + background: #c5cae9; +} + +.drop-zone { + background: #f8f9fa; + border: 2px dashed #9e9e9e; + padding: 12px; + min-width: 180px; + min-height: 120px; + border-radius: 6px; + transition: all 0.3s ease; +} + +.drop-zone h4 { + color: #5c6bc0; + margin: 0 0 8px 0; + font-size: 14px; +} + +.drop-zone.drag-over { + background: #e3f2fd; + border-color: #2196F3; + transform: scale(1.02); + box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2); +} + +.file-drop-zone { + background: #fff8e1; + border: 2px dashed #ffc107; + padding: 12px; + min-width: 180px; + min-height: 120px; + border-radius: 6px; + transition: all 0.3s ease; +} + +.file-drop-zone h4 { + color: #f57c00; + margin: 0 0 8px 0; + font-size: 14px; +} + +.file-drop-zone.drag-over { + background: #fff3cd; + border-color: #ff9800; + transform: scale(1.02); + box-shadow: 0 4px 12px rgba(255, 152, 0, 0.2); +} + +.dropped-item { + background: linear-gradient(135deg, #42a5f5 0%, #66bb6a 100%); + color: white; + padding: 6px 8px; + margin: 4px 2px; + border-radius: 4px; + text-align: center; + animation: slideIn 0.3s ease; + display: inline-block; + font-weight: 500; + font-size: 13px; +} + +.dropped-file { + background: #fff; + border: 2px solid #ff9800; + color: #333; + padding: 6px 8px; + margin: 4px 0; + border-radius: 4px; + text-align: left; + animation: slideIn 0.3s ease; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + font-size: 13px; +} + +#dropMessage, #fileDropMessage { + font-size: 12px; + color: #666; + margin: 4px 0; +} + +@keyframes slideIn { + from { + opacity: 0; + transform: translateY(-10px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +.status { + margin: 15px auto; + max-width: 1000px; + padding: 12px; + background: #2c3e50; + border-radius: 6px; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); +} + +.status h4 { + color: white; + margin: 0 0 8px 0; + font-size: 14px; +} + +#eventLog { + background: #1a1a1a; + padding: 10px; + border-radius: 4px; + max-height: 200px; + overflow-y: auto; + font-family: 'Courier New', monospace; + text-align: left; + font-size: 12px; +} + +.log-entry { + padding: 4px 8px; + font-size: 13px; + margin: 2px 0; + border-radius: 3px; +} + +.log-entry.drag-start { + color: #81c784; + background: rgba(129, 199, 132, 0.1); +} + +.log-entry.drag-over { + color: #64b5f6; + background: rgba(100, 181, 246, 0.1); +} + +.log-entry.drag-enter { + color: #ffb74d; + background: rgba(255, 183, 77, 0.1); +} + +.log-entry.drag-leave { + color: #ba68c8; + background: rgba(186, 104, 200, 0.1); +} + +.log-entry.drop { + color: #e57373; + background: rgba(229, 115, 115, 0.1); + font-weight: bold; +} + +.log-entry.drag-end { + color: #90a4ae; + background: rgba(144, 164, 174, 0.1); +} + +.log-entry.file-drop { + color: #ffc107; + background: rgba(255, 193, 7, 0.1); + font-weight: bold; +} + +.log-entry.page-loaded { + color: #4caf50; + background: rgba(76, 175, 80, 0.1); +} + +.log-entry.wails-status { + color: #00bcd4; + background: rgba(0, 188, 212, 0.1); +} + +h1 { + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + font-size: 1.8em; + margin: 10px 0 8px 0; +} \ No newline at end of file diff --git a/v2/examples/dragdrop-test/frontend/src/assets/fonts/OFL.txt b/v2/examples/dragdrop-test/frontend/src/assets/fonts/OFL.txt new file mode 100644 index 000000000..9cac04ce8 --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/src/assets/fonts/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2016 The Nunito Project Authors (contact@sansoxygen.com), + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/v2/examples/dragdrop-test/frontend/src/assets/fonts/nunito-v16-latin-regular.woff2 b/v2/examples/dragdrop-test/frontend/src/assets/fonts/nunito-v16-latin-regular.woff2 new file mode 100644 index 000000000..2f9cc5964 Binary files /dev/null and b/v2/examples/dragdrop-test/frontend/src/assets/fonts/nunito-v16-latin-regular.woff2 differ diff --git a/v2/examples/dragdrop-test/frontend/src/assets/images/logo-universal.png b/v2/examples/dragdrop-test/frontend/src/assets/images/logo-universal.png new file mode 100644 index 000000000..d63303bfa Binary files /dev/null and b/v2/examples/dragdrop-test/frontend/src/assets/images/logo-universal.png differ diff --git a/v2/examples/dragdrop-test/frontend/src/main.js b/v2/examples/dragdrop-test/frontend/src/main.js new file mode 100644 index 000000000..60d76ac0f --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/src/main.js @@ -0,0 +1,231 @@ +import './style.css'; +import './app.css'; + +// CRITICAL: Register global handlers IMMEDIATELY to prevent file drops from opening new windows +// This must be done as early as possible, before any other code runs +(function() { + // Helper function to check if drag event contains files + function isFileDrop(e) { + return e.dataTransfer && e.dataTransfer.types && + (e.dataTransfer.types.includes('Files') || + Array.from(e.dataTransfer.types).includes('Files')); + } + + // Global dragover handler - MUST prevent default for file drops + window.addEventListener('dragover', function(e) { + if (isFileDrop(e)) { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + } + }, true); // Use capture phase to handle before any other handlers + + // Global drop handler - MUST prevent default for file drops + window.addEventListener('drop', function(e) { + if (isFileDrop(e)) { + e.preventDefault(); + console.log('Global handler prevented file drop navigation'); + } + }, true); // Use capture phase to handle before any other handlers + + // Global dragleave handler + window.addEventListener('dragleave', function(e) { + if (isFileDrop(e)) { + e.preventDefault(); + } + }, true); // Use capture phase + + console.log('Global file drop prevention handlers registered'); +})(); + +document.querySelector('#app').innerHTML = ` +

Wails Drag & Drop Test

+ +
+
+

HTML5 Source

+
Item 1
+
Item 2
+
Item 3
+
+ +
+

HTML5 Drop

+

Drop here

+
+ +
+

File Drop

+

Drop files here

+
+
+ +
+

Event Log

+
+
+`; + +// Get all draggable items and drop zones +const draggables = document.querySelectorAll('.draggable'); +const dropZone = document.getElementById('dropZone'); +const fileDropZone = document.getElementById('fileDropZone'); +const eventLog = document.getElementById('eventLog'); +const dropMessage = document.getElementById('dropMessage'); +const fileDropMessage = document.getElementById('fileDropMessage'); + +let draggedItem = null; +let eventCounter = 0; + +// Function to log events +function logEvent(eventName, details = '') { + eventCounter++; + const timestamp = new Date().toLocaleTimeString(); + const logEntry = document.createElement('div'); + logEntry.className = `log-entry ${eventName.replace(' ', '-').toLowerCase()}`; + logEntry.textContent = `[${timestamp}] ${eventCounter}. ${eventName} ${details}`; + eventLog.insertBefore(logEntry, eventLog.firstChild); + + // Keep only last 20 events + while (eventLog.children.length > 20) { + eventLog.removeChild(eventLog.lastChild); + } + + console.log(`Event: ${eventName} ${details}`); +} + +// Add event listeners to draggable items +draggables.forEach(item => { + // Drag start + item.addEventListener('dragstart', (e) => { + draggedItem = e.target; + e.target.classList.add('dragging'); + e.dataTransfer.effectAllowed = 'copy'; + e.dataTransfer.setData('text/plain', e.target.dataset.item); + logEvent('drag-start', `- Started dragging: ${e.target.dataset.item}`); + }); + + // Drag end + item.addEventListener('dragend', (e) => { + e.target.classList.remove('dragging'); + logEvent('drag-end', `- Ended dragging: ${e.target.dataset.item}`); + }); +}); + +// Add event listeners to HTML drop zone +dropZone.addEventListener('dragenter', (e) => { + e.preventDefault(); + dropZone.classList.add('drag-over'); + logEvent('drag-enter', '- Entered HTML drop zone'); +}); + +dropZone.addEventListener('dragover', (e) => { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + // Don't log every dragover to avoid spam +}); + +dropZone.addEventListener('dragleave', (e) => { + if (e.target === dropZone) { + dropZone.classList.remove('drag-over'); + logEvent('drag-leave', '- Left HTML drop zone'); + } +}); + +dropZone.addEventListener('drop', (e) => { + e.preventDefault(); + dropZone.classList.remove('drag-over'); + + const data = e.dataTransfer.getData('text/plain'); + logEvent('drop', `- Dropped in HTML zone: ${data}`); + + if (draggedItem) { + // Create a copy of the dragged item + const droppedElement = document.createElement('div'); + droppedElement.className = 'dropped-item'; + droppedElement.textContent = data; + + // Remove the placeholder message if it exists + if (dropMessage) { + dropMessage.style.display = 'none'; + } + + dropZone.appendChild(droppedElement); + } + + draggedItem = null; +}); + +// Add event listeners to file drop zone +fileDropZone.addEventListener('dragenter', (e) => { + e.preventDefault(); + fileDropZone.classList.add('drag-over'); + logEvent('drag-enter', '- Entered file drop zone'); +}); + +fileDropZone.addEventListener('dragover', (e) => { + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; +}); + +fileDropZone.addEventListener('dragleave', (e) => { + if (e.target === fileDropZone) { + fileDropZone.classList.remove('drag-over'); + logEvent('drag-leave', '- Left file drop zone'); + } +}); + +fileDropZone.addEventListener('drop', (e) => { + e.preventDefault(); + fileDropZone.classList.remove('drag-over'); + + const files = [...e.dataTransfer.files]; + if (files.length > 0) { + logEvent('file-drop', `- Dropped ${files.length} file(s)`); + + // Hide the placeholder message + if (fileDropMessage) { + fileDropMessage.style.display = 'none'; + } + + // Display dropped files + files.forEach(file => { + const fileElement = document.createElement('div'); + fileElement.className = 'dropped-file'; + + // Format file size + let size = file.size; + let unit = 'bytes'; + if (size > 1024 * 1024) { + size = (size / (1024 * 1024)).toFixed(2); + unit = 'MB'; + } else if (size > 1024) { + size = (size / 1024).toFixed(2); + unit = 'KB'; + } + + fileElement.textContent = `📄 ${file.name} (${size} ${unit})`; + fileDropZone.appendChild(fileElement); + }); + } +}); + +// Log when page loads +window.addEventListener('DOMContentLoaded', () => { + logEvent('page-loaded', '- Wails drag-and-drop test page ready'); + console.log('Wails Drag and Drop test application loaded'); + + // Check if Wails drag and drop is enabled + if (window.wails && window.wails.flags) { + logEvent('wails-status', `- Wails DnD enabled: ${window.wails.flags.enableWailsDragAndDrop}`); + } + + // IMPORTANT: Register Wails drag-and-drop handlers to prevent browser navigation + // This will ensure external files don't open in new windows when dropped anywhere + if (window.runtime && window.runtime.OnFileDrop) { + window.runtime.OnFileDrop((x, y, paths) => { + logEvent('wails-file-drop', `- Wails received ${paths.length} file(s) at (${x}, ${y})`); + console.log('Wails OnFileDrop:', paths); + }, false); // false = don't require drop target, handle all file drops + logEvent('wails-setup', '- Wails OnFileDrop handlers registered'); + } +}); \ No newline at end of file diff --git a/v2/examples/dragdrop-test/frontend/src/style.css b/v2/examples/dragdrop-test/frontend/src/style.css new file mode 100644 index 000000000..f5d071597 --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/src/style.css @@ -0,0 +1,33 @@ +html { + background-color: rgba(27, 38, 54, 1); + text-align: center; + color: white; + height: 100%; + overflow: hidden; +} + +body { + margin: 0; + color: white; + font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", + "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + height: 100%; + overflow: hidden; +} + +@font-face { + font-family: "Nunito"; + font-style: normal; + font-weight: 400; + src: local(""), + url("assets/fonts/nunito-v16-latin-regular.woff2") format("woff2"); +} + +#app { + height: 100vh; + text-align: center; + overflow: hidden; + box-sizing: border-box; + padding: 10px; +} diff --git a/v2/examples/dragdrop-test/frontend/wailsjs/go/main/App.d.ts b/v2/examples/dragdrop-test/frontend/wailsjs/go/main/App.d.ts new file mode 100644 index 000000000..02a3bb988 --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/wailsjs/go/main/App.d.ts @@ -0,0 +1,4 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export function Greet(arg1:string):Promise; diff --git a/v2/examples/dragdrop-test/frontend/wailsjs/go/main/App.js b/v2/examples/dragdrop-test/frontend/wailsjs/go/main/App.js new file mode 100644 index 000000000..c71ae77cb --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/wailsjs/go/main/App.js @@ -0,0 +1,7 @@ +// @ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export function Greet(arg1) { + return window['go']['main']['App']['Greet'](arg1); +} diff --git a/v2/examples/dragdrop-test/frontend/wailsjs/runtime/package.json b/v2/examples/dragdrop-test/frontend/wailsjs/runtime/package.json new file mode 100644 index 000000000..1e7c8a5d7 --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/wailsjs/runtime/package.json @@ -0,0 +1,24 @@ +{ + "name": "@wailsapp/runtime", + "version": "2.0.0", + "description": "Wails Javascript runtime library", + "main": "runtime.js", + "types": "runtime.d.ts", + "scripts": { + }, + "repository": { + "type": "git", + "url": "git+https://github.com/wailsapp/wails.git" + }, + "keywords": [ + "Wails", + "Javascript", + "Go" + ], + "author": "Lea Anthony ", + "license": "MIT", + "bugs": { + "url": "https://github.com/wailsapp/wails/issues" + }, + "homepage": "https://github.com/wailsapp/wails#readme" +} diff --git a/v2/examples/dragdrop-test/frontend/wailsjs/runtime/runtime.d.ts b/v2/examples/dragdrop-test/frontend/wailsjs/runtime/runtime.d.ts new file mode 100644 index 000000000..4445dac21 --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/wailsjs/runtime/runtime.d.ts @@ -0,0 +1,249 @@ +/* + _ __ _ __ +| | / /___ _(_) /____ +| | /| / / __ `/ / / ___/ +| |/ |/ / /_/ / / (__ ) +|__/|__/\__,_/_/_/____/ +The electron alternative for Go +(c) Lea Anthony 2019-present +*/ + +export interface Position { + x: number; + y: number; +} + +export interface Size { + w: number; + h: number; +} + +export interface Screen { + isCurrent: boolean; + isPrimary: boolean; + width : number + height : number +} + +// Environment information such as platform, buildtype, ... +export interface EnvironmentInfo { + buildType: string; + platform: string; + arch: string; +} + +// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) +// emits the given event. Optional data may be passed with the event. +// This will trigger any event listeners. +export function EventsEmit(eventName: string, ...data: any): void; + +// [EventsOn](https://wails.io/docs/reference/runtime/events#eventson) sets up a listener for the given event name. +export function EventsOn(eventName: string, callback: (...data: any) => void): () => void; + +// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple) +// sets up a listener for the given event name, but will only trigger a given number times. +export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void; + +// [EventsOnce](https://wails.io/docs/reference/runtime/events#eventsonce) +// sets up a listener for the given event name, but will only trigger once. +export function EventsOnce(eventName: string, callback: (...data: any) => void): () => void; + +// [EventsOff](https://wails.io/docs/reference/runtime/events#eventsoff) +// unregisters the listener for the given event name. +export function EventsOff(eventName: string, ...additionalEventNames: string[]): void; + +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all listeners. +export function EventsOffAll(): void; + +// [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) +// logs the given message as a raw message +export function LogPrint(message: string): void; + +// [LogTrace](https://wails.io/docs/reference/runtime/log#logtrace) +// logs the given message at the `trace` log level. +export function LogTrace(message: string): void; + +// [LogDebug](https://wails.io/docs/reference/runtime/log#logdebug) +// logs the given message at the `debug` log level. +export function LogDebug(message: string): void; + +// [LogError](https://wails.io/docs/reference/runtime/log#logerror) +// logs the given message at the `error` log level. +export function LogError(message: string): void; + +// [LogFatal](https://wails.io/docs/reference/runtime/log#logfatal) +// logs the given message at the `fatal` log level. +// The application will quit after calling this method. +export function LogFatal(message: string): void; + +// [LogInfo](https://wails.io/docs/reference/runtime/log#loginfo) +// logs the given message at the `info` log level. +export function LogInfo(message: string): void; + +// [LogWarning](https://wails.io/docs/reference/runtime/log#logwarning) +// logs the given message at the `warning` log level. +export function LogWarning(message: string): void; + +// [WindowReload](https://wails.io/docs/reference/runtime/window#windowreload) +// Forces a reload by the main application as well as connected browsers. +export function WindowReload(): void; + +// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp) +// Reloads the application frontend. +export function WindowReloadApp(): void; + +// [WindowSetAlwaysOnTop](https://wails.io/docs/reference/runtime/window#windowsetalwaysontop) +// Sets the window AlwaysOnTop or not on top. +export function WindowSetAlwaysOnTop(b: boolean): void; + +// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) +// *Windows only* +// Sets window theme to system default (dark/light). +export function WindowSetSystemDefaultTheme(): void; + +// [WindowSetLightTheme](https://wails.io/docs/next/reference/runtime/window#windowsetlighttheme) +// *Windows only* +// Sets window to light theme. +export function WindowSetLightTheme(): void; + +// [WindowSetDarkTheme](https://wails.io/docs/next/reference/runtime/window#windowsetdarktheme) +// *Windows only* +// Sets window to dark theme. +export function WindowSetDarkTheme(): void; + +// [WindowCenter](https://wails.io/docs/reference/runtime/window#windowcenter) +// Centers the window on the monitor the window is currently on. +export function WindowCenter(): void; + +// [WindowSetTitle](https://wails.io/docs/reference/runtime/window#windowsettitle) +// Sets the text in the window title bar. +export function WindowSetTitle(title: string): void; + +// [WindowFullscreen](https://wails.io/docs/reference/runtime/window#windowfullscreen) +// Makes the window full screen. +export function WindowFullscreen(): void; + +// [WindowUnfullscreen](https://wails.io/docs/reference/runtime/window#windowunfullscreen) +// Restores the previous window dimensions and position prior to full screen. +export function WindowUnfullscreen(): void; + +// [WindowIsFullscreen](https://wails.io/docs/reference/runtime/window#windowisfullscreen) +// Returns the state of the window, i.e. whether the window is in full screen mode or not. +export function WindowIsFullscreen(): Promise; + +// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize) +// Sets the width and height of the window. +export function WindowSetSize(width: number, height: number): void; + +// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize) +// Gets the width and height of the window. +export function WindowGetSize(): Promise; + +// [WindowSetMaxSize](https://wails.io/docs/reference/runtime/window#windowsetmaxsize) +// Sets the maximum window size. Will resize the window if the window is currently larger than the given dimensions. +// Setting a size of 0,0 will disable this constraint. +export function WindowSetMaxSize(width: number, height: number): void; + +// [WindowSetMinSize](https://wails.io/docs/reference/runtime/window#windowsetminsize) +// Sets the minimum window size. Will resize the window if the window is currently smaller than the given dimensions. +// Setting a size of 0,0 will disable this constraint. +export function WindowSetMinSize(width: number, height: number): void; + +// [WindowSetPosition](https://wails.io/docs/reference/runtime/window#windowsetposition) +// Sets the window position relative to the monitor the window is currently on. +export function WindowSetPosition(x: number, y: number): void; + +// [WindowGetPosition](https://wails.io/docs/reference/runtime/window#windowgetposition) +// Gets the window position relative to the monitor the window is currently on. +export function WindowGetPosition(): Promise; + +// [WindowHide](https://wails.io/docs/reference/runtime/window#windowhide) +// Hides the window. +export function WindowHide(): void; + +// [WindowShow](https://wails.io/docs/reference/runtime/window#windowshow) +// Shows the window, if it is currently hidden. +export function WindowShow(): void; + +// [WindowMaximise](https://wails.io/docs/reference/runtime/window#windowmaximise) +// Maximises the window to fill the screen. +export function WindowMaximise(): void; + +// [WindowToggleMaximise](https://wails.io/docs/reference/runtime/window#windowtogglemaximise) +// Toggles between Maximised and UnMaximised. +export function WindowToggleMaximise(): void; + +// [WindowUnmaximise](https://wails.io/docs/reference/runtime/window#windowunmaximise) +// Restores the window to the dimensions and position prior to maximising. +export function WindowUnmaximise(): void; + +// [WindowIsMaximised](https://wails.io/docs/reference/runtime/window#windowismaximised) +// Returns the state of the window, i.e. whether the window is maximised or not. +export function WindowIsMaximised(): Promise; + +// [WindowMinimise](https://wails.io/docs/reference/runtime/window#windowminimise) +// Minimises the window. +export function WindowMinimise(): void; + +// [WindowUnminimise](https://wails.io/docs/reference/runtime/window#windowunminimise) +// Restores the window to the dimensions and position prior to minimising. +export function WindowUnminimise(): void; + +// [WindowIsMinimised](https://wails.io/docs/reference/runtime/window#windowisminimised) +// Returns the state of the window, i.e. whether the window is minimised or not. +export function WindowIsMinimised(): Promise; + +// [WindowIsNormal](https://wails.io/docs/reference/runtime/window#windowisnormal) +// Returns the state of the window, i.e. whether the window is normal or not. +export function WindowIsNormal(): Promise; + +// [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour) +// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. +export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void; + +// [ScreenGetAll](https://wails.io/docs/reference/runtime/window#screengetall) +// Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system. +export function ScreenGetAll(): Promise; + +// [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl) +// Opens the given URL in the system browser. +export function BrowserOpenURL(url: string): void; + +// [Environment](https://wails.io/docs/reference/runtime/intro#environment) +// Returns information about the environment +export function Environment(): Promise; + +// [Quit](https://wails.io/docs/reference/runtime/intro#quit) +// Quits the application. +export function Quit(): void; + +// [Hide](https://wails.io/docs/reference/runtime/intro#hide) +// Hides the application. +export function Hide(): void; + +// [Show](https://wails.io/docs/reference/runtime/intro#show) +// Shows the application. +export function Show(): void; + +// [ClipboardGetText](https://wails.io/docs/reference/runtime/clipboard#clipboardgettext) +// Returns the current text stored on clipboard +export function ClipboardGetText(): Promise; + +// [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext) +// Sets a text on the clipboard +export function ClipboardSetText(text: string): Promise; + +// [OnFileDrop](https://wails.io/docs/reference/runtime/draganddrop#onfiledrop) +// OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings. +export function OnFileDrop(callback: (x: number, y: number ,paths: string[]) => void, useDropTarget: boolean) :void + +// [OnFileDropOff](https://wails.io/docs/reference/runtime/draganddrop#dragandddropoff) +// OnFileDropOff removes the drag and drop listeners and handlers. +export function OnFileDropOff() :void + +// Check if the file path resolver is available +export function CanResolveFilePaths(): boolean; + +// Resolves file paths for an array of files +export function ResolveFilePaths(files: File[]): void \ No newline at end of file diff --git a/v2/examples/dragdrop-test/frontend/wailsjs/runtime/runtime.js b/v2/examples/dragdrop-test/frontend/wailsjs/runtime/runtime.js new file mode 100644 index 000000000..7cb89d750 --- /dev/null +++ b/v2/examples/dragdrop-test/frontend/wailsjs/runtime/runtime.js @@ -0,0 +1,242 @@ +/* + _ __ _ __ +| | / /___ _(_) /____ +| | /| / / __ `/ / / ___/ +| |/ |/ / /_/ / / (__ ) +|__/|__/\__,_/_/_/____/ +The electron alternative for Go +(c) Lea Anthony 2019-present +*/ + +export function LogPrint(message) { + window.runtime.LogPrint(message); +} + +export function LogTrace(message) { + window.runtime.LogTrace(message); +} + +export function LogDebug(message) { + window.runtime.LogDebug(message); +} + +export function LogInfo(message) { + window.runtime.LogInfo(message); +} + +export function LogWarning(message) { + window.runtime.LogWarning(message); +} + +export function LogError(message) { + window.runtime.LogError(message); +} + +export function LogFatal(message) { + window.runtime.LogFatal(message); +} + +export function EventsOnMultiple(eventName, callback, maxCallbacks) { + return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks); +} + +export function EventsOn(eventName, callback) { + return EventsOnMultiple(eventName, callback, -1); +} + +export function EventsOff(eventName, ...additionalEventNames) { + return window.runtime.EventsOff(eventName, ...additionalEventNames); +} + +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + +export function EventsOnce(eventName, callback) { + return EventsOnMultiple(eventName, callback, 1); +} + +export function EventsEmit(eventName) { + let args = [eventName].slice.call(arguments); + return window.runtime.EventsEmit.apply(null, args); +} + +export function WindowReload() { + window.runtime.WindowReload(); +} + +export function WindowReloadApp() { + window.runtime.WindowReloadApp(); +} + +export function WindowSetAlwaysOnTop(b) { + window.runtime.WindowSetAlwaysOnTop(b); +} + +export function WindowSetSystemDefaultTheme() { + window.runtime.WindowSetSystemDefaultTheme(); +} + +export function WindowSetLightTheme() { + window.runtime.WindowSetLightTheme(); +} + +export function WindowSetDarkTheme() { + window.runtime.WindowSetDarkTheme(); +} + +export function WindowCenter() { + window.runtime.WindowCenter(); +} + +export function WindowSetTitle(title) { + window.runtime.WindowSetTitle(title); +} + +export function WindowFullscreen() { + window.runtime.WindowFullscreen(); +} + +export function WindowUnfullscreen() { + window.runtime.WindowUnfullscreen(); +} + +export function WindowIsFullscreen() { + return window.runtime.WindowIsFullscreen(); +} + +export function WindowGetSize() { + return window.runtime.WindowGetSize(); +} + +export function WindowSetSize(width, height) { + window.runtime.WindowSetSize(width, height); +} + +export function WindowSetMaxSize(width, height) { + window.runtime.WindowSetMaxSize(width, height); +} + +export function WindowSetMinSize(width, height) { + window.runtime.WindowSetMinSize(width, height); +} + +export function WindowSetPosition(x, y) { + window.runtime.WindowSetPosition(x, y); +} + +export function WindowGetPosition() { + return window.runtime.WindowGetPosition(); +} + +export function WindowHide() { + window.runtime.WindowHide(); +} + +export function WindowShow() { + window.runtime.WindowShow(); +} + +export function WindowMaximise() { + window.runtime.WindowMaximise(); +} + +export function WindowToggleMaximise() { + window.runtime.WindowToggleMaximise(); +} + +export function WindowUnmaximise() { + window.runtime.WindowUnmaximise(); +} + +export function WindowIsMaximised() { + return window.runtime.WindowIsMaximised(); +} + +export function WindowMinimise() { + window.runtime.WindowMinimise(); +} + +export function WindowUnminimise() { + window.runtime.WindowUnminimise(); +} + +export function WindowSetBackgroundColour(R, G, B, A) { + window.runtime.WindowSetBackgroundColour(R, G, B, A); +} + +export function ScreenGetAll() { + return window.runtime.ScreenGetAll(); +} + +export function WindowIsMinimised() { + return window.runtime.WindowIsMinimised(); +} + +export function WindowIsNormal() { + return window.runtime.WindowIsNormal(); +} + +export function BrowserOpenURL(url) { + window.runtime.BrowserOpenURL(url); +} + +export function Environment() { + return window.runtime.Environment(); +} + +export function Quit() { + window.runtime.Quit(); +} + +export function Hide() { + window.runtime.Hide(); +} + +export function Show() { + window.runtime.Show(); +} + +export function ClipboardGetText() { + return window.runtime.ClipboardGetText(); +} + +export function ClipboardSetText(text) { + return window.runtime.ClipboardSetText(text); +} + +/** + * Callback for OnFileDrop returns a slice of file path strings when a drop is finished. + * + * @export + * @callback OnFileDropCallback + * @param {number} x - x coordinate of the drop + * @param {number} y - y coordinate of the drop + * @param {string[]} paths - A list of file paths. + */ + +/** + * OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings. + * + * @export + * @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished. + * @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target) + */ +export function OnFileDrop(callback, useDropTarget) { + return window.runtime.OnFileDrop(callback, useDropTarget); +} + +/** + * OnFileDropOff removes the drag and drop listeners and handlers. + */ +export function OnFileDropOff() { + return window.runtime.OnFileDropOff(); +} + +export function CanResolveFilePaths() { + return window.runtime.CanResolveFilePaths(); +} + +export function ResolveFilePaths(files) { + return window.runtime.ResolveFilePaths(files); +} \ No newline at end of file diff --git a/v2/examples/dragdrop-test/go.mod b/v2/examples/dragdrop-test/go.mod new file mode 100644 index 000000000..be13aac19 --- /dev/null +++ b/v2/examples/dragdrop-test/go.mod @@ -0,0 +1,37 @@ +module dragdrop-test + +go 1.23 + +require github.com/wailsapp/wails/v2 v2.10.1 + +require ( + github.com/bep/debounce v1.2.1 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/gorilla/websocket v1.5.3 // indirect + github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect + github.com/labstack/echo/v4 v4.13.3 // indirect + github.com/labstack/gommon v0.4.2 // indirect + github.com/leaanthony/go-ansi-parser v1.6.1 // indirect + github.com/leaanthony/gosod v1.0.4 // indirect + github.com/leaanthony/slicer v1.6.0 // indirect + github.com/leaanthony/u v1.1.1 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/samber/lo v1.49.1 // indirect + github.com/tkrajina/go-reflector v0.5.8 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasttemplate v1.2.2 // indirect + github.com/wailsapp/go-webview2 v1.0.22 // indirect + github.com/wailsapp/mimetype v1.4.1 // indirect + golang.org/x/crypto v0.33.0 // indirect + golang.org/x/net v0.35.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect +) + +replace github.com/wailsapp/wails/v2 => E:/releases/wails/v2 diff --git a/v2/examples/dragdrop-test/go.sum b/v2/examples/dragdrop-test/go.sum new file mode 100644 index 000000000..10d4a9b18 --- /dev/null +++ b/v2/examples/dragdrop-test/go.sum @@ -0,0 +1,79 @@ +github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY= +github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= +github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= +github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY= +github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g= +github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= +github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= +github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc= +github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA= +github.com/leaanthony/go-ansi-parser v1.6.1 h1:xd8bzARK3dErqkPFtoF9F3/HgN8UQk0ed1YDKpEz01A= +github.com/leaanthony/go-ansi-parser v1.6.1/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU= +github.com/leaanthony/gosod v1.0.4 h1:YLAbVyd591MRffDgxUOU1NwLhT9T1/YiwjKZpkNFeaI= +github.com/leaanthony/gosod v1.0.4/go.mod h1:GKuIL0zzPj3O1SdWQOdgURSuhkF+Urizzxh26t9f1cw= +github.com/leaanthony/slicer v1.6.0 h1:1RFP5uiPJvT93TAHi+ipd3NACobkW53yUiBqZheE/Js= +github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8= +github.com/leaanthony/u v1.1.1 h1:TUFjwDGlNX+WuwVEzDqQwC2lOv0P4uhTQw7CMFdiK7M= +github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI= +github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= +github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ= +github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew= +github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ= +github.com/tkrajina/go-reflector v0.5.8/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/wailsapp/go-webview2 v1.0.22 h1:YT61F5lj+GGaat5OB96Aa3b4QA+mybD0Ggq6NZijQ58= +github.com/wailsapp/go-webview2 v1.0.22/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc= +github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= +github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= +golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= +golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/v2/examples/dragdrop-test/main.go b/v2/examples/dragdrop-test/main.go new file mode 100644 index 000000000..64a0c2734 --- /dev/null +++ b/v2/examples/dragdrop-test/main.go @@ -0,0 +1,36 @@ +package main + +import ( + "embed" + + "github.com/wailsapp/wails/v2" + "github.com/wailsapp/wails/v2/pkg/options" + "github.com/wailsapp/wails/v2/pkg/options/assetserver" +) + +//go:embed all:frontend/dist +var assets embed.FS + +func main() { + // Create an instance of the app structure + app := NewApp() + + // Create application with options + err := wails.Run(&options.App{ + Title: "Wails Drag & Drop Test", + Width: 800, + Height: 600, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, + OnStartup: app.startup, + Bind: []interface{}{ + app, + }, + }) + + if err != nil { + println("Error:", err.Error()) + } +} diff --git a/v2/examples/dragdrop-test/wails.json b/v2/examples/dragdrop-test/wails.json new file mode 100644 index 000000000..7970ea4ca --- /dev/null +++ b/v2/examples/dragdrop-test/wails.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://wails.io/schemas/config.v2.json", + "name": "dragdrop-test", + "outputfilename": "dragdrop-test", + "frontend:install": "npm install", + "frontend:build": "npm run build", + "frontend:dev:watcher": "npm run dev", + "frontend:dev:serverUrl": "auto", + "author": { + "name": "Lea Anthony", + "email": "lea.anthony@gmail.com" + } +} diff --git a/v2/examples/panic-recovery-test/README.md b/v2/examples/panic-recovery-test/README.md new file mode 100644 index 000000000..c0a6a7e5a --- /dev/null +++ b/v2/examples/panic-recovery-test/README.md @@ -0,0 +1,76 @@ +# Panic Recovery Test + +This example demonstrates the Linux signal handler issue (#3965) and verifies the fix using `runtime.ResetSignalHandlers()`. + +## The Problem + +On Linux, WebKit installs signal handlers without the `SA_ONSTACK` flag, which prevents Go from recovering panics caused by nil pointer dereferences (SIGSEGV). Without the fix, the application crashes with: + +``` +signal 11 received but handler not on signal stack +fatal error: non-Go code set up signal handler without SA_ONSTACK flag +``` + +## The Solution + +Call `runtime.ResetSignalHandlers()` immediately before code that might panic: + +```go +import "github.com/wailsapp/wails/v2/pkg/runtime" + +go func() { + defer func() { + if err := recover(); err != nil { + log.Printf("Recovered: %v", err) + } + }() + runtime.ResetSignalHandlers() + // Code that might panic... +}() +``` + +## How to Reproduce + +### Prerequisites + +- Linux with WebKit2GTK 4.1 installed +- Go 1.21+ +- Wails CLI + +### Steps + +1. Build the example: + ```bash + cd v2/examples/panic-recovery-test + wails build -tags webkit2_41 + ``` + +2. Run the application: + ```bash + ./build/bin/panic-recovery-test + ``` + +3. Wait ~10 seconds (the app auto-calls `Greet` after 5s, then waits another 5s before the nil pointer dereference) + +### Expected Result (with fix) + +The panic is recovered and you see: +``` +------------------------------"invalid memory address or nil pointer dereference" +``` + +The application continues running. + +### Without the fix + +Comment out the `runtime.ResetSignalHandlers()` call in `app.go` and rebuild. The application will crash with a fatal signal 11 error. + +## Files + +- `app.go` - Contains the `Greet` function that demonstrates panic recovery +- `frontend/src/main.js` - Auto-calls `Greet` after 5 seconds to trigger the test + +## Related + +- Issue: https://github.com/wailsapp/wails/issues/3965 +- Original fix PR: https://github.com/wailsapp/wails/pull/2152 diff --git a/v2/examples/panic-recovery-test/app.go b/v2/examples/panic-recovery-test/app.go new file mode 100644 index 000000000..ceb46e8d5 --- /dev/null +++ b/v2/examples/panic-recovery-test/app.go @@ -0,0 +1,44 @@ +package main + +import ( + "context" + "fmt" + "time" + + "github.com/wailsapp/wails/v2/pkg/runtime" +) + +// App struct +type App struct { + ctx context.Context +} + +// NewApp creates a new App application struct +func NewApp() *App { + return &App{} +} + +// startup is called when the app starts. The context is saved +// so we can call the runtime methods +func (a *App) startup(ctx context.Context) { + a.ctx = ctx +} + +// Greet returns a greeting for the given name +func (a *App) Greet(name string) string { + go func() { + defer func() { + if err := recover(); err != nil { + fmt.Printf("------------------------------%#v\n", err) + } + }() + time.Sleep(5 * time.Second) + // Fix signal handlers right before potential panic using the Wails runtime + runtime.ResetSignalHandlers() + // Nil pointer dereference - causes SIGSEGV + var t *time.Time + fmt.Println(t.Unix()) + }() + + return fmt.Sprintf("Hello %s, It's show time!", name) +} diff --git a/v2/examples/panic-recovery-test/frontend/index.html b/v2/examples/panic-recovery-test/frontend/index.html new file mode 100644 index 000000000..d7aa4e942 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/index.html @@ -0,0 +1,12 @@ + + + + + + panic-test + + +
+ + + diff --git a/v2/examples/panic-recovery-test/frontend/package.json b/v2/examples/panic-recovery-test/frontend/package.json new file mode 100644 index 000000000..a1b6f8e1a --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/package.json @@ -0,0 +1,13 @@ +{ + "name": "frontend", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "devDependencies": { + "vite": "^3.0.7" + } +} \ No newline at end of file diff --git a/v2/examples/panic-recovery-test/frontend/src/app.css b/v2/examples/panic-recovery-test/frontend/src/app.css new file mode 100644 index 000000000..59d06f692 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/src/app.css @@ -0,0 +1,54 @@ +#logo { + display: block; + width: 50%; + height: 50%; + margin: auto; + padding: 10% 0 0; + background-position: center; + background-repeat: no-repeat; + background-size: 100% 100%; + background-origin: content-box; +} + +.result { + height: 20px; + line-height: 20px; + margin: 1.5rem auto; +} + +.input-box .btn { + width: 60px; + height: 30px; + line-height: 30px; + border-radius: 3px; + border: none; + margin: 0 0 0 20px; + padding: 0 8px; + cursor: pointer; +} + +.input-box .btn:hover { + background-image: linear-gradient(to top, #cfd9df 0%, #e2ebf0 100%); + color: #333333; +} + +.input-box .input { + border: none; + border-radius: 3px; + outline: none; + height: 30px; + line-height: 30px; + padding: 0 10px; + background-color: rgba(240, 240, 240, 1); + -webkit-font-smoothing: antialiased; +} + +.input-box .input:hover { + border: none; + background-color: rgba(255, 255, 255, 1); +} + +.input-box .input:focus { + border: none; + background-color: rgba(255, 255, 255, 1); +} \ No newline at end of file diff --git a/v2/examples/panic-recovery-test/frontend/src/assets/fonts/OFL.txt b/v2/examples/panic-recovery-test/frontend/src/assets/fonts/OFL.txt new file mode 100644 index 000000000..9cac04ce8 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/src/assets/fonts/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2016 The Nunito Project Authors (contact@sansoxygen.com), + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/v2/examples/panic-recovery-test/frontend/src/assets/fonts/nunito-v16-latin-regular.woff2 b/v2/examples/panic-recovery-test/frontend/src/assets/fonts/nunito-v16-latin-regular.woff2 new file mode 100644 index 000000000..2f9cc5964 Binary files /dev/null and b/v2/examples/panic-recovery-test/frontend/src/assets/fonts/nunito-v16-latin-regular.woff2 differ diff --git a/v2/examples/panic-recovery-test/frontend/src/assets/images/logo-universal.png b/v2/examples/panic-recovery-test/frontend/src/assets/images/logo-universal.png new file mode 100644 index 000000000..d63303bfa Binary files /dev/null and b/v2/examples/panic-recovery-test/frontend/src/assets/images/logo-universal.png differ diff --git a/v2/examples/panic-recovery-test/frontend/src/main.js b/v2/examples/panic-recovery-test/frontend/src/main.js new file mode 100644 index 000000000..ea5e74fc6 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/src/main.js @@ -0,0 +1,55 @@ +import './style.css'; +import './app.css'; + +import logo from './assets/images/logo-universal.png'; +import {Greet} from '../wailsjs/go/main/App'; + +document.querySelector('#app').innerHTML = ` + +
Please enter your name below 👇
+
+ + +
+ +`; +document.getElementById('logo').src = logo; + +let nameElement = document.getElementById("name"); +nameElement.focus(); +let resultElement = document.getElementById("result"); + +// Setup the greet function +window.greet = function () { + // Get name + let name = nameElement.value; + + // Check if the input is empty + if (name === "") return; + + // Call App.Greet(name) + try { + Greet(name) + .then((result) => { + // Update result with data back from App.Greet() + resultElement.innerText = result; + }) + .catch((err) => { + console.error(err); + }); + } catch (err) { + console.error(err); + } +}; + +// Auto-call Greet after 5 seconds to trigger the panic test +setTimeout(() => { + console.log("Auto-calling Greet to trigger panic test..."); + Greet("PanicTest") + .then((result) => { + resultElement.innerText = result + " (auto-called - panic will occur in 5s)"; + }) + .catch((err) => { + console.error("Error:", err); + }); +}, 5000); diff --git a/v2/examples/panic-recovery-test/frontend/src/style.css b/v2/examples/panic-recovery-test/frontend/src/style.css new file mode 100644 index 000000000..3940d6c63 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/src/style.css @@ -0,0 +1,26 @@ +html { + background-color: rgba(27, 38, 54, 1); + text-align: center; + color: white; +} + +body { + margin: 0; + color: white; + font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", + "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; +} + +@font-face { + font-family: "Nunito"; + font-style: normal; + font-weight: 400; + src: local(""), + url("assets/fonts/nunito-v16-latin-regular.woff2") format("woff2"); +} + +#app { + height: 100vh; + text-align: center; +} diff --git a/v2/examples/panic-recovery-test/frontend/wailsjs/go/main/App.d.ts b/v2/examples/panic-recovery-test/frontend/wailsjs/go/main/App.d.ts new file mode 100755 index 000000000..02a3bb988 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/wailsjs/go/main/App.d.ts @@ -0,0 +1,4 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export function Greet(arg1:string):Promise; diff --git a/v2/examples/panic-recovery-test/frontend/wailsjs/go/main/App.js b/v2/examples/panic-recovery-test/frontend/wailsjs/go/main/App.js new file mode 100755 index 000000000..c71ae77cb --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/wailsjs/go/main/App.js @@ -0,0 +1,7 @@ +// @ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export function Greet(arg1) { + return window['go']['main']['App']['Greet'](arg1); +} diff --git a/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/package.json b/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/package.json new file mode 100644 index 000000000..1e7c8a5d7 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/package.json @@ -0,0 +1,24 @@ +{ + "name": "@wailsapp/runtime", + "version": "2.0.0", + "description": "Wails Javascript runtime library", + "main": "runtime.js", + "types": "runtime.d.ts", + "scripts": { + }, + "repository": { + "type": "git", + "url": "git+https://github.com/wailsapp/wails.git" + }, + "keywords": [ + "Wails", + "Javascript", + "Go" + ], + "author": "Lea Anthony ", + "license": "MIT", + "bugs": { + "url": "https://github.com/wailsapp/wails/issues" + }, + "homepage": "https://github.com/wailsapp/wails#readme" +} diff --git a/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/runtime.d.ts b/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/runtime.d.ts new file mode 100644 index 000000000..4445dac21 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/runtime.d.ts @@ -0,0 +1,249 @@ +/* + _ __ _ __ +| | / /___ _(_) /____ +| | /| / / __ `/ / / ___/ +| |/ |/ / /_/ / / (__ ) +|__/|__/\__,_/_/_/____/ +The electron alternative for Go +(c) Lea Anthony 2019-present +*/ + +export interface Position { + x: number; + y: number; +} + +export interface Size { + w: number; + h: number; +} + +export interface Screen { + isCurrent: boolean; + isPrimary: boolean; + width : number + height : number +} + +// Environment information such as platform, buildtype, ... +export interface EnvironmentInfo { + buildType: string; + platform: string; + arch: string; +} + +// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) +// emits the given event. Optional data may be passed with the event. +// This will trigger any event listeners. +export function EventsEmit(eventName: string, ...data: any): void; + +// [EventsOn](https://wails.io/docs/reference/runtime/events#eventson) sets up a listener for the given event name. +export function EventsOn(eventName: string, callback: (...data: any) => void): () => void; + +// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple) +// sets up a listener for the given event name, but will only trigger a given number times. +export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void; + +// [EventsOnce](https://wails.io/docs/reference/runtime/events#eventsonce) +// sets up a listener for the given event name, but will only trigger once. +export function EventsOnce(eventName: string, callback: (...data: any) => void): () => void; + +// [EventsOff](https://wails.io/docs/reference/runtime/events#eventsoff) +// unregisters the listener for the given event name. +export function EventsOff(eventName: string, ...additionalEventNames: string[]): void; + +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all listeners. +export function EventsOffAll(): void; + +// [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) +// logs the given message as a raw message +export function LogPrint(message: string): void; + +// [LogTrace](https://wails.io/docs/reference/runtime/log#logtrace) +// logs the given message at the `trace` log level. +export function LogTrace(message: string): void; + +// [LogDebug](https://wails.io/docs/reference/runtime/log#logdebug) +// logs the given message at the `debug` log level. +export function LogDebug(message: string): void; + +// [LogError](https://wails.io/docs/reference/runtime/log#logerror) +// logs the given message at the `error` log level. +export function LogError(message: string): void; + +// [LogFatal](https://wails.io/docs/reference/runtime/log#logfatal) +// logs the given message at the `fatal` log level. +// The application will quit after calling this method. +export function LogFatal(message: string): void; + +// [LogInfo](https://wails.io/docs/reference/runtime/log#loginfo) +// logs the given message at the `info` log level. +export function LogInfo(message: string): void; + +// [LogWarning](https://wails.io/docs/reference/runtime/log#logwarning) +// logs the given message at the `warning` log level. +export function LogWarning(message: string): void; + +// [WindowReload](https://wails.io/docs/reference/runtime/window#windowreload) +// Forces a reload by the main application as well as connected browsers. +export function WindowReload(): void; + +// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp) +// Reloads the application frontend. +export function WindowReloadApp(): void; + +// [WindowSetAlwaysOnTop](https://wails.io/docs/reference/runtime/window#windowsetalwaysontop) +// Sets the window AlwaysOnTop or not on top. +export function WindowSetAlwaysOnTop(b: boolean): void; + +// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) +// *Windows only* +// Sets window theme to system default (dark/light). +export function WindowSetSystemDefaultTheme(): void; + +// [WindowSetLightTheme](https://wails.io/docs/next/reference/runtime/window#windowsetlighttheme) +// *Windows only* +// Sets window to light theme. +export function WindowSetLightTheme(): void; + +// [WindowSetDarkTheme](https://wails.io/docs/next/reference/runtime/window#windowsetdarktheme) +// *Windows only* +// Sets window to dark theme. +export function WindowSetDarkTheme(): void; + +// [WindowCenter](https://wails.io/docs/reference/runtime/window#windowcenter) +// Centers the window on the monitor the window is currently on. +export function WindowCenter(): void; + +// [WindowSetTitle](https://wails.io/docs/reference/runtime/window#windowsettitle) +// Sets the text in the window title bar. +export function WindowSetTitle(title: string): void; + +// [WindowFullscreen](https://wails.io/docs/reference/runtime/window#windowfullscreen) +// Makes the window full screen. +export function WindowFullscreen(): void; + +// [WindowUnfullscreen](https://wails.io/docs/reference/runtime/window#windowunfullscreen) +// Restores the previous window dimensions and position prior to full screen. +export function WindowUnfullscreen(): void; + +// [WindowIsFullscreen](https://wails.io/docs/reference/runtime/window#windowisfullscreen) +// Returns the state of the window, i.e. whether the window is in full screen mode or not. +export function WindowIsFullscreen(): Promise; + +// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize) +// Sets the width and height of the window. +export function WindowSetSize(width: number, height: number): void; + +// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize) +// Gets the width and height of the window. +export function WindowGetSize(): Promise; + +// [WindowSetMaxSize](https://wails.io/docs/reference/runtime/window#windowsetmaxsize) +// Sets the maximum window size. Will resize the window if the window is currently larger than the given dimensions. +// Setting a size of 0,0 will disable this constraint. +export function WindowSetMaxSize(width: number, height: number): void; + +// [WindowSetMinSize](https://wails.io/docs/reference/runtime/window#windowsetminsize) +// Sets the minimum window size. Will resize the window if the window is currently smaller than the given dimensions. +// Setting a size of 0,0 will disable this constraint. +export function WindowSetMinSize(width: number, height: number): void; + +// [WindowSetPosition](https://wails.io/docs/reference/runtime/window#windowsetposition) +// Sets the window position relative to the monitor the window is currently on. +export function WindowSetPosition(x: number, y: number): void; + +// [WindowGetPosition](https://wails.io/docs/reference/runtime/window#windowgetposition) +// Gets the window position relative to the monitor the window is currently on. +export function WindowGetPosition(): Promise; + +// [WindowHide](https://wails.io/docs/reference/runtime/window#windowhide) +// Hides the window. +export function WindowHide(): void; + +// [WindowShow](https://wails.io/docs/reference/runtime/window#windowshow) +// Shows the window, if it is currently hidden. +export function WindowShow(): void; + +// [WindowMaximise](https://wails.io/docs/reference/runtime/window#windowmaximise) +// Maximises the window to fill the screen. +export function WindowMaximise(): void; + +// [WindowToggleMaximise](https://wails.io/docs/reference/runtime/window#windowtogglemaximise) +// Toggles between Maximised and UnMaximised. +export function WindowToggleMaximise(): void; + +// [WindowUnmaximise](https://wails.io/docs/reference/runtime/window#windowunmaximise) +// Restores the window to the dimensions and position prior to maximising. +export function WindowUnmaximise(): void; + +// [WindowIsMaximised](https://wails.io/docs/reference/runtime/window#windowismaximised) +// Returns the state of the window, i.e. whether the window is maximised or not. +export function WindowIsMaximised(): Promise; + +// [WindowMinimise](https://wails.io/docs/reference/runtime/window#windowminimise) +// Minimises the window. +export function WindowMinimise(): void; + +// [WindowUnminimise](https://wails.io/docs/reference/runtime/window#windowunminimise) +// Restores the window to the dimensions and position prior to minimising. +export function WindowUnminimise(): void; + +// [WindowIsMinimised](https://wails.io/docs/reference/runtime/window#windowisminimised) +// Returns the state of the window, i.e. whether the window is minimised or not. +export function WindowIsMinimised(): Promise; + +// [WindowIsNormal](https://wails.io/docs/reference/runtime/window#windowisnormal) +// Returns the state of the window, i.e. whether the window is normal or not. +export function WindowIsNormal(): Promise; + +// [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour) +// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. +export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void; + +// [ScreenGetAll](https://wails.io/docs/reference/runtime/window#screengetall) +// Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system. +export function ScreenGetAll(): Promise; + +// [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl) +// Opens the given URL in the system browser. +export function BrowserOpenURL(url: string): void; + +// [Environment](https://wails.io/docs/reference/runtime/intro#environment) +// Returns information about the environment +export function Environment(): Promise; + +// [Quit](https://wails.io/docs/reference/runtime/intro#quit) +// Quits the application. +export function Quit(): void; + +// [Hide](https://wails.io/docs/reference/runtime/intro#hide) +// Hides the application. +export function Hide(): void; + +// [Show](https://wails.io/docs/reference/runtime/intro#show) +// Shows the application. +export function Show(): void; + +// [ClipboardGetText](https://wails.io/docs/reference/runtime/clipboard#clipboardgettext) +// Returns the current text stored on clipboard +export function ClipboardGetText(): Promise; + +// [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext) +// Sets a text on the clipboard +export function ClipboardSetText(text: string): Promise; + +// [OnFileDrop](https://wails.io/docs/reference/runtime/draganddrop#onfiledrop) +// OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings. +export function OnFileDrop(callback: (x: number, y: number ,paths: string[]) => void, useDropTarget: boolean) :void + +// [OnFileDropOff](https://wails.io/docs/reference/runtime/draganddrop#dragandddropoff) +// OnFileDropOff removes the drag and drop listeners and handlers. +export function OnFileDropOff() :void + +// Check if the file path resolver is available +export function CanResolveFilePaths(): boolean; + +// Resolves file paths for an array of files +export function ResolveFilePaths(files: File[]): void \ No newline at end of file diff --git a/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/runtime.js b/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/runtime.js new file mode 100644 index 000000000..7cb89d750 --- /dev/null +++ b/v2/examples/panic-recovery-test/frontend/wailsjs/runtime/runtime.js @@ -0,0 +1,242 @@ +/* + _ __ _ __ +| | / /___ _(_) /____ +| | /| / / __ `/ / / ___/ +| |/ |/ / /_/ / / (__ ) +|__/|__/\__,_/_/_/____/ +The electron alternative for Go +(c) Lea Anthony 2019-present +*/ + +export function LogPrint(message) { + window.runtime.LogPrint(message); +} + +export function LogTrace(message) { + window.runtime.LogTrace(message); +} + +export function LogDebug(message) { + window.runtime.LogDebug(message); +} + +export function LogInfo(message) { + window.runtime.LogInfo(message); +} + +export function LogWarning(message) { + window.runtime.LogWarning(message); +} + +export function LogError(message) { + window.runtime.LogError(message); +} + +export function LogFatal(message) { + window.runtime.LogFatal(message); +} + +export function EventsOnMultiple(eventName, callback, maxCallbacks) { + return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks); +} + +export function EventsOn(eventName, callback) { + return EventsOnMultiple(eventName, callback, -1); +} + +export function EventsOff(eventName, ...additionalEventNames) { + return window.runtime.EventsOff(eventName, ...additionalEventNames); +} + +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + +export function EventsOnce(eventName, callback) { + return EventsOnMultiple(eventName, callback, 1); +} + +export function EventsEmit(eventName) { + let args = [eventName].slice.call(arguments); + return window.runtime.EventsEmit.apply(null, args); +} + +export function WindowReload() { + window.runtime.WindowReload(); +} + +export function WindowReloadApp() { + window.runtime.WindowReloadApp(); +} + +export function WindowSetAlwaysOnTop(b) { + window.runtime.WindowSetAlwaysOnTop(b); +} + +export function WindowSetSystemDefaultTheme() { + window.runtime.WindowSetSystemDefaultTheme(); +} + +export function WindowSetLightTheme() { + window.runtime.WindowSetLightTheme(); +} + +export function WindowSetDarkTheme() { + window.runtime.WindowSetDarkTheme(); +} + +export function WindowCenter() { + window.runtime.WindowCenter(); +} + +export function WindowSetTitle(title) { + window.runtime.WindowSetTitle(title); +} + +export function WindowFullscreen() { + window.runtime.WindowFullscreen(); +} + +export function WindowUnfullscreen() { + window.runtime.WindowUnfullscreen(); +} + +export function WindowIsFullscreen() { + return window.runtime.WindowIsFullscreen(); +} + +export function WindowGetSize() { + return window.runtime.WindowGetSize(); +} + +export function WindowSetSize(width, height) { + window.runtime.WindowSetSize(width, height); +} + +export function WindowSetMaxSize(width, height) { + window.runtime.WindowSetMaxSize(width, height); +} + +export function WindowSetMinSize(width, height) { + window.runtime.WindowSetMinSize(width, height); +} + +export function WindowSetPosition(x, y) { + window.runtime.WindowSetPosition(x, y); +} + +export function WindowGetPosition() { + return window.runtime.WindowGetPosition(); +} + +export function WindowHide() { + window.runtime.WindowHide(); +} + +export function WindowShow() { + window.runtime.WindowShow(); +} + +export function WindowMaximise() { + window.runtime.WindowMaximise(); +} + +export function WindowToggleMaximise() { + window.runtime.WindowToggleMaximise(); +} + +export function WindowUnmaximise() { + window.runtime.WindowUnmaximise(); +} + +export function WindowIsMaximised() { + return window.runtime.WindowIsMaximised(); +} + +export function WindowMinimise() { + window.runtime.WindowMinimise(); +} + +export function WindowUnminimise() { + window.runtime.WindowUnminimise(); +} + +export function WindowSetBackgroundColour(R, G, B, A) { + window.runtime.WindowSetBackgroundColour(R, G, B, A); +} + +export function ScreenGetAll() { + return window.runtime.ScreenGetAll(); +} + +export function WindowIsMinimised() { + return window.runtime.WindowIsMinimised(); +} + +export function WindowIsNormal() { + return window.runtime.WindowIsNormal(); +} + +export function BrowserOpenURL(url) { + window.runtime.BrowserOpenURL(url); +} + +export function Environment() { + return window.runtime.Environment(); +} + +export function Quit() { + window.runtime.Quit(); +} + +export function Hide() { + window.runtime.Hide(); +} + +export function Show() { + window.runtime.Show(); +} + +export function ClipboardGetText() { + return window.runtime.ClipboardGetText(); +} + +export function ClipboardSetText(text) { + return window.runtime.ClipboardSetText(text); +} + +/** + * Callback for OnFileDrop returns a slice of file path strings when a drop is finished. + * + * @export + * @callback OnFileDropCallback + * @param {number} x - x coordinate of the drop + * @param {number} y - y coordinate of the drop + * @param {string[]} paths - A list of file paths. + */ + +/** + * OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings. + * + * @export + * @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished. + * @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target) + */ +export function OnFileDrop(callback, useDropTarget) { + return window.runtime.OnFileDrop(callback, useDropTarget); +} + +/** + * OnFileDropOff removes the drag and drop listeners and handlers. + */ +export function OnFileDropOff() { + return window.runtime.OnFileDropOff(); +} + +export function CanResolveFilePaths() { + return window.runtime.CanResolveFilePaths(); +} + +export function ResolveFilePaths(files) { + return window.runtime.ResolveFilePaths(files); +} \ No newline at end of file diff --git a/v2/examples/panic-recovery-test/go.mod b/v2/examples/panic-recovery-test/go.mod new file mode 100644 index 000000000..026042cbf --- /dev/null +++ b/v2/examples/panic-recovery-test/go.mod @@ -0,0 +1,5 @@ +module panic-recovery-test + +go 1.21 + +require github.com/wailsapp/wails/v2 v2.11.0 diff --git a/v2/examples/panic-recovery-test/main.go b/v2/examples/panic-recovery-test/main.go new file mode 100644 index 000000000..f6a38e86c --- /dev/null +++ b/v2/examples/panic-recovery-test/main.go @@ -0,0 +1,36 @@ +package main + +import ( + "embed" + + "github.com/wailsapp/wails/v2" + "github.com/wailsapp/wails/v2/pkg/options" + "github.com/wailsapp/wails/v2/pkg/options/assetserver" +) + +//go:embed all:frontend/dist +var assets embed.FS + +func main() { + // Create an instance of the app structure + app := NewApp() + + // Create application with options + err := wails.Run(&options.App{ + Title: "panic-test", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, + OnStartup: app.startup, + Bind: []interface{}{ + app, + }, + }) + + if err != nil { + println("Error:", err.Error()) + } +} diff --git a/v2/examples/panic-recovery-test/wails.json b/v2/examples/panic-recovery-test/wails.json new file mode 100644 index 000000000..56770f091 --- /dev/null +++ b/v2/examples/panic-recovery-test/wails.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://wails.io/schemas/config.v2.json", + "name": "panic-recovery-test", + "outputfilename": "panic-recovery-test", + "frontend:install": "npm install", + "frontend:build": "npm run build", + "frontend:dev:watcher": "npm run dev", + "frontend:dev:serverUrl": "auto", + "author": { + "name": "Lea Anthony", + "email": "lea.anthony@gmail.com" + } +} diff --git a/v2/go.mod b/v2/go.mod index 1a40badd2..f1287bde7 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -17,7 +17,7 @@ require ( github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.3 github.com/jackmordaunt/icns v1.0.0 - github.com/jaypipes/ghw v0.13.0 + github.com/jaypipes/ghw v0.21.3 github.com/labstack/echo/v4 v4.13.3 github.com/labstack/gommon v0.4.2 github.com/leaanthony/clir v1.3.0 @@ -51,9 +51,9 @@ require ( atomicgo.dev/keyboard v0.2.9 // indirect atomicgo.dev/schedule v0.1.0 // indirect dario.cat/mergo v1.0.0 // indirect + git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v1.1.5 // indirect - github.com/StackExchange/wmi v1.2.1 // indirect github.com/alecthomas/chroma/v2 v2.14.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect @@ -72,7 +72,7 @@ require ( github.com/gorilla/css v1.0.1 // indirect github.com/itchyny/gojq v0.12.13 // indirect github.com/itchyny/timefmt-go v0.1.5 // indirect - github.com/jaypipes/pcidb v1.0.1 // indirect + github.com/jaypipes/pcidb v1.1.1 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect @@ -82,7 +82,6 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/microcosm-cc/bluemonday v1.0.27 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect @@ -101,6 +100,7 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yuin/goldmark v1.7.4 // indirect github.com/yuin/goldmark-emoji v1.0.3 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect golang.org/x/crypto v0.33.0 // indirect golang.org/x/image v0.12.0 // indirect golang.org/x/sync v0.11.0 // indirect @@ -108,6 +108,6 @@ require ( golang.org/x/text v0.22.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - howett.net/plist v1.0.0 // indirect + howett.net/plist v1.0.2-0.20250314012144-ee69052608d9 // indirect mvdan.cc/sh/v3 v3.7.0 // indirect ) diff --git a/v2/go.sum b/v2/go.sum index 53e56707e..2cfe9f7ab 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -8,6 +8,8 @@ atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs= atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 h1:N3IGoHHp9pb6mj1cbXbuaSXV/UMKwmbKLf53nQmtqMA= +git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3/go.mod h1:QtOLZGz8olr4qH2vWK0QH0w0O4T9fEIjMuWpKUsH7nc= github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs= github.com/MarvinJWendt/testza v0.2.1/go.mod h1:God7bhG8n6uQxwdScay+gjm9/LnO4D3kkcZX4hv9Rp8= github.com/MarvinJWendt/testza v0.2.8/go.mod h1:nwIcjmr0Zz+Rcwfh3/4UhBp7ePKVhuBExvZqnKYWlII= @@ -24,8 +26,6 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/ProtonMail/go-crypto v1.1.5 h1:eoAQfK2dwL+tFSFpr7TbOaPNUbPiJj4fLYwwGE1FQO4= github.com/ProtonMail/go-crypto v1.1.5/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= -github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= -github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= @@ -88,7 +88,7 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= github.com/go-git/go-git/v5 v5.13.2 h1:7O7xvsK7K+rZPKW6AQR1YyNhfywkv7B8/FsP3ki6Zv0= github.com/go-git/go-git/v5 v5.13.2/go.mod h1:hWdW5P4YZRjmpGHwRH2v3zkWcNl6HeXaXQEMGb3NJ9A= -github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= @@ -117,10 +117,10 @@ github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8= github.com/jackmordaunt/icns v1.0.0 h1:RYSxplerf/l/DUd09AHtITwckkv/mqjVv4DjYdPmAMQ= github.com/jackmordaunt/icns v1.0.0/go.mod h1:7TTQVEuGzVVfOPPlLNHJIkzA6CoV7aH1Dv9dW351oOo= -github.com/jaypipes/ghw v0.13.0 h1:log8MXuB8hzTNnSktqpXMHc0c/2k/WgjOMSUtnI1RV4= -github.com/jaypipes/ghw v0.13.0/go.mod h1:In8SsaDqlb1oTyrbmTC14uy+fbBMvp+xdqX51MidlD8= -github.com/jaypipes/pcidb v1.0.1 h1:WB2zh27T3nwg8AE8ei81sNRb9yWBii3JGNJtT7K9Oic= -github.com/jaypipes/pcidb v1.0.1/go.mod h1:6xYUz/yYEyOkIkUt2t2J2folIuZ4Yg6uByCGFXMCeE4= +github.com/jaypipes/ghw v0.21.3 h1:v5mUHM+RN854Vqmk49Uh213jyUA4+8uqaRajlYESsh8= +github.com/jaypipes/ghw v0.21.3/go.mod h1:GPrvwbtPoxYUenr74+nAnWbardIZq600vJDD5HnPsPE= +github.com/jaypipes/pcidb v1.1.1 h1:QmPhpsbmmnCwZmHeYAATxEaoRuiMAJusKYkUncMC0ro= +github.com/jaypipes/pcidb v1.1.1/go.mod h1:x27LT2krrUgjf875KxQXKB0Ha/YXLdZRVmw6hH0G7g8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= @@ -178,8 +178,6 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a h1:2MaM6YC3mGu54x+RKAA6JiFFHlHDY1UbkxqppT7wYOg= @@ -263,6 +261,8 @@ github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg= github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark-emoji v1.0.3 h1:aLRkLHOuBR2czCY4R8olwMjID+tENfhyFDMCRhbIQY4= github.com/yuin/goldmark-emoji v1.0.3/go.mod h1:tTkZEbwu5wkPmgTcitqddVxY9osFZiavD+r4AzQrh1U= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -340,7 +340,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -348,7 +347,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= -howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= +howett.net/plist v1.0.2-0.20250314012144-ee69052608d9 h1:eeH1AIcPvSc0Z25ThsYF+Xoqbn0CI/YnXVYoTLFdGQw= +howett.net/plist v1.0.2-0.20250314012144-ee69052608d9/go.mod h1:fyFX5Hj5tP1Mpk8obqA9MZgXT416Q5711SDT7dQLTLk= mvdan.cc/sh/v3 v3.7.0 h1:lSTjdP/1xsddtaKfGg7Myu7DnlHItd3/M2tomOcNNBg= mvdan.cc/sh/v3 v3.7.0/go.mod h1:K2gwkaesF/D7av7Kxl0HbF5kGOd2ArupNTX3X44+8l8= diff --git a/v2/internal/binding/binding.go b/v2/internal/binding/binding.go index 4908635e1..b7bf07ae0 100644 --- a/v2/internal/binding/binding.go +++ b/v2/internal/binding/binding.go @@ -123,7 +123,15 @@ func (b *Bindings) GenerateModels() ([]byte, error) { // if we have enums for this package, add them as well var enums, enumsExist = b.enumsToGenerateTS[packageName] if enumsExist { - for enumName, enum := range enums { + // Sort the enum names first to make the output deterministic + sortedEnumNames := make([]string, 0, len(enums)) + for enumName := range enums { + sortedEnumNames = append(sortedEnumNames, enumName) + } + sort.Strings(sortedEnumNames) + + for _, enumName := range sortedEnumNames { + enum := enums[enumName] fqemumname := packageName + "." + enumName if seen.Contains(fqemumname) { continue @@ -172,7 +180,7 @@ func (b *Bindings) GenerateModels() ([]byte, error) { } // Sort the package names first to make the output deterministic - sortedPackageNames := make([]string, 0) + sortedPackageNames := make([]string, 0, len(models)) for packageName := range models { sortedPackageNames = append(sortedPackageNames, packageName) } diff --git a/v2/internal/binding/binding_test/binding_enum_ordering_test.go b/v2/internal/binding/binding_test/binding_enum_ordering_test.go new file mode 100644 index 000000000..0939535ec --- /dev/null +++ b/v2/internal/binding/binding_test/binding_enum_ordering_test.go @@ -0,0 +1,271 @@ +package binding_test + +// Test for PR #4664: Fix generated enums ordering +// This test ensures that enum output is deterministic regardless of map iteration order + +// ZFirstEnum - named with Z prefix to test alphabetical sorting +type ZFirstEnum int + +const ( + ZFirstEnumValue1 ZFirstEnum = iota + ZFirstEnumValue2 +) + +var AllZFirstEnumValues = []struct { + Value ZFirstEnum + TSName string +}{ + {ZFirstEnumValue1, "ZValue1"}, + {ZFirstEnumValue2, "ZValue2"}, +} + +// ASecondEnum - named with A prefix to test alphabetical sorting +type ASecondEnum int + +const ( + ASecondEnumValue1 ASecondEnum = iota + ASecondEnumValue2 +) + +var AllASecondEnumValues = []struct { + Value ASecondEnum + TSName string +}{ + {ASecondEnumValue1, "AValue1"}, + {ASecondEnumValue2, "AValue2"}, +} + +// MMiddleEnum - named with M prefix to test alphabetical sorting +type MMiddleEnum int + +const ( + MMiddleEnumValue1 MMiddleEnum = iota + MMiddleEnumValue2 +) + +var AllMMiddleEnumValues = []struct { + Value MMiddleEnum + TSName string +}{ + {MMiddleEnumValue1, "MValue1"}, + {MMiddleEnumValue2, "MValue2"}, +} + +type EntityWithMultipleEnums struct { + Name string `json:"name"` + EnumZ ZFirstEnum `json:"enumZ"` + EnumA ASecondEnum `json:"enumA"` + EnumM MMiddleEnum `json:"enumM"` +} + +func (e EntityWithMultipleEnums) Get() EntityWithMultipleEnums { + return e +} + +// EnumOrderingTest tests that multiple enums in the same package are output +// in alphabetical order by enum name. Before PR #4664, the order was +// non-deterministic due to Go map iteration order. +var EnumOrderingTest = BindingTest{ + name: "EnumOrderingTest", + structs: []interface{}{ + &EntityWithMultipleEnums{}, + }, + enums: []interface{}{ + // Intentionally add enums in non-alphabetical order + AllZFirstEnumValues, + AllASecondEnumValues, + AllMMiddleEnumValues, + }, + exemptions: nil, + shouldError: false, + TsGenerationOptionsTest: TsGenerationOptionsTest{ + TsPrefix: "", + TsSuffix: "", + }, + // Expected output should have enums in alphabetical order: ASecondEnum, MMiddleEnum, ZFirstEnum + want: `export namespace binding_test { + + export enum ASecondEnum { + AValue1 = 0, + AValue2 = 1, + } + export enum MMiddleEnum { + MValue1 = 0, + MValue2 = 1, + } + export enum ZFirstEnum { + ZValue1 = 0, + ZValue2 = 1, + } + export class EntityWithMultipleEnums { + name: string; + enumZ: ZFirstEnum; + enumA: ASecondEnum; + enumM: MMiddleEnum; + + static createFrom(source: any = {}) { + return new EntityWithMultipleEnums(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.name = source["name"]; + this.enumZ = source["enumZ"]; + this.enumA = source["enumA"]; + this.enumM = source["enumM"]; + } + } + +} +`, +} + +// EnumElementOrderingEnum tests sorting of enum elements by TSName +type EnumElementOrderingEnum string + +const ( + EnumElementZ EnumElementOrderingEnum = "z_value" + EnumElementA EnumElementOrderingEnum = "a_value" + EnumElementM EnumElementOrderingEnum = "m_value" +) + +// AllEnumElementOrderingValues intentionally lists values out of alphabetical order +// to test that AddEnum sorts them +var AllEnumElementOrderingValues = []struct { + Value EnumElementOrderingEnum + TSName string +}{ + {EnumElementZ, "Zebra"}, + {EnumElementA, "Apple"}, + {EnumElementM, "Mango"}, +} + +type EntityWithUnorderedEnumElements struct { + Name string `json:"name"` + Enum EnumElementOrderingEnum `json:"enum"` +} + +func (e EntityWithUnorderedEnumElements) Get() EntityWithUnorderedEnumElements { + return e +} + +// EnumElementOrderingTest tests that enum elements are sorted alphabetically +// by their TSName within an enum. Before PR #4664, elements appeared in the +// order they were added, which could be arbitrary. +var EnumElementOrderingTest = BindingTest{ + name: "EnumElementOrderingTest", + structs: []interface{}{ + &EntityWithUnorderedEnumElements{}, + }, + enums: []interface{}{ + AllEnumElementOrderingValues, + }, + exemptions: nil, + shouldError: false, + TsGenerationOptionsTest: TsGenerationOptionsTest{ + TsPrefix: "", + TsSuffix: "", + }, + // Expected output should have enum elements sorted: Apple, Mango, Zebra + want: `export namespace binding_test { + + export enum EnumElementOrderingEnum { + Apple = "a_value", + Mango = "m_value", + Zebra = "z_value", + } + export class EntityWithUnorderedEnumElements { + name: string; + enum: EnumElementOrderingEnum; + + static createFrom(source: any = {}) { + return new EntityWithUnorderedEnumElements(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.name = source["name"]; + this.enum = source["enum"]; + } + } + +} +`, +} + +// TSNameEnumElementOrdering tests sorting with TSName() method enum +type TSNameEnumElementOrdering string + +const ( + TSNameEnumZ TSNameEnumElementOrdering = "z_value" + TSNameEnumA TSNameEnumElementOrdering = "a_value" + TSNameEnumM TSNameEnumElementOrdering = "m_value" +) + +func (v TSNameEnumElementOrdering) TSName() string { + switch v { + case TSNameEnumZ: + return "Zebra" + case TSNameEnumA: + return "Apple" + case TSNameEnumM: + return "Mango" + default: + return "Unknown" + } +} + +// AllTSNameEnumValues intentionally out of order +var AllTSNameEnumValues = []TSNameEnumElementOrdering{TSNameEnumZ, TSNameEnumA, TSNameEnumM} + +type EntityWithTSNameEnumOrdering struct { + Name string `json:"name"` + Enum TSNameEnumElementOrdering `json:"enum"` +} + +func (e EntityWithTSNameEnumOrdering) Get() EntityWithTSNameEnumOrdering { + return e +} + +// TSNameEnumElementOrderingTest tests that enums using TSName() method +// also have their elements sorted alphabetically by the TSName. +var TSNameEnumElementOrderingTest = BindingTest{ + name: "TSNameEnumElementOrderingTest", + structs: []interface{}{ + &EntityWithTSNameEnumOrdering{}, + }, + enums: []interface{}{ + AllTSNameEnumValues, + }, + exemptions: nil, + shouldError: false, + TsGenerationOptionsTest: TsGenerationOptionsTest{ + TsPrefix: "", + TsSuffix: "", + }, + // Expected output should have enum elements sorted: Apple, Mango, Zebra + want: `export namespace binding_test { + + export enum TSNameEnumElementOrdering { + Apple = "a_value", + Mango = "m_value", + Zebra = "z_value", + } + export class EntityWithTSNameEnumOrdering { + name: string; + enum: TSNameEnumElementOrdering; + + static createFrom(source: any = {}) { + return new EntityWithTSNameEnumOrdering(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.name = source["name"]; + this.enum = source["enum"]; + } + } + +} +`, +} diff --git a/v2/internal/binding/binding_test/binding_test.go b/v2/internal/binding/binding_test/binding_test.go index d358d8b0f..41f0618ce 100644 --- a/v2/internal/binding/binding_test/binding_test.go +++ b/v2/internal/binding/binding_test/binding_test.go @@ -55,6 +55,10 @@ func TestBindings_GenerateModels(t *testing.T) { Generics2Test, IgnoredTest, DeepElementsTest, + // PR #4664: Enum ordering tests + EnumOrderingTest, + EnumElementOrderingTest, + TSNameEnumElementOrderingTest, } testLogger := &logger.Logger{} diff --git a/v2/internal/frontend/desktop/darwin/AppDelegate.m b/v2/internal/frontend/desktop/darwin/AppDelegate.m index 318c333d8..a73ec3ec3 100644 --- a/v2/internal/frontend/desktop/darwin/AppDelegate.m +++ b/v2/internal/frontend/desktop/darwin/AppDelegate.m @@ -9,6 +9,7 @@ #import #import "AppDelegate.h" +#import "CustomProtocol.h" #import "message.h" @implementation AppDelegate @@ -19,6 +20,17 @@ return YES; } +- (BOOL)application:(NSApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray> * _Nullable))restorationHandler { + if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) { + NSURL *url = userActivity.webpageURL; + if (url) { + HandleOpenURL((char*)[[url absoluteString] UTF8String]); + return YES; + } + } + return NO; +} + - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender { return NO; } diff --git a/v2/internal/frontend/desktop/darwin/Application.h b/v2/internal/frontend/desktop/darwin/Application.h index 4d8bbd37b..c3cd8075a 100644 --- a/v2/internal/frontend/desktop/darwin/Application.h +++ b/v2/internal/frontend/desktop/darwin/Application.h @@ -69,6 +69,21 @@ void UpdateMenuItem(void* nsmenuitem, int checked); void RunMainLoop(void); void ReleaseContext(void *inctx); +/* Notifications */ +bool IsNotificationAvailable(void *inctx); +bool CheckBundleIdentifier(void *inctx); +bool EnsureDelegateInitialized(void *inctx); +void RequestNotificationAuthorization(void *inctx, int channelID); +void CheckNotificationAuthorization(void *inctx, int channelID); +void SendNotification(void *inctx, int channelID, const char *identifier, const char *title, const char *subtitle, const char *body, const char *data_json); +void SendNotificationWithActions(void *inctx, int channelID, const char *identifier, const char *title, const char *subtitle, const char *body, const char *categoryId, const char *actions_json); +void RegisterNotificationCategory(void *inctx, int channelID, const char *categoryId, const char *actions_json, bool hasReplyField, const char *replyPlaceholder, const char *replyButtonTitle); +void RemoveNotificationCategory(void *inctx, int channelID, const char *categoryId); +void RemoveAllPendingNotifications(void *inctx); +void RemovePendingNotification(void *inctx, const char *identifier); +void RemoveAllDeliveredNotifications(void *inctx); +void RemoveDeliveredNotification(void *inctx, const char *identifier); + NSString* safeInit(const char* input); #endif /* Application_h */ diff --git a/v2/internal/frontend/desktop/darwin/Application.m b/v2/internal/frontend/desktop/darwin/Application.m index 38d349c2c..38b2f35ef 100644 --- a/v2/internal/frontend/desktop/darwin/Application.m +++ b/v2/internal/frontend/desktop/darwin/Application.m @@ -367,6 +367,74 @@ void AppendSeparator(void* inMenu) { } +bool IsNotificationAvailable(void *inctx) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + return [ctx IsNotificationAvailable]; +} + +bool CheckBundleIdentifier(void *inctx) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + return [ctx CheckBundleIdentifier]; +} + +bool EnsureDelegateInitialized(void *inctx) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + return [ctx EnsureDelegateInitialized]; +} + +void RequestNotificationAuthorization(void *inctx, int channelID) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + [ctx RequestNotificationAuthorization:channelID]; +} + +void CheckNotificationAuthorization(void *inctx, int channelID) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + [ctx CheckNotificationAuthorization:channelID]; +} + +void SendNotification(void *inctx, int channelID, const char *identifier, const char *title, const char *subtitle, const char *body, const char *data_json) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + [ctx SendNotification:channelID :identifier :title :subtitle :body :data_json]; +} + +void SendNotificationWithActions(void *inctx, int channelID, const char *identifier, const char *title, const char *subtitle, const char *body, const char *categoryId, const char *actions_json) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + + [ctx SendNotificationWithActions:channelID :identifier :title :subtitle :body :categoryId :actions_json]; +} + +void RegisterNotificationCategory(void *inctx, int channelID, const char *categoryId, const char *actions_json, bool hasReplyField, const char *replyPlaceholder, const char *replyButtonTitle) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + + [ctx RegisterNotificationCategory:channelID :categoryId :actions_json :hasReplyField :replyPlaceholder :replyButtonTitle]; +} + +void RemoveNotificationCategory(void *inctx, int channelID, const char *categoryId) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + + [ctx RemoveNotificationCategory:channelID :categoryId]; +} + +void RemoveAllPendingNotifications(void *inctx) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + [ctx RemoveAllPendingNotifications]; +} + +void RemovePendingNotification(void *inctx, const char *identifier) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + [ctx RemovePendingNotification:identifier]; +} + +void RemoveAllDeliveredNotifications(void *inctx) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + [ctx RemoveAllDeliveredNotifications]; +} + +void RemoveDeliveredNotification(void *inctx, const char *identifier) { + WailsContext *ctx = (__bridge WailsContext*)inctx; + [ctx RemoveDeliveredNotification:identifier]; +} + void Run(void *inctx, const char* url) { WailsContext *ctx = (__bridge WailsContext*) inctx; diff --git a/v2/internal/frontend/desktop/darwin/CustomProtocol.h b/v2/internal/frontend/desktop/darwin/CustomProtocol.h index da0e7079f..0698a4d45 100644 --- a/v2/internal/frontend/desktop/darwin/CustomProtocol.h +++ b/v2/internal/frontend/desktop/darwin/CustomProtocol.h @@ -3,7 +3,7 @@ #import -extern void HandleCustomProtocol(char*); +extern void HandleOpenURL(char*); @interface CustomProtocolSchemeHandler : NSObject + (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent; diff --git a/v2/internal/frontend/desktop/darwin/CustomProtocol.m b/v2/internal/frontend/desktop/darwin/CustomProtocol.m index 7365e4f50..ebc61aa00 100644 --- a/v2/internal/frontend/desktop/darwin/CustomProtocol.m +++ b/v2/internal/frontend/desktop/darwin/CustomProtocol.m @@ -6,7 +6,7 @@ NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; - HandleCustomProtocol((char*)[[[event paramDescriptorForKeyword:keyDirectObject] stringValue] UTF8String]); + HandleOpenURL((char*)[[[event paramDescriptorForKeyword:keyDirectObject] stringValue] UTF8String]); } @end diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.h b/v2/internal/frontend/desktop/darwin/WailsContext.h index 2ec6d8707..aafc3a1d4 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.h +++ b/v2/internal/frontend/desktop/darwin/WailsContext.h @@ -92,10 +92,24 @@ struct Preferences { - (void) ShowApplication; - (void) Quit; --(void) MessageDialog :(NSString*)dialogType :(NSString*)title :(NSString*)message :(NSString*)button1 :(NSString*)button2 :(NSString*)button3 :(NSString*)button4 :(NSString*)defaultButton :(NSString*)cancelButton :(void*)iconData :(int)iconDataLength; +- (void) MessageDialog :(NSString*)dialogType :(NSString*)title :(NSString*)message :(NSString*)button1 :(NSString*)button2 :(NSString*)button3 :(NSString*)button4 :(NSString*)defaultButton :(NSString*)cancelButton :(void*)iconData :(int)iconDataLength; - (void) OpenFileDialog :(NSString*)title :(NSString*)defaultFilename :(NSString*)defaultDirectory :(bool)allowDirectories :(bool)allowFiles :(bool)canCreateDirectories :(bool)treatPackagesAsDirectories :(bool)resolveAliases :(bool)showHiddenFiles :(bool)allowMultipleSelection :(NSString*)filters; - (void) SaveFileDialog :(NSString*)title :(NSString*)defaultFilename :(NSString*)defaultDirectory :(bool)canCreateDirectories :(bool)treatPackagesAsDirectories :(bool)showHiddenFiles :(NSString*)filters; +- (bool) IsNotificationAvailable; +- (bool) CheckBundleIdentifier; +- (bool) EnsureDelegateInitialized; +- (void) RequestNotificationAuthorization:(int)channelID; +- (void) CheckNotificationAuthorization:(int)channelID; +- (void) SendNotification:(int)channelID :(const char *)identifier :(const char *)title :(const char *)subtitle :(const char *)body :(const char *)dataJSON; +- (void) SendNotificationWithActions:(int)channelID :(const char *)identifier :(const char *)title :(const char *)subtitle :(const char *)body :(const char *)categoryId :(const char *)actionsJSON; +- (void) RegisterNotificationCategory:(int)channelID :(const char *)categoryId :(const char *)actionsJSON :(bool)hasReplyField :(const char *)replyPlaceholder :(const char *)replyButtonTitle; +- (void) RemoveNotificationCategory:(int)channelID :(const char *)categoryId; +- (void) RemoveAllPendingNotifications; +- (void) RemovePendingNotification:(const char *)identifier; +- (void) RemoveAllDeliveredNotifications; +- (void) RemoveDeliveredNotification:(const char *)identifier; + - (void) loadRequest:(NSString*)url; - (void) ExecJS:(NSString*)script; - (NSScreen*) getCurrentScreen; diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.m b/v2/internal/frontend/desktop/darwin/WailsContext.m index 1a3f5ef7d..51993eda2 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.m +++ b/v2/internal/frontend/desktop/darwin/WailsContext.m @@ -5,6 +5,7 @@ // Created by Lea Anthony on 10/10/21. // +#include "Application.h" #import #import #import "WailsContext.h" @@ -36,6 +37,14 @@ typedef void (^schemeTaskCaller)(id); @end +// Notifications +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 +#import +#endif + +extern void captureResult(int channelID, bool success, const char* error); +extern void didReceiveNotificationResponse(const char *jsonPayload, const char* error); + @implementation WailsContext - (void) SetSize:(int)width :(int)height { @@ -215,7 +224,13 @@ typedef void (^schemeTaskCaller)(id); // Webview stuff here! WKWebViewConfiguration *config = [WKWebViewConfiguration new]; - config.suppressesIncrementalRendering = true; + // Disable suppressesIncrementalRendering on macOS 26+ to prevent WebView crashes + // during rapid UI updates. See: https://github.com/wailsapp/wails/issues/4592 + if (@available(macOS 26.0, *)) { + config.suppressesIncrementalRendering = false; + } else { + config.suppressesIncrementalRendering = true; + } config.applicationNameForUserAgent = @"wails.io"; [config setURLSchemeHandler:self forURLScheme:@"wails"]; @@ -717,6 +732,357 @@ typedef void (^schemeTaskCaller)(id); } +/***** Notifications ******/ +- (bool) IsNotificationAvailable { + if (@available(macOS 10.14, *)) { + return YES; + } else { + return NO; + } +} + +- (bool) CheckBundleIdentifier { + NSBundle *main = [NSBundle mainBundle]; + if (main.bundleIdentifier == nil) { + return NO; + } + return YES; +} + +- (void)userNotificationCenter:(UNUserNotificationCenter *)center + willPresentNotification:(UNNotification *)notification + withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler API_AVAILABLE(macos(10.14)) { + UNNotificationPresentationOptions options = UNNotificationPresentationOptionSound; + + if (@available(macOS 11.0, *)) { + // These options are only available in macOS 11.0+ + options = UNNotificationPresentationOptionList | + UNNotificationPresentationOptionBanner | + UNNotificationPresentationOptionSound; + } + + completionHandler(options); +} + +- (void)userNotificationCenter:(UNUserNotificationCenter *)center +didReceiveNotificationResponse:(UNNotificationResponse *)response + withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(macos(10.14)) { + + NSMutableDictionary *payload = [NSMutableDictionary dictionary]; + + [payload setObject:response.notification.request.identifier forKey:@"id"]; + [payload setObject:response.actionIdentifier forKey:@"actionIdentifier"]; + [payload setObject:response.notification.request.content.title ?: @"" forKey:@"title"]; + [payload setObject:response.notification.request.content.body ?: @"" forKey:@"body"]; + + if (response.notification.request.content.categoryIdentifier) { + [payload setObject:response.notification.request.content.categoryIdentifier forKey:@"categoryId"]; + } + + if (response.notification.request.content.subtitle) { + [payload setObject:response.notification.request.content.subtitle forKey:@"subtitle"]; + } + + if (response.notification.request.content.userInfo) { + [payload setObject:response.notification.request.content.userInfo forKey:@"userInfo"]; + } + + if ([response isKindOfClass:[UNTextInputNotificationResponse class]]) { + UNTextInputNotificationResponse *textResponse = (UNTextInputNotificationResponse *)response; + [payload setObject:textResponse.userText forKey:@"userText"]; + } + + NSError *error = nil; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:payload options:0 error:&error]; + if (error) { + NSString *errorMsg = [NSString stringWithFormat:@"Error: %@", [error localizedDescription]]; + didReceiveNotificationResponse(NULL, [errorMsg UTF8String]); + } else { + NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + didReceiveNotificationResponse([jsonString UTF8String], NULL); + } + + completionHandler(); +} + +- (bool) EnsureDelegateInitialized { + if (@available(macOS 10.14, *)) { + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + center.delegate = (id)self; + return YES; + } + return NO; +} + +- (void) RequestNotificationAuthorization :(int)channelID { + if (@available(macOS 10.14, *)) { + if (![self EnsureDelegateInitialized]) { + NSString *errorMsg = @"Notification delegate has been lost. Reinitialize the notification service."; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + UNAuthorizationOptions options = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge; + + [center requestAuthorizationWithOptions:options completionHandler:^(BOOL granted, NSError * _Nullable error) { + if (error) { + NSString *errorMsg = [NSString stringWithFormat:@"Error: %@", [error localizedDescription]]; + captureResult(channelID, false, [errorMsg UTF8String]); + } else { + captureResult(channelID, granted, NULL); + } + }]; + } else { + captureResult(channelID, false, "Notifications not available on macOS versions prior to 10.14"); + } +} + +- (void) CheckNotificationAuthorization :(int) channelID { + if (@available(macOS 10.14, *)) { + if (![self EnsureDelegateInitialized]) { + NSString *errorMsg = @"Notification delegate has been lost. Reinitialize the notification service."; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings *settings) { + BOOL isAuthorized = (settings.authorizationStatus == UNAuthorizationStatusAuthorized); + captureResult(channelID, isAuthorized, NULL); + }]; + } else { + captureResult(channelID, false, "Notifications not available on macOS versions prior to 10.14"); + } +} + +- (UNMutableNotificationContent *)createNotificationContent:(const char *)title subtitle:(const char *)subtitle body:(const char *)body dataJSON:(const char *)dataJSON error:(NSError **)contentError API_AVAILABLE(macos(10.14)) { + if (title == NULL) title = ""; + if (body == NULL) body = ""; + + NSString *nsTitle = [NSString stringWithUTF8String:title]; + NSString *nsSubtitle = subtitle ? [NSString stringWithUTF8String:subtitle] : @""; + NSString *nsBody = [NSString stringWithUTF8String:body]; + + UNMutableNotificationContent *content = [[[UNMutableNotificationContent alloc] init] autorelease]; + content.title = nsTitle; + if (![nsSubtitle isEqualToString:@""]) { + content.subtitle = nsSubtitle; + } + content.body = nsBody; + content.sound = [UNNotificationSound defaultSound]; + + // Parse JSON data if provided + if (dataJSON) { + NSString *dataJsonStr = [NSString stringWithUTF8String:dataJSON]; + NSData *jsonData = [dataJsonStr dataUsingEncoding:NSUTF8StringEncoding]; + NSError *error = nil; + NSDictionary *parsedData = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + if (!error && parsedData) { + content.userInfo = parsedData; + } else if (error) { + if (contentError) *contentError = error; + } + } + + return content; +} + +- (void) sendNotificationWithRequest:(UNNotificationRequest *)request channelID:(int)channelID API_AVAILABLE(macos(10.14)) { + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { + if (error) { + NSString *errorMsg = [NSString stringWithFormat:@"Error: %@", [error localizedDescription]]; + captureResult(channelID, false, [errorMsg UTF8String]); + } else { + captureResult(channelID, true, NULL); + } + }]; +} + +- (void) SendNotification:(int)channelID :(const char *)identifier :(const char *)title :(const char *)subtitle :(const char *)body :(const char *)dataJSON API_AVAILABLE(macos(10.14)) { + if (![self EnsureDelegateInitialized]) { + NSString *errorMsg = @"Notification delegate has been lost. Reinitialize the notification service."; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + + NSString *nsIdentifier = [NSString stringWithUTF8String:identifier]; + + NSError *contentError = nil; + UNMutableNotificationContent *content = [self createNotificationContent:title subtitle:subtitle body:body dataJSON:dataJSON error:&contentError]; + if (contentError) { + NSString *errorMsg = [NSString stringWithFormat:@"Error: %@", [contentError localizedDescription]]; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + + UNTimeIntervalNotificationTrigger *trigger = nil; + UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:nsIdentifier content:content trigger:trigger]; + + [self sendNotificationWithRequest:request channelID:channelID]; +} + +- (void) SendNotificationWithActions:(int)channelID :(const char *)identifier :(const char *)title :(const char *)subtitle :(const char *)body :(const char *)categoryId :(const char *)dataJSON API_AVAILABLE(macos(10.14)) { + if (![self EnsureDelegateInitialized]) { + NSString *errorMsg = @"Notification delegate has been lost. Reinitialize the notification service."; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + + NSString *nsIdentifier = [NSString stringWithUTF8String:identifier]; + NSString *nsCategoryId = [NSString stringWithUTF8String:categoryId]; + + NSError *contentError = nil; + UNMutableNotificationContent *content = [self createNotificationContent:title subtitle:subtitle body:body dataJSON:dataJSON error:&contentError]; + if (contentError) { + NSString *errorMsg = [NSString stringWithFormat:@"Error: %@", [contentError localizedDescription]]; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + + content.categoryIdentifier = nsCategoryId; + + UNTimeIntervalNotificationTrigger *trigger = nil; + UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:nsIdentifier content:content trigger:trigger]; + + [self sendNotificationWithRequest:request channelID:channelID]; +} + +- (void) RegisterNotificationCategory:(int)channelID :(const char *)categoryId :(const char *)actionsJSON :(bool)hasReplyField :(const char *)replyPlaceholder :(const char *)replyButtonTitle API_AVAILABLE(macos(10.14)) { + if (![self EnsureDelegateInitialized]) { + NSString *errorMsg = @"Notification delegate has been lost. Reinitialize the notification service."; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + + NSString *nsCategoryId = [NSString stringWithUTF8String:categoryId]; + NSString *actionsJsonStr = actionsJSON ? [NSString stringWithUTF8String:actionsJSON] : @"[]"; + + NSData *jsonData = [actionsJsonStr dataUsingEncoding:NSUTF8StringEncoding]; + NSError *error = nil; + NSArray *actionsArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + + if (error) { + NSString *errorMsg = [NSString stringWithFormat:@"Error: %@", [error localizedDescription]]; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + + NSMutableArray *actions = [NSMutableArray array]; + for (NSDictionary *actionDict in actionsArray) { + NSString *actionId = actionDict[@"id"]; + NSString *actionTitle = actionDict[@"title"]; + BOOL destructive = [actionDict[@"destructive"] boolValue]; + + if (actionId && actionTitle) { + UNNotificationActionOptions options = UNNotificationActionOptionNone; + if (destructive) options |= UNNotificationActionOptionDestructive; + + UNNotificationAction *action = [UNNotificationAction actionWithIdentifier:actionId + title:actionTitle + options:options]; + [actions addObject:action]; + } + } + + if (hasReplyField) { + // Defensive NULL checks: if hasReplyField is true, both strings must be non-NULL + if (!replyPlaceholder || !replyButtonTitle) { + NSString *errorMsg = @"hasReplyField is true but replyPlaceholder or replyButtonTitle is NULL"; + captureResult(channelID, false, [errorMsg UTF8String]); + return; + } + NSString *placeholder = [NSString stringWithUTF8String:replyPlaceholder]; + NSString *buttonTitle = [NSString stringWithUTF8String:replyButtonTitle]; + UNTextInputNotificationAction *textAction = + [UNTextInputNotificationAction actionWithIdentifier:@"TEXT_REPLY" + title:buttonTitle + options:UNNotificationActionOptionNone + textInputButtonTitle:buttonTitle + textInputPlaceholder:placeholder]; + [actions addObject:textAction]; + } + + UNNotificationCategory *newCategory = [UNNotificationCategory categoryWithIdentifier:nsCategoryId + actions:actions + intentIdentifiers:@[] + options:UNNotificationCategoryOptionNone]; + + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center getNotificationCategoriesWithCompletionHandler:^(NSSet *categories) { + NSMutableSet *updatedCategories = [NSMutableSet setWithSet:categories]; + + // Remove existing category with same identifier if found + UNNotificationCategory *existingCategory = nil; + for (UNNotificationCategory *category in updatedCategories) { + if ([category.identifier isEqualToString:nsCategoryId]) { + existingCategory = category; + break; + } + } + if (existingCategory) { + [updatedCategories removeObject:existingCategory]; + } + + // Add the new category + [updatedCategories addObject:newCategory]; + [center setNotificationCategories:updatedCategories]; + + captureResult(channelID, true, NULL); + }]; +} + +- (void) RemoveNotificationCategory:(int)channelID :(const char *)categoryId API_AVAILABLE(macos(10.14)) { + NSString *nsCategoryId = [NSString stringWithUTF8String:categoryId]; + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + + [center getNotificationCategoriesWithCompletionHandler:^(NSSet *categories) { + NSMutableSet *updatedCategories = [NSMutableSet setWithSet:categories]; + + // Find and remove the matching category + UNNotificationCategory *categoryToRemove = nil; + for (UNNotificationCategory *category in updatedCategories) { + if ([category.identifier isEqualToString:nsCategoryId]) { + categoryToRemove = category; + break; + } + } + + if (categoryToRemove) { + [updatedCategories removeObject:categoryToRemove]; + [center setNotificationCategories:updatedCategories]; + captureResult(channelID, true, NULL); + } else { + NSString *errorMsg = [NSString stringWithFormat:@"Category '%@' not found", nsCategoryId]; + captureResult(channelID, false, [errorMsg UTF8String]); + } + }]; +} + +- (void) RemoveAllPendingNotifications API_AVAILABLE(macos(10.14)) { + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center removeAllPendingNotificationRequests]; +} + +- (void) RemovePendingNotification:(const char *)identifier API_AVAILABLE(macos(10.14)) { + NSString *nsIdentifier = [NSString stringWithUTF8String:identifier]; + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center removePendingNotificationRequestsWithIdentifiers:@[nsIdentifier]]; +} + +- (void) RemoveAllDeliveredNotifications API_AVAILABLE(macos(10.14)) { + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center removeAllDeliveredNotifications]; +} + +- (void) RemoveDeliveredNotification:(const char *)identifier API_AVAILABLE(macos(10.14)) { + NSString *nsIdentifier = [NSString stringWithUTF8String:identifier]; + UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; + [center removeDeliveredNotificationsWithIdentifiers:@[nsIdentifier]]; +} + + - (void) SetAbout :(NSString*)title :(NSString*)description :(void*)imagedata :(int)datalen { self.aboutTitle = title; self.aboutDescription = description; @@ -725,7 +1091,7 @@ typedef void (^schemeTaskCaller)(id); self.aboutImage = [[NSImage alloc] initWithData:imageData]; } --(void) About { +- (void) About { WailsAlert *alert = [WailsAlert new]; [alert setAlertStyle:NSAlertStyleInformational]; diff --git a/v2/internal/frontend/desktop/darwin/frontend.go b/v2/internal/frontend/desktop/darwin/frontend.go index c9e70d4be..6566445d5 100644 --- a/v2/internal/frontend/desktop/darwin/frontend.go +++ b/v2/internal/frontend/desktop/darwin/frontend.go @@ -518,8 +518,8 @@ func HandleOpenFile(filePath *C.char) { openFilepathBuffer <- goFilepath } -//export HandleCustomProtocol -func HandleCustomProtocol(url *C.char) { +//export HandleOpenURL +func HandleOpenURL(url *C.char) { goUrl := C.GoString(url) openUrlBuffer <- goUrl } diff --git a/v2/internal/frontend/desktop/darwin/notifications.go b/v2/internal/frontend/desktop/darwin/notifications.go new file mode 100644 index 000000000..b788841e0 --- /dev/null +++ b/v2/internal/frontend/desktop/darwin/notifications.go @@ -0,0 +1,465 @@ +//go:build darwin +// +build darwin + +package darwin + +/* +#cgo CFLAGS:-x objective-c +#cgo LDFLAGS: -framework Foundation -framework Cocoa + +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 +#cgo LDFLAGS: -framework UserNotifications +#endif + +#import "Application.h" +#import "WailsContext.h" +*/ +import "C" +import ( + "context" + "encoding/json" + "fmt" + "os" + "sync" + "time" + "unsafe" + + "github.com/wailsapp/wails/v2/internal/frontend" +) + +// Package-scoped variable only accessible within this file +var ( + currentFrontend *Frontend + frontendMutex sync.RWMutex + // Notification channels + channels map[int]chan notificationChannel + channelsLock sync.Mutex + nextChannelID int + + notificationResultCallback func(result frontend.NotificationResult) + callbackLock sync.RWMutex +) + +const DefaultActionIdentifier = "DEFAULT_ACTION" +const AppleDefaultActionIdentifier = "com.apple.UNNotificationDefaultActionIdentifier" + +// setCurrentFrontend sets the current frontend instance +// This is called when RequestNotificationAuthorization or CheckNotificationAuthorization is called +func setCurrentFrontend(f *Frontend) { + frontendMutex.Lock() + defer frontendMutex.Unlock() + currentFrontend = f +} + +// getCurrentFrontend gets the current frontend instance +func getCurrentFrontend() *Frontend { + frontendMutex.RLock() + defer frontendMutex.RUnlock() + return currentFrontend +} + +type notificationChannel struct { + Success bool + Error error +} + +func (f *Frontend) InitializeNotifications() error { + if !f.IsNotificationAvailable() { + return fmt.Errorf("notifications are not available on this system") + } + if !f.checkBundleIdentifier() { + return fmt.Errorf("notifications require a valid bundle identifier") + } + if !bool(C.EnsureDelegateInitialized(f.mainWindow.context)) { + return fmt.Errorf("failed to initialize notification center delegate") + } + + channels = make(map[int]chan notificationChannel) + nextChannelID = 0 + + setCurrentFrontend(f) + + return nil +} + +// CleanupNotifications is a macOS stub that does nothing. +// (Linux-specific cleanup) +func (f *Frontend) CleanupNotifications() { + // No cleanup needed on macOS +} + +func (f *Frontend) IsNotificationAvailable() bool { + return bool(C.IsNotificationAvailable(f.mainWindow.context)) +} + +func (f *Frontend) checkBundleIdentifier() bool { + return bool(C.CheckBundleIdentifier(f.mainWindow.context)) +} + +func (f *Frontend) RequestNotificationAuthorization() (bool, error) { + ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second) + defer cancel() + + id, resultCh := f.registerChannel() + + C.RequestNotificationAuthorization(f.mainWindow.context, C.int(id)) + + select { + case result := <-resultCh: + close(resultCh) + return result.Success, result.Error + case <-ctx.Done(): + f.cleanupChannel(id) + return false, fmt.Errorf("notification authorization timed out after 3 minutes: %w", ctx.Err()) + } +} + +func (f *Frontend) CheckNotificationAuthorization() (bool, error) { + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + + id, resultCh := f.registerChannel() + + C.CheckNotificationAuthorization(f.mainWindow.context, C.int(id)) + + select { + case result := <-resultCh: + close(resultCh) + return result.Success, result.Error + case <-ctx.Done(): + f.cleanupChannel(id) + return false, fmt.Errorf("notification authorization timed out after 15s: %w", ctx.Err()) + } +} + +// SendNotification sends a basic notification with a unique identifier, title, subtitle, and body. +func (f *Frontend) SendNotification(options frontend.NotificationOptions) error { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + cIdentifier := C.CString(options.ID) + cTitle := C.CString(options.Title) + cSubtitle := C.CString(options.Subtitle) + cBody := C.CString(options.Body) + defer C.free(unsafe.Pointer(cIdentifier)) + defer C.free(unsafe.Pointer(cTitle)) + defer C.free(unsafe.Pointer(cSubtitle)) + defer C.free(unsafe.Pointer(cBody)) + + var cDataJSON *C.char + if options.Data != nil { + jsonData, err := json.Marshal(options.Data) + if err != nil { + return fmt.Errorf("failed to marshal notification data: %w", err) + } + cDataJSON = C.CString(string(jsonData)) + defer C.free(unsafe.Pointer(cDataJSON)) + } + + id, resultCh := f.registerChannel() + C.SendNotification(f.mainWindow.context, C.int(id), cIdentifier, cTitle, cSubtitle, cBody, cDataJSON) + + select { + case result := <-resultCh: + close(resultCh) + if !result.Success { + if result.Error != nil { + return result.Error + } + return fmt.Errorf("sending notification failed") + } + return nil + case <-ctx.Done(): + f.cleanupChannel(id) + return fmt.Errorf("sending notification timed out: %w", ctx.Err()) + } +} + +// SendNotificationWithActions sends a notification with additional actions and inputs. +// A NotificationCategory must be registered with RegisterNotificationCategory first. The `CategoryID` must match the registered category. +// If a NotificationCategory is not registered a basic notification will be sent. +func (f *Frontend) SendNotificationWithActions(options frontend.NotificationOptions) error { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + cIdentifier := C.CString(options.ID) + cTitle := C.CString(options.Title) + cSubtitle := C.CString(options.Subtitle) + cBody := C.CString(options.Body) + cCategoryID := C.CString(options.CategoryID) + defer C.free(unsafe.Pointer(cIdentifier)) + defer C.free(unsafe.Pointer(cTitle)) + defer C.free(unsafe.Pointer(cSubtitle)) + defer C.free(unsafe.Pointer(cBody)) + defer C.free(unsafe.Pointer(cCategoryID)) + + var cDataJSON *C.char + if options.Data != nil { + jsonData, err := json.Marshal(options.Data) + if err != nil { + return fmt.Errorf("failed to marshal notification data: %w", err) + } + cDataJSON = C.CString(string(jsonData)) + defer C.free(unsafe.Pointer(cDataJSON)) + } + + id, resultCh := f.registerChannel() + C.SendNotificationWithActions(f.mainWindow.context, C.int(id), cIdentifier, cTitle, cSubtitle, cBody, cCategoryID, cDataJSON) + + select { + case result := <-resultCh: + close(resultCh) + if !result.Success { + if result.Error != nil { + return result.Error + } + return fmt.Errorf("sending notification failed") + } + return nil + case <-ctx.Done(): + f.cleanupChannel(id) + return fmt.Errorf("sending notification timed out: %w", ctx.Err()) + } +} + +// RegisterNotificationCategory registers a new NotificationCategory to be used with SendNotificationWithActions. +// Registering a category with the same name as a previously registered NotificationCategory will override it. +func (f *Frontend) RegisterNotificationCategory(category frontend.NotificationCategory) error { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + cCategoryID := C.CString(category.ID) + defer C.free(unsafe.Pointer(cCategoryID)) + + actionsJSON, err := json.Marshal(category.Actions) + if err != nil { + return fmt.Errorf("failed to marshal notification category: %w", err) + } + cActionsJSON := C.CString(string(actionsJSON)) + defer C.free(unsafe.Pointer(cActionsJSON)) + + var cReplyPlaceholder, cReplyButtonTitle *C.char + if category.HasReplyField { + cReplyPlaceholder = C.CString(category.ReplyPlaceholder) + cReplyButtonTitle = C.CString(category.ReplyButtonTitle) + defer C.free(unsafe.Pointer(cReplyPlaceholder)) + defer C.free(unsafe.Pointer(cReplyButtonTitle)) + } + + id, resultCh := f.registerChannel() + C.RegisterNotificationCategory(f.mainWindow.context, C.int(id), cCategoryID, cActionsJSON, C.bool(category.HasReplyField), + cReplyPlaceholder, cReplyButtonTitle) + + select { + case result := <-resultCh: + close(resultCh) + if !result.Success { + if result.Error != nil { + return result.Error + } + return fmt.Errorf("category registration failed") + } + return nil + case <-ctx.Done(): + f.cleanupChannel(id) + return fmt.Errorf("category registration timed out: %w", ctx.Err()) + } +} + +// RemoveNotificationCategory remove a previously registered NotificationCategory. +func (f *Frontend) RemoveNotificationCategory(categoryId string) error { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + cCategoryID := C.CString(categoryId) + defer C.free(unsafe.Pointer(cCategoryID)) + + id, resultCh := f.registerChannel() + C.RemoveNotificationCategory(f.mainWindow.context, C.int(id), cCategoryID) + + select { + case result := <-resultCh: + close(resultCh) + if !result.Success { + if result.Error != nil { + return result.Error + } + return fmt.Errorf("category removal failed") + } + return nil + case <-ctx.Done(): + f.cleanupChannel(id) + return fmt.Errorf("category removal timed out: %w", ctx.Err()) + } +} + +// RemoveAllPendingNotifications removes all pending notifications. +func (f *Frontend) RemoveAllPendingNotifications() error { + C.RemoveAllPendingNotifications(f.mainWindow.context) + return nil +} + +// RemovePendingNotification removes a pending notification matching the unique identifier. +func (f *Frontend) RemovePendingNotification(identifier string) error { + cIdentifier := C.CString(identifier) + defer C.free(unsafe.Pointer(cIdentifier)) + C.RemovePendingNotification(f.mainWindow.context, cIdentifier) + return nil +} + +// RemoveAllDeliveredNotifications removes all delivered notifications. +func (f *Frontend) RemoveAllDeliveredNotifications() error { + C.RemoveAllDeliveredNotifications(f.mainWindow.context) + return nil +} + +// RemoveDeliveredNotification removes a delivered notification matching the unique identifier. +func (f *Frontend) RemoveDeliveredNotification(identifier string) error { + cIdentifier := C.CString(identifier) + defer C.free(unsafe.Pointer(cIdentifier)) + C.RemoveDeliveredNotification(f.mainWindow.context, cIdentifier) + return nil +} + +// RemoveNotification is a macOS stub that always returns nil. +// Use one of the following instead: +// RemoveAllPendingNotifications +// RemovePendingNotification +// RemoveAllDeliveredNotifications +// RemoveDeliveredNotification +// (Linux-specific) +func (f *Frontend) RemoveNotification(identifier string) error { + return nil +} + +func (f *Frontend) OnNotificationResponse(callback func(result frontend.NotificationResult)) { + callbackLock.Lock() + notificationResultCallback = callback + callbackLock.Unlock() +} + +//export captureResult +func captureResult(channelID C.int, success C.bool, errorMsg *C.char) { + f := getCurrentFrontend() + if f == nil { + return + } + + resultCh, exists := f.GetChannel(int(channelID)) + if !exists { + return + } + + var err error + if errorMsg != nil { + err = fmt.Errorf("%s", C.GoString(errorMsg)) + } + + resultCh <- notificationChannel{ + Success: bool(success), + Error: err, + } +} + +//export didReceiveNotificationResponse +func didReceiveNotificationResponse(jsonPayload *C.char, err *C.char) { + result := frontend.NotificationResult{} + + if err != nil { + errMsg := C.GoString(err) + result.Error = fmt.Errorf("notification response error: %s", errMsg) + handleNotificationResult(result) + + return + } + + if jsonPayload == nil { + result.Error = fmt.Errorf("received nil JSON payload in notification response") + handleNotificationResult(result) + return + } + + payload := C.GoString(jsonPayload) + + var response frontend.NotificationResponse + if err := json.Unmarshal([]byte(payload), &response); err != nil { + result.Error = fmt.Errorf("failed to unmarshal notification response: %w", err) + handleNotificationResult(result) + return + } + + if response.ActionIdentifier == AppleDefaultActionIdentifier { + response.ActionIdentifier = DefaultActionIdentifier + } + + result.Response = response + handleNotificationResult(result) +} + +func handleNotificationResult(result frontend.NotificationResult) { + callbackLock.Lock() + callback := notificationResultCallback + callbackLock.Unlock() + + if callback != nil { + go func() { + defer func() { + if r := recover(); r != nil { + // Log panic but don't crash the app + fmt.Fprintf(os.Stderr, "panic in notification callback: %v\n", r) + } + }() + callback(result) + }() + } +} + +// Helper methods + +func (f *Frontend) registerChannel() (int, chan notificationChannel) { + channelsLock.Lock() + defer channelsLock.Unlock() + + // Initialize channels map if it's nil + if channels == nil { + channels = make(map[int]chan notificationChannel) + nextChannelID = 0 + } + + id := nextChannelID + nextChannelID++ + + resultCh := make(chan notificationChannel, 1) + + channels[id] = resultCh + return id, resultCh +} + +func (f *Frontend) GetChannel(id int) (chan notificationChannel, bool) { + channelsLock.Lock() + defer channelsLock.Unlock() + + if channels == nil { + return nil, false + } + + ch, exists := channels[id] + if exists { + delete(channels, id) + } + return ch, exists +} + +func (f *Frontend) cleanupChannel(id int) { + channelsLock.Lock() + defer channelsLock.Unlock() + + if channels == nil { + return + } + + if ch, exists := channels[id]; exists { + delete(channels, id) + close(ch) + } +} diff --git a/v2/internal/frontend/desktop/linux/frontend.go b/v2/internal/frontend/desktop/linux/frontend.go index c009a18ca..2942a112e 100644 --- a/v2/internal/frontend/desktop/linux/frontend.go +++ b/v2/internal/frontend/desktop/linux/frontend.go @@ -73,6 +73,16 @@ static void install_signal_handlers() #endif } +static gboolean install_signal_handlers_idle(gpointer data) { + (void)data; + install_signal_handlers(); + return G_SOURCE_REMOVE; +} + +static void fix_signal_handlers_after_gtk_init() { + g_idle_add(install_signal_handlers_idle, NULL); +} + */ import "C" import ( @@ -204,7 +214,7 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger. result.mainWindow = NewWindow(appoptions, result.debug, result.devtoolsEnabled) - C.install_signal_handlers() + C.fix_signal_handlers_after_gtk_init() if appoptions.Linux != nil && appoptions.Linux.ProgramName != "" { prgname := C.CString(appoptions.Linux.ProgramName) diff --git a/v2/internal/frontend/desktop/linux/menu.go b/v2/internal/frontend/desktop/linux/menu.go index 557a24b37..a61d190bd 100644 --- a/v2/internal/frontend/desktop/linux/menu.go +++ b/v2/internal/frontend/desktop/linux/menu.go @@ -34,8 +34,11 @@ void addAccelerator(GtkWidget* menuItem, GtkAccelGroup* group, guint key, GdkMod } */ import "C" -import "github.com/wailsapp/wails/v2/pkg/menu" -import "unsafe" +import ( + "unsafe" + + "github.com/wailsapp/wails/v2/pkg/menu" +) var menuIdCounter int var menuItemToId map[*menu.MenuItem]int @@ -81,8 +84,10 @@ func (w *Window) SetApplicationMenu(inmenu *menu.Menu) { func processMenu(window *Window, menu *menu.Menu) { for _, menuItem := range menu.Items { - submenu := processSubmenu(menuItem, window.accels) - C.gtk_menu_shell_append(C.toGtkMenuShell(unsafe.Pointer(window.menubar)), submenu) + if menuItem.SubMenu != nil { + submenu := processSubmenu(menuItem, window.accels) + C.gtk_menu_shell_append(C.toGtkMenuShell(unsafe.Pointer(window.menubar)), submenu) + } } } diff --git a/v2/internal/frontend/desktop/linux/notifications.go b/v2/internal/frontend/desktop/linux/notifications.go new file mode 100644 index 000000000..80f0ae569 --- /dev/null +++ b/v2/internal/frontend/desktop/linux/notifications.go @@ -0,0 +1,594 @@ +//go:build linux +// +build linux + +package linux + +import ( + "context" + "encoding/json" + "fmt" + "os" + "path/filepath" + "sync" + + "github.com/godbus/dbus/v5" + "github.com/wailsapp/wails/v2/internal/frontend" +) + +var ( + conn *dbus.Conn + categories map[string]frontend.NotificationCategory = make(map[string]frontend.NotificationCategory) + categoriesLock sync.RWMutex + notifications map[uint32]*notificationData = make(map[uint32]*notificationData) + notificationsLock sync.RWMutex + notificationResultCallback func(result frontend.NotificationResult) + callbackLock sync.RWMutex + appName string + cancel context.CancelFunc +) + +type notificationData struct { + ID string + Title string + Subtitle string + Body string + CategoryID string + Data map[string]interface{} + DBusID uint32 + ActionMap map[string]string +} + +const ( + dbusNotificationInterface = "org.freedesktop.Notifications" + dbusNotificationPath = "/org/freedesktop/Notifications" + DefaultActionIdentifier = "DEFAULT_ACTION" +) + +// Creates a new Notifications Service. +func (f *Frontend) InitializeNotifications() error { + // Clean up any previous initialization + f.CleanupNotifications() + + exe, err := os.Executable() + if err != nil { + return fmt.Errorf("failed to get executable: %w", err) + } + appName = filepath.Base(exe) + + _conn, err := dbus.ConnectSessionBus() + if err != nil { + return fmt.Errorf("failed to connect to session bus: %w", err) + } + conn = _conn + + if err := f.loadCategories(); err != nil { + f.logger.Warning("Failed to load notification categories: %v", err) + } + + var signalCtx context.Context + signalCtx, cancel = context.WithCancel(context.Background()) + + if err := f.setupSignalHandling(signalCtx); err != nil { + return fmt.Errorf("failed to set up notification signal handling: %w", err) + } + + return nil +} + +// CleanupNotifications cleans up notification resources +func (f *Frontend) CleanupNotifications() { + if cancel != nil { + cancel() + cancel = nil + } + + if conn != nil { + conn.Close() + conn = nil + } +} + +func (f *Frontend) IsNotificationAvailable() bool { + return true +} + +// RequestNotificationAuthorization is a Linux stub that always returns true, nil. +// (authorization is macOS-specific) +func (f *Frontend) RequestNotificationAuthorization() (bool, error) { + return true, nil +} + +// CheckNotificationAuthorization is a Linux stub that always returns true. +// (authorization is macOS-specific) +func (f *Frontend) CheckNotificationAuthorization() (bool, error) { + return true, nil +} + +// SendNotification sends a basic notification with a unique identifier, title, subtitle, and body. +func (f *Frontend) SendNotification(options frontend.NotificationOptions) error { + if conn == nil { + return fmt.Errorf("notifications not initialized") + } + + hints := map[string]dbus.Variant{} + + body := options.Body + if options.Subtitle != "" { + body = options.Subtitle + "\n" + body + } + + defaultActionID := "default" + actions := []string{defaultActionID, "Default"} + + actionMap := map[string]string{ + defaultActionID: DefaultActionIdentifier, + } + + hints["x-notification-id"] = dbus.MakeVariant(options.ID) + + if options.Data != nil { + userData, err := json.Marshal(options.Data) + if err == nil { + hints["x-user-data"] = dbus.MakeVariant(string(userData)) + } + } + + // Call the Notify method on the D-Bus interface + obj := conn.Object(dbusNotificationInterface, dbusNotificationPath) + call := obj.Call( + dbusNotificationInterface+".Notify", + 0, + appName, + uint32(0), + "", // Icon + options.Title, + body, + actions, + hints, + int32(-1), + ) + + if call.Err != nil { + return fmt.Errorf("failed to send notification: %w", call.Err) + } + + var dbusID uint32 + if err := call.Store(&dbusID); err != nil { + return fmt.Errorf("failed to store notification ID: %w", err) + } + + notification := ¬ificationData{ + ID: options.ID, + Title: options.Title, + Subtitle: options.Subtitle, + Body: options.Body, + Data: options.Data, + DBusID: dbusID, + ActionMap: actionMap, + } + + notificationsLock.Lock() + notifications[dbusID] = notification + notificationsLock.Unlock() + + return nil +} + +// SendNotificationWithActions sends a notification with additional actions. +func (f *Frontend) SendNotificationWithActions(options frontend.NotificationOptions) error { + if conn == nil { + return fmt.Errorf("notifications not initialized") + } + + categoriesLock.RLock() + category, exists := categories[options.CategoryID] + categoriesLock.RUnlock() + + if options.CategoryID == "" || !exists { + // Fall back to basic notification + return f.SendNotification(options) + } + + body := options.Body + if options.Subtitle != "" { + body = options.Subtitle + "\n" + body + } + + var actions []string + actionMap := make(map[string]string) + + defaultActionID := "default" + actions = append(actions, defaultActionID, "Default") + actionMap[defaultActionID] = DefaultActionIdentifier + + for _, action := range category.Actions { + actions = append(actions, action.ID, action.Title) + actionMap[action.ID] = action.ID + } + + hints := map[string]dbus.Variant{} + + hints["x-notification-id"] = dbus.MakeVariant(options.ID) + + hints["x-category-id"] = dbus.MakeVariant(options.CategoryID) + + if options.Data != nil { + userData, err := json.Marshal(options.Data) + if err == nil { + hints["x-user-data"] = dbus.MakeVariant(string(userData)) + } + } + + obj := conn.Object(dbusNotificationInterface, dbusNotificationPath) + call := obj.Call( + dbusNotificationInterface+".Notify", + 0, + appName, + uint32(0), + "", // Icon + options.Title, + body, + actions, + hints, + int32(-1), + ) + + if call.Err != nil { + return fmt.Errorf("failed to send notification: %w", call.Err) + } + + var dbusID uint32 + if err := call.Store(&dbusID); err != nil { + return fmt.Errorf("failed to store notification ID: %w", err) + } + + notification := ¬ificationData{ + ID: options.ID, + Title: options.Title, + Subtitle: options.Subtitle, + Body: options.Body, + CategoryID: options.CategoryID, + Data: options.Data, + DBusID: dbusID, + ActionMap: actionMap, + } + + notificationsLock.Lock() + notifications[dbusID] = notification + notificationsLock.Unlock() + + return nil +} + +// RegisterNotificationCategory registers a new NotificationCategory to be used with SendNotificationWithActions. +func (f *Frontend) RegisterNotificationCategory(category frontend.NotificationCategory) error { + categoriesLock.Lock() + categories[category.ID] = category + categoriesLock.Unlock() + + if err := f.saveCategories(); err != nil { + f.logger.Warning("Failed to save notification categories: %v", err) + } + + return nil +} + +// RemoveNotificationCategory removes a previously registered NotificationCategory. +func (f *Frontend) RemoveNotificationCategory(categoryId string) error { + categoriesLock.Lock() + delete(categories, categoryId) + categoriesLock.Unlock() + + if err := f.saveCategories(); err != nil { + f.logger.Warning("Failed to save notification categories: %v", err) + } + + return nil +} + +// RemoveAllPendingNotifications attempts to remove all active notifications. +func (f *Frontend) RemoveAllPendingNotifications() error { + notificationsLock.Lock() + dbusIDs := make([]uint32, 0, len(notifications)) + for id := range notifications { + dbusIDs = append(dbusIDs, id) + } + notificationsLock.Unlock() + + for _, id := range dbusIDs { + f.closeNotification(id) + } + + return nil +} + +// RemovePendingNotification removes a pending notification. +func (f *Frontend) RemovePendingNotification(identifier string) error { + var dbusID uint32 + found := false + + notificationsLock.Lock() + for id, notif := range notifications { + if notif.ID == identifier { + dbusID = id + found = true + break + } + } + notificationsLock.Unlock() + + if !found { + return nil + } + + return f.closeNotification(dbusID) +} + +// RemoveAllDeliveredNotifications functionally equivalent to RemoveAllPendingNotification on Linux. +func (f *Frontend) RemoveAllDeliveredNotifications() error { + return f.RemoveAllPendingNotifications() +} + +// RemoveDeliveredNotification functionally equivalent RemovePendingNotification on Linux. +func (f *Frontend) RemoveDeliveredNotification(identifier string) error { + return f.RemovePendingNotification(identifier) +} + +// RemoveNotification removes a notification by identifier. +func (f *Frontend) RemoveNotification(identifier string) error { + return f.RemovePendingNotification(identifier) +} + +func (f *Frontend) OnNotificationResponse(callback func(result frontend.NotificationResult)) { + callbackLock.Lock() + defer callbackLock.Unlock() + + notificationResultCallback = callback +} + +// Helper method to close a notification. +func (f *Frontend) closeNotification(id uint32) error { + if conn == nil { + return fmt.Errorf("notifications not initialized") + } + + obj := conn.Object(dbusNotificationInterface, dbusNotificationPath) + call := obj.Call(dbusNotificationInterface+".CloseNotification", 0, id) + + if call.Err != nil { + return fmt.Errorf("failed to close notification: %w", call.Err) + } + + return nil +} + +func (f *Frontend) getConfigDir() (string, error) { + configDir, err := os.UserConfigDir() + if err != nil { + return "", fmt.Errorf("failed to get user config directory: %w", err) + } + + appConfigDir := filepath.Join(configDir, appName) + if err := os.MkdirAll(appConfigDir, 0755); err != nil { + return "", fmt.Errorf("failed to create app config directory: %w", err) + } + + return appConfigDir, nil +} + +// Save notification categories. +func (f *Frontend) saveCategories() error { + configDir, err := f.getConfigDir() + if err != nil { + return err + } + + categoriesFile := filepath.Join(configDir, "notification-categories.json") + + categoriesLock.RLock() + categoriesData, err := json.MarshalIndent(categories, "", " ") + categoriesLock.RUnlock() + + if err != nil { + return fmt.Errorf("failed to marshal notification categories: %w", err) + } + + if err := os.WriteFile(categoriesFile, categoriesData, 0644); err != nil { + return fmt.Errorf("failed to write notification categories to disk: %w", err) + } + + return nil +} + +// Load notification categories. +func (f *Frontend) loadCategories() error { + configDir, err := f.getConfigDir() + if err != nil { + return err + } + + categoriesFile := filepath.Join(configDir, "notification-categories.json") + + if _, err := os.Stat(categoriesFile); os.IsNotExist(err) { + return nil + } + + categoriesData, err := os.ReadFile(categoriesFile) + if err != nil { + return fmt.Errorf("failed to read notification categories from disk: %w", err) + } + + _categories := make(map[string]frontend.NotificationCategory) + if err := json.Unmarshal(categoriesData, &_categories); err != nil { + return fmt.Errorf("failed to unmarshal notification categories: %w", err) + } + + categoriesLock.Lock() + categories = _categories + categoriesLock.Unlock() + + return nil +} + +// Setup signal handling for notification actions. +func (f *Frontend) setupSignalHandling(ctx context.Context) error { + if err := conn.AddMatchSignal( + dbus.WithMatchInterface(dbusNotificationInterface), + dbus.WithMatchMember("ActionInvoked"), + ); err != nil { + return err + } + + if err := conn.AddMatchSignal( + dbus.WithMatchInterface(dbusNotificationInterface), + dbus.WithMatchMember("NotificationClosed"), + ); err != nil { + return err + } + + c := make(chan *dbus.Signal, 10) + conn.Signal(c) + + go f.handleSignals(ctx, c) + + return nil +} + +// Handle incoming D-Bus signals. +func (f *Frontend) handleSignals(ctx context.Context, c chan *dbus.Signal) { + for { + select { + case <-ctx.Done(): + return + case signal, ok := <-c: + if !ok { + return + } + + switch signal.Name { + case dbusNotificationInterface + ".ActionInvoked": + f.handleActionInvoked(signal) + case dbusNotificationInterface + ".NotificationClosed": + f.handleNotificationClosed(signal) + } + } + } +} + +// Handle ActionInvoked signal. +func (f *Frontend) handleActionInvoked(signal *dbus.Signal) { + if len(signal.Body) < 2 { + return + } + + dbusID, ok := signal.Body[0].(uint32) + if !ok { + return + } + + actionID, ok := signal.Body[1].(string) + if !ok { + return + } + + notificationsLock.Lock() + notification, exists := notifications[dbusID] + if exists { + delete(notifications, dbusID) + } + notificationsLock.Unlock() + + if !exists { + return + } + + appActionID, ok := notification.ActionMap[actionID] + if !ok { + appActionID = actionID + } + + response := frontend.NotificationResponse{ + ID: notification.ID, + ActionIdentifier: appActionID, + Title: notification.Title, + Subtitle: notification.Subtitle, + Body: notification.Body, + CategoryID: notification.CategoryID, + UserInfo: notification.Data, + } + + result := frontend.NotificationResult{ + Response: response, + } + + handleNotificationResult(result) +} + +func handleNotificationResult(result frontend.NotificationResult) { + callbackLock.Lock() + callback := notificationResultCallback + callbackLock.Unlock() + + if callback != nil { + go func() { + defer func() { + if r := recover(); r != nil { + // Log panic but don't crash the app + fmt.Fprintf(os.Stderr, "panic in notification callback: %v\n", r) + } + }() + callback(result) + }() + } +} + +// Handle NotificationClosed signal. +// Reason codes: +// 1 - expired timeout +// 2 - dismissed by user (click on X) +// 3 - closed by CloseNotification call +// 4 - undefined/reserved +func (f *Frontend) handleNotificationClosed(signal *dbus.Signal) { + if len(signal.Body) < 2 { + return + } + + dbusID, ok := signal.Body[0].(uint32) + if !ok { + return + } + + reason, ok := signal.Body[1].(uint32) + if !ok { + reason = 0 // Unknown reason + } + + notificationsLock.Lock() + notification, exists := notifications[dbusID] + if exists { + delete(notifications, dbusID) + } + notificationsLock.Unlock() + + if !exists { + return + } + + if reason == 2 { + response := frontend.NotificationResponse{ + ID: notification.ID, + ActionIdentifier: DefaultActionIdentifier, + Title: notification.Title, + Subtitle: notification.Subtitle, + Body: notification.Body, + CategoryID: notification.CategoryID, + UserInfo: notification.Data, + } + + result := frontend.NotificationResult{ + Response: response, + } + + handleNotificationResult(result) + } +} diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index a29eb851b..5df13ed98 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -28,11 +28,13 @@ import ( "github.com/wailsapp/wails/v2/internal/frontend/originvalidator" wailsruntime "github.com/wailsapp/wails/v2/internal/frontend/runtime" "github.com/wailsapp/wails/v2/internal/logger" + w32consts "github.com/wailsapp/wails/v2/internal/platform/win32" "github.com/wailsapp/wails/v2/internal/system/operatingsystem" "github.com/wailsapp/wails/v2/pkg/assetserver" "github.com/wailsapp/wails/v2/pkg/assetserver/webview" "github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options/windows" + w "golang.org/x/sys/windows" ) const startURL = "http://wails.localhost/" @@ -75,6 +77,13 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger. // Get Windows build number versionInfo, _ := operatingsystem.GetWindowsVersionInfo() + // Apply DLL search path settings if specified + if appoptions.Windows != nil && appoptions.Windows.DLLSearchPaths != 0 { + w.SetDefaultDllDirectories(appoptions.Windows.DLLSearchPaths) + } + // Now initialize packages that load DLLs + w32.Init() + w32consts.Init() result := &Frontend{ frontendOptions: appoptions, logger: myLogger, diff --git a/v2/internal/frontend/desktop/windows/notifications.go b/v2/internal/frontend/desktop/windows/notifications.go new file mode 100644 index 000000000..0176b7077 --- /dev/null +++ b/v2/internal/frontend/desktop/windows/notifications.go @@ -0,0 +1,489 @@ +//go:build windows +// +build windows + +package windows + +import ( + "encoding/base64" + "encoding/json" + "log" + "sync" + + wintoast "git.sr.ht/~jackmordaunt/go-toast/v2/wintoast" + "github.com/google/uuid" + "github.com/wailsapp/wails/v2/internal/frontend" + "github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc" + "github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc/w32" + + "fmt" + "os" + "path/filepath" + _ "unsafe" // for go:linkname + + "git.sr.ht/~jackmordaunt/go-toast/v2" + "golang.org/x/sys/windows/registry" +) + +var ( + categories map[string]frontend.NotificationCategory + categoriesLock sync.RWMutex + appName string + appGUID string + iconPath string = "" + exePath string + iconOnce sync.Once + iconErr error + + notificationResultCallback func(result frontend.NotificationResult) + callbackLock sync.RWMutex +) + +const DefaultActionIdentifier = "DEFAULT_ACTION" + +const ( + ToastRegistryPath = `Software\Classes\AppUserModelId\` + ToastRegistryGuidKey = "CustomActivator" + NotificationCategoriesRegistryPath = `SOFTWARE\%s\NotificationCategories` + NotificationCategoriesRegistryKey = "Categories" +) + +// NotificationPayload combines the action ID and user data into a single structure +type NotificationPayload struct { + Action string `json:"action"` + Options frontend.NotificationOptions `json:"payload,omitempty"` +} + +func (f *Frontend) InitializeNotifications() error { + categoriesLock.Lock() + defer categoriesLock.Unlock() + categories = make(map[string]frontend.NotificationCategory) + + exe, err := os.Executable() + if err != nil { + return fmt.Errorf("failed to get executable: %w", err) + } + exePath = exe + appName = filepath.Base(exePath) + + appGUID, err = getGUID() + if err != nil { + return err + } + + iconPath = filepath.Join(os.TempDir(), appName+appGUID+".png") + + // Create the registry key for the toast activator + key, _, err := registry.CreateKey(registry.CURRENT_USER, + `Software\Classes\CLSID\`+appGUID+`\LocalServer32`, registry.ALL_ACCESS) + if err != nil { + return fmt.Errorf("failed to create CLSID key: %w", err) + } + defer key.Close() + + if err := key.SetStringValue("", fmt.Sprintf("\"%s\" %%1", exePath)); err != nil { + return fmt.Errorf("failed to set CLSID server path: %w", err) + } + + toast.SetAppData(toast.AppData{ + AppID: appName, + GUID: appGUID, + IconPath: iconPath, + ActivationExe: exePath, + }) + + toast.SetActivationCallback(func(args string, data []toast.UserData) { + result := frontend.NotificationResult{} + + actionIdentifier, options, err := parseNotificationResponse(args) + + if err != nil { + result.Error = err + } else { + // Subtitle is retained but was not shown with the notification + response := frontend.NotificationResponse{ + ID: options.ID, + ActionIdentifier: actionIdentifier, + Title: options.Title, + Subtitle: options.Subtitle, + Body: options.Body, + CategoryID: options.CategoryID, + UserInfo: options.Data, + } + + if userText, found := getUserText(data); found { + response.UserText = userText + } + + result.Response = response + } + + handleNotificationResult(result) + }) + + // Register the COM class factory for toast activation. + // This is required for Windows to activate the app when users interact with notifications. + // The go-toast library's SetAppData and SetActivationCallback handle the callback setup, + // but the COM class factory registration is not exposed via public APIs, so we use + // go:linkname to access the internal registerClassFactory function. + if err := registerToastClassFactory(wintoast.ClassFactory); err != nil { + return fmt.Errorf("CoRegisterClassObject failed: %w", err) + } + + return loadCategoriesFromRegistry() +} + +// registerToastClassFactory registers the COM class factory required for Windows toast notification activation. +// This function uses go:linkname to access the unexported registerClassFactory function from go-toast. +// The class factory is necessary for Windows COM activation when users click notification actions. +// Without this registration, notification actions will not activate the application. +// +// This is a workaround until go-toast exports this functionality via a public API. +// See: https://git.sr.ht/~jackmordaunt/go-toast +// +//go:linkname registerToastClassFactory git.sr.ht/~jackmordaunt/go-toast/v2/wintoast.registerClassFactory +func registerToastClassFactory(factory *wintoast.IClassFactory) error + +// CleanupNotifications is a Windows stub that does nothing. +// (Linux-specific cleanup) +func (f *Frontend) CleanupNotifications() { + // No cleanup needed on Windows +} + +func (f *Frontend) IsNotificationAvailable() bool { + return true +} + +func (f *Frontend) RequestNotificationAuthorization() (bool, error) { + return true, nil +} + +func (f *Frontend) CheckNotificationAuthorization() (bool, error) { + return true, nil +} + +// SendNotification sends a basic notification with a name, title, and body. All other options are ignored on Windows. +// (subtitle is only available on macOS and Linux) +func (f *Frontend) SendNotification(options frontend.NotificationOptions) error { + if err := f.saveIconToDir(); err != nil { + f.logger.Warning("Error saving icon: %v", err) + } + + n := toast.Notification{ + Title: options.Title, + Body: options.Body, + ActivationType: toast.Foreground, + ActivationArguments: DefaultActionIdentifier, + } + + encodedPayload, err := encodePayload(DefaultActionIdentifier, options) + if err != nil { + return fmt.Errorf("failed to encode notification payload: %w", err) + } + n.ActivationArguments = encodedPayload + + return n.Push() +} + +// SendNotificationWithActions sends a notification with additional actions and inputs. +// A NotificationCategory must be registered with RegisterNotificationCategory first. The `CategoryID` must match the registered category. +// If a NotificationCategory is not registered a basic notification will be sent. +// (subtitle is only available on macOS and Linux) +func (f *Frontend) SendNotificationWithActions(options frontend.NotificationOptions) error { + if err := f.saveIconToDir(); err != nil { + f.logger.Warning("Error saving icon: %v", err) + } + + categoriesLock.RLock() + nCategory, categoryExists := categories[options.CategoryID] + categoriesLock.RUnlock() + + if options.CategoryID == "" || !categoryExists { + f.logger.Warning("Category '%s' not found, sending basic notification without actions", options.CategoryID) + return f.SendNotification(options) + } + + n := toast.Notification{ + Title: options.Title, + Body: options.Body, + ActivationType: toast.Foreground, + ActivationArguments: DefaultActionIdentifier, + } + + for _, action := range nCategory.Actions { + n.Actions = append(n.Actions, toast.Action{ + Content: action.Title, + Arguments: action.ID, + }) + } + + if nCategory.HasReplyField { + n.Inputs = append(n.Inputs, toast.Input{ + ID: "userText", + Placeholder: nCategory.ReplyPlaceholder, + }) + + n.Actions = append(n.Actions, toast.Action{ + Content: nCategory.ReplyButtonTitle, + Arguments: "TEXT_REPLY", + InputID: "userText", + }) + } + + encodedPayload, err := encodePayload(n.ActivationArguments, options) + if err != nil { + return fmt.Errorf("failed to encode notification payload: %w", err) + } + n.ActivationArguments = encodedPayload + + for index := range n.Actions { + encodedPayload, err := encodePayload(n.Actions[index].Arguments, options) + if err != nil { + return fmt.Errorf("failed to encode notification payload: %w", err) + } + n.Actions[index].Arguments = encodedPayload + } + + return n.Push() +} + +// RegisterNotificationCategory registers a new NotificationCategory to be used with SendNotificationWithActions. +// Registering a category with the same name as a previously registered NotificationCategory will override it. +func (f *Frontend) RegisterNotificationCategory(category frontend.NotificationCategory) error { + categoriesLock.Lock() + defer categoriesLock.Unlock() + + categories[category.ID] = frontend.NotificationCategory{ + ID: category.ID, + Actions: category.Actions, + HasReplyField: category.HasReplyField, + ReplyPlaceholder: category.ReplyPlaceholder, + ReplyButtonTitle: category.ReplyButtonTitle, + } + + return saveCategoriesToRegistry() +} + +// RemoveNotificationCategory removes a previously registered NotificationCategory. +func (f *Frontend) RemoveNotificationCategory(categoryId string) error { + categoriesLock.Lock() + defer categoriesLock.Unlock() + + delete(categories, categoryId) + + return saveCategoriesToRegistry() +} + +// RemoveAllPendingNotifications is a Windows stub that always returns nil. +// (macOS and Linux only) +func (f *Frontend) RemoveAllPendingNotifications() error { + return nil +} + +// RemovePendingNotification is a Windows stub that always returns nil. +// (macOS and Linux only) +func (f *Frontend) RemovePendingNotification(_ string) error { + return nil +} + +// RemoveAllDeliveredNotifications is a Windows stub that always returns nil. +// (macOS and Linux only) +func (f *Frontend) RemoveAllDeliveredNotifications() error { + return nil +} + +// RemoveDeliveredNotification is a Windows stub that always returns nil. +// (macOS and Linux only) +func (f *Frontend) RemoveDeliveredNotification(_ string) error { + return nil +} + +// RemoveNotification is a Windows stub that always returns nil. +// (Linux-specific) +func (f *Frontend) RemoveNotification(identifier string) error { + return nil +} + +func (f *Frontend) OnNotificationResponse(callback func(result frontend.NotificationResult)) { + callbackLock.Lock() + defer callbackLock.Unlock() + + notificationResultCallback = callback +} + +func (f *Frontend) saveIconToDir() error { + iconOnce.Do(func() { + hIcon := w32.ExtractIcon(exePath, 0) + if hIcon == 0 { + iconErr = fmt.Errorf("ExtractIcon failed for %s", exePath) + return + } + defer w32.DestroyIcon(hIcon) + iconErr = winc.SaveHIconAsPNG(hIcon, iconPath) + }) + return iconErr +} + +func saveCategoriesToRegistry() error { + // We assume lock is held by caller + + registryPath := fmt.Sprintf(NotificationCategoriesRegistryPath, appName) + + key, _, err := registry.CreateKey( + registry.CURRENT_USER, + registryPath, + registry.ALL_ACCESS, + ) + if err != nil { + return err + } + defer key.Close() + + data, err := json.Marshal(categories) + if err != nil { + return err + } + + return key.SetStringValue(NotificationCategoriesRegistryKey, string(data)) +} + +func loadCategoriesFromRegistry() error { + // We assume lock is held by caller + + registryPath := fmt.Sprintf(NotificationCategoriesRegistryPath, appName) + + key, err := registry.OpenKey( + registry.CURRENT_USER, + registryPath, + registry.QUERY_VALUE, + ) + if err != nil { + if err == registry.ErrNotExist { + // Not an error, no saved categories + return nil + } + return fmt.Errorf("failed to open registry key: %w", err) + } + defer key.Close() + + data, _, err := key.GetStringValue(NotificationCategoriesRegistryKey) + if err != nil { + if err == registry.ErrNotExist { + // No value yet, but key exists + return nil + } + return fmt.Errorf("failed to read categories from registry: %w", err) + } + + _categories := make(map[string]frontend.NotificationCategory) + if err := json.Unmarshal([]byte(data), &_categories); err != nil { + return fmt.Errorf("failed to parse notification categories from registry: %w", err) + } + + categories = _categories + + return nil +} + +func getUserText(data []toast.UserData) (string, bool) { + for _, d := range data { + if d.Key == "userText" { + return d.Value, true + } + } + return "", false +} + +// encodePayload combines an action ID and user data into a single encoded string +func encodePayload(actionID string, options frontend.NotificationOptions) (string, error) { + payload := NotificationPayload{ + Action: actionID, + Options: options, + } + + jsonData, err := json.Marshal(payload) + if err != nil { + return actionID, err + } + + encodedPayload := base64.StdEncoding.EncodeToString(jsonData) + return encodedPayload, nil +} + +// decodePayload extracts the action ID and user data from an encoded payload +func decodePayload(encodedString string) (string, frontend.NotificationOptions, error) { + jsonData, err := base64.StdEncoding.DecodeString(encodedString) + if err != nil { + return encodedString, frontend.NotificationOptions{}, fmt.Errorf("failed to decode base64 payload: %w", err) + } + + var payload NotificationPayload + if err := json.Unmarshal(jsonData, &payload); err != nil { + return encodedString, frontend.NotificationOptions{}, fmt.Errorf("failed to unmarshal notification payload: %w", err) + } + + return payload.Action, payload.Options, nil +} + +// parseNotificationResponse updated to use structured payload decoding +func parseNotificationResponse(response string) (action string, options frontend.NotificationOptions, err error) { + actionID, options, err := decodePayload(response) + + if err != nil { + log.Printf("Warning: Failed to decode notification response: %v", err) + return response, frontend.NotificationOptions{}, err + } + + return actionID, options, nil +} + +func handleNotificationResult(result frontend.NotificationResult) { + callbackLock.RLock() + callback := notificationResultCallback + callbackLock.RUnlock() + + if callback != nil { + go func() { + defer func() { + if r := recover(); r != nil { + // Log panic but don't crash the app + fmt.Fprintf(os.Stderr, "panic in notification callback: %v\n", r) + } + }() + callback(result) + }() + } +} + +// Helper functions + +func getGUID() (string, error) { + keyPath := ToastRegistryPath + appName + + k, err := registry.OpenKey(registry.CURRENT_USER, keyPath, registry.QUERY_VALUE) + if err == nil { + guid, _, err := k.GetStringValue(ToastRegistryGuidKey) + k.Close() + if err == nil && guid != "" { + return guid, nil + } + } + + guid := generateGUID() + + k, _, err = registry.CreateKey(registry.CURRENT_USER, keyPath, registry.WRITE) + if err != nil { + return "", fmt.Errorf("failed to create registry key: %w", err) + } + defer k.Close() + + if err := k.SetStringValue(ToastRegistryGuidKey, guid); err != nil { + return "", fmt.Errorf("failed to write GUID to registry: %w", err) + } + + return guid, nil +} + +func generateGUID() string { + guid := uuid.New() + return fmt.Sprintf("{%s}", guid.String()) +} diff --git a/v2/internal/frontend/desktop/windows/winc/icon.go b/v2/internal/frontend/desktop/windows/winc/icon.go index 6a3e1a391..94e9198d6 100644 --- a/v2/internal/frontend/desktop/windows/winc/icon.go +++ b/v2/internal/frontend/desktop/windows/winc/icon.go @@ -10,11 +10,86 @@ package winc import ( "errors" "fmt" + "image" + "image/png" + "os" "syscall" + "unsafe" "github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc/w32" ) +var ( + user32 = syscall.NewLazyDLL("user32.dll") + gdi32 = syscall.NewLazyDLL("gdi32.dll") + procGetIconInfo = user32.NewProc("GetIconInfo") + procDeleteObject = gdi32.NewProc("DeleteObject") + procGetObject = gdi32.NewProc("GetObjectW") + procGetDIBits = gdi32.NewProc("GetDIBits") + procCreateCompatibleDC = gdi32.NewProc("CreateCompatibleDC") + procSelectObject = gdi32.NewProc("SelectObject") + procDeleteDC = gdi32.NewProc("DeleteDC") +) + +func init() { + // Validate DLL loads at initialization time to surface missing APIs early + if err := user32.Load(); err != nil { + panic(fmt.Sprintf("failed to load user32.dll: %v", err)) + } + if err := gdi32.Load(); err != nil { + panic(fmt.Sprintf("failed to load gdi32.dll: %v", err)) + } +} + +// ICONINFO mirrors the Win32 ICONINFO struct +type ICONINFO struct { + FIcon int32 + XHotspot uint32 + YHotspot uint32 + HbmMask uintptr + HbmColor uintptr +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376.aspx +type BITMAPINFOHEADER struct { + BiSize uint32 + BiWidth int32 + BiHeight int32 + BiPlanes uint16 + BiBitCount uint16 + BiCompression uint32 + BiSizeImage uint32 + BiXPelsPerMeter int32 + BiYPelsPerMeter int32 + BiClrUsed uint32 + BiClrImportant uint32 +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162938.aspx +type RGBQUAD struct { + RgbBlue byte + RgbGreen byte + RgbRed byte + RgbReserved byte +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183375.aspx +type BITMAPINFO struct { + BmiHeader BITMAPINFOHEADER + BmiColors *RGBQUAD +} + +// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183371.aspx +type BITMAP struct { + BmType int32 + BmWidth int32 + BmHeight int32 + BmWidthBytes int32 + BmPlanes uint16 + BmBitsPixel uint16 + BmBits unsafe.Pointer +} + type Icon struct { handle w32.HICON } @@ -46,6 +121,95 @@ func ExtractIcon(fileName string, index int) (*Icon, error) { return ico, err } +func SaveHIconAsPNG(hIcon w32.HICON, filePath string) error { + // Get icon info + var iconInfo ICONINFO + ret, _, err := procGetIconInfo.Call( + uintptr(hIcon), + uintptr(unsafe.Pointer(&iconInfo)), + ) + if ret == 0 { + return err + } + defer procDeleteObject.Call(uintptr(iconInfo.HbmMask)) + defer procDeleteObject.Call(uintptr(iconInfo.HbmColor)) + + // Get bitmap info + var bmp BITMAP + ret, _, err = procGetObject.Call( + uintptr(iconInfo.HbmColor), + unsafe.Sizeof(bmp), + uintptr(unsafe.Pointer(&bmp)), + ) + if ret == 0 { + return err + } + + // Get screen DC for GetDIBits (bitmap must not be selected into a DC) + screenDC := w32.GetDC(0) + if screenDC == 0 { + return fmt.Errorf("failed to get screen DC") + } + defer w32.ReleaseDC(0, screenDC) + + // Prepare bitmap info header + var bi BITMAPINFO + bi.BmiHeader.BiSize = uint32(unsafe.Sizeof(bi.BmiHeader)) + bi.BmiHeader.BiWidth = bmp.BmWidth + bi.BmiHeader.BiHeight = bmp.BmHeight + bi.BmiHeader.BiPlanes = 1 + bi.BmiHeader.BiBitCount = 32 + bi.BmiHeader.BiCompression = w32.BI_RGB + + // Allocate memory for bitmap bits + width, height := int(bmp.BmWidth), int(bmp.BmHeight) + bufferSize := width * height * 4 + bits := make([]byte, bufferSize) + + // Get bitmap bits using screen DC (bitmap must not be selected into any DC) + ret, _, err = procGetDIBits.Call( + uintptr(screenDC), + uintptr(iconInfo.HbmColor), + 0, + uintptr(bmp.BmHeight), + uintptr(unsafe.Pointer(&bits[0])), + uintptr(unsafe.Pointer(&bi)), + w32.DIB_RGB_COLORS, + ) + if ret == 0 { + return fmt.Errorf("failed to get bitmap bits: %w", err) + } + + // Create Go image + img := image.NewRGBA(image.Rect(0, 0, width, height)) + + // Convert DIB to RGBA + for y := 0; y < height; y++ { + for x := 0; x < width; x++ { + // DIB is bottom-up, so we need to invert Y + dibIndex := ((height-1-y)*width + x) * 4 + // RGBA image is top-down + imgIndex := (y*width + x) * 4 + + // BGRA to RGBA + img.Pix[imgIndex] = bits[dibIndex+2] // R + img.Pix[imgIndex+1] = bits[dibIndex+1] // G + img.Pix[imgIndex+2] = bits[dibIndex] // B + img.Pix[imgIndex+3] = bits[dibIndex+3] // A + } + } + + // Create output file + outFile, err := os.Create(filePath) + if err != nil { + return err + } + defer outFile.Close() + + // Encode and save the image + return png.Encode(outFile, img) +} + func (ic *Icon) Destroy() bool { return w32.DestroyIcon(ic.handle) } diff --git a/v2/internal/frontend/desktop/windows/winc/w32/uxtheme.go b/v2/internal/frontend/desktop/windows/winc/w32/uxtheme.go index ed80d487f..8a14f0cb7 100644 --- a/v2/internal/frontend/desktop/windows/winc/w32/uxtheme.go +++ b/v2/internal/frontend/desktop/windows/winc/w32/uxtheme.go @@ -69,7 +69,7 @@ var ( setWindowTheme uintptr ) -func init() { +func Init() { // Library libuxtheme = MustLoadLibrary("uxtheme.dll") diff --git a/v2/internal/frontend/dispatcher/systemcalls.go b/v2/internal/frontend/dispatcher/systemcalls.go index b090a416e..a13eb03b9 100644 --- a/v2/internal/frontend/dispatcher/systemcalls.go +++ b/v2/internal/frontend/dispatcher/systemcalls.go @@ -61,6 +61,102 @@ func (d *Dispatcher) processSystemCall(payload callMessage, sender frontend.Fron return false, err } return true, nil + case "InitializeNotifications": + err := sender.InitializeNotifications() + return nil, err + case "CleanupNotifications": + sender.CleanupNotifications() + return nil, nil + case "IsNotificationAvailable": + return sender.IsNotificationAvailable(), nil + case "RequestNotificationAuthorization": + authorized, err := sender.RequestNotificationAuthorization() + if err != nil { + return nil, err + } + return authorized, nil + case "CheckNotificationAuthorization": + authorized, err := sender.CheckNotificationAuthorization() + if err != nil { + return nil, err + } + return authorized, nil + case "SendNotification": + if len(payload.Args) < 1 { + return nil, errors.New("empty argument, cannot send notification") + } + var options frontend.NotificationOptions + if err := json.Unmarshal(payload.Args[0], &options); err != nil { + return nil, err + } + err := sender.SendNotification(options) + return nil, err + case "SendNotificationWithActions": + if len(payload.Args) < 1 { + return nil, errors.New("empty argument, cannot send notification") + } + var options frontend.NotificationOptions + if err := json.Unmarshal(payload.Args[0], &options); err != nil { + return nil, err + } + err := sender.SendNotificationWithActions(options) + return nil, err + case "RegisterNotificationCategory": + if len(payload.Args) < 1 { + return nil, errors.New("empty argument, cannot register category") + } + var category frontend.NotificationCategory + if err := json.Unmarshal(payload.Args[0], &category); err != nil { + return nil, err + } + err := sender.RegisterNotificationCategory(category) + return nil, err + case "RemoveNotificationCategory": + if len(payload.Args) < 1 { + return nil, errors.New("empty argument, cannot remove category") + } + var categoryId string + if err := json.Unmarshal(payload.Args[0], &categoryId); err != nil { + return nil, err + } + err := sender.RemoveNotificationCategory(categoryId) + return nil, err + case "RemoveAllPendingNotifications": + err := sender.RemoveAllPendingNotifications() + return nil, err + case "RemovePendingNotification": + if len(payload.Args) < 1 { + return nil, errors.New("empty argument, cannot remove notification") + } + var identifier string + if err := json.Unmarshal(payload.Args[0], &identifier); err != nil { + return nil, err + } + err := sender.RemovePendingNotification(identifier) + return nil, err + case "RemoveAllDeliveredNotifications": + err := sender.RemoveAllDeliveredNotifications() + return nil, err + case "RemoveDeliveredNotification": + if len(payload.Args) < 1 { + return nil, errors.New("empty argument, cannot remove notification") + } + var identifier string + if err := json.Unmarshal(payload.Args[0], &identifier); err != nil { + return nil, err + } + err := sender.RemoveDeliveredNotification(identifier) + return nil, err + case "RemoveNotification": + if len(payload.Args) < 1 { + return nil, errors.New("empty argument, cannot remove notification") + } + var identifier string + if err := json.Unmarshal(payload.Args[0], &identifier); err != nil { + return nil, err + } + err := sender.RemoveNotification(identifier) + return nil, err default: return nil, fmt.Errorf("unknown systemcall message: %s", payload.Name) } diff --git a/v2/internal/frontend/frontend.go b/v2/internal/frontend/frontend.go index 6b2ccbcae..873b61dc7 100644 --- a/v2/internal/frontend/frontend.go +++ b/v2/internal/frontend/frontend.go @@ -76,6 +76,51 @@ type MessageDialogOptions struct { Icon []byte } +// NotificationOptions contains configuration for a notification. +type NotificationOptions struct { + ID string `json:"id"` + Title string `json:"title"` + Subtitle string `json:"subtitle,omitempty"` // (macOS and Linux only) + Body string `json:"body,omitempty"` + CategoryID string `json:"categoryId,omitempty"` + Data map[string]interface{} `json:"data,omitempty"` +} + +// NotificationAction represents an action button for a notification. +type NotificationAction struct { + ID string `json:"id,omitempty"` + Title string `json:"title,omitempty"` + Destructive bool `json:"destructive,omitempty"` // (macOS-specific) +} + +// NotificationCategory groups actions for notifications. +type NotificationCategory struct { + ID string `json:"id,omitempty"` + Actions []NotificationAction `json:"actions,omitempty"` + HasReplyField bool `json:"hasReplyField,omitempty"` + ReplyPlaceholder string `json:"replyPlaceholder,omitempty"` + ReplyButtonTitle string `json:"replyButtonTitle,omitempty"` +} + +// NotificationResponse represents the response sent by interacting with a notification. +type NotificationResponse struct { + ID string `json:"id,omitempty"` + ActionIdentifier string `json:"actionIdentifier,omitempty"` + CategoryID string `json:"categoryId,omitempty"` // Consistent with NotificationOptions + Title string `json:"title,omitempty"` + Subtitle string `json:"subtitle,omitempty"` // (macOS and Linux only) + Body string `json:"body,omitempty"` + UserText string `json:"userText,omitempty"` + UserInfo map[string]interface{} `json:"userInfo,omitempty"` +} + +// NotificationResult represents the result of a notification response, +// returning the response or any errors that occurred. +type NotificationResult struct { + Response NotificationResponse + Error error +} + type Frontend interface { Run(ctx context.Context) error RunMainLoop() @@ -139,4 +184,21 @@ type Frontend interface { // Clipboard ClipboardGetText() (string, error) ClipboardSetText(text string) error + + // Notifications + InitializeNotifications() error + CleanupNotifications() + IsNotificationAvailable() bool + RequestNotificationAuthorization() (bool, error) + CheckNotificationAuthorization() (bool, error) + OnNotificationResponse(callback func(result NotificationResult)) + SendNotification(options NotificationOptions) error + SendNotificationWithActions(options NotificationOptions) error + RegisterNotificationCategory(category NotificationCategory) error + RemoveNotificationCategory(categoryId string) error + RemoveAllPendingNotifications() error + RemovePendingNotification(identifier string) error + RemoveAllDeliveredNotifications() error + RemoveDeliveredNotification(identifier string) error + RemoveNotification(identifier string) error } diff --git a/v2/internal/frontend/runtime/desktop/draganddrop.js b/v2/internal/frontend/runtime/desktop/draganddrop.js index 8a088e5b8..e470e4823 100644 --- a/v2/internal/frontend/runtime/desktop/draganddrop.js +++ b/v2/internal/frontend/runtime/desktop/draganddrop.js @@ -44,15 +44,27 @@ function checkStyleDropTarget(style) { /** * onDragOver is called when the dragover event is emitted. - * @param {DragEvent} e - * @returns + * @param {DragEvent} e + * @returns */ function onDragOver(e) { + // Check if this is an external file drop or internal HTML drag + // External file drops will have "Files" in the types array + // Internal HTML drags typically have "text/plain", "text/html" or custom types + const isFileDrop = e.dataTransfer.types.includes("Files"); + + // Only handle external file drops, let internal HTML5 drag-and-drop work normally + if (!isFileDrop) { + return; + } + + // ALWAYS prevent default for file drops to stop browser navigation + e.preventDefault(); + e.dataTransfer.dropEffect = 'copy'; + if (!window.wails.flags.enableWailsDragAndDrop) { return; } - e.dataTransfer.dropEffect = 'copy'; - e.preventDefault(); if (!flags.useDropTarget) { return; @@ -80,14 +92,24 @@ function onDragOver(e) { /** * onDragLeave is called when the dragleave event is emitted. - * @param {DragEvent} e - * @returns + * @param {DragEvent} e + * @returns */ function onDragLeave(e) { + // Check if this is an external file drop or internal HTML drag + const isFileDrop = e.dataTransfer.types.includes("Files"); + + // Only handle external file drops, let internal HTML5 drag-and-drop work normally + if (!isFileDrop) { + return; + } + + // ALWAYS prevent default for file drops to stop browser navigation + e.preventDefault(); + if (!window.wails.flags.enableWailsDragAndDrop) { return; } - e.preventDefault(); if (!flags.useDropTarget) { return; @@ -122,14 +144,24 @@ function onDragLeave(e) { /** * onDrop is called when the drop event is emitted. - * @param {DragEvent} e - * @returns + * @param {DragEvent} e + * @returns */ function onDrop(e) { + // Check if this is an external file drop or internal HTML drag + const isFileDrop = e.dataTransfer.types.includes("Files"); + + // Only handle external file drops, let internal HTML5 drag-and-drop work normally + if (!isFileDrop) { + return; + } + + // ALWAYS prevent default for file drops to stop browser navigation + e.preventDefault(); + if (!window.wails.flags.enableWailsDragAndDrop) { return; } - e.preventDefault(); if (CanResolveFilePaths()) { // process files diff --git a/v2/internal/frontend/runtime/desktop/main.js b/v2/internal/frontend/runtime/desktop/main.js index 3fda7ef36..405d5f60d 100644 --- a/v2/internal/frontend/runtime/desktop/main.js +++ b/v2/internal/frontend/runtime/desktop/main.js @@ -27,6 +27,7 @@ import * as Browser from "./browser"; import * as Clipboard from "./clipboard"; import * as DragAndDrop from "./draganddrop"; import * as ContextMenu from "./contextmenu"; +import * as Notifications from "./notifications"; export function Quit() { window.WailsInvoke('Q'); @@ -52,6 +53,7 @@ window.runtime = { ...Screen, ...Clipboard, ...DragAndDrop, + ...Notifications, EventsOn, EventsOnce, EventsOnMultiple, diff --git a/v2/internal/frontend/runtime/desktop/notifications.js b/v2/internal/frontend/runtime/desktop/notifications.js new file mode 100644 index 000000000..25c01bb34 --- /dev/null +++ b/v2/internal/frontend/runtime/desktop/notifications.js @@ -0,0 +1,200 @@ +/* + _ __ _ __ +| | / /___ _(_) /____ +| | /| / / __ `/ / / ___/ +| |/ |/ / /_/ / / (__ ) +|__/|__/\__,_/_/_/____/ +The electron alternative for Go +(c) Lea Anthony 2019-present +*/ +/* jshint esversion: 9 */ + +import {Call} from "./calls"; + +/** + * Initialize the notification service for the application. + * This must be called before sending any notifications. + * On macOS, this also ensures the notification delegate is properly initialized. + * + * @export + * @return {Promise} + */ +export function InitializeNotifications() { + return Call(":wails:InitializeNotifications"); +} + +/** + * Clean up notification resources and release any held connections. + * This should be called when shutting down the application to properly release resources + * (primarily needed on Linux to close D-Bus connections). + * + * @export + * @return {Promise} + */ +export function CleanupNotifications() { + return Call(":wails:CleanupNotifications"); +} + +/** + * Check if notifications are available on the current platform. + * + * @export + * @return {Promise} True if notifications are available, false otherwise + */ +export function IsNotificationAvailable() { + return Call(":wails:IsNotificationAvailable"); +} + +/** + * Request notification authorization from the user. + * On macOS, this prompts the user to allow notifications. + * On other platforms, this always returns true. + * + * @export + * @return {Promise} True if authorization was granted, false otherwise + */ +export function RequestNotificationAuthorization() { + return Call(":wails:RequestNotificationAuthorization"); +} + +/** + * Check the current notification authorization status. + * On macOS, this checks if the app has notification permissions. + * On other platforms, this always returns true. + * + * @export + * @return {Promise} True if authorized, false otherwise + */ +export function CheckNotificationAuthorization() { + return Call(":wails:CheckNotificationAuthorization"); +} + +/** + * Send a basic notification with the given options. + * The notification will display with the provided title, subtitle (if supported), and body text. + * + * @export + * @param {Object} options - Notification options + * @param {string} options.id - Unique identifier for the notification + * @param {string} options.title - Notification title + * @param {string} [options.subtitle] - Notification subtitle (macOS and Linux only) + * @param {string} [options.body] - Notification body text + * @param {string} [options.categoryId] - Category ID for action buttons (requires SendNotificationWithActions) + * @param {Object} [options.data] - Additional user data to attach to the notification + * @return {Promise} + */ +export function SendNotification(options) { + return Call(":wails:SendNotification", [options]); +} + +/** + * Send a notification with action buttons. + * A NotificationCategory must be registered first using RegisterNotificationCategory. + * The options.categoryId must match a previously registered category ID. + * If the category is not found, a basic notification will be sent instead. + * + * @export + * @param {Object} options - Notification options + * @param {string} options.id - Unique identifier for the notification + * @param {string} options.title - Notification title + * @param {string} [options.subtitle] - Notification subtitle (macOS and Linux only) + * @param {string} [options.body] - Notification body text + * @param {string} options.categoryId - Category ID that matches a registered category + * @param {Object} [options.data] - Additional user data to attach to the notification + * @return {Promise} + */ +export function SendNotificationWithActions(options) { + return Call(":wails:SendNotificationWithActions", [options]); +} + +/** + * Register a notification category that can be used with SendNotificationWithActions. + * Categories define the action buttons and optional reply fields that will appear on notifications. + * Registering a category with the same ID as a previously registered category will override it. + * + * @export + * @param {Object} category - Notification category definition + * @param {string} category.id - Unique identifier for the category + * @param {Array} [category.actions] - Array of action buttons + * @param {string} category.actions[].id - Unique identifier for the action + * @param {string} category.actions[].title - Display title for the action button + * @param {boolean} [category.actions[].destructive] - Whether the action is destructive (macOS-specific) + * @param {boolean} [category.hasReplyField] - Whether to include a text input field for replies + * @param {string} [category.replyPlaceholder] - Placeholder text for the reply field (required if hasReplyField is true) + * @param {string} [category.replyButtonTitle] - Title for the reply button (required if hasReplyField is true) + * @return {Promise} + */ +export function RegisterNotificationCategory(category) { + return Call(":wails:RegisterNotificationCategory", [category]); +} + +/** + * Remove a previously registered notification category. + * + * @export + * @param {string} categoryId - The ID of the category to remove + * @return {Promise} + */ +export function RemoveNotificationCategory(categoryId) { + return Call(":wails:RemoveNotificationCategory", [categoryId]); +} + +/** + * Remove all pending notifications from the notification center. + * On Windows, this is a no-op as the platform manages notification lifecycle automatically. + * + * @export + * @return {Promise} + */ +export function RemoveAllPendingNotifications() { + return Call(":wails:RemoveAllPendingNotifications"); +} + +/** + * Remove a specific pending notification by its identifier. + * On Windows, this is a no-op as the platform manages notification lifecycle automatically. + * + * @export + * @param {string} identifier - The ID of the notification to remove + * @return {Promise} + */ +export function RemovePendingNotification(identifier) { + return Call(":wails:RemovePendingNotification", [identifier]); +} + +/** + * Remove all delivered notifications from the notification center. + * On Windows, this is a no-op as the platform manages notification lifecycle automatically. + * + * @export + * @return {Promise} + */ +export function RemoveAllDeliveredNotifications() { + return Call(":wails:RemoveAllDeliveredNotifications"); +} + +/** + * Remove a specific delivered notification by its identifier. + * On Windows, this is a no-op as the platform manages notification lifecycle automatically. + * + * @export + * @param {string} identifier - The ID of the notification to remove + * @return {Promise} + */ +export function RemoveDeliveredNotification(identifier) { + return Call(":wails:RemoveDeliveredNotification", [identifier]); +} + +/** + * Remove a notification by its identifier. + * This is a convenience function that works across platforms. + * On macOS, use the more specific RemovePendingNotification or RemoveDeliveredNotification functions. + * + * @export + * @param {string} identifier - The ID of the notification to remove + * @return {Promise} + */ +export function RemoveNotification(identifier) { + return Call(":wails:RemoveNotification", [identifier]); +} + diff --git a/v2/internal/frontend/runtime/ipc_websocket.js b/v2/internal/frontend/runtime/ipc_websocket.js index 1ca048df1..a0d6b4a70 100644 --- a/v2/internal/frontend/runtime/ipc_websocket.js +++ b/v2/internal/frontend/runtime/ipc_websocket.js @@ -1,9 +1,9 @@ (()=>{function D(t){console.log("%c wails dev %c "+t+" ","background: #aa0000; color: #fff; border-radius: 3px 0px 0px 3px; padding: 1px; font-size: 0.7rem","background: #009900; color: #fff; border-radius: 0px 3px 3px 0px; padding: 1px; font-size: 0.7rem")}function _(){}var A=t=>t;function N(t){return t()}function it(){return Object.create(null)}function b(t){t.forEach(N)}function w(t){return typeof t=="function"}function L(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function ot(t){return Object.keys(t).length===0}function rt(t,...e){if(t==null)return _;let n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function st(t,e,n){t.$$.on_destroy.push(rt(e,n))}var ct=typeof window!="undefined",Ot=ct?()=>window.performance.now():()=>Date.now(),P=ct?t=>requestAnimationFrame(t):_;var x=new Set;function lt(t){x.forEach(e=>{e.c(t)||(x.delete(e),e.f())}),x.size!==0&&P(lt)}function Dt(t){let e;return x.size===0&&P(lt),{promise:new Promise(n=>{x.add(e={c:t,f:n})}),abort(){x.delete(e)}}}var ut=!1;function At(){ut=!0}function Lt(){ut=!1}function Bt(t,e){t.appendChild(e)}function at(t,e,n){let i=R(t);if(!i.getElementById(e)){let o=B("style");o.id=e,o.textContent=n,ft(i,o)}}function R(t){if(!t)return document;let e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Tt(t){let e=B("style");return ft(R(t),e),e.sheet}function ft(t,e){return Bt(t.head||t,e),e.sheet}function W(t,e,n){t.insertBefore(e,n||null)}function S(t){t.parentNode.removeChild(t)}function B(t){return document.createElement(t)}function Jt(t){return document.createTextNode(t)}function dt(){return Jt("")}function ht(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function zt(t){return Array.from(t.childNodes)}function Ht(t,e,{bubbles:n=!1,cancelable:i=!1}={}){let o=document.createEvent("CustomEvent");return o.initCustomEvent(t,n,i,e),o}var T=new Map,J=0;function Gt(t){let e=5381,n=t.length;for(;n--;)e=(e<<5)-e^t.charCodeAt(n);return e>>>0}function qt(t,e){let n={stylesheet:Tt(e),rules:{}};return T.set(t,n),n}function pt(t,e,n,i,o,c,s,l=0){let f=16.666/i,r=`{ `;for(let g=0;g<=1;g+=f){let F=e+(n-e)*c(g);r+=g*100+`%{${s(F,1-F)}} `}let y=r+`100% {${s(n,1-n)}} -}`,a=`__svelte_${Gt(y)}_${l}`,u=R(t),{stylesheet:h,rules:p}=T.get(u)||qt(u,t);p[a]||(p[a]=!0,h.insertRule(`@keyframes ${a} ${y}`,h.cssRules.length));let v=t.style.animation||"";return t.style.animation=`${v?`${v}, `:""}${a} ${i}ms linear ${o}ms 1 both`,J+=1,a}function Kt(t,e){let n=(t.style.animation||"").split(", "),i=n.filter(e?c=>c.indexOf(e)<0:c=>c.indexOf("__svelte")===-1),o=n.length-i.length;o&&(t.style.animation=i.join(", "),J-=o,J||Nt())}function Nt(){P(()=>{J||(T.forEach(t=>{let{ownerNode:e}=t.stylesheet;e&&S(e)}),T.clear())})}var V;function C(t){V=t}var k=[];var _t=[],z=[],mt=[],Pt=Promise.resolve(),U=!1;function Rt(){U||(U=!0,Pt.then(yt))}function $(t){z.push(t)}var X=new Set,H=0;function yt(){let t=V;do{for(;H{E=null})),E}function Z(t,e,n){t.dispatchEvent(Ht(`${e?"intro":"outro"}${n}`))}var G=new Set,m;function gt(){m={r:0,c:[],p:m}}function bt(){m.r||b(m.c),m=m.p}function I(t,e){t&&t.i&&(G.delete(t),t.i(e))}function Q(t,e,n,i){if(t&&t.o){if(G.has(t))return;G.add(t),m.c.push(()=>{G.delete(t),i&&(n&&t.d(1),i())}),t.o(e)}else i&&i()}var Ut={duration:0};function Y(t,e,n,i){let o=e(t,n),c=i?0:1,s=null,l=null,f=null;function r(){f&&Kt(t,f)}function y(u,h){let p=u.b-c;return h*=Math.abs(p),{a:c,b:u.b,d:p,duration:h,start:u.start,end:u.start+h,group:u.group}}function a(u){let{delay:h=0,duration:p=300,easing:v=A,tick:g=_,css:F}=o||Ut,K={start:Ot()+h,b:u};u||(K.group=m,m.r+=1),s||l?l=K:(F&&(r(),f=pt(t,c,u,p,h,v,F)),u&&g(0,1),s=y(K,p),$(()=>Z(t,u,"start")),Dt(O=>{if(l&&O>l.start&&(s=y(l,p),l=null,Z(t,s.b,"start"),F&&(r(),f=pt(t,c,s.b,s.duration,0,v,o.css))),s){if(O>=s.end)g(c=s.b,1-c),Z(t,s.b,"end"),l||(s.b?r():--s.group.r||b(s.group.c)),s=null;else if(O>=s.start){let jt=O-s.start;c=s.a+s.d*v(jt/s.duration),g(c,1-c)}}return!!(s||l)}))}return{run(u){w(o)?Vt().then(()=>{o=o(),a(u)}):a(u)},end(){r(),s=l=null}}}var le=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var ue=new Set(["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]);function Xt(t,e,n,i){let{fragment:o,after_update:c}=t.$$;o&&o.m(e,n),i||$(()=>{let s=t.$$.on_mount.map(N).filter(w);t.$$.on_destroy?t.$$.on_destroy.push(...s):b(s),t.$$.on_mount=[]}),c.forEach($)}function wt(t,e){let n=t.$$;n.fragment!==null&&(b(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Zt(t,e){t.$$.dirty[0]===-1&&(k.push(t),Rt(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{let p=h.length?h[0]:u;return r.ctx&&o(r.ctx[a],r.ctx[a]=p)&&(!r.skip_bound&&r.bound[a]&&r.bound[a](p),y&&Zt(t,a)),u}):[],r.update(),y=!0,b(r.before_update),r.fragment=i?i(r.ctx):!1,e.target){if(e.hydrate){At();let a=zt(e.target);r.fragment&&r.fragment.l(a),a.forEach(S)}else r.fragment&&r.fragment.c();e.intro&&I(t.$$.fragment),Xt(t,e.target,e.anchor,e.customElement),Lt(),yt()}C(f)}var Qt;typeof HTMLElement=="function"&&(Qt=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(N).filter(w);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){b(this.$$.on_disconnect)}$destroy(){wt(this,1),this.$destroy=_}$on(t,e){if(!w(e))return _;let n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}$set(t){this.$$set&&!ot(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var tt=class{$destroy(){wt(this,1),this.$destroy=_}$on(e,n){if(!w(n))return _;let i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{let o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!ot(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var M=[];function Ft(t,e=_){let n,i=new Set;function o(l){if(L(t,l)&&(t=l,n)){let f=!M.length;for(let r of i)r[1](),M.push(r,t);if(f){for(let r=0;r{i.delete(r),i.size===0&&(n(),n=null)}}return{set:o,update:c,subscribe:s}}var q=Ft(!1);function xt(){q.set(!0)}function $t(){q.set(!1)}function et(t,{delay:e=0,duration:n=400,easing:i=A}={}){let o=+getComputedStyle(t).opacity;return{delay:e,duration:n,easing:i,css:c=>`opacity: ${c*o}`}}function Yt(t){at(t,"svelte-181h7z",`.wails-reconnect-overlay.svelte-181h7z{position:fixed;top:0;left:0;width:100%;height:100%;backdrop-filter:blur(2px) saturate(0%) contrast(50%) brightness(25%);z-index:999999\r - }.wails-reconnect-overlay-content.svelte-181h7z{position:relative;top:50%;transform:translateY(-50%);margin:0;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAA7CAMAAAAEsocZAAAC91BMVEUAAACzQ0PjMjLkMjLZLS7XLS+vJCjkMjKlEx6uGyHjMDGiFx7GJyrAISjUKy3mMzPlMjLjMzOsGyDKJirkMjK6HyXmMjLgMDC6IiLcMjLULC3MJyrRKSy+IibmMzPmMjK7ISXlMjLIJimzHSLkMjKtGiHZLC7BIifgMDCpGSDFIivcLy+yHSKoGR+eFBzNKCvlMjKxHSPkMTKxHSLmMjLKJyq5ICXDJCe6ISXdLzDkMjLmMzPFJSm2HyTlMTLhMDGyHSKUEBmhFx24HyTCJCjHJijjMzOiFh7mMjJ6BhDaLDCuGyOKABjnMzPGJinJJiquHCGEChSmGB/pMzOiFh7VKy3OKCu1HiSvHCLjMTLMKCrBIyeICxWxHCLDIyjSKizBIyh+CBO9ISa6ISWDChS9Iie1HyXVLC7FJSrLKCrlMjLiMTGPDhicFRywGyKXFBuhFx1/BxO7IiXkMTGeFBx8BxLkMTGnGR/GJCi4ICWsGyGJDxXSLS2yGiHSKi3CJCfnMzPQKiyECRTKJiq6ISWUERq/Iye0HiPDJCjGJSm6ICaPDxiTEBrdLy+3HyXSKiy0HyOQEBi4ICWhFh1+CBO9IieODhfSKyzWLC2LDhh8BxHKKCq7ISWaFBzkMzPqNDTTLC3EJSiHDBacExyvGyO1HyTPKCy+IieoGSC7ISaVEhrMKCvQKyusGyG0HiKACBPIJSq/JCaABxR5BRLEJCnkMzPJJinEJimPDRZ2BRKqHx/jMjLnMzPgMDHULC3NKSvQKSzsNDTWLS7SKyy3HyTKJyrDJSjbLzDY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UDLiZwMWLJZKNLzoLbJBYVcurSmbmn+rcyJ8vCMgmlmaW6gnwun/+3C96VpAUuET1ZgRR36r2xWlnYSnf3oKABA14uXDDvydxHs6cpTV1p3hlJ2rJCiUjIZCByItXg8sHJijuvT64CuMTABUYvb6NN1Jdp1PH7D7f3bo2eS5KvW4RJr7atWT5w4MBBg9zdBw9+37BS7QIoFS5WnIaj12dr1DEXFgdvr4fh4eFl+u/wz8uf3jjHic8s4DL2Dal0IANyUBeCRCcwOBJV26JsjSpGwHVuSai69jvqD+jr56OgtKy0zAAK5mLTVBKVKL5tNthGAR9JneJQ/bFsHNzy+U7IlCYROxtMpIjR0ceoQVnowracLLpAQWETqV361bPoFo3cEbz2zYLZM7t3HWXcxmiBOgttS1ycWkTXMWh4mGigdug9DFdttqCFgTN6nD0q1XEVSoCxEjyFCi2eNC6Z69MRVIImJ6JQSf5gcFVCuF+aDhCa1F6MJFDaiNBQAh2TMfWBjhmLsAxUjG/fmjs0qjJck8D0GPBcuUuZW1LS/tIsPzqmQt17PvZQknlwnf4tHDBc+7t5VV3QQCkdc+Ur8/hdrz0but0RCumWiYbiKmLJ7EVbRomj4Q7+y5wsaXvfTGFpQcHB7n2WbG4MGdniw2Tm8xl5Yhr7MrSYHQ3uampz10aWyHyuzxvqaW/6W4MjXAUD3QV2aw97ZxhGjxCohYf5TpTHMXU1BbsAuoFnkRygVieIGAbqiF7rrH4rfWpKJouBCtyHJF8ctEyGubBa+C6NsMYEUonJFITHZqWBxXUA12Dv76Tf/PgOBmeNiiLG1pcKo1HAq8jLpY4JU1yWEixVNaOgoRJAKBSZHTZTU+wJOMtUDZvlVITC6FTlksyrEBoPHXpxxbzdaqzigUtVDkJVIOtVQ9UEOR4VGUh/kHWq0edJ6CxnZ+eePXva2bnY/cF/I1RLLf8vvwDANdMSMegxcAAAAABJRU5ErkJggg==);background-repeat:no-repeat;background-position:center\r - }.wails-reconnect-overlay-loadingspinner.svelte-181h7z{pointer-events:none;width:2.5em;height:2.5em;border:.4em solid transparent;border-color:#f00 #eee0 #f00 #eee0;border-radius:50%;animation:svelte-181h7z-loadingspin 1s linear infinite;margin:auto;padding:2.5em\r +}`,a=`__svelte_${Gt(y)}_${l}`,u=R(t),{stylesheet:h,rules:p}=T.get(u)||qt(u,t);p[a]||(p[a]=!0,h.insertRule(`@keyframes ${a} ${y}`,h.cssRules.length));let v=t.style.animation||"";return t.style.animation=`${v?`${v}, `:""}${a} ${i}ms linear ${o}ms 1 both`,J+=1,a}function Kt(t,e){let n=(t.style.animation||"").split(", "),i=n.filter(e?c=>c.indexOf(e)<0:c=>c.indexOf("__svelte")===-1),o=n.length-i.length;o&&(t.style.animation=i.join(", "),J-=o,J||Nt())}function Nt(){P(()=>{J||(T.forEach(t=>{let{ownerNode:e}=t.stylesheet;e&&S(e)}),T.clear())})}var V;function C(t){V=t}var k=[];var _t=[],z=[],mt=[],Pt=Promise.resolve(),U=!1;function Rt(){U||(U=!0,Pt.then(yt))}function $(t){z.push(t)}var X=new Set,H=0;function yt(){let t=V;do{for(;H{E=null})),E}function Z(t,e,n){t.dispatchEvent(Ht(`${e?"intro":"outro"}${n}`))}var G=new Set,m;function gt(){m={r:0,c:[],p:m}}function bt(){m.r||b(m.c),m=m.p}function I(t,e){t&&t.i&&(G.delete(t),t.i(e))}function Q(t,e,n,i){if(t&&t.o){if(G.has(t))return;G.add(t),m.c.push(()=>{G.delete(t),i&&(n&&t.d(1),i())}),t.o(e)}else i&&i()}var Ut={duration:0};function Y(t,e,n,i){let o=e(t,n),c=i?0:1,s=null,l=null,f=null;function r(){f&&Kt(t,f)}function y(u,h){let p=u.b-c;return h*=Math.abs(p),{a:c,b:u.b,d:p,duration:h,start:u.start,end:u.start+h,group:u.group}}function a(u){let{delay:h=0,duration:p=300,easing:v=A,tick:g=_,css:F}=o||Ut,K={start:Ot()+h,b:u};u||(K.group=m,m.r+=1),s||l?l=K:(F&&(r(),f=pt(t,c,u,p,h,v,F)),u&&g(0,1),s=y(K,p),$(()=>Z(t,u,"start")),Dt(O=>{if(l&&O>l.start&&(s=y(l,p),l=null,Z(t,s.b,"start"),F&&(r(),f=pt(t,c,s.b,s.duration,0,v,o.css))),s){if(O>=s.end)g(c=s.b,1-c),Z(t,s.b,"end"),l||(s.b?r():--s.group.r||b(s.group.c)),s=null;else if(O>=s.start){let jt=O-s.start;c=s.a+s.d*v(jt/s.duration),g(c,1-c)}}return!!(s||l)}))}return{run(u){w(o)?Vt().then(()=>{o=o(),a(u)}):a(u)},end(){r(),s=l=null}}}var le=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var ue=new Set(["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]);function Xt(t,e,n,i){let{fragment:o,after_update:c}=t.$$;o&&o.m(e,n),i||$(()=>{let s=t.$$.on_mount.map(N).filter(w);t.$$.on_destroy?t.$$.on_destroy.push(...s):b(s),t.$$.on_mount=[]}),c.forEach($)}function wt(t,e){let n=t.$$;n.fragment!==null&&(b(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Zt(t,e){t.$$.dirty[0]===-1&&(k.push(t),Rt(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{let p=h.length?h[0]:u;return r.ctx&&o(r.ctx[a],r.ctx[a]=p)&&(!r.skip_bound&&r.bound[a]&&r.bound[a](p),y&&Zt(t,a)),u}):[],r.update(),y=!0,b(r.before_update),r.fragment=i?i(r.ctx):!1,e.target){if(e.hydrate){At();let a=zt(e.target);r.fragment&&r.fragment.l(a),a.forEach(S)}else r.fragment&&r.fragment.c();e.intro&&I(t.$$.fragment),Xt(t,e.target,e.anchor,e.customElement),Lt(),yt()}C(f)}var Qt;typeof HTMLElement=="function"&&(Qt=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(N).filter(w);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){b(this.$$.on_disconnect)}$destroy(){wt(this,1),this.$destroy=_}$on(t,e){if(!w(e))return _;let n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}$set(t){this.$$set&&!ot(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var tt=class{$destroy(){wt(this,1),this.$destroy=_}$on(e,n){if(!w(n))return _;let i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{let o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!ot(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var M=[];function Ft(t,e=_){let n,i=new Set;function o(l){if(L(t,l)&&(t=l,n)){let f=!M.length;for(let r of i)r[1](),M.push(r,t);if(f){for(let r=0;r{i.delete(r),i.size===0&&(n(),n=null)}}return{set:o,update:c,subscribe:s}}var q=Ft(!1);function xt(){q.set(!0)}function $t(){q.set(!1)}function et(t,{delay:e=0,duration:n=400,easing:i=A}={}){let o=+getComputedStyle(t).opacity;return{delay:e,duration:n,easing:i,css:c=>`opacity: ${c*o}`}}function Yt(t){at(t,"svelte-181h7z",`.wails-reconnect-overlay.svelte-181h7z{position:fixed;top:0;left:0;width:100%;height:100%;backdrop-filter:blur(2px) saturate(0%) contrast(50%) brightness(25%);z-index:999999 + }.wails-reconnect-overlay-content.svelte-181h7z{position:relative;top:50%;transform:translateY(-50%);margin:0;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAA7CAMAAAAEsocZAAAC91BMVEUAAACzQ0PjMjLkMjLZLS7XLS+vJCjkMjKlEx6uGyHjMDGiFx7GJyrAISjUKy3mMzPlMjLjMzOsGyDKJirkMjK6HyX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QVnowracLLpAQWETqV361bPoFo3cEbz2zYLZM7t3HWXcxmiBOgttS1ycWkTXMWh4mGigdug9DFdttqCFgTN6nD0q1XEVSoCxEjyFCi2eNC6Z69MRVIImJ6JQSf5gcFVCuF+aDhCa1F6MJFDaiNBQAh2TMfWBjhmLsAxUjG/fmjs0qjJck8D0GPBcuUuZW1LS/tIsPzqmQt17PvZQknlwnf4tHDBc+7t5VV3QQCkdc+Ur8/hdrz0but0RCumWiYbiKmLJ7EVbRomj4Q7+y5wsaXvfTGFpQcHB7n2WbG4MGdniw2Tm8xl5Yhr7MrSYHQ3uampz10aWyHyuzxvqaW/6W4MjXAUD3QV2aw97ZxhGjxCohYf5TpTHMXU1BbsAuoFnkRygVieIGAbqiF7rrH4rfWpKJouBCtyHJF8ctEyGubBa+C6NsMYEUonJFITHZqWBxXUA12Dv76Tf/PgOBmeNiiLG1pcKo1HAq8jLpY4JU1yWEixVNaOgoRJAKBSZHTZTU+wJOMtUDZvlVITC6FTlksyrEBoPHXpxxbzdaqzigUtVDkJVIOtVQ9UEOR4VGUh/kHWq0edJ6CxnZ+eePXva2bnY/cF/I1RLLf8vvwDANdMSMegxcAAAAABJRU5ErkJggg==);background-repeat:no-repeat;background-position:center + }.wails-reconnect-overlay-loadingspinner.svelte-181h7z{pointer-events:none;width:2.5em;height:2.5em;border:.4em solid transparent;border-color:#f00 #eee0 #f00 #eee0;border-radius:50%;animation:svelte-181h7z-loadingspin 1s linear infinite;margin:auto;padding:2.5em }@keyframes svelte-181h7z-loadingspin{100%{transform:rotate(360deg)}}`)}function Mt(t){let e,n,i;return{c(){e=B("div"),e.innerHTML='
',ht(e,"class","wails-reconnect-overlay svelte-181h7z")},m(o,c){W(o,e,c),i=!0},i(o){i||($(()=>{n||(n=Y(e,et,{duration:300},!0)),n.run(1)}),i=!0)},o(o){n||(n=Y(e,et,{duration:300},!1)),n.run(0),i=!1},d(o){o&&S(e),o&&n&&n.end()}}}function te(t){let e,n,i=t[0]&&Mt(t);return{c(){i&&i.c(),e=dt()},m(o,c){i&&i.m(o,c),W(o,e,c),n=!0},p(o,[c]){o[0]?i?c&1&&I(i,1):(i=Mt(o),i.c(),I(i,1),i.m(e.parentNode,e)):i&&(gt(),Q(i,1,1,()=>{i=null}),bt())},i(o){n||(I(i),n=!0)},o(o){Q(i),n=!1},d(o){i&&i.d(o),o&&S(e)}}}function ee(t,e,n){let i;return st(t,q,o=>n(0,i=o)),[i]}var St=class extends tt{constructor(e){super();vt(this,e,ee,te,L,{},Yt)}},Ct=St;var ne={},nt=null,j=[];window.WailsInvoke=t=>{if(!nt){console.log("Queueing: "+t),j.push(t);return}nt(t)};window.addEventListener("DOMContentLoaded",()=>{ne.overlay=new Ct({target:document.body,anchor:document.querySelector("#wails-spinner")})});var d=null,kt;window.onbeforeunload=function(){d&&(d.onclose=function(){},d.close(),d=null)};It();function ie(){nt=t=>{d.send(t)};for(let t=0;t CheckNotificationAuthorization, + CleanupNotifications: () => CleanupNotifications, + InitializeNotifications: () => InitializeNotifications, + IsNotificationAvailable: () => IsNotificationAvailable, + RegisterNotificationCategory: () => RegisterNotificationCategory, + RemoveAllDeliveredNotifications: () => RemoveAllDeliveredNotifications, + RemoveAllPendingNotifications: () => RemoveAllPendingNotifications, + RemoveDeliveredNotification: () => RemoveDeliveredNotification, + RemoveNotification: () => RemoveNotification, + RemoveNotificationCategory: () => RemoveNotificationCategory, + RemovePendingNotification: () => RemovePendingNotification, + RequestNotificationAuthorization: () => RequestNotificationAuthorization, + SendNotification: () => SendNotification, + SendNotificationWithActions: () => SendNotificationWithActions + }); + function InitializeNotifications() { + return Call(":wails:InitializeNotifications"); + } + function CleanupNotifications() { + return Call(":wails:CleanupNotifications"); + } + function IsNotificationAvailable() { + return Call(":wails:IsNotificationAvailable"); + } + function RequestNotificationAuthorization() { + return Call(":wails:RequestNotificationAuthorization"); + } + function CheckNotificationAuthorization() { + return Call(":wails:CheckNotificationAuthorization"); + } + function SendNotification(options) { + return Call(":wails:SendNotification", [options]); + } + function SendNotificationWithActions(options) { + return Call(":wails:SendNotificationWithActions", [options]); + } + function RegisterNotificationCategory(category) { + return Call(":wails:RegisterNotificationCategory", [category]); + } + function RemoveNotificationCategory(categoryId) { + return Call(":wails:RemoveNotificationCategory", [categoryId]); + } + function RemoveAllPendingNotifications() { + return Call(":wails:RemoveAllPendingNotifications"); + } + function RemovePendingNotification(identifier) { + return Call(":wails:RemovePendingNotification", [identifier]); + } + function RemoveAllDeliveredNotifications() { + return Call(":wails:RemoveAllDeliveredNotifications"); + } + function RemoveDeliveredNotification(identifier) { + return Call(":wails:RemoveDeliveredNotification", [identifier]); + } + function RemoveNotification(identifier) { + return Call(":wails:RemoveNotification", [identifier]); + } + // desktop/main.js function Quit() { window.WailsInvoke("Q"); @@ -632,6 +705,7 @@ ...screen_exports, ...clipboard_exports, ...draganddrop_exports, + ...notifications_exports, EventsOn, EventsOnce, EventsOnMultiple, @@ -777,4 +851,4 @@ }); window.WailsInvoke("runtime:ready"); })(); -//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiZGVza3RvcC9sb2cuanMiLCAiZGVza3RvcC9ldmVudHMuanMiLCAiZGVza3RvcC9jYWxscy5qcyIsICJkZXNrdG9wL2JpbmRpbmdzLmpzIiwgImRlc2t0b3Avd2luZG93LmpzIiwgImRlc2t0b3Avc2NyZWVuLmpzIiwgImRlc2t0b3AvYnJvd3Nlci5qcyIsICJkZXNrdG9wL2NsaXBib2FyZC5qcyIsICJkZXNrdG9wL2RyYWdhbmRkcm9wLmpzIiwgImRlc2t0b3AvY29udGV4dG1lbnUuanMiLCAiZGVza3RvcC9tYWluLmpzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyIvKlxyXG4gXyAgICAgICBfXyAgICAgIF8gX19cclxufCB8ICAgICAvIC9fX18gXyhfKSAvX19fX1xyXG58IHwgL3wgLyAvIF9fIGAvIC8gLyBfX18vXHJcbnwgfC8gfC8gLyAvXy8gLyAvICh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XHJcbiAgICAgICAgdGltZW91dCA9IDA7XHJcbiAgICB9XHJcblxyXG4gICAgLy8gQ3JlYXRlIGEgcHJvbWlzZVxyXG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcclxuXHJcbiAgICAgICAgLy8gQ3JlYXRlIGEgdW5pcXVlIGNhbGxiYWNrSURcclxuICAgICAgICB2YXIgY2FsbGJhY2tJRDtcclxuICAgICAgICBkbyB7XHJcbiAgICAgICAgICAgIGNhbGxiYWNrSUQgPSBpZCArICctJyArIHJhbmRvbUZ1bmMoKTtcclxuICAgICAgICB9IHdoaWxlIChjYWxsYmFja3NbY2FsbGJhY2tJRF0pO1xyXG5cclxuICAgICAgICB2YXIgdGltZW91dEhhbmRsZTtcclxuICAgICAgICAvLyBTZXQgdGltZW91dFxyXG4gICAgICAgIGlmICh0aW1lb3V0ID4gMCkge1xyXG4gICAgICAgICAgICB0aW1lb3V0SGFuZGxlID0gc2V0VGltZW91dChmdW5jdGlvbiAoKSB7XHJcbiAgICAgICAgICAgICAgICByZWplY3QoRXJyb3IoJ0NhbGwgdG8gbWV0aG9kICcgKyBpZCArICcgdGltZWQgb3V0LiBSZXF1ZXN0IElEOiAnICsgY2FsbGJhY2tJRCkpO1xyXG4gICAgICAgICAgICB9LCB0aW1lb3V0KTtcclxuICAgICAgICB9XHJcblxyXG4gICAgICAgIC8vIFN0b3JlIGNhbGxiYWNrXHJcbiAgICAgICAgY2FsbGJhY2tzW2NhbGxiYWNrSURdID0ge1xyXG4gICAgICAgICAgICB0aW1lb3V0SGFuZGxlOiB0aW1lb3V0SGFuZGxlLFxyXG4gICAgICAgICAgICByZWplY3Q6IHJlamVjdCxcclxuICAgICAgICAgICAgcmVzb2x2ZTogcmVzb2x2ZVxyXG4gICAgICAgIH07XHJcblxyXG4gICAgICAgIHRyeSB7XHJcbiAgICAgICAgICAgIGNvbnN0IHBheWxvYWQgPSB7XHJcblx0XHRcdFx0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AgLy8gQ2hlY2sgaWYgdGV4dCBoYXMgYmVlbiBzZWxlY3RlZCBhbmQgYWN0aW9uIGlzIG9uIHRoZSBzZWxlY3RlZCBlbGVtZW50c1xyXG4gICAgICAgICAgICBjb25zdCBzZWxlY3Rpb24gPSB3aW5kb3cuZ2V0U2VsZWN0aW9uKCk7XHJcbiAgICAgICAgICAgIGNvbnN0IGhhc1NlbGVjdGlvbiA9IChzZWxlY3Rpb24udG9TdHJpbmcoKS5sZW5ndGggPiAwKVxyXG4gICAgICAgICAgICBpZiAoaGFzU2VsZWN0aW9uKSB7XHJcbiAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNlbGVjdGlvbi5yYW5nZUNvdW50OyBpKyspIHtcclxuICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZSA9IHNlbGVjdGlvbi5nZXRSYW5nZUF0KGkpO1xyXG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3RzID0gcmFuZ2UuZ2V0Q2xpZW50UmVjdHMoKTtcclxuICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHJlY3RzLmxlbmd0aDsgaisrKSB7XHJcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSByZWN0c1tqXTtcclxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvY3VtZW50LmVsZW1lbnRGcm9tUG9pbnQocmVjdC5sZWZ0LCByZWN0LnRvcCkgPT09IGVsZW1lbnQpIHtcclxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcclxuICAgICAgICAgICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAvLyBDaGVjayBpZiB0YWduYW1lIGlzIGlucHV0IG9yIHRleHRhcmVhXHJcbiAgICAgICAgICAgIGlmIChlbGVtZW50LnRhZ05hbWUgPT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ICAgICAgIHdpbmRvdy53YWlscy5mbGFncy5zaG91bGREcmFnID0gZmFsc2U7XHJcbiAgICAgICAgbGV0IG1vdXNlUHJlc3NlZCA9IGUuYnV0dG9ucyAhPT0gdW5kZWZpbmVkID8gZS5idXR0b25zIDogZS53aGljaDtcclxuICAgICAgICBpZiAobW91c2VQcmVzc2VkID4gMCkge1xyXG4gICAgICAgICAgICB3aW5kb3cuV2FpbHNJbnZva2UoXCJkcmFnXCIpO1xyXG4gICAgICAgICAgICByZXR1cm47XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgaWYgKCF3aW5kb3cud2FpbHMuZmxhZ3MuZW5hYmxlUmVzaXplKSB7XHJcbiAgICAgICAgcmV0dXJuO1xyXG4gICAgfVxyXG4gICAgaWYgKHdpbmRvdy53YWlscy5mbGFncy5kZWZhdWx0Q3Vyc29yID09IG51bGwpIHtcclxuICAgICAgICB3aW5kb3cud2FpbHMuZmxhZ3MuZGVmYXVsdEN1cnNvciA9IGRvY3VtZW50LmRvY3VtZW50RWxlbWVudC5zdHlsZS5jdXJzb3I7XHJcbiAgICB9XHJcbiAgICBpZiAod2luZG93Lm91dGVyV2lkdGggLSBlLmNsaWVudFggPCB3aW5kb3cud2FpbHMuZmxhZ3MuYm9yZGVyVGhpY2tuZXNzICYmIHdpbmRvdy5vdXRlckhlaWdodCAtIGUuY2xpZW50WSA8IHdpbmRvdy53YWlscy5mbGFncy5ib3JkZXJUaGlja25lc3MpIHtcclxuICAgICAgICBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQuc3R5bGUuY3Vyc29yID0gXCJzZS1yZXNpemVcIjtcclxuICAgIH1cclxuICAgIGxldCByaWdodEJvcmRlciA9IHdpbmRvdy5vdXRlcldpZHRoIC0gZS5jbGllbnRYIDwgd2luZG93LndhaWxzLmZsYWdzLmJvcmRlclRoaWNrbmVzcztcclxuICAgIGxldCBsZWZ0Qm9yZGVyID0gZS5jbGllbnRYIDwgd2luZG93LndhaWxzLmZsYWd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gICAgICAgY29uc3Qgc2VsZWN0aW9uID0gd2luZG93LmdldFNlbGVjdGlvbigpO1xuICAgICAgICAgICAgY29uc3QgaGFzU2VsZWN0aW9uID0gKHNlbGVjdGlvbi50b1N0cmluZygpLmxlbmd0aCA+IDApXG4gICAgICAgICAgICBpZiAoaGFzU2VsZWN0aW9uKSB7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzZWxlY3Rpb24ucmFuZ2VDb3VudDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhbmdlID0gc2VsZWN0aW9uLmdldFJhbmdlQXQoaSk7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3RzID0gcmFuZ2UuZ2V0Q2xpZW50UmVjdHMoKTtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCByZWN0cy5sZW5ndGg7IGorKykge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHJlY3RzW2pdO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvY3VtZW50LmVsZW1lbnRGcm9tUG9pbnQocmVjdC5sZWZ0LCByZWN0LnRvcCkgPT09IGVsZW1lbnQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBDaGVjayBpZiB0YWduYW1lIGlzIGlucHV0IG9yIHRleHRhcmVhXG4gICAgICAgICAgICBpZiAoZWxlbWVudC50YWdOYW1lID09PSBcIklOUFVUXCIgfHwgZWxlbWVudC50YWdOYW1lID09PSBcIlRFWFRBUkVBXCIpIHtcbiAgICAgICAgICAgICAgICBpZiAoaGFzU2VsZWN0aW9uIHx8ICghZWxlbWVudC5yZWFkT25seSAmJiAhZWxlbWVudC5kaXNhYmxl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BQU8sY0FBYyxFQUFFLFVBQVUsT0FBTyxNQUFNLE1BQU07QUFHdkUsUUFBSSxDQUFDLGNBQWMsQ0FBQyxlQUFlLENBQUMsYUFBYSxDQUFDLGdCQUFnQixPQUFPLE1BQU0sTUFBTSxlQUFlLFFBQVc7QUFDM0csZ0JBQVU7QUFBQSxJQUNkLFdBQVcsZUFBZTtBQUFjLGdCQUFVLFdBQVc7QUFBQSxhQUNwRCxjQUFjO0FBQWMsZ0JBQVUsV0FBVztBQUFBLGFBQ2pELGNBQWM7QUFBVyxnQkFBVSxXQUFXO0FBQUEsYUFDOUMsYUFBYTtBQUFhLGdCQUFVLFdBQVc7QUFBQSxhQUMvQztBQUFZLGdCQUFVLFVBQVU7QUFBQSxhQUNoQztBQUFXLGdCQUFVLFVBQVU7QUFBQSxhQUMvQjtBQUFjLGdCQUFVLFVBQVU7QUFBQSxhQUNsQztBQUFhLGdCQUFVLFVBQVU7QUFBQSxFQUU5QyxDQUFDO0FBR0QsU0FBTyxpQkFBaUIsZUFBZSxTQUFTLEdBQUc7QUFFL0MsUUFBSTtBQUFPO0FBRVgsUUFBSSxPQUFPLE1BQU0sTUFBTSwyQkFBMkI7QUFDOUMsUUFBRSxlQUFlO0FBQUEsSUFDckIsT0FBTztBQUNILE1BQVksMEJBQTBCLENBQUM7QUFBQSxJQUMzQztBQUFBLEVBQ0osQ0FBQztBQUVELFNBQU8sWUFBWSxlQUFlOyIsCiAgIm5hbWVzIjogWyJldmVudE5hbWUiXQp9Cg== diff --git a/v2/internal/frontend/runtime/runtime_prod_desktop.js b/v2/internal/frontend/runtime/runtime_prod_desktop.js index 4bf7d147c..c285fa642 100644 --- a/v2/internal/frontend/runtime/runtime_prod_desktop.js +++ b/v2/internal/frontend/runtime/runtime_prod_desktop.js @@ -1 +1 @@ -(()=>{var j=Object.defineProperty;var p=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})};var b={};p(b,{LogDebug:()=>$,LogError:()=>Q,LogFatal:()=>_,LogInfo:()=>Y,LogLevel:()=>K,LogPrint:()=>X,LogTrace:()=>J,LogWarning:()=>q,SetLogLevel:()=>Z});function u(e,t){window.WailsInvoke("L"+e+t)}function J(e){u("T",e)}function X(e){u("P",e)}function $(e){u("D",e)}function Y(e){u("I",e)}function q(e){u("W",e)}function Q(e){u("E",e)}function _(e){u("F",e)}function Z(e){u("S",e)}var K={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5};var y=class{constructor(t,n,o){this.eventName=t,this.maxCallbacks=o||-1,this.Callback=i=>(n.apply(null,i),this.maxCallbacks===-1?!1:(this.maxCallbacks-=1,this.maxCallbacks===0))}},w={};function v(e,t,n){w[e]=w[e]||[];let o=new y(e,t,n);return w[e].push(o),()=>ee(o)}function W(e,t){return v(e,t,-1)}function A(e,t){return v(e,t,1)}function P(e){let t=e.name,n=w[t]?.slice()||[];if(n.length){for(let o=n.length-1;o>=0;o-=1){let i=n[o],r=e.data;i.Callback(r)&&n.splice(o,1)}n.length===0?g(t):w[t]=n}}function R(e){let t;try{t=JSON.parse(e)}catch{let o="Invalid JSON passed to Notify: "+e;throw new Error(o)}P(t)}function M(e){let t={name:e,data:[].slice.apply(arguments).slice(1)};P(t),window.WailsInvoke("EE"+JSON.stringify(t))}function g(e){delete w[e],window.WailsInvoke("EX"+e)}function x(e,...t){g(e),t.length>0&&t.forEach(n=>{g(n)})}function z(){Object.keys(w).forEach(t=>{g(t)})}function ee(e){let t=e.eventName;w[t]!==void 0&&(w[t]=w[t].filter(n=>n!==e),w[t].length===0&&g(t))}var c={};function te(){var e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0]}function ne(){return Math.random()*9007199254740991}var D;window.crypto?D=te:D=ne;function a(e,t,n){return n==null&&(n=0),new Promise(function(o,i){var r;do r=e+"-"+D();while(c[r]);var l;n>0&&(l=setTimeout(function(){i(Error("Call to "+e+" timed out. Request ID: "+r))},n)),c[r]={timeoutHandle:l,reject:i,resolve:o};try{let d={name:e,args:t,callbackID:r};window.WailsInvoke("C"+JSON.stringify(d))}catch(d){console.error(d)}})}window.ObfuscatedCall=(e,t,n)=>(n==null&&(n=0),new Promise(function(o,i){var r;do r=e+"-"+D();while(c[r]);var l;n>0&&(l=setTimeout(function(){i(Error("Call to method "+e+" timed out. Request ID: "+r))},n)),c[r]={timeoutHandle:l,reject:i,resolve:o};try{let d={id:e,args:t,callbackID:r};window.WailsInvoke("c"+JSON.stringify(d))}catch(d){console.error(d)}}));function B(e){let t;try{t=JSON.parse(e)}catch(i){let r=`Invalid JSON passed to callback: ${i.message}. Message: ${e}`;throw runtime.LogDebug(r),new Error(r)}let n=t.callbackid,o=c[n];if(!o){let i=`Callback '${n}' not registered!!!`;throw console.error(i),new Error(i)}clearTimeout(o.timeoutHandle),delete c[n],t.error?o.reject(t.error):o.resolve(t.result)}window.go={};function F(e){try{e=JSON.parse(e)}catch(t){console.error(t)}window.go=window.go||{},Object.keys(e).forEach(t=>{window.go[t]=window.go[t]||{},Object.keys(e[t]).forEach(n=>{window.go[t][n]=window.go[t][n]||{},Object.keys(e[t][n]).forEach(o=>{window.go[t][n][o]=function(){let i=0;function r(){let l=[].slice.call(arguments);return a([t,n,o].join("."),l,i)}return r.setTimeout=function(l){i=l},r.getTimeout=function(){return i},r}()})})})}var T={};p(T,{WindowCenter:()=>ae,WindowFullscreen:()=>de,WindowGetPosition:()=>xe,WindowGetSize:()=>pe,WindowHide:()=>De,WindowIsFullscreen:()=>ue,WindowIsMaximised:()=>Te,WindowIsMinimised:()=>Ce,WindowIsNormal:()=>Ie,WindowMaximise:()=>Ee,WindowMinimise:()=>Se,WindowReload:()=>oe,WindowReloadApp:()=>ie,WindowSetAlwaysOnTop:()=>ve,WindowSetBackgroundColour:()=>Oe,WindowSetDarkTheme:()=>le,WindowSetLightTheme:()=>se,WindowSetMaxSize:()=>ge,WindowSetMinSize:()=>me,WindowSetPosition:()=>We,WindowSetSize:()=>ce,WindowSetSystemDefaultTheme:()=>re,WindowSetTitle:()=>we,WindowShow:()=>he,WindowToggleMaximise:()=>be,WindowUnfullscreen:()=>fe,WindowUnmaximise:()=>ye,WindowUnminimise:()=>ke});function oe(){window.location.reload()}function ie(){window.WailsInvoke("WR")}function re(){window.WailsInvoke("WASDT")}function se(){window.WailsInvoke("WALT")}function le(){window.WailsInvoke("WADT")}function ae(){window.WailsInvoke("Wc")}function we(e){window.WailsInvoke("WT"+e)}function de(){window.WailsInvoke("WF")}function fe(){window.WailsInvoke("Wf")}function ue(){return a(":wails:WindowIsFullscreen")}function ce(e,t){window.WailsInvoke("Ws:"+e+":"+t)}function pe(){return a(":wails:WindowGetSize")}function ge(e,t){window.WailsInvoke("WZ:"+e+":"+t)}function me(e,t){window.WailsInvoke("Wz:"+e+":"+t)}function ve(e){window.WailsInvoke("WATP:"+(e?"1":"0"))}function We(e,t){window.WailsInvoke("Wp:"+e+":"+t)}function xe(){return a(":wails:WindowGetPos")}function De(){window.WailsInvoke("WH")}function he(){window.WailsInvoke("WS")}function Ee(){window.WailsInvoke("WM")}function be(){window.WailsInvoke("Wt")}function ye(){window.WailsInvoke("WU")}function Te(){return a(":wails:WindowIsMaximised")}function Se(){window.WailsInvoke("Wm")}function ke(){window.WailsInvoke("Wu")}function Ce(){return a(":wails:WindowIsMinimised")}function Ie(){return a(":wails:WindowIsNormal")}function Oe(e,t,n,o){let i=JSON.stringify({r:e||0,g:t||0,b:n||0,a:o||255});window.WailsInvoke("Wr:"+i)}var S={};p(S,{ScreenGetAll:()=>Le});function Le(){return a(":wails:ScreenGetAll")}var k={};p(k,{BrowserOpenURL:()=>Ae});function Ae(e){window.WailsInvoke("BO:"+e)}var C={};p(C,{ClipboardGetText:()=>Re,ClipboardSetText:()=>Pe});function Pe(e){return a(":wails:ClipboardSetText",[e])}function Re(){return a(":wails:ClipboardGetText")}var I={};p(I,{CanResolveFilePaths:()=>V,OnFileDrop:()=>ze,OnFileDropOff:()=>Be,ResolveFilePaths:()=>Me});var s={registered:!1,defaultUseDropTarget:!0,useDropTarget:!0,nextDeactivate:null,nextDeactivateTimeout:null},m="wails-drop-target-active";function h(e){let t=e.getPropertyValue(window.wails.flags.cssDropProperty).trim();return t?t===window.wails.flags.cssDropValue:!1}function G(e){if(!window.wails.flags.enableWailsDragAndDrop||(e.dataTransfer.dropEffect="copy",e.preventDefault(),!s.useDropTarget))return;let t=e.target;if(s.nextDeactivate&&s.nextDeactivate(),!t||!h(getComputedStyle(t)))return;let n=t;for(;n;)h(getComputedStyle(n))&&n.classList.add(m),n=n.parentElement}function H(e){if(!!window.wails.flags.enableWailsDragAndDrop&&(e.preventDefault(),!!s.useDropTarget)){if(!e.target||!h(getComputedStyle(e.target)))return null;s.nextDeactivate&&s.nextDeactivate(),s.nextDeactivate=()=>{Array.from(document.getElementsByClassName(m)).forEach(t=>t.classList.remove(m)),s.nextDeactivate=null,s.nextDeactivateTimeout&&(clearTimeout(s.nextDeactivateTimeout),s.nextDeactivateTimeout=null)},s.nextDeactivateTimeout=setTimeout(()=>{s.nextDeactivate&&s.nextDeactivate()},50)}}function U(e){if(!!window.wails.flags.enableWailsDragAndDrop){if(e.preventDefault(),V()){let t=[];e.dataTransfer.items?t=[...e.dataTransfer.items].map((n,o)=>{if(n.kind==="file")return n.getAsFile()}):t=[...e.dataTransfer.files],window.runtime.ResolveFilePaths(e.x,e.y,t)}!s.useDropTarget||(s.nextDeactivate&&s.nextDeactivate(),Array.from(document.getElementsByClassName(m)).forEach(t=>t.classList.remove(m)))}}function V(){return window.chrome?.webview?.postMessageWithAdditionalObjects!=null}function Me(e,t,n){window.chrome?.webview?.postMessageWithAdditionalObjects&&chrome.webview.postMessageWithAdditionalObjects(`file:drop:${e}:${t}`,n)}function ze(e,t){if(typeof e!="function"){console.error("DragAndDropCallback is not a function");return}if(s.registered)return;s.registered=!0;let n=typeof t;s.useDropTarget=n==="undefined"||n!=="boolean"?s.defaultUseDropTarget:t,window.addEventListener("dragover",G),window.addEventListener("dragleave",H),window.addEventListener("drop",U);let o=e;s.useDropTarget&&(o=function(i,r,l){let d=document.elementFromPoint(i,r);if(!d||!h(getComputedStyle(d)))return null;e(i,r,l)}),W("wails:file-drop",o)}function Be(){window.removeEventListener("dragover",G),window.removeEventListener("dragleave",H),window.removeEventListener("drop",U),x("wails:file-drop"),s.registered=!1}function N(e){let t=e.target;switch(window.getComputedStyle(t).getPropertyValue("--default-contextmenu").trim()){case"show":return;case"hide":e.preventDefault();return;default:if(t.isContentEditable)return;let i=window.getSelection(),r=i.toString().length>0;if(r)for(let l=0;l{if(window.wails.flags.resizeEdge){window.WailsInvoke("resize:"+window.wails.flags.resizeEdge),e.preventDefault();return}if(Ne(e)){if(window.wails.flags.disableScrollbarDrag&&(e.offsetX>e.target.clientWidth||e.offsetY>e.target.clientHeight))return;window.wails.flags.deferDragToMouseMove?window.wails.flags.shouldDrag=!0:(e.preventDefault(),window.WailsInvoke("drag"));return}else window.wails.flags.shouldDrag=!1});window.addEventListener("mouseup",()=>{window.wails.flags.shouldDrag=!1});function f(e){document.documentElement.style.cursor=e||window.wails.flags.defaultCursor,window.wails.flags.resizeEdge=e}window.addEventListener("mousemove",function(e){if(window.wails.flags.shouldDrag&&(window.wails.flags.shouldDrag=!1,(e.buttons!==void 0?e.buttons:e.which)>0)){window.WailsInvoke("drag");return}if(!window.wails.flags.enableResize)return;window.wails.flags.defaultCursor==null&&(window.wails.flags.defaultCursor=document.documentElement.style.cursor),window.outerWidth-e.clientX{var J=Object.defineProperty;var p=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})};var y={};p(y,{LogDebug:()=>q,LogError:()=>_,LogFatal:()=>Z,LogInfo:()=>Y,LogLevel:()=>ee,LogPrint:()=>$,LogTrace:()=>X,LogWarning:()=>Q,SetLogLevel:()=>K});function u(e,t){window.WailsInvoke("L"+e+t)}function X(e){u("T",e)}function $(e){u("P",e)}function q(e){u("D",e)}function Y(e){u("I",e)}function Q(e){u("W",e)}function _(e){u("E",e)}function Z(e){u("F",e)}function K(e){u("S",e)}var ee={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5};var b=class{constructor(t,n,i){this.eventName=t,this.maxCallbacks=i||-1,this.Callback=o=>(n.apply(null,o),this.maxCallbacks===-1?!1:(this.maxCallbacks-=1,this.maxCallbacks===0))}},f={};function v(e,t,n){f[e]=f[e]||[];let i=new b(e,t,n);return f[e].push(i),()=>te(i)}function x(e,t){return v(e,t,-1)}function N(e,t){return v(e,t,1)}function L(e){let t=e.name,n=f[t]?.slice()||[];if(n.length){for(let i=n.length-1;i>=0;i-=1){let o=n[i],s=e.data;o.Callback(s)&&n.splice(i,1)}n.length===0?g(t):f[t]=n}}function P(e){let t;try{t=JSON.parse(e)}catch{let i="Invalid JSON passed to Notify: "+e;throw new Error(i)}L(t)}function z(e){let t={name:e,data:[].slice.apply(arguments).slice(1)};L(t),window.WailsInvoke("EE"+JSON.stringify(t))}function g(e){delete f[e],window.WailsInvoke("EX"+e)}function D(e,...t){g(e),t.length>0&&t.forEach(n=>{g(n)})}function F(){Object.keys(f).forEach(t=>{g(t)})}function te(e){let t=e.eventName;f[t]!==void 0&&(f[t]=f[t].filter(n=>n!==e),f[t].length===0&&g(t))}var c={};function ne(){var e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0]}function ie(){return Math.random()*9007199254740991}var W;window.crypto?W=ne:W=ie;function r(e,t,n){return n==null&&(n=0),new Promise(function(i,o){var s;do s=e+"-"+W();while(c[s]);var l;n>0&&(l=setTimeout(function(){o(Error("Call to "+e+" timed out. Request ID: "+s))},n)),c[s]={timeoutHandle:l,reject:o,resolve:i};try{let w={name:e,args:t,callbackID:s};window.WailsInvoke("C"+JSON.stringify(w))}catch(w){console.error(w)}})}window.ObfuscatedCall=(e,t,n)=>(n==null&&(n=0),new Promise(function(i,o){var s;do s=e+"-"+W();while(c[s]);var l;n>0&&(l=setTimeout(function(){o(Error("Call to method "+e+" timed out. Request ID: "+s))},n)),c[s]={timeoutHandle:l,reject:o,resolve:i};try{let w={id:e,args:t,callbackID:s};window.WailsInvoke("c"+JSON.stringify(w))}catch(w){console.error(w)}}));function M(e){let t;try{t=JSON.parse(e)}catch(o){let s=`Invalid JSON passed to callback: ${o.message}. Message: ${e}`;throw runtime.LogDebug(s),new Error(s)}let n=t.callbackid,i=c[n];if(!i){let o=`Callback '${n}' not registered!!!`;throw console.error(o),new Error(o)}clearTimeout(i.timeoutHandle),delete c[n],t.error?i.reject(t.error):i.resolve(t.result)}window.go={};function B(e){try{e=JSON.parse(e)}catch(t){console.error(t)}window.go=window.go||{},Object.keys(e).forEach(t=>{window.go[t]=window.go[t]||{},Object.keys(e[t]).forEach(n=>{window.go[t][n]=window.go[t][n]||{},Object.keys(e[t][n]).forEach(i=>{window.go[t][n][i]=function(){let o=0;function s(){let l=[].slice.call(arguments);return r([t,n,i].join("."),l,o)}return s.setTimeout=function(l){o=l},s.getTimeout=function(){return o},s}()})})})}var C={};p(C,{WindowCenter:()=>fe,WindowFullscreen:()=>de,WindowGetPosition:()=>We,WindowGetSize:()=>ge,WindowHide:()=>he,WindowIsFullscreen:()=>ce,WindowIsMaximised:()=>Se,WindowIsMinimised:()=>Ie,WindowIsNormal:()=>Ae,WindowMaximise:()=>ye,WindowMinimise:()=>Te,WindowReload:()=>oe,WindowReloadApp:()=>re,WindowSetAlwaysOnTop:()=>xe,WindowSetBackgroundColour:()=>Oe,WindowSetDarkTheme:()=>le,WindowSetLightTheme:()=>ae,WindowSetMaxSize:()=>me,WindowSetMinSize:()=>ve,WindowSetPosition:()=>De,WindowSetSize:()=>pe,WindowSetSystemDefaultTheme:()=>se,WindowSetTitle:()=>we,WindowShow:()=>Ee,WindowToggleMaximise:()=>be,WindowUnfullscreen:()=>ue,WindowUnmaximise:()=>Ce,WindowUnminimise:()=>ke});function oe(){window.location.reload()}function re(){window.WailsInvoke("WR")}function se(){window.WailsInvoke("WASDT")}function ae(){window.WailsInvoke("WALT")}function le(){window.WailsInvoke("WADT")}function fe(){window.WailsInvoke("Wc")}function we(e){window.WailsInvoke("WT"+e)}function de(){window.WailsInvoke("WF")}function ue(){window.WailsInvoke("Wf")}function ce(){return r(":wails:WindowIsFullscreen")}function pe(e,t){window.WailsInvoke("Ws:"+e+":"+t)}function ge(){return r(":wails:WindowGetSize")}function me(e,t){window.WailsInvoke("WZ:"+e+":"+t)}function ve(e,t){window.WailsInvoke("Wz:"+e+":"+t)}function xe(e){window.WailsInvoke("WATP:"+(e?"1":"0"))}function De(e,t){window.WailsInvoke("Wp:"+e+":"+t)}function We(){return r(":wails:WindowGetPos")}function he(){window.WailsInvoke("WH")}function Ee(){window.WailsInvoke("WS")}function ye(){window.WailsInvoke("WM")}function be(){window.WailsInvoke("Wt")}function Ce(){window.WailsInvoke("WU")}function Se(){return r(":wails:WindowIsMaximised")}function Te(){window.WailsInvoke("Wm")}function ke(){window.WailsInvoke("Wu")}function Ie(){return r(":wails:WindowIsMinimised")}function Ae(){return r(":wails:WindowIsNormal")}function Oe(e,t,n,i){let o=JSON.stringify({r:e||0,g:t||0,b:n||0,a:i||255});window.WailsInvoke("Wr:"+o)}var S={};p(S,{ScreenGetAll:()=>Re});function Re(){return r(":wails:ScreenGetAll")}var T={};p(T,{BrowserOpenURL:()=>Ne});function Ne(e){window.WailsInvoke("BO:"+e)}var k={};p(k,{ClipboardGetText:()=>Pe,ClipboardSetText:()=>Le});function Le(e){return r(":wails:ClipboardSetText",[e])}function Pe(){return r(":wails:ClipboardGetText")}var I={};p(I,{CanResolveFilePaths:()=>V,OnFileDrop:()=>Fe,OnFileDropOff:()=>Me,ResolveFilePaths:()=>ze});var a={registered:!1,defaultUseDropTarget:!0,useDropTarget:!0,nextDeactivate:null,nextDeactivateTimeout:null},m="wails-drop-target-active";function h(e){let t=e.getPropertyValue(window.wails.flags.cssDropProperty).trim();return t?t===window.wails.flags.cssDropValue:!1}function G(e){if(!e.dataTransfer.types.includes("Files")||(e.preventDefault(),e.dataTransfer.dropEffect="copy",!window.wails.flags.enableWailsDragAndDrop)||!a.useDropTarget)return;let n=e.target;if(a.nextDeactivate&&a.nextDeactivate(),!n||!h(getComputedStyle(n)))return;let i=n;for(;i;)h(getComputedStyle(i))&&i.classList.add(m),i=i.parentElement}function H(e){if(!!e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!!window.wails.flags.enableWailsDragAndDrop&&!!a.useDropTarget)){if(!e.target||!h(getComputedStyle(e.target)))return null;a.nextDeactivate&&a.nextDeactivate(),a.nextDeactivate=()=>{Array.from(document.getElementsByClassName(m)).forEach(n=>n.classList.remove(m)),a.nextDeactivate=null,a.nextDeactivateTimeout&&(clearTimeout(a.nextDeactivateTimeout),a.nextDeactivateTimeout=null)},a.nextDeactivateTimeout=setTimeout(()=>{a.nextDeactivate&&a.nextDeactivate()},50)}}function U(e){if(!!e.dataTransfer.types.includes("Files")&&(e.preventDefault(),!!window.wails.flags.enableWailsDragAndDrop)){if(V()){let n=[];e.dataTransfer.items?n=[...e.dataTransfer.items].map((i,o)=>{if(i.kind==="file")return i.getAsFile()}):n=[...e.dataTransfer.files],window.runtime.ResolveFilePaths(e.x,e.y,n)}!a.useDropTarget||(a.nextDeactivate&&a.nextDeactivate(),Array.from(document.getElementsByClassName(m)).forEach(n=>n.classList.remove(m)))}}function V(){return window.chrome?.webview?.postMessageWithAdditionalObjects!=null}function ze(e,t,n){window.chrome?.webview?.postMessageWithAdditionalObjects&&chrome.webview.postMessageWithAdditionalObjects(`file:drop:${e}:${t}`,n)}function Fe(e,t){if(typeof e!="function"){console.error("DragAndDropCallback is not a function");return}if(a.registered)return;a.registered=!0;let n=typeof t;a.useDropTarget=n==="undefined"||n!=="boolean"?a.defaultUseDropTarget:t,window.addEventListener("dragover",G),window.addEventListener("dragleave",H),window.addEventListener("drop",U);let i=e;a.useDropTarget&&(i=function(o,s,l){let w=document.elementFromPoint(o,s);if(!w||!h(getComputedStyle(w)))return null;e(o,s,l)}),x("wails:file-drop",i)}function Me(){window.removeEventListener("dragover",G),window.removeEventListener("dragleave",H),window.removeEventListener("drop",U),D("wails:file-drop"),a.registered=!1}function j(e){let t=e.target;switch(window.getComputedStyle(t).getPropertyValue("--default-contextmenu").trim()){case"show":return;case"hide":e.preventDefault();return;default:if(t.isContentEditable)return;let o=window.getSelection(),s=o.toString().length>0;if(s)for(let l=0;lje,CleanupNotifications:()=>He,InitializeNotifications:()=>Ge,IsNotificationAvailable:()=>Ue,RegisterNotificationCategory:()=>$e,RemoveAllDeliveredNotifications:()=>_e,RemoveAllPendingNotifications:()=>Ye,RemoveDeliveredNotification:()=>Ze,RemoveNotification:()=>Ke,RemoveNotificationCategory:()=>qe,RemovePendingNotification:()=>Qe,RequestNotificationAuthorization:()=>Ve,SendNotification:()=>Je,SendNotificationWithActions:()=>Xe});function Ge(){return r(":wails:InitializeNotifications")}function He(){return r(":wails:CleanupNotifications")}function Ue(){return r(":wails:IsNotificationAvailable")}function Ve(){return r(":wails:RequestNotificationAuthorization")}function je(){return r(":wails:CheckNotificationAuthorization")}function Je(e){return r(":wails:SendNotification",[e])}function Xe(e){return r(":wails:SendNotificationWithActions",[e])}function $e(e){return r(":wails:RegisterNotificationCategory",[e])}function qe(e){return r(":wails:RemoveNotificationCategory",[e])}function Ye(){return r(":wails:RemoveAllPendingNotifications")}function Qe(e){return r(":wails:RemovePendingNotification",[e])}function _e(){return r(":wails:RemoveAllDeliveredNotifications")}function Ze(e){return r(":wails:RemoveDeliveredNotification",[e])}function Ke(e){return r(":wails:RemoveNotification",[e])}function et(){window.WailsInvoke("Q")}function tt(){window.WailsInvoke("S")}function nt(){window.WailsInvoke("H")}function it(){return r(":wails:Environment")}window.runtime={...y,...C,...T,...S,...k,...I,...A,EventsOn:x,EventsOnce:N,EventsOnMultiple:v,EventsEmit:z,EventsOff:D,EventsOffAll:F,Environment:it,Show:tt,Hide:nt,Quit:et};window.wails={Callback:M,EventsNotify:P,SetBindings:B,eventListeners:f,callbacks:c,flags:{disableScrollbarDrag:!1,disableDefaultContextMenu:!1,enableResize:!1,defaultCursor:null,borderThickness:6,shouldDrag:!1,deferDragToMouseMove:!0,cssDragProperty:"--wails-draggable",cssDragValue:"drag",cssDropProperty:"--wails-drop-target",cssDropValue:"drop",enableWailsDragAndDrop:!1}};window.wailsbindings&&(window.wails.SetBindings(window.wailsbindings),delete window.wails.SetBindings);delete window.wailsbindings;var ot=function(e){var t=window.getComputedStyle(e.target).getPropertyValue(window.wails.flags.cssDragProperty);return t&&(t=t.trim()),!(t!==window.wails.flags.cssDragValue||e.buttons!==1||e.detail!==1)};window.wails.setCSSDragProperties=function(e,t){window.wails.flags.cssDragProperty=e,window.wails.flags.cssDragValue=t};window.wails.setCSSDropProperties=function(e,t){window.wails.flags.cssDropProperty=e,window.wails.flags.cssDropValue=t};window.addEventListener("mousedown",e=>{if(window.wails.flags.resizeEdge){window.WailsInvoke("resize:"+window.wails.flags.resizeEdge),e.preventDefault();return}if(ot(e)){if(window.wails.flags.disableScrollbarDrag&&(e.offsetX>e.target.clientWidth||e.offsetY>e.target.clientHeight))return;window.wails.flags.deferDragToMouseMove?window.wails.flags.shouldDrag=!0:(e.preventDefault(),window.WailsInvoke("drag"));return}else window.wails.flags.shouldDrag=!1});window.addEventListener("mouseup",()=>{window.wails.flags.shouldDrag=!1});function d(e){document.documentElement.style.cursor=e||window.wails.flags.defaultCursor,window.wails.flags.resizeEdge=e}window.addEventListener("mousemove",function(e){if(window.wails.flags.shouldDrag&&(window.wails.flags.shouldDrag=!1,(e.buttons!==void 0?e.buttons:e.which)>0)){window.WailsInvoke("drag");return}if(!window.wails.flags.enableResize)return;window.wails.flags.defaultCursor==null&&(window.wails.flags.defaultCursor=document.documentElement.style.cursor),window.outerWidth-e.clientX; + +// [CleanupNotifications](https://wails.io/docs/reference/runtime/notification#cleanupnotifications) +// Cleans up notification resources and releases any held connections. +export function CleanupNotifications(): Promise; + +// [IsNotificationAvailable](https://wails.io/docs/reference/runtime/notification#isnotificationavailable) +// Checks if notifications are available on the current platform. +export function IsNotificationAvailable(): Promise; + +// [RequestNotificationAuthorization](https://wails.io/docs/reference/runtime/notification#requestnotificationauthorization) +// Requests notification authorization from the user (macOS only). +export function RequestNotificationAuthorization(): Promise; + +// [CheckNotificationAuthorization](https://wails.io/docs/reference/runtime/notification#checknotificationauthorization) +// Checks the current notification authorization status (macOS only). +export function CheckNotificationAuthorization(): Promise; + +// [SendNotification](https://wails.io/docs/reference/runtime/notification#sendnotification) +// Sends a basic notification with the given options. +export function SendNotification(options: NotificationOptions): Promise; + +// [SendNotificationWithActions](https://wails.io/docs/reference/runtime/notification#sendnotificationwithactions) +// Sends a notification with action buttons. Requires a registered category. +export function SendNotificationWithActions(options: NotificationOptions): Promise; + +// [RegisterNotificationCategory](https://wails.io/docs/reference/runtime/notification#registernotificationcategory) +// Registers a notification category that can be used with SendNotificationWithActions. +export function RegisterNotificationCategory(category: NotificationCategory): Promise; + +// [RemoveNotificationCategory](https://wails.io/docs/reference/runtime/notification#removenotificationcategory) +// Removes a previously registered notification category. +export function RemoveNotificationCategory(categoryId: string): Promise; + +// [RemoveAllPendingNotifications](https://wails.io/docs/reference/runtime/notification#removeallpendingnotifications) +// Removes all pending notifications from the notification center. +export function RemoveAllPendingNotifications(): Promise; + +// [RemovePendingNotification](https://wails.io/docs/reference/runtime/notification#removependingnotification) +// Removes a specific pending notification by its identifier. +export function RemovePendingNotification(identifier: string): Promise; + +// [RemoveAllDeliveredNotifications](https://wails.io/docs/reference/runtime/notification#removealldeliverednotifications) +// Removes all delivered notifications from the notification center. +export function RemoveAllDeliveredNotifications(): Promise; + +// [RemoveDeliveredNotification](https://wails.io/docs/reference/runtime/notification#removedeliverednotification) +// Removes a specific delivered notification by its identifier. +export function RemoveDeliveredNotification(identifier: string): Promise; + +// [RemoveNotification](https://wails.io/docs/reference/runtime/notification#removenotification) +// Removes a notification by its identifier (cross-platform convenience function). +export function RemoveNotification(identifier: string): Promise; \ No newline at end of file diff --git a/v2/internal/frontend/runtime/wrapper/runtime.js b/v2/internal/frontend/runtime/wrapper/runtime.js index 7cb89d750..556621eeb 100644 --- a/v2/internal/frontend/runtime/wrapper/runtime.js +++ b/v2/internal/frontend/runtime/wrapper/runtime.js @@ -239,4 +239,60 @@ export function CanResolveFilePaths() { export function ResolveFilePaths(files) { return window.runtime.ResolveFilePaths(files); +} + +export function InitializeNotifications() { + return window.runtime.InitializeNotifications(); +} + +export function CleanupNotifications() { + return window.runtime.CleanupNotifications(); +} + +export function IsNotificationAvailable() { + return window.runtime.IsNotificationAvailable(); +} + +export function RequestNotificationAuthorization() { + return window.runtime.RequestNotificationAuthorization(); +} + +export function CheckNotificationAuthorization() { + return window.runtime.CheckNotificationAuthorization(); +} + +export function SendNotification(options) { + return window.runtime.SendNotification(options); +} + +export function SendNotificationWithActions(options) { + return window.runtime.SendNotificationWithActions(options); +} + +export function RegisterNotificationCategory(category) { + return window.runtime.RegisterNotificationCategory(category); +} + +export function RemoveNotificationCategory(categoryId) { + return window.runtime.RemoveNotificationCategory(categoryId); +} + +export function RemoveAllPendingNotifications() { + return window.runtime.RemoveAllPendingNotifications(); +} + +export function RemovePendingNotification(identifier) { + return window.runtime.RemovePendingNotification(identifier); +} + +export function RemoveAllDeliveredNotifications() { + return window.runtime.RemoveAllDeliveredNotifications(); +} + +export function RemoveDeliveredNotification(identifier) { + return window.runtime.RemoveDeliveredNotification(identifier); +} + +export function RemoveNotification(identifier) { + return window.runtime.RemoveNotification(identifier); } \ No newline at end of file diff --git a/v2/internal/platform/win32/consts.go b/v2/internal/platform/win32/consts.go index 03f42b1a6..43149b036 100644 --- a/v2/internal/platform/win32/consts.go +++ b/v2/internal/platform/win32/consts.go @@ -80,7 +80,7 @@ ShouldSystemUseDarkMode = bool () // ordinal 138 SetPreferredAppMode = PreferredAppMode (PreferredAppMode appMode) // ordinal 135, since 18334 IsDarkModeAllowedForApp = bool () // ordinal 139 */ -func init() { +func Init() { if IsWindowsVersionAtLeast(10, 0, 18334) { // AllowDarkModeForWindow is only available on Windows 10+ diff --git a/v2/internal/s/s.go b/v2/internal/s/s.go index 5ba0d2eaa..adb304178 100644 --- a/v2/internal/s/s.go +++ b/v2/internal/s/s.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "fmt" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -29,7 +28,7 @@ func checkError(err error) { func mute() { originalOutput = Output - Output = ioutil.Discard + Output = io.Discard } func unmute() { diff --git a/v2/internal/typescriptify/typescriptify.go b/v2/internal/typescriptify/typescriptify.go index 216fba820..e732c5976 100644 --- a/v2/internal/typescriptify/typescriptify.go +++ b/v2/internal/typescriptify/typescriptify.go @@ -2,6 +2,7 @@ package typescriptify import ( "bufio" + "cmp" "fmt" "io" "log" @@ -9,6 +10,7 @@ import ( "path" "reflect" "regexp" + "slices" "strings" "time" @@ -372,6 +374,9 @@ func (t *TypeScriptify) AddEnum(values interface{}) *TypeScriptify { elements = append(elements, el) } + slices.SortFunc(elements, func(a, b enumElement) int { + return cmp.Compare(a.name, b.name) + }) ty := reflect.TypeOf(elements[0].value) t.enums[ty] = elements t.enumTypes = append(t.enumTypes, EnumType{Type: ty}) @@ -516,9 +521,6 @@ func (t TypeScriptify) ConvertToFile(fileName string, packageName string) error if _, err := f.WriteString(converted); err != nil { return err } - if err != nil { - return err - } return nil } diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index 7263f63ae..491a57801 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -3,6 +3,7 @@ package build import ( "fmt" "os" + "os/exec" "path/filepath" "runtime" "strings" @@ -357,6 +358,16 @@ func execBuildApplication(builder Builder, options *Options) (string, error) { pterm.Println("Done.") } + if runtime.GOOS == "darwin" && options.Platform == "darwin" { + // On macOS, self-sign the .app bundle so notifications work + printBulletPoint("Self-signing application: ") + cmd := exec.Command("/usr/bin/codesign", "--force", "--deep", "--sign", "-", options.CompiledBinary) + if out, err := cmd.CombinedOutput(); err != nil { + return "", fmt.Errorf("codesign failed: %v – %s", err, out) + } + pterm.Println("Done.") + } + if options.Platform == "windows" { const nativeWebView2Loader = "native_webview2loader" diff --git a/v2/pkg/options/windows/windows.go b/v2/pkg/options/windows/windows.go index aa065ecd9..1fe351455 100644 --- a/v2/pkg/options/windows/windows.go +++ b/v2/pkg/options/windows/windows.go @@ -35,6 +35,27 @@ const ( Tabbed BackdropType = 4 ) +const ( + // Default is 0, which means no changes to the default Windows DLL search behavior + DLLSearchDefault uint32 = 0 + // LoadLibrary flags for determining from where to search for a DLL + DLLSearchDontResolveDllReferences uint32 = 0x1 // windows.DONT_RESOLVE_DLL_REFERENCES + DLLSearchAsDataFile uint32 = 0x2 // windows.LOAD_LIBRARY_AS_DATAFILE + DLLSearchWithAlteredPath uint32 = 0x8 // windows.LOAD_WITH_ALTERED_SEARCH_PATH + DLLSearchIgnoreCodeAuthzLevel uint32 = 0x10 // windows.LOAD_IGNORE_CODE_AUTHZ_LEVEL + DLLSearchAsImageResource uint32 = 0x20 // windows.LOAD_LIBRARY_AS_IMAGE_RESOURCE + DLLSearchAsDataFileExclusive uint32 = 0x40 // windows.LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE + DLLSearchRequireSignedTarget uint32 = 0x80 // windows.LOAD_LIBRARY_REQUIRE_SIGNED_TARGET + DLLSearchDllLoadDir uint32 = 0x100 // windows.LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR + DLLSearchApplicationDir uint32 = 0x200 // windows.LOAD_LIBRARY_SEARCH_APPLICATION_DIR + DLLSearchUserDirs uint32 = 0x400 // windows.LOAD_LIBRARY_SEARCH_USER_DIRS + DLLSearchSystem32 uint32 = 0x800 // windows.LOAD_LIBRARY_SEARCH_SYSTEM32 + DLLSearchDefaultDirs uint32 = 0x1000 // windows.LOAD_LIBRARY_SEARCH_DEFAULT_DIRS + DLLSearchSafeCurrentDirs uint32 = 0x2000 // windows.LOAD_LIBRARY_SAFE_CURRENT_DIRS + DLLSearchSystem32NoForwarder uint32 = 0x4000 // windows.LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER + DLLSearchOsIntegrityContinuity uint32 = 0x8000 // windows.LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY +) + func RGB(r, g, b uint8) int32 { col := int32(b) col = col<<8 | int32(g) @@ -122,6 +143,11 @@ type Options struct { // Class name for the window. If empty, 'wailsWindow' will be used. WindowClassName string + + // DLLSearchPaths controls which directories are searched when loading DLLs + // Set to 0 for default behavior, or combine multiple flags with bitwise OR + // Example: DLLSearchApplicationDir | DLLSearchSystem32 + DLLSearchPaths uint32 } func DefaultMessages() *Messages { diff --git a/v2/pkg/runtime/notifications.go b/v2/pkg/runtime/notifications.go new file mode 100644 index 000000000..46ae09fac --- /dev/null +++ b/v2/pkg/runtime/notifications.go @@ -0,0 +1,136 @@ +package runtime + +import ( + "context" + + "github.com/wailsapp/wails/v2/internal/frontend" +) + +// NotificationOptions contains configuration for a notification. +type NotificationOptions = frontend.NotificationOptions + +// NotificationAction represents an action button for a notification. +type NotificationAction = frontend.NotificationAction + +// NotificationCategory groups actions for notifications. +type NotificationCategory = frontend.NotificationCategory + +// NotificationResponse represents the response sent by interacting with a notification. +type NotificationResponse = frontend.NotificationResponse + +// NotificationResult represents the result of a notification response, +// returning the response or any errors that occurred. +type NotificationResult = frontend.NotificationResult + +// InitializeNotifications initializes the notification service for the application. +// This must be called before sending any notifications. On macOS, this also ensures +// the notification delegate is properly initialized. +func InitializeNotifications(ctx context.Context) error { + fe := getFrontend(ctx) + return fe.InitializeNotifications() +} + +// CleanupNotifications cleans up notification resources and releases any held connections. +// This should be called when shutting down the application to properly release resources +// (primarily needed on Linux to close D-Bus connections). +func CleanupNotifications(ctx context.Context) { + fe := getFrontend(ctx) + fe.CleanupNotifications() +} + +// IsNotificationAvailable checks if notifications are available on the current platform. +func IsNotificationAvailable(ctx context.Context) bool { + fe := getFrontend(ctx) + return fe.IsNotificationAvailable() +} + +// RequestNotificationAuthorization requests notification authorization from the user. +// On macOS, this prompts the user to allow notifications. On other platforms, this +// always returns true. Returns true if authorization was granted, false otherwise. +func RequestNotificationAuthorization(ctx context.Context) (bool, error) { + fe := getFrontend(ctx) + return fe.RequestNotificationAuthorization() +} + +// CheckNotificationAuthorization checks the current notification authorization status. +// On macOS, this checks if the app has notification permissions. On other platforms, +// this always returns true. +func CheckNotificationAuthorization(ctx context.Context) (bool, error) { + fe := getFrontend(ctx) + return fe.CheckNotificationAuthorization() +} + +// SendNotification sends a basic notification with the given options. +// The notification will display with the provided title, subtitle (if supported), +// and body text. +func SendNotification(ctx context.Context, options NotificationOptions) error { + fe := getFrontend(ctx) + return fe.SendNotification(options) +} + +// SendNotificationWithActions sends a notification with action buttons. +// A NotificationCategory must be registered first using RegisterNotificationCategory. +// The options.CategoryID must match a previously registered category ID. +// If the category is not found, a basic notification will be sent instead. +func SendNotificationWithActions(ctx context.Context, options NotificationOptions) error { + fe := getFrontend(ctx) + return fe.SendNotificationWithActions(options) +} + +// RegisterNotificationCategory registers a notification category that can be used +// with SendNotificationWithActions. Categories define the action buttons and optional +// reply fields that will appear on notifications. +func RegisterNotificationCategory(ctx context.Context, category NotificationCategory) error { + fe := getFrontend(ctx) + return fe.RegisterNotificationCategory(category) +} + +// RemoveNotificationCategory removes a previously registered notification category. +func RemoveNotificationCategory(ctx context.Context, categoryId string) error { + fe := getFrontend(ctx) + return fe.RemoveNotificationCategory(categoryId) +} + +// RemoveAllPendingNotifications removes all pending notifications from the notification center. +// On Windows, this is a no-op as the platform manages notification lifecycle automatically. +func RemoveAllPendingNotifications(ctx context.Context) error { + fe := getFrontend(ctx) + return fe.RemoveAllPendingNotifications() +} + +// RemovePendingNotification removes a specific pending notification by its identifier. +// On Windows, this is a no-op as the platform manages notification lifecycle automatically. +func RemovePendingNotification(ctx context.Context, identifier string) error { + fe := getFrontend(ctx) + return fe.RemovePendingNotification(identifier) +} + +// RemoveAllDeliveredNotifications removes all delivered notifications from the notification center. +// On Windows, this is a no-op as the platform manages notification lifecycle automatically. +func RemoveAllDeliveredNotifications(ctx context.Context) error { + fe := getFrontend(ctx) + return fe.RemoveAllDeliveredNotifications() +} + +// RemoveDeliveredNotification removes a specific delivered notification by its identifier. +// On Windows, this is a no-op as the platform manages notification lifecycle automatically. +func RemoveDeliveredNotification(ctx context.Context, identifier string) error { + fe := getFrontend(ctx) + return fe.RemoveDeliveredNotification(identifier) +} + +// RemoveNotification removes a notification by its identifier. +// This is a convenience function that works across platforms. On macOS, use the +// more specific RemovePendingNotification or RemoveDeliveredNotification functions. +func RemoveNotification(ctx context.Context, identifier string) error { + fe := getFrontend(ctx) + return fe.RemoveNotification(identifier) +} + +// OnNotificationResponse registers a callback function that will be invoked when +// a user interacts with a notification (e.g., clicks an action button or the notification itself). +// The callback receives a NotificationResult containing the response details or any errors. +func OnNotificationResponse(ctx context.Context, callback func(result NotificationResult)) { + fe := getFrontend(ctx) + fe.OnNotificationResponse(callback) +} diff --git a/v2/pkg/runtime/signal_linux.go b/v2/pkg/runtime/signal_linux.go new file mode 100644 index 000000000..6a7ed5db3 --- /dev/null +++ b/v2/pkg/runtime/signal_linux.go @@ -0,0 +1,65 @@ +//go:build linux + +package runtime + +/* +#include +#include +#include +#include + +static void fix_signal(int signum) +{ + struct sigaction st; + + if (sigaction(signum, NULL, &st) < 0) { + return; + } + st.sa_flags |= SA_ONSTACK; + sigaction(signum, &st, NULL); +} + +static void fix_all_signals() +{ +#if defined(SIGSEGV) + fix_signal(SIGSEGV); +#endif +#if defined(SIGBUS) + fix_signal(SIGBUS); +#endif +#if defined(SIGFPE) + fix_signal(SIGFPE); +#endif +#if defined(SIGABRT) + fix_signal(SIGABRT); +#endif +} +*/ +import "C" + +// ResetSignalHandlers resets signal handlers to allow panic recovery. +// +// On Linux, WebKit (used for the webview) may install signal handlers without +// the SA_ONSTACK flag, which prevents Go from properly recovering from panics +// caused by nil pointer dereferences or other memory access violations. +// +// Call this function immediately before code that might panic to ensure +// the signal handlers are properly configured for Go's panic recovery mechanism. +// +// Example usage: +// +// go func() { +// defer func() { +// if err := recover(); err != nil { +// log.Printf("Recovered from panic: %v", err) +// } +// }() +// runtime.ResetSignalHandlers() +// // Code that might panic... +// }() +// +// Note: This function only has an effect on Linux. On other platforms, +// it is a no-op. +func ResetSignalHandlers() { + C.fix_all_signals() +} diff --git a/v2/pkg/runtime/signal_other.go b/v2/pkg/runtime/signal_other.go new file mode 100644 index 000000000..3171a700c --- /dev/null +++ b/v2/pkg/runtime/signal_other.go @@ -0,0 +1,18 @@ +//go:build !linux + +package runtime + +// ResetSignalHandlers resets signal handlers to allow panic recovery. +// +// On Linux, WebKit (used for the webview) may install signal handlers without +// the SA_ONSTACK flag, which prevents Go from properly recovering from panics +// caused by nil pointer dereferences or other memory access violations. +// +// Call this function immediately before code that might panic to ensure +// the signal handlers are properly configured for Go's panic recovery mechanism. +// +// Note: This function only has an effect on Linux. On other platforms, +// it is a no-op. +func ResetSignalHandlers() { + // No-op on non-Linux platforms +} diff --git a/v2/pkg/templates/base/go.mod.tmpl b/v2/pkg/templates/base/go.mod.tmpl index dd7184879..4b34d1668 100644 --- a/v2/pkg/templates/base/go.mod.tmpl +++ b/v2/pkg/templates/base/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.18 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/generate/plain/go.mod.tmpl b/v2/pkg/templates/generate/plain/go.mod.tmpl index e01fbe9e7..f6d0daec4 100644 --- a/v2/pkg/templates/generate/plain/go.mod.tmpl +++ b/v2/pkg/templates/generate/plain/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.18 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates.go b/v2/pkg/templates/templates.go index 9b42ef365..e18185520 100644 --- a/v2/pkg/templates/templates.go +++ b/v2/pkg/templates/templates.go @@ -186,7 +186,16 @@ func Install(options *Options) (bool, *Template, error) { return false, nil, err } options.TargetDir = targetDir - if !fs.DirExists(options.TargetDir) { + if fs.DirExists(options.TargetDir) { + // Check if directory is non-empty + entries, err := os.ReadDir(options.TargetDir) + if err != nil { + return false, nil, err + } + if len(entries) > 0 { + return false, nil, fmt.Errorf("cannot initialise project in non-empty directory: %s", options.TargetDir) + } + } else { err := fs.Mkdir(options.TargetDir) if err != nil { return false, nil, err diff --git a/v2/pkg/templates/templates/lit-ts/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/lit-ts/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/lit-ts/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/lit-ts/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/lit-ts/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/lit-ts/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/lit-ts/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/lit-ts/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/lit-ts/go.mod.tmpl b/v2/pkg/templates/templates/lit-ts/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/lit-ts/go.mod.tmpl +++ b/v2/pkg/templates/templates/lit-ts/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/lit/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/lit/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/lit/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/lit/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/lit/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/lit/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/lit/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/lit/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/lit/go.mod.tmpl b/v2/pkg/templates/templates/lit/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/lit/go.mod.tmpl +++ b/v2/pkg/templates/templates/lit/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/plain/go.mod.tmpl b/v2/pkg/templates/templates/plain/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/plain/go.mod.tmpl +++ b/v2/pkg/templates/templates/plain/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/preact-ts/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/preact-ts/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/preact-ts/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/preact-ts/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/preact-ts/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/preact-ts/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/preact-ts/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/preact-ts/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/preact-ts/go.mod.tmpl b/v2/pkg/templates/templates/preact-ts/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/preact-ts/go.mod.tmpl +++ b/v2/pkg/templates/templates/preact-ts/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/preact/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/preact/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/preact/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/preact/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/preact/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/preact/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/preact/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/preact/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/preact/go.mod.tmpl b/v2/pkg/templates/templates/preact/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/preact/go.mod.tmpl +++ b/v2/pkg/templates/templates/preact/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/react-ts/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/react-ts/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/react-ts/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/react-ts/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/react-ts/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/react-ts/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/react-ts/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/react-ts/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/react-ts/go.mod.tmpl b/v2/pkg/templates/templates/react-ts/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/react-ts/go.mod.tmpl +++ b/v2/pkg/templates/templates/react-ts/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/react/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/react/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/react/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/react/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/react/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/react/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/react/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/react/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/react/go.mod.tmpl b/v2/pkg/templates/templates/react/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/react/go.mod.tmpl +++ b/v2/pkg/templates/templates/react/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/svelte-ts/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/svelte-ts/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/svelte-ts/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/svelte-ts/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/svelte-ts/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/svelte-ts/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/svelte-ts/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/svelte-ts/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/svelte-ts/go.mod.tmpl b/v2/pkg/templates/templates/svelte-ts/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/svelte-ts/go.mod.tmpl +++ b/v2/pkg/templates/templates/svelte-ts/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/svelte/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/svelte/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/svelte/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/svelte/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/svelte/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/svelte/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/svelte/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/svelte/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/svelte/go.mod.tmpl b/v2/pkg/templates/templates/svelte/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/svelte/go.mod.tmpl +++ b/v2/pkg/templates/templates/svelte/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/vanilla-ts/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/vanilla-ts/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/vanilla-ts/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/vanilla-ts/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/vanilla-ts/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/vanilla-ts/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/vanilla-ts/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/vanilla-ts/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/vanilla-ts/go.mod.tmpl b/v2/pkg/templates/templates/vanilla-ts/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/vanilla-ts/go.mod.tmpl +++ b/v2/pkg/templates/templates/vanilla-ts/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/vanilla/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/vanilla/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/vanilla/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/vanilla/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/vanilla/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/vanilla/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/vanilla/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/vanilla/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/vanilla/go.mod.tmpl b/v2/pkg/templates/templates/vanilla/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/vanilla/go.mod.tmpl +++ b/v2/pkg/templates/templates/vanilla/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/vue-ts/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/vue-ts/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/vue-ts/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/vue-ts/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/vue-ts/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/vue-ts/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/vue-ts/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/vue-ts/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/vue-ts/go.mod.tmpl b/v2/pkg/templates/templates/vue-ts/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/vue-ts/go.mod.tmpl +++ b/v2/pkg/templates/templates/vue-ts/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates/vue/frontend/wailsjs/runtime/runtime.d.ts b/v2/pkg/templates/templates/vue/frontend/wailsjs/runtime/runtime.d.ts index 02e7bb46b..336fb07aa 100644 --- a/v2/pkg/templates/templates/vue/frontend/wailsjs/runtime/runtime.d.ts +++ b/v2/pkg/templates/templates/vue/frontend/wailsjs/runtime/runtime.d.ts @@ -52,6 +52,10 @@ export function EventsOnce(eventName: string, callback: (...data: any) => void): // unregisters the listener for the given event name. export function EventsOff(eventName: string): void; +// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall) +// unregisters all event listeners. +export function EventsOffAll(): void; + // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint) // logs the given message as a raw message export function LogPrint(message: string): void; diff --git a/v2/pkg/templates/templates/vue/frontend/wailsjs/runtime/runtime.js b/v2/pkg/templates/templates/vue/frontend/wailsjs/runtime/runtime.js index 2c3dafcc3..b5ae16d56 100644 --- a/v2/pkg/templates/templates/vue/frontend/wailsjs/runtime/runtime.js +++ b/v2/pkg/templates/templates/vue/frontend/wailsjs/runtime/runtime.js @@ -48,6 +48,10 @@ export function EventsOff(eventName) { return window.runtime.EventsOff(eventName); } +export function EventsOffAll() { + return window.runtime.EventsOffAll(); +} + export function EventsOnce(eventName, callback) { EventsOnMultiple(eventName, callback, 1); } diff --git a/v2/pkg/templates/templates/vue/go.mod.tmpl b/v2/pkg/templates/templates/vue/go.mod.tmpl index 0dd9f465a..4b34d1668 100644 --- a/v2/pkg/templates/templates/vue/go.mod.tmpl +++ b/v2/pkg/templates/templates/vue/go.mod.tmpl @@ -1,6 +1,6 @@ module changeme -go 1.23 +go 1.23.0 require github.com/wailsapp/wails/v2 {{.WailsVersion}} diff --git a/v2/pkg/templates/templates_test.go b/v2/pkg/templates/templates_test.go index 3b906601a..658ecadb6 100644 --- a/v2/pkg/templates/templates_test.go +++ b/v2/pkg/templates/templates_test.go @@ -52,3 +52,48 @@ func TestInstall(t *testing.T) { is2.NoErr(err) } + +func TestInstallFailsInNonEmptyDirectory(t *testing.T) { + is2 := is.New(t) + + // Create a temp directory with a file in it + tempDir, err := os.MkdirTemp("", "wails-test-nonempty-*") + is2.NoErr(err) + defer func() { + _ = os.RemoveAll(tempDir) + }() + + // Create a file in the directory to make it non-empty + err = os.WriteFile(filepath.Join(tempDir, "existing-file.txt"), []byte("test"), 0644) + is2.NoErr(err) + + options := &Options{ + ProjectName: "test", + TemplateName: "vanilla", + TargetDir: tempDir, + } + + _, _, err = Install(options) + is2.True(err != nil) // Should fail + is2.True(err.Error() == "cannot initialise project in non-empty directory: "+tempDir) +} + +func TestInstallSucceedsInEmptyDirectory(t *testing.T) { + is2 := is.New(t) + + // Create an empty temp directory + tempDir, err := os.MkdirTemp("", "wails-test-empty-*") + is2.NoErr(err) + defer func() { + _ = os.RemoveAll(tempDir) + }() + + options := &Options{ + ProjectName: "test", + TemplateName: "vanilla", + TargetDir: tempDir, + } + + _, _, err = Install(options) + is2.NoErr(err) // Should succeed in empty directory +} diff --git a/website/bun.lockb b/website/bun.lockb new file mode 100644 index 000000000..63ed1b159 Binary files /dev/null and b/website/bun.lockb differ diff --git a/website/docs/community/showcase/clustta.mdx b/website/docs/community/showcase/clustta.mdx new file mode 100644 index 000000000..7da3195df --- /dev/null +++ b/website/docs/community/showcase/clustta.mdx @@ -0,0 +1,27 @@ +--- +title: Clustta +description: File manager and project management tool for creative professionals. +slug: /community/showcase/clustta +image: /img/showcase/clustta.png +--- + +
+ Clustta screenshot +
+ +[Clustta](https://clustta.com) is a file manager and project management tool designed for creative professionals. Built with Wails, it simplifies file management, collaboration, and version control for creative workflows. + +## Features + +- **File Management**: Track all projects and files with easy access even months after completion. +- **Version Control**: Save unlimited revisions with descriptive notes, without duplicating files. +- **Collaboration**: Share files or entire projects securely through simple user tags with fine-grained permissions. +- **Recovery**: Restore corrupted files from saved checkpoints if your software crashes. +- **Templates**: Quick start with preset project and task templates. +- **Kanban Boards**: Visual task tracking to keep tasks organized. +- **Dependencies**: Track and version project resources and dependencies. +- **Checkpoints**: Create memorable milestones and explore alternate creative directions non-destructively. +- **Search & Filters**: Powerful instant search with metadata filtering (task types, tags, status, file extensions). +- **Workspaces**: Save search and filter combinations for easy access to specific task sets. +- **Integrations**: Connect with creative software packages and production management tools like Blender and Kitsu. +- **Self-Hosting**: Host private instances for teams or studios on your own servers. diff --git a/website/docs/community/showcase/gamestacker.mdx b/website/docs/community/showcase/gamestacker.mdx new file mode 100644 index 000000000..46245e146 --- /dev/null +++ b/website/docs/community/showcase/gamestacker.mdx @@ -0,0 +1,19 @@ +--- +title: GameStacker +description: A modern, console-like interface that unifies your game libraries. +slug: /community/showcase/gamestacker +image: /img/showcase/gamestacker.webp +--- + +
+ GameStacker main dashboard +
+ +[GameStacker](https://gamestacker.io) is a modern, elegant console-like interface that unifies your entire game collection into one beautiful dashboard. + +## Features + +- **Unified Library**: Automatically detects and imports games from external libraries (such as Steam, LaunchBox, and RetroBat), bringing your modern and retro collections into a single, cohesive interface. +- **True Console Experience**: Built for controllers with responsive navigation, UI sound effects, and a dedicated in-game "Guide" overlay to control music and manage your session without alt-tabbing. +- **Achievement Integration**: Tracks your progress across supported services, allowing you to view unlocks and Gamerscore directly from the dashboard. +- **Multi-Profile Support**: Create unique profiles with custom avatars and specific color themes for a personalized experience. diff --git a/website/docs/community/showcase/upbeat.mdx b/website/docs/community/showcase/upbeat.mdx new file mode 100644 index 000000000..2f85b6cce --- /dev/null +++ b/website/docs/community/showcase/upbeat.mdx @@ -0,0 +1,18 @@ +--- +title: UpBeat +description: An RSS/Atom Feed Reader that filters out negative news with locally run ML models. +slug: /community/showcase/upbeat +image: /img/showcase/upbeat.png +--- + +
+ UpBeat screenshot +
+ +[UpBeat](https://upbeat.mitchelltechnologies.co.uk) is An RSS/Atom Feed Reader for macOS that filters out negative news with locally running ML models. + +## Features + +- **Local ML**: UpBeat runs a transformer-based sentiment analysis model directly on your Mac's hardware. No waiting for a Cloud GPU to spin up before you can decide what you want to read +- **Apple Neural Engine Enabled**: UpBeat runs its ML models directly on the Neural Engine of Macs. That means you get super-fast inference, but without burning through your battery or electricity bill. +- **Widely Compatible**: Works with the vast majority of RSS + Atom versions. diff --git a/website/docs/guides/application-development.mdx b/website/docs/guides/application-development.mdx index ae3880fd9..adefa4b04 100644 --- a/website/docs/guides/application-development.mdx +++ b/website/docs/guides/application-development.mdx @@ -10,6 +10,10 @@ The pattern used by the default templates are that `main.go` is used for configu The `app.go` file will define a struct that has 2 methods which act as hooks into the main application: ```go title="app.go" +import ( + "context" +) + type App struct { ctx context.Context } @@ -28,7 +32,7 @@ func (a *App) shutdown(ctx context.Context) { - The startup method is called as soon as Wails allocates the resources it needs and is a good place for creating resources, setting up event listeners and anything else the application needs at startup. - It is given a `context.Context` which is usually saved in a struct field. This context is needed for calling the + It is given a [`context.Context`](https://pkg.go.dev/context) which is usually saved in a struct field. This context is needed for calling the [runtime](../reference/runtime/intro.mdx). If this method returns an error, the application will terminate. In dev mode, the error will be output to the console. @@ -55,7 +59,6 @@ func main() { log.Fatal(err) } } - ``` More information on application lifecycle hooks can be found [here](../howdoesitwork.mdx#application-lifecycle-callbacks). @@ -65,7 +68,12 @@ More information on application lifecycle hooks can be found [here](../howdoesit It is likely that you will want to call Go methods from the frontend. This is normally done by adding public methods to the already defined struct in `app.go`: -```go {16-18} title="app.go" +```go {3,21-23} title="app.go" +import ( + "context" + "fmt" +) + type App struct { ctx context.Context } @@ -82,7 +90,7 @@ func (a *App) shutdown(ctx context.Context) { } func (a *App) Greet(name string) string { - return fmt.Sprintf("Hello %s!", name) + return fmt.Sprintf("Hello %s!", name) } ``` @@ -99,15 +107,14 @@ func main() { Height: 600, OnStartup: app.startup, OnShutdown: app.shutdown, - Bind: []interface{}{ - app, - }, + Bind: []interface{}{ + app, + }, }) if err != nil { log.Fatal(err) } } - ``` This will bind all public methods in our `App` struct (it will never bind the startup and shutdown methods). @@ -133,10 +140,10 @@ func main() { otherStruct.SetContext(ctx) }, OnShutdown: app.shutdown, - Bind: []interface{}{ - app, + Bind: []interface{}{ + app, otherStruct - }, + }, }) if err != nil { log.Fatal(err) @@ -187,18 +194,17 @@ func main() { Height: 600, OnStartup: app.startup, OnShutdown: app.shutdown, - Bind: []interface{}{ - app, - }, - EnumBind: []interface{}{ - AllWeekdays, - }, + Bind: []interface{}{ + app, + }, + EnumBind: []interface{}{ + AllWeekdays, + }, }) if err != nil { log.Fatal(err) } } - ``` This will add missing enums to your `model.ts` file. @@ -223,15 +229,14 @@ func main() { OnStartup: app.startup, OnShutdown: app.shutdown, Menu: app.menu(), - Bind: []interface{}{ - app, - }, + Bind: []interface{}{ + app, + }, }) if err != nil { log.Fatal(err) } } - ``` ## Assets diff --git a/website/docs/guides/custom-protocol-schemes.mdx b/website/docs/guides/custom-protocol-schemes.mdx index c56634f0e..216fb7100 100644 --- a/website/docs/guides/custom-protocol-schemes.mdx +++ b/website/docs/guides/custom-protocol-schemes.mdx @@ -59,6 +59,24 @@ func main() { } ``` +If you want to handle universal links as well, follow this [guide](https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app) to add required entitlements, add required keys to Info.plist and configure `apple-app-site-association` on your website. + +Here is example for Info.plist: +```xml +NSUserActivityTypes + + NSUserActivityTypeBrowsingWeb + +``` + +And for entitlements.plist +```xml +com.apple.developer.associated-domains + + applinks:myawesomeapp.com + +``` + ### Windows On Windows Custom Protocol Schemes is supported only with NSIS installer. During installation, the installer will create a diff --git a/website/docs/guides/linux.mdx b/website/docs/guides/linux.mdx index 1b55297b5..2cfc2e62a 100644 --- a/website/docs/guides/linux.mdx +++ b/website/docs/guides/linux.mdx @@ -70,3 +70,57 @@ If the added package does not resolve the issue, additional GStreamer dependenci - This issue impacts [Tauri apps](https://tauri.app/). Source: [developomp](https://github.com/developomp) on the [Tauri discussion board](https://github.com/tauri-apps/tauri/issues/4642#issuecomment-1643229562). + +## Panic Recovery / Signal Handling Issues + +### App crashes with "non-Go code set up signal handler without SA_ONSTACK flag" + +On Linux, if your application crashes with an error like: + +``` +signal 11 received but handler not on signal stack +fatal error: non-Go code set up signal handler without SA_ONSTACK flag +``` + +This occurs because WebKit (used for the webview) installs signal handlers that interfere with Go's panic recovery mechanism. +Normally, Go can convert signals like SIGSEGV (from nil pointer dereferences) into recoverable panics, but WebKit's signal +handlers prevent this. + +### Solution + +Use the `runtime.ResetSignalHandlers()` function immediately before code that might panic: + +```go +import "github.com/wailsapp/wails/v2/pkg/runtime" + +go func() { + defer func() { + if err := recover(); err != nil { + log.Printf("Recovered from panic: %v", err) + } + }() + // Reset signal handlers right before potentially dangerous code + runtime.ResetSignalHandlers() + + // Your code that might panic... +}() +``` + +:::warning Important + +- Call `ResetSignalHandlers()` in each goroutine where you need panic recovery +- Call it immediately before the code that might panic, as WebKit may reset the handlers at any time +- This is only necessary on Linux - the function is a no-op on other platforms + +::: + +### Why This Happens + +WebKit installs its own signal handlers for garbage collection and other internal processes. These handlers don't include +the `SA_ONSTACK` flag that Go requires to properly handle signals on the correct stack. When a signal like SIGSEGV occurs, +Go's runtime can't recover because the signal is being handled on the wrong stack. + +The `ResetSignalHandlers()` function adds the `SA_ONSTACK` flag to the signal handlers for SIGSEGV, SIGBUS, SIGFPE, and +SIGABRT, allowing Go's panic recovery to work correctly. + +Source: [GitHub Issue #3965](https://github.com/wailsapp/wails/issues/3965) diff --git a/website/docs/guides/notifications.mdx b/website/docs/guides/notifications.mdx new file mode 100644 index 000000000..50d16cb50 --- /dev/null +++ b/website/docs/guides/notifications.mdx @@ -0,0 +1,233 @@ +# Notifications + +Wails provides a comprehensive cross-platform notification system for desktop applications. This runtime allows you to display native system notifications with support for interactive elements like action buttons and text input fields. + +:::info JavaScript + +Notifications are currently unsupported in the JS runtime. + +::: + +## Basic Usage + +### Initializing Notifications + +First, initialize the notification system. This should be called during app startup (typically in `OnStartup`): + +```go +err := runtime.InitializeNotifications(a.ctx) +if err != nil { + // Handle initialization error + // On macOS, this may fail if bundle identifier is not set +} +``` + +Then, check if notifications are available on the current platform: + +```go +if runtime.IsNotificationAvailable(a.ctx) { + // Notifications are supported + // On macOS, this checks for macOS 10.14+ + // On Windows and Linux, this always returns true +} +``` + +On macOS, you'll need to request permission before sending notifications: + +```go +authorized, err := runtime.CheckNotificationAuthorization(a.ctx) +if err != nil { + // Handle authorization error +} + +if !authorized { + authorized, err = runtime.RequestNotificationAuthorization(a.ctx) + if err != nil || !authorized { + // Handle permission denial + } +} +``` + +On Windows and Linux, authorization is not required as these platforms don't have permission systems. + +### Sending Basic Notifications + +Send a basic notification with a unique ID, title, optional subtitle (macOS and Linux), and body text: + +```go +err := runtime.SendNotification(a.ctx, runtime.NotificationOptions{ + ID: "calendar-invite-001", + Title: "New Calendar Invite", + Subtitle: "From: Jane Doe", // Optional - macOS and Linux only + Body: "Tap to view the event", +}) +if err != nil { + // Handle error +} +``` + +## Interactive Notifications + +Interactive notifications allow users to respond with button actions or text input. You must first register a notification category that defines the available actions. + +### Creating Notification Categories + +Define a category with action buttons and optional text input: + +```go +categoryID := "message-category" + +category := runtime.NotificationCategory{ + ID: categoryID, + Actions: []runtime.NotificationAction{ + { + ID: "OPEN", + Title: "Open", + }, + { + ID: "ARCHIVE", + Title: "Archive", + Destructive: true, // macOS-specific - shows as red button + }, + }, + HasReplyField: true, + ReplyPlaceholder: "Type your reply...", + ReplyButtonTitle: "Reply", +} + +err := runtime.RegisterNotificationCategory(a.ctx, category) +if err != nil { + // Handle error +} +``` + +### Sending Interactive Notifications + +Send an interactive notification using the registered category. If the category is not found or `CategoryID` is empty, a basic notification will be sent instead: + +```go +err := runtime.SendNotificationWithActions(a.ctx, runtime.NotificationOptions{ + ID: "message-001", + Title: "New Message", + Subtitle: "From: John Smith", // Optional - macOS and Linux only + Body: "Hey, are you free for lunch?", + CategoryID: categoryID, +}) +if err != nil { + // Handle error +} +``` + +## Handling Notification Responses + +Listen for user interactions with notifications by registering a callback: + +```go +runtime.OnNotificationResponse(a.ctx, func(result runtime.NotificationResult) { + if result.Error != nil { + // Handle response error + return + } + + response := result.Response + fmt.Printf("Notification %s was actioned with: %s\n", + response.ID, response.ActionIdentifier) + + if response.ActionIdentifier == "TEXT_REPLY" { + fmt.Printf("User replied: %s\n", response.UserText) + } + + // You can also emit events to the frontend + runtime.EventsEmit(a.ctx, "notification", response) +}) +``` + +## Adding Custom Data + +Basic and interactive notifications can include custom data that will be returned in the response: + +```go +err := runtime.SendNotification(a.ctx, runtime.NotificationOptions{ + ID: "event-001", + Title: "Team Meeting", + Subtitle: "In 30 minutes", + Body: "Don't forget your presentation materials!", + Data: map[string]interface{}{ + "eventId": "meeting-123", + "startTime": "2024-01-15T14:00:00Z", + "attendees": []string{"john@company.com", "jane@company.com"}, + "priority": "high", + }, +}) + +// In the response handler: +runtime.OnNotificationResponse(a.ctx, func(result runtime.NotificationResult) { + response := result.Response + if eventId, ok := response.UserInfo["eventId"].(string); ok { + fmt.Printf("Event ID: %s\n", eventId) + } +}) +``` + +## Managing Notifications + +### Removing Notification Categories + +Remove a previously registered notification category: + +```go +err := runtime.RemoveNotificationCategory(a.ctx, "message-category") +``` + +### Managing Notifications Lifecycle + +Control notification visibility: + +```go +// Remove a specific pending notification (macOS and Linux only) +err := runtime.RemovePendingNotification(a.ctx, "notification-id") + +// Remove all pending notifications (macOS and Linux only) +err = runtime.RemoveAllPendingNotifications(a.ctx) + +// Remove a specific delivered notification (macOS and Linux only) +err = runtime.RemoveDeliveredNotification(a.ctx, "notification-id") + +// Remove all delivered notifications (macOS and Linux only) +err = runtime.RemoveAllDeliveredNotifications(a.ctx) + +// Remove a notification (Linux-specific) +err = runtime.RemoveNotification(a.ctx, "notification-id") +``` + +## Platform Considerations + +### macOS + +- **Authorization Required**: Apps must request notification permission +- **Notarization**: Required for app distribution on macOS +- **Features**: Supports subtitles, user text input, destructive actions, dark/light mode +- **Behavior**: Notifications appear in the system notification center + +### Windows + +- **No Authorization**: No permission system required +- **Features**: Supports user text input, high DPI displays, Windows theme adaptation +- **Limitations**: Does not support subtitles +- **Behavior**: Uses Windows toast notifications + +### Linux + +- **Desktop Environment Dependent**: Behavior varies by DE (GNOME, KDE, etc.) +- **Features**: Supports subtitles and themes +- **Limitations**: Does not support user text input +- **Behavior**: Uses native notification system when available + +## Best Practices + +1. **Check Platform Support**: Always verify notifications are available before using them +2. **Handle Authorization**: Properly request and check permissions on macOS +3. **Use Descriptive Content**: Provide clear titles, subtitles, and action button labels +4. **Handle Responses**: Always implement proper error handling for notification responses +5. **Test Across Platforms**: Verify functionality on your target platforms +6. **Clean Up**: Remove old notification categories when they're no longer needed \ No newline at end of file diff --git a/website/docs/howdoesitwork.mdx b/website/docs/howdoesitwork.mdx index 48243f4eb..405930492 100644 --- a/website/docs/howdoesitwork.mdx +++ b/website/docs/howdoesitwork.mdx @@ -63,17 +63,17 @@ func main() { type App struct { - ctx context.Context + ctx context.Context } func (b *App) startup(ctx context.Context) { - b.ctx = ctx + b.ctx = ctx } func (b *App) shutdown(ctx context.Context) {} func (b *App) Greet(name string) string { - return fmt.Sprintf("Hello %s!", name) + return fmt.Sprintf("Hello %s!", name) } ``` @@ -178,18 +178,18 @@ func main() { type App struct { - ctx context.Context + ctx context.Context } func (a *App) Greet(name string) string { - return fmt.Sprintf("Hello %s!", name) + return fmt.Sprintf("Hello %s!", name) } ``` You may bind as many structs as you like. Just make sure you create an instance of it and pass it in `Bind`: ```go {10-12} - //... + //... err := wails.Run(&options.App{ Title: "Basic Demo", Width: 1024, @@ -203,7 +203,6 @@ You may bind as many structs as you like. Just make sure you create an instance &mystruct2{}, }, }) - ``` You may bind enums types as well. @@ -236,8 +235,8 @@ var AllWeekdays = []struct { } ``` -```go {10-12} - //... +```go {14-16} + //... err := wails.Run(&options.App{ Title: "Basic Demo", Width: 1024, @@ -250,11 +249,10 @@ var AllWeekdays = []struct { &mystruct1{}, &mystruct2{}, }, - EnumBind: []interface{}{ - AllWeekdays, - }, + EnumBind: []interface{}{ + AllWeekdays, + }, }) - ``` When you run `wails dev` (or `wails generate module`), a frontend module will be generated containing the following: diff --git a/website/docs/reference/menus.mdx b/website/docs/reference/menus.mdx index 4a9b4da1b..52f399f0b 100644 --- a/website/docs/reference/menus.mdx +++ b/website/docs/reference/menus.mdx @@ -8,10 +8,23 @@ It is possible to add an application menu to Wails projects. This is achieved by setting it in the [`Menu`](../reference/options.mdx#menu) application config, or by calling the runtime method [MenuSetApplicationMenu](../reference/runtime/menu.mdx#menusetapplicationmenu). -An example of how to create a menu: +An example of how to create a menu, using [the `NewApp` scaffold](../guides/application-development.mdx): -```go +```go title="main.go" +package main +import ( + "log" + "runtime" + + "github.com/wailsapp/wails/v2" + "github.com/wailsapp/wails/v2/pkg/menu" + "github.com/wailsapp/wails/v2/pkg/menu/keys" + "github.com/wailsapp/wails/v2/pkg/options" + rt "github.com/wailsapp/wails/v2/pkg/runtime" +) + +func main() { app := NewApp() AppMenu := menu.NewMenu() @@ -29,7 +42,7 @@ An example of how to create a menu: }) if runtime.GOOS == "darwin" { - AppMenu.Append(menu.EditMenu()) // On macOS platform, EditMenu should be appended to enable Cmd+C, Cmd+V, Cmd+Z... shortcuts + AppMenu.Append(menu.EditMenu()) // On macOS platform, EditMenu should be appended to enable Cmd+C, Cmd+V, Cmd+Z... shortcuts } err := wails.Run(&options.App{ @@ -40,8 +53,11 @@ An example of how to create a menu: Bind: []interface{}{ app, }, - ) - // ... + }) + if err != nil { + log.Fatal(err) + } +} ``` It is also possible to dynamically update the menu, by updating the menu struct and calling diff --git a/website/docs/reference/runtime/events.mdx b/website/docs/reference/runtime/events.mdx index b9a6196e2..909cb79e9 100644 --- a/website/docs/reference/runtime/events.mdx +++ b/website/docs/reference/runtime/events.mdx @@ -23,6 +23,13 @@ This method unregisters the listener for the given event name, optionally multip Go: `EventsOff(ctx context.Context, eventName string, additionalEventNames ...string)`
JS: `EventsOff(eventName string, ...additionalEventNames)` +### EventsOffAll + +This method unregisters all event listeners. + +Go: `EventsOffAll(ctx context.Context)`
+JS: `EventsOffAll()` + ### EventsOnce This method sets up a listener for the given event name, but will only trigger once. It returns a function to cancel diff --git a/website/docs/reference/runtime/intro.mdx b/website/docs/reference/runtime/intro.mdx index 3c491ecf0..d67e76c64 100644 --- a/website/docs/reference/runtime/intro.mdx +++ b/website/docs/reference/runtime/intro.mdx @@ -98,3 +98,46 @@ interface EnvironmentInfo { arch: string; } ``` + +### ResetSignalHandlers + +Resets signal handlers to allow panic recovery from nil pointer dereferences and other memory access violations. + +Go: `ResetSignalHandlers()` + +:::info Linux Only + +This function only has an effect on Linux. On macOS and Windows, it is a no-op. + +On Linux, WebKit (used for the webview) may install signal handlers without the `SA_ONSTACK` flag, which prevents +Go from properly recovering from panics caused by nil pointer dereferences (SIGSEGV) or other memory access violations. + +Call this function immediately before code that might panic to ensure the signal handlers are properly configured +for Go's panic recovery mechanism. + +::: + +#### Example + +```go +go func() { + defer func() { + if err := recover(); err != nil { + log.Printf("Recovered from panic: %v", err) + } + }() + // Reset signal handlers right before potentially dangerous code + runtime.ResetSignalHandlers() + + // Code that might cause a nil pointer dereference... + var t *time.Time + fmt.Println(t.Unix()) // This would normally crash on Linux +}() +``` + +:::warning + +This function must be called in each goroutine where you want panic recovery to work, and should be called +immediately before the code that might panic, as WebKit may reset the signal handlers at any time. + +::: diff --git a/website/docs/reference/runtime/notification.mdx b/website/docs/reference/runtime/notification.mdx new file mode 100644 index 000000000..e9890ce59 --- /dev/null +++ b/website/docs/reference/runtime/notification.mdx @@ -0,0 +1,601 @@ +--- +sidebar_position: 6 +--- + +# Notification + +This part of the runtime provides access to native system notifications with support for interactive elements like action buttons and text input fields. + +### InitializeNotifications + +Initializes the notification system. It should be called during app startup. + +**Go:** `InitializeNotifications(ctx context.Context) error` + +**JavaScript:** `InitializeNotifications(): Promise` + +Returns: Error if initialization fails + +**Example:** +```go +err := runtime.InitializeNotifications(ctx) +if err != nil { + log.Fatal(err) +} +``` + +```javascript +await runtime.InitializeNotifications(); +``` + +### IsNotificationAvailable + +Checks if notifications are supported on the current platform. + +**Go:** `IsNotificationAvailable(ctx context.Context) bool` + +**JavaScript:** `IsNotificationAvailable(): Promise` + +Returns: `true` if notifications are supported, `false` otherwise + +**Example:** +```go +if !runtime.IsNotificationAvailable(ctx) { + log.Println("Notifications not available on this platform") +} +``` + +```javascript +const available = await runtime.IsNotificationAvailable(); +if (!available) { + console.log("Notifications not available on this platform"); +} +``` + +### RequestNotificationAuthorization + +Requests permission to display notifications (macOS only). On Windows and Linux, this always returns `true`. + +**Go:** `RequestNotificationAuthorization(ctx context.Context) (bool, error)` + +**JavaScript:** `RequestNotificationAuthorization(): Promise` + +Returns: Authorization status and error + +**Example:** +```go +authorized, err := runtime.RequestNotificationAuthorization(ctx) +``` + +```javascript +const authorized = await runtime.RequestNotificationAuthorization(); +``` + +### CheckNotificationAuthorization + +Checks the current notification authorization status (macOS only). On Windows and Linux, this always returns `true`. + +**Go:** `CheckNotificationAuthorization(ctx context.Context) (bool, error)` + +**JavaScript:** `CheckNotificationAuthorization(): Promise` + +Returns: Authorization status and error + +**Example:** +```go +authorized, err := runtime.CheckNotificationAuthorization(ctx) +``` + +```javascript +const authorized = await runtime.CheckNotificationAuthorization(); +``` + +### CleanupNotifications + +Cleans up notification resources and releases any held connections. This should be called when shutting down the application, particularly on Linux where it closes the D-Bus connection. + +**Go:** `CleanupNotifications(ctx context.Context)` + +**JavaScript:** `CleanupNotifications(): Promise` + +**Example:** +```go +runtime.CleanupNotifications(ctx) +``` + +```javascript +await runtime.CleanupNotifications(); +``` + +### SendNotification + +Sends a basic notification to the system. + +**Go:** `SendNotification(ctx context.Context, options NotificationOptions) error` + +**JavaScript:** `SendNotification(options: NotificationOptions): Promise` + +Returns: Error if the notification fails to send + +**Example:** +```go +err := runtime.SendNotification(ctx, runtime.NotificationOptions{ + ID: "notif-1", + Title: "Hello", + Body: "This is a notification", +}) +``` + +```javascript +await runtime.SendNotification({ + id: "notif-1", + title: "Hello", + body: "This is a notification" +}); +``` + +### SendNotificationWithActions + +Sends an interactive notification with predefined actions. Requires a registered notification category. If the category is not found or `CategoryID` is empty, a basic notification will be sent instead. + +**Go:** `SendNotificationWithActions(ctx context.Context, options NotificationOptions) error` + +**JavaScript:** `SendNotificationWithActions(options: NotificationOptions): Promise` + +Returns: Error if the notification fails to send + +**Example:** +```go +err := runtime.SendNotificationWithActions(ctx, runtime.NotificationOptions{ + ID: "notif-2", + Title: "Task Reminder", + Body: "Complete your task", + CategoryID: "TASK_CATEGORY", +}) +``` + +```javascript +await runtime.SendNotificationWithActions({ + id: "notif-2", + title: "Task Reminder", + body: "Complete your task", + categoryId: "TASK_CATEGORY" +}); +``` + +### RegisterNotificationCategory + +Registers a notification category that can be used with interactive notifications. Registering a category with the same ID as a previously registered category will override it. + +**Go:** `RegisterNotificationCategory(ctx context.Context, category NotificationCategory) error` + +**JavaScript:** `RegisterNotificationCategory(category: NotificationCategory): Promise` + +Returns: Error if registration fails + +**Example:** +```go +err := runtime.RegisterNotificationCategory(ctx, runtime.NotificationCategory{ + ID: "TASK_CATEGORY", + Actions: []runtime.NotificationAction{ + {ID: "COMPLETE", Title: "Complete"}, + {ID: "CANCEL", Title: "Cancel"}, + }, +}) +``` + +```javascript +await runtime.RegisterNotificationCategory({ + id: "TASK_CATEGORY", + actions: [ + {id: "COMPLETE", title: "Complete"}, + {id: "CANCEL", title: "Cancel"} + ] +}); +``` + +### RemoveNotificationCategory + +Removes a previously registered notification category. + +**Go:** `RemoveNotificationCategory(ctx context.Context, categoryId string) error` + +**JavaScript:** `RemoveNotificationCategory(categoryId: string): Promise` + +Returns: Error if removal fails + +**Example:** +```go +err := runtime.RemoveNotificationCategory(ctx, "TASK_CATEGORY") +``` + +```javascript +await runtime.RemoveNotificationCategory("TASK_CATEGORY"); +``` + +### RemoveAllPendingNotifications + +Removes all pending notifications (macOS and Linux only). + +**Go:** `RemoveAllPendingNotifications(ctx context.Context) error` + +**JavaScript:** `RemoveAllPendingNotifications(): Promise` + +Returns: Error if removal fails + +**Example:** +```go +err := runtime.RemoveAllPendingNotifications(ctx) +``` + +```javascript +await runtime.RemoveAllPendingNotifications(); +``` + +### RemovePendingNotification + +Removes a specific pending notification (macOS and Linux only). + +**Go:** `RemovePendingNotification(ctx context.Context, identifier string) error` + +**JavaScript:** `RemovePendingNotification(identifier: string): Promise` + +Returns: Error if removal fails + +**Example:** +```go +err := runtime.RemovePendingNotification(ctx, "notif-1") +``` + +```javascript +await runtime.RemovePendingNotification("notif-1"); +``` + +### RemoveAllDeliveredNotifications + +Removes all delivered notifications (macOS and Linux only). + +**Go:** `RemoveAllDeliveredNotifications(ctx context.Context) error` + +**JavaScript:** `RemoveAllDeliveredNotifications(): Promise` + +Returns: Error if removal fails + +**Example:** +```go +err := runtime.RemoveAllDeliveredNotifications(ctx) +``` + +```javascript +await runtime.RemoveAllDeliveredNotifications(); +``` + +### RemoveDeliveredNotification + +Removes a specific delivered notification (macOS and Linux only). + +**Go:** `RemoveDeliveredNotification(ctx context.Context, identifier string) error` + +**JavaScript:** `RemoveDeliveredNotification(identifier: string): Promise` + +Returns: Error if removal fails + +**Example:** +```go +err := runtime.RemoveDeliveredNotification(ctx, "notif-1") +``` + +```javascript +await runtime.RemoveDeliveredNotification("notif-1"); +``` + +### RemoveNotification + +Removes a notification by identifier (Linux only). On macOS and Windows, this is a stub that always returns `nil`. + +**Go:** `RemoveNotification(ctx context.Context, identifier string) error` + +**JavaScript:** `RemoveNotification(identifier: string): Promise` + +Returns: Error if removal fails + +**Example:** +```go +err := runtime.RemoveNotification(ctx, "notif-1") +``` + +```javascript +await runtime.RemoveNotification("notif-1"); +``` + +### OnNotificationResponse + +Registers a callback function to handle notification responses when users interact with notifications. + +**Go:** `OnNotificationResponse(ctx context.Context, callback func(result NotificationResult))` + +:::note JavaScript + +`OnNotificationResponse` is not available in the JavaScript runtime. Instead, JavaScript applications should use the [Events API](/docs/reference/runtime/events) to listen for notification responses. From your Go callback, emit an event that your JavaScript code can listen to. + +**Example:** +```go +runtime.OnNotificationResponse(ctx, func(result runtime.NotificationResult) { + if result.Error != nil { + return + } + // Emit an event that JavaScript can listen to + runtime.EventsEmit(ctx, "notification-response", result.Response) +}) +``` + +```javascript +runtime.EventsOn("notification-response", (response) => { + console.log("Notification response:", response); + switch (response.actionIdentifier) { + case "COMPLETE": + // Handle complete action + break; + case "CANCEL": + // Handle cancel action + break; + } +}); +``` + +::: + +## Options + +### NotificationOptions + +**Go:** +```go +type NotificationOptions struct { + ID string `json:"id"` + Title string `json:"title"` + Subtitle string `json:"subtitle,omitempty"` // (macOS and Linux only) + Body string `json:"body,omitempty"` + CategoryID string `json:"categoryId,omitempty"` + Data map[string]interface{} `json:"data,omitempty"` +} +``` + +**TypeScript:** +```typescript +interface NotificationOptions { + id: string; + title: string; + subtitle?: string; // macOS and Linux only + body?: string; + categoryId?: string; + data?: { [key: string]: any }; +} +``` + +| Field | Description | Win | Mac | Lin | +|-------------|------------------------------------------------|-----|-----|-----| +| ID | Unique identifier for the notification | ✅ | ✅ | ✅ | +| Title | Main notification title | ✅ | ✅ | ✅ | +| Subtitle | Subtitle text (macOS and Linux only) | | ✅ | ✅ | +| Body | Main notification content | ✅ | ✅ | ✅ | +| CategoryID | Category identifier for interactive notifications | ✅ | ✅ | ✅ | +| Data | Custom data to associate with the notification | ✅ | ✅ | ✅ | + +### NotificationCategory + +**Go:** +```go +type NotificationCategory struct { + ID string `json:"id,omitempty"` + Actions []NotificationAction `json:"actions,omitempty"` + HasReplyField bool `json:"hasReplyField,omitempty"` + ReplyPlaceholder string `json:"replyPlaceholder,omitempty"` + ReplyButtonTitle string `json:"replyButtonTitle,omitempty"` +} +``` + +**TypeScript:** +```typescript +interface NotificationCategory { + id?: string; + actions?: NotificationAction[]; + hasReplyField?: boolean; + replyPlaceholder?: string; + replyButtonTitle?: string; +} +``` + +| Field | Description | Win | Mac | Lin | +|------------------|------------------------------------------------|-----|-----|-----| +| ID | Unique identifier for the category | ✅ | ✅ | ✅ | +| Actions | Array of action buttons | ✅ | ✅ | ✅ | +| HasReplyField | Whether to include a text input field | ✅ | ✅ | | +| ReplyPlaceholder | Placeholder text for the input field | ✅ | ✅ | | +| ReplyButtonTitle | Text for the reply button | ✅ | ✅ | | + +### NotificationAction + +**Go:** +```go +type NotificationAction struct { + ID string `json:"id,omitempty"` + Title string `json:"title,omitempty"` + Destructive bool `json:"destructive,omitempty"` // (macOS-specific) +} +``` + +**TypeScript:** +```typescript +interface NotificationAction { + id?: string; + title?: string; + destructive?: boolean; // macOS-specific +} +``` + +| Field | Description | Win | Mac | Lin | +|-------------|------------------------------------------------|----------------|-----|-----| +| ID | Unique identifier for the action | ✅ | ✅ | ✅ | +| Title | Button text | ✅ | ✅ | ✅ | +| Destructive | Whether the action is destructive (macOS-only) | | ✅ | | + +#### macOS-specific Behavior + +On macOS, the `Destructive` flag causes the action button to appear in red, indicating it's a destructive action (like delete or cancel). On Windows and Linux, this flag is ignored. + +Example: +```go +actions := []runtime.NotificationAction{ + {ID: "SAVE", Title: "Save"}, + {ID: "DELETE", Title: "Delete", Destructive: true}, // Shows as red button on macOS +} +``` + +### NotificationResponse + +```go +type NotificationResponse struct { + ID string `json:"id,omitempty"` + ActionIdentifier string `json:"actionIdentifier,omitempty"` + CategoryID string `json:"categoryId,omitempty"` // Consistent with NotificationOptions + Title string `json:"title,omitempty"` + Subtitle string `json:"subtitle,omitempty"` // (macOS and Linux only) + Body string `json:"body,omitempty"` + UserText string `json:"userText,omitempty"` + UserInfo map[string]interface{} `json:"userInfo,omitempty"` +} +``` + +| Field | Description | Win | Mac | Lin | +|------------------|------------------------------------------------|-----|-----|-----| +| ID | Notification identifier | ✅ | ✅ | ✅ | +| ActionIdentifier | Action that was triggered | ✅ | ✅ | ✅ | +| CategoryID | Category of the notification | ✅ | ✅ | ✅ | +| Title | Title of the notification | ✅ | ✅ | ✅ | +| Subtitle | Subtitle of the notification (macOS and Linux only) | | ✅ | ✅ | +| Body | Body text of the notification | ✅ | ✅ | ✅ | +| UserText | Text entered by the user | ✅ | ✅ | | +| UserInfo | Custom data from the notification | ✅ | ✅ | ✅ | + +### NotificationResult + +```go +type NotificationResult struct { + Response NotificationResponse + Error error +} +``` + +| Field | Description | +|----------|------------------------------------------------| +| Response | The notification response data | +| Error | Any error that occurred during the interaction | + +## Platform-Specific Behavior + +### macOS + +- **Authorization Required**: Apps must request notification permission before sending notifications +- **Notarization**: Apps must be notarized for distribution +- **Features**: All features supported including subtitles, text input, and destructive actions +- **Styling**: Automatically adapts to system dark/light mode +- **Center**: Notifications appear in macOS Notification Center + +**Example:** +```go +// Check and request authorization +authorized, err := runtime.CheckNotificationAuthorization(ctx) +if err != nil { + return err +} + +if !authorized { + authorized, err = runtime.RequestNotificationAuthorization(ctx) + if err != nil || !authorized { + return fmt.Errorf("notification authorization denied") + } +} + +// Now send notifications +``` + +```javascript +// Check and request authorization +let authorized = await runtime.CheckNotificationAuthorization(); +if (!authorized) { + authorized = await runtime.RequestNotificationAuthorization(); + if (!authorized) { + throw new Error("Notification authorization denied"); + } +} + +// Now send notifications +``` + +### Windows + +- **No Authorization**: Permission system not required +- **Features**: Supports text input and high DPI displays +- **Limitations**: Subtitle not supported +- **Styling**: Adapts to Windows theme settings +- **Behavior**: Uses Windows toast notification system + +### Linux + +- **Desktop Environment Dependent**: Behavior varies by DE (GNOME, KDE, XFCE, etc.) +- **Features**: Supports subtitles +- **Limitations**: User text input not supported +- **Styling**: Follows desktop environment theme +- **Behavior**: Uses native notification system when available + +**Example:** +```go +// Check system support +if !runtime.IsNotificationAvailable(ctx) { + return fmt.Errorf("notifications not supported on this Linux desktop") +} + +// Linux notifications may not support text input +// Only use actions that don't require user text +``` + +```javascript +// Check system support +const available = await runtime.IsNotificationAvailable(); +if (!available) { + throw new Error("Notifications not supported on this Linux desktop"); +} + +// Linux notifications may not support text input +// Only use actions that don't require user text +``` + +## Action Identifiers + +When handling notification responses, these special action identifiers may be present: + +- `DEFAULT_ACTION`: Triggered when the user clicks the notification itself (not an action button) +- `TEXT_REPLY`: Triggered when the user submits text via the reply field + +Example response handling: +```go +runtime.OnNotificationResponse(ctx, func(result runtime.NotificationResult) { + if result.Error != nil { + fmt.Printf("Response error: %v\n", result.Error) + return + } + + response := result.Response + switch response.ActionIdentifier { + case "DEFAULT_ACTION": + fmt.Println("User clicked the notification") + case "TEXT_REPLY": + fmt.Printf("User replied: %s\n", response.UserText) + case "COMPLETE": + fmt.Println("User clicked Complete button") + case "CANCEL": + fmt.Println("User clicked Cancel button") + } +}) +``` diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 737218f07..16a289a5d 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -1,8 +1,9 @@ // @ts-check // Note: type annotations allow type checking and IDEs autocompletion -const lightCodeTheme = require("prism-react-renderer/themes/github"); -const darkCodeTheme = require("prism-react-renderer/themes/dracula"); +const { themes } = require("prism-react-renderer"); +const lightCodeTheme = themes.github; +const darkCodeTheme = themes.dracula; const { getTranslationProgress } = require("./src/api/crowdin.js"); @@ -14,28 +15,16 @@ module.exports = async function configCreatorAsync() { url: "https://wails.io", baseUrl: "/", onBrokenLinks: "warn", - onBrokenMarkdownLinks: "warn", favicon: "img/favicon.ico", organizationName: "wailsapp", projectName: "wails", - webpack: { - jsLoader: (isServer) => ({ - loader: require.resolve("swc-loader"), - options: { - jsc: { - parser: { - syntax: "typescript", - tsx: true, - }, - target: "es2017", - }, - module: { - type: isServer ? "commonjs" : "es6", - }, - }, - }), + markdown: { + hooks: { + onBrokenMarkdownLinks: "warn", + }, }, + i18n: { defaultLocale: "en", locales: ["en", "zh-Hans", "ja", "ru", "ko", "fr", "pt"], diff --git a/website/i18n/de/docusaurus-theme-classic/footer.json b/website/i18n/de/docusaurus-theme-classic/footer.json index dd6667908..48e57df44 100644 --- a/website/i18n/de/docusaurus-theme-classic/footer.json +++ b/website/i18n/de/docusaurus-theme-classic/footer.json @@ -44,7 +44,7 @@ "description": "The label of footer link with label=Blog linking to /blog" }, "copyright": { - "message": "Copyright © 2022 Lea Anthony", + "message": "Copyright © 2025 Lea Anthony", "description": "The footer copyright" }, "link.item.label.Awesome": { diff --git a/website/i18n/en/docusaurus-plugin-content-docs/version-v2.11.0.json b/website/i18n/en/docusaurus-plugin-content-docs/version-v2.11.0.json new file mode 100644 index 000000000..cc03bd63d --- /dev/null +++ b/website/i18n/en/docusaurus-plugin-content-docs/version-v2.11.0.json @@ -0,0 +1,38 @@ +{ + "version.label": { + "message": "v2.11.0", + "description": "The label for version v2.11.0" + }, + "sidebar.docs.category.Getting Started": { + "message": "Getting Started", + "description": "The label for category Getting Started in sidebar docs" + }, + "sidebar.docs.category.Reference": { + "message": "Reference", + "description": "The label for category Reference in sidebar docs" + }, + "sidebar.docs.category.Runtime": { + "message": "Runtime", + "description": "The label for category Runtime in sidebar docs" + }, + "sidebar.docs.category.Community": { + "message": "Community", + "description": "The label for category Community in sidebar docs" + }, + "sidebar.docs.category.Showcase": { + "message": "Showcase", + "description": "The label for category Showcase in sidebar docs" + }, + "sidebar.docs.category.Guides": { + "message": "Guides", + "description": "The label for category Guides in sidebar docs" + }, + "sidebar.docs.category.Tutorials": { + "message": "Tutorials", + "description": "The label for category Tutorials in sidebar docs" + }, + "sidebar.docs.link.Contributing": { + "message": "Contributing", + "description": "The label for link Contributing in sidebar docs, linking to /community-guide#ways-of-contributing" + } +} diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/guides/sveltekit.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/current/guides/sveltekit.mdx index bf533477a..196eb073d 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/guides/sveltekit.mdx +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/guides/sveltekit.mdx @@ -108,8 +108,8 @@ wails dev ##### Le runtime Wails se décharge avec des pages de navigation complètes ! -- Tout ce qui provoque la navigation de page complète : \`window.location.href = '//' ou le menu contextuel se recharge lorsque vous utilisez wails dev. Cela signifie que vous pouvez finir par perdre la possibilité d'appeler n'importe quel runtime cassant l'application. Il y a deux façons de contourner ce problème. -- Utilisez `import { goto } de '$app/navigation'` puis appelez `goto('//')` dans votre +page.svelte. Cela empêchera la navigation de la page complète. +- Tout ce qui provoque la navigation de page complète : \`window.location.href = '/some/page'` ou le menu contextuel se recharge lorsque vous utilisez wails dev. Cela signifie que vous pouvez finir par perdre la possibilité d'appeler n'importe quel runtime cassant l'application. Il y a deux façons de contourner ce problème. +- Utilisez `import { goto } de '$app/navigation'` puis appelez `goto('/some/page')` dans votre +page.svelte. Cela empêchera la navigation de la page complète. - Si la navigation de la page complète ne peut pas être empêchée, le runtime Wails peut être ajouté à toutes les pages en ajoutant ce qui suit dans le `` de myapp/frontend/src/app.html ``` diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/current/reference/options.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/current/reference/options.mdx index cdcc380db..3ea5ca58e 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/current/reference/options.mdx +++ b/website/i18n/fr/docusaurus-plugin-content-docs/current/reference/options.mdx @@ -961,4 +961,4 @@ Définir cette option à `true` ouvrira l'inspecteur Web au démarrage de l'appl Nom: OpenInspectorOnStartup
Type: `bool` [^1]: Cela nécessite la prise en charge de WebKit2GTK 2.36+ et votre application doit être construite avec la balise de compilation `webkit2_36` pour activer le support de cette fonctionnalité. Cela augmente aussi la version minnimale de WebKit2GTK à 2.36 pour votre application. -[^2]: Cela nécessite la prise en charge de WebKit2GTK 2.40+ et votre application doit être construite avec la balise de compilation `webkit2_40` pour activer le support de cette fonctionnalité. Cela augmente aussi la version minnimale de WebKit2GTK à 2.40 pour votre application. [ [ ↩](#fnref2:2){.footnote-backref} ↩](#fnref:2){.footnote-backref} +[^2]: Cela nécessite la prise en charge de WebKit2GTK 2.40+ et votre application doit être construite avec la balise de compilation `webkit2_40` pour activer le support de cette fonctionnalité. Cela augmente aussi la version minnimale de WebKit2GTK à 2.40 pour votre application. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.10/reference/options.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.10/reference/options.mdx index bf62be6e3..bc0c553f6 100644 --- a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.10/reference/options.mdx +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.10/reference/options.mdx @@ -953,4 +953,4 @@ Définir cette option à `true` ouvrira l'inspecteur Web au démarrage de l'appl Nom: OpenInspectorOnStartup
Type: `bool` [^1]: Cela nécessite la prise en charge de WebKit2GTK 2.36+ et votre application doit être construite avec la balise de compilation `webkit2_36` pour activer le support de cette fonctionnalité. Cela augmente aussi la version minnimale de WebKit2GTK à 2.36 pour votre application. -[^2]: Cela nécessite la prise en charge de WebKit2GTK 2.40+ et votre application doit être construite avec la balise de compilation `webkit2_40` pour activer le support de cette fonctionnalité. Cela augmente aussi la version minnimale de WebKit2GTK à 2.40 pour votre application. [ [ ↩](#fnref2:2){.footnote-backref} ↩](#fnref:2){.footnote-backref} +[^2]: Cela nécessite la prise en charge de WebKit2GTK 2.40+ et votre application doit être construite avec la balise de compilation `webkit2_40` pour activer le support de cette fonctionnalité. Cela augmente aussi la version minnimale de WebKit2GTK à 2.40 pour votre application. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/links.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/links.mdx new file mode 100644 index 000000000..d6b742435 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/links.mdx @@ -0,0 +1,26 @@ +--- +sidebar_position: 2 +--- + +# Liens + +Cette page sert de liste pour les liens liés à la communauté. Veuillez soumettre une PR (cliquez sur `Modifier cette page` en bas) pour soumettre des liens. + +## Awesome Wails + +La [liste définitive](https://github.com/wailsapp/awesome-wails) de liens relatifs à Wails. + +## Canaux de support + +- [Serveur Discord Wails](https://discord.gg/JDdSxwjhGf) +- [Github Issues](https://github.com/wailsapp/wails/issues) +- [canal de discussion sur la bêta v2](https://github.com/wailsapp/wails/discussions/828) + +## Réseaux sociaux + +- [Twitter](https://twitter.com/wailsapp) +- [Groupe QQ pour la communauté chinoise de Wails](https://qm.qq.com/cgi-bin/qm/qr?k=PmIURne5hFGNd7QWzW5qd6FV-INEjNJv&jump_from=webapi) - Numéro de groupe : 1067173054 + +## Autres tutoriels et articles + +- [Construction d'un Panneau d'Affichage](https://blog.customct.com/building-bulletin-board) diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/bulletinboard.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/bulletinboard.mdx new file mode 100644 index 000000000..2c56a2e83 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/bulletinboard.mdx @@ -0,0 +1,10 @@ +# BulletinBoard + +```mdx-code-block +

+ +
+

+``` + +L'application [BulletinBoard](https://github.com/raguay/BulletinBoard) est un panneau de messages versitaux pour les messages statiques ou les boîtes de dialogue pour obtenir des informations de l'utilisateur pour un script. Il a une TUI pour créer de nouvelles boîtes de dialogue qui peuvent être utilisées pour obtenir des informations de l'utilisateur. Son design est de rester en fonctionnement sur votre système et de montrer les informations au besoin, puis de se cacher. J'ai un processus pour surveiller un fichier sur mon système et pour envoyer le contenu à BulletinBoard une fois modifié. Cela fonctionne très bien avec mes workflows. Il y a auss un [workflow Alfred](https://github.com/raguay/MyAlfred/blob/master/Alfred%205/EmailIt.alfredworkflow) pour envoyer les informations au programme. Le workflow fonctionne aussi avec [EmailIt](https://github.com/raguay/EmailIt). diff --git a/website/versioned_docs/version-v2.9.0/community/showcase/cfntracker.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/cfntracker.mdx similarity index 100% rename from website/versioned_docs/version-v2.9.0/community/showcase/cfntracker.mdx rename to website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/cfntracker.mdx diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/emailit.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/emailit.mdx new file mode 100644 index 000000000..ac64e25ac --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/emailit.mdx @@ -0,0 +1,10 @@ +# EmailIt + +```mdx-code-block +

+ +
+

+``` + +[EmailIt](https://github.com/raguay/EmailIt/) est un programme Wails 2 qui est un expéditeur de courrier électronique basé sur le markdown uniquement avec neuf blocs-notes, pour manipuler le texte et les modèles. Il a également un terminal pour exécuter des scripts dans EmailIt sur les fichiers de votre système. Les scripts et modèles peuvent être utilisés depuis la ligne de commande elle-même ou avec les extensions Alfred, Keyboard Maestro, Dropzone ou PopClip. Il supporte également les scripts et thèmes téléchargés sous GitHub. La documentation n'est pas complète, mais le programme fonctionne. Il est construit en utilisant Wails2 et Svelte, et le téléchargement est une application macOS universelle. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/encrypteasy.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/encrypteasy.mdx new file mode 100644 index 000000000..7f4bd7a63 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/encrypteasy.mdx @@ -0,0 +1,12 @@ +# EncryptEasy + +```mdx-code-block +

+ +
+

+``` + +**[EncryptEasy](https://www.encrypteasy.app) est un outil de chiffrement PGP simple et facile à utiliser, qui gère toutes vos clés et celles de vos contacts. Le chiffrement devrait être simple. Développé avec Wails.** + +Chiffrer les messages à l'aide de PGP est la norme de l'industrie. Tout le monde a une clé privée et publique. Votre clé privée, eh bien, doit être privée afin que vous seul puissiez lire les messages. Votre clé publique est distribuée à toute personne qui veut vous envoyer des messages secrets, chiffrés. Gérer les clés, chiffrer les messages et déchiffrer les messages devrait être une expérience agréable. EncryptEasy a pour but de vous simplifier la tâche. diff --git a/website/versioned_docs/version-v2.9.0/community/showcase/espstudio.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/espstudio.mdx similarity index 100% rename from website/versioned_docs/version-v2.9.0/community/showcase/espstudio.mdx rename to website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/espstudio.mdx diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/filehound.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/filehound.mdx new file mode 100644 index 000000000..7522afa6e --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/filehound.mdx @@ -0,0 +1,16 @@ +# Utilitaire d'exportation FileHound + +```mdx-code-block +

+ +
+

+``` + +[L'utilitaire d'exportation FileHound](https://www.filehound.co.uk/) est une plate-forme de gestion de documents cloud conçue pour la conservation sécurisée de fichiers, l'automatisation des processus métier et les capacités de SmartCapture. + +L'utilitaire d'exportation FileHound permet aux administrateurs FileHound d'exécuter des tâches sécurisées d'extraction de documents et de données à des fins alternatives de sauvegarde et de récupération. Cette application téléchargera tous les documents et/ou métadonnées enregistrés dans FileHound en fonction des filtres que vous avez choisis. Les métadonnées seront exportées dans les formats JSON et XML. + +Backend construit avec: Go 1.15 Wails 1.11.0 go-sqlite3 1.14.6 go-linq 3.2 + +Frontend avec: Vue 2.6.11 Vuex 3.4.0 TypeScript Tailwind 1.9.6 diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/grpcmd-gui.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/grpcmd-gui.mdx new file mode 100644 index 000000000..891350290 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/grpcmd-gui.mdx @@ -0,0 +1,10 @@ +# grpcmd-gui + +```mdx-code-block +

+ +
+

+``` + +[grpcmd-gui](https://grpc.md/gui) is a modern cross-platform desktop app and API client for gRPC development and testing. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/hiposter.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/hiposter.mdx new file mode 100644 index 000000000..21fd4b117 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/hiposter.mdx @@ -0,0 +1,10 @@ +# hiposter + +```mdx-code-block +

+ +
+

+``` + +[hiposter](https://github.com/obity/hiposter) est un outil client de test d'API http simple et efficace. Basé sur les Wails, Go et sveltejs. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/kafka-king.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/kafka-king.mdx new file mode 100644 index 000000000..9876cd9a0 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/kafka-king.mdx @@ -0,0 +1,23 @@ +# Kafka-King + +```mdx-code-block +

+ +
+

+``` + +[Kafka-King](https://github.com/Bronya0/Kafka-King) is a kafka GUI client that supports various systems and is compact and easy to use. +This is made of Wails+vue3 + +# Kafka-King function list + +- [x] View the cluster node list, support dynamic configuration of broker and topic configuration items +- [x] Supports consumer clients, consumes the specified topic, size, and timeout according to the specified group, and displays the message information in various dimensions in a table +- [x] Supports PLAIN, SSL, SASL, kerberos, sasl_plaintext, etc. etc. +- [x] Create topics (support batches), delete topics, specify replicas, partitions +- [x] Support statistics of the total number of messages, total number of submissions, and backlog for each topic based on consumer groups +- [x] Support viewing topics Detailed information (offset) of the partition, and support adding additional partitions +- [x] Support simulated producers, batch sending messages, specify headers, partitions +- [x] Health check +- [x] Support viewing consumer groups , Consumer- …… diff --git a/website/versioned_docs/version-v2.9.0/community/showcase/mchat.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/mchat.mdx similarity index 100% rename from website/versioned_docs/version-v2.9.0/community/showcase/mchat.mdx rename to website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/mchat.mdx diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/minecraftupdater.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/minecraftupdater.mdx new file mode 100644 index 000000000..5966e75fa --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/minecraftupdater.mdx @@ -0,0 +1,14 @@ +# Minecraft Updater + +```mdx-code-block +

+ +
+

+``` + +[Minecraft Updater](https://github.com/Gurkengewuerz/MinecraftModUpdater) est un outil utilitaire pour mettre à jour et synchroniser les mods Minecraft pour votre base d'utilisateurs. Il a été conçu en utilisant Wails2 et React avec [antd](https://ant.design/) comme framework frontend. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/minesweeper-xp.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/minesweeper-xp.mdx new file mode 100644 index 000000000..f127a005f --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/minesweeper-xp.mdx @@ -0,0 +1,10 @@ +# Minesweeper XP + +```mdx-code-block +

+ +
+

+``` + +[Minesweeper-XP](https://git.new/Minesweeper-XP) allows you to experience the classic Minesweeper XP (+ 98 and 3.1) on macOS, Windows, and Linux! diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/modalfilemanager.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/modalfilemanager.mdx new file mode 100644 index 000000000..fe644bd7b --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/modalfilemanager.mdx @@ -0,0 +1,14 @@ +# Modal File Manager + +```mdx-code-block +

+ +
+

+``` + +[Modal File Manager](https://github.com/raguay/ModalFileManager) est un gestionnaire de fichiers à double volet utilisant des technologies web. Mon design original était basé sur NW.js et peut être trouvé [ici](https://github.com/raguay/ModalFileManager-NWjs). Cette version utilise le même code frontend basé sur Svelte (mais il a été grandement modifié depuis le départ de NW.js), mais le backend est une implémentation de [Wails 2](https://wails.io/). En utilisant cette implémentation, je n'utilise plus la ligne de commande `rm`, `cp`, etc. , mais une installation de git doit être présente sur le système pour télécharger des thèmes et des extensions. Il est entièrement codé en utilisant Go et fonctionne beaucoup plus rapidement que les versions précédentes. + +Ce gestionnaire de fichiers est conçu autour du même principe que Vim: l'état est contrôlé par des actions via le clavier. Le nombre d'états n'est pas fixe, mais très programmable. Par conséquent, un nombre infini de configurations de clavier qui peuvent être créées et utilisées. C'est la principale différence par rapport aux autres gestionnaires de fichiers. Il y a des thèmes et des extensions disponibles à télécharger à partir de GitHub. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/mollywallet.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/mollywallet.mdx new file mode 100644 index 000000000..70a6cd1f4 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/mollywallet.mdx @@ -0,0 +1,10 @@ +# Molley Wallet + +```mdx-code-block +

+ +
+

+``` + +[Molly Wallet](https://github.com/grvlle/constellation_wallet/) le portefeuille officiel $DAG du Constellation Network. Cela permettra aux utilisateurs d'interagir avec le réseau Hypergraph de différentes manières, sans se limiter à la production de transactions en $DAG. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/october.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/october.mdx new file mode 100644 index 000000000..5a9789d87 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/october.mdx @@ -0,0 +1,14 @@ +# October + +```mdx-code-block +

+ +
+

+``` + +[Octobre](https://october.utf9k.net) est une petite application Wails qui rend vraiment facile d'extraire les surlignements de [Kobo eReaders](https://en.wikipedia.org/wiki/Kobo_eReader) puis de les transférer vers [Readwise](https://readwise.io). + +Il a une taille relativement petite avec toutes les versions de la plate-forme pesant en moins de 10 Mo, et c'est sans activer la [compression UPX](https://upx.github.io/)! + +En revanche, les précédentes tentatives de l'auteur avec Electron ont rapidement gonflé à plusieurs centaines de mégaoctets. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/optimus.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/optimus.mdx new file mode 100644 index 000000000..41744234d --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/optimus.mdx @@ -0,0 +1,10 @@ +# Optimus + +```mdx-code-block +

+ +
+

+``` + +[Optimus](https://github.com/splode/optimus) est une application d'optimisation d'image de bureau. Il supporte la conversion et la compression entre les formats d’images WebP, JPEG et PNG. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/portfall.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/portfall.mdx new file mode 100644 index 000000000..acdc682be --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/portfall.mdx @@ -0,0 +1,10 @@ +# Portfall + +```mdx-code-block +

+ +
+

+``` + +[Portfall](https://github.com/rekon-oss/portfall) - Un portail de redirection de port k8 pour un accès facile à toutes les interfaces de votre instance diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/resizem.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/resizem.mdx new file mode 100644 index 000000000..27f168f48 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/resizem.mdx @@ -0,0 +1,10 @@ +# Resizem + +```mdx-code-block +

+ +
+

+``` + +[Resizem](https://github.com/barats/resizem) - is an app designed for bulk image process. It is particularly useful for users who need to resize, convert, and manage large numbers of image files at once. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/restic-browser.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/restic-browser.mdx new file mode 100644 index 000000000..b65971668 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/restic-browser.mdx @@ -0,0 +1,12 @@ +# Restic Browser + +```mdx-code-block +

+ +
+

+``` + +[Restic-Browser](https://github.com/emuell/restic-browser) - Une interface de sauvegarde simple et multiplateforme [restic](https://github.com/restic/restic) pour la navigation et la restauration de dépôts restic. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/riftshare.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/riftshare.mdx new file mode 100644 index 000000000..e47b2397e --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/riftshare.mdx @@ -0,0 +1,21 @@ +# RiftShare + +```mdx-code-block +

+ +
+

+``` + +Partage de fichiers facile, sécurisé et gratuit pour tout le monde. Apprenez-en plus sur [Riftshare.app](https://riftshare.app) + +## Fonctionnalités + +- Partage facile et sécurisé de fichiers entre ordinateurs à la fois sur le réseau local et via Internet +- Supporte l'envoi de fichiers ou de répertoires de manière sécurisée par le protocole [magic wormhole](https://magic-wormhole.readthedocs.io/en/latest/) +- Compatible avec toutes les autres applications utilisant magic wormhole (magic-wormhole or wormhole-william CLI, wormhole-gui, etc.) +- Compression automatique de plusieurs fichiers sélectionnés à envoyer en même temps +- Animations complètes, barre de progression et support d'annulation pour l'envoi et la réception +- Sélection de fichier natif au système d'exploitation +- Ouvrir les fichiers en un seul clic une fois reçus +- Mise à jour automatique - ne vous inquiétez pas d'avoir la dernière version! diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/scriptbar.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/scriptbar.mdx new file mode 100644 index 000000000..d7215d661 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/scriptbar.mdx @@ -0,0 +1,10 @@ +# ScriptBar + +```mdx-code-block +

+ +
+

+``` + +[ScriptBar](https://GitHub.com/raguay/ScriptBarApp) est un programme pour afficher la sortie de scripts ou d'un serveur [Node-Red](https://nodered.org). Il exécute des scripts définis dans le programme EmailIt et affiche la sortie. Des scripts de xBar ou TextBar peuvent être utilisés. Actuellement sur les scripts TextBar fonctionnent bien. Il affiche également la sortie des scripts sur votre système. ScriptBar ne les met pas dans la barre de menus, mais les a tous dans une fenêtre convenable pour une visualisation facile. Vous pouvez avoir plusieurs onglets pour voir plusieurs choses différentes. Vous pouvez également conserver les liens vers vos sites Web les plus visités. diff --git a/website/versioned_docs/version-v2.9.0/community/showcase/snippetexpander.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/snippetexpander.mdx similarity index 100% rename from website/versioned_docs/version-v2.9.0/community/showcase/snippetexpander.mdx rename to website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/snippetexpander.mdx diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/surge.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/surge.mdx new file mode 100644 index 000000000..b59174843 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/surge.mdx @@ -0,0 +1,10 @@ +# Surge + +```mdx-code-block +

+ +
+

+``` + +[Surge](https://getsurge.io/) est une application de partage de fichiers p2p conçue pour utiliser les technologies blockchain afin d'activer les transferts de fichiers 100 % anonymes. Surge est chiffré de bout en bout, décentralisé et open source. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/tinyrdm.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/tinyrdm.mdx new file mode 100644 index 000000000..5390d57fb --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/tinyrdm.mdx @@ -0,0 +1,11 @@ +# Tiny RDM + +```mdx-code-block +

+ + +
+

+``` + +L'application [Tiny RDM](https://redis.tinycraft.cc/) est une interface Redis moderne et open-source. Il possède une interface utilisateur magnifique, une gestion de base de données Redis intuitive et compatible avec Windows, Mac et Linux. Il fournit des opérations visuelles de données de clé-valeur, supporte diverses options de décodage et de visualisation des données, possède une console intégrée pour exécuter des commandes, des requêtes de log lentes et plus encore. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wailsterm.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wailsterm.mdx new file mode 100644 index 000000000..9924dace5 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wailsterm.mdx @@ -0,0 +1,10 @@ +# WailsTerm + +```mdx-code-block +

+ +
+

+``` + +[WailsTerm](https://github.com/rlshukhov/wailsterm) is a simple translucent terminal app powered by Wails and Xterm.js. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wally.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wally.mdx new file mode 100644 index 000000000..ba2a7fccc --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wally.mdx @@ -0,0 +1,10 @@ +# Wally + +```mdx-code-block +

+ +
+

+``` + +[Wally](https://ergodox-ez.com/pages/wally) est le flasheur officiel du firmware pour les claviers [Ergodox](https://ergodox-ez.com/). C'est un excellent exemple de ce que vous pouvez réaliser avec Wails : la capacité de combiner la puissance de Go et les riches outils graphiques du monde du développement web. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/warmine.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/warmine.mdx new file mode 100644 index 000000000..2e4274330 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/warmine.mdx @@ -0,0 +1,19 @@ +# Lanceur Minecraft pour WarMine + +```mdx-code-block +

+ + +
+

+``` + +[Lanceur Minecraft pour WarMine](https://warmine.ru/) est une application Wails qui vous permet facilement de rejoindre le serveur de jeu contenant les mods, ainsi que la gestion de vos comptes de jeu. + +Le Launcher télécharge les fichiers du jeu, vérifie leur intégrité et lance le jeu avec une large gamme d'options de personnalisation. + +Le frontend est écrit en Svelte, le lanceur entier tient dans 9Mo et prend en charge Windows 7-11. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wombat.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wombat.mdx new file mode 100644 index 000000000..c431f6919 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/wombat.mdx @@ -0,0 +1,10 @@ +# Wombat + +```mdx-code-block +

+ +
+

+``` + +[Wombat](https://github.com/rogchap/wombat) est un client gRPC multi-plateforme. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/ytd.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/ytd.mdx new file mode 100644 index 000000000..4f5bd993c --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/showcase/ytd.mdx @@ -0,0 +1,10 @@ +# Ytd + +```mdx-code-block +

+ +
+

+``` + +[Ytd](https://github.com/marcio199226/ytd/tree/v2-wails) est une application pour télécharger des pistes depuis youtube, créer des listes de lecture hors ligne et les partager avec vos amis, vos amis seront en mesure de lire vos playlists ou de les télécharger pour l'écoute hors ligne, a un lecteur intégré. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/templates.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/templates.mdx new file mode 100644 index 000000000..648555579 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/community/templates.mdx @@ -0,0 +1,76 @@ +--- +sidebar_position: 1 +--- + +# Modèles + +Cette page sert de liste pour les modèles supportés par la communauté. Veuillez soumettre une PR (cliquez sur `Modifier cette page` en bas) pour inclure vos modèles. Pour construire votre propre modèle, veuillez consulter le guide [Modèles](../guides/templates.mdx). + +Pour utiliser ces modèles, exécutez `wails init -n "Votre nom de projet" -t [le lien ci-dessous[@version]]` + +S'il n'y a pas de suffixe de version, la branche principale du modèle de code sera alors utilisé par défaut. S'il y a un suffixe de version, le modèle de code correspondant au tag de cette version sera utilisé. + +Exemple : `wails init -n "Votre nom de projet" -t https://github.com/misitebao/wails-template-vue` + +:::warning Attention + +**Le projet Wails n'entretient pas, et n'est pas responsable des modèles de tierces parties!** + +Si vous n'êtes pas sûr d'un modèle, inspectez `package.json` et `wails.json` pour savoir quels scripts sont exécutés et quels paquets sont installés. + +::: + +## Vue + +- [wails-template-vue](https://github.com/misitebao/wails-template-vue) - Modèle de Wails basé sur Vue (TypeScript intégré, thème sombre, internationalisation, routage de page unique, TailwindCSS) +- [wails-template-quasar-js](https://github.com/sgosiaco/wails-template-quasar-js) - Un modèle utilisant JavaScript + Quasar V2 (Vue 3, Vite, Sass, Pinia, ESLint, Prettier) +- [wails-template-quasar-ts](https://github.com/sgosiaco/wails-template-quasar-ts) - Un modèle utilisant TypeScript + Quasar V2 (Vue 3, Vite, Sass, Pinia, ESLint, Prettier, Composition API avec <script setup>) +- [wails-template-naive](https://github.com/tk103331/wails-template-naive) - Modèle Wails basé sur Naive UI (Librairie de composants Vue 3) +- [wails-template-tdesign-js](https://github.com/tongque0/wails-template-tdesign-js) - Wails template based on TDesign UI (a Vue 3 UI library by Tencent), using Vite, Pinia, Vue Router, ESLint, and Prettier. + +## Angular + +- [wails-template-angular](https://github.com/mateothegreat/wails-template-angular) - Modèle Angular 15+ prêt à être utilisé en production. +- [wails-angular-template](https://github.com/TAINCER/wails-angular-template) - Angular avec TypeScript, Sass, rechargement à chaud, découpage dynamique de code et i18n + +## React + +- [wails-react-template](https://github.com/AlienRecall/wails-react-template) - Un modèle utilisant reactjs +- [wails-react-template](https://github.com/flin7/wails-react-template) - Un modèle minimal pour React qui supporte le développement en direct +- [wails-template-nextjs](https://github.com/LGiki/wails-template-nextjs) - Un modèle utilisant Next.js et TypeScript +- [wails-template-nextjs-app-router](https://github.com/thisisvk-in/wails-template-nextjs-app-router) - A template using Next.js and TypeScript with App router +- [wails-vite-react-ts-tailwind-template](https://github.com/hotafrika/wails-vite-react-ts-tailwind-template) - Un modèle pour React + TypeScript + Vite + TailwindCSS +- [wails-vite-react-ts-tailwind-shadcnui-template](https://github.com/Mahcks/wails-vite-react-tailwind-shadcnui-ts) - Un modèle avec Vite, React, TypeScript, TailwindCSS, et shadcn/ui +- [wails-nextjs-tailwind-template](https://github.com/kairo913/wails-nextjs-tailwind-template) - A template using Next.js and Typescript with TailwindCSS + +## Svelte + +- [wails-svelte-template](https://github.com/raitonoberu/wails-svelte-template) - Un modèle utilisant Svelte +- [wails-vite-svelte-template](https://github.com/BillBuilt/wails-vite-svelte-template) - Un modèle utilisant Svelte et Vite +- [wails-vite-svelte-ts-tailwind-template](https://github.com/xvertile/wails-vite-svelte-tailwind-template) - A template using Wails, Svelte, Vite, TypeScript, and TailwindCSS v3 +- [wails-vite-svelte-tailwind-template](https://github.com/BillBuilt/wails-vite-svelte-tailwind-template) - Un modèle utilisant Svelte et Vite avec TailwindCSS v3 +- [wails-svelte-tailwind-vite-template](https://github.com/PylotLight/wails-vite-svelte-tailwind-template/tree/master) - Un modèle mis à jour en utilisant Svelte v4.2.0 et Vite avec TailwindCSS v3.3.3 +- [wails-sveltekit-template](https://github.com/h8gi/wails-sveltekit-template) - Un modèle utilisant SvelteKit + +## Solid + +- [wails-template-vite-solid-ts](https://github.com/xijaja/wails-template-solid-ts) - Un modèle utilisant Solid + Ts + Vite +- [wails-template-vite-solid-ts](https://github.com/xijaja/wails-template-solid-js) - Un modèle utilisant Solid + Js + Vite + +## Elm + +- [wails-elm-template](https://github.com/benjamin-thomas/wails-elm-template) - Développez votre application GUI avec de la programmation fonctionnelle et une configuration de développement en direct :tada: :rocket: +- [wails-template-elm-tailwind](https://github.com/rnice01/wails-template-elm-tailwind) - Combine les puissances :muscle: d'Elm + Tailwind CSS + Wails ! Rechargement automatique pris en charge. + +## HTMX + +- [wails-htmx-templ-chi-tailwind](https://github.com/PylotLight/wails-hmtx-templ-template) - Utilisez une combinaison unique de htmx pour interactivité, et de templ pour créer des composants et des formes + +## Pure JavaScript (Vanilla) + +- [wails-pure-js-template](https://github.com/KiddoV/wails-pure-js-template) - Un modèle avec rien que du JavaScript, du HTML et du CSS de base + + +## Lit (web components) + +- [wails-lit-shoelace-esbuild-template](https://github.com/Braincompiler/wails-lit-shoelace-esbuild-template) - Wails template providing frontend with lit, Shoelace component library + pre-configured prettier and typescript. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/building.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/building.mdx new file mode 100644 index 000000000..c9cedbcd8 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/building.mdx @@ -0,0 +1,26 @@ +--- +sidebar_position: 6 +--- + +# Compiler votre projet + +À partir du répertoire du projet, exécutez `wails build`. Cela compilera votre projet et sauvegardera le binaire prêt à la production dans le répertoire `build/bin`. + +:::info Linux +If you are using a Linux distribution that does not have webkit2gtk-4.0 (such as Ubuntu 24.04), you will need to add `-tags webkit2_41`. +::: + +Si vous exécutez le binaire, vous devriez voir l'application par défaut : + +```mdx-code-block +
+ +
+
+``` + +Pour plus de détails sur les options de compilation, veuillez vous référer à la [documentation du CLI](../reference/cli.mdx#build). diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/development.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/development.mdx new file mode 100644 index 000000000..307029141 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/development.mdx @@ -0,0 +1,16 @@ +--- +sidebar_position: 5 +--- + +# Développez votre application + +Vous pouvez exécuter votre application en mode développement en exécutant `wails dev` à partir du répertoire de votre projet. Cela fera les choses suivantes : + +- Construire votre application et l'exécuter +- Lier votre code Go au frontend pour qu'il puisse être appelé à partir de JavaScript +- En utilisant la puissance de [Vite](https://vitejs.dev/), surveillera les modifications dans vos fichiers Go et reconstruira / ré-exécutera en cas de changement +- Mettra en place un [serveur web](http://localhost:34115) qui servira votre application via un navigateur. Cela vous permet d'utiliser les extensions de votre navigateur préféré. Vous pouvez même appeler votre code Go depuis la console + +Pour commencer, exécutez `wails dev` dans le répertoire du projet. Plus d'informations à ce sujet peuvent être trouvées [ici](../reference/cli.mdx#dev). + +Prochainement : Tutoriel diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/firstproject.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/firstproject.mdx new file mode 100644 index 000000000..02e9f955b --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/firstproject.mdx @@ -0,0 +1,128 @@ +--- +sidebar_position: 2 +--- + +# Créer un projet + +## Génération de projet + +Maintenant que le CLI est installé, vous pouvez générer un nouveau projet en utilisant la commande `wails init`. + +Choisissez votre framework favori : + +```mdx-code-block +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + + + + Générer un projet Svelte utilisant JavaScript avec:

+ + wails init -n myproject -t svelte + +Si vous préférez utiliser TypeScript:
+ + wails init -n myproject -t svelte-ts + +
+ + Générer un projet React utilisant JavaScript avec :

+ + wails init -n myproject -t react + +Si vous préférez utiliser TypeScript:
+ + wails init -n myproject -t react-ts + +
+ + Générer un projet Vue utilisant JavaScript avec:

+ + wails init -n myproject -t vue + +Si vous préférez TypeScript:
+ + wails init -n myproject -t vue-ts + +
+ + Générer un projet Preact utilisant JavaScript avec:

+ + wails init -n myproject -t preact + +Si vous préférez TypeScript:
+ + wails init -n myproject -t preact-ts + +
+ + Générer un projet Lit utilisant JavaScript avec:

+ + wails init -n myproject -t lit + +Si vous préférez TypeScript:
+ + wails init -n myproject -t lit-ts + +
+ + Générer un projet Vanilla utilisant JavaScript avec :

+ + wails init -n myproject -t vanilla + +Si vous préférez TypeScript:
+ + wails init -n myproject -t vanilla-ts + +
+
+``` + +
+ +Il y a aussi [des modèles créés par la communauté](../community/templates.mdx) qui sont disponibles et qui offrent différentes possibilités. + +Pour voir les autres options disponibles, vous pouvez exécuter `wails init -help`. Plus de détails peuvent être trouvés dans la [documentation du CLI](../reference/cli.mdx#init). + +## Structure du projet + +Les projets Wails ont la structure suivante: + +``` +. +├── build/ +│ ├── appicon.png +│ ├── darwin/ +│ └── windows/ +├── frontend/ +├── go.mod +├── go.sum +├── main.go +└── wails.json +``` + +### Récapitulatif de la structure du projet + +- `/main.go` - L'application principale +- `/frontend/` - Fichiers de la partie frontend +- `/build/` - Répertoire de construction du projet +- `/build/appicon.png` - L'icône de l'application +- `/build/darwin/` - Fichiers spécifiques pour Mac +- `/build/windows/` - Fichiers spécifiques pour Windows +- `/wails.json` - La configuration du projet +- `/go.mod` - Le fichier du module Go +- `/go.sum` - Le checksum du fichier du module Go + +Le répertoire `frontend` n'a rien de spécifique à Wails et n'importe quel outil de frontend peut être utilisé. + +Le répertoire `build` est utilisé pendant le processus de compilation. Ces fichiers peuvent être mis à jour pour personnaliser vos builds. Si fichiers sont supprimés du répertoire de compilation, les versions par défaut seront régénérées. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/installation.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/installation.mdx new file mode 100644 index 000000000..1e66a6202 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/gettingstarted/installation.mdx @@ -0,0 +1,92 @@ +--- +sidebar_position: 1 +--- + +# Installation + +## Plates-formes Prises en charge + +- Windows 10/11 AMD64/ARM64 +- MacOS 10.15+ AMD64 for development, MacOS 10.13+ for release +- MacOS 11.0+ ARM64 +- Linux AMD64/ARM64 + +## Dépendances + +Wails a un certain nombre de dépendances communes qui sont nécessaires avant l'installation : + +- Go 1.21+ (macOS 15+ requires Go 1.23.3+) +- NPM (Node 15+) + +### Go + +Télécharger Go à partir de la [Page de téléchargement](https://go.dev/dl/). + +Assurez-vous que vous suivez les instructions officielles de [l'installation de Go](https://go.dev/doc/install). Vous devrez également vous assurer que votre variable d'environnement `PATH` inclut également le chemin vers votre répertoire `~/go/bin`. Redémarrez votre terminal et effectuez les vérifications suivantes : + +- Vérifiez que Go est installé correctement : `go version` +- Vérifiez que "~/go/bin" est dans votre variable PATH : `echo $PATH | grep go/bin` + +### NPM + +Téléchargez le NPM à partir de la [page de téléchargement de Node](https://nodejs.org/en/download/). Il est préférable d'utiliser la dernière version car c'est avec celle-là que nous effectuons nos tests. + +Exécutez `npm --version` pour vérifier. + +## Dépendances spécifiques aux plateformes + +Vous devrez également installer des dépendances spécifiques liés à la plateforme que vous utilisez : + +```mdx-code-block +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + + + + Wails a besoin que les outils de command line xocde soient installés. Cela peut être fait + en exécutant xcode-select --install. + + + Wails a besoin que WebView2 runtime soit installé. Certaines installations de Windows auront déjà installé cette fonctionnalité. Vous pouvez vérifier en utilisant la commande wails doctor. + + + Linux a besoin de gcc comme outil de compilation en plus de libgtk3 et libwebkit. Plutôt que de lister une tonne de commandes pour différentes distributions, Wails peut essayer de déterminer ce que sont les commandes d'installation pour votre distribution. Exécutez wails doctor après l'installation pour voir de quelles dépendances vous avez besoin. Si votre gestionnaire de distribution/paquet n'est pas pris en charge, veuillez consulter le guide Ajouter une distribution Linux. +
Note:
+ If you are using latest Linux version (example: Ubuntu 24.04) and it is not supporting libwebkit2gtk-4.0-dev, then you might encounter an issue in wails doctor: libwebkit not found. To resolve this issue you can install libwebkit2gtk-4.1-dev and during your build use the tag -tags webkit2_41. +
+
+``` + +## Dépendances optionnelles + +- [UPX](https://upx.github.io/) pour compresser vos applications. +- [NSIS](https://wails.io/docs/guides/windows-installer/) pour générer des installateurs Windows. + +## Installer Wails + +Exécutez `go go install github.com/wailsapp/wails/v2/cmd/wails@latest` pour installer le CLI. + +Note: Si vous obtenez une erreur similaire à ceci: + +```shell +....\Go\pkg\mod\github.com\wailsapp\wails\v2@v2.1.0\pkg\templates\templates.go:28:12: pattern all:ides/*: no matching files found +``` +vérifiez que vous avez installé Go 1.18+ : +```shell +go version +``` + +## Vérification du système + +Exécuter `wails doctor` qui vérifiera si vous avez les bonnes dépendances installées. Si ce n'est pas le cas, il vous conseillera sur ce qui manque et vous aidera à corriger tout problème. + +## La commande `wails` semble manquer ? + +Si votre système signale que la commande `wails` est manquante, assurez-vous que vous avez suivi le guide d'installation correctement. Normalement, cela signifie que le répertoire `go/bin` du répertoire racine de votre utilisateur n'est pas dans la variable d'environnement `PATH` . Vous devrez également normalement fermer et réouvrir toutes les commandes ouvertes afin que les modifications apportées à l'environnement par l'installateur soient reflétées dans l'invite de commande. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/angular.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/angular.mdx new file mode 100644 index 000000000..1fe2f199f --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/angular.mdx @@ -0,0 +1,14 @@ +# Angular + +Bien que Wails n'ait pas de modèle Angular, il est possible d'utiliser Angular avec Wails. + +## Dev Mode + +Pour que le mode développeur fonctionne avec Angular, vous devez ajouter ce qui suit à votre fichier `wails.json`: + +```json + "frontend:build": "npx ng build", + "frontend:install": "npm install", + "frontend:dev:watcher": "npx ng serve", + "frontend:dev:serverUrl": "http://localhost:4200", +``` \ No newline at end of file diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/application-development.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/application-development.mdx new file mode 100644 index 000000000..7ca2ff95b --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/application-development.mdx @@ -0,0 +1,273 @@ +# Développement d'applications + +Il n'y a pas de règles gravées dans le marbre pour le développement d'applications avec Wails, mais il y a quelques lignes directrices de base. + +## Configuration de l'application + +Le modèle utilisé par défaut défini que `main.go` est utilisé pour configurer et démarrer l'application, tandis que `app.go` est utilisé pour définir la logique de l'application. + +Le fichier `app.go` va définir une structure qui a 2 méthodes qui agissent comme crochets dans l'application principale: + +```go title="app.go" +type App struct { + ctx context.Context +} + +func NewApp() *App { + return &App{} +} + +func (a *App) startup(ctx context.Context) { + a.ctx = ctx +} + +func (a *App) shutdown(ctx context.Context) { +} +``` + +- La méthode startup est appelée d-s que Wails a donné les ressources nécessaires et qu'il est dans un bon état pour créer les ressources, mettre en place les event listeners et tout ce dont l'application peut avoir besoin pour démarrer. Il est donné un `context.Context` qui est généralement sauvegardé dans un champ struct. Ce contexte est nécessaire pour appeler le [runtime](../reference/runtime/intro.mdx). Si cette méthode renvoie une erreur, l'application se fermera. En mode développement, l'erreur sera affichée dans la console. + +- La méthode d'arrêt sera appelée par Wails à la fin du processus d'arrêt. C'est un bon endroit pour vider la mémoire et effectuer toutes les tâches d'arrêt. + +Le fichier `main.go` consiste généralement en un seul appel à `wails.Run()`, qui accepte la configuration de l'application. Le modèle utilisé par les templates fait qu'avant l'appel à `wails.Run()`, une instance du struct que l'on a définie dans `app.go` est créée et instanciée dans une variable appelée `app`. Cette configuration est l'endroit où nous ajoutons nos callbacks : + +```go {3,9,10} title="main.go" +func main() { + + app := NewApp() + + err := wails.Run(&options.App{ + Title: "My App", + Width: 800, + Height: 600, + OnStartup: app.startup, + OnShutdown: app.shutdown, + }) + if err != nil { + log.Fatal(err) + } +} + +``` + +Plus d'informations sur les crochets du cycle de vie des applications peuvent être trouvées [ici](../howdoesitwork.mdx#application-lifecycle-callbacks). + +## Méthodes de liaison + +Il est probable que vous vouliez appeler les méthodes Go depuis le frontend. Cela se fait normalement en ajoutant des méthodes publiques à le struct déjà défini dans `app.go`: + +```go {16-18} title="app.go" +type App struct { + ctx context.Context +} + +func NewApp() *App { + return &App{} +} + +func (a *App) startup(ctx context.Context) { + a.ctx = ctx +} + +func (a *App) shutdown(ctx context.Context) { +} + +func (a *App) Greet(name string) string { + return fmt.Sprintf("Hello %s!", name) +} +``` + +Dans la configuration principale de l'application, le paramètre `Bind` est l'endroit où nous pouvons dire à Wails ce que nous voulons lier : + +```go {11-13} title="main.go" +func main() { + + app := NewApp() + + err := wails.Run(&options.App{ + Title: "My App", + Width: 800, + Height: 600, + OnStartup: app.startup, + OnShutdown: app.shutdown, + Bind: []interface{}{ + app, + }, + }) + if err != nil { + log.Fatal(err) + } +} + +``` + +Cela liera toutes les méthodes publiques de notre structure `App` (cela ne liera jamais les méthodes de démarrage et d'arrêt du système). + +### Traiter avec le contexte lors de la liaison de plusieurs structures + +Si vous voulez lier des méthodes pour des structures multiples, mais que vous voulez que chaque struct conserve une référence au contexte pour que vous puissiez utiliser les fonctions d'exécution... Un bon choix est de passer le contexte de la méthode `OnStartup` à vos instances struct : + +```go +func main() { + + app := NewApp() + otherStruct := NewOtherStruct() + + err := wails.Run(&options.App{ + Title: "My App", + Width: 800, + Height: 600, + OnStartup: func(ctx context.Context){ + app.SetContext(ctx) + otherStruct.SetContext(ctx) + }, + OnShutdown: app.shutdown, + Bind: []interface{}{ + app, + otherStruct + }, + }) + if err != nil { + log.Fatal(err) + } +} +``` + +Also you might want to use Enums in your structs and have models for them on frontend. In that case you should create array that will contain all possible enum values, instrument enum type and bind it to the app: + +```go {16-18} title="app.go" +type Weekday string + +const ( + Sunday Weekday = "Sunday" + Monday Weekday = "Monday" + Tuesday Weekday = "Tuesday" + Wednesday Weekday = "Wednesday" + Thursday Weekday = "Thursday" + Friday Weekday = "Friday" + Saturday Weekday = "Saturday" +) + +var AllWeekdays = []struct { + Value Weekday + TSName string +}{ + {Sunday, "SUNDAY"}, + {Monday, "MONDAY"}, + {Tuesday, "TUESDAY"}, + {Wednesday, "WEDNESDAY"}, + {Thursday, "THURSDAY"}, + {Friday, "FRIDAY"}, + {Saturday, "SATURDAY"}, +} +``` + +In the main application configuration, the `EnumBind` key is where we can tell Wails what we want to bind enums as well: + +```go {11-13} title="main.go" +func main() { + + app := NewApp() + + err := wails.Run(&options.App{ + Title: "My App", + Width: 800, + Height: 600, + OnStartup: app.startup, + OnShutdown: app.shutdown, + Bind: []interface{}{ + app, + }, + EnumBind: []interface{}{ + AllWeekdays, + }, + }) + if err != nil { + log.Fatal(err) + } +} + +``` + +This will add missing enums to your `model.ts` file. + +Plus d'informations à sur Binding peuvent être trouvées [ici](../howdoesitwork.mdx#method-binding). + +## Menu de l’application + +Wails prend en charge l'ajout d'un menu à votre application. Ceci est fait en passant un [Menu](../reference/menus.mdx#menu) structuré à la configuration de l'application. Il est courant d'utiliser une méthode qui renvoie un Menu, et encore plus courant pour que cela soit une méthode sur la struct de l'`app` qui soit utilisée pour les hooks du cycle de vie. + +```go {11} title="main.go" +func main() { + + app := NewApp() + + err := wails.Run(&options.App{ + Title: "My App", + Width: 800, + Height: 600, + OnStartup: app.startup, + OnShutdown: app.shutdown, + Menu: app.menu(), + Bind: []interface{}{ + app, + }, + }) + if err != nil { + log.Fatal(err) + } +} + +``` + +## Ressources + +La grande chose à propos de la façon dont Wails v2 gère les ressources pour le frontend, est que ce n'est pas le cas! La seule chose que vous devez donner à Wails est un `embed.FS`. C'est à vous de décider comment vous y arrivez. Vous pouvez utiliser les fichiers html/css/js vanilla comme dans le modèle vanilla. Vous pourriez avoir un système de compilation compliqué, peu importe. + +Quand la commande `wails dev` est exécutée, elle vérifiera le fichier de projet `wails.json` à la racine du projet. Il y a 2 clés dans le fichier du projet qui sont lues : + +- "frontend:install" +- "frontend:build" + +Le premier, si fourni, sera exécuté dans le répertoire `frontend` pour installer les modules. Le second, si fourni, sera exécuté dans le répertoire `frontend` pour construire le projet frontend. + +Si ces 2 clés ne sont pas fournies, alors Wails ne fait absolument rien avec le frontend. Il n'attend que `embed.FS`. + +### AssetsHandler + +Une application Wails v2 peut éventuellement définir un `http.Handler` dans `options.app`, qui permet de se connecter à l'AssetServer pour créer des fichiers à la volée ou traiter les requêtes POST/PUT. Les requêtes GET sont toujours traitées d'abord par le `assets` FS. Si le FS ne trouve pas le fichier demandé, la requête sera transmise au `http.Handler`. Toute requête autre que GET sera traitée directement par le `AssetsHandler` si spécifié. It's also possible to only use the `AssetsHandler` by specifying `nil` as the `Assets` option. + +## Serveur de développement embarqué + +Exécuter `wails dev` démarrera le serveur de développement intégré qui démarrera un observateur de fichiers dans votre répertoire de projet. Par par défaut, si un fichier change, wails vérifie s'il s'agit d'un fichier d'application (par défaut: `.go`, configurable avec l'option `-e`). Si c'est le cas, il reconstruira votre application et la relancera. Si le fichier modifié se trouvait dans les actifs, il lancera un rechargement après un court laps de temps. + +Le serveur de développement utilise une technique appelée "debouncing", ce qui signifie qu'il ne se recharge pas tout de suite, comme il peut y avoir plusieurs fichiers modifiés en un court laps de temps. Lorsqu'un déclencheur se produit, il attend un temps défini avant d'émettre un rechargement. Si un autre déclencheur se produit, le temps d'attente se réinitialise avant un prochain rechargement. Par défaut, cette période est définie à `100ms`. Si cette valeur ne fonctionne pas pour votre projet, elle peut être configurée en utilisant l'option `-debounce`. Si elle est utilisée, cette valeur sera enregistrée dans la configuration de votre projet et deviendra la valeur par défaut. + +## Serveur de développement externe + +Certains frameworks sont fournis avec leur propre serveur de rechargement en direct, cependant ils ne seront pas en mesure de tirer parti des liaisons Wails Go. Dans ce scénario, il est préférable d'exécuter un script qui va surveiller le projet dans dossier build, dossier que Wails surveille aussi. Pour un exemple, voir le modèle svelte par défaut qui utilise [rollup](https://rollupjs.org/guide/en/). + +### Créer une application React + +Le processus pour créer un projet Reactest un peu plus compliqué. Afin de prendre en charge le rechargement du frontend en direct, la configuration suivante doit être ajoutée à votre `wails.json`: + +```json + "frontend:dev:watcher": "yarn start", + "frontend:dev:serverUrl": "http://localhost:3000", +``` + +La commande `frontend:dev:watcher` démarrera le serveur de développement React (hébergé sur le port `3000` typiquement). La commande `frontend:dev:serverUrl` demande ensuite à Wails d'exposer les ressources depuis le serveur de développement lors du chargement du frontend, plutôt que depuis le dossier de construction. En plus de ce qui précède, le fichier `index.html` doit être mis à jour avec les éléments suivants : + +```html + + + + + +``` + +Ceci est nécessaire, car la commande watcher qui reconstruit le frontend empêche Wails de les injecter. Ça contourne le problème en assurant les scripts sont toujours injectés. Avec cette configuration, `wails dev` peut être exécuté, ce qui construira le frontend et le backend de manière appropriée avec le rechargement à chaud activé. De plus, lorsque vous accédez à l'application à partir d'un navigateur, les outils de développement de React peuvent maintenant être utilisés sur une version non minifiée de l'application pour le débogage. Enfin, pour des compilations plus rapides, `wails dev -s` peut être exécuté pour passer la construction par défaut du frontend par Wails car c'est une étape inutile. + +## Module Go + +Les modèles Wails par défaut génèrent un fichier `go.mod` qui contient le nom de module "changeme". Vous devriez changer ceci pour quelque chose de plus approprié après la génération du projet. diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/crossplatform-build.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/crossplatform-build.mdx new file mode 100644 index 000000000..7cacec2cc --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/crossplatform-build.mdx @@ -0,0 +1,66 @@ +# Construction cross-plateforme avec Github Actions + +Pour construire un projet Wails pour toutes les plateformes disponibles, vous devez créer un build de l'application pour chaque système d'exploitation. Une méthode efficace pour y parvenir est d'utiliser GitHub Actions. + +Une action qui facilite la création d'une application Wails est disponible sur : +https://github.com/dAppServer/wails-build-action + +Dans le cas où l'action existante ne répond pas à vos exigences, vous ne pouvez sélectionner que les étapes nécessaires à partir de la source : +https://github.com/dAppServer/wails-build-action/blob/main/action.yml + +Voici un exemple complet qui démontre la construction d'une application lors de la création d'une nouvelle balise Git et qui la téléversera ensuite sur les artefacts Actions : + +```yaml +name: Wails build + +on: + push: + tags: + # Matche n'importe quel nouveau tag + - '*' + +env: + # Nécessaire pour la plupart des environnement, car des soucis de build peuvent arriver à cause de soucis de mémoire + NODE_OPTIONS: "--max-old-space-size=4096" + +jobs: + build: + strategy: + # Afin d'éviter que l'échec du build d'une plateforme n'impacte les autres + fail-fast: false + matrix: + build: + - name: 'App' + platform: 'linux/amd64' + os: 'ubuntu-latest' + - name: 'App' + platform: 'windows/amd64' + os: 'windows-latest' + - name: 'App' + platform: 'darwin/universal' + os: 'macos-latest' + + runs-on: ${{ matrix.build.os }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Build wails + uses: dAppServer/wails-build-action@v2.2 + id: build + with: + build-name: ${{ matrix.build.name }} + build-platform: ${{ matrix.build.platform }} + package: false + go-version: '1.20' +``` + +Cet exemple offre des opportunités pour diverses améliorations, comprenant : + +- Mise en cache des dépendances +- Signature de code +- Uploading to platforms like S3, Supabase, etc. +- Injection de secrets en tant que variables d'environnement +- Utiliser des variables d'environnement comme variables de compilation (telles que la variable de version extraite de la balise Git actuelle) diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/custom-protocol-schemes.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/custom-protocol-schemes.mdx new file mode 100644 index 000000000..e4cd373ae --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/custom-protocol-schemes.mdx @@ -0,0 +1,204 @@ +# Custom Protocol Scheme association + +Custom Protocols feature allows you to associate specific custom protocol with your app so that when users open links with this protocol, +your app is launched to handle them. This can be particularly useful to connect your desktop app with your web app. +In this guide, we'll walk through the steps to implement custom protocols in Wails app. + +## Set Up Custom Protocol Schemes Association: + +To set up custom protocol, you need to modify your application's wails.json file. +In "info" section add a "protocols" section specifying the protocols your app should be associated with. + +For example: + +```json +{ + "info": { + "protocols": [ + { + "scheme": "myapp", + "description": "My App Protocol", + "role": "Editor" + } + ] + } +} +``` + +| Propriété | Description | +| :----------- | :------------------------------------------------------------------------------------------ | +| scheme | Custom Protocol scheme. e.g. myapp | +| description | Windows seulement. La description. | +| role | macOS uniquement. The app’s role with respect to the type. Corresponds to CFBundleTypeRole. | + +## Spécificités par platefome : + +### MacOS + +When you open custom protocol with your app, the system will launch your app and call the `OnUrlOpen` function in your Wails app. Example: + +```go title="main.go" +func main() { + // Create application with options + err := wails.Run(&options.App{ + Title: "wails-open-file", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, + Mac: &mac.Options{ + OnUrlOpen: func(url string) { println(url) }, + }, + Bind: []interface{}{ + app, + }, + }) + + if err != nil { + println("Error:", err.Error()) + } +} +``` + +### Windows + +On Windows Custom Protocol Schemes is supported only with NSIS installer. During installation, the installer will create a +registry entry for your schemes. When you open url with your app, new instance of app is launched and url is passed +as argument to your app. To handle this you should parse command line arguments in your app. Example: + +```go title="main.go" +func main() { + argsWithoutProg := os.Args[1:] + + if len(argsWithoutProg) != 0 { + println("launchArgs", argsWithoutProg) + } +} +``` + +You also can enable single instance lock for your app. In this case, when you open url with your app, new instance of app is not launched +and arguments are passed to already running instance. Check single instance lock guide for details. Example: + +```go title="main.go" +func main() { + // Create application with options + err := wails.Run(&options.App{ + Title: "wails-open-file", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, + SingleInstanceLock: &options.SingleInstanceLock{ + UniqueId: "e3984e08-28dc-4e3d-b70a-45e961589cdc", + OnSecondInstanceLaunch: app.onSecondInstanceLaunch, + }, + Bind: []interface{}{ + app, + }, + }) +} +``` + +### Linux + +Currently, Wails doesn't support bundling for Linux. So, you need to create file associations manually. +For example if you distribute your app as a .deb package, you can create file associations by adding required files in you bundle. +You can use [nfpm](https://nfpm.goreleaser.com/) to create .deb package for your app. + +1. Create a .desktop file for your app and specify file associations there (note that `%u` is important in Exec). Example: + +```ini +[Desktop Entry] +Categories=Office +Exec=/usr/bin/wails-open-file %u +Icon=wails-open-file.png +Name=wails-open-file +Terminal=false +Type=Application +MimeType=x-scheme-handler/myapp; +``` + +2. Prepare postInstall/postRemove scripts for your package. Example: + +```sh +# reload desktop database to load app in list of available +update-desktop-database /usr/share/applications +``` + +3. Configure nfpm to use your scripts and files. Example: + +```yaml +name: "wails-open-file" +arch: "arm64" +platform: "linux" +version: "1.0.0" +section: "default" +priority: "extra" +maintainer: "FooBarCorp " +description: "Sample Package" +vendor: "FooBarCorp" +homepage: "http://example.com" +license: "MIT" +contents: +- src: ../bin/wails-open-file + dst: /usr/bin/wails-open-file +- src: ./main.desktop + dst: /usr/share/applications/wails-open-file.desktop +- src: ../appicon.svg + dst: /usr/share/icons/hicolor/scalable/apps/wails-open-file.svg +# copy icons to Yaru theme as well. For some reason Ubuntu didn't pick up fileicons from hicolor theme +- src: ../appicon.svg + dst: /usr/share/icons/Yaru/scalable/apps/wails-open-file.svg +scripts: + postinstall: ./postInstall.sh + postremove: ./postRemove.sh +``` + +6. Build your .deb package using nfpm: + +```sh +nfpm pkg --packager deb --target . +``` + +7. Now when your package is installed, your app will be associated with custom protocol scheme. When you open url with your app, + new instance of app is launched and file path is passed as argument to your app. + To handle this you should parse command line arguments in your app. Example: + +```go title="main.go" +func main() { + argsWithoutProg := os.Args[1:] + + if len(argsWithoutProg) != 0 { + println("launchArgs", argsWithoutProg) + } +} +``` + +You also can enable single instance lock for your app. In this case, when you open url with your app, new instance of app is not launched +and arguments are passed to already running instance. Check single instance lock guide for details. Example: + +```go title="main.go" +func main() { + // Create application with options + err := wails.Run(&options.App{ + Title: "wails-open-file", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, + SingleInstanceLock: &options.SingleInstanceLock{ + UniqueId: "e3984e08-28dc-4e3d-b70a-45e961589cdc", + OnSecondInstanceLaunch: app.onSecondInstanceLaunch, + }, + Bind: []interface{}{ + app, + }, + }) +} +``` diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/dynamic-assets.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/dynamic-assets.mdx new file mode 100644 index 000000000..14a2ebe5b --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/dynamic-assets.mdx @@ -0,0 +1,142 @@ +# Ressources dynamiques + +:::info + +This does not work with vite v5.0.0+ and wails v2 due to changes in vite. Changes are planned in v3 to support similar functionality under vite v5.0.0+. If you need this feature, stay with vite v4.0.0+. See [issue 3240](https://github.com/wailsapp/wails/issues/3240) for details + +::: + +Si vous voulez charger ou générer des ressources pour votre frontend de manière dynamique, vous pouvez y parvenir en utilisant l'option [AssetsHandler](../reference/options#assetshandler). Le AssetsHandler est un générique`http.Handler` qui sera appelé pour toute requête non GET sur le serveur d'assets et pour les requêtes GET qui ne peuvent pas être servies car l'asset n'est pas trouvé. + +En installant un AssetsHandler personnalisé, vous pouvez servir vos propres ressources en utilisant un serveur de ressources personnalisé. + +## Exemple + +Dans notre exemple de projet, nous allons créer un gestionnaire de ressources simple qui chargera les fichiers à partir du disque: + +```go title=main.go {17-36,49} +package main + +import ( + "embed" + "fmt" + "github.com/wailsapp/wails/v2" + "github.com/wailsapp/wails/v2/pkg/options" + "github.com/wailsapp/wails/v2/pkg/options/assetserver" + "net/http" + "os" + "strings" +) + +//go:embed all:frontend/dist +var assets embed.FS + +type FileLoader struct { + http.Handler +} + +func NewFileLoader() *FileLoader { + return &FileLoader{} +} + +func (h *FileLoader) ServeHTTP(res http.ResponseWriter, req *http.Request) { + var err error + requestedFilename := strings.TrimPrefix(req.URL.Path, "/") + println("Requesting file:", requestedFilename) + fileData, err := os.ReadFile(requestedFilename) + if err != nil { + res.WriteHeader(http.StatusBadRequest) + res.Write([]byte(fmt.Sprintf("Could not load file %s", requestedFilename))) + } + + res.Write(fileData) +} + +func main() { + // Create an instance of the app structure + app := NewApp() + + // Create application with options + err := wails.Run(&options.App{ + Title: "helloworld", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + Handler: NewFileLoader(), + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 255}, + OnStartup: app.startup, + Bind: []interface{}{ + app, + }, + }) + + if err != nil { + println("Error:", err) + } +} +``` + +Lorsque nous exécutons l'application en mode dev en utilisant `wails dev`, nous verrons la sortie suivante : + +``` +DEB | [ExternalAssetHandler] Loading 'http://localhost:3001/favicon.ico' +DEB | [ExternalAssetHandler] Loading 'http://localhost:3001/favicon.ico' failed, using AssetHandler +Requesting file: favicon.ico +``` + +Comme vous pouvez le voir, le gestionnaire d'actifs est appelé lorsque le serveur d'assets par défaut est incapable de servir le fichier `favicon.ico`. + +Si vous faites un clic droit sur l'application principale et sélectionnez "inspecter" pour afficher les devtools, vous pouvez tester cette fonctionnalité en tapant ce qui suit dans la console : + +``` +let response = await fetch('does-not-exist.txt'); +``` + +Cela générera une erreur dans les devtools. Nous pouvons voir que l'erreur est ce que nous attendons est retourné par notre gestionnaire de ressources personnalisées : + +```mdx-code-block +

+ +

+``` + +Cependant, si nous demandons `go.mod`, nous verrons la sortie suivante : + +```mdx-code-block +

+ +

+``` + +Cette technique peut être utilisée pour charger des images directement dans la page. Si nous avons mis à jour notre modèle vanilla par défaut et a remplacé l'image du logo : + +```html + +``` + +avec : + +```html + +``` + +Nous verrions ensuite ce qui suit: + +```mdx-code-block +

+ +

+``` + +:::warning + +Exposer votre système de fichiers de cette manière est un risque de sécurité. Il est recommandé de gérer correctement l'accès à votre système de fichiers. + +::: diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/file-association.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/file-association.mdx new file mode 100644 index 000000000..973a4d217 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/file-association.mdx @@ -0,0 +1,243 @@ +# Associations de fichiers + +La fonction d'association de fichiers vous permet d'associer des types de fichiers spécifiques à votre application afin que lorsque les utilisateurs ouvrent ces fichiers, +votre application est lancée pour les gérer. Cela peut être particulièrement utile pour les éditeurs de texte, les visualisateurs d'images ou n'importe quelle application +qui fonctionne avec des formats de fichiers spécifiques. Dans ce guide, nous allons parcourir les étapes pour implémenter l'association de fichiers dans l'application Wails. + +## Configurer l'association de fichiers : + +Pour configurer l'association de fichiers, vous devez modifier le fichier wails.json de votre application. +Dans la section "info", ajoutez une section "fileAssociations" spécifiant les types de fichiers auxquels votre application doit être associée. + +Par exemple : + +```json +{ + "info": { + "fileAssociations": [ + { + "ext": "wails", + "name": "Wails", + "description": "Wails Application File", + "iconName": "wailsFileIcon", + "role": "Editor" + }, + { + "ext": "jpg", + "name": "JPEG", + "description": "Image File", + "iconName": "jpegFileIcon", + "role": "Editor" + } + ] + } +} +``` + +| Propriété | Description | +| :----------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ext | L'extension. ex: png | +| name | Le nom de l'extension. ex: PNG File | +| iconName | Le nom de l'icône sans extension. Les icônes doivent être situées dans le dossier de build. Des icônes appropriées seront générées à partir du fichier .png pour macOS et Windows | +| description | Windows seulement. La description. Il est affiché dans la colonne `Type` dans l'explorateur Windows. | +| role | macOS uniquement. Rôle de l'application par rapport au type. Correspond au rôle CFBundleTypeRole. | + +## Spécificités par platefome : + +### MacOS + +Lorsque vous ouvrez un fichier (ou des fichiers) avec votre application, le système lancera votre application et appellera la fonction `OnFileOpen` dans votre application Wails. Exemple: + +```go title="main.go" +func main() { + // Création d'une application avec des options + err := wails.Run(&options.App{ + Title: "wails-open-file", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, + Mac: &mac.Options{ + OnFileOpen: func(filePaths []string) { println(filestring) }, + }, + Bind: []interface{}{ + app, + }, + }) + + if err != nil { + println("Error:", err.Error()) + } +} +``` + +### Windows + +L'association de fichiers dans Windows n'est prise en charge qu'avec l'installateur NSS. Pendant l'installation, l'installateur créera une entrée de registre +pour vos associations de fichiers. Lorsque vous ouvrez un fichier avec votre application, une nouvelle instance d'application est lancée et le chemin d'accès est passé à +comme argument à votre application. Pour gérer cela, vous devez analyser les arguments de la ligne de commande dans votre application. Exemple: + +```go title="main.go" +func main() { + argsWithoutProg := os.Args[1:] + + if len(argsWithoutProg) != 0 { + println("launchArgs", argsWithoutProg) + } +} +``` + +Vous pouvez également activer le verrouillage par instance unique pour votre application. Dans ce cas, lorsque vous ouvrez un fichier avec votre application, la nouvelle instance d'application n'est pas lancée +et les arguments sont passés à l'instance déjà en cours d'exécution. Consultez le guide de verrouillage de l'instance unique pour plus de détails. Exemple: + +```go title="main.go" +func main() { + // Création d'une application avec des options + err := wails.Run(&options.App{ + Title: "wails-open-file", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, + SingleInstanceLock: &options.SingleInstanceLock{ + UniqueId: "e3984e08-28dc-4e3d-b70a-45e961589cdc", + OnSecondInstanceLaunch: app.onSecondInstanceLaunch, + }, + Bind: []interface{}{ + app, + }, + }) +} +``` + +### Linux + +Actuellement, Wails ne prend pas en charge l'association de fichiers pour Linux. Vous devez donc créer des associations de fichiers manuellement. +Par exemple, si vous distribuez votre application en tant que package .deb, vous pouvez créer des associations de fichiers en ajoutant les fichiers requis dans votre bundle. +Vous pouvez utiliser [nfpm](https://nfpm.goreleaser.com/) pour créer un package .deb pour votre application. + +1. Créez un fichier .desktop pour votre application et spécifiez des associations de fichiers là-bas. Exemple: + +```ini +[Desktop Entry] +Categories=Office +Exec=/usr/bin/wails-open-file %u +Icon=wails-open-file.png +Name=wails-open-file +Terminal=false +Type=Application +MimeType=application/x-wails;application/x-test +``` + +2. Créer un fichier de type MIME. Exemple: + +```xml + + + + Wails Application File + + + +``` + +3. Créez des icônes pour vos types de fichiers. Les icônes SVG sont recommandées. +4. Préparez les scripts postInstall/postRemove pour votre paquet. Exemple: + +```sh +# Recharge les types MIME pour enregistrer votre association de fichiers +update-mime-database /usr/share/mime +# Recharge la base de données du bureau afin de rendre disponible votre application dans les choix possibles +update-desktop-database /usr/share/applications +# Mise à jour des icônes +update-icon-caches /usr/share/icons/* +``` + +5. Configurez nfpm pour utiliser vos scripts et fichiers. Exemple: + +```yaml +name: "wails-open-file" +arch: "arm64" +platform: "linux" +version: "1.0.0" +section: "default" +priority: "extra" +maintainer: "FooBarCorp " +description: "Sample Package" +vendor: "FooBarCorp" +homepage: "http://example.com" +license: "MIT" +contents: +- src: ../bin/wails-open-file + dst: /usr/bin/wails-open-file +- src: ./main.desktop + dst: /usr/share/applications/wails-open-file.desktop +- src: ./application-wails-mime.xml + dst: /usr/share/mime/packages/application-x-wails.xml +- src: ./application-test-mime.xml + dst: /usr/share/mime/packages/application-x-test.xml +- src: ../appicon.svg + dst: /usr/share/icons/hicolor/scalable/apps/wails-open-file.svg +- src: ../wailsFileIcon.svg + dst: /usr/share/icons/hicolor/scalable/mimetypes/application-x-wails.svg +- src: ../testFileIcon.svg + dst: /usr/share/icons/hicolor/scalable/mimetypes/application-x-test.svg +# copy icons to Yaru theme as well. For some reason Ubuntu didn't pick up fileicons from hicolor theme +- src: ../appicon.svg + dst: /usr/share/icons/Yaru/scalable/apps/wails-open-file.svg +- src: ../wailsFileIcon.svg + dst: /usr/share/icons/Yaru/scalable/mimetypes/application-x-wails.svg +- src: ../testFileIcon.svg + dst: /usr/share/icons/Yaru/scalable/mimetypes/application-x-test.svg +scripts: + postinstall: ./postInstall.sh + postremove: ./postRemove.sh +``` + +6. Construisez votre paquet .deb en utilisant nfpm: + +```sh +nfpm pkg --packager deb --target . +``` + +7. Maintenant que votre paquet est installé, votre application sera associée aux types de fichiers qui ont été spécifiés. Lorsque vous ouvrez un fichier avec votre application, une nouvelle instance est lancée et le chemin du fichier est passé en argument à votre application. + Pour gérer cela, vous devez analyser les arguments de la ligne de commande dans votre application. Exemple: + +```go title="main.go" +func main() { + argsWithoutProg := os.Args[1:] + + if len(argsWithoutProg) != 0 { + println("launchArgs", argsWithoutProg) + } +} +``` + +Vous pouvez également activer le verrouillage par instance unique pour votre application. Dans ce cas, lorsque vous ouvrez un fichier avec votre application, la nouvelle instance d'application n'est pas lancée +et les arguments sont passés à l'instance déjà en cours d'exécution. Consultez le guide de verrouillage de l'instance unique pour plus de détails. Exemple: + +```go title="main.go" +func main() { + // Création d'une application avec des options + err := wails.Run(&options.App{ + Title: "wails-open-file", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, + SingleInstanceLock: &options.SingleInstanceLock{ + UniqueId: "e3984e08-28dc-4e3d-b70a-45e961589cdc", + OnSecondInstanceLaunch: app.onSecondInstanceLaunch, + }, + Bind: []interface{}{ + app, + }, + }) +} +``` diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/frameless.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/frameless.mdx new file mode 100644 index 000000000..bbeb338f1 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/frameless.mdx @@ -0,0 +1,87 @@ +# Applications sans cadre + +Wails prend en charge la création d'applications qui n'ont pas de cadres. Ceci peut être réalisé en utilisant le champ [frameless](../reference/options.mdx#frameless) dans [Application Options](../reference/options.mdx#application-options). + +Wails offre une solution simple pour faire glisser la fenêtre: N'importe quel élément HTML qui a le style CSS `--wails-draggable:drag` agira comme une "poignée de glisser". Cette propriété s'applique à tous les éléments enfants. Si vous devez indiquer qu'un élément imbriqué ne doit pas glisser, alors utilisez l'attribut '--wails-draggable:no-drag' sur cet élément. + +```html + + + + + + + +
+ + +
+
+ + + + +``` + +Pour certains projets, l'utilisation d'une variable CSS peut ne pas être possible en raison du style dynamique. Dans ce cas, vous pouvez utiliser les options `CSSDragProperty` et `CSSDragValue` pour définir une propriété et une valeur qui seront utilisées pour indiquer régions glissables : + +```go title=main.go +package main + +import ( + "embed" + + "github.com/wailsapp/wails/v2" + "github.com/wailsapp/wails/v2/pkg/options" + "github.com/wailsapp/wails/v2/pkg/options/assetserver" +) + +//go:embed all:frontend/dist +var assets embed.FS + +func main() { + // Create an instance of the app structure + app := NewApp() + + // Create application with options + err := wails.Run(&options.App{ + Title: "alwaysontop", + Width: 1024, + Height: 768, + AssetServer: &assetserver.Options{ + Assets: assets, + }, + Frameless: true, + CSSDragProperty: "widows", + CSSDragValue: "1", + Bind: []interface{}{ + app, + }, + }) + + if err != nil { + println("Error:", err) + } +} +``` + +```html title=index.html + + + + + + alwaysontop + + +
+ + + +``` + +:::info Plein écran + +Si vous autorisez votre application à être en plein écran, cette fonctionnalité de glissement sera désactivée. + +::: diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/frontend.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/frontend.mdx new file mode 100644 index 000000000..ef0dbed76 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/frontend.mdx @@ -0,0 +1,72 @@ +# Frontend + +## Injection de script + +Quand Wails sert votre fichier `index.html`, par défaut, il injectera 2 entrées de script dans la balise `` pour charger `/wails/ipc.js` et `/wails/runtime.js`. Ces fichiers installent respectivement les bindings et les runtime. + +Le code ci-dessous montre où ils sont injectés par défaut : + +```html + + + injection example + + + + + + + +
Please enter your name below 👇
+
+ + +
+ + + + +``` + +### Remplacer l'injection de script par défaut + +Pour fournir plus de flexibilité aux développeurs, il y a une balise meta qui peut être utilisée pour personnaliser ce comportement: + +```html + +``` + +Les options sont les suivantes : + +| Valeur | Description | +| ------------------- | -------------------------------------------------------------- | +| noautoinjectruntime | Pour désactiver l'injection automatique de `/wails/runtime.js` | +| noautoinjectipc | Pour désactiver l'injection automatique de `/wails/ipc.js` | +| noautoinject | Pour désactiver l'injection automatique de tous les scripts | + +Multiple options may be used provided they are comma separated. + +Ce code est parfaitement valide et fonctionne de la même manière que la version avec l'auto-injection : + +```html + + + injection example + + + + + + +
Please enter your name below 👇
+
+ + +
+ + + + + + +``` diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/ides.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/ides.mdx new file mode 100644 index 000000000..bd732e283 --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/ides.mdx @@ -0,0 +1,127 @@ +# IDEs + +Wails vise à fournir une grande expérience de développement. À cet effet, nous supportons maintenant la génération d'une configuration spécifique IDE pour fournir une configuration plus souple du projet. + +Currently, we support [Visual Studio Code](https://code.visualstudio.com/) and [Goland](https://www.jetbrains.com/go/). + +## Visual Studio Code + +```mdx-code-block +

+ +

+``` + +Lors de la génération d'un projet en utilisant l'option `-ide vscode` , les fichiers IDE seront créés à côté des autres fichiers du projet. Ces fichiers sont placés dans le répertoire `.vscode` et fournissent la configuration correcte pour déboguer votre application. + +Les 2 fichiers générés sont `tasks.json` et `launch.json`. Ci-dessous se trouvent les fichiers générés par défaut : + +```json title="tasks.json" +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "type": "shell", + "options": { + "cwd": "${workspaceFolder}" + }, + "command": "go", + "args": [ + "build", + "-tags", + "dev", + "-gcflags", + "all=-N -l", + "-o", + "build/bin/myproject.exe" + ] + } + ] +} +``` + +```json title="launch.json" +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Wails: Debug myproject", + "type": "go", + "request": "launch", + "mode": "exec", + "program": "${workspaceFolder}/build/bin/myproject.exe", + "preLaunchTask": "build", + "cwd": "${workspaceFolder}", + "env": {} + } + ] +} +``` + +### Configuration des étapes d'installation et de construction + +Le fichier `tasks.json` est simple pour le projet par défaut car il n'y a pas d'étapes `npm install` ou `npm build` nécessaire. Pour les projets qui ont une étape de construction en frontend comme avec Svelte, nous devrions modifier `tasks.json` pour ajouter les étapes d'installation et de construction suivantes : + +```json title="tasks.json" +{ + "version": "2.0.0", + "tasks": [ + { + "label": "npm install", + "type": "npm", + "script": "install", + "options": { + "cwd": "${workspaceFolder}/frontend" + }, + "presentation": { + "clear": true, + "panel": "shared", + "showReuseMessage": false + }, + "problemMatcher": [] + }, + { + "label": "npm run build", + "type": "npm", + "script": "build", + "options": { + "cwd": "${workspaceFolder}/frontend" + }, + "presentation": { + "clear": true, + "panel": "shared", + "showReuseMessage": false + }, + "problemMatcher": [] + }, + { + "label": "build", + "type": "shell", + "options": { + "cwd": "${workspaceFolder}" + }, + "command": "go", + "args": [ + "build", + "-tags", + "dev", + "-gcflags", + "all=-N -l", + "-o", + "build/bin/vscode.exe" + ], + "dependsOn": ["npm install", "npm run build"] + } + ] +} +``` + +:::info Améliorations futures + +Dans le futur, nous espérons générer un `tasks.json` qui inclut les étapes d'installation et de construction automatiquement. + +::: diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/linux-distro-support.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/linux-distro-support.mdx new file mode 100644 index 000000000..6bd2002fc --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/linux-distro-support.mdx @@ -0,0 +1,103 @@ +# Prise en charge des distributions Linux + +## Vue d'ensemble + +Wails offre le support de Linux, mais fournir des instructions d'installation pour toutes les distributions disponibles est une tâche impossible. À la place, Wails essaie de déterminer si les paquets dont vous avez besoin pour développer des applications sont disponibles via le gestionnaire de paquets de votre système. Actuellement, nous supportons les gestionnaires de paquets suivants : + +- apt +- dnf +- emerge +- eopkg +- nixpkgs +- pacman +- zypper + +## Ajout des noms de paquets + +Il peut y avoir des cas où votre distribution de linux utilise un des gestionnaires de paquets pris en charge mais le nom du paquet est différent. Par exemple, vous pouvez utiliser un dérivé Ubuntu, mais le nom du paquet pour gtk peut être différent. Wails tente de trouver le paquet correct en itérant une liste de noms de paquets. La liste des paquets est stockée dans un fichier spécifique dans le dossier `v2/internal/system/packagemanager` . Dans notre exemple, ce serait `v2/internal/system/packagemanager/apt.go`. + +Dans ce fichier, la liste des paquets est définie par la méthode `Packages()`: + +```go +func (a *Apt) Packages() packagemap { + return packagemap{ + "libgtk-3": []*Package{ + {Name: "libgtk-3-dev", SystemPackage: true, Library: true}, + }, + "libwebkit": []*Package{ + {Name: "libwebkit2gtk-4.0-dev", SystemPackage: true, Library: true}, + }, + "gcc": []*Package{ + {Name: "build-essential", SystemPackage: true}, + }, + "pkg-config": []*Package{ + {Name: "pkg-config", SystemPackage: true}, + }, + "npm": []*Package{ + {Name: "npm", SystemPackage: true}, + }, + "docker": []*Package{ + {Name: "docker.io", SystemPackage: true, Optional: true}, + }, + } +} +``` + +Supposons que dans notre distribution linux, `libgtk-3` est empaqueté sous le nom `lib-gtk3-dev`. Nous pourrions ajouter le support de ce paquet en ajoutant la ligne suivante : + +```go {5} +func (a *Apt) Packages() packagemap { + return packagemap{ + "libgtk-3": []*Package{ + {Name: "libgtk-3-dev", SystemPackage: true, Library: true}, + {Name: "lib-gtk3-dev", SystemPackage: true, Library: true}, + }, + "libwebkit": []*Package{ + {Name: "libwebkit2gtk-4.0-dev", SystemPackage: true, Library: true}, + }, + "gcc": []*Package{ + {Name: "build-essential", SystemPackage: true}, + }, + "pkg-config": []*Package{ + {Name: "pkg-config", SystemPackage: true}, + }, + "npm": []*Package{ + {Name: "npm", SystemPackage: true}, + }, + "docker": []*Package{ + {Name: "docker.io", SystemPackage: true, Optional: true}, + }, + } +} +``` + +## Ajout de nouveaux gestionnaires de paquets + +Pour ajouter un nouveau gestionnaire de paquets, effectuez les étapes suivantes : + +- Créez un nouveau fichier dans `v2/internal/system/packagemanager` appelé `.go`, où `` est le nom du gestionnaire de paquets. +- Définit une structure conforme à l'interface du gestionnaire de paquets définie dans `pm.go`: + +```go +type PackageManager interface { + Name() string + Packages() packagemap + PackageInstalled(*Package) (bool, error) + PackageAvailable(*Package) (bool, error) + InstallCommand(*Package) string +} +``` + +- `Name()` doit retourner le nom du gestionnaire de paquets +- `Packages()` doit retourner une `packagemap`, qui fournit des noms de fichiers candidats pour les dépendances +- `PackageInstalled()` devrait retourner `true` si le paquet donné est installé +- `PackageAvailable()` devrait retourner `true` si le paquet donné n'est pas installé mais disponible pour l'installation +- `InstallCommand()` doit retourner la commande exacte pour installer le nom du paquet donné + +Jetez un coup d'œil au code des autres gestionnaires de paquets pour avoir une idée de comment cela fonctionne. + +:::info Rappel + +Si vous ajoutez le support d'un nouveau gestionnaire de paquets, n'oubliez pas de mettre également à jour cette page ! + +::: diff --git a/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/linux.mdx b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/linux.mdx new file mode 100644 index 000000000..415418ebb --- /dev/null +++ b/website/i18n/fr/docusaurus-plugin-content-docs/version-v2.11.0/guides/linux.mdx @@ -0,0 +1,70 @@ +# Linux + +Cette page a divers guides liés au développement d'applications Wails pour Linux. + +## Video tag doesn't fire "ended" event + +Lorsque vous utilisez un tag vidéo, l'événement "terminé" n'est pas déclenché lorsque la vidéo est finie. Ceci est un bogue dans WebkitGTK, cependant vous pouvez utiliser le contournement suivant pour le corriger : + +```js +videoTag.addEventListener("timeupdate", (event) => { + if (event.target.duration - event.target.currentTime < 0.2) { + let ended = new Event("ended"); + event.target.dispatchEvent(ended); + } +}); +``` + +Source : [Lyimmi](https://github.com/Lyimmi) sur le [forum de discussion](https://github.com/wailsapp/wails/issues/1729#issuecomment-1212291275) + +## GStreamer error when using Audio or Video elements + +If you are seeing the following error when including `