feat: promisify win.capturePage() (#15743)
* feat: promisify win.capturePage * mark optional arg correctly * Add to breaking changes doc * properly deprecate win.capturePage * remove change from api-contract * document both callback and promise versions * address docs feedback * update promisification progress doc
This commit is contained in:
		
					parent
					
						
							
								73fbb69c50
							
						
					
				
			
			
				commit
				
					
						41c2685204
					
				
			
		
					 9 changed files with 74 additions and 38 deletions
				
			
		|  | @ -1212,7 +1212,19 @@ Returns `Boolean` - Whether the window's document has been edited. | |||
| * `callback` Function | ||||
|   * `image` [NativeImage](native-image.md) | ||||
| 
 | ||||
| Same as `webContents.capturePage([rect, ]callback)`. | ||||
| Captures a snapshot of the page within `rect`. Upon completion `callback` will | ||||
| be called with `callback(image)`. The `image` is an instance of [NativeImage](native-image.md) | ||||
| that stores data of the snapshot. Omitting `rect` will capture the whole visible page. | ||||
| 
 | ||||
| **[Deprecated Soon](promisification.md)** | ||||
| 
 | ||||
| #### `win.capturePage([rect])` | ||||
| 
 | ||||
| * `rect` [Rectangle](structures/rectangle.md) (optional) - The bounds to capture | ||||
| 
 | ||||
| * Returns `Promise<NativeImage>` - Resolves with a [NativeImage](native-image.md) | ||||
| 
 | ||||
| Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page. | ||||
| 
 | ||||
| #### `win.loadURL(url[, options])` | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,7 +11,6 @@ When a majority of affected functions are migrated, this flag will be enabled by | |||
| - [ ] [app.getFileIcon(path[, options], callback)](https://github.com/electron/electron/blob/master/docs/api/app.md#getFileIcon) | ||||
| - [ ] [app.importCertificate(options, callback)](https://github.com/electron/electron/blob/master/docs/api/app.md#importCertificate) | ||||
| - [ ] [win.hookWindowMessage(message, callback)](https://github.com/electron/electron/blob/master/docs/api/browser-window.md#hookWindowMessage) | ||||
| - [ ] [win.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/browser-window.md#capturePage) | ||||
| - [ ] [request.write(chunk[, encoding][, callback])](https://github.com/electron/electron/blob/master/docs/api/client-request.md#write) | ||||
| - [ ] [request.end([chunk][, encoding][, callback])](https://github.com/electron/electron/blob/master/docs/api/client-request.md#end) | ||||
| - [ ] [contentTracing.getCategories(callback)](https://github.com/electron/electron/blob/master/docs/api/content-tracing.md#getCategories) | ||||
|  | @ -52,7 +51,6 @@ When a majority of affected functions are migrated, this flag will be enabled by | |||
| - [ ] [contents.executeJavaScript(code[, userGesture, callback])](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#executeJavaScript) | ||||
| - [ ] [contents.getZoomFactor(callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#getZoomFactor) | ||||
| - [ ] [contents.getZoomLevel(callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#getZoomLevel) | ||||
| - [ ] [contents.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#capturePage) | ||||
| - [ ] [contents.hasServiceWorker(callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#hasServiceWorker) | ||||
| - [ ] [contents.unregisterServiceWorker(callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#unregisterServiceWorker) | ||||
| - [ ] [contents.print([options], [callback])](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#print) | ||||
|  | @ -63,8 +61,11 @@ When a majority of affected functions are migrated, this flag will be enabled by | |||
| - [ ] [webFrame.executeJavaScriptInIsolatedWorld(worldId, scripts[, userGesture, callback])](https://github.com/electron/electron/blob/master/docs/api/web-frame.md#executeJavaScriptInIsolatedWorld) | ||||
| - [ ] [webviewTag.executeJavaScript(code[, userGesture, callback])](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#executeJavaScript) | ||||
| - [ ] [webviewTag.printToPDF(options, callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#printToPDF) | ||||
| - [ ] [webviewTag.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#capturePage) | ||||
| - [ ] [webviewTag.getZoomFactor(callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#getZoomFactor) | ||||
| - [ ] [webviewTag.getZoomLevel(callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#getZoomLevel) | ||||
| 
 | ||||
| ### Converted Functions | ||||
| ### Converted Functions | ||||
| 
 | ||||
| - [ ] [win.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/browser-window.md#capturePage) | ||||
| - [ ] [webviewTag.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#capturePage) | ||||
| - [ ] [contents.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/web-contents.md#capturePage) | ||||
|  | @ -1050,14 +1050,23 @@ console.log(requestId) | |||
| 
 | ||||
| #### `contents.capturePage([rect, ]callback)` | ||||
| 
 | ||||
| * `rect` [Rectangle](structures/rectangle.md) (optional) - The area of the page to be captured. | ||||
| * `rect` [Rectangle](structures/rectangle.md) (optional) - The bounds to capture | ||||
| * `callback` Function | ||||
|   * `image` [NativeImage](native-image.md) | ||||
| 
 | ||||
| Captures a snapshot of the page within `rect`. Upon completion `callback` will | ||||
| be called with `callback(image)`. The `image` is an instance of | ||||
| [NativeImage](native-image.md) that stores data of the snapshot. Omitting | ||||
| `rect` will capture the whole visible page. | ||||
| be called with `callback(image)`. The `image` is an instance of [NativeImage](native-image.md) | ||||
| that stores data of the snapshot. Omitting `rect` will capture the whole visible page. | ||||
| 
 | ||||
| **[Deprecated Soon](promisification.md)** | ||||
| 
 | ||||
| #### `contents.capturePage([rect])` | ||||
| 
 | ||||
| * `rect` [Rectangle](structures/rectangle.md) (optional) - The area of the page to be captured. | ||||
| 
 | ||||
| * Returns `Promise<NativeImage>` - Resolves with a [NativeImage](native-image.md) | ||||
| 
 | ||||
| Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page. | ||||
| 
 | ||||
| #### `contents.hasServiceWorker(callback)` | ||||
| 
 | ||||
|  |  | |||
|  | @ -540,11 +540,23 @@ Prints `webview`'s web page as PDF, Same as `webContents.printToPDF(options, cal | |||
| 
 | ||||
| ### `<webview>.capturePage([rect, ]callback)` | ||||
| 
 | ||||
| * `rect` [Rectangle](structures/rectangle.md) (optional) - The area of the page to be captured. | ||||
| * `rect` [Rectangle](structures/rectangle.md) (optional) - The bounds to capture | ||||
| * `callback` Function | ||||
|   * `image` [NativeImage](native-image.md) | ||||
| 
 | ||||
| Captures a snapshot of the `webview`'s page. Same as `webContents.capturePage([rect, ]callback)`. | ||||
| Captures a snapshot of the page within `rect`. Upon completion `callback` will | ||||
| be called with `callback(image)`. The `image` is an instance of [NativeImage](native-image.md) | ||||
| that stores data of the snapshot. Omitting `rect` will capture the whole visible page. | ||||
| 
 | ||||
| **[Deprecated Soon](promisification.md)** | ||||
| 
 | ||||
| ### `<webview>.capturePage([rect])` | ||||
| 
 | ||||
| * `rect` [Rectangle](structures/rectangle.md) (optional) - The area of the page to be captured. | ||||
| 
 | ||||
| * Returns `Promise<NativeImage>` - Resolves with a [NativeImage](native-image.md) | ||||
| 
 | ||||
| Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page. | ||||
| 
 | ||||
| ### `<webview>.send(channel[, arg1][, arg2][, ...])` | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Shelley Vohr
				Shelley Vohr