Skip to content

V2.2.1 alpha1#124

Open
ioa747 wants to merge 5 commits intomainfrom
v2.2.1-alpha1
Open

V2.2.1 alpha1#124
ioa747 wants to merge 5 commits intomainfrom
v2.2.1-alpha1

Conversation

@ioa747
Copy link
Copy Markdown
Owner

@ioa747 ioa747 commented Apr 15, 2026

Important

Thanks for your effort and interest 💛 in improving the project. It's very appreciated.

Description

Refactored: OnDownloadStarting Event
  • Transitioned from a parameter-based signature to a robust, object-oriented argument model.

    • New Argument Wrapper: IWebView2DownloadStartingEventArgs provides access to Uri, ResultFilePath, Handled, Cancel, MimeType, ContentDisposition, and TotalBytesToReceive.

    • Hybrid Deferral Model: Implemented a performance-optimized synchronization mechanism using CoreWebView2Deferral. The C# core now waits up to 5000ms for AutoIt to set Handled or Cancel on the argument object, proceeding immediately once a decision is made.

    • MimeType Support (Issue [FEATURE]: WebView.UnviewableContentIdentified Event #123): Exposed MimeType directly in the download arguments, allowing AutoIt scripts to identify "unviewable content" (e.g., PDFs, ZIPs) at the start of the download lifecycle.

  • Improved: Download Logic: Automatic redirection to _customDownloadPath is now applied before the event fires, allowing AutoIt to see and potentially override the final destination.

Refactored: OnDownloadStateChanged Event
  • Transitioned to an object-oriented argument model for consistent event handling.
    • New Argument Wrapper: IWebView2DownloadStateChangedEventArgs
      provides access to State, Uri, TotalBytesToReceive, BytesReceived, and a new PercentComplete helper.

    • Buffered Property Pattern: Applied to ensure thread-safe progress updates during rapid download cycles.

Fixed: HTTP Status Code Detection
  • Resolved a bug where OnWebResourceResponseReceived failed to fire due to a missing legacy header hack. Replaced with native ResourceContext detection.

Caution

Breaking Change: If you have custom scripts using OnDownloadStarting or OnDownloadStateChanged, please update their signatures to use the new $oArgs object as demonstrated in the updated examples.

🔗 Linked GitHub Issues

#123
#120 (comment)

Closes #123

📋 What is the current behavior?

🚀 What is the new behavior?


Type of changes

  • 🪲 Bugfix (change which fixes an issue)
  • ⭐ New Feature (change which adds functionality)
  • ⭐ New Example (this PR adds a new example)
  • 🔒 Security fix (change which improves security)
  • 🔮 Code style update (formatting, renaming)
  • 🔨 Refactoring (code optimization without functional change)
  • 📚 Documentation (updates to README or docs)
  • ⚙️ Build or CI related changes
  • 🧿 Other type

Breaking changes 🔥

Breaking Change:
If you have custom scripts using
OnDownloadStarting Event
OnDownloadStateChanged Event
please update their signatures to use the new $oArgs object as demonstrated in the updated examples.

  • Yes
  • No

How and where was this tested?

🖥️ Describe where you tested your changes

System:

  • Windows 11 (x64)
  • Windows 10 (x64)
  • Windows 10 (x86)
  • Windows Server ......

Context:

  • COM object NetJson.Parser
  • COM object NetWebView2.Manager - WebView2
  • COM object NetWebView2.Manager - Bridge
  • UDF - NetWebView2Lib.au3
  • Examples: 006-DownloadDemo.au3, 022-HandleUnviewableContent
  • with ...

🔬 Describe how you tested your changes

  • Manually tested in system and context shown above
  • Ran automatic tests (unit tests, integration tests, etc.)
  • Other ways

Checklist

  • I have read and understood the available contributing guidelines.
  • I have ensured my code follows the available code conventions.
  • I have reviewed my changes.
  • I have made corresponding changes to the documentation (if applicable).
  • I have added/updated necessary tests to cover the changes (if applicable).
  • I have checked for potential security implications.

Additional context

Screenshots

Note to reviewers


⚡ OnDownloadStarting

Fired when a download is starting. Provides a robust argument object for decision making and metadata access (MimeType, etc.).
object_OnDownloadStarting(Sender As Object, ParentHandle As HWND, Args As Object)
Args properties:
Uri (string): The target URL of the download.
ResultFilePath (string): Get/Set the target file path.
Handled (bool): Set to True to indicate AutoIt has handled the UI/Decision (stops the 5000ms wait loop).
Cancel (bool): Set to True to cancel the download immediately.
MimeType (string): The MIME type of the content (e.g., "application/pdf").
ContentDisposition (string): The Content-Disposition header from the server.
TotalBytesToReceive (long): Estimated total size of the download (if known).

⚡ OnDownloadStateChanged

Fired when a download state changes (e.g., Progress, Completed, Failed).
object_OnDownloadStateChanged(Sender As Object, ParentHandle As HWND, Args As Object)
Args properties:
State (string): The current state ("InProgress", "Completed", "Interrupted").
Uri (string): The download URI.
TotalBytesToReceive (long): Estimated total size.
BytesReceived (long): Number of bytes received so far.
PercentComplete (int): Calculation (0-100) or -1 if unknown.

ioa747 added 5 commits April 15, 2026 03:31
Updated README.md to reflect new features and enhancements in version 2.2.1-alpha1, including event object refactoring and UI responsiveness improvements.
Added a new section detailing the latest release (v2.2.1-alpha1) with a focus on UI responsiveness and event object refactoring.
Added caution note about breaking changes in HTTP status code detection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: WebView.UnviewableContentIdentified Event

1 participant