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-players/pie-item-player

v0.3.26

Published

Unified custom element for rendering PIE items with iife/esm/preloaded strategies

Readme

@pie-players/pie-item-player

Unified custom element for rendering PIE assessment items. A single <pie-item-player> tag handles delivery, evaluation, and authoring through a mode attribute, and supports multiple loading strategies (iife, esm, preloaded).

This package replaces the legacy @pie-framework/pie-player-components project, which required separate <pie-player> and <pie-author> elements. See migration guide for details.

Install

npm install @pie-players/pie-item-player
# or
bun add @pie-players/pie-item-player

Or load from a CDN:

<script src="https://cdn.jsdelivr.net/npm/@pie-players/pie-item-player/dist/pie-item-player.js"></script>

The script self-registers the <pie-item-player> custom element.

Runtime boundary and migration

  • Browser-only package: @pie-players/pie-item-player is a DOM custom-element runtime package and is not intended for plain Node runtime imports.
  • Node-import-safe packages (for server/runtime utilities) are documented in docs/setup/library-packaging-strategy.md.
  • Migration direction:
    • Legacy migration from @pie-framework/pie-player-components remains documented.
    • For current hosts, prefer the stable default entrypoint:
import "@pie-players/pie-item-player";

Use explicit component subpath exports only when you need targeted registration control (for example the session debugger element export).

Standalone browser variants for this package are intentionally deferred; current support targets default bundler entrypoints under dist.

Quick start

<pie-item-player
  strategy="iife"
  config='{"elements":{"my-el":"[email protected]"},"models":[{"id":"1","element":"my-el"}],"markup":"<my-el id=\"1\"></my-el>"}'
  env='{"mode":"gather","role":"student"}'
  session='{"id":"s1","data":[]}'
></pie-item-player>

Custom elements

| Tag | Export | Description | |-----|--------|-------------| | pie-item-player | @pie-players/pie-item-player | Main player element | | pie-item-player-session-debugger | @pie-players/pie-item-player/components/item-session-debugger-element | Floating debug panel showing live session and filtered model data |

Attributes

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | config | Object | null | Item config with elements, models, and markup fields | | session | Object | { id: "", data: [] } | Session container | | env | Object | { mode: "gather", role: "student" } | Environment (mode + role) | | strategy | String | "iife" | Loading strategy: "iife", "esm", or "preloaded" | | mode | String | "view" | Player mode: "view" or "author" | | authoring-backend | String | "demo" | "demo" (built-in stubs) or "required" (host must provide handlers) | | hosted | Boolean | false | Whether running in hosted mode (affects IIFE bundle type) | | add-correct-response | Boolean | false | Populate correct responses on models | | show-bottom-border | Boolean | false | Add bottom border in evaluate mode | | debug | String | "" | Debug control: truthy enables verbose logs; "false"/"0"/"" disables (also reads window.PIE_DEBUG) | | custom-class-name | String | "" | CSS scope class applied to the player container | | container-class | String | "" | Extra class on the inner item container | | external-style-urls | String | "" | Comma-separated CSS URLs loaded and scoped to the player | | loader-config | Object | (default) | Loader instrumentation config | | configuration | Object | {} | Authoring configuration settings |

Properties (JS only)

These are set via JavaScript, not HTML attributes.

| Property | Type | Description | |----------|------|-------------| | loaderOptions | { bundleHost?: string, esmCdnUrl?: string, view?: string, loadControllers?: boolean } | Strategy-specific loader options |

Events

| Event | Detail | Description | |-------|--------|-------------| | load-complete | payload | Emitted when PIE elements finish loading | | session-changed | { session, ... } | Emitted when the student interacts and session data changes | | player-error | { code?, message? } | Error (e.g. AUTHORING_BACKEND_CONFIG_ERROR) | | model-updated | payload | Emitted when a PIE element model is updated |

Authoring media hooks

When mode="author", the player supports image and sound upload/delete through four handler properties:

| Property | Signature | |----------|-----------| | onInsertImage | (handler: ImageHandler) => void | | onDeleteImage | (src: string, done: (err?: Error) => void) => void | | onInsertSound | (handler: SoundHandler) => void | | onDeleteSound | (src: string, done: (err?: Error) => void) => void |

With authoring-backend="demo", built-in demo handlers are used. Set authoring-backend="required" to enforce that the host provides all four handlers; missing handlers will block the authoring UI and emit a player-error.

const el = document.querySelector("pie-item-player");
el.mode = "author";
el.authoringBackend = "required";

el.onInsertImage = (handler) => {
  handler.done(undefined, "https://example.com/uploaded-image.png");
};
el.onDeleteImage = (_src, done) => done();
el.onInsertSound = (handler) => {
  handler.done(undefined, "https://example.com/uploaded-sound.mp3");
};
el.onDeleteSound = (_src, done) => done();

Exported types

import type {
  PieItemPlayerElement,
  PieItemSessionDebuggerElement,
  AuthoringBackendMode,
  ImageHandler,
  SoundHandler,
  DeleteDone,
} from "@pie-players/pie-item-player";

Further reading