Skip to content

API reference / @jsprismarine/addon-tools / addon

addon ​

Interfaces ​

Addon ​

Defined in: addon.ts:95

An addon read from its folder and checked.

Extends ​

Properties ​

authors? ​

readonly optional authors?: readonly string[]

Defined in: addon.ts:68

Who wrote the addon.

Inherited from ​

AddonMetadata.authors

deprecated? ​

readonly optional deprecated?: string

Defined in: addon.ts:72

Why the addon should no longer be installed; servers warn with it.

Inherited from ​

AddonMetadata.deprecated

description ​

readonly description: string

Defined in: addon.ts:58

A one-line description of what the addon does.

Inherited from ​

AddonMetadata.description

files ​

readonly files: ReadonlyMap<string, Uint8Array<ArrayBufferLike>>

Defined in: addon.ts:107

Every file the pack holds, by its path in the folder with / separators, in path order: every file but those under ADDON_MEDIA_DIRECTORY, and for a TypeScript addon those that build its scripts.

license ​

readonly license: string

Defined in: addon.ts:62

The addon's license, as an SPDX expression such as MIT.

Inherited from ​

AddonMetadata.license

media ​

readonly media: ReadonlyMap<string, Uint8Array<ArrayBufferLike>>

Defined in: addon.ts:109

The files under ADDON_MEDIA_DIRECTORY, by path, in path order.

minServer ​

readonly minServer: string

Defined in: addon.ts:60

The oldest JSPrismarine version the addon runs on, major.minor.patch.

Inherited from ​

AddonMetadata.minServer

name ​

readonly name: string

Defined in: addon.ts:97

The folder's name.

replacedBy? ​

readonly optional replacedBy?: string

Defined in: addon.ts:74

The install id of the addon that replaces this one, such as warps-plus or owner/repo/name.

Inherited from ​

AddonMetadata.replacedBy

screenshots? ​

readonly optional screenshots?: readonly AddonScreenshot[]

Defined in: addon.ts:70

Screenshots for the addon's page, in the order the page shows them.

Inherited from ​

AddonMetadata.screenshots

tags? ​

readonly optional tags?: readonly ("admin" | "chat" | "gameplay" | "performance" | "world")[]

Defined in: addon.ts:66

Tags from ADDON_TAGS, for the marketplace's filters.

Inherited from ​

AddonMetadata.tags

title ​

readonly title: string

Defined in: addon.ts:101

The addon's name for people: addon.json's title, the README's first heading or the manifest header's name.

Overrides ​

AddonMetadata.title

version ​

readonly version: string

Defined in: addon.ts:99

The manifest header's version, major.minor.patch.


AddonListingFiles ​

Defined in: addon.ts:125

The files a release attaches beside an addon's pack for its listing.

Properties ​

icon? ​

readonly optional icon?: AddonReleaseFile

Defined in: addon.ts:129

The pack's icon, <name>-<version>.png, when it has one.

readme ​

readonly readme: AddonReleaseFile

Defined in: addon.ts:127

The README, <name>-<version>.md.

screenshots ​

readonly screenshots: readonly (AddonReleaseFile & object)[]

Defined in: addon.ts:131

Each screenshot, <name>-<version>-<n> and its type, numbered from 1, with its path in the folder.


AddonMetadata ​

Defined in: addon.ts:56

What addon.json holds.

Extended by ​

Properties ​

authors? ​

readonly optional authors?: readonly string[]

Defined in: addon.ts:68

Who wrote the addon.

deprecated? ​

readonly optional deprecated?: string

Defined in: addon.ts:72

Why the addon should no longer be installed; servers warn with it.

description ​

readonly description: string

Defined in: addon.ts:58

A one-line description of what the addon does.

license ​

readonly license: string

Defined in: addon.ts:62

The addon's license, as an SPDX expression such as MIT.

minServer ​

readonly minServer: string

Defined in: addon.ts:60

The oldest JSPrismarine version the addon runs on, major.minor.patch.

replacedBy? ​

readonly optional replacedBy?: string

Defined in: addon.ts:74

The install id of the addon that replaces this one, such as warps-plus or owner/repo/name.

screenshots? ​

readonly optional screenshots?: readonly AddonScreenshot[]

Defined in: addon.ts:70

Screenshots for the addon's page, in the order the page shows them.

tags? ​

readonly optional tags?: readonly ("admin" | "chat" | "gameplay" | "performance" | "world")[]

Defined in: addon.ts:66

Tags from ADDON_TAGS, for the marketplace's filters.

title? ​

readonly optional title?: string

Defined in: addon.ts:64

The addon's name for people. Defaults to the README's first heading, then the manifest header's name.


AddonReleaseFile ​

Defined in: addon.ts:113

A file an addon's release attaches.

Properties ​

bytes ​

readonly bytes: Uint8Array

Defined in: addon.ts:116

fileName ​

readonly fileName: string

Defined in: addon.ts:115

The file's name on the release.

sha256 ​

readonly sha256: string

Defined in: addon.ts:118

The file's SHA-256, in lowercase hexadecimal.


AddonScreenshot ​

Defined in: addon.ts:48

A screenshot addon.json lists.

Properties ​

alt ​

readonly alt: string

Defined in: addon.ts:52

What the image shows, for a reader who cannot see it.

file ​

readonly file: string

Defined in: addon.ts:50

The image's path in the addon's folder, under ADDON_MEDIA_DIRECTORY.

Type Aliases ​

AddonPack ​

AddonPack = AddonReleaseFile

Defined in: addon.ts:122

An addon's .mcpack, named <name>-<version>.mcpack.


AddonTag ​

AddonTag = typeof ADDON_TAGS[number]

Defined in: addon.ts:36

One of ADDON_TAGS.

Variables ​

ADDON_FILES ​

const ADDON_FILES: readonly ["manifest.json", "addon.json", "README.md"]

Defined in: addon.ts:24

The files every addon folder has.


ADDON_ICON_FILE ​

const ADDON_ICON_FILE: "pack_icon.png" = 'pack_icon.png'

Defined in: addon.ts:42

The pack's icon, which Bedrock shows and the marketplace uses as the addon's icon.


ADDON_JSON_OPTIONAL_KEYS ​

const ADDON_JSON_OPTIONAL_KEYS: readonly ["title", "tags", "authors", "screenshots", "deprecated", "replacedBy"]

Defined in: addon.ts:85

The keys an addon.json may add for its listing and deprecation.


ADDON_JSON_REQUIRED_KEYS ​

const ADDON_JSON_REQUIRED_KEYS: readonly ["description", "minServer", "license"]

Defined in: addon.ts:78

The keys every addon.json has.


ADDON_MEDIA_DIRECTORY ​

const ADDON_MEDIA_DIRECTORY: "media" = 'media'

Defined in: addon.ts:39

The folder of an addon that holds its screenshots. The pack leaves it out.


ADDON_MODULE_TYPES ​

const ADDON_MODULE_TYPES: readonly string[]

Defined in: addon.ts:27

The manifest module types an addon may declare: a behavior pack's.


ADDON_SCREENSHOT_TYPES ​

const ADDON_SCREENSHOT_TYPES: readonly string[]

Defined in: addon.ts:45

The file types a screenshot may have.


ADDON_TAGS ​

const ADDON_TAGS: readonly ["admin", "chat", "gameplay", "performance", "world"]

Defined in: addon.ts:33

The tags an addon may list in addon.json, which the marketplace filters by. The list is fixed so that each filter collects every addon it should.

Functions ​

addonIndexEntry() ​

addonIndexEntry(addon, pack, baseUrl, listing?, commands?): AddonIndexEntry

Defined in: addon.ts:432

The index entry for an addon's pack, with the listing that names its listing files.

Parameters ​

addon ​

Addon

pack ​

AddonReleaseFile

baseUrl ​

string

Where the release's files download from; each file's name is added to it.

listing? ​

AddonListingFiles = ...

The addon's listing files, as addonListingFiles gives them.

commands? ​

readonly AddonCommand[]

The commands its scripts register, as readAddonCommands read them; left out when they could not be read.

Returns ​

AddonIndexEntry


addonListingFiles() ​

addonListingFiles(addon): AddonListingFiles

Defined in: addon.ts:404

The files a release attaches beside an addon's pack for the marketplace: its README, its icon and its screenshots, each named for the addon and version so a published version's files stay fixed.

Parameters ​

addon ​

Addon

Returns ​

AddonListingFiles


listingFileList() ​

listingFileList(files): AddonReleaseFile[]

Defined in: addon.ts:419

Every file of a listing, README first.

Parameters ​

files ​

AddonListingFiles

Returns ​

AddonReleaseFile[]


packAddon() ​

packAddon(addon): AddonReleaseFile

Defined in: addon.ts:387

Zips an addon into its .mcpack. Entries are stored in path order and dated 1980-01-01, so the same files always give the same bytes and the same hash, on any machine.

Parameters ​

addon ​

Addon

Returns ​

AddonReleaseFile


parseAddonMetadata() ​

parseAddonMetadata(addon, bytes): AddonMetadata

Defined in: addon.ts:175

Reads and checks an addon's addon.json: a description on one line, a minServer version and a license, each a non-empty string, the optional ADDON_JSON_OPTIONAL_KEYS in the shapes AddonMetadata gives, and no other keys.

Parameters ​

addon ​

string

The addon's name, for the error message.

bytes ​

Uint8Array

The file's contents.

Returns ​

AddonMetadata

Throws ​

InvalidAddonJson when the file breaks any of those rules.


readAddon() ​

readAddon(directory): Promise<Addon>

Defined in: addon.ts:356

Reads an addon from its folder and checks it: the folder's name is an addon name, the three ADDON_FILES are there, manifest.json is a behavior pack manifest whose modules carry the header's version, each script module's entry exists, addon.json follows AddonMetadata with no other keys, each screenshot it lists exists, and a ADDON_ICON_FILE is a square PNG.

Parameters ​

directory ​

string

The addon's folder.

Returns ​

Promise<Addon>

Throws ​

When any check fails.