Compare commits

...

66 Commits

Author SHA1 Message Date
efda7c7b01 2.0.8 2025-01-03 00:14:04 +01:00
2110ab7325 fix(core): Ensure consistent browser automation functionality 2025-01-03 00:14:03 +01:00
445c9ae979 2.0.7 2025-01-02 22:22:04 +01:00
61d1a1c8df fix(dependencies): Update dependencies to latest versions. 2025-01-02 22:22:04 +01:00
79f9042665 update description 2024-05-29 14:11:51 +02:00
ce4dea816e update tsconfig 2024-04-14 17:21:37 +02:00
9354cd5bd3 update npmextra.json: githost 2024-04-01 21:33:53 +02:00
f360dade33 update npmextra.json: githost 2024-04-01 19:57:42 +02:00
9030ccde71 update npmextra.json: githost 2024-03-30 21:46:38 +01:00
2aa517a459 2.0.6 2023-09-11 10:18:46 +02:00
0fea2e6879 fix(core): update 2023-09-11 10:18:45 +02:00
0e6103cb58 switch to new org scheme 2023-07-11 00:14:54 +02:00
8dc697da1a switch to new org scheme 2023-07-10 02:42:14 +02:00
9615d7d0e3 2.0.5 2022-11-08 07:56:52 +01:00
431f63e283 fix(core): update 2022-11-08 07:56:52 +01:00
e9bf2032fb 2.0.4 2022-10-26 23:10:45 +02:00
3a2e85b4e5 fix(core): update 2022-10-26 23:10:45 +02:00
fdfa6a72c8 2.0.3 2022-10-26 23:00:44 +02:00
801416dc1e fix(core): update 2022-10-26 23:00:43 +02:00
84cf226d42 2.0.2 2022-03-25 01:19:21 +01:00
63f56da150 fix(core): update 2022-03-25 01:19:21 +01:00
3559453579 2.0.1 2022-03-24 23:41:51 +01:00
ea509d4246 fix(core): update 2022-03-24 23:41:51 +01:00
c13a125ac7 2.0.0 2022-03-24 14:58:00 +01:00
8f6949b1b8 1.0.23 2022-03-24 14:57:17 +01:00
9b698c6dea fix(core): update 2022-03-24 14:57:16 +01:00
157bcff7c4 1.0.22 2021-11-07 20:42:50 +01:00
934423f0ad fix(core): update 2021-11-07 20:42:49 +01:00
e6d7fdced6 1.0.21 2021-11-07 20:21:04 +01:00
2fc4e691ac fix(core): update 2021-11-07 20:21:03 +01:00
7e8035ea61 1.0.20 2021-04-29 15:26:08 +00:00
1bc3112bb7 fix(core): update 2021-04-29 15:26:08 +00:00
4a177fd166 1.0.19 2021-04-29 14:52:28 +00:00
c1cf019af2 fix(core): update 2021-04-29 14:52:28 +00:00
9ecf7c81d4 1.0.18 2020-08-12 16:31:55 +00:00
8fa40087d4 1.0.17 2020-06-01 20:25:33 +00:00
a5576410cd fix(core): update 2020-06-01 20:25:32 +00:00
dff08ed54b 1.0.16 2020-06-01 20:20:57 +00:00
fe4dd5c1ee fix(core): update 2020-06-01 20:20:57 +00:00
7f146b547f 1.0.15 2020-06-01 20:19:26 +00:00
4ee936035c fix(core): update 2020-06-01 20:19:25 +00:00
2e95f1db7f 1.0.14 2019-06-04 08:29:06 +02:00
35e5ded808 fix(core): update 2019-06-04 08:29:05 +02:00
f2430d095f 1.0.13 2019-06-03 17:17:20 +02:00
d79a5af51a fix(core): update 2019-06-03 17:17:20 +02:00
318bdd1bd8 1.0.12 2019-06-03 17:16:47 +02:00
54a0ec6c71 fix(core): update 2019-06-03 17:16:47 +02:00
8853eecbb9 1.0.11 2019-05-29 14:14:26 +02:00
1bfca4456c fix(core): update 2019-05-29 14:14:26 +02:00
b337e4c779 1.0.10 2019-05-29 08:57:17 +02:00
53d56d2d8a fix(core): update 2019-05-29 08:57:17 +02:00
e3781cfd4d 1.0.9 2019-05-28 23:29:25 +02:00
eca90bdf64 fix(core): update 2019-05-28 23:29:24 +02:00
b35b3f6c0b 1.0.8 2019-05-28 23:28:44 +02:00
d3509b8834 fix(core): update 2019-05-28 23:28:43 +02:00
246037aaae 1.0.7 2019-05-28 23:28:27 +02:00
3fc91bc0c1 fix(core): update 2019-05-28 23:28:26 +02:00
6c3991f6bc 1.0.6 2019-05-28 23:27:56 +02:00
cfcba1aa01 fix(core): update 2019-05-28 23:27:55 +02:00
b8a7f02b97 1.0.5 2017-04-09 16:05:27 +02:00
d6a7fd6c8c add .reload() 2017-04-09 16:05:24 +02:00
6e079e38c3 1.0.4 2017-04-09 13:05:13 +02:00
38d1aa5477 add npmextra.json 2017-04-09 13:05:10 +02:00
6f8ce94ae2 1.0.3 2017-04-09 12:45:32 +02:00
f3a78ba089 1.0.2 2017-04-09 12:35:58 +02:00
43bc078ace update to latest standards 2017-04-09 12:35:53 +02:00
30 changed files with 10360 additions and 386 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

21
.gitignore vendored
View File

@ -1,3 +1,20 @@
node_modules/
pages/
.nogit/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,34 +0,0 @@
image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
testLEGACY:
stage: test
script:
- npmci test legacy
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
tags:
- docker
release:
stage: release
environment: npm_registry
script:
- npmci publish
only:
- tags
tags:
- docker

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,20 +0,0 @@
# smartbrowser
easy class API for serving stacks during development with `browser-sync`.
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartbrowser)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartbrowser)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartbrowser)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartbrowser/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartbrowser/badges/master/build.svg)](https://gitlab.com/pushrocks/smartbrowser/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartbrowser/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartbrowser/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/smartbrowser.svg)](https://david-dm.org/pushrocks/smartbrowser)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartbrowser/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartbrowser/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartbrowser/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartbrowser)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

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

File diff suppressed because one or more lines are too long

View File

@ -1,88 +0,0 @@
TN:
SF:/Users/philkunz/gitlab/pushrocks/smartbrowser/dist/index.js
FN:3,(anonymous_1)
FN:3,defineProperties
FN:3,(anonymous_3)
FN:5,_classCallCheck
FN:12,(anonymous_5)
FN:13,Smartbrowser
FN:31,start
FN:36,(anonymous_8)
FN:40,(anonymous_9)
FN:47,(anonymous_10)
FN:59,stop
FNF:11
FNH:10
FNDA:1,(anonymous_1)
FNDA:1,defineProperties
FNDA:1,(anonymous_3)
FNDA:1,_classCallCheck
FNDA:1,(anonymous_5)
FNDA:1,Smartbrowser
FNDA:1,start
FNDA:1,(anonymous_8)
FNDA:1,(anonymous_9)
FNDA:0,(anonymous_10)
FNDA:1,stop
DA:3,2
DA:5,1
DA:7,1
DA:12,1
DA:13,1
DA:14,1
DA:16,1
DA:17,1
DA:20,1
DA:21,1
DA:22,1
DA:29,1
DA:32,1
DA:34,1
DA:35,1
DA:36,1
DA:37,1
DA:38,1
DA:39,1
DA:40,1
DA:41,1
DA:42,1
DA:43,1
DA:47,0
DA:48,0
DA:51,1
DA:60,1
DA:61,1
DA:62,1
DA:63,1
DA:64,1
DA:68,1
DA:71,1
LF:33
LH:31
BRDA:3,1,0,2
BRDA:3,1,1,2
BRDA:3,2,0,2
BRDA:3,2,1,0
BRDA:3,3,0,1
BRDA:3,3,1,0
BRDA:3,4,0,0
BRDA:3,4,1,1
BRDA:5,5,0,0
BRDA:5,5,1,1
BRDA:35,6,0,1
BRDA:35,6,1,0
BRF:12
BRH:7
end_of_record
TN:
SF:/Users/philkunz/gitlab/pushrocks/smartbrowser/dist/smartbrowser.plugins.js
FNF:0
FNH:0
DA:3,1
DA:4,1
DA:5,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record

32
dist/index.d.ts vendored
View File

@ -1,32 +0,0 @@
/// <reference types="browser-sync" />
/// <reference types="q" />
import * as plugins from './smartbrowser.plugins';
/**
* the options interface of a Smartbrowser instance
*/
export interface ISmartbrowserOptions {
webroot: string;
watchFiles: string[];
}
/**
* Type of status that a bsInstance can have
*/
export declare type bsStatus = 'idle' | 'starting' | 'running';
/**
* class smartbrowser controls a browser-sync instance for you
*/
export declare class Smartbrowser {
bsInstance: plugins.browserSync.BrowserSyncInstance;
bsConfig: plugins.browserSync.Options;
bsStatus: bsStatus;
bsStarted: plugins.q.Promise<void>;
constructor(optionsArg: ISmartbrowserOptions);
/**
* starts the server and returns the browserSync instance in a resolved Promise
*/
start(): plugins.q.Promise<plugins.browserSync.BrowserSyncInstance>;
/**
* stops the smartbrowser instance
*/
stop(): plugins.q.Promise<void>;
}

48
dist/index.js vendored
View File

@ -1,48 +0,0 @@
"use strict";
const plugins = require("./smartbrowser.plugins");
/**
* class smartbrowser controls a browser-sync instance for you
*/
class Smartbrowser {
constructor(optionsArg) {
this.bsInstance = plugins.browserSync.create();
this.bsConfig = {
server: {}
};
this.bsStatus = 'idle';
this.bsConfig.server.baseDir = optionsArg.webroot;
this.bsConfig.files = optionsArg.watchFiles;
}
/**
* starts the server and returns the browserSync instance in a resolved Promise
*/
start() {
let done = plugins.q.defer();
if (this.bsStatus === 'idle') {
this.bsStatus = 'starting';
let localDone = plugins.q.defer();
this.bsStarted = localDone.promise;
this.bsInstance.init(this.bsConfig, () => {
this.bsStatus = 'running';
localDone.resolve();
done.resolve(this.bsInstance);
});
}
else {
this.bsStarted.then(() => { done.resolve(this.bsInstance); });
}
return done.promise;
}
/**
* stops the smartbrowser instance
*/
stop() {
let done = plugins.q.defer();
this.bsInstance.exit();
this.bsStatus = 'idle';
done.resolve();
return done.promise;
}
}
exports.Smartbrowser = Smartbrowser;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsa0RBQWlEO0FBZ0JqRDs7R0FFRztBQUNIO0lBT0ksWUFBWSxVQUFnQztRQU41QyxlQUFVLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLEVBQUUsQ0FBQTtRQUN6QyxhQUFRLEdBQWdDO1lBQ3BDLE1BQU0sRUFBRSxFQUFFO1NBQ2IsQ0FBQTtRQUNELGFBQVEsR0FBYSxNQUFNLENBQUE7UUFHdkIsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxPQUFPLENBQUE7UUFDakQsSUFBSSxDQUFDLFFBQVEsQ0FBQyxLQUFLLEdBQUcsVUFBVSxDQUFDLFVBQVUsQ0FBQTtJQUMvQyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxLQUFLO1FBQ0QsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQTJDLENBQUE7UUFDckUsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsS0FBSyxNQUFNLENBQUMsQ0FBQyxDQUFDO1lBQzNCLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFBO1lBQzFCLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFRLENBQUE7WUFDdkMsSUFBSSxDQUFDLFNBQVMsR0FBRyxTQUFTLENBQUMsT0FBTyxDQUFBO1lBQ2xDLElBQUksQ0FBQyxVQUFVLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUU7Z0JBQ2hDLElBQUksQ0FBQyxRQUFRLEdBQUcsU0FBUyxDQUFBO2dCQUN6QixTQUFTLENBQUMsT0FBTyxFQUFFLENBQUE7Z0JBQ25CLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1lBQ2pDLENBQUMsQ0FBQyxDQUFBO1FBQ04sQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osSUFBSSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUUsUUFBUSxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQSxDQUFDLENBQUMsQ0FBQyxDQUFBO1FBQ2pFLENBQUM7UUFDRCxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtJQUN2QixDQUFDO0lBRUQ7O09BRUc7SUFDSCxJQUFJO1FBQ0EsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQVEsQ0FBQTtRQUNsQyxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksRUFBRSxDQUFBO1FBQ3RCLElBQUksQ0FBQyxRQUFRLEdBQUcsTUFBTSxDQUFBO1FBQ3RCLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNkLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7Q0FDSjtBQTFDRCxvQ0EwQ0MifQ==

View File

@ -1,3 +0,0 @@
import 'typings-global';
export import browserSync = require('browser-sync');
export import q = require('q');

View File

@ -1,5 +0,0 @@
"use strict";
require("typings-global");
exports.browserSync = require("browser-sync");
exports.q = require("q");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRicm93c2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGJyb3dzZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUFtRDtBQUNuRCx5QkFBOEIifQ==

28
npmextra.json Normal file
View File

@ -0,0 +1,28 @@
{
"npmci": {
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartbrowser",
"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"
]
}
},
"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,33 +1,61 @@
{
"name": "smartbrowser",
"version": "1.0.1",
"description": "wraps browser-sync",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"name": "@push.rocks/smartbrowser",
"version": "2.0.8",
"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": "(npmts)"
"test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany)",
"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": {
"@types/browser-sync": "0.0.32",
"@types/q": "0.0.30",
"browser-sync": "^2.16.0",
"q": "^1.4.1",
"typings-global": "^1.0.14"
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartpdf": "^3.1.8",
"@push.rocks/smartpuppeteer": "^2.0.0",
"@push.rocks/smartunique": "^3.0.9"
},
"devDependencies": {
"@types/should": "^8.1.29",
"npmts-g": "^5.2.8",
"should": "^11.1.0",
"typings-test": "^1.0.3"
}
"@git.zone/tsbuild": "^2.2.0",
"@git.zone/tsrun": "^1.3.3",
"@git.zone/tstest": "^1.0.90",
"@push.rocks/tapbundle": "^5.5.4",
"@types/node": "^22.10.4"
},
"private": false,
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
],
"keywords": [
"puppeteer",
"automation",
"testing",
"pdf generation",
"screenshot",
"web scraping",
"browser automation"
]
}

9722
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

114
readme.md Normal file
View File

@ -0,0 +1,114 @@
# @push.rocks/smartbrowser
simplified puppeteer
## Install
To install `@push.rocks/smartbrowser`, use the following npm command:
```bash
npm install @push.rocks/smartbrowser --save
```
This will add `@push.rocks/smartbrowser` to your project's dependencies.
## Usage
`@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.
### Getting Started
First, import `SmartBrowser` from `@push.rocks/smartbrowser`:
```typescript
import { SmartBrowser } from '@push.rocks/smartbrowser';
```
Then, initialize and start the `SmartBrowser` instance:
```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,6 +0,0 @@
<head>
<title>Test</title>
</head>
<body>
Test
</body>

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,33 +0,0 @@
"use strict";
require("typings-test");
const should = require("should");
const smartbrowser = require("../dist/index");
let testSmartBrowser;
describe('smartbrowser', () => {
it('should instanstiate a new browser ', function () {
testSmartBrowser = new smartbrowser.Smartbrowser({
webroot: './test/assets/',
watchFiles: ['./test/assets/']
});
should(testSmartBrowser).be.instanceof(smartbrowser.Smartbrowser);
});
it('should start the browser ', function (done) {
testSmartBrowser.start().then((bsInstance) => {
done();
}).catch((err) => { console.log(err); });
});
it('should stop the browser ', function (done) {
this.timeout(10000);
setTimeout(() => {
testSmartBrowser.stop().then(() => {
done();
}).catch((err) => { console.log(err); });
}, 2000);
});
it('should exit correctly', function () {
setTimeout(() => {
process.exit(0);
}, 2000);
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMsOENBQTZDO0FBRTdDLElBQUksZ0JBQTJDLENBQUE7QUFFL0MsUUFBUSxDQUFDLGNBQWMsRUFBRTtJQUNyQixFQUFFLENBQUMsb0NBQW9DLEVBQUU7UUFDckMsZ0JBQWdCLEdBQUcsSUFBSSxZQUFZLENBQUMsWUFBWSxDQUFDO1lBQzdDLE9BQU8sRUFBRSxnQkFBZ0I7WUFDekIsVUFBVSxFQUFFLENBQUMsZ0JBQWdCLENBQUM7U0FDakMsQ0FBQyxDQUFBO1FBQ0YsTUFBTSxDQUFDLGdCQUFnQixDQUFDLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxZQUFZLENBQUMsWUFBWSxDQUFDLENBQUE7SUFDckUsQ0FBQyxDQUFDLENBQUE7SUFDRixFQUFFLENBQUMsMkJBQTJCLEVBQUUsVUFBVSxJQUFJO1FBQzFDLGdCQUFnQixDQUFDLEtBQUssRUFBRSxDQUFDLElBQUksQ0FBQyxDQUFDLFVBQVU7WUFDckMsSUFBSSxFQUFFLENBQUE7UUFDVixDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxHQUFHLE9BQU8sT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQSxDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQzNDLENBQUMsQ0FBQyxDQUFBO0lBQ0YsRUFBRSxDQUFDLDBCQUEwQixFQUFFLFVBQVUsSUFBSTtRQUN6QyxJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO1FBQ25CLFVBQVUsQ0FBQztZQUNQLGdCQUFnQixDQUFDLElBQUksRUFBRSxDQUFDLElBQUksQ0FBQztnQkFDekIsSUFBSSxFQUFFLENBQUE7WUFDVixDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxHQUFHLE9BQU8sT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQSxDQUFDLENBQUMsQ0FBQyxDQUFBO1FBQzNDLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQTtJQUNaLENBQUMsQ0FBQyxDQUFBO0lBQ0YsRUFBRSxDQUFDLHVCQUF1QixFQUFDO1FBQ3ZCLFVBQVUsQ0FBQztZQUNQLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDbkIsQ0FBQyxFQUFDLElBQUksQ0FBQyxDQUFBO0lBQ1gsQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9

View File

@ -1,34 +1,36 @@
import 'typings-test'
import * as should from 'should'
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
import * as smartbrowser from '../dist/index'
import * as smartbrowser from '../ts/index.js';
let testSmartBrowser: smartbrowser.SmartBrowser;
let testSmartBrowser: smartbrowser.Smartbrowser
tap.test('should instanstiate a new browser ', async () => {
testSmartBrowser = new smartbrowser.SmartBrowser();
return expect(testSmartBrowser).toBeInstanceOf(smartbrowser.SmartBrowser);
});
describe('smartbrowser', () => {
it('should instanstiate a new browser ', function () {
testSmartBrowser = new smartbrowser.Smartbrowser({
webroot: './test/assets/',
watchFiles: ['./test/assets/']
})
should(testSmartBrowser).be.instanceof(smartbrowser.Smartbrowser)
})
it('should start the browser ', function (done) {
testSmartBrowser.start().then((bsInstance) => {
done()
}).catch((err) => { console.log(err) })
})
it('should stop the browser ', function (done) {
this.timeout(10000)
setTimeout(() => {
testSmartBrowser.stop().then(() => {
done()
}).catch((err) => { console.log(err) })
}, 2000)
})
it('should exit correctly',function(){
setTimeout(() => {
process.exit(0)
},2000)
})
})
tap.test('should start the browser ', async () => {
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).toBeInstanceOf(Buffer);
});
tap.test('should produce a valid screenshot', async (tools) => {
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
expect(result.buffer).toBeInstanceOf(Buffer);
});
tap.test('should evalute something in the browser', async () => {
const result = await testSmartBrowser.evaluateOnPage('https://lossless.com', async () => {
return window.location.toString();
});
console.log(result);
});
tap.test('should stop the browser ', async () => {
await testSmartBrowser.stop();
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

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

View File

@ -1,62 +1,76 @@
import * as plugins from './smartbrowser.plugins'
import * as plugins from './smartbrowser.plugins.js';
import * as interfaces from './interfaces/index.js';
/**
* the options interface of a Smartbrowser instance
* SmartBrowser
*/
export interface ISmartbrowserOptions {
webroot: string
watchFiles: string[]
export class SmartBrowser {
public headlessBrowser: plugins.smartpuppeteer.puppeteer.Browser;
public smartpdf: plugins.smartpdf.SmartPdf;
/**
* start the SmartBrowser instance
*/
public async start() {
this.headlessBrowser = await plugins.smartpuppeteer.getEnvAwareBrowserInstance();
this.smartpdf = new plugins.smartpdf.SmartPdf();
await this.smartpdf.start(this.headlessBrowser);
}
/**
* stop the SmartBrowser instance
*/
public async stop() {
await this.headlessBrowser.close();
await this.smartpdf.stop();
}
/**
* create a pdf from page
* @param urlArg
*/
public async pdfFromPage(urlArg: string): Promise<plugins.smartpdf.IPdf> {
const result = await this.smartpdf.getFullWebsiteAsSinglePdf(urlArg);
return result;
}
/**
* make a screenshot from a page
* @param urlArg
*/
public async screenshotFromPage(urlArg: string): Promise<interfaces.IScreenShotResult> {
const pageId = plugins.smartunique.shortId();
const page = await this.headlessBrowser.newPage();
await page.goto(urlArg, {
waitUntil: 'networkidle2',
});
const screenshotBuffer = (await page.screenshot({
encoding: 'binary',
})) as Buffer;
await page.close();
return {
name: pageId,
id: `${pageId}.js`,
buffer: screenshotBuffer,
};
}
/**
* evalutes an expression on a page
* @param urlArg
* @param funcArg
*/
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;
}
}
/**
* Type of status that a bsInstance can have
*/
export type bsStatus = 'idle' | 'starting' | 'running'
/**
* class smartbrowser controls a browser-sync instance for you
*/
export class Smartbrowser {
bsInstance = plugins.browserSync.create()
bsConfig: plugins.browserSync.Options = {
server: {}
}
bsStatus: bsStatus = 'idle'
bsStarted: plugins.q.Promise<void>
constructor(optionsArg: ISmartbrowserOptions) {
this.bsConfig.server.baseDir = optionsArg.webroot
this.bsConfig.files = optionsArg.watchFiles
}
/**
* starts the server and returns the browserSync instance in a resolved Promise
*/
start(): plugins.q.Promise<plugins.browserSync.BrowserSyncInstance> {
let done = plugins.q.defer<plugins.browserSync.BrowserSyncInstance>()
if (this.bsStatus === 'idle') {
this.bsStatus = 'starting'
let localDone = plugins.q.defer<void>()
this.bsStarted = localDone.promise
this.bsInstance.init(this.bsConfig, () => {
this.bsStatus = 'running'
localDone.resolve()
done.resolve(this.bsInstance)
})
} else {
this.bsStarted.then( () => { done.resolve(this.bsInstance) })
}
return done.promise
}
/**
* stops the smartbrowser instance
*/
stop(): plugins.q.Promise<void> {
let done = plugins.q.defer<void>()
this.bsInstance.exit()
this.bsStatus = 'idle'
done.resolve()
return done.promise
}
}
import { smartpuppeteer } from './smartbrowser.plugins.js';
export { smartpuppeteer };

1
ts/interfaces/index.ts Normal file
View File

@ -0,0 +1 @@
export * from './interfaces.screenshotresult.js';

View File

@ -0,0 +1,5 @@
export interface IScreenShotResult {
name: string;
id: string;
buffer: Buffer;
}

View File

@ -1,3 +1,8 @@
import 'typings-global'
export import browserSync = require('browser-sync')
export import q = require('q')
// pushrocks scope
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 };
// third party

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}