Welcome to Puppanel - A simplified Puppeteer management interface! ๐
- ๐ Automatic browser lifecycle management
- โฒ๏ธ Built-in timeout controls with customizable durations
- ๐ฎ Simple and intuitive API
- ๐ก๏ธ TypeScript support out of the box
npm install puppanel
# or
yarn add puppanel
# or
pnpm add puppanel
import { PuppetManager } from 'puppanel';
// Create instance with default timeout (60 seconds)
const puppet = new PuppetManager();
// OR: Create instance with custom global timeout
const puppetWith2min = new PuppetManager({ defaultTimeout: 120 }); // 2 minutes
// Example: Create browser and navigate to a page
async function example() {
// Create new browser instance
const browserId = await puppet.createBrowser();
// Create new page
const page = await puppet.createPage(browserId);
// Use the page as you would with regular Puppeteer
await page.goto('https://example.com');
// Update timeout to a specific value (optional)
puppet.refreshTTL(browserId, 300); // Set 5 minutes for this instance
}
Puppanel offers three ways to control browser timeouts:
- Default Timeout (60 seconds)
const puppet = new PuppetManager();
- Custom Global Timeout
const puppet = new PuppetManager({
defaultTimeout: 180 // 3 minutes for all instances
});
- Per-Instance Timeout
const browserId = await puppet.createBrowser();
puppet.refreshTTL(browserId, 600); // 10 minutes for this instance
interface PuppetManagerOptions {
browserOptions?: LaunchOptions; // Puppeteer launch options
defaultTimeout?: number; // Time in seconds
}
class PuppetManager {
constructor(options?: PuppetManagerOptions);
createBrowser(): Promise<number>;
createPage(bid: number): Promise<Page>;
refreshTTL(bid: number, timeout?: number): void;
subscribeTTL(bid: number, callback: (timeToLive: number) => void): () => void;
destroyBrowser(bid: number): Promise<void>;
cleanup(): Promise<void>;
}
- Default timeout is 60 seconds if not specified
- Each page interaction automatically refreshes the TTL
- Use
cleanup()
when finished to prevent memory leaks - Timeout can be updated at any time using
refreshTTL()
Contributions are welcome! Feel free to submit a Pull Request.
MIT License - see the LICENSE file for details
Made with โค๏ธ by dark1zinn