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

@plnkr/sdk

v1.0.0-pre.1

Published

A set of tools for interacting with the Plunker platform that allow you to:

Downloads

8

Readme

Plunker SDK

A set of tools for interacting with the Plunker platform that allow you to:

  1. Generate dynamic embedded Plunks and show these in target frames or mount these in target DOM elements.

Usage

Mount the embedded view of Plunker inside the 'embed' element with custom files, title and tags

import { showDynamicEmbed } from '@plnkr/sdk';

// Generate the files for the dynamic plunk. This could easily
// be generated on the fly by your application.
const files = [
    {
        pathname: 'index.html',
        content: '<h1>Hello world</h1>',
    },
];

showDynamicEmbed(
    {
        files,
        title: 'Hello world example',
        tags: ['hello', 'world'],
    },
    {
        deferRun: true, // Don't immediately run the preview
        show: ['index.html', 'preview'], // Open the index file and preview panes
        parentEl: 'embed', // Mount the embed in the #embed element
    }
);

Open the embedded view of Plunker in a new window with custom files, title and tags

import { showDynamicEmbed } from '@plnkr/sdk';

// Generate the files for the dynamic plunk. This could easily
// be generated on the fly by your application.
const files = [
    {
        pathname: 'index.html',
        content: '<h1>Hello world</h1>',
    },
];

showDynamicEmbed(
    {
        files,
        title: 'Hello world example',
        tags: ['hello', 'world'],
    },
    {
        deferRun: true, // Don't immediately run the preview
        show: ['index.html', 'preview'], // Open the index file and preview panes
        target: '_blank', // Mount the embed in the #embed element
    }
);

API

showDynamicEditor(projectSpec, options)

Create an embedded Plunk whose content is dynamically generated and either mount it to a DOM element or open it in a new or existing iframe / window where:

  • projectSpec - An object having the following properties:
    • files - An array of objects having the following properties:
      • pathname - The full path of the file.
      • content - The file's content.
      • encoding - (optional) The format in which the content is encoded (utf8 / base64).
    • title - (optional) The suggested title for the Plunk.
    • tags - (optional) An array of suggested string tags for the Plunk.
  • options - (optional) An object having the following properties:
    • editorUrl - (optional) The string url of the instance of the Plunker editor. This is useful for local testing.
    • parentEl - (optional) The string element id or the DOM element in which the embed should be mounted. This is useful for generating dynamic embeds that will be shown on the same page. This option is incompatible with the target option.
    • preview - (optional) A string representing the file that should be loaded in the default preview pane instead of using Plunker's own heuristics.
    • show - (optional) An array of strings representing panes to show. These strings can be pathnames (or partial pathnames, in which the best fuzzy match will be chosen) or the string 'preview' to show the preview pane. These panes will be opened in the order of the array from left to right.
    • sidebar - (optional) The sidebar pane to show by default. Can be the string 'tree' for the file tree or 'config' for the configuration pane.
    • target - (optional) The target frame in which the embed should be displayed. This can be the name of an <iframe>, for example, or the pseudo-targets _self or _blank. This option is incompatible with the parentEl option.

showDynamicEmbed(projectSpec, options)

Create an embedded Plunk whose content is dynamically generated and either mount it to a DOM element or open it in a new or existing iframe / window where:

  • projectSpec - An object having the following properties:
    • files - An array of objects having the following properties:
      • pathname - The full path of the file.
      • content - The file's content.
      • encoding - (optional) The format in which the content is encoded (utf8 / base64).
    • title - (optional) The suggested title for the Plunk.
    • tags - (optional) An array of suggested string tags for the Plunk.
  • options - (optional) An object having the following properties:
    • autoCloseSidebar - (optional) A boolean determining whether the sidebar should automatically close. This is useful if embedding in tighter constraints.
    • deferRun - (optional) A boolean determining whether the preview will automatically refresh on load (default, false) or whether the preview should require a user gesture to run (true).
    • embedUrl - (optional) The string url of the instance of the Plunker embed server. This is useful for local testing.
    • parentEl - (optional) The string element id or the DOM element in which the embed should be mounted. This is useful for generating dynamic embeds that will be shown on the same page. This option is incompatible with the target option.
    • preview - (optional) A string representing the file that should be loaded in the default preview pane instead of using Plunker's own heuristics.
    • show - (optional) An array of strings representing panes to show. These strings can be pathnames (or partial pathnames, in which the best fuzzy match will be chosen) or the string 'preview' to show the preview pane. These panes will be opened in the order of the array from left to right.
    • sidebar - (optional) The sidebar pane to show by default. Can be the string 'tree' for the file tree or 'config' for the configuration pane.
    • target - (optional) The target frame in which the embed should be displayed. This can be the name of an <iframe>, for example, or the pseudo-targets _self or _blank. This option is incompatible with the parentEl option.