[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/script-host](https://jsprismarine.dev/api/@jsprismarine/script-host/index.md) / shape/implementations

# shape/implementations

## Classes

- [ScriptApiImplementations](https://jsprismarine.dev/api/@jsprismarine/script-host/shape/implementations/classes/ScriptApiImplementations.md)

## Interfaces

### AccessorImplementation

Defined in: [script-host/src/shape/implementations.ts:57](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L57)

A writable property's implementation. A half left out throws `NotImplementedError` when used.

#### Properties

##### get?

> `readonly` `optional` **get?**: [`MemberFunction`](#memberfunction)

Defined in: [script-host/src/shape/implementations.ts:58](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L58)

##### set?

> `readonly` `optional` **set?**: (`call`) => `void`

Defined in: [script-host/src/shape/implementations.ts:59](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L59)

###### Parameters

###### call

[`ScriptCall`](#scriptcall)

###### Returns

`void`

***

### GetterImplementation

Defined in: [script-host/src/shape/implementations.ts:52](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L52)

A read-only property's implementation.

#### Properties

##### get

> `readonly` **get**: [`MemberFunction`](#memberfunction)

Defined in: [script-host/src/shape/implementations.ts:53](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L53)

***

### ImplementationCoverage

Defined in: [script-host/src/shape/implementations.ts:146](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L146)

Implemented members over members, for one served version.

#### Properties

##### implemented

> `readonly` **implemented**: `number`

Defined in: [script-host/src/shape/implementations.ts:147](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L147)

##### total

> `readonly` **total**: `number`

Defined in: [script-host/src/shape/implementations.ts:148](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L148)

***

### ImplementationOptions

Defined in: [script-host/src/shape/implementations.ts:92](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L92)

How a member's implementation takes its arguments.

#### Properties

##### converts?

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

Defined in: [script-host/src/shape/implementations.ts:99](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L99)

The arguments, by their metadata names, that the implementation converts and checks itself.
The binding passes them on unchecked, for a member whose errors BDS words itself, such as
`setDynamicProperty`'s value, which refuses `NaN` with `Native variant type conversion
failed.` and nothing after it.

***

### ScriptCall

Defined in: [script-host/src/shape/implementations.ts:9](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L9)

One call from a script into a member's implementation.

#### Properties

##### args

> `readonly` **args**: readonly [`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue)[]

Defined in: [script-host/src/shape/implementations.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L39)

The arguments after the metadata's checks, with each omitted argument's default filled in.
A setter's one argument is the value. Handles last until the implementation returns.

##### engine

> `readonly` **engine**: [`ScriptEngine`](https://jsprismarine.dev/api/@jsprismarine/script-host/ScriptEngine/classes/ScriptEngine.md)

Defined in: [script-host/src/shape/implementations.ts:10](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L10)

##### pack

> `readonly` **pack**: `string`

Defined in: [script-host/src/shape/implementations.ts:12](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L12)

The pack whose script made the call, as its binding names it.

##### packId?

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

Defined in: [script-host/src/shape/implementations.ts:14](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L14)

The pack's stable identity, distinct even when two packs share a display name.

##### self

> `readonly` **self**: [`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue)

Defined in: [script-host/src/shape/implementations.ts:16](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L16)

The call's `this`: the instance, the class for a static member, or undefined for a module function.

##### state

> `readonly` **state**: `string`

Defined in: [script-host/src/shape/implementations.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L23)

The state the host gave `self` when it made the instance, or the one a constructor's
implementation returned: an empty string when it has none.

##### tag

> `readonly` **tag**: `number`

Defined in: [script-host/src/shape/implementations.ts:18](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L18)

The tag the host gave `self` when it made the instance, or 0. See `ScriptApiContext.create`.

#### Methods

##### setState()

> **setState**(`state`): `void`

Defined in: [script-host/src/shape/implementations.ts:25](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L25)

Replaces the state of `self`, for a member that changes its own object, such as `ItemStack.amount`.

###### Parameters

###### state

`string`

###### Returns

`void`

##### setStateOf()

> **setStateOf**(`value`, `state`): `void`

Defined in: [script-host/src/shape/implementations.ts:32](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L32)

Replaces the state of another object the host made, for a member that changes the object it
belongs to, such as an item stack's component writing its stack. Leaves any other value alone.

###### Parameters

###### value

[`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue)

###### state

`string`

###### Returns

`void`

##### stateOf()

> **stateOf**(`value`): `string`

Defined in: [script-host/src/shape/implementations.ts:27](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L27)

The state of an object the host made, such as a `BlockPermutation` argument; empty for any other value.

###### Parameters

###### value

[`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue)

###### Returns

`string`

##### stringify()

> **stringify**(`value`): `string` \| `undefined`

Defined in: [script-host/src/shape/implementations.ts:34](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L34)

A plain argument, such as a `Record` of block states, as JSON; undefined when it has none.

###### Parameters

###### value

[`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue)

###### Returns

`string` \| `undefined`

## Type Aliases

### Implementation

> **Implementation** = [`MemberFunction`](#memberfunction) \| [`GetterImplementation`](#getterimplementation) \| [`AccessorImplementation`](#accessorimplementation)

Defined in: [script-host/src/shape/implementations.ts:75](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L75)

Any member's implementation.

***

### ImplementationOf

> **ImplementationOf**\<`Slot`\> = `Slot` *extends* `"method"` \| `"constructor"` ? [`MemberFunction`](#memberfunction) : `Slot` *extends* `"getter"` ? [`GetterImplementation`](#getterimplementation) : `Slot` *extends* `"accessor"` ? [`AccessorImplementation`](#accessorimplementation) : `never`

Defined in: [script-host/src/shape/implementations.ts:66](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L66)

The implementation a member of each slot takes. A member whose slot changed between versions takes any of them.

#### Type Parameters

##### Slot

`Slot`

***

### MemberFunction

> **MemberFunction** = (`call`) => [`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue)

Defined in: [script-host/src/shape/implementations.ts:49](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L49)

A method's, constructor's or module function's behavior, or a property's getter.

A member whose metadata return type is plain data, an interface such as `Vector3` or an array
of plain values such as `string[]`, returns it as one JSON string, which the binding parses
inside the engine. A constructor may return a string, which becomes the new object's state.

#### Parameters

##### call

[`ScriptCall`](#scriptcall)

#### Returns

[`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue)

***

### MemberSlot

> **MemberSlot** = `"method"` \| `"constructor"` \| `"getter"` \| `"accessor"`

Defined in: [script-host/src/shape/implementations.ts:63](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L63)

How a member binds, as `ScriptApiMembers` records it.

***

### ScriptMemberName

> **ScriptMemberName**\<`Module`, `Owner`\> = keyof [`ScriptApiMembers`](https://jsprismarine.dev/api/@jsprismarine/script-host/generated/scriptApi/index.md#scriptapimembers)\[`Module`\]\[`Owner`\] & `string`

Defined in: [script-host/src/shape/implementations.ts:84](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L84)

A member of a class.

#### Type Parameters

##### Module

`Module` *extends* [`ScriptModuleName`](#scriptmodulename)

##### Owner

`Owner` *extends* [`ScriptOwnerName`](#scriptownername)\<`Module`\>

***

### ScriptModuleName

> **ScriptModuleName** = keyof [`ScriptApiMembers`](https://jsprismarine.dev/api/@jsprismarine/script-host/generated/scriptApi/index.md#scriptapimembers)

Defined in: [script-host/src/shape/implementations.ts:78](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L78)

A generated module name.

***

### ScriptOwnerName

> **ScriptOwnerName**\<`Module`\> = keyof [`ScriptApiMembers`](https://jsprismarine.dev/api/@jsprismarine/script-host/generated/scriptApi/index.md#scriptapimembers)\[`Module`\] & `string`

Defined in: [script-host/src/shape/implementations.ts:81](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L81)

A class of a module with members to implement, or `''` for its module-level functions.

#### Type Parameters

##### Module

`Module` *extends* [`ScriptModuleName`](#scriptmodulename)

## Functions

### implementationCoverage()

> **implementationCoverage**(`shape`, `implementations`): [`ImplementationCoverage`](#implementationcoverage)

Defined in: [script-host/src/shape/implementations.ts:156](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/shape/implementations.ts#L156)

Counts the members of a version that need behavior and how many have it: every method,
constructor and property of a class, an iterable class's `next`, and every module function.
Enums, constants, errors and interfaces need none.

#### Parameters

##### shape

[`ModuleShape`](https://jsprismarine.dev/api/@jsprismarine/script-host/shape/history/index.md#moduleshape)

##### implementations

[`ScriptApiImplementations`](https://jsprismarine.dev/api/@jsprismarine/script-host/shape/implementations/classes/ScriptApiImplementations.md)

#### Returns

[`ImplementationCoverage`](#implementationcoverage)
