Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5dbee93b92 | |||
| 11dd654fc4 | |||
| 68963ae9ea | |||
| c3014eb72d | |||
| 79d02bf806 | |||
| 654cd2619c | |||
| efda7c7b01 | |||
| 2110ab7325 | |||
| 445c9ae979 | |||
| 61d1a1c8df | |||
| 79f9042665 | |||
| ce4dea816e | |||
| 9354cd5bd3 | |||
| f360dade33 | |||
| 9030ccde71 | |||
| 2aa517a459 | |||
| 0fea2e6879 | |||
| 0e6103cb58 | |||
| 8dc697da1a | |||
| 9615d7d0e3 | |||
| 431f63e283 | |||
| e9bf2032fb | |||
| 3a2e85b4e5 | |||
| fdfa6a72c8 | |||
| 801416dc1e | |||
| 84cf226d42 | |||
| 63f56da150 | |||
| 3559453579 | |||
| ea509d4246 | |||
| c13a125ac7 | |||
| 8f6949b1b8 | |||
| 9b698c6dea | |||
| 157bcff7c4 | |||
| 934423f0ad |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @gitzone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
||||
137
.gitlab-ci.yml
137
.gitlab-ci.yml
@@ -1,137 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
90
changelog.md
Normal file
90
changelog.md
Normal file
@@ -0,0 +1,90 @@
|
||||
# Changelog
|
||||
|
||||
## 2026-03-09 - 2.0.11 - fix(deps)
|
||||
upgrade dependencies and adapt code, tests, and docs for new upstream versions
|
||||
|
||||
- Bump runtime deps: @push.rocks/smartpdf -> ^4.2.0, @push.rocks/smartpuppeteer -> ^2.0.5
|
||||
- Bump devDependencies to modern majors: @git.zone/tsbuild ^4.3.0, @git.zone/tsrun ^2.0.1, @git.zone/tstest ^3.3.1, @push.rocks/tapbundle ^6.0.3, @types/node ^25.3.5
|
||||
- Remove --allowimplicitany from build script to match tsbuild v4 behavior
|
||||
- Fix Puppeteer screenshot handling: convert returned Uint8Array to Buffer via Buffer.from()
|
||||
- Update tests to match tapbundle v6 API (remove expectAsync) and export tap.start()
|
||||
- Add/expand documentation (readme.md and readme.hints.md) with dependency notes and usage examples
|
||||
|
||||
## 2026-03-09 - 2.0.10 - fix(config(npmextra))
|
||||
normalize npmextra.json keys to namespaced entries and add release registries
|
||||
|
||||
- Replaced top-level "npmci" and "gitzone" entries with namespaced keys (@git.zone/cli)
|
||||
- Moved tsdoc/legal content under @git.zone/tsdoc
|
||||
- Added a release configuration for @git.zone/cli with registries (verdaccio + npm) and accessLevel: public
|
||||
- Added a new empty @ship.zone/szci entry
|
||||
|
||||
## 2026-03-09 - 2.0.9 - fix(smartpdf)
|
||||
lazily initialize SmartPdf, stop it only when present, and make evaluateOnPage reliably close pages
|
||||
|
||||
- Add private ensureSmartPdf() to lazily initialize and start SmartPdf only when PDF methods are called
|
||||
- Call ensureSmartPdf() in pdfFromPage() before using smartpdf
|
||||
- Stop SmartPdf in stop() only if it was initialized and clear the reference
|
||||
- Wrap evaluateOnPage() page operations in try/finally and safely ignore errors from page.close() to avoid resource leaks or uncaught exceptions
|
||||
|
||||
## 2025-01-03 - 2.0.8 - fix(core)
|
||||
Ensure consistent browser automation functionality
|
||||
|
||||
- Verified browser initialization and shutdown
|
||||
- Tested PDF generation from web pages
|
||||
- Validated screenshot capturing
|
||||
|
||||
## 2025-01-02 - 2.0.7 - fix(dependencies)
|
||||
Update dependencies to latest versions.
|
||||
|
||||
- Updated @push.rocks/smartpdf dependency to version ^3.1.8
|
||||
- Updated @push.rocks/smartunique dependency to version ^3.0.9
|
||||
- Updated devDependencies to the latest versions
|
||||
|
||||
## 2024-05-29 - 2.0.6 - Project Maintenance
|
||||
Minor project maintenance updates.
|
||||
|
||||
- Updated project description
|
||||
- Revised tsconfig settings
|
||||
- Made repeated updates to npmextra.json focusing on 'githost' configuration
|
||||
|
||||
## 2023-07-11 - 2.0.5 - Organizational Updates
|
||||
Switch to new organizational scheme and internal updates.
|
||||
|
||||
- Transitioned project to new organizational scheme
|
||||
|
||||
## 2022-10-26 - 2.0.4 to 2.0.2 - Core Fixes
|
||||
A series of core fixes were applied to ensure better stability and performance.
|
||||
|
||||
## 2022-03-24 - 2.0.1 to 2.0.0 - Core Improvements
|
||||
Significant updates made to the core functionality.
|
||||
|
||||
- Updated core components to enhance performance and reliability
|
||||
|
||||
## 2021-11-07 - 1.0.22 to 1.0.21 - Core Fixes
|
||||
Minor fixes to core components for improved stability.
|
||||
|
||||
## 2021-04-29 - 1.0.20 to 1.0.18 - Core Fixes
|
||||
Routine updates and fixes for core stability.
|
||||
|
||||
## 2020-06-01 - 1.0.16 to 1.0.14 - Bug Fixes
|
||||
Multiple bug fixes and enhancements to the core.
|
||||
|
||||
## 2019-06-04 - 1.0.13 to 1.0.11 - Bug Fixes
|
||||
Addressed several core issues to improve functionality.
|
||||
|
||||
## 2019-05-29 - 1.0.10 to 1.0.6 - Core Updates
|
||||
Numerous updates and fixes were applied to core functionalities.
|
||||
|
||||
## 2017-04-09 - 1.0.5 to 1.0.3 - Feature Enhancements
|
||||
Introduced new features and enhancements.
|
||||
|
||||
- Added .reload() method
|
||||
- Included npmextra.json for better configuration management
|
||||
|
||||
## 2016-09-20 - 1.0.1 to 1.0.0 - Initial Release and Improvements
|
||||
Launched the project with several improvements and setup configurations.
|
||||
|
||||
- Initial project setup and configuration
|
||||
- Enhanced README for better documentation
|
||||
- Integrated GitLab CI for continuous integration
|
||||
|
||||
@@ -1,16 +1,33 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"@git.zone/cli": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartbrowser",
|
||||
"shortDescription": "puppeteer wrapper for easy tasks",
|
||||
"npmPackagename": "@pushrocks/smartbrowser",
|
||||
"license": "MIT"
|
||||
"description": "A simplified Puppeteer wrapper for easy automation and testing tasks.",
|
||||
"npmPackagename": "@push.rocks/smartbrowser",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"puppeteer",
|
||||
"automation",
|
||||
"testing",
|
||||
"pdf generation",
|
||||
"screenshot",
|
||||
"web scraping",
|
||||
"browser automation"
|
||||
]
|
||||
},
|
||||
"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": {}
|
||||
}
|
||||
26818
package-lock.json
generated
26818
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -1,35 +1,37 @@
|
||||
{
|
||||
"name": "@pushrocks/smartbrowser",
|
||||
"version": "1.0.21",
|
||||
"description": "simplified puppeteer",
|
||||
"name": "@push.rocks/smartbrowser",
|
||||
"version": "2.0.11",
|
||||
"description": "A simplified Puppeteer wrapper for easy automation and testing tasks.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web)"
|
||||
"build": "(tsbuild --web)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartbrowser.git"
|
||||
"url": "https://code.foss.global/push.rocks/smartbrowser.git"
|
||||
},
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/smartbrowser/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartbrowser",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartpdf": "^2.0.9",
|
||||
"@pushrocks/smartpuppeteer": "^1.0.21",
|
||||
"@pushrocks/smartunique": "^3.0.3"
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartpdf": "^4.2.0",
|
||||
"@push.rocks/smartpuppeteer": "^2.0.5",
|
||||
"@push.rocks/smartunique": "^3.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
"@git.zone/tsbuild": "^4.3.0",
|
||||
"@git.zone/tsrun": "^2.0.1",
|
||||
"@git.zone/tstest": "^3.3.1",
|
||||
"@push.rocks/tapbundle": "^6.0.3",
|
||||
"@types/node": "^25.3.5"
|
||||
},
|
||||
"private": false,
|
||||
"files": [
|
||||
@@ -46,5 +48,14 @@
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"keywords": [
|
||||
"puppeteer",
|
||||
"automation",
|
||||
"testing",
|
||||
"pdf generation",
|
||||
"screenshot",
|
||||
"web scraping",
|
||||
"browser automation"
|
||||
]
|
||||
}
|
||||
|
||||
11156
pnpm-lock.yaml
generated
Normal file
11156
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
readme.hints.md
Normal file
16
readme.hints.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Smartbrowser Hints
|
||||
|
||||
## Dependencies (as of 2026-03-09)
|
||||
- `@push.rocks/smartpdf` v4.2.x: Has `SmartPdf.create()` factory method, but `new SmartPdf()` + `start(browser)` still works. Lazy init pattern used.
|
||||
- `@push.rocks/smartpuppeteer` v2.x: `getEnvAwareBrowserInstance()` main entry point
|
||||
- `@push.rocks/tapbundle` v6.x: No longer exports `expectAsync`, only `tap`, `expect`, `TapWrap`, `webhelpers`
|
||||
- `@git.zone/tsbuild` v4.x: No `--allowimplicitany` flag (defaults to `noImplicitAny: false`), `--web` flag still passed but ignored if no ts_web
|
||||
- `@git.zone/tstest` v3.3.x: Still supports `--web` flag, file suffix conventions changed (`.chromium.ts` for browser tests)
|
||||
- `@types/node` v25.x: Latest Node.js type definitions
|
||||
- Puppeteer `page.screenshot({ encoding: 'binary' })` returns `Uint8Array`, not `Buffer` - wrap with `Buffer.from()`
|
||||
|
||||
## Build
|
||||
- `pnpm build` uses `tsbuild --web`
|
||||
- `pnpm test` uses `tstest test/ --web`
|
||||
- No ts_web directory exists in this project
|
||||
- Duplicate dayjs versions in transitive deps cause build errors; fix with `pnpm dedupe`
|
||||
174
readme.md
174
readme.md
@@ -1,39 +1,157 @@
|
||||
# @pushrocks/smartbrowser
|
||||
puppeteer wrapper for easy tasks
|
||||
# @push.rocks/smartbrowser
|
||||
A simplified Puppeteer wrapper for easy browser automation, PDF generation, screenshots, and page evaluation.
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartbrowser)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartbrowser)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartbrowser)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartbrowser/)
|
||||
## Install
|
||||
|
||||
## Status for master
|
||||
To install `@push.rocks/smartbrowser`, use the following command with your preferred package manager:
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
```bash
|
||||
npm install @push.rocks/smartbrowser
|
||||
# or
|
||||
pnpm install @push.rocks/smartbrowser
|
||||
```
|
||||
|
||||
This module works with Node.js and requires a Chromium-compatible browser available in the environment. It uses `@push.rocks/smartpuppeteer` under the hood, which automatically detects your environment and configures the browser accordingly (including CI/Docker scenarios).
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
`@push.rocks/smartbrowser` provides a high-level `SmartBrowser` class that wraps Puppeteer for common browser automation tasks: generating PDFs, capturing screenshots, and evaluating JavaScript on web pages.
|
||||
|
||||
## Contribution
|
||||
### Getting Started
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
Import and initialize a `SmartBrowser` instance:
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
```typescript
|
||||
import { SmartBrowser } from '@push.rocks/smartbrowser';
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
const smartBrowser = new SmartBrowser();
|
||||
await smartBrowser.start();
|
||||
```
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
### Generating a PDF from a Webpage
|
||||
|
||||
Generate a full-page PDF from any URL. The result includes a `Buffer` with the PDF contents:
|
||||
|
||||
```typescript
|
||||
const pdfResult = await smartBrowser.pdfFromPage('https://example.com');
|
||||
console.log(pdfResult.buffer); // PDF file buffer
|
||||
console.log(pdfResult.name); // Generated name identifier
|
||||
```
|
||||
|
||||
The PDF generation is powered by `@push.rocks/smartpdf`, which is lazily initialized on first use. This means the SmartPdf server is only started when you actually call `pdfFromPage()`, keeping resource usage minimal.
|
||||
|
||||
### Capturing a Screenshot of a Webpage
|
||||
|
||||
Capture a PNG screenshot of any webpage:
|
||||
|
||||
```typescript
|
||||
const screenshotResult = await smartBrowser.screenshotFromPage('https://example.com');
|
||||
console.log(screenshotResult.buffer); // Screenshot buffer (PNG)
|
||||
console.log(screenshotResult.name); // Short unique identifier
|
||||
console.log(screenshotResult.id); // Identifier with extension
|
||||
```
|
||||
|
||||
### Evaluating JavaScript on a Webpage
|
||||
|
||||
Run arbitrary JavaScript inside a page context and retrieve the result:
|
||||
|
||||
```typescript
|
||||
const pageTitle = await smartBrowser.evaluateOnPage('https://example.com', async () => {
|
||||
return document.title;
|
||||
});
|
||||
console.log(pageTitle); // "Example Domain"
|
||||
```
|
||||
|
||||
The `evaluateOnPage` method supports generic return types:
|
||||
|
||||
```typescript
|
||||
const metrics = await smartBrowser.evaluateOnPage<{ width: number; height: number }>(
|
||||
'https://example.com',
|
||||
async () => {
|
||||
return {
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
};
|
||||
}
|
||||
);
|
||||
console.log(metrics.width, metrics.height);
|
||||
```
|
||||
|
||||
Pages are automatically closed after evaluation, even if an error occurs.
|
||||
|
||||
### Accessing the Underlying Puppeteer Browser
|
||||
|
||||
For advanced use cases, you can access the Puppeteer browser instance directly:
|
||||
|
||||
```typescript
|
||||
const page = await smartBrowser.headlessBrowser.newPage();
|
||||
await page.goto('https://example.com');
|
||||
// ... custom Puppeteer operations
|
||||
await page.close();
|
||||
```
|
||||
|
||||
You can also import the `smartpuppeteer` module directly for lower-level browser management:
|
||||
|
||||
```typescript
|
||||
import { smartpuppeteer } from '@push.rocks/smartbrowser';
|
||||
|
||||
const browser = await smartpuppeteer.getEnvAwareBrowserInstance();
|
||||
```
|
||||
|
||||
### Shutting Down
|
||||
|
||||
Always stop the browser instance when done to free resources:
|
||||
|
||||
```typescript
|
||||
await smartBrowser.stop();
|
||||
```
|
||||
|
||||
This cleanly shuts down the SmartPdf server (if it was initialized) and closes the browser.
|
||||
|
||||
### Full Example
|
||||
|
||||
```typescript
|
||||
import { SmartBrowser } from '@push.rocks/smartbrowser';
|
||||
|
||||
async function main() {
|
||||
const smartBrowser = new SmartBrowser();
|
||||
await smartBrowser.start();
|
||||
|
||||
// Generate a PDF
|
||||
const pdfResult = await smartBrowser.pdfFromPage('https://example.com');
|
||||
console.log('PDF size:', pdfResult.buffer.length, 'bytes');
|
||||
|
||||
// Take a screenshot
|
||||
const screenshot = await smartBrowser.screenshotFromPage('https://example.com');
|
||||
console.log('Screenshot size:', screenshot.buffer.length, 'bytes');
|
||||
|
||||
// Evaluate JavaScript
|
||||
const title = await smartBrowser.evaluateOnPage('https://example.com', async () => {
|
||||
return document.title;
|
||||
});
|
||||
console.log('Page title:', title);
|
||||
|
||||
await smartBrowser.stop();
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This 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.
|
||||
|
||||
**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.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This 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.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By 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.
|
||||
|
||||
16
test/test.ts
16
test/test.ts
@@ -1,25 +1,25 @@
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
import { tap, expect } from '@push.rocks/tapbundle';
|
||||
|
||||
import * as smartbrowser from '../ts/index';
|
||||
import * as smartbrowser from '../ts/index.js';
|
||||
let testSmartBrowser: smartbrowser.SmartBrowser;
|
||||
|
||||
tap.test('should instanstiate a new browser ', async () => {
|
||||
testSmartBrowser = new smartbrowser.SmartBrowser();
|
||||
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.SmartBrowser);
|
||||
return expect(testSmartBrowser).toBeInstanceOf(smartbrowser.SmartBrowser);
|
||||
});
|
||||
|
||||
tap.test('should start the browser ', async () => {
|
||||
await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
|
||||
await testSmartBrowser.start();
|
||||
});
|
||||
|
||||
tap.test('should create a PDF from a page', async (tools) => {
|
||||
const result = await testSmartBrowser.pdfFromPage('https://lossless.com');
|
||||
expect(result.buffer).to.be.instanceOf(Buffer);
|
||||
expect(result.buffer).toBeInstanceOf(Buffer);
|
||||
});
|
||||
|
||||
tap.test('should produce a valid screenshot', async (tools) => {
|
||||
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
|
||||
expect(result.buffer).to.be.instanceOf(Buffer);
|
||||
expect(result.buffer).toBeInstanceOf(Buffer);
|
||||
});
|
||||
|
||||
tap.test('should evalute something in the browser', async () => {
|
||||
@@ -30,7 +30,7 @@ tap.test('should evalute something in the browser', async () => {
|
||||
});
|
||||
|
||||
tap.test('should stop the browser ', async () => {
|
||||
await expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
|
||||
await testSmartBrowser.stop();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
export default tap.start();
|
||||
|
||||
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartbrowser',
|
||||
version: '2.0.11',
|
||||
description: 'A simplified Puppeteer wrapper for easy automation and testing tasks.'
|
||||
}
|
||||
48
ts/index.ts
48
ts/index.ts
@@ -1,6 +1,6 @@
|
||||
import * as plugins from './smartbrowser.plugins';
|
||||
import * as plugins from './smartbrowser.plugins.js';
|
||||
|
||||
import * as interfaces from './interfaces';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
/**
|
||||
* SmartBrowser
|
||||
@@ -14,24 +14,37 @@ export class SmartBrowser {
|
||||
*/
|
||||
public async start() {
|
||||
this.headlessBrowser = await plugins.smartpuppeteer.getEnvAwareBrowserInstance();
|
||||
this.smartpdf = new plugins.smartpdf.SmartPdf();
|
||||
await this.smartpdf.start(this.headlessBrowser);
|
||||
// SmartPdf is lazy-initialized only when PDF methods are called
|
||||
}
|
||||
|
||||
/**
|
||||
* ensure SmartPdf is initialized (lazy)
|
||||
*/
|
||||
private async ensureSmartPdf() {
|
||||
if (!this.smartpdf) {
|
||||
this.smartpdf = new plugins.smartpdf.SmartPdf();
|
||||
await this.smartpdf.start(this.headlessBrowser);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* stop the SmartBrowser instance
|
||||
*/
|
||||
public async stop() {
|
||||
if (this.smartpdf) {
|
||||
await this.smartpdf.stop();
|
||||
this.smartpdf = null;
|
||||
}
|
||||
await this.headlessBrowser.close();
|
||||
await this.smartpdf.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* create a pdf from page
|
||||
* @param urlArg
|
||||
*/
|
||||
public pdfFromPage(urlArg: string) {
|
||||
const result = this.smartpdf.getFullWebsiteAsSinglePdf(urlArg);
|
||||
public async pdfFromPage(urlArg: string): Promise<plugins.smartpdf.IPdf> {
|
||||
await this.ensureSmartPdf();
|
||||
const result = await this.smartpdf.getFullWebsiteAsSinglePdf(urlArg);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -45,9 +58,10 @@ export class SmartBrowser {
|
||||
await page.goto(urlArg, {
|
||||
waitUntil: 'networkidle2',
|
||||
});
|
||||
const screenshotBuffer = await page.screenshot({
|
||||
const screenshotResult = await page.screenshot({
|
||||
encoding: 'binary',
|
||||
});
|
||||
const screenshotBuffer = Buffer.from(screenshotResult);
|
||||
await page.close();
|
||||
return {
|
||||
name: pageId,
|
||||
@@ -63,11 +77,17 @@ export class SmartBrowser {
|
||||
*/
|
||||
public async evaluateOnPage<T>(urlArg: string, funcArg: () => Promise<T>) {
|
||||
const page = await this.headlessBrowser.newPage();
|
||||
await page.goto(urlArg, {
|
||||
waitUntil: 'networkidle2',
|
||||
});
|
||||
const result = await page.evaluate(funcArg);
|
||||
await page.close();
|
||||
return result;
|
||||
try {
|
||||
await page.goto(urlArg, {
|
||||
waitUntil: 'networkidle2',
|
||||
});
|
||||
const result = await page.evaluate(funcArg);
|
||||
return result;
|
||||
} finally {
|
||||
try { await page.close(); } catch (e) { /* page may already be closed */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import { smartpuppeteer } from './smartbrowser.plugins.js';
|
||||
export { smartpuppeteer };
|
||||
@@ -1 +1 @@
|
||||
export * from './interfaces.screenshotresult';
|
||||
export * from './interfaces.screenshotresult.js';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// pushrocks scope
|
||||
import * as smartpdf from '@pushrocks/smartpdf';
|
||||
import * as smartpuppeteer from '@pushrocks/smartpuppeteer';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
import * as smartpdf from '@push.rocks/smartpdf';
|
||||
import * as smartpuppeteer from '@push.rocks/smartpuppeteer';
|
||||
import * as smartunique from '@push.rocks/smartunique';
|
||||
|
||||
export { smartpdf, smartpuppeteer, smartunique };
|
||||
|
||||
|
||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
17
tslint.json
17
tslint.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
||||
Reference in New Issue
Block a user