[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/native-worldgen](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/index.md) / library

# library

## Variables

### LIBRARY\_ENV

> `const` **LIBRARY\_ENV**: `string` = `nativeWorldgenLibrary.libraryEnv`

Defined in: [library.ts:25](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/library.ts#L25)

The environment variable that names a library file to load in place of the installed build.

***

### LIBRARY\_ENV

> `const` **LIBRARY\_ENV**: `string` = `scriptHostLibrary.libraryEnv`

Defined in: [script-host/src/library.ts:26](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/library.ts#L26)

The environment variable that names a library file to load in place of the installed build.

***

### PACKAGE\_NAME

> `const` **PACKAGE\_NAME**: `string` = `scriptHostLibrary.packageName`

Defined in: [script-host/src/library.ts:29](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/library.ts#L29)

The npm package's name, as the messages name it.

***

### nativeWorldgenLibrary

> `const` **nativeWorldgenLibrary**: [`NativeLibrary`](https://jsprismarine.dev/api/@jsprismarine/native-library/NativeLibrary/classes/NativeLibrary.md)

Defined in: [library.ts:15](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/library.ts#L15)

The package's native library: its name, its environment variables and its published builds.

***

### scriptHostLibrary

> `const` **scriptHostLibrary**: [`NativeLibrary`](https://jsprismarine.dev/api/@jsprismarine/native-library/NativeLibrary/classes/NativeLibrary.md)

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

The package's native library: its name, its environment variables and its published builds.

## Functions

### approvalAdvice()

> **approvalAdvice**(`platform`): `string`

Defined in: [script-host/src/library.ts:43](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/library.ts#L43)

What to tell a user whose install did not fetch the library: the package managers that hold
install scripts back, how to let this one run, and the way around it.

#### Parameters

##### platform

`string`

The platform key.

#### Returns

`string`

The advice, as sentences.

***

### bundledManifest()

> **bundledManifest**(): [`NativeManifest`](https://jsprismarine.dev/api/@jsprismarine/native-library/manifest/index.md#nativemanifest)

Defined in: [script-host/src/library.ts:35](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/library.ts#L35)

The manifest this package was built with. It is imported, not read from disk, so a bundled
executable carries it.

#### Returns

[`NativeManifest`](https://jsprismarine.dev/api/@jsprismarine/native-library/manifest/index.md#nativemanifest)

***

### installedLibraryPath()

> **installedLibraryPath**(`packageDir`, `platform?`): `string`

Defined in: [script-host/src/library.ts:80](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/library.ts#L80)

Where a platform's library goes in the package, whether `build:native` built it or the install
script downloaded it.

#### Parameters

##### packageDir

`string`

The package's directory.

##### platform?

`string`

The platform key; this machine's by default.

#### Returns

`string`

`prebuilds/<platform>/<library>` under it.

***

### locateLibrary()

> **locateLibrary**(`options?`): `string`

Defined in: [library.ts:35](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/library.ts#L35)

Where the library for this machine is, checked against its published digest: the file
`JSP_NATIVE_WORLDGEN_LIBRARY` names, or the build the install script or `build:native` put in
the package. Finding it builds and downloads nothing.

#### Parameters

##### options?

[`LocateOptions`](https://jsprismarine.dev/api/@jsprismarine/native-library/NativeLibrary/index.md#locateoptions)

The environment, package, platform and manifest; the defaults are this process's.

#### Returns

`string`

The file's path.

#### Throws

When there is no file, or it is neither the published build nor a local one.

***

### locateLibrary()

> **locateLibrary**(`options?`): `string`

Defined in: [script-host/src/library.ts:64](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/library.ts#L64)

Where the library for this machine is, checked against its published digest: the file
`JSP_SCRIPT_HOST_LIBRARY` names, or the build the install script or `build:native` put in the
package. Finding it builds and downloads nothing.

#### Parameters

##### options?

[`LocateOptions`](https://jsprismarine.dev/api/@jsprismarine/native-library/NativeLibrary/index.md#locateoptions)

The environment, package, platform and manifest; the defaults are this process's.

#### Returns

`string`

The file's path.

#### Throws

When there is no file, or it is neither the published build nor a local one.

***

### packageRoot()

> **packageRoot**(): `string`

Defined in: [library.ts:12](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/library.ts#L12)

The package's root: one level above this file in both `src/` and `dist/`.

#### Returns

`string`

***

### packageRoot()

> **packageRoot**(): `string`

Defined in: [script-host/src/library.ts:13](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/library.ts#L13)

The package's root: one level above this file in both `src/` and `dist/`.

#### Returns

`string`

***

### sharedLibraryName()

> **sharedLibraryName**(`platform?`): `string`

Defined in: [script-host/src/library.ts:71](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/library.ts#L71)

The file name of the shared library on an operating system.

#### Parameters

##### platform?

`Platform`

The operating system, as `process.platform` names it.

#### Returns

`string`

The file name.

***

### verifyLibrary()

> **verifyLibrary**(`path`, `platform`, `manifest`): `void`

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

Checks a library file against the digest the manifest publishes for the platform, or the one a
local `build:native` recorded beside it.

#### Parameters

##### path

`string`

The file.

##### platform

`string`

The platform key.

##### manifest

[`NativeManifest`](https://jsprismarine.dev/api/@jsprismarine/native-library/manifest/index.md#nativemanifest)

The package's manifest.

#### Returns

`void`

#### Throws

When neither digest matches.
