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

@pie-element/print-player

v1.0.1

Published

Print player for PIE elements - dynamically loads and renders print-friendly versions of PIE elements

Downloads

11

Readme

@pie-element/print-player

A web component that dynamically loads and renders PIE (Platform Independent Elements) in print-friendly mode.

Overview

The print player is a specialized, non-interactive version of the PIE element player. It:

  • Dynamically loads print modules from CDN or custom URLs
  • Registers print-specific custom elements
  • Transforms interactive element markup into print-friendly versions
  • Handles both embedded elements (in markup) and floater elements (like rubrics)
  • Provides graceful fallbacks for missing or failed elements

Installation

npm install @pie-element/print-player
# or
bun add @pie-element/print-player

Usage

Basic Example

<!DOCTYPE html>
<html>
  <head>
    <script type="module" src="https://cdn.jsdelivr.net/npm/@pie-element/[email protected]/dist/print-player.js"></script>
  </head>
  <body>
    <pie-print id="player"></pie-print>

    <script>
      const player = document.querySelector('#player');

      player.config = {
        item: {
          markup: '<multiple-choice id="q1"></multiple-choice>',
          elements: {
            'multiple-choice': '@pie-element/[email protected]'
          },
          models: [{
            id: 'q1',
            element: 'multiple-choice',
            prompt: 'What is 2 + 2?',
            choices: [
              { label: '3', value: 'a', correct: false },
              { label: '4', value: 'b', correct: true },
              { label: '5', value: 'c', correct: false }
            ]
          }]
        },
        options: {
          role: 'student' // or 'instructor' to show answers
        }
      };
    </script>
  </body>
</html>

Custom Resolver

Override the default CDN resolution to use custom URLs:

const player = document.querySelector('pie-print');

// Custom resolver for local development
player.resolve = (tagName, pkg) => {
  const [_, name, version] = pkg.match(/@pie-element\/(.*?)@(.*)/);
  return Promise.resolve({
    tagName,
    pkg,
    url: `http://localhost:3000/${name}/dist/print/index.js`,
    module: true
  });
};

player.config = { /* ... */ };

Multiple Items

You can use multiple <pie-print> elements on the same page:

<pie-print id="item-1"></pie-print>
<pie-print id="item-2"></pie-print>

<script>
  document.querySelector('#item-1').config = { /* item 1 config */ };
  document.querySelector('#item-2').config = { /* item 2 config */ };
</script>

Configuration

Config Object

interface Config {
  item: {
    markup: string;           // HTML with element placeholders
    elements: {               // Map of tag names to package@version
      [tagName: string]: string;
    };
    models: Array<{           // Element configurations
      id: string;             // Unique ID matching markup
      element: string;        // Element tag name
      [key: string]: any;     // Element-specific properties
    }>;
  };
  options?: {
    role?: 'student' | 'instructor';  // Affects answer visibility
  };
}

Role-Based Rendering

  • Student role: Shows questions only, no answers or rationales
  • Instructor role: Shows questions with correct answers and rationales
// Student worksheet
player.config = {
  item: { /* ... */ },
  options: { role: 'student' }
};

// Answer key
player.config = {
  item: { /* ... */ },
  options: { role: 'instructor' }
};

Architecture

How It Works

  1. Resolution: Converts element package names to CDN URLs
  2. Loading: Dynamically imports print modules as ES modules
  3. Registration: Registers custom elements with hash-suffixed names
  4. Transformation: Replaces interactive tags with print-specific tags
  5. Data Binding: Applies model data to rendered elements

Hash-Based Naming

Print elements are registered with unique names to avoid conflicts:

multiple-choice → multiple-choice-print-123456789

This allows multiple versions of the same element to coexist.

API

Properties

  • config: Config - Item configuration (reactive)
  • resolve: ResolverFn - Custom URL resolver function
  • missingElement: MissingElFn - Custom error placeholder factory

Events

None - the print player is purely presentational.

Browser Compatibility

  • Modern browsers with ES2020+ support
  • Custom Elements v1
  • ES Modules
  • Dynamic import()

Development

# Install dependencies
bun install

# Build
bun run build

# Watch mode
bun run dev

# Serve demo
bun run serve

Migration from @pie-framework/pie-print

This package is a drop-in replacement for @pie-framework/pie-print with:

  • Updated to Lit 3.x (from Lit 2.0 RC)
  • TypeScript support
  • Modern ESM packaging
  • Support for pie-elements-ng packages
  • Updated default CDN URLs

Change the script URL:

- <script type="module" src="https://cdn.jsdelivr.net/npm/@pie-framework/[email protected]/lib/pie-print.js"></script>
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@pie-element/[email protected]/dist/print-player.js"></script>

The API remains the same - no code changes needed!

License

MIT