fix(browser): update browser context creation for current Puppeteer API and refresh build configuration

This commit is contained in:
2026-05-01 16:26:59 +00:00
parent 5b8eb43181
commit 24aa17f6bc
11 changed files with 3530 additions and 5764 deletions
+37
View File
@@ -0,0 +1,37 @@
{
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartpuppeteer",
"shortDescription": "simplified access to puppeteer",
"npmPackagename": "@push.rocks/smartpuppeteer",
"license": "MIT",
"description": "Provides simplified access to Puppeteer for automation and testing purposes.",
"keywords": [
"puppeteer",
"automation",
"browser automation",
"web scraping",
"testing",
"headless browsing",
"incognito browsing"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
}
}
+7
View File
@@ -1,5 +1,12 @@
# Changelog # Changelog
## 2026-05-01 - 2.0.6 - fix(browser)
update browser context creation for current Puppeteer API and refresh build configuration
- Replace deprecated incognito context creation with createBrowserContext() for compatibility with newer Puppeteer versions
- Refresh build and test tooling configuration, including updated scripts and Node typings
- Rename the test entrypoint to test.node.ts and migrate assertions to @git.zone/tstest/tapbundle
## 2025-02-25 - 2.0.5 - fix(dependencies) ## 2025-02-25 - 2.0.5 - fix(dependencies)
Update dependencies including Puppeteer and node types. Update dependencies including Puppeteer and node types.
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2019 Lossless GmbH (hello@lossless.com) Copyright (c) 2019 Task Venture Capital GmbH <hello@task.vc>
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+13 -7
View File
@@ -1,5 +1,5 @@
{ {
"gitzone": { "@git.zone/cli": {
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "code.foss.global", "githost": "code.foss.global",
@@ -8,7 +8,6 @@
"shortDescription": "simplified access to puppeteer", "shortDescription": "simplified access to puppeteer",
"npmPackagename": "@push.rocks/smartpuppeteer", "npmPackagename": "@push.rocks/smartpuppeteer",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks",
"description": "Provides simplified access to Puppeteer for automation and testing purposes.", "description": "Provides simplified access to Puppeteer for automation and testing purposes.",
"keywords": [ "keywords": [
"puppeteer", "puppeteer",
@@ -19,13 +18,20 @@
"headless browsing", "headless browsing",
"incognito browsing" "incognito browsing"
] ]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
} }
}, },
"npmci": { "@git.zone/tsdoc": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
} }
} }
+12 -9
View File
@@ -6,23 +6,24 @@
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module", "type": "module",
"author": "Lossless GmbH", "author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "tstest test/", "test": "tstest test/",
"build": "tsbuild --web --allowimplicitany" "format": "gitzone format",
"build": "tsbuild --web",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.63", "@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsrun": "^1.2.46", "@git.zone/tsrun": "^2.0.3",
"@git.zone/tstest": "^1.0.71", "@git.zone/tstest": "^3.6.3",
"@push.rocks/tapbundle": "^5.0.8", "@types/node": "^25.6.0"
"@types/node": "^22.13.5"
}, },
"dependencies": { "dependencies": {
"@push.rocks/smartdelay": "^3.0.1", "@push.rocks/smartdelay": "^3.0.1",
"@push.rocks/smartshell": "^3.0.3", "@push.rocks/smartshell": "^3.3.8",
"puppeteer": "^24.3.0", "puppeteer": "^24.42.0",
"tree-kill": "^1.2.2" "tree-kill": "^1.2.2"
}, },
"files": [ "files": [
@@ -34,6 +35,8 @@
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",
".smartconfig.json",
"license",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
], ],
+3444 -5729
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -1,7 +1,7 @@
import { expect, tap } from '@push.rocks/tapbundle'; import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartpuppeteer from '../ts/index.js'; import * as smartpuppeteer from '../ts/index.js';
tap.test('should use pipe', async (tools) => { tap.test('should use pipe', async () => {
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({ const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: false, forceNoSandbox: false,
}); });
@@ -12,7 +12,7 @@ tap.test('should use pipe', async (tools) => {
await headlessBrowser.close(); await headlessBrowser.close();
}); });
tap.test('should use websocket', async (tools) => { tap.test('should use websocket', async () => {
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({ const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: false, forceNoSandbox: false,
usePipe: false, usePipe: false,
@@ -31,4 +31,4 @@ tap.test('should get and stop an Incognito browser', async () => {
await incognitoInstance.stop(); await incognitoInstance.stop();
}); });
tap.start(); export default tap.start();
+1 -1
View File
@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartpuppeteer', name: '@push.rocks/smartpuppeteer',
version: '2.0.5', version: '2.0.6',
description: 'Provides simplified access to Puppeteer for automation and testing purposes.' description: 'Provides simplified access to Puppeteer for automation and testing purposes.'
} }
@@ -55,14 +55,12 @@ export class IncognitoBrowser {
/** /**
* Returns a new incognito browser context. * Returns a new incognito browser context.
* This uses Puppeteer's createIncognitoBrowserContext() API, which is the * This uses Puppeteer's current createBrowserContext() API for isolated sessions.
* correct method for creating isolated sessions.
*/ */
public async getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext> { public async getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext> {
if (!this.browser) { if (!this.browser) {
throw new Error('You need to start the IncognitoBrowser instance first'); throw new Error('You need to start the IncognitoBrowser instance first');
} }
// @ts-ignore return this.browser.createBrowserContext();
return this.browser.createIncognitoBrowserContext();
} }
} }
+1 -1
View File
@@ -43,7 +43,7 @@ export const getEnvAwareBrowserInstance = async (
const headlessBrowser = await plugins.puppeteer.launch({ const headlessBrowser = await plugins.puppeteer.launch({
args: chromeArgs, args: chromeArgs,
pipe: options.usePipe !== undefined ? options.usePipe : true, pipe: options.usePipe ?? true,
headless: true, headless: true,
...executablePathOptions, ...executablePathOptions,
}); });
+4 -4
View File
@@ -5,10 +5,10 @@
"target": "ES2022", "target": "ES2022",
"module": "NodeNext", "module": "NodeNext",
"moduleResolution": "NodeNext", "moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true "verbatimModuleSyntax": true,
"types": ["node"]
}, },
"exclude": [ "exclude": ["dist_*/**/*.d.ts"]
"dist_*/**/*.d.ts"
]
} }