Skip to content

Commit 4e98b76

Browse files
author
SentienceDEV
committed
Merge pull request #99 from SentienceAPI/scale_factor2
add device_scale_factor support & bump version
2 parents 6840511 + 2eda42e commit 4e98b76

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sentienceapi",
3-
"version": "0.92.0",
3+
"version": "0.92.1",
44
"description": "TypeScript SDK for Sentience AI Agent Browser Automation",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/browser.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,24 @@ export class SentienceBrowser implements IBrowser {
2727
private _recordVideoDir?: string;
2828
private _recordVideoSize?: { width: number; height: number };
2929
private _viewport?: { width: number; height: number };
30+
private _deviceScaleFactor?: number;
3031

32+
/**
33+
* Create a new SentienceBrowser instance
34+
*
35+
* @param apiKey - Optional API key for server-side processing (Pro/Enterprise tiers)
36+
* @param apiUrl - Optional API URL (defaults to https://api.sentienceapi.com if apiKey provided)
37+
* @param headless - Whether to run in headless mode (defaults to true in CI, false locally)
38+
* @param proxy - Optional proxy server URL (e.g., 'http://user:pass@proxy.example.com:8080')
39+
* @param userDataDir - Optional path to user data directory for persistent sessions
40+
* @param storageState - Optional storage state to inject (cookies + localStorage)
41+
* @param recordVideoDir - Optional directory path to save video recordings
42+
* @param recordVideoSize - Optional video resolution as object with 'width' and 'height' keys
43+
* @param viewport - Optional viewport size as object with 'width' and 'height' keys
44+
* @param deviceScaleFactor - Optional device scale factor to emulate high-DPI (Retina) screens.
45+
* Examples: 1.0 (default, standard DPI), 2.0 (Retina/high-DPI, like MacBook Pro), 3.0 (very high DPI)
46+
* If undefined, defaults to 1.0 (standard DPI).
47+
*/
3148
constructor(
3249
apiKey?: string,
3350
apiUrl?: string,
@@ -37,7 +54,8 @@ export class SentienceBrowser implements IBrowser {
3754
storageState?: string | StorageState | object,
3855
recordVideoDir?: string,
3956
recordVideoSize?: { width: number; height: number },
40-
viewport?: { width: number; height: number }
57+
viewport?: { width: number; height: number },
58+
deviceScaleFactor?: number
4159
) {
4260
this._apiKey = apiKey;
4361

@@ -72,6 +90,9 @@ export class SentienceBrowser implements IBrowser {
7290

7391
// Viewport configuration
7492
this._viewport = viewport || { width: 1280, height: 800 };
93+
94+
// Device scale factor for high-DPI emulation
95+
this._deviceScaleFactor = deviceScaleFactor;
7596
}
7697

7798
async start(): Promise<void> {
@@ -171,6 +192,11 @@ export class SentienceBrowser implements IBrowser {
171192
ignoreHTTPSErrors: proxyConfig !== undefined,
172193
};
173194

195+
// Add device scale factor if configured
196+
if (this._deviceScaleFactor !== undefined) {
197+
launchOptions.deviceScaleFactor = this._deviceScaleFactor;
198+
}
199+
174200
// Add video recording if configured
175201
if (this._recordVideoDir) {
176202
launchOptions.recordVideo = {

0 commit comments

Comments
 (0)