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

@dicetable/plugin-shell

v0.1.1

Published

Plugin Utilities for VTT-DiceTable Plugins

Downloads

1

Readme

DiceTable Plugin Shell

The plugin shell is used for creating plugins for the DiceTable-VTT.
This repository only exports one real type, the createWebpackConfig. All other exports are only included as types. They will be provided by the DiceTable-VTT. This is to ensure that the plugin itself is as small as possible, as the plugin is also saved inside the savestate.

Installation

It's a node package!

npm install @dicetable/plugin-shell

Usage

webpack.config.js

After installation, setup webpack to use the plugin shell. Basically add a file webpack.config.js to your project with the following content:

const createWebpackConfig = require("packages/plugin-shell/script/createWebpackConfig");

module.exports = createWebpackConfig(__dirname);

This will create a webpack config that will bundle your plugin and replace everything imported from the plugin shell with the global variables on the site.

For this to work, it reads your package.json. The following fields are used:

  • version (only in the resulting zip)
  • name (only in the resulting zip)

package.json

After that add the webpack-command to your package.json:

{
  "scripts": {
    "build": "webpack"
  }
}

You don't need to install webpack, as it is a dependency of the plugin shell.

src/manifest.json

Now add the manifest.json at src/manifest.json. This file contains infos about your plugin. The definition of the file can be found here. The PluginManifestType is also included inside the plugin-shell. A simple and complete manifest.json looks like this:

{
  "apiVersion": 1,
  "id": "com.example.unique.id",
  "label": {
    "en": "My Plugin",
    "de": "Mein Plugin"
  },
  "version": "1.0.0",
  "description": {
    "en": "This is my plugin",
    "de": "Das ist mein Plugin"
  },
  "dependencies": {
    "com.example.other.plugin.id": "^1.0.0"
  },
  "author": "My Name"
}

Only the fields apiVersion, id, label and version are required. All other fields are optional. The apiVersion is the version of the plugin api that is used. If the apiVersion of the plugin is not the same as the apiVersion of the DiceTable-VTT, a warning will be displayed to the user, that the plugin may not be working correctly.

The id is the unique identifier. It must not start with net.dicetable., as only official plugins can start with this prefix. Be sure to pick a unique id, as only one plugin with the same id can be installed at the same time!

The label is the name shown to the user. It is an object with the language as key. en is mandatory, but you can add as many languages as you want, although only languages that are supported by the DiceTable-VTT will be displayed. At the moment this is only en and de. The same goes for the description, where you can describe in more detail what your plugin does.

The version is a semver-version. It is used to check dependencies of the other plugins.

The dependencies is an object with the id of the plugin as key and the semver-version. If a plugin your plugin depends on is not installed, the user will get an error message while trying to install your plugin. At the same time, the user cannot uninstall your plugin as long as other plugins depending on your plugin are installed.

The author field is a string with your name. It will be shown to the user inside the plugin list.

src/index.ts

Now you can start writing your plugin. The entry point is src/index.ts. The basic structure of the file looks like this:

import { registerPlugin } from "@dicetable/plugin-shell";
import manifest from "./manifest.json";

registerPlugin(manifest.id, (api) => {

});

be sure to set resolveJsonModule to true inside your tsconfig.json, otherwise the manifest.json cannot be imported.

with help of the api-object you can add own windows, tools, data, token-objects and many more things to the DiceTable-VTT. The api-object is defined inside here

Example

You can find an example plugin here. This plugin adds the amor class to the token sheet and object.