| 1 | package edge |
| 2 | |
| 3 | import "github.com/wailsapp/go-webview2/webviewloader" |
| 4 | |
| 5 | type Capability string |
| 6 | |
| 7 | var UnsupportedCapabilityError = &unsupportedCapabilityError{} |
| 8 | |
| 9 | type unsupportedCapabilityError struct{} |
| 10 | |
| 11 | func (u *unsupportedCapabilityError) Error() string { |
| 12 | return "unsupported capability" |
| 13 | } |
| 14 | |
| 15 | // Capabilities is a list of capabilities with their corresponding minimum runtime version |
| 16 | // Internal Capabilities are not exposed to the user |
| 17 | // Larger capabilities such as DragAndDrop should be exported with a capital letter |
| 18 | |
| 19 | // WebView2 Runtime Version 131.0.2903.40 (Released: September 2023) |
| 20 | const ( |
| 21 | ScreenCapture = Capability("131.0.2903.40") // Screen capture support |
| 22 | NonClientRegion = Capability("131.0.2903.40") // Non-client region customization |
| 23 | DownloadDialog = Capability("131.0.2903.40") // Download dialog handling |
| 24 | BrowserExtension = Capability("131.0.2903.40") // Browser extension support |
| 25 | BasicAuthentication = Capability("131.0.2903.40") // Basic authentication handling |
| 26 | SaveFileDialog = Capability("131.0.2903.40") // Save file dialog support |
| 27 | ) |
| 28 | |
| 29 | // WebView2 Runtime Version 113.0.1774.30 (Released: Unknown) |
| 30 | const ( |
| 31 | GetAdditionalObjects = Capability("113.0.1774.30") // Additional objects support |
| 32 | ) |
| 33 | |
| 34 | // WebView2 Runtime Version 100.0.1185.39 (Released: April 2022) |
| 35 | const ( |
| 36 | AllowExternalDrop = Capability("100.0.1185.39") // External drop support |
| 37 | GeneralAutofillEnabled = Capability("100.0.1185.39") // General autofill features |
| 38 | PasswordAutosaveEnabled = Capability("100.0.1185.39") // Password autosave support |
| 39 | ) |
| 40 | |
| 41 | // WebView2 Runtime Version 98.0.1108.43 (Released: February 2022) |
| 42 | const ( |
| 43 | CustomScheme = Capability("98.0.1108.43") // Custom scheme support |
| 44 | PrintToPdf = Capability("98.0.1108.43") // Print to PDF functionality |
| 45 | SharedBuffer = Capability("98.0.1108.43") // Shared buffer for performance |
| 46 | ServerCertificate = Capability("98.0.1108.43") // Server certificate handling |
| 47 | FrameNavigation = Capability("98.0.1108.43") // Frame navigation events |
| 48 | ) |
| 49 | |
| 50 | // WebView2 Runtime Version 97.0.1072.69 (Released: January 2022) |
| 51 | const ( |
| 52 | ClientCertificate = Capability("97.0.1072.69") // Client certificate selection |
| 53 | ContextMenus = Capability("97.0.1072.69") // Custom context menus |
| 54 | BackgroundColor = Capability("97.0.1072.69") // Background color customization |
| 55 | ScriptEnabled = Capability("97.0.1072.69") // JavaScript execution control |
| 56 | StatusBar = Capability("97.0.1072.69") // Status bar customization |
| 57 | ) |
| 58 | |
| 59 | // WebView2 Runtime Version 95.0.1020.44 (Released: October 2021) |
| 60 | const ( |
| 61 | WebMessageReceived = Capability("95.0.1020.44") // Web message handling |
| 62 | NewWindowRequested = Capability("95.0.1020.44") // New window request handling |
| 63 | DocumentTitleChanged = Capability("95.0.1020.44") // Document title change events |
| 64 | ContainsFullScreen = Capability("95.0.1020.44") // Fullscreen mode detection |
| 65 | WebResourceRequested = Capability("95.0.1020.44") // Web resource request handling |
| 66 | ) |
| 67 | |
| 68 | // WebView2 Runtime Version 94.0.992.31 (Released: September 2021) |
| 69 | const ( |
| 70 | NavigationStarting = Capability("94.0.992.31") // Navigation start events |
| 71 | NavigationCompleted = Capability("94.0.992.31") // Navigation completion events |
| 72 | FrameNavigationStarting = Capability("94.0.992.31") // Frame navigation start |
| 73 | SourceChanged = Capability("94.0.992.31") // Source change detection |
| 74 | HistoryChanged = Capability("94.0.992.31") // Browser history changes |
| 75 | SwipeNavigation = Capability("94.0.992.31") // Swipe navigation support |
| 76 | ) |
| 77 | |
| 78 | // WebView2 Runtime Version 93.0.961.52 (Released: August 2021) |
| 79 | const ( |
| 80 | DOMContentLoaded = Capability("93.0.961.52") // DOM content loaded events |
| 81 | WebResourceLoaded = Capability("93.0.961.52") // Resource load events |
| 82 | ScriptDialogOpening = Capability("93.0.961.52") // Script dialog handling |
| 83 | PermissionRequested = Capability("93.0.961.52") // Permission request handling |
| 84 | ProcessFailed = Capability("93.0.961.52") // Process failure detection |
| 85 | ) |
| 86 | |
| 87 | // WebView2 Runtime Version 92.0.902.78 (Released: July 2021) |
| 88 | const ( |
| 89 | AcceleratorKeyPressed = Capability("92.0.902.78") // Accelerator key handling |
| 90 | ZoomFactorChanged = Capability("92.0.902.78") // Zoom factor change events |
| 91 | MoveFocusRequested = Capability("92.0.902.78") // Focus movement handling |
| 92 | DevToolsProtocol = Capability("92.0.902.78") // DevTools protocol support |
| 93 | BrowserProcessExited = Capability("92.0.902.78") // Browser process exit handling |
| 94 | ) |
| 95 | |
| 96 | // WebView2 Runtime Version 91.0.864.41 (Released: June 2021) |
| 97 | const ( |
| 98 | DefaultDownloadDialog = Capability("91.0.864.41") // Default download dialog |
| 99 | DefaultContextMenus = Capability("91.0.864.41") // Default context menus |
| 100 | FaviconChanged = Capability("91.0.864.41") // Favicon change events |
| 101 | WindowCloseRequested = Capability("91.0.864.41") // Window close request handling |
| 102 | RasterizationScale = Capability("91.0.864.41") // Display scaling support |
| 103 | SecurityUpdated = Capability("91.0.864.41") // Security state updates |
| 104 | ProcessInfoReceived = Capability("91.0.864.41") // Process info events |
| 105 | FramePermissionRequested = Capability("91.0.864.41") // Frame permission requests |
| 106 | ClearBrowsingData = Capability("91.0.864.41") // Clear browsing data support |
| 107 | IsMutedChanged = Capability("91.0.864.41") // Audio mute state changes |
| 108 | ) |
| 109 | |
| 110 | // WebView2 Runtime Version 90.0.818.41 (Released: May 2021) |
| 111 | const ( |
| 112 | WebResourceResponseReceived = Capability("90.0.818.41") // Web resource response handling |
| 113 | DOMContentLoaded90 = Capability("90.0.818.41") // DOM content loaded events (v90) |
| 114 | WebResourceRequested90 = Capability("90.0.818.41") // Web resource requests (v90) |
| 115 | NewWindowWithOptions = Capability("90.0.818.41") // New window with options |
| 116 | CookieManagement = Capability("90.0.818.41") // Cookie management support |
| 117 | ) |
| 118 | |
| 119 | // WebView2 Runtime Version 89.0.774.75 (Released: April 2021) |
| 120 | const ( |
| 121 | IsBuiltInErrorPageEnabled = Capability("89.0.774.75") // Built-in error page support |
| 122 | WebResourceResponse = Capability("89.0.774.75") // Web resource response handling |
| 123 | ScriptToExecuteOnDocumentCreated = Capability("89.0.774.75") // Document creation scripts |
| 124 | EnvironmentOptions = Capability("89.0.774.75") // Environment options support |
| 125 | FrameNavigation89 = Capability("89.0.774.75") // Frame navigation (v89) |
| 126 | ) |
| 127 | |
| 128 | // WebView2 Runtime Version 88.0.705.74 (Released: March 2021) |
| 129 | const ( |
| 130 | WebResourceRequested88 = Capability("88.0.705.74") // Web resource requests (v88) |
| 131 | PermissionRequested88 = Capability("88.0.705.74") // Permission requests (v88) |
| 132 | ProcessFailed88 = Capability("88.0.705.74") // Process failure handling (v88) |
| 133 | AddHostObjectToScript = Capability("88.0.705.74") // Host object scripting |
| 134 | IsMuted = Capability("88.0.705.74") // Audio mute state |
| 135 | ) |
| 136 | |
| 137 | // WebView2 Runtime Version 87.0.664.75 (Released: February 2021) |
| 138 | const ( |
| 139 | WebMessageReceived87 = Capability("87.0.664.75") // Web message handling (v87) |
| 140 | CallDevToolsProtocolMethod = Capability("87.0.664.75") // DevTools protocol method calls |
| 141 | NewWindow87 = Capability("87.0.664.75") // New window creation (v87) |
| 142 | DocumentTitleChanged87 = Capability("87.0.664.75") // Document title changes (v87) |
| 143 | IsSuspended = Capability("87.0.664.75") // Suspension state |
| 144 | ) |
| 145 | |
| 146 | // WebView2 Runtime Version 86.0.622.58 (Released: January 2021) |
| 147 | const ( |
| 148 | NavigationStarting86 = Capability("86.0.622.58") // Navigation start events (v86) |
| 149 | NavigationCompleted86 = Capability("86.0.622.58") // Navigation completion (v86) |
| 150 | FrameNavigationStarting86 = Capability("86.0.622.58") // Frame navigation start (v86) |
| 151 | BasicWebView = Capability("86.0.622.58") // Basic WebView2 functionality |
| 152 | WindowBounds = Capability("86.0.622.58") // Window bounds control |
| 153 | ) |
| 154 | |
| 155 | // WebView2 Runtime Version 85.0.564.70 (Released: December 2020) |
| 156 | const ( |
| 157 | WebView2Environment = Capability("85.0.564.70") // WebView2 environment |
| 158 | WebView2Controller = Capability("85.0.564.70") // WebView2 controller |
| 159 | BasicSettings = Capability("85.0.564.70") // Basic settings support |
| 160 | UserDataFolder = Capability("85.0.564.70") // User data folder |
| 161 | BrowserVersionString = Capability("85.0.564.70") // Browser version info |
| 162 | ) |
| 163 | |
| 164 | func HasCapability(webview2RuntimeVersion string, capability Capability) bool { |
| 165 | result, err := webviewloader.CompareBrowserVersions(webview2RuntimeVersion, string(capability)) |
| 166 | if err != nil { |
| 167 | return false |
| 168 | } |
| 169 | return result >= 0 |
| 170 | } |
| 171 |