Compare commits

...

17 Commits

14 changed files with 8855 additions and 2984 deletions

View 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

View 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

View File

@ -1,141 +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
before_script:
- npm install -g @shipzone/npmci
# ====================
# 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
allow_failure: true
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

64
changelog.md Normal file
View File

@ -0,0 +1,64 @@
# Changelog
## 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

View File

@ -5,12 +5,24 @@
"gitzone": { "gitzone": {
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "code.foss.global",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartbrowser", "gitrepo": "smartbrowser",
"shortDescription": "puppeteer wrapper for easy tasks", "description": "A simplified Puppeteer wrapper for easy automation and testing tasks.",
"npmPackagename": "@pushrocks/smartbrowser", "npmPackagename": "@push.rocks/smartbrowser",
"license": "MIT" "license": "MIT",
} "keywords": [
"puppeteer",
"automation",
"testing",
"pdf generation",
"screenshot",
"web scraping",
"browser automation"
]
}
},
"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"
} }
} }

View File

@ -1,35 +1,37 @@
{ {
"name": "@pushrocks/smartbrowser", "name": "@push.rocks/smartbrowser",
"version": "2.0.3", "version": "2.0.8",
"description": "simplified puppeteer", "description": "A simplified Puppeteer wrapper for easy automation and testing tasks.",
"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",
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany)" "build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/smartbrowser.git" "url": "https://code.foss.global/push.rocks/smartbrowser.git"
}, },
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/smartbrowser/issues" "url": "https://gitlab.com/pushrocks/smartbrowser/issues"
}, },
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README", "homepage": "https://code.foss.global/push.rocks/smartbrowser",
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.13", "@push.rocks/smartdelay": "^3.0.5",
"@pushrocks/smartpdf": "^3.0.2", "@push.rocks/smartpdf": "^3.1.8",
"@pushrocks/smartpuppeteer": "^2.0.0", "@push.rocks/smartpuppeteer": "^2.0.0",
"@pushrocks/smartunique": "^3.0.3" "@push.rocks/smartunique": "^3.0.9"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.61", "@git.zone/tsbuild": "^2.2.0",
"@gitzone/tsrun": "^1.2.39", "@git.zone/tsrun": "^1.3.3",
"@gitzone/tstest": "^1.0.69", "@git.zone/tstest": "^1.0.90",
"@pushrocks/tapbundle": "^5.0.3" "@push.rocks/tapbundle": "^5.5.4",
"@types/node": "^22.10.4"
}, },
"private": false, "private": false,
"files": [ "files": [
@ -46,5 +48,14 @@
], ],
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
],
"keywords": [
"puppeteer",
"automation",
"testing",
"pdf generation",
"screenshot",
"web scraping",
"browser automation"
] ]
} }

11221
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

131
readme.md
View File

@ -1,39 +1,114 @@
# @pushrocks/smartbrowser # @push.rocks/smartbrowser
puppeteer wrapper for easy tasks simplified puppeteer
## Availabililty and Links ## Install
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartbrowser) To install `@push.rocks/smartbrowser`, use the following npm command:
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartbrowser)
* [github.com (source mirror)](https://github.com/pushrocks/smartbrowser)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartbrowser/)
## Status for master ```bash
npm install @push.rocks/smartbrowser --save
```
Status Category | Status Badge This will add `@push.rocks/smartbrowser` to your project's dependencies.
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartbrowser/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartbrowser/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartbrowser)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartbrowser)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartbrowser)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartbrowser)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartbrowser)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## Usage
Use TypeScript for best in class instellisense. `@push.rocks/smartbrowser` simplifies interactions with Puppeteer for tasks like generating PDFs or capturing screenshots from webpages. Below are examples illustrating how you can use `@push.rocks/smartbrowser` in your projects.
## 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). :) First, import `SmartBrowser` from `@push.rocks/smartbrowser`:
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) Then, initialize and start the `SmartBrowser` instance:
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) ```typescript
const smartBrowser = new SmartBrowser();
await smartBrowser.start();
```
### Generating a PDF from a Webpage
You can generate a PDF from any webpage URL. This can be particularly useful for generating reports, invoices, or snapshot captures of web content.
```typescript
// Generate a PDF from a page
const pdfResult = await smartBrowser.pdfFromPage('https://example.com');
console.log(pdfResult.buffer); // This holds the PDF file's buffer
```
### Capturing a Screenshot of a Webpage
Similarly, you can capture a screenshot of a webpage by passing the URL. This is useful for capturing the current state of a web application, for audits, or for keeping visual records.
```typescript
// Capture a screenshot from a page
const screenshotResult = await smartBrowser.screenshotFromPage('https://example.com');
console.log(screenshotResult.buffer); // This is the screenshot's buffer
```
### Evaluating JavaScript on a Webpage
`SmartBrowser` also allows you to evaluate JavaScript on the webpage. This can be useful for scraping data, testing web applications, or automating interactions with webpages.
```typescript
// Evaluate JavaScript on a page
const pageTitle = await smartBrowser.evaluateOnPage('https://example.com', () => {
return document.title; // Gets the title of the page
});
console.log(pageTitle); // Logs the page title to the console
```
### Shutting Down
Once your tasks are complete, it's important to properly shut down the `SmartBrowser` instance to free up resources:
```typescript
await smartBrowser.stop();
```
### Full Example
Combining the above steps, here's a full example of using `@push.rocks/smartbrowser` to generate a PDF and capture a screenshot of a webpage:
```typescript
import { SmartBrowser } from '@push.rocks/smartbrowser';
async function generateWebAssets() {
const smartBrowser = new SmartBrowser();
await smartBrowser.start();
const pdfResult = await smartBrowser.pdfFromPage('https://example.com');
console.log('PDF Generated:', pdfResult.buffer);
const screenshotResult = await smartBrowser.screenshotFromPage('https://example.com');
console.log('Screenshot Captured:', screenshotResult.buffer);
await smartBrowser.stop();
}
generateWebAssets();
```
In this guide, you've learned how to use `@push.rocks/smartbrowser` for common browser automation tasks. Follow this pattern to incorporate web automation into your applications efficiently.
## 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.

View File

@ -1,4 +1,4 @@
import { tap, expect, expectAsync } from '@pushrocks/tapbundle'; import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
import * as smartbrowser from '../ts/index.js'; import * as smartbrowser from '../ts/index.js';
let testSmartBrowser: smartbrowser.SmartBrowser; let testSmartBrowser: smartbrowser.SmartBrowser;

View File

@ -1,8 +1,8 @@
/** /**
* autocreated commitinfo by @pushrocks/commitinfo * autocreated commitinfo by @push.rocks/commitinfo
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smartbrowser', name: '@push.rocks/smartbrowser',
version: '2.0.3', version: '2.0.8',
description: 'simplified puppeteer' description: 'A simplified Puppeteer wrapper for easy automation and testing tasks.'
} }

View File

@ -30,7 +30,7 @@ export class SmartBrowser {
* create a pdf from page * create a pdf from page
* @param urlArg * @param urlArg
*/ */
public async pdfFromPage(urlArg: string) { public async pdfFromPage(urlArg: string): Promise<plugins.smartpdf.IPdf> {
const result = await this.smartpdf.getFullWebsiteAsSinglePdf(urlArg); const result = await this.smartpdf.getFullWebsiteAsSinglePdf(urlArg);
return result; return result;
} }
@ -45,9 +45,9 @@ export class SmartBrowser {
await page.goto(urlArg, { await page.goto(urlArg, {
waitUntil: 'networkidle2', waitUntil: 'networkidle2',
}); });
const screenshotBuffer = await page.screenshot({ const screenshotBuffer = (await page.screenshot({
encoding: 'binary', encoding: 'binary',
}) as Buffer; })) as Buffer;
await page.close(); await page.close();
return { return {
name: pageId, name: pageId,
@ -71,3 +71,6 @@ export class SmartBrowser {
return result; return result;
} }
} }
import { smartpuppeteer } from './smartbrowser.plugins.js';
export { smartpuppeteer };

View File

@ -1,7 +1,7 @@
// pushrocks scope // pushrocks scope
import * as smartpdf from '@pushrocks/smartpdf'; import * as smartpdf from '@push.rocks/smartpdf';
import * as smartpuppeteer from '@pushrocks/smartpuppeteer'; import * as smartpuppeteer from '@push.rocks/smartpuppeteer';
import * as smartunique from '@pushrocks/smartunique'; import * as smartunique from '@push.rocks/smartunique';
export { smartpdf, smartpuppeteer, smartunique }; export { smartpdf, smartpuppeteer, smartunique };

View File

@ -3,7 +3,12 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"useDefineForClassFields": false, "useDefineForClassFields": false,
"target": "ES2022", "target": "ES2022",
"module": "ES2022", "module": "NodeNext",
"moduleResolution": "nodenext" "moduleResolution": "NodeNext",
} "esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
} }