[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/addon-tools](https://jsprismarine.dev/api/@jsprismarine/addon-tools/index.md) / addon

# addon

## Interfaces

### Addon

Defined in: [addon.ts:95](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L95)

An addon read from its folder and checked.

#### Extends

- [`AddonMetadata`](#addonmetadata)

#### Properties

##### authors?

> `readonly` `optional` **authors?**: readonly `string`[]

Defined in: [addon.ts:68](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L68)

Who wrote the addon.

###### Inherited from

[`AddonMetadata`](#addonmetadata).[`authors`](#authors-1)

##### deprecated?

> `readonly` `optional` **deprecated?**: `string`

Defined in: [addon.ts:72](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L72)

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

###### Inherited from

[`AddonMetadata`](#addonmetadata).[`deprecated`](#deprecated-1)

##### description

> `readonly` **description**: `string`

Defined in: [addon.ts:58](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L58)

A one-line description of what the addon does.

###### Inherited from

[`AddonMetadata`](#addonmetadata).[`description`](#description-1)

##### files

> `readonly` **files**: `ReadonlyMap`\<`string`, `Uint8Array`\<`ArrayBufferLike`\>\>

Defined in: [addon.ts:107](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L107)

Every file the pack holds, by its path in the folder with `/` separators, in path order:
every file but those under [ADDON\_MEDIA\_DIRECTORY](#addon-media-directory), and for a TypeScript addon those
that build its scripts.

##### license

> `readonly` **license**: `string`

Defined in: [addon.ts:62](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L62)

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

###### Inherited from

[`AddonMetadata`](#addonmetadata).[`license`](#license-1)

##### media

> `readonly` **media**: `ReadonlyMap`\<`string`, `Uint8Array`\<`ArrayBufferLike`\>\>

Defined in: [addon.ts:109](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L109)

The files under [ADDON\_MEDIA\_DIRECTORY](#addon-media-directory), by path, in path order.

##### minServer

> `readonly` **minServer**: `string`

Defined in: [addon.ts:60](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L60)

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

###### Inherited from

[`AddonMetadata`](#addonmetadata).[`minServer`](#minserver-1)

##### name

> `readonly` **name**: `string`

Defined in: [addon.ts:97](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L97)

The folder's name.

##### replacedBy?

> `readonly` `optional` **replacedBy?**: `string`

Defined in: [addon.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L74)

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

###### Inherited from

[`AddonMetadata`](#addonmetadata).[`replacedBy`](#replacedby-1)

##### screenshots?

> `readonly` `optional` **screenshots?**: readonly [`AddonScreenshot`](#addonscreenshot)[]

Defined in: [addon.ts:70](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L70)

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

###### Inherited from

[`AddonMetadata`](#addonmetadata).[`screenshots`](#screenshots-2)

##### tags?

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

Defined in: [addon.ts:66](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L66)

Tags from [ADDON\_TAGS](#addon-tags), for the marketplace's filters.

###### Inherited from

[`AddonMetadata`](#addonmetadata).[`tags`](#tags-1)

##### title

> `readonly` **title**: `string`

Defined in: [addon.ts:101](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L101)

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

###### Overrides

[`AddonMetadata`](#addonmetadata).[`title`](#title-1)

##### version

> `readonly` **version**: `string`

Defined in: [addon.ts:99](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L99)

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

***

### AddonListingFiles

Defined in: [addon.ts:125](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L125)

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

#### Properties

##### icon?

> `readonly` `optional` **icon?**: [`AddonReleaseFile`](#addonreleasefile)

Defined in: [addon.ts:129](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L129)

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

##### readme

> `readonly` **readme**: [`AddonReleaseFile`](#addonreleasefile)

Defined in: [addon.ts:127](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L127)

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

##### screenshots

> `readonly` **screenshots**: readonly ([`AddonReleaseFile`](#addonreleasefile) & `object`)[]

Defined in: [addon.ts:131](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L131)

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

***

### AddonMetadata

Defined in: [addon.ts:56](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L56)

What `addon.json` holds.

#### Extended by

- [`Addon`](#addon)

#### Properties

##### authors?

> `readonly` `optional` **authors?**: readonly `string`[]

Defined in: [addon.ts:68](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L68)

Who wrote the addon.

##### deprecated?

> `readonly` `optional` **deprecated?**: `string`

Defined in: [addon.ts:72](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L72)

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

##### description

> `readonly` **description**: `string`

Defined in: [addon.ts:58](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L58)

A one-line description of what the addon does.

##### license

> `readonly` **license**: `string`

Defined in: [addon.ts:62](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L62)

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

##### minServer

> `readonly` **minServer**: `string`

Defined in: [addon.ts:60](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L60)

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

##### replacedBy?

> `readonly` `optional` **replacedBy?**: `string`

Defined in: [addon.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L74)

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

##### screenshots?

> `readonly` `optional` **screenshots?**: readonly [`AddonScreenshot`](#addonscreenshot)[]

Defined in: [addon.ts:70](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L70)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L66)

Tags from [ADDON\_TAGS](#addon-tags), for the marketplace's filters.

##### title?

> `readonly` `optional` **title?**: `string`

Defined in: [addon.ts:64](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L64)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L113)

A file an addon's release attaches.

#### Properties

##### bytes

> `readonly` **bytes**: `Uint8Array`

Defined in: [addon.ts:116](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L116)

##### fileName

> `readonly` **fileName**: `string`

Defined in: [addon.ts:115](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L115)

The file's name on the release.

##### sha256

> `readonly` **sha256**: `string`

Defined in: [addon.ts:118](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L118)

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

***

### AddonScreenshot

Defined in: [addon.ts:48](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L48)

A screenshot `addon.json` lists.

#### Properties

##### alt

> `readonly` **alt**: `string`

Defined in: [addon.ts:52](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L52)

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

##### file

> `readonly` **file**: `string`

Defined in: [addon.ts:50](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L50)

The image's path in the addon's folder, under [ADDON\_MEDIA\_DIRECTORY](#addon-media-directory).

## Type Aliases

### AddonPack

> **AddonPack** = [`AddonReleaseFile`](#addonreleasefile)

Defined in: [addon.ts:122](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L122)

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

***

### AddonTag

> **AddonTag** = *typeof* [`ADDON_TAGS`](#addon-tags)\[`number`\]

Defined in: [addon.ts:36](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L36)

One of [ADDON\_TAGS](#addon-tags).

## Variables

### ADDON\_FILES

> `const` **ADDON\_FILES**: readonly \[`"manifest.json"`, `"addon.json"`, `"README.md"`\]

Defined in: [addon.ts:24](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L24)

The files every addon folder has.

***

### ADDON\_ICON\_FILE

> `const` **ADDON\_ICON\_FILE**: `"pack_icon.png"` = `'pack_icon.png'`

Defined in: [addon.ts:42](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L42)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L85)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L78)

The keys every `addon.json` has.

***

### ADDON\_MEDIA\_DIRECTORY

> `const` **ADDON\_MEDIA\_DIRECTORY**: `"media"` = `'media'`

Defined in: [addon.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L39)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L27)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L45)

The file types a screenshot may have.

***

### ADDON\_TAGS

> `const` **ADDON\_TAGS**: readonly \[`"admin"`, `"chat"`, `"gameplay"`, `"performance"`, `"world"`\]

Defined in: [addon.ts:33](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L33)

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`](https://jsprismarine.dev/api/@jsprismarine/addon-tools/addonIndex/index.md#addonindexentry)

Defined in: [addon.ts:432](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L432)

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

#### Parameters

##### addon

[`Addon`](#addon)

##### pack

[`AddonReleaseFile`](#addonreleasefile)

##### baseUrl

`string`

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

##### listing?

[`AddonListingFiles`](#addonlistingfiles) = `...`

The addon's listing files, as [addonListingFiles](#addonlistingfiles-1) gives them.

##### commands?

readonly [`AddonCommand`](https://jsprismarine.dev/api/@jsprismarine/addon-tools/addonIndex/index.md#addoncommand)[]

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

#### Returns

[`AddonIndexEntry`](https://jsprismarine.dev/api/@jsprismarine/addon-tools/addonIndex/index.md#addonindexentry)

***

### addonListingFiles()

> **addonListingFiles**(`addon`): [`AddonListingFiles`](#addonlistingfiles)

Defined in: [addon.ts:404](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L404)

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`](#addon)

#### Returns

[`AddonListingFiles`](#addonlistingfiles)

***

### listingFileList()

> **listingFileList**(`files`): [`AddonReleaseFile`](#addonreleasefile)[]

Defined in: [addon.ts:419](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L419)

Every file of a listing, README first.

#### Parameters

##### files

[`AddonListingFiles`](#addonlistingfiles)

#### Returns

[`AddonReleaseFile`](#addonreleasefile)[]

***

### packAddon()

> **packAddon**(`addon`): [`AddonReleaseFile`](#addonreleasefile)

Defined in: [addon.ts:387](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L387)

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`](#addon)

#### Returns

[`AddonReleaseFile`](#addonreleasefile)

***

### parseAddonMetadata()

> **parseAddonMetadata**(`addon`, `bytes`): [`AddonMetadata`](#addonmetadata)

Defined in: [addon.ts:175](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L175)

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](#addon-json-optional-keys) in the
shapes [AddonMetadata](#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`](#addonmetadata)

#### Throws

`InvalidAddonJson` when the file breaks any of those rules.

***

### readAddon()

> **readAddon**(`directory`): `Promise`\<[`Addon`](#addon)\>

Defined in: [addon.ts:356](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/addon-tools/src/addon.ts#L356)

Reads an addon from its folder and checks it: the folder's name is an addon name, the three
[ADDON\_FILES](#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](#addonmetadata) with no other keys, each screenshot it lists exists, and a
[ADDON\_ICON\_FILE](#addon-icon-file) is a square PNG.

#### Parameters

##### directory

`string`

The addon's folder.

#### Returns

`Promise`\<[`Addon`](#addon)\>

#### Throws

When any check fails.
