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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pixpilot/chrome-lifecycle

v0.7.0

Published

Lifecycle management utilities for Chrome extensions.

Readme

@pixpilot/chrome-lifecycle

Utilities for managing Chrome extension lifecycle events.

Installation

npm install @pixpilot/chrome-lifecycle

API

Window Events

onWindowClose(windowId, callback)

Registers a callback when a specific Chrome window closes.

import { onWindowClose } from '@pixpilot/chrome-lifecycle';

const unsubscribe = onWindowClose(windowId, () => {
  console.log('Window closed');
});

// Stop listening
unsubscribe();

| Parameter | Type | Description | | ---------- | ------------ | ---------------------------- | | windowId | number | Chrome window ID to watch | | callback | () => void | Function to execute on close |

Returns: Unsubscribe function


Side Panel State Manager

Tracks whether side panels are visible or hidden across different windows.

Setup

This feature requires initialization in both your background script and side panel script.

1. Background script (service worker):

Call initSidePanelStateManager() at the top of your background script, before any other side panel functions. All other functions (getSidePanelStateForWindow, isWindowSidePanelVisible, onSidePanelStateChange) will throw an error if called before initialization.

// background.ts
import { initSidePanelStateManager } from '@pixpilot/chrome-lifecycle';

// ⚠️ Critical Setup
// Must be called first, before any other side panel functions
initSidePanelStateManager();

// Now you can use other functions

2. Side panel script (frontend):

Call initializeSidePanelStateTracker() when your side panel loads. This sets up visibility tracking and a heartbeat to keep the connection alive.

// sidepanel.ts
import { initializeSidePanelStateTracker } from '@pixpilot/chrome-lifecycle';

const cleanup = initializeSidePanelStateTracker();

// Optional: call cleanup() when done to remove listeners and disconnect

Functions

initSidePanelStateManager()

Initializes the backend state manager. Must be called once at the top of your background script before using any other side panel functions. Subsequent calls log a warning and are ignored.

initializeSidePanelStateTracker()

Initializes the frontend tracker in your side panel. Sets up visibility change detection and a heartbeat (every 15 seconds) to maintain the connection.

Returns: Cleanup function to remove listeners and disconnect

isWindowSidePanelVisible(windowId)

Returns true if the side panel is visible for the given window.

import { isWindowSidePanelVisible } from '@pixpilot/chrome-lifecycle';

const isVisible = isWindowSidePanelVisible(windowId);
getSidePanelStateForWindow(windowId)

Returns the current state ('visible' | 'hidden' | undefined) for the given window.

import { getSidePanelStateForWindow } from '@pixpilot/chrome-lifecycle';

const state = getSidePanelStateForWindow(windowId);
onSidePanelStateChange(listener)

Listens for side panel state changes across all windows.

import { onSidePanelStateChange } from '@pixpilot/chrome-lifecycle';

const unsubscribe = onSidePanelStateChange(({ windowId, state, reason }) => {
  console.log(`Window ${windowId}: ${state}`);
});

// Stop listening
unsubscribe();

Callback data:

| Property | Type | Description | | ---------- | ------------------------- | ------------------------- | | windowId | number | Chrome window ID | | state | 'visible' | 'hidden' | Current side panel state | | reason | string | What triggered the change |

Returns: Unsubscribe function