Skip to content

API reference / @jsprismarine/prismarine / addons/addonFiles

addons/addonFiles ​

Interfaces ​

AddonDeprecation ​

Defined in: packages/prismarine/src/addons/addonFiles.ts:58

Why an addon's author deprecated a version, as its index entry's listing says.

Properties ​

deprecated? ​

readonly optional deprecated?: string

Defined in: packages/prismarine/src/addons/addonFiles.ts:60

The author's reason, such as Use warps-plus instead.

replacedBy? ​

readonly optional replacedBy?: string

Defined in: packages/prismarine/src/addons/addonFiles.ts:62

The install id of the addon that replaces it.


AddonsFile ​

Defined in: packages/prismarine/src/addons/addonFiles.ts:116

addons.json.

Properties ​

addons ​

readonly addons: Readonly<Record<string, AddonRequest>>

Defined in: packages/prismarine/src/addons/addonFiles.ts:117


AddonsLockFile ​

Defined in: packages/prismarine/src/addons/addonFiles.ts:121

addons.lock.json.

Properties ​

addons ​

readonly addons: Readonly<Record<string, LockedAddon>>

Defined in: packages/prismarine/src/addons/addonFiles.ts:123

lockfileVersion ​

readonly lockfileVersion: 1

Defined in: packages/prismarine/src/addons/addonFiles.ts:122


ArchiveContents ​

Defined in: packages/prismarine/src/addons/addonFiles.ts:87

What an archive from a URL or a path installed: its packs, and the worlds it imported, which a reinstall of the same archive does not import again. A lock an older server wrote has neither.

Properties ​

packs? ​

readonly optional packs?: readonly LockedPack[]

Defined in: packages/prismarine/src/addons/addonFiles.ts:88

worlds? ​

readonly optional worlds?: readonly LockedWorld[]

Defined in: packages/prismarine/src/addons/addonFiles.ts:89


LockedPack ​

Defined in: packages/prismarine/src/addons/addonFiles.ts:66

One pack an archive installed, in the folder under the addon's it unpacked into.

Properties ​

folder ​

readonly folder: string

Defined in: packages/prismarine/src/addons/addonFiles.ts:68

Its folder inside the addon's, or . when the archive was this one pack.

type ​

readonly type: "behavior" | "resource"

Defined in: packages/prismarine/src/addons/addonFiles.ts:69

uuid ​

readonly uuid: string

Defined in: packages/prismarine/src/addons/addonFiles.ts:71

Its manifest header's UUID.

version ​

readonly version: string

Defined in: packages/prismarine/src/addons/addonFiles.ts:72


LockedWorld ​

Defined in: packages/prismarine/src/addons/addonFiles.ts:76

One world an archive imported, and the level it became.

Properties ​

level ​

readonly level: string

Defined in: packages/prismarine/src/addons/addonFiles.ts:80

The level's UUID, which levels.json records it under.

member ​

readonly member: string

Defined in: packages/prismarine/src/addons/addonFiles.ts:78

Where it sat in the archive, or an empty string for an archive that was the world.

Type Aliases ​

AddonRequest ​

AddonRequest = { name?: string; source: string; version: string; } | { url: string; } | { path: string; }

Defined in: packages/prismarine/src/addons/addonFiles.ts:49

What the owner asked for under one key.

Union Members ​

Type Literal ​

{ name?: string; source: string; version: string; }

An addon from a source's index; name defaults to the key.


Type Literal ​

{ url: string; }

An .mcpack at an https: URL.


Type Literal ​

{ path: string; }

A folder or an .mcpack on disk, relative to the server's folder unless absolute.


LockedAddon ​

LockedAddon = object & AddonDeprecation | object & ArchiveContents | object & ArchiveContents

Defined in: packages/prismarine/src/addons/addonFiles.ts:93

What one key resolved to and was installed from.

Variables ​

ADDONS_DIRECTORY ​

const ADDONS_DIRECTORY: "addons" = 'addons'

Defined in: packages/prismarine/src/addons/addonFiles.ts:38

The folder beside config.json that holds one folder per installed addon.


ADDONS_FILE ​

const ADDONS_FILE: "addons.json" = 'addons.json'

Defined in: packages/prismarine/src/addons/addonFiles.ts:29

The file that says which addons the owner asked for.


ADDONS_LOCKFILE_VERSION ​

const ADDONS_LOCKFILE_VERSION: 1 = 1

Defined in: packages/prismarine/src/addons/addonFiles.ts:35

The lockfile format this server writes and reads.


ADDONS_LOCK_FILE ​

const ADDONS_LOCK_FILE: "addons.lock.json" = 'addons.lock.json'

Defined in: packages/prismarine/src/addons/addonFiles.ts:32

The file that pins what each addon resolved to.


DEFAULT_ADDON_SOURCE ​

const DEFAULT_ADDON_SOURCE: "JSPrismarine/JSPrismarine" = 'JSPrismarine/JSPrismarine'

Defined in: packages/prismarine/src/addons/addonFiles.ts:41

The source a bare addon name installs from: JSPrismarine's own repository.

Functions ​

isAddonSource() ​

isAddonSource(source): boolean

Defined in: packages/prismarine/src/addons/addonFiles.ts:44

Whether a string names a GitHub repository, <owner>/<repo>.

Parameters ​

source ​

string

Returns ​

boolean


isHttpsUrl() ​

isHttpsUrl(url): boolean

Defined in: packages/prismarine/src/addons/addonFiles.ts:238

Whether a string is an https: URL.

Parameters ​

url ​

string

Returns ​

boolean


isPathLock() ​

isPathLock(locked): locked is { name: string; path: string; sha256?: string; version: string } & ArchiveContents

Defined in: packages/prismarine/src/addons/addonFiles.ts:131

Whether a locked addon was installed from a path on disk.

Parameters ​

locked ​

LockedAddon

Returns ​

locked is { name: string; path: string; sha256?: string; version: string } & ArchiveContents


isSourceLock() ​

isSourceLock(locked): locked is { name: string; sha256: string; source: string; url: string; version: string } & AddonDeprecation

Defined in: packages/prismarine/src/addons/addonFiles.ts:127

Whether a locked addon came from a source's index.

Parameters ​

locked ​

LockedAddon

Returns ​

locked is { name: string; sha256: string; source: string; url: string; version: string } & AddonDeprecation


parseAddonsFile() ​

parseAddonsFile(value): AddonsFile

Defined in: packages/prismarine/src/addons/addonFiles.ts:279

Validates a decoded addons.json.

Parameters ​

value ​

unknown

Returns ​

AddonsFile

Throws ​

When it breaks the format.


parseAddonsLockFile() ​

parseAddonsLockFile(value): AddonsLockFile

Defined in: packages/prismarine/src/addons/addonFiles.ts:290

Validates a decoded addons.lock.json.

Parameters ​

value ​

unknown

Returns ​

AddonsLockFile

Throws ​

When it breaks the format or has another lockfileVersion.


readAddonFiles() ​

readAddonFiles(directory): Promise<{ lock: AddonsLockFile; requested: AddonsFile; }>

Defined in: packages/prismarine/src/addons/addonFiles.ts:301

Both files, read from a server's folder; a missing file reads as empty.

Parameters ​

directory ​

string

Returns ​

Promise<{ lock: AddonsLockFile; requested: AddonsFile; }>


serializeAddonsFile() ​

serializeAddonsFile(requested): string

Defined in: packages/prismarine/src/addons/addonFiles.ts:317

addons.json as the server writes it: keys sorted, four-space indented, ending in a newline.

Parameters ​

requested ​

AddonsFile

Returns ​

string


serializeAddonsLockFile() ​

serializeAddonsLockFile(lock): string

Defined in: packages/prismarine/src/addons/addonFiles.ts:321

addons.lock.json as the server writes it: keys sorted, four-space indented, ending in a newline.

Parameters ​

lock ​

AddonsLockFile

Returns ​

string


writeAddonFiles() ​

writeAddonFiles(directory, requested, lock): Promise<void>

Defined in: packages/prismarine/src/addons/addonFiles.ts:339

Writes both files, addons.json first. A server stopped between the two writes finds a key that one of them lacks, and the next sync settles it the way the request says.

Parameters ​

directory ​

string

requested ​

AddonsFile

lock ​

AddonsLockFile

Returns ​

Promise<void>