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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@drupal-canvas/extensions

v0.0.2

Published

API for building extensions for Drupal Canvas

Downloads

115

Readme

Drupal Canvas Extensions API

JavaScript library for building Drupal Canvas extensions. Extensions are embedded web applications that can access and respond to data inside the Drupal Canvas app in real-time.

Installation

npm install @drupal-canvas/extensions

Getting started

To build a Drupal Canvas extension, create a web application with your technology of choice, and make sure it can be embedded in an iframe.

Then create a Drupal module with a [your-module-name].canvas_extension.yml file to define your extension's metadata:

canvas_test_extension: # ID of your extension. You can specify multiple extensions in this file.
  name: Example Extension
  description: A brief description of what your example does.
  url: index.html # Path to local HTML file shipped in your module's codebase, or a remote URL.
  icon: icon.svg # Path to local SVG file shipped in your module's codebase.
  api_version: 1.0

Example

For a full example, see the canvas_test_extension test module in the Drupal Canvas codebase.

API

getPreviewHtml()

Get the current preview HTML.

Returns: Promise<string>

import { getPreviewHtml } from "@drupal-canvas/extensions";

const html = await getPreviewHtml();
console.log(html);

subscribeToPreviewHtml(callback)

Subscribe to preview HTML changes. The callback is called whenever the preview HTML updates.

Parameters:

  • callback: (html: string) => void - Function called with the updated HTML

Returns: () => void - Unsubscribe function

import { subscribeToPreviewHtml } from "@drupal-canvas/extensions";

const unsubscribe = subscribeToPreviewHtml((html) => {
  console.log("Preview HTML updated:", html);
});

// Later, when you want to stop listening:
unsubscribe();

getSelectedComponentUuid()

Get the UUID of the currently selected component.

Returns: Promise<string | undefined>

import { getSelectedComponentUuid } from "@drupal-canvas/extensions";

const uuid = await getSelectedComponentUuid();
if (uuid) {
  console.log("Selected component:", uuid);
} else {
  console.log("No component selected");
}

subscribeToSelectedComponentUuid(callback)

Subscribe to selected component UUID changes. The callback is called whenever the user selects a different component.

Parameters:

  • callback: (uuid: string | undefined) => void - Function called with the selected component UUID

Returns: () => void - Unsubscribe function

import { subscribeToSelectedComponentUuid } from "@drupal-canvas/extensions";

const unsubscribe = subscribeToSelectedComponentUuid((uuid) => {
  if (uuid) {
    console.log("Component selected:", uuid);
  } else {
    console.log("No component selected");
  }
});

// Later, when you want to stop listening:
unsubscribe();