Conversation
Add _resolveRect() helper to convert DOM elements and jQuery selector strings to capture rects, with zoom factor compensation. Update _capturePageBinary bounds validation to account for webview scale factor. Add tests for DOM element, selector, and error case inputs.
Use Math.ceil on zoom-adjusted dimensions to prevent false rejections when innerWidth/Height * zoomFactor produces fractional values.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



based on native platform api: phcode-dev/phoenix-desktop#685
📸 Screenshot Utilities
The Screenshot Utilities provide flexible APIs to capture screenshots of the current page or a specific region and return them in different formats for performance and convenience.
All methods accept the same capture target:
{ x, y, width, height }screenShotBinary(rectOrNodeOrSelector)Captures a screenshot and returns raw PNG bytes.
Parameters
rectOrNodeOrSelectorObject | HTMLElement | string(optional)Returns
Promise<Uint8Array>— PNG image bytesExamples
Capture a specific rectangle
Capture a DOM element
screenShotToBlob(rectOrNodeOrSelector)Captures a screenshot and returns a PNG
Blob.Parameters
rectOrNodeOrSelectorObject | HTMLElement | string(optional)Returns
Promise<Blob>— PNG Blob (image/png)Examples
Display in an image element
Draw to a canvas
screenShotToPNGFile(filePathToSave, rectOrNodeOrSelector)Captures a screenshot and saves it directly as a PNG file.
Parameters
filePathToSavestringrectOrNodeOrSelectorObject | HTMLElement | string(optional)Returns
Promise<void>Throws
ErroriffilePathToSaveis not a non-empty stringExamples
Save the full page
Save a specific element
⚡ Performance Notes
screenShotBinaryscreenShotToBlobscreenShotToPNGFile