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

scastie.js

v0.0.2

Published

Web component to add compilation results to Scala code snippets through Scastie

Downloads

2

Readme

NPM version

scastie.js

Component that adds the capability to run Scala code from any HTML block element. The compilation results will be shown in a console simulation shown under the code block. The Scala code runs through Scastie, an interactive web browser playground for Scala supported by the Scala Center.

Preview

scastie.js preview

Develop and contribute

From this repository:

  1. Install required dependencies: npm install.
  2. npm start to start a local development server at http://localhost:8080.

Release

  1. Update version in package.json and create tag.
  2. npm run build:production to create production bundles.
  3. npm publish --dry-run to check the publication
  4. npm login
  5. npm publish

Installation

Load it from a CDN

Generate the library through the proper npm script, then host it and insert a <script> element into your page Currently, after loading you need an additional process to execute the plugin, using a second <script> element. Like this:

<script src="https://unpkg.com/scastie.js"></script>

<script>
  document.addEventListener("DOMContentLoaded", function () {
    scastie_js();
  });
</script>

Host your own instance

Install scastie.js as dependency via NPM.

npm install scastie.js -S

And then just use it in your code.

// ES5
var scastie_js = require("scastie.js");

document.addEventListener("DOMContentLoaded", function () {
  scastie_js({selector: "code"}); // attach to all <code> elements
});

// ES6
import playground from "scastie.js";

document.addEventListener("DOMContentLoaded", () => {
  scastie_js({selector: "code"}); // attach to all <code> elements
});

Options and configuration

scastie.js supports different options, overwriting the defaults by passing an additional configuration object parameter on initialisation. You can define all or any of them, the rest will be taking defaults.

For example:

const config = {
  selector: "pre code",
  target: {
    scalaVersion: "2.13.10",
    tpe: "Jvm"
  },
  libraries: [
    {
      groupId: "com.twitter",
      artifact: "util-core",
      version: "22.12.0",
      target: {
        scalaVersion: "2.13.10",
        tpe: "Jvm"
      }
    }
  ],
  theme: {
    primary: "#002b36",
    secondary: "#aaa",
    console: "#555555", 
    borderRadius: "2px"
  }
};

scastie_js(config);

Most of these values could be configured per each code snippet through a basic user interface by clicking the Options button.

Options description:

  • selector — The HTML DOM query selector defining the elements where scastie.js should run on, e.g:

    {
      selector: ".code-block-class-selector"
    }
  • target — Scala version to compile the code to. tpe could be Scala3, Jvm, Js. e.g:

    {
      target: {
        scalaVersion: "3.2.2",
        tpe: "Scala3"
      }
    }
  • libraries — Array of dependency libraries to load on your compilation. Bear in mind that, besides the general build, you need to specify the Scala target for each additional dependency, e.g:

    {
      libraries: [
        {
          groupId: "com.twitter",
          artifact: "util-core",
          version: "22.12.0",
          target: {
            scalaVersion: "2.13.10",
            tpe: "Jvm"
          }
        }
    }
  • theme — Some options to adapt the look and feel of the few elements that scastie.js renders, e.g:

    • primary — Text and buttons outline colour.
    • secondary — Buttons background colour.
    • console — Console background colour.
    • borderRadius — Elements border radius (buttons, dialog, inputs).
    {
      theme: {
        primary: "#002b36",
        secondary: "#aaa",
        console: "#555555", 
        borderRadius: "2px"
      }
    }