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

@camptocamp/inkmap

v2.0.0

Published

A library for generating printable, high quality maps in the browser.

Readme

Live demo here!

Introduction

inkmap is based on OpenLayers and will generate maps in PNG format based on a given JSON specification.

inkmap can handle long-running jobs (e.g. A0 format in 300 dpi) and provides an API for following a job progress. It uses a service worker in the background provided the user browser supports OffscreenCanvas, and falls back (almost) seamlessly to the main thread if not.

Please note that the first version of inkmap has been entirely funded and supported by the French Ministry of Ecology as part of their Descartes web mapping toolkit, hosted here: https://adullact.net/projects/descartes/

Usage

Basic

To include the library in your project:

$ npm install --save @camptocamp/inkmap

Then import the different methods from the inkmap package:

import { print, downloadBlob } from '@camptocamp/inkmap';

print({
  layers: [ ... ],
  projection: 'EPSG:4326',
  ...
}).then(downloadBlob);

Advanced

inkmap offers advanced job monitoring through the use of Observables provided by the rxjs library.

Observables are different from Promises in that they can emit multiple values instead of just one, and are a very good fit for progress reporting.

To use an Observable, simply call its subscribe() method with a function as argument. The function will be called anytime a new value is emitted, like so:

import { getJobStatus } from '@camptocamp/inkmap';

...

getJobStatus(jobId).subscribe((jobStatus) => {
  // do something with the status
});

Note that for long-lived Observables (i.e. Observables that never completes) it is important to call unsubscribe() when the emitted values are not needed anymore. Open subscriptions to Observables might create memory leaks.

Enabling the service worker

inkmap can and will use a dedicated service worker for running print jobs if given the chance. This offers the following advantages:

  • Jobs run in a separate thread, meaning the user navigation will not be impacted at all by any CPU-intensive task
  • The service worker isn't tied to a window or tab, so jobs will continue running when the tab is closed (and even when the browser is closed, depending on the platform)
  • Push notifications might be sent to the user when a print job complete (not implemented yet)

To enable this, the inkmap-worker.js file located in the dist folder must be published on the same path as the application using inkmap.

The worker file can be published either using a symbolic link or by actually copying the file, for example in the application build pipeline.

If using Webpack to build the application, a solution is to use the CopyWebpackPlugin:

export default {
  ...
  plugins: [
     new CopyWebpackPlugin([
       {
         from: 'node_modules/@camptocamp/inkmap/dist/inkmap-worker.js',
         to: 'dist'
       },
     ]),
  ],
  ...
}

API

Important note: all API functions are named exports from the inkmap package.

See the API documentation website.

Architecture

Under the hood, inkmap will attempt to install a service worker on the page it is called. The service worker will then be in charge of loading all the map images and data, composing them together and giving them back to the application code.

Contributing

See CONTRIBUTING.

License

CeCILL-C