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

# Class: ScriptHostLibrary

Defined in: [script-host/src/ScriptEngine.ts:145](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/ScriptEngine.ts#L145)

The script host's native library, bound for this thread. Engines run on the thread that loaded it.

## Methods

### close()

> **close**(): `void`

Defined in: [script-host/src/ScriptEngine.ts:180](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/ScriptEngine.ts#L180)

Unloads the library. Destroy its engines first.

#### Returns

`void`

***

### createEngine()

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

Defined in: [script-host/src/ScriptEngine.ts:175](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/ScriptEngine.ts#L175)

Creates an engine: one QuickJS runtime and context, with the globals BDS lacks removed and
`Function` from a string refused.

#### Parameters

##### options?

[`ScriptEngineOptions`](https://jsprismarine.dev/api/@jsprismarine/script-host/ScriptEngine/index.md#scriptengineoptions) = `{}`

Its limits and module loader.

#### Returns

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

The engine.

#### Throws

When the engine cannot be created.

***

### load()

> `static` **load**(`path?`): `ScriptHostLibrary`

Defined in: [script-host/src/ScriptEngine.ts:158](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/ScriptEngine.ts#L158)

Loads the library and checks that it speaks this binding's interface.

#### Parameters

##### path?

`string` = `...`

The library's file; [locateLibrary](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/library/index.md#locatelibrary-3) finds it when absent.

#### Returns

`ScriptHostLibrary`

The bound library.

#### Throws

When there is no library, or it speaks another interface.
