Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules/
dist/
*.log
.DS_Store
.idea/
.vscode/
*.swp
*.swo
*~
.cache/
tmp/
temp/
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 KarinJS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,73 @@
# shared-browser

A unified browser downloader for Puppeteer and Playwright.

## Features

- 🚀 Unified browser management for both Puppeteer and Playwright
- 📦 Browser download and caching with official logic
- 🔍 Browser discovery and path resolution
- 💾 Efficient browser caching mechanism
- 🌐 Support for multiple platforms (Windows, macOS, Linux)
- 📝 Full TypeScript support with TSDoc comments

## Installation

```bash
npm install @karinjs/shared-browser
# or
pnpm add @karinjs/shared-browser
# or
yarn add @karinjs/shared-browser
```

## Requirements

- Node.js >= 18.0.0
- pnpm 9.x (recommended for development)

## Usage

### For Puppeteer

```typescript
import { puppeteer } from '@karinjs/shared-browser';

// Find installed browser
const browserPath = await puppeteer.findBrowser();

// Get download path
const downloadPath = puppeteer.getDownloadPath();

// Download browser
await puppeteer.downloadBrowser({
revision: '123456',
progressCallback: (progress) => {
console.log(`Downloaded: ${progress}%`);
}
});
```

### For Playwright

```typescript
import { playwright } from '@karinjs/shared-browser';

// Find installed browser
const browserPath = await playwright.findBrowser('chromium');

// Get download path
const downloadPath = playwright.getDownloadPath('chromium');

// Download browser
await playwright.downloadBrowser({
browser: 'chromium',
progressCallback: (progress) => {
console.log(`Downloaded: ${progress}%`);
}
});
```

## License

MIT
Loading