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

chrome-types-helpers

v0.1.8

Published

Types helpers for Chrome extensions

Downloads

11

Readme

⚠️ If you're looking for TypeScript definitions for Chrome's extension types, you should depend on chrome-types!

This repository contains code to parse Chrome's internal extensions definitions, to generate both a JS model and publish TypeScript definition files. It itself is published at chrome-types-helpers, and you can depend on this to build the JS model. Its generated ".d.ts" file is published at chrome-types, and you can depend on it for type information for your Chrome extensions projects (MV3 and above).

Usage

This repository is mostly intended as an implementation detail of the https://developer.chrome.com site and for publishing chrome-types on NPM, which happens automaticalty as part of a GitHub Action.

However, if you'd like to build and consume the JS model of extensions are part of your project, you can depend on this project (published as chrome-types-helpers) and see its published types.

Requirements

This helper repository requires Node 14+ as well as a working version of Python 2.7+ installed on your system. Currently this has only been tested on Linux and macOS. The Python interpreter is used to convert Chromium's IDL files to JSON (see below).

Exports

This module exports a single helper function called prepareNamespaces which fetches Chromium's source code at head, and parses its internal types specifications and feature files (see below) to generate a JS model. You might use this to render information about Chrome's extension APIs (as we do on developer.chrome.com).

Tools

There's various tools under "bin/" which you can run as part of this repo if you check it out directly:

  • tsd.js: generates a ".d.ts" file for Chromium's extension types

    • This does not include Platform Apps and other deprecated APIs, and only renders APIs compatiable with MV3+)
  • history.js: fetches older versions of Chromium to find APIs that have changed over time

    • This generates (and accepts, to keep moving forward) a history JSON file that looks like this
  • prepare-types.js: is used internally to prepare a ".d.ts" and the history JSON for regular publish to NPM, and is probably not interesting to the public

    • It internally runs both scripts above

Design

The Chromium repository is read to generate types. Running tools in this codebase will give different results over time, as the tools point to the head of Chromium's codebase, which will change over time.

Types are generated from extensions/common/api and chrome/common/extensions/common/api, both of which contain extension specifications and feature files. The two folders exist to contain slightly different classes of extensions (Chrome-specific and more generic).

There's two main components in this repo, which are combined in interesting ways:

  • JSON parser for Chromium's internal types specification

    • Chromium also has types specified in IDL; these are converted to JSON before being parsed via Python script fetched as part of checking out Chromium
    • This generates a parsed JS model unique to this repo
  • Feature parser for Chromium's feature format

    • These features are heavily restricted to find APIs supported broadly (i.e., removing features that are limited to a specific extension whitelist or which require a command-line flag)
    • Features themselves can be simple, complex (multiple choices) and have multiple dependencies: they can be a graph of requirements that must all be met