Skip to content

dark1zinn/puppet-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3bdcd1d ยท Mar 19, 2025

History

14 Commits
Mar 19, 2025
Mar 19, 2025
Mar 14, 2025
Mar 13, 2025
Mar 14, 2025
Mar 13, 2025
Mar 19, 2025
Mar 15, 2025
Mar 15, 2025
Mar 13, 2025
Mar 19, 2025
Mar 15, 2025
Mar 13, 2025

Repository files navigation

puppet-manager

๐Ÿ“š Documentation

Welcome to Puppanel - A simplified Puppeteer management interface! ๐Ÿš€

๐ŸŽฏ Features

  • ๐Ÿ”„ Automatic browser lifecycle management
  • โฒ๏ธ Built-in timeout controls with customizable durations
  • ๐ŸŽฎ Simple and intuitive API
  • ๐Ÿ›ก๏ธ TypeScript support out of the box

๐Ÿ“ฅ Installation

npm install puppanel
# or
yarn add puppanel
# or
pnpm add puppanel

๐Ÿš€ Quick Start

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
}

โšก Timeout Management

Puppanel offers three ways to control browser timeouts:

  1. Default Timeout (60 seconds)
const puppet = new PuppetManager();
  1. Custom Global Timeout
const puppet = new PuppetManager({ 
  defaultTimeout: 180 // 3 minutes for all instances
});
  1. Per-Instance Timeout
const browserId = await puppet.createBrowser();
puppet.refreshTTL(browserId, 600); // 10 minutes for this instance

๐Ÿ› ๏ธ Complete API

PuppetManager

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>;
}

โš ๏ธ Important Notes

  1. Default timeout is 60 seconds if not specified
  2. Each page interaction automatically refreshes the TTL
  3. Use cleanup() when finished to prevent memory leaks
  4. Timeout can be updated at any time using refreshTTL()

๐Ÿค Contributing

Contributions are welcome! Feel free to submit a Pull Request.

๐Ÿ“ License

MIT License - see the LICENSE file for details


Made with โค๏ธ by dark1zinn

About

A simplified Puppeteer management interface

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published