npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kachik

v0.0.6

Published

Self-hosted Service for Taking Screenshots from Pages Powred by Playwright and Chromium.

Downloads

2

Readme

📷 Ka-chick

npm version npm downloads Github Actions Codecov

Using Kachik, you can easily create a self-hosted service for taking screenshots from pages. Powered by Playwright and Headless Chromium.

Ka-chick is read like "click" the sound taking a picture also is a village in Golestan, Iran.

Features

✅ Simple http and programmatic interfaces.

✅ Custom document selector and masks for taking screenshot.

✅ Strong cache support powered by unjs/unstorage.

✅ Remote URL and inline HMTL rendering

Warning Is is an experimental project. Do not use for production yet!

CLI Usage

$ npx kachik@latest
ℹ Kachik x.y.z
ℹ Cache directory: /.cache/kachik
  > Local:    http://localhost:3000/

Open this sample URL: http://localhost:3000/kachik/dark,s:.VPHome,m:.VPNav%2C.actions/https://vitejs.dev/

image

What it does:

  • Open a chromium browser
  • Navigates to https://vitejs.dev/
  • Emulated dark theme
  • Removes action buttons using .VPNav>.actions query selector
  • Uses .VPHome query selector to take a screenshot
  • Stores screenshot in cache for future requests and avoid rerendering

API

API is powered by unjs/h3.

/capture/:options/:url

Use this URL to take a screenshot of page. options are optional pairs seperated by , and :/= for value.

Possible options:

  • dark: Sets colorScheme to dark.
  • s: Document query selector. Default is body.
  • m: Query selector of masks to hide using display: none;

When you have no options, use _ in place. Example: https://mydomain/kachik/_/https://google.com.

Inline HTML

URL can be also an inline html. You need to prefix it with html: and ensure it is url encoded.

Example: http://localhost:3000/kachik/_/html:%3Ch1%20style=%22color:blue;display:flex;align-items:center%22%3EHelo%20World

/

When making a request to / endpoint, reponse is a JSON object showing kachik version of resource usage.

Programmatic Usage

Install library

# npm
npm install kachik

# yarn
yarn install kachik

# pnpm
pnpm install kachik

Kachik Instance

Instance of kachik is a lazy context that can be used to invoke other APIs:

import { createKachik } from 'kachik'
// const { createKachik } = require('kachik')

const kachik = createKachik({ options })

Options:

  • storage: Custom unjs/unstorage instance for caching.
  • browser: Either chromium, firefox or webkit. Default is chromium.
  • cacheDir: Filesystem cache directory. Default is .cache/kachik. Can be set to false to use in-memory cache. (Warning: In memory is currently infinity!)

kachik.screenshot(url, options?)

Using kachik.screenshot you can request to take a screenshot of a page:

import { writeFile } from 'node:fs/promises'

const buffer = await kachik.screenshot('http://google.com', { colorScheme: 'dark' })
await writeFile(buffer, 'screenshot.png')

Options:

  • colorScheme: (Optional) Emulates browser color scheme.
  • selector: (Optional) A valid query selector from the part of the page. Default is body.
  • mask: (Optional) A valid query selector to remove from page using display: none;

kachik.close()

When you had no use of kachik anymore, call close() to free up resources and memory.

// Dispose kachik resources
await kachik.close()

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable (use npm i -g corepack for Node.js < 16.10)
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛

Published under MIT License.